@opencx/widget-react 4.0.12 → 4.0.14

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
@@ -1,8 +1,8 @@
1
1
  import { jsx as o, jsxs as d, Fragment as oe } from "react/jsx-runtime";
2
2
  import * as le from "@radix-ui/react-popover";
3
3
  import * as K from "react";
4
- import q, { memo as Yt, forwardRef as lt, useState as I, cloneElement as ct, createContext as $t, useEffect as re, useContext as qt, useMemo as dt, useRef as ce, createElement as ot } from "react";
5
- import { useWidget as $, useConfig as y, useDocumentDir as ve, useWidgetRouter as F, usePreludeData as de, useWidgetTrigger as Z, useSessions as U, useMessages as E, useModes as pt, useCsat as ht, useUploadFiles as Ut, useIsAwaitingBotReply as mt, useContact as Vt, WidgetProvider as Xt, WidgetTriggerProvider as Gt } from "@opencx/widget-react-headless";
4
+ import $, { memo as Yt, forwardRef as lt, useState as I, cloneElement as ct, createContext as $t, useEffect as re, useContext as qt, useMemo as dt, useRef as ce, createElement as ot } from "react";
5
+ import { useWidget as q, useConfig as x, useDocumentDir as ve, useWidgetRouter as F, usePreludeData as de, useWidgetTrigger as Z, useSessions as U, useMessages as E, useModes as pt, useCsat as ht, useUploadFiles as Ut, useIsAwaitingBotReply as mt, useContact as Vt, WidgetProvider as Xt, WidgetTriggerProvider as Gt } from "@opencx/widget-react-headless";
6
6
  import { clsx as Kt } from "clsx";
7
7
  import { twMerge as Zt } from "tailwind-merge";
8
8
  import { motion as J, AnimatePresence as N } from "framer-motion";
@@ -38,13 +38,13 @@ const G = {
38
38
  )) return e;
