from typing import Optional, Literal
from pydantic import BaseModel, Field

from uuid import uuid4

# Output to frontend
class Landmark(BaseModel) :
    
    # Properties of the landmark
    name : str
    type: Literal['sightseeing', 'nature', 'shopping', 'start', 'finish']
    location : tuple
    osm_type : str
    osm_id : int
    attractiveness : int
    n_tags : int
    image_url : Optional[str] = None                            # TODO future
    website_url : Optional[str] = None
    wikipedia_url : Optional[str] = None
    description : Optional[str] = None                          # TODO future
    duration : Optional[int] = 0                                # TODO future
    name_en : Optional[str] = None

    # Unique ID of a given landmark
    uuid: str = Field(default_factory=uuid4)                    # TODO implement this ASAP
    
    # Additional properties depending on specific tour
    must_do : Optional[bool] = False
    must_avoid : Optional[bool] = False
    is_secondary : Optional[bool] = False                       # TODO future   
    
    time_to_reach_next : Optional[int] = 0                      # TODO fix this in existing code
    next_uuid : Optional[str] = None                            # TODO implement this ASAP

    def __hash__(self) -> int:
        return self.uuid.int
    
    def __str__(self) -> str:
        time_to_next_str = f", time_to_next={self.time_to_reach_next}" if self.time_to_reach_next else ""
        is_secondary_str = f", secondary" if self.is_secondary else ""
        type_str = '(' + self.type + ')'
        if self.type in ["start", "finish", "nature", "shopping"] : type_str += '\t '
        return f'Landmark{type_str}: [{self.name} @{self.location}, score={self.attractiveness}{time_to_next_str}{is_secondary_str}]'
    
