
    niR              
       V   d Z ddlZddlZddlZddlZddlZddlmZ ddlm	Z	 ej                  j                  d e ee      j                               ddlmZmZmZmZ  ej(                  d      ZdZde	e   fd	Zd
edefdZd1dedede	e   fdZdedefdZded
edefdZdededefdZd
edefdZ	 	 d2dededede	e   fdZ e!dk(  rZddl"Z" ejF                  ejH                  d        e"jJ                  d      Z&e&jO                  dd        e&jO                  d!dd"#       e&jO                  d$d%        e&jQ                         Z) e e)jT                  e)jV                  &      Z,e,re)jZ                  r ee)jZ                        n ed'e)jT                         Z.e)jZ                  se.j_                  dd(       e.d)z  Z0ne.Z0e0j                  j_                  dd(       e0jc                  e,d*+        e2d,e0 d- e3e,       d.       y e2d/        ejh                  d0       yy)3u  
Genesis Gold Pipeline — Landing Page Generator
================================================
Generates industry-specific landing pages using Gemini API.
Produces standalone HTML with Tailwind CSS, voice widget injection,
SEO meta tags, and LocalBusiness schema markup.

Usage:
    from generate_site import generate_landing_page
    html = generate_landing_page("tradiechatbots.com.au")
    N)Path)Optional)get_domain_config	VERTICALSPALETTESCITIESzgold_pipeline.generate_siteul  
<!-- AI Voice Widget — Telnyx WebRTC -->
<div id="voice-widget-container" style="position:fixed;bottom:24px;right:24px;z-index:9999;">
  <button id="voice-widget-btn" onclick="document.getElementById('voice-widget-modal').style.display='flex'"
    style="background:linear-gradient(135deg,{primary},{accent});color:white;border:none;border-radius:50%;
    width:64px;height:64px;font-size:28px;cursor:pointer;
    box-shadow:0 4px 20px rgba(0,0,0,0.3);transition:all 0.3s ease;"
    onmouseover="this.style.transform='scale(1.1)';this.style.boxShadow='0 6px 24px rgba(0,0,0,0.4)'"
    onmouseout="this.style.transform='scale(1)';this.style.boxShadow='0 4px 20px rgba(0,0,0,0.3)'"
    aria-label="Talk to our AI assistant">
    <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin:auto;display:block">
      <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/>
      <path d="M19 10v2a7 7 0 0 1-14 0v-2"/>
      <line x1="12" y1="19" x2="12" y2="23"/>
      <line x1="8" y1="23" x2="16" y2="23"/>
    </svg>
  </button>
  <div style="position:absolute;bottom:72px;right:0;background:white;border-radius:12px;
    padding:8px 14px;font-size:13px;white-space:nowrap;box-shadow:0 2px 12px rgba(0,0,0,0.15);
    color:{primary};font-weight:600;pointer-events:none;">
    Talk to our AI — Try it free
  </div>
</div>

<!-- Voice Widget Modal -->
<div id="voice-widget-modal" style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.6);
  z-index:10000;align-items:center;justify-content:center;backdrop-filter:blur(4px);">
  <div style="background:white;border-radius:16px;padding:32px;max-width:420px;width:90%;
    box-shadow:0 20px 60px rgba(0,0,0,0.3);text-align:center;position:relative;">
    <button onclick="document.getElementById('voice-widget-modal').style.display='none'"
      style="position:absolute;top:12px;right:12px;background:none;border:none;font-size:24px;
      cursor:pointer;color:#666;line-height:1;">&times;</button>
    <div style="font-size:48px;margin-bottom:16px;">🎙️</div>
    <h3 style="margin:0 0 8px;font-size:20px;color:{primary};">Talk to Our AI Receptionist</h3>
    <p style="margin:0 0 20px;color:#666;font-size:14px;">
      Experience how our AI handles calls for businesses like yours.
      Click below to start a live voice demo.
    </p>
    <a href="https://aiva.agileadapt.com/s/{spore_payload}"
      style="display:inline-block;background:linear-gradient(135deg,{primary},{accent});color:white;
      text-decoration:none;padding:14px 32px;border-radius:8px;font-weight:600;font-size:16px;
      transition:transform 0.2s;"
      onmouseover="this.style.transform='translateY(-2px)'"
      onmouseout="this.style.transform='translateY(0)'">
      Start Voice Demo →
    </a>
    <p style="margin:12px 0 0;color:#999;font-size:12px;">Free demo — no signup required</p>
  </div>
