impact-chatbot 2.3.88 → 2.3.90

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.
@@ -0,0 +1,6 @@
1
+ declare const CheckboxGroupContent: ({ bodyText, isFormDisabled, messageIndex }: {
2
+ bodyText: any;
3
+ isFormDisabled?: boolean;
4
+ messageIndex: any;
5
+ }) => import("react/jsx-runtime").JSX.Element;
6
+ export default CheckboxGroupContent;
@@ -1,4 +1,4 @@
1
- declare const Steps: ({ steps, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, activeFormIntent, isRestreaming }: {
1
+ declare const Steps: ({ steps, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, activeFormIntent, isRestreaming, sessionId, chatSessionId }: {
2
2
  steps: any;
3
3
  questions?: any[];
4
4
  questionsStepsMap?: {};
@@ -6,5 +6,7 @@ declare const Steps: ({ steps, questions, questionsStepsMap, stepFormDataMap, is
6
6
  isFormDisabled?: boolean;
7
7
  activeFormIntent?: any;
8
8
  isRestreaming?: boolean;
9
+ sessionId?: string;
10
+ chatSessionId?: string;
9
11
  }) => import("react/jsx-runtime").JSX.Element;
10
12
  export default Steps;
@@ -1,4 +1,4 @@
1
- declare const TabularContent: ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions, questionsStepsMap: initialQuestionsStepsMap, stepFormDataMap: initialStepFormDataMap, isFormDisabled, sessionId: propSessionId, botProps, currentMode, agentId }: {
1
+ declare const TabularContent: ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions, questionsStepsMap: initialQuestionsStepsMap, stepFormDataMap: initialStepFormDataMap, isFormDisabled, sessionId: propSessionId, chatSessionId, botProps, currentMode, agentId }: {
2
2
  steps: any;
3
3
  currentTabValue: any;
4
4
  children: any;
@@ -7,6 +7,7 @@ declare const TabularContent: ({ steps: initialSteps, currentTabValue, children,
7
7
  stepFormDataMap?: {};
8
8
  isFormDisabled?: boolean;
9
9
  sessionId?: string;
10
+ chatSessionId?: string;
10
11
  botProps?: any;
11
12
  currentMode?: string;
12
13
  agentId?: string;
@@ -1,4 +1,4 @@
1
- declare const Steps: ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, botProps, agentId, sessionId, }: {
1
+ declare const Steps: ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, botProps, agentId, sessionId, chatSessionId, }: {
2
2
  steps: any;
3
3
  setSteps: any;
4
4
  done: any;
@@ -15,5 +15,6 @@ declare const Steps: ({ steps, setSteps, done, setTabValue, setDone, finalStepDo
15
15
  botProps?: any;
16
16
  agentId?: string;
17
17
  sessionId?: string;
18
+ chatSessionId?: string;
18
19
  }) => import("react/jsx-runtime").JSX.Element;
19
20
  export default Steps;
package/dist/index.cjs.js CHANGED
@@ -564,6 +564,26 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
564
564
  paramName: data?.data?.param_name
565
565
  }
566
566
  };
567
+ case "checkboxGroup":
568
+ return {
569
+ ...data,
570
+ timeStamp: timeString,
571
+ userType: "bot",
572
+ userName: userName,
573
+ headerTitle: data?.data?.label || "",
574
+ bodyType: "checkboxGroup",
575
+ bodyText: {
576
+ label: data?.data?.label,
577
+ orientation: data?.data?.orientation,
578
+ options: data?.data?.options,
579
+ defaultSelected: data?.data?.defaultSelected,
580
+ minOptions: data?.data?.minOptions,
581
+ maxOptions: data?.data?.maxOptions,
582
+ isRequired: data?.data?.isRequired,
583
+ isDisabled: data?.data?.isDisabled,
584
+ paramName: data?.data?.param_name
585
+ }
586
+ };
567
587
  case "button":
568
588
  return {
569
589
  ...data,
@@ -4216,10 +4236,11 @@ const useStyles$a = styles.makeStyles((theme) => ({
4216
4236
  },
4217
4237
  hideBotStyle: {
4218
4238
  "& .chatbot-component-container": {
4219
- width: "0px",
4220
- height: "0px",
4221
- opacity: "0",
4222
- position: "fixed",
4239
+ width: "0px !important",
4240
+ height: "0px !important",
4241
+ opacity: "0 !important",
4242
+ position: "fixed !important",
4243
+ pointerEvents: "none !important",
4223
4244
  }
4224
4245
  },
4225
4246
  radioGrpLabel: {
@@ -7469,6 +7490,61 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
7469
7490
  return (jsxRuntime.jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsxRuntime.jsx(impactUiV3.Checkbox, { label: label, checked: checked, required: required, disabled: disabled || isFormDisabled, onChange: (e) => handleChange(e), variant: "default" }) }));
7470
7491
  };
7471
7492
 
7493
+ const CheckboxGroupContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7494
+ const formKey = `${messageIndex}_${bodyText?.paramName}`;
7495
+ const classes = useStyles$a();
7496
+ const { label, orientation, options = [], defaultSelected, minOptions, maxOptions, isRequired, isDisabled, } = bodyText || {};
7497
+ const min = minOptions ?? 1;
7498
+ const max = maxOptions ?? options.length;
7499
+ const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
7500
+ const chatbotContextRef = React.useRef(chatbotContext);
7501
+ chatbotContextRef.current = chatbotContext;
7502
+ const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
7503
+ const dispatch = reactRedux.useDispatch();
7504
+ const [selected, setSelected] = React.useState(() => {
7505
+ const persisted = persistedFormValues?.[formKey];
7506
+ if (Array.isArray(persisted))
7507
+ return persisted;
7508
+ return Array.isArray(defaultSelected) ? defaultSelected : [];
7509
+ });
7510
+ if (lodash.isEmpty(bodyText))
7511
+ return null;
7512
+ const groupDisabled = isDisabled || isFormDisabled;
7513
+ const dispatchSelection = (newValues) => {
7514
+ const latestContext = chatbotContextRef.current;
7515
+ dispatch(smartBotActions.setChatbotContext({
7516
+ ...latestContext,
7517
+ [bodyText?.paramName]: {
7518
+ ...latestContext?.[bodyText?.paramName],
7519
+ [bodyText?.paramName]: newValues,
7520
+ updated: true,
7521
+ },
7522
+ }));
7523
+ dispatch(smartBotActions.setPersistedFormValues({ [formKey]: newValues }));
7524
+ };
7525
+ const handleChange = (optionValue, isChecked) => {
7526
+ try {
7527
+ const newValues = isChecked
7528
+ ? [...selected, optionValue]
7529
+ : selected.filter((val) => val !== optionValue);
7530
+ setSelected(newValues);
7531
+ dispatchSelection(newValues);
7532
+ }
7533
+ catch (error) {
7534
+ console.error("Error in checkboxGroup handleChange", error);
7535
+ }
7536
+ };
7537
+ const isRow = orientation === "row";
7538
+ const overMax = selected.length > max;
7539
+ const belowMin = isRequired && selected.length < min;
7540
+ return (jsxRuntime.jsxs("div", { style: { width: "100%", marginTop: "10px" }, children: [label && (jsxRuntime.jsxs("p", { className: classes.radioGrpLabel, children: [label, isRequired ? " *" : ""] })), jsxRuntime.jsx("div", { style: {
7541
+ display: "flex",
7542
+ flexDirection: isRow ? "row" : "column",
7543
+ flexWrap: isRow ? "wrap" : "nowrap",
7544
+ gap: isRow ? "16px" : "8px",
7545
+ }, children: options.map((option) => (jsxRuntime.jsx(impactUiV3.Checkbox, { label: option.label, checked: selected.includes(option.value), disabled: option.disabled || groupDisabled, onChange: (e) => handleChange(option.value, e?.currentTarget?.checked), variant: "default" }, option.value))) }), overMax && (jsxRuntime.jsx("p", { className: classes.radioGrpLabel, style: { margin: "8px 0 0 0", color: "red" }, children: `Select at most ${max} option${max > 1 ? "s" : ""}` })), !overMax && belowMin && (jsxRuntime.jsx("p", { className: classes.radioGrpLabel, style: { margin: "8px 0 0 0", color: "red" }, children: `Select at least ${min} option${min > 1 ? "s" : ""}` }))] }));
7546
+ };
7547
+
7472
7548
  const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7473
7549
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7474
7550
  const classes = useStyles$a();
@@ -7752,6 +7828,38 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7752
7828
  return false;
7753
7829
  });
7754
7830
  }, [formData, chatbotContext, persistedFormValues, messageIndex]);
