@eduzz-automacoes/webchat-widget 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
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 = {
1
+ import { jsx as o, jsxs as l, Fragment as Fe } from "react/jsx-runtime";
2
+ import { forwardRef as Pe, createElement as Ne, useState as S, useEffect as M, useRef as Y, useMemo as k, useCallback as le, useReducer as st } from "react";
3
+ import { Container as ct, MessageList as lt, Composer as it, WebchatProvider as dt, useActiveConversation as ut, useConversations as bt, useUser as ht, useConversationList as pt, Block as Te, StylesheetProvider as mt } from "@botpress/webchat";
4
+ import './style.css';const Z = {
5
5
  botName: "Assistente Virtual",
6
6
  subtitle: "Conectado ao bot real",
7
7
  botAvatar: "",
@@ -64,8 +64,8 @@ import './style.css';const G = {
64
64
  welcomeCloseLabel: "Fechar painel",
65
65
  openFabBackgroundColor: "#2563eb",
66
66
  openFabIconColor: "#ffffff"
67
- }, Fe = (e) => e === "bottom-left" || e === "top-left" ? "bottom-left" : "bottom-right", at = (e) => {
68
- switch (Fe(e)) {
67
+ }, He = (e) => e === "bottom-left" || e === "top-left" ? "bottom-left" : "bottom-right", wt = (e) => {
68
+ switch (He(e)) {
69
69
  case "bottom-left":
70
70
  return {
71
71
  bottom: "24px",
@@ -82,12 +82,12 @@ import './style.css';const G = {
82
82
  "--panel-transform-origin": "right bottom"
83
83
  };
84
84
  }
85
- }, Re = (e, t, a) => Math.min(Math.max(e, t), a), xe = (e) => {
85
+ }, $e = (e, t, a) => Math.min(Math.max(e, t), a), Ie = (e) => {
86
86
  if (typeof e != "string") return null;
87
87
  let t = e.trim();
88
88
  return !t || (t.startsWith("#") && (t = t.slice(1)), t.length === 3 && (t = t.split("").map((a) => `${a}${a}`).join("")), !/^[0-9a-fA-F]{6}$/.test(t)) ? null : `#${t.toLowerCase()}`;
89
- }, Ne = (e) => {
90
- const t = xe(e);
89
+ }, Me = (e) => {
90
+ const t = Ie(e);
91
91
  if (!t) return null;
92
92
  const a = t.slice(1);
93
93
  return {
@@ -95,19 +95,19 @@ import './style.css';const G = {
95
95
  g: Number.parseInt(a.slice(2, 4), 16),
96
96
  b: Number.parseInt(a.slice(4, 6), 16)
97
97
  };
98
- }, nt = ({ r: e, g: t, b: a }) => `#${[e, t, a].map(
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);
98
+ }, ft = ({ r: e, g: t, b: a }) => `#${[e, t, a].map(
99
+ (r) => $e(Math.round(r), 0, 255).toString(16).padStart(2, "0")
100
+ ).join("")}`, pe = (e, t, a) => {
101
+ const r = Me(e), s = Me(t);
102
102
  if (!r || !s) return null;
103
- const n = Re(a, 0, 1);
104
- return nt({
103
+ const n = $e(a, 0, 1);
104
+ return ft({
105
105
  r: r.r * (1 - n) + s.r * n,
106
106
  g: r.g * (1 - n) + s.g * n,
107
107
  b: r.b * (1 - n) + s.b * n
108
108
  });
109
- }, rt = (e, t) => t < 0 ? me(e, "#000000", Math.abs(t)) : me(e, "#ffffff", t), pe = (e) => {
110
- const t = Ne(e);
109
+ }, gt = (e, t) => t < 0 ? pe(e, "#000000", Math.abs(t)) : pe(e, "#ffffff", t), me = (e) => {
110
+ const t = Me(e);
111
111
  return t && [t.r, t.g, t.b].map((r) => {
112
112
  const s = r / 255;
113
113
  return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
@@ -115,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
- }, F = (e, t) => e && Object.prototype.hasOwnProperty.call(e, t) && e[t] != null && e[t] !== "", st = (e, t) => {
119
- const a = xe(e.brandColor);
118
+ }, L = (e, t) => e && Object.prototype.hasOwnProperty.call(e, t) && e[t] != null && e[t] !== "", yt = (e, t) => {
119
+ const a = Ie(e.brandColor);
120
120
  if (!a) return e;
121
- const r = 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;
121
+ const r = Ie(e.brandTextColor) || me(a), s = pe(a, "#ffffff", 0.82) || Z.secondaryButtonBorderColor, n = pe(a, "#ffffff", 0.92) || Z.secondaryButtonHoverBackgroundColor, c = gt(a, -0.12) || Z.primaryButtonHoverBackgroundColor;
122
122
  return {
123
123
  ...e,
124
124
  brandColor: a,
125
125
  brandTextColor: r,
126
- primaryButtonBackgroundColor: F(
126
+ primaryButtonBackgroundColor: L(
127
127
  t,
128
128
  "primaryButtonBackgroundColor"
129
129
  ) ? e.primaryButtonBackgroundColor : a,
130
- primaryButtonTextColor: F(t, "primaryButtonTextColor") ? e.primaryButtonTextColor : r,
131
- primaryButtonHoverBackgroundColor: F(
130
+ primaryButtonTextColor: L(t, "primaryButtonTextColor") ? e.primaryButtonTextColor : r,
131
+ primaryButtonHoverBackgroundColor: L(
132
132
  t,
133
133
  "primaryButtonHoverBackgroundColor"
134
134
  ) ? e.primaryButtonHoverBackgroundColor : c,
135
- secondaryButtonBackgroundColor: F(
135
+ secondaryButtonBackgroundColor: L(
136
136
  t,
137
137
  "secondaryButtonBackgroundColor"
138
138
  ) ? e.secondaryButtonBackgroundColor : "#ffffff",
139
- secondaryButtonTextColor: F(t, "secondaryButtonTextColor") ? e.secondaryButtonTextColor : a,
140
- secondaryButtonBorderColor: F(t, "secondaryButtonBorderColor") ? e.secondaryButtonBorderColor : s,
141
- secondaryButtonHoverBackgroundColor: F(
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: F(t, "iconButtonBackgroundColor") ? e.iconButtonBackgroundColor : "#ffffff",
146
- iconButtonIconColor: F(t, "iconButtonIconColor") ? e.iconButtonIconColor : a,
147
- iconButtonBorderColor: F(t, "iconButtonBorderColor") ? e.iconButtonBorderColor : s,
148
- iconButtonHoverBackgroundColor: F(
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
- }, ct = (e) => {
154
- const t = e.fabBackgroundColor || e.openFabBackgroundColor || G.fabBackgroundColor, a = e.fabIconColor || e.openFabIconColor || G.fabIconColor;
153
+ }, vt = (e) => {
154
+ const t = e.fabBackgroundColor || e.openFabBackgroundColor || Z.fabBackgroundColor, a = e.fabIconColor || e.openFabIconColor || Z.fabIconColor;
155
155
  return {
156
156
  ...e,
157
157
  fabBackgroundColor: t,
@@ -159,17 +159,17 @@ import './style.css';const G = {
159
159
  openFabBackgroundColor: t,
160
160
  openFabIconColor: a
161
161
  };
162
- }, lt = (e = {}) => ct(
163
- st(
162
+ }, Ct = (e = {}) => vt(
163
+ yt(
164
164
  {
165
- ...G,
165
+ ...Z,
166
166
  ...e,
167
- position: Fe(e.position ?? G.position)
167
+ position: He(e.position ?? Z.position)
168
168
  },
169
169
  e
170
170
  )
171
- ), se = (e) => ({
172
- ...at(e.position),
171
+ ), ie = (e) => ({
172
+ ...wt(e.position),
173
173
  "--widget-width": e.width,
174
174
  "--widget-height": e.height,
175
175
  "--bpGray-1": "var(--ui-bg)",
@@ -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": pe(e.accentColor),
188
+ "--accent-text-color": me(e.accentColor),
189
189
  "--header-avatar-bg": e.accentColor,
190
- "--header-avatar-text": pe(e.accentColor),
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
- }), it = (e) => ({
231
+ }), Bt = (e) => ({
232
232
  color: e.color || e.accentColor,
233
233
  fontFamily: e.fontFamily,
234
234
  radius: e.radius,
@@ -238,18 +238,18 @@ import './style.css';const G = {
238
238
  additionalStylesheet: e.additionalStylesheet,
239
239
  additionalStylesheetUrl: e.additionalStylesheetUrl
240
240
  });
241
- const dt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ut = (e) => e.replace(
241
+ const kt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), xt = (e) => e.replace(
242
242
  /^([A-Z])|[\s-_]+(\w)/g,
243
243
  (t, a, r) => r ? r.toUpperCase() : a.toLowerCase()
244
- ), Me = (e) => {
245
- const t = ut(e);
244
+ ), Ae = (e) => {
245
+ const t = xt(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(), bt = (e) => {
247
+ }, Le = (...e) => e.filter((t, a, r) => !!t && t.trim() !== "" && r.indexOf(t) === a).join(" ").trim(), Nt = (e) => {
248
248
  for (const t in e)
249
249
  if (t.startsWith("aria-") || t === "role" || t === "title")
250
250
  return !0;
251
251
  };
252
- var ht = {
252
+ var It = {
253
253
  xmlns: "http://www.w3.org/2000/svg",
254
254
  width: 24,
255
255
  height: 24,
@@ -260,7 +260,7 @@ var ht = {
260
260
  strokeLinecap: "round",
261
261
  strokeLinejoin: "round"
262
262
  };
263
- const mt = Ve(
263
+ const Mt = Pe(
264
264
  ({
265
265
  color: e = "currentColor",
266
266
  size: t = 24,
@@ -270,46 +270,47 @@ const mt = Ve(
270
270
  children: n,
271
271
  iconNode: c,
272
272
  ...i
273
- }, u) => ke(
273
+ }, u) => Ne(
274
274
  "svg",
275
275
  {
276
276
  ref: u,
277
- ...ht,
277
+ ...It,
278
278
  width: t,
279
279
  height: t,
280
280
  stroke: e,
281
281
  strokeWidth: r ? Number(a) * 24 / Number(t) : a,
282
- className: Pe("lucide", s),
283
- ...!n && !bt(i) && { "aria-hidden": "true" },
282
+ className: Le("lucide", s),
283
+ ...!n && !Nt(i) && { "aria-hidden": "true" },
284
284
  ...i
285
285
  },
286
286
  [
287
- ...c.map(([m, w]) => ke(m, w)),
287
+ ...c.map(([w, m]) => Ne(w, m)),
288
288
  ...Array.isArray(n) ? n : [n]
289
289
  ]
290
290
  )
291
291
  );
292
- const S = (e, t) => {
293
- const a = Ve(
294
- ({ className: r, ...s }, n) => ke(mt, {
292
+ const A = (e, t) => {
293
+ const a = Pe(
294
+ ({ className: r, ...s }, n) => Ne(Mt, {
295
295
  ref: n,
296
296
  iconNode: t,
297
- className: Pe(
298
- `lucide-${dt(Me(e))}`,
297
+ className: Le(
298
+ `lucide-${kt(Ae(e))}`,
299
299
  `lucide-${e}`,
300
300
  r
301
301
  ),
302
302
  ...s
303
303
  })
304
304
  );
305
- return a.displayName = Me(e), a;
305
+ return a.displayName = Ae(e), a;
306
306
  };
307
- const pt = [
307
+ const St = [
308
308
  ["path", { d: "M5 12h14", key: "1ays0h" }],
309
309
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
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
- const yt = [
310
+ ], Tt = A("arrow-right", St);
311
+ const At = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], Ut = A("chevron-down", At);
312
+ const Vt = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], Rt = A("chevron-right", Vt);
313
+ const Dt = [
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
- ], vt = S("house", yt);
322
- const Ct = [
322
+ ], Ft = A("house", Dt);
323
+ const Pt = [
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
- ], Bt = S("message-circle-more", Ct);
334
- const kt = [
334
+ ], Ht = A("message-circle-more", Pt);
335
+ const $t = [
335
336
  [
336
337
  "path",
337
338
  {
@@ -339,8 +340,8 @@ const kt = [
339
340
  key: "1sd12s"
340
341
  }
341
342
  ]
342
- ], xt = S("message-circle", kt);
343
- const Nt = [
343
+ ], Lt = A("message-circle", $t);
344
+ const _t = [
344
345
  [
345
346
  "path",
346
347
  {
@@ -348,8 +349,8 @@ const Nt = [
348
349
  key: "18887p"
349
350
  }
350
351
  ]
351
- ], He = S("message-square", Nt);
352
- const It = [
352
+ ], _e = A("message-square", _t);
353
+ const zt = [
353
354
  [
354
355
  "path",
355
356
  {
@@ -364,12 +365,12 @@ const It = [
364
365
  key: "1qfcsi"
365
366
  }
366
367
  ]
367
- ], $e = S("messages-square", It);
368
- const Mt = [
368
+ ], ze = A("messages-square", zt);
369
+ const Et = [
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
- ], St = S("rotate-ccw", Mt);
372
- const Tt = [
372
+ ], Ot = A("rotate-ccw", Et);
373
+ const qt = [
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
- ], At = S("square-pen", Tt);
382
- const Ut = [
382
+ ], jt = A("square-pen", qt);
383
+ const Wt = [
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
- ], Vt = S("thumbs-down", Ut);
392
- const Ft = [
392
+ ], Gt = A("thumbs-down", Wt);
393
+ const Kt = [
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
- ], Rt = S("thumbs-up", Ft);
402
- const Pt = [
402
+ ], Jt = A("thumbs-up", Kt);
403
+ const Xt = [
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
- ], Ht = S("user-round", Pt);
406
- const $t = [
406
+ ], Zt = A("user-round", Xt);
407
+ const Yt = [
407
408
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
408
409
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
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 = `
410
+ ], Ee = A("x", Yt), x = { "aria-hidden": !0, strokeWidth: 1.9 }, Qt = /* @__PURE__ */ o(Ot, { ...x }), we = /* @__PURE__ */ o(Ee, { ...x }), eo = /* @__PURE__ */ o(Ee, { ...x }), Ue = {
411
+ "message-circle-more": /* @__PURE__ */ o(Ht, { ...x }),
412
+ "message-circle": /* @__PURE__ */ o(Lt, { ...x }),
413
+ "message-square": /* @__PURE__ */ o(_e, { ...x }),
414
+ "messages-square": /* @__PURE__ */ o(ze, { ...x })
415
+ }, to = (e = "messages-square") => Ue[e] || Ue["messages-square"], oo = /* @__PURE__ */ o(Tt, { ...x }), Oe = /* @__PURE__ */ o(Ft, { ...x }), ao = /* @__PURE__ */ o(_e, { ...x }), no = /* @__PURE__ */ o(Jt, { ...x }), ro = /* @__PURE__ */ o(Gt, { ...x }), so = /* @__PURE__ */ o(ze, { ...x }), co = /* @__PURE__ */ o(Rt, { ...x }), lo = /* @__PURE__ */ o(Ut, { ...x }), io = /* @__PURE__ */ o(jt, { ...x }), uo = /* @__PURE__ */ o(Zt, { ...x }), he = (e) => String(e).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&apos;"), bo = ({ 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
- }, 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
+ }, ho = (e) => e ? e.payload?.type === "text" ? e.payload.text : e.payload?.type === "bloc" && e.payload.items?.some((t) => t.type === "text") ? e.payload.items.find((a) => a.type === "text")?.payload.text ?? "Conversa sem mensagens" : "Anexo enviado" : "Conversa sem mensagens", Ve = [
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
- ], Zt = new Intl.RelativeTimeFormat("pt-BR", { numeric: "auto" }), Yt = (e) => {
430
+ ], po = new Intl.RelativeTimeFormat("pt-BR", { numeric: "auto" }), mo = (e) => {
430
431
  const t = Math.round((new Date(e).getTime() - Date.now()) / 1e3);
431
432
  if (Math.abs(t) < 45) return "agora";
432
- let a = Te[0];
433
- for (const r of Te)
433
+ let a = Ve[0];
434
+ for (const r of Ve)
434
435
  Math.abs(t) >= r.seconds && (a = r);
435
- return Zt.format(Math.round(t / a.seconds), a.unit);
436
- }, Qt = ({ messages: e, user: t, botName: a, botAvatar: r }) => e.map((s) => {
436
+ return po.format(Math.round(t / a.seconds), a.unit);
437
+ }, wo = ({ 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
- }), eo = ({ activeView: e, clientState: t, conversationId: a, messagesLength: r }) => {
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");
444
+ }), fo = ({ 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 w = window.setTimeout(() => n(!1), 900);
449
- return () => window.clearTimeout(w);
449
+ const m = window.setTimeout(() => n(!1), 900);
450
+ return () => window.clearTimeout(m);
450
451
  }
451
- if (m) {
452
- const w = window.setTimeout(() => n(!1), 0);
453
- return () => window.clearTimeout(w);
452
+ if (w) {
453
+ const m = window.setTimeout(() => n(!1), 0);
454
+ return () => window.clearTimeout(m);
454
455
  }
455
456
  }
456
- }, [a, s, u, m]), {
457
+ }, [a, s, u, w]), {
457
458
  showInitialLoading: i || s && c,
458
459
  setShowInitialLoading: n
459
460
  };
