aizek-chatbot 1.0.1 → 1.0.3
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.cjs +275 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +248 -179
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
2
3
|
|
|
3
|
-
var React = require(
|
|
4
|
-
var jsxRuntime = require(
|
|
5
|
-
var OpenAI = require(
|
|
6
|
-
var ReactMarkdown = require(
|
|
7
|
-
var remarkGfm = require(
|
|
4
|
+
var React = require("react");
|
|
5
|
+
var jsxRuntime = require("react/jsx-runtime");
|
|
6
|
+
var OpenAI = require("openai");
|
|
7
|
+
var ReactMarkdown = require("react-markdown");
|
|
8
|
+
var remarkGfm = require("remark-gfm");
|
|
8
9
|
|
|
9
|
-
function _interopDefault
|
|
10
|
+
function _interopDefault(e) {
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
12
|
+
}
|
|
10
13
|
|
|
11
14
|
function _interopNamespace(e) {
|
|
12
15
|
if (e && e.__esModule) return e;
|
|
13
16
|
var n = Object.create(null);
|
|
14
17
|
if (e) {
|
|
15
18
|
Object.keys(e).forEach(function (k) {
|
|
16
|
-
if (k !==
|
|
19
|
+
if (k !== "default") {
|
|
17
20
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
-
Object.defineProperty(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
Object.defineProperty(
|
|
22
|
+
n,
|
|
23
|
+
k,
|
|
24
|
+
d.get
|
|
25
|
+
? d
|
|
26
|
+
: {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return e[k];
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
);
|
|
22
33
|
}
|
|
23
34
|
});
|
|
24
35
|
}
|
|
@@ -26,10 +37,10 @@ function _interopNamespace(e) {
|
|
|
26
37
|
return Object.freeze(n);
|
|
27
38
|
}
|
|
28
39
|
|
|
29
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
30
|
-
var OpenAI__default = /*#__PURE__*/_interopDefault(OpenAI);
|
|
31
|
-
var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
|
|
32
|
-
var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
|
|
40
|
+
var React__namespace = /*#__PURE__*/ _interopNamespace(React);
|
|
41
|
+
var OpenAI__default = /*#__PURE__*/ _interopDefault(OpenAI);
|
|
42
|
+
var ReactMarkdown__default = /*#__PURE__*/ _interopDefault(ReactMarkdown);
|
|
43
|
+
var remarkGfm__default = /*#__PURE__*/ _interopDefault(remarkGfm);
|
|
33
44
|
|
|
34
45
|
// src/utils/cx.ts
|
|
35
46
|
function cx(...args) {
|
|
@@ -44,18 +55,18 @@ var base = {
|
|
|
44
55
|
lineHeight: 1,
|
|
45
56
|
transition: "background-color .2s ease, color .2s ease, border-color .2s ease",
|
|
46
57
|
outline: "none",
|
|
47
|
-
cursor: "pointer"
|
|
58
|
+
cursor: "pointer",
|
|
48
59
|
};
|
|
49
60
|
var sizes = {
|
|
50
61
|
sm: { height: 36, padding: "0 12px", fontSize: 14 },
|
|
51
62
|
md: { height: 40, padding: "0 16px", fontSize: 16 },
|
|
52
|
-
lg: { height: 44, padding: "0 20px", fontSize: 18 }
|
|
63
|
+
lg: { height: 44, padding: "0 20px", fontSize: 18 },
|
|
53
64
|
};
|
|
54
65
|
var palette = {
|
|
55
66
|
brand: {
|
|
56
67
|
primary: "#2563eb",
|
|
57
|
-
primaryHover: "#1d4ed8"
|
|
58
|
-
}
|
|
68
|
+
primaryHover: "#1d4ed8",
|
|
69
|
+
},
|
|
59
70
|
};
|
|
60
71
|
function styleFor(variant) {
|
|
61
72
|
switch (variant) {
|
|
@@ -63,49 +74,50 @@ function styleFor(variant) {
|
|
|
63
74
|
return {
|
|
64
75
|
background: "transparent",
|
|
65
76
|
color: palette.brand.primary,
|
|
66
|
-
border: `1px solid ${palette.brand.primary}
|
|
77
|
+
border: `1px solid ${palette.brand.primary}`,
|
|
67
78
|
};
|
|
68
79
|
case "ghost":
|
|
69
80
|
return {
|
|
70
81
|
background: "transparent",
|
|
71
82
|
color: palette.brand.primary,
|
|
72
|
-
border: "1px solid transparent"
|
|
83
|
+
border: "1px solid transparent",
|
|
73
84
|
};
|
|
74
85
|
default:
|
|
75
86
|
return {
|
|
76
87
|
background: palette.brand.primary,
|
|
77
88
|
color: "#fff",
|
|
78
|
-
border: "1px solid transparent"
|
|
89
|
+
border: "1px solid transparent",
|
|
79
90
|
};
|
|
80
91
|
}
|
|
81
92
|
}
|
|
82
|
-
var Button = React__namespace.forwardRef(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
);
|
|
93
|
+
var Button = React__namespace.forwardRef(({ variant = "primary", size = "md", style, className, onMouseEnter, onMouseLeave, ...props }, ref) => {
|
|
94
|
+
const [hover, setHover] = React__namespace.useState(false);
|
|
95
|
+
const hoverStyle =
|
|
96
|
+
variant === "primary"
|
|
97
|
+
? { background: hover ? palette.brand.primaryHover : palette.brand.primary }
|
|
98
|
+
: variant === "outline"
|
|
99
|
+
? { borderColor: hover ? palette.brand.primaryHover : palette.brand.primary }
|
|
100
|
+
: { background: hover ? "rgba(37, 99, 235, 0.08)" : "transparent" };
|
|
101
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", {
|
|
102
|
+
ref,
|
|
103
|
+
className: cx("rui-btn", className),
|
|
104
|
+
style: { ...base, ...sizes[size], ...styleFor(variant), ...(hover ? hoverStyle : {}), ...style },
|
|
105
|
+
onMouseEnter: (e) => {
|
|
106
|
+
setHover(true);
|
|
107
|
+
onMouseEnter?.(e);
|
|
108
|
+
},
|
|
109
|
+
onMouseLeave: (e) => {
|
|
110
|
+
setHover(false);
|
|
111
|
+
onMouseLeave?.(e);
|
|
112
|
+
},
|
|
113
|
+
...props,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
105
116
|
Button.displayName = "Button";
|
|
106
117
|
var useChatbot = (options = {}) => {
|
|
107
118
|
const { mcpUrl, apiKey } = options;
|
|
108
119
|
const client = new OpenAI__default.default({ apiKey, dangerouslyAllowBrowser: true });
|
|
120
|
+
const [responseId, setResponseId] = React.useState(null);
|
|
109
121
|
const [messages, setMessages] = React.useState([]);
|
|
110
122
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
111
123
|
const generateId = () => {
|
|
@@ -116,7 +128,7 @@ var useChatbot = (options = {}) => {
|
|
|
116
128
|
id: generateId(),
|
|
117
129
|
content,
|
|
118
130
|
role,
|
|
119
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
131
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
120
132
|
};
|
|
121
133
|
setMessages((prev) => [...prev, newMessage]);
|
|
122
134
|
return newMessage;
|
|
@@ -125,23 +137,41 @@ var useChatbot = (options = {}) => {
|
|
|
125
137
|
if (!message.trim() || isLoading) return;
|
|
126
138
|
addMessage(message, "user");
|
|
127
139
|
setIsLoading(true);
|
|
128
|
-
console.log(options.userToken);
|
|
129
140
|
try {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
let resp;
|
|
142
|
+
if (options.userToken) {
|
|
143
|
+
resp = await client.responses.create({
|
|
144
|
+
model: "gpt-5",
|
|
145
|
+
tools: [
|
|
146
|
+
{
|
|
147
|
+
type: "mcp",
|
|
148
|
+
server_label: "aizek-mcp",
|
|
149
|
+
server_url: mcpUrl,
|
|
150
|
+
require_approval: "never",
|
|
151
|
+
headers: {
|
|
152
|
+
Authorization: `Bearer ${options.userToken}`,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
input: message,
|
|
157
|
+
previous_response_id: responseId || void 0,
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
resp = await client.responses.create({
|
|
161
|
+
model: "gpt-5",
|
|
162
|
+
tools: [
|
|
163
|
+
{
|
|
164
|
+
type: "mcp",
|
|
165
|
+
server_label: "aizek-mcp",
|
|
166
|
+
server_url: mcpUrl,
|
|
167
|
+
require_approval: "never",
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
input: message,
|
|
171
|
+
previous_response_id: responseId || void 0,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
setResponseId(resp.id);
|
|
145
175
|
let responseText = "";
|
|
146
176
|
if (resp && Array.isArray(resp)) {
|
|
147
177
|
const messageItem = resp.find((item) => item.type === "message");
|
|
@@ -173,7 +203,7 @@ var useChatbot = (options = {}) => {
|
|
|
173
203
|
messages,
|
|
174
204
|
isLoading,
|
|
175
205
|
sendMessage,
|
|
176
|
-
addMessage
|
|
206
|
+
addMessage,
|
|
177
207
|
};
|
|
178
208
|
};
|
|
179
209
|
|
|
@@ -184,8 +214,8 @@ var fetchChatWidgetSettings = async (clientId) => {
|
|
|
184
214
|
const response = await fetch(`${API_BASE_URL}/ChatWidgetSettings/GetByClientId?client_id=${clientId}`, {
|
|
185
215
|
method: "GET",
|
|
186
216
|
headers: {
|
|
187
|
-
"Content-Type": "application/json"
|
|
188
|
-
}
|
|
217
|
+
"Content-Type": "application/json",
|
|
218
|
+
},
|
|
189
219
|
});
|
|
190
220
|
if (!response.ok) {
|
|
191
221
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
@@ -202,9 +232,9 @@ var mapApiSettingsToConfig = (apiSettings) => {
|
|
|
202
232
|
return null;
|
|
203
233
|
}
|
|
204
234
|
const buttonSizeMap = {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
235
|
+
small: "sm",
|
|
236
|
+
medium: "md",
|
|
237
|
+
large: "lg",
|
|
208
238
|
};
|
|
209
239
|
return {
|
|
210
240
|
welcomeMessage: apiSettings.welcome_message,
|
|
@@ -218,7 +248,7 @@ var mapApiSettingsToConfig = (apiSettings) => {
|
|
|
218
248
|
initialOpen: apiSettings.initial_open,
|
|
219
249
|
headerBackground: apiSettings.header_background,
|
|
220
250
|
companyLogo: apiSettings.company_logo || void 0,
|
|
221
|
-
companyName: apiSettings.company_name
|
|
251
|
+
companyName: apiSettings.company_name,
|
|
222
252
|
};
|
|
223
253
|
};
|
|
224
254
|
|
|
@@ -232,27 +262,29 @@ var getMessageBubbleStyles = (isUser) => ({
|
|
|
232
262
|
lineHeight: 1.4,
|
|
233
263
|
fontSize: "14px",
|
|
234
264
|
position: "relative",
|
|
235
|
-
...isUser
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
265
|
+
...(isUser
|
|
266
|
+
? {
|
|
267
|
+
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
268
|
+
color: "#ffffff",
|
|
269
|
+
marginLeft: "auto",
|
|
270
|
+
marginRight: "0",
|
|
271
|
+
}
|
|
272
|
+
: {
|
|
273
|
+
background: "#f8fafc",
|
|
274
|
+
color: "#334155",
|
|
275
|
+
border: "1px solid #e2e8f0",
|
|
276
|
+
marginLeft: "0",
|
|
277
|
+
marginRight: "auto",
|
|
278
|
+
}),
|
|
247
279
|
});
|
|
248
280
|
var getTimeStyles = (isUser) => ({
|
|
249
281
|
fontSize: "11px",
|
|
250
282
|
opacity: 0.7,
|
|
251
283
|
marginTop: "4px",
|
|
252
|
-
textAlign: isUser ? "right" : "left"
|
|
284
|
+
textAlign: isUser ? "right" : "left",
|
|
253
285
|
});
|
|
254
286
|
var getMarkdownStyles = () => ({
|
|
255
|
-
lineHeight: 1.6
|
|
287
|
+
lineHeight: 1.6,
|
|
256
288
|
});
|
|
257
289
|
var getMarkdownElementStyles = (isUser) => `
|
|
258
290
|
.markdown-content p {
|
|
@@ -413,7 +445,7 @@ var getMessageContainerStyles = (isUser) => ({
|
|
|
413
445
|
display: "flex",
|
|
414
446
|
flexDirection: "column",
|
|
415
447
|
alignItems: isUser ? "flex-end" : "flex-start",
|
|
416
|
-
width: "100%"
|
|
448
|
+
width: "100%",
|
|
417
449
|
});
|
|
418
450
|
|
|
419
451
|
// src/styles/inputStyles.ts
|
|
@@ -424,7 +456,7 @@ var getInputContainerStyles = () => ({
|
|
|
424
456
|
padding: "16px",
|
|
425
457
|
background: "#ffffff",
|
|
426
458
|
borderTop: "1px solid #e2e8f0",
|
|
427
|
-
borderRadius: "0 0 12px 12px"
|
|
459
|
+
borderRadius: "0 0 12px 12px",
|
|
428
460
|
});
|
|
429
461
|
var getTextareaStyles = (isLoading) => ({
|
|
430
462
|
flex: 1,
|
|
@@ -441,10 +473,12 @@ var getTextareaStyles = (isLoading) => ({
|
|
|
441
473
|
fontFamily: "inherit",
|
|
442
474
|
background: "#f8fafc",
|
|
443
475
|
color: "#334155",
|
|
444
|
-
...isLoading
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
476
|
+
...(isLoading
|
|
477
|
+
? {
|
|
478
|
+
opacity: 0.6,
|
|
479
|
+
cursor: "not-allowed",
|
|
480
|
+
}
|
|
481
|
+
: {}),
|
|
448
482
|
});
|
|
449
483
|
var getSendButtonStyles = (isLoading, hasMessage) => ({
|
|
450
484
|
width: "44px",
|
|
@@ -458,7 +492,7 @@ var getSendButtonStyles = (isLoading, hasMessage) => ({
|
|
|
458
492
|
alignItems: "center",
|
|
459
493
|
justifyContent: "center",
|
|
460
494
|
transition: "all 0.2s ease",
|
|
461
|
-
fontSize: "16px"
|
|
495
|
+
fontSize: "16px",
|
|
462
496
|
});
|
|
463
497
|
|
|
464
498
|
// src/styles/headerStyles.ts
|
|
@@ -468,7 +502,7 @@ var getHeaderStyles = (headerBackground) => ({
|
|
|
468
502
|
color: "#ffffff",
|
|
469
503
|
display: "flex",
|
|
470
504
|
alignItems: "center",
|
|
471
|
-
gap: "12px"
|
|
505
|
+
gap: "12px",
|
|
472
506
|
});
|
|
473
507
|
var getLogoContainerStyles = () => ({
|
|
474
508
|
width: "40px",
|
|
@@ -479,34 +513,34 @@ var getLogoContainerStyles = () => ({
|
|
|
479
513
|
alignItems: "center",
|
|
480
514
|
justifyContent: "center",
|
|
481
515
|
fontSize: "18px",
|
|
482
|
-
overflow: "hidden"
|
|
516
|
+
overflow: "hidden",
|
|
483
517
|
});
|
|
484
518
|
var getLogoImageStyles = () => ({
|
|
485
519
|
width: "100%",
|
|
486
520
|
height: "100%",
|
|
487
521
|
objectFit: "cover",
|
|
488
|
-
borderRadius: "50%"
|
|
522
|
+
borderRadius: "50%",
|
|
489
523
|
});
|
|
490
524
|
var getLogoTextStyles = () => ({
|
|
491
525
|
fontSize: "16px",
|
|
492
|
-
fontWeight: "bold"
|
|
526
|
+
fontWeight: "bold",
|
|
493
527
|
});
|
|
494
528
|
var getCompanyNameStyles = () => ({
|
|
495
529
|
margin: 0,
|
|
496
530
|
fontSize: "16px",
|
|
497
|
-
fontWeight: 600
|
|
531
|
+
fontWeight: 600,
|
|
498
532
|
});
|
|
499
533
|
var getStatusTextStyles = () => ({
|
|
500
534
|
margin: 0,
|
|
501
535
|
fontSize: "12px",
|
|
502
|
-
opacity: 0.8
|
|
536
|
+
opacity: 0.8,
|
|
503
537
|
});
|
|
504
538
|
|
|
505
539
|
// src/styles/containerStyles.ts
|
|
506
540
|
var getButtonSizes = () => ({
|
|
507
541
|
sm: { width: "50px", height: "50px", fontSize: "20px" },
|
|
508
542
|
md: { width: "60px", height: "60px", fontSize: "24px" },
|
|
509
|
-
lg: { width: "70px", height: "70px", fontSize: "28px" }
|
|
543
|
+
lg: { width: "70px", height: "70px", fontSize: "28px" },
|
|
510
544
|
});
|
|
511
545
|
var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isOpen) => {
|
|
512
546
|
const buttonSizes = getButtonSizes();
|
|
@@ -529,7 +563,7 @@ var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isO
|
|
|
529
563
|
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
530
564
|
transition: "all 0.3s ease",
|
|
531
565
|
zIndex: 1e3,
|
|
532
|
-
transform: isOpen ? "scale(0.9)" : "scale(1)"
|
|
566
|
+
transform: isOpen ? "scale(0.9)" : "scale(1)",
|
|
533
567
|
};
|
|
534
568
|
};
|
|
535
569
|
var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) => ({
|
|
@@ -543,7 +577,7 @@ var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) =>
|
|
|
543
577
|
opacity: isOpen ? 1 : 0,
|
|
544
578
|
visibility: isOpen ? "visible" : "hidden",
|
|
545
579
|
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
546
|
-
transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right"
|
|
580
|
+
transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right",
|
|
547
581
|
});
|
|
548
582
|
var getOverlayStyles = (isOpen) => ({
|
|
549
583
|
position: "fixed",
|
|
@@ -555,7 +589,7 @@ var getOverlayStyles = (isOpen) => ({
|
|
|
555
589
|
zIndex: 998,
|
|
556
590
|
opacity: isOpen ? 1 : 0,
|
|
557
591
|
visibility: isOpen ? "visible" : "hidden",
|
|
558
|
-
transition: "all 0.3s ease"
|
|
592
|
+
transition: "all 0.3s ease",
|
|
559
593
|
});
|
|
560
594
|
var getChatbotContainerStyles = () => ({
|
|
561
595
|
display: "flex",
|
|
@@ -565,7 +599,7 @@ var getChatbotContainerStyles = () => ({
|
|
|
565
599
|
borderRadius: "12px",
|
|
566
600
|
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
567
601
|
border: "1px solid #e2e8f0",
|
|
568
|
-
overflow: "hidden"
|
|
602
|
+
overflow: "hidden",
|
|
569
603
|
});
|
|
570
604
|
var getMessagesContainerStyles = () => ({
|
|
571
605
|
flex: 1,
|
|
@@ -574,7 +608,7 @@ var getMessagesContainerStyles = () => ({
|
|
|
574
608
|
display: "flex",
|
|
575
609
|
flexDirection: "column",
|
|
576
610
|
gap: "4px",
|
|
577
|
-
background: "#f8fafc"
|
|
611
|
+
background: "#f8fafc",
|
|
578
612
|
});
|
|
579
613
|
var getEmptyStateStyles = () => ({
|
|
580
614
|
display: "flex",
|
|
@@ -584,7 +618,7 @@ var getEmptyStateStyles = () => ({
|
|
|
584
618
|
height: "100%",
|
|
585
619
|
color: "#64748b",
|
|
586
620
|
textAlign: "center",
|
|
587
|
-
padding: "40px 20px"
|
|
621
|
+
padding: "40px 20px",
|
|
588
622
|
});
|
|
589
623
|
|
|
590
624
|
// src/styles/loadingStyles.ts
|
|
@@ -594,7 +628,7 @@ var getLoadingSpinnerStyles = () => ({
|
|
|
594
628
|
border: "2px solid transparent",
|
|
595
629
|
borderTop: "2px solid currentColor",
|
|
596
630
|
borderRadius: "50%",
|
|
597
|
-
animation: "spin 1s linear infinite"
|
|
631
|
+
animation: "spin 1s linear infinite",
|
|
598
632
|
});
|
|
599
633
|
var AizekChatBot = ({ clientId, userToken }) => {
|
|
600
634
|
const defaultConfig = {
|
|
@@ -609,7 +643,7 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
609
643
|
initialOpen: true,
|
|
610
644
|
headerBackground: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
611
645
|
companyLogo: void 0,
|
|
612
|
-
companyName: "AI Asistan"
|
|
646
|
+
companyName: "AI Asistan",
|
|
613
647
|
};
|
|
614
648
|
const [config, setConfig] = React.useState(defaultConfig);
|
|
615
649
|
const [isConfigLoading, setIsConfigLoading] = React.useState(true);
|
|
@@ -654,21 +688,38 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
654
688
|
}, [messages]);
|
|
655
689
|
const MessageBubble = ({ message }) => {
|
|
656
690
|
const isUser = message.role === "user";
|
|
657
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
691
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
692
|
+
style: getMessageContainerStyles(isUser),
|
|
693
|
+
children: [
|
|
694
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: getMarkdownElementStyles(isUser) }),
|
|
695
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
696
|
+
style: getMessageBubbleStyles(isUser),
|
|
697
|
+
children: [
|
|
698
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
699
|
+
style: getMarkdownStyles(),
|
|
700
|
+
className: "markdown-content",
|
|
701
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ReactMarkdown__default.default, { remarkPlugins: [remarkGfm__default.default], children: message.content }),
|
|
702
|
+
}),
|
|
703
|
+
message.isTyping &&
|
|
704
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
705
|
+
style: {
|
|
706
|
+
display: "inline-flex",
|
|
707
|
+
alignItems: "center",
|
|
708
|
+
marginLeft: "8px",
|
|
709
|
+
},
|
|
710
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(TypingDots, {}),
|
|
711
|
+
}),
|
|
712
|
+
],
|
|
713
|
+
}),
|
|
714
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
715
|
+
style: getTimeStyles(isUser),
|
|
716
|
+
children: message.timestamp.toLocaleTimeString("tr-TR", {
|
|
717
|
+
hour: "2-digit",
|
|
718
|
+
minute: "2-digit",
|
|
719
|
+
}),
|
|
720
|
+
}),
|
|
721
|
+
],
|
|
722
|
+
});
|
|
672
723
|
};
|
|
673
724
|
const TypingDots = () => {
|
|
674
725
|
const [dots, setDots] = React.useState("");
|
|
@@ -708,22 +759,20 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
708
759
|
textarea.style.height = "auto";
|
|
709
760
|
textarea.style.height = Math.min(textarea.scrollHeight, 120) + "px";
|
|
710
761
|
};
|
|
711
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("form", {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
762
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("form", {
|
|
763
|
+
onSubmit: handleSubmit,
|
|
764
|
+
style: getInputContainerStyles(),
|
|
765
|
+
children: [
|
|
766
|
+
/* @__PURE__ */ jsxRuntime.jsx("textarea", {
|
|
715
767
|
ref: textareaRef,
|
|
716
768
|
value: message,
|
|
717
769
|
onChange: handleInputChange,
|
|
718
770
|
onKeyDown: handleKeyDown,
|
|
719
771
|
placeholder,
|
|
720
772
|
disabled: isLoading,
|
|
721
|
-
style: getTextareaStyles(isLoading)
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
725
|
-
"button",
|
|
726
|
-
{
|
|
773
|
+
style: getTextareaStyles(isLoading),
|
|
774
|
+
}),
|
|
775
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", {
|
|
727
776
|
type: "submit",
|
|
728
777
|
disabled: isLoading || !message.trim(),
|
|
729
778
|
style: getSendButtonStyles(isLoading, !!message.trim()),
|
|
@@ -735,10 +784,12 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
735
784
|
onMouseLeave: (e) => {
|
|
736
785
|
e.currentTarget.style.transform = "scale(1)";
|
|
737
786
|
},
|
|
738
|
-
children: isLoading
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
787
|
+
children: isLoading
|
|
788
|
+
? /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, {})
|
|
789
|
+
: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }) }),
|
|
790
|
+
}),
|
|
791
|
+
],
|
|
792
|
+
});
|
|
742
793
|
};
|
|
743
794
|
const LoadingSpinner = () => {
|
|
744
795
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: getLoadingSpinnerStyles() });
|
|
@@ -746,55 +797,76 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
746
797
|
if (isConfigLoading) {
|
|
747
798
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, false), children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: getLoadingSpinnerStyles() }) });
|
|
748
799
|
}
|
|
749
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
/* @__PURE__ */ jsxRuntime.
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
800
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
801
|
+
children: [
|
|
802
|
+
isOpen &&
|
|
803
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
804
|
+
style: getOverlayStyles(isOpen),
|
|
805
|
+
onClick: toggleChat,
|
|
806
|
+
className: "floating-chat-overlay",
|
|
807
|
+
}),
|
|
808
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
809
|
+
style: getChatContainerStyles(buttonPosition, chatWidth, chatHeight, isOpen),
|
|
810
|
+
className: "floating-chat-container",
|
|
811
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
812
|
+
style: getChatbotContainerStyles(),
|
|
813
|
+
children: [
|
|
814
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
815
|
+
style: getHeaderStyles(headerBackground),
|
|
816
|
+
children: [
|
|
817
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
818
|
+
style: getLogoContainerStyles(),
|
|
819
|
+
children: companyLogo
|
|
820
|
+
? companyLogo.startsWith("http") || companyLogo.startsWith("data:")
|
|
821
|
+
? /* @__PURE__ */ jsxRuntime.jsx("img", {
|
|
822
|
+
src: companyLogo,
|
|
823
|
+
alt: "Company Logo",
|
|
824
|
+
style: getLogoImageStyles(),
|
|
825
|
+
})
|
|
826
|
+
: /* @__PURE__ */ jsxRuntime.jsx("span", { style: getLogoTextStyles(), children: companyLogo })
|
|
827
|
+
: "\u{1F916}",
|
|
828
|
+
}),
|
|
829
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
830
|
+
children: [
|
|
831
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: getCompanyNameStyles(), children: companyName }),
|
|
832
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: getStatusTextStyles(), children: isLoading ? "Yaz\u0131yor..." : "\xC7evrimi\xE7i" }),
|
|
833
|
+
],
|
|
834
|
+
}),
|
|
835
|
+
],
|
|
836
|
+
}),
|
|
837
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
838
|
+
style: getMessagesContainerStyles(),
|
|
839
|
+
children: [
|
|
840
|
+
messages.length === 0
|
|
841
|
+
? /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
842
|
+
style: getEmptyStateStyles(),
|
|
843
|
+
children: [
|
|
844
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "\u{1F4AC}" }),
|
|
845
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: { margin: "0 0 8px 0", fontSize: "18px" }, children: welcomeMessage }),
|
|
846
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "14px", opacity: 0.8 }, children: "A\u015Fa\u011F\u0131daki alana mesaj\u0131n\u0131z\u0131 yazarak ba\u015Flayabilirsiniz." }),
|
|
847
|
+
],
|
|
848
|
+
})
|
|
849
|
+
: messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { message }, message.id)),
|
|
850
|
+
showTypingIndicator &&
|
|
851
|
+
isLoading &&
|
|
852
|
+
messages.length > 0 &&
|
|
853
|
+
/* @__PURE__ */ jsxRuntime.jsx(MessageBubble, {
|
|
854
|
+
message: {
|
|
855
|
+
id: "typing",
|
|
856
|
+
content: "",
|
|
857
|
+
role: "assistant",
|
|
858
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
859
|
+
isTyping: true,
|
|
860
|
+
},
|
|
861
|
+
}),
|
|
862
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef }),
|
|
863
|
+
],
|
|
864
|
+
}),
|
|
865
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChatInput, {}),
|
|
866
|
+
],
|
|
867
|
+
}),
|
|
868
|
+
}),
|
|
869
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", {
|
|
798
870
|
onClick: toggleChat,
|
|
799
871
|
style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, isOpen),
|
|
800
872
|
onMouseEnter: (e) => {
|
|
@@ -807,14 +879,28 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
807
879
|
},
|
|
808
880
|
className: "floating-chat-button",
|
|
809
881
|
"aria-label": isOpen ? "Chati kapat" : "Chati a\xE7",
|
|
810
|
-
children: isOpen
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
882
|
+
children: isOpen
|
|
883
|
+
? /* @__PURE__ */ jsxRuntime.jsx("svg", {
|
|
884
|
+
width: "24",
|
|
885
|
+
height: "24",
|
|
886
|
+
viewBox: "0 0 24 24",
|
|
887
|
+
fill: "currentColor",
|
|
888
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }),
|
|
889
|
+
})
|
|
890
|
+
: /* @__PURE__ */ jsxRuntime.jsx("svg", {
|
|
891
|
+
width: "24",
|
|
892
|
+
height: "24",
|
|
893
|
+
viewBox: "0 0 24 24",
|
|
894
|
+
fill: "currentColor",
|
|
895
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4l4 4 4-4h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z" }),
|
|
896
|
+
}),
|
|
897
|
+
}),
|
|
898
|
+
],
|
|
899
|
+
});
|
|
814
900
|
};
|
|
815
901
|
|
|
816
902
|
exports.AizekChatBot = AizekChatBot;
|
|
817
903
|
exports.Button = Button;
|
|
818
904
|
exports.useChatbot = useChatbot;
|
|
819
905
|
//# sourceMappingURL=index.cjs.map
|
|
820
|
-
//# sourceMappingURL=index.cjs.map
|
|
906
|
+
//# sourceMappingURL=index.cjs.map
|