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.cjs.js CHANGED
@@ -38,6 +38,8 @@ var agGridColumnFormatter = require('core/Utils/agGridV36/columnFormatter');
38
38
  var CoreChart = require('core/Utils/core-charts');
39
39
  var makeStyles = require('@mui/styles/makeStyles');
40
40
  var ChevronRightIcon$1 = require('@mui/icons-material/ChevronRight');
41
+ var DescriptionOutlinedIcon = require('@mui/icons-material/DescriptionOutlined');
42
+ var OpenInNewIcon = require('@mui/icons-material/OpenInNew');
41
43
  var FormatListBulletedOutlinedIcon = require('@mui/icons-material/FormatListBulletedOutlined');
42
44
  var PsychologyOutlinedIcon = require('@mui/icons-material/PsychologyOutlined');
43
45
  var colours$1 = require('core/Styles/colours');
@@ -46,6 +48,13 @@ var RangePicker = require('core/commonComponents/dateRangePicker');
46
48
  var NoFilterSetSavedIcon = require('core/coreAssets/chatbot/noFilterSetSaved.svg');
47
49
  var CoreComponentScreen = require('core/commonComponents/coreComponentScreen');
48
50
  var utils$1 = require('core/commonComponents/coreComponentScreen/utils');
51
+ var reactDom = require('react-dom');
52
+ var VisibilityOutlinedIcon = require('@mui/icons-material/VisibilityOutlined');
53
+ var OpenInFullIcon = require('@mui/icons-material/OpenInFull');
54
+ var CloseFullscreenIcon = require('@mui/icons-material/CloseFullscreen');
55
+ var CloseIcon = require('@mui/icons-material/Close');
56
+ var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
57
+ var ArrowForwardIcon = require('@mui/icons-material/ArrowForward');
49
58
  var utils$2 = require('core/Utils/utils');
50
59
 
51
60
  function _interopNamespaceDefault(e) {
@@ -863,6 +872,17 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
863
872
  bodyType: "html",
864
873
  bodyText: { content: data?.data?.content || "" },
865
874
  };
875
+ case "allocation_plan_card":
876
+ return {
877
+ ...data,
878
+ timeStamp: timeString,
879
+ userType: "bot",
880
+ userName: userName,
881
+ headerTitle: "",
882
+ noShowHeaderTitle: true,
883
+ bodyType: "allocation_plan_card",
884
+ bodyText: data?.data || data,
885
+ };
866
886
  case "image":
867
887
  return {
868
888
  ...data,
@@ -2816,9 +2836,16 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2816
2836
  else if (data.actionType === "indirect") {
2817
2837
  setUserInput(data.displayText);
2818
2838
  }
2819
- else {
2839
+ else if (data.screen_name) {
2820
2840
  fetchUserResultsFromQuery(data, true, "", activeConversationId);
2821
2841
  }
2842
+ else {
2843
+ // No screen_name (e.g. suggested follow-up chips from navigation-v2):
2844
+ // treat the chip's displayText as a regular user query so it flows
2845
+ // through the navigation streaming endpoint instead of the
2846
+ // fetchRelatedQuestions screen-based endpoint.
2847
+ fetchUserResultsFromQuery(data, false, data.displayText, activeConversationId);
2848
+ }
2822
2849
  }, [activeConversationId, baseUrl]);
2823
2850
  const fetchUserResultsFromQuery = React.useCallback(async (refObject, fetchQuestions = false, inputValue = userInput, conversationId = activeConversationId) => {
2824
2851
  let flowType = refObject?.flow_type ? refObject?.flow_type : currentMode;
@@ -8832,7 +8859,7 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
8832
8859
  const [isExpanded, setIsExpanded] = React.useState(true);
8833
8860
  const dotClass = status === "completed"
8834
8861
  ? "completed"
8835
- : status === "in-progress"
8862
+ : status === "in-progress" || status === "not-started"
8836
8863
  ? "in-progress"
8837
8864
  : status === "error"
8838
8865
  ? "error"
@@ -8953,6 +8980,479 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
8953
8980
  }, children: jsxRuntime.jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
8954
8981
  };
8955
8982
 
