@eduzz-automacoes/webchat-widget 0.2.1 → 0.2.2
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/eduzz-webchat.cjs +2 -2
- package/dist/eduzz-webchat.js +557 -402
- package/package.json +1 -1
package/dist/eduzz-webchat.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as o, jsxs as l, Fragment as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { Container as
|
|
4
|
-
import './style.css';const
|
|
1
|
+
import { jsx as o, jsxs as l, Fragment as Fe } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Pe, createElement as Ne, useState as S, useEffect as M, useRef as Y, useMemo as k, useCallback as le, useReducer as st } from "react";
|
|
3
|
+
import { Container as ct, MessageList as lt, Composer as it, WebchatProvider as dt, useActiveConversation as ut, useConversations as bt, useUser as ht, useConversationList as pt, Block as Te, StylesheetProvider as mt } from "@botpress/webchat";
|
|
4
|
+
import './style.css';const Z = {
|
|
5
5
|
botName: "Assistente Virtual",
|
|
6
6
|
subtitle: "Conectado ao bot real",
|
|
7
7
|
botAvatar: "",
|
|
@@ -64,8 +64,8 @@ import './style.css';const X = {
|
|
|
64
64
|
welcomeCloseLabel: "Fechar painel",
|
|
65
65
|
openFabBackgroundColor: "#2563eb",
|
|
66
66
|
openFabIconColor: "#ffffff"
|
|
67
|
-
},
|
|
68
|
-
switch (
|
|
67
|
+
}, He = (e) => e === "bottom-left" || e === "top-left" ? "bottom-left" : "bottom-right", wt = (e) => {
|
|
68
|
+
switch (He(e)) {
|
|
69
69
|
case "bottom-left":
|
|
70
70
|
return {
|
|
71
71
|
bottom: "24px",
|
|
@@ -82,12 +82,12 @@ import './style.css';const X = {
|
|
|
82
82
|
"--panel-transform-origin": "right bottom"
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, $e = (e, t, a) => Math.min(Math.max(e, t), a), Ie = (e) => {
|
|
86
86
|
if (typeof e != "string") return null;
|
|
87
87
|
let t = e.trim();
|
|
88
88
|
return !t || (t.startsWith("#") && (t = t.slice(1)), t.length === 3 && (t = t.split("").map((a) => `${a}${a}`).join("")), !/^[0-9a-fA-F]{6}$/.test(t)) ? null : `#${t.toLowerCase()}`;
|
|
89
|
-
},
|
|
90
|
-
const t =
|
|
89
|
+
}, Me = (e) => {
|
|
90
|
+
const t = Ie(e);
|
|
91
91
|
if (!t) return null;
|
|
92
92
|
const a = t.slice(1);
|
|
93
93
|
return {
|
|
@@ -95,19 +95,19 @@ import './style.css';const X = {
|
|
|
95
95
|
g: Number.parseInt(a.slice(2, 4), 16),
|
|
96
96
|
b: Number.parseInt(a.slice(4, 6), 16)
|
|
97
97
|
};
|
|
98
|
-
},
|
|
99
|
-
(r) =>
|
|
98
|
+
}, ft = ({ r: e, g: t, b: a }) => `#${[e, t, a].map(
|
|
99
|
+
(r) => $e(Math.round(r), 0, 255).toString(16).padStart(2, "0")
|
|
100
100
|
).join("")}`, pe = (e, t, a) => {
|
|
101
|
-
const r =
|
|
101
|
+
const r = Me(e), s = Me(t);
|
|
102
102
|
if (!r || !s) return null;
|
|
103
|
-
const n =
|
|
104
|
-
return
|
|
103
|
+
const n = $e(a, 0, 1);
|
|
104
|
+
return ft({
|
|
105
105
|
r: r.r * (1 - n) + s.r * n,
|
|
106
106
|
g: r.g * (1 - n) + s.g * n,
|
|
107
107
|
b: r.b * (1 - n) + s.b * n
|
|
108
108
|
});
|
|
109
|
-
},
|
|
110
|
-
const t =
|
|
109
|
+
}, gt = (e, t) => t < 0 ? pe(e, "#000000", Math.abs(t)) : pe(e, "#ffffff", t), me = (e) => {
|
|
110
|
+
const t = Me(e);
|
|
111
111
|
return t && [t.r, t.g, t.b].map((r) => {
|
|
112
112
|
const s = r / 255;
|
|
113
113
|
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
@@ -115,10 +115,10 @@ import './style.css';const X = {
|
|
|
115
115
|
(r, s, n) => r + s * [0.2126, 0.7152, 0.0722][n],
|
|
116
116
|
0
|
|
117
117
|
) > 0.42 ? "#18181b" : "#ffffff";
|
|
118
|
-
}, L = (e, t) => e && Object.prototype.hasOwnProperty.call(e, t) && e[t] != null && e[t] !== "",
|
|
119
|
-
const a =
|
|
118
|
+
}, L = (e, t) => e && Object.prototype.hasOwnProperty.call(e, t) && e[t] != null && e[t] !== "", yt = (e, t) => {
|
|
119
|
+
const a = Ie(e.brandColor);
|
|
120
120
|
if (!a) return e;
|
|
121
|
-
const r =
|
|
121
|
+
const r = Ie(e.brandTextColor) || me(a), s = pe(a, "#ffffff", 0.82) || Z.secondaryButtonBorderColor, n = pe(a, "#ffffff", 0.92) || Z.secondaryButtonHoverBackgroundColor, c = gt(a, -0.12) || Z.primaryButtonHoverBackgroundColor;
|
|
122
122
|
return {
|
|
123
123
|
...e,
|
|
124
124
|
brandColor: a,
|
|
@@ -150,8 +150,8 @@ import './style.css';const X = {
|
|
|
150
150
|
"iconButtonHoverBackgroundColor"
|
|
151
151
|
) ? e.iconButtonHoverBackgroundColor : n
|
|
152
152
|
};
|
|
153
|
-
},
|
|
154
|
-
const t = e.fabBackgroundColor || e.openFabBackgroundColor ||
|
|
153
|
+
}, vt = (e) => {
|
|
154
|
+
const t = e.fabBackgroundColor || e.openFabBackgroundColor || Z.fabBackgroundColor, a = e.fabIconColor || e.openFabIconColor || Z.fabIconColor;
|
|
155
155
|
return {
|
|
156
156
|
...e,
|
|
157
157
|
fabBackgroundColor: t,
|
|
@@ -159,17 +159,17 @@ import './style.css';const X = {
|
|
|
159
159
|
openFabBackgroundColor: t,
|
|
160
160
|
openFabIconColor: a
|
|
161
161
|
};
|
|
162
|
-
},
|
|
163
|
-
|
|
162
|
+
}, Ct = (e = {}) => vt(
|
|
163
|
+
yt(
|
|
164
164
|
{
|
|
165
|
-
...
|
|
165
|
+
...Z,
|
|
166
166
|
...e,
|
|
167
|
-
position:
|
|
167
|
+
position: He(e.position ?? Z.position)
|
|
168
168
|
},
|
|
169
169
|
e
|
|
170
170
|
)
|
|
171
|
-
),
|
|
172
|
-
...
|
|
171
|
+
), ie = (e) => ({
|
|
172
|
+
...wt(e.position),
|
|
173
173
|
"--widget-width": e.width,
|
|
174
174
|
"--widget-height": e.height,
|
|
175
175
|
"--bpGray-1": "var(--ui-bg)",
|
|
@@ -228,7 +228,7 @@ import './style.css';const X = {
|
|
|
228
228
|
"--button-text": e.secondaryButtonTextColor,
|
|
229
229
|
"--fab-background-color": e.fabBackgroundColor,
|
|
230
230
|
"--fab-icon-color": e.fabIconColor
|
|
231
|
-
}),
|
|
231
|
+
}), Bt = (e) => ({
|
|
232
232
|
color: e.color || e.accentColor,
|
|
233
233
|
fontFamily: e.fontFamily,
|
|
234
234
|
radius: e.radius,
|
|
@@ -238,18 +238,18 @@ import './style.css';const X = {
|
|
|
238
238
|
additionalStylesheet: e.additionalStylesheet,
|
|
239
239
|
additionalStylesheetUrl: e.additionalStylesheetUrl
|
|
240
240
|
});
|
|
241
|
-
const
|
|
241
|
+
const kt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), xt = (e) => e.replace(
|
|
242
242
|
/^([A-Z])|[\s-_]+(\w)/g,
|
|
243
243
|
(t, a, r) => r ? r.toUpperCase() : a.toLowerCase()
|
|
244
|
-
),
|
|
245
|
-
const t =
|
|
244
|
+
), Ae = (e) => {
|
|
245
|
+
const t = xt(e);
|
|
246
246
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
247
|
-
},
|
|
247
|
+
}, Le = (...e) => e.filter((t, a, r) => !!t && t.trim() !== "" && r.indexOf(t) === a).join(" ").trim(), Nt = (e) => {
|
|
248
248
|
for (const t in e)
|
|
249
249
|
if (t.startsWith("aria-") || t === "role" || t === "title")
|
|
250
250
|
return !0;
|
|
251
251
|
};
|
|
252
|
-
var
|
|
252
|
+
var It = {
|
|
253
253
|
xmlns: "http://www.w3.org/2000/svg",
|
|
254
254
|
width: 24,
|
|
255
255
|
height: 24,
|
|
@@ -260,7 +260,7 @@ var pt = {
|
|
|
260
260
|
strokeLinecap: "round",
|
|
261
261
|
strokeLinejoin: "round"
|
|
262
262
|
};
|
|
263
|
-
const
|
|
263
|
+
const Mt = Pe(
|
|
264
264
|
({
|
|
265
265
|
color: e = "currentColor",
|
|
266
266
|
size: t = 24,
|
|
@@ -270,47 +270,47 @@ const mt = Re(
|
|
|
270
270
|
children: n,
|
|
271
271
|
iconNode: c,
|
|
272
272
|
...i
|
|
273
|
-
}, u) =>
|
|
273
|
+
}, u) => Ne(
|
|
274
274
|
"svg",
|
|
275
275
|
{
|
|
276
276
|
ref: u,
|
|
277
|
-
...
|
|
277
|
+
...It,
|
|
278
278
|
width: t,
|
|
279
279
|
height: t,
|
|
280
280
|
stroke: e,
|
|
281
281
|
strokeWidth: r ? Number(a) * 24 / Number(t) : a,
|
|
282
|
-
className:
|
|
283
|
-
...!n && !
|
|
282
|
+
className: Le("lucide", s),
|
|
283
|
+
...!n && !Nt(i) && { "aria-hidden": "true" },
|
|
284
284
|
...i
|
|
285
285
|
},
|
|
286
286
|
[
|
|
287
|
-
...c.map(([w, m]) =>
|
|
287
|
+
...c.map(([w, m]) => Ne(w, m)),
|
|
288
288
|
...Array.isArray(n) ? n : [n]
|
|
289
289
|
]
|
|
290
290
|
)
|
|
291
291
|
);
|
|
292
292
|
const A = (e, t) => {
|
|
293
|
-
const a =
|
|
294
|
-
({ className: r, ...s }, n) =>
|
|
293
|
+
const a = Pe(
|
|
294
|
+
({ className: r, ...s }, n) => Ne(Mt, {
|
|
295
295
|
ref: n,
|
|
296
296
|
iconNode: t,
|
|
297
|
-
className:
|
|
298
|
-
`lucide-${
|
|
297
|
+
className: Le(
|
|
298
|
+
`lucide-${kt(Ae(e))}`,
|
|
299
299
|
`lucide-${e}`,
|
|
300
300
|
r
|
|
301
301
|
),
|
|
302
302
|
...s
|
|
303
303
|
})
|
|
304
304
|
);
|
|
305
|
-
return a.displayName =
|
|
305
|
+
return a.displayName = Ae(e), a;
|
|
306
306
|
};
|
|
307
|
-
const
|
|
307
|
+
const St = [
|
|
308
308
|
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
309
309
|
["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
|
|
310
|
-
],
|
|
311
|
-
const
|
|
312
|
-
const
|
|
313
|
-
const
|
|
310
|
+
], Tt = A("arrow-right", St);
|
|
311
|
+
const At = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], Ut = A("chevron-down", At);
|
|
312
|
+
const Vt = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], Rt = A("chevron-right", Vt);
|
|
313
|
+
const Dt = [
|
|
314
314
|
["path", { d: "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8", key: "5wwlr5" }],
|
|
315
315
|
[
|
|
316
316
|
"path",
|
|
@@ -319,8 +319,8 @@ const Bt = [
|
|
|
319
319
|
key: "r6nss1"
|
|
320
320
|
}
|
|
321
321
|
]
|
|
322
|
-
],
|
|
323
|
-
const
|
|
322
|
+
], Ft = A("house", Dt);
|
|
323
|
+
const Pt = [
|
|
324
324
|
[
|
|
325
325
|
"path",
|
|
326
326
|
{
|
|
@@ -331,8 +331,8 @@ const xt = [
|
|
|
331
331
|
["path", { d: "M8 12h.01", key: "czm47f" }],
|
|
332
332
|
["path", { d: "M12 12h.01", key: "1mp3jc" }],
|
|
333
333
|
["path", { d: "M16 12h.01", key: "1l6xoz" }]
|
|
334
|
-
],
|
|
335
|
-
const
|
|
334
|
+
], Ht = A("message-circle-more", Pt);
|
|
335
|
+
const $t = [
|
|
336
336
|
[
|
|
337
337
|
"path",
|
|
338
338
|
{
|
|
@@ -340,8 +340,8 @@ const It = [
|
|
|
340
340
|
key: "1sd12s"
|
|
341
341
|
}
|
|
342
342
|
]
|
|
343
|
-
],
|
|
344
|
-
const
|
|
343
|
+
], Lt = A("message-circle", $t);
|
|
344
|
+
const _t = [
|
|
345
345
|
[
|
|
346
346
|
"path",
|
|
347
347
|
{
|
|
@@ -349,8 +349,8 @@ const St = [
|
|
|
349
349
|
key: "18887p"
|
|
350
350
|
}
|
|
351
351
|
]
|
|
352
|
-
],
|
|
353
|
-
const
|
|
352
|
+
], _e = A("message-square", _t);
|
|
353
|
+
const zt = [
|
|
354
354
|
[
|
|
355
355
|
"path",
|
|
356
356
|
{
|
|
@@ -365,12 +365,12 @@ const Tt = [
|
|
|
365
365
|
key: "1qfcsi"
|
|
366
366
|
}
|
|
367
367
|
]
|
|
368
|
-
],
|
|
369
|
-
const
|
|
368
|
+
], ze = A("messages-square", zt);
|
|
369
|
+
const Et = [
|
|
370
370
|
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
|
|
371
371
|
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
372
|
-
],
|
|
373
|
-
const
|
|
372
|
+
], Ot = A("rotate-ccw", Et);
|
|
373
|
+
const qt = [
|
|
374
374
|
["path", { d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7", key: "1m0v6g" }],
|
|
375
375
|
[
|
|
376
376
|
"path",
|
|
@@ -379,8 +379,8 @@ const Vt = [
|
|
|
379
379
|
key: "ohrbg2"
|
|
380
380
|
}
|
|
381
381
|
]
|
|
382
|
-
],
|
|
383
|
-
const
|
|
382
|
+
], jt = A("square-pen", qt);
|
|
383
|
+
const Wt = [
|
|
384
384
|
[
|
|
385
385
|
"path",
|
|
386
386
|
{
|
|
@@ -389,8 +389,8 @@ const Dt = [
|
|
|
389
389
|
}
|
|
390
390
|
],
|
|
391
391
|
["path", { d: "M17 14V2", key: "8ymqnk" }]
|
|
392
|
-
],
|
|
393
|
-
const
|
|
392
|
+
], Gt = A("thumbs-down", Wt);
|
|
393
|
+
const Kt = [
|
|
394
394
|
[
|
|
395
395
|
"path",
|
|
396
396
|
{
|
|
@@ -399,20 +399,20 @@ const Pt = [
|
|
|
399
399
|
}
|
|
400
400
|
],
|
|
401
401
|
["path", { d: "M7 10v12", key: "1qc93n" }]
|
|
402
|
-
],
|
|
403
|
-
const
|
|
402
|
+
], Jt = A("thumbs-up", Kt);
|
|
403
|
+
const Xt = [
|
|
404
404
|
["circle", { cx: "12", cy: "8", r: "5", key: "1hypcn" }],
|
|
405
405
|
["path", { d: "M20 21a8 8 0 0 0-16 0", key: "rfgkzh" }]
|
|
406
|
-
],
|
|
407
|
-
const
|
|
406
|
+
], Zt = A("user-round", Xt);
|
|
407
|
+
const Yt = [
|
|
408
408
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
409
409
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
410
|
-
],
|
|
411
|
-
"message-circle-more": /* @__PURE__ */ o(
|
|
412
|
-
"message-circle": /* @__PURE__ */ o(
|
|
413
|
-
"message-square": /* @__PURE__ */ o(
|
|
414
|
-
"messages-square": /* @__PURE__ */ o(
|
|
415
|
-
},
|
|
410
|
+
], Ee = A("x", Yt), x = { "aria-hidden": !0, strokeWidth: 1.9 }, Qt = /* @__PURE__ */ o(Ot, { ...x }), we = /* @__PURE__ */ o(Ee, { ...x }), eo = /* @__PURE__ */ o(Ee, { ...x }), Ue = {
|
|
411
|
+
"message-circle-more": /* @__PURE__ */ o(Ht, { ...x }),
|
|
412
|
+
"message-circle": /* @__PURE__ */ o(Lt, { ...x }),
|
|
413
|
+
"message-square": /* @__PURE__ */ o(_e, { ...x }),
|
|
414
|
+
"messages-square": /* @__PURE__ */ o(ze, { ...x })
|
|
415
|
+
}, to = (e = "messages-square") => Ue[e] || Ue["messages-square"], oo = /* @__PURE__ */ o(Tt, { ...x }), Oe = /* @__PURE__ */ o(Ft, { ...x }), ao = /* @__PURE__ */ o(_e, { ...x }), no = /* @__PURE__ */ o(Jt, { ...x }), ro = /* @__PURE__ */ o(Gt, { ...x }), so = /* @__PURE__ */ o(ze, { ...x }), co = /* @__PURE__ */ o(Rt, { ...x }), lo = /* @__PURE__ */ o(Ut, { ...x }), io = /* @__PURE__ */ o(jt, { ...x }), uo = /* @__PURE__ */ o(Zt, { ...x }), he = (e) => String(e).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'"), bo = ({ name: e, backgroundColor: t }) => {
|
|
416
416
|
const a = (e || "B").trim().charAt(0).toUpperCase() || "B", r = me(t), s = `
|
|
417
417
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-label="${he(e || "Bot")}">
|
|
418
418
|
<rect width="96" height="96" rx="48" fill="${he(t)}" />
|
|
@@ -420,28 +420,28 @@ const _t = [
|
|
|
420
420
|
</svg>
|
|
421
421
|
`.trim();
|
|
422
422
|
return `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(s)}`;
|
|
423
|
-
},
|
|
423
|
+
}, ho = (e) => e ? e.payload?.type === "text" ? e.payload.text : e.payload?.type === "bloc" && e.payload.items?.some((t) => t.type === "text") ? e.payload.items.find((a) => a.type === "text")?.payload.text ?? "Conversa sem mensagens" : "Anexo enviado" : "Conversa sem mensagens", Ve = [
|
|
424
424
|
{ unit: "minute", seconds: 60 },
|
|
425
425
|
{ unit: "hour", seconds: 3600 },
|
|
426
426
|
{ unit: "day", seconds: 3600 * 24 },
|
|
427
427
|
{ unit: "week", seconds: 3600 * 24 * 7 },
|
|
428
428
|
{ unit: "month", seconds: 3600 * 24 * 30 },
|
|
429
429
|
{ unit: "year", seconds: 3600 * 24 * 365 }
|
|
430
|
-
],
|
|
430
|
+
], po = new Intl.RelativeTimeFormat("pt-BR", { numeric: "auto" }), mo = (e) => {
|
|
431
431
|
const t = Math.round((new Date(e).getTime() - Date.now()) / 1e3);
|
|
432
432
|
if (Math.abs(t) < 45) return "agora";
|
|
433
|
-
let a =
|
|
434
|
-
for (const r of
|
|
433
|
+
let a = Ve[0];
|
|
434
|
+
for (const r of Ve)
|
|
435
435
|
Math.abs(t) >= r.seconds && (a = r);
|
|
436
|
-
return
|
|
437
|
-
},
|
|
436
|
+
return po.format(Math.round(t / a.seconds), a.unit);
|
|
437
|
+
}, wo = ({ messages: e, user: t, botName: a, botAvatar: r }) => e.map((s) => {
|
|
438
438
|
const n = s.authorId === t?.userId;
|
|
439
439
|
return {
|
|
440
440
|
...s,
|
|
441
441
|
direction: n ? "outgoing" : "incoming",
|
|
442
442
|
sender: n ? { name: t?.name ?? "Você", avatar: t?.pictureUrl } : { name: a, avatar: r }
|
|
443
443
|
};
|
|
444
|
-
}),
|
|
444
|
+
}), fo = ({ activeView: e, clientState: t, conversationId: a, messagesLength: r }) => {
|
|
445
445
|
const [s, n] = S(!1), c = e === "chat", i = c && t === "connecting", u = c && t === "connected" && r === 0, w = s && (!c || r > 0 || t !== "connecting" && t !== "connected");
|
|
446
446
|
return M(() => {
|
|
447
447
|
if (s) {
|
|
@@ -458,14 +458,14 @@ const _t = [
|
|
|
458
458
|
showInitialLoading: i || s && c,
|
|
459
459
|
setShowInitialLoading: n
|
|
460
460
|
};
|
|
461
|
-
},
|
|
461
|
+
}, go = 3e4, yo = ({
|
|
462
462
|
getSession: e,
|
|
463
463
|
sessionKey: t,
|
|
464
464
|
onSessionChange: a
|
|
465
465
|
}) => {
|
|
466
|
-
const [r, s] = S(null), [n, c] = S(!!e), i =
|
|
466
|
+
const [r, s] = S(null), [n, c] = S(!!e), i = Y(e);
|
|
467
467
|
i.current = e;
|
|
468
|
-
const u =
|
|
468
|
+
const u = Y(a);
|
|
469
469
|
return u.current = a, M(() => {
|
|
470
470
|
let w = !0, m;
|
|
471
471
|
const b = (f) => {
|
|
@@ -482,7 +482,7 @@ const _t = [
|
|
|
482
482
|
throw new Error("Webchat session not created or empty");
|
|
483
483
|
if (!w) return;
|
|
484
484
|
b(f);
|
|
485
|
-
const B = f.expiresAt - Date.now() -
|
|
485
|
+
const B = f.expiresAt - Date.now() - go;
|
|
486
486
|
m = setTimeout(U, Math.max(B, 0));
|
|
487
487
|
} catch (f) {
|
|
488
488
|
console.error("[EduzzWebchat] error creating session: ", f), b(null);
|
|
@@ -495,7 +495,7 @@ const _t = [
|
|
|
495
495
|
};
|
|
496
496
|
}, [t, !!e]), { session: r, resolving: n };
|
|
497
497
|
};
|
|
498
|
-
function
|
|
498
|
+
function vo({
|
|
499
499
|
botName: e,
|
|
500
500
|
botAvatar: t,
|
|
501
501
|
subtitle: a,
|
|
@@ -520,7 +520,7 @@ function co({
|
|
|
520
520
|
type: "button",
|
|
521
521
|
"aria-label": "Abrir início",
|
|
522
522
|
onClick: r,
|
|
523
|
-
children:
|
|
523
|
+
children: Oe
|
|
524
524
|
}
|
|
525
525
|
) : null,
|
|
526
526
|
/* @__PURE__ */ o(
|
|
@@ -530,7 +530,7 @@ function co({
|
|
|
530
530
|
type: "button",
|
|
531
531
|
"aria-label": "Abrir conversas",
|
|
532
532
|
onClick: s,
|
|
533
|
-
children:
|
|
533
|
+
children: so
|
|
534
534
|
}
|
|
535
535
|
),
|
|
536
536
|
/* @__PURE__ */ o(
|
|
@@ -540,7 +540,7 @@ function co({
|
|
|
540
540
|
type: "button",
|
|
541
541
|
"aria-label": "Reiniciar conversa",
|
|
542
542
|
onClick: n,
|
|
543
|
-
children:
|
|
543
|
+
children: Qt
|
|
544
544
|
}
|
|
545
545
|
),
|
|
546
546
|
c ? /* @__PURE__ */ o(
|
|
@@ -556,7 +556,7 @@ function co({
|
|
|
556
556
|
] })
|
|
557
557
|
] });
|
|
558
558
|
}
|
|
559
|
-
function
|
|
559
|
+
function qe() {
|
|
560
560
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-loading", children: [
|
|
561
561
|
/* @__PURE__ */ l("div", { className: "bp-webchat-loading-hero", children: [
|
|
562
562
|
/* @__PURE__ */ o("div", { className: "bp-webchat-loading-circle" }),
|
|
@@ -574,7 +574,7 @@ function ze() {
|
|
|
574
574
|
] })
|
|
575
575
|
] });
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function Co({
|
|
578
578
|
config: e,
|
|
579
579
|
allowFileUpload: t,
|
|
580
580
|
clientState: a,
|
|
@@ -592,7 +592,7 @@ function lo({
|
|
|
592
592
|
}) {
|
|
593
593
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-layout", children: [
|
|
594
594
|
/* @__PURE__ */ o(
|
|
595
|
-
|
|
595
|
+
vo,
|
|
596
596
|
{
|
|
597
597
|
botName: e.botName,
|
|
598
598
|
botAvatar: e.botAvatar,
|
|
@@ -604,14 +604,14 @@ function lo({
|
|
|
604
604
|
}
|
|
605
605
|
),
|
|
606
606
|
/* @__PURE__ */ o(
|
|
607
|
-
|
|
607
|
+
ct,
|
|
608
608
|
{
|
|
609
609
|
className: "bp-webchat-container",
|
|
610
610
|
uploadFile: i,
|
|
611
611
|
allowFileUpload: t,
|
|
612
|
-
children: w ? /* @__PURE__ */ o(
|
|
612
|
+
children: w ? /* @__PURE__ */ o(qe, {}) : /* @__PURE__ */ l(Fe, { children: [
|
|
613
613
|
/* @__PURE__ */ o(
|
|
614
|
-
|
|
614
|
+
lt,
|
|
615
615
|
{
|
|
616
616
|
botName: e.botName,
|
|
617
617
|
botDescription: e.subtitle,
|
|
@@ -628,7 +628,7 @@ function lo({
|
|
|
628
628
|
}
|
|
629
629
|
),
|
|
630
630
|
/* @__PURE__ */ o(
|
|
631
|
-
|
|
631
|
+
it,
|
|
632
632
|
{
|
|
633
633
|
connected: a !== "disconnected",
|
|
634
634
|
sendMessage: c,
|
|
@@ -643,7 +643,7 @@ function lo({
|
|
|
643
643
|
)
|
|
644
644
|
] });
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function je({ activeView: e, onShowHome: t, onShowConversations: a }) {
|
|
647
647
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-tabs bp-webchat-welcome-bottom", children: [
|
|
648
648
|
/* @__PURE__ */ l(
|
|
649
649
|
"button",
|
|
@@ -653,7 +653,7 @@ function Ee({ activeView: e, onShowHome: t, onShowConversations: a }) {
|
|
|
653
653
|
type: "button",
|
|
654
654
|
onClick: t,
|
|
655
655
|
children: [
|
|
656
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children:
|
|
656
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: Oe }),
|
|
657
657
|
/* @__PURE__ */ o("span", { children: "Início" })
|
|
658
658
|
]
|
|
659
659
|
}
|
|
@@ -666,14 +666,14 @@ function Ee({ activeView: e, onShowHome: t, onShowConversations: a }) {
|
|
|
666
666
|
type: "button",
|
|
667
667
|
onClick: a,
|
|
668
668
|
children: [
|
|
669
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children:
|
|
669
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: ao }),
|
|
670
670
|
/* @__PURE__ */ o("span", { children: "Conversas" })
|
|
671
671
|
]
|
|
672
672
|
}
|
|
673
673
|
)
|
|
674
674
|
] });
|
|
675
675
|
}
|
|
676
|
-
function
|
|
676
|
+
function Bo({
|
|
677
677
|
conversations: e,
|
|
678
678
|
currentConversationId: t,
|
|
679
679
|
isLoading: a,
|
|
@@ -713,7 +713,7 @@ function io({
|
|
|
713
713
|
] })
|
|
714
714
|
] }),
|
|
715
715
|
/* @__PURE__ */ o("div", { className: "bp-webchat-history-list", children: a ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-loading", children: "Carregando conversas..." }) : e.length === 0 ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-empty", children: "Nenhuma conversa iniciada ainda." }) : e.map((b) => {
|
|
716
|
-
const U =
|
|
716
|
+
const U = ho(b.lastMessage), f = b.lastMessage?.author?.type === "bot";
|
|
717
717
|
return /* @__PURE__ */ l(
|
|
718
718
|
"button",
|
|
719
719
|
{
|
|
@@ -722,23 +722,23 @@ function io({
|
|
|
722
722
|
onClick: () => m(b.id),
|
|
723
723
|
"data-current": b.id === t || void 0,
|
|
724
724
|
children: [
|
|
725
|
-
/* @__PURE__ */ o("div", { className: "bp-webchat-history-avatar", "data-kind": f ? "bot" : "user", children: f && r ? /* @__PURE__ */ o("img", { src: r, alt: "" }) : f ? /* @__PURE__ */ o("span", { children: (s || "B").slice(0, 1).toUpperCase() }) :
|
|
725
|
+
/* @__PURE__ */ o("div", { className: "bp-webchat-history-avatar", "data-kind": f ? "bot" : "user", children: f && r ? /* @__PURE__ */ o("img", { src: r, alt: "" }) : f ? /* @__PURE__ */ o("span", { children: (s || "B").slice(0, 1).toUpperCase() }) : uo }),
|
|
726
726
|
/* @__PURE__ */ l("div", { className: "bp-webchat-history-content", children: [
|
|
727
727
|
/* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children: U }),
|
|
728
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children:
|
|
728
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: mo(b.updatedAt) })
|
|
729
729
|
] }),
|
|
730
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children:
|
|
730
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children: co })
|
|
731
731
|
]
|
|
732
732
|
},
|
|
733
733
|
b.id
|
|
734
734
|
);
|
|
735
735
|
}) }),
|
|
736
736
|
/* @__PURE__ */ o("div", { className: "bp-webchat-history-footer", children: /* @__PURE__ */ l("button", { className: "bp-webchat-history-new", type: "button", onClick: w, children: [
|
|
737
|
-
|
|
737
|
+
io,
|
|
738
738
|
/* @__PURE__ */ o("span", { children: "Nova conversa" })
|
|
739
739
|
] }) }),
|
|
740
740
|
/* @__PURE__ */ o(
|
|
741
|
-
|
|
741
|
+
je,
|
|
742
742
|
{
|
|
743
743
|
activeView: "conversations",
|
|
744
744
|
onShowHome: i,
|
|
@@ -747,11 +747,11 @@ function io({
|
|
|
747
747
|
)
|
|
748
748
|
] });
|
|
749
749
|
}
|
|
750
|
-
const
|
|
751
|
-
function
|
|
752
|
-
const { label: t, options: a = [], sendMessage: r, isReadOnly: s, messageId: n } = e, [c, i] = S(!1), [u, w] = S(""), [m, b] = S(0), [U, f] = S(null), B =
|
|
753
|
-
const d =
|
|
754
|
-
return d ? a.filter((p) =>
|
|
750
|
+
const Re = (e) => String(e ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim();
|
|
751
|
+
function ko(e) {
|
|
752
|
+
const { label: t, options: a = [], sendMessage: r, isReadOnly: s, messageId: n } = e, [c, i] = S(!1), [u, w] = S(""), [m, b] = S(0), [U, f] = S(null), B = Y(null), F = Y([]), _ = s || U !== null || a.length === 0, V = k(() => {
|
|
753
|
+
const d = Re(u);
|
|
754
|
+
return d ? a.filter((p) => Re(p.label).includes(d)) : a;
|
|
755
755
|
}, [a, u]);
|
|
756
756
|
M(() => {
|
|
757
757
|
b(0);
|
|
@@ -764,9 +764,9 @@ function uo(e) {
|
|
|
764
764
|
}, [c]), M(() => {
|
|
765
765
|
c && F.current[m]?.scrollIntoView({ block: "nearest" });
|
|
766
766
|
}, [m, c]);
|
|
767
|
-
const
|
|
767
|
+
const W = (d) => {
|
|
768
768
|
d && (r?.({ type: "text", text: d.label, value: d.value }), f(d.label), w(""), i(!1));
|
|
769
|
-
},
|
|
769
|
+
}, G = (d) => {
|
|
770
770
|
if (!_)
|
|
771
771
|
switch (d.key) {
|
|
772
772
|
case "ArrowDown":
|
|
@@ -780,13 +780,13 @@ function uo(e) {
|
|
|
780
780
|
d.preventDefault(), b((p) => Math.max(p - 1, 0));
|
|
781
781
|
break;
|
|
782
782
|
case "Enter":
|
|
783
|
-
d.preventDefault(), c &&
|
|
783
|
+
d.preventDefault(), c && W(V[m]);
|
|
784
784
|
break;
|
|
785
785
|
case "Escape":
|
|
786
786
|
i(!1);
|
|
787
787
|
break;
|
|
788
788
|
}
|
|
789
|
-
},
|
|
789
|
+
}, N = `bpDropdownList-${n ?? "x"}`;
|
|
790
790
|
return /* @__PURE__ */ l(
|
|
791
791
|
"div",
|
|
792
792
|
{
|
|
@@ -804,7 +804,7 @@ function uo(e) {
|
|
|
804
804
|
type: "text",
|
|
805
805
|
role: "combobox",
|
|
806
806
|
"aria-expanded": c,
|
|
807
|
-
"aria-controls":
|
|
807
|
+
"aria-controls": N,
|
|
808
808
|
"aria-autocomplete": "list",
|
|
809
809
|
autoComplete: "off",
|
|
810
810
|
placeholder: "Selecione...",
|
|
@@ -816,12 +816,12 @@ function uo(e) {
|
|
|
816
816
|
onChange: (d) => {
|
|
817
817
|
w(d.target.value), i(!0);
|
|
818
818
|
},
|
|
819
|
-
onKeyDown:
|
|
819
|
+
onKeyDown: G
|
|
820
820
|
}
|
|
821
821
|
),
|
|
822
|
-
/* @__PURE__ */ o("span", { className: "bpDropdownChevron", children:
|
|
822
|
+
/* @__PURE__ */ o("span", { className: "bpDropdownChevron", children: lo })
|
|
823
823
|
] }),
|
|
824
|
-
c && !_ ? /* @__PURE__ */ o("ul", { className: "bpDropdownMenu", id:
|
|
824
|
+
c && !_ ? /* @__PURE__ */ o("ul", { className: "bpDropdownMenu", id: N, role: "listbox", children: V.length > 0 ? V.map((d, p) => /* @__PURE__ */ o(
|
|
825
825
|
"li",
|
|
826
826
|
{
|
|
827
827
|
ref: (R) => {
|
|
@@ -833,7 +833,7 @@ function uo(e) {
|
|
|
833
833
|
"data-active": p === m || void 0,
|
|
834
834
|
onMouseEnter: () => b(p),
|
|
835
835
|
onMouseDown: (R) => {
|
|
836
|
-
R.preventDefault(),
|
|
836
|
+
R.preventDefault(), W(d);
|
|
837
837
|
},
|
|
838
838
|
children: d.label
|
|
839
839
|
},
|
|
@@ -843,7 +843,7 @@ function uo(e) {
|
|
|
843
843
|
}
|
|
844
844
|
);
|
|
845
845
|
}
|
|
846
|
-
function
|
|
846
|
+
function xo({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
|
|
847
847
|
return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
|
|
848
848
|
/* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Nos ajude a melhorar" }),
|
|
849
849
|
/* @__PURE__ */ o("p", { className: "bp-webchat-modal-description", children: "Conte o que não ficou bom nesta resposta." }),
|
|
@@ -870,7 +870,7 @@ function bo({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
|
|
|
870
870
|
] })
|
|
871
871
|
] }) }) : null;
|
|
872
872
|
}
|
|
873
|
-
function
|
|
873
|
+
function No({ open: e, onConfirm: t, onCancel: a }) {
|
|
874
874
|
return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
|
|
875
875
|
/* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Criar nova conversa" }),
|
|
876
876
|
/* @__PURE__ */ o("p", { className: "bp-webchat-modal-description", children: "Isso vai limpar a conversa atual e iniciar uma nova sessão com o bot." }),
|
|
@@ -888,7 +888,7 @@ function ho({ open: e, onConfirm: t, onCancel: a }) {
|
|
|
888
888
|
] })
|
|
889
889
|
] }) }) : null;
|
|
890
890
|
}
|
|
891
|
-
function
|
|
891
|
+
function Io({ config: e, activeView: t, onShowHome: a, onShowConversations: r, onStart: s, onClose: n }) {
|
|
892
892
|
const c = e.welcomeCardImage || e.botAvatar;
|
|
893
893
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-welcome", children: [
|
|
894
894
|
/* @__PURE__ */ l("div", { className: "bp-webchat-welcome-hero", children: [
|
|
@@ -914,11 +914,11 @@ function po({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
|
|
|
914
914
|
/* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-title", children: e.welcomeCtaLabel }),
|
|
915
915
|
e.welcomeButtonDescription ? /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-description", children: e.welcomeButtonDescription }) : null
|
|
916
916
|
] }) }),
|
|
917
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-right", children:
|
|
917
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-right", children: oo })
|
|
918
918
|
] })
|
|
919
919
|
] }) }),
|
|
920
920
|
/* @__PURE__ */ o(
|
|
921
|
-
|
|
921
|
+
je,
|
|
922
922
|
{
|
|
923
923
|
activeView: t,
|
|
924
924
|
onShowHome: a,
|
|
@@ -927,43 +927,43 @@ function po({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
|
|
|
927
927
|
)
|
|
928
928
|
] });
|
|
929
929
|
}
|
|
930
|
-
const
|
|
930
|
+
const Mo = 220, fe = "eduzz-webchat", xe = Object.freeze({
|
|
931
931
|
allowFileUpload: !1,
|
|
932
932
|
allowMessageFeedback: !1
|
|
933
|
-
}),
|
|
933
|
+
}), So = "anonymous-id", To = (e) => !!e && typeof e == "object" && !Array.isArray(e), We = (e) => e.replace(/\/+$/, ""), Se = ({ webchatProxyUrl: e }) => {
|
|
934
934
|
if (typeof e != "string" || !e.trim())
|
|
935
935
|
return null;
|
|
936
|
-
const t =
|
|
936
|
+
const t = We(e.trim()), a = "/webchat/proxy";
|
|
937
937
|
return t.endsWith(a) ? t.slice(0, -a.length) : null;
|
|
938
|
-
},
|
|
938
|
+
}, Ao = ({ webchatProxyUrl: e, clientId: t }) => !e || !t ? null : `${e.endsWith("/") ? e.slice(0, -1) : e}/${encodeURIComponent(t)}/runtime-config`, Uo = ({ webchatProxyUrl: e, clientId: t, presetSlug: a }) => {
|
|
939
939
|
if (!e || !t)
|
|
940
940
|
return null;
|
|
941
|
-
const r =
|
|
941
|
+
const r = Se({ webchatProxyUrl: e });
|
|
942
942
|
if (!r)
|
|
943
943
|
return null;
|
|
944
944
|
const s = new URLSearchParams();
|
|
945
945
|
typeof a == "string" && a.trim() && s.set("slug", a.trim());
|
|
946
946
|
const n = s.toString();
|
|
947
947
|
return `${r}/webchat/bootstrap/${encodeURIComponent(t)}${n ? `?${n}` : ""}`;
|
|
948
|
-
},
|
|
948
|
+
}, Vo = (e) => {
|
|
949
949
|
const t = e && typeof e == "object" && e.data && typeof e.data == "object" ? e.data : e;
|
|
950
950
|
return t && typeof t == "object" ? t : null;
|
|
951
|
-
},
|
|
951
|
+
}, re = (e) => To(e) ? e : null, Ro = (e) => {
|
|
952
952
|
if (!e) return "";
|
|
953
953
|
try {
|
|
954
954
|
return JSON.stringify(e);
|
|
955
955
|
} catch {
|
|
956
956
|
return String(Date.now());
|
|
957
957
|
}
|
|
958
|
-
},
|
|
958
|
+
}, Ge = (e) => {
|
|
959
959
|
if (typeof window > "u") return null;
|
|
960
960
|
try {
|
|
961
961
|
return e === "sessionStorage" ? window.sessionStorage : window.localStorage;
|
|
962
962
|
} catch {
|
|
963
963
|
return null;
|
|
964
964
|
}
|
|
965
|
-
},
|
|
966
|
-
const a =
|
|
965
|
+
}, Ke = ({ storageKey: e, storageLocation: t }) => {
|
|
966
|
+
const a = Ge(t);
|
|
967
967
|
if (!a) return null;
|
|
968
968
|
try {
|
|
969
969
|
const r = a.getItem(
|
|
@@ -975,10 +975,13 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
975
975
|
} catch {
|
|
976
976
|
return;
|
|
977
977
|
}
|
|
978
|
-
},
|
|
979
|
-
const a =
|
|
978
|
+
}, Do = ({ storageKey: e, storageLocation: t }) => {
|
|
979
|
+
const a = Ke({
|
|
980
|
+
storageKey: e,
|
|
981
|
+
storageLocation: t
|
|
982
|
+
});
|
|
980
983
|
return typeof a?.conversationId == "string" && a.conversationId.trim() || void 0;
|
|
981
|
-
},
|
|
984
|
+
}, De = () => {
|
|
982
985
|
try {
|
|
983
986
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
|
|
984
987
|
return crypto.randomUUID();
|
|
@@ -992,19 +995,23 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
992
995
|
const t = Math.random() * 16 | 0;
|
|
993
996
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
994
997
|
});
|
|
995
|
-
},
|
|
996
|
-
const a =
|
|
998
|
+
}, Fo = (e) => `${e || fe}-${So}`, Po = ({ storageKey: e, storageLocation: t }) => {
|
|
999
|
+
const a = Ge(t), r = Fo(e);
|
|
997
1000
|
try {
|
|
998
1001
|
const s = a?.getItem(r);
|
|
999
1002
|
if (s)
|
|
1000
1003
|
return s;
|
|
1001
|
-
const n = `anon_${
|
|
1004
|
+
const n = `anon_${De()}`;
|
|
1002
1005
|
return a?.setItem(r, n), n;
|
|
1003
1006
|
} catch {
|
|
1004
|
-
return `anon_${
|
|
1007
|
+
return `anon_${De()}`;
|
|
1005
1008
|
}
|
|
1006
|
-
},
|
|
1007
|
-
|
|
1009
|
+
}, Ho = async ({
|
|
1010
|
+
webchatProxyUrl: e,
|
|
1011
|
+
clientId: t,
|
|
1012
|
+
accountId: a
|
|
1013
|
+
}) => {
|
|
1014
|
+
const r = Se({ webchatProxyUrl: e });
|
|
1008
1015
|
if (!r)
|
|
1009
1016
|
throw new Error("public session request requires a valid webchatProxyUrl");
|
|
1010
1017
|
const s = await fetch(
|
|
@@ -1018,7 +1025,9 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
1018
1025
|
}
|
|
1019
1026
|
);
|
|
1020
1027
|
if (!s.ok)
|
|
1021
|
-
throw new Error(
|
|
1028
|
+
throw new Error(
|
|
1029
|
+
`public session request failed with status ${s.status}`
|
|
1030
|
+
);
|
|
1022
1031
|
const n = await s.json(), c = n && typeof n == "object" && n.data && typeof n.data == "object" ? n.data : n;
|
|
1023
1032
|
if (!c || typeof c != "object")
|
|
1024
1033
|
throw new Error("public session response is invalid");
|
|
@@ -1028,11 +1037,11 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
1028
1037
|
userId: c.userId,
|
|
1029
1038
|
userToken: c.userToken
|
|
1030
1039
|
};
|
|
1031
|
-
},
|
|
1040
|
+
}, $o = (e) => ({
|
|
1032
1041
|
...typeof e.name == "string" && e.name.trim() ? { name: e.name.trim() } : {},
|
|
1033
1042
|
...typeof e.pictureUrl == "string" && e.pictureUrl.trim() ? { pictureUrl: e.pictureUrl.trim() } : {},
|
|
1034
1043
|
userData: e
|
|
1035
|
-
}),
|
|
1044
|
+
}), Lo = ({
|
|
1036
1045
|
showWelcomeScreen: e,
|
|
1037
1046
|
storageKey: t,
|
|
1038
1047
|
storageLocation: a,
|
|
@@ -1040,17 +1049,48 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
1040
1049
|
userToken: s
|
|
1041
1050
|
}) => {
|
|
1042
1051
|
if (!e)
|
|
1043
|
-
return {
|
|
1052
|
+
return {
|
|
1053
|
+
activeView: "chat",
|
|
1054
|
+
historyReturnView: "chat",
|
|
1055
|
+
bootstrapView: "chat"
|
|
1056
|
+
};
|
|
1044
1057
|
if (r && s)
|
|
1045
|
-
return {
|
|
1046
|
-
|
|
1058
|
+
return {
|
|
1059
|
+
activeView: "chat",
|
|
1060
|
+
historyReturnView: "chat",
|
|
1061
|
+
bootstrapView: "chat"
|
|
1062
|
+
};
|
|
1063
|
+
const n = Ke({
|
|
1064
|
+
storageKey: t,
|
|
1065
|
+
storageLocation: a
|
|
1066
|
+
});
|
|
1047
1067
|
if (n == null)
|
|
1048
|
-
return {
|
|
1068
|
+
return {
|
|
1069
|
+
activeView: "home",
|
|
1070
|
+
historyReturnView: "home",
|
|
1071
|
+
bootstrapView: "home"
|
|
1072
|
+
};
|
|
1049
1073
|
if (n === void 0)
|
|
1050
|
-
return {
|
|
1074
|
+
return {
|
|
1075
|
+
activeView: "pending",
|
|
1076
|
+
historyReturnView: "home",
|
|
1077
|
+
bootstrapView: "pending"
|
|
1078
|
+
};
|
|
1051
1079
|
const c = typeof n.conversationId == "string" ? n.conversationId.trim() : "", i = typeof n.user?.userToken == "string" ? n.user.userToken.trim() : "";
|
|
1052
|
-
return c && i ? {
|
|
1053
|
-
|
|
1080
|
+
return c && i ? {
|
|
1081
|
+
activeView: "chat",
|
|
1082
|
+
historyReturnView: "chat",
|
|
1083
|
+
bootstrapView: "chat"
|
|
1084
|
+
} : !c && !i ? {
|
|
1085
|
+
activeView: "home",
|
|
1086
|
+
historyReturnView: "home",
|
|
1087
|
+
bootstrapView: "home"
|
|
1088
|
+
} : {
|
|
1089
|
+
activeView: "pending",
|
|
1090
|
+
historyReturnView: "home",
|
|
1091
|
+
bootstrapView: "pending"
|
|
1092
|
+
};
|
|
1093
|
+
}, _o = (e, t) => {
|
|
1054
1094
|
switch (t.type) {
|
|
1055
1095
|
case "show":
|
|
1056
1096
|
return { isPanelMounted: !0, isPanelVisible: e.isPanelVisible };
|
|
@@ -1064,7 +1104,7 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
1064
1104
|
return e;
|
|
1065
1105
|
}
|
|
1066
1106
|
};
|
|
1067
|
-
function
|
|
1107
|
+
function jo({
|
|
1068
1108
|
clientId: e,
|
|
1069
1109
|
webchatProxyUrl: t,
|
|
1070
1110
|
userCredentials: a,
|
|
@@ -1080,29 +1120,34 @@ function Ro({
|
|
|
1080
1120
|
sessionKey: U,
|
|
1081
1121
|
onSessionChange: f
|
|
1082
1122
|
}) {
|
|
1083
|
-
const { session: B, resolving: F } =
|
|
1123
|
+
const { session: B, resolving: F } = yo({
|
|
1084
1124
|
getSession: b,
|
|
1085
1125
|
sessionKey: U,
|
|
1086
1126
|
onSessionChange: f
|
|
1087
|
-
}),
|
|
1127
|
+
}), Q = !!B && Date.now() < B.expiresAt, _ = Q ? { userId: B.userId, userToken: B.userToken } : void 0, V = b ? _ : a, W = Q ? B.conversationId : void 0, G = k(
|
|
1088
1128
|
() => typeof c == "string" && c.trim() ? c.trim() : void 0,
|
|
1089
1129
|
[c]
|
|
1090
|
-
),
|
|
1091
|
-
() => typeof t == "string" && t.trim() ?
|
|
1130
|
+
), N = k(
|
|
1131
|
+
() => typeof t == "string" && t.trim() ? We(t.trim()) : void 0,
|
|
1092
1132
|
[t]
|
|
1093
1133
|
);
|
|
1094
|
-
|
|
1095
|
-
() =>
|
|
1096
|
-
[
|
|
1134
|
+
k(
|
|
1135
|
+
() => N ? Se({ webchatProxyUrl: N }) : null,
|
|
1136
|
+
[N]
|
|
1097
1137
|
);
|
|
1098
|
-
const d = !!(e &&
|
|
1099
|
-
() => d ?
|
|
1100
|
-
webchatProxyUrl:
|
|
1138
|
+
const d = !!(e && N && (G || !V)), p = k(
|
|
1139
|
+
() => d ? Uo({
|
|
1140
|
+
webchatProxyUrl: N,
|
|
1101
1141
|
clientId: e,
|
|
1102
|
-
presetSlug:
|
|
1142
|
+
presetSlug: G
|
|
1103
1143
|
}) : null,
|
|
1104
|
-
[
|
|
1105
|
-
|
|
1144
|
+
[
|
|
1145
|
+
e,
|
|
1146
|
+
G,
|
|
1147
|
+
N,
|
|
1148
|
+
d
|
|
1149
|
+
]
|
|
1150
|
+
), [R, ee] = S({
|
|
1106
1151
|
error: null,
|
|
1107
1152
|
isLoading: !1,
|
|
1108
1153
|
payload: null,
|
|
@@ -1110,49 +1155,63 @@ function Ro({
|
|
|
1110
1155
|
});
|
|
1111
1156
|
M(() => {
|
|
1112
1157
|
if (!p) {
|
|
1113
|
-
|
|
1158
|
+
ee({
|
|
1159
|
+
error: null,
|
|
1160
|
+
isLoading: !1,
|
|
1161
|
+
payload: null,
|
|
1162
|
+
url: null
|
|
1163
|
+
});
|
|
1114
1164
|
return;
|
|
1115
1165
|
}
|
|
1116
|
-
const
|
|
1117
|
-
return
|
|
1166
|
+
const I = new AbortController();
|
|
1167
|
+
return ee({
|
|
1168
|
+
error: null,
|
|
1169
|
+
isLoading: !0,
|
|
1170
|
+
payload: null,
|
|
1171
|
+
url: p
|
|
1172
|
+
}), fetch(p, {
|
|
1118
1173
|
headers: {
|
|
1119
1174
|
accept: "application/json"
|
|
1120
1175
|
},
|
|
1121
|
-
signal:
|
|
1176
|
+
signal: I.signal
|
|
1122
1177
|
}).then(async (v) => {
|
|
1123
1178
|
if (!v.ok)
|
|
1124
|
-
throw new Error(
|
|
1179
|
+
throw new Error(
|
|
1180
|
+
`bootstrap request failed with status ${v.status}`
|
|
1181
|
+
);
|
|
1125
1182
|
return v.json();
|
|
1126
1183
|
}).then((v) => {
|
|
1127
|
-
const H =
|
|
1184
|
+
const H = Vo(v);
|
|
1128
1185
|
if (!H)
|
|
1129
1186
|
throw new Error("bootstrap response is invalid");
|
|
1130
|
-
|
|
1187
|
+
ee({
|
|
1131
1188
|
error: null,
|
|
1132
1189
|
isLoading: !1,
|
|
1133
1190
|
payload: H,
|
|
1134
1191
|
url: p
|
|
1135
1192
|
});
|
|
1136
1193
|
}).catch((v) => {
|
|
1137
|
-
|
|
1138
|
-
|
|
1194
|
+
I.signal.aborted || (console.warn("[EduzzWebchat] failed to load bootstrap", v), ee({
|
|
1195
|
+
error: v,
|
|
1196
|
+
isLoading: !1,
|
|
1197
|
+
payload: null,
|
|
1198
|
+
url: p
|
|
1199
|
+
}));
|
|
1200
|
+
}), () => I.abort();
|
|
1139
1201
|
}, [p]);
|
|
1140
|
-
const y = p && R.url === p ? R.payload : null,
|
|
1202
|
+
const y = p && R.url === p ? R.payload : null, de = p && R.url === p ? R.error : null, T = y?.clientId || e, P = N || y?.webchatProxyUrl || void 0, z = i === fe && y?.storageKey ? y.storageKey : i, K = typeof w == "boolean" ? w : typeof y?.defaultOpen == "boolean" ? y.defaultOpen : w, D = k(
|
|
1141
1203
|
() => ({
|
|
1142
|
-
...
|
|
1143
|
-
...
|
|
1204
|
+
...re(y?.config) || {},
|
|
1205
|
+
...re(s) || {}
|
|
1144
1206
|
}),
|
|
1145
1207
|
[y, s]
|
|
1146
|
-
), ge =
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
},
|
|
1154
|
-
[n, y]
|
|
1155
|
-
), E = !!(!V && !F && y?.sessionMode === "service-hub" && P && T), [re, ee] = S({
|
|
1208
|
+
), ge = k(() => {
|
|
1209
|
+
const I = {
|
|
1210
|
+
...re(y?.defaultUserData) || {},
|
|
1211
|
+
...re(n) || {}
|
|
1212
|
+
};
|
|
1213
|
+
return Object.keys(I).length > 0 ? I : null;
|
|
1214
|
+
}, [n, y]), E = !!(!V && !F && y?.sessionMode === "service-hub" && P && T), [se, te] = S({
|
|
1156
1215
|
error: null,
|
|
1157
1216
|
isLoading: !1,
|
|
1158
1217
|
payload: null,
|
|
@@ -1160,33 +1219,38 @@ function Ro({
|
|
|
1160
1219
|
});
|
|
1161
1220
|
M(() => {
|
|
1162
1221
|
if (!E) {
|
|
1163
|
-
|
|
1222
|
+
te({
|
|
1223
|
+
error: null,
|
|
1224
|
+
isLoading: !1,
|
|
1225
|
+
payload: null,
|
|
1226
|
+
key: null
|
|
1227
|
+
});
|
|
1164
1228
|
return;
|
|
1165
1229
|
}
|
|
1166
|
-
const
|
|
1230
|
+
const I = Po({
|
|
1167
1231
|
storageKey: z,
|
|
1168
1232
|
storageLocation: u
|
|
1169
|
-
}), v = `${T}:${P}:${
|
|
1233
|
+
}), v = `${T}:${P}:${I}`;
|
|
1170
1234
|
let H = !1;
|
|
1171
|
-
return
|
|
1235
|
+
return te({
|
|
1172
1236
|
error: null,
|
|
1173
1237
|
isLoading: !0,
|
|
1174
1238
|
payload: null,
|
|
1175
1239
|
key: v
|
|
1176
|
-
}),
|
|
1240
|
+
}), Ho({
|
|
1177
1241
|
webchatProxyUrl: P,
|
|
1178
1242
|
clientId: T,
|
|
1179
|
-
accountId:
|
|
1180
|
-
}).then((
|
|
1181
|
-
H ||
|
|
1243
|
+
accountId: I
|
|
1244
|
+
}).then((C) => {
|
|
1245
|
+
H || te({
|
|
1182
1246
|
error: null,
|
|
1183
1247
|
isLoading: !1,
|
|
1184
|
-
payload:
|
|
1248
|
+
payload: C,
|
|
1185
1249
|
key: v
|
|
1186
1250
|
});
|
|
1187
|
-
}).catch((
|
|
1188
|
-
H || (console.warn("[EduzzWebchat] failed to open public session",
|
|
1189
|
-
error:
|
|
1251
|
+
}).catch((C) => {
|
|
1252
|
+
H || (console.warn("[EduzzWebchat] failed to open public session", C), te({
|
|
1253
|
+
error: C,
|
|
1190
1254
|
isLoading: !1,
|
|
1191
1255
|
payload: null,
|
|
1192
1256
|
key: v
|
|
@@ -1201,77 +1265,89 @@ function Ro({
|
|
|
1201
1265
|
E,
|
|
1202
1266
|
u
|
|
1203
1267
|
]);
|
|
1204
|
-
const
|
|
1205
|
-
() =>
|
|
1268
|
+
const J = E ? se.payload : null, oe = V || J, O = k(
|
|
1269
|
+
() => Ct(D),
|
|
1270
|
+
[D]
|
|
1271
|
+
), ae = k(
|
|
1272
|
+
() => W || r || Do({
|
|
1206
1273
|
storageKey: z,
|
|
1207
1274
|
storageLocation: u
|
|
1208
1275
|
}),
|
|
1209
|
-
[
|
|
1210
|
-
|
|
1276
|
+
[
|
|
1277
|
+
W,
|
|
1278
|
+
r,
|
|
1279
|
+
z,
|
|
1280
|
+
u
|
|
1281
|
+
]
|
|
1282
|
+
), $ = K ?? O.initiallyOpen ?? !0, [ye, X] = S($), ce = Y($), [q, ne] = S(
|
|
1283
|
+
xe
|
|
1284
|
+
), ve = le(() => X((I) => !I), []);
|
|
1211
1285
|
M(() => {
|
|
1212
|
-
|
|
1286
|
+
ce.current !== $ && (ce.current = $, X($));
|
|
1213
1287
|
}, [$]);
|
|
1214
|
-
const
|
|
1288
|
+
const ue = d && !y && !de, Ce = E && !J && !se.error;
|
|
1215
1289
|
return M(() => {
|
|
1216
|
-
const
|
|
1290
|
+
const I = Ao({
|
|
1217
1291
|
webchatProxyUrl: P,
|
|
1218
1292
|
clientId: T
|
|
1219
1293
|
});
|
|
1220
|
-
if (
|
|
1294
|
+
if (ne(xe), !I)
|
|
1221
1295
|
return;
|
|
1222
1296
|
const v = new AbortController();
|
|
1223
1297
|
let H = !1;
|
|
1224
|
-
return fetch(
|
|
1298
|
+
return fetch(I, {
|
|
1225
1299
|
headers: {
|
|
1226
1300
|
accept: "application/json"
|
|
1227
1301
|
},
|
|
1228
1302
|
signal: v.signal
|
|
1229
|
-
}).then(async (
|
|
1230
|
-
if (!
|
|
1231
|
-
throw new Error(
|
|
1232
|
-
|
|
1233
|
-
|
|
1303
|
+
}).then(async (C) => {
|
|
1304
|
+
if (!C.ok)
|
|
1305
|
+
throw new Error(
|
|
1306
|
+
`runtime config request failed with status ${C.status}`
|
|
1307
|
+
);
|
|
1308
|
+
return C.json();
|
|
1309
|
+
}).then((C) => {
|
|
1234
1310
|
if (H)
|
|
1235
1311
|
return;
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1238
|
-
allowFileUpload:
|
|
1239
|
-
allowMessageFeedback:
|
|
1312
|
+
const h = C && typeof C == "object" && C.data && typeof C.data == "object" ? C.data : {};
|
|
1313
|
+
ne({
|
|
1314
|
+
allowFileUpload: h.allowFileUpload === !0,
|
|
1315
|
+
allowMessageFeedback: h.allowMessageFeedback === !0
|
|
1240
1316
|
});
|
|
1241
|
-
}).catch((
|
|
1242
|
-
v.signal.aborted || H || (console.warn("[EduzzWebchat] failed to load runtime config",
|
|
1317
|
+
}).catch((C) => {
|
|
1318
|
+
v.signal.aborted || H || (console.warn("[EduzzWebchat] failed to load runtime config", C), ne(xe));
|
|
1243
1319
|
}), () => {
|
|
1244
1320
|
H = !0, v.abort();
|
|
1245
1321
|
};
|
|
1246
|
-
}, [T, P]),
|
|
1247
|
-
|
|
1322
|
+
}, [T, P]), ue || Ce || b && F ? null : de && !y ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel carregar a configuracao publica do webchat." }) }) : se.error && !J ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel abrir a sessao publica do webchat." }) }) : P ? T ? /* @__PURE__ */ o(
|
|
1323
|
+
dt,
|
|
1248
1324
|
{
|
|
1249
1325
|
clientId: T,
|
|
1250
1326
|
apiUrl: P,
|
|
1251
|
-
conversationId:
|
|
1252
|
-
userCredentials:
|
|
1327
|
+
conversationId: ae,
|
|
1328
|
+
userCredentials: oe,
|
|
1253
1329
|
storageKey: z,
|
|
1254
1330
|
storageLocation: u,
|
|
1255
1331
|
children: /* @__PURE__ */ o(
|
|
1256
|
-
|
|
1332
|
+
zo,
|
|
1257
1333
|
{
|
|
1258
1334
|
clientId: T,
|
|
1259
1335
|
config: O,
|
|
1260
1336
|
defaultUserData: ge,
|
|
1261
|
-
conversationIdProp:
|
|
1337
|
+
conversationIdProp: ae,
|
|
1262
1338
|
isOpen: ye,
|
|
1263
1339
|
onUserApiChange: m,
|
|
1264
1340
|
onToggle: ve,
|
|
1265
1341
|
runtimeCapabilities: q,
|
|
1266
1342
|
storageKey: z,
|
|
1267
1343
|
storageLocation: u,
|
|
1268
|
-
userToken:
|
|
1344
|
+
userToken: oe?.userToken
|
|
1269
1345
|
}
|
|
1270
1346
|
)
|
|
1271
1347
|
}
|
|
1272
|
-
) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style:
|
|
1348
|
+
) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhum clientId foi informado." }) }) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhuma URL publica do proxy do webchat foi informada." }) });
|
|
1273
1349
|
}
|
|
1274
|
-
function
|
|
1350
|
+
function zo({
|
|
1275
1351
|
clientId: e,
|
|
1276
1352
|
config: t,
|
|
1277
1353
|
defaultUserData: a,
|
|
@@ -1284,8 +1360,8 @@ function To({
|
|
|
1284
1360
|
storageLocation: w,
|
|
1285
1361
|
userToken: m
|
|
1286
1362
|
}) {
|
|
1287
|
-
const b =
|
|
1288
|
-
() =>
|
|
1363
|
+
const b = k(
|
|
1364
|
+
() => Lo({
|
|
1289
1365
|
showWelcomeScreen: t.showWelcomeScreen,
|
|
1290
1366
|
storageKey: u,
|
|
1291
1367
|
storageLocation: w,
|
|
@@ -1299,147 +1375,215 @@ function To({
|
|
|
1299
1375
|
w,
|
|
1300
1376
|
m
|
|
1301
1377
|
]
|
|
1302
|
-
), [U, f] = S(!1), [B, F] = S({
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1378
|
+
), [U, f] = S(!1), [B, F] = S({
|
|
1379
|
+
open: !1,
|
|
1380
|
+
messageId: null,
|
|
1381
|
+
draft: ""
|
|
1382
|
+
}), [{ isPanelMounted: Q, isPanelVisible: _ }, V] = st(
|
|
1383
|
+
_o,
|
|
1384
|
+
{
|
|
1385
|
+
isPanelMounted: s,
|
|
1386
|
+
isPanelVisible: s
|
|
1387
|
+
}
|
|
1388
|
+
), {
|
|
1389
|
+
conversationId: W,
|
|
1390
|
+
isTyping: G,
|
|
1391
|
+
messages: N,
|
|
1309
1392
|
saveMessageFeedback: d,
|
|
1310
1393
|
sendMessage: p,
|
|
1311
1394
|
status: R,
|
|
1312
|
-
uploadFile:
|
|
1313
|
-
} =
|
|
1395
|
+
uploadFile: ee
|
|
1396
|
+
} = ut(), { openConversation: y, listConversations: de } = bt(), { updateUser: T, userCredentials: P } = ht(), z = Y({}), [K, D] = S(
|
|
1397
|
+
() => b.activeView
|
|
1398
|
+
), [ge, E] = S(
|
|
1399
|
+
() => b.historyReturnView
|
|
1400
|
+
), {
|
|
1401
|
+
conversations: se,
|
|
1402
|
+
isLoading: te,
|
|
1403
|
+
refresh: J
|
|
1404
|
+
} = pt({
|
|
1314
1405
|
userCredentials: P,
|
|
1315
|
-
listConversations:
|
|
1406
|
+
listConversations: de,
|
|
1316
1407
|
clientId: e
|
|
1317
|
-
}),
|
|
1318
|
-
() =>
|
|
1408
|
+
}), oe = k(
|
|
1409
|
+
() => Ro(a),
|
|
1319
1410
|
[a]
|
|
1320
|
-
), O =
|
|
1321
|
-
async (
|
|
1411
|
+
), O = le(
|
|
1412
|
+
async (h = {}) => {
|
|
1322
1413
|
if (!T)
|
|
1323
1414
|
return;
|
|
1324
|
-
const
|
|
1325
|
-
...
|
|
1415
|
+
const j = {
|
|
1416
|
+
...re(a) || {},
|
|
1326
1417
|
...z.current,
|
|
1327
|
-
...
|
|
1418
|
+
...re(h) || {}
|
|
1328
1419
|
};
|
|
1329
|
-
return z.current =
|
|
1420
|
+
return z.current = j, T($o(j));
|
|
1330
1421
|
},
|
|
1331
1422
|
[a, T]
|
|
1332
|
-
),
|
|
1423
|
+
), ae = Y(O);
|
|
1333
1424
|
M(() => {
|
|
1334
|
-
|
|
1425
|
+
ae.current = O;
|
|
1335
1426
|
}, [O]);
|
|
1336
1427
|
const $ = !!T;
|
|
1337
1428
|
M(() => {
|
|
1338
1429
|
z.current = {};
|
|
1339
|
-
}, [
|
|
1430
|
+
}, [oe]), M(() => {
|
|
1340
1431
|
if (n)
|
|
1341
1432
|
return n({
|
|
1342
|
-
updateUserData: $ ? (
|
|
1433
|
+
updateUserData: $ ? (h) => ae.current(h) : void 0
|
|
1343
1434
|
}), () => n(null);
|
|
1344
1435
|
}, [n, $]), M(() => {
|
|
1345
|
-
!$ || !
|
|
1346
|
-
}, [
|
|
1436
|
+
!$ || !oe || ae.current();
|
|
1437
|
+
}, [oe, $]), M(() => {
|
|
1347
1438
|
i.allowMessageFeedback || F({ open: !1, messageId: null, draft: "" });
|
|
1348
1439
|
}, [i.allowMessageFeedback]);
|
|
1349
|
-
const { showInitialLoading: ye, setShowInitialLoading:
|
|
1350
|
-
activeView:
|
|
1440
|
+
const { showInitialLoading: ye, setShowInitialLoading: X } = fo({
|
|
1441
|
+
activeView: K,
|
|
1351
1442
|
clientState: R,
|
|
1352
|
-
conversationId:
|
|
1353
|
-
messagesLength:
|
|
1354
|
-
}),
|
|
1355
|
-
() => t.botAvatar ||
|
|
1443
|
+
conversationId: W,
|
|
1444
|
+
messagesLength: N.length
|
|
1445
|
+
}), ce = k(
|
|
1446
|
+
() => t.botAvatar || bo({
|
|
1447
|
+
name: t.botName,
|
|
1448
|
+
backgroundColor: t.accentColor
|
|
1449
|
+
}),
|
|
1356
1450
|
[t.accentColor, t.botAvatar, t.botName]
|
|
1357
|
-
), q =
|
|
1358
|
-
() => ({ ...t, botAvatar:
|
|
1359
|
-
[t,
|
|
1360
|
-
),
|
|
1361
|
-
async (
|
|
1362
|
-
E(
|
|
1451
|
+
), q = k(
|
|
1452
|
+
() => ({ ...t, botAvatar: ce }),
|
|
1453
|
+
[t, ce]
|
|
1454
|
+
), ne = le(
|
|
1455
|
+
async (h) => {
|
|
1456
|
+
E(h), D("conversations"), await J();
|
|
1363
1457
|
},
|
|
1364
|
-
[
|
|
1365
|
-
), ve =
|
|
1366
|
-
(
|
|
1367
|
-
|
|
1458
|
+
[J]
|
|
1459
|
+
), ve = le(
|
|
1460
|
+
(h) => {
|
|
1461
|
+
X(!0), y(h), D("chat");
|
|
1368
1462
|
},
|
|
1369
|
-
[y,
|
|
1370
|
-
),
|
|
1371
|
-
|
|
1372
|
-
}, [y,
|
|
1373
|
-
() =>
|
|
1374
|
-
messages:
|
|
1463
|
+
[y, X]
|
|
1464
|
+
), ue = le(() => {
|
|
1465
|
+
X(!0), y(), D("chat");
|
|
1466
|
+
}, [y, X]), Ce = k(
|
|
1467
|
+
() => wo({
|
|
1468
|
+
messages: N,
|
|
1375
1469
|
user: P,
|
|
1376
1470
|
botName: q.botName,
|
|
1377
1471
|
botAvatar: q.botAvatar
|
|
1378
1472
|
}),
|
|
1379
|
-
[
|
|
1380
|
-
),
|
|
1473
|
+
[N, q.botAvatar, q.botName, P]
|
|
1474
|
+
), I = ie(t), v = k(() => Bt(t), [t]), H = k(
|
|
1475
|
+
() => to(t.fabChatIconVariant),
|
|
1476
|
+
[t.fabChatIconVariant]
|
|
1477
|
+
);
|
|
1381
1478
|
M(() => {
|
|
1382
1479
|
if (s) {
|
|
1383
1480
|
V({ type: "show" });
|
|
1384
|
-
const be = window.requestAnimationFrame(
|
|
1481
|
+
const be = window.requestAnimationFrame(
|
|
1482
|
+
() => V({ type: "visible" })
|
|
1483
|
+
);
|
|
1385
1484
|
return () => window.cancelAnimationFrame(be);
|
|
1386
1485
|
}
|
|
1387
1486
|
V({ type: "hide" });
|
|
1388
|
-
const
|
|
1487
|
+
const h = window.setTimeout(() => {
|
|
1389
1488
|
f(!1), F({ open: !1, messageId: null, draft: "" });
|
|
1390
|
-
}, 0),
|
|
1489
|
+
}, 0), j = window.setTimeout(
|
|
1490
|
+
() => V({ type: "unmount" }),
|
|
1491
|
+
Mo
|
|
1492
|
+
);
|
|
1391
1493
|
return () => {
|
|
1392
|
-
window.clearTimeout(
|
|
1494
|
+
window.clearTimeout(h), window.clearTimeout(j);
|
|
1393
1495
|
};
|
|
1394
1496
|
}, [s]), M(() => {
|
|
1395
1497
|
if (b.bootstrapView === "pending") {
|
|
1396
|
-
if (
|
|
1397
|
-
const
|
|
1498
|
+
if (N.length > 0) {
|
|
1499
|
+
const h = window.setTimeout(() => {
|
|
1398
1500
|
D("chat"), E("chat");
|
|
1399
1501
|
}, 0);
|
|
1400
|
-
return () => window.clearTimeout(
|
|
1502
|
+
return () => window.clearTimeout(h);
|
|
1401
1503
|
}
|
|
1402
1504
|
if (R !== "connecting") {
|
|
1403
|
-
const
|
|
1505
|
+
const h = window.setTimeout(() => {
|
|
1404
1506
|
D("home"), E("home");
|
|
1405
1507
|
}, 0);
|
|
1406
|
-
return () => window.clearTimeout(
|
|
1508
|
+
return () => window.clearTimeout(h);
|
|
1407
1509
|
}
|
|
1408
1510
|
}
|
|
1409
|
-
}, [R, b.bootstrapView,
|
|
1410
|
-
const
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1511
|
+
}, [R, b.bootstrapView, N.length]);
|
|
1512
|
+
const C = k(() => {
|
|
1513
|
+
const h = {};
|
|
1514
|
+
h.dropdown = ko;
|
|
1515
|
+
const j = (be, g) => function({
|
|
1516
|
+
blocks: ke,
|
|
1517
|
+
horizontalAlignment: Je,
|
|
1518
|
+
verticalAlignment: Xe,
|
|
1519
|
+
direction: Ze,
|
|
1520
|
+
sender: Ye,
|
|
1521
|
+
timestamp: Qe,
|
|
1522
|
+
metadata: et,
|
|
1523
|
+
messageId: tt,
|
|
1524
|
+
isReadOnly: ot,
|
|
1525
|
+
sendMessage: at
|
|
1526
|
+
}) {
|
|
1527
|
+
return /* @__PURE__ */ o(
|
|
1528
|
+
"div",
|
|
1529
|
+
{
|
|
1530
|
+
className: be,
|
|
1531
|
+
"data-horizontal": Je,
|
|
1532
|
+
"data-vertical": Xe,
|
|
1533
|
+
children: ke.map((nt, rt) => /* @__PURE__ */ o(
|
|
1534
|
+
Te,
|
|
1535
|
+
{
|
|
1536
|
+
block: {
|
|
1537
|
+
...nt,
|
|
1538
|
+
direction: Ze,
|
|
1539
|
+
timestamp: Qe,
|
|
1540
|
+
sender: Ye,
|
|
1541
|
+
messageId: tt,
|
|
1542
|
+
isReadOnly: ot,
|
|
1543
|
+
sendMessage: at,
|
|
1544
|
+
...g ? { metadata: et } : {}
|
|
1545
|
+
},
|
|
1546
|
+
renderers: h
|
|
1547
|
+
},
|
|
1548
|
+
rt
|
|
1549
|
+
))
|
|
1550
|
+
}
|
|
1551
|
+
);
|
|
1552
|
+
};
|
|
1553
|
+
return h.column = j("bpMessageBlocksColumn", !1), h.row = j("bpMessageBlocksRow", !0), h.bubble = function(g) {
|
|
1554
|
+
const Be = i.allowMessageFeedback && g.direction === "incoming" && typeof g.addMessageFeedback == "function", ke = {
|
|
1555
|
+
...g.block,
|
|
1556
|
+
direction: g.direction,
|
|
1557
|
+
sender: g.sender,
|
|
1558
|
+
timestamp: g.timestamp,
|
|
1559
|
+
messageId: g.messageId,
|
|
1560
|
+
metadata: g.metadata,
|
|
1561
|
+
isReadOnly: g.isReadOnly,
|
|
1562
|
+
status: g.status,
|
|
1563
|
+
feedback: g.feedback,
|
|
1564
|
+
sendMessage: g.sendMessage,
|
|
1565
|
+
addMessageFeedback: g.addMessageFeedback
|
|
1424
1566
|
};
|
|
1425
1567
|
return /* @__PURE__ */ l(
|
|
1426
1568
|
"div",
|
|
1427
1569
|
{
|
|
1428
1570
|
className: "bpMessageBlocksBubble",
|
|
1429
|
-
"data-direction":
|
|
1430
|
-
"data-feedback":
|
|
1571
|
+
"data-direction": g.direction,
|
|
1572
|
+
"data-feedback": Be || void 0,
|
|
1431
1573
|
children: [
|
|
1432
|
-
/* @__PURE__ */ o(
|
|
1433
|
-
|
|
1574
|
+
/* @__PURE__ */ o(Te, { block: ke, renderers: h }),
|
|
1575
|
+
Be ? /* @__PURE__ */ l("div", { className: "bpMessageBlocksBubbleFeedbackContainer", children: [
|
|
1434
1576
|
/* @__PURE__ */ o(
|
|
1435
1577
|
"button",
|
|
1436
1578
|
{
|
|
1437
1579
|
className: "bpMessageBlocksBubbleFeedbackIcon",
|
|
1438
1580
|
type: "button",
|
|
1439
|
-
"data-selected":
|
|
1581
|
+
"data-selected": g.feedback === "positive",
|
|
1440
1582
|
"aria-label": "Feedback positivo",
|
|
1441
|
-
onClick: () =>
|
|
1442
|
-
|
|
1583
|
+
onClick: () => g.addMessageFeedback(g.messageId, {
|
|
1584
|
+
value: "positive"
|
|
1585
|
+
}),
|
|
1586
|
+
children: no
|
|
1443
1587
|
}
|
|
1444
1588
|
),
|
|
1445
1589
|
/* @__PURE__ */ o(
|
|
@@ -1447,110 +1591,121 @@ function To({
|
|
|
1447
1591
|
{
|
|
1448
1592
|
className: "bpMessageBlocksBubbleFeedbackIcon",
|
|
1449
1593
|
type: "button",
|
|
1450
|
-
"data-selected":
|
|
1594
|
+
"data-selected": g.feedback === "negative",
|
|
1451
1595
|
"aria-label": "Feedback negativo",
|
|
1452
1596
|
onClick: () => F({
|
|
1453
1597
|
open: !0,
|
|
1454
|
-
messageId:
|
|
1598
|
+
messageId: g.messageId,
|
|
1455
1599
|
draft: ""
|
|
1456
1600
|
}),
|
|
1457
|
-
children:
|
|
1601
|
+
children: ro
|
|
1458
1602
|
}
|
|
1459
1603
|
)
|
|
1460
1604
|
] }) : null
|
|
1461
1605
|
]
|
|
1462
1606
|
}
|
|
1463
1607
|
);
|
|
1464
|
-
},
|
|
1465
|
-
|
|
1466
|
-
), ue = C(
|
|
1467
|
-
() => ({ bubble: g, dropdown: uo }),
|
|
1468
|
-
[g]
|
|
1469
|
-
);
|
|
1608
|
+
}, h;
|
|
1609
|
+
}, [i.allowMessageFeedback]);
|
|
1470
1610
|
return /* @__PURE__ */ l(
|
|
1471
1611
|
"div",
|
|
1472
1612
|
{
|
|
1473
1613
|
className: "bp-webchat-shell",
|
|
1474
|
-
"data-panel-mounted":
|
|
1614
|
+
"data-panel-mounted": Q,
|
|
1475
1615
|
"data-panel-open": _,
|
|
1476
|
-
style:
|
|
1616
|
+
style: I,
|
|
1477
1617
|
children: [
|
|
1478
|
-
/* @__PURE__ */ o(
|
|
1479
|
-
|
|
1480
|
-
|
|
1618
|
+
/* @__PURE__ */ o(mt, { ...v }),
|
|
1619
|
+
Q ? /* @__PURE__ */ o(
|
|
1620
|
+
"div",
|
|
1481
1621
|
{
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
currentConversationId: j,
|
|
1494
|
-
isLoading: ee,
|
|
1495
|
-
botAvatar: q.botAvatar,
|
|
1496
|
-
botName: q.botName,
|
|
1497
|
-
onClose: () => D(ge),
|
|
1498
|
-
onCloseWidget: c,
|
|
1499
|
-
onShowHome: () => {
|
|
1500
|
-
D("home"), E("home");
|
|
1501
|
-
},
|
|
1502
|
-
onShowConversations: K,
|
|
1503
|
-
onNewConversation: de,
|
|
1504
|
-
onConversationClick: ve
|
|
1505
|
-
}
|
|
1506
|
-
) : G === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(ze, {}) }) : /* @__PURE__ */ l(Ve, { children: [
|
|
1507
|
-
/* @__PURE__ */ o(
|
|
1508
|
-
lo,
|
|
1509
|
-
{
|
|
1510
|
-
config: q,
|
|
1511
|
-
allowFileUpload: i.allowFileUpload,
|
|
1512
|
-
clientState: R,
|
|
1513
|
-
isTyping: W,
|
|
1514
|
-
messages: Ce,
|
|
1515
|
-
renderers: ue,
|
|
1516
|
-
sendMessage: p,
|
|
1517
|
-
uploadFile: Q,
|
|
1518
|
-
addMessageFeedback: i.allowMessageFeedback ? d : void 0,
|
|
1519
|
-
showInitialLoading: ye,
|
|
1520
|
-
onShowHome: t.showWelcomeScreen ? () => {
|
|
1521
|
-
D("home"), E("home");
|
|
1522
|
-
} : void 0,
|
|
1523
|
-
onOpenHistory: () => ae("chat"),
|
|
1524
|
-
onRestartConversation: () => f(!0),
|
|
1525
|
-
onCloseWidget: c
|
|
1526
|
-
}
|
|
1527
|
-
),
|
|
1528
|
-
/* @__PURE__ */ o(
|
|
1529
|
-
ho,
|
|
1530
|
-
{
|
|
1531
|
-
open: U,
|
|
1532
|
-
onCancel: () => f(!1),
|
|
1533
|
-
onConfirm: () => {
|
|
1534
|
-
f(!1), de();
|
|
1622
|
+
className: "bp-webchat-panel",
|
|
1623
|
+
"data-state": _ ? "open" : "closed",
|
|
1624
|
+
children: K === "home" ? /* @__PURE__ */ o(
|
|
1625
|
+
Io,
|
|
1626
|
+
{
|
|
1627
|
+
config: q,
|
|
1628
|
+
activeView: K,
|
|
1629
|
+
onClose: c,
|
|
1630
|
+
onShowHome: () => D("home"),
|
|
1631
|
+
onShowConversations: () => ne("home"),
|
|
1632
|
+
onStart: () => D("chat")
|
|
1535
1633
|
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1634
|
+
) : K === "conversations" ? /* @__PURE__ */ o(
|
|
1635
|
+
Bo,
|
|
1636
|
+
{
|
|
1637
|
+
conversations: se,
|
|
1638
|
+
currentConversationId: W,
|
|
1639
|
+
isLoading: te,
|
|
1640
|
+
botAvatar: q.botAvatar,
|
|
1641
|
+
botName: q.botName,
|
|
1642
|
+
onClose: () => D(ge),
|
|
1643
|
+
onCloseWidget: c,
|
|
1644
|
+
onShowHome: () => {
|
|
1645
|
+
D("home"), E("home");
|
|
1646
|
+
},
|
|
1647
|
+
onShowConversations: J,
|
|
1648
|
+
onNewConversation: ue,
|
|
1649
|
+
onConversationClick: ve
|
|
1550
1650
|
}
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1651
|
+
) : K === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(qe, {}) }) : /* @__PURE__ */ l(Fe, { children: [
|
|
1652
|
+
/* @__PURE__ */ o(
|
|
1653
|
+
Co,
|
|
1654
|
+
{
|
|
1655
|
+
config: q,
|
|
1656
|
+
allowFileUpload: i.allowFileUpload,
|
|
1657
|
+
clientState: R,
|
|
1658
|
+
isTyping: G,
|
|
1659
|
+
messages: Ce,
|
|
1660
|
+
renderers: C,
|
|
1661
|
+
sendMessage: p,
|
|
1662
|
+
uploadFile: ee,
|
|
1663
|
+
addMessageFeedback: i.allowMessageFeedback ? d : void 0,
|
|
1664
|
+
showInitialLoading: ye,
|
|
1665
|
+
onShowHome: t.showWelcomeScreen ? () => {
|
|
1666
|
+
D("home"), E("home");
|
|
1667
|
+
} : void 0,
|
|
1668
|
+
onOpenHistory: () => ne("chat"),
|
|
1669
|
+
onRestartConversation: () => f(!0),
|
|
1670
|
+
onCloseWidget: c
|
|
1671
|
+
}
|
|
1672
|
+
),
|
|
1673
|
+
/* @__PURE__ */ o(
|
|
1674
|
+
No,
|
|
1675
|
+
{
|
|
1676
|
+
open: U,
|
|
1677
|
+
onCancel: () => f(!1),
|
|
1678
|
+
onConfirm: () => {
|
|
1679
|
+
f(!1), ue();
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
),
|
|
1683
|
+
i.allowMessageFeedback ? /* @__PURE__ */ o(
|
|
1684
|
+
xo,
|
|
1685
|
+
{
|
|
1686
|
+
open: B.open,
|
|
1687
|
+
draft: B.draft,
|
|
1688
|
+
setDraft: (h) => F((j) => ({ ...j, draft: h })),
|
|
1689
|
+
onCancel: () => F({
|
|
1690
|
+
open: !1,
|
|
1691
|
+
messageId: null,
|
|
1692
|
+
draft: ""
|
|
1693
|
+
}),
|
|
1694
|
+
onConfirm: async () => {
|
|
1695
|
+
B.messageId && d && await d(B.messageId, {
|
|
1696
|
+
value: "negative",
|
|
1697
|
+
comment: B.draft
|
|
1698
|
+
}), F({
|
|
1699
|
+
open: !1,
|
|
1700
|
+
messageId: null,
|
|
1701
|
+
draft: ""
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
) : null
|
|
1706
|
+
] })
|
|
1707
|
+
}
|
|
1708
|
+
) : null,
|
|
1554
1709
|
/* @__PURE__ */ l(
|
|
1555
1710
|
"button",
|
|
1556
1711
|
{
|
|
@@ -1561,7 +1716,7 @@ function To({
|
|
|
1561
1716
|
"aria-label": s ? "Fechar webchat" : "Abrir webchat",
|
|
1562
1717
|
children: [
|
|
1563
1718
|
/* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--chat", children: H }),
|
|
1564
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--close", children:
|
|
1719
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--close", children: eo })
|
|
1565
1720
|
]
|
|
1566
1721
|
}
|
|
1567
1722
|
)
|
|
@@ -1570,9 +1725,9 @@ function To({
|
|
|
1570
1725
|
);
|
|
1571
1726
|
}
|
|
1572
1727
|
export {
|
|
1573
|
-
|
|
1574
|
-
|
|
1728
|
+
jo as Webchat,
|
|
1729
|
+
Z as defaultConfig,
|
|
1575
1730
|
me as getContrastingTextColor,
|
|
1576
|
-
|
|
1577
|
-
|
|
1731
|
+
ie as getShellStyle,
|
|
1732
|
+
Ct as normalizeConfig
|
|
1578
1733
|
};
|