7831
+ // Validate checkboxGroup fields against their minOptions/maxOptions bounds.
7832
+ // A required group must have selectedCount within [min, max]; any group (even
7833
+ // non-required) must not exceed max. Blocks submit when out of bounds.
7834
+ const checkboxGroupsValid = React.useMemo(() => {
7835
+ if (!formData || !Array.isArray(formData))
7836
+ return true;
7837
+ const groups = formData.filter((item) => item?.type === "checkboxGroup");
7838
+ return groups.every((item) => {
7839
+ const data = item.data || {};
7840
+ const param = data.param_name;
7841
+ const options = data.options || [];
7842
+ const min = data.minOptions ?? 1;
7843
+ const max = data.maxOptions ?? options.length;
7844
+ // Resolve current selection: chatbotContext first, then persistedFormValues
7845
+ let selectedValues = [];
7846
+ const ctx = chatbotContext?.[param];
7847
+ if (ctx && ctx.updated && Array.isArray(ctx[param])) {
7848
+ selectedValues = ctx[param];
7849
+ }
7850
+ else {
7851
+ const persisted = persistedFormValues?.[`${messageIndex}_${param}`];
7852
+ if (Array.isArray(persisted))
7853
+ selectedValues = persisted;
7854
+ }
7855
+ const count = selectedValues.length;
7856
+ if (count > max)
7857
+ return false;
7858
+ if (data.isRequired && count < min)
7859
+ return false;
7860
+ return true;
7861
+ });
7862
+ }, [formData, chatbotContext, persistedFormValues, messageIndex]);
7755
7863
  // Extract select-type filter configs from formData for cross-filter cascading
