
    ɢi?                     ^   d dl Z d dlZd dlZd dlmZmZmZmZmZm	Z	 d dl
mZmZmZmZ d dlmZ  ej"                  e      ZdZeZeZdededed	efd
Zded	efdZddeded	efdZd Zded	efdZdedededededed	efdZded	efdZded	efdZ 	 	 	 	 ddedededededededed	efdZ!y)    N)call_llmcall_llm_textgenerate_imagecall_llm_routedcall_llm_text_routedgenerate_image_routed)validate_analysisvalidate_packagevalidate_site_copyValidationReport)SYSTEM_PROMPT_AURA_BUILDERa  You are a domain valuation expert, niche strategist, and creative business consultant.
You specialize in analyzing domain names and identifying profitable business opportunities.
You think creatively about acronyms, cross-language meanings, mashups, and cross-domain tie-ins.
You always consider affiliate program opportunities and passive income business models.
Always respond with valid JSON.
niche_name
niche_datadomainreturnc                     |sy|j                  dd      }|j                  dd      }|j                  dd      }|j                  dd      }d|  d|r|nd|  d	 d
|  d|  d| d| d| dS )N target_audiencemonetization_modeldescriptionsynopsisac  
--- AUTO-INFERRED DISCOVERY CONTEXT ---
The client did NOT fill out the discovery questionnaire, so you MUST infer rich, specific context from the niche data to produce output that is just as compelling, textured, and personalized as if they had answered every question. Do NOT produce generic or flat content.

INFERRED BRAND PERSONALITY: Based on the "z" niche, infer the ideal brand personality. Consider: What kind of person would this brand be? What tone of voice? What level of formality? What emotional register? Make it specific and vivid.

INFERRED TARGET AUDIENCE: z'Infer the ideal customer persona for a ze business - their age, income, pain points, aspirations, daily life, and what keeps them up at night.z0

INFERRED VISUAL STYLE: Based on the industry (a-  ), select the most impactful visual direction. Consider what colors, imagery, and design patterns dominate successful brands in this space. Be specific about color mood, typography feel, and imagery style.

INFERRED CORE VALUES: Infer 3-5 core values that would resonate with the target audience of a aU   business. These should feel authentic and differentiating, not generic.

INFERRED EMOTIONAL IMPACT: How should visitors FEEL when they land on this site? What transformation or relief should they experience? What problem does this solve for them emotionally, not just practically?

INFERRED PRIMARY ACTION: Based on the monetization model (z), what is the single most important action visitors should take? Design all copy to drive toward this action.

NICHE CONTEXT:  a  

CRITICAL INSTRUCTION: Use all inferred context above to produce content that feels deeply personalized, industry-specific, and emotionally resonant. Every headline, feature description, testimonial, and CTA must feel like it was written by someone who deeply understands this specific niche and its audience. NEVER produce generic "lorem ipsum"-style content.
--- END AUTO-INFERRED CONTEXT ---
get)r   r   r   targetmonetizationr   r   s          //sites/domain-asset-master/app/services/aura.py_infer_discovery_from_nicher      s    ^^-r2F>>"6;L..3K~~j"-H+ ,6, 7%+63Z[eZf  gL  2M  N N//9l ;__i^j k; <H. I}AhZ (!     discovery_contextc                    | syg }|j                  d       |j                  d       | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d      r|j                  d	| d           | j                  d
      r|j                  d| d
           | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d      r|j                  d| d           | j                  d       r|j                  d!| d            | j                  d"      r|j                  d#| d"           | j                  d$      r|j                  d%| d$           |j                  d&       d'j                  |      S )(Nr   z!
