@djangocfg/ext-knowbase 1.0.21 → 1.0.22

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/hooks.js CHANGED
@@ -5,11 +5,13 @@ import { initializeExtensionAPI, createExtensionAPI } from '@djangocfg/ext-base/
5
5
  import useSWR, { useSWRConfig } from 'swr';
6
6
  import { createExtensionConfig } from '@djangocfg/ext-base';
7
7
  import '@djangocfg/ext-base/hooks';
8
- import { createContext, useContext, useState, useCallback, useRef, useEffect } from 'react';
8
+ import { createContext, useContext, useState, useCallback, useRef, useMemo, useEffect } from 'react';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import { Bot, ExternalLink, User, Loader2, Send, MessageSquare, Clock, Archive, Trash2, List, Plus, X, Minimize2, Maximize2 } from 'lucide-react';
11
11
  import { usePathname } from 'next/navigation';
12
12
  import { createPortal } from 'react-dom';
13
+ import { createExtensionI18n, createTypedExtensionT } from '@djangocfg/ext-base/i18n';
14
+ import { useT } from '@djangocfg/i18n';
13
15
  import { ScrollArea, Avatar, Card, CardContent, Badge, AvatarImage, AvatarFallback, Textarea, Button, Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, CardHeader } from '@djangocfg/ui-nextjs';
14
16
  import { useIsMobile, useLocalStorage } from '@djangocfg/ui-core/hooks';
15
17
  import moment from 'moment';
@@ -4788,7 +4790,7 @@ var apiKnowbase = createExtensionAPI(API);
4788
4790
  // package.json
