"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _native = _interopRequireDefault(require("styled-components/native"));
var _reactNative = require("react-native");
var _Loader = _interopRequireDefault(require("./Loader"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const CustomButton = (0, _native.default)(_reactNative.TouchableOpacity)`
  border-width: ${({
  variant
}) => variant === 'outlined' ? 1 : 0}px;
  border-color: ${({
  backgroundColor
}) => backgroundColor || '#0052CD'};
  border-radius: 20px;
  background-color: ${({
  variant,
  backgroundColor
}) => variant === 'filled' ? backgroundColor || '#0052CD' : 'transparent'};
  flex-direction: row;
  justify-content: center;
  align-items: center;
  height: 40px;
  width: 40px;
  margin: 0 10px;
  padding-horizontal: 8px;
  opacity: ${({
  disabled
}) => disabled ? 0.6 : 1};
`;
const ButtonText = _native.default.Text`
  color: ${({
  variant,
  backgroundColor
}) => variant === 'filled' ? '#FFFFFF' : backgroundColor || '#0052CD'};
  font-size: ${_reactNative.PixelRatio.getFontScale() * 14}px;
  font-weight: bold;
`;
const Button = ({
  text,
  EndIcon,
  loading = false,
  disabled = false,
  unstyled = false,
  variant = 'default',
  backgroundColor,
  onPress,
  StartIcon,
  style: containerStyle,
  color,
  children,
  testID,
  accessibilityLabel
}) => {
  const iconOnly = !loading && !children && !text && !StartIcon && !!EndIcon;
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CustomButton, {
    testID: testID,
    accessibilityLabel: accessibilityLabel,
    style: [containerStyle],
    disabled: disabled || loading,
    onPress: onPress,
    variant: variant,
    backgroundColor: backgroundColor,
    children: [loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loader.default, {
      size: 24
    }), !loading && StartIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: styles.icon,
      children: StartIcon
    }), !loading && children, !loading && !children && typeof text !== 'undefined' && /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonText, {
      style: [{
        color: color || 'black'
      }],
      variant: variant,
      backgroundColor: backgroundColor,
      children: text
    }), !loading && EndIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: iconOnly ? styles.iconOnly : styles.icon,
      children: EndIcon
    })]
  });
};
const styles = _reactNative.StyleSheet.create({
  icon: {
    marginHorizontal: 4
    // maxWidth: '20%',
  },
  iconOnly: {
    marginHorizontal: 0,
    alignItems: 'center',
    justifyContent: 'center'
  }
});
var _default = exports.default = Button;
//# sourceMappingURL=Button.js.map