import React, { forwardRef, useState } from 'react';
import { TouchableOpacity, View } from 'react-native';
import { useTheme } from '../../contexts/theme';
import { ButtonType } from './Button-api';
import { ThemedText } from '../texts/ThemedText';
const ButtonImplComponent = ({
  title,
  buttonType,
  accessibilityLabel,
  accessibilityHint,
  testID,
  onPress,
  disabled = false,
  maxfontSizeMultiplier,
  children
}, ref) => {
  const {
    Buttons,
    heavyOpacity
  } = useTheme();
  const buttonStyles = {
    [ButtonType.Critical]: {
      color: Buttons.critical,
      text: Buttons.primaryText
    },
    [ButtonType.Primary]: {
      color: Buttons.primary,
      text: Buttons.primaryText
    },
    [ButtonType.Secondary]: {
      color: Buttons.secondary,
      text: Buttons.secondaryText
    },
    [ButtonType.Tertiary]: {
      color: Buttons.tertiary,
      text: Buttons.tertiaryText
    },
    [ButtonType.ModalCritical]: {
      color: Buttons.modalCritical,
      text: Buttons.primaryText
    },
    [ButtonType.ModalPrimary]: {
      color: Buttons.modalPrimary,
      text: Buttons.modalPrimaryText
    },
    [ButtonType.ModalSecondary]: {
      color: Buttons.modalSecondary,
      text: Buttons.modalSecondaryText
    },
    [ButtonType.ModalTertiary]: {
      color: Buttons.modalTertiary,
      text: Buttons.modalTertiaryText
    }
  };
  const [isActive, setIsActive] = useState(false);
  return /*#__PURE__*/React.createElement(TouchableOpacity, {
    onPress: onPress,
    accessible: true,
    accessibilityLabel: accessibilityLabel,
    accessibilityHint: accessibilityHint,
    accessibilityRole: 'button',
    onPressIn: () => setIsActive(!disabled && true),
    onPressOut: () => setIsActive(false),
    testID: testID,
    style: [buttonStyles[buttonType].color, disabled && (buttonType === ButtonType.Primary ? Buttons.primaryDisabled : buttonType === ButtonType.Secondary ? Buttons.secondaryDisabled : Buttons.tertiaryDisabled), isActive && (buttonType === ButtonType.Secondary || buttonType === ButtonType.Tertiary) && {
      backgroundColor: Buttons.primary.backgroundColor
    }],
    disabled: disabled,
    activeOpacity: heavyOpacity,
    ref: ref
  }, /*#__PURE__*/React.createElement(View, {
    style: {
      flexDirection: 'row',
      justifyContent: 'center',
      alignItems: 'center'
    }
  }, children, /*#__PURE__*/React.createElement(ThemedText, {
    maxFontSizeMultiplier: maxfontSizeMultiplier,
    style: [buttonStyles[buttonType].text, disabled && (buttonType === ButtonType.Primary ? Buttons.primaryTextDisabled : buttonType === ButtonType.Secondary ? Buttons.secondaryTextDisabled : Buttons.tertiaryTextDisabled), isActive && {
      textDecorationLine: 'underline'
    }, isActive && buttonType === ButtonType.Secondary && {
      color: Buttons.primaryText.color
    }]
  }, title)));
};
const ButtonImpl = /*#__PURE__*/forwardRef(ButtonImplComponent);
export default ButtonImpl;
export { ButtonType, ButtonImpl };
//# sourceMappingURL=Button.js.map