export { };

// Function to set the theme based on user preference or system default
function setTheme() {
    const savedTheme: string | null = localStorage.getItem('theme');
    const systemPrefersDark: boolean = window.matchMedia('(prefers-color-scheme: dark)').matches;
    const defaultTheme: string = savedTheme || (systemPrefersDark ? 'dark' : 'light');
    document.documentElement.setAttribute('data-theme', defaultTheme);
    localStorage.setItem('theme', defaultTheme);
}

// Function to toggle the theme
export function toggleTheme() {
    const currentTheme: string | null = document.documentElement.getAttribute('data-theme');
    const newTheme: string = currentTheme === 'dark' ? 'light' : 'dark';

    document.documentElement.setAttribute('data-theme', newTheme);
    localStorage.setItem('theme', newTheme);
}

setTheme();
