§
    ÈtºfÓ  ã                   ón   — d Z ddlmZ dZ G d„ de¦  «        Z G d„ de¦  «        Z G d„ d	e¦  «        Zd
S )zp
A core state-machine abstraction.

Perhaps something that could be replaced with or integrated into machinist.
é    )Úchainz
<no state>c                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )ÚNoTransitionzõ
    A finite state machine in C{state} has no transition for C{symbol}.

    @param state: the finite state machine's state at the time of the
        illegal transition.

    @param symbol: the input symbol for which no transition exists.
    c                 óœ   •— || _         || _        t          t          | ¦  «                             d                     ||¦  «        ¦  «         d S )Nzno transition for {} in {})ÚstateÚsymbolÚsuperÚ	ExceptionÚ__init__Úformat)Úselfr   r   Ú	__class__s      €úL/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/automat/_core.pyr   zNoTransition.__init__   sP   ø€ ØˆŒ
ØˆŒÝ�i˜ÑÔ×'Ò'Ø(×/Ò/°¸Ñ>Ô>ñ	
ô 	
ð 	
ð 	
ð 	
ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__)r   s   @r   r   r      sB   ø€ € € € € ðð ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
r   r   c                   ór   — e Zd ZdZd„ Zed„ ¦   «         Zej        d„ ¦   «         Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ ZdS )Ú	Automatonzr
    A declaration of a finite state machine.

    Note that this is not the machine itself; it is immutable.
    c                 óD   — t           | _        t          ¦   «         | _        dS )zJ
        Initialize the set of transitions and the initial state.
        N)Ú	_NO_STATEÚ_initialStateÚsetÚ_transitions©r   s    r   r   zAutomaton.__init__'   s   € õ 'ˆÔÝ™EœEˆÔÐÐr   c                 ó   — | j         S )z8
        Return this automaton's initial state.
        )r   r   s    r   ÚinitialStatezAutomaton.initialState/   s   € ð
 Ô!Ð!r   c                 ó~   — | j         t          ur't          d                     | j         ¦  «        ¦  «        ‚|| _         dS )z‚
        Set this automaton's initial state.  Raises a ValueError if
        this automaton already has an initial state.
        zinitial state already set to {}N)r   r   Ú
ValueErrorr   )r   r   s     r   r   zAutomaton.initialState7   sK   € ð Ô¥YÐ.Ð.ÝØ1×8Ò8¸Ô9KÑLÔLñNô Nð Nð #ˆÔÐÐr   c                 óØ   — | j         D ]6\  }}}}||k    r)||k    r#t          d                     ||¦  «        ¦  «        ‚Œ7| j                              |||t	          |¦  «        f¦  «         dS )z 
        Add the given transition to the outputSymbol. Raise ValueError if
        there is already a transition with the same inState and inputSymbol.
        z&already have transition from {} via {}N)r   r!   r   ÚaddÚtuple)	r   ÚinStateÚinputSymbolÚoutStateÚoutputSymbolsÚ	anInStateÚanInputSymbolÚ
anOutStateÚ_s	            r   ÚaddTransitionzAutomaton.addTransitionE   s˜   € ð :>Ô9Jð 	[ð 	[Ñ5ˆY˜ z°1Ø˜WÒ$Ð$¨¸+Ò)EÐ)EÝ Ø<×CÒCÀGÈ[ÑYÔYñ[ô [ð [øàÔ×ÒØ�k 8­U°=Ñ-AÔ-AÐBñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó*   — t          | j        ¦  «        S )z"
        All transitions.
        )Ú	frozensetr   r   s    r   ÚallTransitionszAutomaton.allTransitionsV   s   € õ ˜Ô*Ñ+Ô+Ð+r   c                 ó$   — d„ | j         D ¦   «         S )zG
        The full set of symbols acceptable to this automaton.
        c                 ó   — h | ]	\  }}}}|’Œ
