import { __rest } from '../../_virtual/_tslib.js';
import React__default from 'react';
import { getId } from '../../utils/index.js';
import { getSpinnerVariant } from './utils.js';
import { StyledButton, SpinnerWrapper, IconContainer, ContentWrapper } from './styles.js';
import { Spinner } from '../Spinner/index.js';

const Button = React__default.forwardRef((_a, ref) => {
    var { variant = 'primary', size = 'large', children, type = 'button', disabled = false, isLoading = false, fullWidth = false, iconPosition = 'leading' } = _a, props = __rest(_a, ["variant", "size", "children", "type", "disabled", "isLoading", "fullWidth", "iconPosition"]);
    const appendTestId = getId(props['data-testid']);
    return (React__default.createElement(StyledButton, Object.assign({}, props, { variant: variant, size: size, ref: ref, disabled: disabled, isLoading: isLoading, type: type, fullWidth: fullWidth, "data-status": isLoading ? 'loading' : null }), isLoading ? (React__default.createElement(SpinnerWrapper, null,
        React__default.createElement(Spinner, { "data-testid": appendTestId('spinner'), variant: getSpinnerVariant(variant), size: "S" }))) : (React__default.createElement(React__default.Fragment, null,
        iconPosition === 'leading' && props.icon && (React__default.createElement(IconContainer, null, props.icon)),
        children && (React__default.createElement(ContentWrapper, { "data-testid": appendTestId('content') }, children)),
        iconPosition === 'trailing' && props.icon && (React__default.createElement(IconContainer, null, props.icon))))));
});

export { Button };
