@axos-web-dev/shared-components 1.0.99 → 1.0.100-dev.2

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 (160) hide show
  1. package/dist/ATMLocator/ATMLocator.js +8 -1
  2. package/dist/ArticlesSet/ArticlesSet.js +2 -2
  3. package/dist/Auth/ErrorAlert.js +10 -3
  4. package/dist/Blockquote/Blockquote.module.js +3 -3
  5. package/dist/Button/Button.js +10 -3
  6. package/dist/Calculators/Calculator.js +22 -3
  7. package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.d.ts +9 -0
  8. package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.js +219 -0
  9. package/dist/Calculators/MaxLoanCalculator/index.js +22 -5
  10. package/dist/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.d.ts +1 -0
  11. package/dist/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.js +2 -0
  12. package/dist/Calculators/MonthlyPaymentCalculator/index.js +15 -5
  13. package/dist/Calculators/index.d.ts +2 -1
  14. package/dist/Calculators/index.js +3 -1
  15. package/dist/Carousel/index.js +10 -3
  16. package/dist/Chatbot/Bubble.css.d.ts +1 -0
  17. package/dist/Chatbot/Bubble.css.js +5 -0
  18. package/dist/Chatbot/Bubble.d.ts +3 -0
  19. package/dist/Chatbot/Bubble.js +48 -0
  20. package/dist/Chatbot/Chat.d.ts +1 -0
  21. package/dist/Chatbot/Chat.js +165 -0
  22. package/dist/Chatbot/ChatWindow.css.d.ts +11 -0
  23. package/dist/Chatbot/ChatWindow.css.js +25 -0
  24. package/dist/Chatbot/ChatWindow.d.ts +23 -0
  25. package/dist/Chatbot/ChatWindow.js +202 -0
  26. package/dist/Chatbot/Chatbot.css.d.ts +1 -0
  27. package/dist/Chatbot/Chatbot.css.js +5 -0
  28. package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +1 -0
  29. package/dist/Chatbot/Chatbot.d.ts +1 -0
  30. package/dist/Chatbot/Chatbot.js +39 -0
  31. package/dist/Chatbot/authenticate.d.ts +3 -0
  32. package/dist/Chatbot/authenticate.js +16 -0
  33. package/dist/Chatbot/index.d.ts +9 -0
  34. package/dist/Chatbot/index.js +31 -0
  35. package/dist/Chatbot/store/chat.d.ts +9 -0
  36. package/dist/Chatbot/store/chat.js +11 -0
  37. package/dist/Chatbot/store/messages.d.ts +14 -0
  38. package/dist/Chatbot/store/messages.js +12 -0
  39. package/dist/Chatbot/useHeadlessChat.d.ts +22 -0
  40. package/dist/Chatbot/useHeadlessChat.js +157 -0
  41. package/dist/Chevron/index.js +10 -3
  42. package/dist/Comparison/Comparison.js +10 -3
  43. package/dist/ExecutiveBio/ExecutiveBio.js +10 -3
  44. package/dist/FaqAccordion/index.js +10 -3
  45. package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +10 -3
  46. package/dist/Forms/ApplicationStart.d.ts +1 -1
  47. package/dist/Forms/ApplicationStart.js +111 -89
  48. package/dist/Forms/ApplyNow.d.ts +2 -2
  49. package/dist/Forms/ApplyNow.js +178 -146
  50. package/dist/Forms/ClearingForm.d.ts +1 -1
  51. package/dist/Forms/ClearingForm.js +184 -162
  52. package/dist/Forms/CommercialDeposits.d.ts +1 -1
  53. package/dist/Forms/CommercialDeposits.js +201 -179
  54. package/dist/Forms/CommercialLending.d.ts +1 -1
  55. package/dist/Forms/CommercialLending.js +278 -256
  56. package/dist/Forms/CommercialPremiumFinance.d.ts +1 -1
  57. package/dist/Forms/CommercialPremiumFinance.js +128 -106
  58. package/dist/Forms/ContactCompany.d.ts +1 -1
  59. package/dist/Forms/ContactCompany.js +113 -91
  60. package/dist/Forms/ContactCompanyTitle.d.ts +1 -1
  61. package/dist/Forms/ContactCompanyTitle.js +127 -105
  62. package/dist/Forms/ContactUs.d.ts +1 -1
  63. package/dist/Forms/ContactUs.js +99 -77
  64. package/dist/Forms/ContactUsAAS.d.ts +1 -1
  65. package/dist/Forms/ContactUsAAS.js +180 -158
  66. package/dist/Forms/ContactUsBusiness.d.ts +1 -1
  67. package/dist/Forms/ContactUsBusiness.js +143 -115
  68. package/dist/Forms/ContactUsBusinessNameEmail.d.ts +1 -1
  69. package/dist/Forms/ContactUsBusinessNameEmail.js +112 -84
  70. package/dist/Forms/ContactUsLVF.d.ts +3 -1
  71. package/dist/Forms/ContactUsLVF.js +127 -101
  72. package/dist/Forms/ContactUsNMLSId.d.ts +1 -1
  73. package/dist/Forms/ContactUsNMLSId.js +126 -98
  74. package/dist/Forms/CpraRequest.d.ts +1 -1
  75. package/dist/Forms/CpraRequest.js +641 -619
  76. package/dist/Forms/CraPublicFile.d.ts +1 -1
  77. package/dist/Forms/CraPublicFile.js +118 -90
  78. package/dist/Forms/DealerServices.d.ts +1 -1
  79. package/dist/Forms/DealerServices.js +225 -204
  80. package/dist/Forms/EmailOnly.d.ts +1 -1
  81. package/dist/Forms/EmailOnly.js +65 -39
  82. package/dist/Forms/EmailUs.d.ts +1 -1
  83. package/dist/Forms/EmailUs.js +75 -53
  84. package/dist/Forms/FormProps.d.ts +3 -0
  85. package/dist/Forms/Forms.css.d.ts +18 -0
  86. package/dist/Forms/Forms.css.js +44 -38
  87. package/dist/Forms/HoneyPot/HoneyPot.css.d.ts +1 -0
  88. package/dist/Forms/HoneyPot/HoneyPot.css.js +5 -0
  89. package/dist/Forms/HoneyPot/index.d.ts +23 -0
  90. package/dist/Forms/HoneyPot/index.js +69 -0
  91. package/dist/Forms/MortgageRate/MortgageRateForm.d.ts +1 -1
  92. package/dist/Forms/MortgageRate/MortgageRateForm.js +376 -348
  93. package/dist/Forms/MortgageRate/MortgageRateWatch.js +10 -3
  94. package/dist/Forms/MortgageWarehouseLending.d.ts +11 -0
  95. package/dist/Forms/MortgageWarehouseLending.js +343 -0
  96. package/dist/Forms/QuickPricer/QuickPricerForm.d.ts +1 -1
  97. package/dist/Forms/QuickPricer/QuickPricerForm.js +624 -609
  98. package/dist/Forms/ScheduleCall.d.ts +1 -1
  99. package/dist/Forms/ScheduleCall.js +156 -134
  100. package/dist/Forms/ScheduleCallPremier.d.ts +1 -1
  101. package/dist/Forms/ScheduleCallPremier.js +178 -156
  102. package/dist/Forms/SuccesForm.js +13 -6
  103. package/dist/Forms/VendorQuestionnaire.d.ts +1 -1
  104. package/dist/Forms/VendorQuestionnaire.js +817 -795
  105. package/dist/Forms/WcplSurvey.d.ts +1 -1
  106. package/dist/Forms/WcplSurvey.js +112 -90
  107. package/dist/Forms/applynow-utils.d.ts +1 -0
  108. package/dist/Forms/applynow-utils.js +48 -0
  109. package/dist/Forms/index.d.ts +3 -0
  110. package/dist/Forms/index.js +12 -2
  111. package/dist/HeroBanner/HeroBanner.js +42 -1
  112. package/dist/Hyperlink/index.js +10 -3
  113. package/dist/IconBillboard/sections/CallToActionSection.js +2 -1
  114. package/dist/ImageBillboard/ExitIntentModal/useExitIntentModal.js +6 -1
  115. package/dist/ImageLink/ImageLink.js +10 -3
  116. package/dist/ImageLink/ImageLinkSet.js +10 -3
  117. package/dist/ImageLink/index.js +10 -3
  118. package/dist/Input/Input.js +3 -1
  119. package/dist/Insight/Featured/CategorySelector.js +10 -3
  120. package/dist/Insight/Featured/Featured.js +10 -3
  121. package/dist/Insight/Featured/Header.js +10 -3
  122. package/dist/Modal/Modal.js +10 -3
  123. package/dist/NavigationMenu/AxosALTS/NavData.js +10 -3
  124. package/dist/NavigationMenu/AxosALTS/index.js +10 -3
  125. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.module.js +16 -16
  126. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.d.ts +1 -0
  127. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +25 -7
  128. package/dist/NavigationMenu/AxosBank/NavBar.module.js +39 -39
  129. package/dist/NavigationMenu/AxosBank/NavData.js +10 -3
  130. package/dist/NavigationMenu/AxosBank/SubNavBar.js +32 -8
  131. package/dist/NavigationMenu/AxosBank/index.js +10 -3
  132. package/dist/NavigationMenu/LaVictoire/NavData.js +10 -3
  133. package/dist/NavigationMenu/LaVictoire/index.js +10 -3
  134. package/dist/NavigationMenu/NavDataJson.d.ts +2 -0
  135. package/dist/NavigationMenu/NavDataJson.js +315 -0
  136. package/dist/NavigationMenu/Navbar.d.ts +5 -0
  137. package/dist/NavigationMenu/Navbar.js +201 -0
  138. package/dist/NavigationMenu/SignInNavButton.d.ts +1 -0
  139. package/dist/NavigationMenu/SignInNavButton.js +369 -0
  140. package/dist/SetContainer/SetContainer.js +10 -3
  141. package/dist/SocialMediaBar/iconsRepository.js +10 -3
  142. package/dist/Table/Table.d.ts +1 -1
  143. package/dist/VideoTile/VideoTile.js +10 -3
  144. package/dist/VideoWrapper/index.js +10 -3
  145. package/dist/assets/Blockquote/Blockquote.css.css +68 -68
  146. package/dist/assets/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css +3 -0
  147. package/dist/assets/Chatbot/Bubble.css +40 -0
  148. package/dist/assets/Chatbot/ChatWindow.css +107 -0
  149. package/dist/assets/Forms/Forms.css +135 -105
  150. package/dist/assets/Forms/HoneyPot/HoneyPot.css +8 -0
  151. package/dist/assets/NavigationMenu/AxosBank/MobileMenu/MobileMenu.css.css +191 -191
  152. package/dist/assets/NavigationMenu/AxosBank/NavBar.css.css +473 -473
  153. package/dist/assets/utils/optimizeImage/optimizeImage.css.css +47 -47
  154. package/dist/icons/Logos/AXB.d.ts +8 -0
  155. package/dist/icons/Logos/AXB.js +74 -0
  156. package/dist/main.d.ts +1 -0
  157. package/dist/main.js +43 -3
  158. package/dist/utils/allowedAxosDomains.js +2 -1
  159. package/dist/utils/optimizeImage/optimizeImage.module.js +3 -3
  160. package/package.json +136 -133
