"use strict";

import { useState } from "react";
import { View } from "react-native";
import RNReactNativeHapticFeedback from "react-native-haptic-feedback";
import { useIOTheme } from "../../context";
import { IOSelectionTickVisualParams } from "../../core";
import { useIOFontDynamicScale } from "../../utils/accessibility";
import { Icon } from "../icons";
import { HStack } from "../layout";
import { AnimatedRadio } from "../radio/AnimatedRadio";
import { BodySmall, H6 } from "../typography";
import { PressableListItemBase } from "./PressableListItemBase";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export const ListItemRadioWithAmount = ({
  onValueChange,
  selected,
  label,
  accessibilityLabel,
  isSuggested = false,
  suggestReason,
  formattedAmountString
}) => {
  const {
    dynamicFontScale
  } = useIOFontDynamicScale();
  const [toggleValue, setToggleValue] = useState(selected ?? false);
  const pressHandler = () => {
    RNReactNativeHapticFeedback.trigger("impactLight");
    setToggleValue(val => !val);
    if (onValueChange !== undefined) {
      onValueChange(!toggleValue);
    }
  };
  const theme = useIOTheme();
  const suggestColor = "hanPurple-500";
  const defaultAccessibilityLabel = `${label} ${formattedAmountString} ${suggestReason ?? ""}`;
  return /*#__PURE__*/_jsxs(PressableListItemBase, {
    onPress: pressHandler,
    accessibilityRole: "radio",
    accessibilityLabel: accessibilityLabel ?? defaultAccessibilityLabel,
    accessibilityState: {
      checked: selected ?? toggleValue
    },
    children: [/*#__PURE__*/_jsxs(View, {
      style: {
        flexShrink: 1
      },
      children: [/*#__PURE__*/_jsx(H6, {
        numberOfLines: 1,
        color: theme["textBody-default"],
        children: label
      }), isSuggested && /*#__PURE__*/_jsxs(HStack, {
        space: 4,
        style: {
          alignItems: "center"
        },
        children: [/*#__PURE__*/_jsx(Icon, {
          name: "sparkles",
          size: 16,
          color: suggestColor
        }), /*#__PURE__*/_jsx(BodySmall, {
          weight: "Regular",
          color: suggestColor,
          children: suggestReason
        })]
      })]
    }), /*#__PURE__*/_jsxs(HStack, {
      space: 8,
      pointerEvents: "none",
      accessibilityElementsHidden: true,
      importantForAccessibility: "no-hide-descendants",
      children: [/*#__PURE__*/_jsx(H6, {
        color: theme["interactiveElem-default"],
        children: formattedAmountString
      }), /*#__PURE__*/_jsx(AnimatedRadio, {
        size: IOSelectionTickVisualParams.size * dynamicFontScale,
        checked: selected ?? toggleValue
      })]
    })]
  });
};
//# sourceMappingURL=ListItemRadioWithAmount.js.map