7756
7864
  // and sort them based on the filters_hierarchy_order from tenant config
7757
7865
  const crossFilterConfigs = React.useMemo(() => {
@@ -7860,10 +7968,12 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7860
7968
  return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7861
7969
  case "checkbox":
7862
7970
  return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7971
+ case "checkboxGroup":
7972
+ return jsxRuntime.jsx(CheckboxGroupContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7863
7973
  case "radio":
7864
7974
  return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7865
7975
  case "button":
7866
- return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled, formParamNames: formParamNames, messageIndex: messageIndex }, key);
7976
+ return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled && checkboxGroupsValid, formParamNames: formParamNames, messageIndex: messageIndex }, key);
7867
7977
  case "input":
7868
7978
  return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7869
7979
  case "image":
@@ -8259,7 +8369,7 @@ const getQuestionStatus$1 = (questionSteps) => {
8259
8369
  /**
8260
8370
  * Renders a single progress bar item (main point + sub-items)
8261
8371
  */
8262
- const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined, botProps = null, currentMode = "", agentId = "", sessionId = "" }) => {
8372
+ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined, botProps = null, currentMode = "", agentId = "", sessionId = "", index = 0, chatSessionId = "" }) => {
8263
8373
  const status = getQuestionStatus$1(questionSteps);
8264
8374
  const animatedCountRef = React.useRef(0);
8265
8375
  const [isExpanded, setIsExpanded] = React.useState(true);
@@ -8293,9 +8403,9 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
8293
8403
  if (animatedCountRef.current >= arr.length && onAllSubItemsAnimated) {
8294
8404
  onAllSubItemsAnimated();
8295
8405
  }
8296
- } }) }, idx))) })), formData && isExpanded && (jsxRuntime.jsx("div", { className: classes.stepFormContainer, children: jsxRuntime.jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId }) }))] })] }));
8406
+ } }) }, idx))) })), formData && isExpanded && (jsxRuntime.jsx("div", { className: classes.stepFormContainer, children: jsxRuntime.jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId, messageIndex: `${String(chatSessionId)}_${index}` }) }))] })] }));
8297
8407
  };