</div>
returnc                  <   dD ]'  } t         j                  j                  |       }|s%|c S  	 t        j                  j                  dd       ddlm}  |       S # t        $ r Y nw xY wt        d      }|j                         r|j                         j                         D ]w  }|j                         }|j                  d      s|j                  d      s6|j                  dd	      d	   j                         j                  d
      j                  d      c S  y )N)GEMINI_API_KEYGOOGLE_API_KEYGOOGLE_GEMINI_API_KEYr   z/mnt/e/genesis-system/core)get_gemini_api_keyz(/mnt/e/genesis-system/config/secrets.envzGEMINI_API_KEY=zGOOGLE_API_KEY==   "')osenvirongetsyspathinsertsecrets_loaderr   	Exceptionr   exists	read_text
splitlinesstrip
startswithsplit)key_namevalr   secrets_pathlines        </mnt/e/genesis-system/scripts/gold_pipeline/generate_site.py_get_gemini_api_keyr&   V   s    Q jjnnX&J785!##  BCL **,779 	KD::<D01T__EV5Wzz#q)!,224::3?EEcJJ	K s   ,A 	A'&A'configc                 d   | d   }| d   }| d   }| j                  d      }| j                  d      }|rfd|r |j                  dd      j                         nd	 d
|d    d|d    d|d    d|d    d|r |j                  dd      j                         nd d}nd}dj                  d |d   D              }dj                  d |d   D              }dj                  d |d   D              }	dj                  g d| d| d     d!|d"    d#|d$    d%|d&    d'|d(    d)| d*| d+| d,|	 d-|d.    d/|d0    d1|d2    d3|d4    d5|j	                  d6      d7   j                  d8d      j                          d9|d"    d:| d;| d     d<| d=      }
|
S )>zBBuild a comprehensive Gemini prompt for generating a landing page.verticalpalettedomaincitycity_keyz
LOCATION TARGETING:
- City: _ 	Australiaz

- State: statez
- Service Area: 	area_descz
- Key Suburbs: suburbsz
- Population: 
populationz

Include location-specific content:
- Reference the city name in H1, H2, and body text naturally
- Mention specific suburbs in the service area section
- Use "
AustralianzH" in meta title and description
- Include a "Serving [suburbs]" section
z
LOCATION: National Australia
- Target all major Australian cities
- Use "Australian" in positioning
- Reference major cities: Sydney, Melbourne, Brisbane, Perth, Adelaide

c              3   &   K   | ]	  }d |   ywz- N ).0fs     r%   	<genexpr>z-_build_landing_page_prompt.<locals>.<genexpr>   s     >11#h>   featuresc              3   &   K   | ]	  }d |   ywr8   r9   )r:   ps     r%   r<   z-_build_landing_page_prompt.<locals>.<genexpr>   s      Da2aS Dr=   pain_pointsc              3   &   K   | ]	  }d |   ywr8   r9   )r:   ts     r%   r<   z-_build_landing_page_prompt.<locals>.<genexpr>   s     @Rs8@r=   trust_signals zBGenerate a complete, standalone HTML landing page for the domain: zS

BUSINESS CONTEXT:
This is a landing page for an AI voice agent product targeting vertical_keyz businesses in Australia.
The product is an AI-powered phone receptionist that answers calls 24/7, captures leads, and books appointments.
Brand: AgileAdapt (the service brand) / Sunaiva (the technology platform)

HEADLINE: headlinez
SUBHEADLINE: subheadlinez
CTA: ctaz
PRICE ANCHOR: price_anchorz

z

PAIN POINTS TO ADDRESS:
z

FEATURES TO HIGHLIGHT:
z

