import React__default from 'react';
import { ToastWrapper, CompactWrapper, MessageWrapper, ActionWrapper } from './styles.js';
import { getId, noop } from '../../../utils/index.js';
import { Button } from '../../Button/index.js';
import { getAriaRole } from './utils.js';
import ToastIcon from './ToastIcon.js';

const genericAction = {
    text: '',
    onClick: noop,
};
function Toast(props) {
    const appendTestId = getId(props['data-testid']);
    const appendTrackId = getId(props['data-trackid']);
    const { className, variant = 'neutral', message, action, primaryAction = genericAction, icon, } = props;
    let dismissAction = genericAction;
    if (props.action === 'acknowledge') {
        dismissAction = props.dismissAction;
    }
    return (React__default.createElement(ToastWrapper, { className: className, variant: variant, "data-testid": appendTestId('wrapper'), "data-trackid": appendTrackId('wrapper'), "aria-label": props['aria-label'], role: getAriaRole(variant) },
        React__default.createElement(CompactWrapper, null,
            variant === 'neutral' && icon ? icon : React__default.createElement(ToastIcon, { variant: variant }),
            React__default.createElement(MessageWrapper, null, message)),
        React__default.createElement(ActionWrapper, null,
            action === 'acknowledge' && dismissAction && (React__default.createElement(Button, { size: "xSmall", variant: "inverse-ghost", onClick: dismissAction.onClick, "data-testid": appendTestId('dismiss-button') }, dismissAction.text)),
            React__default.createElement(Button, { size: "xSmall", variant: "inverse-ghost", onClick: primaryAction.onClick, "data-testid": appendTestId('action-button') }, primaryAction.text))));
}

export { Toast };