@@ -6,7 +6,7 @@ import { getVariant } from "../utils/getVariant.js";
6
6
  import { section_text } from "../IconBillboard/IconBillboard.css.js";
7
7
  import "../icons/ArrowIcon/ArrowIcon.css.js";
8
8
  import "../icons/CheckIcon/CheckIcon.css.js";
9
- import '../assets/VideoWrapper/VideoWrapper.css';import '../assets/TopicalNavSet/TopicalNavSet.css';import '../assets/TopicalNavItem/TopicalNavItem.css';import '../assets/Topic/Topic.css';import '../assets/TextBlock/TextBlock.css';import '../assets/SocialMediaBar/SocialMediaBar.css';import '../assets/SecondaryFooter/SecondaryFooter.css';import '../assets/Pagination/Pagination.css';import '../assets/PageNavSet/PageNavigationSet.css';import '../assets/NavigationMenu/LaVictoire/NavBar.css';import '../assets/NavigationMenu/AxosALTS/NavBar.css';import '../assets/NavigationMenu/AxosClearing/NavBar.css';import '../assets/NavigationMenu/AxosBank/SubNavbar.css';import '../assets/NavigationMenu/AxosBank/NavBar.css';import '../assets/NavigationMenu/AxosAdvisorServices/SubNavbar.css';import '../assets/NavigationMenu/AxosAdvisorServices/NavBar.css';import '../assets/NavigationMenu/AxosAdvisor/SubNavbar.css';import '../assets/NavigationMenu/AxosAdvisor/NavBar.css';import '../assets/Insight/Insight.css';import '../assets/Insight/Featured/Header.css';import '../assets/Insight/Featured/CategorySelector.css';import '../assets/Insight/Featured/Featured.css';import '../assets/ImageLink/ImageLink.css';import '../assets/VideoTile/VideoTile.css';import '../assets/HelpArticle/HelpArticle.css';import '../assets/FooterSiteMap/AxosBank/FooterSiteMap.css';import '../assets/FooterDisclosure/LVF/LaVictorieFooter.css';import '../assets/DownloadTile/DownloadTile.css';import '../assets/CollectInformationAlert/CollectInformationAlert.css';import '../assets/CallToActionBar/CallToActionBar.css';import '../assets/AwardsItem/AwardsItem.css';import '../assets/AwardsBanner/AwardsBanner.css';import '../assets/Auth/SignIn.css';import '../assets/Auth/ErrorAlert.css';import '../assets/Calculators/MarginTradingCalculator/MarginTradingCalculator.css';import '../assets/Forms/QuickPricer/UserInformation.css';import '../assets/Modal/Modal.css';import '../assets/Forms/QuickPricer/QuickPricerResults.css';import '../assets/BulletItem/BulletItem.css';import '../assets/Typography/Typography.css';import '../assets/icons/FollowIcon/FollowIcon.css';import '../assets/icons/DownloadIcon/DownloadIcon.css';import '../assets/themes/victorie.css';import '../assets/themes/premier.css';import '../assets/themes/axos.css';/* empty css */
9
+ import '../assets/VideoWrapper/VideoWrapper.css';import '../assets/TopicalNavSet/TopicalNavSet.css';import '../assets/TopicalNavItem/TopicalNavItem.css';import '../assets/Topic/Topic.css';import '../assets/TextBlock/TextBlock.css';import '../assets/SocialMediaBar/SocialMediaBar.css';import '../assets/SecondaryFooter/SecondaryFooter.css';import '../assets/Pagination/Pagination.css';import '../assets/PageNavSet/PageNavigationSet.css';import '../assets/NavigationMenu/LaVictoire/NavBar.css';import '../assets/NavigationMenu/AxosALTS/NavBar.css';import '../assets/NavigationMenu/AxosClearing/NavBar.css';import '../assets/NavigationMenu/AxosBank/SubNavbar.css';import '../assets/NavigationMenu/AxosBank/NavBar.css';import '../assets/NavigationMenu/AxosAdvisorServices/SubNavbar.css';import '../assets/NavigationMenu/AxosAdvisorServices/NavBar.css';import '../assets/NavigationMenu/AxosAdvisor/SubNavbar.css';import '../assets/NavigationMenu/AxosAdvisor/NavBar.css';import '../assets/Insight/Insight.css';import '../assets/Insight/Featured/Header.css';import '../assets/Insight/Featured/CategorySelector.css';import '../assets/Insight/Featured/Featured.css';import '../assets/ImageLink/ImageLink.css';import '../assets/VideoTile/VideoTile.css';import '../assets/HelpArticle/HelpArticle.css';import '../assets/FooterSiteMap/AxosBank/FooterSiteMap.css';import '../assets/FooterDisclosure/LVF/LaVictorieFooter.css';import '../assets/DownloadTile/DownloadTile.css';import '../assets/CollectInformationAlert/CollectInformationAlert.css';import '../assets/Chatbot/ChatWindow.css';import '../assets/Chatbot/Bubble.css';import '../assets/CallToActionBar/CallToActionBar.css';import '../assets/AwardsItem/AwardsItem.css';import '../assets/AwardsBanner/AwardsBanner.css';import '../assets/Auth/SignIn.css';import '../assets/Auth/ErrorAlert.css';import '../assets/Calculators/MarginTradingCalculator/MarginTradingCalculator.css';import '../assets/Forms/QuickPricer/UserInformation.css';import '../assets/Modal/Modal.css';import '../assets/Forms/QuickPricer/QuickPricerResults.css';import '../assets/BulletItem/BulletItem.css';import '../assets/Typography/Typography.css';import '../assets/icons/FollowIcon/FollowIcon.css';import '../assets/icons/DownloadIcon/DownloadIcon.css';import '../assets/themes/victorie.css';import '../assets/themes/premier.css';import '../assets/themes/axos.css';/* empty css */
10
10
  /* empty css */