TRUST SIGNALS:
z

DESIGN REQUIREMENTS:
- Single standalone HTML file (no external dependencies except Tailwind CDN and Google Fonts)
- Mobile-first responsive design
- Colour scheme:
  - Primary: primaryz
  - Secondary: 	secondaryz
  - Accent: accentz
  - Background: bgz
- Typography: Inter font from Google Fonts
- Australian English spelling throughout (colour, favour, licence, etc.)

SECTIONS (in order):
1. HEADER: Sticky nav with logo text (.r   -u  ), navigation links, and prominent CTA button
2. HERO: Full-width gradient hero with headline, subheadline, CTA button, and subtle animation (CSS only)
3. PAIN POINTS: "Sound Familiar?" section with 4 cards showing the problems
4. HOW IT WORKS: 3-step process (1. We Set Up Your AI → 2. AI Answers Your Calls → 3. You Get More Jobs)
5. FEATURES: Grid of 4 feature cards with icons (use emoji or SVG icons)
6. SOCIAL PROOF: Stats bar (e.g., "500+ businesses trust us | 50,000+ calls handled | 4.9★ rating")
7. PRICING: 3 tiers ($497/mo Starter, $997/mo Professional, $1,497/mo Enterprise) with feature comparison
   - Starter: 500 voice minutes, 1 AI agent, basic analytics, email support
   - Professional: 2,000 minutes, CRM integration, advanced analytics, priority support, white-glove setup
   - Enterprise: 5,000 minutes, 3 AI agents, custom webhooks, API access, dedicated account manager
8. FAQ: 6 common questions with expandable answers (use details/summary HTML)
9. FINAL CTA: Full-width section with "Ready to never miss a call again?" and CTA button
10. FOOTER: Logo, links, copyright, "Powered by Sunaiva AI" small text, Privacy Policy link

SEO REQUIREMENTS:
- Title: " | z-" (max 60 chars)
- Meta description: Include z, location if applicable, and CTA (max 155 chars)
- H1: One per page (the headline)
- Schema markup: LocalBusiness JSON-LD
- Open Graph tags for social sharing
- Canonical URL: https://a  

TECHNICAL:
- Tailwind CSS via CDN: <script src="https://cdn.tailwindcss.com"></script>
- Google Fonts Inter: <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
- Smooth scroll behaviour
- FAQ uses native <details><summary> elements
- All phone numbers as tel: links
- CSS animations for hero (fade-in, slide-up) using @keyframes
- No JavaScript dependencies beyond Tailwind

PRICING DISPLAY:
- Monthly prices in AUD
- Highlight "Professional" as "Most Popular"
- Annual discount hint: "Save 20% with annual billing"
- Each tier has a clear CTA button linking to: https://aiva.agileadapt.com/s/demo

OUTPUT: Return ONLY the complete HTML file starting with <!DOCTYPE html>. No markdown, no code blocks, no explanations.r   replacetitlejoinr    )r'   vr@   r+   r,   r-   location_textfeatures_htmlpain_points_html
trust_htmlprompts              r%   _build_landing_page_promptr\   o   s   zAyAHF::fDzz*%H 	/7		#s	#	)	)	+[I J