--- CLIENT DISCOVERY CONTEXT ---zThe client has provided detailed answers about their vision and preferences. Use these to deeply personalize all generated content.
project_storyzPROJECT VISION & STORY: success_visionzSUCCESS VISION (1-5 years): 	one_thingz+THE ONE THING this site must do perfectly: ideal_audiencezIDEAL AUDIENCE: audience_journeyzAUDIENCE JOURNEY: brand_personalityzBRAND PERSONALITY: core_valueszCORE VALUES: differentiatorzUNIQUE DIFFERENTIATOR: desired_feelingz(DESIRED FEELING when visitors interact: color_palettezCOLOR PALETTE PREFERENCE: visual_stylezVISUAL STYLE PREFERENCE: sites_lovedzWEBSITES THEY LOVE (and why): sites_dislikedz!WEBSITES THEY DISLIKE (and why): primary_actionzPRIMARY VISITOR ACTION: key_featureszKEY FEATURES NEEDED: future_visionzFUTURE VISION: additional_noteszADDITIONAL NOTES: z--- END DISCOVERY CONTEXT ---

)appendr   join)r    sectionss     r   _build_discovery_sectionr7   4   s   HOO89OO  \  ]_-23D_3U2VWX-.67HIY7Z6[\][)EFWXcFdEefg-.*+<=M+N*OPQ/0,->?Q-R,STU01-.?@S.T-UVW]+-(9-(H'IJK-.12CDT2U1VWX./BCTUfCgBhij_-45F5W4XYZ^,34En4U3VWX]+89J=9Y8Z[\-.;<MN^<_;`ab-.23DEU3V2WXY^,/0A.0Q/RST_-/*;O*L)MNO/0,->?Q-R,STUOO5699Xr   niche_hintsc                 @   | j                         j                         }d|v r|j                  d      d   n|}d|v r|j                  d      d   nd}|r
 |ddd       d}|rd	| d
}d| d| d| d| d| d}|r
 |ddd       t        d|t              }	 t        j                  |      }	|	j                  d      st        d      t!        |	d      \  }	}|j"                  s%t        j                  d | d|j$                          |j&                  r/t        j)                  d!| dt+        |j&                         d"       t-        |	d   d# d$      |	d<   |j/                         |	d%<   |r
 |d&dd       |	S # t
        j                  $ r |j                         }
|
j                  d      r6|
j                  dd      d   j                  dd      d   j                         }
|
j                  d      }|
j                  d      dz   }|dk\  r_||kD  rZ	 t        j                  |
||       }	ni# t
        j                  $ r* t        j                  d| d|d d         t        d      w xY wt        j                  d| d|d d         t        d      Y w xY w)'N.r   comz+Decomposing domain keywords and patterns...      r   uz   

IMPORTANT — USER-SUGGESTED NICHES:
The domain owner has specifically suggested these niche directions be explored:
"""ug  """

You MUST include at least one niche that directly addresses each user suggestion above, in addition to your own AI-discovered niches. Score them honestly — if a suggested niche is a poor fit, give it a low score but still include it so the user can see the analysis. Weave user suggestions into the 7-10 niches naturally (they count toward the total).
zAnalyze the domain name "z4" for business potential.

The domain name part is "z" with TLD ".z".
as  
Break down the domain into keywords and explore creative interpretations including:
- Literal meanings
- Acronyms (what could each letter stand for?)
- Cross-language meanings (Spanish, French, German, Japanese, etc.)
- Mashups and portmanteaus
- Cross-domain tie-ins
- Industry-specific interpretations

Generate 7-10 niche business ideas for this domain. For EACH niche, consider:
- Whether an affiliate program exists in that industry (list specific programs if known)
- Whether it could work as a passive/semi-passive income site
- How brandable the domain is for that niche

