@axos-web-dev/shared-components 1.0.100-chat.1 → 1.0.100-dev.10

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 (33) hide show
  1. package/dist/Calculators/BuyDownCalculator/index.d.ts +1 -0
  2. package/dist/Calculators/BuyDownCalculator/index.js +162 -76
  3. package/dist/Chatbot/ChatWindow.css.d.ts +2 -0
  4. package/dist/Chatbot/ChatWindow.css.js +4 -0
  5. package/dist/Chatbot/ChatWindow.js +117 -50
  6. package/dist/Chatbot/index.js +3 -1
  7. package/dist/Chatbot/useHeadlessChat.d.ts +2 -1
  8. package/dist/Chatbot/useHeadlessChat.js +27 -9
  9. package/dist/Comparison/ComparisonSet.js +33 -24
  10. package/dist/Forms/CommercialDepositsNoLendingOption.d.ts +16 -0
  11. package/dist/Forms/CommercialDepositsNoLendingOption.js +330 -0
  12. package/dist/Forms/ContactUsLVF.d.ts +5 -1
  13. package/dist/Forms/ContactUsLVF.js +8 -6
  14. package/dist/Forms/FormEnums.js +6 -15
  15. package/dist/Forms/QuickPricer/QuickPricerForm.js +1 -1
  16. package/dist/Forms/SalesforceFieldsForm.d.ts +5 -0
  17. package/dist/Forms/SalesforceFieldsForm.js +11 -1
  18. package/dist/Forms/index.d.ts +1 -0
  19. package/dist/Forms/index.js +2 -0
  20. package/dist/Input/Dropdown.js +1 -0
  21. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.d.ts +1 -0
  22. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +3 -0
  23. package/dist/NavigationMenu/AxosBank/SubNavBar.js +21 -0
  24. package/dist/StepItemSet/StepItemSet.css.d.ts +1 -0
  25. package/dist/StepItemSet/StepItemSet.css.js +9 -5
  26. package/dist/StepItemSet/StepItemSet.d.ts +6 -0
  27. package/dist/StepItemSet/StepItemSet.js +22 -3
  28. package/dist/StepItemSet/index.js +2 -1
  29. package/dist/assets/Chatbot/ChatWindow.css +17 -0
  30. package/dist/assets/Comparison/Comparison.css +3 -1
  31. package/dist/assets/StepItemSet/StepItemSet.css +27 -10
  32. package/dist/main.js +7 -2
  33. package/package.json +1 -1
