"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ListItemAction = void 0;
var _reactNative = require("react-native");
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
var _context = require("../../context");
var _core = require("../../core");
var _hooks = require("../../hooks");
var _accessibility = require("../../utils/accessibility");
var _icons = require("../icons");
var _ButtonText = require("../typography/ButtonText");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const ListItemAction = ({
  variant,
  label,
  onPress,
  icon,
  accessibilityLabel,
  accessibilityHint,
  testID
}) => {
  const {
    onPressIn,
    onPressOut,
    scaleAnimatedStyle,
    backgroundAnimatedStyle
  } = (0, _hooks.useListItemAnimation)();
  const theme = (0, _context.useIOTheme)();
  const {
    dynamicFontScale,
    spacingScaleMultiplier
  } = (0, _accessibility.useIOFontDynamicScale)();
  const listItemAccessibilityLabel = accessibilityLabel || `${label}`;
  const mapForegroundColor = {
    primary: theme["interactiveElem-default"],
    danger: theme.errorText
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
    onPress: onPress,
    onPressIn: onPressIn,
    onPressOut: onPressOut,
    onTouchEnd: onPressOut,
    accessible: true,
    accessibilityLabel: listItemAccessibilityLabel,
    accessibilityHint: accessibilityHint,
    accessibilityRole: "button",
    testID: testID,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
      style: [_core.IOListItemStyles.listItem, backgroundAnimatedStyle],
      importantForAccessibility: "no-hide-descendants",
      accessibilityElementsHidden: true,
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
        style: [_core.IOListItemStyles.listItemInner, {
          columnGap: _core.IOListItemVisualParams.iconMargin * dynamicFontScale * spacingScaleMultiplier
        }, scaleAnimatedStyle],
        children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.AnimatedIcon, {
          allowFontScaling: true,
          name: icon,
          color: _core.IOColors[mapForegroundColor[variant]],
          size: _core.IOListItemVisualParams.iconSize
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
          style: {
            flexGrow: 1,
            flexShrink: 1
          },
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonText.ButtonText, {
            color: mapForegroundColor[variant],
            children: label
          })
        })]
      })
    })
  });
};
exports.ListItemAction = ListItemAction;
//# sourceMappingURL=ListItemAction.js.map