460
- }, to = 3e4, oo = ({
461
+ }, go = 3e4, yo = ({
461
462
  getSession: e,
462
463
  sessionKey: t,
463
464
  onSessionChange: a
464
465
  }) => {
465
- const [r, s] = R(null), [n, c] = R(!!e), i = ce(e);
466
+ const [r, s] = S(null), [n, c] = S(!!e), i = Y(e);
466
467
  i.current = e;
467
- const u = ce(a);
468
+ const u = Y(a);
468
469
  return u.current = a, M(() => {
469
- let m = !0, w;
470
- const b = (h) => {
471
- m && (s(h), u.current?.(h));
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 P = async () => {
478
+ const U = async () => {
478
479
  try {
479
- const h = await i.current();
480
- if (!h?.userToken)
480
+ const f = await i.current();
481
+ if (!f?.userToken)
481
482
  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);
483
+ if (!w) return;
484
+ b(f);
485
+ const B = f.expiresAt - Date.now() - go;
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
- m && c(!1);
490
+ w && c(!1);
490
491
  }
491
492
  };
492
- return c(!0), P(), () => {
493
- m = !1, w && clearTimeout(w);
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 ao({
498
+ function vo({
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: Le
523
+ children: Oe
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: Et
533
+ children: so
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: _t
543
+ children: Qt
543
544
  }
544
545
  ),
545
546
  c ? /* @__PURE__ */ o(
@@ -555,7 +556,7 @@ function ao({
555
556
  ] })
556
557
  ] });
557
558
  }
558
- function ze() {
559
+ function qe() {
559
560
  return /* @__PURE__ */ l("div", { className: "bp-webchat-loading", children: [
560
561
  /* @__PURE__ */ l("div", { className: "bp-webchat-loading-hero", children: [
561
562
  /* @__PURE__ */ o("div", { className: "bp-webchat-loading-circle" }),
@@ -573,7 +574,7 @@ function ze() {
573
574
  ] })
574
575
  ] });
575
576
  }
576
- function no({
577
+ function Co({
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: m,
587
- onShowHome: w,
587
+ showInitialLoading: w,
588
+ onShowHome: m,
588
589
  onOpenHistory: b,
589
- onRestartConversation: P,
590
- onCloseWidget: h
590
+ onRestartConversation: U,
591
+ onCloseWidget: f
591
592
  }) {
592
593
  return /* @__PURE__ */ l("div", { className: "bp-webchat-layout", children: [
593
594
  /* @__PURE__ */ o(
594
- ao,
595
+ vo,
595
596
  {
596
597
  botName: e.botName,
597
598
  botAvatar: e.botAvatar,
598
599
  subtitle: e.subtitle,
599
- onShowHome: w,
600
+ onShowHome: m,
600
601
  onOpenHistory: b,
601
- onRestartConversation: P,
602
- onCloseWidget: h
602
+ onRestartConversation: U,
603
+ onCloseWidget: f
603
604
  }
604
605
  ),
605
606
  /* @__PURE__ */ o(
606
- Ge,
607
+ ct,
607
608
  {
608
609
  className: "bp-webchat-container",
609
610
  uploadFile: i,
610
611
  allowFileUpload: t,
611
- children: m ? /* @__PURE__ */ o(ze, {}) : /* @__PURE__ */ l(Ue, { children: [
612
+ children: w ? /* @__PURE__ */ o(qe, {}) : /* @__PURE__ */ l(Fe, { children: [
612
613
  /* @__PURE__ */ o(
613
- Ke,
614
+ lt,
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
- Je,
631
+ it,
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 De({ activeView: e, onShowHome: t, onShowConversations: a }) {
646
+ function je({ 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: Le }),
656
+ /* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: Oe }),
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: qt }),
669
+ /* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: ao }),
669
670
  /* @__PURE__ */ o("span", { children: "Conversas" })
670
671
  ]
671
672
  }
672
673
  )
673
674
  ] });
674
675
  }
675
- function ro({
676
+ function Bo({
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: m,
686
- onConversationClick: w
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 P = Xt(b.lastMessage), h = b.lastMessage?.author?.type === "bot";
716
+ const U = ho(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: () => w(b.id),
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": h ? "bot" : "user", children: h && r ? /* @__PURE__ */ o("img", { src: r, alt: "" }) : h ? /* @__PURE__ */ o("span", { children: (s || "B").slice(0, 1).toUpperCase() }) : Kt }),
725
+ /* @__PURE__ */ o("div", { className: "bp-webchat-history-avatar", "data-kind": f ? "bot" : "user", children: f && r ? /* @__PURE__ */ o("img", { src: r, alt: "" }) : f ? /* @__PURE__ */ o("span", { children: (s || "B").slice(0, 1).toUpperCase() }) : uo }),
725
726
  /* @__PURE__ */ l("div", { className: "bp-webchat-history-content", children: [
726
- /* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children: P }),
727
- /* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: Yt(b.updatedAt) })
727
+ /* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children: U }),
728
+ /* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: mo(b.updatedAt) })
728
729
  ] }),
729
- /* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children: Wt })
730
+ /* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children: co })
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: m, children: [
736
- Gt,
736
+ /* @__PURE__ */ o("div", { className: "bp-webchat-history-footer", children: /* @__PURE__ */ l("button", { className: "bp-webchat-history-new", type: "button", onClick: w, children: [
737
+ io,
737
738
  /* @__PURE__ */ o("span", { children: "Nova conversa" })
738
739
  ] }) }),
739
740
  /* @__PURE__ */ o(
740
- De,
741
+ je,
741
742
  {
742
743
  activeView: "conversations",
743
744
  onShowHome: i,
@@ -746,7 +747,103 @@ function ro({
746
747
  )
747
748
  ] });
748
749
  }
749
- function so({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
750
+ const Re = (e) => String(e ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim();
751
+ function ko(e) {
752
+ const { label: t, options: a = [], sendMessage: r, isReadOnly: s, messageId: n } = e, [c, i] = S(!1), [u, w] = S(""), [m, b] = S(0), [U, f] = S(null), B = Y(null), F = Y([]), _ = s || U !== null || a.length === 0, V = k(() => {
753
+ const d = Re(u);
754
+ return d ? a.filter((p) => Re(p.label).includes(d)) : a;
755
+ }, [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 W = (d) => {
768
+ d && (r?.({ type: "text", text: d.label, value: d.value }), f(d.label), w(""), i(!1));
769
+ }, G = (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 && W(V[m]);
784
+ break;
785
+ case "Escape":
786
+ i(!1);
787
+ break;
788
+ }
789
+ }, N = `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": N,
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: G
820
+ }
821
+ ),
822
+ /* @__PURE__ */ o("span", { className: "bpDropdownChevron", children: lo })
823
+ ] }),
824
+ c && !_ ? /* @__PURE__ */ o("ul", { className: "bpDropdownMenu", id: N, 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(), W(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 xo({ 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 co({ open: e, onConfirm: t, onCancel: a }) {
873
+ function No({ 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 lo({ config: e, activeView: t, onShowHome: a, onShowConversations: r, onStart: s, onClose: n }) {
891
+ function Io({ 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: Dt })
917
+ /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-right", children: oo })
821
918
  ] })
822
919
  ] }) }),
823
920
  /* @__PURE__ */ o(
824
- De,
921
+ je,
825
922
  {
826
923
  activeView: t,
827
924
  onShowHome: a,
@@ -830,43 +927,43 @@ function lo({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
830
927
  )
831
928
  ] });
832
929
  }
833
- const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
930
+ const Mo = 220, fe = "eduzz-webchat", xe = Object.freeze({
834
931
  allowFileUpload: !1,
835
932
  allowMessageFeedback: !1
836
- }), uo = "anonymous-id", bo = (e) => !!e && typeof e == "object" && !Array.isArray(e), qe = (e) => e.replace(/\/+$/, ""), Ie = ({ webchatProxyUrl: e }) => {
933
+ }), So = "anonymous-id", To = (e) => !!e && typeof e == "object" && !Array.isArray(e), We = (e) => e.replace(/\/+$/, ""), Se = ({ webchatProxyUrl: e }) => {
837
934
  if (typeof e != "string" || !e.trim())
838
935
  return null;
839
- const t = qe(e.trim()), a = "/webchat/proxy";
936
+ const t = We(e.trim()), a = "/webchat/proxy";
840
937
  return t.endsWith(a) ? t.slice(0, -a.length) : null;
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 }) => {
938
+ }, Ao = ({ webchatProxyUrl: e, clientId: t }) => !e || !t ? null : `${e.endsWith("/") ? e.slice(0, -1) : e}/${encodeURIComponent(t)}/runtime-config`, Uo = ({ webchatProxyUrl: e, clientId: t, presetSlug: a }) => {
842
939
  if (!e || !t)
843
940
  return null;
844
- const r = Ie({ webchatProxyUrl: e });
941
+ const r = Se({ webchatProxyUrl: e });
845
942
  if (!r)
846
943
  return null;
847
944
  const s = new URLSearchParams();
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
- }, po = (e) => {
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
- }, Q = (e) => bo(e) ? e : null, wo = (e) => {
951
+ }, re = (e) => To(e) ? e : null, Ro = (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
- }, Oe = (e) => {
958
+ }, Ge = (e) => {
862
959
  if (typeof window > "u") return null;
863
960
  try {
864
961
  return e === "sessionStorage" ? window.sessionStorage : window.localStorage;
865
962
  } catch {
866
963
  return null;
867
964
  }
868
- }, je = ({ storageKey: e, storageLocation: t }) => {
869
- const a = Oe(t);
965
+ }, Ke = ({ storageKey: e, storageLocation: t }) => {
966
+ const a = Ge(t);
870
967
  if (!a) return null;
871
968
  try {
872
969
  const r = a.getItem(
@@ -878,10 +975,13 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
878
975
  } catch {
879
976
  return;
880
977
  }
881
- }, fo = ({ storageKey: e, storageLocation: t }) => {
882
- const a = je({ storageKey: e, storageLocation: t });
978
+ }, Do = ({ storageKey: e, storageLocation: t }) => {
979
+ const a = Ke({
980
+ storageKey: e,
981
+ storageLocation: t
982
+ });
883
983
  return typeof a?.conversationId == "string" && a.conversationId.trim() || void 0;
884
- }, Ae = () => {
984
+ }, De = () => {
885
985
  try {
886
986
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
887
987
  return crypto.randomUUID();
@@ -895,19 +995,23 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
895
995
  const t = Math.random() * 16 | 0;
896
996
  return (e === "x" ? t : t & 3 | 8).toString(16);
897
997
  });
898
- }, go = (e) => `${e || fe}-${uo}`, yo = ({ storageKey: e, storageLocation: t }) => {
899
- const a = Oe(t), r = go(e);
998
+ }, Fo = (e) => `${e || fe}-${So}`, Po = ({ storageKey: e, storageLocation: t }) => {
999
+ const a = Ge(t), r = Fo(e);
900
1000
  try {
901
1001
  const s = a?.getItem(r);
902
1002
  if (s)
903
1003
  return s;
904
- const n = `anon_${Ae()}`;
1004
+ const n = `anon_${De()}`;
905
1005
  return a?.setItem(r, n), n;
906
1006
  } catch {
907
- return `anon_${Ae()}`;
1007
+ return `anon_${De()}`;
908
1008
  }
909
- }, vo = async ({ webchatProxyUrl: e, clientId: t, accountId: a }) => {
910
- const r = Ie({ webchatProxyUrl: e });
1009
+ }, Ho = async ({
1010
+ webchatProxyUrl: e,
1011
+ clientId: t,
1012
+ accountId: a
1013
+ }) => {
1014
+ const r = Se({ webchatProxyUrl: e });
911
1015
  if (!r)
912
1016
  throw new Error("public session request requires a valid webchatProxyUrl");
913
1017
  const s = await fetch(
@@ -921,7 +1025,9 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
921
1025
  }
922
1026
  );
923
1027
  if (!s.ok)
924
- throw new Error(`public session request failed with status ${s.status}`);
1028
+ throw new Error(
1029
+ `public session request failed with status ${s.status}`
1030
+ );
925
1031
  const n = await s.json(), c = n && typeof n == "object" && n.data && typeof n.data == "object" ? n.data : n;
926
1032
  if (!c || typeof c != "object")
927
1033
  throw new Error("public session response is invalid");
@@ -931,11 +1037,11 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
931
1037
  userId: c.userId,
932
1038
  userToken: c.userToken
933
1039
  };
934
- }, Co = (e) => ({
1040
+ }, $o = (e) => ({
935
1041
  ...typeof e.name == "string" && e.name.trim() ? { name: e.name.trim() } : {},
936
1042
  ...typeof e.pictureUrl == "string" && e.pictureUrl.trim() ? { pictureUrl: e.pictureUrl.trim() } : {},
937
1043
  userData: e
938
- }), Bo = ({
1044
+ }), Lo = ({
939
1045
  showWelcomeScreen: e,
940
1046
  storageKey: t,
941
1047
  storageLocation: a,
@@ -943,17 +1049,48 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
943
1049
  userToken: s
944
1050
  }) => {
945
1051
  if (!e)
946
- return { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" };
1052
+ return {
1053
+ activeView: "chat",
1054
+ historyReturnView: "chat",
1055
+ bootstrapView: "chat"
1056
+ };
947
1057
  if (r && s)
948
- return { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" };
949
- const n = je({ storageKey: t, storageLocation: a });
1058
+ return {
1059
+ activeView: "chat",
1060
+ historyReturnView: "chat",
1061
+ bootstrapView: "chat"
1062
+ };
1063
+ const n = Ke({
1064
+ storageKey: t,
1065
+ storageLocation: a
1066
+ });
950
1067
  if (n == null)
951
- return { activeView: "home", historyReturnView: "home", bootstrapView: "home" };
1068
+ return {
1069
+ activeView: "home",
1070
+ historyReturnView: "home",
1071
+ bootstrapView: "home"
1072
+ };
952
1073
  if (n === void 0)
953
- return { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
1074
+ return {
1075
+ activeView: "pending",
1076
+ historyReturnView: "home",
1077
+ bootstrapView: "pending"
1078
+ };
954
1079
  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) => {
1080
+ return c && i ? {
1081
+ activeView: "chat",
1082
+ historyReturnView: "chat",
1083
+ bootstrapView: "chat"
1084
+ } : !c && !i ? {
1085
+ activeView: "home",
1086
+ historyReturnView: "home",
1087
+ bootstrapView: "home"
1088
+ } : {
1089
+ activeView: "pending",
1090
+ historyReturnView: "home",
1091
+ bootstrapView: "pending"
1092
+ };
1093
+ }, _o = (e, t) => {
957
1094
  switch (t.type) {
958
1095
  case "show":
959
1096
  return { isPanelMounted: !0, isPanelVisible: e.isPanelVisible };
@@ -967,7 +1104,7 @@ const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
967
1104
  return e;
968
1105
  }
969
1106
  };
970
- function So({
1107
+ function jo({
971
1108
  clientId: e,
972
1109
  webchatProxyUrl: t,
973
1110
  userCredentials: a,
@@ -977,204 +1114,240 @@ function So({
977
1114
  presetSlug: c,
978
1115
  storageKey: i = fe,
979
1116
  storageLocation: u = "localStorage",
980
- defaultOpen: m,
981
- onUserApiChange: w,
1117
+ defaultOpen: w,
1118
+ onUserApiChange: m,
982
1119
  getSession: b,
983
- sessionKey: P,
984
- onSessionChange: h
1120
+ sessionKey: U,
1121
+ onSessionChange: f
985
1122
  }) {
986
- const { session: x, resolving: z } = oo({
1123
+ const { session: B, resolving: F } = yo({
987
1124
  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(
1125
+ sessionKey: U,
1126
+ onSessionChange: f
1127
+ }), Q = !!B && Date.now() < B.expiresAt, _ = Q ? { userId: B.userId, userToken: B.userToken } : void 0, V = b ? _ : a, W = Q ? B.conversationId : void 0, G = k(
991
1128
  () => typeof c == "string" && c.trim() ? c.trim() : void 0,
992
1129
  [c]
993
- ), N = y(
994
- () => typeof t == "string" && t.trim() ? qe(t.trim()) : void 0,
1130
+ ), N = k(
1131
+ () => typeof t == "string" && t.trim() ? We(t.trim()) : void 0,
995
1132
  [t]
996
1133
  );
997
- y(
998
- () => N ? Ie({ webchatProxyUrl: N }) : null,
1134
+ k(
1135
+ () => N ? Se({ webchatProxyUrl: N }) : null,
999
1136
  [N]
1000
1137
  );
1001
- const O = !!(e && N && (oe || !q)), T = y(
1002
- () => O ? mo({
1138
+ const d = !!(e && N && (G || !V)), p = k(
1139
+ () => d ? Uo({
1003
1140
  webchatProxyUrl: N,
1004
1141
  clientId: e,
1005
- presetSlug: oe
1142
+ presetSlug: G
1006
1143
  }) : null,
1007
- [e, oe, N, O]
1008
- ), [D, K] = R({
1144
+ [
1145
+ e,
1146
+ G,
1147
+ N,
1148
+ d
1149
+ ]
1150
+ ), [R, ee] = S({
1009
1151
  error: null,
1010
1152
  isLoading: !1,
1011
1153
  payload: null,
1012
1154
  url: null
1013
1155
  });
1014
1156
  M(() => {
1015
- if (!T) {
1016
- K({ error: null, isLoading: !1, payload: null, url: null });
1157
+ if (!p) {
1158
+ ee({
1159
+ error: null,
1160
+ isLoading: !1,
1161
+ payload: null,
1162
+ url: null
1163
+ });
1017
1164
  return;
1018
1165
  }
1019
- const v = new AbortController();
1020
- return K({ error: null, isLoading: !0, payload: null, url: T }), fetch(T, {
1166
+ const I = new AbortController();
1167
+ return ee({
1168
+ error: null,
1169
+ isLoading: !0,
1170
+ payload: null,
1171
+ url: p
1172
+ }), fetch(p, {
1021
1173
  headers: {
1022
1174
  accept: "application/json"
1023
1175
  },
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)
1176
+ signal: I.signal
1177
+ }).then(async (v) => {
1178
+ if (!v.ok)
1179
+ throw new Error(
1180
+ `bootstrap request failed with status ${v.status}`
1181
+ );
1182
+ return v.json();
1183
+ }).then((v) => {
1184
+ const H = Vo(v);
1185
+ if (!H)
1032
1186
  throw new Error("bootstrap response is invalid");
1033
- K({
1187
+ ee({
1034
1188
  error: null,
1035
1189
  isLoading: !1,
1036
- payload: U,
1037
- url: T
1190
+ payload: H,
1191
+ url: p
1038
1192
  });
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(
1193
+ }).catch((v) => {
1194
+ I.signal.aborted || (console.warn("[EduzzWebchat] failed to load bootstrap", v), ee({
1195
+ error: v,
1196
+ isLoading: !1,
1197
+ payload: null,
1198
+ url: p
1199
+ }));
1200
+ }), () => I.abort();
1201
+ }, [p]);
1202
+ const y = p && R.url === p ? R.payload : null, de = p && R.url === p ? R.error : null, T = y?.clientId || e, P = N || y?.webchatProxyUrl || void 0, z = i === fe && y?.storageKey ? y.storageKey : i, K = typeof w == "boolean" ? w : typeof y?.defaultOpen == "boolean" ? y.defaultOpen : w, D = k(
1044
1203
  () => ({
1045
- ...Q(f?.config) || {},
1046
- ...Q(s) || {}
1204
+ ...re(y?.config) || {},
1205
+ ...re(s) || {}
1047
1206
  }),
1048
- [f, s]
1049
- ), ge = y(
1050
- () => {
1051
- const v = {
1052
- ...Q(f?.defaultUserData) || {},
1053
- ...Q(n) || {}
1054
- };
1055
- return Object.keys(v).length > 0 ? v : null;
1056
- },
1057
- [n, f]
1058
- ), $ = !!(!q && !z && f?.sessionMode === "service-hub" && A && k), [ae, J] = R({
1207
+ [y, s]
1208
+ ), ge = k(() => {
1209
+ const I = {
1210
+ ...re(y?.defaultUserData) || {},
1211
+ ...re(n) || {}
1212
+ };
1213
+ return Object.keys(I).length > 0 ? I : null;
1214
+ }, [n, y]), E = !!(!V && !F && y?.sessionMode === "service-hub" && P && T), [se, te] = S({
1059
1215
  error: null,
1060
1216
  isLoading: !1,
1061
1217
  payload: null,
1062
1218
  key: null
1063
1219
  });
1064
1220
  M(() => {
1065
- if (!$) {
1066
- J({ error: null, isLoading: !1, payload: null, key: null });
1221
+ if (!E) {
1222
+ te({
1223
+ error: null,
1224
+ isLoading: !1,
1225
+ payload: null,
1226
+ key: null
1227
+ });
1067
1228
  return;
1068
1229
  }
1069
- const v = yo({
1070
- storageKey: H,
1230
+ const I = Po({
1231
+ storageKey: z,
1071
1232
  storageLocation: u
1072
- }), g = `${k}:${A}:${v}`;
1073
- let U = !1;
1074
- return J({
1233
+ }), v = `${T}:${P}:${I}`;
1234
+ let H = !1;
1235
+ return te({
1075
1236
  error: null,
1076
1237
  isLoading: !0,
1077
1238
  payload: null,
1078
- key: g
1079
- }), vo({
1080
- webchatProxyUrl: A,
1081
- clientId: k,
1082
- accountId: v
1083
- }).then((p) => {
1084
- U || J({
1239
+ key: v
1240
+ }), Ho({
1241
+ webchatProxyUrl: P,
1242
+ clientId: T,
1243
+ accountId: I
1244
+ }).then((C) => {
1245
+ H || te({
1085
1246
  error: null,
1086
1247
  isLoading: !1,
1087
- payload: p,
1088
- key: g
1248
+ payload: C,
1249
+ key: v
1089
1250
  });
1090
- }).catch((p) => {
1091
- U || (console.warn("[EduzzWebchat] failed to open public session", p), J({
1092
- error: p,
1251
+ }).catch((C) => {
1252
+ H || (console.warn("[EduzzWebchat] failed to open public session", C), te({
1253
+ error: C,
1093
1254
  isLoading: !1,
1094
1255
  payload: null,
1095
- key: g
1256
+ key: v
1096
1257
  }));
1097
1258
  }), () => {
1098
- U = !0;
1259
+ H = !0;
1099
1260
  };
1100
1261
  }, [
1101
- k,
1102
- H,
1103
- A,
1104
- $,
1262
+ T,
1263
+ z,
1264
+ P,
1265
+ E,
1105
1266
  u
1106
1267
  ]);
1107
- const E = $ ? ae.payload : null, X = q || E, _ = y(() => lt(I), [I]), Z = y(
1108
- () => te || r || fo({
1109
- storageKey: H,
1268
+ const J = E ? se.payload : null, oe = V || J, O = k(
1269
+ () => Ct(D),
1270
+ [D]
1271
+ ), ae = k(
1272
+ () => W || r || Do({
1273
+ storageKey: z,
1110
1274
  storageLocation: u
1111
1275
  }),
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), []);
1276
+ [
1277
+ W,
1278
+ r,
1279
+ z,
1280
+ u
1281
+ ]
1282
+ ), $ = K ?? O.initiallyOpen ?? !0, [ye, X] = S($), ce = Y($), [q, ne] = S(
1283
+ xe
1284
+ ), ve = le(() => X((I) => !I), []);
1114
1285
  M(() => {
1115
- ne.current !== V && (ne.current = V, W(V));
1116
- }, [V]);
1117
- const de = O && !f && !ie, Ce = $ && !E && !ae.error;
1286
+ ce.current !== $ && (ce.current = $, X($));
1287
+ }, [$]);
1288
+ const ue = d && !y && !de, Ce = E && !J && !se.error;
1118
1289
  return M(() => {
1119
- const v = ho({
1120
- webchatProxyUrl: A,
1121
- clientId: k
1290
+ const I = Ao({
1291
+ webchatProxyUrl: P,
1292
+ clientId: T
1122
1293
  });
1123
- if (Y(Be), !v)
1294
+ if (ne(xe), !I)
1124
1295
  return;
1125
- const g = new AbortController();
1126
- let U = !1;
1127
- return fetch(v, {
1296
+ const v = new AbortController();
1297
+ let H = !1;
1298
+ return fetch(I, {
1128
1299
  headers: {
1129
1300
  accept: "application/json"
1130
1301
  },
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)
1302
+ signal: v.signal
1303
+ }).then(async (C) => {
1304
+ if (!C.ok)
1305
+ throw new Error(
1306
+ `runtime config request failed with status ${C.status}`
1307
+ );
1308
+ return C.json();
1309
+ }).then((C) => {
1310
+ if (H)
1138
1311
  return;
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
1312
+ const h = C && typeof C == "object" && C.data && typeof C.data == "object" ? C.data : {};
1313
+ ne({
1314
+ allowFileUpload: h.allowFileUpload === !0,
1315
+ allowMessageFeedback: h.allowMessageFeedback === !0
1143
1316
  });
1144
- }).catch((p) => {
1145
- g.signal.aborted || U || (console.warn("[EduzzWebchat] failed to load runtime config", p), Y(Be));
1317
+ }).catch((C) => {
1318
+ v.signal.aborted || H || (console.warn("[EduzzWebchat] failed to load runtime config", C), ne(xe));
1146
1319
  }), () => {
1147
- U = !0, g.abort();
1320
+ H = !0, v.abort();
1148
1321
  };
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,
1322
+ }, [T, P]), ue || Ce || b && F ? null : de && !y ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel carregar a configuracao publica do webchat." }) }) : se.error && !J ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel abrir a sessao publica do webchat." }) }) : P ? T ? /* @__PURE__ */ o(
1323
+ dt,
1151
1324
  {
1152
- clientId: k,
1153
- apiUrl: A,
1154
- conversationId: Z,
1155
- userCredentials: X,
1156
- storageKey: H,
1325
+ clientId: T,
1326
+ apiUrl: P,
1327
+ conversationId: ae,
1328
+ userCredentials: oe,
1329
+ storageKey: z,
1157
1330
  storageLocation: u,
1158
1331
  children: /* @__PURE__ */ o(
1159
- xo,
1332
+ zo,
1160
1333
  {
1161
- clientId: k,
1162
- config: _,
1334
+ clientId: T,
1335
+ config: O,
1163
1336
  defaultUserData: ge,
1164
- conversationIdProp: Z,
1337
+ conversationIdProp: ae,
1165
1338
  isOpen: ye,
1166
- onUserApiChange: w,
1339
+ onUserApiChange: m,
1167
1340
  onToggle: ve,
1168
- runtimeCapabilities: L,
1169
- storageKey: H,
1341
+ runtimeCapabilities: q,
1342
+ storageKey: z,
1170
1343
  storageLocation: u,
1171
- userToken: X?.userToken
1344
+ userToken: oe?.userToken
1172
1345
  }
1173
1346
  )
1174
1347
  }
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." }) });
1348
+ ) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhum clientId foi informado." }) }) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhuma URL publica do proxy do webchat foi informada." }) });
1176
1349
  }
1177
- function xo({
1350
+ function zo({
1178
1351
  clientId: e,
1179
1352
  config: t,
1180
1353
  defaultUserData: a,
@@ -1184,165 +1357,233 @@ function xo({
1184
1357
  onToggle: c,
1185
1358
  runtimeCapabilities: i,
1186
1359
  storageKey: u,
1187
- storageLocation: m,
1188
- userToken: w
1360
+ storageLocation: w,
1361
+ userToken: m
1189
1362
  }) {
1190
- const b = y(
1191
- () => Bo({
1363
+ const b = k(
1364
+ () => Lo({
1192
1365
  showWelcomeScreen: t.showWelcomeScreen,
1193
1366
  storageKey: u,
1194
- storageLocation: m,
1367
+ storageLocation: w,
1195
1368
  conversationId: r,
1196
- userToken: w
1369
+ userToken: m
1197
1370
  }),
1198
1371
  [
1199
1372
  t.showWelcomeScreen,
1200
1373
  r,
1201
1374
  u,
1202
- m,
1203
- w
1375
+ w,
1376
+ m
1204
1377
  ]
1205
- ), [P, h] = R(!1), [x, z] = R({ open: !1, messageId: null, draft: "" }), [{ isPanelMounted: ee, isPanelVisible: le }, q] = We(ko, {
1206
- isPanelMounted: s,
1207
- isPanelVisible: s
1208
- }), {
1209
- conversationId: te,
1210
- isTyping: oe,
1378
+ ), [U, f] = S(!1), [B, F] = S({
1379
+ open: !1,
1380
+ messageId: null,
1381
+ draft: ""
1382
+ }), [{ isPanelMounted: Q, isPanelVisible: _ }, V] = st(
1383
+ _o,
1384
+ {
1385
+ isPanelMounted: s,
1386
+ isPanelVisible: s
1387
+ }
1388
+ ), {
1389
+ conversationId: W,
1390
+ isTyping: G,
1211
1391
  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,
1392
+ saveMessageFeedback: d,
1393
+ sendMessage: p,
1394
+ status: R,
1395
+ uploadFile: ee
1396
+ } = ut(), { openConversation: y, listConversations: de } = bt(), { updateUser: T, userCredentials: P } = ht(), z = Y({}), [K, D] = S(
1397
+ () => b.activeView
1398
+ ), [ge, E] = S(
1399
+ () => b.historyReturnView
1400
+ ), {
1401
+ conversations: se,
1402
+ isLoading: te,
1403
+ refresh: J
1404
+ } = pt({
1405
+ userCredentials: P,
1406
+ listConversations: de,
1219
1407
  clientId: e
1220
- }), X = y(
1221
- () => wo(a),
1408
+ }), oe = k(
1409
+ () => Ro(a),
1222
1410
  [a]
1223
- ), _ = re(
1224
- async (C = {}) => {
1225
- if (!k)
1411
+ ), O = le(
1412
+ async (h = {}) => {
1413
+ if (!T)
1226
1414
  return;
1227
- const d = {
1228
- ...Q(a) || {},
1229
- ...H.current,
1230
- ...Q(C) || {}
1415
+ const j = {
1416
+ ...re(a) || {},
1417
+ ...z.current,
1418
+ ...re(h) || {}
1231
1419
  };
1232
- return H.current = d, k(Co(d));
1420
+ return z.current = j, T($o(j));
1233
1421
  },
1234
- [a, k]
1235
- ), Z = ce(_);
1422
+ [a, T]
1423
+ ), ae = Y(O);
1236
1424
  M(() => {
1237
- Z.current = _;
1238
- }, [_]);
1239
- const V = !!k;
1425
+ ae.current = O;
1426
+ }, [O]);
1427
+ const $ = !!T;
1240
1428
  M(() => {
1241
- H.current = {};
1242
- }, [X]), M(() => {
1429
+ z.current = {};
1430
+ }, [oe]), M(() => {
1243
1431
  if (n)
1244
1432
  return n({
1245
- updateUserData: V ? (C) => Z.current(C) : void 0
1433
+ updateUserData: $ ? (h) => ae.current(h) : void 0
1246
1434
  }), () => n(null);
1247
- }, [n, V]), M(() => {
1248
- !V || !X || Z.current();
1249
- }, [X, V]), M(() => {
1250
- i.allowMessageFeedback || z({ open: !1, messageId: null, draft: "" });
1435
+ }, [n, $]), M(() => {
1436
+ !$ || !oe || ae.current();
1437
+ }, [oe, $]), M(() => {
1438
+ i.allowMessageFeedback || F({ open: !1, messageId: null, draft: "" });
1251
1439
  }, [i.allowMessageFeedback]);
1252
- const { showInitialLoading: ye, setShowInitialLoading: W } = eo({
1253
- activeView: j,
1254
- clientState: D,
1255
- conversationId: te,
1440
+ const { showInitialLoading: ye, setShowInitialLoading: X } = fo({
1441
+ activeView: K,
1442
+ clientState: R,
1443
+ conversationId: W,
1256
1444
  messagesLength: N.length
1257
- }), ne = y(
1258
- () => t.botAvatar || Jt({ name: t.botName, backgroundColor: t.accentColor }),
1445
+ }), ce = k(
1446
+ () => t.botAvatar || bo({
1447
+ name: t.botName,
1448
+ backgroundColor: t.accentColor
1449
+ }),
1259
1450
  [t.accentColor, t.botAvatar, t.botName]
1260
- ), L = y(
1261
- () => ({ ...t, botAvatar: ne }),
1262
- [t, ne]
1263
- ), Y = re(
1264
- async (C) => {
1265
- $(C), I("conversations"), await E();
1451
+ ), q = k(
1452
+ () => ({ ...t, botAvatar: ce }),
1453
+ [t, ce]
1454
+ ), ne = le(
1455
+ async (h) => {
1456
+ E(h), D("conversations"), await J();
1266
1457
  },
1267
- [E]
1268
- ), ve = re(
1269
- (C) => {
1270
- W(!0), f(C), I("chat");
1458
+ [J]
1459
+ ), ve = le(
1460
+ (h) => {
1461
+ X(!0), y(h), D("chat");
1271
1462
  },
1272
- [f, W]
1273
- ), de = re(() => {
1274
- W(!0), f(), I("chat");
1275
- }, [f, W]), Ce = y(
1276
- () => Qt({
1463
+ [y, X]
1464
+ ), ue = le(() => {
1465
+ X(!0), y(), D("chat");
1466
+ }, [y, X]), Ce = k(
1467
+ () => wo({
1277
1468
  messages: N,
1278
- user: A,
1279
- botName: L.botName,
1280
- botAvatar: L.botAvatar
1469
+ user: P,
1470
+ botName: q.botName,
1471
+ botAvatar: q.botAvatar
1281
1472
  }),
1282
- [N, L.botAvatar, L.botName, A]
1283
- ), v = se(t), g = y(() => it(t), [t]), U = y(() => zt(t.fabChatIconVariant), [t.fabChatIconVariant]);
1473
+ [N, q.botAvatar, q.botName, P]
1474
+ ), I = ie(t), v = k(() => Bt(t), [t]), H = k(
1475
+ () => to(t.fabChatIconVariant),
1476
+ [t.fabChatIconVariant]
1477
+ );
1284
1478
  M(() => {
1285
1479
  if (s) {
1286
- q({ type: "show" });
1287
- const be = window.requestAnimationFrame(() => q({ type: "visible" }));
1480
+ V({ type: "show" });
1481
+ const be = window.requestAnimationFrame(
1482
+ () => V({ type: "visible" })
1483
+ );
1288
1484
  return () => window.cancelAnimationFrame(be);
1289
1485
  }
1290
- q({ type: "hide" });
1291
- const C = window.setTimeout(() => {
1292
- h(!1), z({ open: !1, messageId: null, draft: "" });
1293
- }, 0), d = window.setTimeout(() => q({ type: "unmount" }), io);
1486
+ V({ type: "hide" });
1487
+ const h = window.setTimeout(() => {
1488
+ f(!1), F({ open: !1, messageId: null, draft: "" });
1489
+ }, 0), j = window.setTimeout(
1490
+ () => V({ type: "unmount" }),
1491
+ Mo
1492
+ );
1294
1493
  return () => {
1295
- window.clearTimeout(C), window.clearTimeout(d);
1494
+ window.clearTimeout(h), window.clearTimeout(j);
1296
1495
  };
1297
1496
  }, [s]), M(() => {
1298
1497
  if (b.bootstrapView === "pending") {
1299
1498
  if (N.length > 0) {
1300
- const C = window.setTimeout(() => {
1301
- I("chat"), $("chat");
1499
+ const h = window.setTimeout(() => {
1500
+ D("chat"), E("chat");
1302
1501
  }, 0);
1303
- return () => window.clearTimeout(C);
1502
+ return () => window.clearTimeout(h);
1304
1503
  }
1305
- if (D !== "connecting") {
1306
- const C = window.setTimeout(() => {
1307
- I("home"), $("home");
1504
+ if (R !== "connecting") {
1505
+ const h = window.setTimeout(() => {
1506
+ D("home"), E("home");
1308
1507
  }, 0);
1309
- return () => window.clearTimeout(C);
1508
+ return () => window.clearTimeout(h);
1310
1509
  }
1311
1510
  }
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
1511
+ }, [R, b.bootstrapView, N.length]);
1512
+ const C = k(() => {
1513
+ const h = {};
1514
+ h.dropdown = ko;
1515
+ const j = (be, g) => function({
1516
+ blocks: ke,
1517
+ horizontalAlignment: Je,
1518
+ verticalAlignment: Xe,
1519
+ direction: Ze,
1520
+ sender: Ye,
1521
+ timestamp: Qe,
1522
+ metadata: et,
1523
+ messageId: tt,
1524
+ isReadOnly: ot,
1525
+ sendMessage: at
1526
+ }) {
1527
+ return /* @__PURE__ */ o(
1528
+ "div",
1529
+ {
1530
+ className: be,
1531
+ "data-horizontal": Je,
1532
+ "data-vertical": Xe,
1533
+ children: ke.map((nt, rt) => /* @__PURE__ */ o(
1534
+ Te,
1535
+ {
1536
+ block: {
1537
+ ...nt,
1538
+ direction: Ze,
1539
+ timestamp: Qe,
1540
+ sender: Ye,
1541
+ messageId: tt,
1542
+ isReadOnly: ot,
1543
+ sendMessage: at,
1544
+ ...g ? { metadata: et } : {}
1545
+ },
1546
+ renderers: h
1547
+ },
1548
+ rt
1549
+ ))
1550
+ }
1551
+ );
1552
+ };
1553
+ return h.column = j("bpMessageBlocksColumn", !1), h.row = j("bpMessageBlocksRow", !0), h.bubble = function(g) {
1554
+ const Be = i.allowMessageFeedback && g.direction === "incoming" && typeof g.addMessageFeedback == "function", ke = {
1555
+ ...g.block,
1556
+ direction: g.direction,
1557
+ sender: g.sender,
1558
+ timestamp: g.timestamp,
1559
+ messageId: g.messageId,
1560
+ metadata: g.metadata,
1561
+ isReadOnly: g.isReadOnly,
1562
+ status: g.status,
1563
+ feedback: g.feedback,
1564
+ sendMessage: g.sendMessage,
1565
+ addMessageFeedback: g.addMessageFeedback
1327
1566
  };
1328
1567
  return /* @__PURE__ */ l(
1329
1568
  "div",
1330
1569
  {
1331
1570
  className: "bpMessageBlocksBubble",
1332
- "data-direction": d.direction,
1333
- "data-feedback": be || void 0,
1571
+ "data-direction": g.direction,
1572
+ "data-feedback": Be || void 0,
1334
1573
  children: [
1335
- /* @__PURE__ */ o(tt, { block: Ee }),
1336
- be ? /* @__PURE__ */ l("div", { className: "bpMessageBlocksBubbleFeedbackContainer", children: [
1574
+ /* @__PURE__ */ o(Te, { block: ke, renderers: h }),
1575
+ Be ? /* @__PURE__ */ l("div", { className: "bpMessageBlocksBubbleFeedbackContainer", children: [
1337
1576
  /* @__PURE__ */ o(
1338
1577
  "button",
1339
1578
  {
1340
1579
  className: "bpMessageBlocksBubbleFeedbackIcon",
1341
1580
  type: "button",
1342
- "data-selected": d.feedback === "positive",
1581
+ "data-selected": g.feedback === "positive",
1343
1582
  "aria-label": "Feedback positivo",
1344
- onClick: () => d.addMessageFeedback(d.messageId, { value: "positive" }),
1345
- children: Ot
1583
+ onClick: () => g.addMessageFeedback(g.messageId, {
1584
+ value: "positive"
1585
+ }),
1586
+ children: no
1346
1587
  }
1347
1588
  ),
1348
1589
  /* @__PURE__ */ o(
@@ -1350,107 +1591,121 @@ function xo({
1350
1591
  {
1351
1592
  className: "bpMessageBlocksBubbleFeedbackIcon",
1352
1593
  type: "button",
1353
- "data-selected": d.feedback === "negative",
1594
+ "data-selected": g.feedback === "negative",
1354
1595
  "aria-label": "Feedback negativo",
1355
- onClick: () => z({
1596
+ onClick: () => F({
1356
1597
  open: !0,
1357
- messageId: d.messageId,
1598
+ messageId: g.messageId,
1358
1599
  draft: ""
1359
1600
  }),
1360
- children: jt
1601
+ children: ro
1361
1602
  }
1362
1603
  )
1363
1604
  ] }) : null
1364
1605
  ]
1365
1606
  }
1366
1607
  );
1367
- },
1368
- [i.allowMessageFeedback]
1369
- ), ue = y(() => ({ bubble: p }), [p]);
1608
+ }, h;
1609
+ }, [i.allowMessageFeedback]);
1370
1610
  return /* @__PURE__ */ l(
1371
1611
  "div",
1372
1612
  {
1373
1613
  className: "bp-webchat-shell",
1374
- "data-panel-mounted": ee,
1375
- "data-panel-open": le,
1376
- style: v,
1614
+ "data-panel-mounted": Q,
1615
+ "data-panel-open": _,
1616
+ style: I,
1377
1617
  children: [
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,
1381
- {
1382
- config: L,
1383
- activeView: j,
1384
- onClose: c,
1385
- onShowHome: () => I("home"),
1386
- onShowConversations: () => Y("home"),
1387
- onStart: () => I("chat")
1388
- }
1389
- ) : j === "conversations" ? /* @__PURE__ */ o(
1390
- ro,
1618
+ /* @__PURE__ */ o(mt, { ...v }),
1619
+ Q ? /* @__PURE__ */ o(
1620
+ "div",
1391
1621
  {
1392
- conversations: ae,
1393
- currentConversationId: te,
1394
- isLoading: J,
1395
- botAvatar: L.botAvatar,
1396
- botName: L.botName,
1397
- onClose: () => I(ge),
1398
- onCloseWidget: c,
1399
- onShowHome: () => {
1400
- I("home"), $("home");
1401
- },
1402
- onShowConversations: E,
1403
- onNewConversation: de,
1404
- onConversationClick: ve
1405
- }
1406
- ) : j === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(ze, {}) }) : /* @__PURE__ */ l(Ue, { children: [
1407
- /* @__PURE__ */ o(
1408
- no,
1409
- {
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,
1420
- onShowHome: t.showWelcomeScreen ? () => {
1421
- I("home"), $("home");
1422
- } : void 0,
1423
- onOpenHistory: () => Y("chat"),
1424
- onRestartConversation: () => h(!0),
1425
- onCloseWidget: c
1426
- }
1427
- ),
1428
- /* @__PURE__ */ o(
1429
- co,
1430
- {
1431
- open: P,
1432
- onCancel: () => h(!1),
1433
- onConfirm: () => {
1434
- h(!1), de();
1622
+ className: "bp-webchat-panel",
1623
+ "data-state": _ ? "open" : "closed",
1624
+ children: K === "home" ? /* @__PURE__ */ o(
1625
+ Io,
1626
+ {
1627
+ config: q,
1628
+ activeView: K,
1629
+ onClose: c,
1630
+ onShowHome: () => D("home"),
1631
+ onShowConversations: () => ne("home"),
1632
+ onStart: () => D("chat")
1435
1633
  }
1436
- }
1437
- ),
1438
- i.allowMessageFeedback ? /* @__PURE__ */ o(
1439
- so,
1440
- {
1441
- open: x.open,
1442
- draft: x.draft,
1443
- setDraft: (C) => z((d) => ({ ...d, draft: C })),
1444
- onCancel: () => z({ open: !1, messageId: null, draft: "" }),
1445
- onConfirm: async () => {
1446
- x.messageId && O && await O(x.messageId, {
1447
- value: "negative",
1448
- comment: x.draft
1449
- }), z({ open: !1, messageId: null, draft: "" });
1634
+ ) : K === "conversations" ? /* @__PURE__ */ o(
1635
+ Bo,
1636
+ {
1637
+ conversations: se,
1638
+ currentConversationId: W,
1639
+ isLoading: te,
1640
+ botAvatar: q.botAvatar,
1641
+ botName: q.botName,
1642
+ onClose: () => D(ge),
1643
+ onCloseWidget: c,
1644
+ onShowHome: () => {
1645
+ D("home"), E("home");
1646
+ },
1647
+ onShowConversations: J,
1648
+ onNewConversation: ue,
1649
+ onConversationClick: ve
1450
1650
  }
1451
- }
1452
- ) : null
1453
- ] }) }) : null,
1651
+ ) : K === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(qe, {}) }) : /* @__PURE__ */ l(Fe, { children: [
1652
+ /* @__PURE__ */ o(
1653
+ Co,
1654
+ {
1655
+ config: q,
1656
+ allowFileUpload: i.allowFileUpload,
1657
+ clientState: R,
1658
+ isTyping: G,
1659
+ messages: Ce,
1660
+ renderers: C,
1661
+ sendMessage: p,
1662
+ uploadFile: ee,
1663
+ addMessageFeedback: i.allowMessageFeedback ? d : void 0,
1664
+ showInitialLoading: ye,
1665
+ onShowHome: t.showWelcomeScreen ? () => {
1666
+ D("home"), E("home");
1667
+ } : void 0,
1668
+ onOpenHistory: () => ne("chat"),
1669
+ onRestartConversation: () => f(!0),
1670
+ onCloseWidget: c
1671
+ }
1672
+ ),
1673
+ /* @__PURE__ */ o(
1674
+ No,
1675
+ {
1676
+ open: U,
1677
+ onCancel: () => f(!1),
1678
+ onConfirm: () => {
1679
+ f(!1), ue();
1680
+ }
1681
+ }
1682
+ ),
1683
+ i.allowMessageFeedback ? /* @__PURE__ */ o(
1684
+ xo,
1685
+ {
1686
+ open: B.open,
1687
+ draft: B.draft,
1688
+ setDraft: (h) => F((j) => ({ ...j, draft: h })),
1689
+ onCancel: () => F({
1690
+ open: !1,
1691
+ messageId: null,
1692
+ draft: ""
1693
+ }),
1694
+ onConfirm: async () => {
1695
+ B.messageId && d && await d(B.messageId, {
1696
+ value: "negative",
1697
+ comment: B.draft
1698
+ }), F({
1699
+ open: !1,
1700
+ messageId: null,
1701
+ draft: ""
1702
+ });
1703
+ }
1704
+ }
1705
+ ) : null
1706
+ ] })
1707
+ }
1708
+ ) : null,
1454
1709
  /* @__PURE__ */ l(
1455
1710
  "button",
1456
1711
  {
@@ -1460,8 +1715,8 @@ function xo({
1460
1715
  type: "button",
1461
1716
  "aria-label": s ? "Fechar webchat" : "Abrir webchat",
1462
1717
  children: [
1463
- /* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--chat", children: U }),
1464
- /* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--close", children: Lt })
1718
+ /* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--chat", children: H }),
1719
+ /* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--close", children: eo })
1465
1720
  ]
1466
1721
  }
1467
1722
  )
@@ -1470,9 +1725,9 @@ function xo({
1470
1725
  );
1471
1726
  }
1472
1727
  export {
1473
- So as Webchat,
1474
- G as defaultConfig,
1475
- pe as getContrastingTextColor,
1476
- se as getShellStyle,
1477
- lt as normalizeConfig
1728
+ jo as Webchat,
1729
+ Z as defaultConfig,
1730
+ me as getContrastingTextColor,
1731
+ ie as getShellStyle,
1732
+ Ct as normalizeConfig
1478
1733
  };