vpschatbotwidget 1.0.3 → 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 (29) 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 +33 -29
  14. package/dist-lib/vps-chatbot.js +1198 -967
  15. package/package.json +1 -1
  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/ChatMarkdown.tsx +279 -54
  21. package/src/chatbot/core/ChatMessage.tsx +41 -45
  22. package/src/chatbot/core/ChatMessageList.tsx +1 -1
  23. package/src/chatbot/core/ChatProvider.tsx +109 -22
  24. package/src/chatbot/core/ChatTypingIndicator.tsx +16 -5
  25. package/src/chatbot/core/GroundedSources.tsx +181 -0
  26. package/src/chatbot/embedded/EmbeddedChatbot.tsx +33 -4
  27. package/src/chatbot/index.ts +1 -0
  28. package/src/chatbot/widget/ChatbotWidget.tsx +33 -4
  29. package/src/index.css +1051 -68
@@ -1,53 +1,55 @@
1
- import { jsx as o, jsxs as k, Fragment as oe } from "react/jsx-runtime";
2
- import * as c from "react";
3
- import Xe, { createContext as yt, useContext as Qe, useMemo as Ce, useState as j, useRef as K, useCallback as X, forwardRef as et, createElement as ke, useEffect as me } from "react";
4
- const wt = {};
5
- function ee(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 = ee(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 s = r.slice(0, -4);
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
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 Ct(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 kt(e, t, r) {
25
- var l, a, i;
26
- const n = e, s = (l = n == null ? void 0 : n.error) == null ? void 0 : l.message;
27
- return s && !St(s) ? {
28
- code: (a = n == null ? void 0 : n.error) == null ? void 0 : a.code,
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
29
  message: s,
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 };
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 St(e) {
33
+ function Et(e) {
34
34
  return /traceback|sql|exception|stack|api[_ ]?key|password/i.test(e);
35
35
  }
36
- function Ft(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 Et(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 Tt(e) {
52
+ function Je(e) {
51
53
  return {
52
54
  model: e.model,
53
55
  promptTokens: e.prompt_tokens,
@@ -80,13 +82,13 @@ async function At(e) {
80
82
  return {};
81
83
  }
82
84
  }
83
- function tt(e) {
84
- const t = ee(e);
85
- async function r(n, s) {
86
- let l;
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
- l = await fetch(a, {
91
+ o = await fetch(a, {
90
92
  ...s,
91
93
  headers: {
92
94
  "Content-Type": "application/json",
@@ -96,55 +98,114 @@ function tt(e) {
96
98
  } catch {
97
99
  throw { message: "Something went wrong while connecting. Please try again." };
98
100
  }
99
- if (l.status === 204)
101
+ if (o.status === 204)
100
102
  return;
101
- const i = await At(l);
102
- if (!l.ok)
103
- throw kt(
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
- l.status
108
+ o.status
107
109
  );
108
- return Ct(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, s) {
120
- const l = 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: s })
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: l.request_id,
129
- sessionId: l.session_id,
130
- answer: l.answer,
131
- sources: (l.sources || []).map(Ft),
132
- toolCalls: (l.tool_calls || []).map(Et),
133
- usage: Tt(l.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`
199
+ return ((await n(
200
+ `/api/v1/sessions/${r}/messages`
140
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 hn = tt(), Bt = [
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 hn = tt(), Bt = [
178
239
  label: "How do I contact VPS Support?",
179
240
  query: "How can I contact VPS Customer Support?"
180
241
  }
181
- ], Ee = yt(null);
182
- function Dt() {
183
- const e = Qe(Ee);
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(Ee);
190
- }
191
- function $e(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 Mt(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,133 +270,176 @@ function Mt(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 = Bt,
206
- disableSuggestions: n = !1,
207
- initialMessage: s,
208
- apiBaseUrl: l,
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 h = l ?? a ?? i, g = Ce(
214
- () => d ?? tt(h),
215
- [d, h]
216
- ), [v, f] = j(null), [u, m] = j([]), [T, _] = j("idle"), [D, V] = j(null), L = K(null), $ = K(!1), P = X(async () => {
217
- if (v) return v;
218
- _("connecting");
219
- const y = await g.createSession();
220
- return f(y.sessionId), y.sessionId;
221
- }, [v, g]), I = X(
222
- async (y) => {
223
- L.current = y;
224
- const S = {
225
- id: $e("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: y,
315
+ content: W,
228
316
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
229
317
  status: "complete"
230
- }, F = $e("asst"), B = {
231
- id: F,
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
- m((A) => [...A, S, B]), _("awaiting"), V(null);
238
334
  try {
239
- const A = await P(), E = await g.sendMessage(A, y);
240
- m(
241
- (W) => W.map(
242
- (z) => z.id === F ? {
243
- ...z,
244
- id: E.requestId || F,
245
- content: E.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: E.sources,
248
- toolCalls: E.toolCalls,
249
- usage: E.usage
250
- } : z
356
+ progressText: void 0,
357
+ sources: $.sources,
358
+ toolCalls: $.toolCalls,
359
+ usage: $.usage
360
+ } : U
251
361
  )
252
- ), _("idle");
362
+ ), L("idle");
253
363
  } catch (A) {
254
- const E = Mt(A);
255
- m(
256
- (W) => W.map(
257
- (z) => z.id === F ? { ...z, content: E, status: "error" } : z
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
- ), V(E), _("error");
369
+ ), te($), L("error");
260
370
  }
261
371
  },
262
- [P, g]
263
- ), R = X(
264
- async (y) => {
265
- const S = y.trim();
266
- !S || T === "awaiting" || T === "connecting" || await I(S);
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
- [I, T]
269
- ), O = X(async () => {
270
- const y = L.current;
271
- y && (m((S) => S.filter((F) => F.status !== "error")), await I(y));
272
- }, [I]), N = X(async () => {
273
- }, []), Z = X(() => {
274
- }, []), U = X(async () => {
275
- v && await g.closeSession(v), f(null), m([]), _("idle"), V(null), L.current = null;
276
- }, [v, g]);
277
- Xe.useEffect(() => {
278
- !s || $.current || ($.current = !0, R(s));
279
- }, [s, R]);
280
- const b = Ce(
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,
283
- status: T,
284
- error: D,
285
- sessionId: v,
392
+ messages: I,
393
+ status: E,
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: g.apiBaseUrl,
294
- sendMessage: R,
295
- retryLast: O,
296
- confirmTicket: N,
297
- cancelTicket: Z,
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,
302
- T,
413
+ I,
414
+ E,
415
+ q,
303
416
  D,
304
- v,
305
- r,
306
- n,
307
- t,
308
- g.apiBaseUrl,
309
- R,
310
- O,
311
- N,
312
- Z,
313
- U
417
+ a,
418
+ i,
419
+ F,
420
+ b.apiBaseUrl,
421
+ d,
422
+ p,
423
+ B,
424
+ M,
425
+ P,
426
+ x,
427
+ G
314
428
  ]
315
429
  );
316
- return /* @__PURE__ */ o(Ee.Provider, { value: b, children: e });
430
+ return /* @__PURE__ */ l(Be.Provider, { value: re, children: e });
317
431
  };
318
- function ve() {
319
- return Dt();
432
+ function Ce() {
433
+ return Mt();
320
434
  }
321
- const It = ({ message: e, onRetry: t }) => /* @__PURE__ */ k(
435
+ const Nt = ({ message: e, onRetry: t }) => /* @__PURE__ */ T(
322
436
  "div",
323
437
  {
324
438
  className: "chat-error-banner",
325
439
  role: "alert",
326
440
  children: [
327
- /* @__PURE__ */ o("p", { children: e }),
328
- t && /* @__PURE__ */ o(
441
+ /* @__PURE__ */ l("p", { children: e }),
442
+ t && /* @__PURE__ */ l(
329
443
  "button",
330
444
  {
331
445
  type: "button",
@@ -343,14 +457,14 @@ const It = ({ message: e, onRetry: t }) => /* @__PURE__ */ k(
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 Nt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), st = (...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 Pt = {
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 Pt = {
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 xt = et(
484
+ const Lt = st(
371
485
  ({
372
486
  color: e = "currentColor",
373
487
  size: t = 24,
374
- strokeWidth: r = 2,
375
- absoluteStrokeWidth: n,
488
+ strokeWidth: n = 2,
489
+ absoluteStrokeWidth: r,
376
490
  className: s = "",
377
- children: l,
491
+ children: o,
378
492
  iconNode: a,
379
493
  ...i
380
- }, d) => ke(
494
+ }, c) => Fe(
381
495
  "svg",
382
496
  {
383
- ref: d,
384
- ...Pt,
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: st("lucide", s),
502
+ strokeWidth: r ? Number(n) * 24 / Number(t) : n,
503
+ className: at("lucide", s),
390
504
  ...i
391
505
  },
392
506
  [
393
- ...a.map(([h, g]) => ke(h, g)),
394
- ...Array.isArray(l) ? l : [l]
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 xt = 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 H = (e, t) => {
405
- const r = et(
406
- ({ className: n, ...s }, l) => ke(xt, {
407
- ref: l,
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: st(`lucide-${Nt(e)}`, n),
523
+ className: at(`lucide-${Pt(e)}`, r),
410
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 H = (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 = H("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 = H("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 Ot = H("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 Ot = H("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 Ht = H("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 Ht = H("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 lt = H("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 lt = H("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 zt = H("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 = H("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 = H("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 = H("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 = H("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 = H("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 = H("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 $t = H("FlaskConical", [
632
+ const zt = z("FlaskConical", [
519
633
  [
520
634
  "path",
521
635
  {
@@ -532,7 +646,7 @@ const $t = H("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 ot = H("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 ot = H("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 Ut = H("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 Ut = H("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 jt = H("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 = H("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 = H("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 = H("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 = H("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 = H("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: $t,
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: Ut,
723
+ Icon: Gt,
610
724
  variant: "env-badge--gamma",
611
725
  tooltip: "Gamma / Release Candidate"
612
726
  },
@@ -616,27 +730,27 @@ const Jt = H("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: s, variant: l, tooltip: a } = Kt[e];
626
- return /* @__PURE__ */ k(
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-inline ${l} ${r}`.trim(),
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__ */ o(s, { size: 10, className: "env-badge-icon", "aria-hidden": "true" }),
635
- /* @__PURE__ */ o("span", { className: "env-badge-inline-label", 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
  );
639
- }, Qt = (e) => /* @__PURE__ */ o(
753
+ }, Qt = (e) => /* @__PURE__ */ l(
640
754
  "svg",
641
755
  {
642
756
  width: e.width || "24px",
@@ -646,97 +760,97 @@ const Jt = H("X", [
646
760
  xmlns: "http://www.w3.org/2000/svg",
647
761
  fill: e.Color || "currentColor",
648
762
  ...e,
649
- children: /* @__PURE__ */ o("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" })
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,
768
+ onClose: n,
769
+ onReset: r,
656
770
  onBack: s,
657
- showMinimize: l = !1,
771
+ showMinimize: o = !1,
658
772
  envStage: a,
659
773
  envPulse: i = !0
660
- }) => /* @__PURE__ */ k("header", { className: "chat-header", children: [
661
- /* @__PURE__ */ k("div", { className: "chat-header-left", children: [
662
- s && /* @__PURE__ */ o(
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
780
  onClick: s,
667
781
  className: "icon-btn-back",
668
782
  "aria-label": "Back",
669
- children: /* @__PURE__ */ o(Ot, { size: 16 })
783
+ children: /* @__PURE__ */ l(qt, { size: 16 })
670
784
  }
671
785
  ),
672
- /* @__PURE__ */ o(
786
+ /* @__PURE__ */ l(
673
787
  "div",
674
788
  {
675
789
  className: "avatar-circle",
676
790
  "aria-hidden": "true",
677
- children: /* @__PURE__ */ o(Qt, { width: "16px", height: "16px", color: "white" })
791
+ children: /* @__PURE__ */ l(Qt, { width: "16px", height: "16px", color: "white" })
678
792
  }
679
793
  ),
680
- /* @__PURE__ */ k("div", { children: [
681
- /* @__PURE__ */ k("div", { className: "chat-header-title-row", children: [
682
- /* @__PURE__ */ o("h2", { className: "chat-header-title", children: e }),
683
- /* @__PURE__ */ o(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__ */ o("p", { className: "chat-header-subtitle", children: t || "Customer portal support" })
799
+ /* @__PURE__ */ l("p", { className: "chat-header-subtitle", children: t || "Customer portal support" })
686
800
  ] })
687
801
  ] }),
688
- /* @__PURE__ */ k("div", { className: "chat-header-actions", children: [
689
- n && /* @__PURE__ */ o(
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,
807
+ onClick: r,
694
808
  className: "icon-btn-action",
695
809
  "aria-label": "Start a new conversation",
696
810
  title: "New conversation",
697
- children: /* @__PURE__ */ o(Yt, { size: 15 })
811
+ children: /* @__PURE__ */ l(jt, { size: 15 })
698
812
  }
699
813
  ),
700
- r && /* @__PURE__ */ o(
814
+ n && /* @__PURE__ */ l(
701
815
  "button",
702
816
  {
703
817
  type: "button",
704
- onClick: r,
818
+ onClick: n,
705
819
  className: "icon-btn-action",
706
- "aria-label": l ? "Minimize chat" : "Close chat",
707
- children: /* @__PURE__ */ o(jt, { size: 16 })
820
+ "aria-label": o ? "Minimize chat" : "Close chat",
821
+ children: /* @__PURE__ */ l(Ut, { size: 16 })
708
822
  }
709
823
  )
710
824
  ] })
711
825
  ] });
712
- function tr(e, t) {
713
- const r = K(e);
714
- me(() => {
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 rr(e, t) {
720
- const r = t.trim().toLowerCase();
721
- return r ? e.filter(
722
- (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)
723
837
  ) : e;
724
838
  }
725
- const nr = ({
839
+ const rr = ({
726
840
  suggestions: e,
727
841
  onSelect: t,
728
- disabled: r,
729
- variant: n = "list"
730
- }) => e.length ? n === "badge" ? /* @__PURE__ */ o(
842
+ disabled: n,
843
+ variant: r = "list"
844
+ }) => e.length ? r === "badge" ? /* @__PURE__ */ l(
731
845
  "ul",
732
846
  {
733
847
  className: "suggestions-badge-list",
734
848
  "aria-label": "Suggested questions",
735
- children: e.map((s) => /* @__PURE__ */ o("li", { className: "suggestion-badge-item", children: /* @__PURE__ */ o(
849
+ children: e.map((s) => /* @__PURE__ */ l("li", { className: "suggestion-badge-item", children: /* @__PURE__ */ l(
736
850
  "button",
737
851
  {
738
852
  type: "button",
739
- disabled: r,
853
+ disabled: n,
740
854
  onClick: () => t(s),
741
855
  title: s.query,
742
856
  className: "suggestion-badge-btn",
@@ -744,42 +858,42 @@ const nr = ({
744
858
  }
745
859
  ) }, s.query))
746
860
  }
747
- ) : /* @__PURE__ */ o("div", { className: "suggestions-list", children: e.map((s) => /* @__PURE__ */ o(
861
+ ) : /* @__PURE__ */ l("div", { className: "suggestions-list", children: e.map((s) => /* @__PURE__ */ l(
748
862
  "button",
749
863
  {
750
864
  type: "button",
751
- disabled: r,
865
+ disabled: n,
752
866
  onClick: () => t(s),
753
867
  className: "suggestion-list-btn",
754
868
  children: s.label
755
869
  },
756
870
  s.query
757
- )) }) : null, sr = ({
871
+ )) }) : null, nr = ({
758
872
  onSend: e,
759
873
  disabled: t = !1,
760
- placeholder: r = "Ask something…"
874
+ placeholder: n = "Ask something…"
761
875
  }) => {
762
- const { suggestions: n, showSuggestions: s, suggestionBadgesEnabled: l } = ve(), [a, i] = j(""), d = K(null), h = (u) => {
763
- 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`);
764
878
  };
765
- tr(t, d), me(() => {
766
- h(d.current);
879
+ er(t, c), ie(() => {
880
+ f(c.current);
767
881
  }, [a]);
768
- const g = Ce(() => {
769
- if (!l || t) return [];
770
- const u = a.trim();
771
- return u ? rr(n, u) : s ? n : [];
772
- }, [t, s, l, n, a]), v = (u) => {
773
- i(u.query);
774
- const m = d.current;
775
- m == null || m.focus();
776
- }, f = () => {
777
- const u = a.trim();
778
- !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"));
779
893
  };
780
- return /* @__PURE__ */ k("div", { className: "chat-input-wrapper", children: [
781
- /* @__PURE__ */ o(
782
- nr,
894
+ return /* @__PURE__ */ T("div", { className: "chat-input-wrapper", children: [
895
+ /* @__PURE__ */ l(
896
+ rr,
783
897
  {
784
898
  variant: "badge",
785
899
  suggestions: g,
@@ -787,827 +901,920 @@ const nr = ({
787
901
  disabled: t
788
902
  }
789
903
  ),
790
- /* @__PURE__ */ o("label", { htmlFor: "vps-chat-input", className: "sr-only", children: "Chat message" }),
791
- /* @__PURE__ */ k("div", { className: "chat-input-row", children: [
792
- /* @__PURE__ */ o(
904
+ /* @__PURE__ */ l("label", { htmlFor: "vps-chat-input", className: "sr-only", children: "Chat message" }),
905
+ /* @__PURE__ */ T("div", { className: "chat-input-row", children: [
906
+ /* @__PURE__ */ l(
793
907
  "textarea",
794
908
  {
795
909
  id: "vps-chat-input",
796
- ref: d,
910
+ ref: c,
797
911
  rows: 1,
798
912
  value: a,
799
913
  disabled: t,
800
- placeholder: r,
801
- onChange: (u) => {
802
- i(u.target.value), h(u.target);
914
+ placeholder: n,
915
+ onChange: (d) => {
916
+ i(d.target.value), f(d.target);
803
917
  },
804
- onKeyDown: (u) => {
805
- u.key === "Enter" && !u.shiftKey && (u.preventDefault(), f());
918
+ onKeyDown: (d) => {
919
+ d.key === "Enter" && !d.shiftKey && (d.preventDefault(), h());
806
920
  },
807
921
  className: "chat-textarea"
808
922
  }
809
923
  ),
810
- /* @__PURE__ */ o(
924
+ /* @__PURE__ */ l(
811
925
  "button",
812
926
  {
813
927
  type: "button",
814
- onClick: f,
928
+ onClick: h,
815
929
  disabled: t || !a.trim(),
816
930
  "aria-label": "Send message",
817
931
  className: "chat-send-btn",
818
- children: /* @__PURE__ */ o(Ht, { size: 16 })
932
+ children: /* @__PURE__ */ l(Wt, { size: 16 })
819
933
  }
820
934
  )
821
935
  ] }),
822
- /* @__PURE__ */ k("p", { className: "chat-input-footer", children: [
936
+ /* @__PURE__ */ T("p", { className: "chat-input-footer", children: [
823
937
  "Powered by ",
824
- /* @__PURE__ */ o("span", { className: "chat-input-footer-brand", children: "VPS Veritas AI" })
938
+ /* @__PURE__ */ l("span", { className: "chat-input-footer-brand", children: "VPS Veritas AI" })
825
939
  ] })
826
940
  ] });
827
941
  };
828
- function lr({ defaultTagName: e, props: t, render: r, state: n = {}, stateAttributesMapping: s }) {
829
- let l = Se(or(n, s), t);
830
- if (!r) return c.createElement(e, l);
831
- if (typeof r == "function") return r(l, n);
832
- if (!c.isValidElement(r)) return null;
833
- let a = r.props, i = { ...Se(l, a), ref: ae(l.ref, a.ref) };
834
- return c.cloneElement(r, i);
835
- }
836
- function Se(...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) {
837
951
  let t = {};
838
- for (let r of e) {
839
- if (!r) continue;
840
- let n = r;
841
- for (let s of Object.keys(n)) {
842
- let l = n[s];
843
- if (l === void 0) continue;
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;
844
958
  let a = t[s];
845
- s === "className" ? t[s] = [a, l].filter(Boolean).join(" ") : s === "style" ? t[s] = { ...a, ...l } : s === "ref" ? t[s] = ae(a, l) : ir(s) && typeof a == "function" && typeof l == "function" ? t[s] = ar(l, a) : t[s] = l;
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;
846
960
  }
847
961
  }
848
962
  return t;
849
963
  }
850
964
  function or(e, t) {
851
- var n;
852
- let r = {};
965
+ var r;
966
+ let n = {};
853
967
  for (let s of Object.keys(e)) {
854
- let l = e[s], a = (n = t == null ? void 0 : t[s]) == null ? void 0 : n.call(t, l);
968
+ let o = e[s], a = (r = t == null ? void 0 : t[s]) == null ? void 0 : r.call(t, o);
855
969
  if (a) {
856
- Object.assign(r, a);
970
+ Object.assign(n, a);
857
971
  continue;
858
972
  }
859
973
  if (s === "slot") {
860
- r["data-slot"] = l;
974
+ n["data-slot"] = o;
861
975
  continue;
862
976
  }
863
- let i = `data-${String(s).replace(/[A-Z]/g, (d) => `-${d.toLowerCase()}`)}`;
864
- typeof l == "boolean" ? r[i] = l ? "" : void 0 : l != null && (r[i] = String(l));
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));
865
979
  }
866
- return r;
980
+ return n;
867
981
  }
868
- function ar(e, t) {
869
- return function(r) {
870
- e(r), r.defaultPrevented || t(r);
982
+ function lr(e, t) {
983
+ return function(n) {
984
+ e(n), n.defaultPrevented || t(n);
871
985
  };
872
986
  }
873
- function ir(e) {
987
+ function ar(e) {
874
988
  return /^on[A-Z]/.test(e);
875
989
  }
876
- function ae(...e) {
990
+ function pe(...e) {
877
991
  let t = e.filter(Boolean);
878
- if (t.length !== 0) return (r) => {
879
- 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);
880
994
  };
881
995
  }
882
- var cr = 8, ur = 64, dr = 0, be = 0.5, fr = 180, hr = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "End", "Home", "PageDown", "PageUp", " "]), at = { start: !1, end: !1 }, pr = [], _e = { currentAnchorId: null, visibleMessageIds: pr };
883
- function gr({ content: e, scrollEdgeThreshold: t, spacer: r, viewport: n }) {
884
- if (!n || !e) return at;
885
- let s = Te({ content: e, spacer: r, viewport: n });
886
- return { start: n.scrollTop > t, end: s - n.scrollTop - n.clientHeight > t };
887
- }
888
- function mr({ content: e, scrollMargin: t, scrollPreviousItemPeek: r, spacer: n, viewport: s, visibleMessageIds: l }) {
889
- if (!e || !s) return _e;
890
- let a = s.getBoundingClientRect(), i = a.top + t + r, d = typeof IntersectionObserver > "u", h = [], g = null;
891
- for (let v of le(e, n)) {
892
- let f = v.dataset.messageId;
893
- if (!f) continue;
894
- let u = v.dataset.scrollAnchor === "true", m = u || d ? v.getBoundingClientRect() : null;
895
- (d && m ? m.bottom > i && m.top < a.bottom : l.has(f)) && h.push(f), u && m && m.top <= i + be && (g = 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);
896
1010
  }
897
- return h.length === 0 && g === null ? _e : { currentAnchorId: g, visibleMessageIds: h };
1011
+ return f.length === 0 && g === null ? ye : { currentAnchorId: g, visibleMessageIds: f };
898
1012
  }
899
- function le(e, t) {
900
- 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);
901
1015
  }
902
- function br(e, t) {
903
- for (let r = t; r < e.length; r++) {
904
- let n = e[r];
905
- 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;
906
1020
  }
907
1021
  return null;
908
1022
  }
909
- function _r(e, t) {
910
- 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;
911
1025
  return null;
912
1026
  }
913
1027
  function vr(e, t) {
914
- var n;
915
- let r = 0;
916
- for (let s = t; s < e.length; s++) if (((n = e[s]) == null ? void 0 : n.dataset.scrollAnchor) === "true" && (r += 1, r > 1)) return !0;
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;
917
1031
  return !1;
918
1032
  }
919
- function yr(e) {
1033
+ function _r(e) {
920
1034
  for (let t = e.length - 1; t >= 0; t--) {
921
- let r = e[t];
922
- 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;
923
1037
  }
924
1038
  return null;
925
1039
  }
926
- function wr({ content: e, spacer: t, viewport: r }) {
927
- let n = r.getBoundingClientRect();
928
- for (let s of le(e, t)) {
1040
+ function wr({ content: e, spacer: t, viewport: n }) {
1041
+ let r = n.getBoundingClientRect();
1042
+ for (let s of fe(e, t)) {
929
1043
  if (!s.dataset.messageId) continue;
930
- let l = s.getBoundingClientRect();
931
- if (l.bottom > n.top && l.top < n.bottom) return s;
1044
+ let o = s.getBoundingClientRect();
1045
+ if (o.bottom > r.top && o.top < r.bottom) return s;
932
1046
  }
933
1047
  return null;
934
1048
  }
935
- function Cr({ align: e, element: t, scrollMargin: r, spacer: n, viewport: s }) {
936
- let l = it(t, s), 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);
937
1051
  if (e === "center") {
938
- let d = Math.max(0, s.clientHeight - i.start - i.end);
939
- return l - 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;
940
1054
  }
941
- if (e === "end") return l - s.clientHeight + a + i.end + r;
1055
+ if (e === "end") return o - s.clientHeight + a + i.end + n;
942
1056
  if (e === "nearest") {
943
- let d = l + a, h = s.scrollTop + i.start, g = s.scrollTop + s.clientHeight - i.end;
944
- return l >= h && d <= g ? s.scrollTop : l < h ? l - i.start - r : d - s.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;
945
1059
  }
946
- return l - i.start - r;
1060
+ return o - i.start - n;
947
1061
  }
948
- function it(e, t) {
949
- let r = e.getBoundingClientRect(), n = t.getBoundingClientRect();
950
- 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;
951
1065
  }
952
- function pe(e, t) {
1066
+ function ve(e, t) {
953
1067
  return e.getBoundingClientRect().top - t.getBoundingClientRect().top;
954
1068
  }
955
- function kr({ content: e, scrollTop: t, spacer: r, viewport: n }) {
956
- let s = Te({ content: e, spacer: r, viewport: n });
957
- return t + n.clientHeight - s;
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;
958
1072
  }
959
- function Te({ content: e, spacer: t, viewport: r }) {
960
- let n = le(e, t), s = ct(e), l = r.getBoundingClientRect(), a = r.scrollTop, i = s.start + s.end;
961
- for (let d of n) {
962
- let h = d.getBoundingClientRect();
963
- i = Math.max(i, h.bottom - l.top + a + s.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);
964
1078
  }
965
1079
  return i;
966
1080
  }
967
- function Sr(e) {
1081
+ function Cr(e) {
968
1082
  return Math.max(0, e.scrollHeight - e.clientHeight);
969
1083
  }
970
- function ct(e) {
1084
+ function ht(e) {
971
1085
  let t = window.getComputedStyle(e);
972
- return { end: Fe(t.paddingBlockEnd || t.paddingBottom), start: Fe(t.paddingBlockStart || t.paddingTop) };
1086
+ return { end: Re(t.paddingBlockEnd || t.paddingBottom), start: Re(t.paddingBlockStart || t.paddingTop) };
973
1087
  }
974
- function Fr(e) {
1088
+ function Sr(e) {
975
1089
  let t = e == null ? void 0 : e.parentElement;
976
- return t ? ct(t) : { end: 0, start: 0 };
1090
+ return t ? ht(t) : { end: 0, start: 0 };
977
1091
  }
978
- function Er(e) {
1092
+ function Tr(e) {
979
1093
  if (!e) return 0;
980
- let t = window.getComputedStyle(e), r = t.rowGap === "normal" ? t.gap : t.rowGap;
981
- return Fe(r);
1094
+ let t = window.getComputedStyle(e), n = t.rowGap === "normal" ? t.gap : t.rowGap;
1095
+ return Re(n);
982
1096
  }
983
- function Fe(e) {
1097
+ function Re(e) {
984
1098
  if (!e) return 0;
985
1099
  let t = Number.parseFloat(e);
986
1100
  return Number.isFinite(t) ? t : 0;
987
1101
  }
988
- function ut(e, t) {
989
- let r = e, n = /* @__PURE__ */ new Set();
990
- return { getSnapshot: () => r, hasListeners: () => n.size > 0, setSnapshot: (s) => {
991
- t(r, s) || (r = s, n.forEach((l) => l()));
992
- }, subscribe: (s, l, a) => {
993
- let i = n.size === 0;
994
- return n.add(s), i && (l == null || l()), () => {
995
- n.delete(s), 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());
996
1110
  };
997
1111
  } };
998
1112
  }
999
- function Ue(e, t) {
1000
- return ut(e, t);
1113
+ function Ke(e, t) {
1114
+ return ft(e, t);
1001
1115
  }
1002
- function Tr() {
1003
- return ut(_e, Ar);
1116
+ function Fr() {
1117
+ return ft(ye, Rr);
1004
1118
  }
1005
- function Rr(e, t) {
1119
+ function Er(e, t) {
1006
1120
  return e.start === t.start && e.end === t.end;
1007
1121
  }
1008
- function Ar(e, t) {
1009
- 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]);
1010
1124
  }
1011
- function Br({ autoScroll: e, defaultScrollPosition: t, scrollEdgeThreshold: r, scrollMargin: n, scrollPreviousItemPeek: s }) {
1012
- let l = c.useRef(e), a = c.useRef(!1), i = c.useRef(null), d = c.useRef(!1), h = c.useRef(r), g = c.useRef(0), v = c.useRef(null), f = c.useRef(0), u = c.useRef(e ? "following-bottom" : "free-scrolling"), m = c.useRef(/* @__PURE__ */ new Map()), T = c.useRef(null), _ = c.useRef(null), D = c.useRef(null), V = c.useRef(s), L = c.useRef(!0), $ = c.useRef(null), P = c.useRef(n), I = c.useRef(null), R = c.useRef(0), O = c.useRef(0), N = c.useRef(null), Z = c.useRef(null), U = c.useRef(null), b = c.useRef(null), y = c.useRef(null), S = c.useRef(null), F = c.useRef(null), B = c.useRef(null), A = c.useRef(null), E = c.useRef(/* @__PURE__ */ new Set()), W = c.useRef(/* @__PURE__ */ new WeakSet());
1013
- return U.current === null && (U.current = Ue(t === "end" || t === "last-anchor", (z, ce) => z === ce)), b.current === null && (b.current = Ue(at, Rr)), A.current === null && (A.current = Tr()), l.current = e, h.current = r, P.current = n, V.current = s, { autoScrollRef: l, autoscrollingRef: a, autoscrollingTimeoutRef: y, streamingTurnRef: D, contentRef: i, defaultScrollPositionAppliedRef: d, firstItemRef: v, itemCountRef: g, lastScrollTopRef: f, messageElementsRef: m, modeRef: u, pendingScrollFrameRef: I, pendingScrollToMessageRef: T, prependRestoreRef: _, preserveScrollOnPrependRef: L, pendingDefaultScrollStore: U.current, rootRef: $, scrollEdgeThresholdRef: h, scrollMarginRef: P, scrollPreviousItemPeekRef: V, spacerGapRef: R, spacerHeightRef: O, spacerRef: N, stateFrameRef: Z, stateStore: b.current, viewportRef: S, visibilityFrameRef: F, visibilityObserverRef: B, visibilityStore: A.current, visibleMessageIdsRef: E, handledScrollAnchorsRef: W };
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 };
1014
1128
  }
1015
- function dt(e) {
1129
+ function pt(e) {
1016
1130
  e.pendingDefaultScrollStore.setSnapshot(!1);
1017
1131
  }
1018
- function ge(e) {
1019
- e.defaultScrollPositionAppliedRef.current = !0, dt(e);
1132
+ function _e(e) {
1133
+ e.defaultScrollPositionAppliedRef.current = !0, pt(e);
1020
1134
  }
1021
- function Dr({ refs: e, commitScrollState: t, scheduleStateCommit: r, scheduleVisibilitySync: n }) {
1022
- let { streamingTurnRef: s, autoScrollRef: l, autoscrollingRef: a, autoscrollingTimeoutRef: i, contentRef: d, itemCountRef: h, messageElementsRef: g, modeRef: v, pendingScrollToMessageRef: f, prependRestoreRef: u, scrollMarginRef: m, scrollPreviousItemPeekRef: T, spacerGapRef: _, spacerHeightRef: D, spacerRef: V, viewportRef: L } = e, $ = c.useCallback((b) => {
1023
- 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(() => {
1024
1138
  i.current = null, a.current = !1, t();
1025
- }, fr));
1026
- }, [t]), P = c.useCallback((b) => {
1027
- let y = V.current;
1028
- if (!y) return;
1029
- let S = Math.max(0, Math.ceil(b));
1030
- D.current !== S && (D.current = S, y.hidden = S === 0, y.style.height = `${S}px`, y.style.marginTop = S > 0 ? `${-_.current}px` : "");
1031
- }, []), I = c.useCallback((b, { behavior: y = "auto", autoscrolling: S = !1 } = {}) => {
1032
- let F = L.current;
1033
- if (!F) return;
1034
- let B = Math.max(0, b);
1035
- if (Math.abs(F.scrollTop - B) <= be) {
1036
- F.scrollTop = B, t();
1139
+ }, dr));
1140
+ }, [t]), I = u.useCallback((_) => {
1141
+ let S = k.current;
1142
+ if (!S) return;
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();
1037
1151
  return;
1038
1152
  }
1039
- S && $(!0), F.scrollTo({ top: B, behavior: y }), r();
1040
- }, [t, r, $]), R = c.useCallback(({ behavior: b = "auto" } = {}) => L.current ? (P(0), s.current = null, v.current = "free-scrolling", I(0, { behavior: b }), n(), !0) : !1, [n, I, P]), O = c.useCallback(({ behavior: b = "auto" } = {}) => {
1041
- let y = L.current;
1042
- return y ? (P(0), s.current = null, v.current = l.current ? "following-bottom" : "free-scrolling", I(Sr(y), { autoscrolling: !0, behavior: b }), n(), !0) : !1;
1043
- }, [n, I, P]), N = c.useCallback((b, { align: y = "start", behavior: S = "auto", scrollMargin: F = m.current } = {}, { keepPreviousPeek: B = !1 } = {}) => {
1044
- let A = d.current, E = L.current;
1045
- if (!A || !E || !A.contains(b)) return !1;
1046
- let W = Cr({ align: y, element: b, scrollMargin: B ? F + T.current : F, spacer: V.current, viewport: E }), z = kr({ content: A, scrollTop: W, spacer: V.current, viewport: E });
1047
- return P(z), u.current = { element: b, viewportTop: pe(b, E) }, v.current = B ? "anchored-to-message" : "settling-jump", s.current = B ? b : null, I(W, { behavior: S }), n(), !0;
1048
- }, [n, I, P]), Z = c.useCallback(() => {
1049
- let b = s.current;
1050
- return !b || !b.isConnected || v.current !== "anchored-to-message" ? !1 : N(b, { align: "start" }, { keepPreviousPeek: !0 });
1051
- }, [N]), U = c.useCallback((b, y) => {
1052
- let S = g.current.get(b);
1053
- return S ? (ge(e), N(S, y) ? (f.current = null, !0) : (f.current = { messageId: b, options: y }, !0)) : h.current === 0 ? (f.current = { messageId: b, options: y }, ge(e), !0) : !1;
1054
- }, [N]);
1055
- return { flushPendingScrollToMessage: c.useCallback(() => {
1056
- let b = f.current;
1057
- if (!b) return !1;
1058
- let y = g.current.get(b.messageId);
1059
- return !y || !N(y, b.options) ? !1 : (f.current = null, ge(e), !0);
1060
- }, [N]), reanchorToAnchoredMessage: Z, scrollToElement: N, scrollToEnd: O, scrollToMessage: U, scrollToStart: R };
1061
- }
1062
- function je(e, t) {
1063
- return c.useCallback((r) => {
1064
- 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();
1065
1179
  }, [e, t]);
1066
1180
  }
1067
- function Mr({ autoScroll: e = !1, defaultScrollPosition: t = "end", scrollEdgeThreshold: r = cr, scrollPreviousItemPeek: n = ur, scrollMargin: s = dr }) {
1068
- let l = Br({ autoScroll: e, defaultScrollPosition: t, scrollEdgeThreshold: r, scrollMargin: s, scrollPreviousItemPeek: n }), { streamingTurnRef: a, autoScrollRef: i, autoscrollingRef: d, autoscrollingTimeoutRef: h, contentRef: g, defaultScrollPositionAppliedRef: v, firstItemRef: f, itemCountRef: u, lastScrollTopRef: m, messageElementsRef: T, modeRef: _, pendingScrollFrameRef: D, pendingScrollToMessageRef: V, prependRestoreRef: L, preserveScrollOnPrependRef: $, pendingDefaultScrollStore: P, rootRef: I, scrollEdgeThresholdRef: R, scrollMarginRef: O, scrollPreviousItemPeekRef: N, spacerGapRef: Z, spacerHeightRef: U, spacerRef: b, stateFrameRef: y, stateStore: S, viewportRef: F, visibilityFrameRef: B, visibilityObserverRef: A, visibilityStore: E, visibleMessageIdsRef: W, handledScrollAnchorsRef: z } = l, ce = c.useRef(t);
1069
- ce.current !== t && (ce.current = t, v.current = !1);
1070
- let ue = c.useCallback((p) => {
1071
- let w = I.current, C = F.current, M = [p.start && "start", p.end && "end"].filter(Boolean).join(" "), J = d.current;
1072
- for (let G of [w, C]) G && (M ? G.setAttribute("data-scrollable", M) : G.removeAttribute("data-scrollable"), G.toggleAttribute("data-autoscrolling", J));
1073
- }, []), Re = c.useCallback((p) => {
1074
- var M;
1075
- let w = ((M = F.current) == null ? void 0 : M.scrollTop) ?? 0, C = w < m.current - be;
1076
- m.current = w, i.current && !p.end && _.current !== "settling-jump" && _.current !== "anchored-to-message" ? _.current = "following-bottom" : _.current === "following-bottom" && p.end && C && !d.current && (_.current = "free-scrolling");
1077
- }, []), Y = c.useCallback(() => {
1078
- let p = gr({ content: g.current, scrollEdgeThreshold: R.current, spacer: b.current, viewport: F.current });
1079
- Re(p);
1080
- let w = _.current === "following-bottom" ? { ...p, end: !1 } : p;
1081
- ue(w), S.setSnapshot(w);
1082
- }, [Re, S, ue]), ne = c.useCallback(() => {
1083
- y.current === null && (y.current = window.requestAnimationFrame(() => {
1084
- y.current = null, Y();
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();
1085
1199
  }));
1086
- }, [Y]), x = c.useCallback(() => {
1087
- E.hasListeners() && B.current === null && (B.current = window.requestAnimationFrame(() => {
1088
- B.current = null, E.hasListeners() && E.setSnapshot(mr({ content: g.current, scrollMargin: O.current, scrollPreviousItemPeek: N.current, spacer: b.current, viewport: F.current, visibleMessageIds: W.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 }));
1089
1203
  }));
1090
- }, [E]), { flushPendingScrollToMessage: de, reanchorToAnchoredMessage: Ae, scrollToElement: se, scrollToEnd: q, scrollToMessage: Be, scrollToStart: fe } = Dr({ refs: l, commitScrollState: Y, scheduleStateCommit: ne, scheduleVisibilitySync: x }), De = c.useCallback(() => {
1091
- let p = L.current, w = F.current;
1092
- if (!p || !w || !p.element.isConnected) return !1;
1093
- let C = pe(p.element, w) - p.viewportTop;
1094
- return Math.abs(C) <= be ? !1 : (w.scrollTop += C, p.viewportTop = pe(p.element, w), ne(), x(), !0);
1095
- }, [ne, x]), Q = c.useCallback(() => {
1096
- let p = g.current, w = F.current;
1097
- if (!p || !w) {
1098
- 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;
1099
1213
  return;
1100
1214
  }
1101
- let C = wr({ content: p, spacer: b.current, viewport: w });
1102
- L.current = C ? { element: C, viewportTop: pe(C, w) } : null;
1103
- }, []), Me = c.useCallback(() => {
1104
- D.current === null && (D.current = window.requestAnimationFrame(() => {
1105
- D.current = null, de() && Q();
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();
1106
1220
  }));
1107
- }, [Q, de]), he = c.useCallback(() => {
1108
- if (!t || v.current || u.current === 0) return !1;
1109
- let p = !1;
1221
+ }, [ae, $]), be = u.useCallback(() => {
1222
+ if (!t || v.current || d.current === 0) return !1;
1223
+ let m = !1;
1110
1224
  if (t === "last-anchor") {
1111
- let w = g.current, C = F.current, M = w && C ? yr(le(w, b.current)) : null;
1112
- if (!w || !C || !M) p = 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" });
1113
1227
  else {
1114
- let J = it(M, C);
1115
- p = Te({ content: w, spacer: b.current, viewport: C }) - J <= C.clientHeight ? q({ behavior: "auto" }) : se(M, { 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 });
1116
1230
  }
1117
- } else p = t === "end" ? q({ behavior: "auto" }) : fe({ behavior: "auto" });
1118
- return p ? (ge(l), !0) : !1;
1119
- }, [t, se, q, fe]), Ie = c.useCallback(() => {
1120
- let p = g.current;
1121
- if (!p) return;
1122
- let w = le(p, b.current), C = u.current, M = f.current;
1123
- u.current = w.length, f.current = w[0] ?? null, (() => {
1124
- if (de()) return;
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;
1125
1239
  if (C === 0) {
1126
- if (he() || w.length > 0 && i.current && q({ behavior: "auto" })) return;
1127
- Y(), x();
1240
+ if (be() || w.length > 0 && i.current && H({ behavior: "auto" })) return;
1241
+ J(), A();
1128
1242
  return;
1129
1243
  }
1130
- let J = M ? w.indexOf(M) : -1;
1131
- if ($.current && J > 0) {
1132
- De();
1244
+ let ne = O ? w.indexOf(O) : -1;
1245
+ if (j.current && ne > 0) {
1246
+ Ne();
1133
1247
  return;
1134
1248
  }
1135
1249
  if (w.length > C) {
1136
- let G = br(w, C);
1137
- if (G) {
1138
- if (i.current && _.current === "following-bottom" && vr(w, C)) {
1139
- q({ behavior: "auto" });
1250
+ let V = mr(w, C);
1251
+ if (V) {
1252
+ if (i.current && b.current === "following-bottom" && vr(w, C)) {
1253
+ H({ behavior: "auto" });
1140
1254
  return;
1141
1255
  }
1142
- se(G, { align: "start" }, { keepPreviousPeek: !0 }), z.current.add(G);
1256
+ U(V, { align: "start" }, { keepPreviousPeek: !0 }), re.current.add(V);
1143
1257
  return;
1144
1258
  }
1145
1259
  }
1146
1260
  if (w.length === C) {
1147
- let G = _r(w, z.current);
1148
- if (G) {
1149
- se(G, { align: "start" }, { keepPreviousPeek: !0 }), z.current.add(G);
1261
+ let V = br(w, re.current);
1262
+ if (V) {
1263
+ U(V, { align: "start" }, { keepPreviousPeek: !0 }), re.current.add(V);
1150
1264
  return;
1151
1265
  }
1152
1266
  }
1153
- _.current === "following-bottom" && i.current ? q({ behavior: "auto" }) : (Y(), x());
1154
- })(), Q();
1155
- }, [he, Q, Y, de, De, x, se, q]), Ne = c.useCallback(() => {
1156
- if (_.current === "following-bottom" && i.current) {
1157
- 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" });
1158
1272
  return;
1159
1273
  }
1160
- let p = U.current;
1161
- if (Ae()) {
1162
- i.current && p > 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" });
1163
1277
  return;
1164
1278
  }
1165
- ne(), x();
1166
- }, [Ae, ne, x, q]), Pe = c.useCallback(() => {
1167
- let p = F.current;
1168
- if (!(!p || !E.hasListeners())) {
1279
+ oe(), A();
1280
+ }, [Z, oe, A, H]), Oe = u.useCallback(() => {
1281
+ let m = B.current;
1282
+ if (!(!m || !x.hasListeners())) {
1169
1283
  if (typeof IntersectionObserver > "u") {
1170
- x();
1284
+ A();
1171
1285
  return;
1172
1286
  }
1173
- A.current || (A.current = new IntersectionObserver((w) => {
1287
+ P.current || (P.current = new IntersectionObserver((w) => {
1174
1288
  for (let C of w) {
1175
- let M = C.target.dataset.messageId;
1176
- M && (C.isIntersecting ? W.current.add(M) : W.current.delete(M));
1289
+ let O = C.target.dataset.messageId;
1290
+ O && (C.isIntersecting ? G.current.add(O) : G.current.delete(O));
1177
1291
  }
1178
- x();
1179
- }, { root: p, rootMargin: `${-(O.current + N.current)}px 0px 0px 0px`, threshold: [0, 0.01, 0.5, 1] })), T.current.forEach((w) => {
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) => {
1180
1294
  var C;
1181
- (C = A.current) == null || C.observe(w);
1182
- }), x();
1295
+ (C = P.current) == null || C.observe(w);
1296
+ }), A();
1183
1297
  }
1184
- }, [x, E]), xe = c.useCallback(() => {
1185
- var p;
1186
- B.current !== null && (window.cancelAnimationFrame(B.current), B.current = null), (p = A.current) == null || p.disconnect(), A.current = null, W.current.clear(), E.setSnapshot(_e);
1187
- }, [E]), _t = c.useCallback((p, w, C) => {
1188
- var M, J, G;
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;
1189
1303
  if (w) {
1190
- T.current.set(p, w), (M = A.current) == null || M.observe(w), x(), ((J = V.current) == null ? void 0 : J.messageId) === p && Me();
1304
+ y.current.set(m, w), (O = P.current) == null || O.observe(w), A(), ((ne = k.current) == null ? void 0 : ne.messageId) === m && Pe();
1191
1305
  return;
1192
1306
  }
1193
- C && T.current.get(p) === C && (T.current.delete(p), W.current.delete(p), (G = A.current) == null || G.unobserve(C), x());
1194
- }, [Me, x]), Le = c.useCallback(() => {
1195
- (_.current === "following-bottom" || _.current === "anchored-to-message" || _.current === "settling-jump") && (a.current = null, _.current = "free-scrolling");
1196
- }, []), Oe = c.useCallback(() => ue(S.getSnapshot()), [S, ue]), He = je(I, Oe), ze = je(F, Oe), qe = c.useCallback((p) => {
1197
- g.current = p;
1198
- }, []), Ge = c.useCallback((p) => {
1199
- b.current = p, Z.current = Er((p == null ? void 0 : p.parentElement) ?? null);
1200
- }, []), Ve = c.useCallback(() => {
1201
- Y(), x(), Q();
1202
- }, [Q, Y, x]), vt = c.useMemo(() => ({ handleContentChange: Ie, handleResize: Ne, observeVisibility: Pe, pendingDefaultScrollStore: P, preserveScrollOnPrependRef: $, scrollToEnd: q, scrollToMessage: Be, scrollToStart: fe, setContentElement: qe, setRootElement: He, setSpacerElement: Ge, setViewportElement: ze, stateStore: S, syncAfterScroll: Ve, unobserveVisibility: xe, userScrollIntent: Le, viewportRef: F, visibilityStore: E }), [Ie, Ne, Pe, P, q, Be, fe, qe, He, Ge, ze, S, Ve, xe, Le, E]);
1203
- return c.useLayoutEffect(() => {
1204
- he() || u.current === 0 && dt(l);
1205
- }, [he]), c.useEffect(() => () => {
1206
- var p;
1207
- y.current !== null && (window.cancelAnimationFrame(y.current), y.current = null), B.current !== null && (window.cancelAnimationFrame(B.current), B.current = null), h.current !== null && (window.clearTimeout(h.current), h.current = null), D.current !== null && (window.cancelAnimationFrame(D.current), D.current = null), (p = A.current) == null || p.disconnect(), A.current = null;
1208
- }, []), c.useLayoutEffect(() => {
1209
- if (e && _.current === "following-bottom" && u.current > 0) {
1210
- 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" });
1211
1325
  return;
1212
1326
  }
1213
- Y();
1214
- }, [e, Y, q]), { context: vt, registerMessage: _t };
1327
+ J();
1328
+ }, [e, J, H]), { context: kt, registerMessage: yt };
1215
1329
  }
1216
- function Ir(e) {
1217
- let t = c.useRef(e);
1330
+ function Dr(e) {
1331
+ let t = u.useRef(e);
1218
1332
  return t.current = e, t;
1219
1333
  }
1220
- var ft = c.createContext(null), ht = c.createContext(null);
1221
- function ie() {
1222
- let e = c.useContext(ft);
1334
+ var gt = u.createContext(null), mt = u.createContext(null);
1335
+ function ge() {
1336
+ let e = u.useContext(gt);
1223
1337
  if (!e) throw new Error("useMessageScroller must be used within a MessageScroller.");
1224
1338
  return e;
1225
1339
  }
1226
- function Nr() {
1227
- let e = c.useContext(ht);
1340
+ function Ir() {
1341
+ let e = u.useContext(mt);
1228
1342
  if (!e) throw new Error("MessageScrollerItem must be used within a MessageScroller.");
1229
1343
  return e;
1230
1344
  }
1231
- function Pr({ autoScroll: e = !1, children: t, defaultScrollPosition: r = "end", scrollEdgeThreshold: n, scrollPreviousItemPeek: s, scrollMargin: l }) {
1232
- let { context: a, registerMessage: i } = Mr({ autoScroll: e, defaultScrollPosition: r, scrollEdgeThreshold: n, scrollPreviousItemPeek: s, scrollMargin: l });
1233
- return o(ft.Provider, { value: a, children: o(ht.Provider, { value: i, children: t }) });
1234
- }
1235
- function pt() {
1236
- let { pendingDefaultScrollStore: e } = ie();
1237
- return c.useSyncExternalStore(e.subscribe, e.getSnapshot, e.getSnapshot);
1238
- }
1239
- function xr({ children: e, ...t }) {
1240
- let { setRootElement: r } = ie(), n = pt();
1241
- return o("div", { ref: r, ...t, ...n ? { "data-pending-scroll": "" } : null, children: e });
1242
- }
1243
- function Lr({ "aria-label": e, children: t, onKeyDown: r, onScroll: n, onTouchMove: s, onWheel: l, preserveScrollOnPrepend: a = !0, ref: i, role: d, tabIndex: h, ...g }) {
1244
- let { handleResize: v, preserveScrollOnPrependRef: f, setViewportElement: u, syncAfterScroll: m, userScrollIntent: T, viewportRef: _ } = ie(), D = pt();
1245
- f.current = a;
1246
- let V = c.useCallback((R) => {
1247
- var O;
1248
- u(R), (O = ae(i)) == null || O(R);
1249
- }, [i, u]);
1250
- function L(R) {
1251
- m(), n == null || n(R);
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);
1252
1366
  }
1253
- function $(R) {
1254
- T(), l == null || l(R);
1367
+ function j(E) {
1368
+ y(), o == null || o(E);
1255
1369
  }
1256
- function P(R) {
1257
- T(), s == null || s(R);
1370
+ function I(E) {
1371
+ y(), s == null || s(E);
1258
1372
  }
1259
- function I(R) {
1260
- hr.has(R.key) && T(), r == null || r(R);
1373
+ function N(E) {
1374
+ hr.has(E.key) && y(), n == null || n(E);
1261
1375
  }
1262
- return c.useEffect(() => {
1263
- let R = _.current;
1264
- if (!R || typeof ResizeObserver > "u") return;
1265
- let O = 0, N = new ResizeObserver(() => {
1266
- window.cancelAnimationFrame(O), O = window.requestAnimationFrame(v);
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);
1267
1381
  });
1268
- return N.observe(R), () => {
1269
- window.cancelAnimationFrame(O), N.disconnect();
1382
+ return q.observe(E), () => {
1383
+ window.cancelAnimationFrame(L), q.disconnect();
1270
1384
  };
1271
- }, [v, _]), o("div", { ref: V, role: d ?? "region", "aria-label": e ?? "Messages", tabIndex: h ?? 0, onKeyDown: I, onScroll: L, onTouchMove: P, onWheel: $, ...g, ...D ? { "data-pending-scroll": "" } : null, children: t });
1272
- }
1273
- function Or({ "aria-relevant": e, children: t, ref: r, role: n, spacerClassName: s, ...l }) {
1274
- let { handleContentChange: a, handleResize: i, setContentElement: d, setSpacerElement: h } = ie(), g = c.useRef(null), v = c.useCallback((f) => {
1275
- var u;
1276
- g.current = f, d(f), (u = ae(r)) == null || u(f);
1277
- }, [r, d]);
1278
- return c.useLayoutEffect(() => {
1279
- let f = g.current;
1280
- if (!f || (a(), typeof MutationObserver > "u")) return;
1281
- 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(() => {
1282
1396
  a();
1283
1397
  });
1284
- return u.observe(f, { childList: !0 }), () => u.disconnect();
1285
- }, [a]), c.useEffect(() => {
1286
- let f = g.current;
1287
- if (!f || typeof ResizeObserver > "u") return;
1288
- let u = 0, m = new ResizeObserver(() => {
1289
- 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);
1290
1404
  });
1291
- return m.observe(f), () => {
1292
- window.cancelAnimationFrame(u), m.disconnect();
1405
+ return p.observe(h), () => {
1406
+ window.cancelAnimationFrame(d), p.disconnect();
1293
1407
  };
1294
- }, [i]), k("div", { ref: v, role: n ?? "log", "aria-relevant": e ?? "additions", ...l, children: [t, o("div", { ref: h, "aria-hidden": "true", "data-message-scroller-spacer": "", hidden: !0, className: s })] });
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 })] });
1295
1409
  }
1296
- function Hr({ messageId: e, ref: t, scrollAnchor: r = !1, ...n }) {
1297
- let s = Nr(), l = c.useRef(null), a = c.useCallback((i) => {
1298
- var h;
1299
- let d = l.current;
1300
- l.current = i, e && s(e, i, d), (h = ae(t)) == null || h(i);
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);
1301
1415
  }, [e, t, s]);
1302
- return o("div", { ref: a, "data-message-id": e, "data-scroll-anchor": r ? "true" : "false", ...n });
1303
- }
1304
- function zr({ behavior: e = "smooth", children: t, direction: r = "end", onClick: n, render: s, tabIndex: l, type: a = "button", ...i }) {
1305
- let { scrollToEnd: d, scrollToStart: h, stateStore: g } = ie(), v = Ir(n), f = c.useCallback((_) => g.subscribe(_), [g]), u = c.useCallback(() => {
1306
- let _ = g.getSnapshot();
1307
- return r === "start" ? _.start : _.end;
1308
- }, [r, g]), m = c.useSyncExternalStore(f, u, u), T = c.useCallback((_) => {
1309
- var D;
1310
- m && ((D = v.current) == null || D.call(v, _), _.defaultPrevented || (_.currentTarget.blur(), r === "start" ? h({ behavior: e }) : d({ behavior: e })));
1311
- }, [e, r, m, v, d, h]);
1312
- return lr({ defaultTagName: "button", props: Se({ type: a, inert: !m, tabIndex: m ? l : -1, children: t ?? k("span", { children: ["Scroll to ", r] }), onClick: T }, i), render: s, state: { active: m, direction: r }, stateAttributesMapping: { active: (_) => ({ "data-active": _ ? "true" : "false" }) } });
1313
- }
1314
- var te = { Provider: Pr, Root: xr, Viewport: Lr, Content: Or, Item: Hr, Button: zr };
1315
- function gt(e) {
1316
- var t, r, n = "";
1317
- if (typeof e == "string" || typeof e == "number") n += e;
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;
1318
1432
  else if (typeof e == "object") if (Array.isArray(e)) {
1319
1433
  var s = e.length;
1320
- for (t = 0; t < s; t++) e[t] && (r = gt(e[t])) && (n && (n += " "), n += r);
1321
- } else for (r in e) e[r] && (n && (n += " "), n += r);
1322
- return n;
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;
1323
1437
  }
1324
- function qr() {
1325
- for (var e, t, r = 0, n = "", s = arguments.length; r < s; r++) (e = arguments[r]) && (t = gt(e)) && (n && (n += " "), n += t);
1326
- return n;
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;
1327
1441
  }
1328
- function re(...e) {
1329
- return qr(e);
1442
+ function de(...e) {
1443
+ return Wr(e);
1330
1444
  }
1331
- function Gr(e) {
1332
- return /* @__PURE__ */ o(te.Provider, { ...e });
1445
+ function $r(e) {
1446
+ return /* @__PURE__ */ l(ue.Provider, { ...e });
1333
1447
  }
1334
- function Vr({
1448
+ function Hr({
1335
1449
  className: e,
1336
1450
  ...t
1337
1451
  }) {
1338
- return /* @__PURE__ */ o(
1339
- te.Root,
1452
+ return /* @__PURE__ */ l(
1453
+ ue.Root,
1340
1454
  {
1341
1455
  "data-slot": "message-scroller",
1342
- className: re("msg-scroller-root", e),
1456
+ className: de("msg-scroller-root", e),
1343
1457
  ...t
1344
1458
  }
1345
1459
  );
1346
1460
  }
1347
- function Wr({
1461
+ function Vr({
1348
1462
  className: e,
1349
1463
  ...t
1350
1464
  }) {
1351
- return /* @__PURE__ */ o(
1352
- te.Viewport,
1465
+ return /* @__PURE__ */ l(
1466
+ ue.Viewport,
1353
1467
  {
1354
1468
  "data-slot": "message-scroller-viewport",
1355
- className: re("msg-scroller-viewport", e),
1469
+ className: de("msg-scroller-viewport", e),
1356
1470
  ...t
1357
1471
  }
1358
1472
  );
1359
1473
  }
1360
- function $r({
1474
+ function zr({
1361
1475
  className: e,
1362
1476
  ...t
1363
1477
  }) {
1364
- return /* @__PURE__ */ o(
1365
- te.Content,
1478
+ return /* @__PURE__ */ l(
1479
+ ue.Content,
1366
1480
  {
1367
1481
  "data-slot": "message-scroller-content",
1368
- className: re("msg-scroller-content", e),
1482
+ className: de("msg-scroller-content", e),
1369
1483
  ...t
1370
1484
  }
1371
1485
  );
1372
1486
  }
1373
- function Ye({
1487
+ function Xe({
1374
1488
  className: e,
1375
1489
  scrollAnchor: t = !1,
1376
- ...r
1490
+ ...n
1377
1491
  }) {
1378
- return /* @__PURE__ */ o(
1379
- te.Item,
1492
+ return /* @__PURE__ */ l(
1493
+ ue.Item,
1380
1494
  {
1381
1495
  "data-slot": "message-scroller-item",
1382
1496
  scrollAnchor: t,
1383
- className: re("msg-scroller-item", e),
1384
- ...r
1497
+ className: de("msg-scroller-item", e),
1498
+ ...n
1385
1499
  }
1386
1500
  );
1387
1501
  }
1388
- function Ur({
1502
+ function Gr({
1389
1503
  direction: e = "end",
1390
1504
  className: t,
1391
- children: r,
1392
- ...n
1505
+ children: n,
1506
+ ...r
1393
1507
  }) {
1394
- return /* @__PURE__ */ o(
1395
- te.Button,
1508
+ return /* @__PURE__ */ l(
1509
+ ue.Button,
1396
1510
  {
1397
1511
  "data-slot": "message-scroller-button",
1398
1512
  direction: e,
1399
- className: re("msg-scroller-btn", t),
1400
- ...n,
1401
- children: r ?? /* @__PURE__ */ k(oe, { children: [
1402
- /* @__PURE__ */ o(
1403
- Lt,
1513
+ className: de("msg-scroller-btn", t),
1514
+ ...r,
1515
+ children: n ?? /* @__PURE__ */ T(ke, { children: [
1516
+ /* @__PURE__ */ l(
1517
+ Ot,
1404
1518
  {
1405
1519
  size: 16,
1406
1520
  "aria-hidden": "true",
1407
1521
  className: e === "start" ? "rotate-180" : void 0
1408
1522
  }
1409
1523
  ),
1410
- /* @__PURE__ */ o("span", { className: "sr-only", children: e === "end" ? "Jump to latest" : "Jump to start" })
1524
+ /* @__PURE__ */ l("span", { className: "sr-only", children: e === "end" ? "Jump to latest" : "Jump to start" })
1411
1525
  ] })
1412
1526
  }
1413
1527
  );
1414
1528
  }
1415
- const jr = () => /* @__PURE__ */ k("div", { className: "chat-empty-row", children: [
1416
- /* @__PURE__ */ o(
1529
+ const Ur = () => /* @__PURE__ */ T("div", { className: "chat-empty-row", children: [
1530
+ /* @__PURE__ */ l(
1417
1531
  "div",
1418
1532
  {
1419
1533
  className: "avatar-circle avatar-circle--mt",
1420
1534
  "aria-hidden": "true",
1421
- children: /* @__PURE__ */ o(lt, { size: 15 })
1535
+ children: /* @__PURE__ */ l(it, { size: 15 })
1422
1536
  }
1423
1537
  ),
1424
- /* @__PURE__ */ o("div", { className: "chat-empty-bubble", children: /* @__PURE__ */ o("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." }) })
1425
1539
  ] });
1426
- function ye(e) {
1427
- return e.split(/(\*\*[^*]+\*\*|`[^`]+`|https?:\/\/[^\s]+)/g).map((r, n) => r.startsWith("**") && r.endsWith("**") ? /* @__PURE__ */ o("strong", { children: r.slice(2, -2) }, n) : r.startsWith("`") && r.endsWith("`") ? /* @__PURE__ */ o(
1428
- "code",
1429
- {
1430
- className: "md-code",
1431
- children: r.slice(1, -1)
1432
- },
1433
- n
1434
- ) : /^https?:\/\//.test(r) ? /* @__PURE__ */ o(
1435
- "a",
1436
- {
1437
- href: r,
1438
- target: "_blank",
1439
- rel: "noopener noreferrer",
1440
- className: "md-link",
1441
- children: r
1442
- },
1443
- n
1444
- ) : /* @__PURE__ */ o(Xe.Fragment, { children: r }, n));
1445
- }
1446
- function Yr({ text: e }) {
1447
- if (!e) return null;
1448
- const t = e.split(/\n\n+/);
1449
- return /* @__PURE__ */ o(oe, { children: t.map((r, n) => {
1450
- if (r.trim().startsWith("- ") || r.trim().startsWith("* ")) {
1451
- const s = r.split(/\n/).filter((l) => l.trim().startsWith("- ") || l.trim().startsWith("* "));
1452
- return /* @__PURE__ */ o("ul", { className: "md-ul", children: s.map((l, a) => /* @__PURE__ */ o("li", { children: ye(l.replace(/^[-*]\s+/, "")) }, a)) }, n);
1453
- }
1454
- if (/^\d+\.\s+/.test(r.trim())) {
1455
- const s = r.split(/\n/).filter((l) => /^\d+\.\s+/.test(l.trim()));
1456
- return /* @__PURE__ */ o("ol", { className: "md-ol", children: s.map((l, a) => /* @__PURE__ */ o("li", { children: ye(l.replace(/^\d+\.\s+/, "")) }, a)) }, n);
1457
- }
1458
- if (r.startsWith("```")) {
1459
- const s = r.replace(/^```[a-zA-Z]*\n?/, "").replace(/```$/, "");
1460
- return /* @__PURE__ */ o(
1461
- "pre",
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);
1548
+ return /* @__PURE__ */ l(
1549
+ "a",
1462
1550
  {
1463
- className: "md-pre",
1464
- children: /* @__PURE__ */ o("code", { children: s })
1551
+ href: i,
1552
+ target: c ? "_blank" : void 0,
1553
+ rel: c ? "noopener noreferrer" : void 0,
1554
+ className: "md-link",
1555
+ children: a
1465
1556
  },
1466
- n
1557
+ s
1467
1558
  );
1468
1559
  }
1469
- return /* @__PURE__ */ o("p", { className: "md-p", children: ye(r) }, n);
1470
- }) });
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;
1471
1642
  }
1472
- const Zr = ({ className: e }) => /* @__PURE__ */ k(
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(
1473
1674
  "div",
1474
1675
  {
1475
- className: re("typing-indicator", e),
1676
+ className: de("typing-indicator-container", e),
1476
1677
  role: "status",
1477
1678
  "aria-label": "Assistant is preparing a reply",
1478
- children: [
1479
- /* @__PURE__ */ o("span", { className: "typing-dot" }),
1480
- /* @__PURE__ */ o("span", { className: "typing-dot" }),
1481
- /* @__PURE__ */ o("span", { className: "typing-dot" })
1482
- ]
1679
+ children: /* @__PURE__ */ l("div", { className: "typing-progress-pill", children: /* @__PURE__ */ l("span", { className: "typing-progress-text", children: t || "Retrieving knowledge & generating answer ..." }) })
1483
1680
  }
1484
- );
1485
- 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) {
1486
1718
  return e === "create_ticket" ? "Support ticket processed" : e === "get_customer" ? "Account verified" : e === "get_ticket" ? "Ticket status loaded" : "Information retrieved";
1487
1719
  }
1488
- function Kr({ sources: e }) {
1489
- const [t, r] = j(!1);
1490
- return e.length ? /* @__PURE__ */ k("div", { className: "sources-panel", children: [
1491
- /* @__PURE__ */ k(
1492
- "button",
1493
- {
1494
- type: "button",
1495
- className: "sources-toggle-btn",
1496
- onClick: () => r((n) => !n),
1497
- "aria-expanded": t,
1498
- children: [
1499
- /* @__PURE__ */ o(Wt, { size: 12, "aria-hidden": "true" }),
1500
- e.length,
1501
- " grounded source",
1502
- e.length > 1 ? "s" : "",
1503
- t ? /* @__PURE__ */ o(Gt, { size: 12 }) : /* @__PURE__ */ o(qt, { size: 12 })
1504
- ]
1505
- }
1506
- ),
1507
- t && /* @__PURE__ */ o("ul", { className: "sources-list", children: e.map((n) => /* @__PURE__ */ k(
1508
- "li",
1509
- {
1510
- className: "source-item",
1511
- children: [
1512
- /* @__PURE__ */ o("span", { className: "source-name", title: n.source, children: n.source.split(/[/\\]/).pop() || n.source }),
1513
- /* @__PURE__ */ k("span", { className: "source-score", children: [
1514
- Math.round(n.score * 100),
1515
- "%"
1516
- ] })
1517
- ]
1518
- },
1519
- n.chunkId
1520
- )) })
1521
- ] }) : null;
1522
- }
1523
- function Xr({ toolCalls: e }) {
1524
- return e.length ? /* @__PURE__ */ o("div", { className: "tool-badges", children: e.map((t, r) => /* @__PURE__ */ o(
1720
+ function Qr({ toolCalls: e }) {
1721
+ return e.length ? /* @__PURE__ */ l("div", { className: "tool-badges", children: e.map((t, n) => /* @__PURE__ */ l(
1525
1722
  "span",
1526
1723
  {
1527
1724
  className: "tool-badge",
1528
- children: Jr(t.toolName)
1725
+ children: Kr(t.toolName)
1529
1726
  },
1530
- `${t.toolName}-${r}`
1727
+ `${t.toolName}-${n}`
1531
1728
  )) }) : null;
1532
1729
  }
1533
- const Qr = ({ message: e }) => {
1534
- const t = e.role === "user", r = e.status === "error";
1535
- return /* @__PURE__ */ k("div", { className: `msg-row${t ? " msg-row--user" : ""}`, children: [
1536
- !t && /* @__PURE__ */ o(
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(
1537
1737
  "div",
1538
1738
  {
1539
1739
  className: "avatar-circle avatar-circle--mt",
1540
1740
  "aria-hidden": "true",
1541
- children: /* @__PURE__ */ o(lt, { size: 15 })
1741
+ children: /* @__PURE__ */ l(it, { size: 15 })
1542
1742
  }
1543
1743
  ),
1544
- /* @__PURE__ */ k("div", { className: `msg-col${t ? " msg-col--user" : ""}`, children: [
1545
- /* @__PURE__ */ k(
1744
+ /* @__PURE__ */ T("div", { className: `msg-col${n ? " msg-col--user" : ""}`, children: [
1745
+ /* @__PURE__ */ T(
1546
1746
  "div",
1547
1747
  {
1548
- className: t ? "msg-bubble msg-bubble--user" : r ? "msg-bubble msg-bubble--error" : "msg-bubble msg-bubble--bot",
1748
+ className: n ? "msg-bubble msg-bubble--user" : r ? "msg-bubble msg-bubble--error" : "msg-bubble msg-bubble--bot",
1549
1749
  children: [
1550
- e.status === "pending" ? /* @__PURE__ */ o(Zr, {}) : t ? /* @__PURE__ */ o("p", { className: "msg-user-pre", children: e.content }) : /* @__PURE__ */ o(Yr, { text: e.content }),
1551
- e.toolCalls ? /* @__PURE__ */ o(Xr, { toolCalls: e.toolCalls }) : null,
1552
- e.sources ? /* @__PURE__ */ o(Kr, { sources: e.sources }) : null
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
1553
1760
  ]
1554
1761
  }
1555
1762
  ),
1556
- t && e.status !== "error" && /* @__PURE__ */ o(zt, { size: 13, className: "msg-tick", "aria-hidden": "true" })
1763
+ n && e.status !== "error" && /* @__PURE__ */ l(Ht, { size: 13, className: "msg-tick", "aria-hidden": "true" })
1557
1764
  ] })
1558
1765
  ] });
1559
1766
  }, en = () => {
1560
- const { messages: e, status: t, showSuggestions: r } = ve();
1561
- return /* @__PURE__ */ o(
1562
- Gr,
1767
+ const { messages: e, status: t, showSuggestions: n } = Ce();
1768
+ return /* @__PURE__ */ l(
1769
+ $r,
1563
1770
  {
1564
1771
  autoScroll: !0,
1565
1772
  defaultScrollPosition: "last-anchor",
1566
1773
  scrollPreviousItemPeek: 64,
1567
- children: /* @__PURE__ */ k(Vr, { children: [
1568
- /* @__PURE__ */ o(Wr, { "aria-label": "Chat messages", children: /* @__PURE__ */ k($r, { "aria-busy": t === "awaiting" || t === "connecting", children: [
1569
- r && /* @__PURE__ */ o(Ye, { messageId: "welcome", children: /* @__PURE__ */ o(jr, {}) }),
1570
- e.map((s) => /* @__PURE__ */ o(
1571
- 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,
1572
1779
  {
1573
1780
  messageId: s.id,
1574
1781
  scrollAnchor: s.role === "user",
1575
- children: /* @__PURE__ */ o(Qr, { message: s })
1782
+ children: /* @__PURE__ */ l(Xr, { message: s })
1576
1783
  },
1577
1784
  s.id
1578
1785
  ))
1579
1786
  ] }) }),
1580
- /* @__PURE__ */ o(Ur, {})
1787
+ /* @__PURE__ */ l(Gr, {})
1581
1788
  ] })
1582
1789
  }
1583
1790
  );
1584
1791
  }, tn = () => {
1585
- const { pendingTicket: e, ticketBusy: t, userContext: r, confirmTicket: n, cancelTicket: s } = ve(), l = !r.customerId && !r.email, [a, i] = j("");
1586
- return e ? /* @__PURE__ */ k(
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(
1587
1794
  "div",
1588
1795
  {
1589
1796
  className: "ticket-card",
1590
1797
  role: "region",
1591
1798
  "aria-label": "Create support ticket",
1592
1799
  children: [
1593
- /* @__PURE__ */ o("h3", { className: "ticket-card-title", children: "Create support ticket?" }),
1594
- /* @__PURE__ */ o("p", { className: "ticket-card-desc", children: "I can open a support request for you. Nothing is created until you confirm." }),
1595
- /* @__PURE__ */ o("p", { className: "ticket-card-body", children: e.description }),
1596
- l && /* @__PURE__ */ k("label", { className: "ticket-id-label", 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: [
1597
1804
  "Customer ID or email",
1598
- /* @__PURE__ */ o(
1805
+ /* @__PURE__ */ l(
1599
1806
  "input",
1600
1807
  {
1601
1808
  value: a,
1602
- onChange: (d) => i(d.target.value),
1809
+ onChange: (c) => i(c.target.value),
1603
1810
  className: "ticket-id-input",
1604
1811
  placeholder: "CUST-1001 or you@company.com",
1605
1812
  autoComplete: "email"
1606
1813
  }
1607
1814
  )
1608
1815
  ] }),
1609
- /* @__PURE__ */ k("div", { className: "ticket-actions", children: [
1610
- /* @__PURE__ */ o(
1816
+ /* @__PURE__ */ T("div", { className: "ticket-actions", children: [
1817
+ /* @__PURE__ */ l(
1611
1818
  "button",
1612
1819
  {
1613
1820
  type: "button",
@@ -1617,12 +1824,12 @@ const Qr = ({ message: e }) => {
1617
1824
  children: "Cancel"
1618
1825
  }
1619
1826
  ),
1620
- /* @__PURE__ */ o(
1827
+ /* @__PURE__ */ l(
1621
1828
  "button",
1622
1829
  {
1623
1830
  type: "button",
1624
- onClick: () => void n(a),
1625
- disabled: t || l && !a.trim(),
1831
+ onClick: () => void r(a),
1832
+ disabled: t || o && !a.trim(),
1626
1833
  className: "ticket-confirm-btn",
1627
1834
  children: t ? "Creating…" : "Create ticket"
1628
1835
  }
@@ -1631,42 +1838,42 @@ const Qr = ({ message: e }) => {
1631
1838
  ]
1632
1839
  }
1633
1840
  ) : null;
1634
- }, mt = ({
1841
+ }, _t = ({
1635
1842
  className: e,
1636
1843
  onClose: t,
1637
- showMinimize: r,
1638
- title: n,
1844
+ showMinimize: n,
1845
+ title: r,
1639
1846
  subtitle: s,
1640
- envStage: l,
1847
+ envStage: o,
1641
1848
  envPulse: a = !0
1642
1849
  }) => {
1643
- const { sendMessage: i, status: d, error: h, resetConversation: g, retryLast: v, pendingTicket: f } = ve(), u = d === "awaiting" || d === "connecting" || !!f;
1644
- return /* @__PURE__ */ k(
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(
1645
1852
  "section",
1646
1853
  {
1647
1854
  className: `chat-panel${e ? ` ${e}` : ""}`,
1648
1855
  "aria-label": "VPS AI Assistant",
1649
1856
  children: [
1650
- /* @__PURE__ */ o(
1651
- er,
1857
+ /* @__PURE__ */ l(
1858
+ Xt,
1652
1859
  {
1653
- title: n,
1860
+ title: r,
1654
1861
  subtitle: s,
1655
1862
  onClose: t,
1656
1863
  onReset: () => void g(),
1657
- showMinimize: r,
1658
- envStage: l,
1864
+ showMinimize: n,
1865
+ envStage: o,
1659
1866
  envPulse: a
1660
1867
  }
1661
1868
  ),
1662
- /* @__PURE__ */ o("div", { className: "chat-panel-body", children: /* @__PURE__ */ o(en, {}) }),
1663
- h && d === "error" && /* @__PURE__ */ o(It, { message: h, onRetry: () => void v() }),
1664
- /* @__PURE__ */ o(tn, {}),
1665
- /* @__PURE__ */ o(
1666
- sr,
1869
+ /* @__PURE__ */ l("div", { className: "chat-panel-body", children: /* @__PURE__ */ l(en, {}) }),
1870
+ f && c === "error" && /* @__PURE__ */ l(Nt, { message: f, onRetry: () => void v() }),
1871
+ /* @__PURE__ */ l(tn, {}),
1872
+ /* @__PURE__ */ l(
1873
+ nr,
1667
1874
  {
1668
- onSend: (m) => void i(m),
1669
- disabled: u
1875
+ onSend: (p) => void i(p),
1876
+ disabled: d
1670
1877
  }
1671
1878
  )
1672
1879
  ]
@@ -1675,28 +1882,28 @@ const Qr = ({ message: e }) => {
1675
1882
  }, rn = ({
1676
1883
  open: e,
1677
1884
  onClose: t,
1678
- envStage: r,
1679
- envPulse: n = !0
1680
- }) => e ? /* @__PURE__ */ o(
1885
+ envStage: n,
1886
+ envPulse: r = !0
1887
+ }) => e ? /* @__PURE__ */ l(
1681
1888
  "div",
1682
1889
  {
1683
1890
  id: "vps-chatbot-widget-panel",
1684
1891
  className: "widget-panel",
1685
- children: /* @__PURE__ */ o(
1686
- mt,
1892
+ children: /* @__PURE__ */ l(
1893
+ _t,
1687
1894
  {
1688
1895
  onClose: t,
1689
1896
  showMinimize: !0,
1690
1897
  title: "VPS AI Assistant",
1691
- envStage: r,
1692
- envPulse: n
1898
+ envStage: n,
1899
+ envPulse: r
1693
1900
  }
1694
1901
  )
1695
1902
  }
1696
1903
  ) : null, nn = ({
1697
1904
  open: e,
1698
1905
  onToggle: t
1699
- }) => /* @__PURE__ */ o(
1906
+ }) => /* @__PURE__ */ l(
1700
1907
  "button",
1701
1908
  {
1702
1909
  type: "button",
@@ -1705,61 +1912,73 @@ const Qr = ({ message: e }) => {
1705
1912
  "aria-controls": "vps-chatbot-widget-panel",
1706
1913
  "aria-label": e ? "Close assistant" : "Open assistant",
1707
1914
  className: "widget-trigger-btn",
1708
- children: e ? /* @__PURE__ */ o(Jt, { size: 22 }) : /* @__PURE__ */ o(ot, { size: 24 })
1915
+ children: e ? /* @__PURE__ */ l(Jt, { size: 22 }) : /* @__PURE__ */ l(ct, { size: 24 })
1709
1916
  }
1710
- ), Ze = ({
1917
+ ), et = ({
1711
1918
  defaultOpen: e = !1,
1712
1919
  open: t,
1713
- onOpenChange: r,
1714
- envStage: n,
1920
+ onOpenChange: n,
1921
+ envStage: r,
1715
1922
  envPulse: s = !0
1716
1923
  }) => {
1717
- const [l, a] = j(e), i = t ?? l, d = (h) => {
1718
- r == null || r(h), t === void 0 && a(h);
1924
+ const [o, a] = K(e), i = t ?? o, c = (f) => {
1925
+ n == null || n(f), t === void 0 && a(f);
1719
1926
  };
1720
- return /* @__PURE__ */ k(oe, { children: [
1721
- /* @__PURE__ */ o(
1927
+ return /* @__PURE__ */ T(ke, { children: [
1928
+ /* @__PURE__ */ l(
1722
1929
  rn,
1723
1930
  {
1724
1931
  open: i,
1725
- onClose: () => d(!1),
1726
- envStage: n,
1932
+ onClose: () => c(!1),
1933
+ envStage: r,
1727
1934
  envPulse: s
1728
1935
  }
1729
1936
  ),
1730
- /* @__PURE__ */ o(nn, { open: i, onToggle: () => d(!i) })
1937
+ /* @__PURE__ */ l(nn, { open: i, onToggle: () => c(!i) })
1731
1938
  ] });
1732
1939
  }, pn = ({
1733
1940
  apiBaseUrl: e,
1734
1941
  apiUrl: t,
1735
- proxyUrl: r,
1736
- userContext: n,
1737
- suggestions: s,
1738
- disableSuggestions: l,
1739
- initialMessage: a,
1740
- ...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
1741
1954
  }) => {
1742
- const d = rt(), h = e ?? t ?? r;
1743
- return !!d && (!h || ee(h) === ee(d == null ? void 0 : d.apiBaseUrl)) && !n && !s && l === void 0 && !a ? /* @__PURE__ */ o(Ze, { ...i }) : /* @__PURE__ */ o(
1744
- 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,
1745
1958
  {
1746
- apiBaseUrl: h,
1747
- userContext: n,
1748
- suggestions: s,
1749
- disableSuggestions: l,
1750
- initialMessage: a,
1751
- children: /* @__PURE__ */ o(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 })
1752
1971
  }
1753
1972
  );
1754
1973
  }, sn = ({
1755
1974
  open: e,
1756
1975
  onClose: t,
1757
- subtitle: r,
1758
- title: n,
1976
+ subtitle: n,
1977
+ title: r,
1759
1978
  envStage: s,
1760
- envPulse: l = !0
1761
- }) => /* @__PURE__ */ k(oe, { children: [
1762
- /* @__PURE__ */ o(
1979
+ envPulse: o = !0
1980
+ }) => /* @__PURE__ */ T(ke, { children: [
1981
+ /* @__PURE__ */ l(
1763
1982
  "div",
1764
1983
  {
1765
1984
  className: `embedded-overlay ${e ? "embedded-overlay--open" : "embedded-overlay--closed"}`,
@@ -1768,38 +1987,38 @@ const Qr = ({ message: e }) => {
1768
1987
  "aria-hidden": "true"
1769
1988
  }
1770
1989
  ),
1771
- /* @__PURE__ */ o(
1990
+ /* @__PURE__ */ l(
1772
1991
  "aside",
1773
1992
  {
1774
1993
  id: "vps-embedded-chat-panel",
1775
1994
  className: `embedded-panel ${e ? "embedded-panel--open" : "embedded-panel--closed"}`,
1776
1995
  "aria-hidden": !e,
1777
- children: e && /* @__PURE__ */ o(
1778
- mt,
1996
+ children: e && /* @__PURE__ */ l(
1997
+ _t,
1779
1998
  {
1780
1999
  onClose: t,
1781
- title: n || "VPS AI Assistant",
1782
- subtitle: r,
2000
+ title: r || "VPS AI Assistant",
2001
+ subtitle: n,
1783
2002
  envStage: s,
1784
- envPulse: l
2003
+ envPulse: o
1785
2004
  }
1786
2005
  )
1787
2006
  }
1788
2007
  )
1789
- ] }), ln = 5, we = 8, bt = "vps-embedded-assistant-top";
1790
- function on(e, t, r) {
1791
- return Math.min(r, Math.max(t, e));
1792
- }
1793
- function Je(e, t) {
1794
- const r = Math.max(
1795
- we,
1796
- window.innerHeight - t - we
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
1797
2016
  );
1798
- return on(e, we, r);
2017
+ return ln(e, Te, n);
1799
2018
  }
1800
2019
  function an() {
1801
2020
  try {
1802
- const e = window.localStorage.getItem(bt);
2021
+ const e = window.localStorage.getItem(wt);
1803
2022
  if (!e) return null;
1804
2023
  const t = Number(e);
1805
2024
  return Number.isFinite(t) ? t : null;
@@ -1809,73 +2028,73 @@ function an() {
1809
2028
  }
1810
2029
  function cn(e) {
1811
2030
  try {
1812
- window.localStorage.setItem(bt, String(e));
2031
+ window.localStorage.setItem(wt, String(e));
1813
2032
  } catch {
1814
2033
  }
1815
2034
  }
1816
2035
  const un = ({
1817
2036
  onOpen: e
1818
2037
  }) => {
1819
- const t = K(null), r = K({
2038
+ const t = se(null), n = se({
1820
2039
  pointerId: null,
1821
2040
  startY: 0,
1822
2041
  startTop: 0,
1823
2042
  moved: !1
1824
- }), [n, s] = j(
2043
+ }), [r, s] = K(
1825
2044
  () => typeof window > "u" ? null : an()
1826
- ), l = K(n), a = K(!1), [i, d] = j(!1);
1827
- me(() => {
1828
- l.current = n;
1829
- }, [n]), me(() => {
1830
- const f = t.current;
1831
- if (!f) return;
1832
- const u = () => {
1833
- s((m) => {
1834
- const T = m ?? Math.round(window.innerHeight / 2 - f.offsetHeight / 2), _ = Je(T, f.offsetHeight);
1835
- return l.current = _, _;
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;
1836
2055
  });
1837
2056
  };
1838
- return u(), window.addEventListener("resize", u), () => window.removeEventListener("resize", u);
2057
+ return d(), window.addEventListener("resize", d), () => window.removeEventListener("resize", d);
1839
2058
  }, []);
1840
- const h = (f) => {
1841
- if (f.button !== 0) return;
1842
- const u = f.currentTarget, m = u.getBoundingClientRect();
1843
- r.current = {
1844
- pointerId: f.pointerId,
1845
- startY: f.clientY,
1846
- startTop: m.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,
1847
2066
  moved: !1
1848
2067
  };
1849
2068
  try {
1850
- u.setPointerCapture(f.pointerId);
2069
+ d.setPointerCapture(h.pointerId);
1851
2070
  } catch {
1852
2071
  }
1853
- }, g = (f) => {
1854
- if (r.current.pointerId !== f.pointerId) return;
1855
- const u = f.clientY - r.current.startY;
1856
- if (!r.current.moved && Math.abs(u) < ln) return;
1857
- r.current.moved = !0, d(!0);
1858
- const m = Je(
1859
- r.current.startTop + u,
1860
- 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
1861
2080
  );
1862
- l.current = m, s(m);
1863
- }, v = (f) => {
1864
- var m, T;
1865
- 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;
1866
2085
  try {
1867
- (T = (m = f.currentTarget).hasPointerCapture) != null && T.call(m, f.pointerId) && f.currentTarget.releasePointerCapture(f.pointerId);
2086
+ (y = (p = h.currentTarget).hasPointerCapture) != null && y.call(p, h.pointerId) && h.currentTarget.releasePointerCapture(h.pointerId);
1868
2087
  } catch {
1869
2088
  }
1870
- const u = r.current.moved;
1871
- r.current.pointerId = null, r.current.moved = !1, d(!1), u && (a.current = !0, l.current != null && cn(l.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));
1872
2091
  };
1873
- return /* @__PURE__ */ k(
2092
+ return /* @__PURE__ */ T(
1874
2093
  "button",
1875
2094
  {
1876
2095
  ref: t,
1877
2096
  type: "button",
1878
- onPointerDown: h,
2097
+ onPointerDown: f,
1879
2098
  onPointerMove: g,
1880
2099
  onPointerUp: v,
1881
2100
  onPointerCancel: v,
@@ -1891,58 +2110,70 @@ const un = ({
1891
2110
  "aria-label": "Assistant",
1892
2111
  className: `embedded-trigger-btn ${i ? "embedded-trigger-btn--grabbing" : "embedded-trigger-btn--grab"}`,
1893
2112
  style: {
1894
- top: n ?? "50%",
1895
- transform: n == null ? "translateY(-50%)" : void 0
2113
+ top: r ?? "50%",
2114
+ transform: r == null ? "translateY(-50%)" : void 0
1896
2115
  },
1897
2116
  children: [
1898
- /* @__PURE__ */ o(ot, { size: 16 }),
2117
+ /* @__PURE__ */ l(ct, { size: 16 }),
1899
2118
  "Assistant"
1900
2119
  ]
1901
2120
  }
1902
2121
  );
1903
- }, Ke = ({
2122
+ }, rt = ({
1904
2123
  defaultOpen: e = !1,
1905
2124
  open: t,
1906
- onOpenChange: r,
1907
- showTrigger: n = !0,
2125
+ onOpenChange: n,
2126
+ showTrigger: r = !0,
1908
2127
  envStage: s,
1909
- envPulse: l = !0
2128
+ envPulse: o = !0
1910
2129
  }) => {
1911
- const [a, i] = j(e), d = t ?? a, h = (g) => {
1912
- r == null || r(g), t === void 0 && i(g);
2130
+ const [a, i] = K(e), c = t ?? a, f = (g) => {
2131
+ n == null || n(g), t === void 0 && i(g);
1913
2132
  };
1914
- return /* @__PURE__ */ k(oe, { children: [
1915
- n && !d && /* @__PURE__ */ o(un, { onOpen: () => h(!0) }),
1916
- /* @__PURE__ */ o(
2133
+ return /* @__PURE__ */ T(ke, { children: [
2134
+ r && !c && /* @__PURE__ */ l(un, { onOpen: () => f(!0) }),
2135
+ /* @__PURE__ */ l(
1917
2136
  sn,
1918
2137
  {
1919
- open: d,
1920
- onClose: () => h(!1),
2138
+ open: c,
2139
+ onClose: () => f(!1),
1921
2140
  envStage: s,
1922
- envPulse: l
2141
+ envPulse: o
1923
2142
  }
1924
2143
  )
1925
2144
  ] });
1926
2145
  }, gn = ({
1927
2146
  apiBaseUrl: e,
1928
2147
  apiUrl: t,
1929
- proxyUrl: r,
1930
- userContext: n,
1931
- suggestions: s,
1932
- disableSuggestions: l,
1933
- initialMessage: a,
1934
- ...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
1935
2160
  }) => {
1936
- const d = rt(), h = e ?? t ?? r;
1937
- return !!d && (!h || ee(h) === ee(d == null ? void 0 : d.apiBaseUrl)) && !n && !s && l === void 0 && !a ? /* @__PURE__ */ o(Ke, { ...i }) : /* @__PURE__ */ o(
1938
- 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,
1939
2164
  {
1940
- apiBaseUrl: h,
1941
- userContext: n,
1942
- suggestions: s,
1943
- disableSuggestions: l,
1944
- initialMessage: a,
1945
- children: /* @__PURE__ */ o(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 })
1946
2177
  }
1947
2178
  );
1948
2179
  }, mn = {
@@ -2110,16 +2341,16 @@ const un = ({
2110
2341
  }
2111
2342
  };
2112
2343
  export {
2113
- mt as ChatPanel,
2114
- nt as ChatProvider,
2344
+ _t as ChatPanel,
2345
+ lt as ChatProvider,
2115
2346
  pn as ChatbotWidget,
2116
2347
  mn as ColorPalette,
2117
2348
  gn as EmbeddedChatbot,
2118
- We as buildApiUrl,
2119
- hn as chatApi,
2120
- tt as createChatApi,
2121
- ee as resolveApiBaseUrl,
2122
- Dt as useChatContext,
2123
- ve as useChatbot,
2124
- rt as useOptionalChatContext
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
2125
2356
  };