w- k"# $Y  !L!" #
 /7c"((*LI J II>*>>Myy D1]3C DD@Q-?@@JH{ H{S H{TZS[ H{ \@ H{ AG~@V?WH{XH{ Z=/H{H{ H{ H{ hZH{H{  !H{"H{ H{H{  H{H{$ %H{$%H{* +H{*+H{6 	l^7H{67H{8 +9H{8 9H{: x[M;H{:;H{< 4	=H{<'=H{F (.||C'8';'C'CC'L'R'R'T&UGH{FVGH{d Z=/eH{d eH{d $HeH{d%eH{f $N34gH{f5gH{n !oH{n"xoH{FT M    gemini-2.5-flashr[   modelc           	         t               }|st        j                  d       y	 ddlm} ddlm} |j                  |      }t        j                  d| d       |j                  j                  || |j                  dd	d
            }|j                  }|r$t        j                  dt        |       d       |S 	 	 ddl}	|	j#                         5  |	j%                  d       ddlm}
 ddd       
j+                  |       |
j-                  |d      }|j                  | |
j/                  d	d
            }|j                  }|r$t        j                  dt        |       d       |S 	 y# t        $ r t        j                  d       Y t        $ r#}t        j                  d| d       Y d}~d}~ww xY w# 1 sw Y   xY w# t        $ r"}t        j                  d|        Y d}~yd}~ww xY w)z!Call Gemini API to generate HTML.zNo Gemini API key foundNr   )types)api_keyzCalling Gemini (z) via google.genai SDK...uF  You are a world-class front-end developer specialising in high-conversion landing pages for Australian businesses. You produce complete, standalone HTML files with Tailwind CSS. Your output is always pixel-perfect, mobile-first, and optimised for conversions. Return ONLY HTML — no markdown, no code blocks, no explanations.i @  g?)system_instructionmax_output_tokenstemperature)r_   contentsr'   z	Received z chars from Geminiz0google.genai not available, trying legacy SDK...zgoogle.genai failed: z, trying legacy SDK...ignorezYou are a world-class front-end developer specialising in high-conversion landing pages for Australian businesses. Return ONLY complete HTML files.)
model_namerc   )rd   re   )generation_configz chars (legacy SDK)zLegacy SDK also failed: )r&   loggererrorgoogle.genaigenaira   Clientinfomodelsgenerate_contentGenerateContentConfigtextlenImportErrorr   warningwarningscatch_warningssimplefiltergoogle.generativeaigenerativeai	configureGenerativeModelGenerationConfig)r[   r_   rb   rm   ra   clientresponsers   erw   genai_legacy	model_objs               r%   _call_geminir      s   !#G./J$&g.&ug-FGH==11.. $l"' /  2 
 }}KK)CI;.@ABK 5$$& 	7!!(+6	7 	w/ 00  u 1 
	
 --*;;"' <  . 
 }}KK)CI;.ABCK  G  HFG J.qc1GHIIJ	7 	70  5/s3445sO   BE0 ?G
 F>+BG
 0F;F;F66F;>GG
 
	G5G00G5rawc                 ~   | j                         } | j                  d      r| dd } n| j                  d      r| dd } | j                  d      r| dd } | j                         } | j                         j	                  d      }|dkD  r| |d } | S |d	k(  r)| j                         j	                  d
      }|dkD  r| |d } | S )z5Strip markdown wrappers and ensure clean HTML output.z```html   Nz```   z	<!doctyper   z<html)r   r   endswithlowerfind)r   doctype_idxhtml_idxs      r%   _clean_htmlr   -  s    
))+C
~~i !"g		!"g
||E#2h
))+C))+"";/KQ+, J 
	99;##G,a<hi.CJr]   htmlc                    |d   }ddl }t        j                  d|d    ddd	      }|j                  |j	                               j                         j                  d
      }t        j                  |d   |d   |      }| j                         j                  d      }|dk7  r| d| dz   |z   dz   | |d z   } | S | dz   |z   } | S )z5Inject the voice widget into the HTML before </body>.r*   r   Nzhttps://r+   r   )urC   ),:)
separatorsr   rK   rM   )rK   rM   spore_payloadz</body>r   r6   )base64jsondumpsurlsafe_b64encodeencodedecoderstripVOICE_WIDGET_SNIPPETformatr   rfind)r   r'   r@   r   
spore_datar   widget
body_closes           r%   _inject_voice_widgetr   C  s    yAHVH-=,>"?aHU_`J,,Z->->-@AHHJQQRUVM!((){# ) F ##I.JRKZ 4'&047$z{:KK K d{V#Kr]   r+   c                 v    d| d}| j                         j                  d      }|dk7  r| d| |z   | |d z   } | S )z3Inject Plausible analytics tracking before </head>.zA
    <!-- Plausible Analytics -->
    <script defer data-domain="z4" src="https://plausible.io/js/script.js"></script>
