
    +jr0                     >   d dl mZ d dlmZ d dlmZmZ d dlmZ  e            Z	 G d dej
                  Z G d dej
                  Z G d	 d
ej
                  Z G d dej
                  Z G d dej
                  Z G d dej
                  Z G d dej
                  Z G d dej
                  Z G d dej
                  Z G d dej
                  Z G d dej
                  Z G d dej
                  Z G d de          Zdefd Zd!S )"    )	TypedDict)override)ComfyExtensionio)_ioc                   J    e Zd Zed             Zedej        fd            ZdS )NotNodec           
          t          j        ddddg dt           j                            d          gt           j                                        g          S )NComfyNotNodeNotutilities/logicz^Logical NOT operation. Returns true if the value is falsy. Uses Python's rules for truthiness.)inverttogglenegateflip booleanvaluenode_iddisplay_namecategorydescriptionsearch_aliasesinputsoutputs)r   SchemaAnyTypeInputBooleanOutputclss    8/home/wildlama/comfy/ComfyUI/comfy_extras/nodes_logic.pydefine_schemazNotNode.define_schema   s`    y"&xIII
  )) 
!!##
 
 
 	
    returnc                 ,    t          j        |           S Nr   
NodeOutput)r!   r   s     r"   executezNotNode.execute   s    }Y'''r$   N)__name__
__module____qualname__classmethodr#   r   r)   r*    r$   r"   r	   r	   
   sV        
 
 [
 (r} ( ( ( [( ( (r$   r	   c                   b    e Zd Zed             Zedej        j        dej        fd            Z	dS )AndNodec                 4   t           j                            t           j                            d          dd          }t          j        dddddd	gt           j                            d
|          gt           j                                        g          S )Nr      inputprefixminComfyAndNodeAndr   zhLogical AND operation. Returns true if all of the values are truthy. Uses Python's rules for truthiness.alleveryvaluestemplater   r   AutogrowTemplatePrefixr   r   r   r   r   r!   r>   s     r"   r#   zAndNode.define_schema!   s    ;--*""7++ . 
 

 y"& C!7+!!(X!>> 
!!##
 
 
 	
r$   r<   r%   c                 h    t          j        t          |                                                    S r'   )r   r)   r:   r<   r!   r<   s     r"   r*   zAndNode.execute6   "    }S11222r$   N
r+   r,   r-   r.   r#   r   r@   Typer)   r*   r/   r$   r"   r1   r1       b        
 
 [
( 3R[- 3"- 3 3 3 [3 3 3r$   r1   c                   b    e Zd Zed             Zedej        j        dej        fd            Z	dS )OrNodec                 4   t           j                            t           j                            d          dd          }t          j        dddddd	gt           j                            d
|          gt           j                                        g          S )Nr   r3   r4   ComfyOrNodeOrr   zgLogical OR operation. Returns true if any of the values are truthy. Uses Python's rules for truthiness.anysomer<   r=   r   r?   rB   s     r"   r#   zOrNode.define_schema<   s    ;--*""7++ . 
 

 y!& B!6?!!(X!>> 
!!##
 
 
 	
r$   r<   r%   c                 h    t          j        t          |                                                    S r'   )r   r)   rN   r<   rD   s     r"   r*   zOrNode.executeQ   rE   r$   NrF   r/   r$   r"   rJ   rJ   ;   rH   r$   rJ   c                   b    e Zd Zed             Zedd            Zedej        fd            ZdS )
SwitchNodec                 t   t           j                            d          }t          j        ddddt           j                            d          t           j                            d|d          t           j                            d|d          gt           j                            |d	
          g          S )NswitchComfySwitchNodeSwitchr   Ton_false)r>   lazyon_trueoutputr>   r   r   r   r   is_experimentalr   r   r   	MatchTypeTemplater   r   r   r   rB   s     r"   r#   zSwitchNode.define_schemaW   s    <((22y%!& 
  **"":t"LL""9xd"KK ##XH#MM
 
 
 	
r$   Nc                 &    |r|dgS |s|dgS d S d S NrY   rW   r/   r!   rT   rW   rY   s       r"   check_lazy_statuszSwitchNode.check_lazy_statusi   s;     	go; 	 (*<	  	 **r$   r%   c                 2    t          j        |r|n|          S r'   r(   r!   rT   rY   rW   s       r"   r*   zSwitchNode.executep   s    }<WWH===r$   )NN)	r+   r,   r-   r.   r#   rd   r   r)   r*   r/   r$   r"   rR   rR   V   sv        
 
 [
"       [  >2= > > > [> > >r$   rR   c                       e Zd Zed             Zeeefd            Zeeefd            Zeeefdej	        fd            Z
dS )SoftSwitchNodec                 x   t           j                            d          }t          j        ddddt           j                            d          t           j                            d|dd          t           j                            d|dd          gt           j                            |d	
          g          S )NrT   ComfySoftSwitchNodezSoft Switchr   TrW   )r>   rX   optionalrY   rZ   r[   r\   r^   rB   s     r"   r#   zSoftSwitchNode.define_schemav   s    <((22y)&& 
  **"":tVZ"[[""9xdUY"ZZ ##XH#MM
 
 
 	
r$   c                 V    |t           u rdgS |t           u rdgS |r|dgS |s|dgS d S d S rb   MISSINGrc   s       r"   rd   z SoftSwitchNode.check_lazy_status   sc     w;g< 	go; 	 (*<	  	 **r$   c                 .    |t           u r|t           u rdS dS )NzDAt least one of on_false or on_true must be connected to Switch nodeTrm   rc   s       r"   validate_inputszSoftSwitchNode.validate_inputs   s$     w7g#5#5YYtr$   r%   c                     |t           u rt          j        |          S |t           u rt          j        |          S t          j        |r|n|          S r'   )rn   r   r)   rf   s       r"   r*   zSoftSwitchNode.execute   sQ    g=***w=)))}<WWH===r$   N)r+   r,   r-   r.   r#   rn   rd   rp   r   r)   r*   r/   r$   r"   rh   rh   u   s        
 
 [
" 07       [  .5w    [ %,w > >2= > > > [> > >r$   rh   c                       e Zd ZdZed             Zed
dej        j        de	de
fd            Zed
dej        j        de	dej        fd            Zd	S )CustomComboNodez
    Frontend node that allows user to write their own options for a combo.
    This is here to make sure the node has a backend-representation to avoid some annoyances.
    c                     t          j        ddddt           j                            dg           gt           j                            d          t           j                            d	          gd
          S )NCustomCombozCustom Combo	utilitiesTchoiceoptionsSTRING)r   INDEX)r   r   r   r]   r   r   accept_all_inputs)r   r   Combor   Stringr   Intr    s    r"   r#   zCustomComboNode.define_schema   sr    y!'  HNN8RN889	  h 77733 #
 
 
 	
