"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ListItemNavAlert = void 0;
var _reactNative = require("react-native");
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
var _core = require("../../core");
var _context = require("../../context");
var _hooks = require("../../hooks");
var _accessibility = require("../../utils/accessibility");
var _icons = require("../icons");
var _typography = require("../typography");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const ListItemNavAlert = ({
  value,
  description,
  withoutIcon = false,
  onPress,
  accessibilityLabel,
  accessibilityHint,
  testID
}) => {
  const theme = (0, _context.useIOTheme)();
  const {
    onPressIn,
    onPressOut,
    scaleAnimatedStyle,
    backgroundAnimatedStyle
  } = (0, _hooks.useListItemAnimation)();
  const {
    dynamicFontScale,
    spacingScaleMultiplier
  } = (0, _accessibility.useIOFontDynamicScale)();
  const componentValueToAccessibility = typeof value === "string" ? value : "";
  const componentDescriptionToAccessibility = typeof description === "string" ? description : "";
  const listItemAccessibilityLabel = accessibilityLabel ?? `${componentValueToAccessibility}; ${componentDescriptionToAccessibility}`;

  // TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153
  const listItemNavAlertContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [typeof value === "string" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.H6, {
      color: theme["textBody-default"],
      children: value
    }) : value, description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
      children: typeof description === "string" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.BodySmall, {
        weight: "Semibold",
        color: theme.errorText,
        children: description
      }) : description
    })]
  });
  const iconColor = theme["interactiveElem-default"];
  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: [!withoutIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
          allowFontScaling: true,
          name: "errorFilled",
          color: theme.errorIcon,
          size: _core.IOListItemVisualParams.iconSize
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
          style: {
            flex: 1
          },
          children: listItemNavAlertContent
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
          allowFontScaling: true,
          name: "chevronRightListItem",
          color: iconColor,
          size: _core.IOListItemVisualParams.chevronSize
        })]
      })
    })
  });
};
exports.ListItemNavAlert = ListItemNavAlert;
//# sourceMappingURL=ListItemNavAlert.js.map