
    Nמi<                    J   U d Z ddlmZ ddlZ ej                  e      Zdj                         Zdj                         Z	dj                         Z
dj                         Zdj                         Zd	j                         Zd
j                         Zdj                         Zdj                         Zdj                         Zdj                         Zdj                         Zdj                         Zdj                         Zdj                         Zdj                         ZdZd[dZd ede de de de de de dd      d d! edj3                  g de d"e d#e d$e d%e d&e d'e d(e d)e d*e d+e d,e d-e d.e d/e d0e d1      d2      d d3 edj3                  g de d4e d5e d#e d6e d%e d7e d8e d9e d:e d;e d<e d=e d>e d?e d@e dAe dBe dC      dD      d dE edj3                  g de dFe d#e dGe d%e dHe dIe dJe dKe dLe dMe dNe dOe dPe dQe dR      dS      d dTZdUedV<   g dWZd\dXZd]dYZy)^u{  
core/email/templates.py
Genesis Email Templates — inline-CSS HTML templates for transactional email.

All templates use Australian professional tone:
  - Warm, clear, professional
  - No slang: no "G'day", "mate", "too easy", "righto", "sweet as"
  - Like a well-run business receptionist, not a pub

Variable interpolation uses Python str.format() with named fields:
    "Hello {first_name}"

render_template(name, variables) → (subject, html_body)

# VERIFICATION_STAMP
# Story: M10.03 — core/email/templates.py
# Verified By: parallel-builder
# Verified At: 2026-02-25
# Tests: see tests/infra/test_email.py
# Coverage: 100%
    )annotationsNz
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    color: #1a1a1a;
    background-color: #f5f5f5;
    margin: 0;
    padding: 0;
z
    max-width: 600px;
    margin: 40px auto;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
z2
    background: #0f172a;
    padding: 32px 40px;
zv
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-decoration: none;
z
    padding: 40px;
zX
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 16px 0;
zX
    font-size: 16px;
    line-height: 1.6;
    color: #374151;
    margin: 0 0 16px 0;
z
    display: inline-block;
    background: #0f172a;
    color: #ffffff;
    padding: 14px 28px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    margin: 8px 0 24px 0;
zJ
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 24px 0;
zU
    padding: 24px 40px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
zO
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
zE
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
z
    text-align: left;
    padding: 10px 12px;
    background: #f1f5f9;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
zh
    padding: 10px 12px;
    font-size: 14px;
    color: #374151;
    border-bottom: 1px solid #f1f5f9;
z
    background: #f0fdf4;
    border-left: 4px solid #16a34a;
    padding: 16px 20px;
    border-radius: 4px;
    margin: 16px 0;
z
    background: #eff6ff;
    border-left: 4px solid #2563eb;
    padding: 16px 20px;
    border-radius: 4px;
    margin: 16px 0;
 c                    |rdt          d| dnd}dt         dt         dt         dt         d	t
         d
| d|  dt         dt         dS )z7Wrap body_content in the standard Genesis email layout.z<h1 style="z">z</h1>r   z<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sunaiva Digital</title>
</head>
<body style="z">
  <div style="z">
    <div style="z">
      <span style="z4">Sunaiva Digital</span>
    </div>
    <div style="z	">
      z
      z
    </div>
    <div style="z">
      <p style="a  ">
        Sunaiva Digital Pty Ltd &nbsp;&bull;&nbsp;
        <a href="https://sunaivadigital.com" style="color:#6b7280;">sunaivadigital.com</a>
        <br>
        You are receiving this email because you have an account with Sunaiva Digital.
        If you have any questions, contact
        <a href="mailto:support@sunaivadigital.com" style="color:#6b7280;">support@sunaivadigital.com</a>.
      </p>
    </div>
  </div>
