impact-chatbot 2.3.100 → 2.3.104

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.
package/dist/index.esm.js CHANGED
@@ -23,7 +23,7 @@ import { setSelectedFilters, setFilterConfiguration, getFilterUserConfiguration
23
23
  import { setThinkingContext, setChatbotContext, setStepFormStreamData, setMinimizedStreamData, setPersistedFormValues, setCurrentAgentChatId, clearPersistedFormValues, setHierarchyKeyValue, setChatbotFilterOptions, setSavedFilterSets } from 'core/actions/smartBotActions';
24
24
  import RefreshIcon from '@mui/icons-material/Refresh';
25
25
  import styled from 'styled-components';
26
- import { CircularProgress, Typography, Grid } from '@mui/material';
26
+ import { CircularProgress, Typography, Grid, IconButton, Accordion, AccordionSummary, AccordionDetails } from '@mui/material';
27
27
  import { fetchBaseUrl, pxToRem as pxToRem$1, replaceSpecialCharacter as replaceSpecialCharacter$1, fetchLegacyAgentScreen } from 'core/Utils/functions/utils';
28
28
  import { Button, Modal, Slider, Select, DatePicker, DateRangePicker, Checkbox, RadioButtonGroup, Input, Tabs, Loader, Prompt, Tooltip, ChatBotComponent } from 'impact-ui-v3';
29
29
  import isArray$2 from 'lodash/isArray';
@@ -35,6 +35,8 @@ import agGridColumnFormatter from 'core/Utils/agGridV36/columnFormatter';
35
35
  import CoreChart from 'core/Utils/core-charts';
36
36
  import makeStyles$1 from '@mui/styles/makeStyles';
37
37
  import ChevronRightIcon$1 from '@mui/icons-material/ChevronRight';
38
+ import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined';
39
+ import OpenInNewIcon from '@mui/icons-material/OpenInNew';
38
40
  import FormatListBulletedOutlinedIcon from '@mui/icons-material/FormatListBulletedOutlined';
39
41
  import PsychologyOutlinedIcon from '@mui/icons-material/PsychologyOutlined';
40
42
  import colours$1 from 'core/Styles/colours';
@@ -43,6 +45,13 @@ import RangePicker from 'core/commonComponents/dateRangePicker';
43
45
  import NoFilterSetSavedIcon from 'core/coreAssets/chatbot/noFilterSetSaved.svg';
44
46
  import CoreComponentScreen from 'core/commonComponents/coreComponentScreen';
45
47
  import { fetchFilterFieldValues, formattedFilterConfiguration } from 'core/commonComponents/coreComponentScreen/utils';
48
+ import { createPortal } from 'react-dom';
49
+ import VisibilityOutlinedIcon from '@mui/icons-material/VisibilityOutlined';
50
+ import OpenInFullIcon from '@mui/icons-material/OpenInFull';
51
+ import CloseFullscreenIcon from '@mui/icons-material/CloseFullscreen';
52
+ import CloseIcon from '@mui/icons-material/Close';
53
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
54
+ import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
46
55
  import { getApplicationCodeFromURL } from 'core/Utils/utils';
47
56
 
48
57
  /**
@@ -841,6 +850,17 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
841
850
  bodyType: "html",
842
851
  bodyText: { content: data?.data?.content || "" },
843
852
  };
853
+ case "allocation_plan_card":
854
+ return {
855
+ ...data,
856
+ timeStamp: timeString,
857
+ userType: "bot",
858
+ userName: userName,
859
+ headerTitle: "",
860
+ noShowHeaderTitle: true,
861
+ bodyType: "allocation_plan_card",
862
+ bodyText: data?.data || data,
863
+ };
844
864
  case "image":
845
865
  return {
846
866
  ...data,
@@ -2794,9 +2814,16 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2794
2814
  else if (data.actionType === "indirect") {
2795
2815
  setUserInput(data.displayText);
2796
2816
  }
2797
- else {
2817
+ else if (data.screen_name) {
2798
2818
  fetchUserResultsFromQuery(data, true, "", activeConversationId);
2799
2819
  }
2820
+ else {
2821
+ // No screen_name (e.g. suggested follow-up chips from navigation-v2):
2822
+ // treat the chip's displayText as a regular user query so it flows
2823
+ // through the navigation streaming endpoint instead of the
2824
+ // fetchRelatedQuestions screen-based endpoint.
2825
+ fetchUserResultsFromQuery(data, false, data.displayText, activeConversationId);
2826
+ }
2800
2827
  }, [activeConversationId, baseUrl]);
2801
2828
  const fetchUserResultsFromQuery = useCallback(async (refObject, fetchQuestions = false, inputValue = userInput, conversationId = activeConversationId) => {
2802
2829
  let flowType = refObject?.flow_type ? refObject?.flow_type : currentMode;
@@ -8810,7 +8837,7 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
8810
8837
  const [isExpanded, setIsExpanded] = useState(true);
8811
8838
  const dotClass = status === "completed"
8812
8839
  ? "completed"
8813
- : status === "in-progress"
8840
+ : status === "in-progress" || status === "not-started"
8814
8841
  ? "in-progress"
8815
8842
  : status === "error"
8816
8843
  ? "error"
@@ -8931,6 +8958,479 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
8931
8958
  }, children: jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
8932
8959
  };
8933
8960
 
8961
+ const useAllocationPanelStyles = makeStyles((theme) => ({
8962
+ // AllocationPlanCard styles (inside chatbot)
8963
+ planCard: {
8964
+ border: "1.5px solid #e2e8f0",
8965
+ borderRadius: "14px",
8966
+ padding: "14px 16px",
8967
+ display: "flex",
8968
+ alignItems: "center",
8969
+ gap: "14px",
8970
+ cursor: "pointer",
8971
+ position: "relative",
8972
+ overflow: "hidden",
8973
+ transition: "border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease",
8974
+ background: "#fafbff",
8975
+ "&:hover": {
8976
+ borderColor: "#b4beff",
8977
+ boxShadow: "0 2px 12px rgba(66, 89, 238, 0.10)",
8978
+ background: "linear-gradient(135deg, #f5f7ff 0%, #eef1ff 60%, #e8ecff 100%)",
8979
+ },
8980
+ },
8981
+ planCardIcon: {
8982
+ width: "48px",
8983
+ height: "48px",
8984
+ borderRadius: "12px",
8985
+ background: "linear-gradient(135deg, #e8edff 0%, #dbe1ff 100%)",
8986
+ display: "flex",
8987
+ alignItems: "center",
8988
+ justifyContent: "center",
8989
+ flexShrink: 0,
8990
+ "& svg": {
8991
+ color: "#4259EE",
8992
+ fontSize: "22px",
8993
+ },
8994
+ },
8995
+ planCardContent: {
8996
+ flex: 1,
8997
+ minWidth: 0,
8998
+ },
8999
+ planCardTitle: {
9000
+ fontSize: "14px",
9001
+ fontWeight: 700,
9002
+ color: "#1e293b",
9003
+ lineHeight: 1.4,
9004
+ marginBottom: "4px",
9005
+ },
9006
+ planCardLinks: {
9007
+ display: "flex",
9008
+ alignItems: "center",
9009
+ gap: "4px",
9010
+ flexWrap: "wrap",
9011
+ fontSize: "13px",
9012
+ color: "#64748b",
9013
+ },
9014
+ planCardLink: {
9015
+ color: "#64748b",
9016
+ cursor: "pointer",
9017
+ textDecoration: "none",
9018
+ transition: "color 0.2s ease",
9019
+ "&:hover": {
9020
+ color: "#4259EE",
9021
+ },
9022
+ },
9023
+ planCardLinkSeparator: {
9024
+ color: "#94a3b8",
9025
+ margin: "0 3px",
9026
+ },
9027
+ planCardOpenIcon: {
9028
+ flexShrink: 0,
9029
+ color: "#94a3b8",
9030
+ fontSize: "20px !important",
9031
+ padding: "6px",
9032
+ borderRadius: "8px",
9033
+ border: "1px solid #e2e8f0",
9034
+ background: "#ffffff",
9035
+ transition: "border-color 0.25s ease, color 0.25s ease",
9036
+ "$planCard:hover &": {
9037
+ borderColor: "#b4beff",
9038
+ color: "#4259EE",
9039
+ },
9040
+ },
9041
+
9042
+ // PanelHeader styles
9043
+ panelHeader: {
9044
+ display: "flex",
9045
+ alignItems: "center",
9046
+ justifyContent: "space-between",
9047
+ padding: "16px",
9048
+ borderBottom: "1px solid #f0f0f0",
9049
+ flexShrink: 0,
9050
+ },
9051
+ panelHeaderLeft: {
9052
+ display: "flex",
9053
+ alignItems: "center",
9054
+ gap: "8px",
9055
+ flex: 1,
9056
+ minWidth: 0,
9057
+ },
9058
+ panelHeaderIcon: {
9059
+ color: "#666",
9060
+ fontSize: "20px",
9061
+ cursor: "pointer",
9062
+ },
9063
+ panelTitle: {
9064
+ fontSize: "14px",
9065
+ fontWeight: 600,
9066
+ color: "#1a1a1a",
9067
+ lineHeight: 1.4,
9068
+ overflow: "hidden",
9069
+ textOverflow: "ellipsis",
9070
+ whiteSpace: "nowrap",
9071
+ },
9072
+ panelHeaderActions: {
9073
+ display: "flex",
9074
+ alignItems: "center",
9075
+ gap: "6px",
9076
+ flexShrink: 0,
9077
+ },
9078
+ panelHeaderActionBtn: {
9079
+ width: "28px !important",
9080
+ height: "28px !important",
9081
+ borderRadius: "8px !important",
9082
+ background: "#f1f5f9 !important",
9083
+ color: "#475569 !important",
9084
+ padding: "0 !important",
9085
+ "&:hover": {
9086
+ background: "#e2e8f0 !important",
9087
+ color: "#1e293b !important",
9088
+ },
9089
+ },
9090
+
9091
+ // ReportSummaryCard styles
9092
+ reportSummaryCard: {
9093
+ border: "1px solid #f0c36d",
9094
+ borderRadius: "8px",
9095
+ padding: "14px",
9096
+ margin: "16px 0",
9097
+ background: "#fffdf5",
9098
+ },
9099
+ reportBadge: {
9100
+ display: "inline-block",
9101
+ fontSize: "11px",
9102
+ fontWeight: 500,
9103
+ padding: "3px 8px",
9104
+ borderRadius: "4px",
9105
+ marginBottom: "8px",
9106
+ border: "1px solid #f0c36d",
9107
+ color: "#8b6914",
9108
+ background: "transparent",
9109
+ },
9110
+ reportDescription: {
9111
+ fontSize: "12px",
9112
+ lineHeight: 1.6,
9113
+ color: "#333",
9114
+ marginBottom: "10px",
9115
+ },
9116
+ baselinePlanRow: {
9117
+ fontSize: "12px",
9118
+ color: "#666",
9119
+ display: "flex",
9120
+ alignItems: "center",
9121
+ gap: "4px",
9122
+ },
9123
+ baselinePlanLink: {
9124
+ color: "#2563eb",
9125
+ textDecoration: "underline",
9126
+ cursor: "pointer",
9127
+ wordBreak: "break-all",
9128
+ },
9129
+
9130
+ // PanelSection (Accordion) styles
9131
+ sectionAccordion: {
9132
+ boxShadow: "none !important",
9133
+ border: "none !important",
9134
+ borderRadius: "12px !important",
9135
+ marginBottom: "10px !important",
9136
+ background: "#f8fafc !important",
9137
+ "&:before": {
9138
+ display: "none !important",
9139
+ content: "none !important",
9140
+ background: "none !important",
9141
+ width: "0 !important",
9142
+ height: "0 !important",
9143
+ },
9144
+ "&.Mui-expanded": {
9145
+ margin: "0 0 10px 0 !important",
9146
+ background: "#ffffff !important",
9147
+ boxShadow: "0 1px 8px rgba(0, 0, 0, 0.06) !important",
9148
+ border: "1px solid #e2e8f0 !important",
9149
+ },
9150
+ },
9151
+ sectionSummary: {
9152
+ minHeight: "48px !important",
9153
+ padding: "0 16px !important",
9154
+ border: "none !important",
9155
+ flexDirection: "row-reverse !important",
9156
+ gap: "10px",
9157
+ "&:before": {
9158
+ display: "none !important",
9159
+ content: "none !important",
9160
+ background: "none !important",
9161
+ width: "0 !important",
9162
+ height: "0 !important",
9163
+ },
9164
+ "& .MuiAccordionSummary-content": {
9165
+ margin: "12px 0 !important",
9166
+ },
9167
+ "& .MuiAccordionSummary-expandIconWrapper": {
9168
+ color: "#64748b",
9169
+ transform: "rotate(-90deg)",
9170
+ padding: "0 !important",
9171
+ marginRight: "0 !important",
9172
+ "&.Mui-expanded": {
9173
+ transform: "rotate(0deg)",
9174
+ },
9175
+ },
9176
+ },
9177
+ sectionTitle: {
9178
+ fontSize: "14px",
9179
+ fontWeight: 600,
9180
+ color: "#1e293b",
9181
+ },
9182
+ sectionDetails: {
9183
+ padding: "0 16px 16px !important",
9184
+ border: "none !important",
9185
+ "&:before": {
9186
+ display: "none !important",
9187
+ content: "none !important",
9188
+ background: "none !important",
9189
+ width: "0 !important",
9190
+ height: "0 !important",
9191
+ },
9192
+ },
9193
+
9194
+ // StructuredComparison styles
9195
+ comparisonSubtitle: {
9196
+ fontSize: "12px",
9197
+ color: "#666",
9198
+ marginBottom: "12px",
9199
+ lineHeight: 1.5,
9200
+ },
9201
+ scenarioLabel: {
9202
+ fontSize: "12px",
9203
+ fontWeight: 500,
9204
+ color: "#1a1a1a",
9205
+ padding: "8px 12px",
9206
+ background: "#f8f9fa",
9207
+ borderRadius: "6px",
9208
+ marginBottom: "12px",
9209
+ },
9210
+ comparisonCard: {
9211
+ background: "#f8f9fa",
9212
+ borderRadius: "8px",
9213
+ padding: "12px",
9214
+ marginBottom: "10px",
9215
+ },
9216
+ comparisonParamRow: {
9217
+ display: "flex",
9218
+ alignItems: "center",
9219
+ gap: "8px",
9220
+ marginBottom: "10px",
9221
+ },
9222
+ comparisonParamName: {
9223
+ fontSize: "13px",
9224
+ fontWeight: 600,
9225
+ color: "#1a1a1a",
9226
+ },
9227
+ comparisonTag: {
9228
+ display: "inline-block",
9229
+ fontSize: "10px",
9230
+ fontWeight: 500,
9231
+ padding: "2px 6px",
9232
+ borderRadius: "4px",
9233
+ color: "#2563eb",
9234
+ border: "1px solid #bfdbfe",
9235
+ background: "#eff6ff",
9236
+ },
9237
+ comparisonValues: {
9238
+ display: "flex",
9239
+ alignItems: "center",
9240
+ gap: "8px",
9241
+ },
9242
+ comparisonValueBox: {
9243
+ flex: 1,
9244
+ background: theme.palette.common.white,
9245
+ borderRadius: "6px",
9246
+ padding: "8px 10px",
9247
+ border: "1px solid #e8e8e8",
9248
+ },
9249
+ comparisonValueLabel: {
9250
+ fontSize: "10px",
9251
+ color: "#999",
9252
+ marginBottom: "2px",
9253
+ },
9254
+ comparisonValueText: {
9255
+ fontSize: "12px",
9256
+ fontWeight: 600,
9257
+ color: "#1a1a1a",
9258
+ },
9259
+ comparisonArrow: {
9260
+ color: "#999",
9261
+ fontSize: "16px",
9262
+ flexShrink: 0,
9263
+ },
9264
+
9265
+ // Panel-specific HTML content wrapper (font size/line-height for panel context)
9266
+ panelHtmlContainer: {
9267
+ fontSize: "12px",
9268
+ lineHeight: 1.6,
9269
+ },
9270
+
9271
+ // Slide-in keyframes for panel entry
9272
+ "@keyframes panelSlideIn": {
9273
+ "0%": {
9274
+ transform: "translateX(100%)",
9275
+ opacity: 0,
9276
+ },
9277
+ "100%": {
9278
+ transform: "translateX(0)",
9279
+ opacity: 1,
9280
+ },
9281
+ },
9282
+ // AllocationDetailPanel container (portaled)
9283
+ panelContainer: {
9284
+ position: "fixed",
9285
+ top: 56,
9286
+ right: 0,
9287
+ width: "calc(50vw - 32px)",
9288
+ maxWidth: "520px",
9289
+ height: "calc(100vh - 56px)",
9290
+ zIndex: 99999,
9291
+ display: "flex",
9292
+ flexDirection: "column",
9293
+ background: "#ffffff",
9294
+ boxShadow: "-4px 0 16px rgba(0, 0, 0, 0.15)",
9295
+ borderLeft: "1px solid #e8e8e8",
9296
+ borderRadius: "12px 0 0 12px",
9297
+ overflow: "hidden",
9298
+ animation: "$panelSlideIn 0.3s ease forwards",
9299
+ transition: "width 0.3s ease, max-width 0.3s ease, border-radius 0.3s ease",
9300
+ },
9301
+ // Expanded / maximized panel — covers the chatbot area too
9302
+ panelExpanded: {
9303
+ width: "calc(100vw - 4rem)",
9304
+ maxWidth: "calc(100vw - 4rem)",
9305
+ borderRadius: "0",
9306
+ },
9307
+ panelScrollBody: {
9308
+ flex: 1,
9309
+ overflowY: "auto",
9310
+ padding: "0 16px 24px",
9311
+ },
9312
+
9313
+ // Footer
9314
+ panelFooter: {
9315
+ display: "flex",
9316
+ justifyContent: "flex-end",
9317
+ alignItems: "center",
9318
+ gap: "10px",
9319
+ padding: "12px 16px",
9320
+ borderTop: "1px solid #e2e8f0",
9321
+ background: "#ffffff",
9322
+ flexShrink: 0,
9323
+ position: "relative",
9324
+ },
9325
+ footerBtnOutlined: {
9326
+ display: "inline-flex",
9327
+ alignItems: "center",
9328
+ justifyContent: "center",
9329
+ height: "32px",
9330
+ padding: "0 12px",
9331
+ fontSize: "14px",
9332
+ fontWeight: 600,
9333
+ fontFamily: "Manrope, sans-serif",
9334
+ lineHeight: 1,
9335
+ borderRadius: "8px",
9336
+ border: "1px solid #d1d5db",
9337
+ background: "#ffffff",
9338
+ color: "#1e293b",
9339
+ cursor: "pointer",
9340
+ textTransform: "none",
9341
+ },
9342
+ footerBtnPrimary: {
9343
+ display: "inline-flex",
9344
+ alignItems: "center",
9345
+ justifyContent: "center",
9346
+ height: "32px",
9347
+ padding: "0 12px",
9348
+ fontSize: "14px",
9349
+ fontWeight: 600,
9350
+ fontFamily: "Manrope, sans-serif",
9351
+ lineHeight: 1,
9352
+ borderRadius: "8px",
9353
+ border: "1px solid #4259EE",
9354
+ background: "#4259EE",
9355
+ color: "#ffffff",
9356
+ cursor: "pointer",
9357
+ textTransform: "none",
9358
+ },
9359
+
9360
+ // Footer options popover
9361
+ optionsCard: {
9362
+ position: "absolute",
9363
+ bottom: "100%",
9364
+ right: 0,
9365
+ marginBottom: "8px",
9366
+ background: "#ffffff",
9367
+ borderRadius: "12px",
9368
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.12)",
9369
+ border: "1px solid #e2e8f0",
9370
+ padding: "8px",
9371
+ minWidth: "280px",
9372
+ zIndex: 1,
9373
+ },
9374
+ optionRow: {
9375
+ display: "flex",
9376
+ alignItems: "center",
9377
+ gap: "10px",
9378
+ padding: "10px 12px",
9379
+ borderRadius: "8px",
9380
+ cursor: "pointer",
9381
+ fontSize: "13px",
9382
+ fontWeight: 500,
9383
+ color: "#1e293b",
9384
+ background: "#f8fafc",
9385
+ marginBottom: "4px",
9386
+ border: "none",
9387
+ width: "100%",
9388
+ textAlign: "left",
9389
+ fontFamily: "Manrope, sans-serif",
9390
+ "&:hover": {
9391
+ background: "#eef2ff",
9392
+ },
9393
+ "&:last-child": {
9394
+ marginBottom: 0,
9395
+ },
9396
+ },
9397
+ optionIcon: {
9398
+ color: "#6366f1",
9399
+ fontSize: "16px",
9400
+ },
9401
+ }));
9402
+
9403
+ const AllocationPlanCard = ({ bodyText }) => {
9404
+ const classes = useAllocationPanelStyles();
9405
+ const title = bodyText?.title || "Allocation Plan";
9406
+ const links = bodyText?.links || [];
9407
+ const panelData = bodyText?.panel_data || null;
9408
+ const handleCardClick = (target) => {
9409
+ if (!panelData)
9410
+ return;
9411
+ const openPanel = () => {
9412
+ window.dispatchEvent(new CustomEvent("openAllocationDetailPanel", {
9413
+ detail: { panelData, activeSection: target || null },
9414
+ }));
9415
+ };
9416
+ // Check if the chatbot is in a collapsed/minimized state by looking for
9417
+ // the "Expand chatbot" button (present only when collapsed)
9418
+ const expandBtn = document.querySelector('button[aria-label="Expand chatbot"]');
9419
+ if (expandBtn) {
9420
+ // Maximize first, then open the panel after chatbot finishes expanding
9421
+ window.dispatchEvent(new CustomEvent("smartBotMaximize"));
9422
+ setTimeout(openPanel, 350);
9423
+ }
9424
+ else {
9425
+ openPanel();
9426
+ }
9427
+ };
9428
+ return (jsxs("div", { className: classes.planCard, onClick: () => handleCardClick(links[0]?.target), children: [jsx("div", { className: classes.planCardIcon, children: jsx(DescriptionOutlinedIcon, {}) }), jsxs("div", { className: classes.planCardContent, children: [jsx("div", { className: classes.planCardTitle, children: title }), jsx("div", { className: classes.planCardLinks, children: links.map((link, index) => (jsxs("span", { children: [index > 0 && (jsx("span", { className: classes.planCardLinkSeparator, children: "\u00B7" })), jsx("span", { className: classes.planCardLink, onClick: (e) => {
9429
+ e.stopPropagation();
9430
+ handleCardClick(link.target);
9431
+ }, children: link.label })] }, link.target || index))) })] }), jsx(OpenInNewIcon, { className: classes.planCardOpenIcon })] }));
9432
+ };
9433
+
8934
9434
  const renderWidgetItem = (item, index, isFormDisabled) => {
8935
9435
  try {
8936
9436
  const parsedData = parseResponse(item, item.type, "", "", true);
@@ -8967,6 +9467,8 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
8967
9467
  return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8968
9468
  case "html":
8969
9469
  return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
9470
+ case "allocation_plan_card":
9471
+ return jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
8970
9472
  default:
8971
9473
  return null;
8972
9474
  }
@@ -11445,6 +11947,8 @@ const CombinedContent = ({ botData, props }) => {
11445
11947
  return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
11446
11948
  case "html":
11447
11949
  return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
11950
+ case "allocation_plan_card":
11951
+ return jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
11448
11952
  default:
11449
11953
  return null;
11450
11954
  }
@@ -11545,6 +12049,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
11545
12049
  return jsx(ImageContent, { bodyText: botData.bodyText });
11546
12050
  case "html":
11547
12051
  return jsx(HtmlContent, { bodyText: botData.bodyText });
12052
+ case "allocation_plan_card":
12053
+ return jsx(AllocationPlanCard, { bodyText: botData.bodyText });
11548
12054
  case "combined":
11549
12055
  return jsx(CombinedContent, { botData: botData, props: props });
11550
12056
  case "dynamic":
@@ -15677,6 +16183,146 @@ const MinimizedChatWidget = ({ onExpand }) => {
15677
16183
  return (jsxs("div", { className: classes.widgetContainer, onClick: handleExpandClick, children: [jsxs("div", { className: classes.widgetHeader, children: [jsxs("div", { className: classes.headerLeft, children: [jsx("div", { className: !isCompleted ? classes.headerIconLogoSpin : classes.headerIconLogo, children: jsx(SvgMimimizedIconLogo, {}) }), jsx("span", { className: classes.headerText, children: isCompleted ? "Action completed" : actionLabel }), !isCompleted && (jsx("div", { className: classes.warningIcon, children: jsx(SvgStepError, {}) }))] }), jsx("button", { className: classes.minimizeBtn, onClick: handleMinimizeClick, "aria-label": "Minimize", children: jsx(SvgMinimizeDashIcon, {}) })] }), jsx("div", { className: classes.widgetContent, children: jsxs("div", { className: stepStatus === "step_form" ? classes.innerContentStepForm : classes.innerContent, children: [jsxs("div", { className: classes.innerFirstRow, children: [jsx("span", { className: classes.stepHeaderText, title: stepHeader, children: stepHeader }), jsx("button", { className: classes.expandBtn, onClick: handleExpandClick, "aria-label": "Expand chatbot", children: jsx(SvgExpandFullscreenIcon, {}) })] }), stepSubHeader && (jsxs("div", { className: classes.innerSecondRow, children: [jsxs("div", { className: stepStatus === "step_form" ? classes.subHeaderPillStepForm : classes.subHeaderPill, children: [stepStatus === "step_form" ? (jsx("div", { className: classes.exclamationIcon, children: jsx(SvgExclamationIcon, {}) })) : !isCompleted && (jsx("div", { className: classes.loaderIcon, children: jsx(SvgLoadingCircle, {}) })), jsx("span", { className: classes.subHeaderText, title: stepSubHeader, children: stepSubHeader })] }), elapsedTime && (jsx("span", { className: classes.timeText, children: elapsedTime }))] }))] }) })] }));
15678
16184
  };
15679
16185
 
16186
+ const PanelHeader = ({ title, actions = {}, onClose, isExpanded, onToggleExpand }) => {
16187
+ const classes = useAllocationPanelStyles();
16188
+ return (jsxs("div", { className: classes.panelHeader, children: [jsxs("div", { className: classes.panelHeaderLeft, children: [actions.preview && (jsx(VisibilityOutlinedIcon, { className: classes.panelHeaderIcon })), jsx("span", { className: classes.panelTitle, title: title, children: title })] }), jsxs("div", { className: classes.panelHeaderActions, children: [actions.expand_fullscreen && (jsx(IconButton, { className: classes.panelHeaderActionBtn, size: "small", onClick: onToggleExpand, children: isExpanded ? (jsx(CloseFullscreenIcon, { sx: { fontSize: 16 } })) : (jsx(OpenInFullIcon, { sx: { fontSize: 16 } })) })), jsx(IconButton, { className: classes.panelHeaderActionBtn, size: "small", onClick: onClose, children: jsx(CloseIcon, { sx: { fontSize: 16 } }) })] })] }));
16189
+ };
16190
+
16191
+ const ReportSummaryCard = ({ reportSummary }) => {
16192
+ const classes = useAllocationPanelStyles();
16193
+ if (!reportSummary)
16194
+ return null;
16195
+ const { badge, description, baseline_plan } = reportSummary;
16196
+ return (jsxs("div", { className: classes.reportSummaryCard, children: [badge && (jsx("span", { className: classes.reportBadge, children: badge.label })), description && (jsx("div", { className: classes.reportDescription, children: description })), baseline_plan && (jsxs("div", { className: classes.baselinePlanRow, children: [jsxs("span", { children: [baseline_plan.label, ":"] }), baseline_plan.link_url ? (jsx("span", { className: classes.baselinePlanLink, onClick: () => {
16197
+ if (baseline_plan.link_url) {
16198
+ window.open(baseline_plan.link_url, "_blank");
16199
+ }
16200
+ }, children: baseline_plan.value })) : (jsx("span", { children: baseline_plan.value }))] }))] }));
16201
+ };
16202
+
16203
+ const StructuredComparison = ({ content }) => {
16204
+ const classes = useAllocationPanelStyles();
16205
+ if (!content)
16206
+ return null;
16207
+ const { subtitle, scenario_groups = [] } = content;
16208
+ return (jsxs("div", { children: [subtitle && (jsx("div", { className: classes.comparisonSubtitle, children: subtitle })), scenario_groups.map((group, groupIndex) => (jsxs("div", { children: [jsx("div", { className: classes.scenarioLabel, children: group.scenario_label }), (group.comparisons || []).map((comparison, compIndex) => (jsxs("div", { className: classes.comparisonCard, children: [jsxs("div", { className: classes.comparisonParamRow, children: [jsx("span", { className: classes.comparisonParamName, children: comparison.parameter_name }), (comparison.tags || []).map((tag, tagIndex) => (jsx("span", { className: classes.comparisonTag, children: tag.label }, `tag-${tagIndex}`)))] }), jsxs("div", { className: classes.comparisonValues, children: [jsxs("div", { className: classes.comparisonValueBox, children: [jsx("div", { className: classes.comparisonValueLabel, children: comparison.baseline?.label }), jsx("div", { className: classes.comparisonValueText, children: comparison.baseline?.value })] }), jsx(ArrowForwardIcon, { className: classes.comparisonArrow }), jsxs("div", { className: classes.comparisonValueBox, children: [jsx("div", { className: classes.comparisonValueLabel, children: comparison.new_value?.label }), jsx("div", { className: classes.comparisonValueText, children: comparison.new_value?.value })] })] })] }, `comp-${groupIndex}-${compIndex}`)))] }, `group-${groupIndex}`)))] }));
16209
+ };
16210
+
16211
+ const PanelSection = ({ section }) => {
16212
+ const classes = useAllocationPanelStyles();
16213
+ if (!section)
16214
+ return null;
16215
+ const renderContent = () => {
16216
+ switch (section.content_type) {
16217
+ case "html":
16218
+ case "custom_html":
16219
+ return (jsx("div", { className: classes.panelHtmlContainer, children: jsx(HtmlContent, { bodyText: { content: section.content } }) }));
16220
+ case "structured":
16221
+ return jsx(StructuredComparison, { content: section.content });
16222
+ default:
16223
+ return null;
16224
+ }
16225
+ };
16226
+ return (jsxs(Accordion, { defaultExpanded: section.default_expanded, className: classes.sectionAccordion, disableGutters: true, children: [jsx(AccordionSummary, { expandIcon: jsx(ExpandMoreIcon, {}), className: classes.sectionSummary, children: jsx("span", { className: classes.sectionTitle, children: section.title }) }), jsx(AccordionDetails, { className: classes.sectionDetails, children: renderContent() })] }));
16227
+ };
16228
+
16229
+ const shiftChatbot = (panelEl) => {
16230
+ const chatbot = document.querySelector(".chatbot-component-container");
16231
+ if (!chatbot)
16232
+ return;
16233
+ const panelWidth = panelEl ? panelEl.offsetWidth : 0;
16234
+ const currentLeft = parseFloat(chatbot.style.left) || 0;
16235
+ chatbot.dataset.origLeft = chatbot.style.left;
16236
+ chatbot.style.transition = "left 0.3s ease";
16237
+ chatbot.style.left = (currentLeft - panelWidth) + "px";
16238
+ };
16239
+ const restoreChatbot = () => {
16240
+ const chatbot = document.querySelector(".chatbot-component-container");
16241
+ if (!chatbot)
16242
+ return;
16243
+ if (chatbot.dataset.origLeft) {
16244
+ chatbot.style.transition = "left 0.3s ease";
16245
+ chatbot.style.left = chatbot.dataset.origLeft;
16246
+ delete chatbot.dataset.origLeft;
16247
+ // Clean up transition after animation completes
16248
+ const onEnd = () => {
16249
+ chatbot.style.transition = "";
16250
+ chatbot.removeEventListener("transitionend", onEnd);
16251
+ };
16252
+ chatbot.addEventListener("transitionend", onEnd);
16253
+ }
16254
+ };
16255
+ const AllocationDetailPanel = () => {
16256
+ const classes = useAllocationPanelStyles();
16257
+ const [panelData, setPanelData] = useState(null);
16258
+ const [activeFooterAction, setActiveFooterAction] = useState(null);
16259
+ const [isExpanded, setIsExpanded] = useState(false);
16260
+ const panelRef = useRef(null);
16261
+ const handleOpen = useCallback((e) => {
16262
+ const { panelData: data } = e.detail || {};
16263
+ if (data) {
16264
+ setPanelData(data);
16265
+ }
16266
+ }, []);
16267
+ const handleClose = useCallback(() => {
16268
+ restoreChatbot();
16269
+ setPanelData(null);
16270
+ setIsExpanded(false);
16271
+ }, []);
16272
+ useEffect(() => {
16273
+ window.addEventListener("openAllocationDetailPanel", handleOpen);
16274
+ window.addEventListener("closeAllocationDetailPanel", handleClose);
16275
+ return () => {
16276
+ window.removeEventListener("openAllocationDetailPanel", handleOpen);
16277
+ window.removeEventListener("closeAllocationDetailPanel", handleClose);
16278
+ };
16279
+ }, [handleOpen, handleClose]);
16280
+ // Shift the chatbot once the panel has rendered
16281
+ useEffect(() => {
16282
+ if (panelData && panelRef.current) {
16283
+ // Use requestAnimationFrame to ensure the panel is laid out
16284
+ requestAnimationFrame(() => {
16285
+ shiftChatbot(panelRef.current);
16286
+ });
16287
+ }
16288
+ }, [panelData]);
16289
+ // Listen for direct clicks on the impact-ui collapse button
16290
+ useEffect(() => {
16291
+ if (!panelData)
16292
+ return;
16293
+ const collapseBtn = document.querySelector('button[aria-label="Collapse chatbot"]');
16294
+ if (!collapseBtn)
16295
+ return;
16296
+ const onCollapse = () => handleClose();
16297
+ collapseBtn.addEventListener("click", onCollapse);
16298
+ return () => collapseBtn.removeEventListener("click", onCollapse);
16299
+ }, [panelData, handleClose]);
16300
+ if (!panelData)
16301
+ return null;
16302
+ const footerActions = panelData.footer_actions || [
16303
+ { label: "Purge", variant: "outlined", action: "purge", options: [] },
16304
+ { label: "Finalize Plan", variant: "primary", action: "finalize", options: [] },
16305
+ ];
16306
+ const handleOptionClick = (option) => {
16307
+ setActiveFooterAction(null);
16308
+ window.dispatchEvent(new CustomEvent("allocationPanelAction", {
16309
+ detail: { value: option.value, label: option.label },
16310
+ }));
16311
+ };
16312
+ const handleFooterBtnClick = (btn) => {
16313
+ if (btn.options && btn.options.length > 0) {
16314
+ setActiveFooterAction(activeFooterAction === btn.action ? null : btn.action);
16315
+ }
16316
+ else {
16317
+ console.log("[AllocationPanel] footer action:", btn.action);
16318
+ }
16319
+ };
16320
+ const panel = (jsxs("div", { ref: panelRef, className: `${classes.panelContainer} ${isExpanded ? classes.panelExpanded : ""}`, "data-testid": "allocation-detail-panel", children: [jsx(PanelHeader, { title: panelData.title, actions: panelData.actions || {}, onClose: handleClose, isExpanded: isExpanded, onToggleExpand: () => setIsExpanded((prev) => !prev) }), jsxs("div", { className: classes.panelScrollBody, children: [jsx(ReportSummaryCard, { reportSummary: panelData.report_summary }), (panelData.sections || []).map((section) => (jsx(PanelSection, { section: section }, section.id)))] }), jsxs("div", { className: classes.panelFooter, children: [activeFooterAction && (jsx("div", { className: classes.optionsCard, children: footerActions
16321
+ .find((a) => a.action === activeFooterAction)
16322
+ ?.options?.map((opt, idx) => (jsxs("button", { className: classes.optionRow, onClick: () => handleOptionClick(opt), children: [jsx("span", { className: classes.optionIcon, children: "\u2606" }), opt.label] }, idx))) })), footerActions.map((btn, idx) => (jsx("button", { className: btn.variant === "primary" ? classes.footerBtnPrimary : classes.footerBtnOutlined, onClick: () => handleFooterBtnClick(btn), children: btn.label }, idx)))] })] }));
16323
+ return createPortal(panel, document.body);
16324
+ };
16325
+
15680
16326
  const SmartBot = (props) => {
15681
16327
  const { userName, partialClose, setPartialClose, forceOpen, customBaseUrl = "", displayQuestions, questions = [] } = props;
15682
16328
  const { showModal, setShowModal, minimizedMode, setMinimizedMode, userInput, setUserInput, position, setPosition, flowType, setFlowType, screenName, setScreenName, questionIndex, setQuestionIndex, currentAppLink, setCurrentAppLink, loader, setLoader, enableRefreshAction, setEnableRefreshAction, refreshLoader, setRefreshLoader, chatDataState, setChatDataState, showExtendedContent, setShowExtendedContent, currentMode, setCurrentMode, selectedModule, setSelectedModule, isCardVisible, setIsCardVisible, templateData, setTemplateData, showAlert, setShowAlert, grabPositionRef, chatDataRef, chatBodyRef, minimizedBtnRef, chatDataScreenLinkRef, navigate, location, dispatch, globalClasses, classes, dateFormat, filterReducerState, activeConversationId, setActiveConversationId, isModuleChanged, setIsModuleChanged, showChatPlaceholder, setShowChatPlaceholder, currentAgentId, setCurrentAgentId, baseUrl = customBaseUrl, setBaseUrl, currentSessionId, setCurrentSessionId, notificationData, agentTaskCompleted, setAgentTaskCompleted, customChatConfig, setCustomChatConfig, setMiddleWareFunction, chatBotInfoRef, chatDataInfoRef, initValue, setInitValue, sessionId, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, legacyAgentScreen, setLegacyAgentScreen, uniqueChatId, setUniqueChatId, fieldNumber, setFieldNumber, thinkingContext, isModalOpen, setIsModalOpen, utilityList, setUtilityList, isUploadModalOpen, setIsUploadModalOpen, isRefreshTriggered, setIsRefreshTriggered, additionalArgs, setAdditionalArgs, showSavedFilters, setShowSavedFilters, navSessionId, setNavSessionId, renameOpen, setRenameOpen, renameTargetId, setRenameTargetId, renameValue, setRenameValue, deleteOpen, setDeleteOpen, deleteTargetId, setDeleteTargetId, } = useChatState();
@@ -15804,6 +16450,7 @@ const SmartBot = (props) => {
15804
16450
  // Minimize the chat window when the user follows an in-app link from a bot response
15805
16451
  const handleMinimizeRequest = () => {
15806
16452
  setPartialClose(true);
16453
+ window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
15807
16454
  };
15808
16455
  window.addEventListener("stepFormStreamStart", handleStepFormStreamStart);
15809
16456
  window.addEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
@@ -16814,9 +17461,35 @@ const SmartBot = (props) => {
16814
17461
  if (!root)
16815
17462
  return;
16816
17463
  const collapseBtn = root.querySelector('button[aria-label="Collapse chatbot"]');
16817
- if (collapseBtn)
17464
+ if (collapseBtn) {
16818
17465
  collapseBtn.click();
17466
+ window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
17467
+ }
16819
17468
  }, []);
17469
+ // Expand the chatbot to its full docked view by programmatically clicking
17470
+ // impact-ui's "Expand chatbot" button. Used when the allocation panel opens
17471
+ // from minimized state.
17472
+ const expandChatBotIfCollapsed = useCallback(() => {
17473
+ setShowModal(true);
17474
+ setPartialClose(false);
17475
+ // Use a short delay so the chatbot DOM renders before we look for the button
17476
+ setTimeout(() => {
17477
+ const root = smartBotWrapperRef.current;
17478
+ if (!root)
17479
+ return;
17480
+ const expandBtn = root.querySelector('button[aria-label="Expand chatbot"]');
17481
+ if (expandBtn) {
17482
+ expandBtn.click();
17483
+ }
17484
+ }, 100);
17485
+ }, []);
17486
+ // Listen for smartBotMaximize events (e.g. from allocation plan card)
17487
+ useEffect(() => {
17488
+ window.addEventListener("smartBotMaximize", expandChatBotIfCollapsed);
17489
+ return () => {
17490
+ window.removeEventListener("smartBotMaximize", expandChatBotIfCollapsed);
17491
+ };
17492
+ }, [expandChatBotIfCollapsed]);
16820
17493
  // Auto-collapse to draggable mode when the user interacts outside the bot.
16821
17494
  useEffect(() => {
16822
17495
  const handleOutsideInteraction = (e) => {
@@ -16838,6 +17511,9 @@ const SmartBot = (props) => {
16838
17511
  // Ignore clicks inside the expanded table modal portal
16839
17512
  if (e.target.closest?.(".test-modal"))
16840
17513
  return;
17514
+ // Ignore clicks inside the allocation detail panel
17515
+ if (e.target.closest?.('[data-testid="allocation-detail-panel"]'))
17516
+ return;
16841
17517
  collapseChatBotIfExpanded();
16842
17518
  };
16843
17519
  document.addEventListener("mousedown", handleOutsideInteraction, true);
@@ -16964,6 +17640,7 @@ const SmartBot = (props) => {
16964
17640
  dispatch(setMinimizedStreamData(null));
16965
17641
  }
16966
17642
  setPartialClose(true);
17643
+ window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
16967
17644
  }
16968
17645
  },
16969
17646
  // assistantChats={assistantChats}
@@ -16973,7 +17650,7 @@ const SmartBot = (props) => {
16973
17650
  }, moduleList: modules, tabList: tabList, utilityList: utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder ? showChatPlaceholder : showSavedFilters, customScreenJsx: showChatPlaceholder ?
16974
17651
  jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId, fieldNumber: fieldNumber, setFieldNumber: setFieldNumber, setAdditionalArgs: setAdditionalArgs, displayQuestions: displayQuestions, questions: questions, setActiveConversationId: setActiveConversationId, selectedFilterSet: selectedFilterSet, answerMode: answerMode })
16975
17652
  :
16976
- jsx(ChatbotSaveFilterComponent$1, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
17653
+ jsx(ChatbotSaveFilterComponent$1, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth }), inputText: userInput, threadList: ["Home"], hideMenuArrow: true, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
16977
17654
  freeTextHeading: "Try adding more details :",
16978
17655
  freeTextContent: "Iris works better when you provide more context and pointed questions",
16979
17656
  }, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSavedFilters ? false : showSuggestionBanner, onCloseSuggestionBanner: () => {
@@ -16994,7 +17671,8 @@ const SmartBot = (props) => {
16994
17671
  setChatBotWidth(params);
16995
17672
  }, onMinimiseChatBot: () => {
16996
17673
  setPartialClose(true);
16997
- } })] })] }));
17674
+ window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
17675
+ } })] }), jsx(AllocationDetailPanel, {})] }));
16998
17676
  };
16999
17677
 
17000
17678
  export { SmartBot as default };