S © r3   ©Ú.0r%   r&   r'   ÚoutputSymbols        r   ú	<setcomp>z*Automaton.inputAlphabet.<locals>.<setcomp>a   s9   € ð Eð Eð Eñ !/ ¨+°xØ!-ð ð Eð Eð Er   )r   r   s    r   ÚinputAlphabetzAutomaton.inputAlphabet]   s,   € ðEð EØ26Ô2CðEñ Eô Eð 	Er   c                 ób   — t          t          j        d„ | j        D ¦   «         ¦  «        ¦  «        S )zR
        The full set of symbols which can be produced by this automaton.
        c              3   ó$   K  — | ]\  }}}}|V — Œd S ©Nr3   )r5   r%   r&   r'   r(   s        r   ú	<genexpr>z+Automaton.outputAlphabet.<locals>.<genexpr>j   s>   è è € ð  ð  á?�˜+ x°ð ð ð  ð  ð  ð  ð  r   )r   r   Úfrom_iterabler   r   s    r   ÚoutputAlphabetzAutomaton.outputAlphabete   sG   € õ ÝÔð  ð  ð Ô$ð ñ  ô  ñ ô ñ
ô 
ð 	
r   c                 ób   — t          t          j        d„ | j        D ¦   «         ¦  «        ¦  «        S )zc
        All valid states; "Q" in the mathematical description of a state
        machine.
        c              3   ó(   K  — | ]\  }}}}||fV — Œd S r;   r3   r4   s        r   r<   z#Automaton.states.<locals>.<genexpr>x   sE   è è € ð  ð  ñ ?�˜+ x°ð ˜(Ð#ð ð  ð  ð  ð  ð  r   )r/   r   r=   r   r   s    r   ÚstateszAutomaton.statesr   sG   € õ
 ÝÔð  ð  ð Ô$ð	 ñ  ô  ñ ô ñ
ô 
ð 	
r   c                 ó|   — | j         D ]$\  }}}}||f||fk    r|t          |¦  «        fc S Œ%t          ||¬¦  «        ‚)zI
        A 2-tuple of (outState, outputSymbols) for inputSymbol.
        )r   r   )r   Úlistr   )r   r%   r&   r)   r*   r'   r(   s          r   ÚoutputForInputzAutomaton.outputForInput�   si   € ð
 *.Ô):ð	7ð 	7ñ &ˆY˜Ø�}Ø˜Ð%¨)°]Ð)CÒCÐCØ ¥$ }Ñ"5Ô"5Ð6Ð6Ð6Ð6ð Då °Ð=Ñ=Ô=Ð=r   N)r   r   r   r   r   Úpropertyr   Úsetterr-   r0   r8   r>   rA   rD   r3   r   r   r   r       sÄ   € € € € € ðð ð"ð "ð "ð ð"ð "ñ „Xð"ð Ôð
#ð 
#ñ Ôð
#ð
ð 
ð 
ð",ð ,ð ,ðEð Eð Eð

ð 

ð 

ð
ð 
ð 
ð>ð >ð >ð >ð >r   r   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚTransitionerzA
    The combination of a current state and an L{Automaton}.
    c                 ó0   — || _         || _        d | _        d S r;   )Ú
_automatonÚ_stateÚ_tracer)r   Ú	automatonr   s      r   r   zTransitioner.__init__‘   s   € Ø#ˆŒØ"ˆŒØˆŒˆˆr   c                 ó   — || _         d S r;   )rL   )r   Útracers     r   ÚsetTracezTransitioner.setTrace–   s   € ØˆŒˆˆr   c                 ó  — | j                              | j        |¦  «        \  }}d}| j        rR|                      | j                             ¦   «         |                     ¦   «         |                     ¦   «         ¦  «        }|| _        ||fS )zC
        Transition between states, returning any outputs.
        N)rJ   rD   rK   rL   Ú_name)r   r&   r'   r(   Ú	outTracers        r   Ú
transitionzTransitioner.transition™   s‹   € ð #'¤/×"@Ò"@ÀÄØALñ#Nô #NÑˆ�-àˆ	ØŒ<ð 	7ØŸš T¤[×%6Ò%6Ñ%8Ô%8Ø%0×%6Ò%6Ñ%8Ô%8Ø%-§^¢^Ñ%5Ô%5ñ7ô 7ˆIð ˆŒØ˜yÐ)Ð)r   N)r   r   r   r   r   rP   rT   r3   r   r   rH   rH   Œ   sK   € € € € € ðð ðð ð ð
ð ð ð*ð *ð *ð *ð *r   rH   N)	r   Ú	itertoolsr   r   r
   r   Úobjectr   rH   r3   r   r   ú<module>rW      s¹   ððð ð Ð Ð Ð Ð Ð à€	ð
ð 
ð 
ð 
ð 
�9ñ 
ô 
ð 
ð$i>ð i>ð i>ð i>ð i>�ñ i>ô i>ð i>ðX*ð *ð *ð *ð *�6ñ *ô *ð *ð *ð *r   