r$   r   rw   indexr%   c                     dS )NTr/   r!   rw   r   kwargss       r"   rp   zCustomComboNode.validate_inputs   s	    
 tr$   c                 ,    t          j        ||          S r'   r(   r   s       r"   r*   zCustomComboNode.execute   s    }VU+++r$   N)r   )r+   r,   r-   __doc__r.   r#   r   r}   rG   intboolrp   r)   r*   r/   r$   r"   rs   rs      s          
 
 [
  RX] 3 QU    [ , ,RX] ,3 , , , , [, , ,r$   rs   c                   j    e Zd Z G d de          Zed             Zededej        fd            Z	dS )
DCTestNodec                   b    e Zd ZU eed<   eed<   eed<   ej        j        ed<   e	e         ed<   dS )DCTestNode.DCValuescombostringintegerimagesubcomboN)
r+   r,   r-   str__annotations__r   r   ImagerG   dictr/   r$   r"   DCValuesr      sM         


x}s)r$   r   c                    t          j        ddddt           j                            dt           j                            dt           j                            d          g          t           j                            dt           j                            d	          g          t           j                            d
t           j                            d          g          t           j                            dt           j                            dt           j                            dt           j                            d          t           j                            d          g          t           j                            dt           j	                            dd          g          g          g          g          gt           j
                                        g          S )Nr   DCTestr   Tr   option1r   option2r   option3r   option4r   opt1float_xfloat_yopt2mask1)rk   rx   )r   r   r   is_output_noder   r   )r   r   DynamicCombor   Optionr~   r   r   FloatMaskr   r   r    s    r"   r#   zDCTestNode.define_schema   st   y !&O))'&&y29??83L3L2MNN&&y26<<	3J3J2KLL&&y28>>'3J3J2KLL&&yO))*..vy8Q8QSUS[SaSabkSlSl7mnn..vgX\8]8]7^__?)  3  		<) 
 
 
 Z&&(()!
 
 
 	
r$   r   r%   c                 8   |d         }|dk    rt          j        |d                   S |dk    rt          j        |d                   S |dk    rt          j        |d                   S |dk    rt          j        |d	                    S t          d
|           )Nr   r   r   r   r   r   r   r   r   zInvalid combo: )r   r)   
ValueError)r!   r   	combo_vals      r"   r*   zDCTestNode.execute   s    'N		!!=x111)##=y!1222)##=w000)##=E*$5!7888:y::;;;r$   N)
r+   r,   r-   r   r   r.   r#   r   r)   r*   r/   r$   r"   r   r      s            9    
 
 [
( <H < < < < [< < <r$   r   c                   b    e Zd Zed             Zedej        j        dej	        fd            Z
dS )AutogrowNamesTestNodec           	      .   t           j                            t          j                            d          g d          }t          j        dddt           j                            d|          gt          j                                        g	          S )
Nfloat)abc)r5   namesr   AutogrowNamesTestr   autogrowr=   r   r   r   r   r   )	r   r@   TemplateNamesr   r   r   r   r~   r   rB   s     r"   r#   z#AutogrowNamesTestNode.define_schema   s    <--BHNN74K4KSbSbSb-ccy+,&"":"AA Y%%''(
 
 
 	
r$   r   r%   c                     t          |                                          }d                    d |D                       }t          j        |          S )N,c                 ,    g | ]}t          |          S r/   r   .0xs     r"   
<listcomp>z1AutogrowNamesTestNode.execute.<locals>.<listcomp>      222SVV222r$   listr<   joinr   r)   r!   r   valscombineds       r"   r*   zAutogrowNamesTestNode.execute  I    HOO%%&&8822T22233}X&&&r$   Nr+   r,   r-   r.   r#   r   r@   rG   r   r)   r*   r/   r$   r"   r   r      b        

 

 [

 's|0 'R] ' ' ' [' ' 'r$   r   c                   b    e Zd Zed             Zedej        j        dej	        fd            Z
