@connorpham/live-chat-widget 17.0.4 → 17.0.6

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
1
  var i0 = Object.defineProperty;
2
2
  var o0 = (u, D, f) => D in u ? i0(u, D, { enumerable: !0, configurable: !0, writable: !0, value: f }) : u[D] = f;
3
3
  var lD = (u, D, f) => o0(u, typeof D != "symbol" ? D + "" : D, f);
4
- import af, { createContext as qu, useRef as mu, useEffect as X, useContext as Hu, useState as U, useCallback as Mu, useMemo as d0 } from "react";
4
+ import af, { createContext as qu, useRef as mu, useEffect as Z, useContext as Hu, useState as U, useCallback as Mu, useMemo as d0 } from "react";
5
5
  var dD = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
6
6
  function sf(u) {
7
7
  return u && u.__esModule && Object.prototype.hasOwnProperty.call(u, "default") ? u.default : u;
@@ -191,7 +191,7 @@ function c0() {
191
191
  function z() {
192
192
  }
193
193
  z.__reactDisabledLog = !0;
194
- function Z() {
194
+ function Q() {
195
195
  {
196
196
  if (h === 0) {
197
197
  A = console.log, p = console.info, R = console.warn, N = console.error, M = console.group, V = console.groupCollapsed, J = console.groupEnd;
@@ -281,7 +281,7 @@ function c0() {
281
281
  var G = Error.prepareStackTrace;
282
282
  Error.prepareStackTrace = void 0;
283
283
  var K;
284
- K = cu.current, cu.current = null, Z();
284
+ K = cu.current, cu.current = null, Q();
285
285
  try {
286
286
  if (b) {
287
287
  var Y = function() {
@@ -659,7 +659,7 @@ const Gf = qu(void 0), Xf = ({
659
659
  const f = mu(
660
660
  new BroadcastChannel(D)
661
661
  ), e = mu({});
662
- X(() => {
662
+ Z(() => {
663
663
  const r = ({ data: s }) => {
664
664
  e.current[s.event].forEach((F) => F(s));
665
665
  };
@@ -695,11 +695,11 @@ const Gf = qu(void 0), Xf = ({
695
695
  return u;
696
696
  }, h0 = (...u) => {
697
697
  const { subscribe: D } = E0();
698
- X(() => {
698
+ Z(() => {
699
699
  D(...u);
700
700
  }, [D, ...u]);
701
701
  };
702
- var WD = /* @__PURE__ */ ((u) => (u.message = "message", u.delivery = "delivery", u.read = "read", u.typing = "typing", u.follow = "follow", u.echo = "echo", u.unknown = "", u))(WD || {}), Q = /* @__PURE__ */ ((u) => (u.sent = "sent", u.received = "received", u))(Q || {}), Zf = /* @__PURE__ */ ((u) => (u.text = "text", u.location = "location", u))(Zf || {}), Au = /* @__PURE__ */ ((u) => (u.text = "text", u.quick_reply = "quick_reply", u.postback = "postback", u.location = "location", u.file = "file", u.notify = "notify", u))(Au || {}), YD = /* @__PURE__ */ ((u) => (u.text = "text", u.buttons = "buttons", u.quick_replies = "quick_replies", u.file = "file", u.list = "list", u.carousel = "carousel", u))(YD || {}), iD = /* @__PURE__ */ ((u) => (u[u.sent = 0] = "sent", u[u.sending = 1] = "sending", u[u.uploading = 2] = "uploading", u))(iD || {}), tD = /* @__PURE__ */ ((u) => (u[u.disconnected = 0] = "disconnected", u[u.wantToConnect = 1] = "wantToConnect", u[u.tryingToConnect = 2] = "tryingToConnect", u[u.connected = 3] = "connected", u))(tD || {}), aD = {};
702
+ var WD = /* @__PURE__ */ ((u) => (u.message = "message", u.delivery = "delivery", u.read = "read", u.typing = "typing", u.follow = "follow", u.echo = "echo", u.unknown = "", u))(WD || {}), uu = /* @__PURE__ */ ((u) => (u.sent = "sent", u.received = "received", u))(uu || {}), Zf = /* @__PURE__ */ ((u) => (u.text = "text", u.location = "location", u))(Zf || {}), Au = /* @__PURE__ */ ((u) => (u.text = "text", u.quick_reply = "quick_reply", u.postback = "postback", u.location = "location", u.file = "file", u.notify = "notify", u))(Au || {}), YD = /* @__PURE__ */ ((u) => (u.text = "text", u.buttons = "buttons", u.quick_replies = "quick_replies", u.file = "file", u.list = "list", u.carousel = "carousel", u))(YD || {}), iD = /* @__PURE__ */ ((u) => (u[u.sent = 0] = "sent", u[u.sending = 1] = "sending", u[u.uploading = 2] = "uploading", u))(iD || {}), tD = /* @__PURE__ */ ((u) => (u[u.disconnected = 0] = "disconnected", u[u.wantToConnect = 1] = "wantToConnect", u[u.tryingToConnect = 2] = "tryingToConnect", u[u.connected = 3] = "connected", u))(tD || {}), aD = {};
703
703
  const Qf = {
704
704
  apiUrl: aD.REACT_APP_WIDGET_API_URL || "http://localhost:4000",
705
705
  channel: aD.REACT_APP_WIDGET_CHANNEL || "console-channel",
@@ -3113,7 +3113,7 @@ function ve(u, D) {
3113
3113
  function we(u, D) {
3114
3114
  localStorage.removeItem(lf(u, D));
3115
3115
  }
3116
- const uu = { setItem: ye, getItem: ve, removeItem: we }, wD = class wD {
3116
+ const X = { setItem: ye, getItem: ve, removeItem: we }, wD = class wD {
3117
3117
  constructor(D, f, e) {
3118
3118
  lD(this, "socket");
3119
3119
  lD(this, "config");
@@ -3250,7 +3250,7 @@ lD(wD, "defaultConfig", {
3250
3250
  let uf = wD, qD;
3251
3251
  const Ae = (u, D) => {
3252
3252
  var e;
3253
- const f = (e = uu.getItem("profileLiveChat")) == null ? void 0 : e.id;
3253
+ const f = (e = X.getItem("profileLiveChat")) == null ? void 0 : e.id;
3254
3254
  return qD || (qD = new uf(
3255
3255
  u.apiUrl,
3256
3256
  {
@@ -3283,10 +3283,10 @@ const Ae = (u, D) => {
3283
3283
  return /* @__PURE__ */ a.jsx(h1.Provider, { value: { socket: f.current }, children: u.children });
3284
3284
  }, Gu = () => Hu(h1), Df = (u, D) => {
3285
3285
  const { socket: f } = Gu();
3286
- X(() => (f.on(u, D), () => f.off(u, D)), [u, D, f]);
3286
+ Z(() => (f.on(u, D), () => f.off(u, D)), [u, D, f]);
3287
3287
  }, xe = () => {
3288
3288
  const { socket: u } = Gu();
3289
- X(() => (u.connect(), () => {
3289
+ Z(() => (u.connect(), () => {
3290
3290
  u.disconnect();
3291
3291
  }), []);
3292
3292
  }, _D = {
@@ -3465,21 +3465,21 @@ const Ae = (u, D) => {
3465
3465
  yu.isContactFormActive
3466
3466
  ), [M, V] = U(
3467
3467
  yu.isOfflineMode
3468
- ), { send: J } = Cu(), { t: z } = zu(), Z = (S) => {
3468
+ ), { send: J } = Cu(), { t: z } = zu(), Q = (S) => {
3469
3469
  y(S), S === tD.wantToConnect && u && u(), S === tD.connected && t.alwaysScrollToBottom && s(101);
3470
3470
  }, tu = t.offline_mode, cu = kD(tu), _u = (S) => {
3471
- if (q(S), uu.setItem(
3471
+ if (q(S), X.setItem(
3472
3472
  "isOffline",
3473
3473
  (S == null ? void 0 : S.isOffline) || !1
3474
- ), uu.setItem(
3474
+ ), X.setItem(
3475
3475
  "submitedFormLateTime",
3476
3476
  (S == null ? void 0 : S.submitedFormLateTime) || null
3477
3477
  ), S && "type" in S && S.type === "typing")
3478
3478
  return T === !0;
3479
- _(!1), S && "mid" in S && !C.find((Du) => S.mid === Du.mid) && ("author" in S && (S.direction = S.author === "chatbot" ? Q.received : Q.sent, S.read = !0, S.delivery = !0), v((Du) => [
3479
+ _(!1), S && "mid" in S && !C.find((Du) => S.mid === Du.mid) && ("author" in S && (S.direction = S.author === "chatbot" ? uu.received : uu.sent, S.read = !0, S.delivery = !0), v((Du) => [
3480
3480
  ...Du.filter((au) => au.mid !== S.mid),
3481
3481
  S
3482
- ]), s(0), "direction" in S && S.direction === Q.received && !S.isOffline && V(!1)), S && "data" in S && "quick_replies" in S.data ? I(
3482
+ ]), s(0), "direction" in S && S.direction === uu.received && !S.isOffline && V(!1)), S && "data" in S && "quick_replies" in S.data ? I(
3483
3483
  (S.data.quick_replies || []).map(
3484
3484
  (Du) => ({
3485
3485
  content_type: Zf.text,
@@ -3523,15 +3523,15 @@ const Ae = (u, D) => {
3523
3523
  typeof Uu == "string" && Uu.trim() && au.append(gu, Uu);
3524
3524
  }), au.append("owner_id", e.ownerId);
3525
3525
  const { body: lu } = await Bu.get(`/webhook/${e.channel}/?${au.toString()}`);
3526
- console.log("jump here 2"), uu.setItem("profileLiveChat", lu.profile), uu.setItem("isOffline", cu || !1), uu.setItem(
3526
+ console.log("jump here 2"), X.setItem("profileLiveChat", lu.profile), X.setItem("isOffline", cu || !1), X.setItem(
3527
3527
  "submitedFormLateTime",
3528
3528
  lu.profile.submitedFormLateTime || null
3529
3529
  ), v(
3530
3530
  lu.messages.map((gu) => ({
3531
3531
  ...gu,
3532
- direction: gu.author === lu.profile.foreignId || gu.author === lu.profile.id ? Q.sent : Q.received,
3533
- read: gu.direction === Q.sent || gu.read,
3534
- delivery: gu.direction === Q.sent || gu.delivery,
3532
+ direction: gu.author === lu.profile.foreignId || gu.author === lu.profile.id ? uu.sent : uu.received,
3533
+ read: gu.direction === uu.sent || gu.read,
3534
+ delivery: gu.direction === uu.sent || gu.delivery,
3535
3535
  isOffline: gu.isOffline || lu.profile.isOffline,
3536
3536
  submitedFormLateTime: gu.submitedFormLateTime || lu.profile.submitedFormLateTime
3537
3537
  }))
@@ -3576,12 +3576,12 @@ const Ae = (u, D) => {
3576
3576
  const Pu = (S) => {
3577
3577
  S ? (p(S), r("webview")) : r("chat");
3578
3578
  };
3579
- X(() => {
3579
+ Z(() => {
3580
3580
  F && d && m(0);
3581
- }, [F, d]), X(() => {
3581
+ }, [F, d]), Z(() => {
3582
3582
  if (d && j === tD.connected) {
3583
3583
  console.log("🔄 Widget opened - fetching fresh data");
3584
- const S = uu.getItem("profileLiveChat");
3584
+ const S = X.getItem("profileLiveChat");
3585
3585
  if (S) {
3586
3586
  const Du = S;
3587
3587
  console.log("🔄 Widget opened - fetching fresh data", Du), du(Du.firstName, Du.lastName);
@@ -3590,10 +3590,10 @@ const Ae = (u, D) => {
3590
3590
  }
3591
3591
  }, [d]), h0("logout", () => {
3592
3592
  o.socket.disconnect();
3593
- }), X(() => {
3593
+ }), Z(() => {
3594
3594
  n === "chat" && j === tD.connected && du();
3595
3595
  const S = () => {
3596
- const Du = uu.getItem("profileLiveChat");
3596
+ const Du = X.getItem("profileLiveChat");
3597
3597
  if (Du) {
3598
3598
  const au = Du;
3599
3599
  du(au.firstName, au.lastName);
@@ -3602,7 +3602,7 @@ const Ae = (u, D) => {
3602
3602
  return o.socket.io.on("reconnect", S), () => {
3603
3603
  o.socket.io.off("reconnect", S);
3604
3604
  };
3605
- }, []), X(() => {
3605
+ }, []), Z(() => {
3606
3606
  const S = [...c];
3607
3607
  S[0].imageUrl = t.avatarUrl, l(S);
3608
3608
  }, [t.avatarUrl]);
@@ -3612,7 +3612,7 @@ const Ae = (u, D) => {
3612
3612
  outgoingMessageState: $,
3613
3613
  setOutgoingMessageState: hu,
3614
3614
  connectionState: j,
3615
- setConnectionState: Z,
3615
+ setConnectionState: Q,
3616
3616
  messages: C.sort((S, Du) => {
3617
3617
  const au = Date.parse(S.createdAt), lu = Date.parse(Du.createdAt);
3618
3618
  return +new Date(au) - +new Date(lu);
@@ -4015,7 +4015,7 @@ const Ae = (u, D) => {
4015
4015
  const [D, f] = U(!1), e = mu(null), { send: t } = Cu(), n = async (r) => {
4016
4016
  r.preventDefault(), r.stopPropagation();
4017
4017
  try {
4018
- const s = uu.getItem("profileLiveChat");
4018
+ const s = X.getItem("profileLiveChat");
4019
4019
  if (!s) {
4020
4020
  console.error("No profile found in localStorage");
4021
4021
  return;
@@ -4329,7 +4329,7 @@ var x1 = { exports: {} };
4329
4329
  return R ? du : du.endOf(d);
4330
4330
  }, V = function(Bu, ru) {
4331
4331
  return $.w(p.toDate()[Bu].apply(p.toDate("s"), (R ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(ru)), p);
4332
- }, J = this.$W, z = this.$M, Z = this.$D, tu = "set" + (this.$u ? "UTC" : "");
4332
+ }, J = this.$W, z = this.$M, Q = this.$D, tu = "set" + (this.$u ? "UTC" : "");
4333
4333
  switch (N) {
4334
4334
  case j:
4335
4335
  return R ? M(1, 0) : M(31, 11);
@@ -4337,7 +4337,7 @@ var x1 = { exports: {} };
4337
4337
  return R ? M(1, z) : M(0, z + 1);
4338
4338
  case o:
4339
4339
  var cu = this.$locale().weekStart || 0, _u = (J < cu ? J + 7 : J) - cu;
4340
- return M(R ? Z - _u : Z + (6 - _u), z);
4340
+ return M(R ? Q - _u : Q + (6 - _u), z);
4341
4341
  case d:
4342
4342
  case y:
4343
4343
  return V(tu + "Hours", 0);
@@ -4367,8 +4367,8 @@ var x1 = { exports: {} };
4367
4367
  var p, R = this;
4368
4368
  h = Number(h);
4369
4369
  var N = $.p(A), M = function(z) {
4370
- var Z = O(R);
4371
- return $.w(Z.date(Z.date() + Math.round(z * h)), R);
4370
+ var Q = O(R);
4371
+ return $.w(Q.date(Q.date() + Math.round(z * h)), R);
4372
4372
  };
4373
4373
  if (N === c) return this.set(c, this.$M + h);
4374
4374
  if (N === j) return this.set(j, this.$y + h);
@@ -4381,7 +4381,7 @@ var x1 = { exports: {} };
4381
4381
  }, E.format = function(h) {
4382
4382
  var A = this, p = this.$locale();
4383
4383
  if (!this.isValid()) return p.invalidDate || C;
4384
- var R = h || "YYYY-MM-DDTHH:mm:ssZ", N = $.z(this), M = this.$H, V = this.$m, J = this.$M, z = p.weekdays, Z = p.months, tu = p.meridiem, cu = function(ru, du, Pu, Iu) {
4384
+ var R = h || "YYYY-MM-DDTHH:mm:ssZ", N = $.z(this), M = this.$H, V = this.$m, J = this.$M, z = p.weekdays, Q = p.months, tu = p.meridiem, cu = function(ru, du, Pu, Iu) {
4385
4385
  return ru && (ru[du] || ru(A, R)) || Pu[du].slice(0, Iu);
4386
4386
  }, _u = function(ru) {
4387
4387
  return $.s(M % 12 || 12, ru, "0");
@@ -4401,9 +4401,9 @@ var x1 = { exports: {} };
4401
4401
  case "MM":
4402
4402
  return $.s(J + 1, 2, "0");
4403
4403
  case "MMM":
4404
- return cu(p.monthsShort, J, Z, 3);
4404
+ return cu(p.monthsShort, J, Q, 3);
4405
4405
  case "MMMM":
4406
- return cu(Z, J);
4406
+ return cu(Q, J);
4407
4407
  case "D":
4408
4408
  return A.$D;
4409
4409
  case "DD":
@@ -4447,18 +4447,18 @@ var x1 = { exports: {} };
4447
4447
  }, E.utcOffset = function() {
4448
4448
  return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
4449
4449
  }, E.diff = function(h, A, p) {
4450
- var R, N = this, M = $.p(A), V = O(h), J = (V.utcOffset() - this.utcOffset()) * e, z = this - V, Z = function() {
4450
+ var R, N = this, M = $.p(A), V = O(h), J = (V.utcOffset() - this.utcOffset()) * e, z = this - V, Q = function() {
4451
4451
  return $.m(N, V);
4452
4452
  };
4453
4453
  switch (M) {
4454
4454
  case j:
4455
- R = Z() / 12;
4455
+ R = Q() / 12;
4456
4456
  break;
4457
4457
  case c:
4458
- R = Z();
4458
+ R = Q();
4459
4459
  break;
4460
4460
  case l:
4461
- R = Z() / 3;
4461
+ R = Q() / 3;
4462
4462
  break;
4463
4463
  case o:
4464
4464
  R = (z - J) / 6048e5;
@@ -4759,7 +4759,7 @@ const He = /* @__PURE__ */ sf(Ve), T1 = ({
4759
4759
  /* @__PURE__ */ a.jsx("path", { d: "M413.94 191.88h-78.77a50.17 50.17 0 01-50.11-50.11V63a15 15 0 0130 0v78.77a20.13 20.13 0 0020.11 20.11h78.77a15 15 0 010 30zM264.4 375a15 15 0 01-10.61-4.4l-54.45-54.44a15 15 0 1121.21-21.22l43.85 43.84 43.84-43.84a15 15 0 1121.21 21.22L275 370.55a15 15 0 01-10.6 4.45z" }),
4760
4760
  /* @__PURE__ */ a.jsx("path", { d: "M264.4 365a15 15 0 01-15-15V231a15 15 0 0130 0v119a15 15 0 01-15 15z" })
4761
4761
  ] }) }), Ze = ({ message: u }) => {
4762
- const { t: D } = zu(), { colors: f } = ou(), e = f[u.direction || Q.received];
4762
+ const { t: D } = zu(), { colors: f } = ou(), e = f[u.direction || uu.received];
4763
4763
  if (!("type" in u.data))
4764
4764
  throw new Error("Unable to detect type for file message");
4765
4765
  if (u.data && u.data.type !== "image" && u.data.type !== "audio" && u.data.type !== "video" && u.data.type !== "file")
@@ -4811,18 +4811,18 @@ const He = /* @__PURE__ */ sf(Ve), T1 = ({
4811
4811
  }, Qe = ({ message: u }) => {
4812
4812
  var d;
4813
4813
  const { colors: D } = ou(), f = Nu(), [e, t] = U(!1), n = mu(null);
4814
- if (X(() => {
4814
+ if (Z(() => {
4815
4815
  const o = new IntersectionObserver((c) => {
4816
4816
  !e && c[0].intersectionRatio > 0 && t(!0);
4817
4817
  });
4818
4818
  return n.current && o.observe(n.current), () => {
4819
4819
  n.current && o.unobserve(n.current);
4820
4820
  };
4821
- }, [e]), X(() => {
4821
+ }, [e]), Z(() => {
4822
4822
  e && f && f.scroll > 85 && (f.scroll = 101);
4823
4823
  }, [e, f]), !("coordinates" in u.data))
4824
4824
  throw new Error("Unable to find coordinates");
4825
- const r = ((d = u.data) == null ? void 0 : d.coordinates) || { lat: 0, lng: 0 }, s = `https://www.openstreetmap.org/export/embed.html?bbox=${r.lng - 0.1},${r.lat - 0.1},${r.lng + 0.1},${r.lat + 0.1}&layer=mapnik&marker=${r.lat},${r.lng}`, F = D[u.direction || Q.received];
4825
+ const r = ((d = u.data) == null ? void 0 : d.coordinates) || { lat: 0, lng: 0 }, s = `https://www.openstreetmap.org/export/embed.html?bbox=${r.lng - 0.1},${r.lat - 0.1},${r.lng + 0.1},${r.lat + 0.1}&layer=mapnik&marker=${r.lat},${r.lng}`, F = D[u.direction || uu.received];
4826
4826
  return /* @__PURE__ */ a.jsx(
4827
4827
  "div",
4828
4828
  {
@@ -4853,7 +4853,7 @@ const He = /* @__PURE__ */ sf(Ve), T1 = ({
4853
4853
  }, e = (r, s = 100) => r.length > s ? r.substr(0, s) + "..." : r, t = (r) => r.replace(/\n/g, "<br />");
4854
4854
  if (!("elements" in u.data))
4855
4855
  throw new Error("Unable to find elements");
4856
- const n = D[u.direction || Q.received];
4856
+ const n = D[u.direction || uu.received];
4857
4857
  return /* @__PURE__ */ a.jsxs(
4858
4858
  "div",
4859
4859
  {
@@ -6446,10 +6446,10 @@ const U1 = ({
6446
6446
  }
6447
6447
  return x;
6448
6448
  };
6449
- X(() => {
6449
+ Z(() => {
6450
6450
  if (D)
6451
6451
  try {
6452
- const C = uu.getItem("dataUserSubs");
6452
+ const C = X.getItem("dataUserSubs");
6453
6453
  C && e(C);
6454
6454
  } catch (C) {
6455
6455
  console.error("Error loading dataUserSubs from localStorage:", C);
@@ -6783,7 +6783,7 @@ const xt = ({
6783
6783
  initialData: {},
6784
6784
  loadFromDataUserSubs: !0
6785
6785
  }), [x, m] = U(!1), [T, _] = U(!1);
6786
- X(() => {
6786
+ Z(() => {
6787
6787
  D && !T && D(!0), D && T && D(!1);
6788
6788
  }, [T]);
6789
6789
  const B = async (P) => {
@@ -6797,19 +6797,19 @@ const xt = ({
6797
6797
  E.isDisplay && j[E.key] !== void 0 && (O[E.key] = ((h = j[E.key]) == null ? void 0 : h.toString().trim()) || "");
6798
6798
  });
6799
6799
  const $ = At(O);
6800
- if (!uu.getItem("profileLiveChat"))
6800
+ if (!X.getItem("profileLiveChat"))
6801
6801
  try {
6802
6802
  const E = new URLSearchParams();
6803
6803
  Object.entries($).forEach(([M, V]) => {
6804
6804
  typeof V == "string" && V && E.append(M, V);
6805
6805
  }), E.append("owner_id", e.ownerId), E.append("contactLateTime", (/* @__PURE__ */ new Date()).toISOString());
6806
6806
  const { body: h } = await n.get(`/webhook/${e.channel}/?${E.toString()}`), { messages: A, profile: p } = h;
6807
- uu.setItem("profileLiveChat", p), uu.setItem("isOffline", !1), uu.setItem(
6807
+ X.setItem("profileLiveChat", p), X.setItem("isOffline", !1), X.setItem(
6808
6808
  "submitedFormLateTime",
6809
6809
  (p == null ? void 0 : p.submitedFormLateTime) || null
6810
6810
  ), A.forEach((M) => {
6811
- const V = M.author === p.foreignId || M.author === p.id ? Q.sent : Q.received;
6812
- M.direction = V, M.direction === Q.sent && (M.read = !0, M.delivery = !1);
6811
+ const V = M.author === p.foreignId || M.author === p.id ? uu.sent : uu.received;
6812
+ M.direction = V, M.direction === uu.sent && (M.read = !0, M.delivery = !1);
6813
6813
  }), o(A), c([
6814
6814
  d[0],
6815
6815
  {
@@ -6868,7 +6868,7 @@ const xt = ({
6868
6868
  m(!1);
6869
6869
  }
6870
6870
  }
6871
- }, I = f[Q.received];
6871
+ }, I = f[uu.received];
6872
6872
  return T ? null : /* @__PURE__ */ a.jsx(
6873
6873
  "div",
6874
6874
  {
@@ -6911,11 +6911,11 @@ const xt = ({
6911
6911
  onFormSubmitted: D
6912
6912
  }) => {
6913
6913
  const { colors: f } = ou(), { setIsContactFormActive: e } = Cu(), t = mu(null);
6914
- X(() => {
6914
+ Z(() => {
6915
6915
  n();
6916
6916
  }, [u]);
6917
6917
  const n = () => {
6918
- if (u.direction === Q.received && t.current) {
6918
+ if (u.direction === uu.received && t.current) {
6919
6919
  const F = t.current.innerText;
6920
6920
  let d = lt.link(F, {
6921
6921
  className: "chatLink",
@@ -6926,7 +6926,7 @@ const xt = ({
6926
6926
  };
6927
6927
  if (!("text" in u.data))
6928
6928
  throw new Error("Unable to find text.");
6929
- const r = f[u.direction || Q.received];
6929
+ const r = f[u.direction || uu.received];
6930
6930
  return "isShowForm" in u.data && u.data.isShowForm ? /* @__PURE__ */ a.jsx(
6931
6931
  xt,
6932
6932
  {
@@ -7074,23 +7074,23 @@ const St = ({ message: u, Avatar: D }) => {
7074
7074
  Avatar: u,
7075
7075
  phone: D
7076
7076
  }) => {
7077
- const { colors: f } = ou(), e = f[Q.received];
7077
+ const f = X.getItem("profileLiveChat"), { colors: e } = ou(), t = e[uu.received];
7078
7078
  pu();
7079
- const { participants: t } = Cu(), n = t.find(
7080
- (r) => r.id === "chatbot"
7079
+ const { participants: n } = Cu(), r = n.find(
7080
+ (o) => o.id === "chatbot"
7081
7081
  ) || {
7082
7082
  name: "Bot"
7083
- };
7084
- return /* @__PURE__ */ a.jsx("div", { className: `sc-message ${Q.received}`, children: /* @__PURE__ */ a.jsxs("div", { className: `sc-message--content ${Q.received}`, children: [
7083
+ }, s = (f == null ? void 0 : f.mobile) || "", d = `${(f == null ? void 0 : f.countryCode) || "+61"} ${s}`;
7084
+ return console.log("fullPhone", d), /* @__PURE__ */ a.jsx("div", { className: `sc-message ${uu.received}`, children: /* @__PURE__ */ a.jsxs("div", { className: `sc-message--content ${uu.received}`, children: [
7085
7085
  /* @__PURE__ */ a.jsx(
7086
7086
  "div",
7087
7087
  {
7088
- title: n.name,
7088
+ title: r.name,
7089
7089
  className: "sc-message--avatar",
7090
- style: n.imageUrl ? {
7091
- backgroundImage: `url(${n.imageUrl}?color=${encodeURIComponent(f.header.bg)})`
7090
+ style: r.imageUrl ? {
7091
+ backgroundImage: `url(${r.imageUrl}?color=${encodeURIComponent(e.header.bg)})`
7092
7092
  } : void 0,
7093
- children: u ? /* @__PURE__ */ a.jsx(u, {}) : n.imageUrl ? null : /* @__PURE__ */ a.jsx(T1, { width: "32px", height: "32px" })
7093
+ children: u ? /* @__PURE__ */ a.jsx(u, {}) : r.imageUrl ? null : /* @__PURE__ */ a.jsx(T1, { width: "32px", height: "32px" })
7094
7094
  }
7095
7095
  ),
7096
7096
  /* @__PURE__ */ a.jsx("div", { className: "sc-message--wrapper", children: /* @__PURE__ */ a.jsxs(
@@ -7098,16 +7098,16 @@ const St = ({ message: u, Avatar: D }) => {
7098
7098
  {
7099
7099
  className: "sc-message--text chatLink sc-message--contact-form-confirmation",
7100
7100
  style: {
7101
- color: e.text,
7102
- backgroundColor: e.bg
7101
+ color: t.text,
7102
+ backgroundColor: t.bg
7103
7103
  },
7104
7104
  children: [
7105
7105
  /* @__PURE__ */ a.jsx("div", { className: "sc-message--contact-form-phone-display", children: /* @__PURE__ */ a.jsx(
7106
7106
  "a",
7107
7107
  {
7108
- href: `tel:${D}`,
7108
+ href: `tel:${d}`,
7109
7109
  className: "sc-message--contact-form-phone-link",
7110
- children: D
7110
+ children: d
7111
7111
  }
7112
7112
  ) }),
7113
7113
  /* @__PURE__ */ a.jsxs("div", { className: "sc-message--contact-form-response-text", children: [
@@ -7131,7 +7131,7 @@ const St = ({ message: u, Avatar: D }) => {
7131
7131
  (g) => P.has(B(g.label)) || P.has(B(g.key))
7132
7132
  );
7133
7133
  }, v = mu(null), [x, m] = U();
7134
- return X(() => {
7134
+ return Z(() => {
7135
7135
  const T = (_) => {
7136
7136
  if (v.current) {
7137
7137
  const B = Math.round(
@@ -7151,14 +7151,14 @@ const St = ({ message: u, Avatar: D }) => {
7151
7151
  e && setTimeout(() => {
7152
7152
  T(D);
7153
7153
  }, 100);
7154
- }, [D, e]), X(() => {
7154
+ }, [D, e]), Z(() => {
7155
7155
  const T = () => {
7156
- const B = uu.getItem("profileLiveChat") || {};
7156
+ const B = X.getItem("profileLiveChat") || {};
7157
7157
  if (B.mobile) {
7158
7158
  const q = B.mobile, O = `${B.countryCode || "+61"} ${q}`;
7159
7159
  l(O);
7160
7160
  }
7161
- const I = uu.getItem("submitedFormLateTime") || B.submitedFormLateTime, P = t.some(
7161
+ const I = X.getItem("submitedFormLateTime") || B.submitedFormLateTime, P = t.some(
7162
7162
  (q) => q.data && "isShowForm" in q.data && q.data.isShowForm
7163
7163
  );
7164
7164
  if (y && !I && !P) {
@@ -7166,7 +7166,7 @@ const St = ({ message: u, Avatar: D }) => {
7166
7166
  mid: `show-text-${Date.now()}`,
7167
7167
  author: "system",
7168
7168
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
7169
- direction: Q.received,
7169
+ direction: uu.received,
7170
7170
  read: !0,
7171
7171
  delivery: !0,
7172
7172
  type: YD.text,
@@ -7182,7 +7182,7 @@ const St = ({ message: u, Avatar: D }) => {
7182
7182
  mid: `show-form-${Date.now()}`,
7183
7183
  author: "user",
7184
7184
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
7185
- direction: Q.received,
7185
+ direction: uu.received,
7186
7186
  read: !0,
7187
7187
  delivery: !0,
7188
7188
  type: YD.text,
@@ -7205,9 +7205,9 @@ const St = ({ message: u, Avatar: D }) => {
7205
7205
  return window.addEventListener("storage", _), () => {
7206
7206
  window.removeEventListener("storage", _);
7207
7207
  };
7208
- }, [y]), X(() => {
7208
+ }, [y]), Z(() => {
7209
7209
  r(t[t.length - 1]);
7210
- }, []), X(() => {
7210
+ }, []), Z(() => {
7211
7211
  const T = t[t.length - 1];
7212
7212
  (x == null ? void 0 : x.mid) !== (T == null ? void 0 : T.mid) && (m(T), f(100));
7213
7213
  }, [t]), /* @__PURE__ */ a.jsxs(
@@ -10473,7 +10473,7 @@ const Pt = /* @__PURE__ */ sf(Rt), It = [
10473
10473
  }
10474
10474
  ], Lt = ({ onBlur: u, onSelect: D }) => {
10475
10475
  const f = mu(new Pt()), e = mu(null);
10476
- X(() => {
10476
+ Z(() => {
10477
10477
  const n = e.current;
10478
10478
  n && (n.style.opacity = "0", window.requestAnimationFrame(() => {
10479
10479
  n.style.transition = "opacity 350ms", n.style.opacity = "1";
@@ -10720,7 +10720,7 @@ const Ht = ({ item: u, onPostback: D }) => {
10720
10720
  type: rf.nested,
10721
10721
  call_to_actions: (u == null ? void 0 : u.menu) || []
10722
10722
  }), n = mu(null);
10723
- X(() => {
10723
+ Z(() => {
10724
10724
  t({
10725
10725
  title: "Menu",
10726
10726
  type: rf.nested,
@@ -10829,24 +10829,24 @@ const Ht = ({ item: u, onPostback: D }) => {
10829
10829
  showFile: T,
10830
10830
  placeholder: _
10831
10831
  } = pu(), B = mu(null), [I, P] = U(null), [q, g] = U(!1), [O, $] = U(!1), [hu, fu] = U(!1);
10832
- X(() => {
10832
+ Z(() => {
10833
10833
  y && p();
10834
- }, [t, y]), X(() => {
10834
+ }, [t, y]), Z(() => {
10835
10835
  t === "" && B.current && (B.current.innerHTML = "", B.current.innerText = "");
10836
- }, [t]), X(() => {
10836
+ }, [t]), Z(() => {
10837
10837
  P(null);
10838
10838
  }, [r]);
10839
10839
  const k = () => {
10840
10840
  s(null), P(null);
10841
10841
  }, E = () => {
10842
- var Z, tu;
10842
+ var Q, tu;
10843
10843
  if (hu) {
10844
10844
  console.log("handleInput called but isClearing is true, ignoring");
10845
10845
  return;
10846
10846
  }
10847
- const z = ((Z = B.current) == null ? void 0 : Z.innerText) || ((tu = B.current) == null ? void 0 : tu.textContent) || "";
10847
+ const z = ((Q = B.current) == null ? void 0 : Q.innerText) || ((tu = B.current) == null ? void 0 : tu.textContent) || "";
10848
10848
  n(z);
10849
- }, h = (z, Z = "send-button") => {
10849
+ }, h = (z, Q = "send-button") => {
10850
10850
  if (O) {
10851
10851
  console.log("Already sending, ignoring duplicate call");
10852
10852
  return;
@@ -10856,7 +10856,7 @@ const Ht = ({ item: u, onPostback: D }) => {
10856
10856
  const tu = t;
10857
10857
  F({
10858
10858
  event: z,
10859
- source: Z,
10859
+ source: Q,
10860
10860
  data: {
10861
10861
  type: Au.text,
10862
10862
  data: { text: tu }
@@ -10869,7 +10869,7 @@ const Ht = ({ item: u, onPostback: D }) => {
10869
10869
  }
10870
10870
  r && (P(null), v.includes(r.type) || !1 ? r.size > u ? P(D("messages.file_message.unsupported_file_size")) : (F({
10871
10871
  event: z,
10872
- source: Z,
10872
+ source: Q,
10873
10873
  data: {
10874
10874
  type: Au.file,
10875
10875
  data: {
@@ -10885,7 +10885,7 @@ const Ht = ({ item: u, onPostback: D }) => {
10885
10885
  }, p = () => {
10886
10886
  var z;
10887
10887
  (z = B.current) == null || z.focus();
10888
- }, R = d === iD.uploading, N = uu.getItem("profileLiveChat") || {}, M = uu.getItem("isOffline") || (N == null ? void 0 : N.isOffline), V = ((J = N == null ? void 0 : N.channel) == null ? void 0 : J.name) === "console-channel";
10888
+ }, R = d === iD.uploading, N = X.getItem("profileLiveChat") || {}, M = X.getItem("isOffline") || (N == null ? void 0 : N.isOffline), V = ((J = N == null ? void 0 : N.channel) == null ? void 0 : J.name) === "console-channel";
10889
10889
  return (M || !(N != null && N.id)) && !V ? null : /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
10890
10890
  j.length > 0 && /* @__PURE__ */ a.jsx(Wt, {}),
10891
10891
  /* @__PURE__ */ a.jsxs("div", { className: "sc-user-input-wrapper", children: [
@@ -10935,9 +10935,9 @@ const Ht = ({ item: u, onPostback: D }) => {
10935
10935
  onPaste: async (z) => {
10936
10936
  var cu;
10937
10937
  z.preventDefault();
10938
- const Z = await navigator.clipboard.readText(), tu = (cu = window.getSelection()) == null ? void 0 : cu.getRangeAt(0);
10939
- if (tu && Z) {
10940
- const _u = document.createTextNode(Z);
10938
+ const Q = await navigator.clipboard.readText(), tu = (cu = window.getSelection()) == null ? void 0 : cu.getRangeAt(0);
10939
+ if (tu && Q) {
10940
+ const _u = document.createTextNode(Q);
10941
10941
  tu.deleteContents(), tu.insertNode(_u), tu.collapse(!1);
10942
10942
  }
10943
10943
  E();
@@ -10996,7 +10996,7 @@ const Ht = ({ item: u, onPostback: D }) => {
10996
10996
  }
10997
10997
  ), Zt = () => {
10998
10998
  const { t: u } = zu(), { colors: D } = ou(), { setWebviewUrl: f, webviewUrl: e } = Cu(), [t, n] = U(!1);
10999
- X(() => {
10999
+ Z(() => {
11000
11000
  n(!0);
11001
11001
  }, []);
11002
11002
  const r = () => {
@@ -11043,8 +11043,8 @@ const Ht = ({ item: u, onPostback: D }) => {
11043
11043
  const n = Wu(), r = Cu(), s = Nu(), { socket: F } = Gu(), { setScreen: d } = Nu(), o = pu(), c = o.offline_mode, l = kD(c), j = (C) => {
11044
11044
  C.preventDefault(), s.setIsOpen(!s.isOpen);
11045
11045
  };
11046
- return xe(), new URLSearchParams().append("owner_id", n.ownerId), X(() => {
11047
- if (!l && !uu.getItem("profileLiveChat")) {
11046
+ return xe(), new URLSearchParams().append("owner_id", n.ownerId), Z(() => {
11047
+ if (!l && !X.getItem("profileLiveChat")) {
11048
11048
  d("prechat");
11049
11049
  return;
11050
11050
  }
@@ -11110,8 +11110,8 @@ const Ht = ({ item: u, onPostback: D }) => {
11110
11110
  );
11111
11111
  const T = mu(!1), _ = Mu(
11112
11112
  async (B) => {
11113
- if (B == null || B.preventDefault(), B == null || B.stopPropagation(), !(!uu.getItem("profileLiveChat") && !v(n.formSettings))) {
11114
- Object.keys(l).length > 0 && uu.setItem("dataUserSubs", l);
11113
+ if (B == null || B.preventDefault(), B == null || B.stopPropagation(), !(!X.getItem("profileLiveChat") && !v(n.formSettings))) {
11114
+ Object.keys(l).length > 0 && X.setItem("dataUserSubs", l);
11115
11115
  try {
11116
11116
  d(2);
11117
11117
  const P = new URLSearchParams();
@@ -11119,12 +11119,12 @@ const Ht = ({ item: u, onPostback: D }) => {
11119
11119
  typeof k == "string" && k.trim() && P.append(fu, k);
11120
11120
  }), P.append("contactLateTime", (/* @__PURE__ */ new Date()).toISOString()), P.append("owner_id", D.ownerId);
11121
11121
  const { body: q } = await t.get(`/webhook/${D.channel}/?${P.toString()}`), { messages: g, profile: O } = q;
11122
- console.log("jump here 1"), uu.setItem("profileLiveChat", O), uu.setItem("isOffline", m || !1), uu.setItem(
11122
+ console.log("jump here 1"), X.setItem("profileLiveChat", O), X.setItem("isOffline", m || !1), X.setItem(
11123
11123
  "submitedFormLateTime",
11124
11124
  (O == null ? void 0 : O.submitedFormLateTime) || null
11125
11125
  ), g.forEach((fu) => {
11126
- const k = fu.author === O.foreignId || fu.author === O.id ? Q.sent : Q.received;
11127
- fu.direction = k, fu.direction === Q.sent && (fu.read = !0, fu.delivery = !1);
11126
+ const k = fu.author === O.foreignId || fu.author === O.id ? uu.sent : uu.received;
11127
+ fu.direction = k, fu.direction === uu.sent && (fu.read = !0, fu.delivery = !1);
11128
11128
  }), F(g), c([
11129
11129
  o[0],
11130
11130
  {
@@ -11173,10 +11173,10 @@ const Ht = ({ item: u, onPostback: D }) => {
11173
11173
  t
11174
11174
  ]
11175
11175
  );
11176
- return X(() => {
11176
+ return Z(() => {
11177
11177
  if (!T.current) {
11178
11178
  T.current = !0;
11179
- const B = uu.getItem("profileLiveChat");
11179
+ const B = X.getItem("profileLiveChat");
11180
11180
  if (B) {
11181
11181
  const I = B, P = {};
11182
11182
  Object.entries(I).forEach(([q, g]) => {
@@ -11225,7 +11225,7 @@ const Ht = ({ item: u, onPostback: D }) => {
11225
11225
  console.warn("Unable to get cookies ...");
11226
11226
  }
11227
11227
  };
11228
- return X(() => {
11228
+ return Z(() => {
11229
11229
  f || t();
11230
11230
  }, []), f ? /* @__PURE__ */ a.jsx(u8.Provider, { value: {}, children: u }) : null;
11231
11231
  };
@@ -11254,6 +11254,6 @@ function r8({
11254
11254
  }
11255
11255
  export {
11256
11256
  n8 as ChatWidget,
11257
- uu as LocalStorageScoped,
11257
+ X as LocalStorageScoped,
11258
11258
  r8 as UiChatWidget
11259
11259
  };