@editora/toast 2.0.9 → 2.1.0

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
@@ -1,4 +1,4 @@
1
- class z {
1
+ class j {
2
2
  constructor(t) {
3
3
  this.toasts = /* @__PURE__ */ new Map(), this.groups = /* @__PURE__ */ new Map(), this.containers = /* @__PURE__ */ new Map(), this.config = { ...t };
4
4
  }
@@ -74,7 +74,7 @@ class z {
74
74
  };
75
75
  }
76
76
  }
77
- class N {
77
+ class W {
78
78
  constructor(t) {
79
79
  this.queue = [], this.visible = [], this.config = this.normalizeConfig(t);
80
80
  }
@@ -165,7 +165,7 @@ class N {
165
165
  };
166
166
  }
167
167
  }
168
- const F = /* @__PURE__ */ new Set([
168
+ const G = /* @__PURE__ */ new Set([
169
169
  "a",
170
170
  "b",
171
171
  "strong",
@@ -187,7 +187,7 @@ const F = /* @__PURE__ */ new Set([
187
187
  "ul",
188
188
  "ol",
189
189
  "li"
190
- ]), I = /* @__PURE__ */ new Set([
190
+ ]), K = /* @__PURE__ */ new Set([
191
191
  "script",
192
192
  "style",
193
193
  "iframe",
@@ -214,41 +214,41 @@ const F = /* @__PURE__ */ new Set([
214
214
  "audio",
215
215
  "video",
216
216
  "canvas"
217
- ]), Y = /^(?:https?:|mailto:|tel:)/i;
218
- function V(c) {
219
- const t = c.replace(/[\u0000- \u007f-\u009f]/g, "");
220
- return t ? Y.test(t) ? !0 : !/^[a-z][a-z0-9+.-]*:/i.test(t) : !1;
217
+ ]), R = /^(?:https?:|mailto:|tel:)/i;
218
+ function _(n) {
219
+ const t = n.replace(/[\u0000- \u007f-\u009f]/g, "");
220
+ return t ? R.test(t) ? !0 : !/^[a-z][a-z0-9+.-]*:/i.test(t) : !1;
221
221
  }
222
- function H(c, t, e) {
223
- for (const s of Array.from(c.childNodes)) {
222
+ function M(n, t, e) {
223
+ for (const s of Array.from(n.childNodes)) {
224
224
  if (s.nodeType === Node.TEXT_NODE) {
225
225
  t.appendChild(e.createTextNode(s.textContent || ""));
226
226
  continue;
227
227
  }
228
228
  if (s.nodeType !== Node.ELEMENT_NODE) continue;
229
229
  const i = s, o = i.localName.toLowerCase();
230
- if (I.has(o)) continue;
231
- if (!F.has(o)) {
232
- H(i, t, e);
230
+ if (K.has(o)) continue;
231
+ if (!G.has(o)) {
232
+ M(i, t, e);
233
233
  continue;
234
234
  }
235
235
  const r = e.createElement(o);
236
236
  if (o === "a") {
237
- const n = i.getAttribute("href");
238
- n && V(n) && (r.setAttribute("href", n.trim()), /^(?:https?:)?\/\//i.test(n.trim()) && (r.setAttribute("target", "_blank"), r.setAttribute("rel", "noopener noreferrer")));
239
- const a = i.getAttribute("title");
240
- a && r.setAttribute("title", a);
237
+ const a = i.getAttribute("href");
238
+ a && _(a) && (r.setAttribute("href", a.trim()), /^(?:https?:)?\/\//i.test(a.trim()) && (r.setAttribute("target", "_blank"), r.setAttribute("rel", "noopener noreferrer")));
239
+ const c = i.getAttribute("title");
240
+ c && r.setAttribute("title", c);
241
241
  }
242
- H(i, r, e), t.appendChild(r);
242
+ M(i, r, e), t.appendChild(r);
243
243
  }
244
244
  }
245
- function X(c, t) {
245
+ function U(n, t) {
246
246
  const e = document.createElement("template");
247
247
  e.innerHTML = t;
248
248
  const s = document.createDocumentFragment();
249
- H(e.content, s, document), c.textContent = "", c.appendChild(s);
249
+ M(e.content, s, document), n.textContent = "", n.appendChild(s);
250
250
  }
251
- class j {
251
+ class Q {
252
252
  constructor(t = {}) {
253
253
  var e, s, i, o;
254
254
  this.config = {
@@ -264,28 +264,28 @@ class j {
264
264
  ...this.config,
265
265
  ...o
266
266
  };
267
- let n, a = !1;
268
- const l = Object.keys(e).reduce((u, P) => (u[P] = e[P].from, u), {}), d = Object.keys(e).reduce((u, P) => (u[P] = 0, u), {}), f = () => {
269
- if (a) return;
267
+ let a, c = !1;
268
+ const l = Object.keys(e).reduce((u, v) => (u[v] = e[v].from, u), {}), h = Object.keys(e).reduce((u, v) => (u[v] = 0, u), {}), y = () => {
269
+ if (c) return;
270
270
  let u = !0;
271
- Object.keys(e).forEach((w) => {
272
- const v = e[w].to, S = l[w], p = d[w], y = -r.stiffness * (S - v), m = -r.damping * p, T = (y + m) / r.mass;
273
- d[w] += T * 0.016, l[w] += d[w] * 0.016, (Math.abs(S - v) > r.precision || Math.abs(p) > r.precision) && (u = !1);
271
+ Object.keys(e).forEach((d) => {
272
+ const m = e[d].to, T = l[d], f = h[d], w = -r.stiffness * (T - m), g = -r.damping * f, x = (w + g) / r.mass;
273
+ h[d] += x * 0.016, l[d] += h[d] * 0.016, (Math.abs(T - m) > r.precision || Math.abs(f) > r.precision) && (u = !1);
274
274
  });
275
- const P = Object.keys(l).reduce((w, v) => {
276
- const S = e[v].unit || "px";
277
- return w[v] = `${l[v]}${S}`, w;
275
+ const v = Object.keys(l).reduce((d, m) => {
276
+ const T = e[m].unit || "px";
277
+ return d[m] = `${l[m]}${T}`, d;
278
278
  }, {});
279
- s(P), u ? (a = !0, i == null || i()) : n = requestAnimationFrame(f);
279
+ s(v), u ? (c = !0, i == null || i()) : a = requestAnimationFrame(y);
280
280
  };
281
- return n = requestAnimationFrame(f), () => {
282
- a = !0, n && cancelAnimationFrame(n);
281
+ return a = requestAnimationFrame(y), () => {
282
+ c = !0, a && cancelAnimationFrame(a);
283
283
  };
284
284
  }
285
285
  }
286
- class W {
286
+ class Z {
287
287
  constructor() {
288
- this.springAnimation = new j();
288
+ this.springAnimation = new Q();
289
289
  }
290
290
  // Show toast with specified animation
291
291
  async showToast(t, e, s) {
@@ -378,9 +378,9 @@ class W {
378
378
  // Spring-based show animation
379
379
  async animateSpringShow(t, e) {
380
380
  return new Promise((s) => {
381
- var r, n, a;
381
+ var r, a, c;
382
382
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important"), t.style.setProperty("-webkit-transition", "none", "important");
383
- const o = ((r = t.parentElement) == null ? void 0 : r.classList.contains("editora-toast-bottom-right")) || ((n = t.parentElement) == null ? void 0 : n.classList.contains("editora-toast-bottom-left")) || ((a = t.parentElement) == null ? void 0 : a.classList.contains("editora-toast-bottom-center")) ? 20 : -20;
383
+ const o = ((r = t.parentElement) == null ? void 0 : r.classList.contains("editora-toast-bottom-right")) || ((a = t.parentElement) == null ? void 0 : a.classList.contains("editora-toast-bottom-left")) || ((c = t.parentElement) == null ? void 0 : c.classList.contains("editora-toast-bottom-center")) ? 20 : -20;
384
384
  t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `translateY(${o}px) scale(0.95)`, "important"), t.offsetHeight, setTimeout(() => {
385
385
  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(() => {
386
386
  t.style.setProperty("transition", "none", "important"), s();
@@ -401,21 +401,21 @@ class W {
401
401
  // Bounce-based show animation
402
402
  async animateBounceShow(t, e) {
403
403
  return new Promise((s) => {
404
- var d, f, u;
404
+ var h, y, u;
405
405
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
406
- const i = ((d = t.parentElement) == null ? void 0 : d.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")), o = e.direction || (i ? "up" : "down"), r = e.intensity || "normal", n = e.duration || 800, a = r === "gentle" ? 0.05 : r === "strong" ? 0.15 : 0.1, l = o === "up" ? 30 : o === "down" ? -30 : o === "left" ? 30 : -30;
406
+ const i = ((h = t.parentElement) == null ? void 0 : h.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")), o = e.direction || (i ? "up" : "down"), r = e.intensity || "normal", a = e.duration || 800, c = r === "gentle" ? 0.05 : r === "strong" ? 0.15 : 0.1, l = o === "up" ? 30 : o === "down" ? -30 : o === "left" ? 30 : -30;
407
407
  t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
408
408
  "transform",
409
- o === "left" || o === "right" ? `translateX(${l}px) scale(${1 - a})` : `translateY(${l}px) scale(${1 - a})`,
409
+ o === "left" || o === "right" ? `translateX(${l}px) scale(${1 - c})` : `translateY(${l}px) scale(${1 - c})`,
410
410
  "important"
411
411
  ), t.offsetHeight, setTimeout(() => {
412
412
  t.style.setProperty(
413
413
  "transition",
414
- `opacity ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
414
+ `opacity ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
415
415
  "important"
416
416
  ), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) scale(1)", "important"), setTimeout(() => {
417
417
  t.style.setProperty("transition", "none", "important"), s();
418
- }, n);
418
+ }, a);
419
419
  }, 16);
420
420
  });
421
421
  }
@@ -434,13 +434,13 @@ class W {
434
434
  // Slide-based show animation
435
435
  async animateSlideShow(t, e) {
436
436
  return new Promise((s) => {
437
- var d, f, u;
437
+ var h, y, u;
438
438
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
439
- const i = ((d = t.parentElement) == null ? void 0 : d.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")), o = e.direction || (i ? "up" : "down"), r = e.distance || 100, n = e.easing || "ease-out", a = e.duration || 400, l = o === "up" ? `translateY(${r}px)` : o === "down" ? `translateY(-${r}px)` : o === "left" ? `translateX(${r}px)` : `translateX(-${r}px)`;
439
+ const i = ((h = t.parentElement) == null ? void 0 : h.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")), o = e.direction || (i ? "up" : "down"), r = e.distance || 100, a = e.easing || "ease-out", c = e.duration || 400, l = o === "up" ? `translateY(${r}px)` : o === "down" ? `translateY(-${r}px)` : o === "left" ? `translateX(${r}px)` : `translateX(-${r}px)`;
440
440
  t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", l, "important"), t.offsetHeight, setTimeout(() => {
441
- t.style.setProperty("transition", `opacity ${a}ms ${n}, transform ${a}ms ${n}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
441
+ t.style.setProperty("transition", `opacity ${c}ms ${a}, transform ${c}ms ${a}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
442
442
  t.style.setProperty("transition", "none", "important"), s();
443
- }, a);
443
+ }, c);
444
444
  }, 16);
445
445
  });
446
446
  }
@@ -448,11 +448,11 @@ class W {
448
448
  async animateSlideHide(t, e) {
449
449
  return new Promise((s) => {
450
450
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
451
- const i = e.direction || "down", o = e.distance || 100, r = e.easing || "ease-in", n = e.duration || 300, a = i === "up" ? `translateY(-${o}px)` : i === "down" ? `translateY(${o}px)` : i === "left" ? `translateX(-${o}px)` : `translateX(${o}px)`;
451
+ const i = e.direction || "down", o = e.distance || 100, r = e.easing || "ease-in", a = e.duration || 300, c = i === "up" ? `translateY(-${o}px)` : i === "down" ? `translateY(${o}px)` : i === "left" ? `translateX(-${o}px)` : `translateX(${o}px)`;
452
452
  setTimeout(() => {
453
- t.style.setProperty("transition", `opacity ${n}ms ${r}, transform ${n}ms ${r}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", a, "important"), setTimeout(() => {
453
+ t.style.setProperty("transition", `opacity ${a}ms ${r}, transform ${a}ms ${r}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", c, "important"), setTimeout(() => {
454
454
  t.style.setProperty("transition", "none", "important"), s();
455
- }, n);
455
+ }, a);
456
456
  }, 16);
457
457
  });
458
458
  }
@@ -460,11 +460,11 @@ class W {
460
460
  async animateZoomShow(t, e) {
461
461
  return new Promise((s) => {
462
462
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
463
- const i = e.scale || 0.3, o = e.origin || "center", r = e.easing || "ease-out", n = e.duration || 500;
463
+ const i = e.scale || 0.3, o = e.origin || "center", r = e.easing || "ease-out", a = e.duration || 500;
464
464
  t.style.setProperty("transform-origin", o, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${i})`, "important"), t.offsetHeight, setTimeout(() => {
465
- t.style.setProperty("transition", `opacity ${n}ms ${r}, transform ${n}ms ${r}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "scale(1)", "important"), setTimeout(() => {
465
+ t.style.setProperty("transition", `opacity ${a}ms ${r}, transform ${a}ms ${r}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "scale(1)", "important"), setTimeout(() => {
466
466
  t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
467
- }, n);
467
+ }, a);
468
468
  }, 16);
469
469
  });
470
470
  }
@@ -472,11 +472,11 @@ class W {
472
472
  async animateZoomHide(t, e) {
473
473
  return new Promise((s) => {
474
474
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
475
- const i = e.scale || 0.3, o = e.origin || "center", r = e.easing || "ease-in", n = e.duration || 300;
475
+ const i = e.scale || 0.3, o = e.origin || "center", r = e.easing || "ease-in", a = e.duration || 300;
476
476
  t.style.setProperty("transform-origin", o, "important"), setTimeout(() => {
477
- t.style.setProperty("transition", `opacity ${n}ms ${r}, transform ${n}ms ${r}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${i})`, "important"), setTimeout(() => {
477
+ t.style.setProperty("transition", `opacity ${a}ms ${r}, transform ${a}ms ${r}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${i})`, "important"), setTimeout(() => {
478
478
  t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
479
- }, n);
479
+ }, a);
480
480
  }, 16);
481
481
  });
482
482
  }
@@ -484,13 +484,13 @@ class W {
484
484
  async animateFlipShow(t, e) {
485
485
  return new Promise((s) => {
486
486
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
487
- const i = e.axis || "y", o = e.perspective || 1e3, r = e.direction || "forward", n = e.duration || 600;
487
+ const i = e.axis || "y", o = e.perspective || 1e3, r = e.direction || "forward", a = e.duration || 600;
488
488
  t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${o}px`, "important");
489
- const a = r === "forward" ? i === "x" ? -90 : 90 : i === "x" ? 90 : -90;
490
- t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${a}deg)`, "important"), t.offsetHeight, setTimeout(() => {
491
- t.style.setProperty("transition", `opacity ${n}ms ease, transform ${n}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(() => {
489
+ const c = r === "forward" ? i === "x" ? -90 : 90 : i === "x" ? 90 : -90;
490
+ t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${c}deg)`, "important"), t.offsetHeight, setTimeout(() => {
491
+ t.style.setProperty("transition", `opacity ${a}ms ease, transform ${a}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(() => {
492
492
  t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"), s();
493
- }, n);
493
+ }, a);
494
494
  }, 16);
495
495
  });
496
496
  }
@@ -498,13 +498,13 @@ class W {
498
498
  async animateFlipHide(t, e) {
499
499
  return new Promise((s) => {
500
500
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
501
- const i = e.axis || "y", o = e.perspective || 1e3, r = e.direction || "backward", n = e.duration || 400;
501
+ const i = e.axis || "y", o = e.perspective || 1e3, r = e.direction || "backward", a = e.duration || 400;
502
502
  t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${o}px`, "important");
503
- const a = r === "backward" ? i === "x" ? -90 : 90 : i === "x" ? 90 : -90;
503
+ const c = r === "backward" ? i === "x" ? -90 : 90 : i === "x" ? 90 : -90;
504
504
  setTimeout(() => {
505
- t.style.setProperty("transition", `opacity ${n}ms ease, transform ${n}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${a}deg)`, "important"), setTimeout(() => {
505
+ t.style.setProperty("transition", `opacity ${a}ms ease, transform ${a}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${i.toUpperCase()}(${c}deg)`, "important"), setTimeout(() => {
506
506
  t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"), s();
507
- }, n);
507
+ }, a);
508
508
  }, 16);
509
509
  });
510
510
  }
@@ -513,8 +513,8 @@ class W {
513
513
  return new Promise((s) => {
514
514
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
515
515
  const i = e.direction || "none", o = e.distance || 20, r = e.duration || 300;
516
- let n = "translateY(0) translateX(0)";
517
- i !== "none" && (n = i === "up" ? `translateY(${o}px)` : i === "down" ? `translateY(-${o}px)` : i === "left" ? `translateX(${o}px)` : `translateX(-${o}px)`), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", n, "important"), t.offsetHeight, setTimeout(() => {
516
+ let a = "translateY(0) translateX(0)";
517
+ i !== "none" && (a = i === "up" ? `translateY(${o}px)` : i === "down" ? `translateY(-${o}px)` : i === "left" ? `translateX(${o}px)` : `translateX(-${o}px)`), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", a, "important"), t.offsetHeight, setTimeout(() => {
518
518
  t.style.setProperty("transition", `opacity ${r}ms ease, transform ${r}ms ease`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
519
519
  t.style.setProperty("transition", "none", "important"), s();
520
520
  }, r);
@@ -526,9 +526,9 @@ class W {
526
526
  return new Promise((s) => {
527
527
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
528
528
  const i = e.direction || "none", o = e.distance || 20, r = e.duration || 200;
529
- let n = "translateY(0) translateX(0)";
530
- i !== "none" && (n = i === "up" ? `translateY(-${o}px)` : i === "down" ? `translateY(${o}px)` : i === "left" ? `translateX(-${o}px)` : `translateX(${o}px)`), setTimeout(() => {
531
- t.style.setProperty("transition", `opacity ${r}ms ease, transform ${r}ms ease`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", n, "important"), setTimeout(() => {
529
+ let a = "translateY(0) translateX(0)";
530
+ i !== "none" && (a = i === "up" ? `translateY(-${o}px)` : i === "down" ? `translateY(${o}px)` : i === "left" ? `translateX(-${o}px)` : `translateX(${o}px)`), setTimeout(() => {
531
+ t.style.setProperty("transition", `opacity ${r}ms ease, transform ${r}ms ease`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", a, "important"), setTimeout(() => {
532
532
  t.style.setProperty("transition", "none", "important"), s();
533
533
  }, r);
534
534
  }, 16);
@@ -537,21 +537,21 @@ class W {
537
537
  // Elastic-based show animation
538
538
  async animateElasticShow(t, e) {
539
539
  return new Promise((s) => {
540
- var d, f, u;
540
+ var h, y, u;
541
541
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
542
- const i = ((d = t.parentElement) == null ? void 0 : d.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")), o = e.direction || (i ? "up" : "down"), r = e.intensity || "normal", n = e.duration || 1e3, a = r === "gentle" ? 0.1 : r === "strong" ? 0.3 : 0.2, l = o === "up" ? 40 : o === "down" ? -40 : o === "left" ? 40 : -40;
542
+ const i = ((h = t.parentElement) == null ? void 0 : h.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")), o = e.direction || (i ? "up" : "down"), r = e.intensity || "normal", a = e.duration || 1e3, c = r === "gentle" ? 0.1 : r === "strong" ? 0.3 : 0.2, l = o === "up" ? 40 : o === "down" ? -40 : o === "left" ? 40 : -40;
543
543
  t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
544
544
  "transform",
545
- o === "left" || o === "right" ? `translateX(${l}px) scale(${1 + a})` : `translateY(${l}px) scale(${1 + a})`,
545
+ o === "left" || o === "right" ? `translateX(${l}px) scale(${1 + c})` : `translateY(${l}px) scale(${1 + c})`,
546
546
  "important"
547
547
  ), t.offsetHeight, setTimeout(() => {
548
548
  t.style.setProperty(
549
549
  "transition",
550
- `opacity ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${n}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
550
+ `opacity ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${a}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
551
551
  "important"
552
552
  ), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) scale(1)", "important"), setTimeout(() => {
553
553
  t.style.setProperty("transition", "none", "important"), s();
554
- }, n);
554
+ }, a);
555
555
  }, 16);
556
556
  });
557
557
  }
@@ -571,11 +571,11 @@ class W {
571
571
  async animateRotateShow(t, e) {
572
572
  return new Promise((s) => {
573
573
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
574
- const i = e.degrees || 360, o = e.direction || "clockwise", r = e.origin || "center", n = e.duration || 500, a = o === "clockwise" ? i : -i;
575
- t.style.setProperty("transform-origin", r, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${a}deg) scale(0.8)`, "important"), t.offsetHeight, setTimeout(() => {
576
- t.style.setProperty("transition", `opacity ${n}ms ease, transform ${n}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(() => {
574
+ const i = e.degrees || 360, o = e.direction || "clockwise", r = e.origin || "center", a = e.duration || 500, c = o === "clockwise" ? i : -i;
575
+ t.style.setProperty("transform-origin", r, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${c}deg) scale(0.8)`, "important"), t.offsetHeight, setTimeout(() => {
576
+ t.style.setProperty("transition", `opacity ${a}ms ease, transform ${a}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(() => {
577
577
  t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
578
- }, n);
578
+ }, a);
579
579
  }, 16);
580
580
  });
581
581
  }
@@ -583,23 +583,92 @@ class W {
583
583
  async animateRotateHide(t, e) {
584
584
  return new Promise((s) => {
585
585
  t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
586
- const i = e.degrees || 180, o = e.direction || "counterclockwise", r = e.origin || "center", n = e.duration || 300, a = o === "clockwise" ? i : -i;
586
+ const i = e.degrees || 180, o = e.direction || "counterclockwise", r = e.origin || "center", a = e.duration || 300, c = o === "clockwise" ? i : -i;
587
587
  t.style.setProperty("transform-origin", r, "important"), setTimeout(() => {
588
- t.style.setProperty("transition", `opacity ${n}ms ease, transform ${n}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${a}deg) scale(0.8)`, "important"), setTimeout(() => {
588
+ t.style.setProperty("transition", `opacity ${a}ms ease, transform ${a}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${c}deg) scale(0.8)`, "important"), setTimeout(() => {
589
589
  t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), s();
590
- }, n);
590
+ }, a);
591
591
  }, 16);
592
592
  });
593
593
  }
594
594
  }
595
- const L = new W();
596
- class G {
595
+ const H = new Z(), F = "http://www.w3.org/2000/svg", J = {
596
+ success: [
597
+ ["circle", { cx: "10", cy: "10", r: "8" }],
598
+ ["path", { d: "M6.6 10.3l2.3 2.3 4.5-4.9" }]
599
+ ],
600
+ error: [
601
+ ["circle", { cx: "10", cy: "10", r: "8" }],
602
+ ["path", { d: "M7.6 7.6l4.8 4.8M12.4 7.6l-4.8 4.8" }]
603
+ ],
604
+ warning: [
605
+ ["path", { d: "M10 2.9L18 16.4H2L10 2.9z" }],
606
+ ["path", { d: "M10 8.3v3.4M10 13.9v.1" }]
607
+ ],
608
+ info: [
609
+ ["circle", { cx: "10", cy: "10", r: "8" }],
610
+ ["path", { d: "M10 9.2v4.4M10 6.5v.1" }]
611
+ ],
612
+ loading: [["path", { d: "M10 2a8 8 0 1 0 8 8" }]]
613
+ }, tt = {
614
+ success: "success",
615
+ error: "error",
616
+ warning: "warning",
617
+ info: "info",
618
+ loading: "loading",
619
+ promise: "loading"
620
+ };
621
+ function I(n, t) {
622
+ const e = document.createElementNS(F, "svg");
623
+ return e.setAttribute("viewBox", "0 0 20 20"), e.setAttribute("width", String(t)), e.setAttribute("height", String(t)), e.setAttribute("fill", "none"), e.setAttribute("stroke", "currentColor"), e.setAttribute("stroke-width", "1.7"), e.setAttribute("stroke-linecap", "round"), e.setAttribute("stroke-linejoin", "round"), e.setAttribute("focusable", "false"), e.setAttribute("aria-hidden", "true"), n.forEach(([s, i]) => {
624
+ const o = document.createElementNS(F, s);
625
+ Object.keys(i).forEach((r) => o.setAttribute(r, i[r])), e.appendChild(o);
626
+ }), e;
627
+ }
628
+ function et(n) {
629
+ const t = J[tt[n] || ""];
630
+ return t ? I(t, 18) : null;
631
+ }
632
+ function st() {
633
+ const n = I([["path", { d: "M5.5 5.5l9 9M14.5 5.5l-9 9" }]], 14);
634
+ return n.setAttribute("stroke-width", "1.8"), n;
635
+ }
636
+ const B = 12, it = 0.05, O = 3, L = /* @__PURE__ */ new WeakMap();
637
+ function ot(n) {
638
+ const t = n.style.height;
639
+ n.style.height = "auto";
640
+ const e = n.offsetHeight;
641
+ return n.style.height = t, L.set(n, e), e;
642
+ }
643
+ function rt(n) {
644
+ L.delete(n);
645
+ }
646
+ function nt(n, t) {
647
+ return !t.stack || t.expand || n.dataset.open === "true";
648
+ }
649
+ function at(n, t, e = !1) {
650
+ const i = n.dataset.edge === "bottom" ? -1 : 1, o = Array.from(n.querySelectorAll(".editora-toast")), r = o.filter((d) => !d.classList.contains("hiding") && d.dataset.leaving !== "true"), a = r.slice().reverse(), c = nt(n, t);
651
+ a.forEach((d) => {
652
+ (e || !L.has(d)) && ot(d);
653
+ });
654
+ const l = a.map((d) => L.get(d) || 0), h = l[0] || 0;
655
+ let y = 0;
656
+ a.forEach((d, m) => {
657
+ const T = l[m], f = c ? 1 : Math.max(1 - m * it, 0.8), w = c ? T : h, g = c ? y : m * B + h * (1 - f);
658
+ d.style.setProperty("--et-y", `${i * g}px`), d.style.setProperty("--et-s", String(f)), d.style.setProperty("--et-index", String(m)), d.style.height = `${w}px`, d.style.zIndex = String(a.length - m), d.dataset.index = String(m), d.dataset.front = String(m === 0), d.dataset.collapsed = String(!c && m > 0), d.dataset.hidden = String(!c && m >= O), y += T + t.gap;
659
+ }), o.forEach((d) => {
660
+ r.includes(d) || (d.dataset.front = "false");
661
+ });
662
+ const u = a.length, v = c ? l.reduce((d, m) => d + m, 0) + Math.max(u - 1, 0) * t.gap : h + (Math.min(u, O) - 1 > 0 ? (Math.min(u, O) - 1) * B : 0);
663
+ n.style.height = u > 0 ? `${v}px` : "0px", n.dataset.count = String(u), n.dataset.expanded = String(c);
664
+ }
665
+ class ct {
597
666
  constructor(t) {
598
- this.containers = /* @__PURE__ */ new Map(), this.cssInjected = !1, this.config = t;
667
+ this.containers = /* @__PURE__ */ new Map(), this.cssInjected = !1, this.toastOf = /* @__PURE__ */ new WeakMap(), this.holds = /* @__PURE__ */ new Map(), this.timing = /* @__PURE__ */ new Map(), this.returnFocusTo = null, this.globalListeners = [], this.config = t;
599
668
  }
600
669
  updateConfig(t) {
601
670
  this.config = t, this.containers.forEach((e, s) => {
602
- this.applyContainerStyles(e, s), this.applyStackState(e);
671
+ this.applyContainerStyles(e, s), this.layout(e, !0);
603
672
  });
604
673
  }
605
674
  // Ensure container exists for position
@@ -607,135 +676,219 @@ class G {
607
676
  if (this.containers.has(t))
608
677
  return this.containers.get(t);
609
678
  const e = document.createElement("div");
610
- return e.className = `editora-toast-container editora-toast-${t.replace("-", "-")}`, e.setAttribute("role", "region"), e.setAttribute("aria-label", "Toast notifications"), e.setAttribute("aria-live", "polite"), e.dataset.expand = String(this.config.expand), e.dataset.stack = String(this.config.stack), this.applyContainerStyles(e, t), document.body.appendChild(e), this.containers.set(t, e), this.injectCSS(), e;
679
+ return e.className = `editora-toast-container editora-toast-${t.replace("-", "-")}`, e.setAttribute("role", "region"), e.setAttribute("aria-label", "Toast notifications"), e.setAttribute("aria-live", "polite"), e.dataset.expand = String(this.config.expand), e.dataset.stack = String(this.config.stack), this.applyContainerStyles(e, t), this.attachContainerListeners(e), document.body.appendChild(e), this.containers.set(t, e), this.attachGlobalListeners(), this.injectCSS(), e;
680
+ }
681
+ // Hovering or focusing the stack opens it and holds the timers; leaving closes it and lets them run on.
682
+ attachContainerListeners(t) {
683
+ t.addEventListener("mouseenter", () => {
684
+ t.dataset.hover = "true", this.holdAll(t, "pointer"), this.syncOpen(t);
685
+ }), t.addEventListener("pointerdown", (e) => {
686
+ e.pointerType !== "touch" || t.dataset.hover === "true" || (t.dataset.hover = "true", this.holdAll(t, "pointer"), this.syncOpen(t));
687
+ }), t.addEventListener("mouseleave", () => {
688
+ delete t.dataset.hover, this.releaseAll(t, "pointer"), this.syncOpen(t);
689
+ }), t.addEventListener("focusin", (e) => {
690
+ this.isKeyboardFocus(e.target) && (t.dataset.focus = "true", this.holdAll(t, "focus"), this.syncOpen(t));
691
+ }), t.addEventListener("focusout", (e) => {
692
+ const s = e.relatedTarget;
693
+ s && t.contains(s) || (delete t.dataset.focus, this.releaseAll(t, "focus"), this.syncOpen(t));
694
+ }), t.addEventListener("keydown", (e) => this.onContainerKey(t, e));
695
+ }
696
+ syncOpen(t) {
697
+ const e = t.dataset.hover === "true" || t.dataset.focus === "true";
698
+ t.dataset.open = String(e), this.layout(t);
699
+ }
700
+ isKeyboardFocus(t) {
701
+ if (!(t instanceof Element)) return !1;
702
+ try {
703
+ return t.matches(":focus-visible");
704
+ } catch (e) {
705
+ return !0;
706
+ }
707
+ }
708
+ onContainerKey(t, e) {
709
+ if (e.key !== "Escape") return;
710
+ const s = e.target instanceof Element ? e.target.closest(".editora-toast") : null, i = s ? this.toastOf.get(s) : void 0;
711
+ if (!s || !i) return;
712
+ e.preventDefault();
713
+ const o = Array.from(t.querySelectorAll(".editora-toast:not(.hiding)")), r = o[o.indexOf(s) + 1] || o[o.indexOf(s) - 1];
714
+ i.dismiss(), r && r !== s ? r.focus() : this.restoreFocus();
715
+ }
716
+ restoreFocus() {
717
+ const t = this.returnFocusTo;
718
+ this.returnFocusTo = null, t && t.isConnected && t.focus();
719
+ }
720
+ // Document level behaviour: the hotkey that jumps to the toasts, a tap outside that closes an open stack, and
721
+ // a resize that can change how much the text of a toast wraps.
722
+ attachGlobalListeners() {
723
+ if (this.globalListeners.length > 0 || typeof window == "undefined") return;
724
+ const t = (e, s, i) => {
725
+ e.addEventListener(s, i), this.globalListeners.push([e, s, i]);
726
+ };
727
+ t(document, "keydown", ((e) => {
728
+ if (!this.matchesHotkey(e)) return;
729
+ const s = Array.from(this.containers.values()).find((r) => r.querySelector(".editora-toast:not(.hiding)"));
730
+ if (!s) return;
731
+ const i = s.querySelector('.editora-toast[data-front="true"]');
732
+ if (!i) return;
733
+ e.preventDefault();
734
+ const o = document.activeElement;
735
+ o instanceof HTMLElement && !s.contains(o) && (this.returnFocusTo = o), i.focus();
736
+ })), t(document, "pointerdown", ((e) => {
737
+ this.containers.forEach((s) => {
738
+ s.dataset.hover === "true" && !s.contains(e.target) && (delete s.dataset.hover, this.releaseAll(s, "pointer"), this.syncOpen(s));
739
+ });
740
+ })), t(window, "resize", (() => {
741
+ window.clearTimeout(this.resizeTimer), this.resizeTimer = window.setTimeout(() => this.containers.forEach((e) => this.layout(e, !0)), 120);
742
+ }));
743
+ }
744
+ matchesHotkey(t) {
745
+ const e = this.config.hotkey;
746
+ if (!e) return !1;
747
+ const s = e.toLowerCase().split("+").map((r) => r.trim()).filter(Boolean), i = s.pop();
748
+ if (!i) return !1;
749
+ const o = (r) => s.includes(r);
750
+ return t.altKey !== o("alt") || t.shiftKey !== o("shift") || t.ctrlKey !== o("ctrl") || t.metaKey !== (o("meta") || o("cmd")) ? !1 : t.code.toLowerCase() === `key${i}` || t.code.toLowerCase() === i || t.key.toLowerCase() === i;
751
+ }
752
+ layout(t, e = !1) {
753
+ at(t, { stack: this.config.stack, expand: this.config.expand, gap: this.toPx(this.config.gap) }, e);
754
+ }
755
+ toPx(t) {
756
+ if (typeof t == "number") return t;
757
+ const e = parseFloat(t || "");
758
+ return Number.isFinite(e) ? e : 8;
759
+ }
760
+ // Timer holds
761
+ holdAll(t, e) {
762
+ t.querySelectorAll(".editora-toast").forEach((s) => {
763
+ const i = this.toastOf.get(s);
764
+ if (!i) return;
765
+ (e === "focus" ? i.options.pauseOnFocus : i.options.pauseOnHover) !== !1 && this.pauseToast(i, e);
766
+ });
767
+ }
768
+ releaseAll(t, e) {
769
+ t.querySelectorAll(".editora-toast").forEach((s) => {
770
+ const i = this.toastOf.get(s);
771
+ i && this.resumeToast(i, e);
772
+ });
611
773
  }
612
774
  // Create toast element
613
775
  createToastElement(t) {
614
776
  const e = t.options, s = document.createElement("div");
615
- s.className = `editora-toast editora-toast-${e.level || "info"}`, s.dataset.level = e.level || "info", e.customClass && e.customClass.split(/\s+/).filter(Boolean).forEach((n) => s.classList.add(n)), s.setAttribute("role", e.role || (e.level === "error" ? "alert" : "status")), s.setAttribute("aria-atomic", "true"), e.ariaLive && e.ariaLive !== "off" && s.setAttribute("aria-live", e.ariaLive);
777
+ s.className = `editora-toast editora-toast-${e.level || "info"}`, s.dataset.level = e.level || "info", e.customClass && e.customClass.split(/\s+/).filter(Boolean).forEach((a) => s.classList.add(a)), s.setAttribute("role", e.role || (e.level === "error" ? "alert" : "status")), s.setAttribute("aria-atomic", "true"), s.tabIndex = 0, (e.closable || e.closeButton) && (s.dataset.closable = "true"), this.toastOf.set(s, t), e.ariaLive && e.ariaLive !== "off" && s.setAttribute("aria-live", e.ariaLive);
616
778
  const i = e.theme || this.config.theme;
617
779
  i && i !== "system" && s.setAttribute("data-theme", i), (this.config.richColors || i === "colored") && s.setAttribute("data-rich-colors", "true"), (e.rtl !== void 0 ? e.rtl : this.config.rtl) && (s.setAttribute("data-rtl", "true"), s.setAttribute("dir", "rtl"));
618
780
  const r = this.createContent(t);
619
- if (e.progress) {
620
- const n = document.createElement("div");
621
- n.className = "editora-toast-progress-track", n.setAttribute("role", "progressbar"), n.setAttribute("aria-valuemin", "0"), n.setAttribute("aria-valuemax", "100"), n.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, e.progress.value))));
622
- const a = document.createElement("div");
623
- if (a.className = "editora-toast-progress-bar", a.style.width = `${Math.min(100, Math.max(0, e.progress.value))}%`, e.progress.showPercentage) {
624
- const l = document.createElement("span");
625
- l.className = "editora-toast-progress-text", l.textContent = `${Math.round(e.progress.value)}%`, n.appendChild(l);
626
- }
627
- n.appendChild(a), r.appendChild(n);
628
- }
629
781
  if (s.appendChild(r), e.actions && e.actions.length > 0) {
630
- const n = document.createElement("div");
631
- n.className = "editora-toast-actions", e.actions.forEach((a) => n.appendChild(this.createActionButton(a, t))), s.appendChild(n);
782
+ const a = document.createElement("div");
783
+ a.className = "editora-toast-actions", e.actions.forEach((c) => a.appendChild(this.createActionButton(c, t))), s.appendChild(a);
632
784
  }
633
- return (e.closable || e.closeButton) && s.appendChild(this.createCloseButton(t)), 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;
785
+ return (e.closable || e.closeButton) && s.appendChild(this.createCloseButton(t)), e.swipeDismiss && this.addSwipeDismiss(s, t), e.dragDismiss && this.addDragDismiss(s, t), s;
634
786
  }
635
787
  // Show toast with animation
636
788
  async showToast(t) {
637
789
  var o, r;
638
790
  const e = this.ensureContainer(t.options.position || this.config.position), s = this.createToastElement(t);
639
- t.element = s, e.appendChild(s), this.applyStackState(e);
791
+ t.element = s, e.appendChild(s), e.dataset.hover === "true" && t.options.pauseOnHover !== !1 && this.pauseToast(t, "pointer"), e.dataset.focus === "true" && t.options.pauseOnFocus !== !1 && this.pauseToast(t, "focus"), this.layout(e);
640
792
  const i = t.options.animation || this.config.animation || { type: "css" };
641
- if (await L.showToast(s, t, i), this.config.enableAccessibility && this.announceToast(t), (r = (o = t.options).onShow) == null || r.call(o), !t.options.persistent && t.options.duration !== 0) {
642
- const n = t.options.duration || this.config.duration;
643
- t.timeoutId = window.setTimeout(() => {
644
- t.dismiss();
645
- }, n);
646
- }
793
+ await H.showToast(s, t, i), this.config.enableAccessibility && this.announceToast(t), (r = (o = t.options).onShow) == null || r.call(o), this.startTimer(t);
647
794
  }
648
795
  // Hide toast with animation
649
796
  async hideToast(t) {
650
- var s, i;
797
+ var i, o;
651
798
  if (!t.element) return;
652
- t.timeoutId && (clearTimeout(t.timeoutId), t.timeoutId = void 0);
653
- const e = t.options.animation || this.config.animation || { type: "css" };
654
- if (await L.hideToast(t.element, t, e), t.element && t.element.parentNode) {
655
- const o = t.element.parentElement;
656
- t.element.parentNode.removeChild(t.element), t.element = void 0, o && this.applyStackState(o);
799
+ this.stopTimer(t), this.holds.delete(t.id);
800
+ const e = t.element;
801
+ e.dataset.leaving = "true", e.parentElement && this.layout(e.parentElement);
802
+ const s = t.options.animation || this.config.animation || { type: "css" };
803
+ if (await H.hideToast(e, t, s), t.element && t.element.parentNode) {
804
+ const r = t.element.parentElement;
805
+ t.element.parentNode.removeChild(t.element), t.element = void 0, r && (r.querySelector(".editora-toast") || (delete r.dataset.hover, delete r.dataset.focus, r.dataset.open = "false"), this.layout(r));
657
806
  }
658
- (i = (s = t.options).onHide) == null || i.call(s);
807
+ (o = (i = t.options).onHide) == null || o.call(i);
659
808
  }
660
809
  // Update toast content
661
810
  async updateToast(t, e) {
662
- var o, r, n;
811
+ var o, r, a;
663
812
  if (!t.element) return;
664
813
  const s = t.options.animation || this.config.animation || { type: "css" };
665
814
  if (s.type === "custom" && s.update) {
666
- await L.updateToast(t.element, t, e, s);
815
+ await H.updateToast(t.element, t, e, s);
667
816
  return;
668
817
  }
669
- if (Object.assign(t.options, e), e.level && (t.element.className = t.element.className.replace(/editora-toast-(info|success|error|warning|loading|progress|promise|custom)/g, ""), t.element.classList.add(`editora-toast-${e.level}`), t.element.dataset.level = e.level), e.title !== void 0 || e.description !== void 0 || e.message !== void 0 || e.icon !== void 0 || e.render) {
670
- const a = t.element.querySelector(".editora-toast-content"), l = this.createContent(t);
671
- a == null || a.replaceWith(l);
818
+ if (Object.assign(t.options, e), e.level && (t.element.className = t.element.className.replace(/editora-toast-(info|success|error|warning|loading|progress|promise|custom)/g, ""), t.element.classList.add(`editora-toast-${e.level}`), t.element.dataset.level = e.level), e.title !== void 0 || e.description !== void 0 || e.message !== void 0 || e.icon !== void 0 || e.level !== void 0 || e.render) {
819
+ const c = t.element.querySelector(".editora-toast-content"), l = this.createContent(t);
820
+ c == null || c.replaceWith(l);
672
821
  }
673
822
  const i = (o = e.closeButton) != null ? o : e.closable;
674
823
  if (i !== void 0) {
675
- t.options.closable = i, t.options.closeButton = i;
676
- const a = t.element.querySelector(".editora-toast-close");
677
- i && !a ? t.element.appendChild(this.createCloseButton(t)) : !i && a && a.remove();
824
+ t.options.closable = i, t.options.closeButton = i, i ? t.element.dataset.closable = "true" : delete t.element.dataset.closable;
825
+ const c = t.element.querySelector(".editora-toast-close");
826
+ i && !c ? t.element.appendChild(this.createCloseButton(t)) : !i && c && c.remove();
678
827
  }
679
828
  if (e.progress !== void 0) {
680
- let a = t.element.querySelector(".editora-toast-progress-track");
681
- if (e.progress) {
682
- if (!a) {
683
- a = document.createElement("div"), a.className = "editora-toast-progress-track", a.setAttribute("role", "progressbar"), a.setAttribute("aria-valuemin", "0"), a.setAttribute("aria-valuemax", "100");
684
- const d = t.element.querySelector(".editora-toast-content");
685
- d && d.appendChild(a);
686
- }
687
- a.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, e.progress.value))));
688
- const l = a.querySelector(".editora-toast-progress-bar");
689
- if (l && (l.style.width = `${Math.min(100, Math.max(0, e.progress.value))}%`), e.progress.showPercentage) {
690
- let d = a.querySelector(".editora-toast-progress-text");
691
- d || (d = document.createElement("span"), d.className = "editora-toast-progress-text", a.insertBefore(d, a.firstChild)), d.textContent = `${Math.round(e.progress.value)}%`;
692
- } else {
693
- const d = a.querySelector(".editora-toast-progress-text");
694
- d && d.remove();
695
- }
696
- } else a && a.remove();
829
+ const c = t.element.querySelector(".editora-toast-body"), l = t.element.querySelector(".editora-toast-progress-track");
830
+ if (e.progress && c) {
831
+ const h = this.createProgress(e.progress);
832
+ l ? l.replaceWith(h) : c.appendChild(h);
833
+ } else l && l.remove();
697
834
  }
698
835
  if (e.actions !== void 0 || e.action !== void 0 || e.cancel !== void 0) {
699
- let a = t.element.querySelector(".editora-toast-actions");
836
+ let c = t.element.querySelector(".editora-toast-actions");
700
837
  const l = t.options.actions || [];
701
- l.length > 0 ? (a ? a.innerHTML = "" : (a = document.createElement("div"), a.className = "editora-toast-actions", t.element.appendChild(a)), a && l.forEach((d) => a.appendChild(this.createActionButton(d, t)))) : a && a.remove();
702
- }
703
- if ((e.duration !== void 0 || e.persistent !== void 0 || e.level !== void 0) && (t.timeoutId && (clearTimeout(t.timeoutId), t.timeoutId = void 0), !t.options.persistent && t.options.duration !== 0)) {
704
- const a = t.options.duration || this.config.duration;
705
- t.timeoutId = window.setTimeout(() => {
706
- t.dismiss();
707
- }, a);
838
+ l.length > 0 ? (c ? c.innerHTML = "" : (c = document.createElement("div"), c.className = "editora-toast-actions", t.element.appendChild(c)), c && l.forEach((h) => c.appendChild(this.createActionButton(h, t)))) : c && c.remove();
708
839
  }
709
- (n = (r = t.options).onUpdate) == null || n.call(r, e);
840
+ (e.duration !== void 0 || e.persistent !== void 0 || e.level !== void 0) && this.startTimer(t), t.element.style.height = "", rt(t.element), t.element.parentElement && this.layout(t.element.parentElement), (a = (r = t.options).onUpdate) == null || a.call(r, e);
710
841
  }
711
842
  createContent(t) {
712
843
  const e = t.options, s = document.createElement("div");
713
- if (s.className = "editora-toast-content", e.icon) {
714
- const o = document.createElement("span");
715
- o.className = "editora-toast-icon", o.setAttribute("aria-hidden", "true"), o.textContent = e.icon, s.appendChild(o);
716
- }
717
- const i = document.createElement("div");
718
- if (i.className = "editora-toast-body", e.render)
719
- i.appendChild(e.render(t));
844
+ s.className = "editora-toast-content";
845
+ const i = this.createIcon(t);
846
+ i && s.appendChild(i);
847
+ const o = document.createElement("div");
848
+ if (o.className = "editora-toast-body", e.render)
849
+ o.appendChild(e.render(t));
720
850
  else {
721
851
  if (e.title) {
722
- const o = document.createElement("div");
723
- o.className = "editora-toast-title", o.textContent = e.title, i.appendChild(o);
852
+ const r = document.createElement("div");
853
+ r.className = "editora-toast-title", r.textContent = e.title, o.appendChild(r);
724
854
  }
725
855
  if (e.message) {
726
- const o = document.createElement("div");
727
- o.className = "editora-toast-message", e.html ? X(o, e.message) : o.textContent = e.message, i.appendChild(o);
856
+ const r = document.createElement("div");
857
+ r.className = "editora-toast-message", e.html ? U(r, e.message) : r.textContent = e.message, o.appendChild(r);
728
858
  }
729
859
  if (e.description) {
730
- const o = document.createElement("div");
731
- o.className = "editora-toast-description", o.textContent = e.description, i.appendChild(o);
860
+ const r = document.createElement("div");
861
+ r.className = "editora-toast-description", r.textContent = e.description, o.appendChild(r);
732
862
  }
733
863
  }
864
+ return e.progress && o.appendChild(this.createProgress(e.progress)), s.appendChild(o), s;
865
+ }
866
+ createProgress(t) {
867
+ const e = Math.min(100, Math.max(0, t.value)), s = document.createElement("div");
868
+ s.className = "editora-toast-progress-track", s.setAttribute("role", "progressbar"), s.setAttribute("aria-valuemin", "0"), s.setAttribute("aria-valuemax", "100"), s.setAttribute("aria-valuenow", String(e));
869
+ const i = document.createElement("div");
870
+ if (i.className = "editora-toast-progress-bar", i.style.width = `${e}%`, t.showPercentage) {
871
+ const o = document.createElement("span");
872
+ o.className = "editora-toast-progress-text", o.textContent = `${Math.round(t.value)}%`, s.appendChild(o);
873
+ }
734
874
  return s.appendChild(i), s;
735
875
  }
736
876
  createCloseButton(t) {
737
877
  const e = document.createElement("button");
738
- return e.className = "editora-toast-close", e.setAttribute("type", "button"), e.setAttribute("aria-label", "Close notification"), e.textContent = "×", e.onclick = () => t.dismiss(), e;
878
+ return e.className = "editora-toast-close", e.setAttribute("type", "button"), e.setAttribute("aria-label", "Close notification"), e.appendChild(st()), e.onclick = () => t.dismiss(), e;
879
+ }
880
+ // The icon is the caller's own (text, emoji or a node), false for none, or else the built-in one of the level.
881
+ createIcon(t) {
882
+ const e = t.options;
883
+ if (e.icon === !1) return null;
884
+ const s = document.createElement("span");
885
+ if (s.className = "editora-toast-icon", s.setAttribute("aria-hidden", "true"), typeof e.icon == "string" && e.icon)
886
+ return s.textContent = e.icon, s;
887
+ if (e.icon && typeof e.icon == "object")
888
+ return s.appendChild(e.icon), s;
889
+ if (this.config.icons === !1) return null;
890
+ const i = e.level || "info", o = et(i);
891
+ return o ? ((i === "loading" || i === "promise") && (s.dataset.spin = "true"), s.appendChild(o), s) : null;
739
892
  }
740
893
  createActionButton(t, e) {
741
894
  const s = document.createElement("button");
@@ -745,22 +898,19 @@ class G {
745
898
  }
746
899
  applyContainerStyles(t, e) {
747
900
  const s = this.toCssLength(this.config.offset), i = this.toCssLength(this.config.mobileOffset), o = this.toCssLength(this.config.gap);
748
- t.dataset.position = e, t.dataset.expand = String(this.config.expand), t.dataset.stack = String(this.config.stack), t.style.setProperty("--editora-toast-offset", s), t.style.setProperty("--editora-toast-mobile-offset", i), t.style.setProperty("--editora-toast-gap", o);
901
+ t.dataset.position = e, t.dataset.edge = e.startsWith("bottom") ? "bottom" : "top", t.dataset.expand = String(this.config.expand), t.dataset.stack = String(this.config.stack), t.style.setProperty("--editora-toast-offset", s), t.style.setProperty("--editora-toast-mobile-offset", i), t.style.setProperty("--editora-toast-gap", o), t.style.setProperty("--et-edge", e.startsWith("bottom") ? "1" : "-1");
749
902
  const r = {
750
903
  position: "fixed",
751
904
  zIndex: (this.config.zIndex || 2147483647).toString(),
752
- display: "flex",
753
- flexDirection: e.startsWith("top") ? "column" : "column-reverse",
754
- gap: o,
755
- pointerEvents: "none",
756
- maxWidth: "100%",
905
+ display: "block",
906
+ width: "var(--et-width, 360px)",
907
+ maxWidth: `calc(100vw - 2 * ${s})`,
757
908
  boxSizing: "border-box",
758
909
  top: "",
759
910
  right: "",
760
911
  bottom: "",
761
912
  left: "",
762
- transform: "",
763
- alignItems: e.includes("center") ? "center" : "stretch"
913
+ transform: ""
764
914
  };
765
915
  switch (e) {
766
916
  case "top-left":
@@ -782,99 +932,113 @@ class G {
782
932
  r.bottom = `max(${s}, env(safe-area-inset-bottom))`, r.right = `max(${s}, env(safe-area-inset-right))`;
783
933
  break;
784
934
  case "center":
785
- r.top = "50%", r.left = "50%", r.transform = "translate(-50%, -50%)", r.alignItems = "center";
935
+ r.top = "50%", r.left = "50%", r.transform = "translate(-50%, -50%)";
786
936
  break;
787
937
  }
788
938
  Object.assign(t.style, r), t.style.setProperty("--editora-toast-mobile-left", i);
789
939
  }
790
- applyStackState(t) {
791
- const e = Array.from(t.querySelectorAll(".editora-toast"));
792
- e.forEach((s, i) => {
793
- const o = e.length - i - 1;
794
- s.dataset.index = String(i), s.dataset.front = String(o === 0), s.style.setProperty("--editora-toast-index", String(i)), s.style.setProperty("--editora-toast-before", String(o));
795
- });
796
- }
797
940
  toCssLength(t) {
798
941
  return typeof t == "number" ? `${t}px` : t || "16px";
799
942
  }
800
- // Pause/resume auto-dismiss
801
- pauseToast(t) {
943
+ // Auto-dismiss timer. It keeps the time that is left, so pausing a toast and letting go does not give it a
944
+ // fresh full duration.
945
+ startTimer(t) {
946
+ if (this.stopTimer(t), t.options.persistent || t.options.duration === 0) {
947
+ this.timing.delete(t.id);
948
+ return;
949
+ }
950
+ this.arm(t, t.options.duration || this.config.duration);
951
+ }
952
+ arm(t, e) {
953
+ var s;
954
+ this.timing.set(t.id, { remaining: e, startedAt: Date.now() }), !((((s = this.holds.get(t.id)) == null ? void 0 : s.size) || 0) > 0) && (t.timeoutId = window.setTimeout(() => {
955
+ t.timeoutId = void 0, t.dismiss();
956
+ }, e));
957
+ }
958
+ stopTimer(t) {
802
959
  t.timeoutId && (clearTimeout(t.timeoutId), t.timeoutId = void 0);
803
960
  }
804
- resumeToast(t) {
805
- if (!t.options.persistent && t.options.duration !== 0) {
806
- const e = t.options.duration || this.config.duration;
807
- t.timeoutId = window.setTimeout(() => {
808
- t.dismiss();
809
- }, e);
961
+ pauseToast(t, e = "hover") {
962
+ const s = this.holds.get(t.id) || /* @__PURE__ */ new Set();
963
+ if (this.holds.set(t.id, s), s.size === 0 && t.timeoutId) {
964
+ const i = this.timing.get(t.id);
965
+ this.stopTimer(t), i && (i.remaining = Math.max(0, i.remaining - (Date.now() - i.startedAt)));
810
966
  }
967
+ s.add(e);
968
+ }
969
+ resumeToast(t, e = "hover") {
970
+ const s = this.holds.get(t.id);
971
+ if (!s || !s.delete(e) || s.size > 0) return;
972
+ this.holds.delete(t.id);
973
+ const i = this.timing.get(t.id);
974
+ i && !t.timeoutId && !t.options.persistent && t.options.duration !== 0 && this.arm(t, i.remaining);
811
975
  }
812
976
  // Swipe dismiss with directional control
813
977
  addSwipeDismiss(t, e) {
814
978
  let s = 0, i = 0, o = !1;
815
- const r = e.options.swipeDirection || this.config.swipeDirection || "any", n = 40;
816
- let a = "", l = !1;
817
- const d = 'button, a[href], input, select, textarea, label, summary, [role="button"], [contenteditable="true"]', f = () => {
818
- t.style.transform = a, t.style.transition = "", t.style.cursor = "", t.style.userSelect = "";
819
- }, u = (p, y) => {
820
- if ("changedTouches" in p || "touches" in p) {
821
- const m = y ? p.changedTouches : p.touches, g = m && m[0];
822
- return g ? { x: g.clientX, y: g.clientY } : null;
979
+ const r = e.options.swipeDirection || this.config.swipeDirection || "any", a = 40;
980
+ let c = "", l = !1;
981
+ const h = 'button, a[href], input, select, textarea, label, summary, [role="button"], [contenteditable="true"]', y = () => {
982
+ t.style.transform = c, t.style.transition = "", t.style.cursor = "", t.style.userSelect = "";
983
+ }, u = (f, w) => {
984
+ if ("changedTouches" in f || "touches" in f) {
985
+ const g = w ? f.changedTouches : f.touches, b = g && g[0];
986
+ return b ? { x: b.clientX, y: b.clientY } : null;
823
987
  }
824
- return { x: p.clientX, y: p.clientY };
825
- }, P = (p) => {
826
- const y = p.target;
827
- if (y instanceof Element && t.contains(y) && y.closest(d) || "button" in p && p.button !== 0) return;
828
- const m = u(p, !1);
829
- m && (o = !0, l = !1, s = m.x, i = m.y, a = t.style.transform || "");
830
- }, w = (p) => {
831
- var b, k;
988
+ return { x: f.clientX, y: f.clientY };
989
+ }, v = (f) => {
990
+ const w = f.target;
991
+ if (w instanceof Element && t.contains(w) && w.closest(h) || "button" in f && f.button !== 0) return;
992
+ const g = u(f, !1);
993
+ g && (o = !0, l = !1, s = g.x, i = g.y, c = t.style.transform || "");
994
+ }, d = (f) => {
995
+ var P, k;
832
996
  if (!o) return;
833
- const y = u(p, !1);
834
- if (!y) return;
835
- const m = y.x - s, g = y.y - i, T = 5;
836
- if (!l && (Math.abs(m) > T || Math.abs(g) > T) && (l = !0, t.style.transition = "none", t.style.cursor = "grabbing", t.style.userSelect = "none", (k = (b = window.getSelection) == null ? void 0 : b.call(window)) == null || k.removeAllRanges()), l) {
837
- const x = Math.abs(g) > Math.abs(m) ? 25 : 20, B = Math.min(Math.max(m * 0.2, -x), x), D = Math.min(Math.max(g * 0.2, -x), x);
838
- t.style.transform = `${a} translate(${B}px, ${D}px)`, p.cancelable && p.preventDefault();
997
+ const w = u(f, !1);
998
+ if (!w) return;
999
+ const g = w.x - s, b = w.y - i, x = 5;
1000
+ if (!l && (Math.abs(g) > x || Math.abs(b) > x) && (l = !0, t.style.transition = "none", t.style.cursor = "grabbing", t.style.userSelect = "none", (k = (P = window.getSelection) == null ? void 0 : P.call(window)) == null || k.removeAllRanges()), l) {
1001
+ const E = Math.abs(b) > Math.abs(g) ? 25 : 20, V = Math.min(Math.max(g * 0.2, -E), E), X = Math.min(Math.max(b * 0.2, -E), E);
1002
+ t.style.transform = `${c} translate(${V}px, ${X}px)`, f.cancelable && f.preventDefault();
839
1003
  }
840
- }, v = (p) => {
1004
+ }, m = (f) => {
841
1005
  if (!o) return;
842
1006
  o = !1;
843
- const y = l;
844
- if (f(), !y) return;
845
- const m = u(p, !0);
846
- if (!m) return;
847
- const g = m.x - s, T = m.y - i;
848
- let b = !1;
849
- const x = r === "vertical" || r === "up" || r === "down" ? 35 : n;
1007
+ const w = l;
1008
+ if (y(), !w) return;
1009
+ const g = u(f, !0);
1010
+ if (!g) return;
1011
+ const b = g.x - s, x = g.y - i;
1012
+ let P = !1;
1013
+ const E = r === "vertical" || r === "up" || r === "down" ? 35 : a;
850
1014
  switch (r) {
851
1015
  case "any":
852
- b = Math.abs(g) > n || Math.abs(T) > n;
1016
+ P = Math.abs(b) > a || Math.abs(x) > a;
853
1017
  break;
854
1018
  case "horizontal":
855
- b = Math.abs(g) > n;
1019
+ P = Math.abs(b) > a;
856
1020
  break;
857
1021
  case "vertical":
858
- b = Math.abs(T) > x;
1022
+ P = Math.abs(x) > E;
859
1023
  break;
860
1024
  case "left":
861
- b = g < -n;
1025
+ P = b < -a;
862
1026
  break;
863
1027
  case "right":
864
- b = g > n;
1028
+ P = b > a;
865
1029
  break;
866
1030
  case "up":
867
- b = T < -x;
1031
+ P = x < -E;
868
1032
  break;
869
1033
  case "down":
870
- b = T > x;
1034
+ P = x > E;
871
1035
  break;
872
1036
  }
873
- b && e.dismiss();
874
- }, S = () => {
875
- o && (o = !1, l = !1, f());
1037
+ P && e.dismiss();
1038
+ }, T = () => {
1039
+ o && (o = !1, l = !1, y());
876
1040
  };
877
- t.addEventListener("dragstart", (p) => p.preventDefault()), t.addEventListener("touchstart", P, { passive: !0 }), t.addEventListener("touchmove", w, { passive: !1 }), t.addEventListener("touchend", v), t.addEventListener("touchcancel", S), t.addEventListener("mousedown", P), t.addEventListener("mousemove", w), t.addEventListener("mouseup", v), t.addEventListener("mouseleave", v);
1041
+ t.addEventListener("dragstart", (f) => f.preventDefault()), t.addEventListener("touchstart", v, { passive: !0 }), t.addEventListener("touchmove", d, { passive: !1 }), t.addEventListener("touchend", m), t.addEventListener("touchcancel", T), t.addEventListener("mousedown", v), t.addEventListener("mousemove", d), t.addEventListener("mouseup", m), t.addEventListener("mouseleave", m);
878
1042
  }
879
1043
  // Drag dismiss (simplified)
880
1044
  addDragDismiss(t, e) {
@@ -900,18 +1064,18 @@ class G {
900
1064
  }
901
1065
  )) {
902
1066
  const e = document.createElement("style");
903
- e.setAttribute("data-editora-toast-fallback", "true"), e.textContent = ".editora-toast{box-sizing:border-box;pointer-events:auto}.editora-toast-container{box-sizing:border-box;pointer-events:none}.editora-toast.show{opacity:1;transform:translateY(0) scale(1)}.editora-toast.hiding{opacity:0}", document.head.appendChild(e);
1067
+ e.setAttribute("data-editora-toast-fallback", "true"), e.textContent = ".editora-toast-container{position:fixed;width:360px;max-width:100vw;box-sizing:border-box}.editora-toast{position:absolute;left:0;width:100%;box-sizing:border-box;padding:12px 14px;background:#fff;color:#111;border:1px solid #ddd;border-radius:12px;font:13px/1.45 system-ui,sans-serif;overflow:hidden;pointer-events:auto;opacity:0;translate:0 var(--et-y,0px);scale:var(--et-s,1);transition:opacity .2s,translate .3s,scale .3s,height .3s}.editora-toast-container[data-edge=bottom] .editora-toast{bottom:0}.editora-toast-container[data-edge=top] .editora-toast{top:0}.editora-toast.show{opacity:1}.editora-toast.hiding,.editora-toast[data-hidden=true]{opacity:0}", document.head.appendChild(e);
904
1068
  }
905
1069
  this.cssInjected = !0;
906
1070
  }
907
1071
  // Cleanup
908
1072
  destroy() {
909
- this.containers.forEach((t) => {
1073
+ this.globalListeners.forEach(([t, e, s]) => t.removeEventListener(e, s)), this.globalListeners = [], window.clearTimeout(this.resizeTimer), this.containers.forEach((t) => {
910
1074
  t.parentNode && t.parentNode.removeChild(t);
911
1075
  }), this.containers.clear();
912
1076
  }
913
1077
  }
914
- class U {
1078
+ class lt {
915
1079
  constructor() {
916
1080
  this.plugins = [], this.hooks = {
917
1081
  beforeShow: [],
@@ -1020,20 +1184,20 @@ class U {
1020
1184
  });
1021
1185
  }
1022
1186
  }
1023
- const O = {
1187
+ const D = {
1024
1188
  position: "bottom-right",
1025
1189
  duration: 4e3,
1026
1190
  maxVisible: 3,
1027
1191
  queueStrategy: "fifo",
1028
1192
  theme: "system",
1029
1193
  richColors: !1,
1030
- expand: !0,
1031
- stack: !1,
1194
+ expand: !1,
1195
+ stack: !0,
1032
1196
  offset: 16,
1033
1197
  mobileOffset: 16,
1034
1198
  gap: 8,
1035
1199
  pauseOnHover: !0,
1036
- pauseOnFocus: !1,
1200
+ pauseOnFocus: !0,
1037
1201
  pauseOnWindowBlur: !1,
1038
1202
  // Don't pause by default
1039
1203
  swipeDismiss: !0,
@@ -1044,6 +1208,8 @@ const O = {
1044
1208
  // LTR by default
1045
1209
  enableAccessibility: !0,
1046
1210
  closeButton: !1,
1211
+ icons: !0,
1212
+ hotkey: "alt+t",
1047
1213
  preventDuplicate: !1,
1048
1214
  dedupeScope: "all",
1049
1215
  animation: { type: "css" }
@@ -1051,7 +1217,7 @@ const O = {
1051
1217
  };
1052
1218
  class q {
1053
1219
  constructor(t = {}) {
1054
- this.idCounter = 0, this.pausedToasts = /* @__PURE__ */ new Set(), this.pendingShows = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Set(), this.config = this.normalizeConfig({ ...O, ...t }), this.store = new z(this.config), this.queue = new N(this.config), this.renderer = new G(this.config), this.lifecycle = new U(), this.setupWindowFocusHandling();
1220
+ this.idCounter = 0, this.pendingShows = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Set(), this.config = this.normalizeConfig({ ...D, ...t }), this.store = new j(this.config), this.queue = new W(this.config), this.renderer = new ct(this.config), this.lifecycle = new lt(), this.setupWindowFocusHandling();
1055
1221
  }
1056
1222
  // Core API
1057
1223
  show(t) {
@@ -1104,17 +1270,17 @@ class q {
1104
1270
  var i, o;
1105
1271
  const s = this.show(this.normalizeOptions(e.loading, "loading"));
1106
1272
  try {
1107
- const r = await t, n = this.normalizeOptions(
1273
+ const r = await t, a = this.normalizeResult(
1108
1274
  typeof e.success == "function" ? e.success(r) : e.success,
1109
1275
  "success"
1110
1276
  );
1111
- return n.duration === void 0 && !n.persistent && (n.duration = this.config.duration), this.update(s.id, n), (i = e.onSuccess) == null || i.call(e, r), r;
1277
+ return a.duration === void 0 && !a.persistent && (a.duration = this.config.duration), this.update(s.id, a), (i = e.onSuccess) == null || i.call(e, r), r;
1112
1278
  } catch (r) {
1113
- const n = this.normalizeOptions(
1279
+ const a = this.normalizeResult(
1114
1280
  typeof e.error == "function" ? e.error(r) : e.error,
1115
1281
  "error"
1116
1282
  );
1117
- throw n.duration === void 0 && !n.persistent && (n.duration = this.config.duration), this.update(s.id, n), (o = e.onError) == null || o.call(e, r), r;
1283
+ throw a.duration === void 0 && !a.persistent && (a.duration = this.config.duration), this.update(s.id, a), (o = e.onError) == null || o.call(e, r), r;
1118
1284
  }
1119
1285
  }
1120
1286
  // Group API
@@ -1176,8 +1342,14 @@ class q {
1176
1342
  normalizeOptions(t, e) {
1177
1343
  return typeof t == "string" ? { message: t, level: e } : { ...t, level: t.level || e };
1178
1344
  }
1345
+ // The result of a promise replaces the loading toast's text. update() merges, so a result given as options
1346
+ // without a message (a title and a description, say) would otherwise keep showing the loading message.
1347
+ normalizeResult(t, e) {
1348
+ const s = this.normalizeOptions(t, e);
1349
+ return "message" in s ? s : { ...s, message: void 0 };
1350
+ }
1179
1351
  normalizeConfig(t) {
1180
- const e = t.visibleToasts || t.maxVisible || O.maxVisible;
1352
+ const e = t.visibleToasts || t.maxVisible || D.maxVisible;
1181
1353
  return {
1182
1354
  ...t,
1183
1355
  maxVisible: e,
@@ -1189,8 +1361,8 @@ class q {
1189
1361
  // caller passed first: the merged object always carries the config's `closeButton: false`, so reading it
1190
1362
  // first made an explicit `closable: true` lose and the documented option silently did nothing.
1191
1363
  normalizeToastOptions(t, e = t) {
1192
- var r, n, a, l, d, f;
1193
- const s = (l = (a = (n = (r = e.closeButton) != null ? r : e.closable) != null ? n : t.closable) != null ? a : t.closeButton) != null ? l : this.config.closeButton, i = t.action ? { ...t.action, primary: (d = t.action.primary) != null ? d : !0 } : void 0, o = [
1364
+ var r, a, c, l, h, y;
1365
+ const s = (l = (c = (a = (r = e.closeButton) != null ? r : e.closable) != null ? a : t.closable) != null ? c : t.closeButton) != null ? l : this.config.closeButton, i = t.action ? { ...t.action, primary: (h = t.action.primary) != null ? h : !0 } : void 0, o = [
1194
1366
  ...i ? [i] : [],
1195
1367
  ...t.cancel ? [t.cancel] : [],
1196
1368
  ...t.actions || []
@@ -1204,7 +1376,7 @@ class q {
1204
1376
  actions: o.length > 0 ? o : void 0,
1205
1377
  ariaLive: t.ariaLive || (t.level === "error" || t.important ? "assertive" : "polite"),
1206
1378
  role: t.role || (t.level === "error" || t.important ? "alert" : "status"),
1207
- preventDuplicate: (f = t.preventDuplicate) != null ? f : this.config.preventDuplicate,
1379
+ preventDuplicate: (y = t.preventDuplicate) != null ? y : this.config.preventDuplicate,
1208
1380
  dedupeScope: t.dedupeScope || this.config.dedupeScope
1209
1381
  };
1210
1382
  }
@@ -1241,107 +1413,115 @@ class q {
1241
1413
  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));
1242
1414
  }
1243
1415
  pauseAllToasts() {
1244
- this.store.getAllToasts().forEach((e) => {
1245
- e.timeoutId && !this.pausedToasts.has(e.id) && (clearTimeout(e.timeoutId), e.timeoutId = void 0, this.pausedToasts.add(e.id));
1246
- });
1416
+ this.store.getAllToasts().forEach((t) => this.renderer.pauseToast(t, "window"));
1247
1417
  }
1248
1418
  resumeAllToasts() {
1249
- this.store.getAllToasts().forEach((e) => {
1250
- if (this.pausedToasts.has(e.id) && !e.options.persistent && e.options.duration !== 0) {
1251
- const s = e.options.duration || this.config.duration;
1252
- e.timeoutId = window.setTimeout(() => {
1253
- this.dismiss(e.id);
1254
- }, s), this.pausedToasts.delete(e.id);
1255
- }
1256
- });
1419
+ this.store.getAllToasts().forEach((t) => this.renderer.resumeToast(t, "window"));
1257
1420
  }
1258
1421
  // Cleanup
1259
1422
  destroy() {
1260
1423
  this.teardownWindowFocusHandling(), this.clear(), this.renderer.destroy(), this.lifecycle.destroy();
1261
1424
  }
1262
1425
  }
1263
- let E = null;
1264
- function h() {
1265
- return E || (E = new q()), E;
1426
+ let S = null;
1427
+ function p() {
1428
+ return S || (S = new q()), S;
1266
1429
  }
1267
- function C(c) {
1268
- return typeof document == "undefined" ? { dismiss: () => {
1269
- } } : h().show(c);
1430
+ const dt = (n) => ({
1431
+ id: n.id || "",
1432
+ options: n,
1433
+ createdAt: 0,
1434
+ dismiss: () => {
1435
+ },
1436
+ update: () => {
1437
+ }
1438
+ });
1439
+ function z(n) {
1440
+ return typeof document == "undefined" ? dt(n) : p().show(n);
1270
1441
  }
1271
- function $(c, t, e, s) {
1442
+ function Y(n, t, e, s) {
1272
1443
  let i = {};
1273
1444
  t && typeof t == "object" ? i = { ...t } : typeof t == "number" && (i.duration = t), e && (i.theme = e), s && (i.position = s);
1274
1445
  const o = {
1275
- message: c,
1446
+ message: n,
1276
1447
  ...i,
1277
1448
  level: i.level || void 0
1278
1449
  };
1279
1450
  return i.duration !== void 0 && (o.duration = i.duration), i.position && (o.position = i.position), i.theme && (o.theme = i.theme), o;
1280
1451
  }
1281
- const M = {
1282
- info: (c, t, e, s) => C({
1283
- ...$(c, t, e, s),
1284
- level: "info"
1285
- }),
1286
- success: (c, t, e, s) => C({
1287
- ...$(c, t, e, s),
1288
- level: "success"
1289
- }),
1290
- error: (c, t, e, s) => C({
1291
- ...$(c, t, e, s),
1292
- level: "error"
1293
- }),
1294
- warning: (c, t, e, s) => C({
1295
- ...$(c, t, e, s),
1296
- level: "warning"
1297
- }),
1298
- loading: (c, t, e, s) => C({
1299
- ...$(c, t, e, s),
1300
- level: "loading"
1301
- })
1302
- }, A = {
1452
+ function C(n) {
1453
+ return (t, e, s, i) => z({
1454
+ ...Y(t, e, s, i),
1455
+ level: n
1456
+ });
1457
+ }
1458
+ const $ = () => typeof document != "undefined";
1459
+ function ut(n, t, e, s) {
1460
+ const i = Y(n, t, e, s);
1461
+ return z({ ...i, level: i.level || "custom" });
1462
+ }
1463
+ const N = Object.assign(ut, {
1464
+ info: C("info"),
1465
+ success: C("success"),
1466
+ error: C("error"),
1467
+ warning: C("warning"),
1468
+ loading: C("loading"),
1469
+ // Full options (title, description, actions, progress, ...). Returns the toast.
1470
+ show: (n) => z(n),
1471
+ // One toast that follows a promise from loading to success or error. Resolves with the promise's value.
1472
+ promise: (n, t) => $() ? p().promise(n, t) : n,
1473
+ update: (n, t) => $() ? p().update(n, t) : !1,
1474
+ // With an id: that toast. Without: all of them.
1475
+ dismiss: (n) => $() ? n === void 0 ? (p().clear(), !0) : p().dismiss(n) : !1,
1476
+ clear: () => {
1477
+ $() && p().clear();
1478
+ },
1479
+ configure: (n) => {
1480
+ $() && p().configure(n);
1481
+ }
1482
+ }), A = {
1303
1483
  // Core methods
1304
- show: (c) => h().show(c),
1305
- update: (c, t) => h().update(c, t),
1306
- dismiss: (c) => h().dismiss(c),
1307
- clear: () => h().clear(),
1484
+ show: (n) => p().show(n),
1485
+ update: (n, t) => p().update(n, t),
1486
+ dismiss: (n) => p().dismiss(n),
1487
+ clear: () => p().clear(),
1308
1488
  // Convenience methods
1309
- info: (c, t) => h().show({ message: c, level: "info", ...t }),
1310
- success: (c, t) => h().show({ message: c, level: "success", ...t }),
1311
- error: (c, t) => h().show({ message: c, level: "error", ...t }),
1312
- warning: (c, t) => h().show({ message: c, level: "warning", ...t }),
1313
- loading: (c, t) => h().show({ message: c, level: "loading", ...t }),
1489
+ info: (n, t) => p().show({ message: n, level: "info", ...t }),
1490
+ success: (n, t) => p().show({ message: n, level: "success", ...t }),
1491
+ error: (n, t) => p().show({ message: n, level: "error", ...t }),
1492
+ warning: (n, t) => p().show({ message: n, level: "warning", ...t }),
1493
+ loading: (n, t) => p().show({ message: n, level: "loading", ...t }),
1314
1494
  // Advanced features
1315
- promise: (c, t) => h().promise(c, t),
1316
- group: (c, t) => h().group(c, t),
1317
- configure: (c) => h().configure(c),
1318
- use: (c) => h().use(c),
1495
+ promise: (n, t) => p().promise(n, t),
1496
+ group: (n, t) => p().group(n, t),
1497
+ configure: (n) => p().configure(n),
1498
+ use: (n) => p().use(n),
1319
1499
  // State queries
1320
- getToasts: () => h().getToasts(),
1321
- getGroups: () => h().getGroups(),
1322
- getConfig: () => h().getConfig(),
1323
- getState: () => h().getState(),
1324
- subscribe: (c) => h().subscribe(c),
1500
+ getToasts: () => p().getToasts(),
1501
+ getGroups: () => p().getGroups(),
1502
+ getConfig: () => p().getConfig(),
1503
+ getState: () => p().getState(),
1504
+ subscribe: (n) => p().subscribe(n),
1325
1505
  // Editor integration
1326
- onEditorEvent: (c, t) => h().onEditorEvent(c, t),
1327
- triggerEditorEvent: (c, t, ...e) => h().triggerEditorEvent(c, t, ...e),
1506
+ onEditorEvent: (n, t) => p().onEditorEvent(n, t),
1507
+ triggerEditorEvent: (n, t, ...e) => p().triggerEditorEvent(n, t, ...e),
1328
1508
  // Cleanup
1329
1509
  destroy: () => {
1330
- E && (E.destroy(), E = null);
1510
+ S && (S.destroy(), S = null);
1331
1511
  }
1332
1512
  };
1333
1513
  if (typeof window != "undefined" && typeof document != "undefined") {
1334
- const c = window;
1335
- c.toast = M, c.toastAdvanced = A, c.toastPro = A, c.ToastManager = q, c.__editoraToastReady || (c.__editoraToastReady = !0, window.dispatchEvent(
1514
+ const n = window;
1515
+ n.toast = N, n.toastAdvanced = A, n.toastPro = A, n.ToastManager = q, n.__editoraToastReady || (n.__editoraToastReady = !0, window.dispatchEvent(
1336
1516
  new CustomEvent("toastReady", {
1337
- detail: { toast: M, toastAdvanced: A, toastPro: A, ToastManager: q }
1517
+ detail: { toast: N, toastAdvanced: A, toastPro: A, ToastManager: q }
1338
1518
  })
1339
1519
  ));
1340
1520
  }
1341
1521
  export {
1342
1522
  q as ToastManager,
1343
- M as default,
1344
- M as toast,
1523
+ N as default,
1524
+ N as toast,
1345
1525
  A as toastAdvanced,
1346
1526
  A as toastPro
1347
1527
  };