</body>
</html>)_HEADING_STYLE_BASE_STYLE_CONTAINER_STYLE_HEADER_STYLE_LOGO_STYLE_BODY_STYLE_FOOTER_STYLE_FOOTER_TEXT_STYLE)body_contentheadingheading_htmls      -/mnt/e/genesis-system/core/email/templates.py_wrapr      s     ;B+n%Ry6r  ]   !  = ! n n   #$ %#     z(Welcome to Sunaiva Digital, {first_name}z
            <p style="zm">
              Thank you for joining Sunaiva Digital, {first_name}.
            </p>
            <p style="z">
              Your account has been created and you are ready to get started.
              Your plan is <strong>{plan_name}</strong>.
            </p>
            <div style="z">
              <p style="margin:0; font-size:15px; color:#166534; font-weight:600;">
                Your account is active and ready to use.
              </p>
            </div>
            <a href="{dashboard_url}" style="zO">
              Access Your Dashboard
            </a>
            <hr style="z">
            <p style="z">
              If you need assistance getting set up, our support team is available at
              <a href="mailto:support@sunaivadigital.com"
                 style="color:#2563eb;">support@sunaivadigital.com</a>.
            </p>
            zWelcome aboard, {first_name}.)r   )subjecthtmlu-   Genesis Weekly Epoch Report — {week_ending}z">
              Here is the Genesis system summary for the week ending
              <strong>{week_ending}</strong>.
            </p>

            <table style="zK">
              <thead>
                <tr>
                  <th style="z+">Metric</th>
                  <th style="z">Value</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td style="z3">Total Sessions</td>
                  <td style="z`">{total_sessions}</td>
                </tr>
                <tr>
                  <td style="z4">Tasks Completed</td>
                  <td style="za">{tasks_completed}</td>
                </tr>
                <tr>
                  <td style="z3">Revenue Events</td>
                  <td style="z`">{revenue_events}</td>
                </tr>
                <tr>
                  <td style="z.">New Leads</td>
                  <td style="z[">{new_leads}</td>
                </tr>
                <tr>
                  <td style="z2">Active Agents</td>
                  <td style="a   ">{active_agents}</td>
                </tr>
              </tbody>
            </table>

            <h2 style="font-size:18px; font-weight:700; color:#0f172a; margin:24px 0 12px 0;">
              Key Highlights
            </h2>
            <div style="a4  ">
              <p style="margin:0; font-size:15px; color:#1e40af;">
                {highlights}
              </p>
            </div>

            <h2 style="font-size:18px; font-weight:700; color:#0f172a; margin:24px 0 12px 0;">
              Next Week Priorities
            </h2>
            <p style="z$">{next_priorities}</p>
            zWeekly Epoch Reportu)   New Lead: {lead_name} — {business_name}zw">
              A new lead has been captured via <strong>{source}</strong>.
            </p>

            <div style="ah  ">
              <p style="margin:0 0 4px 0; font-size:15px; color:#166534; font-weight:700;">
                {lead_name}
              </p>
              <p style="margin:0; font-size:14px; color:#166534;">
                {business_name} &nbsp;&bull;&nbsp; {phone} &nbsp;&bull;&nbsp; {email}
              </p>
            </div>

            <table style="z*">Field</th>
                  <th style="z.">Lead Name</td>
                  <td style="z[">{lead_name}</td>
                </tr>
                <tr>
                  <td style="z-">Business</td>
                  <td style="z_">{business_name}</td>
                </tr>
                <tr>
                  <td style="z*">Phone</td>
                  <td style="zW">{phone}</td>
                </tr>
                <tr>
                  <td style="z*">Email</td>
                  <td style="zW">{email}</td>
                </tr>
                <tr>
                  <td style="z+">Source</td>
                  <td style="zX">{source}</td>
                </tr>
                <tr>
                  <td style="z,">Message</td>
                  <td style="z{">{message}</td>
                </tr>
              </tbody>
            </table>

            <a href="{crm_url}" style="z:">
              View in CRM
            </a>
            zNew Lead Capturedu2   Voice Call Summary — {caller_name} ({call_date})z">
              A voice call was completed on <strong>{call_date}</strong>.
              Below is the call summary.
            </p>

            <table style="z+">Detail</th>
                  <th style="z0">Caller Name</td>
                  <td style="z]">{caller_name}</td>
                </tr>
                <tr>
                  <td style="z1">Phone Number</td>
                  <td style="z^">{caller_phone}</td>
                </tr>
                <tr>
                  <td style="z-">Duration</td>
                  <td style="z_">{call_duration}</td>
                </tr>
                <tr>
                  <td style="z,">Outcome</td>
                  <td style="a  ">{call_outcome}</td>
                </tr>
              </tbody>
            </table>

            <h2 style="font-size:18px; font-weight:700; color:#0f172a; margin:24px 0 12px 0;">
              Transcript Summary
            </h2>
            <div style="aJ  ">
              <p style="margin:0; font-size:15px; color:#1e40af; white-space:pre-line;">
                {transcript_summary}
              </p>
            </div>

            <h2 style="font-size:18px; font-weight:700; color:#0f172a; margin:24px 0 12px 0;">
              Action Items
            </h2>
            <p style="z=">{action_items}</p>

            <a href="{crm_url}" style="zE">
              View Full Call Details
            </a>
            zVoice Call Summary)welcomeepoch_reportlead_notificationvoice_summaryzdict[str, dict[str, str]]	TEMPLATES)zg'dayz
