'use strict';

var state = require('./state.js');

const isBrowser = typeof window !== "undefined";
function initPrefersReducedMotion() {
    state.hasReducedMotionListener.current = true;
    if (!isBrowser)
        return;
    if (window.matchMedia) {
        const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
        const setReducedMotionPreferences = () => (state.prefersReducedMotion.current = motionMediaQuery.matches);
        motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
        setReducedMotionPreferences();
    }
    else {
        state.prefersReducedMotion.current = false;
    }
}

exports.hasReducedMotionListener = state.hasReducedMotionListener;
exports.prefersReducedMotion = state.prefersReducedMotion;
exports.initPrefersReducedMotion = initPrefersReducedMotion;