4789
4791
  var package_default = {
4790
4792
  name: "@djangocfg/ext-knowbase",
4791
- version: "1.0.21",
4793
+ version: "1.0.22",
4792
4794
  description: "Knowledge base and chat extension for DjangoCFG",
4793
4795
  keywords: [
4794
4796
  "django",
@@ -4834,6 +4836,11 @@ var package_default = {
4834
4836
  types: "./dist/config.d.ts",
4835
4837
  import: "./dist/config.js",
4836
4838
  require: "./dist/config.cjs"
4839
+ },
4840
+ "./i18n": {
4841
+ types: "./dist/i18n.d.ts",
4842
+ import: "./dist/i18n.js",
4843
+ require: "./dist/i18n.cjs"
4837
4844
  }
4838
4845
  },
4839
4846
  files: [
@@ -4849,6 +4856,7 @@ var package_default = {
4849
4856
  peerDependencies: {
4850
4857
  "@djangocfg/api": "workspace:*",
4851
4858
  "@djangocfg/ext-base": "workspace:*",
4859
+ "@djangocfg/i18n": "workspace:*",
4852
4860
  "@djangocfg/ui-core": "workspace:*",
4853
4861
  "@djangocfg/ui-nextjs": "workspace:*",
4854
4862
  consola: "^3.4.2",
@@ -4865,6 +4873,7 @@ var package_default = {
4865
4873
  devDependencies: {
4866
4874
  "@djangocfg/api": "workspace:*",
4867
4875
  "@djangocfg/ext-base": "workspace:*",
4876
+ "@djangocfg/i18n": "workspace:*",
4868
4877
  "@djangocfg/ui-core": "workspace:*",
4869
4878
  "@djangocfg/typescript-config": "workspace:*",
4870
4879
  "@types/node": "^24.7.2",
@@ -5236,6 +5245,117 @@ function useChatUI() {
5236
5245
  }
5237
5246
  return context;
5238
5247
  }
5248
+
5249
+ // src/i18n/locales/en.ts
5250
+ var en = {
5251
+ chat: {
5252
+ title: "Knowledge Assistant",
5253
+ titleShort: "Support",
5254
+ placeholder: "Ask me anything...",
5255
+ enterToSend: "Press Enter to send, Shift+Enter for new line",
5256
+ thinking: "Thinking...",
5257
+ source: "Source {index}",
5258
+ startConversation: "Start a Conversation",
5259
+ startConversationDescription: "Ask me anything about the documentation, features, or get help with your project.",
5260
+ openChat: "Open Support Chat"
5261
+ },
5262
+ sessions: {
5263
+ title: "Chat Sessions",
5264
+ description: "View and manage your chat history",
5265
+ noSessions: "No Sessions Yet",
5266
+ noSessionsDescription: "Start a new conversation to create your first session.",
5267
+ untitled: "Untitled Session",
5268
+ active: "Active",
5269
+ archive: "Archive",
5270
+ delete: "Delete",
5271
+ loadingMore: "Loading more...",
5272
+ noMore: "No more sessions",
5273
+ newChat: "New Chat"
5274
+ },
5275
+ actions: {
5276
+ sessions: "Sessions",
5277
+ collapse: "Collapse",
5278
+ expand: "Expand",
5279
+ close: "Close"
5280
+ }
5281
+ };
5282
+
5283
+ // src/i18n/locales/ru.ts
5284
+ var ru = {
5285
+ chat: {
5286
+ title: "\u0411\u0430\u0437\u0430 \u0437\u043D\u0430\u043D\u0438\u0439",
5287
+ titleShort: "\u041F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u0430",
5288
+ placeholder: "\u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u0432\u043E\u043F\u0440\u043E\u0441...",
5289
+ enterToSend: "Enter \u0434\u043B\u044F \u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0438, Shift+Enter \u0434\u043B\u044F \u043D\u043E\u0432\u043E\u0439 \u0441\u0442\u0440\u043E\u043A\u0438",
5290
+ thinking: "\u0414\u0443\u043C\u0430\u044E...",
5291
+ source: "\u0418\u0441\u0442\u043E\u0447\u043D\u0438\u043A {index}",
5292
+ startConversation: "\u041D\u0430\u0447\u0430\u0442\u044C \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440",
5293
+ startConversationDescription: "\u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u043B\u044E\u0431\u043E\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u043E \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u0438, \u0444\u0443\u043D\u043A\u0446\u0438\u044F\u0445 \u0438\u043B\u0438 \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u0435 \u043F\u043E\u043C\u043E\u0449\u044C \u0441 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u043C.",
5294
+ openChat: "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0447\u0430\u0442 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u0438"
5295
+ },
5296
+ sessions: {
5297
+ title: "\u0421\u0435\u0441\u0441\u0438\u0438 \u0447\u0430\u0442\u0430",
5298
+ description: "\u041F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u0438 \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0438\u0441\u0442\u043E\u0440\u0438\u0435\u0439 \u0447\u0430\u0442\u0430",
5299
+ noSessions: "\u041D\u0435\u0442 \u0441\u0435\u0441\u0441\u0438\u0439",
5300
+ noSessionsDescription: "\u041D\u0430\u0447\u043D\u0438\u0442\u0435 \u043D\u043E\u0432\u044B\u0439 \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440, \u0447\u0442\u043E\u0431\u044B \u0441\u043E\u0437\u0434\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u0443\u044E \u0441\u0435\u0441\u0441\u0438\u044E.",
5301
+ untitled: "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u044F",
5302
+ active: "\u0410\u043A\u0442\u0438\u0432\u043D\u0430\u044F",
5303
+ archive: "\u0410\u0440\u0445\u0438\u0432\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
5304
+ delete: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
5305
+ loadingMore: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430...",
5306
+ noMore: "\u0411\u043E\u043B\u044C\u0448\u0435 \u043D\u0435\u0442 \u0441\u0435\u0441\u0441\u0438\u0439",
5307
+ newChat: "\u041D\u043E\u0432\u044B\u0439 \u0447\u0430\u0442"
5308
+ },
5309
+ actions: {
5310
+ sessions: "\u0421\u0435\u0441\u0441\u0438\u0438",
5311
+ collapse: "\u0421\u0432\u0435\u0440\u043D\u0443\u0442\u044C",
5312
+ expand: "\u0420\u0430\u0437\u0432\u0435\u0440\u043D\u0443\u0442\u044C",
5313
+ close: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C"
5314
+ }
5315
+ };
5316
+
5317
+ // src/i18n/locales/ko.ts
5318
+ var ko = {
5319
+ chat: {
5320
+ title: "\uC9C0\uC2DD \uB3C4\uC6B0\uBBF8",
5321
+ titleShort: "\uC9C0\uC6D0",
5322
+ placeholder: "\uBB34\uC5C7\uC774\uB4E0 \uBB3C\uC5B4\uBCF4\uC138\uC694...",
5323
+ enterToSend: "Enter\uB85C \uC804\uC1A1, Shift+Enter\uB85C \uC904\uBC14\uAFC8",
5324
+ thinking: "\uC0DD\uAC01 \uC911...",
5325
+ source: "\uCD9C\uCC98 {index}",
5326
+ startConversation: "\uB300\uD654 \uC2DC\uC791\uD558\uAE30",
5327
+ startConversationDescription: "\uBB38\uC11C, \uAE30\uB2A5\uC5D0 \uB300\uD574 \uC9C8\uBB38\uD558\uAC70\uB098 \uD504\uB85C\uC81D\uD2B8 \uB3C4\uC6C0\uC744 \uBC1B\uC73C\uC138\uC694.",
5328
+ openChat: "\uC9C0\uC6D0 \uCC44\uD305 \uC5F4\uAE30"
5329
+ },
5330
+ sessions: {
5331
+ title: "\uCC44\uD305 \uC138\uC158",
5332
+ description: "\uCC44\uD305 \uAE30\uB85D \uBCF4\uAE30 \uBC0F \uAD00\uB9AC",
5333
+ noSessions: "\uC138\uC158 \uC5C6\uC74C",
5334
+ noSessionsDescription: "\uC0C8 \uB300\uD654\uB97C \uC2DC\uC791\uD558\uC5EC \uCCAB \uBC88\uC9F8 \uC138\uC158\uC744 \uB9CC\uB4DC\uC138\uC694.",
5335
+ untitled: "\uC81C\uBAA9 \uC5C6\uC74C",
5336
+ active: "\uD65C\uC131",
5337
+ archive: "\uBCF4\uAD00",
5338
+ delete: "\uC0AD\uC81C",
5339
+ loadingMore: "\uBD88\uB7EC\uC624\uB294 \uC911...",
5340
+ noMore: "\uB354 \uC774\uC0C1 \uC138\uC158 \uC5C6\uC74C",
5341
+ newChat: "\uC0C8 \uCC44\uD305"
5342
+ },
5343
+ actions: {
5344
+ sessions: "\uC138\uC158",
5345
+ collapse: "\uCD95\uC18C",
5346
+ expand: "\uD655\uC7A5",
5347
+ close: "\uB2EB\uAE30"
5348
+ }
5349
+ };
5350
+
5351
+ // src/i18n/index.ts
5352
+ var KNOWBASE_NAMESPACE = "knowbase";
5353
+ var knowbaseI18n = createExtensionI18n({
5354
+ namespace: KNOWBASE_NAMESPACE,
5355
+ defaultLocale: "en",
5356
+ locales: { en, ru, ko }
5357
+ });
5358
+ knowbaseI18n.getAllTranslations();
5239
5359
  var isDevelopment = process.env.NODE_ENV === "development";
5240
5360
  var logger = createConsola({
5241
5361
  level: isDevelopment ? 4 : 1
@@ -5252,8 +5372,16 @@ var MessageList = ({
5252
5372
  autoScroll = true,
5253
5373
  className = ""
5254
5374
  }) => {
5375
+ const baseT = useT();
5376
+ const kt = createTypedExtensionT(baseT, KNOWBASE_NAMESPACE);
5255
5377
  const scrollRef = useRef(null);
5256
5378
  const { user } = useAuth();
5379
+ const labels = useMemo(() => ({
5380
+ startConversation: kt("chat.startConversation"),
5381
+ startConversationDescription: kt("chat.startConversationDescription"),
5382
+ source: kt("chat.source"),
5383
+ thinking: kt("chat.thinking")
5384
+ }), [kt]);
5257
5385
  useEffect(() => {
5258
5386
  if (autoScroll && scrollRef.current) {
5259
5387
  const scrollContainer = scrollRef.current.querySelector("[data-radix-scroll-area-viewport]");
@@ -5269,8 +5397,8 @@ var MessageList = ({
5269
5397
  return /* @__PURE__ */ jsx(ScrollArea, { className: `h-full bg-muted/50 ${className}`, viewportRef: scrollRef, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 p-4", children: [
5270
5398
  messages.length === 0 && !isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full text-center py-12", children: [
5271
5399
  /* @__PURE__ */ jsx(Bot, { className: "h-12 w-12 text-muted-foreground mb-4" }),
5272
- /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: "Start a Conversation" }),
5273
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-md", children: "Ask me anything about the documentation, features, or get help with your project." })
5400
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: labels.startConversation }),
5401
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-md", children: labels.startConversationDescription })
5274
5402
  ] }) : messages.map((message, index) => {
5275
5403
  const isUser = message.role === Enums.ChatMessageRole.USER;
5276
5404
  const isAssistant = message.role === Enums.ChatMessageRole.ASSISTANT;
@@ -5299,10 +5427,10 @@ var MessageList = ({
5299
5427
  Badge,
5300
5428
  {
5301
5429
  variant: "secondary",
5302
- className: "text-xs flex items-center gap-1 cursor-pointer \n hover:bg-secondary/80 hover:scale-105 active:scale-95 \n transition-all duration-200 animate-in fade-in zoom-in-95",
5430
+ className: "text-xs flex items-center gap-1 cursor-pointer\n hover:bg-secondary/80 hover:scale-105 active:scale-95\n transition-all duration-200 animate-in fade-in zoom-in-95",
5303
5431
  style: { animationDelay: `${(idx + 1) * 100}ms` },
5304
5432
  children: [
5305
- source.document_title || `Source ${idx + 1}`,
5433
+ source.document_title || labels.source.replace("{index}", String(idx + 1)),
5306
5434
  /* @__PURE__ */ jsx(ExternalLink, { className: "h-3 w-3" })
5307
5435
  ]
5308
5436
  }
@@ -5323,7 +5451,7 @@ var MessageList = ({
5323
5451
  /* @__PURE__ */ jsx(Avatar, { className: "h-8 w-8 shrink-0 animate-pulse", children: /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center justify-center bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(Bot, { className: "h-5 w-5 animate-bounce" }) }) }),
5324
5452
  /* @__PURE__ */ jsx(Card, { className: "bg-muted animate-pulse", children: /* @__PURE__ */ jsx(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
5325
5453
  /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
5326
- /* @__PURE__ */ jsx("span", { className: "animate-pulse", children: "Thinking..." })
5454
+ /* @__PURE__ */ jsx("span", { className: "animate-pulse", children: labels.thinking })
5327
5455
  ] }) }) })
5328
5456
  ] })
5329
5457
  ] }) });
