import { useState, useCallback, useEffect, useMemo } from 'react';
import { Dimensions, StyleSheet as StyleSheet$1 } from 'react-native';
import mapValues from 'lodash-es/mapValues';

function create(styles) {
  return function useStyles() {
    var _useState = useState({
      window: Dimensions.get('window'),
      screen: Dimensions.get('screen')
    }),
        dimensions = _useState[0],
        setDimensions = _useState[1];

    var onChange = useCallback(function onChange(_ref) {
      var window = _ref.window,
          screen = _ref.screen;
      setDimensions({
        window: window,
        screen: screen
      });
    }, []);
    useEffect(function manageDimensionsEventListeners() {
      Dimensions.addEventListener('change', onChange);
      return function () {
        return Dimensions.removeEventListener('change', onChange);
      };
    }, []);
    var compiledStyles = useMemo(function () {
      return StyleSheet$1.create(mapValues(styles, function (s) {
        return s(dimensions);
      }));
    }, [dimensions]);
    return compiledStyles;
  };
}
var StyleSheet = {
  create: create
};

export { StyleSheet, create };
//# sourceMappingURL=react-native-stylehooks.esm.js.map
