@eduzz-automacoes/webchat-widget 0.0.2 → 0.2.0

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