aizek-chatbot 1.0.2 → 1.0.4
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 +273 -190
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +246 -180
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -3
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useState, useEffect, useRef } from "react";
|
|
4
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
|
+
import OpenAI from "openai";
|
|
6
|
+
import ReactMarkdown from "react-markdown";
|
|
7
|
+
import remarkGfm from "remark-gfm";
|
|
7
8
|
|
|
8
9
|
// src/utils/cx.ts
|
|
9
10
|
function cx(...args) {
|
|
@@ -18,18 +19,18 @@ var base = {
|
|
|
18
19
|
lineHeight: 1,
|
|
19
20
|
transition: "background-color .2s ease, color .2s ease, border-color .2s ease",
|
|
20
21
|
outline: "none",
|
|
21
|
-
cursor: "pointer"
|
|
22
|
+
cursor: "pointer",
|
|
22
23
|
};
|
|
23
24
|
var sizes = {
|
|
24
25
|
sm: { height: 36, padding: "0 12px", fontSize: 14 },
|
|
25
26
|
md: { height: 40, padding: "0 16px", fontSize: 16 },
|
|
26
|
-
lg: { height: 44, padding: "0 20px", fontSize: 18 }
|
|
27
|
+
lg: { height: 44, padding: "0 20px", fontSize: 18 },
|
|
27
28
|
};
|
|
28
29
|
var palette = {
|
|
29
30
|
brand: {
|
|
30
31
|
primary: "#2563eb",
|
|
31
|
-
primaryHover: "#1d4ed8"
|
|
32
|
-
}
|
|
32
|
+
primaryHover: "#1d4ed8",
|
|
33
|
+
},
|
|
33
34
|
};
|
|
34
35
|
function styleFor(variant) {
|
|
35
36
|
switch (variant) {
|
|
@@ -37,45 +38,45 @@ function styleFor(variant) {
|
|
|
37
38
|
return {
|
|
38
39
|
background: "transparent",
|
|
39
40
|
color: palette.brand.primary,
|
|
40
|
-
border: `1px solid ${palette.brand.primary}
|
|
41
|
+
border: `1px solid ${palette.brand.primary}`,
|
|
41
42
|
};
|
|
42
43
|
case "ghost":
|
|
43
44
|
return {
|
|
44
45
|
background: "transparent",
|
|
45
46
|
color: palette.brand.primary,
|
|
46
|
-
border: "1px solid transparent"
|
|
47
|
+
border: "1px solid transparent",
|
|
47
48
|
};
|
|
48
49
|
default:
|
|
49
50
|
return {
|
|
50
51
|
background: palette.brand.primary,
|
|
51
52
|
color: "#fff",
|
|
52
|
-
border: "1px solid transparent"
|
|
53
|
+
border: "1px solid transparent",
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
var Button = React.forwardRef(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
);
|
|
57
|
+
var Button = React.forwardRef(({ variant = "primary", size = "md", style, className, onMouseEnter, onMouseLeave, ...props }, ref) => {
|
|
58
|
+
const [hover, setHover] = React.useState(false);
|
|
59
|
+
const hoverStyle =
|
|
60
|
+
variant === "primary"
|
|
61
|
+
? { background: hover ? palette.brand.primaryHover : palette.brand.primary }
|
|
62
|
+
: variant === "outline"
|
|
63
|
+
? { borderColor: hover ? palette.brand.primaryHover : palette.brand.primary }
|
|
64
|
+
: { background: hover ? "rgba(37, 99, 235, 0.08)" : "transparent" };
|
|
65
|
+
return /* @__PURE__ */ jsx("button", {
|
|
66
|
+
ref,
|
|
67
|
+
className: cx("rui-btn", className),
|
|
68
|
+
style: { ...base, ...sizes[size], ...styleFor(variant), ...(hover ? hoverStyle : {}), ...style },
|
|
69
|
+
onMouseEnter: (e) => {
|
|
70
|
+
setHover(true);
|
|
71
|
+
onMouseEnter?.(e);
|
|
72
|
+
},
|
|
73
|
+
onMouseLeave: (e) => {
|
|
74
|
+
setHover(false);
|
|
75
|
+
onMouseLeave?.(e);
|
|
76
|
+
},
|
|
77
|
+
...props,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
79
80
|
Button.displayName = "Button";
|
|
80
81
|
var useChatbot = (options = {}) => {
|
|
81
82
|
const { mcpUrl, apiKey } = options;
|
|
@@ -91,7 +92,7 @@ var useChatbot = (options = {}) => {
|
|
|
91
92
|
id: generateId(),
|
|
92
93
|
content,
|
|
93
94
|
role,
|
|
94
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
95
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
95
96
|
};
|
|
96
97
|
setMessages((prev) => [...prev, newMessage]);
|
|
97
98
|
return newMessage;
|
|
@@ -101,23 +102,39 @@ var useChatbot = (options = {}) => {
|
|
|
101
102
|
addMessage(message, "user");
|
|
102
103
|
setIsLoading(true);
|
|
103
104
|
try {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
105
|
+
let resp;
|
|
106
|
+
if (options.userToken) {
|
|
107
|
+
resp = await client.responses.create({
|
|
108
|
+
model: "gpt-5",
|
|
109
|
+
tools: [
|
|
110
|
+
{
|
|
111
|
+
type: "mcp",
|
|
112
|
+
server_label: "aizek-mcp",
|
|
113
|
+
server_url: mcpUrl,
|
|
114
|
+
require_approval: "never",
|
|
115
|
+
headers: {
|
|
116
|
+
Authorization: `Bearer ${options.userToken}`,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
input: message,
|
|
121
|
+
previous_response_id: responseId || void 0,
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
resp = await client.responses.create({
|
|
125
|
+
model: "gpt-5",
|
|
126
|
+
tools: [
|
|
127
|
+
{
|
|
128
|
+
type: "mcp",
|
|
129
|
+
server_label: "aizek-mcp",
|
|
130
|
+
server_url: mcpUrl,
|
|
131
|
+
require_approval: "never",
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
input: message,
|
|
135
|
+
previous_response_id: responseId || void 0,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
121
138
|
setResponseId(resp.id);
|
|
122
139
|
let responseText = "";
|
|
123
140
|
if (resp && Array.isArray(resp)) {
|
|
@@ -150,7 +167,7 @@ var useChatbot = (options = {}) => {
|
|
|
150
167
|
messages,
|
|
151
168
|
isLoading,
|
|
152
169
|
sendMessage,
|
|
153
|
-
addMessage
|
|
170
|
+
addMessage,
|
|
154
171
|
};
|
|
155
172
|
};
|
|
156
173
|
|
|
@@ -161,8 +178,8 @@ var fetchChatWidgetSettings = async (clientId) => {
|
|
|
161
178
|
const response = await fetch(`${API_BASE_URL}/ChatWidgetSettings/GetByClientId?client_id=${clientId}`, {
|
|
162
179
|
method: "GET",
|
|
163
180
|
headers: {
|
|
164
|
-
"Content-Type": "application/json"
|
|
165
|
-
}
|
|
181
|
+
"Content-Type": "application/json",
|
|
182
|
+
},
|
|
166
183
|
});
|
|
167
184
|
if (!response.ok) {
|
|
168
185
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
@@ -179,9 +196,9 @@ var mapApiSettingsToConfig = (apiSettings) => {
|
|
|
179
196
|
return null;
|
|
180
197
|
}
|
|
181
198
|
const buttonSizeMap = {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
199
|
+
small: "sm",
|
|
200
|
+
medium: "md",
|
|
201
|
+
large: "lg",
|
|
185
202
|
};
|
|
186
203
|
return {
|
|
187
204
|
welcomeMessage: apiSettings.welcome_message,
|
|
@@ -195,7 +212,7 @@ var mapApiSettingsToConfig = (apiSettings) => {
|
|
|
195
212
|
initialOpen: apiSettings.initial_open,
|
|
196
213
|
headerBackground: apiSettings.header_background,
|
|
197
214
|
companyLogo: apiSettings.company_logo || void 0,
|
|
198
|
-
companyName: apiSettings.company_name
|
|
215
|
+
companyName: apiSettings.company_name,
|
|
199
216
|
};
|
|
200
217
|
};
|
|
201
218
|
|
|
@@ -209,27 +226,29 @@ var getMessageBubbleStyles = (isUser) => ({
|
|
|
209
226
|
lineHeight: 1.4,
|
|
210
227
|
fontSize: "14px",
|
|
211
228
|
position: "relative",
|
|
212
|
-
...isUser
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
229
|
+
...(isUser
|
|
230
|
+
? {
|
|
231
|
+
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
232
|
+
color: "#ffffff",
|
|
233
|
+
marginLeft: "auto",
|
|
234
|
+
marginRight: "0",
|
|
235
|
+
}
|
|
236
|
+
: {
|
|
237
|
+
background: "#f8fafc",
|
|
238
|
+
color: "#334155",
|
|
239
|
+
border: "1px solid #e2e8f0",
|
|
240
|
+
marginLeft: "0",
|
|
241
|
+
marginRight: "auto",
|
|
242
|
+
}),
|
|
224
243
|
});
|
|
225
244
|
var getTimeStyles = (isUser) => ({
|
|
226
245
|
fontSize: "11px",
|
|
227
246
|
opacity: 0.7,
|
|
228
247
|
marginTop: "4px",
|
|
229
|
-
textAlign: isUser ? "right" : "left"
|
|
248
|
+
textAlign: isUser ? "right" : "left",
|
|
230
249
|
});
|
|
231
250
|
var getMarkdownStyles = () => ({
|
|
232
|
-
lineHeight: 1.6
|
|
251
|
+
lineHeight: 1.6,
|
|
233
252
|
});
|
|
234
253
|
var getMarkdownElementStyles = (isUser) => `
|
|
235
254
|
.markdown-content p {
|
|
@@ -390,7 +409,7 @@ var getMessageContainerStyles = (isUser) => ({
|
|
|
390
409
|
display: "flex",
|
|
391
410
|
flexDirection: "column",
|
|
392
411
|
alignItems: isUser ? "flex-end" : "flex-start",
|
|
393
|
-
width: "100%"
|
|
412
|
+
width: "100%",
|
|
394
413
|
});
|
|
395
414
|
|
|
396
415
|
// src/styles/inputStyles.ts
|
|
@@ -401,7 +420,7 @@ var getInputContainerStyles = () => ({
|
|
|
401
420
|
padding: "16px",
|
|
402
421
|
background: "#ffffff",
|
|
403
422
|
borderTop: "1px solid #e2e8f0",
|
|
404
|
-
borderRadius: "0 0 12px 12px"
|
|
423
|
+
borderRadius: "0 0 12px 12px",
|
|
405
424
|
});
|
|
406
425
|
var getTextareaStyles = (isLoading) => ({
|
|
407
426
|
flex: 1,
|
|
@@ -418,10 +437,12 @@ var getTextareaStyles = (isLoading) => ({
|
|
|
418
437
|
fontFamily: "inherit",
|
|
419
438
|
background: "#f8fafc",
|
|
420
439
|
color: "#334155",
|
|
421
|
-
...isLoading
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
440
|
+
...(isLoading
|
|
441
|
+
? {
|
|
442
|
+
opacity: 0.6,
|
|
443
|
+
cursor: "not-allowed",
|
|
444
|
+
}
|
|
445
|
+
: {}),
|
|
425
446
|
});
|
|
426
447
|
var getSendButtonStyles = (isLoading, hasMessage) => ({
|
|
427
448
|
width: "44px",
|
|
@@ -435,7 +456,7 @@ var getSendButtonStyles = (isLoading, hasMessage) => ({
|
|
|
435
456
|
alignItems: "center",
|
|
436
457
|
justifyContent: "center",
|
|
437
458
|
transition: "all 0.2s ease",
|
|
438
|
-
fontSize: "16px"
|
|
459
|
+
fontSize: "16px",
|
|
439
460
|
});
|
|
440
461
|
|
|
441
462
|
// src/styles/headerStyles.ts
|
|
@@ -445,7 +466,7 @@ var getHeaderStyles = (headerBackground) => ({
|
|
|
445
466
|
color: "#ffffff",
|
|
446
467
|
display: "flex",
|
|
447
468
|
alignItems: "center",
|
|
448
|
-
gap: "12px"
|
|
469
|
+
gap: "12px",
|
|
449
470
|
});
|
|
450
471
|
var getLogoContainerStyles = () => ({
|
|
451
472
|
width: "40px",
|
|
@@ -456,34 +477,34 @@ var getLogoContainerStyles = () => ({
|
|
|
456
477
|
alignItems: "center",
|
|
457
478
|
justifyContent: "center",
|
|
458
479
|
fontSize: "18px",
|
|
459
|
-
overflow: "hidden"
|
|
480
|
+
overflow: "hidden",
|
|
460
481
|
});
|
|
461
482
|
var getLogoImageStyles = () => ({
|
|
462
483
|
width: "100%",
|
|
463
484
|
height: "100%",
|
|
464
485
|
objectFit: "cover",
|
|
465
|
-
borderRadius: "50%"
|
|
486
|
+
borderRadius: "50%",
|
|
466
487
|
});
|
|
467
488
|
var getLogoTextStyles = () => ({
|
|
468
489
|
fontSize: "16px",
|
|
469
|
-
fontWeight: "bold"
|
|
490
|
+
fontWeight: "bold",
|
|
470
491
|
});
|
|
471
492
|
var getCompanyNameStyles = () => ({
|
|
472
493
|
margin: 0,
|
|
473
494
|
fontSize: "16px",
|
|
474
|
-
fontWeight: 600
|
|
495
|
+
fontWeight: 600,
|
|
475
496
|
});
|
|
476
497
|
var getStatusTextStyles = () => ({
|
|
477
498
|
margin: 0,
|
|
478
499
|
fontSize: "12px",
|
|
479
|
-
opacity: 0.8
|
|
500
|
+
opacity: 0.8,
|
|
480
501
|
});
|
|
481
502
|
|
|
482
503
|
// src/styles/containerStyles.ts
|
|
483
504
|
var getButtonSizes = () => ({
|
|
484
505
|
sm: { width: "50px", height: "50px", fontSize: "20px" },
|
|
485
506
|
md: { width: "60px", height: "60px", fontSize: "24px" },
|
|
486
|
-
lg: { width: "70px", height: "70px", fontSize: "28px" }
|
|
507
|
+
lg: { width: "70px", height: "70px", fontSize: "28px" },
|
|
487
508
|
});
|
|
488
509
|
var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isOpen) => {
|
|
489
510
|
const buttonSizes = getButtonSizes();
|
|
@@ -506,7 +527,7 @@ var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isO
|
|
|
506
527
|
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
507
528
|
transition: "all 0.3s ease",
|
|
508
529
|
zIndex: 1e3,
|
|
509
|
-
transform: isOpen ? "scale(0.9)" : "scale(1)"
|
|
530
|
+
transform: isOpen ? "scale(0.9)" : "scale(1)",
|
|
510
531
|
};
|
|
511
532
|
};
|
|
512
533
|
var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) => ({
|
|
@@ -520,7 +541,7 @@ var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) =>
|
|
|
520
541
|
opacity: isOpen ? 1 : 0,
|
|
521
542
|
visibility: isOpen ? "visible" : "hidden",
|
|
522
543
|
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
523
|
-
transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right"
|
|
544
|
+
transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right",
|
|
524
545
|
});
|
|
525
546
|
var getOverlayStyles = (isOpen) => ({
|
|
526
547
|
position: "fixed",
|
|
@@ -532,7 +553,7 @@ var getOverlayStyles = (isOpen) => ({
|
|
|
532
553
|
zIndex: 998,
|
|
533
554
|
opacity: isOpen ? 1 : 0,
|
|
534
555
|
visibility: isOpen ? "visible" : "hidden",
|
|
535
|
-
transition: "all 0.3s ease"
|
|
556
|
+
transition: "all 0.3s ease",
|
|
536
557
|
});
|
|
537
558
|
var getChatbotContainerStyles = () => ({
|
|
538
559
|
display: "flex",
|
|
@@ -542,7 +563,7 @@ var getChatbotContainerStyles = () => ({
|
|
|
542
563
|
borderRadius: "12px",
|
|
543
564
|
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
544
565
|
border: "1px solid #e2e8f0",
|
|
545
|
-
overflow: "hidden"
|
|
566
|
+
overflow: "hidden",
|
|
546
567
|
});
|
|
547
568
|
var getMessagesContainerStyles = () => ({
|
|
548
569
|
flex: 1,
|
|
@@ -551,7 +572,7 @@ var getMessagesContainerStyles = () => ({
|
|
|
551
572
|
display: "flex",
|
|
552
573
|
flexDirection: "column",
|
|
553
574
|
gap: "4px",
|
|
554
|
-
background: "#f8fafc"
|
|
575
|
+
background: "#f8fafc",
|
|
555
576
|
});
|
|
556
577
|
var getEmptyStateStyles = () => ({
|
|
557
578
|
display: "flex",
|
|
@@ -561,7 +582,7 @@ var getEmptyStateStyles = () => ({
|
|
|
561
582
|
height: "100%",
|
|
562
583
|
color: "#64748b",
|
|
563
584
|
textAlign: "center",
|
|
564
|
-
padding: "40px 20px"
|
|
585
|
+
padding: "40px 20px",
|
|
565
586
|
});
|
|
566
587
|
|
|
567
588
|
// src/styles/loadingStyles.ts
|
|
@@ -571,7 +592,7 @@ var getLoadingSpinnerStyles = () => ({
|
|
|
571
592
|
border: "2px solid transparent",
|
|
572
593
|
borderTop: "2px solid currentColor",
|
|
573
594
|
borderRadius: "50%",
|
|
574
|
-
animation: "spin 1s linear infinite"
|
|
595
|
+
animation: "spin 1s linear infinite",
|
|
575
596
|
});
|
|
576
597
|
var AizekChatBot = ({ clientId, userToken }) => {
|
|
577
598
|
const defaultConfig = {
|
|
@@ -586,7 +607,7 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
586
607
|
initialOpen: true,
|
|
587
608
|
headerBackground: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
588
609
|
companyLogo: void 0,
|
|
589
|
-
companyName: "AI Asistan"
|
|
610
|
+
companyName: "AI Asistan",
|
|
590
611
|
};
|
|
591
612
|
const [config, setConfig] = useState(defaultConfig);
|
|
592
613
|
const [isConfigLoading, setIsConfigLoading] = useState(true);
|
|
@@ -631,21 +652,34 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
631
652
|
}, [messages]);
|
|
632
653
|
const MessageBubble = ({ message }) => {
|
|
633
654
|
const isUser = message.role === "user";
|
|
634
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
/* @__PURE__ */ jsx("
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
655
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
656
|
+
style: getMessageContainerStyles(isUser),
|
|
657
|
+
children: [
|
|
658
|
+
/* @__PURE__ */ jsx("style", { children: getMarkdownElementStyles(isUser) }),
|
|
659
|
+
/* @__PURE__ */ jsxs("div", {
|
|
660
|
+
style: getMessageBubbleStyles(isUser),
|
|
661
|
+
children: [
|
|
662
|
+
/* @__PURE__ */ jsx("div", { style: getMarkdownStyles(), className: "markdown-content", children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.content }) }),
|
|
663
|
+
message.isTyping &&
|
|
664
|
+
/* @__PURE__ */ jsx("div", {
|
|
665
|
+
style: {
|
|
666
|
+
display: "inline-flex",
|
|
667
|
+
alignItems: "center",
|
|
668
|
+
marginLeft: "8px",
|
|
669
|
+
},
|
|
670
|
+
children: /* @__PURE__ */ jsx(TypingDots, {}),
|
|
671
|
+
}),
|
|
672
|
+
],
|
|
673
|
+
}),
|
|
674
|
+
/* @__PURE__ */ jsx("div", {
|
|
675
|
+
style: getTimeStyles(isUser),
|
|
676
|
+
children: message.timestamp.toLocaleTimeString("tr-TR", {
|
|
677
|
+
hour: "2-digit",
|
|
678
|
+
minute: "2-digit",
|
|
679
|
+
}),
|
|
680
|
+
}),
|
|
681
|
+
],
|
|
682
|
+
});
|
|
649
683
|
};
|
|
650
684
|
const TypingDots = () => {
|
|
651
685
|
const [dots, setDots] = useState("");
|
|
@@ -685,22 +719,20 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
685
719
|
textarea.style.height = "auto";
|
|
686
720
|
textarea.style.height = Math.min(textarea.scrollHeight, 120) + "px";
|
|
687
721
|
};
|
|
688
|
-
return /* @__PURE__ */ jsxs("form", {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
722
|
+
return /* @__PURE__ */ jsxs("form", {
|
|
723
|
+
onSubmit: handleSubmit,
|
|
724
|
+
style: getInputContainerStyles(),
|
|
725
|
+
children: [
|
|
726
|
+
/* @__PURE__ */ jsx("textarea", {
|
|
692
727
|
ref: textareaRef,
|
|
693
728
|
value: message,
|
|
694
729
|
onChange: handleInputChange,
|
|
695
730
|
onKeyDown: handleKeyDown,
|
|
696
731
|
placeholder,
|
|
697
732
|
disabled: isLoading,
|
|
698
|
-
style: getTextareaStyles(isLoading)
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/* @__PURE__ */ jsx(
|
|
702
|
-
"button",
|
|
703
|
-
{
|
|
733
|
+
style: getTextareaStyles(isLoading),
|
|
734
|
+
}),
|
|
735
|
+
/* @__PURE__ */ jsx("button", {
|
|
704
736
|
type: "submit",
|
|
705
737
|
disabled: isLoading || !message.trim(),
|
|
706
738
|
style: getSendButtonStyles(isLoading, !!message.trim()),
|
|
@@ -712,10 +744,12 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
712
744
|
onMouseLeave: (e) => {
|
|
713
745
|
e.currentTarget.style.transform = "scale(1)";
|
|
714
746
|
},
|
|
715
|
-
children: isLoading
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
747
|
+
children: isLoading
|
|
748
|
+
? /* @__PURE__ */ jsx(LoadingSpinner, {})
|
|
749
|
+
: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }) }),
|
|
750
|
+
}),
|
|
751
|
+
],
|
|
752
|
+
});
|
|
719
753
|
};
|
|
720
754
|
const LoadingSpinner = () => {
|
|
721
755
|
return /* @__PURE__ */ jsx("div", { style: getLoadingSpinnerStyles() });
|
|
@@ -723,55 +757,73 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
723
757
|
if (isConfigLoading) {
|
|
724
758
|
return /* @__PURE__ */ jsx("div", { style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, false), children: /* @__PURE__ */ jsx("div", { style: getLoadingSpinnerStyles() }) });
|
|
725
759
|
}
|
|
726
|
-
return /* @__PURE__ */ jsxs(Fragment, {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
/* @__PURE__ */
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
760
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
761
|
+
children: [
|
|
762
|
+
isOpen &&
|
|
763
|
+
/* @__PURE__ */ jsx("div", {
|
|
764
|
+
style: getOverlayStyles(isOpen),
|
|
765
|
+
onClick: toggleChat,
|
|
766
|
+
className: "floating-chat-overlay",
|
|
767
|
+
}),
|
|
768
|
+
/* @__PURE__ */ jsx("div", {
|
|
769
|
+
style: getChatContainerStyles(buttonPosition, chatWidth, chatHeight, isOpen),
|
|
770
|
+
className: "floating-chat-container",
|
|
771
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
772
|
+
style: getChatbotContainerStyles(),
|
|
773
|
+
children: [
|
|
774
|
+
/* @__PURE__ */ jsxs("div", {
|
|
775
|
+
style: getHeaderStyles(headerBackground),
|
|
776
|
+
children: [
|
|
777
|
+
/* @__PURE__ */ jsx("div", {
|
|
778
|
+
style: getLogoContainerStyles(),
|
|
779
|
+
children: companyLogo
|
|
780
|
+
? companyLogo.startsWith("http") || companyLogo.startsWith("data:")
|
|
781
|
+
? /* @__PURE__ */ jsx("img", {
|
|
782
|
+
src: companyLogo,
|
|
783
|
+
alt: "Company Logo",
|
|
784
|
+
style: getLogoImageStyles(),
|
|
785
|
+
})
|
|
786
|
+
: /* @__PURE__ */ jsx("span", { style: getLogoTextStyles(), children: companyLogo })
|
|
787
|
+
: "\u{1F916}",
|
|
788
|
+
}),
|
|
789
|
+
/* @__PURE__ */ jsxs("div", {
|
|
790
|
+
children: [/* @__PURE__ */ jsx("h3", { style: getCompanyNameStyles(), children: companyName }), /* @__PURE__ */ jsx("p", { style: getStatusTextStyles(), children: isLoading ? "Yaz\u0131yor..." : "\xC7evrimi\xE7i" })],
|
|
791
|
+
}),
|
|
792
|
+
],
|
|
793
|
+
}),
|
|
794
|
+
/* @__PURE__ */ jsxs("div", {
|
|
795
|
+
style: getMessagesContainerStyles(),
|
|
796
|
+
children: [
|
|
797
|
+
messages.length === 0
|
|
798
|
+
? /* @__PURE__ */ jsxs("div", {
|
|
799
|
+
style: getEmptyStateStyles(),
|
|
800
|
+
children: [
|
|
801
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "\u{1F4AC}" }),
|
|
802
|
+
/* @__PURE__ */ jsx("h4", { style: { margin: "0 0 8px 0", fontSize: "18px" }, children: welcomeMessage }),
|
|
803
|
+
/* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "14px", opacity: 0.8 }, children: "A\u015Fa\u011F\u0131daki alana mesaj\u0131n\u0131z\u0131 yazarak ba\u015Flayabilirsiniz." }),
|
|
804
|
+
],
|
|
805
|
+
})
|
|
806
|
+
: messages.map((message) => /* @__PURE__ */ jsx(MessageBubble, { message }, message.id)),
|
|
807
|
+
showTypingIndicator &&
|
|
808
|
+
isLoading &&
|
|
809
|
+
messages.length > 0 &&
|
|
810
|
+
/* @__PURE__ */ jsx(MessageBubble, {
|
|
811
|
+
message: {
|
|
812
|
+
id: "typing",
|
|
813
|
+
content: "",
|
|
814
|
+
role: "assistant",
|
|
815
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
816
|
+
isTyping: true,
|
|
817
|
+
},
|
|
818
|
+
}),
|
|
819
|
+
/* @__PURE__ */ jsx("div", { ref: messagesEndRef }),
|
|
820
|
+
],
|
|
821
|
+
}),
|
|
822
|
+
/* @__PURE__ */ jsx(ChatInput, {}),
|
|
823
|
+
],
|
|
824
|
+
}),
|
|
825
|
+
}),
|
|
826
|
+
/* @__PURE__ */ jsx("button", {
|
|
775
827
|
onClick: toggleChat,
|
|
776
828
|
style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, isOpen),
|
|
777
829
|
onMouseEnter: (e) => {
|
|
@@ -784,12 +836,26 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
784
836
|
},
|
|
785
837
|
className: "floating-chat-button",
|
|
786
838
|
"aria-label": isOpen ? "Chati kapat" : "Chati a\xE7",
|
|
787
|
-
children: isOpen
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
839
|
+
children: isOpen
|
|
840
|
+
? /* @__PURE__ */ jsx("svg", {
|
|
841
|
+
width: "24",
|
|
842
|
+
height: "24",
|
|
843
|
+
viewBox: "0 0 24 24",
|
|
844
|
+
fill: "currentColor",
|
|
845
|
+
children: /* @__PURE__ */ 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" }),
|
|
846
|
+
})
|
|
847
|
+
: /* @__PURE__ */ jsx("svg", {
|
|
848
|
+
width: "24",
|
|
849
|
+
height: "24",
|
|
850
|
+
viewBox: "0 0 24 24",
|
|
851
|
+
fill: "currentColor",
|
|
852
|
+
children: /* @__PURE__ */ 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" }),
|
|
853
|
+
}),
|
|
854
|
+
}),
|
|
855
|
+
],
|
|
856
|
+
});
|
|
791
857
|
};
|
|
792
858
|
|
|
793
859
|
export { AizekChatBot, Button, useChatbot };
|
|
794
860
|
//# sourceMappingURL=index.mjs.map
|
|
795
|
-
//# sourceMappingURL=index.mjs.map
|
|
861
|
+
//# sourceMappingURL=index.mjs.map
|