@axos-web-dev/shared-components 2.0.0-dev.enableCTA2 → 2.0.0-dev.insights.11

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 (90) hide show
  1. package/dist/ATMLocator/ATMLocator.js +1 -1
  2. package/dist/Auth/ErrorAlert.js +1 -1
  3. package/dist/Button/Button.js +1 -1
  4. package/dist/Calculators/ApyCalculator/index.js +5 -78
  5. package/dist/Calculators/Calculator.js +1 -1
  6. package/dist/Calculators/MarginTradingCalculator/index.js +1 -1
  7. package/dist/Carousel/index.js +1 -1
  8. package/dist/Chatbot/Bubble.css.js +0 -1
  9. package/dist/Chatbot/ChatWindow.d.ts +0 -1
  10. package/dist/Chatbot/ChatWindow.js +10 -5
  11. package/dist/Chatbot/Chatbot.css.js +1 -0
  12. package/dist/Chatbot/Chatbot.js +42 -75
  13. package/dist/Chatbot/ChatbotMessage.d.ts +0 -1
  14. package/dist/Chatbot/ChatbotMessage.js +1 -2
  15. package/dist/Chatbot/store/messages.d.ts +1 -6
  16. package/dist/Chatbot/store/messages.js +3 -62
  17. package/dist/Chevron/index.js +1 -1
  18. package/dist/Comparison/Comparison.js +1 -1
  19. package/dist/ExecutiveBio/ExecutiveBio.js +1 -1
  20. package/dist/FaqAccordion/index.js +1 -1
  21. package/dist/FdicCallout/index.js +1 -1
  22. package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +1 -1
  23. package/dist/Forms/ApplyNow.js +1 -1
  24. package/dist/Forms/ContactUsBusiness.js +1 -1
  25. package/dist/Forms/ContactUsBusinessNameEmail.js +1 -1
  26. package/dist/Forms/ContactUsNMLSId.js +1 -1
  27. package/dist/Forms/CpraRequest.js +1 -1
  28. package/dist/Forms/CraPublicFile.js +1 -1
  29. package/dist/Forms/EmailOnly.js +2 -12
  30. package/dist/Forms/FormEnums.d.ts +0 -16
  31. package/dist/Forms/FormEnums.js +0 -27
  32. package/dist/Forms/MortgageRate/MortgageRateForm.js +9 -27
  33. package/dist/Forms/MortgageRate/MortgageRateQuoteFilters.js +11 -33
  34. package/dist/Forms/MortgageRate/MortgageRateWatch.d.ts +1 -1
  35. package/dist/Forms/MortgageRate/MortgageRateWatch.js +18 -91
  36. package/dist/Forms/MortgageWarehouseLending.js +1 -1
  37. package/dist/Forms/SuccesForm.js +1 -1
  38. package/dist/Forms/index.d.ts +0 -1
  39. package/dist/Forms/index.js +0 -2
  40. package/dist/Hyperlink/index.js +1 -1
  41. package/dist/ImageLink/ImageLink.js +1 -1
  42. package/dist/ImageLink/ImageLinkSet.js +1 -1
  43. package/dist/ImageLink/index.js +1 -1
  44. package/dist/ImageToast/index.js +1 -1
  45. package/dist/Input/DownPaymentInput.js +0 -1
  46. package/dist/Insight/Featured/CategorySelector.css.d.ts +5 -3
  47. package/dist/Insight/Featured/CategorySelector.css.js +12 -8
  48. package/dist/Insight/Featured/CategorySelector.d.ts +1 -0
  49. package/dist/Insight/Featured/CategorySelector.js +75 -35
  50. package/dist/Insight/Featured/Featured.css.d.ts +13 -4
  51. package/dist/Insight/Featured/Featured.css.js +37 -18
  52. package/dist/Insight/Featured/Featured.d.ts +1 -0
  53. package/dist/Insight/Featured/Featured.js +130 -94
  54. package/dist/Insight/Featured/Header.css.d.ts +1 -0
  55. package/dist/Insight/Featured/Header.css.js +9 -6
  56. package/dist/Insight/Featured/Header.js +11 -18
  57. package/dist/Insight/Featured/index.js +13 -4
  58. package/dist/Insight/index.js +13 -4
  59. package/dist/LandingPageHeader/WithLogin.js +1 -1
  60. package/dist/Modal/Modal.js +1 -1
  61. package/dist/NavigationMenu/AxosALTS/index.js +1 -1
  62. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.js +1 -1
  63. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +1 -1
  64. package/dist/NavigationMenu/AxosBank/SubNavBar.js +2 -2
  65. package/dist/NavigationMenu/AxosBank/index.js +1 -1
  66. package/dist/NavigationMenu/LaVictoire/index.js +1 -1
  67. package/dist/NavigationMenu/NavItem/index.js +1 -1
  68. package/dist/NavigationMenu/ServerNavigation/DropwdownButton.js +1 -1
  69. package/dist/NavigationMenu/ServerNavigation/Menu.js +1 -1
  70. package/dist/NavigationMenu/ServerNavigation/MobileMenu/MobileMenu.js +14 -12
  71. package/dist/NavigationMenu/ServerNavigation/SubNavBar.js +1 -1
  72. package/dist/NavigationMenu/ServerNavigation/SubNavItem.js +1 -1
  73. package/dist/NavigationMenu/ServerNavigation/index.js +1 -1
  74. package/dist/SetContainer/SetContainer.js +1 -1
  75. package/dist/SocialMediaBar/iconsRepository.js +1 -1
  76. package/dist/VideoTile/VideoTile.js +1 -1
  77. package/dist/VideoWrapper/index.js +1 -1
  78. package/dist/assets/CallToActionBar/CallToActionBar.css +2 -1
  79. package/dist/assets/Forms/Forms.css +2 -1
  80. package/dist/assets/Input/Input.css +1 -0
  81. package/dist/assets/Insight/Featured/CategorySelector.css +60 -38
  82. package/dist/assets/Insight/Featured/Featured.css +126 -65
  83. package/dist/assets/Insight/Featured/Header.css +22 -13
  84. package/dist/assets/TextBlock/TextBlock.css +1 -0
  85. package/dist/icons/Clock/index.js +1 -0
  86. package/dist/main.js +12 -5
  87. package/dist/utils/allowedAxosDomains.js +3 -2
  88. package/package.json +4 -5
  89. package/dist/Forms/NonQMLoans.d.ts +0 -16
  90. package/dist/Forms/NonQMLoans.js +0 -471
