import os
import urllib.parse
from dotenv import load_dotenv

# Load environment variables from the .env file
load_dotenv()

class Settings:
    # Database Settings
    DB_USER = os.getenv("DB_USER", "aiagent_u")
    
    # Fetch the raw password and URL-encode it to safely handle special characters like '@'
    _raw_db_pass = os.getenv("DB_PASS", "AiA@gent231")
    DB_PASS = urllib.parse.quote_plus(_raw_db_pass)
    
    DB_HOST = os.getenv("DB_HOST", "localhost")
    DB_NAME = os.getenv("DB_NAME", "aiagent_d")
    
    # Construct the final URL with the encoded password
    DATABASE_URL = f"postgresql://{DB_USER}:{DB_PASS}@{DB_HOST}/{DB_NAME}"

    # SMTP Settings
    SMTP_HOST = os.getenv("SMTP_HOST", "smtp.zeptomail.in")
    SMTP_PORT = int(os.getenv("SMTP_PORT", 465))
    SMTP_USER = os.getenv("SMTP_USER", "")
    SMTP_PASS = os.getenv("SMTP_PASS", "")
    SMTP_FROM = os.getenv("SMTP_FROM", "AiAgent <aiagent@transactglobal.com>")

    # API Keys
    OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")
    ELEVENLABS_API_KEY = os.getenv("ELEVENLABS_API_KEY", "")

settings = Settings()