robot-toast 2.1.8 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pratham2703005
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -79,12 +79,12 @@ toast.error("Something went wrong");
79
79
 
80
80
  ## Features at a Glance
81
81
 
82
- | Robots | Layout | Styling | Behavior |
83
- | ----------------------- | ------------------ | --------------------- | --------------------- |
84
- | 16 built-in variants | 6 position options | 3 themes | Fully draggable |
85
- | Tree-shakeable imports | Auto-queuing | Custom inline styles | Typewriter effect |
86
- | Custom images (SVG/PNG) | Progress bar | Transitions (4 types) | Promise helpers |
87
- | Custom image paths | Multi-toast queue | CSS overrides | React hook included |
82
+ | Robots | Layout | Styling | Behavior |
83
+ | ----------------------- | ------------------ | ------------------------------ | --------------------- |
84
+ | 16 built-in variants | 6 position options | 3 themes | Fully draggable |
85
+ | Tree-shakeable imports | Auto-queuing | Custom inline styles | Typewriter effect |
86
+ | Custom images (SVG/PNG) | Progress bar | Tailwind-friendly `className` | Promise helpers |
87
+ | Custom image paths | Multi-toast queue | CSS overrides | React hook included |
88
88
 
89
89
  ---
90
90
 
@@ -118,7 +118,9 @@ toast({
118
118
  // Robot & Styling
119
119
  robotVariant: wave | base | success | error | '...' | 'default' | '/path.svg',
120
120
  nearScreen: true,
121
+ className: 'bg-emerald-600 text-white rounded-2xl shadow-lg',
121
122
  style: { background: '...', color: '...' },
123
+ className: 'bg-emerald-600 text-white',
122
124
 
123
125
  // Timing & Behavior
124
126
  autoClose: 5000 | false,
@@ -253,6 +255,29 @@ toast({
253
255
  });
254
256
  ```
255
257
 
258
+ ### Tailwind and `className`
259
+
260
+ `className` is applied to the toast message container, so you can use your own
261
+ utility classes for surface styling without replacing the toast layout,
262
+ animation, buttons, or progress behavior.
263
+
264
+ When your `className` or inline `style` sets surface properties such as
265
+ `background` or `color`, those user-defined values win over the built-in theme
266
+ surface colors. That makes utilities like `bg-*`, `text-*`, `rounded-*`, and
267
+ `shadow-*` work predictably.
268
+
269
+ ```tsx
270
+ toast({
271
+ message: "Build finished",
272
+ theme: "dark",
273
+ className:
274
+ "bg-slate-950 text-slate-50 rounded-2xl border border-slate-700 shadow-2xl",
275
+ });
276
+ ```
277
+
278
+ Use `className` when your app stylesheet or Tailwind tokens should drive the
279
+ toast appearance, and use `style` when you need runtime-calculated values.
280
+
256
281
  ### Accessibility
257
282
 
258
283
  - `error` / `warning` toasts: `role="alert"` + `aria-live="assertive"`
package/dist/index.d.mts CHANGED
@@ -75,6 +75,11 @@ interface RobotToastOptions {
75
75
  * This takes precedence over className for conflicting properties.
76
76
  */
77
77
  style?: Record<string, string | number>;
78
+ /**
79
+ * Optional CSS class(es) applied to the toast message container.
80
+ * Useful for Tailwind/utility class styling.
81
+ */
82
+ className?: string;
78
83
  /** Typing speed in ms per character. 0 = instant. Default: 30 */
79
84
  typeSpeed?: number;
80
85
  /**
package/dist/index.d.ts CHANGED
@@ -75,6 +75,11 @@ interface RobotToastOptions {
75
75
  * This takes precedence over className for conflicting properties.
76
76
  */
77
77
  style?: Record<string, string | number>;
78
+ /**
79
+ * Optional CSS class(es) applied to the toast message container.
80
+ * Useful for Tailwind/utility class styling.
81
+ */
82
+ className?: string;
78
83
  /** Typing speed in ms per character. 0 = instant. Default: 30 */
79
84
  typeSpeed?: number;
80
85
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var f=class f{constructor(){typeof document>"u"||f.injected||(f.injected=true,this.injectCSS());}injectCSS(){let t="robot-toast-styles";if(document.getElementById(t))return;let o=`
1
+ 'use strict';var u=class u{constructor(){typeof document>"u"||u.injected||(u.injected=true,this.injectCSS());}injectCSS(){let t="robot-toast-styles";if(document.getElementById(t))return;let o=`
2
2
  /* RobotToast v2 - CSS Styles */
3
3
 
4
4
  /* \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 */
@@ -124,7 +124,7 @@
124
124
  /* MESSAGE BOX - Toast content container */
125
125
  /* \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 */
126
126
 
127
- .robot-toast-message {
127
+ :where(.robot-toast-message) {
128
128
  position: relative;
129
129
  width: fit-content;
130
130
  min-width: 120px;
@@ -145,80 +145,87 @@
145
145
  user-select: none;
146
146
  cursor: default;
147
147
  box-sizing: border-box;
148
+ /*
149
+ * Clip children to the rounded border so the progress bar's straight edges
150
+ * follow whatever border-radius the user sets via the style option.
151
+ * Without this, a high border-radius leaves the progress bar's bottom
152
+ * corners poking out past the rounded message box.
153
+ */
154
+ overflow: hidden;
148
155
  }
149
156
 
150
157
  .robot-toast-message.robot-toast-empty {
151
158
  display: none;
152
159
  }
153
160
 
154
- .robot-toast-message.robot-toast-theme-light {
161
+ .robot-toast-message:where(.robot-toast-theme-light):not(.robot-toast-custom-surface) {
155
162
  background: #ffffff;
156
163
  color: #333333;
157
164
  border: 1px solid #e0e0e0;
158
165
  }
159
166
 
160
- .robot-toast-message.robot-toast-theme-dark {
167
+ .robot-toast-message:where(.robot-toast-theme-dark):not(.robot-toast-custom-surface) {
161
168
  background: #2d2d2d;
162
169
  color: #f0f0f0;
163
170
  border: 1px solid #444444;
164
171
  }
165
172
 
166
- .robot-toast-message.robot-toast-theme-colored {
173
+ .robot-toast-message:where(.robot-toast-theme-colored):not(.robot-toast-custom-surface) {
167
174
  color: #ffffff;
168
175
  }
169
176
 
170
177
  /* Type-specific colors for colored theme */
171
- .robot-toast-message.robot-toast-theme-colored.robot-toast-type-default {
178
+ .robot-toast-message:where(.robot-toast-theme-colored):not(.robot-toast-custom-surface).robot-toast-type-default {
172
179
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
173
180
  }
174
181
 
175
- .robot-toast-message.robot-toast-theme-colored.robot-toast-type-info {
182
+ .robot-toast-message:where(.robot-toast-theme-colored):not(.robot-toast-custom-surface).robot-toast-type-info {
176
183
  background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
177
184
  }
178
185
 
179
- .robot-toast-message.robot-toast-theme-colored.robot-toast-type-success {
186
+ .robot-toast-message:where(.robot-toast-theme-colored):not(.robot-toast-custom-surface).robot-toast-type-success {
180
187
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
181
188
  }
182
189
 
183
- .robot-toast-message.robot-toast-theme-colored.robot-toast-type-warning {
190
+ .robot-toast-message:where(.robot-toast-theme-colored):not(.robot-toast-custom-surface).robot-toast-type-warning {
184
191
  background: linear-gradient(135deg, #fb6e3b 0%, #f5a623 100%);
185
192
  }
186
193
 
187
- .robot-toast-message.robot-toast-theme-colored.robot-toast-type-error {
194
+ .robot-toast-message:where(.robot-toast-theme-colored):not(.robot-toast-custom-surface).robot-toast-type-error {
188
195
  background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
189
196
  }
190
197
 
191
198
  /* Light theme type-specific colors */
192
- .robot-toast-message.robot-toast-theme-light.robot-toast-type-info {
199
+ .robot-toast-message:where(.robot-toast-theme-light):not(.robot-toast-custom-surface).robot-toast-type-info {
193
200
  border-left: 4px solid #2193b0;
194
201
  }
195
202
 
196
- .robot-toast-message.robot-toast-theme-light.robot-toast-type-success {
203
+ .robot-toast-message:where(.robot-toast-theme-light):not(.robot-toast-custom-surface).robot-toast-type-success {
197
204
  border-left: 4px solid #11998e;
198
205
  }
199
206
 
200
- .robot-toast-message.robot-toast-theme-light.robot-toast-type-warning {
207
+ .robot-toast-message:where(.robot-toast-theme-light):not(.robot-toast-custom-surface).robot-toast-type-warning {
201
208
  border-left: 4px solid #fb6e3b;
202
209
  }
203
210
 
204
- .robot-toast-message.robot-toast-theme-light.robot-toast-type-error {
211
+ .robot-toast-message:where(.robot-toast-theme-light):not(.robot-toast-custom-surface).robot-toast-type-error {
205
212
  border-left: 4px solid #eb3349;
206
213
  }
207
214
 
208
215
  /* Dark theme type-specific colors */
209
- .robot-toast-message.robot-toast-theme-dark.robot-toast-type-info {
216
+ .robot-toast-message:where(.robot-toast-theme-dark):not(.robot-toast-custom-surface).robot-toast-type-info {
210
217
  border-left: 4px solid #6dd5ed;
211
218
  }
212
219
 
213
- .robot-toast-message.robot-toast-theme-dark.robot-toast-type-success {
220
+ .robot-toast-message:where(.robot-toast-theme-dark):not(.robot-toast-custom-surface).robot-toast-type-success {
214
221
  border-left: 4px solid #38ef7d;
215
222
  }
216
223
 
217
- .robot-toast-message.robot-toast-theme-dark.robot-toast-type-warning {
224
+ .robot-toast-message:where(.robot-toast-theme-dark):not(.robot-toast-custom-surface).robot-toast-type-warning {
218
225
  border-left: 4px solid #f5a623;
219
226
  }
220
227
 
221
- .robot-toast-message.robot-toast-theme-dark.robot-toast-type-error {
228
+ .robot-toast-message:where(.robot-toast-theme-dark):not(.robot-toast-custom-surface).robot-toast-type-error {
222
229
  border-left: 4px solid #f45c43;
223
230
  }
224
231
 
@@ -235,28 +242,32 @@
235
242
  /* \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 */
236
243
 
237
244
  /*
238
- * Close button: 28x28 click target anchored at the message-box corner,
239
- * but the SVG icon is aligned to the TOP-RIGHT of that target (not centered).
240
- * Centering the SVG put the visible \xD7 ~14px from the corner, which on short
241
- * single-line toasts looked like it was "in the middle" of the toast. Aligning
242
- * to the corner with a small padding keeps the icon visually pinned to the
243
- * top-right regardless of toast height, while preserving a comfortable hit zone.
245
+ * Close button is absolutely positioned against the BODY section (not the
246
+ * whole message box), and vertically centered with top: 50% / translateY.
247
+ * This makes it pair with the text automatically:
248
+ * - single-line toast -> centered with the text line
249
+ * - multi-line toast -> centered with the text block
250
+ * - toast with buttons -> stays in body region, never drifts into footer
251
+ * - any font size / theme -> body grows, button follows
252
+ * The icon itself is an inline SVG so it renders identically across browsers
253
+ * (the &amp;times; glyph has unstable baselines on mobile font stacks).
244
254
  */
245
255
  .robot-toast-close {
246
256
  position: absolute;
247
- top: 0;
248
- right: 0;
257
+ top: 35%;
258
+ right: 2px;
259
+ transform: translateY(-50%);
249
260
  background: none;
250
261
  border: none;
251
262
  cursor: pointer;
252
- opacity: 0.6;
263
+ opacity: 0.5;
253
264
  transition: opacity 0.2s;
254
265
  width: 28px;
255
266
  height: 28px;
256
267
  display: flex;
257
- align-items: flex-start;
258
- justify-content: flex-end;
259
- padding: 6px 6px 0 0;
268
+ align-items: center;
269
+ justify-content: center;
270
+ padding: 0;
260
271
  box-sizing: border-box;
261
272
  color: currentColor;
262
273
  line-height: 0;
@@ -264,8 +275,8 @@
264
275
 
265
276
  .robot-toast-close svg {
266
277
  display: block;
267
- width: 12px;
268
- height: 12px;
278
+ width: 9px;
279
+ height: 9px;
269
280
  }
270
281
 
271
282
  .robot-toast-close:hover {
@@ -301,6 +312,7 @@
301
312
  /* \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 */
302
313
 
303
314
  .robot-toast-body {
315
+ position: relative;
304
316
  padding: 10px 40px 10px 14px;
305
317
  }
306
318
 
@@ -400,40 +412,40 @@
400
412
  }
401
413
 
402
414
  /* Dark theme \u2014 inverted neutral */
403
- .robot-toast-message.robot-toast-theme-dark .robot-toast-btn {
415
+ .robot-toast-message:where(.robot-toast-theme-dark) .robot-toast-btn {
404
416
  color: #a1a1aa;
405
417
  border-color: #3f3f46;
406
418
  }
407
- .robot-toast-message.robot-toast-theme-dark .robot-toast-btn:hover {
419
+ .robot-toast-message:where(.robot-toast-theme-dark) .robot-toast-btn:hover {
408
420
  background: #27272a;
409
421
  color: #fafafa;
410
422
  }
411
- .robot-toast-message.robot-toast-theme-dark .robot-toast-row[data-count="1"]:only-child .robot-toast-btn {
423
+ .robot-toast-message:where(.robot-toast-theme-dark) .robot-toast-row[data-count="1"]:only-child .robot-toast-btn {
412
424
  background: #fafafa;
413
425
  color: #18181b;
414
426
  border-color: #fafafa;
415
427
  }
416
- .robot-toast-message.robot-toast-theme-dark .robot-toast-row[data-count="1"]:only-child .robot-toast-btn:hover {
428
+ .robot-toast-message:where(.robot-toast-theme-dark) .robot-toast-row[data-count="1"]:only-child .robot-toast-btn:hover {
417
429
  background: #e4e4e7;
418
430
  border-color: #e4e4e7;
419
431
  color: #18181b;
420
432
  }
421
433
 
422
434
  /* Colored theme \u2014 translucent whites keep contrast on any gradient */
423
- .robot-toast-message.robot-toast-theme-colored .robot-toast-btn {
435
+ .robot-toast-message:where(.robot-toast-theme-colored) .robot-toast-btn {
424
436
  color: rgba(255, 255, 255, 0.9);
425
437
  border-color: rgba(255, 255, 255, 0.35);
426
438
  }
427
- .robot-toast-message.robot-toast-theme-colored .robot-toast-btn:hover {
439
+ .robot-toast-message:where(.robot-toast-theme-colored) .robot-toast-btn:hover {
428
440
  background: rgba(255, 255, 255, 0.15);
429
441
  color: #fff;
430
442
  }
431
- .robot-toast-message.robot-toast-theme-colored .robot-toast-row[data-count="1"]:only-child .robot-toast-btn {
443
+ .robot-toast-message:where(.robot-toast-theme-colored) .robot-toast-row[data-count="1"]:only-child .robot-toast-btn {
432
444
  background: rgba(255, 255, 255, 0.95);
433
445
  color: #18181b;
434
446
  border-color: transparent;
435
447
  }
436
- .robot-toast-message.robot-toast-theme-colored .robot-toast-row[data-count="1"]:only-child .robot-toast-btn:hover {
448
+ .robot-toast-message:where(.robot-toast-theme-colored) .robot-toast-row[data-count="1"]:only-child .robot-toast-btn:hover {
437
449
  background: #fff;
438
450
  color: #18181b;
439
451
  }
@@ -450,7 +462,7 @@
450
462
  overflow: hidden;
451
463
  }
452
464
 
453
- .robot-toast-message.robot-toast-theme-dark .robot-toast-progress-container {
465
+ .robot-toast-message:where(.robot-toast-theme-dark) .robot-toast-progress-container {
454
466
  background: rgba(255, 255, 255, 0.15);
455
467
  }
456
468
 
@@ -461,16 +473,17 @@
461
473
  transform: scaleX(1); /* \u2190 starts full */
462
474
  }
463
475
 
464
- .robot-toast-theme-light.robot-toast-type-success .robot-toast-progress-bar { background: #11998e; }
465
- .robot-toast-theme-light.robot-toast-type-error .robot-toast-progress-bar { background: #eb3349; }
466
- .robot-toast-theme-light.robot-toast-type-warning .robot-toast-progress-bar { background: #fb6e3b; }
467
- .robot-toast-theme-light.robot-toast-type-info .robot-toast-progress-bar { background: #2193b0; }
476
+ .robot-toast-message:where(.robot-toast-theme-light):not(.robot-toast-custom-surface).robot-toast-type-success .robot-toast-progress-bar { background: #11998e; }
477
+ .robot-toast-message:where(.robot-toast-theme-light):not(.robot-toast-custom-surface).robot-toast-type-error .robot-toast-progress-bar { background: #eb3349; }
478
+ .robot-toast-message:where(.robot-toast-theme-light):not(.robot-toast-custom-surface).robot-toast-type-warning .robot-toast-progress-bar { background: #fb6e3b; }
479
+ .robot-toast-message:where(.robot-toast-theme-light):not(.robot-toast-custom-surface).robot-toast-type-info .robot-toast-progress-bar { background: #2193b0; }
468
480
 
469
481
  /* Dark theme progress bar colors */
470
- .robot-toast-theme-dark.robot-toast-type-success .robot-toast-progress-bar { background: #38ef7d; }
471
- .robot-toast-theme-dark.robot-toast-type-error .robot-toast-progress-bar { background: #f45c43; }
472
- .robot-toast-theme-dark.robot-toast-type-warning .robot-toast-progress-bar { background: #f5a623; }
473
- .robot-toast-theme-dark.robot-toast-type-info .robot-toast-progress-bar { background: #6dd5ed; }
482
+ .robot-toast-message:where(.robot-toast-theme-dark):not(.robot-toast-custom-surface).robot-toast-type-success .robot-toast-progress-bar { background: #38ef7d; }
483
+ .robot-toast-message:where(.robot-toast-theme-dark):not(.robot-toast-custom-surface).robot-toast-type-error .robot-toast-progress-bar { background: #f45c43; }
484
+ .robot-toast-message:where(.robot-toast-theme-dark):not(.robot-toast-custom-surface).robot-toast-type-warning .robot-toast-progress-bar { background: #f5a623; }
485
+ .robot-toast-message:where(.robot-toast-theme-dark):not(.robot-toast-custom-surface).robot-toast-type-info .robot-toast-progress-bar { background: #6dd5ed; }
486
+
474
487
 
475
488
 
476
489
  .robot-toast-progress-bar.robot-toast-progress-auto {
@@ -750,7 +763,7 @@
750
763
  .robot-toast-close {
751
764
  width: 24px;
752
765
  height: 24px;
753
- padding: 5px 5px 0 0;
766
+ right: -6px;
754
767
  }
755
768
  .robot-toast-close svg {
756
769
  width: 11px;
@@ -767,7 +780,7 @@
767
780
  max-width: calc(100vw - 40px - 20px - 8px);
768
781
  }
769
782
  }
770
- `,e=document.createElement("style");e.id=t,e.textContent=o,document.head.appendChild(e);}};f.injected=false;var w=f,k=w;var E=1;function R(){return E++}var L=16;function B(a){let t=a.length;if(t===0)return [];if(t<=3)return [a.slice()];if(t===4)return [a.slice(0,2),a.slice(2)];let o=[],e=0;for(;t-e>4;)o.push(a.slice(e,e+3)),e+=3;return t-e===4?(o.push(a.slice(e,e+2)),o.push(a.slice(e+2))):o.push(a.slice(e)),o}var x=class{constructor(t,o,e){this.progressBar=null;this.timerStart=null;this.closeTimeout=null;this.isDragging=false;this.dragOffsetX=0;this.dragOffsetY=0;this.dragWidth=0;this.dragHeight=0;this.isHovered=false;this.isFocusLost=false;this.isClosed=false;this.cleanupFns=[];this.id=t,this.onRemove=e;let s={message:o.message,autoClose:o.autoClose??5e3,position:o.position??"bottom-right",type:o.type??"default",theme:o.theme??"light",style:o.style,typeSpeed:o.typeSpeed??30,robotVariant:o.robotVariant??"",hideProgressBar:o.hideProgressBar??false,pauseOnFocusLoss:o.pauseOnFocusLoss??true,draggable:o.draggable??true,nearScreen:o.nearScreen??true,pauseOnHover:o.pauseOnHover??true,rtl:o.rtl??false,transition:o.transition??"bounce",buttons:o.buttons,onOpen:o.onOpen,onClose:o.onClose};this.options=s;let r=s.position.includes("left"),i;s.nearScreen?i=r?"left":"right":i=r?"right":"left",this.currentRobotSide=i,this.autoCloseDuration=typeof s.autoClose=="number"?s.autoClose:s.autoClose?5e3:0,this.remainingTime=this.autoCloseDuration,this.wrapper=this.buildWrapper(),this.robotEl=this.buildRobot(),this.messageBox=this.buildMessageBox(),this.messageText=this.messageBox.querySelector(".robot-toast-text"),this.progressBar=this.messageBox.querySelector(".robot-toast-progress-bar"),s.message===""&&this.messageBox.classList.add("robot-toast-empty"),this.assembleLayout(),document.body.appendChild(this.wrapper),s.draggable&&this.initDrag(),s.pauseOnFocusLoss&&this.initFocusWatcher(),s.pauseOnHover&&this.initHoverWatcher(),requestAnimationFrame(()=>this.playEntrance());}close(){this.isClosed||(this.isClosed=true,this.cancelTimer(),this.cleanupFns.forEach(t=>t()),this.cleanupFns=[],this.playExit(()=>{this.wrapper.parentNode&&this.wrapper.parentNode.removeChild(this.wrapper),this.options.onClose?.(),this.onRemove(this.id);}));}shiftVertical(t){this.options.position.startsWith("bottom")?this.wrapper.style.bottom=`${t}px`:this.wrapper.style.top=`${t}px`;}getWrapperHeight(){return this.wrapper.getBoundingClientRect().height||90}buildWrapper(){let t=document.createElement("div"),o=["robot-toast-wrapper",`robot-toast-${this.options.position}`];this.options.rtl&&o.push("robot-toast-rtl"),t.className=o.join(" ");let e=this.options.type==="error"||this.options.type==="warning";return t.setAttribute("role",e?"alert":"status"),t.setAttribute("aria-live",e?"assertive":"polite"),t.setAttribute("aria-atomic","true"),t}resolveVariant(){let t=this.options.robotVariant;if(!t||t==="none")return "hidden";if(t==="default")return "default";let o=[".svg",".png",".jpg",".jpeg",".gif",".webp"];return t.startsWith("data:")||o.some(r=>t.toLowerCase().endsWith(r))?"image":"hidden"}buildRobot(){let t=document.createElement("div");t.className="robot-toast-robot";let o=this.resolveVariant();if(o==="hidden")return t.style.display="none",t;if(o==="default")return t.innerHTML=this.getBuiltinSVG(),t;let e=document.createElement("img");return e.src=this.options.robotVariant,e.alt="Robot",e.setAttribute("width","65"),e.setAttribute("height","70"),e.style.cssText="width:100%;height:100%;object-fit:contain;display:block;",e.onerror=()=>{t.innerHTML=this.getBuiltinSVG();},t.appendChild(e),t}buildMessageBox(){let t=document.createElement("div"),o=["robot-toast-message",`robot-toast-type-${this.options.type}`,`robot-toast-theme-${this.options.theme}`].filter(Boolean);t.className=o.join(" "),t.style.cursor=this.options.draggable?"grab":"default",this.options.style&&Object.entries(this.options.style).forEach(([l,m])=>{let d=l.replace(/-([a-z])/g,b=>b[1].toUpperCase());t.style[d]=m;});let e=document.createElement("button");e.className="robot-toast-close",e.innerHTML='<svg viewBox="0 0 14 14" width="12" height="12" aria-hidden="true" focusable="false"><path d="M1 1 L13 13 M13 1 L1 13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',e.title="Dismiss",e.type="button",e.setAttribute("aria-label","Dismiss notification"),e.addEventListener("click",l=>{l.stopPropagation(),this.close();}),t.appendChild(e);let s=document.createElement("div");s.className="robot-toast-body";let r=document.createElement("div");if(r.className="robot-toast-text",s.appendChild(r),t.appendChild(s),this.options.buttons&&this.options.buttons.length>0){let l=document.createElement("div");l.className="robot-toast-footer",B(this.options.buttons).forEach(d=>{let b=document.createElement("div");b.className="robot-toast-row",b.setAttribute("data-count",String(d.length)),d.forEach(y=>b.appendChild(this.buildButton(y))),l.appendChild(b);}),t.appendChild(l);}let i=document.createElement("div");i.className="robot-toast-progress-container",this.options.hideProgressBar&&(i.style.display="none");let p=document.createElement("div");return p.className="robot-toast-progress-bar",i.appendChild(p),t.appendChild(i),t}buildButton(t){let o=document.createElement("button");return o.type="button",o.className=t.className?`robot-toast-btn ${t.className}`:"robot-toast-btn",o.textContent=t.label,t.style&&Object.entries(t.style).forEach(([e,s])=>{let r=e.replace(/-([a-z])/g,i=>i[1].toUpperCase());o.style[r]=s;}),o.addEventListener("click",e=>{e.stopPropagation();try{t.onClick(e);}catch(s){console.error("[robot-toast] button onClick threw:",s);}this.close();}),o}assembleLayout(){let{rtl:t}=this.options;this.wrapper.innerHTML="",(t?this.currentRobotSide==="right":this.currentRobotSide==="left")?(this.wrapper.appendChild(this.robotEl),this.wrapper.appendChild(this.messageBox)):(this.wrapper.appendChild(this.messageBox),this.wrapper.appendChild(this.robotEl));}playEntrance(){this.wrapper.classList.add("robot-toast-visible");let t=this.resolveVariant()==="hidden",o=this.options.message==="",e=()=>{if(o){this.options.onOpen?.(),this.afterTypingComplete();return}let s=this.options.transition==="bounce"?"message-enter":`message-enter-${this.options.transition}`;this.messageBox.classList.add(s);let r=()=>{this.messageBox.removeEventListener("animationend",r),this.messageBox.classList.remove(s),this.messageBox.style.opacity="1",this.messageBox.style.transform="none",this.options.onOpen?.(),this.startTyping();};this.messageBox.addEventListener("animationend",r,{once:true});};if(t)e();else {let s=this.currentRobotSide==="left"?"left":"right",r=this.options.transition!=="bounce"?`-${this.options.transition}`:"",i=`robot-enter-${s}${r}`;this.robotEl.classList.add(i);let p=()=>{this.robotEl.removeEventListener("animationend",p),this.robotEl.style.opacity="1",this.robotEl.classList.remove(i),this.robotEl.classList.add("robot-idle"),e();};this.robotEl.addEventListener("animationend",p,{once:true});}}playExit(t){let o=this.resolveVariant()==="hidden",e=this.options.message==="",s=()=>{if(this.messageBox.removeEventListener("animationend",s),o)this.wrapper.classList.remove("robot-toast-visible"),setTimeout(t,260);else {this.robotEl.classList.remove("robot-idle","robot-snap-left","robot-snap-right");let r=this.currentRobotSide==="left"?"left":"right",i=this.options.transition!=="bounce"?`-${this.options.transition}`:"",p=`robot-exit-${r}${i}`;this.robotEl.classList.add(p);let l=()=>{this.robotEl.removeEventListener("animationend",l),this.wrapper.classList.remove("robot-toast-visible"),setTimeout(t,260);};this.robotEl.addEventListener("animationend",l,{once:true});}};e?s():(this.messageBox.classList.add("message-exit"),this.messageBox.addEventListener("animationend",s,{once:true}));}startTyping(){let{message:t,typeSpeed:o}=this.options,e=this.messageText;if(o===0){e.textContent=t,this.afterTypingComplete();return}let s=0,r=true;this.cleanupFns.push(()=>{r=false;});let i=()=>{r&&(s<t.length?(e.textContent+=t.charAt(s++),setTimeout(i,o)):this.afterTypingComplete());};i();}afterTypingComplete(){this.autoCloseDuration>0&&!this.options.hideProgressBar&&this.progressBar&&(this.progressBar.style.animationDuration=`${this.autoCloseDuration}ms`,this.progressBar.offsetWidth,this.progressBar.classList.add("robot-toast-progress-auto"),(this.isHovered||this.isFocusLost)&&this.progressBar.classList.add("robot-toast-progress-paused")),!this.isHovered&&!this.isFocusLost&&this.startTimer();}startTimer(){this.autoCloseDuration<=0||this.remainingTime<=0||(this.timerStart=Date.now(),this.closeTimeout=setTimeout(()=>this.close(),this.remainingTime));}pauseTimer(){if(this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null,this.timerStart!==null)){let t=Date.now()-this.timerStart;this.remainingTime=Math.max(0,this.remainingTime-t),this.timerStart=null;}this.progressBar?.classList.add("robot-toast-progress-paused");}resumeTimer(){this.isHovered||this.isFocusLost||this.isDragging||(this.progressBar?.classList.remove("robot-toast-progress-paused"),this.startTimer());}cancelTimer(){this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null);}initHoverWatcher(){let t=()=>{this.isHovered=true,this.pauseTimer();},o=()=>{this.isHovered=false,this.resumeTimer();};this.wrapper.addEventListener("mouseenter",t),this.wrapper.addEventListener("mouseleave",o),this.cleanupFns.push(()=>{this.wrapper.removeEventListener("mouseenter",t),this.wrapper.removeEventListener("mouseleave",o);});}initFocusWatcher(){let t=()=>{this.isFocusLost=true,this.pauseTimer();},o=()=>{this.isFocusLost=false,this.resumeTimer();};window.addEventListener("blur",t),window.addEventListener("focus",o),this.cleanupFns.push(()=>{window.removeEventListener("blur",t),window.removeEventListener("focus",o);});}initDrag(){this.messageBox.style.cursor="grab";let t=s=>{if(s.target.closest(".robot-toast-close, .robot-toast-btn")||s.button!==void 0&&s.button!==0)return;s.preventDefault(),this.isDragging=true,this.pauseTimer();let r=this.wrapper.getBoundingClientRect();this.wrapper.classList.add("robot-toast-dragging"),this.wrapper.style.top=`${r.top}px`,this.wrapper.style.left=`${r.left}px`,this.wrapper.style.right="auto",this.wrapper.style.bottom="auto",this.wrapper.style.transform="none",this.dragWidth=r.width,this.dragHeight=r.height,this.dragOffsetX=s.clientX-r.left,this.dragOffsetY=s.clientY-r.top,this.messageBox.style.cursor="grabbing",this.wrapper.setPointerCapture(s.pointerId);},o=s=>{if(!this.isDragging)return;s.preventDefault();let r=window.innerWidth-this.dragWidth,i=window.innerHeight-this.dragHeight,p=Math.max(0,Math.min(s.clientX-this.dragOffsetX,r)),l=Math.max(0,Math.min(s.clientY-this.dragOffsetY,i));this.wrapper.style.left=`${p}px`,this.wrapper.style.top=`${l}px`;},e=s=>{if(!this.isDragging)return;this.isDragging=false,this.wrapper.classList.remove("robot-toast-dragging"),this.messageBox.style.cursor="grab";let r=this.wrapper.getBoundingClientRect(),i=r.top,p=r.left+r.width/2,l=window.innerWidth/2,m=p<l,d=this.options.nearScreen?m?"left":"right":m?"right":"left",b=m?20:window.innerWidth-this.dragWidth-20,y=Math.max(20,Math.min(i,window.innerHeight-this.dragHeight-20));if(this.wrapper.style.transition="left 0.45s cubic-bezier(0.34,1.56,0.64,1), top 0.4s cubic-bezier(0.34,1.56,0.64,1)",this.wrapper.style.left=`${b}px`,this.wrapper.style.top=`${y}px`,d!==this.currentRobotSide){this.currentRobotSide=d;let v=d==="left";this.robotEl.style.order=v?"0":"1",this.messageBox.style.order=v?"1":"0";let T=d==="left"?"robot-snap-left":"robot-snap-right";this.robotEl.classList.remove("robot-idle","robot-snap-left","robot-snap-right"),this.robotEl.classList.add(T),this.robotEl.addEventListener("animationend",()=>{this.robotEl.style.opacity="1",this.robotEl.classList.remove(T),this.robotEl.classList.add("robot-idle");},{once:true});}setTimeout(()=>{this.wrapper.style.transition="";},500),this.resumeTimer();};this.wrapper.addEventListener("pointerdown",t),this.wrapper.addEventListener("pointermove",o),this.wrapper.addEventListener("pointerup",e),this.wrapper.addEventListener("pointercancel",e),this.cleanupFns.push(()=>{this.wrapper.removeEventListener("pointerdown",t),this.wrapper.removeEventListener("pointermove",o),this.wrapper.removeEventListener("pointerup",e),this.wrapper.removeEventListener("pointercancel",e);});}getBuiltinSVG(){return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 120"
783
+ `,e=document.createElement("style");e.id=t,e.textContent=o,document.head.appendChild(e);}};u.injected=false;var v=u,E=v;var R=1;function B(){return R++}var L=16;function O(a){let t=a.length;if(t===0)return [];if(t<=3)return [a.slice()];if(t===4)return [a.slice(0,2),a.slice(2)];let o=[],e=0;for(;t-e>4;)o.push(a.slice(e,e+3)),e+=3;return t-e===4?(o.push(a.slice(e,e+2)),o.push(a.slice(e+2))):o.push(a.slice(e)),o}var T=class{constructor(t,o,e){this.progressBar=null;this.timerStart=null;this.closeTimeout=null;this.isDragging=false;this.dragOffsetX=0;this.dragOffsetY=0;this.dragWidth=0;this.dragHeight=0;this.isHovered=false;this.isFocusLost=false;this.isClosed=false;this.cleanupFns=[];this.id=t,this.onRemove=e;let s={message:o.message,autoClose:o.autoClose??5e3,position:o.position??"bottom-right",type:o.type??"default",theme:o.theme??"light",style:o.style,className:o.className,typeSpeed:o.typeSpeed??30,robotVariant:o.robotVariant??"",hideProgressBar:o.hideProgressBar??false,pauseOnFocusLoss:o.pauseOnFocusLoss??true,draggable:o.draggable??true,nearScreen:o.nearScreen??true,pauseOnHover:o.pauseOnHover??true,rtl:o.rtl??false,transition:o.transition??"bounce",buttons:o.buttons,onOpen:o.onOpen,onClose:o.onClose};this.options=s;let r=s.position.includes("left"),i;s.nearScreen?i=r?"left":"right":i=r?"right":"left",this.currentRobotSide=i,this.autoCloseDuration=typeof s.autoClose=="number"?s.autoClose:s.autoClose?5e3:0,this.remainingTime=this.autoCloseDuration,this.wrapper=this.buildWrapper(),this.robotEl=this.buildRobot(),this.messageBox=this.buildMessageBox(),this.messageText=this.messageBox.querySelector(".robot-toast-text"),this.progressBar=this.messageBox.querySelector(".robot-toast-progress-bar"),s.message===""&&this.messageBox.classList.add("robot-toast-empty"),this.assembleLayout(),document.body.appendChild(this.wrapper),s.draggable&&this.initDrag(),s.pauseOnFocusLoss&&this.initFocusWatcher(),s.pauseOnHover&&this.initHoverWatcher(),requestAnimationFrame(()=>this.playEntrance());}close(){this.isClosed||(this.isClosed=true,this.cancelTimer(),this.cleanupFns.forEach(t=>t()),this.cleanupFns=[],this.playExit(()=>{this.wrapper.parentNode&&this.wrapper.parentNode.removeChild(this.wrapper),this.options.onClose?.(),this.onRemove(this.id);}));}shiftVertical(t){this.options.position.startsWith("bottom")?this.wrapper.style.bottom=`${t}px`:this.wrapper.style.top=`${t}px`;}getWrapperHeight(){return this.wrapper.getBoundingClientRect().height||90}buildWrapper(){let t=document.createElement("div"),o=["robot-toast-wrapper",`robot-toast-${this.options.position}`];this.options.rtl&&o.push("robot-toast-rtl"),t.className=o.join(" ");let e=this.options.type==="error"||this.options.type==="warning";return t.setAttribute("role",e?"alert":"status"),t.setAttribute("aria-live",e?"assertive":"polite"),t.setAttribute("aria-atomic","true"),t}resolveVariant(){let t=this.options.robotVariant;if(!t||t==="none")return "hidden";if(t==="default")return "default";let o=[".svg",".png",".jpg",".jpeg",".gif",".webp"];return t.startsWith("data:")||o.some(r=>t.toLowerCase().endsWith(r))?"image":"hidden"}buildRobot(){let t=document.createElement("div");t.className="robot-toast-robot";let o=this.resolveVariant();if(o==="hidden")return t.style.display="none",t;if(o==="default")return t.innerHTML=this.getBuiltinSVG(),t;let e=document.createElement("img");return e.src=this.options.robotVariant,e.alt="Robot",e.setAttribute("width","65"),e.setAttribute("height","70"),e.style.cssText="width:100%;height:100%;object-fit:contain;display:block;",e.onerror=()=>{t.innerHTML=this.getBuiltinSVG();},t.appendChild(e),t}buildMessageBox(){let t=document.createElement("div"),o=!!(this.options.className||this.options.style),e=["robot-toast-message",`robot-toast-type-${this.options.type}`,`robot-toast-theme-${this.options.theme}`];o&&e.push("robot-toast-custom-surface"),this.options.className&&e.push(...this.options.className.split(/\s+/).filter(Boolean));let s=e.filter(Boolean);t.className=s.join(" "),t.style.cursor=this.options.draggable?"grab":"default",this.options.style&&Object.entries(this.options.style).forEach(([p,w])=>{let f=p.replace(/-([a-z])/g,d=>d[1].toUpperCase());t.style[f]=w;});let r=document.createElement("div");r.className="robot-toast-body";let i=document.createElement("div");i.className="robot-toast-text",r.appendChild(i);let n=document.createElement("button");if(n.className="robot-toast-close",n.innerHTML='<svg viewBox="0 0 14 14" width="12" height="12" aria-hidden="true" focusable="false"><path d="M1 1 L13 13 M13 1 L1 13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',n.title="Dismiss",n.type="button",n.setAttribute("aria-label","Dismiss notification"),n.addEventListener("click",p=>{p.stopPropagation(),this.close();}),r.appendChild(n),t.appendChild(r),this.options.buttons&&this.options.buttons.length>0){let p=document.createElement("div");p.className="robot-toast-footer",O(this.options.buttons).forEach(f=>{let d=document.createElement("div");d.className="robot-toast-row",d.setAttribute("data-count",String(f.length)),f.forEach(y=>d.appendChild(this.buildButton(y))),p.appendChild(d);}),t.appendChild(p);}let b=document.createElement("div");b.className="robot-toast-progress-container",this.options.hideProgressBar&&(b.style.display="none");let m=document.createElement("div");return m.className="robot-toast-progress-bar",b.appendChild(m),t.appendChild(b),t}buildButton(t){let o=document.createElement("button");return o.type="button",o.className=t.className?`robot-toast-btn ${t.className}`:"robot-toast-btn",o.textContent=t.label,t.style&&Object.entries(t.style).forEach(([e,s])=>{let r=e.replace(/-([a-z])/g,i=>i[1].toUpperCase());o.style[r]=s;}),o.addEventListener("click",e=>{e.stopPropagation();try{t.onClick(e);}catch(s){console.error("[robot-toast] button onClick threw:",s);}this.close();}),o}assembleLayout(){let{rtl:t}=this.options;this.wrapper.innerHTML="",(t?this.currentRobotSide==="right":this.currentRobotSide==="left")?(this.wrapper.appendChild(this.robotEl),this.wrapper.appendChild(this.messageBox)):(this.wrapper.appendChild(this.messageBox),this.wrapper.appendChild(this.robotEl));}playEntrance(){this.wrapper.classList.add("robot-toast-visible");let t=this.resolveVariant()==="hidden",o=this.options.message==="",e=()=>{if(o){this.options.onOpen?.(),this.afterTypingComplete();return}let s=this.options.transition==="bounce"?"message-enter":`message-enter-${this.options.transition}`;this.messageBox.classList.add(s);let r=()=>{this.messageBox.removeEventListener("animationend",r),this.messageBox.classList.remove(s),this.messageBox.style.opacity="1",this.messageBox.style.transform="none",this.options.onOpen?.(),this.startTyping();};this.messageBox.addEventListener("animationend",r,{once:true});};if(t)e();else {let s=this.currentRobotSide==="left"?"left":"right",r=this.options.transition!=="bounce"?`-${this.options.transition}`:"",i=`robot-enter-${s}${r}`;this.robotEl.classList.add(i);let n=()=>{this.robotEl.removeEventListener("animationend",n),this.robotEl.style.opacity="1",this.robotEl.classList.remove(i),this.robotEl.classList.add("robot-idle"),e();};this.robotEl.addEventListener("animationend",n,{once:true});}}playExit(t){let o=this.resolveVariant()==="hidden",e=this.options.message==="",s=()=>{if(this.messageBox.removeEventListener("animationend",s),o)this.wrapper.classList.remove("robot-toast-visible"),setTimeout(t,260);else {this.robotEl.classList.remove("robot-idle","robot-snap-left","robot-snap-right");let r=this.currentRobotSide==="left"?"left":"right",i=this.options.transition!=="bounce"?`-${this.options.transition}`:"",n=`robot-exit-${r}${i}`;this.robotEl.classList.add(n);let b=()=>{this.robotEl.removeEventListener("animationend",b),this.wrapper.classList.remove("robot-toast-visible"),setTimeout(t,260);};this.robotEl.addEventListener("animationend",b,{once:true});}};e?s():(this.messageBox.classList.add("message-exit"),this.messageBox.addEventListener("animationend",s,{once:true}));}startTyping(){let{message:t,typeSpeed:o}=this.options,e=this.messageText;if(o===0){e.textContent=t,this.afterTypingComplete();return}let s=0,r=true;this.cleanupFns.push(()=>{r=false;});let i=()=>{r&&(s<t.length?(e.textContent+=t.charAt(s++),setTimeout(i,o)):this.afterTypingComplete());};i();}afterTypingComplete(){this.autoCloseDuration>0&&!this.options.hideProgressBar&&this.progressBar&&(this.progressBar.style.animationDuration=`${this.autoCloseDuration}ms`,this.progressBar.offsetWidth,this.progressBar.classList.add("robot-toast-progress-auto"),(this.isHovered||this.isFocusLost)&&this.progressBar.classList.add("robot-toast-progress-paused")),!this.isHovered&&!this.isFocusLost&&this.startTimer();}startTimer(){this.autoCloseDuration<=0||this.remainingTime<=0||(this.timerStart=Date.now(),this.closeTimeout=setTimeout(()=>this.close(),this.remainingTime));}pauseTimer(){if(this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null,this.timerStart!==null)){let t=Date.now()-this.timerStart;this.remainingTime=Math.max(0,this.remainingTime-t),this.timerStart=null;}this.progressBar?.classList.add("robot-toast-progress-paused");}resumeTimer(){this.isHovered||this.isFocusLost||this.isDragging||(this.progressBar?.classList.remove("robot-toast-progress-paused"),this.startTimer());}cancelTimer(){this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null);}initHoverWatcher(){let t=()=>{this.isHovered=true,this.pauseTimer();},o=()=>{this.isHovered=false,this.resumeTimer();};this.wrapper.addEventListener("mouseenter",t),this.wrapper.addEventListener("mouseleave",o),this.cleanupFns.push(()=>{this.wrapper.removeEventListener("mouseenter",t),this.wrapper.removeEventListener("mouseleave",o);});}initFocusWatcher(){let t=()=>{this.isFocusLost=true,this.pauseTimer();},o=()=>{this.isFocusLost=false,this.resumeTimer();};window.addEventListener("blur",t),window.addEventListener("focus",o),this.cleanupFns.push(()=>{window.removeEventListener("blur",t),window.removeEventListener("focus",o);});}initDrag(){this.messageBox.style.cursor="grab";let t=s=>{if(s.target.closest(".robot-toast-close, .robot-toast-btn")||s.button!==void 0&&s.button!==0)return;s.preventDefault(),this.isDragging=true,this.pauseTimer();let r=this.wrapper.getBoundingClientRect();this.wrapper.classList.add("robot-toast-dragging"),this.wrapper.style.top=`${r.top}px`,this.wrapper.style.left=`${r.left}px`,this.wrapper.style.right="auto",this.wrapper.style.bottom="auto",this.wrapper.style.transform="none",this.dragWidth=r.width,this.dragHeight=r.height,this.dragOffsetX=s.clientX-r.left,this.dragOffsetY=s.clientY-r.top,this.messageBox.style.cursor="grabbing",this.wrapper.setPointerCapture(s.pointerId);},o=s=>{if(!this.isDragging)return;s.preventDefault();let r=window.innerWidth-this.dragWidth,i=window.innerHeight-this.dragHeight,n=Math.max(0,Math.min(s.clientX-this.dragOffsetX,r)),b=Math.max(0,Math.min(s.clientY-this.dragOffsetY,i));this.wrapper.style.left=`${n}px`,this.wrapper.style.top=`${b}px`;},e=s=>{if(!this.isDragging)return;this.isDragging=false,this.wrapper.classList.remove("robot-toast-dragging"),this.messageBox.style.cursor="grab";let r=this.wrapper.getBoundingClientRect(),i=r.top,n=r.left+r.width/2,b=window.innerWidth/2,m=n<b,p=this.options.nearScreen?m?"left":"right":m?"right":"left",w=m?20:window.innerWidth-this.dragWidth-20,f=Math.max(20,Math.min(i,window.innerHeight-this.dragHeight-20));if(this.wrapper.style.transition="left 0.45s cubic-bezier(0.34,1.56,0.64,1), top 0.4s cubic-bezier(0.34,1.56,0.64,1)",this.wrapper.style.left=`${w}px`,this.wrapper.style.top=`${f}px`,p!==this.currentRobotSide){this.currentRobotSide=p;let y=p==="left";this.robotEl.style.order=y?"0":"1",this.messageBox.style.order=y?"1":"0";let k=p==="left"?"robot-snap-left":"robot-snap-right";this.robotEl.classList.remove("robot-idle","robot-snap-left","robot-snap-right"),this.robotEl.classList.add(k),this.robotEl.addEventListener("animationend",()=>{this.robotEl.style.opacity="1",this.robotEl.classList.remove(k),this.robotEl.classList.add("robot-idle");},{once:true});}setTimeout(()=>{this.wrapper.style.transition="";},500),this.resumeTimer();};this.wrapper.addEventListener("pointerdown",t),this.wrapper.addEventListener("pointermove",o),this.wrapper.addEventListener("pointerup",e),this.wrapper.addEventListener("pointercancel",e),this.cleanupFns.push(()=>{this.wrapper.removeEventListener("pointerdown",t),this.wrapper.removeEventListener("pointermove",o),this.wrapper.removeEventListener("pointerup",e),this.wrapper.removeEventListener("pointercancel",e);});}getBuiltinSVG(){return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 120"
771
784
  width="100%" height="100%" role="img" aria-label="Robot">
772
785
  <defs>
773
786
  <linearGradient id="rtGrad${this.id}" x1="0" y1="0" x2="1" y2="1">
@@ -815,5 +828,5 @@
815
828
  fill="url(#rtAccent${this.id})" stroke="#2B3A55" stroke-width="1.5"/>
816
829
  <rect x="54" y="110" width="16" height="10" rx="5"
817
830
  fill="url(#rtAccent${this.id})" stroke="#2B3A55" stroke-width="1.5"/>
818
- </svg>`}},h=class h{constructor(){this.activeToasts=[];this.queue=[];this.globalLimit=0;new k;}static getInstance(){return h._instance||(h._instance=new h),h._instance}show(t){if(typeof document>"u")return -1;let o=R(),e=t.limit??this.globalLimit;return e>0&&this.activeToasts.length>=e?(this.queue.push({options:t,id:o}),o):(this.spawnToast(t,o),o)}closeAll(){this.queue=[],[...this.activeToasts].forEach(t=>t.close());}closeById(t){let o=this.activeToasts.find(e=>e.id===t);o&&o.close(),this.queue=this.queue.filter(e=>e.id!==t);}spawnToast(t,o){let e=new x(o,t,r=>this.handleRemoved(r));t.newestOnTop??false?this.activeToasts.unshift(e):this.activeToasts.push(e),this.restack();}handleRemoved(t){if(this.activeToasts=this.activeToasts.filter(o=>o.id!==t),this.restack(),this.queue.length>0){let o=this.queue.shift();setTimeout(()=>this.spawnToast(o.options,o.id),120);}}restack(){let t={};this.activeToasts.forEach(o=>{let e=o.options.position;t[e]||(t[e]=[]),t[e].push(o);}),Object.keys(t).forEach(o=>{let e=t[o],s=20;e.forEach(r=>{r.shiftVertical(s),s+=r.getWrapperHeight()+L;});});}};h._instance=null;var c=h;function u(a=5e3){return new Promise((t,o)=>{if(typeof window>"u"){o(new Error("[RobotToast] Cannot run outside of a browser environment."));return}if(window.RobotToast){t(window.RobotToast);return}let e=Date.now(),s=setInterval(()=>{if(window.RobotToast){clearInterval(s),t(window.RobotToast);return}Date.now()-e>=a&&(clearInterval(s),o(new Error(`[RobotToast] Failed to load within ${a}ms.`)));},80);})}async function O(a){try{return (await u()).show(a)}catch(t){return console.error("[RobotToast] showRobotToast failed:",t),-1}}async function S(){try{(await u()).closeAll();}catch(a){console.error("[RobotToast] closeAllRobotToasts failed:",a);}}async function A(){return u()}var I=["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],C=["default","info","success","warning","error"],P=["light","dark","colored"],Y=["bounce","slide","zoom","flip"];function g(a){return typeof a=="string"?{message:a}:a}function n(a){return typeof window>"u"?-1:c.getInstance().show(g(a))}n.success=a=>n({...g(a),type:"success"});n.error=a=>n({...g(a),type:"error"});n.info=a=>n({...g(a),type:"info"});n.warning=a=>n({...g(a),type:"warning"});n.closeAll=()=>{typeof window>"u"||c.getInstance().closeAll();};n.closeById=a=>{typeof window>"u"||c.getInstance().closeById(a);};n.promise=(a,t)=>{if(typeof window>"u")return a;let o=typeof t.loading=="string"?{message:t.loading}:{message:"",...t.loading},e=n({autoClose:false,hideProgressBar:true,...o,typeSpeed:o.typeSpeed??0}),s=(r,i)=>{let p=typeof r=="string"?{message:r}:{message:"",...r};return {type:i,...p}};return a.then(r=>{n.closeById(e);let i=typeof t.success=="function"?t.success(r):t.success;return n(s(i,"success")),r},r=>{n.closeById(e);let i=typeof t.error=="function"?t.error(r):t.error;throw n(s(i,"error")),r})};function N(){if(typeof window>"u"||window.__robotToastLoaded)return;window.__robotToastLoaded=true;let a={show:t=>c.getInstance().show(t),closeAll:()=>c.getInstance().closeAll(),closeById:t=>c.getInstance().closeById(t),getInstance:()=>c.getInstance()};window.RobotToast=a;}N();exports.RobotToast=c;exports.RobotToastManager=c;exports.TOAST_POSITIONS=I;exports.TOAST_THEMES=P;exports.TOAST_TRANSITIONS=Y;exports.TOAST_TYPES=C;exports.closeAllRobotToasts=S;exports.ensureRobotToastReady=u;exports.getRobotToastInstance=A;exports.showRobotToast=O;exports.toast=n;//# sourceMappingURL=index.js.map
831
+ </svg>`}},h=class h{constructor(){this.activeToasts=[];this.queue=[];this.globalLimit=0;new E;}static getInstance(){return h._instance||(h._instance=new h),h._instance}show(t){if(typeof document>"u")return -1;let o=B(),e=t.limit??this.globalLimit;return e>0&&this.activeToasts.length>=e?(this.queue.push({options:t,id:o}),o):(this.spawnToast(t,o),o)}closeAll(){this.queue=[],[...this.activeToasts].forEach(t=>t.close());}closeById(t){let o=this.activeToasts.find(e=>e.id===t);o&&o.close(),this.queue=this.queue.filter(e=>e.id!==t);}spawnToast(t,o){let e=new T(o,t,r=>this.handleRemoved(r));t.newestOnTop??false?this.activeToasts.unshift(e):this.activeToasts.push(e),this.restack();}handleRemoved(t){if(this.activeToasts=this.activeToasts.filter(o=>o.id!==t),this.restack(),this.queue.length>0){let o=this.queue.shift();setTimeout(()=>this.spawnToast(o.options,o.id),120);}}restack(){let t={};this.activeToasts.forEach(o=>{let e=o.options.position;t[e]||(t[e]=[]),t[e].push(o);}),Object.keys(t).forEach(o=>{let e=t[o],s=20;e.forEach(r=>{r.shiftVertical(s),s+=r.getWrapperHeight()+L;});});}};h._instance=null;var c=h;function x(a=5e3){return new Promise((t,o)=>{if(typeof window>"u"){o(new Error("[RobotToast] Cannot run outside of a browser environment."));return}if(window.RobotToast){t(window.RobotToast);return}let e=Date.now(),s=setInterval(()=>{if(window.RobotToast){clearInterval(s),t(window.RobotToast);return}Date.now()-e>=a&&(clearInterval(s),o(new Error(`[RobotToast] Failed to load within ${a}ms.`)));},80);})}async function S(a){try{return (await x()).show(a)}catch(t){return console.error("[RobotToast] showRobotToast failed:",t),-1}}async function A(){try{(await x()).closeAll();}catch(a){console.error("[RobotToast] closeAllRobotToasts failed:",a);}}async function C(){return x()}var I=["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],P=["default","info","success","warning","error"],N=["light","dark","colored"],Y=["bounce","slide","zoom","flip"];function g(a){return typeof a=="string"?{message:a}:a}function l(a){return typeof window>"u"?-1:c.getInstance().show(g(a))}l.success=a=>l({...g(a),type:"success"});l.error=a=>l({...g(a),type:"error"});l.info=a=>l({...g(a),type:"info"});l.warning=a=>l({...g(a),type:"warning"});l.closeAll=()=>{typeof window>"u"||c.getInstance().closeAll();};l.closeById=a=>{typeof window>"u"||c.getInstance().closeById(a);};l.promise=(a,t)=>{if(typeof window>"u")return a;let o=typeof t.loading=="string"?{message:t.loading}:{message:"",...t.loading},e=l({autoClose:false,hideProgressBar:true,...o,typeSpeed:o.typeSpeed??0}),s=(r,i)=>{let n=typeof r=="string"?{message:r}:{message:"",...r};return {type:i,...n}};return a.then(r=>{l.closeById(e);let i=typeof t.success=="function"?t.success(r):t.success;return l(s(i,"success")),r},r=>{l.closeById(e);let i=typeof t.error=="function"?t.error(r):t.error;throw l(s(i,"error")),r})};function D(){if(typeof window>"u"||window.__robotToastLoaded)return;window.__robotToastLoaded=true;let a={show:t=>c.getInstance().show(t),closeAll:()=>c.getInstance().closeAll(),closeById:t=>c.getInstance().closeById(t),getInstance:()=>c.getInstance()};window.RobotToast=a;}D();exports.RobotToast=c;exports.RobotToastManager=c;exports.TOAST_POSITIONS=I;exports.TOAST_THEMES=N;exports.TOAST_TRANSITIONS=Y;exports.TOAST_TYPES=P;exports.closeAllRobotToasts=A;exports.ensureRobotToastReady=x;exports.getRobotToastInstance=C;exports.showRobotToast=S;exports.toast=l;//# sourceMappingURL=index.js.map
819
832
  //# sourceMappingURL=index.js.map