chordia-ui 3.9.2 → 3.9.3

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.
@@ -1,5 +1,5 @@
1
- import { jsxs as i, jsx as e, Fragment as $ } from "react/jsx-runtime";
2
- import { useState as x, useRef as j, useEffect as U } from "react";
1
+ import { jsxs as i, jsx as e, Fragment as N } from "react/jsx-runtime";
2
+ import { useState as x, useRef as j, useEffect as $ } from "react";
3
3
  import { Send as re, Search as ne, MessageSquare as ie, Pin as oe, Check as ae, X as se, Pencil as le, Trash2 as de, Clock as G, Hash as ee, AtSign as ce, Paperclip as pe } from "lucide-react";
4
4
  import { C as te } from "../ChatMessage.es.js";
5
5
  import { a as ze } from "../ChatMessage.es.js";
@@ -238,7 +238,7 @@ function ge({
238
238
  ] });
239
239
  }
240
240
  const ue = { error: (...m) => console.warn("toast.error:", ...m) };
241
- function Se({
241
+ function ke({
242
242
  initialMessages: m = [],
243
243
  onSendMessage: M,
244
244
  onStreamMessage: C,
@@ -250,38 +250,38 @@ function Se({
250
250
  placeholder: R = "Ask a question about this interaction...",
251
251
  title: P = "Chat with Chordia"
252
252
  }) {
253
- const [h, z] = x(m || []), [f, E] = x(""), [b, d] = x(!1), [l, c] = x(!1), [p, y] = x(null), [A, _] = x("thinking"), [W, r] = x(null), [v, k] = x(0), g = j(null), F = j(null), N = j(null), O = j(null), L = j(null), [t, s] = x(!1), [H, w] = x(0);
254
- U(() => {
253
+ const [h, z] = x(m || []), [f, E] = x(""), [b, d] = x(!1), [l, c] = x(!1), [p, y] = x(null), [A, _] = x("thinking"), [W, r] = x(null), [v, S] = x(0), g = j(null), F = j(null), O = j(null), Y = j(null), L = j(null), [t, s] = x(!1), [H, w] = x(0);
254
+ $(() => {
255
255
  var a;
256
256
  (a = g.current) == null || a.scrollIntoView({ behavior: "smooth" });
257
- }, [h, b]), U(() => {
257
+ }, [h, b]), $(() => {
258
258
  F.current && (F.current.style.height = "auto", F.current.style.height = `${Math.min(
259
259
  F.current.scrollHeight,
260
260
  120
261
261
  )}px`);
262
- }, [f]), U(() => {
262
+ }, [f]), $(() => {
263
263
  if (B) {
264
264
  const a = [...h];
265
265
  p && a.push(p), B(a);
266
266
  }
267
- }, [h, p, B]), U(() => {
267
+ }, [h, p, B]), $(() => {
268
268
  let a;
269
269
  return b && W && (a = setInterval(() => {
270
- if (k(Date.now() - W), L.current) {
271
- const S = (Date.now() - L.current) / 1e3;
272
- S >= 3 ? (s(!0), w(Math.floor(S))) : s(!1);
270
+ if (S(Date.now() - W), L.current) {
271
+ const k = (Date.now() - L.current) / 1e3;
272
+ k >= 3 ? (s(!0), w(Math.floor(k))) : s(!1);
273
273
  }
274
274
  }, 500)), () => a && clearInterval(a);
275
275
  }, [b, W]);
276
276
  const I = () => {
277
- d(!1), c(!1), y(null), O.current = null, _("thinking"), s(!1), w(0), L.current = null, r(null), k(0), N.current && (N.current.abort(), N.current = null);
277
+ d(!1), c(!1), y(null), Y.current = null, _("thinking"), s(!1), w(0), L.current = null, r(null), S(0), O.current && (O.current.abort(), O.current = null);
278
278
  }, q = (a) => {
279
279
  if (a.startsWith("data: ")) {
280
- const S = a.slice(6);
281
- if (S === "[DONE]")
280
+ const k = a.slice(6);
281
+ if (k === "[DONE]")
282
282
  return { type: "done" };
283
283
  try {
284
- return { type: "data", data: JSON.parse(S) };
284
+ return { type: "data", data: JSON.parse(k) };
285
285
  } catch {
286
286
  return null;
287
287
  }
@@ -292,36 +292,36 @@ function Se({
292
292
  if (!((u = (D = a.choices) == null ? void 0 : D[0]) != null && u.delta))
293
293
  return;
294
294
  L.current = Date.now(), s(!1);
295
- const S = a.choices[0].delta;
296
- if (S.tool_calls || S.tool_results) {
295
+ const k = a.choices[0].delta;
296
+ if (k.tool_calls || k.tool_results) {
297
297
  _("tool");
298
298
  return;
299
299
  }
300
- S.content !== void 0 && (_("responding"), y((T) => {
301
- const K = T || {
300
+ k.content !== void 0 && (_("responding"), y((T) => {
301
+ const U = T || {
302
302
  id: Date.now().toString(),
303
303
  role: "assistant",
304
304
  content: "",
305
- timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
305
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString(void 0, {
306
306
  hour: "2-digit",
307
307
  minute: "2-digit"
308
308
  }),
309
309
  isStreaming: !0
310
310
  }, V = {
311
- ...K,
312
- content: (K.content || "") + (S.content || "")
311
+ ...U,
312
+ content: (U.content || "") + (k.content || "")
313
313
  };
314
- return O.current = V, V;
314
+ return Y.current = V, V;
315
315
  }));
316
- }, Y = async (a) => {
317
- const S = a.getReader(), D = new TextDecoder();
316
+ }, K = async (a) => {
317
+ const k = a.getReader(), D = new TextDecoder();
318
318
  let u = "";
319
319
  try {
320
320
  for (; ; ) {
321
- const { done: T, value: K } = await S.read();
321
+ const { done: T, value: U } = await k.read();
322
322
  if (T)
323
323
  break;
324
- u += D.decode(K, { stream: !0 });
324
+ u += D.decode(U, { stream: !0 });
325
325
  const V = u.split(`
326
326
  `);
327
327
  u = V.pop() || "";
@@ -336,21 +336,21 @@ function Se({
336
336
  }
337
337
  }
338
338
  } finally {
339
- S.releaseLock();
339
+ k.releaseLock();
340
340
  }
341
341
  }, n = async () => {
342
342
  if (!f.trim() || l)
343
343
  return;
344
- const a = f.trim(), S = {
344
+ const a = f.trim(), k = {
345
345
  id: Date.now().toString(),
346
346
  role: "user",
347
347
  content: a,
348
- timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
348
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString(void 0, {
349
349
  hour: "2-digit",
350
350
  minute: "2-digit"
351
351
  })
352
- }, D = [...h, S];
353
- z(D), E(""), d(!0), c(!0), _("thinking"), r(Date.now()), L.current = Date.now(), N.current = new AbortController();
352
+ }, D = [...h, k];
353
+ z(D), E(""), d(!0), c(!0), _("thinking"), r(Date.now()), L.current = Date.now(), O.current = new AbortController();
354
354
  try {
355
355
  let u;
356
356
  if (C)
@@ -363,25 +363,25 @@ function Se({
363
363
  id: (Date.now() + 1).toString(),
364
364
  role: "assistant",
365
365
  content: "This is a demonstration response. In a real implementation, this would connect to your LLM backend.",
366
- timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
366
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString(void 0, {
367
367
  hour: "2-digit",
368
368
  minute: "2-digit"
369
369
  })
370
370
  };
371
- z((K) => [...K, T]), I();
371
+ z((U) => [...U, T]), I();
372
372
  }, 1e3);
373
373
  return;
374
374
  }
375
375
  if (u instanceof ReadableStream)
376
- await Y(u);
376
+ await K(u);
377
377
  else if (u instanceof Response && u.body)
378
- await Y(u.body);
378
+ await K(u.body);
379
379
  else if (u && typeof u.then == "function") {
380
380
  const T = await u;
381
- T instanceof ReadableStream ? await Y(T) : T instanceof Response && T.body && await Y(T.body);
381
+ T instanceof ReadableStream ? await K(T) : T instanceof Response && T.body && await K(T.body);
382
382
  }
383
- O.current && z((T) => [...T, {
384
- ...O.current,
383
+ Y.current && z((T) => [...T, {
384
+ ...Y.current,
385
385
  isStreaming: !1
386
386
  }]);
387
387
  } catch (u) {
@@ -466,7 +466,7 @@ function Se({
466
466
  },
467
467
  children: "No messages yet. Start a conversation by asking a question below."
468
468
  }
469
- ) : /* @__PURE__ */ i($, { children: [
469
+ ) : /* @__PURE__ */ i(N, { children: [
470
470
  h.map((a) => /* @__PURE__ */ e(
471
471
  te,
472
472
  {
@@ -577,7 +577,7 @@ function Se({
577
577
  transition: "all 0.15s ease",
578
578
  height: "42px"
579
579
  },
580
- children: l ? /* @__PURE__ */ i($, { children: [
580
+ children: l ? /* @__PURE__ */ i(N, { children: [
581
581
  /* @__PURE__ */ e("style", { children: `
582
582
  @keyframes buttonSpin {
583
583
  from { transform: rotate(0deg); }
@@ -598,7 +598,7 @@ function Se({
598
598
  }
599
599
  ),
600
600
  "Sending..."
601
- ] }) : /* @__PURE__ */ i($, { children: [
601
+ ] }) : /* @__PURE__ */ i(N, { children: [
602
602
  /* @__PURE__ */ e(re, { size: 16 }),
603
603
  "Send"
604
604
  ] })
@@ -625,7 +625,7 @@ function Se({
625
625
  }
626
626
  );
627
627
  }
628
- function ke({
628
+ function Se({
629
629
  threads: m = [],
630
630
  activeThreadId: M,
631
631
  onSelectThread: C,
@@ -635,7 +635,7 @@ function ke({
635
635
  loading: P = !1
636
636
  }) {
637
637
  const [h, z] = x(""), [f, E] = x(null), [b, d] = x(null), [l, c] = x(""), [p, y] = x(null), A = j(null);
638
- U(() => {
638
+ $(() => {
639
639
  b && A.current && (A.current.focus(), A.current.select());
640
640
  }, [b]);
641
641
  const W = [...m.filter((t) => {
@@ -654,10 +654,10 @@ function ke({
654
654
  if (!t)
655
655
  return "";
656
656
  const s = new Date(t), w = (/* @__PURE__ */ new Date()).getTime() - s.getTime(), I = Math.floor(w / 864e5);
657
- return I === 0 ? s.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" }) : I === 1 ? "Yesterday" : I < 7 ? s.toLocaleDateString("en-US", { weekday: "short" }) : s.toLocaleDateString("en-US", { month: "short", day: "numeric" });
657
+ return I === 0 ? s.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" }) : I === 1 ? "Yesterday" : I < 7 ? s.toLocaleDateString(void 0, { weekday: "short" }) : s.toLocaleDateString(void 0, { month: "short", day: "numeric" });
658
658
  }, v = (t, s) => {
659
659
  t.stopPropagation(), y(null), d(s.id), c(s.title || "");
660
- }, k = (t) => {
660
+ }, S = (t) => {
661
661
  t && t.stopPropagation();
662
662
  const s = (l || "").trim();
663
663
  b && s && (o == null || o(b, s)), d(null), c("");
@@ -665,9 +665,9 @@ function ke({
665
665
  t && t.stopPropagation(), d(null), c("");
666
666
  }, F = (t, s) => {
667
667
  t.stopPropagation(), d(null), y(s.id);
668
- }, N = (t) => {
669
- t && t.stopPropagation(), p && (R == null || R(p)), y(null);
670
668
  }, O = (t) => {
669
+ t && t.stopPropagation(), p && (R == null || R(p)), y(null);
670
+ }, Y = (t) => {
671
671
  t && t.stopPropagation(), y(null);
672
672
  }, L = {
673
673
  display: "inline-flex",
@@ -822,7 +822,7 @@ function ke({
822
822
  children: h ? "No threads found" : "No threads yet"
823
823
  }
824
824
  ) : W.map((t) => {
825
- const s = t.id === M, H = f === t.id, w = b === t.id, I = p === t.id, q = typeof o == "function", X = typeof R == "function", Y = (q || X) && H && !w && !I;
825
+ const s = t.id === M, H = f === t.id, w = b === t.id, I = p === t.id, q = typeof o == "function", X = typeof R == "function", K = (q || X) && H && !w && !I;
826
826
  return /* @__PURE__ */ i(
827
827
  "div",
828
828
  {
@@ -865,7 +865,7 @@ function ke({
865
865
  onChange: (n) => c(n.target.value),
866
866
  onClick: (n) => n.stopPropagation(),
867
867
  onKeyDown: (n) => {
868
- n.stopPropagation(), n.key === "Enter" ? k(n) : n.key === "Escape" && g(n);
868
+ n.stopPropagation(), n.key === "Enter" ? S(n) : n.key === "Escape" && g(n);
869
869
  },
870
870
  style: {
871
871
  flex: 1,
@@ -904,7 +904,7 @@ function ke({
904
904
  {
905
905
  type: "button",
906
906
  title: "Save",
907
- onClick: k,
907
+ onClick: S,
908
908
  style: {
909
909
  ...L,
910
910
  color: "var(--rail-discovery, #5E88B0)"
@@ -935,7 +935,7 @@ function ke({
935
935
  }
936
936
  )
937
937
  ] }),
938
- Y && /* @__PURE__ */ i("div", { style: { display: "inline-flex", alignItems: "center", gap: "2px", flexShrink: 0 }, children: [
938
+ K && /* @__PURE__ */ i("div", { style: { display: "inline-flex", alignItems: "center", gap: "2px", flexShrink: 0 }, children: [
939
939
  q && /* @__PURE__ */ e(
940
940
  "button",
941
941
  {
@@ -997,7 +997,7 @@ function ke({
997
997
  "button",
998
998
  {
999
999
  type: "button",
1000
- onClick: N,
1000
+ onClick: O,
1001
1001
  style: {
1002
1002
  padding: "3px 10px",
1003
1003
  fontSize: "11px",
@@ -1022,7 +1022,7 @@ function ke({
1022
1022
  "button",
1023
1023
  {
1024
1024
  type: "button",
1025
- onClick: O,
1025
+ onClick: Y,
1026
1026
  style: {
1027
1027
  padding: "3px 4px",
1028
1028
  fontSize: "11px",
@@ -1044,7 +1044,7 @@ function ke({
1044
1044
  )
1045
1045
  ]
1046
1046
  }
1047
- ) : /* @__PURE__ */ i($, { children: [
1047
+ ) : /* @__PURE__ */ i(N, { children: [
1048
1048
  t.last_message_preview && !w && /* @__PURE__ */ e(
1049
1049
  "div",
1050
1050
  {
@@ -1074,7 +1074,7 @@ function ke({
1074
1074
  children: [
1075
1075
  /* @__PURE__ */ e(G, { size: 9 }),
1076
1076
  /* @__PURE__ */ e("span", { children: r(t.updated_at || t.created_at) }),
1077
- t.message_count != null && /* @__PURE__ */ i($, { children: [
1077
+ t.message_count != null && /* @__PURE__ */ i(N, { children: [
1078
1078
  /* @__PURE__ */ e("span", { children: "·" }),
1079
1079
  /* @__PURE__ */ i("span", { children: [
1080
1080
  t.message_count,
@@ -1108,9 +1108,9 @@ function we({
1108
1108
  initials: ((W = c == null ? void 0 : c.name) == null ? void 0 : W.split(" ").map((r) => r[0]).join("").toUpperCase()) || "YO",
1109
1109
  color: "#6B7C93"
1110
1110
  };
1111
- U(() => {
1111
+ $(() => {
1112
1112
  f(M || []);
1113
- }, [M]), U(() => {
1113
+ }, [M]), $(() => {
1114
1114
  p.current && p.current.scrollIntoView({ behavior: "smooth" });
1115
1115
  }, [z]);
1116
1116
  const A = async () => {
@@ -1131,10 +1131,10 @@ function we({
1131
1131
  type: "comment",
1132
1132
  isOptimistic: !0
1133
1133
  };
1134
- if (f((k) => [...k, v]), C) {
1134
+ if (f((S) => [...S, v]), C) {
1135
1135
  try {
1136
1136
  await C(r), f(
1137
- (k) => k.map(
1137
+ (S) => S.map(
1138
1138
  (g) => g.id === v.id ? { ...g, isOptimistic: !1 } : g
1139
1139
  )
1140
1140
  );
@@ -1147,7 +1147,7 @@ function we({
1147
1147
  }
1148
1148
  setTimeout(() => {
1149
1149
  f(
1150
- (k) => k.map(
1150
+ (S) => S.map(
1151
1151
  (g) => g.id === v.id ? { ...g, isOptimistic: !1 } : g
1152
1152
  )
1153
1153
  ), l(!1);
@@ -1373,7 +1373,7 @@ function we({
1373
1373
  gap: "6px",
1374
1374
  marginTop: "8px"
1375
1375
  },
1376
- children: r.references.map((v, k) => /* @__PURE__ */ i(
1376
+ children: r.references.map((v, S) => /* @__PURE__ */ i(
1377
1377
  "button",
1378
1378
  {
1379
1379
  type: "button",
@@ -1403,7 +1403,7 @@ function we({
1403
1403
  v.label
1404
1404
  ]
1405
1405
  },
1406
- k
1406
+ S
1407
1407
  ))
1408
1408
  }
1409
1409
  )
@@ -1603,7 +1603,7 @@ function we({
1603
1603
  onMouseLeave: (r) => {
1604
1604
  o.trim() && !d && (r.currentTarget.style.background = "rgba(94, 136, 176, 0.85)");
1605
1605
  },
1606
- children: d ? /* @__PURE__ */ i($, { children: [
1606
+ children: d ? /* @__PURE__ */ i(N, { children: [
1607
1607
  /* @__PURE__ */ e("style", { children: `
1608
1608
  @keyframes messageSpin {
1609
1609
  from { transform: rotate(0deg); }
@@ -1624,7 +1624,7 @@ function we({
1624
1624
  }
1625
1625
  ),
1626
1626
  "Sending..."
1627
- ] }) : /* @__PURE__ */ i($, { children: [
1627
+ ] }) : /* @__PURE__ */ i(N, { children: [
1628
1628
  /* @__PURE__ */ e(re, { size: 14 }),
1629
1629
  "Send"
1630
1630
  ] })
@@ -1695,8 +1695,8 @@ function we({
1695
1695
  }
1696
1696
  export {
1697
1697
  ze as ChartRenderer,
1698
- ke as ChatHistoryPanel,
1699
- Se as ChatInterface,
1698
+ Se as ChatHistoryPanel,
1699
+ ke as ChatInterface,
1700
1700
  te as ChatMessage,
1701
1701
  we as MessageThread,
1702
1702
  ge as ThinkingIndicator