vpschatbotwidget 1.0.0 → 1.0.2

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.
Files changed (75) hide show
  1. package/README.md +385 -47
  2. package/dist-lib/types/App.d.ts +2 -0
  3. package/dist-lib/types/chatbot/api/chatbot-api.d.ts +25 -0
  4. package/dist-lib/types/chatbot/api/chatbot-types.d.ts +125 -0
  5. package/dist-lib/types/chatbot/chatbot.test.d.ts +1 -0
  6. package/dist-lib/types/chatbot/config/colors.d.ts +165 -0
  7. package/dist-lib/types/chatbot/config/suggestions.d.ts +3 -0
  8. package/dist-lib/types/chatbot/core/ChatContext.d.ts +28 -0
  9. package/dist-lib/types/chatbot/core/ChatEmptyState.d.ts +2 -0
  10. package/dist-lib/types/chatbot/core/ChatError.d.ts +7 -0
  11. package/dist-lib/types/chatbot/core/ChatHeader.d.ts +22 -0
  12. package/dist-lib/types/chatbot/core/ChatInput.d.ts +8 -0
  13. package/dist-lib/types/chatbot/core/ChatMarkdown.d.ts +4 -0
  14. package/dist-lib/types/chatbot/core/ChatMessage.d.ts +7 -0
  15. package/dist-lib/types/chatbot/core/ChatMessageList.d.ts +2 -0
  16. package/dist-lib/types/chatbot/core/ChatPanel.d.ts +14 -0
  17. package/dist-lib/types/chatbot/core/ChatProvider.d.ts +19 -0
  18. package/dist-lib/types/chatbot/core/ChatSuggestions.d.ts +11 -0
  19. package/dist-lib/types/chatbot/core/ChatTicketConfirmation.d.ts +2 -0
  20. package/dist-lib/types/chatbot/core/ChatTypingIndicator.d.ts +4 -0
  21. package/dist-lib/types/chatbot/core/ticket-intent.d.ts +2 -0
  22. package/dist-lib/types/chatbot/embedded/EmbeddedChatbot.d.ts +27 -0
  23. package/dist-lib/types/chatbot/embedded/EmbeddedChatbotPanel.d.ts +12 -0
  24. package/dist-lib/types/chatbot/embedded/EmbeddedChatbotTrigger.d.ts +6 -0
  25. package/dist-lib/types/chatbot/hooks/useChatbot.d.ts +1 -0
  26. package/dist-lib/types/chatbot/index.d.ts +10 -0
  27. package/dist-lib/types/chatbot/widget/ChatbotWidget.d.ts +26 -0
  28. package/dist-lib/types/chatbot/widget/ChatbotWidgetPanel.d.ts +10 -0
  29. package/dist-lib/types/chatbot/widget/ChatbotWidgetTrigger.d.ts +7 -0
  30. package/dist-lib/types/components/AgentSummaryCard.d.ts +8 -0
  31. package/dist-lib/types/components/ChatHeader.d.ts +20 -0
  32. package/dist-lib/types/components/ChatInput.d.ts +9 -0
  33. package/dist-lib/types/components/ChatWidget.d.ts +14 -0
  34. package/dist-lib/types/components/ConnectingStatus.d.ts +6 -0
  35. package/dist-lib/types/components/EnvBadge.d.ts +31 -0
  36. package/dist-lib/types/components/FeedbackRatingCard.d.ts +7 -0
  37. package/dist-lib/types/components/MessageItem.d.ts +12 -0
  38. package/dist-lib/types/components/MessageList.d.ts +21 -0
  39. package/dist-lib/types/components/OrderTrackingCard.d.ts +13 -0
  40. package/dist-lib/types/components/QuickPrompts.d.ts +11 -0
  41. package/dist-lib/types/components/ResponseIconMapper.d.ts +26 -0
  42. package/dist-lib/types/components/SourceCitations.d.ts +7 -0
  43. package/dist-lib/types/components/ToolCallBadge.d.ts +7 -0
  44. package/dist-lib/types/components/TypingProgressBar.d.ts +21 -0
  45. package/dist-lib/types/components/ui/message-scroller.d.ts +9 -0
  46. package/dist-lib/types/lib/cn.d.ts +1 -0
  47. package/dist-lib/types/lib/gibberishDetector.d.ts +26 -0
  48. package/dist-lib/types/lib/textHighlighter.d.ts +15 -0
  49. package/dist-lib/types/main.d.ts +1 -0
  50. package/dist-lib/types/services/api.d.ts +12 -0
  51. package/dist-lib/types/test/message-scroller-stub.d.ts +36 -0
  52. package/dist-lib/types/test/setup.d.ts +1 -0
  53. package/dist-lib/types/types/chat.d.ts +59 -0
  54. package/dist-lib/vps-chatbot.cjs +101 -0
  55. package/dist-lib/vps-chatbot.js +2179 -0
  56. package/package.json +30 -3
  57. package/src/chatbot/chatbot.test.tsx +87 -0
  58. package/src/chatbot/core/ChatContext.tsx +6 -0
  59. package/src/chatbot/core/ChatProvider.tsx +29 -7
  60. package/src/chatbot/embedded/EmbeddedChatbot.tsx +63 -2
  61. package/src/chatbot/index.ts +25 -5
  62. package/src/chatbot/widget/ChatbotWidget.tsx +64 -2
  63. package/Chatbot.svg +0 -1
  64. package/dist/assets/index-C0fUDi2s.css +0 -1
  65. package/dist/assets/index-foGq5_Av.js +0 -159
  66. package/dist/index.html +0 -17
  67. package/index.html +0 -16
  68. package/src/App.tsx +0 -85
  69. package/src/main.tsx +0 -10
  70. package/src/services/api.ts +0 -74
  71. package/src/test/message-scroller-stub.tsx +0 -60
  72. package/src/test/setup.ts +0 -8
  73. package/src/vite-env.d.ts +0 -14
  74. package/tsconfig.json +0 -21
  75. package/vite.config.ts +0 -28
