import { useState, useEffect } from 'react';

const usePrefersColorScheme = () => {
  const [systemPrefersDark, setSystemPrefersDark] = useState();
  useEffect(() => {
    function isSystemDark(event) {
      setSystemPrefersDark(event.matches);
    }
    if (typeof window !== "undefined") {
      const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
      if (mediaQuery?.addEventListener != null) {
        mediaQuery.addEventListener("change", isSystemDark);
      } else {
        mediaQuery.addListener(isSystemDark);
      }
      return () => {
        if (mediaQuery?.addEventListener != null) {
          mediaQuery.removeEventListener("change", isSystemDark);
        } else {
          mediaQuery.removeListener(isSystemDark);
        }
      };
    }
  }, []);
  return {
    mode: systemPrefersDark ? "dark" : "light"
  };
};

export { usePrefersColorScheme as u };
//# sourceMappingURL=usePrefersColorScheme-_hT7dK7_.js.map