@@ -11,6 +11,7 @@ export type BuyDownCalculatorInputs = {
11
11
  purchasePrice: number;
12
12
  downpayment: number;
13
13
  dealerContribution: number;
14
+ manufacturerContributionAmount: number;
14
15
  program: string;
15
16
  fico: string;
16
17
  buydownRate: number;
@@ -3,7 +3,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
3
3
  import { zodResolver } from "@hookform/resolvers/zod";
4
4
  import { Button } from "../../Button/Button.js";
5
5
  import "../../Button/Button.css.js";
6
- import { useState } from "react";
6
+ import { useState, useEffect } from "react";
7
7
  import "react-use";
8
8
  import { Program, Fico, BuydownRate, BuydownTerm, LoanRates } from "../../Forms/FormEnums.js";
9
9
  import { Checkbox } from "../../Input/Checkbox.js";
@@ -39,7 +39,6 @@ const BuyDownCalculator = ({
39
39
  const [finalNoteRate, setFinalNoteRate] = useState("");
40
40
  const [manuContributionPercentage, setManuContributionPercentage] = useState("");
41
41
  const [buydownPayment, setBuydownPayment] = useState("");
42
- const [manuContributionAmount, setManuContributionAmount] = useState("");
43
42
  const [nonBuydownPayment, setNonBuydownPayment] = useState("");
44
43
  const [totalBuydownCost, setTotalBuydownCost] = useState("");
45
44
  const [monthlySavings, setMonthlySavings] = useState("");
@@ -47,6 +46,11 @@ const BuyDownCalculator = ({
47
46
  const [enableFullTimeCharter, setEnableFullTimeCharter] = useState(false);
48
47
  const [disableMooringOutside, setDisableMooringOutside] = useState(false);
49
48
  const [disableLTVAbove60, setDisableLTVAbove60] = useState(true);
49
+ const [isDealerContributionDisabled, setIsDealerContributionDisabled] = useState(false);
50
+ const [
51
+ isManufacturerContributionDisabled,
52
+ setIsManufacturerContributionDisabled
53
+ ] = useState(false);
50
54
  const schema = z.object({
51
55
  purchasePrice: z.string().min(1, { message: "Loan amount is required." }).transform((val) => {
52
56
  return formatToNumber(val);
@@ -54,8 +58,13 @@ const BuyDownCalculator = ({
54
58
  downpayment: z.string().min(1, { message: "Down Payment is required." }).transform((val) => {
55
59
  return formatToNumber(val);
56
60
  }),
57
- dealerContribution: z.string().min(1, { message: "Dealer Contribution is required." }).transform((val) => {
58
- return formatToNumber(val);
61
+ dealerContribution: z.union([z.string(), z.number()]).optional().transform((val) => {
62
+ if (typeof val === "number") return val;
63
+ return val ? formatToNumber(val) : 0;
64
+ }),
65
+ manufacturerContributionAmount: z.union([z.string(), z.number()]).optional().transform((val) => {
66
+ if (typeof val === "number") return val;
67
+ return val ? formatToNumber(val) : 0;
59
68
  }),
60
69
  program: z.string().min(1, { message: "Program is required." }),
61
70
  fico: z.string().min(1, { message: "FICO is required." }),
@@ -66,7 +75,32 @@ const BuyDownCalculator = ({
66
75
  return formatToNumber(val);
67
76
  })
68
77
  }).superRefine((values, ctx) => {
69
- const { purchasePrice, downpayment, program, buydownTerm } = values;
78
+ const {
79
+ purchasePrice,
80
+ downpayment,
81
+ program,
82
+ buydownTerm,
83
+ dealerContribution,
84
+ manufacturerContributionAmount
85
+ } = values;
86
+ if (dealerContribution > 0 && manufacturerContributionAmount > 0) {
87
+ ctx.addIssue({
88
+ code: z.ZodIssueCode.custom,
89
+ path: ["dealerContribution"],
90
+ message: "Cannot specify both Dealer Contribution and Manufacturer Contribution Amount. Please choose one."
91
+ });
92
+ ctx.addIssue({
93
+ code: z.ZodIssueCode.custom,
94
+ path: ["manufacturerContributionAmount"],
95
+ message: "Cannot specify both Dealer Contribution and Manufacturer Contribution Amount. Please choose one."
96
+ });
97
+ } else if (dealerContribution === 0 && manufacturerContributionAmount === 0) {
98
+ ctx.addIssue({
99
+ code: z.ZodIssueCode.custom,
100
+ path: ["dealerContribution"],
101
+ message: "Either Dealer Contribution or Manufacturer Contribution Amount is required."
102
+ });
103
+ }
70
104
  if (program === "3/6 SOFR ARM" && (buydownTerm === 4 || buydownTerm === 5)) {
71
105
  ctx.addIssue({
72
106
  code: z.ZodIssueCode.custom,
@@ -114,8 +148,23 @@ const BuyDownCalculator = ({
114
148
  handleSubmit,
115
149
  register,
116
150
  setValue,
151
+ watch,
152
+ trigger,
117
153
  formState: { errors, isValid }
118
154
  } = methods;
155
+ const watchedFields = watch(["purchasePrice", "downpayment", "program"]);
156
+ useEffect(() => {
157
+ const [purchasePrice, downpayment, program] = watchedFields;
158
+ if (purchasePrice && downpayment && program) {
159
+ const purchasePriceNum = typeof purchasePrice === "string" ? formatToNumber(purchasePrice) : purchasePrice;
160
+ const downpaymentNum = typeof downpayment === "string" ? formatToNumber(downpayment) : downpayment;
161
+ if (purchasePriceNum > 0 && downpaymentNum >= 0 && purchasePriceNum > downpaymentNum) {
162
+ const financedAmount2 = purchasePriceNum - downpaymentNum;
163
+ const loanRange2 = getRange(financedAmount2, program);
164
+ setLoanRange(loanRange2);
165
+ }
166
+ }
167
+ }, [watchedFields]);
119
168
  const calculator_variant = getVariant(variant);
120
169
  const enableDependentInputs = enableFullTimeCharter;
121
170
  const formatToNumber = (value) => {
@@ -224,6 +273,32 @@ const BuyDownCalculator = ({
224
273
  setDisableMooringOutside(true);
225
274
  }
226
275
  };
276
+ const handleDealerContributionChange = (event) => {
277
+ const value = event.target.value;
278
+ const numericValue = formatToNumber(value);
279
+ if (numericValue > 0) {
280
+ setIsManufacturerContributionDisabled(true);
281
+ setValue("manufacturerContributionAmount", 0);
282
+ } else {
283
+ setIsManufacturerContributionDisabled(false);
284
+ }
285
+ setTimeout(() => {
286
+ trigger(["dealerContribution", "manufacturerContributionAmount"]);
287
+ }, 0);
288
+ };
289
+ const handleManufacturerContributionChange = (event) => {
290
+ const value = event.target.value;
291
+ const numericValue = formatToNumber(value);
292
+ if (numericValue > 0) {
293
+ setIsDealerContributionDisabled(true);
294
+ setValue("dealerContribution", 0);
295
+ } else {
296
+ setIsDealerContributionDisabled(false);
297
+ }
298
+ setTimeout(() => {
299
+ trigger(["dealerContribution", "manufacturerContributionAmount"]);
300
+ }, 0);
301
+ };
227
302
  const updateFicoRequirements = (loanRangeValue, program) => {
228
303
  const ficoOptionsToDisable = ["700-719", "720-759"];
229
304
  const ficoSelect = document.getElementById("fico");
@@ -383,17 +458,17 @@ const BuyDownCalculator = ({
383
458
  setTotalBuydownCost(formatToCurrency(TBC));
384
459
  return TBC;
385
460
  };
386
- const calculateManufacturerContribution = (dealerContribution) => {
387
- const manufacturerContribution = 100 - dealerContribution;
461
+ const calculateManufacturerContribution = (dealerContribution, manufacturerContributionAmount, totalBuydownCost2) => {
462
+ let manufacturerContribution;
463
+ if (manufacturerContributionAmount > 0) {
464
+ manufacturerContribution = manufacturerContributionAmount / totalBuydownCost2 * 100;
465
+ } else {
466
+ manufacturerContribution = 100 - dealerContribution;
467
+ }
388
468
  const percentage = formatToPercentage(manufacturerContribution);
389
469
  setManuContributionPercentage(percentage);
390
470
  return manufacturerContribution;
391
471
  };
392
- const calculateManufacturerAmount = (totalBuydownCost2, manufacturerContribution) => {
393
- const manufacturerAmount = totalBuydownCost2 * (manufacturerContribution / 100);
394
- const formattedAmount = formatToCurrency(manufacturerAmount);
395
- setManuContributionAmount(formattedAmount);
396
- };
397
472
  const calculateDealerContributionAmount = (dealerContribution, totalBuydownCost2) => {
398
473
  const dealerContributionValue = totalBuydownCost2 * (dealerContribution / 100);
399
474
  const formattedAmount = formatToCurrency(dealerContributionValue);
@@ -405,6 +480,7 @@ const BuyDownCalculator = ({
405
480
  buydownRate,
406
481
  buydownTerm,
407
482
  dealerContribution,
483
+ manufacturerContributionAmount,
408
484
  downpayment,
409
485
  fico,
410
486
  program,
@@ -436,8 +512,11 @@ const BuyDownCalculator = ({
436
512
  financedAmountValue,
437
513
  buydownTerm
438
514
  );
439
- const manufacturerContribution = calculateManufacturerContribution(dealerContribution);
440
- calculateManufacturerAmount(totalBuydownCost2, manufacturerContribution);
515
+ calculateManufacturerContribution(
516
+ dealerContribution,
517
+ manufacturerContributionAmount,
518
+ totalBuydownCost2
519
+ );
441
520
  calculateDealerContributionAmount(dealerContribution, totalBuydownCost2);
442
521
  }
443
522
  };
@@ -495,16 +574,40 @@ const BuyDownCalculator = ({
495
574
  PercentageInput,
496
575
  {
497
576
  id: "dealerContribution",
498
- ...register("dealerContribution", { required: true }),
577
+ ...register("dealerContribution", {
578
+ required: false,
579
+ onChange: handleDealerContributionChange
580
+ }),
499
581
  sizes: "medium",
500
582
  placeholder: "0.00%",
501
583
  label: "Dealer Contribution",
502
- required: true,
584
+ required: false,
503
585
  error: !!errors["dealerContribution"],
504
586
  helperText: errors["dealerContribution"]?.message,
505
- variant: calculator_variant
587
+ variant: calculator_variant,
588
+ disabled: isDealerContributionDisabled
506
589
  }
507
590
  ) }),
591
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
592
+ CurrencyInput,
593
+ {
594
+ id: "manufacturerContributionAmount",
595
+ ...register("manufacturerContributionAmount", {
596
+ required: false,
597
+ onChange: handleManufacturerContributionChange
598
+ }),
599
+ sizes: "medium",
600
+ placeholder: "$0.00",
601
+ label: "Manufacturer Contribution Amount",
602
+ required: false,
603
+ error: !!errors["manufacturerContributionAmount"],
604
+ helperText: errors["manufacturerContributionAmount"]?.message,
605
+ variant: calculator_variant,
606
+ disabled: isManufacturerContributionDisabled
607
+ }
608
+ ) })
609
+ ] }),
610
+ /* @__PURE__ */ jsxs("div", { className: `${row_form}`, children: [
508
611
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
509
612
  Dropdown,
510
613
  {
@@ -526,9 +629,7 @@ const BuyDownCalculator = ({
526
629
  Program.map((item) => /* @__PURE__ */ jsx("option", { value: item.value, children: item.text }, item.value))
527
630
  ]
528
631
  }
529
- ) })
530
- ] }),
531
- /* @__PURE__ */ jsxs("div", { className: `${row_form}`, children: [
632
+ ) }),
532
633
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
533
634
  Dropdown,
534
635
  {
@@ -546,7 +647,9 @@ const BuyDownCalculator = ({
546
647
  Fico.map((item) => /* @__PURE__ */ jsx("option", { value: item.value, children: item.text }, item.value))
547
648
  ]
548
649
  }
549
- ) }),
650
+ ) })
651
+ ] }),
652
+ /* @__PURE__ */ jsxs("div", { className: `${row_form}`, children: [
550
653
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
551
654
  Input,
552
655
  {
@@ -558,10 +661,8 @@ const BuyDownCalculator = ({
558
661
  variant: calculator_variant,
559
662
  value: loanRange
560
663
  }
561
- ) })
562
- ] }),
563
- /* @__PURE__ */ jsxs("div", { className: `${row_form}`, children: [
564
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
664
+ ) }),
665
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
565
666
  Dropdown,
566
667
  {
567
668
  id: "buydownRate",
@@ -574,35 +675,31 @@ const BuyDownCalculator = ({
574
675
  error: !!errors.buydownRate,
575
676
  helperText: errors.buydownRate?.message,
576
677
  variant: calculator_variant,
577
- defaultValue: "",
578
- children: [
579
- /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select Buydown Rate" }),
580
- BuydownRate.map((item) => /* @__PURE__ */ jsx("option", { value: item.value, children: item.text }, item.value))
581
- ]
582
- }
583
- ) }),
584
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
585
- Dropdown,
586
- {
587
- id: "buydownTerm",
588
- ...register("buydownTerm", {
589
- required: true,
590
- deps: ["program"]
591
- }),
592
- label: "Buydown Term (1-5 Years)",
593
- sizes: "medium",
594
- required: true,
595
- error: !!errors.buydownTerm,
596
- helperText: errors.buydownTerm?.message,
597
- variant: calculator_variant,
598
- defaultValue: 0,
599
- children: [
600
- /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select Buydown Term" }),
601
- BuydownTerm.map((item) => /* @__PURE__ */ jsx("option", { value: item.value, children: item.text }, item.value))
602
- ]
678
+ disabled: true,
679
+ defaultValue: 3.74,
680
+ children: BuydownRate.map((item) => /* @__PURE__ */ jsx("option", { value: item.value, children: item.text }, item.value))
603
681
  }
604
682
  ) })
605
683
  ] }),
