
    Kpjh                       d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ed         Zed         Zh d	Zd
Z ed           G d d                      Z ed           G d d                      Zd!dZd"dZd#dZd$dZd S )%z7Retention-led shot planning before any video rendering.    )annotations)	dataclass)Literal)ScriptDraftvalidate_script_draft)ValidationResult)first_frame_hookpattern_interruptcore_explanationscreen_or_card_visualcta)kinetic_text_overlaymechanism_animationscreen_recording_simulationcinematic_ai_videostatic_slideshow>   r   r   r   r   )zbaked-inzfake ui textzgenerated textzunreadable uiT)frozenc                  n    e Zd ZU ded<   ded<   ded<   ded<   ded<   d	ed
<   ded<   ded<   dZded<   dS )	ShotScenezShotPurpose | strpurposeintstart_secondsend_secondsstrvoiceover_beatvisual_actionzAssetMode | str
asset_modecaption_beatretention_goalTboollabels_renderer_ownedN)__name__
__module____qualname____annotations__r!        X/home/agent/jarvis_runtime/autoshortsbot/AutoShortsBot/autoshorts/rendering/shot_plan.pyr   r   #   s         "&&&&&&&r'   r   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )	ShotPlanr   	script_idtitler   estimated_duration_secondsztuple[ShotScene, ...]scenesN)r"   r#   r$   r%   r&   r'   r(   r*   r*   0   s<         NNNJJJ####!!!!!!r'   r*   valuer   returnr    c                0    | pd                                  S )N )strip)r/   s    r(   	_is_blankr4   8   s    ""$$$$r'   duration_secondsr   tuple[tuple[int, int], ...]c                    t          d|           }t          d|           }t          d|           }t          t          | dz
  |dz             |           }d|f||f||f||f|| ffS )N               r   )minmax)r5   	first_end
second_end	third_end
fourth_ends        r(   _scene_windowsrC   <   s    A'((IQ())JB())IS)A-y1}==?OPPJ	
I	J	Y	J	%& r'   scriptr   c                   t          |           }|j        s't          d                    |j                            t          | j                  }| j        }t          d|d         d         |d         d         | j	        dd| j	        d          t          d	|d         d         |d         d         |d         d
d|d         d          t          d|d         d         |d         d         t          |          dk    r|d         n| j        ddt          |          dk    r|d         n| j        d          t          d|d         d         |d         d         t          |          dk    r|d         n| j        ddt          |          dk    r|d         n| j        d          t          d|d         d         |d         d         | j        dd| j        d          f}t          | j        | j        | j        |          S )zJCreate a deterministic five-scene retention shot plan from a script draft.z; r	   r   r<   zPImmediate motion punch-in on clean kinetic hook text; no generated UI lettering.r   z>Stop the scroll with a first-frame hook and pattern interrupt.)r   r   r   r   r   r   r   r   r
   zSRapid desk-to-phone change showing messy priorities becoming a controlled workflow.r   zGCreate visible change before the viewer can classify it as a slideshow.r      zXSimulated screen flow with renderer-owned boxes, cursor motion, and approval checkpoint.r   zJMake the mechanism concrete without trusting generated text inside assets.r   r8   zPAnimated checklist/card sequence showing the weekly review routine step by step.z+Deliver the payoff visually before the CTA.r      zVClean kinetic CTA overlay with renderer-owned caption and final checklist card motion.z>Give a concrete comment action tied to the promised checklist.)r+   r,   r-   r.   )r   is_valid
ValueErrorjoinerrorsrC   r-   retention_beatsr   hooklenscript_outliner   r*   brief_idr,   )rD   
validationwindowsbeatsr.   s        r(   create_shot_planrT   J   s$    'v..J 7:#455666V>??G"E&!!*Q-
1!;l-[		
 		
 		
 	'!!*Q-
1 8o,qd		
 		
 		
 	&!!*Q-
1'*5zzA~~5886;Pt4%(ZZ!^^q9Ng		
 		
 		
 	+!!*Q-
1'*5zzA~~5886;Pl,%(ZZ!^^q9NH		
 		
 		
 	!!*Q-
1!:r-[		
 		
 		
S3Fh /l#)#D	   r'   planr   c           	        g }t          | j                  r|                    d           t          | j                  r|                    d           d| j        cxk    rdk    sn |                    d           | j        s|                    d           n+| j        d         j        dk    r|                    d	           d }t          | j        d
          D ]|\  }}|j        |j	        k    r|                    d| d           |$|j	        |k     r|                    d| d           |j        }|j        |j
        |j        |j        |j        |j        d                                D ]0\  }}t          |          r|                    d| d| d           1|j        dk    r|                    d           n+|j        t           vr|                    d|j                    |j        s|                    d           |j                                        t'          fdt(          D                       r|                    d           ~t+          | t-          |                    S )Nzscript_id is requiredztitle is required
      z+duration_seconds must be between 10 and 180zat least one scene is requiredr   r	   z$first scene must be first_frame_hookr<   )startzscene z/ end_seconds must be greater than start_secondsz& start_seconds overlaps previous scene)r   r   r   r   r   r    z is requiredr   z*static slideshow asset mode is not allowedzunsupported asset mode: z*labels and captions must be renderer-ownedc              3      K   | ]}|v V  	d S )Nr&   ).0markervisuals     r(   	<genexpr>z%validate_shot_plan.<locals>.<genexpr>   s(      BBFvBBBBBBr'   z$baked-in fake UI text is not allowed)rH   rK   )r4   r+   appendr,   r-   r.   r   	enumerater   r   r   r   r   r   r   items_ALLOWED_ASSET_MODESr!   casefoldany_BAKED_TEXT_MARKERSr   tuple)rU   rK   previous_endindexscene
field_namer/   r^   s          @r(   validate_shot_planrl      s   F   /-... +)***07777C7777CDDD; >67777	Q	#5	5	5<===#L!$+Q777 B Bu 333MMY5YYYZZZ#(;l(J(JMMP5PPPQQQ( }#2"0*!.#2"
 "
 %''		I 		IJ  IGuGGzGGGHHH111MMFGGGG%999MMGU5EGGHHH* 	HMMFGGG$--//BBBB.ABBBBB 	BMM@AAAZfFFFFr'   N)r/   r   r0   r    )r5   r   r0   r6   )rD   r   r0   r*   )rU   r*   r0   r   )__doc__
__future__r   dataclassesr   typingr   autoshorts.content.script_draftr   r   autoshorts.ideas.candidater   ShotPurpose	AssetModerc   rf   r   r*   r4   rC   rT   rl   r&   r'   r(   <module>ru      s   = = " " " " " " ! ! ! ! ! !       N N N N N N N N 7 7 7 7 7 7 	    V  $	' 	' 	' 	' 	' 	' 	' 	' $" " " " " " " "% % % %   B B B BJ*G *G *G *G *G *Gr'   