@seekhiwave/agent-widget 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js ADDED
@@ -0,0 +1,1166 @@
1
+ import{useEffect as q}from"react";var O=`
2
+ :host {
3
+ all: initial;
4
+ --sw-bg: #080d19;
5
+ --sw-surface: #0f172a;
6
+ --sw-surface-2: #162036;
7
+ --sw-surface-3: #1e293b;
8
+ --sw-border: rgba(148, 163, 184, 0.16);
9
+ --sw-border-strong: rgba(148, 163, 184, 0.28);
10
+ --sw-text: #f8fafc;
11
+ --sw-text-muted: #94a3b8;
12
+ --sw-text-dim: #64748b;
13
+ --sw-accent: #f59e0b;
14
+ --sw-accent-soft: rgba(245, 158, 11, 0.14);
15
+ --sw-accent-glow: rgba(245, 158, 11, 0.32);
16
+ --sw-green: #22c55e;
17
+ --sw-red: #ef4444;
18
+ --sw-user-bubble: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
19
+ --sw-spectrum: linear-gradient(90deg, #ef4444 0%, #f59e0b 52%, #22c55e 100%);
20
+ --sw-shadow: 0 24px 64px rgba(2, 6, 23, 0.62), 0 4px 18px rgba(2, 6, 23, 0.35);
21
+ --sw-font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
22
+ font-family: var(--sw-font);
23
+ color: var(--sw-text);
24
+ box-sizing: border-box;
25
+ -webkit-font-smoothing: antialiased;
26
+ }
27
+
28
+ *, *::before, *::after {
29
+ box-sizing: border-box;
30
+ }
31
+
32
+ .sw-root {
33
+ position: fixed;
34
+ bottom: 22px;
35
+ right: 22px;
36
+ display: flex;
37
+ flex-direction: column;
38
+ align-items: flex-end;
39
+ gap: 12px;
40
+ font-family: var(--sw-font);
41
+ color: var(--sw-text);
42
+ pointer-events: none;
43
+ }
44
+
45
+ .sw-root.sw-left {
46
+ right: auto;
47
+ left: 22px;
48
+ align-items: flex-start;
49
+ }
50
+
51
+ .sw-root > * {
52
+ pointer-events: auto;
53
+ }
54
+
55
+ /* ---------- Launcher & Teaser Pill ---------- */
56
+ .sw-launcher-row {
57
+ display: flex;
58
+ align-items: center;
59
+ gap: 10px;
60
+ }
61
+
62
+ .sw-root.sw-left .sw-launcher-row {
63
+ flex-direction: row-reverse;
64
+ }
65
+
66
+ .sw-teaser {
67
+ display: flex;
68
+ align-items: center;
69
+ gap: 10px;
70
+ background: rgba(15, 23, 42, 0.96);
71
+ border: 1px solid var(--sw-border-strong);
72
+ color: var(--sw-text);
73
+ padding: 10px 14px;
74
+ border-radius: 14px;
75
+ font-size: 13px;
76
+ line-height: 1.35;
77
+ max-width: 260px;
78
+ box-shadow: 0 14px 36px rgba(2, 6, 23, 0.45);
79
+ cursor: pointer;
80
+ animation: sw-fade-up 0.35s cubic-bezier(0.22, 1, 0.36, 1);
81
+ transition: transform 0.18s ease, border-color 0.18s ease;
82
+ }
83
+
84
+ .sw-teaser:hover {
85
+ transform: translateY(-2px);
86
+ border-color: rgba(245, 158, 11, 0.48);
87
+ }
88
+
89
+ .sw-teaser-close {
90
+ background: none;
91
+ border: none;
92
+ color: var(--sw-text-muted);
93
+ cursor: pointer;
94
+ padding: 2px 4px;
95
+ font-size: 14px;
96
+ line-height: 1;
97
+ border-radius: 6px;
98
+ flex-shrink: 0;
99
+ }
100
+
101
+ .sw-teaser-close:hover {
102
+ color: var(--sw-text);
103
+ background: rgba(148, 163, 184, 0.14);
104
+ }
105
+
106
+ .sw-launcher {
107
+ position: relative;
108
+ width: 60px;
109
+ height: 60px;
110
+ border-radius: 999px;
111
+ border: 1.5px solid rgba(251, 191, 36, 0.42);
112
+ background: radial-gradient(circle at 30% 25%, #1e293b 0%, #080d19 72%);
113
+ box-shadow: 0 14px 34px rgba(2, 6, 23, 0.55), 0 0 0 0 var(--sw-accent-glow);
114
+ cursor: pointer;
115
+ display: flex;
116
+ align-items: center;
117
+ justify-content: center;
118
+ padding: 0;
119
+ transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease, border-color 0.22s ease;
120
+ -webkit-tap-highlight-color: transparent;
121
+ }
122
+
123
+ .sw-launcher:hover {
124
+ transform: translateY(-2px) scale(1.04);
125
+ border-color: rgba(251, 191, 36, 0.85);
126
+ box-shadow: 0 18px 40px rgba(2, 6, 23, 0.65), 0 0 22px rgba(245, 158, 11, 0.28);
127
+ }
128
+
129
+ .sw-launcher:active {
130
+ transform: scale(0.95);
131
+ }
132
+
133
+ .sw-launcher-img {
134
+ width: 44px;
135
+ height: 44px;
136
+ border-radius: 999px;
137
+ object-fit: cover;
138
+ display: block;
139
+ }
140
+
141
+ .sw-launcher-icon-close {
142
+ display: none;
143
+ color: var(--sw-text);
144
+ }
145
+
146
+ .sw-root.sw-open .sw-launcher-img {
147
+ display: none;
148
+ }
149
+
150
+ .sw-root.sw-open .sw-launcher-icon-close {
151
+ display: flex;
152
+ }
153
+
154
+ .sw-status-dot {
155
+ position: absolute;
156
+ bottom: 2px;
157
+ right: 2px;
158
+ width: 13px;
159
+ height: 13px;
160
+ border-radius: 999px;
161
+ background: var(--sw-green);
162
+ border: 2.5px solid #080d19;
163
+ box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
164
+ }
165
+
166
+ .sw-unread-badge {
167
+ position: absolute;
168
+ top: -4px;
169
+ right: -3px;
170
+ min-width: 20px;
171
+ height: 20px;
172
+ padding: 0 6px;
173
+ border-radius: 999px;
174
+ background: #ef4444;
175
+ color: #fff;
176
+ font-size: 11px;
177
+ font-weight: 700;
178
+ display: flex;
179
+ align-items: center;
180
+ justify-content: center;
181
+ border: 2px solid #080d19;
182
+ }
183
+
184
+ /* ---------- Chat Panel ---------- */
185
+ .sw-panel {
186
+ position: relative;
187
+ width: 400px;
188
+ max-width: calc(100vw - 32px);
189
+ height: 620px;
190
+ max-height: calc(100dvh - 110px);
191
+ background: var(--sw-bg);
192
+ border: 1px solid var(--sw-border-strong);
193
+ border-radius: 22px;
194
+ box-shadow: var(--sw-shadow);
195
+ display: flex;
196
+ flex-direction: column;
197
+ overflow: hidden;
198
+ transform-origin: bottom right;
199
+ opacity: 0;
200
+ transform: translateY(14px) scale(0.96);
201
+ pointer-events: none;
202
+ visibility: hidden;
203
+ transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.22s;
204
+ }
205
+
206
+ .sw-root.sw-left .sw-panel {
207
+ transform-origin: bottom left;
208
+ }
209
+
210
+ .sw-root.sw-open .sw-panel {
211
+ opacity: 1;
212
+ transform: translateY(0) scale(1);
213
+ pointer-events: auto;
214
+ visibility: visible;
215
+ }
216
+
217
+ .sw-spectrum-bar {
218
+ height: 3px;
219
+ width: 100%;
220
+ background: var(--sw-spectrum);
221
+ flex-shrink: 0;
222
+ }
223
+
224
+ /* ---------- Header ---------- */
225
+ .sw-header {
226
+ display: flex;
227
+ align-items: center;
228
+ justify-content: space-between;
229
+ gap: 10px;
230
+ padding: 13px 14px 12px;
231
+ background: rgba(15, 23, 42, 0.94);
232
+ border-bottom: 1px solid var(--sw-border);
233
+ flex-shrink: 0;
234
+ }
235
+
236
+ .sw-header-brand {
237
+ display: flex;
238
+ align-items: center;
239
+ gap: 10px;
240
+ min-width: 0;
241
+ }
242
+
243
+ .sw-header-avatar-wrap {
244
+ position: relative;
245
+ width: 38px;
246
+ height: 38px;
247
+ flex-shrink: 0;
248
+ }
249
+
250
+ .sw-header-avatar {
251
+ width: 38px;
252
+ height: 38px;
253
+ border-radius: 999px;
254
+ object-fit: cover;
255
+ border: 1px solid rgba(251, 191, 36, 0.38);
256
+ background: #0f172a;
257
+ }
258
+
259
+ .sw-header-dot {
260
+ position: absolute;
261
+ bottom: 0;
262
+ right: 0;
263
+ width: 10px;
264
+ height: 10px;
265
+ border-radius: 999px;
266
+ background: var(--sw-green);
267
+ border: 2px solid #0f172a;
268
+ }
269
+
270
+ .sw-header-dot.sw-offline {
271
+ background: #f59e0b;
272
+ }
273
+
274
+ .sw-header-info {
275
+ min-width: 0;
276
+ }
277
+
278
+ .sw-header-title {
279
+ font-size: 14px;
280
+ font-weight: 700;
281
+ color: var(--sw-text);
282
+ letter-spacing: -0.01em;
283
+ white-space: nowrap;
284
+ overflow: hidden;
285
+ text-overflow: ellipsis;
286
+ }
287
+
288
+ .sw-header-sub {
289
+ font-size: 11.5px;
290
+ color: var(--sw-text-muted);
291
+ margin-top: 1px;
292
+ }
293
+
294
+ .sw-header-actions {
295
+ display: flex;
296
+ align-items: center;
297
+ gap: 4px;
298
+ flex-shrink: 0;
299
+ }
300
+
301
+ .sw-icon-btn {
302
+ width: 32px;
303
+ height: 32px;
304
+ border-radius: 10px;
305
+ border: 1px solid transparent;
306
+ background: transparent;
307
+ color: var(--sw-text-muted);
308
+ display: flex;
309
+ align-items: center;
310
+ justify-content: center;
311
+ cursor: pointer;
312
+ transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
313
+ padding: 0;
314
+ }
315
+
316
+ .sw-icon-btn:hover {
317
+ background: rgba(148, 163, 184, 0.12);
318
+ color: var(--sw-text);
319
+ border-color: var(--sw-border);
320
+ }
321
+
322
+ /* ---------- Messages Stream ---------- */
323
+ .sw-messages {
324
+ flex: 1;
325
+ overflow-y: auto;
326
+ overflow-x: hidden;
327
+ padding: 16px 14px 14px;
328
+ display: flex;
329
+ flex-direction: column;
330
+ gap: 10px;
331
+ scroll-behavior: smooth;
332
+ overscroll-behavior: contain;
333
+ }
334
+
335
+ .sw-messages::-webkit-scrollbar {
336
+ width: 6px;
337
+ }
338
+
339
+ .sw-messages::-webkit-scrollbar-thumb {
340
+ background: rgba(148, 163, 184, 0.22);
341
+ border-radius: 999px;
342
+ }
343
+
344
+ .sw-welcome {
345
+ background: linear-gradient(155deg, rgba(22, 32, 54, 0.92), rgba(15, 23, 42, 0.92));
346
+ border: 1px solid var(--sw-border);
347
+ border-radius: 16px;
348
+ padding: 14px 15px;
349
+ margin-bottom: 4px;
350
+ }
351
+
352
+ .sw-welcome-eyebrow {
353
+ font-size: 10.5px;
354
+ font-weight: 700;
355
+ text-transform: uppercase;
356
+ letter-spacing: 0.12em;
357
+ color: #fbbf24;
358
+ margin-bottom: 6px;
359
+ }
360
+
361
+ .sw-welcome-text {
362
+ font-size: 13.5px;
363
+ line-height: 1.5;
364
+ color: #e2e8f0;
365
+ margin: 0 0 12px;
366
+ }
367
+
368
+ .sw-chips {
369
+ display: flex;
370
+ flex-wrap: wrap;
371
+ gap: 6px;
372
+ }
373
+
374
+ .sw-chip {
375
+ font-family: inherit;
376
+ font-size: 12px;
377
+ font-weight: 500;
378
+ color: #fde68a;
379
+ background: rgba(245, 158, 11, 0.11);
380
+ border: 1px solid rgba(245, 158, 11, 0.32);
381
+ border-radius: 999px;
382
+ padding: 6px 11px;
383
+ cursor: pointer;
384
+ transition: background 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
385
+ }
386
+
387
+ .sw-chip:hover {
388
+ background: rgba(245, 158, 11, 0.22);
389
+ border-color: rgba(251, 191, 36, 0.65);
390
+ transform: translateY(-1px);
391
+ }
392
+
393
+ .sw-msg-row {
394
+ display: flex;
395
+ flex-direction: column;
396
+ max-width: 86%;
397
+ position: relative;
398
+ animation: sw-fade-up 0.2s ease-out;
399
+ }
400
+
401
+ .sw-msg-row.sw-user {
402
+ align-self: flex-end;
403
+ align-items: flex-end;
404
+ }
405
+
406
+ .sw-msg-row.sw-agent {
407
+ align-self: flex-start;
408
+ align-items: flex-start;
409
+ }
410
+
411
+ .sw-msg-row.sw-system {
412
+ align-self: center;
413
+ max-width: 94%;
414
+ }
415
+
416
+ .sw-bubble {
417
+ position: relative;
418
+ padding: 10px 13px;
419
+ border-radius: 16px;
420
+ font-size: 13.8px;
421
+ line-height: 1.52;
422
+ word-wrap: break-word;
423
+ overflow-wrap: anywhere;
424
+ }
425
+
426
+ .sw-user .sw-bubble {
427
+ background: var(--sw-user-bubble);
428
+ color: #ffffff;
429
+ border-bottom-right-radius: 5px;
430
+ box-shadow: 0 6px 18px rgba(29, 78, 216, 0.28);
431
+ }
432
+
433
+ .sw-agent .sw-bubble {
434
+ background: var(--sw-surface-2);
435
+ color: #f1f5f9;
436
+ border: 1px solid var(--sw-border);
437
+ border-bottom-left-radius: 5px;
438
+ }
439
+
440
+ .sw-system .sw-bubble {
441
+ background: rgba(239, 68, 68, 0.12);
442
+ border: 1px solid rgba(239, 68, 68, 0.34);
443
+ color: #fecaca;
444
+ font-size: 12.5px;
445
+ text-align: center;
446
+ border-radius: 12px;
447
+ padding: 8px 12px;
448
+ }
449
+
450
+ .sw-bubble a {
451
+ color: #fbbf24;
452
+ text-decoration: underline;
453
+ text-underline-offset: 2px;
454
+ }
455
+
456
+ .sw-user .sw-bubble a {
457
+ color: #fef08a;
458
+ }
459
+
460
+ .sw-bubble code {
461
+ background: rgba(2, 6, 23, 0.5);
462
+ padding: 1px 5px;
463
+ border-radius: 5px;
464
+ font-size: 12.5px;
465
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
466
+ }
467
+
468
+ .sw-reaction {
469
+ position: absolute;
470
+ bottom: -10px;
471
+ left: -6px;
472
+ background: #0f172a;
473
+ border: 1px solid var(--sw-border-strong);
474
+ border-radius: 999px;
475
+ padding: 2px 6px;
476
+ font-size: 13px;
477
+ line-height: 1.2;
478
+ box-shadow: 0 4px 12px rgba(2, 6, 23, 0.45);
479
+ animation: sw-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
480
+ }
481
+
482
+ .sw-time {
483
+ font-size: 10px;
484
+ color: var(--sw-text-dim);
485
+ margin-top: 4px;
486
+ padding: 0 3px;
487
+ }
488
+
489
+ /* ---------- Action Buttons & Quick Replies ---------- */
490
+ .sw-url-buttons {
491
+ display: flex;
492
+ flex-wrap: wrap;
493
+ gap: 6px;
494
+ margin-top: 8px;
495
+ }
496
+
497
+ .sw-url-btn {
498
+ display: inline-flex;
499
+ align-items: center;
500
+ gap: 5px;
501
+ padding: 7px 11px;
502
+ border-radius: 10px;
503
+ background: rgba(245, 158, 11, 0.14);
504
+ border: 1px solid rgba(245, 158, 11, 0.38);
505
+ color: #fde68a !important;
506
+ text-decoration: none !important;
507
+ font-size: 12.2px;
508
+ font-weight: 600;
509
+ transition: background 0.15s ease, transform 0.12s ease;
510
+ }
511
+
512
+ .sw-url-btn:hover {
513
+ background: rgba(245, 158, 11, 0.26);
514
+ transform: translateY(-1px);
515
+ }
516
+
517
+ .sw-quick-replies {
518
+ display: flex;
519
+ flex-wrap: wrap;
520
+ gap: 6px;
521
+ margin-top: 7px;
522
+ }
523
+
524
+ /* ---------- Image Card ---------- */
525
+ .sw-image-card {
526
+ width: 100%;
527
+ background: var(--sw-surface-2);
528
+ border: 1px solid var(--sw-border);
529
+ border-radius: 16px;
530
+ overflow: hidden;
531
+ }
532
+
533
+ .sw-image-card img {
534
+ display: block;
535
+ width: 100%;
536
+ max-height: 210px;
537
+ object-fit: cover;
538
+ cursor: pointer;
539
+ background: #0b1120;
540
+ }
541
+
542
+ .sw-image-card-body {
543
+ padding: 10px 12px;
544
+ font-size: 13.2px;
545
+ line-height: 1.48;
546
+ }
547
+
548
+ /* ---------- Branded PDF Card ---------- */
549
+ .sw-pdf-card {
550
+ width: 100%;
551
+ min-width: 245px;
552
+ background: linear-gradient(155deg, #162036 0%, #0f172a 100%);
553
+ border: 1px solid rgba(245, 158, 11, 0.35);
554
+ border-radius: 16px;
555
+ padding: 12px 13px;
556
+ display: flex;
557
+ flex-direction: column;
558
+ gap: 10px;
559
+ }
560
+
561
+ .sw-pdf-top {
562
+ display: flex;
563
+ align-items: center;
564
+ gap: 10px;
565
+ }
566
+
567
+ .sw-pdf-badge {
568
+ width: 40px;
569
+ height: 40px;
570
+ border-radius: 11px;
571
+ background: rgba(239, 68, 68, 0.16);
572
+ border: 1px solid rgba(239, 68, 68, 0.38);
573
+ color: #fca5a5;
574
+ font-size: 11px;
575
+ font-weight: 800;
576
+ letter-spacing: 0.06em;
577
+ display: flex;
578
+ align-items: center;
579
+ justify-content: center;
580
+ flex-shrink: 0;
581
+ }
582
+
583
+ .sw-pdf-meta {
584
+ min-width: 0;
585
+ flex: 1;
586
+ }
587
+
588
+ .sw-pdf-name {
589
+ font-size: 13px;
590
+ font-weight: 700;
591
+ color: var(--sw-text);
592
+ white-space: nowrap;
593
+ overflow: hidden;
594
+ text-overflow: ellipsis;
595
+ }
596
+
597
+ .sw-pdf-sub {
598
+ font-size: 11.5px;
599
+ color: var(--sw-text-muted);
600
+ margin-top: 2px;
601
+ }
602
+
603
+ .sw-pdf-caption {
604
+ font-size: 12.8px;
605
+ line-height: 1.48;
606
+ color: #cbd5e1;
607
+ }
608
+
609
+ .sw-pdf-dl {
610
+ display: inline-flex;
611
+ align-items: center;
612
+ justify-content: center;
613
+ gap: 7px;
614
+ width: 100%;
615
+ padding: 9px 12px;
616
+ border-radius: 11px;
617
+ background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
618
+ color: #080d19 !important;
619
+ text-decoration: none !important;
620
+ font-size: 12.8px;
621
+ font-weight: 700;
622
+ cursor: pointer;
623
+ border: none;
624
+ transition: filter 0.15s ease, transform 0.12s ease;
625
+ }
626
+
627
+ .sw-pdf-dl:hover {
628
+ filter: brightness(1.08);
629
+ transform: translateY(-1px);
630
+ }
631
+
632
+ /* ---------- Voice Audio Bubble ---------- */
633
+ .sw-voice-bubble {
634
+ display: flex;
635
+ flex-direction: column;
636
+ gap: 7px;
637
+ min-width: 230px;
638
+ }
639
+
640
+ .sw-voice-row {
641
+ display: flex;
642
+ align-items: center;
643
+ gap: 10px;
644
+ }
645
+
646
+ .sw-voice-play {
647
+ width: 34px;
648
+ height: 34px;
649
+ border-radius: 999px;
650
+ border: none;
651
+ background: #f59e0b;
652
+ color: #080d19;
653
+ display: flex;
654
+ align-items: center;
655
+ justify-content: center;
656
+ cursor: pointer;
657
+ flex-shrink: 0;
658
+ padding: 0;
659
+ }
660
+
661
+ .sw-user .sw-voice-play {
662
+ background: #ffffff;
663
+ color: #1d4ed8;
664
+ }
665
+
666
+ .sw-voice-track {
667
+ flex: 1;
668
+ display: flex;
669
+ flex-direction: column;
670
+ gap: 4px;
671
+ }
672
+
673
+ .sw-voice-bar {
674
+ height: 5px;
675
+ width: 100%;
676
+ border-radius: 999px;
677
+ background: rgba(148, 163, 184, 0.28);
678
+ overflow: hidden;
679
+ cursor: pointer;
680
+ }
681
+
682
+ .sw-voice-fill {
683
+ height: 100%;
684
+ width: 0%;
685
+ background: #fbbf24;
686
+ border-radius: 999px;
687
+ transition: width 0.12s linear;
688
+ }
689
+
690
+ .sw-user .sw-voice-fill {
691
+ background: #ffffff;
692
+ }
693
+
694
+ .sw-voice-meta {
695
+ display: flex;
696
+ justify-content: space-between;
697
+ font-size: 10.5px;
698
+ color: var(--sw-text-muted);
699
+ }
700
+
701
+ .sw-user .sw-voice-meta {
702
+ color: rgba(255, 255, 255, 0.82);
703
+ }
704
+
705
+ /* ---------- Portfolio Carousel ---------- */
706
+ .sw-carousel {
707
+ width: 100%;
708
+ min-width: 280px;
709
+ background: var(--sw-surface-2);
710
+ border: 1px solid var(--sw-border-strong);
711
+ border-radius: 16px;
712
+ overflow: hidden;
713
+ }
714
+
715
+ .sw-carousel-media {
716
+ position: relative;
717
+ width: 100%;
718
+ height: 158px;
719
+ background: #0b1120;
720
+ }
721
+
722
+ .sw-carousel-media img {
723
+ width: 100%;
724
+ height: 100%;
725
+ object-fit: cover;
726
+ display: block;
727
+ }
728
+
729
+ .sw-carousel-counter {
730
+ position: absolute;
731
+ top: 10px;
732
+ right: 10px;
733
+ background: rgba(8, 13, 25, 0.82);
734
+ border: 1px solid rgba(255, 255, 255, 0.16);
735
+ color: #f8fafc;
736
+ font-size: 11px;
737
+ font-weight: 700;
738
+ padding: 3px 9px;
739
+ border-radius: 999px;
740
+ }
741
+
742
+ .sw-carousel-body {
743
+ padding: 12px 13px;
744
+ }
745
+
746
+ .sw-carousel-industry {
747
+ font-size: 10.5px;
748
+ font-weight: 700;
749
+ text-transform: uppercase;
750
+ letter-spacing: 0.1em;
751
+ color: #fbbf24;
752
+ margin-bottom: 4px;
753
+ }
754
+
755
+ .sw-carousel-title {
756
+ font-size: 15px;
757
+ font-weight: 700;
758
+ color: var(--sw-text);
759
+ margin: 0 0 6px;
760
+ }
761
+
762
+ .sw-carousel-summary {
763
+ font-size: 12.6px;
764
+ line-height: 1.48;
765
+ color: #cbd5e1;
766
+ margin: 0 0 11px;
767
+ }
768
+
769
+ .sw-carousel-cta {
770
+ display: grid;
771
+ grid-template-columns: 1fr 1fr;
772
+ gap: 7px;
773
+ margin-bottom: 9px;
774
+ }
775
+
776
+ .sw-btn-secondary, .sw-btn-primary {
777
+ font-family: inherit;
778
+ font-size: 12px;
779
+ font-weight: 600;
780
+ padding: 8px 10px;
781
+ border-radius: 10px;
782
+ text-align: center;
783
+ text-decoration: none;
784
+ cursor: pointer;
785
+ display: inline-flex;
786
+ align-items: center;
787
+ justify-content: center;
788
+ gap: 4px;
789
+ }
790
+
791
+ .sw-btn-secondary {
792
+ background: rgba(148, 163, 184, 0.12);
793
+ border: 1px solid var(--sw-border-strong);
794
+ color: var(--sw-text);
795
+ }
796
+
797
+ .sw-btn-secondary:hover {
798
+ background: rgba(148, 163, 184, 0.22);
799
+ }
800
+
801
+ .sw-btn-primary {
802
+ background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
803
+ border: none;
804
+ color: #080d19;
805
+ font-weight: 700;
806
+ }
807
+
808
+ .sw-btn-primary:hover {
809
+ filter: brightness(1.07);
810
+ }
811
+
812
+ .sw-carousel-nav {
813
+ display: flex;
814
+ align-items: center;
815
+ justify-content: space-between;
816
+ border-top: 1px solid var(--sw-border);
817
+ padding-top: 8px;
818
+ }
819
+
820
+ .sw-carousel-nav button {
821
+ font-family: inherit;
822
+ background: rgba(148, 163, 184, 0.1);
823
+ border: 1px solid var(--sw-border);
824
+ color: var(--sw-text);
825
+ border-radius: 8px;
826
+ padding: 5px 10px;
827
+ font-size: 12px;
828
+ font-weight: 600;
829
+ cursor: pointer;
830
+ }
831
+
832
+ .sw-carousel-nav button:hover {
833
+ background: rgba(148, 163, 184, 0.2);
834
+ }
835
+
836
+ /* ---------- Typing Indicator ---------- */
837
+ .sw-typing {
838
+ display: none;
839
+ align-self: flex-start;
840
+ align-items: center;
841
+ gap: 8px;
842
+ background: var(--sw-surface-2);
843
+ border: 1px solid var(--sw-border);
844
+ border-radius: 16px;
845
+ border-bottom-left-radius: 5px;
846
+ padding: 10px 14px;
847
+ margin: 0 14px 10px;
848
+ }
849
+
850
+ .sw-typing.sw-visible {
851
+ display: inline-flex;
852
+ }
853
+
854
+ .sw-dots {
855
+ display: inline-flex;
856
+ gap: 4px;
857
+ }
858
+
859
+ .sw-dots span {
860
+ width: 6px;
861
+ height: 6px;
862
+ border-radius: 999px;
863
+ background: #fbbf24;
864
+ animation: sw-bounce 1.2s infinite ease-in-out;
865
+ }
866
+
867
+ .sw-dots span:nth-child(2) { animation-delay: 0.18s; }
868
+ .sw-dots span:nth-child(3) { animation-delay: 0.36s; }
869
+
870
+ .sw-typing-label {
871
+ font-size: 12px;
872
+ color: var(--sw-text-muted);
873
+ }
874
+
875
+ /* ---------- Drag & Drop Overlay ---------- */
876
+ .sw-drop-overlay {
877
+ position: absolute;
878
+ inset: 0;
879
+ background: rgba(8, 13, 25, 0.88);
880
+ backdrop-filter: blur(6px);
881
+ border: 2px dashed #f59e0b;
882
+ border-radius: 20px;
883
+ margin: 8px;
884
+ display: none;
885
+ flex-direction: column;
886
+ align-items: center;
887
+ justify-content: center;
888
+ gap: 8px;
889
+ z-index: 20;
890
+ pointer-events: none;
891
+ }
892
+
893
+ .sw-drop-overlay.sw-visible {
894
+ display: flex;
895
+ }
896
+
897
+ .sw-drop-title {
898
+ font-size: 15px;
899
+ font-weight: 700;
900
+ color: #fde68a;
901
+ }
902
+
903
+ .sw-drop-sub {
904
+ font-size: 12.5px;
905
+ color: var(--sw-text-muted);
906
+ }
907
+
908
+ /* ---------- Composer / Input Bar ---------- */
909
+ .sw-composer {
910
+ padding: 10px 12px 12px;
911
+ background: rgba(15, 23, 42, 0.96);
912
+ border-top: 1px solid var(--sw-border);
913
+ flex-shrink: 0;
914
+ }
915
+
916
+ .sw-recording-bar {
917
+ display: none;
918
+ align-items: center;
919
+ justify-content: space-between;
920
+ gap: 10px;
921
+ background: rgba(239, 68, 68, 0.14);
922
+ border: 1px solid rgba(239, 68, 68, 0.42);
923
+ border-radius: 14px;
924
+ padding: 8px 12px;
925
+ }
926
+
927
+ .sw-recording-bar.sw-visible {
928
+ display: flex;
929
+ }
930
+
931
+ .sw-rec-status {
932
+ display: flex;
933
+ align-items: center;
934
+ gap: 8px;
935
+ font-size: 13px;
936
+ font-weight: 600;
937
+ color: #fecaca;
938
+ }
939
+
940
+ .sw-rec-dot {
941
+ width: 9px;
942
+ height: 9px;
943
+ border-radius: 999px;
944
+ background: #ef4444;
945
+ animation: sw-pulse 1s infinite;
946
+ }
947
+
948
+ .sw-rec-actions {
949
+ display: flex;
950
+ gap: 6px;
951
+ }
952
+
953
+ .sw-input-row {
954
+ display: flex;
955
+ align-items: flex-end;
956
+ gap: 7px;
957
+ background: var(--sw-bg);
958
+ border: 1px solid var(--sw-border-strong);
959
+ border-radius: 15px;
960
+ padding: 6px 7px;
961
+ transition: border-color 0.18s ease, box-shadow 0.18s ease;
962
+ }
963
+
964
+ .sw-input-row:focus-within {
965
+ border-color: rgba(245, 158, 11, 0.6);
966
+ box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
967
+ }
968
+
969
+ .sw-input-row.sw-hidden {
970
+ display: none;
971
+ }
972
+
973
+ .sw-textarea {
974
+ flex: 1;
975
+ background: transparent;
976
+ border: none;
977
+ outline: none;
978
+ color: var(--sw-text);
979
+ font-family: inherit;
980
+ font-size: 14px;
981
+ line-height: 1.4;
982
+ max-height: 100px;
983
+ min-height: 24px;
984
+ resize: none;
985
+ padding: 5px 4px;
986
+ }
987
+
988
+ .sw-textarea::placeholder {
989
+ color: var(--sw-text-dim);
990
+ }
991
+
992
+ .sw-send-btn {
993
+ width: 34px;
994
+ height: 34px;
995
+ border-radius: 11px;
996
+ border: none;
997
+ background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
998
+ color: #080d19;
999
+ display: flex;
1000
+ align-items: center;
1001
+ justify-content: center;
1002
+ cursor: pointer;
1003
+ flex-shrink: 0;
1004
+ padding: 0;
1005
+ transition: transform 0.14s ease, filter 0.14s ease;
1006
+ }
1007
+
1008
+ .sw-send-btn:hover {
1009
+ filter: brightness(1.08);
1010
+ transform: translateY(-1px);
1011
+ }
1012
+
1013
+ .sw-send-btn:active {
1014
+ transform: scale(0.94);
1015
+ }
1016
+
1017
+ .sw-footer-note {
1018
+ display: flex;
1019
+ align-items: center;
1020
+ justify-content: space-between;
1021
+ margin-top: 7px;
1022
+ padding: 0 3px;
1023
+ font-size: 10.5px;
1024
+ color: var(--sw-text-dim);
1025
+ }
1026
+
1027
+ .sw-footer-note a {
1028
+ color: var(--sw-text-muted);
1029
+ text-decoration: none;
1030
+ font-weight: 600;
1031
+ }
1032
+
1033
+ .sw-footer-note a:hover {
1034
+ color: #fbbf24;
1035
+ }
1036
+
1037
+ /* ---------- Animations ---------- */
1038
+ @keyframes sw-fade-up {
1039
+ from { opacity: 0; transform: translateY(6px); }
1040
+ to { opacity: 1; transform: translateY(0); }
1041
+ }
1042
+
1043
+ @keyframes sw-pop {
1044
+ 0% { transform: scale(0.4); opacity: 0; }
1045
+ 100% { transform: scale(1); opacity: 1; }
1046
+ }
1047
+
1048
+ @keyframes sw-bounce {
1049
+ 0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
1050
+ 40% { transform: translateY(-4px); opacity: 1; }
1051
+ }
1052
+
1053
+ @keyframes sw-pulse {
1054
+ 0%, 100% { opacity: 1; transform: scale(1); }
1055
+ 50% { opacity: 0.35; transform: scale(0.85); }
1056
+ }
1057
+
1058
+ /* ---------- Mobile Full-Screen Drawer ---------- */
1059
+ @media (max-width: 520px) {
1060
+ .sw-root {
1061
+ bottom: 14px;
1062
+ right: 14px;
1063
+ }
1064
+
1065
+ .sw-root.sw-left {
1066
+ left: 14px;
1067
+ }
1068
+
1069
+ .sw-root.sw-open {
1070
+ inset: 0;
1071
+ padding: 0;
1072
+ gap: 0;
1073
+ }
1074
+
1075
+ .sw-root.sw-open .sw-launcher-row {
1076
+ display: none;
1077
+ }
1078
+
1079
+ .sw-panel {
1080
+ width: 100vw;
1081
+ max-width: 100vw;
1082
+ height: 100dvh;
1083
+ max-height: 100dvh;
1084
+ border-radius: 0;
1085
+ border: none;
1086
+ }
1087
+
1088
+ .sw-composer {
1089
+ padding-bottom: max(12px, env(safe-area-inset-bottom));
1090
+ }
1091
+
1092
+ .sw-textarea {
1093
+ font-size: 16px;
1094
+ }
1095
+
1096
+ .sw-teaser {
1097
+ max-width: 210px;
1098
+ font-size: 12.2px;
1099
+ }
1100
+ }
1101
+
1102
+ @media (prefers-reduced-motion: reduce) {
1103
+ .sw-panel, .sw-launcher, .sw-msg-row, .sw-teaser, .sw-reaction, .sw-dots span, .sw-rec-dot {
1104
+ animation: none !important;
1105
+ transition: none !important;
1106
+ }
1107
+ }
1108
+ `;var z=10*1024*1024,N=40,A='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M18 6L6 18M6 6l12 12"/></svg>',P='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg>',D='<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/></svg>',j='<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',$='<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="2" width="6" height="12" rx="3"/><path d="M5 10v2a7 7 0 0 0 14 0v-2"/><line x1="12" y1="19" x2="12" y2="22"/></svg>',U='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>',_='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="6 4 20 12 6 20 6 4"/></svg>',F='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg>',K='<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',R="data:image/svg+xml;utf8,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="32" fill="#080d19"/><text x="50%" y="56%" text-anchor="middle" fill="#fbbf24" font-family="Arial,sans-serif" font-weight="800" font-size="24">SW</text></svg>');function I(u){if(!u)return null;try{let e=new URL(u,window.location.origin);if(e.protocol==="http:"||e.protocol==="https:")return e.href}catch{return null}return null}function H(u,e){let t=atob(u),s=t.length,i=new Uint8Array(s);for(let r=0;r<s;r++)i[r]=t.charCodeAt(r);return URL.createObjectURL(new Blob([i],{type:e}))}function B(u){try{return(u?new Date(u):new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function L(u){if(!Number.isFinite(u)||u<0)return"0:00";let e=Math.floor(u/60),t=Math.floor(u%60);return`${e}:${t.toString().padStart(2,"0")}`}function S(u){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${u}_${crypto.randomUUID().replace(/-/g,"").slice(0,12)}`:`${u}_${Math.random().toString(36).slice(2,12)}`}var T=class{constructor(e){this.teaserEl=null;this.isOpen=!1;this.unreadCount=0;this.sessionToken=null;this.sessionExpiresAt=0;this.ws=null;this.wsConnecting=!1;this.pingTimer=null;this.reconnectTimer=null;this.reconnectAttempt=0;this.typingClearTimer=null;this.pendingFrames=[];this.objectUrls=[];this.storedMessages=[];this.msgRowById=new Map;this.destroyed=!1;this.mediaRecorder=null;this.mediaStream=null;this.recChunks=[];this.recStartedAt=0;this.recTickTimer=null;this.recCancelled=!1;let t=e.apiUrl.replace(/\/+$/,"");this.opts={siteId:e.siteId,apiUrl:t,position:e.position??"bottom-right",greeting:e.greeting??"Need a website, app, or AI agent? Chat with our AI Agent",title:e.title??"SEEKHI WAVE AI Agent",avatarUrl:e.avatarUrl??`${t}/widget/avatar.png`,turnstileSiteKey:e.turnstileSiteKey,zIndex:e.zIndex??2147483e3,hideTeaser:e.hideTeaser??!1},this.hostEl=document.createElement("div"),this.hostEl.id="seekhiwave-agent-widget-host",this.hostEl.setAttribute("data-seekhiwave-widget","true"),this.shadow=this.hostEl.attachShadow({mode:"open"}),this.renderShell(),document.body.appendChild(this.hostEl),this.loadStoredHistory()}get storageSessionKey(){return`sw_widget_sess_${this.opts.siteId}`}get storageHistoryKey(){return`sw_widget_hist_${this.opts.siteId}`}get storageTeaserKey(){return`sw_widget_teaser_dismissed_${this.opts.siteId}`}renderShell(){let e=document.createElement("style");e.textContent=O,this.shadow.appendChild(e);let t=document.createElement("div");t.className=`sw-root${this.opts.position==="bottom-left"?" sw-left":""}`,t.style.zIndex=String(this.opts.zIndex),this.rootEl=t;let s=document.createElement("section");s.className="sw-panel",s.setAttribute("aria-label",this.opts.title);let i=document.createElement("div");i.className="sw-spectrum-bar",s.appendChild(i);let r=document.createElement("header");r.className="sw-header",r.innerHTML=`
1109
+ <div class="sw-header-brand">
1110
+ <div class="sw-header-avatar-wrap">
1111
+ <img class="sw-header-avatar" alt="SEEKHI WAVE" />
1112
+ <span class="sw-header-dot"></span>
1113
+ </div>
1114
+ <div class="sw-header-info">
1115
+ <div class="sw-header-title"></div>
1116
+ <div class="sw-header-sub">Online \xB7 Replies in seconds</div>
1117
+ </div>
1118
+ </div>
1119
+ <div class="sw-header-actions">
1120
+ <button class="sw-icon-btn sw-act-portfolio" type="button" title="Browse Portfolio" aria-label="Browse Portfolio">${P}</button>
1121
+ <button class="sw-icon-btn sw-act-reset" type="button" title="New Conversation" aria-label="New Conversation">${D}</button>
1122
+ <button class="sw-icon-btn sw-act-close" type="button" title="Close Chat" aria-label="Close Chat">${A}</button>
1123
+ </div>
1124
+ `;let o=r.querySelector(".sw-header-avatar");o.src=this.opts.avatarUrl,o.onerror=()=>{o.src=R},r.querySelector(".sw-header-title").textContent=this.opts.title,this.headerDotEl=r.querySelector(".sw-header-dot"),this.headerSubEl=r.querySelector(".sw-header-sub"),r.querySelector(".sw-act-portfolio").addEventListener("click",()=>this.openPortfolio()),r.querySelector(".sw-act-reset").addEventListener("click",()=>this.resetSession()),r.querySelector(".sw-act-close").addEventListener("click",()=>this.close()),s.appendChild(r);let a=document.createElement("div");a.className="sw-messages",this.messagesEl=a,s.appendChild(a);let n=document.createElement("div");n.className="sw-typing",n.innerHTML=`
1125
+ <span class="sw-dots"><span></span><span></span><span></span></span>
1126
+ <span class="sw-typing-label">SEEKHI WAVE Agent is typing\u2026</span>
1127
+ `,this.typingEl=n,s.appendChild(n);let d=document.createElement("div");d.className="sw-drop-overlay",d.innerHTML=`
1128
+ <div class="sw-drop-title">Drop file to share with SEEKHI WAVE</div>
1129
+ <div class="sw-drop-sub">Screenshots, designs, PDFs, or DOCX specs (up to 10 MB)</div>
1130
+ `,this.dropOverlayEl=d,s.appendChild(d);let l=document.createElement("div");l.className="sw-composer";let c=document.createElement("div");c.className="sw-recording-bar",c.innerHTML=`
1131
+ <div class="sw-rec-status">
1132
+ <span class="sw-rec-dot"></span>
1133
+ <span>Recording voice note\u2026</span>
1134
+ <span class="sw-rec-timer">0:00</span>
1135
+ </div>
1136
+ <div class="sw-rec-actions">
1137
+ <button class="sw-icon-btn sw-rec-cancel" type="button" title="Cancel" aria-label="Cancel Recording">${A}</button>
1138
+ <button class="sw-send-btn sw-rec-send" type="button" title="Send Voice Note" aria-label="Send Voice Note">${U}</button>
1139
+ </div>
1140
+ `,this.recordingBarEl=c,this.recTimerEl=c.querySelector(".sw-rec-timer"),c.querySelector(".sw-rec-cancel").addEventListener("click",()=>this.stopRecording(!0)),c.querySelector(".sw-rec-send").addEventListener("click",()=>this.stopRecording(!1)),l.appendChild(c);let h=document.createElement("div");h.className="sw-input-row",h.innerHTML=`
1141
+ <input class="sw-file-input" type="file" accept="image/*,audio/*,.pdf,.doc,.docx,.txt" style="display:none" />
1142
+ <button class="sw-icon-btn sw-btn-attach" type="button" title="Attach image, PDF, or DOCX" aria-label="Attach File">${j}</button>
1143
+ <textarea class="sw-textarea" rows="1" placeholder="Ask about projects, voice note, or drop a brief\u2026"></textarea>
1144
+ <button class="sw-icon-btn sw-btn-mic" type="button" title="Record voice note" aria-label="Record Voice Note">${$}</button>
1145
+ <button class="sw-send-btn sw-btn-send" type="button" title="Send" aria-label="Send Message">${U}</button>
1146
+ `,this.inputRowEl=h,this.fileInputEl=h.querySelector(".sw-file-input"),this.textareaEl=h.querySelector(".sw-textarea"),h.querySelector(".sw-btn-attach").addEventListener("click",()=>this.fileInputEl.click()),this.fileInputEl.addEventListener("change",()=>{var f;let p=(f=this.fileInputEl.files)==null?void 0:f[0];p&&this.handleFileUpload(p),this.fileInputEl.value=""}),h.querySelector(".sw-btn-mic").addEventListener("click",()=>{this.startRecording()}),h.querySelector(".sw-btn-send").addEventListener("click",()=>this.submitTextarea()),this.textareaEl.addEventListener("input",()=>this.autoResizeTextarea()),this.textareaEl.addEventListener("keydown",p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),this.submitTextarea())}),l.appendChild(h);let v=document.createElement("div");v.className="sw-footer-note",v.innerHTML=`
1147
+ <span>Voice \xB7 Screenshots \xB7 PDFs supported</span>
1148
+ <span>Powered by <a href="https://www.seekhiwave.com/" target="_blank" rel="noopener noreferrer">SEEKHI WAVE</a></span>
1149
+ `,l.appendChild(v),s.appendChild(l);let m=0;s.addEventListener("dragenter",p=>{p.preventDefault(),m++,this.dropOverlayEl.classList.add("sw-visible")}),s.addEventListener("dragover",p=>{p.preventDefault()}),s.addEventListener("dragleave",()=>{m=Math.max(0,m-1),m===0&&this.dropOverlayEl.classList.remove("sw-visible")}),s.addEventListener("drop",p=>{var x,g;p.preventDefault(),m=0,this.dropOverlayEl.classList.remove("sw-visible");let f=(g=(x=p.dataTransfer)==null?void 0:x.files)==null?void 0:g[0];f&&this.handleFileUpload(f)}),t.appendChild(s);let b=document.createElement("div");b.className="sw-launcher-row";let y=(()=>{try{return sessionStorage.getItem(this.storageTeaserKey)==="1"}catch{return!1}})();if(!this.opts.hideTeaser&&!y){let p=document.createElement("div");p.className="sw-teaser";let f=document.createElement("span");f.textContent=this.opts.greeting;let x=document.createElement("button");x.className="sw-teaser-close",x.type="button",x.setAttribute("aria-label","Dismiss greeting"),x.textContent="\xD7",x.addEventListener("click",g=>{g.stopPropagation(),this.dismissTeaser()}),p.addEventListener("click",()=>this.open()),p.appendChild(f),p.appendChild(x),this.teaserEl=p,b.appendChild(p)}let w=document.createElement("button");w.className="sw-launcher",w.type="button",w.setAttribute("aria-label","Open SEEKHI WAVE AI Agent Chat"),w.innerHTML=`
1150
+ <img class="sw-launcher-img" alt="SEEKHI WAVE AI Agent" />
1151
+ <span class="sw-launcher-icon-close">${A}</span>
1152
+ <span class="sw-status-dot"></span>
1153
+ <span class="sw-unread-badge" style="display:none">0</span>
1154
+ `;let E=w.querySelector(".sw-launcher-img");E.src=this.opts.avatarUrl,E.onerror=()=>{E.src=R},this.unreadBadgeEl=w.querySelector(".sw-unread-badge"),w.addEventListener("click",()=>this.toggle()),b.appendChild(w),t.appendChild(b),this.shadow.appendChild(t),this.renderWelcomeCard()}renderWelcomeCard(){let e=document.createElement("div");e.className="sw-welcome",e.innerHTML=`
1155
+ <div class="sw-welcome-eyebrow">SEEKHI WAVE \xB7 AI SALES &amp; CONSULTATION AGENT</div>
1156
+ <p class="sw-welcome-text">
1157
+ Hi! I'm SEEKHI WAVE's AI Agent. Ask about websites, POS, SaaS apps, AI agents, drop a screenshot or PDF brief, or send a voice note in English or Sinhala.
1158
+ </p>
1159
+ <div class="sw-chips"></div>
1160
+ `;let t=e.querySelector(".sw-chips"),s=[{label:"Explore Portfolio",action:()=>this.openPortfolio()},{label:"What do you build?",action:()=>this.sendMessage("What services and software solutions does SEEKHI WAVE build?")},{label:"Audit my website",action:()=>this.sendMessage("Can you audit my website and tell me how we can improve it?")}];for(let i of s){let r=document.createElement("button");r.type="button",r.className="sw-chip",r.textContent=i.label,r.addEventListener("click",i.action),t.appendChild(r)}this.messagesEl.appendChild(e)}open(){this.destroyed||(this.isOpen=!0,this.rootEl.classList.add("sw-open"),this.dismissTeaser(),this.clearUnread(),this.ensureConnected(),setTimeout(()=>{this.scrollToBottom(),this.textareaEl.focus()},180))}close(){this.destroyed||(this.isOpen=!1,this.rootEl.classList.remove("sw-open"))}toggle(){this.isOpen?this.close():this.open()}sendMessage(e){let t=e.trim();if(!t)return;this.isOpen||this.open();let s=S("msg"),i=new Date().toISOString(),r={id:s,role:"user",kind:"text",text:t,ts:i};this.appendStoredMessage(r),this.renderMessage(r),this.showTyping(),this.sendWsFrame({type:"message",text:t,page_path:window.location.pathname||"/",client_message_id:s})}openPortfolio(){this.isOpen||this.open(),this.sendWsFrame({type:"open_portfolio"})}resetSession(){try{localStorage.removeItem(this.storageSessionKey),localStorage.removeItem(this.storageHistoryKey)}catch{}if(this.sessionToken=null,this.sessionExpiresAt=0,this.storedMessages=[],this.msgRowById.clear(),this.ws){try{this.ws.close(1e3,"reset")}catch{}this.ws=null}this.messagesEl.innerHTML="",this.renderWelcomeCard(),this.hideTyping(),this.ensureConnected()}destroy(){if(this.destroyed=!0,this.stopTimers(),this.mediaRecorder&&this.mediaRecorder.state!=="inactive"&&this.stopRecording(!0),this.ws){try{this.ws.close(1e3,"destroy")}catch{}this.ws=null}for(let e of this.objectUrls)URL.revokeObjectURL(e);this.objectUrls=[],this.hostEl.remove()}setConnectionStatus(e,t){this.headerDotEl.classList.toggle("sw-offline",!e),this.headerSubEl.textContent=t??(e?"Online \xB7 Replies in seconds":"Connecting\u2026")}async ensureSession(){let e=Math.floor(Date.now()/1e3);if(this.sessionToken&&this.sessionExpiresAt>e+60)return this.sessionToken;let t;try{let a=localStorage.getItem(this.storageSessionKey);if(a){let n=JSON.parse(a);n.token&&(n.expiresAt??0)>e+60&&(t=n.token)}}catch{}let s=this.opts.turnstileSiteKey;if(!s&&!t)try{let a=await fetch(`${this.opts.apiUrl}/api/widget/config`,{method:"GET",credentials:"omit"});if(a.ok){let n=await a.json();n.turnstile_site_key&&(s=n.turnstile_site_key,this.opts.turnstileSiteKey=s)}}catch{}let i;s&&!t&&(i=await this.acquireTurnstileToken(s));let r=await fetch(`${this.opts.apiUrl}/api/widget/session`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify({site_id:this.opts.siteId,page_path:window.location.pathname||"/",existing_token:t??null,turnstile_token:i??null})});if(!r.ok){let a=`Session failed (${r.status})`;try{let n=await r.json();n.detail&&(a=n.detail)}catch{}throw new Error(a)}let o=await r.json();this.sessionToken=o.session_token,this.sessionExpiresAt=o.expires_at;try{localStorage.setItem(this.storageSessionKey,JSON.stringify({token:o.session_token,visitorId:o.visitor_id,expiresAt:o.expires_at}))}catch{}return o.session_token}async acquireTurnstileToken(e){let t=window;if(t.turnstile||await new Promise(s=>{let i=document.createElement("script");i.src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",i.async=!0,i.onload=()=>s(),i.onerror=()=>s(),document.head.appendChild(i)}),!!t.turnstile)return await new Promise(s=>{let i=document.createElement("div");i.style.cssText="position:fixed;bottom:0;right:0;opacity:0;pointer-events:none;z-index:-1;",document.body.appendChild(i);let r=!1,o=n=>{r||(r=!0,i.remove(),s(n))},a=window.setTimeout(()=>o(void 0),1e4);try{t.turnstile.render(i,{sitekey:e,size:"compact",callback:n=>{window.clearTimeout(a),o(n)},"error-callback":()=>{window.clearTimeout(a),o(void 0)}})}catch{window.clearTimeout(a),o(void 0)}})}async ensureConnected(){if(!this.destroyed&&!(this.ws&&this.ws.readyState===WebSocket.OPEN)&&!this.wsConnecting){this.wsConnecting=!0,this.setConnectionStatus(!1,"Connecting\u2026");try{let e=await this.ensureSession(),t=this.opts.apiUrl.replace(/^http:/i,"ws:").replace(/^https:/i,"wss:"),s=new WebSocket(`${t}/ws/widget?token=${encodeURIComponent(e)}`);this.ws=s,s.onopen=()=>{this.wsConnecting=!1,this.reconnectAttempt=0,this.setConnectionStatus(!0),this.startPingLoop(),this.flushPendingFrames()},s.onmessage=i=>{try{let r=JSON.parse(i.data);this.handleServerEvent(r)}catch{}},s.onclose=i=>{if(this.wsConnecting=!1,this.stopPingLoop(),this.ws===s&&(this.ws=null),this.destroyed)return;if(i.code===4401){this.sessionToken=null,this.sessionExpiresAt=0;try{localStorage.removeItem(this.storageSessionKey)}catch{}}if(i.code===4403){this.setConnectionStatus(!1,"Origin not authorized"),this.showSystemNotice("This website origin is not authorized for this widget.");return}if(i.code===1e3)return;this.setConnectionStatus(!1,"Reconnecting\u2026");let r=Math.min(12e3,1e3*Math.pow(2,this.reconnectAttempt));this.reconnectAttempt++,this.reconnectTimer=window.setTimeout(()=>{this.ensureConnected()},r)},s.onerror=()=>{this.wsConnecting=!1}}catch(e){this.wsConnecting=!1,this.setConnectionStatus(!1,"Connection issue"),this.hideTyping(),this.showSystemNotice(e instanceof Error?e.message:"Could not connect to SEEKHI WAVE Agent.")}}}async sendWsFrame(e){if(this.ws&&this.ws.readyState===WebSocket.OPEN){this.ws.send(JSON.stringify(e));return}this.pendingFrames.push(e),await this.ensureConnected()}flushPendingFrames(){if(!(!this.ws||this.ws.readyState!==WebSocket.OPEN))for(;this.pendingFrames.length>0;){let e=this.pendingFrames.shift();e&&this.ws.send(JSON.stringify(e))}}startPingLoop(){this.stopPingLoop(),this.pingTimer=window.setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"ping"}))},25e3)}stopPingLoop(){this.pingTimer!==null&&(window.clearInterval(this.pingTimer),this.pingTimer=null)}stopTimers(){this.stopPingLoop(),this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.typingClearTimer!==null&&(window.clearTimeout(this.typingClearTimer),this.typingClearTimer=null),this.recTickTimer!==null&&(window.clearInterval(this.recTickTimer),this.recTickTimer=null)}handleServerEvent(e){switch(e.type){case"connected":case"pong":return;case"typing":this.showTyping();return;case"error":this.hideTyping(),this.showSystemNotice(e.message);return;case"reaction":this.attachReaction(e.message_id,e.emoji);return;case"text_bubble":{this.hideTyping();let t={id:S("ag"),role:"agent",kind:"text",html:e.html,text:e.text,urlButtons:e.url_buttons,quickReplies:e.quick_replies,ts:e.ts??new Date().toISOString()};this.appendStoredMessage(t),this.renderMessage(t),this.bumpUnreadIfClosed();return}case"image_card":{this.hideTyping();let t={id:S("img"),role:"agent",kind:"image",imageUrl:e.image_url,html:e.caption_html,urlButtons:e.url_buttons,quickReplies:e.quick_replies,ts:e.ts??new Date().toISOString()};this.appendStoredMessage(t),this.renderMessage(t),this.bumpUnreadIfClosed();return}case"pdf_card":{this.hideTyping();let t=H(e.data_b64,e.mime||"application/pdf");this.objectUrls.push(t);let s={id:S("pdf"),role:"agent",kind:"pdf",filename:e.filename,html:e.caption_html,urlButtons:e.url_buttons,ts:e.ts??new Date().toISOString()};this.appendStoredMessage(s),this.renderPdfCard(s,t),this.bumpUnreadIfClosed();return}case"voice_audio":{this.hideTyping();let t=H(e.audio_b64,e.mime||"audio/mpeg");this.objectUrls.push(t);let s={id:S("voc"),role:"agent",kind:"voice",filename:e.filename??"seekhiwave_reply.mp3",html:e.caption_html,ts:e.ts??new Date().toISOString()};this.appendStoredMessage(s),this.renderVoiceMessage(s,t),this.bumpUnreadIfClosed();return}case"portfolio_carousel":{this.hideTyping();let t={id:S("car"),role:"agent",kind:"carousel",projects:e.projects,startIndex:e.start_index??0,ts:e.ts??new Date().toISOString()};this.appendStoredMessage(t),this.renderCarousel(t),this.bumpUnreadIfClosed();return}}}async handleFileUpload(e,t=!1){if(e.size>z){this.showSystemNotice("File is too large. Maximum allowed size is 10 MB.");return}let s=S("up"),i=new Date().toISOString(),r=e.type.startsWith("image/");if(t||e.type.startsWith("audio/")){let a=URL.createObjectURL(e);this.objectUrls.push(a);let n={id:s,role:"user",kind:"voice",filename:e.name,ts:i};this.appendStoredMessage(n),this.renderVoiceMessage(n,a)}else if(r){let a=URL.createObjectURL(e);this.objectUrls.push(a);let n={id:s,role:"user",kind:"image",imageUrl:a,text:e.name,ts:i};this.appendStoredMessage({...n,imageUrl:void 0,text:`\u{1F4F7} Uploaded image: ${e.name}`}),this.renderMessage(n)}else{let a={id:s,role:"user",kind:"text",text:`\u{1F4CE} ${e.name}`,ts:i};this.appendStoredMessage(a),this.renderMessage(a)}this.showTyping();try{await this.ensureConnected();let a=await this.ensureSession(),n=new FormData;n.append("file",e,e.name),n.append("caption",this.textareaEl.value.trim()),n.append("page_path",window.location.pathname||"/"),n.append("client_message_id",s),this.textareaEl.value.trim()&&(this.textareaEl.value="",this.autoResizeTextarea());let d=await fetch(`${this.opts.apiUrl}/api/widget/upload`,{method:"POST",headers:{Authorization:`Bearer ${a}`},credentials:"omit",body:n});if(!d.ok){let l=`Upload failed (${d.status})`;try{let c=await d.json();c.detail&&(l=c.detail)}catch{}throw new Error(l)}}catch(a){this.hideTyping(),this.showSystemNotice(a instanceof Error?a.message:"Could not upload file.")}}async startRecording(){if(!navigator.mediaDevices||typeof MediaRecorder>"u"){this.showSystemNotice("Voice recording is not supported in this browser.");return}try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});this.mediaStream=e;let t=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/ogg;codecs=opus")?"audio/ogg;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",s=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);this.mediaRecorder=s,this.recChunks=[],this.recCancelled=!1,this.recStartedAt=Date.now(),this.recTimerEl.textContent="0:00",s.ondataavailable=i=>{i.data&&i.data.size>0&&this.recChunks.push(i.data)},s.onstop=()=>{if(this.cleanupMediaStream(),this.recCancelled||this.recChunks.length===0)return;let i=s.mimeType||t||"audio/webm",r=i.includes("ogg")?"ogg":i.includes("mp4")?"m4a":"webm",o=new Blob(this.recChunks,{type:i}),a=new File([o],`voice_note.${r}`,{type:i});this.handleFileUpload(a,!0)},s.start(),this.inputRowEl.classList.add("sw-hidden"),this.recordingBarEl.classList.add("sw-visible"),this.recTickTimer=window.setInterval(()=>{let i=(Date.now()-this.recStartedAt)/1e3;this.recTimerEl.textContent=L(i),i>=120&&this.stopRecording(!1)},300)}catch{this.showSystemNotice("Microphone permission was denied. You can type or attach files instead.")}}stopRecording(e){if(this.recCancelled=e,this.recTickTimer!==null&&(window.clearInterval(this.recTickTimer),this.recTickTimer=null),this.recordingBarEl.classList.remove("sw-visible"),this.inputRowEl.classList.remove("sw-hidden"),this.mediaRecorder&&this.mediaRecorder.state!=="inactive")try{this.mediaRecorder.stop()}catch{this.cleanupMediaStream()}else this.cleanupMediaStream()}cleanupMediaStream(){if(this.mediaStream){for(let e of this.mediaStream.getTracks())e.stop();this.mediaStream=null}this.mediaRecorder=null}submitTextarea(){let e=this.textareaEl.value.trim();e&&(this.textareaEl.value="",this.autoResizeTextarea(),this.sendMessage(e))}autoResizeTextarea(){this.textareaEl.style.height="auto",this.textareaEl.style.height=`${Math.min(100,this.textareaEl.scrollHeight)}px`}showTyping(){this.typingEl.classList.add("sw-visible"),this.typingClearTimer!==null&&window.clearTimeout(this.typingClearTimer),this.typingClearTimer=window.setTimeout(()=>this.hideTyping(),25e3),this.scrollToBottom()}hideTyping(){this.typingEl.classList.remove("sw-visible"),this.typingClearTimer!==null&&(window.clearTimeout(this.typingClearTimer),this.typingClearTimer=null)}showSystemNotice(e){let t=document.createElement("div");t.className="sw-msg-row sw-system";let s=document.createElement("div");s.className="sw-bubble",s.textContent=e,t.appendChild(s),this.messagesEl.appendChild(t),this.scrollToBottom()}attachReaction(e,t){let s=this.msgRowById.get(e);if(!s)return;let i=s.querySelector(".sw-bubble");if(!i)return;let r=i.querySelector(".sw-reaction");r||(r=document.createElement("span"),r.className="sw-reaction",i.appendChild(r)),r.textContent=t;let o=this.storedMessages.find(a=>a.id===e);o&&(o.reaction=t,this.saveStoredHistory())}renderMessage(e){var i,r,o,a,n;if(e.kind==="carousel"&&((i=e.projects)!=null&&i.length)){this.renderCarousel(e);return}if(e.kind==="pdf"){this.renderPdfCard(e,null);return}if(e.kind==="voice"){this.renderVoiceMessage(e,null);return}let t=document.createElement("div");if(t.className=`sw-msg-row sw-${e.role}`,t.dataset.msgId=e.id,e.kind==="image"&&e.imageUrl){let d=document.createElement("div");d.className="sw-image-card";let l=document.createElement("img");if(l.src=e.imageUrl,l.alt="Project preview",l.loading="lazy",l.addEventListener("click",()=>{let c=I(e.imageUrl);c&&window.open(c,"_blank","noopener,noreferrer")}),d.appendChild(l),e.html||e.text||(r=e.urlButtons)!=null&&r.length){let c=document.createElement("div");if(c.className="sw-image-card-body",e.html&&e.role==="agent"){let h=document.createElement("div");h.innerHTML=e.html,c.appendChild(h)}else if(e.text){let h=document.createElement("div");h.textContent=e.text,c.appendChild(h)}(o=e.urlButtons)!=null&&o.length&&c.appendChild(this.buildUrlButtons(e.urlButtons)),d.appendChild(c)}t.appendChild(d)}else{let d=document.createElement("div");if(d.className="sw-bubble",e.role==="agent"&&e.html?d.innerHTML=e.html:d.textContent=e.text??"",e.reaction){let l=document.createElement("span");l.className="sw-reaction",l.textContent=e.reaction,d.appendChild(l)}t.appendChild(d),(a=e.urlButtons)!=null&&a.length&&t.appendChild(this.buildUrlButtons(e.urlButtons))}(n=e.quickReplies)!=null&&n.length&&t.appendChild(this.buildQuickReplies(e.quickReplies));let s=document.createElement("div");s.className="sw-time",s.textContent=B(e.ts),t.appendChild(s),this.msgRowById.set(e.id,t),this.messagesEl.appendChild(t),this.scrollToBottom()}renderPdfCard(e,t){var a;let s=document.createElement("div");s.className=`sw-msg-row sw-${e.role}`,s.dataset.msgId=e.id;let i=document.createElement("div");i.className="sw-pdf-card";let r=document.createElement("div");if(r.className="sw-pdf-top",r.innerHTML=`
1161
+ <div class="sw-pdf-badge">PDF</div>
1162
+ <div class="sw-pdf-meta">
1163
+ <div class="sw-pdf-name"></div>
1164
+ <div class="sw-pdf-sub">SEEKHI WAVE Project Brief</div>
1165
+ </div>
1166
+ `,r.querySelector(".sw-pdf-name").textContent=e.filename||"SEEKHI_WAVE_Brief.pdf",i.appendChild(r),e.html){let n=document.createElement("div");n.className="sw-pdf-caption",n.innerHTML=e.html,i.appendChild(n)}if(t){let n=document.createElement("a");n.className="sw-pdf-dl",n.href=t,n.download=e.filename||"SEEKHI_WAVE_Brief.pdf",n.innerHTML=`${K}<span>Download PDF Brief</span>`,i.appendChild(n)}else{let n=document.createElement("div");n.className="sw-pdf-sub",n.textContent="PDF sent earlier in this session \u2014 ask me to regenerate a fresh copy anytime.",i.appendChild(n)}(a=e.urlButtons)!=null&&a.length&&i.appendChild(this.buildUrlButtons(e.urlButtons)),s.appendChild(i);let o=document.createElement("div");o.className="sw-time",o.textContent=B(e.ts),s.appendChild(o),this.msgRowById.set(e.id,s),this.messagesEl.appendChild(s),this.scrollToBottom()}renderVoiceMessage(e,t){let s=document.createElement("div");s.className=`sw-msg-row sw-${e.role}`,s.dataset.msgId=e.id;let i=document.createElement("div");if(i.className="sw-bubble sw-voice-bubble",t){let o=new Audio(t),a=document.createElement("div");a.className="sw-voice-row";let n=document.createElement("button");n.type="button",n.className="sw-voice-play",n.setAttribute("aria-label","Play voice note"),n.innerHTML=_;let d=document.createElement("div");d.className="sw-voice-track";let l=document.createElement("div");l.className="sw-voice-bar";let c=document.createElement("div");c.className="sw-voice-fill",l.appendChild(c);let h=document.createElement("div");h.className="sw-voice-meta";let v=document.createElement("span");v.textContent=e.role==="user"?"Voice note":"SEEKHI WAVE Voice Reply";let m=document.createElement("span");m.textContent="0:00",h.appendChild(v),h.appendChild(m),d.appendChild(l),d.appendChild(h),a.appendChild(n),a.appendChild(d),i.appendChild(a),o.addEventListener("loadedmetadata",()=>{Number.isFinite(o.duration)&&(m.textContent=L(o.duration))}),o.addEventListener("timeupdate",()=>{o.duration>0&&(c.style.width=`${Math.min(100,o.currentTime/o.duration*100)}%`,m.textContent=L(o.currentTime))}),o.addEventListener("ended",()=>{n.innerHTML=_,c.style.width="0%",Number.isFinite(o.duration)&&(m.textContent=L(o.duration))}),n.addEventListener("click",()=>{o.paused?(o.play(),n.innerHTML=F):(o.pause(),n.innerHTML=_)}),l.addEventListener("click",b=>{if(!Number.isFinite(o.duration)||o.duration<=0)return;let y=l.getBoundingClientRect(),w=Math.max(0,Math.min(1,(b.clientX-y.left)/y.width));o.currentTime=w*o.duration})}else{let o=document.createElement("div");o.textContent=e.role==="user"?"\u{1F3A4} Voice note sent earlier":"\u{1F50A} Voice reply sent earlier",i.appendChild(o)}if(e.html&&e.role==="agent"){let o=document.createElement("div");o.style.fontSize="12.5px",o.style.opacity="0.9",o.innerHTML=e.html,i.appendChild(o)}s.appendChild(i);let r=document.createElement("div");r.className="sw-time",r.textContent=B(e.ts),s.appendChild(r),this.msgRowById.set(e.id,s),this.messagesEl.appendChild(s),this.scrollToBottom()}renderCarousel(e){let t=e.projects??[];if(t.length===0)return;let s=document.createElement("div");s.className="sw-msg-row sw-agent",s.style.maxWidth="94%";let i=document.createElement("div");i.className="sw-carousel";let r=(e.startIndex??0)%t.length,o=document.createElement("div");o.className="sw-carousel-media";let a=document.createElement("img");a.loading="lazy";let n=document.createElement("span");n.className="sw-carousel-counter",o.appendChild(a),o.appendChild(n);let d=document.createElement("div");d.className="sw-carousel-body";let l=document.createElement("div");l.className="sw-carousel-industry";let c=document.createElement("h4");c.className="sw-carousel-title";let h=document.createElement("p");h.className="sw-carousel-summary";let v=document.createElement("div");v.className="sw-carousel-cta";let m=document.createElement("a");m.className="sw-btn-secondary",m.target="_blank",m.rel="noopener noreferrer",m.textContent="Visit Live \u2197";let b=document.createElement("button");b.type="button",b.className="sw-btn-primary",b.textContent="Build Similar \u2192",v.appendChild(m),v.appendChild(b);let y=document.createElement("div");y.className="sw-carousel-nav";let w=document.createElement("button");w.type="button",w.textContent="\u2190 Prev";let E=document.createElement("span");E.style.fontSize="11px",E.style.color="#94a3b8";let p=document.createElement("button");p.type="button",p.textContent="Next \u2192",y.appendChild(w),y.appendChild(E),y.appendChild(p),d.appendChild(l),d.appendChild(c),d.appendChild(h),d.appendChild(v),d.appendChild(y),i.appendChild(o),i.appendChild(d),s.appendChild(i);let f=()=>{let g=t[r];a.src=I(g.image_url)||R,a.alt=g.name,n.textContent=`${r+1} / ${t.length}`,l.textContent=g.industry||"Featured Project",c.textContent=g.name,h.textContent=g.summary,m.href=I(g.url)||"https://www.seekhiwave.com/",E.textContent="SEEKHI WAVE Portfolio"};w.addEventListener("click",()=>{r=(r-1+t.length)%t.length,f()}),p.addEventListener("click",()=>{r=(r+1)%t.length,f()}),b.addEventListener("click",()=>{let g=t[r],k=S("sim"),C={id:k,role:"user",kind:"text",text:`I'd like to build something similar to ${g.name}!`,ts:new Date().toISOString()};this.appendStoredMessage(C),this.renderMessage(C),this.showTyping(),this.sendWsFrame({type:"carousel_similar",project_name:g.name,industry:g.industry,page_path:window.location.pathname||"/",client_message_id:k})});let x=0;i.addEventListener("touchstart",g=>{var k;x=((k=g.touches[0])==null?void 0:k.clientX)??0},{passive:!0}),i.addEventListener("touchend",g=>{var C;let k=(((C=g.changedTouches[0])==null?void 0:C.clientX)??0)-x;Math.abs(k)>40&&(r=k<0?(r+1)%t.length:(r-1+t.length)%t.length,f())},{passive:!0}),f(),this.messagesEl.appendChild(s),this.scrollToBottom()}buildUrlButtons(e){let t=document.createElement("div");t.className="sw-url-buttons";for(let s of e){let i=I(s.url);if(!i)continue;let r=document.createElement("a");r.className="sw-url-btn",r.href=i,r.target="_blank",r.rel="noopener noreferrer",r.textContent=`${s.label} \u2197`,t.appendChild(r)}return t}buildQuickReplies(e){let t=document.createElement("div");t.className="sw-quick-replies";for(let s of e){let i=document.createElement("button");i.type="button",i.className="sw-chip",i.textContent=s.label,i.addEventListener("click",()=>{t.remove(),this.sendMessage(s.label)}),t.appendChild(i)}return t}dismissTeaser(){this.teaserEl&&(this.teaserEl.remove(),this.teaserEl=null);try{sessionStorage.setItem(this.storageTeaserKey,"1")}catch{}}bumpUnreadIfClosed(){this.isOpen||(this.unreadCount++,this.unreadBadgeEl.textContent=this.unreadCount>9?"9+":String(this.unreadCount),this.unreadBadgeEl.style.display="flex")}clearUnread(){this.unreadCount=0,this.unreadBadgeEl.style.display="none"}scrollToBottom(){requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight})}loadStoredHistory(){try{let e=localStorage.getItem(this.storageHistoryKey);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;this.storedMessages=t.slice(-N);for(let s of this.storedMessages)this.renderMessage(s)}catch{}}appendStoredMessage(e){this.storedMessages.push(e),this.storedMessages.length>N&&(this.storedMessages=this.storedMessages.slice(-N)),this.saveStoredHistory()}saveStoredHistory(){try{localStorage.setItem(this.storageHistoryKey,JSON.stringify(this.storedMessages))}catch{}}};var M=null;function W(u){return M&&(M.destroy(),M=null),M=new T(u),M}function te(u){let{siteId:e,apiUrl:t,position:s,greeting:i,title:r,avatarUrl:o,turnstileSiteKey:a,zIndex:n,hideTeaser:d}=u;return q(()=>{if(typeof window>"u")return;let l=W({siteId:e,apiUrl:t,position:s,greeting:i,title:r,avatarUrl:o,turnstileSiteKey:a,zIndex:n,hideTeaser:d});return()=>{l.destroy()}},[e,t,s,i,r,o,a,n,d]),null}export{te as SeekhiWaveWidget};