"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.usePressedState = void 0;
var _react = require("react");
var _styleFunctions = require("../../theme/src/style-functions");
var _useDynamicStateStyle = require("./useDynamicStateStyle");
/**
 * Hook to manage a pressed state and compose extra styling while a component is pressed
 * @param props The props object of a component
 * @param styleFunctions List of style functions supported by the component. By default, boxStyleFunctions are used
 * @param activeComponentType Type of the component inside which the hook is used. By default, this value is set to 'basic'
 * @param animateable Whether the styles should be dynamically animated using Moti. By default, this value is set to 'true'
 * @param parentStateValue A override value to control the 'pressed' state instead of the local state value
 * @returns The props object with updated styles according the current 'pressed' state
 */
const usePressedState = (props, styleFunctions = _styleFunctions.boxStyleFunctions, activeComponentType = "basic", animateable = true, parentStateValue = undefined) => {
  // Initialize pressed state to false
  const [pressed, setPressed] = (0, _react.useState)(false);

  // Override the pressed state if the parentStateValue is provided
  let finalPressedFlag;
  if (parentStateValue !== undefined) {
    finalPressedFlag = parentStateValue;
  } else {
    finalPressedFlag = pressed;
  }

  // Compose extra styling while a component is pressed
  const propsWithPressedStyles = (0, _useDynamicStateStyle.useDynamicStateStyle)(props, "_pressed", finalPressedFlag, styleFunctions, activeComponentType, animateable);
  return {
    pressed,
    setPressed,
    propsWithPressedStyles
  };
};
exports.usePressedState = usePressedState;
//# sourceMappingURL=usePressedState.js.map