import { jsxs, jsx } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import Icon from '../Icon/Icon.js';
import classNames from '../../_virtual/index.js';
import Typography from '../Typography/Typography.js';

const Button = /*#__PURE__*/forwardRef(({
  variant = 'primary',
  backgroundColor,
  border,
  size = 'small',
  onClick,
  onCopy,
  label,
  disabled = false,
  children = null,
  type = 'button',
  className = '',
  style = {},
  iconName,
  iconPosition = 'left',
  isChooseFile = false,
  buttonWidth = 'auto',
  buttonHeight = 'auto',
  handleCloseIcon,
  selectedFile,
  fontSize = 10,
  typographyStyle,
  iconColor = '',
  isMandatory = false,
  ...props
}, ref) => {
  const renderIcon = () => iconName && jsx("div", {
    onClick: e => {
      if (iconName === 'close') {
        e.stopPropagation();
        handleCloseIcon?.();
      }
    },
    children: jsx(Icon, {
      height: isChooseFile ? 14 : 8,
      width: isChooseFile ? 14 : 8,
      color: iconName === 'close' ? 'var(--ff-delete-button-attachment)' : variant === 'danger' ? 'var(--status-rejected-text-color)' : iconColor || (variant === 'primary' ? 'var(--primary-icon-color)' : 'var(--secondary-icon-color)'),
      name: iconName,
      className: "ff-button-icon",
      disabled: disabled
    })
  });
  return jsxs("button", {
    type: type,
    ref: ref,
    className: classNames('ff-button', `ff-button--${size}`, `ff-button--${variant}`, `${className}`, {
      'ff-button-choose-file': isChooseFile
    }, {
      'ff-button-choose-file-text': selectedFile
    }),
    style: {
      backgroundColor,
      border,
      ...style,
      width: buttonWidth,
      height: buttonHeight
    },
    onClick: onClick,
    onCopy: onCopy,
    disabled: disabled,
    ...props,
    children: [iconPosition === 'left' && renderIcon(), jsxs(Typography, {
      fontSize: fontSize,
      style: {
        ...typographyStyle
      },
      fontWeight: "semi-bold",
      className: classNames(`ff-button-${variant}--text`, {
        'ff-button-choose-file-text': selectedFile
      }),
      children: [isMandatory && jsx("span", {
        className: "required-asterisk",
        children: "*"
      }), label]
    }), iconPosition === 'right' && renderIcon(), children]
  });
});

export { Button as default };
//# sourceMappingURL=Button.js.map
