impact-chatbot 2.3.88 → 2.3.89

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,
@@ -7469,6 +7489,61 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
7469
7489
  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
7490
  };
7471
7491
 
7492
+ const CheckboxGroupContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7493
+ const formKey = `${messageIndex}_${bodyText?.paramName}`;
7494
+ const classes = useStyles$a();
7495
+ const { label, orientation, options = [], defaultSelected, minOptions, maxOptions, isRequired, isDisabled, } = bodyText || {};
7496
+ const min = minOptions ?? 1;
7497
+ const max = maxOptions ?? options.length;
7498
+ const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
7499
+ const chatbotContextRef = React.useRef(chatbotContext);
7500
+ chatbotContextRef.current = chatbotContext;
7501
+ const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
7502
+ const dispatch = reactRedux.useDispatch();
7503
+ const [selected, setSelected] = React.useState(() => {
7504
+ const persisted = persistedFormValues?.[formKey];
7505
+ if (Array.isArray(persisted))
7506
+ return persisted;
7507
+ return Array.isArray(defaultSelected) ? defaultSelected : [];
7508
+ });
7509
+ if (lodash.isEmpty(bodyText))
7510
+ return null;
7511
+ const groupDisabled = isDisabled || isFormDisabled;
7512
+ const dispatchSelection = (newValues) => {
7513
+ const latestContext = chatbotContextRef.current;
7514
+ dispatch(smartBotActions.setChatbotContext({
7515
+ ...latestContext,
7516
+ [bodyText?.paramName]: {
7517
+ ...latestContext?.[bodyText?.paramName],
7518
+ [bodyText?.paramName]: newValues,
7519
+ updated: true,
7520
+ },
7521
+ }));
7522
+ dispatch(smartBotActions.setPersistedFormValues({ [formKey]: newValues }));
7523
+ };
7524
+ const handleChange = (optionValue, isChecked) => {
7525
+ try {
7526
+ const newValues = isChecked
7527
+ ? [...selected, optionValue]
7528
+ : selected.filter((val) => val !== optionValue);
7529
+ setSelected(newValues);
7530
+ dispatchSelection(newValues);
7531
+ }
7532
+ catch (error) {
7533
+ console.error("Error in checkboxGroup handleChange", error);
7534
+ }
7535
+ };
7536
+ const isRow = orientation === "row";
7537
+ const overMax = selected.length > max;
7538
+ const belowMin = isRequired && selected.length < min;
7539
+ return (jsxRuntime.jsxs("div", { style: { width: "100%", marginTop: "10px" }, children: [label && (jsxRuntime.jsxs("p", { className: classes.radioGrpLabel, children: [label, isRequired ? " *" : ""] })), jsxRuntime.jsx("div", { style: {
7540
+ display: "flex",
7541
+ flexDirection: isRow ? "row" : "column",
7542
+ flexWrap: isRow ? "wrap" : "nowrap",
7543
+ gap: isRow ? "16px" : "8px",
7544
+ }, 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" : ""}` }))] }));
7545
+ };
7546
+
7472
7547
  const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7473
7548
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7474
7549
  const classes = useStyles$a();
@@ -7752,6 +7827,38 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7752
7827
  return false;
7753
7828
  });
7754
7829
  }, [formData, chatbotContext, persistedFormValues, messageIndex]);
7830
+ // Validate checkboxGroup fields against their minOptions/maxOptions bounds.
7831
+ // A required group must have selectedCount within [min, max]; any group (even
7832
+ // non-required) must not exceed max. Blocks submit when out of bounds.
7833
+ const checkboxGroupsValid = React.useMemo(() => {
7834
+ if (!formData || !Array.isArray(formData))
7835
+ return true;
7836
+ const groups = formData.filter((item) => item?.type === "checkboxGroup");
7837
+ return groups.every((item) => {
7838
+ const data = item.data || {};
7839
+ const param = data.param_name;
7840
+ const options = data.options || [];
7841
+ const min = data.minOptions ?? 1;
7842
+ const max = data.maxOptions ?? options.length;
7843
+ // Resolve current selection: chatbotContext first, then persistedFormValues
7844
+ let selectedValues = [];
7845
+ const ctx = chatbotContext?.[param];
7846
+ if (ctx && ctx.updated && Array.isArray(ctx[param])) {
7847
+ selectedValues = ctx[param];
7848
+ }
7849
+ else {
7850
+ const persisted = persistedFormValues?.[`${messageIndex}_${param}`];
7851
+ if (Array.isArray(persisted))
7852
+ selectedValues = persisted;
7853
+ }
7854
+ const count = selectedValues.length;
7855
+ if (count > max)
7856
+ return false;
7857
+ if (data.isRequired && count < min)
7858
+ return false;
7859
+ return true;
7860
+ });
7861
+ }, [formData, chatbotContext, persistedFormValues, messageIndex]);
7755
7862
  // Extract select-type filter configs from formData for cross-filter cascading
7756
7863
  // and sort them based on the filters_hierarchy_order from tenant config
7757
7864
  const crossFilterConfigs = React.useMemo(() => {
@@ -7860,10 +7967,12 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7860
7967
  return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7861
7968
  case "checkbox":
7862
7969
  return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7970
+ case "checkboxGroup":
7971
+ return jsxRuntime.jsx(CheckboxGroupContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7863
7972
  case "radio":
7864
7973
  return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7865
7974
  case "button":
7866
- return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled, formParamNames: formParamNames, messageIndex: messageIndex }, key);
7975
+ return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled && checkboxGroupsValid, formParamNames: formParamNames, messageIndex: messageIndex }, key);
7867
7976
  case "input":
