teodor-new-chat-ui 4.3.413 → 4.3.414

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -11,48 +11,32 @@ import * as co from "react-dom";
11
11
  import ki from "react-dom";
12
12
  import { ChevronRight as ju, Check as Ts, Circle as Pg, Square as Mg, Send as Og, X as Yn, ExternalLink as Ha, Download as Dg, Image as Lg, FileText as Ul, Loader as Ei, Clock as ha, CheckCircle as $g, Search as _u, ChevronUp as Ri, ChevronDown as Cs, Paperclip as Ua, Bot as ma, Wrench as Fg, User as Bg, ChevronLeft as zg, Copy as Wl, Edit as Vl, RotateCcw as Kl, Loader2 as Kn, Edit3 as Ii, Plus as Hg, FileSpreadsheet as Ug, Calendar as Wg, MoreHorizontal as Vg, Share2 as Kg, Trash2 as qg, MessageSquare as Gg } from "lucide-react";
13
13
  function Yg(e, t) {
14
- var d;
15
- let n = [], r = null, o = {}, s = {}, a = null, i = null, l = null;
14
+ let n = [], r = null, o = null;
16
15
  if (!(e && "type" in e && e.type === "default_message") && e) {
17
- const p = e, m = p.checkpointId ?? null;
18
- o = p.additionalKwargs ?? {}, s = p.responseMetadata ?? {};
19
- const f = m ? t.checkpointMetaById.get(m) ?? null : null;
20
- a = typeof o.step == "number" ? o.step : typeof s.step == "number" ? s.step : (f == null ? void 0 : f.step) ?? null;
21
- const v = typeof o.source == "string" ? o.source : typeof s.source == "string" ? s.source : (f == null ? void 0 : f.source) ?? null;
22
- i = v ? String(v) : null;
23
- const g = a !== null && i ? `${a}:${i}` : null;
24
- if (g && t.checkpointIndexByKey.has(g) ? n = t.checkpointIndexByKey.get(g) ?? [] : m && f && (n = [f]), r = m ?? ((d = n[0]) == null ? void 0 : d.id) ?? null, l = m ? t.attemptMetaById.get(m) ?? null : null, !l && p.role === "user" && p.id && t.userMessageIdToAttempts.has(p.id)) {
25
- const x = t.userMessageIdToAttempts.get(p.id);
26
- if (x && x.length > 0) {
27
- const b = x[0].checkpointId;
28
- l = t.attemptMetaById.get(b) ?? null;
29
- }
30
- }
31
- if (!l && n.length > 0) {
32
- const x = t.attemptMetaById.get(n[0].id);
33
- x && (l = x);
16
+ const i = e.checkpointId ?? null;
17
+ if (i) {
18
+ const l = t.checkpointMetaByCheckpointId.get(i) ?? null;
19
+ l && (n = [l], r = i, o = l);
34
20
  }
35
- if (l && l.attemptCount > 1) {
36
- const x = l.baseUserMessageId;
37
- if (x) {
38
- const b = [];
39
- for (const [w, y] of t.attemptMetaById.entries())
40
- if (y.baseUserMessageId === x) {
41
- const C = t.checkpointMetaById.get(w);
42
- C && b.push(C);
21
+ if (o && (o.attemptCount ?? 1) > 1) {
22
+ const l = o.baseUserMessageId ?? null;
23
+ if (l) {
24
+ const c = [];
25
+ for (const [d, p] of t.checkpointMetaByCheckpointId.entries())
26
+ if (p.baseUserMessageId === l) {
27
+ const m = t.checkpointMetaByCheckpointId.get(d);
28
+ m && c.push(m);
43
29
  }
44
- b.length > 0 && (b.sort((w, y) => {
45
- const C = w.createdAt ? Date.parse(w.createdAt) : 0;
46
- return (y.createdAt ? Date.parse(y.createdAt) : 0) - C;
47
- }), n = b);
30
+ c.length > 0 && (c.sort((d, p) => {
31
+ const m = d.createdAt ? Date.parse(d.createdAt) : 0;
32
+ return (p.createdAt ? Date.parse(p.createdAt) : 0) - m;
33
+ }), n = c);
48
34
  }
49
35
  }
50
36
  }
51
37
  return {
52
38
  checkpointCandidates: n,
53
- defaultCheckpointId: r,
54
- resolvedStep: a,
55
- resolvedSource: i
39
+ defaultCheckpointId: r
56
40
  };
57
41
  }
58
42
  function Xg(e, t) {
@@ -137,70 +121,51 @@ function SI(e) {
137
121
  return t;
138
122
  }
139
123
  function Qg(e) {
140
- const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = [], o = /* @__PURE__ */ new Map();
141
- for (let p = 0; p < e.length; p++) {
142
- const m = e[p], f = m.checkpointId, v = f ?? `cp-${p}`, g = m.metadata ?? {}, x = typeof g.step == "number" ? g.step : null, b = typeof g.source == "string" ? g.source : null, w = {
143
- id: v,
144
- step: x,
145
- source: b,
146
- createdAt: m.createdAt ?? null,
147
- namespace: m.checkpointNs ?? null,
148
- parentId: m.parentId ?? null
149
- };
150
- if (f && (t.set(f, w), x !== null && b)) {
151
- const T = `${x}:${b}`, k = n.get(T);
152
- k ? k.push(w) : n.set(T, [w]);
153
- }
154
- let y = null, C = null;
155
- const S = Array.isArray(m.messages) ? m.messages : [];
156
- for (const T of S)
157
- T.role === "user" && (C || (C = T), T.id && (y = T.id));
158
- if (f && C) {
159
- const T = Pu(C);
160
- T && o.set(f, T);
161
- }
162
- r.push({
163
- id: v,
164
- messageId: y,
165
- step: x,
166
- source: b,
167
- createdAt: m.createdAt ?? null,
168
- next: m.next && m.next.length > 0 ? String(m.next[0]) : null,
169
- parentConfig: m.parentConfig ?? null
170
- });
171
- }
172
- const { attemptMetaById: s, userMessageIdToAttempts: a } = Jg(e), i = /* @__PURE__ */ new Map();
173
- for (const [p, m] of t.entries()) {
174
- const f = s.get(p);
175
- f ? i.set(p, {
176
- ...m,
177
- attemptIndex: f.attemptIndex,
178
- attemptCount: f.attemptCount,
179
- isLatestAttempt: f.isLatestAttempt,
180
- baseUserMessageId: f.baseUserMessageId ?? null
181
- }) : i.set(p, {
182
- ...m,
183
- attemptIndex: 0,
184
- attemptCount: 1,
185
- isLatestAttempt: !0,
186
- baseUserMessageId: null
124
+ const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), { attemptMetaById: o, userMessageIdToAttempts: s } = Jg(e);
125
+ for (let c = 0; c < e.length; c++) {
126
+ const d = e[c], p = d.checkpointId, m = p ?? `cp-${c}`, f = d.metadata ?? {}, v = typeof f.step == "number" ? f.step : null, g = typeof f.source == "string" ? f.source : null;
127
+ let x = null, b = null;
128
+ const w = Array.isArray(d.messages) ? d.messages : [];
129
+ for (const k of w)
130
+ k.role === "user" && (b || (b = k), k.id && (x = k.id));
131
+ const y = d.next && d.next.length > 0 ? String(d.next[0]) : null, C = d.parentConfig ?? null, S = {
132
+ id: m,
133
+ step: v,
134
+ source: g,
135
+ createdAt: d.createdAt ?? null,
136
+ namespace: d.checkpointNs ?? null,
137
+ parentId: d.parentId ?? null,
138
+ messageId: x,
139
+ next: y,
140
+ parentConfig: C
141
+ }, T = p ? o.get(p) : null;
142
+ if (S.attemptIndex = (T == null ? void 0 : T.attemptIndex) ?? 0, S.attemptCount = (T == null ? void 0 : T.attemptCount) ?? 1, S.isLatestAttempt = (T == null ? void 0 : T.isLatestAttempt) ?? !0, S.baseUserMessageId = (T == null ? void 0 : T.baseUserMessageId) ?? null, p && t.set(p, S), p && b) {
143
+ const k = Pu(b);
144
+ k && r.set(p, k);
145
+ }
146
+ n.push({
147
+ id: m,
148
+ messageId: x,
149
+ step: v,
150
+ source: g,
151
+ createdAt: d.createdAt ?? null,
152
+ next: y,
153
+ parentConfig: C
187
154
  });
188
155
  }
189
156
  return {
190
157
  checkpoints: e,
191
- checkpointMetaById: t,
192
- checkpointIndexByKey: n,
193
- attemptMetaById: i,
194
- userMessageIdToAttempts: a,
195
- timeline: r,
196
- messagePreviews: o,
158
+ checkpointMetaByCheckpointId: t,
159
+ userMessageIdToAttempts: s,
160
+ timeline: n,
161
+ messagePreviews: r,
197
162
  getLatest: () => {
198
- const p = r[0];
199
- if (p)
200
- return t.get(p.id);
163
+ const c = n[0];
164
+ if (c)
165
+ return t.get(c.id);
201
166
  },
202
- getCheckpoint: (p) => t.get(p),
203
- getAttempts: (p) => a.get(p) ?? []
167
+ getCheckpoint: (c) => t.get(c),
168
+ getAttempts: (c) => s.get(c) ?? []
204
169
  };
205
170
  }
206
171
  function ex(e) {
@@ -14963,9 +14928,7 @@ const fh = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, ph = O.memo(
14963
14928
  t,
14964
14929
  w ?? {
14965
14930
  checkpoints: [],
14966
- checkpointMetaById: /* @__PURE__ */ new Map(),
14967
- checkpointIndexByKey: /* @__PURE__ */ new Map(),
14968
- attemptMetaById: /* @__PURE__ */ new Map(),
14931
+ checkpointMetaByCheckpointId: /* @__PURE__ */ new Map(),
14969
14932
  userMessageIdToAttempts: /* @__PURE__ */ new Map(),
14970
14933
  timeline: [],
14971
14934
  messagePreviews: /* @__PURE__ */ new Map(),