8298
- const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, botProps = null, agentId = "", sessionId = "", }) => {
8408
+ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, botProps = null, agentId = "", sessionId = "", chatSessionId = "", }) => {
8299
8409
  const classes = useStyles$4();
8300
8410
  React.useState(false);
8301
8411
  const [showThinking, setShowThinking] = React.useState(false);
@@ -8378,7 +8488,7 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
8378
8488
  const showSavedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.showSavedFilters : true;
8379
8489
  const preSelectedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.preSelectedFilters : null;
8380
8490
  const isLast = index === questions.length - 1;
8381
- return (jsxRuntime.jsx(ProgressBarItem$1, { question: question, questionSteps: questionSteps, isLast: isLast && !showThinking, classes: classes, formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId, onAllSubItemsAnimated: isLast && lastQuestionCompleted && !done
8491
+ return (jsxRuntime.jsx(ProgressBarItem$1, { question: question, questionSteps: questionSteps, isLast: isLast && !showThinking, classes: classes, formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId, index: index, chatSessionId: chatSessionId, onAllSubItemsAnimated: isLast && lastQuestionCompleted && !done
8382
8492
  ? () => setShowThinking(true)
8383
8493
  : undefined }, index));
8384
8494
  }), showThinking && !done && (jsxRuntime.jsx("div", { style: {
@@ -8406,6 +8516,8 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
8406
8516
  return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8407
8517
  case "checkbox":
8408
8518
  return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8519
+ case "checkboxGroup":
8520
+ return jsxRuntime.jsx(CheckboxGroupContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8409
8521
  case "select":
8410
8522
  return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8411
8523
  case "slider":
@@ -8440,7 +8552,7 @@ const AgentResponse$1 = (props) => {
8440
8552
  };
8441
8553
 
8442
8554
  const StepsResponseTab = (props) => {
8443
- const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, isRetrying, botProps, agentId, sessionId, } = props;
8555
+ const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, isRetrying, botProps, agentId, sessionId, chatSessionId, } = props;
8444
8556
  const dispatch = reactRedux.useDispatch();
8445
8557
  const thinkingContext = reactRedux.useSelector((state) => state.smartBotReducer.thinkingContext);
8446
8558
  const streamStartTimeRef = React.useRef(thinkingContext?.streamStartTime);
@@ -8504,7 +8616,7 @@ const StepsResponseTab = (props) => {
8504
8616
  icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
8505
8617
  },
8506
8618
  ], tabPanels: [
8507
- jsxRuntime.jsx(Steps$1, { steps: steps, setSteps: setSteps, done: stepsDone, setDone: setStepsDone, setTabValue: setTabValue, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, stepChange: stepChange, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: isFormDisabled || isTimedOut, botProps: botProps, agentId: agentId, sessionId: sessionId }),
8619
+ jsxRuntime.jsx(Steps$1, { steps: steps, setSteps: setSteps, done: stepsDone, setDone: setStepsDone, setTabValue: setTabValue, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, stepChange: stepChange, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: isFormDisabled || isTimedOut, botProps: botProps, agentId: agentId, sessionId: sessionId, chatSessionId: chatSessionId }),
8508
8620
  jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(AgentResponse$1, { content: content, isStreaming: isStreaming, streamingWidgetData: streamingWidgetData, isFormDisabled: isFormDisabled || isTimedOut }), timeoutMessage && (jsxRuntime.jsx("div", { style: { marginTop: "8px", padding: "0 8px" }, children: jsxRuntime.jsx(TextRenderer, { text: timeoutMessage, thinking: "" }) }))] }),
8509
8621
  ], value: tabValue }) }));
8510
8622
  };
@@ -10076,7 +10188,7 @@ const StreamedContent = ({ botData, botProps }) => {
10076
10188
  * @returns {JSX.Element} Rendered content with optional blinking cursor
10077
10189
  */
10078
10190
  const renderContent = () => {
10079
- return (jsxRuntime.jsxs("div", { className: classes.streamContainer, children: [jsxRuntime.jsx(StepsResponseTab, { steps: steps, stepChange: stepChange, setSteps: setSteps, stepsDone: stepsDone, setStepsDone: setStepsDone, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, content: content, isStreaming: isStreaming, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: botData?.isFormDisabled || false, streamingWidgetData: streamingWidgetData, isRetrying: isRetrying, botProps: botProps, agentId: botData?.inputBody?.agent_id || "", sessionId: messageToStoreRef.current?.sessionId || "" }), isRetrying && (jsxRuntime.jsx("div", { className: classes.retryContainer, children: jsxRuntime.jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) }))] }));
10191
+ return (jsxRuntime.jsxs("div", { className: classes.streamContainer, children: [jsxRuntime.jsx(StepsResponseTab, { steps: steps, stepChange: stepChange, setSteps: setSteps, stepsDone: stepsDone, setStepsDone: setStepsDone, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, content: content, isStreaming: isStreaming, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: botData?.isFormDisabled || false, streamingWidgetData: streamingWidgetData, isRetrying: isRetrying, botProps: botProps, agentId: botData?.inputBody?.agent_id || "", sessionId: messageToStoreRef.current?.sessionId || "", chatSessionId: messageToStoreRef.current?.chatSessionId || botData?.chatSessionId || "" }), isRetrying && (jsxRuntime.jsx("div", { className: classes.retryContainer, children: jsxRuntime.jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) }))] }));
10080
10192
  };
