+
    „°ñj  ã                   ó˜   € ^ RI t ^ RIHt ^ RIt^ RIt^ RIt^ RIHtH	t	 RR lt
 ! R R]	P                  4      t ! R R]4      tR	 R
 ltR# )é    N)Úoverride)ÚComfyExtensionÚioc                óº  € V P                   ^,          V P                   ^,          rC\        V\        W44      ,          R4      p\        V\        W5,          V,          4      V,          4      p\        V\        WE,          V,          4      V,          4      p\        P
                  P                  V R,          P                  R^4      WvRR4      P                  ^R4      # )zVResize (preserve aspect) so the long edge <= max_size, then snap each side to `stride`g      ð?ÚareaÚdisabled©ºNNNr
   r
   ºNé   Néÿÿÿÿ)ÚshapeÚminÚmaxÚroundÚcomfyÚutilsÚcommon_upscaleÚmovedim)ÚimageÚmax_sizeÚstrideÚhÚwÚscaleÚnhÚnws   &&&     Ú>C:\Ai_Coding\apps\studio\ComfyUI\comfy_extras\nodes_bernini.pyÚ_resize_long_edger   
   s¦   € à�;‰;�q�>˜5Ÿ;™; q�>€qÜ�œ3˜q›9Õ$ cÓ*€EÜ	ˆV”U˜1�9 vÕ-Ó.°Õ7Ó	8€BÜ	ˆV”U˜1�9 vÕ-Ó.°Õ7Ó	8€BÜ�;‰;×%Ñ% e¨KÕ&8×&@Ñ&@ÀÀQÓ&GÈÐQWÐYcÓd×lÑlÐmnÐprÓsÐsó    c                   óT   a € ] tR t^t o Rt]R 4       t]RV 3R lR ll4       tRtV t	R# )ÚBerniniConditioningaø  Bernini in-context conditioning for a Wan2.2-A14B model.

Attaches the VAE-encoded source video / reference images to the conditioning
source video first, then each reference image

The task is inferred from which inputs are connected:
  (nothing)                  -> t2v (text-to-video)
  source_video               -> v2v (video-to-video)
  source_video + ref_images  -> rv2v (reference-guided video editing)
  ref_images only            -> r2v (reference-to-video)
  source_video + ref_video   -> ads2v (insert image/video into video)

source_video is the edit base / canvas (resized to width x height).
reference_video is moving content to composite in.
Streams are ordered source_video, reference_video, then reference_images -> source_id (1, 2, 3, ...).
c                óN  € \         P                  ! R RRR\         P                  P                  R4      \         P                  P                  R4      \         P                  P                  R4      \         P
                  P                  RR^R	^R
7      \         P
                  P                  RR^R	^R
7      \         P
                  P                  R^Q^R	^R
7      \         P
                  P                  R^^RR7      \         P                  P                  RRRR7      \         P                  P                  RRRR7      \         P                  P                  RR\         P                  P                  \         P                  P                  RRR7      R^ ^R7      R7      \         P
                  P                  RR^R	^RR R!7      .\         P                  P                  RR"7      \         P                  P                  RR"7      \         P                  P                  R#R"7      .R$7      # )%r"   zBernini Conditioningzmodel/conditioning/berninia•  Conditioning node for Bernini in-context video/image conditioning. It can be used for the following tasks: t2v (text-to-video), v2v (video-to-video), rv2v (reference-guided video editing), r2v (reference-to-video), ads2v (insert image/video into video).Reference images injected as in-context tokens (r2v, rv2v) are encoded independently at their own native aspect ratio (long edge capped at ref_max_size)ÚpositiveÚnegativeÚvaeÚwidthi@  i    )Údefaultr   r   ÚstepÚheightià  ÚlengthÚ
batch_sizei   )r(   r   r   Úsource_videoTz[Source video to edit or restyle (v2v, rv2v). Resized to width/height and trimmed to length.)ÚoptionalÚtooltipÚreference_videoz.Video to insert into the source video (ads2v).Úreference_imagesÚreference_imagez<Reference image injected as an in-context token (r2v, rv2v).)r/   Úreference_image_)ÚinputÚprefixr   r   )r.   ÚtemplateÚref_max_sizeéP  z|Max size for the long edge of reference_video and reference_images. Resized with preserved aspect ratio and snapped to 16px.)r(   r   r   r)   r.   r/   )Údisplay_nameÚlatent)Únode_idr9   ÚcategoryÚdescriptionÚinputsÚoutputs)r   ÚSchemaÚConditioningÚInputÚVaeÚIntÚImageÚAutogrowÚTemplatePrefixÚOutputÚLatent)Úclss   &r   Údefine_schemaÚ!BerniniConditioning.define_schema%   sÄ  € ä�yŠyØ)Ø/Ø1ðkô —‘×%Ñ% jÓ1Ü—‘×%Ñ% jÓ1Ü—‘—‘˜UÓ#Ü—‘—‘˜W¨c°r¸tÈ"�ÓMÜ—‘—‘˜X¨s¸ÀÈ2�ÓNÜ—‘—‘˜X¨r°q¸dÈ�ÓKÜ—‘—‘˜\°1¸!À�ÓFÜ—‘—‘˜~¸ð  He�ó  gÜ—‘—‘Ð0¸4ÐJz�Ó|Ü—‘×!Ñ!Ð"4¸tÜŸ[™[×7Ñ7Ü Ÿh™hŸn™nÐ->ð  JH˜nó  JØ1°q¸að 8ó Að "ó Bô —‘—‘˜^°S¸bÀdÐQSÐ^bð Sð ó Uðô$ —‘×&Ñ&°JÐ&Ó?Ü—‘×&Ñ&°JÐ&Ó?Ü—	‘	× Ñ ¨hÐ Ó7ðô/
ð 	
r    Nc                ó4   <€ V ^8„  d   QhRS[ P                  /# ©é   Úreturn)r   Ú
NodeOutput)ÚformatÚ__classdict__s   "€r   Ú__annotate__Ú BerniniConditioning.__annotate__F   s*   ø€ ÷ Fñ Fñ  gi÷  gtñ  gtñ Fr    c                óÞ  € \         P                  ! V^V^,
          ^,          ^,           V^,          V^,          .\        P                  P	                  4       R7      p. pVew   \        P
                  P                  VRV1RRR3,          P                  R	^4      WERR4      P                  ^R	4      pVP                  VP                  VR