@@ -75,10 +75,10 @@ import "../Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.js"
75
75
  /* empty css */
76
76
  import "../Carousel/index.js";
77
77
  /* empty css */
78
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
79
78
  /* empty css */
80
79
  import "../Chatbot/store/chat.js";
81
80
  import "../Chatbot/Chatbot.js";
81
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
82
82
  /* empty css */
83
83
  import "../Chatbot/store/messages.js";
84
84
  /* empty css */
@@ -71,10 +71,10 @@ import "./SignInPassword.js";
71
71
  /* empty css */
72
72
  import "../Carousel/index.js";
73
73
  /* empty css */
74
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
75
74
  /* empty css */
76
75
  import "../Chatbot/store/chat.js";
77
76
  import "../Chatbot/Chatbot.js";
77
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
78
78
  import "../LoadingIndicator/LoadingIndicator.css.js";
79
79
  /* empty css */
80
80
  import "../Chatbot/store/messages.js";
@@ -80,10 +80,10 @@ import "../Auth/SignInPassword.js";
80
80
  /* empty css */
81
81
  import "../Carousel/index.js";
82
82
  /* empty css */
83
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
84
83
  /* empty css */
85
84
  import "../Chatbot/store/chat.js";
86
85
  import "../Chatbot/Chatbot.js";
86
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
87
87
  /* empty css */
88
88
  import "../Chatbot/store/messages.js";
89
89
  /* empty css */
@@ -24,10 +24,6 @@ const CALCULATOR_DEFINITIONS = [
24
24
  term: "APY (Annual Percentage Yield)",
25
25
  description: "The rate your money earns in a year, with compounding included."
26
26
  },