7868
7977
  return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7869
7978
  case "image":
@@ -8259,7 +8368,7 @@ const getQuestionStatus$1 = (questionSteps) => {
8259
8368
  /**
8260
8369
  * Renders a single progress bar item (main point + sub-items)
8261
8370
  */
8262
- const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined, botProps = null, currentMode = "", agentId = "", sessionId = "" }) => {
8371
+ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined, botProps = null, currentMode = "", agentId = "", sessionId = "", index = 0, chatSessionId = "" }) => {
8263
8372
  const status = getQuestionStatus$1(questionSteps);
8264
8373
  const animatedCountRef = React.useRef(0);
8265
8374
  const [isExpanded, setIsExpanded] = React.useState(true);
@@ -8293,9 +8402,9 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
8293
8402
  if (animatedCountRef.current >= arr.length && onAllSubItemsAnimated) {
8294
8403
  onAllSubItemsAnimated();
8295
8404
  }
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 }) }))] })] }));
8405
+ } }) }, 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
8406
  };
8298
- const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, botProps = null, agentId = "", sessionId = "", }) => {
8407
+ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, botProps = null, agentId = "", sessionId = "", chatSessionId = "", }) => {
8299
8408
  const classes = useStyles$4();
8300
8409
  React.useState(false);
8301
8410
  const [showThinking, setShowThinking] = React.useState(false);
@@ -8378,7 +8487,7 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
8378
8487
  const showSavedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.showSavedFilters : true;
8379
8488
  const preSelectedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.preSelectedFilters : null;
8380
8489
  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
8490
+ 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
8491
  ? () => setShowThinking(true)
8383
8492
  : undefined }, index));
8384
8493
  }), showThinking && !done && (jsxRuntime.jsx("div", { style: {
@@ -8406,6 +8515,8 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
8406
8515
  return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8407
8516
  case "checkbox":
8408
8517
  return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8518
+ case "checkboxGroup":
8519
+ return jsxRuntime.jsx(CheckboxGroupContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8409
8520
  case "select":
8410
8521
  return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
8411
8522
  case "slider":
@@ -8440,7 +8551,7 @@ const AgentResponse$1 = (props) => {
8440
8551
  };
8441
8552
 
8442
8553
  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;
8554
+ const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, isRetrying, botProps, agentId, sessionId, chatSessionId, } = props;
8444
8555
  const dispatch = reactRedux.useDispatch();
8445
8556
  const thinkingContext = reactRedux.useSelector((state) => state.smartBotReducer.thinkingContext);
8446
8557
  const streamStartTimeRef = React.useRef(thinkingContext?.streamStartTime);
@@ -8504,7 +8615,7 @@ const StepsResponseTab = (props) => {
8504
8615
  icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
8505
8616
  },
8506
8617
  ], 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 }),
8618
+ 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
8619
  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
8620
  ], value: tabValue }) }));
