
    +jr0                     b   S SK Jr  S SKJr  S SKJrJr  S SKJr  \" 5       r	 " S S\R                  5      r " S S\R                  5      r " S	 S
\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\5      rS\4S  jrg!)"    )	TypedDict)override)ComfyExtensionio)_ioc                   P    \ rS rSr\S 5       r\S\R                  4S j5       rSr	g)NotNode
   c           
          [         R                  " SSSS/ SQ[         R                  R                  S5      /[         R                  R                  5       /S9$ )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_schemaNotNode.define_schema   sP    yy"&xI

  ) 

!!#
 	
    returnc                 8    [         R                  " U(       + 5      $ Nr   
NodeOutput)r"   r   s     r#   executeNotNode.execute   s    }}Y''r&    N)
__name__
__module____qualname____firstlineno__classmethodr$   r   r+   r,   __static_attributes__r.   r&   r#   r	   r	   
   s3    
 
 (r}} ( (r&   r	   c                   |    \ rS rSr\S 5       r\S\R                  R                  S\R                  4S j5       r
Srg)AndNode    c                 &   [         R                  R                  [         R                  R	                  S5      SSS9n[         R
                  " SSSSSS	/[         R                  R	                  S
US9/[         R                  R                  5       /S9$ )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"   rD   s     r#   r$   AndNode.define_schema!   s    ;;--**""7+ . 

 yy"& C!7+!!(X!> 

!!#
 	
r&   rB   r'   c                 \    [         R                  " [        UR                  5       5      5      $ r)   )r   r+   r@   rB   r"   rB   s     r#   r,   AndNode.execute6       }}S122r&   r.   Nr/   r0   r1   r2   r3   r$   r   rF   Typer+   r,   r4   r.   r&   r#   r6   r6       D    
 
( 3R[[-- 3"-- 3 3r&   r6   c                   |    \ rS rSr\S 5       r\S\R                  R                  S\R                  4S j5       r
Srg)OrNode;   c                 &   [         R                  R                  [         R                  R	                  S5      SSS9n[         R
                  " SSSSSS	/[         R                  R	                  S
US9/[         R                  R                  5       /S9$ )Nr   r9   r:   ComfyOrNodeOrr   zgLogical OR operation. Returns true if any of the values are truthy. Uses Python's rules for truthiness.anysomerB   rC   r   rE   rH   s     r#   r$   OrNode.define_schema<   s    ;;--**""7+ . 

 yy!& B!6?!!(X!> 

!!#
 	
r&   rB   r'   c                 \    [         R                  " [        UR                  5       5      5      $ r)   )r   r+   rW   rB   rK   s     r#   r,   OrNode.executeQ   rM   r&   r.   NrN   r.   r&   r#   rR   rR   ;   rP   r&   rR   c                   d    \ rS rSr\S 5       r\SS j5       r\S\R                  4S j5       r	Sr
g)	
SwitchNodeV   c                 `   [         R                  R                  S5      n[         R                  " SSSS[         R                  R                  S5      [         R                  R                  SUSS9[         R                  R                  SUSS9/[         R                  R                  US	S
9/S9$ )NswitchComfySwitchNodeSwitchr   Ton_false)rD   lazyon_trueoutputrD   r   r   r   r   is_experimentalr   r   r   	MatchTypeTemplater   r   r   r    rH   s     r#   r$   SwitchNode.define_schemaW   s    <<((2yy%!& 

  *"":t"L""9xd"K ##XH#M
 	
r&   Nc                 :    U(       a  Uc  S/$ U(       d  Uc  S/$ g g Nre   rc   r.   r"   r`   rc   re   s       r#   check_lazy_statusSwitchNode.check_lazy_statusi   s(    go;(*< +vr&   r'   c                 H    [         R                  " U(       a  U5      $ U5      $ r)   r*   r"   r`   re   rc   s       r#   r,   SwitchNode.executep   s    }}W==H==r&   r.   )NN)r/   r0   r1   r2   r3   r$   rq   r   r+   r,   r4   r.   r&   r#   r]   r]   V   sG    
 
"     >2== > >r&   r]   c                       \ rS rSr\S 5       r\\\4S j5       r\\\4S j5       r\\\4S\	R                  4S jj5       rSrg)	SoftSwitchNodeu   c                 d   [         R                  R                  S5      n[         R                  " SSSS[         R                  R                  S5      [         R                  R                  SUSSS9[         R                  R                  SUSSS9/[         R                  R                  US	S
9/S9$ )Nr`   ComfySoftSwitchNodezSoft Switchr   Trc   )rD   rd   optionalre   rf   rg   rh   rj   rH   s     r#   r$   SoftSwitchNode.define_schemav   s    <<((2yy)&& 

  *"":tVZ"[""9xdUY"Z ##XH#M
 	
r&   c                 j    U[         L a  S/$ U[         L a  S/$ U(       a  Uc  S/$ U(       d  Uc  S/$ g g ro   MISSINGrp   s       r#   rq    SoftSwitchNode.check_lazy_status   sJ     w;g<go;(*< +vr&   c                 *    U[         L a
  U[         L a  gg)NzDAt least one of on_false or on_true must be connected to Switch nodeTr~   rp   s       r#   validate_inputsSoftSwitchNode.validate_inputs   s     w7g#5Yr&   r'   c                     U[         L a  [        R                  " U5      $ U[         L a  [        R                  " U5      $ [        R                  " U(       a  U5      $ U5      $ r)   )r   r   r+   rt   s       r#   r,   SoftSwitchNode.execute   sI    g==**w==))}}W==H==r&   r.   N)r/   r0   r1   r2   r3   r$   r   rq   r   r   r+   r,   r4   r.   r&   r#   rw   rw   u   sj    
 
" 07     .5w   %,w >2== > >r&   rw   c                       \ rS rSrSr\S 5       r\SS\R                  R                  S\
S\4S jj5       r\SS\R                  R                  S\
S\R                  4S jj5       rS	rg
)CustomComboNode   z
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                     [         R                  " SSSS[         R                  R                  S/ S9/[         R                  R                  SS9[         R                  R                  S	S9/SS
9$ )NCustomCombozCustom Combo	utilitiesTchoiceoptionsSTRING)r   INDEX)r   r   r   ri   r   r   accept_all_inputs)r   r   Combor   Stringr    Intr!   s    r#   r$   CustomComboNode.define_schema   sg    yy!'  HHNN8RN89		  h 773 #
 	
r&   r   indexr'   c                     g)NTr.   r"   r   r   kwargss       r#   r   CustomComboNode.validate_inputs   s    
 r&   c                 .    [         R                  " X5      $ r)   r*   r   s       r#   r,   CustomComboNode.execute   s    }}V++r&   r.   N)r   )r/   r0   r1   r2   __doc__r3   r$   r   r   rO   intboolr   r+   r,   r4   r.   r&   r#   r   r      s     
 
 RXX]] 3 QU   ,RXX]] ,3 , , ,r&   r   c                   j    \ rS rSr " S S\5      r\S 5       r\S\S\R                  4S j5       r
Srg	)

DCTestNode   c                   v    \ rS rSr% \\S'   \\S'   \\S'   \R                  R                  \S'   \
\   \S'   Srg)	DCTestNode.DCValues   combostringintegerimagesubcombor.   N)r/   r0   r1   r2   str__annotations__r   r   ImagerO   dictr4   r.   r&   r#   DCValuesr      s)    
xx}}s)r&   r   c                    [         R                  " SSSS[         R                  R                  S[         R                  R	                  S[         R
                  R                  S5      /5      [         R                  R	                  S[         R                  R                  S	5      /5      [         R                  R	                  S
[         R                  R                  S5      /5      [         R                  R	                  S[         R                  R                  S[         R                  R	                  S[         R                  R                  S5      [         R                  R                  S5      /5      [         R                  R	                  S[         R                  R                  SSS9/5      /S9/5      /S9/[         R                  R                  5       /S9$ )Nr   DCTestr   Tr   option1r   option2r   option3r   option4r   opt1float_xfloat_yopt2mask1)r{   r   )r   r   r   is_output_noder   r   )r   r   DynamicCombor   Optionr   r   r   FloatMaskr   r    r!   s    r#   r$   DCTestNode.define_schema   sX   yy !&OO))'&&y299??83L2MN&&y266<<	3J2KL&&y288>>'3J2KL&&yOO))*..vy8QSUS[S[SaSabkSl7mn..vgX\8]7^_?) 3 		<) 
 
 ZZ&&()!
 	
r&   r   r'   c                 "   US   nUS:X  a  [         R                  " US   5      $ US:X  a  [         R                  " US   5      $ US:X  a  [         R                  " US   5      $ US:X  a  [         R                  " US	    5      $ [        S
U 35      e)Nr   r   r   r   r   r   r   r   r   zInvalid combo: )r   r+   
ValueError)r"   r   	combo_vals      r#   r,   DCTestNode.execute   s    'N		!==x11)#==y!122)#==w00)#==E*$5#688yk:;;r&   r.   N)r/   r0   r1   r2   r   r   r3   r$   r   r+   r,   r4   r.   r&   r#   r   r      sH    9  
 
( <H < < <r&   r   c                   |    \ rS rSr\S 5       r\S\R                  R                  S\	R                  4S j5       rSrg)AutogrowNamesTestNode   c           
          [         R                  R                  [        R                  R                  S5      / SQS9n[        R                  " SSS[         R                  R                  SUS9/[        R                  R                  5       /S	9$ )
Nfloat)abc)r;   namesr   AutogrowNamesTestr   autogrowrC   r   r   r   r   r   )	r   rF   TemplateNamesr   r   r   r   r   r    rH   s     r#   r$   #AutogrowNamesTestNode.define_schema   st    <<--BHHNN74KSb-cyy+,&"":"A YY%%'(
 	
r&   r   r'   c                     [        UR                  5       5      nSR                  U Vs/ s H  n[        U5      PM     sn5      n[        R
                  " U5      $ s  snf N,listrB   joinr   r   r+   r"   r   valsxcombineds        r#   r,   AutogrowNamesTestNode.execute  H    HOO%&88T2TSVT23}}X&& 3   Ar.   Nr/   r0   r1   r2   r3   r$   r   rF   rO   r   r+   r,   r4   r.   r&   r#   r   r      D    

 

 's||00 'R]] ' 'r&   r   c                   |    \ rS rSr\S 5       r\S\R                  R                  S\	R                  4S j5       rSrg)AutogrowPrefixTestNodei	  c           
          [         R                  R                  [        R                  R                  S5      SSSS9n[        R                  " SSS[         R                  R                  SUS	9/[        R                  R                  5       /S
9$ )Nr   r9   r
   )r;   r<   r=   maxr   AutogrowPrefixTestr   r   rC   r   )	r   rF   rG   r   r   r   r   r   r    rH   s     r#   r$   $AutogrowPrefixTestNode.define_schema
  sz    <<..RXX^^G5LU\bcik.lyy,-&"":"A YY%%'(
 	
r&   r   r'   c                     [        UR                  5       5      nSR                  U Vs/ s H  n[        U5      PM     sn5      n[        R
                  " U5      $ s  snf r   r   r   s        r#   r,   AutogrowPrefixTestNode.execute  r   r   r.   Nr   r.   r&   r#   r   r   	  r   r&   r   c                       \ rS rSr\S 5       r\S\R                  R                  S\R                  R                  S\R                  4S j5       r
Srg)	ComboOutputTestNodei  c                 "   [         R                  " SSS[         R                  R                  S/ SQS9[         R                  R                  S/ SQS9/[         R                  R	                  5       [         R                  R	                  5       /S	9$ )
NComboOptionTestNodeComboOptionTestr   r   )r   r   r   r   combo2)r   option5option6r   )r   r   r   r   r    r!   s    r#   r$   !ComboOutputTestNode.define_schema  sj    yy)*&HHNN74UNVHHNN85VNWYXX__&(9:
 	
r&   r   r   r'   c                 .    [         R                  " X5      $ r)   r*   )r"   r   r   s      r#   r,   ComboOutputTestNode.execute)  s    }}U++r&   r.   N)r/   r0   r1   r2   r3   r$   r   r   rO   r+   r,   r4   r.   r&   r#   r   r     sQ    
 
 ,BHHMM ,288== ,R]] , ,r&   r   c                   T    \ rS rSr\S 5       r\S\S\R                  4S j5       r	Sr
g)ConvertStringToComboNodei-  c           	          [         R                  " SSS/SS[         R                  R                  S5      /[         R                  R                  5       /S9$ )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$   &ConvertStringToComboNode.define_schema.  sH    yy.0/B2&IIOOH-.XX__&'
 	
r&   r   r'   c                 .    [         R                  " U5      $ r)   r*   )r"   r   s     r#   r,    ConvertStringToComboNode.execute9  s    }}V$$r&   r.   N)r/   r0   r1   r2   r3   r$   r   r   r+   r,   r4   r.   r&   r#   r   r   -  s:    
 
 %S %R]] % %r&   r   c                   T    \ rS rSr\S 5       r\S\S\R                  4S j5       r	Sr
g)InvertBooleanNodei=  c           	          [         R                  " S/ SQSS[         R                  R                  S5      /[         R                  R	                  5       /S9$ )Nr   )notr   r   r   zInvert Booleanr   booleanr   )r   r   r   r   r    r!   s    r#   r$   InvertBooleanNode.define_schema>  sG    yy'F)&JJ$$Y/0ZZ&&()
 	
r&   r   r'   c                 8    [         R                  " U(       + 5      $ r)   r*   )r"   r   s     r#   r,   InvertBooleanNode.executeI  s    }}[))r&   r.   N)r/   r0   r1   r2   r3   r$   r   r   r+   r,   r4   r.   r&   r#   r   r   =  s:    
 
 *d *r}} * *r&   r   c                   L    \ rS rSr\S\\\R                        4S j5       r	Sr
g)LogicExtensioniM  r'   c                 @   #    [         [        [        [        [        /$ 7fr)   )r]   r   r	   r6   rR   )selfs    r#   get_node_listLogicExtension.get_node_listN  s       
 	
s   r.   N)r/   r0   r1   r2   r   r   typer   	ComfyNoder  r4   r.   r&   r#   r  r  M  s)    
T$r||*<%= 
 
r&   r  r'   c                     #    [        5       $ 7fr)   )r  r.   r&   r#   comfy_entrypointr  _  s     s   N)typingr   typing_extensionsr   comfy_api.latestr   r   r   objectr   r  r	   r6   rR   r]   rw   r   r   r   r   r   r   r   r  r  r.   r&   r#   <module>r     s     & /   ((bll (,3bll 363R\\ 36> >>1>R\\ 1>h,bll ,@)< )<X'BLL '('R\\ '(,",, , %r|| % * * 
^ 
$ r&   