@@ -0,0 +1,2179 @@
1
+ import { jsx as l, jsxs as C, Fragment as le } from "react/jsx-runtime";
2
+ import * as c from "react";
3
+ import Xe, { createContext as _t, useContext as Qe, useMemo as we, useState as Y, useRef as X, useCallback as Q, forwardRef as et, createElement as Ce, useEffect as ge } from "react";
4
+ const xt = {};
5
+ function te(e) {
6
+ return e != null && e.trim() !== "" ? e.trim().replace(/\/+$/, "") : String("").trim().replace(/\/+$/, "");
7
+ }
8
+ function We(e, t) {
9
+ const r = te(e);
10
+ if (!r)
11
+ return t;
12
+ if (r.endsWith("/api") && t.startsWith("/api/"))
13
+ return `${r}${t.slice(4)}`;
14
+ if (r.endsWith("/api") && t === "/health") {
15
+ const o = r.slice(0, -4);
16
+ return o ? `${o}/health` : "/health";
17
+ }
18
+ const n = t.startsWith("/") ? t : `/${t}`;
19
+ return `${r}${n}`;
20
+ }
21
+ function wt(e) {
22
+ return e && typeof e == "object" && "data" in e && e.success !== !1 ? e.data : e;
23
+ }
24
+ function Ct(e, t, r) {
25
+ var s, a, i;
26
+ const n = e, o = (s = n == null ? void 0 : n.error) == null ? void 0 : s.message;
27
+ return o && !kt(o) ? {
28
+ code: (a = n == null ? void 0 : n.error) == null ? void 0 : a.code,
29
+ message: o,
30
+ requestId: (i = n == null ? void 0 : n.error) == null ? void 0 : i.request_id
31
+ } : r >= 500 ? { message: "I couldn't process that request right now." } : r === 0 ? { message: "Something went wrong while connecting. Please try again." } : { message: t };
32
+ }
33
+ function kt(e) {
34
+ return /traceback|sql|exception|stack|api[_ ]?key|password/i.test(e);
35
+ }
36
+ function St(e) {
37
+ return {
38
+ chunkId: e.chunk_id,
39
+ source: e.source,
40
+ score: e.score
41
+ };
42
+ }
43
+ function Ft(e) {
44
+ return {
45
+ toolName: e.tool_name,
46
+ arguments: e.arguments ?? {},
47
+ result: e.result ?? {}
48
+ };
49
+ }
50
+ function Et(e) {
51
+ return {
52
+ model: e.model,
53
+ promptTokens: e.prompt_tokens,
54
+ completionTokens: e.completion_tokens,
55
+ totalTokens: e.total_tokens
56
+ };
57
+ }
58
+ function Tt(e) {
59
+ const t = e.role === "user" || e.role === "system" ? e.role : "assistant";
60
+ return {
61
+ id: String(e.id),
62
+ role: t,
63
+ content: e.content,
64
+ createdAt: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
65
+ status: "complete",
66
+ usage: e.model ? {
67
+ model: e.model,
68
+ promptTokens: e.prompt_tokens || 0,
69
+ completionTokens: e.completion_tokens || 0,
70
+ totalTokens: (e.prompt_tokens || 0) + (e.completion_tokens || 0)
71
+ } : void 0
72
+ };
73
+ }
74
+ async function Rt(e) {
75
+ const t = await e.text();
76
+ if (!t) return {};
77
+ try {
78
+ return JSON.parse(t);
79
+ } catch {
80
+ return {};
81
+ }
82
+ }
83
+ function tt(e) {
84
+ const t = te(e);
85
+ async function r(n, o) {
86
+ let s;
87
+ const a = We(t, n);
88
+ try {
89
+ s = await fetch(a, {
90
+ ...o,
91
+ headers: {
92
+ "Content-Type": "application/json",
93
+ ...(o == null ? void 0 : o.headers) ?? {}
94
+ }
95
+ });
96
+ } catch {
97
+ throw { message: "Something went wrong while connecting. Please try again." };
98
+ }
99
+ if (s.status === 204)
100
+ return;
101
+ const i = await Rt(s);
102
+ if (!s.ok)
103
+ throw Ct(
104
+ i,
105
+ "I couldn't process that request right now.",
106
+ s.status
107
+ );
108
+ return wt(i);
109
+ }
110
+ return {
111
+ apiBaseUrl: t,
112
+ async createSession() {
113
+ const n = await r("/api/v1/sessions", {
114
+ method: "POST",
115
+ body: JSON.stringify({})
116
+ });
117
+ return { sessionId: n.session_id, createdAt: n.created_at };
118
+ },
119
+ async sendMessage(n, o) {
120
+ const s = await r(
121
+ `/api/v1/sessions/${n}/messages`,
122
+ {
123
+ method: "POST",
124
+ body: JSON.stringify({ message: o })
125
+ }
126
+ );
127
+ return {
128
+ requestId: s.request_id,
129
+ sessionId: s.session_id,
130
+ answer: s.answer,
131
+ sources: (s.sources || []).map(St),
132
+ toolCalls: (s.tool_calls || []).map(Ft),
133
+ usage: Et(s.usage)
134
+ };
135
+ },
136
+ async getHistory(n) {
137
+ try {
138
+ return ((await r(
139
+ `/api/v1/sessions/${n}/messages`
140
+ )).messages || []).map(Tt);
141
+ } catch {
142
+ return [];
143
+ }
144
+ },
145
+ async closeSession(n) {
146
+ try {
147
+ await r(`/api/v1/sessions/${n}`, { method: "DELETE" });
148
+ } catch {
149
+ }
150
+ },
151
+ async createTicket() {
152
+ throw new Error("Ticket creation has been removed.");
153
+ },
154
+ async checkHealth() {
155
+ try {
156
+ const n = We(t, "/health");
157
+ return (await fetch(n)).ok;
158
+ } catch {
159
+ return !1;
160
+ }
161
+ }
162
+ };
163
+ }
164
+ const pn = tt(), At = [
165
+ {
166
+ label: "How do I access my reports?",
167
+ query: "How do I access my reports in the VPS Customer Portal?"
168
+ },
169
+ {
170
+ label: "Where can I find sample status?",
171
+ query: "Where can I find my sample status?"
172
+ },
173
+ {
174
+ label: "How do I pre-register a sample?",
175
+ query: "How do I pre-register a sample in the portal?"
176
+ },
177
+ {
178
+ label: "How do I contact VPS Support?",
179
+ query: "How can I contact VPS Customer Support?"
180
+ }
181
+ ], Fe = _t(null);
182
+ function Bt() {
183
+ const e = Qe(Fe);
184
+ if (!e)
185
+ throw new Error("useChatbot must be used inside ChatProvider.");
186
+ return e;
187
+ }
188
+ function rt() {
189
+ return Qe(Fe);
190
+ }
191
+ function je(e) {
192
+ return `${e}-${crypto.randomUUID()}`;
193
+ }
194
+ function Dt(e) {
195
+ if (e && typeof e == "object" && "message" in e) {
196
+ const t = String(e.message);
197
+ if (t && !/traceback|sql|exception|stack|api[_ ]?key|password/i.test(t))
198
+ return t;
199
+ }
200
+ return "I couldn't process that request right now.";
201
+ }
202
+ const nt = ({
203
+ children: e,
204
+ userContext: t = {},
205
+ suggestions: r = At,
206
+ disableSuggestions: n = !1,
207
+ initialMessage: o,
208
+ apiBaseUrl: s,
209
+ apiUrl: a,
210
+ proxyUrl: i,
211
+ api: d
212
+ }) => {
213
+ const p = s ?? a ?? i, m = we(
214
+ () => d ?? tt(p),
215
+ [d, p]
216
+ ), [y, f] = Y(null), [u, g] = Y([]), [E, v] = Y("idle"), [B, W] = Y(null), L = X(null), $ = X(!1), N = Q(async () => {
217
+ if (y) return y;
218
+ v("connecting");
219
+ const _ = await m.createSession();
220
+ return f(_.sessionId), _.sessionId;
221
+ }, [y, m]), M = Q(
222
+ async (_) => {
223
+ L.current = _;
224
+ const k = {
225
+ id: je("user"),
226
+ role: "user",
227
+ content: _,
228
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
229
+ status: "complete"
230
+ }, S = je("asst"), A = {
231
+ id: S,
232
+ role: "assistant",
233
+ content: "",
234
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
235
+ status: "pending"
236
+ };
237
+ g((R) => [...R, k, A]), v("awaiting"), W(null);
238
+ try {
239
+ const R = await N(), F = await m.sendMessage(R, _);
240
+ g(
241
+ (j) => j.map(
242
+ (H) => H.id === S ? {
243
+ ...H,
244
+ id: F.requestId || S,
245
+ content: F.answer,
246
+ status: "complete",
247
+ sources: F.sources,
248
+ toolCalls: F.toolCalls,
249
+ usage: F.usage
250
+ } : H
251
+ )
252
+ ), v("idle");
253
+ } catch (R) {
254
+ const F = Dt(R);
255
+ g(
256
+ (j) => j.map(
257
+ (H) => H.id === S ? { ...H, content: F, status: "error" } : H
258
+ )
259
+ ), W(F), v("error");
260
+ }
261
+ },
262
+ [N, m]
263
+ ), T = Q(
264
+ async (_) => {
265
+ const k = _.trim();
266
+ !k || E === "awaiting" || E === "connecting" || await M(k);
267
+ },
268
+ [M, E]
269
+ ), z = Q(async () => {
270
+ const _ = L.current;
271
+ _ && (g((k) => k.filter((S) => S.status !== "error")), await M(_));
272
+ }, [M]), I = Q(async () => {
273
+ }, []), J = Q(() => {
274
+ }, []), U = Q(async () => {
275
+ y && await m.closeSession(y), f(null), g([]), v("idle"), W(null), L.current = null;
276
+ }, [y, m]);
277
+ Xe.useEffect(() => {
278
+ !o || $.current || ($.current = !0, T(o));
279
+ }, [o, T]);
280
+ const b = we(
281
+ () => ({
282
+ messages: u,
283
+ status: E,
284
+ error: B,
285
+ sessionId: y,
286
+ pendingTicket: null,
287
+ ticketBusy: !1,
288
+ lastTicket: null,
289
+ suggestions: r,
290
+ showSuggestions: !n && u.length === 0,
291
+ suggestionBadgesEnabled: !n,
292
+ userContext: t,
293
+ apiBaseUrl: m.apiBaseUrl,
294
+ sendMessage: T,
295
+ retryLast: z,
296
+ confirmTicket: I,
297
+ cancelTicket: J,
298
+ resetConversation: U
299
+ }),
300
+ [
301
+ u,
302
+ E,
303
+ B,
304
+ y,
305
+ r,
306
+ n,
307
+ t,
308
+ m.apiBaseUrl,
309
+ T,
310
+ z,
311
+ I,
312
+ J,
313
+ U
314
+ ]
315
+ );
316
+ return /* @__PURE__ */ l(Fe.Provider, { value: b, children: e });
317
+ };
318
+ function ye() {
319
+ return Bt();
320
+ }
321
+ const Mt = ({ message: e, onRetry: t }) => /* @__PURE__ */ C(
322
+ "div",
323
+ {
324
+ className: "mx-4 mb-2 rounded-lg border border-[var(--error-border)] bg-[var(--error-bg)] px-3 py-2 text-[12.5px] text-[var(--error-text)]",
325
+ role: "alert",
326
+ children: [
327
+ /* @__PURE__ */ l("p", { children: e }),
328
+ t && /* @__PURE__ */ l(
329
+ "button",
330
+ {
331
+ type: "button",
332
+ onClick: t,
333
+ className: "mt-1.5 text-[12px] font-semibold underline underline-offset-2",
334
+ children: "Try again"
335
+ }
336
+ )
337
+ ]
338
+ }
339
+ );
340
+ /**
341
+ * @license lucide-react v0.468.0 - ISC
342
+ *
343
+ * This source code is licensed under the ISC license.
344
+ * See the LICENSE file in the root directory of this source tree.
345
+ */
346
+ const It = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ot = (...e) => e.filter((t, r, n) => !!t && t.trim() !== "" && n.indexOf(t) === r).join(" ").trim();
347
+ /**
348
+ * @license lucide-react v0.468.0 - ISC
349
+ *
350
+ * This source code is licensed under the ISC license.
351
+ * See the LICENSE file in the root directory of this source tree.
352
+ */
353
+ var Nt = {
354
+ xmlns: "http://www.w3.org/2000/svg",
355
+ width: 24,
356
+ height: 24,
357
+ viewBox: "0 0 24 24",
358
+ fill: "none",
359
+ stroke: "currentColor",
360
+ strokeWidth: 2,
361
+ strokeLinecap: "round",
362
+ strokeLinejoin: "round"
363
+ };
364
+ /**
365
+ * @license lucide-react v0.468.0 - ISC
366
+ *
367
+ * This source code is licensed under the ISC license.
368
+ * See the LICENSE file in the root directory of this source tree.
369
+ */
370
+ const Pt = et(
371
+ ({
372
+ color: e = "currentColor",
373
+ size: t = 24,
374
+ strokeWidth: r = 2,
375
+ absoluteStrokeWidth: n,
376
+ className: o = "",
377
+ children: s,
378
+ iconNode: a,
379
+ ...i
380
+ }, d) => Ce(
381
+ "svg",
382
+ {
383
+ ref: d,
384
+ ...Nt,
385
+ width: t,
386
+ height: t,
387
+ stroke: e,
388
+ strokeWidth: n ? Number(r) * 24 / Number(t) : r,
389
+ className: ot("lucide", o),
390
+ ...i
391
+ },
392
+ [
393
+ ...a.map(([p, m]) => Ce(p, m)),
394
+ ...Array.isArray(s) ? s : [s]
395
+ ]
396
+ )
397
+ );
398
+ /**
399
+ * @license lucide-react v0.468.0 - ISC
400
+ *
401
+ * This source code is licensed under the ISC license.
402
+ * See the LICENSE file in the root directory of this source tree.
403
+ */
404
+ const O = (e, t) => {
405
+ const r = et(
406
+ ({ className: n, ...o }, s) => Ce(Pt, {
407
+ ref: s,
408
+ iconNode: t,
409
+ className: ot(`lucide-${It(e)}`, n),
410
+ ...o
411
+ })
412
+ );
413
+ return r.displayName = `${e}`, r;
414
+ };
415
+ /**
416
+ * @license lucide-react v0.468.0 - ISC
417
+ *
418
+ * This source code is licensed under the ISC license.
419
+ * See the LICENSE file in the root directory of this source tree.
420
+ */
421
+ const Lt = O("ArrowDown", [
422
+ ["path", { d: "M12 5v14", key: "s699le" }],
423
+ ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
424
+ ]);
425
+ /**
426
+ * @license lucide-react v0.468.0 - ISC
427
+ *
428
+ * This source code is licensed under the ISC license.
429
+ * See the LICENSE file in the root directory of this source tree.
430
+ */
431
+ const zt = O("ArrowLeft", [
432
+ ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
433
+ ["path", { d: "M19 12H5", key: "x3x0zl" }]
434
+ ]);
435
+ /**
436
+ * @license lucide-react v0.468.0 - ISC
437
+ *
438
+ * This source code is licensed under the ISC license.
439
+ * See the LICENSE file in the root directory of this source tree.
440
+ */
441
+ const Ot = O("ArrowUp", [
442
+ ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
443
+ ["path", { d: "M12 19V5", key: "x0mq9r" }]
444
+ ]);
445
+ /**
446
+ * @license lucide-react v0.468.0 - ISC
447
+ *
448
+ * This source code is licensed under the ISC license.
449
+ * See the LICENSE file in the root directory of this source tree.
450
+ */
451
+ const st = O("BotMessageSquare", [
452
+ ["path", { d: "M12 6V2H8", key: "1155em" }],
453
+ ["path", { d: "m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z", key: "w2lp3e" }],
454
+ ["path", { d: "M2 12h2", key: "1t8f8n" }],
455
+ ["path", { d: "M9 11v2", key: "1ueba0" }],
456
+ ["path", { d: "M15 11v2", key: "i11awn" }],
457
+ ["path", { d: "M20 12h2", key: "1q8mjw" }]
458
+ ]);
459
+ /**
460
+ * @license lucide-react v0.468.0 - ISC
461
+ *
462
+ * This source code is licensed under the ISC license.
463
+ * See the LICENSE file in the root directory of this source tree.
464
+ */
465
+ const Ht = O("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
466
+ /**
467
+ * @license lucide-react v0.468.0 - ISC
468
+ *
469
+ * This source code is licensed under the ISC license.
470
+ * See the LICENSE file in the root directory of this source tree.
471
+ */
472
+ const qt = O("ChevronDown", [
473
+ ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
474
+ ]);
475
+ /**
476
+ * @license lucide-react v0.468.0 - ISC
477
+ *
478
+ * This source code is licensed under the ISC license.
479
+ * See the LICENSE file in the root directory of this source tree.
480
+ */
481
+ const Gt = O("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
482
+ /**
483
+ * @license lucide-react v0.468.0 - ISC
484
+ *
485
+ * This source code is licensed under the ISC license.
486
+ * See the LICENSE file in the root directory of this source tree.
487
+ */
488
+ const Vt = O("ClipboardCheck", [
489
+ ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
490
+ [
491
+ "path",
492
+ {
493
+ d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",
494
+ key: "116196"
495
+ }
496
+ ],
497
+ ["path", { d: "m9 14 2 2 4-4", key: "df797q" }]
498
+ ]);
499
+ /**
500
+ * @license lucide-react v0.468.0 - ISC
501
+ *
502
+ * This source code is licensed under the ISC license.
503
+ * See the LICENSE file in the root directory of this source tree.
504
+ */
505
+ const Wt = O("FileText", [
506
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
507
+ ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
508
+ ["path", { d: "M10 9H8", key: "b1mrlr" }],
509
+ ["path", { d: "M16 13H8", key: "t4e002" }],
510
+ ["path", { d: "M16 17H8", key: "z1uh3a" }]
511
+ ]);
512
+ /**
513
+ * @license lucide-react v0.468.0 - ISC
514
+ *
515
+ * This source code is licensed under the ISC license.
516
+ * See the LICENSE file in the root directory of this source tree.
517
+ */
518
+ const jt = O("FlaskConical", [
519
+ [
520
+ "path",
521
+ {
522
+ d: "M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",
523
+ key: "18mbvz"
524
+ }
525
+ ],
526
+ ["path", { d: "M6.453 15h11.094", key: "3shlmq" }],
527
+ ["path", { d: "M8.5 2h7", key: "csnxdl" }]
528
+ ]);
529
+ /**
530
+ * @license lucide-react v0.468.0 - ISC
531
+ *
532
+ * This source code is licensed under the ISC license.
533
+ * See the LICENSE file in the root directory of this source tree.
534
+ */
535
+ const lt = O("MessageSquare", [
536
+ ["path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z", key: "1lielz" }]
537
+ ]);
538
+ /**
539
+ * @license lucide-react v0.468.0 - ISC
540
+ *
541
+ * This source code is licensed under the ISC license.
542
+ * See the LICENSE file in the root directory of this source tree.
543
+ */
544
+ const $t = O("Microscope", [
545
+ ["path", { d: "M6 18h8", key: "1borvv" }],
546
+ ["path", { d: "M3 22h18", key: "8prr45" }],
547
+ ["path", { d: "M14 22a7 7 0 1 0 0-14h-1", key: "1jwaiy" }],
548
+ ["path", { d: "M9 14h2", key: "197e7h" }],
549
+ ["path", { d: "M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z", key: "1bmzmy" }],
550
+ ["path", { d: "M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3", key: "1drr47" }]
551
+ ]);
552
+ /**
553
+ * @license lucide-react v0.468.0 - ISC
554
+ *
555
+ * This source code is licensed under the ISC license.
556
+ * See the LICENSE file in the root directory of this source tree.
557
+ */
558
+ const Ut = O("Minus", [["path", { d: "M5 12h14", key: "1ays0h" }]]);
559
+ /**
560
+ * @license lucide-react v0.468.0 - ISC
561
+ *
562
+ * This source code is licensed under the ISC license.
563
+ * See the LICENSE file in the root directory of this source tree.
564
+ */
565
+ const Yt = O("RefreshCw", [
566
+ ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
567
+ ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
568
+ ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
569
+ ["path", { d: "M8 16H3v5", key: "1cv678" }]
570
+ ]);
571
+ /**
572
+ * @license lucide-react v0.468.0 - ISC
573
+ *
574
+ * This source code is licensed under the ISC license.
575
+ * See the LICENSE file in the root directory of this source tree.
576
+ */
577
+ const Zt = O("TestTubeDiagonal", [
578
+ [
579
+ "path",
580
+ { d: "M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3", key: "1ub6xw" }
581
+ ],
582
+ ["path", { d: "m16 2 6 6", key: "1gw87d" }],
583
+ ["path", { d: "M12 16H4", key: "1cjfip" }]
584
+ ]);
585
+ /**
586
+ * @license lucide-react v0.468.0 - ISC
587
+ *
588
+ * This source code is licensed under the ISC license.
589
+ * See the LICENSE file in the root directory of this source tree.
590
+ */
591
+ const Jt = O("X", [
592
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
593
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
594
+ ]), Kt = {
595
+ alpha: {
596
+ label: "Alpha",
597
+ Icon: jt,
598
+ variant: "env-badge--alpha",
599
+ tooltip: "Alpha build — internal testing only"
600
+ },
601
+ beta: {
602
+ label: "Beta",
603
+ Icon: Zt,
604
+ variant: "env-badge--beta",
605
+ tooltip: "Beta build — public pre-release"
606
+ },
607
+ gamma: {
608
+ label: "Gamma",
609
+ Icon: $t,
610
+ variant: "env-badge--gamma",
611
+ tooltip: "Gamma / Release Candidate"
612
+ },
613
+ qa: {
614
+ label: "QA",
615
+ Icon: Vt,
616
+ variant: "env-badge--qa",
617
+ tooltip: "Quality Assurance build"
618
+ }
619
+ }, Xt = ({
620
+ stage: e,
621
+ pulse: t = !0,
622
+ className: r = ""
623
+ }) => {
624
+ if (!e) return null;
625
+ const { label: n, Icon: o, variant: s, tooltip: a } = Kt[e];
626
+ return /* @__PURE__ */ C(
627
+ "span",
628
+ {
629
+ className: `env-badge ${s} ${r} text-[var(--vps-orange)] font-medium text-[10px] leading-[12px] px-1.5 py-0.5 rounded-full border border-[var(--border)] bg-[var(--orange-50)] hover:bg-[var(--grey-200)] cursor-pointer hover:text-foreground flex items-center gap-1 `,
630
+ title: a,
631
+ "aria-label": `${n} build`,
632
+ role: "status",
633
+ children: [
634
+ /* @__PURE__ */ l(o, { size: 10, className: "env-badge-icon", "aria-hidden": "true" }),
635
+ /* @__PURE__ */ l("span", { className: "text-[var(--text-primary)] font-medium text-[10px] leading-[12px]", children: n })
636
+ ]
637
+ }
638
+ );
639
+ }, Qt = (e) => /* @__PURE__ */ l(
640
+ "svg",
641
+ {
642
+ width: e.width || "24px",
643
+ height: e.height || "24px",
644
+ viewBox: "0 0 24 24",
645
+ role: "img",
646
+ xmlns: "http://www.w3.org/2000/svg",
647
+ fill: e.Color || "currentColor",
648
+ ...e,
649
+ children: /* @__PURE__ */ l("path", { d: "M11.999 0c-2.25 0-4.5.06-6.6.21a5.57 5.57 0 0 0-5.19 5.1c-.24 3.21-.27 6.39-.06 9.6a5.644 5.644 0 0 0 5.7 5.19h3.15v-3.9h-3.15c-.93.03-1.74-.63-1.83-1.56-.18-3-.15-6 .06-9 .06-.84.72-1.47 1.56-1.53 2.04-.15 4.2-.21 6.36-.21s4.32.09 6.36.18c.81.06 1.5.69 1.56 1.53.24 3 .24 6 .06 9-.12.93-.9 1.62-1.83 1.59h-3.15l-6 3.9V24l6-3.9h3.15c2.97.03 5.46-2.25 5.7-5.19.21-3.18.18-6.39-.03-9.57a5.57 5.57 0 0 0-5.19-5.1c-2.13-.18-4.38-.24-6.63-.24zm-5.04 8.76c-.36 0-.66.3-.66.66v2.34c0 .33.18.63.48.78 1.62.78 3.42 1.2 5.22 1.26 1.8-.06 3.6-.48 5.22-1.26.3-.15.48-.45.48-.78V9.42c0-.09-.03-.15-.09-.21a.648.648 0 0 0-.87-.36c-1.5.66-3.12 1.02-4.77 1.05-1.65-.03-3.27-.42-4.77-1.08a.566.566 0 0 0-.24-.06z" })
650
+ }
651
+ ), er = ({
652
+ title: e = "VPS AI Assistant",
653
+ subtitle: t = "Customer portal support",
654
+ onClose: r,
655
+ onReset: n,
656
+ onBack: o,
657
+ showMinimize: s = !1,
658
+ envStage: a,
659
+ envPulse: i = !0
660
+ }) => /* @__PURE__ */ C("header", { className: "flex items-center justify-between border-b border-border bg-card px-5 py-4", children: [
661
+ /* @__PURE__ */ C("div", { className: "flex items-center gap-3", children: [
662
+ o && /* @__PURE__ */ l(
663
+ "button",
664
+ {
665
+ type: "button",
666
+ onClick: o,
667
+ className: "flex h-8 w-8 items-center justify-center rounded-full border border-border bg-muted text-muted-foreground hover:bg-[var(--grey-100)]",
668
+ "aria-label": "Back",
669
+ children: /* @__PURE__ */ l(zt, { size: 16 })
670
+ }
671
+ ),
672
+ /* @__PURE__ */ l(
673
+ "div",
674
+ {
675
+ className: "flex h-8 w-8 items-center justify-center rounded-full bg-primary text-primary-foreground",
676
+ "aria-hidden": "true",
677
+ children: /* @__PURE__ */ l(Qt, { width: "16px", height: "16px", Color: "white" })
678
+ }
679
+ ),
680
+ /* @__PURE__ */ C("div", { children: [
681
+ /* @__PURE__ */ C("div", { className: "flex items-center gap-1.5", children: [
682
+ /* @__PURE__ */ l("h2", { className: "text-[16px] font-bold tracking-tight text-foreground", children: e }),
683
+ /* @__PURE__ */ l(Xt, { stage: a, pulse: i })
684
+ ] }),
685
+ /* @__PURE__ */ l("p", { className: "text-[12px] text-muted-foreground font-medium text-[var(--text-subtle)]", children: t || "Customer portal support" })
686
+ ] })
687
+ ] }),
688
+ /* @__PURE__ */ C("div", { className: "flex items-center gap-1", children: [
689
+ n && /* @__PURE__ */ l(
690
+ "button",
691
+ {
692
+ type: "button",
693
+ onClick: n,
694
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-subtle)] hover:bg-muted hover:text-foreground",
695
+ "aria-label": "Start a new conversation",
696
+ title: "New conversation",
697
+ children: /* @__PURE__ */ l(Yt, { size: 15 })
698
+ }
699
+ ),
700
+ r && /* @__PURE__ */ l(
701
+ "button",
702
+ {
703
+ type: "button",
704
+ onClick: r,
705
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-subtle)] hover:bg-muted hover:text-foreground",
706
+ "aria-label": s ? "Minimize chat" : "Close chat",
707
+ children: /* @__PURE__ */ l(Ut, { size: 16 })
708
+ }
709
+ )
710
+ ] })
711
+ ] });
712
+ function tr(e, t) {
713
+ const r = X(e);
714
+ ge(() => {
715
+ var n;
716
+ r.current && !e && ((n = t.current) == null || n.focus()), r.current = e;
717
+ }, [e, t]);
718
+ }
719
+ function at(e) {
720
+ var t, r, n = "";
721
+ if (typeof e == "string" || typeof e == "number") n += e;
722
+ else if (typeof e == "object") if (Array.isArray(e)) {
723
+ var o = e.length;
724
+ for (t = 0; t < o; t++) e[t] && (r = at(e[t])) && (n && (n += " "), n += r);
725
+ } else for (r in e) e[r] && (n && (n += " "), n += r);
726
+ return n;
727
+ }
728
+ function rr() {
729
+ for (var e, t, r = 0, n = "", o = arguments.length; r < o; r++) (e = arguments[r]) && (t = at(e)) && (n && (n += " "), n += t);
730
+ return n;
731
+ }
732
+ function V(...e) {
733
+ return rr(e);
734
+ }
735
+ function nr(e, t) {
736
+ const r = t.trim().toLowerCase();
737
+ return r ? e.filter(
738
+ (n) => n.label.toLowerCase().includes(r) || n.query.toLowerCase().includes(r)
739
+ ) : e;
740
+ }
741
+ const or = ({
742
+ suggestions: e,
743
+ onSelect: t,
744
+ disabled: r,
745
+ variant: n = "list"
746
+ }) => e.length ? n === "badge" ? /* @__PURE__ */ l(
747
+ "ul",
748
+ {
749
+ className: "mb-2 flex flex-wrap gap-1.5",
750
+ "aria-label": "Suggested questions",
751
+ children: e.map((o) => /* @__PURE__ */ l("li", { className: "max-w-full", children: /* @__PURE__ */ l(
752
+ "button",
753
+ {
754
+ type: "button",
755
+ disabled: r,
756
+ onClick: () => t(o),
757
+ title: o.query,
758
+ className: V(
759
+ "max-w-full truncate rounded-full border border-border bg-card px-2.5 py-1 text-left text-[11.5px] font-semibold text-foreground",
760
+ "hover:border-primary hover:bg-[var(--tint-solus-10)] hover:text-primary",
761
+ "disabled:cursor-not-allowed disabled:opacity-50"
762
+ ),
763
+ children: o.label
764
+ }
765
+ ) }, o.query))
766
+ }
767
+ ) : /* @__PURE__ */ l("div", { className: "mt-3 flex flex-col gap-2", children: e.map((o) => /* @__PURE__ */ l(
768
+ "button",
769
+ {
770
+ type: "button",
771
+ disabled: r,
772
+ onClick: () => t(o),
773
+ className: "rounded-lg border border-border bg-card px-3.5 py-2.5 text-left text-[13px] font-semibold text-foreground shadow-[0_1px_3px_rgba(0,0,0,0.02)] transition hover:-translate-y-px hover:border-vps-light-grey hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none motion-reduce:hover:translate-y-0",
774
+ children: o.label
775
+ },
776
+ o.query
777
+ )) }) : null, sr = ({
778
+ onSend: e,
779
+ disabled: t = !1,
780
+ placeholder: r = "Ask something…"
781
+ }) => {
782
+ const { suggestions: n, showSuggestions: o, suggestionBadgesEnabled: s } = ye(), [a, i] = Y(""), d = X(null), p = (u) => {
783
+ u && (u.style.height = "auto", u.style.height = `${Math.min(u.scrollHeight, 96)}px`);
784
+ };
785
+ tr(t, d), ge(() => {
786
+ p(d.current);
787
+ }, [a]);
788
+ const m = we(() => {
789
+ if (!s || t) return [];
790
+ const u = a.trim();
791
+ return u ? nr(n, u) : o ? n : [];
792
+ }, [t, o, s, n, a]), y = (u) => {
793
+ i(u.query);
794
+ const g = d.current;
795
+ g == null || g.focus();
796
+ }, f = () => {
797
+ const u = a.trim();
798
+ !u || t || (e(u), i(""), d.current && (d.current.style.height = "auto"));
799
+ };
800
+ return /* @__PURE__ */ C("div", { className: "bg-card px-4 pb-3 pt-2", children: [
801
+ /* @__PURE__ */ l(
802
+ or,
803
+ {
804
+ variant: "badge",
805
+ suggestions: m,
806
+ onSelect: y,
807
+ disabled: t
808
+ }
809
+ ),
810
+ /* @__PURE__ */ l("label", { htmlFor: "vps-chat-input", className: "sr-only", children: "Chat message" }),
811
+ /* @__PURE__ */ C("div", { className: "flex items-end gap-2 rounded-xl bg-[var(--input-bg)] px-2.5 py-1.5", children: [
812
+ /* @__PURE__ */ l(
813
+ "textarea",
814
+ {
815
+ id: "vps-chat-input",
816
+ ref: d,
817
+ rows: 1,
818
+ value: a,
819
+ disabled: t,
820
+ placeholder: r,
821
+ onChange: (u) => {
822
+ i(u.target.value), p(u.target);
823
+ },
824
+ onKeyDown: (u) => {
825
+ u.key === "Enter" && !u.shiftKey && (u.preventDefault(), f());
826
+ },
827
+ className: "max-h-24 flex-1 resize-none bg-transparent py-1.5 text-[13.5px] text-foreground outline-none placeholder:text-[var(--text-subtle)] disabled:opacity-60"
828
+ }
829
+ ),
830
+ /* @__PURE__ */ l(
831
+ "button",
832
+ {
833
+ type: "button",
834
+ onClick: f,
835
+ disabled: t || !a.trim(),
836
+ "aria-label": "Send message",
837
+ className: "mb-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-action text-action-foreground hover:bg-[var(--action-hover)] disabled:cursor-not-allowed disabled:opacity-40",
838
+ children: /* @__PURE__ */ l(Ot, { size: 16 })
839
+ }
840
+ )
841
+ ] }),
842
+ /* @__PURE__ */ C("p", { className: "mt-2 text-center text-[11px] font-medium text-[var(--text-subtle)]", children: [
843
+ "Powered by ",
844
+ /* @__PURE__ */ l("span", { className: "text-primary font-bold hover:underline cursor-pointer", children: "VPS Veritas AI" })
845
+ ] })
846
+ ] });
847
+ };
848
+ function lr({ defaultTagName: e, props: t, render: r, state: n = {}, stateAttributesMapping: o }) {
849
+ let s = ke(ar(n, o), t);
850
+ if (!r) return c.createElement(e, s);
851
+ if (typeof r == "function") return r(s, n);
852
+ if (!c.isValidElement(r)) return null;
853
+ let a = r.props, i = { ...ke(s, a), ref: ae(s.ref, a.ref) };
854
+ return c.cloneElement(r, i);
855
+ }
856
+ function ke(...e) {
857
+ let t = {};
858
+ for (let r of e) {
859
+ if (!r) continue;
860
+ let n = r;
861
+ for (let o of Object.keys(n)) {
862
+ let s = n[o];
863
+ if (s === void 0) continue;
864
+ let a = t[o];
865
+ o === "className" ? t[o] = [a, s].filter(Boolean).join(" ") : o === "style" ? t[o] = { ...a, ...s } : o === "ref" ? t[o] = ae(a, s) : cr(o) && typeof a == "function" && typeof s == "function" ? t[o] = ir(s, a) : t[o] = s;
866
+ }
867
+ }
868
+ return t;
869
+ }
870
+ function ar(e, t) {
871
+ var n;
872
+ let r = {};
873
+ for (let o of Object.keys(e)) {
874
+ let s = e[o], a = (n = t == null ? void 0 : t[o]) == null ? void 0 : n.call(t, s);
875
+ if (a) {
876
+ Object.assign(r, a);
877
+ continue;
878
+ }
879
+ if (o === "slot") {
880
+ r["data-slot"] = s;
881
+ continue;
882
+ }
883
+ let i = `data-${String(o).replace(/[A-Z]/g, (d) => `-${d.toLowerCase()}`)}`;
884
+ typeof s == "boolean" ? r[i] = s ? "" : void 0 : s != null && (r[i] = String(s));
885
+ }
886
+ return r;
887
+ }
888
+ function ir(e, t) {
889
+ return function(r) {
890
+ e(r), r.defaultPrevented || t(r);
891
+ };
892
+ }
893
+ function cr(e) {
894
+ return /^on[A-Z]/.test(e);
895
+ }
896
+ function ae(...e) {
897
+ let t = e.filter(Boolean);
898
+ if (t.length !== 0) return (r) => {
899
+ for (let n of t) typeof n == "function" ? n(r) : n && (n.current = r);
900
+ };
901
+ }
902
+ var ur = 8, dr = 64, fr = 0, be = 0.5, pr = 180, hr = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "End", "Home", "PageDown", "PageUp", " "]), it = { start: !1, end: !1 }, mr = [], ve = { currentAnchorId: null, visibleMessageIds: mr };
903
+ function gr({ content: e, scrollEdgeThreshold: t, spacer: r, viewport: n }) {
904
+ if (!n || !e) return it;
905
+ let o = Ee({ content: e, spacer: r, viewport: n });
906
+ return { start: n.scrollTop > t, end: o - n.scrollTop - n.clientHeight > t };
907
+ }
908
+ function br({ content: e, scrollMargin: t, scrollPreviousItemPeek: r, spacer: n, viewport: o, visibleMessageIds: s }) {
909
+ if (!e || !o) return ve;
910
+ let a = o.getBoundingClientRect(), i = a.top + t + r, d = typeof IntersectionObserver > "u", p = [], m = null;
911
+ for (let y of se(e, n)) {
912
+ let f = y.dataset.messageId;
913
+ if (!f) continue;
914
+ let u = y.dataset.scrollAnchor === "true", g = u || d ? y.getBoundingClientRect() : null;
915
+ (d && g ? g.bottom > i && g.top < a.bottom : s.has(f)) && p.push(f), u && g && g.top <= i + be && (m = f);
916
+ }
917
+ return p.length === 0 && m === null ? ve : { currentAnchorId: m, visibleMessageIds: p };
918
+ }
919
+ function se(e, t) {
920
+ return Array.from(e.children).filter((r) => r instanceof HTMLElement && r !== t);
921
+ }
922
+ function vr(e, t) {
923
+ for (let r = t; r < e.length; r++) {
924
+ let n = e[r];
925
+ if ((n == null ? void 0 : n.dataset.scrollAnchor) === "true") return n;
926
+ }
927
+ return null;
928
+ }
929
+ function yr(e, t) {
930
+ for (let r of e) if (r.dataset.scrollAnchor === "true" && !t.has(r)) return r;
931
+ return null;
932
+ }
933
+ function _r(e, t) {
934
+ var n;
935
+ let r = 0;
936
+ for (let o = t; o < e.length; o++) if (((n = e[o]) == null ? void 0 : n.dataset.scrollAnchor) === "true" && (r += 1, r > 1)) return !0;
937
+ return !1;
938
+ }
939
+ function xr(e) {
940
+ for (let t = e.length - 1; t >= 0; t--) {
941
+ let r = e[t];
942
+ if ((r == null ? void 0 : r.dataset.scrollAnchor) === "true") return r;
943
+ }
944
+ return null;
945
+ }
946
+ function wr({ content: e, spacer: t, viewport: r }) {
947
+ let n = r.getBoundingClientRect();
948
+ for (let o of se(e, t)) {
949
+ if (!o.dataset.messageId) continue;
950
+ let s = o.getBoundingClientRect();
951
+ if (s.bottom > n.top && s.top < n.bottom) return o;
952
+ }
953
+ return null;
954
+ }
955
+ function Cr({ align: e, element: t, scrollMargin: r, spacer: n, viewport: o }) {
956
+ let s = ct(t, o), a = t.getBoundingClientRect().height, i = Fr(n);
957
+ if (e === "center") {
958
+ let d = Math.max(0, o.clientHeight - i.start - i.end);
959
+ return s - i.start - (d - a) / 2 - r;
960
+ }
961
+ if (e === "end") return s - o.clientHeight + a + i.end + r;
962
+ if (e === "nearest") {
963
+ let d = s + a, p = o.scrollTop + i.start, m = o.scrollTop + o.clientHeight - i.end;
964
+ return s >= p && d <= m ? o.scrollTop : s < p ? s - i.start - r : d - o.clientHeight + i.end + r;
965
+ }
966
+ return s - i.start - r;
967
+ }
968
+ function ct(e, t) {
969
+ let r = e.getBoundingClientRect(), n = t.getBoundingClientRect();
970
+ return r.top - n.top + t.scrollTop;
971
+ }
972
+ function he(e, t) {
973
+ return e.getBoundingClientRect().top - t.getBoundingClientRect().top;
974
+ }
975
+ function kr({ content: e, scrollTop: t, spacer: r, viewport: n }) {
976
+ let o = Ee({ content: e, spacer: r, viewport: n });
977
+ return t + n.clientHeight - o;
978
+ }
979
+ function Ee({ content: e, spacer: t, viewport: r }) {
980
+ let n = se(e, t), o = ut(e), s = r.getBoundingClientRect(), a = r.scrollTop, i = o.start + o.end;
981
+ for (let d of n) {
982
+ let p = d.getBoundingClientRect();
983
+ i = Math.max(i, p.bottom - s.top + a + o.end);
984
+ }
985
+ return i;
986
+ }
987
+ function Sr(e) {
988
+ return Math.max(0, e.scrollHeight - e.clientHeight);
989
+ }
990
+ function ut(e) {
991
+ let t = window.getComputedStyle(e);
992
+ return { end: Se(t.paddingBlockEnd || t.paddingBottom), start: Se(t.paddingBlockStart || t.paddingTop) };
993
+ }
994
+ function Fr(e) {
995
+ let t = e == null ? void 0 : e.parentElement;
996
+ return t ? ut(t) : { end: 0, start: 0 };
997
+ }
998
+ function Er(e) {
999
+ if (!e) return 0;
1000
+ let t = window.getComputedStyle(e), r = t.rowGap === "normal" ? t.gap : t.rowGap;
1001
+ return Se(r);
1002
+ }
1003
+ function Se(e) {
1004
+ if (!e) return 0;
1005
+ let t = Number.parseFloat(e);
1006
+ return Number.isFinite(t) ? t : 0;
1007
+ }
1008
+ function dt(e, t) {
1009
+ let r = e, n = /* @__PURE__ */ new Set();
1010
+ return { getSnapshot: () => r, hasListeners: () => n.size > 0, setSnapshot: (o) => {
1011
+ t(r, o) || (r = o, n.forEach((s) => s()));
1012
+ }, subscribe: (o, s, a) => {
1013
+ let i = n.size === 0;
1014
+ return n.add(o), i && (s == null || s()), () => {
1015
+ n.delete(o), n.size === 0 && (a == null || a());
1016
+ };
1017
+ } };
1018
+ }
1019
+ function $e(e, t) {
1020
+ return dt(e, t);
1021
+ }
1022
+ function Tr() {
1023
+ return dt(ve, Ar);
1024
+ }
1025
+ function Rr(e, t) {
1026
+ return e.start === t.start && e.end === t.end;
1027
+ }
1028
+ function Ar(e, t) {
1029
+ return e.currentAnchorId !== t.currentAnchorId || e.visibleMessageIds.length !== t.visibleMessageIds.length ? !1 : e.visibleMessageIds.every((r, n) => r === t.visibleMessageIds[n]);
1030
+ }
1031
+ function Br({ autoScroll: e, defaultScrollPosition: t, scrollEdgeThreshold: r, scrollMargin: n, scrollPreviousItemPeek: o }) {
1032
+ let s = c.useRef(e), a = c.useRef(!1), i = c.useRef(null), d = c.useRef(!1), p = c.useRef(r), m = c.useRef(0), y = c.useRef(null), f = c.useRef(0), u = c.useRef(e ? "following-bottom" : "free-scrolling"), g = c.useRef(/* @__PURE__ */ new Map()), E = c.useRef(null), v = c.useRef(null), B = c.useRef(null), W = c.useRef(o), L = c.useRef(!0), $ = c.useRef(null), N = c.useRef(n), M = c.useRef(null), T = c.useRef(0), z = c.useRef(0), I = c.useRef(null), J = c.useRef(null), U = c.useRef(null), b = c.useRef(null), _ = c.useRef(null), k = c.useRef(null), S = c.useRef(null), A = c.useRef(null), R = c.useRef(null), F = c.useRef(/* @__PURE__ */ new Set()), j = c.useRef(/* @__PURE__ */ new WeakSet());
1033
+ return U.current === null && (U.current = $e(t === "end" || t === "last-anchor", (H, ce) => H === ce)), b.current === null && (b.current = $e(it, Rr)), R.current === null && (R.current = Tr()), s.current = e, p.current = r, N.current = n, W.current = o, { autoScrollRef: s, autoscrollingRef: a, autoscrollingTimeoutRef: _, streamingTurnRef: B, contentRef: i, defaultScrollPositionAppliedRef: d, firstItemRef: y, itemCountRef: m, lastScrollTopRef: f, messageElementsRef: g, modeRef: u, pendingScrollFrameRef: M, pendingScrollToMessageRef: E, prependRestoreRef: v, preserveScrollOnPrependRef: L, pendingDefaultScrollStore: U.current, rootRef: $, scrollEdgeThresholdRef: p, scrollMarginRef: N, scrollPreviousItemPeekRef: W, spacerGapRef: T, spacerHeightRef: z, spacerRef: I, stateFrameRef: J, stateStore: b.current, viewportRef: k, visibilityFrameRef: S, visibilityObserverRef: A, visibilityStore: R.current, visibleMessageIdsRef: F, handledScrollAnchorsRef: j };
1034
+ }
1035
+ function ft(e) {
1036
+ e.pendingDefaultScrollStore.setSnapshot(!1);
1037
+ }
1038
+ function me(e) {
1039
+ e.defaultScrollPositionAppliedRef.current = !0, ft(e);
1040
+ }
1041
+ function Dr({ refs: e, commitScrollState: t, scheduleStateCommit: r, scheduleVisibilitySync: n }) {
1042
+ let { streamingTurnRef: o, autoScrollRef: s, autoscrollingRef: a, autoscrollingTimeoutRef: i, contentRef: d, itemCountRef: p, messageElementsRef: m, modeRef: y, pendingScrollToMessageRef: f, prependRestoreRef: u, scrollMarginRef: g, scrollPreviousItemPeekRef: E, spacerGapRef: v, spacerHeightRef: B, spacerRef: W, viewportRef: L } = e, $ = c.useCallback((b) => {
1043
+ i.current !== null && (window.clearTimeout(i.current), i.current = null), a.current !== b && (a.current = b, t()), b && (i.current = window.setTimeout(() => {
1044
+ i.current = null, a.current = !1, t();
1045
+ }, pr));
1046
+ }, [t]), N = c.useCallback((b) => {
1047
+ let _ = W.current;
1048
+ if (!_) return;
1049
+ let k = Math.max(0, Math.ceil(b));
1050
+ B.current !== k && (B.current = k, _.hidden = k === 0, _.style.height = `${k}px`, _.style.marginTop = k > 0 ? `${-v.current}px` : "");
1051
+ }, []), M = c.useCallback((b, { behavior: _ = "auto", autoscrolling: k = !1 } = {}) => {
1052
+ let S = L.current;
1053
+ if (!S) return;
1054
+ let A = Math.max(0, b);
1055
+ if (Math.abs(S.scrollTop - A) <= be) {
1056
+ S.scrollTop = A, t();
1057
+ return;
1058
+ }
1059
+ k && $(!0), S.scrollTo({ top: A, behavior: _ }), r();
1060
+ }, [t, r, $]), T = c.useCallback(({ behavior: b = "auto" } = {}) => L.current ? (N(0), o.current = null, y.current = "free-scrolling", M(0, { behavior: b }), n(), !0) : !1, [n, M, N]), z = c.useCallback(({ behavior: b = "auto" } = {}) => {
1061
+ let _ = L.current;
1062
+ return _ ? (N(0), o.current = null, y.current = s.current ? "following-bottom" : "free-scrolling", M(Sr(_), { autoscrolling: !0, behavior: b }), n(), !0) : !1;
1063
+ }, [n, M, N]), I = c.useCallback((b, { align: _ = "start", behavior: k = "auto", scrollMargin: S = g.current } = {}, { keepPreviousPeek: A = !1 } = {}) => {
1064
+ let R = d.current, F = L.current;
1065
+ if (!R || !F || !R.contains(b)) return !1;
1066
+ let j = Cr({ align: _, element: b, scrollMargin: A ? S + E.current : S, spacer: W.current, viewport: F }), H = kr({ content: R, scrollTop: j, spacer: W.current, viewport: F });
1067
+ return N(H), u.current = { element: b, viewportTop: he(b, F) }, y.current = A ? "anchored-to-message" : "settling-jump", o.current = A ? b : null, M(j, { behavior: k }), n(), !0;
1068
+ }, [n, M, N]), J = c.useCallback(() => {
1069
+ let b = o.current;
1070
+ return !b || !b.isConnected || y.current !== "anchored-to-message" ? !1 : I(b, { align: "start" }, { keepPreviousPeek: !0 });
1071
+ }, [I]), U = c.useCallback((b, _) => {
1072
+ let k = m.current.get(b);
1073
+ return k ? (me(e), I(k, _) ? (f.current = null, !0) : (f.current = { messageId: b, options: _ }, !0)) : p.current === 0 ? (f.current = { messageId: b, options: _ }, me(e), !0) : !1;
1074
+ }, [I]);
1075
+ return { flushPendingScrollToMessage: c.useCallback(() => {
1076
+ let b = f.current;
1077
+ if (!b) return !1;
1078
+ let _ = m.current.get(b.messageId);
1079
+ return !_ || !I(_, b.options) ? !1 : (f.current = null, me(e), !0);
1080
+ }, [I]), reanchorToAnchoredMessage: J, scrollToElement: I, scrollToEnd: z, scrollToMessage: U, scrollToStart: T };
1081
+ }
1082
+ function Ue(e, t) {
1083
+ return c.useCallback((r) => {
1084
+ e.current = r, r && t();
1085
+ }, [e, t]);
1086
+ }
1087
+ function Mr({ autoScroll: e = !1, defaultScrollPosition: t = "end", scrollEdgeThreshold: r = ur, scrollPreviousItemPeek: n = dr, scrollMargin: o = fr }) {
1088
+ let s = Br({ autoScroll: e, defaultScrollPosition: t, scrollEdgeThreshold: r, scrollMargin: o, scrollPreviousItemPeek: n }), { streamingTurnRef: a, autoScrollRef: i, autoscrollingRef: d, autoscrollingTimeoutRef: p, contentRef: m, defaultScrollPositionAppliedRef: y, firstItemRef: f, itemCountRef: u, lastScrollTopRef: g, messageElementsRef: E, modeRef: v, pendingScrollFrameRef: B, pendingScrollToMessageRef: W, prependRestoreRef: L, preserveScrollOnPrependRef: $, pendingDefaultScrollStore: N, rootRef: M, scrollEdgeThresholdRef: T, scrollMarginRef: z, scrollPreviousItemPeekRef: I, spacerGapRef: J, spacerHeightRef: U, spacerRef: b, stateFrameRef: _, stateStore: k, viewportRef: S, visibilityFrameRef: A, visibilityObserverRef: R, visibilityStore: F, visibleMessageIdsRef: j, handledScrollAnchorsRef: H } = s, ce = c.useRef(t);
1089
+ ce.current !== t && (ce.current = t, y.current = !1);
1090
+ let ue = c.useCallback((h) => {
1091
+ let x = M.current, w = S.current, D = [h.start && "start", h.end && "end"].filter(Boolean).join(" "), K = d.current;
1092
+ for (let G of [x, w]) G && (D ? G.setAttribute("data-scrollable", D) : G.removeAttribute("data-scrollable"), G.toggleAttribute("data-autoscrolling", K));
1093
+ }, []), Te = c.useCallback((h) => {
1094
+ var D;
1095
+ let x = ((D = S.current) == null ? void 0 : D.scrollTop) ?? 0, w = x < g.current - be;
1096
+ g.current = x, i.current && !h.end && v.current !== "settling-jump" && v.current !== "anchored-to-message" ? v.current = "following-bottom" : v.current === "following-bottom" && h.end && w && !d.current && (v.current = "free-scrolling");
1097
+ }, []), Z = c.useCallback(() => {
1098
+ let h = gr({ content: m.current, scrollEdgeThreshold: T.current, spacer: b.current, viewport: S.current });
1099
+ Te(h);
1100
+ let x = v.current === "following-bottom" ? { ...h, end: !1 } : h;
1101
+ ue(x), k.setSnapshot(x);
1102
+ }, [Te, k, ue]), ne = c.useCallback(() => {
1103
+ _.current === null && (_.current = window.requestAnimationFrame(() => {
1104
+ _.current = null, Z();
1105
+ }));
1106
+ }, [Z]), P = c.useCallback(() => {
1107
+ F.hasListeners() && A.current === null && (A.current = window.requestAnimationFrame(() => {
1108
+ A.current = null, F.hasListeners() && F.setSnapshot(br({ content: m.current, scrollMargin: z.current, scrollPreviousItemPeek: I.current, spacer: b.current, viewport: S.current, visibleMessageIds: j.current }));
1109
+ }));
1110
+ }, [F]), { flushPendingScrollToMessage: de, reanchorToAnchoredMessage: Re, scrollToElement: oe, scrollToEnd: q, scrollToMessage: Ae, scrollToStart: fe } = Dr({ refs: s, commitScrollState: Z, scheduleStateCommit: ne, scheduleVisibilitySync: P }), Be = c.useCallback(() => {
1111
+ let h = L.current, x = S.current;
1112
+ if (!h || !x || !h.element.isConnected) return !1;
1113
+ let w = he(h.element, x) - h.viewportTop;
1114
+ return Math.abs(w) <= be ? !1 : (x.scrollTop += w, h.viewportTop = he(h.element, x), ne(), P(), !0);
1115
+ }, [ne, P]), ee = c.useCallback(() => {
1116
+ let h = m.current, x = S.current;
1117
+ if (!h || !x) {
1118
+ L.current = null;
1119
+ return;
1120
+ }
1121
+ let w = wr({ content: h, spacer: b.current, viewport: x });
1122
+ L.current = w ? { element: w, viewportTop: he(w, x) } : null;
1123
+ }, []), De = c.useCallback(() => {
1124
+ B.current === null && (B.current = window.requestAnimationFrame(() => {
1125
+ B.current = null, de() && ee();
1126
+ }));
1127
+ }, [ee, de]), pe = c.useCallback(() => {
1128
+ if (!t || y.current || u.current === 0) return !1;
1129
+ let h = !1;
1130
+ if (t === "last-anchor") {
1131
+ let x = m.current, w = S.current, D = x && w ? xr(se(x, b.current)) : null;
1132
+ if (!x || !w || !D) h = q({ behavior: "auto" });
1133
+ else {
1134
+ let K = ct(D, w);
1135
+ h = Ee({ content: x, spacer: b.current, viewport: w }) - K <= w.clientHeight ? q({ behavior: "auto" }) : oe(D, { align: "start" }, { keepPreviousPeek: !0 });
1136
+ }
1137
+ } else h = t === "end" ? q({ behavior: "auto" }) : fe({ behavior: "auto" });
1138
+ return h ? (me(s), !0) : !1;
1139
+ }, [t, oe, q, fe]), Me = c.useCallback(() => {
1140
+ let h = m.current;
1141
+ if (!h) return;
1142
+ let x = se(h, b.current), w = u.current, D = f.current;
1143
+ u.current = x.length, f.current = x[0] ?? null, (() => {
1144
+ if (de()) return;
1145
+ if (w === 0) {
1146
+ if (pe() || x.length > 0 && i.current && q({ behavior: "auto" })) return;
1147
+ Z(), P();
1148
+ return;
1149
+ }
1150
+ let K = D ? x.indexOf(D) : -1;
1151
+ if ($.current && K > 0) {
1152
+ Be();
1153
+ return;
1154
+ }
1155
+ if (x.length > w) {
1156
+ let G = vr(x, w);
1157
+ if (G) {
1158
+ if (i.current && v.current === "following-bottom" && _r(x, w)) {
1159
+ q({ behavior: "auto" });
1160
+ return;
1161
+ }
1162
+ oe(G, { align: "start" }, { keepPreviousPeek: !0 }), H.current.add(G);
1163
+ return;
1164
+ }
1165
+ }
1166
+ if (x.length === w) {
1167
+ let G = yr(x, H.current);
1168
+ if (G) {
1169
+ oe(G, { align: "start" }, { keepPreviousPeek: !0 }), H.current.add(G);
1170
+ return;
1171
+ }
1172
+ }
1173
+ v.current === "following-bottom" && i.current ? q({ behavior: "auto" }) : (Z(), P());
1174
+ })(), ee();
1175
+ }, [pe, ee, Z, de, Be, P, oe, q]), Ie = c.useCallback(() => {
1176
+ if (v.current === "following-bottom" && i.current) {
1177
+ q({ behavior: "auto" });
1178
+ return;
1179
+ }
1180
+ let h = U.current;
1181
+ if (Re()) {
1182
+ i.current && h > 0 && U.current === 0 && q({ behavior: "auto" });
1183
+ return;
1184
+ }
1185
+ ne(), P();
1186
+ }, [Re, ne, P, q]), Ne = c.useCallback(() => {
1187
+ let h = S.current;
1188
+ if (!(!h || !F.hasListeners())) {
1189
+ if (typeof IntersectionObserver > "u") {
1190
+ P();
1191
+ return;
1192
+ }
1193
+ R.current || (R.current = new IntersectionObserver((x) => {
1194
+ for (let w of x) {
1195
+ let D = w.target.dataset.messageId;
1196
+ D && (w.isIntersecting ? j.current.add(D) : j.current.delete(D));
1197
+ }
1198
+ P();
1199
+ }, { root: h, rootMargin: `${-(z.current + I.current)}px 0px 0px 0px`, threshold: [0, 0.01, 0.5, 1] })), E.current.forEach((x) => {
1200
+ var w;
1201
+ (w = R.current) == null || w.observe(x);
1202
+ }), P();
1203
+ }
1204
+ }, [P, F]), Pe = c.useCallback(() => {
1205
+ var h;
1206
+ A.current !== null && (window.cancelAnimationFrame(A.current), A.current = null), (h = R.current) == null || h.disconnect(), R.current = null, j.current.clear(), F.setSnapshot(ve);
1207
+ }, [F]), vt = c.useCallback((h, x, w) => {
1208
+ var D, K, G;
1209
+ if (x) {
1210
+ E.current.set(h, x), (D = R.current) == null || D.observe(x), P(), ((K = W.current) == null ? void 0 : K.messageId) === h && De();
1211
+ return;
1212
+ }
1213
+ w && E.current.get(h) === w && (E.current.delete(h), j.current.delete(h), (G = R.current) == null || G.unobserve(w), P());
1214
+ }, [De, P]), Le = c.useCallback(() => {
1215
+ (v.current === "following-bottom" || v.current === "anchored-to-message" || v.current === "settling-jump") && (a.current = null, v.current = "free-scrolling");
1216
+ }, []), ze = c.useCallback(() => ue(k.getSnapshot()), [k, ue]), Oe = Ue(M, ze), He = Ue(S, ze), qe = c.useCallback((h) => {
1217
+ m.current = h;
1218
+ }, []), Ge = c.useCallback((h) => {
1219
+ b.current = h, J.current = Er((h == null ? void 0 : h.parentElement) ?? null);
1220
+ }, []), Ve = c.useCallback(() => {
1221
+ Z(), P(), ee();
1222
+ }, [ee, Z, P]), yt = c.useMemo(() => ({ handleContentChange: Me, handleResize: Ie, observeVisibility: Ne, pendingDefaultScrollStore: N, preserveScrollOnPrependRef: $, scrollToEnd: q, scrollToMessage: Ae, scrollToStart: fe, setContentElement: qe, setRootElement: Oe, setSpacerElement: Ge, setViewportElement: He, stateStore: k, syncAfterScroll: Ve, unobserveVisibility: Pe, userScrollIntent: Le, viewportRef: S, visibilityStore: F }), [Me, Ie, Ne, N, q, Ae, fe, qe, Oe, Ge, He, k, Ve, Pe, Le, F]);
1223
+ return c.useLayoutEffect(() => {
1224
+ pe() || u.current === 0 && ft(s);
1225
+ }, [pe]), c.useEffect(() => () => {
1226
+ var h;
1227
+ _.current !== null && (window.cancelAnimationFrame(_.current), _.current = null), A.current !== null && (window.cancelAnimationFrame(A.current), A.current = null), p.current !== null && (window.clearTimeout(p.current), p.current = null), B.current !== null && (window.cancelAnimationFrame(B.current), B.current = null), (h = R.current) == null || h.disconnect(), R.current = null;
1228
+ }, []), c.useLayoutEffect(() => {
1229
+ if (e && v.current === "following-bottom" && u.current > 0) {
1230
+ q({ behavior: "auto" });
1231
+ return;
1232
+ }
1233
+ Z();
1234
+ }, [e, Z, q]), { context: yt, registerMessage: vt };
1235
+ }
1236
+ function Ir(e) {
1237
+ let t = c.useRef(e);
1238
+ return t.current = e, t;
1239
+ }
1240
+ var pt = c.createContext(null), ht = c.createContext(null);
1241
+ function ie() {
1242
+ let e = c.useContext(pt);
1243
+ if (!e) throw new Error("useMessageScroller must be used within a MessageScroller.");
1244
+ return e;
1245
+ }
1246
+ function Nr() {
1247
+ let e = c.useContext(ht);
1248
+ if (!e) throw new Error("MessageScrollerItem must be used within a MessageScroller.");
1249
+ return e;
1250
+ }
1251
+ function Pr({ autoScroll: e = !1, children: t, defaultScrollPosition: r = "end", scrollEdgeThreshold: n, scrollPreviousItemPeek: o, scrollMargin: s }) {
1252
+ let { context: a, registerMessage: i } = Mr({ autoScroll: e, defaultScrollPosition: r, scrollEdgeThreshold: n, scrollPreviousItemPeek: o, scrollMargin: s });
1253
+ return l(pt.Provider, { value: a, children: l(ht.Provider, { value: i, children: t }) });
1254
+ }
1255
+ function mt() {
1256
+ let { pendingDefaultScrollStore: e } = ie();
1257
+ return c.useSyncExternalStore(e.subscribe, e.getSnapshot, e.getSnapshot);
1258
+ }
1259
+ function Lr({ children: e, ...t }) {
1260
+ let { setRootElement: r } = ie(), n = mt();
1261
+ return l("div", { ref: r, ...t, ...n ? { "data-pending-scroll": "" } : null, children: e });
1262
+ }
1263
+ function zr({ "aria-label": e, children: t, onKeyDown: r, onScroll: n, onTouchMove: o, onWheel: s, preserveScrollOnPrepend: a = !0, ref: i, role: d, tabIndex: p, ...m }) {
1264
+ let { handleResize: y, preserveScrollOnPrependRef: f, setViewportElement: u, syncAfterScroll: g, userScrollIntent: E, viewportRef: v } = ie(), B = mt();
1265
+ f.current = a;
1266
+ let W = c.useCallback((T) => {
1267
+ var z;
1268
+ u(T), (z = ae(i)) == null || z(T);
1269
+ }, [i, u]);
1270
+ function L(T) {
1271
+ g(), n == null || n(T);
1272
+ }
1273
+ function $(T) {
1274
+ E(), s == null || s(T);
1275
+ }
1276
+ function N(T) {
1277
+ E(), o == null || o(T);
1278
+ }
1279
+ function M(T) {
1280
+ hr.has(T.key) && E(), r == null || r(T);
1281
+ }
1282
+ return c.useEffect(() => {
1283
+ let T = v.current;
1284
+ if (!T || typeof ResizeObserver > "u") return;
1285
+ let z = 0, I = new ResizeObserver(() => {
1286
+ window.cancelAnimationFrame(z), z = window.requestAnimationFrame(y);
1287
+ });
1288
+ return I.observe(T), () => {
1289
+ window.cancelAnimationFrame(z), I.disconnect();
1290
+ };
1291
+ }, [y, v]), l("div", { ref: W, role: d ?? "region", "aria-label": e ?? "Messages", tabIndex: p ?? 0, onKeyDown: M, onScroll: L, onTouchMove: N, onWheel: $, ...m, ...B ? { "data-pending-scroll": "" } : null, children: t });
1292
+ }
1293
+ function Or({ "aria-relevant": e, children: t, ref: r, role: n, spacerClassName: o, ...s }) {
1294
+ let { handleContentChange: a, handleResize: i, setContentElement: d, setSpacerElement: p } = ie(), m = c.useRef(null), y = c.useCallback((f) => {
1295
+ var u;
1296
+ m.current = f, d(f), (u = ae(r)) == null || u(f);
1297
+ }, [r, d]);
1298
+ return c.useLayoutEffect(() => {
1299
+ let f = m.current;
1300
+ if (!f || (a(), typeof MutationObserver > "u")) return;
1301
+ let u = new MutationObserver(() => {
1302
+ a();
1303
+ });
1304
+ return u.observe(f, { childList: !0 }), () => u.disconnect();
1305
+ }, [a]), c.useEffect(() => {
1306
+ let f = m.current;
1307
+ if (!f || typeof ResizeObserver > "u") return;
1308
+ let u = 0, g = new ResizeObserver(() => {
1309
+ window.cancelAnimationFrame(u), u = window.requestAnimationFrame(i);
1310
+ });
1311
+ return g.observe(f), () => {
1312
+ window.cancelAnimationFrame(u), g.disconnect();
1313
+ };
1314
+ }, [i]), C("div", { ref: y, role: n ?? "log", "aria-relevant": e ?? "additions", ...s, children: [t, l("div", { ref: p, "aria-hidden": "true", "data-message-scroller-spacer": "", hidden: !0, className: o })] });
1315
+ }
1316
+ function Hr({ messageId: e, ref: t, scrollAnchor: r = !1, ...n }) {
1317
+ let o = Nr(), s = c.useRef(null), a = c.useCallback((i) => {
1318
+ var p;
1319
+ let d = s.current;
1320
+ s.current = i, e && o(e, i, d), (p = ae(t)) == null || p(i);
1321
+ }, [e, t, o]);
1322
+ return l("div", { ref: a, "data-message-id": e, "data-scroll-anchor": r ? "true" : "false", ...n });
1323
+ }
1324
+ function qr({ behavior: e = "smooth", children: t, direction: r = "end", onClick: n, render: o, tabIndex: s, type: a = "button", ...i }) {
1325
+ let { scrollToEnd: d, scrollToStart: p, stateStore: m } = ie(), y = Ir(n), f = c.useCallback((v) => m.subscribe(v), [m]), u = c.useCallback(() => {
1326
+ let v = m.getSnapshot();
1327
+ return r === "start" ? v.start : v.end;
1328
+ }, [r, m]), g = c.useSyncExternalStore(f, u, u), E = c.useCallback((v) => {
1329
+ var B;
1330
+ g && ((B = y.current) == null || B.call(y, v), v.defaultPrevented || (v.currentTarget.blur(), r === "start" ? p({ behavior: e }) : d({ behavior: e })));
1331
+ }, [e, r, g, y, d, p]);
1332
+ return lr({ defaultTagName: "button", props: ke({ type: a, inert: !g, tabIndex: g ? s : -1, children: t ?? C("span", { children: ["Scroll to ", r] }), onClick: E }, i), render: o, state: { active: g, direction: r }, stateAttributesMapping: { active: (v) => ({ "data-active": v ? "true" : "false" }) } });
1333
+ }
1334
+ var re = { Provider: Pr, Root: Lr, Viewport: zr, Content: Or, Item: Hr, Button: qr };
1335
+ function Gr(e) {
1336
+ return /* @__PURE__ */ l(re.Provider, { ...e });
1337
+ }
1338
+ function Vr({
1339
+ className: e,
1340
+ ...t
1341
+ }) {
1342
+ return /* @__PURE__ */ l(
1343
+ re.Root,
1344
+ {
1345
+ "data-slot": "message-scroller",
1346
+ className: V(
1347
+ "group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden",
1348
+ e
1349
+ ),
1350
+ ...t
1351
+ }
1352
+ );
1353
+ }
1354
+ function Wr({
1355
+ className: e,
1356
+ ...t
1357
+ }) {
1358
+ return /* @__PURE__ */ l(
1359
+ re.Viewport,
1360
+ {
1361
+ "data-slot": "message-scroller-viewport",
1362
+ className: V(
1363
+ "size-full min-h-0 min-w-0 overflow-y-auto overscroll-contain",
1364
+ "data-[pending-scroll]:invisible",
1365
+ e
1366
+ ),
1367
+ ...t
1368
+ }
1369
+ );
1370
+ }
1371
+ function jr({
1372
+ className: e,
1373
+ ...t
1374
+ }) {
1375
+ return /* @__PURE__ */ l(
1376
+ re.Content,
1377
+ {
1378
+ "data-slot": "message-scroller-content",
1379
+ className: V("flex h-max min-h-full flex-col gap-4 px-4 py-4", e),
1380
+ ...t
1381
+ }
1382
+ );
1383
+ }
1384
+ function Ye({
1385
+ className: e,
1386
+ scrollAnchor: t = !1,
1387
+ ...r
1388
+ }) {
1389
+ return /* @__PURE__ */ l(
1390
+ re.Item,
1391
+ {
1392
+ "data-slot": "message-scroller-item",
1393
+ scrollAnchor: t,
1394
+ className: V(
1395
+ "min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]",
1396
+ e
1397
+ ),
1398
+ ...r
1399
+ }
1400
+ );
1401
+ }
1402
+ function $r({
1403
+ direction: e = "end",
1404
+ className: t,
1405
+ children: r,
1406
+ ...n
1407
+ }) {
1408
+ return /* @__PURE__ */ l(
1409
+ re.Button,
1410
+ {
1411
+ "data-slot": "message-scroller-button",
1412
+ direction: e,
1413
+ className: V(
1414
+ "absolute left-1/2 z-10 flex h-9 w-9 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-card text-foreground shadow-md transition-[opacity,transform] duration-200",
1415
+ "hover:bg-[var(--input-bg)]",
1416
+ "data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0",
1417
+ "data-[active=true]:scale-100 data-[active=true]:opacity-100",
1418
+ "data-[direction=end]:bottom-3 data-[direction=start]:top-3",
1419
+ "motion-reduce:transition-none",
1420
+ t
1421
+ ),
1422
+ ...n,
1423
+ children: r ?? /* @__PURE__ */ C(le, { children: [
1424
+ /* @__PURE__ */ l(
1425
+ Lt,
1426
+ {
1427
+ size: 16,
1428
+ "aria-hidden": "true",
1429
+ className: e === "start" ? "rotate-180" : void 0
1430
+ }
1431
+ ),
1432
+ /* @__PURE__ */ l("span", { className: "sr-only", children: e === "end" ? "Jump to latest" : "Jump to start" })
1433
+ ] })
1434
+ }
1435
+ );
1436
+ }
1437
+ const Ur = () => /* @__PURE__ */ C("div", { className: "flex items-start gap-2.5", children: [
1438
+ /* @__PURE__ */ l(
1439
+ "div",
1440
+ {
1441
+ className: "mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground",
1442
+ "aria-hidden": "true",
1443
+ children: /* @__PURE__ */ l(st, { size: 15 })
1444
+ }
1445
+ ),
1446
+ /* @__PURE__ */ l("div", { className: "max-w-[82%] rounded-2xl rounded-tl-sm border border-border bg-[var(--bubble-assistant-bg)] px-3.5 py-2.5 text-[13.5px] leading-[1.55] text-foreground", children: /* @__PURE__ */ l("p", { children: "Hello — I am the VPS Veritas assistant. Ask about reports, sample status, registration, or support, or choose a question below the text box." }) })
1447
+ ] });
1448
+ function _e(e) {
1449
+ return e.split(/(\*\*[^*]+\*\*|`[^`]+`|https?:\/\/[^\s]+)/g).map((r, n) => r.startsWith("**") && r.endsWith("**") ? /* @__PURE__ */ l("strong", { children: r.slice(2, -2) }, n) : r.startsWith("`") && r.endsWith("`") ? /* @__PURE__ */ l(
1450
+ "code",
1451
+ {
1452
+ className: "rounded bg-[var(--input-bg)] px-1 py-0.5 font-mono text-[12px] text-foreground",
1453
+ children: r.slice(1, -1)
1454
+ },
1455
+ n
1456
+ ) : /^https?:\/\//.test(r) ? /* @__PURE__ */ l(
1457
+ "a",
1458
+ {
1459
+ href: r,
1460
+ target: "_blank",
1461
+ rel: "noopener noreferrer",
1462
+ className: "underline underline-offset-2",
1463
+ children: r
1464
+ },
1465
+ n
1466
+ ) : /* @__PURE__ */ l(Xe.Fragment, { children: r }, n));
1467
+ }
1468
+ function Yr({ text: e }) {
1469
+ if (!e) return null;
1470
+ const t = e.split(/\n\n+/);
1471
+ return /* @__PURE__ */ l(le, { children: t.map((r, n) => {
1472
+ if (r.trim().startsWith("- ") || r.trim().startsWith("* ")) {
1473
+ const o = r.split(/\n/).filter((s) => s.trim().startsWith("- ") || s.trim().startsWith("* "));
1474
+ return /* @__PURE__ */ l("ul", { className: "my-1.5 ml-4 list-disc space-y-0.5", children: o.map((s, a) => /* @__PURE__ */ l("li", { children: _e(s.replace(/^[-*]\s+/, "")) }, a)) }, n);
1475
+ }
1476
+ if (/^\d+\.\s+/.test(r.trim())) {
1477
+ const o = r.split(/\n/).filter((s) => /^\d+\.\s+/.test(s.trim()));
1478
+ return /* @__PURE__ */ l("ol", { className: "my-1.5 ml-4 list-decimal space-y-0.5", children: o.map((s, a) => /* @__PURE__ */ l("li", { children: _e(s.replace(/^\d+\.\s+/, "")) }, a)) }, n);
1479
+ }
1480
+ if (r.startsWith("```")) {
1481
+ const o = r.replace(/^```[a-zA-Z]*\n?/, "").replace(/```$/, "");
1482
+ return /* @__PURE__ */ l(
1483
+ "pre",
1484
+ {
1485
+ className: "my-2 overflow-x-auto rounded-lg bg-[var(--code-bg)] p-3 font-mono text-[12px] text-primary-foreground",
1486
+ children: /* @__PURE__ */ l("code", { children: o })
1487
+ },
1488
+ n
1489
+ );
1490
+ }
1491
+ return /* @__PURE__ */ l("p", { className: "mb-2 last:mb-0 whitespace-pre-wrap", children: _e(r) }, n);
1492
+ }) });
1493
+ }
1494
+ const Zr = ({ className: e }) => /* @__PURE__ */ C(
1495
+ "div",
1496
+ {
1497
+ className: V("flex items-center gap-1 py-0.5", e),
1498
+ role: "status",
1499
+ "aria-label": "Assistant is preparing a reply",
1500
+ children: [
1501
+ /* @__PURE__ */ l("span", { className: "h-1.5 w-1.5 rounded-full bg-[var(--text-subtle)] motion-safe:animate-pulse" }),
1502
+ /* @__PURE__ */ l("span", { className: "h-1.5 w-1.5 rounded-full bg-[var(--text-subtle)] motion-safe:animate-pulse [animation-delay:150ms]" }),
1503
+ /* @__PURE__ */ l("span", { className: "h-1.5 w-1.5 rounded-full bg-[var(--text-subtle)] motion-safe:animate-pulse [animation-delay:300ms]" })
1504
+ ]
1505
+ }
1506
+ );
1507
+ function Jr(e) {
1508
+ return e === "create_ticket" ? "Support ticket processed" : e === "get_customer" ? "Account verified" : e === "get_ticket" ? "Ticket status loaded" : "Information retrieved";
1509
+ }
1510
+ function Kr({ sources: e }) {
1511
+ const [t, r] = Y(!1);
1512
+ return e.length ? /* @__PURE__ */ C("div", { className: "mt-2 border-t border-border pt-1.5", children: [
1513
+ /* @__PURE__ */ C(
1514
+ "button",
1515
+ {
1516
+ type: "button",
1517
+ className: "inline-flex items-center gap-1.5 text-[11.5px] font-semibold text-muted-foreground hover:text-foreground",
1518
+ onClick: () => r((n) => !n),
1519
+ "aria-expanded": t,
1520
+ children: [
1521
+ /* @__PURE__ */ l(Wt, { size: 12, "aria-hidden": "true" }),
1522
+ e.length,
1523
+ " grounded source",
1524
+ e.length > 1 ? "s" : "",
1525
+ t ? /* @__PURE__ */ l(Gt, { size: 12 }) : /* @__PURE__ */ l(qt, { size: 12 })
1526
+ ]
1527
+ }
1528
+ ),
1529
+ t && /* @__PURE__ */ l("ul", { className: "mt-1.5 space-y-1", children: e.map((n) => /* @__PURE__ */ C(
1530
+ "li",
1531
+ {
1532
+ className: "flex items-center justify-between rounded-md border border-border bg-muted px-2 py-1 text-[11px] text-muted-foreground",
1533
+ children: [
1534
+ /* @__PURE__ */ l("span", { className: "truncate", title: n.source, children: n.source.split(/[/\\]/).pop() || n.source }),
1535
+ /* @__PURE__ */ C("span", { className: "ml-2 font-semibold text-success", children: [
1536
+ Math.round(n.score * 100),
1537
+ "%"
1538
+ ] })
1539
+ ]
1540
+ },
1541
+ n.chunkId
1542
+ )) })
1543
+ ] }) : null;
1544
+ }
1545
+ function Xr({ toolCalls: e }) {
1546
+ return e.length ? /* @__PURE__ */ l("div", { className: "mt-2 flex flex-wrap gap-1.5", children: e.map((t, r) => /* @__PURE__ */ l(
1547
+ "span",
1548
+ {
1549
+ className: "inline-flex items-center rounded-full border border-border bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",
1550
+ children: Jr(t.toolName)
1551
+ },
1552
+ `${t.toolName}-${r}`
1553
+ )) }) : null;
1554
+ }
1555
+ const Qr = ({ message: e }) => {
1556
+ const t = e.role === "user", r = e.status === "error";
1557
+ return /* @__PURE__ */ C(
1558
+ "div",
1559
+ {
1560
+ className: V("flex items-start gap-2.5", t && "flex-row-reverse"),
1561
+ children: [
1562
+ !t && /* @__PURE__ */ l(
1563
+ "div",
1564
+ {
1565
+ className: "mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground",
1566
+ "aria-hidden": "true",
1567
+ children: /* @__PURE__ */ l(st, { size: 15 })
1568
+ }
1569
+ ),
1570
+ /* @__PURE__ */ C("div", { className: V("flex max-w-[82%] flex-col", t && "items-end"), children: [
1571
+ /* @__PURE__ */ C(
1572
+ "div",
1573
+ {
1574
+ className: V(
1575
+ "rounded-2xl px-3.5 py-2.5 text-[13.5px] leading-[1.55]",
1576
+ t && "rounded-tr-sm bg-[var(--bubble-user-bg)] text-[var(--bubble-user-text)] font-medium",
1577
+ !t && !r && "rounded-tl-sm border border-border bg-[var(--bubble-bot-message-bg)] text-foreground",
1578
+ r && "rounded-tl-sm border border-[var(--error-border)] bg-[var(--error-bg)] text-[var(--error-text)]"
1579
+ ),
1580
+ children: [
1581
+ e.status === "pending" ? /* @__PURE__ */ l(Zr, {}) : t ? /* @__PURE__ */ l("p", { className: "whitespace-pre-wrap", children: e.content }) : /* @__PURE__ */ l(Yr, { text: e.content }),
1582
+ e.toolCalls ? /* @__PURE__ */ l(Xr, { toolCalls: e.toolCalls }) : null,
1583
+ e.sources ? /* @__PURE__ */ l(Kr, { sources: e.sources }) : null
1584
+ ]
1585
+ }
1586
+ ),
1587
+ t && e.status !== "error" && /* @__PURE__ */ l(Ht, { size: 13, className: "mt-1 text-success", "aria-hidden": "true" })
1588
+ ] })
1589
+ ]
1590
+ }
1591
+ );
1592
+ }, en = () => {
1593
+ const { messages: e, status: t, showSuggestions: r } = ye();
1594
+ return /* @__PURE__ */ l(
1595
+ Gr,
1596
+ {
1597
+ autoScroll: !0,
1598
+ defaultScrollPosition: "last-anchor",
1599
+ scrollPreviousItemPeek: 64,
1600
+ children: /* @__PURE__ */ C(Vr, { children: [
1601
+ /* @__PURE__ */ l(Wr, { "aria-label": "Chat messages", children: /* @__PURE__ */ C(jr, { "aria-busy": t === "awaiting" || t === "connecting", children: [
1602
+ r && /* @__PURE__ */ l(Ye, { messageId: "welcome", children: /* @__PURE__ */ l(Ur, {}) }),
1603
+ e.map((o) => /* @__PURE__ */ l(
1604
+ Ye,
1605
+ {
1606
+ messageId: o.id,
1607
+ scrollAnchor: o.role === "user",
1608
+ children: /* @__PURE__ */ l(Qr, { message: o })
1609
+ },
1610
+ o.id
1611
+ ))
1612
+ ] }) }),
1613
+ /* @__PURE__ */ l($r, {})
1614
+ ] })
1615
+ }
1616
+ );
1617
+ }, tn = () => {
1618
+ const { pendingTicket: e, ticketBusy: t, userContext: r, confirmTicket: n, cancelTicket: o } = ye(), s = !r.customerId && !r.email, [a, i] = Y("");
1619
+ return e ? /* @__PURE__ */ C(
1620
+ "div",
1621
+ {
1622
+ className: "mx-4 mb-3 rounded-xl border border-border bg-card p-4 shadow-sm",
1623
+ role: "region",
1624
+ "aria-label": "Create support ticket",
1625
+ children: [
1626
+ /* @__PURE__ */ l("h3", { className: "text-[13.5px] font-bold text-foreground", children: "Create support ticket?" }),
1627
+ /* @__PURE__ */ l("p", { className: "mt-1.5 text-[12.5px] leading-5 text-muted-foreground", children: "I can open a support request for you. Nothing is created until you confirm." }),
1628
+ /* @__PURE__ */ l("p", { className: "mt-2 rounded-md bg-muted px-2.5 py-2 text-[12.5px] text-foreground", children: e.description }),
1629
+ s && /* @__PURE__ */ C("label", { className: "mt-3 block text-[12px] font-semibold text-foreground", children: [
1630
+ "Customer ID or email",
1631
+ /* @__PURE__ */ l(
1632
+ "input",
1633
+ {
1634
+ value: a,
1635
+ onChange: (d) => i(d.target.value),
1636
+ className: "mt-1 w-full rounded-md border border-border px-2.5 py-2 text-[13px] font-normal outline-none focus-visible:ring-2 focus-visible:ring-primary",
1637
+ placeholder: "CUST-1001 or you@company.com",
1638
+ autoComplete: "email"
1639
+ }
1640
+ )
1641
+ ] }),
1642
+ /* @__PURE__ */ C("div", { className: "mt-3 flex justify-end gap-2", children: [
1643
+ /* @__PURE__ */ l(
1644
+ "button",
1645
+ {
1646
+ type: "button",
1647
+ onClick: o,
1648
+ disabled: t,
1649
+ className: "rounded-lg border border-border bg-card px-3.5 py-1.5 text-[12.5px] font-semibold text-muted-foreground hover:bg-muted",
1650
+ children: "Cancel"
1651
+ }
1652
+ ),
1653
+ /* @__PURE__ */ l(
1654
+ "button",
1655
+ {
1656
+ type: "button",
1657
+ onClick: () => void n(a),
1658
+ disabled: t || s && !a.trim(),
1659
+ className: "rounded-lg bg-action px-3.5 py-1.5 text-[12.5px] font-semibold text-action-foreground hover:bg-[var(--action-hover)] disabled:opacity-40",
1660
+ children: t ? "Creating…" : "Create ticket"
1661
+ }
1662
+ )
1663
+ ] })
1664
+ ]
1665
+ }
1666
+ ) : null;
1667
+ }, gt = ({
1668
+ className: e,
1669
+ onClose: t,
1670
+ showMinimize: r,
1671
+ title: n,
1672
+ subtitle: o,
1673
+ envStage: s,
1674
+ envPulse: a = !0
1675
+ }) => {
1676
+ const { sendMessage: i, status: d, error: p, resetConversation: m, retryLast: y, pendingTicket: f } = ye(), u = d === "awaiting" || d === "connecting" || !!f;
1677
+ return /* @__PURE__ */ C(
1678
+ "section",
1679
+ {
1680
+ className: V(
1681
+ "flex h-full min-h-0 flex-col overflow-hidden bg-card",
1682
+ e
1683
+ ),
1684
+ "aria-label": "VPS AI Assistant",
1685
+ children: [
1686
+ /* @__PURE__ */ l(
1687
+ er,
1688
+ {
1689
+ title: n,
1690
+ subtitle: o,
1691
+ onClose: t,
1692
+ onReset: () => void m(),
1693
+ showMinimize: r,
1694
+ envStage: s,
1695
+ envPulse: a
1696
+ }
1697
+ ),
1698
+ /* @__PURE__ */ l("div", { className: "relative min-h-0 flex-1", children: /* @__PURE__ */ l(en, {}) }),
1699
+ p && d === "error" && /* @__PURE__ */ l(Mt, { message: p, onRetry: () => void y() }),
1700
+ /* @__PURE__ */ l(tn, {}),
1701
+ /* @__PURE__ */ l(
1702
+ sr,
1703
+ {
1704
+ onSend: (g) => void i(g),
1705
+ disabled: u
1706
+ }
1707
+ )
1708
+ ]
1709
+ }
1710
+ );
1711
+ }, rn = ({
1712
+ open: e,
1713
+ onClose: t,
1714
+ envStage: r,
1715
+ envPulse: n = !0
1716
+ }) => e ? /* @__PURE__ */ l(
1717
+ "div",
1718
+ {
1719
+ id: "vps-chatbot-widget-panel",
1720
+ className: V(
1721
+ "fixed bottom-[98px] right-7 z-[999] flex h-[min(660px,calc(100vh-120px))] w-[min(420px,calc(100vw-32px))] flex-col overflow-hidden rounded-[20px] border border-border bg-card",
1722
+ "shadow-[0_20px_40px_-15px_rgba(0,0,0,0.12)]",
1723
+ "origin-bottom-right animate-[chat-pop_180ms_ease-out] motion-reduce:animate-none"
1724
+ ),
1725
+ children: /* @__PURE__ */ l(
1726
+ gt,
1727
+ {
1728
+ onClose: t,
1729
+ showMinimize: !0,
1730
+ title: "VPS AI Assistant",
1731
+ envStage: r,
1732
+ envPulse: n
1733
+ }
1734
+ )
1735
+ }
1736
+ ) : null, nn = ({
1737
+ open: e,
1738
+ onToggle: t
1739
+ }) => /* @__PURE__ */ l(
1740
+ "button",
1741
+ {
1742
+ type: "button",
1743
+ onClick: t,
1744
+ "aria-expanded": e,
1745
+ "aria-controls": "vps-chatbot-widget-panel",
1746
+ "aria-label": e ? "Close assistant" : "Open assistant",
1747
+ className: V(
1748
+ "fixed bottom-7 right-7 z-[1000] flex h-[58px] w-[58px] items-center justify-center rounded-xl text-primary-foreground",
1749
+ "bg-primary hover:bg-[var(--primary-hover)]",
1750
+ "shadow-md",
1751
+ "transition duration-200 motion-reduce:transition-none motion-reduce:hover:scale-100",
1752
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary"
1753
+ ),
1754
+ children: e ? /* @__PURE__ */ l(Jt, { size: 22 }) : /* @__PURE__ */ l(lt, { size: 24 })
1755
+ }
1756
+ ), Ze = ({
1757
+ defaultOpen: e = !1,
1758
+ open: t,
1759
+ onOpenChange: r,
1760
+ envStage: n,
1761
+ envPulse: o = !0
1762
+ }) => {
1763
+ const [s, a] = Y(e), i = t ?? s, d = (p) => {
1764
+ r == null || r(p), t === void 0 && a(p);
1765
+ };
1766
+ return /* @__PURE__ */ C(le, { children: [
1767
+ /* @__PURE__ */ l(
1768
+ rn,
1769
+ {
1770
+ open: i,
1771
+ onClose: () => d(!1),
1772
+ envStage: n,
1773
+ envPulse: o
1774
+ }
1775
+ ),
1776
+ /* @__PURE__ */ l(nn, { open: i, onToggle: () => d(!i) })
1777
+ ] });
1778
+ }, hn = ({
1779
+ apiBaseUrl: e,
1780
+ apiUrl: t,
1781
+ proxyUrl: r,
1782
+ userContext: n,
1783
+ suggestions: o,
1784
+ disableSuggestions: s,
1785
+ initialMessage: a,
1786
+ ...i
1787
+ }) => {
1788
+ const d = rt(), p = e ?? t ?? r;
1789
+ return !!d && (!p || te(p) === te(d == null ? void 0 : d.apiBaseUrl)) && !n && !o && s === void 0 && !a ? /* @__PURE__ */ l(Ze, { ...i }) : /* @__PURE__ */ l(
1790
+ nt,
1791
+ {
1792
+ apiBaseUrl: p,
1793
+ userContext: n,
1794
+ suggestions: o,
1795
+ disableSuggestions: s,
1796
+ initialMessage: a,
1797
+ children: /* @__PURE__ */ l(Ze, { ...i })
1798
+ }
1799
+ );
1800
+ }, on = ({
1801
+ open: e,
1802
+ onClose: t,
1803
+ subtitle: r,
1804
+ title: n,
1805
+ envStage: o,
1806
+ envPulse: s = !0
1807
+ }) => /* @__PURE__ */ C(le, { children: [
1808
+ /* @__PURE__ */ l(
1809
+ "div",
1810
+ {
1811
+ className: V(
1812
+ "fixed inset-0 z-[90] bg-[var(--overlay)] sm:hidden",
1813
+ e ? "opacity-100" : "pointer-events-none opacity-0",
1814
+ "transition-opacity duration-200 motion-reduce:transition-none"
1815
+ ),
1816
+ hidden: !e,
1817
+ onClick: t,
1818
+ "aria-hidden": "true"
1819
+ }
1820
+ ),
1821
+ /* @__PURE__ */ l(
1822
+ "aside",
1823
+ {
1824
+ id: "vps-embedded-chat-panel",
1825
+ className: V(
1826
+ "fixed inset-y-0 right-0 z-[100] flex w-full max-w-[440px] flex-col border-l border-border bg-card shadow-xl",
1827
+ "transition-transform duration-300 ease-out motion-reduce:transition-none",
1828
+ e ? "translate-x-0" : "translate-x-full"
1829
+ ),
1830
+ "aria-hidden": !e,
1831
+ children: e && /* @__PURE__ */ l(
1832
+ gt,
1833
+ {
1834
+ onClose: t,
1835
+ title: n || "VPS AI Assistant",
1836
+ subtitle: r,
1837
+ envStage: o,
1838
+ envPulse: s
1839
+ }
1840
+ )
1841
+ }
1842
+ )
1843
+ ] }), sn = 5, xe = 8, bt = "vps-embedded-assistant-top";
1844
+ function ln(e, t, r) {
1845
+ return Math.min(r, Math.max(t, e));
1846
+ }
1847
+ function Je(e, t) {
1848
+ const r = Math.max(
1849
+ xe,
1850
+ window.innerHeight - t - xe
1851
+ );
1852
+ return ln(e, xe, r);
1853
+ }
1854
+ function an() {
1855
+ try {
1856
+ const e = window.localStorage.getItem(bt);
1857
+ if (!e) return null;
1858
+ const t = Number(e);
1859
+ return Number.isFinite(t) ? t : null;
1860
+ } catch {
1861
+ return null;
1862
+ }
1863
+ }
1864
+ function cn(e) {
1865
+ try {
1866
+ window.localStorage.setItem(bt, String(e));
1867
+ } catch {
1868
+ }
1869
+ }
1870
+ const un = ({
1871
+ onOpen: e
1872
+ }) => {
1873
+ const t = X(null), r = X({
1874
+ pointerId: null,
1875
+ startY: 0,
1876
+ startTop: 0,
1877
+ moved: !1
1878
+ }), [n, o] = Y(
1879
+ () => typeof window > "u" ? null : an()
1880
+ ), s = X(n), a = X(!1), [i, d] = Y(!1);
1881
+ ge(() => {
1882
+ s.current = n;
1883
+ }, [n]), ge(() => {
1884
+ const f = t.current;
1885
+ if (!f) return;
1886
+ const u = () => {
1887
+ o((g) => {
1888
+ const E = g ?? Math.round(window.innerHeight / 2 - f.offsetHeight / 2), v = Je(E, f.offsetHeight);
1889
+ return s.current = v, v;
1890
+ });
1891
+ };
1892
+ return u(), window.addEventListener("resize", u), () => window.removeEventListener("resize", u);
1893
+ }, []);
1894
+ const p = (f) => {
1895
+ if (f.button !== 0) return;
1896
+ const u = f.currentTarget, g = u.getBoundingClientRect();
1897
+ r.current = {
1898
+ pointerId: f.pointerId,
1899
+ startY: f.clientY,
1900
+ startTop: g.top,
1901
+ moved: !1
1902
+ };
1903
+ try {
1904
+ u.setPointerCapture(f.pointerId);
1905
+ } catch {
1906
+ }
1907
+ }, m = (f) => {
1908
+ if (r.current.pointerId !== f.pointerId) return;
1909
+ const u = f.clientY - r.current.startY;
1910
+ if (!r.current.moved && Math.abs(u) < sn) return;
1911
+ r.current.moved = !0, d(!0);
1912
+ const g = Je(
1913
+ r.current.startTop + u,
1914
+ f.currentTarget.offsetHeight
1915
+ );
1916
+ s.current = g, o(g);
1917
+ }, y = (f) => {
1918
+ var g, E;
1919
+ if (r.current.pointerId !== f.pointerId) return;
1920
+ try {
1921
+ (E = (g = f.currentTarget).hasPointerCapture) != null && E.call(g, f.pointerId) && f.currentTarget.releasePointerCapture(f.pointerId);
1922
+ } catch {
1923
+ }
1924
+ const u = r.current.moved;
1925
+ r.current.pointerId = null, r.current.moved = !1, d(!1), u && (a.current = !0, s.current != null && cn(s.current));
1926
+ };
1927
+ return /* @__PURE__ */ C(
1928
+ "button",
1929
+ {
1930
+ ref: t,
1931
+ type: "button",
1932
+ onPointerDown: p,
1933
+ onPointerMove: m,
1934
+ onPointerUp: y,
1935
+ onPointerCancel: y,
1936
+ onClick: () => {
1937
+ if (a.current) {
1938
+ a.current = !1;
1939
+ return;
1940
+ }
1941
+ e();
1942
+ },
1943
+ "aria-expanded": !1,
1944
+ "aria-controls": "vps-embedded-chat-panel",
1945
+ "aria-label": "Assistant",
1946
+ className: `fixed right-0 z-[80] flex touch-none items-center gap-2 rounded-l-lg bg-action px-3 py-2.5 text-[12.5px] font-semibold text-action-foreground shadow-lg hover:bg-[var(--action-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${i ? "cursor-grabbing" : "cursor-grab"}`,
1947
+ style: {
1948
+ top: n ?? "50%",
1949
+ transform: n == null ? "translateY(-50%)" : void 0
1950
+ },
1951
+ children: [
1952
+ /* @__PURE__ */ l(lt, { size: 16 }),
1953
+ "Assistant"
1954
+ ]
1955
+ }
1956
+ );
1957
+ }, Ke = ({
1958
+ defaultOpen: e = !1,
1959
+ open: t,
1960
+ onOpenChange: r,
1961
+ showTrigger: n = !0,
1962
+ envStage: o,
1963
+ envPulse: s = !0
1964
+ }) => {
1965
+ const [a, i] = Y(e), d = t ?? a, p = (m) => {
1966
+ r == null || r(m), t === void 0 && i(m);
1967
+ };
1968
+ return /* @__PURE__ */ C(le, { children: [
1969
+ n && !d && /* @__PURE__ */ l(un, { onOpen: () => p(!0) }),
1970
+ /* @__PURE__ */ l(
1971
+ on,
1972
+ {
1973
+ open: d,
1974
+ onClose: () => p(!1),
1975
+ envStage: o,
1976
+ envPulse: s
1977
+ }
1978
+ )
1979
+ ] });
1980
+ }, mn = ({
1981
+ apiBaseUrl: e,
1982
+ apiUrl: t,
1983
+ proxyUrl: r,
1984
+ userContext: n,
1985
+ suggestions: o,
1986
+ disableSuggestions: s,
1987
+ initialMessage: a,
1988
+ ...i
1989
+ }) => {
1990
+ const d = rt(), p = e ?? t ?? r;
1991
+ return !!d && (!p || te(p) === te(d == null ? void 0 : d.apiBaseUrl)) && !n && !o && s === void 0 && !a ? /* @__PURE__ */ l(Ke, { ...i }) : /* @__PURE__ */ l(
1992
+ nt,
1993
+ {
1994
+ apiBaseUrl: p,
1995
+ userContext: n,
1996
+ suggestions: o,
1997
+ disableSuggestions: s,
1998
+ initialMessage: a,
1999
+ children: /* @__PURE__ */ l(Ke, { ...i })
2000
+ }
2001
+ );
2002
+ }, gn = {
2003
+ Colors: {
2004
+ VPS_White: "#fff",
2005
+ VPS_Dark_Blue: "#1A1A31",
2006
+ VPS_Light_Blue: "#353552",
2007
+ VPS_Light_Grey: "#D1D1D6",
2008
+ VPS_Orange: "#FF4717",
2009
+ Dark_Blue_50: "#F1F5FC",
2010
+ Dark_Blue_100: "#E5EBFA",
2011
+ Dark_Blue_200: "#D1DAF4",
2012
+ Dark_Blue_300: "#B4C2ED",
2013
+ Dark_Blue_400: "#96A2E3",
2014
+ Dark_Blue_500: "#7C84D8",
2015
+ Dark_Blue_600: "#6262C9",
2016
+ Dark_Blue_700: "#5351B1",
2017
+ Dark_Blue_800: "#44448F",
2018
+ Dark_Blue_900: "#3C3D73",
2019
+ Dark_Blue_950: "#1A1A31",
2020
+ Light_Blue_50: "#F4F6FA",
2021
+ Light_Blue_100: "#E6E9F3",
2022
+ Light_Blue_200: "#D3D8EA",
2023
+ Light_Blue_300: "#B4BEDC",
2024
+ Light_Blue_400: "#909DCA",
2025
+ Light_Blue_500: "#7580BC",
2026
+ Light_Blue_600: "#6369AD",
2027
+ Light_Blue_700: "#575A9E",
2028
+ Light_Blue_800: "#4B4B82",
2029
+ Light_Blue_900: "#404168",
2030
+ Light_Blue_950: "#353552",
2031
+ Grey_50: "#F6F6F7",
2032
+ Grey_100: "#EFEFF0",
2033
+ Grey_200: "#E2E1E4",
2034
+ Grey_300: "#D1D1D6",
2035
+ Grey_400: "#B9B9C0",
2036
+ Grey_500: "#A7A6AE",
2037
+ Grey_600: "#93919A",
2038
+ Grey_700: "#7E7D85",
2039
+ Grey_800: "#67666D",
2040
+ Grey_900: "#56555A",
2041
+ Grey_950: "#323234",
2042
+ Orange_50: "#FFF3ED",
2043
+ Orange_100: "#FFE4D4",
2044
+ Orange_200: "#FFC5A8",
2045
+ Orange_300: "#FF9D70",
2046
+ Orange_400: "#FF6837",
2047
+ Orange_500: "#FF4717",
2048
+ Orange_600: "#F02706",
2049
+ Orange_700: "#C71807",
2050
+ Orange_800: "#9E150E",
2051
+ Orange_900: "#7F150F",
2052
+ Orange_950: "#450605",
2053
+ Success_50: "#F1FCF5",
2054
+ Success_100: "#DEFAEA",
2055
+ Success_200: "#BEF4D4",
2056
+ Success_300: "#8BEAB3",
2057
+ Success_400: "#52D689",
2058
+ Success_500: "#2ECC71",
2059
+ Success_600: "#1D9C53",
2060
+ Success_700: "#1B7A43",
2061
+ Success_800: "#1A6139",
2062
+ Success_900: "#175031",
2063
+ Success_950: "#072C18",
2064
+ Warning_50: "#FFFEEA",
2065
+ Warning_100: "#FFF9C5",
2066
+ Warning_200: "#FFF485",
2067
+ Warning_300: "#FFE846",
2068
+ Warning_400: "#FFD81B",
2069
+ Warning_500: "#FFB800",
2070
+ Warning_600: "#E28D00",
2071
+ Warning_700: "#BB6302",
2072
+ Warning_800: "#984C08",
2073
+ Warning_900: "#7C3F0B",
2074
+ Warning_950: "#482000",
2075
+ Error_50: "#FFF1F1",
2076
+ Error_100: "#FFDFDF",
2077
+ Error_200: "#FFC5C5",
2078
+ Error_300: "#FF9D9D",
2079
+ Error_400: "#FF6464",
2080
+ Error_500: "#FF2E2E",
2081
+ Error_600: "#ED1515",
2082
+ Error_700: "#C80D0D",
2083
+ Error_800: "#A50F0F",
2084
+ Error_900: "#881414",
2085
+ Error_950: "#4B0404",
2086
+ Netural_25: "#FDFDFD",
2087
+ Netural_50: "#FAFAFA",
2088
+ Netural_100: "#F5F5F5",
2089
+ Netural_200: "#E9EAEC",
2090
+ Netural_300: "#D6D7DB",
2091
+ Netural_400: "#A4A7AE",
2092
+ Netural_500: "#727681",
2093
+ Netural_600: "#545863",
2094
+ Netural_700: "#424651",
2095
+ Netural_800: "#252B37",
2096
+ Netural_900: "#191D28",
2097
+ Netural_950: "#0A0D12",
2098
+ Tint_Dark_Blue_100: "#1A1A31",
2099
+ Tint_Dark_Blue_90: "#313146",
2100
+ Tint_Dark_Blue_80: "#48485A",
2101
+ Tint_Dark_Blue_70: "#5F5F6F",
2102
+ Tint_Dark_Blue_60: "#767683",
2103
+ Tint_Dark_Blue_50: "#8C8C98",
2104
+ Tint_Dark_Blue_40: "#A3A3AD",
2105
+ Tint_Dark_Blue_30: "#BABAC1",
2106
+ Tint_Dark_Blue_20: "#D1D1D6",
2107
+ Tint_Dark_Blue_10: "#E8E8EA",
2108
+ Tint_Dark_Blue_5: "#F4F4F5",
2109
+ Tint_Light_Blue_100: "#353552",
2110
+ Tint_Light_Blue_90: "#494963",
2111
+ Tint_Light_Blue_80: "#5D5D75",
2112
+ Tint_Light_Blue_70: "#727286",
2113
+ Tint_Light_Blue_60: "#868697",
2114
+ Tint_Light_Blue_50: "#9A9AA8",
2115
+ Tint_Light_Blue_40: "#AEAEBA",
2116
+ Tint_Light_Blue_30: "#C2C2CB",
2117
+ Tint_Light_Blue_20: "#D7D7DC",
2118
+ Tint_Light_Blue_10: "#EBEBEE",
2119
+ Tint_Light_Blue_5: "#F5F5F6",
2120
+ Tint_Grey_100: "#D1D1D6",
2121
+ Tint_Grey_90: "#D6D6DA",
2122
+ Tint_Grey_80: "#DADADE",
2123
+ Tint_Grey_70: "#DFDFE2",
2124
+ Tint_Grey_60: "#E3E3E6",
2125
+ Tint_Grey_50: "#E8E8EB",
2126
+ Tint_Grey_40: "#EDEDEF",
2127
+ Tint_Grey_30: "#F1F1F3",
2128
+ Tint_Grey_20: "#F6F6F7",
2129
+ Tint_Grey_10: "#FAFAFB",
2130
+ Tint_Grey_5: "#FDFDFD",
2131
+ Tint_Solus_100: "#FF4717",
2132
+ Tint_Solus_90: "#FF592E",
2133
+ Tint_Solus_80: "#FF6C45",
2134
+ Tint_Solus_70: "#FF7E5D",
2135
+ Tint_Solus_60: "#FF9174",
2136
+ Tint_Solus_50: "#FFA38B",
2137
+ Tint_Solus_40: "#FFB5A2",
2138
+ Tint_Solus_30: "#FFC8B9",
2139
+ Tint_Solus_20: "#FFDAD1",
2140
+ Tint_Solus_10: "#FFEDE8",
2141
+ Tint_Solus_5: "#FFF6F3",
2142
+ Other_Color: "#00ABC9"
2143
+ },
2144
+ StatusColor: {
2145
+ tested: "#3E4784",
2146
+ received: "#EE46BC",
2147
+ InTransit: "#6938EF",
2148
+ registered: "#1570EF",
2149
+ reported: "#2ECC71",
2150
+ noStatus: "#727681",
2151
+ Action: "#FF2E2E",
2152
+ Caution: "#FFB800",
2153
+ Pass: "#2ECC71",
2154
+ No_Rating: "#FF6837",
2155
+ Received: "#EE46BC",
2156
+ Tested: "#3E4784",
2157
+ Reported: "#2ECC71",
2158
+ No_Status: "#6938EF",
2159
+ Overdue: "#FF2E2E",
2160
+ Duesoon: "#FFB800",
2161
+ Scheduled: "#1570EF",
2162
+ Good: "#2ECC71",
2163
+ NotApplicable: "#353552"
2164
+ }
2165
+ };
2166
+ export {
2167
+ gt as ChatPanel,
2168
+ nt as ChatProvider,
2169
+ hn as ChatbotWidget,
2170
+ gn as ColorPalette,
2171
+ mn as EmbeddedChatbot,
2172
+ We as buildApiUrl,
2173
+ pn as chatApi,
2174
+ tt as createChatApi,
2175
+ te as resolveApiBaseUrl,
2176
+ Bt as useChatContext,
2177
+ ye as useChatbot,
2178
+ rt as useOptionalChatContext
2179
+ };