10081
10193
  if (currentMode === "agent") {
10082
10194
  return renderContent();
@@ -10272,7 +10384,7 @@ const getQuestionStatus = (questionSteps) => {
10272
10384
  /**
10273
10385
  * Renders a single progress bar item (main point + sub-items)
10274
10386
  */
10275
- const ProgressBarItem = ({ question, questionSteps, isLast, classes, formData, isFormDisabled, isRestreaming = false, showSavedFilters = true, preSelectedFilters = null }) => {
10387
+ const ProgressBarItem = ({ question, questionSteps, isLast, classes, formData, isFormDisabled, isRestreaming = false, showSavedFilters = true, preSelectedFilters = null, sessionId = "", index = 0, chatSessionId = "" }) => {
10276
10388
  const baseStatus = getQuestionStatus(questionSteps);
10277
10389
  // When restreaming and this is the last item, show as in-progress
10278
10390
  const status = (isRestreaming && isLast) ? "in-progress" : baseStatus;
@@ -10302,9 +10414,9 @@ const ProgressBarItem = ({ question, questionSteps, isLast, classes, formData, i
10302
10414
  setIsExpanded(true);
10303
10415
  }
10304
10416
  }, [status, formData]);
10305
- return (jsxRuntime.jsxs("div", { className: classes.progressItem, children: [jsxRuntime.jsxs("div", { className: classes.progressTrack, children: [jsxRuntime.jsx("div", { className: `${classes.progressDot} ${dotClass}` }), !isLast && jsxRuntime.jsx("div", { className: `${classes.progressLine} ${lineClass}` })] }), jsxRuntime.jsxs("div", { className: classes.progressContent, children: [jsxRuntime.jsxs("div", { className: classes.progressHeader, onClick: handleToggle, children: [jsxRuntime.jsx("span", { className: `${classes.progressHeaderText} ${textClass}`, children: question }), hasSubItems && (jsxRuntime.jsx(ChevronRightIcon$1, { className: `${classes.progressChevron} ${textClass} ${isExpanded ? "expanded" : ""}` }))] }), hasSubItems && isExpanded && status === "in-progress" && (jsxRuntime.jsxs("div", { className: classes.reasoningLabel, children: [jsxRuntime.jsx(SvgReasoningIcon, {}), "Working on the next step..."] })), hasSubItems && isExpanded && !isProcessingRequest && (jsxRuntime.jsx("div", { className: classes.progressSubItems, style: { maxHeight: isExpanded ? "500px" : "0", opacity: isExpanded ? 1 : 0 }, children: questionSteps.map((step, idx) => (jsxRuntime.jsx("div", { className: classes.progressSubItem, children: jsxRuntime.jsx(SubStepRenderer, { text: `${step.header}${step.sub_header ? ` - ${step.sub_header}` : ""}` }) }, idx))) })), formData && isExpanded && (jsxRuntime.jsx("div", { className: classes.stepFormContainer, children: jsxRuntime.jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters }) }))] })] }));
10417
+ return (jsxRuntime.jsxs("div", { className: classes.progressItem, children: [jsxRuntime.jsxs("div", { className: classes.progressTrack, children: [jsxRuntime.jsx("div", { className: `${classes.progressDot} ${dotClass}` }), !isLast && jsxRuntime.jsx("div", { className: `${classes.progressLine} ${lineClass}` })] }), jsxRuntime.jsxs("div", { className: classes.progressContent, children: [jsxRuntime.jsxs("div", { className: classes.progressHeader, onClick: handleToggle, children: [jsxRuntime.jsx("span", { className: `${classes.progressHeaderText} ${textClass}`, children: question }), hasSubItems && (jsxRuntime.jsx(ChevronRightIcon$1, { className: `${classes.progressChevron} ${textClass} ${isExpanded ? "expanded" : ""}` }))] }), hasSubItems && isExpanded && status === "in-progress" && (jsxRuntime.jsxs("div", { className: classes.reasoningLabel, children: [jsxRuntime.jsx(SvgReasoningIcon, {}), "Working on the next step..."] })), hasSubItems && isExpanded && !isProcessingRequest && (jsxRuntime.jsx("div", { className: classes.progressSubItems, style: { maxHeight: isExpanded ? "500px" : "0", opacity: isExpanded ? 1 : 0 }, children: questionSteps.map((step, idx) => (jsxRuntime.jsx("div", { className: classes.progressSubItem, children: jsxRuntime.jsx(SubStepRenderer, { text: `${step.header}${step.sub_header ? ` - ${step.sub_header}` : ""}` }) }, idx))) })), formData && isExpanded && (jsxRuntime.jsx("div", { className: classes.stepFormContainer, children: jsxRuntime.jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, messageIndex: `${String(chatSessionId)}_${index}` }) }))] })] }));
10306
10418
  };
