from src.core.config import settings


def build_workspace_url(subdomain: str) -> str:
    """Build the tenant workspace URL based on the current environment.

    development  → http://{subdomain}.localhost:{FRONTEND_PORT}
    staging      → https://{subdomain}.staging.{PUBLIC_BASE_DOMAIN}
    production   → https://{subdomain}.{PUBLIC_BASE_DOMAIN}
    """
    if settings.APP_ENV == "development":
        return f"http://{subdomain}.localhost:{settings.FRONTEND_PORT}"
    elif settings.APP_ENV == "staging":
        return f"https://{subdomain}.staging.{settings.PUBLIC_BASE_DOMAIN}"
    else:
        return f"https://{subdomain}.{settings.PUBLIC_BASE_DOMAIN}"
