"""Intent understanding prompts for LLM."""


class IntentPrompt:
    """Prompt templates for intent understanding."""
    
    @staticmethod
    def build_intent_prompt(query: str, available_poi_types: list) -> str:
        """Build intent understanding prompt with actual POI types from dataset.
        
        Args:
            query: User query
            available_poi_types: List of actual POI types in the dataset
            
        Returns:
            Formatted prompt string
        """
        poi_types_str = ", ".join(sorted(available_poi_types))
        
        prompt = f"""You are an expert in spatial business analysis.

User goal:
{query}

Dataset contains the following POI types (ONLY use these types in your recommendations):
{poi_types_str}

Co-location patterns are formed by combinations of these POI types that frequently co-occur in space.

Based on the user's goal, please infer:

1. Target business type: What kind of business or activity is the user interested in?
2. Important spatial factors: What spatial characteristics matter most (e.g., proximity to parks, high traffic areas, etc.)?
3. Preferred co-location patterns: What types of POI co-locations would be beneficial? 
   IMPORTANT: Only use POI types from the list above. Examples: ["Park", "Restaurant"], ["Shopping Mall", "Coffee Shop"]
4. Risk factors: What spatial patterns or characteristics should be avoided?

Return ONLY a valid JSON object in the following format:

{{
  "business": "string describing the target business type",
  "importance": {{
    "factor1": "description",
    "factor2": "description"
  }},
  "pattern_preference": [
    ["POI_type1", "POI_type2"],
    ["POI_type3", "POI_type4"]
  ],
  "risk": {{
    "risk1": "description",
    "risk2": "description"
  }}
}}

CRITICAL REQUIREMENTS:
- Only return the JSON object, no other text, explanations, or dialogue history.
- pattern_preference must be a list of lists, where each inner list represents a preferred co-location pattern.
- ALL POI types in pattern_preference MUST be from the list above: {poi_types_str}
- Do NOT use POI types that are not in the dataset.
- If you need to suggest a similar concept, map it to the closest available POI type (e.g., "cafe" -> "Coffee Shop", "store" -> "Shopping Mall").
"""
        return prompt
    
    # Backward compatibility: keep old prompt format but mark as deprecated
    INTENT_PROMPT = """You are an expert in spatial business analysis.

User goal:
{query}

Dataset contains:
- POI types (e.g., Park, Zoo, Restaurant, Shopping Mall, etc.)
- Co-location patterns (frequently co-occurring spatial features)
- Density information
- Mobility patterns

Based on the user's goal, please infer:

1. Target business type: What kind of business or activity is the user interested in?
2. Important spatial factors: What spatial characteristics matter most (e.g., proximity to parks, high traffic areas, etc.)?
3. Preferred co-location patterns: What types of POI co-locations would be beneficial (e.g., ["Park", "Restaurant"], ["Shopping Mall", "Restaurant"])?
4. Risk factors: What spatial patterns or characteristics should be avoided?

Return ONLY a valid JSON object in the following format:

{{
  "business": "string describing the target business type",
  "importance": {{
    "factor1": "description",
    "factor2": "description"
  }},
  "pattern_preference": [
    ["POI_type1", "POI_type2"],
    ["POI_type3", "POI_type4"]
  ],
  "risk": {{
    "risk1": "description",
    "risk2": "description"
  }}
}}

Important: 
- Only return the JSON object, no other text, explanations, or dialogue history.
- pattern_preference should be a list of lists, where each inner list represents a preferred co-location pattern.
- Use actual POI types that might exist in the dataset (e.g., Park, Zoo, Restaurant, Shopping Mall, School, Hospital, etc.).
"""

