@retrivora-ai/rag-engine 1.0.4 → 1.0.5

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.
Files changed (39) hide show
  1. package/dist/DocumentChunker-Dh9TvmGG.d.mts +45 -0
  2. package/dist/DocumentChunker-Dh9TvmGG.d.ts +45 -0
  3. package/dist/{RagConfig-DRJO4hGU.d.mts → RagConfig-BEmz4hVP.d.mts} +58 -1
  4. package/dist/{RagConfig-DRJO4hGU.d.ts → RagConfig-BEmz4hVP.d.ts} +58 -1
  5. package/dist/{chunk-6MLZHQZT.mjs → chunk-MWL4AGQI.mjs} +189 -98
  6. package/dist/handlers/index.d.mts +2 -2
  7. package/dist/handlers/index.d.ts +2 -2
  8. package/dist/handlers/index.js +191 -100
  9. package/dist/handlers/index.mjs +11 -3
  10. package/dist/index-CSfaCeux.d.ts +206 -0
  11. package/dist/index-DFSy0CG6.d.mts +206 -0
  12. package/dist/index.d.mts +3 -4
  13. package/dist/index.d.ts +3 -4
  14. package/dist/index.js +103 -89
  15. package/dist/index.mjs +91 -95
  16. package/dist/server.d.mts +45 -97
  17. package/dist/server.d.ts +45 -97
  18. package/dist/server.js +271 -215
  19. package/dist/server.mjs +78 -167
  20. package/package.json +12 -10
  21. package/src/components/ChatWindow.tsx +2 -2
  22. package/src/components/ConfigProvider.tsx +2 -2
  23. package/src/components/MessageBubble.tsx +2 -2
  24. package/src/components/SourceCard.tsx +1 -1
  25. package/src/components/ThemeToggle.tsx +1 -1
  26. package/src/config/ConfigBuilder.ts +86 -211
  27. package/src/config/uiConstants.ts +23 -0
  28. package/src/core/ConfigResolver.ts +57 -29
  29. package/src/core/LangChainAgent.ts +73 -40
  30. package/src/core/Pipeline.ts +63 -7
  31. package/src/core/ProviderRegistry.ts +2 -2
  32. package/src/core/QueryProcessor.ts +9 -8
  33. package/src/handlers/index.ts +138 -49
  34. package/src/hooks/useRagChat.ts +71 -32
  35. package/src/server.ts +12 -2
  36. package/dist/DocumentChunker-C-sCZPhi.d.mts +0 -102
  37. package/dist/DocumentChunker-C-sCZPhi.d.ts +0 -102
  38. package/dist/index-B2mutkgp.d.ts +0 -116
  39. package/dist/index-Bjy0es5a.d.mts +0 -116
package/dist/index.mjs CHANGED
@@ -7,16 +7,16 @@ import {
7
7
  } from "./chunk-X4TOT24V.mjs";
8
8
 
9
9
  // src/components/ChatWidget.tsx
10
- import React7, { useState as useState4 } from "react";
11
- import { MessageSquare as MessageSquare2, X as X2 } from "lucide-react";
10
+ import React6, { useState as useState4 } from "react";
11
+ import { MessageSquare, X as X2 } from "lucide-react";
12
12
 
13
13
  // src/components/ChatWindow.tsx
14
- import React6, { useState as useState3, useRef as useRef2, useEffect as useEffect3, useCallback as useCallback2 } from "react";
14
+ import React5, { useState as useState3, useRef as useRef2, useEffect as useEffect3, useCallback as useCallback2 } from "react";
15
15
  import {
16
- Bot as Bot3,
16
+ Bot as Bot2,
17
17
  Trash2,
18
18
  X,
19
- Sparkles as Sparkles2,
19
+ Sparkles,
20
20
  ArrowUp,
21
21
  TriangleAlert
22
22
  } from "lucide-react";
@@ -159,6 +159,22 @@ function useStoredMessages(storageKey, persist) {
159
159
  }
160
160
 
161
161
  // src/hooks/useRagChat.ts