684
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
685
+ Dropdown,
686
+ {
687
+ id: "buydownTerm",
688
+ ...register("buydownTerm", {
689
+ required: true,
690
+ deps: ["program"]
691
+ }),
692
+ label: "Buydown Term (1-5 Years)",
693
+ sizes: "medium",
694
+ required: true,
695
+ error: !!errors.buydownTerm,
696
+ helperText: errors.buydownTerm?.message,
697
+ variant: calculator_variant,
698
+ disabled: true,
699
+ defaultValue: 3,
700
+ children: BuydownTerm.map((item) => /* @__PURE__ */ jsx("option", { value: item.value, children: item.text }, item.value))
701
+ }
702
+ ) }) }),
606
703
  /* @__PURE__ */ jsx("div", { className: `${row_form}`, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("label", { children: "Loan Level Rate Adjustments" }) }) }),
607
704
  /* @__PURE__ */ jsxs("div", { className: `${row_form}`, children: [
608
705
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: row_form, children: /* @__PURE__ */ jsxs(
@@ -788,23 +885,23 @@ const BuyDownCalculator = ({
788
885
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
789
886
  CurrencyInput,
790
887
  {
791
- id: "manuContributionAmount",
888
+ id: "nonBuydownPayment",
792
889
  sizes: "medium",
793
- label: "Manufacturer Contribution Amount",
890
+ label: "Non-buydown Payment",
794
891
  disabled: true,
795
892
  variant: calculator_variant,
796
- value: manuContributionAmount
893
+ value: nonBuydownPayment
797
894
  }
798
895
  ) }),
799
896
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
800
897
  CurrencyInput,
801
898
  {
802
- id: "nonBuydownPayment",
899
+ id: "totalBuydownCost",
803
900
  sizes: "medium",
804
- label: "Non-buydown Payment",
901
+ label: "Total Buydown Cost",
805
902
  disabled: true,
806
903
  variant: calculator_variant,
807
- value: nonBuydownPayment
904
+ value: totalBuydownCost
808
905
  }
809
906
  ) })