10307
- const Steps = ({ steps, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, activeFormIntent = null, isRestreaming = false }) => {
10419
+ const Steps = ({ steps, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, activeFormIntent = null, isRestreaming = false, sessionId = "", chatSessionId = "" }) => {
10308
10420
  const classes = useStyles$3();
10309
10421
  React.useState(false);
10310
10422
  const hasQuestions = questions.length > 0;
@@ -10333,7 +10445,7 @@ const Steps = ({ steps, questions = [], questionsStepsMap = {}, stepFormDataMap
10333
10445
  const formDisabledForThis = activeFormIntent
10334
10446
  ? question !== activeFormIntent
10335
10447
  : isFormDisabled;
10336
- return (jsxRuntime.jsx(ProgressBarItem, { question: question, questionSteps: questionSteps, isLast: index === questions.length - 1, classes: classes, formData: formData, isFormDisabled: formDisabledForThis, isRestreaming: isRestreaming, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters }, index));
10448
+ return (jsxRuntime.jsx(ProgressBarItem, { question: question, questionSteps: questionSteps, isLast: index === questions.length - 1, classes: classes, formData: formData, isFormDisabled: formDisabledForThis, isRestreaming: isRestreaming, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, sessionId: sessionId, index: index, chatSessionId: chatSessionId }, index));
10337
10449
  }) }));
10338
10450
  };
10339
10451
 
@@ -10346,7 +10458,7 @@ const AgentResponse = ({ children }) => {
10346
10458
  // Only the active instance should process stepFormStreamData from Redux.
10347
10459
  let instanceCounter = 0;
10348
10460
  let activeTabularInstanceId = null;
10349
- const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
10461
+ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", chatSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
10350
10462
  const dispatch = reactRedux.useDispatch();
10351
10463
  const stepFormStreamData = reactRedux.useSelector((state) => state.smartBotReducer.stepFormStreamData);
10352
10464
  const thinkingContext = reactRedux.useSelector((state) => state.smartBotReducer.thinkingContext);
@@ -10827,7 +10939,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
10827
10939
  icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
10828
10940
  },
10829
10941
  ], tabPanels: [
10830
- jsxRuntime.jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted || isTimedOut, activeFormIntent: hasNewStepFormFromRestream ? activeFormIntent : null, isRestreaming: isRestreaming }),
10942
+ jsxRuntime.jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted || isTimedOut, activeFormIntent: hasNewStepFormFromRestream ? activeFormIntent : null, isRestreaming: isRestreaming, sessionId: propSessionId, chatSessionId: chatSessionId, agentId: agentId }),
10831
10943
  jsxRuntime.jsxs(AgentResponse, { children: [children, renderedWidgets.length > 0 && (jsxRuntime.jsx("div", { className: "restream-widget-content", children: renderedWidgets })), retryCountdown > 0 && (jsxRuntime.jsx("div", { style: { marginTop: "8px" }, children: jsxRuntime.jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) })), timeoutMessage && (jsxRuntime.jsx("div", { style: { marginTop: "8px" }, children: jsxRuntime.jsx(TextRenderer, { text: timeoutMessage, thinking: "" }) }))] }),