For each niche, provide:
- "name": short niche name (2-5 words)
- "description": 3-4 sentence description of the business concept, what it does, who it serves, and why it's viable
- "synopsis": A one-paragraph executive summary of what this business would look like, written for someone unfamiliar with the industry
- "monetization_model": primary revenue method (e.g., "SaaS subscription", "marketplace fees", "affiliate revenue", "ad-supported content", "e-commerce", "digital products")
- "affiliate_programs": list of specific affiliate programs or networks relevant to this niche (e.g., "Amazon Associates", "ShareASale", "CJ Affiliate")
- "target_audience": who would use this site
- "time_to_revenue": one of "fast", "medium", "slow"
- "valuation_band": estimated domain+business value range (e.g., "500-2000", "5000-20000", "20000-100000")
- "score": 0-10 rating of viability and potential
- "requires_inventory": boolean - true if the business model needs physical inventory, false if digital/affiliate/service

Return JSON in this exact format:
{
  "domain": "a9  ",
  "keywords": ["keyword1", "keyword2"],
  "interpretations": ["interpretation1", "interpretation2"],
  "domain_summary": "A one-paragraph summary of the domain's overall potential and most promising directions",
  "niches": [
    {
      "name": "...",
      "description": "...",
      "synopsis": "...",
      "monetization_model": "...",
      "affiliate_programs": ["program1", "program2"],
      "target_audience": "...",
      "time_to_revenue": "fast|medium|slow",
      "valuation_band": "...",
      "score": 8,
      "requires_inventory": false
    }
  ]
}z/Analyzing niches and business models with AI...   domain_analysisz```r3   {}zAI response not valid JSON for : i  z0Failed to parse domain analysis response from AInichesz*AI returned no niche ideas for this domainTauto_repairzAnalysis validation failed for zAnalysis auto-repairs for  fixes appliedc                 &    | j                  dd      S )Nscorer   r   )xs    r   <lambda>z analyze_domain.<locals>.<lambda>   s    aeeGQ>O r   )keyreverse_validationzAnalysis complete!)striplowersplitr   SYSTEM_PROMPT_ANALYZERjsonloadsJSONDecodeError
startswithrsplitfindrfindloggererror
ValueErrorr   r	   is_validerrorsrepairsinfolensortedto_dict)r   progress_callbackr8   clean_domain	name_parttldniche_hint_blockpromptresponseresultcleanedstartendanalysis_reports                 r   analyze_domainrp   c   s   <<>'')L.1\.A""3'*|I),)<,

S
!"
%%CGAN  m 	 +<. 9#M# 7  8 ^ ?1Ff KQPQR0&:PQHQH%" ::hEFF/DIFO##6|nBG]G]F^_`0b_E\E\A]@^^lmnfX.4OY]^F8+335F=.15M?  Q.."e$mmD!,R077qA!DJJLGS!mmC 1$A:#+UGE#$67'' U>|nBxX\Y\~N^_` !STTU LL:<.8TXUX>JZ[\OPP Qs+   E< <BJH0/J0=I--,JJc                    | g S t        | t              r3|D ]+  }|| v st        | |   t              st        | |   |      c S  | gS t        | t              r}g }| D ]t  }t        |t              r|j	                  |       %t        |t
              s6|r*t        |      dk\  r|j	                  |d   ||d   di       b|j	                  d|i       v |S g S )Nr?   r   r=   r   text)
isinstancedictlist_ensure_list_of_dictsr4   strra   )data	dict_keyskrk   items        r   rv   rv      s    |	$ 	AADyZQ6,T!Wi@@	A v$ 	2D$%d#D#&Y1!4MM9Q<y|R"HIMM64.1	2 Ir   	site_copyc                 \   ddgddgddgddgddgd	d
gd	dgddgddgd	}|j                         D ]  \  }}|| v st        | |   |      | |<    t        | j                               D ]K  }| |   }t	        |t              st        |      dk(  s(t	        |d   t              s<||d   v sD|d   | |<   M ddddddd}|j                         D ]  \  }}| j                  |      }t	        |t              s(||v s-|j                  |      }|j                         D ]  \  }	}
|	| vs|
| |	<    t        ||j                  |g             | |<   ||k7  s| |=  ddg}|D ]  }| j                  |      }t	        |t              s%|j                         D ]   \  }}t	        |t              s|| vs|| |<   " || v s]t	        | |   t              sq|j                  ||j                  d|j                  dd                  }t	        |t              r|| |<   | |=  g d}|D ]h  }| j                  |      }t	        |t              s%i }|j                         D ]
  \  }}|||<    | |= |j                         D ]  \  }}|| vs|| |<    j ddd}|j                         D ]#  \  }}|| v s|| vs| j                  |      | |<   % |j                         D ]  \  }}|| v st        | |   |      | |<    d| v r1| d   }t	        |t              rd|vrg |d<   d|vrg |d<   | S g g d | d<   | S )!Ntitler   quoteauthorquestionanswervaluelabelnamepricerole)	featurestestimonials	faq_itemsstatshow_it_works_stepspricing_tiersteam_membersgallery_sectionsresource_itemsr=   r   r   r   r   r   r   )r   r   faqtrustpricingr   aboutherocontentbodyr   )problemsolutionhow_it_worksr   
