
    KWiN                        S SK r S SKJr  S SKJrJrJrJrJr  S SK	r	S SK
Jr  \" \5      R                  R                  r\S-  S-  S-  r\R!                  SSS	9  \S-  S-  S
-  r\R!                  SSS	9  \S-  S-  r\R!                  SSS	9  \S-  rS rSS\4S jjrSS\S\S\4S jjr\S:X  a  \" S5        \" SS5        \" SS5        gg)    N)Path)Image	ImageDraw	ImageFontImageEnhanceImageFilter)BytesIOSunaivawebsite_factorystatic_templatesT)parentsexist_okentry_portalsfontszInter-Bold.ttfc                     [         R                  5       (       dt  [        S5        Sn  [        R                  " U 5      nUR                  5         [        [         S5       nUR                  UR                  5        S S S 5        [        S5        g g ! , (       d  f       N= f! [         a  n[        SU 35         S nAg S nAff = f)Nz-[Entry Portal] Downloading Inter-Bold font...zChttps://github.com/google/fonts/raw/main/ofl/roboto/Roboto-Bold.ttfwbz[Entry Portal] Font downloaded.z([Entry Portal] Failed to download font: )
	FONT_PATHexistsprintrequestsgetraise_for_statusopenwritecontent	Exception)font_urlrfes       3e:\genesis-system\scripts\entry_portal_generator.pydownload_font_if_missingr"      s    =>X	BX&A i&!		" '34  '&  	B<QC@AA	Bs/   6B  B:B  
BB   
C*B==Croofingindustryc                     [         SU  S3-  nUR                  5       (       a  U$ [        SU  S35        [        R                  " SSSS9n[
        R                  " U5      nS	u  pEpgUR                  XEXF-   XW-   /S
SS9  UR                  U5        U$ )z
Creates a temporary solid gradient background to use if we don't have premium
pre-rendered industry templates in the directory yet.
base_.jpgz8[Entry Portal] Generating placeholder base template for z...RGB)i  iv  )      *   )color)      i   i,     )   )   ;   r-   )radiusfill)	TEMPLATES_DIRr   r   r   newr   Drawrounded_rectanglesave)r$   pathimgdrawcard_xcard_ycard_wcard_hs           r!   create_placeholder_templaterA   "   s    
 U8*D11D{{}}	DXJc
RS
))E;l
;C>>#D &8"FFFFM6=IRT[lmHHTNK    business_namereturnc                    [        5         [        SU S3-  nUR                  5       (       d  [        U5      n [        R
                  " U5      R                  S5      n[        R                  " SUR                  S5      n[        R                  " U5      n [        R                  " [        [        5      SS9n[        R                  " [        [        5      SS9nU  nSUR#                  5        S	3n	UR%                  S
XS9n
U
S   U
S   -
  nU
S   U
S   -
  nUR%                  S
XS9nUS   US   -
  nUR                  u  nnX-
  S-  nUS-  S-
  nX-
  S-  nUU-   S-   nSnSnUR'                  UU-   UU-   4XUS9  UR'                  UU-   UU-   4XUS9  UR'                  UU4XSS9  UR'                  UU4XSS9  [        R(                  " X45      nUR                  S5      nSR+                  U  Vs/ s H1  nUR-                  5       (       d  UR/                  5       (       d  M/  UPM3     sn5      R1                  5       n[2        U SU S3-  nUR5                  USS9  [7        SU  SU 35        [        U5      $ ! [         a.    [        R                   " 5       n[        R                   " 5       n GNf = fs  snf ! [8         a  n[7        SU  SU 35         S nAgS nAff = f)!z
Takes a pre-rendered high-fidelity SaaS/Website template for the given industry
and dynamically burns the prospect's `business_name` directly into the hero text.
Returns the file path of the generated "Nano-Banana" static payload.
r&   r'   RGBA)   rG   rG   r   @   )size    zThe Next Generation of z
 Websites.)r   r   )font   r         (   r/   )r   r   r      )rK   r4   )r      rG   rG   )r-         rG   r(    _z_payload.jpgZ   )quality[z] [NANO-BANANA] Generated: z,[Entry Portal] Error generating payload for z: N)r"   r5   r   rA   r   r   convertr6   rI   r   r7   r   truetypestrr   OSErrorload_defaulttitletextbboxtextalpha_compositejoinisalphaisdigitlower
OUTPUT_DIRr9   r   r   )rC   r$   template_pathr;   	txt_layerr<   rK   sub_fontheadlinesubheadline	bbox_headhead_whead_hbbox_subsub_wimg_wimg_hhead_xhead_ysub_xsub_yshadow_colorshadow_offset	final_imgc	safe_nameoutput_filer    s                               r!   generate_nano_banana_portalr}   7   s     "eH:T$::M!!3H=?jj'//7IIfchh0BC	~~i(	0%%c)n2>D ))#i.rBH $_/0@/AL MM&(M>	1	!,1	!,===Dhqk)xxu .A%!)r!!#"$ &		6M)6M+ABH^j	k		5=(%-*?@+co	p 			66"H>P	Q		5%.+CW	X ))#9	%%e,	 GGT1		QTU[[]	 i[(<#HH{B/- ;K=IJ;c  	0))+D --/H	0V U  <]O2aSQRsQ   AJ: AI: DJ: 2.J5$J5*AJ: :4J2.J: 1J22J: :
KKK__main__z.Testing Nano-Banana Outreach Hook Generator...zPrestige Law GrouplegalzBrisbane Elite Roofers)r#   )ospathlibr   PILr   r   r   r   r   r   ior	   __file__parentBASE_DIRr5   mkdirrf   FONT_DIRr   r"   r[   rA   r}   __name__r    rB   r!   <module>r      s   	  F F  >  ''9$'88;MM   D4  0 	!$55G
 
    - i') td +''	B# *Ls Lc LRU L\ z	
:; 4g> 8)D	 rB   