import { h } from '@stencil/core';
import { DomUtil } from '@ema/core';
export class FlashMessage {
    constructor() {
        this.active = false;
        this.activeClass = 'primary';
    }
    async show(message, activeClass, duration = 2000) {
        this.message = message;
        this.activeClass = activeClass;
        this.active = true;
        DomUtil.fadeIn(this.el, 150, 0, 'flex');
        this.timeout = setTimeout(() => {
            this.active = false;
        }, duration);
    }
    dismiss() {
        this.active = false;
        DomUtil.fadeOut(this.el, 150, 0);
        clearTimeout(this.timeout);
    }
    render() {
        return (h("div", { onClick: () => this.dismiss(), class: 'flash-container ' + (this.active ? 'show ' : 'hide ') + this.activeClass },
            h("div", { class: "message" }, this.message),
            h("p", { class: "dismiss" }, "tap to dismiss")));
    }
    static get is() { return "ema-flash-message"; }
    static get originalStyleUrls() { return {
        "$": ["flash-message.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["flash-message.css"]
    }; }
    static get states() { return {
        "active": {},
        "message": {},
        "activeClass": {}
    }; }
    static get methods() { return {
        "show": {
            "complexType": {
                "signature": "(message: string, activeClass: string, duration?: number) => Promise<void>",
                "parameters": [{
                        "tags": [],
                        "text": ""
                    }, {
                        "tags": [],
                        "text": ""
                    }, {
                        "tags": [],
                        "text": ""
                    }],
                "references": {
                    "Promise": {
                        "location": "global"
                    }
                },
                "return": "Promise<void>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        }
    }; }
    static get elementRef() { return "el"; }
}
