
    ׷*j                       d dl mZ d dlZd dlmZm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mZmZmZmZmZmZmZmZmZmZmZ d	d
gZg dZg dZh dZddddg ddddddg ddddddg ddddd d!g d"dd#d$d%d&g d'dd(d)d*d+g d,dd-d.d/d0g d1dd2d3d4d5g d6dd7d8d9d:g d;dd<d=d>d?g d@ddAdBdCdDg dEddFdGdHdIg dJdgZ g dKg dLg dMg dNg dOg dPdQZ!ddVZ"ddXZ#dd\Z$dd_Z%dd`Z&da Z'dddhZ(ddjZ)dddoZ*ddqZ+ddxZ,ddd{Z-dddZ.ddZ/ddZ0ddZ1ddZ2ddZ3ddZ4ddZ5ddZ6dddZ7ddZ8ddZ9ddZ:dddZ;dddZ<dddZ=ddZ>ddZ?ddZ@ddZAddZBddZCdddZDdS )    )annotationsN)Counterdefaultdict)Path)Any)HTTPException)Sessionselect)ActivityEventAnalyticsPostSnapshot
AppSettingContentScriptExternalPostIdea	PostDraftProductionQueueItemTheme
VideoAssetWebsiteCompanionnow_utclocked_nextapproved_next)		suggestedr   r   concept_proposedconcept_approved	producing	in_reviewneeds_changesheld)archiveddonearchived_pre_real_runhidden_from_active_review>   anddiddonfortheyoudontfakefromlocksaysscamstoptestthatthiswillwithyourdidntshortvideolockedaccountmessagepreviewwarningzthe second payment trapu@   The first fee is not the scam — the second payment request is.zShow a fake small delivery/customs fee flow where the danger is the follow-up card-verification step, then give the safer move: open the official delivery app/site manually.zGFast phone-screen style red-flag explainer with one clear safer action.)deliveryfeecustomspaymentcard)suffixhookbriefformatkeywordsz"when support calls after the popupzLIf a popup gives you a phone number, the phone call is part two of the scam.zsOpen with a scary device/security popup, then show the dangerous shift to phone support and remote access pressure.zMDramatic popup-to-call escalation, high contrast UI, calm safety instruction.)supportpopupphoneremotecallz the changed invoice detail checkz7One changed bank detail can redirect the whole invoice.z}Business-safety short: changed payment details in an invoice email, verify through an existing trusted channel before paying.z0Office/email scenario with before-pay checklist.)invoicebankrB   businesssupplierz"the courier chatbot pressure trickz<A courier chatbot asking for a card is not customer support.z|Messenger/chatbot delivery flow that pushes a tiny fee, card update or identity check; safer move is app-first verification.z=Chat interface beats, subtitle-heavy, simple red flag labels.)r?   chatbotcourierr@   rC   znew number, old pressureuC   The new number is not the red flag — the rushed money request is.zqFamily-message scam with a new number and urgent payment/gift-card ask. Show callback verification before acting.zJText-message story with emotional pressure cue and calm verification step.)newnumberfamilyrB   giftzcreator collab login trapz?A brand deal that starts with a login link is not a brand deal.zCreator-account safety: fake collaboration email or DM asks for login/permissions. Safer move: verify sender and never log in from the message link.z9Creator dashboard/DM visual metaphor, premium clean look.)creatorbrandlogincollabr;   z refund link that steals the card.A refund should not need your full card again.z~Fake refund/overpayment link asks for card details. Explain why legitimate refunds usually reverse to original payment method.z-Payment-screen close-up with one strong rule.)refundrC   rB   linkzside hustle app upfront feez.If the job starts with you paying them, pause.zSide-hustle/app opportunity asks for activation, training, or verification fee. Safer move: research outside the app and never pay to unlock income.z.App-store/job-offer style, punchy risk labels.)jobsidehustler@   appzQR code at the parking meterz4A sticker QR code can replace the real payment page.zPublic QR/payment red flag: parking/charging meter sticker QR sends to fake payment page. Safer move: use official app or typed URL.z.Real-world object + phone screen split visual.)qrparkingrB   stickerzbank code read-aloud replayz=If someone asks for the code, the code is already the target.zFollow-up to bank-code performer: show how attackers reframe a verification code as a security check; safer move: hang up and call back through official app.z2Voice-call pressure scenario with code box visual.)rO   coderM   verificationz!marketplace pickup payment switchzBThe payment switch is where the marketplace protection disappears.z]Buyer/seller moves chat off-platform and changes payment method; show why protection is lost.z0Marketplace chat + payment-method switch visual.)marketplacerB   sellerbuyerz!subscription renewal panic screenz:A renewal warning with a countdown wants speed, not truth.zFake subscription renewal popup/email pushes immediate payment update; safer move: open the service manually and check billing.z6Countdown/panic screen defused by calm app-first step.)subscriptionrenewal	countdownbilling)r?   rS   r@   rA   parcel)rI   rJ   rK   rL   )r;   rZ   r-   mfarf   )rN   rO   rP   rQ   )rX   rY   r[   rZ   )rh   ri   rj   )r?   rI   r;   rN   rX   rh   value
str | Nonereturnstrc                    d                     t          j        dd| pd                                                                                    S )N z
[^a-z0-9]+ )joinresublowersplitrq   s    R/home/agent/projects/AutoShorts_Dashboard/backend/app/services/production_queue.pynormalize_textr      s>    88BF=#/B/B/D/DEEKKMMNNN    set[str]c                X    d t          |                                           D             S )Nc                J    h | ] }t          |          d k    |t          v|!S )   )len	STOPWORDS).0ws     r~   	<setcomp>ztoken_set.<locals>.<setcomp>   s1    ZZZ!A

qPYGYGYAGYGYGYr   )r   r|   r}   s    r~   	token_setr      s*    ZZ~e,,2244ZZZZr   abfloatc                    t          |           t          |          }}|r|sdS t          ||z            t          ||z            z  S )Ng        )r   r   )r   r   leftrights       r~   
similarityr      sN    A,,	!%D u ste|s4%<0000r   itemr   c                4    | j         pd| j        d d          S )Npackage_   )expected_package_ididr   s    r~   r   r      s#    #?'?$'"1"+'?'??r   c                6    | j         pdt          |            dS )Nzstorage/incoming/z/manifest.json)expected_package_manifestr   r   s    r~   expected_manifestr      s&    )j-jATUYAZAZ-j-j-jjr   c                    t          t                                        t          j                            t
                                                  t          j        t          j        	                                t          j
                  S N)r
   r   wherestatusnotin_ARCHIVE_STATUSESorder_bypositionprioritydesc
