@opencx/widget-react 4.0.36 → 4.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { jsx as r, jsxs as c, Fragment as te } from "react/jsx-runtime";
2
2
  import * as ce from "@radix-ui/react-popover";
3
3
  import * as G from "react";
4
4
  import U, { memo as Lt, forwardRef as dt, useState as T, cloneElement as pt, createContext as Bt, useEffect as re, useContext as Yt, useMemo as ht, useRef as de, createElement as ot } from "react";
5
- import { useWidget as j, useConfig as b, useDocumentDir as ve, useSessions as L, useMessages as E, useWidgetRouter as A, useWidgetTrigger as K, useModes as mt, useCsat as gt, useUploadFiles as Ut, useIsAwaitingBotReply as wt, useContact as qt, WidgetProvider as Xt, WidgetTriggerProvider as Vt } from "@opencx/widget-react-headless";
5
+ import { useWidget as j, useConfig as b, useDocumentDir as ve, useSessions as L, useMessages as E, useWidgetRouter as O, useWidgetTrigger as K, useModes as mt, useCsat as gt, useUploadFiles as Ut, useIsAwaitingBotReply as wt, useContact as qt, WidgetProvider as Xt, WidgetTriggerProvider as Vt } from "@opencx/widget-react-headless";
6
6
  import { clsx as Gt } from "clsx";
7
7
  import { twMerge as Kt } from "tailwind-merge";
8
8
  import { motion as Z, AnimatePresence as _ } from "framer-motion";
@@ -38,15 +38,15 @@ const V = {
38
38
  )) return e;
