@opencx/widget 2.3.0 → 2.4.0

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.
Files changed (66) hide show
  1. package/dist/basic.cjs +64 -64
  2. package/dist/basic.cjs.map +1 -1
  3. package/dist/basic.js +7105 -7012
  4. package/dist/basic.js.map +1 -1
  5. package/dist/core/types/schemas-v2.d.ts +25 -0
  6. package/dist/index-BDLPOpfl.cjs +18 -0
  7. package/dist/index-BDLPOpfl.cjs.map +1 -0
  8. package/dist/{index-BQfnx4Er.js → index-CgATAy4r.js} +606 -560
  9. package/dist/index-CgATAy4r.js.map +1 -0
  10. package/dist/{react-lib → react-web}/hooks/useAxiosInstance.d.ts +21 -1
  11. package/dist/react-web/hooks/useVote.d.ts +18 -0
  12. package/dist/{react-lib → react-web}/index.d.ts +1 -1
  13. package/dist/react.cjs +1 -1
  14. package/dist/react.cjs.map +1 -1
  15. package/dist/react.d.ts +1 -1
  16. package/dist/react.js +14 -28
  17. package/dist/react.js.map +1 -1
  18. package/dist/src/@components/BotMessageWrapper.d.ts +3 -1
  19. package/dist/src/@components/ChatEvent.component.d.ts +1 -1
  20. package/dist/src/@components/Fallback.component.d.ts +1 -1
  21. package/dist/src/@components/Text.component.d.ts +1 -1
  22. package/dist/src/components/VoteButtons.d.ts +8 -0
  23. package/dist/src/components/button.d.ts +1 -1
  24. package/dist/src/components/userMessage.d.ts +1 -1
  25. package/dist/src/designs/basic/index.d.ts +1 -1
  26. package/dist/style.css +1 -1
  27. package/dist-embed/script.js +101 -91
  28. package/dist-embed/script.js.map +1 -1
  29. package/package.json +1 -1
  30. package/dist/index-B7LNpE9i.cjs +0 -18
  31. package/dist/index-B7LNpE9i.cjs.map +0 -1
  32. package/dist/index-BQfnx4Er.js.map +0 -1
  33. package/dist/react-lib/hooks/useVote.d.ts +0 -2
  34. /package/dist/{react-lib → react-web}/Root.d.ts +0 -0
  35. /package/dist/{react-lib → react-web}/hooks/index.d.ts +0 -0
  36. /package/dist/{react-lib → react-web}/hooks/use-sound.d.ts +0 -0
  37. /package/dist/{react-lib → react-web}/hooks/use-sound.test.d.ts +0 -0
  38. /package/dist/{react-lib → react-web}/hooks/use-sync-state.test.d.ts +0 -0
  39. /package/dist/{react-lib → react-web}/hooks/useAbstractChat.d.ts +0 -0
  40. /package/dist/{react-lib → react-web}/hooks/useScrollTo.d.ts +0 -0
  41. /package/dist/{react-lib → react-web}/hooks/useSyncState.d.ts +0 -0
  42. /package/dist/{react-lib → react-web}/hooks/useTimeoutState.d.ts +0 -0
  43. /package/dist/{react-lib → react-web}/hooks/useUploadFiles.d.ts +0 -0
  44. /package/dist/{react-lib → react-web}/hooks/useWidgetContentHeight.d.ts +0 -0
  45. /package/dist/{react-lib → react-web}/locales/ar.locale.d.ts +0 -0
  46. /package/dist/{react-lib → react-web}/locales/de.locale.d.ts +0 -0
  47. /package/dist/{react-lib → react-web}/locales/en.locale.d.ts +0 -0
  48. /package/dist/{react-lib → react-web}/locales/fr.locale.d.ts +0 -0
  49. /package/dist/{react-lib → react-web}/locales/helper.d.ts +0 -0
  50. /package/dist/{react-lib → react-web}/locales/index.d.ts +0 -0
  51. /package/dist/{react-lib → react-web}/locales/nl.locale.d.ts +0 -0
  52. /package/dist/{react-lib → react-web}/locales/pt.locale.d.ts +0 -0
  53. /package/dist/{react-lib → react-web}/providers/ChatProvider.d.ts +0 -0
  54. /package/dist/{react-lib → react-web}/providers/ConfigDataProvider.d.ts +0 -0
  55. /package/dist/{react-lib → react-web}/providers/ContactProvider.d.ts +0 -0
  56. /package/dist/{react-lib → react-web}/providers/LocalesProvider.d.ts +0 -0
  57. /package/dist/{react-lib → react-web}/providers/componentRegistry.d.ts +0 -0
  58. /package/dist/{react-lib → react-web}/providers/use-widget-sfx.d.ts +0 -0
  59. /package/dist/{react-lib → react-web}/providers/usePreludeData.d.ts +0 -0
  60. /package/dist/{react-lib → react-web}/types/components.d.ts +0 -0
  61. /package/dist/{react-lib → react-web}/types/index.d.ts +0 -0
  62. /package/dist/{react-lib → react-web}/types/options.d.ts +0 -0
  63. /package/dist/{react-lib → react-web}/utils/create-safe-context.d.ts +0 -0
  64. /package/dist/{react-lib → react-web}/utils/debug.d.ts +0 -0
  65. /package/dist/{react-lib → react-web}/utils/getters.d.ts +0 -0
  66. /package/dist/{react-lib → react-web}/utils/index.d.ts +0 -0
@@ -1,13 +1,13 @@
1
1
  var rn = Object.defineProperty;