@@ -5332,12 +5460,18 @@ var MessageInput = ({
5332
5460
  onSend,
5333
5461
  isLoading = false,
5334
5462
  disabled = false,
5335
- placeholder = "Ask me anything...",
5463
+ placeholder,
5336
5464
  className = ""
5337
5465
  }) => {
5466
+ const baseT = useT();
5467
+ const kt = createTypedExtensionT(baseT, KNOWBASE_NAMESPACE);
5338
5468
  const [message, setMessage] = useState("");
5339
5469
  const [rows, setRows] = useState(1);
5340
5470
  const textareaRef = useRef(null);
5471
+ const labels = useMemo(() => ({
5472
+ placeholder: placeholder || kt("chat.placeholder"),
5473
+ enterToSend: kt("chat.enterToSend")
5474
+ }), [kt, placeholder]);
5341
5475
  useEffect(() => {
5342
5476
  if (textareaRef.current) {
5343
5477
  const lineHeight = 24;
@@ -5392,10 +5526,10 @@ var MessageInput = ({
5392
5526
  value: message,
5393
5527
  onChange: (e) => setMessage(e.target.value),
5394
5528
  onKeyDown: handleKeyDown,
5395
- placeholder,
5529
+ placeholder: labels.placeholder,
5396
5530
  disabled: isDisabled,
5397
5531
  rows,
5398
- className: "resize-none min-h-[40px] max-h-[120px] transition-all duration-200 \n focus:ring-2 focus:ring-primary/20",
5532
+ className: "resize-none min-h-[40px] max-h-[120px] transition-all duration-200\n focus:ring-2 focus:ring-primary/20",
5399
5533
  style: { resize: "none" }
5400
5534
  }
5401
5535
  ),
@@ -5405,12 +5539,12 @@ var MessageInput = ({
5405
5539
  type: "submit",
5406
5540
  size: "icon",
5407
5541
  disabled: !canSend,
5408
- className: "shrink-0 h-10 w-10 transition-all duration-200 \n hover:scale-110 active:scale-95 disabled:scale-100",
5542
+ className: "shrink-0 h-10 w-10 transition-all duration-200\n hover:scale-110 active:scale-95 disabled:scale-100",
5409
5543
  children: isLoading ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "h-4 w-4" })
5410
5544
  }
5411
5545
  )
5412
5546
  ] }),