created_at r   r~   active_queue_queryr      s    %&&,,-@-G-N-NO_-`-`aajjk~  lH  J]  Jf  Jk  Jk  Jm  Jm  oB  oM  N  N  Nr   Fsessionr	   include_archivedbooldict[str, Any]c                    t          t                                        t          j        t          j                                        t          j                  }|s7|                    t          j        	                    t                              }                     |                                          } fd|D             t          |          t          d |D                       dS )Nc                0    g | ]}t          |          S r   serialize_item)r   r   r   s     r~   
<listcomp>zlist_queue.<locals>.<listcomp>   s#    FFFnWd33FFFr   c                .    g | ]}|j         t          v|S r   )r   r   r   is     r~   r   zlist_queue.<locals>.<listcomp>   sU      rh  rh  rhxy  GH  GO  Wg  Gg  Ggrs  Gg  Gg  Ggr   )itemscountactive_count)r
   r   r   r   r   r   r   r   r   r   r   execallr   )r   r   stmtr   s   `   r~   
list_queuer      s   %&&//0C0LNaNjNoNoNqNq  tG  tR  S  SD Ozz-4;;<LMMNNLL""$$EFFFFFFFQTUZQ[Q[mp  rh  rh  ~C  rh  rh  rh  ni  ni  j  j  jr   list[dict[str, Any]]c           
        g }|                      t          t                                                              D ]^}t	          |j        d|j                  }|dv r"|                    d|j        p|j        |j	        |j
        |j        |j        d           _|                      t          t                                                              D ]}|j        rD|                     t          |j                  }|rt	          |j        d|j                  nd }|dv rM|j        r+|                    d|j        d d |j        |j        d           |j        r+|                    d|j        d d |j        |j        d           |                      t          t"                                                              D ]2}|                    d|j        |j        d |j        |j        d           3|                      t          t&                                                              D ]2}|                    d|j        |j	        d |j        |j        d           3|                      t          t*                                                              D ]-}|                    d	|j        d d |j        |j        d           .d
 |D             S )Nrq   >   r    rejectedr"   r#   r9   )kindtitle	family_id
package_idr   r   youtube_draftcaptionscriptyoutube_csvwebsite_slugc                <    g | ]}|                     d           |S )r   )get)r   rs     r~   r   z(_all_existing_titles.<locals>.<listcomp>   s'    ...!quuW~~.A...r   )r   r
   r   r   getattrr   appendworking_titlecandidate_idtopic_idr   r   r   video_asset_idr   r   r   r   r   r   mapping_statusr   slug)	r   rowsvr   dr9   spcs	            r~   _all_existing_titlesr      so   !#D\\&,,--1133 x x7AH55cccWq/P!._`_iyz  zF  RS  RZ  jk  jv  w  w  	x  	x  	x  	x\\&++,,0022 	X 	X 	KK
A,<==EEJTWU\7ELAAAPTFggg7 	\KK17QUeiuvu}  NO  NZ  [  [  \  \  \9 	XKKQYTaeqrqy  JK  JV  W  W  X  X  X\\&//004466 X XXakaeqrqy  JK  JV  W  W  	X  	X  	X  	X\\&..//3355 d d]QW1:eiuv  vF  VW  Vb  c  c  	d  	d  	d  	d\\&!122337799 V V^af4_copow  HI  HT  U  U  	V  	V  	V  	V..t....r   r   rE   rH   list[str] | Nonec           
        d                     |pd|pdd                     |pg           g          }g }t          |           D ]}t          t          ||d                   t          ||d                             }t	          |d                   }dt	          |          v rd|v sd|v rt          |d          }|dk    r[|                    |d	         |d         t          |d
          |                    d          |                    d          d           t          |d d          d d         }|r|d         d         dk    rd}	d}
n|rd}	d}
nd}	d}
|	||
dS )Nrv   rw   r   r;   r:   r-   g
ףp=
?g
ףp=
?r   r   r   r   )r   r   scorer   r   c                    | d         S )Nr   r   )ms    r~   <lambda>z"duplicate_report.<locals>.<lambda>   s
    AgJ r   Tkeyreverse   r   r   gffffff?highz6Use only if the hook angle is significantly different.mediumzUVariation is acceptable if the first sentence and safer action are clearly different.lowzNo close duplicate detected.)risksimilar_contentrecommendation)	rx   r   maxr   r   r   roundr   sorted)r   r   rE   rH   textmatchesrowr   
normalizedr   r   s              r~   duplicate_reportr      s   88U[b$*"chhx~2.F.FGHHDG#G,, e eJuc'l33Zc'l5S5STT#CL11
u----8z3I3IVWaMaMat$$ED==NNCK#g,QVW\^_Q`Q`lolslst|l}l}  NQ  NU  NU  Vb  Nc  Nc  d  d  e  e  eW"6"6EEEbqbIG 871:g&#--Q	 8p7WWWWr   dict[str, dict[str, Any]]c                (   d |                      t          t                                                              D             }|                      t          t                                                              D ]&}|j        |v r||j                 dxx         dz  cc<   '|                      t          t                                        t          j        	                                                                                    }t                      }g }|D ]L}|j        |j        |j        f}||v s|j        r"|                    |           |                    |           Md |                      t          t"                                                              D             }t%          t&                    }	|D ]}
|                    |
j                  }|r|j        nd }|s2|
j        r+|                     t          |
j                  }|r|j        nd }||v r||         dxx         |
j        pdz  cc<   ||         dxx         |
j        pdz  cc<   |
j         |	|                             |
j                   ||         d         r |
j        pd||         d         j        pdk    r|
||         d<   |	                                D ]?\  }}|r-t5          t7          |          t9          |          z  d          nd ||         d	<   @|S )
Nc           
     ,    i | ]}|j         |d dd d ddS )r   N)rV   views	retentionsubscribersvideosbestr   )r   fs     r~   
