@eduzz-automacoes/webchat-widget 0.1.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 Ne } from "react/jsx-runtime";
2
- import { forwardRef as Ie, createElement as he, useState as R, useEffect as A, useMemo as f, useRef as me, useCallback as ee, useReducer as We } from "react";
3
- import { Container as Ge, MessageList as Ke, Composer as Je, WebchatProvider as Ze, useActiveConversation as Xe, useConversations as Ye, useUser as Qe, useConversationList as et, Block as tt, StylesheetProvider as ot } from "@botpress/webchat";
4
- import './style.css';const j = {
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 j = {
64
64
  welcomeCloseLabel: "Fechar painel",
65
65
  openFabBackgroundColor: "#2563eb",
66
66
  openFabIconColor: "#ffffff"
67
- }, Me = (e) => e === "bottom-left" || e === "top-left" ? "bottom-left" : "bottom-right", at = (e) => {
68
- switch (Me(e)) {
67
+ }, 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,12 +82,12 @@ import './style.css';const j = {
82
82
  "--panel-transform-origin": "right bottom"
83
83
  };
84
84
  }
85
- }, Se = (e, t, a) => Math.min(Math.max(e, t), a), pe = (e) => {
85
+ }, 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()}`;
89
- }, we = (e) => {
90
- const t = pe(e);
89
+ }, Ne = (e) => {
90
+ const t = xe(e);
91
91
  if (!t) return null;
92
92
  const a = t.slice(1);
93
93
  return {
@@ -95,19 +95,19 @@ import './style.css';const j = {
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) => Se(Math.round(r), 0, 255).toString(16).padStart(2, "0")
100
- ).join("")}`, se = (e, t, a) => {
101
- const r = we(e), s = we(t);
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
+ const r = Ne(e), s = Ne(t);
102
102
  if (!r || !s) return null;
103
- const n = Se(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 ? se(e, "#000000", Math.abs(t)) : se(e, "#ffffff", t), ce = (e) => {
110
- const t = we(e);
109
+ }, st = (e, t) => t < 0 ? pe(e, "#000000", Math.abs(t)) : pe(e, "#ffffff", t), me = (e) => {
110
+ const t = Ne(e);
111
111
  return t && [t.r, t.g, t.b].map((r) => {
112
112
  const s = r / 255;
113
113
  return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
@@ -115,43 +115,43 @@ import './style.css';const j = {
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 = pe(e.brandColor);
118
+ }, L = (e, t) => e && Object.prototype.hasOwnProperty.call(e, t) && e[t] != null && e[t] !== "", ct = (e, t) => {
119
+ const a = xe(e.brandColor);
120
120
  if (!a) return e;
121
- const r = pe(e.brandTextColor) || ce(a), s = se(a, "#ffffff", 0.82) || j.secondaryButtonBorderColor, n = se(a, "#ffffff", 0.92) || j.secondaryButtonHoverBackgroundColor, c = rt(a, -0.12) || j.primaryButtonHoverBackgroundColor;
121
+ const r = xe(e.brandTextColor) || 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 || j.fabBackgroundColor, a = e.fabIconColor || e.openFabIconColor || j.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 j = {
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
- ...j,
165
+ ...X,
166
166
  ...e,
167
- position: Me(e.position ?? j.position)
167
+ position: De(e.position ?? X.position)
168
168
  },
169
169
  e
170
170
  )
171
- ), te = (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 j = {
185
185
  "--bpGray-900": "var(--ui-text)",
186
186
  "--bpGray-950": "var(--ui-text)",
187
187
  "--accent-color": e.accentColor,
188
- "--accent-text-color": ce(e.accentColor),
188
+ "--accent-text-color": me(e.accentColor),
189
189
  "--header-avatar-bg": e.accentColor,
190
- "--header-avatar-text": ce(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 j = {
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 j = {
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
- ), ve = (e) => {
245
- const t = ut(e);
244
+ ), Me = (e) => {
245
+ const t = bt(e);
246
246
  return t.charAt(0).toUpperCase() + t.slice(1);
247
- }, Te = (...e) => e.filter((t, a, r) => !!t && t.trim() !== "" && r.indexOf(t) === a).join(" ").trim(), bt = (e) => {
247
+ }, Pe = (...e) => e.filter((t, a, r) => !!t && t.trim() !== "" && r.indexOf(t) === a).join(" ").trim(), 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 = Ie(
263
+ const mt = Re(
264
264
  ({
265
265
  color: e = "currentColor",
266
266
  size: t = 24,
@@ -269,47 +269,48 @@ const mt = Ie(
269
269
  className: s = "",
270
270
  children: n,
271
271
  iconNode: c,
272
- ...d
273
- }, h) => he(
272
+ ...i
273
+ }, u) => ke(
274
274
  "svg",
275
275
  {
276
- ref: h,
277
- ...ht,
276
+ ref: u,
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
- className: Te("lucide", s),
283
- ...!n && !bt(d) && { "aria-hidden": "true" },
284
- ...d
282
+ className: Pe("lucide", s),
283
+ ...!n && !ht(i) && { "aria-hidden": "true" },
284
+ ...i
285
285
  },
286
286
  [
287
- ...c.map(([B, x]) => he(B, x)),
287
+ ...c.map(([w, m]) => ke(w, m)),
288
288
  ...Array.isArray(n) ? n : [n]
289
289
  ]
290
290
  )
291
291
  );
292
- const M = (e, t) => {
293
- const a = Ie(
294
- ({ className: r, ...s }, n) => he(mt, {
292
+ const A = (e, t) => {
293
+ const a = Re(
294
+ ({ className: r, ...s }, n) => ke(mt, {
295
295
  ref: n,
296
296
  iconNode: t,
297
- className: Te(
298
- `lucide-${dt(ve(e))}`,
297
+ className: Pe(
298
+ `lucide-${ut(Me(e))}`,
299
299
  `lucide-${e}`,
300
300
  r
301
301
  ),
302
302
  ...s
303
303
  })
304
304
  );
305
- return a.displayName = ve(e), a;
305
+ return a.displayName = Me(e), a;
306
306
  };
307
- 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 = M("arrow-right", pt);
311
- const ft = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], gt = M("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
- ], Ct = M("house", yt);
322
- const vt = [
322
+ ], kt = A("house", Bt);
323
+ const xt = [
323
324
  [
324
325
  "path",
325
326
  {
@@ -330,8 +331,8 @@ const vt = [
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 = M("message-circle-more", vt);
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 = M("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
- ], Ae = M("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
- ], Ve = M("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 = M("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 = M("square-pen", Tt);
382
- const Vt = [
382
+ ], Rt = A("square-pen", Vt);
383
+ const Dt = [
383
384
  [
384
385
  "path",
385
386
  {
@@ -388,8 +389,8 @@ const Vt = [
388
389
  }
389
390
  ],
390
391
  ["path", { d: "M17 14V2", key: "8ymqnk" }]
391
- ], Ut = M("thumbs-down", Vt);
392
- const Ft = [
392
+ ], Ft = A("thumbs-down", Dt);
393
+ const Pt = [
393
394
  [
394
395
  "path",
395
396
  {
@@ -398,67 +399,103 @@ const Ft = [
398
399
  }
399
400
  ],
400
401
  ["path", { d: "M7 10v12", key: "1qc93n" }]
401
- ], Pt = M("thumbs-up", Ft);
402
- const Ht = [
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
- ], Rt = M("user-round", Ht);
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
- ], Ue = M("x", $t), v = { "aria-hidden": !0, strokeWidth: 1.9 }, _t = /* @__PURE__ */ o(St, { ...v }), le = /* @__PURE__ */ o(Ue, { ...v }), Lt = /* @__PURE__ */ o(Ue, { ...v }), Be = {
410
- "message-circle-more": /* @__PURE__ */ o(Bt, { ...v }),
411
- "message-circle": /* @__PURE__ */ o(xt, { ...v }),
412
- "message-square": /* @__PURE__ */ o(Ae, { ...v }),
413
- "messages-square": /* @__PURE__ */ o(Ve, { ...v })
414
- }, zt = (e = "messages-square") => Be[e] || Be["messages-square"], Dt = /* @__PURE__ */ o(wt, { ...v }), Fe = /* @__PURE__ */ o(Ct, { ...v }), qt = /* @__PURE__ */ o(Ae, { ...v }), Ot = /* @__PURE__ */ o(Pt, { ...v }), jt = /* @__PURE__ */ o(Ut, { ...v }), Et = /* @__PURE__ */ o(Ve, { ...v }), Wt = /* @__PURE__ */ o(gt, { ...v }), Gt = /* @__PURE__ */ o(At, { ...v }), Kt = /* @__PURE__ */ o(Rt, { ...v }), re = (e) => String(e).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&apos;"), Jt = ({ name: e, backgroundColor: t }) => {
415
- const a = (e || "B").trim().charAt(0).toUpperCase() || "B", r = ce(t), s = `
416
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-label="${re(e || "Bot")}">
417
- <rect width="96" height="96" rx="48" fill="${re(t)}" />
418
- <text x="50%" y="52%" dominant-baseline="middle" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="42" font-weight="700" fill="${re(r)}">${re(a)}</text>
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 = `
417
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-label="${he(e || "Bot")}">
418
+ <rect width="96" height="96" rx="48" fill="${he(t)}" />
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
- }, Zt = (e) => e ? e.payload?.type === "text" ? e.payload.text : e.payload?.type === "bloc" && e.payload.items?.some((t) => t.type === "text") ? e.payload.items.find((a) => a.type === "text")?.payload.text ?? "Conversa sem mensagens" : "Anexo enviado" : "Conversa sem mensagens", ke = [
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
- ], Xt = 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
- let a = ke[0];
433
- for (const r of ke)
433
+ let a = Te[0];
434
+ for (const r of Te)
434
435
  Math.abs(t) >= r.seconds && (a = r);
435
- return Xt.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", d = c && t === "connecting", h = c && t === "connected" && r === 0, B = s && (!c || r > 0 || t !== "connecting" && t !== "connected");
445
- return A(() => {
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");
446
+ return M(() => {
446
447
  if (s) {
447
- if (h) {
448
- const x = window.setTimeout(() => n(!1), 900);
449
- return () => window.clearTimeout(x);
448
+ if (u) {
449
+ const m = window.setTimeout(() => n(!1), 900);
450
+ return () => window.clearTimeout(m);
450
451
  }
451
- if (B) {
452
- const x = window.setTimeout(() => n(!1), 0);
453
- return () => window.clearTimeout(x);
452
+ if (w) {
453
+ const m = window.setTimeout(() => n(!1), 0);
454
+ return () => window.clearTimeout(m);
454
455
  }
455
456
  }
456
- }, [a, s, h, B]), {
457
- showInitialLoading: d || s && c,
457
+ }, [a, s, u, w]), {
458
+ showInitialLoading: i || s && c,
458
459
  setShowInitialLoading: n
459
460
  };
461
+ }, ro = 3e4, so = ({
462
+ getSession: e,
463
+ sessionKey: t,
464
+ onSessionChange: a
465
+ }) => {
466
+ const [r, s] = S(null), [n, c] = S(!!e), i = Z(e);
467
+ i.current = e;
468
+ const u = Z(a);
469
+ return u.current = a, M(() => {
470
+ let w = !0, m;
471
+ const b = (f) => {
472
+ w && (s(f), u.current?.(f));
473
+ };
474
+ if (!i.current) {
475
+ c(!1), b(null);
476
+ return;
477
+ }
478
+ const U = async () => {
479
+ try {
480
+ const f = await i.current();
481
+ if (!f?.userToken)
482
+ throw new Error("Webchat session not created or empty");
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);
489
+ } finally {
490
+ w && c(!1);
491
+ }
492
+ };
493
+ return c(!0), U(), () => {
494
+ w = !1, m && clearTimeout(m);
495
+ };
496
+ }, [t, !!e]), { session: r, resolving: n };
460
497
  };
461
- function to({
498
+ function co({
462
499
  botName: e,
463
500
  botAvatar: t,
464
501
  subtitle: a,
@@ -483,7 +520,7 @@ function to({
483
520
  type: "button",
484
521
  "aria-label": "Abrir início",
485
522
  onClick: r,
486
- children: Fe
523
+ children: _e
487
524
  }
488
525
  ) : null,
489
526
  /* @__PURE__ */ o(
@@ -493,7 +530,7 @@ function to({
493
530
  type: "button",
494
531
  "aria-label": "Abrir conversas",
495
532
  onClick: s,
496
- children: Et
533
+ children: Kt
497
534
  }
498
535
  ),
499
536
  /* @__PURE__ */ o(
@@ -503,7 +540,7 @@ function to({
503
540
  type: "button",
504
541
  "aria-label": "Reiniciar conversa",
505
542
  onClick: n,
506
- children: _t
543
+ children: zt
507
544
  }
508
545
  ),
509
546
  c ? /* @__PURE__ */ o(
@@ -513,13 +550,13 @@ function to({
513
550
  type: "button",
514
551
  "aria-label": "Fechar webchat",
515
552
  onClick: c,
516
- children: le
553
+ children: we
517
554
  }
518
555
  ) : null
519
556
  ] })
520
557
  ] });
521
558
  }
522
- function Pe() {
559
+ function ze() {
523
560
  return /* @__PURE__ */ l("div", { className: "bp-webchat-loading", children: [
524
561
  /* @__PURE__ */ l("div", { className: "bp-webchat-loading-hero", children: [
525
562
  /* @__PURE__ */ o("div", { className: "bp-webchat-loading-circle" }),
@@ -537,7 +574,7 @@ function Pe() {
537
574
  ] })
538
575
  ] });
539
576
  }
540
- function oo({
577
+ function lo({
541
578
  config: e,
542
579
  allowFileUpload: t,
543
580
  clientState: a,
@@ -545,36 +582,36 @@ function oo({
545
582
  messages: s,
546
583
  renderers: n,
547
584
  sendMessage: c,
548
- uploadFile: d,
549
- addMessageFeedback: h,
550
- showInitialLoading: B,
551
- onShowHome: x,
552
- onOpenHistory: p,
553
- onRestartConversation: I,
554
- onCloseWidget: N
585
+ uploadFile: i,
586
+ addMessageFeedback: u,
587
+ showInitialLoading: w,
588
+ onShowHome: m,
589
+ onOpenHistory: b,
590
+ onRestartConversation: U,
591
+ onCloseWidget: f
555
592
  }) {
556
593
  return /* @__PURE__ */ l("div", { className: "bp-webchat-layout", children: [
557
594
  /* @__PURE__ */ o(
558
- to,
595
+ co,
559
596
  {
560
597
  botName: e.botName,
561
598
  botAvatar: e.botAvatar,
562
599
  subtitle: e.subtitle,
563
- onShowHome: x,
564
- onOpenHistory: p,
565
- onRestartConversation: I,
566
- onCloseWidget: N
600
+ onShowHome: m,
601
+ onOpenHistory: b,
602
+ onRestartConversation: U,
603
+ onCloseWidget: f
567
604
  }
568
605
  ),
569
606
  /* @__PURE__ */ o(
570
- Ge,
607
+ Ke,
571
608
  {
572
609
  className: "bp-webchat-container",
573
- uploadFile: d,
610
+ uploadFile: i,
574
611
  allowFileUpload: t,
575
- children: B ? /* @__PURE__ */ o(Pe, {}) : /* @__PURE__ */ l(Ne, { children: [
612
+ children: w ? /* @__PURE__ */ o(ze, {}) : /* @__PURE__ */ l(Ve, { children: [
576
613
  /* @__PURE__ */ o(
577
- Ke,
614
+ Je,
578
615
  {
579
616
  botName: e.botName,
580
617
  botDescription: e.subtitle,
@@ -582,7 +619,7 @@ function oo({
582
619
  isTyping: r,
583
620
  messages: s,
584
621
  sendMessage: c,
585
- addMessageFeedback: h,
622
+ addMessageFeedback: u,
586
623
  renderers: n,
587
624
  showDateSystemMessage: !1,
588
625
  showMessageStatus: !1,
@@ -591,11 +628,11 @@ function oo({
591
628
  }
592
629
  ),
593
630
  /* @__PURE__ */ o(
594
- Je,
631
+ Xe,
595
632
  {
596
633
  connected: a !== "disconnected",
597
634
  sendMessage: c,
598
- uploadFile: d,
635
+ uploadFile: i,
599
636
  allowFileUpload: t,
600
637
  composerPlaceholder: e.placeholder,
601
638
  disableSendButton: !1
@@ -606,7 +643,7 @@ function oo({
606
643
  )
607
644
  ] });
608
645
  }
609
- function He({ activeView: e, onShowHome: t, onShowConversations: a }) {
646
+ function Ee({ activeView: e, onShowHome: t, onShowConversations: a }) {
610
647
  return /* @__PURE__ */ l("div", { className: "bp-webchat-tabs bp-webchat-welcome-bottom", children: [
611
648
  /* @__PURE__ */ l(
612
649
  "button",
@@ -616,7 +653,7 @@ function He({ activeView: e, onShowHome: t, onShowConversations: a }) {
616
653
  type: "button",
617
654
  onClick: t,
618
655
  children: [
619
- /* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: Fe }),
656
+ /* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: _e }),
620
657
  /* @__PURE__ */ o("span", { children: "Início" })
621
658
  ]
622
659
  }
@@ -629,14 +666,14 @@ function He({ activeView: e, onShowHome: t, onShowConversations: a }) {
629
666
  type: "button",
630
667
  onClick: a,
631
668
  children: [
632
- /* @__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 }),
633
670
  /* @__PURE__ */ o("span", { children: "Conversas" })
634
671
  ]
635
672
  }
636
673
  )
637
674
  ] });
638
675
  }
639
- function ao({
676
+ function io({
640
677
  conversations: e,
641
678
  currentConversationId: t,
642
679
  isLoading: a,
@@ -644,10 +681,10 @@ function ao({
644
681
  botName: s,
645
682
  onClose: n,
646
683
  onCloseWidget: c,
647
- onShowHome: d,
648
- onShowConversations: h,
649
- onNewConversation: B,
650
- onConversationClick: x
684
+ onShowHome: i,
685
+ onShowConversations: u,
686
+ onNewConversation: w,
687
+ onConversationClick: m
651
688
  }) {
652
689
  return /* @__PURE__ */ l("div", { className: "bp-webchat-history", children: [
653
690
  /* @__PURE__ */ l("div", { className: "bp-webchat-history-header", children: [
@@ -660,7 +697,7 @@ function ao({
660
697
  type: "button",
661
698
  onClick: n,
662
699
  "aria-label": "Fechar conversas",
663
- children: le
700
+ children: we
664
701
  }
665
702
  ),
666
703
  c ? /* @__PURE__ */ o(
@@ -670,47 +707,143 @@ function ao({
670
707
  type: "button",
671
708
  onClick: c,
672
709
  "aria-label": "Fechar webchat",
673
- children: le
710
+ children: we
674
711
  }
675
712
  ) : null
676
713
  ] })
677
714
  ] }),
678
- /* @__PURE__ */ o("div", { className: "bp-webchat-history-list", children: a ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-loading", children: "Carregando conversas..." }) : e.length === 0 ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-empty", children: "Nenhuma conversa iniciada ainda." }) : e.map((p) => {
679
- const I = Zt(p.lastMessage), N = p.lastMessage?.author?.type === "bot";
715
+ /* @__PURE__ */ o("div", { className: "bp-webchat-history-list", children: a ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-loading", children: "Carregando conversas..." }) : e.length === 0 ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-empty", children: "Nenhuma conversa iniciada ainda." }) : e.map((b) => {
716
+ const U = eo(b.lastMessage), f = b.lastMessage?.author?.type === "bot";
680
717
  return /* @__PURE__ */ l(
681
718
  "button",
682
719
  {
683
720
  className: "bp-webchat-history-item",
684
721
  type: "button",
685
- onClick: () => x(p.id),
686
- "data-current": p.id === t || void 0,
722
+ onClick: () => m(b.id),
723
+ "data-current": b.id === t || void 0,
687
724
  children: [
688
- /* @__PURE__ */ o("div", { className: "bp-webchat-history-avatar", "data-kind": N ? "bot" : "user", children: N && r ? /* @__PURE__ */ o("img", { src: r, alt: "" }) : N ? /* @__PURE__ */ o("span", { children: (s || "B").slice(0, 1).toUpperCase() }) : Kt }),
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 }),
689
726
  /* @__PURE__ */ l("div", { className: "bp-webchat-history-content", children: [
690
- /* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children: I }),
691
- /* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: Yt(p.updatedAt) })
727
+ /* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children: U }),
728
+ /* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: oo(b.updatedAt) })
692
729
  ] }),
693
- /* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children: Wt })
730
+ /* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children: Jt })
694
731
  ]
695
732
  },
696
- p.id
733
+ b.id
697
734
  );
698
735
  }) }),
699
- /* @__PURE__ */ o("div", { className: "bp-webchat-history-footer", children: /* @__PURE__ */ l("button", { className: "bp-webchat-history-new", type: "button", onClick: B, children: [
700
- 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,
701
738
  /* @__PURE__ */ o("span", { children: "Nova conversa" })
702
739
  ] }) }),
703
740
  /* @__PURE__ */ o(
704
- He,
741
+ Ee,
705
742
  {
706
743
  activeView: "conversations",
707
- onShowHome: d,
708
- onShowConversations: h
744
+ onShowHome: i,
745
+ onShowConversations: u
709
746
  }
710
747
  )
711
748
  ] });
712
749
  }
713
- function no({ 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 }) {
714
847
  return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
715
848
  /* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Nos ajude a melhorar" }),
716
849
  /* @__PURE__ */ o("p", { className: "bp-webchat-modal-description", children: "Conte o que não ficou bom nesta resposta." }),
@@ -737,7 +870,7 @@ function no({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
737
870
  ] })
738
871
  ] }) }) : null;
739
872
  }
740
- function ro({ open: e, onConfirm: t, onCancel: a }) {
873
+ function ho({ open: e, onConfirm: t, onCancel: a }) {
741
874
  return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
742
875
  /* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Criar nova conversa" }),
743
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." }),
@@ -755,7 +888,7 @@ function ro({ open: e, onConfirm: t, onCancel: a }) {
755
888
  ] })
756
889
  ] }) }) : null;
757
890
  }
758
- function so({ 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 }) {
759
892
  const c = e.welcomeCardImage || e.botAvatar;
760
893
  return /* @__PURE__ */ l("div", { className: "bp-webchat-welcome", children: [
761
894
  /* @__PURE__ */ l("div", { className: "bp-webchat-welcome-hero", children: [
@@ -766,7 +899,7 @@ function so({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
766
899
  type: "button",
767
900
  onClick: n,
768
901
  "aria-label": e.welcomeCloseLabel,
769
- children: le
902
+ children: we
770
903
  }
771
904
  ),
772
905
  e.welcomeCoverImage ? /* @__PURE__ */ o("img", { className: "bp-webchat-welcome-cover", src: e.welcomeCoverImage, alt: "" }) : null
@@ -781,11 +914,11 @@ function so({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
781
914
  /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-title", children: e.welcomeCtaLabel }),
782
915
  e.welcomeButtonDescription ? /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-description", children: e.welcomeButtonDescription }) : null
783
916
  ] }) }),
784
- /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-right", children: Dt })
917
+ /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-right", children: qt })
785
918
  ] })
786
919
  ] }) }),
787
920
  /* @__PURE__ */ o(
788
- He,
921
+ Ee,
789
922
  {
790
923
  activeView: t,
791
924
  onShowHome: a,
@@ -794,47 +927,47 @@ function so({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
794
927
  )
795
928
  ] });
796
929
  }
797
- const co = 220, ie = "eduzz-webchat", be = Object.freeze({
930
+ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
798
931
  allowFileUpload: !1,
799
932
  allowMessageFeedback: !1
800
- }), lo = "anonymous-id", io = (e) => !!e && typeof e == "object" && !Array.isArray(e), Re = (e) => e.replace(/\/+$/, ""), fe = ({ webchatProxyUrl: e }) => {
933
+ }), wo = "anonymous-id", fo = (e) => !!e && typeof e == "object" && !Array.isArray(e), Oe = (e) => e.replace(/\/+$/, ""), Ie = ({ webchatProxyUrl: e }) => {
801
934
  if (typeof e != "string" || !e.trim())
802
935
  return null;
803
- const t = Re(e.trim()), a = "/webchat/proxy";
936
+ const t = Oe(e.trim()), a = "/webchat/proxy";
804
937
  return t.endsWith(a) ? t.slice(0, -a.length) : null;
805
- }, uo = ({ webchatProxyUrl: e, clientId: t }) => !e || !t ? null : `${e.endsWith("/") ? e.slice(0, -1) : e}/${encodeURIComponent(t)}/runtime-config`, bo = ({ webchatProxyUrl: e, clientId: t, presetSlug: a }) => {
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 }) => {
806
939
  if (!e || !t)
807
940
  return null;
808
- const r = fe({ webchatProxyUrl: e });
941
+ const r = Ie({ webchatProxyUrl: e });
809
942
  if (!r)
810
943
  return null;
811
944
  const s = new URLSearchParams();
812
945
  typeof a == "string" && a.trim() && s.set("slug", a.trim());
813
946
  const n = s.toString();
814
947
  return `${r}/webchat/bootstrap/${encodeURIComponent(t)}${n ? `?${n}` : ""}`;
815
- }, ho = (e) => {
948
+ }, vo = (e) => {
816
949
  const t = e && typeof e == "object" && e.data && typeof e.data == "object" ? e.data : e;
817
950
  return t && typeof t == "object" ? t : null;
818
- }, J = (e) => io(e) ? e : null, mo = (e) => {
951
+ }, ne = (e) => fo(e) ? e : null, Co = (e) => {
819
952
  if (!e) return "";
820
953
  try {
821
954
  return JSON.stringify(e);
822
955
  } catch {
823
956
  return String(Date.now());
824
957
  }
825
- }, $e = (e) => {
958
+ }, qe = (e) => {
826
959
  if (typeof window > "u") return null;
827
960
  try {
828
961
  return e === "sessionStorage" ? window.sessionStorage : window.localStorage;
829
962
  } catch {
830
963
  return null;
831
964
  }
832
- }, _e = ({ storageKey: e, storageLocation: t }) => {
833
- const a = $e(t);
965
+ }, je = ({ storageKey: e, storageLocation: t }) => {
966
+ const a = qe(t);
834
967
  if (!a) return null;
835
968
  try {
836
969
  const r = a.getItem(
837
- `${e || ie}-client`
970
+ `${e || fe}-client`
838
971
  );
839
972
  if (!r) return null;
840
973
  const s = JSON.parse(r), n = typeof s?.state == "string" ? JSON.parse(s.state) : s?.state ?? s;
@@ -842,10 +975,10 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
842
975
  } catch {
843
976
  return;
844
977
  }
845
- }, po = ({ storageKey: e, storageLocation: t }) => {
846
- const a = _e({ storageKey: e, storageLocation: t });
978
+ }, Bo = ({ storageKey: e, storageLocation: t }) => {
979
+ const a = je({ storageKey: e, storageLocation: t });
847
980
  return typeof a?.conversationId == "string" && a.conversationId.trim() || void 0;
848
- }, xe = () => {
981
+ }, Ue = () => {
849
982
  try {
850
983
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
851
984
  return crypto.randomUUID();
@@ -859,19 +992,19 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
859
992
  const t = Math.random() * 16 | 0;
860
993
  return (e === "x" ? t : t & 3 | 8).toString(16);
861
994
  });
862
- }, wo = (e) => `${e || ie}-${lo}`, fo = ({ storageKey: e, storageLocation: t }) => {
863
- const a = $e(t), r = wo(e);
995
+ }, ko = (e) => `${e || fe}-${wo}`, xo = ({ storageKey: e, storageLocation: t }) => {
996
+ const a = qe(t), r = ko(e);
864
997
  try {
865
998
  const s = a?.getItem(r);
866
999
  if (s)
867
1000
  return s;
868
- const n = `anon_${xe()}`;
1001
+ const n = `anon_${Ue()}`;
869
1002
  return a?.setItem(r, n), n;
870
1003
  } catch {
871
- return `anon_${xe()}`;
1004
+ return `anon_${Ue()}`;
872
1005
  }
873
- }, go = async ({ webchatProxyUrl: e, clientId: t, accountId: a }) => {
874
- const r = fe({ webchatProxyUrl: e });
1006
+ }, No = async ({ webchatProxyUrl: e, clientId: t, accountId: a }) => {
1007
+ const r = Ie({ webchatProxyUrl: e });
875
1008
  if (!r)
876
1009
  throw new Error("public session request requires a valid webchatProxyUrl");
877
1010
  const s = await fetch(
@@ -895,11 +1028,11 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
895
1028
  userId: c.userId,
896
1029
  userToken: c.userToken
897
1030
  };
898
- }, yo = (e) => ({
1031
+ }, Io = (e) => ({
899
1032
  ...typeof e.name == "string" && e.name.trim() ? { name: e.name.trim() } : {},
900
1033
  ...typeof e.pictureUrl == "string" && e.pictureUrl.trim() ? { pictureUrl: e.pictureUrl.trim() } : {},
901
1034
  userData: e
902
- }), Co = ({
1035
+ }), Mo = ({
903
1036
  showWelcomeScreen: e,
904
1037
  storageKey: t,
905
1038
  storageLocation: a,
@@ -910,14 +1043,14 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
910
1043
  return { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" };
911
1044
  if (r && s)
912
1045
  return { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" };
913
- const n = _e({ storageKey: t, storageLocation: a });
1046
+ const n = je({ storageKey: t, storageLocation: a });
914
1047
  if (n == null)
915
1048
  return { activeView: "home", historyReturnView: "home", bootstrapView: "home" };
916
1049
  if (n === void 0)
917
1050
  return { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
918
- const c = typeof n.conversationId == "string" ? n.conversationId.trim() : "", d = typeof n.user?.userToken == "string" ? n.user.userToken.trim() : "";
919
- return c && d ? { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" } : !c && !d ? { activeView: "home", historyReturnView: "home", bootstrapView: "home" } : { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
920
- }, vo = (e, t) => {
1051
+ const c = typeof n.conversationId == "string" ? n.conversationId.trim() : "", i = typeof n.user?.userToken == "string" ? n.user.userToken.trim() : "";
1052
+ return c && i ? { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" } : !c && !i ? { activeView: "home", historyReturnView: "home", bootstrapView: "home" } : { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
1053
+ }, So = (e, t) => {
921
1054
  switch (t.type) {
922
1055
  case "show":
923
1056
  return { isPanelMounted: !0, isPanelVisible: e.isPanelVisible };
@@ -931,7 +1064,7 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
931
1064
  return e;
932
1065
  }
933
1066
  };
934
- function Io({
1067
+ function Ro({
935
1068
  clientId: e,
936
1069
  webchatProxyUrl: t,
937
1070
  userCredentials: a,
@@ -939,199 +1072,206 @@ function Io({
939
1072
  config: s,
940
1073
  defaultUserData: n,
941
1074
  presetSlug: c,
942
- storageKey: d = ie,
943
- storageLocation: h = "localStorage",
944
- defaultOpen: B,
945
- onUserApiChange: x
1075
+ storageKey: i = fe,
1076
+ storageLocation: u = "localStorage",
1077
+ defaultOpen: w,
1078
+ onUserApiChange: m,
1079
+ getSession: b,
1080
+ sessionKey: U,
1081
+ onSessionChange: f
946
1082
  }) {
947
- const p = f(
1083
+ const { session: B, resolving: F } = so({
1084
+ getSession: b,
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(
948
1088
  () => typeof c == "string" && c.trim() ? c.trim() : void 0,
949
1089
  [c]
950
- ), I = f(
951
- () => typeof t == "string" && t.trim() ? Re(t.trim()) : void 0,
1090
+ ), x = C(
1091
+ () => typeof t == "string" && t.trim() ? Oe(t.trim()) : void 0,
952
1092
  [t]
953
1093
  );
954
- f(
955
- () => I ? fe({ webchatProxyUrl: I }) : null,
956
- [I]
1094
+ C(
1095
+ () => x ? Ie({ webchatProxyUrl: x }) : null,
1096
+ [x]
957
1097
  );
958
- const N = !!(e && I && (p || !a)), g = f(
959
- () => N ? bo({
960
- webchatProxyUrl: I,
1098
+ const d = !!(e && x && (W || !V)), p = C(
1099
+ () => d ? yo({
1100
+ webchatProxyUrl: x,
961
1101
  clientId: e,
962
- presetSlug: p
1102
+ presetSlug: W
963
1103
  }) : null,
964
- [e, p, I, N]
965
- ), [V, D] = R({
1104
+ [e, W, x, d]
1105
+ ), [R, Q] = S({
966
1106
  error: null,
967
1107
  isLoading: !1,
968
1108
  payload: null,
969
1109
  url: null
970
1110
  });
971
- A(() => {
972
- if (!g) {
973
- D({ error: null, isLoading: !1, payload: null, url: null });
1111
+ M(() => {
1112
+ if (!p) {
1113
+ Q({ error: null, isLoading: !1, payload: null, url: null });
974
1114
  return;
975
1115
  }
976
- const u = new AbortController();
977
- return D({ error: null, isLoading: !0, payload: null, url: g }), fetch(g, {
1116
+ const N = new AbortController();
1117
+ return Q({ error: null, isLoading: !0, payload: null, url: p }), fetch(p, {
978
1118
  headers: {
979
1119
  accept: "application/json"
980
1120
  },
981
- signal: u.signal
982
- }).then(async (m) => {
983
- if (!m.ok)
984
- throw new Error(`bootstrap request failed with status ${m.status}`);
985
- return m.json();
986
- }).then((m) => {
987
- const k = ho(m);
988
- if (!k)
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)
989
1129
  throw new Error("bootstrap response is invalid");
990
- D({
1130
+ Q({
991
1131
  error: null,
992
1132
  isLoading: !1,
993
- payload: k,
994
- url: g
1133
+ payload: H,
1134
+ url: p
995
1135
  });
996
- }).catch((m) => {
997
- u.signal.aborted || (console.warn("[EduzzWebchat] failed to load bootstrap", m), D({ error: m, isLoading: !1, payload: null, url: g }));
998
- }), () => u.abort();
999
- }, [g]);
1000
- const y = g && V.url === g ? V.payload : null, q = g && V.url === g ? V.error : null, S = y?.clientId || e, P = I || y?.webchatProxyUrl || void 0, T = d === ie && y?.storageKey ? y.storageKey : d, Z = typeof B == "boolean" ? B : typeof y?.defaultOpen == "boolean" ? y.defaultOpen : B, oe = f(
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(
1001
1141
  () => ({
1002
- ...J(y?.config) || {},
1003
- ...J(s) || {}
1142
+ ...ne(y?.config) || {},
1143
+ ...ne(s) || {}
1004
1144
  }),
1005
1145
  [y, s]
1006
- ), E = f(
1146
+ ), ge = C(
1007
1147
  () => {
1008
- const u = {
1009
- ...J(y?.defaultUserData) || {},
1010
- ...J(n) || {}
1148
+ const N = {
1149
+ ...ne(y?.defaultUserData) || {},
1150
+ ...ne(n) || {}
1011
1151
  };
1012
- return Object.keys(u).length > 0 ? u : null;
1152
+ return Object.keys(N).length > 0 ? N : null;
1013
1153
  },
1014
1154
  [n, y]
1015
- ), W = !!(!a && y?.sessionMode === "service-hub" && P && S), [$, G] = R({
1155
+ ), E = !!(!V && !F && y?.sessionMode === "service-hub" && P && T), [re, ee] = S({
1016
1156
  error: null,
1017
1157
  isLoading: !1,
1018
1158
  payload: null,
1019
1159
  key: null
1020
1160
  });
1021
- A(() => {
1022
- if (!W) {
1023
- G({ error: null, isLoading: !1, payload: null, key: null });
1161
+ M(() => {
1162
+ if (!E) {
1163
+ ee({ error: null, isLoading: !1, payload: null, key: null });
1024
1164
  return;
1025
1165
  }
1026
- const u = fo({
1027
- storageKey: T,
1028
- storageLocation: h
1029
- }), m = `${S}:${P}:${u}`;
1030
- let k = !1;
1031
- return G({
1166
+ const N = xo({
1167
+ storageKey: z,
1168
+ storageLocation: u
1169
+ }), v = `${T}:${P}:${N}`;
1170
+ let H = !1;
1171
+ return ee({
1032
1172
  error: null,
1033
1173
  isLoading: !0,
1034
1174
  payload: null,
1035
- key: m
1036
- }), go({
1175
+ key: v
1176
+ }), No({
1037
1177
  webchatProxyUrl: P,
1038
- clientId: S,
1039
- accountId: u
1040
- }).then((b) => {
1041
- k || G({
1178
+ clientId: T,
1179
+ accountId: N
1180
+ }).then((g) => {
1181
+ H || ee({
1042
1182
  error: null,
1043
1183
  isLoading: !1,
1044
- payload: b,
1045
- key: m
1184
+ payload: g,
1185
+ key: v
1046
1186
  });
1047
- }).catch((b) => {
1048
- k || (console.warn("[EduzzWebchat] failed to open public session", b), G({
1049
- error: b,
1187
+ }).catch((g) => {
1188
+ H || (console.warn("[EduzzWebchat] failed to open public session", g), ee({
1189
+ error: g,
1050
1190
  isLoading: !1,
1051
1191
  payload: null,
1052
- key: m
1192
+ key: v
1053
1193
  }));
1054
1194
  }), () => {
1055
- k = !0;
1195
+ H = !0;
1056
1196
  };
1057
1197
  }, [
1058
- S,
1059
1198
  T,
1199
+ z,
1060
1200
  P,
1061
- W,
1062
- h
1201
+ E,
1202
+ u
1063
1203
  ]);
1064
- const _ = W ? $.payload : null, K = a || _, H = f(() => lt(oe), [oe]), L = f(
1065
- () => r || po({
1066
- storageKey: T,
1067
- storageLocation: 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,
1207
+ storageLocation: u
1068
1208
  }),
1069
- [r, T, h]
1070
- ), w = Z ?? H.initiallyOpen ?? !0, [de, z] = R(w), ae = me(w), [ue, O] = R(be), X = ee(() => z((u) => !u), []);
1071
- A(() => {
1072
- ae.current !== w && (ae.current = w, z(w));
1073
- }, [w]);
1074
- const Y = N && !y && !q, Q = W && !_ && !$.error;
1075
- return A(() => {
1076
- const u = uo({
1209
+ [j, r, z, u]
1210
+ ), $ = G ?? O.initiallyOpen ?? !0, [ye, J] = S($), se = Z($), [q, ae] = S(Be), ve = ce(() => J((N) => !N), []);
1211
+ M(() => {
1212
+ se.current !== $ && (se.current = $, J($));
1213
+ }, [$]);
1214
+ const de = d && !y && !ie, Ce = E && !K && !re.error;
1215
+ return M(() => {
1216
+ const N = go({
1077
1217
  webchatProxyUrl: P,
1078
- clientId: S
1218
+ clientId: T
1079
1219
  });
1080
- if (O(be), !u)
1220
+ if (ae(Be), !N)
1081
1221
  return;
1082
- const m = new AbortController();
1083
- let k = !1;
1084
- return fetch(u, {
1222
+ const v = new AbortController();
1223
+ let H = !1;
1224
+ return fetch(N, {
1085
1225
  headers: {
1086
1226
  accept: "application/json"
1087
1227
  },
1088
- signal: m.signal
1089
- }).then(async (b) => {
1090
- if (!b.ok)
1091
- throw new Error(`runtime config request failed with status ${b.status}`);
1092
- return b.json();
1093
- }).then((b) => {
1094
- if (k)
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)
1095
1235
  return;
1096
- const U = b && typeof b == "object" && b.data && typeof b.data == "object" ? b.data : {};
1097
- O({
1098
- allowFileUpload: U.allowFileUpload === !0,
1099
- allowMessageFeedback: U.allowMessageFeedback === !0
1236
+ const ue = g && typeof g == "object" && g.data && typeof g.data == "object" ? g.data : {};
1237
+ ae({
1238
+ allowFileUpload: ue.allowFileUpload === !0,
1239
+ allowMessageFeedback: ue.allowMessageFeedback === !0
1100
1240
  });
1101
- }).catch((b) => {
1102
- m.signal.aborted || k || (console.warn("[EduzzWebchat] failed to load runtime config", b), O(be));
1241
+ }).catch((g) => {
1242
+ v.signal.aborted || H || (console.warn("[EduzzWebchat] failed to load runtime config", g), ae(Be));
1103
1243
  }), () => {
1104
- k = !0, m.abort();
1244
+ H = !0, v.abort();
1105
1245
  };
1106
- }, [S, P]), Y || Q ? null : q && !y ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: te(H), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel carregar a configuracao publica do webchat." }) }) : $.error && !_ ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: te(H), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel abrir a sessao publica do webchat." }) }) : P ? S ? /* @__PURE__ */ o(
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(
1107
1247
  Ze,
1108
1248
  {
1109
- clientId: S,
1249
+ clientId: T,
1110
1250
  apiUrl: P,
1111
- conversationId: L,
1112
- userCredentials: K,
1113
- storageKey: T,
1114
- storageLocation: h,
1251
+ conversationId: oe,
1252
+ userCredentials: te,
1253
+ storageKey: z,
1254
+ storageLocation: u,
1115
1255
  children: /* @__PURE__ */ o(
1116
- Bo,
1256
+ To,
1117
1257
  {
1118
- clientId: S,
1119
- config: H,
1120
- defaultUserData: E,
1121
- conversationIdProp: L,
1122
- isOpen: de,
1123
- onUserApiChange: x,
1124
- onToggle: X,
1125
- runtimeCapabilities: ue,
1126
- storageKey: T,
1127
- storageLocation: h,
1128
- userToken: K?.userToken
1258
+ clientId: T,
1259
+ config: O,
1260
+ defaultUserData: ge,
1261
+ conversationIdProp: oe,
1262
+ isOpen: ye,
1263
+ onUserApiChange: m,
1264
+ onToggle: ve,
1265
+ runtimeCapabilities: q,
1266
+ storageKey: z,
1267
+ storageLocation: u,
1268
+ userToken: te?.userToken
1129
1269
  }
1130
1270
  )
1131
1271
  }
1132
- ) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: te(H), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhum clientId foi informado." }) }) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: te(H), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhuma URL publica do proxy do webchat foi informada." }) });
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." }) });
1133
1273
  }
1134
- function Bo({
1274
+ function To({
1135
1275
  clientId: e,
1136
1276
  config: t,
1137
1277
  defaultUserData: a,
@@ -1139,167 +1279,167 @@ function Bo({
1139
1279
  isOpen: s,
1140
1280
  onUserApiChange: n,
1141
1281
  onToggle: c,
1142
- runtimeCapabilities: d,
1143
- storageKey: h,
1144
- storageLocation: B,
1145
- userToken: x
1282
+ runtimeCapabilities: i,
1283
+ storageKey: u,
1284
+ storageLocation: w,
1285
+ userToken: m
1146
1286
  }) {
1147
- const p = f(
1148
- () => Co({
1287
+ const b = C(
1288
+ () => Mo({
1149
1289
  showWelcomeScreen: t.showWelcomeScreen,
1150
- storageKey: h,
1151
- storageLocation: B,
1290
+ storageKey: u,
1291
+ storageLocation: w,
1152
1292
  conversationId: r,
1153
- userToken: x
1293
+ userToken: m
1154
1294
  }),
1155
1295
  [
1156
1296
  t.showWelcomeScreen,
1157
1297
  r,
1158
- h,
1159
- B,
1160
- x
1298
+ u,
1299
+ w,
1300
+ m
1161
1301
  ]
1162
- ), [I, N] = R(!1), [g, V] = R({ open: !1, messageId: null, draft: "" }), [{ isPanelMounted: D, isPanelVisible: y }, q] = We(vo, {
1302
+ ), [U, f] = S(!1), [B, F] = S({ open: !1, messageId: null, draft: "" }), [{ isPanelMounted: Y, isPanelVisible: _ }, V] = Ge(So, {
1163
1303
  isPanelMounted: s,
1164
1304
  isPanelVisible: s
1165
1305
  }), {
1166
- conversationId: S,
1167
- isTyping: P,
1168
- messages: T,
1169
- saveMessageFeedback: Z,
1170
- sendMessage: oe,
1171
- status: E,
1172
- uploadFile: W
1173
- } = Xe(), { openConversation: $, listConversations: G } = Ye(), { updateUser: _, userCredentials: K } = Qe(), H = me({}), [L, w] = R(() => p.activeView), [de, z] = R(() => p.historyReturnView), { conversations: ae, isLoading: ue, refresh: O } = et({
1174
- userCredentials: K,
1175
- listConversations: G,
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,
1315
+ listConversations: ie,
1176
1316
  clientId: e
1177
- }), X = f(
1178
- () => mo(a),
1317
+ }), te = C(
1318
+ () => Co(a),
1179
1319
  [a]
1180
- ), Y = ee(
1181
- async (C = {}) => {
1182
- if (!_)
1320
+ ), O = ce(
1321
+ async (I = {}) => {
1322
+ if (!T)
1183
1323
  return;
1184
- const i = {
1185
- ...J(a) || {},
1186
- ...H.current,
1187
- ...J(C) || {}
1324
+ const h = {
1325
+ ...ne(a) || {},
1326
+ ...z.current,
1327
+ ...ne(I) || {}
1188
1328
  };
1189
- return H.current = i, _(yo(i));
1329
+ return z.current = h, T(Io(h));
1190
1330
  },
1191
- [a, _]
1192
- ), Q = me(Y);
1193
- A(() => {
1194
- Q.current = Y;
1195
- }, [Y]);
1196
- const u = !!_;
1197
- A(() => {
1198
- H.current = {};
1199
- }, [X]), A(() => {
1331
+ [a, T]
1332
+ ), oe = Z(O);
1333
+ M(() => {
1334
+ oe.current = O;
1335
+ }, [O]);
1336
+ const $ = !!T;
1337
+ M(() => {
1338
+ z.current = {};
1339
+ }, [te]), M(() => {
1200
1340
  if (n)
1201
1341
  return n({
1202
- updateUserData: u ? (C) => Q.current(C) : void 0
1342
+ updateUserData: $ ? (I) => oe.current(I) : void 0
1203
1343
  }), () => n(null);
1204
- }, [n, u]), A(() => {
1205
- !u || !X || Q.current();
1206
- }, [X, u]), A(() => {
1207
- d.allowMessageFeedback || V({ open: !1, messageId: null, draft: "" });
1208
- }, [d.allowMessageFeedback]);
1209
- const { showInitialLoading: m, setShowInitialLoading: k } = eo({
1210
- activeView: L,
1211
- clientState: E,
1212
- conversationId: S,
1213
- messagesLength: T.length
1214
- }), b = f(
1215
- () => t.botAvatar || Jt({ name: t.botName, backgroundColor: t.accentColor }),
1344
+ }, [n, $]), M(() => {
1345
+ !$ || !te || oe.current();
1346
+ }, [te, $]), M(() => {
1347
+ i.allowMessageFeedback || F({ open: !1, messageId: null, draft: "" });
1348
+ }, [i.allowMessageFeedback]);
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 }),
1216
1356
  [t.accentColor, t.botAvatar, t.botName]
1217
- ), U = f(
1218
- () => ({ ...t, botAvatar: b }),
1219
- [t, b]
1220
- ), ge = ee(
1221
- async (C) => {
1222
- z(C), w("conversations"), await O();
1357
+ ), q = C(
1358
+ () => ({ ...t, botAvatar: se }),
1359
+ [t, se]
1360
+ ), ae = ce(
1361
+ async (I) => {
1362
+ E(I), D("conversations"), await K();
1223
1363
  },
1224
- [O]
1225
- ), Le = ee(
1226
- (C) => {
1227
- k(!0), $(C), w("chat");
1364
+ [K]
1365
+ ), ve = ce(
1366
+ (I) => {
1367
+ J(!0), y(I), D("chat");
1228
1368
  },
1229
- [$, k]
1230
- ), ye = ee(() => {
1231
- k(!0), $(), w("chat");
1232
- }, [$, k]), ze = f(
1233
- () => Qt({
1234
- messages: T,
1235
- user: K,
1236
- botName: U.botName,
1237
- botAvatar: U.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
1238
1378
  }),
1239
- [T, U.botAvatar, U.botName, K]
1240
- ), De = te(t), qe = f(() => it(t), [t]), Oe = f(() => zt(t.fabChatIconVariant), [t.fabChatIconVariant]);
1241
- A(() => {
1379
+ [x, q.botAvatar, q.botName, P]
1380
+ ), N = le(t), v = C(() => dt(t), [t]), H = C(() => Ot(t.fabChatIconVariant), [t.fabChatIconVariant]);
1381
+ M(() => {
1242
1382
  if (s) {
1243
- q({ type: "show" });
1244
- const ne = window.requestAnimationFrame(() => q({ type: "visible" }));
1245
- return () => window.cancelAnimationFrame(ne);
1383
+ V({ type: "show" });
1384
+ const be = window.requestAnimationFrame(() => V({ type: "visible" }));
1385
+ return () => window.cancelAnimationFrame(be);
1246
1386
  }
1247
- q({ type: "hide" });
1248
- const C = window.setTimeout(() => {
1249
- N(!1), V({ open: !1, messageId: null, draft: "" });
1250
- }, 0), i = window.setTimeout(() => q({ type: "unmount" }), co);
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);
1251
1391
  return () => {
1252
- window.clearTimeout(C), window.clearTimeout(i);
1392
+ window.clearTimeout(I), window.clearTimeout(h);
1253
1393
  };
1254
- }, [s]), A(() => {
1255
- if (p.bootstrapView === "pending") {
1256
- if (T.length > 0) {
1257
- const C = window.setTimeout(() => {
1258
- w("chat"), z("chat");
1394
+ }, [s]), M(() => {
1395
+ if (b.bootstrapView === "pending") {
1396
+ if (x.length > 0) {
1397
+ const I = window.setTimeout(() => {
1398
+ D("chat"), E("chat");
1259
1399
  }, 0);
1260
- return () => window.clearTimeout(C);
1400
+ return () => window.clearTimeout(I);
1261
1401
  }
1262
- if (E !== "connecting") {
1263
- const C = window.setTimeout(() => {
1264
- w("home"), z("home");
1402
+ if (R !== "connecting") {
1403
+ const I = window.setTimeout(() => {
1404
+ D("home"), E("home");
1265
1405
  }, 0);
1266
- return () => window.clearTimeout(C);
1406
+ return () => window.clearTimeout(I);
1267
1407
  }
1268
1408
  }
1269
- }, [E, p.bootstrapView, T.length]);
1270
- const Ce = f(
1271
- () => function(i) {
1272
- const ne = d.allowMessageFeedback && i.direction === "incoming" && typeof i.addMessageFeedback == "function", Ee = {
1273
- ...i.block,
1274
- direction: i.direction,
1275
- sender: i.sender,
1276
- timestamp: i.timestamp,
1277
- messageId: i.messageId,
1278
- metadata: i.metadata,
1279
- isReadOnly: i.isReadOnly,
1280
- status: i.status,
1281
- feedback: i.feedback,
1282
- sendMessage: i.sendMessage,
1283
- addMessageFeedback: i.addMessageFeedback
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
1284
1424
  };
1285
1425
  return /* @__PURE__ */ l(
1286
1426
  "div",
1287
1427
  {
1288
1428
  className: "bpMessageBlocksBubble",
1289
- "data-direction": i.direction,
1290
- "data-feedback": ne || void 0,
1429
+ "data-direction": h.direction,
1430
+ "data-feedback": be || void 0,
1291
1431
  children: [
1292
- /* @__PURE__ */ o(tt, { block: Ee }),
1293
- ne ? /* @__PURE__ */ l("div", { className: "bpMessageBlocksBubbleFeedbackContainer", children: [
1432
+ /* @__PURE__ */ o(ot, { block: We }),
1433
+ be ? /* @__PURE__ */ l("div", { className: "bpMessageBlocksBubbleFeedbackContainer", children: [
1294
1434
  /* @__PURE__ */ o(
1295
1435
  "button",
1296
1436
  {
1297
1437
  className: "bpMessageBlocksBubbleFeedbackIcon",
1298
1438
  type: "button",
1299
- "data-selected": i.feedback === "positive",
1439
+ "data-selected": h.feedback === "positive",
1300
1440
  "aria-label": "Feedback positivo",
1301
- onClick: () => i.addMessageFeedback(i.messageId, { value: "positive" }),
1302
- children: Ot
1441
+ onClick: () => h.addMessageFeedback(h.messageId, { value: "positive" }),
1442
+ children: Wt
1303
1443
  }
1304
1444
  ),
1305
1445
  /* @__PURE__ */ o(
@@ -1307,14 +1447,14 @@ function Bo({
1307
1447
  {
1308
1448
  className: "bpMessageBlocksBubbleFeedbackIcon",
1309
1449
  type: "button",
1310
- "data-selected": i.feedback === "negative",
1450
+ "data-selected": h.feedback === "negative",
1311
1451
  "aria-label": "Feedback negativo",
1312
- onClick: () => V({
1452
+ onClick: () => F({
1313
1453
  open: !0,
1314
- messageId: i.messageId,
1454
+ messageId: h.messageId,
1315
1455
  draft: ""
1316
1456
  }),
1317
- children: jt
1457
+ children: Gt
1318
1458
  }
1319
1459
  )
1320
1460
  ] }) : null
@@ -1322,88 +1462,91 @@ function Bo({
1322
1462
  }
1323
1463
  );
1324
1464
  },
1325
- [d.allowMessageFeedback]
1326
- ), je = f(() => ({ bubble: Ce }), [Ce]);
1465
+ [i.allowMessageFeedback]
1466
+ ), ue = C(
1467
+ () => ({ bubble: g, dropdown: uo }),
1468
+ [g]
1469
+ );
1327
1470
  return /* @__PURE__ */ l(
1328
1471
  "div",
1329
1472
  {
1330
1473
  className: "bp-webchat-shell",
1331
- "data-panel-mounted": D,
1332
- "data-panel-open": y,
1333
- style: De,
1474
+ "data-panel-mounted": Y,
1475
+ "data-panel-open": _,
1476
+ style: N,
1334
1477
  children: [
1335
- /* @__PURE__ */ o(ot, { ...qe }),
1336
- D ? /* @__PURE__ */ o("div", { className: "bp-webchat-panel", "data-state": y ? "open" : "closed", children: L === "home" ? /* @__PURE__ */ o(
1337
- so,
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,
1338
1481
  {
1339
- config: U,
1340
- activeView: L,
1482
+ config: q,
1483
+ activeView: G,
1341
1484
  onClose: c,
1342
- onShowHome: () => w("home"),
1343
- onShowConversations: () => ge("home"),
1344
- onStart: () => w("chat")
1485
+ onShowHome: () => D("home"),
1486
+ onShowConversations: () => ae("home"),
1487
+ onStart: () => D("chat")
1345
1488
  }
1346
- ) : L === "conversations" ? /* @__PURE__ */ o(
1347
- ao,
1489
+ ) : G === "conversations" ? /* @__PURE__ */ o(
1490
+ io,
1348
1491
  {
1349
- conversations: ae,
1350
- currentConversationId: S,
1351
- isLoading: ue,
1352
- botAvatar: U.botAvatar,
1353
- botName: U.botName,
1354
- onClose: () => w(de),
1492
+ conversations: re,
1493
+ currentConversationId: j,
1494
+ isLoading: ee,
1495
+ botAvatar: q.botAvatar,
1496
+ botName: q.botName,
1497
+ onClose: () => D(ge),
1355
1498
  onCloseWidget: c,
1356
1499
  onShowHome: () => {
1357
- w("home"), z("home");
1500
+ D("home"), E("home");
1358
1501
  },
1359
- onShowConversations: O,
1360
- onNewConversation: ye,
1361
- onConversationClick: Le
1502
+ onShowConversations: K,
1503
+ onNewConversation: de,
1504
+ onConversationClick: ve
1362
1505
  }
1363
- ) : L === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(Pe, {}) }) : /* @__PURE__ */ l(Ne, { children: [
1506
+ ) : G === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(ze, {}) }) : /* @__PURE__ */ l(Ve, { children: [
1364
1507
  /* @__PURE__ */ o(
1365
- oo,
1508
+ lo,
1366
1509
  {
1367
- config: U,
1368
- allowFileUpload: d.allowFileUpload,
1369
- clientState: E,
1370
- isTyping: P,
1371
- messages: ze,
1372
- renderers: je,
1373
- sendMessage: oe,
1374
- uploadFile: W,
1375
- addMessageFeedback: d.allowMessageFeedback ? Z : void 0,
1376
- showInitialLoading: m,
1510
+ config: q,
1511
+ allowFileUpload: i.allowFileUpload,
1512
+ clientState: R,
1513
+ isTyping: W,
1514
+ messages: Ce,
1515
+ renderers: ue,
1516
+ sendMessage: p,
1517
+ uploadFile: Q,
1518
+ addMessageFeedback: i.allowMessageFeedback ? d : void 0,
1519
+ showInitialLoading: ye,
1377
1520
  onShowHome: t.showWelcomeScreen ? () => {
1378
- w("home"), z("home");
1521
+ D("home"), E("home");
1379
1522
  } : void 0,
1380
- onOpenHistory: () => ge("chat"),
1381
- onRestartConversation: () => N(!0),
1523
+ onOpenHistory: () => ae("chat"),
1524
+ onRestartConversation: () => f(!0),
1382
1525
  onCloseWidget: c
1383
1526
  }
1384
1527
  ),
1385
1528
  /* @__PURE__ */ o(
1386
- ro,
1529
+ ho,
1387
1530
  {
1388
- open: I,
1389
- onCancel: () => N(!1),
1531
+ open: U,
1532
+ onCancel: () => f(!1),
1390
1533
  onConfirm: () => {
1391
- N(!1), ye();
1534
+ f(!1), de();
1392
1535
  }
1393
1536
  }
1394
1537
  ),
1395
- d.allowMessageFeedback ? /* @__PURE__ */ o(
1396
- no,
1538
+ i.allowMessageFeedback ? /* @__PURE__ */ o(
1539
+ bo,
1397
1540
  {
1398
- open: g.open,
1399
- draft: g.draft,
1400
- setDraft: (C) => V((i) => ({ ...i, draft: C })),
1401
- onCancel: () => V({ 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: "" }),
1402
1545
  onConfirm: async () => {
1403
- g.messageId && Z && await Z(g.messageId, {
1546
+ B.messageId && d && await d(B.messageId, {
1404
1547
  value: "negative",
1405
- comment: g.draft
1406
- }), V({ open: !1, messageId: null, draft: "" });
1548
+ comment: B.draft
1549
+ }), F({ open: !1, messageId: null, draft: "" });
1407
1550
  }
1408
1551
  }
1409
1552
  ) : null
@@ -1417,8 +1560,8 @@ function Bo({
1417
1560
  type: "button",
1418
1561
  "aria-label": s ? "Fechar webchat" : "Abrir webchat",
1419
1562
  children: [
1420
- /* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--chat", children: Oe }),
1421
- /* @__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 })
1422
1565
  ]
1423
1566
  }
1424
1567
  )
@@ -1427,9 +1570,9 @@ function Bo({
1427
1570
  );
1428
1571
  }
1429
1572
  export {
1430
- Io as Webchat,
1431
- j as defaultConfig,
1432
- ce as getContrastingTextColor,
1433
- te as getShellStyle,
1434
- lt as normalizeConfig
1573
+ Ro as Webchat,
1574
+ X as defaultConfig,
1575
+ me as getContrastingTextColor,
1576
+ le as getShellStyle,
1577
+ it as normalizeConfig
1435
1578
  };