8510
8621
  };
@@ -10076,7 +10187,7 @@ const StreamedContent = ({ botData, botProps }) => {
10076
10187
  * @returns {JSX.Element} Rendered content with optional blinking cursor
10077
10188
  */
10078
10189
  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: "" }) }))] }));
10190
+ 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
10191
  };
10081
10192
  if (currentMode === "agent") {
10082
10193
  return renderContent();
@@ -10272,7 +10383,7 @@ const getQuestionStatus = (questionSteps) => {
10272
10383
  /**
10273
10384
  * Renders a single progress bar item (main point + sub-items)
10274
10385
  */
10275
- const ProgressBarItem = ({ question, questionSteps, isLast, classes, formData, isFormDisabled, isRestreaming = false, showSavedFilters = true, preSelectedFilters = null }) => {
10386
+ const ProgressBarItem = ({ question, questionSteps, isLast, classes, formData, isFormDisabled, isRestreaming = false, showSavedFilters = true, preSelectedFilters = null, sessionId = "", index = 0, chatSessionId = "" }) => {
10276
10387
  const baseStatus = getQuestionStatus(questionSteps);
10277
10388
  // When restreaming and this is the last item, show as in-progress
10278
10389
  const status = (isRestreaming && isLast) ? "in-progress" : baseStatus;
@@ -10302,9 +10413,9 @@ const ProgressBarItem = ({ question, questionSteps, isLast, classes, formData, i
10302
10413
  setIsExpanded(true);
10303
10414
  }
10304
10415
  }, [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 }) }))] })] }));
10416
+ 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
10417
  };
10307
- const Steps = ({ steps, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, activeFormIntent = null, isRestreaming = false }) => {
10418
+ const Steps = ({ steps, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, activeFormIntent = null, isRestreaming = false, sessionId = "", chatSessionId = "" }) => {
10308
10419
  const classes = useStyles$3();
10309
10420
  React.useState(false);
10310
10421
  const hasQuestions = questions.length > 0;
@@ -10333,7 +10444,7 @@ const Steps = ({ steps, questions = [], questionsStepsMap = {}, stepFormDataMap
10333
10444
  const formDisabledForThis = activeFormIntent
10334
10445
  ? question !== activeFormIntent
10335
10446
  : 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));
10447
+ 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
10448
  }) }));
10338
10449
  };
10339
10450
 
@@ -10346,7 +10457,7 @@ const AgentResponse = ({ children }) => {
10346
10457
  // Only the active instance should process stepFormStreamData from Redux.
10347
10458
  let instanceCounter = 0;
10348
10459
  let activeTabularInstanceId = null;
10349
- const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
10460
+ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", chatSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
10350
10461
  const dispatch = reactRedux.useDispatch();
10351
10462
  const stepFormStreamData = reactRedux.useSelector((state) => state.smartBotReducer.stepFormStreamData);
10352
10463
  const thinkingContext = reactRedux.useSelector((state) => state.smartBotReducer.thinkingContext);
@@ -10827,7 +10938,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
10827
10938
  icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
10828
10939
  },
10829
10940
  ], tabPanels: [
10830
- jsxRuntime.jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted || isTimedOut, activeFormIntent: hasNewStepFormFromRestream ? activeFormIntent : null, isRestreaming: isRestreaming }),
10941
+ 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
10942
  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
10943
  ], value: tabValue }) }));
10833
10944
  };