11
11
  /* empty css */
12
12
  /* empty css */
@@ -41,8 +41,11 @@ import "../Input/InputPhone.js";
41
41
  import "../Input/InputTextArea.js";
42
42
  import "../Input/DownPaymentInput.js";
43
43
  import "../Input/RadioButton.js";
44
+ import "../Input/PercentageInput.js";
44
45
  import "react-hook-form";
46
+ import "../Calculators/BuyDownCalculator/BuyDownCalculator.css.js";
45
47
  import "../Forms/Forms.css.js";
48
+ import "../Forms/HoneyPot/index.js";
46
49
  import "../Forms/SalesforceFieldsForm.js";
47
50
  import "../Input/RadioButton.css.js";
48
51
  import "../Input/Checkbox.css.js";
@@ -61,8 +64,6 @@ import "iframe-resizer";
61
64
  import "../Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.js";
62
65
  import "../Calculators/MonthlyPaymentLVFCalculator/MonthlyPaymentCalculator.css.js";
63
66
  import "../Calculators/SummitApyCalculator/BalanceAPYCalculator.css.js";
64
- import "../Input/PercentageInput.js";
65
- import "../Calculators/BuyDownCalculator/BuyDownCalculator.css.js";
66
67
  /* empty css */
67
68
  import "react-dom";