8983
+ const useAllocationPanelStyles = styles.makeStyles((theme) => ({
8984
+ // AllocationPlanCard styles (inside chatbot)
8985
+ planCard: {
8986
+ border: "1.5px solid #e2e8f0",
8987
+ borderRadius: "14px",
8988
+ padding: "14px 16px",
8989
+ display: "flex",
8990
+ alignItems: "center",
8991
+ gap: "14px",
8992
+ cursor: "pointer",
8993
+ position: "relative",
8994
+ overflow: "hidden",
8995
+ transition: "border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease",
8996
+ background: "#fafbff",
8997
+ "&:hover": {
8998
+ borderColor: "#b4beff",
8999
+ boxShadow: "0 2px 12px rgba(66, 89, 238, 0.10)",
9000
+ background: "linear-gradient(135deg, #f5f7ff 0%, #eef1ff 60%, #e8ecff 100%)",
9001
+ },
9002
+ },
9003
+ planCardIcon: {
9004
+ width: "48px",
9005
+ height: "48px",
9006
+ borderRadius: "12px",
9007
+ background: "linear-gradient(135deg, #e8edff 0%, #dbe1ff 100%)",
9008
+ display: "flex",
9009
+ alignItems: "center",
9010
+ justifyContent: "center",
9011
+ flexShrink: 0,
9012
+ "& svg": {
9013
+ color: "#4259EE",
9014
+ fontSize: "22px",
9015
+ },
9016
+ },
9017
+ planCardContent: {
9018
+ flex: 1,
9019
+ minWidth: 0,
9020
+ },
9021
+ planCardTitle: {
9022
+ fontSize: "14px",
9023
+ fontWeight: 700,
9024
+ color: "#1e293b",
9025
+ lineHeight: 1.4,
9026
+ marginBottom: "4px",
9027
+ },
9028
+ planCardLinks: {
9029
+ display: "flex",
9030
+ alignItems: "center",
9031
+ gap: "4px",
9032
+ flexWrap: "wrap",
9033
+ fontSize: "13px",
9034
+ color: "#64748b",
9035
+ },
9036
+ planCardLink: {
9037
+ color: "#64748b",
9038
+ cursor: "pointer",
9039
+ textDecoration: "none",
9040
+ transition: "color 0.2s ease",
9041
+ "&:hover": {
9042
+ color: "#4259EE",
9043
+ },
9044
+ },
9045
+ planCardLinkSeparator: {
9046
+ color: "#94a3b8",
9047
+ margin: "0 3px",
9048
+ },
9049
+ planCardOpenIcon: {
9050
+ flexShrink: 0,
9051
+ color: "#94a3b8",
9052
+ fontSize: "20px !important",
9053
+ padding: "6px",
9054
+ borderRadius: "8px",
9055
+ border: "1px solid #e2e8f0",
9056
+ background: "#ffffff",
9057
+ transition: "border-color 0.25s ease, color 0.25s ease",
9058
+ "$planCard:hover &": {
9059
+ borderColor: "#b4beff",
9060
+ color: "#4259EE",
9061
+ },
9062
+ },
9063
+
9064
+ // PanelHeader styles
9065
+ panelHeader: {
9066
+ display: "flex",
9067
+ alignItems: "center",
9068
+ justifyContent: "space-between",
9069
+ padding: "16px",
9070
+ borderBottom: "1px solid #f0f0f0",
9071
+ flexShrink: 0,
9072
+ },
9073
+ panelHeaderLeft: {
9074
+ display: "flex",
9075
+ alignItems: "center",
9076
+ gap: "8px",
9077
+ flex: 1,
9078
+ minWidth: 0,
9079
+ },
9080
+ panelHeaderIcon: {
9081
+ color: "#666",
9082
+ fontSize: "20px",
9083
+ cursor: "pointer",
9084
+ },
9085
+ panelTitle: {
9086
+ fontSize: "14px",
9087
+ fontWeight: 600,
9088
+ color: "#1a1a1a",
9089
+ lineHeight: 1.4,
9090
+ overflow: "hidden",
9091
+ textOverflow: "ellipsis",
9092
+ whiteSpace: "nowrap",
9093
+ },
9094
+ panelHeaderActions: {
9095
+ display: "flex",
9096
+ alignItems: "center",
9097
+ gap: "6px",
9098
+ flexShrink: 0,
9099
+ },
9100
+ panelHeaderActionBtn: {
9101
+ width: "28px !important",
9102
+ height: "28px !important",
9103
+ borderRadius: "8px !important",
9104
+ background: "#f1f5f9 !important",
9105
+ color: "#475569 !important",
9106
+ padding: "0 !important",
9107
+ "&:hover": {
9108
+ background: "#e2e8f0 !important",
9109
+ color: "#1e293b !important",
9110
+ },
9111
+ },
9112
+
9113
+ // ReportSummaryCard styles
9114
+ reportSummaryCard: {
9115
+ border: "1px solid #f0c36d",
9116
+ borderRadius: "8px",
9117
+ padding: "14px",
9118
+ margin: "16px 0",
9119
+ background: "#fffdf5",
9120
+ },
9121
+ reportBadge: {
9122
+ display: "inline-block",
9123
+ fontSize: "11px",
9124
+ fontWeight: 500,
9125
+ padding: "3px 8px",
9126
+ borderRadius: "4px",
9127
+ marginBottom: "8px",
9128
+ border: "1px solid #f0c36d",
9129
+ color: "#8b6914",
9130
+ background: "transparent",
9131
+ },
9132
+ reportDescription: {
9133
+ fontSize: "12px",
9134
+ lineHeight: 1.6,
9135
+ color: "#333",
9136
+ marginBottom: "10px",
9137
+ },
9138
+ baselinePlanRow: {
9139
+ fontSize: "12px",
9140
+ color: "#666",
9141
+ display: "flex",
9142
+ alignItems: "center",
9143
+ gap: "4px",
9144
+ },
9145
+ baselinePlanLink: {
9146
+ color: "#2563eb",
9147
+ textDecoration: "underline",
9148
+ cursor: "pointer",
9149
+ wordBreak: "break-all",
9150
+ },
9151
+
9152
+ // PanelSection (Accordion) styles
9153
+ sectionAccordion: {
9154
+ boxShadow: "none !important",
9155
+ border: "none !important",
9156
+ borderRadius: "12px !important",
9157
+ marginBottom: "10px !important",
9158
+ background: "#f8fafc !important",
9159
+ "&:before": {
9160
+ display: "none !important",
9161
+ content: "none !important",
9162
+ background: "none !important",
9163
+ width: "0 !important",
9164
+ height: "0 !important",
9165
+ },
9166
+ "&.Mui-expanded": {
9167
+ margin: "0 0 10px 0 !important",
9168
+ background: "#ffffff !important",
9169
+ boxShadow: "0 1px 8px rgba(0, 0, 0, 0.06) !important",
9170
+ border: "1px solid #e2e8f0 !important",
9171
+ },
9172
+ },
9173
+ sectionSummary: {
9174
+ minHeight: "48px !important",
9175
+ padding: "0 16px !important",
9176
+ border: "none !important",
9177
+ flexDirection: "row-reverse !important",
9178
+ gap: "10px",
9179
+ "&:before": {
9180
+ display: "none !important",
9181
+ content: "none !important",
9182
+ background: "none !important",
9183
+ width: "0 !important",
9184
+ height: "0 !important",
9185
+ },
9186
+ "& .MuiAccordionSummary-content": {
9187
+ margin: "12px 0 !important",
9188
+ },
9189
+ "& .MuiAccordionSummary-expandIconWrapper": {
9190
+ color: "#64748b",
9191
+ transform: "rotate(-90deg)",
9192
+ padding: "0 !important",
9193
+ marginRight: "0 !important",
9194
+ "&.Mui-expanded": {
9195
+ transform: "rotate(0deg)",
9196
+ },
9197
+ },
9198
+ },
9199
+ sectionTitle: {
9200
+ fontSize: "14px",
9201
+ fontWeight: 600,
9202
+ color: "#1e293b",
9203
+ },
9204
+ sectionDetails: {
9205
+ padding: "0 16px 16px !important",
9206
+ border: "none !important",
9207
+ "&:before": {
9208
+ display: "none !important",
9209
+ content: "none !important",
9210
+ background: "none !important",
9211
+ width: "0 !important",
9212
+ height: "0 !important",
9213
+ },
9214
+ },
9215
+
9216
+ // StructuredComparison styles
9217
+ comparisonSubtitle: {
9218
+ fontSize: "12px",
9219
+ color: "#666",
9220
+ marginBottom: "12px",
9221
+ lineHeight: 1.5,
9222
+ },
9223
+ scenarioLabel: {
9224
+ fontSize: "12px",
9225
+ fontWeight: 500,
9226
+ color: "#1a1a1a",
9227
+ padding: "8px 12px",
9228
+ background: "#f8f9fa",
9229
+ borderRadius: "6px",
9230
+ marginBottom: "12px",
9231
+ },
9232
+ comparisonCard: {
9233
+ background: "#f8f9fa",
9234
+ borderRadius: "8px",
9235
+ padding: "12px",
9236
+ marginBottom: "10px",
9237
+ },
9238
+ comparisonParamRow: {
9239
+ display: "flex",
9240
+ alignItems: "center",
9241
+ gap: "8px",
9242
+ marginBottom: "10px",
9243
+ },
9244
+ comparisonParamName: {
9245
+ fontSize: "13px",
9246
+ fontWeight: 600,
9247
+ color: "#1a1a1a",
9248
+ },
9249
+ comparisonTag: {
9250
+ display: "inline-block",
9251
+ fontSize: "10px",
9252
+ fontWeight: 500,
9253
+ padding: "2px 6px",
9254
+ borderRadius: "4px",
9255
+ color: "#2563eb",
9256
+ border: "1px solid #bfdbfe",
9257
+ background: "#eff6ff",
9258
+ },
9259
+ comparisonValues: {
9260
+ display: "flex",
9261
+ alignItems: "center",
9262
+ gap: "8px",
9263
+ },
9264
+ comparisonValueBox: {
9265
+ flex: 1,
9266
+ background: theme.palette.common.white,
9267
+ borderRadius: "6px",
9268
+ padding: "8px 10px",
9269
+ border: "1px solid #e8e8e8",
9270
+ },
9271
+ comparisonValueLabel: {
9272
+ fontSize: "10px",
9273
+ color: "#999",
9274
+ marginBottom: "2px",
9275
+ },
9276
+ comparisonValueText: {
9277
+ fontSize: "12px",
9278
+ fontWeight: 600,
9279
+ color: "#1a1a1a",
9280
+ },
9281
+ comparisonArrow: {
9282
+ color: "#999",
9283
+ fontSize: "16px",
9284
+ flexShrink: 0,
9285
+ },
9286
+
9287
+ // Panel-specific HTML content wrapper (font size/line-height for panel context)
9288
+ panelHtmlContainer: {
9289
+ fontSize: "12px",
9290
+ lineHeight: 1.6,
9291
+ },
9292
+
9293
+ // Slide-in keyframes for panel entry
9294
+ "@keyframes panelSlideIn": {
9295
+ "0%": {
9296
+ transform: "translateX(100%)",
9297
+ opacity: 0,
9298
+ },
9299
+ "100%": {
9300
+ transform: "translateX(0)",
9301
+ opacity: 1,
9302
+ },
9303
+ },
9304
+ // AllocationDetailPanel container (portaled)
9305
+ panelContainer: {
9306
+ position: "fixed",
9307
+ top: 56,
9308
+ right: 0,
9309
+ width: "calc(50vw - 32px)",
9310
+ maxWidth: "520px",
9311
+ height: "calc(100vh - 56px)",
9312
+ zIndex: 99999,
9313
+ display: "flex",
9314
+ flexDirection: "column",
9315
+ background: "#ffffff",
9316
+ boxShadow: "-4px 0 16px rgba(0, 0, 0, 0.15)",
9317
+ borderLeft: "1px solid #e8e8e8",
9318
+ borderRadius: "12px 0 0 12px",
9319
+ overflow: "hidden",
9320
+ animation: "$panelSlideIn 0.3s ease forwards",
9321
+ transition: "width 0.3s ease, max-width 0.3s ease, border-radius 0.3s ease",
9322
+ },
9323
+ // Expanded / maximized panel — covers the chatbot area too
9324
+ panelExpanded: {
9325
+ width: "calc(100vw - 4rem)",
9326
+ maxWidth: "calc(100vw - 4rem)",
9327
+ borderRadius: "0",
9328
+ },
9329
+ panelScrollBody: {
9330
+ flex: 1,
9331
+ overflowY: "auto",
9332
+ padding: "0 16px 24px",
9333
+ },
9334
+
9335
+ // Footer
9336
+ panelFooter: {
9337
+ display: "flex",
9338
+ justifyContent: "flex-end",
9339
+ alignItems: "center",
9340
+ gap: "10px",
9341
+ padding: "12px 16px",
9342
+ borderTop: "1px solid #e2e8f0",
9343
+ background: "#ffffff",
9344
+ flexShrink: 0,
9345
+ position: "relative",
9346
+ },
9347
+ footerBtnOutlined: {
9348
+ display: "inline-flex",
9349
+ alignItems: "center",
9350
+ justifyContent: "center",
9351
+ height: "32px",
9352
+ padding: "0 12px",
9353
+ fontSize: "14px",
9354
+ fontWeight: 600,
9355
+ fontFamily: "Manrope, sans-serif",
9356
+ lineHeight: 1,
9357
+ borderRadius: "8px",
9358
+ border: "1px solid #d1d5db",
9359
+ background: "#ffffff",
9360
+ color: "#1e293b",
9361
+ cursor: "pointer",
9362
+ textTransform: "none",
9363
+ },
9364
+ footerBtnPrimary: {
9365
+ display: "inline-flex",
9366
+ alignItems: "center",
9367
+ justifyContent: "center",
9368
+ height: "32px",
9369
+ padding: "0 12px",
9370
+ fontSize: "14px",
9371
+ fontWeight: 600,
9372
+ fontFamily: "Manrope, sans-serif",
9373
+ lineHeight: 1,
9374
+ borderRadius: "8px",
9375
+ border: "1px solid #4259EE",
9376
+ background: "#4259EE",
9377
+ color: "#ffffff",
9378
+ cursor: "pointer",
9379
+ textTransform: "none",
9380
+ },
9381
+
9382
+ // Footer options popover
9383
+ optionsCard: {
9384
+ position: "absolute",
9385
+ bottom: "100%",
9386
+ right: 0,
9387
+ marginBottom: "8px",
9388
+ background: "#ffffff",
9389
+ borderRadius: "12px",
9390
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.12)",
9391
+ border: "1px solid #e2e8f0",
9392
+ padding: "8px",
9393
+ minWidth: "280px",
9394
+ zIndex: 1,
9395
+ },
9396
+ optionRow: {
9397
+ display: "flex",
9398
+ alignItems: "center",
9399
+ gap: "10px",
9400
+ padding: "10px 12px",
9401
+ borderRadius: "8px",
9402
+ cursor: "pointer",
9403
+ fontSize: "13px",
9404
+ fontWeight: 500,
9405
+ color: "#1e293b",
9406
+ background: "#f8fafc",
9407
+ marginBottom: "4px",
9408
+ border: "none",
9409
+ width: "100%",
9410
+ textAlign: "left",
9411
+ fontFamily: "Manrope, sans-serif",
9412
+ "&:hover": {
9413
+ background: "#eef2ff",
9414
+ },
9415
+ "&:last-child": {
9416
+ marginBottom: 0,
9417
+ },
9418
+ },
9419
+ optionIcon: {
9420
+ color: "#6366f1",
9421
+ fontSize: "16px",
9422
+ },
9423
+ }));
9424
+
9425
+ const AllocationPlanCard = ({ bodyText }) => {
9426
+ const classes = useAllocationPanelStyles();
9427
+ const title = bodyText?.title || "Allocation Plan";
9428
+ const links = bodyText?.links || [];
9429
+ const panelData = bodyText?.panel_data || null;
9430
+ const handleCardClick = (target) => {
9431
+ if (!panelData)
9432
+ return;
9433
+ const openPanel = () => {
9434
+ window.dispatchEvent(new CustomEvent("openAllocationDetailPanel", {
9435
+ detail: { panelData, activeSection: target || null },
9436
+ }));
9437
+ };
9438
+ // Check if the chatbot is in a collapsed/minimized state by looking for
9439
+ // the "Expand chatbot" button (present only when collapsed)
9440
+ const expandBtn = document.querySelector('button[aria-label="Expand chatbot"]');
9441
+ if (expandBtn) {
9442
+ // Maximize first, then open the panel after chatbot finishes expanding
9443
+ window.dispatchEvent(new CustomEvent("smartBotMaximize"));
9444
+ setTimeout(openPanel, 350);
9445
+ }
9446
+ else {
9447
+ openPanel();
9448
+ }
9449
+ };
9450
+ return (jsxRuntime.jsxs("div", { className: classes.planCard, onClick: () => handleCardClick(links[0]?.target), children: [jsxRuntime.jsx("div", { className: classes.planCardIcon, children: jsxRuntime.jsx(DescriptionOutlinedIcon, {}) }), jsxRuntime.jsxs("div", { className: classes.planCardContent, children: [jsxRuntime.jsx("div", { className: classes.planCardTitle, children: title }), jsxRuntime.jsx("div", { className: classes.planCardLinks, children: links.map((link, index) => (jsxRuntime.jsxs("span", { children: [index > 0 && (jsxRuntime.jsx("span", { className: classes.planCardLinkSeparator, children: "\u00B7" })), jsxRuntime.jsx("span", { className: classes.planCardLink, onClick: (e) => {
9451
+ e.stopPropagation();
9452
+ handleCardClick(link.target);
9453
+ }, children: link.label })] }, link.target || index))) })] }), jsxRuntime.jsx(OpenInNewIcon, { className: classes.planCardOpenIcon })] }));
9454
+ };
9455
+
8956
9456
  const renderWidgetItem = (item, index, isFormDisabled) => {
8957
9457
  try {
8958
9458
  const parsedData = parseResponse(item, item.type, "", "", true);
@@ -8989,6 +9489,8 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
8989
9489
  return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8990
9490
  case "html":
8991
9491
  return jsxRuntime.jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
9492
+ case "allocation_plan_card":
9493
+ return jsxRuntime.jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
8992
9494
  default:
8993
9495
  return null;
8994
9496
  }
@@ -11467,6 +11969,8 @@ const CombinedContent = ({ botData, props }) => {
11467
11969
  return jsxRuntime.jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
11468
11970
  case "html":
11469
11971
  return jsxRuntime.jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
11972
+ case "allocation_plan_card":
11973
+ return jsxRuntime.jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
11470
11974
  default:
11471
11975
  return null;
11472
11976
  }
@@ -11567,6 +12071,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
11567
12071
  return jsxRuntime.jsx(ImageContent, { bodyText: botData.bodyText });
11568
12072
  case "html":
11569
12073
  return jsxRuntime.jsx(HtmlContent, { bodyText: botData.bodyText });
12074
+ case "allocation_plan_card":
12075
+ return jsxRuntime.jsx(AllocationPlanCard, { bodyText: botData.bodyText });
11570
12076
  case "combined":
11571
12077
  return jsxRuntime.jsx(CombinedContent, { botData: botData, props: props });
11572
12078
  case "dynamic":
@@ -15699,6 +16205,146 @@ const MinimizedChatWidget = ({ onExpand }) => {
15699
16205
  return (jsxRuntime.jsxs("div", { className: classes.widgetContainer, onClick: handleExpandClick, children: [jsxRuntime.jsxs("div", { className: classes.widgetHeader, children: [jsxRuntime.jsxs("div", { className: classes.headerLeft, children: [jsxRuntime.jsx("div", { className: !isCompleted ? classes.headerIconLogoSpin : classes.headerIconLogo, children: jsxRuntime.jsx(SvgMimimizedIconLogo, {}) }), jsxRuntime.jsx("span", { className: classes.headerText, children: isCompleted ? "Action completed" : actionLabel }), !isCompleted && (jsxRuntime.jsx("div", { className: classes.warningIcon, children: jsxRuntime.jsx(SvgStepError, {}) }))] }), jsxRuntime.jsx("button", { className: classes.minimizeBtn, onClick: handleMinimizeClick, "aria-label": "Minimize", children: jsxRuntime.jsx(SvgMinimizeDashIcon, {}) })] }), jsxRuntime.jsx("div", { className: classes.widgetContent, children: jsxRuntime.jsxs("div", { className: stepStatus === "step_form" ? classes.innerContentStepForm : classes.innerContent, children: [jsxRuntime.jsxs("div", { className: classes.innerFirstRow, children: [jsxRuntime.jsx("span", { className: classes.stepHeaderText, title: stepHeader, children: stepHeader }), jsxRuntime.jsx("button", { className: classes.expandBtn, onClick: handleExpandClick, "aria-label": "Expand chatbot", children: jsxRuntime.jsx(SvgExpandFullscreenIcon, {}) })] }), stepSubHeader && (jsxRuntime.jsxs("div", { className: classes.innerSecondRow, children: [jsxRuntime.jsxs("div", { className: stepStatus === "step_form" ? classes.subHeaderPillStepForm : classes.subHeaderPill, children: [stepStatus === "step_form" ? (jsxRuntime.jsx("div", { className: classes.exclamationIcon, children: jsxRuntime.jsx(SvgExclamationIcon, {}) })) : !isCompleted && (jsxRuntime.jsx("div", { className: classes.loaderIcon, children: jsxRuntime.jsx(SvgLoadingCircle, {}) })), jsxRuntime.jsx("span", { className: classes.subHeaderText, title: stepSubHeader, children: stepSubHeader })] }), elapsedTime && (jsxRuntime.jsx("span", { className: classes.timeText, children: elapsedTime }))] }))] }) })] }));
15700
16206
  };
15701
16207
 
16208
+ const PanelHeader = ({ title, actions = {}, onClose, isExpanded, onToggleExpand }) => {
16209
+ const classes = useAllocationPanelStyles();
16210
+ return (jsxRuntime.jsxs("div", { className: classes.panelHeader, children: [jsxRuntime.jsxs("div", { className: classes.panelHeaderLeft, children: [actions.preview && (jsxRuntime.jsx(VisibilityOutlinedIcon, { className: classes.panelHeaderIcon })), jsxRuntime.jsx("span", { className: classes.panelTitle, title: title, children: title })] }), jsxRuntime.jsxs("div", { className: classes.panelHeaderActions, children: [actions.expand_fullscreen && (jsxRuntime.jsx(material.IconButton, { className: classes.panelHeaderActionBtn, size: "small", onClick: onToggleExpand, children: isExpanded ? (jsxRuntime.jsx(CloseFullscreenIcon, { sx: { fontSize: 16 } })) : (jsxRuntime.jsx(OpenInFullIcon, { sx: { fontSize: 16 } })) })), jsxRuntime.jsx(material.IconButton, { className: classes.panelHeaderActionBtn, size: "small", onClick: onClose, children: jsxRuntime.jsx(CloseIcon, { sx: { fontSize: 16 } }) })] })] }));
16211
+ };
16212
+
16213
+ const ReportSummaryCard = ({ reportSummary }) => {
16214
+ const classes = useAllocationPanelStyles();
16215
+ if (!reportSummary)
16216
+ return null;
16217
+ const { badge, description, baseline_plan } = reportSummary;
16218
+ return (jsxRuntime.jsxs("div", { className: classes.reportSummaryCard, children: [badge && (jsxRuntime.jsx("span", { className: classes.reportBadge, children: badge.label })), description && (jsxRuntime.jsx("div", { className: classes.reportDescription, children: description })), baseline_plan && (jsxRuntime.jsxs("div", { className: classes.baselinePlanRow, children: [jsxRuntime.jsxs("span", { children: [baseline_plan.label, ":"] }), baseline_plan.link_url ? (jsxRuntime.jsx("span", { className: classes.baselinePlanLink, onClick: () => {
16219
+ if (baseline_plan.link_url) {
16220
+ window.open(baseline_plan.link_url, "_blank");
16221
+ }
16222
+ }, children: baseline_plan.value })) : (jsxRuntime.jsx("span", { children: baseline_plan.value }))] }))] }));
16223
+ };
16224
+
16225
+ const StructuredComparison = ({ content }) => {
16226
+ const classes = useAllocationPanelStyles();
16227
+ if (!content)
16228
+ return null;
16229
+ const { subtitle, scenario_groups = [] } = content;
16230
+ return (jsxRuntime.jsxs("div", { children: [subtitle && (jsxRuntime.jsx("div", { className: classes.comparisonSubtitle, children: subtitle })), scenario_groups.map((group, groupIndex) => (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { className: classes.scenarioLabel, children: group.scenario_label }), (group.comparisons || []).map((comparison, compIndex) => (jsxRuntime.jsxs("div", { className: classes.comparisonCard, children: [jsxRuntime.jsxs("div", { className: classes.comparisonParamRow, children: [jsxRuntime.jsx("span", { className: classes.comparisonParamName, children: comparison.parameter_name }), (comparison.tags || []).map((tag, tagIndex) => (jsxRuntime.jsx("span", { className: classes.comparisonTag, children: tag.label }, `tag-${tagIndex}`)))] }), jsxRuntime.jsxs("div", { className: classes.comparisonValues, children: [jsxRuntime.jsxs("div", { className: classes.comparisonValueBox, children: [jsxRuntime.jsx("div", { className: classes.comparisonValueLabel, children: comparison.baseline?.label }), jsxRuntime.jsx("div", { className: classes.comparisonValueText, children: comparison.baseline?.value })] }), jsxRuntime.jsx(ArrowForwardIcon, { className: classes.comparisonArrow }), jsxRuntime.jsxs("div", { className: classes.comparisonValueBox, children: [jsxRuntime.jsx("div", { className: classes.comparisonValueLabel, children: comparison.new_value?.label }), jsxRuntime.jsx("div", { className: classes.comparisonValueText, children: comparison.new_value?.value })] })] })] }, `comp-${groupIndex}-${compIndex}`)))] }, `group-${groupIndex}`)))] }));
16231
+ };
16232
+
16233
+ const PanelSection = ({ section }) => {
16234
+ const classes = useAllocationPanelStyles();
16235
+ if (!section)
16236
+ return null;
16237
+ const renderContent = () => {
16238
+ switch (section.content_type) {
16239
+ case "html":
16240
+ case "custom_html":
16241
+ return (jsxRuntime.jsx("div", { className: classes.panelHtmlContainer, children: jsxRuntime.jsx(HtmlContent, { bodyText: { content: section.content } }) }));
16242
+ case "structured":
16243
+ return jsxRuntime.jsx(StructuredComparison, { content: section.content });
16244
+ default:
16245
+ return null;
16246
+ }
16247
+ };
16248
+ return (jsxRuntime.jsxs(material.Accordion, { defaultExpanded: section.default_expanded, className: classes.sectionAccordion, disableGutters: true, children: [jsxRuntime.jsx(material.AccordionSummary, { expandIcon: jsxRuntime.jsx(ExpandMoreIcon, {}), className: classes.sectionSummary, children: jsxRuntime.jsx("span", { className: classes.sectionTitle, children: section.title }) }), jsxRuntime.jsx(material.AccordionDetails, { className: classes.sectionDetails, children: renderContent() })] }));
16249
+ };
16250
+
16251
+ const shiftChatbot = (panelEl) => {
16252
+ const chatbot = document.querySelector(".chatbot-component-container");
16253
+ if (!chatbot)
16254
+ return;
16255
+ const panelWidth = panelEl ? panelEl.offsetWidth : 0;
16256
+ const currentLeft = parseFloat(chatbot.style.left) || 0;
16257
+ chatbot.dataset.origLeft = chatbot.style.left;
16258
+ chatbot.style.transition = "left 0.3s ease";
16259
+ chatbot.style.left = (currentLeft - panelWidth) + "px";
16260
+ };
16261
+ const restoreChatbot = () => {
16262
+ const chatbot = document.querySelector(".chatbot-component-container");
16263
+ if (!chatbot)
16264
+ return;
16265
+ if (chatbot.dataset.origLeft) {
16266
+ chatbot.style.transition = "left 0.3s ease";
16267
+ chatbot.style.left = chatbot.dataset.origLeft;
16268
+ delete chatbot.dataset.origLeft;
16269
+ // Clean up transition after animation completes
16270
+ const onEnd = () => {
16271
+ chatbot.style.transition = "";
16272
+ chatbot.removeEventListener("transitionend", onEnd);
16273
+ };
16274
+ chatbot.addEventListener("transitionend", onEnd);
16275
+ }
16276
+ };
16277
+ const AllocationDetailPanel = () => {
16278
+ const classes = useAllocationPanelStyles();
16279
+ const [panelData, setPanelData] = React.useState(null);
16280
+ const [activeFooterAction, setActiveFooterAction] = React.useState(null);
16281
+ const [isExpanded, setIsExpanded] = React.useState(false);
16282
+ const panelRef = React.useRef(null);
16283
+ const handleOpen = React.useCallback((e) => {
16284
+ const { panelData: data } = e.detail || {};
16285
+ if (data) {
16286
+ setPanelData(data);
16287
+ }
16288
+ }, []);
16289
+ const handleClose = React.useCallback(() => {
16290
+ restoreChatbot();
16291
+ setPanelData(null);
16292
+ setIsExpanded(false);
16293
+ }, []);
16294
+ React.useEffect(() => {
16295
+ window.addEventListener("openAllocationDetailPanel", handleOpen);
16296
+ window.addEventListener("closeAllocationDetailPanel", handleClose);
16297
+ return () => {
16298
+ window.removeEventListener("openAllocationDetailPanel", handleOpen);
16299
+ window.removeEventListener("closeAllocationDetailPanel", handleClose);
16300
+ };
16301
+ }, [handleOpen, handleClose]);
16302
+ // Shift the chatbot once the panel has rendered
16303
+ React.useEffect(() => {
16304
+ if (panelData && panelRef.current) {
16305
+ // Use requestAnimationFrame to ensure the panel is laid out
16306
+ requestAnimationFrame(() => {
16307
+ shiftChatbot(panelRef.current);
16308
+ });
16309
+ }
16310
+ }, [panelData]);
16311
+ // Listen for direct clicks on the impact-ui collapse button
16312
+ React.useEffect(() => {
16313
+ if (!panelData)
16314
+ return;
16315
+ const collapseBtn = document.querySelector('button[aria-label="Collapse chatbot"]');
16316
+ if (!collapseBtn)
16317
+ return;
16318
+ const onCollapse = () => handleClose();
16319
+ collapseBtn.addEventListener("click", onCollapse);
16320
+ return () => collapseBtn.removeEventListener("click", onCollapse);
16321
+ }, [panelData, handleClose]);
16322
+ if (!panelData)
16323
+ return null;
16324
+ const footerActions = panelData.footer_actions || [
16325
+ { label: "Purge", variant: "outlined", action: "purge", options: [] },
16326
+ { label: "Finalize Plan", variant: "primary", action: "finalize", options: [] },
16327
+ ];
16328
+ const handleOptionClick = (option) => {
16329
+ setActiveFooterAction(null);
16330
+ window.dispatchEvent(new CustomEvent("allocationPanelAction", {
16331
+ detail: { value: option.value, label: option.label },
16332
+ }));
16333
+ };
16334
+ const handleFooterBtnClick = (btn) => {
16335
+ if (btn.options && btn.options.length > 0) {
16336
+ setActiveFooterAction(activeFooterAction === btn.action ? null : btn.action);
16337
+ }
16338
+ else {
16339
+ console.log("[AllocationPanel] footer action:", btn.action);
16340
+ }
16341
+ };
16342
+ const panel = (jsxRuntime.jsxs("div", { ref: panelRef, className: `${classes.panelContainer} ${isExpanded ? classes.panelExpanded : ""}`, "data-testid": "allocation-detail-panel", children: [jsxRuntime.jsx(PanelHeader, { title: panelData.title, actions: panelData.actions || {}, onClose: handleClose, isExpanded: isExpanded, onToggleExpand: () => setIsExpanded((prev) => !prev) }), jsxRuntime.jsxs("div", { className: classes.panelScrollBody, children: [jsxRuntime.jsx(ReportSummaryCard, { reportSummary: panelData.report_summary }), (panelData.sections || []).map((section) => (jsxRuntime.jsx(PanelSection, { section: section }, section.id)))] }), jsxRuntime.jsxs("div", { className: classes.panelFooter, children: [activeFooterAction && (jsxRuntime.jsx("div", { className: classes.optionsCard, children: footerActions
16343
+ .find((a) => a.action === activeFooterAction)
16344
+ ?.options?.map((opt, idx) => (jsxRuntime.jsxs("button", { className: classes.optionRow, onClick: () => handleOptionClick(opt), children: [jsxRuntime.jsx("span", { className: classes.optionIcon, children: "\u2606" }), opt.label] }, idx))) })), footerActions.map((btn, idx) => (jsxRuntime.jsx("button", { className: btn.variant === "primary" ? classes.footerBtnPrimary : classes.footerBtnOutlined, onClick: () => handleFooterBtnClick(btn), children: btn.label }, idx)))] })] }));
16345
+ return reactDom.createPortal(panel, document.body);
16346
+ };
16347
+
15702
16348
  const SmartBot = (props) => {
15703
16349
  const { userName, partialClose, setPartialClose, forceOpen, customBaseUrl = "", displayQuestions, questions = [] } = props;
15704
16350
  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();
@@ -15826,6 +16472,7 @@ const SmartBot = (props) => {
15826
16472
  // Minimize the chat window when the user follows an in-app link from a bot response
15827
16473
  const handleMinimizeRequest = () => {
15828
16474
  setPartialClose(true);
16475
+ window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
15829
16476
  };
15830
16477
  window.addEventListener("stepFormStreamStart", handleStepFormStreamStart);
15831
16478
  window.addEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
@@ -16836,9 +17483,35 @@ const SmartBot = (props) => {
16836
17483
  if (!root)
16837
17484
  return;
16838
17485
  const collapseBtn = root.querySelector('button[aria-label="Collapse chatbot"]');
16839
- if (collapseBtn)
17486
+ if (collapseBtn) {
16840
17487
  collapseBtn.click();
17488
+ window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
17489
+ }
16841
17490
  }, []);
17491
+ // Expand the chatbot to its full docked view by programmatically clicking
17492
+ // impact-ui's "Expand chatbot" button. Used when the allocation panel opens
17493
+ // from minimized state.
17494
+ const expandChatBotIfCollapsed = React.useCallback(() => {
17495
+ setShowModal(true);
17496
+ setPartialClose(false);
17497
+ // Use a short delay so the chatbot DOM renders before we look for the button
17498
+ setTimeout(() => {
17499
+ const root = smartBotWrapperRef.current;
17500
+ if (!root)
17501
+ return;
17502
+ const expandBtn = root.querySelector('button[aria-label="Expand chatbot"]');
17503
+ if (expandBtn) {
17504
+ expandBtn.click();
17505
+ }
17506
+ }, 100);
17507
+ }, []);
17508
+ // Listen for smartBotMaximize events (e.g. from allocation plan card)
17509
+ React.useEffect(() => {
17510
+ window.addEventListener("smartBotMaximize", expandChatBotIfCollapsed);
17511
+ return () => {
17512
+ window.removeEventListener("smartBotMaximize", expandChatBotIfCollapsed);
17513
+ };
17514
+ }, [expandChatBotIfCollapsed]);
16842
17515
  // Auto-collapse to draggable mode when the user interacts outside the bot.
16843
17516
  React.useEffect(() => {
16844
17517
  const handleOutsideInteraction = (e) => {
@@ -16860,6 +17533,9 @@ const SmartBot = (props) => {
16860
17533
  // Ignore clicks inside the expanded table modal portal
16861
17534
  if (e.target.closest?.(".test-modal"))
16862
17535
  return;
17536
+ // Ignore clicks inside the allocation detail panel
17537
+ if (e.target.closest?.('[data-testid="allocation-detail-panel"]'))
17538
+ return;
16863
17539
  collapseChatBotIfExpanded();
16864
17540
  };
16865
17541
  document.addEventListener("mousedown", handleOutsideInteraction, true);
@@ -16986,6 +17662,7 @@ const SmartBot = (props) => {
16986
17662
  dispatch(smartBotActions.setMinimizedStreamData(null));
16987
17663
  }
16988
17664
  setPartialClose(true);
17665
+ window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
16989
17666
  }
16990
17667
  },
16991
17668
  // assistantChats={assistantChats}
@@ -16995,7 +17672,7 @@ const SmartBot = (props) => {
16995
17672
  }, moduleList: modules, tabList: tabList, utilityList: utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder ? showChatPlaceholder : showSavedFilters, customScreenJsx: showChatPlaceholder ?
16996
17673
  jsxRuntime.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 })
16997
17674
  :
16998
- jsxRuntime.jsx(ChatbotSaveFilterComponent$1, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
17675
+ jsxRuntime.jsx(ChatbotSaveFilterComponent$1, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth }), inputText: userInput, threadList: ["Home"], hideMenuArrow: true, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
16999
17676
  freeTextHeading: "Try adding more details :",
17000
17677
  freeTextContent: "Iris works better when you provide more context and pointed questions",
17001
17678
  }, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSavedFilters ? false : showSuggestionBanner, onCloseSuggestionBanner: () => {
@@ -17016,7 +17693,8 @@ const SmartBot = (props) => {
17016
17693
  setChatBotWidth(params);
17017
17694
  }, onMinimiseChatBot: () => {
17018
17695
  setPartialClose(true);
17019
- } })] })] }));
17696
+ window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
17697
+ } })] }), jsxRuntime.jsx(AllocationDetailPanel, {})] }));
17020
17698
  };
17021
17699
 
17022
17700
  exports.default = SmartBot;