function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import { TouchableOpacity, TouchableHighlight } from 'react-native';
import React, { useMemo } from 'react';
import { useTemplateContext } from '../../template/app-review/template-context';
import { ANALYTICS_EVENT_TYPE } from '../../variables/analytics';
const hitSlop = {
  left: 12,
  right: 12,
  bottom: 12,
  top: 12
};
const logEvent = (eventName, analyticsID, analytics, analyticsParams) => {
  analytics && analytics.logEvent(eventName, {
    ...(analyticsParams || {}),
    id: analyticsID
  });
};
const Touchable = props => {
  const templateContext = useTemplateContext();
  const {
    theme,
    vibration,
    analytics
  } = templateContext;
  const {
    analyticsID,
    analyticsParams,
    accessibilityLabel,
    onPress,
    onLongPress,
    isWithoutFeedback,
    isHighlight,
    activeOpacity,
    disabled
  } = props;
  const handlePress = useMemo(() => event => {
    if (!onPress) return;
    vibration?.vibrate();
    analytics && analyticsID && logEvent(ANALYTICS_EVENT_TYPE.PRESS, analyticsID, analytics, analyticsParams);
    onPress(event);
  }, [analytics, analyticsID, analyticsParams, onPress, vibration]);
  const handleLongPress = useMemo(() => event => {
    if (!onLongPress) return;
    vibration?.vibrate();
    analytics && analyticsID && logEvent(ANALYTICS_EVENT_TYPE.LONG_PRESS, analyticsID, analytics, analyticsParams);
    onLongPress(event);
  }, [analytics, analyticsID, analyticsParams, onLongPress, vibration]);
  if (isHighlight) {
    return /*#__PURE__*/React.createElement(TouchableHighlight, _extends({}, props, {
      accessibilityLabel: accessibilityLabel,
      hitSlop: hitSlop,
      underlayColor: theme.colors.gray.light,
      onPress: handlePress,
      onLongPress: handleLongPress,
      activeOpacity: activeOpacity || (disabled ? 1 : 0.85)
    }));
  }
  return /*#__PURE__*/React.createElement(TouchableOpacity, _extends({}, props, {
    accessibilityLabel: accessibilityLabel,
    hitSlop: hitSlop,
    onPress: handlePress,
    onLongPress: handleLongPress,
    activeOpacity: isWithoutFeedback && 1 || activeOpacity || (disabled ? 1 : 0.2)
  }));
};
export default Touchable;
//# sourceMappingURL=index.native.js.map