@fencyai/react 0.1.171 → 0.1.173

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,76 +1,76 @@
1
- import { jsxs as p, jsx as o, Fragment as E } from "react/jsx-runtime";
2
- import { createStream as se, isStreamTimeoutEvent as le, isStreamNotFoundEvent as ce, isAgentTaskProgressItemUpdatedEvent as de, createAgentTask as me } from "@fencyai/js";
3
- import { createContext as ue, useState as w, useRef as F, useEffect as R, useCallback as N, useContext as ye, useMemo as z } from "react";
4
- import { motion as I, useInView as ge, AnimatePresence as pe } from "motion/react";
5
- import he from "react-markdown";
6
- import { Prism as ne } from "react-syntax-highlighter";
7
- import fe from "remark-gfm";
8
- import './assets/index.css';const te = ue(
1
+ import { jsxs as h, jsx as o, Fragment as E } from "react/jsx-runtime";
2
+ import { createStream as ce, isStreamTimeoutEvent as de, isStreamNotFoundEvent as me, isAgentTaskProgressItemUpdatedEvent as ue, createAgentTask as ye } from "@fencyai/js";
3
+ import { createContext as ge, useState as I, useRef as F, useEffect as A, useCallback as O, useContext as he, useMemo as B } from "react";
4
+ import { motion as C, useInView as pe, AnimatePresence as fe } from "motion/react";
5
+ import Se from "react-markdown";
6
+ import { Prism as oe } from "react-syntax-highlighter";
7
+ import xe from "remark-gfm";
8
+ import './assets/index.css';const ie = ge(
9
9
  void 0
10
10
  );
11
- async function xe(e, n) {
11
+ async function ke(e, r) {
12
12
  const t = e.getReader();
13
- let r;
14
- for (; !(r = await t.read()).done; )
15
- n(r.value);
13
+ let n;
14
+ for (; !(n = await t.read()).done; )
15
+ r(n.value);
16
16
  }
17
- function Se(e) {
18
- let n, t, r, a = !1;
19
- return function(s) {
20
- n === void 0 ? (n = s, t = 0, r = -1) : n = ke(n, s);
21
- const d = n.length;
17
+ function be(e) {
18
+ let r, t, n, i = !1;
19
+ return function(a) {
20
+ r === void 0 ? (r = a, t = 0, n = -1) : r = Te(r, a);
21
+ const c = r.length;
22
22
  let u = 0;
23
- for (; t < d; ) {
24
- a && (n[t] === 10 && (u = ++t), a = !1);
23
+ for (; t < c; ) {
24
+ i && (r[t] === 10 && (u = ++t), i = !1);
25
25
  let y = -1;
26
- for (; t < d && y === -1; ++t)
27
- switch (n[t]) {
26
+ for (; t < c && y === -1; ++t)
27
+ switch (r[t]) {
28
28
  case 58:
29
- r === -1 && (r = t - u);
29
+ n === -1 && (n = t - u);
30
30
  break;
31
31
  case 13:
32
- a = !0;
32
+ i = !0;
33
33
  case 10:
34
34
  y = t;
35
35
  break;
36
36
  }
37
37
  if (y === -1)
38
38
  break;
39
- e(n.subarray(u, y), r), u = t, r = -1;
39
+ e(r.subarray(u, y), n), u = t, n = -1;
40
40
  }
41
- u === d ? n = void 0 : u !== 0 && (n = n.subarray(u), t -= u);
41
+ u === c ? r = void 0 : u !== 0 && (r = r.subarray(u), t -= u);
42
42
  };
43
43
  }
44
- function Te(e, n, t) {
45
- let r = J();
46
- const a = new TextDecoder();
47
- return function(s, d) {
48
- if (s.length === 0)
49
- t == null || t(r), r = J();
50
- else if (d > 0) {
51
- const u = a.decode(s.subarray(0, d)), y = d + (s[d + 1] === 32 ? 2 : 1), i = a.decode(s.subarray(y));
44
+ function ve(e, r, t) {
45
+ let n = J();
46
+ const i = new TextDecoder();
47
+ return function(a, c) {
48
+ if (a.length === 0)
49
+ t == null || t(n), n = J();
50
+ else if (c > 0) {
51
+ const u = i.decode(a.subarray(0, c)), y = c + (a[c + 1] === 32 ? 2 : 1), s = i.decode(a.subarray(y));
52
52
  switch (u) {
53
53
  case "data":
54
- r.data = r.data ? r.data + `
55
- ` + i : i;
54
+ n.data = n.data ? n.data + `
55
+ ` + s : s;
56
56
  break;
57
57
  case "event":
58
- r.event = i;
58
+ n.event = s;
59
59
  break;
60
60
  case "id":
61
- e(r.id = i);
61
+ e(n.id = s);
62
62
  break;
63
63
  case "retry":
64
- const l = parseInt(i, 10);
65
- isNaN(l) || n(r.retry = l);
64
+ const d = parseInt(s, 10);
65
+ isNaN(d) || r(n.retry = d);
66
66
  break;
67
67
  }
68
68
  }
69
69
  };
70
70
  }
71
- function ke(e, n) {
72
- const t = new Uint8Array(e.length + n.length);
73
- return t.set(e), t.set(n, e.length), t;
71
+ function Te(e, r) {
72
+ const t = new Uint8Array(e.length + r.length);
73
+ return t.set(e), t.set(r, e.length), t;
74
74
  }
75
75
  function J() {
76
76
  return {
@@ -80,110 +80,339 @@ function J() {
80
80
  retry: void 0
81
81
  };
82
82
  }
83
- var be = function(e, n) {
83
+ var we = function(e, r) {
84
84
  var t = {};
85
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && n.indexOf(r) < 0 && (t[r] = e[r]);
85
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
86
86
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
87
- for (var a = 0, r = Object.getOwnPropertySymbols(e); a < r.length; a++)
88
- n.indexOf(r[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[a]) && (t[r[a]] = e[r[a]]);
87
+ for (var i = 0, n = Object.getOwnPropertySymbols(e); i < n.length; i++)
88
+ r.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[i]) && (t[n[i]] = e[n[i]]);
89
89
  return t;
90
90
  };
91
- const U = "text/event-stream", ve = 1e3, Y = "last-event-id";
92
- function Ce(e, n) {
93
- var { signal: t, headers: r, onopen: a, onmessage: c, onclose: s, onerror: d, openWhenHidden: u, fetch: y } = n, i = be(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
- return new Promise((l, m) => {
95
- const g = Object.assign({}, r);
96
- g.accept || (g.accept = U);
97
- let h;
91
+ const z = "text/event-stream", Ie = 1e3, Y = "last-event-id";
92
+ function Ce(e, r) {
93
+ var { signal: t, headers: n, onopen: i, onmessage: l, onclose: a, onerror: c, openWhenHidden: u, fetch: y } = r, s = we(r, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
+ return new Promise((d, m) => {
95
+ const g = Object.assign({}, n);
96
+ g.accept || (g.accept = z);
97
+ let p;
98
98
  function f() {
99
- h.abort(), document.hidden || v();
99
+ p.abort(), document.hidden || T();
100
100
  }
101
101
  u || document.addEventListener("visibilitychange", f);
102
- let S = ve, T = 0;
103
- function k() {
104
- document.removeEventListener("visibilitychange", f), window.clearTimeout(T), h.abort();
102
+ let x = Ie, k = 0;
103
+ function b() {
104
+ document.removeEventListener("visibilitychange", f), window.clearTimeout(k), p.abort();
105
105
  }
106
106
  t == null || t.addEventListener("abort", () => {
107
- k(), l();
107
+ b(), d();
108
108
  });
109
- const x = y ?? window.fetch, C = a ?? we;
110
- async function v() {
111
- var P;
112
- h = new AbortController();
109
+ const S = y ?? window.fetch, w = i ?? Ee;
110
+ async function T() {
111
+ var L;
112
+ p = new AbortController();
113
113
  try {
114
- const D = await x(e, Object.assign(Object.assign({}, i), { headers: g, signal: h.signal }));
115
- await C(D), await xe(D.body, Se(Te((A) => {
116
- A ? g[Y] = A : delete g[Y];
117
- }, (A) => {
118
- S = A;
119
- }, c))), s == null || s(), k(), l();
120
- } catch (D) {
121
- if (!h.signal.aborted)
114
+ const P = await S(e, Object.assign(Object.assign({}, s), { headers: g, signal: p.signal }));
115
+ await w(P), await ke(P.body, be(ve((R) => {
116
+ R ? g[Y] = R : delete g[Y];
117
+ }, (R) => {
118
+ x = R;
119
+ }, l))), a == null || a(), b(), d();
120
+ } catch (P) {
121
+ if (!p.signal.aborted)
122
122
  try {
123
- const A = (P = d == null ? void 0 : d(D)) !== null && P !== void 0 ? P : S;
124
- window.clearTimeout(T), T = window.setTimeout(v, A);
125
- } catch (A) {
126
- k(), m(A);
123
+ const R = (L = c == null ? void 0 : c(P)) !== null && L !== void 0 ? L : x;
124
+ window.clearTimeout(k), k = window.setTimeout(T, R);
125
+ } catch (R) {
126
+ b(), m(R);
127
127
  }
128
128
  }
129
129
  }
130
- v();
130
+ T();
131
131
  });
132
132
  }
133
- function we(e) {
134
- const n = e.headers.get("content-type");
135
- if (!(n != null && n.startsWith(U)))
136
- throw new Error(`Expected content-type to be ${U}, Actual: ${n}`);
133
+ function Ee(e) {
134
+ const r = e.headers.get("content-type");
135
+ if (!(r != null && r.startsWith(z)))
136
+ throw new Error(`Expected content-type to be ${z}, Actual: ${r}`);
137
137
  }
138
- function Ie(e) {
139
- const n = atob(e), t = new Uint8Array(n.length);
140
- for (let r = 0; r < n.length; r++)
141
- t[r] = n.charCodeAt(r);
138
+ function Z(e) {
139
+ const r = atob(e), t = new Uint8Array(r.length);
140
+ for (let n = 0; n < r.length; n++)
141
+ t[n] = r.charCodeAt(n);
142
142
  return new TextDecoder("utf-8").decode(t);
143
143
  }
144
- function Ee(e) {
144
+ function Me() {
145
+ return `
146
+ var connections = new Map();
147
+
148
+ function disconnectStream(streamId) {
149
+ var entry = connections.get(streamId);
150
+ if (entry) {
151
+ try {
152
+ entry.cancel();
153
+ } catch (e) {}
154
+ connections.delete(streamId);
155
+ }
156
+ }
157
+
158
+ function findEventBoundary(buf) {
159
+ var iCRLF = buf.indexOf("\\r\\n\\r\\n");
160
+ var iLF = buf.indexOf("\\n\\n");
161
+ if (iCRLF !== -1 && (iLF === -1 || iCRLF < iLF)) {
162
+ return { index: iCRLF, len: 4 };
163
+ }
164
+ if (iLF !== -1) {
165
+ return { index: iLF, len: 2 };
166
+ }
167
+ return null;
168
+ }
169
+
170
+ function parseSseBuffer(buffer) {
171
+ var events = [];
172
+ var rest = buffer;
173
+ while (true) {
174
+ var boundary = findEventBoundary(rest);
175
+ if (!boundary) break;
176
+ var rawEvent = rest.slice(0, boundary.index);
177
+ rest = rest.slice(boundary.index + boundary.len);
178
+ if (!rawEvent.trim()) continue;
179
+
180
+ var eventType = "";
181
+ var eventId = "";
182
+ var dataLines = [];
183
+ var lines = rawEvent.split(/\\r\\n|\\r|\\n/);
184
+ for (var i = 0; i < lines.length; i++) {
185
+ var line = lines[i];
186
+ if (line.charAt(0) === ":") continue;
187
+ var colon = line.indexOf(":");
188
+ if (colon === -1) continue;
189
+ var field = line.slice(0, colon);
190
+ var value = line.slice(colon + 1);
191
+ if (value.charAt(0) === " ") value = value.slice(1);
192
+ if (field === "data") dataLines.push(value);
193
+ else if (field === "event") eventType = value;
194
+ else if (field === "id") eventId = value;
195
+ }
196
+ var data = dataLines.join("\\n");
197
+ if (data.length > 0) {
198
+ events.push({ data: data, event: eventType, id: eventId });
199
+ }
200
+ }
201
+ return { events: events, rest: rest };
202
+ }
203
+
204
+ async function readStream(streamId, readableStream) {
205
+ disconnectStream(streamId);
206
+ if (!readableStream || typeof readableStream.getReader !== "function") {
207
+ self.postMessage({
208
+ type: "error",
209
+ streamId: streamId,
210
+ error: "No readable stream",
211
+ });
212
+ return;
213
+ }
214
+ var reader = readableStream.getReader();
215
+ connections.set(streamId, {
216
+ cancel: function () {
217
+ reader.cancel().catch(function () {});
218
+ },
219
+ });
220
+ try {
221
+ var decoder = new TextDecoder();
222
+ var buf = "";
223
+ while (true) {
224
+ var readResult = await reader.read();
225
+ var done = readResult.done;
226
+ var value = readResult.value;
227
+ if (done) break;
228
+ buf += decoder.decode(value, { stream: true });
229
+ var parsed = parseSseBuffer(buf);
230
+ buf = parsed.rest;
231
+ for (var j = 0; j < parsed.events.length; j++) {
232
+ var ev = parsed.events[j];
233
+ self.postMessage({
234
+ type: "message",
235
+ streamId: streamId,
236
+ data: ev.data,
237
+ event: ev.event || undefined,
238
+ id: ev.id || undefined,
239
+ });
240
+ }
241
+ }
242
+ buf += decoder.decode();
243
+ var finalParsed = parseSseBuffer(buf);
244
+ for (var k = 0; k < finalParsed.events.length; k++) {
245
+ var fev = finalParsed.events[k];
246
+ self.postMessage({
247
+ type: "message",
248
+ streamId: streamId,
249
+ data: fev.data,
250
+ event: fev.event || undefined,
251
+ id: fev.id || undefined,
252
+ });
253
+ }
254
+ } catch (err) {
255
+ if (err && err.name === "AbortError") {
256
+ return;
257
+ }
258
+ var msg = err && err.message ? String(err.message) : String(err);
259
+ self.postMessage({ type: "error", streamId: streamId, error: msg });
260
+ } finally {
261
+ connections.delete(streamId);
262
+ }
263
+ }
264
+
265
+ self.onmessage = function (e) {
266
+ var d = e.data;
267
+ if (!d || !d.command) return;
268
+ switch (d.command) {
269
+ case "start":
270
+ readStream(d.streamId, d.readableStream);
271
+ break;
272
+ case "disconnect":
273
+ disconnectStream(d.streamId);
274
+ break;
275
+ case "cleanup":
276
+ connections.forEach(function (entry) {
277
+ try {
278
+ entry.cancel();
279
+ } catch (e2) {}
280
+ });
281
+ connections.clear();
282
+ self.close();
283
+ break;
284
+ default:
285
+ break;
286
+ }
287
+ };
288
+ `.trim();
289
+ }
290
+ function ee(e) {
145
291
  return e instanceof Error ? e.message : typeof e == "string" ? e : "Unknown stream error";
146
292
  }
147
- class Me {
148
- constructor(n) {
149
- this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = n;
293
+ class Re {
294
+ constructor(r) {
295
+ this.activeConnections = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.worker = null, this.workerBlobUrl = null, this.workerSupported = !1, this.fency = r, this.tryInitWorker();
296
+ }
297
+ tryInitWorker() {
298
+ try {
299
+ if (typeof Worker > "u" || typeof Blob > "u" || typeof URL > "u" || typeof URL.createObjectURL != "function" || typeof ReadableStream > "u")
300
+ return;
301
+ const r = Me(), t = new Blob([r], { type: "application/javascript" }), n = URL.createObjectURL(t), i = new Worker(n);
302
+ i.onmessage = (l) => {
303
+ this.handleWorkerMessage(l.data);
304
+ }, i.onerror = (l) => {
305
+ console.error("Fency stream worker error:", l.message);
306
+ }, this.worker = i, this.workerBlobUrl = n, this.workerSupported = !0;
307
+ } catch {
308
+ this.workerSupported = !1, this.worker = null, this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
309
+ }
310
+ }
311
+ handleWorkerMessage(r) {
312
+ if (!r || typeof r != "object") return;
313
+ const t = r;
314
+ switch (t.type) {
315
+ case "message":
316
+ if (t.data && t.streamId) {
317
+ const n = Z(t.data);
318
+ this.broadcast(n, t.streamId);
319
+ }
320
+ break;
321
+ case "error":
322
+ t.streamId && (this.activeConnections.delete(t.streamId), this.broadcastError(t.streamId, t.error));
323
+ break;
324
+ }
150
325
  }
151
326
  /**
152
327
  * Called by FencyProvider when activeStreams changes.
153
328
  * Creates new connections and removes old ones.
154
329
  */
155
- updateStreams(n) {
156
- n.forEach((r) => {
157
- const a = r.stream.id;
158
- this.eventSources.has(a) || this.connectStream(r);
330
+ updateStreams(r) {
331
+ r.forEach((n) => {
332
+ const i = n.stream.id;
333
+ this.activeConnections.has(i) || this.connectStream(n);
159
334
  });
160
- const t = new Set(n.map((r) => r.stream.id));
161
- this.eventSources.forEach((r, a) => {
162
- t.has(a) || (r.abort(), this.eventSources.delete(a));
335
+ const t = new Set(r.map((n) => n.stream.id));
336
+ this.activeConnections.forEach((n, i) => {
337
+ t.has(i) || (n.abort(), this.activeConnections.delete(i));
163
338
  });
164
339
  }
165
- connectStream(n) {
166
- const t = n.stream.id, r = new AbortController();
167
- this.eventSources.set(t, r);
168
- const a = `${this.fency.baseUrl}/sse/streams/${t}`, c = {
340
+ connectStream(r) {
341
+ this.workerSupported && this.worker ? this.connectStreamInWorker(r) : this.connectStreamOnMainThread(r);
342
+ }
343
+ connectStreamInWorker(r) {
344
+ const t = r.stream.id, n = `${this.fency.baseUrl}/sse/streams/${t}`, i = new AbortController(), l = {
345
+ accept: z,
346
+ "X-Fency-Publishable-Key": this.fency.publishableKey,
347
+ "X-Fency-Stream-Token": r.stream.token
348
+ };
349
+ this.activeConnections.set(t, {
350
+ abort: () => {
351
+ var a;
352
+ i.abort(), (a = this.worker) == null || a.postMessage({ command: "disconnect", streamId: t });
353
+ }
354
+ }), this.startWorkerStream(t, n, l, i);
355
+ }
356
+ async startWorkerStream(r, t, n, i) {
357
+ const l = this.worker;
358
+ if (!l) return;
359
+ const a = (c) => {
360
+ i.signal.aborted || (this.activeConnections.delete(r), this.broadcastError(r, c));
361
+ };
362
+ try {
363
+ const c = await fetch(t, {
364
+ method: "GET",
365
+ headers: n,
366
+ signal: i.signal
367
+ });
368
+ if (!c.ok) {
369
+ c.status >= 400 && c.status < 500 && c.status !== 429 ? a(`Client error ${c.status}`) : a(`HTTP ${c.status}`);
370
+ return;
371
+ }
372
+ const u = c.body;
373
+ if (!u) {
374
+ a("No response body");
375
+ return;
376
+ }
377
+ if (!this.activeConnections.has(r)) {
378
+ await u.cancel().catch(() => {
379
+ });
380
+ return;
381
+ }
382
+ l.postMessage(
383
+ { command: "start", streamId: r, readableStream: u },
384
+ [u]
385
+ );
386
+ } catch (c) {
387
+ if (i.signal.aborted) return;
388
+ a(ee(c));
389
+ }
390
+ }
391
+ connectStreamOnMainThread(r) {
392
+ const t = r.stream.id, n = new AbortController();
393
+ this.activeConnections.set(t, {
394
+ abort: () => n.abort()
395
+ });
396
+ const i = `${this.fency.baseUrl}/sse/streams/${t}`, l = {
169
397
  "X-Fency-Publishable-Key": this.fency.publishableKey,
170
- "X-Fency-Stream-Token": n.stream.token
398
+ "X-Fency-Stream-Token": r.stream.token
171
399
  };
172
- Ce(a, {
173
- headers: c,
174
- signal: r.signal,
175
- onopen: async (s) => {
176
- if (!s.ok && s.status >= 400 && s.status < 500 && s.status !== 429)
177
- throw this.eventSources.delete(t), new Error(`Client error ${s.status}`);
400
+ Ce(i, {
401
+ headers: l,
402
+ signal: n.signal,
403
+ openWhenHidden: !0,
404
+ onopen: async (a) => {
405
+ if (!a.ok && a.status >= 400 && a.status < 500 && a.status !== 429)
406
+ throw this.activeConnections.delete(t), new Error(`Client error ${a.status}`);
178
407
  },
179
- onmessage: (s) => {
180
- if (s.data) {
181
- const d = Ie(s.data);
182
- this.broadcast(d, t);
408
+ onmessage: (a) => {
409
+ if (a.data) {
410
+ const c = Z(a.data);
411
+ this.broadcast(c, t);
183
412
  }
184
413
  },
185
- onerror: (s) => {
186
- throw console.error("EventSource error for stream", t, ":", s), this.eventSources.delete(t), this.broadcastError(t, Ee(s)), s;
414
+ onerror: (a) => {
415
+ throw console.error("EventSource error for stream", t, ":", a), this.activeConnections.delete(t), this.broadcastError(t, ee(a)), a;
187
416
  },
188
417
  onclose() {
189
418
  }
@@ -193,129 +422,136 @@ class Me {
193
422
  * Subscribe to events from all active streams.
194
423
  * Returns an unsubscribe function.
195
424
  */
196
- subscribe(n, t) {
197
- return this.subscribers.set(n, t), () => {
198
- this.subscribers.delete(n);
425
+ subscribe(r, t) {
426
+ return this.subscribers.set(r, t), () => {
427
+ this.subscribers.delete(r);
199
428
  };
200
429
  }
201
- broadcast(n, t) {
202
- this.subscribers.forEach((r) => {
203
- r.onMessage(n, t);
430
+ broadcast(r, t) {
431
+ this.subscribers.forEach((n) => {
432
+ n.onMessage(r, t);
204
433
  });
205
434
  }
206
- broadcastError(n, t) {
207
- this.subscribers.forEach((r) => {
208
- r.onError(n, t);
435
+ broadcastError(r, t) {
436
+ this.subscribers.forEach((n) => {
437
+ n.onError(r, t);
209
438
  });
210
439
  }
211
440
  /**
212
441
  * Cleanup all connections and subscriptions
213
442
  */
214
443
  cleanup() {
215
- this.eventSources.forEach((n) => n.abort()), this.eventSources.clear(), this.subscribers.clear();
444
+ if (this.activeConnections.forEach((r) => r.abort()), this.activeConnections.clear(), this.worker) {
445
+ try {
446
+ this.worker.postMessage({ command: "cleanup" });
447
+ } catch {
448
+ }
449
+ this.worker = null;
450
+ }
451
+ this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null), this.workerSupported = !1, this.subscribers.clear();
216
452
  }
217
453
  }
218
- const Ae = 48e4, Re = 3e5, Z = (e) => {
219
- const n = Date.now();
220
- return e.filter((t) => n - t.createdAt < Ae);
454
+ const Ae = 48e4, Fe = 3e5, re = (e) => {
455
+ const r = Date.now();
456
+ return e.filter((t) => r - t.createdAt < Ae);
221
457
  };
222
- function Fr({ fency: e, fetchCreateStreamClientToken: n, children: t }) {
223
- const [r, a] = w(
458
+ function Lr({ fency: e, fetchCreateStreamClientToken: r, children: t }) {
459
+ const [n, i] = I(
224
460
  null
225
- ), [c, s] = w(!0), [d, u] = w(null), [y, i] = w([]), l = F(null), m = F(null);
226
- R(() => {
227
- e.then((S) => {
228
- a(S), s(!1);
229
- }).catch((S) => {
230
- u(S), s(!1);
461
+ ), [l, a] = I(!0), [c, u] = I(null), [y, s] = I([]), d = F(null), m = F(null);
462
+ A(() => {
463
+ e.then((x) => {
464
+ i(x), a(!1);
465
+ }).catch((x) => {
466
+ u(x), a(!1);
231
467
  });
232
- }, [e]), R(() => {
233
- r && !m.current && (m.current = new Me(r));
234
- }, [r]), R(() => {
468
+ }, [e]), A(() => {
469
+ n && !m.current && (m.current = new Re(n));
470
+ }, [n]), A(() => {
235
471
  m.current && m.current.updateStreams(y);
236
- }, [y]), R(() => () => {
237
- var S;
238
- (S = m.current) == null || S.cleanup();
239
- }, []), R(() => {
240
- const S = setInterval(() => {
241
- i((T) => {
242
- const k = Z(T);
243
- return k.length !== T.length ? k : T;
472
+ }, [y]), A(() => () => {
473
+ var x;
474
+ (x = m.current) == null || x.cleanup();
475
+ }, []), A(() => {
476
+ const x = setInterval(() => {
477
+ s((k) => {
478
+ const b = re(k);
479
+ return b.length !== k.length ? b : k;
244
480
  });
245
481
  }, 6e4);
246
- return () => clearInterval(S);
482
+ return () => clearInterval(x);
247
483
  }, []);
248
- const g = N(
249
- async (S = Re) => {
250
- if (l.current)
251
- return l.current;
252
- const T = Date.now(), k = y.length > 0 ? y[y.length - 1] : null;
253
- if (k && T - k.createdAt < S)
254
- return k.stream;
255
- const x = (async () => {
256
- if (!r)
484
+ const g = O(
485
+ async (x = Fe) => {
486
+ if (d.current)
487
+ return d.current;
488
+ const k = Date.now(), b = y.length > 0 ? y[y.length - 1] : null;
489
+ if (b && k - b.createdAt < x)
490
+ return b.stream;
491
+ const S = (async () => {
492
+ if (!n)
257
493
  throw new Error("Fency instance not initialized");
258
- const C = await n(), v = await se({
259
- pk: r.publishableKey,
260
- baseUrl: r.baseUrl,
261
- clientToken: (C == null ? void 0 : C.clientToken) ?? ""
494
+ const w = await r(), T = await ce({
495
+ pk: n.publishableKey,
496
+ baseUrl: n.baseUrl,
497
+ clientToken: (w == null ? void 0 : w.clientToken) ?? ""
262
498
  });
263
- if (v.type === "success") {
264
- const P = {
265
- stream: v.stream,
499
+ if (T.type === "success") {
500
+ const L = {
501
+ stream: T.stream,
266
502
  createdAt: Date.now()
267
503
  };
268
- return i((D) => {
269
- const A = [...D, P];
270
- return Z(A);
271
- }), l.current = null, v.stream;
504
+ return s((P) => {
505
+ const R = [...P, L];
506
+ return re(R);
507
+ }), d.current = null, T.stream;
272
508
  } else
273
- throw l.current = null, new Error("Failed to create stream");
509
+ throw d.current = null, new Error("Failed to create stream");
274
510
  })();
275
- return l.current = x, x;
511
+ return d.current = S, S;
276
512
  },
277
- [r, y]
513
+ [n, y]
278
514
  );
279
- if (d)
280
- return /* @__PURE__ */ p("div", { children: [
515
+ if (c)
516
+ return /* @__PURE__ */ h("div", { children: [
281
517
  "Fency error: ",
282
- d.message
518
+ c.message
283
519
  ] });
284
- if (!r)
520
+ if (!n)
285
521
  return null;
286
- const h = y.length > 0 ? y[y.length - 1] : null, f = {
287
- fency: r,
288
- loading: c,
289
- error: d,
522
+ const p = y.length > 0 ? y[y.length - 1] : null, f = {
523
+ fency: n,
524
+ loading: l,
525
+ error: c,
290
526
  activeStreams: y,
291
- latestStream: h,
527
+ latestStream: p,
292
528
  eventManager: m.current,
293
529
  getOrCreateStream: g
294
530
  };
295
- return /* @__PURE__ */ o(te.Provider, { value: f, children: t });
531
+ return /* @__PURE__ */ o(ie.Provider, { value: f, children: t });
296
532
  }
297
- function oe() {
298
- const e = ye(te);
533
+ function ae() {
534
+ const e = he(ie);
299
535
  if (e === void 0)
300
536
  throw new Error("useFencyContext must be used within a FencyProvider");
301
537
  return e;
302
538
  }
303
- const Fe = (e) => {
539
+ const Le = (e) => {
304
540
  try {
305
- const n = JSON.parse(e);
306
- return Pe(n);
307
- } catch (n) {
308
- return console.error("Error parsing message:", n), null;
541
+ const r = JSON.parse(e);
542
+ return Pe(r);
543
+ } catch (r) {
544
+ return console.error("Error parsing message:", r), null;
309
545
  }
310
- }, Pe = (e) => le(e) ? De(e) : ce(e) ? Le(e) : de(e) ? ze(e) : null, De = (e) => ({
546
+ }, Pe = (e) => de(e) ? De(e) : me(e) ? Be(e) : ue(e) ? Oe(e) : null, De = (e) => ({
311
547
  type: "STREAM_TIMEOUT",
312
548
  streamId: e.streamId,
313
549
  timestamp: e.timestamp
314
- }), Le = (e) => ({
550
+ }), Be = (e) => ({
315
551
  type: "STREAM_NOT_FOUND",
316
552
  streamId: e.streamId,
317
553
  timestamp: e.timestamp
318
- }), ze = (e) => ({
554
+ }), Oe = (e) => ({
319
555
  type: "AGENT_TASK_PROGRESS_ITEM_UPDATED",
320
556
  streamId: e.streamId,
321
557
  agentTaskId: e.agentTaskId,
@@ -323,30 +559,30 @@ const Fe = (e) => {
323
559
  timestamp: e.timestamp,
324
560
  createdAt: e.createdAt,
325
561
  data: JSON.parse(e.data)
326
- }), Ne = (e) => {
327
- const n = oe(), [t, r] = w(null), a = F(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
328
- return R(() => {
329
- if (!n.eventManager) return;
330
- const s = {
562
+ }), We = (e) => {
563
+ const r = ae(), [t, n] = I(null), i = F(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
564
+ return A(() => {
565
+ if (!r.eventManager) return;
566
+ const a = {
331
567
  onMessage: (u, y) => {
332
- var l, m, g;
333
- const i = Fe(u);
334
- if (i)
335
- switch (i.type) {
568
+ var d, m, g;
569
+ const s = Le(u);
570
+ if (s)
571
+ switch (s.type) {
336
572
  case "STREAM_TIMEOUT":
337
- (l = e == null ? void 0 : e.onStreamTimeout) == null || l.call(e, i);
573
+ (d = e == null ? void 0 : e.onStreamTimeout) == null || d.call(e, s);
338
574
  break;
339
575
  case "STREAM_NOT_FOUND":
340
- (m = e == null ? void 0 : e.onStreamNotFound) == null || m.call(e, i);
576
+ (m = e == null ? void 0 : e.onStreamNotFound) == null || m.call(e, s);
341
577
  break;
342
578
  case "AGENT_TASK_PROGRESS_ITEM_UPDATED":
343
- (g = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || g.call(e, i);
579
+ (g = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || g.call(e, s);
344
580
  break;
345
581
  }
346
582
  },
347
583
  onError: (u, y) => {
348
- var i;
349
- (i = e == null ? void 0 : e.onStreamError) == null || i.call(e, {
584
+ var s;
585
+ (s = e == null ? void 0 : e.onStreamError) == null || s.call(e, {
350
586
  streamId: u,
351
587
  error: {
352
588
  code: "UnknownError",
@@ -355,24 +591,24 @@ const Fe = (e) => {
355
591
  });
356
592
  }
357
593
  };
358
- return n.eventManager.subscribe(
359
- a.current,
360
- s
594
+ return r.eventManager.subscribe(
595
+ i.current,
596
+ a
361
597
  );
362
- }, [n.eventManager, e]), {
598
+ }, [r.eventManager, e]), {
363
599
  createStream: async () => {
364
600
  try {
365
- const s = await n.getOrCreateStream();
366
- return r(s), {
601
+ const a = await r.getOrCreateStream();
602
+ return n(a), {
367
603
  type: "success",
368
- stream: s
604
+ stream: a
369
605
  };
370
- } catch (s) {
606
+ } catch (a) {
371
607
  return {
372
608
  type: "error",
373
609
  error: {
374
610
  code: "UnknownError",
375
- message: s instanceof Error ? s.message : "Failed to create stream"
611
+ message: a instanceof Error ? a.message : "Failed to create stream"
376
612
  }
377
613
  };
378
614
  }
@@ -380,292 +616,292 @@ const Fe = (e) => {
380
616
  stream: t
381
617
  };
382
618
  }, Pr = (e) => {
383
- const n = oe(), [t, r] = w([]), a = F(/* @__PURE__ */ new Set()), c = F(/* @__PURE__ */ new Map()), s = N(
384
- (i, l) => {
385
- r((m) => {
386
- const g = [], h = m.map((f) => {
387
- var T;
388
- if (f.streamId !== i || !f.loading) return f;
389
- const S = (T = f.confirmedData) == null ? void 0 : T.taskId;
390
- return S && g.push(S), { ...f, loading: !1, error: l };
619
+ const r = ae(), [t, n] = I([]), i = F(/* @__PURE__ */ new Set()), l = F(/* @__PURE__ */ new Map()), a = O(
620
+ (s, d) => {
621
+ n((m) => {
622
+ const g = [], p = m.map((f) => {
623
+ var k;
624
+ if (f.streamId !== s || !f.loading) return f;
625
+ const x = (k = f.confirmedData) == null ? void 0 : k.taskId;
626
+ return x && g.push(x), { ...f, loading: !1, error: d };
391
627
  });
392
628
  for (const f of g) {
393
- a.current.delete(f);
394
- const S = c.current.get(f);
395
- S && (c.current.delete(f), S({ type: "error", error: l }));
629
+ i.current.delete(f);
630
+ const x = l.current.get(f);
631
+ x && (l.current.delete(f), x({ type: "error", error: d }));
396
632
  }
397
- return h;
633
+ return p;
398
634
  });
399
635
  },
400
636
  []
401
- ), { createStream: d } = Ne({
402
- onAgentTaskProgressItemUpdated: (i) => {
637
+ ), { createStream: c } = We({
638
+ onAgentTaskProgressItemUpdated: (s) => {
403
639
  var g;
404
- if (!a.current.has(i.agentTaskId)) return;
405
- const l = i.data;
406
- if (l.taskType === "StreamingChatCompletion" && l.eventType === "Completed" || l.taskType === "StructuredChatCompletion" && l.eventType === "Completed" || l.taskType === "MemoryChat" && l.eventType === "Completed" || l.taskType === "MemorySearch" && l.eventType === "Completed") {
407
- const h = l.taskType === "MemorySearch" && l.eventType === "Completed" || l.taskType === "StructuredChatCompletion" && l.eventType === "Completed";
408
- r(
409
- h ? (S) => S.map((T) => {
410
- var C;
411
- if (((C = T.confirmedData) == null ? void 0 : C.taskId) !== i.agentTaskId)
412
- return T;
413
- const x = T.progressItems.some(
414
- (v) => v.progressItemId === i.progressItemId
415
- ) ? T.progressItems.map(
416
- (v) => v.progressItemId === i.progressItemId ? i : v
417
- ) : [...T.progressItems, i];
640
+ if (!i.current.has(s.agentTaskId)) return;
641
+ const d = s.data;
642
+ if (d.taskType === "StreamingChatCompletion" && d.eventType === "Completed" || d.taskType === "StructuredChatCompletion" && d.eventType === "Completed" || d.taskType === "MemoryChat" && d.eventType === "Completed" || d.taskType === "MemorySearch" && d.eventType === "Completed") {
643
+ const p = d.taskType === "MemorySearch" && d.eventType === "Completed" || d.taskType === "StructuredChatCompletion" && d.eventType === "Completed";
644
+ n(
645
+ p ? (x) => x.map((k) => {
646
+ var w;
647
+ if (((w = k.confirmedData) == null ? void 0 : w.taskId) !== s.agentTaskId)
648
+ return k;
649
+ const S = k.progressItems.some(
650
+ (T) => T.progressItemId === s.progressItemId
651
+ ) ? k.progressItems.map(
652
+ (T) => T.progressItemId === s.progressItemId ? s : T
653
+ ) : [...k.progressItems, s];
418
654
  return {
419
- ...T,
420
- progressItems: x,
655
+ ...k,
656
+ progressItems: S,
421
657
  loading: !1
422
658
  };
423
- }) : (S) => S.map(
424
- (T) => {
425
- var k;
426
- return ((k = T.confirmedData) == null ? void 0 : k.taskId) === i.agentTaskId ? { ...T, loading: !1 } : T;
659
+ }) : (x) => x.map(
660
+ (k) => {
661
+ var b;
662
+ return ((b = k.confirmedData) == null ? void 0 : b.taskId) === s.agentTaskId ? { ...k, loading: !1 } : k;
427
663
  }
428
664
  )
429
665
  );
430
- const f = c.current.get(
431
- i.agentTaskId
666
+ const f = l.current.get(
667
+ s.agentTaskId
432
668
  );
433
- f && (c.current.delete(i.agentTaskId), f({
669
+ f && (l.current.delete(s.agentTaskId), f({
434
670
  type: "success",
435
- streamId: i.streamId,
436
- agentTaskId: i.agentTaskId,
437
- response: l
671
+ streamId: s.streamId,
672
+ agentTaskId: s.agentTaskId,
673
+ response: d
438
674
  }));
439
675
  return;
440
676
  }
441
- (g = e.onAgentTaskProgressItemUpdated) == null || g.call(e, i), r(
442
- (h) => h.map((f) => {
443
- var k;
444
- if (((k = f.confirmedData) == null ? void 0 : k.taskId) !== i.agentTaskId)
677
+ (g = e.onAgentTaskProgressItemUpdated) == null || g.call(e, s), n(
678
+ (p) => p.map((f) => {
679
+ var b;
680
+ if (((b = f.confirmedData) == null ? void 0 : b.taskId) !== s.agentTaskId)
445
681
  return f;
446
- const T = f.progressItems.some(
447
- (x) => x.progressItemId === i.progressItemId
682
+ const k = f.progressItems.some(
683
+ (S) => S.progressItemId === s.progressItemId
448
684
  ) ? f.progressItems.map(
449
- (x) => x.progressItemId === i.progressItemId ? i : x
450
- ) : [...f.progressItems, i];
451
- return { ...f, progressItems: T };
685
+ (S) => S.progressItemId === s.progressItemId ? s : S
686
+ ) : [...f.progressItems, s];
687
+ return { ...f, progressItems: k };
452
688
  })
453
689
  );
454
690
  },
455
- onStreamError: (i) => {
456
- var l;
457
- (l = e == null ? void 0 : e.onStreamError) == null || l.call(e, i), s(i.streamId, i.error);
691
+ onStreamError: (s) => {
692
+ var d;
693
+ (d = e == null ? void 0 : e.onStreamError) == null || d.call(e, s), a(s.streamId, s.error);
458
694
  },
459
- onStreamNotFound: (i) => {
460
- var l;
461
- (l = e == null ? void 0 : e.onStreamNotFound) == null || l.call(e, i), s(i.streamId, {
695
+ onStreamNotFound: (s) => {
696
+ var d;
697
+ (d = e == null ? void 0 : e.onStreamNotFound) == null || d.call(e, s), a(s.streamId, {
462
698
  code: "StreamNotFound",
463
699
  message: "Stream not found"
464
700
  });
465
701
  },
466
- onStreamTimeout: (i) => {
467
- var l;
468
- (l = e == null ? void 0 : e.onStreamTimeout) == null || l.call(e, i), s(i.streamId, {
702
+ onStreamTimeout: (s) => {
703
+ var d;
704
+ (d = e == null ? void 0 : e.onStreamTimeout) == null || d.call(e, s), a(s.streamId, {
469
705
  code: "StreamTimeout",
470
706
  message: "Stream timed out"
471
707
  });
472
708
  }
473
- }), u = N(
474
- async (i, l) => {
709
+ }), u = O(
710
+ async (s, d) => {
475
711
  var f;
476
- const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, g = (l == null ? void 0 : l.fetchCreateAgentTaskClientToken) ?? e.fetchCreateAgentTaskClientToken;
712
+ const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, g = (d == null ? void 0 : d.fetchCreateAgentTaskClientToken) ?? e.fetchCreateAgentTaskClientToken;
477
713
  if (g === void 0)
478
714
  throw new Error(
479
715
  "fetchCreateAgentTaskClientToken must be provided either in useAgentTasks props or in createAgentTask options"
480
716
  );
481
- const h = await d();
482
- if (h.type === "success") {
483
- const S = (/* @__PURE__ */ new Date()).toISOString(), T = {
717
+ const p = await c();
718
+ if (p.type === "success") {
719
+ const x = (/* @__PURE__ */ new Date()).toISOString(), k = {
484
720
  taskKey: m,
485
- streamId: h.stream.id,
486
- triggeredAt: S,
721
+ streamId: p.stream.id,
722
+ triggeredAt: x,
487
723
  confirmedData: null,
488
724
  error: null,
489
- params: i,
725
+ params: s,
490
726
  progressItems: [],
491
727
  loading: !0,
492
- loadingText: l == null ? void 0 : l.loadingText
728
+ loadingText: d == null ? void 0 : d.loadingText
493
729
  };
494
- r((k) => [...k, T]), (f = l == null ? void 0 : l.onTaskRegistered) == null || f.call(l, T);
730
+ n((b) => [...b, k]), (f = d == null ? void 0 : d.onTaskRegistered) == null || f.call(d, k);
495
731
  try {
496
- const { clientToken: k } = await g(), x = await me({
497
- pk: n.fency.publishableKey,
498
- baseUrl: n.fency.baseUrl,
499
- clientToken: k,
500
- streamToken: h.stream.token,
732
+ const { clientToken: b } = await g(), S = await ye({
733
+ pk: r.fency.publishableKey,
734
+ baseUrl: r.fency.baseUrl,
735
+ clientToken: b,
736
+ streamToken: p.stream.token,
501
737
  request: {
502
- streamingChatCompletionTask: i.type === "StreamingChatCompletion" ? {
503
- messages: i.messages,
504
- model: i.model,
505
- ...i.temperature !== void 0 ? {
506
- temperature: i.temperature
738
+ streamingChatCompletionTask: s.type === "StreamingChatCompletion" ? {
739
+ messages: s.messages,
740
+ model: s.model,
741
+ ...s.temperature !== void 0 ? {
742
+ temperature: s.temperature
507
743
  } : {},
508
- ...i.topP !== void 0 ? { topP: i.topP } : {}
744
+ ...s.topP !== void 0 ? { topP: s.topP } : {}
509
745
  } : void 0,
510
- structuredChatCompletionTask: i.type === "StructuredChatCompletion" ? {
511
- messages: i.messages,
512
- jsonSchema: i.jsonSchema,
513
- model: i.model,
514
- ...i.temperature !== void 0 ? {
515
- temperature: i.temperature
746
+ structuredChatCompletionTask: s.type === "StructuredChatCompletion" ? {
747
+ messages: s.messages,
748
+ jsonSchema: s.jsonSchema,
749
+ model: s.model,
750
+ ...s.temperature !== void 0 ? {
751
+ temperature: s.temperature
516
752
  } : {},
517
- ...i.topP !== void 0 ? { topP: i.topP } : {}
753
+ ...s.topP !== void 0 ? { topP: s.topP } : {}
518
754
  } : void 0,
519
- memoryChatTask: i.type === "MemoryChat" ? {
520
- messages: i.messages,
521
- model: i.model,
522
- language: i.language ?? "en",
523
- chunkLimit: i.chunkLimit ?? 10,
524
- memoryScanLimit: i.memoryScanLimit ?? 3
755
+ memoryChatTask: s.type === "MemoryChat" ? {
756
+ messages: s.messages,
757
+ model: s.model,
758
+ language: s.language ?? "en",
759
+ chunkLimit: s.chunkLimit ?? 10,
760
+ memoryScanLimit: s.memoryScanLimit ?? 3
525
761
  } : void 0,
526
- memorySearchTask: i.type === "MemorySearch" ? {
527
- query: i.query,
528
- model: i.model,
529
- language: i.language ?? "en",
530
- chunkLimit: i.chunkLimit ?? 10,
531
- contextExpansion: i.contextExpansion,
532
- ...i.queryExpansion != null ? {
533
- queryExpansion: i.queryExpansion
762
+ memorySearchTask: s.type === "MemorySearch" ? {
763
+ query: s.query,
764
+ model: s.model,
765
+ language: s.language ?? "en",
766
+ chunkLimit: s.chunkLimit ?? 10,
767
+ contextExpansion: s.contextExpansion,
768
+ ...s.queryExpansion != null ? {
769
+ queryExpansion: s.queryExpansion
534
770
  } : {}
535
771
  } : void 0
536
772
  }
537
773
  });
538
- if (x.type === "success" && x.agentTask)
539
- return a.current.add(
540
- x.agentTask.id
541
- ), r((C) => [
542
- ...C.filter((v) => v.taskKey !== m),
774
+ if (S.type === "success" && S.agentTask)
775
+ return i.current.add(
776
+ S.agentTask.id
777
+ ), n((w) => [
778
+ ...w.filter((T) => T.taskKey !== m),
543
779
  {
544
780
  taskKey: m,
545
- streamId: h.stream.id,
781
+ streamId: p.stream.id,
546
782
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
547
- taskId: x.agentTask.id,
548
- createdAt: x.agentTask.createdAt,
783
+ taskId: S.agentTask.id,
784
+ createdAt: S.agentTask.createdAt,
549
785
  error: null,
550
- params: i,
786
+ params: s,
551
787
  progressItems: [],
552
788
  loading: !0,
553
- loadingText: l == null ? void 0 : l.loadingText,
789
+ loadingText: d == null ? void 0 : d.loadingText,
554
790
  confirmedData: {
555
- taskId: x.agentTask.id,
556
- createdAt: x.agentTask.createdAt
791
+ taskId: S.agentTask.id,
792
+ createdAt: S.agentTask.createdAt
557
793
  }
558
794
  }
559
795
  ]), await new Promise(
560
- (C) => {
561
- c.current.set(
562
- x.agentTask.id,
563
- C
796
+ (w) => {
797
+ l.current.set(
798
+ S.agentTask.id,
799
+ w
564
800
  );
565
801
  }
566
802
  );
567
- if (x.type === "error")
568
- return r((C) => [
569
- ...C.filter((v) => v.taskKey !== m),
803
+ if (S.type === "error")
804
+ return n((w) => [
805
+ ...w.filter((T) => T.taskKey !== m),
570
806
  {
571
807
  taskKey: m,
572
808
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
573
- streamId: h.stream.id,
574
- params: i,
575
- error: x.error,
809
+ streamId: p.stream.id,
810
+ params: s,
811
+ error: S.error,
576
812
  progressItems: [],
577
813
  loading: !1,
578
- loadingText: l == null ? void 0 : l.loadingText,
814
+ loadingText: d == null ? void 0 : d.loadingText,
579
815
  confirmedData: null
580
816
  }
581
817
  ]), {
582
818
  type: "error",
583
- error: x.error
819
+ error: S.error
584
820
  };
585
821
  {
586
- const C = {
822
+ const w = {
587
823
  message: "No response received",
588
824
  code: "UnknownError"
589
825
  };
590
- return r((v) => [
591
- ...v.filter((P) => P.taskKey !== m),
826
+ return n((T) => [
827
+ ...T.filter((L) => L.taskKey !== m),
592
828
  {
593
829
  taskKey: m,
594
830
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
595
- streamId: h.stream.id,
596
- error: C,
597
- params: i,
831
+ streamId: p.stream.id,
832
+ error: w,
833
+ params: s,
598
834
  progressItems: [],
599
835
  loading: !1,
600
- loadingText: l == null ? void 0 : l.loadingText,
836
+ loadingText: d == null ? void 0 : d.loadingText,
601
837
  confirmedData: null
602
838
  }
603
839
  ]), {
604
840
  type: "error",
605
- error: C
841
+ error: w
606
842
  };
607
843
  }
608
- } catch (k) {
609
- const x = {
844
+ } catch (b) {
845
+ const S = {
610
846
  code: "UnknownError",
611
- message: k instanceof Error ? k.message : "Unknown error during agent task creation"
847
+ message: b instanceof Error ? b.message : "Unknown error during agent task creation"
612
848
  };
613
- return r((C) => [
614
- ...C.filter((v) => v.taskKey !== m),
849
+ return n((w) => [
850
+ ...w.filter((T) => T.taskKey !== m),
615
851
  {
616
852
  taskKey: m,
617
853
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
618
- streamId: h.stream.id,
619
- params: i,
620
- error: x,
854
+ streamId: p.stream.id,
855
+ params: s,
856
+ error: S,
621
857
  progressItems: [],
622
858
  loading: !1,
623
- loadingText: l == null ? void 0 : l.loadingText,
859
+ loadingText: d == null ? void 0 : d.loadingText,
624
860
  confirmedData: null
625
861
  }
626
862
  ]), {
627
863
  type: "error",
628
- error: x
864
+ error: S
629
865
  };
630
866
  }
631
867
  } else
632
- return console.error(h.error), h;
868
+ return console.error(p.error), p;
633
869
  },
634
870
  [
635
- n,
636
- d,
871
+ r,
872
+ c,
637
873
  e.fetchCreateAgentTaskClientToken,
638
- s
874
+ a
639
875
  ]
640
- ), y = z(() => {
876
+ ), y = B(() => {
641
877
  if (t.length !== 0)
642
- return [...t].sort((i, l) => new Date(l.triggeredAt).getTime() - new Date(i.triggeredAt).getTime())[0];
878
+ return [...t].sort((s, d) => new Date(d.triggeredAt).getTime() - new Date(s.triggeredAt).getTime())[0];
643
879
  }, [t]);
644
- return R(() => () => {
645
- a.current.clear(), c.current.clear();
880
+ return A(() => () => {
881
+ i.current.clear(), l.current.clear();
646
882
  }, []), {
647
883
  agentTasks: t,
648
884
  createAgentTask: u,
649
885
  latest: y
650
886
  };
651
887
  };
652
- function Oe(e) {
653
- return e.progressItems.map((n, t) => {
654
- const r = e.progressItems[t + 1], a = r != null;
655
- let c;
656
- if (r != null && r.createdAt) {
657
- const s = new Date(n.createdAt).getTime(), d = new Date(r.createdAt).getTime();
658
- c = Math.round((d - s) / 1e3);
888
+ function ze(e) {
889
+ return e.progressItems.map((r, t) => {
890
+ const n = e.progressItems[t + 1], i = n != null;
891
+ let l;
892
+ if (n != null && n.createdAt) {
893
+ const a = new Date(r.createdAt).getTime(), c = new Date(n.createdAt).getTime();
894
+ l = Math.round((c - a) / 1e3);
659
895
  }
660
896
  return {
661
- item: n,
662
- completed: a,
897
+ item: r,
898
+ completed: i,
663
899
  isLatest: t === e.progressItems.length - 1,
664
- durationSeconds: c
900
+ durationSeconds: l
665
901
  };
666
902
  });
667
903
  }
668
- const ie = {
904
+ const se = {
669
905
  'code[class*="language-"]': {
670
906
  color: "#f8f8f2",
671
907
  background: "none",
@@ -816,57 +1052,57 @@ const ie = {
816
1052
  italic: {
817
1053
  fontStyle: "italic"
818
1054
  }
819
- }, ee = ({
1055
+ }, ne = ({
820
1056
  text: e
821
1057
  }) => /* @__PURE__ */ o("div", { style: { padding: "16px" }, children: /* @__PURE__ */ o(
822
- I.div,
1058
+ C.div,
823
1059
  {
824
1060
  className: "fency-markdown-body-raw",
825
1061
  initial: { opacity: 0, y: -10 },
826
1062
  animate: { opacity: 1, y: 0 },
827
1063
  transition: { duration: 0.3, delay: 0 },
828
1064
  children: /* @__PURE__ */ o(
829
- he,
1065
+ Se,
830
1066
  {
831
- remarkPlugins: [fe],
1067
+ remarkPlugins: [xe],
832
1068
  components: {
833
- code(n) {
834
- const { children: t, className: r, node: a, ref: c, ...s } = n, d = /language-(\w+)/.exec(r || "");
835
- return d ? (
1069
+ code(r) {
1070
+ const { children: t, className: n, node: i, ref: l, ...a } = r, c = /language-(\w+)/.exec(n || "");
1071
+ return c ? (
836
1072
  // @ts-expect-error react-syntax-highlighter types incompatible with @types/react 18
837
1073
  /* @__PURE__ */ o(
838
- ne,
1074
+ oe,
839
1075
  {
840
- ...s,
1076
+ ...a,
841
1077
  PreTag: "div",
842
1078
  children: String(t).replace(/\n$/, ""),
843
- language: d[1],
844
- style: ie
1079
+ language: c[1],
1080
+ style: se
845
1081
  }
846
1082
  )
847
- ) : /* @__PURE__ */ o("code", { ...s, className: r, children: String(t) });
1083
+ ) : /* @__PURE__ */ o("code", { ...a, className: n, children: String(t) });
848
1084
  }
849
1085
  },
850
1086
  children: e
851
1087
  }
852
1088
  )
853
1089
  }
854
- ) }), Be = ({ data: e }) => {
855
- const n = JSON.stringify(
1090
+ ) }), Ne = ({ data: e }) => {
1091
+ const r = JSON.stringify(
856
1092
  JSON.parse(e.response.jsonResponse),
857
1093
  null,
858
1094
  2
859
1095
  );
860
1096
  return /* @__PURE__ */ o("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ o(
861
- I.div,
1097
+ C.div,
862
1098
  {
863
1099
  initial: { opacity: 0, y: -10 },
864
1100
  animate: { opacity: 1, y: 0 },
865
1101
  transition: { duration: 0.3, delay: 0 },
866
- children: /* @__PURE__ */ o(ne, { language: "json", style: ie, PreTag: "div", children: n })
1102
+ children: /* @__PURE__ */ o(oe, { language: "json", style: se, PreTag: "div", children: r })
867
1103
  }
868
1104
  ) });
869
- }, We = {
1105
+ }, $e = {
870
1106
  en: {
871
1107
  error: "Error",
872
1108
  streaming: "Streaming...",
@@ -990,44 +1226,44 @@ const ie = {
990
1226
  memoryChatChunkResultsInOneMemory: "i 1 minne"
991
1227
  }
992
1228
  };
993
- function $e(e) {
994
- return We[e];
1229
+ function He(e) {
1230
+ return $e[e];
995
1231
  }
996
- function b(e, n) {
997
- return Object.entries(n).reduce(
998
- (t, [r, a]) => t.replace(`{${r}}`, String(a)),
1232
+ function v(e, r) {
1233
+ return Object.entries(r).reduce(
1234
+ (t, [n, i]) => t.replace(`{${n}}`, String(i)),
999
1235
  e
1000
1236
  );
1001
1237
  }
1002
- function Q(e, n) {
1003
- const t = e.map((r) => `'${r}'`);
1004
- if (n != null && t.length >= 2) {
1005
- const r = t.pop();
1006
- return t.length > 0 ? `${t.join(", ")} ${n} ${r}` : r;
1238
+ function G(e, r) {
1239
+ const t = e.map((n) => `'${n}'`);
1240
+ if (r != null && t.length >= 2) {
1241
+ const n = t.pop();
1242
+ return t.length > 0 ? `${t.join(", ")} ${r} ${n}` : n;
1007
1243
  }
1008
1244
  return t.join(", ");
1009
1245
  }
1010
1246
  function M({
1011
1247
  text: e,
1012
- duration: n = 2,
1248
+ duration: r = 2,
1013
1249
  delay: t = 0,
1014
- repeat: r = !0,
1015
- repeatDelay: a = 0.5,
1016
- className: c,
1017
- startOnView: s = !1,
1018
- once: d = !1,
1250
+ repeat: n = !0,
1251
+ repeatDelay: i = 0.5,
1252
+ className: l,
1253
+ startOnView: a = !1,
1254
+ once: c = !1,
1019
1255
  inViewMargin: u,
1020
1256
  spread: y = 2,
1021
- color: i = "#999",
1022
- shimmerColor: l = "#000",
1257
+ color: s = "#999",
1258
+ shimmerColor: d = "#000",
1023
1259
  direction: m = "fromBottom"
1024
1260
  }) {
1025
- const g = F(null), h = ge(g, { once: d, margin: u }), f = z(() => e.length * y, [e, y]), S = !s || h, T = m === "fromBottom" ? "100% center" : "-100% center", k = m === "fromBottom" ? "0% center" : "200% center";
1261
+ const g = F(null), p = pe(g, { once: c, margin: u }), f = B(() => e.length * y, [e, y]), x = !a || p, k = m === "fromBottom" ? "100% center" : "-100% center", b = m === "fromBottom" ? "0% center" : "200% center";
1026
1262
  return /* @__PURE__ */ o(
1027
- I.span,
1263
+ C.span,
1028
1264
  {
1029
1265
  ref: g,
1030
- className: c,
1266
+ className: l,
1031
1267
  style: {
1032
1268
  position: "relative",
1033
1269
  display: "inline-block",
@@ -1038,25 +1274,25 @@ function M({
1038
1274
  WebkitTextFillColor: "transparent",
1039
1275
  backgroundRepeat: "no-repeat, padding-box",
1040
1276
  "--spread": `${f}px`,
1041
- "--base-color": i,
1042
- "--shimmer-color": l,
1277
+ "--base-color": s,
1278
+ "--shimmer-color": d,
1043
1279
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
1044
1280
  backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
1045
1281
  },
1046
1282
  initial: {
1047
- backgroundPosition: T,
1283
+ backgroundPosition: k,
1048
1284
  opacity: 0
1049
1285
  },
1050
- animate: S ? {
1051
- backgroundPosition: k,
1286
+ animate: x ? {
1287
+ backgroundPosition: b,
1052
1288
  opacity: 1
1053
1289
  } : {},
1054
1290
  transition: {
1055
1291
  backgroundPosition: {
1056
- repeat: r ? 1 / 0 : 0,
1057
- duration: n,
1292
+ repeat: n ? 1 / 0 : 0,
1293
+ duration: r,
1058
1294
  delay: t,
1059
- repeatDelay: a,
1295
+ repeatDelay: i,
1060
1296
  ease: "linear"
1061
1297
  },
1062
1298
  opacity: {
@@ -1068,20 +1304,20 @@ function M({
1068
1304
  }
1069
1305
  );
1070
1306
  }
1071
- const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1072
- const [a, c] = w(!1), d = (e.memories ?? []).map((S) => S.memoryTitle), u = d.length > 0, y = u && d.length > $, i = y && !a ? d.slice(0, $) : d, l = d.length - $, m = !y || a, g = `${r.searchingFor}'${e.queryDescription}'`, h = u ? `${r.searchingIn}${Q(
1073
- i,
1074
- m ? r.and : void 0
1075
- )}` : "", f = u ? `${g}${h}` : `${r.searchingPrefix}${e.queryDescription}`;
1076
- return /* @__PURE__ */ p("div", { style: { padding: "16px" }, children: [
1307
+ const H = 5, Ue = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1308
+ const [i, l] = I(!1), c = (e.memories ?? []).map((x) => x.memoryTitle), u = c.length > 0, y = u && c.length > H, s = y && !i ? c.slice(0, H) : c, d = c.length - H, m = !y || i, g = `${n.searchingFor}'${e.queryDescription}'`, p = u ? `${n.searchingIn}${G(
1309
+ s,
1310
+ m ? n.and : void 0
1311
+ )}` : "", f = u ? `${g}${p}` : `${n.searchingPrefix}${e.queryDescription}`;
1312
+ return /* @__PURE__ */ h("div", { style: { padding: "16px" }, children: [
1077
1313
  /* @__PURE__ */ o(
1078
- I.div,
1314
+ C.div,
1079
1315
  {
1080
1316
  style: { color: "#666" },
1081
1317
  initial: { opacity: 0, y: -10 },
1082
1318
  animate: { opacity: 1, y: 0 },
1083
1319
  transition: { duration: 0.3, delay: 0 },
1084
- children: n && !t && !y ? /* @__PURE__ */ o(
1320
+ children: r && !t && !y ? /* @__PURE__ */ o(
1085
1321
  M,
1086
1322
  {
1087
1323
  text: f,
@@ -1090,23 +1326,23 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1090
1326
  color: "#999",
1091
1327
  shimmerColor: "#000"
1092
1328
  }
1093
- ) : /* @__PURE__ */ p(E, { children: [
1094
- /* @__PURE__ */ o("span", { style: { color: "#666" }, children: u ? /* @__PURE__ */ p(E, { children: [
1095
- r.searchingFor,
1096
- /* @__PURE__ */ p("span", { style: { fontWeight: 600 }, children: [
1329
+ ) : /* @__PURE__ */ h(E, { children: [
1330
+ /* @__PURE__ */ o("span", { style: { color: "#666" }, children: u ? /* @__PURE__ */ h(E, { children: [
1331
+ n.searchingFor,
1332
+ /* @__PURE__ */ h("span", { style: { fontWeight: 600 }, children: [
1097
1333
  "'",
1098
1334
  e.queryDescription,
1099
1335
  "'"
1100
1336
  ] }),
1101
- h
1102
- ] }) : `${r.searchingPrefix}${e.queryDescription}` }),
1103
- y && !a && /* @__PURE__ */ p(E, { children: [
1337
+ p
1338
+ ] }) : `${n.searchingPrefix}${e.queryDescription}` }),
1339
+ y && !i && /* @__PURE__ */ h(E, { children: [
1104
1340
  " ",
1105
1341
  /* @__PURE__ */ o(
1106
1342
  "button",
1107
1343
  {
1108
1344
  type: "button",
1109
- onClick: () => c(!0),
1345
+ onClick: () => l(!0),
1110
1346
  style: {
1111
1347
  background: "none",
1112
1348
  border: "none",
@@ -1118,19 +1354,19 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1118
1354
  textDecoration: "underline",
1119
1355
  fontFamily: "inherit"
1120
1356
  },
1121
- children: b(r.moreMemories, {
1122
- n: l
1357
+ children: v(n.moreMemories, {
1358
+ n: d
1123
1359
  })
1124
1360
  }
1125
1361
  )
1126
1362
  ] }),
1127
- y && a && /* @__PURE__ */ p(E, { children: [
1363
+ y && i && /* @__PURE__ */ h(E, { children: [
1128
1364
  " ",
1129
1365
  /* @__PURE__ */ o(
1130
1366
  "button",
1131
1367
  {
1132
1368
  type: "button",
1133
- onClick: () => c(!1),
1369
+ onClick: () => l(!1),
1134
1370
  style: {
1135
1371
  background: "none",
1136
1372
  border: "none",
@@ -1142,7 +1378,7 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1142
1378
  textDecoration: "underline",
1143
1379
  fontFamily: "inherit"
1144
1380
  },
1145
- children: r.clickToCollapse
1381
+ children: n.clickToCollapse
1146
1382
  }
1147
1383
  )
1148
1384
  ] })
@@ -1158,18 +1394,18 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1158
1394
  marginTop: "4px",
1159
1395
  fontStyle: "italic"
1160
1396
  },
1161
- children: b(r.tookSeconds, { n: t })
1397
+ children: v(n.tookSeconds, { n: t })
1162
1398
  }
1163
1399
  )
1164
1400
  ] });
1165
- }, H = 5, _e = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1166
- const [a, c] = w(!1), s = e.titles, d = s.length > 0, u = d && s.length > H, y = u && !a ? s.slice(0, H) : s, i = s.length - H, l = !u || a, m = d ? `${r.findingMemoriesIn}${Q(
1401
+ }, U = 5, _e = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1402
+ const [i, l] = I(!1), a = e.titles, c = a.length > 0, u = c && a.length > U, y = u && !i ? a.slice(0, U) : a, s = a.length - U, d = !u || i, m = c ? `${n.findingMemoriesIn}${G(
1167
1403
  y,
1168
- l ? r.and : void 0
1169
- )}` : r.findingMemories;
1170
- return /* @__PURE__ */ p("div", { style: { padding: "16px" }, children: [
1404
+ d ? n.and : void 0
1405
+ )}` : n.findingMemories;
1406
+ return /* @__PURE__ */ h("div", { style: { padding: "16px" }, children: [
1171
1407
  /* @__PURE__ */ o(
1172
- I.div,
1408
+ C.div,
1173
1409
  {
1174
1410
  style: {
1175
1411
  color: "#666"
@@ -1177,7 +1413,7 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1177
1413
  initial: { opacity: 0, y: -10 },
1178
1414
  animate: { opacity: 1, y: 0 },
1179
1415
  transition: { duration: 0.3, delay: 0 },
1180
- children: n && !t && !u ? /* @__PURE__ */ o(
1416
+ children: r && !t && !u ? /* @__PURE__ */ o(
1181
1417
  M,
1182
1418
  {
1183
1419
  text: m,
@@ -1186,15 +1422,15 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1186
1422
  color: "#999",
1187
1423
  shimmerColor: "#000"
1188
1424
  }
1189
- ) : /* @__PURE__ */ p(E, { children: [
1425
+ ) : /* @__PURE__ */ h(E, { children: [
1190
1426
  /* @__PURE__ */ o("span", { style: { color: "#666" }, children: m }),
1191
- u && !a && /* @__PURE__ */ p(E, { children: [
1427
+ u && !i && /* @__PURE__ */ h(E, { children: [
1192
1428
  " ",
1193
1429
  /* @__PURE__ */ o(
1194
1430
  "button",
1195
1431
  {
1196
1432
  type: "button",
1197
- onClick: () => c(!0),
1433
+ onClick: () => l(!0),
1198
1434
  style: {
1199
1435
  background: "none",
1200
1436
  border: "none",
@@ -1206,19 +1442,19 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1206
1442
  textDecoration: "underline",
1207
1443
  fontFamily: "inherit"
1208
1444
  },
1209
- children: b(r.moreMemories, {
1210
- n: i
1445
+ children: v(n.moreMemories, {
1446
+ n: s
1211
1447
  })
1212
1448
  }
1213
1449
  )
1214
1450
  ] }),
1215
- u && a && /* @__PURE__ */ p(E, { children: [
1451
+ u && i && /* @__PURE__ */ h(E, { children: [
1216
1452
  " ",
1217
1453
  /* @__PURE__ */ o(
1218
1454
  "button",
1219
1455
  {
1220
1456
  type: "button",
1221
- onClick: () => c(!1),
1457
+ onClick: () => l(!1),
1222
1458
  style: {
1223
1459
  background: "none",
1224
1460
  border: "none",
@@ -1230,7 +1466,7 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1230
1466
  textDecoration: "underline",
1231
1467
  fontFamily: "inherit"
1232
1468
  },
1233
- children: r.clickToCollapse
1469
+ children: n.clickToCollapse
1234
1470
  }
1235
1471
  )
1236
1472
  ] })
@@ -1246,31 +1482,31 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1246
1482
  marginTop: "4px",
1247
1483
  fontStyle: "italic"
1248
1484
  },
1249
- children: b(r.tookSeconds, { n: t })
1485
+ children: v(n.tookSeconds, { n: t })
1250
1486
  }
1251
1487
  )
1252
1488
  ] });
1253
- }, _ = 5, Ge = ({ data: e, t: n }) => {
1254
- const [t, r] = w(!1), c = e.memories.map((g) => g.memoryTitle), s = c.length > 0, d = s && c.length > _, u = d && !t ? c.slice(0, _) : c, y = c.length - _, i = !d || t, l = c.length === 1 ? n.memoryFound : n.memoriesFoundPrefix, m = s ? `${l}${Q(
1489
+ }, _ = 5, je = ({ data: e, t: r }) => {
1490
+ const [t, n] = I(!1), l = e.memories.map((g) => g.memoryTitle), a = l.length > 0, c = a && l.length > _, u = c && !t ? l.slice(0, _) : l, y = l.length - _, s = !c || t, d = l.length === 1 ? r.memoryFound : r.memoriesFoundPrefix, m = a ? `${d}${G(
1255
1491
  u,
1256
- i ? n.and : void 0
1257
- )}` : n.memoriesFound;
1492
+ s ? r.and : void 0
1493
+ )}` : r.memoriesFound;
1258
1494
  return /* @__PURE__ */ o("div", { style: { padding: "16px" }, children: /* @__PURE__ */ o(
1259
- I.div,
1495
+ C.div,
1260
1496
  {
1261
1497
  style: { color: "#666" },
1262
1498
  initial: { opacity: 0, y: -10 },
1263
1499
  animate: { opacity: 1, y: 0 },
1264
1500
  transition: { duration: 0.3, delay: 0 },
1265
- children: /* @__PURE__ */ p(E, { children: [
1501
+ children: /* @__PURE__ */ h(E, { children: [
1266
1502
  /* @__PURE__ */ o("span", { style: { color: "#666" }, children: m }),
1267
- d && !t && /* @__PURE__ */ p(E, { children: [
1503
+ c && !t && /* @__PURE__ */ h(E, { children: [
1268
1504
  " ",
1269
1505
  /* @__PURE__ */ o(
1270
1506
  "button",
1271
1507
  {
1272
1508
  type: "button",
1273
- onClick: () => r(!0),
1509
+ onClick: () => n(!0),
1274
1510
  style: {
1275
1511
  background: "none",
1276
1512
  border: "none",
@@ -1282,19 +1518,19 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1282
1518
  textDecoration: "underline",
1283
1519
  fontFamily: "inherit"
1284
1520
  },
1285
- children: b(n.moreMemories, {
1521
+ children: v(r.moreMemories, {
1286
1522
  n: y
1287
1523
  })
1288
1524
  }
1289
1525
  )
1290
1526
  ] }),
1291
- d && t && /* @__PURE__ */ p(E, { children: [
1527
+ c && t && /* @__PURE__ */ h(E, { children: [
1292
1528
  " ",
1293
1529
  /* @__PURE__ */ o(
1294
1530
  "button",
1295
1531
  {
1296
1532
  type: "button",
1297
- onClick: () => r(!1),
1533
+ onClick: () => n(!1),
1298
1534
  style: {
1299
1535
  background: "none",
1300
1536
  border: "none",
@@ -1306,18 +1542,18 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1306
1542
  textDecoration: "underline",
1307
1543
  fontFamily: "inherit"
1308
1544
  },
1309
- children: n.clickToCollapse
1545
+ children: r.clickToCollapse
1310
1546
  }
1311
1547
  )
1312
1548
  ] })
1313
1549
  ] })
1314
1550
  }
1315
1551
  ) });
1316
- }, Ue = ({ isLatest: e = !1, durationSeconds: n, t }) => {
1317
- const r = t.addingSources;
1318
- return /* @__PURE__ */ p("div", { style: { padding: "16px" }, children: [
1552
+ }, Ge = ({ isLatest: e = !1, durationSeconds: r, t }) => {
1553
+ const n = t.addingSources;
1554
+ return /* @__PURE__ */ h("div", { style: { padding: "16px" }, children: [
1319
1555
  /* @__PURE__ */ o(
1320
- I.div,
1556
+ C.div,
1321
1557
  {
1322
1558
  style: {
1323
1559
  display: "flex",
@@ -1328,19 +1564,19 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1328
1564
  initial: { opacity: 0, y: -10 },
1329
1565
  animate: { opacity: 1, y: 0 },
1330
1566
  transition: { duration: 0.3, delay: 0 },
1331
- children: e && !n ? /* @__PURE__ */ o(
1567
+ children: e && !r ? /* @__PURE__ */ o(
1332
1568
  M,
1333
1569
  {
1334
- text: r,
1570
+ text: n,
1335
1571
  duration: 2.5,
1336
1572
  repeat: !0,
1337
1573
  color: "#999",
1338
1574
  shimmerColor: "#000"
1339
1575
  }
1340
- ) : /* @__PURE__ */ o("span", { style: { color: "#666" }, children: r })
1576
+ ) : /* @__PURE__ */ o("span", { style: { color: "#666" }, children: n })
1341
1577
  }
1342
1578
  ),
1343
- n !== void 0 && /* @__PURE__ */ o(
1579
+ r !== void 0 && /* @__PURE__ */ o(
1344
1580
  "div",
1345
1581
  {
1346
1582
  style: {
@@ -1349,28 +1585,28 @@ const $ = 5, He = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
1349
1585
  marginTop: "4px",
1350
1586
  fontStyle: "italic"
1351
1587
  },
1352
- children: b(t.tookSeconds, { n })
1588
+ children: v(t.tookSeconds, { n: r })
1353
1589
  }
1354
1590
  )
1355
1591
  ] });
1356
1592
  };
1357
- function Qe(e, n) {
1593
+ function Qe(e, r) {
1358
1594
  if (e.length === 0) return "";
1359
1595
  if (e.length === 1)
1360
- return b(n.pageSingle, { n: e[0] });
1596
+ return v(r.pageSingle, { n: e[0] });
1361
1597
  if (e.length === 2)
1362
- return b(n.pageTwo, {
1598
+ return v(r.pageTwo, {
1363
1599
  a: e[0],
1364
1600
  b: e[1]
1365
1601
  });
1366
- const t = e[e.length - 1], r = e.slice(0, -1).join(", ");
1367
- return b(n.pageMultiple, { list: r, n: t });
1602
+ const t = e[e.length - 1], n = e.slice(0, -1).join(", ");
1603
+ return v(r.pageMultiple, { list: n, n: t });
1368
1604
  }
1369
- const je = ({ data: e, onSourceClick: n, t }) => {
1370
- const [r, a] = w(null);
1371
- return /* @__PURE__ */ p("div", { style: { padding: "16px" }, children: [
1605
+ const qe = ({ data: e, onSourceClick: r, t }) => {
1606
+ const [n, i] = I(null);
1607
+ return /* @__PURE__ */ h("div", { style: { padding: "16px" }, children: [
1372
1608
  /* @__PURE__ */ o(
1373
- I.div,
1609
+ C.div,
1374
1610
  {
1375
1611
  style: {
1376
1612
  marginBottom: "10px",
@@ -1386,51 +1622,51 @@ const je = ({ data: e, onSourceClick: n, t }) => {
1386
1622
  children: t.sources
1387
1623
  }
1388
1624
  ),
1389
- /* @__PURE__ */ o("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ o("span", { style: { fontSize: "13px", color: "#888" }, children: t.noSources }) : e.sources.map((c, s) => /* @__PURE__ */ o(
1390
- qe,
1625
+ /* @__PURE__ */ o("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ o("span", { style: { fontSize: "13px", color: "#888" }, children: t.noSources }) : e.sources.map((l, a) => /* @__PURE__ */ o(
1626
+ Ke,
1391
1627
  {
1392
- source: c,
1393
- index: s,
1394
- loadingMemoryId: r,
1395
- setLoadingMemoryId: a,
1396
- onSourceClick: n,
1628
+ source: l,
1629
+ index: a,
1630
+ loadingMemoryId: n,
1631
+ setLoadingMemoryId: i,
1632
+ onSourceClick: r,
1397
1633
  t
1398
1634
  },
1399
- c.memoryId
1635
+ l.memoryId
1400
1636
  )) })
1401
1637
  ] });
1402
- }, qe = ({
1638
+ }, Ke = ({
1403
1639
  source: e,
1404
- index: n,
1640
+ index: r,
1405
1641
  loadingMemoryId: t,
1406
- setLoadingMemoryId: r,
1407
- onSourceClick: a,
1408
- t: c
1642
+ setLoadingMemoryId: n,
1643
+ onSourceClick: i,
1644
+ t: l
1409
1645
  }) => {
1410
- const [s, d] = w(!1), u = !!a, y = t === e.memoryId, i = e.pageNumbers ?? [], l = Qe(i, c);
1411
- return /* @__PURE__ */ p(
1412
- I.div,
1646
+ const [a, c] = I(!1), u = !!i, y = t === e.memoryId, s = e.pageNumbers ?? [], d = Qe(s, l);
1647
+ return /* @__PURE__ */ h(
1648
+ C.div,
1413
1649
  {
1414
1650
  "aria-busy": y,
1415
1651
  initial: { opacity: 0, scale: 0.9 },
1416
1652
  animate: { opacity: 1, scale: 1 },
1417
- transition: { duration: 0.25, delay: n * 0.05 },
1653
+ transition: { duration: 0.25, delay: r * 0.05 },
1418
1654
  onClick: u && !y ? async () => {
1419
- r(e.memoryId);
1655
+ n(e.memoryId);
1420
1656
  try {
1421
- await a({
1657
+ await i({
1422
1658
  memoryId: e.memoryId,
1423
1659
  memoryTitle: e.memoryTitle,
1424
1660
  memoryTypeId: e.memoryTypeId,
1425
1661
  memoryTypeName: e.memoryTypeName,
1426
- pageNumbers: [...i]
1662
+ pageNumbers: [...s]
1427
1663
  });
1428
1664
  } finally {
1429
- r(null);
1665
+ n(null);
1430
1666
  }
1431
1667
  } : void 0,
1432
- onMouseEnter: u && !y ? () => d(!0) : void 0,
1433
- onMouseLeave: u && !y ? () => d(!1) : void 0,
1668
+ onMouseEnter: u && !y ? () => c(!0) : void 0,
1669
+ onMouseLeave: u && !y ? () => c(!1) : void 0,
1434
1670
  style: {
1435
1671
  display: "inline-flex",
1436
1672
  flexDirection: "column",
@@ -1438,14 +1674,14 @@ const je = ({ data: e, onSourceClick: n, t }) => {
1438
1674
  padding: "8px 12px",
1439
1675
  borderRadius: "6px",
1440
1676
  border: "1px solid #e0e0e0",
1441
- backgroundColor: s ? "#f5f5f5" : "transparent",
1677
+ backgroundColor: a ? "#f5f5f5" : "transparent",
1442
1678
  cursor: u && !y ? "pointer" : y ? "wait" : "default",
1443
1679
  transition: "background-color 0.15s ease",
1444
1680
  userSelect: "none",
1445
1681
  pointerEvents: y ? "none" : void 0
1446
1682
  },
1447
1683
  children: [
1448
- /* @__PURE__ */ p(
1684
+ /* @__PURE__ */ h(
1449
1685
  "span",
1450
1686
  {
1451
1687
  style: {
@@ -1468,57 +1704,57 @@ const je = ({ data: e, onSourceClick: n, t }) => {
1468
1704
  ]
1469
1705
  }
1470
1706
  ),
1471
- l && /* @__PURE__ */ o("span", { style: { fontSize: "12px", color: "#666" }, children: l })
1707
+ d && /* @__PURE__ */ o("span", { style: { fontSize: "12px", color: "#666" }, children: d })
1472
1708
  ]
1473
1709
  }
1474
1710
  );
1475
- }, L = ({
1711
+ }, D = ({
1476
1712
  color: e = "#78b13f",
1477
- size: n = 24,
1713
+ size: r = 24,
1478
1714
  borderWidth: t = 7
1479
1715
  }) => {
1480
- const r = n * 0.5;
1716
+ const n = r * 0.5;
1481
1717
  return /* @__PURE__ */ o(
1482
1718
  "span",
1483
1719
  {
1484
1720
  style: {
1485
1721
  display: "inline-block",
1486
1722
  transform: "rotate(45deg)",
1487
- height: n,
1488
- width: r,
1723
+ height: r,
1724
+ width: n,
1489
1725
  borderBottom: `${t}px solid ${e}`,
1490
1726
  borderRight: `${t}px solid ${e}`
1491
1727
  }
1492
1728
  }
1493
1729
  );
1494
- }, j = ({
1730
+ }, Q = ({
1495
1731
  color: e = "#333",
1496
- size: n = 32,
1732
+ size: r = 32,
1497
1733
  lineWidth: t = 2
1498
1734
  }) => {
1499
- const r = n + 1, a = (n - t) / 2, c = (n - r) / 2, s = {
1735
+ const n = r + 1, i = (r - t) / 2, l = (r - n) / 2, a = {
1500
1736
  position: "absolute",
1501
- left: a,
1502
- top: c,
1737
+ left: i,
1738
+ top: l,
1503
1739
  width: t,
1504
- height: r,
1740
+ height: n,
1505
1741
  backgroundColor: e
1506
1742
  };
1507
- return /* @__PURE__ */ p(
1743
+ return /* @__PURE__ */ h(
1508
1744
  "span",
1509
1745
  {
1510
1746
  style: {
1511
1747
  position: "relative",
1512
1748
  display: "inline-block",
1513
- width: n,
1514
- height: n
1749
+ width: r,
1750
+ height: r
1515
1751
  },
1516
1752
  children: [
1517
1753
  /* @__PURE__ */ o(
1518
1754
  "span",
1519
1755
  {
1520
1756
  style: {
1521
- ...s,
1757
+ ...a,
1522
1758
  transform: "rotate(45deg)"
1523
1759
  }
1524
1760
  }
@@ -1527,7 +1763,7 @@ const je = ({ data: e, onSourceClick: n, t }) => {
1527
1763
  "span",
1528
1764
  {
1529
1765
  style: {
1530
- ...s,
1766
+ ...a,
1531
1767
  transform: "rotate(-45deg)"
1532
1768
  }
1533
1769
  }
@@ -1536,26 +1772,26 @@ const je = ({ data: e, onSourceClick: n, t }) => {
1536
1772
  }
1537
1773
  );
1538
1774
  };
1539
- function Ke({
1775
+ function Ve({
1540
1776
  memory: e,
1541
- completed: n
1777
+ completed: r
1542
1778
  }) {
1543
- return e.error != null ? /* @__PURE__ */ o(j, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : n ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
1779
+ return e.error != null ? /* @__PURE__ */ o(Q, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ o(D, { color: "#999", size: 15, borderWidth: 2 }) : r ? /* @__PURE__ */ o(D, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
1544
1780
  }
1545
- const re = 80;
1546
- function Ve({
1781
+ const te = 80;
1782
+ function Xe({
1547
1783
  memory: e,
1548
- completed: n,
1784
+ completed: r,
1549
1785
  t
1550
1786
  }) {
1551
- const [r, a] = w(!1), c = e.result ?? e.error, s = c != null && c.length > re, d = c != null ? r || !s ? c : `${c.slice(0, re)}...` : void 0, u = s, y = e.error != null;
1552
- return /* @__PURE__ */ p(
1553
- I.div,
1787
+ const [n, i] = I(!1), l = e.result ?? e.error, a = l != null && l.length > te, c = l != null ? n || !a ? l : `${l.slice(0, te)}...` : void 0, u = a, y = e.error != null;
1788
+ return /* @__PURE__ */ h(
1789
+ C.div,
1554
1790
  {
1555
1791
  initial: { opacity: 0 },
1556
1792
  animate: { opacity: 1 },
1557
1793
  transition: { duration: 0.25 },
1558
- onClick: u ? () => a((i) => !i) : void 0,
1794
+ onClick: u ? () => i((s) => !s) : void 0,
1559
1795
  style: {
1560
1796
  paddingTop: "12px",
1561
1797
  paddingBottom: "12px",
@@ -1578,10 +1814,10 @@ function Ve({
1578
1814
  flexShrink: 0,
1579
1815
  width: 32
1580
1816
  },
1581
- children: /* @__PURE__ */ o(Ke, { memory: e, completed: n })
1817
+ children: /* @__PURE__ */ o(Ve, { memory: e, completed: r })
1582
1818
  }
1583
1819
  ),
1584
- /* @__PURE__ */ p(
1820
+ /* @__PURE__ */ h(
1585
1821
  "div",
1586
1822
  {
1587
1823
  style: {
@@ -1598,16 +1834,16 @@ function Ve({
1598
1834
  children: e.memoryTitle
1599
1835
  }
1600
1836
  ),
1601
- d != null && /* @__PURE__ */ o(
1837
+ c != null && /* @__PURE__ */ o(
1602
1838
  "span",
1603
1839
  {
1604
1840
  style: {
1605
1841
  fontSize: 12,
1606
1842
  color: y ? "#c62828" : "#666",
1607
1843
  lineHeight: 1.4,
1608
- whiteSpace: r ? "pre-wrap" : void 0
1844
+ whiteSpace: n ? "pre-wrap" : void 0
1609
1845
  },
1610
- children: d
1846
+ children: c
1611
1847
  }
1612
1848
  ),
1613
1849
  u && /* @__PURE__ */ o(
@@ -1618,7 +1854,7 @@ function Ve({
1618
1854
  color: "#999",
1619
1855
  marginTop: 2
1620
1856
  },
1621
- children: r ? t.clickToCollapse : t.clickToExpand
1857
+ children: n ? t.clickToCollapse : t.clickToExpand
1622
1858
  }
1623
1859
  )
1624
1860
  ]
@@ -1628,102 +1864,102 @@ function Ve({
1628
1864
  }
1629
1865
  );
1630
1866
  }
1631
- const Xe = ({ data: e, completed: n, t }) => /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: e.memories.map((r) => /* @__PURE__ */ o(
1632
- Ve,
1867
+ const Je = ({ data: e, completed: r, t }) => /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: e.memories.map((n) => /* @__PURE__ */ o(
1868
+ Xe,
1633
1869
  {
1634
- memory: r,
1635
- completed: n,
1870
+ memory: n,
1871
+ completed: r,
1636
1872
  t
1637
1873
  },
1638
- r.memoryId
1874
+ n.memoryId
1639
1875
  )) });
1640
- function Je(e, n) {
1641
- const t = Math.min(e.length, n.length);
1642
- for (let r = t; r >= 0; r--)
1643
- if (e.slice(-r) === n.slice(0, r)) return r;
1876
+ function Ye(e, r) {
1877
+ const t = Math.min(e.length, r.length);
1878
+ for (let n = t; n >= 0; n--)
1879
+ if (e.slice(-n) === r.slice(0, n)) return n;
1644
1880
  return 0;
1645
1881
  }
1646
- const Ye = `
1882
+ const Ze = `
1647
1883
 
1648
1884
  `;
1649
1885
  function q(e) {
1650
- var t, r;
1886
+ var t, n;
1651
1887
  if (e.length === 0) return "";
1652
- let n = ((t = e[0]) == null ? void 0 : t.content) ?? "";
1653
- for (let a = 1; a < e.length; a++) {
1654
- const c = ((r = e[a]) == null ? void 0 : r.content) ?? "";
1655
- if (c === "") continue;
1656
- if (n === "") {
1657
- n = c;
1888
+ let r = ((t = e[0]) == null ? void 0 : t.content) ?? "";
1889
+ for (let i = 1; i < e.length; i++) {
1890
+ const l = ((n = e[i]) == null ? void 0 : n.content) ?? "";
1891
+ if (l === "") continue;
1892
+ if (r === "") {
1893
+ r = l;
1658
1894
  continue;
1659
1895
  }
1660
- const s = Je(n, c);
1661
- s === 0 ? n += Ye + c : n += c.slice(s);
1896
+ const a = Ye(r, l);
1897
+ a === 0 ? r += Ze + l : r += l.slice(a);
1662
1898
  }
1663
- return n;
1899
+ return r;
1664
1900
  }
1665
- function K(e, n) {
1901
+ function K(e, r) {
1666
1902
  if (e.length === 0) return "";
1667
1903
  if (e.length === 1)
1668
- return b(n.memorySearchPagesSingle, {
1904
+ return v(r.memorySearchPagesSingle, {
1669
1905
  n: e[0]
1670
1906
  });
1671
1907
  if (e.length === 2)
1672
- return b(n.memorySearchPagesTwo, {
1908
+ return v(r.memorySearchPagesTwo, {
1673
1909
  a: e[0],
1674
1910
  b: e[1]
1675
1911
  });
1676
- const t = e[e.length - 1], r = e.slice(0, -1).join(", ");
1677
- return b(n.memorySearchPagesMultiple, {
1678
- list: r,
1912
+ const t = e[e.length - 1], n = e.slice(0, -1).join(", ");
1913
+ return v(r.memorySearchPagesMultiple, {
1914
+ list: n,
1679
1915
  n: t
1680
1916
  });
1681
1917
  }
1682
1918
  function V(e) {
1683
- const n = /* @__PURE__ */ new Set();
1919
+ const r = /* @__PURE__ */ new Set();
1684
1920
  for (const t of e)
1685
- for (const r of t.pageNumbers) n.add(r);
1686
- return [...n].sort((t, r) => t - r);
1921
+ for (const n of t.pageNumbers) r.add(n);
1922
+ return [...r].sort((t, n) => t - n);
1687
1923
  }
1688
1924
  function X(e) {
1689
- const n = e.memoryTypeName.trim();
1690
- if (n !== "") return n;
1925
+ const r = e.memoryTypeName.trim();
1926
+ if (r !== "") return r;
1691
1927
  if (e.memoryTypeId !== "") return e.memoryTypeId;
1692
1928
  }
1693
- function ae(e) {
1694
- return e.chunks.filter((n) => n.relation === "MATCH").length;
1929
+ function le(e) {
1930
+ return e.chunks.filter((r) => r.relation === "MATCH").length;
1695
1931
  }
1696
- function Ze(e, n) {
1697
- let t = 0, r = 0;
1698
- for (const s of e)
1699
- t += ae(s), s.matchingChunkScore > r && (r = s.matchingChunkScore);
1700
- const a = t === 1 ? n.chunkFound : b(n.chunksFound, { n: t }), c = b(n.scoreLabel, {
1701
- n: r.toFixed(2)
1932
+ function er(e, r) {
1933
+ let t = 0, n = 0;
1934
+ for (const a of e)
1935
+ t += le(a), a.matchingChunkScore > n && (n = a.matchingChunkScore);
1936
+ const i = t === 1 ? r.chunkFound : v(r.chunksFound, { n: t }), l = v(r.scoreLabel, {
1937
+ n: n.toFixed(2)
1702
1938
  });
1703
- return `${a} - ${c}`;
1939
+ return `${i} - ${l}`;
1704
1940
  }
1705
- function er(e) {
1706
- const n = [], t = /* @__PURE__ */ new Map();
1707
- return e.forEach((r, a) => {
1708
- let c = t.get(r.memoryId);
1709
- if (c == null) {
1710
- n.push(r.memoryId);
1711
- const s = r.memoryTitle !== "" ? r.memoryTitle : r.memoryId;
1712
- c = {
1713
- memoryId: r.memoryId,
1714
- memoryTitle: s,
1941
+ function rr(e) {
1942
+ const r = [], t = /* @__PURE__ */ new Map();
1943
+ return e.forEach((n, i) => {
1944
+ let l = t.get(n.memoryId);
1945
+ if (l == null) {
1946
+ r.push(n.memoryId);
1947
+ const a = n.memoryTitle !== "" ? n.memoryTitle : n.memoryId;
1948
+ l = {
1949
+ memoryId: n.memoryId,
1950
+ memoryTitle: a,
1715
1951
  items: []
1716
- }, t.set(r.memoryId, c);
1952
+ }, t.set(n.memoryId, l);
1717
1953
  }
1718
- c.items.push({ item: r, flatIndex: a });
1719
- }), n.map((r) => t.get(r));
1954
+ l.items.push({ item: n, flatIndex: i });
1955
+ }), r.map((n) => t.get(n));
1720
1956
  }
1721
- function rr({
1957
+ function nr({
1722
1958
  items: e,
1723
- onSearchResultClick: n,
1959
+ onSearchResultClick: r,
1724
1960
  t
1725
1961
  }) {
1726
- const [r, a] = w(null), c = !!n;
1962
+ const [n, i] = I(null), l = !!r;
1727
1963
  return /* @__PURE__ */ o(
1728
1964
  "div",
1729
1965
  {
@@ -1735,25 +1971,25 @@ function rr({
1735
1971
  paddingTop: 8,
1736
1972
  borderTop: "1px solid #f0f0f0"
1737
1973
  },
1738
- children: e.map((s, d) => {
1974
+ children: e.map((a, c) => {
1739
1975
  const u = V(
1740
- s.chunks
1976
+ a.chunks
1741
1977
  ), y = [
1742
- X(s),
1743
- b(t.scoreLabel, {
1744
- n: s.matchingChunkScore.toFixed(2)
1978
+ X(a),
1979
+ v(t.scoreLabel, {
1980
+ n: a.matchingChunkScore.toFixed(2)
1745
1981
  }),
1746
1982
  u.length > 0 ? K(u, t) : t.pagesNotAvailable
1747
1983
  ].filter(
1748
1984
  (g) => g != null && g !== ""
1749
- ), i = {
1750
- memoryId: s.memoryId,
1751
- memoryTitle: s.memoryTitle,
1752
- memoryTypeId: s.memoryTypeId,
1753
- memoryTypeName: s.memoryTypeName,
1985
+ ), s = {
1986
+ memoryId: a.memoryId,
1987
+ memoryTitle: a.memoryTitle,
1988
+ memoryTypeId: a.memoryTypeId,
1989
+ memoryTypeName: a.memoryTypeName,
1754
1990
  pageNumbers: u
1755
- }, l = `${s.memoryId}-${d}`, m = r === l;
1756
- return /* @__PURE__ */ p(
1991
+ }, d = `${a.memoryId}-${c}`, m = n === d;
1992
+ return /* @__PURE__ */ h(
1757
1993
  "div",
1758
1994
  {
1759
1995
  style: {
@@ -1761,13 +1997,13 @@ function rr({
1761
1997
  flexDirection: "row",
1762
1998
  alignItems: "flex-start",
1763
1999
  gap: "12px",
1764
- paddingTop: d > 0 ? 12 : 0,
1765
- paddingBottom: d < e.length - 1 ? 12 : 0,
1766
- borderBottom: d < e.length - 1 ? "1px solid #eee" : void 0,
2000
+ paddingTop: c > 0 ? 12 : 0,
2001
+ paddingBottom: c < e.length - 1 ? 12 : 0,
2002
+ borderBottom: c < e.length - 1 ? "1px solid #eee" : void 0,
1767
2003
  minWidth: 0
1768
2004
  },
1769
2005
  children: [
1770
- /* @__PURE__ */ p(
2006
+ /* @__PURE__ */ h(
1771
2007
  "div",
1772
2008
  {
1773
2009
  style: {
@@ -1788,7 +2024,7 @@ function rr({
1788
2024
  whiteSpace: "pre-wrap",
1789
2025
  wordBreak: "break-word"
1790
2026
  },
1791
- children: q(s.chunks)
2027
+ children: q(a.chunks)
1792
2028
  }
1793
2029
  ),
1794
2030
  /* @__PURE__ */ o(
@@ -1806,20 +2042,20 @@ function rr({
1806
2042
  ]
1807
2043
  }
1808
2044
  ),
1809
- c && /* @__PURE__ */ p(
2045
+ l && /* @__PURE__ */ h(
1810
2046
  "button",
1811
2047
  {
1812
2048
  type: "button",
1813
2049
  "aria-busy": m,
1814
2050
  disabled: m,
1815
2051
  onClick: async () => {
1816
- a(l);
2052
+ i(d);
1817
2053
  try {
1818
- await n(
1819
- i
2054
+ await r(
2055
+ s
1820
2056
  );
1821
2057
  } finally {
1822
- a(null);
2058
+ i(null);
1823
2059
  }
1824
2060
  },
1825
2061
  style: {
@@ -1852,22 +2088,22 @@ function rr({
1852
2088
  )
1853
2089
  ]
1854
2090
  },
1855
- l
2091
+ d
1856
2092
  );
1857
2093
  })
1858
2094
  }
1859
2095
  );
1860
2096
  }
1861
- function nr({
2097
+ function tr({
1862
2098
  group: e,
1863
- t: n,
2099
+ t: r,
1864
2100
  expanded: t,
1865
- onToggle: r,
1866
- onSearchResultClick: a
2101
+ onToggle: n,
2102
+ onSearchResultClick: i
1867
2103
  }) {
1868
- const c = e.items.map((d) => d.item), s = c.some((d) => d.chunks.length > 0);
1869
- return /* @__PURE__ */ p(
1870
- I.div,
2104
+ const l = e.items.map((c) => c.item), a = l.some((c) => c.chunks.length > 0);
2105
+ return /* @__PURE__ */ h(
2106
+ C.div,
1871
2107
  {
1872
2108
  initial: { opacity: 0 },
1873
2109
  animate: { opacity: 1 },
@@ -1894,10 +2130,10 @@ function nr({
1894
2130
  width: 32,
1895
2131
  paddingTop: 2
1896
2132
  },
1897
- children: /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 })
2133
+ children: /* @__PURE__ */ o(D, { color: "#999", size: 15, borderWidth: 2 })
1898
2134
  }
1899
2135
  ),
1900
- /* @__PURE__ */ p(
2136
+ /* @__PURE__ */ h(
1901
2137
  "div",
1902
2138
  {
1903
2139
  style: {
@@ -1920,7 +2156,7 @@ function nr({
1920
2156
  children: e.memoryTitle
1921
2157
  }
1922
2158
  ),
1923
- /* @__PURE__ */ p(
2159
+ /* @__PURE__ */ h(
1924
2160
  "div",
1925
2161
  {
1926
2162
  style: {
@@ -1940,14 +2176,14 @@ function nr({
1940
2176
  color: "#666",
1941
2177
  whiteSpace: "nowrap"
1942
2178
  },
1943
- children: Ze(c, n)
2179
+ children: er(l, r)
1944
2180
  }
1945
2181
  ),
1946
- s && /* @__PURE__ */ o(
2182
+ a && /* @__PURE__ */ o(
1947
2183
  "button",
1948
2184
  {
1949
2185
  type: "button",
1950
- onClick: r,
2186
+ onClick: n,
1951
2187
  style: {
1952
2188
  border: "none",
1953
2189
  background: "none",
@@ -1958,18 +2194,18 @@ function nr({
1958
2194
  textDecoration: "underline",
1959
2195
  fontFamily: "inherit"
1960
2196
  },
1961
- children: t ? n.memorySearchHideExploreResults : n.memorySearchViewExploreResults
2197
+ children: t ? r.memorySearchHideExploreResults : r.memorySearchViewExploreResults
1962
2198
  }
1963
2199
  )
1964
2200
  ]
1965
2201
  }
1966
2202
  ),
1967
- t && s && /* @__PURE__ */ o(
1968
- rr,
2203
+ t && a && /* @__PURE__ */ o(
2204
+ nr,
1969
2205
  {
1970
- items: c,
1971
- onSearchResultClick: a,
1972
- t: n
2206
+ items: l,
2207
+ onSearchResultClick: i,
2208
+ t: r
1973
2209
  }
1974
2210
  )
1975
2211
  ]
@@ -1979,26 +2215,26 @@ function nr({
1979
2215
  }
1980
2216
  );
1981
2217
  }
1982
- function tr(e, n) {
1983
- return e === 1 ? n.chunkFound : b(n.chunksFound, { n: e });
2218
+ function or(e, r) {
2219
+ return e === 1 ? r.chunkFound : v(r.chunksFound, { n: e });
1984
2220
  }
1985
- const or = ({
2221
+ const ir = ({
1986
2222
  data: e,
1987
- onSearchResultClick: n,
2223
+ onSearchResultClick: r,
1988
2224
  t
1989
2225
  }) => {
1990
- const r = e.items, a = r.reduce(
1991
- (m, g) => m + ae(g),
2226
+ const n = e.items, i = n.reduce(
2227
+ (m, g) => m + le(g),
1992
2228
  0
1993
- ), c = new Set(r.map((m) => m.memoryId)).size, [s, d] = w({}), u = N((m) => {
1994
- d((g) => ({
2229
+ ), l = new Set(n.map((m) => m.memoryId)).size, [a, c] = I({}), u = O((m) => {
2230
+ c((g) => ({
1995
2231
  ...g,
1996
2232
  [m]: !g[m]
1997
2233
  }));
1998
- }, []), y = z(() => er(r), [r]), i = c === 1 ? t.memoryChatChunkResultsInOneMemory : b(t.memoryChatChunkResultsInMemories, {
1999
- n: c
2000
- }), l = `${tr(a, t)} ${i}`;
2001
- return r.length === 0 ? /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: /* @__PURE__ */ o(
2234
+ }, []), y = B(() => rr(n), [n]), s = l === 1 ? t.memoryChatChunkResultsInOneMemory : v(t.memoryChatChunkResultsInMemories, {
2235
+ n: l
2236
+ }), d = `${or(i, t)} ${s}`;
2237
+ return n.length === 0 ? /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: /* @__PURE__ */ o(
2002
2238
  "div",
2003
2239
  {
2004
2240
  style: {
@@ -2008,15 +2244,15 @@ const or = ({
2008
2244
  },
2009
2245
  children: t.memorySearchExploreNoResults
2010
2246
  }
2011
- ) }) : /* @__PURE__ */ p("div", { style: { padding: "10px" }, children: [
2247
+ ) }) : /* @__PURE__ */ h("div", { style: { padding: "10px" }, children: [
2012
2248
  y.map((m) => /* @__PURE__ */ o(
2013
- nr,
2249
+ tr,
2014
2250
  {
2015
2251
  group: m,
2016
2252
  t,
2017
- expanded: s[m.memoryId] === !0,
2253
+ expanded: a[m.memoryId] === !0,
2018
2254
  onToggle: () => u(m.memoryId),
2019
- onSearchResultClick: n
2255
+ onSearchResultClick: r
2020
2256
  },
2021
2257
  m.memoryId
2022
2258
  )),
@@ -2029,27 +2265,27 @@ const or = ({
2029
2265
  marginTop: "4px",
2030
2266
  fontStyle: "italic"
2031
2267
  },
2032
- children: l
2268
+ children: d
2033
2269
  }
2034
2270
  )
2035
2271
  ] });
2036
2272
  };
2037
- function ir({ item: e }) {
2038
- return e.error != null ? /* @__PURE__ */ o(j, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
2273
+ function ar({ item: e }) {
2274
+ return e.error != null ? /* @__PURE__ */ o(Q, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ o(D, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
2039
2275
  }
2040
- function ar(e, n) {
2041
- return b(n.searchingInMemoriesOfType, {
2276
+ function sr(e, r) {
2277
+ return v(r.searchingInMemoriesOfType, {
2042
2278
  name: e.memoryTypeName
2043
2279
  });
2044
2280
  }
2045
- function sr({
2281
+ function lr({
2046
2282
  item: e,
2047
- t: n,
2283
+ t: r,
2048
2284
  showShimmerForPrimary: t
2049
2285
  }) {
2050
- const r = e.result != null, a = e.error != null, c = ar(e, n);
2051
- return /* @__PURE__ */ p(
2052
- I.div,
2286
+ const n = e.result != null, i = e.error != null, l = sr(e, r);
2287
+ return /* @__PURE__ */ h(
2288
+ C.div,
2053
2289
  {
2054
2290
  initial: { opacity: 0 },
2055
2291
  animate: { opacity: 1 },
@@ -2075,10 +2311,10 @@ function sr({
2075
2311
  flexShrink: 0,
2076
2312
  width: 32
2077
2313
  },
2078
- children: /* @__PURE__ */ o(ir, { item: e })
2314
+ children: /* @__PURE__ */ o(ar, { item: e })
2079
2315
  }
2080
2316
  ),
2081
- /* @__PURE__ */ p(
2317
+ /* @__PURE__ */ h(
2082
2318
  "div",
2083
2319
  {
2084
2320
  style: {
@@ -2089,25 +2325,25 @@ function sr({
2089
2325
  flex: 1
2090
2326
  },
2091
2327
  children: [
2092
- /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: !r && !a && t ? /* @__PURE__ */ o(
2328
+ /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: !n && !i && t ? /* @__PURE__ */ o(
2093
2329
  M,
2094
2330
  {
2095
- text: c,
2331
+ text: l,
2096
2332
  duration: 2.5,
2097
2333
  repeat: !0,
2098
2334
  color: "#999",
2099
2335
  shimmerColor: "#000"
2100
2336
  }
2101
- ) : c }),
2102
- r && /* @__PURE__ */ o("span", { style: { fontSize: 12, color: "#666" }, children: e.result.numberOfChunks === 1 ? b(
2103
- n.memorySearchTypeResultSummaryOne,
2337
+ ) : l }),
2338
+ n && /* @__PURE__ */ o("span", { style: { fontSize: 12, color: "#666" }, children: e.result.numberOfChunks === 1 ? v(
2339
+ r.memorySearchTypeResultSummaryOne,
2104
2340
  {
2105
2341
  score: e.result.highestChunkScore.toFixed(
2106
2342
  2
2107
2343
  )
2108
2344
  }
2109
- ) : b(
2110
- n.memorySearchTypeResultSummary,
2345
+ ) : v(
2346
+ r.memorySearchTypeResultSummary,
2111
2347
  {
2112
2348
  count: e.result.numberOfChunks,
2113
2349
  score: e.result.highestChunkScore.toFixed(
@@ -2115,7 +2351,7 @@ function sr({
2115
2351
  )
2116
2352
  }
2117
2353
  ) }),
2118
- a && /* @__PURE__ */ o("span", { style: { fontSize: 12, color: "#c62828" }, children: e.error })
2354
+ i && /* @__PURE__ */ o("span", { style: { fontSize: 12, color: "#c62828" }, children: e.error })
2119
2355
  ]
2120
2356
  }
2121
2357
  )
@@ -2123,31 +2359,31 @@ function sr({
2123
2359
  }
2124
2360
  );
2125
2361
  }
2126
- const lr = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
2127
- const a = z(() => {
2128
- let c = -1;
2129
- return e.memoryTypes.forEach((s, d) => {
2130
- s.result == null && s.error == null && (c = d);
2131
- }), c;
2362
+ const cr = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
2363
+ const i = B(() => {
2364
+ let l = -1;
2365
+ return e.memoryTypes.forEach((a, c) => {
2366
+ a.result == null && a.error == null && (l = c);
2367
+ }), l;
2132
2368
  }, [e.memoryTypes]);
2133
- return /* @__PURE__ */ p("div", { style: { padding: "10px" }, children: [
2134
- n && !t && e.memoryTypes.length === 0 ? /* @__PURE__ */ o(
2369
+ return /* @__PURE__ */ h("div", { style: { padding: "10px" }, children: [
2370
+ r && !t && e.memoryTypes.length === 0 ? /* @__PURE__ */ o(
2135
2371
  M,
2136
2372
  {
2137
- text: r.searchingMemoryTypes,
2373
+ text: n.searchingMemoryTypes,
2138
2374
  duration: 2.5,
2139
2375
  repeat: !0,
2140
2376
  color: "#999",
2141
2377
  shimmerColor: "#000"
2142
2378
  }
2143
- ) : e.memoryTypes.map((c, s) => /* @__PURE__ */ o(
2144
- sr,
2379
+ ) : e.memoryTypes.map((l, a) => /* @__PURE__ */ o(
2380
+ lr,
2145
2381
  {
2146
- item: c,
2147
- t: r,
2148
- showShimmerForPrimary: s === a && n
2382
+ item: l,
2383
+ t: n,
2384
+ showShimmerForPrimary: a === i && r
2149
2385
  },
2150
- c.memoryTypeId
2386
+ l.memoryTypeId
2151
2387
  )),
2152
2388
  t !== void 0 && /* @__PURE__ */ o(
2153
2389
  "div",
@@ -2158,45 +2394,45 @@ const lr = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
2158
2394
  marginTop: "4px",
2159
2395
  fontStyle: "italic"
2160
2396
  },
2161
- children: b(r.tookSeconds, { n: t })
2397
+ children: v(n.tookSeconds, { n: t })
2162
2398
  }
2163
2399
  )
2164
2400
  ] });
2165
- }, B = 12, W = 1.45, cr = Math.ceil(
2166
- B * W
2167
- ), dr = Math.ceil(
2168
- 5 * B * W
2401
+ }, N = 12, $ = 1.45, dr = Math.ceil(
2402
+ N * $
2403
+ ), mr = Math.ceil(
2404
+ 5 * N * $
2169
2405
  );
2170
- function O(e) {
2406
+ function W(e) {
2171
2407
  return e.queries != null && e.queries.length > 0;
2172
2408
  }
2173
- function mr(e) {
2174
- const n = e.reasoning;
2175
- return (n == null || n === "") && !O(e);
2176
- }
2177
2409
  function ur(e) {
2178
- if (O(e)) return 3;
2179
- const n = e.reasoning;
2180
- return n == null || n === "" ? 1 : e.reasoningCompleted === !0 ? 2 : 1;
2410
+ const r = e.reasoning;
2411
+ return (r == null || r === "") && !W(e);
2181
2412
  }
2182
- function yr({ phase: e }) {
2183
- return e === 3 ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
2413
+ function yr(e) {
2414
+ if (W(e)) return 3;
2415
+ const r = e.reasoning;
2416
+ return r == null || r === "" ? 1 : e.reasoningCompleted === !0 ? 2 : 1;
2184
2417
  }
2185
- function gr({
2418
+ function gr({ phase: e }) {
2419
+ return e === 3 ? /* @__PURE__ */ o(D, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
2420
+ }
2421
+ function hr({
2186
2422
  item: e,
2187
- t: n,
2423
+ t: r,
2188
2424
  isActiveRow: t
2189
2425
  }) {
2190
- const r = mr(e), a = ur(e), c = e.reasoning, s = c != null && c.length > 0, d = F(null), [u, y] = w(!1), i = r && t, l = a === 2 && t && !O(e);
2191
- R(() => {
2192
- const h = d.current;
2193
- h != null && a === 1 && s && (h.scrollTop = h.scrollHeight);
2194
- }, [c, a, s]);
2195
- const m = b(n.searchingInMemoriesOfType, {
2426
+ const n = ur(e), i = yr(e), l = e.reasoning, a = l != null && l.length > 0, c = F(null), [u, y] = I(!1), s = n && t, d = i === 2 && t && !W(e);
2427
+ A(() => {
2428
+ const p = c.current;
2429
+ p != null && i === 1 && a && (p.scrollTop = p.scrollHeight);
2430
+ }, [l, i, a]);
2431
+ const m = v(r.searchingInMemoriesOfType, {
2196
2432
  name: e.memoryTypeName
2197
- }), g = !r && a === 3;
2198
- return /* @__PURE__ */ p(
2199
- I.div,
2433
+ }), g = !n && i === 3;
2434
+ return /* @__PURE__ */ h(
2435
+ C.div,
2200
2436
  {
2201
2437
  initial: { opacity: 0 },
2202
2438
  animate: { opacity: 1 },
@@ -2223,10 +2459,10 @@ function gr({
2223
2459
  width: 32,
2224
2460
  ...g ? { paddingTop: 2 } : {}
2225
2461
  },
2226
- children: /* @__PURE__ */ o(yr, { phase: r ? 1 : a })
2462
+ children: /* @__PURE__ */ o(gr, { phase: n ? 1 : i })
2227
2463
  }
2228
2464
  ),
2229
- /* @__PURE__ */ p(
2465
+ /* @__PURE__ */ h(
2230
2466
  "div",
2231
2467
  {
2232
2468
  style: {
@@ -2237,7 +2473,7 @@ function gr({
2237
2473
  flex: 1
2238
2474
  },
2239
2475
  children: [
2240
- /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: i ? /* @__PURE__ */ o(
2476
+ /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: s ? /* @__PURE__ */ o(
2241
2477
  M,
2242
2478
  {
2243
2479
  text: m,
@@ -2247,7 +2483,7 @@ function gr({
2247
2483
  shimmerColor: "#000"
2248
2484
  }
2249
2485
  ) : e.memoryTypeName }),
2250
- a === 1 && s && !O(e) && /* @__PURE__ */ p("div", { style: { minWidth: 0 }, children: [
2486
+ i === 1 && a && !W(e) && /* @__PURE__ */ h("div", { style: { minWidth: 0 }, children: [
2251
2487
  /* @__PURE__ */ o(
2252
2488
  "span",
2253
2489
  {
@@ -2258,7 +2494,7 @@ function gr({
2258
2494
  marginBottom: 4,
2259
2495
  fontWeight: 500
2260
2496
  },
2261
- children: n.memorySearchQueryReasoningLabel
2497
+ children: r.memorySearchQueryReasoningLabel
2262
2498
  }
2263
2499
  ),
2264
2500
  /* @__PURE__ */ o(
@@ -2273,38 +2509,38 @@ function gr({
2273
2509
  children: /* @__PURE__ */ o(
2274
2510
  "div",
2275
2511
  {
2276
- ref: d,
2512
+ ref: c,
2277
2513
  className: "memory-search-generating-reasoning-viewport",
2278
2514
  style: {
2279
- minHeight: cr,
2280
- maxHeight: dr,
2515
+ minHeight: dr,
2516
+ maxHeight: mr,
2281
2517
  height: "auto",
2282
2518
  overflowY: "auto",
2283
2519
  overflowX: "hidden",
2284
- fontSize: B,
2285
- lineHeight: W,
2520
+ fontSize: N,
2521
+ lineHeight: $,
2286
2522
  whiteSpace: "pre-wrap",
2287
2523
  wordBreak: "break-word",
2288
2524
  color: "#888"
2289
2525
  },
2290
- children: c
2526
+ children: l
2291
2527
  }
2292
2528
  )
2293
2529
  }
2294
2530
  )
2295
2531
  ] }),
2296
- a === 2 && l && /* @__PURE__ */ o("div", { style: { fontSize: 12 }, children: /* @__PURE__ */ o(
2532
+ i === 2 && d && /* @__PURE__ */ o("div", { style: { fontSize: 12 }, children: /* @__PURE__ */ o(
2297
2533
  M,
2298
2534
  {
2299
- text: n.memorySearchGeneratingQueriesPending,
2535
+ text: r.memorySearchGeneratingQueriesPending,
2300
2536
  duration: 2.5,
2301
2537
  repeat: !0,
2302
2538
  color: "#999",
2303
2539
  shimmerColor: "#000"
2304
2540
  }
2305
2541
  ) }),
2306
- a === 3 && /* @__PURE__ */ p(E, { children: [
2307
- /* @__PURE__ */ p("div", { style: { minWidth: 0 }, children: [
2542
+ i === 3 && /* @__PURE__ */ h(E, { children: [
2543
+ /* @__PURE__ */ h("div", { style: { minWidth: 0 }, children: [
2308
2544
  /* @__PURE__ */ o(
2309
2545
  "span",
2310
2546
  {
@@ -2315,7 +2551,7 @@ function gr({
2315
2551
  marginBottom: 6,
2316
2552
  fontWeight: 500
2317
2553
  },
2318
- children: n.memorySearchGeneratedQueriesHeading
2554
+ children: r.memorySearchGeneratedQueriesHeading
2319
2555
  }
2320
2556
  ),
2321
2557
  /* @__PURE__ */ o(
@@ -2326,7 +2562,7 @@ function gr({
2326
2562
  flexDirection: "column",
2327
2563
  gap: 6
2328
2564
  },
2329
- children: e.queries.map((h, f) => /* @__PURE__ */ o(
2565
+ children: e.queries.map((p, f) => /* @__PURE__ */ o(
2330
2566
  "div",
2331
2567
  {
2332
2568
  style: {
@@ -2335,19 +2571,19 @@ function gr({
2335
2571
  lineHeight: 1.5,
2336
2572
  wordBreak: "break-word"
2337
2573
  },
2338
- children: h.query
2574
+ children: p.query
2339
2575
  },
2340
2576
  f
2341
2577
  ))
2342
2578
  }
2343
2579
  )
2344
2580
  ] }),
2345
- s && /* @__PURE__ */ p(E, { children: [
2581
+ a && /* @__PURE__ */ h(E, { children: [
2346
2582
  /* @__PURE__ */ o(
2347
2583
  "button",
2348
2584
  {
2349
2585
  type: "button",
2350
- onClick: () => y((h) => !h),
2586
+ onClick: () => y((p) => !p),
2351
2587
  style: {
2352
2588
  alignSelf: "flex-start",
2353
2589
  border: "none",
@@ -2358,15 +2594,15 @@ function gr({
2358
2594
  color: "#666",
2359
2595
  textDecoration: "underline"
2360
2596
  },
2361
- children: u ? n.memorySearchHideReasoning : n.memorySearchViewReasoning
2597
+ children: u ? r.memorySearchHideReasoning : r.memorySearchViewReasoning
2362
2598
  }
2363
2599
  ),
2364
2600
  u && /* @__PURE__ */ o(
2365
2601
  "div",
2366
2602
  {
2367
2603
  style: {
2368
- fontSize: B,
2369
- lineHeight: W,
2604
+ fontSize: N,
2605
+ lineHeight: $,
2370
2606
  whiteSpace: "pre-wrap",
2371
2607
  wordBreak: "break-word",
2372
2608
  color: "#888",
@@ -2374,7 +2610,7 @@ function gr({
2374
2610
  borderRadius: 6,
2375
2611
  padding: "8px 10px"
2376
2612
  },
2377
- children: c
2613
+ children: l
2378
2614
  }
2379
2615
  )
2380
2616
  ] })
@@ -2386,31 +2622,31 @@ function gr({
2386
2622
  }
2387
2623
  );
2388
2624
  }
2389
- const pr = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
2390
- const a = z(() => {
2391
- let c = -1;
2392
- return e.memoryTypes.forEach((s, d) => {
2393
- O(s) || (c = d);
2394
- }), c;
2625
+ const pr = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
2626
+ const i = B(() => {
2627
+ let l = -1;
2628
+ return e.memoryTypes.forEach((a, c) => {
2629
+ W(a) || (l = c);
2630
+ }), l;
2395
2631
  }, [e.memoryTypes]);
2396
- return /* @__PURE__ */ p("div", { style: { padding: "10px" }, children: [
2397
- n && !t && e.memoryTypes.length === 0 ? /* @__PURE__ */ o(
2632
+ return /* @__PURE__ */ h("div", { style: { padding: "10px" }, children: [
2633
+ r && !t && e.memoryTypes.length === 0 ? /* @__PURE__ */ o(
2398
2634
  M,
2399
2635
  {
2400
- text: r.memorySearchGeneratingQueries,
2636
+ text: n.memorySearchGeneratingQueries,
2401
2637
  duration: 2.5,
2402
2638
  repeat: !0,
2403
2639
  color: "#999",
2404
2640
  shimmerColor: "#000"
2405
2641
  }
2406
- ) : e.memoryTypes.map((c, s) => /* @__PURE__ */ o(
2407
- gr,
2642
+ ) : e.memoryTypes.map((l, a) => /* @__PURE__ */ o(
2643
+ hr,
2408
2644
  {
2409
- item: c,
2410
- t: r,
2411
- isActiveRow: s === a && n
2645
+ item: l,
2646
+ t: n,
2647
+ isActiveRow: a === i && r
2412
2648
  },
2413
- c.memoryTypeId
2649
+ l.memoryTypeId
2414
2650
  )),
2415
2651
  t !== void 0 && /* @__PURE__ */ o(
2416
2652
  "div",
@@ -2421,44 +2657,44 @@ const pr = ({ data: e, isLatest: n = !1, durationSeconds: t, t: r }) => {
2421
2657
  marginTop: "4px",
2422
2658
  fontStyle: "italic"
2423
2659
  },
2424
- children: b(r.tookSeconds, { n: t })
2660
+ children: v(n.tookSeconds, { n: t })
2425
2661
  }
2426
2662
  )
2427
2663
  ] });
2428
2664
  };
2429
- function hr(e) {
2430
- return e.some((r) => r.result == null && r.error == null) ? /* @__PURE__ */ o("span", { className: "explore-memory-loader" }) : e.some((r) => r.error != null) ? /* @__PURE__ */ o(j, { color: "#c62828", size: 15, lineWidth: 2 }) : /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 });
2665
+ function fr(e) {
2666
+ return e.some((n) => n.result == null && n.error == null) ? /* @__PURE__ */ o("span", { className: "explore-memory-loader" }) : e.some((n) => n.error != null) ? /* @__PURE__ */ o(Q, { color: "#c62828", size: 15, lineWidth: 2 }) : /* @__PURE__ */ o(D, { color: "#999", size: 15, borderWidth: 2 });
2431
2667
  }
2432
- function fr(e, n) {
2668
+ function Sr(e, r) {
2433
2669
  if (e.error != null)
2434
2670
  return /* @__PURE__ */ o("span", { style: { fontSize: 12, color: "#c62828", whiteSpace: "nowrap" }, children: e.error });
2435
2671
  if (e.result == null)
2436
2672
  return /* @__PURE__ */ o("span", { style: { flexShrink: 0, fontSize: 12 }, children: /* @__PURE__ */ o(
2437
2673
  M,
2438
2674
  {
2439
- text: n.searching,
2675
+ text: r.searching,
2440
2676
  duration: 2.5,
2441
2677
  repeat: !0,
2442
2678
  color: "#999",
2443
2679
  shimmerColor: "#000"
2444
2680
  }
2445
2681
  ) });
2446
- const t = e.result, r = t.numberOfChunks === 1 ? n.chunkFound : b(n.chunksFound, { n: t.numberOfChunks }), a = b(n.scoreLabel, {
2682
+ const t = e.result, n = t.numberOfChunks === 1 ? r.chunkFound : v(r.chunksFound, { n: t.numberOfChunks }), i = v(r.scoreLabel, {
2447
2683
  n: t.highestChunkScore.toFixed(2)
2448
2684
  });
2449
- return /* @__PURE__ */ p("span", { style: { fontSize: 12, color: "#666", whiteSpace: "nowrap" }, children: [
2450
- r,
2685
+ return /* @__PURE__ */ h("span", { style: { fontSize: 12, color: "#666", whiteSpace: "nowrap" }, children: [
2686
+ n,
2451
2687
  " · ",
2452
- a
2688
+ i
2453
2689
  ] });
2454
2690
  }
2455
2691
  function xr({
2456
2692
  items: e,
2457
- queryRow: n,
2693
+ queryRow: r,
2458
2694
  onExploreQueryResultClick: t,
2459
- t: r
2695
+ t: n
2460
2696
  }) {
2461
- const [a, c] = w(null);
2697
+ const [i, l] = I(null);
2462
2698
  if (e.length === 0)
2463
2699
  return /* @__PURE__ */ o(
2464
2700
  "div",
@@ -2468,10 +2704,10 @@ function xr({
2468
2704
  color: "#94a3b8",
2469
2705
  paddingTop: 4
2470
2706
  },
2471
- children: r.memorySearchExploreNoResults
2707
+ children: n.memorySearchExploreNoResults
2472
2708
  }
2473
2709
  );
2474
- const s = !!t;
2710
+ const a = !!t;
2475
2711
  return /* @__PURE__ */ o(
2476
2712
  "div",
2477
2713
  {
@@ -2483,26 +2719,26 @@ function xr({
2483
2719
  paddingTop: 8,
2484
2720
  borderTop: "1px solid #f0f0f0"
2485
2721
  },
2486
- children: e.map((d, u) => {
2487
- const y = d.memoryTitle !== "" ? d.memoryTitle : d.memoryId, i = V(
2488
- d.chunks
2489
- ), l = [
2490
- X(d),
2491
- b(r.scoreLabel, {
2492
- n: d.matchingChunkScore.toFixed(2)
2722
+ children: e.map((c, u) => {
2723
+ const y = c.memoryTitle !== "" ? c.memoryTitle : c.memoryId, s = V(
2724
+ c.chunks
2725
+ ), d = [
2726
+ X(c),
2727
+ v(n.scoreLabel, {
2728
+ n: c.matchingChunkScore.toFixed(2)
2493
2729
  }),
2494
- i.length > 0 ? K(i, r) : r.pagesNotAvailable
2730
+ s.length > 0 ? K(s, n) : n.pagesNotAvailable
2495
2731
  ].filter(
2496
2732
  (f) => f != null && f !== ""
2497
2733
  ), m = {
2498
- memoryId: d.memoryId,
2499
- memoryTitle: d.memoryTitle,
2500
- pageNumbers: i,
2501
- memoryTypeId: n.memoryTypeId,
2502
- memoryTypeName: n.memoryTypeName,
2503
- query: n.query
2504
- }, g = `${n.query}::${d.memoryId}::${u}`, h = a === g;
2505
- return /* @__PURE__ */ p(
2734
+ memoryId: c.memoryId,
2735
+ memoryTitle: c.memoryTitle,
2736
+ pageNumbers: s,
2737
+ memoryTypeId: r.memoryTypeId,
2738
+ memoryTypeName: r.memoryTypeName,
2739
+ query: r.query
2740
+ }, g = `${r.query}::${c.memoryId}::${u}`, p = i === g;
2741
+ return /* @__PURE__ */ h(
2506
2742
  "div",
2507
2743
  {
2508
2744
  style: {
@@ -2516,7 +2752,7 @@ function xr({
2516
2752
  minWidth: 0
2517
2753
  },
2518
2754
  children: [
2519
- /* @__PURE__ */ p(
2755
+ /* @__PURE__ */ h(
2520
2756
  "div",
2521
2757
  {
2522
2758
  style: {
@@ -2549,7 +2785,7 @@ function xr({
2549
2785
  wordBreak: "break-word"
2550
2786
  },
2551
2787
  children: q(
2552
- d.chunks
2788
+ c.chunks
2553
2789
  )
2554
2790
  }
2555
2791
  ),
@@ -2562,26 +2798,26 @@ function xr({
2562
2798
  color: "#94a3b8",
2563
2799
  lineHeight: 1.35
2564
2800
  },
2565
- children: l.join(" · ")
2801
+ children: d.join(" · ")
2566
2802
  }
2567
2803
  )
2568
2804
  ]
2569
2805
  }
2570
2806
  ),
2571
- s && /* @__PURE__ */ p(
2807
+ a && /* @__PURE__ */ h(
2572
2808
  "button",
2573
2809
  {
2574
2810
  type: "button",
2575
- "aria-busy": h,
2576
- disabled: h,
2811
+ "aria-busy": p,
2812
+ disabled: p,
2577
2813
  onClick: async () => {
2578
- c(g);
2814
+ l(g);
2579
2815
  try {
2580
2816
  await t(
2581
2817
  m
2582
2818
  );
2583
2819
  } finally {
2584
- c(null);
2820
+ l(null);
2585
2821
  }
2586
2822
  },
2587
2823
  style: {
@@ -2594,56 +2830,56 @@ function xr({
2594
2830
  background: "#eff6ff",
2595
2831
  border: "1px solid #bfdbfe",
2596
2832
  borderRadius: 6,
2597
- cursor: h ? "wait" : "pointer",
2833
+ cursor: p ? "wait" : "pointer",
2598
2834
  fontFamily: "inherit",
2599
2835
  display: "inline-flex",
2600
2836
  alignItems: "center",
2601
2837
  gap: 8
2602
2838
  },
2603
2839
  children: [
2604
- h && /* @__PURE__ */ o(
2840
+ p && /* @__PURE__ */ o(
2605
2841
  "span",
2606
2842
  {
2607
2843
  className: "explore-memory-loader explore-memory-loader--callback",
2608
2844
  "aria-hidden": !0
2609
2845
  }
2610
2846
  ),
2611
- r.viewButton
2847
+ n.viewButton
2612
2848
  ]
2613
2849
  }
2614
2850
  )
2615
2851
  ]
2616
2852
  },
2617
- `${d.memoryId}-${u}`
2853
+ `${c.memoryId}-${u}`
2618
2854
  );
2619
2855
  })
2620
2856
  }
2621
2857
  );
2622
2858
  }
2623
- function Sr(e) {
2624
- const n = [], t = /* @__PURE__ */ new Map();
2625
- return e.forEach((r, a) => {
2626
- let c = t.get(r.memoryTypeId);
2627
- c == null && (n.push(r.memoryTypeId), c = {
2628
- memoryTypeId: r.memoryTypeId,
2629
- memoryTypeName: r.memoryTypeName,
2859
+ function kr(e) {
2860
+ const r = [], t = /* @__PURE__ */ new Map();
2861
+ return e.forEach((n, i) => {
2862
+ let l = t.get(n.memoryTypeId);
2863
+ l == null && (r.push(n.memoryTypeId), l = {
2864
+ memoryTypeId: n.memoryTypeId,
2865
+ memoryTypeName: n.memoryTypeName,
2630
2866
  items: []
2631
- }, t.set(r.memoryTypeId, c)), c.items.push({ item: r, flatIndex: a });
2632
- }), n.map((r) => t.get(r));
2867
+ }, t.set(n.memoryTypeId, l)), l.items.push({ item: n, flatIndex: i });
2868
+ }), r.map((n) => t.get(n));
2633
2869
  }
2634
- function Tr({
2870
+ function br({
2635
2871
  group: e,
2636
- t: n,
2872
+ t: r,
2637
2873
  isLatest: t,
2638
- expandedRows: r,
2639
- toggleExpanded: a,
2640
- onExploreQueryResultClick: c
2874
+ expandedRows: n,
2875
+ toggleExpanded: i,
2876
+ onExploreQueryResultClick: l
2641
2877
  }) {
2642
- const s = e.items.map((u) => u.item), d = s.some(
2878
+ const a = e.items.map((u) => u.item), c = a.some(
2643
2879
  (u) => u.result == null && u.error == null
2644
2880
  );
2645
- return /* @__PURE__ */ p(
2646
- I.div,
2881
+ return /* @__PURE__ */ h(
2882
+ C.div,
2647
2883
  {
2648
2884
  initial: { opacity: 0 },
2649
2885
  animate: { opacity: 1 },
@@ -2654,7 +2890,7 @@ function Tr({
2654
2890
  borderBottom: "1px solid #eee",
2655
2891
  display: "flex",
2656
2892
  flexDirection: "row",
2657
- alignItems: d ? "center" : "flex-start",
2893
+ alignItems: c ? "center" : "flex-start",
2658
2894
  gap: "10px",
2659
2895
  minWidth: 0
2660
2896
  },
@@ -2668,12 +2904,12 @@ function Tr({
2668
2904
  justifyContent: "center",
2669
2905
  flexShrink: 0,
2670
2906
  width: 32,
2671
- ...d ? {} : { paddingTop: 2 }
2907
+ ...c ? {} : { paddingTop: 2 }
2672
2908
  },
2673
- children: hr(s)
2909
+ children: fr(a)
2674
2910
  }
2675
2911
  ),
2676
- /* @__PURE__ */ p(
2912
+ /* @__PURE__ */ h(
2677
2913
  "div",
2678
2914
  {
2679
2915
  style: {
@@ -2691,15 +2927,15 @@ function Tr({
2691
2927
  fontSize: 12,
2692
2928
  color: "#888"
2693
2929
  },
2694
- children: b(n.memorySearchExploreQueryTypeLabel, {
2930
+ children: v(r.memorySearchExploreQueryTypeLabel, {
2695
2931
  name: e.memoryTypeName
2696
2932
  })
2697
2933
  }
2698
2934
  ),
2699
2935
  e.items.map(({ item: u, flatIndex: y }) => {
2700
2936
  var f;
2701
- const i = u.result != null, l = u.error != null, m = t && !i && !l, g = r[y] === !0, h = ((f = u.result) == null ? void 0 : f.items) ?? [];
2702
- return /* @__PURE__ */ p(
2937
+ const s = u.result != null, d = u.error != null, m = t && !s && !d, g = n[y] === !0, p = ((f = u.result) == null ? void 0 : f.items) ?? [];
2938
+ return /* @__PURE__ */ h(
2703
2939
  "div",
2704
2940
  {
2705
2941
  style: {
@@ -2709,7 +2945,7 @@ function Tr({
2709
2945
  minWidth: 0
2710
2946
  },
2711
2947
  children: [
2712
- /* @__PURE__ */ p(
2948
+ /* @__PURE__ */ h(
2713
2949
  "div",
2714
2950
  {
2715
2951
  style: {
@@ -2744,7 +2980,7 @@ function Tr({
2744
2980
  ) : u.query
2745
2981
  }
2746
2982
  ),
2747
- /* @__PURE__ */ p(
2983
+ /* @__PURE__ */ h(
2748
2984
  "div",
2749
2985
  {
2750
2986
  style: {
@@ -2755,12 +2991,12 @@ function Tr({
2755
2991
  flexShrink: 0
2756
2992
  },
2757
2993
  children: [
2758
- fr(u, n),
2759
- i && /* @__PURE__ */ o(
2994
+ Sr(u, r),
2995
+ s && /* @__PURE__ */ o(
2760
2996
  "button",
2761
2997
  {
2762
2998
  type: "button",
2763
- onClick: () => a(y),
2999
+ onClick: () => i(y),
2764
3000
  style: {
2765
3001
  border: "none",
2766
3002
  background: "none",
@@ -2771,7 +3007,7 @@ function Tr({
2771
3007
  textDecoration: "underline",
2772
3008
  fontFamily: "inherit"
2773
3009
  },
2774
- children: g ? n.memorySearchHideExploreResults : n.memorySearchViewExploreResults
3010
+ children: g ? r.memorySearchHideExploreResults : r.memorySearchViewExploreResults
2775
3011
  }
2776
3012
  )
2777
3013
  ]
@@ -2780,13 +3016,13 @@ function Tr({
2780
3016
  ]
2781
3017
  }
2782
3018
  ),
2783
- i && g && /* @__PURE__ */ o(
3019
+ s && g && /* @__PURE__ */ o(
2784
3020
  xr,
2785
3021
  {
2786
- items: h,
3022
+ items: p,
2787
3023
  queryRow: u,
2788
- onExploreQueryResultClick: c,
2789
- t: n
3024
+ onExploreQueryResultClick: l,
3025
+ t: r
2790
3026
  }
2791
3027
  )
2792
3028
  ]
@@ -2801,43 +3037,43 @@ function Tr({
2801
3037
  }
2802
3038
  );
2803
3039
  }
2804
- const kr = ({
3040
+ const vr = ({
2805
3041
  data: e,
2806
- isLatest: n = !1,
3042
+ isLatest: r = !1,
2807
3043
  durationSeconds: t,
2808
- onExploreQueryResultClick: r,
2809
- t: a
3044
+ onExploreQueryResultClick: n,
3045
+ t: i
2810
3046
  }) => {
2811
- const [c, s] = w(
3047
+ const [l, a] = I(
2812
3048
  {}
2813
- ), d = N((y) => {
2814
- s((i) => ({
2815
- ...i,
2816
- [y]: !i[y]
3049
+ ), c = O((y) => {
3050
+ a((s) => ({
3051
+ ...s,
3052
+ [y]: !s[y]
2817
3053
  }));
2818
- }, []), u = z(
2819
- () => Sr(e.queries),
3054
+ }, []), u = B(
3055
+ () => kr(e.queries),
2820
3056
  [e.queries]
2821
3057
  );
2822
- return /* @__PURE__ */ p("div", { style: { padding: "10px" }, children: [
2823
- n && !t && e.queries.length === 0 ? /* @__PURE__ */ o(
3058
+ return /* @__PURE__ */ h("div", { style: { padding: "10px" }, children: [
3059
+ r && !t && e.queries.length === 0 ? /* @__PURE__ */ o(
2824
3060
  M,
2825
3061
  {
2826
- text: a.memorySearchExploringQueries,
3062
+ text: i.memorySearchExploringQueries,
2827
3063
  duration: 2.5,
2828
3064
  repeat: !0,
2829
3065
  color: "#999",
2830
3066
  shimmerColor: "#000"
2831
3067
  }
2832
3068
  ) : u.map((y) => /* @__PURE__ */ o(
2833
- Tr,
3069
+ br,
2834
3070
  {
2835
3071
  group: y,
2836
- t: a,
2837
- isLatest: n,
2838
- expandedRows: c,
2839
- toggleExpanded: d,
2840
- onExploreQueryResultClick: r
3072
+ t: i,
3073
+ isLatest: r,
3074
+ expandedRows: l,
3075
+ toggleExpanded: c,
3076
+ onExploreQueryResultClick: n
2841
3077
  },
2842
3078
  y.memoryTypeId
2843
3079
  )),
@@ -2850,15 +3086,15 @@ const kr = ({
2850
3086
  marginTop: "4px",
2851
3087
  fontStyle: "italic"
2852
3088
  },
2853
- children: b(a.tookSeconds, { n: t })
3089
+ children: v(i.tookSeconds, { n: t })
2854
3090
  }
2855
3091
  )
2856
3092
  ] });
2857
- }, br = ({ data: e, onSearchResultClick: n, t }) => {
2858
- const r = e.response.items, a = !!n, [c, s] = w(null);
2859
- return /* @__PURE__ */ p("div", { style: { padding: "16px" }, children: [
3093
+ }, Tr = ({ data: e, onSearchResultClick: r, t }) => {
3094
+ const n = e.response.items, i = !!r, [l, a] = I(null);
3095
+ return /* @__PURE__ */ h("div", { style: { padding: "16px" }, children: [
2860
3096
  /* @__PURE__ */ o(
2861
- I.div,
3097
+ C.div,
2862
3098
  {
2863
3099
  style: {
2864
3100
  marginBottom: "12px",
@@ -2880,26 +3116,26 @@ const kr = ({
2880
3116
  flexDirection: "column",
2881
3117
  gap: 0
2882
3118
  },
2883
- children: r.map((d, u) => {
2884
- const y = d.memoryTitle !== "" ? d.memoryTitle : d.memoryId, i = V(
2885
- d.chunks
2886
- ), l = [
2887
- X(d),
2888
- b(t.scoreLabel, {
2889
- n: d.matchingChunkScore.toFixed(2)
3119
+ children: n.map((c, u) => {
3120
+ const y = c.memoryTitle !== "" ? c.memoryTitle : c.memoryId, s = V(
3121
+ c.chunks
3122
+ ), d = [
3123
+ X(c),
3124
+ v(t.scoreLabel, {
3125
+ n: c.matchingChunkScore.toFixed(2)
2890
3126
  }),
2891
- i.length > 0 ? K(i, t) : t.pagesNotAvailable
3127
+ s.length > 0 ? K(s, t) : t.pagesNotAvailable
2892
3128
  ].filter(
2893
3129
  (f) => f != null && f !== ""
2894
3130
  ), m = {
2895
- memoryId: d.memoryId,
2896
- memoryTitle: d.memoryTitle,
2897
- memoryTypeId: d.memoryTypeId,
2898
- memoryTypeName: d.memoryTypeName,
2899
- pageNumbers: i
2900
- }, g = `${d.memoryId}-${u}`, h = c === g;
2901
- return /* @__PURE__ */ p(
2902
- I.div,
3131
+ memoryId: c.memoryId,
3132
+ memoryTitle: c.memoryTitle,
3133
+ memoryTypeId: c.memoryTypeId,
3134
+ memoryTypeName: c.memoryTypeName,
3135
+ pageNumbers: s
3136
+ }, g = `${c.memoryId}-${u}`, p = l === g;
3137
+ return /* @__PURE__ */ h(
3138
+ C.div,
2903
3139
  {
2904
3140
  initial: { opacity: 0 },
2905
3141
  animate: { opacity: 1 },
@@ -2911,11 +3147,11 @@ const kr = ({
2911
3147
  gap: "12px",
2912
3148
  paddingTop: "12px",
2913
3149
  paddingBottom: "12px",
2914
- borderBottom: u < r.length - 1 ? "1px solid #eee" : void 0,
3150
+ borderBottom: u < n.length - 1 ? "1px solid #eee" : void 0,
2915
3151
  minWidth: 0
2916
3152
  },
2917
3153
  children: [
2918
- /* @__PURE__ */ p(
3154
+ /* @__PURE__ */ h(
2919
3155
  "div",
2920
3156
  {
2921
3157
  style: {
@@ -2947,7 +3183,7 @@ const kr = ({
2947
3183
  whiteSpace: "pre-wrap",
2948
3184
  wordBreak: "break-word"
2949
3185
  },
2950
- children: q(d.chunks)
3186
+ children: q(c.chunks)
2951
3187
  }
2952
3188
  ),
2953
3189
  /* @__PURE__ */ o(
@@ -2959,24 +3195,24 @@ const kr = ({
2959
3195
  color: "#94a3b8",
2960
3196
  lineHeight: 1.35
2961
3197
  },
2962
- children: l.join(" · ")
3198
+ children: d.join(" · ")
2963
3199
  }
2964
3200
  )
2965
3201
  ]
2966
3202
  }
2967
3203
  ),
2968
- a && /* @__PURE__ */ p(
3204
+ i && /* @__PURE__ */ h(
2969
3205
  "button",
2970
3206
  {
2971
3207
  type: "button",
2972
- "aria-busy": h,
2973
- disabled: h,
3208
+ "aria-busy": p,
3209
+ disabled: p,
2974
3210
  onClick: async () => {
2975
- s(g);
3211
+ a(g);
2976
3212
  try {
2977
- await n(m);
3213
+ await r(m);
2978
3214
  } finally {
2979
- s(null);
3215
+ a(null);
2980
3216
  }
2981
3217
  },
2982
3218
  style: {
@@ -2989,14 +3225,14 @@ const kr = ({
2989
3225
  background: "#eff6ff",
2990
3226
  border: "1px solid #bfdbfe",
2991
3227
  borderRadius: 6,
2992
- cursor: h ? "wait" : "pointer",
3228
+ cursor: p ? "wait" : "pointer",
2993
3229
  fontFamily: "inherit",
2994
3230
  display: "inline-flex",
2995
3231
  alignItems: "center",
2996
3232
  gap: 8
2997
3233
  },
2998
3234
  children: [
2999
- h && /* @__PURE__ */ o(
3235
+ p && /* @__PURE__ */ o(
3000
3236
  "span",
3001
3237
  {
3002
3238
  className: "explore-memory-loader explore-memory-loader--callback",
@@ -3009,14 +3245,14 @@ const kr = ({
3009
3245
  )
3010
3246
  ]
3011
3247
  },
3012
- `${d.memoryId}-${u}`
3248
+ `${c.memoryId}-${u}`
3013
3249
  );
3014
3250
  })
3015
3251
  }
3016
3252
  )
3017
3253
  ] });
3018
- }, G = ({ message: e }) => /* @__PURE__ */ o("div", { style: { padding: "16px" }, children: /* @__PURE__ */ o(
3019
- I.div,
3254
+ }, j = ({ message: e }) => /* @__PURE__ */ o("div", { style: { padding: "16px" }, children: /* @__PURE__ */ o(
3255
+ C.div,
3020
3256
  {
3021
3257
  initial: { opacity: 0, y: -10 },
3022
3258
  animate: { opacity: 1, y: 0 },
@@ -3038,94 +3274,94 @@ const kr = ({
3038
3274
  }
3039
3275
  )
3040
3276
  }
3041
- ) }), vr = ({
3277
+ ) }), wr = ({
3042
3278
  progressViewItems: e,
3043
- loading: n,
3279
+ loading: r,
3044
3280
  error: t,
3045
- loadingText: r,
3046
- t: a,
3047
- onSourceClick: c,
3048
- onSearchResultClick: s,
3049
- onExploreQueryResultClick: d
3281
+ loadingText: n,
3282
+ t: i,
3283
+ onSourceClick: l,
3284
+ onSearchResultClick: a,
3285
+ onExploreQueryResultClick: c
3050
3286
  }) => {
3051
3287
  const u = F(null);
3052
- R(() => {
3288
+ A(() => {
3053
3289
  u.current && (u.current.scrollTop = u.current.scrollHeight);
3054
3290
  }, [e.length]);
3055
- const y = (l) => {
3056
- const m = l.item.data;
3291
+ const y = (d) => {
3292
+ const m = d.item.data;
3057
3293
  if (m.taskType === "StreamingChatCompletion" && m.eventType === "Text")
3058
- return /* @__PURE__ */ o(ee, { text: m.text });
3294
+ return /* @__PURE__ */ o(ne, { text: m.text });
3059
3295
  if (m.taskType === "StructuredChatCompletion" && m.eventType === "Completed")
3060
- return /* @__PURE__ */ o(Be, { data: m });
3296
+ return /* @__PURE__ */ o(Ne, { data: m });
3061
3297
  if (m.taskType === "MemoryChat")
3062
3298
  switch (m.eventType) {
3063
3299
  case "Text":
3064
- return /* @__PURE__ */ o(ee, { text: m.text });
3300
+ return /* @__PURE__ */ o(ne, { text: m.text });
3065
3301
  case "FindMemories":
3066
3302
  return /* @__PURE__ */ o(
3067
3303
  _e,
3068
3304
  {
3069
3305
  data: m,
3070
- isLatest: l.isLatest,
3071
- durationSeconds: l.durationSeconds,
3072
- t: a
3306
+ isLatest: d.isLatest,
3307
+ durationSeconds: d.durationSeconds,
3308
+ t: i
3073
3309
  }
3074
3310
  );
3075
3311
  case "FindMemoriesResult":
3076
3312
  return /* @__PURE__ */ o(
3077
- Ge,
3313
+ je,
3078
3314
  {
3079
3315
  data: m,
3080
- t: a
3316
+ t: i
3081
3317
  }
3082
3318
  );
3083
3319
  case "Search":
3084
3320
  return /* @__PURE__ */ o(
3085
- He,
3321
+ Ue,
3086
3322
  {
3087
3323
  data: m,
3088
- isLatest: l.isLatest,
3089
- durationSeconds: l.durationSeconds,
3090
- t: a
3324
+ isLatest: d.isLatest,
3325
+ durationSeconds: d.durationSeconds,
3326
+ t: i
3091
3327
  }
3092
3328
  );
3093
3329
  case "FindSources":
3094
3330
  return /* @__PURE__ */ o(
3095
- Ue,
3331
+ Ge,
3096
3332
  {
3097
3333
  data: m,
3098
- isLatest: l.isLatest,
3099
- durationSeconds: l.durationSeconds,
3100
- t: a
3334
+ isLatest: d.isLatest,
3335
+ durationSeconds: d.durationSeconds,
3336
+ t: i
3101
3337
  }
3102
3338
  );
3103
3339
  case "SourcesResult":
3104
3340
  return /* @__PURE__ */ o(
3105
- je,
3341
+ qe,
3106
3342
  {
3107
3343
  data: m,
3108
- onSourceClick: c,
3109
- t: a
3344
+ onSourceClick: l,
3345
+ t: i
3110
3346
  }
3111
3347
  );
3112
3348
  case "ExploreMemories":
3113
3349
  return /* @__PURE__ */ o(
3114
- Xe,
3350
+ Je,
3115
3351
  {
3116
3352
  data: m,
3117
- completed: l.completed,
3118
- isLatest: l.isLatest,
3119
- t: a
3353
+ completed: d.completed,
3354
+ isLatest: d.isLatest,
3355
+ t: i
3120
3356
  }
3121
3357
  );
3122
3358
  case "ChunkResults":
3123
3359
  return /* @__PURE__ */ o(
3124
- or,
3360
+ ir,
3125
3361
  {
3126
3362
  data: m,
3127
- onSearchResultClick: s,
3128
- t: a
3363
+ onSearchResultClick: a,
3364
+ t: i
3129
3365
  }
3130
3366
  );
3131
3367
  case "Completed":
@@ -3138,49 +3374,49 @@ const kr = ({
3138
3374
  pr,
3139
3375
  {
3140
3376
  data: m,
3141
- isLatest: l.isLatest,
3142
- durationSeconds: l.durationSeconds,
3143
- t: a
3377
+ isLatest: d.isLatest,
3378
+ durationSeconds: d.durationSeconds,
3379
+ t: i
3144
3380
  }
3145
3381
  );
3146
3382
  case "ExploreQueries":
3147
3383
  return /* @__PURE__ */ o(
3148
- kr,
3384
+ vr,
3149
3385
  {
3150
3386
  data: m,
3151
- isLatest: l.isLatest,
3152
- durationSeconds: l.durationSeconds,
3153
- onExploreQueryResultClick: d,
3154
- t: a
3387
+ isLatest: d.isLatest,
3388
+ durationSeconds: d.durationSeconds,
3389
+ onExploreQueryResultClick: c,
3390
+ t: i
3155
3391
  }
3156
3392
  );
3157
3393
  case "SearchMemoryTypes":
3158
3394
  return /* @__PURE__ */ o(
3159
- lr,
3395
+ cr,
3160
3396
  {
3161
3397
  data: m,
3162
- isLatest: l.isLatest,
3163
- durationSeconds: l.durationSeconds,
3164
- t: a
3398
+ isLatest: d.isLatest,
3399
+ durationSeconds: d.durationSeconds,
3400
+ t: i
3165
3401
  }
3166
3402
  );
3167
3403
  case "Completed":
3168
3404
  return /* @__PURE__ */ o(
3169
- br,
3405
+ Tr,
3170
3406
  {
3171
3407
  data: m,
3172
- onSearchResultClick: s,
3173
- t: a
3408
+ onSearchResultClick: a,
3409
+ t: i
3174
3410
  }
3175
3411
  );
3176
3412
  }
3177
- return m.taskType === "StreamingChatCompletion" && m.eventType === "Completed" ? null : m.eventType === "Error" && "message" in m ? /* @__PURE__ */ o(G, { message: m.message }) : null;
3413
+ return m.taskType === "StreamingChatCompletion" && m.eventType === "Completed" ? null : m.eventType === "Error" && "message" in m ? /* @__PURE__ */ o(j, { message: m.message }) : null;
3178
3414
  };
3179
3415
  if (e.length === 0)
3180
- return t ? /* @__PURE__ */ o("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ o(G, { message: t.message }) }) : n ? /* @__PURE__ */ o("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ o(
3416
+ return t ? /* @__PURE__ */ o("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ o(j, { message: t.message }) }) : r ? /* @__PURE__ */ o("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ o(
3181
3417
  M,
3182
3418
  {
3183
- text: r ?? a.processingYourTask,
3419
+ text: n ?? i.processingYourTask,
3184
3420
  duration: 1.5,
3185
3421
  repeat: !0,
3186
3422
  repeatDelay: 0,
@@ -3188,23 +3424,23 @@ const kr = ({
3188
3424
  shimmerColor: "#000"
3189
3425
  }
3190
3426
  ) }) : null;
3191
- const i = e.filter((l, m) => {
3192
- const g = l.item.data;
3427
+ const s = e.filter((d, m) => {
3428
+ const g = d.item.data;
3193
3429
  return g.taskType === "MemoryChat" && g.eventType === "ExploreMemories" ? !e.slice(m + 1).some(
3194
- (x) => x.item.data.taskType === "MemoryChat" && x.item.data.eventType === "ExploreMemories"
3430
+ (S) => S.item.data.taskType === "MemoryChat" && S.item.data.eventType === "ExploreMemories"
3195
3431
  ) : g.taskType === "MemorySearch" && g.eventType === "GeneratingQueries" ? !e.slice(m + 1).some(
3196
- (x) => x.item.data.taskType === "MemorySearch" && x.item.data.eventType === "GeneratingQueries"
3432
+ (S) => S.item.data.taskType === "MemorySearch" && S.item.data.eventType === "GeneratingQueries"
3197
3433
  ) : g.taskType === "MemorySearch" && g.eventType === "ExploreQueries" ? !e.slice(m + 1).some(
3198
- (x) => x.item.data.taskType === "MemorySearch" && x.item.data.eventType === "ExploreQueries"
3434
+ (S) => S.item.data.taskType === "MemorySearch" && S.item.data.eventType === "ExploreQueries"
3199
3435
  ) : g.taskType === "MemoryChat" && g.eventType === "ChunkResults" ? !e.slice(m + 1).some(
3200
- (x) => x.item.data.taskType === "MemoryChat" && x.item.data.eventType === "ChunkResults"
3436
+ (S) => S.item.data.taskType === "MemoryChat" && S.item.data.eventType === "ChunkResults"
3201
3437
  ) : !0;
3202
3438
  });
3203
- return /* @__PURE__ */ p("div", { id: "agent-task-progress-verbose", ref: u, children: [
3204
- /* @__PURE__ */ o(pe, { children: i.map((l, m) => /* @__PURE__ */ o(
3205
- I.div,
3439
+ return /* @__PURE__ */ h("div", { id: "agent-task-progress-verbose", ref: u, children: [
3440
+ /* @__PURE__ */ o(fe, { children: s.map((d, m) => /* @__PURE__ */ o(
3441
+ C.div,
3206
3442
  {
3207
- id: `agent-task-progress-item-${l.item.progressItemId}`,
3443
+ id: `agent-task-progress-item-${d.item.progressItemId}`,
3208
3444
  initial: { opacity: 0, y: -20 },
3209
3445
  animate: { opacity: 1, y: 0 },
3210
3446
  transition: {
@@ -3212,40 +3448,40 @@ const kr = ({
3212
3448
  delay: m * 0.1,
3213
3449
  ease: "easeOut"
3214
3450
  },
3215
- children: y(l)
3451
+ children: y(d)
3216
3452
  },
3217
- l.item.progressItemId
3453
+ d.item.progressItemId
3218
3454
  )) }),
3219
- t ? /* @__PURE__ */ o("div", { style: { marginTop: 8 }, children: /* @__PURE__ */ o(G, { message: t.message }) }) : null
3455
+ t ? /* @__PURE__ */ o("div", { style: { marginTop: 8 }, children: /* @__PURE__ */ o(j, { message: t.message }) }) : null
3220
3456
  ] });
3221
3457
  }, Dr = ({
3222
3458
  agentTask: e,
3223
- language: n,
3459
+ language: r,
3224
3460
  onSourceClick: t,
3225
- onSearchResultClick: r,
3226
- onExploreQueryResultClick: a
3461
+ onSearchResultClick: n,
3462
+ onExploreQueryResultClick: i
3227
3463
  }) => {
3228
- const c = Oe(e), s = (e.params.type === "MemoryChat" || e.params.type === "MemorySearch") && "language" in e.params ? e.params.language ?? "en" : n ?? "en", d = $e(s);
3464
+ const l = ze(e), a = (e.params.type === "MemoryChat" || e.params.type === "MemorySearch") && "language" in e.params ? e.params.language ?? "en" : r ?? "en", c = He(a);
3229
3465
  return /* @__PURE__ */ o(
3230
- vr,
3466
+ wr,
3231
3467
  {
3232
- progressViewItems: c,
3468
+ progressViewItems: l,
3233
3469
  loading: e.loading,
3234
3470
  error: e.error,
3235
3471
  loadingText: e.loadingText,
3236
- t: d,
3472
+ t: c,
3237
3473
  onSourceClick: t,
3238
- onSearchResultClick: r,
3239
- onExploreQueryResultClick: a
3474
+ onSearchResultClick: n,
3475
+ onExploreQueryResultClick: i
3240
3476
  }
3241
3477
  );
3242
3478
  };
3243
3479
  export {
3244
3480
  Dr as AgentTaskProgress,
3245
- L as Checkmark,
3246
- Fr as FencyProvider,
3247
- br as MemorySearchCompletedResults,
3248
- Me as StreamEventManager,
3249
- j as XMark,
3481
+ D as Checkmark,
3482
+ Lr as FencyProvider,
3483
+ Tr as MemorySearchCompletedResults,
3484
+ Re as StreamEventManager,
3485
+ Q as XMark,
3250
3486
  Pr as useAgentTasks
3251
3487
  };