• Sets application theme mode and updates DOM and storage.

    Parameters

    • newTheme: ThemeMode

      The theme mode to set ("dark", "light", or "system").

    Returns Promise<boolean>

    True if dark mode is enabled, false otherwise.

    Dispatches "themeToggled" event on document.

    export async function setTheme(newTheme: ThemeMode) {
    // Delegate to the explicit mode methods for clarity and single-responsibility
    switch (newTheme) {
    case "dark":
    return enableDarkMode();
    case "light":
    return enableLightMode();
    case "system":
    default:
    return applySystemTheme();
    }
    }