810
907
  ] }),
@@ -812,38 +909,27 @@ const BuyDownCalculator = ({
812
909
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
813
910
  CurrencyInput,
814
911
  {
815
- id: "totalBuydownCost",
912
+ id: "monthlySavings",
816
913
  sizes: "medium",
817
- label: "Total Buydown Cost",
914
+ label: "Monthly Savings",
818
915
  disabled: true,
819
916
  variant: calculator_variant,
820
- value: totalBuydownCost
917
+ value: monthlySavings
821
918
  }
822
919
  ) }),
823
920
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
824
921
  CurrencyInput,
825
922
  {
826
- id: "monthlySavings",
923
+ id: "dealerContributionAmount",
827
924
  sizes: "medium",
828
- label: "Monthly Savings",
925
+ label: "Dealer Contribution Amount",
829
926
  disabled: true,
830
927
  variant: calculator_variant,
831
- value: monthlySavings
928
+ value: dealerContributionAmount,
929
+ helperText: "Dealer reserve offset not included in this amount."
832
930
  }
833
931
  ) })
834
- ] }),
835
- /* @__PURE__ */ jsx("div", { className: `${row_form}`, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
836
- CurrencyInput,
837
- {
838
- id: "dealerContributionAmount",
839
- sizes: "medium",
840
- label: "Dealer Contribution Amount",
841
- disabled: true,
842
- variant: calculator_variant,
843
- value: dealerContributionAmount,
844
- helperText: "Dealer reserve offset not included in this amount."
845
- }
846
- ) }) })
932
+ ] })
847
933
  ]
