aizek-chatbot 1.0.4 → 1.0.6
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 +184 -245
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +174 -218
- package/dist/index.mjs.map +1 -1
- package/package.json +46 -46
package/dist/index.cjs
CHANGED
|
@@ -1,35 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
1
|
+
'use strict';
|
|
3
2
|
|
|
4
|
-
var React = require(
|
|
5
|
-
var jsxRuntime = require(
|
|
6
|
-
var OpenAI = require(
|
|
7
|
-
var ReactMarkdown = require(
|
|
8
|
-
var remarkGfm = require(
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var OpenAI = require('openai');
|
|
6
|
+
var ReactMarkdown = require('react-markdown');
|
|
7
|
+
var remarkGfm = require('remark-gfm');
|
|
9
8
|
|
|
10
|
-
function _interopDefault(e) {
|
|
11
|
-
return e && e.__esModule ? e : { default: e };
|
|
12
|
-
}
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
10
|
|
|
14
11
|
function _interopNamespace(e) {
|
|
15
12
|
if (e && e.__esModule) return e;
|
|
16
13
|
var n = Object.create(null);
|
|
17
14
|
if (e) {
|
|
18
15
|
Object.keys(e).forEach(function (k) {
|
|
19
|
-
if (k !==
|
|
16
|
+
if (k !== 'default') {
|
|
20
17
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
-
Object.defineProperty(
|
|
22
|
-
|
|
23
|
-
k
|
|
24
|
-
|
|
25
|
-
? d
|
|
26
|
-
: {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () {
|
|
29
|
-
return e[k];
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
33
22
|
}
|
|
34
23
|
});
|
|
35
24
|
}
|
|
@@ -37,10 +26,10 @@ function _interopNamespace(e) {
|
|
|
37
26
|
return Object.freeze(n);
|
|
38
27
|
}
|
|
39
28
|
|
|
40
|
-
var React__namespace = /*#__PURE__*/
|
|
41
|
-
var OpenAI__default = /*#__PURE__*/
|
|
42
|
-
var ReactMarkdown__default = /*#__PURE__*/
|
|
43
|
-
var remarkGfm__default = /*#__PURE__*/
|
|
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);
|
|
44
33
|
|
|
45
34
|
// src/utils/cx.ts
|
|
46
35
|
function cx(...args) {
|
|
@@ -55,18 +44,18 @@ var base = {
|
|
|
55
44
|
lineHeight: 1,
|
|
56
45
|
transition: "background-color .2s ease, color .2s ease, border-color .2s ease",
|
|
57
46
|
outline: "none",
|
|
58
|
-
cursor: "pointer"
|
|
47
|
+
cursor: "pointer"
|
|
59
48
|
};
|
|
60
49
|
var sizes = {
|
|
61
50
|
sm: { height: 36, padding: "0 12px", fontSize: 14 },
|
|
62
51
|
md: { height: 40, padding: "0 16px", fontSize: 16 },
|
|
63
|
-
lg: { height: 44, padding: "0 20px", fontSize: 18 }
|
|
52
|
+
lg: { height: 44, padding: "0 20px", fontSize: 18 }
|
|
64
53
|
};
|
|
65
54
|
var palette = {
|
|
66
55
|
brand: {
|
|
67
56
|
primary: "#2563eb",
|
|
68
|
-
primaryHover: "#1d4ed8"
|
|
69
|
-
}
|
|
57
|
+
primaryHover: "#1d4ed8"
|
|
58
|
+
}
|
|
70
59
|
};
|
|
71
60
|
function styleFor(variant) {
|
|
72
61
|
switch (variant) {
|
|
@@ -74,45 +63,45 @@ function styleFor(variant) {
|
|
|
74
63
|
return {
|
|
75
64
|
background: "transparent",
|
|
76
65
|
color: palette.brand.primary,
|
|
77
|
-
border: `1px solid ${palette.brand.primary}
|
|
66
|
+
border: `1px solid ${palette.brand.primary}`
|
|
78
67
|
};
|
|
79
68
|
case "ghost":
|
|
80
69
|
return {
|
|
81
70
|
background: "transparent",
|
|
82
71
|
color: palette.brand.primary,
|
|
83
|
-
border: "1px solid transparent"
|
|
72
|
+
border: "1px solid transparent"
|
|
84
73
|
};
|
|
85
74
|
default:
|
|
86
75
|
return {
|
|
87
76
|
background: palette.brand.primary,
|
|
88
77
|
color: "#fff",
|
|
89
|
-
border: "1px solid transparent"
|
|
78
|
+
border: "1px solid transparent"
|
|
90
79
|
};
|
|
91
80
|
}
|
|
92
81
|
}
|
|
93
|
-
var Button = React__namespace.forwardRef(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
variant === "primary"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
82
|
+
var Button = React__namespace.forwardRef(
|
|
83
|
+
({ variant = "primary", size = "md", style, className, onMouseEnter, onMouseLeave, ...props }, ref) => {
|
|
84
|
+
const [hover, setHover] = React__namespace.useState(false);
|
|
85
|
+
const hoverStyle = variant === "primary" ? { background: hover ? palette.brand.primaryHover : palette.brand.primary } : variant === "outline" ? { borderColor: hover ? palette.brand.primaryHover : palette.brand.primary } : { background: hover ? "rgba(37, 99, 235, 0.08)" : "transparent" };
|
|
86
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
"button",
|
|
88
|
+
{
|
|
89
|
+
ref,
|
|
90
|
+
className: cx("rui-btn", className),
|
|
91
|
+
style: { ...base, ...sizes[size], ...styleFor(variant), ...hover ? hoverStyle : {}, ...style },
|
|
92
|
+
onMouseEnter: (e) => {
|
|
93
|
+
setHover(true);
|
|
94
|
+
onMouseEnter?.(e);
|
|
95
|
+
},
|
|
96
|
+
onMouseLeave: (e) => {
|
|
97
|
+
setHover(false);
|
|
98
|
+
onMouseLeave?.(e);
|
|
99
|
+
},
|
|
100
|
+
...props
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
);
|
|
116
105
|
Button.displayName = "Button";
|
|
117
106
|
var useChatbot = (options = {}) => {
|
|
118
107
|
const { mcpUrl, apiKey } = options;
|
|
@@ -128,7 +117,7 @@ var useChatbot = (options = {}) => {
|
|
|
128
117
|
id: generateId(),
|
|
129
118
|
content,
|
|
130
119
|
role,
|
|
131
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
120
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
132
121
|
};
|
|
133
122
|
setMessages((prev) => [...prev, newMessage]);
|
|
134
123
|
return newMessage;
|
|
@@ -150,11 +139,13 @@ var useChatbot = (options = {}) => {
|
|
|
150
139
|
require_approval: "never",
|
|
151
140
|
headers: {
|
|
152
141
|
Authorization: `Bearer ${options.userToken}`,
|
|
153
|
-
|
|
154
|
-
|
|
142
|
+
brandId: "c5bfc750-69fd-4653-8dbb-f01614bc3319",
|
|
143
|
+
"privy-token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlNLb3JzbjRsMnJWSllrNEFrd0EtY0NaVVY1M0ticUQ2eHZ6UTNPeDdsY3cifQ.eyJzaWQiOiJjbWdqN25yb3EwMWRqbGEwY2M3a3hoamVzIiwiaXNzIjoicHJpdnkuaW8iLCJpYXQiOjE3NjAwMTMzMTYsImF1ZCI6ImNsc3U1eWM4NTA4d2hpMGZhZWR1a2Uxd3MiLCJzdWIiOiJkaWQ6cHJpdnk6Y2x0Y3d4MTNuMGkwNTEyeXRmNWI5d3NzdSIsImV4cCI6MTc2MDAxNjkxNn0.qzUpTuk5e8W0mggf4FTAAP3zZyjJjwpMi-QXU_2pLO9kgfMV5IYPzymR9XjTEBMfJxgC9dApMDvOAX8MvX7URw"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
155
146
|
],
|
|
156
147
|
input: message,
|
|
157
|
-
previous_response_id: responseId || void 0
|
|
148
|
+
previous_response_id: responseId || void 0
|
|
158
149
|
});
|
|
159
150
|
} else {
|
|
160
151
|
resp = await client.responses.create({
|
|
@@ -165,10 +156,14 @@ var useChatbot = (options = {}) => {
|
|
|
165
156
|
server_label: "aizek-mcp",
|
|
166
157
|
server_url: mcpUrl,
|
|
167
158
|
require_approval: "never",
|
|
168
|
-
|
|
159
|
+
headers: {
|
|
160
|
+
brandId: "c5bfc750-69fd-4653-8dbb-f01614bc3319",
|
|
161
|
+
"privy-token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlNLb3JzbjRsMnJWSllrNEFrd0EtY0NaVVY1M0ticUQ2eHZ6UTNPeDdsY3cifQ.eyJzaWQiOiJjbWdqN25yb3EwMWRqbGEwY2M3a3hoamVzIiwiaXNzIjoicHJpdnkuaW8iLCJpYXQiOjE3NjAwMTMzMTYsImF1ZCI6ImNsc3U1eWM4NTA4d2hpMGZhZWR1a2Uxd3MiLCJzdWIiOiJkaWQ6cHJpdnk6Y2x0Y3d4MTNuMGkwNTEyeXRmNWI5d3NzdSIsImV4cCI6MTc2MDAxNjkxNn0.qzUpTuk5e8W0mggf4FTAAP3zZyjJjwpMi-QXU_2pLO9kgfMV5IYPzymR9XjTEBMfJxgC9dApMDvOAX8MvX7URw"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
169
164
|
],
|
|
170
165
|
input: message,
|
|
171
|
-
previous_response_id: responseId || void 0
|
|
166
|
+
previous_response_id: responseId || void 0
|
|
172
167
|
});
|
|
173
168
|
}
|
|
174
169
|
setResponseId(resp.id);
|
|
@@ -203,7 +198,7 @@ var useChatbot = (options = {}) => {
|
|
|
203
198
|
messages,
|
|
204
199
|
isLoading,
|
|
205
200
|
sendMessage,
|
|
206
|
-
addMessage
|
|
201
|
+
addMessage
|
|
207
202
|
};
|
|
208
203
|
};
|
|
209
204
|
|
|
@@ -214,8 +209,8 @@ var fetchChatWidgetSettings = async (clientId) => {
|
|
|
214
209
|
const response = await fetch(`${API_BASE_URL}/ChatWidgetSettings/GetByClientId?client_id=${clientId}`, {
|
|
215
210
|
method: "GET",
|
|
216
211
|
headers: {
|
|
217
|
-
"Content-Type": "application/json"
|
|
218
|
-
}
|
|
212
|
+
"Content-Type": "application/json"
|
|
213
|
+
}
|
|
219
214
|
});
|
|
220
215
|
if (!response.ok) {
|
|
221
216
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
@@ -232,9 +227,9 @@ var mapApiSettingsToConfig = (apiSettings) => {
|
|
|
232
227
|
return null;
|
|
233
228
|
}
|
|
234
229
|
const buttonSizeMap = {
|
|
235
|
-
small: "sm",
|
|
236
|
-
medium: "md",
|
|
237
|
-
large: "lg"
|
|
230
|
+
"small": "sm",
|
|
231
|
+
"medium": "md",
|
|
232
|
+
"large": "lg"
|
|
238
233
|
};
|
|
239
234
|
return {
|
|
240
235
|
welcomeMessage: apiSettings.welcome_message,
|
|
@@ -248,7 +243,7 @@ var mapApiSettingsToConfig = (apiSettings) => {
|
|
|
248
243
|
initialOpen: apiSettings.initial_open,
|
|
249
244
|
headerBackground: apiSettings.header_background,
|
|
250
245
|
companyLogo: apiSettings.company_logo || void 0,
|
|
251
|
-
companyName: apiSettings.company_name
|
|
246
|
+
companyName: apiSettings.company_name
|
|
252
247
|
};
|
|
253
248
|
};
|
|
254
249
|
|
|
@@ -262,29 +257,27 @@ var getMessageBubbleStyles = (isUser) => ({
|
|
|
262
257
|
lineHeight: 1.4,
|
|
263
258
|
fontSize: "14px",
|
|
264
259
|
position: "relative",
|
|
265
|
-
...
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
marginRight: "auto",
|
|
278
|
-
}),
|
|
260
|
+
...isUser ? {
|
|
261
|
+
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
262
|
+
color: "#ffffff",
|
|
263
|
+
marginLeft: "auto",
|
|
264
|
+
marginRight: "0"
|
|
265
|
+
} : {
|
|
266
|
+
background: "#f8fafc",
|
|
267
|
+
color: "#334155",
|
|
268
|
+
border: "1px solid #e2e8f0",
|
|
269
|
+
marginLeft: "0",
|
|
270
|
+
marginRight: "auto"
|
|
271
|
+
}
|
|
279
272
|
});
|
|
280
273
|
var getTimeStyles = (isUser) => ({
|
|
281
274
|
fontSize: "11px",
|
|
282
275
|
opacity: 0.7,
|
|
283
276
|
marginTop: "4px",
|
|
284
|
-
textAlign: isUser ? "right" : "left"
|
|
277
|
+
textAlign: isUser ? "right" : "left"
|
|
285
278
|
});
|
|
286
279
|
var getMarkdownStyles = () => ({
|
|
287
|
-
lineHeight: 1.6
|
|
280
|
+
lineHeight: 1.6
|
|
288
281
|
});
|
|
289
282
|
var getMarkdownElementStyles = (isUser) => `
|
|
290
283
|
.markdown-content p {
|
|
@@ -445,7 +438,7 @@ var getMessageContainerStyles = (isUser) => ({
|
|
|
445
438
|
display: "flex",
|
|
446
439
|
flexDirection: "column",
|
|
447
440
|
alignItems: isUser ? "flex-end" : "flex-start",
|
|
448
|
-
width: "100%"
|
|
441
|
+
width: "100%"
|
|
449
442
|
});
|
|
450
443
|
|
|
451
444
|
// src/styles/inputStyles.ts
|
|
@@ -456,7 +449,7 @@ var getInputContainerStyles = () => ({
|
|
|
456
449
|
padding: "16px",
|
|
457
450
|
background: "#ffffff",
|
|
458
451
|
borderTop: "1px solid #e2e8f0",
|
|
459
|
-
borderRadius: "0 0 12px 12px"
|
|
452
|
+
borderRadius: "0 0 12px 12px"
|
|
460
453
|
});
|
|
461
454
|
var getTextareaStyles = (isLoading) => ({
|
|
462
455
|
flex: 1,
|
|
@@ -473,12 +466,10 @@ var getTextareaStyles = (isLoading) => ({
|
|
|
473
466
|
fontFamily: "inherit",
|
|
474
467
|
background: "#f8fafc",
|
|
475
468
|
color: "#334155",
|
|
476
|
-
...
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
: {}),
|
|
469
|
+
...isLoading ? {
|
|
470
|
+
opacity: 0.6,
|
|
471
|
+
cursor: "not-allowed"
|
|
472
|
+
} : {}
|
|
482
473
|
});
|
|
483
474
|
var getSendButtonStyles = (isLoading, hasMessage) => ({
|
|
484
475
|
width: "44px",
|
|
@@ -492,7 +483,7 @@ var getSendButtonStyles = (isLoading, hasMessage) => ({
|
|
|
492
483
|
alignItems: "center",
|
|
493
484
|
justifyContent: "center",
|
|
494
485
|
transition: "all 0.2s ease",
|
|
495
|
-
fontSize: "16px"
|
|
486
|
+
fontSize: "16px"
|
|
496
487
|
});
|
|
497
488
|
|
|
498
489
|
// src/styles/headerStyles.ts
|
|
@@ -502,7 +493,7 @@ var getHeaderStyles = (headerBackground) => ({
|
|
|
502
493
|
color: "#ffffff",
|
|
503
494
|
display: "flex",
|
|
504
495
|
alignItems: "center",
|
|
505
|
-
gap: "12px"
|
|
496
|
+
gap: "12px"
|
|
506
497
|
});
|
|
507
498
|
var getLogoContainerStyles = () => ({
|
|
508
499
|
width: "40px",
|
|
@@ -513,34 +504,34 @@ var getLogoContainerStyles = () => ({
|
|
|
513
504
|
alignItems: "center",
|
|
514
505
|
justifyContent: "center",
|
|
515
506
|
fontSize: "18px",
|
|
516
|
-
overflow: "hidden"
|
|
507
|
+
overflow: "hidden"
|
|
517
508
|
});
|
|
518
509
|
var getLogoImageStyles = () => ({
|
|
519
510
|
width: "100%",
|
|
520
511
|
height: "100%",
|
|
521
512
|
objectFit: "cover",
|
|
522
|
-
borderRadius: "50%"
|
|
513
|
+
borderRadius: "50%"
|
|
523
514
|
});
|
|
524
515
|
var getLogoTextStyles = () => ({
|
|
525
516
|
fontSize: "16px",
|
|
526
|
-
fontWeight: "bold"
|
|
517
|
+
fontWeight: "bold"
|
|
527
518
|
});
|
|
528
519
|
var getCompanyNameStyles = () => ({
|
|
529
520
|
margin: 0,
|
|
530
521
|
fontSize: "16px",
|
|
531
|
-
fontWeight: 600
|
|
522
|
+
fontWeight: 600
|
|
532
523
|
});
|
|
533
524
|
var getStatusTextStyles = () => ({
|
|
534
525
|
margin: 0,
|
|
535
526
|
fontSize: "12px",
|
|
536
|
-
opacity: 0.8
|
|
527
|
+
opacity: 0.8
|
|
537
528
|
});
|
|
538
529
|
|
|
539
530
|
// src/styles/containerStyles.ts
|
|
540
531
|
var getButtonSizes = () => ({
|
|
541
532
|
sm: { width: "50px", height: "50px", fontSize: "20px" },
|
|
542
533
|
md: { width: "60px", height: "60px", fontSize: "24px" },
|
|
543
|
-
lg: { width: "70px", height: "70px", fontSize: "28px" }
|
|
534
|
+
lg: { width: "70px", height: "70px", fontSize: "28px" }
|
|
544
535
|
});
|
|
545
536
|
var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isOpen) => {
|
|
546
537
|
const buttonSizes = getButtonSizes();
|
|
@@ -563,7 +554,7 @@ var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isO
|
|
|
563
554
|
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
564
555
|
transition: "all 0.3s ease",
|
|
565
556
|
zIndex: 1e3,
|
|
566
|
-
transform: isOpen ? "scale(0.9)" : "scale(1)"
|
|
557
|
+
transform: isOpen ? "scale(0.9)" : "scale(1)"
|
|
567
558
|
};
|
|
568
559
|
};
|
|
569
560
|
var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) => ({
|
|
@@ -577,7 +568,7 @@ var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) =>
|
|
|
577
568
|
opacity: isOpen ? 1 : 0,
|
|
578
569
|
visibility: isOpen ? "visible" : "hidden",
|
|
579
570
|
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
580
|
-
transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right"
|
|
571
|
+
transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right"
|
|
581
572
|
});
|
|
582
573
|
var getOverlayStyles = (isOpen) => ({
|
|
583
574
|
position: "fixed",
|
|
@@ -589,7 +580,7 @@ var getOverlayStyles = (isOpen) => ({
|
|
|
589
580
|
zIndex: 998,
|
|
590
581
|
opacity: isOpen ? 1 : 0,
|
|
591
582
|
visibility: isOpen ? "visible" : "hidden",
|
|
592
|
-
transition: "all 0.3s ease"
|
|
583
|
+
transition: "all 0.3s ease"
|
|
593
584
|
});
|
|
594
585
|
var getChatbotContainerStyles = () => ({
|
|
595
586
|
display: "flex",
|
|
@@ -599,7 +590,7 @@ var getChatbotContainerStyles = () => ({
|
|
|
599
590
|
borderRadius: "12px",
|
|
600
591
|
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
601
592
|
border: "1px solid #e2e8f0",
|
|
602
|
-
overflow: "hidden"
|
|
593
|
+
overflow: "hidden"
|
|
603
594
|
});
|
|
604
595
|
var getMessagesContainerStyles = () => ({
|
|
605
596
|
flex: 1,
|
|
@@ -608,7 +599,7 @@ var getMessagesContainerStyles = () => ({
|
|
|
608
599
|
display: "flex",
|
|
609
600
|
flexDirection: "column",
|
|
610
601
|
gap: "4px",
|
|
611
|
-
background: "#f8fafc"
|
|
602
|
+
background: "#f8fafc"
|
|
612
603
|
});
|
|
613
604
|
var getEmptyStateStyles = () => ({
|
|
614
605
|
display: "flex",
|
|
@@ -618,7 +609,7 @@ var getEmptyStateStyles = () => ({
|
|
|
618
609
|
height: "100%",
|
|
619
610
|
color: "#64748b",
|
|
620
611
|
textAlign: "center",
|
|
621
|
-
padding: "40px 20px"
|
|
612
|
+
padding: "40px 20px"
|
|
622
613
|
});
|
|
623
614
|
|
|
624
615
|
// src/styles/loadingStyles.ts
|
|
@@ -628,7 +619,7 @@ var getLoadingSpinnerStyles = () => ({
|
|
|
628
619
|
border: "2px solid transparent",
|
|
629
620
|
borderTop: "2px solid currentColor",
|
|
630
621
|
borderRadius: "50%",
|
|
631
|
-
animation: "spin 1s linear infinite"
|
|
622
|
+
animation: "spin 1s linear infinite"
|
|
632
623
|
});
|
|
633
624
|
var AizekChatBot = ({ clientId, userToken }) => {
|
|
634
625
|
const defaultConfig = {
|
|
@@ -643,7 +634,7 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
643
634
|
initialOpen: true,
|
|
644
635
|
headerBackground: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
645
636
|
companyLogo: void 0,
|
|
646
|
-
companyName: "AI Asistan"
|
|
637
|
+
companyName: "AI Asistan"
|
|
647
638
|
};
|
|
648
639
|
const [config, setConfig] = React.useState(defaultConfig);
|
|
649
640
|
const [isConfigLoading, setIsConfigLoading] = React.useState(true);
|
|
@@ -688,38 +679,21 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
688
679
|
}, [messages]);
|
|
689
680
|
const MessageBubble = ({ message }) => {
|
|
690
681
|
const isUser = message.role === "user";
|
|
691
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
692
|
-
style:
|
|
693
|
-
children: [
|
|
694
|
-
/* @__PURE__ */ jsxRuntime.jsx("style", { children:
|
|
695
|
-
/* @__PURE__ */ jsxRuntime.
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
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
|
-
});
|
|
682
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getMessageContainerStyles(isUser), children: [
|
|
683
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: getMarkdownElementStyles(isUser) }),
|
|
684
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: getMessageBubbleStyles(isUser), children: [
|
|
685
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: getMarkdownStyles(), className: "markdown-content", children: /* @__PURE__ */ jsxRuntime.jsx(ReactMarkdown__default.default, { remarkPlugins: [remarkGfm__default.default], children: message.content }) }),
|
|
686
|
+
message.isTyping && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
687
|
+
display: "inline-flex",
|
|
688
|
+
alignItems: "center",
|
|
689
|
+
marginLeft: "8px"
|
|
690
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx(TypingDots, {}) })
|
|
691
|
+
] }),
|
|
692
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: getTimeStyles(isUser), children: message.timestamp.toLocaleTimeString("tr-TR", {
|
|
693
|
+
hour: "2-digit",
|
|
694
|
+
minute: "2-digit"
|
|
695
|
+
}) })
|
|
696
|
+
] });
|
|
723
697
|
};
|
|
724
698
|
const TypingDots = () => {
|
|
725
699
|
const [dots, setDots] = React.useState("");
|
|
@@ -759,20 +733,22 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
759
733
|
textarea.style.height = "auto";
|
|
760
734
|
textarea.style.height = Math.min(textarea.scrollHeight, 120) + "px";
|
|
761
735
|
};
|
|
762
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("form", {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
/* @__PURE__ */ jsxRuntime.jsx("textarea", {
|
|
736
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: getInputContainerStyles(), children: [
|
|
737
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
738
|
+
"textarea",
|
|
739
|
+
{
|
|
767
740
|
ref: textareaRef,
|
|
768
741
|
value: message,
|
|
769
742
|
onChange: handleInputChange,
|
|
770
743
|
onKeyDown: handleKeyDown,
|
|
771
744
|
placeholder,
|
|
772
745
|
disabled: isLoading,
|
|
773
|
-
style: getTextareaStyles(isLoading)
|
|
774
|
-
}
|
|
775
|
-
|
|
746
|
+
style: getTextareaStyles(isLoading)
|
|
747
|
+
}
|
|
748
|
+
),
|
|
749
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
750
|
+
"button",
|
|
751
|
+
{
|
|
776
752
|
type: "submit",
|
|
777
753
|
disabled: isLoading || !message.trim(),
|
|
778
754
|
style: getSendButtonStyles(isLoading, !!message.trim()),
|
|
@@ -784,12 +760,10 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
784
760
|
onMouseLeave: (e) => {
|
|
785
761
|
e.currentTarget.style.transform = "scale(1)";
|
|
786
762
|
},
|
|
787
|
-
children: isLoading
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
],
|
|
792
|
-
});
|
|
763
|
+
children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, {}) : /* @__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" }) })
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
] });
|
|
793
767
|
};
|
|
794
768
|
const LoadingSpinner = () => {
|
|
795
769
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: getLoadingSpinnerStyles() });
|
|
@@ -797,76 +771,55 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
797
771
|
if (isConfigLoading) {
|
|
798
772
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, false), children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: getLoadingSpinnerStyles() }) });
|
|
799
773
|
}
|
|
800
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
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", {
|
|
774
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
775
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
776
|
+
"div",
|
|
777
|
+
{
|
|
778
|
+
style: getOverlayStyles(isOpen),
|
|
779
|
+
onClick: toggleChat,
|
|
780
|
+
className: "floating-chat-overlay"
|
|
781
|
+
}
|
|
782
|
+
),
|
|
783
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: getChatContainerStyles(buttonPosition, chatWidth, chatHeight, isOpen), className: "floating-chat-container", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getChatbotContainerStyles(), children: [
|
|
784
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: getHeaderStyles(headerBackground), children: [
|
|
785
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: getLogoContainerStyles(), children: companyLogo ? companyLogo.startsWith("http") || companyLogo.startsWith("data:") ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
786
|
+
"img",
|
|
787
|
+
{
|
|
788
|
+
src: companyLogo,
|
|
789
|
+
alt: "Company Logo",
|
|
790
|
+
style: getLogoImageStyles()
|
|
791
|
+
}
|
|
792
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: getLogoTextStyles(), children: companyLogo }) : "\u{1F916}" }),
|
|
793
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
794
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: getCompanyNameStyles(), children: companyName }),
|
|
795
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: getStatusTextStyles(), children: isLoading ? "Yaz\u0131yor..." : "\xC7evrimi\xE7i" })
|
|
796
|
+
] })
|
|
797
|
+
] }),
|
|
798
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: getMessagesContainerStyles(), children: [
|
|
799
|
+
messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getEmptyStateStyles(), children: [
|
|
800
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "\u{1F4AC}" }),
|
|
801
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: { margin: "0 0 8px 0", fontSize: "18px" }, children: welcomeMessage }),
|
|
802
|
+
/* @__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." })
|
|
803
|
+
] }) : messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { message }, message.id)),
|
|
804
|
+
showTypingIndicator && isLoading && messages.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
805
|
+
MessageBubble,
|
|
806
|
+
{
|
|
807
|
+
message: {
|
|
808
|
+
id: "typing",
|
|
809
|
+
content: "",
|
|
810
|
+
role: "assistant",
|
|
811
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
812
|
+
isTyping: true
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
),
|
|
816
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
|
|
817
|
+
] }),
|
|
818
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChatInput, {})
|
|
819
|
+
] }) }),
|
|
820
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
821
|
+
"button",
|
|
822
|
+
{
|
|
870
823
|
onClick: toggleChat,
|
|
871
824
|
style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, isOpen),
|
|
872
825
|
onMouseEnter: (e) => {
|
|
@@ -879,28 +832,14 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
879
832
|
},
|
|
880
833
|
className: "floating-chat-button",
|
|
881
834
|
"aria-label": isOpen ? "Chati kapat" : "Chati a\xE7",
|
|
882
|
-
children: isOpen
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
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
|
-
});
|
|
835
|
+
children: isOpen ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", 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" }) }) : /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", 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" }) })
|
|
836
|
+
}
|
|
837
|
+
)
|
|
838
|
+
] });
|
|
900
839
|
};
|
|
901
840
|
|
|
902
841
|
exports.AizekChatBot = AizekChatBot;
|
|
903
842
|
exports.Button = Button;
|
|
904
843
|
exports.useChatbot = useChatbot;
|
|
905
844
|
//# sourceMappingURL=index.cjs.map
|
|
906
|
-
//# sourceMappingURL=index.cjs.map
|
|
845
|
+
//# sourceMappingURL=index.cjs.map
|