z</head>r   N)r   r   )r   r+   	analytics
head_closes       r%   _inject_analyticsr   Y  sZ      &x (I ##I.JRKZ 9,tJK/@@Kr]   c                    | d   }| d   | d   }| j                  d      }| j                  d      r0| j                  dd      j                  dd      j                         nd	}d
j                  fd|d   D              }dj                  g d|d    d| d|d    d| d|d    d|d    d|d    d| d| dd    d|j	                  d      d   j                  dd      j                          dd     d!d    d"|d#    d$d    d%d&    d'|d    d(|d    d)|rd*|z   d+z   nd, d-d     d!d    d"|d#    d.|d    d/d    d0| d1d2    d3d    d4|d    d5d    d"|d#    d6d    d7|j	                  d      d   j                  dd      j                          d8      S )9zAGenerate a basic but functional landing page if Gemini API fails.r)   r*   r+   r,   r-   rE   r.   r/   r0   r6   c              3   6   K   | ]  }d d    d| d  yw)zd<div class="bg-white rounded-xl p-6 shadow-sm border"><p class="text-lg font-semibold" style="color:rK   ">z
</p></div>Nr9   )r:   r;   r@   s     r%   r<   z%_generate_fallback.<locals>.<genexpr>q  sD       oopqzo{n||~  @A  B  BL  	Ms   r>   z<!DOCTYPE html>
<html lang="en-AU">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>rG   rQ   z/</title>
    <meta name="description" content="rH   z	 Serving z. rJ   z+.">
    <meta property="og:title" content="z0">
    <meta property="og:description" content="z0">
    <meta property="og:url" content="https://z+">
    <link rel="canonical" href="https://aU  ">
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <style>body { font-family: 'Inter', sans-serif; }</style>
</head>
<body class="bg-gray-50">
    <header class="sticky top-0 z-50 shadow-sm" style="background:rK   z">
        <div class="max-w-6xl mx-auto px-4 py-4 flex justify-between items-center">
            <span class="text-white text-xl font-bold">rO   r   rP   z</span>
            <a href="https://aiva.agileadapt.com/s/demo" class="text-sm font-semibold px-6 py-2.5 rounded-lg transition" style="background:rL   z;color:r   rI   z}</a>
        </div>
    </header>
    <section class="py-24 text-center text-white" style="background:linear-gradient(135deg,r   rM   zr)">
        <div class="max-w-3xl mx-auto px-4">
            <h1 class="text-4xl md:text-5xl font-extrabold mb-4">z5</h1>
            <p class="text-xl opacity-90 mb-2">z</p>
            z+<p class="text-lg opacity-80 mb-8">Serving z</p>z@<p class="text-lg opacity-80 mb-8">For Australian businesses</p>z
            <a href="https://aiva.agileadapt.com/s/demo" class="inline-block text-lg font-bold px-10 py-4 rounded-xl transition hover:opacity-90" style="background:u8    →</a>
            <p class="mt-4 text-sm opacity-70">z</p>
        </div>
    </section>
    <section class="py-16 bg-white">
        <div class="max-w-5xl mx-auto px-4">
            <h2 class="text-3xl font-bold text-center mb-10" style="color:zH">Why Choose Us</h2>
            <div class="grid md:grid-cols-2 gap-6">zR</div>
        </div>
    </section>
    <section class="py-16" style="background:rN   zy">
        <div class="max-w-4xl mx-auto px-4 text-center">
            <h2 class="text-3xl font-bold mb-4" style="color:z[">Ready to Never Miss a Call Again?</h2>
            <p class="text-lg text-gray-600 mb-8">z</p>
            <a href="https://aiva.agileadapt.com/s/demo" class="inline-block text-lg font-bold px-10 py-4 rounded-xl text-white transition hover:opacity-90" style="background:ut    →</a>
        </div>
    </section>
    <footer class="py-8 text-center text-gray-400 text-sm" style="background:z0">
        <p class="text-gray-300">&copy; 2026 z. All rights reserved.</p>
        <p class="mt-1 text-gray-500">Powered by <a href="https://sunaiva.ai" class="underline">Sunaiva AI</a></p>
    </footer>
</body>
</html>rR   )r'   rV   r+   r,   	city_namerX   r@   s         @r%   _generate_fallbackr   i  s   zAyAHF::fDHN