,          4      4       V	e7   \        V	RV V4      pVP                  VP                  VR
,          4      4       V
'       d‚   \        V
4       Fr  pV
V,          pVf   K  \        VP                  ^ ,          4       F@  p\        VVV^,            V4      pVP                  VP                  VR
,          4      4       KB  	  Kt  	  V'       d3   \        P                  ! VRV/4      p\        P                  ! VRV/4      p\         P"                  ! WRV/4      # )é   )ÚdeviceNr
   r   r   ÚcenterÚcontext_latentsÚsamplesr   r	   )ÚtorchÚzerosr   Úmodel_managementÚintermediate_devicer   r   r   ÚappendÚencoder   ÚsortedÚranger   Únode_helpersÚconditioning_set_valuesr   rQ   )rJ   r$   r%   r&   r'   r*   r+   r,   r-   r0   r1   r7   r:   ÚcontextÚvidÚref_vidÚnameÚimgsÚiÚimgs   &&&&&&&&&&&&        r   ÚexecuteÚBerniniConditioning.executeE   sÉ  € ä—’˜j¨"°¸µ
¸qÕ/@ÀAÕ.EÀvÐQRÅ{ÐTYÐ]^ÕT^Ð_Ôhm×h~Ñh~÷  iSñ  iSó  iUô  Vˆð ˆØÒ#Ü—+‘+×,Ñ,¨\¸'¸6¸'À1ÀaÈÐ:KÕ-L×-TÑ-TÐUWÐYZÓ-[Ð]bÐlrÐt|Ó}÷  Fñ  Fð  GHð  JLó  MˆCØ�N‰N˜3Ÿ:™: c¨+Õ&6Ó7Ô8àÒ&Ü'¨¸¸Ð(@À,ÓOˆGØ�N‰N˜3Ÿ:™: g¨kÕ&:Ó;Ô<÷ ÜÐ/Ö0�Ø'¨Õ-�Ø’<ÙÜ˜tŸz™z¨!�}Ö-�AÜ+¨D°°1°qµ5¨M¸<ÓH�CØ—N‘N 3§:¡:¨c°+Õ.>Ó#?Ö@ó .ñ	 1÷ Ü#×;Ò;¸HÐGXÐZaÐFbÓcˆHÜ#×;Ò;¸HÐGXÐZaÐFbÓcˆHä�}Š}˜X°)¸VÐ1DÓEÐEr    © )NNNr8   )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚclassmethodrK   rm   Ú__static_attributes__Ú__classdictcell__©rS   s   @r   r"   r"      s:   ø‡ € ñð" ñ
ó ð
ð> ÷Fñ Fó öFr    r"   c                   ó<   a € ] tR t^et o ]V 3R lR l4       tRtV tR# )ÚBerniniExtensionc                óT   <€ V ^8„  d   QhRS[ S[S[P                  ,          ,          /# rN   )ÚlistÚtyper   Ú	ComfyNode)rR   rS   s   "€r   rT   ÚBerniniExtension.__annotate__g   s"   ø€ ÷ &ñ &¡T©$©r¯|©|Õ*<Õ%=ñ &r    c              ƒ  ó   "  € \         .# 5i©N)r"   )Úselfs   &r   Úget_node_listÚBerniniExtension.get_node_listf   s   é € ä#Ð%Ð%ùs   ‚
ro   N)rp   rq   rr   rs   r   rƒ   rv   rw   rx   s   @r   rz   rz   e   s   ø‡ € Ø÷&ó ö&r    rz   c                ó$   € V ^8„  d   QhR\         /# rN   ©rz   )rR   s   "r   rT   rT   k   s   € ÷ ñ Ô 0ñ r    c               ƒ   ó   "  € \        4       # 5ir�   r†   ro   r    r   Úcomfy_entrypointrˆ   k   s   é € ÜÓÐùs   ‚)rW   )r\   Útyping_extensionsr   Úcomfy.model_managementr   Úcomfy.utilsrd   Úcomfy_api.latestr   r   r   r~   r"   rz   rˆ   ro   r    r   Ú<module>r�      sC   ðÛ Ý &ã Û Û ß /ôtôOF˜"Ÿ,™,ô OFôd&�~ô &÷r    