juice-toast 1.4.4-beta.2 → 1.4.4
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/API.md +15 -0
- package/CHANGELOG.md +11 -1
- package/CONTRIBUTING.md +1 -1
- package/README.md +13 -2
- package/dist/juice-toast.esm.js +29 -204
- package/dist/juice-toast.umd.js +29 -204
- package/package.json +4 -1
package/API.md
CHANGED
|
@@ -311,6 +311,21 @@ juiceToast.success({
|
|
|
311
311
|
});
|
|
312
312
|
```
|
|
313
313
|
|
|
314
|
+
# Urgent Skip Queue
|
|
315
|
+
```js
|
|
316
|
+
juiceToast.setup({
|
|
317
|
+
urgentSkipsQueue: true
|
|
318
|
+
});
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
# Utility
|
|
322
|
+
```js
|
|
323
|
+
juiceToast.pauseAll();
|
|
324
|
+
juiceToast.resumeAll();
|
|
325
|
+
juiceToast.dismissAll();
|
|
326
|
+
juiceToast.listActive(filter);
|
|
327
|
+
```
|
|
328
|
+
|
|
314
329
|
---
|
|
315
330
|
|
|
316
331
|
# License
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
## v1.4.4
|
|
1
|
+
## v1.4.4 (Stable)
|
|
2
|
+
- Fix priority queue
|
|
3
|
+
- Reduce memory leak's
|
|
4
|
+
- Fix documentation
|
|
5
|
+
|
|
6
|
+
v1.4.3 LTS / v1.4.4 (Final)
|
|
7
|
+
- Fix priority queue
|
|
8
|
+
- Fix Promise
|
|
9
|
+
- Adding `urgentSkipsQueue`
|
|
10
|
+
|
|
11
|
+
v1.4.4 Pack 1 (Beta 2)
|
|
2
12
|
- Fix Parallax, 3D Mode, Promise, & Toast Animation
|
|
3
13
|
- Adding `pauseAll()`, `resumeAll()` & `listActive(filter)`
|
|
4
14
|
- Fix RAF
|
package/CONTRIBUTING.md
CHANGED
|
@@ -62,4 +62,4 @@ git push origin feature/your-feature-name
|
|
|
62
62
|
## Code of Conduct
|
|
63
63
|
Read the [Code Of Conduct](https://github.com/KhairyK/juiceToast/blob/main/CODE_OF_CONDUCT.md)
|
|
64
64
|
|
|
65
|
-
2026 (C) OpenDN Foundation / Released under Atrosfer 1.
|
|
65
|
+
2026 (C) OpenDN Foundation / Released under Atrosfer 1.0 LICENSE
|
package/README.md
CHANGED
|
@@ -41,12 +41,18 @@ It supports **UMD & ESM**, **dynamic toast types**, **theme management**, **queu
|
|
|
41
41
|
- 🧩 Plugin system
|
|
42
42
|
- ♿ Accessible (ARIA + focus/hover pause)
|
|
43
43
|
|
|
44
|
+
Try a new [React JuiceToast](https://npmjs.com/package/@juice-toast/plugins-react) plugin!
|
|
45
|
+
|
|
44
46
|
---
|
|
45
47
|
|
|
46
48
|
## 📦 Installation
|
|
47
49
|
|
|
48
50
|
### NPM
|
|
49
51
|
```bash
|
|
52
|
+
npm install juice-toast --no-optional
|
|
53
|
+
```
|
|
54
|
+
#### With Optional (React Plugins)
|
|
55
|
+
```bash
|
|
50
56
|
npm install juice-toast
|
|
51
57
|
```
|
|
52
58
|
|
|
@@ -321,6 +327,10 @@ juiceToast.setup({
|
|
|
321
327
|
```js
|
|
322
328
|
juiceToast.clear(); // Clear queue
|
|
323
329
|
juiceToast.destroy(); // Remove all toast roots
|
|
330
|
+
juiceToast.pauseAll(); // Pause all toast
|
|
331
|
+
juiceToast.resumeAll(); // Resume all toast
|
|
332
|
+
juiceToast.dismissAll(); // Dismiss all toast
|
|
333
|
+
juiceToast.listActive(filter); // See all active toast
|
|
324
334
|
```
|
|
325
335
|
|
|
326
336
|
## Modal
|
|
@@ -356,7 +366,6 @@ juiceToast.modal({
|
|
|
356
366
|
| Avatar Support | ✅ | ❌ | ❌ |
|
|
357
367
|
| Custom Themes | ✅ | ✅ | Limited |
|
|
358
368
|
| Modal Support | ✅ | ✅ | ❌ |
|
|
359
|
-
| Designed for Toast Only | ✅ | ❌ (modal-focused) | ✅ |
|
|
360
369
|
|
|
361
370
|
### Compared to SweetAlert2
|
|
362
371
|
|
|
@@ -416,4 +425,6 @@ JuiceToast gives you:
|
|
|
416
425
|
- Plugins
|
|
417
426
|
- Advanced control
|
|
418
427
|
- Performance focus
|
|
419
|
-
- Clean modern UI
|
|
428
|
+
- Clean modern UI
|
|
429
|
+
|
|
430
|
+
:)
|
package/dist/juice-toast.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ke=Object.defineProperty,
|
|
1
|
+
var ke=Object.defineProperty,Ee=Object.defineProperties,we=Object.getOwnPropertyDescriptors,W=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,me=(e,a,t)=>a in e?ke(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,ie=(e,a)=>{for(var t in a||(a={}))pe.call(a,t)&&me(e,t,a[t]);if(W)for(var t of W(a))he.call(a,t)&&me(e,t,a[t]);return e},ne=(e,a)=>Ee(e,we(a)),Se=(e,a)=>{var t={};for(var n in e)pe.call(e,n)&&a.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&W)for(var n of W(e))a.indexOf(n)<0&&he.call(e,n)&&(t[n]=e[n]);return t};const C=typeof window!="undefined"&&typeof document!="undefined",z=C&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;class Q{constructor(){this._heap=[]}get size(){return this._heap.length}_parent(a){return Math.floor((a-1)/2)}_left(a){return 2*a+1}_right(a){return 2*a+2}_swap(a,t){[this._heap[a],this._heap[t]]=[this._heap[t],this._heap[a]]}push(a,t=0){const n={item:a,priority:t,seq:Q._seq=(Q._seq||0)+1};this._heap.push(n),this._siftUp(this._heap.length-1)}pop(){if(!this._heap.length)return null;this._swap(0,this._heap.length-1);const a=this._heap.pop();return this._siftDown(0),a.item}peek(){return this._heap[0]?this._heap[0].item:null}_siftUp(a){for(;a>0;){const t=this._parent(a);if(this._compare(a,t)<=0)break;this._swap(a,t),a=t}}_siftDown(a){for(;;){const t=this._left(a),n=this._right(a),c=this._heap.length;let r=a;if(t<c&&this._compare(t,r)>0&&(r=t),n<c&&this._compare(n,r)>0&&(r=n),r===a)break;this._swap(a,r),a=r}}_compare(a,t){const n=this._heap[a],c=this._heap[t];return n.priority!==c.priority?n.priority-c.priority:c.seq-n.seq}}let fe=!1;const B=`
|
|
2
2
|
:root{
|
|
3
3
|
--jt-radius:10px;
|
|
4
4
|
--jt-bg1:rgba(30,30,30,.95);
|
|
@@ -17,41 +17,35 @@ var ke=Object.defineProperty,we=Object.defineProperties,Se=Object.getOwnProperty
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/* POSITIONS */
|
|
20
|
-
|
|
21
20
|
[data-juice-root][data-position="bottom-right"]{
|
|
22
21
|
bottom:20px;
|
|
23
22
|
right:20px;
|
|
24
23
|
flex-direction:column-reverse;
|
|
25
24
|
align-items:flex-end;
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
[data-juice-root][data-position="top-right"]{
|
|
29
27
|
top:20px;
|
|
30
28
|
right:20px;
|
|
31
29
|
flex-direction:column;
|
|
32
30
|
align-items:flex-end;
|
|
33
31
|
}
|
|
34
|
-
|
|
35
32
|
[data-juice-root][data-position="bottom-left"]{
|
|
36
33
|
bottom:20px;
|
|
37
34
|
left:20px;
|
|
38
35
|
flex-direction:column-reverse;
|
|
39
36
|
align-items:flex-start;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
[data-juice-root][data-position="top-left"]{
|
|
43
39
|
top:20px;
|
|
44
40
|
left:20px;
|
|
45
41
|
flex-direction:column;
|
|
46
42
|
align-items:flex-start;
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
[data-juice-root][data-position="top-center"]{
|
|
50
45
|
top:20px;
|
|
51
46
|
left:50%;
|
|
52
47
|
transform:translateX(-50%);
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
[data-juice-root][data-position="bottom-center"]{
|
|
56
50
|
bottom:20px;
|
|
57
51
|
left:50%;
|
|
@@ -59,7 +53,6 @@ var ke=Object.defineProperty,we=Object.defineProperties,Se=Object.getOwnProperty
|
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
/* TOAST */
|
|
62
|
-
|
|
63
56
|
.juice-toast{
|
|
64
57
|
pointer-events:auto;
|
|
65
58
|
min-width:220px;
|
|
@@ -89,247 +82,79 @@ var ke=Object.defineProperty,we=Object.defineProperties,Se=Object.getOwnProperty
|
|
|
89
82
|
}
|
|
90
83
|
|
|
91
84
|
/* STACK DEPTH FEATURE */
|
|
92
|
-
|
|
93
85
|
.juice-toast[data-stack="1"]{--jt-stack-scale:.97;opacity:.95}
|
|
94
86
|
.juice-toast[data-stack="2"]{--jt-stack-scale:.94;opacity:.9}
|
|
95
87
|
.juice-toast[data-stack="3"]{--jt-stack-scale:.91;opacity:.85}
|
|
96
88
|
|
|
97
89
|
/* SHOW/HIDE */
|
|
98
|
-
|
|
99
90
|
@keyframes jt-slide-in{
|
|
100
91
|
from{opacity:0;transform:translateY(20px) scale(.98)}
|
|
101
92
|
to{opacity:1;transform:translateY(0) scale(1)}
|
|
102
93
|
}
|
|
103
|
-
|
|
104
94
|
@keyframes jt-slide-out{
|
|
105
95
|
from{opacity:1;transform:translateY(0) scale(1)}
|
|
106
96
|
to{opacity:0;transform:translateY(20px) scale(.98)}
|
|
107
97
|
}
|
|
108
|
-
|
|
109
98
|
.juice-toast.show{
|
|
110
99
|
animation:jt-slide-in .32s cubic-bezier(.4,0,.2,1) forwards;
|
|
111
100
|
}
|
|
112
|
-
|
|
113
101
|
.juice-toast.hide{
|
|
114
102
|
animation:jt-slide-out .28s cubic-bezier(.4,0,.2,1) forwards;
|
|
115
103
|
pointer-events:none;
|
|
116
104
|
}
|
|
117
105
|
|
|
118
106
|
/* MICRO ANIMATIONS */
|
|
119
|
-
|
|
120
|
-
@keyframes jt-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@keyframes jt-shake{
|
|
126
|
-
0%,100%{transform:translateX(0)}
|
|
127
|
-
25%{transform:translateX(-6px)}
|
|
128
|
-
75%{transform:translateX(6px)}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
@keyframes jt-pulse{
|
|
132
|
-
0%,100%{transform:scale(1)}
|
|
133
|
-
50%{transform:scale(1.03)}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@keyframes jt-spin{
|
|
137
|
-
from{transform:rotate(0deg)}
|
|
138
|
-
to{transform:rotate(360deg)}
|
|
139
|
-
}
|
|
140
|
-
|
|
107
|
+
@keyframes jt-bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}
|
|
108
|
+
@keyframes jt-shake{0%,100%{transform:translateX(0)}25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
|
|
109
|
+
@keyframes jt-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.03)}}
|
|
110
|
+
@keyframes jt-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
|
|
141
111
|
.jt-spin{animation:jt-spin 1.5s linear infinite}
|
|
142
112
|
.jt-pulse{animation:jt-pulse 1.2s ease-in-out}
|
|
143
113
|
|
|
144
114
|
/* ICON */
|
|
145
|
-
|
|
146
115
|
.juice-toast .icon{
|
|
147
|
-
width:30px;
|
|
148
|
-
height:30px;
|
|
149
|
-
display:flex;
|
|
150
|
-
align-items:center;
|
|
151
|
-
justify-content:center;
|
|
152
|
-
border-radius:8px;
|
|
153
|
-
background:rgba(255,255,255,.06);
|
|
116
|
+
width:30px;height:30px;display:flex;align-items:center;justify-content:center;border-radius:8px;background:rgba(255,255,255,.06);
|
|
154
117
|
}
|
|
155
118
|
|
|
156
119
|
/* CONTENT */
|
|
157
|
-
|
|
158
|
-
.jt-
|
|
159
|
-
|
|
160
|
-
flex-direction:column;
|
|
161
|
-
gap:4px;
|
|
162
|
-
flex:1;
|
|
163
|
-
min-width:0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.jt-title{
|
|
167
|
-
font-weight:700;
|
|
168
|
-
font-size:13px;
|
|
169
|
-
white-space:nowrap;
|
|
170
|
-
overflow:hidden;
|
|
171
|
-
text-overflow:ellipsis;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.jt-message{
|
|
175
|
-
font-size:13px;
|
|
176
|
-
opacity:.95;
|
|
177
|
-
word-break:break-word;
|
|
178
|
-
}
|
|
120
|
+
.jt-content{display:flex;flex-direction:column;gap:4px;flex:1;min-width:0;}
|
|
121
|
+
.jt-title{font-weight:700;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
|
122
|
+
.jt-message{font-size:13px;opacity:.95;word-break:break-word;}
|
|
179
123
|
|
|
180
124
|
/* ACTIONS */
|
|
181
|
-
|
|
182
|
-
.jt-
|
|
183
|
-
display:flex;
|
|
184
|
-
gap:8px;
|
|
185
|
-
margin-top:10px;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.jt-action{
|
|
189
|
-
border:1px solid currentColor;
|
|
190
|
-
padding:4px 10px;
|
|
191
|
-
border-radius:6px;
|
|
192
|
-
font-size:12px;
|
|
193
|
-
cursor:pointer;
|
|
194
|
-
background:transparent;
|
|
195
|
-
}
|
|
125
|
+
.jt-actions{display:flex;gap:8px;margin-top:10px;}
|
|
126
|
+
.jt-action{border:1px solid currentColor;padding:4px 10px;border-radius:6px;font-size:12px;cursor:pointer;background:transparent;}
|
|
196
127
|
|
|
197
128
|
/* PROGRESS */
|
|
198
|
-
|
|
199
|
-
.jt-progress{
|
|
200
|
-
position:absolute;
|
|
201
|
-
left:0;
|
|
202
|
-
bottom:0;
|
|
203
|
-
height:4px;
|
|
204
|
-
width:100%;
|
|
205
|
-
border-radius:2px;
|
|
206
|
-
background:linear-gradient(90deg,#4ade80,#22c55e);
|
|
207
|
-
transform-origin:left;
|
|
208
|
-
transform:scaleX(1);
|
|
209
|
-
transition:transform linear;
|
|
210
|
-
}
|
|
129
|
+
.jt-progress{position:absolute;left:0;bottom:0;height:4px;width:100%;border-radius:2px;background:linear-gradient(90deg,#4ade80,#22c55e);transform-origin:left;transform:scaleX(1);transition:transform linear;}
|
|
211
130
|
|
|
212
131
|
/* SWIPE */
|
|
213
|
-
|
|
214
|
-
.juice-toast.swipe-dismissing{
|
|
215
|
-
opacity:0;
|
|
216
|
-
transition:transform .22s ease-out,opacity .22s ease-out;
|
|
217
|
-
}
|
|
132
|
+
.juice-toast.swipe-dismissing{opacity:0;transition:transform .22s ease-out,opacity .22s ease-out;}
|
|
218
133
|
|
|
219
134
|
/* AVATAR */
|
|
220
|
-
|
|
221
|
-
.jt-avatar{
|
|
222
|
-
width:36px;
|
|
223
|
-
height:36px;
|
|
224
|
-
border-radius:50%;
|
|
225
|
-
object-fit:cover;
|
|
226
|
-
flex-shrink:0;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.juice-toast.jt-avatar-top{
|
|
230
|
-
flex-direction:column;
|
|
231
|
-
align-items:flex-start;
|
|
232
|
-
}
|
|
135
|
+
.jt-avatar{width:36px;height:36px;border-radius:50%;object-fit:cover;flex-shrink:0;}
|
|
136
|
+
.juice-toast.jt-avatar-top{flex-direction:column;align-items:flex-start;}
|
|
233
137
|
|
|
234
138
|
/* MODAL */
|
|
235
|
-
|
|
236
|
-
.jt-modal-overlay{
|
|
237
|
-
position:fixed;
|
|
238
|
-
inset:0;
|
|
239
|
-
display:flex;
|
|
240
|
-
align-items:center;
|
|
241
|
-
justify-content:center;
|
|
242
|
-
padding:20px;
|
|
243
|
-
background:rgba(15,23,42,.55);
|
|
244
|
-
backdrop-filter:blur(6px) saturate(120%);
|
|
245
|
-
opacity:0;
|
|
246
|
-
transition:opacity .25s ease;
|
|
247
|
-
z-index:10000;
|
|
248
|
-
}
|
|
249
|
-
|
|
139
|
+
.jt-modal-overlay{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.55);backdrop-filter:blur(6px) saturate(120%);opacity:0;transition:opacity .25s ease;z-index:10000;}
|
|
250
140
|
.jt-modal-overlay.show{opacity:1}
|
|
251
|
-
|
|
252
|
-
.jt-modal{
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
will-change:transform,opacity;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.jt-modal.show{
|
|
264
|
-
opacity:1;
|
|
265
|
-
transform:translateY(0) scale(1);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
.jt-modal-btn{
|
|
269
|
-
padding:8px 14px;
|
|
270
|
-
border-radius:8px;
|
|
271
|
-
font-size:14px;
|
|
272
|
-
cursor:pointer;
|
|
273
|
-
border:none;
|
|
274
|
-
transition:all .18s ease;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/* PRIMARY */
|
|
278
|
-
|
|
279
|
-
.jt-modal-btn.primary{
|
|
280
|
-
background:#3b82f6;
|
|
281
|
-
color:#fff;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
.jt-modal-btn.primary:hover{
|
|
285
|
-
background:#2563eb;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/* SECONDARY */
|
|
289
|
-
|
|
290
|
-
.jt-modal-btn.secondary{
|
|
291
|
-
background:#e5e7eb;
|
|
292
|
-
color:#111;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.jt-modal-btn.secondary:hover{
|
|
296
|
-
background:#d1d5db;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/* OUTLINE */
|
|
300
|
-
|
|
301
|
-
.jt-modal-btn.outline{
|
|
302
|
-
background:transparent;
|
|
303
|
-
border:1px solid currentColor;
|
|
304
|
-
color:inherit;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
.jt-modal-btn.outline:hover{
|
|
308
|
-
background:rgba(255,255,255,.06);
|
|
309
|
-
}
|
|
141
|
+
.jt-modal{width:100%;max-width:520px;border-radius:18px;padding:24px;opacity:0;transform:translateY(40px) scale(.96);transition:transform .35s cubic-bezier(.16,1,.3,1),opacity .25s ease;will-change:transform,opacity;}
|
|
142
|
+
.jt-modal.show{opacity:1;transform:translateY(0) scale(1);}
|
|
143
|
+
.jt-modal-btn{padding:8px 14px;border-radius:8px;font-size:14px;cursor:pointer;border:none;transition:all .18s ease;}
|
|
144
|
+
.jt-modal-btn.primary{background:#3b82f6;color:#fff}
|
|
145
|
+
.jt-modal-btn.primary:hover{background:#2563eb}
|
|
146
|
+
.jt-modal-btn.secondary{background:#e5e7eb;color:#111}
|
|
147
|
+
.jt-modal-btn.secondary:hover{background:#d1d5db}
|
|
148
|
+
.jt-modal-btn.outline{background:transparent;border:1px solid currentColor;color:inherit}
|
|
149
|
+
.jt-modal-btn.outline:hover{background:rgba(255,255,255,.06)}
|
|
310
150
|
|
|
311
151
|
/* PARALLAX */
|
|
312
|
-
|
|
313
|
-
[data-juice-root][data-parallax="true"] .juice-toast{
|
|
314
|
-
transition:transform .12s cubic-bezier(.2,.8,.2,1),opacity .2s;
|
|
315
|
-
}
|
|
152
|
+
[data-juice-root][data-parallax="true"] .juice-toast{transition:transform .12s cubic-bezier(.2,.8,.2,1),opacity .2s;}
|
|
316
153
|
|
|
317
154
|
/* GLASS FEATURE */
|
|
318
|
-
|
|
319
|
-
[data-juice-root][data-glass="true"] .juice-toast{
|
|
320
|
-
background:rgba(30,30,30,.55);
|
|
321
|
-
backdrop-filter:blur(14px) saturate(140%);
|
|
322
|
-
border:1px solid rgba(255,255,255,.08);
|
|
323
|
-
}
|
|
155
|
+
[data-juice-root][data-glass="true"] .juice-toast{background:rgba(30,30,30,.55);backdrop-filter:blur(14px) saturate(140%);border:1px solid rgba(255,255,255,.08);}
|
|
324
156
|
|
|
325
157
|
/* REDUCED MOTION */
|
|
326
|
-
|
|
327
|
-
@media (prefers-reduced-motion:reduce){
|
|
328
|
-
.juice-toast,
|
|
329
|
-
.jt-modal{
|
|
330
|
-
animation:none!important;
|
|
331
|
-
transition:none!important;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
`;function ie(e=Q){if(!P||fe||(fe=!0,document.getElementById("juice-toast-style")))return;const a=document.createElement("style");a.id="juice-toast-style",a.textContent=e,document.head.appendChild(a)}const le=(()=>{let e=1;return()=>"jt-"+Date.now().toString(36)+"-"+e++})();function S(){return Date.now()}function N(e,a){return Object.assign({},e||{},a||{})}function I(e,a,t){return Math.max(a,Math.min(t,e))}function U(e,a,t){return e+(a-e)*t}function B(e){if(!e)return"";const a=document.createElement("template");a.innerHTML=e,a.content.querySelectorAll("script, style, iframe, object, embed").forEach(i=>i.remove());const t=new Set(["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"]),l=/^(https?:\/\/|mailto:|tel:|\/\/)/i;return(function i(r){Array.from(r.childNodes).forEach(s=>{if(s.nodeType===1){const p=s.tagName.toLowerCase();t.has(p)?(Array.from(s.attributes||[]).forEach(f=>{const h=f.name.toLowerCase(),u=(f.value||"").trim();h.startsWith("on")?s.removeAttribute(f.name):h==="src"||h==="href"||h==="xlink:href"?l.test(u)?/^data:\s*image\/svg\+xml/i.test(u)&&s.removeAttribute(f.name):s.removeAttribute(f.name):(p==="img"&&h==="srcset"||h==="style")&&s.removeAttribute(f.name)}),i(s)):s.replaceWith(...Array.from(s.childNodes))}})})(a.content),a.innerHTML}const z={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},ye={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},Pe={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},$={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,glassOnly:!1,playSound:null,dev:!1,injectCSS:!0,css:null,autoDedupe:!1,maxVisiblePerType:{},parallaxMode:!1,autoFetchFA:!0,use3d:!1,parallaxSmoothing:.12,_maxRequeueRetries:8},_config:{},_theme:"dark",_plugins:[],_queue:new H,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],_faInjected:!1,_schedulerRunning:!1,_schedulerLast:0,_schedulerRAF:null,_pausedAll:!1,setup(e={}){const a=e,{duration:t,maxVisible:l}=a,i=Le(a,["duration","maxVisible"]);typeof t=="number"&&(this._defaults.duration=t),typeof l=="number"&&(this._defaults.maxVisible=l),typeof e.autoDedupe=="boolean"&&(this._defaults.autoDedupe=e.autoDedupe),e.maxVisiblePerType&&(this._defaults.maxVisiblePerType=N(this._defaults.maxVisiblePerType,e.maxVisiblePerType)),typeof e.parallaxMode=="boolean"&&(this._defaults.parallaxMode=e.parallaxMode),typeof e.autoFetchFA=="boolean"&&(this._defaults.autoFetchFA=e.autoFetchFA),typeof e.use3d=="boolean"&&(this._defaults.use3d=e.use3d),typeof e.parallaxSmoothing=="number"&&(this._defaults.parallaxSmoothing=I(e.parallaxSmoothing,0,1)),typeof e._maxRequeueRetries=="number"&&(this._defaults._maxRequeueRetries=e._maxRequeueRetries),this._config=N(this._config,i),this._registerTypes(),this._defaults.injectCSS!==!1&&ie(this._defaults.css||Q)},use(e){typeof e=="function"&&this._plugins.push(e)},addType(e,a={}){this._config[e]=a,this._registerTypes()},defineTheme(e,a={}){z[e]=N(z[e]||{},a)},setTheme(e){this._theme=e,P&&this._roots.forEach(a=>a.dataset.theme=e)},clear(){this._queue=new H,this._queueDedupe.clear()},destroy(){this.clear(),P&&(this._roots.forEach(e=>{try{e._parallaxRAF&&cancelAnimationFrame(e._parallaxRAF),e._parallaxHandler&&(e.removeEventListener("mousemove",e._parallaxHandler),e.removeEventListener("touchmove",e._parallaxHandler)),e._parallaxReset&&(e.removeEventListener("mouseleave",e._parallaxReset),e.removeEventListener("touchend",e._parallaxReset)),e.remove()}catch(a){}}),this._roots.clear(),Array.from(this._activeMap.keys()).forEach(e=>this.remove(e)),this._stopScheduler())},promise(e,a={}){if(!e||typeof e.then!="function"){this._warn("promise expects a Promise");return}const t=le(),l=a.timeout;let i=null,r=!1,s=!1;const p=()=>{i&&(clearTimeout(i),i=null)};return this._enqueue("loading",ne(se({},Ce(a.loading,"Loading...")),{groupId:t,duration:0})),l&&(i=setTimeout(()=>{s||r||(s=!0,p(),this._enqueue("error",{message:a.timeoutMessage||"Request timeout",groupId:t}))},l)),e.then(f=>{r||s||(s=!0,p(),this._enqueue("success",ne(se({},ge(a.success,f,"Success")),{groupId:t})))}).catch(f=>{r||s||(s=!0,p(),this._enqueue("error",ne(se({},ge(a.error,f,"Error")),{groupId:t})))}),{cancel:()=>{r||s||(r=!0,p(),this._enqueue("info",{message:a.cancelMessage||"Cancelled",groupId:t}))}}},modal(e={}){var a;if(!P)return;this._defaults.injectCSS!==!1&&ie(this._defaults.css||Q);const t=N({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme,use3d:void 0},e),l=t.use3d===void 0?this._defaults.use3d:!!t.use3d,i=z[t.theme]||z.dark,r=document.createElement("div");r.className="jt-modal-overlay",r.style.pointerEvents=t.block?"all":"none",t.blur||(r.style.backdropFilter="none",r.style.webkitBackdropFilter="none");const s=document.createElement("div");if(s.className=`jt-modal jt-anim-${t.animation}`,s.style.background=i.bg,s.style.color=i.color,s.style.border=i.border||"none",l&&(r.style.perspective=r.style.perspective||"900px",s.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),t.title){const u=document.createElement("div");u.className="jt-modal-header",u.textContent=t.title,s.appendChild(u)}const p=document.createElement("div");if(p.className="jt-modal-body",t.html?p.innerHTML=B(t.html):p.textContent=t.message||"",s.appendChild(p),(a=t.actions)!=null&&a.length){const u=document.createElement("div");u.className="jt-modal-actions",t.actions.forEach(y=>{const _=document.createElement("button"),v=y.buttonType||(y.primary?"primary":"secondary");_.className=`jt-modal-btn ${v}`,_.textContent=y.label||"OK",_.onclick=j=>{var L;j.stopPropagation(),(L=y.onClick)==null||L.call(y,j),y.closeOnClick!==!1&&h()},u.appendChild(_)}),s.appendChild(u)}r.appendChild(s),document.body.appendChild(r),this._modalStack.push(r),t.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{r.classList.add("show"),s.classList.add("show"),l&&(s.style.transform="translateY(0) scale(1) rotateX(0deg)")});const f=u=>{u.key==="Escape"&&h()};t.closable&&(t.closeOnOverlay&&r.addEventListener("click",u=>{u.target===r&&h()}),document.addEventListener("keydown",f));const h=()=>{r.classList.remove("show"),s.classList.remove("show"),l&&(s.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),setTimeout(()=>{try{r.remove()}catch(y){}t.block&&(document.body.style.overflow=""),document.removeEventListener("keydown",f);const u=this._modalStack.indexOf(r);u>=0&&this._modalStack.splice(u,1)},300)};return{close:h}},_registerTypes(){Object.keys(this._config).forEach(e=>{if(typeof this[e]=="function"&&!this[e].__auto)return;const a=t=>this._enqueue(e,t);a.__auto=!0,this[e]=a})},_enqueue(e,a={}){var t,l;const i=typeof a.priority=="number"?a.priority:(l=(t=this._priorityMap)==null?void 0:t[a.priority])!=null?l:2,r=a.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,a):void 0);if(r&&this._queueDedupe.has(r)){this._defaults.dev&&console.log("[JuiceToast] deduped (queue)",r);return}const s={id:le(),type:e,payload:a,priority:i};return s._retries=0,r&&(s._dedupeKey=r,this._queueDedupe.add(r)),this._queue.push(s,i),this._scheduleProcessQueue(),s.id},_processQueueScheduled:!1,_scheduleProcessQueue(){this._processQueueScheduled||(this._processQueueScheduled=!0,setTimeout(()=>{this._processQueueScheduled=!1,this._processQueue()},40))},_processQueue(){var e,a;if(!P)return;const t=this._defaults.maxVisible||1/0;let l=0;for(;this._queue.size>0&&l<200;){l++;const i=this._queue.pop();if(!i)break;const r=((e=i.payload)==null?void 0:e.position)||((a=i.payload)==null?void 0:a.toast)||"bottom-right",s=this._getRoot(r);if(!s){if(i._retries=(i._retries||0)+1,i._retries>(this._defaults._maxRequeueRetries||8)){i._dedupeKey&&this._queueDedupe.delete(i._dedupeKey);continue}setTimeout(()=>{this._queue.push(i,i.priority)},120);break}if(Array.from(s.children).length>=t){if(i._retries=(i._retries||0)+1,i._retries>(this._defaults._maxRequeueRetries||8)){i._dedupeKey&&this._queueDedupe.delete(i._dedupeKey);continue}setTimeout(()=>this._queue.push(i,i.priority),160);break}const p=(this._defaults.maxVisiblePerType||{})[i.type];if(typeof p=="number"&&Array.from(s.children).filter(f=>f.dataset.toastType===i.type).length>=p){if(i._retries=(i._retries||0)+1,i._retries>(this._defaults._maxRequeueRetries||8)){i._dedupeKey&&this._queueDedupe.delete(i._dedupeKey);continue}setTimeout(()=>this._queue.push(i,i.priority),160);break}this._showToast(i.type,i.payload,i.id)}},_getRoot(e="bottom-right"){var a;if(!P)return null;if(this._roots.has(e))return this._roots.get(e);const t=document.createElement("div");switch(t.setAttribute("data-juice-root","1"),t.id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.pointerEvents="none",t.style.display="flex",t.style.flexDirection="column",this._defaults.parallaxMode&&(t.dataset.parallax="true"),e){case"top-left":t.style.top="20px",t.style.left="20px";break;case"top-right":t.style.top="20px",t.style.right="20px";break;case"bottom-left":t.style.bottom="20px",t.style.left="20px";break;case"bottom-right":t.style.bottom="20px",t.style.right="20px";break;case"top-center":t.style.top="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;case"bottom-center":t.style.bottom="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;default:t.style.bottom="20px",t.style.right="20px"}if(document.body.appendChild(t),this._defaults.parallaxMode&&!D){const l=(a=this._defaults.parallaxSmoothing)!=null?a:.12;t._parallaxTargets=new WeakMap;const i=s=>{const p=t.getBoundingClientRect(),f=p.left+p.width/2,h=p.top+p.height/2,u=s.touches?s.touches[0].clientX:s.clientX,y=s.touches?s.touches[0].clientY:s.clientY;Array.from(t.children).forEach((_,v)=>{const j=(v+1)/Math.max(1,t.children.length),L=I((u-f)/p.width*j*12,-18,18),T=I((y-h)/p.height*j*8,-14,14),M=I(-j*8,-30,0),J=I((u-f)/p.width*j*-6,-12,12),G=I((y-h)/p.height*j*4,-8,8),o={tx:L,ty:T,tz:M,rotX:G,rotY:J,smoothing:l};t._parallaxTargets.set(_,o)}),this._startScheduler()},r=()=>{Array.from(t.children).forEach(s=>{t._parallaxTargets.set(s,{tx:0,ty:0,tz:0,rotX:0,rotY:0,smoothing:.16})}),this._startScheduler()};t._parallaxHandler=i,t._parallaxReset=r,t.addEventListener("mousemove",i),t.addEventListener("touchmove",i,{passive:!0}),t.addEventListener("mouseleave",r),t.addEventListener("touchend",r)}return this._roots.set(e,t),t},_warn(e){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",e)},_ensureFA(){if(!(!P||this._faInjected||!this._defaults.autoFetchFA)){if(document.querySelector('link[href*="fontawesome"], link[href*="font-awesome"], link[href*="cdnjs.cloudflare.com/ajax/libs/font-awesome"]')){this._faInjected=!0;return}try{const e=document.createElement("link");e.rel="stylesheet",e.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css",e.crossOrigin="anonymous",document.head.appendChild(e),this._faInjected=!0}catch(e){console.error("[JuiceToast]: Fetching icons failed:",e)}}},_playSound(e){if(!P)return;const a=typeof e=="string"&&e?e:this._defaults.playSound;if(a)try{const t=new Audio(a);t.volume=.6,t.play().catch(()=>{})}catch(t){}},_updateStackPositionsFor(e){const a=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),a.forEach((t,l)=>{const i=l,r=i*12;t.style.setProperty("--jt-stack-y",`${-r}px`),t.style.setProperty("--jt-stack-scale",1-i*.04),t.style.setProperty("--jt-stack-opacity",1-i*.12),t.style.zIndex=1e3-i,t.style.setProperty("--jt-parallax-z",`${-i*2}px`),t.dataset.stack=String(i)})},_runPlugins(e){this._plugins.forEach(a=>{try{a(e)}catch(t){this._warn("Plugin error: "+((t==null?void 0:t.message)||t))}})},_normalizeGlass(e){if(e===!0)return 60;if(!e)return 0;const a=Number(e);return Number.isFinite(a)?I(a,0,100):0},_computeDedupeKey(e,a){try{const t=e||"",l=a.title||"",i=a.message||a.html||"";return`${t}::${String(l).trim().slice(0,200)}::${String(i).trim().slice(0,500)}`}catch(t){return}},_showToast(e,a={},t){var l,i,r,s,p,f,h,u,y,_,v,j,L,T,M;if(!P)return;this._defaults.injectCSS!==!1&&ie(this._defaults.css||Q),this._ensureFA();const J=this._config[e]||{},G=typeof a=="object"?a:{message:String(a)},o=N(J,G);o.icon=(l=o.icon)!=null?l:o.icon_left_top,o.position=(r=(i=o.position)!=null?i:o.toast)!=null?r:"bottom-right",o.closable=(p=(s=o.closable)!=null?s:o.closeable)!=null?p:!0,o.duration=typeof o.duration=="number"?o.duration:this._defaults.duration;const V=z[o.theme||this._theme]||{},k=t||le(),X=o.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,o):void 0);if(X)for(const c of this._roots.values()){const d=Array.from(c.children).find(b=>b.dataset.dedupeKey===X);if(d){let b=d._cachedCountEl;if(b||(b=document.createElement("span"),b.className="jt-count",b.style.marginLeft="6px",(f=d.querySelector(".jt-title"))==null||f.appendChild(b),d._cachedCountEl=b,b.textContent="1"),b.textContent=String(parseInt(b.textContent||"1")+1),o.mergeMessage){const E=d.querySelector(".jt-message");E&&(o.html?E.innerHTML=B(o.html):E.textContent=String(o.message||""))}return d.dataset.toastId}}const n=document.createElement("div");if(n.className="juice-toast",n.dataset.toastId=k,n.dataset.position=o.position,n.dataset.toastType=e,X&&(n.dataset.dedupeKey=X),n.tabIndex=0,n.setAttribute("role",o.ariaRole||(e==="error"?"alert":"status")),n.getAttribute("aria-live")||(n.setAttribute("aria-live",e==="error"||e==="success"?"assertive":"polite"),n.setAttribute("aria-atomic","true")),n.style.position="relative",n.style.pointerEvents="auto",o.glassOnly?(n.style.background="rgba(255,255,255,0.35)",n.style.backdropFilter="blur(14px) saturate(140%)",n.style.webkitBackdropFilter="blur(14px) saturate(140%)",n.style.color="rgba(15,23,42,0.85)",n.style.border="1px solid rgba(0,0,0,0.08)",n.style.boxShadow="0 8px 28px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.25)"):(n.style.background=o.bg||V.bg,n.style.color=o.color||V.color,n.style.border=o.border||V.border||"none"),n.style.minHeight=n.style.minHeight||"",n.style.setProperty("--jt-parallax-x","0px"),n.style.setProperty("--jt-parallax-y","0px"),n.style.setProperty("--jt-parallax-z","0px"),n.style.setProperty("--jt-drag-x","0px"),n.style.setProperty("--jt-drag-y","0px"),n.style.setProperty("--jt-rot-x","0deg"),n.style.setProperty("--jt-rot-y","0deg"),n.style.setProperty("--jt-stack-y","0px"),n.style.setProperty("--jt-stack-scale","1"),o.size&&ye[o.size]){const c=ye[o.size];c.width&&(n.style.width=c.width),c.padding&&(n.style.padding=c.padding)}const w=document.createElement("div");w.className="jt-content";let Y=null;o.title&&(Y=document.createElement("div"),Y.className="jt-title",Y.textContent=o.title,w.appendChild(Y));const R=document.createElement("div");if(R.className="jt-message",o.html?R.innerHTML=B(o.html):typeof o.message=="string"?o.message.split(/(`[^`]+`)/g).forEach(c=>{if(c.startsWith("`")&&c.endsWith("`")){const d=document.createElement("code");d.textContent=c.slice(1,-1),R.appendChild(d)}else R.appendChild(document.createTextNode(c))}):o.message&&(R.textContent=String(o.message)),w.appendChild(R),Array.isArray(o.actions)&&o.actions.length){const c=document.createElement("div");c.className="jt-actions",o.actions.forEach(d=>{const b=document.createElement("button");b.className="jt-action",b.textContent=d.label||"Action",b.onclick=E=>{var F;E.stopPropagation(),(F=d.onClick)==null||F.call(d,E),d.closeOnClick!==!1&&this.remove(k)},c.appendChild(b)}),w.appendChild(c)}o.glassOnly||(o.bgImage?(n.style.backgroundImage=`url(${o.bgImage})`,n.style.backgroundSize=o.bgSize||"cover",n.style.backgroundPosition=o.bgPosition||"center"):n.style.background=o.bg||V.bg);let x=null;if(o.icon){x=document.createElement("i");const c=String(o.icon).startsWith("fa")?o.icon:`fa-${o.icon}`;if(x.className=["icon",o.iconPack||"",c].join(" ").trim(),o.iconSize&&(x.style.fontSize=o.iconSize),!D){const d=o.iconAnim||Pe[e];d&&x.classList.add(d)}(o.iconLink||o.iconAnimate)&&(x.classList.add("icon-clickable"),x.addEventListener("click",d=>{d.stopPropagation(),o.iconAnimate&&(x.classList.remove(o.iconAnimate),x.offsetWidth,x.classList.add(o.iconAnimate)),o.iconLink&&window.open(o.iconLink,"_blank","noopener")}))}let g=null;if(o.avatar){g=document.createElement("img");const c=typeof o.avatar=="string"&&o.avatar?o.avatar:o.avatarSrc||"";c&&(g.src=c),g.alt=o.avatarAlt||o.title||"avatar",g.className="jt-avatar",g.loading=o.avatarLazy?"lazy":"eager",g.style.width=g.style.width||"36px",g.style.height=g.style.height||"36px",g.style.borderRadius=g.style.borderRadius||"50%",g.style.objectFit=g.style.objectFit||"cover",g.style.flexShrink="0";const d=o.avatarPosition||"left";d==="left"?g.style.marginRight=(h=o.avatarSpacing)!=null?h:"10px":d==="right"?g.style.marginLeft=(u=o.avatarSpacing)!=null?u:"10px":d==="top"&&(g.style.marginBottom=(y=o.avatarSpacing)!=null?y:"8px")}const Z=o.avatarPosition||"left";g&&Z==="top"?(n.classList.add("jt-avatar-top"),n.style.flexDirection="column",n.style.alignItems="flex-start",n.appendChild(g),x&&o.iconPosition==="top"?(n.appendChild(x),n.appendChild(w)):x&&o.iconPosition==="right"?(n.appendChild(w),n.appendChild(x)):(x&&n.appendChild(x),n.appendChild(w))):(n.style.flexDirection="row",n.style.alignItems="center",g&&Z==="left"&&n.appendChild(g),x&&o.iconPosition==="right"?(n.appendChild(w),n.appendChild(x)):x&&o.iconPosition==="top"?(n.classList.add("jt-icon-top"),n.appendChild(x),n.appendChild(w)):(x&&n.appendChild(x),n.appendChild(w)),g&&Z==="right"&&n.appendChild(g));let K=null;if(o.progress&&((_=o.duration)!=null?_:this._defaults.duration)>0&&(K=document.createElement("div"),K.className="jt-progress",o.progressColor&&(K.style.background=o.progressColor),n.appendChild(K)),o.undo){const c=document.createElement("button");c.className="jt-action",c.textContent="Undo",c.onclick=()=>{try{o.undo()}catch(d){}this.remove(k)},w.appendChild(c)}if(o.closable){const c=document.createElement("span");c.className="juice-toast-close",c.tabIndex=0,c.textContent="\xD7",c.style.marginLeft="8px",c.addEventListener("click",d=>{d.stopPropagation(),this.remove(k)}),n.appendChild(c)}const C=this._getRoot(o.position||"bottom-right");if(!C)return;if(o.groupId){const c=Array.from(C.children).find(d=>d.dataset.groupId===o.groupId);if(c){const d=c.dataset.toastId;return this.update(d,{title:o.title,message:o.message,html:o.html,bg:o.bg,color:o.color,duration:o.duration,icon:o.icon,iconPack:o.iconPack}),d}n.dataset.groupId=o.groupId}const ce=this._defaults.maxVisible;if(ce&&C.children.length>=ce){const c=C.firstElementChild;if(c&&c.dataset&&c.dataset.toastId)this.remove(c.dataset.toastId);else try{C.removeChild(C.firstElementChild)}catch(d){}}C.appendChild(n),n._cachedTitleEl=Y,n._cachedMessageEl=R,n._cachedProgressEl=K;const m={id:k,toast:n,cfg:o,type:e,createdAt:S(),remaining:(v=o.duration)!=null?v:this._defaults.duration,timer:null,start:S(),paused:!1,_boundMove:null,_boundUp:null,_onPointerDown:null,_onEnter:null,_onLeave:null,dedupeKey:X,hooks:{onShow:o.onShow,onShown:o.onShown,onClose:o.onClose,onRemoved:o.onRemoved}};this._activeMap.set(k,m);try{(L=(j=m.hooks).onShow)==null||L.call(j,{id:k,toast:n,cfg:o,type:e})}catch(c){}this._runPlugins({toast:n,cfg:o,type:e,root:C,meta:m}),this._updateStackPositionsFor(C),requestAnimationFrame(()=>{var c,d;D?(n.style.opacity="1",(d=(c=m.hooks).onShown)==null||d.call(c,{id:k,toast:n,cfg:o,type:e})):(n.classList.add("show"),setTimeout(()=>{var b,E;try{(E=(b=m.hooks).onShown)==null||E.call(b,{id:k,toast:n,cfg:o,type:e})}catch(F){}},320))});let de=0,ue=0,A=0,O=0,ee=!1,q=null,te=0;const ae=c=>{const d=c.touches?c.touches[0]:c;de=d.clientX,ue=d.clientY,A=0,O=0,ee=!0,q=null,m.paused=!0,n.style.transition="none",m._boundMove=_e,m._boundUp=be,document.addEventListener("touchmove",m._boundMove,{passive:!0}),document.addEventListener("mousemove",m._boundMove),document.addEventListener("touchend",m._boundUp),document.addEventListener("mouseup",m._boundUp),te=S()},_e=c=>{if(!ee)return;const d=c.touches?c.touches[0]:c;A=d.clientX-de,O=d.clientY-ue,q||(Math.abs(A)>6?q="x":Math.abs(O)>6&&(q="y")),q==="x"?n.style.setProperty("--jt-drag-x",`${A}px`):q==="y"&&n.style.setProperty("--jt-drag-y",`${O}px`),te=S(),d.clientX},be=c=>{ee=!1,m.paused=!1;const d=Math.abs(A),b=Math.abs(O),E=q||(d>b?"x":"y"),F=Math.max(1,S()-te),xe=F?A/F*1e3:0,ve=E==="x"&&(d>($._defaults.swipeThreshold||60)||Math.abs(xe)>800),je=E==="y"&&b>($._defaults.swipeThreshold||80);if(ve||je){const Ee=A>=0?1:-1;E==="x"?n.style.setProperty("--jt-drag-x",`${Ee*1e3}px`):n.style.setProperty("--jt-drag-y","1000px"),n.classList.add("swipe-dismissing"),setTimeout(()=>this.remove(k),220)}else n.style.transition="transform 0.22s ease-out, opacity 0.22s ease-out",n.style.setProperty("--jt-drag-x","0px"),n.style.setProperty("--jt-drag-y","0px");A=O=0,m._boundMove&&(document.removeEventListener("touchmove",m._boundMove),document.removeEventListener("mousemove",m._boundMove),m._boundMove=null),m._boundUp&&(document.removeEventListener("touchend",m._boundUp),document.removeEventListener("mouseup",m._boundUp),m._boundUp=null),m.start=S(),this._startScheduler()};n._onPointerDown=ae,n.addEventListener("touchstart",ae,{passive:!0}),n.addEventListener("mousedown",ae);const oe=()=>{m.paused=!0},re=()=>{m.paused&&(m.paused=!1,m.start=S(),this._startScheduler())};return m._onEnter=oe,m._onLeave=re,n.addEventListener("mouseenter",oe),n.addEventListener("mouseleave",re),n.addEventListener("focusin",oe),n.addEventListener("focusout",re),m.start=S(),m.remaining=(T=o.duration)!=null?T:this._defaults.duration,m.paused=!1,((M=o.duration)!=null?M:this._defaults.duration)>0&&this._startScheduler(),o.undoTimeout&&(m.timer=setTimeout(()=>this.remove(k),o.undoTimeout)),(o.playSound||this._defaults.playSound)&&this._playSound(o.playSound||this._defaults.playSound),k},_startScheduler(){if(this._schedulerRunning)return;this._schedulerRunning=!0;const e=a=>{const t=S();this._schedulerLast=t,this._pausedAll||this._activeMap.forEach((r,s)=>{var p;if(!r||r.paused)return;const f=(p=r.cfg.duration)!=null?p:this._defaults.duration;if(f<=0)return;const h=t-r.start,u=Math.max(0,Math.min(h,1e3));r.remaining-=u,r.start=t;const y=r.toast._cachedProgressEl||r.toast.querySelector(".jt-progress");if(y){const _=Math.max(0,r.remaining/f);y.style.transform=`scaleX(${_})`}r.remaining<=0&&(D||r.toast.classList.remove("show"),setTimeout(()=>this.remove(s),280))}),this._roots.forEach(r=>{!r._parallaxTargets||!r.children.length||Array.from(r.children).forEach(s=>{var p,f,h;const u=r._parallaxTargets.get(s)||{tx:0,ty:0,tz:0,rotX:0,rotY:0,smoothing:(p=this._defaults.parallaxSmoothing)!=null?p:.12};s._jtPrev=s._jtPrev||{tx:0,ty:0,tz:0,rotX:0,rotY:0};const y=s._jtPrev,_=(h=u.smoothing)!=null?h:(f=this._defaults.parallaxSmoothing)!=null?f:.12,v=U(y.tx,u.tx||0,_),j=U(y.ty,u.ty||0,_),L=U(y.tz,u.tz||0,_),T=U(y.rotX,u.rotX||0,_),M=U(y.rotY,u.rotY||0,_);s.style.setProperty("--jt-parallax-x",`${v}px`),s.style.setProperty("--jt-parallax-y",`${j}px`),s.style.setProperty("--jt-parallax-z",`${L}px`),s.style.setProperty("--jt-rot-x",`${T}deg`),s.style.setProperty("--jt-rot-y",`${M}deg`),s._jtPrev.tx=v,s._jtPrev.ty=j,s._jtPrev.tz=L,s._jtPrev.rotX=T,s._jtPrev.rotY=M})});let l=!1;this._activeMap.forEach(r=>{var s;((s=r.cfg.duration)!=null?s:this._defaults.duration)>0&&!r.paused&&(l=!0)});let i=!1;this._roots.forEach(r=>{r._parallaxTargets&&r.children.length&&(i=!0)}),!l&&!i?this._stopScheduler():this._schedulerRAF=requestAnimationFrame(e)};this._schedulerRAF=requestAnimationFrame(e)},_stopScheduler(){this._schedulerRunning&&(this._schedulerRAF&&cancelAnimationFrame(this._schedulerRAF),this._schedulerRAF=null,this._schedulerRunning=!1,this._schedulerLast=0)},remove(e){var a,t,l,i;const r=this._activeMap.get(e);if(!r)return!1;const{toast:s,cfg:p,type:f}=r;try{(t=(a=r.hooks).onClose)==null||t.call(a,{id:e,toast:s,cfg:p,type:f})}catch(u){}D?s.style.opacity="0":s.classList.add("hide");try{s._onPointerDown&&(s.removeEventListener("touchstart",s._onPointerDown),s.removeEventListener("mousedown",s._onPointerDown))}catch(u){}if(r._boundMove){try{document.removeEventListener("touchmove",r._boundMove),document.removeEventListener("mousemove",r._boundMove)}catch(u){}r._boundMove=null}if(r._boundUp){try{document.removeEventListener("touchend",r._boundUp),document.removeEventListener("mouseup",r._boundUp)}catch(u){}r._boundUp=null}try{r._onEnter&&s.removeEventListener("mouseenter",r._onEnter),r._onLeave&&s.removeEventListener("mouseleave",r._onLeave),r._onEnter&&s.removeEventListener("focusin",r._onEnter),r._onLeave&&s.removeEventListener("focusout",r._onLeave)}catch(u){}r.timer&&(clearTimeout(r.timer),r.timer=null),this._activeMap.delete(e);const h=s.parentNode;if(h){const u=()=>{var y,_;try{s.parentNode&&s.parentNode.removeChild(s)}catch(v){}try{if(h.children.length===0){try{h._parallaxHandler&&(h.removeEventListener("mousemove",h._parallaxHandler),h.removeEventListener("touchmove",h._parallaxHandler)),h._parallaxReset&&(h.removeEventListener("mouseleave",h._parallaxReset),h.removeEventListener("touchend",h._parallaxReset)),h.remove()}catch(v){}this._roots.delete(h.dataset.position)}else this._updateStackPositionsFor(h)}catch(v){}if(r.dedupeKey)try{this._queueDedupe.delete(r.dedupeKey)}catch(v){}try{(_=(y=r.hooks).onRemoved)==null||_.call(y,{id:e,cfg:p,type:f})}catch(v){}};if(D)u();else{const y=_=>{_.target===s&&(s.removeEventListener("animationend",y),u())};s.addEventListener("animationend",y),setTimeout(u,700)}}else{if(r.dedupeKey)try{this._queueDedupe.delete(r.dedupeKey)}catch(u){}try{(i=(l=r.hooks).onRemoved)==null||i.call(l,{id:e,cfg:p,type:f})}catch(u){}}return!0},update(e,a={}){const t=this._activeMap.get(e);if(!t)return this._warn("update: id not found "+e),!1;const{toast:l}=t;if(t.cfg=N(t.cfg,a),t.cfg.title){const s=l.querySelector(".jt-title")||l._cachedTitleEl;s&&(s.textContent=t.cfg.title)}const i=l.querySelector(".jt-message")||l._cachedMessageEl;i&&(t.cfg.html?i.innerHTML=B(t.cfg.html):i.textContent=String(t.cfg.message||""));const r=z[t.cfg.theme||this._theme]||{};if(l.style.background=t.cfg.bg||r.bg,l.style.color=t.cfg.color||r.color,l.style.border=t.cfg.border||r.border||"none",t.cfg.duration!==void 0){t.remaining=t.cfg.duration,t.start=S(),t.paused||this._startScheduler();const s=t.toast._cachedProgressEl||t.toast.querySelector(".jt-progress");s&&(s.style.transform="scaleX(1)")}return this._runPlugins({toast:l,cfg:t.cfg,type:t.type,meta:t}),!0},_priorityMap:{low:1,normal:2,high:3,urgent:4},pauseAll(){this._pausedAll=!0},resumeAll(){this._pausedAll=!1,this._activeMap.forEach(e=>e.start=S()),this._startScheduler()},dismissAll(e={}){const a=e.type,t=e.position,l=[];this._activeMap.forEach((i,r)=>{const s=a?i.type===a:!0,p=t?(i.cfg.position||i.toast.dataset.position)===t:!0;s&&p&&l.push(r)}),l.forEach(i=>this.remove(i))},listActive(){const e=[];return this._activeMap.forEach((a,t)=>{e.push({id:t,type:a.type,remaining:a.remaining,createdAt:a.createdAt,position:a.cfg.position})}),e}};function Ce(e,a){return e?typeof e=="string"?{message:e}:e:{message:a}}function ge(e,a,t){return e?typeof e=="function"?{message:e(a)}:typeof e=="string"?{message:e}:e:{message:t}}$.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:4e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"fa-spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}});export{$ as default,$ as juiceToast};
|
|
158
|
+
@media (prefers-reduced-motion:reduce){.juice-toast,.jt-modal{animation:none!important;transition:none!important;}}
|
|
159
|
+
`;function le(e=B){if(!C||fe||(fe=!0,document.getElementById("juice-toast-style")))return;const a=document.createElement("style");a.id="juice-toast-style",a.textContent=e,document.head.appendChild(a)}const ce=(()=>{let e=1;return()=>"jt-"+Date.now().toString(36)+"-"+e++})();function A(){return Date.now()}function F(e,a){return Object.assign({},e||{},a||{})}function I(e,a,t){return Math.max(a,Math.min(t,e))}function $(e,a,t){return e+(a-e)*t}function G(e){if(!e)return"";const a=document.createElement("template");a.innerHTML=e,a.content.querySelectorAll("script, style, iframe, object, embed").forEach(c=>c.remove());const t=new Set(["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"]),n=/^(https?:\/\/|mailto:|tel:|\/\/)/i;return(function c(r){Array.from(r.childNodes).forEach(s=>{if(s.nodeType===1){const m=s.tagName.toLowerCase();t.has(m)?(Array.from(s.attributes||[]).forEach(l=>{const h=l.name.toLowerCase(),d=(l.value||"").trim();h.startsWith("on")?s.removeAttribute(l.name):h==="src"||h==="href"||h==="xlink:href"?(!n.test(d)||/^data:\s*image\/svg\+xml/i.test(d))&&s.removeAttribute(l.name):(m==="img"&&h==="srcset"||h==="style")&&s.removeAttribute(l.name)}),c(s)):s.replaceWith(...Array.from(s.childNodes))}})})(a.content),a.innerHTML}const N={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},ye={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},Le={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},H={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,glassOnly:!1,playSound:null,dev:!1,injectCSS:!0,css:null,autoDedupe:!1,maxVisiblePerType:{},parallaxMode:!1,autoFetchFA:!0,use3d:!1,parallaxSmoothing:.12,_maxRequeueRetries:8,urgentSkipsQueue:!1},_config:{},_theme:"dark",_plugins:[],_queue:new Q,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],_faInjected:!1,_schedulerRunning:!1,_schedulerLast:0,_schedulerRAF:null,_pausedAll:!1,setup(e={}){const a=e,{duration:t,maxVisible:n,urgentSkipsQueue:c}=a,r=Se(a,["duration","maxVisible","urgentSkipsQueue"]);typeof t=="number"&&(this._defaults.duration=t),typeof n=="number"&&(this._defaults.maxVisible=n),typeof c=="boolean"&&(this._defaults.urgentSkipsQueue=c),typeof e.autoDedupe=="boolean"&&(this._defaults.autoDedupe=e.autoDedupe),e.maxVisiblePerType&&(this._defaults.maxVisiblePerType=F(this._defaults.maxVisiblePerType,e.maxVisiblePerType)),typeof e.parallaxMode=="boolean"&&(this._defaults.parallaxMode=e.parallaxMode),typeof e.autoFetchFA=="boolean"&&(this._defaults.autoFetchFA=e.autoFetchFA),typeof e.use3d=="boolean"&&(this._defaults.use3d=e.use3d),typeof e.parallaxSmoothing=="number"&&(this._defaults.parallaxSmoothing=I(e.parallaxSmoothing,0,1)),typeof e._maxRequeueRetries=="number"&&(this._defaults._maxRequeueRetries=e._maxRequeueRetries),this._config=F(this._config,r),this._registerTypes(),this._defaults.injectCSS!==!1&&le(this._defaults.css||B)},use(e){typeof e=="function"&&this._plugins.push(e)},addType(e,a={}){this._config[e]=a,this._registerTypes()},defineTheme(e,a={}){N[e]=F(N[e]||{},a)},setTheme(e){this._theme=e,C&&this._roots.forEach(a=>a.dataset.theme=e)},clear(){this._queue=new Q,this._queueDedupe.clear()},destroy(){this.clear(),C&&(this._roots.forEach(e=>{try{e._parallaxRAF&&cancelAnimationFrame(e._parallaxRAF),e._parallaxHandler&&(e.removeEventListener("mousemove",e._parallaxHandler),e.removeEventListener("touchmove",e._parallaxHandler)),e._parallaxReset&&(e.removeEventListener("mouseleave",e._parallaxReset),e.removeEventListener("touchend",e._parallaxReset)),e.remove()}catch(a){}}),this._roots.clear(),Array.from(this._activeMap.keys()).forEach(e=>this.remove(e)),this._stopScheduler())},promise(e,a={}){const t=typeof e=="function"?e():e;if(!t||typeof t.then!="function"){this._warn("promise expects a Promise or function returning Promise");return}const n=ce(),c=a.timeout;let r=null,s=!1,m=!1;const l=()=>{r&&(clearTimeout(r),r=null)},h=(f,g,v)=>f?Ae(f,g,v)||{message:v}:{message:v},d=(f,g)=>f?Pe(f,g)||{message:g}:{message:g};return this._enqueue("loading",ne(ie({},d(a.loading,"Loading...")),{groupId:n,duration:0})),c&&c>0&&(r=setTimeout(()=>{m||s||(m=!0,l(),this._enqueue("error",{message:a.timeoutMessage||"Request timeout",groupId:n}))},c)),t.then(f=>{s||m||(m=!0,l(),this._enqueue("success",ne(ie({},h(a.success,f,"Success")),{groupId:n})))}).catch(f=>{s||m||(m=!0,l(),this._enqueue("error",ne(ie({},h(a.error,f,"Error")),{groupId:n})))}),{cancel:()=>{s||m||(s=!0,l(),this._enqueue("info",{message:a.cancelMessage||"Cancelled",groupId:n}))}}},modal(e={}){var a;if(!C)return;this._defaults.injectCSS!==!1&&le(this._defaults.css||B);const t=F({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme,use3d:void 0},e),n=t.use3d===void 0?this._defaults.use3d:!!t.use3d,c=N[t.theme]||N.dark,r=document.createElement("div");r.className="jt-modal-overlay",r.style.pointerEvents=t.block?"all":"none",t.blur||(r.style.backdropFilter="none",r.style.webkitBackdropFilter="none");const s=document.createElement("div");if(s.className=`jt-modal jt-anim-${t.animation}`,s.style.background=c.bg,s.style.color=c.color,s.style.border=c.border||"none",n&&(r.style.perspective=r.style.perspective||"900px",s.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),t.title){const d=document.createElement("div");d.className="jt-modal-header",d.textContent=t.title,s.appendChild(d)}const m=document.createElement("div");if(m.className="jt-modal-body",t.html?m.innerHTML=G(t.html):m.textContent=t.message||"",s.appendChild(m),(a=t.actions)!=null&&a.length){const d=document.createElement("div");d.className="jt-modal-actions",t.actions.forEach(f=>{const g=document.createElement("button"),v=f.buttonType||(f.primary?"primary":"secondary");g.className=`jt-modal-btn ${v}`,g.textContent=f.label||"OK",g.onclick=j=>{var k;j.stopPropagation(),(k=f.onClick)==null||k.call(f,j),f.closeOnClick!==!1&&h()},d.appendChild(g)}),s.appendChild(d)}r.appendChild(s),document.body.appendChild(r),this._modalStack.push(r),t.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{r.classList.add("show"),s.classList.add("show"),n&&(s.style.transform="translateY(0) scale(1) rotateX(0deg)")});const l=d=>{d.key==="Escape"&&h()};t.closable&&(t.closeOnOverlay&&r.addEventListener("click",d=>{d.target===r&&h()}),document.addEventListener("keydown",l));const h=()=>{r.classList.remove("show"),s.classList.remove("show"),n&&(s.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),setTimeout(()=>{try{r.remove()}catch(f){}t.block&&(document.body.style.overflow=""),document.removeEventListener("keydown",l);const d=this._modalStack.indexOf(r);d>=0&&this._modalStack.splice(d,1)},300)};return{close:h}},_registerTypes(){Object.keys(this._config).forEach(e=>{if(typeof this[e]=="function"&&!this[e].__auto)return;const a=t=>this._enqueue(e,t);a.__auto=!0,this[e]=a})},_enqueue(e,a={}){var t,n;const c=typeof a.priority=="number"?a.priority:(n=(t=this._priorityMap)==null?void 0:t[a.priority])!=null?n:2,r=a.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,a):void 0);if(r&&this._queueDedupe.has(r)){this._defaults.dev&&console.log("[JuiceToast] deduped (queue)",r);return}const s={id:ce(),type:e,payload:a,priority:c};return s._retries=0,r&&(s._dedupeKey=r,this._queueDedupe.add(r)),this._queue.push(s,c),this._scheduleProcessQueue(),s.id},enqueueBatch(e=[],a={}){const{interval:t=0}=a;if(!(!Array.isArray(e)||e.length===0)){if(!t){e.forEach(n=>this._enqueue(n.type||n._type||"info",n.payload||n));return}e.forEach((n,c)=>{setTimeout(()=>{this._enqueue(n.type||n._type||"info",n.payload||n)},c*t)})}},_processQueueScheduled:!1,_scheduleProcessQueue(){this._processQueueScheduled||(this._processQueueScheduled=!0,setTimeout(()=>{this._processQueueScheduled=!1,this._processQueue()},40))},_processQueue(){var e,a,t,n,c,r;if(!C)return;const s=this._defaults.maxVisible||1/0;let m=0;for(;this._queue.size>0&&m<200;){m++;const l=this._queue.pop();if(!l)break;const h=((e=l.payload)==null?void 0:e.position)||((a=l.payload)==null?void 0:a.toast)||"bottom-right",d=this._getRoot(h);if(!d){if(l._retries=(l._retries||0)+1,l._retries>(this._defaults._maxRequeueRetries||8)){l._dedupeKey&&this._queueDedupe.delete(l._dedupeKey);continue}setTimeout(()=>{this._queue.push(l,l.priority)},120);break}const f=d.children.length,g=this._priorityMap.urgent||4;if(this._defaults.urgentSkipsQueue&&l.priority>=g&&f>=s){let j=!1;for(let k=0;k<d.children.length;k++){const L=d.children[k];L.dataset.toastType;const w=Array.from(this._activeMap.values()).find(T=>T.toast===L);if(((r=(c=(t=w==null?void 0:w.cfg)==null?void 0:t.priority)!=null?c:(n=this._priorityMap)==null?void 0:n[w==null?void 0:w.type])!=null?r:2)<l.priority){const T=L.dataset.toastId;if(T){this.remove(T),j=!0;break}}}if(!j){if(l._retries=(l._retries||0)+1,l._retries>(this._defaults._maxRequeueRetries||8)){l._dedupeKey&&this._queueDedupe.delete(l._dedupeKey);continue}setTimeout(()=>this._queue.push(l,l.priority),160);break}}else if(f>=s){if(l._retries=(l._retries||0)+1,l._retries>(this._defaults._maxRequeueRetries||8)){l._dedupeKey&&this._queueDedupe.delete(l._dedupeKey);continue}setTimeout(()=>this._queue.push(l,l.priority),160);break}const v=(this._defaults.maxVisiblePerType||{})[l.type];if(typeof v=="number"&&Array.from(d.children).filter(j=>j.dataset.toastType===l.type).length>=v){if(l._retries=(l._retries||0)+1,l._retries>(this._defaults._maxRequeueRetries||8)){l._dedupeKey&&this._queueDedupe.delete(l._dedupeKey);continue}setTimeout(()=>this._queue.push(l,l.priority),160);break}this._showToast(l.type,l.payload,l.id)}},_getRoot(e="bottom-right"){var a;if(!C)return null;if(this._roots.has(e))return this._roots.get(e);const t=document.createElement("div");switch(t.setAttribute("data-juice-root","1"),t.id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.pointerEvents="none",t.style.display="flex",t.style.flexDirection="column",this._defaults.parallaxMode&&(t.dataset.parallax="true"),e){case"top-left":t.style.top="20px",t.style.left="20px";break;case"top-right":t.style.top="20px",t.style.right="20px";break;case"bottom-left":t.style.bottom="20px",t.style.left="20px";break;case"bottom-right":t.style.bottom="20px",t.style.right="20px";break;case"top-center":t.style.top="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;case"bottom-center":t.style.bottom="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;default:t.style.bottom="20px",t.style.right="20px"}if(document.body.appendChild(t),this._defaults.parallaxMode&&!z){const n=(a=this._defaults.parallaxSmoothing)!=null?a:.12;t._parallaxTargets=new WeakMap;const c=s=>{const m=t.getBoundingClientRect(),l=m.left+m.width/2,h=m.top+m.height/2,d=s.touches?s.touches[0].clientX:s.clientX,f=s.touches?s.touches[0].clientY:s.clientY;Array.from(t.children).forEach((g,v)=>{const j=(v+1)/Math.max(1,t.children.length),k=I((d-l)/m.width*j*12,-18,18),L=I((f-h)/m.height*j*8,-14,14),w=I(-j*8,-30,0),T=I((d-l)/m.width*j*-6,-12,12),J=I((f-h)/m.height*j*4,-8,8),Z={tx:k,ty:L,tz:w,rotX:J,rotY:T,smoothing:n};t._parallaxTargets.set(g,Z)}),this._startScheduler()},r=()=>{Array.from(t.children).forEach(s=>{t._parallaxTargets.set(s,{tx:0,ty:0,tz:0,rotX:0,rotY:0,smoothing:.16})}),this._startScheduler()};t._parallaxHandler=c,t._parallaxReset=r,t.addEventListener("mousemove",c),t.addEventListener("touchmove",c,{passive:!0}),t.addEventListener("mouseleave",r),t.addEventListener("touchend",r)}return this._roots.set(e,t),t},_warn(e){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",e)},_ensureFA(){if(!(!C||this._faInjected||!this._defaults.autoFetchFA)){if(document.querySelector('link[href*="fontawesome"], link[href*="font-awesome"], link[href*="cdnjs.cloudflare.com/ajax/libs/font-awesome"]')){this._faInjected=!0;return}try{const e=document.createElement("link");e.rel="stylesheet",e.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css",e.crossOrigin="anonymous",document.head.appendChild(e),this._faInjected=!0}catch(e){console.error("[JuiceToast]: Fetching icons failed:",e)}}},_playSound(e){if(!C)return;const a=typeof e=="string"&&e?e:this._defaults.playSound;if(a)try{const t=new Audio(a);t.volume=.6,t.play().catch(()=>{})}catch(t){}},_updateStackPositionsFor(e){const a=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),a.forEach((t,n)=>{const c=n,r=c*12;t.style.setProperty("--jt-stack-y",`${-r}px`),t.style.setProperty("--jt-stack-scale",1-c*.04),t.style.setProperty("--jt-stack-opacity",1-c*.12),t.style.zIndex=1e3-c,t.style.setProperty("--jt-parallax-z",`${-c*2}px`),t.dataset.stack=String(c)})},_runPlugins(e){this._plugins.forEach(a=>{try{a(e)}catch(t){this._warn("Plugin error: "+((t==null?void 0:t.message)||t))}})},_normalizeGlass(e){if(e===!0)return 60;if(!e)return 0;const a=Number(e);return Number.isFinite(a)?I(a,0,100):0},_computeDedupeKey(e,a){try{const t=e||"",n=a.title||"",c=a.message||a.html||"";return`${t}::${String(n).trim().slice(0,200)}::${String(c).trim().slice(0,500)}`}catch(t){return}},_showToast(e,a={},t){var n,c,r,s,m,l,h,d,f,g,v,j,k,L,w,T;if(!C)return;this._defaults.injectCSS!==!1&&le(this._defaults.css||B),this._ensureFA();const J=this._config[e]||{},Z=typeof a=="object"?a:{message:String(a)},o=F(J,Z);o.icon=(n=o.icon)!=null?n:o.icon_left_top,o.position=(r=(c=o.position)!=null?c:o.toast)!=null?r:"bottom-right",o.closable=(m=(s=o.closable)!=null?s:o.closeable)!=null?m:!0,o.duration=typeof o.duration=="number"?o.duration:this._defaults.duration;const V=N[o.theme||this._theme]||{},S=t||ce(),X=o.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,o):void 0);if(X)for(const u of this._roots.values()){const p=Array.from(u.children).find(b=>b.dataset.dedupeKey===X);if(p){let b=p._cachedCountEl;if(b||(b=document.createElement("span"),b.className="jt-count",b.style.marginLeft="6px",(l=p.querySelector(".jt-title"))==null||l.appendChild(b),p._cachedCountEl=b,b.textContent="1"),b.textContent=String(parseInt(b.textContent||"1")+1),o.mergeMessage){const E=p.querySelector(".jt-message");E&&(o.html?E.innerHTML=G(o.html):E.textContent=String(o.message||""))}return p.dataset.toastId}}const i=document.createElement("div");if(i.className="juice-toast",i.dataset.toastId=S,i.dataset.position=o.position,i.dataset.toastType=e,X&&(i.dataset.dedupeKey=X),i.tabIndex=0,i.setAttribute("role",o.ariaRole||(e==="error"?"alert":"status")),i.getAttribute("aria-live")||(i.setAttribute("aria-live",e==="error"||e==="success"?"assertive":"polite"),i.setAttribute("aria-atomic","true")),i.style.position="relative",i.style.pointerEvents="auto",o.glassOnly?(i.style.background="rgba(255,255,255,0.35)",i.style.backdropFilter="blur(14px) saturate(140%)",i.style.webkitBackdropFilter="blur(14px) saturate(140%)",i.style.color="rgba(15,23,42,0.85)",i.style.border="1px solid rgba(0,0,0,0.08)",i.style.boxShadow="0 8px 28px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.25)"):(i.style.background=o.bg||V.bg,i.style.color=o.color||V.color,i.style.border=o.border||V.border||"none"),i.style.minHeight=i.style.minHeight||"",["--jt-parallax-x","--jt-parallax-y","--jt-parallax-z","--jt-drag-x","--jt-drag-y","--jt-rot-x","--jt-rot-y","--jt-stack-y","--jt-stack-scale"].forEach(u=>i.style.setProperty(u,u.includes("rot")?"0deg":"0px")),o.size&&ye[o.size]){const u=ye[o.size];u.width&&(i.style.width=u.width),u.padding&&(i.style.padding=u.padding)}const P=document.createElement("div");P.className="jt-content";let Y=null;o.title&&(Y=document.createElement("div"),Y.className="jt-title",Y.textContent=o.title,P.appendChild(Y));const R=document.createElement("div");if(R.className="jt-message",o.html?R.innerHTML=G(o.html):typeof o.message=="string"?o.message.split(/(`[^`]+`)/g).forEach(u=>{if(u.startsWith("`")&&u.endsWith("`")){const p=document.createElement("code");p.textContent=u.slice(1,-1),R.appendChild(p)}else R.appendChild(document.createTextNode(u))}):o.message&&(R.textContent=String(o.message)),P.appendChild(R),Array.isArray(o.actions)&&o.actions.length){const u=document.createElement("div");u.className="jt-actions",o.actions.forEach(p=>{const b=document.createElement("button");b.className="jt-action",b.textContent=p.label||"Action",b.onclick=E=>{var D;E.stopPropagation(),(D=p.onClick)==null||D.call(p,E),p.closeOnClick!==!1&&this.remove(S)},u.appendChild(b)}),P.appendChild(u)}o.glassOnly||(o.bgImage?(i.style.backgroundImage=`url(${o.bgImage})`,i.style.backgroundSize=o.bgSize||"cover",i.style.backgroundPosition=o.bgPosition||"center"):i.style.background=o.bg||V.bg);let x=null;if(o.icon){x=document.createElement("i");const u=String(o.icon).startsWith("fa")?o.icon:`fa-${o.icon}`;if(x.className=["icon",o.iconPack||"",u].join(" ").trim(),o.iconSize&&(x.style.fontSize=o.iconSize),!z){const p=o.iconAnim||Le[e];p&&x.classList.add(p)}(o.iconLink||o.iconAnimate)&&(x.classList.add("icon-clickable"),x.addEventListener("click",p=>{p.stopPropagation(),o.iconAnimate&&(x.classList.remove(o.iconAnimate),x.offsetWidth,x.classList.add(o.iconAnimate)),o.iconLink&&window.open(o.iconLink,"_blank","noopener")}))}let _=null;if(o.avatar){_=document.createElement("img");const u=typeof o.avatar=="string"&&o.avatar?o.avatar:o.avatarSrc||"";u&&(_.src=u),_.alt=o.avatarAlt||o.title||"avatar",_.className="jt-avatar",_.loading=o.avatarLazy?"lazy":"eager",_.style.width=_.style.width||"36px",_.style.height=_.style.height||"36px",_.style.borderRadius=_.style.borderRadius||"50%",_.style.objectFit=_.style.objectFit||"cover",_.style.flexShrink="0";const p=o.avatarPosition||"left";p==="left"?_.style.marginRight=(h=o.avatarSpacing)!=null?h:"10px":p==="right"?_.style.marginLeft=(d=o.avatarSpacing)!=null?d:"10px":p==="top"&&(_.style.marginBottom=(f=o.avatarSpacing)!=null?f:"8px")}const ee=o.avatarPosition||"left";_&&ee==="top"?(i.classList.add("jt-avatar-top"),i.style.flexDirection="column",i.style.alignItems="flex-start",i.appendChild(_),x&&o.iconPosition==="top"?(i.appendChild(x),i.appendChild(P)):x&&o.iconPosition==="right"?(i.appendChild(P),i.appendChild(x)):(x&&i.appendChild(x),i.appendChild(P))):(i.style.flexDirection="row",i.style.alignItems="center",_&&ee==="left"&&i.appendChild(_),x&&o.iconPosition==="right"?(i.appendChild(P),i.appendChild(x)):x&&o.iconPosition==="top"?(i.classList.add("jt-icon-top"),i.appendChild(x),i.appendChild(P)):(x&&i.appendChild(x),i.appendChild(P)),_&&ee==="right"&&i.appendChild(_));let K=null;if(o.progress&&((g=o.duration)!=null?g:this._defaults.duration)>0&&(K=document.createElement("div"),K.className="jt-progress",o.progressColor&&(K.style.background=o.progressColor),i.appendChild(K)),o.undo){const u=document.createElement("button");u.className="jt-action",u.textContent="Undo",u.onclick=()=>{try{o.undo()}catch(p){}this.remove(S)},P.appendChild(u)}if(o.closable){const u=document.createElement("span");u.className="juice-toast-close",u.tabIndex=0,u.textContent="\xD7",u.style.marginLeft="8px",u.addEventListener("click",p=>{p.stopPropagation(),this.remove(S)}),i.appendChild(u)}const U=this._getRoot(o.position||"bottom-right");if(!U)return;if(o.groupId){const u=Array.from(U.children).find(p=>p.dataset.groupId===o.groupId);if(u){const p=u.dataset.toastId;return this.update(p,{title:o.title,message:o.message,html:o.html,bg:o.bg,color:o.color,duration:o.duration,icon:o.icon,iconPack:o.iconPack}),p}i.dataset.groupId=o.groupId}U.appendChild(i),i._cachedTitleEl=Y,i._cachedMessageEl=R,i._cachedProgressEl=K;const y={id:S,toast:i,cfg:o,type:e,createdAt:A(),remaining:(v=o.duration)!=null?v:this._defaults.duration,timer:null,start:A(),paused:!1,_boundMove:null,_boundUp:null,_onPointerDown:null,_onEnter:null,_onLeave:null,dedupeKey:X,hooks:{onShow:o.onShow,onShown:o.onShown,onClose:o.onClose,onRemoved:o.onRemoved},_numericPriority:(j=typeof o.priority=="number"?o.priority:this._priorityMap[o.priority])!=null?j:2};this._activeMap.set(S,y);try{(L=(k=y.hooks).onShow)==null||L.call(k,{id:S,toast:i,cfg:o,type:e})}catch(u){}this._runPlugins({toast:i,cfg:o,type:e,root:U,meta:y}),this._updateStackPositionsFor(U),requestAnimationFrame(()=>{var u,p;z?(i.style.opacity="1",(p=(u=y.hooks).onShown)==null||p.call(u,{id:S,toast:i,cfg:o,type:e})):(i.classList.add("show"),setTimeout(()=>{var b,E;try{(E=(b=y.hooks).onShown)==null||E.call(b,{id:S,toast:i,cfg:o,type:e})}catch(D){}},320))});let de=0,ue=0,M=0,O=0,te=!1,q=null,ae=0;const oe=u=>{const p=u.touches?u.touches[0]:u;de=p.clientX,ue=p.clientY,M=0,O=0,te=!0,q=null,y.paused=!0,i.style.transition="none",y._boundMove=ge,y._boundUp=_e,document.addEventListener("touchmove",y._boundMove,{passive:!0}),document.addEventListener("mousemove",y._boundMove),document.addEventListener("touchend",y._boundUp),document.addEventListener("mouseup",y._boundUp),ae=A()},ge=u=>{if(!te)return;const p=u.touches?u.touches[0]:u;M=p.clientX-de,O=p.clientY-ue,q||(Math.abs(M)>6?q="x":Math.abs(O)>6&&(q="y")),q==="x"?i.style.setProperty("--jt-drag-x",`${M}px`):q==="y"&&i.style.setProperty("--jt-drag-y",`${O}px`),ae=A(),p.clientX},_e=u=>{te=!1,y.paused=!1;const p=Math.abs(M),b=Math.abs(O),E=q||(p>b?"x":"y"),D=Math.max(1,A()-ae),be=D?M/D*1e3:0,ve=E==="x"&&(p>(H._defaults.swipeThreshold||60)||Math.abs(be)>800),xe=E==="y"&&b>(H._defaults.swipeThreshold||80);if(ve||xe){const je=M>=0?1:-1;E==="x"?i.style.setProperty("--jt-drag-x",`${je*1e3}px`):i.style.setProperty("--jt-drag-y","1000px"),i.classList.add("swipe-dismissing"),setTimeout(()=>this.remove(S),220)}else i.style.transition="transform 0.22s ease-out, opacity 0.22s ease-out",i.style.setProperty("--jt-drag-x","0px"),i.style.setProperty("--jt-drag-y","0px");M=O=0,y._boundMove&&(document.removeEventListener("touchmove",y._boundMove),document.removeEventListener("mousemove",y._boundMove),y._boundMove=null),y._boundUp&&(document.removeEventListener("touchend",y._boundUp),document.removeEventListener("mouseup",y._boundUp),y._boundUp=null),y.start=A(),this._startScheduler()};i._onPointerDown=oe,i.addEventListener("touchstart",oe,{passive:!0}),i.addEventListener("mousedown",oe);const re=()=>{y.paused=!0},se=()=>{y.paused&&(y.paused=!1,y.start=A(),this._startScheduler())};return y._onEnter=re,y._onLeave=se,i.addEventListener("mouseenter",re),i.addEventListener("mouseleave",se),i.addEventListener("focusin",re),i.addEventListener("focusout",se),y.start=A(),y.remaining=(w=o.duration)!=null?w:this._defaults.duration,y.paused=!1,((T=o.duration)!=null?T:this._defaults.duration)>0&&this._startScheduler(),o.undoTimeout&&(y.timer=setTimeout(()=>this.remove(S),o.undoTimeout)),(o.playSound||this._defaults.playSound)&&this._playSound(o.playSound||this._defaults.playSound),S},_startScheduler(){if(this._schedulerRunning)return;this._schedulerRunning=!0;const e=a=>{const t=A();this._schedulerLast=t,this._pausedAll||this._activeMap.forEach((r,s)=>{var m;if(!r||r.paused)return;const l=(m=r.cfg.duration)!=null?m:this._defaults.duration;if(l<=0)return;const h=t-r.start,d=Math.max(0,Math.min(h,1e3));r.remaining-=d,r.start=t;const f=r.toast._cachedProgressEl||r.toast.querySelector(".jt-progress");if(f){const g=Math.max(0,r.remaining/l);f.style.transform=`scaleX(${g})`}r.remaining<=0&&(z||r.toast.classList.remove("show"),setTimeout(()=>this.remove(s),280))}),this._roots.forEach(r=>{!r._parallaxTargets||!r.children.length||Array.from(r.children).forEach(s=>{var m,l,h;const d=r._parallaxTargets.get(s)||{tx:0,ty:0,tz:0,rotX:0,rotY:0,smoothing:(m=this._defaults.parallaxSmoothing)!=null?m:.12};s._jtPrev=s._jtPrev||{tx:0,ty:0,tz:0,rotX:0,rotY:0};const f=s._jtPrev,g=(h=(l=d.smoothing)!=null?l:this._defaults.parallaxSmoothing)!=null?h:.12,v=$(f.tx,d.tx||0,g),j=$(f.ty,d.ty||0,g),k=$(f.tz,d.tz||0,g),L=$(f.rotX,d.rotX||0,g),w=$(f.rotY,d.rotY||0,g);s.style.setProperty("--jt-parallax-x",`${v}px`),s.style.setProperty("--jt-parallax-y",`${j}px`),s.style.setProperty("--jt-parallax-z",`${k}px`),s.style.setProperty("--jt-rot-x",`${L}deg`),s.style.setProperty("--jt-rot-y",`${w}deg`),s._jtPrev.tx=v,s._jtPrev.ty=j,s._jtPrev.tz=k,s._jtPrev.rotX=L,s._jtPrev.rotY=w})});let n=!1;this._activeMap.forEach(r=>{var s;((s=r.cfg.duration)!=null?s:this._defaults.duration)>0&&!r.paused&&(n=!0)});let c=!1;this._roots.forEach(r=>{r._parallaxTargets&&r.children.length&&(c=!0)}),!n&&!c?this._stopScheduler():this._schedulerRAF=requestAnimationFrame(e)};this._schedulerRAF=requestAnimationFrame(e)},_stopScheduler(){this._schedulerRunning&&(this._schedulerRAF&&cancelAnimationFrame(this._schedulerRAF),this._schedulerRAF=null,this._schedulerRunning=!1,this._schedulerLast=0)},remove(e){var a,t,n,c;const r=this._activeMap.get(e);if(!r)return!1;const{toast:s,cfg:m,type:l}=r;try{(t=(a=r.hooks).onClose)==null||t.call(a,{id:e,toast:s,cfg:m,type:l})}catch(d){}z?s.style.opacity="0":s.classList.add("hide");try{s._onPointerDown&&(s.removeEventListener("touchstart",s._onPointerDown),s.removeEventListener("mousedown",s._onPointerDown))}catch(d){}if(r._boundMove){try{document.removeEventListener("touchmove",r._boundMove),document.removeEventListener("mousemove",r._boundMove)}catch(d){}r._boundMove=null}if(r._boundUp){try{document.removeEventListener("touchend",r._boundUp),document.removeEventListener("mouseup",r._boundUp)}catch(d){}r._boundUp=null}try{r._onEnter&&s.removeEventListener("mouseenter",r._onEnter),r._onLeave&&s.removeEventListener("mouseleave",r._onLeave),r._onEnter&&s.removeEventListener("focusin",r._onEnter),r._onLeave&&s.removeEventListener("focusout",r._onLeave)}catch(d){}r.timer&&(clearTimeout(r.timer),r.timer=null),this._activeMap.delete(e);const h=s.parentNode;if(h){const d=()=>{var f,g;try{s.parentNode&&s.parentNode.removeChild(s)}catch(v){}try{if(h.children.length===0){try{h._parallaxHandler&&(h.removeEventListener("mousemove",h._parallaxHandler),h.removeEventListener("touchmove",h._parallaxHandler)),h._parallaxReset&&(h.removeEventListener("mouseleave",h._parallaxReset),h.removeEventListener("touchend",h._parallaxReset)),h.remove()}catch(v){}this._roots.delete(h.dataset.position)}else this._updateStackPositionsFor(h)}catch(v){}if(r.dedupeKey)try{this._queueDedupe.delete(r.dedupeKey)}catch(v){}try{(g=(f=r.hooks).onRemoved)==null||g.call(f,{id:e,cfg:m,type:l})}catch(v){}this._scheduleProcessQueue()};if(z)d();else{const f=g=>{g.target===s&&(s.removeEventListener("animationend",f),d())};s.addEventListener("animationend",f),setTimeout(d,700)}}else{if(r.dedupeKey)try{this._queueDedupe.delete(r.dedupeKey)}catch(d){}try{(c=(n=r.hooks).onRemoved)==null||c.call(n,{id:e,cfg:m,type:l})}catch(d){}this._scheduleProcessQueue()}return!0},update(e,a={}){const t=this._activeMap.get(e);if(!t)return this._warn("update: id not found "+e),!1;const{toast:n}=t;if(t.cfg=F(t.cfg,a),t.cfg.title){const s=n.querySelector(".jt-title")||n._cachedTitleEl;s&&(s.textContent=t.cfg.title)}const c=n.querySelector(".jt-message")||n._cachedMessageEl;c&&(t.cfg.html?c.innerHTML=G(t.cfg.html):c.textContent=String(t.cfg.message||""));const r=N[t.cfg.theme||this._theme]||{};if(n.style.background=t.cfg.bg||r.bg,n.style.color=t.cfg.color||r.color,n.style.border=t.cfg.border||r.border||"none",t.cfg.duration!==void 0){t.remaining=t.cfg.duration,t.start=A(),t.paused||this._startScheduler();const s=t.toast._cachedProgressEl||t.toast.querySelector(".jt-progress");s&&(s.style.transform="scaleX(1)")}return this._runPlugins({toast:n,cfg:t.cfg,type:t.type,meta:t}),!0},_priorityMap:{low:1,normal:2,high:3,urgent:4},pauseAll(){this._pausedAll=!0},resumeAll(){this._pausedAll=!1,this._activeMap.forEach(e=>e.start=A()),this._startScheduler()},dismissAll(e={}){const a=e.type,t=e.position,n=[];this._activeMap.forEach((c,r)=>{const s=a?c.type===a:!0,m=t?(c.cfg.position||c.toast.dataset.position)===t:!0;s&&m&&n.push(r)}),n.forEach(c=>this.remove(c))},listActive(){const e=[];return this._activeMap.forEach((a,t)=>{e.push({id:t,type:a.type,remaining:a.remaining,createdAt:a.createdAt,position:a.cfg.position})}),e}};function Pe(e,a){return e?typeof e=="string"?{message:e}:e:{message:a}}function Ae(e,a,t){return e?typeof e=="function"?{message:e(a)}:typeof e=="string"?{message:e}:e:{message:t}}H.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:4e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"fa-spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}});export{H as default,H as juiceToast};
|
|
335
160
|
//# sourceMappingURL=juice-toast.esm.js.map
|
package/dist/juice-toast.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(R,Y){typeof exports=="object"&&typeof module!="undefined"?Y(exports):typeof define=="function"&&define.amd?define(["exports"],Y):(R=typeof globalThis!="undefined"?globalThis:R||self,Y(R.juiceToast={}))})(this,(function(R){"use strict";var Y=Object.defineProperty,be=Object.defineProperties,ve=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,me=(e,a,t)=>a in e?Y(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,ee=(e,a)=>{for(var t in a||(a={}))pe.call(a,t)&&me(e,t,a[t]);if(B)for(var t of B(a))he.call(a,t)&&me(e,t,a[t]);return e},te=(e,a)=>be(e,ve(a)),xe=(e,a)=>{var t={};for(var n in e)pe.call(e,n)&&a.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&B)for(var n of B(e))a.indexOf(n)<0&&he.call(e,n)&&(t[n]=e[n]);return t};const C=typeof window!="undefined"&&typeof document!="undefined",D=C&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;class K{constructor(){this._heap=[]}get size(){return this._heap.length}_parent(a){return Math.floor((a-1)/2)}_left(a){return 2*a+1}_right(a){return 2*a+2}_swap(a,t){[this._heap[a],this._heap[t]]=[this._heap[t],this._heap[a]]}push(a,t=0){const n={item:a,priority:t,seq:K._seq=(K._seq||0)+1};this._heap.push(n),this._siftUp(this._heap.length-1)}pop(){if(!this._heap.length)return null;this._swap(0,this._heap.length-1);const a=this._heap.pop();return this._siftDown(0),a.item}peek(){return this._heap[0]?this._heap[0].item:null}_siftUp(a){for(;a>0;){const t=this._parent(a);if(this._compare(a,t)<=0)break;this._swap(a,t),a=t}}_siftDown(a){for(;;){const t=this._left(a),n=this._right(a),c=this._heap.length;let r=a;if(t<c&&this._compare(t,r)>0&&(r=t),n<c&&this._compare(n,r)>0&&(r=n),r===a)break;this._swap(a,r),a=r}}_compare(a,t){const n=this._heap[a],c=this._heap[t];return n.priority!==c.priority?n.priority-c.priority:c.seq-n.seq}}let fe=!1;const G=`
|
|
2
2
|
:root{
|
|
3
3
|
--jt-radius:10px;
|
|
4
4
|
--jt-bg1:rgba(30,30,30,.95);
|
|
@@ -17,41 +17,35 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/* POSITIONS */
|
|
20
|
-
|
|
21
20
|
[data-juice-root][data-position="bottom-right"]{
|
|
22
21
|
bottom:20px;
|
|
23
22
|
right:20px;
|
|
24
23
|
flex-direction:column-reverse;
|
|
25
24
|
align-items:flex-end;
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
[data-juice-root][data-position="top-right"]{
|
|
29
27
|
top:20px;
|
|
30
28
|
right:20px;
|
|
31
29
|
flex-direction:column;
|
|
32
30
|
align-items:flex-end;
|
|
33
31
|
}
|
|
34
|
-
|
|
35
32
|
[data-juice-root][data-position="bottom-left"]{
|
|
36
33
|
bottom:20px;
|
|
37
34
|
left:20px;
|
|
38
35
|
flex-direction:column-reverse;
|
|
39
36
|
align-items:flex-start;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
[data-juice-root][data-position="top-left"]{
|
|
43
39
|
top:20px;
|
|
44
40
|
left:20px;
|
|
45
41
|
flex-direction:column;
|
|
46
42
|
align-items:flex-start;
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
[data-juice-root][data-position="top-center"]{
|
|
50
45
|
top:20px;
|
|
51
46
|
left:50%;
|
|
52
47
|
transform:translateX(-50%);
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
[data-juice-root][data-position="bottom-center"]{
|
|
56
50
|
bottom:20px;
|
|
57
51
|
left:50%;
|
|
@@ -59,7 +53,6 @@
|
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
/* TOAST */
|
|
62
|
-
|
|
63
56
|
.juice-toast{
|
|
64
57
|
pointer-events:auto;
|
|
65
58
|
min-width:220px;
|
|
@@ -89,247 +82,79 @@
|
|
|
89
82
|
}
|
|
90
83
|
|
|
91
84
|
/* STACK DEPTH FEATURE */
|
|
92
|
-
|
|
93
85
|
.juice-toast[data-stack="1"]{--jt-stack-scale:.97;opacity:.95}
|
|
94
86
|
.juice-toast[data-stack="2"]{--jt-stack-scale:.94;opacity:.9}
|
|
95
87
|
.juice-toast[data-stack="3"]{--jt-stack-scale:.91;opacity:.85}
|
|
96
88
|
|
|
97
89
|
/* SHOW/HIDE */
|
|
98
|
-
|
|
99
90
|
@keyframes jt-slide-in{
|
|
100
91
|
from{opacity:0;transform:translateY(20px) scale(.98)}
|
|
101
92
|
to{opacity:1;transform:translateY(0) scale(1)}
|
|
102
93
|
}
|
|
103
|
-
|
|
104
94
|
@keyframes jt-slide-out{
|
|
105
95
|
from{opacity:1;transform:translateY(0) scale(1)}
|
|
106
96
|
to{opacity:0;transform:translateY(20px) scale(.98)}
|
|
107
97
|
}
|
|
108
|
-
|
|
109
98
|
.juice-toast.show{
|
|
110
99
|
animation:jt-slide-in .32s cubic-bezier(.4,0,.2,1) forwards;
|
|
111
100
|
}
|
|
112
|
-
|
|
113
101
|
.juice-toast.hide{
|
|
114
102
|
animation:jt-slide-out .28s cubic-bezier(.4,0,.2,1) forwards;
|
|
115
103
|
pointer-events:none;
|
|
116
104
|
}
|
|
117
105
|
|
|
118
106
|
/* MICRO ANIMATIONS */
|
|
119
|
-
|
|
120
|
-
@keyframes jt-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@keyframes jt-shake{
|
|
126
|
-
0%,100%{transform:translateX(0)}
|
|
127
|
-
25%{transform:translateX(-6px)}
|
|
128
|
-
75%{transform:translateX(6px)}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
@keyframes jt-pulse{
|
|
132
|
-
0%,100%{transform:scale(1)}
|
|
133
|
-
50%{transform:scale(1.03)}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@keyframes jt-spin{
|
|
137
|
-
from{transform:rotate(0deg)}
|
|
138
|
-
to{transform:rotate(360deg)}
|
|
139
|
-
}
|
|
140
|
-
|
|
107
|
+
@keyframes jt-bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}
|
|
108
|
+
@keyframes jt-shake{0%,100%{transform:translateX(0)}25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
|
|
109
|
+
@keyframes jt-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.03)}}
|
|
110
|
+
@keyframes jt-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
|
|
141
111
|
.jt-spin{animation:jt-spin 1.5s linear infinite}
|
|
142
112
|
.jt-pulse{animation:jt-pulse 1.2s ease-in-out}
|
|
143
113
|
|
|
144
114
|
/* ICON */
|
|
145
|
-
|
|
146
115
|
.juice-toast .icon{
|
|
147
|
-
width:30px;
|
|
148
|
-
height:30px;
|
|
149
|
-
display:flex;
|
|
150
|
-
align-items:center;
|
|
151
|
-
justify-content:center;
|
|
152
|
-
border-radius:8px;
|
|
153
|
-
background:rgba(255,255,255,.06);
|
|
116
|
+
width:30px;height:30px;display:flex;align-items:center;justify-content:center;border-radius:8px;background:rgba(255,255,255,.06);
|
|
154
117
|
}
|
|
155
118
|
|
|
156
119
|
/* CONTENT */
|
|
157
|
-
|
|
158
|
-
.jt-
|
|
159
|
-
|
|
160
|
-
flex-direction:column;
|
|
161
|
-
gap:4px;
|
|
162
|
-
flex:1;
|
|
163
|
-
min-width:0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.jt-title{
|
|
167
|
-
font-weight:700;
|
|
168
|
-
font-size:13px;
|
|
169
|
-
white-space:nowrap;
|
|
170
|
-
overflow:hidden;
|
|
171
|
-
text-overflow:ellipsis;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.jt-message{
|
|
175
|
-
font-size:13px;
|
|
176
|
-
opacity:.95;
|
|
177
|
-
word-break:break-word;
|
|
178
|
-
}
|
|
120
|
+
.jt-content{display:flex;flex-direction:column;gap:4px;flex:1;min-width:0;}
|
|
121
|
+
.jt-title{font-weight:700;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
|
122
|
+
.jt-message{font-size:13px;opacity:.95;word-break:break-word;}
|
|
179
123
|
|
|
180
124
|
/* ACTIONS */
|
|
181
|
-
|
|
182
|
-
.jt-
|
|
183
|
-
display:flex;
|
|
184
|
-
gap:8px;
|
|
185
|
-
margin-top:10px;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.jt-action{
|
|
189
|
-
border:1px solid currentColor;
|
|
190
|
-
padding:4px 10px;
|
|
191
|
-
border-radius:6px;
|
|
192
|
-
font-size:12px;
|
|
193
|
-
cursor:pointer;
|
|
194
|
-
background:transparent;
|
|
195
|
-
}
|
|
125
|
+
.jt-actions{display:flex;gap:8px;margin-top:10px;}
|
|
126
|
+
.jt-action{border:1px solid currentColor;padding:4px 10px;border-radius:6px;font-size:12px;cursor:pointer;background:transparent;}
|
|
196
127
|
|
|
197
128
|
/* PROGRESS */
|
|
198
|
-
|
|
199
|
-
.jt-progress{
|
|
200
|
-
position:absolute;
|
|
201
|
-
left:0;
|
|
202
|
-
bottom:0;
|
|
203
|
-
height:4px;
|
|
204
|
-
width:100%;
|
|
205
|
-
border-radius:2px;
|
|
206
|
-
background:linear-gradient(90deg,#4ade80,#22c55e);
|
|
207
|
-
transform-origin:left;
|
|
208
|
-
transform:scaleX(1);
|
|
209
|
-
transition:transform linear;
|
|
210
|
-
}
|
|
129
|
+
.jt-progress{position:absolute;left:0;bottom:0;height:4px;width:100%;border-radius:2px;background:linear-gradient(90deg,#4ade80,#22c55e);transform-origin:left;transform:scaleX(1);transition:transform linear;}
|
|
211
130
|
|
|
212
131
|
/* SWIPE */
|
|
213
|
-
|
|
214
|
-
.juice-toast.swipe-dismissing{
|
|
215
|
-
opacity:0;
|
|
216
|
-
transition:transform .22s ease-out,opacity .22s ease-out;
|
|
217
|
-
}
|
|
132
|
+
.juice-toast.swipe-dismissing{opacity:0;transition:transform .22s ease-out,opacity .22s ease-out;}
|
|
218
133
|
|
|
219
134
|
/* AVATAR */
|
|
220
|
-
|
|
221
|
-
.jt-avatar{
|
|
222
|
-
width:36px;
|
|
223
|
-
height:36px;
|
|
224
|
-
border-radius:50%;
|
|
225
|
-
object-fit:cover;
|
|
226
|
-
flex-shrink:0;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.juice-toast.jt-avatar-top{
|
|
230
|
-
flex-direction:column;
|
|
231
|
-
align-items:flex-start;
|
|
232
|
-
}
|
|
135
|
+
.jt-avatar{width:36px;height:36px;border-radius:50%;object-fit:cover;flex-shrink:0;}
|
|
136
|
+
.juice-toast.jt-avatar-top{flex-direction:column;align-items:flex-start;}
|
|
233
137
|
|
|
234
138
|
/* MODAL */
|
|
235
|
-
|
|
236
|
-
.jt-modal-overlay{
|
|
237
|
-
position:fixed;
|
|
238
|
-
inset:0;
|
|
239
|
-
display:flex;
|
|
240
|
-
align-items:center;
|
|
241
|
-
justify-content:center;
|
|
242
|
-
padding:20px;
|
|
243
|
-
background:rgba(15,23,42,.55);
|
|
244
|
-
backdrop-filter:blur(6px) saturate(120%);
|
|
245
|
-
opacity:0;
|
|
246
|
-
transition:opacity .25s ease;
|
|
247
|
-
z-index:10000;
|
|
248
|
-
}
|
|
249
|
-
|
|
139
|
+
.jt-modal-overlay{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.55);backdrop-filter:blur(6px) saturate(120%);opacity:0;transition:opacity .25s ease;z-index:10000;}
|
|
250
140
|
.jt-modal-overlay.show{opacity:1}
|
|
251
|
-
|
|
252
|
-
.jt-modal{
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
will-change:transform,opacity;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.jt-modal.show{
|
|
264
|
-
opacity:1;
|
|
265
|
-
transform:translateY(0) scale(1);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
.jt-modal-btn{
|
|
269
|
-
padding:8px 14px;
|
|
270
|
-
border-radius:8px;
|
|
271
|
-
font-size:14px;
|
|
272
|
-
cursor:pointer;
|
|
273
|
-
border:none;
|
|
274
|
-
transition:all .18s ease;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/* PRIMARY */
|
|
278
|
-
|
|
279
|
-
.jt-modal-btn.primary{
|
|
280
|
-
background:#3b82f6;
|
|
281
|
-
color:#fff;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
.jt-modal-btn.primary:hover{
|
|
285
|
-
background:#2563eb;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/* SECONDARY */
|
|
289
|
-
|
|
290
|
-
.jt-modal-btn.secondary{
|
|
291
|
-
background:#e5e7eb;
|
|
292
|
-
color:#111;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.jt-modal-btn.secondary:hover{
|
|
296
|
-
background:#d1d5db;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/* OUTLINE */
|
|
300
|
-
|
|
301
|
-
.jt-modal-btn.outline{
|
|
302
|
-
background:transparent;
|
|
303
|
-
border:1px solid currentColor;
|
|
304
|
-
color:inherit;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
.jt-modal-btn.outline:hover{
|
|
308
|
-
background:rgba(255,255,255,.06);
|
|
309
|
-
}
|
|
141
|
+
.jt-modal{width:100%;max-width:520px;border-radius:18px;padding:24px;opacity:0;transform:translateY(40px) scale(.96);transition:transform .35s cubic-bezier(.16,1,.3,1),opacity .25s ease;will-change:transform,opacity;}
|
|
142
|
+
.jt-modal.show{opacity:1;transform:translateY(0) scale(1);}
|
|
143
|
+
.jt-modal-btn{padding:8px 14px;border-radius:8px;font-size:14px;cursor:pointer;border:none;transition:all .18s ease;}
|
|
144
|
+
.jt-modal-btn.primary{background:#3b82f6;color:#fff}
|
|
145
|
+
.jt-modal-btn.primary:hover{background:#2563eb}
|
|
146
|
+
.jt-modal-btn.secondary{background:#e5e7eb;color:#111}
|
|
147
|
+
.jt-modal-btn.secondary:hover{background:#d1d5db}
|
|
148
|
+
.jt-modal-btn.outline{background:transparent;border:1px solid currentColor;color:inherit}
|
|
149
|
+
.jt-modal-btn.outline:hover{background:rgba(255,255,255,.06)}
|
|
310
150
|
|
|
311
151
|
/* PARALLAX */
|
|
312
|
-
|
|
313
|
-
[data-juice-root][data-parallax="true"] .juice-toast{
|
|
314
|
-
transition:transform .12s cubic-bezier(.2,.8,.2,1),opacity .2s;
|
|
315
|
-
}
|
|
152
|
+
[data-juice-root][data-parallax="true"] .juice-toast{transition:transform .12s cubic-bezier(.2,.8,.2,1),opacity .2s;}
|
|
316
153
|
|
|
317
154
|
/* GLASS FEATURE */
|
|
318
|
-
|
|
319
|
-
[data-juice-root][data-glass="true"] .juice-toast{
|
|
320
|
-
background:rgba(30,30,30,.55);
|
|
321
|
-
backdrop-filter:blur(14px) saturate(140%);
|
|
322
|
-
border:1px solid rgba(255,255,255,.08);
|
|
323
|
-
}
|
|
155
|
+
[data-juice-root][data-glass="true"] .juice-toast{background:rgba(30,30,30,.55);backdrop-filter:blur(14px) saturate(140%);border:1px solid rgba(255,255,255,.08);}
|
|
324
156
|
|
|
325
157
|
/* REDUCED MOTION */
|
|
326
|
-
|
|
327
|
-
@media (prefers-reduced-motion:reduce){
|
|
328
|
-
.juice-toast,
|
|
329
|
-
.jt-modal{
|
|
330
|
-
animation:none!important;
|
|
331
|
-
transition:none!important;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
`;function te(e=B){if(!P||me||(me=!0,document.getElementById("juice-toast-style")))return;const a=document.createElement("style");a.id="juice-toast-style",a.textContent=e,document.head.appendChild(a)}const ae=(()=>{let e=1;return()=>"jt-"+Date.now().toString(36)+"-"+e++})();function w(){return Date.now()}function D(e,a){return Object.assign({},e||{},a||{})}function M(e,a,t){return Math.max(a,Math.min(t,e))}function U(e,a,t){return e+(a-e)*t}function J(e){if(!e)return"";const a=document.createElement("template");a.innerHTML=e,a.content.querySelectorAll("script, style, iframe, object, embed").forEach(i=>i.remove());const t=new Set(["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"]),l=/^(https?:\/\/|mailto:|tel:|\/\/)/i;return(function i(r){Array.from(r.childNodes).forEach(s=>{if(s.nodeType===1){const p=s.tagName.toLowerCase();t.has(p)?(Array.from(s.attributes||[]).forEach(f=>{const h=f.name.toLowerCase(),u=(f.value||"").trim();h.startsWith("on")?s.removeAttribute(f.name):h==="src"||h==="href"||h==="xlink:href"?l.test(u)?/^data:\s*image\/svg\+xml/i.test(u)&&s.removeAttribute(f.name):s.removeAttribute(f.name):(p==="img"&&h==="srcset"||h==="style")&&s.removeAttribute(f.name)}),i(s)):s.replaceWith(...Array.from(s.childNodes))}})})(a.content),a.innerHTML}const N={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},fe={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},Ee={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},$={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,glassOnly:!1,playSound:null,dev:!1,injectCSS:!0,css:null,autoDedupe:!1,maxVisiblePerType:{},parallaxMode:!1,autoFetchFA:!0,use3d:!1,parallaxSmoothing:.12,_maxRequeueRetries:8},_config:{},_theme:"dark",_plugins:[],_queue:new K,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],_faInjected:!1,_schedulerRunning:!1,_schedulerLast:0,_schedulerRAF:null,_pausedAll:!1,setup(e={}){const a=e,{duration:t,maxVisible:l}=a,i=je(a,["duration","maxVisible"]);typeof t=="number"&&(this._defaults.duration=t),typeof l=="number"&&(this._defaults.maxVisible=l),typeof e.autoDedupe=="boolean"&&(this._defaults.autoDedupe=e.autoDedupe),e.maxVisiblePerType&&(this._defaults.maxVisiblePerType=D(this._defaults.maxVisiblePerType,e.maxVisiblePerType)),typeof e.parallaxMode=="boolean"&&(this._defaults.parallaxMode=e.parallaxMode),typeof e.autoFetchFA=="boolean"&&(this._defaults.autoFetchFA=e.autoFetchFA),typeof e.use3d=="boolean"&&(this._defaults.use3d=e.use3d),typeof e.parallaxSmoothing=="number"&&(this._defaults.parallaxSmoothing=M(e.parallaxSmoothing,0,1)),typeof e._maxRequeueRetries=="number"&&(this._defaults._maxRequeueRetries=e._maxRequeueRetries),this._config=D(this._config,i),this._registerTypes(),this._defaults.injectCSS!==!1&&te(this._defaults.css||B)},use(e){typeof e=="function"&&this._plugins.push(e)},addType(e,a={}){this._config[e]=a,this._registerTypes()},defineTheme(e,a={}){N[e]=D(N[e]||{},a)},setTheme(e){this._theme=e,P&&this._roots.forEach(a=>a.dataset.theme=e)},clear(){this._queue=new K,this._queueDedupe.clear()},destroy(){this.clear(),P&&(this._roots.forEach(e=>{try{e._parallaxRAF&&cancelAnimationFrame(e._parallaxRAF),e._parallaxHandler&&(e.removeEventListener("mousemove",e._parallaxHandler),e.removeEventListener("touchmove",e._parallaxHandler)),e._parallaxReset&&(e.removeEventListener("mouseleave",e._parallaxReset),e.removeEventListener("touchend",e._parallaxReset)),e.remove()}catch(a){}}),this._roots.clear(),Array.from(this._activeMap.keys()).forEach(e=>this.remove(e)),this._stopScheduler())},promise(e,a={}){if(!e||typeof e.then!="function"){this._warn("promise expects a Promise");return}const t=ae(),l=a.timeout;let i=null,r=!1,s=!1;const p=()=>{i&&(clearTimeout(i),i=null)};return this._enqueue("loading",ee(Z({},ke(a.loading,"Loading...")),{groupId:t,duration:0})),l&&(i=setTimeout(()=>{s||r||(s=!0,p(),this._enqueue("error",{message:a.timeoutMessage||"Request timeout",groupId:t}))},l)),e.then(f=>{r||s||(s=!0,p(),this._enqueue("success",ee(Z({},ye(a.success,f,"Success")),{groupId:t})))}).catch(f=>{r||s||(s=!0,p(),this._enqueue("error",ee(Z({},ye(a.error,f,"Error")),{groupId:t})))}),{cancel:()=>{r||s||(r=!0,p(),this._enqueue("info",{message:a.cancelMessage||"Cancelled",groupId:t}))}}},modal(e={}){var a;if(!P)return;this._defaults.injectCSS!==!1&&te(this._defaults.css||B);const t=D({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme,use3d:void 0},e),l=t.use3d===void 0?this._defaults.use3d:!!t.use3d,i=N[t.theme]||N.dark,r=document.createElement("div");r.className="jt-modal-overlay",r.style.pointerEvents=t.block?"all":"none",t.blur||(r.style.backdropFilter="none",r.style.webkitBackdropFilter="none");const s=document.createElement("div");if(s.className=`jt-modal jt-anim-${t.animation}`,s.style.background=i.bg,s.style.color=i.color,s.style.border=i.border||"none",l&&(r.style.perspective=r.style.perspective||"900px",s.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),t.title){const u=document.createElement("div");u.className="jt-modal-header",u.textContent=t.title,s.appendChild(u)}const p=document.createElement("div");if(p.className="jt-modal-body",t.html?p.innerHTML=J(t.html):p.textContent=t.message||"",s.appendChild(p),(a=t.actions)!=null&&a.length){const u=document.createElement("div");u.className="jt-modal-actions",t.actions.forEach(y=>{const _=document.createElement("button"),v=y.buttonType||(y.primary?"primary":"secondary");_.className=`jt-modal-btn ${v}`,_.textContent=y.label||"OK",_.onclick=j=>{var L;j.stopPropagation(),(L=y.onClick)==null||L.call(y,j),y.closeOnClick!==!1&&h()},u.appendChild(_)}),s.appendChild(u)}r.appendChild(s),document.body.appendChild(r),this._modalStack.push(r),t.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{r.classList.add("show"),s.classList.add("show"),l&&(s.style.transform="translateY(0) scale(1) rotateX(0deg)")});const f=u=>{u.key==="Escape"&&h()};t.closable&&(t.closeOnOverlay&&r.addEventListener("click",u=>{u.target===r&&h()}),document.addEventListener("keydown",f));const h=()=>{r.classList.remove("show"),s.classList.remove("show"),l&&(s.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),setTimeout(()=>{try{r.remove()}catch(y){}t.block&&(document.body.style.overflow=""),document.removeEventListener("keydown",f);const u=this._modalStack.indexOf(r);u>=0&&this._modalStack.splice(u,1)},300)};return{close:h}},_registerTypes(){Object.keys(this._config).forEach(e=>{if(typeof this[e]=="function"&&!this[e].__auto)return;const a=t=>this._enqueue(e,t);a.__auto=!0,this[e]=a})},_enqueue(e,a={}){var t,l;const i=typeof a.priority=="number"?a.priority:(l=(t=this._priorityMap)==null?void 0:t[a.priority])!=null?l:2,r=a.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,a):void 0);if(r&&this._queueDedupe.has(r)){this._defaults.dev&&console.log("[JuiceToast] deduped (queue)",r);return}const s={id:ae(),type:e,payload:a,priority:i};return s._retries=0,r&&(s._dedupeKey=r,this._queueDedupe.add(r)),this._queue.push(s,i),this._scheduleProcessQueue(),s.id},_processQueueScheduled:!1,_scheduleProcessQueue(){this._processQueueScheduled||(this._processQueueScheduled=!0,setTimeout(()=>{this._processQueueScheduled=!1,this._processQueue()},40))},_processQueue(){var e,a;if(!P)return;const t=this._defaults.maxVisible||1/0;let l=0;for(;this._queue.size>0&&l<200;){l++;const i=this._queue.pop();if(!i)break;const r=((e=i.payload)==null?void 0:e.position)||((a=i.payload)==null?void 0:a.toast)||"bottom-right",s=this._getRoot(r);if(!s){if(i._retries=(i._retries||0)+1,i._retries>(this._defaults._maxRequeueRetries||8)){i._dedupeKey&&this._queueDedupe.delete(i._dedupeKey);continue}setTimeout(()=>{this._queue.push(i,i.priority)},120);break}if(Array.from(s.children).length>=t){if(i._retries=(i._retries||0)+1,i._retries>(this._defaults._maxRequeueRetries||8)){i._dedupeKey&&this._queueDedupe.delete(i._dedupeKey);continue}setTimeout(()=>this._queue.push(i,i.priority),160);break}const p=(this._defaults.maxVisiblePerType||{})[i.type];if(typeof p=="number"&&Array.from(s.children).filter(f=>f.dataset.toastType===i.type).length>=p){if(i._retries=(i._retries||0)+1,i._retries>(this._defaults._maxRequeueRetries||8)){i._dedupeKey&&this._queueDedupe.delete(i._dedupeKey);continue}setTimeout(()=>this._queue.push(i,i.priority),160);break}this._showToast(i.type,i.payload,i.id)}},_getRoot(e="bottom-right"){var a;if(!P)return null;if(this._roots.has(e))return this._roots.get(e);const t=document.createElement("div");switch(t.setAttribute("data-juice-root","1"),t.id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.pointerEvents="none",t.style.display="flex",t.style.flexDirection="column",this._defaults.parallaxMode&&(t.dataset.parallax="true"),e){case"top-left":t.style.top="20px",t.style.left="20px";break;case"top-right":t.style.top="20px",t.style.right="20px";break;case"bottom-left":t.style.bottom="20px",t.style.left="20px";break;case"bottom-right":t.style.bottom="20px",t.style.right="20px";break;case"top-center":t.style.top="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;case"bottom-center":t.style.bottom="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;default:t.style.bottom="20px",t.style.right="20px"}if(document.body.appendChild(t),this._defaults.parallaxMode&&!F){const l=(a=this._defaults.parallaxSmoothing)!=null?a:.12;t._parallaxTargets=new WeakMap;const i=s=>{const p=t.getBoundingClientRect(),f=p.left+p.width/2,h=p.top+p.height/2,u=s.touches?s.touches[0].clientX:s.clientX,y=s.touches?s.touches[0].clientY:s.clientY;Array.from(t.children).forEach((_,v)=>{const j=(v+1)/Math.max(1,t.children.length),L=M((u-f)/p.width*j*12,-18,18),R=M((y-h)/p.height*j*8,-14,14),q=M(-j*8,-30,0),oe=M((u-f)/p.width*j*-6,-12,12),re=M((y-h)/p.height*j*4,-8,8),o={tx:L,ty:R,tz:q,rotX:re,rotY:oe,smoothing:l};t._parallaxTargets.set(_,o)}),this._startScheduler()},r=()=>{Array.from(t.children).forEach(s=>{t._parallaxTargets.set(s,{tx:0,ty:0,tz:0,rotX:0,rotY:0,smoothing:.16})}),this._startScheduler()};t._parallaxHandler=i,t._parallaxReset=r,t.addEventListener("mousemove",i),t.addEventListener("touchmove",i,{passive:!0}),t.addEventListener("mouseleave",r),t.addEventListener("touchend",r)}return this._roots.set(e,t),t},_warn(e){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",e)},_ensureFA(){if(!(!P||this._faInjected||!this._defaults.autoFetchFA)){if(document.querySelector('link[href*="fontawesome"], link[href*="font-awesome"], link[href*="cdnjs.cloudflare.com/ajax/libs/font-awesome"]')){this._faInjected=!0;return}try{const e=document.createElement("link");e.rel="stylesheet",e.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css",e.crossOrigin="anonymous",document.head.appendChild(e),this._faInjected=!0}catch(e){console.error("[JuiceToast]: Fetching icons failed:",e)}}},_playSound(e){if(!P)return;const a=typeof e=="string"&&e?e:this._defaults.playSound;if(a)try{const t=new Audio(a);t.volume=.6,t.play().catch(()=>{})}catch(t){}},_updateStackPositionsFor(e){const a=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),a.forEach((t,l)=>{const i=l,r=i*12;t.style.setProperty("--jt-stack-y",`${-r}px`),t.style.setProperty("--jt-stack-scale",1-i*.04),t.style.setProperty("--jt-stack-opacity",1-i*.12),t.style.zIndex=1e3-i,t.style.setProperty("--jt-parallax-z",`${-i*2}px`),t.dataset.stack=String(i)})},_runPlugins(e){this._plugins.forEach(a=>{try{a(e)}catch(t){this._warn("Plugin error: "+((t==null?void 0:t.message)||t))}})},_normalizeGlass(e){if(e===!0)return 60;if(!e)return 0;const a=Number(e);return Number.isFinite(a)?M(a,0,100):0},_computeDedupeKey(e,a){try{const t=e||"",l=a.title||"",i=a.message||a.html||"";return`${t}::${String(l).trim().slice(0,200)}::${String(i).trim().slice(0,500)}`}catch(t){return}},_showToast(e,a={},t){var l,i,r,s,p,f,h,u,y,_,v,j,L,R,q;if(!P)return;this._defaults.injectCSS!==!1&&te(this._defaults.css||B),this._ensureFA();const oe=this._config[e]||{},re=typeof a=="object"?a:{message:String(a)},o=D(oe,re);o.icon=(l=o.icon)!=null?l:o.icon_left_top,o.position=(r=(i=o.position)!=null?i:o.toast)!=null?r:"bottom-right",o.closable=(p=(s=o.closable)!=null?s:o.closeable)!=null?p:!0,o.duration=typeof o.duration=="number"?o.duration:this._defaults.duration;const G=N[o.theme||this._theme]||{},k=t||ae(),H=o.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,o):void 0);if(H)for(const c of this._roots.values()){const d=Array.from(c.children).find(b=>b.dataset.dedupeKey===H);if(d){let b=d._cachedCountEl;if(b||(b=document.createElement("span"),b.className="jt-count",b.style.marginLeft="6px",(f=d.querySelector(".jt-title"))==null||f.appendChild(b),d._cachedCountEl=b,b.textContent="1"),b.textContent=String(parseInt(b.textContent||"1")+1),o.mergeMessage){const E=d.querySelector(".jt-message");E&&(o.html?E.innerHTML=J(o.html):E.textContent=String(o.message||""))}return d.dataset.toastId}}const n=document.createElement("div");if(n.className="juice-toast",n.dataset.toastId=k,n.dataset.position=o.position,n.dataset.toastType=e,H&&(n.dataset.dedupeKey=H),n.tabIndex=0,n.setAttribute("role",o.ariaRole||(e==="error"?"alert":"status")),n.getAttribute("aria-live")||(n.setAttribute("aria-live",e==="error"||e==="success"?"assertive":"polite"),n.setAttribute("aria-atomic","true")),n.style.position="relative",n.style.pointerEvents="auto",o.glassOnly?(n.style.background="rgba(255,255,255,0.35)",n.style.backdropFilter="blur(14px) saturate(140%)",n.style.webkitBackdropFilter="blur(14px) saturate(140%)",n.style.color="rgba(15,23,42,0.85)",n.style.border="1px solid rgba(0,0,0,0.08)",n.style.boxShadow="0 8px 28px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.25)"):(n.style.background=o.bg||G.bg,n.style.color=o.color||G.color,n.style.border=o.border||G.border||"none"),n.style.minHeight=n.style.minHeight||"",n.style.setProperty("--jt-parallax-x","0px"),n.style.setProperty("--jt-parallax-y","0px"),n.style.setProperty("--jt-parallax-z","0px"),n.style.setProperty("--jt-drag-x","0px"),n.style.setProperty("--jt-drag-y","0px"),n.style.setProperty("--jt-rot-x","0deg"),n.style.setProperty("--jt-rot-y","0deg"),n.style.setProperty("--jt-stack-y","0px"),n.style.setProperty("--jt-stack-scale","1"),o.size&&fe[o.size]){const c=fe[o.size];c.width&&(n.style.width=c.width),c.padding&&(n.style.padding=c.padding)}const S=document.createElement("div");S.className="jt-content";let V=null;o.title&&(V=document.createElement("div"),V.className="jt-title",V.textContent=o.title,S.appendChild(V));const I=document.createElement("div");if(I.className="jt-message",o.html?I.innerHTML=J(o.html):typeof o.message=="string"?o.message.split(/(`[^`]+`)/g).forEach(c=>{if(c.startsWith("`")&&c.endsWith("`")){const d=document.createElement("code");d.textContent=c.slice(1,-1),I.appendChild(d)}else I.appendChild(document.createTextNode(c))}):o.message&&(I.textContent=String(o.message)),S.appendChild(I),Array.isArray(o.actions)&&o.actions.length){const c=document.createElement("div");c.className="jt-actions",o.actions.forEach(d=>{const b=document.createElement("button");b.className="jt-action",b.textContent=d.label||"Action",b.onclick=E=>{var X;E.stopPropagation(),(X=d.onClick)==null||X.call(d,E),d.closeOnClick!==!1&&this.remove(k)},c.appendChild(b)}),S.appendChild(c)}o.glassOnly||(o.bgImage?(n.style.backgroundImage=`url(${o.bgImage})`,n.style.backgroundSize=o.bgSize||"cover",n.style.backgroundPosition=o.bgPosition||"center"):n.style.background=o.bg||G.bg);let x=null;if(o.icon){x=document.createElement("i");const c=String(o.icon).startsWith("fa")?o.icon:`fa-${o.icon}`;if(x.className=["icon",o.iconPack||"",c].join(" ").trim(),o.iconSize&&(x.style.fontSize=o.iconSize),!F){const d=o.iconAnim||Ee[e];d&&x.classList.add(d)}(o.iconLink||o.iconAnimate)&&(x.classList.add("icon-clickable"),x.addEventListener("click",d=>{d.stopPropagation(),o.iconAnimate&&(x.classList.remove(o.iconAnimate),x.offsetWidth,x.classList.add(o.iconAnimate)),o.iconLink&&window.open(o.iconLink,"_blank","noopener")}))}let g=null;if(o.avatar){g=document.createElement("img");const c=typeof o.avatar=="string"&&o.avatar?o.avatar:o.avatarSrc||"";c&&(g.src=c),g.alt=o.avatarAlt||o.title||"avatar",g.className="jt-avatar",g.loading=o.avatarLazy?"lazy":"eager",g.style.width=g.style.width||"36px",g.style.height=g.style.height||"36px",g.style.borderRadius=g.style.borderRadius||"50%",g.style.objectFit=g.style.objectFit||"cover",g.style.flexShrink="0";const d=o.avatarPosition||"left";d==="left"?g.style.marginRight=(h=o.avatarSpacing)!=null?h:"10px":d==="right"?g.style.marginLeft=(u=o.avatarSpacing)!=null?u:"10px":d==="top"&&(g.style.marginBottom=(y=o.avatarSpacing)!=null?y:"8px")}const se=o.avatarPosition||"left";g&&se==="top"?(n.classList.add("jt-avatar-top"),n.style.flexDirection="column",n.style.alignItems="flex-start",n.appendChild(g),x&&o.iconPosition==="top"?(n.appendChild(x),n.appendChild(S)):x&&o.iconPosition==="right"?(n.appendChild(S),n.appendChild(x)):(x&&n.appendChild(x),n.appendChild(S))):(n.style.flexDirection="row",n.style.alignItems="center",g&&se==="left"&&n.appendChild(g),x&&o.iconPosition==="right"?(n.appendChild(S),n.appendChild(x)):x&&o.iconPosition==="top"?(n.classList.add("jt-icon-top"),n.appendChild(x),n.appendChild(S)):(x&&n.appendChild(x),n.appendChild(S)),g&&se==="right"&&n.appendChild(g));let W=null;if(o.progress&&((_=o.duration)!=null?_:this._defaults.duration)>0&&(W=document.createElement("div"),W.className="jt-progress",o.progressColor&&(W.style.background=o.progressColor),n.appendChild(W)),o.undo){const c=document.createElement("button");c.className="jt-action",c.textContent="Undo",c.onclick=()=>{try{o.undo()}catch(d){}this.remove(k)},S.appendChild(c)}if(o.closable){const c=document.createElement("span");c.className="juice-toast-close",c.tabIndex=0,c.textContent="\xD7",c.style.marginLeft="8px",c.addEventListener("click",d=>{d.stopPropagation(),this.remove(k)}),n.appendChild(c)}const C=this._getRoot(o.position||"bottom-right");if(!C)return;if(o.groupId){const c=Array.from(C.children).find(d=>d.dataset.groupId===o.groupId);if(c){const d=c.dataset.toastId;return this.update(d,{title:o.title,message:o.message,html:o.html,bg:o.bg,color:o.color,duration:o.duration,icon:o.icon,iconPack:o.iconPack}),d}n.dataset.groupId=o.groupId}const ge=this._defaults.maxVisible;if(ge&&C.children.length>=ge){const c=C.firstElementChild;if(c&&c.dataset&&c.dataset.toastId)this.remove(c.dataset.toastId);else try{C.removeChild(C.firstElementChild)}catch(d){}}C.appendChild(n),n._cachedTitleEl=V,n._cachedMessageEl=I,n._cachedProgressEl=W;const m={id:k,toast:n,cfg:o,type:e,createdAt:w(),remaining:(v=o.duration)!=null?v:this._defaults.duration,timer:null,start:w(),paused:!1,_boundMove:null,_boundUp:null,_onPointerDown:null,_onEnter:null,_onLeave:null,dedupeKey:H,hooks:{onShow:o.onShow,onShown:o.onShown,onClose:o.onClose,onRemoved:o.onRemoved}};this._activeMap.set(k,m);try{(L=(j=m.hooks).onShow)==null||L.call(j,{id:k,toast:n,cfg:o,type:e})}catch(c){}this._runPlugins({toast:n,cfg:o,type:e,root:C,meta:m}),this._updateStackPositionsFor(C),requestAnimationFrame(()=>{var c,d;F?(n.style.opacity="1",(d=(c=m.hooks).onShown)==null||d.call(c,{id:k,toast:n,cfg:o,type:e})):(n.classList.add("show"),setTimeout(()=>{var b,E;try{(E=(b=m.hooks).onShown)==null||E.call(b,{id:k,toast:n,cfg:o,type:e})}catch(X){}},320))});let _e=0,be=0,A=0,z=0,ne=!1,O=null,ie=0;const le=c=>{const d=c.touches?c.touches[0]:c;_e=d.clientX,be=d.clientY,A=0,z=0,ne=!0,O=null,m.paused=!0,n.style.transition="none",m._boundMove=we,m._boundUp=Se,document.addEventListener("touchmove",m._boundMove,{passive:!0}),document.addEventListener("mousemove",m._boundMove),document.addEventListener("touchend",m._boundUp),document.addEventListener("mouseup",m._boundUp),ie=w()},we=c=>{if(!ne)return;const d=c.touches?c.touches[0]:c;A=d.clientX-_e,z=d.clientY-be,O||(Math.abs(A)>6?O="x":Math.abs(z)>6&&(O="y")),O==="x"?n.style.setProperty("--jt-drag-x",`${A}px`):O==="y"&&n.style.setProperty("--jt-drag-y",`${z}px`),ie=w(),d.clientX},Se=c=>{ne=!1,m.paused=!1;const d=Math.abs(A),b=Math.abs(z),E=O||(d>b?"x":"y"),X=Math.max(1,w()-ie),Pe=X?A/X*1e3:0,Le=E==="x"&&(d>($._defaults.swipeThreshold||60)||Math.abs(Pe)>800),Ce=E==="y"&&b>($._defaults.swipeThreshold||80);if(Le||Ce){const Ae=A>=0?1:-1;E==="x"?n.style.setProperty("--jt-drag-x",`${Ae*1e3}px`):n.style.setProperty("--jt-drag-y","1000px"),n.classList.add("swipe-dismissing"),setTimeout(()=>this.remove(k),220)}else n.style.transition="transform 0.22s ease-out, opacity 0.22s ease-out",n.style.setProperty("--jt-drag-x","0px"),n.style.setProperty("--jt-drag-y","0px");A=z=0,m._boundMove&&(document.removeEventListener("touchmove",m._boundMove),document.removeEventListener("mousemove",m._boundMove),m._boundMove=null),m._boundUp&&(document.removeEventListener("touchend",m._boundUp),document.removeEventListener("mouseup",m._boundUp),m._boundUp=null),m.start=w(),this._startScheduler()};n._onPointerDown=le,n.addEventListener("touchstart",le,{passive:!0}),n.addEventListener("mousedown",le);const ce=()=>{m.paused=!0},de=()=>{m.paused&&(m.paused=!1,m.start=w(),this._startScheduler())};return m._onEnter=ce,m._onLeave=de,n.addEventListener("mouseenter",ce),n.addEventListener("mouseleave",de),n.addEventListener("focusin",ce),n.addEventListener("focusout",de),m.start=w(),m.remaining=(R=o.duration)!=null?R:this._defaults.duration,m.paused=!1,((q=o.duration)!=null?q:this._defaults.duration)>0&&this._startScheduler(),o.undoTimeout&&(m.timer=setTimeout(()=>this.remove(k),o.undoTimeout)),(o.playSound||this._defaults.playSound)&&this._playSound(o.playSound||this._defaults.playSound),k},_startScheduler(){if(this._schedulerRunning)return;this._schedulerRunning=!0;const e=a=>{const t=w();this._schedulerLast=t,this._pausedAll||this._activeMap.forEach((r,s)=>{var p;if(!r||r.paused)return;const f=(p=r.cfg.duration)!=null?p:this._defaults.duration;if(f<=0)return;const h=t-r.start,u=Math.max(0,Math.min(h,1e3));r.remaining-=u,r.start=t;const y=r.toast._cachedProgressEl||r.toast.querySelector(".jt-progress");if(y){const _=Math.max(0,r.remaining/f);y.style.transform=`scaleX(${_})`}r.remaining<=0&&(F||r.toast.classList.remove("show"),setTimeout(()=>this.remove(s),280))}),this._roots.forEach(r=>{!r._parallaxTargets||!r.children.length||Array.from(r.children).forEach(s=>{var p,f,h;const u=r._parallaxTargets.get(s)||{tx:0,ty:0,tz:0,rotX:0,rotY:0,smoothing:(p=this._defaults.parallaxSmoothing)!=null?p:.12};s._jtPrev=s._jtPrev||{tx:0,ty:0,tz:0,rotX:0,rotY:0};const y=s._jtPrev,_=(h=u.smoothing)!=null?h:(f=this._defaults.parallaxSmoothing)!=null?f:.12,v=U(y.tx,u.tx||0,_),j=U(y.ty,u.ty||0,_),L=U(y.tz,u.tz||0,_),R=U(y.rotX,u.rotX||0,_),q=U(y.rotY,u.rotY||0,_);s.style.setProperty("--jt-parallax-x",`${v}px`),s.style.setProperty("--jt-parallax-y",`${j}px`),s.style.setProperty("--jt-parallax-z",`${L}px`),s.style.setProperty("--jt-rot-x",`${R}deg`),s.style.setProperty("--jt-rot-y",`${q}deg`),s._jtPrev.tx=v,s._jtPrev.ty=j,s._jtPrev.tz=L,s._jtPrev.rotX=R,s._jtPrev.rotY=q})});let l=!1;this._activeMap.forEach(r=>{var s;((s=r.cfg.duration)!=null?s:this._defaults.duration)>0&&!r.paused&&(l=!0)});let i=!1;this._roots.forEach(r=>{r._parallaxTargets&&r.children.length&&(i=!0)}),!l&&!i?this._stopScheduler():this._schedulerRAF=requestAnimationFrame(e)};this._schedulerRAF=requestAnimationFrame(e)},_stopScheduler(){this._schedulerRunning&&(this._schedulerRAF&&cancelAnimationFrame(this._schedulerRAF),this._schedulerRAF=null,this._schedulerRunning=!1,this._schedulerLast=0)},remove(e){var a,t,l,i;const r=this._activeMap.get(e);if(!r)return!1;const{toast:s,cfg:p,type:f}=r;try{(t=(a=r.hooks).onClose)==null||t.call(a,{id:e,toast:s,cfg:p,type:f})}catch(u){}F?s.style.opacity="0":s.classList.add("hide");try{s._onPointerDown&&(s.removeEventListener("touchstart",s._onPointerDown),s.removeEventListener("mousedown",s._onPointerDown))}catch(u){}if(r._boundMove){try{document.removeEventListener("touchmove",r._boundMove),document.removeEventListener("mousemove",r._boundMove)}catch(u){}r._boundMove=null}if(r._boundUp){try{document.removeEventListener("touchend",r._boundUp),document.removeEventListener("mouseup",r._boundUp)}catch(u){}r._boundUp=null}try{r._onEnter&&s.removeEventListener("mouseenter",r._onEnter),r._onLeave&&s.removeEventListener("mouseleave",r._onLeave),r._onEnter&&s.removeEventListener("focusin",r._onEnter),r._onLeave&&s.removeEventListener("focusout",r._onLeave)}catch(u){}r.timer&&(clearTimeout(r.timer),r.timer=null),this._activeMap.delete(e);const h=s.parentNode;if(h){const u=()=>{var y,_;try{s.parentNode&&s.parentNode.removeChild(s)}catch(v){}try{if(h.children.length===0){try{h._parallaxHandler&&(h.removeEventListener("mousemove",h._parallaxHandler),h.removeEventListener("touchmove",h._parallaxHandler)),h._parallaxReset&&(h.removeEventListener("mouseleave",h._parallaxReset),h.removeEventListener("touchend",h._parallaxReset)),h.remove()}catch(v){}this._roots.delete(h.dataset.position)}else this._updateStackPositionsFor(h)}catch(v){}if(r.dedupeKey)try{this._queueDedupe.delete(r.dedupeKey)}catch(v){}try{(_=(y=r.hooks).onRemoved)==null||_.call(y,{id:e,cfg:p,type:f})}catch(v){}};if(F)u();else{const y=_=>{_.target===s&&(s.removeEventListener("animationend",y),u())};s.addEventListener("animationend",y),setTimeout(u,700)}}else{if(r.dedupeKey)try{this._queueDedupe.delete(r.dedupeKey)}catch(u){}try{(i=(l=r.hooks).onRemoved)==null||i.call(l,{id:e,cfg:p,type:f})}catch(u){}}return!0},update(e,a={}){const t=this._activeMap.get(e);if(!t)return this._warn("update: id not found "+e),!1;const{toast:l}=t;if(t.cfg=D(t.cfg,a),t.cfg.title){const s=l.querySelector(".jt-title")||l._cachedTitleEl;s&&(s.textContent=t.cfg.title)}const i=l.querySelector(".jt-message")||l._cachedMessageEl;i&&(t.cfg.html?i.innerHTML=J(t.cfg.html):i.textContent=String(t.cfg.message||""));const r=N[t.cfg.theme||this._theme]||{};if(l.style.background=t.cfg.bg||r.bg,l.style.color=t.cfg.color||r.color,l.style.border=t.cfg.border||r.border||"none",t.cfg.duration!==void 0){t.remaining=t.cfg.duration,t.start=w(),t.paused||this._startScheduler();const s=t.toast._cachedProgressEl||t.toast.querySelector(".jt-progress");s&&(s.style.transform="scaleX(1)")}return this._runPlugins({toast:l,cfg:t.cfg,type:t.type,meta:t}),!0},_priorityMap:{low:1,normal:2,high:3,urgent:4},pauseAll(){this._pausedAll=!0},resumeAll(){this._pausedAll=!1,this._activeMap.forEach(e=>e.start=w()),this._startScheduler()},dismissAll(e={}){const a=e.type,t=e.position,l=[];this._activeMap.forEach((i,r)=>{const s=a?i.type===a:!0,p=t?(i.cfg.position||i.toast.dataset.position)===t:!0;s&&p&&l.push(r)}),l.forEach(i=>this.remove(i))},listActive(){const e=[];return this._activeMap.forEach((a,t)=>{e.push({id:t,type:a.type,remaining:a.remaining,createdAt:a.createdAt,position:a.cfg.position})}),e}};function ke(e,a){return e?typeof e=="string"?{message:e}:e:{message:a}}function ye(e,a,t){return e?typeof e=="function"?{message:e(a)}:typeof e=="string"?{message:e}:e:{message:t}}$.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:4e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"fa-spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}}),T.default=$,T.juiceToast=$,Object.defineProperty(T,"__esModule",{value:!0})}));
|
|
158
|
+
@media (prefers-reduced-motion:reduce){.juice-toast,.jt-modal{animation:none!important;transition:none!important;}}
|
|
159
|
+
`;function ae(e=G){if(!C||fe||(fe=!0,document.getElementById("juice-toast-style")))return;const a=document.createElement("style");a.id="juice-toast-style",a.textContent=e,document.head.appendChild(a)}const oe=(()=>{let e=1;return()=>"jt-"+Date.now().toString(36)+"-"+e++})();function L(){return Date.now()}function z(e,a){return Object.assign({},e||{},a||{})}function q(e,a,t){return Math.max(a,Math.min(t,e))}function U(e,a,t){return e+(a-e)*t}function J(e){if(!e)return"";const a=document.createElement("template");a.innerHTML=e,a.content.querySelectorAll("script, style, iframe, object, embed").forEach(c=>c.remove());const t=new Set(["b","i","u","strong","em","code","pre","ul","ol","li","br","p","span","img","h1","h2","h3","h4","h5","h6","a"]),n=/^(https?:\/\/|mailto:|tel:|\/\/)/i;return(function c(r){Array.from(r.childNodes).forEach(s=>{if(s.nodeType===1){const m=s.tagName.toLowerCase();t.has(m)?(Array.from(s.attributes||[]).forEach(l=>{const h=l.name.toLowerCase(),d=(l.value||"").trim();h.startsWith("on")?s.removeAttribute(l.name):h==="src"||h==="href"||h==="xlink:href"?(!n.test(d)||/^data:\s*image\/svg\+xml/i.test(d))&&s.removeAttribute(l.name):(m==="img"&&h==="srcset"||h==="style")&&s.removeAttribute(l.name)}),c(s)):s.replaceWith(...Array.from(s.childNodes))}})})(a.content),a.innerHTML}const F={dark:{bg:"linear-gradient(180deg,#1f2937,#111827)",color:"#fff",border:"1px solid rgba(255,255,255,.06)"},light:{bg:"#fff",color:"#111",border:"1px solid #e5e7eb"},glass:{bg:"rgba(30,30,30,.35)",color:"#fff",border:"1px solid rgba(255,255,255,.1)"}},ye={sm:{width:"260px",padding:"10px"},md:{width:"320px",padding:"14px"},lg:{width:"420px",padding:"18px"}},je={success:"jt-bounce",error:"jt-shake",warning:"jt-shake",info:"jt-pulse",loading:"jt-spin"},$={_defaults:{duration:2500,maxVisible:3,swipeThreshold:60,glassUI:0,glassOnly:!1,playSound:null,dev:!1,injectCSS:!0,css:null,autoDedupe:!1,maxVisiblePerType:{},parallaxMode:!1,autoFetchFA:!0,use3d:!1,parallaxSmoothing:.12,_maxRequeueRetries:8,urgentSkipsQueue:!1},_config:{},_theme:"dark",_plugins:[],_queue:new K,_queueDedupe:new Set,_activeMap:new Map,_roots:new Map,_modalStack:[],_faInjected:!1,_schedulerRunning:!1,_schedulerLast:0,_schedulerRAF:null,_pausedAll:!1,setup(e={}){const a=e,{duration:t,maxVisible:n,urgentSkipsQueue:c}=a,r=xe(a,["duration","maxVisible","urgentSkipsQueue"]);typeof t=="number"&&(this._defaults.duration=t),typeof n=="number"&&(this._defaults.maxVisible=n),typeof c=="boolean"&&(this._defaults.urgentSkipsQueue=c),typeof e.autoDedupe=="boolean"&&(this._defaults.autoDedupe=e.autoDedupe),e.maxVisiblePerType&&(this._defaults.maxVisiblePerType=z(this._defaults.maxVisiblePerType,e.maxVisiblePerType)),typeof e.parallaxMode=="boolean"&&(this._defaults.parallaxMode=e.parallaxMode),typeof e.autoFetchFA=="boolean"&&(this._defaults.autoFetchFA=e.autoFetchFA),typeof e.use3d=="boolean"&&(this._defaults.use3d=e.use3d),typeof e.parallaxSmoothing=="number"&&(this._defaults.parallaxSmoothing=q(e.parallaxSmoothing,0,1)),typeof e._maxRequeueRetries=="number"&&(this._defaults._maxRequeueRetries=e._maxRequeueRetries),this._config=z(this._config,r),this._registerTypes(),this._defaults.injectCSS!==!1&&ae(this._defaults.css||G)},use(e){typeof e=="function"&&this._plugins.push(e)},addType(e,a={}){this._config[e]=a,this._registerTypes()},defineTheme(e,a={}){F[e]=z(F[e]||{},a)},setTheme(e){this._theme=e,C&&this._roots.forEach(a=>a.dataset.theme=e)},clear(){this._queue=new K,this._queueDedupe.clear()},destroy(){this.clear(),C&&(this._roots.forEach(e=>{try{e._parallaxRAF&&cancelAnimationFrame(e._parallaxRAF),e._parallaxHandler&&(e.removeEventListener("mousemove",e._parallaxHandler),e.removeEventListener("touchmove",e._parallaxHandler)),e._parallaxReset&&(e.removeEventListener("mouseleave",e._parallaxReset),e.removeEventListener("touchend",e._parallaxReset)),e.remove()}catch(a){}}),this._roots.clear(),Array.from(this._activeMap.keys()).forEach(e=>this.remove(e)),this._stopScheduler())},promise(e,a={}){const t=typeof e=="function"?e():e;if(!t||typeof t.then!="function"){this._warn("promise expects a Promise or function returning Promise");return}const n=oe(),c=a.timeout;let r=null,s=!1,m=!1;const l=()=>{r&&(clearTimeout(r),r=null)},h=(f,g,v)=>f?Ee(f,g,v)||{message:v}:{message:v},d=(f,g)=>f?ke(f,g)||{message:g}:{message:g};return this._enqueue("loading",te(ee({},d(a.loading,"Loading...")),{groupId:n,duration:0})),c&&c>0&&(r=setTimeout(()=>{m||s||(m=!0,l(),this._enqueue("error",{message:a.timeoutMessage||"Request timeout",groupId:n}))},c)),t.then(f=>{s||m||(m=!0,l(),this._enqueue("success",te(ee({},h(a.success,f,"Success")),{groupId:n})))}).catch(f=>{s||m||(m=!0,l(),this._enqueue("error",te(ee({},h(a.error,f,"Error")),{groupId:n})))}),{cancel:()=>{s||m||(s=!0,l(),this._enqueue("info",{message:a.cancelMessage||"Cancelled",groupId:n}))}}},modal(e={}){var a;if(!C)return;this._defaults.injectCSS!==!1&&ae(this._defaults.css||G);const t=z({title:"",message:"",html:null,block:!0,blur:!0,closeOnOverlay:!0,closable:!0,animation:"scale",actions:[],theme:this._theme,use3d:void 0},e),n=t.use3d===void 0?this._defaults.use3d:!!t.use3d,c=F[t.theme]||F.dark,r=document.createElement("div");r.className="jt-modal-overlay",r.style.pointerEvents=t.block?"all":"none",t.blur||(r.style.backdropFilter="none",r.style.webkitBackdropFilter="none");const s=document.createElement("div");if(s.className=`jt-modal jt-anim-${t.animation}`,s.style.background=c.bg,s.style.color=c.color,s.style.border=c.border||"none",n&&(r.style.perspective=r.style.perspective||"900px",s.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),t.title){const d=document.createElement("div");d.className="jt-modal-header",d.textContent=t.title,s.appendChild(d)}const m=document.createElement("div");if(m.className="jt-modal-body",t.html?m.innerHTML=J(t.html):m.textContent=t.message||"",s.appendChild(m),(a=t.actions)!=null&&a.length){const d=document.createElement("div");d.className="jt-modal-actions",t.actions.forEach(f=>{const g=document.createElement("button"),v=f.buttonType||(f.primary?"primary":"secondary");g.className=`jt-modal-btn ${v}`,g.textContent=f.label||"OK",g.onclick=j=>{var k;j.stopPropagation(),(k=f.onClick)==null||k.call(f,j),f.closeOnClick!==!1&&h()},d.appendChild(g)}),s.appendChild(d)}r.appendChild(s),document.body.appendChild(r),this._modalStack.push(r),t.block&&(document.body.style.overflow="hidden"),requestAnimationFrame(()=>{r.classList.add("show"),s.classList.add("show"),n&&(s.style.transform="translateY(0) scale(1) rotateX(0deg)")});const l=d=>{d.key==="Escape"&&h()};t.closable&&(t.closeOnOverlay&&r.addEventListener("click",d=>{d.target===r&&h()}),document.addEventListener("keydown",l));const h=()=>{r.classList.remove("show"),s.classList.remove("show"),n&&(s.style.transform="translateY(40px) scale(.96) rotateX(8deg)"),setTimeout(()=>{try{r.remove()}catch(f){}t.block&&(document.body.style.overflow=""),document.removeEventListener("keydown",l);const d=this._modalStack.indexOf(r);d>=0&&this._modalStack.splice(d,1)},300)};return{close:h}},_registerTypes(){Object.keys(this._config).forEach(e=>{if(typeof this[e]=="function"&&!this[e].__auto)return;const a=t=>this._enqueue(e,t);a.__auto=!0,this[e]=a})},_enqueue(e,a={}){var t,n;const c=typeof a.priority=="number"?a.priority:(n=(t=this._priorityMap)==null?void 0:t[a.priority])!=null?n:2,r=a.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,a):void 0);if(r&&this._queueDedupe.has(r)){this._defaults.dev&&console.log("[JuiceToast] deduped (queue)",r);return}const s={id:oe(),type:e,payload:a,priority:c};return s._retries=0,r&&(s._dedupeKey=r,this._queueDedupe.add(r)),this._queue.push(s,c),this._scheduleProcessQueue(),s.id},enqueueBatch(e=[],a={}){const{interval:t=0}=a;if(!(!Array.isArray(e)||e.length===0)){if(!t){e.forEach(n=>this._enqueue(n.type||n._type||"info",n.payload||n));return}e.forEach((n,c)=>{setTimeout(()=>{this._enqueue(n.type||n._type||"info",n.payload||n)},c*t)})}},_processQueueScheduled:!1,_scheduleProcessQueue(){this._processQueueScheduled||(this._processQueueScheduled=!0,setTimeout(()=>{this._processQueueScheduled=!1,this._processQueue()},40))},_processQueue(){var e,a,t,n,c,r;if(!C)return;const s=this._defaults.maxVisible||1/0;let m=0;for(;this._queue.size>0&&m<200;){m++;const l=this._queue.pop();if(!l)break;const h=((e=l.payload)==null?void 0:e.position)||((a=l.payload)==null?void 0:a.toast)||"bottom-right",d=this._getRoot(h);if(!d){if(l._retries=(l._retries||0)+1,l._retries>(this._defaults._maxRequeueRetries||8)){l._dedupeKey&&this._queueDedupe.delete(l._dedupeKey);continue}setTimeout(()=>{this._queue.push(l,l.priority)},120);break}const f=d.children.length,g=this._priorityMap.urgent||4;if(this._defaults.urgentSkipsQueue&&l.priority>=g&&f>=s){let j=!1;for(let k=0;k<d.children.length;k++){const P=d.children[k];P.dataset.toastType;const w=Array.from(this._activeMap.values()).find(T=>T.toast===P);if(((r=(c=(t=w==null?void 0:w.cfg)==null?void 0:t.priority)!=null?c:(n=this._priorityMap)==null?void 0:n[w==null?void 0:w.type])!=null?r:2)<l.priority){const T=P.dataset.toastId;if(T){this.remove(T),j=!0;break}}}if(!j){if(l._retries=(l._retries||0)+1,l._retries>(this._defaults._maxRequeueRetries||8)){l._dedupeKey&&this._queueDedupe.delete(l._dedupeKey);continue}setTimeout(()=>this._queue.push(l,l.priority),160);break}}else if(f>=s){if(l._retries=(l._retries||0)+1,l._retries>(this._defaults._maxRequeueRetries||8)){l._dedupeKey&&this._queueDedupe.delete(l._dedupeKey);continue}setTimeout(()=>this._queue.push(l,l.priority),160);break}const v=(this._defaults.maxVisiblePerType||{})[l.type];if(typeof v=="number"&&Array.from(d.children).filter(j=>j.dataset.toastType===l.type).length>=v){if(l._retries=(l._retries||0)+1,l._retries>(this._defaults._maxRequeueRetries||8)){l._dedupeKey&&this._queueDedupe.delete(l._dedupeKey);continue}setTimeout(()=>this._queue.push(l,l.priority),160);break}this._showToast(l.type,l.payload,l.id)}},_getRoot(e="bottom-right"){var a;if(!C)return null;if(this._roots.has(e))return this._roots.get(e);const t=document.createElement("div");switch(t.setAttribute("data-juice-root","1"),t.id=`juice-toast-root-${e}`,t.dataset.position=e,t.dataset.theme=this._theme,t.style.pointerEvents="none",t.style.display="flex",t.style.flexDirection="column",this._defaults.parallaxMode&&(t.dataset.parallax="true"),e){case"top-left":t.style.top="20px",t.style.left="20px";break;case"top-right":t.style.top="20px",t.style.right="20px";break;case"bottom-left":t.style.bottom="20px",t.style.left="20px";break;case"bottom-right":t.style.bottom="20px",t.style.right="20px";break;case"top-center":t.style.top="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;case"bottom-center":t.style.bottom="20px",t.style.left="50%",t.style.transform="translateX(-50%)";break;default:t.style.bottom="20px",t.style.right="20px"}if(document.body.appendChild(t),this._defaults.parallaxMode&&!D){const n=(a=this._defaults.parallaxSmoothing)!=null?a:.12;t._parallaxTargets=new WeakMap;const c=s=>{const m=t.getBoundingClientRect(),l=m.left+m.width/2,h=m.top+m.height/2,d=s.touches?s.touches[0].clientX:s.clientX,f=s.touches?s.touches[0].clientY:s.clientY;Array.from(t.children).forEach((g,v)=>{const j=(v+1)/Math.max(1,t.children.length),k=q((d-l)/m.width*j*12,-18,18),P=q((f-h)/m.height*j*8,-14,14),w=q(-j*8,-30,0),T=q((d-l)/m.width*j*-6,-12,12),re=q((f-h)/m.height*j*4,-8,8),se={tx:k,ty:P,tz:w,rotX:re,rotY:T,smoothing:n};t._parallaxTargets.set(g,se)}),this._startScheduler()},r=()=>{Array.from(t.children).forEach(s=>{t._parallaxTargets.set(s,{tx:0,ty:0,tz:0,rotX:0,rotY:0,smoothing:.16})}),this._startScheduler()};t._parallaxHandler=c,t._parallaxReset=r,t.addEventListener("mousemove",c),t.addEventListener("touchmove",c,{passive:!0}),t.addEventListener("mouseleave",r),t.addEventListener("touchend",r)}return this._roots.set(e,t),t},_warn(e){this._defaults.dev&&typeof console!="undefined"&&console.warn("[JuiceToast]",e)},_ensureFA(){if(!(!C||this._faInjected||!this._defaults.autoFetchFA)){if(document.querySelector('link[href*="fontawesome"], link[href*="font-awesome"], link[href*="cdnjs.cloudflare.com/ajax/libs/font-awesome"]')){this._faInjected=!0;return}try{const e=document.createElement("link");e.rel="stylesheet",e.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css",e.crossOrigin="anonymous",document.head.appendChild(e),this._faInjected=!0}catch(e){console.error("[JuiceToast]: Fetching icons failed:",e)}}},_playSound(e){if(!C)return;const a=typeof e=="string"&&e?e:this._defaults.playSound;if(a)try{const t=new Audio(a);t.volume=.6,t.play().catch(()=>{})}catch(t){}},_updateStackPositionsFor(e){const a=Array.from(e.children);e.dataset.position&&e.dataset.position.includes("bottom"),a.forEach((t,n)=>{const c=n,r=c*12;t.style.setProperty("--jt-stack-y",`${-r}px`),t.style.setProperty("--jt-stack-scale",1-c*.04),t.style.setProperty("--jt-stack-opacity",1-c*.12),t.style.zIndex=1e3-c,t.style.setProperty("--jt-parallax-z",`${-c*2}px`),t.dataset.stack=String(c)})},_runPlugins(e){this._plugins.forEach(a=>{try{a(e)}catch(t){this._warn("Plugin error: "+((t==null?void 0:t.message)||t))}})},_normalizeGlass(e){if(e===!0)return 60;if(!e)return 0;const a=Number(e);return Number.isFinite(a)?q(a,0,100):0},_computeDedupeKey(e,a){try{const t=e||"",n=a.title||"",c=a.message||a.html||"";return`${t}::${String(n).trim().slice(0,200)}::${String(c).trim().slice(0,500)}`}catch(t){return}},_showToast(e,a={},t){var n,c,r,s,m,l,h,d,f,g,v,j,k,P,w,T;if(!C)return;this._defaults.injectCSS!==!1&&ae(this._defaults.css||G),this._ensureFA();const re=this._config[e]||{},se=typeof a=="object"?a:{message:String(a)},o=z(re,se);o.icon=(n=o.icon)!=null?n:o.icon_left_top,o.position=(r=(c=o.position)!=null?c:o.toast)!=null?r:"bottom-right",o.closable=(m=(s=o.closable)!=null?s:o.closeable)!=null?m:!0,o.duration=typeof o.duration=="number"?o.duration:this._defaults.duration;const Z=F[o.theme||this._theme]||{},S=t||oe(),H=o.dedupeKey||(this._defaults.autoDedupe?this._computeDedupeKey(e,o):void 0);if(H)for(const u of this._roots.values()){const p=Array.from(u.children).find(b=>b.dataset.dedupeKey===H);if(p){let b=p._cachedCountEl;if(b||(b=document.createElement("span"),b.className="jt-count",b.style.marginLeft="6px",(l=p.querySelector(".jt-title"))==null||l.appendChild(b),p._cachedCountEl=b,b.textContent="1"),b.textContent=String(parseInt(b.textContent||"1")+1),o.mergeMessage){const E=p.querySelector(".jt-message");E&&(o.html?E.innerHTML=J(o.html):E.textContent=String(o.message||""))}return p.dataset.toastId}}const i=document.createElement("div");if(i.className="juice-toast",i.dataset.toastId=S,i.dataset.position=o.position,i.dataset.toastType=e,H&&(i.dataset.dedupeKey=H),i.tabIndex=0,i.setAttribute("role",o.ariaRole||(e==="error"?"alert":"status")),i.getAttribute("aria-live")||(i.setAttribute("aria-live",e==="error"||e==="success"?"assertive":"polite"),i.setAttribute("aria-atomic","true")),i.style.position="relative",i.style.pointerEvents="auto",o.glassOnly?(i.style.background="rgba(255,255,255,0.35)",i.style.backdropFilter="blur(14px) saturate(140%)",i.style.webkitBackdropFilter="blur(14px) saturate(140%)",i.style.color="rgba(15,23,42,0.85)",i.style.border="1px solid rgba(0,0,0,0.08)",i.style.boxShadow="0 8px 28px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.25)"):(i.style.background=o.bg||Z.bg,i.style.color=o.color||Z.color,i.style.border=o.border||Z.border||"none"),i.style.minHeight=i.style.minHeight||"",["--jt-parallax-x","--jt-parallax-y","--jt-parallax-z","--jt-drag-x","--jt-drag-y","--jt-rot-x","--jt-rot-y","--jt-stack-y","--jt-stack-scale"].forEach(u=>i.style.setProperty(u,u.includes("rot")?"0deg":"0px")),o.size&&ye[o.size]){const u=ye[o.size];u.width&&(i.style.width=u.width),u.padding&&(i.style.padding=u.padding)}const A=document.createElement("div");A.className="jt-content";let Q=null;o.title&&(Q=document.createElement("div"),Q.className="jt-title",Q.textContent=o.title,A.appendChild(Q));const O=document.createElement("div");if(O.className="jt-message",o.html?O.innerHTML=J(o.html):typeof o.message=="string"?o.message.split(/(`[^`]+`)/g).forEach(u=>{if(u.startsWith("`")&&u.endsWith("`")){const p=document.createElement("code");p.textContent=u.slice(1,-1),O.appendChild(p)}else O.appendChild(document.createTextNode(u))}):o.message&&(O.textContent=String(o.message)),A.appendChild(O),Array.isArray(o.actions)&&o.actions.length){const u=document.createElement("div");u.className="jt-actions",o.actions.forEach(p=>{const b=document.createElement("button");b.className="jt-action",b.textContent=p.label||"Action",b.onclick=E=>{var X;E.stopPropagation(),(X=p.onClick)==null||X.call(p,E),p.closeOnClick!==!1&&this.remove(S)},u.appendChild(b)}),A.appendChild(u)}o.glassOnly||(o.bgImage?(i.style.backgroundImage=`url(${o.bgImage})`,i.style.backgroundSize=o.bgSize||"cover",i.style.backgroundPosition=o.bgPosition||"center"):i.style.background=o.bg||Z.bg);let x=null;if(o.icon){x=document.createElement("i");const u=String(o.icon).startsWith("fa")?o.icon:`fa-${o.icon}`;if(x.className=["icon",o.iconPack||"",u].join(" ").trim(),o.iconSize&&(x.style.fontSize=o.iconSize),!D){const p=o.iconAnim||je[e];p&&x.classList.add(p)}(o.iconLink||o.iconAnimate)&&(x.classList.add("icon-clickable"),x.addEventListener("click",p=>{p.stopPropagation(),o.iconAnimate&&(x.classList.remove(o.iconAnimate),x.offsetWidth,x.classList.add(o.iconAnimate)),o.iconLink&&window.open(o.iconLink,"_blank","noopener")}))}let _=null;if(o.avatar){_=document.createElement("img");const u=typeof o.avatar=="string"&&o.avatar?o.avatar:o.avatarSrc||"";u&&(_.src=u),_.alt=o.avatarAlt||o.title||"avatar",_.className="jt-avatar",_.loading=o.avatarLazy?"lazy":"eager",_.style.width=_.style.width||"36px",_.style.height=_.style.height||"36px",_.style.borderRadius=_.style.borderRadius||"50%",_.style.objectFit=_.style.objectFit||"cover",_.style.flexShrink="0";const p=o.avatarPosition||"left";p==="left"?_.style.marginRight=(h=o.avatarSpacing)!=null?h:"10px":p==="right"?_.style.marginLeft=(d=o.avatarSpacing)!=null?d:"10px":p==="top"&&(_.style.marginBottom=(f=o.avatarSpacing)!=null?f:"8px")}const ie=o.avatarPosition||"left";_&&ie==="top"?(i.classList.add("jt-avatar-top"),i.style.flexDirection="column",i.style.alignItems="flex-start",i.appendChild(_),x&&o.iconPosition==="top"?(i.appendChild(x),i.appendChild(A)):x&&o.iconPosition==="right"?(i.appendChild(A),i.appendChild(x)):(x&&i.appendChild(x),i.appendChild(A))):(i.style.flexDirection="row",i.style.alignItems="center",_&&ie==="left"&&i.appendChild(_),x&&o.iconPosition==="right"?(i.appendChild(A),i.appendChild(x)):x&&o.iconPosition==="top"?(i.classList.add("jt-icon-top"),i.appendChild(x),i.appendChild(A)):(x&&i.appendChild(x),i.appendChild(A)),_&&ie==="right"&&i.appendChild(_));let V=null;if(o.progress&&((g=o.duration)!=null?g:this._defaults.duration)>0&&(V=document.createElement("div"),V.className="jt-progress",o.progressColor&&(V.style.background=o.progressColor),i.appendChild(V)),o.undo){const u=document.createElement("button");u.className="jt-action",u.textContent="Undo",u.onclick=()=>{try{o.undo()}catch(p){}this.remove(S)},A.appendChild(u)}if(o.closable){const u=document.createElement("span");u.className="juice-toast-close",u.tabIndex=0,u.textContent="\xD7",u.style.marginLeft="8px",u.addEventListener("click",p=>{p.stopPropagation(),this.remove(S)}),i.appendChild(u)}const W=this._getRoot(o.position||"bottom-right");if(!W)return;if(o.groupId){const u=Array.from(W.children).find(p=>p.dataset.groupId===o.groupId);if(u){const p=u.dataset.toastId;return this.update(p,{title:o.title,message:o.message,html:o.html,bg:o.bg,color:o.color,duration:o.duration,icon:o.icon,iconPack:o.iconPack}),p}i.dataset.groupId=o.groupId}W.appendChild(i),i._cachedTitleEl=Q,i._cachedMessageEl=O,i._cachedProgressEl=V;const y={id:S,toast:i,cfg:o,type:e,createdAt:L(),remaining:(v=o.duration)!=null?v:this._defaults.duration,timer:null,start:L(),paused:!1,_boundMove:null,_boundUp:null,_onPointerDown:null,_onEnter:null,_onLeave:null,dedupeKey:H,hooks:{onShow:o.onShow,onShown:o.onShown,onClose:o.onClose,onRemoved:o.onRemoved},_numericPriority:(j=typeof o.priority=="number"?o.priority:this._priorityMap[o.priority])!=null?j:2};this._activeMap.set(S,y);try{(P=(k=y.hooks).onShow)==null||P.call(k,{id:S,toast:i,cfg:o,type:e})}catch(u){}this._runPlugins({toast:i,cfg:o,type:e,root:W,meta:y}),this._updateStackPositionsFor(W),requestAnimationFrame(()=>{var u,p;D?(i.style.opacity="1",(p=(u=y.hooks).onShown)==null||p.call(u,{id:S,toast:i,cfg:o,type:e})):(i.classList.add("show"),setTimeout(()=>{var b,E;try{(E=(b=y.hooks).onShown)==null||E.call(b,{id:S,toast:i,cfg:o,type:e})}catch(X){}},320))});let ge=0,_e=0,M=0,N=0,ne=!1,I=null,le=0;const ce=u=>{const p=u.touches?u.touches[0]:u;ge=p.clientX,_e=p.clientY,M=0,N=0,ne=!0,I=null,y.paused=!0,i.style.transition="none",y._boundMove=we,y._boundUp=Se,document.addEventListener("touchmove",y._boundMove,{passive:!0}),document.addEventListener("mousemove",y._boundMove),document.addEventListener("touchend",y._boundUp),document.addEventListener("mouseup",y._boundUp),le=L()},we=u=>{if(!ne)return;const p=u.touches?u.touches[0]:u;M=p.clientX-ge,N=p.clientY-_e,I||(Math.abs(M)>6?I="x":Math.abs(N)>6&&(I="y")),I==="x"?i.style.setProperty("--jt-drag-x",`${M}px`):I==="y"&&i.style.setProperty("--jt-drag-y",`${N}px`),le=L(),p.clientX},Se=u=>{ne=!1,y.paused=!1;const p=Math.abs(M),b=Math.abs(N),E=I||(p>b?"x":"y"),X=Math.max(1,L()-le),Le=X?M/X*1e3:0,Pe=E==="x"&&(p>($._defaults.swipeThreshold||60)||Math.abs(Le)>800),Ae=E==="y"&&b>($._defaults.swipeThreshold||80);if(Pe||Ae){const Ce=M>=0?1:-1;E==="x"?i.style.setProperty("--jt-drag-x",`${Ce*1e3}px`):i.style.setProperty("--jt-drag-y","1000px"),i.classList.add("swipe-dismissing"),setTimeout(()=>this.remove(S),220)}else i.style.transition="transform 0.22s ease-out, opacity 0.22s ease-out",i.style.setProperty("--jt-drag-x","0px"),i.style.setProperty("--jt-drag-y","0px");M=N=0,y._boundMove&&(document.removeEventListener("touchmove",y._boundMove),document.removeEventListener("mousemove",y._boundMove),y._boundMove=null),y._boundUp&&(document.removeEventListener("touchend",y._boundUp),document.removeEventListener("mouseup",y._boundUp),y._boundUp=null),y.start=L(),this._startScheduler()};i._onPointerDown=ce,i.addEventListener("touchstart",ce,{passive:!0}),i.addEventListener("mousedown",ce);const de=()=>{y.paused=!0},ue=()=>{y.paused&&(y.paused=!1,y.start=L(),this._startScheduler())};return y._onEnter=de,y._onLeave=ue,i.addEventListener("mouseenter",de),i.addEventListener("mouseleave",ue),i.addEventListener("focusin",de),i.addEventListener("focusout",ue),y.start=L(),y.remaining=(w=o.duration)!=null?w:this._defaults.duration,y.paused=!1,((T=o.duration)!=null?T:this._defaults.duration)>0&&this._startScheduler(),o.undoTimeout&&(y.timer=setTimeout(()=>this.remove(S),o.undoTimeout)),(o.playSound||this._defaults.playSound)&&this._playSound(o.playSound||this._defaults.playSound),S},_startScheduler(){if(this._schedulerRunning)return;this._schedulerRunning=!0;const e=a=>{const t=L();this._schedulerLast=t,this._pausedAll||this._activeMap.forEach((r,s)=>{var m;if(!r||r.paused)return;const l=(m=r.cfg.duration)!=null?m:this._defaults.duration;if(l<=0)return;const h=t-r.start,d=Math.max(0,Math.min(h,1e3));r.remaining-=d,r.start=t;const f=r.toast._cachedProgressEl||r.toast.querySelector(".jt-progress");if(f){const g=Math.max(0,r.remaining/l);f.style.transform=`scaleX(${g})`}r.remaining<=0&&(D||r.toast.classList.remove("show"),setTimeout(()=>this.remove(s),280))}),this._roots.forEach(r=>{!r._parallaxTargets||!r.children.length||Array.from(r.children).forEach(s=>{var m,l,h;const d=r._parallaxTargets.get(s)||{tx:0,ty:0,tz:0,rotX:0,rotY:0,smoothing:(m=this._defaults.parallaxSmoothing)!=null?m:.12};s._jtPrev=s._jtPrev||{tx:0,ty:0,tz:0,rotX:0,rotY:0};const f=s._jtPrev,g=(h=(l=d.smoothing)!=null?l:this._defaults.parallaxSmoothing)!=null?h:.12,v=U(f.tx,d.tx||0,g),j=U(f.ty,d.ty||0,g),k=U(f.tz,d.tz||0,g),P=U(f.rotX,d.rotX||0,g),w=U(f.rotY,d.rotY||0,g);s.style.setProperty("--jt-parallax-x",`${v}px`),s.style.setProperty("--jt-parallax-y",`${j}px`),s.style.setProperty("--jt-parallax-z",`${k}px`),s.style.setProperty("--jt-rot-x",`${P}deg`),s.style.setProperty("--jt-rot-y",`${w}deg`),s._jtPrev.tx=v,s._jtPrev.ty=j,s._jtPrev.tz=k,s._jtPrev.rotX=P,s._jtPrev.rotY=w})});let n=!1;this._activeMap.forEach(r=>{var s;((s=r.cfg.duration)!=null?s:this._defaults.duration)>0&&!r.paused&&(n=!0)});let c=!1;this._roots.forEach(r=>{r._parallaxTargets&&r.children.length&&(c=!0)}),!n&&!c?this._stopScheduler():this._schedulerRAF=requestAnimationFrame(e)};this._schedulerRAF=requestAnimationFrame(e)},_stopScheduler(){this._schedulerRunning&&(this._schedulerRAF&&cancelAnimationFrame(this._schedulerRAF),this._schedulerRAF=null,this._schedulerRunning=!1,this._schedulerLast=0)},remove(e){var a,t,n,c;const r=this._activeMap.get(e);if(!r)return!1;const{toast:s,cfg:m,type:l}=r;try{(t=(a=r.hooks).onClose)==null||t.call(a,{id:e,toast:s,cfg:m,type:l})}catch(d){}D?s.style.opacity="0":s.classList.add("hide");try{s._onPointerDown&&(s.removeEventListener("touchstart",s._onPointerDown),s.removeEventListener("mousedown",s._onPointerDown))}catch(d){}if(r._boundMove){try{document.removeEventListener("touchmove",r._boundMove),document.removeEventListener("mousemove",r._boundMove)}catch(d){}r._boundMove=null}if(r._boundUp){try{document.removeEventListener("touchend",r._boundUp),document.removeEventListener("mouseup",r._boundUp)}catch(d){}r._boundUp=null}try{r._onEnter&&s.removeEventListener("mouseenter",r._onEnter),r._onLeave&&s.removeEventListener("mouseleave",r._onLeave),r._onEnter&&s.removeEventListener("focusin",r._onEnter),r._onLeave&&s.removeEventListener("focusout",r._onLeave)}catch(d){}r.timer&&(clearTimeout(r.timer),r.timer=null),this._activeMap.delete(e);const h=s.parentNode;if(h){const d=()=>{var f,g;try{s.parentNode&&s.parentNode.removeChild(s)}catch(v){}try{if(h.children.length===0){try{h._parallaxHandler&&(h.removeEventListener("mousemove",h._parallaxHandler),h.removeEventListener("touchmove",h._parallaxHandler)),h._parallaxReset&&(h.removeEventListener("mouseleave",h._parallaxReset),h.removeEventListener("touchend",h._parallaxReset)),h.remove()}catch(v){}this._roots.delete(h.dataset.position)}else this._updateStackPositionsFor(h)}catch(v){}if(r.dedupeKey)try{this._queueDedupe.delete(r.dedupeKey)}catch(v){}try{(g=(f=r.hooks).onRemoved)==null||g.call(f,{id:e,cfg:m,type:l})}catch(v){}this._scheduleProcessQueue()};if(D)d();else{const f=g=>{g.target===s&&(s.removeEventListener("animationend",f),d())};s.addEventListener("animationend",f),setTimeout(d,700)}}else{if(r.dedupeKey)try{this._queueDedupe.delete(r.dedupeKey)}catch(d){}try{(c=(n=r.hooks).onRemoved)==null||c.call(n,{id:e,cfg:m,type:l})}catch(d){}this._scheduleProcessQueue()}return!0},update(e,a={}){const t=this._activeMap.get(e);if(!t)return this._warn("update: id not found "+e),!1;const{toast:n}=t;if(t.cfg=z(t.cfg,a),t.cfg.title){const s=n.querySelector(".jt-title")||n._cachedTitleEl;s&&(s.textContent=t.cfg.title)}const c=n.querySelector(".jt-message")||n._cachedMessageEl;c&&(t.cfg.html?c.innerHTML=J(t.cfg.html):c.textContent=String(t.cfg.message||""));const r=F[t.cfg.theme||this._theme]||{};if(n.style.background=t.cfg.bg||r.bg,n.style.color=t.cfg.color||r.color,n.style.border=t.cfg.border||r.border||"none",t.cfg.duration!==void 0){t.remaining=t.cfg.duration,t.start=L(),t.paused||this._startScheduler();const s=t.toast._cachedProgressEl||t.toast.querySelector(".jt-progress");s&&(s.style.transform="scaleX(1)")}return this._runPlugins({toast:n,cfg:t.cfg,type:t.type,meta:t}),!0},_priorityMap:{low:1,normal:2,high:3,urgent:4},pauseAll(){this._pausedAll=!0},resumeAll(){this._pausedAll=!1,this._activeMap.forEach(e=>e.start=L()),this._startScheduler()},dismissAll(e={}){const a=e.type,t=e.position,n=[];this._activeMap.forEach((c,r)=>{const s=a?c.type===a:!0,m=t?(c.cfg.position||c.toast.dataset.position)===t:!0;s&&m&&n.push(r)}),n.forEach(c=>this.remove(c))},listActive(){const e=[];return this._activeMap.forEach((a,t)=>{e.push({id:t,type:a.type,remaining:a.remaining,createdAt:a.createdAt,position:a.cfg.position})}),e}};function ke(e,a){return e?typeof e=="string"?{message:e}:e:{message:a}}function Ee(e,a,t){return e?typeof e=="function"?{message:e(a)}:typeof e=="string"?{message:e}:e:{message:t}}$.setup({success:{icon:"fa-check",iconPack:"fas",bg:"#16a34a",progress:!0,duration:4e3},error:{icon:"fa-xmark",iconPack:"fas",bg:"#dc2626",progress:!0,duration:4e3},info:{icon:"fa-circle-info",iconPack:"fas",bg:"#2563eb",progress:!0,duration:4e3},warning:{icon:"fa-triangle-exclamation",iconPack:"fas",bg:"#f59e0b",progress:!0,duration:4e3},loading:{icon:"fa-spinner",iconPack:"fas",iconAnim:"jt-spin",duration:0,progress:!0}}),R.default=$,R.juiceToast=$,Object.defineProperty(R,"__esModule",{value:!0})}));
|
|
335
160
|
//# sourceMappingURL=juice-toast.umd.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "juice-toast",
|
|
3
|
-
"version": "1.4.4
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Zero dependency JavaScript toast notification library with animations, dark mode, auto CSS injection, and mobile support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"toast",
|
|
@@ -67,5 +67,8 @@
|
|
|
67
67
|
"prettier": "^3.8.1",
|
|
68
68
|
"rollup": "^4.59.0",
|
|
69
69
|
"rollup-plugin-esbuild": "^6.2.1"
|
|
70
|
+
},
|
|
71
|
+
"optionalDependencies": {
|
|
72
|
+
"@juice-toast/plugins-react": "^1.0.0-beta.1"
|
|
70
73
|
}
|
|
71
74
|
}
|