"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useStyleProps = void 0;
var _useTheme = require("./useTheme");
var _utils = require("./utils/utils");
var _react = require("react");
var _lodash = _interopRequireDefault(require("lodash"));
var _reactNative = require("react-native");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
 * Hook to convert the received style props to appropriate React Native styles
 * @param props Raw props passed to the component where the hook is being used.
 * @param styleFunctions List of style functions to use for computing the received style props.
 * @returns Object containing the computed style properties
 */
const useStyleProps = (props, styleFunctions) => {
  const {
    theme,
    colorMode
  } = (0, _useTheme.useTheme)();
  const dimensions = (0, _reactNative.useWindowDimensions)();

  // Compose the style functions
  const buildStyleProperties = (0, _react.useMemo)(() => (0, _utils.composeStyleProps)(styleFunctions), [styleFunctions]);

  // If no props are passed, return an empty style object
  if (_lodash.default.isEmpty(props)) {
    return {
      style: {}
    };
  }

  // Build the final style properties
  return (0, _utils.buildFinalStyleProps)(props, buildStyleProperties, {
    theme,
    colorMode,
    dimensions
  });
};
exports.useStyleProps = useStyleProps;
//# sourceMappingURL=useStyleProps.js.map