dS )AutogrowPrefixTestNodec           	      .   t           j                            t          j                            d          ddd          }t          j        dddt           j                            d|	          gt          j                                        g
          S )Nr   r3   
   )r5   r6   r7   maxr   AutogrowPrefixTestr   r   r=   r   )	r   r@   rA   r   r   r   r   r~   r   rB   s     r"   r#   z$AutogrowPrefixTestNode.define_schema
  s    <..RX^^G5L5LU\bcik.lly,-&"":"AA Y%%''(
 
 
 	
r$   r   r%   c                     t          |                                          }d                    d |D                       }t          j        |          S )Nr   c                 ,    g | ]}t          |          S r/   r   r   s     r"   r   z2AutogrowPrefixTestNode.execute.<locals>.<listcomp>  r   r$   r   r   s       r"   r*   zAutogrowPrefixTestNode.execute  r   r$   Nr   r/   r$   r"   r   r   	  r   r$   r   c                   z    e Zd Zed             Zedej        j        dej        j        dej        fd            Z	dS )ComboOutputTestNodec                 0   t          j        dddt           j                            dg d          t           j                            dg d          gt           j                                        t           j                                        g	          S )
NComboOptionTestNodeComboOptionTestr   r   )r   r   r   rx   combo2)r   option5option6r   )r   r   r}   r   r   r    s    r"   r#   z!ComboOutputTestNode.define_schema  s    y)*&HNN74U4U4UNVVHNN85V5V5VNWWYX__&&(9(9:
 
 
 	