<dictcomp>z!_family_stats.<locals>.<dictcomp>   sB      \  \  \tuQTRS_`jnoo  \  \  \r   r      c                    i | ]
}|j         |S r   )external_post_id)r   r   s     r~   r   z!_family_stats.<locals>.<dictcomp>   s    UUUqQUUUr   r   r   r   r   r   )r   r
   r   r   r   r   r   r   snapshot_atr   setprovider
account_idr   is_demoaddr   r   r   listr   r   r   subscribers_deltaretention_proxy_pctr   r   sumr   )r   familiesr   	snapshotsseenlatestr   r   postsretention_valuessnappostr   r9   fidvaluess                   r~   _family_statsr     sV    \  \  zA  zF  zF  GM  NS  GT  GT  zU  zU  zY  zY  z[  z[  \  \  \H\\&,,--1133 0 0:!!QZ ***a/***V$9::CCDYDeDjDjDlDlmmnnrrttI55DF ( (z1<);<$;;!);v}}Q''''UUGLL9M9M,N,N,R,R,T,TUUUE/:4/@/@ 3 3yy.//%)3DMMt	 	:T0 	:KK
D,?@@E*/9TI  Y(((DJO!;(((Y...$2H2MAM...'3 +2243KLLLI&v. 34:?xPYGZ[aGbGhGmlm2n2n.2#F+'--// ] ]VLR%\U3v;;V+Da%H%H%HX\k""Or   angler
  list[Theme]indexintTheme | Nonec           	       
 |sd S d                     |d         |d         gz             g }|D ]}t          d                     |j        pd|j        pd|j        pd|j        pdg                    
t          
fd|d         D                       }t                                          D ]@\  }}t          fd|D                       r t          
fd|D                       r|dz  }A|
                    ||j        pd	|f           t          |d
           }	|	d	         d	k    r|	d         n||t          |          z           S )Nrv   rH   rD   rw   c              3  $   K   | ]
}|v d V  dS )r   Nr   )r   kwfts     r~   	<genexpr>z$_family_for_angle.<locals>.<genexpr>   s'      >>"R2XXAXXXX>>r   c              3      K   | ]}|v V  	d S r   r   )r   kr   s     r~   r  z$_family_for_angle.<locals>.<genexpr>  s'      **19******r   c              3      K   | ]}|v V  	d S r   r   )r   r   r  s     r~   r  z$_family_for_angle.<locals>.<genexpr>  s'      2H2Hq172H2H2H2H2H2Hr   r   r   c                "    | d         | d         fS )Nr   r   r   )r   s    r~   r   z#_family_for_angle.<locals>.<lambda>  s    AA'7 r   )r   r   )rx   r   r   descriptionaudience_painpromiser	  FAMILY_HINTSr   anyr   r   r   r   )r   r  r
  r  scoredrV   r   _kwsr   r  r   s             @@r~   _family_for_angler+     s    t88E*%x(99::DF = =CHHfl&8b&:L:RPRTZThTnlnpvp~  qE  CE  &F  G  G  H  H>>>>j 1>>>>>"((** 	 	FAs****c***** s2H2H2H2HC2H2H2H/H/H 
ufo2F;<<<<v77888D1gkk477xH0E'FFr      limitc                   t          |           }d t          |                                d d          D             }|sh|                     t	          t
                                        t
          j                                                            	                                }|                     t	          t                                        t          j                                                            	                                d d         }t          d |D                       }g }t                      }t          t                    D ]\  }}	t!          | |	||          }
|
r|
j        nd}|                    dd	                              d
d	                                          pd}| d|	d          }t)          |          |v r|                    t)          |                     |
r|                    |
j        i           ni }t1          | ||	d         |	d                   }|                    |
r|
j        nd d          }dt3          |                    d          pd          z   t3          |
r|
j        nd          z   |dz  z
  }|d         dk    r|dz  }n|d         dk    r|dz  }|dk    rdn	|dk    rdnd}|
rd|                    dd           dndd |	d          |d!         d"| d#g}|                    d$          }|r)|                    d%d&|j         d'|j        pd d(           |                    i d)|d*|
r|
j        nd d+|d|	d         d,|	d,         d-|d.|d/|	d0         d0|	d0         d1|d2|d         d3|d4|                    dd          |                    d5          |                    d6d          |r|j        nd d7d8d!d9d:d|	d                    |                     t	          t:                                        t:          j                             g d;                                        t:          j                                                            	                                }|d d         D ]~}|j!        r |                     t
          |j!                  nd }
|j        }t)          |          |v rEt1          | ||j"        |j#        pg           }|j!        r|                    |j!        i           ni }t3          |j        pd<          t3          |                    d          pd          z   |d         dk    rd<ndz
  }|                    ||j!        |
r|
j        n|j$        |j"        p||j"        p|d=|d!         d>|                    dd           d?g|d@dA|d         ||                    dd          |                    d5          |                    d6d          dBd!d:dC           t          |dD d          d |         S )ENc                    g | ]
}|d          S )rV   r   )r   r   s     r~   r   z3build_recommendation_candidates.<locals>.<listcomp>  s    |||(|||r   c                ,    | d         | d         j         fS )Nr   rV   )r   )xs    r~   r   z1build_recommendation_candidates.<locals>.<lambda>  s    1W:WXYaWbWkJl r   Tr   r   c              3  2   K   | ]}|j         	|j         V  d S r   )r   )r   r   s     r~   r  z2build_recommendation_candidates.<locals>.<genexpr>  s+      "L"L!"L1:"L"L"L"L"L"Lr   Everyday Red FlagsScamsrw   WarningszEveryday red flagz: rD   rE   rH   r   d   r      r   r   7   r      r   zRotate away soonzGood rotation fitz%Recently used once; angle must differzFamily performance: z linked viewszGeneral red-flag coverage gap.zHook angle: r   z
Rotation: .r   r   zBest related performer: z with z views.r   r   rV   rF   reasonr   stylerG   rotation_hintduplicate_riskr   performance_referencer   r   r   r   r   
best_videosourcer   r   )ideaneeds_researchplannedapproved2   z!Manual/library idea is available.zPerformance reference: z linked family views.u5   Use the family’s proven short-form red-flag format.z@Manual/library idea; check recent-family balance before locking.)r   r   r   )r   r   rV   rE   rF   r;  r   r<  r=  r>  r   r?  rB  r   c                *    | d         | d         dk    fS )Nr   r>  r   r   )r   s    r~   r   z1build_recommendation_candidates.<locals>.<lambda>W  s    Qz]A>N<OSX<X,Y r   )%r  r   r  r   r
   r   r   r   r   r   r   r   r   r  	enumerateTEMPLATE_ANGLESr+  r   replacestripr   r  r   r   r   r  insertr   r   r   r   r   in_r   short_explanationrH   pillar)r   r-  statsr
  recentrecent_family_counts
candidatesused_titlesidxr  rV   family_titlebaser   family_stat	duplicaterotation_penaltyr   rotationr;  r   ideasrC  s                          r~   build_recommendation_candidatesr^  	  s   '""E||VELLNN@l@lvz%{%{%{|||H U<<u 6 6u~7J7J7L7L M MNNRRTT\\&,,55j6K6P6P6R6RSSTTXXZZ[]\][]^F""L"Lv"L"L"LLL')J%%K00 + +
U"7E8SAA'-Gv||3G##GR0088RHHNNPPgTg,,5?,,%  K//u--...28@eii	2...b$WeU6]E*DUVV	/334QFIITSTUU[__W55:;;;cU[Bb&//ab>c>ccfvy{f{{V&&NHHv(**NH)9Q)>)>%%[kop[p[pDWDW  w^QW}M;??7A#>#>MMMM]}*5=**&'$$$$	
 v&& 	dMM!b
bb$*/XYbbbccc 
U
f6$
 l
 E&M	

 U7^
 f
 
 U8_
 eHo
 X
 i/
 	
 ${w/J/JYdYhYhitYuYu  GR  GV  GV  Wd  fg  Gh  Gh  FJ  xT  x|  xB  xB  PT  &U  &U
 &
 k
  j)!
 	 	 	 	$ LL++DKOO<m<m<m,n,nooxxy}  zG  zL  zL  zN  zN  O  O  P  P  T  T  V  VEbqb	  6:mMUDM222
%  K//$WeT5KT]M`^`aa	6:mKeiir222t}*++c+//'2J2J2Oa.P.PPZcdjZkouZuZuTVTV{|}&,=fll$+*3e+4u:IFV<W  Zfs~  tC  tC  DK  MN  tO  tO  Zf  Zf  Zf  g L_'/ )/:w/J/JYdYhYhitYuYu  GR  GV  GV  Wd  fg  Gh  Gh  &i  &i&!
 
 	 	 	 	  *"Y"Ycghhhiojoioppr      minimumreplace_existing_suggestionsc                	    |r                      t          t                                        t          j        dk    t          j        dk                                                        D ]1}d|_        t                      |_         	                    |           2 
                                                       t          t                                        t          j        dk    t          j        dk                                                        }t          |          |k    rd fd|D             dS d                       t          t                                        t          j                            t                                                                        D             }t          d                       t          t                                                              D             pdg          }g }t           d	
          D ]u}t          |          t          |          z   |k    r nNt!          |d                   |v rAt          |                    d          |d         d|d          d|d          d|                    d          p|                    d          pd d|d          ddd                    |d                   t'          |d                   |t          |          z   dz   dd          } 	                    |            
                                                      |           |                    |           |	                    t!          |j                             w|rK 	                    t/          dddd t          |          |d!"                      
                                                       t          t                                        t          j        dk    t          j        dk                                  t          j                                                            }	t          |           fd#|	D             dS )$Nr   r   r    r   c                0    g | ]}t          |          S r   r   r   r   r   s     r~   r   z/ensure_recommendation_queue.<locals>.<listcomp>c  s#    '_'_'_qw(B(B'_'_'_r   )createdr   c                6    h | ]}t          |j                  S r   )r   r   r   s     r~   r   z.ensure_recommendation_queue.<locals>.<setcomp>d  s4      b  b  b^AG,,  b  b  br   c                    g | ]	}|j         
S r   r   r   s     r~   r   z/ensure_recommendation_queue.<locals>.<listcomp>e      WWW!1:WWWr   r9  )r-  r   r   zHook: rE   z	

Brief: rF   z


Format: rG   r<  zFast red-flag explainerzFirst sentence must land in <1s. Keep it concrete, no generic cyber jargon. End with one safer action. No final Wan render without explicit approval.zV Avoid real scam URLs, phone numbers, bank details, private data, or unreviewed logos.zVUse approved Gianna premium voice for real render. Calm, confident, fast but readable.
r;  r   r   )r   r   rF   script_constraintsvisual_constraintsvoice_constraintsr;  r   r   r   rB  production_queuebulk!production_recommendations_seededz!Production recommendations seeded)re  r`  entity_type	entity_id
event_typelabelpayload_jsonc                0    g | ]}t          |          S r   r   rd  s     r~   r   z/ensure_recommendation_queue.<locals>.<listcomp>  s#    .Y.Y.Ya~gq/I/I.Y.Y.Yr   )r   r
   r   r   rB  r   r   r   
