"use client";
import { useThemeUI } from "theme-ui";
import { ColorMode, defaultColorMode, colorsByMode } from "../tokens/Color.js";
const useTheme = () => {
  var _a;
  const { theme, colorMode: contextColorMode, setColorMode } = useThemeUI();
  if (!("breakpoints" in theme) || (((_a = theme.breakpoints) == null ? void 0 : _a.length) ?? 0) === 0 || !("colors" in theme) || !("rawColors" in theme)) {
    throw new Error(
      "useTheme: no theme found, make sure `GDSProvider` has `useThemeUI` when rendering components that require Theme UI"
    );
  }
  const colorMode = contextColorMode === ColorMode.LIGHT || contextColorMode === ColorMode.DARK ? contextColorMode : defaultColorMode;
  const toggleColorMode = setColorMode == null ? void 0 : () => setColorMode(colorMode === ColorMode.DARK ? ColorMode.LIGHT : ColorMode.DARK);
  const colors = colorsByMode[colorMode];
  return {
    theme,
    colors,
    colorMode,
    setColorMode,
    toggleColorMode
  };
};
export {
  useTheme
};
