"""
Конфигурация service portal (Pydantic Settings).

Читает из .env:
  - DATABASE_URL: PostgreSQL URL
  - SECRET_KEY: ключ сессий
  - SESSION_TTL: время жизни сессии (сек)
  - DOCS_DIR/UPLOADS_DIR: пути к документам
"""
import os
from pathlib import Path
from pydantic_settings import BaseSettings
from functools import lru_cache


class Settings(BaseSettings):
    DATABASE_URL: str = "postgresql+asyncpg://aegisone:aegisone_pass@localhost:5432/aegisone"
    SECRET_KEY: str = "change-me-to-random-string"
    SESSION_TTL: int = 3600
    APP_ENV: str = "development"
    LOG_LEVEL: str = "debug"
    DOCS_DIR: str = str(Path(__file__).parent.parent / "docs")
    PERMISSIONS_DIR: str = str(Path(__file__).parent.parent.parent / "permissions")
    UPLOADS_DIR: str = str(Path(__file__).parent.parent.parent / "uploads")
    PORTAINER_URL: str = "https://81.177.141.34:9443"

    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"


@lru_cache()
def get_settings() -> Settings:
    return Settings()