updated_atr  commitr   r   r   r   r^  r   r   rx   r  refreshr   r   r   r   r   )
r   r`  ra  r   active_suggestionsexisting_normmax_posre  candr   s
   `         r~   ensure_recommendation_queuer  Z  sB   # LL(;!<!<!B!BCVC]aqCq  tG  tN  R]  t]  "^  "^  _  _  c  c  e  e 	 	D$DK%iiDOKK f-@&A&A&G&GH[HbfvHv  yL  yS  Wb  yb  'c  'c  d  d  h  h  j  j
'))'_'_'_'_L^'_'_'_``` b  bgll6J]C^C^CdCdexe  fG  fG  HX  fY  fY  DZ  DZ  7[  7[  7_  7_  7a  7a  b  b  bMWWw||F;N4O4O'P'P'T'T'V'VWWW^\][^__GG/rBBB 6 6!""S\\1W<<E$w-((M99"hh{++w- V4<  V  VDM  V  VtxxX`OaOa  PTeiememnuevev  PT  {T  V  V  w"&w-   H   H   Hv99T(^,,j)**s7||+a/#
 
 
 	D7>>+++W__T-B-B-Bt.445555 M.@F  `C  Kn  IL  MT  IU  IU  bi  }j  }j  k  k  k  	l  	l  	lLL 344::;N;UYi;ik~  lF  JU  lU  V  V  _  _  `s  `|  }  }  ~  ~  B  B  D  DE7||.Y.Y.Y.YSX.Y.Y.YZZZr   c                   |j         r |                     t          |j                   nd }|j        r |                     t          |j                  nd }|j        r |                     t          |j                  nd }|j        r |                     t          |j                  nd }|j	        pd}d }|
                                D ]Y}|                                                    d          r0|                    dd          d                                         } nZt          | |j        |          }	t#          | |          }
i d|j        d|j         d|j        d|j        d	|j        d
|j	        d|d|j        d|j        d|j        d|j        dd |j        pd                    d          D             d|j        d|j        d|j        d|j        dt7          |          i dt9          |          d|j        d|j        d|j        d|j        d|r|j        nd d|r|j        nd d|r|j        nd d |r|j         nd d!|	d"         d#|	d#         d$|	d%         d&|
d'tC          |          d(tE          | |          d)|j#        r|j#        $                                nd d*|j%        r|j%        $                                nd }|S )+Nrw   zhook::r   r   r   idea_idcontent_script_idr   rF   rE   rk  rl  rm  r;  reason_linesc                    g | ]}||S r   r   r   lines     r~   r   z"serialize_item.<locals>.<listcomp>  s    RRR$TRRRRr   rj  r   r   r   rB  r   r   actual_package_idr   attached_package_patherrorrV   rC  r   video_titler>  r   r   duplicate_recommendationr   r=  format_hintr?  r   rx  )&r   r   r   r  r   r  r   r   r   rF   
splitlinesr{   
startswithr|   rL  r   r   _rotation_hint_for_itemr   rk  rl  rm  r;  r   r   r   rB  r   r   r  r  r  r   _format_hint_performance_reference_for_itemr   	isoformatrx  )r   r   rV   rC  r   r9   rF   rE   r  duper\  datas               r~   r   r     s   37>KW[[///tF.2lD7;;tT\***DCGCYcW[[(>???_cF<@<OYGKK
D$7888UYEJ"ED  ""  ::<<""7++ 	::c1%%a(..00DE	 GTZ66D&w55H#dg#T^# 	4<# 	T3	#
 	# 	# 	# 	d5# 	d5# 	T3# 	$+# 	RR4;+<"*C*CD*I*IRRR# 	DM# 	DM# 	$+#  	$+!#" 	2488## #$ 	$%6t%<%<%#& 	T3'#( 	$-)#* 	 !;+#, 	-#. 	&2&,,d/#0 	d,

1#2 	&2&,,d3#4 	e=u**5#6 	$v,7#8 	4 129#: 	#D)9$:;#< 	=#> 	|D))?#@ 	 !@$!O!OA#B 	T_Ndo//111$C#D 	T_Ndo//111$E# #DH Kr   c                p    | j         p| j        pd}|r#|                    d          d         d d         ndS )Nrw   r:  r      z6Fast red-flag explainer with one concrete safer action)rl  rF   r|   )r   r   s     r~   r  r    s?    "6dj6BD'+i4::c??1dsd##1iir   c                   t          |                               |j        pdi           }|                    d          }|                    dd          |                    d          |                    dd          |r|j        nd dS )Nrw   r   r   r   r   r   r@  )r  r   r   r   )r   r   rQ  r   s       r~   r  r    s    '""&&t~';R@@E99VDYYw**;9O9O`e`i`ijwyz`{`{  Z^  Lh  LP  LV  LV  dh  i  i  ir   c                6   |                      t          t                                        t          j                                                                                            d d         }t          fd|D                       }|dk    rdS |rdS dS )N   c                B    g | ]}|j         	|j         j        k    |S r   )r   r   )r   r   r   s     r~   r   z+_rotation_hint_for_item.<locals>.<listcomp>  s.    RRRqajRQZ4>5Q5Q5Q5Q5Qr      zhHigh repetition risk: this family appeared often recently. Lock only if hook angle is clearly different.z,Recently used family; keep variation strong.z:Good rotation fit: not overused in the last active videos.)r   r
   r   r   r   r   r   r   )r   r   rR  r   s    `  r~   r  r    s    \\&,,55j6K6P6P6R6RSSTTXXZZ[]\][]^FRRRRFRRRSSEzzyy >==GGr   payloadc                   t          d |                     t          t                                                              D             pdg          }t          |                    d          |                    d          |                    d          |                    d          p|                    d          pd|                    d	          |                    d
          |                    d          |                    d          t          |                    d          t                    r|                    d          n)d                    |                    d          pg           t          |                    dd                    t          |                    d|dz                       |                    d          pd|                    d          pd|                    d          |                    d                    }|j
        st          |          |_
        |j        st          |          |_        |                     |           |                                  |                     |           |                     t!          d|j        dd|j        |j        d                     |                                  t)          | |          S )Nc                    g | ]	}|j         
S r   rh  r   s     r~   r   z%create_queue_item.<locals>.<listcomp>  ri  r   r   r   r  r  r   rC  zUntitled production itemrF   rk  rl  rm  r;  rj  r   r   r   r   r   rB  manualr   r   )r   r  r  r   rF   rk  rl  rm  r;  r   r   r   rB  r   r   rn  production_queue_item_createdzProduction queue item created)r   rB  rq  )r   r   r
   r   r   r   
isinstancert   rx   r  r   r   r   r  ry  rz  r   r   r   rB  r   )r   r  r}  r   s       r~   create_queue_itemr    s   WWw||F;N4O4O'P'P'T'T'V'VWWW^\][^__G++k**I&&!++&9::kk'""Wgkk&&9&9W=Wkk'""";;';<<";;';<<!++&9::(27;;x3H3H#(N(Nzw{{8$$$TXT]T]^e^i^ijr^s^s^ywyTzTzW[[Q//00W[[Wq[99::{{8$$3{{8$$0#KK(=>>")++.I"J"J  D" # =#6t#<#< ) A):4)@)@&KKw~~''')>)>)>KK*<\{  Dc  |@  |F  RV  R]  r^  r^  _  _  _  `  `  `NN'4(((r   item_idc                `   |                      t          |          }|st          dd          dD ]}||v rt          ||||                    t	                      |_        |                     |           |                                  |                     |           t          | |          S )N  Production queue item not foundstatus_codedetail)r   r   r   rF   rk  rl  rm  r;  r   r   r  r   r  r  )
r   r   r   setattrr   rx  r  ry  rz  r   )r   r  r  r   r   s        r~   update_queue_itemr    s    ;;*G44D W4UVVVV C - -'>>D#ws|,,,iiDOKKw~~''')>)>)>'4(((r   r   c                4   t          | |                    d          |                    d          pd|                    d          pd d|                    d          p|                    d          |                    d          pg d	d
ddddd
          S )Nr   rC  zNext rV   r9   z variantrecommended_actionr;  rG  r   r   zTFast hook, short setup, concrete safer action. No final Wan render without approval.zfPreview/test render allowed. Avoid unreviewed logos, real scam URLs, phone numbers or payment details.z]Use approved Gianna premium voice only for real renders; test package may use silent preview.)
