'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const core = require('./core-906e2cc9.js');
require('./_commonjsHelpers-72d386ba.js');
const index = require('./index-da2f731d.js');

const Notifier = class {
    constructor(hostRef) {
        core.registerInstance(this, hostRef);
    }
    onTrigger(event) {
        if (event.detail.name == "close") {
            event.stopPropagation();
            this.notice = undefined;
        }
    }
    onUpdatedNotice(newValue) {
        if (this.timer) {
            window.clearTimeout(this.timer);
            this.timer = undefined;
        }
        if (newValue != undefined && !(index.dist_10.is(newValue) && newValue.remain)) {
            this.timer = window.setTimeout(() => {
                this.notice = undefined;
                this.timer = undefined;
            }, index.dist_10.is(newValue) && newValue.timeout ? newValue.timeout : 5000);
        }
    }
    onNotice(event) {
        this.notice = event.detail;
    }
    render() {
        const notice = !this.notice ? undefined : typeof (this.notice) == "string" ? JSON.parse(this.notice) : this.notice;
        const color = notice && notice.type != "default" ? notice.type : "primary";
        return notice == undefined ? core.h("slot", null) :
            [
                core.h("slot", null),
                core.h("aside", { class: notice.type }, core.h("p", null, notice.message, core.h("smoothly-trigger", { color: color, fill: "clear", name: "close" }, core.h("smoothly-icon", { name: "close-circle", color: color })))),
            ];
    }
    static get watchers() { return {
        "notice": ["onUpdatedNotice"]
    }; }
    static get style() { return ".sc-smoothly-notifier-h{display:block}[hidden].sc-smoothly-notifier-h{display:none}smoothly-trigger.sc-smoothly-notifier{display:inline-block;vertical-align:middle}aside.sc-smoothly-notifier{text-align:center;vertical-align:middle;width:100%-2em;padding-left:1em;padding-right:1em;border-style:solid;border-width:1px;border-radius:5px}aside.warning.sc-smoothly-notifier{background-color:rgb(var(--smoothly-warning-tint));border-color:rgb(var(--smoothly-warning-shade));color:rgb(var(--smoothly-warning-contrast))}aside.success.sc-smoothly-notifier{background-color:rgb(var(--smoothly-success-color));border-color:rgb(var(--smoothly-success-shade));color:rgb(var(--smoothly-success-contrast))}aside.danger.sc-smoothly-notifier{background-color:rgb(var(--smoothly-danger-tint));border-color:rgb(var(--smoothly-danger-shade));color:rgb(var(--smoothly-danger-contrast))}aside.default.sc-smoothly-notifier{background-color:rgb(var(--smoothly-primary-tint));border-color:rgb(var(--smoothly-primary-shade));color:rgb(var(--smoothly-primary-contrast))}"; }
};

exports.smoothly_notifier = Notifier;