848
934
  }
849
935
  ) }),
@@ -14,3 +14,5 @@ export declare const inline_button: string;
14
14
  export declare const endChatButtonStyle: string;
15
15
  export declare const chatbotMenu: string;
16
16
  export declare const chatbotMenuItem: string;
17
+ export declare const chatNetworkStatus: string;
18
+ export declare const chatFinishDialog: string;
@@ -15,9 +15,13 @@ var inline_button = "_13n1jqkc";
15
15
  var endChatButtonStyle = "_13n1jqkd";
16
16
  var chatbotMenu = "_13n1jqke";
17
17
  var chatbotMenuItem = "_13n1jqkf";
18
+ var chatNetworkStatus = "_13n1jqkg";
19
+ var chatFinishDialog = "_13n1jqkh";
18
20
  export {
19
21
  arrowFill,
20
22
  button_reset,
23
+ chatFinishDialog,
24
+ chatNetworkStatus,
21
25
  chat_title,
22
26
  chatbotMenu,
23
27
  chatbotMenuItem,
@@ -1,11 +1,11 @@
1
1
  "use client";
2
- import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
- import React, { useRef, useEffect, Fragment } from "react";
4
+ import React, { useRef, useEffect, Fragment as Fragment$1 } from "react";
5
5
  import ReactMarkdown from "react-markdown";
6
6
  import { useNetworkState, useMount } from "react-use";
7
7
  import remarkGfm from "remark-gfm";
8
- import { windowBarStyle, chat_title, chatbotMenuItem, chatbotMenu, button_reset, arrowFill, notificationStyle, messageStyle, inline_button_wrapper, inline_button, endChatButtonStyle, messagesContainerStyle, inputStyle, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
8
+ import { windowBarStyle, chat_title, chatbotMenuItem, chatbotMenu, chatFinishDialog, endChatButtonStyle, button_reset, arrowFill, chatNetworkStatus, notificationStyle, messageStyle, inline_button_wrapper, inline_button, messagesContainerStyle, inputStyle, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
9
9
  import { EllipsisIcon } from "./EllipsisIcon.js";
10
10
  import { useOpenChat } from "./store/chat.js";
11
11
  const ChatWindow = ({
@@ -88,46 +88,75 @@ const ChatWindow = ({
88
88
  children: "Finish chat"
89
89
  }
90
90
  ) }) }),
91
- showEndChatDialog && /* @__PURE__ */ jsx(
92
- "dialog",
93
- {
94
- open: showEndChatDialog,
95
- style: {
96
- padding: "1rem",
97
- borderRadius: 8,
98
- background: "#fff",
99
- color: "#000",
100
- border: "none",
101
- outline: "none",
102
- maxWidth: "90%",
103
- top: "25%"
104
- },
105
- children: /* @__PURE__ */ jsxs("form", { method: "dialog", children: [
106
- /* @__PURE__ */ jsx("p", { children: "are you sure you want to end this chat?" }),
107
- /* @__PURE__ */ jsx(
108
- "button",
109
- {
110
- type: "submit",
111
- onClick: () => {
112
- endChat();
113
- setShowEndChatDialog(false);
114
- },
115
- children: "Yes"
116
- }
117
- ),
118
- /* @__PURE__ */ jsx(
119
- "button",
120
- {
121
- type: "button",
122
- onClick: () => {
123
- setShowEndChatDialog(false);
124
- },
125
- children: "No"
126
- }
127
- )
128
- ] })
129
- }
130
- ),
91
+ showEndChatDialog && /* @__PURE__ */ jsxs(Fragment, { children: [
92
+ /* @__PURE__ */ jsx(
93
+ "div",
94
+ {
95
+ style: {
96
+ background: "#00000080",
97
+ position: "fixed",
98
+ top: 0,
99
+ left: 0,
100
+ right: 0,
101
+ bottom: 0,
102
+ zIndex: 999,
103
+ opacity: 0.75
104
+ }
105
+ }
106
+ ),
107
+ /* @__PURE__ */ jsx(
108
+ "dialog",
109
+ {
110
+ open: showEndChatDialog,
111
+ style: {
112
+ padding: "1rem",
113
+ borderRadius: 8,
114
+ background: "#fff",
115
+ color: "#000",
116
+ border: `1px solid ${endUserBg}`,
117
+ outline: "none",
118
+ maxWidth: "90%",
119
+ top: "25%",
120
+ marginInline: "auto",
121
+ zIndex: 1e3
122
+ },
123
+ children: /* @__PURE__ */ jsxs("form", { method: "dialog", className: chatFinishDialog, children: [
124
+ /* @__PURE__ */ jsx("p", { children: "Are you sure you want to end this chat?" }),
125
+ /* @__PURE__ */ jsxs(
126
+ "div",
127
+ {
128
+ style: { display: "flex", gap: "1rem", marginTop: "1rem" },
129
+ children: [
130
+ /* @__PURE__ */ jsx(
131
+ "button",
132
+ {
133
+ className: endChatButtonStyle,
134
+ type: "submit",
135
+ onClick: () => {
136
+ endChat();
137
+ setShowEndChatDialog(false);
138
+ },
139
+ children: "Yes"
140
+ }
141
+ ),
142
+ /* @__PURE__ */ jsx(
143
+ "button",
144
+ {
145
+ className: endChatButtonStyle,
146
+ type: "button",
147
+ onClick: () => {
148
+ setShowEndChatDialog(false);
149
+ },
150
+ children: "No"
151
+ }
152
+ )
153
+ ]
154
+ }
155
+ )
156
+ ] })
157
+ }
158
+ )
159
+ ] }),
131
160
  onClose && /* @__PURE__ */ jsx(
132
161
  "button",
133
162
  {
@@ -156,13 +185,31 @@ const ChatWindow = ({
156
185
  }
157
186
  )
158
187
  ] }),