r   r   rF   r;  r   r   rB  rk  rl  rm  )r  r   )r   r   s     r~   add_recommendationr    s    W#''44##F++h/h~7I7I(7S7S7^W^/h/h/h##F++W~/A/ABV/W/W $$X..4""t G|' '   r   c                   |                      t          t                                        t          j        dk                                                        }|D ]<}|j        |k    r/d|_        t                      |_        | 	                    |           =| 
                                 t          | |ddd          S )Nr   r   r   )r   r   )r   r
   r   r   r   r   r   r   rx  r  ry  r  )r   r  r   r   s       r~   	lock_nextr    s    <<23399:M:TXe:effggkkmmD  6W(CJ$YYCNKKNNWg-UV/W/WXXXr   c                   |                      t          t                                        t          j                            g d                                                              }g }|D ]r}||j        |k    rcd|_        t          |j	        d          |_	        t                      |_        |                     |           |                    |j                   s|                                  d|t          |           dS )N)r   r   r   r   r   r   T)okunlockednext)r   r
   r   r   r   rN  r   r   r   r   r   rx  r  r   ry  next_for_agent)r   r  r   changedr   s        r~   unlock_nextr    s   <<23399:M:T:X:X  Z^  Z^  Z^  ;_  ;_  `  `  a  a  e  e  g  gDG 5 5?cf//(CJs|Q//CL$YYCNKKgnnSV444NNG^G5L5LMMMr   c                @    t          |            t          | |          S r   )r  r  )r   r  s     r~   replace_locked_withr    s     Wg&&&r   	directionc                   |                      t                                                                }t          fdt	          |          D             d           }|t          dd          |dk    r|dz
  n|dz   }|dk     s|t          |          k    rt          | ||                   S ||         j        ||         j        c||         _        ||         _        t                      ||         _
        t                      ||         _
        |                     ||                    |                     ||                    |                                  |                     ||                    t          | ||                   S )Nc              3  8   K   | ]\  }}|j         k    |V  d S r   r   )r   r   r   r  s      r~   r  zmove_item.<locals>.<genexpr>#  s3      HHgaTW5G5G5G5G5G5GHHr   r  r  r  upr   r   )r   r   r   r  rI  r   r   r   r   r   rx  r  ry  rz  )r   r  r  r   rV  swap_idxs    `    r~   	move_itemr  !  sb   LL+--..2244E
