
    +j              	          d dl Z d dlmZ d dlmZmZmZ d dlmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z% dZ&d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. ej/         ej0        g d          d          Z1de2de3fdZ4de5ej(                 de6dz  de2de3e
         dz  fdZ7de5ej(                 de	dej8        fd Z9 G d! d"ej(                  Z: G d# d$ej(                  Z; G d% d&e          Z<de<fd'Z=dS )(    N)override)IOComfyExtensionInput)Luma2GenerationLuma2GenerationRequestLuma2ImageRefLumaAspectRatioLumaCharacterRefLumaConceptChainLumaGenerationLumaGenerationRequestLumaImageGenerationRequestLumaImageIdentityLumaImageModelLumaImageReferenceLumaIOLumaKeyframesLumaModifyImageRefLumaReferenceLumaReferenceChainLumaVideoModelLumaVideoModelOutputDurationLumaVideoOutputResolutionget_luma_concepts)ApiEndpointdownload_url_to_image_tensordownload_url_to_video_outputpoll_opsync_opupload_image_to_comfyapiupload_images_to_comfyapivalidate_stringi   d   c            
       r    e Zd Zedej        fd            Zeddej        de	de
dej        fd            ZdS )	LumaReferenceNodereturnc                    t          j        ddddt           j                            dd          t           j                            dd	d
d	dd          t          j        t          j                                      dd          gt          j        t          j                                      d          g          S )Nr'   zLuma Referencepartner/image/Lumaz@Holds an image and weight for use with Luma Generate Image node.imagezImage to use as reference.tooltipweight      ?        {Gz?zWeight of image reference.defaultminmaxstepr-   luma_refT)optionaldisplay_namenode_idr:   categorydescriptioninputsoutputs)	r   SchemaImager   FloatCustomr   LUMA_REFOutputclss    :/home/wildlama/comfy/ComfyUI/comfy_api_nodes/nodes_luma.pydefine_schemazLumaReferenceNode.define_schema,   s    y'))Z8    8    	&/**00! 1  $ Yv//66J6OOP/
 
 
 	
    Nr+   r.   r7   c           	          ||                                 }nt                      }|                    t          |t	          |d                               t          j        |          S )N   r+   r.   )cloner   addr   roundr   
NodeOutput)rH   r+   r.   r7   s       rI   executezLumaReferenceNode.executeH   s]    ~~''HH)++H]uVQ7G7GHHHIII}X&&&rK   N)__name__
__module____qualname__classmethodr   rA   rJ   torchTensorfloatr   rR   rS    rK   rI   r'   r'   +   s        
bi 
 
 
 [
6 ' 'EL '% 'CU 'acan ' ' ' [' ' 'rK   r'   c                   r    e Zd Zedej        fd            Ze	 d
dedededededej	        fd	            Z
dS )LumaConceptsNoder(   c                 n   t          j        ddddt           j                            dt	          d                    t           j                            d	t	          d                    t           j                            d
t	          d                    t           j                            dt	          d                    t          j        t          j                                      ddd          gt          j        t          j                                      d          g          S )Nr^   zLuma Conceptspartner/video/LumazNCamera Concepts for use with Luma Text to Video and Luma Image to Video nodes.concept1T)include_noneoptionsconcept2concept3concept4luma_conceptsz8Optional Camera Concepts to add to the ones chosen here.r-   r8   r9   r;   )	r   rA   Combor   r   rD   r   LUMA_CONCEPTSrF   rG   s    rI   rJ   zLumaConceptsNode.define_schemaS   s,   y&()h-4@@@    -4@@@    -4@@@    -4@@@    	&.//55#V! 6  #. Yv344;;;YYZ9
 
 
 	
rK   Nra   re   rf   rg   rh   c                     t          ||||g          }||                    |          }t          j        |          S )N)str_list)r   clone_and_merger   rR   )rH   ra   re   rf   rg   rh   chains          rI   rS   zLumaConceptsNode.executet   sF     !8Xx*RSSS$!11%88E}U###rK   rT   )rU   rV   rW   rX   r   rA   rJ   strr   rR   rS   r\   rK   rI   r^   r^   R   s        
bi 
 
 
 [
@  +/$ $$ $ 	$
 $ ($ 
$ $ $ [$ $ $rK   r^   c                       e Zd Zedej        fd            Ze	 	 	 ddedededede	dz  d	e
j        dz  d
e
j        dz  dej        fd            Zede	defd            Zed	e
j        defd            ZdS )LumaImageGenerationNoder(   c                    t          j        ddddt           j                            dddd	          t           j                            d
t
                    t           j                            dt          t          j                  t           j                            dddddd          t           j	                            dddddd          t          j
        t          j                                      ddd          t           j                            ddd          t           j                            ddd          gt           j                                        gt           j        j        t           j        j        t           j        j        gdt          j        t          j        d
g           d!"          #	  	        S )$NLumaImageNodezLuma Text to Imager*   z@Generates images synchronously based on prompt and aspect ratio.promptT Prompt for the image generation	multiliner3   r-   modelrc   aspect_ratiord   r3   seedr       `Seed to determine if node should re-run; actual results are nondeterministic regardless of seed.r3   r4   r5   control_after_generater-   style_image_weightr/   r0   r1   z:Weight of style image. Ignored if no style_image provided.r2   image_luma_refzkLuma Reference node connection to influence generation with input images; up to 4 images can be considered.ri   style_imagez1Style reference image; only 1 image will be used.character_imagezYCharacter reference images; can be a batch of multiple, up to 4 images can be considered.widgetsV  
                (
                  $m := widgets.model;
                  $contains($m,"photon-flash-1")
                    ? {"type":"usd","usd":0.0027}
                    : $contains($m,"photon-1")
                      ? {"type":"usd","usd":0.0104}
                      : {"type":"usd","usd":0.0246}
                )
                
depends_onexpr	r<   r:   r=   r>   r?   r@   hiddenis_api_nodeprice_badge)r   rA   Stringr   rj   r   r
   
ratio_16_9IntrC   rD   r   rE   rB   rF   Hiddenauth_token_comfy_orgapi_key_comfy_org	unique_id
PriceBadgePriceBadgeDependsrG   s    rI   rJ   z%LumaImageGenerationNode.define_schema   s   y#-)Z	"=	     *    "++6   
 *+/~    (X    	&/**00$ J! 1  
 !O!   
 %w!   U/` X__&&'	.	+	#
 /	BBB	  yI
 I
 I
 I	
rK   Nru   rz   r{   r   r   r   r   c	                 n  K   t          |dd           d }	||                     |d           d {V }	d }
||                     ||           d {V }
d }|6t          | |d           d {V }t	          t          |          	          }t          | t          d
d          t          t          ||||	|
|                     d {V }t          | t          d|j                   t          d            d {V }t          j        t          |j        j                   d {V           S )NT   strip_whitespace
min_length   max_refs)r.   
max_images)images)	identity0/proxy/luma/generations/imagePOSTpathmethod)ru   rz   r{   	image_ref	style_refcharacter_refresponse_modeldata/proxy/luma/generations/r   c                     | j         S rT   statexs    rI   <lambda>z1LumaImageGenerationNode.execute.<locals>.<lambda>       qw rK   r   status_extractor)r#   _convert_luma_refs_convert_style_imager"   r   r   r    r   r   r   r   idr   rR   r   assetsr+   )rH   ru   rz   r{   r}   r   r   r   r   api_image_refapi_style_refr   download_urlsresponse_apiresponse_polls                  rI   rS   zLumaImageGenerationNode.execute   s      	!DDDD%"%"8"8RS"8"T"TTTTTTTM""%":":;Oa":"b"bbbbbbbM&";C]^"_"_"_______M,7HP]7^7^7^___M$<VLLL)+)''+  	
 
 
 
 
 
 
 
 
 &IIIJJJ)..	
 
 
 
 
 
 
 
 
 }#?@T@Z#[#[[[[[[[\\\rK   r7   r   c                    K   g }d}|j         D ]G}t          | |j        d           d {V }|                    |d                    |dz  }||k    r nH|                    ||          S )Nr      r   )r   r   )refsr"   r+   appendcreate_api_model)rH   r7   r   	luma_urls	ref_countrefr   s          rI   r   z*LumaImageGenerationNode._convert_luma_refs  s      		= 	 	C";CWX"Y"Y"YYYYYYYM]1-...NIH$$ %((y8(TTTrK   r.   c                 ~   K   t          t          ||                    }|                     |d           d {V S )NrN   )	first_refr   r   )r   r   r   )rH   r   r.   ro   s       rI   r   z,LumaImageGenerationNode._convert_style_image  sO      "]U[-\-\-\]]]++EA+>>>>>>>>>rK   NNN)rU   rV   rW   rX   r   rA   rJ   rp   r[   r   rY   rZ   rR   rS   intr   r   r\   rK   rI   rr   rr      sG       J
bi J
 J
 J
 [J
X  59+//3-] -]-] -] 	-] "-] +T1-] \D(-] ,-] 
-] -] -] [-]^ 	U0B 	Uc 	U 	U 	U [	U ?U\ ?5 ? ? ? [? ? ?rK   rr   c                   t    e Zd Zedej        fd            Zedededej	        de
dej        f
d            ZdS )	LumaImageModifyNoder(   c                    t          j        ddddt           j                            d          t           j                            dddd	
          t           j                            dddddd          t           j                            dt                    t           j                            dddddd          gt           j        	                                gt           j
        j        t           j
        j        t           j
        j        gdt          j        t          j        dg          d          	  	        S )Nr   zLuma Image to Imager*   z?Modifies images synchronously based on prompt and aspect ratio.r+   ru   Trv   rw   rx   image_weightg?r0   \(\?r1   zLWeight of the image; the closer to 1.0, the less the image will be modified.r2   rz   rc   r}   r   r~   r   r   r   r   r   r   )r   rA   rB   r   r   rC   rj   r   r   rF   r   r   r   r   r   r   rG   s    rI   rJ   z!LumaImageModifyNode.define_schema  sC   y).)Y  	"=	     "j    *    *+/~   -> X__&&'	.	+	#
 /	BBB	  W8
 8
 8
 8	
rK   ru   rz   r+   r   c                   K   t          | |d           d {V }|d         }t          | t          dd          t          t	          ||t          |t          t          t          d|z
  d          d	          d
                                         d {V }t          | t          d|j
                   t          d            d {V }	t          j        t          |	j        j                   d {V           S )Nr   r   r   r   r   r   r/   r   r0   rM   )urlr.   )ru   rz   modify_image_refr   r   r   c                     | j         S rT   r   r   s    rI   r   z-LumaImageModifyNode.execute.<locals>.<lambda>k  r   rK   r   )r"   r    r   r   r   r   rQ   r5   r4   r   r   r   rR   r   r   r+   )
rH   ru   rz   r+   r   r}   r   	image_urlr   r   s
             rI   rS   zLumaImageModifyNode.executeP  sa      8UqQQQQQQQQQ!!$	$<VLLL)+!3!%Cl8JD4Q4QSV0W0WYZ*[*[" " "  	
 
 
 
 
 
 
 
 
 &IIIJJJ)..	
 
 
 
 
 
 
 
 
 }#?@T@Z#[#[[[[[[[\\\rK   N)rU   rV   rW   rX   r   rA   rJ   rp   rY   rZ   r[   rR   rS   r\   rK   rI   r   r     s        9
bi 9
 9
 9
 [9
v ]] ] |	]
 ] 
] ] ] [] ] ]rK   r   c                       e Zd Zedej        fd            Ze	 ddededededed	ed
e	dz  dej
        fd            ZdS )LumaTextToVideoGenerationNoder(   c                 f   t          j        ddddt           j                            dddd	          t           j                            d
t
                    t           j                            dt          t          j                  t           j                            dt          t          j	                  t           j                            dt                    t           j                            dd          t           j                            dddddd          t          j        t          j                                      ddd          gt           j                                        gt           j        j        t           j        j        t           j        j        gdt,          	  	        S )NLumaVideoNodezLuma Text to Videor`   z?Generates videos synchronously based on prompt and output_size.ru   Trv   Prompt for the video generationrx   rz   rc   r{   r|   
resolutiondurationloopFr3   r}   r   r~   r   r   rh   MOptional Camera Concepts to dictate camera motion via the Luma Concepts node.ri   r   )r   rA   r   r   rj   r   r
   r   r   res_540pr   Booleanr   rD   r   rk   VideorF   r   r   r   r   PRICE_BADGE_VIDEOrG   s    rI   rJ   z+LumaTextToVideoGenerationNode.define_schemaq  s   y#-)Y	"=	     *    "++6   
  55>   
 8    
  ! !   *+/~    	&.//55#k! 6  K*V X__&&'	.	+	#
 )o8
 8
 8
 8	
rK   Nru   rz   r{   r   r   r   rh   c	                    K   t          |dd           |t          j        k    r|nd }|t          j        k    r|nd }t          | t	          dd          t
          t          |||||||r|                                nd                      d {V }	t          | t	          d	|	j	         
          t
          d t                     d {V }
t          j        t          |
j        j                   d {V           S )NFr   r   /proxy/luma/generationsr   r   )ru   rz   r   r{   r   r   conceptsr   r   r   c                     | j         S rT   r   r   s    rI   r   z7LumaTextToVideoGenerationNode.execute.<locals>.<lambda>  r   rK   )r   r   estimated_duration)r#   r   ray_1_6r    r   r   r   r   r   r   LUMA_T2V_AVERAGE_DURATIONr   rR   r   r   video)rH   ru   rz   r{   r   r   r   r}   rh   r   r   s              rI   rS   z%LumaTextToVideoGenerationNode.execute  s_      	1EEEE$(>>>88D#(N,B#B#BZZ
$6vFFF)&%)!=JT77999PT  	
 
 
 
 
 
 
 
 
 &IIIJJJ)..8
 
 
 
 
 
 
 
 
 }#?@T@Z#[#[[[[[[[\\\rK   rT   )rU   rV   rW   rX   r   rA   rJ   rp   boolr   rR   rS   r\   rK   rI   r   r   p  s        9
bi 9
 9
 9
 [9
v  26$] $]$] $] 	$]
 $] $] $] ($.$] 
$] $] $] [$] $] $]rK   r   c                       e Zd Zedej        fd            Ze	 	 	 ddededededed	e	j
        d
e	j
        dedej        fd            Ze	 	 dd	e	j
        d
e	j
        fd            ZdS )LumaImageToVideoGenerationNoder(   c                    t          j        ddddt           j                            dddd	          t           j                            d
t
                    t           j                            dt          t          j                  t           j                            dd t          D                       t           j	                            dd          t           j
                            dddddd          t           j                            ddd          t           j                            ddd          t          j        t          j                                      ddd          g	t           j                                        gt           j        j        t           j        j        t           j        j        gdt*          	  	        S ) NLumaImageToVideoNodezLuma Image to Videor`   zNGenerates videos synchronously based on prompt, input images, and output_size.ru   Trv   r   rx   rz   rc   r   r|   r   c                     g | ]	}|j         
S r\   )value).0durs     rI   
<listcomp>z@LumaImageToVideoGenerationNode.define_schema.<locals>.<listcomp>  s    OOO3SYOOOrK   r   Fr   r}   r   r~   r   r   first_imagezFirst frame of generated video.ri   
last_imagezLast frame of generated video.rh   r   r   )r   rA   r   r   rj   r   r   r   r   r   r   rB   rD   r   rk   r   rF   r   r   r   r   r   rG   s    rI   rJ   z,LumaImageToVideoGenerationNode.define_schema  s   y*.)h	"=	     *     55>   
 OO2NOOO    
  ! !   *+/~    !=!   
  <!   
 	&.//55#k! 6  _4j X__&&'	.	+	#
 )CB
 B
 B
 B	
rK   Nru   rz   r   r   r   r   r   rh   c
                 P  K   ||t          d          |                     ||           d {V }
|t          j        k    r|nd }|t          j        k    r|nd }t	          | t          dd          t          t          ||t          j	        ||||
|	r|	
                                nd                      d {V }t          | t          d|j                   t          d	 t          
           d {V }t          j        t!          |j        j                   d {V           S )Nz=At least one of first_image and last_image requires an input.r   r   r   )ru   rz   r{   r   r   r   	keyframesr   r   r   r   c                     | j         S rT   r   r   s    rI   r   z8LumaImageToVideoGenerationNode.execute.<locals>.<lambda>A  r   rK   )poll_endpointr   r   r   )	Exception_convert_to_keyframesr   r   r    r   r   r   r
   r   r   r   r   LUMA_I2V_AVERAGE_DURATIONr   rR   r   r   r   )rH   ru   rz   r   r   r   r}   r   r   rh   r   r   r   s                rI   rS   z&LumaImageToVideoGenerationNode.execute  s      :#5[\\\33KLLLLLLLL	$(>>>88D#(N,B#B#BZZ
$6vFFF)&,7%!#=JT77999PT	 	 		
 
 
 
 
 
 
 
 
 &%+Wlo+W+WXXX)..8
 
 
 
 
 
 
 
 
 }#?@T@Z#[#[[[[[[[\\\rK   c                    K   ||d S d }d }|/t          | |d           d {V }t          d|d                   }|/t          | |d           d {V }t          d|d                   }t          ||          S )Nr   r   r+   r   )typer   )frame0frame1)r"   r   r   )rH   r   r   r  r  r   s         rI   r  z4LumaImageToVideoGenerationNode._convert_to_keyframesF  s       :#54"";CYZ"["["[[[[[[[M'W-:JKKKF!";CXY"Z"Z"ZZZZZZZM'W-:JKKKFF6::::rK   r   )NN)rU   rV   rW   rX   r   rA   rJ   rp   r   rY   rZ   r   rR   rS   r  r\   rK   rI   r   r     s!       C
bi C
 C
 C
 [C
J  %)#'*.'] ']'] '] 	']
 '] '] \'] L'] ('] 
'] '] '] [']R  %)#'; ;\; L; ; ; [; ; ;rK   r   )rz   r   r   r   a  
    (
      $p := {
        "ray-flash-2": {
          "5s": {"4k":3.13,"1080p":0.79,"720p":0.34,"540p":0.2},
          "9s": {"4k":5.65,"1080p":1.42,"720p":0.61,"540p":0.36}
        },
        "ray-2": {
          "5s": {"4k":9.11,"1080p":2.27,"720p":1.02,"540p":0.57},
          "9s": {"4k":16.4,"1080p":4.1,"720p":1.83,"540p":1.03}
        }
      };

      $m := widgets.model;
      $d := widgets.duration;
      $r := widgets.resolution;

      $modelKey :=
        $contains($m,"ray-flash-2") ? "ray-flash-2" :
        $contains($m,"ray-2") ? "ray-2" :
        $contains($m,"ray-1-6") ? "ray-1-6" :
        "other";

      $durKey := $contains($d,"5s") ? "5s" : $contains($d,"9s") ? "9s" : "";
      $resKey :=
        $contains($r,"4k") ? "4k" :
        $contains($r,"1080p") ? "1080p" :
        $contains($r,"720p") ? "720p" :
        $contains($r,"540p") ? "540p" : "";

      $modelPrices := $lookup($p, $modelKey);
      $durPrices := $lookup($modelPrices, $durKey);
      $v := $lookup($durPrices, $resKey);

      $price :=
        ($modelKey = "ray-1-6") ? 0.5 :
        ($modelKey = "other") ? 0.79 :
        ($exists($v) ? $v : 0.79);

      {"type":"usd","usd": $price}
    )
    r   max_image_refsr(   c                    t           j                            dddgdd          t           j                            ddd	          t           j                            d
t           j                            t           j                            d          d t          d| dz             D             d          dd|  d          gS )NstyleautomangazStyle preset. 'auto' picks based on the prompt; 'manga' applies a manga/anime aesthetic and requires a portrait aspect ratio (2:3, 9:16, 1:2, 1:3).rd   r3   r-   
web_searchFz7Search the web for visual references before generating.)r3   r-   r   r+   c                     g | ]}d | S )image_r\   )r   is     rI   r   z-_luma2_uni1_common_inputs.<locals>.<listcomp>  s    JJJ|||JJJrK   r   r   )namesr4   TzUp to z- reference images for style/content guidance.)templater8   r-   )r   rj   r   r   AutogrowTemplateNamesrB   ranger  s    rI   _luma2_uni1_common_inputsr    s    
W%2	 	 	
 	
 	
M 	 	
 	

 	[..w''JJU1nq6H-I-IJJJ /  
 Z^ZZZ 	 		
 		
 rK   rH   r   	max_countc                    K   |sd S g }|D ]A}t          | ||                    d {V }|                    t          |                     Bt          |          |k    rt	          d| d          |pd S )Nr   zMaximum z reference images are allowed.)r!   r   r	   len
ValueError)rH   r   r  outkeyr   s         rI   _luma2_upload_image_refsr    s      
  t!C + +,S$s)<<<<<<<<

=S)))****
3xx)MIMMMNNN;$rK   requestc                   K   t          | t          dd          t          |           d {V }|j        st	          d          t          | t          d|j         d          t          d d	 
           d {V }|j        s|j        pd}t	          d|           |j        d         j        }|st	          d          t          |           d {V S )Nz/proxy/luma_2/generationsr   r   r   z*Luma 2 API did not return a generation id.z/proxy/luma_2/generations/GETc                     | j         S rT   r   rs    rI   r   z(_luma2_submit_and_poll.<locals>.<lambda>  s    17 rK   c                     d S rT   r\   r$  s    rI   r   z(_luma2_submit_and_poll.<locals>.<lambda>  s    T rK   )r   r   progress_extractorzno output returnedzLuma 2 generation failed: r   z2Luma 2 generation completed without an output URL.)
r    r   r   r   RuntimeErrorr   outputfailure_reasonr   r   )rH   r   initialfinalmsgr   s         rI   _luma2_submit_and_pollr.    sE      4VDDD&	        G : IGHHHBgjBB5QQQ&**)>        E < ?":&:===>>>
,q/
C QOPPP-c222222222rK   c            	       f    e Zd Zedej        fd            Zededede	dej
        fd            ZdS )rt   r(   c                 D   t          j        ddddt           j                            dddd	          t           j                            d
t           j                            dt           j                            dg ddd          gt          d                    t           j                            dt           j                            dg ddd          gt          d                    gd          t           j                            dddddd          gt           j	        
                                gt           j        j        t           j        j        t           j        j        gdt          j        t          j        d
gdg          d          	  	        S ) NLumaImageNode2zLuma UNI-1 Imager*   z5Generate images from text using the Luma UNI-1 model.ru   Trv   u;   Text description of the desired image. 1–6000 characters.rx   rz   uni-1r{   )
r
  z3:1z2:1z16:9z3:2z1:12:39:161:21:3r
  zJOutput image aspect ratio. 'auto' lets the model pick based on the prompt.r  	   r  	uni-1-maxzModel to use for generation.rd   r-   r}   r   _Seed controls whether the node should re-run; results are non-deterministic regardless of seed.r   model.image_refr   input_groupsa%  
                (
                  $m := widgets.model;
                  $refs := $lookup(inputGroups, "model.image_ref");
                  $base := $m = "uni-1-max" ? 0.1 : 0.0404;
                  {"type":"usd","usd": $round($base + 0.003 * $refs, 4)}
                )
                r   r   )r   rA   r   r   DynamicComboOptionrj   r  r   rB   rF   r   r   r   r   r   r   rG   s    rI   rJ   zLumaImageNode.define_schema  s   y$+)O	"Y	     %%..# "$2-& -& -& -3-J !/ !" !"& ";!!L!L!L' 0 ..' "$2-& -& -& -3-J !/ !" !"& ";!!L!L!L' 31d ;i & 5 5l "+/H   {FN X__&&'	.	+	#
 /	QbPcddd
 
 
g^
 ^
 ^
 ^	
rK   ru   rz   r}   c                   K   t          |dd           |d         }|d         }h d}|dk    r@|dk    r:||vr6t          d	d
                    t          |                     d| d          t	          ||d         d|dk    r|nd |dk    r|nd d|d         t          | |                    d          d           d {V           }t          j        t          | |           d {V           S )Nr   p  r   
max_lengthr{   r	  >   r5  r6  r3  r4  r  r
  z0'manga' style requires a portrait aspect ratio (z, z) or 'auto'; got 'z'.rz   r+   pngr  r   r7  r  )ru   rz   r  r{   r	  output_formatr  r   )
r#   r  joinsortedr   r  getr   rR   r.  )rH   ru   rz   r}   r{   r	  allowed_manga_ratiosr   s           rI   rS   zLumaImageNode.execute4  s[      	1>>>>^,g<<<G 6 6<Oc;c;c`IIf%9::;;` `O[` ` `   ).)5)?)?T F??%%\*4S%))K:P:P\]^^^^^^^^^	
 	
 	
 }#9#w#G#GGGGGGGHHHrK   N)rU   rV   rW   rX   r   rA   rJ   rp   dictr   rR   rS   r\   rK   rI   rt   rt     s        _
bi _
 _
 _
 [_
B II I 	I
 
I I I [I I IrK   rt   c                   t    e Zd Zedej        fd            Zedej        de	de
dedej        f
d            ZdS )	LumaImageEditNoder(   c                    t          j        ddddt           j                            dd          t           j                            dd	d
d          t           j                            dt           j                            dt          d                    t           j                            dt          d                    gd          t           j                            ddddd	d          gt           j        	                                gt           j
        j        t           j
        j        t           j
        j        gd	t          j        t          j        dgdg          d          	  	        S )NLumaImageEditNode2zLuma UNI-1 Image Editr*   zEEdit an existing image with a text prompt using the Luma UNI-1 model.sourcezSource image to edit.r,   ru   Trv   u5   Description of the desired edit. 1–6000 characters.rx   rz   r2     r  r8  zModel to use for editing.r9  r}   r   r:  r;  r   r<  r=  a'  
                (
                  $m := widgets.model;
                  $refs := $lookup(inputGroups, "model.image_ref");
                  $base := $m = "uni-1-max" ? 0.103 : 0.0434;
                  {"type":"usd","usd": $round($base + 0.003 * $refs, 4)}
                )
                r   r   )r   rA   rB   r   r   r?  r@  r  r   rF   r   r   r   r   r   r   rG   s    rI   rJ   zLumaImageEditNode.define_schemaS  s   y(0)_3    	"S	     %%..#5QGGG  ..'5QGGG 	 8 &   "+/H   3"F X__&&'	.	+	#
 /	QbPcddd
 
 
_:
 :
 :
 :	
rK   rQ  ru   rz   r}   c                 ~  K   t          |dd           t          ||d         dt          t          | |           d {V           |d         dk    r|d         nd d	|d
         t	          | |                    d          d           d {V           }t          j        t          | |           d {V           S )Nr   rB  rC  rz   
image_editr  r	  r
  rE  r  r   rR  rF  )ru   rz   r  rQ  r	  rG  r  r   )	r#   r   r	   r!   r  rJ  r   rR   r.  )rH   rQ  ru   rz   r}   r   s         rI   rS   zLumaImageEditNode.execute  s       	1>>>>(. +CC+P+P%P%P%P%P%P%PQQQ$)'Nf$<$<%..$\*4S%))K:P:P\]^^^^^^^^^	
 	
 	
 }#9#w#G#GGGGGGGHHHrK   N)rU   rV   rW   rX   r   rA   rJ   r   rB   rp   rL  r   rR   rS   r\   rK   rI   rN  rN  Q  s        ;
bi ;
 ;
 ;
 [;
z II I 	I
 I 
I I I [I I IrK   rN  c                   L    e Zd Zedeeej                          fd            ZdS )LumaExtensionr(   c                 j   K   t           t          t          t          t          t
          t          t          gS rT   )rr   r   r   r   r'   r^   rt   rN  )selfs    rI   get_node_listzLumaExtension.get_node_list  s*       $)*	
 		
rK   N)	rU   rV   rW   r   listr  r   	ComfyNoderY  r\   rK   rI   rV  rV    sE        

T$r|*<%= 

 

 

 X

 

 

rK   rV  c                  "   K   t                      S rT   )rV  r\   rK   rI   comfy_entrypointr]    s      ??rK   )>rY   typing_extensionsr   comfy_api.latestr   r   r   comfy_api_nodes.apis.lumar   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   comfy_api_nodes.utilr   r   r   r   r    r!   r"   r#   r   r  r[  r'   r^   rr   r   r   r   r   r   r   r   rZ  r  r  rL  r  rB   r.  rt   rN  rV  r]  r\   rK   rI   <module>rb     s~    & & & & & & 6 6 6 6 6 6 6 6 6 6                                             .	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	    $' $' $' $' $' $' $' $'N.$ .$ .$ .$ .$r| .$ .$ .$bM? M? M? M? M?bl M? M? M?`Z] Z] Z] Z] Z]", Z] Z] Z]zb] b] b] b] b]BL b] b] b]JA; A; A; A; A;R\ A; A; A;H "BM#r#,O,O,OPPP)
, , , ^c d    8	bl	
+  
-4	    3	bl	3#3 [3 3 3 38~I ~I ~I ~I ~IBL ~I ~I ~IBSI SI SI SI SI SI SI SIl
 
 
 
 
N 
 
 
      rK   