159
- /* @__PURE__ */ jsxs("div", { children: [
160
- " ",
161
- mounted && !state.online ? "Offline" : null,
162
- " "
163
- ] }),
188
+ mounted && !state.online ? /* @__PURE__ */ jsx("div", { className: clsx(chatNetworkStatus), children: /* @__PURE__ */ jsxs(
189
+ "div",
190
+ {
191
+ style: {
192
+ color: "#d32f2f",
193
+ textAlign: "center",
194
+ padding: "8px 0",
195
+ fontWeight: 500
196
+ },
197
+ children: [
198
+ /* @__PURE__ */ jsx(
199
+ "span",
200
+ {
201
+ role: "img",
202
+ "aria-label": "disconnected",
203
+ style: { marginRight: 6 },
204
+ children: "⚠️"
205
+ }
206
+ ),
207
+ "You are currently disconnected. Please check your connection."
208
+ ]
209
+ }
210
+ ) }) : null,
164
211
  /* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
165
- messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment, { children: [
212
+ messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
166
213
  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),
167
214
  msg.type == "noti" && msg.$userType == "system" && msg.event == "memberLeft" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
168
215
  /* @__PURE__ */ jsx("strong", { children: "Virtual Agent" }),
@@ -264,7 +311,26 @@ const ChatWindow = ({
264
311
  index
265
312
  );
266
313
  }) }),