HHHH5!1!1HHH$
O
OC
{4UVVVV#t++sQwwqH!||x3u::--guSz22249(O4LeTWjNa1E#Jx1#IIE#JGIIuX'AKKc
W[[x9997>>;K;K;KW__]bcf]gMhMhMh'5:...r   c           	        t          | |          }|j        }|                    d          p!|j        p|                    d          d         }|                    d          pd}| d}g d}d                    g 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g}	i d|j        d|d |d!d"d#d$d|d%d&d'|j        pd(| d)d*|d+|	d,d-d.d/d0|j        p|                    d1          d2|j        pd3d4|d5|d d6         d7d8| d9||                    d:          p)|                    d;          |                    d<          g|                    d=          |                    d>          d?|j         d@S )ANrE   rj  r   rV   r3  zx

Safer move: if a refund page asks for full card details, close it and verify inside the official app or typed website.)z
#ScamAlertz#OnlineSafetyz#DigitalSafetyz#EverydayRedFlags)r\   IThis page says refund, but asks for the card number, expiry date and CVC.ZThat is the red flag: real refunds usually go back to the payment method you already used.(If a refund link needs a new card, stop.VClose the link. Open the delivery app or website yourself, and check the refund there.z@One screen. One red flag. Never give a card to receive a refund.z0.0-1.0szInstant visual hookz[Phone close-up: fake refund page already asking for full card details; no real logo or URL.r\   )timebeatvisualvoicez1.0-3.5szName the trapzBCamera pushes into the card form fields: card number, expiry, CVC.r  z3.5-6.5szExplain the mechanismzLClean contrast between 'refund' label and the dangerous 'enter card' fields.r  z6.5-9.0sRulezRThe link is closed; official app icon / typed address path appears as safer route.r  z	9.0-13.0szSafer move + takeawayz[Official-app-first verification; calm final frame with the phone safely away from the link.r  queue_item_idr   content_familyapproval_modescript_concept_onlyno_preview_video_requiredThook_rationalea  The hook is strong because it creates instant self-recognition and contradiction: viewers expect a refund to send money back, not ask for a full card again. The first frame can show the exact danger without needing sound, so the red flag lands inside the first second.script_ideazOpen with: z). Show the red flag, then one safer move.script_text
storyboardvisual_hook_planaB  First frame must show one concrete screen: a refund page asking for card number, expiry and CVC. No PowerPoint cards, no generic warning icons, no real brands, no real URLs. Premium AI image should feel like a cinematic phone close-up; renderer-owned subtitles are the only text layer beyond the controlled fake form text.director_planah  Use 3-5 premium AI/keyframe visuals: phone close-up, card-field danger push-in, contrast beat, close-link beat, official-app-first safer move. Keep movement controlled: slow push, cut on sentence beats, no shake, no diagram overlays. Final render only after Director QA verifies silent first-frame recognition, readable subtitles and no PowerPoint/mockup feel.visual_conceptr  
voice_tonez9Gianna premium voice, calm and direct, fast but readable.tiktok_captionyoutube_title_   youtube_descriptionz"A short practical red-flag guide: z.

If a refund page asks for full card details, stop and verify through the official app or typed website.