S]H^

:r*223<BBDdoIII : M
1 1  1
 jM?1
 1
 %X1
&'1 ()'7&81 9B1 CL1 MO1 PQQ_O`Na1b(1 )**17.1 /0.>-?1@.1 /5X16)1 *011C1  DEY<.!1 Q8!1$ 9?S8I!8L8T8TUXY\8]8c8c8e7f%1$gL%1& MN  OZ  M[  L\'1& \c'1& de  fo  dp  cq'1& qs'1& tu  v{  t|  s}'1&}\'1, ]^^g\h[i-1, jk-1, lmmukvjw-1,xB-10 CDJ-110Q0112 12-0@/A312B314 TX:YFO  ^`  a514ae516 fg  hs  ft  eu716 u|716 }~  H  }I  |J716 JL716 MN  OT  MU  LV716V0718 12.0A/B918CK91B LMY<.C1BY4C1D 5B?E1DC.E1J /0gYK1J7>K1N ?@	l^O1NL3O1P 45]3C2DQ1PEpQ1R qr  s|  q}  p~S1R ~@S1R AB  CH  AI  @JS1RJNS1X OPPYl^Y1X\.Y1Z /5ll3.?.B.J.J3s.S.Y.Y.[-\[1Z][1 1r]   Tuse_fallback_on_failurec                    t        |       }t        j                  d|  d|d    d|j                  dd       d|d    d		       t	        |      }t        ||
      }|rt        |      }n(|r%t        j                  d|  d       t        |      }nyt        ||      }t        ||       }t        j                  d|  dt        |       d       |S )aK  
    Generate a complete landing page for a domain from the portfolio.

    Args:
        domain: The domain name (e.g., "tradiechatbots.com.au")
        model: Gemini model to use
        use_fallback_on_failure: If True, return a basic template on API failure

    Returns:
        Complete HTML string ready for deployment.
    zGenerating landing page for z (vertical=rF   z, city=r-   nationalz, tier=tier)r_   zGemini failed for z, using fallback templateNzLanding page generated for z: z chars)r   rj   ro   r   r\   r   r   rv   r   r   r   rt   )r+   r_   r   r'   r[   raw_htmlr   s          r%   generate_landing_pager     s     v&F
KK.vhk&BXAYY`agakaklv  yC  bD  aE  EL  MS  TZ  M[  L\  \]  ^  _ (/F F%0H8$	 +F83LMN!&)  f-DT6*D
KK-fXRD	{&IJKr]   __main__z%(levelname)s %(message)s)levelr   z,Generate a landing page for a Genesis domain)descriptionz)Domain name (e.g., tradiechatbots.com.au))helpz--modelzGemini model to use)defaultr   z--outputz6Output file path (default: output/{domain}/index.html)r   z3/mnt/e/genesis-system/scripts/gold_pipeline/output/)parentsexist_okz
index.htmlzutf-8)encodingzLanding page saved: z (z chars)zGeneration failedr   )r^   )r^   T)5__doc__r   r   reloggingr   pathlibr   typingr   r   r   str__file__parentprompt_templatesr   r   r   r   	getLoggerrj   r   r&   dictr\   r   r   r   r   r   boolr   __name__argparsebasicConfigINFOArgumentParserparseradd_argument
parse_argsargsr+   r_   r   output
output_dirmkdiroutput_path
write_textprintrt   exitr9   r]   r%   <module>r      s  
 
 
 	     3tH~,,- . K K			8	91 pXc] 2ot o olA AS A(3- APS S ,s D S ,	C 	 	 	 >t > >N $$(&&& "& c]	&Z zGgll3NO$X$$1_`F
'RS
	+=DYZ

)abD DJJ?D*.++T$++&4Buvz  wB  wB  vC  AD  <E
{{TD9$|3K$K   =tg6$[MCI;gFG!"1 r]   