r$   r   r   r%   c                 ,    t          j        ||          S r'   r(   )r!   r   r   s      r"   r*   zComboOutputTestNode.execute)  s    }UF+++r$   N)
r+   r,   r-   r.   r#   r   r}   rG   r)   r*   r/   r$   r"   r   r     sl        
 
 [
 ,BHM ,28= ,R] , , , [, , ,r$   r   c                   N    e Zd Zed             Zededej        fd            ZdS )ConvertStringToComboNodec           	          t          j        dddgddt           j                            d          gt           j                                        g          S )Nr   zstring to dropdownztext to combozConvert String to Combor   r   r   r   r   r   r   r   )r   r   r~   r   r}   r   r    s    r"   r#   z&ConvertStringToComboNode.define_schema.  sR    y.0/B2&IOOH--.X__&&'
 
 
 	
r$   r   r%   c                 *    t          j        |          S r'   r(   )r!   r   s     r"   r*   z ConvertStringToComboNode.execute9  s    }V$$$r$   N)	r+   r,   r-   r.   r#   r   r   r)   r*   r/   r$   r"   r   r   -  s]        
 
 [
 %S %R] % % % [% % %r$   r   c                   N    e Zd Zed             Zededej        fd            ZdS )InvertBooleanNodec           	          t          j        dg dddt           j                            d          gt           j                                        g          S )Nr   )notr   r   r   zInvert Booleanr   booleanr   )r   r   r   r   r   r    s    r"   r#   zInvertBooleanNode.define_schema>  sW    y'FFF)&J$$Y//0Z&&(()
 
 
 	
r$   r   r%   c                 ,    t          j        |           S r'   r(   )r!   r   s     r"   r*   zInvertBooleanNode.executeI  s    }[)))r$   N)	r+   r,   r-   r.   r#   r   r   r)   r*   r/   r$   r"   r   r   =  s]        
 
 [
 *d *r} * * * [* * *r$   r   c                   L    e Zd Zedeeej                          fd            ZdS )LogicExtensionr%   c                 F   K   t           t          t          t          t          gS r'   )rR   rs   r	   r1   rJ   )selfs    r"   get_node_listzLogicExtension.get_node_listN  s!       
 	
r$   N)	r+   r,   r-   r   r   typer   	ComfyNoder   r/   r$   r"   r   r   M  sE        
T$r|*<%= 
 
 
 X
 
 
r$   r   r%   c                  "   K   t                      S r'   )r   r/   r$   r"   comfy_entrypointr   _  s      r$   N)typingr   typing_extensionsr   comfy_api.latestr   r   r   objectrn   r   r	   r1   rJ   rR   rh   rs   r   r   r   r   r   r   r   r   r/   r$   r"   <module>r      s         & & & & & & / / / / / / / /             &((( ( ( ( (bl ( ( (,3 3 3 3 3bl 3 3 363 3 3 3 3R\ 3 3 36> > > > > > > >>1> 1> 1> 1> 1>R\ 1> 1> 1>h, , , , ,bl , , ,@)< )< )< )< )< )< )< )<X' ' ' ' 'BL ' ' '(' ' ' ' 'R\ ' ' '(, , , , ,", , , , % % % % %r| % % % * * * * * * * * 
 
 
 
 
^ 
 
 
$      r$   