@contenify/chatbot 0.1.4 → 0.1.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.
package/dist/index.mjs CHANGED
@@ -19,6 +19,9 @@ var __spreadValues = (a, b) => {
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
21
 
22
+ // src/index.tsx
23
+ import { useEffect as useEffect8 } from "react";
24
+
22
25
  // contexts/PreferencesContext.tsx
23
26
  import { createContext, useContext, useState, useEffect } from "react";
24
27
 
@@ -26,12 +29,22 @@ import { createContext, useContext, useState, useEffect } from "react";
26
29
  import axios from "axios";
27
30
 
28
31
  // lib/config.ts
32
+ var _apiUrl = process.env.NEXT_PUBLIC_CONTENIFY_API_URL || "http://localhost:8080/api";
33
+ var _apiKey = process.env.NEXT_PUBLIC_API_KEY || "";
34
+ var _domain = process.env.NEXT_PUBLIC_DOMAIN || "";
35
+ function setConfig(config) {
36
+ if (config.apiUrl) _apiUrl = config.apiUrl;
37
+ if (config.apiKey) _apiKey = config.apiKey;
38
+ if (config.domain) _domain = config.domain;
39
+ }
29
40
  function getApiBaseUrl() {
30
- return process.env.NEXT_PUBLIC_CONTENIFY_API_URL || "http://localhost:8080/api";
41
+ return _apiUrl;
31
42
  }
32
43
  function getServerBaseUrl() {
33
- const apiUrl = getApiBaseUrl();
34
- return apiUrl.replace(/\/api\/?$/, "");
44
+ return _apiUrl.replace(/\/api\/?$/, "");
45
+ }
46
+ function getApiKey() {
47
+ return _apiKey;
35
48
  }
36
49
 
37
50
  // lib/api.ts
@@ -44,7 +57,7 @@ var api = axios.create({
44
57
  });
45
58
  api.interceptors.request.use(
46
59
  (config) => {
47
- const apiKey = process.env.NEXT_PUBLIC_API_KEY;
60
+ const apiKey = getApiKey();
48
61
  if (apiKey) {
49
62
  config.headers["x-api-key"] = apiKey;
50
63
  }
@@ -67,6 +80,88 @@ var getMyPreferencesApi = async () => {
67
80
  const { data } = await api_default.get("/preferences/me");
68
81
  return data.data;
69
82
  };
83
+ var savePreferencesApi = async ({
84
+ botName,
85
+ logo,
86
+ state,
87
+ cities,
88
+ primaryColor,
89
+ secondaryColor,
90
+ theme,
91
+ language,
92
+ showSidebar,
93
+ showHeader,
94
+ activeThemePreset,
95
+ showNewsPanel,
96
+ tone,
97
+ style,
98
+ wordCount,
99
+ includeQuotes,
100
+ includeFAQ,
101
+ targetAudience
102
+ }) => {
103
+ const formData = new FormData();
104
+ if (botName) {
105
+ formData.append("botName", botName);
106
+ }
107
+ if (logo) {
108
+ formData.append("logo", logo);
109
+ }
110
+ if (state) {
111
+ formData.append("state", state);
112
+ }
113
+ if (cities) {
114
+ formData.append("cities", JSON.stringify(cities));
115
+ }
116
+ if (primaryColor) {
117
+ formData.append("primaryColor", primaryColor);
118
+ }
119
+ if (secondaryColor) {
120
+ formData.append("secondaryColor", secondaryColor);
121
+ }
122
+ if (theme) {
123
+ formData.append("theme", theme);
124
+ }
125
+ if (language) {
126
+ formData.append("language", language);
127
+ }
128
+ if (showSidebar !== void 0) {
129
+ formData.append("showSidebar", String(showSidebar));
130
+ }
131
+ if (showHeader !== void 0) {
132
+ formData.append("showHeader", String(showHeader));
133
+ }
134
+ if (activeThemePreset !== void 0) {
135
+ formData.append("activeThemePreset", activeThemePreset != null ? activeThemePreset : "");
136
+ }
137
+ if (showNewsPanel !== void 0) {
138
+ formData.append("showNewsPanel", String(showNewsPanel));
139
+ }
140
+ if (tone) {
141
+ formData.append("tone", tone);
142
+ }
143
+ if (style) {
144
+ formData.append("style", style);
145
+ }
146
+ if (wordCount) {
147
+ formData.append("wordCount", wordCount);
148
+ }
149
+ if (includeQuotes !== void 0) {
150
+ formData.append("includeQuotes", String(includeQuotes));
151
+ }
152
+ if (includeFAQ !== void 0) {
153
+ formData.append("includeFAQ", String(includeFAQ));
154
+ }
155
+ if (targetAudience !== void 0) {
156
+ formData.append("targetAudience", targetAudience);
157
+ }
158
+ const { data } = await api_default.put("/preferences", formData, {
159
+ headers: {
160
+ "Content-Type": "multipart/form-data"
161
+ }
162
+ });
163
+ return data.data;
164
+ };
70
165
 
71
166
  // contexts/PreferencesContext.tsx
72
167
  import { jsx } from "react/jsx-runtime";
@@ -169,59 +264,7 @@ function usePreferences() {
169
264
  }
170
265
 
171
266
  // components/chatbot/ChatBot.tsx
172
- import { useState as useState8, useCallback as useCallback3 } from "react";
173
-
174
- // components/chatbot/ArticleModal.tsx
175
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
176
- function ArticleModal({
177
- article,
178
- onClose,
179
- onRecreate
180
- }) {
181
- return /* @__PURE__ */ jsx2("div", { className: "cnfy-article-modal-overlay", children: /* @__PURE__ */ jsxs("div", { className: "cnfy-article-modal", children: [
182
- /* @__PURE__ */ jsxs("div", { className: "cnfy-article-modal-header", children: [
183
- /* @__PURE__ */ jsxs("div", { children: [
184
- /* @__PURE__ */ jsx2("p", { className: "cnfy-article-modal-source", children: "Source Article" }),
185
- /* @__PURE__ */ jsx2("h2", { className: "cnfy-article-modal-title", children: article.title })
186
- ] }),
187
- /* @__PURE__ */ jsx2(
188
- "button",
189
- {
190
- onClick: onClose,
191
- className: "cnfy-article-modal-close-btn",
192
- "aria-label": "Close modal",
193
- children: "\u2715"
194
- }
195
- )
196
- ] }),
197
- /* @__PURE__ */ jsx2("div", { className: "cnfy-article-modal-body", children: /* @__PURE__ */ jsx2("div", { className: "cnfy-article-modal-content", children: article.content }) }),
198
- /* @__PURE__ */ jsxs("div", { className: "cnfy-article-modal-footer", children: [
199
- /* @__PURE__ */ jsx2("span", { className: "cnfy-article-modal-footer-text", children: "This content will be recreated using AI" }),
200
- /* @__PURE__ */ jsxs("div", { className: "cnfy-article-modal-footer-actions", children: [
201
- /* @__PURE__ */ jsx2(
202
- "button",
203
- {
204
- onClick: onClose,
205
- className: "cnfy-btn-cancel",
206
- children: "Cancel"
207
- }
208
- ),
209
- /* @__PURE__ */ jsx2(
210
- "button",
211
- {
212
- onClick: () => onRecreate({
213
- title: article.title,
214
- content: article.content,
215
- id: article._id
216
- }),
217
- className: "cnfy-btn-recreate",
218
- children: "Recreate Article"
219
- }
220
- )
221
- ] })
222
- ] })
223
- ] }) });
224
- }
267
+ import { useState as useState7 } from "react";
225
268
 
226
269
  // util/util.ts
227
270
  function extractArticleContent(raw) {
@@ -274,7 +317,7 @@ import {
274
317
  Pilcrow
275
318
  } from "lucide-react";
276
319
  import { useEffect as useEffect2 } from "react";
277
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
320
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
278
321
  function RichTextEditor({
279
322
  content,
280
323
  onChange,
@@ -309,96 +352,96 @@ function RichTextEditor({
309
352
  }
310
353
  }, [content, editor]);
311
354
  if (!editor) {
312
- return /* @__PURE__ */ jsx3("div", { className: "cnfy-editor-loading", children: "Loading editor..." });
355
+ return /* @__PURE__ */ jsx2("div", { className: "cnfy-editor-loading", children: "Loading editor..." });
313
356
  }
314
- return /* @__PURE__ */ jsxs2("div", { className: "cnfy-editor", children: [
315
- /* @__PURE__ */ jsxs2("div", { className: "cnfy-toolbar", children: [
316
- /* @__PURE__ */ jsx3(
357
+ return /* @__PURE__ */ jsxs("div", { className: "cnfy-editor", children: [
358
+ /* @__PURE__ */ jsxs("div", { className: "cnfy-toolbar", children: [
359
+ /* @__PURE__ */ jsx2(
317
360
  ToolbarButton,
318
361
  {
319
362
  onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
320
363
  isActive: editor.isActive("heading", { level: 1 }),
321
364
  title: "Heading 1",
322
- children: /* @__PURE__ */ jsx3(Heading1, { size: 18 })
365
+ children: /* @__PURE__ */ jsx2(Heading1, { size: 18 })
323
366
  }
324
367
  ),
325
- /* @__PURE__ */ jsx3(
368
+ /* @__PURE__ */ jsx2(
326
369
  ToolbarButton,
327
370
  {
328
371
  onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
329
372
  isActive: editor.isActive("heading", { level: 2 }),
330
373
  title: "Heading 2",
331
- children: /* @__PURE__ */ jsx3(Heading2, { size: 18 })
374
+ children: /* @__PURE__ */ jsx2(Heading2, { size: 18 })
332
375
  }
333
376
  ),
334
- /* @__PURE__ */ jsx3(
377
+ /* @__PURE__ */ jsx2(
335
378
  ToolbarButton,
336
379
  {
337
380
  onClick: () => editor.chain().focus().setParagraph().run(),
338
381
  isActive: editor.isActive("paragraph"),
339
382
  title: "Paragraph",
340
- children: /* @__PURE__ */ jsx3(Pilcrow, { size: 18 })
383
+ children: /* @__PURE__ */ jsx2(Pilcrow, { size: 18 })
341
384
  }
342
385
  ),
343
- /* @__PURE__ */ jsx3("div", { className: "cnfy-toolbar-divider" }),
344
- /* @__PURE__ */ jsx3(
386
+ /* @__PURE__ */ jsx2("div", { className: "cnfy-toolbar-divider" }),
387
+ /* @__PURE__ */ jsx2(
345
388
  ToolbarButton,
346
389
  {
347
390
  onClick: () => editor.chain().focus().toggleBold().run(),
348
391
  isActive: editor.isActive("bold"),
349
392
  title: "Bold",
350
- children: /* @__PURE__ */ jsx3(Bold, { size: 18 })
393
+ children: /* @__PURE__ */ jsx2(Bold, { size: 18 })
351
394
  }
352
395
  ),
353
- /* @__PURE__ */ jsx3(
396
+ /* @__PURE__ */ jsx2(
354
397
  ToolbarButton,
355
398
  {
356
399
  onClick: () => editor.chain().focus().toggleItalic().run(),
357
400
  isActive: editor.isActive("italic"),
358
401
  title: "Italic",
359
- children: /* @__PURE__ */ jsx3(Italic, { size: 18 })
402
+ children: /* @__PURE__ */ jsx2(Italic, { size: 18 })
360
403
  }
361
404
  ),
362
- /* @__PURE__ */ jsx3("div", { className: "cnfy-toolbar-divider" }),
363
- /* @__PURE__ */ jsx3(
405
+ /* @__PURE__ */ jsx2("div", { className: "cnfy-toolbar-divider" }),
406
+ /* @__PURE__ */ jsx2(
364
407
  ToolbarButton,
365
408
  {
366
409
  onClick: () => editor.chain().focus().toggleBulletList().run(),
367
410
  isActive: editor.isActive("bulletList"),
368
411
  title: "Bullet List",
369
- children: /* @__PURE__ */ jsx3(List, { size: 18 })
412
+ children: /* @__PURE__ */ jsx2(List, { size: 18 })
370
413
  }
371
414
  ),
372
- /* @__PURE__ */ jsx3(
415
+ /* @__PURE__ */ jsx2(
373
416
  ToolbarButton,
374
417
  {
375
418
  onClick: () => editor.chain().focus().toggleOrderedList().run(),
376
419
  isActive: editor.isActive("orderedList"),
377
420
  title: "Numbered List",
378
- children: /* @__PURE__ */ jsx3(ListOrdered, { size: 18 })
421
+ children: /* @__PURE__ */ jsx2(ListOrdered, { size: 18 })
379
422
  }
380
423
  ),
381
- /* @__PURE__ */ jsx3("div", { className: "cnfy-toolbar-divider" }),
382
- /* @__PURE__ */ jsx3(
424
+ /* @__PURE__ */ jsx2("div", { className: "cnfy-toolbar-divider" }),
425
+ /* @__PURE__ */ jsx2(
383
426
  ToolbarButton,
384
427
  {
385
428
  onClick: () => editor.chain().focus().undo().run(),
386
429
  disabled: !editor.can().undo(),
387
430
  title: "Undo",
388
- children: /* @__PURE__ */ jsx3(Undo, { size: 18 })
431
+ children: /* @__PURE__ */ jsx2(Undo, { size: 18 })
389
432
  }
390
433
  ),
391
- /* @__PURE__ */ jsx3(
434
+ /* @__PURE__ */ jsx2(
392
435
  ToolbarButton,
393
436
  {
394
437
  onClick: () => editor.chain().focus().redo().run(),
395
438
  disabled: !editor.can().redo(),
396
439
  title: "Redo",
397
- children: /* @__PURE__ */ jsx3(Redo, { size: 18 })
440
+ children: /* @__PURE__ */ jsx2(Redo, { size: 18 })
398
441
  }
399
442
  )
400
443
  ] }),
401
- /* @__PURE__ */ jsx3(EditorContent, { editor, className: "cnfy-editor-content" })
444
+ /* @__PURE__ */ jsx2(EditorContent, { editor, className: "cnfy-editor-content" })
402
445
  ] });
403
446
  }
404
447
  function ToolbarButton({
@@ -408,7 +451,7 @@ function ToolbarButton({
408
451
  title,
409
452
  children
410
453
  }) {
411
- return /* @__PURE__ */ jsx3(
454
+ return /* @__PURE__ */ jsx2(
412
455
  "button",
413
456
  {
414
457
  onClick,
@@ -439,7 +482,7 @@ function useTheme() {
439
482
  }
440
483
 
441
484
  // components/chatbot/EditModal.tsx
442
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
485
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
443
486
  function EditModal({
444
487
  isOpen,
445
488
  initialContent,
@@ -498,30 +541,30 @@ function EditModal({
498
541
  }
499
542
  };
500
543
  if (!isOpen) return null;
501
- return /* @__PURE__ */ jsxs3("div", { className: "cnfy-edit-modal-overlay", children: [
502
- /* @__PURE__ */ jsx4(
544
+ return /* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal-overlay", children: [
545
+ /* @__PURE__ */ jsx3(
503
546
  "div",
504
547
  {
505
548
  className: "cnfy-edit-modal-backdrop",
506
549
  onClick: onClose
507
550
  }
508
551
  ),
509
- /* @__PURE__ */ jsxs3("div", { className: "cnfy-edit-modal", children: [
510
- /* @__PURE__ */ jsxs3("div", { className: "cnfy-edit-modal-header", children: [
511
- /* @__PURE__ */ jsx4("h2", { className: "cnfy-edit-modal-title", children: "Edit Article" }),
512
- /* @__PURE__ */ jsx4(
552
+ /* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal", children: [
553
+ /* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal-header", children: [
554
+ /* @__PURE__ */ jsx3("h2", { className: "cnfy-edit-modal-title", children: "Edit Article" }),
555
+ /* @__PURE__ */ jsx3(
513
556
  "button",
514
557
  {
515
558
  onClick: onClose,
516
559
  className: "cnfy-edit-modal-close-btn",
517
- children: /* @__PURE__ */ jsx4(X, { size: 20, className: "cnfy-edit-modal-close-icon" })
560
+ children: /* @__PURE__ */ jsx3(X, { size: 20, className: "cnfy-edit-modal-close-icon" })
518
561
  }
519
562
  )
520
563
  ] }),
521
- /* @__PURE__ */ jsxs3("div", { className: "cnfy-edit-modal-body", children: [
522
- /* @__PURE__ */ jsxs3("div", { children: [
523
- /* @__PURE__ */ jsx4("label", { className: "cnfy-edit-label", children: "Article Content" }),
524
- /* @__PURE__ */ jsx4(
564
+ /* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal-body", children: [
565
+ /* @__PURE__ */ jsxs2("div", { children: [
566
+ /* @__PURE__ */ jsx3("label", { className: "cnfy-edit-label", children: "Article Content" }),
567
+ /* @__PURE__ */ jsx3(
525
568
  RichTextEditor,
526
569
  {
527
570
  content,
@@ -530,29 +573,29 @@ function EditModal({
530
573
  }
531
574
  )
532
575
  ] }),
533
- /* @__PURE__ */ jsxs3("div", { children: [
534
- /* @__PURE__ */ jsx4("label", { className: "cnfy-edit-label", children: "Meta Keywords" }),
535
- /* @__PURE__ */ jsx4("div", { className: "cnfy-keyword-list", children: keywords.map((keyword, index) => /* @__PURE__ */ jsxs3(
576
+ /* @__PURE__ */ jsxs2("div", { children: [
577
+ /* @__PURE__ */ jsx3("label", { className: "cnfy-edit-label", children: "Meta Keywords" }),
578
+ /* @__PURE__ */ jsx3("div", { className: "cnfy-keyword-list", children: keywords.map((keyword, index) => /* @__PURE__ */ jsxs2(
536
579
  "span",
537
580
  {
538
581
  className: "cnfy-keyword-tag",
539
582
  children: [
540
583
  "#",
541
584
  keyword,
542
- /* @__PURE__ */ jsx4(
585
+ /* @__PURE__ */ jsx3(
543
586
  "button",
544
587
  {
545
588
  onClick: () => handleRemoveKeyword(index),
546
589
  className: "cnfy-keyword-remove-btn",
547
- children: /* @__PURE__ */ jsx4(X, { size: 14 })
590
+ children: /* @__PURE__ */ jsx3(X, { size: 14 })
548
591
  }
549
592
  )
550
593
  ]
551
594
  },
552
595
  index
553
596
  )) }),
554
- /* @__PURE__ */ jsxs3("div", { className: "cnfy-keyword-input-row", children: [
555
- /* @__PURE__ */ jsx4(
597
+ /* @__PURE__ */ jsxs2("div", { className: "cnfy-keyword-input-row", children: [
598
+ /* @__PURE__ */ jsx3(
556
599
  "input",
557
600
  {
558
601
  type: "text",
@@ -563,7 +606,7 @@ function EditModal({
563
606
  className: "cnfy-keyword-input"
564
607
  }
565
608
  ),
566
- /* @__PURE__ */ jsx4(
609
+ /* @__PURE__ */ jsx3(
567
610
  "button",
568
611
  {
569
612
  onClick: handleAddKeyword,
@@ -574,8 +617,8 @@ function EditModal({
574
617
  ] })
575
618
  ] })
576
619
  ] }),
577
- /* @__PURE__ */ jsxs3("div", { className: "cnfy-edit-modal-footer", children: [
578
- /* @__PURE__ */ jsx4(
620
+ /* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal-footer", children: [
621
+ /* @__PURE__ */ jsx3(
579
622
  "button",
580
623
  {
581
624
  onClick: onClose,
@@ -583,7 +626,7 @@ function EditModal({
583
626
  children: "Cancel"
584
627
  }
585
628
  ),
586
- /* @__PURE__ */ jsx4(
629
+ /* @__PURE__ */ jsx3(
587
630
  "button",
588
631
  {
589
632
  onClick: () => onSaveDraft(content, keywords),
@@ -591,7 +634,7 @@ function EditModal({
591
634
  children: "Save Draft"
592
635
  }
593
636
  ),
594
- /* @__PURE__ */ jsx4(
637
+ /* @__PURE__ */ jsx3(
595
638
  "button",
596
639
  {
597
640
  onClick: () => onPost(content, keywords),
@@ -608,7 +651,7 @@ function EditModal({
608
651
  // components/news/NewsList.tsx
609
652
  import { useState as useState3 } from "react";
610
653
  import { Eye, RefreshCcw } from "lucide-react";
611
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
654
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
612
655
  var dateFormatter = new Intl.DateTimeFormat("en-GB", {
613
656
  day: "2-digit",
614
657
  month: "short",
@@ -650,19 +693,19 @@ function NewsList({
650
693
  b = Math.round(b + (255 - b) * (percent / 100));
651
694
  return `rgb(${r}, ${g}, ${b})`;
652
695
  };
653
- return /* @__PURE__ */ jsx5("div", { className: "cnfy-news-list", children: news.flatMap((item) => {
696
+ return /* @__PURE__ */ jsx4("div", { className: "cnfy-news-list", children: news.flatMap((item) => {
654
697
  const publishedDate = new Date(item.publishedAt);
655
698
  const links = extractLinksFromContent(item.content);
656
699
  if (links.length > 0) {
657
- return links.map((link, idx) => /* @__PURE__ */ jsxs4(
700
+ return links.map((link, idx) => /* @__PURE__ */ jsxs3(
658
701
  "div",
659
702
  {
660
703
  className: "cnfy-news-card",
661
704
  children: [
662
- /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-card-content", children: [
663
- /* @__PURE__ */ jsx5("p", { className: "cnfy-news-card-title", children: link.title }),
664
- /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-card-meta", children: [
665
- /* @__PURE__ */ jsx5(
705
+ /* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-content", children: [
706
+ /* @__PURE__ */ jsx4("p", { className: "cnfy-news-card-title", children: link.title }),
707
+ /* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-meta", children: [
708
+ /* @__PURE__ */ jsx4(
666
709
  "span",
667
710
  {
668
711
  className: "cnfy-news-badge",
@@ -674,27 +717,27 @@ function NewsList({
674
717
  children: link.source || item.sourceName
675
718
  }
676
719
  ),
677
- /* @__PURE__ */ jsx5("span", { children: "\u2022" }),
678
- /* @__PURE__ */ jsx5("span", { className: "cnfy-news-card-category", children: item.category }),
679
- /* @__PURE__ */ jsx5("span", { children: "\u2022" }),
680
- /* @__PURE__ */ jsxs4("span", { children: [
720
+ /* @__PURE__ */ jsx4("span", { children: "\u2022" }),
721
+ /* @__PURE__ */ jsx4("span", { className: "cnfy-news-card-category", children: item.category }),
722
+ /* @__PURE__ */ jsx4("span", { children: "\u2022" }),
723
+ /* @__PURE__ */ jsxs3("span", { children: [
681
724
  dateFormatter.format(publishedDate),
682
725
  " ",
683
726
  timeFormatter.format(publishedDate)
684
727
  ] })
685
728
  ] })
686
729
  ] }),
687
- /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-card-actions", children: [
688
- /* @__PURE__ */ jsx5(
730
+ /* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-actions", children: [
731
+ /* @__PURE__ */ jsx4(
689
732
  "button",
690
733
  {
691
734
  onClick: () => window.open(link.url, "_blank"),
692
735
  className: "cnfy-news-action-btn",
693
736
  title: "View",
694
- children: /* @__PURE__ */ jsx5(Eye, { size: 16 })
737
+ children: /* @__PURE__ */ jsx4(Eye, { size: 16 })
695
738
  }
696
739
  ),
697
- /* @__PURE__ */ jsx5(
740
+ /* @__PURE__ */ jsx4(
698
741
  "button",
699
742
  {
700
743
  onClick: () => onRecreate({
@@ -704,7 +747,7 @@ function NewsList({
704
747
  }),
705
748
  className: "cnfy-news-action-btn",
706
749
  title: "Recreate",
707
- children: /* @__PURE__ */ jsx5(RefreshCcw, { size: 16 })
750
+ children: /* @__PURE__ */ jsx4(RefreshCcw, { size: 16 })
708
751
  }
709
752
  )
710
753
  ] })
@@ -713,15 +756,15 @@ function NewsList({
713
756
  `${item._id}-link-${idx}`
714
757
  ));
715
758
  }
716
- return /* @__PURE__ */ jsxs4(
759
+ return /* @__PURE__ */ jsxs3(
717
760
  "div",
718
761
  {
719
762
  className: "cnfy-news-card",
720
763
  children: [
721
- /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-card-content", children: [
722
- /* @__PURE__ */ jsx5("p", { className: "cnfy-news-card-title", children: item.title }),
723
- /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-card-meta", children: [
724
- /* @__PURE__ */ jsx5(
764
+ /* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-content", children: [
765
+ /* @__PURE__ */ jsx4("p", { className: "cnfy-news-card-title", children: item.title }),
766
+ /* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-meta", children: [
767
+ /* @__PURE__ */ jsx4(
725
768
  "span",
726
769
  {
727
770
  className: "cnfy-news-badge",
@@ -733,27 +776,27 @@ function NewsList({
733
776
  children: item.sourceName
734
777
  }
735
778
  ),
736
- /* @__PURE__ */ jsx5("span", { children: "\u2022" }),
737
- /* @__PURE__ */ jsx5("span", { className: "cnfy-news-card-category", children: item.category }),
738
- /* @__PURE__ */ jsx5("span", { children: "\u2022" }),
739
- /* @__PURE__ */ jsxs4("span", { children: [
779
+ /* @__PURE__ */ jsx4("span", { children: "\u2022" }),
780
+ /* @__PURE__ */ jsx4("span", { className: "cnfy-news-card-category", children: item.category }),
781
+ /* @__PURE__ */ jsx4("span", { children: "\u2022" }),
782
+ /* @__PURE__ */ jsxs3("span", { children: [
740
783
  dateFormatter.format(publishedDate),
741
784
  " ",
742
785
  timeFormatter.format(publishedDate)
743
786
  ] })
744
787
  ] })
745
788
  ] }),
746
- /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-card-actions", children: [
747
- /* @__PURE__ */ jsx5(
789
+ /* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-actions", children: [
790
+ /* @__PURE__ */ jsx4(
748
791
  "button",
749
792
  {
750
793
  onClick: () => onView(item),
751
794
  className: "cnfy-news-action-btn",
752
795
  title: "View",
753
- children: /* @__PURE__ */ jsx5(Eye, { size: 16 })
796
+ children: /* @__PURE__ */ jsx4(Eye, { size: 16 })
754
797
  }
755
798
  ),
756
- /* @__PURE__ */ jsx5(
799
+ /* @__PURE__ */ jsx4(
757
800
  "button",
758
801
  {
759
802
  onClick: () => onRecreate({
@@ -763,7 +806,7 @@ function NewsList({
763
806
  }),
764
807
  className: "cnfy-news-action-btn",
765
808
  title: "Recreate",
766
- children: /* @__PURE__ */ jsx5(RefreshCcw, { size: 16 })
809
+ children: /* @__PURE__ */ jsx4(RefreshCcw, { size: 16 })
767
810
  }
768
811
  )
769
812
  ] })
@@ -794,7 +837,7 @@ var getNewsBySource = async (sourceId) => {
794
837
 
795
838
  // components/chatbot/ChatWindow.tsx
796
839
  import Select from "react-select";
797
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
840
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
798
841
  var ACTION_ICONS = {
799
842
  recreate_article: RefreshCcw2,
800
843
  create_summary: ListChecks,
@@ -970,13 +1013,13 @@ function ChatWindow({
970
1013
  });
971
1014
  return { blocks, metaKeywords };
972
1015
  }
973
- return /* @__PURE__ */ jsxs5("div", { className: "cnfy-chat", children: [
974
- /* @__PURE__ */ jsx6("div", { className: "cnfy-chat-area", children: /* @__PURE__ */ jsxs5("div", { className: "cnfy-chat-scroll", children: [
1016
+ return /* @__PURE__ */ jsxs4("div", { className: "cnfy-chat", children: [
1017
+ /* @__PURE__ */ jsx5("div", { className: "cnfy-chat-area", children: /* @__PURE__ */ jsxs4("div", { className: "cnfy-chat-scroll", children: [
975
1018
  messages.map((msg) => {
976
1019
  var _a2;
977
1020
  const parsed = formatAIContent(msg.content);
978
- return /* @__PURE__ */ jsxs5("div", { className: "cnfy-msg", children: [
979
- /* @__PURE__ */ jsx6("div", { className: "cnfy-msg-avatar-wrap", children: /* @__PURE__ */ jsx6(
1021
+ return /* @__PURE__ */ jsxs4("div", { className: "cnfy-msg", children: [
1022
+ /* @__PURE__ */ jsx5("div", { className: "cnfy-msg-avatar-wrap", children: /* @__PURE__ */ jsx5(
980
1023
  "div",
981
1024
  {
982
1025
  className: "cnfy-msg-avatar",
@@ -986,19 +1029,19 @@ function ChatWindow({
986
1029
  children: msg.role === "assistant" ? "AI" : "You"
987
1030
  }
988
1031
  ) }),
989
- /* @__PURE__ */ jsxs5("div", { className: "cnfy-msg-body", children: [
990
- msg.role === "assistant" && parsed.blocks.length > 0 && /* @__PURE__ */ jsx6("div", { className: "cnfy-msg-copy-row", children: /* @__PURE__ */ jsx6(
1032
+ /* @__PURE__ */ jsxs4("div", { className: "cnfy-msg-body", children: [
1033
+ msg.role === "assistant" && parsed.blocks.length > 0 && /* @__PURE__ */ jsx5("div", { className: "cnfy-msg-copy-row", children: /* @__PURE__ */ jsx5(
991
1034
  "button",
992
1035
  {
993
1036
  onClick: () => handleCopy(parsed.blocks, msg.id),
994
1037
  className: "cnfy-copy-btn",
995
1038
  title: "Copy to clipboard",
996
- children: copiedId === msg.id ? /* @__PURE__ */ jsx6(Check, { size: 16, className: "cnfy-copy-icon--copied" }) : /* @__PURE__ */ jsx6(Copy, { size: 16 })
1039
+ children: copiedId === msg.id ? /* @__PURE__ */ jsx5(Check, { size: 16, className: "cnfy-copy-icon--copied" }) : /* @__PURE__ */ jsx5(Copy, { size: 16 })
997
1040
  }
998
1041
  ) }),
999
1042
  parsed.blocks.map((block, idx) => {
1000
1043
  if (block.type === "h1") {
1001
- return /* @__PURE__ */ jsx6(
1044
+ return /* @__PURE__ */ jsx5(
1002
1045
  "h1",
1003
1046
  {
1004
1047
  className: "cnfy-block-h1",
@@ -1008,7 +1051,7 @@ function ChatWindow({
1008
1051
  );
1009
1052
  }
1010
1053
  if (block.type === "h2") {
1011
- return /* @__PURE__ */ jsx6(
1054
+ return /* @__PURE__ */ jsx5(
1012
1055
  "h2",
1013
1056
  {
1014
1057
  className: "cnfy-block-h2",
@@ -1017,9 +1060,9 @@ function ChatWindow({
1017
1060
  idx
1018
1061
  );
1019
1062
  }
1020
- return /* @__PURE__ */ jsx6("p", { className: "cnfy-block-p", children: block.text }, idx);
1063
+ return /* @__PURE__ */ jsx5("p", { className: "cnfy-block-p", children: block.text }, idx);
1021
1064
  }),
1022
- parsed.metaKeywords.length > 0 && /* @__PURE__ */ jsx6("div", { className: "cnfy-msg-keywords", children: /* @__PURE__ */ jsx6("div", { className: "cnfy-msg-keywords-list", children: parsed.metaKeywords.map((tag, i) => /* @__PURE__ */ jsxs5(
1065
+ parsed.metaKeywords.length > 0 && /* @__PURE__ */ jsx5("div", { className: "cnfy-msg-keywords", children: /* @__PURE__ */ jsx5("div", { className: "cnfy-msg-keywords-list", children: parsed.metaKeywords.map((tag, i) => /* @__PURE__ */ jsxs4(
1023
1066
  "span",
1024
1067
  {
1025
1068
  className: "cnfy-msg-keyword-tag",
@@ -1030,41 +1073,41 @@ function ChatWindow({
1030
1073
  },
1031
1074
  i
1032
1075
  )) }) }),
1033
- msg.role === "assistant" && (analyzedData == null ? void 0 : analyzedData.messageId) === msg.id && analyzedData.options.length > 0 && /* @__PURE__ */ jsx6("div", { className: "cnfy-action-options", children: analyzedData.options.map((option) => {
1076
+ msg.role === "assistant" && (analyzedData == null ? void 0 : analyzedData.messageId) === msg.id && analyzedData.options.length > 0 && /* @__PURE__ */ jsx5("div", { className: "cnfy-action-options", children: analyzedData.options.map((option) => {
1034
1077
  const IconComponent = ACTION_ICONS[option.id] || FileText;
1035
- return /* @__PURE__ */ jsxs5(
1078
+ return /* @__PURE__ */ jsxs4(
1036
1079
  "button",
1037
1080
  {
1038
1081
  onClick: () => onSelectAction == null ? void 0 : onSelectAction(option.id, analyzedData.url, analyzedData.content),
1039
1082
  className: "cnfy-action-btn",
1040
1083
  children: [
1041
- /* @__PURE__ */ jsx6(IconComponent, { size: 16 }),
1084
+ /* @__PURE__ */ jsx5(IconComponent, { size: 16 }),
1042
1085
  option.name
1043
1086
  ]
1044
1087
  },
1045
1088
  option.id
1046
1089
  );
1047
1090
  }) }),
1048
- msg.role === "assistant" && parsed.blocks.length > 0 && !(analyzedData == null ? void 0 : analyzedData.messageId) && (!isStreaming || msg.id !== ((_a2 = messages[messages.length - 1]) == null ? void 0 : _a2.id)) && /* @__PURE__ */ jsxs5("div", { className: "cnfy-msg-actions", children: [
1049
- /* @__PURE__ */ jsxs5(
1091
+ msg.role === "assistant" && parsed.blocks.length > 0 && !(analyzedData == null ? void 0 : analyzedData.messageId) && (!isStreaming || msg.id !== ((_a2 = messages[messages.length - 1]) == null ? void 0 : _a2.id)) && /* @__PURE__ */ jsxs4("div", { className: "cnfy-msg-actions", children: [
1092
+ /* @__PURE__ */ jsxs4(
1050
1093
  "button",
1051
1094
  {
1052
1095
  onClick: () => handleEdit(parsed.blocks, parsed.metaKeywords, msg.id),
1053
1096
  className: "cnfy-btn-edit",
1054
1097
  children: [
1055
- /* @__PURE__ */ jsx6(Edit3, { size: 16 }),
1098
+ /* @__PURE__ */ jsx5(Edit3, { size: 16 }),
1056
1099
  "Edit"
1057
1100
  ]
1058
1101
  }
1059
1102
  ),
1060
- /* @__PURE__ */ jsxs5(
1103
+ /* @__PURE__ */ jsxs4(
1061
1104
  "button",
1062
1105
  {
1063
1106
  onClick: () => handlePost(msg.content, parsed.metaKeywords),
1064
1107
  className: "cnfy-btn-post",
1065
1108
  style: { backgroundColor: primaryColor, color: "#fff" },
1066
1109
  children: [
1067
- /* @__PURE__ */ jsx6(Send, { size: 16 }),
1110
+ /* @__PURE__ */ jsx5(Send, { size: 16 }),
1068
1111
  "Post"
1069
1112
  ]
1070
1113
  }
@@ -1073,34 +1116,34 @@ function ChatWindow({
1073
1116
  ] })
1074
1117
  ] }, msg.id);
1075
1118
  }),
1076
- /* @__PURE__ */ jsx6("div", { ref: bottomRef })
1119
+ /* @__PURE__ */ jsx5("div", { ref: bottomRef })
1077
1120
  ] }) }),
1078
- /* @__PURE__ */ jsx6("div", { className: "cnfy-input-area", children: /* @__PURE__ */ jsxs5("div", { className: "cnfy-input-inner", children: [
1079
- !showNewsPanel && /* @__PURE__ */ jsxs5("div", { ref: dropdownRef, className: "cnfy-news-pulse-wrap", children: [
1080
- /* @__PURE__ */ jsx6(
1121
+ /* @__PURE__ */ jsx5("div", { className: "cnfy-input-area", children: /* @__PURE__ */ jsxs4("div", { className: "cnfy-input-inner", children: [
1122
+ /* @__PURE__ */ jsxs4("div", { ref: dropdownRef, className: "cnfy-news-pulse-wrap", children: [
1123
+ /* @__PURE__ */ jsx5(
1081
1124
  "button",
1082
1125
  {
1083
1126
  onClick: handleOpenNewsDropdown,
1084
1127
  className: "cnfy-news-pulse-btn cnfy-animate-pulse",
1085
1128
  title: "Select from trending news",
1086
- children: /* @__PURE__ */ jsx6(Zap, { size: 16 })
1129
+ children: /* @__PURE__ */ jsx5(Zap, { size: 16 })
1087
1130
  }
1088
1131
  ),
1089
- showNewsDropdown && /* @__PURE__ */ jsxs5("div", { className: "cnfy-news-dropdown", children: [
1090
- /* @__PURE__ */ jsxs5("div", { className: "cnfy-news-dropdown-header", style: { backgroundColor: primaryColor, color: "#fff" }, children: [
1091
- /* @__PURE__ */ jsx6("span", { className: "cnfy-news-dropdown-title", children: "Select News" }),
1092
- /* @__PURE__ */ jsx6(
1132
+ showNewsDropdown && /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-dropdown", children: [
1133
+ /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-dropdown-header", style: { backgroundColor: primaryColor, color: "#fff" }, children: [
1134
+ /* @__PURE__ */ jsx5("span", { className: "cnfy-news-dropdown-title", children: "Select News" }),
1135
+ /* @__PURE__ */ jsx5(
1093
1136
  "button",
1094
1137
  {
1095
1138
  onClick: () => setShowNewsDropdown(false),
1096
1139
  className: "cnfy-news-dropdown-close",
1097
1140
  style: { backgroundColor: primaryColor, color: "#fff" },
1098
- children: /* @__PURE__ */ jsx6(X2, { size: 14 })
1141
+ children: /* @__PURE__ */ jsx5(X2, { size: 14 })
1099
1142
  }
1100
1143
  )
1101
1144
  ] }),
1102
- /* @__PURE__ */ jsxs5("div", { className: "cnfy-news-dropdown-source", children: [
1103
- /* @__PURE__ */ jsx6("div", { className: "cnfy-news-dropdown-select-wrap", children: /* @__PURE__ */ jsx6(
1145
+ /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-dropdown-source", children: [
1146
+ /* @__PURE__ */ jsx5("div", { className: "cnfy-news-dropdown-select-wrap", children: /* @__PURE__ */ jsx5(
1104
1147
  Select,
1105
1148
  {
1106
1149
  options: [
@@ -1146,7 +1189,7 @@ function ChatWindow({
1146
1189
  }
1147
1190
  }
1148
1191
  ) }),
1149
- selectedSource && /* @__PURE__ */ jsxs5(
1192
+ selectedSource && /* @__PURE__ */ jsxs4(
1150
1193
  "button",
1151
1194
  {
1152
1195
  onClick: handleScrape,
@@ -1154,28 +1197,28 @@ function ChatWindow({
1154
1197
  className: "cnfy-scrape-btn",
1155
1198
  title: "Fetch latest news",
1156
1199
  children: [
1157
- /* @__PURE__ */ jsx6(RefreshCcw2, { size: 14, className: scraping ? "cnfy-animate-spin" : "" }),
1200
+ /* @__PURE__ */ jsx5(RefreshCcw2, { size: 14, className: scraping ? "cnfy-animate-spin" : "" }),
1158
1201
  scraping ? "Scraping..." : "Scrape"
1159
1202
  ]
1160
1203
  }
1161
1204
  ),
1162
- !selectedSource && /* @__PURE__ */ jsxs5(
1205
+ !selectedSource && /* @__PURE__ */ jsxs4(
1163
1206
  "button",
1164
1207
  {
1165
1208
  onClick: () => fetchNews(null),
1166
1209
  disabled: loadingNews,
1167
1210
  className: "cnfy-refresh-btn",
1168
1211
  children: [
1169
- /* @__PURE__ */ jsx6(RefreshCcw2, { size: 14, className: loadingNews ? "cnfy-animate-spin" : "" }),
1212
+ /* @__PURE__ */ jsx5(RefreshCcw2, { size: 14, className: loadingNews ? "cnfy-animate-spin" : "" }),
1170
1213
  "Refresh"
1171
1214
  ]
1172
1215
  }
1173
1216
  )
1174
1217
  ] }),
1175
- /* @__PURE__ */ jsx6("div", { className: "cnfy-news-dropdown-list", children: loadingNews ? /* @__PURE__ */ jsx6("div", { className: "cnfy-news-dropdown-msg", children: "Loading news..." }) : trendingNews.length === 0 ? /* @__PURE__ */ jsxs5("div", { className: "cnfy-news-dropdown-msg", children: [
1176
- /* @__PURE__ */ jsx6("p", { children: "No news found." }),
1177
- selectedSource && /* @__PURE__ */ jsx6("p", { className: "cnfy-news-dropdown-hint", children: 'Click "Scrape" to fetch latest news.' })
1178
- ] }) : /* @__PURE__ */ jsx6(
1218
+ /* @__PURE__ */ jsx5("div", { className: "cnfy-news-dropdown-list", children: loadingNews ? /* @__PURE__ */ jsx5("div", { className: "cnfy-news-dropdown-msg", children: "Loading news..." }) : trendingNews.length === 0 ? /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-dropdown-msg", children: [
1219
+ /* @__PURE__ */ jsx5("p", { children: "No news found." }),
1220
+ selectedSource && /* @__PURE__ */ jsx5("p", { className: "cnfy-news-dropdown-hint", children: 'Click "Scrape" to fetch latest news.' })
1221
+ ] }) : /* @__PURE__ */ jsx5(
1179
1222
  NewsList,
1180
1223
  {
1181
1224
  news: trendingNews.slice(0, 10),
@@ -1188,7 +1231,7 @@ function ChatWindow({
1188
1231
  ) })
1189
1232
  ] })
1190
1233
  ] }),
1191
- /* @__PURE__ */ jsx6(
1234
+ /* @__PURE__ */ jsx5(
1192
1235
  "textarea",
1193
1236
  {
1194
1237
  ref: textareaRef,
@@ -1206,17 +1249,17 @@ function ChatWindow({
1206
1249
  style: { maxHeight: "200px", overflowY: input.split("\n").length > 6 ? "auto" : "hidden" }
1207
1250
  }
1208
1251
  ),
1209
- /* @__PURE__ */ jsx6(
1252
+ /* @__PURE__ */ jsx5(
1210
1253
  "button",
1211
1254
  {
1212
1255
  onClick: handleSend,
1213
1256
  className: "cnfy-send-btn",
1214
1257
  style: { backgroundColor: primaryColor, color: "#fff" },
1215
- children: /* @__PURE__ */ jsx6(SendHorizontal, { size: 18 })
1258
+ children: /* @__PURE__ */ jsx5(SendHorizontal, { size: 18 })
1216
1259
  }
1217
1260
  )
1218
1261
  ] }) }),
1219
- /* @__PURE__ */ jsx6(
1262
+ /* @__PURE__ */ jsx5(
1220
1263
  EditModal,
1221
1264
  {
1222
1265
  isOpen: editModal.isOpen,
@@ -1231,115 +1274,31 @@ function ChatWindow({
1231
1274
  }
1232
1275
 
1233
1276
  // components/chatbot/UserMenu.tsx
1234
- import { useEffect as useEffect5, useRef as useRef2, useState as useState5 } from "react";
1235
- import {
1236
- Settings,
1237
- User,
1238
- HelpCircle,
1239
- LogOut,
1240
- Palette
1241
- } from "lucide-react";
1242
- import toast from "react-hot-toast";
1243
-
1244
- // services/auth.service.ts
1245
- var logoutUser = async () => {
1246
- const { data } = await api_default.post("/auth/logout");
1247
- return data;
1248
- };
1249
-
1250
- // components/chatbot/UserMenu.tsx
1251
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1277
+ import { Settings } from "lucide-react";
1278
+ import { jsx as jsx6 } from "react/jsx-runtime";
1252
1279
  function UserMenu({
1253
- onNavigate,
1254
- onLogout
1255
- }) {
1256
- const [open, setOpen] = useState5(false);
1257
- const ref = useRef2(null);
1258
- useEffect5(() => {
1259
- const handler = (e) => {
1260
- if (ref.current && !ref.current.contains(e.target)) {
1261
- setOpen(false);
1262
- }
1263
- };
1264
- document.addEventListener("mousedown", handler);
1265
- return () => document.removeEventListener("mousedown", handler);
1266
- }, []);
1267
- function go(path) {
1268
- setOpen(false);
1269
- onNavigate == null ? void 0 : onNavigate(path);
1270
- }
1271
- async function logout() {
1272
- setOpen(false);
1273
- if (onLogout) {
1274
- onLogout();
1275
- return;
1276
- }
1277
- try {
1278
- await logoutUser();
1279
- toast.success("Logged out successfully");
1280
- onNavigate == null ? void 0 : onNavigate("/login");
1281
- } catch (err) {
1282
- toast.error(err || "Logout failed");
1283
- }
1284
- }
1285
- return /* @__PURE__ */ jsxs6("div", { ref, className: "cnfy-user-menu", children: [
1286
- /* @__PURE__ */ jsx7(
1287
- "button",
1288
- {
1289
- onClick: () => setOpen((v) => !v),
1290
- className: "cnfy-user-menu-trigger",
1291
- "aria-label": "Settings",
1292
- children: /* @__PURE__ */ jsx7(Settings, { size: 20, className: "cnfy-user-menu-trigger-icon" })
1293
- }
1294
- ),
1295
- open && /* @__PURE__ */ jsxs6("div", { className: "cnfy-dropdown", children: [
1296
- /* @__PURE__ */ jsx7(MenuItem, { icon: User, label: "Account", onClick: () => go("/dashboard/account") }),
1297
- /* @__PURE__ */ jsx7(MenuItem, { icon: Settings, label: "Preferences", onClick: () => go("/dashboard/preferences") }),
1298
- /* @__PURE__ */ jsx7(MenuItem, { icon: Palette, label: "Appearance", onClick: () => go("/dashboard/appearance") }),
1299
- /* @__PURE__ */ jsx7(MenuItem, { icon: HelpCircle, label: "Settings", onClick: () => go("/dashboard/settings") }),
1300
- /* @__PURE__ */ jsx7(MenuItem, { icon: HelpCircle, label: "Help & Support", onClick: () => go("/dashboard/help") }),
1301
- /* @__PURE__ */ jsx7("div", { className: "cnfy-dropdown-divider" }),
1302
- /* @__PURE__ */ jsx7(
1303
- MenuItem,
1304
- {
1305
- icon: LogOut,
1306
- label: "Logout",
1307
- danger: true,
1308
- onClick: logout
1309
- }
1310
- )
1311
- ] })
1312
- ] });
1313
- }
1314
- function MenuItem({
1315
- icon: Icon,
1316
- label,
1317
- onClick,
1318
- danger = false
1280
+ onOpenPreferences
1319
1281
  }) {
1320
- return /* @__PURE__ */ jsxs6(
1282
+ return /* @__PURE__ */ jsx6("div", { className: "cnfy-user-menu", children: /* @__PURE__ */ jsx6(
1321
1283
  "button",
1322
1284
  {
1323
- onClick,
1324
- className: `cnfy-menu-item ${danger ? "cnfy-menu-item--danger" : ""}`,
1325
- children: [
1326
- /* @__PURE__ */ jsx7(Icon, { size: 16 }),
1327
- label
1328
- ]
1285
+ onClick: () => onOpenPreferences == null ? void 0 : onOpenPreferences(),
1286
+ className: "cnfy-user-menu-trigger",
1287
+ "aria-label": "Settings",
1288
+ children: /* @__PURE__ */ jsx6(Settings, { size: 20, className: "cnfy-user-menu-trigger-icon" })
1329
1289
  }
1330
- );
1290
+ ) });
1331
1291
  }
1332
1292
 
1333
1293
  // components/chatbot/headerBar.tsx
1334
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1294
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1335
1295
  function HeaderBar({
1336
- onNavigate,
1337
- onLogout
1296
+ onOpenPreferences
1338
1297
  }) {
1339
1298
  const { primaryColor, botName, logoUrl } = useTheme();
1340
- return /* @__PURE__ */ jsx8("header", { className: "cnfy-header", children: /* @__PURE__ */ jsxs7("div", { className: "cnfy-header-inner", children: [
1341
- /* @__PURE__ */ jsxs7("div", { className: "cnfy-header-left", onClick: () => onNavigate == null ? void 0 : onNavigate("/"), children: [
1342
- logoUrl ? /* @__PURE__ */ jsx8("img", { src: logoUrl, alt: "Logo", className: "cnfy-header-logo-img" }) : /* @__PURE__ */ jsx8(
1299
+ return /* @__PURE__ */ jsx7("header", { className: "cnfy-header", children: /* @__PURE__ */ jsxs5("div", { className: "cnfy-header-inner", children: [
1300
+ /* @__PURE__ */ jsxs5("div", { className: "cnfy-header-left", children: [
1301
+ logoUrl ? /* @__PURE__ */ jsx7("img", { src: logoUrl, alt: "Logo", className: "cnfy-header-logo-img" }) : /* @__PURE__ */ jsx7(
1343
1302
  "div",
1344
1303
  {
1345
1304
  className: "cnfy-header-logo-fallback",
@@ -1347,224 +1306,579 @@ function HeaderBar({
1347
1306
  children: botName.charAt(0).toUpperCase()
1348
1307
  }
1349
1308
  ),
1350
- /* @__PURE__ */ jsx8("span", { className: "cnfy-header-brand", children: botName.toUpperCase() })
1309
+ /* @__PURE__ */ jsx7("span", { className: "cnfy-header-brand", children: botName.toUpperCase() })
1351
1310
  ] }),
1352
- /* @__PURE__ */ jsx8("div", { className: "cnfy-header-right", children: /* @__PURE__ */ jsx8(UserMenu, { onNavigate, onLogout }) })
1311
+ /* @__PURE__ */ jsx7("div", { className: "cnfy-header-right", children: /* @__PURE__ */ jsx7(UserMenu, { onOpenPreferences }) })
1353
1312
  ] }) });
1354
1313
  }
1355
1314
 
1356
- // components/news/TrendingNews.tsx
1357
- import { useEffect as useEffect6, useState as useState6, useCallback } from "react";
1358
- import toast2 from "react-hot-toast";
1359
- import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
1360
- function TrendingNews({
1361
- onRecreate,
1362
- selectedSource,
1363
- refreshKey,
1364
- news: externalNews,
1365
- isLoading: externalLoading
1315
+ // components/ui/Drawer.tsx
1316
+ import { useEffect as useEffect5 } from "react";
1317
+ import { X as X3 } from "lucide-react";
1318
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1319
+ function Drawer({
1320
+ open,
1321
+ onClose,
1322
+ title,
1323
+ children
1366
1324
  }) {
1367
- const [news, setNews] = useState6([]);
1368
- const [loading, setLoading] = useState6(false);
1369
- const displayNews = externalNews !== void 0 ? externalNews : news;
1370
- const isLoading = externalLoading !== void 0 ? externalLoading : loading;
1371
- const fetchNews = useCallback(async () => {
1372
- if (externalNews !== void 0) {
1373
- return;
1374
- }
1375
- setLoading(true);
1376
- try {
1377
- let data;
1378
- if (selectedSource) {
1379
- data = await getNewsBySource(selectedSource);
1380
- } else {
1381
- data = await getTrendingNews();
1382
- }
1383
- setNews(data || []);
1384
- } catch (e) {
1385
- toast2.error("Failed to load news");
1386
- } finally {
1387
- setLoading(false);
1388
- }
1389
- }, [selectedSource, externalNews]);
1390
- useEffect6(() => {
1391
- fetchNews();
1392
- }, [fetchNews, refreshKey]);
1393
- function handleView(item) {
1394
- window.open(item.sourceUrl || item.link, "_blank");
1395
- }
1396
- if (isLoading) {
1397
- return /* @__PURE__ */ jsx9("div", { className: "cnfy-trending-msg", children: "Loading news..." });
1398
- }
1399
- if (!displayNews || displayNews.length === 0) {
1400
- return /* @__PURE__ */ jsxs8("div", { className: "cnfy-trending-msg cnfy-trending-msg--center", children: [
1401
- /* @__PURE__ */ jsx9("p", { children: "No news found for this source." }),
1402
- /* @__PURE__ */ jsx9("p", { className: "cnfy-trending-hint", children: 'Click "Scrape" to fetch latest news.' })
1403
- ] });
1404
- }
1405
- return /* @__PURE__ */ jsx9(
1406
- NewsList,
1407
- {
1408
- news: displayNews,
1409
- onView: handleView,
1410
- onRecreate
1325
+ useEffect5(() => {
1326
+ if (open) {
1327
+ document.body.style.overflow = "hidden";
1328
+ } else {
1329
+ document.body.style.overflow = "";
1411
1330
  }
1412
- );
1331
+ return () => {
1332
+ document.body.style.overflow = "";
1333
+ };
1334
+ }, [open]);
1335
+ if (!open) return null;
1336
+ return /* @__PURE__ */ jsxs6("div", { className: "cnfy-drawer-overlay", children: [
1337
+ /* @__PURE__ */ jsx8("div", { className: "cnfy-drawer-backdrop", onClick: onClose }),
1338
+ /* @__PURE__ */ jsxs6("div", { className: "cnfy-drawer-panel", children: [
1339
+ /* @__PURE__ */ jsxs6("div", { className: "cnfy-drawer-header", children: [
1340
+ title && /* @__PURE__ */ jsx8("h2", { className: "cnfy-drawer-title", children: title }),
1341
+ /* @__PURE__ */ jsx8("button", { onClick: onClose, className: "cnfy-drawer-close-btn", children: /* @__PURE__ */ jsx8(X3, { size: 20 }) })
1342
+ ] }),
1343
+ /* @__PURE__ */ jsx8("div", { className: "cnfy-drawer-body", children })
1344
+ ] })
1345
+ ] });
1413
1346
  }
1414
1347
 
1415
- // components/news/SourceSelector.tsx
1416
- import { useEffect as useEffect7, useState as useState7, useCallback as useCallback2 } from "react";
1417
- import { RefreshCcw as RefreshCcw3 } from "lucide-react";
1418
- import Select2 from "react-select";
1419
- import toast3 from "react-hot-toast";
1420
- import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1421
- var ALL_SOURCES_VALUE = "__all__";
1422
- function SourceSelector({
1423
- selectedSource,
1424
- onSourceChange,
1425
- onScrapeComplete,
1426
- onNewsLoaded,
1427
- onLoadingChange
1428
- }) {
1429
- const [sources, setSources] = useState7([]);
1430
- const [loading, setLoading] = useState7(true);
1431
- const [scraping, setScraping] = useState7(false);
1432
- const [fetchingNews, setFetchingNews] = useState7(true);
1433
- const { primaryColor } = useTheme();
1434
- useEffect7(() => {
1435
- onLoadingChange == null ? void 0 : onLoadingChange(fetchingNews);
1436
- }, [fetchingNews, onLoadingChange]);
1348
+ // components/preferences/Preferences.tsx
1349
+ import { useState as useState6, useEffect as useEffect7 } from "react";
1350
+ import toast from "react-hot-toast";
1351
+
1352
+ // services/settings.service.ts
1353
+ var triggerScrape = async ({
1354
+ state,
1355
+ cities
1356
+ }) => {
1357
+ const { data } = await api_default.post("/scrape/trigger", {
1358
+ state,
1359
+ cities
1360
+ });
1361
+ return data;
1362
+ };
1363
+ var getScrapeStatus = async () => {
1364
+ const { data } = await api_default.get("/scrape/status");
1365
+ return data.data;
1366
+ };
1367
+
1368
+ // components/ClientSelect.tsx
1369
+ import { useEffect as useEffect6, useState as useState5 } from "react";
1370
+ import { jsx as jsx9 } from "react/jsx-runtime";
1371
+ var ReactSelect = null;
1372
+ var ClientSelect = (props) => {
1373
+ const [mounted, setMounted] = useState5(false);
1374
+ useEffect6(() => {
1375
+ setMounted(true);
1376
+ import("react-select").then((mod) => {
1377
+ ReactSelect = mod.default;
1378
+ });
1379
+ }, []);
1380
+ if (!mounted || !ReactSelect) return null;
1381
+ return /* @__PURE__ */ jsx9(ReactSelect, __spreadValues({}, props));
1382
+ };
1383
+ var ClientSelect_default = ClientSelect;
1384
+
1385
+ // components/preferences/Preferences.tsx
1386
+ import { Fragment, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
1387
+ var STATE_OPTIONS = [
1388
+ { value: "Uttar Pradesh", label: "Uttar Pradesh" }
1389
+ ];
1390
+ var CITY_OPTIONS = [
1391
+ "Agra",
1392
+ "Aligarh",
1393
+ "Ayodhya",
1394
+ "Bareilly",
1395
+ "Bijnor",
1396
+ "Bulandshahr",
1397
+ "Etawah",
1398
+ "Firozabad",
1399
+ "Ghaziabad",
1400
+ "Gorakhpur",
1401
+ "Jhansi",
1402
+ "Kanpur",
1403
+ "Lucknow",
1404
+ "Mathura",
1405
+ "Meerut",
1406
+ "Moradabad",
1407
+ "Muzaffarnagar",
1408
+ "Noida",
1409
+ "Prayagraj",
1410
+ "Rampur",
1411
+ "Saharanpur",
1412
+ "Sitapur",
1413
+ "Unnao",
1414
+ "Varanasi"
1415
+ ].map((city) => ({ value: city, label: city }));
1416
+ var LANGUAGE_OPTIONS = [
1417
+ { value: "en", label: "English" },
1418
+ { value: "hi", label: "Hindi" }
1419
+ ];
1420
+ var TONE_OPTIONS = [
1421
+ { value: "formal", label: "Formal" },
1422
+ { value: "casual", label: "Casual" },
1423
+ { value: "engaging", label: "Engaging" },
1424
+ { value: "professional", label: "Professional" }
1425
+ ];
1426
+ var STYLE_OPTIONS = [
1427
+ { value: "news", label: "News Article" },
1428
+ { value: "blog", label: "Blog Post" },
1429
+ { value: "editorial", label: "Editorial" },
1430
+ { value: "summary", label: "Summary" }
1431
+ ];
1432
+ var WORD_COUNT_OPTIONS = [
1433
+ { value: "short", label: "Short (~300 words)" },
1434
+ { value: "medium", label: "Medium (~600 words)" },
1435
+ { value: "long", label: "Long (~1000+ words)" }
1436
+ ];
1437
+ function PreferencesPage() {
1438
+ var _a, _b, _c;
1439
+ const { preferences, loading, refreshPreferences, updatePreferences } = usePreferences();
1440
+ const primaryColor = ((_a = preferences == null ? void 0 : preferences.chatbot) == null ? void 0 : _a.primaryColor) || "#10b981";
1441
+ const [botName, setBotName] = useState6("");
1442
+ const [logo, setLogo] = useState6(null);
1443
+ const [logoUrl, setLogoUrl] = useState6(null);
1444
+ const [state, setState] = useState6(null);
1445
+ const [cities, setCities] = useState6([]);
1446
+ const [language, setLanguage] = useState6(null);
1447
+ const [tone, setTone] = useState6(null);
1448
+ const [style, setStyle] = useState6(null);
1449
+ const [wordCount, setWordCount] = useState6(null);
1450
+ const [includeQuotes, setIncludeQuotes] = useState6(true);
1451
+ const [includeFAQ, setIncludeFAQ] = useState6(false);
1452
+ const [targetAudience, setTargetAudience] = useState6("");
1453
+ const [saving, setSaving] = useState6(false);
1454
+ const [success, setSuccess] = useState6(false);
1455
+ const [scraping, setScraping] = useState6(false);
1456
+ const [scrapeStatus, setScrapeStatus] = useState6(null);
1457
+ const [loadingStatus, setLoadingStatus] = useState6(true);
1458
+ const [originalValues, setOriginalValues] = useState6({
1459
+ botName: "",
1460
+ state: void 0,
1461
+ cities: [],
1462
+ language: void 0,
1463
+ tone: void 0,
1464
+ style: void 0,
1465
+ wordCount: void 0,
1466
+ includeQuotes: true,
1467
+ includeFAQ: false,
1468
+ targetAudience: ""
1469
+ });
1437
1470
  useEffect7(() => {
1438
- const fetchSources = async () => {
1471
+ const fetchScrapeStatus = async () => {
1439
1472
  try {
1440
- const data = await getNewsSources();
1441
- setSources(data || []);
1442
- } catch (e) {
1443
- toast3.error("Failed to load news sources");
1473
+ const data = await getScrapeStatus();
1474
+ setScrapeStatus(data);
1475
+ } catch (error) {
1476
+ console.log("Failed to fetch scrape status:", error);
1444
1477
  } finally {
1445
- setLoading(false);
1478
+ setLoadingStatus(false);
1446
1479
  }
1447
1480
  };
1448
- fetchSources();
1481
+ fetchScrapeStatus();
1449
1482
  }, []);
1450
- const fetchNews = useCallback2(async (sourceId) => {
1451
- setFetchingNews(true);
1483
+ const handleScrape = async () => {
1484
+ var _a2, _b2;
1485
+ setScraping(true);
1452
1486
  try {
1453
- let news;
1454
- if (sourceId) {
1455
- news = await getNewsBySource(sourceId);
1456
- } else {
1457
- news = await getTrendingNews();
1458
- }
1459
- onNewsLoaded == null ? void 0 : onNewsLoaded(news || []);
1460
- } catch (err) {
1461
- console.error("Failed to fetch news:", err);
1487
+ await triggerScrape({
1488
+ state: (_a2 = preferences == null ? void 0 : preferences.localization) == null ? void 0 : _a2.state,
1489
+ cities: (_b2 = preferences == null ? void 0 : preferences.localization) == null ? void 0 : _b2.cities
1490
+ });
1491
+ toast.success("News scraping started successfully!");
1492
+ setTimeout(async () => {
1493
+ try {
1494
+ const data = await getScrapeStatus();
1495
+ setScrapeStatus(data);
1496
+ } catch (e) {
1497
+ console.log("Failed to refresh scrape status:", e);
1498
+ }
1499
+ }, 2e3);
1500
+ } catch (error) {
1501
+ console.error(error);
1502
+ toast.error("Failed to trigger news scraping");
1462
1503
  } finally {
1463
- setFetchingNews(false);
1504
+ setScraping(false);
1464
1505
  }
1465
- }, []);
1466
- useEffect7(() => {
1467
- fetchNews(selectedSource);
1468
- }, [selectedSource, fetchNews]);
1469
- const handleSourceSelect = (option) => {
1470
- var _a;
1471
- const value = (option == null ? void 0 : option.value) === ALL_SOURCES_VALUE ? null : (_a = option == null ? void 0 : option.value) != null ? _a : null;
1472
- onSourceChange(value);
1473
1506
  };
1474
- const handleScrape = async () => {
1475
- if (!selectedSource) {
1476
- toast3.error("Please select a source first");
1507
+ useEffect7(() => {
1508
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1509
+ if (preferences) {
1510
+ const name = ((_a2 = preferences.chatbot) == null ? void 0 : _a2.name) || "";
1511
+ const pState = (_b2 = preferences.localization) == null ? void 0 : _b2.state;
1512
+ const pCities = ((_c2 = preferences.localization) == null ? void 0 : _c2.cities) || [];
1513
+ const pLanguage = (_d = preferences.localization) == null ? void 0 : _d.language;
1514
+ setBotName(name);
1515
+ if ((_e = preferences.chatbot) == null ? void 0 : _e.logoUrl) setLogoUrl(preferences.chatbot.logoUrl);
1516
+ if (pState) {
1517
+ setState({ value: pState, label: pState });
1518
+ }
1519
+ if (Array.isArray(pCities)) {
1520
+ setCities(pCities.map((city) => ({ value: city, label: city })));
1521
+ }
1522
+ if (pLanguage) {
1523
+ const langOption = LANGUAGE_OPTIONS.find((opt) => opt.value === pLanguage);
1524
+ setLanguage(langOption || null);
1525
+ }
1526
+ const pTone = (_f = preferences.content) == null ? void 0 : _f.tone;
1527
+ const pStyle = (_g = preferences.content) == null ? void 0 : _g.style;
1528
+ const pWordCount = (_h = preferences.content) == null ? void 0 : _h.wordCount;
1529
+ const pIncludeQuotes = (_j = (_i = preferences.content) == null ? void 0 : _i.includeQuotes) != null ? _j : true;
1530
+ const pIncludeFAQ = (_l = (_k = preferences.content) == null ? void 0 : _k.includeFAQ) != null ? _l : false;
1531
+ const pTargetAudience = ((_m = preferences.content) == null ? void 0 : _m.targetAudience) || "";
1532
+ if (pTone) {
1533
+ const toneOption = TONE_OPTIONS.find((opt) => opt.value === pTone);
1534
+ setTone(toneOption || null);
1535
+ }
1536
+ if (pStyle) {
1537
+ const styleOption = STYLE_OPTIONS.find((opt) => opt.value === pStyle);
1538
+ setStyle(styleOption || null);
1539
+ }
1540
+ if (pWordCount) {
1541
+ const wordCountOption = WORD_COUNT_OPTIONS.find((opt) => opt.value === pWordCount);
1542
+ setWordCount(wordCountOption || null);
1543
+ }
1544
+ setIncludeQuotes(pIncludeQuotes);
1545
+ setIncludeFAQ(pIncludeFAQ);
1546
+ setTargetAudience(pTargetAudience);
1547
+ setOriginalValues({
1548
+ botName: name,
1549
+ state: pState,
1550
+ cities: pCities,
1551
+ language: pLanguage,
1552
+ tone: pTone,
1553
+ style: pStyle,
1554
+ wordCount: pWordCount,
1555
+ includeQuotes: pIncludeQuotes,
1556
+ includeFAQ: pIncludeFAQ,
1557
+ targetAudience: pTargetAudience
1558
+ });
1559
+ }
1560
+ }, [preferences]);
1561
+ const handleSave = async () => {
1562
+ if (!botName) {
1563
+ toast.error("Chatbot name is required");
1477
1564
  return;
1478
1565
  }
1479
- setScraping(true);
1566
+ setSaving(true);
1567
+ setSuccess(false);
1480
1568
  try {
1481
- await scrapeNewsSource(selectedSource);
1482
- toast3.success("News scraped successfully!");
1483
- onScrapeComplete == null ? void 0 : onScrapeComplete();
1484
- const news = await getNewsBySource(selectedSource);
1485
- onNewsLoaded == null ? void 0 : onNewsLoaded(news || []);
1486
- } catch (err) {
1487
- toast3.error(err || "Failed to scrape news");
1569
+ const payload = {};
1570
+ if (botName !== originalValues.botName) {
1571
+ payload.botName = botName;
1572
+ }
1573
+ if (logo) {
1574
+ payload.logo = logo;
1575
+ }
1576
+ const currentState = state == null ? void 0 : state.value;
1577
+ if (currentState !== originalValues.state) {
1578
+ payload.state = currentState;
1579
+ }
1580
+ const currentCities = cities.map((c) => c.value);
1581
+ const citiesChanged = currentCities.length !== originalValues.cities.length || currentCities.some((city, index) => city !== originalValues.cities[index]);
1582
+ if (citiesChanged) {
1583
+ payload.cities = currentCities;
1584
+ }
1585
+ const currentLanguage = language == null ? void 0 : language.value;
1586
+ if (currentLanguage !== originalValues.language) {
1587
+ payload.language = currentLanguage;
1588
+ }
1589
+ const currentTone = tone == null ? void 0 : tone.value;
1590
+ if (currentTone !== originalValues.tone) {
1591
+ payload.tone = currentTone;
1592
+ }
1593
+ const currentStyle = style == null ? void 0 : style.value;
1594
+ if (currentStyle !== originalValues.style) {
1595
+ payload.style = currentStyle;
1596
+ }
1597
+ const currentWordCount = wordCount == null ? void 0 : wordCount.value;
1598
+ if (currentWordCount !== originalValues.wordCount) {
1599
+ payload.wordCount = currentWordCount;
1600
+ }
1601
+ if (includeQuotes !== originalValues.includeQuotes) {
1602
+ payload.includeQuotes = includeQuotes;
1603
+ }
1604
+ if (includeFAQ !== originalValues.includeFAQ) {
1605
+ payload.includeFAQ = includeFAQ;
1606
+ }
1607
+ if (targetAudience !== originalValues.targetAudience) {
1608
+ payload.targetAudience = targetAudience;
1609
+ }
1610
+ if (Object.keys(payload).length === 0) {
1611
+ toast.error("No changes to save");
1612
+ setSaving(false);
1613
+ return;
1614
+ }
1615
+ const updatedPreferences = await savePreferencesApi(payload);
1616
+ if (updatedPreferences) {
1617
+ updatePreferences(updatedPreferences);
1618
+ } else {
1619
+ await refreshPreferences();
1620
+ }
1621
+ setSuccess(true);
1622
+ setLogo(null);
1623
+ toast.success("Preferences saved successfully!");
1624
+ } catch (error) {
1625
+ console.error(error);
1626
+ toast.error("Failed to save preferences");
1488
1627
  } finally {
1489
- setScraping(false);
1628
+ setSaving(false);
1490
1629
  }
1491
1630
  };
1492
- const options = [
1493
- { value: ALL_SOURCES_VALUE, label: "All Sources (Trending)" },
1494
- ...sources.map((source) => ({
1495
- value: source.id,
1496
- label: source.name
1497
- }))
1498
- ];
1499
- const selectedOption = options.find(
1500
- (opt) => selectedSource === null ? opt.value === ALL_SOURCES_VALUE : opt.value === selectedSource
1501
- ) || options[0];
1502
- return /* @__PURE__ */ jsxs9("div", { className: "cnfy-source-selector", children: [
1503
- /* @__PURE__ */ jsx10("div", { className: "cnfy-source-selector-select-wrap", children: /* @__PURE__ */ jsx10(
1504
- Select2,
1505
- {
1506
- options,
1507
- value: selectedOption,
1508
- onChange: handleSourceSelect,
1509
- isLoading: loading,
1510
- isDisabled: loading,
1511
- placeholder: "Select source...",
1512
- classNamePrefix: "react-select",
1513
- menuPlacement: "bottom",
1514
- menuPosition: "fixed",
1515
- menuShouldScrollIntoView: false,
1516
- maxMenuHeight: 220,
1517
- menuPortalTarget: typeof window !== "undefined" ? document.body : null,
1518
- styles: {
1519
- container: (base) => __spreadProps(__spreadValues({}, base), {
1520
- width: "100%"
1521
- }),
1522
- control: (base) => __spreadProps(__spreadValues({}, base), {
1523
- minHeight: "38px",
1524
- borderColor: "#e5e7eb",
1525
- boxShadow: "none",
1526
- width: "100%"
1527
- }),
1528
- menu: (base) => __spreadProps(__spreadValues({}, base), {
1529
- width: "100%",
1530
- zIndex: 999999
1531
- }),
1532
- menuPortal: (base) => __spreadProps(__spreadValues({}, base), {
1533
- zIndex: 999999
1534
- }),
1535
- option: (base, state) => __spreadProps(__spreadValues({}, base), {
1536
- backgroundColor: state.isSelected ? primaryColor : state.isFocused ? "#f3f4f6" : "white",
1537
- color: state.isSelected ? "white" : "#374151",
1538
- cursor: "pointer"
1539
- })
1631
+ if (loading) {
1632
+ return /* @__PURE__ */ jsx10("div", { className: "cnfy-dash-page", children: /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-page-subtitle", children: "Loading settings..." }) });
1633
+ }
1634
+ return /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-page", children: [
1635
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card", children: [
1636
+ /* @__PURE__ */ jsx10("h2", { className: "cnfy-dash-card-title", children: "Chatbot Settings" }),
1637
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
1638
+ /* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Chatbot Name" }),
1639
+ /* @__PURE__ */ jsx10(
1640
+ "input",
1641
+ {
1642
+ value: botName,
1643
+ onChange: (e) => setBotName(e.target.value),
1644
+ className: "cnfy-dash-input",
1645
+ placeholder: "Contenify AI"
1646
+ }
1647
+ )
1648
+ ] }),
1649
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
1650
+ /* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Chatbot Logo" }),
1651
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-logo-upload", children: [
1652
+ /* @__PURE__ */ jsx10("div", { className: "cnfy-logo-preview", children: logo ? /* @__PURE__ */ jsx10(
1653
+ "img",
1654
+ {
1655
+ src: URL.createObjectURL(logo),
1656
+ alt: "Logo preview",
1657
+ className: "cnfy-logo-img"
1658
+ }
1659
+ ) : logoUrl ? /* @__PURE__ */ jsx10(
1660
+ "img",
1661
+ {
1662
+ src: logoUrl,
1663
+ alt: "Current logo",
1664
+ className: "cnfy-logo-img"
1665
+ }
1666
+ ) : /* @__PURE__ */ jsx10("span", { className: "cnfy-logo-placeholder", children: "No logo" }) }),
1667
+ /* @__PURE__ */ jsx10(
1668
+ "input",
1669
+ {
1670
+ type: "file",
1671
+ accept: "image/*",
1672
+ onChange: (e) => {
1673
+ var _a2;
1674
+ return setLogo(((_a2 = e.target.files) == null ? void 0 : _a2[0]) || null);
1675
+ },
1676
+ className: "cnfy-file-input"
1677
+ }
1678
+ )
1679
+ ] })
1680
+ ] })
1681
+ ] }),
1682
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card", children: [
1683
+ /* @__PURE__ */ jsx10("h2", { className: "cnfy-dash-card-title", children: "Localization Settings" }),
1684
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
1685
+ /* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "State" }),
1686
+ /* @__PURE__ */ jsx10(
1687
+ ClientSelect_default,
1688
+ {
1689
+ options: STATE_OPTIONS,
1690
+ value: state,
1691
+ onChange: (option) => setState(option),
1692
+ placeholder: "Select state"
1693
+ }
1694
+ )
1695
+ ] }),
1696
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
1697
+ /* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Cities" }),
1698
+ /* @__PURE__ */ jsx10(
1699
+ ClientSelect_default,
1700
+ {
1701
+ isMulti: true,
1702
+ options: CITY_OPTIONS,
1703
+ value: cities,
1704
+ onChange: (options) => setCities(options),
1705
+ placeholder: "Select cities",
1706
+ isDisabled: !state
1707
+ }
1708
+ )
1709
+ ] }),
1710
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
1711
+ /* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Language" }),
1712
+ /* @__PURE__ */ jsx10(
1713
+ ClientSelect_default,
1714
+ {
1715
+ options: LANGUAGE_OPTIONS,
1716
+ value: language,
1717
+ onChange: (option) => setLanguage(option),
1718
+ placeholder: "Select language"
1719
+ }
1720
+ )
1721
+ ] })
1722
+ ] }),
1723
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card", children: [
1724
+ /* @__PURE__ */ jsx10("h2", { className: "cnfy-dash-card-title", children: "Content Generation Settings" }),
1725
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
1726
+ /* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Tone" }),
1727
+ /* @__PURE__ */ jsx10(
1728
+ ClientSelect_default,
1729
+ {
1730
+ options: TONE_OPTIONS,
1731
+ value: tone,
1732
+ onChange: (option) => setTone(option),
1733
+ placeholder: "Select tone"
1734
+ }
1735
+ ),
1736
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-hint", children: "The writing tone for generated content" })
1737
+ ] }),
1738
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
1739
+ /* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Style" }),
1740
+ /* @__PURE__ */ jsx10(
1741
+ ClientSelect_default,
1742
+ {
1743
+ options: STYLE_OPTIONS,
1744
+ value: style,
1745
+ onChange: (option) => setStyle(option),
1746
+ placeholder: "Select style"
1747
+ }
1748
+ ),
1749
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-hint", children: "The format/style of generated articles" })
1750
+ ] }),
1751
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
1752
+ /* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Word Count" }),
1753
+ /* @__PURE__ */ jsx10(
1754
+ ClientSelect_default,
1755
+ {
1756
+ options: WORD_COUNT_OPTIONS,
1757
+ value: wordCount,
1758
+ onChange: (option) => setWordCount(option),
1759
+ placeholder: "Select word count"
1760
+ }
1761
+ ),
1762
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-hint", children: "Target length for generated content" })
1763
+ ] }),
1764
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
1765
+ /* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Target Audience" }),
1766
+ /* @__PURE__ */ jsx10(
1767
+ "input",
1768
+ {
1769
+ value: targetAudience,
1770
+ onChange: (e) => setTargetAudience(e.target.value),
1771
+ className: "cnfy-dash-input",
1772
+ placeholder: "e.g. tech-savvy millennials, business professionals"
1773
+ }
1774
+ ),
1775
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-hint", children: "Describe your target audience for personalized content" })
1776
+ ] }),
1777
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-toggle-group", children: [
1778
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-toggle-row", children: [
1779
+ /* @__PURE__ */ jsxs7("div", { children: [
1780
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-toggle-label", children: "Include Quotes" }),
1781
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-toggle-desc", children: "Add relevant quotes to generated articles" })
1782
+ ] }),
1783
+ /* @__PURE__ */ jsx10(
1784
+ "button",
1785
+ {
1786
+ type: "button",
1787
+ role: "switch",
1788
+ "aria-checked": includeQuotes,
1789
+ onClick: () => setIncludeQuotes(!includeQuotes),
1790
+ className: "cnfy-toggle",
1791
+ style: { backgroundColor: includeQuotes ? primaryColor : "#d1d5db" },
1792
+ children: /* @__PURE__ */ jsx10(
1793
+ "span",
1794
+ {
1795
+ className: `cnfy-toggle-thumb ${includeQuotes ? "cnfy-toggle-thumb--on" : ""}`
1796
+ }
1797
+ )
1798
+ }
1799
+ )
1800
+ ] }),
1801
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-toggle-row", children: [
1802
+ /* @__PURE__ */ jsxs7("div", { children: [
1803
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-toggle-label", children: "Include FAQ Section" }),
1804
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-toggle-desc", children: "Add FAQ section at the end of articles" })
1805
+ ] }),
1806
+ /* @__PURE__ */ jsx10(
1807
+ "button",
1808
+ {
1809
+ type: "button",
1810
+ role: "switch",
1811
+ "aria-checked": includeFAQ,
1812
+ onClick: () => setIncludeFAQ(!includeFAQ),
1813
+ className: "cnfy-toggle",
1814
+ style: { backgroundColor: includeFAQ ? primaryColor : "#d1d5db" },
1815
+ children: /* @__PURE__ */ jsx10(
1816
+ "span",
1817
+ {
1818
+ className: `cnfy-toggle-thumb ${includeFAQ ? "cnfy-toggle-thumb--on" : ""}`
1819
+ }
1820
+ )
1821
+ }
1822
+ )
1823
+ ] })
1824
+ ] })
1825
+ ] }),
1826
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card", children: [
1827
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card-header", children: [
1828
+ /* @__PURE__ */ jsx10("h2", { className: "cnfy-dash-card-title-inline", children: "News Scraping" }),
1829
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-card-desc", children: "Scrape latest news from your configured locations" })
1830
+ ] }),
1831
+ !loadingStatus && scrapeStatus && /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-grid cnfy-dash-grid--sm", children: [
1832
+ /* @__PURE__ */ jsxs7("div", { children: [
1833
+ /* @__PURE__ */ jsx10("span", { className: "cnfy-dash-label-muted", children: "Status:" }),
1834
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-label-bold", children: scrapeStatus.isRunning ? /* @__PURE__ */ jsx10("span", { className: "cnfy-dash-badge cnfy-dash-badge--yellow", children: "Running" }) : /* @__PURE__ */ jsx10("span", { className: "cnfy-dash-badge cnfy-dash-badge--green", children: "Idle" }) })
1835
+ ] }),
1836
+ scrapeStatus.lastRun && /* @__PURE__ */ jsxs7("div", { children: [
1837
+ /* @__PURE__ */ jsx10("span", { className: "cnfy-dash-label-muted", children: "Last Run:" }),
1838
+ /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-label-bold", children: new Date(scrapeStatus.lastRun).toLocaleString() })
1839
+ ] }),
1840
+ scrapeStatus.totalScraped !== void 0 && /* @__PURE__ */ jsxs7("div", { children: [
1841
+ /* @__PURE__ */ jsx10("span", { className: "cnfy-dash-label-muted", children: "Total Scraped:" }),
1842
+ /* @__PURE__ */ jsxs7("p", { className: "cnfy-dash-label-bold", children: [
1843
+ scrapeStatus.totalScraped.toLocaleString(),
1844
+ " articles"
1845
+ ] })
1846
+ ] })
1847
+ ] }),
1848
+ /* @__PURE__ */ jsxs7("div", { children: [
1849
+ /* @__PURE__ */ jsxs7("p", { className: "cnfy-dash-info-text", children: [
1850
+ "Current configuration: ",
1851
+ /* @__PURE__ */ jsx10("strong", { children: (_b = preferences == null ? void 0 : preferences.localization) == null ? void 0 : _b.state }),
1852
+ ((_c = preferences == null ? void 0 : preferences.localization) == null ? void 0 : _c.cities) && preferences.localization.cities.length > 0 && /* @__PURE__ */ jsxs7(Fragment, { children: [
1853
+ " - ",
1854
+ preferences.localization.cities.join(", ")
1855
+ ] })
1856
+ ] }),
1857
+ /* @__PURE__ */ jsx10(
1858
+ "button",
1859
+ {
1860
+ onClick: handleScrape,
1861
+ disabled: scraping || (scrapeStatus == null ? void 0 : scrapeStatus.isRunning),
1862
+ className: "cnfy-dash-btn-save",
1863
+ style: { backgroundColor: primaryColor },
1864
+ children: scraping ? "Starting Scrape..." : (scrapeStatus == null ? void 0 : scrapeStatus.isRunning) ? "Scraping in Progress..." : "Start Scraping"
1865
+ }
1866
+ )
1867
+ ] })
1868
+ ] }),
1869
+ /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-actions", children: [
1870
+ /* @__PURE__ */ jsx10(
1871
+ "button",
1872
+ {
1873
+ onClick: handleSave,
1874
+ disabled: saving,
1875
+ className: "cnfy-dash-btn-save",
1876
+ style: { backgroundColor: primaryColor },
1877
+ children: saving ? "Saving..." : "Save Preferences"
1540
1878
  }
1541
- }
1542
- ) }),
1543
- selectedSource && /* @__PURE__ */ jsxs9(
1544
- "button",
1545
- {
1546
- onClick: handleScrape,
1547
- disabled: scraping,
1548
- className: "cnfy-scrape-btn",
1549
- title: "Fetch latest news",
1550
- children: [
1551
- /* @__PURE__ */ jsx10(RefreshCcw3, { size: 14, className: scraping ? "cnfy-animate-spin" : "" }),
1552
- scraping ? "Scraping..." : "Scrape"
1553
- ]
1554
- }
1555
- ),
1556
- !selectedSource && /* @__PURE__ */ jsxs9(
1557
- "button",
1558
- {
1559
- onClick: () => fetchNews(null),
1560
- disabled: fetchingNews,
1561
- className: "cnfy-refresh-btn",
1562
- children: [
1563
- /* @__PURE__ */ jsx10(RefreshCcw3, { size: 14, className: fetchingNews ? "cnfy-animate-spin" : "" }),
1564
- "Refresh"
1565
- ]
1566
- }
1567
- )
1879
+ ),
1880
+ success && /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-success", style: { color: primaryColor }, children: "Preferences saved successfully \u2705" })
1881
+ ] })
1568
1882
  ] });
1569
1883
  }
1570
1884
 
@@ -1588,7 +1902,7 @@ var createContentStreamApi = async ({
1588
1902
  }) => {
1589
1903
  var _a;
1590
1904
  const API_BASE_URL = getApiBaseUrl();
1591
- const apiKey = process.env.NEXT_PUBLIC_API_KEY;
1905
+ const apiKey = getApiKey();
1592
1906
  const headers = {
1593
1907
  "Content-Type": "application/json"
1594
1908
  };
@@ -1681,7 +1995,7 @@ var rewriteNewsStreamApi = async ({
1681
1995
  if (targetAudience) payload.targetAudience = targetAudience;
1682
1996
  try {
1683
1997
  const API_BASE_URL = getApiBaseUrl();
1684
- const apiKey = process.env.NEXT_PUBLIC_API_KEY;
1998
+ const apiKey = getApiKey();
1685
1999
  console.log("\u{1F680} Starting stream request to:", `${API_BASE_URL}/chat/rewrite/stream`);
1686
2000
  console.log("\u{1F4E6} Payload:", payload);
1687
2001
  const headers = {
@@ -1810,32 +2124,18 @@ var rewriteNewsApi = async ({
1810
2124
  };
1811
2125
 
1812
2126
  // components/chatbot/ChatBot.tsx
1813
- import toast4 from "react-hot-toast";
2127
+ import toast2 from "react-hot-toast";
1814
2128
  import { Loader2 } from "lucide-react";
1815
- import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1816
- function ChatBot({
1817
- onNavigate,
1818
- onLogout
1819
- } = {}) {
1820
- const { loading, showNewsPanel } = useTheme();
2129
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
2130
+ function ChatBot() {
2131
+ const { loading } = useTheme();
1821
2132
  const { preferences } = usePreferences();
1822
- const [selectedSource, setSelectedSource] = useState8(null);
1823
- const [news, setNews] = useState8([]);
1824
- const [newsLoading, setNewsLoading] = useState8(true);
1825
- const [selectedArticle, setSelectedArticle] = useState8(null);
1826
- const [messages, setMessages] = useState8([]);
1827
- const [showChatMobile, setShowChatMobile] = useState8(false);
1828
- const [isStreaming, setIsStreaming] = useState8(false);
1829
- const [analyzedData, setAnalyzedData] = useState8(null);
1830
- const handleNewsLoaded = useCallback3((loadedNews) => {
1831
- setNews(loadedNews);
1832
- }, []);
1833
- const handleLoadingChange = useCallback3((isLoading) => {
1834
- setNewsLoading(isLoading);
1835
- }, []);
2133
+ const [preferencesOpen, setPreferencesOpen] = useState7(false);
2134
+ const [messages, setMessages] = useState7([]);
2135
+ const [isStreaming, setIsStreaming] = useState7(false);
2136
+ const [analyzedData, setAnalyzedData] = useState7(null);
1836
2137
  const handleRecreate = async ({ title, content, id }) => {
1837
2138
  var _a;
1838
- setShowChatMobile(true);
1839
2139
  const assistantId = crypto.randomUUID();
1840
2140
  setMessages((prev) => [
1841
2141
  ...prev,
@@ -1878,7 +2178,7 @@ ${title}`
1878
2178
  },
1879
2179
  onComplete: () => {
1880
2180
  console.log("Streaming completed successfully");
1881
- toast4.success("Article created successfully!");
2181
+ toast2.success("Article created successfully!");
1882
2182
  },
1883
2183
  onError: async (error) => {
1884
2184
  console.error("Streaming error:", error);
@@ -1886,7 +2186,7 @@ ${title}`
1886
2186
  console.log("Falling back to regular API...");
1887
2187
  throw error;
1888
2188
  } else {
1889
- toast4.error("Failed to complete article generation");
2189
+ toast2.error("Failed to complete article generation");
1890
2190
  setMessages(
1891
2191
  (prev) => prev.map(
1892
2192
  (m) => m.id === assistantId ? __spreadProps(__spreadValues({}, m), { content: accumulatedContent || "\u274C Failed to create article. Please try again." }) : m
@@ -1918,11 +2218,11 @@ ${title}`
1918
2218
  (m) => m.id === assistantId ? __spreadProps(__spreadValues({}, m), { content: result.article || result }) : m
1919
2219
  )
1920
2220
  );
1921
- toast4.success("Article created successfully!");
2221
+ toast2.success("Article created successfully!");
1922
2222
  }
1923
2223
  } catch (err) {
1924
2224
  console.error("Complete Error:", err);
1925
- toast4.error((err == null ? void 0 : err.message) || "An error occurred while creating the article");
2225
+ toast2.error((err == null ? void 0 : err.message) || "An error occurred while creating the article");
1926
2226
  setMessages(
1927
2227
  (prev) => prev.map(
1928
2228
  (m) => m.id === assistantId ? __spreadProps(__spreadValues({}, m), { content: "\u274C Failed to create article. Please try again." }) : m
@@ -1973,7 +2273,7 @@ ${optionsList}`
1973
2273
  }
1974
2274
  } catch (err) {
1975
2275
  console.error("Analyze input error:", err);
1976
- toast4.error("Failed to analyze the link");
2276
+ toast2.error("Failed to analyze the link");
1977
2277
  setMessages(
1978
2278
  (prev) => prev.map(
1979
2279
  (m) => m.id === assistantId ? __spreadProps(__spreadValues({}, m), { content: "\u274C Failed to analyze the link. Please try again." }) : m
@@ -2009,12 +2309,12 @@ ${optionsList}`
2009
2309
  },
2010
2310
  onComplete: () => {
2011
2311
  setIsStreaming(false);
2012
- toast4.success("Content generated!");
2312
+ toast2.success("Content generated!");
2013
2313
  },
2014
2314
  onError: (error) => {
2015
2315
  console.error("Stream error:", error);
2016
2316
  setIsStreaming(false);
2017
- toast4.error("Failed to generate content");
2317
+ toast2.error("Failed to generate content");
2018
2318
  }
2019
2319
  });
2020
2320
  } catch (err) {
@@ -2062,12 +2362,12 @@ ${optionsList}`
2062
2362
  },
2063
2363
  onComplete: () => {
2064
2364
  setIsStreaming(false);
2065
- toast4.success("Content created!");
2365
+ toast2.success("Content created!");
2066
2366
  },
2067
2367
  onError: (error) => {
2068
2368
  console.error("Stream error:", error);
2069
2369
  setIsStreaming(false);
2070
- toast4.error("Failed to create content");
2370
+ toast2.error("Failed to create content");
2071
2371
  }
2072
2372
  });
2073
2373
  } catch (e) {
@@ -2082,7 +2382,7 @@ ${optionsList}`
2082
2382
  )
2083
2383
  );
2084
2384
  setIsStreaming(false);
2085
- toast4.success("Content created!");
2385
+ toast2.success("Content created!");
2086
2386
  }
2087
2387
  } catch (err) {
2088
2388
  console.error("Create content error:", err);
@@ -2095,74 +2395,37 @@ ${optionsList}`
2095
2395
  }
2096
2396
  };
2097
2397
  if (loading) {
2098
- return /* @__PURE__ */ jsx11("div", { className: "cnfy-loading", children: /* @__PURE__ */ jsxs10("div", { className: "cnfy-loading-inner", children: [
2398
+ return /* @__PURE__ */ jsx11("div", { className: "cnfy-loading", children: /* @__PURE__ */ jsxs8("div", { className: "cnfy-loading-inner", children: [
2099
2399
  /* @__PURE__ */ jsx11(Loader2, { className: "cnfy-loading-spinner cnfy-animate-spin" }),
2100
2400
  /* @__PURE__ */ jsx11("p", { className: "cnfy-loading-text", children: "Loading..." })
2101
2401
  ] }) });
2102
2402
  }
2103
- return /* @__PURE__ */ jsxs10("div", { className: "cnfy-root", children: [
2104
- /* @__PURE__ */ jsx11(HeaderBar, { onNavigate, onLogout }),
2105
- /* @__PURE__ */ jsxs10("div", { className: `cnfy-main ${showNewsPanel ? "cnfy-main--with-news" : ""}`, children: [
2106
- showNewsPanel && /* @__PURE__ */ jsxs10("aside", { className: "cnfy-sidebar", children: [
2107
- /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsx11(
2108
- SourceSelector,
2109
- {
2110
- selectedSource,
2111
- onSourceChange: (value) => {
2112
- console.log("Selected source:", value);
2113
- setSelectedSource(value);
2114
- },
2115
- onNewsLoaded: handleNewsLoaded,
2116
- onLoadingChange: handleLoadingChange
2117
- }
2118
- ) }),
2119
- /* @__PURE__ */ jsx11(
2120
- TrendingNews,
2121
- {
2122
- onRecreate: handleRecreate,
2123
- news,
2124
- isLoading: newsLoading
2125
- }
2126
- )
2127
- ] }),
2128
- /* @__PURE__ */ jsxs10(
2129
- "section",
2403
+ return /* @__PURE__ */ jsxs8("div", { className: "cnfy-root", children: [
2404
+ /* @__PURE__ */ jsx11(HeaderBar, { onOpenPreferences: () => setPreferencesOpen(true) }),
2405
+ /* @__PURE__ */ jsx11("div", { className: "cnfy-main", children: /* @__PURE__ */ jsxs8("section", { className: "cnfy-chat-section cnfy-chat-section--full", children: [
2406
+ /* @__PURE__ */ jsx11("div", { className: "cnfy-chat-inner", children: /* @__PURE__ */ jsx11(
2407
+ ChatWindow,
2130
2408
  {
2131
- className: `cnfy-chat-section ${showNewsPanel ? "cnfy-chat-section--with-news" : "cnfy-chat-section--full"} ${showChatMobile ? "cnfy-chat-section--visible" : "cnfy-chat-section--hidden-mobile"}`,
2132
- children: [
2133
- /* @__PURE__ */ jsx11("div", { className: "cnfy-mobile-back", children: /* @__PURE__ */ jsx11(
2134
- "button",
2135
- {
2136
- onClick: () => setShowChatMobile(false),
2137
- className: "cnfy-mobile-back-btn",
2138
- children: "\u2190 Back to news"
2139
- }
2140
- ) }),
2141
- /* @__PURE__ */ jsx11("div", { className: "cnfy-chat-inner", children: /* @__PURE__ */ jsx11(
2142
- ChatWindow,
2143
- {
2144
- messages,
2145
- onSend: handleSendMessage,
2146
- onSelectNews: handleRecreate,
2147
- isStreaming,
2148
- analyzedData,
2149
- onSelectAction: handleSelectAction
2150
- }
2151
- ) }),
2152
- !messages.length && /* @__PURE__ */ jsx11("div", { className: "cnfy-empty-state", children: /* @__PURE__ */ jsxs10("div", { children: [
2153
- /* @__PURE__ */ jsx11("p", { className: "cnfy-empty-state-title", children: "AI News Assistant" }),
2154
- /* @__PURE__ */ jsx11("p", { className: "cnfy-empty-state-subtitle", children: "Select a news article or type a message to begin" })
2155
- ] }) })
2156
- ]
2409
+ messages,
2410
+ onSend: handleSendMessage,
2411
+ onSelectNews: handleRecreate,
2412
+ isStreaming,
2413
+ analyzedData,
2414
+ onSelectAction: handleSelectAction
2157
2415
  }
2158
- )
2159
- ] }),
2160
- selectedArticle && /* @__PURE__ */ jsx11(
2161
- ArticleModal,
2416
+ ) }),
2417
+ !messages.length && /* @__PURE__ */ jsx11("div", { className: "cnfy-empty-state", children: /* @__PURE__ */ jsxs8("div", { children: [
2418
+ /* @__PURE__ */ jsx11("p", { className: "cnfy-empty-state-title", children: "AI News Assistant" }),
2419
+ /* @__PURE__ */ jsx11("p", { className: "cnfy-empty-state-subtitle", children: "Type a message or paste a link to begin" })
2420
+ ] }) })
2421
+ ] }) }),
2422
+ /* @__PURE__ */ jsx11(
2423
+ Drawer,
2162
2424
  {
2163
- article: selectedArticle,
2164
- onClose: () => setSelectedArticle(null),
2165
- onRecreate: handleRecreate
2425
+ open: preferencesOpen,
2426
+ onClose: () => setPreferencesOpen(false),
2427
+ title: "Settings",
2428
+ children: /* @__PURE__ */ jsx11(PreferencesPage, {})
2166
2429
  }
2167
2430
  )
2168
2431
  ] });
@@ -2170,12 +2433,16 @@ ${optionsList}`
2170
2433
 
2171
2434
  // src/index.tsx
2172
2435
  import { jsx as jsx12 } from "react/jsx-runtime";
2173
- function ContenifyChatBot({ onNavigate, onLogout }) {
2174
- return /* @__PURE__ */ jsx12(PreferencesProvider, { children: /* @__PURE__ */ jsx12(ChatBot, { onNavigate, onLogout }) });
2436
+ function ContenifyChatBot({ apiUrl, apiKey, domain }) {
2437
+ useEffect8(() => {
2438
+ setConfig({ apiUrl, apiKey, domain });
2439
+ }, [apiUrl, apiKey, domain]);
2440
+ return /* @__PURE__ */ jsx12(PreferencesProvider, { children: /* @__PURE__ */ jsx12(ChatBot, {}) });
2175
2441
  }
2176
2442
  var index_default = ContenifyChatBot;
2177
2443
  export {
2178
2444
  ContenifyChatBot,
2179
- index_default as default
2445
+ index_default as default,
2446
+ setConfig
2180
2447
  };
2181
2448
  //# sourceMappingURL=index.mjs.map