teodor-new-chat-ui 4.1.10 → 4.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -136,14 +136,14 @@ function om() {
136
136
  }
137
137
  return null;
138
138
  }
139
- var _ = Object.assign, V = 0, U, q, L, k, W, Y, ue;
139
+ var _ = Object.assign, V = 0, U, q, F, k, W, Y, ue;
140
140
  function re() {
141
141
  }
142
142
  re.__reactDisabledLog = !0;
143
143
  function de() {
144
144
  {
145
145
  if (V === 0) {
146
- U = console.log, q = console.info, L = console.warn, k = console.error, W = console.group, Y = console.groupCollapsed, ue = console.groupEnd;
146
+ U = console.log, q = console.info, F = console.warn, k = console.error, W = console.group, Y = console.groupCollapsed, ue = console.groupEnd;
147
147
  var T = {
148
148
  configurable: !0,
149
149
  enumerable: !0,
@@ -179,7 +179,7 @@ function om() {
179
179
  value: q
180
180
  }),
181
181
  warn: _({}, T, {
182
- value: L
182
+ value: F
183
183
  }),
184
184
  error: _({}, T, {
185
185
  value: k
@@ -380,8 +380,8 @@ function om() {
380
380
  ref: !0,
381
381
  __self: !0,
382
382
  __source: !0
383
- }, Ve, F;
384
- function J(T) {
383
+ }, Ve, L;
384
+ function X(T) {
385
385
  if (Ee.call(T, "ref")) {
386
386
  var H = Object.getOwnPropertyDescriptor(T, "ref").get;
387
387
  if (H && H.isReactWarning)
@@ -414,7 +414,7 @@ function om() {
414
414
  function it(T, H) {
415
415
  {
416
416
  var ee = function() {
417
- F || (F = !0, b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", H));
417
+ L || (L = !0, b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", H));
418
418
  };
419
419
  ee.isReactWarning = !0, Object.defineProperty(T, "ref", {
420
420
  get: ee,
@@ -454,7 +454,7 @@ function om() {
454
454
  function tr(T, H, ee, Te, Ke) {
455
455
  {
456
456
  var Xe, Be = {}, Le = null, Ct = null;
457
- ee !== void 0 && (ve(ee), Le = "" + ee), Ce(H) && (ve(H.key), Le = "" + H.key), J(H) && (Ct = H.ref, Oe(H, Ke));
457
+ ee !== void 0 && (ve(ee), Le = "" + ee), Ce(H) && (ve(H.key), Le = "" + H.key), X(H) && (Ct = H.ref, Oe(H, Ke));
458
458
  for (Xe in H)
459
459
  Ee.call(H, Xe) && !et.hasOwnProperty(Xe) && (Be[Xe] = H[Xe]);
460
460
  if (T && T.defaultProps) {
@@ -1900,32 +1900,32 @@ const Wc = (e) => {
1900
1900
  credentials: U ? j : void 0
1901
1901
  };
1902
1902
  D = s && new n(v, q);
1903
- let L = await (s ? O(D, N) : O(v, q));
1903
+ let F = await (s ? O(D, N) : O(v, q));
1904
1904
  const k = d && (E === "stream" || E === "response");
1905
1905
  if (d && (S || k && _)) {
1906
1906
  const Y = {};
1907
1907
  ["status", "statusText", "headers"].forEach((fe) => {
1908
- Y[fe] = L[fe];
1908
+ Y[fe] = F[fe];
1909
1909
  });
1910
- const ue = A.toFiniteNumber(L.headers.get("content-length")), [re, de] = S && Qa(
1910
+ const ue = A.toFiniteNumber(F.headers.get("content-length")), [re, de] = S && Qa(
1911
1911
  ue,
1912
1912
  Mo(el(S), !0)
1913
1913
  ) || [];
1914
- L = new r(
1915
- nl(L.body, rl, re, () => {
1914
+ F = new r(
1915
+ nl(F.body, rl, re, () => {
1916
1916
  de && de(), _ && _();
1917
1917
  }),
1918
1918
  Y
1919
1919
  );
1920
1920
  }
1921
1921
  E = E || "text";
1922
- let W = await f[A.findKey(f, E) || "text"](L, w);
1922
+ let W = await f[A.findKey(f, E) || "text"](F, w);
1923
1923
  return !k && _ && _(), await new Promise((Y, ue) => {
1924
1924
  Hc(Y, ue, {
1925
1925
  data: W,
1926
- headers: It.from(L.headers),
1927
- status: L.status,
1928
- statusText: L.statusText,
1926
+ headers: It.from(F.headers),
1927
+ status: F.status,
1928
+ statusText: F.statusText,
1929
1929
  config: w,
1930
1930
  request: D
1931
1931
  });
@@ -2908,7 +2908,7 @@ function Zg(e = {}) {
2908
2908
  y.current && (y.current.abort(), y.current = null), l(!0), d(null), e.autoAppendAssistant !== !1 && h("");
2909
2909
  const D = new AbortController();
2910
2910
  return y.current = D, (async () => {
2911
- var V, U, q, L, k, W, Y, ue;
2911
+ var V, U, q, F, k, W, Y, ue;
2912
2912
  const _ = (re) => {
2913
2913
  var de;
2914
2914
  try {
@@ -2990,7 +2990,7 @@ function Zg(e = {}) {
2990
2990
  }, 5e3), Ye = 1024 * 1024;
2991
2991
  try {
2992
2992
  const Ee = de.headers.get("X-Thread-Id") || de.headers.get("x-thread-id"), _e = de.headers.get("X-Thread-Created") || de.headers.get("x-thread-created"), Qe = Ee ?? null, je = String(_e ?? "").toLowerCase() === "true";
2993
- for ((L = M == null ? void 0 : M.onOpen) == null || L.call(M, { threadId: Qe, created: je }); ; ) {
2993
+ for ((F = M == null ? void 0 : M.onOpen) == null || F.call(M, { threadId: Qe, created: je }); ; ) {
2994
2994
  const { value: st, done: at } = await fe.read();
2995
2995
  if (at) break;
2996
2996
  B += ye.decode(st, { stream: !0 }), B.length > Ye && (B = "", console.warn("Stream buffer reset: exceeded 1MB"));
@@ -3103,7 +3103,7 @@ function tx({
3103
3103
  s.current = w;
3104
3104
  }
3105
3105
  if (p.type === "thread_info") {
3106
- t(p);
3106
+ console.log("[useChatStreamingService] 🎯 Received thread_info event:", p), t(p);
3107
3107
  return;
3108
3108
  }
3109
3109
  if (Hg(p)) {
@@ -3161,16 +3161,16 @@ function ox({
3161
3161
  prepend: V,
3162
3162
  pushUser: U,
3163
3163
  onEvent: q,
3164
- reset: L
3164
+ reset: F
3165
3165
  } = Vg(), k = ut(p);
3166
3166
  gt(() => {
3167
3167
  k.current = p;
3168
3168
  }, [p]);
3169
- const W = ut(!1), Y = ut([]), ue = ut(null), re = ut(null), de = Ue((F, J) => new Promise((Ce, Oe) => {
3169
+ const W = ut(!1), Y = ut([]), ue = ut(null), re = ut(null), de = Ue((L, X) => new Promise((Ce, Oe) => {
3170
3170
  const De = async () => {
3171
3171
  W.current = !0;
3172
3172
  try {
3173
- await F(), Ce();
3173
+ await L(), Ce();
3174
3174
  } catch (it) {
3175
3175
  Oe(it);
3176
3176
  } finally {
@@ -3186,10 +3186,10 @@ function ox({
3186
3186
  }), []), fe = Ue(async () => {
3187
3187
  g(!0);
3188
3188
  try {
3189
- const F = await l.listThreads();
3190
- h(F);
3191
- } catch (F) {
3192
- i == null || i(String(F)), console.error("[ChatSessionProvider] Failed to refresh threads:", F);
3189
+ const L = await l.listThreads();
3190
+ h(L);
3191
+ } catch (L) {
3192
+ i == null || i(String(L)), console.error("[ChatSessionProvider] Failed to refresh threads:", L);
3193
3193
  } finally {
3194
3194
  g(!1);
3195
3195
  }
@@ -3197,42 +3197,49 @@ function ox({
3197
3197
  Ue(async () => {
3198
3198
  try {
3199
3199
  await fe();
3200
- } catch (F) {
3201
- console.error("[ChatSessionProvider] Failed to refresh threads after stream:", F);
3200
+ } catch (L) {
3201
+ console.error("[ChatSessionProvider] Failed to refresh threads after stream:", L);
3202
3202
  }
3203
3203
  }, [fe]);
3204
3204
  const ye = ut(!1), B = Ue(
3205
- (F, J) => {
3206
- const Ce = Array.isArray(F == null ? void 0 : F.messages) ? F.messages : [];
3207
- J === "replace" ? _(Ce, {
3208
- checkpointId: (F == null ? void 0 : F.checkpointId) ?? null,
3209
- checkpointNs: (F == null ? void 0 : F.checkpointNs) ?? null
3210
- }) : J === "prepend" && Ce.length && V(Ce), I((F == null ? void 0 : F.nextCursor) ?? null), R(!!(F != null && F.hasMore)), N((Oe) => (F == null ? void 0 : F.checkpointId) ?? Oe ?? void 0), M((Oe) => (F == null ? void 0 : F.checkpointNs) ?? Oe ?? void 0);
3205
+ (L, X) => {
3206
+ const Ce = Array.isArray(L == null ? void 0 : L.messages) ? L.messages : [];
3207
+ X === "replace" ? _(Ce, {
3208
+ checkpointId: (L == null ? void 0 : L.checkpointId) ?? null,
3209
+ checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null
3210
+ }) : X === "prepend" && Ce.length && V(Ce), I((L == null ? void 0 : L.nextCursor) ?? null), R(!!(L != null && L.hasMore)), N((Oe) => (L == null ? void 0 : L.checkpointId) ?? Oe ?? void 0), M((Oe) => (L == null ? void 0 : L.checkpointNs) ?? Oe ?? void 0);
3211
3211
  },
3212
3212
  [V, _]
3213
3213
  ), P = Ue(() => {
3214
- L([]), R(!1), C(!1), I(null), N(void 0), M(void 0);
3215
- }, [L]), G = Ue(({ from: F, to: J }) => {
3214
+ F([]), R(!1), C(!1), I(null), N(void 0), M(void 0);
3215
+ }, [F]), G = Ue(({ from: L, to: X }) => {
3216
3216
  const Ce = k.current;
3217
3217
  Ce && console.warn(
3218
- `[ChatSessionProvider] Stream sequence gap detected (${F} -> ${J}) for thread ${Ce}`
3218
+ `[ChatSessionProvider] Stream sequence gap detected (${L} -> ${X}) for thread ${Ce}`
3219
3219
  );
3220
3220
  }, []), Z = Ue(
3221
- (F) => {
3222
- const J = F.threadId, Ce = {
3223
- threadId: J,
3224
- title: F.title || `Thread ${J.slice(0, 8)}`,
3225
- createdAt: F.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3226
- updatedAt: F.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3227
- messageCount: F.messageCount || 0
3221
+ (L) => {
3222
+ const X = L.threadId;
3223
+ console.log("[ChatSessionProvider] 📥 Handling thread_info event:", {
3224
+ threadId: X,
3225
+ title: L.title,
3226
+ created: L.created,
3227
+ currentThreads: f.length
3228
+ });
3229
+ const Ce = {
3230
+ threadId: X,
3231
+ title: L.title || `Thread ${X.slice(0, 8)}`,
3232
+ createdAt: L.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3233
+ updatedAt: L.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3234
+ messageCount: L.messageCount || 0
3228
3235
  };
3229
- k.current !== J && (!k.current && D.messages.length <= 1 && (re.current = J), w(J)), h((Oe) => {
3230
- const De = Oe.findIndex((it) => it.threadId === J);
3236
+ k.current !== X && (!k.current && D.messages.length <= 1 && (re.current = X), w(X)), h((Oe) => {
3237
+ const De = Oe.findIndex((it) => it.threadId === X);
3231
3238
  if (De >= 0) {
3232
3239
  const it = [...Oe];
3233
- return it[De] = Ce, it;
3240
+ return it[De] = Ce, console.log("[ChatSessionProvider] ✏️ Updated existing thread at index:", De), it;
3234
3241
  } else
3235
- return [Ce, ...Oe];
3242
+ return console.log("[ChatSessionProvider] ➕ Added new thread to list"), [Ce, ...Oe];
3236
3243
  });
3237
3244
  },
3238
3245
  [D.messages.length]
@@ -3240,8 +3247,8 @@ function ox({
3240
3247
  baseUrl: d,
3241
3248
  onThreadInfo: Z,
3242
3249
  onMessageEvent: q,
3243
- onUnhandledEvent: (F) => {
3244
- console.warn(`[ChatSessionProvider] Unhandled stream event: ${F.type}`, F);
3250
+ onUnhandledEvent: (L) => {
3251
+ console.warn(`[ChatSessionProvider] Unhandled stream event: ${L.type}`, L);
3245
3252
  },
3246
3253
  onSequenceGap: G
3247
3254
  });
@@ -3249,62 +3256,62 @@ function ox({
3249
3256
  ye.current = Me;
3250
3257
  }, [Me]), gt(() => {
3251
3258
  var Ce;
3252
- const F = l.getAuthToken();
3253
- Ye(F);
3254
- const J = (Ce = l.onTokenChange) == null ? void 0 : Ce.call(l, (Oe) => {
3259
+ const L = l.getAuthToken();
3260
+ Ye(L);
3261
+ const X = (Ce = l.onTokenChange) == null ? void 0 : Ce.call(l, (Oe) => {
3255
3262
  Ye(Oe);
3256
3263
  });
3257
3264
  return () => {
3258
- J == null || J();
3265
+ X == null || X();
3259
3266
  };
3260
3267
  }, [l, Ye]);
3261
3268
  const Ee = Ue(
3262
- async (F) => {
3263
- const J = `temp-${Date.now()}`, Ce = {
3264
- threadId: J,
3265
- title: F || "New Chat",
3269
+ async (L) => {
3270
+ const X = `temp-${Date.now()}`, Ce = {
3271
+ threadId: X,
3272
+ title: L || "New Chat",
3266
3273
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3267
3274
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
3268
3275
  messageCount: 0
3269
3276
  };
3270
- h((Oe) => [Ce, ...Oe]), w(J);
3277
+ h((Oe) => [Ce, ...Oe]), w(X);
3271
3278
  try {
3272
- const Oe = await l.createThread(F), De = typeof Oe == "string" ? Oe : Oe.threadId;
3279
+ const Oe = await l.createThread(L), De = typeof Oe == "string" ? Oe : Oe.threadId;
3273
3280
  return h((it) => it.map(
3274
- (At) => At.threadId === J ? { ...At, threadId: De } : At
3281
+ (At) => At.threadId === X ? { ...At, threadId: De } : At
3275
3282
  )), w(De), setTimeout(() => fe(), 10), De;
3276
3283
  } catch (Oe) {
3277
- throw h((De) => De.filter((it) => it.threadId !== J)), w(null), Oe;
3284
+ throw h((De) => De.filter((it) => it.threadId !== X)), w(null), Oe;
3278
3285
  }
3279
3286
  },
3280
3287
  [l, fe]
3281
3288
  ), _e = Ue(
3282
- async (F) => {
3283
- await l.deleteThread(F), k.current === F && (re.current = F, w(null), P()), await fe();
3289
+ async (L) => {
3290
+ await l.deleteThread(L), k.current === L && (re.current = L, w(null), P()), await fe();
3284
3291
  },
3285
3292
  [l, P, fe]
3286
3293
  ), Qe = Ue(
3287
- async (F, J) => {
3294
+ async (L, X) => {
3288
3295
  try {
3289
- await l.updateThread(F, J), h((Ce) => Ce.map((Oe) => Oe.threadId === F ? { ...Oe, title: J } : Oe));
3296
+ await l.updateThread(L, X), h((Ce) => Ce.map((Oe) => Oe.threadId === L ? { ...Oe, title: X } : Oe));
3290
3297
  } catch (Ce) {
3291
3298
  throw await fe(), Ce;
3292
3299
  }
3293
3300
  },
3294
3301
  [l, fe]
3295
3302
  ), je = Ue(
3296
- async (F, J, Ce, Oe = !1) => {
3303
+ async (L, X, Ce, Oe = !1) => {
3297
3304
  await de(async () => {
3298
- if (re.current === F && !Oe) {
3305
+ if (re.current === L && !Oe) {
3299
3306
  re.current = null;
3300
3307
  return;
3301
3308
  }
3302
- if (!(ue.current === F && !Oe)) {
3303
- w((De) => De === F ? De : F), ue.current = F, b(!0);
3309
+ if (!(ue.current === L && !Oe)) {
3310
+ w((De) => De === L ? De : L), ue.current = L, b(!0);
3304
3311
  try {
3305
3312
  const De = await l.getMessages({
3306
- threadId: F,
3307
- checkpointId: J,
3313
+ threadId: L,
3314
+ checkpointId: X,
3308
3315
  checkpointNs: Ce
3309
3316
  });
3310
3317
  B(De, "replace"), N((De == null ? void 0 : De.checkpointId) ?? void 0), M((De == null ? void 0 : De.checkpointNs) ?? void 0);
@@ -3314,7 +3321,7 @@ function ox({
3314
3321
  ue.current = null, b(!1);
3315
3322
  }
3316
3323
  }
3317
- }, `loadThread-${F}`);
3324
+ }, `loadThread-${L}`);
3318
3325
  },
3319
3326
  [l, B, de, i]
3320
3327
  ), st = Ue(async () => {
@@ -3322,39 +3329,39 @@ function ox({
3322
3329
  k.current && (re.current = k.current), w(null), P(), N(void 0), M(void 0);
3323
3330
  try {
3324
3331
  localStorage.removeItem("lastThreadId");
3325
- } catch (F) {
3326
- console.warn("[ChatSessionProvider] Failed to clear lastThreadId:", F);
3332
+ } catch (L) {
3333
+ console.warn("[ChatSessionProvider] Failed to clear lastThreadId:", L);
3327
3334
  }
3328
3335
  }, "clearCurrentThread");
3329
3336
  }, [P, de]), at = Ue(
3330
- async (F) => {
3331
- const J = await l.listCheckpoints(F);
3332
- return $g(J, F);
3337
+ async (L) => {
3338
+ const X = await l.listCheckpoints(L);
3339
+ return $g(X, L);
3333
3340
  },
3334
3341
  [l]
3335
3342
  ), Q = Ue(
3336
- async (F, J) => {
3343
+ async (L, X) => {
3337
3344
  if (!k.current) throw new Error("No active thread");
3338
- await je(k.current, F, J ?? void 0, !0);
3345
+ await je(k.current, L, X ?? void 0, !0);
3339
3346
  },
3340
3347
  [je]
3341
3348
  ), ae = Ue(async () => {
3342
3349
  if (!k.current) throw new Error("No active thread");
3343
3350
  await je(k.current, void 0, void 0, !0);
3344
3351
  }, [je]), he = Ue(
3345
- async (F) => {
3352
+ async (L) => {
3346
3353
  if (!k.current) throw new Error("No active thread");
3347
3354
  if (S || !y) return;
3348
- const J = E;
3349
- if (J) {
3355
+ const X = E;
3356
+ if (X) {
3350
3357
  C(!0);
3351
3358
  try {
3352
3359
  const Ce = await l.getMessages({
3353
3360
  threadId: k.current,
3354
3361
  checkpointId: j,
3355
3362
  checkpointNs: O,
3356
- limit: (F == null ? void 0 : F.limit) ?? rx,
3357
- beforeId: J
3363
+ limit: (L == null ? void 0 : L.limit) ?? rx,
3364
+ beforeId: X
3358
3365
  });
3359
3366
  B(Ce, "prepend");
3360
3367
  } finally {
@@ -3372,25 +3379,25 @@ function ox({
3372
3379
  S
3373
3380
  ]
3374
3381
  ), Se = Ue(
3375
- async (F, J) => {
3382
+ async (L, X) => {
3376
3383
  var bn;
3377
3384
  const Ce = k.current;
3378
- !Ce && !(J != null && J.payloadExtras) && console.warn("[ChatSessionProvider] No thread ID - message will create new thread");
3379
- const Oe = (J == null ? void 0 : J.attachments) || [], { contentParts: De, filesInfo: it } = await Bg(
3385
+ !Ce && !(X != null && X.payloadExtras) && console.warn("[ChatSessionProvider] No thread ID - message will create new thread");
3386
+ const Oe = (X == null ? void 0 : X.attachments) || [], { contentParts: De, filesInfo: it } = await Bg(
3380
3387
  l,
3381
3388
  Oe
3382
3389
  ), At = [...De];
3383
- F && F.trim() && At.push({ type: "text", text: F.trim() });
3390
+ L && L.trim() && At.push({ type: "text", text: L.trim() });
3384
3391
  const tr = {
3385
3392
  id: ((bn = crypto.randomUUID) == null ? void 0 : bn.call(crypto)) || `user-${Date.now()}`,
3386
3393
  role: "user",
3387
3394
  content: At,
3388
3395
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3389
- checkpointId: (J == null ? void 0 : J.checkpointId) ?? D.lastCheckpointId ?? void 0,
3390
- checkpointNs: (J == null ? void 0 : J.checkpointNs) ?? D.lastCheckpointNs ?? void 0
3396
+ checkpointId: (X == null ? void 0 : X.checkpointId) ?? D.lastCheckpointId ?? void 0,
3397
+ checkpointNs: (X == null ? void 0 : X.checkpointNs) ?? D.lastCheckpointNs ?? void 0
3391
3398
  };
3392
3399
  U(tr);
3393
- const Pn = { ...tr, content: At }, nr = { ...(J == null ? void 0 : J.payloadExtras) ?? {} }, Qt = Oe.length > 0, On = {
3400
+ const Pn = { ...tr, content: At }, nr = { ...(X == null ? void 0 : X.payloadExtras) ?? {} }, Qt = Oe.length > 0, On = {
3394
3401
  ...Ce ? { threadId: Ce } : {},
3395
3402
  payload: {
3396
3403
  messages: [Pn],
@@ -3398,10 +3405,10 @@ function ox({
3398
3405
  ...o && Qt && s ? { active_agent: s } : {},
3399
3406
  ...nr
3400
3407
  },
3401
- checkpointId: (J == null ? void 0 : J.checkpointId) ?? D.lastCheckpointId ?? void 0,
3402
- checkpointNs: (J == null ? void 0 : J.checkpointNs) ?? D.lastCheckpointNs ?? void 0,
3403
- nodeFilter: J == null ? void 0 : J.nodeFilter,
3404
- config: J == null ? void 0 : J.config
3408
+ checkpointId: (X == null ? void 0 : X.checkpointId) ?? D.lastCheckpointId ?? void 0,
3409
+ checkpointNs: (X == null ? void 0 : X.checkpointNs) ?? D.lastCheckpointNs ?? void 0,
3410
+ nodeFilter: X == null ? void 0 : X.nodeFilter,
3411
+ config: X == null ? void 0 : X.config
3405
3412
  };
3406
3413
  le(On, {
3407
3414
  onError: (en) => {
@@ -3425,15 +3432,15 @@ function ox({
3425
3432
  le
3426
3433
  ]
3427
3434
  ), ve = Ue(
3428
- async (F, J, Ce) => {
3435
+ async (L, X, Ce) => {
3429
3436
  const Oe = k.current;
3430
3437
  if (!Oe)
3431
3438
  throw new Error("No active thread to handle interrupt");
3432
3439
  try {
3433
- const De = J ? Ce ?? !0 : !1;
3440
+ const De = X ? Ce ?? !0 : !1;
3434
3441
  await l.resume({ threadId: Oe, value: De });
3435
3442
  } catch (De) {
3436
- throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${F}:`, De), De;
3443
+ throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${L}:`, De), De;
3437
3444
  }
3438
3445
  },
3439
3446
  [l]
@@ -3442,14 +3449,14 @@ function ox({
3442
3449
  if (a == null || a(p), p)
3443
3450
  try {
3444
3451
  localStorage.setItem("lastThreadId", p);
3445
- } catch (F) {
3446
- console.warn("[ChatSessionProvider] Failed to persist lastThreadId:", F);
3452
+ } catch (L) {
3453
+ console.warn("[ChatSessionProvider] Failed to persist lastThreadId:", L);
3447
3454
  }
3448
3455
  }, [p, a]), gt(() => {
3449
- let F = !0;
3456
+ let L = !0;
3450
3457
  return (async () => {
3451
3458
  try {
3452
- if (await fe(), !F) return;
3459
+ if (await fe(), !L) return;
3453
3460
  if (!r && !t)
3454
3461
  try {
3455
3462
  const Ce = localStorage.getItem("lastThreadId");
@@ -3462,7 +3469,7 @@ function ox({
3462
3469
  console.error("[ChatSessionProvider] Initialization failed:", Ce), i == null || i(String(Ce));
3463
3470
  }
3464
3471
  })(), () => {
3465
- F = !1;
3472
+ L = !1;
3466
3473
  };
3467
3474
  }, []);
3468
3475
  const Ne = pt(
@@ -3582,7 +3589,7 @@ function Vs({
3582
3589
  }
3583
3590
  ) });
3584
3591
  }
3585
- function X(...e) {
3592
+ function J(...e) {
3586
3593
  return nm(tm(e));
3587
3594
  }
3588
3595
  const ix = ts(
@@ -3615,7 +3622,7 @@ const ix = ts(
3615
3622
  return /* @__PURE__ */ c.jsx(
3616
3623
  i,
3617
3624
  {
3618
- className: X(ix({ variant: t, size: n, className: e })),
3625
+ className: J(ix({ variant: t, size: n, className: e })),
3619
3626
  ref: s,
3620
3627
  ...o
3621
3628
  }
@@ -3627,7 +3634,7 @@ const nu = m.forwardRef(
3627
3634
  ({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
3628
3635
  "textarea",
3629
3636
  {
3630
- className: X(
3637
+ className: J(
3631
3638
  "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
3632
3639
  e
3633
3640
  ),
@@ -4780,9 +4787,9 @@ const Qr = We(
4780
4787
  D,
4781
4788
  _
4782
4789
  ]) => {
4783
- const V = xu(R), { align: U, behavior: q, offset: L } = V, k = E - 1, W = mu(V, S, k);
4790
+ const V = xu(R), { align: U, behavior: q, offset: F } = V, k = E - 1, W = mu(V, S, k);
4784
4791
  let Y = Br(W, S.offsetTree, M) + j;
4785
- U === "end" ? (Y += D + Gt(S.sizeTree, W)[1] - C + _, W === k && (Y += N)) : U === "center" ? Y += (D + Gt(S.sizeTree, W)[1] - C + _) / 2 : Y -= I, L && (Y += L);
4792
+ U === "end" ? (Y += D + Gt(S.sizeTree, W)[1] - C + _, W === k && (Y += N)) : U === "center" ? Y += (D + Gt(S.sizeTree, W)[1] - C + _) / 2 : Y -= I, F && (Y += F);
4786
4793
  const ue = (re) => {
4787
4794
  y(), re ? (O("retrying to scroll to", { location: R }, Nt.DEBUG), Ae(p, R)) : (Ae(w, !0), O("list did not change, scroll successful", {}, Nt.DEBUG));
4788
4795
  };
@@ -5210,12 +5217,12 @@ const Jn = We(
5210
5217
  _,
5211
5218
  V
5212
5219
  ]) => {
5213
- const U = j, { offsetTree: q, sizeTree: L } = U, k = ct(g);
5220
+ const U = j, { offsetTree: q, sizeTree: F } = U, k = ct(g);
5214
5221
  if (I === 0)
5215
5222
  return { ...qs, totalCount: I };
5216
5223
  if (C === 0 && E === 0)
5217
5224
  return k === 0 ? { ...qs, totalCount: I } : wu(k, N, j, D, _, V || []);
5218
- if (Je(L))
5225
+ if (Je(F))
5219
5226
  return k > 0 ? null : Ro(
5220
5227
  $x(ta(N, I), U, V),
5221
5228
  [],
@@ -5228,7 +5235,7 @@ const Jn = We(
5228
5235
  if (M.length > 0) {
5229
5236
  const fe = M[0], ye = M[M.length - 1];
5230
5237
  let B = 0;
5231
- for (const P of us(L, fe, ye)) {
5238
+ for (const P of us(F, fe, ye)) {
5232
5239
  const G = P.value, Z = Math.max(P.start, fe), le = Math.min(P.end, ye);
5233
5240
  for (let oe = Z; oe <= le; oe++)
5234
5241
  W.push({ data: V == null ? void 0 : V[oe], index: oe, offset: B, size: G }), B += G;
@@ -6417,7 +6424,7 @@ const Cv = /* @__PURE__ */ We(
6417
6424
  { customScrollParent: g, useWindowScroll: x, windowScrollContainerState: b, windowScrollTo: y, windowViewportRect: R },
6418
6425
  S
6419
6426
  ]) => {
6420
- const C = K(0), E = K(0), I = K(Il), j = K({ height: 0, width: 0 }), N = K({ height: 0, width: 0 }), O = ze(), M = ze(), D = K(0), _ = K(null), V = K({ column: 0, row: 0 }), U = ze(), q = ze(), L = K(!1), k = K(0), W = K(!0), Y = K(!1), ue = K(!1);
6427
+ const C = K(0), E = K(0), I = K(Il), j = K({ height: 0, width: 0 }), N = K({ height: 0, width: 0 }), O = ze(), M = ze(), D = K(0), _ = K(null), V = K({ column: 0, row: 0 }), U = ze(), q = ze(), F = K(!1), k = K(0), W = K(!0), Y = K(!1), ue = K(!1);
6421
6428
  qe(
6422
6429
  $(
6423
6430
  w,
@@ -6453,8 +6460,8 @@ const Cv = /* @__PURE__ */ We(
6453
6460
  be(([, P]) => P != null)
6454
6461
  ),
6455
6462
  ([, P]) => {
6456
- P && (Ae(j, P.viewport), Ae(N, P.item), Ae(V, P.gap), P.scrollTop > 0 && (Ae(L, !0), qt($(u, Wn(1)), (G) => {
6457
- Ae(L, !1);
6463
+ P && (Ae(j, P.viewport), Ae(N, P.item), Ae(V, P.gap), P.scrollTop > 0 && (Ae(F, !0), qt($(u, Wn(1)), (G) => {
6464
+ Ae(F, !1);
6458
6465
  }), Ae(l, { top: P.scrollTop })));
6459
6466
  }
6460
6467
  ), ce(
@@ -6489,7 +6496,7 @@ const Cv = /* @__PURE__ */ We(
6489
6496
  we(j, fo),
6490
6497
  we(_),
6491
6498
  we(E),
6492
- we(L),
6499
+ we(F),
6493
6500
  we(W),
6494
6501
  we(k)
6495
6502
  ),
@@ -6511,14 +6518,14 @@ const Cv = /* @__PURE__ */ We(
6511
6518
  if (Ye === 0 && (P === 0 || Q === 0))
6512
6519
  return Il;
6513
6520
  if (at === 0) {
6514
- const J = ta(_e, P), Ce = J + Math.max(Ye - 1, 0);
6515
- return yv(jl(J, Ce, Ge));
6521
+ const X = ta(_e, P), Ce = X + Math.max(Ye - 1, 0);
6522
+ return yv(jl(X, Ce, Ge));
6516
6523
  }
6517
6524
  const ae = Ou(Q, at, Qe);
6518
6525
  let he, Se;
6519
6526
  Ee ? G === 0 && Z === 0 && Ye > 0 ? (he = 0, Se = Ye - 1) : (he = ae * zo((G + je) / (st + je)), Se = ae * Nl((Z + je) / (st + je)) - 1, Se = Xs(P - 1, Pr(Se, ae - 1)), he = Xs(Se, Pr(0, he))) : (he = 0, Se = -1);
6520
- const ve = jl(he, Se, Ge), { bottom: Ne, top: et } = _l(Me, le, oe, ve), Ve = Nl(P / ae), F = Ve * st + (Ve - 1) * je - Ne;
6521
- return { bottom: Ne, itemHeight: st, items: ve, itemWidth: at, offsetBottom: F, offsetTop: et, top: et };
6527
+ const ve = jl(he, Se, Ge), { bottom: Ne, top: et } = _l(Me, le, oe, ve), Ve = Nl(P / ae), L = Ve * st + (Ve - 1) * je - Ne;
6528
+ return { bottom: Ne, itemHeight: st, items: ve, itemWidth: at, offsetBottom: L, offsetTop: et, top: et };
6522
6529
  }
6523
6530
  )
6524
6531
  ),
@@ -6573,7 +6580,7 @@ const Cv = /* @__PURE__ */ We(
6573
6580
  ), ye = Mt(
6574
6581
  $(
6575
6582
  we(I),
6576
- Pe(L),
6583
+ Pe(F),
6577
6584
  be(([{ items: P }, G]) => P.length > 0 && !G),
6578
6585
  te(([{ items: P }]) => ({
6579
6586
  endIndex: P[P.length - 1].index,
@@ -6648,7 +6655,7 @@ const Cv = /* @__PURE__ */ We(
6648
6655
  rangeChanged: ye,
6649
6656
  startReached: fe,
6650
6657
  stateChanged: U,
6651
- stateRestoreInProgress: L,
6658
+ stateRestoreInProgress: F,
6652
6659
  ...S
6653
6660
  };
6654
6661
  },
@@ -6869,7 +6876,7 @@ const Ov = ts(
6869
6876
  }
6870
6877
  );
6871
6878
  function Ei({ className: e, variant: t, ...n }) {
6872
- return /* @__PURE__ */ c.jsx("div", { className: X(Ov({ variant: t }), e), ...n });
6879
+ return /* @__PURE__ */ c.jsx("div", { className: J(Ov({ variant: t }), e), ...n });
6873
6880
  }
6874
6881
  function ie(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
6875
6882
  return function(o) {
@@ -7221,7 +7228,7 @@ const Ml = Xv, Dl = $u, Or = m.forwardRef(({ className: e, ...t }, n) => /* @__P
7221
7228
  "div",
7222
7229
  {
7223
7230
  ref: n,
7224
- className: X(
7231
+ className: J(
7225
7232
  "rounded-lg border bg-card text-card-foreground shadow-sm",
7226
7233
  e
7227
7234
  ),
@@ -7233,7 +7240,7 @@ const Mr = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
7233
7240
  "div",
7234
7241
  {
7235
7242
  ref: n,
7236
- className: X("flex flex-col space-y-1.5 p-6", e),
7243
+ className: J("flex flex-col space-y-1.5 p-6", e),
7237
7244
  ...t
7238
7245
  }
7239
7246
  ));
@@ -7242,7 +7249,7 @@ const Dr = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
7242
7249
  "h3",
7243
7250
  {
7244
7251
  ref: n,
7245
- className: X(
7252
+ className: J(
7246
7253
  "text-2xl font-semibold leading-none tracking-tight",
7247
7254
  e
7248
7255
  ),
@@ -7254,18 +7261,18 @@ const zu = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
7254
7261
  "p",
7255
7262
  {
7256
7263
  ref: n,
7257
- className: X("text-sm text-muted-foreground", e),
7264
+ className: J("text-sm text-muted-foreground", e),
7258
7265
  ...t
7259
7266
  }
7260
7267
  ));
7261
7268
  zu.displayName = "CardDescription";
7262
- const Eo = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx("div", { ref: n, className: X("p-6 pt-0", e), ...t }));
7269
+ const Eo = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx("div", { ref: n, className: J("p-6 pt-0", e), ...t }));
7263
7270
  Eo.displayName = "CardContent";
7264
7271
  const Bu = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
7265
7272
  "div",
7266
7273
  {
7267
7274
  ref: n,
7268
- className: X("flex items-center p-6 pt-0", e),
7275
+ className: J("flex items-center p-6 pt-0", e),
7269
7276
  ...t
7270
7277
  }
7271
7278
  ));
@@ -8838,7 +8845,7 @@ function Ul({
8838
8845
  return /* @__PURE__ */ c.jsx(
8839
8846
  "div",
8840
8847
  {
8841
- className: X("markdown prose max-w-none break-words dark:prose-invert", t),
8848
+ className: J("markdown prose max-w-none break-words dark:prose-invert", t),
8842
8849
  dangerouslySetInnerHTML: { __html: r }
8843
8850
  }
8844
8851
  );
@@ -9999,7 +10006,7 @@ const _b = Cd, Pb = Td, Ed = m.forwardRef(({ className: e, ...t }, n) => /* @__P
9999
10006
  bs,
10000
10007
  {
10001
10008
  ref: n,
10002
- className: X(
10009
+ className: J(
10003
10010
  "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
10004
10011
  e
10005
10012
  ),
@@ -10029,7 +10036,7 @@ const kd = m.forwardRef(({ className: e, children: t, ...n }, r) => {
10029
10036
  ys,
10030
10037
  {
10031
10038
  ref: r,
10032
- className: X(
10039
+ className: J(
10033
10040
  "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
10034
10041
  e
10035
10042
  ),
@@ -10053,7 +10060,7 @@ const Id = ({
10053
10060
  }) => /* @__PURE__ */ c.jsx(
10054
10061
  "div",
10055
10062
  {
10056
- className: X(
10063
+ className: J(
10057
10064
  "flex flex-col space-y-1.5 text-center sm:text-left",
10058
10065
  e
10059
10066
  ),
@@ -10065,7 +10072,7 @@ const Nd = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
10065
10072
  Bn,
10066
10073
  {
10067
10074
  ref: n,
10068
- className: X(
10075
+ className: J(
10069
10076
  "text-lg font-semibold leading-none tracking-tight",
10070
10077
  e
10071
10078
  ),
@@ -10077,7 +10084,7 @@ const Ob = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
10077
10084
  Ss,
10078
10085
  {
10079
10086
  ref: n,
10080
- className: X("text-sm text-muted-foreground", e),
10087
+ className: J("text-sm text-muted-foreground", e),
10081
10088
  ...t
10082
10089
  }
10083
10090
  ));
@@ -10352,7 +10359,7 @@ function Hb({ className: e }) {
10352
10359
  "span",
10353
10360
  {
10354
10361
  "aria-live": "polite",
10355
- className: X("inline-block text-xs opacity-70 ml-1", e),
10362
+ className: J("inline-block text-xs opacity-70 ml-1", e),
10356
10363
  children: [
10357
10364
  "Is thinking",
10358
10365
  ".".repeat(t)
@@ -10379,8 +10386,8 @@ const Ub = z.memo(function({
10379
10386
  onCancelEdit: g,
10380
10387
  onCopy: x
10381
10388
  }) {
10382
- const [b, y] = pe(!1), [R, S] = pe("collapsed"), [C, E] = pe(!1), { currentThreadId: I } = Gi(), { handleInterrupt: j } = tu(), { toast: N } = ha(), [O, M] = pe({}), [D, _] = pe(!1), [V, U] = pe(null), q = l === "phone" || l === "half-screen", L = t.role, k = L === "tool", W = !(r && L !== "user"), Y = z.useMemo(() => {
10383
- switch (L) {
10389
+ const [b, y] = pe(!1), [R, S] = pe("collapsed"), [C, E] = pe(!1), { currentThreadId: I } = Gi(), { handleInterrupt: j } = tu(), { toast: N } = ha(), [O, M] = pe({}), [D, _] = pe(!1), [V, U] = pe(null), q = l === "phone" || l === "half-screen", F = t.role, k = F === "tool", W = !(r && F !== "user"), Y = z.useMemo(() => {
10390
+ switch (F) {
10384
10391
  case "user":
10385
10392
  return "text-[hsl(var(--chat-bubble-user-text))]";
10386
10393
  case "assistant":
@@ -10392,7 +10399,7 @@ const Ub = z.memo(function({
10392
10399
  default:
10393
10400
  return "text-[hsl(var(--chat-bubble-ai-text))]";
10394
10401
  }
10395
- }, [L]), ue = pt(() => Db(t.content), [t.content]), re = pt(() => Lb(t.content), [t.content]), de = pt(
10402
+ }, [F]), ue = pt(() => Db(t.content), [t.content]), re = pt(() => Lb(t.content), [t.content]), de = pt(
10396
10403
  () => t.content.filter((Q) => Q.type === "image_url"),
10397
10404
  [t.content]
10398
10405
  ), fe = pt(
@@ -10453,22 +10460,22 @@ const Ub = z.memo(function({
10453
10460
  const Ve = await mw(I ?? void 0);
10454
10461
  if (!Ve || !Array.isArray(Ve))
10455
10462
  throw new Error("Invalid file list response");
10456
- const F = Ve.find((J) => !J || typeof J != "object" || !((J.filename ?? "") === (ae.name ?? "")) ? !1 : typeof ae.size == "number" && typeof J.size == "number" ? J.size === ae.size : !0);
10457
- if (!(F != null && F.id))
10463
+ const L = Ve.find((X) => !X || typeof X != "object" || !((X.filename ?? "") === (ae.name ?? "")) ? !1 : typeof ae.size == "number" && typeof X.size == "number" ? X.size === ae.size : !0);
10464
+ if (!(L != null && L.id))
10458
10465
  throw new Error(`File "${ae.name}" is not yet available on the server`);
10459
- if (!F.id || !F.filename)
10466
+ if (!L.id || !L.filename)
10460
10467
  throw new Error("Invalid file data received from server");
10461
10468
  U({
10462
- id: F.id,
10463
- name: ae.name || F.filename || `file_${F.id}`,
10464
- mimeType: ae.mimeType || F.mime_type || "application/octet-stream"
10469
+ id: L.id,
10470
+ name: ae.name || L.filename || `file_${L.id}`,
10471
+ mimeType: ae.mimeType || L.mime_type || "application/octet-stream"
10465
10472
  }), _(!0), et.update({ id: et.id, title: "Success", description: `Opened ${ae.name}`, open: !0 });
10466
10473
  } catch (Ve) {
10467
10474
  console.error("Failed to fetch server file:", Ve);
10468
- const F = Ve instanceof Error ? Ve.message : "Unknown error occurred";
10469
- et.update({ id: et.id, title: "Failed", description: F }), N({
10475
+ const L = Ve instanceof Error ? Ve.message : "Unknown error occurred";
10476
+ et.update({ id: et.id, title: "Failed", description: L }), N({
10470
10477
  title: "Failed to fetch file",
10471
- description: F,
10478
+ description: L,
10472
10479
  open: !0
10473
10480
  });
10474
10481
  } finally {
@@ -10479,8 +10486,8 @@ const Ub = z.memo(function({
10479
10486
  console.error("File click error:", Se), M((ve) => ({ ...ve, [he]: !1 }));
10480
10487
  }
10481
10488
  }, [W, O, N, I]), Me = z.useCallback(() => {
10482
- const ae = X(q ? "h-3 w-3" : "h-4 w-4", "opacity-60 flex-shrink-0", Y);
10483
- switch (L) {
10489
+ const ae = J(q ? "h-3 w-3" : "h-4 w-4", "opacity-60 flex-shrink-0", Y);
10490
+ switch (F) {
10484
10491
  case "user":
10485
10492
  return /* @__PURE__ */ c.jsx(Fp, { className: ae });
10486
10493
  case "assistant":
@@ -10490,51 +10497,51 @@ const Ub = z.memo(function({
10490
10497
  default:
10491
10498
  return /* @__PURE__ */ c.jsx(Ua, { className: ae });
10492
10499
  }
10493
- }, [q, Y, L]), Ge = z.useCallback(() => {
10500
+ }, [q, Y, F]), Ge = z.useCallback(() => {
10494
10501
  const Q = "group relative mb-4 flex w-full";
10495
- switch (L) {
10502
+ switch (F) {
10496
10503
  case "user":
10497
- return X(Q, "justify-end");
10504
+ return J(Q, "justify-end");
10498
10505
  case "assistant":
10499
10506
  case "tool":
10500
10507
  case "system":
10501
- return X(Q, "justify-start");
10508
+ return J(Q, "justify-start");
10502
10509
  default:
10503
10510
  return Q;
10504
10511
  }
10505
- }, [L]), Ye = z.useCallback(() => {
10506
- const Q = X(
10512
+ }, [F]), Ye = z.useCallback(() => {
10513
+ const Q = J(
10507
10514
  "rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",
10508
10515
  q && "px-3 py-2 text-sm"
10509
10516
  );
10510
- switch (L) {
10517
+ switch (F) {
10511
10518
  case "user":
10512
- return X(
10519
+ return J(
10513
10520
  Q,
10514
10521
  "w-full md:max-w-[95%]",
10515
10522
  "bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]",
10516
10523
  "border border-transparent"
10517
10524
  );
10518
10525
  case "assistant":
10519
- return X(
10526
+ return J(
10520
10527
  Q,
10521
10528
  "w-full md:max-w-[95%]",
10522
10529
  "bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]",
10523
10530
  "border border-border/60 dark:border-border/40"
10524
10531
  );
10525
10532
  case "tool":
10526
- return X(Q, "w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");
10533
+ return J(Q, "w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");
10527
10534
  case "system":
10528
- return X(Q, "w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");
10535
+ return J(Q, "w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");
10529
10536
  default:
10530
- return X(
10537
+ return J(
10531
10538
  Q,
10532
10539
  "w-full md:max-w-[95%]",
10533
10540
  "bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]",
10534
10541
  "border border-border/60 dark:border-border/40"
10535
10542
  );
10536
10543
  }
10537
- }, [q, L]), Ee = z.useCallback(async (Q) => {
10544
+ }, [q, F]), Ee = z.useCallback(async (Q) => {
10538
10545
  try {
10539
10546
  const ae = Q.id || `interrupt-${Date.now()}`;
10540
10547
  await j(ae, !0);
@@ -10551,8 +10558,8 @@ const Ub = z.memo(function({
10551
10558
  }, [j]), Qe = z.useCallback(({ part: Q, i: ae }) => {
10552
10559
  if (Q.type === "text") {
10553
10560
  const he = Q.text ?? "", Se = he.trim(), ve = oc(Se);
10554
- return ve && L !== "tool" ? /* @__PURE__ */ c.jsx(Wb, { data: ve }, ae) : L === "user" && f && Se.length > h ? /* @__PURE__ */ c.jsxs(Ml, { open: C, onOpenChange: E, children: [
10555
- /* @__PURE__ */ c.jsx("div", { className: X("text-sm text-[hsl(var(--chat-bubble-user-text))]", q && "text-xs"), children: C ? /* @__PURE__ */ c.jsx(Ul, { content: Se, allowHtml: !1 }) : /* @__PURE__ */ c.jsxs("pre", { className: X("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]", q && "text-xs"), children: [
10561
+ return ve && F !== "tool" ? /* @__PURE__ */ c.jsx(Wb, { data: ve }, ae) : F === "user" && f && Se.length > h ? /* @__PURE__ */ c.jsxs(Ml, { open: C, onOpenChange: E, children: [
10562
+ /* @__PURE__ */ c.jsx("div", { className: J("text-sm text-[hsl(var(--chat-bubble-user-text))]", q && "text-xs"), children: C ? /* @__PURE__ */ c.jsx(Ul, { content: Se, allowHtml: !1 }) : /* @__PURE__ */ c.jsxs("pre", { className: J("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]", q && "text-xs"), children: [
10556
10563
  Se.substring(0, h),
10557
10564
  "..."
10558
10565
  ] }) }),
@@ -10621,7 +10628,7 @@ const Ub = z.memo(function({
10621
10628
  O,
10622
10629
  Ee,
10623
10630
  _e,
10624
- L,
10631
+ F,
10625
10632
  f,
10626
10633
  h,
10627
10634
  C,
@@ -10685,11 +10692,11 @@ const Ub = z.memo(function({
10685
10692
  Y
10686
10693
  ]), at = pt(() => Bb(t), [t]);
10687
10694
  return /* @__PURE__ */ c.jsxs(c.Fragment, { children: [
10688
- /* @__PURE__ */ c.jsx("div", { className: X(Ge(), p.container), children: /* @__PURE__ */ c.jsxs("div", { className: X(Ye(), p.content), children: [
10695
+ /* @__PURE__ */ c.jsx("div", { className: J(Ge(), p.container), children: /* @__PURE__ */ c.jsxs("div", { className: J(Ye(), p.content), children: [
10689
10696
  (i || a || k) && /* @__PURE__ */ c.jsxs(
10690
10697
  "div",
10691
10698
  {
10692
- className: X(
10699
+ className: J(
10693
10700
  "flex items-center justify-between mb-2 pb-2 border-b border-current/10",
10694
10701
  q && "mb-1 pb-1",
10695
10702
  Y,
@@ -10698,12 +10705,12 @@ const Ub = z.memo(function({
10698
10705
  children: [
10699
10706
  /* @__PURE__ */ c.jsxs("div", { className: "flex items-center gap-2", children: [
10700
10707
  Me(),
10701
- a && at && /* @__PURE__ */ c.jsx("span", { className: X("font-medium", q ? "text-xs" : "text-sm"), children: at }),
10708
+ a && at && /* @__PURE__ */ c.jsx("span", { className: J("font-medium", q ? "text-xs" : "text-sm"), children: at }),
10702
10709
  k && re.name && /* @__PURE__ */ c.jsxs(
10703
10710
  Ei,
10704
10711
  {
10705
10712
  variant: "outline",
10706
- className: X(
10713
+ className: J(
10707
10714
  "text-xs flex items-center gap-1 cursor-pointer",
10708
10715
  Y,
10709
10716
  "border border-current/40",
@@ -10727,7 +10734,7 @@ const Ub = z.memo(function({
10727
10734
  {
10728
10735
  variant: "ghost",
10729
10736
  size: "sm",
10730
- className: X("h-6 px-1", Y, "hover:bg-foreground/10"),
10737
+ className: J("h-6 px-1", Y, "hover:bg-foreground/10"),
10731
10738
  onClick: () => S((Q) => Q === "collapsed" ? "preview" : "collapsed"),
10732
10739
  children: /* @__PURE__ */ c.jsxs("span", { className: "text-xs flex items-center gap-1", children: [
10733
10740
  "Tool Output ",
@@ -10740,7 +10747,7 @@ const Ub = z.memo(function({
10740
10747
  i && t.createdAt && /* @__PURE__ */ c.jsx(
10741
10748
  "time",
10742
10749
  {
10743
- className: X("text-xs opacity-60", Y, q && "text-xs"),
10750
+ className: J("text-xs opacity-60", Y, q && "text-xs"),
10744
10751
  dateTime: new Date(t.createdAt).toISOString(),
10745
10752
  title: new Date(t.createdAt).toLocaleString(),
10746
10753
  children: new Intl.DateTimeFormat(void 0, { hour: "2-digit", minute: "2-digit" }).format(new Date(t.createdAt))
@@ -10749,7 +10756,7 @@ const Ub = z.memo(function({
10749
10756
  s && !o && /* @__PURE__ */ c.jsxs(
10750
10757
  "div",
10751
10758
  {
10752
- className: X(
10759
+ className: J(
10753
10760
  "opacity-0 group-hover:opacity-100 transition-opacity",
10754
10761
  "flex items-center gap-1",
10755
10762
  p.actions
@@ -10762,10 +10769,10 @@ const Ub = z.memo(function({
10762
10769
  variant: "ghost",
10763
10770
  size: "sm",
10764
10771
  onClick: () => G(k ? "visible" : "all"),
10765
- className: X("h-6 w-6 p-0 hover:bg-foreground/10", Y, q && "h-5 w-5"),
10772
+ className: J("h-6 w-6 p-0 hover:bg-foreground/10", Y, q && "h-5 w-5"),
10766
10773
  "aria-label": k ? "Copy visible" : "Copy message",
10767
10774
  title: k ? "Copy visible portion" : "Copy message",
10768
- children: /* @__PURE__ */ c.jsx(Wa, { className: X(b ? "text-success" : Y, q ? "h-3 w-3" : "h-4 w-4") })
10775
+ children: /* @__PURE__ */ c.jsx(Wa, { className: J(b ? "text-success" : Y, q ? "h-3 w-3" : "h-4 w-4") })
10769
10776
  }
10770
10777
  ),
10771
10778
  k && /* @__PURE__ */ c.jsx(
@@ -10774,33 +10781,33 @@ const Ub = z.memo(function({
10774
10781
  variant: "ghost",
10775
10782
  size: "sm",
10776
10783
  onClick: () => G("all"),
10777
- className: X("h-6 px-1 text-xs hover:bg-foreground/10", Y),
10784
+ className: J("h-6 px-1 text-xs hover:bg-foreground/10", Y),
10778
10785
  "aria-label": "Copy all (may be large)",
10779
10786
  title: "Copy all (may be large)",
10780
10787
  children: "all"
10781
10788
  }
10782
10789
  )
10783
10790
  ] }),
10784
- L === "user" && w && /* @__PURE__ */ c.jsx(
10791
+ F === "user" && w && /* @__PURE__ */ c.jsx(
10785
10792
  He,
10786
10793
  {
10787
10794
  variant: "ghost",
10788
10795
  size: "sm",
10789
10796
  onClick: Z,
10790
- className: X("h-6 w-6 p-0 hover:bg-foreground/10", Y, q && "h-5 w-5"),
10797
+ className: J("h-6 w-6 p-0 hover:bg-foreground/10", Y, q && "h-5 w-5"),
10791
10798
  "aria-label": "Edit message",
10792
- children: /* @__PURE__ */ c.jsx(Va, { className: X(Y, q ? "h-3 w-3" : "h-4 w-4") })
10799
+ children: /* @__PURE__ */ c.jsx(Va, { className: J(Y, q ? "h-3 w-3" : "h-4 w-4") })
10793
10800
  }
10794
10801
  ),
10795
- L === "assistant" && v && /* @__PURE__ */ c.jsx(
10802
+ F === "assistant" && v && /* @__PURE__ */ c.jsx(
10796
10803
  He,
10797
10804
  {
10798
10805
  variant: "ghost",
10799
10806
  size: "sm",
10800
10807
  onClick: le,
10801
- className: X("h-6 w-6 p-0 hover:bg-foreground/10", Y, q && "h-5 w-5"),
10808
+ className: J("h-6 w-6 p-0 hover:bg-foreground/10", Y, q && "h-5 w-5"),
10802
10809
  "aria-label": "Regenerate response",
10803
- children: /* @__PURE__ */ c.jsx(di, { className: X(Y, q ? "h-3 w-3" : "h-4 w-4") })
10810
+ children: /* @__PURE__ */ c.jsx(di, { className: J(Y, q ? "h-3 w-3" : "h-4 w-4") })
10804
10811
  }
10805
10812
  )
10806
10813
  ]
@@ -10811,7 +10818,7 @@ const Ub = z.memo(function({
10811
10818
  }
10812
10819
  ),
10813
10820
  /* @__PURE__ */ c.jsx("div", { className: "relative", children: st() }),
10814
- k && R === "expanded" && (re.toolCallId || re.name) && /* @__PURE__ */ c.jsxs("div", { className: X("mt-2 pt-2 border-t border-current/10 text-xs opacity-60", q && "text-xs"), children: [
10821
+ k && R === "expanded" && (re.toolCallId || re.name) && /* @__PURE__ */ c.jsxs("div", { className: J("mt-2 pt-2 border-t border-current/10 text-xs opacity-60", q && "text-xs"), children: [
10815
10822
  re.name && /* @__PURE__ */ c.jsxs("div", { children: [
10816
10823
  "Function: ",
10817
10824
  re.name
@@ -10824,7 +10831,7 @@ const Ub = z.memo(function({
10824
10831
  !(i || a || k) && s && !o && /* @__PURE__ */ c.jsxs(
10825
10832
  "div",
10826
10833
  {
10827
- className: X(
10834
+ className: J(
10828
10835
  "absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",
10829
10836
  "flex items-center gap-1",
10830
10837
  p.actions
@@ -10836,28 +10843,28 @@ const Ub = z.memo(function({
10836
10843
  variant: "ghost",
10837
10844
  size: "sm",
10838
10845
  onClick: () => G(),
10839
- className: X("h-6 w-6 p-0 hover:bg-background/50 text-current", q && "h-5 w-5"),
10840
- children: /* @__PURE__ */ c.jsx(Wa, { className: X(b ? "text-success" : "text-current", q ? "h-3 w-3" : "h-4 w-4") })
10846
+ className: J("h-6 w-6 p-0 hover:bg-background/50 text-current", q && "h-5 w-5"),
10847
+ children: /* @__PURE__ */ c.jsx(Wa, { className: J(b ? "text-success" : "text-current", q ? "h-3 w-3" : "h-4 w-4") })
10841
10848
  }
10842
10849
  ),
10843
- L === "user" && w && /* @__PURE__ */ c.jsx(
10850
+ F === "user" && w && /* @__PURE__ */ c.jsx(
10844
10851
  He,
10845
10852
  {
10846
10853
  variant: "ghost",
10847
10854
  size: "sm",
10848
10855
  onClick: Z,
10849
- className: X("h-6 w-6 p-0 hover:bg-background/50 text-current", q && "h-5 w-5"),
10850
- children: /* @__PURE__ */ c.jsx(Va, { className: X("text-current", q ? "h-3 w-3" : "h-4 w-4") })
10856
+ className: J("h-6 w-6 p-0 hover:bg-background/50 text-current", q && "h-5 w-5"),
10857
+ children: /* @__PURE__ */ c.jsx(Va, { className: J("text-current", q ? "h-3 w-3" : "h-4 w-4") })
10851
10858
  }
10852
10859
  ),
10853
- L === "assistant" && v && /* @__PURE__ */ c.jsx(
10860
+ F === "assistant" && v && /* @__PURE__ */ c.jsx(
10854
10861
  He,
10855
10862
  {
10856
10863
  variant: "ghost",
10857
10864
  size: "sm",
10858
10865
  onClick: le,
10859
- className: X("h-6 w-6 p-0 hover:bg-background/50 text-current", q && "h-5 w-5"),
10860
- children: /* @__PURE__ */ c.jsx(di, { className: X("text-current", q ? "h-3 w-3" : "h-4 w-4") })
10866
+ className: J("h-6 w-6 p-0 hover:bg-background/50 text-current", q && "h-5 w-5"),
10867
+ children: /* @__PURE__ */ c.jsx(di, { className: J("text-current", q ? "h-3 w-3" : "h-4 w-4") })
10861
10868
  }
10862
10869
  )
10863
10870
  ]
@@ -11521,7 +11528,7 @@ const dy = (e) => ({
11521
11528
  const _ = (((O = s.flip) == null ? void 0 : O.index) || 0) + 1, V = E[_];
11522
11529
  if (V && (!(f === "alignment" ? b !== an(V) : !1) || // We leave the current main axis only if every placement on that axis
11523
11530
  // overflows the main axis.
11524
- N.every((L) => an(L.placement) === b ? L.overflows[0] > 0 : !0)))
11531
+ N.every((F) => an(F.placement) === b ? F.overflows[0] > 0 : !0)))
11525
11532
  return {
11526
11533
  data: {
11527
11534
  index: _,
@@ -11531,20 +11538,20 @@ const dy = (e) => ({
11531
11538
  placement: V
11532
11539
  }
11533
11540
  };
11534
- let U = (M = N.filter((q) => q.overflows[0] <= 0).sort((q, L) => q.overflows[1] - L.overflows[1])[0]) == null ? void 0 : M.placement;
11541
+ let U = (M = N.filter((q) => q.overflows[0] <= 0).sort((q, F) => q.overflows[1] - F.overflows[1])[0]) == null ? void 0 : M.placement;
11535
11542
  if (!U)
11536
11543
  switch (p) {
11537
11544
  case "bestFit": {
11538
11545
  var D;
11539
- const q = (D = N.filter((L) => {
11546
+ const q = (D = N.filter((F) => {
11540
11547
  if (C) {
11541
- const k = an(L.placement);
11548
+ const k = an(F.placement);
11542
11549
  return k === b || // Create a bias to the `y` side axis due to horizontal
11543
11550
  // reading directions favoring greater width.
11544
11551
  k === "y";
11545
11552
  }
11546
11553
  return !0;
11547
- }).map((L) => [L.placement, L.overflows.filter((k) => k > 0).reduce((k, W) => k + W, 0)]).sort((L, k) => L[1] - k[1])[0]) == null ? void 0 : D[0];
11554
+ }).map((F) => [F.placement, F.overflows.filter((k) => k > 0).reduce((k, W) => k + W, 0)]).sort((F, k) => F[1] - k[1])[0]) == null ? void 0 : D[0];
11548
11555
  q && (U = q);
11549
11556
  break;
11550
11557
  }
@@ -12370,19 +12377,19 @@ function e0(e) {
12370
12377
  isPositioned: !1
12371
12378
  }), [h, p] = m.useState(r);
12372
12379
  qo(h, r) || p(r);
12373
- const [w, v] = m.useState(null), [g, x] = m.useState(null), b = m.useCallback((L) => {
12374
- L !== C.current && (C.current = L, v(L));
12375
- }, []), y = m.useCallback((L) => {
12376
- L !== E.current && (E.current = L, x(L));
12380
+ const [w, v] = m.useState(null), [g, x] = m.useState(null), b = m.useCallback((F) => {
12381
+ F !== C.current && (C.current = F, v(F));
12382
+ }, []), y = m.useCallback((F) => {
12383
+ F !== E.current && (E.current = F, x(F));
12377
12384
  }, []), R = s || w, S = i || g, C = m.useRef(null), E = m.useRef(null), I = m.useRef(d), j = l != null, N = ai(l), O = ai(o), M = ai(u), D = m.useCallback(() => {
12378
12385
  if (!C.current || !E.current)
12379
12386
  return;
12380
- const L = {
12387
+ const F = {
12381
12388
  placement: t,
12382
12389
  strategy: n,
12383
12390
  middleware: h
12384
12391
  };
12385
- O.current && (L.platform = O.current), Jy(C.current, E.current, L).then((k) => {
12392
+ O.current && (F.platform = O.current), Jy(C.current, E.current, F).then((k) => {
12386
12393
  const W = {
12387
12394
  ...k,
12388
12395
  // The floating element's position may be recomputed while it's closed
@@ -12397,8 +12404,8 @@ function e0(e) {
12397
12404
  });
12398
12405
  }, [h, t, n, O, M]);
12399
12406
  Oo(() => {
12400
- u === !1 && I.current.isPositioned && (I.current.isPositioned = !1, f((L) => ({
12401
- ...L,
12407
+ u === !1 && I.current.isPositioned && (I.current.isPositioned = !1, f((F) => ({
12408
+ ...F,
12402
12409
  isPositioned: !1
12403
12410
  })));
12404
12411
  }, [u]);
@@ -12421,16 +12428,16 @@ function e0(e) {
12421
12428
  reference: R,
12422
12429
  floating: S
12423
12430
  }), [R, S]), q = m.useMemo(() => {
12424
- const L = {
12431
+ const F = {
12425
12432
  position: n,
12426
12433
  left: 0,
12427
12434
  top: 0
12428
12435
  };
12429
12436
  if (!U.floating)
12430
- return L;
12437
+ return F;
12431
12438
  const k = gc(U.floating, d.x), W = gc(U.floating, d.y);
12432
12439
  return a ? {
12433
- ...L,
12440
+ ...F,
12434
12441
  transform: "translate(" + k + "px, " + W + "px)",
12435
12442
  ...Ud(U.floating) >= 1.5 && {
12436
12443
  willChange: "transform"
@@ -12569,7 +12576,7 @@ var Ia = "PopperContent", [f0, h0] = Kd(Ia), Jd = m.forwardRef(
12569
12576
  boundary: O.filter(m0),
12570
12577
  // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
12571
12578
  altBoundary: M
12572
- }, { refs: _, floatingStyles: V, placement: U, isPositioned: q, middlewareData: L } = e0({
12579
+ }, { refs: _, floatingStyles: V, placement: U, isPositioned: q, middlewareData: F } = e0({
12573
12580
  // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
12574
12581
  strategy: "fixed",
12575
12582
  placement: j,
@@ -12603,7 +12610,7 @@ var Ia = "PopperContent", [f0, h0] = Kd(Ia), Jd = m.forwardRef(
12603
12610
  xt(() => {
12604
12611
  q && (Y == null || Y());
12605
12612
  }, [q, Y]);
12606
- const ue = (B = L.arrow) == null ? void 0 : B.x, re = (P = L.arrow) == null ? void 0 : P.y, de = ((G = L.arrow) == null ? void 0 : G.centerOffset) !== 0, [fe, ye] = m.useState();
12613
+ const ue = (B = F.arrow) == null ? void 0 : B.x, re = (P = F.arrow) == null ? void 0 : P.y, de = ((G = F.arrow) == null ? void 0 : G.centerOffset) !== 0, [fe, ye] = m.useState();
12607
12614
  return xt(() => {
12608
12615
  x && ye(window.getComputedStyle(x).zIndex);
12609
12616
  }, [x]), /* @__PURE__ */ c.jsx(
@@ -12618,13 +12625,13 @@ var Ia = "PopperContent", [f0, h0] = Kd(Ia), Jd = m.forwardRef(
12618
12625
  minWidth: "max-content",
12619
12626
  zIndex: fe,
12620
12627
  "--radix-popper-transform-origin": [
12621
- (Z = L.transformOrigin) == null ? void 0 : Z.x,
12622
- (le = L.transformOrigin) == null ? void 0 : le.y
12628
+ (Z = F.transformOrigin) == null ? void 0 : Z.x,
12629
+ (le = F.transformOrigin) == null ? void 0 : le.y
12623
12630
  ].join(" "),
12624
12631
  // hide the content if using the hide middleware and should be hidden
12625
12632
  // set visibility to hidden and disable pointer events so the UI behaves
12626
12633
  // as if the PopperContent isn't there at all
12627
- ...((oe = L.hide) == null ? void 0 : oe.referenceHidden) && {
12634
+ ...((oe = F.hide) == null ? void 0 : oe.referenceHidden) && {
12628
12635
  visibility: "hidden",
12629
12636
  pointerEvents: "none"
12630
12637
  }
@@ -13015,7 +13022,7 @@ var Ut = "MenuContent", [$0, ja] = Qn(Ut), vf = m.forwardRef(
13015
13022
  })(W), ye && setTimeout(() => ye.focus());
13016
13023
  };
13017
13024
  m.useEffect(() => () => window.clearTimeout(j.current), []), pa();
13018
- const L = m.useCallback((k) => {
13025
+ const F = m.useCallback((k) => {
13019
13026
  var Y, ue;
13020
13027
  return D.current === ((Y = M.current) == null ? void 0 : Y.side) && nS(k, (ue = M.current) == null ? void 0 : ue.area);
13021
13028
  }, []);
@@ -13026,22 +13033,22 @@ var Ut = "MenuContent", [$0, ja] = Qn(Ut), vf = m.forwardRef(
13026
13033
  searchRef: N,
13027
13034
  onItemEnter: m.useCallback(
13028
13035
  (k) => {
13029
- L(k) && k.preventDefault();
13036
+ F(k) && k.preventDefault();
13030
13037
  },
13031
- [L]
13038
+ [F]
13032
13039
  ),
13033
13040
  onItemLeave: m.useCallback(
13034
13041
  (k) => {
13035
13042
  var W;
13036
- L(k) || ((W = E.current) == null || W.focus(), C(null));
13043
+ F(k) || ((W = E.current) == null || W.focus(), C(null));
13037
13044
  },
13038
- [L]
13045
+ [F]
13039
13046
  ),
13040
13047
  onTriggerLeave: m.useCallback(
13041
13048
  (k) => {
13042
- L(k) && k.preventDefault();
13049
+ F(k) && k.preventDefault();
13043
13050
  },
13044
- [L]
13051
+ [F]
13045
13052
  ),
13046
13053
  pointerGraceTimerRef: O,
13047
13054
  onPointerGraceIntentChange: m.useCallback((k) => {
@@ -13645,7 +13652,7 @@ const FS = MS, $S = DS, zS = m.forwardRef(({ className: e, inset: t, children: n
13645
13652
  rh,
13646
13653
  {
13647
13654
  ref: o,
13648
- className: X(
13655
+ className: J(
13649
13656
  "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
13650
13657
  t && "pl-8",
13651
13658
  e
@@ -13662,7 +13669,7 @@ const BS = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
13662
13669
  oh,
13663
13670
  {
13664
13671
  ref: n,
13665
- className: X(
13672
+ className: J(
13666
13673
  "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
13667
13674
  e
13668
13675
  ),
@@ -13675,7 +13682,7 @@ const sh = m.forwardRef(({ className: e, sideOffset: t = 4, ...n }, r) => /* @__
13675
13682
  {
13676
13683
  ref: r,
13677
13684
  sideOffset: t,
13678
- className: X(
13685
+ className: J(
13679
13686
  "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
13680
13687
  e
13681
13688
  ),
@@ -13687,7 +13694,7 @@ const Mi = m.forwardRef(({ className: e, inset: t, ...n }, r) => /* @__PURE__ */
13687
13694
  Zf,
13688
13695
  {
13689
13696
  ref: r,
13690
- className: X(
13697
+ className: J(
13691
13698
  "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13692
13699
  t && "pl-8",
13693
13700
  e
@@ -13700,7 +13707,7 @@ const HS = m.forwardRef(({ className: e, children: t, checked: n, ...r }, o) =>
13700
13707
  Qf,
13701
13708
  {
13702
13709
  ref: o,
13703
- className: X(
13710
+ className: J(
13704
13711
  "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13705
13712
  e
13706
13713
  ),
@@ -13717,7 +13724,7 @@ const US = m.forwardRef(({ className: e, children: t, ...n }, r) => /* @__PURE__
13717
13724
  eh,
13718
13725
  {
13719
13726
  ref: r,
13720
- className: X(
13727
+ className: J(
13721
13728
  "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
13722
13729
  e
13723
13730
  ),
@@ -13733,7 +13740,7 @@ const WS = m.forwardRef(({ className: e, inset: t, ...n }, r) => /* @__PURE__ */
13733
13740
  Jf,
13734
13741
  {
13735
13742
  ref: r,
13736
- className: X(
13743
+ className: J(
13737
13744
  "px-2 py-1.5 text-sm font-semibold",
13738
13745
  t && "pl-8",
13739
13746
  e
@@ -13746,7 +13753,7 @@ const VS = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
13746
13753
  nh,
13747
13754
  {
13748
13755
  ref: n,
13749
- className: X("-mx-1 my-1 h-px bg-muted", e),
13756
+ className: J("-mx-1 my-1 h-px bg-muted", e),
13750
13757
  ...t
13751
13758
  }
13752
13759
  ));
@@ -13786,17 +13793,17 @@ function ci({
13786
13793
  streamingAssistantId: M,
13787
13794
  lastCheckpointId: D,
13788
13795
  lastCheckpointNs: _
13789
- } = sx(), [V, U] = pe(null), [q, L] = pe(""), [k, W] = pe(null), [Y, ue] = pe([]), [re, de] = pe(0), [fe, ye] = pe(0), [B, P] = pe(!1), [G, Z] = pe(null), [le, oe] = pe(null), [Me, Ge] = pe(!1), [Ye, Ee] = pe(null), [_e, Qe] = pe([]), [je, st] = pe(null), [at, Q] = pe(null), [ae, he] = pe(!1), Se = ut(null), ve = ut(null), Ne = ut(null), et = Ue(() => {
13796
+ } = sx(), [V, U] = pe(null), [q, F] = pe(""), [k, W] = pe(null), [Y, ue] = pe([]), [re, de] = pe(0), [fe, ye] = pe(0), [B, P] = pe(!1), [G, Z] = pe(null), [le, oe] = pe(null), [Me, Ge] = pe(!1), [Ye, Ee] = pe(null), [_e, Qe] = pe([]), [je, st] = pe(null), [at, Q] = pe(null), [ae, he] = pe(!1), Se = ut(null), ve = ut(null), Ne = ut(null), et = Ue(() => {
13790
13797
  Se.current && (Se.current.value = ""), ve.current && (ve.current.value = ""), de((se) => se + 1), ye((se) => se + 1);
13791
13798
  }, []), Ve = ut(!1);
13792
13799
  gt(() => {
13793
13800
  Ve.current && !N && (ue([]), et()), Ve.current = N;
13794
13801
  }, [N, et]);
13795
- const [F, J] = pe("desktop");
13802
+ const [L, X] = pe("desktop");
13796
13803
  gt(() => {
13797
13804
  const se = () => {
13798
13805
  const xe = window.innerWidth;
13799
- J(xe < 640 ? "phone" : xe < 1024 ? "tablet" : "desktop");
13806
+ X(xe < 640 ? "phone" : xe < 1024 ? "tablet" : "desktop");
13800
13807
  };
13801
13808
  return se(), window.addEventListener("resize", se), () => window.removeEventListener("resize", se);
13802
13809
  }, []), gt(() => {
@@ -13879,16 +13886,16 @@ function ci({
13879
13886
  checkpointNs: at ?? _ ?? void 0,
13880
13887
  payloadExtras: V ? { edit: !0, originalMessageId: V } : void 0,
13881
13888
  attachments: Y
13882
- }), f == null || f(xe), W(null), ue([]), et(), U(null), L("");
13889
+ }), f == null || f(xe), W(null), ue([]), et(), U(null), F("");
13883
13890
  } catch ($e) {
13884
13891
  const rt = ($e == null ? void 0 : $e.message) || "Failed to send message";
13885
13892
  W(rt), p == null || p(rt);
13886
13893
  }
13887
13894
  }
13888
13895
  }, it = z.useCallback((se, xe) => {
13889
- u && (U(se), L(xe), W(null));
13896
+ u && (U(se), F(xe), W(null));
13890
13897
  }, [u]), At = z.useCallback(() => {
13891
- U(null), L(""), W(null);
13898
+ U(null), F(""), W(null);
13892
13899
  }, []), tr = Ue((se, xe) => {
13893
13900
  it(se, xe);
13894
13901
  }, [it]), Pn = Ue((se) => {
@@ -14008,7 +14015,7 @@ function ci({
14008
14015
  streamingAssistantId: M,
14009
14016
  streamingDebounceMs: typeof s == "number" ? s : o,
14010
14017
  followNewMessages: i,
14011
- layoutSize: F,
14018
+ layoutSize: L,
14012
14019
  enableMessageEditing: u,
14013
14020
  editingMessageId: V,
14014
14021
  onStartReached: () => {
@@ -14158,7 +14165,7 @@ const Xo = m.forwardRef(
14158
14165
  "input",
14159
14166
  {
14160
14167
  type: t,
14161
- className: X(
14168
+ className: J(
14162
14169
  "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
14163
14170
  e
14164
14171
  ),
@@ -14686,7 +14693,7 @@ const wh = m.forwardRef(({ className: e, children: t, ...n }, r) => /* @__PURE__
14686
14693
  vh,
14687
14694
  {
14688
14695
  ref: r,
14689
- className: X("relative overflow-hidden", e),
14696
+ className: J("relative overflow-hidden", e),
14690
14697
  ...n,
14691
14698
  children: [
14692
14699
  /* @__PURE__ */ c.jsx(rC, { className: "h-full w-full rounded-[inherit] overflow-auto", children: t }),
@@ -14701,7 +14708,7 @@ const bh = m.forwardRef(({ className: e, orientation: t = "vertical", ...n }, r)
14701
14708
  {
14702
14709
  ref: r,
14703
14710
  orientation: t,
14704
- className: X(
14711
+ className: J(
14705
14712
  "flex touch-none select-none transition-colors",
14706
14713
  t === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
14707
14714
  t === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
@@ -14781,7 +14788,7 @@ function wc({
14781
14788
  } catch {
14782
14789
  return "";
14783
14790
  }
14784
- }, L = (k) => k.title || `Thread ${k.threadId.slice(0, 8)}`;
14791
+ }, F = (k) => k.title || `Thread ${k.threadId.slice(0, 8)}`;
14785
14792
  return /* @__PURE__ */ c.jsxs("div", { className: `flex flex-col h-full ${e} ${s.container || ""}`, children: [
14786
14793
  t && /* @__PURE__ */ c.jsx("div", { className: s.header || "flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end", children: /* @__PURE__ */ c.jsx(
14787
14794
  He,
@@ -14818,7 +14825,7 @@ function wc({
14818
14825
  /* @__PURE__ */ c.jsx(He, { variant: "ghost", size: "sm", onClick: () => _(k.threadId), className: "h-6 w-6 p-0", children: /* @__PURE__ */ c.jsx(Wi, { size: 12 }) }),
14819
14826
  /* @__PURE__ */ c.jsx(He, { variant: "ghost", size: "sm", onClick: V, className: "h-6 w-6 p-0", children: /* @__PURE__ */ c.jsx(lr, { size: 12 }) })
14820
14827
  ] }) : /* @__PURE__ */ c.jsxs(c.Fragment, { children: [
14821
- /* @__PURE__ */ c.jsx("div", { className: "font-medium text-sm truncate text-gray-900 dark:text-slate-100", children: L(k) }),
14828
+ /* @__PURE__ */ c.jsx("div", { className: "font-medium text-sm truncate text-gray-900 dark:text-slate-100", children: F(k) }),
14822
14829
  /* @__PURE__ */ c.jsxs("div", { className: "flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1", children: [
14823
14830
  /* @__PURE__ */ c.jsx(Vp, { size: 10 }),
14824
14831
  /* @__PURE__ */ c.jsx("span", { children: q(k.updatedAt || k.createdAt) })
@@ -14971,7 +14978,7 @@ const dC = ts(
14971
14978
  Eh,
14972
14979
  {
14973
14980
  ref: n,
14974
- className: X(dC(), e),
14981
+ className: J(dC(), e),
14975
14982
  ...t
14976
14983
  }
14977
14984
  ));
@@ -15100,7 +15107,7 @@ var Ph = Ih, gC = Ah;
15100
15107
  const Sn = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
15101
15108
  Ph,
15102
15109
  {
15103
- className: X(
15110
+ className: J(
15104
15111
  "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
15105
15112
  e
15106
15113
  ),
@@ -15109,7 +15116,7 @@ const Sn = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
15109
15116
  children: /* @__PURE__ */ c.jsx(
15110
15117
  gC,
15111
15118
  {
15112
- className: X(
15119
+ className: J(
15113
15120
  "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
15114
15121
  )
15115
15122
  }
@@ -15199,8 +15206,8 @@ var wC = [" ", "Enter", "ArrowUp", "ArrowDown"], bC = [" ", "Enter"], Gn = "Sele
15199
15206
  }, []),
15200
15207
  onNativeOptionRemove: m.useCallback((U) => {
15201
15208
  _((q) => {
15202
- const L = new Set(q);
15203
- return L.delete(U), L;
15209
+ const F = new Set(q);
15210
+ return F.delete(U), F;
15204
15211
  });
15205
15212
  }, []),
15206
15213
  children: n
@@ -15358,7 +15365,7 @@ var Kt = 10, [Uh, _n] = Cr(Yn), kC = "SelectContentImpl", IC = hr("SelectContent
15358
15365
  m.useEffect(() => {
15359
15366
  D && q();
15360
15367
  }, [D, q]);
15361
- const { onOpenChange: L, triggerPointerDownPosRef: k } = b;
15368
+ const { onOpenChange: F, triggerPointerDownPosRef: k } = b;
15362
15369
  m.useEffect(() => {
15363
15370
  if (y) {
15364
15371
  let B = { x: 0, y: 0 };
@@ -15369,18 +15376,18 @@ var Kt = 10, [Uh, _n] = Cr(Yn), kC = "SelectContentImpl", IC = hr("SelectContent
15369
15376
  y: Math.abs(Math.round(Z.pageY) - (((oe = k.current) == null ? void 0 : oe.y) ?? 0))
15370
15377
  };
15371
15378
  }, G = (Z) => {
15372
- B.x <= 10 && B.y <= 10 ? Z.preventDefault() : y.contains(Z.target) || L(!1), document.removeEventListener("pointermove", P), k.current = null;
15379
+ B.x <= 10 && B.y <= 10 ? Z.preventDefault() : y.contains(Z.target) || F(!1), document.removeEventListener("pointermove", P), k.current = null;
15373
15380
  };
15374
15381
  return k.current !== null && (document.addEventListener("pointermove", P), document.addEventListener("pointerup", G, { capture: !0, once: !0 })), () => {
15375
15382
  document.removeEventListener("pointermove", P), document.removeEventListener("pointerup", G, { capture: !0 });
15376
15383
  };
15377
15384
  }
15378
- }, [y, L, k]), m.useEffect(() => {
15379
- const B = () => L(!1);
15385
+ }, [y, F, k]), m.useEffect(() => {
15386
+ const B = () => F(!1);
15380
15387
  return window.addEventListener("blur", B), window.addEventListener("resize", B), () => {
15381
15388
  window.removeEventListener("blur", B), window.removeEventListener("resize", B);
15382
15389
  };
15383
- }, [L]);
15390
+ }, [F]);
15384
15391
  const [W, Y] = ap((B) => {
15385
15392
  const P = M().filter((le) => !le.disabled), G = P.find((le) => le.ref.current === document.activeElement), Z = lp(P, B, G);
15386
15393
  Z && setTimeout(() => Z.ref.current.focus());
@@ -15509,7 +15516,7 @@ var NC = "SelectItemAlignedPosition", Vh = m.forwardRef((e, t) => {
15509
15516
  ]);
15510
15517
  a.style.minWidth = Ge + "px", a.style.right = _e + "px";
15511
15518
  }
15512
- const O = h(), M = window.innerHeight - Kt * 2, D = v.scrollHeight, _ = window.getComputedStyle(u), V = parseInt(_.borderTopWidth, 10), U = parseInt(_.paddingTop, 10), q = parseInt(_.borderBottomWidth, 10), L = parseInt(_.paddingBottom, 10), k = V + U + D + L + q, W = Math.min(g.offsetHeight * 5, k), Y = window.getComputedStyle(v), ue = parseInt(Y.paddingTop, 10), re = parseInt(Y.paddingBottom, 10), de = E.top + E.height / 2 - Kt, fe = M - de, ye = g.offsetHeight / 2, B = g.offsetTop + ye, P = V + U + B, G = k - P;
15519
+ const O = h(), M = window.innerHeight - Kt * 2, D = v.scrollHeight, _ = window.getComputedStyle(u), V = parseInt(_.borderTopWidth, 10), U = parseInt(_.paddingTop, 10), q = parseInt(_.borderBottomWidth, 10), F = parseInt(_.paddingBottom, 10), k = V + U + D + F + q, W = Math.min(g.offsetHeight * 5, k), Y = window.getComputedStyle(v), ue = parseInt(Y.paddingTop, 10), re = parseInt(Y.paddingBottom, 10), de = E.top + E.height / 2 - Kt, fe = M - de, ye = g.offsetHeight / 2, B = g.offsetTop + ye, P = V + U + B, G = k - P;
15513
15520
  if (P <= de) {
15514
15521
  const le = O.length > 0 && g === O[O.length - 1].ref.current;
15515
15522
  a.style.bottom = "0px";
@@ -15949,7 +15956,7 @@ const bc = zC, yc = BC, Hi = m.forwardRef(({ className: e, children: t, ...n },
15949
15956
  cp,
15950
15957
  {
15951
15958
  ref: r,
15952
- className: X(
15959
+ className: J(
15953
15960
  "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
15954
15961
  e
15955
15962
  ),
@@ -15965,7 +15972,7 @@ const gp = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
15965
15972
  hp,
15966
15973
  {
15967
15974
  ref: n,
15968
- className: X(
15975
+ className: J(
15969
15976
  "flex cursor-default items-center justify-center py-1",
15970
15977
  e
15971
15978
  ),
@@ -15978,7 +15985,7 @@ const xp = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
15978
15985
  pp,
15979
15986
  {
15980
15987
  ref: n,
15981
- className: X(
15988
+ className: J(
15982
15989
  "flex cursor-default items-center justify-center py-1",
15983
15990
  e
15984
15991
  ),
@@ -15991,7 +15998,7 @@ const Ui = m.forwardRef(({ className: e, children: t, position: n = "popper", ..
15991
15998
  up,
15992
15999
  {
15993
16000
  ref: o,
15994
- className: X(
16001
+ className: J(
15995
16002
  "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
15996
16003
  n === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
15997
16004
  e
@@ -16003,7 +16010,7 @@ const Ui = m.forwardRef(({ className: e, children: t, position: n = "popper", ..
16003
16010
  /* @__PURE__ */ c.jsx(
16004
16011
  WC,
16005
16012
  {
16006
- className: X(
16013
+ className: J(
16007
16014
  "p-1",
16008
16015
  n === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
16009
16016
  ),
@@ -16019,7 +16026,7 @@ const qC = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
16019
16026
  dp,
16020
16027
  {
16021
16028
  ref: n,
16022
- className: X("py-1.5 pl-8 pr-2 text-sm font-semibold", e),
16029
+ className: J("py-1.5 pl-8 pr-2 text-sm font-semibold", e),
16023
16030
  ...t
16024
16031
  }
16025
16032
  ));
@@ -16028,7 +16035,7 @@ const Ln = m.forwardRef(({ className: e, children: t, ...n }, r) => /* @__PURE__
16028
16035
  fp,
16029
16036
  {
16030
16037
  ref: r,
16031
- className: X(
16038
+ className: J(
16032
16039
  "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
16033
16040
  e
16034
16041
  ),
@@ -16044,7 +16051,7 @@ const GC = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
16044
16051
  mp,
16045
16052
  {
16046
16053
  ref: n,
16047
- className: X("-mx-1 my-1 h-px bg-muted", e),
16054
+ className: J("-mx-1 my-1 h-px bg-muted", e),
16048
16055
  ...t
16049
16056
  }
16050
16057
  ));
@@ -16073,7 +16080,7 @@ const bp = m.forwardRef(
16073
16080
  ref: o,
16074
16081
  decorative: n,
16075
16082
  orientation: t,
16076
- className: X(
16083
+ className: J(
16077
16084
  "shrink-0 bg-border",
16078
16085
  t === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
16079
16086
  e
@@ -16086,7 +16093,7 @@ bp.displayName = wp.displayName;
16086
16093
  const ZC = Cd, QC = jb, eT = Td, yp = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
16087
16094
  bs,
16088
16095
  {
16089
- className: X(
16096
+ className: J(
16090
16097
  "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
16091
16098
  e
16092
16099
  ),
@@ -16116,7 +16123,7 @@ const tT = ts(
16116
16123
  ys,
16117
16124
  {
16118
16125
  ref: o,
16119
- className: X(tT({ side: e }), t),
16126
+ className: J(tT({ side: e }), t),
16120
16127
  ...r,
16121
16128
  children: [
16122
16129
  n,
@@ -16135,7 +16142,7 @@ const Cp = ({
16135
16142
  }) => /* @__PURE__ */ c.jsx(
16136
16143
  "div",
16137
16144
  {
16138
- className: X(
16145
+ className: J(
16139
16146
  "flex flex-col space-y-2 text-center sm:text-left",
16140
16147
  e
16141
16148
  ),
@@ -16147,7 +16154,7 @@ const Tp = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
16147
16154
  Bn,
16148
16155
  {
16149
16156
  ref: n,
16150
- className: X("text-lg font-semibold text-foreground", e),
16157
+ className: J("text-lg font-semibold text-foreground", e),
16151
16158
  ...t
16152
16159
  }
16153
16160
  ));
@@ -16156,7 +16163,7 @@ const Rp = m.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ c.jsx(
16156
16163
  Ss,
16157
16164
  {
16158
16165
  ref: n,
16159
- className: X("text-sm text-muted-foreground", e),
16166
+ className: J("text-sm text-muted-foreground", e),
16160
16167
  ...t
16161
16168
  }
16162
16169
  ));