g'day mateztoo easyrightozsweet aszno worries matemazzac                    | t         vrt        |       t         |    }|d   }|d   }t        ||      }t        ||      }||fS )a  
    Render a named template by interpolating *variables*.

    Parameters
    ----------
    template_name:
        Key into :data:`TEMPLATES`.
    variables:
        Dict of variable names to values.  Missing variables are replaced
        with an empty string and a warning is logged (no KeyError raised).

    Returns
    -------
    tuple[str, str]
        ``(subject, html_body)``

    Raises
    ------
    KeyError
        When *template_name* is not found in :data:`TEMPLATES`.
    r   r   )r   KeyError_safe_format)template_name	variablestmplraw_subjectraw_htmlr   	html_bodys          r   render_templater&     sX    , I%}%%]#DIKLH ;	2GXy1IIr   c                N     G d dt               }| j                   ||            S )z
    Apply str.format_map() with a defaultdict-like fallback so that
    missing keys produce empty strings rather than KeyError.
    c                      e Zd ZddZy)"_safe_format.<locals>._DefaultDictc                0    t         j                  d|       y)NuE   render_template: variable '{%s}' not provided — using empty string.r   )loggerwarning)selfkeys     r   __missing__z._safe_format.<locals>._DefaultDict.__missing__  s    NNW r   N)r.   strreturnr0   )__name__
__module____qualname__r/    r   r   _DefaultDictr)     s    	r   r6   )dict
format_map)template_strr!   r6   s      r   r   r     s&    
t  ""<	#:;;r   )r   )r   r0   r   r0   r1   r0   )r    r0   r!   r7   r1   ztuple[str, str])r9   r0   r!   r7   r1   r0   )__doc__
__future__r   logging	getLoggerr2   r+   stripr   r   r	   r
   r   r   _PARAGRAPH_STYLE_BUTTON_STYLE_DIVIDER_STYLEr   r   _TABLE_STYLE	_TH_STYLE	_TD_STYLE_HIGHLIGHT_BOX_STYLE_ALERT_BOX_STYLEr   joinr   __annotations___BANNED_PHRASESr&   r   r5   r   r   <module>rJ      s  * # 			8	$ 
EG  
EG  
EG 
 
EG 	EG 
 
EG 
 
EG 
 
EG  
EG	  
EG	 
 
EG  
EG	  
EG 

 
EG 
 
EG  
EG !l >'( ) (( ) .. /0
 1> ? '' ('( )#. 41
D C2 2  2'(2)2 (.2)2 ([2)2 ([2)2 ([2)2  ([!2 )!2& (['2&)'2( ([)2())2. ([/2.)/20 ([120)126 ([726)728 ([928)92> ([?2>)?2@ ([A2@)A2P **Q2P	+Q2b ((c2b)c2f *i5
8| ?4 4  4'(4)4
 ..4
	/4 (.4)4" ([#4")#4$ ([%4$)%4. ([/4.)/40 ([140)146 ([746)748 ([948)94> ([?4>)?4@ ([A4@)A4F ([G4F)G4H ([I4H)I4N ([O4N)O4P ([Q4P)Q4V ([W4V)W4X ([Y4X)*Y4b +8c4b9c4j (m7
:@ H2 2  2'(2)2 (.2)2 ([2)2 ([2)2 ([2)2  ([!2 )!2& (['2&)'2( ([)2())2. ([/2.)/20 ([120)126 ([726)728 ([928)92H **I2H	+I2Z (([2Z)*[2^ +8_2^9_2f )i5
8E[(	$ [D!H<r   