10832
10944
  ], value: tabValue }) }));
10833
10945
  };
@@ -10870,6 +10982,8 @@ const CombinedContent = ({ botData, props }) => {
10870
10982
  return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
10871
10983
  case "checkbox":
10872
10984
  return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
10985
+ case "checkboxGroup":
10986
+ return jsxRuntime.jsx(CheckboxGroupContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
10873
10987
  case "radio":
10874
10988
  return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
10875
10989
  case "button":
@@ -10905,7 +11019,7 @@ const CombinedContent = ({ botData, props }) => {
10905
11019
  const validContent = renderedContent.filter(content => content !== null);
10906
11020
  const renderCombinedContent = () => (jsxRuntime.jsx("div", { className: "combined-content-container", children: validContent.length > 0 ? (validContent.map((content, index) => (jsxRuntime.jsx("div", { className: "combined-content-item", children: content }, `wrapper-${index}`)))) : (jsxRuntime.jsx("div", { children: "No valid content to display" })) }));
10907
11021
  if (isTabEnabled) {
10908
- return (jsxRuntime.jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", questions: botData?.utilityData?.questions || [], questionsStepsMap: botData?.utilityData?.questionsStepsMap || {}, stepFormDataMap: botData?.utilityData?.stepFormDataMap || {}, isFormDisabled: isFormDisabled, sessionId: botData?.sessionId || "", botProps: props, currentMode: botData?.currentMode || "", agentId: botData?.agentId || "", children: renderCombinedContent() }));
11022
+ return (jsxRuntime.jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", questions: botData?.utilityData?.questions || [], questionsStepsMap: botData?.utilityData?.questionsStepsMap || {}, stepFormDataMap: botData?.utilityData?.stepFormDataMap || {}, isFormDisabled: isFormDisabled, sessionId: botData?.sessionId || "", chatSessionId: botData?.chatSessionId || "", botProps: props, currentMode: botData?.currentMode || "", agentId: botData?.agentId || "", children: renderCombinedContent() }));
10909
11023
  }
10910
11024
  return renderCombinedContent();
10911
11025
  };
@@ -10968,6 +11082,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
10968
11082
  return jsxRuntime.jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
10969
11083
  case "checkbox":
10970
11084
  return jsxRuntime.jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
11085
+ case "checkboxGroup":
11086
+ return jsxRuntime.jsx(CheckboxGroupContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
10971
11087
  case "radio":
10972
11088
  return jsxRuntime.jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
10973
11089
  case "button":
@@ -13606,9 +13722,9 @@ const ChatbotInput = (props) => {
13606
13722
  }, [showAnswerModeMenu]);
13607
13723
  const ANSWER_MODE_OPTIONS = [
13608
13724
  { value: "fast", label: "Fast", description: "Speed over depth" },
13609
- { value: "auto", label: "Auto", description: "Adapts depth, detail, and visuals" },
13725
+ { value: "auto", label: "Deep Analysis", description: "Adapts depth, detail, and visuals" },
13610
13726
  ];
13611
- const selectedModeOption = ANSWER_MODE_OPTIONS.find((opt) => opt.value === answerMode) || ANSWER_MODE_OPTIONS[1];
13727
+ const selectedModeOption = ANSWER_MODE_OPTIONS.find((opt) => opt.value === answerMode) || ANSWER_MODE_OPTIONS[0];
13612
13728
  return (jsxRuntime.jsx("div", { className: "chat-input-container", ref: chatInputContainerRef, onClick: (e) => {
13613
13729
  // Focus editor when clicking anywhere in the input container
13614
13730
  // unless clicking on a button or interactive element
@@ -15101,7 +15217,7 @@ const SmartBot = (props) => {
15101
15217
  const [filterOptions, setFilterOptions] = React.useState([]);
15102
15218
  const [savedFilterSets, setSavedFilterSets] = React.useState([]);
15103
15219
  const [selectedFilterSet, setSelectedFilterSet] = React.useState(null);
15104
- const [answerMode, setAnswerMode] = React.useState("auto");
15220
+ const [answerMode, setAnswerMode] = React.useState("fast");
15105
15221
  const [chatBotWidth, setChatBotWidth] = React.useState(null);
15106
15222
  const [tabList, setTabList] = React.useState([]);
15107
15223
  React.useRef(0);
@@ -16103,10 +16219,50 @@ const SmartBot = (props) => {
16103
16219
  }
16104
16220
  fetchConversations(null, "agent");
16105
16221
  }, [renameConversation, deleteConversation, fetchConversations]);
16222
+ // Ref to the SmartBot wrapper so we can scope outside-click detection and the
16223
+ // collapse-button query to this (local) chatbot instance only.
16224
+ const smartBotWrapperRef = React.useRef(null);
16225
+ // Collapse the expanded/docked chatbot into the small draggable panel by
16226
+ // triggering impact-ui's header "Collapse chatbot" control. That button is
16227
+ // only present while expanded (its label becomes "Expand chatbot" once
16228
+ // collapsed), so this is a safe no-op when already collapsed.
16229
+ const collapseChatBotIfExpanded = React.useCallback(() => {
16230
+ const root = smartBotWrapperRef.current;
16231
+ if (!root)
16232
+ return;
16233
+ const collapseBtn = root.querySelector('button[aria-label="Collapse chatbot"]');
16234
+ if (collapseBtn)
16235
+ collapseBtn.click();
16236
+ }, []);
16237
+ // Auto-collapse to draggable mode when the user interacts outside the bot.
16238
+ React.useEffect(() => {
16239
+ const handleOutsideInteraction = (e) => {
16240
+ const root = smartBotWrapperRef.current;
16241
+ if (!root)
16242
+ return;
16243
+ if (root.contains(e.target))
16244
+ return; // interaction inside the bot → ignore
16245
+ collapseChatBotIfExpanded();
16246
+ };
16247
+ document.addEventListener("mousedown", handleOutsideInteraction, true);
16248
+ return () => {
16249
+ document.removeEventListener("mousedown", handleOutsideInteraction, true);
16250
+ };
16251
+ }, [collapseChatBotIfExpanded]);
16252
+ // Auto-collapse on route changes (skip the initial mount so freshly opening
16253
+ // the bot doesn't immediately collapse it).
16254
+ const hasMountedForCollapseRef = React.useRef(false);
16255
+ React.useEffect(() => {
16256
+ if (!hasMountedForCollapseRef.current) {
16257
+ hasMountedForCollapseRef.current = true;
16258
+ return;
16259
+ }
16260
+ collapseChatBotIfExpanded();
16261
+ }, [location.pathname, collapseChatBotIfExpanded]);
16106
16262
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [partialClose && (minimizedStreamData?.isStreaming || minimizedStreamData?.stepStatus === "step_form") && (jsxRuntime.jsx(MinimizedChatWidget, { onExpand: () => {
16107
16263
  setShowModal(true);
16108
16264
  setPartialClose(false);
16109
- } })), jsxRuntime.jsxs("div", { className: `${classes.agentStyleOverride} ${partialClose ? classes.hideBotStyle : ""} `, children: [jsxRuntime.jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(impactUiV3.ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: false, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsxRuntime.jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
16265
+ } })), jsxRuntime.jsxs("div", { ref: smartBotWrapperRef, className: `${classes.agentStyleOverride} ${partialClose || !(showModal || forceOpen) ? classes.hideBotStyle : ""} `, children: [jsxRuntime.jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(impactUiV3.ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: false, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsxRuntime.jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
16110
16266
  // onSaveClick={saveCurrentChat}
16111
16267
  savedFilterSets: savedFilterSets, selectedFilterSet: selectedFilterSet, onFilterSetSelect: (filterSet) => setSelectedFilterSet(filterSet), onClearFilterSet: () => setSelectedFilterSet(null), onTriggerRefresh: triggerRefreshAction, answerMode: answerMode, setAnswerMode: setAnswerMode })) : showSavedFilters ? jsxRuntime.jsx(jsxRuntime.Fragment, {}) : null, isChatBotOpen: showModal || forceOpen, historyPanelData: historyPanelData, onHistorySearchChange: (params) => { console.log("History Search Change", params); }, onHistorySelectConversation: (params) => {
16112
16268
  console.log("History Select Conversation", params);