import { useState, useEffect } from 'react';

const usePrefersReducedMotion = () => {
  const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
  useEffect(() => {
    if (typeof window === "undefined") {
      return;
    }
    const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
    const sync = () => {
      setPrefersReducedMotion(mediaQuery.matches);
    };
    sync();
    const handleModern = (event) => {
      setPrefersReducedMotion(event.matches);
    };
    if (typeof mediaQuery.addEventListener === "function") {
      mediaQuery.addEventListener("change", handleModern);
      return () => {
        mediaQuery.removeEventListener("change", handleModern);
      };
    }
    const handleLegacy = () => {
      sync();
    };
    mediaQuery.addListener(handleLegacy);
    return () => {
      mediaQuery.removeListener(handleLegacy);
    };
  }, []);
  return {
    prefersReducedMotion
  };
};

export { usePrefersReducedMotion as u };
//# sourceMappingURL=usePrefersReducedMotion-DR9B_D6w.js.map
