aizek-chatbot 1.0.29 → 1.0.30
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 +1190 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +1852 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +50 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.mjs +1182 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +1 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1182 @@
|
|
|
1
|
+
import { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import ReactMarkdown from 'react-markdown';
|
|
4
|
+
import remarkGfm from 'remark-gfm';
|
|
5
|
+
import sanitizeHtml from 'sanitize-html';
|
|
6
|
+
|
|
7
|
+
// src/utils/global.ts
|
|
8
|
+
var SESSION_TTL_MS = 60 * 60 * 1e3;
|
|
9
|
+
var MAX_SESSIONS = 3;
|
|
10
|
+
var DEVICE_KEY = "aizek_device_id_v1";
|
|
11
|
+
var ACTIVE_SESSION_KEY = "aizek_active_session_v1";
|
|
12
|
+
var LOCAL_SESSIONS_KEY = "aizek_sessions_v1";
|
|
13
|
+
function validateHeaders(headers, authConfig, opts = {}) {
|
|
14
|
+
if (headers && (!authConfig || Object.keys(authConfig).length === 0)) {
|
|
15
|
+
return {
|
|
16
|
+
isValid: false,
|
|
17
|
+
missingKeys: [],
|
|
18
|
+
extraKeys: [],
|
|
19
|
+
emptyValueKeys: [],
|
|
20
|
+
warning: "Auth config bo\u015F ya da tan\u0131ms\u0131z, header do\u011Frulamas\u0131 yap\u0131lam\u0131yor."
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const { caseSensitive = false, allowExtra = false } = opts;
|
|
24
|
+
const normalize = (s) => caseSensitive ? s : s.toLowerCase();
|
|
25
|
+
const headerEntries = Object.entries(headers).map(([k, v]) => [normalize(k), v.trim()]);
|
|
26
|
+
const authEntries = Object.entries(authConfig).map(([k, v]) => [normalize(k), v.trim()]);
|
|
27
|
+
const headerKeys = headerEntries.map(([k]) => k);
|
|
28
|
+
const authKeys = authEntries.map(([k]) => k);
|
|
29
|
+
const requiredSet = new Set(authKeys);
|
|
30
|
+
const missingKeys = authKeys.filter((k) => !headerKeys.includes(k));
|
|
31
|
+
const extraKeys = headerKeys.filter((k) => !requiredSet.has(k));
|
|
32
|
+
const hasAllRequired = missingKeys.length === 0;
|
|
33
|
+
const hasExtraKeys = extraKeys.length > 0 && !allowExtra;
|
|
34
|
+
const emptyValueKeys = authKeys.filter((k) => {
|
|
35
|
+
const val = headerEntries.find(([key]) => key === k)?.[1];
|
|
36
|
+
return !val || val.length === 0;
|
|
37
|
+
});
|
|
38
|
+
const isValid = hasAllRequired && !hasExtraKeys && emptyValueKeys.length === 0;
|
|
39
|
+
return { isValid, missingKeys, extraKeys, emptyValueKeys };
|
|
40
|
+
}
|
|
41
|
+
function getOrCreateDeviceId() {
|
|
42
|
+
if (typeof window === "undefined") return "";
|
|
43
|
+
const existing = localStorage.getItem(DEVICE_KEY);
|
|
44
|
+
if (existing) return existing;
|
|
45
|
+
const id = crypto.randomUUID();
|
|
46
|
+
localStorage.setItem(DEVICE_KEY, id);
|
|
47
|
+
return id;
|
|
48
|
+
}
|
|
49
|
+
function now() {
|
|
50
|
+
return Date.now();
|
|
51
|
+
}
|
|
52
|
+
function readStoredSessions() {
|
|
53
|
+
try {
|
|
54
|
+
const raw = localStorage.getItem(LOCAL_SESSIONS_KEY);
|
|
55
|
+
const parsed = JSON.parse(raw ?? "[]");
|
|
56
|
+
if (!Array.isArray(parsed)) return [];
|
|
57
|
+
return parsed.filter((x) => x && typeof x.sessionId === "string" && typeof x.lastActive === "number").slice(0, MAX_SESSIONS);
|
|
58
|
+
} catch {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function writeStoredSessions(list) {
|
|
63
|
+
localStorage.setItem(LOCAL_SESSIONS_KEY, JSON.stringify(list.slice(0, MAX_SESSIONS)));
|
|
64
|
+
}
|
|
65
|
+
function purgeExpiredLocalSessions(setActiveSessionIdState) {
|
|
66
|
+
const list = readStoredSessions();
|
|
67
|
+
const filtered = list.filter((s) => now() - s.lastActive <= SESSION_TTL_MS);
|
|
68
|
+
if (filtered.length !== list.length) writeStoredSessions(filtered);
|
|
69
|
+
const active = getActiveSessionId();
|
|
70
|
+
if (active && !filtered.some((s) => s.sessionId === active)) {
|
|
71
|
+
setActiveSessionId(null);
|
|
72
|
+
setActiveSessionIdState(null);
|
|
73
|
+
}
|
|
74
|
+
return filtered;
|
|
75
|
+
}
|
|
76
|
+
function getActiveSessionId() {
|
|
77
|
+
return localStorage.getItem(ACTIVE_SESSION_KEY);
|
|
78
|
+
}
|
|
79
|
+
function setActiveSessionId(id) {
|
|
80
|
+
if (!id) localStorage.removeItem(ACTIVE_SESSION_KEY);
|
|
81
|
+
else localStorage.setItem(ACTIVE_SESSION_KEY, id);
|
|
82
|
+
}
|
|
83
|
+
function touchSession(sessionId) {
|
|
84
|
+
const list = readStoredSessions();
|
|
85
|
+
const next = list.map((s) => s.sessionId === sessionId ? { ...s, lastActive: now() } : s);
|
|
86
|
+
if (!next.some((s) => s.sessionId === sessionId)) next.unshift({ sessionId, lastActive: now() });
|
|
87
|
+
writeStoredSessions(next.slice(0, MAX_SESSIONS));
|
|
88
|
+
}
|
|
89
|
+
function upsertSessionsFromServer(serverSessionIds, setSessions) {
|
|
90
|
+
const local = readStoredSessions();
|
|
91
|
+
const map = new Map(local.map((s) => [s.sessionId, s.lastActive]));
|
|
92
|
+
const merged = serverSessionIds.slice(0, MAX_SESSIONS).map((sid) => ({
|
|
93
|
+
sessionId: sid,
|
|
94
|
+
lastActive: map.get(sid) ?? now()
|
|
95
|
+
}));
|
|
96
|
+
writeStoredSessions(merged);
|
|
97
|
+
setSessions(merged.map((x) => x.sessionId));
|
|
98
|
+
return merged;
|
|
99
|
+
}
|
|
100
|
+
var HeaderAlert = ({ headerValidation, showAlert, setShowAlert }) => {
|
|
101
|
+
if (!headerValidation || !showAlert) return null;
|
|
102
|
+
const { isValid, missingKeys, extraKeys, emptyValueKeys, warning } = headerValidation;
|
|
103
|
+
if (isValid && missingKeys.length === 0 && extraKeys.length === 0 && emptyValueKeys.length === 0 && !warning) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
const hasErrors = missingKeys.length > 0 || emptyValueKeys.length > 0;
|
|
107
|
+
const hasWarnings = extraKeys.length > 0 || !!warning;
|
|
108
|
+
const alertType = hasErrors ? "error" : "warning";
|
|
109
|
+
const getAlertIcon = () => {
|
|
110
|
+
if (hasErrors) {
|
|
111
|
+
return /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" }) });
|
|
112
|
+
}
|
|
113
|
+
return /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }) });
|
|
114
|
+
};
|
|
115
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: `alert-container ${alertType}`, children: [
|
|
116
|
+
/* @__PURE__ */ jsx("div", { className: "alert-icon-container", children: getAlertIcon() }),
|
|
117
|
+
/* @__PURE__ */ jsxs("div", { className: "alert-content", children: [
|
|
118
|
+
/* @__PURE__ */ jsx("h4", { className: "alert-title", children: hasErrors ? "Header Do\u011Frulama Hatas\u0131" : "Header Uyar\u0131s\u0131" }),
|
|
119
|
+
/* @__PURE__ */ jsx("p", { className: "alert-message", children: hasErrors && hasWarnings ? "Header yap\u0131land\u0131rman\u0131zda hatalar ve uyar\u0131lar bulundu." : hasErrors ? "Header yap\u0131land\u0131rman\u0131zda hatalar bulundu." : "Header yap\u0131land\u0131rman\u0131zda fazla anahtarlar bulundu." }),
|
|
120
|
+
missingKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
121
|
+
/* @__PURE__ */ jsx("strong", { children: "Eksik Header'lar:" }),
|
|
122
|
+
/* @__PURE__ */ jsx("ul", { className: "alert-list", children: missingKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { className: "alert-list-item", children: [
|
|
123
|
+
/* @__PURE__ */ jsx("span", { children: "\u2022" }),
|
|
124
|
+
/* @__PURE__ */ jsx("code", { children: key })
|
|
125
|
+
] }, index)) })
|
|
126
|
+
] }),
|
|
127
|
+
emptyValueKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
128
|
+
/* @__PURE__ */ jsx("strong", { children: "Bo\u015F De\u011Ferli Header'lar:" }),
|
|
129
|
+
/* @__PURE__ */ jsx("ul", { className: "alert-list", children: emptyValueKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { className: "alert-list-item", children: [
|
|
130
|
+
/* @__PURE__ */ jsx("span", { children: "\u2022" }),
|
|
131
|
+
/* @__PURE__ */ jsx("code", { children: key }),
|
|
132
|
+
/* @__PURE__ */ jsx("span", { children: "(de\u011Fer bo\u015F olamaz)" })
|
|
133
|
+
] }, index)) })
|
|
134
|
+
] }),
|
|
135
|
+
extraKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
136
|
+
/* @__PURE__ */ jsx("strong", { children: "Fazla Header'lar:" }),
|
|
137
|
+
/* @__PURE__ */ jsx("ul", { className: "alert-list", children: extraKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { className: "alert-list-item", children: [
|
|
138
|
+
/* @__PURE__ */ jsx("span", { children: "\u2022" }),
|
|
139
|
+
/* @__PURE__ */ jsx("code", { children: key })
|
|
140
|
+
] }, index)) })
|
|
141
|
+
] }),
|
|
142
|
+
warning && /* @__PURE__ */ jsxs("div", { children: [
|
|
143
|
+
/* @__PURE__ */ jsx("strong", { children: "Uyar\u0131:" }),
|
|
144
|
+
/* @__PURE__ */ jsx("p", { className: "alert-message", children: warning })
|
|
145
|
+
] })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ jsx(
|
|
148
|
+
"button",
|
|
149
|
+
{
|
|
150
|
+
onClick: () => setShowAlert(false),
|
|
151
|
+
className: "alert-close-button",
|
|
152
|
+
"aria-label": "Uyar\u0131y\u0131 kapat",
|
|
153
|
+
children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", 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" }) })
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
] }) });
|
|
157
|
+
};
|
|
158
|
+
var LoadingSpinner = () => {
|
|
159
|
+
return /* @__PURE__ */ jsx("div", { className: "loading-spinner" });
|
|
160
|
+
};
|
|
161
|
+
var ChatInput = ({ isLoading, placeholder, handleSendMessage }) => {
|
|
162
|
+
const [message, setMessage] = useState("");
|
|
163
|
+
const textareaRef = useRef(null);
|
|
164
|
+
const handleSubmit = (e) => {
|
|
165
|
+
e.preventDefault();
|
|
166
|
+
if (message.trim() && !isLoading) {
|
|
167
|
+
handleSendMessage(message.trim());
|
|
168
|
+
setMessage("");
|
|
169
|
+
if (textareaRef.current) {
|
|
170
|
+
textareaRef.current.style.height = "auto";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const handleKeyDown = (e) => {
|
|
175
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
handleSubmit(e);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const handleInputChange = (e) => {
|
|
181
|
+
setMessage(e.target.value);
|
|
182
|
+
const textarea = e.target;
|
|
183
|
+
textarea.style.height = "auto";
|
|
184
|
+
textarea.style.height = Math.min(textarea.scrollHeight, 120) + "px";
|
|
185
|
+
};
|
|
186
|
+
return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "input-container", children: [
|
|
187
|
+
/* @__PURE__ */ jsx(
|
|
188
|
+
"textarea",
|
|
189
|
+
{
|
|
190
|
+
ref: textareaRef,
|
|
191
|
+
value: message,
|
|
192
|
+
onChange: handleInputChange,
|
|
193
|
+
onKeyDown: handleKeyDown,
|
|
194
|
+
placeholder,
|
|
195
|
+
disabled: isLoading,
|
|
196
|
+
className: "textarea"
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
/* @__PURE__ */ jsx(
|
|
200
|
+
"button",
|
|
201
|
+
{
|
|
202
|
+
type: "submit",
|
|
203
|
+
disabled: isLoading || !message.trim(),
|
|
204
|
+
className: "send-button",
|
|
205
|
+
children: isLoading ? /* @__PURE__ */ jsx(LoadingSpinner, {}) : /* @__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" }) })
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
] });
|
|
209
|
+
};
|
|
210
|
+
var GenericUIRenderer = ({ uiData, onInteraction }) => {
|
|
211
|
+
const containerRef = useRef(null);
|
|
212
|
+
if (!uiData || !uiData.components) return null;
|
|
213
|
+
const collectFormValues = () => {
|
|
214
|
+
if (!containerRef.current) return {};
|
|
215
|
+
const formData = {};
|
|
216
|
+
const inputs = containerRef.current.querySelectorAll("input, textarea, select");
|
|
217
|
+
inputs.forEach((element) => {
|
|
218
|
+
const name = element.getAttribute("name");
|
|
219
|
+
if (name) {
|
|
220
|
+
if (element instanceof HTMLInputElement && element.type === "checkbox") {
|
|
221
|
+
formData[name] = element.checked;
|
|
222
|
+
} else if (element instanceof HTMLInputElement && element.type === "radio") {
|
|
223
|
+
if (element.checked) {
|
|
224
|
+
formData[name] = element.value;
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
formData[name] = element.value;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return formData;
|
|
232
|
+
};
|
|
233
|
+
const renderComponent = (comp) => {
|
|
234
|
+
switch (comp.type) {
|
|
235
|
+
case "text":
|
|
236
|
+
return /* @__PURE__ */ jsx("p", { className: "gen-ui-text", children: comp.value ?? comp.label }, comp.id);
|
|
237
|
+
case "input":
|
|
238
|
+
return /* @__PURE__ */ jsxs("div", { className: "gen-ui-input-wrapper", children: [
|
|
239
|
+
comp.label && /* @__PURE__ */ jsx("label", { className: "gen-ui-input-label", children: comp.label }),
|
|
240
|
+
comp.fieldType === "textarea" ? /* @__PURE__ */ jsx(
|
|
241
|
+
"textarea",
|
|
242
|
+
{
|
|
243
|
+
name: comp.id,
|
|
244
|
+
placeholder: comp.placeholder,
|
|
245
|
+
className: "gen-ui-textarea"
|
|
246
|
+
}
|
|
247
|
+
) : /* @__PURE__ */ jsx(
|
|
248
|
+
"input",
|
|
249
|
+
{
|
|
250
|
+
name: comp.id,
|
|
251
|
+
type: comp.fieldType || "text",
|
|
252
|
+
placeholder: comp.placeholder,
|
|
253
|
+
className: "gen-ui-input"
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
] }, comp.id);
|
|
257
|
+
case "select":
|
|
258
|
+
return /* @__PURE__ */ jsxs("div", { className: "gen-ui-select-wrapper", children: [
|
|
259
|
+
comp.label && /* @__PURE__ */ jsx("label", { className: "gen-ui-select-label", children: comp.label }),
|
|
260
|
+
/* @__PURE__ */ jsx("select", { name: comp.id, className: "gen-ui-select", children: comp.options?.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt)) })
|
|
261
|
+
] }, comp.id);
|
|
262
|
+
case "button":
|
|
263
|
+
return /* @__PURE__ */ jsx(
|
|
264
|
+
"button",
|
|
265
|
+
{
|
|
266
|
+
onClick: () => {
|
|
267
|
+
const formValues = collectFormValues();
|
|
268
|
+
onInteraction({
|
|
269
|
+
action: comp.label,
|
|
270
|
+
buttonId: comp.buttonType,
|
|
271
|
+
formData: formValues
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
className: "gen-ui-button",
|
|
275
|
+
children: comp.label
|
|
276
|
+
},
|
|
277
|
+
comp.id
|
|
278
|
+
);
|
|
279
|
+
case "card":
|
|
280
|
+
return /* @__PURE__ */ jsxs("div", { className: "gen-ui-card", children: [
|
|
281
|
+
comp.label && /* @__PURE__ */ jsx("h2", { className: "gen-ui-card-title", children: comp.label }),
|
|
282
|
+
comp.value && /* @__PURE__ */ jsx("p", { className: "gen-ui-card-content", children: comp.value })
|
|
283
|
+
] }, comp.id);
|
|
284
|
+
case "list":
|
|
285
|
+
return /* @__PURE__ */ jsx("ul", { className: "gen-ui-list", children: comp.items?.map((item) => /* @__PURE__ */ jsx("li", { className: "gen-ui-list-item", children: item.label ?? String(item.value ?? "") }, item.id)) }, comp.id);
|
|
286
|
+
case "image":
|
|
287
|
+
return /* @__PURE__ */ jsx(
|
|
288
|
+
"img",
|
|
289
|
+
{
|
|
290
|
+
src: comp.url,
|
|
291
|
+
alt: comp.label || "",
|
|
292
|
+
className: "gen-ui-image"
|
|
293
|
+
},
|
|
294
|
+
comp.id
|
|
295
|
+
);
|
|
296
|
+
case "link":
|
|
297
|
+
return /* @__PURE__ */ jsx(
|
|
298
|
+
"a",
|
|
299
|
+
{
|
|
300
|
+
href: comp.url,
|
|
301
|
+
className: "gen-ui-link",
|
|
302
|
+
children: comp.label || comp.url
|
|
303
|
+
},
|
|
304
|
+
comp.id
|
|
305
|
+
);
|
|
306
|
+
case "table":
|
|
307
|
+
return /* @__PURE__ */ jsx("div", { className: "gen-ui-table-wrapper", children: /* @__PURE__ */ jsxs("table", { className: "gen-ui-table", children: [
|
|
308
|
+
comp.columns && /* @__PURE__ */ jsx("thead", { className: "gen-ui-table-header", children: /* @__PURE__ */ jsx("tr", { children: comp.columns.map((col) => /* @__PURE__ */ jsx("th", { className: "gen-ui-table-th", children: col }, col)) }) }),
|
|
309
|
+
comp.rows && /* @__PURE__ */ jsx("tbody", { className: "gen-ui-table-body", children: comp.rows.map((row, ridx) => /* @__PURE__ */ jsx("tr", { children: row.map((cell, cidx) => /* @__PURE__ */ jsx("td", { className: "gen-ui-table-td", children: cell }, cidx)) }, ridx)) })
|
|
310
|
+
] }) }, comp.id);
|
|
311
|
+
case "form":
|
|
312
|
+
return /* @__PURE__ */ jsx("form", { className: "gen-ui-form", children: comp.items?.map((field) => renderComponent(field)) }, comp.id);
|
|
313
|
+
default:
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
return /* @__PURE__ */ jsxs("div", { className: "generative-ui-container", ref: containerRef, children: [
|
|
318
|
+
(uiData.title || uiData.description) && /* @__PURE__ */ jsxs("div", { className: "generative-ui-header", children: [
|
|
319
|
+
uiData.title && /* @__PURE__ */ jsx("h1", { className: "generative-ui-title", children: uiData.title }),
|
|
320
|
+
uiData.description && /* @__PURE__ */ jsx("p", { className: "generative-ui-description", children: uiData.description })
|
|
321
|
+
] }),
|
|
322
|
+
uiData.components.map((comp) => renderComponent(comp))
|
|
323
|
+
] });
|
|
324
|
+
};
|
|
325
|
+
var MessageBubble = ({ message, onAction }) => {
|
|
326
|
+
console.log("MESSAGE", message);
|
|
327
|
+
const isUser = message.role === "user";
|
|
328
|
+
const approval = message.role === "approval";
|
|
329
|
+
if (approval) {
|
|
330
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
331
|
+
}
|
|
332
|
+
return /* @__PURE__ */ jsxs("div", { className: `message-container ${isUser ? "user" : "assistant"}`, children: [
|
|
333
|
+
/* @__PURE__ */ jsx("div", { className: `message-bubble ${isUser ? "user" : "assistant"}`, children: isUser ? message.text && /* @__PURE__ */ jsx("div", { className: "markdown-content", children: message.text }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
334
|
+
message.text && /* @__PURE__ */ jsx("div", { className: "markdown-content", children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.text }) }),
|
|
335
|
+
message.ui && /* @__PURE__ */ jsx(
|
|
336
|
+
GenericUIRenderer,
|
|
337
|
+
{
|
|
338
|
+
uiData: message.ui,
|
|
339
|
+
onInteraction: (event) => {
|
|
340
|
+
console.log("event", event);
|
|
341
|
+
if (event.buttonId === "submit") {
|
|
342
|
+
onAction(JSON.stringify(event.formData), true);
|
|
343
|
+
} else {
|
|
344
|
+
onAction(event.action, true);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
)
|
|
349
|
+
] }) }),
|
|
350
|
+
/* @__PURE__ */ jsx("div", { className: `message-time ${isUser ? "user" : "assistant"}`, children: message.timestamp.toLocaleTimeString("tr-TR", {
|
|
351
|
+
hour: "2-digit",
|
|
352
|
+
minute: "2-digit"
|
|
353
|
+
}) })
|
|
354
|
+
] });
|
|
355
|
+
};
|
|
356
|
+
var TypingDots = () => {
|
|
357
|
+
const [dots, setDots] = useState("");
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
const interval = setInterval(() => {
|
|
360
|
+
setDots((prev) => {
|
|
361
|
+
if (prev === "...") return "";
|
|
362
|
+
return prev + ".";
|
|
363
|
+
});
|
|
364
|
+
}, 500);
|
|
365
|
+
return () => clearInterval(interval);
|
|
366
|
+
}, []);
|
|
367
|
+
return /* @__PURE__ */ jsx("div", { className: "message-container assistant", children: /* @__PURE__ */ jsx("div", { className: "message-bubble assistant", children: /* @__PURE__ */ jsx("div", { className: "message-typing-indicator", children: /* @__PURE__ */ jsx("span", { children: dots }) }) }) });
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// src/utils/chatbot.ts
|
|
371
|
+
var extractUIJsonFromText = (text) => {
|
|
372
|
+
const regex = /```ui-component([\s\S]*?)```/g;
|
|
373
|
+
let cleaned = text;
|
|
374
|
+
let match;
|
|
375
|
+
let uiData = null;
|
|
376
|
+
while ((match = regex.exec(text)) !== null) {
|
|
377
|
+
const block = match[1].trim();
|
|
378
|
+
try {
|
|
379
|
+
const parsed = JSON.parse(block);
|
|
380
|
+
if (parsed && parsed.components && Array.isArray(parsed.components)) {
|
|
381
|
+
parsed.components = parsed.components.map((comp, index) => {
|
|
382
|
+
if (!comp.id || typeof comp.id !== "string" || !comp.id.trim()) {
|
|
383
|
+
comp.id = `ui-comp-${index}-${Date.now()}`;
|
|
384
|
+
}
|
|
385
|
+
if (comp.type === "button") {
|
|
386
|
+
if (!comp.buttonType) {
|
|
387
|
+
comp.buttonType = "click";
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (comp.type === "input") {
|
|
391
|
+
if (!comp.fieldType) {
|
|
392
|
+
comp.fieldType = "text";
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (comp.type === "select") {
|
|
396
|
+
if (comp.options && Array.isArray(comp.options)) {
|
|
397
|
+
const firstOption = comp.options[0];
|
|
398
|
+
if (typeof firstOption === "object" && firstOption !== null) {
|
|
399
|
+
if ("label" in firstOption || "value" in firstOption) {
|
|
400
|
+
comp.options = comp.options.map(
|
|
401
|
+
(opt) => opt.label || opt.value || String(opt)
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (comp.type === "table") {
|
|
408
|
+
if (comp.columns && Array.isArray(comp.columns)) {
|
|
409
|
+
const firstCol = comp.columns[0];
|
|
410
|
+
if (typeof firstCol === "object" && firstCol !== null) {
|
|
411
|
+
comp.columns = comp.columns.map(
|
|
412
|
+
(col) => col.label || col.id || String(col)
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (comp.rows && Array.isArray(comp.rows)) {
|
|
417
|
+
const firstRow = comp.rows[0];
|
|
418
|
+
if (typeof firstRow === "object" && !Array.isArray(firstRow)) {
|
|
419
|
+
comp.rows = comp.rows.map((row) => {
|
|
420
|
+
if (Array.isArray(row)) return row;
|
|
421
|
+
return Object.values(row).map((val) => {
|
|
422
|
+
if (typeof val === "object" && val !== null) {
|
|
423
|
+
if (val.type === "image" && val.src) return val.src;
|
|
424
|
+
if (val.value !== void 0) return String(val.value);
|
|
425
|
+
}
|
|
426
|
+
return String(val || "");
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (comp.type === "form" && comp.items && Array.isArray(comp.items)) {
|
|
433
|
+
comp.items = comp.items.map((field, fieldIndex) => {
|
|
434
|
+
if (!field.id || !field.id.trim()) {
|
|
435
|
+
field.id = `field-${fieldIndex}-${Date.now()}`;
|
|
436
|
+
}
|
|
437
|
+
if (field.optional !== void 0) {
|
|
438
|
+
field.requiredField = !field.optional;
|
|
439
|
+
delete field.optional;
|
|
440
|
+
}
|
|
441
|
+
if (field.required !== void 0) {
|
|
442
|
+
field.requiredField = field.required;
|
|
443
|
+
delete field.required;
|
|
444
|
+
}
|
|
445
|
+
if (field.type === "input" && !field.fieldType) {
|
|
446
|
+
field.fieldType = "text";
|
|
447
|
+
}
|
|
448
|
+
if (field.type === "select" && field.options && Array.isArray(field.options)) {
|
|
449
|
+
const firstOpt = field.options[0];
|
|
450
|
+
if (typeof firstOpt === "object" && firstOpt !== null) {
|
|
451
|
+
field.options = field.options.map(
|
|
452
|
+
(opt) => opt.label || opt.value || String(opt)
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return field;
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
if (comp.type === "list" && comp.items && Array.isArray(comp.items)) {
|
|
460
|
+
comp.items = comp.items.map((item, itemIndex) => {
|
|
461
|
+
if (typeof item === "string") {
|
|
462
|
+
return {
|
|
463
|
+
id: `list-item-${itemIndex}-${Date.now()}`,
|
|
464
|
+
type: "text",
|
|
465
|
+
value: item,
|
|
466
|
+
label: item
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
if (!item.id || !item.id.trim()) {
|
|
470
|
+
item.id = `list-item-${itemIndex}-${Date.now()}`;
|
|
471
|
+
}
|
|
472
|
+
return item;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
return comp;
|
|
476
|
+
});
|
|
477
|
+
uiData = parsed;
|
|
478
|
+
}
|
|
479
|
+
cleaned = cleaned.replace(match[0], "").trim();
|
|
480
|
+
break;
|
|
481
|
+
} catch (e) {
|
|
482
|
+
console.error("Invalid ui-component JSON:", e, block);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
cleanedText: cleaned,
|
|
487
|
+
uiData
|
|
488
|
+
};
|
|
489
|
+
};
|
|
490
|
+
var AizekChatBot = ({ clientId, headers, onMounted, onReady, onOpen, onClose, onMessage, onToolCall, onDisconnect }) => {
|
|
491
|
+
const messagesEndRef = useRef(null);
|
|
492
|
+
const [config, setConfig] = useState();
|
|
493
|
+
const [messages, setMessages] = useState([]);
|
|
494
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
495
|
+
const [isConfigLoading, setIsConfigLoading] = useState(true);
|
|
496
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
497
|
+
const [headerValidation, setHeaderValidation] = useState(null);
|
|
498
|
+
const [showAlert, setShowAlert] = useState(true);
|
|
499
|
+
const [sessions, setSessions] = useState([]);
|
|
500
|
+
const [activeSessionId, setActiveSessionIdState] = useState(null);
|
|
501
|
+
const [activeTab, setActiveTab] = useState("home");
|
|
502
|
+
const [messageView, setMessageView] = useState("list");
|
|
503
|
+
const [sessionTitleById, setSessionTitleById] = useState({});
|
|
504
|
+
const PROXY_BASE_URL = "https://proxy.aizek.ai/api";
|
|
505
|
+
const createNewSession = async () => {
|
|
506
|
+
const deviceId = getOrCreateDeviceId();
|
|
507
|
+
if (sessions.length >= MAX_SESSIONS) {
|
|
508
|
+
throw new Error(`You can open up to ${MAX_SESSIONS} sessions.`);
|
|
509
|
+
}
|
|
510
|
+
const res = await fetch(`${PROXY_BASE_URL}/aizek-sessions/new?clientId=${clientId}`, {
|
|
511
|
+
method: "POST",
|
|
512
|
+
headers: {
|
|
513
|
+
"Content-Type": "application/json",
|
|
514
|
+
"x-device-id": deviceId,
|
|
515
|
+
"x-alternate": JSON.stringify(headers)
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
const data = await res.json();
|
|
519
|
+
if (!data.success) throw new Error(data.message || "session create failed");
|
|
520
|
+
const sid = data.data.sessionId;
|
|
521
|
+
const updatedSessions = data.data.sessions ?? [sid];
|
|
522
|
+
upsertSessionsFromServer(updatedSessions, setSessions);
|
|
523
|
+
setActiveSessionIdState(sid);
|
|
524
|
+
setActiveSessionId(sid);
|
|
525
|
+
setActiveTab("messages");
|
|
526
|
+
setMessageView("detail");
|
|
527
|
+
touchSession(sid);
|
|
528
|
+
setMessages([]);
|
|
529
|
+
return sid;
|
|
530
|
+
};
|
|
531
|
+
const loadConfig = async () => {
|
|
532
|
+
try {
|
|
533
|
+
setIsConfigLoading(true);
|
|
534
|
+
const deviceId = getOrCreateDeviceId();
|
|
535
|
+
purgeExpiredLocalSessions(setActiveSessionIdState);
|
|
536
|
+
const localActive = getActiveSessionId();
|
|
537
|
+
const response = await fetch(`${PROXY_BASE_URL}/aizek-connect?clientId=${clientId}`, {
|
|
538
|
+
method: "POST",
|
|
539
|
+
headers: {
|
|
540
|
+
"Content-Type": "application/json",
|
|
541
|
+
"x-device-id": deviceId,
|
|
542
|
+
"x-alternate": JSON.stringify(headers)
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
const data = await response.json();
|
|
546
|
+
if (!data.success) {
|
|
547
|
+
setIsOpen(false);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
setIsOpen(!!data.data.widget_config.initial_open);
|
|
551
|
+
setConfig(data.data);
|
|
552
|
+
const serverSessions = data.data.sessions ?? [];
|
|
553
|
+
const merged = upsertSessionsFromServer(serverSessions, setSessions);
|
|
554
|
+
if (merged.length === 0) {
|
|
555
|
+
const newSid = await createNewSession();
|
|
556
|
+
setActiveSessionIdState(newSid);
|
|
557
|
+
setActiveSessionId(newSid);
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
const mergedIds = merged.map((s) => s.sessionId);
|
|
561
|
+
const nextActive = (localActive && mergedIds.includes(localActive) ? localActive : null) ?? mergedIds[0] ?? null;
|
|
562
|
+
setActiveSessionIdState(nextActive);
|
|
563
|
+
setActiveSessionId(nextActive);
|
|
564
|
+
if (headers) {
|
|
565
|
+
const validationResult = validateHeaders(headers, data.data.auth_config, {
|
|
566
|
+
allowExtra: false,
|
|
567
|
+
caseSensitive: true
|
|
568
|
+
});
|
|
569
|
+
setHeaderValidation(validationResult);
|
|
570
|
+
}
|
|
571
|
+
onReady?.({ config: { ...data.data } });
|
|
572
|
+
} catch (error) {
|
|
573
|
+
console.error("Failed to load chat widget config:", error);
|
|
574
|
+
} finally {
|
|
575
|
+
setIsConfigLoading(false);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
const getHistoryMessageBySessionId = async (sid) => {
|
|
579
|
+
try {
|
|
580
|
+
const deviceId = getOrCreateDeviceId();
|
|
581
|
+
const response = await fetch(`${PROXY_BASE_URL}/aizek-messages`, {
|
|
582
|
+
method: "GET",
|
|
583
|
+
headers: {
|
|
584
|
+
"Content-Type": "application/json",
|
|
585
|
+
"x-device-id": deviceId,
|
|
586
|
+
"x-session-id": sid,
|
|
587
|
+
"x-alternate": JSON.stringify(headers)
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
const data = await response.json();
|
|
591
|
+
if (!data.success) {
|
|
592
|
+
throw new Error(data.message || "Failed to fetch messages");
|
|
593
|
+
}
|
|
594
|
+
const historyMessages = [];
|
|
595
|
+
if (data.data?.messages && Array.isArray(data.data.messages)) {
|
|
596
|
+
for (const msg of data.data.messages) {
|
|
597
|
+
let textContent = "";
|
|
598
|
+
let uiData = null;
|
|
599
|
+
if (typeof msg.content === "string") {
|
|
600
|
+
textContent = msg.content;
|
|
601
|
+
} else if (Array.isArray(msg.content)) {
|
|
602
|
+
const textParts = [];
|
|
603
|
+
for (const item of msg.content) {
|
|
604
|
+
if (item.type === "text" && item.text) {
|
|
605
|
+
textParts.push(item.text);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
textContent = textParts.join("\n");
|
|
609
|
+
}
|
|
610
|
+
if (textContent) {
|
|
611
|
+
const extracted = extractUIJsonFromText(textContent);
|
|
612
|
+
textContent = extracted.cleanedText;
|
|
613
|
+
uiData = extracted.uiData;
|
|
614
|
+
}
|
|
615
|
+
if (textContent.trim() || uiData) {
|
|
616
|
+
historyMessages.push({
|
|
617
|
+
text: textContent.trim() || void 0,
|
|
618
|
+
ui: uiData,
|
|
619
|
+
role: msg.role === "user" ? "user" : msg.role === "assistant" ? "assistant" : "user",
|
|
620
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return historyMessages;
|
|
626
|
+
} catch (error) {
|
|
627
|
+
console.error("Error fetching message history:", error);
|
|
628
|
+
return [];
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
useEffect(() => {
|
|
632
|
+
onMounted?.();
|
|
633
|
+
loadConfig();
|
|
634
|
+
}, []);
|
|
635
|
+
useEffect(() => {
|
|
636
|
+
const t = setInterval(() => {
|
|
637
|
+
purgeExpiredLocalSessions(setActiveSessionIdState);
|
|
638
|
+
}, 1e3);
|
|
639
|
+
return () => clearInterval(t);
|
|
640
|
+
}, []);
|
|
641
|
+
useEffect(() => {
|
|
642
|
+
if (typeof config?.widget_config.initial_open === "boolean") {
|
|
643
|
+
const open = config.widget_config.initial_open;
|
|
644
|
+
setIsOpen(open);
|
|
645
|
+
if (open) onOpen?.();
|
|
646
|
+
else onClose?.();
|
|
647
|
+
}
|
|
648
|
+
}, [config?.widget_config.initial_open]);
|
|
649
|
+
useEffect(() => {
|
|
650
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
651
|
+
}, [messages]);
|
|
652
|
+
useEffect(() => {
|
|
653
|
+
if (activeSessionId && !isConfigLoading) {
|
|
654
|
+
getHistoryMessageBySessionId(activeSessionId).then((historyMessages) => {
|
|
655
|
+
setMessages(historyMessages);
|
|
656
|
+
}).catch((error) => {
|
|
657
|
+
console.error("Failed to load message history:", error);
|
|
658
|
+
});
|
|
659
|
+
} else if (!activeSessionId) {
|
|
660
|
+
setMessages([]);
|
|
661
|
+
}
|
|
662
|
+
}, [activeSessionId, isConfigLoading]);
|
|
663
|
+
useEffect(() => {
|
|
664
|
+
if (!sessions.length) return;
|
|
665
|
+
const missing = sessions.filter((sid) => !sessionTitleById[sid]);
|
|
666
|
+
if (!missing.length) return;
|
|
667
|
+
let cancelled = false;
|
|
668
|
+
(async () => {
|
|
669
|
+
for (const sid of missing) {
|
|
670
|
+
if (cancelled) return;
|
|
671
|
+
const title = await fetchLastMessageTitle(sid);
|
|
672
|
+
if (cancelled) return;
|
|
673
|
+
if (!title) continue;
|
|
674
|
+
setSessionTitleById((prev) => prev[sid] ? prev : { ...prev, [sid]: title });
|
|
675
|
+
}
|
|
676
|
+
})();
|
|
677
|
+
return () => {
|
|
678
|
+
cancelled = true;
|
|
679
|
+
};
|
|
680
|
+
}, [sessions]);
|
|
681
|
+
const addMessage = (payload) => {
|
|
682
|
+
const newMessage = {
|
|
683
|
+
text: payload.text,
|
|
684
|
+
ui: payload.ui,
|
|
685
|
+
role: payload.role,
|
|
686
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
687
|
+
};
|
|
688
|
+
onMessage?.(newMessage);
|
|
689
|
+
setMessages((prev) => [...prev, newMessage]);
|
|
690
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
691
|
+
return newMessage;
|
|
692
|
+
};
|
|
693
|
+
const sendMessage = async (message, approval) => {
|
|
694
|
+
if (!message.trim() || isLoading) return;
|
|
695
|
+
setMessages((prev) => [
|
|
696
|
+
...prev,
|
|
697
|
+
{ text: message, ui: void 0, role: approval ? "approval" : "user", timestamp: /* @__PURE__ */ new Date() }
|
|
698
|
+
]);
|
|
699
|
+
setIsLoading(true);
|
|
700
|
+
try {
|
|
701
|
+
const deviceId = getOrCreateDeviceId();
|
|
702
|
+
purgeExpiredLocalSessions(setActiveSessionIdState);
|
|
703
|
+
let sid = activeSessionId;
|
|
704
|
+
if (!sid) sid = await createNewSession();
|
|
705
|
+
const response = await fetch(`${PROXY_BASE_URL}/aizek-chat?clientId=${clientId}`, {
|
|
706
|
+
method: "POST",
|
|
707
|
+
headers: {
|
|
708
|
+
"Content-Type": "application/json",
|
|
709
|
+
"x-device-id": deviceId,
|
|
710
|
+
"x-session-id": sid,
|
|
711
|
+
"x-alternate": JSON.stringify(headers)
|
|
712
|
+
},
|
|
713
|
+
body: JSON.stringify({ message })
|
|
714
|
+
});
|
|
715
|
+
if (response.status === 401) {
|
|
716
|
+
const local = readStoredSessions().filter((s) => s.sessionId !== sid);
|
|
717
|
+
writeStoredSessions(local);
|
|
718
|
+
setSessions(local.map((x) => x.sessionId));
|
|
719
|
+
setActiveSessionId(null);
|
|
720
|
+
setActiveSessionIdState(null);
|
|
721
|
+
const newSid = await createNewSession();
|
|
722
|
+
const retry = await fetch(`${PROXY_BASE_URL}/aizek-chat?clientId=${clientId}`, {
|
|
723
|
+
method: "POST",
|
|
724
|
+
headers: {
|
|
725
|
+
"Content-Type": "application/json",
|
|
726
|
+
"x-device-id": deviceId,
|
|
727
|
+
"x-session-id": newSid,
|
|
728
|
+
"x-alternate": JSON.stringify(headers)
|
|
729
|
+
},
|
|
730
|
+
body: JSON.stringify({ message })
|
|
731
|
+
});
|
|
732
|
+
if (!retry.ok) throw new Error(`HTTP error ${retry.status}`);
|
|
733
|
+
const retryJson = await retry.json();
|
|
734
|
+
const text = JSON.stringify(retryJson.data);
|
|
735
|
+
const { cleanedText, uiData } = extractUIJsonFromText(text);
|
|
736
|
+
addMessage({ text: cleanedText, ui: uiData, role: "assistant" });
|
|
737
|
+
touchSession(newSid);
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
if (!response.ok) {
|
|
741
|
+
throw new Error(`HTTP error ${response.status}`);
|
|
742
|
+
}
|
|
743
|
+
if (!response.body) {
|
|
744
|
+
throw new Error("Streaming desteklenmiyor (response.body yok)");
|
|
745
|
+
}
|
|
746
|
+
const reader = response.body.getReader();
|
|
747
|
+
const decoder = new TextDecoder();
|
|
748
|
+
let buffer = "";
|
|
749
|
+
while (true) {
|
|
750
|
+
const { value, done } = await reader.read();
|
|
751
|
+
if (done) break;
|
|
752
|
+
buffer += decoder.decode(value, { stream: true });
|
|
753
|
+
const chunks = buffer.split("\n\n");
|
|
754
|
+
buffer = chunks.pop() ?? "";
|
|
755
|
+
for (const rawChunk of chunks) {
|
|
756
|
+
const line = rawChunk.split("\n").find((l) => l.startsWith("data:"));
|
|
757
|
+
if (!line) continue;
|
|
758
|
+
const jsonStr = line.replace(/^data:\s*/, "").trim();
|
|
759
|
+
if (!jsonStr) continue;
|
|
760
|
+
const event = JSON.parse(jsonStr);
|
|
761
|
+
if (event.type === "assistant_text" && event.content) {
|
|
762
|
+
const { cleanedText, uiData } = extractUIJsonFromText(event.content);
|
|
763
|
+
addMessage({
|
|
764
|
+
text: cleanedText,
|
|
765
|
+
ui: uiData,
|
|
766
|
+
role: "assistant"
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
if (event.type === "assistant_tool_result" && event.content) {
|
|
770
|
+
const toolInfoParsed = JSON.parse(event.content);
|
|
771
|
+
onToolCall?.(toolInfoParsed);
|
|
772
|
+
}
|
|
773
|
+
if (event.type === "error" && event.content) {
|
|
774
|
+
const { cleanedText, uiData } = extractUIJsonFromText(event.content);
|
|
775
|
+
addMessage({
|
|
776
|
+
text: cleanedText,
|
|
777
|
+
ui: uiData,
|
|
778
|
+
role: "assistant"
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
touchSession(sid);
|
|
784
|
+
} catch (error) {
|
|
785
|
+
console.error("Error sending message:", error);
|
|
786
|
+
addMessage({ text: "Sorry, something went wrong. Please try again.", role: "assistant" });
|
|
787
|
+
} finally {
|
|
788
|
+
setIsLoading(false);
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
const disconnectActiveSession = async () => {
|
|
792
|
+
try {
|
|
793
|
+
const deviceId = getOrCreateDeviceId();
|
|
794
|
+
const sid = activeSessionId;
|
|
795
|
+
if (!sid) return;
|
|
796
|
+
await fetch(`${PROXY_BASE_URL}/aizek-disconnect?clientId=${clientId}`, {
|
|
797
|
+
method: "POST",
|
|
798
|
+
headers: {
|
|
799
|
+
"Content-Type": "application/json",
|
|
800
|
+
"x-device-id": deviceId,
|
|
801
|
+
"x-session-id": sid,
|
|
802
|
+
"x-alternate": JSON.stringify(headers)
|
|
803
|
+
},
|
|
804
|
+
body: JSON.stringify({ sessionId: sid })
|
|
805
|
+
});
|
|
806
|
+
const nextStored = readStoredSessions().filter((s) => s.sessionId !== sid);
|
|
807
|
+
writeStoredSessions(nextStored);
|
|
808
|
+
const nextSessions = nextStored.map((x) => x.sessionId);
|
|
809
|
+
setSessions(nextSessions);
|
|
810
|
+
const nextActive = nextSessions[0] ?? null;
|
|
811
|
+
setActiveSessionIdState(nextActive);
|
|
812
|
+
setActiveSessionId(nextActive);
|
|
813
|
+
setMessages([]);
|
|
814
|
+
onDisconnect?.();
|
|
815
|
+
} catch (e) {
|
|
816
|
+
console.error(e);
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
const handleSelectSession = (sid) => {
|
|
820
|
+
setActiveSessionIdState(sid);
|
|
821
|
+
setActiveSessionId(sid);
|
|
822
|
+
setActiveTab("messages");
|
|
823
|
+
setMessageView("detail");
|
|
824
|
+
};
|
|
825
|
+
const getSessionTitle = (sid) => {
|
|
826
|
+
if (sessionTitleById[sid]) return sessionTitleById[sid];
|
|
827
|
+
return "New conversation";
|
|
828
|
+
};
|
|
829
|
+
const fetchLastMessageTitle = async (sid) => {
|
|
830
|
+
try {
|
|
831
|
+
const deviceId = getOrCreateDeviceId();
|
|
832
|
+
const res = await fetch(`${PROXY_BASE_URL}/aizek-last-message`, {
|
|
833
|
+
method: "GET",
|
|
834
|
+
headers: {
|
|
835
|
+
"Content-Type": "application/json",
|
|
836
|
+
"x-device-id": deviceId,
|
|
837
|
+
"x-session-id": sid,
|
|
838
|
+
"x-alternate": JSON.stringify(headers)
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
const json = await res.json();
|
|
842
|
+
if (!json?.success) return null;
|
|
843
|
+
const last = json?.data?.lastMessage;
|
|
844
|
+
if (!last) return null;
|
|
845
|
+
let textContent = "";
|
|
846
|
+
if (typeof last.content === "string") {
|
|
847
|
+
textContent = last.content;
|
|
848
|
+
} else if (Array.isArray(last.content)) {
|
|
849
|
+
const parts = [];
|
|
850
|
+
for (const item of last.content) {
|
|
851
|
+
if (item?.type === "text" && typeof item.text === "string") parts.push(item.text);
|
|
852
|
+
}
|
|
853
|
+
textContent = parts.join("\n");
|
|
854
|
+
}
|
|
855
|
+
if (!textContent.trim()) return null;
|
|
856
|
+
const extracted = extractUIJsonFromText(textContent);
|
|
857
|
+
const cleaned = (extracted.cleanedText || "").trim();
|
|
858
|
+
const firstLine = (cleaned.split("\n").find((l) => l.trim()) || "").trim();
|
|
859
|
+
const title = firstLine || cleaned;
|
|
860
|
+
if (!title) return null;
|
|
861
|
+
const compact = title.length > 46 ? `${title.slice(0, 46).trim()}\u2026` : title;
|
|
862
|
+
return compact;
|
|
863
|
+
} catch (e) {
|
|
864
|
+
console.error("Failed to fetch last message title:", e);
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
const toggleChat = () => {
|
|
869
|
+
const newIsOpen = !isOpen;
|
|
870
|
+
setIsOpen(newIsOpen);
|
|
871
|
+
if (newIsOpen) onOpen?.();
|
|
872
|
+
else onClose?.();
|
|
873
|
+
};
|
|
874
|
+
const clean = sanitizeHtml(config?.widget_config.welcome_message ?? "", {
|
|
875
|
+
allowedTags: ["b", "i", "em", "strong", "a", "p", "br"],
|
|
876
|
+
allowedAttributes: {
|
|
877
|
+
a: ["href", "target", "rel"]
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isConfigLoading ? /* @__PURE__ */ jsx(
|
|
881
|
+
"button",
|
|
882
|
+
{
|
|
883
|
+
className: "floating-button bottom-right button-sizes medium loading-state",
|
|
884
|
+
style: { background: "#4f46e5" },
|
|
885
|
+
"aria-label": "Loading",
|
|
886
|
+
children: /* @__PURE__ */ jsx("div", { className: "loading-spinner" })
|
|
887
|
+
}
|
|
888
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
889
|
+
isOpen && /* @__PURE__ */ jsx("div", { className: `overlay floating-chat-overlay ${isOpen ? "is-open" : ""}`, onClick: toggleChat }),
|
|
890
|
+
/* @__PURE__ */ jsx(
|
|
891
|
+
"div",
|
|
892
|
+
{
|
|
893
|
+
className: `chat-container ${config?.widget_config.button_position} ${isOpen ? "is-open" : ""}`,
|
|
894
|
+
style: { width: config?.widget_config.chat_width, height: config?.widget_config.chat_height },
|
|
895
|
+
children: /* @__PURE__ */ jsxs("div", { className: "chatbot-container", children: [
|
|
896
|
+
/* @__PURE__ */ jsxs("div", { className: "header", style: { background: config?.widget_config.header_background }, children: [
|
|
897
|
+
/* @__PURE__ */ jsx("div", { className: "logo-container", children: config?.widget_config.company_logo ? config?.widget_config.company_logo.startsWith("http") || config?.widget_config.company_logo.startsWith("data:") ? /* @__PURE__ */ jsx("img", { src: config?.widget_config.company_logo, alt: "Company Logo", className: "logo-image" }) : /* @__PURE__ */ jsx("span", { className: "logo-text", children: config?.widget_config.company_logo }) : "\u{1F916}" }),
|
|
898
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
899
|
+
/* @__PURE__ */ jsx("h3", { className: "company-name", children: config?.widget_config.company_name }),
|
|
900
|
+
/* @__PURE__ */ jsx("p", { className: "status-text", children: isLoading ? "Typing..." : "Online" })
|
|
901
|
+
] })
|
|
902
|
+
] }),
|
|
903
|
+
/* @__PURE__ */ jsxs("div", { className: "chat-content", children: [
|
|
904
|
+
activeTab === "home" && /* @__PURE__ */ jsxs("div", { className: "home-panel", children: [
|
|
905
|
+
/* @__PURE__ */ jsx("p", { className: "eyebrow", children: "Welcome" }),
|
|
906
|
+
/* @__PURE__ */ jsx("h3", { className: "panel-title", children: config?.widget_config.company_name }),
|
|
907
|
+
/* @__PURE__ */ jsx("p", { className: "panel-subtitle", children: "Ask anything. We keep your history and respond instantly." }),
|
|
908
|
+
/* @__PURE__ */ jsxs("div", { className: "home-actions", children: [
|
|
909
|
+
/* @__PURE__ */ jsx(
|
|
910
|
+
"button",
|
|
911
|
+
{
|
|
912
|
+
className: "primary-button",
|
|
913
|
+
onClick: async () => {
|
|
914
|
+
try {
|
|
915
|
+
await createNewSession();
|
|
916
|
+
} catch (e) {
|
|
917
|
+
console.error(e);
|
|
918
|
+
}
|
|
919
|
+
},
|
|
920
|
+
disabled: isLoading || sessions.length >= MAX_SESSIONS,
|
|
921
|
+
children: "Start a new conversation"
|
|
922
|
+
}
|
|
923
|
+
),
|
|
924
|
+
/* @__PURE__ */ jsx(
|
|
925
|
+
"button",
|
|
926
|
+
{
|
|
927
|
+
className: "ghost-button",
|
|
928
|
+
onClick: () => {
|
|
929
|
+
setActiveTab("messages");
|
|
930
|
+
setMessageView("list");
|
|
931
|
+
},
|
|
932
|
+
children: "View conversations"
|
|
933
|
+
}
|
|
934
|
+
)
|
|
935
|
+
] })
|
|
936
|
+
] }),
|
|
937
|
+
activeTab === "messages" && /* @__PURE__ */ jsx(Fragment, { children: messageView === "list" ? /* @__PURE__ */ jsxs("div", { className: "conversation-list", children: [
|
|
938
|
+
/* @__PURE__ */ jsxs("div", { className: "list-header", children: [
|
|
939
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
940
|
+
/* @__PURE__ */ jsx("p", { className: "eyebrow", children: "Conversations" }),
|
|
941
|
+
/* @__PURE__ */ jsx("h4", { className: "panel-title", children: "Inbox" })
|
|
942
|
+
] }),
|
|
943
|
+
/* @__PURE__ */ jsx(
|
|
944
|
+
"button",
|
|
945
|
+
{
|
|
946
|
+
className: "session-new-button",
|
|
947
|
+
onClick: async () => {
|
|
948
|
+
try {
|
|
949
|
+
await createNewSession();
|
|
950
|
+
} catch (e) {
|
|
951
|
+
console.error(e);
|
|
952
|
+
}
|
|
953
|
+
},
|
|
954
|
+
disabled: sessions.length >= MAX_SESSIONS,
|
|
955
|
+
children: /* @__PURE__ */ jsx("span", { children: "+ New" })
|
|
956
|
+
}
|
|
957
|
+
)
|
|
958
|
+
] }),
|
|
959
|
+
sessions.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "empty-list", children: [
|
|
960
|
+
/* @__PURE__ */ jsx("div", { className: "empty-state-icon", children: "\u{1F4AC}" }),
|
|
961
|
+
/* @__PURE__ */ jsx("h4", { className: "empty-state-title", children: "No conversations yet" }),
|
|
962
|
+
/* @__PURE__ */ jsx("p", { className: "empty-state-description", children: "Start a new conversation to see it appear here." })
|
|
963
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "conversation-items", children: sessions.map((sid) => /* @__PURE__ */ jsxs(
|
|
964
|
+
"button",
|
|
965
|
+
{
|
|
966
|
+
className: `conversation-item ${sid === activeSessionId ? "active" : ""}`,
|
|
967
|
+
onClick: () => handleSelectSession(sid),
|
|
968
|
+
children: [
|
|
969
|
+
/* @__PURE__ */ jsxs("div", { className: "conversation-meta", children: [
|
|
970
|
+
/* @__PURE__ */ jsx("p", { className: "conversation-title", children: getSessionTitle(sid) }),
|
|
971
|
+
/* @__PURE__ */ jsxs("p", { className: "conversation-sub", children: [
|
|
972
|
+
"Session ID: ",
|
|
973
|
+
sid.slice(0, 8),
|
|
974
|
+
"..."
|
|
975
|
+
] })
|
|
976
|
+
] }),
|
|
977
|
+
/* @__PURE__ */ jsx("span", { className: "conversation-pill", children: "Open" })
|
|
978
|
+
]
|
|
979
|
+
},
|
|
980
|
+
sid
|
|
981
|
+
)) })
|
|
982
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "conversation-detail", children: [
|
|
983
|
+
/* @__PURE__ */ jsxs("div", { className: "detail-header", children: [
|
|
984
|
+
/* @__PURE__ */ jsx("div", { className: "detail-header-left", children: /* @__PURE__ */ jsx("button", { className: "icon-button", onClick: () => setMessageView("list"), "aria-label": "Back", children: /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
|
|
985
|
+
"path",
|
|
986
|
+
{
|
|
987
|
+
d: "M15 18l-6-6 6-6",
|
|
988
|
+
stroke: "currentColor",
|
|
989
|
+
strokeWidth: "2",
|
|
990
|
+
strokeLinecap: "round",
|
|
991
|
+
strokeLinejoin: "round"
|
|
992
|
+
}
|
|
993
|
+
) }) }) }),
|
|
994
|
+
/* @__PURE__ */ jsxs("div", { className: "detail-header-center", children: [
|
|
995
|
+
/* @__PURE__ */ jsx("div", { className: "detail-avatar", "aria-hidden": "true", children: /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
|
|
996
|
+
"path",
|
|
997
|
+
{
|
|
998
|
+
d: "M12 3c-4.418 0-8 3.134-8 7 0 2.382 1.362 4.486 3.5 5.737V21l4.07-2.13c.14.008.283.013.43.013 4.418 0 8-3.134 8-7s-3.582-7-8-7z",
|
|
999
|
+
stroke: "currentColor",
|
|
1000
|
+
strokeWidth: "2",
|
|
1001
|
+
strokeLinejoin: "round"
|
|
1002
|
+
}
|
|
1003
|
+
) }) }),
|
|
1004
|
+
/* @__PURE__ */ jsxs("div", { className: "detail-title", children: [
|
|
1005
|
+
/* @__PURE__ */ jsxs("div", { className: "detail-title-row", children: [
|
|
1006
|
+
/* @__PURE__ */ jsx("strong", { className: "detail-title-text", children: activeSessionId ? getSessionTitle(activeSessionId) : "Chat" }),
|
|
1007
|
+
/* @__PURE__ */ jsx("span", { className: `status-dot ${isLoading ? "typing" : "online"}`, "aria-hidden": "true" })
|
|
1008
|
+
] }),
|
|
1009
|
+
/* @__PURE__ */ jsx("p", { className: "detail-subtitle", children: isLoading ? "Yaz\u0131yor\u2026" : "Online" })
|
|
1010
|
+
] })
|
|
1011
|
+
] }),
|
|
1012
|
+
/* @__PURE__ */ jsxs("div", { className: "detail-header-right", children: [
|
|
1013
|
+
/* @__PURE__ */ jsx(
|
|
1014
|
+
"button",
|
|
1015
|
+
{
|
|
1016
|
+
className: "icon-button",
|
|
1017
|
+
onClick: () => {
|
|
1018
|
+
setActiveTab("info");
|
|
1019
|
+
setMessageView("list");
|
|
1020
|
+
},
|
|
1021
|
+
"aria-label": "Bilgi",
|
|
1022
|
+
children: /* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: [
|
|
1023
|
+
/* @__PURE__ */ jsx(
|
|
1024
|
+
"path",
|
|
1025
|
+
{
|
|
1026
|
+
d: "M12 17v-6",
|
|
1027
|
+
stroke: "currentColor",
|
|
1028
|
+
strokeWidth: "2",
|
|
1029
|
+
strokeLinecap: "round"
|
|
1030
|
+
}
|
|
1031
|
+
),
|
|
1032
|
+
/* @__PURE__ */ jsx(
|
|
1033
|
+
"path",
|
|
1034
|
+
{
|
|
1035
|
+
d: "M12 8h.01",
|
|
1036
|
+
stroke: "currentColor",
|
|
1037
|
+
strokeWidth: "2.5",
|
|
1038
|
+
strokeLinecap: "round"
|
|
1039
|
+
}
|
|
1040
|
+
),
|
|
1041
|
+
/* @__PURE__ */ jsx(
|
|
1042
|
+
"circle",
|
|
1043
|
+
{
|
|
1044
|
+
cx: "12",
|
|
1045
|
+
cy: "12",
|
|
1046
|
+
r: "9",
|
|
1047
|
+
stroke: "currentColor",
|
|
1048
|
+
strokeWidth: "2"
|
|
1049
|
+
}
|
|
1050
|
+
)
|
|
1051
|
+
] })
|
|
1052
|
+
}
|
|
1053
|
+
),
|
|
1054
|
+
/* @__PURE__ */ jsx(
|
|
1055
|
+
"button",
|
|
1056
|
+
{
|
|
1057
|
+
className: "icon-button danger",
|
|
1058
|
+
onClick: disconnectActiveSession,
|
|
1059
|
+
disabled: !activeSessionId,
|
|
1060
|
+
"aria-label": "End conversation",
|
|
1061
|
+
children: /* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: [
|
|
1062
|
+
/* @__PURE__ */ jsx(
|
|
1063
|
+
"path",
|
|
1064
|
+
{
|
|
1065
|
+
d: "M3 6h18",
|
|
1066
|
+
stroke: "currentColor",
|
|
1067
|
+
strokeWidth: "2",
|
|
1068
|
+
strokeLinecap: "round"
|
|
1069
|
+
}
|
|
1070
|
+
),
|
|
1071
|
+
/* @__PURE__ */ jsx(
|
|
1072
|
+
"path",
|
|
1073
|
+
{
|
|
1074
|
+
d: "M8 6V4h8v2",
|
|
1075
|
+
stroke: "currentColor",
|
|
1076
|
+
strokeWidth: "2",
|
|
1077
|
+
strokeLinejoin: "round"
|
|
1078
|
+
}
|
|
1079
|
+
),
|
|
1080
|
+
/* @__PURE__ */ jsx(
|
|
1081
|
+
"path",
|
|
1082
|
+
{
|
|
1083
|
+
d: "M6 6l1 16h10l1-16",
|
|
1084
|
+
stroke: "currentColor",
|
|
1085
|
+
strokeWidth: "2",
|
|
1086
|
+
strokeLinejoin: "round"
|
|
1087
|
+
}
|
|
1088
|
+
)
|
|
1089
|
+
] })
|
|
1090
|
+
}
|
|
1091
|
+
)
|
|
1092
|
+
] })
|
|
1093
|
+
] }),
|
|
1094
|
+
/* @__PURE__ */ jsxs("div", { className: "messages-container", children: [
|
|
1095
|
+
/* @__PURE__ */ jsx(HeaderAlert, { headerValidation, setShowAlert, showAlert }),
|
|
1096
|
+
messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "empty-state", children: /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: clean } }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1097
|
+
messages.map((message, index) => /* @__PURE__ */ jsx(MessageBubble, { message, onAction: sendMessage }, index)),
|
|
1098
|
+
config?.widget_config.show_typing_indicator && isLoading && /* @__PURE__ */ jsx(TypingDots, {})
|
|
1099
|
+
] }),
|
|
1100
|
+
/* @__PURE__ */ jsx("div", { ref: messagesEndRef })
|
|
1101
|
+
] }),
|
|
1102
|
+
/* @__PURE__ */ jsx(
|
|
1103
|
+
ChatInput,
|
|
1104
|
+
{
|
|
1105
|
+
handleSendMessage: sendMessage,
|
|
1106
|
+
isLoading,
|
|
1107
|
+
placeholder: config?.widget_config.placeholder ?? ""
|
|
1108
|
+
}
|
|
1109
|
+
)
|
|
1110
|
+
] }) }),
|
|
1111
|
+
activeTab === "info" && /* @__PURE__ */ jsxs("div", { className: "info-panel", children: [
|
|
1112
|
+
/* @__PURE__ */ jsx("p", { className: "eyebrow", children: "Info" }),
|
|
1113
|
+
/* @__PURE__ */ jsx("h4", { className: "panel-title", children: "Widget Details" }),
|
|
1114
|
+
/* @__PURE__ */ jsxs("ul", { className: "info-list", children: [
|
|
1115
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
1116
|
+
/* @__PURE__ */ jsx("span", { children: "Company" }),
|
|
1117
|
+
/* @__PURE__ */ jsx("strong", { children: config?.widget_config.company_name })
|
|
1118
|
+
] }),
|
|
1119
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
1120
|
+
/* @__PURE__ */ jsx("span", { children: "Status" }),
|
|
1121
|
+
/* @__PURE__ */ jsx("strong", { children: isLoading ? "Typing..." : "Online" })
|
|
1122
|
+
] }),
|
|
1123
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
1124
|
+
/* @__PURE__ */ jsx("span", { children: "Conversations" }),
|
|
1125
|
+
/* @__PURE__ */ jsx("strong", { children: sessions.length })
|
|
1126
|
+
] })
|
|
1127
|
+
] })
|
|
1128
|
+
] })
|
|
1129
|
+
] }),
|
|
1130
|
+
/* @__PURE__ */ jsxs("div", { className: "bottom-nav", children: [
|
|
1131
|
+
/* @__PURE__ */ jsx(
|
|
1132
|
+
"button",
|
|
1133
|
+
{
|
|
1134
|
+
className: `nav-button ${activeTab === "home" ? "active" : ""}`,
|
|
1135
|
+
onClick: () => {
|
|
1136
|
+
setActiveTab("home");
|
|
1137
|
+
setMessageView("list");
|
|
1138
|
+
},
|
|
1139
|
+
children: "Home"
|
|
1140
|
+
}
|
|
1141
|
+
),
|
|
1142
|
+
/* @__PURE__ */ jsx(
|
|
1143
|
+
"button",
|
|
1144
|
+
{
|
|
1145
|
+
className: `nav-button ${activeTab === "messages" ? "active" : ""}`,
|
|
1146
|
+
onClick: () => {
|
|
1147
|
+
setActiveTab("messages");
|
|
1148
|
+
setMessageView("list");
|
|
1149
|
+
},
|
|
1150
|
+
children: "Messages"
|
|
1151
|
+
}
|
|
1152
|
+
),
|
|
1153
|
+
/* @__PURE__ */ jsx(
|
|
1154
|
+
"button",
|
|
1155
|
+
{
|
|
1156
|
+
className: `nav-button ${activeTab === "info" ? "active" : ""}`,
|
|
1157
|
+
onClick: () => {
|
|
1158
|
+
setActiveTab("info");
|
|
1159
|
+
setMessageView("list");
|
|
1160
|
+
},
|
|
1161
|
+
children: "Info"
|
|
1162
|
+
}
|
|
1163
|
+
)
|
|
1164
|
+
] })
|
|
1165
|
+
] })
|
|
1166
|
+
}
|
|
1167
|
+
),
|
|
1168
|
+
/* @__PURE__ */ jsx(
|
|
1169
|
+
"button",
|
|
1170
|
+
{
|
|
1171
|
+
onClick: toggleChat,
|
|
1172
|
+
className: `floating-button ${config?.widget_config.button_position} button-sizes ${config?.widget_config.button_size} ${isOpen ? "is-open" : ""}`,
|
|
1173
|
+
style: { background: config?.widget_config.button_background },
|
|
1174
|
+
children: isOpen ? /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", 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" }) }) : /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", 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" }) })
|
|
1175
|
+
}
|
|
1176
|
+
)
|
|
1177
|
+
] }) });
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
export { AizekChatBot };
|
|
1181
|
+
//# sourceMappingURL=index.mjs.map
|
|
1182
|
+
//# sourceMappingURL=index.mjs.map
|