from pydantic_settings import BaseSettings, SettingsConfigDict

from app.log import get_logger

log = get_logger(__name__)


class Settings(BaseSettings):
    """Configuration settings for the application."""

    model_config = SettingsConfigDict(env_file="./.env", env_file_encoding="utf-8", case_sensitive=True, extra="allow")

    API_VERSION: str = "0.0.1"
    PROJECT_TITLE: str = "API Documentation"
    PROJECT_NAME: str = "API Documentation"
    DESCRIPTION: str = "API Documentation"

    SQL_HOST: str = "host.docker.internal"
    SQL_USER: str = "root"
    SQL_PASS: str = ""
    SQL_DB: str = "CNC_database"
    SQL_PORT: int = 3306

    # MONGODB
    MONGODB_URI: str = "mongodb://localhost:27017"
    MONGODB_DB: str = "main"
    MONGO_HOST: str="localhost"
    MONGO_PORT: str = "27017"

    MAIN_ENCRYPTION_IV: str = "1234567890123456"
    MAIN_ENCRYPTION_KEY: str = "1234567890123456"

    ALLOWED_ORIGINS: list = ["127.0.0.3"]

    IDLE_DURATION_IN_MINUTES: int = 10
    REDIS_HOST: str = "redis://localhost"



def get_settings(env: str = "local") -> Settings:
    """
    Return the settings object based on the environment.

    Parameters
    ----------
        env (str): The environment to retrieve the settings for. Defaults to "dev".

    Returns
    -------
        Settings: The settings object based on the environment.

    Raises
    ------
        ValueError: If the environment is invalid.
    """
    log.debug("getting settings for env: %s", env)
    return Settings()  # type: ignore  # noqa: PGH003


settings = get_settings()
CONFIG_SETTINGS = Settings()