comparisongalleryteam	resourcescontact	cta_finalfooterheadliner   )	how_stepspricing_planscomparison_tableheadersrows)r   r   )
itemsrv   ru   keysrs   ra   rt   r   poprw   )r|   list_field_schemasrL   ry   valwrapper_fieldswrapper_key	inner_keyinnerrz   vstring_fields_with_nestedinner_kinner_vtext_valsection_dicts_to_flattenpromotedkey_aliasesalias	canonicalcts                        r   _normalize_site_copyr      s   m, (+ (+7#&6 '*($m4"M2
 -224 NY)29S>9MIcNN INN$% $nc4 SX]z#a&$7OTW[^_`[aTa VIcN$ "&N #1"6"6"8 	+YmmK(c4 Y#%5GGI&E		 %1I%#$IaL% $9@R@V@VW`bd@e#fIi i'k*	+ ")& 1( 'mmC c4 $'IIK 1 gs+y0H)0Ig&1 iJy~t$D773	37762;N(OPh,%-IcN!#' 
 ( 	1mmC c4 H$'IIK , $+!,#$,NN$4 1 )+)0Ig&1	1 *(K (--/ 8yI)9"<#,==#7Ii 8 -224 NY)29S>9MIcNN Y&)*b$" "9R6
  9;B,GI()r   chosen_niche	blueprintdepthc                 b   |dk(  }|rdnd}i }|r|j                  dd      }	|	j                  dd      j                  d      }
	 t        |
      dkD  rt	        |
d   j                               nd	}t        |
      d
kD  rt	        |
d
   j                               n|dz  }g }|j                  d|      }|j                  dd      }|j                         j                         D ]"  }t        |      dkD  s|j                  |       $ |j                  d      r3|j                  |d   d d D cg c]  }|j                          c}       g }|j                  dd      }|dk  r|j                  d       |j                  d      r|j                  d       |j                  dd      }|dk(  r|j                  d       |dk\  rdn|dk\  rdnd|d d |||d||j                  d d      |j                  d!d      |j                  d"d      |j                  dg       d#	}i }|rV|j                  d$d      }|j                  d%d      }|j                  d&d      }||fD cg c]  }|s|	 }}|rd'j                  |      nd}|j                  d(|j                  d)d            |j                  d*|j                  d+d            |j                  d,d      |||||j                  d-d      |j                  d.d      |j                  d/d      |j                  d0d      |j                  d1d      |j                  d2d      |j                  d3d      d4}|j                         D ci c]  \  }}|s	|| }}}|j                  d5g       D cg c]  }|j                  d6      s| }}|D cg c]  }|d7   	 }}d8} |r+|j                  dd      }t        t        d9|d:z        d      } || || ||d5|id;}!|!S # t        t        f$ r	 d\  }}Y sw xY wc c}w c c}w c c}}w c c}w c c}w )<N	legendarystandardvaluation_bandz
