@fencyai/react 0.1.143 → 0.1.145

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.js CHANGED
@@ -1,78 +1,78 @@
1
- import { jsxs as v, jsx as i } from "react/jsx-runtime";
2
- import { createStream as G, isStreamTimeoutEvent as J, isStreamNotFoundEvent as V, isAgentTaskProgressItemUpdatedEvent as X, createAgentTask as Y } from "@fencyai/js";
3
- import { createContext as q, useState as C, useRef as A, useEffect as w, useCallback as _, useContext as Q, useMemo as $ } from "react";
4
- import { useInView as Z, motion as T, AnimatePresence as W } from "motion/react";
5
- import ee from "react-markdown";
6
- import { Prism as j } from "react-syntax-highlighter";
7
- import te from "remark-gfm";
8
- import './assets/index.css';const H = q(
1
+ import { jsxs as y, jsx as i, Fragment as E } from "react/jsx-runtime";
2
+ import { createStream as V, isStreamTimeoutEvent as Q, isStreamNotFoundEvent as Z, isAgentTaskProgressItemUpdatedEvent as ee, createAgentTask as te } from "@fencyai/js";
3
+ import { createContext as ne, useState as x, useRef as I, useEffect as w, useCallback as H, useContext as re, useMemo as K } from "react";
4
+ import { useInView as oe, motion as S, AnimatePresence as q } from "motion/react";
5
+ import ie from "react-markdown";
6
+ import { Prism as G } from "react-syntax-highlighter";
7
+ import ae from "remark-gfm";
8
+ import './assets/index.css';const X = ne(
9
9
  void 0
10
10
  );
11
- async function ne(e, t) {
11
+ async function se(e, t) {
12
12
  const n = e.getReader();
13
13
  let r;
14
14
  for (; !(r = await n.read()).done; )
15
15
  t(r.value);
16
16
  }
17
- function re(e) {
18
- let t, n, r, s = !1;
19
- return function(o) {
20
- t === void 0 ? (t = o, n = 0, r = -1) : t = ae(t, o);
21
- const l = t.length;
22
- let m = 0;
23
- for (; n < l; ) {
24
- s && (t[n] === 10 && (m = ++n), s = !1);
25
- let a = -1;
26
- for (; n < l && a === -1; ++n)
17
+ function le(e) {
18
+ let t, n, r, l = !1;
19
+ return function(a) {
20
+ t === void 0 ? (t = a, n = 0, r = -1) : t = de(t, a);
21
+ const c = t.length;
22
+ let s = 0;
23
+ for (; n < c; ) {
24
+ l && (t[n] === 10 && (s = ++n), l = !1);
25
+ let o = -1;
26
+ for (; n < c && o === -1; ++n)
27
27
  switch (t[n]) {
28
28
  case 58:
29
- r === -1 && (r = n - m);
29
+ r === -1 && (r = n - s);
30
30
  break;
31
31
  case 13:
32
- s = !0;
32
+ l = !0;
33
33
  case 10:
34
- a = n;
34
+ o = n;
35
35
  break;
36
36
  }
37
- if (a === -1)
37
+ if (o === -1)
38
38
  break;
39
- e(t.subarray(m, a), r), m = n, r = -1;
39
+ e(t.subarray(s, o), r), s = n, r = -1;
40
40
  }
41
- m === l ? t = void 0 : m !== 0 && (t = t.subarray(m), n -= m);
41
+ s === c ? t = void 0 : s !== 0 && (t = t.subarray(s), n -= s);
42
42
  };
43
43
  }
44
- function oe(e, t, n) {
45
- let r = O();
46
- const s = new TextDecoder();
47
- return function(o, l) {
48
- if (o.length === 0)
49
- n == null || n(r), r = O();
50
- else if (l > 0) {
51
- const m = s.decode(o.subarray(0, l)), a = l + (o[l + 1] === 32 ? 2 : 1), c = s.decode(o.subarray(a));
52
- switch (m) {
44
+ function ce(e, t, n) {
45
+ let r = U();
46
+ const l = new TextDecoder();
47
+ return function(a, c) {
48
+ if (a.length === 0)
49
+ n == null || n(r), r = U();
50
+ else if (c > 0) {
51
+ const s = l.decode(a.subarray(0, c)), o = c + (a[c + 1] === 32 ? 2 : 1), d = l.decode(a.subarray(o));
52
+ switch (s) {
53
53
  case "data":
54
54
  r.data = r.data ? r.data + `
55
- ` + c : c;
55
+ ` + d : d;
56
56
  break;
57
57
  case "event":
58
- r.event = c;
58
+ r.event = d;
59
59
  break;
60
60
  case "id":
61
- e(r.id = c);
61
+ e(r.id = d);
62
62
  break;
63
63
  case "retry":
64
- const y = parseInt(c, 10);
65
- isNaN(y) || t(r.retry = y);
64
+ const g = parseInt(d, 10);
65
+ isNaN(g) || t(r.retry = g);
66
66
  break;
67
67
  }
68
68
  }
69
69
  };
70
70
  }
71
- function ae(e, t) {
71
+ function de(e, t) {
72
72
  const n = new Uint8Array(e.length + t.length);
73
73
  return n.set(e), n.set(t, e.length), n;
74
74
  }
75
- function O() {
75
+ function U() {
76
76
  return {
77
77
  data: "",
78
78
  event: "",
@@ -80,68 +80,68 @@ function O() {
80
80
  retry: void 0
81
81
  };
82
82
  }
83
- var ie = function(e, t) {
83
+ var ue = function(e, t) {
84
84
  var n = {};
85
85
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
86
86
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
87
- for (var s = 0, r = Object.getOwnPropertySymbols(e); s < r.length; s++)
88
- t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[s]) && (n[r[s]] = e[r[s]]);
87
+ for (var l = 0, r = Object.getOwnPropertySymbols(e); l < r.length; l++)
88
+ t.indexOf(r[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[l]) && (n[r[l]] = e[r[l]]);
89
89
  return n;
90
90
  };
91
- const F = "text/event-stream", se = 1e3, L = "last-event-id";
92
- function le(e, t) {
93
- var { signal: n, headers: r, onopen: s, onmessage: d, onclose: o, onerror: l, openWhenHidden: m, fetch: a } = t, c = ie(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
- return new Promise((y, g) => {
95
- const h = Object.assign({}, r);
96
- h.accept || (h.accept = F);
97
- let u;
98
- function p() {
99
- u.abort(), document.hidden || E();
100
- }
101
- m || document.addEventListener("visibilitychange", p);
102
- let f = se, S = 0;
91
+ const z = "text/event-stream", me = 1e3, _ = "last-event-id";
92
+ function ge(e, t) {
93
+ var { signal: n, headers: r, onopen: l, onmessage: u, onclose: a, onerror: c, openWhenHidden: s, fetch: o } = t, d = ue(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
+ return new Promise((g, m) => {
95
+ const p = Object.assign({}, r);
96
+ p.accept || (p.accept = z);
97
+ let h;
103
98
  function k() {
104
- document.removeEventListener("visibilitychange", p), window.clearTimeout(S), u.abort();
99
+ h.abort(), document.hidden || M();
100
+ }
101
+ s || document.addEventListener("visibilitychange", k);
102
+ let f = me, b = 0;
103
+ function T() {
104
+ document.removeEventListener("visibilitychange", k), window.clearTimeout(b), h.abort();
105
105
  }
106
106
  n == null || n.addEventListener("abort", () => {
107
- k(), y();
107
+ T(), g();
108
108
  });
109
- const P = a ?? window.fetch, M = s ?? ce;
110
- async function E() {
109
+ const R = o ?? window.fetch, F = l ?? he;
110
+ async function M() {
111
111
  var D;
112
- u = new AbortController();
112
+ h = new AbortController();
113
113
  try {
114
- const I = await P(e, Object.assign(Object.assign({}, c), { headers: h, signal: u.signal }));
115
- await M(I), await ne(I.body, re(oe((b) => {
116
- b ? h[L] = b : delete h[L];
117
- }, (b) => {
118
- f = b;
119
- }, d))), o == null || o(), k(), y();
120
- } catch (I) {
121
- if (!u.signal.aborted)
114
+ const A = await R(e, Object.assign(Object.assign({}, d), { headers: p, signal: h.signal }));
115
+ await F(A), await se(A.body, le(ce((C) => {
116
+ C ? p[_] = C : delete p[_];
117
+ }, (C) => {
118
+ f = C;
119
+ }, u))), a == null || a(), T(), g();
120
+ } catch (A) {
121
+ if (!h.signal.aborted)
122
122
  try {
123
- const b = (D = l == null ? void 0 : l(I)) !== null && D !== void 0 ? D : f;
124
- window.clearTimeout(S), S = window.setTimeout(E, b);
125
- } catch (b) {
126
- k(), g(b);
123
+ const C = (D = c == null ? void 0 : c(A)) !== null && D !== void 0 ? D : f;
124
+ window.clearTimeout(b), b = window.setTimeout(M, C);
125
+ } catch (C) {
126
+ T(), m(C);
127
127
  }
128
128
  }
129
129
  }
130
- E();
130
+ M();
131
131
  });
132
132
  }
133
- function ce(e) {
133
+ function he(e) {
134
134
  const t = e.headers.get("content-type");
135
- if (!(t != null && t.startsWith(F)))
136
- throw new Error(`Expected content-type to be ${F}, Actual: ${t}`);
135
+ if (!(t != null && t.startsWith(z)))
136
+ throw new Error(`Expected content-type to be ${z}, Actual: ${t}`);
137
137
  }
138
- function de(e) {
138
+ function pe(e) {
139
139
  const t = atob(e), n = new Uint8Array(t.length);
140
140
  for (let r = 0; r < t.length; r++)
141
141
  n[r] = t.charCodeAt(r);
142
142
  return new TextDecoder("utf-8").decode(n);
143
143
  }
144
- class ue {
144
+ class fe {
145
145
  constructor(t) {
146
146
  this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = t;
147
147
  }
@@ -151,36 +151,36 @@ class ue {
151
151
  */
152
152
  updateStreams(t) {
153
153
  t.forEach((r) => {
154
- const s = r.stream.id;
155
- this.eventSources.has(s) || this.connectStream(r);
154
+ const l = r.stream.id;
155
+ this.eventSources.has(l) || this.connectStream(r);
156
156
  });
157
157
  const n = new Set(t.map((r) => r.stream.id));
158
- this.eventSources.forEach((r, s) => {
159
- n.has(s) || (r.abort(), this.eventSources.delete(s));
158
+ this.eventSources.forEach((r, l) => {
159
+ n.has(l) || (r.abort(), this.eventSources.delete(l));
160
160
  });
161
161
  }
162
162
  connectStream(t) {
163
163
  const n = t.stream.id, r = new AbortController();
164
164
  this.eventSources.set(n, r);
165
- const s = `${this.fency.baseUrl}/sse/streams/${n}`, d = {
165
+ const l = `${this.fency.baseUrl}/sse/streams/${n}`, u = {
166
166
  "X-Fency-Publishable-Key": this.fency.publishableKey,
167
167
  "X-Fency-Stream-Token": t.stream.token
168
168
  };
169
- le(s, {
170
- headers: d,
169
+ ge(l, {
170
+ headers: u,
171
171
  signal: r.signal,
172
- async onopen(o) {
173
- if (!o.ok && o.status >= 400 && o.status < 500 && o.status !== 429)
174
- throw new Error(`Client error ${o.status}`);
172
+ async onopen(a) {
173
+ if (!a.ok && a.status >= 400 && a.status < 500 && a.status !== 429)
174
+ throw new Error(`Client error ${a.status}`);
175
175
  },
176
- onmessage: (o) => {
177
- if (o.data) {
178
- const l = de(o.data);
179
- this.broadcast(l, n);
176
+ onmessage: (a) => {
177
+ if (a.data) {
178
+ const c = pe(a.data);
179
+ this.broadcast(c, n);
180
180
  }
181
181
  },
182
- onerror: (o) => {
183
- throw console.error("EventSource error for stream", n, ":", o), this.broadcastError(n), o;
182
+ onerror: (a) => {
183
+ throw console.error("EventSource error for stream", n, ":", a), this.broadcastError(n), a;
184
184
  },
185
185
  onclose() {
186
186
  }
@@ -212,99 +212,99 @@ class ue {
212
212
  this.eventSources.forEach((t) => t.abort()), this.eventSources.clear(), this.subscribers.clear();
213
213
  }
214
214
  }
215
- const me = 12e4, ge = (e) => {
215
+ const ye = 12e4, ke = (e) => {
216
216
  const t = Date.now();
217
- return e.filter((n) => t - n.createdAt < me);
217
+ return e.filter((n) => t - n.createdAt < ye);
218
218
  };
219
- function Ge({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
220
- const [r, s] = C(
219
+ function et({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
220
+ const [r, l] = x(
221
221
  null
222
- ), [d, o] = C(!0), [l, m] = C(null), [a, c] = C([]), y = A(null), g = A(null);
222
+ ), [u, a] = x(!0), [c, s] = x(null), [o, d] = x([]), g = I(null), m = I(null);
223
223
  w(() => {
224
224
  e.then((f) => {
225
- s(f), o(!1);
225
+ l(f), a(!1);
226
226
  }).catch((f) => {
227
- m(f), o(!1);
227
+ s(f), a(!1);
228
228
  });
229
229
  }, [e]), w(() => {
230
- r && !g.current && (g.current = new ue(r));
230
+ r && !m.current && (m.current = new fe(r));
231
231
  }, [r]), w(() => {
232
- g.current && g.current.updateStreams(a);
233
- }, [a]), w(() => () => {
232
+ m.current && m.current.updateStreams(o);
233
+ }, [o]), w(() => () => {
234
234
  var f;
235
- (f = g.current) == null || f.cleanup();
235
+ (f = m.current) == null || f.cleanup();
236
236
  }, []);
237
- const h = _(
237
+ const p = H(
238
238
  async (f = 3e4) => {
239
- if (y.current)
240
- return y.current;
241
- const S = Date.now(), k = a.length > 0 ? a[a.length - 1] : null;
242
- if (k && S - k.createdAt < f)
243
- return k.stream;
244
- const P = (async () => {
239
+ if (g.current)
240
+ return g.current;
241
+ const b = Date.now(), T = o.length > 0 ? o[o.length - 1] : null;
242
+ if (T && b - T.createdAt < f)
243
+ return T.stream;
244
+ const R = (async () => {
245
245
  if (!r)
246
246
  throw new Error("Fency instance not initialized");
247
- const M = await t(), E = await G({
247
+ const F = await t(), M = await V({
248
248
  pk: r.publishableKey,
249
249
  baseUrl: r.baseUrl,
250
- clientToken: (M == null ? void 0 : M.clientToken) ?? ""
250
+ clientToken: (F == null ? void 0 : F.clientToken) ?? ""
251
251
  });
252
- if (E.type === "success") {
252
+ if (M.type === "success") {
253
253
  const D = {
254
- stream: E.stream,
254
+ stream: M.stream,
255
255
  createdAt: Date.now()
256
256
  };
257
- return c((I) => {
258
- const b = [...I, D];
259
- return ge(b);
260
- }), y.current = null, E.stream;
257
+ return d((A) => {
258
+ const C = [...A, D];
259
+ return ke(C);
260
+ }), g.current = null, M.stream;
261
261
  } else
262
- throw y.current = null, new Error("Failed to create stream");
262
+ throw g.current = null, new Error("Failed to create stream");
263
263
  })();
264
- return y.current = P, P;
264
+ return g.current = R, R;
265
265
  },
266
- [r, a]
266
+ [r, o]
267
267
  );
268
- if (l)
269
- return /* @__PURE__ */ v("div", { children: [
268
+ if (c)
269
+ return /* @__PURE__ */ y("div", { children: [
270
270
  "Fency error: ",
271
- l.message
271
+ c.message
272
272
  ] });
273
273
  if (!r)
274
274
  return null;
275
- const u = a.length > 0 ? a[a.length - 1] : null, p = {
275
+ const h = o.length > 0 ? o[o.length - 1] : null, k = {
276
276
  fency: r,
277
- loading: d,
278
- error: l,
279
- activeStreams: a,
280
- latestStream: u,
281
- eventManager: g.current,
282
- getOrCreateStream: h
277
+ loading: u,
278
+ error: c,
279
+ activeStreams: o,
280
+ latestStream: h,
281
+ eventManager: m.current,
282
+ getOrCreateStream: p
283
283
  };
284
- return /* @__PURE__ */ i(H.Provider, { value: p, children: n });
284
+ return /* @__PURE__ */ i(X.Provider, { value: k, children: n });
285
285
  }
286
- function N() {
287
- const e = Q(H);
286
+ function J() {
287
+ const e = re(X);
288
288
  if (e === void 0)
289
289
  throw new Error("useFencyContext must be used within a FencyProvider");
290
290
  return e;
291
291
  }
292
- const ye = (e) => {
292
+ const Se = (e) => {
293
293
  try {
294
294
  const t = JSON.parse(e);
295
- return fe(t);
295
+ return be(t);
296
296
  } catch (t) {
297
297
  return console.error("Error parsing message:", t), null;
298
298
  }
299
- }, fe = (e) => J(e) ? he(e) : V(e) ? pe(e) : X(e) ? Se(e) : null, he = (e) => ({
299
+ }, be = (e) => Q(e) ? Te(e) : Z(e) ? ve(e) : ee(e) ? xe(e) : null, Te = (e) => ({
300
300
  type: "STREAM_TIMEOUT",
301
301
  streamId: e.streamId,
302
302
  timestamp: e.timestamp
303
- }), pe = (e) => ({
303
+ }), ve = (e) => ({
304
304
  type: "STREAM_NOT_FOUND",
305
305
  streamId: e.streamId,
306
306
  timestamp: e.timestamp
307
- }), Se = (e) => ({
307
+ }), xe = (e) => ({
308
308
  type: "AGENT_TASK_PROGRESS_ITEM_UPDATED",
309
309
  streamId: e.streamId,
310
310
  agentTaskId: e.agentTaskId,
@@ -312,31 +312,31 @@ const ye = (e) => {
312
312
  timestamp: e.timestamp,
313
313
  createdAt: e.createdAt,
314
314
  data: JSON.parse(e.data)
315
- }), ke = (e) => {
316
- const t = N(), [n, r] = C(null), s = A(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
315
+ }), Ce = (e) => {
316
+ const t = J(), [n, r] = x(null), l = I(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
317
317
  return w(() => {
318
318
  if (!t.eventManager) return;
319
- const o = {
320
- onMessage: (m, a) => {
321
- var y, g, h;
322
- const c = ye(m);
323
- if (c)
324
- switch (c.type) {
319
+ const a = {
320
+ onMessage: (s, o) => {
321
+ var g, m, p;
322
+ const d = Se(s);
323
+ if (d)
324
+ switch (d.type) {
325
325
  case "STREAM_TIMEOUT":
326
- (y = e == null ? void 0 : e.onStreamTimeout) == null || y.call(e, c);
326
+ (g = e == null ? void 0 : e.onStreamTimeout) == null || g.call(e, d);
327
327
  break;
328
328
  case "STREAM_NOT_FOUND":
329
- (g = e == null ? void 0 : e.onStreamNotFound) == null || g.call(e, c);
329
+ (m = e == null ? void 0 : e.onStreamNotFound) == null || m.call(e, d);
330
330
  break;
331
331
  case "AGENT_TASK_PROGRESS_ITEM_UPDATED":
332
- (h = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || h.call(e, c);
332
+ (p = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || p.call(e, d);
333
333
  break;
334
334
  }
335
335
  },
336
- onError: (m) => {
337
- var a;
338
- (a = e == null ? void 0 : e.onStreamError) == null || a.call(e, {
339
- streamId: m,
336
+ onError: (s) => {
337
+ var o;
338
+ (o = e == null ? void 0 : e.onStreamError) == null || o.call(e, {
339
+ streamId: s,
340
340
  error: {
341
341
  code: "UnknownError",
342
342
  message: "Unknown error in useStream"
@@ -345,258 +345,258 @@ const ye = (e) => {
345
345
  }
346
346
  };
347
347
  return t.eventManager.subscribe(
348
- s.current,
349
- o
348
+ l.current,
349
+ a
350
350
  );
351
351
  }, [t.eventManager, e]), {
352
352
  createStream: async () => {
353
353
  try {
354
- const o = await t.getOrCreateStream(3e4);
355
- return r(o), {
354
+ const a = await t.getOrCreateStream(3e4);
355
+ return r(a), {
356
356
  type: "success",
357
- stream: o
357
+ stream: a
358
358
  };
359
- } catch (o) {
359
+ } catch (a) {
360
360
  return {
361
361
  type: "error",
362
362
  error: {
363
363
  code: "UnknownError",
364
- message: o instanceof Error ? o.message : "Failed to create stream"
364
+ message: a instanceof Error ? a.message : "Failed to create stream"
365
365
  }
366
366
  };
367
367
  }
368
368
  },
369
369
  stream: n
370
370
  };
371
- }, Je = (e) => {
372
- const t = N(), [n, r] = C([]), s = A(/* @__PURE__ */ new Set()), d = A(/* @__PURE__ */ new Map()), { createStream: o } = ke({
373
- onAgentTaskProgressItemUpdated: (a) => {
374
- var g;
375
- if (!s.current.has(a.agentTaskId)) return;
376
- const c = a.data;
377
- if (c.taskType === "StreamingChatCompletion" && c.eventType === "Completed" || c.taskType === "StructuredChatCompletion" && c.eventType === "Completed" || c.taskType === "MemoryChatCompletion" && c.eventType === "Completed") {
371
+ }, tt = (e) => {
372
+ const t = J(), [n, r] = x([]), l = I(/* @__PURE__ */ new Set()), u = I(/* @__PURE__ */ new Map()), { createStream: a } = Ce({
373
+ onAgentTaskProgressItemUpdated: (o) => {
374
+ var m;
375
+ if (!l.current.has(o.agentTaskId)) return;
376
+ const d = o.data;
377
+ if (d.taskType === "StreamingChatCompletion" && d.eventType === "Completed" || d.taskType === "StructuredChatCompletion" && d.eventType === "Completed" || d.taskType === "MemoryChatCompletion" && d.eventType === "Completed") {
378
378
  r(
379
- (u) => u.map(
380
- (p) => {
379
+ (h) => h.map(
380
+ (k) => {
381
381
  var f;
382
- return ((f = p.confirmedData) == null ? void 0 : f.taskId) === a.agentTaskId ? { ...p, loading: !1 } : p;
382
+ return ((f = k.confirmedData) == null ? void 0 : f.taskId) === o.agentTaskId ? { ...k, loading: !1 } : k;
383
383
  }
384
384
  )
385
385
  );
386
- const h = d.current.get(
387
- a.agentTaskId
386
+ const p = u.current.get(
387
+ o.agentTaskId
388
388
  );
389
- h && (d.current.delete(a.agentTaskId), h(c));
389
+ p && (u.current.delete(o.agentTaskId), p(d));
390
390
  return;
391
391
  }
392
- (g = e.onAgentTaskProgressItemUpdated) == null || g.call(e, a), r(
393
- (h) => h.map((u) => {
394
- var S;
395
- if (((S = u.confirmedData) == null ? void 0 : S.taskId) !== a.agentTaskId)
396
- return u;
397
- const f = u.progressItems.some(
398
- (k) => k.progressItemId === a.progressItemId
399
- ) ? u.progressItems.map(
400
- (k) => k.progressItemId === a.progressItemId ? a : k
401
- ) : [...u.progressItems, a];
402
- return { ...u, progressItems: f };
392
+ (m = e.onAgentTaskProgressItemUpdated) == null || m.call(e, o), r(
393
+ (p) => p.map((h) => {
394
+ var b;
395
+ if (((b = h.confirmedData) == null ? void 0 : b.taskId) !== o.agentTaskId)
396
+ return h;
397
+ const f = h.progressItems.some(
398
+ (T) => T.progressItemId === o.progressItemId
399
+ ) ? h.progressItems.map(
400
+ (T) => T.progressItemId === o.progressItemId ? o : T
401
+ ) : [...h.progressItems, o];
402
+ return { ...h, progressItems: f };
403
403
  })
404
404
  );
405
405
  },
406
- onStreamError: (a) => {
407
- var c;
408
- (c = e == null ? void 0 : e.onStreamError) == null || c.call(e, a), r((y) => {
409
- const g = y.find((h) => h.streamId === a.streamId);
410
- return g ? [
411
- ...y.filter((h) => h.streamId !== a.streamId),
406
+ onStreamError: (o) => {
407
+ var d;
408
+ (d = e == null ? void 0 : e.onStreamError) == null || d.call(e, o), r((g) => {
409
+ const m = g.find((p) => p.streamId === o.streamId);
410
+ return m ? [
411
+ ...g.filter((p) => p.streamId !== o.streamId),
412
412
  {
413
- ...g,
413
+ ...m,
414
414
  loading: !1,
415
- error: a.error
415
+ error: o.error
416
416
  }
417
- ] : y;
417
+ ] : g;
418
418
  });
419
419
  },
420
- onStreamNotFound: (a) => {
421
- var c;
422
- (c = e == null ? void 0 : e.onStreamNotFound) == null || c.call(e, a);
420
+ onStreamNotFound: (o) => {
421
+ var d;
422
+ (d = e == null ? void 0 : e.onStreamNotFound) == null || d.call(e, o);
423
423
  },
424
- onStreamTimeout: (a) => {
425
- var c;
426
- (c = e == null ? void 0 : e.onStreamTimeout) == null || c.call(e, a);
424
+ onStreamTimeout: (o) => {
425
+ var d;
426
+ (d = e == null ? void 0 : e.onStreamTimeout) == null || d.call(e, o);
427
427
  }
428
- }), l = _(
429
- async (a, c) => {
430
- const y = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, g = await o();
431
- if (g.type === "success") {
428
+ }), c = H(
429
+ async (o, d) => {
430
+ const g = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, m = await a();
431
+ if (m.type === "success") {
432
432
  r([
433
433
  ...n,
434
434
  {
435
- taskKey: y,
436
- streamId: g.stream.id,
435
+ taskKey: g,
436
+ streamId: m.stream.id,
437
437
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
438
438
  confirmedData: null,
439
439
  error: null,
440
- params: a,
440
+ params: o,
441
441
  progressItems: [],
442
442
  loading: !0,
443
- loadingText: c == null ? void 0 : c.loadingText
443
+ loadingText: d == null ? void 0 : d.loadingText
444
444
  }
445
445
  ]);
446
- const { clientToken: h } = await e.fetchCreateAgentTaskClientToken(a.type), u = await Y({
446
+ const { clientToken: p } = await e.fetchCreateAgentTaskClientToken(o.type), h = await te({
447
447
  pk: t.fency.publishableKey,
448
448
  baseUrl: t.fency.baseUrl,
449
- clientToken: h,
450
- streamToken: g.stream.token,
449
+ clientToken: p,
450
+ streamToken: m.stream.token,
451
451
  request: {
452
- streamingChatCompletionTask: a.type === "StreamingChatCompletion" ? {
453
- messages: a.messages,
454
- model: a.model
452
+ streamingChatCompletionTask: o.type === "StreamingChatCompletion" ? {
453
+ messages: o.messages,
454
+ model: o.model
455
455
  } : void 0,
456
- structuredChatCompletionTask: a.type === "StructuredChatCompletion" ? {
457
- messages: a.messages,
458
- jsonSchema: a.jsonSchema,
459
- model: a.model
456
+ structuredChatCompletionTask: o.type === "StructuredChatCompletion" ? {
457
+ messages: o.messages,
458
+ jsonSchema: o.jsonSchema,
459
+ model: o.model
460
460
  } : void 0,
461
- memoryChatCompletionTask: a.type === "MemoryChatCompletion" ? {
462
- messages: a.messages,
463
- model: a.model,
464
- language: a.language ?? "en",
465
- chunkLimit: a.chunkLimit ?? 10,
466
- memoryScanLimit: a.memoryScanLimit ?? 3
461
+ memoryChatCompletionTask: o.type === "MemoryChatCompletion" ? {
462
+ messages: o.messages,
463
+ model: o.model,
464
+ language: o.language ?? "en",
465
+ chunkLimit: o.chunkLimit ?? 10,
466
+ memoryScanLimit: o.memoryScanLimit ?? 3
467
467
  } : void 0
468
468
  }
469
469
  });
470
- if (u.type === "success" && u.agentTask) {
471
- s.current.add(
472
- u.agentTask.id
470
+ if (h.type === "success" && h.agentTask) {
471
+ l.current.add(
472
+ h.agentTask.id
473
473
  ), r((f) => [
474
- ...f.filter((S) => S.taskKey !== y),
474
+ ...f.filter((b) => b.taskKey !== g),
475
475
  {
476
- taskKey: y,
477
- streamId: g.stream.id,
476
+ taskKey: g,
477
+ streamId: m.stream.id,
478
478
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
479
- taskId: u.agentTask.id,
480
- createdAt: u.agentTask.createdAt,
479
+ taskId: h.agentTask.id,
480
+ createdAt: h.agentTask.createdAt,
481
481
  error: null,
482
- params: a,
482
+ params: o,
483
483
  progressItems: [],
484
484
  loading: !0,
485
- loadingText: c == null ? void 0 : c.loadingText,
485
+ loadingText: d == null ? void 0 : d.loadingText,
486
486
  confirmedData: {
487
- taskId: u.agentTask.id,
488
- createdAt: u.agentTask.createdAt
487
+ taskId: h.agentTask.id,
488
+ createdAt: h.agentTask.createdAt
489
489
  }
490
490
  }
491
491
  ]);
492
- const p = await new Promise((f) => {
493
- d.current.set(
494
- u.agentTask.id,
492
+ const k = await new Promise((f) => {
493
+ u.current.set(
494
+ h.agentTask.id,
495
495
  f
496
496
  );
497
497
  });
498
498
  return {
499
499
  type: "success",
500
- streamId: g.stream.id,
501
- agentTaskId: u.agentTask.id,
502
- response: p
500
+ streamId: m.stream.id,
501
+ agentTaskId: h.agentTask.id,
502
+ response: k
503
503
  };
504
504
  } else {
505
- if (u.type === "error")
506
- return r((p) => [
507
- ...p.filter((f) => f.taskKey !== y),
505
+ if (h.type === "error")
506
+ return r((k) => [
507
+ ...k.filter((f) => f.taskKey !== g),
508
508
  {
509
- taskKey: y,
509
+ taskKey: g,
510
510
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
511
- streamId: g.stream.id,
512
- params: a,
513
- error: u.error,
511
+ streamId: m.stream.id,
512
+ params: o,
513
+ error: h.error,
514
514
  progressItems: [],
515
515
  loading: !1,
516
- loadingText: c == null ? void 0 : c.loadingText,
516
+ loadingText: d == null ? void 0 : d.loadingText,
517
517
  confirmedData: null
518
518
  }
519
519
  ]), {
520
520
  type: "error",
521
- error: u.error
521
+ error: h.error
522
522
  };
523
523
  {
524
- const p = {
524
+ const k = {
525
525
  message: "No response received",
526
526
  code: "UnknownError"
527
527
  };
528
528
  return r((f) => [
529
- ...f.filter((S) => S.taskKey !== y),
529
+ ...f.filter((b) => b.taskKey !== g),
530
530
  {
531
- taskKey: y,
531
+ taskKey: g,
532
532
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
533
- streamId: g.stream.id,
534
- error: p,
535
- params: a,
533
+ streamId: m.stream.id,
534
+ error: k,
535
+ params: o,
536
536
  progressItems: [],
537
537
  loading: !1,
538
- loadingText: c == null ? void 0 : c.loadingText,
538
+ loadingText: d == null ? void 0 : d.loadingText,
539
539
  confirmedData: null
540
540
  }
541
541
  ]), {
542
542
  type: "error",
543
- error: p
543
+ error: k
544
544
  };
545
545
  }
546
546
  }
547
547
  } else
548
- return console.error(g.error), g;
548
+ return console.error(m.error), m;
549
549
  },
550
- [t, n, o]
551
- ), m = $(() => {
550
+ [t, n, a]
551
+ ), s = K(() => {
552
552
  if (n.length !== 0)
553
- return [...n].sort((a, c) => new Date(c.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
553
+ return [...n].sort((o, d) => new Date(d.triggeredAt).getTime() - new Date(o.triggeredAt).getTime())[0];
554
554
  }, [n]);
555
555
  return w(() => () => {
556
- s.current.clear(), d.current.clear();
556
+ l.current.clear(), u.current.clear();
557
557
  }, []), {
558
558
  agentTasks: n,
559
- createAgentTask: l,
560
- latest: m
559
+ createAgentTask: c,
560
+ latest: s
561
561
  };
562
562
  };
563
- function Te(e) {
563
+ function Ee(e) {
564
564
  return e.progressItems.map((t, n) => {
565
- const r = e.progressItems[n + 1], s = r != null;
566
- let d;
565
+ const r = e.progressItems[n + 1], l = r != null;
566
+ let u;
567
567
  if (r != null && r.createdAt) {
568
- const o = new Date(t.createdAt).getTime(), l = new Date(r.createdAt).getTime();
569
- d = Math.round((l - o) / 1e3);
568
+ const a = new Date(t.createdAt).getTime(), c = new Date(r.createdAt).getTime();
569
+ u = Math.round((c - a) / 1e3);
570
570
  }
571
571
  return {
572
572
  item: t,
573
- completed: s,
573
+ completed: l,
574
574
  isLatest: n === e.progressItems.length - 1,
575
- durationSeconds: d
575
+ durationSeconds: u
576
576
  };
577
577
  });
578
578
  }
579
- function R({
579
+ function P({
580
580
  text: e,
581
581
  duration: t = 2,
582
582
  delay: n = 0,
583
583
  repeat: r = !0,
584
- repeatDelay: s = 0.5,
585
- className: d,
586
- startOnView: o = !1,
587
- once: l = !1,
588
- inViewMargin: m,
589
- spread: a = 2,
590
- color: c = "#999",
591
- shimmerColor: y = "#000",
592
- direction: g = "fromBottom"
584
+ repeatDelay: l = 0.5,
585
+ className: u,
586
+ startOnView: a = !1,
587
+ once: c = !1,
588
+ inViewMargin: s,
589
+ spread: o = 2,
590
+ color: d = "#999",
591
+ shimmerColor: g = "#000",
592
+ direction: m = "fromBottom"
593
593
  }) {
594
- const h = A(null), u = Z(h, { once: l, margin: m }), p = $(() => e.length * a, [e, a]), f = !o || u, S = g === "fromBottom" ? "100% center" : "-100% center", k = g === "fromBottom" ? "0% center" : "200% center";
594
+ const p = I(null), h = oe(p, { once: c, margin: s }), k = K(() => e.length * o, [e, o]), f = !a || h, b = m === "fromBottom" ? "100% center" : "-100% center", T = m === "fromBottom" ? "0% center" : "200% center";
595
595
  return /* @__PURE__ */ i(
596
- T.span,
596
+ S.span,
597
597
  {
598
- ref: h,
599
- className: d,
598
+ ref: p,
599
+ className: u,
600
600
  style: {
601
601
  position: "relative",
602
602
  display: "inline-block",
@@ -606,18 +606,18 @@ function R({
606
606
  color: "transparent",
607
607
  WebkitTextFillColor: "transparent",
608
608
  backgroundRepeat: "no-repeat, padding-box",
609
- "--spread": `${p}px`,
610
- "--base-color": c,
611
- "--shimmer-color": y,
609
+ "--spread": `${k}px`,
610
+ "--base-color": d,
611
+ "--shimmer-color": g,
612
612
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
613
613
  backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
614
614
  },
615
615
  initial: {
616
- backgroundPosition: S,
616
+ backgroundPosition: b,
617
617
  opacity: 0
618
618
  },
619
619
  animate: f ? {
620
- backgroundPosition: k,
620
+ backgroundPosition: T,
621
621
  opacity: 1
622
622
  } : {},
623
623
  transition: {
@@ -625,7 +625,7 @@ function R({
625
625
  repeat: r ? 1 / 0 : 0,
626
626
  duration: t,
627
627
  delay: n,
628
- repeatDelay: s,
628
+ repeatDelay: l,
629
629
  ease: "linear"
630
630
  },
631
631
  opacity: {
@@ -637,7 +637,7 @@ function R({
637
637
  }
638
638
  );
639
639
  }
640
- function ve(e, t) {
640
+ function Me(e, t) {
641
641
  const n = e.item.data;
642
642
  if (n.eventType === "Error" && "message" in n)
643
643
  return t.error;
@@ -655,16 +655,16 @@ function ve(e, t) {
655
655
  return t.streaming;
656
656
  case "Search":
657
657
  return t.searching;
658
+ case "FindMemories":
659
+ return e.completed ? t.memoriesFound : t.findingMemories;
660
+ case "FindMemoriesResult":
661
+ return t.memoriesFound;
658
662
  case "FindSources":
659
663
  return t.addingSources;
660
664
  case "SourcesResult":
661
665
  return t.sourcesAdded;
662
- case "ExploreMemoryStart":
663
- return t.exploringMemory;
664
- case "ExploreMemoryResult":
665
- return t.memoryExplored;
666
- case "ExploreMemoryError":
667
- return t.memoryExplorationFailed;
666
+ case "ExploreMemories":
667
+ return e.completed ? t.memoriesExplored : t.exploringMemories;
668
668
  case "ChunkResult":
669
669
  return t.chunksRetrieved;
670
670
  case "Completed":
@@ -672,12 +672,12 @@ function ve(e, t) {
672
672
  }
673
673
  return t.processing;
674
674
  }
675
- const be = ({ progressViewItems: e, t }) => {
675
+ const we = ({ progressViewItems: e, t }) => {
676
676
  const n = e[e.length - 1];
677
677
  if (!n) return null;
678
- const r = ve(n, t);
679
- return /* @__PURE__ */ i("div", { className: "simple-mode-container", children: /* @__PURE__ */ i(W, { mode: "wait", children: /* @__PURE__ */ i(
680
- T.div,
678
+ const r = Me(n, t);
679
+ return /* @__PURE__ */ i("div", { className: "simple-mode-container", children: /* @__PURE__ */ i(q, { mode: "wait", children: /* @__PURE__ */ i(
680
+ S.div,
681
681
  {
682
682
  initial: { opacity: 0, y: 10 },
683
683
  animate: { opacity: 1, y: 0 },
@@ -691,7 +691,7 @@ const be = ({ progressViewItems: e, t }) => {
691
691
  children: r
692
692
  }
693
693
  ) : /* @__PURE__ */ i(
694
- R,
694
+ P,
695
695
  {
696
696
  text: r,
697
697
  className: "simple-mode-title",
@@ -704,7 +704,7 @@ const be = ({ progressViewItems: e, t }) => {
704
704
  },
705
705
  n.item.progressItemId
706
706
  ) }) });
707
- }, K = {
707
+ }, Y = {
708
708
  'code[class*="language-"]': {
709
709
  color: "#f8f8f2",
710
710
  background: "none",
@@ -855,53 +855,53 @@ const be = ({ progressViewItems: e, t }) => {
855
855
  italic: {
856
856
  fontStyle: "italic"
857
857
  }
858
- }, B = ({
858
+ }, N = ({
859
859
  text: e
860
860
  }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
861
- T.div,
861
+ S.div,
862
862
  {
863
863
  className: "fency-markdown-body-raw",
864
864
  initial: { opacity: 0, y: -10 },
865
865
  animate: { opacity: 1, y: 0 },
866
866
  transition: { duration: 0.3, delay: 0 },
867
867
  children: /* @__PURE__ */ i(
868
- ee,
868
+ ie,
869
869
  {
870
- remarkPlugins: [te],
870
+ remarkPlugins: [ae],
871
871
  components: {
872
872
  code(t) {
873
- const { children: n, className: r, node: s, ref: d, ...o } = t, l = /language-(\w+)/.exec(r || "");
874
- return l ? (
873
+ const { children: n, className: r, node: l, ref: u, ...a } = t, c = /language-(\w+)/.exec(r || "");
874
+ return c ? (
875
875
  // @ts-expect-error react-syntax-highlighter types incompatible with @types/react 18
876
876
  /* @__PURE__ */ i(
877
- j,
877
+ G,
878
878
  {
879
- ...o,
879
+ ...a,
880
880
  PreTag: "div",
881
881
  children: String(n).replace(/\n$/, ""),
882
- language: l[1],
883
- style: K
882
+ language: c[1],
883
+ style: Y
884
884
  }
885
885
  )
886
- ) : /* @__PURE__ */ i("code", { ...o, className: r, children: String(n) });
886
+ ) : /* @__PURE__ */ i("code", { ...a, className: r, children: String(n) });
887
887
  }
888
888
  },
889
889
  children: e
890
890
  }
891
891
  )
892
892
  }
893
- ) }), xe = ({ data: e }) => {
893
+ ) }), Ie = ({ data: e }) => {
894
894
  const t = JSON.stringify(e.json, null, 2);
895
895
  return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
896
- T.div,
896
+ S.div,
897
897
  {
898
898
  initial: { opacity: 0, y: -10 },
899
899
  animate: { opacity: 1, y: 0 },
900
900
  transition: { duration: 0.3, delay: 0 },
901
- children: /* @__PURE__ */ i(j, { language: "json", style: K, PreTag: "div", children: t })
901
+ children: /* @__PURE__ */ i(G, { language: "json", style: Y, PreTag: "div", children: t })
902
902
  }
903
903
  ) });
904
- }, Ce = {
904
+ }, Ae = {
905
905
  en: {
906
906
  error: "Error",
907
907
  streaming: "Streaming...",
@@ -912,6 +912,16 @@ const be = ({ progressViewItems: e, t }) => {
912
912
  sourcesAdded: "Sources added...",
913
913
  exploringMemory: "Exploring memory...",
914
914
  memoryExplored: "Memory explored",
915
+ exploringMemories: "Exploring memories...",
916
+ memoriesExplored: "Memories explored",
917
+ findingMemories: "Finding relevant memories...",
918
+ findingMemoriesIn: "Finding relevant memories in ",
919
+ moreMemories: "+{n} more",
920
+ memoryFound: "Found memory ",
921
+ memoriesFoundPrefix: "Found memories ",
922
+ memoriesFound: "Memories found",
923
+ searchingFor: "Searching for ",
924
+ searchingIn: " in ",
915
925
  memoryExplorationFailed: "Memory exploration failed",
916
926
  processing: "Processing...",
917
927
  processingYourTask: "Processing your task...",
@@ -927,7 +937,8 @@ const be = ({ progressViewItems: e, t }) => {
927
937
  chunkFound: "1 chunk found",
928
938
  chunksFound: "{n} chunks found",
929
939
  chunksRetrieved: "Chunks retrieved",
930
- scoreLabel: "score: {n}"
940
+ scoreLabel: "score: {n}",
941
+ and: "and"
931
942
  },
932
943
  no: {
933
944
  error: "Feil",
@@ -939,6 +950,16 @@ const be = ({ progressViewItems: e, t }) => {
939
950
  sourcesAdded: "Kilder lagt til...",
940
951
  exploringMemory: "Utforsker minne...",
941
952
  memoryExplored: "Minne utforsket",
953
+ exploringMemories: "Utforsker minner...",
954
+ memoriesExplored: "Minner utforsket",
955
+ findingMemories: "Finner relevante minner...",
956
+ findingMemoriesIn: "Finner relevante minner i ",
957
+ moreMemories: "+{n} flere",
958
+ memoryFound: "Fant minne ",
959
+ memoriesFoundPrefix: "Fant minner ",
960
+ memoriesFound: "Minner funnet",
961
+ searchingFor: "Søker etter ",
962
+ searchingIn: " i ",
942
963
  memoryExplorationFailed: "Minneutforskning feilet",
943
964
  processing: "Behandler...",
944
965
  processingYourTask: "Behandler oppgaven din...",
@@ -954,43 +975,194 @@ const be = ({ progressViewItems: e, t }) => {
954
975
  chunkFound: "1 del funnet",
955
976
  chunksFound: "{n} deler funnet",
956
977
  chunksRetrieved: "Deler hentet",
957
- scoreLabel: "poeng: {n}"
978
+ scoreLabel: "poeng: {n}",
979
+ and: "og"
958
980
  }
959
981
  };
960
- function Ee(e) {
961
- return Ce[e];
982
+ function Fe(e) {
983
+ return Ae[e];
962
984
  }
963
- function x(e, t) {
985
+ function v(e, t) {
964
986
  return Object.entries(t).reduce(
965
- (n, [r, s]) => n.replace(`{${r}}`, String(s)),
987
+ (n, [r, l]) => n.replace(`{${r}}`, String(l)),
966
988
  e
967
989
  );
968
990
  }
969
- const we = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
970
- const s = `${r.searchingPrefix}${e.queryDescription}`;
971
- return /* @__PURE__ */ v("div", { style: { padding: "16px" }, children: [
991
+ function B(e, t) {
992
+ const n = e.map((r) => `'${r}'`);
993
+ if (t != null && n.length >= 2) {
994
+ const r = n.pop();
995
+ return n.length > 0 ? `${n.join(", ")} ${t} ${r}` : r;
996
+ }
997
+ return n.join(", ");
998
+ }
999
+ const L = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1000
+ const [l, u] = x(!1), c = (e.memories ?? []).map((f) => f.memoryTitle), s = c.length > 0, o = s && c.length > L, d = o && !l ? c.slice(0, L) : c, g = c.length - L, m = !o || l, p = `${r.searchingFor}'${e.queryDescription}'`, h = s ? `${r.searchingIn}${B(
1001
+ d,
1002
+ m ? r.and : void 0
1003
+ )}` : "", k = s ? `${p}${h}` : `${r.searchingPrefix}${e.queryDescription}`;
1004
+ return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1005
+ /* @__PURE__ */ i(
1006
+ S.div,
1007
+ {
1008
+ style: { color: "#666" },
1009
+ initial: { opacity: 0, y: -10 },
1010
+ animate: { opacity: 1, y: 0 },
1011
+ transition: { duration: 0.3, delay: 0 },
1012
+ children: t && !n && !o ? /* @__PURE__ */ i(
1013
+ P,
1014
+ {
1015
+ text: k,
1016
+ duration: 2.5,
1017
+ repeat: !0,
1018
+ color: "#999",
1019
+ shimmerColor: "#000"
1020
+ }
1021
+ ) : /* @__PURE__ */ y(E, { children: [
1022
+ /* @__PURE__ */ i("span", { style: { color: "#666" }, children: s ? /* @__PURE__ */ y(E, { children: [
1023
+ r.searchingFor,
1024
+ /* @__PURE__ */ y("span", { style: { fontWeight: 600 }, children: [
1025
+ "'",
1026
+ e.queryDescription,
1027
+ "'"
1028
+ ] }),
1029
+ h
1030
+ ] }) : `${r.searchingPrefix}${e.queryDescription}` }),
1031
+ o && !l && /* @__PURE__ */ y(E, { children: [
1032
+ " ",
1033
+ /* @__PURE__ */ i(
1034
+ "button",
1035
+ {
1036
+ type: "button",
1037
+ onClick: () => u(!0),
1038
+ style: {
1039
+ background: "none",
1040
+ border: "none",
1041
+ padding: 0,
1042
+ margin: 0,
1043
+ fontSize: "inherit",
1044
+ color: "inherit",
1045
+ cursor: "pointer",
1046
+ textDecoration: "underline",
1047
+ fontFamily: "inherit"
1048
+ },
1049
+ children: v(r.moreMemories, {
1050
+ n: g
1051
+ })
1052
+ }
1053
+ )
1054
+ ] }),
1055
+ o && l && /* @__PURE__ */ y(E, { children: [
1056
+ " ",
1057
+ /* @__PURE__ */ i(
1058
+ "button",
1059
+ {
1060
+ type: "button",
1061
+ onClick: () => u(!1),
1062
+ style: {
1063
+ background: "none",
1064
+ border: "none",
1065
+ padding: 0,
1066
+ margin: 0,
1067
+ fontSize: "inherit",
1068
+ color: "inherit",
1069
+ cursor: "pointer",
1070
+ textDecoration: "underline",
1071
+ fontFamily: "inherit"
1072
+ },
1073
+ children: r.clickToCollapse
1074
+ }
1075
+ )
1076
+ ] })
1077
+ ] })
1078
+ }
1079
+ ),
1080
+ n !== void 0 && /* @__PURE__ */ i(
1081
+ "div",
1082
+ {
1083
+ style: {
1084
+ fontSize: "12px",
1085
+ color: "#999",
1086
+ marginTop: "4px",
1087
+ fontStyle: "italic"
1088
+ },
1089
+ children: v(r.tookSeconds, { n })
1090
+ }
1091
+ )
1092
+ ] });
1093
+ }, O = 5, Pe = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1094
+ const [l, u] = x(!1), a = e.titles, c = a.length > 0, s = c && a.length > O, o = s && !l ? a.slice(0, O) : a, d = a.length - O, g = !s || l, m = c ? `${r.findingMemoriesIn}${B(
1095
+ o,
1096
+ g ? r.and : void 0
1097
+ )}` : r.findingMemories;
1098
+ return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
972
1099
  /* @__PURE__ */ i(
973
- T.div,
1100
+ S.div,
974
1101
  {
975
1102
  style: {
976
- display: "flex",
977
- alignItems: "center",
978
- gap: "10px",
979
1103
  color: "#666"
980
1104
  },
981
1105
  initial: { opacity: 0, y: -10 },
982
1106
  animate: { opacity: 1, y: 0 },
983
1107
  transition: { duration: 0.3, delay: 0 },
984
- children: t && !n ? /* @__PURE__ */ i(
985
- R,
1108
+ children: t && !n && !s ? /* @__PURE__ */ i(
1109
+ P,
986
1110
  {
987
- text: s,
1111
+ text: m,
988
1112
  duration: 2.5,
989
1113
  repeat: !0,
990
1114
  color: "#999",
991
1115
  shimmerColor: "#000"
992
1116
  }
993
- ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: s })
1117
+ ) : /* @__PURE__ */ y(E, { children: [
1118
+ /* @__PURE__ */ i("span", { style: { color: "#666" }, children: m }),
1119
+ s && !l && /* @__PURE__ */ y(E, { children: [
1120
+ " ",
1121
+ /* @__PURE__ */ i(
1122
+ "button",
1123
+ {
1124
+ type: "button",
1125
+ onClick: () => u(!0),
1126
+ style: {
1127
+ background: "none",
1128
+ border: "none",
1129
+ padding: 0,
1130
+ margin: 0,
1131
+ fontSize: "inherit",
1132
+ color: "inherit",
1133
+ cursor: "pointer",
1134
+ textDecoration: "underline",
1135
+ fontFamily: "inherit"
1136
+ },
1137
+ children: v(r.moreMemories, {
1138
+ n: d
1139
+ })
1140
+ }
1141
+ )
1142
+ ] }),
1143
+ s && l && /* @__PURE__ */ y(E, { children: [
1144
+ " ",
1145
+ /* @__PURE__ */ i(
1146
+ "button",
1147
+ {
1148
+ type: "button",
1149
+ onClick: () => u(!1),
1150
+ style: {
1151
+ background: "none",
1152
+ border: "none",
1153
+ padding: 0,
1154
+ margin: 0,
1155
+ fontSize: "inherit",
1156
+ color: "inherit",
1157
+ cursor: "pointer",
1158
+ textDecoration: "underline",
1159
+ fontFamily: "inherit"
1160
+ },
1161
+ children: r.clickToCollapse
1162
+ }
1163
+ )
1164
+ ] })
1165
+ ] })
994
1166
  }
995
1167
  ),
996
1168
  n !== void 0 && /* @__PURE__ */ i(
@@ -1002,15 +1174,78 @@ const we = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1002
1174
  marginTop: "4px",
1003
1175
  fontStyle: "italic"
1004
1176
  },
1005
- children: x(r.tookSeconds, { n })
1177
+ children: v(r.tookSeconds, { n })
1006
1178
  }
1007
1179
  )
1008
1180
  ] });
1009
- }, Ae = ({ isLatest: e = !1, durationSeconds: t, t: n }) => {
1181
+ }, $ = 5, Re = ({ data: e, t }) => {
1182
+ const [n, r] = x(!1), u = e.memories.map((p) => p.memoryTitle), a = u.length > 0, c = a && u.length > $, s = c && !n ? u.slice(0, $) : u, o = u.length - $, d = !c || n, g = u.length === 1 ? t.memoryFound : t.memoriesFoundPrefix, m = a ? `${g}${B(
1183
+ s,
1184
+ d ? t.and : void 0
1185
+ )}` : t.memoriesFound;
1186
+ return /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
1187
+ S.div,
1188
+ {
1189
+ style: { color: "#666" },
1190
+ initial: { opacity: 0, y: -10 },
1191
+ animate: { opacity: 1, y: 0 },
1192
+ transition: { duration: 0.3, delay: 0 },
1193
+ children: /* @__PURE__ */ y(E, { children: [
1194
+ /* @__PURE__ */ i("span", { style: { color: "#666" }, children: m }),
1195
+ c && !n && /* @__PURE__ */ y(E, { children: [
1196
+ " ",
1197
+ /* @__PURE__ */ i(
1198
+ "button",
1199
+ {
1200
+ type: "button",
1201
+ onClick: () => r(!0),
1202
+ style: {
1203
+ background: "none",
1204
+ border: "none",
1205
+ padding: 0,
1206
+ margin: 0,
1207
+ fontSize: "inherit",
1208
+ color: "inherit",
1209
+ cursor: "pointer",
1210
+ textDecoration: "underline",
1211
+ fontFamily: "inherit"
1212
+ },
1213
+ children: v(t.moreMemories, {
1214
+ n: o
1215
+ })
1216
+ }
1217
+ )
1218
+ ] }),
1219
+ c && n && /* @__PURE__ */ y(E, { children: [
1220
+ " ",
1221
+ /* @__PURE__ */ i(
1222
+ "button",
1223
+ {
1224
+ type: "button",
1225
+ onClick: () => r(!1),
1226
+ style: {
1227
+ background: "none",
1228
+ border: "none",
1229
+ padding: 0,
1230
+ margin: 0,
1231
+ fontSize: "inherit",
1232
+ color: "inherit",
1233
+ cursor: "pointer",
1234
+ textDecoration: "underline",
1235
+ fontFamily: "inherit"
1236
+ },
1237
+ children: t.clickToCollapse
1238
+ }
1239
+ )
1240
+ ] })
1241
+ ] })
1242
+ }
1243
+ ) });
1244
+ }, Le = ({ isLatest: e = !1, durationSeconds: t, t: n }) => {
1010
1245
  const r = n.addingSources;
1011
- return /* @__PURE__ */ v("div", { style: { padding: "16px" }, children: [
1246
+ return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1012
1247
  /* @__PURE__ */ i(
1013
- T.div,
1248
+ S.div,
1014
1249
  {
1015
1250
  style: {
1016
1251
  display: "flex",
@@ -1022,7 +1257,7 @@ const we = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1022
1257
  animate: { opacity: 1, y: 0 },
1023
1258
  transition: { duration: 0.3, delay: 0 },
1024
1259
  children: e && !t ? /* @__PURE__ */ i(
1025
- R,
1260
+ P,
1026
1261
  {
1027
1262
  text: r,
1028
1263
  duration: 2.5,
@@ -1042,26 +1277,26 @@ const we = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1042
1277
  marginTop: "4px",
1043
1278
  fontStyle: "italic"
1044
1279
  },
1045
- children: x(n.tookSeconds, { n: t })
1280
+ children: v(n.tookSeconds, { n: t })
1046
1281
  }
1047
1282
  )
1048
1283
  ] });
1049
1284
  };
1050
- function Ie(e, t) {
1285
+ function Oe(e, t) {
1051
1286
  if (e.length === 0) return "";
1052
1287
  if (e.length === 1)
1053
- return x(t.pageSingle, { n: e[0] });
1288
+ return v(t.pageSingle, { n: e[0] });
1054
1289
  if (e.length === 2)
1055
- return x(t.pageTwo, {
1290
+ return v(t.pageTwo, {
1056
1291
  a: e[0],
1057
1292
  b: e[1]
1058
1293
  });
1059
1294
  const n = e[e.length - 1], r = e.slice(0, -1).join(", ");
1060
- return x(t.pageMultiple, { list: r, n });
1295
+ return v(t.pageMultiple, { list: r, n });
1061
1296
  }
1062
- const Me = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ v("div", { style: { padding: "16px" }, children: [
1297
+ const $e = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1063
1298
  /* @__PURE__ */ i(
1064
- T.div,
1299
+ S.div,
1065
1300
  {
1066
1301
  style: {
1067
1302
  marginBottom: "10px",
@@ -1077,32 +1312,32 @@ const Me = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ v("div", { s
1077
1312
  children: n.sources
1078
1313
  }
1079
1314
  ),
1080
- /* @__PURE__ */ i("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ i("span", { style: { fontSize: "13px", color: "#888" }, children: n.noSources }) : e.sources.map((r, s) => /* @__PURE__ */ i(
1081
- De,
1315
+ /* @__PURE__ */ i("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ i("span", { style: { fontSize: "13px", color: "#888" }, children: n.noSources }) : e.sources.map((r, l) => /* @__PURE__ */ i(
1316
+ ze,
1082
1317
  {
1083
1318
  source: r,
1084
- index: s,
1319
+ index: l,
1085
1320
  onSourceClick: t,
1086
1321
  t: n
1087
1322
  },
1088
1323
  r.memoryId
1089
1324
  )) })
1090
- ] }), De = ({
1325
+ ] }), ze = ({
1091
1326
  source: e,
1092
1327
  index: t,
1093
1328
  onSourceClick: n,
1094
1329
  t: r
1095
1330
  }) => {
1096
- const [s, d] = C(!1), o = !!n, l = e.pageNumbers ?? [], m = Ie(l, r);
1097
- return /* @__PURE__ */ v(
1098
- T.div,
1331
+ const [l, u] = x(!1), a = !!n, c = e.pageNumbers ?? [], s = Oe(c, r);
1332
+ return /* @__PURE__ */ y(
1333
+ S.div,
1099
1334
  {
1100
1335
  initial: { opacity: 0, scale: 0.9 },
1101
1336
  animate: { opacity: 1, scale: 1 },
1102
1337
  transition: { duration: 0.25, delay: t * 0.05 },
1103
- onClick: o ? () => n(e.memoryId) : void 0,
1104
- onMouseEnter: o ? () => d(!0) : void 0,
1105
- onMouseLeave: o ? () => d(!1) : void 0,
1338
+ onClick: a ? () => n(e.memoryId) : void 0,
1339
+ onMouseEnter: a ? () => u(!0) : void 0,
1340
+ onMouseLeave: a ? () => u(!1) : void 0,
1106
1341
  style: {
1107
1342
  display: "inline-flex",
1108
1343
  flexDirection: "column",
@@ -1110,18 +1345,18 @@ const Me = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ v("div", { s
1110
1345
  padding: "8px 12px",
1111
1346
  borderRadius: "6px",
1112
1347
  border: "1px solid #e0e0e0",
1113
- backgroundColor: s ? "#f5f5f5" : "transparent",
1114
- cursor: o ? "pointer" : "default",
1348
+ backgroundColor: l ? "#f5f5f5" : "transparent",
1349
+ cursor: a ? "pointer" : "default",
1115
1350
  transition: "background-color 0.15s ease",
1116
1351
  userSelect: "none"
1117
1352
  },
1118
1353
  children: [
1119
1354
  /* @__PURE__ */ i("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1120
- m && /* @__PURE__ */ i("span", { style: { fontSize: "12px", color: "#666" }, children: m })
1355
+ s && /* @__PURE__ */ i("span", { style: { fontSize: "12px", color: "#666" }, children: s })
1121
1356
  ]
1122
1357
  }
1123
1358
  );
1124
- }, U = ({
1359
+ }, j = ({
1125
1360
  color: e = "#78b13f",
1126
1361
  size: t = 24,
1127
1362
  borderWidth: n = 7
@@ -1140,20 +1375,20 @@ const Me = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ v("div", { s
1140
1375
  }
1141
1376
  }
1142
1377
  );
1143
- }, Pe = ({
1378
+ }, Be = ({
1144
1379
  color: e = "#333",
1145
1380
  size: t = 32,
1146
1381
  lineWidth: n = 2
1147
1382
  }) => {
1148
- const r = t + 1, s = (t - n) / 2, d = (t - r) / 2, o = {
1383
+ const r = t + 1, l = (t - n) / 2, u = (t - r) / 2, a = {
1149
1384
  position: "absolute",
1150
- left: s,
1151
- top: d,
1385
+ left: l,
1386
+ top: u,
1152
1387
  width: n,
1153
1388
  height: r,
1154
1389
  backgroundColor: e
1155
1390
  };
1156
- return /* @__PURE__ */ v(
1391
+ return /* @__PURE__ */ y(
1157
1392
  "span",
1158
1393
  {
1159
1394
  style: {
@@ -1167,7 +1402,7 @@ const Me = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ v("div", { s
1167
1402
  "span",
1168
1403
  {
1169
1404
  style: {
1170
- ...o,
1405
+ ...a,
1171
1406
  transform: "rotate(45deg)"
1172
1407
  }
1173
1408
  }
@@ -1176,7 +1411,7 @@ const Me = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ v("div", { s
1176
1411
  "span",
1177
1412
  {
1178
1413
  style: {
1179
- ...o,
1414
+ ...a,
1180
1415
  transform: "rotate(-45deg)"
1181
1416
  }
1182
1417
  }
@@ -1185,22 +1420,28 @@ const Me = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ v("div", { s
1185
1420
  }
1186
1421
  );
1187
1422
  };
1188
- function Re({
1189
- eventType: e,
1423
+ function Ue({
1424
+ memory: e,
1190
1425
  completed: t
1191
1426
  }) {
1192
- return e === "ExploreMemoryError" ? /* @__PURE__ */ i(Pe, { color: "#c62828", size: 15, lineWidth: 2 }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ i(U, { color: "#999", size: 15, borderWidth: 2 }) : e === "ExploreMemoryStart" ? t ? /* @__PURE__ */ i(U, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ i("span", { className: "explore-memory-loader" }) : null;
1427
+ return e.error != null ? /* @__PURE__ */ i(Be, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ i(j, { color: "#999", size: 15, borderWidth: 2 }) : t ? /* @__PURE__ */ i(j, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ i("span", { className: "explore-memory-loader" });
1193
1428
  }
1194
- const z = 80, Fe = ({ data: e, completed: t, isLatest: n = !1, t: r }) => {
1195
- const [s, d] = C(!1), o = e.eventType === "ExploreMemoryResult" ? e.result : void 0, l = o != null && o.length > z, m = o != null ? s || !l ? o : `${o.slice(0, z)}...` : void 0, a = l;
1196
- return /* @__PURE__ */ i("div", { style: { padding: "10px" }, children: /* @__PURE__ */ v(
1197
- T.div,
1429
+ const W = 80;
1430
+ function _e({
1431
+ memory: e,
1432
+ completed: t,
1433
+ t: n
1434
+ }) {
1435
+ const [r, l] = x(!1), u = e.result ?? e.error, a = u != null && u.length > W, c = u != null ? r || !a ? u : `${u.slice(0, W)}...` : void 0, s = a, o = e.error != null;
1436
+ return /* @__PURE__ */ y(
1437
+ S.div,
1198
1438
  {
1199
1439
  initial: { opacity: 0 },
1200
1440
  animate: { opacity: 1 },
1201
1441
  transition: { duration: 0.25 },
1202
- onClick: a ? () => d((c) => !c) : void 0,
1442
+ onClick: s ? () => l((d) => !d) : void 0,
1203
1443
  style: {
1444
+ paddingTop: "12px",
1204
1445
  paddingBottom: "12px",
1205
1446
  borderBottom: "1px solid #eee",
1206
1447
  display: "flex",
@@ -1208,7 +1449,7 @@ const z = 80, Fe = ({ data: e, completed: t, isLatest: n = !1, t: r }) => {
1208
1449
  alignItems: "center",
1209
1450
  gap: "10px",
1210
1451
  minWidth: 0,
1211
- cursor: a ? "pointer" : "default"
1452
+ cursor: s ? "pointer" : "default"
1212
1453
  },
1213
1454
  children: [
1214
1455
  /* @__PURE__ */ i(
@@ -1221,16 +1462,10 @@ const z = 80, Fe = ({ data: e, completed: t, isLatest: n = !1, t: r }) => {
1221
1462
  flexShrink: 0,
1222
1463
  width: 32
1223
1464
  },
1224
- children: /* @__PURE__ */ i(
1225
- Re,
1226
- {
1227
- eventType: e.eventType,
1228
- completed: t
1229
- }
1230
- )
1465
+ children: /* @__PURE__ */ i(Ue, { memory: e, completed: t })
1231
1466
  }
1232
1467
  ),
1233
- /* @__PURE__ */ v(
1468
+ /* @__PURE__ */ y(
1234
1469
  "div",
1235
1470
  {
1236
1471
  style: {
@@ -1247,19 +1482,19 @@ const z = 80, Fe = ({ data: e, completed: t, isLatest: n = !1, t: r }) => {
1247
1482
  children: e.memoryTitle
1248
1483
  }
1249
1484
  ),
1250
- m != null && /* @__PURE__ */ i(
1485
+ c != null && /* @__PURE__ */ i(
1251
1486
  "span",
1252
1487
  {
1253
1488
  style: {
1254
1489
  fontSize: 12,
1255
- color: "#666",
1490
+ color: o ? "#c62828" : "#666",
1256
1491
  lineHeight: 1.4,
1257
- whiteSpace: s ? "pre-wrap" : void 0
1492
+ whiteSpace: r ? "pre-wrap" : void 0
1258
1493
  },
1259
- children: m
1494
+ children: c
1260
1495
  }
1261
1496
  ),
1262
- a && /* @__PURE__ */ i(
1497
+ s && /* @__PURE__ */ i(
1263
1498
  "span",
1264
1499
  {
1265
1500
  style: {
@@ -1267,7 +1502,7 @@ const z = 80, Fe = ({ data: e, completed: t, isLatest: n = !1, t: r }) => {
1267
1502
  color: "#999",
1268
1503
  marginTop: 2
1269
1504
  },
1270
- children: s ? r.clickToCollapse : r.clickToExpand
1505
+ children: r ? n.clickToCollapse : n.clickToExpand
1271
1506
  }
1272
1507
  )
1273
1508
  ]
@@ -1275,33 +1510,42 @@ const z = 80, Fe = ({ data: e, completed: t, isLatest: n = !1, t: r }) => {
1275
1510
  )
1276
1511
  ]
1277
1512
  }
1278
- ) });
1279
- };
1280
- function Oe(e, t) {
1513
+ );
1514
+ }
1515
+ const Ne = ({ data: e, completed: t, t: n }) => /* @__PURE__ */ i("div", { style: { padding: "10px" }, children: e.memories.map((r) => /* @__PURE__ */ i(
1516
+ _e,
1517
+ {
1518
+ memory: r,
1519
+ completed: t,
1520
+ t: n
1521
+ },
1522
+ r.memoryId
1523
+ )) });
1524
+ function je(e, t) {
1281
1525
  if (e.length === 0) return "";
1282
1526
  if (e.length === 1)
1283
- return x(t.pageSingle, { n: e[0] });
1527
+ return v(t.pageSingle, { n: e[0] });
1284
1528
  if (e.length === 2)
1285
- return x(t.pageTwo, {
1529
+ return v(t.pageTwo, {
1286
1530
  a: e[0],
1287
1531
  b: e[1]
1288
1532
  });
1289
1533
  const n = e[e.length - 1], r = e.slice(0, -1).join(", ");
1290
- return x(t.pageMultiple, { list: r, n });
1534
+ return v(t.pageMultiple, { list: r, n });
1291
1535
  }
1292
- function Le(e, t) {
1293
- return e === 1 ? t.chunkFound : x(t.chunksFound, { n: e });
1536
+ function We(e, t) {
1537
+ return e === 1 ? t.chunkFound : v(t.chunksFound, { n: e });
1294
1538
  }
1295
- const Be = ({ data: e, t }) => {
1296
- const [n, r] = C(!1), s = e.chunks.length, d = s > 0;
1297
- return /* @__PURE__ */ v("div", { style: { padding: "10px" }, children: [
1298
- /* @__PURE__ */ v(
1299
- T.div,
1539
+ const He = ({ data: e, t }) => {
1540
+ const [n, r] = x(!1), l = e.chunks.length, u = l > 0;
1541
+ return /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
1542
+ /* @__PURE__ */ y(
1543
+ S.div,
1300
1544
  {
1301
1545
  initial: { opacity: 0 },
1302
1546
  animate: { opacity: 1 },
1303
1547
  transition: { duration: 0.25 },
1304
- onClick: d ? () => r((o) => !o) : void 0,
1548
+ onClick: u ? () => r((a) => !a) : void 0,
1305
1549
  style: {
1306
1550
  paddingBottom: n ? "12px" : 0,
1307
1551
  borderBottom: n ? "1px solid #eee" : void 0,
@@ -1309,12 +1553,12 @@ const Be = ({ data: e, t }) => {
1309
1553
  flexDirection: "column",
1310
1554
  gap: "4px",
1311
1555
  minWidth: 0,
1312
- cursor: d ? "pointer" : "default"
1556
+ cursor: u ? "pointer" : "default"
1313
1557
  },
1314
1558
  children: [
1315
1559
  /* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1316
- /* @__PURE__ */ i("span", { style: { fontSize: 12, color: "#666" }, children: Le(s, t) }),
1317
- d && /* @__PURE__ */ i(
1560
+ /* @__PURE__ */ i("span", { style: { fontSize: 12, color: "#666" }, children: We(l, t) }),
1561
+ u && /* @__PURE__ */ i(
1318
1562
  "span",
1319
1563
  {
1320
1564
  style: {
@@ -1328,8 +1572,8 @@ const Be = ({ data: e, t }) => {
1328
1572
  ]
1329
1573
  }
1330
1574
  ),
1331
- n && d && /* @__PURE__ */ i(
1332
- T.div,
1575
+ n && u && /* @__PURE__ */ i(
1576
+ S.div,
1333
1577
  {
1334
1578
  initial: { opacity: 0, height: 0 },
1335
1579
  animate: { opacity: 1, height: "auto" },
@@ -1342,9 +1586,9 @@ const Be = ({ data: e, t }) => {
1342
1586
  flexDirection: "column",
1343
1587
  gap: 8
1344
1588
  },
1345
- children: e.chunks.map((o, l) => {
1346
- const m = o.pageNumbers ?? [], a = Oe(m, t);
1347
- return /* @__PURE__ */ v(
1589
+ children: e.chunks.map((a, c) => {
1590
+ const s = a.pageNumbers ?? [], o = je(s, t);
1591
+ return /* @__PURE__ */ y(
1348
1592
  "div",
1349
1593
  {
1350
1594
  style: {
@@ -1364,10 +1608,10 @@ const Be = ({ data: e, t }) => {
1364
1608
  display: "block",
1365
1609
  marginBottom: 4
1366
1610
  },
1367
- children: o.content
1611
+ children: a.content
1368
1612
  }
1369
1613
  ),
1370
- /* @__PURE__ */ v(
1614
+ /* @__PURE__ */ y(
1371
1615
  "div",
1372
1616
  {
1373
1617
  style: {
@@ -1377,23 +1621,23 @@ const Be = ({ data: e, t }) => {
1377
1621
  color: "#666"
1378
1622
  },
1379
1623
  children: [
1380
- a && /* @__PURE__ */ i("span", { children: a }),
1381
- /* @__PURE__ */ i("span", { children: x(t.scoreLabel, {
1382
- n: o.score
1624
+ o && /* @__PURE__ */ i("span", { children: o }),
1625
+ /* @__PURE__ */ i("span", { children: v(t.scoreLabel, {
1626
+ n: a.score
1383
1627
  }) })
1384
1628
  ]
1385
1629
  }
1386
1630
  )
1387
1631
  ]
1388
1632
  },
1389
- l
1633
+ c
1390
1634
  );
1391
1635
  })
1392
1636
  }
1393
1637
  )
1394
1638
  ] });
1395
- }, Ue = ({ message: e }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
1396
- T.div,
1639
+ }, Ke = ({ message: e }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
1640
+ S.div,
1397
1641
  {
1398
1642
  initial: { opacity: 0, y: -10 },
1399
1643
  animate: { opacity: 1, y: 0 },
@@ -1415,126 +1659,144 @@ const Be = ({ data: e, t }) => {
1415
1659
  }
1416
1660
  )
1417
1661
  }
1418
- ) }), ze = ({
1662
+ ) }), qe = ({
1419
1663
  progressViewItems: e,
1420
1664
  loadingText: t,
1421
1665
  t: n,
1422
1666
  onSourceClick: r
1423
1667
  }) => {
1424
- const s = A(null);
1668
+ const l = I(null);
1425
1669
  w(() => {
1426
- s.current && (s.current.scrollTop = s.current.scrollHeight);
1670
+ l.current && (l.current.scrollTop = l.current.scrollHeight);
1427
1671
  }, [e.length]);
1428
- const d = (o) => {
1429
- const l = o.item.data;
1430
- if (l.taskType === "StreamingChatCompletion" && l.eventType === "Text")
1431
- return /* @__PURE__ */ i(B, { text: l.text });
1432
- if (l.taskType === "StructuredChatCompletion" && l.eventType === "Json")
1433
- return /* @__PURE__ */ i(xe, { data: l });
1434
- if (l.taskType === "MemoryChatCompletion")
1435
- switch (l.eventType) {
1672
+ const u = (c) => {
1673
+ const s = c.item.data;
1674
+ if (s.taskType === "StreamingChatCompletion" && s.eventType === "Text")
1675
+ return /* @__PURE__ */ i(N, { text: s.text });
1676
+ if (s.taskType === "StructuredChatCompletion" && s.eventType === "Json")
1677
+ return /* @__PURE__ */ i(Ie, { data: s });
1678
+ if (s.taskType === "MemoryChatCompletion")
1679
+ switch (s.eventType) {
1436
1680
  case "Text":
1437
- return /* @__PURE__ */ i(B, { text: l.text });
1681
+ return /* @__PURE__ */ i(N, { text: s.text });
1682
+ case "FindMemories":
1683
+ return /* @__PURE__ */ i(
1684
+ Pe,
1685
+ {
1686
+ data: s,
1687
+ isLatest: c.isLatest,
1688
+ durationSeconds: c.durationSeconds,
1689
+ t: n
1690
+ }
1691
+ );
1692
+ case "FindMemoriesResult":
1693
+ return /* @__PURE__ */ i(Re, { data: s, t: n });
1438
1694
  case "Search":
1439
1695
  return /* @__PURE__ */ i(
1440
- we,
1696
+ De,
1441
1697
  {
1442
- data: l,
1443
- isLatest: o.isLatest,
1444
- durationSeconds: o.durationSeconds,
1698
+ data: s,
1699
+ isLatest: c.isLatest,
1700
+ durationSeconds: c.durationSeconds,
1445
1701
  t: n
1446
1702
  }
1447
1703
  );
1448
1704
  case "FindSources":
1449
1705
  return /* @__PURE__ */ i(
1450
- Ae,
1706
+ Le,
1451
1707
  {
1452
- data: l,
1453
- isLatest: o.isLatest,
1454
- durationSeconds: o.durationSeconds,
1708
+ data: s,
1709
+ isLatest: c.isLatest,
1710
+ durationSeconds: c.durationSeconds,
1455
1711
  t: n
1456
1712
  }
1457
1713
  );
1458
1714
  case "SourcesResult":
1459
1715
  return /* @__PURE__ */ i(
1460
- Me,
1716
+ $e,
1461
1717
  {
1462
- data: l,
1718
+ data: s,
1463
1719
  onSourceClick: r,
1464
1720
  t: n
1465
1721
  }
1466
1722
  );
1467
- case "ExploreMemoryStart":
1468
- case "ExploreMemoryResult":
1469
- case "ExploreMemoryError":
1723
+ case "ExploreMemories":
1470
1724
  return /* @__PURE__ */ i(
1471
- Fe,
1725
+ Ne,
1472
1726
  {
1473
- data: l,
1474
- completed: o.completed,
1475
- isLatest: o.isLatest,
1727
+ data: s,
1728
+ completed: c.completed,
1729
+ isLatest: c.isLatest,
1476
1730
  t: n
1477
1731
  }
1478
1732
  );
1479
1733
  case "ChunkResult":
1480
- return /* @__PURE__ */ i(Be, { data: l, t: n });
1734
+ return /* @__PURE__ */ i(He, { data: s, t: n });
1481
1735
  case "Completed":
1482
1736
  return null;
1483
1737
  }
1484
- return l.taskType === "StreamingChatCompletion" && l.eventType === "Completed" || l.taskType === "StructuredChatCompletion" && l.eventType === "Completed" ? null : l.eventType === "Error" && "message" in l ? /* @__PURE__ */ i(Ue, { message: l.message }) : null;
1738
+ return s.taskType === "StreamingChatCompletion" && s.eventType === "Completed" || s.taskType === "StructuredChatCompletion" && s.eventType === "Completed" ? null : s.eventType === "Error" && "message" in s ? /* @__PURE__ */ i(Ke, { message: s.message }) : null;
1485
1739
  };
1486
- return e.length === 0 ? /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
1487
- R,
1488
- {
1489
- text: t ?? n.processingYourTask,
1490
- duration: 1.5,
1491
- repeat: !0,
1492
- repeatDelay: 0,
1493
- color: "#999",
1494
- shimmerColor: "#000"
1495
- }
1496
- ) }) : /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: s, children: /* @__PURE__ */ i(W, { children: e.map((o, l) => /* @__PURE__ */ i(
1497
- T.div,
1740
+ if (e.length === 0)
1741
+ return /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
1742
+ P,
1743
+ {
1744
+ text: t ?? n.processingYourTask,
1745
+ duration: 1.5,
1746
+ repeat: !0,
1747
+ repeatDelay: 0,
1748
+ color: "#999",
1749
+ shimmerColor: "#000"
1750
+ }
1751
+ ) });
1752
+ const a = e.filter((c, s) => {
1753
+ const o = c.item.data;
1754
+ return o.taskType === "MemoryChatCompletion" && o.eventType === "ExploreMemories" ? !e.slice(s + 1).some(
1755
+ (m) => m.item.data.taskType === "MemoryChatCompletion" && m.item.data.eventType === "ExploreMemories"
1756
+ ) : !0;
1757
+ });
1758
+ return /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: l, children: /* @__PURE__ */ i(q, { children: a.map((c, s) => /* @__PURE__ */ i(
1759
+ S.div,
1498
1760
  {
1499
- id: `agent-task-progress-item-${o.item.progressItemId}`,
1761
+ id: `agent-task-progress-item-${c.item.progressItemId}`,
1500
1762
  initial: { opacity: 0, y: -20 },
1501
1763
  animate: { opacity: 1, y: 0 },
1502
1764
  transition: {
1503
1765
  duration: 0.4,
1504
- delay: l * 0.1,
1766
+ delay: s * 0.1,
1505
1767
  ease: "easeOut"
1506
1768
  },
1507
- children: d(o)
1769
+ children: u(c)
1508
1770
  },
1509
- o.item.progressItemId
1771
+ c.item.progressItemId
1510
1772
  )) }) });
1511
- }, Ve = ({
1773
+ }, nt = ({
1512
1774
  agentTask: e,
1513
1775
  mode: t = "verbose",
1514
1776
  language: n,
1515
1777
  onSourceClick: r
1516
1778
  }) => {
1517
- const s = Te(e), d = e.params.type === "MemoryChatCompletion" && "language" in e.params ? e.params.language ?? "en" : n ?? "en", o = Ee(d);
1779
+ const l = Ee(e), u = e.params.type === "MemoryChatCompletion" && "language" in e.params ? e.params.language ?? "en" : n ?? "en", a = Fe(u);
1518
1780
  return t === "simple" ? /* @__PURE__ */ i(
1519
- be,
1781
+ we,
1520
1782
  {
1521
- progressViewItems: s,
1522
- t: o
1783
+ progressViewItems: l,
1784
+ t: a
1523
1785
  }
1524
1786
  ) : /* @__PURE__ */ i(
1525
- ze,
1787
+ qe,
1526
1788
  {
1527
- progressViewItems: s,
1789
+ progressViewItems: l,
1528
1790
  loadingText: e.loadingText,
1529
- t: o,
1791
+ t: a,
1530
1792
  onSourceClick: r
1531
1793
  }
1532
1794
  );
1533
1795
  };
1534
1796
  export {
1535
- Ve as AgentTaskProgress,
1536
- U as Checkmark,
1537
- Ge as FencyProvider,
1538
- Pe as XMark,
1539
- Je as useAgentTasks
1797
+ nt as AgentTaskProgress,
1798
+ j as Checkmark,
1799
+ et as FencyProvider,
1800
+ Be as XMark,
1801
+ tt as useAgentTasks
1540
1802
  };