• Sets the application theme to the specified mode and updates the DOM and local storage.

    Parameters

    • newTheme: ThemeMode

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

    Returns Promise<boolean>

    A promise that resolves to true if dark mode is enabled, false otherwise.

    Also dispatches a "themeToggled" event on the 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();
    }
    }