39
39
  const y = (w) => {
40
40
  var N, S;
41
- const { clientX: k, clientY: I } = w, x = w.currentTarget.getBoundingClientRect(), M = k - (x.left + x.width / 2), H = I - (x.top + x.height / 2), F = Math.max(
41
+ const { clientX: k, clientY: I } = w, f = w.currentTarget.getBoundingClientRect(), M = k - (f.left + f.width / 2), F = I - (f.top + f.height / 2), A = Math.max(
42
42
  -1,
43
- Math.min(1, M / (x.width / 2))
43
+ Math.min(1, M / (f.width / 2))
44
44
  ), W = Math.max(
45
45
  -1,
46
- Math.min(1, H / (x.height / 2))
47
- ), R = F * V.x, f = W * V.y;
48
- d({ x: R, y: f }), (S = (N = e.props).onMouseMove) == null || S.call(N, w);
49
- }, v = () => {
46
+ Math.min(1, F / (f.height / 2))
47
+ ), R = A * V.x, v = W * V.y;
48
+ d({ x: R, y: v }), (S = (N = e.props).onMouseMove) == null || S.call(N, w);
49
+ }, x = () => {
50
50
  var w, k;
51
51
  i(!0), (k = (w = e.props).onMouseEnter) == null || k.call(w);
52
52
  }, m = () => {
@@ -60,7 +60,7 @@ const V = {
60
60
  return pt(e, {
61
61
  ref: s,
62
62
  onMouseMove: y,
63
- onMouseEnter: v,
63
+ onMouseEnter: x,
64
64
  onMouseLeave: m,
65
65
  style: {
66
66
  ...z,
@@ -87,19 +87,19 @@ const Er = 10, Rr = (e, o, t) => ({
87
87
  initial: { opacity: 0, x: e, ...o.initial },
88
88
  animate: { opacity: 1, x: 0, ...o.animate, transition: { delay: t } },
89
89
  exit: { opacity: 0, x: -e, ...o.exit }
90
- }), Ar = (e, o, t) => ({
90
+ }), Or = (e, o, t) => ({
91
91
  initial: { opacity: 0, y: e, ...o.initial },
92
92
  animate: { opacity: 1, y: 0, ...o.animate, transition: { delay: t } },
93
93
  exit: { opacity: 0, y: -e, ...o.exit }
94
- }), Or = (e, o, t) => ({
94
+ }), Hr = (e, o, t) => ({
95
95
  initial: { opacity: 0, y: -e, ...o.initial },
96
96
  animate: { opacity: 1, y: 0, ...o.animate, transition: { delay: t } },
97
97
  exit: { opacity: 0, y: e, ...o.exit }
98
- }), Hr = {
98
+ }), Fr = {
99
99
  right: Rr,
100
100
  left: Pr,
101
- up: Ar,
102
- down: Or
101
+ up: Or,
102
+ down: Hr
103
103
  }, u = dt(
104
104
  ({
105
105
  fadeIn: e = "down",
@@ -110,12 +110,12 @@ const Er = 10, Rr = (e, o, t) => ({
110
110
  delay: a = 0,
111
111
  ...i
112
112
  }, l) => {
113
- const d = e ? Hr[e](o, s, a) : {};
113
+ const d = e ? Fr[e](o, s, a) : {};
114
114
  return n && d.exit && typeof d.exit == "object" && !Array.isArray(d.exit) && (d.exit.transition = { duration: 0 }), /* @__PURE__ */ r(Z.div, { ref: l, ...i, ...d, children: t });
115
115
  }
116
116
  );
117
117
  u.displayName = "MotionDiv";
118
- const Fr = Zt(
118
+ const Ar = Zt(
119
119
  p(
120
120
  "inline-flex shrink-0 items-center justify-center gap-2",
121
121
  "text-sm font-medium whitespace-nowrap",
@@ -160,7 +160,7 @@ const Fr = Zt(
160
160
  {
161
161
  ...g("ui_lib/btn"),
162
162
  "data-variant": o,
163
- className: p(Fr({ variant: o, size: t, className: e })),
163
+ className: p(Ar({ variant: o, size: t, className: e })),
164
164
  ...s
165
165
  }
166
166
  ) })
@@ -407,7 +407,7 @@ function ge({
407
407
  d == null ? void 0 : d.messageContainer
408
408
  ),
409
409
  children: [
410
- n && n.length > 0 && /* @__PURE__ */ r("div", { className: "w-full gap-1 flex flex-row flex-wrap items-center justify-start", children: n == null ? void 0 : n.map((v) => /* @__PURE__ */ r(Tt, { attachment: v }, v.id)) }),
410
+ n && n.length > 0 && /* @__PURE__ */ r("div", { className: "w-full gap-1 flex flex-row flex-wrap items-center justify-start", children: n == null ? void 0 : n.map((x) => /* @__PURE__ */ r(Tt, { attachment: x }, x.id)) }),
411
411
  h.length > 0 && /* @__PURE__ */ r(
412
412
  "div",
413
413
  {
@@ -547,7 +547,7 @@ function J({
547
547
  ] });
548
548
  }
549
549
  const st = 450;
550
- function O() {
550
+ function H() {
551
551
  const [e, o] = U.useState(() => (window.top || window).innerWidth < st);
552
552
  return U.useEffect(() => {
553
553
  const t = window.top || window, n = () => {
@@ -563,17 +563,17 @@ const ie = {
563
563
  transitionDuration: "1000ms"
564
564
  };
565
565
  function q() {
566
- var v, m, z, w, k, I, x, M, H, F, W, R, f, N, S, B, se, _e, Ie, Te, Me, De, je, Ee, Re, Pe, Ae, Oe, He, Fe, We, $e, Le, Be, Ye, Ue, qe, Xe, Ve, Ge, Ke, Qe, Ze, Je, et, tt, rt;
567
- const { dir: e } = ve(), { isSmallScreen: o } = O(), { theme: t, inline: n } = b(), s = (Y) => n ? "100%" : Y, a = (Y, he) => o ? `100dv${Y}` : he, i = (Y, he) => s(a(Y, he)), l = {
568
- zIndex: ((v = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : v.zIndex) ?? 1e7,
566
+ var x, m, z, w, k, I, f, M, F, A, W, R, v, N, S, B, se, _e, Ie, Te, Me, De, je, Ee, Re, Pe, Oe, He, Fe, Ae, We, $e, Le, Be, Ye, Ue, qe, Xe, Ve, Ge, Ke, Qe, Ze, Je, et, tt, rt;
567
+ const { dir: e } = ve(), { isSmallScreen: o } = H(), { theme: t, inline: n } = b(), s = (Y) => n ? "100%" : Y, a = (Y, he) => o ? `100dv${Y}` : he, i = (Y, he) => s(a(Y, he)), l = {
568
+ zIndex: ((x = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : x.zIndex) ?? 1e7,
569
569
  offset: {
570
570
  bottom: ((z = (m = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : m.offset) == null ? void 0 : z.bottom) ?? 20,
571
571
  right: ((k = (w = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : w.offset) == null ? void 0 : k.right) ?? (e === "ltr" ? 20 : "initial"),
572
- left: ((x = (I = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : I.offset) == null ? void 0 : x.left) ?? (e === "rtl" ? 20 : "initial")
572
+ left: ((f = (I = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : I.offset) == null ? void 0 : f.left) ?? (e === "rtl" ? 20 : "initial")
573
573
  },
574
574
  size: {
575
- button: ((H = (M = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : M.size) == null ? void 0 : H.button) ?? 48,
576
- icon: ((W = (F = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : F.size) == null ? void 0 : W.icon) ?? 24
575
+ button: ((F = (M = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : M.size) == null ? void 0 : F.button) ?? 48,
576
+ icon: ((W = (A = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : A.size) == null ? void 0 : W.icon) ?? 24
577
577
  }
578
578
  }, d = (() => {
579
579
  const Y = e === "ltr" ? l.offset.right : l.offset.left;
@@ -584,7 +584,7 @@ function q() {
584
584
  widgetTrigger: l,
585
585
  widgetContentContainer: {
586
586
  borderRadius: o ? "0px" : ((R = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : R.borderRadius) ?? "32px",
587
- zIndex: ((f = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : f.zIndex) ?? l.zIndex + 1,
587
+ zIndex: ((v = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : v.zIndex) ?? l.zIndex + 1,
588
588
  outline: ((N = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : N.outline) ?? "none",
589
589
  // was: '1px solid'
590
590
  outlineColor: ((S = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : S.outlineColor) ?? "hsl(0 0% 50% / .5)",
@@ -603,12 +603,12 @@ function q() {
603
603
  // By setting minHeight to 1px, a nice animation will play from 1px to the dynamic height of the content of the screen
604
604
  minHeight: i(
605
605
  "h",
606
- ((Ae = (Pe = t == null ? void 0 : t.screens) == null ? void 0 : Pe.welcome) == null ? void 0 : Ae.minHeight) ?? "1px"
606
+ ((Oe = (Pe = t == null ? void 0 : t.screens) == null ? void 0 : Pe.welcome) == null ? void 0 : Oe.minHeight) ?? "1px"
607
607
  )
608
608
  },
609
609
  sessions: {
610
- width: i("w", ((He = (Oe = t == null ? void 0 : t.screens) == null ? void 0 : Oe.sessions) == null ? void 0 : He.width) ?? "450px"),
611
- height: i("h", ((We = (Fe = t == null ? void 0 : t.screens) == null ? void 0 : Fe.sessions) == null ? void 0 : We.height) ?? "600px")
610
+ width: i("w", ((Fe = (He = t == null ? void 0 : t.screens) == null ? void 0 : He.sessions) == null ? void 0 : Fe.width) ?? "450px"),
611
+ height: i("h", ((We = (Ae = t == null ? void 0 : t.screens) == null ? void 0 : Ae.sessions) == null ? void 0 : We.height) ?? "600px")
612
612
  },
613
613
  chat: {
614
614
  width: i("w", ((Le = ($e = t == null ? void 0 : t.screens) == null ? void 0 : $e.chat) == null ? void 0 : Le.width) ?? "525px"),
@@ -783,7 +783,7 @@ function ze({
783
783
  width: e,
784
784
  height: o
785
785
  }) {
786
- const { isSmallScreen: t } = O(), { setWidth: n, setHeight: s } = Rt();
786
+ const { isSmallScreen: t } = H(), { setWidth: n, setHeight: s } = Rt();
787
787
  re(() => {
788
788
  e && n(e), o && s(o);
789
789
  }, [t, o, e, n, s]);
@@ -842,7 +842,7 @@ function ne() {
842
842
  messagesState: { messages: n }
843
843
  } = E(), {
844
844
  routerState: { screen: s }
845
- } = A();
845
+ } = O();
846
846
  return {
847
847
  react: U,
848
848
  org: e,
@@ -867,7 +867,7 @@ function Ne() {
867
867
  widgetCtx: { org: e }
868
868
  } = j(), {
869
869
  routerState: { screen: o }
870
- } = A(), { textContent: t } = b();
870
+ } = O(), { textContent: t } = b();
871
871
  return (() => {
872
872
  var s, a;
873
873
  switch (o) {
@@ -900,7 +900,7 @@ function Qr() {
900
900
  const { router: e } = b(), {
901
901
  routerState: { screen: o },
902
902
  toSessionsScreen: t
903
- } = A();
903
+ } = O();
904
904
  return o !== "chat" || e != null && e.chatScreenOnly ? null : /* @__PURE__ */ r(
905
905
  C,
906
906
  {
@@ -915,7 +915,7 @@ function Qr() {
915
915
  function Zr({
916
916
  button: e
917
917
  }) {
918
- const { setIsOpen: o } = K(), { isSmallScreen: t } = O();
918
+ const { setIsOpen: o } = K(), { isSmallScreen: t } = H();
919
919
  return t && e.hideOnSmallScreen || !t && e.hideOnLargeScreen ? null : /* @__PURE__ */ r(
920
920
  C,
921
921
  {
@@ -935,7 +935,7 @@ function ue({
935
935
  }) {
936
936
  const [o, t] = T(!1), {
937
937
  routerState: { screen: n }
938
- } = A(), { isSmallScreen: s } = O(), { theme: a } = q(), { setWidth: i, setHeight: l } = Rt();
938
+ } = O(), { isSmallScreen: s } = H(), { theme: a } = q(), { setWidth: i, setHeight: l } = Rt();
939
939
  if (n !== "chat" && n !== "sessions") return null;
940
940
  const d = (() => {
941
941
  switch (n) {
@@ -956,8 +956,8 @@ function ue({
956
956
  return D(n, ue.name), a.screens.chat.width;
957
957
  }
958
958
  })(), y = () => {
959
- t((v) => {
960
- const m = !v;
959
+ t((x) => {
960
+ const m = !x;
961
961
  return l(m ? "100vh" : d), i(m ? `max(40vw, ${h})` : h), m;
962
962
  });
963
963
  };
@@ -981,9 +981,9 @@ function Pt({
981
981
  button: e
982
982
  }) {
983
983
  var k, I;
984
- const { close: o } = pe(), { widgetCtx: t } = j(), { setIsOpen: n } = K(), { resolveSession: s, sessionState: a } = L(), { isSmallScreen: i } = O(), l = !a.session, d = ((k = a.session) == null ? void 0 : k.isOpened) === !1, h = e.onResolved || "stay-in-chat", y = e.behaviorBeforeSessionCreation || "disabled", v = e.behaviorIfSessionIsResolved || "disabled", m = !!(a.isResolvingSession || l && y === "disabled" || d && v === "disabled"), z = async () => {
985
- const { success: x, error: M } = await s();
986
- if (o(), !x) return console.error(M);
984
+ const { close: o } = pe(), { widgetCtx: t } = j(), { setIsOpen: n } = K(), { resolveSession: s, sessionState: a } = L(), { isSmallScreen: i } = H(), l = !a.session, d = ((k = a.session) == null ? void 0 : k.isOpened) === !1, h = e.onResolved || "stay-in-chat", y = e.behaviorBeforeSessionCreation || "disabled", x = e.behaviorIfSessionIsResolved || "disabled", m = !!(a.isResolvingSession || l && y === "disabled" || d && x === "disabled"), z = async () => {
985
+ const { success: f, error: M } = await s();
986
+ if (o(), !f) return console.error(M);
987
987
  switch (h) {
988
988
  case "stay-in-chat":
989
989
  return;
@@ -1015,7 +1015,7 @@ function Pt({
1015
1015
  );
1016
1016
  }
1017
1017
  if (d)
1018
- switch (v) {
1018
+ switch (x) {
1019
1019
  case "disabled":
1020
1020
  return;
1021
1021
  case "close-widget":
@@ -1031,7 +1031,7 @@ function Pt({
1031
1031
  break;
1032
1032
  default:
1033
1033
  D(
1034
- v,
1034
+ x,
1035
1035
  w.name
1036
1036
  );
1037
1037
  }
@@ -1106,7 +1106,7 @@ const Jr = {
1106
1106
  function eo() {
1107
1107
  const {
1108
1108
  routerState: { screen: e }
1109
- } = A(), { headerButtons: o } = b(), t = e === "chat" ? o == null ? void 0 : o.chatScreen : e === "sessions" ? o == null ? void 0 : o.sessionsScreen : [];
1109
+ } = O(), { headerButtons: o } = b(), t = e === "chat" ? o == null ? void 0 : o.chatScreen : e === "sessions" ? o == null ? void 0 : o.sessionsScreen : [];
1110
1110
  return !t || t.length === 0 ? /* @__PURE__ */ r(fe, { button: Jr }) : /* @__PURE__ */ r(te, { children: t.map((n) => /* @__PURE__ */ r(
1111
1111
  fe,
1112
1112
  {
@@ -1115,10 +1115,10 @@ function eo() {
1115
1115
  `${n.functionality}-${n.icon}`
1116
1116
  )) });
1117
1117
  }
1118
- function At() {
1118
+ function Ot() {
1119
1119
  const {
1120
1120
  routerState: { screen: e }
1121
- } = A(), o = Kr(e), t = Ne();
1121
+ } = O(), o = Kr(e), t = Ne();
1122
1122
  return /* @__PURE__ */ c("header", { ...o, className: "py-2 px-4 shrink-0", children: [
1123
1123
  /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
1124
1124
  /* @__PURE__ */ r(Qr, {}),
@@ -1142,13 +1142,13 @@ function At() {
1142
1142
  /* @__PURE__ */ r(Vr, {})
1143
1143
  ] });
1144
1144
  }
1145
- function Ot({ className: e }) {
1145
+ function Ht({ className: e }) {
1146
1146
  return /* @__PURE__ */ r(wr, { className: p("size-4 animate-spin", e) });
1147
1147
  }
1148
1148
  function to() {
1149
1149
  const {
1150
1150
  messagesState: { isInitialFetchLoading: e }
1151
- } = E(), { isSmallScreen: o } = O(), { activeMode: t, Component: n } = mt();
1151
+ } = E(), { isSmallScreen: o } = H(), { activeMode: t, Component: n } = mt();
1152
1152
  return {
1153
1153
  isCanvasOpen: !e && !o && !!t && !!n
1154
1154
  };
@@ -1221,7 +1221,7 @@ const oo = [
1221
1221
  }
1222
1222
  ];
1223
1223
  function no() {
1224
- const { isSmallScreen: e } = O(), {
1224
+ const { isSmallScreen: e } = H(), {
1225
1225
  submitCsat: o,
1226
1226
  isCsatRequested: t,
1227
1227
  isCsatSubmitted: n,
@@ -1229,7 +1229,7 @@ function no() {
1229
1229
  submittedFeedback: a
1230
1230
  } = gt(), [i, l] = T(null), [d, h] = T(null), y = (m) => {
1231
1231
  l((z) => z === m ? null : m);
1232
- }, v = () => {
1232
+ }, x = () => {
1233
1233
  i && o({
1234
1234
  score: i,
1235
1235
  feedback: d || void 0
@@ -1292,7 +1292,7 @@ function no() {
1292
1292
  C,
1293
1293
  {
1294
1294
  size: "fit",
1295
- onClick: v,
1295
+ onClick: x,
1296
1296
  disabled: !i,
1297
1297
  className: p(
1298
1298
  "transition-all overflow-hidden",
@@ -1434,21 +1434,21 @@ function io({
1434
1434
  }
1435
1435
  function ao() {
1436
1436
  var R;
1437
- const { isSmallScreen: e } = O(), o = de(null), { sendMessage: t } = E(), { sessionState: n } = L(), { t: s } = X(), [a, i] = T(""), {
1437
+ const { isSmallScreen: e } = H(), o = de(null), { sendMessage: t } = E(), { sessionState: n } = L(), { t: s } = X(), [a, i] = T(""), {
1438
1438
  allFiles: l,
1439
1439
  emptyTheFiles: d,
1440
1440
  handleCancelUpload: h,
1441
1441
  appendFiles: y,
1442
- isUploading: v,
1442
+ isUploading: x,
1443
1443
  successFiles: m
1444
- } = Ut(), z = !!((R = n.session) != null && R.isHandedOff), { isAwaitingBotReply: w } = wt(), k = (f) => {
1445
- y(f);
1446
- }, I = !a.trim() && m.length === 0, x = async () => {
1444
+ } = Ut(), z = !!((R = n.session) != null && R.isHandedOff), { isAwaitingBotReply: w } = wt(), k = (v) => {
1445
+ y(v);
1446
+ }, I = !a.trim() && m.length === 0, f = async () => {
1447
1447
  if (w || I) return;
1448
- v && console.info("please wait for the file(s) to upload");
1449
- const f = a.trim();
1448
+ x && console.info("please wait for the file(s) to upload");
1449
+ const v = a.trim();
1450
1450
  t({
1451
- content: f,
1451
+ content: v,
1452
1452
  attachments: m.flatMap(
1453
1453
  (N) => N.fileUrl ? [
1454
1454
  {
@@ -1463,8 +1463,8 @@ function ao() {
1463
1463
  }), i(""), d();
1464
1464
  }, {
1465
1465
  getRootProps: M,
1466
- getInputProps: H,
1467
- open: F
1466
+ getInputProps: F,
1467
+ open: A
1468
1468
  } = Dr({
1469
1469
  onDrop: k,
1470
1470
  noClick: !0,
@@ -1482,8 +1482,8 @@ function ao() {
1482
1482
  "image/gif": [".gif"],
1483
1483
  "image/webp": [".webp"]
1484
1484
  }
1485
- }), W = (f) => {
1486
- const N = f.clipboardData;
1485
+ }), W = (v) => {
1486
+ const N = v.clipboardData;
1487
1487
  N && N.files.length > 0 && k(Array.from(N.files));
1488
1488
  };
1489
1489
  return /* @__PURE__ */ c(
@@ -1493,7 +1493,7 @@ function ao() {
1493
1493
  className: "p-2 relative space-y-1",
1494
1494
  ...M(),
1495
1495
  children: [
1496
- /* @__PURE__ */ r("input", { ...H() }),
1496
+ /* @__PURE__ */ r("input", { ...F() }),
1497
1497
  /* @__PURE__ */ c(
1498
1498
  "div",
1499
1499
  {
@@ -1517,13 +1517,13 @@ function ao() {
1517
1517
  {
1518
1518
  ...g("chat/input_box/attachments_container"),
1519
1519
  className: "flex items-center gap-1",
1520
- children: /* @__PURE__ */ r(_, { mode: "popLayout", children: l.map((f) => /* @__PURE__ */ r(u, { snapExit: !0, children: /* @__PURE__ */ r(
1520
+ children: /* @__PURE__ */ r(_, { mode: "popLayout", children: l.map((v) => /* @__PURE__ */ r(u, { snapExit: !0, children: /* @__PURE__ */ r(
1521
1521
  io,
1522
1522
  {
1523
- onCancel: () => h(f.id),
1524
- file: f
1523
+ onCancel: () => h(v.id),
1524
+ file: v
1525
1525
  }
1526
- ) }, f.id)) })
1526
+ ) }, v.id)) })
1527
1527
  }
1528
1528
  ),
1529
1529
  /* @__PURE__ */ r(
@@ -1546,9 +1546,9 @@ function ao() {
1546
1546
  // 16px on mobiles prevents auto-zoom on the input when focused
1547
1547
  e ? "text-[16px]" : "text-sm"
1548
1548
  ),
1549
- onChange: (f) => i(f.target.value),
1550
- onKeyDown: async (f) => {
1551
- f.key === "Enter" && !f.shiftKey && (f.preventDefault(), x());
1549
+ onChange: (v) => i(v.target.value),
1550
+ onKeyDown: async (v) => {
1551
+ v.key === "Enter" && !v.shiftKey && (v.preventDefault(), f());
1552
1552
  },
1553
1553
  placeholder: s("write_a_message_placeholder")
1554
1554
  }
@@ -1566,7 +1566,7 @@ function ao() {
1566
1566
  children: /* @__PURE__ */ r(
1567
1567
  C,
1568
1568
  {
1569
- onClick: F,
1569
+ onClick: A,
1570
1570
  size: "fit",
1571
1571
  variant: "ghost",
1572
1572
  className: p(
@@ -1581,10 +1581,10 @@ function ao() {
1581
1581
  C,
1582
1582
  {
1583
1583
  size: "fit",
1584
- onClick: x,
1585
- disabled: w || v || I,
1584
+ onClick: f,
1585
+ disabled: w || x || I,
1586
1586
  className: "rounded-full size-8 flex items-center justify-center p-0",
1587
- children: /* @__PURE__ */ r(_, { mode: "wait", children: w || v ? /* @__PURE__ */ r(u, { snapExit: !0, children: /* @__PURE__ */ r(vr, { className: "size-4 animate-spin animate-iteration-infinite" }) }, "loading") : /* @__PURE__ */ r(u, { snapExit: !0, children: /* @__PURE__ */ r(ft, { className: "size-4" }) }, "send") })
1587
+ children: /* @__PURE__ */ r(_, { mode: "wait", children: w || x ? /* @__PURE__ */ r(u, { snapExit: !0, children: /* @__PURE__ */ r(vr, { className: "size-4 animate-spin animate-iteration-infinite" }) }, "loading") : /* @__PURE__ */ r(u, { snapExit: !0, children: /* @__PURE__ */ r(ft, { className: "size-4" }) }, "send") })
1588
1588
  }
1589
1589
  ) })
1590
1590
  ] })
@@ -1596,7 +1596,7 @@ function ao() {
1596
1596
  );
1597
1597
  }
1598
1598
  function lt() {
1599
- const { widgetCtx: e } = j(), { router: o } = b(), { canCreateNewSession: t } = L(), { toSessionsScreen: n } = A(), { t: s } = X();
1599
+ const { widgetCtx: e } = j(), { router: o } = b(), { canCreateNewSession: t } = L(), { toSessionsScreen: n } = O(), { t: s } = X();
1600
1600
  return /* @__PURE__ */ r(te, { children: t || o != null && o.chatScreenOnly ? /* @__PURE__ */ r(C, { onClick: e.resetChat, className: "rounded-2xl w-full", children: s("new_conversation") }) : /* @__PURE__ */ r(C, { onClick: n, className: "rounded-2xl w-full", children: s("back_to_conversations") }) });
1601
1601
  }
1602
1602
  function lo() {
@@ -1673,7 +1673,7 @@ function po({
1673
1673
  }
1674
1674
  );
1675
1675
  }
1676
- function Ht({
1676
+ function Ft({
1677
1677
  messages: e,
1678
1678
  className: o,
1679
1679
  containerClassName: t
@@ -1746,7 +1746,7 @@ function le({
1746
1746
  },
1747
1747
  n.id
1748
1748
  )),
1749
- /* @__PURE__ */ r(Ht, { messages: e })
1749
+ /* @__PURE__ */ r(Ft, { messages: e })
1750
1750
  ]
1751
1751
  }
1752
1752
  )
@@ -1838,7 +1838,7 @@ function go({
1838
1838
  },
1839
1839
  o.id
1840
1840
  )),
1841
- /* @__PURE__ */ r(Ht, { messages: e, containerClassName: "ms-auto" })
1841
+ /* @__PURE__ */ r(Ft, { messages: e, containerClassName: "ms-auto" })
1842
1842
  ]
1843
1843
  }
1844
1844
  );
@@ -1961,13 +1961,13 @@ function Co() {
1961
1961
  /* @__PURE__ */ r(yo, {}),
1962
1962
  a.map((h, y) => {
1963
1963
  var z, w, k, I;
1964
- const v = (z = h == null ? void 0 : h[0]) == null ? void 0 : z.type, m = (w = h[0]) == null ? void 0 : w.id;
1965
- if (!v || !m) return null;
1964
+ const x = (z = h == null ? void 0 : h[0]) == null ? void 0 : z.type, m = (w = h[0]) == null ? void 0 : w.id;
1965
+ if (!x || !m) return null;
1966
1966
  if (uo(h))
1967
1967
  return /* @__PURE__ */ r(go, { messages: h }, m);
1968
1968
  if (fo(h)) {
1969
- const x = y === a.length - 1;
1970
- return o && x ? null : ((k = h[0]) == null || k.agent, /* @__PURE__ */ r(
1969
+ const f = y === a.length - 1;
1970
+ return o && f ? null : ((k = h[0]) == null || k.agent, /* @__PURE__ */ r(
1971
1971
  le,
1972
1972
  {
1973
1973
  messages: h,
@@ -1977,18 +1977,19 @@ function Co() {
1977
1977
  ));
1978
1978
  }
1979
1979
  if (vo(h)) {
1980
- const x = (I = h[0]) == null ? void 0 : I.agent;
1980
+ const f = (I = h[0]) == null ? void 0 : I.agent;
1981
1981
  return /* @__PURE__ */ r(
1982
1982
  le,
1983
1983
  {
1984
1984
  messages: h,
1985
- agent: x ? {
1986
- ...x,
1987
- avatarUrl: (s == null ? void 0 : s.avatarUrl) || x.avatarUrl || null
1985
+ agent: f ? {
1986
+ ...f,
1987
+ name: (s == null ? void 0 : s.name) || f.name || "",
1988
+ avatarUrl: (s == null ? void 0 : s.avatarUrl) || f.avatarUrl || null
1988
1989
  } : s ? {
1989
1990
  isAi: !1,
1990
1991
  id: null,
1991
- name: "",
1992
+ name: s.name || "",
1992
1993
  avatarUrl: s.avatarUrl || null
1993
1994
  } : void 0
1994
1995
  },
@@ -2031,12 +2032,12 @@ function zo() {
2031
2032
  // Relative to the iframe
2032
2033
  },
2033
2034
  children: /* @__PURE__ */ c("div", { className: "size-full justify-between flex flex-col", children: [
2034
- /* @__PURE__ */ r(At, {}),
2035
+ /* @__PURE__ */ r(Ot, {}),
2035
2036
  /* @__PURE__ */ r(_, { mode: "wait", children: e ? /* @__PURE__ */ r(
2036
2037
  u,
2037
2038
  {
2038
2039
  className: "flex flex-col items-center justify-center w-full flex-1",
2039
- children: /* @__PURE__ */ r(Ot, {})
2040
+ children: /* @__PURE__ */ r(Ht, {})
2040
2041
  },
2041
2042
  "loading"
2042
2043
  ) : /* @__PURE__ */ c(
@@ -2118,7 +2119,7 @@ function So({ className: e }) {
2118
2119
  }
2119
2120
  );
2120
2121
  }
2121
- function Ft({ className: e }) {
2122
+ function At({ className: e }) {
2122
2123
  const { token: o } = b();
2123
2124
  return /* @__PURE__ */ r(
2124
2125
  "div",
@@ -2158,7 +2159,7 @@ function ct({
2158
2159
  session: e,
2159
2160
  className: o
2160
2161
  }) {
2161
- const { bot: t, humanAgent: n } = b(), { toChatScreen: s } = A(), a = e.assignee.kind === "human" ? e.assignee.name || "Support Agent" : (t == null ? void 0 : t.name) || "AI Support Agent", i = e.assignee.kind === "human" ? (n == null ? void 0 : n.avatarUrl) || e.assignee.avatarUrl || "" : (t == null ? void 0 : t.avatarUrl) || (t == null ? void 0 : t.avatar) || "";
2162
+ const { bot: t, humanAgent: n } = b(), { toChatScreen: s } = O(), a = e.assignee.kind === "human" ? (n == null ? void 0 : n.name) || e.assignee.name || "Support Agent" : (t == null ? void 0 : t.name) || "AI Support Agent", i = e.assignee.kind === "human" ? (n == null ? void 0 : n.avatarUrl) || e.assignee.avatarUrl || "" : (t == null ? void 0 : t.avatarUrl) || (t == null ? void 0 : t.avatar) || "";
2162
2163
  return /* @__PURE__ */ c(
2163
2164
  C,
2164
2165
  {
@@ -2194,7 +2195,7 @@ function ct({
2194
2195
  );
2195
2196
  }
2196
2197
  function Io() {
2197
- const { t: e } = X(), { toChatScreen: o } = A(), {
2198
+ const { t: e } = X(), { toChatScreen: o } = O(), {
2198
2199
  sessionsState: { data: t, isInitialFetchLoading: n },
2199
2200
  openSessions: s,
2200
2201
  closedSessions: a,
@@ -2204,7 +2205,7 @@ function Io() {
2204
2205
  u,
2205
2206
  {
2206
2207
  className: "flex-1 flex items-center justify-center",
2207
- children: /* @__PURE__ */ r(Ot, {})
2208
+ children: /* @__PURE__ */ r(Ht, {})
2208
2209
  },
2209
2210
  "loading"
2210
2211
  ) : /* @__PURE__ */ r(
@@ -2295,16 +2296,16 @@ function To() {
2295
2296
  // Relative to the iframe
2296
2297
  },
2297
2298
  children: /* @__PURE__ */ c("div", { className: "size-full flex flex-col", children: [
2298
- /* @__PURE__ */ r(At, {}),
2299
+ /* @__PURE__ */ r(Ot, {}),
2299
2300
  /* @__PURE__ */ r(Io, {}),
2300
- /* @__PURE__ */ r(Ft, {})
2301
+ /* @__PURE__ */ r(At, {})
2301
2302
  ] })
2302
2303
  }
2303
2304
  );
2304
2305
  }
2305
2306
  const ae = G.forwardRef(
2306
2307
  ({ className: e, type: o, ...t }, n) => {
2307
- const { isSmallScreen: s } = O();
2308
+ const { isSmallScreen: s } = H();
2308
2309
  return /* @__PURE__ */ r($, { ref: n, children: /* @__PURE__ */ r(
2309
2310
  "input",
2310
2311
  {
@@ -2350,15 +2351,15 @@ const Do = me.object({
2350
2351
  email: me.string().email()
2351
2352
  });
2352
2353
  function jo() {
2353
- var x, M, H, F, W, R, f, N;
2354
+ var f, M, F, A, W, R, v, N;
2354
2355
  const {
2355
2356
  widgetCtx: { org: e }
2356
- } = j(), { setIsOpen: o } = K(), { createUnverifiedContact: t } = qt(), { isSmallScreen: n } = O(), s = b(), { theme: a } = q(), { t: i } = X(), { observedElementRef: l } = Mo();
2357
+ } = j(), { setIsOpen: o } = K(), { createUnverifiedContact: t } = qt(), { isSmallScreen: n } = H(), s = b(), { theme: a } = q(), { t: i } = X(), { observedElementRef: l } = Mo();
2357
2358
  ze({
2358
2359
  height: void 0,
2359
2360
  width: a.screens.welcome.width
2360
2361
  });
2361
- const [d, h] = T(((x = s.prefillUserData) == null ? void 0 : x.name) || ""), [y, v] = T(((M = s.prefillUserData) == null ? void 0 : M.email) || ""), m = (s.extraDataCollectionFields || []).filter(
2362
+ const [d, h] = T(((f = s.prefillUserData) == null ? void 0 : f.name) || ""), [y, x] = T(((M = s.prefillUserData) == null ? void 0 : M.email) || ""), m = (s.extraDataCollectionFields || []).filter(
2362
2363
  (S) => S !== "name" && S !== "email" && !!S
2363
2364
  ), [z, w] = T({}), [k, I] = jr(
2364
2365
  async (S) => {
@@ -2409,17 +2410,17 @@ function jo() {
2409
2410
  ),
2410
2411
  children: [
2411
2412
  n && /* @__PURE__ */ r(u, { className: "absolute top-6 end-6", children: /* @__PURE__ */ r(C, { size: "selfless", onClick: () => o(!1), children: /* @__PURE__ */ r(xe, { className: "size-4" }) }) }),
2412
- /* @__PURE__ */ r("div", { className: "flex items-center justify-between w-full mb-2", children: (H = s.assets) != null && H.organizationLogo ? /* @__PURE__ */ r(
2413
+ /* @__PURE__ */ r("div", { className: "flex items-center justify-between w-full mb-2", children: (F = s.assets) != null && F.organizationLogo ? /* @__PURE__ */ r(
2413
2414
  "img",
2414
2415
  {
2415
- src: (F = s.assets) == null ? void 0 : F.organizationLogo,
2416
+ src: (A = s.assets) == null ? void 0 : A.organizationLogo,
2416
2417
  alt: "Company Logo",
2417
2418
  className: "h-8 w-auto object-contain"
2418
2419
  }
2419
2420
  ) : /* @__PURE__ */ r("h2", { className: "font-bold text-sm", children: e.name }) }),
2420
2421
  /* @__PURE__ */ c("div", { className: "space-y-2", children: [
2421
2422
  /* @__PURE__ */ r("h1", { className: "text-[1.75rem] font-semibold tracking-tight leading-none", children: ((R = (W = s.textContent) == null ? void 0 : W.welcomeScreen) == null ? void 0 : R.title) || i("welcome_screen_title") }),
2422
- /* @__PURE__ */ r("p", { className: "text-sm", children: ((N = (f = s.textContent) == null ? void 0 : f.welcomeScreen) == null ? void 0 : N.description) || i("welcome_screen_description") })
2423
+ /* @__PURE__ */ r("p", { className: "text-sm", children: ((N = (v = s.textContent) == null ? void 0 : v.welcomeScreen) == null ? void 0 : N.description) || i("welcome_screen_description") })
2423
2424
  ] })
2424
2425
  ]
2425
2426
  }
@@ -2450,7 +2451,7 @@ function jo() {
2450
2451
  {
2451
2452
  required: !0,
2452
2453
  value: y,
2453
- onChange: (S) => v(S.target.value),
2454
+ onChange: (S) => x(S.target.value),
2454
2455
  type: "email",
2455
2456
  placeholder: i("your_email_placeholder"),
2456
2457
  name: "email"
@@ -2481,7 +2482,7 @@ function jo() {
2481
2482
  }
2482
2483
  )
2483
2484
  ] }),
2484
- /* @__PURE__ */ r(Ft, {})
2485
+ /* @__PURE__ */ r(At, {})
2485
2486
  ]
2486
2487
  }
2487
2488
  )
@@ -2494,7 +2495,7 @@ function jo() {
2494
2495
  function Wt() {
2495
2496
  const {
2496
2497
  routerState: { screen: e }
2497
- } = A();
2498
+ } = O();
2498
2499
  return /* @__PURE__ */ r("div", { className: "relative bg-background size-full", children: /* @__PURE__ */ r(_, { mode: "wait", children: (() => {
2499
2500
  switch (e) {
2500
2501
  case "welcome":
@@ -2535,7 +2536,7 @@ function Wt() {
2535
2536
  }
2536
2537
  })() }) });
2537
2538
  }
2538
- const Eo = "4.0.36", Ro = `<!DOCTYPE html>
2539
+ const Eo = "4.0.38", Ro = `<!DOCTYPE html>
2539
2540
  <html>
2540
2541
  <head>
2541
2542
  <style>
@@ -2658,7 +2659,7 @@ function Po() {
2658
2659
  }
2659
2660
  );
2660
2661
  }
2661
- function Ao({
2662
+ function Oo({
2662
2663
  className: e,
2663
2664
  style: o
2664
2665
  }) {
@@ -2693,7 +2694,7 @@ function Ao({
2693
2694
  }
2694
2695
  );
2695
2696
  }
2696
- const Oo = `<!DOCTYPE html>
2697
+ const Ho = `<!DOCTYPE html>
2697
2698
  <html>
2698
2699
  <head>
2699
2700
  <style>
@@ -2710,13 +2711,13 @@ html, body {
2710
2711
  <body>
2711
2712
  </body>
2712
2713
  </html>`;
2713
- function Ho() {
2714
+ function Fo() {
2714
2715
  var a, i;
2715
2716
  const { isOpen: e } = K(), { cssOverrides: o, assets: t } = b(), { theme: n, cssVars: s } = q();
2716
2717
  return /* @__PURE__ */ c(
2717
2718
  bt,
2718
2719
  {
2719
- initialContent: Oo,
2720
+ initialContent: Ho,
2720
2721
  title: "OpenCX Live Chat Trigger",
2721
2722
  style: {
2722
2723
  height: `calc(${n.widgetTrigger.size.button}px + ${V.x * 2}px)`,
@@ -2817,7 +2818,7 @@ function Ho() {
2817
2818
  }
2818
2819
  }
2819
2820
  ) : /* @__PURE__ */ r(
2820
- Ao,
2821
+ Oo,
2821
2822
  {
2822
2823
  style: {
2823
2824
  width: n.widgetTrigger.size.icon,
@@ -2839,7 +2840,7 @@ function Ho() {
2839
2840
  }
2840
2841
  );
2841
2842
  }
2842
- function Fo() {
2843
+ function Ao() {
2843
2844
  const { dir: e } = ve();
2844
2845
  return /* @__PURE__ */ r(
2845
2846
  ce.Anchor,
@@ -2856,8 +2857,8 @@ function Fo() {
2856
2857
  function Wo() {
2857
2858
  const { isOpen: e, setIsOpen: o } = K();
2858
2859
  return /* @__PURE__ */ c(ce.Root, { open: e, onOpenChange: o, children: [
2860
+ /* @__PURE__ */ r(Ao, {}),
2859
2861
  /* @__PURE__ */ r(Fo, {}),
2860
- /* @__PURE__ */ r(Ho, {}),
2861
2862
  /* @__PURE__ */ r(Po, {})
2862
2863
  ] });
2863
2864
  }