68
69
  /* empty css */
@@ -70,6 +71,12 @@ import "../Auth/SignInPassword.js";
70
71
  /* empty css */
71
72
  /* empty css */
72
73
  /* empty css */
74
+ /* empty css */
75
+ import "../Chatbot/store/chat.js";
76
+ import "../Chatbot/authenticate.js";
77
+ /* empty css */
78
+ import "../Chatbot/store/messages.js";
79
+ import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
73
80
  /* empty css */
74
81
  import "../Comparison/Comparison.css.js";
75
82
  import "next/image.js";
@@ -0,0 +1 @@
1
+ export declare const bubbleWrapper: string;
@@ -0,0 +1,5 @@
1
+ import '../assets/Chatbot/Bubble.css';/* empty css */
2
+ var bubbleWrapper = "_7u9pv30";
3
+ export {
4
+ bubbleWrapper
5
+ };
@@ -0,0 +1,3 @@
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ export declare const Bubble: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { bubbleWrapper } from "./Bubble.css.js";
4
+ import { useOpenChat } from "./store/chat.js";
5
+ import { AnimatePresence, motion } from "framer-motion";
6
+ const Bubble = ({ children }) => {
7
+ const isOpen = useOpenChat((state) => state.isOpen);
8
+ const toggle = useOpenChat((state) => state.toggle);
9
+ return /* @__PURE__ */ jsxs("div", { className: bubbleWrapper, onClick: toggle, children: [
10
+ /* @__PURE__ */ jsx("div", { className: "bubble-circle", children: /* @__PURE__ */ jsx(AnimatePresence, { children: !isOpen ? /* @__PURE__ */ jsx(
11
+ motion.img,
12
+ {
13
+ alt: "Evo, Virtual Financial Assistant",
14
+ src: "https://www.axos.com/images/5yPSYWRtCV9kNiVUzGONdb/axb-chat-bubble.png",
15
+ height: 36,
16
+ width: 36,
17
+ initial: { scale: 0.1, opacity: 0 },
18
+ animate: {
19
+ scale: 1,
20
+ opacity: 1,
21
+ transition: {
22
+ default: { type: "spring" },
23
+ opacity: { ease: [0, 0.71, 0.2, 1.01] }
24
+ }
25
+ }
26
+ }
27
+ ) : /* @__PURE__ */ jsx("span", { className: "close-icon", children: /* @__PURE__ */ jsx(
28
+ motion.img,
29
+ {
30
+ alt: "Close chat",
31
+ src: "https://www.axos.com/images/7kHGbXlPvoGOC4YL3Ae5cg/axb-x-close.svg",
32
+ initial: { opacity: 0, rotate: 0 },
33
+ animate: {
34
+ opacity: 1,
35
+ rotate: -90,
36
+ transition: {
37
+ default: { type: "spring" },
38
+ opacity: { ease: "linear" }
39
+ }
40
+ }
41
+ }
42
+ ) }) }) }),
43
+ children
44
+ ] });
45
+ };
46
+ export {
47
+ Bubble
48
+ };
@@ -0,0 +1 @@
1
+ export default function Chat(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,165 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { useRef, useEffect } from "react";
4
+ import { authenticate } from "./authenticate.js";
5
+ import { useMessages } from "./store/messages.js";
6
+ const companyId = process.env.CCAI_COMPANY_ID || "";
7
+ const tenant = process.env.CCAI_TENANT_NAME || "";
8
+ const host = process.env.CCAI_HOST || "";
9
+ const COBROWSE_CONSENT_TEMPLATE = `
10
+ <script class="cobrowse-template" type="text/template">
11
+ <div class="cobrowse">
12
+ <div class="cobrowse-title">$title</div>
13
+ <div class="cobrowse-content">$content</div>
14
+ <div class="cobrowse-footer">
15
+ <button class="cobrowse-deny js-cobrowse-deny">$deny</button>
16
+ <button class="cobrowse-allow js-cobrowse-allow">$allow</button>
17
+ </div>
18
+ </div>
19
+ <\/script>
20
+ `;
21
+ function Chat() {
22
+ const clientRef = useRef(null);
23
+ const hasLoadedBefore = useRef(true);
24
+ const addMessages = useMessages((state) => state.addMessages);
25
+ const addMessage = useMessages((state) => state.addMessage);
26
+ const chatRef = useRef(null);
27
+ const isMounted = useRef(true);
28
+ useEffect(() => {
29
+ let messageHandler;
30
+ let identityHandler;
31
+ let chatUpdatedHandler;
32
+ let memberJoinedHandler;
33
+ let chatConnectedHandler;
34
+ async function initChat() {
35
+ const { Client, consoleLoggerHandler, Logger } = await import("@ujet/websdk-headless");
36
+ console.log("this", isMounted);
37
+ Logger.addHandler(consoleLoggerHandler);
38
+ clientRef.current = new Client({
39
+ companyId,
40
+ tenant,
41
+ cobrowse: {
42
+ enabled: true,
43
+ template: COBROWSE_CONSENT_TEMPLATE,
44
+ messages: {
45
+ confirmSessionTitle: "...",
46
+ confirmSessionContent: "...",
47
+ endSessionText: "...",
48
+ confirmRemoteControlTitle: "...",
49
+ confirmRemoteControlContent: "...",
50
+ confirmFullDeviceTitle: "...",
51
+ confirmFullDeviceContent: "...",
52
+ allowText: "...",
53
+ denyText: "..."
54
+ }
55
+ },
56
+ host,
57
+ authenticate
58
+ });
59
+ const menus = await clientRef.current?.getMenus();
60
+ try {
61
+ chatRef.current = await clientRef.current?.loadOngoingChat();
62
+ console.log("chat:", chatRef.current);
63
+ if (!chatRef.current) {
64
+ chatRef.current = await clientRef.current?.createChat(
65
+ menus?.menus[5].id
66
+ );
67
+ }
68
+ } catch (error) {
69
+ console.error("Error creating chat:", error);
70
+ chatRef.current = await clientRef.current?.createChat(
71
+ menus?.menus[5].id
72
+ );
73
+ }
74
+ console.log("this");
75
+ identityHandler = (identity) => {
76
+ if (!isMounted.current) return;
77
+ console.log("identity:", identity);
78
+ };
79
+ messageHandler = (msg) => {
80
+ console.log("new message:", msg);
81
+ console.log("addMessage:", msg);
82
+ addMessage(msg);
83
+ };
84
+ chatUpdatedHandler = (chat) => {
85
+ console.log("chat updated:", chat);
86
+ };
87
+ chatConnectedHandler = async () => {
88
+ console.log("connected");
89
+ const messagesFetched = await clientRef.current?.fetchMessages();
90
+ console.log("[messages]:", messagesFetched);
91
+ addMessages(messagesFetched || []);
92
+ };
93
+ memberJoinedHandler = (identity) => {
94
+ console.log("member joined:", identity);
95
+ };
96
+ console.log(isMounted.current);
97
+ clientRef.current?.on("authenticated", () => {
98
+ console.log("authenticated");
99
+ });
100
+ clientRef.current?.on("chat.ongoing", (chat) => {
101
+ if (!isMounted.current) return;
102
+ console.log("chat:", chat);
103
+ });
104
+ clientRef.current?.on("chat.connected", chatConnectedHandler);
105
+ clientRef.current?.on("chat.updated", chatUpdatedHandler);
106
+ clientRef.current?.on("chat.identity", identityHandler);
107
+ clientRef.current?.on("chat.message", messageHandler);
108
+ clientRef.current?.on("cobrowse.request", ({ from }) => {
109
+ console.log("request by", from);
110
+ });
111
+ clientRef.current?.on("chat.memberJoined", memberJoinedHandler);
112
+ }
113
+ if (hasLoadedBefore.current) {
114
+ console.log("Initial setup");
115
+ initChat();
116
+ hasLoadedBefore.current = false;
117
+ }
118
+ return () => {
119
+ isMounted.current = false;
120
+ console.log("Component unmounted. Cancelling pending async operations.");
121
+ if (clientRef.current) {
122
+ if (messageHandler)
123
+ clientRef.current.off("chat.message", messageHandler);
124
+ if (identityHandler)
125
+ clientRef.current.off("chat.identity", identityHandler);
126
+ clientRef.current.off("chat.connected", chatConnectedHandler);
127
+ clientRef.current.off("chat.updated", chatUpdatedHandler);
128
+ clientRef.current.off("chat.memberJoined", memberJoinedHandler);
129
+ if (typeof clientRef.current.destroyChat === "function") {
130
+ console.log("Destroying chat:", chatRef.current);
131
+ clientRef.current.destroyChat();
132
+ }
133
+ }
134
+ };
135
+ }, [addMessage, addMessages]);
136
+ return /* @__PURE__ */ jsxs("div", { children: [
137
+ /* @__PURE__ */ jsx("h2", { children: "Chat" }),
138
+ /* @__PURE__ */ jsxs(
139
+ "form",
140
+ {
141
+ style: { marginTop: "1rem", display: "flex", gap: "0.5rem" },
142
+ onSubmit: async (e) => {
143
+ e.preventDefault();
144
+ const form = e.target;
145
+ const input = form.elements[0];
146
+ const message = input.value;
147
+ console.log("Sending message:", message);
148
+ try {
149
+ await clientRef.current?.sendTextMessage(message);
150
+ input.value = "";
151
+ } catch (error) {
152
+ console.error("Error sending message:", error);
153
+ }
154
+ },
155
+ children: [
156
+ /* @__PURE__ */ jsx("input", { type: "text", name: "message", placeholder: "Type a message..." }),
157
+ /* @__PURE__ */ jsx("button", { type: "submit", children: "Send" })
158
+ ]
159
+ }
160
+ )
161
+ ] });
162
+ }
163
+ export {
164
+ Chat as default
165
+ };
@@ -0,0 +1,11 @@
1
+ export declare const windowStyle: string;
2
+ export declare const windowOpenStyle: string;
3
+ export declare const windowBarStyle: string;
4
+ export declare const chat_title: string;
5
+ export declare const button_reset: string;
6
+ export declare const inputStyle: string;
7
+ export declare const sendButtonStyle: string;
8
+ export declare const messagesContainerStyle: string;
9
+ export declare const notificationStyle: string;
10
+ export declare const messageStyle: string;
11
+ export declare const inline_button_wrapper: string;
@@ -0,0 +1,25 @@
1
+ import '../assets/Chatbot/ChatWindow.css';/* empty css */
2
+ var windowStyle = "_13n1jqk0";
3
+ var windowOpenStyle = "_13n1jqk1";
4
+ var windowBarStyle = "_13n1jqk2";
5
+ var chat_title = "_13n1jqk3";
6
+ var button_reset = "_13n1jqk4";
7
+ var inputStyle = "_13n1jqk5";
8
+ var sendButtonStyle = "_13n1jqk6";
9
+ var messagesContainerStyle = "_13n1jqk7";
10
+ var notificationStyle = "_13n1jqk8";
11
+ var messageStyle = "_13n1jqk9";
12
+ var inline_button_wrapper = "_13n1jqka";
13
+ export {
14
+ button_reset,
15
+ chat_title,
16
+ inline_button_wrapper,
17
+ inputStyle,
18
+ messageStyle,
19
+ messagesContainerStyle,
20
+ notificationStyle,
21
+ sendButtonStyle,
22
+ windowBarStyle,
23
+ windowOpenStyle,
24
+ windowStyle
25
+ };
@@ -0,0 +1,23 @@
1
+ import { MessageResponse as BaseMessageResponse, HumanAgent } from '@ujet/websdk-headless';
2
+ import { default as React } from 'react';
3
+
4
+ interface MessageResponse extends BaseMessageResponse {
5
+ to_agent?: HumanAgent;
6
+ }
7
+ export interface ChatBubble {
8
+ id: string | number;
9
+ body: string;
10
+ sender?: string;
11
+ timestamp?: string;
12
+ isOwn?: boolean;
13
+ }
14
+ interface ChatWindowProps {
15
+ messages: MessageResponse[];
16
+ status?: string;
17
+ onSend: (msg: string) => void;
18
+ inputDisabled?: boolean;
19
+ onClose?: () => void;
20
+ endChat?: () => void;
21
+ }
22
+ export declare const ChatWindow: React.FC<ChatWindowProps>;
23
+ export {};
@@ -0,0 +1,202 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import React, { useRef, useEffect, Fragment } from "react";
5
+ import ReactMarkdown from "react-markdown";
6
+ import remarkGfm from "remark-gfm";
7
+ import { useOpenChat } from "./store/chat.js";
8
+ import { windowBarStyle, chat_title, button_reset, notificationStyle, messageStyle, inline_button_wrapper, messagesContainerStyle, inputStyle, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
9
+ const ChatWindow = ({
10
+ messages,
11
+ status = "connected",
12
+ onSend,
13
+ inputDisabled = false,
14
+ onClose,
15
+ endChat = () => {
16
+ console.log("End chat");
17
+ }
18
+ }) => {
19
+ const [input, setInput] = React.useState("");
20
+ const messagesEndRef = useRef(null);
21
+ const isOpen = useOpenChat((state) => state.isOpen);
22
+ useEffect(() => {
23
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
24
+ }, [messages]);
25
+ const handleSend = (e) => {
26
+ e.preventDefault();
27
+ if (input.trim()) {
28
+ onSend(input);
29
+ setInput("");
30
+ }
31
+ };
32
+ return /* @__PURE__ */ jsxs("div", { className: clsx(windowStyle, isOpen && windowOpenStyle), children: [
33
+ /* @__PURE__ */ jsxs("div", { className: windowBarStyle, children: [
34
+ /* @__PURE__ */ jsxs("div", { className: "flex middle", style: { paddingBlock: "6px" }, children: [
35
+ /* @__PURE__ */ jsx(
36
+ "img",
37
+ {
38
+ src: "https://www.axos.com/images/2xmVfQm5l0HWOKjgxQO1Iw/axb-assistant.svg",
39
+ style: { marginRight: 12 },
40
+ height: 18,
41
+ width: 18
42
+ }
43
+ ),
44
+ /* @__PURE__ */ jsx("h2", { className: chat_title, children: "Evo Virtual Assistant" })
45
+ ] }),
46
+ onClose && /* @__PURE__ */ jsx(
47
+ "button",
48
+ {
49
+ onClick: onClose,
50
+ className: button_reset,
51
+ "aria-label": "Close chat",
52
+ title: "Close",
53
+ children: /* @__PURE__ */ jsx(
54
+ "img",
55
+ {
56
+ src: "https://www.axos.com/images/fXFpk3tIJEym7OWKNuKBU/axb-down-chevron.svg",
57
+ height: 24,
58
+ width: 24,
59
+ alt: ""
60
+ }
61
+ )
62
+ }
63
+ )
64
+ ] }),
65
+ /* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
66
+ messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment, { children: [
67
+ msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationStarted" && /* @__PURE__ */ jsx("div", { className: notificationStyle, children: "We are connecting you with a human agent..." }, msg.$index),
68
+ msg.type == "noti" && msg.$userType == "system" && msg.event == "memberLeft" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
69
+ /* @__PURE__ */ jsx("strong", { children: "Virtual Agent" }),
70
+ " just left the conversation."
71
+ ] }, msg.$index),
72
+ msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationAccepted" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
73
+ "You are now connected with a",
74
+ " ",
75
+ msg.to_agent ? /* @__PURE__ */ jsx("strong", { children: msg?.to_agent?.name }) : "an agent"
76
+ ] }, msg.$index),
77
+ ["text", "markdown_template", "markdown"].includes(msg.type) && /* @__PURE__ */ jsxs(
78
+ "div",
79
+ {
80
+ className: messageStyle,
81
+ style: {
82
+ textAlign: msg.$userType == "end_user" ? "right" : "left",
83
+ alignSelf: msg.$userType == "end_user" ? "flex-end" : "flex-start",
84
+ background: msg.$userType == "end_user" ? "#14263d" : "#E9F8FF",
85
+ color: msg.$userType == "end_user" ? "#fff" : "#1F1F1F",
86
+ boxShadow: msg.$userType == "end_user" ? "0 1px 4px #b3e0ff55" : void 0
87
+ },
88
+ children: [
89
+ /* @__PURE__ */ jsx(
90
+ "div",
91
+ {
92
+ style: {
93
+ fontSize: 13,
94
+ display: "flex",
95
+ flexDirection: "column",
96
+ gap: 4
97
+ },
98
+ children: /* @__PURE__ */ jsx(
99
+ ReactMarkdown,
100
+ {
101
+ remarkPlugins: [[remarkGfm, { singleTilde: false }]],
102
+ components: {
103
+ p: ({ ...props }) => /* @__PURE__ */ jsx("p", { style: { margin: 0 }, ...props })
104
+ },
105
+ children: msg.content
106
+ }
107
+ )
108
+ }
109
+ ),
110
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 10, color: "#888", marginTop: 2 } })
111
+ ]
112
+ },
113
+ msg.$index
114
+ ),
115
+ msg.type == "inline_button" && Array.isArray(msg.buttons) && msg.buttons.length > 0 && /* @__PURE__ */ jsx("div", { className: inline_button_wrapper, children: msg.buttons.length !== 0 && Array.isArray(msg.buttons) && msg.buttons.map((button, index) => {
116
+ const lastItem = msg.buttons && msg.buttons?.length - 1;
117
+ return /* @__PURE__ */ jsx(
118
+ "button",
119
+ {
120
+ style: {
121
+ fontSize: 12,
122
+ textAlign: "left",
123
+ background: "#fff",
124
+ color: "#1e3860",
125
+ borderRadius: "0px",
126
+ borderTopLeftRadius: [0].includes(index) ? 8 : 0,
127
+ borderTopRightRadius: [0].includes(index) ? 8 : 0,
128
+ borderBottomLeftRadius: [lastItem].includes(index) ? 8 : 0,
129
+ borderBottomRightRadius: [lastItem].includes(index) ? 8 : 0
130
+ },
131
+ onClick: () => {
132
+ onSend(button?.title);
133
+ },
134
+ children: button.title
135
+ },
136
+ index
137
+ );
138
+ }) }),
139
+ msg.event == "chatEnded" && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
140
+ "button",
141
+ {
142
+ style: {
143
+ fontSize: 12,
144
+ textAlign: "center"
145
+ },
146
+ onClick: endChat,
147
+ children: "End Chat"
148
+ }
149
+ ) })
150
+ ] }, msg.$index)),
151
+ /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
152
+ ] }),
153
+ /* @__PURE__ */ jsxs(
154
+ "form",
155
+ {
156
+ onSubmit: handleSend,
157
+ style: {
158
+ borderTop: "1px solid #eee",
159
+ display: "flex",
160
+ gap: 8
161
+ },
162
+ children: [
163
+ /* @__PURE__ */ jsx(
164
+ "input",
165
+ {
166
+ type: "text",
167
+ value: input,
168
+ onChange: (e) => setInput(e.target.value),
169
+ placeholder: "Ask something...",
170
+ className: inputStyle,
171
+ disabled: inputDisabled || status !== "connected"
172
+ }
173
+ ),
174
+ /* @__PURE__ */ jsx(
175
+ "button",
176
+ {
177
+ className: clsx(sendButtonStyle, input.trim().length > 0 && "active"),
178
+ type: "submit",
179
+ disabled: inputDisabled || status !== "connected" || !input.trim(),
180
+ children: /* @__PURE__ */ jsxs(
181
+ "svg",
182
+ {
183
+ xmlns: "http://www.w3.org/2000/svg",
184
+ id: "send-icon",
185
+ width: 24,
186
+ height: 24,
187
+ children: [
188
+ /* @__PURE__ */ jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }),
189
+ /* @__PURE__ */ jsx("path", { d: "M0 0h24v24H0z", fill: "none" })
190
+ ]
191
+ }
192
+ )
193
+ }
194
+ )
195
+ ]
196
+ }
197
+ )
198
+ ] });
199
+ };
200
+ export {
201
+ ChatWindow
202
+ };
@@ -0,0 +1 @@
1
+ export declare const chatbotWrapper: string;
@@ -0,0 +1,5 @@
1
+ import "./Chatbot.css.ts.vanilla.css.js";
2
+ var chatbotWrapper = "_1hpv6vm0";
3
+ export {
4
+ chatbotWrapper
5
+ };
@@ -0,0 +1 @@
1
+ export declare const Chatbot: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { authenticate } from "./authenticate.js";
4
+ import { Bubble } from "./Bubble.js";
5
+ import { ChatWindow } from "./ChatWindow.js";
6
+ import { useOpenChat } from "./store/chat.js";
7
+ import { useMessages } from "./store/messages.js";
8
+ import { useHeadlessChat } from "./useHeadlessChat.js";
9
+ const Chatbot = () => {
10
+ const messages = useMessages((state) => state.messages);
11
+ const close = useOpenChat((state) => state.close);
12
+ const { status, sendMessage } = useHeadlessChat({
13
+ companyId: process.env.CCAI_COMPANY_ID || "",
14
+ tenant: process.env.CCAI_TENANT_NAME || "",
15
+ host: process.env.CCAI_HOST || "",
16
+ // or your region
17
+ projectId: process.env.CCAI_PROJECT_ID || "axos",
18
+ // replace with your project id
19
+ getToken: authenticate,
20
+ debug: process.env.NODE_ENV === "development"
21
+ });
22
+ return /* @__PURE__ */ jsxs("div", { children: [
23
+ /* @__PURE__ */ jsx(Bubble, {}),
24
+ /* @__PURE__ */ jsx(
25
+ ChatWindow,
26
+ {
27
+ status,
28
+ onClose: close,
29
+ messages,
30
+ onSend: function(msg) {
31
+ sendMessage(msg);
32
+ }
33
+ }
34
+ )
35
+ ] });
36
+ };
37
+ export {
38
+ Chatbot
39
+ };
@@ -0,0 +1,3 @@
1
+ export declare const authenticate: () => Promise<{
2
+ token: any;
3
+ }>;
@@ -0,0 +1,16 @@
1
+ const AUTH_URL = process.env.AUTH_CHAT_URL || "http://localhost:3000/api/auth/token";
2
+ const authenticate = async () => {
3
+ const res = await fetch(AUTH_URL, {
4
+ method: "GET",
5
+ headers: {
6
+ "Content-Type": "application/json"
7
+ }
8
+ });
9
+ const data = await res.json();
10
+ return {
11
+ token: data.token
12
+ };
13
+ };
14
+ export {
15
+ authenticate
16
+ };
@@ -0,0 +1,9 @@
1
+ export * from './Bubble';
2
+ export * from './Bubble.css';
3
+ export * from './Chatbot';
4
+ export * from './Chatbot.css';
5
+ export * from './ChatWindow';
6
+ export * from './ChatWindow.css';
7
+ export * from './store/chat';
8
+ export * from './store/messages';
9
+ export * from './useHeadlessChat';