'use strict';

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

const index = require('./index-7f52f1a2.js');

const balToastCss = "@-webkit-keyframes spinAround{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes spinAround{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.sc-bal-toast-h{display:-ms-inline-flexbox;display:inline-flex;position:relative;-ms-flex-item-align:center;align-self:center;cursor:pointer;width:100%;-ms-flex-pack:center;justify-content:center;-ms-flex-positive:0 !important;flex-grow:0 !important}.sc-bal-toast-h .toast.sc-bal-toast{-ms-flex-item-align:center;align-self:center;display:-ms-inline-flexbox;display:inline-flex;-webkit-animation-duration:150ms;animation-duration:150ms;margin:0.5em 0;text-align:center;-webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);box-shadow:0 1px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);border-radius:3px;padding:20px 40px;pointer-events:auto;max-width:600px;-ms-flex-positive:1;flex-grow:1;font-size:0.9375rem;font-weight:700}.sc-bal-toast-h .toast.is-primary.sc-bal-toast{background:#009ee7;color:#ffffff}.sc-bal-toast-h .toast.is-info.sc-bal-toast{background:#003399;color:#fff}.sc-bal-toast-h .toast.is-success.sc-bal-toast{background:#3fc889;color:#ffffff}.sc-bal-toast-h .toast.is-warning.sc-bal-toast{background:#ff9900;color:#ffffff}.sc-bal-toast-h .toast.is-danger.sc-bal-toast{background:#ff3366;color:#ffffff}";

const Toast = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.animationClass = 'fadeInDown';
    /**
     * The theme type of the toast. Given by bulma our css framework.
     */
    this.type = 'is-primary';
  }
  /**
   * Closes the toast after the given duration in ms
   */
  async closeIn(duration) {
    this.timer = setTimeout(() => this.close(), duration);
  }
  /**
   * Closes this toast
   */
  async close() {
    clearTimeout(this.timer);
    this.animationClass = 'fadeOut';
    this.timer = setTimeout(() => {
      this.element.remove();
      clearTimeout(this.timer);
    }, 150);
  }
  render() {
    return (index.h(index.Host, { class: "container" }, index.h("div", { role: "alert", onClick: () => this.close(), class: `toast ${this.animationClass} ${this.type}` }, index.h("bal-text", null, index.h("slot", null)))));
  }
  get element() { return index.getElement(this); }
};
Toast.style = balToastCss;

exports.bal_toast = Toast;