This video is educational and uses synthetic/AI-generated media.r  r  r=  r>  r   APPROVE_PRODUCTION )hashtagswhy_this_videor>  r   confirm_command)	r   r   r   rF   r|   rx   r   rl  rm  )
r   r   r  r   rE   rV   r   r  r  r  s
             r~   concept_payloadr  /  s   '4((DJE88FC
 3e::4@@CDXXh7#7F  R  R  RGUUUH))     K %:  Gd  o_  	`  	`_  AE  P[  	\  	\%<  IW  b~  	  	V  8L  WA  	B  	B&=  Jg  rJ  	K  	KJ 	& 	.	
 	$T 	 	  i 	tzb%b4%b%b%b 	{ 	j 	  a 	  D 	$1LTXXm5L5L 	d,k0k 	'  	ss!" 	   |E   |   |   |#$ ((>22wtxx@Z7[7[]a]e]efu]v]v6w((#34488$566:::-   r   dict[str, Any] | Nonec           	        |                      t          |          }|st          dd          |r|                     d          nd }|pt          | |          }|j        dvrd|_        d |_        t                      |_        |                     |           |                     t          d|j
        dd	|
                     |                                  |                     |           t          | |          |dS )Nr  r  r  concept>   r   r   package_readyr   r   rn  production_concept_proposedzProduction concept proposedrq  )r   r  )r   r   r   r  r   r  r   rx  r  r   r   ry  rz  r   )r   r  r  r   r  final_concepts         r~   propose_conceptr  _  s   ;;*G44D W4UVVVV(/9gkk)$$$TG=w==M{YYY(DJiiDOKKKK*<\y  B_  n{  |  |  |  }  }  }NNgood+++"7D11mLLLr   c           	        |                      t          |          }|st          dd          d|_        t	                      |_        |                     |           |                     t          d|j        dd|pi                      | 	                                 | 
                    |           t          | |          S )	Nr  r  r  r   rn  production_concept_approvedzProduction concept approvedrq  )r   r   r   r   r   rx  r  r   r   ry  rz  r   r   r  r  r   s       r~   approve_generationr  o  s    ;;*G44D W4UVVVV$DKiiDOKKKK*<\y  B_  nu  n{  y{  |  |  |  }  }  }NNgood+++'4(((r   c           	        |                      t          |          }|st          dd          d|_        |pi                      d          pd|_        t                      |_        |                     |           |                     t          d|j	        dd	|pi 
                     | 
                                 |                     |           t          | |          S )Nr  r  r  r   r;  zConcept rejected by creatorrn  production_concept_rejectedzProduction concept rejectedrq  )r   r   r   r   r  r   rx  r  r   r   ry  rz  r   r  s       r~   reject_conceptr  {  s    ;;*G44D W4UVVVV!DK-R$$X..O2ODJiiDOKKKK*<\y  B_  nu  n{  y{  |  |  |  }  }  }NNgood+++'4(((r   c                 *    ddddddddg d	g d
g ddS )Nzautoshorts-quality-v1.1z AutoShorts Director Quality v1.1a  Premium text-free AI styleframes are mandatory for real review videos. Deterministic/Pillow/layout mockups are blueprints only, never final review visuals. No PowerPoint/template slides, no large top titles, no persistent top banners, no unnecessary lower-third dimming, no large text boards, no AI-generated text, no real brands, real URLs, phone numbers, card or bank data. Styleframes remain text-free; renderer-owned captions/labels must be listed in quality_report.renderer_owned_text.a  Use Gianna premium clone for real renders. Generate 2-3 takes, normalize audio, transcribe with Whisper/forced alignment, compare against script, require WER <= 0.03, no wrong critical keywords, no hook/safer-move omissions, no clipped syllables/clicks/peaks/glitches.zFirst 0.5-1.0s must show a concrete red-flag visual and direct hook. Pattern interrupt in first 1-2s, visual change every 2-3s, clear safer move at the end. hook_score >= 8 required.zTikTok caption, hashtags, YouTube private title/description/tags, synthetic-media disclosure and safety wording must be present before review.zNo real scam URLs, phone numbers, bank/card/IBAN data, private data, operational scam instructions, unreviewed logos, public uploads, TikTok automation, or website push from production.zDirector visual plan -> 3-5 premium text-free styleframes -> styleframe QA -> review candidate render. Captions/labels are renderer-owned. Wan/I2V final renders require separate explicit approval.)visual_gate
voice_gate	hook_gatemetadata_gatesafety_gatepackage_integrity_gate)premium_ai_styleframes_usedstyleframes_text_freeno_large_top_titleno_unnecessary_lower_third_dimno_powerpoint_layoutrenderer_owned_text_listed)r  r  r  )versionnamevisual_policyvoice_policyhook_policymetadata_policysafety_policyrender_policygates_requiredvisual_checks_requiredvisual_fail_if_falser   r   r   r~   default_quality_profiler    s_    ,2 F g P l U `~~~ #I  #I  #I p p p  r   c                N   |                      t          d          }|s[t          dt                                }|                     |           |                                  |                     |           |j        pi }t                      }|                    |           |S )Nproduction_quality_profile)r   
value_json)r   r   r  r  ry  rz  r
  update)r   settingprofilemergeds       r~   get_quality_profiler    s    kk*&BCCG I!=JaJcJcdddGgnn...0H0H0H &BG$&&F
MM'Mr   c                     ddddS )NzAutoShorts Director Quality v1z!docs/director-production-skill.mdT)r  docrequiredr   r   r   r~   director_skill_payloadr    s    4=`nrsssr   c                F   |                      t          t                                        t          j        dk                                  t          j        t          j                                                            	                                }|s|                      t          t                                        t          j        
                    g d                                        t          j        t          j                                                            	                                }|s|                      t          t                                        t          j        dk                                  t          j        t          j                                                            	                                }|sd ddS |j        r |                     t          |j                  nd }|j        r |                     t          |j                  nd }|j        r |                     t"          |j                  nd }i d|j        d|r|j        nd d|j        d	|r|j        nd d
