/*
 * Copyright (c) 2023-2025 Datalayer, Inc.
 * Distributed under the terms of the Modified BSD License.
 */
import { useEffect, useState } from 'react';
export var JupyterLabTheme;
(function (JupyterLabTheme) {
    JupyterLabTheme["LIGHT"] = "JupyterLab Light";
    JupyterLabTheme["DARK"] = "JupyterLab Dark";
})(JupyterLabTheme || (JupyterLabTheme = {}));
export const useJupyterLabTheme = (themeManager) => {
    const isLight = themeManager && themeManager.theme
        ? themeManager.isLight(themeManager.theme)
        : true;
    const [theme, setTheme] = useState(isLight ? JupyterLabTheme.LIGHT : JupyterLabTheme.DARK);
    useEffect(() => {
        const handleThemeChange = (newTheme, event) => {
            setTheme(event.newValue);
        };
        themeManager?.themeChanged?.connect(handleThemeChange);
        return () => {
            themeManager?.themeChanged?.disconnect(handleThemeChange);
        };
    }, []);
    return theme;
};
