@eduzz-automacoes/webchat-widget 0.2.0 → 0.2.1

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