@@ -10870,6 +10981,8 @@ const CombinedContent = ({ botData, props }) => {
10870
10981
  return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
10871
10982
  case "checkbox":
10872
10983
  return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
10984
+ case "checkboxGroup":
10985
+ return jsxRuntime.jsx(CheckboxGroupContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
10873
10986
  case "radio":
10874
10987
  return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, messageIndex: botData.messageIndex }, key);
10875
10988
  case "button":
@@ -10905,7 +11018,7 @@ const CombinedContent = ({ botData, props }) => {
10905
11018
  const validContent = renderedContent.filter(content => content !== null);
10906
11019
  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
11020
  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() }));
11021
+ 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
11022
  }
10910
11023
  return renderCombinedContent();
10911
11024
  };
@@ -10968,6 +11081,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
10968
11081
  return jsxRuntime.jsx(DateRangePickerContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
10969
11082
  case "checkbox":
10970
11083
  return jsxRuntime.jsx(CheckboxContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
11084
+ case "checkboxGroup":
11085
+ return jsxRuntime.jsx(CheckboxGroupContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
10971
11086
  case "radio":
10972
11087
  return jsxRuntime.jsx(RadioContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
10973
11088
  case "button":
@@ -16103,10 +16218,50 @@ const SmartBot = (props) => {
16103
16218
  }
16104
16219
  fetchConversations(null, "agent");
16105
16220
  }, [renameConversation, deleteConversation, fetchConversations]);
16221
+ // Ref to the SmartBot wrapper so we can scope outside-click detection and the
16222
+ // collapse-button query to this (local) chatbot instance only.
16223
+ const smartBotWrapperRef = React.useRef(null);
16224
+ // Collapse the expanded/docked chatbot into the small draggable panel by
16225
+ // triggering impact-ui's header "Collapse chatbot" control. That button is
16226
+ // only present while expanded (its label becomes "Expand chatbot" once
16227
+ // collapsed), so this is a safe no-op when already collapsed.
16228
+ const collapseChatBotIfExpanded = React.useCallback(() => {
16229
+ const root = smartBotWrapperRef.current;
16230
+ if (!root)
16231
+ return;
16232
+ const collapseBtn = root.querySelector('button[aria-label="Collapse chatbot"]');
16233
+ if (collapseBtn)
16234
+ collapseBtn.click();
16235
+ }, []);
16236
+ // Auto-collapse to draggable mode when the user interacts outside the bot.
16237
+ React.useEffect(() => {
16238
+ const handleOutsideInteraction = (e) => {
16239
+ const root = smartBotWrapperRef.current;
16240
+ if (!root)
16241
+ return;
16242
+ if (root.contains(e.target))
16243
+ return; // interaction inside the bot → ignore
16244
+ collapseChatBotIfExpanded();
16245
+ };
16246
+ document.addEventListener("mousedown", handleOutsideInteraction, true);
16247
+ return () => {
16248
+ document.removeEventListener("mousedown", handleOutsideInteraction, true);
16249
+ };
16250
+ }, [collapseChatBotIfExpanded]);
16251
+ // Auto-collapse on route changes (skip the initial mount so freshly opening
16252
+ // the bot doesn't immediately collapse it).
16253
+ const hasMountedForCollapseRef = React.useRef(false);
16254
+ React.useEffect(() => {
16255
+ if (!hasMountedForCollapseRef.current) {
16256
+ hasMountedForCollapseRef.current = true;
16257
+ return;
16258
+ }
16259
+ collapseChatBotIfExpanded();
16260
+ }, [location.pathname, collapseChatBotIfExpanded]);
16106
16261
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [partialClose && (minimizedStreamData?.isStreaming || minimizedStreamData?.stepStatus === "step_form") && (jsxRuntime.jsx(MinimizedChatWidget, { onExpand: () => {
16107
16262
  setShowModal(true);
16108
16263
  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,
16264
+ } })), jsxRuntime.jsxs("div", { ref: smartBotWrapperRef, 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,
16110
16265
  // onSaveClick={saveCurrentChat}
16111
16266
  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
16267
  console.log("History Select Conversation", params);