5413
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-2", children: "Press Enter to send, Shift+Enter for new line" })
5547
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-2", children: labels.enterToSend })
5414
5548
  ] });
5415
5549
  };
5416
5550
  var PAGE_SIZE = 20;
@@ -5467,6 +5601,8 @@ var SessionList = ({
5467
5601
  onSelectSession,
5468
5602
  className = ""
5469
5603
  }) => {
5604
+ const baseT = useT();
5605
+ const kt = createTypedExtensionT(baseT, KNOWBASE_NAMESPACE);
5470
5606
  const { deleteSession, archiveSession } = useKnowbaseSessionsContext();
5471
5607
  const {
5472
5608
  sessions,
@@ -5475,6 +5611,18 @@ var SessionList = ({
5475
5611
  hasMore,
5476
5612
  loadMore
5477
5613
  } = useInfiniteSessions();
5614
+ const labels = useMemo(() => ({
5615
+ title: kt("sessions.title"),
5616
+ description: kt("sessions.description"),
5617
+ noSessions: kt("sessions.noSessions"),
5618
+ noSessionsDescription: kt("sessions.noSessionsDescription"),
5619
+ untitled: kt("sessions.untitled"),
5620
+ active: kt("sessions.active"),
5621
+ archive: kt("sessions.archive"),
5622
+ delete: kt("sessions.delete"),
5623
+ loadingMore: kt("sessions.loadingMore"),
5624
+ noMore: kt("sessions.noMore")
5625
+ }), [kt]);
5478
5626
  const scrollRef = useRef(null);
5479
5627
  const handleScroll = useCallback(() => {
5480
5628
  if (!scrollRef.current || isLoadingMore || !hasMore) return;
@@ -5497,13 +5645,13 @@ var SessionList = ({
5497
5645
  };
5498
5646
  return /* @__PURE__ */ jsx(Sheet, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: `w-[400px] sm:w-[540px] ${className}`, children: [
5499
5647
  /* @__PURE__ */ jsxs(SheetHeader, { children: [
5500
- /* @__PURE__ */ jsx(SheetTitle, { children: "Chat Sessions" }),
5501
- /* @__PURE__ */ jsx(SheetDescription, { children: "View and manage your chat history" })
5648
+ /* @__PURE__ */ jsx(SheetTitle, { children: labels.title }),
5649
+ /* @__PURE__ */ jsx(SheetDescription, { children: labels.description })
5502
5650
  ] }),
5503
5651
  /* @__PURE__ */ jsx(ScrollArea, { className: "h-[calc(100vh-120px)] mt-6", viewportRef: scrollRef, children: isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }) : !sessions || sessions.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
5504
5652
  /* @__PURE__ */ jsx(MessageSquare, { className: "h-12 w-12 text-muted-foreground mb-4" }),
5505
- /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: "No Sessions Yet" }),
5506
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-md", children: "Start a new conversation to create your first session." })
5653
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-foreground mb-2", children: labels.noSessions }),
5654
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-md", children: labels.noSessionsDescription })
5507
5655
  ] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
5508
5656
  sessions.map((session, index) => /* @__PURE__ */ jsxs(
5509
5657
  "div",
@@ -5518,8 +5666,8 @@ var SessionList = ({
5518
5666
  /* @__PURE__ */ jsx("div", { className: "shrink-0 mt-1", children: /* @__PURE__ */ jsx(MessageSquare, { className: "h-5 w-5 text-muted-foreground" }) }),
5519
5667
  /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
5520
5668
  /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2 mb-1", children: [
5521
- /* @__PURE__ */ jsx("h4", { className: "font-medium text-sm truncate", children: session.title || "Untitled Session" }),
5522
- session.is_active && /* @__PURE__ */ jsx(Badge, { variant: "default", className: "shrink-0 text-xs", children: "Active" })
5669
+ /* @__PURE__ */ jsx("h4", { className: "font-medium text-sm truncate", children: session.title || labels.untitled }),
5670
+ session.is_active && /* @__PURE__ */ jsx(Badge, { variant: "default", className: "shrink-0 text-xs", children: labels.active })
5523
5671
  ] }),
5524
5672
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
5525
5673
  /* @__PURE__ */ jsx(Clock, { className: "h-3 w-3" }),
@@ -5537,7 +5685,7 @@ var SessionList = ({
5537
5685
  e.stopPropagation();
5538
5686
  archiveSession(session.id, {});
5539
5687
  },
5540
- title: "Archive",
5688
+ title: labels.archive,
5541
5689
  children: /* @__PURE__ */ jsx(Archive, { className: "h-4 w-4" })
5542
5690
  }
5543
5691
  ),
@@ -5546,12 +5694,12 @@ var SessionList = ({
5546
5694
  {
5547
5695
  variant: "ghost",
5548
5696
  size: "sm",
5549
- className: "h-8 w-8 p-0 text-destructive hover:text-destructive \n hover:scale-110 active:scale-95 transition-transform duration-200",
5697
+ className: "h-8 w-8 p-0 text-destructive hover:text-destructive\n hover:scale-110 active:scale-95 transition-transform duration-200",
5550
5698
  onClick: (e) => {
5551
5699
  e.stopPropagation();
5552
5700
  deleteSession(session.id);
5553
5701
  },
5554
- title: "Delete",
5702
+ title: labels.delete,
5555
5703
  children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
5556
5704
  }
5557
5705
  )
@@ -5562,9 +5710,9 @@ var SessionList = ({
5562
5710
  )),
5563
5711
  isLoadingMore && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-6", children: [
5564
5712
  /* @__PURE__ */ jsx(Loader2, { className: "h-5 w-5 animate-spin text-muted-foreground mr-2" }),
5565
- /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "Loading more..." })
5713
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: labels.loadingMore })
5566
5714
  ] }),