267
- msg.event == "chatEnded" && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: endChat, children: "End Chat" }) })
314
+ msg.event == "chatEnded" && /* @__PURE__ */ jsxs(Fragment, { children: [
315
+ /* @__PURE__ */ jsxs(
316
+ "div",
317
+ {
318
+ title: (/* @__PURE__ */ new Date()).toLocaleString(),
319
+ style: {
320
+ fontSize: 12,
321
+ color: "#888",
322
+ marginBottom: 4,
323
+ textAlign: "center"
324
+ },
325
+ children: [
326
+ "Thank you for chatting!",
327
+ /* @__PURE__ */ jsx("br", {}),
328
+ " This conversation has ended."
329
+ ]
330
+ }
331
+ ),
332
+ /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginBottom: 12 }, children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: endChat, children: "End Chat" }) })
333
+ ] })
268
334
  ] }, msg.$index)),
269
335
  showReconnect && /* @__PURE__ */ jsx(
270
336
  "button",
@@ -295,6 +361,7 @@ const ChatWindow = ({
295
361
  onChange: (e) => setInput(e.target.value),
296
362
  placeholder: "Ask something...",
297
363
  className: inputStyle,
364
+ autoFocus: true,
298
365
  disabled: inputDisabled || status !== "connected"
299
366
  }
300
367
  ),
@@ -4,7 +4,7 @@ import { bubbleWrapper, svgFill } from "./Bubble.css.js";
4
4
  import { Chatbot } from "./Chatbot.js";
5
5
  import { chatbotAXB, chatbotUFB } from "./Chatbot.css.js";
6
6
  import { ChatWindow } from "./ChatWindow.js";
7
- import { arrowFill, button_reset, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./ChatWindow.css.js";
7
+ import { arrowFill, button_reset, chatFinishDialog, chatNetworkStatus, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./ChatWindow.css.js";
8
8
  import { useOpenChat } from "./store/chat.js";
9
9
  import { useMessages } from "./store/messages.js";
10
10
  import { useHeadlessChat } from "./useHeadlessChat.js";
@@ -15,6 +15,8 @@ export {
15
15
  arrowFill,
16
16
  bubbleWrapper,
17
17
  button_reset,
18
+ chatFinishDialog,
19
+ chatNetworkStatus,
18
20
  chat_title,
19
21
  chatbotAXB,
20
22
  chatbotMenu,
@@ -8,6 +8,7 @@ interface UseHeadlessChatOptions {
8
8
  channelId?: string;
9
9
  projectId?: "axos" | "" | "ufb" | string;
10
10
  debug?: boolean;
11
+ menuOption?: string;
11
12
  }
12
13
  export interface ChatMessage {
13
14
  id: string;
@@ -15,7 +16,7 @@ export interface ChatMessage {
15
16
  sender?: string;
16
17
  timestamp?: string;
17
18
  }
18
- export declare function useHeadlessChat({ companyId, tenant, host, getToken, projectId, debug, }: UseHeadlessChatOptions): {
19
+ export declare function useHeadlessChat({ companyId, tenant, host, getToken, projectId, debug, menuOption, }: UseHeadlessChatOptions): {
19
20
  status: "error" | "idle" | "connected" | "connecting" | "finished";
20
21
  sendMessage: (body: string) => Promise<void>;
21
22
  showReconnect: boolean;