2
2
  var sn = (e, t, n) => t in e ? rn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var st = (e, t, n) => sn(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { g as te, S as gt, A as on } from "./schemas-BBAV6Sd_.js";
5
- import de, { useMemo as re, useState as We, useCallback as ge, useEffect as le, createContext as ht, useContext as mt, useRef as oe, useReducer as an, useLayoutEffect as cn, useDebugValue as un } from "react";
6
- import { jsx as ne } from "react/jsx-runtime";
3
+ var rt = (e, t, n) => sn(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { g as ee, S as pt, A as on } from "./schemas-BBAV6Sd_.js";
5
+ import de, { useMemo as ne, useState as Qe, useCallback as ge, useEffect as le, createContext as gt, useContext as ht, useRef as ae, useReducer as an, useLayoutEffect as cn, useDebugValue as un } from "react";
6
+ import { jsx as te } from "react/jsx-runtime";
7
7
  import { create as ln } from "mutative";
8
8
  import dn from "lodash.set";
9
9
  import fn from "axios";
10
- const pn = typeof window > "u", ot = {
10
+ const pn = typeof window > "u", st = {
11
11
  getItem: () => null,
12
12
  setItem: () => {
13
13
  },
@@ -15,10 +15,10 @@ const pn = typeof window > "u", ot = {
15
15
  }
16
16
  };
17
17
  function gn(e) {
18
- return pn ? ot : e === "local" ? localStorage : e === "session" ? sessionStorage : ot;
18
+ return pn ? st : e === "local" ? localStorage : e === "session" ? sessionStorage : st;
19
19
  }
20
- function Ke(e, t, n = "session") {
21
- const r = re(() => gn(n), [n]), [s, o] = We(() => {
20
+ function We(e, t, n = "session") {
21
+ const r = ne(() => gn(n), [n]), [s, o] = Qe(() => {
22
22
  const p = r.getItem(e);
23
23
  if (p !== null)
24
24
  try {
@@ -54,7 +54,7 @@ function Ke(e, t, n = "session") {
54
54
  };
55
55
  }, [e, s]), [s, a, l];
56
56
  }
57
- const hn = "@opencx/widget", yt = "2.3.0", mn = "module", yn = {
57
+ const hn = "@opencx/widget", mt = "2.4.0", mn = "module", yn = {
58
58
  access: "public"
59
59
  }, Sn = {
60
60
  clean: "rm -rf ./dist ./dist-embed",
@@ -126,7 +126,7 @@ const hn = "@opencx/widget", yt = "2.3.0", mn = "module", yn = {
126
126
  }, Cn = {
127
127
  name: "openchatai",
128
128
  url: "https://github.com/openchatai"
129
- }, _n = "./dist/index.js", Nn = "./dist/index.js", Dn = "./dist/index.d.ts", xn = !1, Pn = {
129
+ }, Nn = "./dist/index.js", Dn = "./dist/index.js", _n = "./dist/index.d.ts", xn = !1, Pn = {
130
130
  ".": {
131
131
  types: "./dist/index.d.ts",
132
132
  import: "./dist/index.js",
@@ -186,7 +186,7 @@ const hn = "@opencx/widget", yt = "2.3.0", mn = "module", yn = {
186
186
  }, jn = {
187
187
  name: hn,
188
188
  private: !1,
189
- version: yt,
189
+ version: mt,
190
190
  type: mn,
191
191
  publishConfig: yn,
192
192
  scripts: Sn,
@@ -199,23 +199,23 @@ const hn = "@opencx/widget", yt = "2.3.0", mn = "module", yn = {
199
199
  files: Tn,
200
200
  bugs: Rn,
201
201
  author: Cn,
202
- main: _n,
203
- module: Nn,
204
- types: Dn,
202
+ main: Nn,
203
+ module: Dn,
204
+ types: _n,
205
205
  sideEffects: xn,
206
206
  exports: Pn,
207
207
  devDependencies: In
208
208
  }, kn = "X-Bot-Token", Mn = "X-Widget-Version";
209
- function St(e) {
210
- const t = re(() => fn.create({
209
+ function yt(e) {
210
+ const t = ne(() => fn.create({
211
211
  baseURL: e.apiUrl,
212
212
  headers: {
213
213
  [kn]: e.botToken,
214
- [Mn]: yt,
214
+ [Mn]: mt,
215
215
  "X-Use-Guard": !0
216
216
  }
217
217
  }), [e]);
218
- return { apis: re(
218
+ return { apis: ne(
219
219
  () => ({
220
220
  createSession: (r) => {
221
221
  if (!r)
@@ -243,7 +243,19 @@ function St(e) {
243
243
  `widget/session/history/${r}`
244
244
  );
245
245
  },
246
+ /**
247
+ * downvote a message
248
+ * @param id
249
+ * @returns
250
+ * @deprecated use vote instead
251
+ */
246
252
  downvote: (r) => t.delete(`/chat/vote/${r}`),
253
+ /**
254
+ * upvote a message
255
+ * @param id
256
+ * @returns
257
+ * @deprecated use vote instead
258
+ */
247
259
  upvote: (r) => t.post(`/chat/vote/${r}`),
248
260
  /**
249
261
  * given the userData object we will create or update the contact + get the related conversations/tickets/sessions
@@ -277,21 +289,26 @@ function St(e) {
277
289
  * send a message to the chat
278
290
  * @param message
279
291
  */
280
- sendMessage: async (r) => t.post("widget/chat/send", r)
292
+ sendMessage: async (r) => t.post("widget/chat/send", r),
293
+ /**
294
+ * vote on a message
295
+ * @param data
296
+ */
297
+ vote: (r) => t.post("/widget/chat/vote", r)
281
298
  }),
282
299
  [t]
283
300
  ), options: e };
284
301
  }
285
302
  function Ce(e) {
286
- const t = ht({});
303
+ const t = gt({});
287
304
  return [() => {
288
- const r = mt(t);
305
+ const r = ht(t);
289
306
  if (r === void 0)
290
307
  throw new Error("useSafeContext must be used within a Provider");
291
308
  return r;
292
309
  }, t.Provider];
293
310
  }
294
- const Ln = {
311
+ const Fn = {
295
312
  ok: "حسنا",
296
313
  yes: "نعم",
297
314
  no: "لا",
@@ -344,7 +361,7 @@ const Ln = {
344
361
  "start-chat": "تحدث إلى الدعم",
345
362
  "starting-chat": "جاري الاتصال...",
346
363
  "hello-greeting": "مرحبًا! كيف يمكننا مساعدتك اليوم؟"
347
- }, Fn = {
364
+ }, Ln = {
348
365
  ok: "OK",
349
366
  yes: "Ja",
350
367
  no: "Nein",
@@ -611,10 +628,10 @@ const Ln = {
611
628
  "hello-greeting": "Olá! Como podemos ajudar você hoje?"
612
629
  }, zn = {
613
630
  en: Vn,
614
- ar: Ln,
631
+ ar: Fn,
615
632
  nl: Hn,
616
633
  fr: Un,
617
- de: Fn,
634
+ de: Ln,
618
635
  pt: Gn
619
636
  };
620
637
  function Yn(e, t) {
@@ -622,9 +639,9 @@ function Yn(e, t) {
622
639
  return n && n[e] || "";
623
640
  }
624
641
  const [as, Bn] = Ce();
625
- function vt({ children: e }) {
626
- const t = ce();
627
- return /* @__PURE__ */ ne(
642
+ function St({ children: e }) {
643
+ const t = B();
644
+ return /* @__PURE__ */ te(
628
645
  Bn,
629
646
  {
630
647
  value: {
@@ -637,7 +654,7 @@ function vt({ children: e }) {
637
654
  }
638
655
  class qn {
639
656
  constructor(t) {
640
- st(this, "components", [
657
+ rt(this, "components", [
641
658
  {
642
659
  key: "FALLBACK",
643
660
  component: (t) => "fallback"
@@ -676,7 +693,7 @@ const Xn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABlCAYAAAC7vkbxAA
676
693
  triggerOffset: "20px"
677
694
  };
678
695
  function Wn(e) {
679
- return re(() => {
696
+ return ne(() => {
680
697
  var s, o, a, l;
681
698
  const t = {
682
699
  messageArrived: "https://cloud.opencopilot.so/sfx/notification3.mp3",
@@ -708,25 +725,25 @@ function Wn(e) {
708
725
  };
709
726
  }, [e]);
710
727
  }
711
- const [ce, Kn] = Ce(), Jn = "en";
728
+ const [B, Kn] = Ce(), Jn = "en";
712
729
  function Zn({
713
730
  children: e,
714
731
  data: t
715
732
  }) {
716
- const n = re(
733
+ const n = ne(
717
734
  () => new qn({
718
735
  components: t.components
719
736
  }),
720
737
  [t]
721
- ), r = Wn(t), s = St({
738
+ ), r = Wn(t), s = yt({
722
739
  apiUrl: r.apiUrl,
723
740
  botToken: r.token
724
- }), [o, a] = Ke(
741
+ }), [o, a] = We(
725
742
  "open_settings",
726
743
  r.defaultSettings,
727
744
  "local"
728
745
  );
729
- return /* @__PURE__ */ ne(
746
+ return /* @__PURE__ */ te(
730
747
  Kn,
731
748
  {
732
749
  value: { ...r, http: s, componentStore: n, widgetSettings: o, setSettings: (p) => {
@@ -738,7 +755,7 @@ function Zn({
738
755
  );
739
756
  a(u);
740
757
  } },
741
- children: /* @__PURE__ */ ne(vt, { children: e })
758
+ children: /* @__PURE__ */ te(St, { children: e })
742
759
  }
743
760
  );
744
761
  }
@@ -765,17 +782,17 @@ function $n(e) {
765
782
  });
766
783
  }), n;
767
784
  }
768
- var Et = {}, He = function(e, t) {
769
- return He = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
785
+ var vt = {}, Ue = function(e, t) {
786
+ return Ue = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
770
787
  n.__proto__ = r;
771
788
  } || function(n, r) {
772
789
  for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (n[s] = r[s]);
773
- }, He(e, t);
790
+ }, Ue(e, t);
774
791
  };
775
- function wt(e, t) {
792
+ function Et(e, t) {
776
793
  if (typeof t != "function" && t !== null)
777
794
  throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
778
- He(e, t);
795
+ Ue(e, t);
779
796
  function n() {
780
797
  this.constructor = e;
781
798
  }
@@ -790,7 +807,7 @@ var Te = function() {
790
807
  return t;
791
808
  }, Te.apply(this, arguments);
792
809
  };
793
- function bt(e, t) {
810
+ function wt(e, t) {
794
811
  var n = {};
795
812
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
796
813
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
@@ -798,18 +815,18 @@ function bt(e, t) {
798
815
  t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[s]) && (n[r[s]] = e[r[s]]);
799
816
  return n;
800
817
  }
801
- function Ot(e, t, n, r) {
818
+ function bt(e, t, n, r) {
802
819
  var s = arguments.length, o = s < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, a;
803
820
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") o = Reflect.decorate(e, t, n, r);
804
821
  else for (var l = e.length - 1; l >= 0; l--) (a = e[l]) && (o = (s < 3 ? a(o) : s > 3 ? a(t, n, o) : a(t, n)) || o);
805
822
  return s > 3 && o && Object.defineProperty(t, n, o), o;
806
823
  }
807
- function At(e, t) {
824
+ function Ot(e, t) {
808
825
  return function(n, r) {
809
826
  t(n, r, e);
810
827
  };
811
828
  }
812
- function Tt(e, t, n, r, s, o) {
829
+ function At(e, t, n, r, s, o) {
813
830
  function a(h) {
814
831
  if (h !== void 0 && typeof h != "function") throw new TypeError("Function expected");
815
832
  return h;
@@ -831,15 +848,15 @@ function Tt(e, t, n, r, s, o) {
831
848
  }
832
849
  u && Object.defineProperty(u, r.name, c), g = !0;
833
850
  }
834
- function Rt(e, t, n) {
851
+ function Tt(e, t, n) {
835
852
  for (var r = arguments.length > 2, s = 0; s < t.length; s++)
836
853
  n = r ? t[s].call(e, n) : t[s].call(e);
837
854
  return r ? n : void 0;
838
855
  }
839
- function Ct(e) {
856
+ function Rt(e) {
840
857
  return typeof e == "symbol" ? e : "".concat(e);
841
858
  }
842
- function _t(e, t, n) {
859
+ function Ct(e, t, n) {
843
860
  return typeof t == "symbol" && (t = t.description ? "[".concat(t.description, "]") : ""), Object.defineProperty(e, "name", { configurable: !0, value: n ? "".concat(n, " ", t) : t });
844
861
  }
845
862
  function Nt(e, t) {
@@ -872,7 +889,7 @@ function Dt(e, t, n, r) {
872
889
  u((r = r.apply(e, t || [])).next());
873
890
  });
874
891
  }
875
- function xt(e, t) {
892
+ function _t(e, t) {
876
893
  var n = { label: 0, sent: function() {
877
894
  if (o[0] & 1) throw o[1];
878
895
  return o[1];
@@ -932,7 +949,7 @@ function xt(e, t) {
932
949
  return { value: u[0] ? u[1] : void 0, done: !0 };
933
950
  }
934
951
  }
935
- var _e = Object.create ? function(e, t, n, r) {
952
+ var Ne = Object.create ? function(e, t, n, r) {
936
953
  r === void 0 && (r = n);
937
954
  var s = Object.getOwnPropertyDescriptor(t, n);
938
955
  (!s || ("get" in s ? !t.__esModule : s.writable || s.configurable)) && (s = { enumerable: !0, get: function() {
@@ -941,8 +958,8 @@ var _e = Object.create ? function(e, t, n, r) {
941
958
  } : function(e, t, n, r) {
942
959
  r === void 0 && (r = n), e[r] = t[n];
943
960
  };
944
- function Pt(e, t) {
945
- for (var n in e) n !== "default" && !Object.prototype.hasOwnProperty.call(t, n) && _e(t, e, n);
961
+ function xt(e, t) {
962
+ for (var n in e) n !== "default" && !Object.prototype.hasOwnProperty.call(t, n) && Ne(t, e, n);
946
963
  }
947
964
  function Re(e) {
948
965
  var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
@@ -954,7 +971,7 @@ function Re(e) {
954
971
  };
955
972
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
956
973
  }
957
- function Je(e, t) {
974
+ function Ke(e, t) {
958
975
  var n = typeof Symbol == "function" && e[Symbol.iterator];
959
976
  if (!n) return e;
960
977
  var r = n.call(e), s, o = [], a;
@@ -971,19 +988,19 @@ function Je(e, t) {
971
988
  }
972
989
  return o;
973
990
  }
974
- function It() {
991
+ function Pt() {
975
992
  for (var e = [], t = 0; t < arguments.length; t++)
976
- e = e.concat(Je(arguments[t]));
993
+ e = e.concat(Ke(arguments[t]));
977
994
  return e;
978
995
  }
979
- function jt() {
996
+ function It() {
980
997
  for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
981
998
  for (var r = Array(e), s = 0, t = 0; t < n; t++)
982
999
  for (var o = arguments[t], a = 0, l = o.length; a < l; a++, s++)
983
1000
  r[s] = o[a];
984
1001
  return r;
985
1002
  }
986
- function kt(e, t, n) {
1003
+ function jt(e, t, n) {
987
1004
  if (n || arguments.length === 2) for (var r = 0, s = t.length, o; r < s; r++)
988
1005
  (o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
989
1006
  return e.concat(o || Array.prototype.slice.call(t));
@@ -991,7 +1008,7 @@ function kt(e, t, n) {
991
1008
  function he(e) {
992
1009
  return this instanceof he ? (this.v = e, this) : new he(e);
993
1010
  }
994
- function Mt(e, t, n) {
1011
+ function kt(e, t, n) {
995
1012
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
996
1013
  var r = n.apply(e, t || []), s, o = [];
997
1014
  return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), l("next"), l("throw"), l("return", a), s[Symbol.asyncIterator] = function() {
@@ -1029,7 +1046,7 @@ function Mt(e, t, n) {
1029
1046
  f(m), o.shift(), o.length && p(o[0][0], o[0][1]);
1030
1047
  }
1031
1048
  }
1032
- function Lt(e) {
1049
+ function Mt(e) {
1033
1050
  var t, n;
1034
1051
  return t = {}, r("next"), r("throw", function(s) {
1035
1052
  throw s;
@@ -1061,7 +1078,7 @@ function Ft(e) {
1061
1078
  }, a);
1062
1079
  }
1063
1080
  }
1064
- function Vt(e, t) {
1081
+ function Lt(e, t) {
1065
1082
  return Object.defineProperty ? Object.defineProperty(e, "raw", { value: t }) : e.raw = t, e;
1066
1083
  }
1067
1084
  var er = Object.create ? function(e, t) {
@@ -1069,31 +1086,31 @@ var er = Object.create ? function(e, t) {
1069
1086
  } : function(e, t) {
1070
1087
  e.default = t;
1071
1088
  };
1072
- function Ut(e) {
1089
+ function Vt(e) {
1073
1090
  if (e && e.__esModule) return e;
1074
1091
  var t = {};
1075
- if (e != null) for (var n in e) n !== "default" && Object.prototype.hasOwnProperty.call(e, n) && _e(t, e, n);
1092
+ if (e != null) for (var n in e) n !== "default" && Object.prototype.hasOwnProperty.call(e, n) && Ne(t, e, n);
1076
1093
  return er(t, e), t;
1077
1094
  }
1078
- function Ht(e) {
1095
+ function Ut(e) {
1079
1096
  return e && e.__esModule ? e : { default: e };
1080
1097
  }
1081
- function Gt(e, t, n, r) {
1098
+ function Ht(e, t, n, r) {
1082
1099
  if (n === "a" && !r) throw new TypeError("Private accessor was defined without a getter");
1083
1100
  if (typeof t == "function" ? e !== t || !r : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1084
1101
  return n === "m" ? r : n === "a" ? r.call(e) : r ? r.value : t.get(e);
1085
1102
  }
1086
- function zt(e, t, n, r, s) {
1103
+ function Gt(e, t, n, r, s) {
1087
1104
  if (r === "m") throw new TypeError("Private method is not writable");
1088
1105
  if (r === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
1089
1106
  if (typeof t == "function" ? e !== t || !s : !t.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1090
1107
  return r === "a" ? s.call(e, n) : s ? s.value = n : t.set(e, n), n;
1091
1108
  }
1092
- function Yt(e, t) {
1109
+ function zt(e, t) {
1093
1110
  if (t === null || typeof t != "object" && typeof t != "function") throw new TypeError("Cannot use 'in' operator on non-object");
1094
1111
  return typeof e == "function" ? t === e : e.has(t);
1095
1112
  }
1096
- function Bt(e, t, n) {
1113
+ function Yt(e, t, n) {
1097
1114
  if (t != null) {
1098
1115
  if (typeof t != "object" && typeof t != "function") throw new TypeError("Object expected.");
1099
1116
  var r, s;
@@ -1120,7 +1137,7 @@ var tr = typeof SuppressedError == "function" ? SuppressedError : function(e, t,
1120
1137
  var r = new Error(n);
1121
1138
  return r.name = "SuppressedError", r.error = e, r.suppressed = t, r;
1122
1139
  };
1123
- function qt(e) {
1140
+ function Bt(e) {
1124
1141
  function t(o) {
1125
1142
  e.error = e.hasError ? new tr(o, e.error, "An error was suppressed during disposal.") : o, e.hasError = !0;
1126
1143
  }
@@ -1143,86 +1160,86 @@ function qt(e) {
1143
1160
  }
1144
1161
  return s();
1145
1162
  }
1146
- function Xt(e, t) {
1163
+ function qt(e, t) {
1147
1164
  return typeof e == "string" && /^\.\.?\//.test(e) ? e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(n, r, s, o, a) {
1148
1165
  return r ? t ? ".jsx" : ".js" : s && (!o || !a) ? n : s + o + "." + a.toLowerCase() + "js";
1149
1166
  }) : e;
1150
1167
  }
1151
1168
  const nr = {
1152
- __extends: wt,
1169
+ __extends: Et,
1153
1170
  __assign: Te,
1154
- __rest: bt,
1155
- __decorate: Ot,
1156
- __param: At,
1157
- __esDecorate: Tt,
1158
- __runInitializers: Rt,
1159
- __propKey: Ct,
1160
- __setFunctionName: _t,
1171
+ __rest: wt,
1172
+ __decorate: bt,
1173
+ __param: Ot,
1174
+ __esDecorate: At,
1175
+ __runInitializers: Tt,
1176
+ __propKey: Rt,
1177
+ __setFunctionName: Ct,
1161
1178
  __metadata: Nt,
1162
1179
  __awaiter: Dt,
1163
- __generator: xt,
1164
- __createBinding: _e,
1165
- __exportStar: Pt,
1180
+ __generator: _t,
1181
+ __createBinding: Ne,
1182
+ __exportStar: xt,
1166
1183
  __values: Re,
1167
- __read: Je,
1168
- __spread: It,
1169
- __spreadArrays: jt,
1170
- __spreadArray: kt,
1184
+ __read: Ke,
1185
+ __spread: Pt,
1186
+ __spreadArrays: It,
1187
+ __spreadArray: jt,
1171
1188
  __await: he,
1172
- __asyncGenerator: Mt,
1173
- __asyncDelegator: Lt,
1189
+ __asyncGenerator: kt,
1190
+ __asyncDelegator: Mt,
1174
1191
  __asyncValues: Ft,
1175
- __makeTemplateObject: Vt,
1176
- __importStar: Ut,
1177
- __importDefault: Ht,
1178
- __classPrivateFieldGet: Gt,
1179
- __classPrivateFieldSet: zt,
1180
- __classPrivateFieldIn: Yt,
1181
- __addDisposableResource: Bt,
1182
- __disposeResources: qt,
1183
- __rewriteRelativeImportExtension: Xt
1192
+ __makeTemplateObject: Lt,
1193
+ __importStar: Vt,
1194
+ __importDefault: Ut,
1195
+ __classPrivateFieldGet: Ht,
1196
+ __classPrivateFieldSet: Gt,
1197
+ __classPrivateFieldIn: zt,
1198
+ __addDisposableResource: Yt,
1199
+ __disposeResources: Bt,
1200
+ __rewriteRelativeImportExtension: qt
1184
1201
  }, rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1185
1202
  __proto__: null,
1186
- __addDisposableResource: Bt,
1203
+ __addDisposableResource: Yt,
1187
1204
  get __assign() {
1188
1205
  return Te;
1189
1206
  },
1190
- __asyncDelegator: Lt,
1191
- __asyncGenerator: Mt,
1207
+ __asyncDelegator: Mt,
1208
+ __asyncGenerator: kt,
1192
1209
  __asyncValues: Ft,
1193
1210
  __await: he,
1194
1211
  __awaiter: Dt,
1195
- __classPrivateFieldGet: Gt,
1196
- __classPrivateFieldIn: Yt,
1197
- __classPrivateFieldSet: zt,
1198
- __createBinding: _e,
1199
- __decorate: Ot,
1200
- __disposeResources: qt,
1201
- __esDecorate: Tt,
1202
- __exportStar: Pt,
1203
- __extends: wt,
1204
- __generator: xt,
1205
- __importDefault: Ht,
1206
- __importStar: Ut,
1207
- __makeTemplateObject: Vt,
1212
+ __classPrivateFieldGet: Ht,
1213
+ __classPrivateFieldIn: zt,
1214
+ __classPrivateFieldSet: Gt,
1215
+ __createBinding: Ne,
1216
+ __decorate: bt,
1217
+ __disposeResources: Bt,
1218
+ __esDecorate: At,
1219
+ __exportStar: xt,
1220
+ __extends: Et,
1221
+ __generator: _t,
1222
+ __importDefault: Ut,
1223
+ __importStar: Vt,
1224
+ __makeTemplateObject: Lt,
1208
1225
  __metadata: Nt,
1209
- __param: At,
1210
- __propKey: Ct,
1211
- __read: Je,
1212
- __rest: bt,
1213
- __rewriteRelativeImportExtension: Xt,
1214
- __runInitializers: Rt,
1215
- __setFunctionName: _t,
1216
- __spread: It,
1217
- __spreadArray: kt,
1218
- __spreadArrays: jt,
1226
+ __param: Ot,
1227
+ __propKey: Rt,
1228
+ __read: Ke,
1229
+ __rest: wt,
1230
+ __rewriteRelativeImportExtension: qt,
1231
+ __runInitializers: Tt,
1232
+ __setFunctionName: Ct,
1233
+ __spread: Pt,
1234
+ __spreadArray: jt,
1235
+ __spreadArrays: It,
1219
1236
  __values: Re,
1220
1237
  default: nr
1221
1238
  }, Symbol.toStringTag, { value: "Module" })), sr = /* @__PURE__ */ $n(rr);
1222
- var be = {}, at;
1239
+ var be = {}, ot;
1223
1240
  function or() {
1224
- if (at) return be;
1225
- at = 1, Object.defineProperty(be, "__esModule", { value: !0 });
1241
+ if (ot) return be;
1242
+ ot = 1, Object.defineProperty(be, "__esModule", { value: !0 });
1226
1243
  var e = de;
1227
1244
  function t() {
1228
1245
  var n = e.useRef(!1), r = e.useCallback(function() {
@@ -1236,16 +1253,16 @@ function or() {
1236
1253
  }
1237
1254
  return be.default = t, be;
1238
1255
  }
1239
- Object.defineProperty(Et, "__esModule", { value: !0 });
1240
- var Ge = sr, Ie = de, ar = Ge.__importDefault(or());
1256
+ Object.defineProperty(vt, "__esModule", { value: !0 });
1257
+ var He = sr, Pe = de, ar = He.__importDefault(or());
1241
1258
  function ir(e, t, n) {
1242
1259
  t === void 0 && (t = []), n === void 0 && (n = { loading: !1 });
1243
- var r = Ie.useRef(0), s = ar.default(), o = Ie.useState(n), a = o[0], l = o[1], p = Ie.useCallback(function() {
1260
+ var r = Pe.useRef(0), s = ar.default(), o = Pe.useState(n), a = o[0], l = o[1], p = Pe.useCallback(function() {
1244
1261
  for (var u = [], c = 0; c < arguments.length; c++)
1245
1262
  u[c] = arguments[c];
1246
1263
  var i = ++r.current;
1247
1264
  return a.loading || l(function(g) {
1248
- return Ge.__assign(Ge.__assign({}, g), { loading: !0 });
1265
+ return He.__assign(He.__assign({}, g), { loading: !0 });
1249
1266
  }), e.apply(void 0, u).then(function(g) {
1250
1267
  return s() && i === r.current && l({ value: g, loading: !1 }), g;
1251
1268
  }, function(g) {
@@ -1254,14 +1271,35 @@ function ir(e, t, n) {
1254
1271
  }, t);
1255
1272
  return [a, p];
1256
1273
  }
1257
- var $ = Et.default = ir;
1258
- const se = /* @__PURE__ */ new Map();
1259
- function us() {
1260
- const [e, t] = We([]), { http: n } = ce();
1274
+ var Y = vt.default = ir;
1275
+ function us(e, t, n) {
1276
+ const { http: r } = B();
1277
+ return Y(
1278
+ async (s) => s === "up" ? r.apis.vote({ action: "upvote", messagePublicId: e, sessionId: t }).then(n) : r.apis.vote({ action: "downvote", messagePublicId: e, sessionId: t }).then(n),
1279
+ [r.apis, e, n]
1280
+ );
1281
+ }
1282
+ function ls(e, t) {
1283
+ const { http: n } = B();
1284
+ return Y(
1285
+ async () => n.apis.upvote(e).then(t),
1286
+ [n.options, e, t]
1287
+ );
1288
+ }
1289
+ function ds(e, t) {
1290
+ const { http: n } = B();
1291
+ return Y(
1292
+ async () => n.apis.downvote(e).then(t),
1293
+ [n.options, e]
1294
+ );
1295
+ }
1296
+ const oe = /* @__PURE__ */ new Map();
1297
+ function fs() {
1298
+ const [e, t] = Qe([]), { http: n } = B();
1261
1299
  function r(c) {
1262
1300
  const i = c.map((g) => ({
1263
1301
  file: g,
1264
- id: te(10),
1302
+ id: ee(10),
1265
1303
  status: "pending",
1266
1304
  progress: 0
1267
1305
  }));
@@ -1277,7 +1315,7 @@ function us() {
1277
1315
  }
1278
1316
  const a = async (c) => {
1279
1317
  const i = new AbortController();
1280
- se.set(c.id, i);
1318
+ oe.set(c.id, i);
1281
1319
  try {
1282
1320
  t(
1283
1321
  (f) => f.map(
@@ -1306,17 +1344,17 @@ function us() {
1306
1344
  progress: 0
1307
1345
  });
1308
1346
  } finally {
1309
- se.delete(c.id);
1347
+ oe.delete(c.id);
1310
1348
  }
1311
1349
  }, l = (c) => {
1312
- const i = se.get(c);
1313
- i && (i.abort(), se.delete(c)), o(c);
1314
- }, p = re(() => e.filter((c) => c.status === "success" && c.fileUrl), [e]);
1350
+ const i = oe.get(c);
1351
+ i && (i.abort(), oe.delete(c)), o(c);
1352
+ }, p = ne(() => e.filter((c) => c.status === "success" && c.fileUrl), [e]);
1315
1353
  function u() {
1316
- se.forEach((c) => c.abort()), se.clear(), t([]);
1354
+ oe.forEach((c) => c.abort()), oe.clear(), t([]);
1317
1355
  }
1318
1356
  return le(() => () => {
1319
- se.forEach((c) => c.abort()), se.clear();
1357
+ oe.forEach((c) => c.abort()), oe.clear();
1320
1358
  }, []), {
1321
1359
  allFiles: e,
1322
1360
  appendFiles: r,
@@ -1336,7 +1374,7 @@ function us() {
1336
1374
  isUploading: e.some((c) => c.status === "uploading")
1337
1375
  };
1338
1376
  }
1339
- function it(e) {
1377
+ function at(e) {
1340
1378
  var n, r, s;
1341
1379
  const t = [];
1342
1380
  for (let o = 0; o < e.length; o++) {
@@ -1345,7 +1383,7 @@ function it(e) {
1345
1383
  a.message && a.message.length > 0 && t.push({
1346
1384
  type: "FROM_USER",
1347
1385
  content: a.message,
1348
- id: a.publicId || te(),
1386
+ id: a.publicId || ee(),
1349
1387
  deliveredAt: a.created_at || "",
1350
1388
  attachments: a.attachments
1351
1389
  });
@@ -1358,7 +1396,7 @@ function it(e) {
1358
1396
  data: {
1359
1397
  message: a.message ?? ""
1360
1398
  },
1361
- id: a.publicId || te(),
1399
+ id: a.publicId || ee(),
1362
1400
  timestamp: a.created_at || "",
1363
1401
  original: a,
1364
1402
  attachments: a.attachments,
@@ -1377,7 +1415,7 @@ function it(e) {
1377
1415
  data: {
1378
1416
  message: a.message ?? ""
1379
1417
  },
1380
- id: a.publicId || te(),
1418
+ id: a.publicId || ee(),
1381
1419
  timestamp: a.created_at || "",
1382
1420
  original: a,
1383
1421
  attachments: a.attachments,
@@ -1397,7 +1435,7 @@ function it(e) {
1397
1435
  event: a.type,
1398
1436
  message: a.message ?? ""
1399
1437
  },
1400
- id: a.publicId || te(),
1438
+ id: a.publicId || ee(),
1401
1439
  original: a,
1402
1440
  attachments: a.attachments,
1403
1441
  timestamp: a.created_at || "",
@@ -1413,7 +1451,7 @@ function it(e) {
1413
1451
  return t;
1414
1452
  }
1415
1453
  function cr(e) {
1416
- const t = oe(null);
1454
+ const t = ae(null);
1417
1455
  return le(() => {
1418
1456
  if (!t.current) {
1419
1457
  const n = new Audio(e.src);
@@ -1435,7 +1473,7 @@ function cr(e) {
1435
1473
  };
1436
1474
  }
1437
1475
  function ur() {
1438
- const { soundEffectFiles: e, widgetSettings: t, defaultSettings: n } = ce(), r = (t == null ? void 0 : t.useSoundEffects) ?? n.useSoundEffects;
1476
+ const { soundEffectFiles: e, widgetSettings: t, defaultSettings: n } = B(), r = (t == null ? void 0 : t.useSoundEffects) ?? n.useSoundEffects;
1439
1477
  return {
1440
1478
  messageArrivedSound: cr({
1441
1479
  src: e.messageArrived,
@@ -1499,23 +1537,23 @@ function pr({
1499
1537
  persist: e,
1500
1538
  sessionKey: t = (n, { external_id: r }) => `[OPEN_SESSION_${n}]_${r || "session"}`
1501
1539
  }) {
1502
- const { botToken: n, http: r, user: s } = ce(), [o, a, l] = Ke(
1540
+ const { botToken: n, http: r, user: s } = B(), [o, a, l] = We(
1503
1541
  t(n, s),
1504
1542
  void 0,
1505
1543
  e ? "local" : "memory"
1506
1544
  ), p = (d) => ({
1507
1545
  ...d,
1508
- isSessionClosed: d.status !== gt.OPEN,
1546
+ isSessionClosed: d.status !== pt.OPEN,
1509
1547
  isAssignedToAi: d.assignee_id === 555,
1510
1548
  isAssignedToHuman: d.assignee_id !== 555,
1511
1549
  isPendingHuman: d.assignee_id === 555 && d.ai_closure_type === on.handed_off
1512
- }), u = re(() => o ? p(o) : null, [o]), [c, i] = $(
1550
+ }), u = ne(() => o ? p(o) : null, [o]), [c, i] = Y(
1513
1551
  async (d) => {
1514
1552
  let S = await r.apis.fetchSession(d);
1515
1553
  return S.data && a(S.data), S.data;
1516
1554
  },
1517
1555
  [r, a]
1518
- ), [g, f] = $(
1556
+ ), [g, f] = Y(
1519
1557
  async (d) => {
1520
1558
  try {
1521
1559
  const S = await i(d);
@@ -1544,71 +1582,71 @@ function gr({ onSessionDestroy: e }) {
1544
1582
  lastUpdated: null,
1545
1583
  messages: [],
1546
1584
  keyboard: null
1547
- }), [r, s] = We({ state: "idle" }), o = t.messages.length === 0, { botToken: a, http: l, widgetSettings: p, defaultSettings: u, language: c, ...i } = ce(), { messageArrivedSound: g } = ur(), f = (p == null ? void 0 : p.persistSession) || u.persistSession, { refreshSession: m, session: d, deleteSession: S, setSession: h, pollSession: z } = pr({
1585
+ }), [r, s] = Qe({ state: "idle" }), o = t.messages.length === 0, { botToken: a, http: l, widgetSettings: p, defaultSettings: u, language: c, ...i } = B(), { messageArrivedSound: g } = ur(), f = (p == null ? void 0 : p.persistSession) || u.persistSession, { refreshSession: m, session: d, deleteSession: S, setSession: h, pollSession: q } = pr({
1548
1586
  persist: f
1549
- }), [R, y] = $(
1550
- async (w) => {
1587
+ }), [C, y] = Y(
1588
+ async (A) => {
1551
1589
  if (!d) return [];
1552
1590
  try {
1553
- const { data: C } = await l.apis.fetchHistory(w);
1554
- return C ? Array.isArray(C) ? it(C) : [] : [];
1555
- } catch (C) {
1556
- throw console.error("Error fetching history:", C), C;
1591
+ const { data: N } = await l.apis.fetchHistory(A);
1592
+ return N ? Array.isArray(N) ? at(N) : [] : [];
1593
+ } catch (N) {
1594
+ throw console.error("Error fetching history:", N), N;
1557
1595
  }
1558
1596
  },
1559
1597
  [d, l.apis]
1560
- ), [b, v] = $(
1561
- async (w, C) => {
1598
+ ), [b, v] = Y(
1599
+ async (A, N) => {
1562
1600
  try {
1563
- const P = await l.apis.getHistoryPooling({
1564
- sessionId: w,
1565
- lastMessageTimestamp: C
1601
+ const L = await l.apis.getHistoryPooling({
1602
+ sessionId: A,
1603
+ lastMessageTimestamp: N
1566
1604
  });
1567
- if (P.data) {
1568
- const U = it(P.data);
1569
- if (U.length > 0) {
1605
+ if (L.data) {
1606
+ const k = at(L.data);
1607
+ if (k.length > 0) {
1570
1608
  n({
1571
1609
  type: "APPEND_MESSAGES",
1572
- payload: U
1610
+ payload: k
1573
1611
  });
1574
1612
  try {
1575
1613
  g.play();
1576
- } catch (q) {
1577
- console.error("Error playing sound:", q);
1614
+ } catch (ue) {
1615
+ console.error("Error playing sound:", ue);
1578
1616
  }
1579
1617
  }
1580
- return U;
1618
+ return k;
1581
1619
  }
1582
1620
  return [];
1583
- } catch (P) {
1584
- throw console.error("Error polling messages:", P), P;
1621
+ } catch (L) {
1622
+ throw console.error("Error polling messages:", L), L;
1585
1623
  }
1586
1624
  },
1587
1625
  [l.apis, n, g]
1588
1626
  );
1589
1627
  le(() => {
1590
- let w, C;
1591
- return d && (w = setInterval(() => {
1592
- z(d.id);
1593
- }, lr), C = setInterval(() => {
1594
- var U;
1595
- const P = (U = t.messages.at(-1)) == null ? void 0 : U.timestamp;
1596
- P && v(d.id, P);
1628
+ let A, N;
1629
+ return d && (A = setInterval(() => {
1630
+ q(d.id);
1631
+ }, lr), N = setInterval(() => {
1632
+ var k;
1633
+ const L = (k = t.messages.at(-1)) == null ? void 0 : k.timestamp;
1634
+ L && v(d.id, L);
1597
1635
  }, dr)), () => {
1598
- clearInterval(w), clearInterval(C);
1636
+ clearInterval(A), clearInterval(N);
1599
1637
  };
1600
- }, [d, z, v]);
1601
- const [M, O] = $(
1638
+ }, [d, q, v]);
1639
+ const [F, O] = Y(
1602
1640
  async () => {
1603
1641
  if (d)
1604
1642
  try {
1605
- const w = await m(d.id);
1606
- if (w) {
1607
- const C = await y(w.id);
1608
- C && n({ type: "PREPEND_HISTORY", payload: C });
1643
+ const A = await m(d.id);
1644
+ if (A) {
1645
+ const N = await y(A.id);
1646
+ N && n({ type: "PREPEND_HISTORY", payload: N });
1609
1647
  }
1610
- } catch (w) {
1611
- throw console.error("Error initializing session:", w), w;
1648
+ } catch (A) {
1649
+ throw console.error("Error initializing session:", A), A;
1612
1650
  }
1613
1651
  },
1614
1652
  [d, m, y, n]
@@ -1616,187 +1654,192 @@ function gr({ onSessionDestroy: e }) {
1616
1654
  le(() => {
1617
1655
  O();
1618
1656
  }, []);
1619
- const [N, x] = $(
1657
+ const [_, x] = Y(
1620
1658
  async () => {
1621
1659
  try {
1622
1660
  S(), n({ type: "RESET" }), e == null || e(), s({ state: "idle" });
1623
- } catch (w) {
1624
- throw console.error("Error clearing session:", w), w;
1661
+ } catch (A) {
1662
+ throw console.error("Error clearing session:", A), A;
1625
1663
  }
1626
1664
  },
1627
1665
  [S, n, e, s]
1628
- ), [Y, W] = $(
1666
+ ), [X, K] = Y(
1629
1667
  async () => {
1630
1668
  try {
1631
1669
  await x();
1632
- const { data: w } = await l.apis.createSession(a);
1633
- return h(w), w;
1634
- } catch (w) {
1635
- throw console.error("Error recreating session:", w), w;
1670
+ const { data: A } = await l.apis.createSession(a);
1671
+ return h(A), A;
1672
+ } catch (A) {
1673
+ throw console.error("Error recreating session:", A), A;
1636
1674
  }
1637
1675
  },
1638
1676
  [x, l.apis, a, h]
1639
- ), [F, B] = $(
1640
- async ({ content: w, user: C, attachments: P, ...U }) => {
1641
- var ue;
1642
- d != null && d.isAssignedToAi && s({ state: "loading" });
1643
- let q = d, K = !1;
1644
- if (!d && o)
1677
+ ), j = async ({ content: A, user: N, attachments: L, ...k }) => {
1678
+ var ue;
1679
+ try {
1680
+ let U = d, H = !1;
1681
+ if ((!d || d != null && d.isAssignedToAi) && s({ state: "loading" }), !d && o)
1645
1682
  try {
1646
- const { data: D } = await l.apis.createSession(a);
1647
- if (D)
1648
- h(D), q = {
1649
- ...D,
1650
- isSessionClosed: D.status !== gt.OPEN,
1651
- isAssignedToAi: D.assignee_id === 555,
1683
+ const { data: w } = await l.apis.createSession(a);
1684
+ if (w)
1685
+ h(w), U = {
1686
+ ...w,
1687
+ isSessionClosed: w.status !== pt.OPEN,
1688
+ isAssignedToAi: w.assignee_id === 555,
1652
1689
  isAssignedToHuman: !1,
1653
1690
  isPendingHuman: !1
1654
- }, K = !0;
1691
+ }, H = !0;
1655
1692
  else
1656
- throw new Error("Failed to create session");
1657
- } catch (D) {
1658
- throw console.error("Error creating session:", D), D;
1659
- }
1660
- if (!q)
1661
- throw new Error("No active session");
1662
- const H = te(), { headers: fe, queryParams: Ee } = i;
1663
- try {
1664
- if (n({
1665
- type: "APPEND_USER_MESSAGE",
1666
- payload: {
1667
- type: "FROM_USER",
1668
- id: H,
1669
- content: w.text,
1670
- user: {
1671
- ...i.user,
1672
- ...C
1673
- },
1674
- deliveredAt: null,
1675
- attachments: P
1676
- }
1677
- }), t.keyboard && n({
1678
- type: "SET_KEYBOARD",
1679
- payload: null
1680
- }), !K && q.isAssignedToAi) {
1681
- const G = await z(q.id);
1682
- G && (q = G);
1693
+ throw new Error("Failed to create new chat session");
1694
+ } catch (w) {
1695
+ throw s({
1696
+ state: "error",
1697
+ error: w instanceof Error ? w.message : "Failed to create session"
1698
+ }), w;
1683
1699
  }
1684
- const D = await l.apis.sendMessage({
1685
- id: H,
1686
- content: w.text,
1687
- session_id: q.id,
1688
- bot_token: a,
1689
- headers: fe,
1690
- query_params: Ee,
1700
+ if (!U) {
1701
+ const w = new Error("No active session available");
1702
+ throw s({ state: "error", error: w.message }), w;
1703
+ }
1704
+ const z = ee(), { headers: fe, queryParams: we } = i;
1705
+ if (n({
1706
+ type: "APPEND_USER_MESSAGE",
1707
+ payload: {
1708
+ type: "FROM_USER",
1709
+ id: z,
1710
+ content: A.text,
1691
1711
  user: {
1692
1712
  ...i.user,
1693
- ...C
1713
+ ...N
1694
1714
  },
1695
- language: c,
1696
- attachments: P,
1697
- ...U
1698
- });
1699
- if (n({
1700
- type: "SET_DELIVERED_AT",
1715
+ deliveredAt: null,
1716
+ attachments: L
1717
+ }
1718
+ }), t.keyboard && n({
1719
+ type: "SET_KEYBOARD",
1720
+ payload: null
1721
+ }), !H && U.isAssignedToAi)
1722
+ try {
1723
+ const w = await q(U.id);
1724
+ w && (U = w);
1725
+ } catch (w) {
1726
+ console.error("Error polling session:", w);
1727
+ }
1728
+ const se = await l.apis.sendMessage({
1729
+ id: z,
1730
+ content: A.text,
1731
+ session_id: U.id,
1732
+ bot_token: a,
1733
+ headers: fe,
1734
+ query_params: we,
1735
+ user: {
1736
+ ...i.user,
1737
+ ...N
1738
+ },
1739
+ language: c,
1740
+ attachments: L,
1741
+ ...k
1742
+ });
1743
+ if (n({
1744
+ type: "SET_DELIVERED_AT",
1745
+ payload: {
1746
+ clientMessageId: z,
1747
+ deliveredAt: (/* @__PURE__ */ new Date()).toISOString()
1748
+ }
1749
+ }), se.data.success) {
1750
+ const w = se.data;
1751
+ if (w.autopilotResponse && n({
1752
+ type: "ADD_RESPONSE_MESSAGE",
1701
1753
  payload: {
1702
- clientMessageId: H,
1703
- deliveredAt: (/* @__PURE__ */ new Date()).toISOString()
1704
- }
1705
- }), D.data.success) {
1706
- const G = D.data;
1707
- if (G.autopilotResponse && n({
1708
- type: "ADD_RESPONSE_MESSAGE",
1709
- payload: {
1710
- type: "FROM_BOT",
1711
- id: G.autopilotResponse.id || te(),
1712
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1713
- component: "TEXT",
1714
- data: {
1715
- message: G.autopilotResponse.value.content
1716
- }
1754
+ type: "FROM_BOT",
1755
+ id: w.autopilotResponse.id || ee(),
1756
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1757
+ component: "TEXT",
1758
+ data: {
1759
+ message: w.autopilotResponse.value.content
1717
1760
  }
1718
- }), G.uiResponse) {
1719
- const we = G.uiResponse.value;
1720
- n({
1721
- type: "ADD_RESPONSE_MESSAGE",
1722
- payload: {
1723
- type: "FROM_BOT",
1724
- id: te(),
1725
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1726
- component: we.name,
1727
- data: we.request_response
1728
- }
1729
- });
1730
1761
  }
1731
- } else
1762
+ }), w.uiResponse) {
1763
+ const me = w.uiResponse.value;
1732
1764
  n({
1733
1765
  type: "ADD_RESPONSE_MESSAGE",
1734
1766
  payload: {
1735
1767
  type: "FROM_BOT",
1736
- id: te(),
1737
- component: "TEXT",
1738
- data: {
1739
- message: ((ue = D.data.error) == null ? void 0 : ue.message) || "",
1740
- variant: "error"
1741
- }
1768
+ id: ee(),
1769
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1770
+ component: me.name,
1771
+ data: me.request_response
1742
1772
  }
1743
1773
  });
1744
- return { id: H };
1745
- } catch (D) {
1746
- throw console.error("Error sending message:", D), s({ state: "error", error: D }), D;
1747
- } finally {
1748
- d != null && d.isAssignedToAi && s({ state: "idle" });
1774
+ }
1775
+ } else {
1776
+ const w = ((ue = se.data.error) == null ? void 0 : ue.message) || "Unknown error occurred";
1777
+ n({
1778
+ type: "ADD_RESPONSE_MESSAGE",
1779
+ payload: {
1780
+ type: "FROM_BOT",
1781
+ id: ee(),
1782
+ component: "TEXT",
1783
+ data: {
1784
+ message: w,
1785
+ variant: "error"
1786
+ }
1787
+ }
1788
+ }), s({ state: "error", error: w });
1749
1789
  }
1750
- },
1751
- [d, o, l.apis, a, h, i, c, t.keyboard]
1752
- ), De = ge(
1753
- (w) => {
1754
- B({
1790
+ return s({ state: "idle" }), { id: z };
1791
+ } catch (U) {
1792
+ const H = U instanceof Error ? U.message : "An unexpected error occurred";
1793
+ throw console.error("Error in sendMessage:", H, U), (!d || d != null && d.isAssignedToAi) && s({ state: "error", error: H }), U;
1794
+ }
1795
+ }, re = ge(
1796
+ (A) => {
1797
+ j({
1755
1798
  content: {
1756
- text: w
1799
+ text: A
1757
1800
  }
1758
- }).catch((C) => {
1759
- console.error("Error handling keyboard input:", C);
1801
+ }).catch((N) => {
1802
+ console.error("Error handling keyboard input:", N);
1760
1803
  }), n({
1761
1804
  type: "SET_KEYBOARD",
1762
1805
  payload: null
1763
1806
  });
1764
1807
  },
1765
- [n, B]
1808
+ [n, j]
1766
1809
  );
1767
1810
  return {
1768
1811
  version: jn.version,
1769
1812
  state: t,
1770
1813
  session: d,
1771
1814
  noMessages: o,
1772
- initState: M,
1773
- clearSessionState: N,
1774
- recreateSessionState: Y,
1815
+ initState: F,
1816
+ clearSessionState: _,
1817
+ recreateSessionState: X,
1775
1818
  hookState: r,
1776
- recreateSession: W,
1819
+ recreateSession: K,
1777
1820
  clearSession: x,
1778
- sendMessage: B,
1779
- handleKeyboard: De
1821
+ sendMessage: j,
1822
+ handleKeyboard: re
1780
1823
  };
1781
1824
  }
1782
- const [ls, hr] = Ce();
1825
+ const [ps, hr] = Ce();
1783
1826
  function mr({
1784
1827
  children: e
1785
1828
  }) {
1786
- const { settings: t } = ce(), n = gr({
1829
+ const { settings: t } = B(), n = gr({
1787
1830
  defaultHookSettings: {
1788
1831
  persistSession: (t == null ? void 0 : t.persistSession) ?? !0,
1789
1832
  useSoundEffects: (t == null ? void 0 : t.useSoundEffects) ?? !1
1790
1833
  }
1791
1834
  });
1792
- return /* @__PURE__ */ ne(hr, { value: n, children: e });
1835
+ return /* @__PURE__ */ te(hr, { value: n, children: e });
1793
1836
  }
1794
1837
  function yr() {
1795
- const { http: e, botToken: t, user: n, collectUserData: r } = ce(), [s, o] = Ke(
1838
+ const { http: e, botToken: t, user: n, collectUserData: r } = B(), [s, o] = We(
1796
1839
  `${t}:contact:${n.external_id}`,
1797
1840
  null,
1798
1841
  "local"
1799
- ), [a, l] = $(
1842
+ ), [a, l] = Y(
1800
1843
  async (u) => {
1801
1844
  var c;
1802
1845
  try {
@@ -1813,7 +1856,7 @@ function yr() {
1813
1856
  le(() => {
1814
1857
  n && t && l(n);
1815
1858
  }, [n, t]);
1816
- const p = re(() => !(s != null && s.id) && r ? {
1859
+ const p = ne(() => !(s != null && s.id) && r ? {
1817
1860
  should: !0,
1818
1861
  reason: "No contact id and collectUserData is true"
1819
1862
  } : {
@@ -1826,18 +1869,18 @@ function yr() {
1826
1869
  shouldCollectData: p
1827
1870
  };
1828
1871
  }
1829
- const [ds, Sr] = Ce();
1872
+ const [gs, Sr] = Ce();
1830
1873
  function vr({ children: e }) {
1831
1874
  const t = yr();
1832
- return /* @__PURE__ */ ne(Sr, { value: t, children: e });
1875
+ return /* @__PURE__ */ te(Sr, { value: t, children: e });
1833
1876
  }
1834
- function fs({
1877
+ function hs({
1835
1878
  children: e,
1836
1879
  options: t
1837
1880
  }) {
1838
- return /* @__PURE__ */ ne(Zn, { data: t, children: /* @__PURE__ */ ne(vr, { children: /* @__PURE__ */ ne(vt, { children: /* @__PURE__ */ ne(mr, { children: e }) }) }) });
1881
+ return /* @__PURE__ */ te(Zn, { data: t, children: /* @__PURE__ */ te(vr, { children: /* @__PURE__ */ te(St, { children: /* @__PURE__ */ te(mr, { children: e }) }) }) });
1839
1882
  }
1840
- var ze = { exports: {} }, je = {};
1883
+ var Ge = { exports: {} }, Ie = {};
1841
1884
  /**
1842
1885
  * @license React
1843
1886
  * use-sync-external-store-shim.production.min.js
@@ -1847,10 +1890,10 @@ var ze = { exports: {} }, je = {};
1847
1890
  * This source code is licensed under the MIT license found in the
1848
1891
  * LICENSE file in the root directory of this source tree.
1849
1892
  */
1850
- var ct;
1893
+ var it;
1851
1894
  function Er() {
1852
- if (ct) return je;
1853
- ct = 1;
1895
+ if (it) return Ie;
1896
+ it = 1;
1854
1897
  var e = de;
1855
1898
  function t(i, g) {
1856
1899
  return i === g && (i !== 0 || 1 / i === 1 / g) || i !== i && g !== g;
@@ -1880,9 +1923,9 @@ function Er() {
1880
1923
  return g();
1881
1924
  }
1882
1925
  var c = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : l;
1883
- return je.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : c, je;
1926
+ return Ie.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : c, Ie;
1884
1927
  }
1885
- var ke = {};
1928
+ var je = {};
1886
1929
  /**
1887
1930
  * @license React
1888
1931
  * use-sync-external-store-shim.development.js
@@ -1892,63 +1935,63 @@ var ke = {};
1892
1935
  * This source code is licensed under the MIT license found in the
1893
1936
  * LICENSE file in the root directory of this source tree.
1894
1937
  */
1895
- var ut;
1938
+ var ct;
1896
1939
  function wr() {
1897
- return ut || (ut = 1, process.env.NODE_ENV !== "production" && function() {
1940
+ return ct || (ct = 1, process.env.NODE_ENV !== "production" && function() {
1898
1941
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
1899
1942
  var e = de, t = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1900
- function n(R) {
1943
+ function n(C) {
1901
1944
  {
1902
1945
  for (var y = arguments.length, b = new Array(y > 1 ? y - 1 : 0), v = 1; v < y; v++)
1903
1946
  b[v - 1] = arguments[v];
1904
- r("error", R, b);
1947
+ r("error", C, b);
1905
1948
  }
1906
1949
  }
1907
- function r(R, y, b) {
1950
+ function r(C, y, b) {
1908
1951
  {
1909
- var v = t.ReactDebugCurrentFrame, M = v.getStackAddendum();
1910
- M !== "" && (y += "%s", b = b.concat([M]));
1911
- var O = b.map(function(N) {
1912
- return String(N);
1952
+ var v = t.ReactDebugCurrentFrame, F = v.getStackAddendum();
1953
+ F !== "" && (y += "%s", b = b.concat([F]));
1954
+ var O = b.map(function(_) {
1955
+ return String(_);
1913
1956
  });
1914
- O.unshift("Warning: " + y), Function.prototype.apply.call(console[R], console, O);
1957
+ O.unshift("Warning: " + y), Function.prototype.apply.call(console[C], console, O);
1915
1958
  }
1916
1959
  }
1917
- function s(R, y) {
1918
- return R === y && (R !== 0 || 1 / R === 1 / y) || R !== R && y !== y;
1960
+ function s(C, y) {
1961
+ return C === y && (C !== 0 || 1 / C === 1 / y) || C !== C && y !== y;
1919
1962
  }
1920
1963
  var o = typeof Object.is == "function" ? Object.is : s, a = e.useState, l = e.useEffect, p = e.useLayoutEffect, u = e.useDebugValue, c = !1, i = !1;
1921
- function g(R, y, b) {
1964
+ function g(C, y, b) {
1922
1965
  c || e.startTransition !== void 0 && (c = !0, n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
1923
1966
  var v = y();
1924
1967
  if (!i) {
1925
- var M = y();
1926
- o(v, M) || (n("The result of getSnapshot should be cached to avoid an infinite loop"), i = !0);
1968
+ var F = y();
1969
+ o(v, F) || (n("The result of getSnapshot should be cached to avoid an infinite loop"), i = !0);
1927
1970
  }
1928
1971
  var O = a({
1929
1972
  inst: {
1930
1973
  value: v,
1931
1974
  getSnapshot: y
1932
1975
  }
1933
- }), N = O[0].inst, x = O[1];
1976
+ }), _ = O[0].inst, x = O[1];
1934
1977
  return p(function() {
1935
- N.value = v, N.getSnapshot = y, f(N) && x({
1936
- inst: N
1978
+ _.value = v, _.getSnapshot = y, f(_) && x({
1979
+ inst: _
1937
1980
  });
1938
- }, [R, v, y]), l(function() {
1939
- f(N) && x({
1940
- inst: N
1981
+ }, [C, v, y]), l(function() {
1982
+ f(_) && x({
1983
+ inst: _
1941
1984
  });
1942
- var Y = function() {
1943
- f(N) && x({
1944
- inst: N
1985
+ var X = function() {
1986
+ f(_) && x({
1987
+ inst: _
1945
1988
  });
1946
1989
  };
1947
- return R(Y);
1948
- }, [R]), u(v), v;
1990
+ return C(X);
1991
+ }, [C]), u(v), v;
1949
1992
  }
1950
- function f(R) {
1951
- var y = R.getSnapshot, b = R.value;
1993
+ function f(C) {
1994
+ var y = C.getSnapshot, b = C.value;
1952
1995
  try {
1953
1996
  var v = y();
1954
1997
  return !o(b, v);
@@ -1956,116 +1999,116 @@ function wr() {
1956
1999
  return !0;
1957
2000
  }
1958
2001
  }
1959
- function m(R, y, b) {
2002
+ function m(C, y, b) {
1960
2003
  return y();
1961
2004
  }
1962
- var d = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", S = !d, h = S ? m : g, z = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : h;
1963
- ke.useSyncExternalStore = z, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
1964
- }()), ke;
2005
+ var d = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", S = !d, h = S ? m : g, q = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : h;
2006
+ je.useSyncExternalStore = q, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
2007
+ }()), je;
1965
2008
  }
1966
- process.env.NODE_ENV === "production" ? ze.exports = Er() : ze.exports = wr();
1967
- var br = ze.exports;
1968
- const ae = () => {
1969
- }, L = (
2009
+ process.env.NODE_ENV === "production" ? Ge.exports = Er() : Ge.exports = wr();
2010
+ var br = Ge.exports;
2011
+ const ie = () => {
2012
+ }, V = (
1970
2013
  /*#__NOINLINE__*/
1971
- ae()
1972
- ), Me = Object, E = (e) => e === L, Q = (e) => typeof e == "function", ie = (e, t) => ({
2014
+ ie()
2015
+ ), ke = Object, E = (e) => e === V, W = (e) => typeof e == "function", ce = (e, t) => ({
1973
2016
  ...e,
1974
2017
  ...t
1975
- }), Or = (e) => Q(e.then), Oe = /* @__PURE__ */ new WeakMap();
2018
+ }), Or = (e) => W(e.then), Oe = /* @__PURE__ */ new WeakMap();
1976
2019
  let Ar = 0;
1977
- const Se = (e) => {
2020
+ const ve = (e) => {
1978
2021
  const t = typeof e, n = e && e.constructor, r = n == Date;
1979
2022
  let s, o;
1980
- if (Me(e) === e && !r && n != RegExp) {
2023
+ if (ke(e) === e && !r && n != RegExp) {
1981
2024
  if (s = Oe.get(e), s) return s;
1982
2025
  if (s = ++Ar + "~", Oe.set(e, s), n == Array) {
1983
2026
  for (s = "@", o = 0; o < e.length; o++)
1984
- s += Se(e[o]) + ",";
2027
+ s += ve(e[o]) + ",";
1985
2028
  Oe.set(e, s);
1986
2029
  }
1987
- if (n == Me) {
2030
+ if (n == ke) {
1988
2031
  s = "#";
1989
- const a = Me.keys(e).sort();
2032
+ const a = ke.keys(e).sort();
1990
2033
  for (; !E(o = a.pop()); )
1991
- E(e[o]) || (s += o + ":" + Se(e[o]) + ",");
2034
+ E(e[o]) || (s += o + ":" + ve(e[o]) + ",");
1992
2035
  Oe.set(e, s);
1993
2036
  }
1994
2037
  } else
1995
2038
  s = r ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e;
1996
2039
  return s;
1997
- }, ee = /* @__PURE__ */ new WeakMap(), Le = {}, Ae = {}, Ze = "undefined", Ne = typeof window != Ze, Ye = typeof document != Ze, Tr = () => Ne && typeof window.requestAnimationFrame != Ze, Qt = (e, t) => {
1998
- const n = ee.get(e);
2040
+ }, $ = /* @__PURE__ */ new WeakMap(), Me = {}, Ae = {}, Je = "undefined", De = typeof window != Je, ze = typeof document != Je, Tr = () => De && typeof window.requestAnimationFrame != Je, Xt = (e, t) => {
2041
+ const n = $.get(e);
1999
2042
  return [
2000
2043
  // Getter
2001
- () => !E(t) && e.get(t) || Le,
2044
+ () => !E(t) && e.get(t) || Me,
2002
2045
  // Setter
2003
2046
  (r) => {
2004
2047
  if (!E(t)) {
2005
2048
  const s = e.get(t);
2006
- t in Ae || (Ae[t] = s), n[5](t, ie(s, r), s || Le);
2049
+ t in Ae || (Ae[t] = s), n[5](t, ce(s, r), s || Me);
2007
2050
  }
2008
2051
  },
2009
2052
  // Subscriber
2010
2053
  n[6],
2011
2054
  // Get server cache snapshot
2012
- () => !E(t) && t in Ae ? Ae[t] : !E(t) && e.get(t) || Le
2055
+ () => !E(t) && t in Ae ? Ae[t] : !E(t) && e.get(t) || Me
2013
2056
  ];
2014
2057
  };
2015
- let Be = !0;
2016
- const Rr = () => Be, [qe, Xe] = Ne && window.addEventListener ? [
2058
+ let Ye = !0;
2059
+ const Rr = () => Ye, [Be, qe] = De && window.addEventListener ? [
2017
2060
  window.addEventListener.bind(window),
2018
2061
  window.removeEventListener.bind(window)
2019
2062
  ] : [
2020
- ae,
2021
- ae
2063
+ ie,
2064
+ ie
2022
2065
  ], Cr = () => {
2023
- const e = Ye && document.visibilityState;
2066
+ const e = ze && document.visibilityState;
2024
2067
  return E(e) || e !== "hidden";
2025
- }, _r = (e) => (Ye && document.addEventListener("visibilitychange", e), qe("focus", e), () => {
2026
- Ye && document.removeEventListener("visibilitychange", e), Xe("focus", e);
2027
- }), Nr = (e) => {
2068
+ }, Nr = (e) => (ze && document.addEventListener("visibilitychange", e), Be("focus", e), () => {
2069
+ ze && document.removeEventListener("visibilitychange", e), qe("focus", e);
2070
+ }), Dr = (e) => {
2028
2071
  const t = () => {
2029
- Be = !0, e();
2072
+ Ye = !0, e();
2030
2073
  }, n = () => {
2031
- Be = !1;
2074
+ Ye = !1;
2032
2075
  };
2033
- return qe("online", t), qe("offline", n), () => {
2034
- Xe("online", t), Xe("offline", n);
2076
+ return Be("online", t), Be("offline", n), () => {
2077
+ qe("online", t), qe("offline", n);
2035
2078
  };
2036
- }, Dr = {
2079
+ }, _r = {
2037
2080
  isOnline: Rr,
2038
2081
  isVisible: Cr
2039
2082
  }, xr = {
2040
- initFocus: _r,
2041
- initReconnect: Nr
2042
- }, lt = !de.useId, ve = !Ne || "Deno" in window, Pr = (e) => Tr() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Fe = ve ? le : cn, Ve = typeof navigator < "u" && navigator.connection, dt = !ve && Ve && ([
2083
+ initFocus: Nr,
2084
+ initReconnect: Dr
2085
+ }, ut = !de.useId, Ee = !De || "Deno" in window, Pr = (e) => Tr() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Fe = Ee ? le : cn, Le = typeof navigator < "u" && navigator.connection, lt = !Ee && Le && ([
2043
2086
  "slow-2g",
2044
2087
  "2g"
2045
- ].includes(Ve.effectiveType) || Ve.saveData), $e = (e) => {
2046
- if (Q(e))
2088
+ ].includes(Le.effectiveType) || Le.saveData), Ze = (e) => {
2089
+ if (W(e))
2047
2090
  try {
2048
2091
  e = e();
2049
2092
  } catch {
2050
2093
  e = "";
2051
2094
  }
2052
2095
  const t = e;
2053
- return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? Se(e) : "", [
2096
+ return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? ve(e) : "", [
2054
2097
  e,
2055
2098
  t
2056
2099
  ];
2057
2100
  };
2058
2101
  let Ir = 0;
2059
- const Qe = () => ++Ir, Wt = 0, Kt = 1, Jt = 2, jr = 3;
2060
- var ye = {
2102
+ const Xe = () => ++Ir, Qt = 0, Wt = 1, Kt = 2, jr = 3;
2103
+ var Se = {
2061
2104
  __proto__: null,
2062
2105
  ERROR_REVALIDATE_EVENT: jr,
2063
- FOCUS_EVENT: Wt,
2064
- MUTATE_EVENT: Jt,
2065
- RECONNECT_EVENT: Kt
2106
+ FOCUS_EVENT: Qt,
2107
+ MUTATE_EVENT: Kt,
2108
+ RECONNECT_EVENT: Wt
2066
2109
  };
2067
- async function Zt(...e) {
2068
- const [t, n, r, s] = e, o = ie({
2110
+ async function Jt(...e) {
2111
+ const [t, n, r, s] = e, o = ce({
2069
2112
  populateCache: !0,
2070
2113
  throwOnError: !0
2071
2114
  }, typeof s == "boolean" ? {
@@ -2075,7 +2118,7 @@ async function Zt(...e) {
2075
2118
  const l = o.rollbackOnError;
2076
2119
  let p = o.optimisticData;
2077
2120
  const u = (g) => typeof l == "function" ? l(g) : l !== !1, c = o.throwOnError;
2078
- if (Q(n)) {
2121
+ if (W(n)) {
2079
2122
  const g = n, f = [], m = t.keys();
2080
2123
  for (const d of m)
2081
2124
  // Skip the special useSWRInfinite and useSWRSubscription keys.
@@ -2084,57 +2127,57 @@ async function Zt(...e) {
2084
2127
  }
2085
2128
  return i(n);
2086
2129
  async function i(g) {
2087
- const [f] = $e(g);
2130
+ const [f] = Ze(g);
2088
2131
  if (!f) return;
2089
- const [m, d] = Qt(t, f), [S, h, z, R] = ee.get(t), y = () => {
2090
- const F = S[f];
2091
- return (Q(o.revalidate) ? o.revalidate(m().data, g) : o.revalidate !== !1) && (delete z[f], delete R[f], F && F[0]) ? F[0](Jt).then(() => m().data) : m().data;
2132
+ const [m, d] = Xt(t, f), [S, h, q, C] = $.get(t), y = () => {
2133
+ const j = S[f];
2134
+ return (W(o.revalidate) ? o.revalidate(m().data, g) : o.revalidate !== !1) && (delete q[f], delete C[f], j && j[0]) ? j[0](Kt).then(() => m().data) : m().data;
2092
2135
  };
2093
2136
  if (e.length < 3)
2094
2137
  return y();
2095
2138
  let b = r, v;
2096
- const M = Qe();
2139
+ const F = Xe();
2097
2140
  h[f] = [
2098
- M,
2141
+ F,
2099
2142
  0
2100
2143
  ];
2101
- const O = !E(p), N = m(), x = N.data, Y = N._c, W = E(Y) ? x : Y;
2102
- if (O && (p = Q(p) ? p(W, x) : p, d({
2144
+ const O = !E(p), _ = m(), x = _.data, X = _._c, K = E(X) ? x : X;
2145
+ if (O && (p = W(p) ? p(K, x) : p, d({
2103
2146
  data: p,
2104
- _c: W
2105
- })), Q(b))
2147
+ _c: K
2148
+ })), W(b))
2106
2149
  try {
2107
- b = b(W);
2108
- } catch (F) {
2109
- v = F;
2150
+ b = b(K);
2151
+ } catch (j) {
2152
+ v = j;
2110
2153
  }
2111
2154
  if (b && Or(b))
2112
- if (b = await b.catch((F) => {
2113
- v = F;
2114
- }), M !== h[f][0]) {
2155
+ if (b = await b.catch((j) => {
2156
+ v = j;
2157
+ }), F !== h[f][0]) {
2115
2158
  if (v) throw v;
2116
2159
  return b;
2117
2160
  } else v && O && u(v) && (a = !0, d({
2118
- data: W,
2119
- _c: L
2161
+ data: K,
2162
+ _c: V
2120
2163
  }));
2121
2164
  if (a && !v)
2122
- if (Q(a)) {
2123
- const F = a(b, W);
2165
+ if (W(a)) {
2166
+ const j = a(b, K);
2124
2167
  d({
2125
- data: F,
2126
- error: L,
2127
- _c: L
2168
+ data: j,
2169
+ error: V,
2170
+ _c: V
2128
2171
  });
2129
2172
  } else
2130
2173
  d({
2131
2174
  data: b,
2132
- error: L,
2133
- _c: L
2175
+ error: V,
2176
+ _c: V
2134
2177
  });
2135
- if (h[f][1] = Qe(), Promise.resolve(y()).then(() => {
2178
+ if (h[f][1] = Xe(), Promise.resolve(y()).then(() => {
2136
2179
  d({
2137
- _c: L
2180
+ _c: V
2138
2181
  });
2139
2182
  }), v) {
2140
2183
  if (c) throw v;
@@ -2143,13 +2186,13 @@ async function Zt(...e) {
2143
2186
  return b;
2144
2187
  }
2145
2188
  }
2146
- const ft = (e, t) => {
2189
+ const dt = (e, t) => {
2147
2190
  for (const n in e)
2148
2191
  e[n][0] && e[n][0](t);
2149
2192
  }, kr = (e, t) => {
2150
- if (!ee.has(e)) {
2151
- const n = ie(xr, t), r = {}, s = Zt.bind(L, e);
2152
- let o = ae;
2193
+ if (!$.has(e)) {
2194
+ const n = ce(xr, t), r = {}, s = Jt.bind(V, e);
2195
+ let o = ie;
2153
2196
  const a = {}, l = (c, i) => {
2154
2197
  const g = a[c] || [];
2155
2198
  return a[c] = g, g.push(i), () => g.splice(g.indexOf(i), 1);
@@ -2160,7 +2203,7 @@ const ft = (e, t) => {
2160
2203
  for (const m of f)
2161
2204
  m(i, g);
2162
2205
  }, u = () => {
2163
- if (!ee.has(e) && (ee.set(e, [
2206
+ if (!$.has(e) && ($.set(e, [
2164
2207
  r,
2165
2208
  {},
2166
2209
  {},
@@ -2168,10 +2211,10 @@ const ft = (e, t) => {
2168
2211
  s,
2169
2212
  p,
2170
2213
  l
2171
- ]), !ve)) {
2172
- const c = n.initFocus(setTimeout.bind(L, ft.bind(L, r, Wt))), i = n.initReconnect(setTimeout.bind(L, ft.bind(L, r, Kt)));
2214
+ ]), !Ee)) {
2215
+ const c = n.initFocus(setTimeout.bind(V, dt.bind(V, r, Qt))), i = n.initReconnect(setTimeout.bind(V, dt.bind(V, r, Wt)));
2173
2216
  o = () => {
2174
- c && c(), i && i(), ee.delete(e);
2217
+ c && c(), i && i(), $.delete(e);
2175
2218
  };
2176
2219
  }
2177
2220
  };
@@ -2184,48 +2227,48 @@ const ft = (e, t) => {
2184
2227
  }
2185
2228
  return [
2186
2229
  e,
2187
- ee.get(e)[4]
2230
+ $.get(e)[4]
2188
2231
  ];
2189
2232
  }, Mr = (e, t, n, r, s) => {
2190
2233
  const o = n.errorRetryCount, a = s.retryCount, l = ~~((Math.random() + 0.5) * (1 << (a < 8 ? a : 8))) * n.errorRetryInterval;
2191
2234
  !E(o) && a > o || setTimeout(r, l, s);
2192
- }, Lr = (e, t) => Se(e) == Se(t), [$t, Fr] = kr(/* @__PURE__ */ new Map()), Vr = ie(
2235
+ }, Fr = (e, t) => ve(e) == ve(t), [Zt, Lr] = kr(/* @__PURE__ */ new Map()), Vr = ce(
2193
2236
  {
2194
2237
  // events
2195
- onLoadingSlow: ae,
2196
- onSuccess: ae,
2197
- onError: ae,
2238
+ onLoadingSlow: ie,
2239
+ onSuccess: ie,
2240
+ onError: ie,
2198
2241
  onErrorRetry: Mr,
2199
- onDiscarded: ae,
2242
+ onDiscarded: ie,
2200
2243
  // switches
2201
2244
  revalidateOnFocus: !0,
2202
2245
  revalidateOnReconnect: !0,
2203
2246
  revalidateIfStale: !0,
2204
2247
  shouldRetryOnError: !0,
2205
2248
  // timeouts
2206
- errorRetryInterval: dt ? 1e4 : 5e3,
2249
+ errorRetryInterval: lt ? 1e4 : 5e3,
2207
2250
  focusThrottleInterval: 5 * 1e3,
2208
2251
  dedupingInterval: 2 * 1e3,
2209
- loadingTimeout: dt ? 5e3 : 3e3,
2252
+ loadingTimeout: lt ? 5e3 : 3e3,
2210
2253
  // providers
2211
- compare: Lr,
2254
+ compare: Fr,
2212
2255
  isPaused: () => !1,
2213
- cache: $t,
2214
- mutate: Fr,
2256
+ cache: Zt,
2257
+ mutate: Lr,
2215
2258
  fallback: {}
2216
2259
  },
2217
2260
  // use web preset by default
2218
- Dr
2261
+ _r
2219
2262
  ), Ur = (e, t) => {
2220
- const n = ie(e, t);
2263
+ const n = ce(e, t);
2221
2264
  if (t) {
2222
2265
  const { use: r, fallback: s } = e, { use: o, fallback: a } = t;
2223
- r && o && (n.use = r.concat(o)), s && a && (n.fallback = ie(s, a));
2266
+ r && o && (n.use = r.concat(o)), s && a && (n.fallback = ce(s, a));
2224
2267
  }
2225
2268
  return n;
2226
- }, Hr = ht({}), Gr = "$inf$", en = Ne && window.__SWR_DEVTOOLS_USE__, zr = en ? window.__SWR_DEVTOOLS_USE__ : [], Yr = () => {
2227
- en && (window.__SWR_DEVTOOLS_REACT__ = de);
2228
- }, Br = (e) => Q(e[1]) ? [
2269
+ }, Hr = gt({}), Gr = "$inf$", $t = De && window.__SWR_DEVTOOLS_USE__, zr = $t ? window.__SWR_DEVTOOLS_USE__ : [], Yr = () => {
2270
+ $t && (window.__SWR_DEVTOOLS_REACT__ = de);
2271
+ }, Br = (e) => W(e[1]) ? [
2229
2272
  e[0],
2230
2273
  e[1],
2231
2274
  e[2] || {}
@@ -2233,8 +2276,8 @@ const ft = (e, t) => {
2233
2276
  e[0],
2234
2277
  null,
2235
2278
  (e[1] === null ? e[2] : e[1]) || {}
2236
- ], qr = () => ie(Vr, mt(Hr)), Xr = (e) => (t, n, r) => e(t, n && ((...o) => {
2237
- const [a] = $e(t), [, , , l] = ee.get($t);
2279
+ ], qr = () => ce(Vr, ht(Hr)), Xr = (e) => (t, n, r) => e(t, n && ((...o) => {
2280
+ const [a] = Ze(t), [, , , l] = $.get(Zt);
2238
2281
  if (a.startsWith(Gr))
2239
2282
  return n(...o);
2240
2283
  const p = l[a];
@@ -2254,7 +2297,7 @@ const ft = (e, t) => {
2254
2297
  };
2255
2298
  };
2256
2299
  Yr();
2257
- const pt = de.use || ((e) => {
2300
+ const ft = de.use || ((e) => {
2258
2301
  if (e.status === "pending")
2259
2302
  throw e;
2260
2303
  if (e.status === "fulfilled")
@@ -2264,95 +2307,95 @@ const pt = de.use || ((e) => {
2264
2307
  }, (t) => {
2265
2308
  e.status = "rejected", e.reason = t;
2266
2309
  }), e);
2267
- }), Ue = {
2310
+ }), Ve = {
2268
2311
  dedupe: !0
2269
2312
  }, Jr = (e, t, n) => {
2270
- const { cache: r, compare: s, suspense: o, fallbackData: a, revalidateOnMount: l, revalidateIfStale: p, refreshInterval: u, refreshWhenHidden: c, refreshWhenOffline: i, keepPreviousData: g } = n, [f, m, d, S] = ee.get(r), [h, z] = $e(e), R = oe(!1), y = oe(!1), b = oe(h), v = oe(t), M = oe(n), O = () => M.current, N = () => O().isVisible() && O().isOnline(), [x, Y, W, F] = Qt(r, h), B = oe({}).current, De = E(a) ? n.fallback[h] : a, w = (A, T) => {
2271
- for (const j in B) {
2272
- const _ = j;
2273
- if (_ === "data") {
2274
- if (!s(A[_], T[_]) && (!E(A[_]) || !s(ue, T[_])))
2313
+ const { cache: r, compare: s, suspense: o, fallbackData: a, revalidateOnMount: l, revalidateIfStale: p, refreshInterval: u, refreshWhenHidden: c, refreshWhenOffline: i, keepPreviousData: g } = n, [f, m, d, S] = $.get(r), [h, q] = Ze(e), C = ae(!1), y = ae(!1), b = ae(h), v = ae(t), F = ae(n), O = () => F.current, _ = () => O().isVisible() && O().isOnline(), [x, X, K, j] = Xt(r, h), re = ae({}).current, A = E(a) ? n.fallback[h] : a, N = (T, R) => {
2314
+ for (const I in re) {
2315
+ const D = I;
2316
+ if (D === "data") {
2317
+ if (!s(T[D], R[D]) && (!E(T[D]) || !s(se, R[D])))
2275
2318
  return !1;
2276
- } else if (T[_] !== A[_])
2319
+ } else if (R[D] !== T[D])
2277
2320
  return !1;
2278
2321
  }
2279
2322
  return !0;
2280
- }, C = re(() => {
2281
- const A = !h || !t ? !1 : E(l) ? O().isPaused() || o ? !1 : E(p) ? !0 : p : l, T = (k) => {
2282
- const J = ie(k);
2283
- return delete J._k, A ? {
2323
+ }, L = ne(() => {
2324
+ const T = !h || !t ? !1 : E(l) ? O().isPaused() || o ? !1 : E(p) ? !0 : p : l, R = (M) => {
2325
+ const J = ce(M);
2326
+ return delete J._k, T ? {
2284
2327
  isValidating: !0,
2285
2328
  isLoading: !0,
2286
2329
  ...J
2287
2330
  } : J;
2288
- }, j = x(), _ = F(), X = T(j), pe = j === _ ? X : T(_);
2289
- let I = X;
2331
+ }, I = x(), D = j(), Q = R(I), pe = I === D ? Q : R(D);
2332
+ let P = Q;
2290
2333
  return [
2291
2334
  () => {
2292
- const k = T(x());
2293
- return w(k, I) ? (I.data = k.data, I.isLoading = k.isLoading, I.isValidating = k.isValidating, I.error = k.error, I) : (I = k, k);
2335
+ const M = R(x());
2336
+ return N(M, P) ? (P.data = M.data, P.isLoading = M.isLoading, P.isValidating = M.isValidating, P.error = M.error, P) : (P = M, M);
2294
2337
  },
2295
2338
  () => pe
2296
2339
  ];
2297
2340
  }, [
2298
2341
  r,
2299
2342
  h
2300
- ]), P = br.useSyncExternalStore(ge(
2301
- (A) => W(h, (T, j) => {
2302
- w(j, T) || A();
2343
+ ]), k = br.useSyncExternalStore(ge(
2344
+ (T) => K(h, (R, I) => {
2345
+ N(I, R) || T();
2303
2346
  }),
2304
2347
  // eslint-disable-next-line react-hooks/exhaustive-deps
2305
2348
  [
2306
2349
  r,
2307
2350
  h
2308
2351
  ]
2309
- ), C[0], C[1]), U = !R.current, q = f[h] && f[h].length > 0, K = P.data, H = E(K) ? De : K, fe = P.error, Ee = oe(H), ue = g ? E(K) ? Ee.current : K : H, D = q && !E(fe) ? !1 : U && !E(l) ? l : O().isPaused() ? !1 : o ? E(H) ? !1 : p : E(H) || p, G = !!(h && t && U && D), we = E(P.isValidating) ? G : P.isValidating, tn = E(P.isLoading) ? G : P.isLoading, me = ge(
2310
- async (A) => {
2311
- const T = v.current;
2312
- if (!h || !T || y.current || O().isPaused())
2352
+ ), L[0], L[1]), ue = !C.current, U = f[h] && f[h].length > 0, H = k.data, z = E(H) ? A : H, fe = k.error, we = ae(z), se = g ? E(H) ? we.current : H : z, w = U && !E(fe) ? !1 : ue && !E(l) ? l : O().isPaused() ? !1 : o ? E(z) ? !1 : p : E(z) || p, me = !!(h && t && ue && w), en = E(k.isValidating) ? me : k.isValidating, tn = E(k.isLoading) ? me : k.isLoading, ye = ge(
2353
+ async (T) => {
2354
+ const R = v.current;
2355
+ if (!h || !R || y.current || O().isPaused())
2313
2356
  return !1;
2314
- let j, _, X = !0;
2315
- const pe = A || {}, I = !d[h] || !pe.dedupe, k = () => lt ? !y.current && h === b.current && R.current : h === b.current, J = {
2357
+ let I, D, Q = !0;
2358
+ const pe = T || {}, P = !d[h] || !pe.dedupe, M = () => ut ? !y.current && h === b.current && C.current : h === b.current, J = {
2316
2359
  isValidating: !1,
2317
2360
  isLoading: !1
2361
+ }, et = () => {
2362
+ X(J);
2318
2363
  }, tt = () => {
2319
- Y(J);
2320
- }, nt = () => {
2321
- const V = d[h];
2322
- V && V[1] === _ && delete d[h];
2323
- }, rt = {
2364
+ const G = d[h];
2365
+ G && G[1] === D && delete d[h];
2366
+ }, nt = {
2324
2367
  isValidating: !0
2325
2368
  };
2326
- E(x().data) && (rt.isLoading = !0);
2369
+ E(x().data) && (nt.isLoading = !0);
2327
2370
  try {
2328
- if (I && (Y(rt), n.loadingTimeout && E(x().data) && setTimeout(() => {
2329
- X && k() && O().onLoadingSlow(h, n);
2371
+ if (P && (X(nt), n.loadingTimeout && E(x().data) && setTimeout(() => {
2372
+ Q && M() && O().onLoadingSlow(h, n);
2330
2373
  }, n.loadingTimeout), d[h] = [
2331
- T(z),
2332
- Qe()
2333
- ]), [j, _] = d[h], j = await j, I && setTimeout(nt, n.dedupingInterval), !d[h] || d[h][1] !== _)
2334
- return I && k() && O().onDiscarded(h), !1;
2335
- J.error = L;
2336
- const V = m[h];
2337
- if (!E(V) && // case 1
2338
- (_ <= V[0] || // case 2
2339
- _ <= V[1] || // case 3
2340
- V[1] === 0))
2341
- return tt(), I && k() && O().onDiscarded(h), !1;
2374
+ R(q),
2375
+ Xe()
2376
+ ]), [I, D] = d[h], I = await I, P && setTimeout(tt, n.dedupingInterval), !d[h] || d[h][1] !== D)
2377
+ return P && M() && O().onDiscarded(h), !1;
2378
+ J.error = V;
2379
+ const G = m[h];
2380
+ if (!E(G) && // case 1
2381
+ (D <= G[0] || // case 2
2382
+ D <= G[1] || // case 3
2383
+ G[1] === 0))
2384
+ return et(), P && M() && O().onDiscarded(h), !1;
2342
2385
  const Z = x().data;
2343
- J.data = s(Z, j) ? Z : j, I && k() && O().onSuccess(j, h, n);
2344
- } catch (V) {
2345
- nt();
2346
- const Z = O(), { shouldRetryOnError: xe } = Z;
2347
- Z.isPaused() || (J.error = V, I && k() && (Z.onError(V, h, Z), (xe === !0 || Q(xe) && xe(V)) && (!O().revalidateOnFocus || !O().revalidateOnReconnect || N()) && Z.onErrorRetry(V, h, Z, (nn) => {
2348
- const Pe = f[h];
2349
- Pe && Pe[0] && Pe[0](ye.ERROR_REVALIDATE_EVENT, nn);
2386
+ J.data = s(Z, I) ? Z : I, P && M() && O().onSuccess(I, h, n);
2387
+ } catch (G) {
2388
+ tt();
2389
+ const Z = O(), { shouldRetryOnError: _e } = Z;
2390
+ Z.isPaused() || (J.error = G, P && M() && (Z.onError(G, h, Z), (_e === !0 || W(_e) && _e(G)) && (!O().revalidateOnFocus || !O().revalidateOnReconnect || _()) && Z.onErrorRetry(G, h, Z, (nn) => {
2391
+ const xe = f[h];
2392
+ xe && xe[0] && xe[0](Se.ERROR_REVALIDATE_EVENT, nn);
2350
2393
  }, {
2351
2394
  retryCount: (pe.retryCount || 0) + 1,
2352
2395
  dedupe: !0
2353
2396
  })));
2354
2397
  }
2355
- return X = !1, tt(), !0;
2398
+ return Q = !1, et(), !0;
2356
2399
  },
2357
2400
  // `setState` is immutable, and `eventsCallback`, `fnArg`, and
2358
2401
  // `keyValidating` are depending on `key`, so we can exclude them from
@@ -2369,108 +2412,111 @@ const pt = de.use || ((e) => {
2369
2412
  h,
2370
2413
  r
2371
2414
  ]
2372
- ), et = ge(
2415
+ ), $e = ge(
2373
2416
  // Use callback to make sure `keyRef.current` returns latest result every time
2374
- (...A) => Zt(r, b.current, ...A),
2417
+ (...T) => Jt(r, b.current, ...T),
2375
2418
  // eslint-disable-next-line react-hooks/exhaustive-deps
2376
2419
  []
2377
2420
  );
2378
2421
  if (Fe(() => {
2379
- v.current = t, M.current = n, E(K) || (Ee.current = K);
2422
+ v.current = t, F.current = n, E(H) || (we.current = H);
2380
2423
  }), Fe(() => {
2381
2424
  if (!h) return;
2382
- const A = me.bind(L, Ue);
2383
- let T = 0;
2384
- const _ = Kr(h, f, (X, pe = {}) => {
2385
- if (X == ye.FOCUS_EVENT) {
2386
- const I = Date.now();
2387
- O().revalidateOnFocus && I > T && N() && (T = I + O().focusThrottleInterval, A());
2388
- } else if (X == ye.RECONNECT_EVENT)
2389
- O().revalidateOnReconnect && N() && A();
2425
+ const T = ye.bind(V, Ve);
2426
+ let R = 0;
2427
+ const D = Kr(h, f, (Q, pe = {}) => {
2428
+ if (Q == Se.FOCUS_EVENT) {
2429
+ const P = Date.now();
2430
+ O().revalidateOnFocus && P > R && _() && (R = P + O().focusThrottleInterval, T());
2431
+ } else if (Q == Se.RECONNECT_EVENT)
2432
+ O().revalidateOnReconnect && _() && T();
2390
2433
  else {
2391
- if (X == ye.MUTATE_EVENT)
2392
- return me();
2393
- if (X == ye.ERROR_REVALIDATE_EVENT)
2394
- return me(pe);
2434
+ if (Q == Se.MUTATE_EVENT)
2435
+ return ye();
2436
+ if (Q == Se.ERROR_REVALIDATE_EVENT)
2437
+ return ye(pe);
2395
2438
  }
2396
2439
  });
2397
- return y.current = !1, b.current = h, R.current = !0, Y({
2398
- _k: z
2399
- }), D && (E(H) || ve ? A() : Pr(A)), () => {
2400
- y.current = !0, _();
2440
+ return y.current = !1, b.current = h, C.current = !0, X({
2441
+ _k: q
2442
+ }), w && (E(z) || Ee ? T() : Pr(T)), () => {
2443
+ y.current = !0, D();
2401
2444
  };
2402
2445
  }, [
2403
2446
  h
2404
2447
  ]), Fe(() => {
2405
- let A;
2406
- function T() {
2407
- const _ = Q(u) ? u(x().data) : u;
2408
- _ && A !== -1 && (A = setTimeout(j, _));
2448
+ let T;
2449
+ function R() {
2450
+ const D = W(u) ? u(x().data) : u;
2451
+ D && T !== -1 && (T = setTimeout(I, D));
2409
2452
  }
2410
- function j() {
2411
- !x().error && (c || O().isVisible()) && (i || O().isOnline()) ? me(Ue).then(T) : T();
2453
+ function I() {
2454
+ !x().error && (c || O().isVisible()) && (i || O().isOnline()) ? ye(Ve).then(R) : R();
2412
2455
  }
2413
- return T(), () => {
2414
- A && (clearTimeout(A), A = -1);
2456
+ return R(), () => {
2457
+ T && (clearTimeout(T), T = -1);
2415
2458
  };
2416
2459
  }, [
2417
2460
  u,
2418
2461
  c,
2419
2462
  i,
2420
2463
  h
2421
- ]), un(ue), o && E(H) && h) {
2422
- if (!lt && ve)
2464
+ ]), un(se), o && E(z) && h) {
2465
+ if (!ut && Ee)
2423
2466
  throw new Error("Fallback data is required when using suspense in SSR.");
2424
- v.current = t, M.current = n, y.current = !1;
2425
- const A = S[h];
2426
- if (!E(A)) {
2427
- const T = et(A);
2428
- pt(T);
2467
+ v.current = t, F.current = n, y.current = !1;
2468
+ const T = S[h];
2469
+ if (!E(T)) {
2470
+ const R = $e(T);
2471
+ ft(R);
2429
2472
  }
2430
2473
  if (E(fe)) {
2431
- const T = me(Ue);
2432
- E(ue) || (T.status = "fulfilled", T.value = !0), pt(T);
2474
+ const R = ye(Ve);
2475
+ E(se) || (R.status = "fulfilled", R.value = !0), ft(R);
2433
2476
  } else
2434
2477
  throw fe;
2435
2478
  }
2436
2479
  return {
2437
- mutate: et,
2480
+ mutate: $e,
2438
2481
  get data() {
2439
- return B.data = !0, ue;
2482
+ return re.data = !0, se;
2440
2483
  },
2441
2484
  get error() {
2442
- return B.error = !0, fe;
2485
+ return re.error = !0, fe;
2443
2486
  },
2444
2487
  get isValidating() {
2445
- return B.isValidating = !0, we;
2488
+ return re.isValidating = !0, en;
2446
2489
  },
2447
2490
  get isLoading() {
2448
- return B.isLoading = !0, tn;
2491
+ return re.isLoading = !0, tn;
2449
2492
  }
2450
2493
  };
2451
2494
  }, Zr = Wr(Jr);
2452
- function ps() {
2453
- const { apiUrl: e, botToken: t } = ce(), n = St({
2495
+ function ms() {
2496
+ const { apiUrl: e, botToken: t } = B(), n = yt({
2454
2497
  apiUrl: e,
2455
2498
  botToken: t
2456
2499
  });
2457
2500
  return Zr(n.options, n.apis.fetchPreludeData);
2458
2501
  }
2459
2502
  export {
2460
- fs as W,
2461
- $ as _,
2462
- ds as a,
2463
- ps as b,
2503
+ hs as W,
2504
+ Y as _,
2505
+ B as a,
2506
+ gs as b,
2464
2507
  is as c,
2465
- as as d,
2466
- ls as e,
2467
- Ce as f,
2508
+ ms as d,
2509
+ as as e,
2510
+ ps as f,
2468
2511
  cs as g,
2469
- us as h,
2470
- Te as i,
2471
- bt as j,
2472
- kt as k,
2473
- ur as l,
2474
- ce as u
2512
+ Ce as h,
2513
+ fs as i,
2514
+ Te as j,
2515
+ wt as k,
2516
+ jt as l,
2517
+ ls as m,
2518
+ ds as n,
2519
+ ur as o,
2520
+ us as u
2475
2521
  };
2476
- //# sourceMappingURL=index-BQfnx4Er.js.map
2522
+ //# sourceMappingURL=index-CgATAy4r.js.map