39
39
  const b = (f) => {
40
40
  var C, B;
41
- const { clientX: z, clientY: T } = f, S = f.currentTarget.getBoundingClientRect(), M = z - (S.left + S.width / 2), P = T - (S.top + S.height / 2), A = Math.max(
41
+ const { clientX: z, clientY: T } = f, S = f.currentTarget.getBoundingClientRect(), M = z - (S.left + S.width / 2), O = T - (S.top + S.height / 2), P = Math.max(
42
42
  -1,
43
43
  Math.min(1, M / (S.width / 2))
44
- ), O = Math.max(
44
+ ), A = Math.max(
45
45
  -1,
46
- Math.min(1, P / (S.height / 2))
47
- ), j = A * G.x, v = O * G.y;
46
+ Math.min(1, O / (S.height / 2))
47
+ ), j = P * G.x, v = A * G.y;
48
48
  l({ x: j, y: v }), (B = (C = e.props).onMouseMove) == null || B.call(C, f);
49
49
  }, w = () => {
50
50
  var f, z;
@@ -83,23 +83,23 @@ const Eo = 10, Ro = (e, r, t) => ({
83
83
  initial: { opacity: 0, x: -e, ...r.initial },
84
84
  animate: { opacity: 1, x: 0, ...r.animate, transition: { delay: t } },
85
85
  exit: { opacity: 0, x: e, ...r.exit }
86
- }), Po = (e, r, t) => ({
86
+ }), Oo = (e, r, t) => ({
87
87
  initial: { opacity: 0, x: e, ...r.initial },
88
88
  animate: { opacity: 1, x: 0, ...r.animate, transition: { delay: t } },
89
89
  exit: { opacity: 0, x: -e, ...r.exit }
90
- }), Ao = (e, r, t) => ({
90
+ }), Po = (e, r, t) => ({
91
91
  initial: { opacity: 0, y: e, ...r.initial },
92
92
  animate: { opacity: 1, y: 0, ...r.animate, transition: { delay: t } },
93
93
  exit: { opacity: 0, y: -e, ...r.exit }
94
- }), Oo = (e, r, t) => ({
94
+ }), Ao = (e, r, t) => ({
95
95
  initial: { opacity: 0, y: -e, ...r.initial },
96
96
  animate: { opacity: 1, y: 0, ...r.animate, transition: { delay: t } },
97
97
  exit: { opacity: 0, y: e, ...r.exit }
98
98
  }), Wo = {
99
99
  right: Ro,
100
- left: Po,
101
- up: Ao,
102
- down: Oo
100
+ left: Oo,
101
+ up: Po,
102
+ down: Ao
103
103
  }, g = lt(
104
104
  ({
105
105
  fadeIn: e = "down",
@@ -154,7 +154,7 @@ const Ho = Jt(
154
154
  size: "default"
155
155
  }
156
156
  }
157
- ), x = K.forwardRef(
157
+ ), y = K.forwardRef(
158
158
  ({ className: e, variant: r = "default", size: t, asChild: n = !1, ...s }, a) => /* @__PURE__ */ o(W, { ref: a, children: /* @__PURE__ */ o(
159
159
  n ? Qt : "button",
160
160
  {
@@ -165,7 +165,7 @@ const Ho = Jt(
165
165
  }
166
166
  ) })
167
167
  );
168
- x.displayName = "Button";
168
+ y.displayName = "Button";
169
169
  const bt = $t(null);
170
170
  function Fo({ children: e }) {
171
171
  const [r, t] = I(!1), [n, s] = I(null), a = (c) => {
@@ -198,7 +198,7 @@ function pe() {
198
198
  });
199
199
  }
200
200
  function Bo() {
201
- const { contentIframeRef: e } = $(), { isOpen: r, content: t, close: n } = pe();
201
+ const { contentIframeRef: e } = q(), { isOpen: r, content: t, close: n } = pe();
202
202
  return re(() => {
203
203
  var a, i;
204
204
  const s = (c) => {
@@ -246,7 +246,7 @@ function xt({
246
246
  children: [
247
247
  e,
248
248
  t && /* @__PURE__ */ d(
249
- x,
249
+ y,
250
250
  {
251
251
  size: "fit",
252
252
  className: "rounded-full absolute top-4 right-4",
@@ -289,7 +289,7 @@ const Ct = ({
289
289
  ...r
290
290
  }) => /* @__PURE__ */ o("div", { className: p("flex flex-col gap-2", e), ...r });
291
291
  Ct.displayName = "DialogerFooter";
292
- const zt = q.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ o(
292
+ const zt = $.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ o(
293
293
  "p",
294
294
  {
295
295
  ref: t,
@@ -301,7 +301,7 @@ const zt = q.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ o(
301
301
  }
302
302
  ));
303
303
  zt.displayName = "DialogerTitle";
304
- const Nt = q.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ o(
304
+ const Nt = $.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ o(
305
305
  "p",
306
306
  {
307
307
  ref: t,
@@ -361,7 +361,7 @@ function _t({ attachment: e }) {
361
361
  }
362
362
  );
363
363
  }
364
- const It = q.memo(
364
+ const It = $.memo(
365
365
  Mo,
366
366
  (e, r) => e.children === r.children && e.className === r.className
367
367
  );
@@ -370,7 +370,7 @@ function Tt({
370
370
  messageType: r,
371
371
  messageId: t
372
372
  }) {
373
- const { anchorTarget: n } = y();
373
+ const { anchorTarget: n } = x();
374
374
  return /* @__PURE__ */ o(
375
375
  It,
376
376
  {
@@ -529,7 +529,7 @@ function ee({
529
529
  side: t,
530
530
  align: n
531
531
  }) {
532
- const { disableTooltips: s } = y();
532
+ const { disableTooltips: s } = x();
533
533
  return !r || s ? e : /* @__PURE__ */ d(qo, { children: [
534
534
  /* @__PURE__ */ o(Uo, { asChild: !0, children: e }),
535
535
  /* @__PURE__ */ o(
@@ -546,8 +546,8 @@ function ee({
546
546
  }
547
547
  const nt = 450;
548
548
  function R() {
549
- const [e, r] = q.useState(() => (window.top || window).innerWidth < nt);
550
- return q.useEffect(() => {
549
+ const [e, r] = $.useState(() => (window.top || window).innerWidth < nt);
550
+ return $.useEffect(() => {
551
551
  const t = window.top || window, n = () => {
552
552
  r(t.innerWidth < nt);
553
553
  };
@@ -561,8 +561,8 @@ const ae = {
561
561
  transitionDuration: "1000ms"
562
562
  };
563
563
  function V() {
564
- var w, m, k, f, z, T, S, M, P, A, O, j, v, C, B, _, L, se, _e, Ie, Te, Me, De, je, Ee, Re, Pe, Ae, Oe, We, He, Fe, Be, Le, Ye, $e, qe, Ue, Ve, Xe, Ge, Ke, Ze, Qe, Je, et, tt;
565
- const { dir: e } = ve(), { isSmallScreen: r } = R(), { theme: t, inline: n } = y(), s = (Y) => n ? "100%" : Y, a = (Y, he) => r ? `100dv${Y}` : he, i = (Y, he) => s(a(Y, he)), c = {
564
+ var w, m, k, f, z, T, S, M, O, P, A, j, v, C, B, _, L, se, _e, Ie, Te, Me, De, je, Ee, Re, Oe, Pe, Ae, We, He, Fe, Be, Le, Ye, $e, qe, Ue, Ve, Xe, Ge, Ke, Ze, Qe, Je, et, tt;
565
+ const { dir: e } = ve(), { isSmallScreen: r } = R(), { theme: t, inline: n } = x(), s = (Y) => n ? "100%" : Y, a = (Y, he) => r ? `100dv${Y}` : he, i = (Y, he) => s(a(Y, he)), c = {
566
566
  zIndex: ((w = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : w.zIndex) ?? 1e7,
567
567
  offset: {
568
568
  bottom: ((k = (m = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : m.offset) == null ? void 0 : k.bottom) ?? 20,
@@ -570,8 +570,8 @@ function V() {
570
570
  left: ((S = (T = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : T.offset) == null ? void 0 : S.left) ?? (e === "rtl" ? 20 : "initial")
571
571
  },
572
572
  size: {
573
- button: ((P = (M = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : M.size) == null ? void 0 : P.button) ?? 48,
574
- icon: ((O = (A = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : A.size) == null ? void 0 : O.icon) ?? 24
573
+ button: ((O = (M = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : M.size) == null ? void 0 : O.button) ?? 48,
574
+ icon: ((A = (P = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : P.size) == null ? void 0 : A.icon) ?? 24
575
575
  }
576
576
  }, l = (() => {
577
577
  const Y = e === "ltr" ? c.offset.right : c.offset.left;
@@ -601,11 +601,11 @@ function V() {
601
601
  // By setting minHeight to 1px, a nice animation will play from 1px to the dynamic height of the content of the screen
602
602
  minHeight: i(
603
603
  "h",
604
- ((Pe = (Re = t == null ? void 0 : t.screens) == null ? void 0 : Re.welcome) == null ? void 0 : Pe.minHeight) ?? "1px"
604
+ ((Oe = (Re = t == null ? void 0 : t.screens) == null ? void 0 : Re.welcome) == null ? void 0 : Oe.minHeight) ?? "1px"
605
605
  )
606
606
  },
607
607
  sessions: {
608
- width: i("w", ((Oe = (Ae = t == null ? void 0 : t.screens) == null ? void 0 : Ae.sessions) == null ? void 0 : Oe.width) ?? "450px"),
608
+ width: i("w", ((Ae = (Pe = t == null ? void 0 : t.screens) == null ? void 0 : Pe.sessions) == null ? void 0 : Ae.width) ?? "450px"),
609
609
  height: i("h", ((He = (We = t == null ? void 0 : t.screens) == null ? void 0 : We.sessions) == null ? void 0 : He.height) ?? "600px")
610
610
  },
611
611
  chat: {
@@ -759,7 +759,7 @@ function jt(e) {
759
759
  }
760
760
  }
761
761
  function Et() {
762
- const { contentIframeRef: e } = $(), { inline: r } = y();
762
+ const { contentIframeRef: e } = q(), { inline: r } = x();
763
763
  return {
764
764
  setWidth: (t) => {
765
765
  var n;
@@ -847,7 +847,7 @@ function ze() {
847
847
  var s;
848
848
  const { data: e } = de(), {
849
849
  routerState: { screen: r }
850
- } = F(), { textContent: t } = y();
850
+ } = F(), { textContent: t } = x();
851
851
  return (() => {
852
852
  var a, i;
853
853
  switch (r) {
@@ -877,12 +877,12 @@ function Xo(e) {
877
877
  }
878
878
  }
879
879
  function Go() {
880
- const { router: e } = y(), {
880
+ const { router: e } = x(), {
881
881
  routerState: { screen: r },
882
882
  toSessionsScreen: t
883
883
  } = F();
884
884
  return r !== "chat" || e != null && e.chatScreenOnly ? null : /* @__PURE__ */ o(
885
- x,
885
+ y,
886
886
  {
887
887
  variant: "ghost",
888
888
  size: "fit",
@@ -897,7 +897,7 @@ function Ko({
897
897
  }) {
898
898
  const { setIsOpen: r } = Z(), { isSmallScreen: t } = R();
899
899
  return t && e.hideOnSmallScreen || !t && e.hideOnLargeScreen ? null : /* @__PURE__ */ o(
900
- x,
900
+ y,
901
901
  {
902
902
  variant: "ghost",
903
903
  size: "fit",
@@ -942,7 +942,7 @@ function we({
942
942
  });
943
943
  };
944
944
  return s && e.hideOnSmallScreen || !s && e.hideOnLargeScreen ? null : /* @__PURE__ */ o(
945
- x,
945
+ y,
946
946
  {
947
947
  variant: "ghost",
948
948
  size: "fit",
@@ -957,11 +957,11 @@ function we({
957
957
  }
958
958
  );
959
959
  }
960
- function Pt({
960
+ function Ot({
961
961
  button: e
962
962
  }) {
963
963
  var z, T;
964
- const { close: r } = pe(), { widgetCtx: t } = $(), { setIsOpen: n } = Z(), { resolveSession: s, sessionState: a } = U(), { isSmallScreen: i } = R(), c = !a.session, l = ((z = a.session) == null ? void 0 : z.isOpened) === !1, h = e.onResolved || "stay-in-chat", b = e.behaviorBeforeSessionCreation || "disabled", w = e.behaviorIfSessionIsResolved || "disabled", m = !!(a.isResolvingSession || c && b === "disabled" || l && w === "disabled"), k = async () => {
964
+ const { close: r } = pe(), { widgetCtx: t } = q(), { setIsOpen: n } = Z(), { resolveSession: s, sessionState: a } = U(), { isSmallScreen: i } = R(), c = !a.session, l = ((z = a.session) == null ? void 0 : z.isOpened) === !1, h = e.onResolved || "stay-in-chat", b = e.behaviorBeforeSessionCreation || "disabled", w = e.behaviorIfSessionIsResolved || "disabled", m = !!(a.isResolvingSession || c && b === "disabled" || l && w === "disabled"), k = async () => {
965
965
  const { success: S, error: M } = await s();
966
966
  if (r(), !S) return console.error(M);
967
967
  switch (h) {
@@ -977,7 +977,7 @@ function Pt({
977
977
  n(!1), t.resetChat();
978
978
  break;
979
979
  default:
980
- D(h, Pt.name);
980
+ D(h, Ot.name);
981
981
  break;
982
982
  }
983
983
  }, f = () => {
@@ -1020,7 +1020,7 @@ function Pt({
1020
1020
  St,
1021
1021
  {
1022
1022
  trigger: /* @__PURE__ */ o(
1023
- x,
1023
+ y,
1024
1024
  {
1025
1025
  variant: "ghost",
1026
1026
  size: "fit",
@@ -1034,7 +1034,7 @@ function Pt({
1034
1034
  /* @__PURE__ */ o(kt, { children: /* @__PURE__ */ o(Nt, { children: e.confirmation.description || "Are you sure you want to close this conversation?" }) }),
1035
1035
  /* @__PURE__ */ d(Ct, { children: [
1036
1036
  /* @__PURE__ */ o(
1037
- x,
1037
+ y,
1038
1038
  {
1039
1039
  variant: "secondary",
1040
1040
  onClick: r,
@@ -1043,7 +1043,7 @@ function Pt({
1043
1043
  }
1044
1044
  ),
1045
1045
  /* @__PURE__ */ o(
1046
- x,
1046
+ y,
1047
1047
  {
1048
1048
  variant: "destructive",
1049
1049
  onClick: k,
@@ -1055,7 +1055,7 @@ function Pt({
1055
1055
  ] })
1056
1056
  }
1057
1057
  ) : /* @__PURE__ */ o(
1058
- x,
1058
+ y,
1059
1059
  {
1060
1060
  variant: "ghost",
1061
1061
  size: "fit",
@@ -1073,7 +1073,7 @@ function fe({ button: e }) {
1073
1073
  case "expand-shrink":
1074
1074
  return /* @__PURE__ */ o(we, { button: e });
1075
1075
  case "resolve-session":
1076
- return /* @__PURE__ */ o(Pt, { button: e });
1076
+ return /* @__PURE__ */ o(Ot, { button: e });
1077
1077
  default:
1078
1078
  return D(e, fe.name), null;
1079
1079
  }
@@ -1086,7 +1086,7 @@ const Zo = {
1086
1086
  function Qo() {
1087
1087
  const {
1088
1088
  routerState: { screen: e }
1089
- } = F(), { headerButtons: r } = y(), t = e === "chat" ? r == null ? void 0 : r.chatScreen : e === "sessions" ? r == null ? void 0 : r.sessionsScreen : [];
1089
+ } = F(), { headerButtons: r } = x(), t = e === "chat" ? r == null ? void 0 : r.chatScreen : e === "sessions" ? r == null ? void 0 : r.sessionsScreen : [];
1090
1090
  return !t || t.length === 0 ? /* @__PURE__ */ o(fe, { button: Zo }) : /* @__PURE__ */ o(oe, { children: t.map((n) => /* @__PURE__ */ o(
1091
1091
  fe,
1092
1092
  {
@@ -1095,7 +1095,7 @@ function Qo() {
1095
1095
  `${n.functionality}-${n.icon}`
1096
1096
  )) });
1097
1097
  }
1098
- function At() {
1098
+ function Pt() {
1099
1099
  const {
1100
1100
  routerState: { screen: e }
1101
1101
  } = F(), { isLoading: r } = de(), t = Xo(e), n = ze();
@@ -1114,7 +1114,7 @@ function At() {
1114
1114
  /* @__PURE__ */ o(Qo, {})
1115
1115
  ] }) });
1116
1116
  }
1117
- function Ot({ className: e }) {
1117
+ function At({ className: e }) {
1118
1118
  return /* @__PURE__ */ o(fo, { className: p("size-4 animate-spin", e) });
1119
1119
  }
1120
1120
  function Jo() {
@@ -1138,7 +1138,7 @@ function er() {
1138
1138
  return !e || !r ? null : /* @__PURE__ */ o(
1139
1139
  r,
1140
1140
  {
1141
- react: q,
1141
+ react: $,
1142
1142
  mode: e,
1143
1143
  createStateCheckpoint: n,
1144
1144
  sendMessage: i,
@@ -1146,7 +1146,7 @@ function er() {
1146
1146
  }
1147
1147
  );
1148
1148
  }
1149
- const H = q.forwardRef(
1149
+ const H = $.forwardRef(
1150
1150
  (e, r) => {
1151
1151
  var t, n, s;
1152
1152
  return /* @__PURE__ */ o(
@@ -1218,7 +1218,7 @@ function or() {
1218
1218
  n && "gap-0 justify-center"
1219
1219
  ),
1220
1220
  children: tr.map((m) => /* @__PURE__ */ o(
1221
- x,
1221
+ y,
1222
1222
  {
1223
1223
  variant: m.value === i ? "secondary" : "ghost",
1224
1224
  size: "selfless",
@@ -1261,7 +1261,7 @@ function or() {
1261
1261
  }
1262
1262
  ),
1263
1263
  /* @__PURE__ */ o(
1264
- x,
1264
+ y,
1265
1265
  {
1266
1266
  size: "fit",
1267
1267
  onClick: w,
@@ -1424,7 +1424,7 @@ function mr(e, r) {
1424
1424
  return t && t[e] || "";
1425
1425
  }
1426
1426
  function X() {
1427
- const { dir: e } = ve(), r = y();
1427
+ const { dir: e } = ve(), r = x();
1428
1428
  return dt(() => {
1429
1429
  const t = hr(r.language) ? r.language : "en";
1430
1430
  return {
@@ -1445,7 +1445,7 @@ function Ne({
1445
1445
  a && n({ content: a });
1446
1446
  };
1447
1447
  return /* @__PURE__ */ o(
1448
- x,
1448
+ y,
1449
1449
  {
1450
1450
  ...u("chat/suggested_reply_btn"),
1451
1451
  size: "sm",
@@ -1579,8 +1579,8 @@ function wr() {
1579
1579
  }), i(""), l();
1580
1580
  }, {
1581
1581
  getRootProps: M,
1582
- getInputProps: P,
1583
- open: A
1582
+ getInputProps: O,
1583
+ open: P
1584
1584
  } = Do({
1585
1585
  onDrop: z,
1586
1586
  noClick: !0,
@@ -1598,7 +1598,7 @@ function wr() {
1598
1598
  "image/gif": [".gif"],
1599
1599
  "image/webp": [".webp"]
1600
1600
  }
1601
- }), O = (v) => {
1601
+ }), A = (v) => {
1602
1602
  const C = v.clipboardData;
1603
1603
  C && C.files.length > 0 && z(Array.from(C.files));
1604
1604
  };
@@ -1609,7 +1609,7 @@ function wr() {
1609
1609
  className: "p-2 relative space-y-1",
1610
1610
  ...M(),
1611
1611
  children: [
1612
- /* @__PURE__ */ o("input", { ...P() }),
1612
+ /* @__PURE__ */ o("input", { ...O() }),
1613
1613
  /* @__PURE__ */ d(
1614
1614
  "div",
1615
1615
  {
@@ -1646,7 +1646,7 @@ function wr() {
1646
1646
  "textarea",
1647
1647
  {
1648
1648
  ...u("chat/input_box/textarea"),
1649
- onPaste: O,
1649
+ onPaste: A,
1650
1650
  ref: r,
1651
1651
  id: "chat-input",
1652
1652
  value: a,
@@ -1680,9 +1680,9 @@ function wr() {
1680
1680
  align: "start",
1681
1681
  content: "attach files, (maximum size 5mb)",
1682
1682
  children: /* @__PURE__ */ o(
1683
- x,
1683
+ y,
1684
1684
  {
1685
- onClick: A,
1685
+ onClick: P,
1686
1686
  size: "fit",
1687
1687
  variant: "ghost",
1688
1688
  className: p(
@@ -1694,7 +1694,7 @@ function wr() {
1694
1694
  }
1695
1695
  ),
1696
1696
  /* @__PURE__ */ o(ee, { content: "send message", side: "top", align: "end", children: /* @__PURE__ */ o(
1697
- x,
1697
+ y,
1698
1698
  {
1699
1699
  size: "fit",
1700
1700
  onClick: S,
@@ -1712,8 +1712,8 @@ function wr() {
1712
1712
  );
1713
1713
  }
1714
1714
  function at() {
1715
- const { widgetCtx: e } = $(), { router: r } = y(), { canCreateNewSession: t } = U(), { toSessionsScreen: n } = F(), { t: s } = X();
1716
- return /* @__PURE__ */ o(oe, { children: t || r != null && r.chatScreenOnly ? /* @__PURE__ */ o(x, { onClick: e.resetChat, className: "rounded-2xl w-full", children: s("new-conversation") }) : /* @__PURE__ */ o(x, { onClick: n, className: "rounded-2xl w-full", children: s("back-to-conversations") }) });
1715
+ const { widgetCtx: e } = q(), { router: r } = x(), { canCreateNewSession: t } = U(), { toSessionsScreen: n } = F(), { t: s } = X();
1716
+ return /* @__PURE__ */ o(oe, { children: t || r != null && r.chatScreenOnly ? /* @__PURE__ */ o(y, { onClick: e.resetChat, className: "rounded-2xl w-full", children: s("new-conversation") }) : /* @__PURE__ */ o(y, { onClick: n, className: "rounded-2xl w-full", children: s("back-to-conversations") }) });
1717
1717
  }
1718
1718
  function fr() {
1719
1719
  const { t: e } = X(), { isCsatRequested: r, isCsatSubmitted: t } = ht();
@@ -1730,7 +1730,7 @@ function fr() {
1730
1730
  }
1731
1731
  function vr() {
1732
1732
  var i;
1733
- const { initialQuestions: e, initialQuestionsPosition: r, thisWasHelpfulOrNot: t } = y(), { sessionState: n } = U(), { messagesState: s } = E(), a = s.messages.length === 0;
1733
+ const { initialQuestions: e, initialQuestionsPosition: r, thisWasHelpfulOrNot: t } = x(), { sessionState: n } = U(), { messagesState: s } = E(), a = s.messages.length === 0;
1734
1734
  return /* @__PURE__ */ o("footer", { children: /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(N, { mode: "wait", children: n.session && !((i = n.session) != null && i.isOpened) ? /* @__PURE__ */ o(H, { children: /* @__PURE__ */ o(fr, {}) }, "session-closed") : /* @__PURE__ */ d(H, { children: [
1735
1735
  s.lastAIResMightSolveUserIssue && (t == null ? void 0 : t.enabled) !== !1 && /* @__PURE__ */ o(ur, {}),
1736
1736
  a && e && r !== "below-initial-messages" && /* @__PURE__ */ o("div", { className: "flex items-center flex-row justify-end gap-2 flex-wrap px-2", children: e == null ? void 0 : e.map((c, l) => /* @__PURE__ */ o(
@@ -1749,7 +1749,7 @@ function br({
1749
1749
  isAloneInGroup: t,
1750
1750
  ...n
1751
1751
  }) {
1752
- const { componentStore: s } = $();
1752
+ const { componentStore: s } = q();
1753
1753
  if (n.type !== "AGENT" && n.type !== "AI") return null;
1754
1754
  if (n.data.action) {
1755
1755
  const i = s.getComponent(n.data.action.name);
@@ -1791,7 +1791,7 @@ function Ht({
1791
1791
  containerClassName: t
1792
1792
  }) {
1793
1793
  var i, c;
1794
- const { timestamps: n } = y();
1794
+ const { timestamps: n } = x();
1795
1795
  if (!((i = n == null ? void 0 : n.perMessageGroup) != null && i.enabled))
1796
1796
  return null;
1797
1797
  const s = (c = e[e.length - 1]) == null ? void 0 : c.timestamp;
@@ -1976,7 +1976,7 @@ function Sr() {
1976
1976
  initialQuestionsPosition: t,
1977
1977
  initialQuestions: n,
1978
1978
  bot: s
1979
- } = y();
1979
+ } = x();
1980
1980
  return /* @__PURE__ */ o(oe, { children: e.length === 0 && r.length > 0 && /* @__PURE__ */ o(
1981
1981
  Se,
1982
1982
  {
@@ -1997,7 +1997,7 @@ function Sr() {
1997
1997
  function _r() {
1998
1998
  const {
1999
1999
  messagesState: { messages: e }
2000
- } = E(), { chatBannerItems: r } = y();
2000
+ } = E(), { chatBannerItems: r } = x();
2001
2001
  return !(r != null && r.length) || e.length > 0 && r.every((t) => !t.persistent) ? null : /* @__PURE__ */ o("div", { className: "w-full text-center text-xs", children: r.map(
2002
2002
  ({ message: t, persistent: n }, s) => e.length > 0 && !n ? null : /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(Tt, { children: t }) }, `${t}-${s}`)
2003
2003
  ) });
@@ -2005,7 +2005,7 @@ function _r() {
2005
2005
  function Ir() {
2006
2006
  const {
2007
2007
  messagesState: { messages: e }
2008
- } = E(), r = y(), {
2008
+ } = E(), r = x(), {
2009
2009
  advancedInitialMessages: t = [],
2010
2010
  initialQuestions: n,
2011
2011
  initialQuestionsPosition: s
@@ -2033,7 +2033,7 @@ function Ir() {
2033
2033
  function Tr() {
2034
2034
  const {
2035
2035
  messagesState: { messages: e }
2036
- } = E(), { isAwaitingBotReply: r } = mt(), { componentStore: t } = $(), n = y(), s = dt(
2036
+ } = E(), { isAwaitingBotReply: r } = mt(), { componentStore: t } = q(), n = x(), s = dt(
2037
2037
  () => kr(e),
2038
2038
  [e]
2039
2039
  ), a = t.getComponent(
@@ -2076,12 +2076,21 @@ function Tr() {
2076
2076
  }
2077
2077
  return null;
2078
2078
  }),
2079
- r && a && /* @__PURE__ */ o(a, { agent: n.bot })
2079
+ r && a && /* @__PURE__ */ o(a, { agent: n.bot }),
2080
+ /* @__PURE__ */ o(Mr, {})
2080
2081
  ]
2081
2082
  }
2082
2083
  );
2083
2084
  }
2084
2085
  function Mr() {
2086
+ const {
2087
+ sessionState: { session: e }
2088
+ } = U(), { specialComponents: r } = x();
2089
+ if (e != null && e.isOpened || !e) return null;
2090
+ const t = r == null ? void 0 : r.onSessionResolved;
2091
+ return t ? /* @__PURE__ */ o(t, { react: $ }) : null;
2092
+ }
2093
+ function Dr() {
2085
2094
  const {
2086
2095
  messagesState: { isInitialFetchLoading: e }
2087
2096
  } = E(), {
@@ -2108,12 +2117,12 @@ function Mr() {
2108
2117
  // Relative to the iframe
2109
2118
  },
2110
2119
  children: /* @__PURE__ */ d("div", { className: "size-full justify-between flex flex-col", children: [
2111
- /* @__PURE__ */ o(At, {}),
2120
+ /* @__PURE__ */ o(Pt, {}),
2112
2121
  /* @__PURE__ */ o(N, { mode: "wait", children: e ? /* @__PURE__ */ o(
2113
2122
  g,
2114
2123
  {
2115
2124
  className: "flex flex-col items-center justify-center w-full flex-1",
2116
- children: /* @__PURE__ */ o(Ot, {})
2125
+ children: /* @__PURE__ */ o(At, {})
2117
2126
  },
2118
2127
  "loading"
2119
2128
  ) : /* @__PURE__ */ d(
@@ -2163,7 +2172,7 @@ function Mr() {
2163
2172
  }
2164
2173
  );
2165
2174
  }
2166
- function Dr({ className: e }) {
2175
+ function jr({ className: e }) {
2167
2176
  return /* @__PURE__ */ o(
2168
2177
  "svg",
2169
2178
  {
@@ -2184,7 +2193,7 @@ function Dr({ className: e }) {
2184
2193
  );
2185
2194
  }
2186
2195
  function Ft({ className: e }) {
2187
- const { token: r } = y();
2196
+ const { token: r } = x();
2188
2197
  return /* @__PURE__ */ o(
2189
2198
  "div",
2190
2199
  {
@@ -2207,7 +2216,7 @@ function Ft({ className: e }) {
2207
2216
  /* @__PURE__ */ o("span", { children: "Powered by" }),
2208
2217
  /* @__PURE__ */ o("span", { children: " " }),
2209
2218
  /* @__PURE__ */ d("span", { className: "flex items-center gap-[1px]", children: [
2210
- /* @__PURE__ */ o("span", { children: /* @__PURE__ */ o(Dr, { className: "size-3 inline-block" }) }),
2219
+ /* @__PURE__ */ o("span", { children: /* @__PURE__ */ o(jr, { className: "size-3 inline-block" }) }),
2211
2220
  /* @__PURE__ */ o("span", { className: "font-semibold", children: "open" })
2212
2221
  ] })
2213
2222
  ]
@@ -2216,16 +2225,16 @@ function Ft({ className: e }) {
2216
2225
  }
2217
2226
  );
2218
2227
  }
2219
- function jr({ children: e }) {
2228
+ function Er({ children: e }) {
2220
2229
  return /* @__PURE__ */ o("p", { className: "ps-4 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight", children: e });
2221
2230
  }
2222
2231
  function it({
2223
2232
  session: e,
2224
2233
  className: r
2225
2234
  }) {
2226
- const { bot: t } = y(), { toChatScreen: n } = F(), s = e.assignee.kind === "human" ? e.assignee.name || "Support Agent" : (t == null ? void 0 : t.name) || "AI Support Agent", a = e.assignee.kind === "human" ? e.assignee.avatarUrl || "" : (t == null ? void 0 : t.avatar) || "";
2235
+ const { bot: t } = x(), { toChatScreen: n } = F(), s = e.assignee.kind === "human" ? e.assignee.name || "Support Agent" : (t == null ? void 0 : t.name) || "AI Support Agent", a = e.assignee.kind === "human" ? e.assignee.avatarUrl || "" : (t == null ? void 0 : t.avatar) || "";
2227
2236
  return /* @__PURE__ */ d(
2228
- x,
2237
+ y,
2229
2238
  {
2230
2239
  variant: "ghost",
2231
2240
  size: "lg",
@@ -2258,7 +2267,7 @@ function it({
2258
2267
  }
2259
2268
  );
2260
2269
  }
2261
- function Er() {
2270
+ function Rr() {
2262
2271
  const { t: e } = X(), { toChatScreen: r } = F(), {
2263
2272
  sessionsState: { data: t, isInitialFetchLoading: n },
2264
2273
  openSessions: s,
@@ -2269,7 +2278,7 @@ function Er() {
2269
2278
  g,
2270
2279
  {
2271
2280
  className: "flex-1 flex items-center justify-center",
2272
- children: /* @__PURE__ */ o(Ot, {})
2281
+ children: /* @__PURE__ */ o(At, {})
2273
2282
  },
2274
2283
  "loading"
2275
2284
  ) : /* @__PURE__ */ o(
@@ -2296,7 +2305,7 @@ function Er() {
2296
2305
  delay: 0.2,
2297
2306
  snapExit: !0,
2298
2307
  children: [
2299
- /* @__PURE__ */ o(jr, { children: e("closed-conversations") }),
2308
+ /* @__PURE__ */ o(Er, { children: e("closed-conversations") }),
2300
2309
  a.map((c) => /* @__PURE__ */ o(
2301
2310
  it,
2302
2311
  {
@@ -2311,7 +2320,7 @@ function Er() {
2311
2320
  )
2312
2321
  ] }),
2313
2322
  i && /* @__PURE__ */ o("div", { className: "mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background", children: /* @__PURE__ */ ot(
2314
- x,
2323
+ y,
2315
2324
  {
2316
2325
  ...u("sessions/new_conversation_btn"),
2317
2326
  size: "lg",
@@ -2324,7 +2333,7 @@ function Er() {
2324
2333
  ] }) : /* @__PURE__ */ d("div", { className: "flex-1 flex flex-col gap-2 items-center", children: [
2325
2334
  /* @__PURE__ */ o("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ o("p", { className: "text-muted-foreground", children: e("no-conversations-yet") }) }),
2326
2335
  /* @__PURE__ */ ot(
2327
- x,
2336
+ y,
2328
2337
  {
2329
2338
  ...u("sessions/new_conversation_btn"),
2330
2339
  size: "lg",
@@ -2339,7 +2348,7 @@ function Er() {
2339
2348
  "sessions"
2340
2349
  ) }) });
2341
2350
  }
2342
- function Rr() {
2351
+ function Or() {
2343
2352
  const { theme: e } = V();
2344
2353
  return Ce({
2345
2354
  width: e.screens.sessions.width,
@@ -2360,8 +2369,8 @@ function Rr() {
2360
2369
  // Relative to the iframe
2361
2370
  },
2362
2371
  children: /* @__PURE__ */ d("div", { className: "size-full flex flex-col", children: [
2363
- /* @__PURE__ */ o(At, {}),
2364
- /* @__PURE__ */ o(Er, {}),
2372
+ /* @__PURE__ */ o(Pt, {}),
2373
+ /* @__PURE__ */ o(Rr, {}),
2365
2374
  /* @__PURE__ */ o(Ft, {})
2366
2375
  ] })
2367
2376
  }
@@ -2389,7 +2398,7 @@ const ie = K.forwardRef(
2389
2398
  );
2390
2399
  ie.displayName = "Input";
2391
2400
  function Pr() {
2392
- const { contentIframeRef: e } = $(), { inline: r } = y(), t = ce(null);
2401
+ const { contentIframeRef: e } = q(), { inline: r } = x(), t = ce(null);
2393
2402
  return re(() => {
2394
2403
  const n = e == null ? void 0 : e.current;
2395
2404
  if (n && t.current) {
@@ -2414,9 +2423,9 @@ const Ar = me.object({
2414
2423
  name: me.string().min(2),
2415
2424
  email: me.string().email()
2416
2425
  });
2417
- function Or() {
2418
- var S, M, P, A, O, j, v, C, B;
2419
- const { setIsOpen: e } = Z(), { createUnverifiedContact: r } = Vt(), { isSmallScreen: t } = R(), n = y(), { theme: s } = V(), { t: a } = X(), { data: i } = de(), { observedElementRef: c } = Pr();
2426
+ function Wr() {
2427
+ var S, M, O, P, A, j, v, C, B;
2428
+ const { setIsOpen: e } = Z(), { createUnverifiedContact: r } = Vt(), { isSmallScreen: t } = R(), n = x(), { theme: s } = V(), { t: a } = X(), { data: i } = de(), { observedElementRef: c } = Pr();
2420
2429
  Ce({
2421
2430
  height: void 0,
2422
2431
  width: s.screens.welcome.width
@@ -2471,15 +2480,15 @@ function Or() {
2471
2480
  "text-primary-foreground"
2472
2481
  ),
2473
2482
  children: [
2474
- t && /* @__PURE__ */ o(g, { className: "absolute top-6 end-6", children: /* @__PURE__ */ o(x, { size: "selfless", onClick: () => e(!1), children: /* @__PURE__ */ o(be, { className: "size-4" }) }) }),
2475
- /* @__PURE__ */ o("div", { className: "flex items-center justify-between w-full mb-2", children: (P = n.assets) != null && P.organizationLogo ? /* @__PURE__ */ o(
2483
+ t && /* @__PURE__ */ o(g, { className: "absolute top-6 end-6", children: /* @__PURE__ */ o(y, { size: "selfless", onClick: () => e(!1), children: /* @__PURE__ */ o(be, { className: "size-4" }) }) }),
2484
+ /* @__PURE__ */ o("div", { className: "flex items-center justify-between w-full mb-2", children: (O = n.assets) != null && O.organizationLogo ? /* @__PURE__ */ o(
2476
2485
  "img",
2477
2486
  {
2478
- src: (A = n.assets) == null ? void 0 : A.organizationLogo,
2487
+ src: (P = n.assets) == null ? void 0 : P.organizationLogo,
2479
2488
  alt: "Company Logo",
2480
2489
  className: "h-8 w-auto object-contain"
2481
2490
  }
2482
- ) : /* @__PURE__ */ o("h2", { className: "font-bold text-sm", children: (O = i == null ? void 0 : i.data) == null ? void 0 : O.organizationName }) }),
2491
+ ) : /* @__PURE__ */ o("h2", { className: "font-bold text-sm", children: (A = i == null ? void 0 : i.data) == null ? void 0 : A.organizationName }) }),
2483
2492
  /* @__PURE__ */ d("div", { className: "space-y-2", children: [
2484
2493
  /* @__PURE__ */ o("h1", { className: "text-[1.75rem] font-semibold tracking-tight leading-none", children: ((v = (j = n.textContent) == null ? void 0 : j.welcomeScreen) == null ? void 0 : v.title) || a("welcome-title") }),
2485
2494
  /* @__PURE__ */ o("p", { className: "text-sm", children: ((B = (C = n.textContent) == null ? void 0 : C.welcomeScreen) == null ? void 0 : B.description) || a("welcome-description") })
@@ -2532,7 +2541,7 @@ function Or() {
2532
2541
  _
2533
2542
  )),
2534
2543
  /* @__PURE__ */ d(
2535
- x,
2544
+ y,
2536
2545
  {
2537
2546
  disabled: z.loading,
2538
2547
  className: "w-full",
@@ -2568,7 +2577,7 @@ function Bt() {
2568
2577
  fadeIn: "right",
2569
2578
  className: "size-full",
2570
2579
  snapExit: !0,
2571
- children: /* @__PURE__ */ o(Or, {})
2580
+ children: /* @__PURE__ */ o(Wr, {})
2572
2581
  },
2573
2582
  e
2574
2583
  );
@@ -2579,7 +2588,7 @@ function Bt() {
2579
2588
  fadeIn: "right",
2580
2589
  className: "size-full",
2581
2590
  snapExit: !0,
2582
- children: /* @__PURE__ */ o(Rr, {})
2591
+ children: /* @__PURE__ */ o(Or, {})
2583
2592
  },
2584
2593
  e
2585
2594
  );
@@ -2590,7 +2599,7 @@ function Bt() {
2590
2599
  fadeIn: "right",
2591
2600
  className: "size-full",
2592
2601
  snapExit: !0,
2593
- children: /* @__PURE__ */ o(Mr, {})
2602
+ children: /* @__PURE__ */ o(Dr, {})
2594
2603
  },
2595
2604
  e
2596
2605
  );
@@ -2599,7 +2608,7 @@ function Bt() {
2599
2608
  }
2600
2609
  })() }) });
2601
2610
  }
2602
- const Wr = "4.0.12", Hr = `<!DOCTYPE html>
2611
+ const Hr = "4.0.14", Fr = `<!DOCTYPE html>
2603
2612
  <html>
2604
2613
  <head>
2605
2614
  <style>
@@ -2618,7 +2627,7 @@ html, body {
2618
2627
  </body>
2619
2628
  </html>`;
2620
2629
  function Lt() {
2621
- const { isOpen: e } = Z(), { contentIframeRef: r } = $(), { cssOverrides: t, inline: n } = y(), { theme: s, cssVars: a, computed: i } = V(), { dir: c } = X();
2630
+ const { isOpen: e } = Z(), { contentIframeRef: r } = q(), { cssOverrides: t, inline: n } = x(), { theme: s, cssVars: a, computed: i } = V(), { dir: c } = X();
2622
2631
  return /* @__PURE__ */ o(
2623
2632
  J.div,
2624
2633
  {
@@ -2642,7 +2651,7 @@ function Lt() {
2642
2651
  vt,
2643
2652
  {
2644
2653
  ref: r,
2645
- initialContent: Hr,
2654
+ initialContent: Fr,
2646
2655
  allowFullScreen: !0,
2647
2656
  title: "OpenCX Live Chat",
2648
2657
  style: {
@@ -2679,7 +2688,7 @@ function Lt() {
2679
2688
  ...a,
2680
2689
  zIndex: s.widgetContentContainer.zIndex
2681
2690
  },
2682
- "data-version": Wr,
2691
+ "data-version": Hr,
2683
2692
  className: p(
2684
2693
  "antialiased font-sans size-full overflow-hidden relative text-secondary-foreground isolate"
2685
2694
  ),
@@ -2700,7 +2709,7 @@ function Lt() {
2700
2709
  }
2701
2710
  );
2702
2711
  }
2703
- function Fr() {
2712
+ function Br() {
2704
2713
  const { theme: e } = V();
2705
2714
  return /* @__PURE__ */ o(
2706
2715
  le.Content,
@@ -2720,7 +2729,7 @@ function Fr() {
2720
2729
  }
2721
2730
  );
2722
2731
  }
2723
- function Br({
2732
+ function Lr({
2724
2733
  className: e,
2725
2734
  style: r
2726
2735
  }) {
@@ -2755,7 +2764,7 @@ function Br({
2755
2764
  }
2756
2765
  );
2757
2766
  }
2758
- const Lr = `<!DOCTYPE html>
2767
+ const Yr = `<!DOCTYPE html>
2759
2768
  <html>
2760
2769
  <head>
2761
2770
  <style>
@@ -2772,13 +2781,13 @@ html, body {
2772
2781
  <body>
2773
2782
  </body>
2774
2783
  </html>`;
2775
- function Yr() {
2784
+ function $r() {
2776
2785
  var a, i;
2777
- const { isOpen: e } = Z(), { cssOverrides: r, assets: t } = y(), { theme: n, cssVars: s } = V();
2786
+ const { isOpen: e } = Z(), { cssOverrides: r, assets: t } = x(), { theme: n, cssVars: s } = V();
2778
2787
  return /* @__PURE__ */ d(
2779
2788
  vt,
2780
2789
  {
2781
- initialContent: Lr,
2790
+ initialContent: Yr,
2782
2791
  style: {
2783
2792
  height: `calc(${n.widgetTrigger.size.button}px + ${G.x * 2}px)`,
2784
2793
  width: `calc(${n.widgetTrigger.size.button}px + ${G.y * 2}px)`,
@@ -2878,7 +2887,7 @@ function Yr() {
2878
2887
  }
2879
2888
  }
2880
2889
  ) : /* @__PURE__ */ o(
2881
- Br,
2890
+ Lr,
2882
2891
  {
2883
2892
  style: {
2884
2893
  width: n.widgetTrigger.size.icon,
@@ -2900,7 +2909,7 @@ function Yr() {
2900
2909
  }
2901
2910
  );
2902
2911
  }
2903
- function $r() {
2912
+ function qr() {
2904
2913
  const { dir: e } = ve();
2905
2914
  return /* @__PURE__ */ o(
2906
2915
  le.Anchor,
@@ -2914,15 +2923,15 @@ function $r() {
2914
2923
  }
2915
2924
  );
2916
2925
  }
2917
- function qr() {
2926
+ function Ur() {
2918
2927
  const { isOpen: e, setIsOpen: r } = Z();
2919
2928
  return /* @__PURE__ */ d(le.Root, { open: e, onOpenChange: r, children: [
2929
+ /* @__PURE__ */ o(qr, {}),
2920
2930
  /* @__PURE__ */ o($r, {}),
2921
- /* @__PURE__ */ o(Yr, {}),
2922
- /* @__PURE__ */ o(Fr, {})
2931
+ /* @__PURE__ */ o(Br, {})
2923
2932
  ] });
2924
2933
  }
2925
- const Ur = [
2934
+ const Vr = [
2926
2935
  {
2927
2936
  key: "loading",
2928
2937
  component: Yo
@@ -2939,7 +2948,7 @@ const Ur = [
2939
2948
  key: "agent_message",
2940
2949
  component: ue
2941
2950
  }
2942
- ], Vr = {
2951
+ ], Xr = {
2943
2952
  get: async (e) => localStorage.getItem(e),
2944
2953
  set: async (e, r) => {
2945
2954
  localStorage.setItem(e, r);
@@ -2948,7 +2957,7 @@ const Ur = [
2948
2957
  localStorage.removeItem(e);
2949
2958
  }
2950
2959
  };
2951
- function mn({
2960
+ function un({
2952
2961
  options: e,
2953
2962
  components: r = [],
2954
2963
  loadingComponent: t
@@ -2956,15 +2965,15 @@ function mn({
2956
2965
  return /* @__PURE__ */ o(
2957
2966
  Xt,
2958
2967
  {
2959
- components: [...Ur, ...r],
2968
+ components: [...Vr, ...r],
2960
2969
  options: e,
2961
- storage: Vr,
2970
+ storage: Xr,
2962
2971
  loadingComponent: t,
2963
- children: /* @__PURE__ */ o(Gt, { children: e.inline ? /* @__PURE__ */ o(Lt, {}) : /* @__PURE__ */ o(qr, {}) })
2972
+ children: /* @__PURE__ */ o(Gt, { children: e.inline ? /* @__PURE__ */ o(Lt, {}) : /* @__PURE__ */ o(Ur, {}) })
2964
2973
  }
2965
2974
  );
2966
2975
  }
2967
2976
  export {
2968
- mn as Widget
2977
+ un as Widget
2969
2978
  };
2970
2979
  //# sourceMappingURL=index.js.map