|j        d|j        d|j        d|j        dt+          | |                              d          d|j        p
|r|j        nd d|j        d|j        dd |j        pd                    d          D             dt9          | |j                  dt;          | |          dt=          |          dt?          |          ddd|j         dd|j         dd|j         dd |j         dd!dddddd"tA          |           tC                      d#	S )$Nr   )r   r   r   r   z"No locked/approved production item)r  r<   r  rV   r   rC  r  r  r   rF   rE   rk  rl  rm  recommended_reasonc                    g | ]}||S r   r   r  s     r~   r   z"next_for_agent.<locals>.<listcomp>  s    XXXSWXtXXXr   rw   rj  r   r=  r   r   T0propose_concept_then_wait_for_APPROVE_PRODUCTIONz/api/agent/production/z/concept-proposedz/approve-generationz/reject-conceptr  F)$no_final_wan_render_without_approvaltest_preview_allowedrenderer_owned_textno_unreviewed_uploadconcept_confirmation_requiredquality_report_required(ready_for_review_requires_quality_passed)	requires_concept_confirmationnext_required_actionconcept_endpointapprove_endpointreject_endpointr  production_rulesquality_profiledirector_skill)"r   r
   r   r   r   r   r   r   r   firstrN  r   r   r   r  r   r  r   r   r   rF   r   rk  r  rl  rm  r;  r|   r   r  r   r   r  r  )r   r   rV   rC  r   s        r~   r  r    s   <<23399:M:TXe:effoo  qD  qM  Ob  Ok  Op  Op  Or  Or  s  s  t  t  z  z  |  |D j||F#677==>Q>X>\>\  ^S  ^S  ^S  ?T  ?T  U  U  ^  ^  _r  _{  }P  }Y  }^  }^  }`  }`  a  a  b  b  h  h  j  j B||F#677==>Q>X\k>klluu  wJ  wS  Uh  Uq  Uv  Uv  Ux  Ux  y  y  z  z  @  @  B  B X!%2VWWW37>KW[[///tF.2lD7;;tT\***DCGCYcW[[(>???_cF##&2&,,d# 	T^# 	d,

	#
 	4<# 	T3# 	# 	# 	w--11&99# 	d5aPV:`&:L:L\`# 	d5# 	T3# 	XX1B0I0I$0O0OXXX# 	,WdjAA# 	0$??#  	2488!#" 	$%6t%<%<##$ *. ROTWOOOQTWQQQLDGLLL:::48$)#'$(-1'+8<
 
 /w77022E# # # #r   c           	     .   |                      t          |          }|st          dd          |j        dvrt          dd          |                     t          d|dd	i 
                     |                                  t          | |ddi          S )Nr  r  r  >   r   in_productionr     z1Concept must be approved before production startsrn  production_startedzProduction startedrq  r   r   )r   r   r   r   r  r   ry  r  )r   r  r   s      r~   mark_startedr,    s    ;;*G44D W4UVVVV{LLL4ghhhhKK*<\p  yM  \^  _  _  _  `  `  `NNWg+/FGGGr   c                X   |                      t          |          }|st          dd          |                     d          p|                     d          }|                     d          p$|r!t          t	          |          j                  nd }d||p|j        |                     d          p|j        |                     d          p|j        d	}| 	                    t          d
|dd|||d         d                     |                                  t          | ||          S )Nr  r  r  manifest_pathpackage_pathr  r   r   )r   r  r   r  r   rn  production_package_attachedzProduction package attached)r/  r.  r   rq  )r   r   r   rt   r   parentr   r  r   r  r   ry  r  )r   r  r  r   r.  r/  updatess          r~   attach_packager3    sg   ;;*G44D W4UVVVVKK00OGKK4O4OM;;~..nVc3m3tM7J7J7Q3R3R3RimL!!-%2%Td6T$[[66P$:P!++&677N4;N G KK*<\y  B_  K  ^k  F  GW  X  nY  nY  Z  Z  Z  [  [  [NNWgw777r   c           	        |pi }|                     d          }|rc|                      t          |          }|rFt          |j                  dvr0t	          |j        d|j                  dk    rt          dd          |                     t          d|d	d
|                     |                                  t          | |ddi|                     d          rd|                     d          ini           S )Nr   >   VideoStatus.ready_for_reviewready_for_reviewrq   r6  r*  z5Video must pass quality gates before ready_for_reviewr  rn  production_ready_for_reviewz#Production package ready for reviewrq  r   r   )
r   r   rt   r   r   r   r  r   ry  r  )r   r  r  video_idr9   s        r~   mark_ready_for_reviewr9    s{   mG{{+,,H qJ11 	qS&&.bbbgnoto{  ~E  GL  GS  hT  hT  Xj  hj  hjC8oppppKK*<\y  Bg  v}  ~  ~  ~      NNWg+  0g  @G  @K  @K  L\  @]  @]  KeK[]d]h]hiy]z]zJ{J{  ce  0g  h  h  hr   )rq   rr   rs   rt   )rq   rr   rs   r   )r   rr   r   rr   rs   r   )r   r   rs   rt   )F)r   r	   r   r   rs   r   )r   r	   rs   r   )NN)
r   r	   r   rt   rE   rr   rH   r   rs   r   )r   r	   rs   r   )
r   r	   r  r   r
  r  r  r  rs   r  )r,  )r   r	   r-  r  rs   r   )r_  F)r   r	   r`  r  ra  r   rs   r   )r   r	   r   r   rs   r   )r   r	   r   r   rs   rt   )r   r	   r  r   rs   r   )r   r	   r  rt   r  r   rs   r   )r   r	   r   r   rs   r   )r   r	   r  rt   rs   r   r   )r   r	   r  rr   rs   r   )r   r	   r  rt   r  rt   rs   r   )r   r	   r  rt   r  r  rs   r   )rs   r   )r   r	   rs   r   )E
__future__r   ry   collectionsr   r   pathlibr   typingr   fastapir   sqlmodelr	   r
   app.models.corer   r   r   r   r   r   r   r   r   r   r   r   ACTIVE_NEXT_STATUSESACTIVE_QUEUE_STATUSESr   r   rJ  r&  r   r   r   r   r   r   r   r   r   r  r+  r^  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r,  r3  r9  r   r   r~   <module>rC     s   " " " " " " 				 , , , , , , , ,             ! ! ! ! ! ! $ $ $ $ $ $ $ $                            &7  a  a  a ]]]   	 ,R A[EEE  7^ GaCCC  5I QDJJJ  7N PQEEE  -U E^BBB  .Q hMFFF  5@ RA999  0@ hB;;;  1F XB;;;  0O qF<<<  6TpDAAA  6L SJGGG ]Up DCC666::::::666555 O O O O[ [ [ [1 1 1 1@ @ @ @k k k kN N Nj j j j j/ / / /4X X X X X.   BG G G G Nq Nq Nq Nq Nqb&[ &[ &[ &[ &[R1 1 1 1hj j j j
i i i iH H H H) ) ) ):	) 	) 	) 	)   Y Y Y Y
N 
N 
N 
N 
N' ' ' '
/ / / /- - - -`M M M M M 	) 	) 	) 	) 	)
) 
) 
) 
) 
)       t t t t. . . .bH H H H8 8 8 8$	h 	h 	h 	h 	h 	h 	hr   