@locdo.tech/botiq-chat-sdk 0.3.2 → 0.3.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/sdk/index.js +1 -1
- package/dist/sdk/{npm-CHWKiGUF.js → npm-BHJnX0sn.js} +254 -142
- package/dist/sdk/react.js +1 -1
- package/dist/sdk/vue.js +1 -1
- package/package.json +6 -1
package/dist/sdk/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./npm-
|
|
1
|
+
import { t as e } from "./npm-BHJnX0sn.js";
|
|
2
2
|
export { e as init };
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
//#region src/core/config.ts
|
|
2
2
|
var e = "https://bot-q-backend.vercel.app", t = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
placeholder: ""
|
|
23
|
-
},
|
|
24
|
-
font: "inter"
|
|
3
|
+
colors: {
|
|
4
|
+
primary: "#F97316",
|
|
5
|
+
header: "#F97316",
|
|
6
|
+
userBubble: "#F97316",
|
|
7
|
+
botBubble: "#1A1A1A",
|
|
8
|
+
background: "#000000",
|
|
9
|
+
text: "#FFFFFF",
|
|
10
|
+
inputBackground: "#1A1A1A"
|
|
11
|
+
},
|
|
12
|
+
layout: {
|
|
13
|
+
position: "bottom-right",
|
|
14
|
+
buttonShape: "circle",
|
|
15
|
+
width: 360,
|
|
16
|
+
height: 520
|
|
17
|
+
},
|
|
18
|
+
content: {
|
|
19
|
+
greeting: "",
|
|
20
|
+
suggestionChips: [],
|
|
21
|
+
placeholder: ""
|
|
25
22
|
},
|
|
23
|
+
font: "inter"
|
|
24
|
+
}, n = {
|
|
25
|
+
name: "BotIQ",
|
|
26
|
+
design: t,
|
|
26
27
|
widgetLanguage: "vi"
|
|
27
|
-
},
|
|
28
|
+
}, r = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/, i = new Set(["bottom-right", "bottom-left"]), a = new Set(["circle", "square"]), o = new Set([
|
|
28
29
|
"inter",
|
|
29
30
|
"plus-jakarta",
|
|
30
31
|
"poppins",
|
|
@@ -33,54 +34,74 @@ var e = "https://bot-q-backend.vercel.app", t = {
|
|
|
33
34
|
"raleway",
|
|
34
35
|
"lato",
|
|
35
36
|
"playfair"
|
|
36
|
-
]),
|
|
37
|
+
]), s = new Set([
|
|
37
38
|
"none",
|
|
38
39
|
"fade",
|
|
39
40
|
"slide-up",
|
|
40
41
|
"bounce"
|
|
41
|
-
]),
|
|
42
|
+
]), c = new Set([
|
|
42
43
|
"dots-bounce",
|
|
43
44
|
"dots-pulse",
|
|
44
45
|
"bar"
|
|
45
46
|
]);
|
|
46
|
-
function
|
|
47
|
+
function l(e) {
|
|
47
48
|
let t = e.colors;
|
|
48
|
-
if (![
|
|
49
|
+
if (t.inputBackground ||= "#1A1A1A", ![
|
|
49
50
|
t.primary,
|
|
50
51
|
t.header,
|
|
51
52
|
t.userBubble,
|
|
52
53
|
t.botBubble,
|
|
53
54
|
t.background,
|
|
54
|
-
t.text
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
t.text,
|
|
56
|
+
t.inputBackground
|
|
57
|
+
].every((e) => typeof e == "string" && r.test(e)) || !i.has(e.layout.position) || !a.has(e.layout.buttonShape) || !o.has(e.font)) return !1;
|
|
58
|
+
let { width: n, height: l } = e.layout;
|
|
59
|
+
if (!Number.isFinite(n) || n < 280 || n > 800 || !Number.isFinite(l) || l < 200 || l > 900) return !1;
|
|
58
60
|
if (e.gradient) {
|
|
59
61
|
let t = e.gradient;
|
|
60
|
-
if (t.type !== "linear" && t.type !== "radial" || !
|
|
62
|
+
if (t.type !== "linear" && t.type !== "radial" || !r.test(t.from) || !r.test(t.to) || t.angle !== void 0 && (!Number.isFinite(t.angle) || t.angle < 0 || t.angle > 360)) return !1;
|
|
61
63
|
}
|
|
62
|
-
return !(e.animation && (!
|
|
64
|
+
return !(e.animation && (!s.has(e.animation.bubbleOpen) || !c.has(e.animation.typingIndicator)) || e.customCSS !== void 0 && (typeof e.customCSS != "string" || e.customCSS.length > 8e3));
|
|
65
|
+
}
|
|
66
|
+
var u = 8e3;
|
|
67
|
+
function d(e, t) {
|
|
68
|
+
return fetch(`${t}/widget/meta`, {
|
|
69
|
+
headers: { "X-Api-Key": e },
|
|
70
|
+
referrerPolicy: "no-referrer-when-downgrade",
|
|
71
|
+
signal: AbortSignal.timeout(u)
|
|
72
|
+
});
|
|
63
73
|
}
|
|
64
|
-
async function
|
|
74
|
+
async function f(e, r) {
|
|
75
|
+
let i;
|
|
65
76
|
try {
|
|
66
|
-
|
|
67
|
-
headers: { "X-Api-Key": e },
|
|
68
|
-
signal: AbortSignal.timeout(5e3)
|
|
69
|
-
});
|
|
70
|
-
if (!r.ok) return t;
|
|
71
|
-
let i = await r.json();
|
|
72
|
-
if (!i?.design?.colors || !i?.design?.layout || !i?.design?.content || !c(i.design)) return t;
|
|
73
|
-
let a = typeof i.name == "string" && i.name.length > 0 ? i.name : "BotIQ", o = i.widgetLanguage === "en" ? "en" : "vi";
|
|
74
|
-
return {
|
|
75
|
-
name: a,
|
|
76
|
-
design: i.design,
|
|
77
|
-
widgetLanguage: o
|
|
78
|
-
};
|
|
77
|
+
i = await d(e, r);
|
|
79
78
|
} catch {
|
|
80
|
-
|
|
79
|
+
try {
|
|
80
|
+
i = await d(e, r);
|
|
81
|
+
} catch {
|
|
82
|
+
return n;
|
|
83
|
+
}
|
|
81
84
|
}
|
|
85
|
+
if (i.status === 401 || i.status === 403) return null;
|
|
86
|
+
if (!i.ok) return n;
|
|
87
|
+
let a;
|
|
88
|
+
try {
|
|
89
|
+
a = await i.json();
|
|
90
|
+
} catch {
|
|
91
|
+
return n;
|
|
92
|
+
}
|
|
93
|
+
let o = typeof a.name == "string" && a.name.length > 0 ? a.name : n.name, s = a.widgetLanguage === "en" ? "en" : "vi";
|
|
94
|
+
return !a.design?.colors || !a.design?.layout || !a.design?.content || !l(a.design) ? {
|
|
95
|
+
name: o,
|
|
96
|
+
design: t,
|
|
97
|
+
widgetLanguage: s
|
|
98
|
+
} : {
|
|
99
|
+
name: o,
|
|
100
|
+
design: a.design,
|
|
101
|
+
widgetLanguage: s
|
|
102
|
+
};
|
|
82
103
|
}
|
|
83
|
-
function
|
|
104
|
+
function p(t) {
|
|
84
105
|
return {
|
|
85
106
|
apiKey: t.apiKey,
|
|
86
107
|
apiUrl: e
|
|
@@ -88,32 +109,38 @@ function u(t) {
|
|
|
88
109
|
}
|
|
89
110
|
//#endregion
|
|
90
111
|
//#region src/core/session.ts
|
|
91
|
-
var
|
|
92
|
-
function
|
|
112
|
+
var m = "botiq:sessionId", h = "botiq:sessionId:", g = "botiq:history:", _ = 10;
|
|
113
|
+
function v() {
|
|
114
|
+
try {
|
|
115
|
+
let e = localStorage.getItem(m);
|
|
116
|
+
localStorage.removeItem(m), e && localStorage.removeItem(g + e);
|
|
117
|
+
} catch {}
|
|
118
|
+
}
|
|
119
|
+
function y(e) {
|
|
93
120
|
try {
|
|
94
|
-
let e = localStorage.getItem(
|
|
95
|
-
return
|
|
121
|
+
let t = h + e, n = localStorage.getItem(t);
|
|
122
|
+
return n || (n = crypto.randomUUID(), localStorage.setItem(t, n)), n;
|
|
96
123
|
} catch {
|
|
97
124
|
return crypto.randomUUID();
|
|
98
125
|
}
|
|
99
126
|
}
|
|
100
|
-
function
|
|
127
|
+
function b(e, t) {
|
|
101
128
|
try {
|
|
102
|
-
let
|
|
103
|
-
return
|
|
129
|
+
let n = localStorage.getItem(`${g}${e}:${t}`);
|
|
130
|
+
return n ? JSON.parse(n) : [];
|
|
104
131
|
} catch {
|
|
105
132
|
return [];
|
|
106
133
|
}
|
|
107
134
|
}
|
|
108
|
-
function
|
|
135
|
+
function x(e, t, n) {
|
|
109
136
|
try {
|
|
110
|
-
let
|
|
111
|
-
localStorage.setItem(
|
|
137
|
+
let r = [...b(e, t), ...n].slice(-_);
|
|
138
|
+
localStorage.setItem(`${g}${e}:${t}`, JSON.stringify(r));
|
|
112
139
|
} catch {}
|
|
113
140
|
}
|
|
114
141
|
//#endregion
|
|
115
142
|
//#region src/core/api.ts
|
|
116
|
-
async function
|
|
143
|
+
async function S(e, t, n, r, i, a) {
|
|
117
144
|
try {
|
|
118
145
|
let o = await fetch(`${e}/widget/chat`, {
|
|
119
146
|
method: "POST",
|
|
@@ -121,6 +148,7 @@ async function _(e, t, n, r, i, a) {
|
|
|
121
148
|
"Content-Type": "application/json",
|
|
122
149
|
"X-Api-Key": t
|
|
123
150
|
},
|
|
151
|
+
referrerPolicy: "no-referrer-when-downgrade",
|
|
124
152
|
body: JSON.stringify({
|
|
125
153
|
sessionId: n,
|
|
126
154
|
message: r,
|
|
@@ -134,28 +162,28 @@ async function _(e, t, n, r, i, a) {
|
|
|
134
162
|
}
|
|
135
163
|
//#endregion
|
|
136
164
|
//#region src/core/state.ts
|
|
137
|
-
var
|
|
165
|
+
var C = {
|
|
138
166
|
messages: [],
|
|
139
167
|
isLoading: !1,
|
|
140
168
|
isOpen: !1
|
|
141
|
-
},
|
|
142
|
-
function
|
|
143
|
-
return
|
|
169
|
+
}, w = /* @__PURE__ */ new Set();
|
|
170
|
+
function T() {
|
|
171
|
+
return C;
|
|
144
172
|
}
|
|
145
|
-
function
|
|
146
|
-
Object.assign(
|
|
173
|
+
function E(e) {
|
|
174
|
+
Object.assign(C, e);
|
|
147
175
|
let t = {
|
|
148
|
-
...
|
|
149
|
-
messages: [...
|
|
176
|
+
...C,
|
|
177
|
+
messages: [...C.messages]
|
|
150
178
|
};
|
|
151
|
-
|
|
179
|
+
w.forEach((e) => e(t));
|
|
152
180
|
}
|
|
153
|
-
function
|
|
154
|
-
return
|
|
181
|
+
function D(e) {
|
|
182
|
+
return w.add(e), () => w.delete(e);
|
|
155
183
|
}
|
|
156
184
|
//#endregion
|
|
157
185
|
//#region src/core/styles.ts
|
|
158
|
-
var
|
|
186
|
+
var O = {
|
|
159
187
|
inter: {
|
|
160
188
|
url: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap",
|
|
161
189
|
family: "'Inter', system-ui, -apple-system, sans-serif"
|
|
@@ -189,20 +217,20 @@ var C = {
|
|
|
189
217
|
family: "'Playfair Display', Georgia, serif"
|
|
190
218
|
}
|
|
191
219
|
};
|
|
192
|
-
function
|
|
220
|
+
function k(e, t) {
|
|
193
221
|
if (!t) return e;
|
|
194
222
|
let n = t.angle ?? 135;
|
|
195
223
|
return t.type === "linear" ? `linear-gradient(${n}deg, ${t.from}, ${t.to})` : `radial-gradient(circle, ${t.from}, ${t.to})`;
|
|
196
224
|
}
|
|
197
|
-
function
|
|
225
|
+
function A(e) {
|
|
198
226
|
return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\\[0-9a-fA-F]{1,6}\s?/g, "x").replace(/@import\b[^;]*;?/gi, "").replace(/url\s*\(\s*["']?\s*(?!data:)[^)]*["']?\s*\)/gi, "url(\"\")").replace(/expression\s*\(/gi, "expression_(").replace(/javascript\s*:/gi, "blocked:").replace(/-moz-binding\s*:/gi, "").replace(/\bbehavior\s*:/gi, "");
|
|
199
227
|
}
|
|
200
|
-
function
|
|
228
|
+
function j(e) {
|
|
201
229
|
let t = e?.bubbleOpen ?? "none", n = e?.typingIndicator ?? "dots-bounce";
|
|
202
230
|
return [t === "fade" ? "@keyframes biq-open-fade { from { opacity: 0; } to { opacity: 1; } }\n.chat-window.open { animation: biq-open-fade .22s ease forwards; }" : t === "slide-up" ? "@keyframes biq-open-slide { from { opacity: 0; transform: scale(1) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }\n.chat-window.open { animation: biq-open-slide .25s cubic-bezier(.22,1,.36,1) forwards; }" : t === "bounce" ? "@keyframes biq-open-bounce { 0% { opacity: 0; transform: scale(.85) translateY(8px); } 60% { transform: scale(1.03) translateY(-3px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }\n.chat-window.open { animation: biq-open-bounce .35s cubic-bezier(.34,1.56,.64,1) forwards; }" : "", n === "dots-pulse" ? "@keyframes biq-pulse { 0%, 100% { opacity: 0.3; transform: scale(1); } 50% { opacity: 1; transform: scale(1.3); } }\n.typing span { animation: biq-pulse 1.2s infinite ease-in-out; }" : n === "bar" ? ".typing { gap: 3px; align-items: flex-end; }\n.typing span { width: 3px; height: 14px; border-radius: 2px; animation: biq-bar 1s infinite ease-in-out; }\n.typing span:nth-child(1) { animation-delay: 0s; }\n.typing span:nth-child(2) { animation-delay: .15s; height: 20px; }\n.typing span:nth-child(3) { animation-delay: .3s; }\n@keyframes biq-bar { 0%, 100% { transform: scaleY(.4); opacity: .5; } 50% { transform: scaleY(1); opacity: 1; } }" : ""].filter(Boolean).join("\n");
|
|
203
231
|
}
|
|
204
|
-
function
|
|
205
|
-
let { colors: t, layout: n, font: r, gradient: i, animation: a, customCSS: o, whiteLabel: s } = e, c =
|
|
232
|
+
function M(e) {
|
|
233
|
+
let { colors: t, layout: n, font: r, gradient: i, animation: a, customCSS: o, whiteLabel: s } = e, c = O[r] ?? O.inter, l = n.buttonShape === "square" ? "14px" : "50%", u = n.position === "bottom-left" ? "right: auto; left: 24px;" : "right: 24px;", d = n.position === "bottom-left" ? "bottom left" : "bottom right", f = n.position === "bottom-left" ? "right: auto; left: 0;" : "right: 0;", p = k(t.primary, i), m = k(t.header, i), h = k(t.userBubble, i), g = s ? ".botiq-badge { display: none !important; }" : "";
|
|
206
234
|
return `
|
|
207
235
|
@import url('${c.url}');
|
|
208
236
|
|
|
@@ -219,6 +247,7 @@ function D(e) {
|
|
|
219
247
|
--color-bot: ${t.botBubble};
|
|
220
248
|
--color-bg: ${t.background};
|
|
221
249
|
--color-text: ${t.text};
|
|
250
|
+
--color-input-bg: ${t.inputBackground};
|
|
222
251
|
--gray-50: #1A1A1A;
|
|
223
252
|
--gray-100: #222222;
|
|
224
253
|
--gray-200: #2D2D2D;
|
|
@@ -354,21 +383,60 @@ function D(e) {
|
|
|
354
383
|
|
|
355
384
|
.message { display: flex; flex-direction: column; max-width: 82%; }
|
|
356
385
|
.message.user { align-self: flex-end; align-items: flex-end; }
|
|
357
|
-
.message.assistant { align-self: flex-start; align-items: flex-start; }
|
|
386
|
+
.message.assistant { align-self: flex-start; align-items: flex-start; max-width: 92%; }
|
|
358
387
|
|
|
359
388
|
.message-bubble {
|
|
360
389
|
padding: 10px 14px;
|
|
361
390
|
border-radius: var(--radius-msg);
|
|
362
391
|
font-size: 14px;
|
|
363
392
|
line-height: 1.5;
|
|
364
|
-
white-space:
|
|
393
|
+
white-space: normal;
|
|
365
394
|
word-break: break-word;
|
|
395
|
+
overflow-x: auto;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/* ── Markdown inline elements ───────────────────────── */
|
|
399
|
+
.message-bubble strong { font-weight: 600; }
|
|
400
|
+
.message-bubble em { font-style: italic; }
|
|
401
|
+
.message-bubble a { color: var(--color-primary); text-decoration: underline; word-break: break-all; }
|
|
402
|
+
.message-bubble code {
|
|
403
|
+
font-family: monospace;
|
|
404
|
+
font-size: 12px;
|
|
405
|
+
padding: 1px 5px;
|
|
406
|
+
border-radius: 4px;
|
|
407
|
+
background: rgba(255,255,255,.1);
|
|
408
|
+
white-space: pre-wrap;
|
|
366
409
|
}
|
|
367
410
|
|
|
411
|
+
/* ── Markdown tables ─────────────────────────────────── */
|
|
412
|
+
.message-bubble table {
|
|
413
|
+
border-collapse: collapse;
|
|
414
|
+
min-width: 100%;
|
|
415
|
+
font-size: 12.5px;
|
|
416
|
+
display: block;
|
|
417
|
+
overflow-x: auto;
|
|
418
|
+
margin: 4px 0;
|
|
419
|
+
}
|
|
420
|
+
.message-bubble th,
|
|
421
|
+
.message-bubble td {
|
|
422
|
+
border: 1px solid rgba(255,255,255,.15);
|
|
423
|
+
padding: 5px 10px;
|
|
424
|
+
text-align: left;
|
|
425
|
+
}
|
|
426
|
+
.message-bubble th { background: rgba(255,255,255,.08); font-weight: 600; white-space: nowrap; }
|
|
427
|
+
.message-bubble td { white-space: normal; }
|
|
428
|
+
.message-bubble tr:nth-child(even) td { background: rgba(255,255,255,.04); }
|
|
429
|
+
|
|
430
|
+
/* ── Markdown lists ──────────────────────────────────── */
|
|
431
|
+
.message-bubble ul,
|
|
432
|
+
.message-bubble ol { padding-left: 18px; margin: 2px 0; }
|
|
433
|
+
.message-bubble li { margin: 2px 0; }
|
|
434
|
+
|
|
368
435
|
.message.user .message-bubble {
|
|
369
436
|
background: ${h};
|
|
370
437
|
color: #fff;
|
|
371
438
|
border-bottom-right-radius: 4px;
|
|
439
|
+
white-space: pre-wrap;
|
|
372
440
|
}
|
|
373
441
|
|
|
374
442
|
.message.assistant .message-bubble {
|
|
@@ -489,13 +557,13 @@ function D(e) {
|
|
|
489
557
|
color: var(--color-text);
|
|
490
558
|
resize: none;
|
|
491
559
|
outline: none;
|
|
492
|
-
background: var(--
|
|
560
|
+
background: var(--color-input-bg);
|
|
493
561
|
line-height: 1.4;
|
|
494
562
|
overflow-y: auto;
|
|
495
563
|
transition: border-color .15s;
|
|
496
564
|
}
|
|
497
565
|
|
|
498
|
-
.input:focus { border-color: var(--color-primary); background: var(--
|
|
566
|
+
.input:focus { border-color: var(--color-primary); background: var(--color-input-bg); }
|
|
499
567
|
.input::placeholder { color: var(--gray-400); }
|
|
500
568
|
|
|
501
569
|
.send-btn {
|
|
@@ -518,62 +586,100 @@ function D(e) {
|
|
|
518
586
|
.send-btn svg { width: 18px; height: 18px; fill: #fff; }
|
|
519
587
|
|
|
520
588
|
${g}
|
|
521
|
-
${
|
|
522
|
-
${o ?
|
|
589
|
+
${j(a)}
|
|
590
|
+
${o ? A(o) : ""}
|
|
523
591
|
`;
|
|
524
592
|
}
|
|
525
593
|
//#endregion
|
|
526
|
-
//#region src/core/
|
|
527
|
-
var
|
|
528
|
-
function
|
|
529
|
-
if (!e || e.type === "icon") return
|
|
530
|
-
if (e.type === "emoji") return `<span style="font-size:22px;line-height:1;display:flex;align-items:center;justify-content:center;width:100%;height:100%">${
|
|
594
|
+
//#region src/core/assets.ts
|
|
595
|
+
var N = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABL8SURBVHhe7ZsJjJzlecchbZo2aRPwScFAfM29s3N9M9/cO7O7c+zOzr0ze8ze3tN7+1yvD8Be29iYmEIrlaIaRIIIDW1URRE9BFFpAlXLYZNKxFLVVL1Q0yZSgCJhw7963u/7Zr95dyCtuuuDzCP99V0z7/c8v/d5nvedlX3LLTWrWc1qVrOa1axmNatZzWpWs5rV7Jrbc8899/nz588bz5w5lz219ODCyROnHz3xwNLTS8dPPk868cDSN5aOn3rs5ImTB8+ePps7f/a8kb7Dj/NLZadPn/7yw2cfzj146syF+48ev7y4cARHD9+PI4v3Y3HhGBYOHMHB/YeZ6Hxx4SiOLN7HRM+P37d0+cGTDz557sy5LI3Fj/+ZtVOnTpkeuO/4+YMHFv9l4cBh7NtzEOOjUxjqH2XaNTCG0V2TGB+ZqtDY8BSGB8fLn5kYnca++YM4uH8RCweP/PPJE6cfOXXqlJl/32fGji0c0y7sO3xhz9z+D/fM7cNg/whKnf3oLQ1goG8XgzI8OIGRoQmMDU8yQGoRRHpGIpCDfSPoLQ2yMYYGRjE/tw/zM3uvHjp45OtLS0tG/v03rU1NTf3azNSeY3PTe9/bPTaDrmIvujv6WPB9PUPo7x1iAIf6RxgYBZIaIsEb3bW7DI+ADfYPo793Fxujt3uAjdtZ7MXu8VnMz+7/YHZ679LRo0e/wPtzU9n09B7b9O7Zv6Xy6yz0oJjvZvAoa3q6COBgGSABoSxUAJIImqJy9g1IZUzfGSCAJQIoZSKNXcx1sffQBExO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91vBGnbEe1noHKz+bauHgAarPy6DZfalcLfUOmAxm6HWGN3Ua3fjmzZtv7FV2lexWzbZtMcNO3RN6reEfDHoT6owWWM0SUALG9pO0kqt+kRC8+jo76kxWGPRm2hD/k3aH5sLWe7a2XLe/qFxv27Jlyxd23HWvc+s9Wye0O7SP63fq/1KzQ3tJu1P3j3qt8V91Wv2/aXZqf6zdqb2k1ehf0mzXXNh277aZrVu2em+7WbYl18MIrOYrX/nNrV/+8m/deeedv84/r1nNalazmtWsZjWrWc1qVrNfXvsfj+EYlqVWv8UAAAAASUVORK5CYII=", P = "https://bot-q-frontend.vercel.app/", F = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 2H4a2 2 0 00-2 2v18l4-4h14a2 2 0 002-2V4a2 2 0 00-2-2z\"/>\n</svg>", I = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <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\"/>\n</svg>", L = `<img src="${N}" alt="" style="width:100%;height:100%;object-fit:cover;border-radius:50%" />`, R = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\"/>\n</svg>", z = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 2H4a2 2 0 00-2 2v18l4-4h14a2 2 0 002-2V4a2 2 0 00-2-2zm-2 10H6v-2h12v2zm0-3H6V7h12v2z\"/>\n</svg>";
|
|
596
|
+
function B(e) {
|
|
597
|
+
if (!e || e.type === "icon") return L;
|
|
598
|
+
if (e.type === "emoji") return `<span style="font-size:22px;line-height:1;display:flex;align-items:center;justify-content:center;width:100%;height:100%">${V(e.value)}</span>`;
|
|
531
599
|
if (e.type === "initials") {
|
|
532
600
|
let t = e.bgColor ?? "#F97316";
|
|
533
|
-
return `<div style="width:100%;height:100%;border-radius:50%;background:${/^#[0-9A-Fa-f]{3,6}$/.test(t) ? t : "#F97316"};display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;color:#fff">${
|
|
601
|
+
return `<div style="width:100%;height:100%;border-radius:50%;background:${/^#[0-9A-Fa-f]{3,6}$/.test(t) ? t : "#F97316"};display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;color:#fff">${V(e.value.slice(0, 2).toUpperCase())}</div>`;
|
|
534
602
|
}
|
|
535
|
-
return e.type === "image" ? `<img src="${
|
|
603
|
+
return e.type === "image" ? `<img src="${V(e.value)}" style="width:100%;height:100%;object-fit:cover;border-radius:50%" alt="" />` : L;
|
|
536
604
|
}
|
|
537
|
-
function
|
|
605
|
+
function V(e) {
|
|
538
606
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
539
607
|
}
|
|
540
|
-
function
|
|
541
|
-
let t =
|
|
542
|
-
return
|
|
608
|
+
function H(e) {
|
|
609
|
+
let t = [];
|
|
610
|
+
return e = e.replace(/`([^`]+)`/g, (e, n) => (t.push(`<code>${n}</code>`), `\x00CODE${t.length - 1}\x00`)), e = e.replace(/\*\*\*(.+?)\*\*\*/g, "<strong><em>$1</em></strong>"), e = e.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), e = e.replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, "<em>$1</em>"), e = e.replace(/\[([^\]]+)\]\(([^()]*(?:\([^()]*\))*[^()]*)\)/g, (e, t, n) => /^https?:\/\//.test(n) ? `<a href="${n}" target="_blank" rel="noopener noreferrer">${t}</a>` : t), e = e.replace(/\x00CODE(\d+)\x00/g, (e, n) => t[Number(n)]), e;
|
|
611
|
+
}
|
|
612
|
+
function U(e) {
|
|
613
|
+
return /^\|[\s\-:|]+\|$/.test(e);
|
|
614
|
+
}
|
|
615
|
+
function W(e) {
|
|
616
|
+
return e.replace(/^\|/, "").replace(/\|$/, "").split("|").map((e) => e.trim());
|
|
617
|
+
}
|
|
618
|
+
function G(e) {
|
|
619
|
+
let t = V(e).replace(/\x00/g, "").split("\n"), n = [], r = 0;
|
|
620
|
+
for (; r < t.length;) {
|
|
621
|
+
let e = t[r].trim();
|
|
622
|
+
if (e.startsWith("|") && e.endsWith("|")) {
|
|
623
|
+
let e = [];
|
|
624
|
+
for (; r < t.length && t[r].trim().startsWith("|") && t[r].trim().endsWith("|");) e.push(t[r].trim()), r++;
|
|
625
|
+
let i = e.findIndex(U), a = i > 0 ? e.slice(0, i) : [], o = i >= 0 ? e.slice(i + 1) : e, s = "<table>";
|
|
626
|
+
a.length > 0 && (s += "<thead>" + a.map((e) => "<tr>" + W(e).map((e) => `<th>${H(e)}</th>`).join("") + "</tr>").join("") + "</thead>"), o.length > 0 && (s += "<tbody>" + o.map((e) => "<tr>" + W(e).map((e) => `<td>${H(e)}</td>`).join("") + "</tr>").join("") + "</tbody>"), s += "</table>", n.push(s);
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
if (/^[-*]\s/.test(e)) {
|
|
630
|
+
let e = [];
|
|
631
|
+
for (; r < t.length && /^\s*[-*]\s/.test(t[r]);) e.push(t[r].trim().replace(/^[-*]\s+/, "")), r++;
|
|
632
|
+
n.push("<ul>" + e.map((e) => `<li>${H(e)}</li>`).join("") + "</ul>");
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
if (/^\d+\.\s/.test(e)) {
|
|
636
|
+
let e = [];
|
|
637
|
+
for (; r < t.length && /^\s*\d+\.\s/.test(t[r]);) e.push(t[r].trim().replace(/^\d+\.\s+/, "")), r++;
|
|
638
|
+
n.push("<ol>" + e.map((e) => `<li>${H(e)}</li>`).join("") + "</ol>");
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
if (e === "") {
|
|
642
|
+
n.push("<br>"), r++;
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
n.push(H(e)), n.push("<br>"), r++;
|
|
646
|
+
}
|
|
647
|
+
for (; n.length > 0 && n[n.length - 1] === "<br>";) n.pop();
|
|
648
|
+
return n.join("");
|
|
543
649
|
}
|
|
544
|
-
function
|
|
650
|
+
function K(e, t, n, r, i) {
|
|
545
651
|
let { name: a, design: o } = t, s, c, l, u, d, f, { content: p } = o;
|
|
546
652
|
function m(e) {
|
|
547
|
-
e.setAttribute("data-position", o.layout.position), s = e.attachShadow({ mode: "
|
|
653
|
+
e.setAttribute("data-position", o.layout.position), s = e.attachShadow({ mode: "closed" });
|
|
548
654
|
let t = document.createElement("style");
|
|
549
|
-
t.textContent =
|
|
550
|
-
<span class="icon-chat">${
|
|
551
|
-
<span class="icon-close">${
|
|
655
|
+
t.textContent = M(o), s.appendChild(t), c = document.createElement("button"), c.className = "bubble", c.setAttribute("aria-label", n.ariaOpenChat), c.innerHTML = `
|
|
656
|
+
<span class="icon-chat">${F}</span>
|
|
657
|
+
<span class="icon-close">${I}</span>
|
|
552
658
|
`, c.addEventListener("click", i), s.appendChild(c), l = document.createElement("div"), l.className = "chat-window", l.setAttribute("role", "dialog"), l.setAttribute("aria-label", `${a} chat`), l.innerHTML = `
|
|
553
659
|
<div class="chat-header">
|
|
554
|
-
<div class="avatar">${
|
|
660
|
+
<div class="avatar">${B(o.avatar)}</div>
|
|
555
661
|
<div class="header-text">
|
|
556
|
-
<span class="bot-name">${
|
|
557
|
-
<span class="bot-status">${
|
|
662
|
+
<span class="bot-name">${V(a)}</span>
|
|
663
|
+
<span class="bot-status">${V(n.statusOnline)}</span>
|
|
558
664
|
</div>
|
|
559
|
-
<button class="close-btn" aria-label="${
|
|
665
|
+
<button class="close-btn" aria-label="${V(n.ariaCloseChat)}">×</button>
|
|
560
666
|
</div>
|
|
561
667
|
<div class="messages" id="messages-container" role="log" aria-live="polite" aria-atomic="false"></div>
|
|
562
668
|
<div class="chat-footer">
|
|
563
669
|
<div class="input-row">
|
|
564
670
|
<textarea
|
|
565
671
|
class="input"
|
|
566
|
-
placeholder="${
|
|
672
|
+
placeholder="${V(p.placeholder || n.inputPlaceholder)}"
|
|
567
673
|
rows="1"
|
|
568
674
|
maxlength="2000"
|
|
569
675
|
aria-label="Message input"
|
|
570
676
|
></textarea>
|
|
571
|
-
<button class="send-btn" aria-label="${
|
|
572
|
-
${
|
|
677
|
+
<button class="send-btn" aria-label="${V(n.ariaSendMessage)}">
|
|
678
|
+
${R}
|
|
573
679
|
</button>
|
|
574
680
|
</div>
|
|
575
|
-
<a class="botiq-badge" href="${
|
|
576
|
-
${
|
|
681
|
+
<a class="botiq-badge" href="${P}" target="_blank" rel="noopener noreferrer">
|
|
682
|
+
${V(n.poweredBy)} <span class="botiq-badge-name">BotIQ</span>
|
|
577
683
|
</a>
|
|
578
684
|
</div>
|
|
579
685
|
`, l.querySelector(".close-btn").addEventListener("click", i), u = l.querySelector("#messages-container"), d = l.querySelector(".input"), f = l.querySelector(".send-btn"), d.addEventListener("input", () => {
|
|
@@ -588,11 +694,11 @@ function L(e, t, n, r, i) {
|
|
|
588
694
|
}
|
|
589
695
|
function g(e) {
|
|
590
696
|
if (e.messages.length === 0 && !e.isLoading) {
|
|
591
|
-
let e = p.suggestionChips.length > 0 ? `<div class="chips">${p.suggestionChips.map((e) => `<button class="chip">${
|
|
697
|
+
let e = p.suggestionChips.length > 0 ? `<div class="chips">${p.suggestionChips.map((e) => `<button class="chip">${V(e)}</button>`).join("")}</div>` : "";
|
|
592
698
|
u.innerHTML = `
|
|
593
699
|
<div class="empty-state">
|
|
594
|
-
${
|
|
595
|
-
<span class="greeting">${
|
|
700
|
+
${z}
|
|
701
|
+
<span class="greeting">${V(p.greeting || n.defaultGreeting)}</span>
|
|
596
702
|
${e}
|
|
597
703
|
</div>
|
|
598
704
|
`, u.querySelectorAll(".chip").forEach((e) => {
|
|
@@ -602,7 +708,7 @@ function L(e, t, n, r, i) {
|
|
|
602
708
|
}
|
|
603
709
|
let t = e.messages.map((e) => `
|
|
604
710
|
<div class="message ${e.role}">
|
|
605
|
-
<div class="message-bubble">${e.role === "assistant" ?
|
|
711
|
+
<div class="message-bubble">${e.role === "assistant" ? G(e.content) : V(e.content)}</div>
|
|
606
712
|
</div>
|
|
607
713
|
`).join(""), i = e.isLoading ? "<div class=\"typing\"><span></span><span></span><span></span></div>" : "";
|
|
608
714
|
u.innerHTML = t + i, u.scrollTop = u.scrollHeight;
|
|
@@ -617,7 +723,7 @@ function L(e, t, n, r, i) {
|
|
|
617
723
|
}
|
|
618
724
|
//#endregion
|
|
619
725
|
//#region src/i18n/vi.ts
|
|
620
|
-
var
|
|
726
|
+
var q = {
|
|
621
727
|
statusOnline: "Trực tuyến",
|
|
622
728
|
inputPlaceholder: "Nhắn tin...",
|
|
623
729
|
defaultGreeting: "Xin chào! Tôi có thể giúp gì cho bạn?",
|
|
@@ -633,7 +739,7 @@ var R = {
|
|
|
633
739
|
ariaOpenChat: "Mở khung chat",
|
|
634
740
|
ariaCloseChat: "Đóng khung chat",
|
|
635
741
|
ariaSendMessage: "Gửi tin nhắn"
|
|
636
|
-
},
|
|
742
|
+
}, J = {
|
|
637
743
|
statusOnline: "Online",
|
|
638
744
|
inputPlaceholder: "Type a message...",
|
|
639
745
|
defaultGreeting: "Hello! How can I help you?",
|
|
@@ -652,53 +758,59 @@ var R = {
|
|
|
652
758
|
};
|
|
653
759
|
//#endregion
|
|
654
760
|
//#region src/i18n/index.ts
|
|
655
|
-
function
|
|
656
|
-
return e === "en" ?
|
|
761
|
+
function Y(e) {
|
|
762
|
+
return e === "en" ? J : q;
|
|
657
763
|
}
|
|
658
764
|
//#endregion
|
|
659
765
|
//#region src/builds/npm/index.ts
|
|
660
|
-
function
|
|
766
|
+
function X(e) {
|
|
661
767
|
if (!e.apiKey) return console.warn("[BotIQ] apiKey is required"), () => void 0;
|
|
662
|
-
let t =
|
|
663
|
-
|
|
664
|
-
let
|
|
665
|
-
|
|
666
|
-
let i = ()
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
768
|
+
let t = p(e);
|
|
769
|
+
v();
|
|
770
|
+
let n = t.apiKey.slice(-16), r = y(n);
|
|
771
|
+
E({ messages: b(n, r) });
|
|
772
|
+
let i = document.createElement("div");
|
|
773
|
+
document.body.appendChild(i);
|
|
774
|
+
let a = () => void 0, o = !1, s = Y(void 0);
|
|
775
|
+
f(t.apiKey, t.apiUrl).then((e) => {
|
|
776
|
+
if (o) return;
|
|
777
|
+
if (e === null) {
|
|
778
|
+
console.warn("[BotIQ] Widget not authorised on this origin — skipped mount"), i.remove();
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
s = Y(e.widgetLanguage);
|
|
782
|
+
let n = K(t, e, s, c, l);
|
|
783
|
+
n.mount(i), a = D((e) => n.update(e)), n.update(T());
|
|
672
784
|
});
|
|
673
|
-
function
|
|
674
|
-
let
|
|
675
|
-
if (
|
|
676
|
-
let
|
|
785
|
+
function c(e) {
|
|
786
|
+
let i = T();
|
|
787
|
+
if (i.isLoading) return;
|
|
788
|
+
let a = {
|
|
677
789
|
role: "user",
|
|
678
790
|
content: e
|
|
679
791
|
};
|
|
680
|
-
|
|
681
|
-
messages: [...
|
|
792
|
+
E({
|
|
793
|
+
messages: [...i.messages, a],
|
|
682
794
|
isLoading: !0
|
|
683
|
-
}),
|
|
795
|
+
}), S(t.apiUrl, t.apiKey, r, e, i.messages, s).then((e) => {
|
|
684
796
|
let t = {
|
|
685
797
|
role: "assistant",
|
|
686
798
|
content: e
|
|
687
799
|
};
|
|
688
|
-
|
|
689
|
-
messages: [...
|
|
800
|
+
E({
|
|
801
|
+
messages: [...T().messages, t],
|
|
690
802
|
isLoading: !1
|
|
691
|
-
}),
|
|
803
|
+
}), x(n, r, [a, t]);
|
|
692
804
|
}).catch(() => {
|
|
693
|
-
|
|
805
|
+
E({ isLoading: !1 });
|
|
694
806
|
});
|
|
695
807
|
}
|
|
696
|
-
function
|
|
697
|
-
|
|
808
|
+
function l() {
|
|
809
|
+
E({ isOpen: !T().isOpen });
|
|
698
810
|
}
|
|
699
811
|
return () => {
|
|
700
|
-
|
|
812
|
+
o = !0, a(), i.remove();
|
|
701
813
|
};
|
|
702
814
|
}
|
|
703
815
|
//#endregion
|
|
704
|
-
export {
|
|
816
|
+
export { X as t };
|
package/dist/sdk/react.js
CHANGED
package/dist/sdk/vue.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locdo.tech/botiq-chat-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "BotIQ chat widget SDK — embed AI chatbot into any website with vanilla JS, React, or Vue.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"botiq",
|
|
@@ -75,6 +75,11 @@
|
|
|
75
75
|
"test:browser:chromium": "playwright test --project=chromium",
|
|
76
76
|
"pretest:browser": "npm run build:cdn && cpx \"test/browser/fixtures/**\" dist/test-fixtures",
|
|
77
77
|
"pretest:browser:chromium": "npm run pretest:browser",
|
|
78
|
+
"test:wordpress": "playwright test --config=playwright.wordpress.config.ts",
|
|
79
|
+
"pretest:wordpress": "npm run build:cdn",
|
|
80
|
+
"test:wordpress:up": "docker compose -f test/wordpress/docker-compose.wp.yml up -d",
|
|
81
|
+
"test:wordpress:down": "docker compose -f test/wordpress/docker-compose.wp.yml down -v",
|
|
82
|
+
"test:wordpress:logs": "docker compose -f test/wordpress/docker-compose.wp.yml logs --tail=100",
|
|
78
83
|
"prepublishOnly": "npm run build:sdk",
|
|
79
84
|
"rollback:cdn": "bash scripts/rollback/cdn-rollback.sh"
|
|
80
85
|
},
|