from __future__ import annotations

import os
from pathlib import Path


BASE_DIR = Path(__file__).resolve().parent


class Config:
    APP_NAME = "Putzliga"
    SECRET_KEY = os.getenv("SECRET_KEY", "dev-secret-change-me")
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    WTF_CSRF_TIME_LIMIT = None

    DATA_DIR = Path(os.getenv("DATA_DIR", BASE_DIR / "data")).resolve()
    SQLITE_PATH = Path(os.getenv("DATABASE_PATH", DATA_DIR / "putzliga.db")).resolve()
    SQLALCHEMY_DATABASE_URI = f"sqlite:///{SQLITE_PATH}"

    UPLOAD_FOLDER = Path(os.getenv("UPLOAD_FOLDER", DATA_DIR / "uploads")).resolve()
    MAX_CONTENT_LENGTH = 3 * 1024 * 1024

    APP_BASE_URL = os.getenv("APP_BASE_URL") or os.getenv("CLOUDRON_APP_ORIGIN", "http://localhost:8000")
    APP_TIMEZONE = os.getenv("APP_TIMEZONE", "Europe/Berlin")
    PORT = int(os.getenv("PORT", "8000"))

    VAPID_PUBLIC_KEY = os.getenv("VAPID_PUBLIC_KEY", "")
    VAPID_PRIVATE_KEY = os.getenv("VAPID_PRIVATE_KEY", "").replace("\\n", "\n")
    VAPID_CLAIMS_SUBJECT = os.getenv("VAPID_CLAIMS_SUBJECT", "mailto:admin@example.com")

    SESSION_COOKIE_SAMESITE = "Lax"
    REMEMBER_COOKIE_SAMESITE = "Lax"