5567
- !hasMore && sessions.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-center py-4", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "No more sessions" }) })
5715
+ !hasMore && sessions.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-center py-4", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: labels.noMore }) })
5568
5716
  ] }) })
5569
5717
  ] }) });
5570
5718
  };
@@ -5577,6 +5725,8 @@ var ChatWidget = ({
5577
5725
  onToggle,
5578
5726
  onMessage
5579
5727
  }) => {
5728
+ const baseT = useT();
5729
+ const kt = createTypedExtensionT(baseT, KNOWBASE_NAMESPACE);
5580
5730
  const { sendQuery, getChatHistory } = useKnowbaseChatContext();
5581
5731
  const { createSession, getSession } = useKnowbaseSessionsContext();
5582
5732
  const {
@@ -5587,6 +5737,17 @@ var ChatWidget = ({
5587
5737
  toggleSources,
5588
5738
  toggleTimestamps
5589
5739
  } = useChatUI();
5740
+ const labels = useMemo(() => ({
5741
+ title: kt("chat.title"),
5742
+ titleShort: kt("chat.titleShort"),
5743
+ placeholder: kt("chat.placeholder"),
5744
+ openChat: kt("chat.openChat"),
5745
+ sessions: kt("actions.sessions"),
5746
+ newChat: kt("sessions.newChat"),
5747
+ collapse: kt("actions.collapse"),
5748
+ expand: kt("actions.expand"),
5749
+ close: kt("actions.close")
5750
+ }), [kt]);
5590
5751
  const pathname = usePathname();
5591
5752
  const isMobile = useIsMobile();
5592
5753
  const [isLoading, setIsLoading] = useState(false);
@@ -5727,7 +5888,7 @@ var ChatWidget = ({
5727
5888
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b bg-background shadow-sm", children: [
5728
5889
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5729
5890
  /* @__PURE__ */ jsx(MessageSquare, { className: "h-5 w-5 text-primary" }),
5730
- /* @__PURE__ */ jsx("h2", { className: "font-semibold text-foreground", children: "Knowledge Assistant" })
5891
+ /* @__PURE__ */ jsx("h2", { className: "font-semibold text-foreground", children: labels.title })
5731
5892
  ] }),
5732
5893
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5733
5894
  /* @__PURE__ */ jsx(
@@ -5737,7 +5898,7 @@ var ChatWidget = ({
5737
5898
  size: "sm",
5738
5899
  onClick: () => setShowSessions(true),
5739
5900
  className: "text-muted-foreground hover:text-foreground",
5740
- title: "Sessions",
5901
+ title: labels.sessions,
5741
5902
  children: /* @__PURE__ */ jsx(List, { className: "h-5 w-5" })
5742
5903
  }
5743
5904
  ),
@@ -5748,7 +5909,7 @@ var ChatWidget = ({
5748
5909
  size: "sm",
5749
5910
  onClick: handleNewChat,
5750
5911
  className: "text-muted-foreground hover:text-foreground",
5751
- title: "New Chat",
5912
+ title: labels.newChat,
5752
5913
  children: /* @__PURE__ */ jsx(Plus, { className: "h-5 w-5" })
5753
5914
  }
5754
5915
  ),
@@ -5781,7 +5942,7 @@ var ChatWidget = ({
5781
5942
  {
5782
5943
  onSend: handleSendMessage,
5783
5944
  isLoading,
5784
- placeholder: "Ask me anything..."
5945
+ placeholder: labels.placeholder
5785
5946
  }
5786
5947
  )
5787
5948
  ] })
@@ -5830,7 +5991,7 @@ var ChatWidget = ({
5830
5991
  /* @__PURE__ */ jsxs(CardHeader, { className: "flex-row items-center justify-between space-y-0 pb-3 border-b", children: [
5831
5992
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5832
5993
  /* @__PURE__ */ jsx(MessageSquare, { className: "h-5 w-5 text-primary" }),
5833
- /* @__PURE__ */ jsx("h3", { className: "font-semibold text-foreground", children: "Support" })
5994
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-foreground", children: labels.titleShort })
5834
5995
  ] }),
5835
5996
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
5836
5997
  /* @__PURE__ */ jsx(
@@ -5840,7 +6001,7 @@ var ChatWidget = ({
5840
6001
  size: "sm",
5841
6002
  onClick: () => setShowSessions(true),
5842
6003
  className: "h-8 w-8 p-0",
5843
- title: "Sessions",
6004
+ title: labels.sessions,
5844
6005
  children: /* @__PURE__ */ jsx(List, { className: "h-4 w-4" })
5845
6006
  }
5846
6007
  ),
@@ -5851,7 +6012,7 @@ var ChatWidget = ({
5851
6012
  size: "sm",
5852
6013
  onClick: handleNewChat,
5853
6014
  className: "h-8 w-8 p-0",
5854
- title: "New Chat",
6015
+ title: labels.newChat,
5855
6016
  children: /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" })
5856
6017
  }
5857
6018
  ),
@@ -5862,7 +6023,7 @@ var ChatWidget = ({
5862
6023
  size: "sm",
5863
6024
  onClick: uiState.isExpanded ? collapseChat : expandChat,
5864
6025
  className: "h-8 w-8 p-0",
5865
- title: uiState.isExpanded ? "Collapse" : "Expand",
6026
+ title: uiState.isExpanded ? labels.collapse : labels.expand,
5866
6027
  children: uiState.isExpanded ? /* @__PURE__ */ jsx(Minimize2, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Maximize2, { className: "h-4 w-4" })
5867
6028
  }
5868
6029
  ),
@@ -5873,7 +6034,7 @@ var ChatWidget = ({
5873
6034
  size: "sm",
5874
6035
  onClick: toggleChat,
5875
6036
  className: "h-8 w-8 p-0",
5876
- title: "Close",
6037
+ title: labels.close,
5877
6038
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
5878
6039
  }
5879
6040
  )
@@ -5896,7 +6057,7 @@ var ChatWidget = ({
5896
6057
  {
5897
6058
  onSend: handleSendMessage,
5898
6059
  isLoading,
5899
- placeholder: "Ask me anything..."
6060
+ placeholder: labels.placeholder
5900
6061
  }
5901
6062
  )
5902
6063
  ] })
@@ -5931,14 +6092,14 @@ var ChatWidget = ({
5931
6092
  Button,
5932
6093
  {
5933
6094
  onClick: toggleChat,
5934
- className: "w-full h-full rounded-full shadow-2xl \n hover:scale-110 hover:rotate-12 active:scale-95 \n transition-all duration-300 ease-out\n flex items-center justify-center\n group",
6095
+ className: "w-full h-full rounded-full shadow-2xl\n hover:scale-110 hover:rotate-12 active:scale-95\n transition-all duration-300 ease-out\n flex items-center justify-center\n group",
5935
6096
  style: {
5936
6097
  backgroundColor: "hsl(var(--primary))",
5937
6098
  borderRadius: "50%",
5938
6099
  padding: 0
5939
6100
  },
5940
- title: "Open Support Chat",
5941
- "aria-label": "Open Support Chat",
6101
+ title: labels.openChat,
6102
+ "aria-label": labels.openChat,
5942
6103
  children: /* @__PURE__ */ jsx(
5943
6104
  MessageSquare,
5944
6105
  {
package/dist/i18n.cjs ADDED
@@ -0,0 +1,144 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/i18n/index.ts
20
+ var i18n_exports = {};
21
+ __export(i18n_exports, {
22
+ KNOWBASE_NAMESPACE: () => KNOWBASE_NAMESPACE,
23
+ knowbaseI18n: () => knowbaseI18n,
24
+ knowbaseTranslations: () => knowbaseTranslations
25
+ });
26
+ module.exports = __toCommonJS(i18n_exports);
27
+ var import_i18n = require("@djangocfg/ext-base/i18n");
28
+
29
+ // src/i18n/locales/en.ts
30
+ var en = {
31
+ chat: {
32
+ title: "Knowledge Assistant",
33
+ titleShort: "Support",
34
+ placeholder: "Ask me anything...",
35
+ enterToSend: "Press Enter to send, Shift+Enter for new line",
36
+ thinking: "Thinking...",
37
+ source: "Source {index}",
38
+ startConversation: "Start a Conversation",
39
+ startConversationDescription: "Ask me anything about the documentation, features, or get help with your project.",
40
+ openChat: "Open Support Chat"
41
+ },
42
+ sessions: {
43
+ title: "Chat Sessions",
44
+ description: "View and manage your chat history",
45
+ noSessions: "No Sessions Yet",
46
+ noSessionsDescription: "Start a new conversation to create your first session.",
47
+ untitled: "Untitled Session",
48
+ active: "Active",
49
+ archive: "Archive",
50
+ delete: "Delete",
51
+ loadingMore: "Loading more...",
52
+ noMore: "No more sessions",
53
+ newChat: "New Chat"
54
+ },
55
+ actions: {
56
+ sessions: "Sessions",
57
+ collapse: "Collapse",
58
+ expand: "Expand",
59
+ close: "Close"
60
+ }
61
+ };
62
+
63
+ // src/i18n/locales/ru.ts
64
+ var ru = {
65
+ chat: {
66
+ title: "\u0411\u0430\u0437\u0430 \u0437\u043D\u0430\u043D\u0438\u0439",
67
+ titleShort: "\u041F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u0430",
68
+ placeholder: "\u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u0432\u043E\u043F\u0440\u043E\u0441...",
69
+ enterToSend: "Enter \u0434\u043B\u044F \u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0438, Shift+Enter \u0434\u043B\u044F \u043D\u043E\u0432\u043E\u0439 \u0441\u0442\u0440\u043E\u043A\u0438",
70
+ thinking: "\u0414\u0443\u043C\u0430\u044E...",
71
+ source: "\u0418\u0441\u0442\u043E\u0447\u043D\u0438\u043A {index}",
72
+ startConversation: "\u041D\u0430\u0447\u0430\u0442\u044C \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440",
73
+ startConversationDescription: "\u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u043B\u044E\u0431\u043E\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u043E \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u0438, \u0444\u0443\u043D\u043A\u0446\u0438\u044F\u0445 \u0438\u043B\u0438 \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u0435 \u043F\u043E\u043C\u043E\u0449\u044C \u0441 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u043C.",
74
+ openChat: "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0447\u0430\u0442 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u0438"
75
+ },
76
+ sessions: {
77
+ title: "\u0421\u0435\u0441\u0441\u0438\u0438 \u0447\u0430\u0442\u0430",
78
+ description: "\u041F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u0438 \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0438\u0441\u0442\u043E\u0440\u0438\u0435\u0439 \u0447\u0430\u0442\u0430",
79
+ noSessions: "\u041D\u0435\u0442 \u0441\u0435\u0441\u0441\u0438\u0439",
80
+ noSessionsDescription: "\u041D\u0430\u0447\u043D\u0438\u0442\u0435 \u043D\u043E\u0432\u044B\u0439 \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440, \u0447\u0442\u043E\u0431\u044B \u0441\u043E\u0437\u0434\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u0443\u044E \u0441\u0435\u0441\u0441\u0438\u044E.",
81
+ untitled: "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u044F",
82
+ active: "\u0410\u043A\u0442\u0438\u0432\u043D\u0430\u044F",
83
+ archive: "\u0410\u0440\u0445\u0438\u0432\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
84
+ delete: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
85
+ loadingMore: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430...",
86
+ noMore: "\u0411\u043E\u043B\u044C\u0448\u0435 \u043D\u0435\u0442 \u0441\u0435\u0441\u0441\u0438\u0439",
87
+ newChat: "\u041D\u043E\u0432\u044B\u0439 \u0447\u0430\u0442"
88
+ },
89
+ actions: {
90
+ sessions: "\u0421\u0435\u0441\u0441\u0438\u0438",
91
+ collapse: "\u0421\u0432\u0435\u0440\u043D\u0443\u0442\u044C",
92
+ expand: "\u0420\u0430\u0437\u0432\u0435\u0440\u043D\u0443\u0442\u044C",
93
+ close: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C"
94
+ }
95
+ };
96
+
97
+ // src/i18n/locales/ko.ts
98
+ var ko = {
99
+ chat: {
100
+ title: "\uC9C0\uC2DD \uB3C4\uC6B0\uBBF8",
101
+ titleShort: "\uC9C0\uC6D0",
102
+ placeholder: "\uBB34\uC5C7\uC774\uB4E0 \uBB3C\uC5B4\uBCF4\uC138\uC694...",
103
+ enterToSend: "Enter\uB85C \uC804\uC1A1, Shift+Enter\uB85C \uC904\uBC14\uAFC8",
104
+ thinking: "\uC0DD\uAC01 \uC911...",
105
+ source: "\uCD9C\uCC98 {index}",
106
+ startConversation: "\uB300\uD654 \uC2DC\uC791\uD558\uAE30",
107
+ startConversationDescription: "\uBB38\uC11C, \uAE30\uB2A5\uC5D0 \uB300\uD574 \uC9C8\uBB38\uD558\uAC70\uB098 \uD504\uB85C\uC81D\uD2B8 \uB3C4\uC6C0\uC744 \uBC1B\uC73C\uC138\uC694.",
108
+ openChat: "\uC9C0\uC6D0 \uCC44\uD305 \uC5F4\uAE30"
109
+ },
110
+ sessions: {
111
+ title: "\uCC44\uD305 \uC138\uC158",
112
+ description: "\uCC44\uD305 \uAE30\uB85D \uBCF4\uAE30 \uBC0F \uAD00\uB9AC",
113
+ noSessions: "\uC138\uC158 \uC5C6\uC74C",
114
+ noSessionsDescription: "\uC0C8 \uB300\uD654\uB97C \uC2DC\uC791\uD558\uC5EC \uCCAB \uBC88\uC9F8 \uC138\uC158\uC744 \uB9CC\uB4DC\uC138\uC694.",
115
+ untitled: "\uC81C\uBAA9 \uC5C6\uC74C",
116
+ active: "\uD65C\uC131",
117
+ archive: "\uBCF4\uAD00",
118
+ delete: "\uC0AD\uC81C",
119
+ loadingMore: "\uBD88\uB7EC\uC624\uB294 \uC911...",
120
+ noMore: "\uB354 \uC774\uC0C1 \uC138\uC158 \uC5C6\uC74C",
121
+ newChat: "\uC0C8 \uCC44\uD305"
122
+ },
123
+ actions: {
124
+ sessions: "\uC138\uC158",
125
+ collapse: "\uCD95\uC18C",
126
+ expand: "\uD655\uC7A5",
127
+ close: "\uB2EB\uAE30"
128
+ }
129
+ };
130
+
131
+ // src/i18n/index.ts
132
+ var KNOWBASE_NAMESPACE = "knowbase";
133
+ var knowbaseI18n = (0, import_i18n.createExtensionI18n)({
134
+ namespace: KNOWBASE_NAMESPACE,
135
+ defaultLocale: "en",
136
+ locales: { en, ru, ko }
137
+ });
138
+ var knowbaseTranslations = knowbaseI18n.getAllTranslations();
139
+ // Annotate the CommonJS export names for ESM import in node:
140
+ 0 && (module.exports = {
141
+ KNOWBASE_NAMESPACE,
142
+ knowbaseI18n,
143
+ knowbaseTranslations
144
+ });