@editora/toast 2.1.2 → 2.2.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.
@@ -0,0 +1,351 @@
1
+ class b {
2
+ constructor(t = {}) {
3
+ var s, r, o, a;
4
+ this.config = {
5
+ stiffness: (s = t.stiffness) != null ? s : 100,
6
+ damping: (r = t.damping) != null ? r : 10,
7
+ mass: (o = t.mass) != null ? o : 1,
8
+ precision: (a = t.precision) != null ? a : 0.01
9
+ };
10
+ }
11
+ // Spring animation function
12
+ animate(t, s, r, o, a) {
13
+ const n = {
14
+ ...this.config,
15
+ ...a
16
+ };
17
+ let i, e = !1;
18
+ const c = Object.keys(s).reduce((p, l) => (p[l] = s[l].from, p), {}), y = Object.keys(s).reduce((p, l) => (p[l] = 0, p), {}), d = () => {
19
+ if (e) return;
20
+ let p = !0;
21
+ Object.keys(s).forEach((m) => {
22
+ const u = s[m].to, P = c[m], f = y[m], g = -n.stiffness * (P - u), $ = -n.damping * f, h = (g + $) / n.mass;
23
+ y[m] += h * 0.016, c[m] += y[m] * 0.016, (Math.abs(P - u) > n.precision || Math.abs(f) > n.precision) && (p = !1);
24
+ });
25
+ const l = Object.keys(c).reduce((m, u) => {
26
+ const P = s[u].unit || "px";
27
+ return m[u] = `${c[u]}${P}`, m;
28
+ }, {});
29
+ r(l), p ? (e = !0, o == null || o()) : i = requestAnimationFrame(d);
30
+ };
31
+ return i = requestAnimationFrame(d), () => {
32
+ e = !0, i && cancelAnimationFrame(i);
33
+ };
34
+ }
35
+ }
36
+ class T {
37
+ constructor() {
38
+ this.springAnimation = new b();
39
+ }
40
+ // Show toast with specified animation
41
+ async showToast(t, s, r) {
42
+ switch (r.type) {
43
+ case "spring":
44
+ await this.animateSpringShow(t, r);
45
+ break;
46
+ case "bounce":
47
+ await this.animateBounceShow(t, r);
48
+ break;
49
+ case "slide":
50
+ await this.animateSlideShow(t, r);
51
+ break;
52
+ case "zoom":
53
+ await this.animateZoomShow(t, r);
54
+ break;
55
+ case "flip":
56
+ await this.animateFlipShow(t, r);
57
+ break;
58
+ case "fade":
59
+ await this.animateFadeShow(t, r);
60
+ break;
61
+ case "elastic":
62
+ await this.animateElasticShow(t, r);
63
+ break;
64
+ case "rotate":
65
+ await this.animateRotateShow(t, r);
66
+ break;
67
+ case "custom":
68
+ r.show ? await Promise.resolve(r.show(t, s)) : await this.animateCssShow(t);
69
+ break;
70
+ default:
71
+ await this.animateCssShow(t);
72
+ break;
73
+ }
74
+ }
75
+ // Hide toast with specified animation
76
+ async hideToast(t, s, r) {
77
+ switch (r.type) {
78
+ case "spring":
79
+ await this.animateSpringHide(t, r);
80
+ break;
81
+ case "bounce":
82
+ await this.animateBounceHide(t, r);
83
+ break;
84
+ case "slide":
85
+ await this.animateSlideHide(t, r);
86
+ break;
87
+ case "zoom":
88
+ await this.animateZoomHide(t, r);
89
+ break;
90
+ case "flip":
91
+ await this.animateFlipHide(t, r);
92
+ break;
93
+ case "fade":
94
+ await this.animateFadeHide(t, r);
95
+ break;
96
+ case "elastic":
97
+ await this.animateElasticHide(t, r);
98
+ break;
99
+ case "rotate":
100
+ await this.animateRotateHide(t, r);
101
+ break;
102
+ case "custom":
103
+ r.hide ? await Promise.resolve(r.hide(t, s)) : await this.animateCssHide(t);
104
+ break;
105
+ default:
106
+ await this.animateCssHide(t);
107
+ break;
108
+ }
109
+ }
110
+ // Update toast with specified animation
111
+ async updateToast(t, s, r, o) {
112
+ o.type === "custom" && o.update && await Promise.resolve(o.update(t, s, r));
113
+ }
114
+ // CSS-based show animation (existing behavior)
115
+ animateCssShow(t) {
116
+ return new Promise((s) => {
117
+ requestAnimationFrame(() => {
118
+ t.classList.add("show"), window.setTimeout(s, 220);
119
+ });
120
+ });
121
+ }
122
+ // CSS-based hide animation (existing behavior)
123
+ animateCssHide(t) {
124
+ return new Promise((s) => {
125
+ t.classList.remove("show"), t.classList.add("hiding"), window.setTimeout(s, 220);
126
+ });
127
+ }
128
+ // Spring-based show animation
129
+ async animateSpringShow(t, s) {
130
+ return new Promise((r) => {
131
+ var n, i, e;
132
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important"), t.style.setProperty("-webkit-transition", "none", "important");
133
+ const a = ((n = t.parentElement) == null ? void 0 : n.classList.contains("editora-toast-bottom-right")) || ((i = t.parentElement) == null ? void 0 : i.classList.contains("editora-toast-bottom-left")) || ((e = t.parentElement) == null ? void 0 : e.classList.contains("editora-toast-bottom-center")) ? 20 : -20;
134
+ t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `translateY(${a}px) scale(0.95)`, "important"), t.offsetHeight, setTimeout(() => {
135
+ 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(() => {
136
+ t.style.setProperty("transition", "none", "important"), r();
137
+ }, 800);
138
+ }, 16);
139
+ });
140
+ }
141
+ // Spring-based hide animation
142
+ async animateSpringHide(t, s) {
143
+ return new Promise((r) => {
144
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important"), t.style.setProperty("-webkit-transition", "none", "important"), setTimeout(() => {
145
+ 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(() => {
146
+ t.style.setProperty("transition", "none", "important"), r();
147
+ }, 400);
148
+ }, 16);
149
+ });
150
+ }
151
+ // Bounce-based show animation
152
+ async animateBounceShow(t, s) {
153
+ return new Promise((r) => {
154
+ var y, d, p;
155
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
156
+ const o = ((y = t.parentElement) == null ? void 0 : y.classList.contains("editora-toast-bottom-right")) || ((d = t.parentElement) == null ? void 0 : d.classList.contains("editora-toast-bottom-left")) || ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-center")), a = s.direction || (o ? "up" : "down"), n = s.intensity || "normal", i = s.duration || 800, e = n === "gentle" ? 0.05 : n === "strong" ? 0.15 : 0.1, c = a === "up" ? 30 : a === "down" ? -30 : a === "left" ? 30 : -30;
157
+ t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
158
+ "transform",
159
+ a === "left" || a === "right" ? `translateX(${c}px) scale(${1 - e})` : `translateY(${c}px) scale(${1 - e})`,
160
+ "important"
161
+ ), t.offsetHeight, setTimeout(() => {
162
+ t.style.setProperty(
163
+ "transition",
164
+ `opacity ${i}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${i}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
165
+ "important"
166
+ ), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) scale(1)", "important"), setTimeout(() => {
167
+ t.style.setProperty("transition", "none", "important"), r();
168
+ }, i);
169
+ }, 16);
170
+ });
171
+ }
172
+ // Bounce-based hide animation
173
+ async animateBounceHide(t, s) {
174
+ return new Promise((r) => {
175
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
176
+ const o = s.intensity || "normal", a = o === "gentle" ? 0.05 : o === "strong" ? 0.15 : 0.1;
177
+ setTimeout(() => {
178
+ 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 - a})`, "important"), setTimeout(() => {
179
+ t.style.setProperty("transition", "none", "important"), r();
180
+ }, 400);
181
+ }, 16);
182
+ });
183
+ }
184
+ // Slide-based show animation
185
+ async animateSlideShow(t, s) {
186
+ return new Promise((r) => {
187
+ var y, d, p;
188
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
189
+ const o = ((y = t.parentElement) == null ? void 0 : y.classList.contains("editora-toast-bottom-right")) || ((d = t.parentElement) == null ? void 0 : d.classList.contains("editora-toast-bottom-left")) || ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-center")), a = s.direction || (o ? "up" : "down"), n = s.distance || 100, i = s.easing || "ease-out", e = s.duration || 400, c = a === "up" ? `translateY(${n}px)` : a === "down" ? `translateY(-${n}px)` : a === "left" ? `translateX(${n}px)` : `translateX(-${n}px)`;
190
+ t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", c, "important"), t.offsetHeight, setTimeout(() => {
191
+ t.style.setProperty("transition", `opacity ${e}ms ${i}, transform ${e}ms ${i}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) translateX(0)", "important"), setTimeout(() => {
192
+ t.style.setProperty("transition", "none", "important"), r();
193
+ }, e);
194
+ }, 16);
195
+ });
196
+ }
197
+ // Slide-based hide animation
198
+ async animateSlideHide(t, s) {
199
+ return new Promise((r) => {
200
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
201
+ const o = s.direction || "down", a = s.distance || 100, n = s.easing || "ease-in", i = s.duration || 300, e = o === "up" ? `translateY(-${a}px)` : o === "down" ? `translateY(${a}px)` : o === "left" ? `translateX(-${a}px)` : `translateX(${a}px)`;
202
+ setTimeout(() => {
203
+ t.style.setProperty("transition", `opacity ${i}ms ${n}, transform ${i}ms ${n}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", e, "important"), setTimeout(() => {
204
+ t.style.setProperty("transition", "none", "important"), r();
205
+ }, i);
206
+ }, 16);
207
+ });
208
+ }
209
+ // Zoom-based show animation
210
+ async animateZoomShow(t, s) {
211
+ return new Promise((r) => {
212
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
213
+ const o = s.scale || 0.3, a = s.origin || "center", n = s.easing || "ease-out", i = s.duration || 500;
214
+ t.style.setProperty("transform-origin", a, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${o})`, "important"), t.offsetHeight, setTimeout(() => {
215
+ t.style.setProperty("transition", `opacity ${i}ms ${n}, transform ${i}ms ${n}`, "important"), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "scale(1)", "important"), setTimeout(() => {
216
+ t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), r();
217
+ }, i);
218
+ }, 16);
219
+ });
220
+ }
221
+ // Zoom-based hide animation
222
+ async animateZoomHide(t, s) {
223
+ return new Promise((r) => {
224
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
225
+ const o = s.scale || 0.3, a = s.origin || "center", n = s.easing || "ease-in", i = s.duration || 300;
226
+ t.style.setProperty("transform-origin", a, "important"), setTimeout(() => {
227
+ t.style.setProperty("transition", `opacity ${i}ms ${n}, transform ${i}ms ${n}`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `scale(${o})`, "important"), setTimeout(() => {
228
+ t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), r();
229
+ }, i);
230
+ }, 16);
231
+ });
232
+ }
233
+ // Flip-based show animation
234
+ async animateFlipShow(t, s) {
235
+ return new Promise((r) => {
236
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
237
+ const o = s.axis || "y", a = s.perspective || 1e3, n = s.direction || "forward", i = s.duration || 600;
238
+ t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${a}px`, "important");
239
+ const e = n === "forward" ? o === "x" ? -90 : 90 : o === "x" ? 90 : -90;
240
+ t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${o.toUpperCase()}(${e}deg)`, "important"), t.offsetHeight, setTimeout(() => {
241
+ t.style.setProperty("transition", `opacity ${i}ms ease, transform ${i}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(() => {
242
+ t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"), r();
243
+ }, i);
244
+ }, 16);
245
+ });
246
+ }
247
+ // Flip-based hide animation
248
+ async animateFlipHide(t, s) {
249
+ return new Promise((r) => {
250
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
251
+ const o = s.axis || "y", a = s.perspective || 1e3, n = s.direction || "backward", i = s.duration || 400;
252
+ t.style.setProperty("transform-style", "preserve-3d", "important"), t.parentElement.style.setProperty("perspective", `${a}px`, "important");
253
+ const e = n === "backward" ? o === "x" ? -90 : 90 : o === "x" ? 90 : -90;
254
+ setTimeout(() => {
255
+ t.style.setProperty("transition", `opacity ${i}ms ease, transform ${i}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate${o.toUpperCase()}(${e}deg)`, "important"), setTimeout(() => {
256
+ t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-style", "", "important"), t.parentElement.style.setProperty("perspective", "", "important"), r();
257
+ }, i);
258
+ }, 16);
259
+ });
260
+ }
261
+ // Fade-based show animation
262
+ async animateFadeShow(t, s) {
263
+ return new Promise((r) => {
264
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
265
+ const o = s.direction || "none", a = s.distance || 20, n = s.duration || 300;
266
+ let i = "translateY(0) translateX(0)";
267
+ o !== "none" && (i = o === "up" ? `translateY(${a}px)` : o === "down" ? `translateY(-${a}px)` : o === "left" ? `translateX(${a}px)` : `translateX(-${a}px)`), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", i, "important"), t.offsetHeight, setTimeout(() => {
268
+ 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(() => {
269
+ t.style.setProperty("transition", "none", "important"), r();
270
+ }, n);
271
+ }, 16);
272
+ });
273
+ }
274
+ // Fade-based hide animation
275
+ async animateFadeHide(t, s) {
276
+ return new Promise((r) => {
277
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
278
+ const o = s.direction || "none", a = s.distance || 20, n = s.duration || 200;
279
+ let i = "translateY(0) translateX(0)";
280
+ o !== "none" && (i = o === "up" ? `translateY(-${a}px)` : o === "down" ? `translateY(${a}px)` : o === "left" ? `translateX(-${a}px)` : `translateX(${a}px)`), setTimeout(() => {
281
+ t.style.setProperty("transition", `opacity ${n}ms ease, transform ${n}ms ease`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", i, "important"), setTimeout(() => {
282
+ t.style.setProperty("transition", "none", "important"), r();
283
+ }, n);
284
+ }, 16);
285
+ });
286
+ }
287
+ // Elastic-based show animation
288
+ async animateElasticShow(t, s) {
289
+ return new Promise((r) => {
290
+ var y, d, p;
291
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
292
+ const o = ((y = t.parentElement) == null ? void 0 : y.classList.contains("editora-toast-bottom-right")) || ((d = t.parentElement) == null ? void 0 : d.classList.contains("editora-toast-bottom-left")) || ((p = t.parentElement) == null ? void 0 : p.classList.contains("editora-toast-bottom-center")), a = s.direction || (o ? "up" : "down"), n = s.intensity || "normal", i = s.duration || 1e3, e = n === "gentle" ? 0.1 : n === "strong" ? 0.3 : 0.2, c = a === "up" ? 40 : a === "down" ? -40 : a === "left" ? 40 : -40;
293
+ t.style.setProperty("opacity", "0", "important"), t.style.setProperty(
294
+ "transform",
295
+ a === "left" || a === "right" ? `translateX(${c}px) scale(${1 + e})` : `translateY(${c}px) scale(${1 + e})`,
296
+ "important"
297
+ ), t.offsetHeight, setTimeout(() => {
298
+ t.style.setProperty(
299
+ "transition",
300
+ `opacity ${i}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${i}ms cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
301
+ "important"
302
+ ), t.style.setProperty("opacity", "1", "important"), t.style.setProperty("transform", "translateY(0) scale(1)", "important"), setTimeout(() => {
303
+ t.style.setProperty("transition", "none", "important"), r();
304
+ }, i);
305
+ }, 16);
306
+ });
307
+ }
308
+ // Elastic-based hide animation
309
+ async animateElasticHide(t, s) {
310
+ return new Promise((r) => {
311
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
312
+ const o = s.intensity || "normal", a = o === "gentle" ? 0.1 : o === "strong" ? 0.3 : 0.2;
313
+ s.duration, setTimeout(() => {
314
+ 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 + a})`, "important"), setTimeout(() => {
315
+ t.style.setProperty("transition", "none", "important"), r();
316
+ }, 400);
317
+ }, 16);
318
+ });
319
+ }
320
+ // Rotate-based show animation
321
+ async animateRotateShow(t, s) {
322
+ return new Promise((r) => {
323
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
324
+ const o = s.degrees || 360, a = s.direction || "clockwise", n = s.origin || "center", i = s.duration || 500, e = a === "clockwise" ? o : -o;
325
+ t.style.setProperty("transform-origin", n, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${e}deg) scale(0.8)`, "important"), t.offsetHeight, setTimeout(() => {
326
+ t.style.setProperty("transition", `opacity ${i}ms ease, transform ${i}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(() => {
327
+ t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), r();
328
+ }, i);
329
+ }, 16);
330
+ });
331
+ }
332
+ // Rotate-based hide animation
333
+ async animateRotateHide(t, s) {
334
+ return new Promise((r) => {
335
+ t.classList.add("spring-animation"), t.style.setProperty("transition", "none", "important");
336
+ const o = s.degrees || 180, a = s.direction || "counterclockwise", n = s.origin || "center", i = s.duration || 300, e = a === "clockwise" ? o : -o;
337
+ t.style.setProperty("transform-origin", n, "important"), setTimeout(() => {
338
+ t.style.setProperty("transition", `opacity ${i}ms ease, transform ${i}ms ease-in`, "important"), t.style.setProperty("opacity", "0", "important"), t.style.setProperty("transform", `rotate(${e}deg) scale(0.8)`, "important"), setTimeout(() => {
339
+ t.style.setProperty("transition", "none", "important"), t.style.setProperty("transform-origin", "", "important"), r();
340
+ }, i);
341
+ }, 16);
342
+ });
343
+ }
344
+ }
345
+ const S = new T();
346
+ export {
347
+ T as AnimationManager,
348
+ b as SpringAnimation,
349
+ S as animationManager
350
+ };
351
+ //# sourceMappingURL=AnimationUtils-CaHTcqKD.es.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class g{constructor(t={}){var s,r,o,a;this.config={stiffness:(s=t.stiffness)!=null?s:100,damping:(r=t.damping)!=null?r:10,mass:(o=t.mass)!=null?o:1,precision:(a=t.precision)!=null?a:.01}}animate(t,s,r,o,a){const n={...this.config,...a};let i,e=!1;const c=Object.keys(s).reduce((p,l)=>(p[l]=s[l].from,p),{}),y=Object.keys(s).reduce((p,l)=>(p[l]=0,p),{}),d=()=>{if(e)return;let p=!0;Object.keys(s).forEach(m=>{const u=s[m].to,P=c[m],f=y[m],h=-n.stiffness*(P-u),b=-n.damping*f,T=(h+b)/n.mass;y[m]+=T*.016,c[m]+=y[m]*.016,(Math.abs(P-u)>n.precision||Math.abs(f)>n.precision)&&(p=!1)});const l=Object.keys(c).reduce((m,u)=>{const P=s[u].unit||"px";return m[u]=`${c[u]}${P}`,m},{});r(l),p?(e=!0,o==null||o()):i=requestAnimationFrame(d)};return i=requestAnimationFrame(d),()=>{e=!0,i&&cancelAnimationFrame(i)}}}class w{constructor(){this.springAnimation=new g}async showToast(t,s,r){switch(r.type){case"spring":await this.animateSpringShow(t,r);break;case"bounce":await this.animateBounceShow(t,r);break;case"slide":await this.animateSlideShow(t,r);break;case"zoom":await this.animateZoomShow(t,r);break;case"flip":await this.animateFlipShow(t,r);break;case"fade":await this.animateFadeShow(t,r);break;case"elastic":await this.animateElasticShow(t,r);break;case"rotate":await this.animateRotateShow(t,r);break;case"custom":r.show?await Promise.resolve(r.show(t,s)):await this.animateCssShow(t);break;default:await this.animateCssShow(t);break}}async hideToast(t,s,r){switch(r.type){case"spring":await this.animateSpringHide(t,r);break;case"bounce":await this.animateBounceHide(t,r);break;case"slide":await this.animateSlideHide(t,r);break;case"zoom":await this.animateZoomHide(t,r);break;case"flip":await this.animateFlipHide(t,r);break;case"fade":await this.animateFadeHide(t,r);break;case"elastic":await this.animateElasticHide(t,r);break;case"rotate":await this.animateRotateHide(t,r);break;case"custom":r.hide?await Promise.resolve(r.hide(t,s)):await this.animateCssHide(t);break;default:await this.animateCssHide(t);break}}async updateToast(t,s,r,o){o.type==="custom"&&o.update&&await Promise.resolve(o.update(t,s,r))}animateCssShow(t){return new Promise(s=>{requestAnimationFrame(()=>{t.classList.add("show"),window.setTimeout(s,220)})})}animateCssHide(t){return new Promise(s=>{t.classList.remove("show"),t.classList.add("hiding"),window.setTimeout(s,220)})}async animateSpringShow(t,s){return new Promise(r=>{var n,i,e;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important"),t.style.setProperty("-webkit-transition","none","important");const a=((n=t.parentElement)==null?void 0:n.classList.contains("editora-toast-bottom-right"))||((i=t.parentElement)==null?void 0:i.classList.contains("editora-toast-bottom-left"))||((e=t.parentElement)==null?void 0:e.classList.contains("editora-toast-bottom-center"))?20:-20;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`translateY(${a}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"),r()},800)},16)})}async animateSpringHide(t,s){return new Promise(r=>{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"),r()},400)},16)})}async animateBounceShow(t,s){return new Promise(r=>{var y,d,p;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-right"))||((d=t.parentElement)==null?void 0:d.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),a=s.direction||(o?"up":"down"),n=s.intensity||"normal",i=s.duration||800,e=n==="gentle"?.05:n==="strong"?.15:.1,c=a==="up"?30:a==="down"?-30:a==="left"?30:-30;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a==="left"||a==="right"?`translateX(${c}px) scale(${1-e})`:`translateY(${c}px) scale(${1-e})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${i}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"),r()},i)},16)})}async animateBounceHide(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.intensity||"normal",a=o==="gentle"?.05:o==="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-a})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),r()},400)},16)})}async animateSlideShow(t,s){return new Promise(r=>{var y,d,p;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-right"))||((d=t.parentElement)==null?void 0:d.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),a=s.direction||(o?"up":"down"),n=s.distance||100,i=s.easing||"ease-out",e=s.duration||400,c=a==="up"?`translateY(${n}px)`:a==="down"?`translateY(-${n}px)`:a==="left"?`translateX(${n}px)`:`translateX(-${n}px)`;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",c,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${e}ms ${i}, transform ${e}ms ${i}`,"important"),t.style.setProperty("opacity","1","important"),t.style.setProperty("transform","translateY(0) translateX(0)","important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),r()},e)},16)})}async animateSlideHide(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.direction||"down",a=s.distance||100,n=s.easing||"ease-in",i=s.duration||300,e=o==="up"?`translateY(-${a}px)`:o==="down"?`translateY(${a}px)`:o==="left"?`translateX(-${a}px)`:`translateX(${a}px)`;setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms ${n}, transform ${i}ms ${n}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",e,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),r()},i)},16)})}async animateZoomShow(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.scale||.3,a=s.origin||"center",n=s.easing||"ease-out",i=s.duration||500;t.style.setProperty("transform-origin",a,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${o})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms ${n}, transform ${i}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"),r()},i)},16)})}async animateZoomHide(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.scale||.3,a=s.origin||"center",n=s.easing||"ease-in",i=s.duration||300;t.style.setProperty("transform-origin",a,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms ${n}, transform ${i}ms ${n}`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`scale(${o})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),r()},i)},16)})}async animateFlipShow(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.axis||"y",a=s.perspective||1e3,n=s.direction||"forward",i=s.duration||600;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${a}px`,"important");const e=n==="forward"?o==="x"?-90:90:o==="x"?90:-90;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${o.toUpperCase()}(${e}deg)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms ease, transform ${i}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"),r()},i)},16)})}async animateFlipHide(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.axis||"y",a=s.perspective||1e3,n=s.direction||"backward",i=s.duration||400;t.style.setProperty("transform-style","preserve-3d","important"),t.parentElement.style.setProperty("perspective",`${a}px`,"important");const e=n==="backward"?o==="x"?-90:90:o==="x"?90:-90;setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms ease, transform ${i}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate${o.toUpperCase()}(${e}deg)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-style","","important"),t.parentElement.style.setProperty("perspective","","important"),r()},i)},16)})}async animateFadeShow(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.direction||"none",a=s.distance||20,n=s.duration||300;let i="translateY(0) translateX(0)";o!=="none"&&(i=o==="up"?`translateY(${a}px)`:o==="down"?`translateY(-${a}px)`:o==="left"?`translateX(${a}px)`:`translateX(-${a}px)`),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",i,"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"),r()},n)},16)})}async animateFadeHide(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.direction||"none",a=s.distance||20,n=s.duration||200;let i="translateY(0) translateX(0)";o!=="none"&&(i=o==="up"?`translateY(-${a}px)`:o==="down"?`translateY(${a}px)`:o==="left"?`translateX(-${a}px)`:`translateX(${a}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",i,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),r()},n)},16)})}async animateElasticShow(t,s){return new Promise(r=>{var y,d,p;t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=((y=t.parentElement)==null?void 0:y.classList.contains("editora-toast-bottom-right"))||((d=t.parentElement)==null?void 0:d.classList.contains("editora-toast-bottom-left"))||((p=t.parentElement)==null?void 0:p.classList.contains("editora-toast-bottom-center")),a=s.direction||(o?"up":"down"),n=s.intensity||"normal",i=s.duration||1e3,e=n==="gentle"?.1:n==="strong"?.3:.2,c=a==="up"?40:a==="down"?-40:a==="left"?40:-40;t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",a==="left"||a==="right"?`translateX(${c}px) scale(${1+e})`:`translateY(${c}px) scale(${1+e})`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms cubic-bezier(0.68, -0.55, 0.265, 1.55), transform ${i}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"),r()},i)},16)})}async animateElasticHide(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.intensity||"normal",a=o==="gentle"?.1:o==="strong"?.3:.2;s.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+a})`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),r()},400)},16)})}async animateRotateShow(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.degrees||360,a=s.direction||"clockwise",n=s.origin||"center",i=s.duration||500,e=a==="clockwise"?o:-o;t.style.setProperty("transform-origin",n,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${e}deg) scale(0.8)`,"important"),t.offsetHeight,setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms ease, transform ${i}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"),r()},i)},16)})}async animateRotateHide(t,s){return new Promise(r=>{t.classList.add("spring-animation"),t.style.setProperty("transition","none","important");const o=s.degrees||180,a=s.direction||"counterclockwise",n=s.origin||"center",i=s.duration||300,e=a==="clockwise"?o:-o;t.style.setProperty("transform-origin",n,"important"),setTimeout(()=>{t.style.setProperty("transition",`opacity ${i}ms ease, transform ${i}ms ease-in`,"important"),t.style.setProperty("opacity","0","important"),t.style.setProperty("transform",`rotate(${e}deg) scale(0.8)`,"important"),setTimeout(()=>{t.style.setProperty("transition","none","important"),t.style.setProperty("transform-origin","","important"),r()},i)},16)})}}const S=new w;exports.AnimationManager=w;exports.SpringAnimation=g;exports.animationManager=S;
2
+ //# sourceMappingURL=AnimationUtils-Cp3BmULJ.cjs.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";let K=null;function Y(o){K=o}function J(){return K}class Z{constructor(e){this.toasts=new Map,this.groups=new Map,this.containers=new Map,this.config={...e}}addToast(e){this.toasts.set(e.id,e),this.updateGroup(e)}removeToast(e){const t=this.toasts.get(e);return t?(this.toasts.delete(e),this.updateGroup(t),!0):!1}getToast(e){return this.toasts.get(e)}getAllToasts(){return Array.from(this.toasts.values())}getToastsByPosition(e){return this.getAllToasts().filter(t=>t.options.position===e)}updateToast(e,t){const s=this.toasts.get(e);return s?(Object.assign(s,t),this.updateGroup(s),!0):!1}updateGroup(e){const t=e.options.group;if(!t)return;let s=this.groups.get(t);s||(s={id:t,toasts:[]},this.groups.set(t,s)),s.toasts=s.toasts.filter(i=>i.id!==e.id),e.options.group===t&&s.toasts.push(e),s.toasts.length===0&&this.groups.delete(t)}getGroup(e){return this.groups.get(e)}getAllGroups(){return Array.from(this.groups.values())}getContainer(e){return this.containers.get(e)}setContainer(e,t){this.containers.set(e,t)}removeContainer(e){return this.containers.delete(e)}getAllContainers(){return new Map(this.containers)}getConfig(){return{...this.config}}updateConfig(e){this.config={...this.config,...e}}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(e=>[e,this.getToastsByPosition(e).length]))}}}class ee{constructor(e){this.queue=[],this.visible=[],this.config=this.normalizeConfig(e)}enqueue(e){var r;const t=this.findDuplicate(e);if(t&&((r=e.options.preventDuplicate)!=null?r:this.config.preventDuplicate))return{show:[],hide:[],rejected:t};const s=[];if(e.options.important&&this.visible.length>=this.maxVisible){const n=this.removeLowestPriorityVisible();return this.visible.push(e),{show:[e],hide:n?[...s,n]:s}}this.config.queueStrategy==="fifo"?this.queue.push(e):this.queue.unshift(e),this.sortQueue();const i=this.processQueue();return{show:i.show,hide:[...s,...i.hide]}}dequeue(e){return this.removeFromCollections(e)?{show:this.processQueue().show,hide:[]}:{show:[],hide:[]}}updateConfig(e){return this.config=this.normalizeConfig({...this.config,...e}),this.sortQueue(),this.processQueue()}getQueued(){return[...this.queue]}getVisible(){return[...this.visible]}getAll(){return[...this.visible,...this.queue]}isVisible(e){return this.visible.some(t=>t.id===e)}clear(){const e=[...this.visible,...this.queue];return this.queue=[],this.visible=[],e}processQueue(){const e=[],t=[];for(;this.visible.length>this.maxVisible;){const s=this.visible.pop();s&&t.push(s)}for(;this.visible.length<this.maxVisible&&this.queue.length>0;){const s=this.queue.shift();if(!s)break;this.visible.push(s),e.push(s)}return{show:e,hide:t}}removeLowestPriorityVisible(){if(this.visible.length===0)return;let e=0;for(let t=1;t<this.visible.length;t+=1)(this.visible[t].options.priority||0)<(this.visible[e].options.priority||0)&&(e=t);return this.visible.splice(e,1)[0]}removeFromCollections(e){const t=this.visible.findIndex(i=>i.id===e);if(t!==-1)return this.visible.splice(t,1)[0];const s=this.queue.findIndex(i=>i.id===e);if(s!==-1)return this.queue.splice(s,1)[0]}findDuplicate(e){const t=e.options.dedupeScope||this.config.dedupeScope,s=t==="visible"?this.visible:t==="queue"?this.queue:[...this.visible,...this.queue],i=this.getDedupeKey(e);return s.find(r=>this.getDedupeKey(r)===i)}getDedupeKey(e){if(e.options.dedupeKey)return e.options.dedupeKey;const{level:t,title:s,message:i,description:r}=e.options;return typeof Node!="undefined"&&[s,i,r].some(a=>a instanceof Node)?`node:${e.id}`:`${t||"info"}:${s||""}:${i||""}:${r||""}`}sortQueue(){this.queue.sort((e,t)=>{const s=(t.options.priority||0)-(e.options.priority||0);return s!==0?s:e.createdAt-t.createdAt})}get maxVisible(){return Math.max(1,this.config.visibleToasts||this.config.maxVisible||1)}normalizeConfig(e){return{...e,maxVisible:e.visibleToasts||e.maxVisible}}}const te=new Set(["a","b","strong","i","em","u","s","del","ins","mark","small","sub","sup","code","kbd","br","span","p","ul","ol","li"]),se=new Set(["script","style","iframe","frame","frameset","object","embed","applet","noscript","template","svg","math","form","input","button","textarea","select","option","head","title","link","meta","base","audio","video","canvas"]),ie=/^(?:https?:|mailto:|tel:)/i;function oe(o){const e=o.replace(/[\u0000- \u007f-\u009f]/g,"");return e?ie.test(e)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(e):!1}function D(o,e,t){for(const s of Array.from(o.childNodes)){if(s.nodeType===Node.TEXT_NODE){e.appendChild(t.createTextNode(s.textContent||""));continue}if(s.nodeType!==Node.ELEMENT_NODE)continue;const i=s,r=i.localName.toLowerCase();if(se.has(r))continue;if(!te.has(r)){D(i,e,t);continue}const n=t.createElement(r);if(r==="a"){const a=i.getAttribute("href");a&&oe(a)&&(n.setAttribute("href",a.trim()),/^(?:https?:)?\/\//i.test(a.trim())&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer")));const c=i.getAttribute("title");c&&n.setAttribute("title",c)}D(i,n,t),e.appendChild(n)}}function ne(o,e){const t=document.createElement("template");t.innerHTML=e;const s=document.createDocumentFragment();D(t.content,s,document),o.textContent="",o.appendChild(s)}const F="http://www.w3.org/2000/svg",re={success:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M6.6 10.3l2.3 2.3 4.5-4.9"}]],error:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M7.6 7.6l4.8 4.8M12.4 7.6l-4.8 4.8"}]],warning:[["path",{d:"M10 2.9L18 16.4H2L10 2.9z"}],["path",{d:"M10 8.3v3.4M10 13.9v.1"}]],info:[["circle",{cx:"10",cy:"10",r:"8"}],["path",{d:"M10 9.2v4.4M10 6.5v.1"}]],loading:[["path",{d:"M10 2a8 8 0 1 0 8 8"}]]},ae={success:"success",error:"error",warning:"warning",info:"info",loading:"loading",promise:"loading"};function _(o,e){const t=document.createElementNS(F,"svg");return t.setAttribute("viewBox","0 0 20 20"),t.setAttribute("width",String(e)),t.setAttribute("height",String(e)),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.7"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("focusable","false"),t.setAttribute("aria-hidden","true"),o.forEach(([s,i])=>{const r=document.createElementNS(F,s);Object.keys(i).forEach(n=>r.setAttribute(n,i[n])),t.appendChild(r)}),t}function le(o){const e=re[ae[o]||""];return e?_(e,18):null}function ce(){const o=_([["path",{d:"M5.5 5.5l9 9M14.5 5.5l-9 9"}]],14);return o.setAttribute("stroke-width","1.8"),o}const I=12,de=.05,N=3,M=new WeakMap;function he(o){const e=o.style.height;o.style.height="auto";const t=o.offsetHeight;return o.style.height=e,M.set(o,t),t}function V(o){M.delete(o)}function ue(o,e){return!e.stack||e.expand||o.dataset.open==="true"}function fe(o,e,t=!1){const i=o.dataset.edge==="bottom"?-1:1,r=Array.from(o.querySelectorAll(".editora-toast")),n=r.filter(h=>!h.classList.contains("hiding")&&h.dataset.leaving!=="true"),a=n.slice().reverse(),c=ue(o,e);a.forEach(h=>{(t||!M.has(h))&&he(h)});const l=a.map(h=>M.get(h)||0),f=l[0]||0;let m=0;a.forEach((h,g)=>{const L=l[g],u=c?1:Math.max(1-g*de,.8),b=c?L:f,p=c?m:g*I+f*(1-u);h.style.setProperty("--et-y",`${i*p}px`),h.style.setProperty("--et-s",String(u)),h.style.setProperty("--et-index",String(g)),h.style.height=`${b}px`,h.style.zIndex=String(a.length-g),h.dataset.index=String(g),h.dataset.front=String(g===0),h.dataset.collapsed=String(!c&&g>0),h.dataset.hidden=String(!c&&g>=N),m+=L+e.gap}),r.forEach(h=>{n.includes(h)||(h.dataset.front="false")});const w=a.length,k=c?l.reduce((h,g)=>h+g,0)+Math.max(w-1,0)*e.gap:f+(Math.min(w,N)-1>0?(Math.min(w,N)-1)*I:0);o.style.height=w>0?`${k}px`:"0px",o.dataset.count=String(w),o.dataset.expanded=String(c)}let W=null;const O=()=>W||(W=Promise.resolve().then(()=>require("./AnimationUtils-Cp3BmULJ.cjs.js")).then(o=>o.animationManager)),H=o=>!!o&&o.type!=="css"&&o.type!=="custom",pe=o=>new Promise(e=>{requestAnimationFrame(()=>{o.classList.add("show"),window.setTimeout(e,220)})}),ge=o=>new Promise(e=>{o.classList.remove("show"),o.classList.add("hiding"),window.setTimeout(e,220)});async function j(o,e,t,s){if(H(s)){const i=await O();return o==="show"?i.showToast(e,t,s):i.hideToast(e,t,s)}if(s.type==="custom"){const i=o==="show"?s.show:s.hide;if(i)return void await Promise.resolve(i(e,t))}return o==="show"?pe(e):ge(e)}const R=o=>typeof Node!="undefined"&&o instanceof Node;function P(o,e,t){R(e)?o.appendChild(e):t?ne(o,e):o.textContent=e}function me(){const o=document.querySelector('meta[property="csp-nonce"]');return o&&(o.nonce||o.getAttribute("nonce")||o.content)||void 0}const be=o=>R(o)?o.textContent||"":o?String(o):"";class ve{constructor(e){this.containers=new Map,this.cssInjected=!1,this.toastOf=new WeakMap,this.holds=new Map,this.timing=new Map,this.returnFocusTo=null,this.globalListeners=[],this.resizeObserver=null,this.config=e,H(e.animation)&&O()}observeSize(e){if(typeof ResizeObserver=="undefined")return;if(!this.resizeObserver){const s=new Set;let i=0;this.resizeObserver=new ResizeObserver(r=>{for(const n of r){const a=n.target.closest(".editora-toast");a&&s.add(a)}i||(i=requestAnimationFrame(()=>{i=0;const n=new Set;s.forEach(a=>{V(a),a.parentElement&&n.add(a.parentElement)}),s.clear(),n.forEach(a=>this.layout(a))}))})}const t=e.querySelector(".editora-toast-content");t&&this.resizeObserver.observe(t)}updateConfig(e){H(e.animation)&&O(),this.config=e,this.containers.forEach((t,s)=>{this.applyContainerStyles(t,s),this.layout(t,!0)})}ensureContainer(e){if(this.containers.has(e))return this.containers.get(e);const t=document.createElement("div");return t.className=`editora-toast-container editora-toast-${e.replace("-","-")}`,t.setAttribute("role","region"),t.setAttribute("aria-label","Toast notifications"),t.setAttribute("aria-live","polite"),t.dataset.expand=String(this.config.expand),t.dataset.stack=String(this.config.stack),this.applyContainerStyles(t,e),this.attachContainerListeners(t),document.body.appendChild(t),this.containers.set(e,t),this.attachGlobalListeners(),this.injectCSS(),t}attachContainerListeners(e){e.addEventListener("mouseenter",()=>{e.dataset.hover="true",this.holdAll(e,"pointer"),this.syncOpen(e)}),e.addEventListener("pointerdown",t=>{t.pointerType!=="touch"||e.dataset.hover==="true"||(e.dataset.hover="true",this.holdAll(e,"pointer"),this.syncOpen(e))}),e.addEventListener("mouseleave",()=>{delete e.dataset.hover,this.releaseAll(e,"pointer"),this.syncOpen(e)}),e.addEventListener("focusin",t=>{this.isKeyboardFocus(t.target)&&(e.dataset.focus="true",this.holdAll(e,"focus"),this.syncOpen(e))}),e.addEventListener("focusout",t=>{const s=t.relatedTarget;s&&e.contains(s)||(delete e.dataset.focus,this.releaseAll(e,"focus"),this.syncOpen(e))}),e.addEventListener("keydown",t=>this.onContainerKey(e,t))}syncOpen(e){const t=e.dataset.hover==="true"||e.dataset.focus==="true";e.dataset.open=String(t),this.layout(e)}isKeyboardFocus(e){if(!(e instanceof Element))return!1;try{return e.matches(":focus-visible")}catch(t){return!0}}onContainerKey(e,t){if(t.key!=="Escape")return;const s=t.target instanceof Element?t.target.closest(".editora-toast"):null,i=s?this.toastOf.get(s):void 0;if(!s||!i)return;t.preventDefault();const r=Array.from(e.querySelectorAll(".editora-toast:not(.hiding)")),n=r[r.indexOf(s)+1]||r[r.indexOf(s)-1];i.dismiss(),n&&n!==s?n.focus():this.restoreFocus()}restoreFocus(){const e=this.returnFocusTo;this.returnFocusTo=null,e&&e.isConnected&&e.focus()}attachGlobalListeners(){if(this.globalListeners.length>0||typeof window=="undefined")return;const e=(t,s,i)=>{t.addEventListener(s,i),this.globalListeners.push([t,s,i])};e(document,"keydown",(t=>{if(!this.matchesHotkey(t))return;const s=Array.from(this.containers.values()).find(n=>n.querySelector(".editora-toast:not(.hiding)"));if(!s)return;const i=s.querySelector('.editora-toast[data-front="true"]');if(!i)return;t.preventDefault();const r=document.activeElement;r instanceof HTMLElement&&!s.contains(r)&&(this.returnFocusTo=r),i.focus()})),e(document,"pointerdown",(t=>{this.containers.forEach(s=>{s.dataset.hover==="true"&&!s.contains(t.target)&&(delete s.dataset.hover,this.releaseAll(s,"pointer"),this.syncOpen(s))})})),e(window,"resize",(()=>{window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>this.containers.forEach(t=>this.layout(t,!0)),120)}))}matchesHotkey(e){const t=this.config.hotkey;if(!t)return!1;const s=t.toLowerCase().split("+").map(n=>n.trim()).filter(Boolean),i=s.pop();if(!i)return!1;const r=n=>s.includes(n);return e.altKey!==r("alt")||e.shiftKey!==r("shift")||e.ctrlKey!==r("ctrl")||e.metaKey!==(r("meta")||r("cmd"))?!1:e.code.toLowerCase()===`key${i}`||e.code.toLowerCase()===i||e.key.toLowerCase()===i}layout(e,t=!1){fe(e,{stack:this.config.stack,expand:this.config.expand,gap:this.toPx(this.config.gap)},t)}toPx(e){if(typeof e=="number")return e;const t=parseFloat(e||"");return Number.isFinite(t)?t:8}holdAll(e,t){e.querySelectorAll(".editora-toast").forEach(s=>{const i=this.toastOf.get(s);if(!i)return;(t==="focus"?i.options.pauseOnFocus:i.options.pauseOnHover)!==!1&&this.pauseToast(i,t)})}releaseAll(e,t){e.querySelectorAll(".editora-toast").forEach(s=>{const i=this.toastOf.get(s);i&&this.resumeToast(i,t)})}createToastElement(e){const t=e.options,s=document.createElement("div");s.className=`editora-toast editora-toast-${t.level||"info"}`,s.dataset.level=t.level||"info",t.customClass&&t.customClass.split(/\s+/).filter(Boolean).forEach(a=>s.classList.add(a)),s.setAttribute("role",t.role||(t.level==="error"?"alert":"status")),s.setAttribute("aria-atomic","true"),s.tabIndex=0,(t.closable||t.closeButton)&&(s.dataset.closable="true"),this.toastOf.set(s,e),t.ariaLive&&t.ariaLive!=="off"&&s.setAttribute("aria-live",t.ariaLive);const i=t.theme||this.config.theme;i&&i!=="system"&&s.setAttribute("data-theme",i),(this.config.richColors||i==="colored")&&s.setAttribute("data-rich-colors","true"),(t.rtl!==void 0?t.rtl:this.config.rtl)&&(s.setAttribute("data-rtl","true"),s.setAttribute("dir","rtl"));const n=this.createContent(e);if(s.appendChild(n),t.actions&&t.actions.length>0){const a=document.createElement("div");a.className="editora-toast-actions",t.actions.forEach(c=>a.appendChild(this.createActionButton(c,e))),s.appendChild(a)}return(t.closable||t.closeButton)&&s.appendChild(this.createCloseButton(e)),t.swipeDismiss&&this.addSwipeDismiss(s,e),t.dragDismiss&&this.addDragDismiss(s,e),s}async showToast(e){var r,n;const t=this.ensureContainer(e.options.position||this.config.position),s=this.createToastElement(e);e.element=s,t.appendChild(s),t.dataset.hover==="true"&&e.options.pauseOnHover!==!1&&this.pauseToast(e,"pointer"),t.dataset.focus==="true"&&e.options.pauseOnFocus!==!1&&this.pauseToast(e,"focus"),this.layout(t);const i=e.options.animation||this.config.animation||{type:"css"};H(i)&&O(),this.observeSize(s),await j("show",s,e,i),this.config.enableAccessibility&&this.announceToast(e),(n=(r=e.options).onShow)==null||n.call(r),this.startTimer(e)}async hideToast(e){var r,n,a;if(!e.element)return;this.stopTimer(e),this.holds.delete(e.id);const t=e.element;t.dataset.leaving="true",t.parentElement&&this.layout(t.parentElement);const s=e.options.animation||this.config.animation||{type:"css"},i=t.querySelector(".editora-toast-content");if(i&&((r=this.resizeObserver)==null||r.unobserve(i)),await j("hide",t,e,s),e.element&&e.element.parentNode){const c=e.element.parentElement;e.element.parentNode.removeChild(e.element),e.element=void 0,c&&(c.querySelector(".editora-toast")||(delete c.dataset.hover,delete c.dataset.focus,c.dataset.open="false"),this.layout(c))}(a=(n=e.options).onHide)==null||a.call(n)}async updateToast(e,t){var r,n,a,c;if(!e.element)return;const s=e.options.animation||this.config.animation||{type:"css"};if(s.type==="custom"&&s.update){await Promise.resolve(s.update(e.element,e,t));return}if(Object.assign(e.options,t),t.level&&(e.element.className=e.element.className.replace(/editora-toast-(info|success|error|warning|loading|progress|promise|custom)/g,""),e.element.classList.add(`editora-toast-${t.level}`),e.element.dataset.level=t.level),t.title!==void 0||t.description!==void 0||t.message!==void 0||t.icon!==void 0||t.level!==void 0||t.render){const l=e.element.querySelector(".editora-toast-content"),f=this.createContent(e);l&&((r=this.resizeObserver)==null||r.unobserve(l)),l==null||l.replaceWith(f),this.observeSize(e.element)}const i=(n=t.closeButton)!=null?n:t.closable;if(i!==void 0){e.options.closable=i,e.options.closeButton=i,i?e.element.dataset.closable="true":delete e.element.dataset.closable;const l=e.element.querySelector(".editora-toast-close");i&&!l?e.element.appendChild(this.createCloseButton(e)):!i&&l&&l.remove()}if(t.progress!==void 0){const l=e.element.querySelector(".editora-toast-body"),f=e.element.querySelector(".editora-toast-progress-track");if(t.progress&&l){const m=this.createProgress(t.progress);f?f.replaceWith(m):l.appendChild(m)}else f&&f.remove()}if(t.actions!==void 0||t.action!==void 0||t.cancel!==void 0){let l=e.element.querySelector(".editora-toast-actions");const f=e.options.actions||[];f.length>0?(l?l.innerHTML="":(l=document.createElement("div"),l.className="editora-toast-actions",e.element.appendChild(l)),l&&f.forEach(m=>l.appendChild(this.createActionButton(m,e)))):l&&l.remove()}(t.duration!==void 0||t.persistent!==void 0||t.level!==void 0)&&this.startTimer(e),e.element.style.height="",V(e.element),e.element.parentElement&&this.layout(e.element.parentElement),(c=(a=e.options).onUpdate)==null||c.call(a,t)}createContent(e){const t=e.options,s=document.createElement("div");s.className="editora-toast-content";const i=this.createIcon(e);i&&s.appendChild(i);const r=document.createElement("div");if(r.className="editora-toast-body",t.render)r.appendChild(t.render(e));else{if(t.title){const n=document.createElement("div");n.className="editora-toast-title",P(n,t.title),r.appendChild(n)}if(t.message){const n=document.createElement("div");n.className="editora-toast-message",P(n,t.message,t.html),r.appendChild(n)}if(t.description){const n=document.createElement("div");n.className="editora-toast-description",P(n,t.description),r.appendChild(n)}}return t.progress&&r.appendChild(this.createProgress(t.progress)),s.appendChild(r),s}createProgress(e){const t=Math.min(100,Math.max(0,e.value)),s=document.createElement("div");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(t));const i=document.createElement("div");if(i.className="editora-toast-progress-bar",i.style.width=`${t}%`,e.showPercentage){const r=document.createElement("span");r.className="editora-toast-progress-text",r.textContent=`${Math.round(e.value)}%`,s.appendChild(r)}return s.appendChild(i),s}createCloseButton(e){const t=document.createElement("button");return t.className="editora-toast-close",t.setAttribute("type","button"),t.setAttribute("aria-label","Close notification"),t.appendChild(ce()),t.onclick=()=>e.dismiss(),t}createIcon(e){const t=e.options;if(t.icon===!1)return null;const s=document.createElement("span");if(s.className="editora-toast-icon",s.setAttribute("aria-hidden","true"),typeof t.icon=="string"&&t.icon)return s.textContent=t.icon,s;if(t.icon&&typeof t.icon=="object")return s.appendChild(t.icon),s;if(this.config.icons===!1)return null;const i=t.level||"info",r=le(i);return r?((i==="loading"||i==="promise")&&(s.dataset.spin="true"),s.appendChild(r),s):null}createActionButton(e,t){const s=document.createElement("button");return s.className=`editora-toast-action ${e.primary?"primary":""}`,s.textContent=e.label,e.altText&&s.setAttribute("aria-label",e.altText),s.onclick=i=>{i.stopPropagation(),e.onClick(),e.dismissOnClick!==!1&&t.dismiss()},s}applyContainerStyles(e,t){const s=this.toCssLength(this.config.offset),i=this.toCssLength(this.config.mobileOffset),r=this.toCssLength(this.config.gap);e.dataset.position=t,e.dataset.edge=t.startsWith("bottom")?"bottom":"top",e.dataset.expand=String(this.config.expand),e.dataset.stack=String(this.config.stack),e.style.setProperty("--editora-toast-offset",s),e.style.setProperty("--editora-toast-mobile-offset",i),e.style.setProperty("--editora-toast-gap",r),e.style.setProperty("--et-edge",t.startsWith("bottom")?"1":"-1");const n={position:"fixed",zIndex:(this.config.zIndex||2147483647).toString(),display:"block",width:"var(--et-width, 360px)",maxWidth:`calc(100vw - 2 * ${s})`,boxSizing:"border-box",top:"",right:"",bottom:"",left:"",transform:""};switch(t){case"top-left":n.top=`max(${s}, env(safe-area-inset-top))`,n.left=`max(${s}, env(safe-area-inset-left))`;break;case"top-center":n.top=`max(${s}, env(safe-area-inset-top))`,n.left="50%",n.transform="translateX(-50%)";break;case"top-right":n.top=`max(${s}, env(safe-area-inset-top))`,n.right=`max(${s}, env(safe-area-inset-right))`;break;case"bottom-left":n.bottom=`max(${s}, env(safe-area-inset-bottom))`,n.left=`max(${s}, env(safe-area-inset-left))`;break;case"bottom-center":n.bottom=`max(${s}, env(safe-area-inset-bottom))`,n.left="50%",n.transform="translateX(-50%)";break;case"bottom-right":n.bottom=`max(${s}, env(safe-area-inset-bottom))`,n.right=`max(${s}, env(safe-area-inset-right))`;break;case"center":n.top="50%",n.left="50%",n.transform="translate(-50%, -50%)";break}Object.assign(e.style,n),e.style.setProperty("--editora-toast-mobile-left",i)}toCssLength(e){return typeof e=="number"?`${e}px`:e||"16px"}startTimer(e){if(this.stopTimer(e),e.options.persistent||e.options.duration===0){this.timing.delete(e.id);return}this.arm(e,e.options.duration||this.config.duration)}arm(e,t){var s;this.timing.set(e.id,{remaining:t,startedAt:Date.now()}),!((((s=this.holds.get(e.id))==null?void 0:s.size)||0)>0)&&(e.timeoutId=window.setTimeout(()=>{e.timeoutId=void 0,e.dismiss()},t))}stopTimer(e){e.timeoutId&&(clearTimeout(e.timeoutId),e.timeoutId=void 0)}pauseToast(e,t="hover"){const s=this.holds.get(e.id)||new Set;if(this.holds.set(e.id,s),s.size===0&&e.timeoutId){const i=this.timing.get(e.id);this.stopTimer(e),i&&(i.remaining=Math.max(0,i.remaining-(Date.now()-i.startedAt)))}s.add(t)}resumeToast(e,t="hover"){const s=this.holds.get(e.id);if(!s||!s.delete(t)||s.size>0)return;this.holds.delete(e.id);const i=this.timing.get(e.id);i&&!e.timeoutId&&!e.options.persistent&&e.options.duration!==0&&this.arm(e,i.remaining)}addSwipeDismiss(e,t){let s=0,i=0,r=!1;const n=t.options.swipeDirection||this.config.swipeDirection||"any",a=40;let c="",l=!1;const f='button, a[href], input, select, textarea, label, summary, [role="button"], [contenteditable="true"]',m=()=>{e.style.transform=c,e.style.transition="",e.style.cursor="",e.style.userSelect=""},w=(u,b)=>{if("changedTouches"in u||"touches"in u){const p=b?u.changedTouches:u.touches,v=p&&p[0];return v?{x:v.clientX,y:v.clientY}:null}return{x:u.clientX,y:u.clientY}},k=u=>{const b=u.target;if(b instanceof Element&&e.contains(b)&&b.closest(f)||"button"in u&&u.button!==0)return;const p=w(u,!1);p&&(r=!0,l=!1,s=p.x,i=p.y,c=e.style.transform||"")},h=u=>{var y,z;if(!r)return;const b=w(u,!1);if(!b)return;const p=b.x-s,v=b.y-i,T=5;if(!l&&(Math.abs(p)>T||Math.abs(v)>T)&&(l=!0,e.style.transition="none",e.style.cursor="grabbing",e.style.userSelect="none",(z=(y=window.getSelection)==null?void 0:y.call(window))==null||z.removeAllRanges()),l){const E=Math.abs(v)>Math.abs(p)?25:20,Q=Math.min(Math.max(p*.2,-E),E),X=Math.min(Math.max(v*.2,-E),E);e.style.transform=`${c} translate(${Q}px, ${X}px)`,u.cancelable&&u.preventDefault()}},g=u=>{if(!r)return;r=!1;const b=l;if(m(),!b)return;const p=w(u,!0);if(!p)return;const v=p.x-s,T=p.y-i;let y=!1;const E=n==="vertical"||n==="up"||n==="down"?35:a;switch(n){case"any":y=Math.abs(v)>a||Math.abs(T)>a;break;case"horizontal":y=Math.abs(v)>a;break;case"vertical":y=Math.abs(T)>E;break;case"left":y=v<-a;break;case"right":y=v>a;break;case"up":y=T<-E;break;case"down":y=T>E;break}y&&t.dismiss()},L=()=>{r&&(r=!1,l=!1,m())};e.addEventListener("dragstart",u=>u.preventDefault()),e.addEventListener("touchstart",k,{passive:!0}),e.addEventListener("touchmove",h,{passive:!1}),e.addEventListener("touchend",g),e.addEventListener("touchcancel",L),e.addEventListener("mousedown",k),e.addEventListener("mousemove",h),e.addEventListener("mouseup",g),e.addEventListener("mouseleave",g)}addDragDismiss(e,t){this.addSwipeDismiss(e,t)}announceToast(e){if(e.options.ariaLive==="off")return;const t=document.createElement("div");t.setAttribute("aria-live",e.options.ariaLive||(e.options.level==="error"?"assertive":"polite")),t.setAttribute("aria-atomic","true"),t.style.position="absolute",t.style.left="-10000px",t.style.width="1px",t.style.height="1px",t.style.overflow="hidden";const s=[e.options.title,e.options.message,e.options.description].map(be).filter(Boolean).join(". ");t.textContent=`${e.options.level||"info"}: ${s}`,document.body.appendChild(t),setTimeout(()=>{t.remove()},1e3)}injectCSS(){if(this.cssInjected||typeof document=="undefined"||(this.cssInjected=!0,getComputedStyle(document.documentElement).getPropertyValue("--editora-toast-stylesheet").trim()!==""||Array.from(document.styleSheets).some(n=>{var a,c,l,f;return((c=(a=n.ownerNode)==null?void 0:a.href)==null?void 0:c.includes("toast.css"))||((f=(l=n.ownerNode)==null?void 0:l.textContent)==null?void 0:f.includes("editora-toast"))})))return;const s=document.createElement("style"),i=this.config.nonce||me();i&&(s.nonce=i);const r=this.config.injectStyles===!1?null:J();if(r){s.setAttribute("data-editora-toast",""),s.textContent=r,document.head.insertBefore(s,document.head.firstChild);return}console.warn("[@editora/toast] toast.css is not loaded, so toasts use a minimal fallback style. Import '@editora/toast/toast.css' once in your app (or link @editora/toast/dist/toast.css)."),s.setAttribute("data-editora-toast-fallback","true"),s.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(s)}destroy(){var e;(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this.globalListeners.forEach(([t,s,i])=>t.removeEventListener(s,i)),this.globalListeners=[],window.clearTimeout(this.resizeTimer),this.containers.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.containers.clear()}}class ye{constructor(){this.plugins=[],this.hooks={beforeShow:[],afterShow:[],beforeHide:[],afterHide:[],beforeUpdate:[],afterUpdate:[]}}use(e){if(this.plugins.find(t=>t.name===e.name)){console.warn(`Plugin "${e.name}" is already installed`);return}this.plugins.push(e),e.install(this)}remove(e){const t=this.plugins.findIndex(i=>i.name===e);if(t===-1)return!1;const s=this.plugins[t];return s.uninstall&&s.uninstall(this),this.plugins.splice(t,1),!0}getPlugins(){return[...this.plugins]}on(e,t){this.hooks[e]&&this.hooks[e].push(t)}off(e,t){if(this.hooks[e]){const s=this.hooks[e].indexOf(t);s!==-1&&this.hooks[e].splice(s,1)}}async trigger(e,t,...s){const i=this.hooks[e];if(!(!i||i.length===0))for(const r of i)try{await r(t,...s)}catch(n){console.error(`Error in ${e} hook:`,n)}}async beforeShow(e){await this.trigger("beforeShow",e)}async afterShow(e){await this.trigger("afterShow",e)}async beforeHide(e){await this.trigger("beforeHide",e)}async afterHide(e){await this.trigger("afterHide",e)}async beforeUpdate(e,t){await this.trigger("beforeUpdate",e,t)}async afterUpdate(e,t){await this.trigger("afterUpdate",e,t)}onEditorEvent(e,t){const s=`editor:${e}`;this.hooks[s]||(this.hooks[s]=[]),this.hooks[s].push(t)}triggerEditorEvent(e,t,...s){const i=`editor:${e}`;this.trigger(i,t,...s)}async handlePromise(e,t,s,i){t();try{const r=await e;return s(r),r}catch(r){throw i(r),r}}async batchShow(e){const t=e.map(i=>this.beforeShow(i));await Promise.all(t);const s=e.map(i=>this.afterShow(i));await Promise.all(s)}async batchHide(e){const t=e.map(i=>this.beforeHide(i));await Promise.all(t);const s=e.map(i=>this.afterHide(i));await Promise.all(s)}destroy(){this.plugins.forEach(e=>{e.uninstall&&e.uninstall(this)}),this.plugins=[],Object.keys(this.hooks).forEach(e=>{this.hooks[e]=[]})}}const we=o=>typeof Node!="undefined"&&o instanceof Node,G={position:"bottom-right",duration:4e3,maxVisible:3,queueStrategy:"fifo",theme:"system",richColors:!1,expand:!1,stack:!0,offset:16,mobileOffset:16,gap:8,pauseOnHover:!0,pauseOnFocus:!0,pauseOnWindowBlur:!1,swipeDismiss:!0,swipeDirection:"any",dragDismiss:!1,rtl:!1,enableAccessibility:!0,closeButton:!1,icons:!0,hotkey:"alt+t",preventDuplicate:!1,dedupeScope:"all",animation:{type:"css"}};class q{constructor(e={}){this.idCounter=0,this.pendingShows=new Map,this.subscribers=new Set,this.config=this.normalizeConfig({...G,...e}),this.store=new Z(this.config),this.queue=new ee(this.config),this.renderer=new ve(this.config),this.lifecycle=new ye,this.setupWindowFocusHandling()}show(e){const t=e.id||`toast-${++this.idCounter}`,s={id:t,options:this.normalizeToastOptions({...this.config,...e},e),createdAt:Date.now(),dismiss:()=>this.dismiss(t),update:n=>this.update(t,n)},i=this.lifecycle.beforeShow(s).then(async()=>{const n=this.queue.enqueue(s);n.rejected||(this.store.addToast(s),await this.hideToasts(n.hide,!0),await this.showToasts(n.show),this.notify())});this.pendingShows.set(t,i);const r=()=>{this.pendingShows.get(t)===i&&this.pendingShows.delete(t)};return i.then(r,r),s}update(e,t){const s=this.pendingShows.get(e);if(s)return s.then(()=>this.update(e,t),()=>{}),!0;const i=this.store.getToast(e);return i?(this.lifecycle.beforeUpdate(i,t).then(async()=>{const r=this.normalizeToastOptions({...i.options,...t},t);this.store.updateToast(e,{options:r}),this.queue.isVisible(e)&&await this.renderer.updateToast(i,t),this.lifecycle.afterUpdate(i,t),this.notify()}),!0):!1}dismiss(e){const t=this.pendingShows.get(e);if(t)return t.then(()=>this.dismiss(e),()=>{}),!0;const s=this.store.getToast(e);return s?(this.lifecycle.beforeHide(s).then(async()=>{const i=this.queue.isVisible(e),r=this.queue.dequeue(e);i&&await this.renderer.hideToast(s),this.store.removeToast(e),this.lifecycle.afterHide(s),await this.showToasts(r.show),this.notify()}),!0):!1}clear(){const e=this.queue.clear();Promise.all(e.map(t=>this.hideOne(t,!1))).then(()=>{this.store.clear(),this.notify()})}async promise(e,t){var i,r;const s=this.show({duration:0,...this.normalizeOptions(t.loading,"loading")});try{const n=await e,a=this.normalizeResult(typeof t.success=="function"?t.success(n):t.success,"success");return a.duration===void 0&&!a.persistent&&(a.duration=this.config.duration),this.update(s.id,a),(i=t.onSuccess)==null||i.call(t,n),n}catch(n){const a=this.normalizeResult(typeof t.error=="function"?t.error(n):t.error,"error");throw a.duration===void 0&&!a.persistent&&(a.duration=this.config.duration),this.update(s.id,a),(r=t.onError)==null||r.call(t,n),n}}group(e,t){return this.show({...t,group:e})}use(e){this.lifecycle.use(e)}configure(e){const t=this.config.pauseOnWindowBlur,s={...this.config,...e};e.maxVisible!==void 0&&e.visibleToasts===void 0&&delete s.visibleToasts,this.config=this.normalizeConfig(s),this.store.updateConfig(this.config),this.renderer.updateConfig(this.config);const i=this.queue.updateConfig(this.config);this.hideToasts(i.hide,!0).then(()=>this.showToasts(i.show)).then(()=>this.notify()),e.pauseOnWindowBlur!==void 0&&e.pauseOnWindowBlur!==t&&(this.teardownWindowFocusHandling(),this.setupWindowFocusHandling())}getConfig(){return{...this.config}}getToasts(){return this.store.getAllToasts()}getState(){return{toasts:this.store.getAllToasts(),visible:this.queue.getVisible(),queued:this.queue.getQueued(),groups:this.store.getAllGroups(),config:this.getConfig()}}subscribe(e){return this.subscribers.add(e),e(this.getState()),()=>{this.subscribers.delete(e)}}getGroups(){return this.store.getAllGroups()}info(e,t){return this.show({message:e,level:"info",duration:t})}success(e,t){return this.show({message:e,level:"success",duration:t})}error(e,t){return this.show({message:e,level:"error",duration:t})}warning(e,t){return this.show({message:e,level:"warning",duration:t})}loading(e,t){return this.show({message:e,level:"loading",duration:t})}normalizeOptions(e,t){return typeof e=="string"||we(e)?{message:e,level:t}:{...e,level:e.level||t}}normalizeResult(e,t){const s=this.normalizeOptions(e,t);return"message"in s?s:{...s,message:void 0}}normalizeConfig(e){const t=e.visibleToasts||e.maxVisible||G.maxVisible;return{...e,maxVisible:t,visibleToasts:t}}normalizeToastOptions(e,t=e){var n,a,c,l,f,m;const s=(l=(c=(a=(n=t.closeButton)!=null?n:t.closable)!=null?a:e.closable)!=null?c:e.closeButton)!=null?l:this.config.closeButton,i=e.action?{...e.action,primary:(f=e.action.primary)!=null?f:!0}:void 0,r=[...i?[i]:[],...e.cancel?[e.cancel]:[],...e.actions||[]];return{...e,closable:s,closeButton:s,actions:r.length>0?r:void 0,ariaLive:e.ariaLive||(e.level==="error"||e.important?"assertive":"polite"),role:e.role||(e.level==="error"||e.important?"alert":"status"),preventDuplicate:(m=e.preventDuplicate)!=null?m:this.config.preventDuplicate,dedupeScope:e.dedupeScope||this.config.dedupeScope}}async showToasts(e){for(const t of e)await this.renderer.showToast(t),await this.lifecycle.afterShow(t)}async hideToasts(e,t){for(const s of e)await this.hideOne(s,t)}async hideOne(e,t){await this.lifecycle.beforeHide(e),await this.renderer.hideToast(e),t&&this.store.removeToast(e.id),await this.lifecycle.afterHide(e)}notify(){if(this.subscribers.size===0)return;const e=this.getState();this.subscribers.forEach(t=>t(e))}onEditorEvent(e,t){this.lifecycle.onEditorEvent(e,t)}triggerEditorEvent(e,t,...s){this.lifecycle.triggerEditorEvent(e,t,...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=>this.renderer.pauseToast(e,"window"))}resumeAllToasts(){this.store.getAllToasts().forEach(e=>this.renderer.resumeToast(e,"window"))}destroy(){this.teardownWindowFocusHandling(),this.clear(),this.renderer.destroy(),this.lifecycle.destroy()}}let C=null;function d(){return C||(C=new q),C}const Ee=o=>({id:o.id||"",options:o,createdAt:0,dismiss:()=>{},update:()=>{}});function B(o){return typeof document=="undefined"?Ee(o):d().show(o)}function U(o,e,t,s){let i={};e&&typeof e=="object"?i={...e}:typeof e=="number"&&(i.duration=e),t&&(i.theme=t),s&&(i.position=s);const r={message:o,...i,level:i.level||void 0};return i.duration!==void 0&&(r.duration=i.duration),i.position&&(r.position=i.position),i.theme&&(r.theme=i.theme),r}function x(o){return(e,t,s,i)=>B({...U(e,t,s,i),level:o})}const S=()=>typeof document!="undefined";function Te(o,e,t,s){const i=U(o,e,t,s);return B({...i,level:i.level||"custom"})}const $=Object.assign(Te,{info:x("info"),success:x("success"),error:x("error"),warning:x("warning"),loading:x("loading"),show:o=>B(o),promise:(o,e)=>S()?d().promise(o,e):o,update:(o,e)=>S()?d().update(o,e):!1,dismiss:o=>S()?o===void 0?(d().clear(),!0):d().dismiss(o):!1,clear:()=>{S()&&d().clear()},configure:o=>{S()&&d().configure(o)}}),A={show:o=>d().show(o),update:(o,e)=>d().update(o,e),dismiss:o=>d().dismiss(o),clear:()=>d().clear(),info:(o,e)=>d().show({message:o,level:"info",...e}),success:(o,e)=>d().show({message:o,level:"success",...e}),error:(o,e)=>d().show({message:o,level:"error",...e}),warning:(o,e)=>d().show({message:o,level:"warning",...e}),loading:(o,e)=>d().show({message:o,level:"loading",...e}),promise:(o,e)=>d().promise(o,e),group:(o,e)=>d().group(o,e),configure:o=>d().configure(o),use:o=>d().use(o),getToasts:()=>d().getToasts(),getGroups:()=>d().getGroups(),getConfig:()=>d().getConfig(),getState:()=>d().getState(),subscribe:o=>d().subscribe(o),onEditorEvent:(o,e)=>d().onEditorEvent(o,e),triggerEditorEvent:(o,e,...t)=>d().triggerEditorEvent(o,e,...t),destroy:()=>{C&&(C.destroy(),C=null)}};if(typeof window!="undefined"&&typeof document!="undefined"){const o=window;o.toast=$,o.toastAdvanced=A,o.toastPro=A,o.ToastManager=q,o.__editoraToastReady||(o.__editoraToastReady=!0,window.dispatchEvent(new CustomEvent("toastReady",{detail:{toast:$,toastAdvanced:A,toastPro:A,ToastManager:q}})))}exports.ToastManager=q;exports.provideStyles=Y;exports.toast=$;exports.toastAdvanced=A;
2
+ //# sourceMappingURL=toast-1p-XtLiV.cjs.js.map