5000-20000,r   -r     r=      )r   i N  r   r   r?   affiliate_programsr>   rI         zmoderate competition expectedrequires_inventoryzrequires physical inventorytime_to_revenuemediumslowzlonger time to revenuehighlow   )minmaxr   r   r   )	intent_levelprimary_keyword_clusterrisksvaluation_band_numericr   r   r   r   r   r'   r(   r*   z; r"   r#   r%   r&   r)   r+   r,   r-   r.   r/   r$   r2   )visionaudiencepositioningbrand_voice_profiler'   r(   r*   color_preferencer,   r-   r.   r/   r$   r2   r6   enabledrL   g333333?gGz?g      $@)moder   primary_nicheprimary_confidenceniche_context	discoveryr   )r   replacerQ   ra   intrO   r\   
IndexErrorrP   r4   extendr5   r   roundr   )"r   r   r   r    r   r   is_legendaryr   r   r   	val_partsval_minval_maxkeywordsr   descwordpr   rI   time_to_revr   r'   r(   r*   voice_partsr   rz   r   senabled_sectionssection_keys
confidencestructured_inputs"                                     r   _build_structured_inputr   G  sQ   K'L&;JDM#(8,G"**3399#>		+36y>A3Ec)A,,,./4G36y>A3Ec)A,,,./7UV;G ~~fl3~~mR0JJL&&( 	&D4y1}%	& >>./OO
;O0PQSRS0TU1QWWYUVw*19LL89>>./LL67 nn%6A& LL12 ',qjF5A:xSX'/|.5g&F"z26",..1Er"J)~~.?D",..1Er"J

 I-112ErJ'++M2>+//0A2F#4o"FLQ!qLL8Cdii4 (++O=N=R=RSceg=hi)--.>@Q@U@UVhjl@mn,001A2F#6!2&. 1 5 5or J-11."E,00C/334DbI/334DbI*..{B? 1 5 56H" M
	  '0oo&7=da1QT=	=#,==R#@UaAEE)DTUU&67AeH7L7Jw*3tUT\2A6
 %(&

 a J' 	+*GW	+ V: M& >U7sC   AO< /P"P*P)
P!4P!P''P'1P,<PP
brand_datac           	      Z   | j                  d| j                  dd            }t        |t              sd}| j                  dg       }d}d}d}|r]|t        |      k  rO||   }|j                  di       }|r6|j                  d	|      }|j                  d
|      }|j                  d|      }||| j                  d|      | j                  d|      | j                  d|      | j                  dd      d}|d   dk(  r
|dk7  r||d<   |d   dk(  r
|dk7  r||d<   |d   dk(  r
|dk7  r||d<   |S )Nrecommended_indexrecommendedr   options#4F46E5z#7C3AEDz#06B6D4paletteprimaryprimary_altaccentcolor_primarycolor_secondarycolor_accentindustry_contextr   )r   r   r  r  r  r  )r   rs   r   ra   )	r   rec_idxr   r  r  r  
rec_optionr   rk   s	            r   _translate_brand_outputr    sT   nn0*..PQ2RSGgs#nnY+GMOL7S\)W%
..B/#KK	=AM%kk-IO";;x>L #G%>>*;_M"~|D&NN+=rBF o)+0J"/ I-/Y2N$3 !n*|y/H!-~Mr   c                 ,	   d| v rd| vr| d   | d<   d| v rd| vr| d   | d<   d| v rd| vr| d   | d<   d| v rd| vr| d   | d<   d	| v rHt        | d	   t              r5| d	   }d
| vrd
|v r|d
   | d
<   d| vrd|v r|d   | d<   d| vrd|v r|d   | d<   d| v rHt        | d   t              r5| d   }d| vrd|v r|d   | d<   d| vrd|v r|d   | d<   d| vrd|v r|d   | d<   d| v rCt        | d   t              r0| d   }|j                         D ]  \  }}|| vs|}|dk(  rd}|| |<    d| v rIt        | d   t              r6| d   }|j                         D ]  \  }}|dk(  r
d| vr|| d<   || vs|| |<     d| v rt        | d   t              r| d   D ]y  }t        |t              sd|v rPd|vrL|j	                  dd      g}	|j	                  d      r|	j                  |d          dj                  |	      |d<   d|v smd|vsr|d   |d<   { d| v rgt        | d   t              rT| d   j	                  dg       }
t        |
t              r/|
D ]%  }t        |t              sd|v sd|vs|d   |d<   ' |
| d<   d| v rgt        | d   t              rT| d   j	                  dg       }
t        |
t              r/|
D ]%  }t        |t              sd|v sd|vs|d   |d<   ' |
| d<   d| v rut        | d   t              rb| d   j	                  d g       }t        |t              r=|| d!<   d"| vr| d   j	                  d#d$      | d"<   d%| vr| d   j	                  d&d      | d%<   d'| v rt        | d'   t              r| d'   j	                  d(g       }t        |t              rw|D ]5  }t        |t              sd|v rd)|vr|d   |d)<   d*|v s)d+|vs.|d*   |d+<   7 || d,<   d-| vr| d'   j	                  d#d.      | d-<   d/| vr| d'   j	                  d&d      | d/<   d0| v r=t        | d0   t              r*| d0   j	                  d1g       }t        |t              r|| d1<   d2| v rHt        | d2   t              r5| d2   }d3|v rd3| vr|d3   | d3<   d4|v rd4| vr|d4   | d4<   d5|v rd5| vr|d5   | d5<   | S )6Nproblem_bodyproblem_descriptionsolution_bodysolution_description	hero_bodyhero_descriptionabout_titleabout_headingr   problem_titleproblem_pointsr   solution_titlesolution_pointsr   r   r   summaryr   r   detailr   	icon_hinticonr   r   contextr   r   r   r   stepsr   	how_titler~   zHow It Workshow_subtitlesubtitler   tiersfeatures_listr   highlightedr   pricing_titlePricingpricing_subtitler   r   r   r   comparison_titlecomparison_points)rs   rt   r   ru   r   r4   r5   )r|   probsolr   rz   r   
mapped_keyr   feat
desc_partsr   r{   r  r  tierr   comps                    r   _translate_site_copy_outputr.    s   "'<I'M+4^+D	'()#(>i(O,5o,F	()i$6i$G(1+(>	$%	!oY&F%.}%=	/"I*Yy-A4"H#)+40G)-o)>Io& 	1n6L/3N/CI+,9,1AT1I*./?*@I&'Y:i
.CT#J
#9,1AS1H*-.>*?I&'!2#7M03O0DI,-I-2Cs2J+./@+AI'(z)F*;TB JJL 	*DAq	!
#!3J()	*%	* )
9W+=t D'"KKM 	!DAqM!oY&F-.	/*)# 	!		! Y:i
.CT#Jj) 	5D$%$d)B"&((9b"9!:Jxx)"))$x.9*-((:*>D'$&6+=#'#4DL	5 )
9W+=t D'"&&w3eT" :dD)i4.?MY]D]*.y/D': "'Ig"z)N2KT'R.)--gr:eT" 6dD)~($*>)-fX6 ).In%"z)N2KT'R.)--gr:eT".3I*+)+)2>)B)F)FwP^)_	+&Y.,5n,E,I,I*VX,Y	.)I*Yy-A4"H)$(("5eT" BdD)!T)oT.I04Z0@_-$,d1J.2=.A]+B */Io&i/-6y-A-E-Egy-Y	/*!209)0D0H0HUW0X	,-	j5)94@e$((b9	i&%.Ik"y Z	,0G%N&%*<I*M,01C,DI()%*<I*M,01C,DI()$&+>i+O-12E-FI)*r   template_typebrandkit_contextassembled_contextc	                 b   ddl m}	m}
 | j                         j	                         }|s |	d      }|j                  dg       D cg c]  }|j                  d      s| }}|D cg c]  }|d   	 }}t        |      }|j                  dd      }|dk(  }t        }|r
 |d	d
d       t        ||||||      }d}|rd| d}d}|rt        |      }n|rt        |||      }dt        j                  |d       d| d| d| d| d}|r |d| ddd       t        d||d      }	 t        j                  |      }d|v rt|j#                  d      }|j                  d      rt$        j'                  d| d|d           |j                  d       rt$        j)                  d!| d|d            ||d"<   |j                  d#i       }t+        |      }dd$lm}  ||d%&      \  }}|j0                  r/t$        j)                  d'| dt        |j0                         d(       ||d#<   |j                  di       }t3        |      }t5        |      }t7        |d%&      \  }}|j8                  s%t$        j;                  d)| d|j<                          |j0                  r/t$        j)                  d*| dt        |j0                         d(       ||d<   |D ]R  }|d   } | |vsi }!|j                  d+g       D ]  }"|"d   }#|#|v s||#   |!|#<    |!r;t$        j'                  d,|         T |j                  dd      ||d-|d.<   |r
 |d/d0d       d}$|rd1|j                  d2|       d3|j                  d4d       d5|j                  d6d       d7|j                  d8d       d9|j                  d:d       d;d<j?                  |j                  d=g              d>|j                  d?d       }$d@| dA| dB| d|$ d| d| dC}%tA        dD|%tB              }&d }'|r
 |dEdFd       	 |j                  d#i       }(dG})|(j                  dHg       }*|(j                  dId      }+|*r#|+t        |*      k  r|*|+   j                  d2dG      })d},|rT|j                  dJ      r	dK|dJ    dL},|j                  dM      r|,dN|dM    dLz  },|j                  dO      r|,dP|dO    dLz  },dQ| dR|) dS| dT|(j                  dUdV       dW|, 
}-tE        dX|-dYZ      }'t$        j)                  d[|        |r
 |d]dd       |||j                  d#i       |j                  di       |&d^}/|'r|'|/d_<   |/S c c}w c c}w # t        j                  $ r t!        d      w xY w# tF        $ r'}.t$        j'                  d\| d|.        d }'Y d }.~.d }.~.ww xY w)`Nr   )get_default_blueprintblueprint_to_prompt_speccomprehensiver6   r   rL   r   r   z"Creating brand identity options...r=   r   r   z*
--- PROJECT CONTEXT (Running Memory) ---
z
--- END PROJECT CONTEXT ---
zXGenerate a complete business-in-a-box package based on the following structured input:

r?   )indentz

r3   zr

Respond with STRICTLY VALID JSON following the RESPONSE SCHEMA from your instructions.
Generate content for ALL z sections listed in the blueprint.
For icon fields, use one of: shield|chart|globe|zap|users|star|target|clock|heart|check|book|rocket|sparkle|gem|fire|brain|leaf|sun|moon|flower|wave|lotuszGenerating brand + z content sections...r|   i @  )
max_tokensz+Failed to parse brand/copy response from AImetawarningszAI warnings for rC   assumptionszAI assumptions for _metabrand)validate_brandTrE   zBrand auto-repairs for rG   z Site copy validation failed for zSite copy auto-repairs for fieldsz)AI did not generate content for section: )r   r   section_count
_blueprintz#Writing marketplace sales letter...r>   z
Niche details:
- Name: r   z
- Description: r   z
- Synopsis: r   z
- Monetization: r   z
- Target Audience: r   z
- Affiliate Programs: z, r   z
- Valuation band: r   z0Write a compelling sales letter for the domain "z" targeting the "z	" niche.
u  

This sales letter should be suitable for posting on domain marketplaces like Flippa or Sedo.

The letter should:
1. Open with a strong hook about the opportunity
2. Explain what this domain/business is (assume the reader knows nothing about the niche)
3. Detail 3-4 specific monetization methods and realistic revenue potential
4. Highlight the domain's brandability, memorability, and SEO value
5. Include what the buyer gets (the business-in-a-box concept: brand, website, copy, strategy)
6. Mention relevant affiliate programs or partnerships available
7. Close with urgency and a clear call to action

Write it in a professional but persuasive tone. Use markdown formatting (headers ##, bold **, bullet points -, numbered lists).
Keep it between 500-700 words. Make it specific to this domain and niche - not generic.

IMPORTANT: Return ONLY the markdown text. Do NOT wrap it in JSON or any other structure. No title field, no metadata — just the sales letter content in markdown.sales_letterz)Generating hero image for site preview...r   Businessr   r   r,   zVisual style: r:   r+   z Color mood: r*   z The image should evoke: zDCreate a professional, modern hero banner image for a website about z. 
The brand is called "z". 
Style: Clean, modern, professional. High-quality stock-photo style.
The image should visually communicate the industry/niche of z.
Do NOT include any text or logos in the image. Just a beautiful, relevant background image.
Color palette hint: use tones related to r  r   z.

hero_image	1536x1024)sizezGenerated hero image for z!Hero image generation failed for zPackage complete!)r   r   r<  r|   rA  hero_image_data)$app.services.blueprintr3  r4  rO   rP   r   ra   r   r   r7   r   rS   dumpsr   rT   rU   r\   r   rZ   warningr`   r  app.services.validatorsr=  r_   r.  r   r   r]   r[   r^   r5   r   SYSTEM_PROMPT_BUILDERr   	Exception)0r   r   r   rd   r    r/  r   r0  r1  r3  r4  re   r   r   enabled_keysr?  r   r   builder_system_promptr   context_blockdiscovery_sectionbrand_promptbrand_responsepackage_datar8  r   r=  brand_reportr|   copy_reportsectionrL   section_datafieldfkeyniche_desc_for_salessales_promptrA  rF  
brand_info
brand_nameoptsrecr,   image_prompterk   s0                                                   r   build_packagerb  >  s     W<<>'')L)/:	#,==R#@UaAEE)DTUU&67AeH7L7()MMM'?3EK'L6>1E.lJ9e
 M   45FG	7jR^_Q' ( )      ( )[
^L />RSUVXYZ$[,@UbghNHzz.1 '88JNN-l^2d:>N=OPQ88M"KK-l^2d=>Q=RST $W!!'2.J(4J6-jdKJ-l^2c,BVBV>W=XXfgh&L  b1I+I6I$Y/I/	tLI{7~RHZHZG[\]1,r#kFYFYBZA[[ijk )L# 	ReniL Xr2 9U|9$)24L&9  !J3%PQ	R w8(&"L ?AF$			-. /}b12 3^^J+, - 4b9: ;NN#4b9: ;yy0Db!IJK L>>"2B78 < H~Ufgsft u       d	gL, (F[\LOEq!L!%%gr2

~~i,nn]A.C#d)Ocvz:J $$^4!/0A.0Q/RRST $$_5-0A/0R/SST UU $$%67";<MN_<`;aab cc_`l_m n \ "==IN K**4..)*T)U V 0lQ\]/~>?
 -q!4 $!!'2.!%%k26$F $3 !Mm V7`  HFGGHf  :<.1#NOs7   UU&U(U C<U> U;>	V.V))V.)Nr   )NNNr   Nr   r   )"rS   osloggingapp.services.llmr   r   r   r   r   r   rJ  r	   r
   r   r   app.services.promptsr   	getLogger__name__rZ   rR   rK  SYSTEM_PROMPT_BUILDER_LEGENDARYrw   rt   r   r7   rp   rv   r   r   r  r.  rb   r   r   <module>rk     s    	  C  C m m ;			8	$#  3 "< C T 3 SV @, , ,^k3 kS kRV k\,]D ]T ]@\C \s \ \/3\@D\MP\UY\~# # #Lo4 oD od FJDHAEGIA# AS Ad A=AA!$A:>A %(A BEA OSAr   