import { h } from "@stencil/core";
/**
 * Alert 警告提示组件
 * 展示需要关注的信息
 */
export class Alert {
    /** 标题 */
    title = '';
    /** 描述文字 */
    description;
    /** 类型 */
    type = 'info';
    /** 是否可关闭 */
    closable = false;
    /** 是否显示图标 */
    showIcon = true;
    /** 是否居中 */
    center = false;
    closed = false;
    hbClose;
    handleClose = () => {
        this.closed = true;
        this.hbClose.emit();
    };
    render() {
        if (this.closed)
            return null;
        const icons = { success: '✓', warning: '⚠', info: 'ℹ', error: '✕' };
        // error/warning 是紧急通告 → role=alert（断言式，屏幕阅读器即时朗读）；
        // info/success 是状态信息 → role=status（礼貌式，不打断）。
        const liveRole = this.type === 'error' || this.type === 'warning' ? 'alert' : 'status';
        return (h("div", { class: { 'hb-alert': true, [`hb-alert--${this.type}`]: true, 'hb-alert--center': this.center, 'hb-alert--with-description': !!this.description }, role: liveRole }, this.showIcon && h("span", { class: "hb-alert__icon", "aria-hidden": "true" }, icons[this.type]), h("div", { class: "hb-alert__body" }, h("div", { class: "hb-alert__title" }, this.title), this.description && h("div", { class: "hb-alert__description" }, this.description)), this.closable && h("span", { class: "hb-alert__close", role: "button", "aria-label": "\u5173\u95ED", tabIndex: 0, onClick: this.handleClose }, "\u00D7")));
    }
    static get is() { return "hb-alert"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["alert.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["alert.css"]
        };
    }
    static get properties() {
        return {
            "title": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u6807\u9898"
                },
                "getter": false,
                "setter": false,
                "attribute": "title",
                "reflect": false,
                "defaultValue": "''"
            },
            "description": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "\u63CF\u8FF0\u6587\u5B57"
                },
                "getter": false,
                "setter": false,
                "attribute": "description",
                "reflect": false
            },
            "type": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'success' | 'warning' | 'info' | 'error'",
                    "resolved": "\"error\" | \"info\" | \"success\" | \"warning\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u7C7B\u578B"
                },
                "getter": false,
                "setter": false,
                "attribute": "type",
                "reflect": false,
                "defaultValue": "'info'"
            },
            "closable": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u662F\u5426\u53EF\u5173\u95ED"
                },
                "getter": false,
                "setter": false,
                "attribute": "closable",
                "reflect": false,
                "defaultValue": "false"
            },
            "showIcon": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u662F\u5426\u663E\u793A\u56FE\u6807"
                },
                "getter": false,
                "setter": false,
                "attribute": "show-icon",
                "reflect": false,
                "defaultValue": "true"
            },
            "center": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "\u662F\u5426\u5C45\u4E2D"
                },
                "getter": false,
                "setter": false,
                "attribute": "center",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "closed": {}
        };
    }
    static get events() {
        return [{
                "method": "hbClose",
                "name": "hbClose",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }];
    }
}
//# sourceMappingURL=Alert.js.map