162
+ function parseSseChunk(raw) {
163
+ const frames = [];
164
+ for (const block of raw.split("\n\n")) {
165
+ for (const line of block.split("\n")) {
166
+ if (!line.startsWith("data: ")) continue;
167
+ try {
168
+ const frame = JSON.parse(line.slice(6));
169
+ if (frame && typeof frame === "object" && "type" in frame) {
170
+ frames.push(frame);
171
+ }
172
+ } catch (e) {
173
+ }
174
+ }
175
+ }
176
+ return frames;
177
+ }
162
178
  function useRagChat(projectId, options = {}) {
163
179
  const {
164
180
  apiUrl = "/api/chat",
@@ -177,11 +193,12 @@ function useRagChat(projectId, options = {}) {
177
193
  messagesRef.current = messages;
178
194
  }, [messages]);
179
195
  const sendMessage = useCallback(
180
- async (text, options2) => {
196
+ async (text, opts) => {
197
+ var _a, _b;
181
198
  const trimmed = text.trim();
182
199
  if (!trimmed || isLoading) return;
183
200
  lastInputRef.current = trimmed;
184
- if (!(options2 == null ? void 0 : options2.skipUserMessage)) {
201
+ if (!(opts == null ? void 0 : opts.skipUserMessage)) {
185
202
  const userMessage = {
186
203
  id: `user_${Date.now()}`,
187
204
  role: "user",
@@ -214,6 +231,7 @@ function useRagChat(projectId, options = {}) {
214
231
  const decoder = new TextDecoder();
215
232
  let assistantContent = "";
216
233
  let sources = [];
234
+ let buffer = "";
217
235
  const assistantMessageId = `assistant_${Date.now()}`;
218
236
  setMessages((prev) => [
219
237
  ...prev,
@@ -227,27 +245,19 @@ function useRagChat(projectId, options = {}) {
227
245
  while (true) {
228
246
  const { done, value } = await reader.read();
229
247
  if (done) break;
230
- const chunk = decoder.decode(value, { stream: true });
231
- if (chunk.includes("__METADATA__")) {
232
- const [text2, metadataStr] = chunk.split("__METADATA__");
233
- if (text2) assistantContent += text2;
234
- try {
235
- const meta = JSON.parse(metadataStr);
236
- sources = meta.sources || [];
237
- } catch (e) {
238
- console.warn("[useRagChat] Failed to parse metadata");
248
+ buffer += decoder.decode(value, { stream: true });
249
+ const lastBoundary = buffer.lastIndexOf("\n\n");
250
+ if (lastBoundary === -1) continue;
251
+ const complete = buffer.slice(0, lastBoundary + 2);
252
+ buffer = buffer.slice(lastBoundary + 2);
253
+ for (const frame of parseSseChunk(complete)) {
254
+ if (frame.type === "text") {
255
+ assistantContent += frame.text;
256
+ } else if (frame.type === "metadata") {
257
+ sources = (_a = frame.sources) != null ? _a : [];
258
+ } else if (frame.type === "error") {
259
+ setError(frame.error || "Stream error");
239
260
  }
240
- } else if (chunk.includes("__ERROR__")) {
241
- const [text2, errorStr] = chunk.split("__ERROR__");
242
- if (text2) assistantContent += text2;
243
- try {
244
- const err = JSON.parse(errorStr);
245
- setError(err.error || "Stream error");
246
- } catch (e) {
247
- setError("An error occurred during streaming");
248
- }
249
- } else {
250
- assistantContent += chunk;
251
261
  }
252
262
  setMessages(
253
263
  (prev) => prev.map(
@@ -255,6 +265,12 @@ function useRagChat(projectId, options = {}) {
255
265
  )
256
266
  );
257
267
  }
268
+ if (buffer.trim()) {
269
+ for (const frame of parseSseChunk(buffer)) {
270
+ if (frame.type === "text") assistantContent += frame.text;
271
+ else if (frame.type === "metadata") sources = (_b = frame.sources) != null ? _b : [];
272
+ }
273
+ }
258
274
  const finalAssistantMessage = {
259
275
  id: assistantMessageId,
260
276
  role: "assistant",
@@ -297,32 +313,7 @@ function useRagChat(projectId, options = {}) {
297
313
  };
298
314
  }
299
315
 
300
- // src/app/constants.tsx
301
- import React5 from "react";
302
- import {
303
- Zap,
304
- Database,
305
- Layers,
306
- Search,
307
- Box,
308
- Package,
309
- Activity,
310
- Hexagon,
311
- Sparkles,
312
- Bot as Bot2,
313
- Brain,
314
- Rabbit,
315
- Code,
316
- Terminal,
317
- FileText,
318
- Puzzle,
319
- MessageSquare
320
- } from "lucide-react";
321
- var CHAT_SUGGESTIONS = [
322
- "What can you help me with?",
323
- "Summarise the key topics",
324
- "Show me an example"
325
- ];
316
+ // src/config/uiConstants.ts
326
317
  var BORDER_RADIUS_MAP = {
327
318
  none: "rounded-none",
328
319
  sm: "rounded-sm",
@@ -331,6 +322,11 @@ var BORDER_RADIUS_MAP = {
331
322
  xl: "rounded-xl",
332
323
  full: "rounded-3xl"
333
324
  };
325
+ var CHAT_SUGGESTIONS = [
326
+ "What can you help me with?",
327
+ "Summarise the key topics",
328
+ "Show me an example"
329
+ ];
334
330
 
335
331
  // src/components/ChatWindow.tsx
336
332
  function ChatWindow({ className = "", style, onClose, showClose = false }) {
@@ -374,58 +370,58 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
374
370
  const isEmpty = messages.length === 0;
375
371
  const currentRadius = BORDER_RADIUS_MAP[ui.borderRadius || "xl"];
376
372
  const isGlass = ui.visualStyle !== "solid";
377
- return /* @__PURE__ */ React6.createElement(
373
+ return /* @__PURE__ */ React5.createElement(
378
374
  "div",
379
375
  {
380
376
  className: `flex flex-col border border-slate-200 dark:border-white/10 shadow-2xl transition-all duration-300 ${currentRadius} ${isGlass ? "bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl" : "bg-white dark:bg-[#0f0f1a]"} ${className}`,
381
377
  style: __spreadValues({ "--primary": ui.primaryColor, "--accent": ui.accentColor }, style)
382
378
  },
383
- /* @__PURE__ */ React6.createElement(
379
+ /* @__PURE__ */ React5.createElement(
384
380
  "div",
385
381
  {
386
382
  className: "flex items-center justify-between px-5 py-4 border-b border-slate-200 dark:border-white/10",
387
383
  style: { background: `linear-gradient(135deg, ${ui.primaryColor}15, ${ui.accentColor}10)` }
388
384
  },
389
- /* @__PURE__ */ React6.createElement("div", { className: "flex items-center gap-3" }, ui.logoUrl ? (
385
+ /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-3" }, ui.logoUrl ? (
390
386
  // eslint-disable-next-line @next/next/no-img-element
391
- /* @__PURE__ */ React6.createElement("img", { src: ui.logoUrl, alt: "logo", className: "w-8 h-8 rounded-lg object-cover" })
392
- ) : /* @__PURE__ */ React6.createElement(
387
+ /* @__PURE__ */ React5.createElement("img", { src: ui.logoUrl, alt: "logo", className: "w-8 h-8 rounded-lg object-cover" })
388
+ ) : /* @__PURE__ */ React5.createElement(
393
389
  "div",
394
390
  {
395
391
  className: `w-9 h-9 flex items-center justify-center shadow-md ${ui.borderRadius === "full" ? "rounded-full" : "rounded-xl"}`,
396
392
  style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` }
397
393
  },
398
- /* @__PURE__ */ React6.createElement(Bot3, { className: "w-5 h-5 text-white" })
399
- ), /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("h2", { className: "text-slate-900 dark:text-white font-semibold text-sm leading-tight" }, ui.title), ui.poweredBy && /* @__PURE__ */ React6.createElement("p", { className: "text-slate-500 dark:text-white/40 text-[11px] leading-tight" }, `Powered by ${ui.poweredBy}`))),
400
- /* @__PURE__ */ React6.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React6.createElement("span", { className: "flex items-center gap-1 text-[10px] text-emerald-500 dark:text-emerald-400" }, /* @__PURE__ */ React6.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse" }), "Online"), mounted && messages.length > 0 && /* @__PURE__ */ React6.createElement(
394
+ /* @__PURE__ */ React5.createElement(Bot2, { className: "w-5 h-5 text-white" })
395
+ ), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("h2", { className: "text-slate-900 dark:text-white font-semibold text-sm leading-tight" }, ui.title), ui.poweredBy && /* @__PURE__ */ React5.createElement("p", { className: "text-slate-500 dark:text-white/40 text-[11px] leading-tight" }, `Powered by ${ui.poweredBy}`))),
396
+ /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React5.createElement("span", { className: "flex items-center gap-1 text-[10px] text-emerald-500 dark:text-emerald-400" }, /* @__PURE__ */ React5.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse" }), "Online"), mounted && messages.length > 0 && /* @__PURE__ */ React5.createElement(
401
397
  "button",
402
398
  {
403
399
  onClick: clearHistory,
404
400
  title: "Clear conversation",
405
401
  className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer"
406
402
  },
407
- /* @__PURE__ */ React6.createElement(Trash2, { className: "w-3.5 h-3.5" })
408
- ), showClose && onClose && /* @__PURE__ */ React6.createElement(
403
+ /* @__PURE__ */ React5.createElement(Trash2, { className: "w-3.5 h-3.5" })
404
+ ), showClose && onClose && /* @__PURE__ */ React5.createElement(
409
405
  "button",
410
406
  {
411
407
  onClick: onClose,
412
408
  title: "Close chat",
413
409
  className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer"
414
410
  },
415
- /* @__PURE__ */ React6.createElement(X, { className: "w-4 h-4" })
411
+ /* @__PURE__ */ React5.createElement(X, { className: "w-4 h-4" })
416
412
  ))
417
413
  ),
418
- /* @__PURE__ */ React6.createElement("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5 scrollbar-thin scrollbar-thumb-slate-200 dark:scrollbar-thumb-white/10 scrollbar-track-transparent min-h-0 bg-slate-50 dark:bg-transparent" }, !mounted || isEmpty ? (
414
+ /* @__PURE__ */ React5.createElement("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5 scrollbar-thin scrollbar-thumb-slate-200 dark:scrollbar-thumb-white/10 scrollbar-track-transparent min-h-0 bg-slate-50 dark:bg-transparent" }, !mounted || isEmpty ? (
419
415
  /* Welcome state */
420
- /* @__PURE__ */ React6.createElement("div", { className: "h-full flex flex-col items-center justify-center text-center gap-4 px-6 py-12" }, /* @__PURE__ */ React6.createElement(
416
+ /* @__PURE__ */ React5.createElement("div", { className: "h-full flex flex-col items-center justify-center text-center gap-4 px-6 py-12" }, /* @__PURE__ */ React5.createElement(
421
417
  "div",
422
418
  {
423
419
  className: `w-16 h-16 flex items-center justify-center shadow-lg ${ui.borderRadius === "full" ? "rounded-full" : "rounded-2xl"}`,
424
420
  style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` }
425
421
  },
426
- /* @__PURE__ */ React6.createElement(Sparkles2, { className: "w-8 h-8 text-white" })
427
- ), /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("p", { className: "text-slate-800 dark:text-white/80 font-medium leading-relaxed" }, ui.welcomeMessage), /* @__PURE__ */ React6.createElement("p", { className: "text-slate-500 dark:text-white/30 text-sm mt-2" }, "Ask a question to get started")), /* @__PURE__ */ React6.createElement("div", { className: "flex flex-wrap gap-2 justify-center mt-2" }, CHAT_SUGGESTIONS.map(
428
- (suggestion) => /* @__PURE__ */ React6.createElement(
422
+ /* @__PURE__ */ React5.createElement(Sparkles, { className: "w-8 h-8 text-white" })
423
+ ), /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("p", { className: "text-slate-800 dark:text-white/80 font-medium leading-relaxed" }, ui.welcomeMessage), /* @__PURE__ */ React5.createElement("p", { className: "text-slate-500 dark:text-white/30 text-sm mt-2" }, "Ask a question to get started")), /* @__PURE__ */ React5.createElement("div", { className: "flex flex-wrap gap-2 justify-center mt-2" }, CHAT_SUGGESTIONS.map(
424
+ (suggestion) => /* @__PURE__ */ React5.createElement(
429
425
  "button",
430
426
  {
431
427
  key: suggestion,
@@ -439,7 +435,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
439
435
  suggestion
440
436
  )
441
437
  )))
442
- ) : messages.map((msg, index) => /* @__PURE__ */ React6.createElement(
438
+ ) : messages.map((msg, index) => /* @__PURE__ */ React5.createElement(
443
439
  MessageBubble,
444
440
  {
445
441
  key: msg.id,
@@ -449,7 +445,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
449
445
  primaryColor: ui.primaryColor,
450
446
  accentColor: ui.accentColor
451
447
  }
452
- )), isLoading && ((_a = messages[messages.length - 1]) == null ? void 0 : _a.role) !== "assistant" && /* @__PURE__ */ React6.createElement(
448
+ )), isLoading && ((_a = messages[messages.length - 1]) == null ? void 0 : _a.role) !== "assistant" && /* @__PURE__ */ React5.createElement(
453
449
  MessageBubble,
454
450
  {
455
451
  message: { role: "assistant", content: "" },
@@ -457,8 +453,8 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
457
453
  primaryColor: ui.primaryColor,
458
454
  accentColor: ui.accentColor
459
455
  }
460
- ), error && /* @__PURE__ */ React6.createElement("div", { className: "flex items-center gap-2 text-rose-500 dark:text-rose-400 text-sm bg-rose-50 dark:bg-rose-400/10 border border-rose-200 dark:border-rose-400/20 rounded-xl px-4 py-3" }, /* @__PURE__ */ React6.createElement(TriangleAlert, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ React6.createElement("span", null, error)), /* @__PURE__ */ React6.createElement("div", { ref: bottomRef })),
461
- /* @__PURE__ */ React6.createElement("div", { className: `px-4 pb-4 pt-2 border-t border-slate-200 dark:border-white/10 ${isGlass ? "bg-transparent" : "bg-white dark:bg-[#0f0f1a]"}` }, /* @__PURE__ */ React6.createElement("div", { className: `flex items-end gap-2 bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 p-2 focus-within:border-slate-300 dark:focus-within:border-white/20 transition-all ${ui.borderRadius === "full" ? "rounded-3xl" : "rounded-2xl"}` }, /* @__PURE__ */ React6.createElement(
456
+ ), error && /* @__PURE__ */ React5.createElement("div", { className: "flex items-center gap-2 text-rose-500 dark:text-rose-400 text-sm bg-rose-50 dark:bg-rose-400/10 border border-rose-200 dark:border-rose-400/20 rounded-xl px-4 py-3" }, /* @__PURE__ */ React5.createElement(TriangleAlert, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ React5.createElement("span", null, error)), /* @__PURE__ */ React5.createElement("div", { ref: bottomRef })),
457
+ /* @__PURE__ */ React5.createElement("div", { className: `px-4 pb-4 pt-2 border-t border-slate-200 dark:border-white/10 ${isGlass ? "bg-transparent" : "bg-white dark:bg-[#0f0f1a]"}` }, /* @__PURE__ */ React5.createElement("div", { className: `flex items-end gap-2 bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 p-2 focus-within:border-slate-300 dark:focus-within:border-white/20 transition-all ${ui.borderRadius === "full" ? "rounded-3xl" : "rounded-2xl"}` }, /* @__PURE__ */ React5.createElement(
462
458
  "textarea",
463
459
  {
464
460
  ref: inputRef,
@@ -471,7 +467,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
471
467
  className: "flex-1 bg-transparent text-slate-900 dark:text-white/90 placeholder-slate-400 dark:placeholder-white/30 text-sm resize-none outline-none py-1.5 px-2 max-h-32 leading-relaxed disabled:opacity-50",
472
468
  style: { scrollbarWidth: "none" }
473
469
  }
474
- ), /* @__PURE__ */ React6.createElement(
470
+ ), /* @__PURE__ */ React5.createElement(
475
471
  "button",
476
472
  {
477
473
  onClick: sendMessage,
@@ -482,8 +478,8 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
482
478
  // slate-400/20 for light mode disabled
483
479
  }
484
480
  },
485
- /* @__PURE__ */ React6.createElement(ArrowUp, { className: "w-4 h-4 text-white" })
486
- )), /* @__PURE__ */ React6.createElement("p", { className: "text-center text-[10px] text-slate-400 dark:text-white/20 mt-2" }, "Press Enter to send \xB7 Shift+Enter for new line"))
481
+ /* @__PURE__ */ React5.createElement(ArrowUp, { className: "w-4 h-4 text-white" })
482
+ )), /* @__PURE__ */ React5.createElement("p", { className: "text-center text-[10px] text-slate-400 dark:text-white/20 mt-2" }, "Press Enter to send \xB7 Shift+Enter for new line"))
487
483
  );
488
484
  }
489
485
 
@@ -500,13 +496,13 @@ function ChatWidget({ position = "bottom-right" }) {
500
496
  setIsOpen(true);
501
497
  setHasUnread(false);
502
498
  };
503
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(
499
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(
504
500
  "div",
505
501
  {
506
502
  className: `fixed z-[9998] w-[380px] max-w-[calc(100vw-3rem)] transition-all duration-300 ease-in-out ${windowPositionClass} ${isOpen ? "opacity-100 translate-y-0 pointer-events-auto" : "opacity-0 translate-y-4 pointer-events-none"}`,
507
503
  style: { height: "600px", maxHeight: "calc(100vh - 6rem)" }
508
504
  },
509
- /* @__PURE__ */ React7.createElement(
505
+ /* @__PURE__ */ React6.createElement(
510
506
  ChatWindow,
511
507
  {
512
508
  className: "h-full relative z-10",
@@ -514,13 +510,13 @@ function ChatWidget({ position = "bottom-right" }) {
514
510
  onClose: () => setIsOpen(false)
515
511
  }
516
512
  ),
517
- /* @__PURE__ */ React7.createElement(
513
+ /* @__PURE__ */ React6.createElement(
518
514
  "div",
519
515
  {
520
516
  className: `absolute -bottom-1.5 w-4 h-4 rotate-45 border-r border-b border-slate-200 dark:border-white/10 z-0 ${ui.visualStyle === "solid" ? "bg-white dark:bg-[#0f0f1a]" : "bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl"} ${position === "bottom-left" ? "left-5" : "right-5"}`
521
517
  }
522
518
  )
523
- ), /* @__PURE__ */ React7.createElement(
519
+ ), /* @__PURE__ */ React6.createElement(
524
520
  "button",
525
521
  {
526
522
  onClick: isOpen ? () => setIsOpen(false) : handleOpen,
@@ -528,26 +524,26 @@ function ChatWidget({ position = "bottom-right" }) {
528
524
  style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
529
525
  "aria-label": "Open chat"
530
526
  },
531
- /* @__PURE__ */ React7.createElement(
527
+ /* @__PURE__ */ React6.createElement(
532
528
  "span",
533
529
  {
534
530
  className: "absolute inset-0 rounded-full animate-ping opacity-20",
535
531
  style: { background: ui.primaryColor }
536
532
  }
537
533
  ),
538
- /* @__PURE__ */ React7.createElement(
534
+ /* @__PURE__ */ React6.createElement(
539
535
  "span",
540
536
  {
541
537
  className: `transition-transform duration-300 ${isOpen ? "rotate-90 scale-90" : "rotate-0 scale-100"}`
542
538
  },
543
- isOpen ? /* @__PURE__ */ React7.createElement(X2, { className: "w-6 h-6 text-white" }) : /* @__PURE__ */ React7.createElement(MessageSquare2, { className: "w-6 h-6 text-white" })
539
+ isOpen ? /* @__PURE__ */ React6.createElement(X2, { className: "w-6 h-6 text-white" }) : /* @__PURE__ */ React6.createElement(MessageSquare, { className: "w-6 h-6 text-white" })
544
540
  ),
545
- hasUnread && !isOpen && /* @__PURE__ */ React7.createElement("span", { className: "absolute top-0 right-0 w-4 h-4 bg-rose-500 rounded-full border-2 border-white flex items-center justify-center text-[9px] font-bold text-white" }, "1")
541
+ hasUnread && !isOpen && /* @__PURE__ */ React6.createElement("span", { className: "absolute top-0 right-0 w-4 h-4 bg-rose-500 rounded-full border-2 border-white flex items-center justify-center text-[9px] font-bold text-white" }, "1")
546
542
  ));
547
543
  }
548
544
 
549
545
  // src/components/DocumentUpload.tsx
550
- import React8, { useState as useState5, useRef as useRef3 } from "react";
546
+ import React7, { useState as useState5, useRef as useRef3 } from "react";
551
547
  import { Upload, File, X as X3, CheckCircle, AlertCircle, Loader2 } from "lucide-react";
552
548
  function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
553
549
  const { ui } = useConfig();
@@ -603,7 +599,7 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
603
599
  };
604
600
  const isUploading = fileStates.some((s) => s.status === "uploading");
605
601
  const hasIdle = fileStates.some((s) => s.status === "idle");
606
- return /* @__PURE__ */ React8.createElement(
602
+ return /* @__PURE__ */ React7.createElement(
607
603
  "div",
608
604
  {
609
605
  className: `p-6 border-2 border-dashed transition-all duration-300 rounded-2xl ${isDragging ? "border-emerald-500 bg-emerald-50/50 dark:bg-emerald-500/5" : "border-slate-200 dark:border-white/10 bg-white dark:bg-white/5"} ${className}`,
@@ -611,14 +607,14 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
611
607
  onDragLeave,
612
608
  onDrop
613
609
  },
614
- /* @__PURE__ */ React8.createElement("div", { className: "flex flex-col items-center justify-center text-center" }, /* @__PURE__ */ React8.createElement(
610
+ /* @__PURE__ */ React7.createElement("div", { className: "flex flex-col items-center justify-center text-center" }, /* @__PURE__ */ React7.createElement(
615
611
  "div",
616
612
  {
617
613
  className: "w-12 h-12 rounded-full flex items-center justify-center mb-4 shadow-sm",
618
614
  style: { background: `linear-gradient(135deg, ${ui.primaryColor}20, ${ui.accentColor}20)` }
619
615
  },
620
- /* @__PURE__ */ React8.createElement(Upload, { className: "w-6 h-6", style: { color: ui.primaryColor } })
621
- ), /* @__PURE__ */ React8.createElement("h3", { className: "text-slate-900 dark:text-white font-semibold mb-1" }, "Upload Documents"), /* @__PURE__ */ React8.createElement("p", { className: "text-slate-500 dark:text-white/40 text-sm mb-6 max-w-xs" }, "Drag and drop PDF, DOCX, TXT, or JSON files to train your AI on your own data."), /* @__PURE__ */ React8.createElement(
616
+ /* @__PURE__ */ React7.createElement(Upload, { className: "w-6 h-6", style: { color: ui.primaryColor } })
617
+ ), /* @__PURE__ */ React7.createElement("h3", { className: "text-slate-900 dark:text-white font-semibold mb-1" }, "Upload Documents"), /* @__PURE__ */ React7.createElement("p", { className: "text-slate-500 dark:text-white/40 text-sm mb-6 max-w-xs" }, "Drag and drop PDF, DOCX, TXT, or JSON files to train your AI on your own data."), /* @__PURE__ */ React7.createElement(
622
618
  "button",
623
619
  {
624
620
  onClick: () => {
@@ -634,7 +630,7 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
634
630
  }
635
631
  },
636
632
  "Select Files"
637
- ), /* @__PURE__ */ React8.createElement(
633
+ ), /* @__PURE__ */ React7.createElement(
638
634
  "input",
639
635
  {
640
636
  ref: fileInputRef,
@@ -645,22 +641,22 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
645
641
  accept: ".pdf,.docx,.txt,.md,.json,.csv"
646
642
  }
647
643
  )),
648
- fileStates.length > 0 && /* @__PURE__ */ React8.createElement("div", { className: "mt-8 space-y-3" }, fileStates.map((state, i) => /* @__PURE__ */ React8.createElement(
644
+ fileStates.length > 0 && /* @__PURE__ */ React7.createElement("div", { className: "mt-8 space-y-3" }, fileStates.map((state, i) => /* @__PURE__ */ React7.createElement(
649
645
  "div",
650
646
  {
651
647
  key: i,
652
648
  className: "flex items-center justify-between p-3 rounded-xl bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/10"
653
649
  },
654
- /* @__PURE__ */ React8.createElement("div", { className: "flex items-center gap-3 overflow-hidden" }, /* @__PURE__ */ React8.createElement("div", { className: "w-8 h-8 rounded-lg bg-white dark:bg-white/10 flex items-center justify-center shadow-sm" }, /* @__PURE__ */ React8.createElement(File, { className: "w-4 h-4 text-slate-400" })), /* @__PURE__ */ React8.createElement("div", { className: "truncate" }, /* @__PURE__ */ React8.createElement("p", { className: "text-xs font-medium text-slate-700 dark:text-white/80 truncate" }, state.file.name), /* @__PURE__ */ React8.createElement("p", { className: "text-[10px] text-slate-400" }, (state.file.size / 1024).toFixed(1), " KB"))),
655
- /* @__PURE__ */ React8.createElement("div", { className: "flex items-center gap-2" }, state.status === "uploading" && /* @__PURE__ */ React8.createElement(Loader2, { className: "w-4 h-4 text-slate-400 animate-spin" }), state.status === "success" && /* @__PURE__ */ React8.createElement(CheckCircle, { className: "w-4 h-4 text-emerald-500" }), state.status === "error" && /* @__PURE__ */ React8.createElement("div", { title: state.error }, /* @__PURE__ */ React8.createElement(AlertCircle, { className: "w-4 h-4 text-rose-500" })), state.status !== "uploading" && /* @__PURE__ */ React8.createElement(
650
+ /* @__PURE__ */ React7.createElement("div", { className: "flex items-center gap-3 overflow-hidden" }, /* @__PURE__ */ React7.createElement("div", { className: "w-8 h-8 rounded-lg bg-white dark:bg-white/10 flex items-center justify-center shadow-sm" }, /* @__PURE__ */ React7.createElement(File, { className: "w-4 h-4 text-slate-400" })), /* @__PURE__ */ React7.createElement("div", { className: "truncate" }, /* @__PURE__ */ React7.createElement("p", { className: "text-xs font-medium text-slate-700 dark:text-white/80 truncate" }, state.file.name), /* @__PURE__ */ React7.createElement("p", { className: "text-[10px] text-slate-400" }, (state.file.size / 1024).toFixed(1), " KB"))),
651
+ /* @__PURE__ */ React7.createElement("div", { className: "flex items-center gap-2" }, state.status === "uploading" && /* @__PURE__ */ React7.createElement(Loader2, { className: "w-4 h-4 text-slate-400 animate-spin" }), state.status === "success" && /* @__PURE__ */ React7.createElement(CheckCircle, { className: "w-4 h-4 text-emerald-500" }), state.status === "error" && /* @__PURE__ */ React7.createElement("div", { title: state.error }, /* @__PURE__ */ React7.createElement(AlertCircle, { className: "w-4 h-4 text-rose-500" })), state.status !== "uploading" && /* @__PURE__ */ React7.createElement(
656
652
  "button",
657
653
  {
658
654
  onClick: () => removeFile(i),
659
655
  className: "p-1 rounded-md hover:bg-slate-200 dark:hover:bg-white/10 transition-colors"
660
656
  },
661
- /* @__PURE__ */ React8.createElement(X3, { className: "w-3.5 h-3.5 text-slate-400" })
657
+ /* @__PURE__ */ React7.createElement(X3, { className: "w-3.5 h-3.5 text-slate-400" })
662
658
  ))
663
- )), hasIdle && !isUploading && /* @__PURE__ */ React8.createElement(
659
+ )), hasIdle && !isUploading && /* @__PURE__ */ React7.createElement(
664
660
  "button",
665
661
  {
666
662
  onClick: uploadFiles,