
    j                        d Z ddlmZ ddlmZ ddlmZ ddlmZ dddd	d
dZ	ddddddZ
d(dZd)d*dZd+dZd,dZd-dZd.d Zd/d&Zd'S )0zOAdapters from Retention Studio mechanism explainers into production shot plans.    )annotations)Path)Any_slugpattern_interruptproblemmechanism_revealtwistfollow_triggerr   r	   	mechanismr   r   cinematic_ai_videomechanism_animationkinetic_text_overlay	explainerdict[str, Any]returnstrc                \    t          | d                    dt          | d                    S )Npillar-titler   )r   s    W/home/agent/jarvis_runtime/autoshortsbot/AutoShortsBot/autoshorts/mechanism_pipeline.py_plan_idr      s0    Ih'((FF571C+D+DFFF    H   	voiceoverlimitintc                   d                     |                                           }t          |          |k    r|S |d |dz
                               dd          d                             d          }|                                r|                                d                                         dv rd                     |                                d d                                       d          }|                                r.|                                d                                         dv | dS )N    r   z.,;:>   dasderdiemitundvonoderdurchu   …)joinsplitlenrsplitrstriplower)r   r   cleaned	truncateds       r   _overlay_textr5      s   hhy(())G
7||u%!)$++C33A6==fEEI
//

 D	 1 1" 5 ; ; = =A| | |HHY__..ss344;;FCC	 //

 D	 1 1" 5 ; ; = =A| | |r   indexbeatc                    |d         }| t           |         |d         |d         t          |         t          |d                   |d         |d         |d         |d         t          |          dS )	Nr7   startendr   visualvisual_motion	sound_cue)scenepurposer9   r:   
asset_typeon_screen_textr   visual_directionr<   r=   retention_goal)BEAT_TO_PURPOSEBEAT_TO_ASSET_TYPEr5   _retention_goal)r6   r7   	beat_names      r   _scene_from_beatrH   )   su    VI"9-gE{(3'[(9::+& No.+&))44  r   rG   c                "    dddddd}||          S )NzLOpen a visual loop immediately; make the viewer need the hidden explanation.z6Make the surface-level interpretation feel incomplete.zGReveal the invisible system through moving layers, not narration alone.z.Reframe the obvious cause into the real cause.zBPromise the next hidden system without a generic like/follow plea.r    )rG   goalss     r   rF   rF   :   s*    kK^A^ E r   c                    d t          | d         d          D             }d | d         D             }t          |           | d         | d         | d         t          | d	                   ||d
dddddS )zKConvert a Retention Studio mechanism explainer into a motion-led shot plan.c                4    g | ]\  }}t          ||          S rJ   )rH   ).0r6   r7   s      r   
<listcomp>z-build_mechanism_shot_plan.<locals>.<listcomp>G   s'    ffftud++fffr   beatsr#   )r9   c                J    g | ] }t          |d                    |d         d!S )r9   r   )r9   text)r    rN   r7   s     r   rO   z-build_mechanism_shot_plan.<locals>.<listcomp>H   sA        d7m$$d;.?@@  r   seriesr   r   target_secondsr      !mechanism_reveal_motion_explainerzDlarge kinetic overlays; voiceover carries detail; no paragraph cards)static_card_limitvisual_change_every_secondsprimary_stylecaptions)idrT   r   r   estimated_secondscaption_beatsscenesfinal_render_intent)	enumerater   r    )r   r_   r^   s      r   build_mechanism_shot_planrb   E   s    ffySZI[cd?e?e?efffF g&  M
 y!!H%7#H% +;!<==&!"+,@^	 
  
  r   planc                D   g }| d         D ]z}|                     d|d          d|d          d|d          d|d	          d
|d          d|d          d|d          d|d          d|d          d|d          d|d                     {d                    |          }d                    d | d         D                       }| d         }d| d          d| d           d!| d"          d#| d$          d%| d&          d'| d(| d)|d*          d+|d,          d-|d.          d/|d0          dS )1Nr_   z
### Scene r>   u    — r?   z

- Timing: r9   u   s–r:   zs
- Asset type: r@   z
- On-screen text: rA   z
- Voiceover: r   z
- Visual direction: rB   z
- Visual motion: r<   z
- Sound cue: r=   z
- Retention goal: rC   z


c              3  @   K   | ]}d |d         dd|d          V  dS )z- r9   02dzs: rR   NrJ   rS   s     r   	<genexpr>z-format_mechanism_shot_plan.<locals>.<genexpr>l   s>      bbD?4=???f??bbbbbbr   r^   r`   z# r   z	

- ID: `r\   z`
- Series: rT   z
- Pillar: `r   z`
- Estimated duration: r]   zs

## Mechanism shot plan

z

## Caption beats

z/

## Final render intent

- Static card limit: rX   z 
- Visual change every seconds: rY   z
- Primary style: rZ   z
- Captions: r[   )appendr-   )rc   scene_blocksr>   r_   rP   intents         r   format_mechanism_shot_planrl   ]   s+   Lh 
 
;w ; ;eI.> ; ;w; ;-25\; ;"<0; ; "''7!8; ; "+.	; ;
 $));#<; ; !&o 6; ; "+.; ; "''7!8; ;
	
 
	
 
	
 
	
 [[&&FIIbbDQ`LabbbbbE'(F$w-  T
  >  N	 
 /0     " 01# $ !''D E% & )' ( J)   r   
explainerslist[dict[str, Any]]
output_dirr   
list[Path]c                    |                     dd           g }| D ]X}t          |          }||d          dz  }|                    t          |          d           |                    |           Y|S )z-Write mechanism shot plans as Markdown files.T)parentsexist_okr\   z.mdzutf-8)encoding)mkdirrb   
write_textrl   ri   )rm   ro   pathsr   rc   paths         r   write_mechanism_shot_plansry      s    TD111E  	(33tDz....24887KKKTLr   N)r   r   r   r   )r   )r   r   r   r    r   r   )r6   r    r7   r   r   r   )rG   r   r   r   )r   r   r   r   )rc   r   r   r   )rm   rn   ro   r   r   rp   )__doc__
__future__r   pathlibr   typingr   autoshorts.script_draftsr   rD   rE   r   r5   rH   rF   rb   rl   ry   rJ   r   r   <module>r      s.   U U " " " " " "             * * * * * * -#&  .#&",  G G G G       "      0& & & &R	 	 	 	 	 	r   