"use strict";

import { Pressable, View } from "react-native";
import Animated from "react-native-reanimated";
import { IOListItemStyles, IOListItemVisualParams } from "../../core";
import { useIOTheme } from "../../context";
import { useListItemAnimation } from "../../hooks";
import { useIOFontDynamicScale } from "../../utils/accessibility";
import { Icon } from "../icons";
import { BodySmall, H6 } from "../typography";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
export const ListItemNavAlert = ({
  value,
  description,
  withoutIcon = false,
  onPress,
  accessibilityLabel,
  accessibilityHint,
  testID
}) => {
  const theme = useIOTheme();
  const {
    onPressIn,
    onPressOut,
    scaleAnimatedStyle,
    backgroundAnimatedStyle
  } = useListItemAnimation();
  const {
    dynamicFontScale,
    spacingScaleMultiplier
  } = 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__*/_jsxs(_Fragment, {
    children: [typeof value === "string" ? /*#__PURE__*/_jsx(H6, {
      color: theme["textBody-default"],
      children: value
    }) : value, description && /*#__PURE__*/_jsx(_Fragment, {
      children: typeof description === "string" ? /*#__PURE__*/_jsx(BodySmall, {
        weight: "Semibold",
        color: theme.errorText,
        children: description
      }) : description
    })]
  });
  const iconColor = theme["interactiveElem-default"];
  return /*#__PURE__*/_jsx(Pressable, {
    onPress: onPress,
    onPressIn: onPressIn,
    onPressOut: onPressOut,
    onTouchEnd: onPressOut,
    accessible: true,
    accessibilityLabel: listItemAccessibilityLabel,
    accessibilityHint: accessibilityHint,
    accessibilityRole: "button",
    testID: testID,
    children: /*#__PURE__*/_jsx(Animated.View, {
      style: [IOListItemStyles.listItem, backgroundAnimatedStyle],
      importantForAccessibility: "no-hide-descendants",
      accessibilityElementsHidden: true,
      children: /*#__PURE__*/_jsxs(Animated.View, {
        style: [IOListItemStyles.listItemInner, {
          columnGap: IOListItemVisualParams.iconMargin * dynamicFontScale * spacingScaleMultiplier
        }, scaleAnimatedStyle],
        children: [!withoutIcon && /*#__PURE__*/_jsx(Icon, {
          allowFontScaling: true,
          name: "errorFilled",
          color: theme.errorIcon,
          size: IOListItemVisualParams.iconSize
        }), /*#__PURE__*/_jsx(View, {
          style: {
            flex: 1
          },
          children: listItemNavAlertContent
        }), /*#__PURE__*/_jsx(Icon, {
          allowFontScaling: true,
          name: "chevronRightListItem",
          color: iconColor,
          size: IOListItemVisualParams.chevronSize
        })]
      })
    })
  });
};
//# sourceMappingURL=ListItemNavAlert.js.map