vpschatbotwidget 1.0.2 → 1.1.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.
Files changed (42) hide show
  1. package/dist-lib/types/App.d.ts +1 -0
  2. package/dist-lib/types/chatbot/api/chatbot-api.d.ts +10 -2
  3. package/dist-lib/types/chatbot/api/chatbot-types.d.ts +21 -0
  4. package/dist-lib/types/chatbot/core/AgentReasoning.d.ts +9 -0
  5. package/dist-lib/types/chatbot/core/ChatContext.d.ts +2 -0
  6. package/dist-lib/types/chatbot/core/ChatMarkdown.d.ts +2 -2
  7. package/dist-lib/types/chatbot/core/ChatProvider.d.ts +13 -1
  8. package/dist-lib/types/chatbot/core/ChatTypingIndicator.d.ts +1 -0
  9. package/dist-lib/types/chatbot/core/GroundedSources.d.ts +14 -0
  10. package/dist-lib/types/chatbot/embedded/EmbeddedChatbot.d.ts +13 -1
  11. package/dist-lib/types/chatbot/index.d.ts +1 -1
  12. package/dist-lib/types/chatbot/widget/ChatbotWidget.d.ts +13 -1
  13. package/dist-lib/vps-chatbot.cjs +32 -28
  14. package/dist-lib/vps-chatbot.js +1262 -1085
  15. package/package.json +2 -2
  16. package/src/chatbot/api/chatbot-api.ts +105 -3
  17. package/src/chatbot/api/chatbot-types.ts +23 -0
  18. package/src/chatbot/core/AgentReasoning.tsx +60 -0
  19. package/src/chatbot/core/ChatContext.tsx +2 -0
  20. package/src/chatbot/core/ChatEmptyState.tsx +4 -4
  21. package/src/chatbot/core/ChatError.tsx +2 -2
  22. package/src/chatbot/core/ChatHeader.tsx +13 -13
  23. package/src/chatbot/core/ChatInput.tsx +6 -6
  24. package/src/chatbot/core/ChatMarkdown.tsx +280 -55
  25. package/src/chatbot/core/ChatMessage.tsx +53 -62
  26. package/src/chatbot/core/ChatMessageList.tsx +1 -1
  27. package/src/chatbot/core/ChatPanel.tsx +2 -6
  28. package/src/chatbot/core/ChatProvider.tsx +109 -22
  29. package/src/chatbot/core/ChatSuggestions.tsx +5 -10
  30. package/src/chatbot/core/ChatTicketConfirmation.tsx +9 -9
  31. package/src/chatbot/core/ChatTypingIndicator.tsx +16 -5
  32. package/src/chatbot/core/GroundedSources.tsx +181 -0
  33. package/src/chatbot/embedded/EmbeddedChatbot.tsx +33 -4
  34. package/src/chatbot/embedded/EmbeddedChatbotPanel.tsx +2 -11
  35. package/src/chatbot/embedded/EmbeddedChatbotTrigger.tsx +2 -2
  36. package/src/chatbot/index.ts +1 -0
  37. package/src/chatbot/widget/ChatbotWidget.tsx +33 -4
  38. package/src/chatbot/widget/ChatbotWidgetPanel.tsx +1 -6
  39. package/src/chatbot/widget/ChatbotWidgetTrigger.tsx +1 -8
  40. package/src/components/EnvBadge.tsx +2 -2
  41. package/src/components/ui/message-scroller.tsx +5 -23
  42. package/src/index.css +1998 -51
