@eduzz-automacoes/webchat-widget 0.2.0 → 0.2.1
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 +542 -442
- package/dist/style.css +1 -1
- 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 Ve } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Re, createElement as ke, useState as S, useEffect as M, useRef as Z, useMemo as C, useCallback as ce, useReducer as Ge } from "react";
|
|
3
|
+
import { Container as Ke, MessageList as Je, Composer as Xe, WebchatProvider as Ze, useActiveConversation as Ye, useConversations as Qe, useUser as et, useConversationList as tt, Block as ot, StylesheetProvider as at } from "@botpress/webchat";
|
|
4
|
+
import './style.css';const X = {
|
|
5
5
|
botName: "Assistente Virtual",
|
|
6
6
|
subtitle: "Conectado ao bot real",
|
|
7
7
|
botAvatar: "",
|
|
@@ -64,8 +64,8 @@ import './style.css';const G = {
|
|
|
64
64
|
welcomeCloseLabel: "Fechar painel",
|
|
65
65
|
openFabBackgroundColor: "#2563eb",
|
|
66
66
|
openFabIconColor: "#ffffff"
|
|
67
|
-
},
|
|
68
|
-
switch (
|
|
67
|
+
}, De = (e) => e === "bottom-left" || e === "top-left" ? "bottom-left" : "bottom-right", nt = (e) => {
|
|
68
|
+
switch (De(e)) {
|
|
69
69
|
case "bottom-left":
|
|
70
70
|
return {
|
|
71
71
|
bottom: "24px",
|
|
@@ -82,7 +82,7 @@ import './style.css';const G = {
|
|
|
82
82
|
"--panel-transform-origin": "right bottom"
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, Fe = (e, t, a) => Math.min(Math.max(e, t), a), xe = (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()}`;
|
|
@@ -95,18 +95,18 @@ import './style.css';const G = {
|
|
|
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) =>
|
|
100
|
-
).join("")}`,
|
|
98
|
+
}, rt = ({ r: e, g: t, b: a }) => `#${[e, t, a].map(
|
|
99
|
+
(r) => Fe(Math.round(r), 0, 255).toString(16).padStart(2, "0")
|
|
100
|
+
).join("")}`, pe = (e, t, a) => {
|
|
101
101
|
const r = Ne(e), s = Ne(t);
|
|
102
102
|
if (!r || !s) return null;
|
|
103
|
-
const n =
|
|
104
|
-
return
|
|
103
|
+
const n = Fe(a, 0, 1);
|
|
104
|
+
return rt({
|
|
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
|
-
},
|
|
109
|
+
}, st = (e, t) => t < 0 ? pe(e, "#000000", Math.abs(t)) : pe(e, "#ffffff", t), me = (e) => {
|
|
110
110
|
const t = Ne(e);
|
|
111
111
|
return t && [t.r, t.g, t.b].map((r) => {
|
|
112
112
|
const s = r / 255;
|
|
@@ -115,43 +115,43 @@ import './style.css';const G = {
|
|
|
115
115
|
(r, s, n) => r + s * [0.2126, 0.7152, 0.0722][n],
|
|
116
116
|
0
|
|
117
117
|
) > 0.42 ? "#18181b" : "#ffffff";
|
|
118
|
-
},
|
|
118
|
+
}, L = (e, t) => e && Object.prototype.hasOwnProperty.call(e, t) && e[t] != null && e[t] !== "", ct = (e, t) => {
|
|
119
119
|
const a = xe(e.brandColor);
|
|
120
120
|
if (!a) return e;
|
|
121
|
-
const r = xe(e.brandTextColor) ||
|
|
121
|
+
const r = xe(e.brandTextColor) || me(a), s = pe(a, "#ffffff", 0.82) || X.secondaryButtonBorderColor, n = pe(a, "#ffffff", 0.92) || X.secondaryButtonHoverBackgroundColor, c = st(a, -0.12) || X.primaryButtonHoverBackgroundColor;
|
|
122
122
|
return {
|
|
123
123
|
...e,
|
|
124
124
|
brandColor: a,
|
|
125
125
|
brandTextColor: r,
|
|
126
|
-
primaryButtonBackgroundColor:
|
|
126
|
+
primaryButtonBackgroundColor: L(
|
|
127
127
|
t,
|
|
128
128
|
"primaryButtonBackgroundColor"
|
|
129
129
|
) ? e.primaryButtonBackgroundColor : a,
|
|
130
|
-
primaryButtonTextColor:
|
|
131
|
-
primaryButtonHoverBackgroundColor:
|
|
130
|
+
primaryButtonTextColor: L(t, "primaryButtonTextColor") ? e.primaryButtonTextColor : r,
|
|
131
|
+
primaryButtonHoverBackgroundColor: L(
|
|
132
132
|
t,
|
|
133
133
|
"primaryButtonHoverBackgroundColor"
|
|
134
134
|
) ? e.primaryButtonHoverBackgroundColor : c,
|
|
135
|
-
secondaryButtonBackgroundColor:
|
|
135
|
+
secondaryButtonBackgroundColor: L(
|
|
136
136
|
t,
|
|
137
137
|
"secondaryButtonBackgroundColor"
|
|
138
138
|
) ? e.secondaryButtonBackgroundColor : "#ffffff",
|
|
139
|
-
secondaryButtonTextColor:
|
|
140
|
-
secondaryButtonBorderColor:
|
|
141
|
-
secondaryButtonHoverBackgroundColor:
|
|
139
|
+
secondaryButtonTextColor: L(t, "secondaryButtonTextColor") ? e.secondaryButtonTextColor : a,
|
|
140
|
+
secondaryButtonBorderColor: L(t, "secondaryButtonBorderColor") ? e.secondaryButtonBorderColor : s,
|
|
141
|
+
secondaryButtonHoverBackgroundColor: L(
|
|
142
142
|
t,
|
|
143
143
|
"secondaryButtonHoverBackgroundColor"
|
|
144
144
|
) ? e.secondaryButtonHoverBackgroundColor : n,
|
|
145
|
-
iconButtonBackgroundColor:
|
|
146
|
-
iconButtonIconColor:
|
|
147
|
-
iconButtonBorderColor:
|
|
148
|
-
iconButtonHoverBackgroundColor:
|
|
145
|
+
iconButtonBackgroundColor: L(t, "iconButtonBackgroundColor") ? e.iconButtonBackgroundColor : "#ffffff",
|
|
146
|
+
iconButtonIconColor: L(t, "iconButtonIconColor") ? e.iconButtonIconColor : a,
|
|
147
|
+
iconButtonBorderColor: L(t, "iconButtonBorderColor") ? e.iconButtonBorderColor : s,
|
|
148
|
+
iconButtonHoverBackgroundColor: L(
|
|
149
149
|
t,
|
|
150
150
|
"iconButtonHoverBackgroundColor"
|
|
151
151
|
) ? e.iconButtonHoverBackgroundColor : n
|
|
152
152
|
};
|
|
153
|
-
},
|
|
154
|
-
const t = e.fabBackgroundColor || e.openFabBackgroundColor ||
|
|
153
|
+
}, lt = (e) => {
|
|
154
|
+
const t = e.fabBackgroundColor || e.openFabBackgroundColor || X.fabBackgroundColor, a = e.fabIconColor || e.openFabIconColor || X.fabIconColor;
|
|
155
155
|
return {
|
|
156
156
|
...e,
|
|
157
157
|
fabBackgroundColor: t,
|
|
@@ -159,17 +159,17 @@ import './style.css';const G = {
|
|
|
159
159
|
openFabBackgroundColor: t,
|
|
160
160
|
openFabIconColor: a
|
|
161
161
|
};
|
|
162
|
-
},
|
|
163
|
-
|
|
162
|
+
}, it = (e = {}) => lt(
|
|
163
|
+
ct(
|
|
164
164
|
{
|
|
165
|
-
...
|
|
165
|
+
...X,
|
|
166
166
|
...e,
|
|
167
|
-
position:
|
|
167
|
+
position: De(e.position ?? X.position)
|
|
168
168
|
},
|
|
169
169
|
e
|
|
170
170
|
)
|
|
171
|
-
),
|
|
172
|
-
...
|
|
171
|
+
), le = (e) => ({
|
|
172
|
+
...nt(e.position),
|
|
173
173
|
"--widget-width": e.width,
|
|
174
174
|
"--widget-height": e.height,
|
|
175
175
|
"--bpGray-1": "var(--ui-bg)",
|
|
@@ -185,9 +185,9 @@ import './style.css';const G = {
|
|
|
185
185
|
"--bpGray-900": "var(--ui-text)",
|
|
186
186
|
"--bpGray-950": "var(--ui-text)",
|
|
187
187
|
"--accent-color": e.accentColor,
|
|
188
|
-
"--accent-text-color":
|
|
188
|
+
"--accent-text-color": me(e.accentColor),
|
|
189
189
|
"--header-avatar-bg": e.accentColor,
|
|
190
|
-
"--header-avatar-text":
|
|
190
|
+
"--header-avatar-text": me(e.accentColor),
|
|
191
191
|
"--primary-button-background-color": e.primaryButtonBackgroundColor,
|
|
192
192
|
"--primary-button-text-color": e.primaryButtonTextColor,
|
|
193
193
|
"--primary-button-hover-background-color": e.primaryButtonHoverBackgroundColor,
|
|
@@ -228,7 +228,7 @@ import './style.css';const G = {
|
|
|
228
228
|
"--button-text": e.secondaryButtonTextColor,
|
|
229
229
|
"--fab-background-color": e.fabBackgroundColor,
|
|
230
230
|
"--fab-icon-color": e.fabIconColor
|
|
231
|
-
}),
|
|
231
|
+
}), dt = (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 G = {
|
|
|
238
238
|
additionalStylesheet: e.additionalStylesheet,
|
|
239
239
|
additionalStylesheetUrl: e.additionalStylesheetUrl
|
|
240
240
|
});
|
|
241
|
-
const
|
|
241
|
+
const ut = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), bt = (e) => e.replace(
|
|
242
242
|
/^([A-Z])|[\s-_]+(\w)/g,
|
|
243
243
|
(t, a, r) => r ? r.toUpperCase() : a.toLowerCase()
|
|
244
244
|
), Me = (e) => {
|
|
245
|
-
const t =
|
|
245
|
+
const t = bt(e);
|
|
246
246
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
247
|
-
}, Pe = (...e) => e.filter((t, a, r) => !!t && t.trim() !== "" && r.indexOf(t) === a).join(" ").trim(),
|
|
247
|
+
}, Pe = (...e) => e.filter((t, a, r) => !!t && t.trim() !== "" && r.indexOf(t) === a).join(" ").trim(), ht = (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 pt = {
|
|
253
253
|
xmlns: "http://www.w3.org/2000/svg",
|
|
254
254
|
width: 24,
|
|
255
255
|
height: 24,
|
|
@@ -260,7 +260,7 @@ var ht = {
|
|
|
260
260
|
strokeLinecap: "round",
|
|
261
261
|
strokeLinejoin: "round"
|
|
262
262
|
};
|
|
263
|
-
const mt =
|
|
263
|
+
const mt = Re(
|
|
264
264
|
({
|
|
265
265
|
color: e = "currentColor",
|
|
266
266
|
size: t = 24,
|
|
@@ -274,28 +274,28 @@ const mt = Ve(
|
|
|
274
274
|
"svg",
|
|
275
275
|
{
|
|
276
276
|
ref: u,
|
|
277
|
-
...
|
|
277
|
+
...pt,
|
|
278
278
|
width: t,
|
|
279
279
|
height: t,
|
|
280
280
|
stroke: e,
|
|
281
281
|
strokeWidth: r ? Number(a) * 24 / Number(t) : a,
|
|
282
282
|
className: Pe("lucide", s),
|
|
283
|
-
...!n && !
|
|
283
|
+
...!n && !ht(i) && { "aria-hidden": "true" },
|
|
284
284
|
...i
|
|
285
285
|
},
|
|
286
286
|
[
|
|
287
|
-
...c.map(([
|
|
287
|
+
...c.map(([w, m]) => ke(w, m)),
|
|
288
288
|
...Array.isArray(n) ? n : [n]
|
|
289
289
|
]
|
|
290
290
|
)
|
|
291
291
|
);
|
|
292
|
-
const
|
|
293
|
-
const a =
|
|
292
|
+
const A = (e, t) => {
|
|
293
|
+
const a = Re(
|
|
294
294
|
({ className: r, ...s }, n) => ke(mt, {
|
|
295
295
|
ref: n,
|
|
296
296
|
iconNode: t,
|
|
297
297
|
className: Pe(
|
|
298
|
-
`lucide-${
|
|
298
|
+
`lucide-${ut(Me(e))}`,
|
|
299
299
|
`lucide-${e}`,
|
|
300
300
|
r
|
|
301
301
|
),
|
|
@@ -304,12 +304,13 @@ const S = (e, t) => {
|
|
|
304
304
|
);
|
|
305
305
|
return a.displayName = Me(e), a;
|
|
306
306
|
};
|
|
307
|
-
const
|
|
307
|
+
const wt = [
|
|
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
|
|
310
|
+
], ft = A("arrow-right", wt);
|
|
311
|
+
const gt = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], yt = A("chevron-down", gt);
|
|
312
|
+
const vt = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], Ct = A("chevron-right", vt);
|
|
313
|
+
const Bt = [
|
|
313
314
|
["path", { d: "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8", key: "5wwlr5" }],
|
|
314
315
|
[
|
|
315
316
|
"path",
|
|
@@ -318,8 +319,8 @@ const yt = [
|
|
|
318
319
|
key: "r6nss1"
|
|
319
320
|
}
|
|
320
321
|
]
|
|
321
|
-
],
|
|
322
|
-
const
|
|
322
|
+
], kt = A("house", Bt);
|
|
323
|
+
const xt = [
|
|
323
324
|
[
|
|
324
325
|
"path",
|
|
325
326
|
{
|
|
@@ -330,8 +331,8 @@ const Ct = [
|
|
|
330
331
|
["path", { d: "M8 12h.01", key: "czm47f" }],
|
|
331
332
|
["path", { d: "M12 12h.01", key: "1mp3jc" }],
|
|
332
333
|
["path", { d: "M16 12h.01", key: "1l6xoz" }]
|
|
333
|
-
],
|
|
334
|
-
const
|
|
334
|
+
], Nt = A("message-circle-more", xt);
|
|
335
|
+
const It = [
|
|
335
336
|
[
|
|
336
337
|
"path",
|
|
337
338
|
{
|
|
@@ -339,8 +340,8 @@ const kt = [
|
|
|
339
340
|
key: "1sd12s"
|
|
340
341
|
}
|
|
341
342
|
]
|
|
342
|
-
],
|
|
343
|
-
const
|
|
343
|
+
], Mt = A("message-circle", It);
|
|
344
|
+
const St = [
|
|
344
345
|
[
|
|
345
346
|
"path",
|
|
346
347
|
{
|
|
@@ -348,8 +349,8 @@ const Nt = [
|
|
|
348
349
|
key: "18887p"
|
|
349
350
|
}
|
|
350
351
|
]
|
|
351
|
-
], He =
|
|
352
|
-
const
|
|
352
|
+
], He = A("message-square", St);
|
|
353
|
+
const Tt = [
|
|
353
354
|
[
|
|
354
355
|
"path",
|
|
355
356
|
{
|
|
@@ -364,12 +365,12 @@ const It = [
|
|
|
364
365
|
key: "1qfcsi"
|
|
365
366
|
}
|
|
366
367
|
]
|
|
367
|
-
], $e =
|
|
368
|
-
const
|
|
368
|
+
], $e = A("messages-square", Tt);
|
|
369
|
+
const At = [
|
|
369
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" }],
|
|
370
371
|
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
371
|
-
],
|
|
372
|
-
const
|
|
372
|
+
], Ut = A("rotate-ccw", At);
|
|
373
|
+
const Vt = [
|
|
373
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" }],
|
|
374
375
|
[
|
|
375
376
|
"path",
|
|
@@ -378,8 +379,8 @@ const Tt = [
|
|
|
378
379
|
key: "ohrbg2"
|
|
379
380
|
}
|
|
380
381
|
]
|
|
381
|
-
],
|
|
382
|
-
const
|
|
382
|
+
], Rt = A("square-pen", Vt);
|
|
383
|
+
const Dt = [
|
|
383
384
|
[
|
|
384
385
|
"path",
|
|
385
386
|
{
|
|
@@ -388,8 +389,8 @@ const Ut = [
|
|
|
388
389
|
}
|
|
389
390
|
],
|
|
390
391
|
["path", { d: "M17 14V2", key: "8ymqnk" }]
|
|
391
|
-
],
|
|
392
|
-
const
|
|
392
|
+
], Ft = A("thumbs-down", Dt);
|
|
393
|
+
const Pt = [
|
|
393
394
|
[
|
|
394
395
|
"path",
|
|
395
396
|
{
|
|
@@ -398,103 +399,103 @@ const Ft = [
|
|
|
398
399
|
}
|
|
399
400
|
],
|
|
400
401
|
["path", { d: "M7 10v12", key: "1qc93n" }]
|
|
401
|
-
],
|
|
402
|
-
const
|
|
402
|
+
], Ht = A("thumbs-up", Pt);
|
|
403
|
+
const $t = [
|
|
403
404
|
["circle", { cx: "12", cy: "8", r: "5", key: "1hypcn" }],
|
|
404
405
|
["path", { d: "M20 21a8 8 0 0 0-16 0", key: "rfgkzh" }]
|
|
405
|
-
],
|
|
406
|
-
const
|
|
406
|
+
], Lt = A("user-round", $t);
|
|
407
|
+
const _t = [
|
|
407
408
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
408
409
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
409
|
-
],
|
|
410
|
-
"message-circle-more": /* @__PURE__ */ o(
|
|
411
|
-
"message-circle": /* @__PURE__ */ o(
|
|
412
|
-
"message-square": /* @__PURE__ */ o(He, { ...
|
|
413
|
-
"messages-square": /* @__PURE__ */ o($e, { ...
|
|
414
|
-
},
|
|
415
|
-
const a = (e || "B").trim().charAt(0).toUpperCase() || "B", r =
|
|
410
|
+
], Le = A("x", _t), k = { "aria-hidden": !0, strokeWidth: 1.9 }, zt = /* @__PURE__ */ o(Ut, { ...k }), we = /* @__PURE__ */ o(Le, { ...k }), Et = /* @__PURE__ */ o(Le, { ...k }), Se = {
|
|
411
|
+
"message-circle-more": /* @__PURE__ */ o(Nt, { ...k }),
|
|
412
|
+
"message-circle": /* @__PURE__ */ o(Mt, { ...k }),
|
|
413
|
+
"message-square": /* @__PURE__ */ o(He, { ...k }),
|
|
414
|
+
"messages-square": /* @__PURE__ */ o($e, { ...k })
|
|
415
|
+
}, Ot = (e = "messages-square") => Se[e] || Se["messages-square"], qt = /* @__PURE__ */ o(ft, { ...k }), _e = /* @__PURE__ */ o(kt, { ...k }), jt = /* @__PURE__ */ o(He, { ...k }), Wt = /* @__PURE__ */ o(Ht, { ...k }), Gt = /* @__PURE__ */ o(Ft, { ...k }), Kt = /* @__PURE__ */ o($e, { ...k }), Jt = /* @__PURE__ */ o(Ct, { ...k }), Xt = /* @__PURE__ */ o(yt, { ...k }), Zt = /* @__PURE__ */ o(Rt, { ...k }), Yt = /* @__PURE__ */ o(Lt, { ...k }), he = (e) => String(e).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'"), Qt = ({ name: e, backgroundColor: t }) => {
|
|
416
|
+
const a = (e || "B").trim().charAt(0).toUpperCase() || "B", r = me(t), s = `
|
|
416
417
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-label="${he(e || "Bot")}">
|
|
417
418
|
<rect width="96" height="96" rx="48" fill="${he(t)}" />
|
|
418
419
|
<text x="50%" y="52%" dominant-baseline="middle" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="42" font-weight="700" fill="${he(r)}">${he(a)}</text>
|
|
419
420
|
</svg>
|
|
420
421
|
`.trim();
|
|
421
422
|
return `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(s)}`;
|
|
422
|
-
},
|
|
423
|
+
}, eo = (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", Te = [
|
|
423
424
|
{ unit: "minute", seconds: 60 },
|
|
424
425
|
{ unit: "hour", seconds: 3600 },
|
|
425
426
|
{ unit: "day", seconds: 3600 * 24 },
|
|
426
427
|
{ unit: "week", seconds: 3600 * 24 * 7 },
|
|
427
428
|
{ unit: "month", seconds: 3600 * 24 * 30 },
|
|
428
429
|
{ unit: "year", seconds: 3600 * 24 * 365 }
|
|
429
|
-
],
|
|
430
|
+
], to = new Intl.RelativeTimeFormat("pt-BR", { numeric: "auto" }), oo = (e) => {
|
|
430
431
|
const t = Math.round((new Date(e).getTime() - Date.now()) / 1e3);
|
|
431
432
|
if (Math.abs(t) < 45) return "agora";
|
|
432
433
|
let a = Te[0];
|
|
433
434
|
for (const r of Te)
|
|
434
435
|
Math.abs(t) >= r.seconds && (a = r);
|
|
435
|
-
return
|
|
436
|
-
},
|
|
436
|
+
return to.format(Math.round(t / a.seconds), a.unit);
|
|
437
|
+
}, ao = ({ messages: e, user: t, botName: a, botAvatar: r }) => e.map((s) => {
|
|
437
438
|
const n = s.authorId === t?.userId;
|
|
438
439
|
return {
|
|
439
440
|
...s,
|
|
440
441
|
direction: n ? "outgoing" : "incoming",
|
|
441
442
|
sender: n ? { name: t?.name ?? "Você", avatar: t?.pictureUrl } : { name: a, avatar: r }
|
|
442
443
|
};
|
|
443
|
-
}),
|
|
444
|
-
const [s, n] =
|
|
444
|
+
}), no = ({ activeView: e, clientState: t, conversationId: a, messagesLength: r }) => {
|
|
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");
|
|
445
446
|
return M(() => {
|
|
446
447
|
if (s) {
|
|
447
448
|
if (u) {
|
|
448
|
-
const
|
|
449
|
-
return () => window.clearTimeout(
|
|
449
|
+
const m = window.setTimeout(() => n(!1), 900);
|
|
450
|
+
return () => window.clearTimeout(m);
|
|
450
451
|
}
|
|
451
|
-
if (
|
|
452
|
-
const
|
|
453
|
-
return () => window.clearTimeout(
|
|
452
|
+
if (w) {
|
|
453
|
+
const m = window.setTimeout(() => n(!1), 0);
|
|
454
|
+
return () => window.clearTimeout(m);
|
|
454
455
|
}
|
|
455
456
|
}
|
|
456
|
-
}, [a, s, u,
|
|
457
|
+
}, [a, s, u, w]), {
|
|
457
458
|
showInitialLoading: i || s && c,
|
|
458
459
|
setShowInitialLoading: n
|
|
459
460
|
};
|
|
460
|
-
},
|
|
461
|
+
}, ro = 3e4, so = ({
|
|
461
462
|
getSession: e,
|
|
462
463
|
sessionKey: t,
|
|
463
464
|
onSessionChange: a
|
|
464
465
|
}) => {
|
|
465
|
-
const [r, s] =
|
|
466
|
+
const [r, s] = S(null), [n, c] = S(!!e), i = Z(e);
|
|
466
467
|
i.current = e;
|
|
467
|
-
const u =
|
|
468
|
+
const u = Z(a);
|
|
468
469
|
return u.current = a, M(() => {
|
|
469
|
-
let
|
|
470
|
-
const b = (
|
|
471
|
-
|
|
470
|
+
let w = !0, m;
|
|
471
|
+
const b = (f) => {
|
|
472
|
+
w && (s(f), u.current?.(f));
|
|
472
473
|
};
|
|
473
474
|
if (!i.current) {
|
|
474
475
|
c(!1), b(null);
|
|
475
476
|
return;
|
|
476
477
|
}
|
|
477
|
-
const
|
|
478
|
+
const U = async () => {
|
|
478
479
|
try {
|
|
479
|
-
const
|
|
480
|
-
if (!
|
|
480
|
+
const f = await i.current();
|
|
481
|
+
if (!f?.userToken)
|
|
481
482
|
throw new Error("Webchat session not created or empty");
|
|
482
|
-
if (!
|
|
483
|
-
b(
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
} catch (
|
|
487
|
-
console.error("[EduzzWebchat] error creating session: ",
|
|
483
|
+
if (!w) return;
|
|
484
|
+
b(f);
|
|
485
|
+
const B = f.expiresAt - Date.now() - ro;
|
|
486
|
+
m = setTimeout(U, Math.max(B, 0));
|
|
487
|
+
} catch (f) {
|
|
488
|
+
console.error("[EduzzWebchat] error creating session: ", f), b(null);
|
|
488
489
|
} finally {
|
|
489
|
-
|
|
490
|
+
w && c(!1);
|
|
490
491
|
}
|
|
491
492
|
};
|
|
492
|
-
return c(!0),
|
|
493
|
-
|
|
493
|
+
return c(!0), U(), () => {
|
|
494
|
+
w = !1, m && clearTimeout(m);
|
|
494
495
|
};
|
|
495
496
|
}, [t, !!e]), { session: r, resolving: n };
|
|
496
497
|
};
|
|
497
|
-
function
|
|
498
|
+
function co({
|
|
498
499
|
botName: e,
|
|
499
500
|
botAvatar: t,
|
|
500
501
|
subtitle: a,
|
|
@@ -519,7 +520,7 @@ function ao({
|
|
|
519
520
|
type: "button",
|
|
520
521
|
"aria-label": "Abrir início",
|
|
521
522
|
onClick: r,
|
|
522
|
-
children:
|
|
523
|
+
children: _e
|
|
523
524
|
}
|
|
524
525
|
) : null,
|
|
525
526
|
/* @__PURE__ */ o(
|
|
@@ -529,7 +530,7 @@ function ao({
|
|
|
529
530
|
type: "button",
|
|
530
531
|
"aria-label": "Abrir conversas",
|
|
531
532
|
onClick: s,
|
|
532
|
-
children:
|
|
533
|
+
children: Kt
|
|
533
534
|
}
|
|
534
535
|
),
|
|
535
536
|
/* @__PURE__ */ o(
|
|
@@ -539,7 +540,7 @@ function ao({
|
|
|
539
540
|
type: "button",
|
|
540
541
|
"aria-label": "Reiniciar conversa",
|
|
541
542
|
onClick: n,
|
|
542
|
-
children:
|
|
543
|
+
children: zt
|
|
543
544
|
}
|
|
544
545
|
),
|
|
545
546
|
c ? /* @__PURE__ */ o(
|
|
@@ -573,7 +574,7 @@ function ze() {
|
|
|
573
574
|
] })
|
|
574
575
|
] });
|
|
575
576
|
}
|
|
576
|
-
function
|
|
577
|
+
function lo({
|
|
577
578
|
config: e,
|
|
578
579
|
allowFileUpload: t,
|
|
579
580
|
clientState: a,
|
|
@@ -583,34 +584,34 @@ function no({
|
|
|
583
584
|
sendMessage: c,
|
|
584
585
|
uploadFile: i,
|
|
585
586
|
addMessageFeedback: u,
|
|
586
|
-
showInitialLoading:
|
|
587
|
-
onShowHome:
|
|
587
|
+
showInitialLoading: w,
|
|
588
|
+
onShowHome: m,
|
|
588
589
|
onOpenHistory: b,
|
|
589
|
-
onRestartConversation:
|
|
590
|
-
onCloseWidget:
|
|
590
|
+
onRestartConversation: U,
|
|
591
|
+
onCloseWidget: f
|
|
591
592
|
}) {
|
|
592
593
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-layout", children: [
|
|
593
594
|
/* @__PURE__ */ o(
|
|
594
|
-
|
|
595
|
+
co,
|
|
595
596
|
{
|
|
596
597
|
botName: e.botName,
|
|
597
598
|
botAvatar: e.botAvatar,
|
|
598
599
|
subtitle: e.subtitle,
|
|
599
|
-
onShowHome:
|
|
600
|
+
onShowHome: m,
|
|
600
601
|
onOpenHistory: b,
|
|
601
|
-
onRestartConversation:
|
|
602
|
-
onCloseWidget:
|
|
602
|
+
onRestartConversation: U,
|
|
603
|
+
onCloseWidget: f
|
|
603
604
|
}
|
|
604
605
|
),
|
|
605
606
|
/* @__PURE__ */ o(
|
|
606
|
-
|
|
607
|
+
Ke,
|
|
607
608
|
{
|
|
608
609
|
className: "bp-webchat-container",
|
|
609
610
|
uploadFile: i,
|
|
610
611
|
allowFileUpload: t,
|
|
611
|
-
children:
|
|
612
|
+
children: w ? /* @__PURE__ */ o(ze, {}) : /* @__PURE__ */ l(Ve, { children: [
|
|
612
613
|
/* @__PURE__ */ o(
|
|
613
|
-
|
|
614
|
+
Je,
|
|
614
615
|
{
|
|
615
616
|
botName: e.botName,
|
|
616
617
|
botDescription: e.subtitle,
|
|
@@ -627,7 +628,7 @@ function no({
|
|
|
627
628
|
}
|
|
628
629
|
),
|
|
629
630
|
/* @__PURE__ */ o(
|
|
630
|
-
|
|
631
|
+
Xe,
|
|
631
632
|
{
|
|
632
633
|
connected: a !== "disconnected",
|
|
633
634
|
sendMessage: c,
|
|
@@ -642,7 +643,7 @@ function no({
|
|
|
642
643
|
)
|
|
643
644
|
] });
|
|
644
645
|
}
|
|
645
|
-
function
|
|
646
|
+
function Ee({ activeView: e, onShowHome: t, onShowConversations: a }) {
|
|
646
647
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-tabs bp-webchat-welcome-bottom", children: [
|
|
647
648
|
/* @__PURE__ */ l(
|
|
648
649
|
"button",
|
|
@@ -652,7 +653,7 @@ function De({ activeView: e, onShowHome: t, onShowConversations: a }) {
|
|
|
652
653
|
type: "button",
|
|
653
654
|
onClick: t,
|
|
654
655
|
children: [
|
|
655
|
-
/* @__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: _e }),
|
|
656
657
|
/* @__PURE__ */ o("span", { children: "Início" })
|
|
657
658
|
]
|
|
658
659
|
}
|
|
@@ -665,14 +666,14 @@ function De({ activeView: e, onShowHome: t, onShowConversations: a }) {
|
|
|
665
666
|
type: "button",
|
|
666
667
|
onClick: a,
|
|
667
668
|
children: [
|
|
668
|
-
/* @__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: jt }),
|
|
669
670
|
/* @__PURE__ */ o("span", { children: "Conversas" })
|
|
670
671
|
]
|
|
671
672
|
}
|
|
672
673
|
)
|
|
673
674
|
] });
|
|
674
675
|
}
|
|
675
|
-
function
|
|
676
|
+
function io({
|
|
676
677
|
conversations: e,
|
|
677
678
|
currentConversationId: t,
|
|
678
679
|
isLoading: a,
|
|
@@ -682,8 +683,8 @@ function ro({
|
|
|
682
683
|
onCloseWidget: c,
|
|
683
684
|
onShowHome: i,
|
|
684
685
|
onShowConversations: u,
|
|
685
|
-
onNewConversation:
|
|
686
|
-
onConversationClick:
|
|
686
|
+
onNewConversation: w,
|
|
687
|
+
onConversationClick: m
|
|
687
688
|
}) {
|
|
688
689
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-history", children: [
|
|
689
690
|
/* @__PURE__ */ l("div", { className: "bp-webchat-history-header", children: [
|
|
@@ -712,32 +713,32 @@ function ro({
|
|
|
712
713
|
] })
|
|
713
714
|
] }),
|
|
714
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) => {
|
|
715
|
-
const
|
|
716
|
+
const U = eo(b.lastMessage), f = b.lastMessage?.author?.type === "bot";
|
|
716
717
|
return /* @__PURE__ */ l(
|
|
717
718
|
"button",
|
|
718
719
|
{
|
|
719
720
|
className: "bp-webchat-history-item",
|
|
720
721
|
type: "button",
|
|
721
|
-
onClick: () =>
|
|
722
|
+
onClick: () => m(b.id),
|
|
722
723
|
"data-current": b.id === t || void 0,
|
|
723
724
|
children: [
|
|
724
|
-
/* @__PURE__ */ o("div", { className: "bp-webchat-history-avatar", "data-kind":
|
|
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() }) : Yt }),
|
|
725
726
|
/* @__PURE__ */ l("div", { className: "bp-webchat-history-content", children: [
|
|
726
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children:
|
|
727
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children:
|
|
727
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children: U }),
|
|
728
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: oo(b.updatedAt) })
|
|
728
729
|
] }),
|
|
729
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children:
|
|
730
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children: Jt })
|
|
730
731
|
]
|
|
731
732
|
},
|
|
732
733
|
b.id
|
|
733
734
|
);
|
|
734
735
|
}) }),
|
|
735
|
-
/* @__PURE__ */ o("div", { className: "bp-webchat-history-footer", children: /* @__PURE__ */ l("button", { className: "bp-webchat-history-new", type: "button", onClick:
|
|
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
|
+
Zt,
|
|
737
738
|
/* @__PURE__ */ o("span", { children: "Nova conversa" })
|
|
738
739
|
] }) }),
|
|
739
740
|
/* @__PURE__ */ o(
|
|
740
|
-
|
|
741
|
+
Ee,
|
|
741
742
|
{
|
|
742
743
|
activeView: "conversations",
|
|
743
744
|
onShowHome: i,
|
|
@@ -746,7 +747,103 @@ function ro({
|
|
|
746
747
|
)
|
|
747
748
|
] });
|
|
748
749
|
}
|
|
749
|
-
|
|
750
|
+
const Ae = (e) => String(e ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim();
|
|
751
|
+
function uo(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 = Z(null), F = Z([]), _ = s || U !== null || a.length === 0, V = C(() => {
|
|
753
|
+
const d = Ae(u);
|
|
754
|
+
return d ? a.filter((p) => Ae(p.label).includes(d)) : a;
|
|
755
|
+
}, [a, u]);
|
|
756
|
+
M(() => {
|
|
757
|
+
b(0);
|
|
758
|
+
}, [u]), M(() => {
|
|
759
|
+
if (!c) return;
|
|
760
|
+
const d = (p) => {
|
|
761
|
+
B.current && !B.current.contains(p.target) && i(!1);
|
|
762
|
+
};
|
|
763
|
+
return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
|
|
764
|
+
}, [c]), M(() => {
|
|
765
|
+
c && F.current[m]?.scrollIntoView({ block: "nearest" });
|
|
766
|
+
}, [m, c]);
|
|
767
|
+
const j = (d) => {
|
|
768
|
+
d && (r?.({ type: "text", text: d.label, value: d.value }), f(d.label), w(""), i(!1));
|
|
769
|
+
}, W = (d) => {
|
|
770
|
+
if (!_)
|
|
771
|
+
switch (d.key) {
|
|
772
|
+
case "ArrowDown":
|
|
773
|
+
if (d.preventDefault(), !c) {
|
|
774
|
+
i(!0);
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
b((p) => Math.min(p + 1, V.length - 1));
|
|
778
|
+
break;
|
|
779
|
+
case "ArrowUp":
|
|
780
|
+
d.preventDefault(), b((p) => Math.max(p - 1, 0));
|
|
781
|
+
break;
|
|
782
|
+
case "Enter":
|
|
783
|
+
d.preventDefault(), c && j(V[m]);
|
|
784
|
+
break;
|
|
785
|
+
case "Escape":
|
|
786
|
+
i(!1);
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
789
|
+
}, x = `bpDropdownList-${n ?? "x"}`;
|
|
790
|
+
return /* @__PURE__ */ l(
|
|
791
|
+
"div",
|
|
792
|
+
{
|
|
793
|
+
className: "bpDropdown",
|
|
794
|
+
"data-open": c || void 0,
|
|
795
|
+
"data-disabled": _ || void 0,
|
|
796
|
+
ref: B,
|
|
797
|
+
children: [
|
|
798
|
+
t ? /* @__PURE__ */ o("span", { className: "bpDropdownLabel", children: t }) : null,
|
|
799
|
+
/* @__PURE__ */ l("div", { className: "bpDropdownControl", children: [
|
|
800
|
+
/* @__PURE__ */ o(
|
|
801
|
+
"input",
|
|
802
|
+
{
|
|
803
|
+
className: "bpDropdownInput",
|
|
804
|
+
type: "text",
|
|
805
|
+
role: "combobox",
|
|
806
|
+
"aria-expanded": c,
|
|
807
|
+
"aria-controls": x,
|
|
808
|
+
"aria-autocomplete": "list",
|
|
809
|
+
autoComplete: "off",
|
|
810
|
+
placeholder: "Selecione...",
|
|
811
|
+
value: U ?? u,
|
|
812
|
+
disabled: _,
|
|
813
|
+
onFocus: () => {
|
|
814
|
+
_ || i(!0);
|
|
815
|
+
},
|
|
816
|
+
onChange: (d) => {
|
|
817
|
+
w(d.target.value), i(!0);
|
|
818
|
+
},
|
|
819
|
+
onKeyDown: W
|
|
820
|
+
}
|
|
821
|
+
),
|
|
822
|
+
/* @__PURE__ */ o("span", { className: "bpDropdownChevron", children: Xt })
|
|
823
|
+
] }),
|
|
824
|
+
c && !_ ? /* @__PURE__ */ o("ul", { className: "bpDropdownMenu", id: x, role: "listbox", children: V.length > 0 ? V.map((d, p) => /* @__PURE__ */ o(
|
|
825
|
+
"li",
|
|
826
|
+
{
|
|
827
|
+
ref: (R) => {
|
|
828
|
+
F.current[p] = R;
|
|
829
|
+
},
|
|
830
|
+
className: "bpDropdownOption",
|
|
831
|
+
role: "option",
|
|
832
|
+
"aria-selected": p === m,
|
|
833
|
+
"data-active": p === m || void 0,
|
|
834
|
+
onMouseEnter: () => b(p),
|
|
835
|
+
onMouseDown: (R) => {
|
|
836
|
+
R.preventDefault(), j(d);
|
|
837
|
+
},
|
|
838
|
+
children: d.label
|
|
839
|
+
},
|
|
840
|
+
d.value
|
|
841
|
+
)) : /* @__PURE__ */ o("li", { className: "bpDropdownEmpty", role: "presentation", children: "Nenhuma opção encontrada" }) }) : null
|
|
842
|
+
]
|
|
843
|
+
}
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
function bo({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
|
|
750
847
|
return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
|
|
751
848
|
/* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Nos ajude a melhorar" }),
|
|
752
849
|
/* @__PURE__ */ o("p", { className: "bp-webchat-modal-description", children: "Conte o que não ficou bom nesta resposta." }),
|
|
@@ -773,7 +870,7 @@ function so({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
|
|
|
773
870
|
] })
|
|
774
871
|
] }) }) : null;
|
|
775
872
|
}
|
|
776
|
-
function
|
|
873
|
+
function ho({ open: e, onConfirm: t, onCancel: a }) {
|
|
777
874
|
return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
|
|
778
875
|
/* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Criar nova conversa" }),
|
|
779
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." }),
|
|
@@ -791,7 +888,7 @@ function co({ open: e, onConfirm: t, onCancel: a }) {
|
|
|
791
888
|
] })
|
|
792
889
|
] }) }) : null;
|
|
793
890
|
}
|
|
794
|
-
function
|
|
891
|
+
function po({ config: e, activeView: t, onShowHome: a, onShowConversations: r, onStart: s, onClose: n }) {
|
|
795
892
|
const c = e.welcomeCardImage || e.botAvatar;
|
|
796
893
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-welcome", children: [
|
|
797
894
|
/* @__PURE__ */ l("div", { className: "bp-webchat-welcome-hero", children: [
|
|
@@ -817,11 +914,11 @@ function lo({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
|
|
|
817
914
|
/* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-title", children: e.welcomeCtaLabel }),
|
|
818
915
|
e.welcomeButtonDescription ? /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-description", children: e.welcomeButtonDescription }) : null
|
|
819
916
|
] }) }),
|
|
820
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-right", children:
|
|
917
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-right", children: qt })
|
|
821
918
|
] })
|
|
822
919
|
] }) }),
|
|
823
920
|
/* @__PURE__ */ o(
|
|
824
|
-
|
|
921
|
+
Ee,
|
|
825
922
|
{
|
|
826
923
|
activeView: t,
|
|
827
924
|
onShowHome: a,
|
|
@@ -830,15 +927,15 @@ function lo({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
|
|
|
830
927
|
)
|
|
831
928
|
] });
|
|
832
929
|
}
|
|
833
|
-
const
|
|
930
|
+
const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
834
931
|
allowFileUpload: !1,
|
|
835
932
|
allowMessageFeedback: !1
|
|
836
|
-
}),
|
|
933
|
+
}), wo = "anonymous-id", fo = (e) => !!e && typeof e == "object" && !Array.isArray(e), Oe = (e) => e.replace(/\/+$/, ""), Ie = ({ webchatProxyUrl: e }) => {
|
|
837
934
|
if (typeof e != "string" || !e.trim())
|
|
838
935
|
return null;
|
|
839
|
-
const t =
|
|
936
|
+
const t = Oe(e.trim()), a = "/webchat/proxy";
|
|
840
937
|
return t.endsWith(a) ? t.slice(0, -a.length) : null;
|
|
841
|
-
},
|
|
938
|
+
}, go = ({ webchatProxyUrl: e, clientId: t }) => !e || !t ? null : `${e.endsWith("/") ? e.slice(0, -1) : e}/${encodeURIComponent(t)}/runtime-config`, yo = ({ webchatProxyUrl: e, clientId: t, presetSlug: a }) => {
|
|
842
939
|
if (!e || !t)
|
|
843
940
|
return null;
|
|
844
941
|
const r = Ie({ webchatProxyUrl: e });
|
|
@@ -848,17 +945,17 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
848
945
|
typeof a == "string" && a.trim() && s.set("slug", a.trim());
|
|
849
946
|
const n = s.toString();
|
|
850
947
|
return `${r}/webchat/bootstrap/${encodeURIComponent(t)}${n ? `?${n}` : ""}`;
|
|
851
|
-
},
|
|
948
|
+
}, vo = (e) => {
|
|
852
949
|
const t = e && typeof e == "object" && e.data && typeof e.data == "object" ? e.data : e;
|
|
853
950
|
return t && typeof t == "object" ? t : null;
|
|
854
|
-
},
|
|
951
|
+
}, ne = (e) => fo(e) ? e : null, Co = (e) => {
|
|
855
952
|
if (!e) return "";
|
|
856
953
|
try {
|
|
857
954
|
return JSON.stringify(e);
|
|
858
955
|
} catch {
|
|
859
956
|
return String(Date.now());
|
|
860
957
|
}
|
|
861
|
-
},
|
|
958
|
+
}, qe = (e) => {
|
|
862
959
|
if (typeof window > "u") return null;
|
|
863
960
|
try {
|
|
864
961
|
return e === "sessionStorage" ? window.sessionStorage : window.localStorage;
|
|
@@ -866,7 +963,7 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
866
963
|
return null;
|
|
867
964
|
}
|
|
868
965
|
}, je = ({ storageKey: e, storageLocation: t }) => {
|
|
869
|
-
const a =
|
|
966
|
+
const a = qe(t);
|
|
870
967
|
if (!a) return null;
|
|
871
968
|
try {
|
|
872
969
|
const r = a.getItem(
|
|
@@ -878,10 +975,10 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
878
975
|
} catch {
|
|
879
976
|
return;
|
|
880
977
|
}
|
|
881
|
-
},
|
|
978
|
+
}, Bo = ({ storageKey: e, storageLocation: t }) => {
|
|
882
979
|
const a = je({ storageKey: e, storageLocation: t });
|
|
883
980
|
return typeof a?.conversationId == "string" && a.conversationId.trim() || void 0;
|
|
884
|
-
},
|
|
981
|
+
}, Ue = () => {
|
|
885
982
|
try {
|
|
886
983
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
|
|
887
984
|
return crypto.randomUUID();
|
|
@@ -895,18 +992,18 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
895
992
|
const t = Math.random() * 16 | 0;
|
|
896
993
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
897
994
|
});
|
|
898
|
-
},
|
|
899
|
-
const a =
|
|
995
|
+
}, ko = (e) => `${e || fe}-${wo}`, xo = ({ storageKey: e, storageLocation: t }) => {
|
|
996
|
+
const a = qe(t), r = ko(e);
|
|
900
997
|
try {
|
|
901
998
|
const s = a?.getItem(r);
|
|
902
999
|
if (s)
|
|
903
1000
|
return s;
|
|
904
|
-
const n = `anon_${
|
|
1001
|
+
const n = `anon_${Ue()}`;
|
|
905
1002
|
return a?.setItem(r, n), n;
|
|
906
1003
|
} catch {
|
|
907
|
-
return `anon_${
|
|
1004
|
+
return `anon_${Ue()}`;
|
|
908
1005
|
}
|
|
909
|
-
},
|
|
1006
|
+
}, No = async ({ webchatProxyUrl: e, clientId: t, accountId: a }) => {
|
|
910
1007
|
const r = Ie({ webchatProxyUrl: e });
|
|
911
1008
|
if (!r)
|
|
912
1009
|
throw new Error("public session request requires a valid webchatProxyUrl");
|
|
@@ -931,11 +1028,11 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
931
1028
|
userId: c.userId,
|
|
932
1029
|
userToken: c.userToken
|
|
933
1030
|
};
|
|
934
|
-
},
|
|
1031
|
+
}, Io = (e) => ({
|
|
935
1032
|
...typeof e.name == "string" && e.name.trim() ? { name: e.name.trim() } : {},
|
|
936
1033
|
...typeof e.pictureUrl == "string" && e.pictureUrl.trim() ? { pictureUrl: e.pictureUrl.trim() } : {},
|
|
937
1034
|
userData: e
|
|
938
|
-
}),
|
|
1035
|
+
}), Mo = ({
|
|
939
1036
|
showWelcomeScreen: e,
|
|
940
1037
|
storageKey: t,
|
|
941
1038
|
storageLocation: a,
|
|
@@ -953,7 +1050,7 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
953
1050
|
return { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
|
|
954
1051
|
const c = typeof n.conversationId == "string" ? n.conversationId.trim() : "", i = typeof n.user?.userToken == "string" ? n.user.userToken.trim() : "";
|
|
955
1052
|
return c && i ? { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" } : !c && !i ? { activeView: "home", historyReturnView: "home", bootstrapView: "home" } : { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
|
|
956
|
-
},
|
|
1053
|
+
}, So = (e, t) => {
|
|
957
1054
|
switch (t.type) {
|
|
958
1055
|
case "show":
|
|
959
1056
|
return { isPanelMounted: !0, isPanelVisible: e.isPanelVisible };
|
|
@@ -967,7 +1064,7 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
|
967
1064
|
return e;
|
|
968
1065
|
}
|
|
969
1066
|
};
|
|
970
|
-
function
|
|
1067
|
+
function Ro({
|
|
971
1068
|
clientId: e,
|
|
972
1069
|
webchatProxyUrl: t,
|
|
973
1070
|
userCredentials: a,
|
|
@@ -977,204 +1074,204 @@ function So({
|
|
|
977
1074
|
presetSlug: c,
|
|
978
1075
|
storageKey: i = fe,
|
|
979
1076
|
storageLocation: u = "localStorage",
|
|
980
|
-
defaultOpen:
|
|
981
|
-
onUserApiChange:
|
|
1077
|
+
defaultOpen: w,
|
|
1078
|
+
onUserApiChange: m,
|
|
982
1079
|
getSession: b,
|
|
983
|
-
sessionKey:
|
|
984
|
-
onSessionChange:
|
|
1080
|
+
sessionKey: U,
|
|
1081
|
+
onSessionChange: f
|
|
985
1082
|
}) {
|
|
986
|
-
const { session:
|
|
1083
|
+
const { session: B, resolving: F } = so({
|
|
987
1084
|
getSession: b,
|
|
988
|
-
sessionKey:
|
|
989
|
-
onSessionChange:
|
|
990
|
-
}),
|
|
1085
|
+
sessionKey: U,
|
|
1086
|
+
onSessionChange: f
|
|
1087
|
+
}), Y = !!B && Date.now() < B.expiresAt, _ = Y ? { userId: B.userId, userToken: B.userToken } : void 0, V = b ? _ : a, j = Y ? B.conversationId : void 0, W = C(
|
|
991
1088
|
() => typeof c == "string" && c.trim() ? c.trim() : void 0,
|
|
992
1089
|
[c]
|
|
993
|
-
),
|
|
994
|
-
() => typeof t == "string" && t.trim() ?
|
|
1090
|
+
), x = C(
|
|
1091
|
+
() => typeof t == "string" && t.trim() ? Oe(t.trim()) : void 0,
|
|
995
1092
|
[t]
|
|
996
1093
|
);
|
|
997
|
-
|
|
998
|
-
() =>
|
|
999
|
-
[
|
|
1094
|
+
C(
|
|
1095
|
+
() => x ? Ie({ webchatProxyUrl: x }) : null,
|
|
1096
|
+
[x]
|
|
1000
1097
|
);
|
|
1001
|
-
const
|
|
1002
|
-
() =>
|
|
1003
|
-
webchatProxyUrl:
|
|
1098
|
+
const d = !!(e && x && (W || !V)), p = C(
|
|
1099
|
+
() => d ? yo({
|
|
1100
|
+
webchatProxyUrl: x,
|
|
1004
1101
|
clientId: e,
|
|
1005
|
-
presetSlug:
|
|
1102
|
+
presetSlug: W
|
|
1006
1103
|
}) : null,
|
|
1007
|
-
[e,
|
|
1008
|
-
), [
|
|
1104
|
+
[e, W, x, d]
|
|
1105
|
+
), [R, Q] = S({
|
|
1009
1106
|
error: null,
|
|
1010
1107
|
isLoading: !1,
|
|
1011
1108
|
payload: null,
|
|
1012
1109
|
url: null
|
|
1013
1110
|
});
|
|
1014
1111
|
M(() => {
|
|
1015
|
-
if (!
|
|
1016
|
-
|
|
1112
|
+
if (!p) {
|
|
1113
|
+
Q({ error: null, isLoading: !1, payload: null, url: null });
|
|
1017
1114
|
return;
|
|
1018
1115
|
}
|
|
1019
|
-
const
|
|
1020
|
-
return
|
|
1116
|
+
const N = new AbortController();
|
|
1117
|
+
return Q({ error: null, isLoading: !0, payload: null, url: p }), fetch(p, {
|
|
1021
1118
|
headers: {
|
|
1022
1119
|
accept: "application/json"
|
|
1023
1120
|
},
|
|
1024
|
-
signal:
|
|
1025
|
-
}).then(async (
|
|
1026
|
-
if (!
|
|
1027
|
-
throw new Error(`bootstrap request failed with status ${
|
|
1028
|
-
return
|
|
1029
|
-
}).then((
|
|
1030
|
-
const
|
|
1031
|
-
if (!
|
|
1121
|
+
signal: N.signal
|
|
1122
|
+
}).then(async (v) => {
|
|
1123
|
+
if (!v.ok)
|
|
1124
|
+
throw new Error(`bootstrap request failed with status ${v.status}`);
|
|
1125
|
+
return v.json();
|
|
1126
|
+
}).then((v) => {
|
|
1127
|
+
const H = vo(v);
|
|
1128
|
+
if (!H)
|
|
1032
1129
|
throw new Error("bootstrap response is invalid");
|
|
1033
|
-
|
|
1130
|
+
Q({
|
|
1034
1131
|
error: null,
|
|
1035
1132
|
isLoading: !1,
|
|
1036
|
-
payload:
|
|
1037
|
-
url:
|
|
1133
|
+
payload: H,
|
|
1134
|
+
url: p
|
|
1038
1135
|
});
|
|
1039
|
-
}).catch((
|
|
1040
|
-
|
|
1041
|
-
}), () =>
|
|
1042
|
-
}, [
|
|
1043
|
-
const
|
|
1136
|
+
}).catch((v) => {
|
|
1137
|
+
N.signal.aborted || (console.warn("[EduzzWebchat] failed to load bootstrap", v), Q({ error: v, isLoading: !1, payload: null, url: p }));
|
|
1138
|
+
}), () => N.abort();
|
|
1139
|
+
}, [p]);
|
|
1140
|
+
const y = p && R.url === p ? R.payload : null, ie = p && R.url === p ? R.error : null, T = y?.clientId || e, P = x || y?.webchatProxyUrl || void 0, z = i === fe && y?.storageKey ? y.storageKey : i, G = typeof w == "boolean" ? w : typeof y?.defaultOpen == "boolean" ? y.defaultOpen : w, D = C(
|
|
1044
1141
|
() => ({
|
|
1045
|
-
...
|
|
1046
|
-
...
|
|
1142
|
+
...ne(y?.config) || {},
|
|
1143
|
+
...ne(s) || {}
|
|
1047
1144
|
}),
|
|
1048
|
-
[
|
|
1049
|
-
), ge =
|
|
1145
|
+
[y, s]
|
|
1146
|
+
), ge = C(
|
|
1050
1147
|
() => {
|
|
1051
|
-
const
|
|
1052
|
-
...
|
|
1053
|
-
...
|
|
1148
|
+
const N = {
|
|
1149
|
+
...ne(y?.defaultUserData) || {},
|
|
1150
|
+
...ne(n) || {}
|
|
1054
1151
|
};
|
|
1055
|
-
return Object.keys(
|
|
1152
|
+
return Object.keys(N).length > 0 ? N : null;
|
|
1056
1153
|
},
|
|
1057
|
-
[n,
|
|
1058
|
-
),
|
|
1154
|
+
[n, y]
|
|
1155
|
+
), E = !!(!V && !F && y?.sessionMode === "service-hub" && P && T), [re, ee] = S({
|
|
1059
1156
|
error: null,
|
|
1060
1157
|
isLoading: !1,
|
|
1061
1158
|
payload: null,
|
|
1062
1159
|
key: null
|
|
1063
1160
|
});
|
|
1064
1161
|
M(() => {
|
|
1065
|
-
if (
|
|
1066
|
-
|
|
1162
|
+
if (!E) {
|
|
1163
|
+
ee({ error: null, isLoading: !1, payload: null, key: null });
|
|
1067
1164
|
return;
|
|
1068
1165
|
}
|
|
1069
|
-
const
|
|
1070
|
-
storageKey:
|
|
1166
|
+
const N = xo({
|
|
1167
|
+
storageKey: z,
|
|
1071
1168
|
storageLocation: u
|
|
1072
|
-
}),
|
|
1073
|
-
let
|
|
1074
|
-
return
|
|
1169
|
+
}), v = `${T}:${P}:${N}`;
|
|
1170
|
+
let H = !1;
|
|
1171
|
+
return ee({
|
|
1075
1172
|
error: null,
|
|
1076
1173
|
isLoading: !0,
|
|
1077
1174
|
payload: null,
|
|
1078
|
-
key:
|
|
1079
|
-
}),
|
|
1080
|
-
webchatProxyUrl:
|
|
1081
|
-
clientId:
|
|
1082
|
-
accountId:
|
|
1083
|
-
}).then((
|
|
1084
|
-
|
|
1175
|
+
key: v
|
|
1176
|
+
}), No({
|
|
1177
|
+
webchatProxyUrl: P,
|
|
1178
|
+
clientId: T,
|
|
1179
|
+
accountId: N
|
|
1180
|
+
}).then((g) => {
|
|
1181
|
+
H || ee({
|
|
1085
1182
|
error: null,
|
|
1086
1183
|
isLoading: !1,
|
|
1087
|
-
payload:
|
|
1088
|
-
key:
|
|
1184
|
+
payload: g,
|
|
1185
|
+
key: v
|
|
1089
1186
|
});
|
|
1090
|
-
}).catch((
|
|
1091
|
-
|
|
1092
|
-
error:
|
|
1187
|
+
}).catch((g) => {
|
|
1188
|
+
H || (console.warn("[EduzzWebchat] failed to open public session", g), ee({
|
|
1189
|
+
error: g,
|
|
1093
1190
|
isLoading: !1,
|
|
1094
1191
|
payload: null,
|
|
1095
|
-
key:
|
|
1192
|
+
key: v
|
|
1096
1193
|
}));
|
|
1097
1194
|
}), () => {
|
|
1098
|
-
|
|
1195
|
+
H = !0;
|
|
1099
1196
|
};
|
|
1100
1197
|
}, [
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1198
|
+
T,
|
|
1199
|
+
z,
|
|
1200
|
+
P,
|
|
1201
|
+
E,
|
|
1105
1202
|
u
|
|
1106
1203
|
]);
|
|
1107
|
-
const
|
|
1108
|
-
() =>
|
|
1109
|
-
storageKey:
|
|
1204
|
+
const K = E ? re.payload : null, te = V || K, O = C(() => it(D), [D]), oe = C(
|
|
1205
|
+
() => j || r || Bo({
|
|
1206
|
+
storageKey: z,
|
|
1110
1207
|
storageLocation: u
|
|
1111
1208
|
}),
|
|
1112
|
-
[
|
|
1113
|
-
),
|
|
1209
|
+
[j, r, z, u]
|
|
1210
|
+
), $ = G ?? O.initiallyOpen ?? !0, [ye, J] = S($), se = Z($), [q, ae] = S(Be), ve = ce(() => J((N) => !N), []);
|
|
1114
1211
|
M(() => {
|
|
1115
|
-
|
|
1116
|
-
}, [
|
|
1117
|
-
const de =
|
|
1212
|
+
se.current !== $ && (se.current = $, J($));
|
|
1213
|
+
}, [$]);
|
|
1214
|
+
const de = d && !y && !ie, Ce = E && !K && !re.error;
|
|
1118
1215
|
return M(() => {
|
|
1119
|
-
const
|
|
1120
|
-
webchatProxyUrl:
|
|
1121
|
-
clientId:
|
|
1216
|
+
const N = go({
|
|
1217
|
+
webchatProxyUrl: P,
|
|
1218
|
+
clientId: T
|
|
1122
1219
|
});
|
|
1123
|
-
if (
|
|
1220
|
+
if (ae(Be), !N)
|
|
1124
1221
|
return;
|
|
1125
|
-
const
|
|
1126
|
-
let
|
|
1127
|
-
return fetch(
|
|
1222
|
+
const v = new AbortController();
|
|
1223
|
+
let H = !1;
|
|
1224
|
+
return fetch(N, {
|
|
1128
1225
|
headers: {
|
|
1129
1226
|
accept: "application/json"
|
|
1130
1227
|
},
|
|
1131
|
-
signal:
|
|
1132
|
-
}).then(async (
|
|
1133
|
-
if (!
|
|
1134
|
-
throw new Error(`runtime config request failed with status ${
|
|
1135
|
-
return
|
|
1136
|
-
}).then((
|
|
1137
|
-
if (
|
|
1228
|
+
signal: v.signal
|
|
1229
|
+
}).then(async (g) => {
|
|
1230
|
+
if (!g.ok)
|
|
1231
|
+
throw new Error(`runtime config request failed with status ${g.status}`);
|
|
1232
|
+
return g.json();
|
|
1233
|
+
}).then((g) => {
|
|
1234
|
+
if (H)
|
|
1138
1235
|
return;
|
|
1139
|
-
const ue =
|
|
1140
|
-
|
|
1236
|
+
const ue = g && typeof g == "object" && g.data && typeof g.data == "object" ? g.data : {};
|
|
1237
|
+
ae({
|
|
1141
1238
|
allowFileUpload: ue.allowFileUpload === !0,
|
|
1142
1239
|
allowMessageFeedback: ue.allowMessageFeedback === !0
|
|
1143
1240
|
});
|
|
1144
|
-
}).catch((
|
|
1145
|
-
|
|
1241
|
+
}).catch((g) => {
|
|
1242
|
+
v.signal.aborted || H || (console.warn("[EduzzWebchat] failed to load runtime config", g), ae(Be));
|
|
1146
1243
|
}), () => {
|
|
1147
|
-
|
|
1244
|
+
H = !0, v.abort();
|
|
1148
1245
|
};
|
|
1149
|
-
}, [
|
|
1150
|
-
|
|
1246
|
+
}, [T, P]), de || Ce || b && F ? null : ie && !y ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: le(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel carregar a configuracao publica do webchat." }) }) : re.error && !K ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: le(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel abrir a sessao publica do webchat." }) }) : P ? T ? /* @__PURE__ */ o(
|
|
1247
|
+
Ze,
|
|
1151
1248
|
{
|
|
1152
|
-
clientId:
|
|
1153
|
-
apiUrl:
|
|
1154
|
-
conversationId:
|
|
1155
|
-
userCredentials:
|
|
1156
|
-
storageKey:
|
|
1249
|
+
clientId: T,
|
|
1250
|
+
apiUrl: P,
|
|
1251
|
+
conversationId: oe,
|
|
1252
|
+
userCredentials: te,
|
|
1253
|
+
storageKey: z,
|
|
1157
1254
|
storageLocation: u,
|
|
1158
1255
|
children: /* @__PURE__ */ o(
|
|
1159
|
-
|
|
1256
|
+
To,
|
|
1160
1257
|
{
|
|
1161
|
-
clientId:
|
|
1162
|
-
config:
|
|
1258
|
+
clientId: T,
|
|
1259
|
+
config: O,
|
|
1163
1260
|
defaultUserData: ge,
|
|
1164
|
-
conversationIdProp:
|
|
1261
|
+
conversationIdProp: oe,
|
|
1165
1262
|
isOpen: ye,
|
|
1166
|
-
onUserApiChange:
|
|
1263
|
+
onUserApiChange: m,
|
|
1167
1264
|
onToggle: ve,
|
|
1168
|
-
runtimeCapabilities:
|
|
1169
|
-
storageKey:
|
|
1265
|
+
runtimeCapabilities: q,
|
|
1266
|
+
storageKey: z,
|
|
1170
1267
|
storageLocation: u,
|
|
1171
|
-
userToken:
|
|
1268
|
+
userToken: te?.userToken
|
|
1172
1269
|
}
|
|
1173
1270
|
)
|
|
1174
1271
|
}
|
|
1175
|
-
) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style:
|
|
1272
|
+
) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: le(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhum clientId foi informado." }) }) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: le(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhuma URL publica do proxy do webchat foi informada." }) });
|
|
1176
1273
|
}
|
|
1177
|
-
function
|
|
1274
|
+
function To({
|
|
1178
1275
|
clientId: e,
|
|
1179
1276
|
config: t,
|
|
1180
1277
|
defaultUserData: a,
|
|
@@ -1184,165 +1281,165 @@ function xo({
|
|
|
1184
1281
|
onToggle: c,
|
|
1185
1282
|
runtimeCapabilities: i,
|
|
1186
1283
|
storageKey: u,
|
|
1187
|
-
storageLocation:
|
|
1188
|
-
userToken:
|
|
1284
|
+
storageLocation: w,
|
|
1285
|
+
userToken: m
|
|
1189
1286
|
}) {
|
|
1190
|
-
const b =
|
|
1191
|
-
() =>
|
|
1287
|
+
const b = C(
|
|
1288
|
+
() => Mo({
|
|
1192
1289
|
showWelcomeScreen: t.showWelcomeScreen,
|
|
1193
1290
|
storageKey: u,
|
|
1194
|
-
storageLocation:
|
|
1291
|
+
storageLocation: w,
|
|
1195
1292
|
conversationId: r,
|
|
1196
|
-
userToken:
|
|
1293
|
+
userToken: m
|
|
1197
1294
|
}),
|
|
1198
1295
|
[
|
|
1199
1296
|
t.showWelcomeScreen,
|
|
1200
1297
|
r,
|
|
1201
1298
|
u,
|
|
1202
|
-
|
|
1203
|
-
|
|
1299
|
+
w,
|
|
1300
|
+
m
|
|
1204
1301
|
]
|
|
1205
|
-
), [
|
|
1302
|
+
), [U, f] = S(!1), [B, F] = S({ open: !1, messageId: null, draft: "" }), [{ isPanelMounted: Y, isPanelVisible: _ }, V] = Ge(So, {
|
|
1206
1303
|
isPanelMounted: s,
|
|
1207
1304
|
isPanelVisible: s
|
|
1208
1305
|
}), {
|
|
1209
|
-
conversationId:
|
|
1210
|
-
isTyping:
|
|
1211
|
-
messages:
|
|
1212
|
-
saveMessageFeedback:
|
|
1213
|
-
sendMessage:
|
|
1214
|
-
status:
|
|
1215
|
-
uploadFile:
|
|
1216
|
-
} =
|
|
1217
|
-
userCredentials:
|
|
1306
|
+
conversationId: j,
|
|
1307
|
+
isTyping: W,
|
|
1308
|
+
messages: x,
|
|
1309
|
+
saveMessageFeedback: d,
|
|
1310
|
+
sendMessage: p,
|
|
1311
|
+
status: R,
|
|
1312
|
+
uploadFile: Q
|
|
1313
|
+
} = Ye(), { openConversation: y, listConversations: ie } = Qe(), { updateUser: T, userCredentials: P } = et(), z = Z({}), [G, D] = S(() => b.activeView), [ge, E] = S(() => b.historyReturnView), { conversations: re, isLoading: ee, refresh: K } = tt({
|
|
1314
|
+
userCredentials: P,
|
|
1218
1315
|
listConversations: ie,
|
|
1219
1316
|
clientId: e
|
|
1220
|
-
}),
|
|
1221
|
-
() =>
|
|
1317
|
+
}), te = C(
|
|
1318
|
+
() => Co(a),
|
|
1222
1319
|
[a]
|
|
1223
|
-
),
|
|
1224
|
-
async (
|
|
1225
|
-
if (!
|
|
1320
|
+
), O = ce(
|
|
1321
|
+
async (I = {}) => {
|
|
1322
|
+
if (!T)
|
|
1226
1323
|
return;
|
|
1227
|
-
const
|
|
1228
|
-
...
|
|
1229
|
-
...
|
|
1230
|
-
...
|
|
1324
|
+
const h = {
|
|
1325
|
+
...ne(a) || {},
|
|
1326
|
+
...z.current,
|
|
1327
|
+
...ne(I) || {}
|
|
1231
1328
|
};
|
|
1232
|
-
return
|
|
1329
|
+
return z.current = h, T(Io(h));
|
|
1233
1330
|
},
|
|
1234
|
-
[a,
|
|
1235
|
-
),
|
|
1331
|
+
[a, T]
|
|
1332
|
+
), oe = Z(O);
|
|
1236
1333
|
M(() => {
|
|
1237
|
-
|
|
1238
|
-
}, [
|
|
1239
|
-
const
|
|
1334
|
+
oe.current = O;
|
|
1335
|
+
}, [O]);
|
|
1336
|
+
const $ = !!T;
|
|
1240
1337
|
M(() => {
|
|
1241
|
-
|
|
1242
|
-
}, [
|
|
1338
|
+
z.current = {};
|
|
1339
|
+
}, [te]), M(() => {
|
|
1243
1340
|
if (n)
|
|
1244
1341
|
return n({
|
|
1245
|
-
updateUserData:
|
|
1342
|
+
updateUserData: $ ? (I) => oe.current(I) : void 0
|
|
1246
1343
|
}), () => n(null);
|
|
1247
|
-
}, [n,
|
|
1248
|
-
|
|
1249
|
-
}, [
|
|
1250
|
-
i.allowMessageFeedback ||
|
|
1344
|
+
}, [n, $]), M(() => {
|
|
1345
|
+
!$ || !te || oe.current();
|
|
1346
|
+
}, [te, $]), M(() => {
|
|
1347
|
+
i.allowMessageFeedback || F({ open: !1, messageId: null, draft: "" });
|
|
1251
1348
|
}, [i.allowMessageFeedback]);
|
|
1252
|
-
const { showInitialLoading: ye, setShowInitialLoading:
|
|
1253
|
-
activeView:
|
|
1254
|
-
clientState:
|
|
1255
|
-
conversationId:
|
|
1256
|
-
messagesLength:
|
|
1257
|
-
}),
|
|
1258
|
-
() => t.botAvatar ||
|
|
1349
|
+
const { showInitialLoading: ye, setShowInitialLoading: J } = no({
|
|
1350
|
+
activeView: G,
|
|
1351
|
+
clientState: R,
|
|
1352
|
+
conversationId: j,
|
|
1353
|
+
messagesLength: x.length
|
|
1354
|
+
}), se = C(
|
|
1355
|
+
() => t.botAvatar || Qt({ name: t.botName, backgroundColor: t.accentColor }),
|
|
1259
1356
|
[t.accentColor, t.botAvatar, t.botName]
|
|
1260
|
-
),
|
|
1261
|
-
() => ({ ...t, botAvatar:
|
|
1262
|
-
[t,
|
|
1263
|
-
),
|
|
1264
|
-
async (
|
|
1265
|
-
|
|
1357
|
+
), q = C(
|
|
1358
|
+
() => ({ ...t, botAvatar: se }),
|
|
1359
|
+
[t, se]
|
|
1360
|
+
), ae = ce(
|
|
1361
|
+
async (I) => {
|
|
1362
|
+
E(I), D("conversations"), await K();
|
|
1266
1363
|
},
|
|
1267
|
-
[
|
|
1268
|
-
), ve =
|
|
1269
|
-
(
|
|
1270
|
-
|
|
1364
|
+
[K]
|
|
1365
|
+
), ve = ce(
|
|
1366
|
+
(I) => {
|
|
1367
|
+
J(!0), y(I), D("chat");
|
|
1271
1368
|
},
|
|
1272
|
-
[
|
|
1273
|
-
), de =
|
|
1274
|
-
|
|
1275
|
-
}, [
|
|
1276
|
-
() =>
|
|
1277
|
-
messages:
|
|
1278
|
-
user:
|
|
1279
|
-
botName:
|
|
1280
|
-
botAvatar:
|
|
1369
|
+
[y, J]
|
|
1370
|
+
), de = ce(() => {
|
|
1371
|
+
J(!0), y(), D("chat");
|
|
1372
|
+
}, [y, J]), Ce = C(
|
|
1373
|
+
() => ao({
|
|
1374
|
+
messages: x,
|
|
1375
|
+
user: P,
|
|
1376
|
+
botName: q.botName,
|
|
1377
|
+
botAvatar: q.botAvatar
|
|
1281
1378
|
}),
|
|
1282
|
-
[
|
|
1283
|
-
),
|
|
1379
|
+
[x, q.botAvatar, q.botName, P]
|
|
1380
|
+
), N = le(t), v = C(() => dt(t), [t]), H = C(() => Ot(t.fabChatIconVariant), [t.fabChatIconVariant]);
|
|
1284
1381
|
M(() => {
|
|
1285
1382
|
if (s) {
|
|
1286
|
-
|
|
1287
|
-
const be = window.requestAnimationFrame(() =>
|
|
1383
|
+
V({ type: "show" });
|
|
1384
|
+
const be = window.requestAnimationFrame(() => V({ type: "visible" }));
|
|
1288
1385
|
return () => window.cancelAnimationFrame(be);
|
|
1289
1386
|
}
|
|
1290
|
-
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1293
|
-
}, 0),
|
|
1387
|
+
V({ type: "hide" });
|
|
1388
|
+
const I = window.setTimeout(() => {
|
|
1389
|
+
f(!1), F({ open: !1, messageId: null, draft: "" });
|
|
1390
|
+
}, 0), h = window.setTimeout(() => V({ type: "unmount" }), mo);
|
|
1294
1391
|
return () => {
|
|
1295
|
-
window.clearTimeout(
|
|
1392
|
+
window.clearTimeout(I), window.clearTimeout(h);
|
|
1296
1393
|
};
|
|
1297
1394
|
}, [s]), M(() => {
|
|
1298
1395
|
if (b.bootstrapView === "pending") {
|
|
1299
|
-
if (
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1396
|
+
if (x.length > 0) {
|
|
1397
|
+
const I = window.setTimeout(() => {
|
|
1398
|
+
D("chat"), E("chat");
|
|
1302
1399
|
}, 0);
|
|
1303
|
-
return () => window.clearTimeout(
|
|
1400
|
+
return () => window.clearTimeout(I);
|
|
1304
1401
|
}
|
|
1305
|
-
if (
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1402
|
+
if (R !== "connecting") {
|
|
1403
|
+
const I = window.setTimeout(() => {
|
|
1404
|
+
D("home"), E("home");
|
|
1308
1405
|
}, 0);
|
|
1309
|
-
return () => window.clearTimeout(
|
|
1406
|
+
return () => window.clearTimeout(I);
|
|
1310
1407
|
}
|
|
1311
1408
|
}
|
|
1312
|
-
}, [
|
|
1313
|
-
const
|
|
1314
|
-
() => function(
|
|
1315
|
-
const be = i.allowMessageFeedback &&
|
|
1316
|
-
...
|
|
1317
|
-
direction:
|
|
1318
|
-
sender:
|
|
1319
|
-
timestamp:
|
|
1320
|
-
messageId:
|
|
1321
|
-
metadata:
|
|
1322
|
-
isReadOnly:
|
|
1323
|
-
status:
|
|
1324
|
-
feedback:
|
|
1325
|
-
sendMessage:
|
|
1326
|
-
addMessageFeedback:
|
|
1409
|
+
}, [R, b.bootstrapView, x.length]);
|
|
1410
|
+
const g = C(
|
|
1411
|
+
() => function(h) {
|
|
1412
|
+
const be = i.allowMessageFeedback && h.direction === "incoming" && typeof h.addMessageFeedback == "function", We = {
|
|
1413
|
+
...h.block,
|
|
1414
|
+
direction: h.direction,
|
|
1415
|
+
sender: h.sender,
|
|
1416
|
+
timestamp: h.timestamp,
|
|
1417
|
+
messageId: h.messageId,
|
|
1418
|
+
metadata: h.metadata,
|
|
1419
|
+
isReadOnly: h.isReadOnly,
|
|
1420
|
+
status: h.status,
|
|
1421
|
+
feedback: h.feedback,
|
|
1422
|
+
sendMessage: h.sendMessage,
|
|
1423
|
+
addMessageFeedback: h.addMessageFeedback
|
|
1327
1424
|
};
|
|
1328
1425
|
return /* @__PURE__ */ l(
|
|
1329
1426
|
"div",
|
|
1330
1427
|
{
|
|
1331
1428
|
className: "bpMessageBlocksBubble",
|
|
1332
|
-
"data-direction":
|
|
1429
|
+
"data-direction": h.direction,
|
|
1333
1430
|
"data-feedback": be || void 0,
|
|
1334
1431
|
children: [
|
|
1335
|
-
/* @__PURE__ */ o(
|
|
1432
|
+
/* @__PURE__ */ o(ot, { block: We }),
|
|
1336
1433
|
be ? /* @__PURE__ */ l("div", { className: "bpMessageBlocksBubbleFeedbackContainer", children: [
|
|
1337
1434
|
/* @__PURE__ */ o(
|
|
1338
1435
|
"button",
|
|
1339
1436
|
{
|
|
1340
1437
|
className: "bpMessageBlocksBubbleFeedbackIcon",
|
|
1341
1438
|
type: "button",
|
|
1342
|
-
"data-selected":
|
|
1439
|
+
"data-selected": h.feedback === "positive",
|
|
1343
1440
|
"aria-label": "Feedback positivo",
|
|
1344
|
-
onClick: () =>
|
|
1345
|
-
children:
|
|
1441
|
+
onClick: () => h.addMessageFeedback(h.messageId, { value: "positive" }),
|
|
1442
|
+
children: Wt
|
|
1346
1443
|
}
|
|
1347
1444
|
),
|
|
1348
1445
|
/* @__PURE__ */ o(
|
|
@@ -1350,14 +1447,14 @@ function xo({
|
|
|
1350
1447
|
{
|
|
1351
1448
|
className: "bpMessageBlocksBubbleFeedbackIcon",
|
|
1352
1449
|
type: "button",
|
|
1353
|
-
"data-selected":
|
|
1450
|
+
"data-selected": h.feedback === "negative",
|
|
1354
1451
|
"aria-label": "Feedback negativo",
|
|
1355
|
-
onClick: () =>
|
|
1452
|
+
onClick: () => F({
|
|
1356
1453
|
open: !0,
|
|
1357
|
-
messageId:
|
|
1454
|
+
messageId: h.messageId,
|
|
1358
1455
|
draft: ""
|
|
1359
1456
|
}),
|
|
1360
|
-
children:
|
|
1457
|
+
children: Gt
|
|
1361
1458
|
}
|
|
1362
1459
|
)
|
|
1363
1460
|
] }) : null
|
|
@@ -1366,87 +1463,90 @@ function xo({
|
|
|
1366
1463
|
);
|
|
1367
1464
|
},
|
|
1368
1465
|
[i.allowMessageFeedback]
|
|
1369
|
-
), ue =
|
|
1466
|
+
), ue = C(
|
|
1467
|
+
() => ({ bubble: g, dropdown: uo }),
|
|
1468
|
+
[g]
|
|
1469
|
+
);
|
|
1370
1470
|
return /* @__PURE__ */ l(
|
|
1371
1471
|
"div",
|
|
1372
1472
|
{
|
|
1373
1473
|
className: "bp-webchat-shell",
|
|
1374
|
-
"data-panel-mounted":
|
|
1375
|
-
"data-panel-open":
|
|
1376
|
-
style:
|
|
1474
|
+
"data-panel-mounted": Y,
|
|
1475
|
+
"data-panel-open": _,
|
|
1476
|
+
style: N,
|
|
1377
1477
|
children: [
|
|
1378
|
-
/* @__PURE__ */ o(
|
|
1379
|
-
|
|
1380
|
-
|
|
1478
|
+
/* @__PURE__ */ o(at, { ...v }),
|
|
1479
|
+
Y ? /* @__PURE__ */ o("div", { className: "bp-webchat-panel", "data-state": _ ? "open" : "closed", children: G === "home" ? /* @__PURE__ */ o(
|
|
1480
|
+
po,
|
|
1381
1481
|
{
|
|
1382
|
-
config:
|
|
1383
|
-
activeView:
|
|
1482
|
+
config: q,
|
|
1483
|
+
activeView: G,
|
|
1384
1484
|
onClose: c,
|
|
1385
|
-
onShowHome: () =>
|
|
1386
|
-
onShowConversations: () =>
|
|
1387
|
-
onStart: () =>
|
|
1485
|
+
onShowHome: () => D("home"),
|
|
1486
|
+
onShowConversations: () => ae("home"),
|
|
1487
|
+
onStart: () => D("chat")
|
|
1388
1488
|
}
|
|
1389
|
-
) :
|
|
1390
|
-
|
|
1489
|
+
) : G === "conversations" ? /* @__PURE__ */ o(
|
|
1490
|
+
io,
|
|
1391
1491
|
{
|
|
1392
|
-
conversations:
|
|
1393
|
-
currentConversationId:
|
|
1394
|
-
isLoading:
|
|
1395
|
-
botAvatar:
|
|
1396
|
-
botName:
|
|
1397
|
-
onClose: () =>
|
|
1492
|
+
conversations: re,
|
|
1493
|
+
currentConversationId: j,
|
|
1494
|
+
isLoading: ee,
|
|
1495
|
+
botAvatar: q.botAvatar,
|
|
1496
|
+
botName: q.botName,
|
|
1497
|
+
onClose: () => D(ge),
|
|
1398
1498
|
onCloseWidget: c,
|
|
1399
1499
|
onShowHome: () => {
|
|
1400
|
-
|
|
1500
|
+
D("home"), E("home");
|
|
1401
1501
|
},
|
|
1402
|
-
onShowConversations:
|
|
1502
|
+
onShowConversations: K,
|
|
1403
1503
|
onNewConversation: de,
|
|
1404
1504
|
onConversationClick: ve
|
|
1405
1505
|
}
|
|
1406
|
-
) :
|
|
1506
|
+
) : G === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(ze, {}) }) : /* @__PURE__ */ l(Ve, { children: [
|
|
1407
1507
|
/* @__PURE__ */ o(
|
|
1408
|
-
|
|
1508
|
+
lo,
|
|
1409
1509
|
{
|
|
1410
|
-
config:
|
|
1510
|
+
config: q,
|
|
1411
1511
|
allowFileUpload: i.allowFileUpload,
|
|
1412
|
-
clientState:
|
|
1413
|
-
isTyping:
|
|
1512
|
+
clientState: R,
|
|
1513
|
+
isTyping: W,
|
|
1414
1514
|
messages: Ce,
|
|
1415
1515
|
renderers: ue,
|
|
1416
|
-
sendMessage:
|
|
1417
|
-
uploadFile:
|
|
1418
|
-
addMessageFeedback: i.allowMessageFeedback ?
|
|
1516
|
+
sendMessage: p,
|
|
1517
|
+
uploadFile: Q,
|
|
1518
|
+
addMessageFeedback: i.allowMessageFeedback ? d : void 0,
|
|
1419
1519
|
showInitialLoading: ye,
|
|
1420
1520
|
onShowHome: t.showWelcomeScreen ? () => {
|
|
1421
|
-
|
|
1521
|
+
D("home"), E("home");
|
|
1422
1522
|
} : void 0,
|
|
1423
|
-
onOpenHistory: () =>
|
|
1424
|
-
onRestartConversation: () =>
|
|
1523
|
+
onOpenHistory: () => ae("chat"),
|
|
1524
|
+
onRestartConversation: () => f(!0),
|
|
1425
1525
|
onCloseWidget: c
|
|
1426
1526
|
}
|
|
1427
1527
|
),
|
|
1428
1528
|
/* @__PURE__ */ o(
|
|
1429
|
-
|
|
1529
|
+
ho,
|
|
1430
1530
|
{
|
|
1431
|
-
open:
|
|
1432
|
-
onCancel: () =>
|
|
1531
|
+
open: U,
|
|
1532
|
+
onCancel: () => f(!1),
|
|
1433
1533
|
onConfirm: () => {
|
|
1434
|
-
|
|
1534
|
+
f(!1), de();
|
|
1435
1535
|
}
|
|
1436
1536
|
}
|
|
1437
1537
|
),
|
|
1438
1538
|
i.allowMessageFeedback ? /* @__PURE__ */ o(
|
|
1439
|
-
|
|
1539
|
+
bo,
|
|
1440
1540
|
{
|
|
1441
|
-
open:
|
|
1442
|
-
draft:
|
|
1443
|
-
setDraft: (
|
|
1444
|
-
onCancel: () =>
|
|
1541
|
+
open: B.open,
|
|
1542
|
+
draft: B.draft,
|
|
1543
|
+
setDraft: (I) => F((h) => ({ ...h, draft: I })),
|
|
1544
|
+
onCancel: () => F({ open: !1, messageId: null, draft: "" }),
|
|
1445
1545
|
onConfirm: async () => {
|
|
1446
|
-
|
|
1546
|
+
B.messageId && d && await d(B.messageId, {
|
|
1447
1547
|
value: "negative",
|
|
1448
|
-
comment:
|
|
1449
|
-
}),
|
|
1548
|
+
comment: B.draft
|
|
1549
|
+
}), F({ open: !1, messageId: null, draft: "" });
|
|
1450
1550
|
}
|
|
1451
1551
|
}
|
|
1452
1552
|
) : null
|
|
@@ -1460,8 +1560,8 @@ function xo({
|
|
|
1460
1560
|
type: "button",
|
|
1461
1561
|
"aria-label": s ? "Fechar webchat" : "Abrir webchat",
|
|
1462
1562
|
children: [
|
|
1463
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--chat", children:
|
|
1464
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--close", children:
|
|
1563
|
+
/* @__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: Et })
|
|
1465
1565
|
]
|
|
1466
1566
|
}
|
|
1467
1567
|
)
|
|
@@ -1470,9 +1570,9 @@ function xo({
|
|
|
1470
1570
|
);
|
|
1471
1571
|
}
|
|
1472
1572
|
export {
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1573
|
+
Ro as Webchat,
|
|
1574
|
+
X as defaultConfig,
|
|
1575
|
+
me as getContrastingTextColor,
|
|
1576
|
+
le as getShellStyle,
|
|
1577
|
+
it as normalizeConfig
|
|
1478
1578
|
};
|