27
- {
28
- term: "APR (Annual Percentage Rate)",
29
- description: "The rate your money earns in a year, without compounding."
30
- },
31
27
  {
32
28
  term: "Months",
33
29
  description: "How long you plan to keep your money in the account."
@@ -147,14 +143,6 @@ const ApyCalculator = ({
147
143
  },
148
144
  [compounding]
149
145
  );
150
- const getAPY = useCallback(
151
- (apr) => {
152
- return Number.parseFloat(
153
- (((1 + apr / 100 / compounding) ** compounding - 1) * 100).toFixed(2)
154
- );
155
- },
156
- [compounding]
157
- );
158
146
  const AXOS_ONE_APY = Number(domains.AXOS_ONE_APY) || 4.21;
159
147
  const [initialDeposit, setInitialDeposit] = useState(1e4);
160
148
  const [initialDepositDisplay, setInitialDepositDisplay] = useState(
@@ -162,8 +150,6 @@ const ApyCalculator = ({
162
150
  );
163
151
  const [APY, setAPY] = useState(AXOS_ONE_APY);
164
152
  const [APYDisplay, setAPYDisplay] = useState(APY.toString());
165
- const [APR, setAPR] = useState(() => getAPR(AXOS_ONE_APY));
166
- const [APRDisplay, setAPRDisplay] = useState(APR.toString());
167
153
  const [months, setMonths] = useState(12);
168
154
  const [monthsDisplay, setMonthsDisplay] = useState(months.toString());
169
155
  const [monthlyDeposits, setMonthlyDeposits] = useState(100);
@@ -196,29 +182,10 @@ const ApyCalculator = ({
196
182
  };
197
183
  const handleAPYChange = (e) => {
198
184
  const raw = e.target.value;
199
- const cleaned = raw.replace(/[^0-9.]/g, "");
200
- const num = parseFloat(cleaned);
185
+ const num = parseFloat(raw.replace(/[^0-9.]/g, ""));
201
186
  setAPY(num);
202
- setAPYDisplay(cleaned);
203
- const newAPR = Number.isNaN(num) ? NaN : getAPR(num);
204
- setAPR(newAPR);
205
- setAPRDisplay(Number.isNaN(newAPR) ? "" : newAPR.toString());
206
- };
207
- const handleAPRChange = (e) => {
208
- const raw = e.target.value;
209
- const cleaned = raw.replace(/[^0-9.]/g, "");
210
- const num = parseFloat(cleaned);
211
- setAPR(num);
212
- setAPRDisplay(cleaned);
213
- const newAPY = Number.isNaN(num) ? NaN : getAPY(num);
214
- setAPY(newAPY);
215
- setAPYDisplay(Number.isNaN(newAPY) ? "" : newAPY.toString());
187
+ setAPYDisplay(raw.replace(/[^0-9.]/g, ""));
216
188
  };
217
- useEffect(() => {
218
- const newAPR = Number.isNaN(APY) ? NaN : getAPR(APY);
219
- setAPR(newAPR);
220
- setAPRDisplay(Number.isNaN(newAPR) ? "" : newAPR.toString());
221
- }, [compounding]);
222
189
  const [endingBalanceRaw, setEndingBalanceRaw] = useState(0);
223
190
  const [totalDepositsRaw, setTotalDepositsRaw] = useState(0);
224
191
  const [interestEarnedRaw, setInterestEarnedRaw] = useState(0);
@@ -248,11 +215,9 @@ const ApyCalculator = ({
248
215
  if (!APY || APY <= 0 || Number.isNaN(APY)) {
249
216
  newErrors.APY = "Please enter a valid APY greater than 0.";
250
217
  }
251
- if (!APR || APR <= 0 || Number.isNaN(APR)) {
252
- newErrors.APR = "Please enter a valid APR greater than 0.";
253
- }
254
218
  setFieldErrors(newErrors);
255
219
  if (Object.keys(newErrors).length > 0) return false;
220
+ const APR = getAPR(APY);
256
221
  const interestRate = 0.01 * APR;
257
222
  let total;
258
223
  if (compounding === 360) {
@@ -278,7 +243,7 @@ const ApyCalculator = ({
278
243
  setTotalDepositsRaw(deposits);
279
244
  setInterestEarnedRaw(interest > 0 ? interest : 0);
280
245
  return true;
281
- }, [initialDeposit, APY, APR, months, monthlyDeposits, compounding]);
246
+ }, [initialDeposit, APY, months, monthlyDeposits, compounding, getAPR]);
282
247
  const handleCalculateClick = useCallback(() => {
283
248
  const didCalculate = calculate();
284
249
  if (!didCalculate || !isStackedLayout) return;
@@ -361,8 +326,7 @@ const ApyCalculator = ({
361
326
  className: `${field_row_input} ${fieldErrors.APY ? ` ${field_row_input_error}` : ""}`,
362
327
  id: "apy",
363
328
  type: "text",
364
- inputMode: "decimal",
365
- pattern: "[0-9.]*",
329
+ inputMode: "numeric",
366
330
  name: "apy",
367
331
  value: APYDisplay,
368
332
  onChange: handleAPYChange,
@@ -382,43 +346,6 @@ const ApyCalculator = ({
382
346
  }
383
347
  )
384
348
  ] }),
385
- /* @__PURE__ */ jsxs(Field, { className: `${field_row} ${relative} flex flex_col`, children: [
386
- /* @__PURE__ */ jsx(Label, { className: field_label, children: "APR (Annual Percentage Rate)" }),
387
- /* @__PURE__ */ jsx(
388
- "span",
389
- {
390
- className: `${label_symbol} ${percent}`,
391
- "aria-hidden": "true",
392
- children: "%"
393
- }
394
- ),
395
- /* @__PURE__ */ jsx(
396
- Input,
397
- {
398
- className: `${field_row_input} ${fieldErrors.APR ? ` ${field_row_input_error}` : ""}`,
399
- id: "apr",
400
- type: "text",
401
- inputMode: "decimal",
402
- pattern: "[0-9.]*",
403
- name: "apr",
404
- value: APRDisplay,
405
- onChange: handleAPRChange,
406
- onWheel: (e) => e.currentTarget.blur(),
407
- "aria-invalid": !!fieldErrors.APR,
408
- "aria-describedby": fieldErrors.APR ? "apr-error" : void 0
409
- }
410
- ),
411
- fieldErrors.APR && /* @__PURE__ */ jsx(
412
- Description,
413
- {
414
- as: "span",
415
- id: "apr-error",
416
- className: field_error,
417
- role: "alert",
418
- children: fieldErrors.APR
419
- }
420
- )
421
- ] }),
422
349
  /* @__PURE__ */ jsxs(Field, { className: `${field_row} ${relative} flex flex_col`, children: [
423
350
  /* @__PURE__ */ jsx(Label, { className: field_label, children: "Months" }),
424
351
  /* @__PURE__ */ jsx(
@@ -51,10 +51,10 @@ import { SummitApyCalculator } from "./SummitApyCalculator/index.js";
51
51
  /* empty css */
52
52
  import "../Carousel/index.js";
53
53
  /* empty css */
54
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
55
54
  /* empty css */
56
55
  import "../Chatbot/store/chat.js";
57
56
  import "../Chatbot/Chatbot.js";
57
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
58
58
  import "../LoadingIndicator/LoadingIndicator.css.js";
59
59
  import "react-use";
60
60
  /* empty css */
@@ -80,10 +80,10 @@ import "../../Auth/SignInPassword.js";
80
80
  /* empty css */
81
81
  import "../../Carousel/index.js";
82
82
  /* empty css */
83
- import "../../Chatbot/Chatbot.css.ts.vanilla.css.js";
84
83
  /* empty css */
85
84
  import "../../Chatbot/store/chat.js";
86
85
  import "../../Chatbot/Chatbot.js";
86
+ import "../../Chatbot/Chatbot.css.ts.vanilla.css.js";
87
87
  /* empty css */
88
88
  import "../../Chatbot/store/messages.js";
89
89
  /* empty css */
@@ -81,10 +81,10 @@ import "../Auth/SignInPassword.js";
81
81
  /* empty css */
82
82
  /* empty css */
83
83
  /* empty css */
84
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
85
84
  /* empty css */
86
85
  import "../Chatbot/store/chat.js";
87
86
  import "../Chatbot/Chatbot.js";
87
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
88
88
  /* empty css */
89
89
  import "../Chatbot/store/messages.js";
90
90
  /* empty css */
@@ -2,7 +2,6 @@ import '../assets/Chatbot/Bubble.css';import '../assets/themes/victorie.css';imp
2
2
  /* empty css */
3
3
  /* empty css */
4
4
  /* empty css */
5
- import "./Chatbot.css.ts.vanilla.css.js";
6
5
  /* empty css */
7
6
  var borderHoverGradient = "_7u9pv31";
8
7
  var bubbleWrapper = "_7u9pv32";
@@ -3,7 +3,6 @@ import { default as React } from 'react';
3
3
 
4
4
  interface MessageResponse extends BaseMessageResponse {
5
5
  to_agent?: HumanAgent;
6
- pending?: boolean;
7
6
  }
8
7
  export interface ChatBubble {
9
8
  id: string | number;
@@ -18,6 +18,7 @@ import { useOpenChat } from "./store/chat.js";
18
18
  import { ThankYouMessage } from "./ThankYouMessage.js";
19
19
  const ChatWindow = ({
20
20
  messages,
21
+ status = "connected",
21
22
  onSend,
22
23
  inputDisabled = false,
23
24
  onClose,
@@ -42,6 +43,7 @@ const ChatWindow = ({
42
43
  showThankyouMessage,
43
44
  toggleThankyouMessage,
44
45
  hasEscalated,
46
+ isBlockedInput,
45
47
  isOpen,
46
48
  hasOpenedOnce,
47
49
  chatStatus,
@@ -63,6 +65,7 @@ const ChatWindow = ({
63
65
  const handleSend = (e) => {
64
66
  e.preventDefault();
65
67
  const cleaned = cleanInput(input);
68
+ if (isBlockedInput) return;
66
69
  if (cleaned != "") {
67
70
  onSend(cleaned);
68
71
  setInput("");
@@ -457,7 +460,7 @@ const ChatWindow = ({
457
460
  }
458
461
  ) }) : null,
459
462
  /* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
460
- !messages.some((msg) => !msg.pending) && /* @__PURE__ */ jsx(
463
+ (status === "idle" && messages.length == 0 || messages.length == 0) && /* @__PURE__ */ jsx(
461
464
  "div",
462
465
  {
463
466
  className: clsx(),
@@ -522,7 +525,9 @@ const ChatWindow = ({
522
525
  /* @__PURE__ */ jsx(
523
526
  "div",
524
527
  {
525
- className: clsx(focused && !inputDisabled ? focusAnimation : ""),
528
+ className: clsx(
529
+ focused && !inputDisabled && !isBlockedInput ? focusAnimation : ""
530
+ ),
526
531
  style: {
527
532
  position: "absolute",
528
533
  left: "10%",
@@ -539,7 +544,7 @@ const ChatWindow = ({
539
544
  style: {
540
545
  display: "flex",
541
546
  padding: "12px 16px",
542
- background: inputDisabled || escalationDeflected ? "light-dark(rgba(239, 239, 239, 0.3), rgba(59, 59, 59, 0.3))" : "#ffffff",
547
+ background: isBlockedInput || inputDisabled || status !== "connected" || messages.length == 0 || escalationDeflected ? "light-dark(rgba(239, 239, 239, 0.3), rgba(59, 59, 59, 0.3))" : "#ffffff",
543
548
  borderRadius: 12
544
549
  },
545
550
  children: [
@@ -563,7 +568,7 @@ const ChatWindow = ({
563
568
  "aria-label": "Ask anything...",
564
569
  className: clsx(inputStyle, autoResize),
565
570
  autoFocus: true,
566
- disabled: inputDisabled || escalationDeflected,
571
+ disabled: isBlockedInput || inputDisabled || status !== "connected" || messages.length == 0 || escalationDeflected,
567
572
  rows: 1
568
573
  }
569
574
  ),
@@ -577,7 +582,7 @@ const ChatWindow = ({
577
582
  type: "submit",
578
583
  title: "Send message",
579
584
  "aria-label": "Send message",
580
- disabled: inputDisabled || !input.trim() || escalationDeflected,
585
+ disabled: isBlockedInput || inputDisabled || status !== "connected" || !input.trim() || messages.length == 0 || escalationDeflected,
581
586
  children: /* @__PURE__ */ jsx(
582
587
  "svg",
583
588
  {
@@ -1,3 +1,4 @@
1
+ import "./Chatbot.css.ts.vanilla.css.js";
1
2
  var chatbotAXB = "_1hpv6vm0";
2
3
  var chatbotUFB = "_1hpv6vm1";
3
4
  export {
@@ -40,34 +40,17 @@ const Chatbot = ({
40
40
  hideDisplayThankyouMessage
41
41
  } = useOpenChat();
42
42
  const isVisible = usePageVisibility();
43
- const {
44
- addMessage,
45
- addMessages,
46
- clearMessages,
47
- messages,
48
- addPendingMessage,
49
- resolvePendingMessage
50
- } = useMessages();
43
+ const { addMessage, addMessages, clearMessages, messages } = useMessages();
51
44
  const clientRef = useRef(null);
52
45
  const menuRef = useRef(null);
53
46
  const isMountedRef = useRef(false);
54
47
  const chatRef = useRef(null);
55
48
  const chatLoading = useRef(false);
56
49
  const agent_virtual = useRef(null);
57
- const messageQueueRef = useRef([]);
58
- const sendInFlightRef = useRef(false);
59
- const flushingRef = useRef(false);
60
- const statusRef = useRef("idle");
61
50
  const [status, setStatus] = useState("idle");
62
51
  const [menusLoaded, setMenusLoaded] = useState(false);
63
52
  const [isTyping, setIsTyping] = useState(false);
64
53
  const [scalationStarted, setScalationStarted] = useState(false);
65
- useEffect(() => {
66
- statusRef.current = status;
67
- if (status === "connected") {
68
- flushQueuedMessages();
69
- }
70
- }, [status]);
71
54
  useEffect(() => {
72
55
  if (messages.length === 0) return;
73
56
  const hasScalation = messages.some(
@@ -84,9 +67,6 @@ const Chatbot = ({
84
67
  ["axos", 1],
85
68
  ["ufb", 3]
86
69
  ]);
87
- const hasRealReply = () => useMessages.getState().messages.some(
88
- (m) => !m.pending && m.$userType !== "end_user" && m.type !== "noti" && m.$sid !== "typing-1"
89
- );
90
70
  const typingMessage = {
91
71
  $sid: "typing-1",
92
72
  type: "system",
@@ -127,7 +107,7 @@ const Chatbot = ({
127
107
  menuRef.current = await clientRef.current.getMenus();
128
108
  setMenusLoaded(true);
129
109
  console.log("menus:", menuRef.current);
130
- if (menuRef.current !== null && useOpenChat.getState().isOpen) {
110
+ if (menuRef.current !== null) {
131
111
  await startChat("onReady");
132
112
  }
133
113
  }
@@ -141,11 +121,10 @@ const Chatbot = ({
141
121
  const onChatMessageHandler = async (message) => {
142
122
  console.log("Received message:", message);
143
123
  const { event, $userType } = message;
144
- if (["virtual_agent", "user"].includes($userType) && event === void 0) {
124
+ if (["system", "virtual_agent", "user"].includes($userType) && event === void 0) {
145
125
  addMessage(message);
146
126
  if (!hasEscalated) {
147
127
  unblockInput?.();
148
- flushQueuedMessages();
149
128
  }
150
129
  return;
151
130
  }
@@ -226,7 +205,6 @@ const Chatbot = ({
226
205
  startEscalation?.();
227
206
  }
228
207
  }
229
- flushQueuedMessages();
230
208
  } catch (error) {
231
209
  console.error("Error fetching messages on chat connected:", error);
232
210
  }
@@ -248,7 +226,7 @@ const Chatbot = ({
248
226
  const deregisterEventHandlers = () => {
249
227
  clientRef.current?.off("ready", onReadyHandler);
250
228
  clientRef.current?.off("authenticated", onAuthenticatedHandler);
251
- clientRef.current?.off("chat.ongoing", onChatOngoingHandler);
229
+ clientRef.current?.off("chat.ongoing", onDismissedHandler);
252
230
  clientRef.current?.off("chat.message", onChatMessageHandler);
253
231
  clientRef.current?.off("chat.typingStarted", onChatTypingStartedHandler);
254
232
  clientRef.current?.off("chat.typingEnded", onChatTypingEndedHandler);
@@ -362,41 +340,6 @@ const Chatbot = ({
362
340
  setChatStarted();
363
341
  }
364
342
  };
365
- const sendNow = async (msg) => {
366
- sendInFlightRef.current = true;
367
- let success = true;
368
- try {
369
- await clientRef.current?.sendTextMessage(msg);
370
- } catch (error) {
371
- console.log(error);
372
- success = false;
373
- } finally {
374
- sendInFlightRef.current = false;
375
- if (!hasEscalated) {
376
- blockInput?.();
377
- }
378
- }
379
- return success;
380
- };
381
- const flushQueuedMessages = async () => {
382
- if (flushingRef.current) return;
383
- if (messageQueueRef.current.length === 0) return;
384
- if (!clientRef.current || statusRef.current !== "connected") return;
385
- if (!hasRealReply()) return;
386
- flushingRef.current = true;
387
- try {
388
- while (messageQueueRef.current.length > 0 && !useOpenChat.getState().isBlockedInput && !sendInFlightRef.current) {
389
- const next = messageQueueRef.current[0];
390
- const success = await sendNow(next.text);
391
- messageQueueRef.current.shift();
392
- if (!success) {
393
- resolvePendingMessage(next.id);
394
- }
395
- }
396
- } finally {
397
- flushingRef.current = false;
398
- }
399
- };
400
343
  const onSendMessage = async (msg) => {
401
344
  const clientChatId = clientRef.current?.chat?.id;
402
345
  const refChatId = chatRef.current?.id;
@@ -408,16 +351,15 @@ const Chatbot = ({
408
351
  "| chatRef.id:",
409
352
  refChatId
410
353
  );
411
- const notReady = !clientRef.current || statusRef.current !== "connected";
412
- const isThinking = useOpenChat.getState().isBlockedInput;
413
- const noReplyYet = !hasRealReply();
414
- if (notReady || isThinking || sendInFlightRef.current || noReplyYet) {
415
- const id = `pending-${Date.now()}-${Math.random().toString(36).slice(2)}`;
416
- messageQueueRef.current.push({ id, text: msg });
417
- addPendingMessage(id, msg);
418
- return;
354
+ try {
355
+ await clientRef.current?.sendTextMessage(msg);
356
+ } catch (error) {
357
+ console.log(error);
358
+ } finally {
359
+ if (!hasEscalated) {
360
+ blockInput?.();
361
+ }
419
362
  }
420
- await sendNow(msg);
421
363
  };
422
364
  const onEndChat = async () => {
423
365
  console.log(`Ending chat [end chat]`);
@@ -431,9 +373,6 @@ const Chatbot = ({
431
373
  clearMessages();
432
374
  chatRef.current = null;
433
375
  resetChatStarted();
434
- messageQueueRef.current = [];
435
- sendInFlightRef.current = false;
436
- flushingRef.current = false;
437
376
  console.log("Chat ended");
438
377
  endEscalation?.();
439
378
  } finally {
@@ -460,8 +399,6 @@ const Chatbot = ({
460
399
  console.log("Chatbot unmounted");
461
400
  deregisterEventHandlers();
462
401
  chatLoading.current = false;
463
- messageQueueRef.current = [];
464
- sendInFlightRef.current = false;
465
402
  reset();
466
403
  resetChatStarted();
467
404
  setStatus("idle");
@@ -506,6 +443,36 @@ const Chatbot = ({
506
443
  }
507
444
  }
508
445
  }, [isOpen, isVisible]);
446
+ useMount(() => {
447
+ const hasParams = () => {
448
+ return window.location.search.includes("utm_");
449
+ };
450
+ const tryStart = () => {
451
+ if (hasParams()) {
452
+ startChat("utm-ready");
453
+ return true;
454
+ }
455
+ return false;
456
+ };
457
+ if (tryStart()) return;
458
+ const original = history.replaceState;
459
+ history.replaceState = function(...args) {
460
+ original.apply(this, args);
461
+ if (tryStart()) {
462
+ history.replaceState = original;
463
+ }
464
+ };
465
+ const interval = setInterval(() => {
466
+ if (tryStart()) {
467
+ clearInterval(interval);
468
+ history.replaceState = original;
469
+ }
470
+ }, 100);
471
+ return () => {
472
+ clearInterval(interval);
473
+ history.replaceState = original;
474
+ };
475
+ });
509
476
  return menusLoaded && /* @__PURE__ */ jsxs(
510
477
  "div",
511
478
  {
@@ -3,7 +3,6 @@ import { MessageResponse as BaseMessageResponse, HumanAgent, VirtualAgent } from
3
3
 
4
4
  interface MessageResponse extends BaseMessageResponse {
5
5
  to_agent?: HumanAgent;
6
- pending?: boolean;
7
6
  }
8
7
  interface ChatbotMessageProps {
9
8
  msg: MessageResponse;
@@ -108,7 +108,6 @@ const ChatbotMessage = ({
108
108
  messageStyle,
109
109
  msg.$userType == "end_user" ? user_msg : agent_msg
110
110
  ),
111
- style: msg.pending ? { opacity: 0.65 } : void 0,
112
111
  children: /* @__PURE__ */ jsxs(
113
112
  "div",
114
113
  {
@@ -254,7 +253,7 @@ const ChatbotMessage = ({
254
253
  textTransform: "capitalize",
255
254
  fontFamily: "inherit"
256
255
  },
257
- children: msg.pending ? "Sending..." : timeText
256
+ children: timeText
258
257
  }
259
258
  )
260
259
  ]
@@ -1,17 +1,12 @@
1
1
  import { MessageResponse } from '@ujet/websdk-headless';
2
2
 
3
- export type PendingMessage = MessageResponse & {
4
- pending?: boolean;
5
- };
6
3
  interface MessageStore {
7
- messages: Array<PendingMessage>;
4
+ messages: Array<MessageResponse>;
8
5
  addMessage: (message: MessageResponse) => void;
9
6
  removeMessage: (id: string) => void;
10
7
  addMessages: (newMessages: MessageResponse[]) => void;
11
8
  clearMessages: () => void;
12
9
  isEscalated: boolean;
13
- addPendingMessage: (id: string, text: string) => void;
14
- resolvePendingMessage: (id: string) => void;
15
10
  }
16
11
  export interface Message {
17
12
  id: string;
@@ -3,77 +3,18 @@ const useMessages = create((set, get) => ({
3
3
  messages: [],
4
4
  addMessage: (message) => set((state) => {
5
5
  const cleaned = state.messages.filter((m) => m.$sid !== "typing-1");
6
- const isPending = message.pending;
7
- if (!isPending && message.$userType === "end_user") {
8
- const pendingIdx = cleaned.findIndex(
9
- (m) => m.pending && m.content === message.content
10
- );
11
- if (pendingIdx !== -1) {
12
- return {
13
- messages: [
14
- ...cleaned.slice(0, pendingIdx),
15
- message,
16
- ...cleaned.slice(pendingIdx + 1)
17
- ]
18
- };
19
- }
20
- return { messages: [...cleaned, message] };
21
- }
22
- const insertBeforeIdx = !isPending ? cleaned.findIndex((m) => m.pending) : -1;
23
- if (insertBeforeIdx === -1) {
24
- return { messages: [...cleaned, message] };
25
- }
26
- return {
27
- messages: [
28
- ...cleaned.slice(0, insertBeforeIdx),
29
- message,
30
- ...cleaned.slice(insertBeforeIdx)
31
- ]
32
- };
6
+ return { messages: [...cleaned, message] };
33
7
  }),
34
8
  removeMessage: (id) => set((state) => ({
35
9
  messages: state.messages.filter(
36
10
  (msg) => "$sid" in msg && msg.$sid !== id
37
11
  )
38
12
  })),
39
- addMessages: (newMessages) => set((state) => {
40
- const pendingIdx = state.messages.findIndex(
41
- (m) => m.pending
42
- );
43
- if (pendingIdx === -1) {
44
- return { messages: [...state.messages, ...newMessages] };
45
- }
46
- return {
47
- messages: [
48
- ...state.messages.slice(0, pendingIdx),
49
- ...newMessages,
50
- ...state.messages.slice(pendingIdx)
51
- ]
52
- };
53
- }),
13
+ addMessages: (newMessages) => set((state) => ({ messages: [...state.messages, ...newMessages] })),
54
14
  clearMessages: () => set({ messages: [] }),
55
15
  isEscalated: get()?.messages?.some(
56
16
  (msg) => ["escalationAccepted", "escalationStarted"].includes(msg.event)
57
- ),
58
- addPendingMessage: (id, text) => set((state) => ({
59
- messages: [
60
- ...state.messages,
61
- {
62
- $sid: id,
63
- type: "text",
64
- content: text,
65
- sender: { id: "end_user", type: "end_user" },
66
- $timestamp: /* @__PURE__ */ new Date(),
67
- $userType: "end_user",
68
- $index: Date.now(),
69
- $userId: 0,
70
- pending: true
71
- }
72
- ]
73
- })),
74
- resolvePendingMessage: (id) => set((state) => ({
75
- messages: state.messages.filter((msg) => msg.$sid !== id)
76
- }))
17
+ )
77
18
  }));
78
19
  export {
79
20
  useMessages
@@ -81,10 +81,10 @@ import "../Auth/SignInPassword.js";
81
81
  /* empty css */
82
82
  import "../Carousel/index.js";
83
83
  /* empty css */
84
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
85
84
  /* empty css */
86
85
  import "../Chatbot/store/chat.js";
87
86
  import "../Chatbot/Chatbot.js";
87
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
88
88
  /* empty css */
89
89
  import "../Chatbot/store/messages.js";
90
90
  /* empty css */
@@ -81,10 +81,10 @@ import "../Auth/SignInPassword.js";
81
81
  /* empty css */
82
82
  import "../Carousel/index.js";
83
83
  /* empty css */
84
- import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
85
84
  /* empty css */
86
85
  import "../Chatbot/store/chat.js";
87
86
  import "../Chatbot/Chatbot.js";
87
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
88
88
  /* empty css */
89
89
  import "../Chatbot/store/messages.js";
90
90
  /* empty css */