var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import React from 'react';
import { locale } from '../../lib/locale/decorators.js';
import { ZIndex } from '../../internal/ZIndex/index.js';
import { ThemeContext } from '../../lib/theming/ThemeContext.js';
import { CommonWrapper } from '../../internal/CommonWrapper/index.js';
import { rootNode } from '../../lib/rootNode/index.js';
import { CloseButtonIcon } from '../../internal/CloseButtonIcon/CloseButtonIcon.js';
import { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';
import { getStyles } from './ToastView.styles.js';
import { ToastDataTids } from './Toast.js';
import { ToastLocaleHelper } from './locale/index.js';
var ToastView = /** @class */ (function (_super) {
    __extends(ToastView, _super);
    function ToastView() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.renderMain = function () {
            var _a = _this.props, action = _a.action, showCloseIcon = _a.showCloseIcon, onClose = _a.onClose, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, use = _a.use;
            var toastCloseColors = use === 'error'
                ? { hover: _this.theme.toastCloseHoverColorError, default: _this.theme.toastCloseColorError }
                : { hover: _this.theme.toastCloseHoverColor, default: _this.theme.toastCloseColor };
            var toastActionColorsClassName = use === 'error' ? _this.styles.toastActionErrorColor(_this.theme) : _this.styles.toastActionDefaultColor(_this.theme);
            var toastActionClassNames = _this.cx(_this.styles.link(_this.theme), toastActionColorsClassName);
            var link = action ? (React.createElement("button", { "aria-label": action['aria-label'], "data-tid": ToastDataTids.action, className: toastActionClassNames, onClick: action.handler }, action.label)) : null;
            var close = action || showCloseIcon ? (React.createElement("span", { className: _this.styles.closeWrapper(_this.theme) },
                React.createElement(CloseButtonIcon, { "aria-label": _this.locale.closeButtonAriaLabel, "data-tid": ToastDataTids.close, onClick: onClose, size: parseInt(_this.theme.toastCloseSize), side: 40, color: toastCloseColors.default, colorHover: toastCloseColors.hover, tabbable: false }))) : null;
            var rootClassName = _this.cx(_this.styles.root(_this.theme), _this.styles[use !== null && use !== void 0 ? use : 'default'](_this.theme));
            return (React.createElement(CommonWrapper, __assign({}, _this.props),
                React.createElement(ZIndex, { priority: "Toast", className: _this.styles.wrapper(_this.theme) },
                    React.createElement("div", { "data-tid": ToastDataTids.toastView, className: rootClassName, ref: _this.setRootNode, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave },
                        React.createElement("span", null, _this.props.children),
                        link,
                        close))));
        };
        return _this;
    }
    ToastView.prototype.render = function () {
        var _this = this;
        this.styles = getStyles(this.emotion);
        return (React.createElement(ThemeContext.Consumer, null, function (theme) {
            _this.theme = theme;
            return _this.renderMain();
        }));
    };
    ToastView = __decorate([
        withRenderEnvironment,
        rootNode,
        locale('Toast', ToastLocaleHelper)
    ], ToastView);
    return ToastView;
}(React.Component));
export { ToastView };
//# sourceMappingURL=ToastView.js.map