from pydantic import BaseModel
from typing import List, Optional, Union, Literal, Dict, Any

class Property(BaseModel):
    property_id: str

class AudienceBaseModel(Property):
    audience_id: str
class DataResponse(BaseModel):
    status: str = 'ok'
    message: str
    data: Union[List[Dict[str, Any]], Dict[str, Any]]

class Suggesstion(Property):
    source: Literal['event', 'user', 'ad_refferal']

class AddAudience(Property):
    id: Optional[str] = None  # Audience ID (optional for create, will be generated if not provided)
    active: bool = False
    type: Literal['preset', 'builder']
    name: str
    nodes: dict
    connections: Union[Dict[str, Any], str] = None
    settings: dict = {
        "type": "dynamic",
        "calculation": {
            "type": "daily",
            "time": "09:00"
        }
    }

class GetAudience(Property):
    audience_id: str = 'all'

class AudienceModel(AudienceBaseModel):
    active: bool = False
    type: Literal['preset', 'builder']
    name: str
    nodes: dict
    connections: Union[Dict[str, Any], str] = None
    settings: dict = {
        "type": "dynamic",
        "calculation": {
            "type": "daily",
            "time": "09:00"
        }
    }

class DeleteAudience(Property):
    audience_id: str

class UpdateAudienceStatus(Property):
    audience_id: str
    active: bool
