import os
from typing import Annotated, Literal
from dotenv import load_dotenv
from pydantic import AnyUrl, BeforeValidator

load_dotenv()

class Config:
    def __init__(self):
        self.ENVIRONMENT: Literal["local", "staging", "production", "testing"] = os.getenv("ENVIRONMENT", "local")

        self.MONGO_DB_URI = os.getenv("MONGO_URI_LOCAL")
        self.QDRANT_URI = os.getenv("QDRANT_URI_LOCAL")
        self.DATA_PATH = os.getenv("DATA_PATH_LOCAL")
        self.USUARI = os.getenv("USUARI")
        self.CONTRASENYA = os.getenv("CONTRASENYA")
        if self.ENVIRONMENT == "local":
            self.MONGO_DB_URI = os.getenv("MONGO_URI_LOCAL")
            self.MONGO_DB = os.getenv("MONGO_DB")
            self.MONGO_COLLECTION = os.getenv("MONGO_COLLECTION")
            self.MONGO_REGISTRE_COLLECTION = os.getenv("MONGO_REGISTRE_COLLECTION")
        elif self.ENVIRONMENT == "testing":
            self.MONGO_DB = os.getenv("MONGO_DB_TEST")
            self.MONGO_COLLECTION = os.getenv("MONGO_COLLECTION_TEST")
        elif self.ENVIRONMENT == "docker":
            self.MONGO_DB = os.getenv("MONGO_DB")
            self.MONGO_COLLECTION = os.getenv("MONGO_COLLECTION")
            self.MONGO_DB_URI = os.getenv("MONGO_URI_DOCKER")
            self.QDRANT_URI = os.getenv("QDRANT_URI_DOCKER")
            self.DATA_PATH = os.getenv("DATA_PATH_DOCKER")
            self.MONGO_REGISTRE_COLLECTION = os.getenv("MONGO_REGISTRE_COLLECTION")
        elif self.ENVIRONMENT == "production":
            self.MONGO_DB = os.getenv("MONGO_DB")
            self.MONGO_COLLECTION = os.getenv("MONGO_COLLECTION")
            self.MONGO_DB_URI = os.getenv("MONGO_URI_PROD")
            self.QDRANT_URI = os.getenv("QDRANT_URI_PROD")
            self.QDRANT_API_KEY = os.getenv("QDRANT_API_KEY")
            self.DATA_PATH = os.getenv("DATA_PATH_PROD")
            self.MONGO_REGISTRE_COLLECTION = os.getenv("MONGO_REGISTRE_COLLECTION")


config = Config()