/**
 * amis-ui v6.14.0-beta.1
 * Copyright 2018-2025 fex
 */

import { __extends } from 'tslib';
import React__default from 'react';
import { themeable } from 'amis-core';
import { Icon } from './icons.js';

/**
 * @file Alert2
 * @author fex
 */
var Alert = /** @class */ (function (_super) {
    __extends(Alert, _super);
    function Alert(props) {
        var _this = _super.call(this, props) || this;
        _this.handleClick = _this.handleClick.bind(_this);
        _this.state = {
            show: true
        };
        return _this;
    }
    Alert.prototype.handleClick = function () {
        this.setState({
            show: false
        }, this.props.onClose);
    };
    Alert.prototype.render = function () {
        var _a = this.props, cx = _a.classnames, className = _a.className, style = _a.style, level = _a.level, children = _a.children, actions = _a.actions, showCloseButton = _a.showCloseButton, title = _a.title, icon = _a.icon, showIcon = _a.showIcon, iconClassName = _a.iconClassName, closeButtonClassName = _a.closeButtonClassName;
        // 优先使用内置svg，其次使用icon库
        var iconNode = showIcon ? (React__default.createElement(Icon, { cx: cx, icon: icon || "alert-".concat(level), className: "icon" })) : null;
        return this.state.show ? (React__default.createElement("div", { className: cx('Alert', level ? "Alert--".concat(level) : '', title ? 'Alert-has-title' : '', className), style: style },
            showIcon && iconNode ? (React__default.createElement("div", { className: cx('Alert-icon', iconClassName) }, iconNode)) : null,
            React__default.createElement("div", { className: cx('Alert-content') },
                title ? React__default.createElement("div", { className: cx('Alert-title') }, title) : null,
                React__default.createElement("div", { className: cx('Alert-desc') }, children)),
            actions ? React__default.createElement("div", { className: cx('Alert-actions') }, actions) : null,
            showCloseButton ? (React__default.createElement("button", { className: cx('Alert-close', closeButtonClassName), onClick: this.handleClick, type: "button" },
                React__default.createElement(Icon, { icon: "close", className: "icon" }))) : null)) : null;
    };
    Alert.defaultProps = {
        level: 'info',
        className: '',
        showCloseButton: false
    };
    Alert.propsList = [
        'level',
        'className',
        'showCloseButton',
        'onClose'
    ];
    return Alert;
}(React__default.Component));
var Alert2 = themeable(Alert);

export { Alert, Alert2 as default };
