@editora/toast 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -75,7 +75,7 @@ class k {
75
75
  };
76
76
  }
77
77
  }
78
- class H {
78
+ class M {
79
79
  constructor(t) {
80
80
  this.queue = [], this.visible = [], this.config = t;
81
81
  }
@@ -166,26 +166,26 @@ class A {
166
166
  ...r
167
167
  };
168
168
  let o, a = !1;
169
- const l = Object.keys(s).reduce((u, p) => (u[p] = s[p].from, u), {}), d = Object.keys(s).reduce((u, p) => (u[p] = 0, u), {}), m = () => {
169
+ const l = Object.keys(s).reduce((u, d) => (u[d] = s[d].from, u), {}), p = Object.keys(s).reduce((u, d) => (u[d] = 0, u), {}), y = () => {
170
170
  if (a)
171
171
  return;
172
172
  let u = !0;
173
173
  Object.keys(s).forEach((g) => {
174
- const b = s[g].to, y = l[g], w = d[g], f = -n.stiffness * (y - b), v = -n.damping * w, x = (f + v) / n.mass;
175
- d[g] += x * 0.016, l[g] += d[g] * 0.016, (Math.abs(y - b) > n.precision || Math.abs(w) > n.precision) && (u = !1);
174
+ const b = s[g].to, m = l[g], w = p[g], f = -n.stiffness * (m - b), v = -n.damping * w, H = (f + v) / n.mass;
175
+ p[g] += H * 0.016, l[g] += p[g] * 0.016, (Math.abs(m - b) > n.precision || Math.abs(w) > n.precision) && (u = !1);
176
176
  });
177
- const p = Object.keys(l).reduce((g, b) => {
178
- const y = s[b].unit || "px";
179
- return g[b] = `${l[b]}${y}`, g;
177
+ const d = Object.keys(l).reduce((g, b) => {
178
+ const m = s[b].unit || "px";
179
+ return g[b] = `${l[b]}${m}`, g;
180
180
  }, {});
181
- e(p), u ? (a = !0, i == null || i()) : o = requestAnimationFrame(m);
181
+ e(d), u ? (a = !0, i == null || i()) : o = requestAnimationFrame(y);
182
182
  };
183
- return o = requestAnimationFrame(m), () => {
183
+ return o = requestAnimationFrame(y), () => {
184
184
  a = !0, o && cancelAnimationFrame(o);
185
185
  };
186
186
  }
187
187
  }
188
- class M {
188
+ class q {
189
189
  constructor() {
190
190
  this.springAnimation = new A();
191
191
  }
@@ -301,9 +301,9 @@ class M {
301
301
  // Bounce-based show animation
302
302
  async animateBounceShow(t, s) {
303
303
  return new Promise((e) => {
304
- var d, m, u;
304
+ var p, y, u;
305
305
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
306
- const i = ((d = t.parentElement) == null ? void 0 : d.classList.contains("editora-toast-bottom-right")) || ((m = t.parentElement) == null ? void 0 : m.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), r = s.direction || (i ? "up" : "down"), n = s.intensity || "normal", o = s.duration || 800, a = n === "gentle" ? 0.05 : n === "strong" ? 0.15 : 0.1, l = r === "up" ? 30 : r === "down" ? -30 : r === "left" ? 30 : -30;
306
+ const i = ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-right")) || ((y = t.parentElement) == null ? void 0 : y.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), r = s.direction || (i ? "up" : "down"), n = s.intensity || "normal", o = s.duration || 800, a = n === "gentle" ? 0.05 : n === "strong" ? 0.15 : 0.1, l = r === "up" ? 30 : r === "down" ? -30 : r === "left" ? 30 : -30;
307
307
  t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
308
308
  "transform",
309
309
  r === "left" || r === "right" ? `translateX(${l}px) scale(${1 - a})` : `translateY(${l}px) scale(${1 - a})`,
@@ -334,9 +334,9 @@ class M {
334
334
  // Slide-based show animation
335
335
  async animateSlideShow(t, s) {
336
336
  return new Promise((e) => {
337
- var d, m, u;
337
+ var p, y, u;
338
338
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
339
- const i = ((d = t.parentElement) == null ? void 0 : d.classList.contains("editora-toast-bottom-right")) || ((m = t.parentElement) == null ? void 0 : m.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), r = s.direction || (i ? "up" : "down"), n = s.distance || 100, o = s.easing || "ease-out", a = s.duration || 400, l = r === "up" ? `translateY(${n}px)` : r === "down" ? `translateY(-${n}px)` : r === "left" ? `translateX(${n}px)` : `translateX(-${n}px)`;
339
+ const i = ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-right")) || ((y = t.parentElement) == null ? void 0 : y.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), r = s.direction || (i ? "up" : "down"), n = s.distance || 100, o = s.easing || "ease-out", a = s.duration || 400, l = r === "up" ? `translateY(${n}px)` : r === "down" ? `translateY(-${n}px)` : r === "left" ? `translateX(${n}px)` : `translateX(-${n}px)`;
340
340
  t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", l, "important"), t.offsetHeight, setTimeout(() => {
341
341
  t.style.setProperty("transition", `opacity ${a}ms ${o}, transform ${a}ms ${o}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
342
342
  t.style.setProperty("transition", "none", "important"), e();
@@ -437,9 +437,9 @@ class M {
437
437
  // Elastic-based show animation
438
438
  async animateElasticShow(t, s) {
439
439
  return new Promise((e) => {
440
- var d, m, u;
440
+ var p, y, u;
441
441
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
442
- const i = ((d = t.parentElement) == null ? void 0 : d.classList.contains("editora-toast-bottom-right")) || ((m = t.parentElement) == null ? void 0 : m.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), r = s.direction || (i ? "up" : "down"), n = s.intensity || "normal", o = s.duration || 1e3, a = n === "gentle" ? 0.1 : n === "strong" ? 0.3 : 0.2, l = r === "up" ? 40 : r === "down" ? -40 : r === "left" ? 40 : -40;
442
+ const i = ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-right")) || ((y = t.parentElement) == null ? void 0 : y.classList.contains("editora-toast-bottom-left")) || ((u = t.parentElement) == null ? void 0 : u.classList.contains("editora-toast-bottom-center")), r = s.direction || (i ? "up" : "down"), n = s.intensity || "normal", o = s.duration || 1e3, a = n === "gentle" ? 0.1 : n === "strong" ? 0.3 : 0.2, l = r === "up" ? 40 : r === "down" ? -40 : r === "left" ? 40 : -40;
443
443
  t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
444
444
  "transform",
445
445
  r === "left" || r === "right" ? `translateX(${l}px) scale(${1 + a})` : `translateY(${l}px) scale(${1 + a})`,
@@ -492,8 +492,8 @@ class M {
492
492
  });
493
493
  }
494
494
  }
495
- const S = new M();
496
- class q {
495
+ const S = new q();
496
+ class Y {
497
497
  constructor(t) {
498
498
  this.containers = /* @__PURE__ */ new Map(), this.cssInjected = !1, this.config = t;
499
499
  }
@@ -556,18 +556,18 @@ class q {
556
556
  a.className = "editora-toast-progress";
557
557
  const l = document.createElement("div");
558
558
  if (l.className = "editora-toast-progress-bar", l.style.width = `${Math.min(100, Math.max(0, s.progress.value))}%`, s.progress.showPercentage) {
559
- const d = document.createElement("span");
560
- d.className = "editora-toast-progress-text", d.textContent = `${Math.round(s.progress.value)}%`, a.appendChild(d);
559
+ const p = document.createElement("span");
560
+ p.className = "editora-toast-progress-text", p.textContent = `${Math.round(s.progress.value)}%`, a.appendChild(p);
561
561
  }
562
562
  a.appendChild(l), n.appendChild(a);
563
563
  }
564
564
  if (e.appendChild(n), s.actions && s.actions.length > 0) {
565
565
  const a = document.createElement("div");
566
566
  a.className = "editora-toast-actions", s.actions.forEach((l) => {
567
- const d = document.createElement("button");
568
- d.className = `editora-toast-action ${l.primary ? "primary" : ""}`, d.textContent = l.label, d.onclick = (m) => {
569
- m.stopPropagation(), l.onClick();
570
- }, a.appendChild(d);
567
+ const p = document.createElement("button");
568
+ p.className = `editora-toast-action ${l.primary ? "primary" : ""}`, p.textContent = l.label, p.onclick = (y) => {
569
+ y.stopPropagation(), l.onClick();
570
+ }, a.appendChild(p);
571
571
  }), e.appendChild(a);
572
572
  }
573
573
  if (s.closable !== !1) {
@@ -644,8 +644,8 @@ class q {
644
644
  let o = t.element.querySelector(".editora-toast-actions");
645
645
  s.actions && s.actions.length > 0 ? (o ? o.innerHTML = "" : (o = document.createElement("div"), o.className = "editora-toast-actions", t.element.appendChild(o)), o && s.actions.forEach((a) => {
646
646
  const l = document.createElement("button");
647
- l.className = `editora-toast-action ${a.primary ? "primary" : ""}`, l.textContent = a.label, l.onclick = (d) => {
648
- d.stopPropagation(), a.onClick();
647
+ l.className = `editora-toast-action ${a.primary ? "primary" : ""}`, l.textContent = a.label, l.onclick = (p) => {
648
+ p.stopPropagation(), a.onClick();
649
649
  }, o.appendChild(l);
650
650
  })) : o && o.remove();
651
651
  }
@@ -668,42 +668,42 @@ class q {
668
668
  let e = 0, i = 0, r = !1;
669
669
  const n = s.options.swipeDirection || this.config.swipeDirection || "any", o = 40;
670
670
  let a = "", l = !1;
671
- const d = (p) => {
672
- r = !0, l = !1, e = "touches" in p ? p.touches[0].clientX : p.clientX, i = "touches" in p ? p.touches[0].clientY : p.clientY, a = t.style.transform || "", t.style.transition = "none", t.style.cursor = "grabbing", p.preventDefault();
673
- }, m = (p) => {
671
+ const p = (d) => {
672
+ r = !0, l = !1, e = "touches" in d ? d.touches[0].clientX : d.clientX, i = "touches" in d ? d.touches[0].clientY : d.clientY, a = t.style.transform || "", t.style.transition = "none", t.style.cursor = "grabbing", d.preventDefault();
673
+ }, y = (d) => {
674
674
  if (!r)
675
675
  return;
676
- const g = "touches" in p ? p.touches[0].clientX : p.clientX, b = "touches" in p ? p.touches[0].clientY : p.clientY, y = g - e, w = b - i, f = 5;
677
- if ((Math.abs(y) > f || Math.abs(w) > f) && (l = !0), l) {
678
- const v = Math.abs(w) > Math.abs(y) ? 25 : 20, P = Math.min(Math.max(y * 0.2, -v), v), x = Math.min(Math.max(w * 0.2, -v), v);
679
- t.style.transform = `${a} translate(${P}px, ${x}px)`;
676
+ const g = "touches" in d ? d.touches[0].clientX : d.clientX, b = "touches" in d ? d.touches[0].clientY : d.clientY, m = g - e, w = b - i, f = 5;
677
+ if ((Math.abs(m) > f || Math.abs(w) > f) && (l = !0), l) {
678
+ const v = Math.abs(w) > Math.abs(m) ? 25 : 20, P = Math.min(Math.max(m * 0.2, -v), v), H = Math.min(Math.max(w * 0.2, -v), v);
679
+ t.style.transform = `${a} translate(${P}px, ${H}px)`;
680
680
  }
681
- (Math.abs(w) > Math.abs(y) || n === "vertical" || n === "up" || n === "down") && p.preventDefault();
682
- }, u = (p) => {
681
+ (Math.abs(w) > Math.abs(m) || n === "vertical" || n === "up" || n === "down") && d.preventDefault();
682
+ }, u = (d) => {
683
683
  if (!r)
684
684
  return;
685
685
  if (t.style.transform = a, t.style.transition = "", t.style.cursor = "", !l) {
686
686
  r = !1;
687
687
  return;
688
688
  }
689
- const g = "changedTouches" in p ? p.changedTouches[0].clientX : p.clientX, b = "changedTouches" in p ? p.changedTouches[0].clientY : p.clientY, y = g - e, w = b - i;
689
+ const g = "changedTouches" in d ? d.changedTouches[0].clientX : d.clientX, b = "changedTouches" in d ? d.changedTouches[0].clientY : d.clientY, m = g - e, w = b - i;
690
690
  let f = !1;
691
691
  const v = n === "vertical" || n === "up" || n === "down", P = v ? 35 : o;
692
692
  switch (n) {
693
693
  case "any":
694
- f = Math.abs(y) > o || Math.abs(w) > o;
694
+ f = Math.abs(m) > o || Math.abs(w) > o;
695
695
  break;
696
696
  case "horizontal":
697
- f = Math.abs(y) > o;
697
+ f = Math.abs(m) > o;
698
698
  break;
699
699
  case "vertical":
700
700
  f = Math.abs(w) > P;
701
701
  break;
702
702
  case "left":
703
- f = y < -o;
703
+ f = m < -o;
704
704
  break;
705
705
  case "right":
706
- f = y > o;
706
+ f = m > o;
707
707
  break;
708
708
  case "up":
709
709
  f = w < -P;
@@ -714,7 +714,7 @@ class q {
714
714
  }
715
715
  v && console.log(`Vertical swipe attempt: direction=${n}, deltaY=${w}, effectiveMinDistance=${P}, shouldDismiss=${f}`), f && s.dismiss(), r = !1;
716
716
  };
717
- t.addEventListener("dragstart", (p) => p.preventDefault()), t.addEventListener("touchstart", d, { passive: !1 }), t.addEventListener("touchmove", m, { passive: !1 }), t.addEventListener("touchend", u, { passive: !1 }), t.addEventListener("mousedown", d), t.addEventListener("mousemove", m), t.addEventListener("mouseup", u), t.addEventListener("mouseleave", u);
717
+ t.addEventListener("dragstart", (d) => d.preventDefault()), t.addEventListener("touchstart", p, { passive: !1 }), t.addEventListener("touchmove", y, { passive: !1 }), t.addEventListener("touchend", u, { passive: !1 }), t.addEventListener("mousedown", p), t.addEventListener("mousemove", y), t.addEventListener("mouseup", u), t.addEventListener("mouseleave", u);
718
718
  }
719
719
  // Drag dismiss (simplified)
720
720
  addDragDismiss(t, s) {
@@ -754,7 +754,7 @@ class q {
754
754
  }), this.containers.clear();
755
755
  }
756
756
  }
757
- class Y {
757
+ class F {
758
758
  constructor() {
759
759
  this.plugins = [], this.hooks = {
760
760
  beforeShow: [],
@@ -864,7 +864,7 @@ class Y {
864
864
  });
865
865
  }
866
866
  }
867
- const X = {
867
+ const I = {
868
868
  position: "bottom-right",
869
869
  duration: 4e3,
870
870
  maxVisible: 5,
@@ -886,7 +886,7 @@ const X = {
886
886
  };
887
887
  class C {
888
888
  constructor(t = {}) {
889
- this.idCounter = 0, this.pausedToasts = /* @__PURE__ */ new Set(), this.config = { ...X, ...t }, this.store = new k(this.config), this.queue = new H(this.config), this.renderer = new q(this.config), this.lifecycle = new Y(), this.setupWindowFocusHandling();
889
+ this.idCounter = 0, this.pausedToasts = /* @__PURE__ */ new Set(), this.config = { ...I, ...t }, this.store = new k(this.config), this.queue = new M(this.config), this.renderer = new Y(this.config), this.lifecycle = new F(), this.setupWindowFocusHandling();
890
890
  }
891
891
  // Core API
892
892
  show(t) {
@@ -947,7 +947,8 @@ class C {
947
947
  }
948
948
  // Configuration
949
949
  configure(t) {
950
- this.config = { ...this.config, ...t }, this.store.updateConfig(t), this.queue.updateConfig(t);
950
+ const s = this.config.pauseOnWindowBlur;
951
+ this.config = { ...this.config, ...t }, this.store.updateConfig(t), this.queue.updateConfig(t), t.pauseOnWindowBlur !== void 0 && t.pauseOnWindowBlur !== s && (this.teardownWindowFocusHandling(), this.setupWindowFocusHandling());
951
952
  }
952
953
  getConfig() {
953
954
  return { ...this.config };
@@ -988,9 +989,12 @@ class C {
988
989
  }
989
990
  // Window focus/blur handling
990
991
  setupWindowFocusHandling() {
991
- typeof window == "undefined" || !this.config.pauseOnWindowBlur || (this.windowBlurHandler = () => this.pauseAllToasts(), this.windowFocusHandler = () => this.resumeAllToasts(), window.addEventListener("blur", this.windowBlurHandler), window.addEventListener("focus", this.windowFocusHandler), document.addEventListener("visibilitychange", () => {
992
+ typeof window == "undefined" || typeof document == "undefined" || !this.config.pauseOnWindowBlur || (this.teardownWindowFocusHandling(), this.windowBlurHandler = () => this.pauseAllToasts(), this.windowFocusHandler = () => this.resumeAllToasts(), this.visibilityChangeHandler = () => {
992
993
  document.hidden ? this.pauseAllToasts() : this.resumeAllToasts();
993
- }));
994
+ }, window.addEventListener("blur", this.windowBlurHandler), window.addEventListener("focus", this.windowFocusHandler), document.addEventListener("visibilitychange", this.visibilityChangeHandler));
995
+ }
996
+ teardownWindowFocusHandling() {
997
+ typeof window != "undefined" && (this.windowBlurHandler && (window.removeEventListener("blur", this.windowBlurHandler), this.windowBlurHandler = void 0), this.windowFocusHandler && (window.removeEventListener("focus", this.windowFocusHandler), this.windowFocusHandler = void 0), typeof document != "undefined" && this.visibilityChangeHandler && (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = void 0));
994
998
  }
995
999
  pauseAllToasts() {
996
1000
  this.store.getAllToasts().forEach((s) => {
@@ -1009,15 +1013,18 @@ class C {
1009
1013
  }
1010
1014
  // Cleanup
1011
1015
  destroy() {
1012
- this.windowBlurHandler && typeof window != "undefined" && window.removeEventListener("blur", this.windowBlurHandler), this.windowFocusHandler && typeof window != "undefined" && window.removeEventListener("focus", this.windowFocusHandler), this.clear(), this.renderer.destroy(), this.lifecycle.destroy();
1016
+ this.teardownWindowFocusHandling(), this.clear(), this.renderer.destroy(), this.lifecycle.destroy();
1013
1017
  }
1014
1018
  }
1015
- const h = new C();
1016
- function T(c) {
1019
+ let T = null;
1020
+ function h() {
1021
+ return T || (T = new C()), T;
1022
+ }
1023
+ function E(c) {
1017
1024
  return typeof document == "undefined" ? { dismiss: () => {
1018
- } } : h.show(c);
1025
+ } } : h().show(c);
1019
1026
  }
1020
- function E(c, t, s, e) {
1027
+ function $(c, t, s, e) {
1021
1028
  const i = { position: "top-right", theme: "light" };
1022
1029
  let r = {};
1023
1030
  return t && typeof t == "object" ? r = { ...t } : typeof t == "number" && (r.duration = t), s && (r.theme = s), e && (r.position = e), {
@@ -1030,46 +1037,51 @@ function E(c, t, s, e) {
1030
1037
  };
1031
1038
  }
1032
1039
  const L = {
1033
- info: (c, t, s, e) => T({ ...E(c, t, s, e), level: "info" }),
1034
- success: (c, t, s, e) => T({ ...E(c, t, s, e), level: "success" }),
1035
- error: (c, t, s, e) => T({ ...E(c, t, s, e), level: "error" }),
1036
- warning: (c, t, s, e) => T({ ...E(c, t, s, e), level: "warning" }),
1037
- loading: (c, t, s, e) => T({ ...E(c, t, s, e), level: "loading" })
1038
- }, $ = {
1040
+ info: (c, t, s, e) => E({ ...$(c, t, s, e), level: "info" }),
1041
+ success: (c, t, s, e) => E({ ...$(c, t, s, e), level: "success" }),
1042
+ error: (c, t, s, e) => E({ ...$(c, t, s, e), level: "error" }),
1043
+ warning: (c, t, s, e) => E({ ...$(c, t, s, e), level: "warning" }),
1044
+ loading: (c, t, s, e) => E({ ...$(c, t, s, e), level: "loading" })
1045
+ }, x = {
1039
1046
  // Core methods
1040
- show: (c) => h.show(c),
1041
- update: (c, t) => h.update(c, t),
1042
- dismiss: (c) => h.dismiss(c),
1043
- clear: () => h.clear(),
1047
+ show: (c) => h().show(c),
1048
+ update: (c, t) => h().update(c, t),
1049
+ dismiss: (c) => h().dismiss(c),
1050
+ clear: () => h().clear(),
1044
1051
  // Convenience methods
1045
- info: (c, t) => h.show({ message: c, level: "info", ...t }),
1046
- success: (c, t) => h.show({ message: c, level: "success", ...t }),
1047
- error: (c, t) => h.show({ message: c, level: "error", ...t }),
1048
- warning: (c, t) => h.show({ message: c, level: "warning", ...t }),
1049
- loading: (c, t) => h.show({ message: c, level: "loading", ...t }),
1052
+ info: (c, t) => h().show({ message: c, level: "info", ...t }),
1053
+ success: (c, t) => h().show({ message: c, level: "success", ...t }),
1054
+ error: (c, t) => h().show({ message: c, level: "error", ...t }),
1055
+ warning: (c, t) => h().show({ message: c, level: "warning", ...t }),
1056
+ loading: (c, t) => h().show({ message: c, level: "loading", ...t }),
1050
1057
  // Advanced features
1051
- promise: (c, t) => h.promise(c, t),
1052
- group: (c, t) => h.group(c, t),
1053
- configure: (c) => h.configure(c),
1054
- use: (c) => h.use(c),
1058
+ promise: (c, t) => h().promise(c, t),
1059
+ group: (c, t) => h().group(c, t),
1060
+ configure: (c) => h().configure(c),
1061
+ use: (c) => h().use(c),
1055
1062
  // State queries
1056
- getToasts: () => h.getToasts(),
1057
- getGroups: () => h.getGroups(),
1058
- getConfig: () => h.getConfig(),
1063
+ getToasts: () => h().getToasts(),
1064
+ getGroups: () => h().getGroups(),
1065
+ getConfig: () => h().getConfig(),
1059
1066
  // Editor integration
1060
- onEditorEvent: (c, t) => h.onEditorEvent(c, t),
1061
- triggerEditorEvent: (c, t, ...s) => h.triggerEditorEvent(c, t, ...s),
1067
+ onEditorEvent: (c, t) => h().onEditorEvent(c, t),
1068
+ triggerEditorEvent: (c, t, ...s) => h().triggerEditorEvent(c, t, ...s),
1062
1069
  // Cleanup
1063
- destroy: () => h.destroy()
1070
+ destroy: () => {
1071
+ T && (T.destroy(), T = null);
1072
+ }
1064
1073
  };
1065
- typeof window != "undefined" && typeof document != "undefined" && (window.toast = L, window.toastAdvanced = $, window.toastPro = $, window.ToastManager = C, window.dispatchEvent(new CustomEvent("toastReady", {
1066
- detail: { toast: L, toastAdvanced: $, toastPro: $, ToastManager: C }
1067
- })));
1074
+ if (typeof window != "undefined" && typeof document != "undefined") {
1075
+ const c = window;
1076
+ c.toast = L, c.toastAdvanced = x, c.toastPro = x, c.ToastManager = C, c.__editoraToastReady || (c.__editoraToastReady = !0, window.dispatchEvent(new CustomEvent("toastReady", {
1077
+ detail: { toast: L, toastAdvanced: x, toastPro: x, ToastManager: C }
1078
+ })));
1079
+ }
1068
1080
  export {
1069
1081
  C as ToastManager,
1070
1082
  L as default,
1071
1083
  L as toast,
1072
- $ as toastAdvanced,
1073
- $ as toastPro
1084
+ x as toastAdvanced,
1085
+ x as toastPro
1074
1086
  };
1075
1087
  //# sourceMappingURL=index.esm.js.map
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(b,$){typeof exports=="object"&&typeof module!="undefined"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(b=typeof globalThis!="undefined"?globalThis:b||self,$(b.EditoraToast={}))})(this,function(b){"use strict";class ${constructor(t){this.toasts=new Map,this.groups=new Map,this.containers=new Map,this.config={...t}}addToast(t){this.toasts.set(t.id,t),this.updateGroup(t)}removeToast(t){const e=this.toasts.get(t);return e?(this.toasts.delete(t),this.updateGroup(e),!0):!1}getToast(t){return this.toasts.get(t)}getAllToasts(){return Array.from(this.toasts.values())}getToastsByPosition(t){return this.getAllToasts().filter(e=>e.options.position===t)}updateToast(t,e){const s=this.toasts.get(t);return s?(Object.assign(s,e),this.updateGroup(s),!0):!1}updateGroup(t){const e=t.options.group;if(!e)return;let s=this.groups.get(e);s||(s={id:e,toasts:[]},this.groups.set(e,s)),s.toasts=s.toasts.filter(i=>i.id!==t.id),t.options.group===e&&s.toasts.push(t),s.toasts.length===0&&this.groups.delete(e)}getGroup(t){return this.groups.get(t)}getAllGroups(){return Array.from(this.groups.values())}getContainer(t){return this.containers.get(t)}setContainer(t,e){this.containers.set(t,e)}removeContainer(t){return this.containers.delete(t)}getAllContainers(){return new Map(this.containers)}getConfig(){return{...this.config}}updateConfig(t){this.config={...this.config,...t}}clear(){this.toasts.clear(),this.groups.clear()}getStats(){return{totalToasts:this.toasts.size,totalGroups:this.groups.size,toastsByPosition:Object.fromEntries(Array.from(this.containers.keys()).map(t=>[t,this.getToastsByPosition(t).length]))}}}class M{constructor(t){this.queue=[],this.visible=[],this.config=t}enqueue(t){this.deduplicate(t),this.config.queueStrategy==="fifo"?this.queue.push(t):this.queue.unshift(t),this.queue.sort((e,s)=>(s.options.priority||0)-(e.options.priority||0)),this.processQueue()}dequeue(t){let e=!1;const s=this.queue.findIndex(r=>r.id===t);s!==-1&&(this.queue.splice(s,1),e=!0);const i=this.visible.findIndex(r=>r.id===t);return i!==-1&&(this.visible.splice(i,1),e=!0),e&&this.processQueue(),e}processQueue(){const t=this.config.maxVisible;for(;this.visible.length>t;){const e=this.visible.pop();this.hideToast(e)}for(;this.visible.length<t&&this.queue.length>0;){const e=this.queue.shift();this.showToast(e)}}showToast(t){this.visible.push(t)}hideToast(t){}deduplicate(t){this.queue.filter(s=>s.options.message===t.options.message&&s.options.level===t.options.level).forEach(s=>{const i=this.queue.indexOf(s);i!==-1&&this.queue.splice(i,1)})}updateConfig(t){this.config={...this.config,...t},this.processQueue()}getQueued(){return[...this.queue]}getVisible(){return[...this.visible]}getAll(){return[...this.visible,...this.queue]}clear(){const t=[...this.visible,...this.queue];this.queue=[],this.visible=[],t.forEach(e=>{e.element&&this.hideToast(e)})}forceShow(t){if(this.visible.length>=this.config.maxVisible){const e=this.visible.reduce((s,i)=>(i.options.priority||0)<(s.options.priority||0)?i:s);this.dequeue(e.id)}this.showToast(t)}}class A{constructor(t={}){var e,s,i,r;this.config={stiffness:(e=t.stiffness)!=null?e:100,damping:(s=t.damping)!=null?s:10,mass:(i=t.mass)!=null?i:1,precision:(r=t.precision)!=null?r:.01}}animate(t,e,s,i,r){const n={...this.config,...r};let o,a=!1;const l=Object.keys(e).reduce((u,d)=>(u[d]=e[d].from,u),{}),p=Object.keys(e).reduce((u,d)=>(u[d]=0,u),{}),m=()=>{if(a)return;let u=!0;Object.keys(e).forEach(g=>{const v=e[g].to,f=l[g],w=p[g],y=-n.stiffness*(f-v),P=-n.damping*w,H=(y+P)/n.mass;p[g]+=H*.016,l[g]+=p[g]*.016,(Math.abs(f-v)>n.precision||Math.abs(w)>n.precision)&&(u=!1)});const d=Object.keys(l).reduce((g,v)=>{const f=e[v].unit||"px";return g[v]=`${l[v]}${f}`,g},{});s(d),u?(a=!0,i==null||i()):o=requestAnimationFrame(m)};return o=requestAnimationFrame(m),()=>{a=!0,o&&cancelAnimationFrame(o)}}}class q{constructor(){this.springAnimation=new A}async showToast(t,e,s){switch(s.type){case"spring":await this.animateSpringShow(t,s);break;case"bounce":await this.animateBounceShow(t,s);break;case"slide":await this.animateSlideShow(t,s);break;case"zoom":await this.animateZoomShow(t,s);break;case"flip":await this.animateFlipShow(t,s);break;case"fade":await this.animateFadeShow(t,s);break;case"elastic":await this.animateElasticShow(t,s);break;case"rotate":await this.animateRotateShow(t,s);break;case"custom":s.show?await Promise.resolve(s.show(t,e)):this.animateCssShow(t);break;case"css":default:this.animateCssShow(t);break}}async hideToast(t,e,s){switch(s.type){case"spring":await this.animateSpringHide(t,s);break;case"bounce":await this.animateBounceHide(t,s);break;case"slide":await this.animateSlideHide(t,s);break;case"zoom":await this.animateZoomHide(t,s);break;case"flip":await this.animateFlipHide(t,s);break;case"fade":await this.animateFadeHide(t,s);break;case"elastic":await this.animateElasticHide(t,s);break;case"rotate":await this.animateRotateHide(t,s);break;case"custom":s.hide?await Promise.resolve(s.hide(t,e)):this.animateCssHide(t);break;case"css":default:this.animateCssHide(t);break}}async updateToast(t,e,s,i){i.type==="custom"&&i.update&&await Promise.resolve(i.update(t,e,s))}animateCssShow(t){requestAnimationFrame(()=>{t.classList.add("show")})}animateCssHide(t){t.classList.remove("show"),t.classList.add("hiding")}async animateSpringShow(t,e){return new Promise(s=>{var n,o,a;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important");const r=((n=t.parentElement)==null?void 0:n.classList.contains("editora-toast-bottom-right"))||((o=t.parentElement)==null?void 0:o.classList.contains("editora-toast-bottom-left"))||((a=t.parentElement)==null?void 0:a.classList.contains("editora-toast-bottom-center"))?20:-20;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`translateY(${r}px) scale(0.95)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition","opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1)","important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},800)},16)})}async animateSpringHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important"),setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform","translateY(-10px) scale(0.95)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateBounceShow(t,e){return new Promise(s=>{var p,m,u;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-right"))||((m=t.parentElement)==null?void 0:m.classList.contains("editora-toast-bottom-left"))||((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),n=e.intensity||"normal",o=e.duration||800,a=n==="gentle"?.05:n==="strong"?.15:.1,l=r==="up"?30:r==="down"?-30:r==="left"?30:-30;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",r==="left"||r==="right"?`translateX(${l}px) scale(${1-a})`:`translateY(${l}px) scale(${1-a})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},o)},16)})}async animateBounceHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",r=i==="gentle"?.05:i==="strong"?.15:.1;setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1-r})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateSlideShow(t,e){return new Promise(s=>{var p,m,u;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-right"))||((m=t.parentElement)==null?void 0:m.classList.contains("editora-toast-bottom-left"))||((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),n=e.distance||100,o=e.easing||"ease-out",a=e.duration||400,l=r==="up"?`translateY(${n}px)`:r==="down"?`translateY(-${n}px)`:r==="left"?`translateX(${n}px)`:`translateX(-${n}px)`;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",l,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${o}, transform ${a}ms ${o}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},16)})}async animateSlideHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"down",r=e.distance||100,n=e.easing||"ease-in",o=e.duration||300,a=i==="up"?`translateY(-${r}px)`:i==="down"?`translateY(${r}px)`:i==="left"?`translateX(-${r}px)`:`translateX(${r}px)`;setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ${n}, transform ${o}ms ${n}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},o)},16)})}async animateZoomShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,r=e.origin||"center",n=e.easing||"ease-out",o=e.duration||500;t.style.setProperty("transform-origin",r,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ${n}, transform ${o}ms ${n}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},o)},16)})}async animateZoomHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,r=e.origin||"center",n=e.easing||"ease-in",o=e.duration||300;t.style.setProperty("transform-origin",r,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ${n}, transform ${o}ms ${n}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},o)},16)})}async animateFlipShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",r=e.perspective||1e3,n=e.direction||"forward",o=e.duration||600;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const a=n==="forward"?i==="x"?-90:90:i==="x"?90:-90;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${a}deg)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotateX(0deg) rotateY(0deg)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},o)},16)})}async animateFlipHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",r=e.perspective||1e3,n=e.direction||"backward",o=e.duration||400;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const a=n==="backward"?i==="x"?-90:90:i==="x"?90:-90;setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${a}deg)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},o)},16)})}async animateFadeShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",r=e.distance||20,n=e.duration||300;let o="translateY(0) translateX(0)";i!=="none"&&(o=i==="up"?`translateY(${r}px)`:i==="down"?`translateY(-${r}px)`:i==="left"?`translateX(${r}px)`:`translateX(-${r}px)`),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms ease`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateFadeHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",r=e.distance||20,n=e.duration||200;let o="translateY(0) translateX(0)";i!=="none"&&(o=i==="up"?`translateY(-${r}px)`:i==="down"?`translateY(${r}px)`:i==="left"?`translateX(-${r}px)`:`translateX(${r}px)`),setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms ease`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateElasticShow(t,e){return new Promise(s=>{var p,m,u;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-right"))||((m=t.parentElement)==null?void 0:m.classList.contains("editora-toast-bottom-left"))||((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),n=e.intensity||"normal",o=e.duration||1e3,a=n==="gentle"?.1:n==="strong"?.3:.2,l=r==="up"?40:r==="down"?-40:r==="left"?40:-40;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",r==="left"||r==="right"?`translateX(${l}px) scale(${1+a})`:`translateY(${l}px) scale(${1+a})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},o)},16)})}async animateElasticHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",r=i==="gentle"?.1:i==="strong"?.3:.2;e.duration,setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1+r})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateRotateShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||360,r=e.direction||"clockwise",n=e.origin||"center",o=e.duration||500,a=r==="clockwise"?i:-i;t.style.setProperty("transform-origin",n,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${a}deg) scale(0.8)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotate(0deg) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},o)},16)})}async animateRotateHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||180,r=e.direction||"counterclockwise",n=e.origin||"center",o=e.duration||300,a=r==="clockwise"?i:-i;t.style.setProperty("transform-origin",n,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${a}deg) scale(0.8)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},o)},16)})}}const k=new q;class Y{constructor(t){this.containers=new Map,this.cssInjected=!1,this.config=t}ensureContainer(t){if(this.containers.has(t))return this.containers.get(t);const e=document.createElement("div");e.className=`editora-toast-container editora-toast-${t.replace("-","-")}`,e.setAttribute("role","region"),e.setAttribute("aria-label","Toast notifications"),e.setAttribute("aria-live","polite");const s={position:"fixed",zIndex:(this.config.zIndex||2147483647).toString(),display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none",maxWidth:"100%",boxSizing:"border-box"};switch(t){case"top-left":s.top="16px",s.left="16px";break;case"top-right":s.top="16px",s.right="16px";break;case"bottom-left":s.bottom="16px",s.left="16px";break;case"bottom-right":s.bottom="16px",s.right="16px";break;case"center":s.top="50%",s.left="50%",s.transform="translate(-50%, -50%)",s.alignItems="center";break}return Object.assign(e.style,s),document.body.appendChild(e),this.containers.set(t,e),this.injectCSS(),e}createToastElement(t){const e=t.options,s=document.createElement("div");s.className=`editora-toast editora-toast-${e.level||"info"}`,e.customClass&&s.classList.add(e.customClass),s.setAttribute("role","alert"),s.setAttribute("aria-atomic","true");const i=e.theme||this.config.theme;i&&i!=="system"&&s.setAttribute("data-theme",i),(e.rtl!==void 0?e.rtl:this.config.rtl)&&(s.setAttribute("data-rtl","true"),s.setAttribute("dir","rtl"));const n=document.createElement("div");if(n.className="editora-toast-content",e.icon){const a=document.createElement("span");a.className="editora-toast-icon",a.textContent=e.icon,n.appendChild(a)}const o=document.createElement("span");if(o.className="editora-toast-message",e.html&&e.message)o.innerHTML=this.sanitizeHTML(e.message);else if(e.render){const a=e.render();o.appendChild(a)}else o.textContent=e.message||"";if(n.appendChild(o),e.progress){const a=document.createElement("div");a.className="editora-toast-progress";const l=document.createElement("div");if(l.className="editora-toast-progress-bar",l.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`,e.progress.showPercentage){const p=document.createElement("span");p.className="editora-toast-progress-text",p.textContent=`${Math.round(e.progress.value)}%`,a.appendChild(p)}a.appendChild(l),n.appendChild(a)}if(s.appendChild(n),e.actions&&e.actions.length>0){const a=document.createElement("div");a.className="editora-toast-actions",e.actions.forEach(l=>{const p=document.createElement("button");p.className=`editora-toast-action ${l.primary?"primary":""}`,p.textContent=l.label,p.onclick=m=>{m.stopPropagation(),l.onClick()},a.appendChild(p)}),s.appendChild(a)}if(e.closable!==!1){const a=document.createElement("button");a.className="editora-toast-close",a.setAttribute("aria-label","Close notification"),a.innerHTML="×",a.onclick=()=>t.dismiss(),s.appendChild(a)}return e.pauseOnHover&&(s.addEventListener("mouseenter",()=>this.pauseToast(t)),s.addEventListener("mouseleave",()=>this.resumeToast(t))),e.pauseOnFocus&&(s.addEventListener("focusin",()=>this.pauseToast(t)),s.addEventListener("focusout",()=>this.resumeToast(t))),e.swipeDismiss&&this.addSwipeDismiss(s,t),e.dragDismiss&&this.addDragDismiss(s,t),s}async showToast(t){var r,n;const e=this.ensureContainer(t.options.position||this.config.position),s=this.createToastElement(t);t.element=s,e.appendChild(s);const i=t.options.animation||this.config.animation||{type:"css"};if(await k.showToast(s,t,i),this.config.enableAccessibility&&this.announceToast(t),(n=(r=t.options).onShow)==null||n.call(r),!t.options.persistent&&t.options.duration!==0){const o=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{this.hideToast(t)},o)}}async hideToast(t){var s,i;if(!t.element)return;t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0);const e=t.options.animation||this.config.animation||{type:"css"};await k.hideToast(t.element,t,e),t.element&&t.element.parentNode&&(t.element.parentNode.removeChild(t.element),t.element=void 0),(i=(s=t.options).onHide)==null||i.call(s)}async updateToast(t,e){var r,n;if(!t.element)return;const s=t.options.animation||this.config.animation||{type:"css"};if(s.type==="custom"&&s.update){await k.updateToast(t.element,t,e,s);return}Object.assign(t.options,e),e.level&&(t.element.className=t.element.className.replace(/editora-toast--(info|success|error|warning|loading|custom)/g,""),t.element.classList.add(`editora-toast--${e.level}`));const i=t.element.querySelector(".editora-toast-message");if(i&&e.message!==void 0)if(t.options.html&&e.message)i.innerHTML=this.sanitizeHTML(e.message);else if(t.options.render){const o=t.element.querySelector(".editora-toast-content");if(o){const a=t.options.render();o.innerHTML="",o.appendChild(a)}}else i.textContent=e.message||"";if(e.progress!==void 0){let o=t.element.querySelector(".editora-toast-progress");if(e.progress){if(!o){o=document.createElement("div"),o.className="editora-toast-progress";const l=t.element.querySelector(".editora-toast-content");l&&l.appendChild(o)}const a=o.querySelector(".editora-toast-progress-bar");if(a&&(a.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`),e.progress.showPercentage){let l=o.querySelector(".editora-toast-progress-text");l||(l=document.createElement("span"),l.className="editora-toast-progress-text",o.insertBefore(l,o.firstChild)),l.textContent=`${Math.round(e.progress.value)}%`}else{const l=o.querySelector(".editora-toast-progress-text");l&&l.remove()}}else o&&o.remove()}if(e.actions!==void 0){let o=t.element.querySelector(".editora-toast-actions");e.actions&&e.actions.length>0?(o?o.innerHTML="":(o=document.createElement("div"),o.className="editora-toast-actions",t.element.appendChild(o)),o&&e.actions.forEach(a=>{const l=document.createElement("button");l.className=`editora-toast-action ${a.primary?"primary":""}`,l.textContent=a.label,l.onclick=p=>{p.stopPropagation(),a.onClick()},o.appendChild(l)})):o&&o.remove()}(n=(r=t.options).onUpdate)==null||n.call(r,e)}pauseToast(t){t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0)}resumeToast(t){if(!t.options.persistent&&t.options.duration!==0){const e=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{this.hideToast(t)},e)}}addSwipeDismiss(t,e){let s=0,i=0,r=!1;const n=e.options.swipeDirection||this.config.swipeDirection||"any",o=40;let a="",l=!1;const p=d=>{r=!0,l=!1,s="touches"in d?d.touches[0].clientX:d.clientX,i="touches"in d?d.touches[0].clientY:d.clientY,a=t.style.transform||"",t.style.transition="none",t.style.cursor="grabbing",d.preventDefault()},m=d=>{if(!r)return;const g="touches"in d?d.touches[0].clientX:d.clientX,v="touches"in d?d.touches[0].clientY:d.clientY,f=g-s,w=v-i,y=5;if((Math.abs(f)>y||Math.abs(w)>y)&&(l=!0),l){const P=Math.abs(w)>Math.abs(f)?25:20,T=Math.min(Math.max(f*.2,-P),P),H=Math.min(Math.max(w*.2,-P),P);t.style.transform=`${a} translate(${T}px, ${H}px)`}(Math.abs(w)>Math.abs(f)||n==="vertical"||n==="up"||n==="down")&&d.preventDefault()},u=d=>{if(!r)return;if(t.style.transform=a,t.style.transition="",t.style.cursor="",!l){r=!1;return}const g="changedTouches"in d?d.changedTouches[0].clientX:d.clientX,v="changedTouches"in d?d.changedTouches[0].clientY:d.clientY,f=g-s,w=v-i;let y=!1;const P=n==="vertical"||n==="up"||n==="down",T=P?35:o;switch(n){case"any":y=Math.abs(f)>o||Math.abs(w)>o;break;case"horizontal":y=Math.abs(f)>o;break;case"vertical":y=Math.abs(w)>T;break;case"left":y=f<-o;break;case"right":y=f>o;break;case"up":y=w<-T;break;case"down":y=w>T;break}P&&console.log(`Vertical swipe attempt: direction=${n}, deltaY=${w}, effectiveMinDistance=${T}, shouldDismiss=${y}`),y&&e.dismiss(),r=!1};t.addEventListener("dragstart",d=>d.preventDefault()),t.addEventListener("touchstart",p,{passive:!1}),t.addEventListener("touchmove",m,{passive:!1}),t.addEventListener("touchend",u,{passive:!1}),t.addEventListener("mousedown",p),t.addEventListener("mousemove",m),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",u)}addDragDismiss(t,e){this.addSwipeDismiss(t,e)}announceToast(t){const e=document.createElement("div");e.setAttribute("aria-live","assertive"),e.setAttribute("aria-atomic","true"),e.style.position="absolute",e.style.left="-10000px",e.style.width="1px",e.style.height="1px",e.style.overflow="hidden",e.textContent=`${t.options.level||"info"}: ${t.options.message}`,document.body.appendChild(e),setTimeout(()=>{document.body.removeChild(e)},1e3)}sanitizeHTML(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}injectCSS(){if(this.cssInjected||typeof document=="undefined")return;if(!Array.from(document.styleSheets).find(e=>{var s,i,r,n;return((i=(s=e.ownerNode)==null?void 0:s.href)==null?void 0:i.includes("toast.css"))||((n=(r=e.ownerNode)==null?void 0:r.textContent)==null?void 0:n.includes("editora-toast"))})){const e=document.createElement("link");e.rel="stylesheet",e.href="/packages/editora-toast/dist/toast.css",document.head.appendChild(e)}this.cssInjected=!0}destroy(){this.containers.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.containers.clear()}}class X{constructor(){this.plugins=[],this.hooks={beforeShow:[],afterShow:[],beforeHide:[],afterHide:[],beforeUpdate:[],afterUpdate:[]}}use(t){if(this.plugins.find(e=>e.name===t.name)){console.warn(`Plugin "${t.name}" is already installed`);return}this.plugins.push(t),t.install(this)}remove(t){const e=this.plugins.findIndex(i=>i.name===t);if(e===-1)return!1;const s=this.plugins[e];return s.uninstall&&s.uninstall(this),this.plugins.splice(e,1),!0}getPlugins(){return[...this.plugins]}on(t,e){this.hooks[t]&&this.hooks[t].push(e)}off(t,e){if(this.hooks[t]){const s=this.hooks[t].indexOf(e);s!==-1&&this.hooks[t].splice(s,1)}}async trigger(t,e,...s){const i=this.hooks[t];if(!(!i||i.length===0))for(const r of i)try{await r(e,...s)}catch(n){console.error(`Error in ${t} hook:`,n)}}async beforeShow(t){await this.trigger("beforeShow",t)}async afterShow(t){await this.trigger("afterShow",t)}async beforeHide(t){await this.trigger("beforeHide",t)}async afterHide(t){await this.trigger("afterHide",t)}async beforeUpdate(t,e){await this.trigger("beforeUpdate",t,e)}async afterUpdate(t,e){await this.trigger("afterUpdate",t,e)}onEditorEvent(t,e){const s=`editor:${t}`;this.hooks[s]||(this.hooks[s]=[]),this.hooks[s].push(e)}triggerEditorEvent(t,e,...s){const i=`editor:${t}`;this.trigger(i,e,...s)}async handlePromise(t,e,s,i){e();try{const r=await t;return s(r),r}catch(r){throw i(r),r}}async batchShow(t){const e=t.map(i=>this.beforeShow(i));await Promise.all(e);const s=t.map(i=>this.afterShow(i));await Promise.all(s)}async batchHide(t){const e=t.map(i=>this.beforeHide(i));await Promise.all(e);const s=t.map(i=>this.afterHide(i));await Promise.all(s)}destroy(){this.plugins.forEach(t=>{t.uninstall&&t.uninstall(this)}),this.plugins=[],Object.keys(this.hooks).forEach(t=>{this.hooks[t]=[]})}}const I={position:"bottom-right",duration:4e3,maxVisible:5,queueStrategy:"fifo",theme:"system",pauseOnHover:!0,pauseOnFocus:!1,pauseOnWindowBlur:!1,swipeDismiss:!1,swipeDirection:"any",dragDismiss:!1,rtl:!1,enableAccessibility:!0,animation:{type:"css"}};class C{constructor(t={}){this.idCounter=0,this.pausedToasts=new Set,this.config={...I,...t},this.store=new $(this.config),this.queue=new M(this.config),this.renderer=new Y(this.config),this.lifecycle=new X,this.setupWindowFocusHandling()}show(t){const e=t.id||`toast-${++this.idCounter}`,s={id:e,options:{...this.config,...t},createdAt:Date.now(),dismiss:()=>this.dismiss(e),update:i=>this.update(e,i)};return this.lifecycle.beforeShow(s).then(async()=>{this.store.addToast(s),this.queue.enqueue(s),await this.renderer.showToast(s),this.lifecycle.afterShow(s)}),s}update(t,e){const s=this.store.getToast(t);return s?(this.lifecycle.beforeUpdate(s,e).then(async()=>{this.store.updateToast(t,{options:{...s.options,...e}}),await this.renderer.updateToast(s,e),this.lifecycle.afterUpdate(s,e)}),!0):!1}dismiss(t){const e=this.store.getToast(t);return e?(this.lifecycle.beforeHide(e).then(async()=>{this.queue.dequeue(t),await this.renderer.hideToast(e),this.store.removeToast(t),this.lifecycle.afterHide(e)}),!0):!1}clear(){const t=this.store.getAllToasts();this.lifecycle.batchHide(t).then(()=>{this.queue.clear(),this.store.clear()})}async promise(t,e){var i,r;const s=this.show(this.normalizeOptions(e.loading,"loading"));try{const n=await t,o=this.normalizeOptions(typeof e.success=="function"?e.success(n):e.success,"success");return this.update(s.id,o),(i=e.onSuccess)==null||i.call(e,n),n}catch(n){const o=this.normalizeOptions(typeof e.error=="function"?e.error(n):e.error,"error");throw this.update(s.id,o),(r=e.onError)==null||r.call(e,n),n}}group(t,e){return this.show({...e,group:t})}use(t){this.lifecycle.use(t)}configure(t){this.config={...this.config,...t},this.store.updateConfig(t),this.queue.updateConfig(t)}getConfig(){return{...this.config}}getToasts(){return this.store.getAllToasts()}getGroups(){return this.store.getAllGroups()}info(t,e){return this.show({message:t,level:"info",duration:e})}success(t,e){return this.show({message:t,level:"success",duration:e})}error(t,e){return this.show({message:t,level:"error",duration:e})}warning(t,e){return this.show({message:t,level:"warning",duration:e})}loading(t,e){return this.show({message:t,level:"loading",duration:e})}normalizeOptions(t,e){return typeof t=="string"?{message:t,level:e}:{...t,level:t.level||e}}onEditorEvent(t,e){this.lifecycle.onEditorEvent(t,e)}triggerEditorEvent(t,e,...s){this.lifecycle.triggerEditorEvent(t,e,...s)}setupWindowFocusHandling(){typeof window=="undefined"||!this.config.pauseOnWindowBlur||(this.windowBlurHandler=()=>this.pauseAllToasts(),this.windowFocusHandler=()=>this.resumeAllToasts(),window.addEventListener("blur",this.windowBlurHandler),window.addEventListener("focus",this.windowFocusHandler),document.addEventListener("visibilitychange",()=>{document.hidden?this.pauseAllToasts():this.resumeAllToasts()}))}pauseAllToasts(){this.store.getAllToasts().forEach(e=>{e.timeoutId&&!this.pausedToasts.has(e.id)&&(clearTimeout(e.timeoutId),e.timeoutId=void 0,this.pausedToasts.add(e.id))})}resumeAllToasts(){this.store.getAllToasts().forEach(e=>{if(this.pausedToasts.has(e.id)&&!e.options.persistent&&e.options.duration!==0){const s=e.options.duration||this.config.duration;e.timeoutId=window.setTimeout(()=>{this.dismiss(e.id)},s),this.pausedToasts.delete(e.id)}})}destroy(){this.windowBlurHandler&&typeof window!="undefined"&&window.removeEventListener("blur",this.windowBlurHandler),this.windowFocusHandler&&typeof window!="undefined"&&window.removeEventListener("focus",this.windowFocusHandler),this.clear(),this.renderer.destroy(),this.lifecycle.destroy()}}const h=new C;function x(c){return typeof document=="undefined"?{dismiss:()=>{}}:h.show(c)}function S(c,t,e,s){const i={position:"top-right",theme:"light"};let r={};return t&&typeof t=="object"?r={...t}:typeof t=="number"&&(r.duration=t),e&&(r.theme=e),s&&(r.position=s),{message:c,...r,duration:r.duration,level:r.level||void 0,position:r.position||i.position,theme:r.theme||i.theme}}const L={info:(c,t,e,s)=>x({...S(c,t,e,s),level:"info"}),success:(c,t,e,s)=>x({...S(c,t,e,s),level:"success"}),error:(c,t,e,s)=>x({...S(c,t,e,s),level:"error"}),warning:(c,t,e,s)=>x({...S(c,t,e,s),level:"warning"}),loading:(c,t,e,s)=>x({...S(c,t,e,s),level:"loading"})},E={show:c=>h.show(c),update:(c,t)=>h.update(c,t),dismiss:c=>h.dismiss(c),clear:()=>h.clear(),info:(c,t)=>h.show({message:c,level:"info",...t}),success:(c,t)=>h.show({message:c,level:"success",...t}),error:(c,t)=>h.show({message:c,level:"error",...t}),warning:(c,t)=>h.show({message:c,level:"warning",...t}),loading:(c,t)=>h.show({message:c,level:"loading",...t}),promise:(c,t)=>h.promise(c,t),group:(c,t)=>h.group(c,t),configure:c=>h.configure(c),use:c=>h.use(c),getToasts:()=>h.getToasts(),getGroups:()=>h.getGroups(),getConfig:()=>h.getConfig(),onEditorEvent:(c,t)=>h.onEditorEvent(c,t),triggerEditorEvent:(c,t,...e)=>h.triggerEditorEvent(c,t,...e),destroy:()=>h.destroy()};typeof window!="undefined"&&typeof document!="undefined"&&(window.toast=L,window.toastAdvanced=E,window.toastPro=E,window.ToastManager=C,window.dispatchEvent(new CustomEvent("toastReady",{detail:{toast:L,toastAdvanced:E,toastPro:E,ToastManager:C}}))),b.ToastManager=C,b.default=L,b.toast=L,b.toastAdvanced=E,b.toastPro=E,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(b,x){typeof exports=="object"&&typeof module!="undefined"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(b=typeof globalThis!="undefined"?globalThis:b||self,x(b.EditoraToast={}))})(this,function(b){"use strict";class x{constructor(t){this.toasts=new Map,this.groups=new Map,this.containers=new Map,this.config={...t}}addToast(t){this.toasts.set(t.id,t),this.updateGroup(t)}removeToast(t){const e=this.toasts.get(t);return e?(this.toasts.delete(t),this.updateGroup(e),!0):!1}getToast(t){return this.toasts.get(t)}getAllToasts(){return Array.from(this.toasts.values())}getToastsByPosition(t){return this.getAllToasts().filter(e=>e.options.position===t)}updateToast(t,e){const s=this.toasts.get(t);return s?(Object.assign(s,e),this.updateGroup(s),!0):!1}updateGroup(t){const e=t.options.group;if(!e)return;let s=this.groups.get(e);s||(s={id:e,toasts:[]},this.groups.set(e,s)),s.toasts=s.toasts.filter(i=>i.id!==t.id),t.options.group===e&&s.toasts.push(t),s.toasts.length===0&&this.groups.delete(e)}getGroup(t){return this.groups.get(t)}getAllGroups(){return Array.from(this.groups.values())}getContainer(t){return this.containers.get(t)}setContainer(t,e){this.containers.set(t,e)}removeContainer(t){return this.containers.delete(t)}getAllContainers(){return new Map(this.containers)}getConfig(){return{...this.config}}updateConfig(t){this.config={...this.config,...t}}clear(){this.toasts.clear(),this.groups.clear()}getStats(){return{totalToasts:this.toasts.size,totalGroups:this.groups.size,toastsByPosition:Object.fromEntries(Array.from(this.containers.keys()).map(t=>[t,this.getToastsByPosition(t).length]))}}}class A{constructor(t){this.queue=[],this.visible=[],this.config=t}enqueue(t){this.deduplicate(t),this.config.queueStrategy==="fifo"?this.queue.push(t):this.queue.unshift(t),this.queue.sort((e,s)=>(s.options.priority||0)-(e.options.priority||0)),this.processQueue()}dequeue(t){let e=!1;const s=this.queue.findIndex(r=>r.id===t);s!==-1&&(this.queue.splice(s,1),e=!0);const i=this.visible.findIndex(r=>r.id===t);return i!==-1&&(this.visible.splice(i,1),e=!0),e&&this.processQueue(),e}processQueue(){const t=this.config.maxVisible;for(;this.visible.length>t;){const e=this.visible.pop();this.hideToast(e)}for(;this.visible.length<t&&this.queue.length>0;){const e=this.queue.shift();this.showToast(e)}}showToast(t){this.visible.push(t)}hideToast(t){}deduplicate(t){this.queue.filter(s=>s.options.message===t.options.message&&s.options.level===t.options.level).forEach(s=>{const i=this.queue.indexOf(s);i!==-1&&this.queue.splice(i,1)})}updateConfig(t){this.config={...this.config,...t},this.processQueue()}getQueued(){return[...this.queue]}getVisible(){return[...this.visible]}getAll(){return[...this.visible,...this.queue]}clear(){const t=[...this.visible,...this.queue];this.queue=[],this.visible=[],t.forEach(e=>{e.element&&this.hideToast(e)})}forceShow(t){if(this.visible.length>=this.config.maxVisible){const e=this.visible.reduce((s,i)=>(i.options.priority||0)<(s.options.priority||0)?i:s);this.dequeue(e.id)}this.showToast(t)}}class q{constructor(t={}){var e,s,i,r;this.config={stiffness:(e=t.stiffness)!=null?e:100,damping:(s=t.damping)!=null?s:10,mass:(i=t.mass)!=null?i:1,precision:(r=t.precision)!=null?r:.01}}animate(t,e,s,i,r){const n={...this.config,...r};let o,a=!1;const l=Object.keys(e).reduce((u,d)=>(u[d]=e[d].from,u),{}),p=Object.keys(e).reduce((u,d)=>(u[d]=0,u),{}),f=()=>{if(a)return;let u=!0;Object.keys(e).forEach(g=>{const v=e[g].to,y=l[g],w=p[g],m=-n.stiffness*(y-v),P=-n.damping*w,M=(m+P)/n.mass;p[g]+=M*.016,l[g]+=p[g]*.016,(Math.abs(y-v)>n.precision||Math.abs(w)>n.precision)&&(u=!1)});const d=Object.keys(l).reduce((g,v)=>{const y=e[v].unit||"px";return g[v]=`${l[v]}${y}`,g},{});s(d),u?(a=!0,i==null||i()):o=requestAnimationFrame(f)};return o=requestAnimationFrame(f),()=>{a=!0,o&&cancelAnimationFrame(o)}}}class Y{constructor(){this.springAnimation=new q}async showToast(t,e,s){switch(s.type){case"spring":await this.animateSpringShow(t,s);break;case"bounce":await this.animateBounceShow(t,s);break;case"slide":await this.animateSlideShow(t,s);break;case"zoom":await this.animateZoomShow(t,s);break;case"flip":await this.animateFlipShow(t,s);break;case"fade":await this.animateFadeShow(t,s);break;case"elastic":await this.animateElasticShow(t,s);break;case"rotate":await this.animateRotateShow(t,s);break;case"custom":s.show?await Promise.resolve(s.show(t,e)):this.animateCssShow(t);break;case"css":default:this.animateCssShow(t);break}}async hideToast(t,e,s){switch(s.type){case"spring":await this.animateSpringHide(t,s);break;case"bounce":await this.animateBounceHide(t,s);break;case"slide":await this.animateSlideHide(t,s);break;case"zoom":await this.animateZoomHide(t,s);break;case"flip":await this.animateFlipHide(t,s);break;case"fade":await this.animateFadeHide(t,s);break;case"elastic":await this.animateElasticHide(t,s);break;case"rotate":await this.animateRotateHide(t,s);break;case"custom":s.hide?await Promise.resolve(s.hide(t,e)):this.animateCssHide(t);break;case"css":default:this.animateCssHide(t);break}}async updateToast(t,e,s,i){i.type==="custom"&&i.update&&await Promise.resolve(i.update(t,e,s))}animateCssShow(t){requestAnimationFrame(()=>{t.classList.add("show")})}animateCssHide(t){t.classList.remove("show"),t.classList.add("hiding")}async animateSpringShow(t,e){return new Promise(s=>{var n,o,a;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important");const r=((n=t.parentElement)==null?void 0:n.classList.contains("editora-toast-bottom-right"))||((o=t.parentElement)==null?void 0:o.classList.contains("editora-toast-bottom-left"))||((a=t.parentElement)==null?void 0:a.classList.contains("editora-toast-bottom-center"))?20:-20;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`translateY(${r}px) scale(0.95)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition","opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1)","important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},800)},16)})}async animateSpringHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important"),setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform","translateY(-10px) scale(0.95)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateBounceShow(t,e){return new Promise(s=>{var p,f,u;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-right"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-left"))||((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),n=e.intensity||"normal",o=e.duration||800,a=n==="gentle"?.05:n==="strong"?.15:.1,l=r==="up"?30:r==="down"?-30:r==="left"?30:-30;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",r==="left"||r==="right"?`translateX(${l}px) scale(${1-a})`:`translateY(${l}px) scale(${1-a})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},o)},16)})}async animateBounceHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",r=i==="gentle"?.05:i==="strong"?.15:.1;setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1-r})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateSlideShow(t,e){return new Promise(s=>{var p,f,u;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-right"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-left"))||((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),n=e.distance||100,o=e.easing||"ease-out",a=e.duration||400,l=r==="up"?`translateY(${n}px)`:r==="down"?`translateY(-${n}px)`:r==="left"?`translateX(${n}px)`:`translateX(-${n}px)`;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",l,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${a}ms ${o}, transform ${a}ms ${o}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},a)},16)})}async animateSlideHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"down",r=e.distance||100,n=e.easing||"ease-in",o=e.duration||300,a=i==="up"?`translateY(-${r}px)`:i==="down"?`translateY(${r}px)`:i==="left"?`translateX(-${r}px)`:`translateX(${r}px)`;setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ${n}, transform ${o}ms ${n}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},o)},16)})}async animateZoomShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,r=e.origin||"center",n=e.easing||"ease-out",o=e.duration||500;t.style.setProperty("transform-origin",r,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ${n}, transform ${o}ms ${n}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},o)},16)})}async animateZoomHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.scale||.3,r=e.origin||"center",n=e.easing||"ease-in",o=e.duration||300;t.style.setProperty("transform-origin",r,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ${n}, transform ${o}ms ${n}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${i})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},o)},16)})}async animateFlipShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",r=e.perspective||1e3,n=e.direction||"forward",o=e.duration||600;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const a=n==="forward"?i==="x"?-90:90:i==="x"?90:-90;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${a}deg)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotateX(0deg) rotateY(0deg)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},o)},16)})}async animateFlipHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.axis||"y",r=e.perspective||1e3,n=e.direction||"backward",o=e.duration||400;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${r}px`,"important");const a=n==="backward"?i==="x"?-90:90:i==="x"?90:-90;setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${i.toUpperCase()}(${a}deg)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),s()},o)},16)})}async animateFadeShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",r=e.distance||20,n=e.duration||300;let o="translateY(0) translateX(0)";i!=="none"&&(o=i==="up"?`translateY(${r}px)`:i==="down"?`translateY(-${r}px)`:i==="left"?`translateX(${r}px)`:`translateX(-${r}px)`),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms ease`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateFadeHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.direction||"none",r=e.distance||20,n=e.duration||200;let o="translateY(0) translateX(0)";i!=="none"&&(o=i==="up"?`translateY(-${r}px)`:i==="down"?`translateY(${r}px)`:i==="left"?`translateX(-${r}px)`:`translateX(${r}px)`),setTimeout(()=>{t.style.setProperty("transition",`opacity ${n}ms ease, transform ${n}ms ease`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",o,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},n)},16)})}async animateElasticShow(t,e){return new Promise(s=>{var p,f,u;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-right"))||((f=t.parentElement)==null?void 0:f.classList.contains("editora-toast-bottom-left"))||((u=t.parentElement)==null?void 0:u.classList.contains("editora-toast-bottom-center")),r=e.direction||(i?"up":"down"),n=e.intensity||"normal",o=e.duration||1e3,a=n==="gentle"?.1:n==="strong"?.3:.2,l=r==="up"?40:r==="down"?-40:r==="left"?40:-40;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",r==="left"||r==="right"?`translateX(${l}px) scale(${1+a})`:`translateY(${l}px) scale(${1+a})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${o}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},o)},16)})}async animateElasticHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.intensity||"normal",r=i==="gentle"?.1:i==="strong"?.3:.2;e.duration,setTimeout(()=>{t.style.setProperty("transition","opacity 0.4s ease, transform 0.4s ease","important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${1+r})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),s()},400)},16)})}async animateRotateShow(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||360,r=e.direction||"clockwise",n=e.origin||"center",o=e.duration||500,a=r==="clockwise"?i:-i;t.style.setProperty("transform-origin",n,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${a}deg) scale(0.8)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms cubic-bezier(0.175, 0.885, 0.32, 1.275)`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","rotate(0deg) scale(1)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},o)},16)})}async animateRotateHide(t,e){return new Promise(s=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const i=e.degrees||180,r=e.direction||"counterclockwise",n=e.origin||"center",o=e.duration||300,a=r==="clockwise"?i:-i;t.style.setProperty("transform-origin",n,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${o}ms ease, transform ${o}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${a}deg) scale(0.8)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),s()},o)},16)})}}const k=new Y;class F{constructor(t){this.containers=new Map,this.cssInjected=!1,this.config=t}ensureContainer(t){if(this.containers.has(t))return this.containers.get(t);const e=document.createElement("div");e.className=`editora-toast-container editora-toast-${t.replace("-","-")}`,e.setAttribute("role","region"),e.setAttribute("aria-label","Toast notifications"),e.setAttribute("aria-live","polite");const s={position:"fixed",zIndex:(this.config.zIndex||2147483647).toString(),display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none",maxWidth:"100%",boxSizing:"border-box"};switch(t){case"top-left":s.top="16px",s.left="16px";break;case"top-right":s.top="16px",s.right="16px";break;case"bottom-left":s.bottom="16px",s.left="16px";break;case"bottom-right":s.bottom="16px",s.right="16px";break;case"center":s.top="50%",s.left="50%",s.transform="translate(-50%, -50%)",s.alignItems="center";break}return Object.assign(e.style,s),document.body.appendChild(e),this.containers.set(t,e),this.injectCSS(),e}createToastElement(t){const e=t.options,s=document.createElement("div");s.className=`editora-toast editora-toast-${e.level||"info"}`,e.customClass&&s.classList.add(e.customClass),s.setAttribute("role","alert"),s.setAttribute("aria-atomic","true");const i=e.theme||this.config.theme;i&&i!=="system"&&s.setAttribute("data-theme",i),(e.rtl!==void 0?e.rtl:this.config.rtl)&&(s.setAttribute("data-rtl","true"),s.setAttribute("dir","rtl"));const n=document.createElement("div");if(n.className="editora-toast-content",e.icon){const a=document.createElement("span");a.className="editora-toast-icon",a.textContent=e.icon,n.appendChild(a)}const o=document.createElement("span");if(o.className="editora-toast-message",e.html&&e.message)o.innerHTML=this.sanitizeHTML(e.message);else if(e.render){const a=e.render();o.appendChild(a)}else o.textContent=e.message||"";if(n.appendChild(o),e.progress){const a=document.createElement("div");a.className="editora-toast-progress";const l=document.createElement("div");if(l.className="editora-toast-progress-bar",l.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`,e.progress.showPercentage){const p=document.createElement("span");p.className="editora-toast-progress-text",p.textContent=`${Math.round(e.progress.value)}%`,a.appendChild(p)}a.appendChild(l),n.appendChild(a)}if(s.appendChild(n),e.actions&&e.actions.length>0){const a=document.createElement("div");a.className="editora-toast-actions",e.actions.forEach(l=>{const p=document.createElement("button");p.className=`editora-toast-action ${l.primary?"primary":""}`,p.textContent=l.label,p.onclick=f=>{f.stopPropagation(),l.onClick()},a.appendChild(p)}),s.appendChild(a)}if(e.closable!==!1){const a=document.createElement("button");a.className="editora-toast-close",a.setAttribute("aria-label","Close notification"),a.innerHTML="×",a.onclick=()=>t.dismiss(),s.appendChild(a)}return e.pauseOnHover&&(s.addEventListener("mouseenter",()=>this.pauseToast(t)),s.addEventListener("mouseleave",()=>this.resumeToast(t))),e.pauseOnFocus&&(s.addEventListener("focusin",()=>this.pauseToast(t)),s.addEventListener("focusout",()=>this.resumeToast(t))),e.swipeDismiss&&this.addSwipeDismiss(s,t),e.dragDismiss&&this.addDragDismiss(s,t),s}async showToast(t){var r,n;const e=this.ensureContainer(t.options.position||this.config.position),s=this.createToastElement(t);t.element=s,e.appendChild(s);const i=t.options.animation||this.config.animation||{type:"css"};if(await k.showToast(s,t,i),this.config.enableAccessibility&&this.announceToast(t),(n=(r=t.options).onShow)==null||n.call(r),!t.options.persistent&&t.options.duration!==0){const o=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{this.hideToast(t)},o)}}async hideToast(t){var s,i;if(!t.element)return;t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0);const e=t.options.animation||this.config.animation||{type:"css"};await k.hideToast(t.element,t,e),t.element&&t.element.parentNode&&(t.element.parentNode.removeChild(t.element),t.element=void 0),(i=(s=t.options).onHide)==null||i.call(s)}async updateToast(t,e){var r,n;if(!t.element)return;const s=t.options.animation||this.config.animation||{type:"css"};if(s.type==="custom"&&s.update){await k.updateToast(t.element,t,e,s);return}Object.assign(t.options,e),e.level&&(t.element.className=t.element.className.replace(/editora-toast--(info|success|error|warning|loading|custom)/g,""),t.element.classList.add(`editora-toast--${e.level}`));const i=t.element.querySelector(".editora-toast-message");if(i&&e.message!==void 0)if(t.options.html&&e.message)i.innerHTML=this.sanitizeHTML(e.message);else if(t.options.render){const o=t.element.querySelector(".editora-toast-content");if(o){const a=t.options.render();o.innerHTML="",o.appendChild(a)}}else i.textContent=e.message||"";if(e.progress!==void 0){let o=t.element.querySelector(".editora-toast-progress");if(e.progress){if(!o){o=document.createElement("div"),o.className="editora-toast-progress";const l=t.element.querySelector(".editora-toast-content");l&&l.appendChild(o)}const a=o.querySelector(".editora-toast-progress-bar");if(a&&(a.style.width=`${Math.min(100,Math.max(0,e.progress.value))}%`),e.progress.showPercentage){let l=o.querySelector(".editora-toast-progress-text");l||(l=document.createElement("span"),l.className="editora-toast-progress-text",o.insertBefore(l,o.firstChild)),l.textContent=`${Math.round(e.progress.value)}%`}else{const l=o.querySelector(".editora-toast-progress-text");l&&l.remove()}}else o&&o.remove()}if(e.actions!==void 0){let o=t.element.querySelector(".editora-toast-actions");e.actions&&e.actions.length>0?(o?o.innerHTML="":(o=document.createElement("div"),o.className="editora-toast-actions",t.element.appendChild(o)),o&&e.actions.forEach(a=>{const l=document.createElement("button");l.className=`editora-toast-action ${a.primary?"primary":""}`,l.textContent=a.label,l.onclick=p=>{p.stopPropagation(),a.onClick()},o.appendChild(l)})):o&&o.remove()}(n=(r=t.options).onUpdate)==null||n.call(r,e)}pauseToast(t){t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0)}resumeToast(t){if(!t.options.persistent&&t.options.duration!==0){const e=t.options.duration||this.config.duration;t.timeoutId=window.setTimeout(()=>{this.hideToast(t)},e)}}addSwipeDismiss(t,e){let s=0,i=0,r=!1;const n=e.options.swipeDirection||this.config.swipeDirection||"any",o=40;let a="",l=!1;const p=d=>{r=!0,l=!1,s="touches"in d?d.touches[0].clientX:d.clientX,i="touches"in d?d.touches[0].clientY:d.clientY,a=t.style.transform||"",t.style.transition="none",t.style.cursor="grabbing",d.preventDefault()},f=d=>{if(!r)return;const g="touches"in d?d.touches[0].clientX:d.clientX,v="touches"in d?d.touches[0].clientY:d.clientY,y=g-s,w=v-i,m=5;if((Math.abs(y)>m||Math.abs(w)>m)&&(l=!0),l){const P=Math.abs(w)>Math.abs(y)?25:20,T=Math.min(Math.max(y*.2,-P),P),M=Math.min(Math.max(w*.2,-P),P);t.style.transform=`${a} translate(${T}px, ${M}px)`}(Math.abs(w)>Math.abs(y)||n==="vertical"||n==="up"||n==="down")&&d.preventDefault()},u=d=>{if(!r)return;if(t.style.transform=a,t.style.transition="",t.style.cursor="",!l){r=!1;return}const g="changedTouches"in d?d.changedTouches[0].clientX:d.clientX,v="changedTouches"in d?d.changedTouches[0].clientY:d.clientY,y=g-s,w=v-i;let m=!1;const P=n==="vertical"||n==="up"||n==="down",T=P?35:o;switch(n){case"any":m=Math.abs(y)>o||Math.abs(w)>o;break;case"horizontal":m=Math.abs(y)>o;break;case"vertical":m=Math.abs(w)>T;break;case"left":m=y<-o;break;case"right":m=y>o;break;case"up":m=w<-T;break;case"down":m=w>T;break}P&&console.log(`Vertical swipe attempt: direction=${n}, deltaY=${w}, effectiveMinDistance=${T}, shouldDismiss=${m}`),m&&e.dismiss(),r=!1};t.addEventListener("dragstart",d=>d.preventDefault()),t.addEventListener("touchstart",p,{passive:!1}),t.addEventListener("touchmove",f,{passive:!1}),t.addEventListener("touchend",u,{passive:!1}),t.addEventListener("mousedown",p),t.addEventListener("mousemove",f),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",u)}addDragDismiss(t,e){this.addSwipeDismiss(t,e)}announceToast(t){const e=document.createElement("div");e.setAttribute("aria-live","assertive"),e.setAttribute("aria-atomic","true"),e.style.position="absolute",e.style.left="-10000px",e.style.width="1px",e.style.height="1px",e.style.overflow="hidden",e.textContent=`${t.options.level||"info"}: ${t.options.message}`,document.body.appendChild(e),setTimeout(()=>{document.body.removeChild(e)},1e3)}sanitizeHTML(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}injectCSS(){if(this.cssInjected||typeof document=="undefined")return;if(!Array.from(document.styleSheets).find(e=>{var s,i,r,n;return((i=(s=e.ownerNode)==null?void 0:s.href)==null?void 0:i.includes("toast.css"))||((n=(r=e.ownerNode)==null?void 0:r.textContent)==null?void 0:n.includes("editora-toast"))})){const e=document.createElement("link");e.rel="stylesheet",e.href="/packages/editora-toast/dist/toast.css",document.head.appendChild(e)}this.cssInjected=!0}destroy(){this.containers.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.containers.clear()}}class I{constructor(){this.plugins=[],this.hooks={beforeShow:[],afterShow:[],beforeHide:[],afterHide:[],beforeUpdate:[],afterUpdate:[]}}use(t){if(this.plugins.find(e=>e.name===t.name)){console.warn(`Plugin "${t.name}" is already installed`);return}this.plugins.push(t),t.install(this)}remove(t){const e=this.plugins.findIndex(i=>i.name===t);if(e===-1)return!1;const s=this.plugins[e];return s.uninstall&&s.uninstall(this),this.plugins.splice(e,1),!0}getPlugins(){return[...this.plugins]}on(t,e){this.hooks[t]&&this.hooks[t].push(e)}off(t,e){if(this.hooks[t]){const s=this.hooks[t].indexOf(e);s!==-1&&this.hooks[t].splice(s,1)}}async trigger(t,e,...s){const i=this.hooks[t];if(!(!i||i.length===0))for(const r of i)try{await r(e,...s)}catch(n){console.error(`Error in ${t} hook:`,n)}}async beforeShow(t){await this.trigger("beforeShow",t)}async afterShow(t){await this.trigger("afterShow",t)}async beforeHide(t){await this.trigger("beforeHide",t)}async afterHide(t){await this.trigger("afterHide",t)}async beforeUpdate(t,e){await this.trigger("beforeUpdate",t,e)}async afterUpdate(t,e){await this.trigger("afterUpdate",t,e)}onEditorEvent(t,e){const s=`editor:${t}`;this.hooks[s]||(this.hooks[s]=[]),this.hooks[s].push(e)}triggerEditorEvent(t,e,...s){const i=`editor:${t}`;this.trigger(i,e,...s)}async handlePromise(t,e,s,i){e();try{const r=await t;return s(r),r}catch(r){throw i(r),r}}async batchShow(t){const e=t.map(i=>this.beforeShow(i));await Promise.all(e);const s=t.map(i=>this.afterShow(i));await Promise.all(s)}async batchHide(t){const e=t.map(i=>this.beforeHide(i));await Promise.all(e);const s=t.map(i=>this.afterHide(i));await Promise.all(s)}destroy(){this.plugins.forEach(t=>{t.uninstall&&t.uninstall(this)}),this.plugins=[],Object.keys(this.hooks).forEach(t=>{this.hooks[t]=[]})}}const O={position:"bottom-right",duration:4e3,maxVisible:5,queueStrategy:"fifo",theme:"system",pauseOnHover:!0,pauseOnFocus:!1,pauseOnWindowBlur:!1,swipeDismiss:!1,swipeDirection:"any",dragDismiss:!1,rtl:!1,enableAccessibility:!0,animation:{type:"css"}};class C{constructor(t={}){this.idCounter=0,this.pausedToasts=new Set,this.config={...O,...t},this.store=new x(this.config),this.queue=new A(this.config),this.renderer=new F(this.config),this.lifecycle=new I,this.setupWindowFocusHandling()}show(t){const e=t.id||`toast-${++this.idCounter}`,s={id:e,options:{...this.config,...t},createdAt:Date.now(),dismiss:()=>this.dismiss(e),update:i=>this.update(e,i)};return this.lifecycle.beforeShow(s).then(async()=>{this.store.addToast(s),this.queue.enqueue(s),await this.renderer.showToast(s),this.lifecycle.afterShow(s)}),s}update(t,e){const s=this.store.getToast(t);return s?(this.lifecycle.beforeUpdate(s,e).then(async()=>{this.store.updateToast(t,{options:{...s.options,...e}}),await this.renderer.updateToast(s,e),this.lifecycle.afterUpdate(s,e)}),!0):!1}dismiss(t){const e=this.store.getToast(t);return e?(this.lifecycle.beforeHide(e).then(async()=>{this.queue.dequeue(t),await this.renderer.hideToast(e),this.store.removeToast(t),this.lifecycle.afterHide(e)}),!0):!1}clear(){const t=this.store.getAllToasts();this.lifecycle.batchHide(t).then(()=>{this.queue.clear(),this.store.clear()})}async promise(t,e){var i,r;const s=this.show(this.normalizeOptions(e.loading,"loading"));try{const n=await t,o=this.normalizeOptions(typeof e.success=="function"?e.success(n):e.success,"success");return this.update(s.id,o),(i=e.onSuccess)==null||i.call(e,n),n}catch(n){const o=this.normalizeOptions(typeof e.error=="function"?e.error(n):e.error,"error");throw this.update(s.id,o),(r=e.onError)==null||r.call(e,n),n}}group(t,e){return this.show({...e,group:t})}use(t){this.lifecycle.use(t)}configure(t){const e=this.config.pauseOnWindowBlur;this.config={...this.config,...t},this.store.updateConfig(t),this.queue.updateConfig(t),t.pauseOnWindowBlur!==void 0&&t.pauseOnWindowBlur!==e&&(this.teardownWindowFocusHandling(),this.setupWindowFocusHandling())}getConfig(){return{...this.config}}getToasts(){return this.store.getAllToasts()}getGroups(){return this.store.getAllGroups()}info(t,e){return this.show({message:t,level:"info",duration:e})}success(t,e){return this.show({message:t,level:"success",duration:e})}error(t,e){return this.show({message:t,level:"error",duration:e})}warning(t,e){return this.show({message:t,level:"warning",duration:e})}loading(t,e){return this.show({message:t,level:"loading",duration:e})}normalizeOptions(t,e){return typeof t=="string"?{message:t,level:e}:{...t,level:t.level||e}}onEditorEvent(t,e){this.lifecycle.onEditorEvent(t,e)}triggerEditorEvent(t,e,...s){this.lifecycle.triggerEditorEvent(t,e,...s)}setupWindowFocusHandling(){typeof window=="undefined"||typeof document=="undefined"||!this.config.pauseOnWindowBlur||(this.teardownWindowFocusHandling(),this.windowBlurHandler=()=>this.pauseAllToasts(),this.windowFocusHandler=()=>this.resumeAllToasts(),this.visibilityChangeHandler=()=>{document.hidden?this.pauseAllToasts():this.resumeAllToasts()},window.addEventListener("blur",this.windowBlurHandler),window.addEventListener("focus",this.windowFocusHandler),document.addEventListener("visibilitychange",this.visibilityChangeHandler))}teardownWindowFocusHandling(){typeof window!="undefined"&&(this.windowBlurHandler&&(window.removeEventListener("blur",this.windowBlurHandler),this.windowBlurHandler=void 0),this.windowFocusHandler&&(window.removeEventListener("focus",this.windowFocusHandler),this.windowFocusHandler=void 0),typeof document!="undefined"&&this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=void 0))}pauseAllToasts(){this.store.getAllToasts().forEach(e=>{e.timeoutId&&!this.pausedToasts.has(e.id)&&(clearTimeout(e.timeoutId),e.timeoutId=void 0,this.pausedToasts.add(e.id))})}resumeAllToasts(){this.store.getAllToasts().forEach(e=>{if(this.pausedToasts.has(e.id)&&!e.options.persistent&&e.options.duration!==0){const s=e.options.duration||this.config.duration;e.timeoutId=window.setTimeout(()=>{this.dismiss(e.id)},s),this.pausedToasts.delete(e.id)}})}destroy(){this.teardownWindowFocusHandling(),this.clear(),this.renderer.destroy(),this.lifecycle.destroy()}}let E=null;function h(){return E||(E=new C),E}function S(c){return typeof document=="undefined"?{dismiss:()=>{}}:h().show(c)}function H(c,t,e,s){const i={position:"top-right",theme:"light"};let r={};return t&&typeof t=="object"?r={...t}:typeof t=="number"&&(r.duration=t),e&&(r.theme=e),s&&(r.position=s),{message:c,...r,duration:r.duration,level:r.level||void 0,position:r.position||i.position,theme:r.theme||i.theme}}const L={info:(c,t,e,s)=>S({...H(c,t,e,s),level:"info"}),success:(c,t,e,s)=>S({...H(c,t,e,s),level:"success"}),error:(c,t,e,s)=>S({...H(c,t,e,s),level:"error"}),warning:(c,t,e,s)=>S({...H(c,t,e,s),level:"warning"}),loading:(c,t,e,s)=>S({...H(c,t,e,s),level:"loading"})},$={show:c=>h().show(c),update:(c,t)=>h().update(c,t),dismiss:c=>h().dismiss(c),clear:()=>h().clear(),info:(c,t)=>h().show({message:c,level:"info",...t}),success:(c,t)=>h().show({message:c,level:"success",...t}),error:(c,t)=>h().show({message:c,level:"error",...t}),warning:(c,t)=>h().show({message:c,level:"warning",...t}),loading:(c,t)=>h().show({message:c,level:"loading",...t}),promise:(c,t)=>h().promise(c,t),group:(c,t)=>h().group(c,t),configure:c=>h().configure(c),use:c=>h().use(c),getToasts:()=>h().getToasts(),getGroups:()=>h().getGroups(),getConfig:()=>h().getConfig(),onEditorEvent:(c,t)=>h().onEditorEvent(c,t),triggerEditorEvent:(c,t,...e)=>h().triggerEditorEvent(c,t,...e),destroy:()=>{E&&(E.destroy(),E=null)}};if(typeof window!="undefined"&&typeof document!="undefined"){const c=window;c.toast=L,c.toastAdvanced=$,c.toastPro=$,c.ToastManager=C,c.__editoraToastReady||(c.__editoraToastReady=!0,window.dispatchEvent(new CustomEvent("toastReady",{detail:{toast:L,toastAdvanced:$,toastPro:$,ToastManager:C}})))}b.ToastManager=C,b.default=L,b.toast=L,b.toastAdvanced=$,b.toastPro=$,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
2
2
  //# sourceMappingURL=index.umd.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@editora/toast",
3
- "version": "2.0.1",
4
- "description": "Advanced toast notification system with enterprise features, backward compatibility, and rich customization options",
3
+ "version": "2.0.2",
4
+ "description": "Advanced toast notification system for the Editora UI ecosystem with enterprise features and rich customization",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "browser": "dist/index.umd.js",
@@ -18,9 +18,15 @@
18
18
  "./toast.css": "./dist/toast.css"
19
19
  },
20
20
  "files": [
21
- "dist"
21
+ "dist/**/*.js",
22
+ "dist/**/*.css",
23
+ "dist/**/*.d.ts",
24
+ "README.md",
25
+ "CHANGELOG.md"
22
26
  ],
23
27
  "keywords": [
28
+ "editora",
29
+ "editora ui ecosystem",
24
30
  "toast",
25
31
  "notification",
26
32
  "ui",
@@ -61,4 +67,4 @@
61
67
  "vite": "^7.3.1"
62
68
  },
63
69
  "gitHead": "694494db58b809f0dcf24501696284faa1ab68a5"
64
- }
70
+ }