@@ -1,53 +1,55 @@
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) {
1
+ import { jsx as l, jsxs as T, Fragment as ke } from "react/jsx-runtime";
2
+ import * as u from "react";
3
+ import Ae, { createContext as Ct, useContext as nt, useMemo as he, useState as K, useRef as se, useCallback as le, forwardRef as st, createElement as Fe, useEffect as ie } from "react";
4
+ const St = {};
5
+ function ce(e) {
6
6
  return e != null && e.trim() !== "" ? e.trim().replace(/\/+$/, "") : String("").trim().replace(/\/+$/, "");
7
7
  }
8
- function We(e, t) {
9
- const r = te(e);
10
- if (!r)
8
+ function Se(e, t) {
9
+ const n = ce(e);
10
+ if (!n)
11
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";
12
+ if (n.endsWith("/api") && t.startsWith("/api/"))
13
+ return `${n}${t.slice(4)}`;
14
+ if (n.endsWith("/api") && t === "/health") {
15
+ const s = n.slice(0, -4);
16
+ return s ? `${s}/health` : "/health";
17
17
  }
18
- const n = t.startsWith("/") ? t : `/${t}`;
19
- return `${r}${n}`;
18
+ const r = t.startsWith("/") ? t : `/${t}`;
19
+ return `${n}${r}`;
20
20
  }
21
- function wt(e) {
21
+ function Tt(e) {
22
22
  return e && typeof e == "object" && "data" in e && e.success !== !1 ? e.data : e;
23
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 };
24
+ function Ft(e, t, n) {
25
+ var o, a, i;
26
+ const r = e, s = (o = r == null ? void 0 : r.error) == null ? void 0 : o.message;
27
+ return s && !Et(s) ? {
28
+ code: (a = r == null ? void 0 : r.error) == null ? void 0 : a.code,
29
+ message: s,
30
+ requestId: (i = r == null ? void 0 : r.error) == null ? void 0 : i.request_id
31
+ } : n >= 500 ? { message: "I couldn't process that request right now." } : n === 0 ? { message: "Something went wrong while connecting. Please try again." } : { message: t };
32
32
  }
33
- function kt(e) {
33
+ function Et(e) {
34
34
  return /traceback|sql|exception|stack|api[_ ]?key|password/i.test(e);
35
35
  }
36
- function St(e) {
36
+ function je(e) {
37
37
  return {
38
38
  chunkId: e.chunk_id,
39
39
  source: e.source,
40
- score: e.score
40
+ score: e.score,
41
+ title: e.title,
42
+ snippet: e.snippet
41
43
  };
42
44
  }
43
- function Ft(e) {
45
+ function Ye(e) {
44
46
  return {
45
47
  toolName: e.tool_name,
46
48
  arguments: e.arguments ?? {},
47
49
  result: e.result ?? {}
48
50
  };
49
51
  }
50
- function Et(e) {
52
+ function Je(e) {
51
53
  return {
52
54
  model: e.model,
53
55
  promptTokens: e.prompt_tokens,
@@ -55,7 +57,7 @@ function Et(e) {
55
57
  totalTokens: e.total_tokens
56
58
  };
57
59
  }
58
- function Tt(e) {
60
+ function Rt(e) {
59
61
  const t = e.role === "user" || e.role === "system" ? e.role : "assistant";
60
62
  return {
61
63
  id: String(e.id),
@@ -71,7 +73,7 @@ function Tt(e) {
71
73
  } : void 0
72
74
  };
73
75
  }
74
- async function Rt(e) {
76
+ async function At(e) {
75
77
  const t = await e.text();
76
78
  if (!t) return {};
77
79
  try {
@@ -80,71 +82,130 @@ async function Rt(e) {
80
82
  return {};
81
83
  }
82
84
  }
83
- function tt(e) {
84
- const t = te(e);
85
- async function r(n, o) {
86
- let s;
87
- const a = We(t, n);
85
+ function ot(e) {
86
+ const t = ce(e);
87
+ async function n(r, s) {
88
+ let o;
89
+ const a = Se(t, r);
88
90
  try {
89
- s = await fetch(a, {
90
- ...o,
91
+ o = await fetch(a, {
92
+ ...s,
91
93
  headers: {
92
94
  "Content-Type": "application/json",
93
- ...(o == null ? void 0 : o.headers) ?? {}
95
+ ...(s == null ? void 0 : s.headers) ?? {}
94
96
  }
95
97
  });
96
98
  } catch {
97
99
  throw { message: "Something went wrong while connecting. Please try again." };
98
100
  }
99
- if (s.status === 204)
101
+ if (o.status === 204)
100
102
  return;
101
- const i = await Rt(s);
102
- if (!s.ok)
103
- throw Ct(
103
+ const i = await At(o);
104
+ if (!o.ok)
105
+ throw Ft(
104
106
  i,
105
107
  "I couldn't process that request right now.",
106
- s.status
108
+ o.status
107
109
  );
108
- return wt(i);
110
+ return Tt(i);
109
111
  }
110
112
  return {
111
113
  apiBaseUrl: t,
112
114
  async createSession() {
113
- const n = await r("/api/v1/sessions", {
115
+ const r = await n("/api/v1/sessions", {
114
116
  method: "POST",
115
117
  body: JSON.stringify({})
116
118
  });
117
- return { sessionId: n.session_id, createdAt: n.created_at };
119
+ return { sessionId: r.session_id, createdAt: r.created_at };
118
120
  },
119
- async sendMessage(n, o) {
120
- const s = await r(
121
- `/api/v1/sessions/${n}/messages`,
121
+ async sendMessage(r, s, o) {
122
+ const a = await n(
123
+ `/api/v1/sessions/${r}/messages`,
122
124
  {
123
125
  method: "POST",
124
- body: JSON.stringify({ message: o })
126
+ body: JSON.stringify({
127
+ message: s,
128
+ ...(o == null ? void 0 : o.roleId) !== void 0 ? { role_id: o.roleId } : {},
129
+ ...o != null && o.client ? { client: o.client } : {}
130
+ })
125
131
  }
126
132
  );
127
133
  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
+ requestId: a.request_id,
135
+ sessionId: a.session_id,
136
+ answer: a.answer,
137
+ sources: (a.sources || []).map(je),
138
+ toolCalls: (a.tool_calls || []).map(Ye),
139
+ usage: Je(a.usage)
134
140
  };
135
141
  },
136
- async getHistory(n) {
142
+ async sendMessageStream(r, s, o, a) {
143
+ const i = Se(t, `/api/v1/sessions/${r}/messages/stream`);
144
+ try {
145
+ const c = await fetch(i, {
146
+ method: "POST",
147
+ headers: {
148
+ "Content-Type": "application/json"
149
+ },
150
+ body: JSON.stringify({
151
+ message: s,
152
+ ...(o == null ? void 0 : o.roleId) !== void 0 ? { role_id: o.roleId } : {},
153
+ ...o != null && o.client ? { client: o.client } : {}
154
+ })
155
+ });
156
+ if (!c.ok || !c.body)
157
+ return await this.sendMessage(r, s, o);
158
+ const f = c.body.getReader(), g = new TextDecoder();
159
+ let v = "", h = null;
160
+ for (; ; ) {
161
+ const { done: d, value: p } = await f.read();
162
+ if (d) break;
163
+ v += g.decode(p, { stream: !0 });
164
+ const y = v.split(`
165
+
166
+ `);
167
+ v = y.pop() || "";
168
+ for (const b of y) {
169
+ const F = b.trim();
170
+ if (F.startsWith("data:"))
171
+ try {
172
+ const k = JSON.parse(F.slice(5).trim());
173
+ if (k.type === "progress" && k.stage)
174
+ a == null || a(k.stage);
175
+ else if (k.type === "complete")
176
+ h = {
177
+ requestId: k.request_id,
178
+ sessionId: k.session_id,
179
+ answer: k.answer,
180
+ sources: (k.sources || []).map(je),
181
+ toolCalls: (k.tool_calls || []).map(Ye),
182
+ usage: Je(k.usage)
183
+ };
184
+ else if (k.type === "error")
185
+ throw new Error(k.message || "An error occurred");
186
+ } catch (k) {
187
+ if (!(k instanceof Error && k.message !== "An error occurred"))
188
+ throw k;
189
+ }
190
+ }
191
+ }
192
+ return h || await this.sendMessage(r, s, o);
193
+ } catch {
194
+ return await this.sendMessage(r, s, o);
195
+ }
196
+ },
197
+ async getHistory(r) {
137
198
  try {
138
- return ((await r(
139
- `/api/v1/sessions/${n}/messages`
140
- )).messages || []).map(Tt);
199
+ return ((await n(
200
+ `/api/v1/sessions/${r}/messages`
201
+ )).messages || []).map(Rt);
141
202
  } catch {
142
203
  return [];
143
204
  }
144
205
  },
145
- async closeSession(n) {
206
+ async closeSession(r) {
146
207
  try {
147
- await r(`/api/v1/sessions/${n}`, { method: "DELETE" });
208
+ await n(`/api/v1/sessions/${r}`, { method: "DELETE" });
148
209
  } catch {
149
210
  }
150
211
  },
@@ -153,15 +214,15 @@ function tt(e) {
153
214
  },
154
215
  async checkHealth() {
155
216
  try {
156
- const n = We(t, "/health");
157
- return (await fetch(n)).ok;
217
+ const r = Se(t, "/health");
218
+ return (await fetch(r)).ok;
158
219
  } catch {
159
220
  return !1;
160
221
  }
161
222
  }
162
223
  };
163
224
  }
164
- const pn = tt(), At = [
225
+ const fn = ot(), Bt = [
165
226
  {
166
227
  label: "How do I access my reports?",
167
228
  query: "How do I access my reports in the VPS Customer Portal?"
@@ -178,20 +239,30 @@ const pn = tt(), At = [
178
239
  label: "How do I contact VPS Support?",
179
240
  query: "How can I contact VPS Customer Support?"
180
241
  }
181
- ], Fe = _t(null);
182
- function Bt() {
183
- const e = Qe(Fe);
242
+ ], Be = Ct(null);
243
+ function Mt() {
244
+ const e = nt(Be);
184
245
  if (!e)
185
246
  throw new Error("useChatbot must be used inside ChatProvider.");
186
247
  return e;
187
248
  }
188
- function rt() {
189
- return Qe(Fe);
190
- }
191
- function je(e) {
249
+ function Me() {
250
+ return nt(Be);
251
+ }
252
+ const Dt = `Hello! I am your **VPS Veritas assistant**.
253
+
254
+ I can help you with:
255
+ - **Fuel Quality Testing (FQT)** & **Oil Condition Monitoring (OCM)**
256
+ - **Fuel Defect Reporting (FDR)** — report and track bunker defect incidents
257
+ - **Bunker Master** — manage bunkering operations, BDN logs, and surveys
258
+ - **FSC & FSQ E-Forms** — paperless fuel system checks and bunker sample pre-registration
259
+ - **Samplogic** sample logistics, report downloads, and support tickets
260
+
261
+ Feel free to ask a question or select one of the suggested topics below!`;
262
+ function Ze(e) {
192
263
  return `${e}-${crypto.randomUUID()}`;
193
264
  }
194
- function Dt(e) {
265
+ function It(e) {
195
266
  if (e && typeof e == "object" && "message" in e) {
196
267
  const t = String(e.message);
197
268
  if (t && !/traceback|sql|exception|stack|api[_ ]?key|password/i.test(t))
@@ -199,129 +270,172 @@ function Dt(e) {
199
270
  }
200
271
  return "I couldn't process that request right now.";
201
272
  }
202
- const nt = ({
273
+ const lt = ({
203
274
  children: e,
204
275
  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
276
+ role: n,
277
+ roleId: r,
278
+ client: s,
279
+ welcomeMessage: o,
280
+ suggestions: a = Bt,
281
+ disableSuggestions: i = !1,
282
+ initialMessage: c,
283
+ apiBaseUrl: f,
284
+ apiUrl: g,
285
+ proxyUrl: v,
286
+ api: h,
287
+ hideInspectSources: d = !1,
288
+ showGroundedSources: p = !0
212
289
  }) => {
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"),
290
+ const y = f ?? g ?? v, b = he(
291
+ () => h ?? ot(y),
292
+ [h, y]
293
+ ), F = he(() => ({
294
+ ...t,
295
+ ...n !== void 0 ? { role: n } : {},
296
+ ...r !== void 0 ? { roleId: r } : {},
297
+ ...s !== void 0 ? { client: s } : {}
298
+ }), [t, n, r, s]), k = he(() => o === "" ? null : {
299
+ id: "welcome-default",
300
+ role: "assistant",
301
+ content: o || Dt,
302
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
303
+ status: "complete"
304
+ }, [o]), [D, j] = K(null), [I, N] = K(() => k ? [k] : []), [E, L] = K("idle"), [q, te] = K(null), Y = se(null), _ = se(!1), S = le(async () => {
305
+ if (D) return D;
306
+ L("connecting");
307
+ const W = await b.createSession();
308
+ return j(W.sessionId), W.sessionId;
309
+ }, [D, b]), R = le(
310
+ async (W) => {
311
+ Y.current = W;
312
+ const Q = {
313
+ id: Ze("user"),
226
314
  role: "user",
227
- content: _,
315
+ content: W,
228
316
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
229
317
  status: "complete"
230
- }, S = je("asst"), A = {
231
- id: S,
318
+ }, X = Ze("asst"), J = {
319
+ id: X,
232
320
  role: "assistant",
233
321
  content: "",
234
322
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
235
- status: "pending"
323
+ status: "pending",
324
+ progressText: "Analyzing question & expanding domain terms "
325
+ };
326
+ N((A) => [...A, Q, J]), L("awaiting"), te(null);
327
+ const oe = (A) => {
328
+ N(
329
+ ($) => $.map(
330
+ (Z) => Z.id === X ? { ...Z, progressText: A } : Z
331
+ )
332
+ );
236
333
  };
237
- g((R) => [...R, k, A]), v("awaiting"), W(null);
238
334
  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,
335
+ const A = await S(), $ = b.sendMessageStream ? await b.sendMessageStream(
336
+ A,
337
+ W,
338
+ {
339
+ roleId: F.roleId,
340
+ client: F.client
341
+ },
342
+ (Z) => {
343
+ oe(Z);
344
+ }
345
+ ) : await b.sendMessage(A, W, {
346
+ roleId: F.roleId,
347
+ client: F.client
348
+ });
349
+ N(
350
+ (Z) => Z.map(
351
+ (U) => U.id === X ? {
352
+ ...U,
353
+ id: $.requestId || X,
354
+ content: $.answer,
246
355
  status: "complete",
247
- sources: F.sources,
248
- toolCalls: F.toolCalls,
249
- usage: F.usage
250
- } : H
356
+ progressText: void 0,
357
+ sources: $.sources,
358
+ toolCalls: $.toolCalls,
359
+ usage: $.usage
360
+ } : U
251
361
  )
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
362
+ ), L("idle");
363
+ } catch (A) {
364
+ const $ = It(A);
365
+ N(
366
+ (Z) => Z.map(
367
+ (U) => U.id === X ? { ...U, content: $, status: "error", progressText: void 0 } : U
258
368
  )
259
- ), W(F), v("error");
369
+ ), te($), L("error");
260
370
  }
261
371
  },
262
- [N, m]
263
- ), T = Q(
264
- async (_) => {
265
- const k = _.trim();
266
- !k || E === "awaiting" || E === "connecting" || await M(k);
372
+ [S, b, F.client, F.roleId]
373
+ ), B = le(
374
+ async (W) => {
375
+ const Q = W.trim();
376
+ !Q || E === "awaiting" || E === "connecting" || await R(Q);
267
377
  },
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(
378
+ [R, E]
379
+ ), M = le(async () => {
380
+ const W = Y.current;
381
+ W && (N((Q) => Q.filter((X) => X.status !== "error")), await R(W));
382
+ }, [R]), P = le(async () => {
383
+ }, []), x = le(() => {
384
+ }, []), G = le(async () => {
385
+ D && await b.closeSession(D), j(null), N(k ? [k] : []), L("idle"), te(null), Y.current = null;
386
+ }, [D, b, k]);
387
+ Ae.useEffect(() => {
388
+ !c || _.current || (_.current = !0, B(c));
389
+ }, [c, B]);
390
+ const re = he(
281
391
  () => ({
282
- messages: u,
392
+ messages: I,
283
393
  status: E,
284
- error: B,
285
- sessionId: y,
394
+ error: q,
395
+ sessionId: D,
286
396
  pendingTicket: null,
287
397
  ticketBusy: !1,
288
398
  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
399
+ suggestions: a,
400
+ showSuggestions: !i && (I.length === 0 || I.length === 1 && I[0].id === "welcome-default"),
401
+ suggestionBadgesEnabled: !i,
402
+ userContext: F,
403
+ apiBaseUrl: b.apiBaseUrl,
404
+ hideInspectSources: d,
405
+ showGroundedSources: p,
406
+ sendMessage: B,
407
+ retryLast: M,
408
+ confirmTicket: P,
409
+ cancelTicket: x,
410
+ resetConversation: G
299
411
  }),
300
412
  [
301
- u,
413
+ I,
302
414
  E,
415
+ q,
416
+ D,
417
+ a,
418
+ i,
419
+ F,
420
+ b.apiBaseUrl,
421
+ d,
422
+ p,
303
423
  B,
304
- y,
305
- r,
306
- n,
307
- t,
308
- m.apiBaseUrl,
309
- T,
310
- z,
311
- I,
312
- J,
313
- U
424
+ M,
425
+ P,
426
+ x,
427
+ G
314
428
  ]
315
429
  );
316
- return /* @__PURE__ */ l(Fe.Provider, { value: b, children: e });
430
+ return /* @__PURE__ */ l(Be.Provider, { value: re, children: e });
317
431
  };
318
- function ye() {
319
- return Bt();
432
+ function Ce() {
433
+ return Mt();
320
434
  }
321
- const Mt = ({ message: e, onRetry: t }) => /* @__PURE__ */ C(
435
+ const Nt = ({ message: e, onRetry: t }) => /* @__PURE__ */ T(
322
436
  "div",
323
437
  {
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)]",
438
+ className: "chat-error-banner",
325
439
  role: "alert",
326
440
  children: [
327
441
  /* @__PURE__ */ l("p", { children: e }),
@@ -330,7 +444,7 @@ const Mt = ({ message: e, onRetry: t }) => /* @__PURE__ */ C(
330
444
  {
331
445
  type: "button",
332
446
  onClick: t,
333
- className: "mt-1.5 text-[12px] font-semibold underline underline-offset-2",
447
+ className: "chat-error-retry-btn",
334
448
  children: "Try again"
335
449
  }
336
450
  )
@@ -343,14 +457,14 @@ const Mt = ({ message: e, onRetry: t }) => /* @__PURE__ */ C(
343
457
  * This source code is licensed under the ISC license.
344
458
  * See the LICENSE file in the root directory of this source tree.
345
459
  */
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();
460
+ const Pt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), at = (...e) => e.filter((t, n, r) => !!t && t.trim() !== "" && r.indexOf(t) === n).join(" ").trim();
347
461
  /**
348
462
  * @license lucide-react v0.468.0 - ISC
349
463
  *
350
464
  * This source code is licensed under the ISC license.
351
465
  * See the LICENSE file in the root directory of this source tree.
352
466
  */
353
- var Nt = {
467
+ var xt = {
354
468
  xmlns: "http://www.w3.org/2000/svg",
355
469
  width: 24,
356
470
  height: 24,
@@ -367,31 +481,31 @@ var Nt = {
367
481
  * This source code is licensed under the ISC license.
368
482
  * See the LICENSE file in the root directory of this source tree.
369
483
  */
370
- const Pt = et(
484
+ const Lt = st(
371
485
  ({
372
486
  color: e = "currentColor",
373
487
  size: t = 24,
374
- strokeWidth: r = 2,
375
- absoluteStrokeWidth: n,
376
- className: o = "",
377
- children: s,
488
+ strokeWidth: n = 2,
489
+ absoluteStrokeWidth: r,
490
+ className: s = "",
491
+ children: o,
378
492
  iconNode: a,
379
493
  ...i
380
- }, d) => Ce(
494
+ }, c) => Fe(
381
495
  "svg",
382
496
  {
383
- ref: d,
384
- ...Nt,
497
+ ref: c,
498
+ ...xt,
385
499
  width: t,
386
500
  height: t,
387
501
  stroke: e,
388
- strokeWidth: n ? Number(r) * 24 / Number(t) : r,
389
- className: ot("lucide", o),
502
+ strokeWidth: r ? Number(n) * 24 / Number(t) : n,
503
+ className: at("lucide", s),
390
504
  ...i
391
505
  },
392
506
  [
393
- ...a.map(([p, m]) => Ce(p, m)),
394
- ...Array.isArray(s) ? s : [s]
507
+ ...a.map(([f, g]) => Fe(f, g)),
508
+ ...Array.isArray(o) ? o : [o]
395
509
  ]
396
510
  )
397
511
  );
@@ -401,16 +515,16 @@ const Pt = et(
401
515
  * This source code is licensed under the ISC license.
402
516
  * See the LICENSE file in the root directory of this source tree.
403
517
  */
404
- const O = (e, t) => {
405
- const r = et(
406
- ({ className: n, ...o }, s) => Ce(Pt, {
407
- ref: s,
518
+ const z = (e, t) => {
519
+ const n = st(
520
+ ({ className: r, ...s }, o) => Fe(Lt, {
521
+ ref: o,
408
522
  iconNode: t,
409
- className: ot(`lucide-${It(e)}`, n),
410
- ...o
523
+ className: at(`lucide-${Pt(e)}`, r),
524
+ ...s
411
525
  })
412
526
  );
413
- return r.displayName = `${e}`, r;
527
+ return n.displayName = `${e}`, n;
414
528
  };
415
529
  /**
416
530
  * @license lucide-react v0.468.0 - ISC
@@ -418,7 +532,7 @@ const O = (e, t) => {
418
532
  * This source code is licensed under the ISC license.
419
533
  * See the LICENSE file in the root directory of this source tree.
420
534
  */
421
- const Lt = O("ArrowDown", [
535
+ const Ot = z("ArrowDown", [
422
536
  ["path", { d: "M12 5v14", key: "s699le" }],
423
537
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
424
538
  ]);
@@ -428,7 +542,7 @@ const Lt = O("ArrowDown", [
428
542
  * This source code is licensed under the ISC license.
429
543
  * See the LICENSE file in the root directory of this source tree.
430
544
  */
431
- const zt = O("ArrowLeft", [
545
+ const qt = z("ArrowLeft", [
432
546
  ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
433
547
  ["path", { d: "M19 12H5", key: "x3x0zl" }]
434
548
  ]);
@@ -438,7 +552,7 @@ const zt = O("ArrowLeft", [
438
552
  * This source code is licensed under the ISC license.
439
553
  * See the LICENSE file in the root directory of this source tree.
440
554
  */
441
- const Ot = O("ArrowUp", [
555
+ const Wt = z("ArrowUp", [
442
556
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
443
557
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
444
558
  ]);
@@ -448,7 +562,7 @@ const Ot = O("ArrowUp", [
448
562
  * This source code is licensed under the ISC license.
449
563
  * See the LICENSE file in the root directory of this source tree.
450
564
  */
451
- const st = O("BotMessageSquare", [
565
+ const it = z("BotMessageSquare", [
452
566
  ["path", { d: "M12 6V2H8", key: "1155em" }],
453
567
  ["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
568
  ["path", { d: "M2 12h2", key: "1t8f8n" }],
@@ -462,15 +576,28 @@ const st = O("BotMessageSquare", [
462
576
  * This source code is licensed under the ISC license.
463
577
  * See the LICENSE file in the root directory of this source tree.
464
578
  */
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" }]
579
+ const $t = z("Brain", [
580
+ [
581
+ "path",
582
+ {
583
+ d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",
584
+ key: "l5xja"
585
+ }
586
+ ],
587
+ [
588
+ "path",
589
+ {
590
+ d: "M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",
591
+ key: "ep3f8r"
592
+ }
593
+ ],
594
+ ["path", { d: "M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4", key: "1p4c4q" }],
595
+ ["path", { d: "M17.599 6.5a3 3 0 0 0 .399-1.375", key: "tmeiqw" }],
596
+ ["path", { d: "M6.003 5.125A3 3 0 0 0 6.401 6.5", key: "105sqy" }],
597
+ ["path", { d: "M3.477 10.896a4 4 0 0 1 .585-.396", key: "ql3yin" }],
598
+ ["path", { d: "M19.938 10.5a4 4 0 0 1 .585.396", key: "1qfode" }],
599
+ ["path", { d: "M6 18a4 4 0 0 1-1.967-.516", key: "2e4loj" }],
600
+ ["path", { d: "M19.967 17.484A4 4 0 0 1 18 18", key: "159ez6" }]
474
601
  ]);
475
602
  /**
476
603
  * @license lucide-react v0.468.0 - ISC
@@ -478,14 +605,14 @@ const qt = O("ChevronDown", [
478
605
  * This source code is licensed under the ISC license.
479
606
  * See the LICENSE file in the root directory of this source tree.
480
607
  */
481
- const Gt = O("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
608
+ const Ht = z("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
482
609
  /**
483
610
  * @license lucide-react v0.468.0 - ISC
484
611
  *
485
612
  * This source code is licensed under the ISC license.
486
613
  * See the LICENSE file in the root directory of this source tree.
487
614
  */
488
- const Vt = O("ClipboardCheck", [
615
+ const Vt = z("ClipboardCheck", [
489
616
  ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
490
617
  [
491
618
  "path",
@@ -502,20 +629,7 @@ const Vt = O("ClipboardCheck", [
502
629
  * This source code is licensed under the ISC license.
503
630
  * See the LICENSE file in the root directory of this source tree.
504
631
  */
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", [
632
+ const zt = z("FlaskConical", [
519
633
  [
520
634
  "path",
521
635
  {
@@ -532,7 +646,7 @@ const jt = O("FlaskConical", [
532
646
  * This source code is licensed under the ISC license.
533
647
  * See the LICENSE file in the root directory of this source tree.
534
648
  */
535
- const lt = O("MessageSquare", [
649
+ const ct = z("MessageSquare", [
536
650
  ["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
651
  ]);
538
652
  /**
@@ -541,7 +655,7 @@ const lt = O("MessageSquare", [
541
655
  * This source code is licensed under the ISC license.
542
656
  * See the LICENSE file in the root directory of this source tree.
543
657
  */
544
- const $t = O("Microscope", [
658
+ const Gt = z("Microscope", [
545
659
  ["path", { d: "M6 18h8", key: "1borvv" }],
546
660
  ["path", { d: "M3 22h18", key: "8prr45" }],
547
661
  ["path", { d: "M14 22a7 7 0 1 0 0-14h-1", key: "1jwaiy" }],
@@ -555,14 +669,14 @@ const $t = O("Microscope", [
555
669
  * This source code is licensed under the ISC license.
556
670
  * See the LICENSE file in the root directory of this source tree.
557
671
  */
558
- const Ut = O("Minus", [["path", { d: "M5 12h14", key: "1ays0h" }]]);
672
+ const Ut = z("Minus", [["path", { d: "M5 12h14", key: "1ays0h" }]]);
559
673
  /**
560
674
  * @license lucide-react v0.468.0 - ISC
561
675
  *
562
676
  * This source code is licensed under the ISC license.
563
677
  * See the LICENSE file in the root directory of this source tree.
564
678
  */
565
- const Yt = O("RefreshCw", [
679
+ const jt = z("RefreshCw", [
566
680
  ["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
681
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
568
682
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
@@ -574,7 +688,7 @@ const Yt = O("RefreshCw", [
574
688
  * This source code is licensed under the ISC license.
575
689
  * See the LICENSE file in the root directory of this source tree.
576
690
  */
577
- const Zt = O("TestTubeDiagonal", [
691
+ const Yt = z("TestTubeDiagonal", [
578
692
  [
579
693
  "path",
580
694
  { 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" }
@@ -588,25 +702,25 @@ const Zt = O("TestTubeDiagonal", [
588
702
  * This source code is licensed under the ISC license.
589
703
  * See the LICENSE file in the root directory of this source tree.
590
704
  */
591
- const Jt = O("X", [
705
+ const Jt = z("X", [
592
706
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
593
707
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
594
- ]), Kt = {
708
+ ]), Zt = {
595
709
  alpha: {
596
710
  label: "Alpha",
597
- Icon: jt,
711
+ Icon: zt,
598
712
  variant: "env-badge--alpha",
599
713
  tooltip: "Alpha build — internal testing only"
600
714
  },
601
715
  beta: {
602
716
  label: "Beta",
603
- Icon: Zt,
717
+ Icon: Yt,
604
718
  variant: "env-badge--beta",
605
719
  tooltip: "Beta build — public pre-release"
606
720
  },
607
721
  gamma: {
608
722
  label: "Gamma",
609
- Icon: $t,
723
+ Icon: Gt,
610
724
  variant: "env-badge--gamma",
611
725
  tooltip: "Gamma / Release Candidate"
612
726
  },
@@ -616,23 +730,23 @@ const Jt = O("X", [
616
730
  variant: "env-badge--qa",
617
731
  tooltip: "Quality Assurance build"
618
732
  }
619
- }, Xt = ({
733
+ }, Kt = ({
620
734
  stage: e,
621
735
  pulse: t = !0,
622
- className: r = ""
736
+ className: n = ""
623
737
  }) => {
624
738
  if (!e) return null;
625
- const { label: n, Icon: o, variant: s, tooltip: a } = Kt[e];
626
- return /* @__PURE__ */ C(
739
+ const { label: r, Icon: s, variant: o, tooltip: a } = Zt[e];
740
+ return /* @__PURE__ */ T(
627
741
  "span",
628
742
  {
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 `,
743
+ className: `env-badge-inline ${o} ${n}`.trim(),
630
744
  title: a,
631
- "aria-label": `${n} build`,
745
+ "aria-label": `${r} build`,
632
746
  role: "status",
633
747
  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 })
748
+ /* @__PURE__ */ l(s, { size: 10, className: "env-badge-icon", "aria-hidden": "true" }),
749
+ /* @__PURE__ */ l("span", { className: "env-badge-inline-label", children: r })
636
750
  ]
637
751
  }
638
752
  );
@@ -648,781 +762,759 @@ const Jt = O("X", [
648
762
  ...e,
649
763
  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
764
  }
651
- ), er = ({
765
+ ), Xt = ({
652
766
  title: e = "VPS AI Assistant",
653
767
  subtitle: t = "Customer portal support",
654
- onClose: r,
655
- onReset: n,
656
- onBack: o,
657
- showMinimize: s = !1,
768
+ onClose: n,
769
+ onReset: r,
770
+ onBack: s,
771
+ showMinimize: o = !1,
658
772
  envStage: a,
659
773
  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(
774
+ }) => /* @__PURE__ */ T("header", { className: "chat-header", children: [
775
+ /* @__PURE__ */ T("div", { className: "chat-header-left", children: [
776
+ s && /* @__PURE__ */ l(
663
777
  "button",
664
778
  {
665
779
  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)]",
780
+ onClick: s,
781
+ className: "icon-btn-back",
668
782
  "aria-label": "Back",
669
- children: /* @__PURE__ */ l(zt, { size: 16 })
783
+ children: /* @__PURE__ */ l(qt, { size: 16 })
670
784
  }
671
785
  ),
672
786
  /* @__PURE__ */ l(
673
787
  "div",
674
788
  {
675
- className: "flex h-8 w-8 items-center justify-center rounded-full bg-primary text-primary-foreground",
789
+ className: "avatar-circle",
676
790
  "aria-hidden": "true",
677
- children: /* @__PURE__ */ l(Qt, { width: "16px", height: "16px", Color: "white" })
791
+ children: /* @__PURE__ */ l(Qt, { width: "16px", height: "16px", color: "white" })
678
792
  }
679
793
  ),
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 })
794
+ /* @__PURE__ */ T("div", { children: [
795
+ /* @__PURE__ */ T("div", { className: "chat-header-title-row", children: [
796
+ /* @__PURE__ */ l("h2", { className: "chat-header-title", children: e }),
797
+ /* @__PURE__ */ l(Kt, { stage: a, pulse: i })
684
798
  ] }),
685
- /* @__PURE__ */ l("p", { className: "text-[12px] text-muted-foreground font-medium text-[var(--text-subtle)]", children: t || "Customer portal support" })
799
+ /* @__PURE__ */ l("p", { className: "chat-header-subtitle", children: t || "Customer portal support" })
686
800
  ] })
687
801
  ] }),
688
- /* @__PURE__ */ C("div", { className: "flex items-center gap-1", children: [
689
- n && /* @__PURE__ */ l(
802
+ /* @__PURE__ */ T("div", { className: "chat-header-actions", children: [
803
+ r && /* @__PURE__ */ l(
690
804
  "button",
691
805
  {
692
806
  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",
807
+ onClick: r,
808
+ className: "icon-btn-action",
695
809
  "aria-label": "Start a new conversation",
696
810
  title: "New conversation",
697
- children: /* @__PURE__ */ l(Yt, { size: 15 })
811
+ children: /* @__PURE__ */ l(jt, { size: 15 })
698
812
  }
699
813
  ),
700
- r && /* @__PURE__ */ l(
814
+ n && /* @__PURE__ */ l(
701
815
  "button",
702
816
  {
703
817
  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",
818
+ onClick: n,
819
+ className: "icon-btn-action",
820
+ "aria-label": o ? "Minimize chat" : "Close chat",
707
821
  children: /* @__PURE__ */ l(Ut, { size: 16 })
708
822
  }
709
823
  )
710
824
  ] })
711
825
  ] });
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;
826
+ function er(e, t) {
827
+ const n = se(e);
828
+ ie(() => {
829
+ var r;
830
+ n.current && !e && ((r = t.current) == null || r.focus()), n.current = e;
717
831
  }, [e, t]);
718
832
  }
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)
833
+ function tr(e, t) {
834
+ const n = t.trim().toLowerCase();
835
+ return n ? e.filter(
836
+ (r) => r.label.toLowerCase().includes(n) || r.query.toLowerCase().includes(n)
739
837
  ) : e;
740
838
  }
741
- const or = ({
839
+ const rr = ({
742
840
  suggestions: e,
743
841
  onSelect: t,
744
- disabled: r,
745
- variant: n = "list"
746
- }) => e.length ? n === "badge" ? /* @__PURE__ */ l(
842
+ disabled: n,
843
+ variant: r = "list"
844
+ }) => e.length ? r === "badge" ? /* @__PURE__ */ l(
747
845
  "ul",
748
846
  {
749
- className: "mb-2 flex flex-wrap gap-1.5",
847
+ className: "suggestions-badge-list",
750
848
  "aria-label": "Suggested questions",
751
- children: e.map((o) => /* @__PURE__ */ l("li", { className: "max-w-full", children: /* @__PURE__ */ l(
849
+ children: e.map((s) => /* @__PURE__ */ l("li", { className: "suggestion-badge-item", children: /* @__PURE__ */ l(
752
850
  "button",
753
851
  {
754
852
  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
853
+ disabled: n,
854
+ onClick: () => t(s),
855
+ title: s.query,
856
+ className: "suggestion-badge-btn",
857
+ children: s.label
764
858
  }
765
- ) }, o.query))
859
+ ) }, s.query))
766
860
  }
767
- ) : /* @__PURE__ */ l("div", { className: "mt-3 flex flex-col gap-2", children: e.map((o) => /* @__PURE__ */ l(
861
+ ) : /* @__PURE__ */ l("div", { className: "suggestions-list", children: e.map((s) => /* @__PURE__ */ l(
768
862
  "button",
769
863
  {
770
864
  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
865
+ disabled: n,
866
+ onClick: () => t(s),
867
+ className: "suggestion-list-btn",
868
+ children: s.label
775
869
  },
776
- o.query
777
- )) }) : null, sr = ({
870
+ s.query
871
+ )) }) : null, nr = ({
778
872
  onSend: e,
779
873
  disabled: t = !1,
780
- placeholder: r = "Ask something…"
874
+ placeholder: n = "Ask something…"
781
875
  }) => {
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`);
876
+ const { suggestions: r, showSuggestions: s, suggestionBadgesEnabled: o } = Ce(), [a, i] = K(""), c = se(null), f = (d) => {
877
+ d && (d.style.height = "auto", d.style.height = `${Math.min(d.scrollHeight, 96)}px`);
784
878
  };
785
- tr(t, d), ge(() => {
786
- p(d.current);
879
+ er(t, c), ie(() => {
880
+ f(c.current);
787
881
  }, [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"));
882
+ const g = he(() => {
883
+ if (!o || t) return [];
884
+ const d = a.trim();
885
+ return d ? tr(r, d) : s ? r : [];
886
+ }, [t, s, o, r, a]), v = (d) => {
887
+ i(d.query);
888
+ const p = c.current;
889
+ p == null || p.focus();
890
+ }, h = () => {
891
+ const d = a.trim();
892
+ !d || t || (e(d), i(""), c.current && (c.current.style.height = "auto"));
799
893
  };
800
- return /* @__PURE__ */ C("div", { className: "bg-card px-4 pb-3 pt-2", children: [
894
+ return /* @__PURE__ */ T("div", { className: "chat-input-wrapper", children: [
801
895
  /* @__PURE__ */ l(
802
- or,
896
+ rr,
803
897
  {
804
898
  variant: "badge",
805
- suggestions: m,
806
- onSelect: y,
899
+ suggestions: g,
900
+ onSelect: v,
807
901
  disabled: t
808
902
  }
809
903
  ),
810
904
  /* @__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: [
905
+ /* @__PURE__ */ T("div", { className: "chat-input-row", children: [
812
906
  /* @__PURE__ */ l(
813
907
  "textarea",
814
908
  {
815
909
  id: "vps-chat-input",
816
- ref: d,
910
+ ref: c,
817
911
  rows: 1,
818
912
  value: a,
819
913
  disabled: t,
820
- placeholder: r,
821
- onChange: (u) => {
822
- i(u.target.value), p(u.target);
914
+ placeholder: n,
915
+ onChange: (d) => {
916
+ i(d.target.value), f(d.target);
823
917
  },
824
- onKeyDown: (u) => {
825
- u.key === "Enter" && !u.shiftKey && (u.preventDefault(), f());
918
+ onKeyDown: (d) => {
919
+ d.key === "Enter" && !d.shiftKey && (d.preventDefault(), h());
826
920
  },
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"
921
+ className: "chat-textarea"
828
922
  }
829
923
  ),
830
924
  /* @__PURE__ */ l(
831
925
  "button",
832
926
  {
833
927
  type: "button",
834
- onClick: f,
928
+ onClick: h,
835
929
  disabled: t || !a.trim(),
836
930
  "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 })
931
+ className: "chat-send-btn",
932
+ children: /* @__PURE__ */ l(Wt, { size: 16 })
839
933
  }
840
934
  )
841
935
  ] }),
842
- /* @__PURE__ */ C("p", { className: "mt-2 text-center text-[11px] font-medium text-[var(--text-subtle)]", children: [
936
+ /* @__PURE__ */ T("p", { className: "chat-input-footer", children: [
843
937
  "Powered by ",
844
- /* @__PURE__ */ l("span", { className: "text-primary font-bold hover:underline cursor-pointer", children: "VPS Veritas AI" })
938
+ /* @__PURE__ */ l("span", { className: "chat-input-footer-brand", children: "VPS Veritas AI" })
845
939
  ] })
846
940
  ] });
847
941
  };
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) {
942
+ function sr({ defaultTagName: e, props: t, render: n, state: r = {}, stateAttributesMapping: s }) {
943
+ let o = Ee(or(r, s), t);
944
+ if (!n) return u.createElement(e, o);
945
+ if (typeof n == "function") return n(o, r);
946
+ if (!u.isValidElement(n)) return null;
947
+ let a = n.props, i = { ...Ee(o, a), ref: pe(o.ref, a.ref) };
948
+ return u.cloneElement(n, i);
949
+ }
950
+ function Ee(...e) {
857
951
  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;
952
+ for (let n of e) {
953
+ if (!n) continue;
954
+ let r = n;
955
+ for (let s of Object.keys(r)) {
956
+ let o = r[s];
957
+ if (o === void 0) continue;
958
+ let a = t[s];
959
+ s === "className" ? t[s] = [a, o].filter(Boolean).join(" ") : s === "style" ? t[s] = { ...a, ...o } : s === "ref" ? t[s] = pe(a, o) : ar(s) && typeof a == "function" && typeof o == "function" ? t[s] = lr(o, a) : t[s] = o;
866
960
  }
867
961
  }
868
962
  return t;
869
963
  }
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);
964
+ function or(e, t) {
965
+ var r;
966
+ let n = {};
967
+ for (let s of Object.keys(e)) {
968
+ let o = e[s], a = (r = t == null ? void 0 : t[s]) == null ? void 0 : r.call(t, o);
875
969
  if (a) {
876
- Object.assign(r, a);
970
+ Object.assign(n, a);
877
971
  continue;
878
972
  }
879
- if (o === "slot") {
880
- r["data-slot"] = s;
973
+ if (s === "slot") {
974
+ n["data-slot"] = o;
881
975
  continue;
882
976
  }
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));
977
+ let i = `data-${String(s).replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`;
978
+ typeof o == "boolean" ? n[i] = o ? "" : void 0 : o != null && (n[i] = String(o));
885
979
  }
886
- return r;
980
+ return n;
887
981
  }
888
- function ir(e, t) {
889
- return function(r) {
890
- e(r), r.defaultPrevented || t(r);
982
+ function lr(e, t) {
983
+ return function(n) {
984
+ e(n), n.defaultPrevented || t(n);
891
985
  };
892
986
  }
893
- function cr(e) {
987
+ function ar(e) {
894
988
  return /^on[A-Z]/.test(e);
895
989
  }
896
- function ae(...e) {
990
+ function pe(...e) {
897
991
  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);
992
+ if (t.length !== 0) return (n) => {
993
+ for (let r of t) typeof r == "function" ? r(n) : r && (r.current = n);
900
994
  };
901
995
  }
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);
996
+ var ir = 8, cr = 64, ur = 0, we = 0.5, dr = 180, hr = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "End", "Home", "PageDown", "PageUp", " "]), ut = { start: !1, end: !1 }, fr = [], ye = { currentAnchorId: null, visibleMessageIds: fr };
997
+ function pr({ content: e, scrollEdgeThreshold: t, spacer: n, viewport: r }) {
998
+ if (!r || !e) return ut;
999
+ let s = De({ content: e, spacer: n, viewport: r });
1000
+ return { start: r.scrollTop > t, end: s - r.scrollTop - r.clientHeight > t };
1001
+ }
1002
+ function gr({ content: e, scrollMargin: t, scrollPreviousItemPeek: n, spacer: r, viewport: s, visibleMessageIds: o }) {
1003
+ if (!e || !s) return ye;
1004
+ let a = s.getBoundingClientRect(), i = a.top + t + n, c = typeof IntersectionObserver > "u", f = [], g = null;
1005
+ for (let v of fe(e, r)) {
1006
+ let h = v.dataset.messageId;
1007
+ if (!h) continue;
1008
+ let d = v.dataset.scrollAnchor === "true", p = d || c ? v.getBoundingClientRect() : null;
1009
+ (c && p ? p.bottom > i && p.top < a.bottom : o.has(h)) && f.push(h), d && p && p.top <= i + we && (g = h);
916
1010
  }
917
- return p.length === 0 && m === null ? ve : { currentAnchorId: m, visibleMessageIds: p };
1011
+ return f.length === 0 && g === null ? ye : { currentAnchorId: g, visibleMessageIds: f };
918
1012
  }
919
- function se(e, t) {
920
- return Array.from(e.children).filter((r) => r instanceof HTMLElement && r !== t);
1013
+ function fe(e, t) {
1014
+ return Array.from(e.children).filter((n) => n instanceof HTMLElement && n !== t);
921
1015
  }
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;
1016
+ function mr(e, t) {
1017
+ for (let n = t; n < e.length; n++) {
1018
+ let r = e[n];
1019
+ if ((r == null ? void 0 : r.dataset.scrollAnchor) === "true") return r;
926
1020
  }
927
1021
  return null;
928
1022
  }
929
- function yr(e, t) {
930
- for (let r of e) if (r.dataset.scrollAnchor === "true" && !t.has(r)) return r;
1023
+ function br(e, t) {
1024
+ for (let n of e) if (n.dataset.scrollAnchor === "true" && !t.has(n)) return n;
931
1025
  return null;
932
1026
  }
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;
1027
+ function vr(e, t) {
1028
+ var r;
1029
+ let n = 0;
1030
+ for (let s = t; s < e.length; s++) if (((r = e[s]) == null ? void 0 : r.dataset.scrollAnchor) === "true" && (n += 1, n > 1)) return !0;
937
1031
  return !1;
938
1032
  }
939
- function xr(e) {
1033
+ function _r(e) {
940
1034
  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;
1035
+ let n = e[t];
1036
+ if ((n == null ? void 0 : n.dataset.scrollAnchor) === "true") return n;
943
1037
  }
944
1038
  return null;
945
1039
  }
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;
1040
+ function wr({ content: e, spacer: t, viewport: n }) {
1041
+ let r = n.getBoundingClientRect();
1042
+ for (let s of fe(e, t)) {
1043
+ if (!s.dataset.messageId) continue;
1044
+ let o = s.getBoundingClientRect();
1045
+ if (o.bottom > r.top && o.top < r.bottom) return s;
952
1046
  }
953
1047
  return null;
954
1048
  }
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);
1049
+ function yr({ align: e, element: t, scrollMargin: n, spacer: r, viewport: s }) {
1050
+ let o = dt(t, s), a = t.getBoundingClientRect().height, i = Sr(r);
957
1051
  if (e === "center") {
958
- let d = Math.max(0, o.clientHeight - i.start - i.end);
959
- return s - i.start - (d - a) / 2 - r;
1052
+ let c = Math.max(0, s.clientHeight - i.start - i.end);
1053
+ return o - i.start - (c - a) / 2 - n;
960
1054
  }
961
- if (e === "end") return s - o.clientHeight + a + i.end + r;
1055
+ if (e === "end") return o - s.clientHeight + a + i.end + n;
962
1056
  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;
1057
+ let c = o + a, f = s.scrollTop + i.start, g = s.scrollTop + s.clientHeight - i.end;
1058
+ return o >= f && c <= g ? s.scrollTop : o < f ? o - i.start - n : c - s.clientHeight + i.end + n;
965
1059
  }
966
- return s - i.start - r;
1060
+ return o - i.start - n;
967
1061
  }
968
- function ct(e, t) {
969
- let r = e.getBoundingClientRect(), n = t.getBoundingClientRect();
970
- return r.top - n.top + t.scrollTop;
1062
+ function dt(e, t) {
1063
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
1064
+ return n.top - r.top + t.scrollTop;
971
1065
  }
972
- function he(e, t) {
1066
+ function ve(e, t) {
973
1067
  return e.getBoundingClientRect().top - t.getBoundingClientRect().top;
974
1068
  }
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;
1069
+ function kr({ content: e, scrollTop: t, spacer: n, viewport: r }) {
1070
+ let s = De({ content: e, spacer: n, viewport: r });
1071
+ return t + r.clientHeight - s;
978
1072
  }
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);
1073
+ function De({ content: e, spacer: t, viewport: n }) {
1074
+ let r = fe(e, t), s = ht(e), o = n.getBoundingClientRect(), a = n.scrollTop, i = s.start + s.end;
1075
+ for (let c of r) {
1076
+ let f = c.getBoundingClientRect();
1077
+ i = Math.max(i, f.bottom - o.top + a + s.end);
984
1078
  }
985
1079
  return i;
986
1080
  }
987
- function Sr(e) {
1081
+ function Cr(e) {
988
1082
  return Math.max(0, e.scrollHeight - e.clientHeight);
989
1083
  }
990
- function ut(e) {
1084
+ function ht(e) {
991
1085
  let t = window.getComputedStyle(e);
992
- return { end: Se(t.paddingBlockEnd || t.paddingBottom), start: Se(t.paddingBlockStart || t.paddingTop) };
1086
+ return { end: Re(t.paddingBlockEnd || t.paddingBottom), start: Re(t.paddingBlockStart || t.paddingTop) };
993
1087
  }
994
- function Fr(e) {
1088
+ function Sr(e) {
995
1089
  let t = e == null ? void 0 : e.parentElement;
996
- return t ? ut(t) : { end: 0, start: 0 };
1090
+ return t ? ht(t) : { end: 0, start: 0 };
997
1091
  }
998
- function Er(e) {
1092
+ function Tr(e) {
999
1093
  if (!e) return 0;
1000
- let t = window.getComputedStyle(e), r = t.rowGap === "normal" ? t.gap : t.rowGap;
1001
- return Se(r);
1094
+ let t = window.getComputedStyle(e), n = t.rowGap === "normal" ? t.gap : t.rowGap;
1095
+ return Re(n);
1002
1096
  }
1003
- function Se(e) {
1097
+ function Re(e) {
1004
1098
  if (!e) return 0;
1005
1099
  let t = Number.parseFloat(e);
1006
1100
  return Number.isFinite(t) ? t : 0;
1007
1101
  }
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());
1102
+ function ft(e, t) {
1103
+ let n = e, r = /* @__PURE__ */ new Set();
1104
+ return { getSnapshot: () => n, hasListeners: () => r.size > 0, setSnapshot: (s) => {
1105
+ t(n, s) || (n = s, r.forEach((o) => o()));
1106
+ }, subscribe: (s, o, a) => {
1107
+ let i = r.size === 0;
1108
+ return r.add(s), i && (o == null || o()), () => {
1109
+ r.delete(s), r.size === 0 && (a == null || a());
1016
1110
  };
1017
1111
  } };
1018
1112
  }
1019
- function $e(e, t) {
1020
- return dt(e, t);
1113
+ function Ke(e, t) {
1114
+ return ft(e, t);
1021
1115
  }
1022
- function Tr() {
1023
- return dt(ve, Ar);
1116
+ function Fr() {
1117
+ return ft(ye, Rr);
1024
1118
  }
1025
- function Rr(e, t) {
1119
+ function Er(e, t) {
1026
1120
  return e.start === t.start && e.end === t.end;
1027
1121
  }
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]);
1122
+ function Rr(e, t) {
1123
+ return e.currentAnchorId !== t.currentAnchorId || e.visibleMessageIds.length !== t.visibleMessageIds.length ? !1 : e.visibleMessageIds.every((n, r) => n === t.visibleMessageIds[r]);
1030
1124
  }
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 };
1125
+ function Ar({ autoScroll: e, defaultScrollPosition: t, scrollEdgeThreshold: n, scrollMargin: r, scrollPreviousItemPeek: s }) {
1126
+ let o = u.useRef(e), a = u.useRef(!1), i = u.useRef(null), c = u.useRef(!1), f = u.useRef(n), g = u.useRef(0), v = u.useRef(null), h = u.useRef(0), d = u.useRef(e ? "following-bottom" : "free-scrolling"), p = u.useRef(/* @__PURE__ */ new Map()), y = u.useRef(null), b = u.useRef(null), F = u.useRef(null), k = u.useRef(s), D = u.useRef(!0), j = u.useRef(null), I = u.useRef(r), N = u.useRef(null), E = u.useRef(0), L = u.useRef(0), q = u.useRef(null), te = u.useRef(null), Y = u.useRef(null), _ = u.useRef(null), S = u.useRef(null), R = u.useRef(null), B = u.useRef(null), M = u.useRef(null), P = u.useRef(null), x = u.useRef(/* @__PURE__ */ new Set()), G = u.useRef(/* @__PURE__ */ new WeakSet());
1127
+ return Y.current === null && (Y.current = Ke(t === "end" || t === "last-anchor", (re, W) => re === W)), _.current === null && (_.current = Ke(ut, Er)), P.current === null && (P.current = Fr()), o.current = e, f.current = n, I.current = r, k.current = s, { autoScrollRef: o, autoscrollingRef: a, autoscrollingTimeoutRef: S, streamingTurnRef: F, contentRef: i, defaultScrollPositionAppliedRef: c, firstItemRef: v, itemCountRef: g, lastScrollTopRef: h, messageElementsRef: p, modeRef: d, pendingScrollFrameRef: N, pendingScrollToMessageRef: y, prependRestoreRef: b, preserveScrollOnPrependRef: D, pendingDefaultScrollStore: Y.current, rootRef: j, scrollEdgeThresholdRef: f, scrollMarginRef: I, scrollPreviousItemPeekRef: k, spacerGapRef: E, spacerHeightRef: L, spacerRef: q, stateFrameRef: te, stateStore: _.current, viewportRef: R, visibilityFrameRef: B, visibilityObserverRef: M, visibilityStore: P.current, visibleMessageIdsRef: x, handledScrollAnchorsRef: G };
1034
1128
  }
1035
- function ft(e) {
1129
+ function pt(e) {
1036
1130
  e.pendingDefaultScrollStore.setSnapshot(!1);
1037
1131
  }
1038
- function me(e) {
1039
- e.defaultScrollPositionAppliedRef.current = !0, ft(e);
1132
+ function _e(e) {
1133
+ e.defaultScrollPositionAppliedRef.current = !0, pt(e);
1040
1134
  }
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(() => {
1135
+ function Br({ refs: e, commitScrollState: t, scheduleStateCommit: n, scheduleVisibilitySync: r }) {
1136
+ let { streamingTurnRef: s, autoScrollRef: o, autoscrollingRef: a, autoscrollingTimeoutRef: i, contentRef: c, itemCountRef: f, messageElementsRef: g, modeRef: v, pendingScrollToMessageRef: h, prependRestoreRef: d, scrollMarginRef: p, scrollPreviousItemPeekRef: y, spacerGapRef: b, spacerHeightRef: F, spacerRef: k, viewportRef: D } = e, j = u.useCallback((_) => {
1137
+ i.current !== null && (window.clearTimeout(i.current), i.current = null), a.current !== _ && (a.current = _, t()), _ && (i.current = window.setTimeout(() => {
1044
1138
  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;
1139
+ }, dr));
1140
+ }, [t]), I = u.useCallback((_) => {
1141
+ let S = k.current;
1053
1142
  if (!S) return;
1054
- let A = Math.max(0, b);
1055
- if (Math.abs(S.scrollTop - A) <= be) {
1056
- S.scrollTop = A, t();
1143
+ let R = Math.max(0, Math.ceil(_));
1144
+ F.current !== R && (F.current = R, S.hidden = R === 0, S.style.height = `${R}px`, S.style.marginTop = R > 0 ? `${-b.current}px` : "");
1145
+ }, []), N = u.useCallback((_, { behavior: S = "auto", autoscrolling: R = !1 } = {}) => {
1146
+ let B = D.current;
1147
+ if (!B) return;
1148
+ let M = Math.max(0, _);
1149
+ if (Math.abs(B.scrollTop - M) <= we) {
1150
+ B.scrollTop = M, t();
1057
1151
  return;
1058
1152
  }
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();
1153
+ R && j(!0), B.scrollTo({ top: M, behavior: S }), n();
1154
+ }, [t, n, j]), E = u.useCallback(({ behavior: _ = "auto" } = {}) => D.current ? (I(0), s.current = null, v.current = "free-scrolling", N(0, { behavior: _ }), r(), !0) : !1, [r, N, I]), L = u.useCallback(({ behavior: _ = "auto" } = {}) => {
1155
+ let S = D.current;
1156
+ return S ? (I(0), s.current = null, v.current = o.current ? "following-bottom" : "free-scrolling", N(Cr(S), { autoscrolling: !0, behavior: _ }), r(), !0) : !1;
1157
+ }, [r, N, I]), q = u.useCallback((_, { align: S = "start", behavior: R = "auto", scrollMargin: B = p.current } = {}, { keepPreviousPeek: M = !1 } = {}) => {
1158
+ let P = c.current, x = D.current;
1159
+ if (!P || !x || !P.contains(_)) return !1;
1160
+ let G = yr({ align: S, element: _, scrollMargin: M ? B + y.current : B, spacer: k.current, viewport: x }), re = kr({ content: P, scrollTop: G, spacer: k.current, viewport: x });
1161
+ return I(re), d.current = { element: _, viewportTop: ve(_, x) }, v.current = M ? "anchored-to-message" : "settling-jump", s.current = M ? _ : null, N(G, { behavior: R }), r(), !0;
1162
+ }, [r, N, I]), te = u.useCallback(() => {
1163
+ let _ = s.current;
1164
+ return !_ || !_.isConnected || v.current !== "anchored-to-message" ? !1 : q(_, { align: "start" }, { keepPreviousPeek: !0 });
1165
+ }, [q]), Y = u.useCallback((_, S) => {
1166
+ let R = g.current.get(_);
1167
+ return R ? (_e(e), q(R, S) ? (h.current = null, !0) : (h.current = { messageId: _, options: S }, !0)) : f.current === 0 ? (h.current = { messageId: _, options: S }, _e(e), !0) : !1;
1168
+ }, [q]);
1169
+ return { flushPendingScrollToMessage: u.useCallback(() => {
1170
+ let _ = h.current;
1171
+ if (!_) return !1;
1172
+ let S = g.current.get(_.messageId);
1173
+ return !S || !q(S, _.options) ? !1 : (h.current = null, _e(e), !0);
1174
+ }, [q]), reanchorToAnchoredMessage: te, scrollToElement: q, scrollToEnd: L, scrollToMessage: Y, scrollToStart: E };
1175
+ }
1176
+ function Qe(e, t) {
1177
+ return u.useCallback((n) => {
1178
+ e.current = n, n && t();
1085
1179
  }, [e, t]);
1086
1180
  }
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();
1181
+ function Mr({ autoScroll: e = !1, defaultScrollPosition: t = "end", scrollEdgeThreshold: n = ir, scrollPreviousItemPeek: r = cr, scrollMargin: s = ur }) {
1182
+ let o = Ar({ autoScroll: e, defaultScrollPosition: t, scrollEdgeThreshold: n, scrollMargin: s, scrollPreviousItemPeek: r }), { streamingTurnRef: a, autoScrollRef: i, autoscrollingRef: c, autoscrollingTimeoutRef: f, contentRef: g, defaultScrollPositionAppliedRef: v, firstItemRef: h, itemCountRef: d, lastScrollTopRef: p, messageElementsRef: y, modeRef: b, pendingScrollFrameRef: F, pendingScrollToMessageRef: k, prependRestoreRef: D, preserveScrollOnPrependRef: j, pendingDefaultScrollStore: I, rootRef: N, scrollEdgeThresholdRef: E, scrollMarginRef: L, scrollPreviousItemPeekRef: q, spacerGapRef: te, spacerHeightRef: Y, spacerRef: _, stateFrameRef: S, stateStore: R, viewportRef: B, visibilityFrameRef: M, visibilityObserverRef: P, visibilityStore: x, visibleMessageIdsRef: G, handledScrollAnchorsRef: re } = o, W = u.useRef(t);
1183
+ W.current !== t && (W.current = t, v.current = !1);
1184
+ let Q = u.useCallback((m) => {
1185
+ let w = N.current, C = B.current, O = [m.start && "start", m.end && "end"].filter(Boolean).join(" "), ne = c.current;
1186
+ for (let V of [w, C]) V && (O ? V.setAttribute("data-scrollable", O) : V.removeAttribute("data-scrollable"), V.toggleAttribute("data-autoscrolling", ne));
1187
+ }, []), X = u.useCallback((m) => {
1188
+ var O;
1189
+ let w = ((O = B.current) == null ? void 0 : O.scrollTop) ?? 0, C = w < p.current - we;
1190
+ p.current = w, i.current && !m.end && b.current !== "settling-jump" && b.current !== "anchored-to-message" ? b.current = "following-bottom" : b.current === "following-bottom" && m.end && C && !c.current && (b.current = "free-scrolling");
1191
+ }, []), J = u.useCallback(() => {
1192
+ let m = pr({ content: g.current, scrollEdgeThreshold: E.current, spacer: _.current, viewport: B.current });
1193
+ X(m);
1194
+ let w = b.current === "following-bottom" ? { ...m, end: !1 } : m;
1195
+ Q(w), R.setSnapshot(w);
1196
+ }, [X, R, Q]), oe = u.useCallback(() => {
1197
+ S.current === null && (S.current = window.requestAnimationFrame(() => {
1198
+ S.current = null, J();
1105
1199
  }));
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 }));
1200
+ }, [J]), A = u.useCallback(() => {
1201
+ x.hasListeners() && M.current === null && (M.current = window.requestAnimationFrame(() => {
1202
+ M.current = null, x.hasListeners() && x.setSnapshot(gr({ content: g.current, scrollMargin: L.current, scrollPreviousItemPeek: q.current, spacer: _.current, viewport: B.current, visibleMessageIds: G.current }));
1109
1203
  }));
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;
1204
+ }, [x]), { flushPendingScrollToMessage: $, reanchorToAnchoredMessage: Z, scrollToElement: U, scrollToEnd: H, scrollToMessage: Ie, scrollToStart: me } = Br({ refs: o, commitScrollState: J, scheduleStateCommit: oe, scheduleVisibilitySync: A }), Ne = u.useCallback(() => {
1205
+ let m = D.current, w = B.current;
1206
+ if (!m || !w || !m.element.isConnected) return !1;
1207
+ let C = ve(m.element, w) - m.viewportTop;
1208
+ return Math.abs(C) <= we ? !1 : (w.scrollTop += C, m.viewportTop = ve(m.element, w), oe(), A(), !0);
1209
+ }, [oe, A]), ae = u.useCallback(() => {
1210
+ let m = g.current, w = B.current;
1211
+ if (!m || !w) {
1212
+ D.current = null;
1119
1213
  return;
1120
1214
  }
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();
1215
+ let C = wr({ content: m, spacer: _.current, viewport: w });
1216
+ D.current = C ? { element: C, viewportTop: ve(C, w) } : null;
1217
+ }, []), Pe = u.useCallback(() => {
1218
+ F.current === null && (F.current = window.requestAnimationFrame(() => {
1219
+ F.current = null, $() && ae();
1126
1220
  }));
1127
- }, [ee, de]), pe = c.useCallback(() => {
1128
- if (!t || y.current || u.current === 0) return !1;
1129
- let h = !1;
1221
+ }, [ae, $]), be = u.useCallback(() => {
1222
+ if (!t || v.current || d.current === 0) return !1;
1223
+ let m = !1;
1130
1224
  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" });
1225
+ let w = g.current, C = B.current, O = w && C ? _r(fe(w, _.current)) : null;
1226
+ if (!w || !C || !O) m = H({ behavior: "auto" });
1133
1227
  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 });
1228
+ let ne = dt(O, C);
1229
+ m = De({ content: w, spacer: _.current, viewport: C }) - ne <= C.clientHeight ? H({ behavior: "auto" }) : U(O, { align: "start" }, { keepPreviousPeek: !0 });
1136
1230
  }
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();
1231
+ } else m = t === "end" ? H({ behavior: "auto" }) : me({ behavior: "auto" });
1232
+ return m ? (_e(o), !0) : !1;
1233
+ }, [t, U, H, me]), xe = u.useCallback(() => {
1234
+ let m = g.current;
1235
+ if (!m) return;
1236
+ let w = fe(m, _.current), C = d.current, O = h.current;
1237
+ d.current = w.length, h.current = w[0] ?? null, (() => {
1238
+ if ($()) return;
1239
+ if (C === 0) {
1240
+ if (be() || w.length > 0 && i.current && H({ behavior: "auto" })) return;
1241
+ J(), A();
1148
1242
  return;
1149
1243
  }
1150
- let K = D ? x.indexOf(D) : -1;
1151
- if ($.current && K > 0) {
1152
- Be();
1244
+ let ne = O ? w.indexOf(O) : -1;
1245
+ if (j.current && ne > 0) {
1246
+ Ne();
1153
1247
  return;
1154
1248
  }
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" });
1249
+ if (w.length > C) {
1250
+ let V = mr(w, C);
1251
+ if (V) {
1252
+ if (i.current && b.current === "following-bottom" && vr(w, C)) {
1253
+ H({ behavior: "auto" });
1160
1254
  return;
1161
1255
  }
1162
- oe(G, { align: "start" }, { keepPreviousPeek: !0 }), H.current.add(G);
1256
+ U(V, { align: "start" }, { keepPreviousPeek: !0 }), re.current.add(V);
1163
1257
  return;
1164
1258
  }
1165
1259
  }
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);
1260
+ if (w.length === C) {
1261
+ let V = br(w, re.current);
1262
+ if (V) {
1263
+ U(V, { align: "start" }, { keepPreviousPeek: !0 }), re.current.add(V);
1170
1264
  return;
1171
1265
  }
1172
1266
  }
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" });
1267
+ b.current === "following-bottom" && i.current ? H({ behavior: "auto" }) : (J(), A());
1268
+ })(), ae();
1269
+ }, [be, ae, J, $, Ne, A, U, H]), Le = u.useCallback(() => {
1270
+ if (b.current === "following-bottom" && i.current) {
1271
+ H({ behavior: "auto" });
1178
1272
  return;
1179
1273
  }
1180
- let h = U.current;
1181
- if (Re()) {
1182
- i.current && h > 0 && U.current === 0 && q({ behavior: "auto" });
1274
+ let m = Y.current;
1275
+ if (Z()) {
1276
+ i.current && m > 0 && Y.current === 0 && H({ behavior: "auto" });
1183
1277
  return;
1184
1278
  }
1185
- ne(), P();
1186
- }, [Re, ne, P, q]), Ne = c.useCallback(() => {
1187
- let h = S.current;
1188
- if (!(!h || !F.hasListeners())) {
1279
+ oe(), A();
1280
+ }, [Z, oe, A, H]), Oe = u.useCallback(() => {
1281
+ let m = B.current;
1282
+ if (!(!m || !x.hasListeners())) {
1189
1283
  if (typeof IntersectionObserver > "u") {
1190
- P();
1284
+ A();
1191
1285
  return;
1192
1286
  }
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));
1287
+ P.current || (P.current = new IntersectionObserver((w) => {
1288
+ for (let C of w) {
1289
+ let O = C.target.dataset.messageId;
1290
+ O && (C.isIntersecting ? G.current.add(O) : G.current.delete(O));
1197
1291
  }
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();
1292
+ A();
1293
+ }, { root: m, rootMargin: `${-(L.current + q.current)}px 0px 0px 0px`, threshold: [0, 0.01, 0.5, 1] })), y.current.forEach((w) => {
1294
+ var C;
1295
+ (C = P.current) == null || C.observe(w);
1296
+ }), A();
1203
1297
  }
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();
1298
+ }, [A, x]), qe = u.useCallback(() => {
1299
+ var m;
1300
+ M.current !== null && (window.cancelAnimationFrame(M.current), M.current = null), (m = P.current) == null || m.disconnect(), P.current = null, G.current.clear(), x.setSnapshot(ye);
1301
+ }, [x]), yt = u.useCallback((m, w, C) => {
1302
+ var O, ne, V;
1303
+ if (w) {
1304
+ y.current.set(m, w), (O = P.current) == null || O.observe(w), A(), ((ne = k.current) == null ? void 0 : ne.messageId) === m && Pe();
1211
1305
  return;
1212
1306
  }
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" });
1307
+ C && y.current.get(m) === C && (y.current.delete(m), G.current.delete(m), (V = P.current) == null || V.unobserve(C), A());
1308
+ }, [Pe, A]), We = u.useCallback(() => {
1309
+ (b.current === "following-bottom" || b.current === "anchored-to-message" || b.current === "settling-jump") && (a.current = null, b.current = "free-scrolling");
1310
+ }, []), $e = u.useCallback(() => Q(R.getSnapshot()), [R, Q]), He = Qe(N, $e), Ve = Qe(B, $e), ze = u.useCallback((m) => {
1311
+ g.current = m;
1312
+ }, []), Ge = u.useCallback((m) => {
1313
+ _.current = m, te.current = Tr((m == null ? void 0 : m.parentElement) ?? null);
1314
+ }, []), Ue = u.useCallback(() => {
1315
+ J(), A(), ae();
1316
+ }, [ae, J, A]), kt = u.useMemo(() => ({ handleContentChange: xe, handleResize: Le, observeVisibility: Oe, pendingDefaultScrollStore: I, preserveScrollOnPrependRef: j, scrollToEnd: H, scrollToMessage: Ie, scrollToStart: me, setContentElement: ze, setRootElement: He, setSpacerElement: Ge, setViewportElement: Ve, stateStore: R, syncAfterScroll: Ue, unobserveVisibility: qe, userScrollIntent: We, viewportRef: B, visibilityStore: x }), [xe, Le, Oe, I, H, Ie, me, ze, He, Ge, Ve, R, Ue, qe, We, x]);
1317
+ return u.useLayoutEffect(() => {
1318
+ be() || d.current === 0 && pt(o);
1319
+ }, [be]), u.useEffect(() => () => {
1320
+ var m;
1321
+ S.current !== null && (window.cancelAnimationFrame(S.current), S.current = null), M.current !== null && (window.cancelAnimationFrame(M.current), M.current = null), f.current !== null && (window.clearTimeout(f.current), f.current = null), F.current !== null && (window.cancelAnimationFrame(F.current), F.current = null), (m = P.current) == null || m.disconnect(), P.current = null;
1322
+ }, []), u.useLayoutEffect(() => {
1323
+ if (e && b.current === "following-bottom" && d.current > 0) {
1324
+ H({ behavior: "auto" });
1231
1325
  return;
1232
1326
  }
1233
- Z();
1234
- }, [e, Z, q]), { context: yt, registerMessage: vt };
1327
+ J();
1328
+ }, [e, J, H]), { context: kt, registerMessage: yt };
1235
1329
  }
1236
- function Ir(e) {
1237
- let t = c.useRef(e);
1330
+ function Dr(e) {
1331
+ let t = u.useRef(e);
1238
1332
  return t.current = e, t;
1239
1333
  }
1240
- var pt = c.createContext(null), ht = c.createContext(null);
1241
- function ie() {
1242
- let e = c.useContext(pt);
1334
+ var gt = u.createContext(null), mt = u.createContext(null);
1335
+ function ge() {
1336
+ let e = u.useContext(gt);
1243
1337
  if (!e) throw new Error("useMessageScroller must be used within a MessageScroller.");
1244
1338
  return e;
1245
1339
  }
1246
- function Nr() {
1247
- let e = c.useContext(ht);
1340
+ function Ir() {
1341
+ let e = u.useContext(mt);
1248
1342
  if (!e) throw new Error("MessageScrollerItem must be used within a MessageScroller.");
1249
1343
  return e;
1250
1344
  }
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);
1345
+ function Nr({ autoScroll: e = !1, children: t, defaultScrollPosition: n = "end", scrollEdgeThreshold: r, scrollPreviousItemPeek: s, scrollMargin: o }) {
1346
+ let { context: a, registerMessage: i } = Mr({ autoScroll: e, defaultScrollPosition: n, scrollEdgeThreshold: r, scrollPreviousItemPeek: s, scrollMargin: o });
1347
+ return l(gt.Provider, { value: a, children: l(mt.Provider, { value: i, children: t }) });
1348
+ }
1349
+ function bt() {
1350
+ let { pendingDefaultScrollStore: e } = ge();
1351
+ return u.useSyncExternalStore(e.subscribe, e.getSnapshot, e.getSnapshot);
1352
+ }
1353
+ function Pr({ children: e, ...t }) {
1354
+ let { setRootElement: n } = ge(), r = bt();
1355
+ return l("div", { ref: n, ...t, ...r ? { "data-pending-scroll": "" } : null, children: e });
1356
+ }
1357
+ function xr({ "aria-label": e, children: t, onKeyDown: n, onScroll: r, onTouchMove: s, onWheel: o, preserveScrollOnPrepend: a = !0, ref: i, role: c, tabIndex: f, ...g }) {
1358
+ let { handleResize: v, preserveScrollOnPrependRef: h, setViewportElement: d, syncAfterScroll: p, userScrollIntent: y, viewportRef: b } = ge(), F = bt();
1359
+ h.current = a;
1360
+ let k = u.useCallback((E) => {
1361
+ var L;
1362
+ d(E), (L = pe(i)) == null || L(E);
1363
+ }, [i, d]);
1364
+ function D(E) {
1365
+ p(), r == null || r(E);
1272
1366
  }
1273
- function $(T) {
1274
- E(), s == null || s(T);
1367
+ function j(E) {
1368
+ y(), o == null || o(E);
1275
1369
  }
1276
- function N(T) {
1277
- E(), o == null || o(T);
1370
+ function I(E) {
1371
+ y(), s == null || s(E);
1278
1372
  }
1279
- function M(T) {
1280
- hr.has(T.key) && E(), r == null || r(T);
1373
+ function N(E) {
1374
+ hr.has(E.key) && y(), n == null || n(E);
1281
1375
  }
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);
1376
+ return u.useEffect(() => {
1377
+ let E = b.current;
1378
+ if (!E || typeof ResizeObserver > "u") return;
1379
+ let L = 0, q = new ResizeObserver(() => {
1380
+ window.cancelAnimationFrame(L), L = window.requestAnimationFrame(v);
1287
1381
  });
1288
- return I.observe(T), () => {
1289
- window.cancelAnimationFrame(z), I.disconnect();
1382
+ return q.observe(E), () => {
1383
+ window.cancelAnimationFrame(L), q.disconnect();
1290
1384
  };
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(() => {
1385
+ }, [v, b]), l("div", { ref: k, role: c ?? "region", "aria-label": e ?? "Messages", tabIndex: f ?? 0, onKeyDown: N, onScroll: D, onTouchMove: I, onWheel: j, ...g, ...F ? { "data-pending-scroll": "" } : null, children: t });
1386
+ }
1387
+ function Lr({ "aria-relevant": e, children: t, ref: n, role: r, spacerClassName: s, ...o }) {
1388
+ let { handleContentChange: a, handleResize: i, setContentElement: c, setSpacerElement: f } = ge(), g = u.useRef(null), v = u.useCallback((h) => {
1389
+ var d;
1390
+ g.current = h, c(h), (d = pe(n)) == null || d(h);
1391
+ }, [n, c]);
1392
+ return u.useLayoutEffect(() => {
1393
+ let h = g.current;
1394
+ if (!h || (a(), typeof MutationObserver > "u")) return;
1395
+ let d = new MutationObserver(() => {
1302
1396
  a();
1303
1397
  });
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);
1398
+ return d.observe(h, { childList: !0 }), () => d.disconnect();
1399
+ }, [a]), u.useEffect(() => {
1400
+ let h = g.current;
1401
+ if (!h || typeof ResizeObserver > "u") return;
1402
+ let d = 0, p = new ResizeObserver(() => {
1403
+ window.cancelAnimationFrame(d), d = window.requestAnimationFrame(i);
1310
1404
  });
1311
- return g.observe(f), () => {
1312
- window.cancelAnimationFrame(u), g.disconnect();
1405
+ return p.observe(h), () => {
1406
+ window.cancelAnimationFrame(d), p.disconnect();
1313
1407
  };
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 });
1408
+ }, [i]), T("div", { ref: v, role: r ?? "log", "aria-relevant": e ?? "additions", ...o, children: [t, l("div", { ref: f, "aria-hidden": "true", "data-message-scroller-spacer": "", hidden: !0, className: s })] });
1409
+ }
1410
+ function Or({ messageId: e, ref: t, scrollAnchor: n = !1, ...r }) {
1411
+ let s = Ir(), o = u.useRef(null), a = u.useCallback((i) => {
1412
+ var f;
1413
+ let c = o.current;
1414
+ o.current = i, e && s(e, i, c), (f = pe(t)) == null || f(i);
1415
+ }, [e, t, s]);
1416
+ return l("div", { ref: a, "data-message-id": e, "data-scroll-anchor": n ? "true" : "false", ...r });
1417
+ }
1418
+ function qr({ behavior: e = "smooth", children: t, direction: n = "end", onClick: r, render: s, tabIndex: o, type: a = "button", ...i }) {
1419
+ let { scrollToEnd: c, scrollToStart: f, stateStore: g } = ge(), v = Dr(r), h = u.useCallback((b) => g.subscribe(b), [g]), d = u.useCallback(() => {
1420
+ let b = g.getSnapshot();
1421
+ return n === "start" ? b.start : b.end;
1422
+ }, [n, g]), p = u.useSyncExternalStore(h, d, d), y = u.useCallback((b) => {
1423
+ var F;
1424
+ p && ((F = v.current) == null || F.call(v, b), b.defaultPrevented || (b.currentTarget.blur(), n === "start" ? f({ behavior: e }) : c({ behavior: e })));
1425
+ }, [e, n, p, v, c, f]);
1426
+ return sr({ defaultTagName: "button", props: Ee({ type: a, inert: !p, tabIndex: p ? o : -1, children: t ?? T("span", { children: ["Scroll to ", n] }), onClick: y }, i), render: s, state: { active: p, direction: n }, stateAttributesMapping: { active: (b) => ({ "data-active": b ? "true" : "false" }) } });
1427
+ }
1428
+ var ue = { Provider: Nr, Root: Pr, Viewport: xr, Content: Lr, Item: Or, Button: qr };
1429
+ function vt(e) {
1430
+ var t, n, r = "";
1431
+ if (typeof e == "string" || typeof e == "number") r += e;
1432
+ else if (typeof e == "object") if (Array.isArray(e)) {
1433
+ var s = e.length;
1434
+ for (t = 0; t < s; t++) e[t] && (n = vt(e[t])) && (r && (r += " "), r += n);
1435
+ } else for (n in e) e[n] && (r && (r += " "), r += n);
1436
+ return r;
1337
1437
  }
1338
- function Vr({
1438
+ function Wr() {
1439
+ for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t = vt(e)) && (r && (r += " "), r += t);
1440
+ return r;
1441
+ }
1442
+ function de(...e) {
1443
+ return Wr(e);
1444
+ }
1445
+ function $r(e) {
1446
+ return /* @__PURE__ */ l(ue.Provider, { ...e });
1447
+ }
1448
+ function Hr({
1339
1449
  className: e,
1340
1450
  ...t
1341
1451
  }) {
1342
1452
  return /* @__PURE__ */ l(
1343
- re.Root,
1453
+ ue.Root,
1344
1454
  {
1345
1455
  "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
- ),
1456
+ className: de("msg-scroller-root", e),
1350
1457
  ...t
1351
1458
  }
1352
1459
  );
1353
1460
  }
1354
- function Wr({
1461
+ function Vr({
1355
1462
  className: e,
1356
1463
  ...t
1357
1464
  }) {
1358
1465
  return /* @__PURE__ */ l(
1359
- re.Viewport,
1466
+ ue.Viewport,
1360
1467
  {
1361
1468
  "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
- ),
1469
+ className: de("msg-scroller-viewport", e),
1367
1470
  ...t
1368
1471
  }
1369
1472
  );
1370
1473
  }
1371
- function jr({
1474
+ function zr({
1372
1475
  className: e,
1373
1476
  ...t
1374
1477
  }) {
1375
1478
  return /* @__PURE__ */ l(
1376
- re.Content,
1479
+ ue.Content,
1377
1480
  {
1378
1481
  "data-slot": "message-scroller-content",
1379
- className: V("flex h-max min-h-full flex-col gap-4 px-4 py-4", e),
1482
+ className: de("msg-scroller-content", e),
1380
1483
  ...t
1381
1484
  }
1382
1485
  );
1383
1486
  }
1384
- function Ye({
1487
+ function Xe({
1385
1488
  className: e,
1386
1489
  scrollAnchor: t = !1,
1387
- ...r
1490
+ ...n
1388
1491
  }) {
1389
1492
  return /* @__PURE__ */ l(
1390
- re.Item,
1493
+ ue.Item,
1391
1494
  {
1392
1495
  "data-slot": "message-scroller-item",
1393
1496
  scrollAnchor: t,
1394
- className: V(
1395
- "min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]",
1396
- e
1397
- ),
1398
- ...r
1497
+ className: de("msg-scroller-item", e),
1498
+ ...n
1399
1499
  }
1400
1500
  );
1401
1501
  }
1402
- function $r({
1502
+ function Gr({
1403
1503
  direction: e = "end",
1404
1504
  className: t,
1405
- children: r,
1406
- ...n
1505
+ children: n,
1506
+ ...r
1407
1507
  }) {
1408
1508
  return /* @__PURE__ */ l(
1409
- re.Button,
1509
+ ue.Button,
1410
1510
  {
1411
1511
  "data-slot": "message-scroller-button",
1412
1512
  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: [
1513
+ className: de("msg-scroller-btn", t),
1514
+ ...r,
1515
+ children: n ?? /* @__PURE__ */ T(ke, { children: [
1424
1516
  /* @__PURE__ */ l(
1425
- Lt,
1517
+ Ot,
1426
1518
  {
1427
1519
  size: 16,
1428
1520
  "aria-hidden": "true",
@@ -1434,219 +1526,301 @@ function $r({
1434
1526
  }
1435
1527
  );
1436
1528
  }
1437
- const Ur = () => /* @__PURE__ */ C("div", { className: "flex items-start gap-2.5", children: [
1529
+ const Ur = () => /* @__PURE__ */ T("div", { className: "chat-empty-row", children: [
1438
1530
  /* @__PURE__ */ l(
1439
1531
  "div",
1440
1532
  {
1441
- className: "mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground",
1533
+ className: "avatar-circle avatar-circle--mt",
1442
1534
  "aria-hidden": "true",
1443
- children: /* @__PURE__ */ l(st, { size: 15 })
1535
+ children: /* @__PURE__ */ l(it, { size: 15 })
1444
1536
  }
1445
1537
  ),
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." }) })
1538
+ /* @__PURE__ */ l("div", { className: "chat-empty-bubble", 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
1539
  ] });
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(/```$/, "");
1540
+ function ee(e) {
1541
+ if (!e) return [];
1542
+ const t = /(\[[^\]]+\]\([^)]+\)|\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|https?:\/\/[^\s]+)/g;
1543
+ return e.split(t).map((r, s) => {
1544
+ if (!r) return null;
1545
+ const o = r.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
1546
+ if (o) {
1547
+ const a = o[1], i = o[2], c = /^https?:\/\//i.test(i);
1482
1548
  return /* @__PURE__ */ l(
1483
- "pre",
1549
+ "a",
1484
1550
  {
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 })
1551
+ href: i,
1552
+ target: c ? "_blank" : void 0,
1553
+ rel: c ? "noopener noreferrer" : void 0,
1554
+ className: "md-link",
1555
+ children: a
1487
1556
  },
1488
- n
1557
+ s
1489
1558
  );
1490
1559
  }
1491
- return /* @__PURE__ */ l("p", { className: "mb-2 last:mb-0 whitespace-pre-wrap", children: _e(r) }, n);
1492
- }) });
1560
+ return r.startsWith("**") && r.endsWith("**") && r.length >= 4 ? /* @__PURE__ */ l("strong", { children: r.slice(2, -2) }, s) : r.startsWith("*") && r.endsWith("*") && r.length >= 2 ? /* @__PURE__ */ l("em", { children: r.slice(1, -1) }, s) : r.startsWith("`") && r.endsWith("`") && r.length >= 2 ? /* @__PURE__ */ l("code", { className: "md-code", children: r.slice(1, -1) }, s) : /^https?:\/\//i.test(r) ? /* @__PURE__ */ l(
1561
+ "a",
1562
+ {
1563
+ href: r,
1564
+ target: "_blank",
1565
+ rel: "noopener noreferrer",
1566
+ className: "md-link",
1567
+ children: r
1568
+ },
1569
+ s
1570
+ ) : /* @__PURE__ */ l(Ae.Fragment, { children: r }, s);
1571
+ });
1572
+ }
1573
+ function jr(e) {
1574
+ const t = e.replace(/\r\n/g, `
1575
+ `).split(`
1576
+ `), n = [];
1577
+ let r = 0;
1578
+ for (; r < t.length; ) {
1579
+ const o = t[r].trim();
1580
+ if (!o) {
1581
+ r++;
1582
+ continue;
1583
+ }
1584
+ if (o.startsWith("```")) {
1585
+ const c = o.slice(3).trim(), f = [];
1586
+ for (r++; r < t.length && !t[r].trim().startsWith("```"); )
1587
+ f.push(t[r]), r++;
1588
+ r < t.length && t[r].trim().startsWith("```") && r++, n.push({ type: "code", lang: c, code: f.join(`
1589
+ `) });
1590
+ continue;
1591
+ }
1592
+ if (/^(---|___|\*\*\*)$/.test(o)) {
1593
+ n.push({ type: "hr" }), r++;
1594
+ continue;
1595
+ }
1596
+ const a = o.match(/^(#{1,4})\s+(.*)$/);
1597
+ if (a) {
1598
+ n.push({
1599
+ type: "h",
1600
+ level: a[1].length,
1601
+ content: a[2]
1602
+ }), r++;
1603
+ continue;
1604
+ }
1605
+ if (o.startsWith(">")) {
1606
+ const c = [];
1607
+ for (; r < t.length && t[r].trim().startsWith(">"); )
1608
+ c.push(t[r].trim().replace(/^>\s?/, "")), r++;
1609
+ n.push({ type: "quote", lines: c });
1610
+ continue;
1611
+ }
1612
+ if (/^[-*]\s+/.test(o)) {
1613
+ const c = [];
1614
+ for (; r < t.length && /^[-*]\s+/.test(t[r].trim()); )
1615
+ c.push(t[r].trim().replace(/^[-*]\s+/, "")), r++;
1616
+ n.push({ type: "ul", items: c });
1617
+ continue;
1618
+ }
1619
+ if (/^\d+\.\s+/.test(o)) {
1620
+ const c = [];
1621
+ for (; r < t.length && /^\d+\.\s+/.test(t[r].trim()); )
1622
+ c.push(t[r].trim().replace(/^\d+\.\s+/, "")), r++;
1623
+ n.push({ type: "ol", items: c });
1624
+ continue;
1625
+ }
1626
+ if (o.startsWith("|") && o.endsWith("|")) {
1627
+ const c = [];
1628
+ for (; r < t.length && t[r].trim().startsWith("|") && t[r].trim().endsWith("|"); )
1629
+ c.push(t[r].trim()), r++;
1630
+ if (c.length >= 2) {
1631
+ const f = (d) => d.slice(1, -1).split("|").map((p) => p.trim()), g = f(c[0]), v = c[1].includes("-") ? 2 : 1, h = c.slice(v).map(f);
1632
+ n.push({ type: "table", headers: g, rows: h });
1633
+ continue;
1634
+ }
1635
+ }
1636
+ const i = [];
1637
+ for (; r < t.length && t[r].trim() && !t[r].trim().startsWith("```") && !/^(#{1,4})\s+/.test(t[r].trim()) && !/^[-*]\s+/.test(t[r].trim()) && !/^\d+\.\s+/.test(t[r].trim()) && !t[r].trim().startsWith(">") && !/^(---|___|\*\*\*)$/.test(t[r].trim()); )
1638
+ i.push(t[r].trim()), r++;
1639
+ i.length > 0 && n.push({ type: "p", lines: i });
1640
+ }
1641
+ return n;
1493
1642
  }
1494
- const Zr = ({ className: e }) => /* @__PURE__ */ C(
1643
+ const Yr = ({ text: e }) => {
1644
+ if (!e) return null;
1645
+ const t = jr(e);
1646
+ return /* @__PURE__ */ l("div", { className: "md-content", children: t.map((n, r) => {
1647
+ switch (n.type) {
1648
+ case "h":
1649
+ return n.level === 1 ? /* @__PURE__ */ l("h2", { className: "md-h1", children: ee(n.content) }, r) : n.level === 2 ? /* @__PURE__ */ l("h3", { className: "md-h2", children: ee(n.content) }, r) : n.level === 3 ? /* @__PURE__ */ l("h4", { className: "md-h3", children: ee(n.content) }, r) : /* @__PURE__ */ l("h5", { className: "md-h4", children: ee(n.content) }, r);
1650
+ case "ul":
1651
+ return /* @__PURE__ */ l("ul", { className: "md-ul", children: n.items.map((s, o) => /* @__PURE__ */ l("li", { className: "md-li", children: ee(s) }, o)) }, r);
1652
+ case "ol":
1653
+ return /* @__PURE__ */ l("ol", { className: "md-ol", children: n.items.map((s, o) => /* @__PURE__ */ l("li", { className: "md-li", children: ee(s) }, o)) }, r);
1654
+ case "code":
1655
+ return /* @__PURE__ */ l("pre", { className: "md-pre", children: /* @__PURE__ */ l("code", { children: n.code }) }, r);
1656
+ case "quote":
1657
+ return /* @__PURE__ */ l("blockquote", { className: "md-quote", children: n.lines.map((s, o) => /* @__PURE__ */ l("p", { children: ee(s) }, o)) }, r);
1658
+ case "hr":
1659
+ return /* @__PURE__ */ l("hr", { className: "md-hr" }, r);
1660
+ case "table":
1661
+ return /* @__PURE__ */ l("div", { className: "md-table-wrap", children: /* @__PURE__ */ T("table", { className: "md-table", children: [
1662
+ /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: n.headers.map((s, o) => /* @__PURE__ */ l("th", { children: ee(s) }, o)) }) }),
1663
+ /* @__PURE__ */ l("tbody", { children: n.rows.map((s, o) => /* @__PURE__ */ l("tr", { children: s.map((a, i) => /* @__PURE__ */ l("td", { children: ee(a) }, i)) }, o)) })
1664
+ ] }) }, r);
1665
+ case "p":
1666
+ default:
1667
+ return /* @__PURE__ */ l("p", { className: "md-p", children: n.lines.map((s, o) => /* @__PURE__ */ T(Ae.Fragment, { children: [
1668
+ ee(s),
1669
+ o < n.lines.length - 1 && /* @__PURE__ */ l("br", {})
1670
+ ] }, o)) }, r);
1671
+ }
1672
+ }) });
1673
+ }, Jr = ({ className: e, text: t }) => /* @__PURE__ */ l(
1495
1674
  "div",
1496
1675
  {
1497
- className: V("flex items-center gap-1 py-0.5", e),
1676
+ className: de("typing-indicator-container", e),
1498
1677
  role: "status",
1499
1678
  "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
- ]
1679
+ children: /* @__PURE__ */ l("div", { className: "typing-progress-pill", children: /* @__PURE__ */ l("span", { className: "typing-progress-text", children: t || "Retrieving knowledge & generating answer ..." }) })
1505
1680
  }
1506
- );
1507
- function Jr(e) {
1681
+ ), Zr = ({
1682
+ status: e = "complete",
1683
+ progressText: t,
1684
+ sourcesCount: n = 5,
1685
+ durationMs: r = 1800
1686
+ }) => {
1687
+ const s = e === "pending", [o, a] = K(s), [i, c] = K(0);
1688
+ ie(() => {
1689
+ if (!s) return;
1690
+ a(!0);
1691
+ const g = Date.now(), v = setInterval(() => {
1692
+ c(Number(((Date.now() - g) / 1e3).toFixed(1)));
1693
+ }, 100);
1694
+ return () => clearInterval(v);
1695
+ }, [s]), ie(() => {
1696
+ s || a(!1);
1697
+ }, [s]);
1698
+ const f = s ? `${i}s` : `${(r / 1e3).toFixed(1)}s`;
1699
+ return /* @__PURE__ */ l("div", { className: `agent-reasoning-container${s ? " agent-reasoning--active" : ""}`, children: /* @__PURE__ */ l(
1700
+ "div",
1701
+ {
1702
+ className: "agent-reasoning-header",
1703
+ "aria-expanded": o,
1704
+ children: /* @__PURE__ */ T("div", { className: "agent-reasoning-header-left", children: [
1705
+ /* @__PURE__ */ l(
1706
+ $t,
1707
+ {
1708
+ size: 13,
1709
+ className: `agent-reasoning-brain-icon${s ? " agent-reasoning-brain--pulse" : ""}`
1710
+ }
1711
+ ),
1712
+ /* @__PURE__ */ l("span", { className: "agent-reasoning-title", children: s ? `Thinking (${f})...` : `Thought for ${f} ` })
1713
+ ] })
1714
+ }
1715
+ ) });
1716
+ };
1717
+ function Kr(e) {
1508
1718
  return e === "create_ticket" ? "Support ticket processed" : e === "get_customer" ? "Account verified" : e === "get_ticket" ? "Ticket status loaded" : "Information retrieved";
1509
1719
  }
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(
1720
+ function Qr({ toolCalls: e }) {
1721
+ return e.length ? /* @__PURE__ */ l("div", { className: "tool-badges", children: e.map((t, n) => /* @__PURE__ */ l(
1547
1722
  "span",
1548
1723
  {
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)
1724
+ className: "tool-badge",
1725
+ children: Kr(t.toolName)
1551
1726
  },
1552
- `${t.toolName}-${r}`
1727
+ `${t.toolName}-${n}`
1553
1728
  )) }) : null;
1554
1729
  }
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
- );
1730
+ const Xr = ({ message: e }) => {
1731
+ var c;
1732
+ const t = Me();
1733
+ t == null || t.hideInspectSources, t == null || t.showGroundedSources;
1734
+ const n = e.role === "user", r = e.status === "error", s = e.status === "pending", o = e.id === "welcome-default" || e.id.startsWith("welcome") || e.id === "welcome", a = !!(s || e.sources && e.sources.length > 0 || e.toolCalls && e.toolCalls.length > 0 || e.usage);
1735
+ return /* @__PURE__ */ T("div", { className: `msg-row${n ? " msg-row--user" : ""}`, children: [
1736
+ !n && /* @__PURE__ */ l(
1737
+ "div",
1738
+ {
1739
+ className: "avatar-circle avatar-circle--mt",
1740
+ "aria-hidden": "true",
1741
+ children: /* @__PURE__ */ l(it, { size: 15 })
1742
+ }
1743
+ ),
1744
+ /* @__PURE__ */ T("div", { className: `msg-col${n ? " msg-col--user" : ""}`, children: [
1745
+ /* @__PURE__ */ T(
1746
+ "div",
1747
+ {
1748
+ className: n ? "msg-bubble msg-bubble--user" : r ? "msg-bubble msg-bubble--error" : "msg-bubble msg-bubble--bot",
1749
+ children: [
1750
+ !n && !r && !o && a && /* @__PURE__ */ l(
1751
+ Zr,
1752
+ {
1753
+ status: s ? "pending" : "complete",
1754
+ progressText: e.progressText,
1755
+ sourcesCount: ((c = e.sources) == null ? void 0 : c.length) || 5
1756
+ }
1757
+ ),
1758
+ s ? /* @__PURE__ */ l(Jr, { text: e.progressText }) : n ? /* @__PURE__ */ l("p", { className: "msg-user-pre", children: e.content }) : /* @__PURE__ */ l("div", { className: "msg-content-wrapper", children: /* @__PURE__ */ l(Yr, { text: e.content }) }),
1759
+ e.toolCalls ? /* @__PURE__ */ l(Qr, { toolCalls: e.toolCalls }) : null
1760
+ ]
1761
+ }
1762
+ ),
1763
+ n && e.status !== "error" && /* @__PURE__ */ l(Ht, { size: 13, className: "msg-tick", "aria-hidden": "true" })
1764
+ ] })
1765
+ ] });
1592
1766
  }, en = () => {
1593
- const { messages: e, status: t, showSuggestions: r } = ye();
1767
+ const { messages: e, status: t, showSuggestions: n } = Ce();
1594
1768
  return /* @__PURE__ */ l(
1595
- Gr,
1769
+ $r,
1596
1770
  {
1597
1771
  autoScroll: !0,
1598
1772
  defaultScrollPosition: "last-anchor",
1599
1773
  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,
1774
+ children: /* @__PURE__ */ T(Hr, { children: [
1775
+ /* @__PURE__ */ l(Vr, { "aria-label": "Chat messages", children: /* @__PURE__ */ T(zr, { "aria-busy": t === "awaiting" || t === "connecting", children: [
1776
+ e.length === 0 && /* @__PURE__ */ l(Xe, { messageId: "welcome", children: /* @__PURE__ */ l(Ur, {}) }),
1777
+ e.map((s) => /* @__PURE__ */ l(
1778
+ Xe,
1605
1779
  {
1606
- messageId: o.id,
1607
- scrollAnchor: o.role === "user",
1608
- children: /* @__PURE__ */ l(Qr, { message: o })
1780
+ messageId: s.id,
1781
+ scrollAnchor: s.role === "user",
1782
+ children: /* @__PURE__ */ l(Xr, { message: s })
1609
1783
  },
1610
- o.id
1784
+ s.id
1611
1785
  ))
1612
1786
  ] }) }),
1613
- /* @__PURE__ */ l($r, {})
1787
+ /* @__PURE__ */ l(Gr, {})
1614
1788
  ] })
1615
1789
  }
1616
1790
  );
1617
1791
  }, 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(
1792
+ const { pendingTicket: e, ticketBusy: t, userContext: n, confirmTicket: r, cancelTicket: s } = Ce(), o = !n.customerId && !n.email, [a, i] = K("");
1793
+ return e ? /* @__PURE__ */ T(
1620
1794
  "div",
1621
1795
  {
1622
- className: "mx-4 mb-3 rounded-xl border border-border bg-card p-4 shadow-sm",
1796
+ className: "ticket-card",
1623
1797
  role: "region",
1624
1798
  "aria-label": "Create support ticket",
1625
1799
  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: [
1800
+ /* @__PURE__ */ l("h3", { className: "ticket-card-title", children: "Create support ticket?" }),
1801
+ /* @__PURE__ */ l("p", { className: "ticket-card-desc", children: "I can open a support request for you. Nothing is created until you confirm." }),
1802
+ /* @__PURE__ */ l("p", { className: "ticket-card-body", children: e.description }),
1803
+ o && /* @__PURE__ */ T("label", { className: "ticket-id-label", children: [
1630
1804
  "Customer ID or email",
1631
1805
  /* @__PURE__ */ l(
1632
1806
  "input",
1633
1807
  {
1634
1808
  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",
1809
+ onChange: (c) => i(c.target.value),
1810
+ className: "ticket-id-input",
1637
1811
  placeholder: "CUST-1001 or you@company.com",
1638
1812
  autoComplete: "email"
1639
1813
  }
1640
1814
  )
1641
1815
  ] }),
1642
- /* @__PURE__ */ C("div", { className: "mt-3 flex justify-end gap-2", children: [
1816
+ /* @__PURE__ */ T("div", { className: "ticket-actions", children: [
1643
1817
  /* @__PURE__ */ l(
1644
1818
  "button",
1645
1819
  {
1646
1820
  type: "button",
1647
- onClick: o,
1821
+ onClick: s,
1648
1822
  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",
1823
+ className: "ticket-cancel-btn",
1650
1824
  children: "Cancel"
1651
1825
  }
1652
1826
  ),
@@ -1654,9 +1828,9 @@ const Qr = ({ message: e }) => {
1654
1828
  "button",
1655
1829
  {
1656
1830
  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",
1831
+ onClick: () => void r(a),
1832
+ disabled: t || o && !a.trim(),
1833
+ className: "ticket-confirm-btn",
1660
1834
  children: t ? "Creating…" : "Create ticket"
1661
1835
  }
1662
1836
  )
@@ -1664,45 +1838,42 @@ const Qr = ({ message: e }) => {
1664
1838
  ]
1665
1839
  }
1666
1840
  ) : null;
1667
- }, gt = ({
1841
+ }, _t = ({
1668
1842
  className: e,
1669
1843
  onClose: t,
1670
- showMinimize: r,
1671
- title: n,
1672
- subtitle: o,
1673
- envStage: s,
1844
+ showMinimize: n,
1845
+ title: r,
1846
+ subtitle: s,
1847
+ envStage: o,
1674
1848
  envPulse: a = !0
1675
1849
  }) => {
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(
1850
+ const { sendMessage: i, status: c, error: f, resetConversation: g, retryLast: v, pendingTicket: h } = Ce(), d = c === "awaiting" || c === "connecting" || !!h;
1851
+ return /* @__PURE__ */ T(
1678
1852
  "section",
1679
1853
  {
1680
- className: V(
1681
- "flex h-full min-h-0 flex-col overflow-hidden bg-card",
1682
- e
1683
- ),
1854
+ className: `chat-panel${e ? ` ${e}` : ""}`,
1684
1855
  "aria-label": "VPS AI Assistant",
1685
1856
  children: [
1686
1857
  /* @__PURE__ */ l(
1687
- er,
1858
+ Xt,
1688
1859
  {
1689
- title: n,
1690
- subtitle: o,
1860
+ title: r,
1861
+ subtitle: s,
1691
1862
  onClose: t,
1692
- onReset: () => void m(),
1693
- showMinimize: r,
1694
- envStage: s,
1863
+ onReset: () => void g(),
1864
+ showMinimize: n,
1865
+ envStage: o,
1695
1866
  envPulse: a
1696
1867
  }
1697
1868
  ),
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() }),
1869
+ /* @__PURE__ */ l("div", { className: "chat-panel-body", children: /* @__PURE__ */ l(en, {}) }),
1870
+ f && c === "error" && /* @__PURE__ */ l(Nt, { message: f, onRetry: () => void v() }),
1700
1871
  /* @__PURE__ */ l(tn, {}),
1701
1872
  /* @__PURE__ */ l(
1702
- sr,
1873
+ nr,
1703
1874
  {
1704
- onSend: (g) => void i(g),
1705
- disabled: u
1875
+ onSend: (p) => void i(p),
1876
+ disabled: d
1706
1877
  }
1707
1878
  )
1708
1879
  ]
@@ -1711,25 +1882,21 @@ const Qr = ({ message: e }) => {
1711
1882
  }, rn = ({
1712
1883
  open: e,
1713
1884
  onClose: t,
1714
- envStage: r,
1715
- envPulse: n = !0
1885
+ envStage: n,
1886
+ envPulse: r = !0
1716
1887
  }) => e ? /* @__PURE__ */ l(
1717
1888
  "div",
1718
1889
  {
1719
1890
  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
- ),
1891
+ className: "widget-panel",
1725
1892
  children: /* @__PURE__ */ l(
1726
- gt,
1893
+ _t,
1727
1894
  {
1728
1895
  onClose: t,
1729
1896
  showMinimize: !0,
1730
1897
  title: "VPS AI Assistant",
1731
- envStage: r,
1732
- envPulse: n
1898
+ envStage: n,
1899
+ envPulse: r
1733
1900
  }
1734
1901
  )
1735
1902
  }
@@ -1744,75 +1911,77 @@ const Qr = ({ message: e }) => {
1744
1911
  "aria-expanded": e,
1745
1912
  "aria-controls": "vps-chatbot-widget-panel",
1746
1913
  "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 })
1914
+ className: "widget-trigger-btn",
1915
+ children: e ? /* @__PURE__ */ l(Jt, { size: 22 }) : /* @__PURE__ */ l(ct, { size: 24 })
1755
1916
  }
1756
- ), Ze = ({
1917
+ ), et = ({
1757
1918
  defaultOpen: e = !1,
1758
1919
  open: t,
1759
- onOpenChange: r,
1760
- envStage: n,
1761
- envPulse: o = !0
1920
+ onOpenChange: n,
1921
+ envStage: r,
1922
+ envPulse: s = !0
1762
1923
  }) => {
1763
- const [s, a] = Y(e), i = t ?? s, d = (p) => {
1764
- r == null || r(p), t === void 0 && a(p);
1924
+ const [o, a] = K(e), i = t ?? o, c = (f) => {
1925
+ n == null || n(f), t === void 0 && a(f);
1765
1926
  };
1766
- return /* @__PURE__ */ C(le, { children: [
1927
+ return /* @__PURE__ */ T(ke, { children: [
1767
1928
  /* @__PURE__ */ l(
1768
1929
  rn,
1769
1930
  {
1770
1931
  open: i,
1771
- onClose: () => d(!1),
1772
- envStage: n,
1773
- envPulse: o
1932
+ onClose: () => c(!1),
1933
+ envStage: r,
1934
+ envPulse: s
1774
1935
  }
1775
1936
  ),
1776
- /* @__PURE__ */ l(nn, { open: i, onToggle: () => d(!i) })
1937
+ /* @__PURE__ */ l(nn, { open: i, onToggle: () => c(!i) })
1777
1938
  ] });
1778
- }, hn = ({
1939
+ }, pn = ({
1779
1940
  apiBaseUrl: e,
1780
1941
  apiUrl: t,
1781
- proxyUrl: r,
1782
- userContext: n,
1783
- suggestions: o,
1784
- disableSuggestions: s,
1785
- initialMessage: a,
1786
- ...i
1942
+ proxyUrl: n,
1943
+ userContext: r,
1944
+ role: s,
1945
+ roleId: o,
1946
+ client: a,
1947
+ welcomeMessage: i,
1948
+ suggestions: c,
1949
+ disableSuggestions: f,
1950
+ initialMessage: g,
1951
+ hideInspectSources: v,
1952
+ showGroundedSources: h,
1953
+ ...d
1787
1954
  }) => {
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,
1955
+ const p = Me(), y = e ?? t ?? n;
1956
+ return !!p && (!y || ce(y) === ce(p == null ? void 0 : p.apiBaseUrl)) && !r && s === void 0 && o === void 0 && a === void 0 && i === void 0 && !c && f === void 0 && !g && v === void 0 && h === void 0 ? /* @__PURE__ */ l(et, { ...d }) : /* @__PURE__ */ l(
1957
+ lt,
1791
1958
  {
1792
- apiBaseUrl: p,
1793
- userContext: n,
1794
- suggestions: o,
1795
- disableSuggestions: s,
1796
- initialMessage: a,
1797
- children: /* @__PURE__ */ l(Ze, { ...i })
1959
+ apiBaseUrl: y,
1960
+ userContext: r,
1961
+ role: s,
1962
+ roleId: o,
1963
+ client: a,
1964
+ welcomeMessage: i,
1965
+ suggestions: c,
1966
+ disableSuggestions: f,
1967
+ initialMessage: g,
1968
+ hideInspectSources: v,
1969
+ showGroundedSources: h,
1970
+ children: /* @__PURE__ */ l(et, { ...d })
1798
1971
  }
1799
1972
  );
1800
- }, on = ({
1973
+ }, sn = ({
1801
1974
  open: e,
1802
1975
  onClose: t,
1803
- subtitle: r,
1804
- title: n,
1805
- envStage: o,
1806
- envPulse: s = !0
1807
- }) => /* @__PURE__ */ C(le, { children: [
1976
+ subtitle: n,
1977
+ title: r,
1978
+ envStage: s,
1979
+ envPulse: o = !0
1980
+ }) => /* @__PURE__ */ T(ke, { children: [
1808
1981
  /* @__PURE__ */ l(
1809
1982
  "div",
1810
1983
  {
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
- ),
1984
+ className: `embedded-overlay ${e ? "embedded-overlay--open" : "embedded-overlay--closed"}`,
1816
1985
  hidden: !e,
1817
1986
  onClick: t,
1818
1987
  "aria-hidden": "true"
@@ -1822,38 +1991,34 @@ const Qr = ({ message: e }) => {
1822
1991
  "aside",
1823
1992
  {
1824
1993
  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
- ),
1994
+ className: `embedded-panel ${e ? "embedded-panel--open" : "embedded-panel--closed"}`,
1830
1995
  "aria-hidden": !e,
1831
1996
  children: e && /* @__PURE__ */ l(
1832
- gt,
1997
+ _t,
1833
1998
  {
1834
1999
  onClose: t,
1835
- title: n || "VPS AI Assistant",
1836
- subtitle: r,
1837
- envStage: o,
1838
- envPulse: s
2000
+ title: r || "VPS AI Assistant",
2001
+ subtitle: n,
2002
+ envStage: s,
2003
+ envPulse: o
1839
2004
  }
1840
2005
  )
1841
2006
  }
1842
2007
  )
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
2008
+ ] }), on = 5, Te = 8, wt = "vps-embedded-assistant-top";
2009
+ function ln(e, t, n) {
2010
+ return Math.min(n, Math.max(t, e));
2011
+ }
2012
+ function tt(e, t) {
2013
+ const n = Math.max(
2014
+ Te,
2015
+ window.innerHeight - t - Te
1851
2016
  );
1852
- return ln(e, xe, r);
2017
+ return ln(e, Te, n);
1853
2018
  }
1854
2019
  function an() {
1855
2020
  try {
1856
- const e = window.localStorage.getItem(bt);
2021
+ const e = window.localStorage.getItem(wt);
1857
2022
  if (!e) return null;
1858
2023
  const t = Number(e);
1859
2024
  return Number.isFinite(t) ? t : null;
@@ -1863,76 +2028,76 @@ function an() {
1863
2028
  }
1864
2029
  function cn(e) {
1865
2030
  try {
1866
- window.localStorage.setItem(bt, String(e));
2031
+ window.localStorage.setItem(wt, String(e));
1867
2032
  } catch {
1868
2033
  }
1869
2034
  }
1870
2035
  const un = ({
1871
2036
  onOpen: e
1872
2037
  }) => {
1873
- const t = X(null), r = X({
2038
+ const t = se(null), n = se({
1874
2039
  pointerId: null,
1875
2040
  startY: 0,
1876
2041
  startTop: 0,
1877
2042
  moved: !1
1878
- }), [n, o] = Y(
2043
+ }), [r, s] = K(
1879
2044
  () => 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;
2045
+ ), o = se(r), a = se(!1), [i, c] = K(!1);
2046
+ ie(() => {
2047
+ o.current = r;
2048
+ }, [r]), ie(() => {
2049
+ const h = t.current;
2050
+ if (!h) return;
2051
+ const d = () => {
2052
+ s((p) => {
2053
+ const y = p ?? Math.round(window.innerHeight / 2 - h.offsetHeight / 2), b = tt(y, h.offsetHeight);
2054
+ return o.current = b, b;
1890
2055
  });
1891
2056
  };
1892
- return u(), window.addEventListener("resize", u), () => window.removeEventListener("resize", u);
2057
+ return d(), window.addEventListener("resize", d), () => window.removeEventListener("resize", d);
1893
2058
  }, []);
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,
2059
+ const f = (h) => {
2060
+ if (h.button !== 0) return;
2061
+ const d = h.currentTarget, p = d.getBoundingClientRect();
2062
+ n.current = {
2063
+ pointerId: h.pointerId,
2064
+ startY: h.clientY,
2065
+ startTop: p.top,
1901
2066
  moved: !1
1902
2067
  };
1903
2068
  try {
1904
- u.setPointerCapture(f.pointerId);
2069
+ d.setPointerCapture(h.pointerId);
1905
2070
  } catch {
1906
2071
  }
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
2072
+ }, g = (h) => {
2073
+ if (n.current.pointerId !== h.pointerId) return;
2074
+ const d = h.clientY - n.current.startY;
2075
+ if (!n.current.moved && Math.abs(d) < on) return;
2076
+ n.current.moved = !0, c(!0);
2077
+ const p = tt(
2078
+ n.current.startTop + d,
2079
+ h.currentTarget.offsetHeight
1915
2080
  );
1916
- s.current = g, o(g);
1917
- }, y = (f) => {
1918
- var g, E;
1919
- if (r.current.pointerId !== f.pointerId) return;
2081
+ o.current = p, s(p);
2082
+ }, v = (h) => {
2083
+ var p, y;
2084
+ if (n.current.pointerId !== h.pointerId) return;
1920
2085
  try {
1921
- (E = (g = f.currentTarget).hasPointerCapture) != null && E.call(g, f.pointerId) && f.currentTarget.releasePointerCapture(f.pointerId);
2086
+ (y = (p = h.currentTarget).hasPointerCapture) != null && y.call(p, h.pointerId) && h.currentTarget.releasePointerCapture(h.pointerId);
1922
2087
  } catch {
1923
2088
  }
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));
2089
+ const d = n.current.moved;
2090
+ n.current.pointerId = null, n.current.moved = !1, c(!1), d && (a.current = !0, o.current != null && cn(o.current));
1926
2091
  };
1927
- return /* @__PURE__ */ C(
2092
+ return /* @__PURE__ */ T(
1928
2093
  "button",
1929
2094
  {
1930
2095
  ref: t,
1931
2096
  type: "button",
1932
- onPointerDown: p,
1933
- onPointerMove: m,
1934
- onPointerUp: y,
1935
- onPointerCancel: y,
2097
+ onPointerDown: f,
2098
+ onPointerMove: g,
2099
+ onPointerUp: v,
2100
+ onPointerCancel: v,
1936
2101
  onClick: () => {
1937
2102
  if (a.current) {
1938
2103
  a.current = !1;
@@ -1943,63 +2108,75 @@ const un = ({
1943
2108
  "aria-expanded": !1,
1944
2109
  "aria-controls": "vps-embedded-chat-panel",
1945
2110
  "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"}`,
2111
+ className: `embedded-trigger-btn ${i ? "embedded-trigger-btn--grabbing" : "embedded-trigger-btn--grab"}`,
1947
2112
  style: {
1948
- top: n ?? "50%",
1949
- transform: n == null ? "translateY(-50%)" : void 0
2113
+ top: r ?? "50%",
2114
+ transform: r == null ? "translateY(-50%)" : void 0
1950
2115
  },
1951
2116
  children: [
1952
- /* @__PURE__ */ l(lt, { size: 16 }),
2117
+ /* @__PURE__ */ l(ct, { size: 16 }),
1953
2118
  "Assistant"
1954
2119
  ]
1955
2120
  }
1956
2121
  );
1957
- }, Ke = ({
2122
+ }, rt = ({
1958
2123
  defaultOpen: e = !1,
1959
2124
  open: t,
1960
- onOpenChange: r,
1961
- showTrigger: n = !0,
1962
- envStage: o,
1963
- envPulse: s = !0
2125
+ onOpenChange: n,
2126
+ showTrigger: r = !0,
2127
+ envStage: s,
2128
+ envPulse: o = !0
1964
2129
  }) => {
1965
- const [a, i] = Y(e), d = t ?? a, p = (m) => {
1966
- r == null || r(m), t === void 0 && i(m);
2130
+ const [a, i] = K(e), c = t ?? a, f = (g) => {
2131
+ n == null || n(g), t === void 0 && i(g);
1967
2132
  };
1968
- return /* @__PURE__ */ C(le, { children: [
1969
- n && !d && /* @__PURE__ */ l(un, { onOpen: () => p(!0) }),
2133
+ return /* @__PURE__ */ T(ke, { children: [
2134
+ r && !c && /* @__PURE__ */ l(un, { onOpen: () => f(!0) }),
1970
2135
  /* @__PURE__ */ l(
1971
- on,
2136
+ sn,
1972
2137
  {
1973
- open: d,
1974
- onClose: () => p(!1),
1975
- envStage: o,
1976
- envPulse: s
2138
+ open: c,
2139
+ onClose: () => f(!1),
2140
+ envStage: s,
2141
+ envPulse: o
1977
2142
  }
1978
2143
  )
1979
2144
  ] });
1980
- }, mn = ({
2145
+ }, gn = ({
1981
2146
  apiBaseUrl: e,
1982
2147
  apiUrl: t,
1983
- proxyUrl: r,
1984
- userContext: n,
1985
- suggestions: o,
1986
- disableSuggestions: s,
1987
- initialMessage: a,
1988
- ...i
2148
+ proxyUrl: n,
2149
+ userContext: r,
2150
+ role: s,
2151
+ roleId: o,
2152
+ client: a,
2153
+ welcomeMessage: i,
2154
+ suggestions: c,
2155
+ disableSuggestions: f,
2156
+ initialMessage: g,
2157
+ hideInspectSources: v,
2158
+ showGroundedSources: h,
2159
+ ...d
1989
2160
  }) => {
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,
2161
+ const p = Me(), y = e ?? t ?? n;
2162
+ return !!p && (!y || ce(y) === ce(p == null ? void 0 : p.apiBaseUrl)) && !r && s === void 0 && o === void 0 && a === void 0 && i === void 0 && !c && f === void 0 && !g && v === void 0 && h === void 0 ? /* @__PURE__ */ l(rt, { ...d }) : /* @__PURE__ */ l(
2163
+ lt,
1993
2164
  {
1994
- apiBaseUrl: p,
1995
- userContext: n,
1996
- suggestions: o,
1997
- disableSuggestions: s,
1998
- initialMessage: a,
1999
- children: /* @__PURE__ */ l(Ke, { ...i })
2165
+ apiBaseUrl: y,
2166
+ userContext: r,
2167
+ role: s,
2168
+ roleId: o,
2169
+ client: a,
2170
+ welcomeMessage: i,
2171
+ suggestions: c,
2172
+ disableSuggestions: f,
2173
+ initialMessage: g,
2174
+ hideInspectSources: v,
2175
+ showGroundedSources: h,
2176
+ children: /* @__PURE__ */ l(rt, { ...d })
2000
2177
  }
2001
2178
  );
2002
- }, gn = {
2179
+ }, mn = {
2003
2180
  Colors: {
2004
2181
  VPS_White: "#fff",
2005
2182
  VPS_Dark_Blue: "#1A1A31",
@@ -2164,16 +2341,16 @@ const un = ({
2164
2341
  }
2165
2342
  };
2166
2343
  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
2344
+ _t as ChatPanel,
2345
+ lt as ChatProvider,
2346
+ pn as ChatbotWidget,
2347
+ mn as ColorPalette,
2348
+ gn as EmbeddedChatbot,
2349
+ Se as buildApiUrl,
2350
+ fn as chatApi,
2351
+ ot as createChatApi,
2352
+ ce as resolveApiBaseUrl,
2353
+ Mt as useChatContext,
2354
+ Ce as useChatbot,
2355
+ Me as useOptionalChatContext
2179
2356
  };