import { i as p, e as _ } from "./isObject-C9OMxPJa.js";
import { resolveComponent as v, createElementBlock as d, openBlock as c, createVNode as B, TransitionGroup as $, withCtx as w, Fragment as g, renderList as x, createBlock as N, createTextVNode as b, toDisplayString as y } from "vue";
import { _ as k } from "./install-BuMO14Rb.js";
const C = (t) => p(t) && (t.entity || t.module), i = (t) => (o) => (...n) => {
  if (C(n[0])) {
    const u = n[0], { app: f = t, entity: s = "", module: r = "" } = u, e = /* @__PURE__ */ new Date(), a = window?.location?.href || "non-browser env";
    return (...l) => {
      const h = `@webitel/${f}:${s}:${r}:`, m = `[${e}][${a}]`;
      return console[o](h, ...l, m);
    };
  }
  return console[o](...n);
}, D = (t) => ({
  info: i(t)("info"),
  warn: i(t)("warn"),
  error: i(t)("error"),
  log: i(t)("log")
}), T = D("ui-sdk"), j = {
  name: "WtNotificationsBar",
  inject: [
    "$eventBus"
  ],
  data: () => ({
    notificationDuration: 4e3,
    notifications: [],
    eventBus: _
  }),
  created() {
    this.$eventBus ? this.eventBus = this.$eventBus : T.warn({
      entity: "component",
      module: "wt-notification-bar"
    })(
      "no globally provided $eventBus found, using default webitel-ui eventBus"
    ), this.eventBus.$on("notification", this.showNotification);
  },
  unmounted() {
    this.eventBus.$off("notification", this.showNotification);
  },
  methods: {
    showNotification(t) {
      this.notifications.unshift(t), setTimeout(
        () => this.closeNotification(t),
        t.timeout * 1e3 || this.notificationDuration
      );
    },
    closeNotification(t) {
      const o = this.notifications.indexOf(t);
      this.notifications.splice(o, 1);
    }
  }
}, L = { class: "wt-notifications-bar wt-scrollbar" };
function O(t, o, n, u, f, s) {
  const r = v("wt-notification");
  return c(), d("aside", L, [
    B($, {
      class: "wt-notifications-bar__wrapper",
      name: "wt-notifications-transition",
      tag: "div"
    }, {
      default: w(() => [
        (c(!0), d(g, null, x(t.notifications, (e, a) => (c(), N(r, {
          key: a + e.text,
          type: e.type,
          onClose: (l) => s.closeNotification(e)
        }, {
          default: w(() => [
            b(y(e.text), 1)
          ], void 0, !0),
          _: 2
        }, 1032, ["type", "onClose"]))), 128))
      ], void 0, !0),
      _: 1
    })
  ]);
}
const G = /* @__PURE__ */ k(j, [["render", O], ["__scopeId", "data-v-8f1de0c8"]]);
export {
  G as default
};
