"use client";
import { useMemo } from "react";
import { useEnsuredState } from "../useEnsuredState.js";
import { useColorSchemeMetaTag } from "./useColorSchemeMetaTag.js";
import { usePrefersDarkTheme } from "./usePrefersColorScheme.js";
export function useColorSchemeProvider(options = {}) {
    const { disableMetaTag, colorSchemeMode: value, setColorSchemeMode: setValue, defaultColorSchemeMode } = options;
    const [colorSchemeMode, setColorSchemeMode] = useEnsuredState({
        value,
        setValue,
        defaultValue: defaultColorSchemeMode
    });
    const prefersDarkTheme = usePrefersDarkTheme(colorSchemeMode !== "system");
    const derivedColorScheme = prefersDarkTheme ? "dark" : "light";
    const colorScheme = colorSchemeMode === "system" ? derivedColorScheme : colorSchemeMode;
    useColorSchemeMetaTag({
        disabled: disableMetaTag,
        colorScheme
    });
    return useMemo(()=>({
            colorScheme,
            colorSchemeMode,
            setColorSchemeMode
        }), [
        colorScheme,
        colorSchemeMode,
        setColorSchemeMode
    ]);
}

//# sourceMappingURL=useColorSchemeProvider.js.map