"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useResponsiveProp = void 0;
var _useTheme = require("./useTheme");
var _responsiveHelpers = require("../theme/src/responsive-helpers");
var _react = require("react");
var _reactNative = require("react-native");
/**
 * Hook to get the appropriate value from a responsive style object based on the current screen size.
 * @param propValue An object that specifies the values based on the different breakpoints
 * @returns The appropriate value from the responsive style object based on the current screen size
 */
const useResponsiveProp = propValue => {
  const {
    theme
  } = (0, _useTheme.useTheme)();
  const dimensions = (0, _reactNative.useWindowDimensions)();

  // If the propValue is a responsive object value, get the appropriate value for the current screen size
  // Use useMemo to avoid unnecessary calculations on every render
  return (0, _react.useMemo)(() => {
    if ((0, _responsiveHelpers.isResponsiveObjectValue)(propValue, theme)) {
      const valueForScreenSize = (0, _responsiveHelpers.getValueForScreenSize)({
        responsiveValue: propValue,
        breakpoints: theme.breakpoints,
        dimensions
      });
      return valueForScreenSize;
    }

    // If the propValue is not a responsive object value, return the propValue as is
    return propValue;
  }, [propValue, theme, dimensions]);
};
exports.useResponsiveProp = useResponsiveProp;
//# sourceMappingURL=useResponsiveProp.js.map