impact-chatbot 2.3.82 → 2.3.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -326,9 +326,9 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
326
326
  userType: "bot",
327
327
  userName: userName,
328
328
  bodyText: data?.response,
329
- headerTitle: data?.response_heading,
329
+ headerTitle: "",
330
330
  thinkingResponse: data?.thinkingResponse,
331
- noShowHeaderTitle: false,
331
+ noShowHeaderTitle: true,
332
332
  bodyType: "text",
333
333
  };
334
334
  case "stream":
@@ -592,7 +592,8 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
592
592
  timeStamp: timeString,
593
593
  userType: "bot",
594
594
  userName: userName,
595
- headerTitle: data?.response_heading || "",
595
+ headerTitle: "",
596
+ noShowHeaderTitle: true,
596
597
  bodyType: "image",
597
598
  bodyText: data?.image || data,
598
599
  };
@@ -5009,7 +5010,7 @@ const ChipsContent = ({ bodyText, props }) => {
5009
5010
  const classes = useStyles$a();
5010
5011
  const globalClasses = globalStyles();
5011
5012
  return (jsx("div", { className: `${globalClasses.flexRow} ${globalClasses.flexWrap} ${globalClasses.gap} ${globalClasses.verticalAlignCenter}`, children: bodyText.map((data, index) => {
5012
- const callBack = data.interactable
5013
+ const callBack = data.interactable && props
5013
5014
  ? Object.entries(props).filter((entry) => entry[0] === data.actionName)?.[0]?.[1]
5014
5015
  : null;
5015
5016
  return (jsx(Typography, { component: "span", variant: "body1", className: `${classes.gptChips} ${data.interactable ? globalClasses.cursorPointer : ""}`, onClick: () => {
@@ -5076,7 +5077,7 @@ const QuestionsContent = ({ bodyText, props }) => {
5076
5077
  };
5077
5078
  };
5078
5079
  return (jsx("div", { className: `${globalClasses.flexRow} ${globalClasses.flexColumn} ${classes.gptQuestionContainer}`, children: bodyText.map((data, index) => {
5079
- const callBack = data.interactable
5080
+ const callBack = data.interactable && props
5080
5081
  ? Object.entries(props).filter((entry) => entry[0] === data.actionName)?.[0]?.[1]
5081
5082
  : null;
5082
5083
  return (jsxs("div", { className: `${globalClasses.layoutAlignStart} ${classes.gptQuestionBlock}`, style: {
@@ -6827,6 +6828,36 @@ const fetchCrossFilterOptions = async (filterConfig, existingSelections = [], al
6827
6828
  }
6828
6829
  };
6829
6830
 
6831
+ const useStyles$6 = makeStyles(() => ({
6832
+ htmlContentContainer: {
6833
+ width: "100%",
6834
+ "& *": {
6835
+ boxSizing: "border-box",
6836
+ },
6837
+ },
6838
+ }));
6839
+ const HtmlContent = ({ bodyText }) => {
6840
+ const classes = useStyles$6();
6841
+ const containerRef = useRef(null);
6842
+ const content = bodyText?.content || "";
6843
+ useEffect(() => {
6844
+ if (containerRef.current && content) {
6845
+ const sanitizedHtml = DOMPurify.sanitize(content, {
6846
+ ADD_TAGS: ["style", "details", "summary"],
6847
+ ADD_ATTR: ["open", "target", "rel", "class", "style"],
6848
+ ALLOW_DATA_ATTR: true,
6849
+ FORCE_BODY: true,
6850
+ WHOLE_DOCUMENT: false,
6851
+ });
6852
+ containerRef.current.innerHTML = sanitizedHtml;
6853
+ }
6854
+ }, [content]);
6855
+ if (!content) {
6856
+ return null;
6857
+ }
6858
+ return (jsx("div", { ref: containerRef, className: classes.htmlContentContainer }));
6859
+ };
6860
+
6830
6861
  const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6831
6862
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
6832
6863
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
@@ -7372,8 +7403,9 @@ const STEP_FORM_TIMEOUT_KEY = "__stepFormTimedOut";
7372
7403
  * @param {Array} props.formData - Array of raw widget_data items from step_form chunk
7373
7404
  * @param {number} props.messageIndex - Index for form state persistence keys
7374
7405
  */
7375
- const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, showSavedFilters = true, preSelectedFilters = null }) => {
7406
+ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, showSavedFilters = true, preSelectedFilters = null, botProps = null, currentMode = "", agentId = "", sessionId = "", }) => {
7376
7407
  const dispatch = useDispatch();
7408
+ const classes = useStyles$a();
7377
7409
  const savedFilterSets = useSelector((state) => state.smartBotReducer.savedFilterSets);
7378
7410
  const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
7379
7411
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -7646,7 +7678,11 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7646
7678
  case "text":
7647
7679
  return jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
7648
7680
  case "chips":
7649
- return jsx(ChipsContent, { bodyText: parsedData.bodyText, props: {} }, key);
7681
+ return parsedData.isMultiSelect ? (jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: botProps }, key)) : (jsx(ChipsContent, { bodyText: parsedData.bodyText, props: botProps }, key));
7682
+ case "questions":
7683
+ return jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: botProps }, key);
7684
+ case "html":
7685
+ return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
7650
7686
  case "table":
7651
7687
  return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
7652
7688
  case "graph":
@@ -7677,12 +7713,18 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7677
7713
  const buttonItems = [];
7678
7714
  formData.forEach((item, index) => {
7679
7715
  try {
7680
- const parsedData = parseResponse(item, item.type, "", "", true);
7716
+ const parsedData = parseResponse(item, item.type, agentId, currentMode, true, sessionId);
7681
7717
  if (!parsedData)
7682
7718
  return;
7683
- const rendered = renderItem(parsedData, index);
7684
- if (!rendered)
7719
+ const body = renderItem(parsedData, index);
7720
+ if (!body)
7685
7721
  return;
7722
+ // Skip the block header when it is just a repeat of the label the widget
7723
+ // renders itself (parseResponse derives headerTitle from label for inputs).
7724
+ const showHeaderTitle = !parsedData?.noShowHeaderTitle &&
7725
+ Boolean(parsedData?.headerTitle?.length) &&
7726
+ parsedData.headerTitle !== parsedData?.bodyText?.label;
7727
+ const rendered = showHeaderTitle ? (jsxs(Fragment$1, { children: [jsx("div", { className: `${classes.chatbotText} ${classes.boldText} ${classes.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }), body] }, `step-form-block-${index}`)) : (body);
7686
7728
  if (parsedData.bodyType === "button") {
7687
7729
  buttonItems.push(rendered);
7688
7730
  }
@@ -7705,7 +7747,7 @@ const resetStepFormTimeoutFlag = () => {
7705
7747
  sessionStorage.removeItem(STEP_FORM_TIMEOUT_KEY);
7706
7748
  };
7707
7749
 
7708
- const useStyles$6 = makeStyles(() => ({
7750
+ const useStyles$5 = makeStyles(() => ({
7709
7751
  subStepMarkdown: {
7710
7752
  // Inherit font styles from parent (.progressSubItem)
7711
7753
  fontFamily: 'inherit',
@@ -7779,14 +7821,14 @@ const preprocessSubStepMarkdown = (content) => {
7779
7821
  .trim();
7780
7822
  };
7781
7823
  const SubStepRenderer = ({ text }) => {
7782
- const classes = useStyles$6();
7824
+ const classes = useStyles$5();
7783
7825
  if (!text)
7784
7826
  return null;
7785
7827
  const processed = preprocessSubStepMarkdown(text);
7786
7828
  return (jsx("div", { className: classes.subStepMarkdown, children: jsx(ReactMarkdown, { remarkPlugins: [remarkGfm, remarkBreaks], children: processed }) }));
7787
7829
  };
7788
7830
 
7789
- const useStyles$5 = makeStyles$1((theme) => ({
7831
+ const useStyles$4 = makeStyles$1((theme) => ({
7790
7832
  "@global": {
7791
7833
  "@keyframes progressDotPulse": {
7792
7834
  "0%": {
@@ -8060,7 +8102,7 @@ const getQuestionStatus$1 = (questionSteps) => {
8060
8102
  /**
8061
8103
  * Renders a single progress bar item (main point + sub-items)
8062
8104
  */
8063
- const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined }) => {
8105
+ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined, botProps = null, currentMode = "", agentId = "", sessionId = "" }) => {
8064
8106
  const status = getQuestionStatus$1(questionSteps);
8065
8107
  const animatedCountRef = useRef(0);
8066
8108
  const [isExpanded, setIsExpanded] = useState(true);
@@ -8094,10 +8136,10 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
8094
8136
  if (animatedCountRef.current >= arr.length && onAllSubItemsAnimated) {
8095
8137
  onAllSubItemsAnimated();
8096
8138
  }
8097
- } }) }, idx))) })), formData && isExpanded && (jsx("div", { className: classes.stepFormContainer, children: jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters }) }))] })] }));
8139
+ } }) }, idx))) })), formData && isExpanded && (jsx("div", { className: classes.stepFormContainer, children: jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId }) }))] })] }));
8098
8140
  };
8099
- const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, }) => {
8100
- const classes = useStyles$5();
8141
+ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, botProps = null, agentId = "", sessionId = "", }) => {
8142
+ const classes = useStyles$4();
8101
8143
  useState(false);
8102
8144
  const [showThinking, setShowThinking] = useState(false);
8103
8145
  // Determine if last question is fully completed (all sub-steps done)
@@ -8179,7 +8221,7 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
8179
8221
  const showSavedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.showSavedFilters : true;
8180
8222
  const preSelectedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.preSelectedFilters : null;
8181
8223
  const isLast = index === questions.length - 1;
8182
- return (jsx(ProgressBarItem$1, { question: question, questionSteps: questionSteps, isLast: isLast && !showThinking, classes: classes, formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, onAllSubItemsAnimated: isLast && lastQuestionCompleted && !done
8224
+ return (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
8183
8225
  ? () => setShowThinking(true)
8184
8226
  : undefined }, index));
8185
8227
  }), showThinking && !done && (jsx("div", { style: {
@@ -8187,36 +8229,6 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
8187
8229
  }, children: jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
8188
8230
  };
8189
8231
 
8190
- const useStyles$4 = makeStyles(() => ({
8191
- htmlContentContainer: {
8192
- width: "100%",
8193
- "& *": {
8194
- boxSizing: "border-box",
8195
- },
8196
- },
8197
- }));
8198
- const HtmlContent = ({ bodyText }) => {
8199
- const classes = useStyles$4();
8200
- const containerRef = useRef(null);
8201
- const content = bodyText?.content || "";
8202
- useEffect(() => {
8203
- if (containerRef.current && content) {
8204
- const sanitizedHtml = DOMPurify.sanitize(content, {
8205
- ADD_TAGS: ["style", "details", "summary"],
8206
- ADD_ATTR: ["open", "target", "rel", "class", "style"],
8207
- ALLOW_DATA_ATTR: true,
8208
- FORCE_BODY: true,
8209
- WHOLE_DOCUMENT: false,
8210
- });
8211
- containerRef.current.innerHTML = sanitizedHtml;
8212
- }
8213
- }, [content]);
8214
- if (!content) {
8215
- return null;
8216
- }
8217
- return (jsx("div", { ref: containerRef, className: classes.htmlContentContainer }));
8218
- };
8219
-
8220
8232
  const renderWidgetItem = (item, index, isFormDisabled) => {
8221
8233
  try {
8222
8234
  const parsedData = parseResponse(item, item.type, "", "", true);
@@ -8268,7 +8280,7 @@ const AgentResponse$1 = (props) => {
8268
8280
  };
8269
8281
 
8270
8282
  const StepsResponseTab = (props) => {
8271
- const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, isRetrying, } = props;
8283
+ const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, isRetrying, botProps, agentId, sessionId, } = props;
8272
8284
  const dispatch = useDispatch();
8273
8285
  const thinkingContext = useSelector((state) => state.smartBotReducer.thinkingContext);
8274
8286
  const streamStartTimeRef = useRef(thinkingContext?.streamStartTime);
@@ -8332,7 +8344,7 @@ const StepsResponseTab = (props) => {
8332
8344
  icon: jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
8333
8345
  },
8334
8346
  ], tabPanels: [
8335
- 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 }),
8347
+ 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 }),
8336
8348
  jsxs(Fragment, { children: [jsx(AgentResponse$1, { content: content, isStreaming: isStreaming, streamingWidgetData: streamingWidgetData, isFormDisabled: isFormDisabled || isTimedOut }), timeoutMessage && (jsx("div", { style: { marginTop: "8px", padding: "0 8px" }, children: jsx(TextRenderer, { text: timeoutMessage, thinking: "" }) }))] }),
8337
8349
  ], value: tabValue }) }));
8338
8350
  };
@@ -8514,7 +8526,7 @@ const streamStateMap = new Map();
8514
8526
  * @param {React.RefObject} botData.utilityObject.chatBodyRef - Ref to chat body element
8515
8527
  * @param {Function} botData.utilityObject.setChatDataState - Function to update chat data state
8516
8528
  */
8517
- const StreamedContent = ({ botData }) => {
8529
+ const StreamedContent = ({ botData, botProps }) => {
8518
8530
  const { activeConversationId, currentMode, chatDataRef, chatBodyRef, setChatDataState, chatDataInfoRef, setLoader = (params) => { }, processResponse = (params) => { }, setThinkingContent, thinkingContent, isThinking: isThinkingFromParent, setIsThinking: setIsThinkingFromParent, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, baseUrl, setNavSessionId } = botData.utilityObject || {};
8519
8531
  const classes = useStyles$7();
8520
8532
  useStyles$a();
@@ -9693,8 +9705,13 @@ const StreamedContent = ({ botData }) => {
9693
9705
  }, 1000);
9694
9706
  }
9695
9707
  }, [isStreamingDone, thinkingTime, activeConversationId]);
9708
+ // Show/hide the stop (cancel execution) icon while the stream is active.
9709
+ // Gate on state only - sourceRef is a ref, so mutating it never re-runs this
9710
+ // effect. Relying on it meant that if the source wasn't assigned yet on the
9711
+ // first run, isStop was set to false and never re-evaluated for the rest of
9712
+ // the stream, leaving the cancel button hidden.
9696
9713
  useEffect(() => {
9697
- if (sourceRef.current && isStreaming) {
9714
+ if (isStreaming && !isStreamingDone) {
9698
9715
  setIsStop(true);
9699
9716
  setFunctionsState({
9700
9717
  ...functionsState,
@@ -9705,7 +9722,7 @@ const StreamedContent = ({ botData }) => {
9705
9722
  else {
9706
9723
  setIsStop(false);
9707
9724
  }
9708
- }, [isStreaming]);
9725
+ }, [isStreaming, isStreamingDone]);
9709
9726
  /**
9710
9727
  * Aborts the current streaming connection
9711
9728
  */
@@ -9718,10 +9735,12 @@ const StreamedContent = ({ botData }) => {
9718
9735
  setRetryCountdown(0);
9719
9736
  }
9720
9737
  retryCountRef.current = MAX_RETRY_COUNT; // Exhaust retries so no further auto-retries happen
9721
- if (sourceRef.current && isStreaming) {
9738
+ if (isStreaming) {
9722
9739
  setWasStreamingAborted(true);
9723
9740
  wasStreamingAbortedRef.current = true;
9724
- sourceRef.current.close();
9741
+ if (sourceRef.current) {
9742
+ sourceRef.current.close();
9743
+ }
9725
9744
  setIsStreaming(false);
9726
9745
  setIsStreamingDone(true);
9727
9746
  // Mark as completed+aborted so tab-switch remounts don't restart the stream.
@@ -9881,7 +9900,7 @@ const StreamedContent = ({ botData }) => {
9881
9900
  * @returns {JSX.Element} Rendered content with optional blinking cursor
9882
9901
  */
9883
9902
  const renderContent = () => {
9884
- return (jsxs("div", { className: classes.streamContainer, children: [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 }), isRetrying && (jsx("div", { className: classes.retryContainer, children: jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) }))] }));
9903
+ return (jsxs("div", { className: classes.streamContainer, children: [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 && (jsx("div", { className: classes.retryContainer, children: jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) }))] }));
9885
9904
  };
9886
9905
  if (currentMode === "agent") {
9887
9906
  return renderContent();
@@ -10151,8 +10170,9 @@ const AgentResponse = ({ children }) => {
10151
10170
  // Only the active instance should process stepFormStreamData from Redux.
10152
10171
  let instanceCounter = 0;
10153
10172
  let activeTabularInstanceId = null;
10154
- const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "" }) => {
10173
+ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
10155
10174
  const dispatch = useDispatch();
10175
+ const chatClasses = useStyles$a();
10156
10176
  const stepFormStreamData = useSelector((state) => state.smartBotReducer.stepFormStreamData);
10157
10177
  const thinkingContext = useSelector((state) => state.smartBotReducer.thinkingContext);
10158
10178
  const streamStartTimeRef = useRef(thinkingContext?.streamStartTime);
@@ -10236,40 +10256,55 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
10236
10256
  };
10237
10257
  }, []);
10238
10258
  // Render a widget item from SSE data
10259
+ const renderWidgetBody = (parsedData, key) => {
10260
+ switch (parsedData.bodyType) {
10261
+ case "text":
10262
+ return jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
10263
+ case "chips":
10264
+ return parsedData.isMultiSelect ? (jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: botProps }, key)) : (jsx(ChipsContent, { bodyText: parsedData.bodyText, props: botProps }, key));
10265
+ case "questions":
10266
+ return jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: botProps }, key);
10267
+ case "image":
10268
+ return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
10269
+ case "table":
10270
+ return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
10271
+ case "graph":
10272
+ return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
10273
+ case "radio":
10274
+ return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10275
+ case "checkbox":
10276
+ return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10277
+ case "select":
10278
+ return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10279
+ case "slider":
10280
+ return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10281
+ case "button":
10282
+ return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10283
+ case "input":
10284
+ return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10285
+ case "datePicker":
10286
+ return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10287
+ case "dateRangePicker":
10288
+ return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10289
+ case "html":
10290
+ return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
10291
+ default:
10292
+ return null;
10293
+ }
10294
+ };
10239
10295
  const renderWidget = (item, index) => {
10240
10296
  try {
10241
- const parsedData = parseResponse(item, item.type, "", "", true);
10297
+ const parsedData = parseResponse(item, item.type, agentId, currentMode, true, propSessionId);
10242
10298
  if (!parsedData)
10243
10299
  return null;
10244
10300
  const key = `restream-widget-${index}`;
10245
- switch (parsedData.bodyType) {
10246
- case "text":
10247
- return jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
10248
- case "table":
10249
- return jsx(TableContent, { bodyText: parsedData.bodyText }, key);
10250
- case "graph":
10251
- return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
10252
- case "radio":
10253
- return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10254
- case "checkbox":
10255
- return jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10256
- case "select":
10257
- return jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10258
- case "slider":
10259
- return jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10260
- case "button":
10261
- return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10262
- case "input":
10263
- return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10264
- case "datePicker":
10265
- return jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10266
- case "dateRangePicker":
10267
- return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10268
- case "html":
10269
- return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
10270
- default:
10271
- return null;
10272
- }
10301
+ const body = renderWidgetBody(parsedData, key);
10302
+ if (!body)
10303
+ return null;
10304
+ const showHeaderTitle = !parsedData?.noShowHeaderTitle && Boolean(parsedData?.headerTitle?.length);
10305
+ if (!showHeaderTitle)
10306
+ return body;
10307
+ return (jsxs(Fragment$1, { children: [jsx("div", { className: `${chatClasses.chatbotText} ${chatClasses.boldText} ${chatClasses.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }), body] }, `restream-widget-block-${index}`));
10273
10308
  }
10274
10309
  catch (e) {
10275
10310
  console.error("[TabularContent] renderWidget error:", e);
@@ -10639,11 +10674,8 @@ const CombinedContent = ({ botData, props }) => {
10639
10674
  // Get the array of content items from bodyText
10640
10675
  const contentItems = Array.isArray(botData.bodyText) ? botData.bodyText : [];
10641
10676
  // Renders the optional block-level header title above a content item.
10642
- // Text blocks are skipped because their heading is the echoed user query
10643
- // (response_heading), which we don't want to duplicate in the response.
10644
10677
  const renderHeaderTitle = (parsedData) => {
10645
- const showHeaderTitle = parsedData?.bodyType !== "text" &&
10646
- !parsedData?.noShowHeaderTitle &&
10678
+ const showHeaderTitle = !parsedData?.noShowHeaderTitle &&
10647
10679
  Boolean(parsedData?.headerTitle?.length);
10648
10680
  if (!showHeaderTitle)
10649
10681
  return null;
@@ -10713,7 +10745,7 @@ const CombinedContent = ({ botData, props }) => {
10713
10745
  const validContent = renderedContent.filter(content => content !== null);
10714
10746
  const renderCombinedContent = () => (jsx("div", { className: "combined-content-container", children: validContent.length > 0 ? (validContent.map((content, index) => (jsx("div", { className: "combined-content-item", children: content }, `wrapper-${index}`)))) : (jsx("div", { children: "No valid content to display" })) }));
10715
10747
  if (isTabEnabled) {
10716
- return (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 || "", children: renderCombinedContent() }));
10748
+ return (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() }));
10717
10749
  }
10718
10750
  return renderCombinedContent();
10719
10751
  };
@@ -10752,7 +10784,7 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
10752
10784
  case "text":
10753
10785
  return jsx(TextContent, { bodyText: botData.bodyText, botData: botData });
10754
10786
  case "stream":
10755
- return jsx(StreamedContent, { botData: botData });
10787
+ return jsx(StreamedContent, { botData: botData, botProps: props });
10756
10788
  case "chips":
10757
10789
  if (botData.isMultiSelect) {
10758
10790
  return (jsx(SelectableChips, { bodyText: botData.bodyText, utilityData: botData.utilityData, props: props }));
@@ -15141,6 +15173,13 @@ const SmartBot = (props) => {
15141
15173
  // );
15142
15174
  // return;
15143
15175
  // } else {
15176
+ // The library re-fires the `initialClick` tab's onClick from an
15177
+ // effect whose deps (tabList/menuItems/onChatBotResize) are
15178
+ // recreated on every render. Track the previous tab so we only
15179
+ // reset transient state on a real tab change - otherwise these
15180
+ // spurious re-invocations wipe isStop mid-stream and hide the
15181
+ // cancel execution button.
15182
+ const previousActiveTab = activeTab.current.activeTab;
15144
15183
  setShowSavedFilters(false);
15145
15184
  const agentConversations = chatDataInfoRef?.current[params?.name?.toLowerCase()]?.conversations;
15146
15185
  const firstConversationId = agentConversations ? Object.keys(agentConversations)[0] : undefined;
@@ -15159,7 +15198,9 @@ const SmartBot = (props) => {
15159
15198
  localStorage.setItem("currentModeData", params?.name?.toLowerCase());
15160
15199
  setNewChatScreen(false);
15161
15200
  activeTab.current.activeTab = "agent";
15162
- setIsStop(false);
15201
+ if (previousActiveTab !== "agent") {
15202
+ setIsStop(false);
15203
+ }
15163
15204
  // }
15164
15205
  // setConversation([]);
15165
15206
  // chatDataInfoRef.current[currentMode] = [];
@@ -15178,6 +15219,8 @@ const SmartBot = (props) => {
15178
15219
  // );
15179
15220
  // return;
15180
15221
  // } else {
15222
+ // Only reset transient state on a real tab change.
15223
+ const previousActiveTab = activeTab.current.activeTab;
15181
15224
  setShowSavedFilters(false);
15182
15225
  let currentModeValue = params?.name?.toLowerCase();
15183
15226
  const modeConversations = chatDataInfoRef?.current[currentModeValue]?.conversations;
@@ -15201,7 +15244,9 @@ const SmartBot = (props) => {
15201
15244
  chatDataInfoRef.current = cloneDeep(parsedData);
15202
15245
  }
15203
15246
  // setNewChatScreen(true);
15204
- setIsStop(false);
15247
+ if (previousActiveTab !== "navigation") {
15248
+ setIsStop(false);
15249
+ }
15205
15250
  setCurrentMode(params?.name?.toLowerCase());
15206
15251
  if (firstConversationId) {
15207
15252
  setActiveConversationId(firstConversationId);
@@ -15270,6 +15315,9 @@ const SmartBot = (props) => {
15270
15315
  // );
15271
15316
  // return;
15272
15317
  // } else {
15318
+ // Only reset transient state on a real tab change - the library
15319
+ // re-fires this initialClick handler on every render.
15320
+ const previousActiveTab = activeTab.current.activeTab;
15273
15321
  setShowSavedFilters(false);
15274
15322
  let currentModeValue = params?.name?.toLowerCase();
15275
15323
  const modeConversations = chatDataInfoRef?.current[currentModeValue]?.conversations;
@@ -15293,7 +15341,9 @@ const SmartBot = (props) => {
15293
15341
  chatDataInfoRef.current = cloneDeep(parsedData);
15294
15342
  }
15295
15343
  // setNewChatScreen(true);
15296
- setIsStop(false);
15344
+ if (previousActiveTab !== "navigation") {
15345
+ setIsStop(false);
15346
+ }
15297
15347
  setCurrentMode(params?.name?.toLowerCase());
15298
15348
  if (firstConversationId) {
15299
15349
  setActiveConversationId(firstConversationId);
@@ -15324,6 +15374,9 @@ const SmartBot = (props) => {
15324
15374
  // );
15325
15375
  // return;
15326
15376
  // } else {
15377
+ // Only reset transient state on a real tab change - the library
15378
+ // re-fires this initialClick handler on every render.
15379
+ const previousActiveTab = activeTab.current.activeTab;
15327
15380
  setShowSavedFilters(false);
15328
15381
  let currentModeValue = params?.name?.toLowerCase();
15329
15382
  const modeConversations = chatDataInfoRef?.current[currentModeValue]?.conversations;
@@ -15347,7 +15400,9 @@ const SmartBot = (props) => {
15347
15400
  chatDataInfoRef.current = cloneDeep(parsedData);
15348
15401
  }
15349
15402
  // setNewChatScreen(true);
15350
- setIsStop(false);
15403
+ if (previousActiveTab !== "navigation") {
15404
+ setIsStop(false);
15405
+ }
15351
15406
  setCurrentMode(params?.name?.toLowerCase());
15352
15407
  if (firstConversationId) {
15353
15408
  setActiveConversationId(firstConversationId);