impact-chatbot 2.3.4 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -31,6 +31,8 @@ var AgGridComponent = require('core/Utils/agGrid');
31
31
  var agGridColumnFormatter = require('core/Utils/agGrid/column-formatter');
32
32
  var CoreChart = require('core/Utils/core-charts');
33
33
  var makeStyles = require('@mui/styles/makeStyles');
34
+ var globalStyles$1 = require('core/Styles/globalStyles');
35
+ var CircularProgress = require('@mui/material/CircularProgress');
34
36
  var FormatListBulletedOutlinedIcon = require('@mui/icons-material/FormatListBulletedOutlined');
35
37
  var PsychologyOutlinedIcon = require('@mui/icons-material/PsychologyOutlined');
36
38
  var chatbotServices = require('core/commonComponents/smartBot/services/chatbot-services');
@@ -940,14 +942,6 @@ const getFormattedApplicationName = (applicationURL) => {
940
942
  }
941
943
  };
942
944
 
943
- // Fetch legacy agent screen - stub implementation
944
- const fetchLegacyAgentScreen = () => {
945
- // This function is kept as a stub since it's rarely used
946
- // The actual implementation will be provided by the host app if needed
947
- console.warn("fetchLegacyAgentScreen called - this is a stub implementation");
948
- return null;
949
- };
950
-
951
945
  /**
952
946
  * Preprocesses markdown content to improve list formatting
953
947
  */
@@ -1868,6 +1862,8 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
1868
1862
  isTabEnabled: utilsObject?.isTabEnabled,
1869
1863
  steps: utilsObject?.steps,
1870
1864
  currentTabValue: utilsObject?.currentTabValue,
1865
+ questions: utilsObject?.questions,
1866
+ questionsStepsMap: utilsObject?.questionsStepsMap,
1871
1867
  }, null, { thinkingResponse: thinkingInfo });
1872
1868
  }
1873
1869
  }
@@ -4457,7 +4453,7 @@ const Rectangle = ({ type, icon, title, description, onClick, hoverable }) => {
4457
4453
  return (jsxRuntime.jsx("div", { className: `${classes.rectangle} ${classes[type]} ${hoverable ? classes.rectangleHoverable : ''}`, onClick: onClick, children: jsxRuntime.jsxs("div", { className: classes.textContainer, children: [jsxRuntime.jsx(material.Typography, { className: classes.title, children: title }), jsxRuntime.jsx(material.Typography, { className: classes.description, children: description })] }) }));
4458
4454
  };
4459
4455
  const ChatPlaceholder = (props) => {
4460
- const { dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, setCurrentAgentId, baseUrl, setBaseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, setChatDataState, userInput, legacyAgentScreen, activeConversationId, chatBodyRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, setUniqueChatId, } = props;
4456
+ const { dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, setCurrentAgentId, baseUrl, setBaseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, setChatDataState, userInput, legacyAgentScreen, activeConversationId, chatBodyRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, setUniqueChatId, fieldNumber, setFieldNumber, } = props;
4461
4457
  const classes = useStyles$5();
4462
4458
  globalStyles();
4463
4459
  const [cardList, setCardList] = React.useState([]);
@@ -4485,6 +4481,8 @@ const ChatPlaceholder = (props) => {
4485
4481
  setThinkingHeaderMessage,
4486
4482
  uniqueChatId,
4487
4483
  setUniqueChatId,
4484
+ fieldNumber,
4485
+ setFieldNumber,
4488
4486
  });
4489
4487
  const getBaseUrl = async () => {
4490
4488
  try {
@@ -4565,7 +4563,7 @@ const ChatPlaceholder = (props) => {
4565
4563
  type: "blue",
4566
4564
  icon: jsxRuntime.jsx(SvgCircular3D, {}),
4567
4565
  title: card.name || card.title || "Agent",
4568
- description: card.description || card.helpText || "Agent description",
4566
+ description: card.description || card.helpText || "",
4569
4567
  agentId: card.agentId || card.id
4570
4568
  }));
4571
4569
  const dataToMap = legacyAgentScreen ? transformedCardList : rectangleData;
@@ -5420,26 +5418,57 @@ var SvgStepError = function SvgStepError(props) {
5420
5418
  })));
5421
5419
  };
5422
5420
 
5421
+ const CustomGroupAccordion = ({ children, onExpandChange, }) => {
5422
+ const globalClasses = globalStyles$1();
5423
+ const [accordionData, setAccordionData] = React.useState([]);
5424
+ const [activeAccordion, setActiveAccordion] = React.useState("");
5425
+ const prepareAccordionData = () => {
5426
+ const data = [];
5427
+ React.Children.toArray(children).forEach((child, index) => {
5428
+ data.push({
5429
+ id: index + 1,
5430
+ header: child.props.accordionName,
5431
+ content: child,
5432
+ value: child.props.accordionValue || child.props.accordionName,
5433
+ childCount: child.props.accordionChildCount,
5434
+ });
5435
+ });
5436
+ setAccordionData(data);
5437
+ };
5438
+ React.useEffect(() => {
5439
+ prepareAccordionData();
5440
+ }, [children]);
5441
+ return (jsxRuntime.jsx("div", { className: globalClasses.accordianWrapper, children: jsxRuntime.jsx(impactUiV3.AccordionModern, { data: accordionData, expanded: activeAccordion, setExpanded: (val) => {
5442
+ setActiveAccordion(val);
5443
+ onExpandChange?.(val);
5444
+ } }) }));
5445
+ };
5446
+
5423
5447
  const useStyles$2 = makeStyles((theme) => ({
5448
+ "@global": {
5449
+ "@keyframes stepsLoaderSpin": {
5450
+ "0%": {
5451
+ transform: "rotate(0deg)",
5452
+ },
5453
+ "100%": {
5454
+ transform: "rotate(360deg)",
5455
+ },
5456
+ },
5457
+ },
5424
5458
  stepsContainer: {
5425
5459
  display: "flex",
5426
5460
  flexDirection: "column",
5427
- gap: "20px",
5461
+ gap: pxToRem(20),
5428
5462
  background: colours.white,
5429
- marginTop: "20px",
5463
+ marginTop: pxToRem(20),
5430
5464
  },
5431
5465
  stepItem: {
5432
5466
  display: "flex",
5433
5467
  alignItems: "center",
5434
5468
  gap: "12px",
5435
5469
  },
5436
- "@keyframes rotate": {
5437
- "0%": {
5438
- transform: "rotate(0deg)",
5439
- },
5440
- "100%": {
5441
- transform: "rotate(360deg)",
5442
- }
5470
+ mt12: {
5471
+ marginTop: pxToRem(12),
5443
5472
  },
5444
5473
  stepStatus: {
5445
5474
  display: "flex",
@@ -5453,7 +5482,7 @@ const useStyles$2 = makeStyles((theme) => ({
5453
5482
  "&.loading": {
5454
5483
  background: colours.backgroundChat,
5455
5484
  "& svg": {
5456
- animation: "$rotate 1s linear infinite",
5485
+ animation: "stepsLoaderSpin 1s linear infinite",
5457
5486
  }
5458
5487
  },
5459
5488
  "&.error": {
@@ -5472,10 +5501,10 @@ const useStyles$2 = makeStyles((theme) => ({
5472
5501
  stepHeader: {
5473
5502
  color: colours.oceanGreen,
5474
5503
  fontFamily: "Manrope",
5475
- fontSize: "14px",
5504
+ fontSize: pxToRem(14),
5476
5505
  fontStyle: "normal",
5477
5506
  fontWeight: 500,
5478
- lineHeight: "20px",
5507
+ lineHeight: pxToRem(20),
5479
5508
  "&.loading": {
5480
5509
  color: colours.brightRoyalBlue,
5481
5510
  },
@@ -5486,25 +5515,131 @@ const useStyles$2 = makeStyles((theme) => ({
5486
5515
  stepSubheader: {
5487
5516
  color: colours.neutrals,
5488
5517
  fontFamily: "Manrope",
5489
- fontSize: "12px",
5518
+ fontSize: pxToRem(12),
5490
5519
  fontStyle: "normal",
5491
5520
  fontWeight: 500,
5492
- lineHeight: "16px",
5521
+ lineHeight: pxToRem(16),
5522
+ },
5523
+ "@keyframes slideDown": {
5524
+ "0%": {
5525
+ opacity: 0,
5526
+ maxHeight: 0,
5527
+ transform: "translateY(-12px)",
5528
+ },
5529
+ "100%": {
5530
+ opacity: 1,
5531
+ maxHeight: "2000px",
5532
+ transform: "translateY(0)",
5533
+ },
5534
+ },
5535
+ loaderContainer: {
5536
+ display: "flex",
5537
+ flexDirection: "column",
5538
+ justifyContent: "center",
5539
+ alignItems: "center",
5540
+ padding: pxToRem(40),
5541
+ },
5542
+ loader: {
5543
+ color: "#435af0",
5544
+ },
5545
+ loaderCaption: {
5546
+ color: colours.neutrals,
5547
+ fontFamily: "Manrope",
5548
+ fontSize: pxToRem(13),
5549
+ fontWeight: 500,
5550
+ marginTop: pxToRem(12),
5551
+ },
5552
+ accordionAnimated: {
5553
+ animation: "$slideDown 0.4s ease-out forwards",
5554
+ overflow: "hidden",
5555
+ "& .impact-modern-accordion-item .impact-modern-accordion-header": {
5556
+ height: "auto",
5557
+ alignItems: "flex-start",
5558
+ padding: `${pxToRem(16)} ${pxToRem(16)} ${pxToRem(8)} ${pxToRem(16)} !important`
5559
+ },
5560
+ "& .loading svg": {
5561
+ animation: "stepsLoaderSpin 1s linear infinite !important",
5562
+ },
5563
+ "& .impact-modern-accordion-item .impact-modern-accordion-content": {
5564
+ padding: `${pxToRem(0)} ${pxToRem(42)} ${pxToRem(8)} ${pxToRem(32)} !important`
5565
+ },
5566
+ "& .impact-modern-accordion-item .impact-modern-accordion-header .impact-modern-accordion-expand-icon": {
5567
+ width: `${pxToRem(24)} !important`,
5568
+ height: `${pxToRem(24)} !important`,
5569
+ }
5570
+ },
5571
+ accordionStepsWrapper: {
5572
+ display: "flex",
5573
+ flexDirection: "column",
5574
+ gap: pxToRem(12),
5575
+ },
5576
+ accordionHeaderWrapper: {
5577
+ display: "flex",
5578
+ flexDirection: "column",
5579
+ gap: pxToRem(16),
5580
+ width: "100%",
5581
+ },
5582
+ accordionHeaderQuestion: {
5583
+ fontFamily: "Manrope",
5584
+ fontSize: pxToRem(14),
5585
+ fontWeight: 600,
5586
+ },
5587
+ headerStepPreview: {
5588
+ marginLeft: pxToRem(-20),
5589
+ },
5590
+ closedAccordionStep: {
5591
+ display: "flex",
5592
+ alignItems: "center",
5593
+ gap: "8px",
5594
+ marginTop: pxToRem(4),
5595
+ "& svg": {
5596
+ width: "14px",
5597
+ height: "14px",
5598
+ flexShrink: 0,
5599
+ },
5600
+ },
5601
+ closedStepLoading: {
5602
+ "& svg": {
5603
+ animation: "stepsLoaderSpin 1s linear infinite",
5604
+ },
5605
+ },
5606
+ closedStepText: {
5607
+ fontFamily: "Manrope",
5608
+ fontSize: pxToRem(12),
5609
+ fontWeight: 500,
5610
+ color: colours.neutrals,
5611
+ "&.loading": {
5612
+ color: colours.brightRoyalBlue,
5613
+ },
5614
+ "&.completed": {
5615
+ color: colours.oceanGreen,
5616
+ },
5493
5617
  },
5494
5618
  }));
5495
- const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, }) => {
5619
+ const StepItemRenderer$1 = ({ step, classes }) => (jsxRuntime.jsxs("div", { className: classes.stepItem, children: [jsxRuntime.jsx("div", { className: `${classes.stepStatus} ${step.step_status === "not-completed"
5620
+ ? "loading"
5621
+ : step.step_status === "error"
5622
+ ? "error"
5623
+ : ""}`, children: step.step_status === "not-completed" ? (jsxRuntime.jsx(SvgStepsLoader, {})) : step.step_status === "error" ? (jsxRuntime.jsx(SvgStepError, {})) : (jsxRuntime.jsx(SvgStepDone, {})) }), jsxRuntime.jsxs("div", { className: classes.stepContent, children: [jsxRuntime.jsx("div", { className: `${classes.stepHeader} ${step.step_status === "not-completed"
5624
+ ? "loading"
5625
+ : step.step_status === "error"
5626
+ ? "error"
5627
+ : ""}`, children: step.header }), jsxRuntime.jsx("div", { className: classes.stepSubheader, children: step.sub_header })] })] }));
5628
+ const getActiveStep = (stepsForQuestion) => {
5629
+ if (!stepsForQuestion || stepsForQuestion.length === 0)
5630
+ return null;
5631
+ const loadingStep = stepsForQuestion.find((s) => s.step_status === "not-completed");
5632
+ if (loadingStep)
5633
+ return loadingStep;
5634
+ return stepsForQuestion[stepsForQuestion.length - 1];
5635
+ };
5636
+ const AccordionStepsContent$1 = ({ questionSteps, classes, accordionName, accordionChildCount = "", accordionValue }) => {
5637
+ return (jsxRuntime.jsx("div", { className: classes.accordionStepsWrapper, children: jsxRuntime.jsx("div", { className: `${classes.stepsContainer} ${classes.mt12}`, children: questionSteps.map((step, index) => (jsxRuntime.jsx(StepItemRenderer$1, { step: step, classes: classes }, index))) }) }));
5638
+ };
5639
+ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, }) => {
5496
5640
  const classes = useStyles$2();
5497
5641
  React.useState(false);
5498
- // useEffect(() => {
5499
- // if (steps.length > 0) {
5500
- // // Mark all previous steps as done and last step as loading
5501
- // const updatedSteps = steps.map((step, index) => ({
5502
- // ...step,
5503
- // status: index === steps.length - 1 ? "loading" : "done"
5504
- // }));
5505
- // setSteps(updatedSteps);
5506
- // }
5507
- // }, [steps]);
5642
+ const [expandedAccordion, setExpandedAccordion] = React.useState("");
5508
5643
  React.useEffect(() => {
5509
5644
  if (done) {
5510
5645
  // Add finished step when done is true
@@ -5539,15 +5674,38 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
5539
5674
  }
5540
5675
  }
5541
5676
  }, [done]);
5542
- return (jsxRuntime.jsx("div", { className: classes.stepsContainer, children: steps.map((step, index) => (jsxRuntime.jsxs("div", { className: classes.stepItem, children: [jsxRuntime.jsx("div", { className: `${classes.stepStatus} ${step.step_status === "not-completed"
5543
- ? "loading"
5544
- : step.step_status === "error"
5545
- ? "error"
5546
- : ""}`, children: step.step_status === "not-completed" ? (jsxRuntime.jsx(SvgStepsLoader, {})) : step.step_status === "error" ? (jsxRuntime.jsx(SvgStepError, {})) : (jsxRuntime.jsx(SvgStepDone, {})) }), jsxRuntime.jsxs("div", { className: classes.stepContent, children: [jsxRuntime.jsx("div", { className: `${classes.stepHeader} ${step.step_status === "not-completed"
5547
- ? "loading"
5548
- : step.step_status === "error"
5549
- ? "error"
5550
- : ""}`, children: step.header }), jsxRuntime.jsx("div", { className: classes.stepSubheader, children: step.sub_header })] })] }, index))) }));
5677
+ const hasQuestions = questions.length > 0;
5678
+ if (!hasQuestions) {
5679
+ if (currentMode === "agent" && steps.length === 1) {
5680
+ return (jsxRuntime.jsxs("div", { className: classes.loaderContainer, children: [jsxRuntime.jsx(CircularProgress, { className: classes.loader, size: 50, thickness: 4 }), jsxRuntime.jsx("span", { className: classes.loaderCaption, children: "Analyzing next steps..." })] }));
5681
+ }
5682
+ if (steps.length > 0) {
5683
+ const fallbackQuestion = "Processing Request";
5684
+ const activeStep = getActiveStep(steps);
5685
+ const isExpanded = expandedAccordion === fallbackQuestion;
5686
+ const accordionHeader = (jsxRuntime.jsxs("div", { className: classes.accordionHeaderWrapper, children: [jsxRuntime.jsx("div", { className: classes.accordionHeaderQuestion, children: fallbackQuestion }), !isExpanded && activeStep && (jsxRuntime.jsx("div", { className: classes.headerStepPreview, children: jsxRuntime.jsx(StepItemRenderer$1, { step: activeStep, classes: classes }) }))] }));
5687
+ return (jsxRuntime.jsx("div", { className: `${classes.stepsContainer} ${classes.accordionAnimated}`, children: jsxRuntime.jsx(CustomGroupAccordion, { onExpandChange: (val) => setExpandedAccordion(val), children: jsxRuntime.jsx(AccordionStepsContent$1, { questionSteps: steps, classes: classes, accordionName: accordionHeader, accordionValue: fallbackQuestion }) }) }));
5688
+ }
5689
+ return null;
5690
+ }
5691
+ return (jsxRuntime.jsx("div", { className: `${classes.stepsContainer} ${classes.accordionAnimated}`, children: jsxRuntime.jsx(CustomGroupAccordion, { onExpandChange: (val) => setExpandedAccordion(val), children: questions.map((question, index) => {
5692
+ const questionSteps = questionsStepsMap[question] || [
5693
+ {
5694
+ header: "Processing Request",
5695
+ sub_header: "Analyzing the current request",
5696
+ step_status: "not-completed",
5697
+ },
5698
+ ];
5699
+ const activeStep = getActiveStep(questionSteps);
5700
+ const stepCount = questionSteps.length;
5701
+ const completedCount = questionSteps.filter((s) => s.step_status === "completed").length;
5702
+ activeStep
5703
+ ? `${activeStep.header} - Step ${completedCount}/${stepCount}`
5704
+ : "";
5705
+ const isExpanded = expandedAccordion === question;
5706
+ const accordionHeader = (jsxRuntime.jsxs("div", { className: classes.accordionHeaderWrapper, children: [jsxRuntime.jsx("div", { className: classes.accordionHeaderQuestion, children: question }), !isExpanded && activeStep && (jsxRuntime.jsx("div", { className: classes.headerStepPreview, children: jsxRuntime.jsx(StepItemRenderer$1, { step: activeStep, classes: classes }) }))] }));
5707
+ return (jsxRuntime.jsx(AccordionStepsContent$1, { questionSteps: questionSteps, classes: classes, accordionName: accordionHeader, accordionValue: question }, index));
5708
+ }) }) }));
5551
5709
  };
5552
5710
 
5553
5711
  const AgentResponse$1 = (props) => {
@@ -5560,7 +5718,7 @@ const AgentResponse$1 = (props) => {
5560
5718
  };
5561
5719
 
5562
5720
  const StepsResponseTab = (props) => {
5563
- const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, } = props;
5721
+ const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, } = props;
5564
5722
  const [tabValue, setTabValue] = React.useState("steps");
5565
5723
  const handleChangeTabValue = (_event, newValue) => {
5566
5724
  setTabValue(newValue);
@@ -5577,7 +5735,7 @@ const StepsResponseTab = (props) => {
5577
5735
  icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
5578
5736
  },
5579
5737
  ], tabPanels: [
5580
- jsxRuntime.jsx(Steps$1, { steps: steps, setSteps: setSteps, done: stepsDone, setDone: setStepsDone, setTabValue: setTabValue, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, stepChange: stepChange, currentMode: currentMode }),
5738
+ 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 }),
5581
5739
  jsxRuntime.jsx(AgentResponse$1, { content: content, isStreaming: isStreaming }),
5582
5740
  ], value: tabValue }) }));
5583
5741
  };
@@ -5635,6 +5793,8 @@ const StreamedContent = ({ botData }) => {
5635
5793
  step_status: "not-completed"
5636
5794
  }
5637
5795
  ]);
5796
+ const [questions, setQuestions] = React.useState([]);
5797
+ const [questionsStepsMap, setQuestionsStepsMap] = React.useState({});
5638
5798
  const [stepChange, setStepChange] = React.useState(false);
5639
5799
  const [stepsDone, setStepsDone] = React.useState(false);
5640
5800
  const [finalStepDone, setFinalStepDone] = React.useState(false);
@@ -5651,6 +5811,8 @@ const StreamedContent = ({ botData }) => {
5651
5811
  step_status: "not-completed"
5652
5812
  }
5653
5813
  ]);
5814
+ const questionsRef = React.useRef([]);
5815
+ const questionsStepsMapRef = React.useRef({});
5654
5816
  // Refs to maintain data across renders
5655
5817
  const sourceRef = React.useRef(null); // Holds the SSE source instance
5656
5818
  React.useRef(""); // Tracks the last received message
@@ -5740,8 +5902,25 @@ const StreamedContent = ({ botData }) => {
5740
5902
  thinkingStartTimeRef.current = Date.now();
5741
5903
  }
5742
5904
  const data = JSON.parse(event.data);
5743
- if (data?.message || data?.status === "step" || data?.status === "thinking") {
5744
- if (data.status === "thinking") {
5905
+ if (data?.message || data?.status === "step" || data?.status === "thinking" || data?.status === "questions") {
5906
+ if (data.status === "questions") {
5907
+ const incomingQuestions = data.widget_data?.[0]?.questions || [];
5908
+ questionsRef.current = incomingQuestions;
5909
+ setQuestions(incomingQuestions);
5910
+ const initialMap = {};
5911
+ incomingQuestions.forEach((q) => {
5912
+ initialMap[q] = [
5913
+ {
5914
+ header: "Processing Request",
5915
+ sub_header: "Analyzing the current request",
5916
+ step_status: "not-completed",
5917
+ },
5918
+ ];
5919
+ });
5920
+ questionsStepsMapRef.current = initialMap;
5921
+ setQuestionsStepsMap(lodash.cloneDeep(initialMap));
5922
+ }
5923
+ else if (data.status === "thinking") {
5745
5924
  messageToStoreRef.current.chatData.thinkingResponse.thinkingHeading = "Planning next moves";
5746
5925
  // Start thinking if not already started
5747
5926
  if (!isThinking) {
@@ -5780,6 +5959,7 @@ const StreamedContent = ({ botData }) => {
5780
5959
  }
5781
5960
  else if (data.status === "step") {
5782
5961
  let newStep = data.widget_data[0];
5962
+ const currentIntent = data.widget_data[0]?.current_intent;
5783
5963
  setSteps([...steps, newStep]);
5784
5964
  let newSteps = lodash.cloneDeep(stepRef.current);
5785
5965
  if (newSteps.length === 1) {
@@ -5789,15 +5969,28 @@ const StreamedContent = ({ botData }) => {
5789
5969
  }
5790
5970
  const existingStepIndex = newSteps.findIndex((step) => step.header === newStep.header);
5791
5971
  if (existingStepIndex !== -1) {
5792
- // Replace the existing step at the same position
5793
5972
  newSteps[existingStepIndex] = newStep;
5794
5973
  }
5795
5974
  else {
5796
- // If no matching step found, add it to the end
5797
5975
  newSteps.push(newStep);
5798
5976
  }
5799
5977
  stepRef.current = newSteps;
5800
5978
  setSteps(newSteps);
5979
+ if (currentIntent && questionsStepsMapRef.current[currentIntent]) {
5980
+ let intentSteps = lodash.cloneDeep(questionsStepsMapRef.current[currentIntent]);
5981
+ if (intentSteps.length === 1 && intentSteps[0].header === "Processing Request") {
5982
+ intentSteps[0].step_status = "completed";
5983
+ }
5984
+ const existingIdx = intentSteps.findIndex((s) => s.header === newStep.header);
5985
+ if (existingIdx !== -1) {
5986
+ intentSteps[existingIdx] = newStep;
5987
+ }
5988
+ else {
5989
+ intentSteps.push(newStep);
5990
+ }
5991
+ questionsStepsMapRef.current[currentIntent] = intentSteps;
5992
+ setQuestionsStepsMap(lodash.cloneDeep(questionsStepsMapRef.current));
5993
+ }
5801
5994
  setStepChange((prev) => !prev);
5802
5995
  }
5803
5996
  else if (data.message !== "[DONE]") {
@@ -6029,6 +6222,8 @@ const StreamedContent = ({ botData }) => {
6029
6222
  isTabEnabled: true,
6030
6223
  steps: lodash.cloneDeep(stepRef.current),
6031
6224
  currentTabValue: "agent_response",
6225
+ questions: lodash.cloneDeep(questionsRef.current),
6226
+ questionsStepsMap: lodash.cloneDeep(questionsStepsMapRef.current),
6032
6227
  });
6033
6228
  // [
6034
6229
  // {
@@ -6107,6 +6302,8 @@ const StreamedContent = ({ botData }) => {
6107
6302
  isTabEnabled: true,
6108
6303
  steps: lodash.cloneDeep(stepRef.current),
6109
6304
  currentTabValue: "agent_response",
6305
+ questions: lodash.cloneDeep(questionsRef.current),
6306
+ questionsStepsMap: lodash.cloneDeep(questionsStepsMapRef.current),
6110
6307
  });
6111
6308
  }
6112
6309
  // Trigger re-render by updating chatDataState
@@ -6243,7 +6440,7 @@ const StreamedContent = ({ botData }) => {
6243
6440
  * @returns {JSX.Element} Rendered content with optional blinking cursor
6244
6441
  */
6245
6442
  const renderContent = () => {
6246
- return (jsxRuntime.jsx("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 }) }));
6443
+ return (jsxRuntime.jsx("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 }) }));
6247
6444
  };
6248
6445
  if (currentMode === "agent") {
6249
6446
  return renderContent();
@@ -6462,9 +6659,28 @@ const useStyles$1 = makeStyles((theme) => ({
6462
6659
  stepsContainer: {
6463
6660
  display: "flex",
6464
6661
  flexDirection: "column",
6465
- gap: "20px",
6662
+ gap: pxToRem(20),
6466
6663
  background: colours.white,
6467
- marginTop: "20px",
6664
+ marginTop: pxToRem(20),
6665
+ "& .impact-modern-accordion-item .impact-modern-accordion-header": {
6666
+ height: "auto",
6667
+ alignItems: "flex-start"
6668
+ },
6669
+ "& .impact-modern-accordion-item .impact-modern-accordion-content": {
6670
+ padding: `${pxToRem(0)} ${pxToRem(42)} ${pxToRem(8)} ${pxToRem(32)} !important`
6671
+ },
6672
+ "& .impact-modern-accordion-item .impact-modern-accordion-header .impact-modern-accordion-expand-icon": {
6673
+ width: `${pxToRem(24)} !important`,
6674
+ height: `${pxToRem(24)} !important`,
6675
+ }
6676
+ },
6677
+ hideContentDiv: {
6678
+ "& .impact-modern-accordion-item .impact-modern-accordion-content": {
6679
+ display: "none",
6680
+ }
6681
+ },
6682
+ mt12: {
6683
+ marginTop: pxToRem(12),
6468
6684
  },
6469
6685
  stepItem: {
6470
6686
  display: "flex",
@@ -6510,10 +6726,10 @@ const useStyles$1 = makeStyles((theme) => ({
6510
6726
  stepHeader: {
6511
6727
  color: colours.oceanGreen,
6512
6728
  fontFamily: "Manrope",
6513
- fontSize: "14px",
6729
+ fontSize: pxToRem(14),
6514
6730
  fontStyle: "normal",
6515
6731
  fontWeight: 500,
6516
- lineHeight: "20px",
6732
+ lineHeight: pxToRem(20),
6517
6733
  "&.loading": {
6518
6734
  color: colours.brightRoyalBlue,
6519
6735
  },
@@ -6524,62 +6740,89 @@ const useStyles$1 = makeStyles((theme) => ({
6524
6740
  stepSubheader: {
6525
6741
  color: colours.neutrals,
6526
6742
  fontFamily: "Manrope",
6527
- fontSize: "12px",
6743
+ fontSize: pxToRem(12),
6528
6744
  fontStyle: "normal",
6529
6745
  fontWeight: 500,
6530
- lineHeight: "16px",
6746
+ lineHeight: pxToRem(16),
6747
+ },
6748
+ accordionStepsWrapper: {
6749
+ display: "flex",
6750
+ flexDirection: "column",
6751
+ gap: pxToRem(12),
6752
+ },
6753
+ accordionHeaderWrapper: {
6754
+ display: "flex",
6755
+ flexDirection: "column",
6756
+ gap: pxToRem(16),
6757
+ width: "100%",
6758
+ },
6759
+ accordionHeaderQuestion: {
6760
+ fontFamily: "Manrope",
6761
+ fontSize: pxToRem(14),
6762
+ fontWeight: 600,
6763
+ },
6764
+ headerStepPreview: {
6765
+ marginLeft: pxToRem(-20),
6766
+ },
6767
+ closedAccordionStep: {
6768
+ display: "flex",
6769
+ alignItems: "center",
6770
+ gap: "8px",
6771
+ marginTop: pxToRem(4),
6772
+ "& svg": {
6773
+ width: "14px",
6774
+ height: "14px",
6775
+ flexShrink: 0,
6776
+ },
6777
+ },
6778
+ closedStepText: {
6779
+ fontFamily: "Manrope",
6780
+ fontSize: pxToRem(12),
6781
+ fontWeight: 500,
6782
+ color: colours.oceanGreen,
6531
6783
  },
6532
6784
  }));
6533
- const Steps = ({ steps }) => {
6534
- const classes = useStyles$1();
6535
- React.useState(false);
6536
- // useEffect(() => {
6537
- // if (steps.length > 0) {
6538
- // // Mark all previous steps as done and last step as loading
6539
- // const updatedSteps = steps.map((step, index) => ({
6540
- // ...step,
6541
- // status: index === steps.length - 1 ? "loading" : "done"
6542
- // }));
6543
- // setSteps(updatedSteps);
6544
- // }
6545
- // }, [steps]);
6546
- // useEffect(() => {
6547
- // if (done) {
6548
- // // Add finished step when done is true
6549
- // if (!finalStepDone) {
6550
- // let updatedSteps = steps.map((step) => ({
6551
- // ...step,
6552
- // step_status: "completed",
6553
- // }));
6554
- // updatedSteps = [...updatedSteps, {
6555
- // header: "Finished",
6556
- // sub_header: "Analysis complete",
6557
- // step_status: "not-completed",
6558
- // }];
6559
- // setSteps(cloneDeep(updatedSteps));
6560
- // setTimeout(() => {
6561
- // updatedSteps = updatedSteps.map((step) => ({
6562
- // ...step,
6563
- // step_status: "completed",
6564
- // }));
6565
- // setSteps(cloneDeep(updatedSteps));
6566
- // setFinalStepDone(true);
6567
- // }, 4000);
6568
- // setTimeout(() => {
6569
- // setTabValue("agent_response");
6570
- // }, 4300);
6571
- // }
6572
- // }
6573
- // }, [done]);
6574
- return (jsxRuntime.jsx("div", { className: classes.stepsContainer, children: steps.map((step, index) => (jsxRuntime.jsxs("div", { className: classes.stepItem, children: [jsxRuntime.jsx("div", { className: `${classes.stepStatus} ${step.step_status === "not-completed"
6785
+ const StepItemRenderer = ({ step, classes }) => (jsxRuntime.jsxs("div", { className: classes.stepItem, children: [jsxRuntime.jsx("div", { className: `${classes.stepStatus} ${step.step_status === "not-completed"
6786
+ ? "loading"
6787
+ : step.step_status === "error"
6788
+ ? "error"
6789
+ : ""}`, children: step.step_status === "not-completed" ? (jsxRuntime.jsx(SvgStepsLoader, {})) : step.step_status === "error" ? (jsxRuntime.jsx(SvgStepError, {})) : (jsxRuntime.jsx(SvgStepDone, {})) }), jsxRuntime.jsxs("div", { className: classes.stepContent, children: [jsxRuntime.jsx("div", { className: `${classes.stepHeader} ${step.step_status === "not-completed"
6575
6790
  ? "loading"
6576
6791
  : step.step_status === "error"
6577
6792
  ? "error"
6578
- : ""}`, children: step.step_status === "not-completed" ? (jsxRuntime.jsx(SvgStepsLoader, {})) : step.step_status === "error" ? (jsxRuntime.jsx(SvgStepError, {})) : (jsxRuntime.jsx(SvgStepDone, {})) }), jsxRuntime.jsxs("div", { className: classes.stepContent, children: [jsxRuntime.jsx("div", { className: `${classes.stepHeader} ${step.step_status === "not-completed"
6579
- ? "loading"
6580
- : step.step_status === "error"
6581
- ? "error"
6582
- : ""}`, children: step.header }), jsxRuntime.jsx("div", { className: classes.stepSubheader, children: step.sub_header })] })] }, index))) }));
6793
+ : ""}`, children: step.header }), jsxRuntime.jsx("div", { className: classes.stepSubheader, children: step.sub_header })] })] }));
6794
+ const AccordionStepsContent = ({ questionSteps, classes, accordionName, accordionChildCount = "", accordionValue }) => {
6795
+ return (jsxRuntime.jsx("div", { className: classes.accordionStepsWrapper, children: jsxRuntime.jsx("div", { className: `${classes.stepsContainer} ${classes.mt12}`, children: questionSteps.map((step, index) => (jsxRuntime.jsx(StepItemRenderer, { step: step, classes: classes }, index))) }) }));
6796
+ };
6797
+ const Steps = ({ steps, questions = [], questionsStepsMap = {} }) => {
6798
+ const classes = useStyles$1();
6799
+ React.useState(false);
6800
+ const [expandedAccordion, setExpandedAccordion] = React.useState("");
6801
+ const hasQuestions = questions.length > 0;
6802
+ if (!hasQuestions) {
6803
+ if (steps.length > 0) {
6804
+ const fallbackQuestion = "Processing Request";
6805
+ const lastStep = steps[steps.length - 1];
6806
+ const isExpanded = expandedAccordion === fallbackQuestion;
6807
+ const accordionHeader = (jsxRuntime.jsxs("div", { className: classes.accordionHeaderWrapper, children: [jsxRuntime.jsx("div", { className: classes.accordionHeaderQuestion, children: fallbackQuestion }), !isExpanded && lastStep && (jsxRuntime.jsx("div", { className: classes.headerStepPreview, children: jsxRuntime.jsx(StepItemRenderer, { step: lastStep, classes: classes }) }))] }));
6808
+ return (jsxRuntime.jsx("div", { className: classes.stepsContainer, children: jsxRuntime.jsx(CustomGroupAccordion, { onExpandChange: (val) => setExpandedAccordion(val), children: jsxRuntime.jsx(AccordionStepsContent, { questionSteps: steps, classes: classes, accordionName: accordionHeader, accordionValue: fallbackQuestion }) }) }));
6809
+ }
6810
+ return null;
6811
+ }
6812
+ return (jsxRuntime.jsx("div", { className: classes.stepsContainer, children: jsxRuntime.jsx(CustomGroupAccordion, { onExpandChange: (val) => setExpandedAccordion(val), children: questions.map((question, index) => {
6813
+ const questionSteps = questionsStepsMap[question] || [
6814
+ {
6815
+ header: "Processing Request",
6816
+ sub_header: "Analyzing the current request",
6817
+ step_status: "completed",
6818
+ },
6819
+ ];
6820
+ questionSteps.length;
6821
+ const lastStep = questionSteps[questionSteps.length - 1];
6822
+ const isExpanded = expandedAccordion === question;
6823
+ const accordionHeader = (jsxRuntime.jsxs("div", { className: classes.accordionHeaderWrapper, children: [jsxRuntime.jsx("div", { className: classes.accordionHeaderQuestion, children: question }), !isExpanded && lastStep && (jsxRuntime.jsx("div", { className: classes.headerStepPreview, children: jsxRuntime.jsx(StepItemRenderer, { step: lastStep, classes: classes }) }))] }));
6824
+ return (jsxRuntime.jsx(AccordionStepsContent, { questionSteps: questionSteps, classes: classes, accordionName: accordionHeader, accordionValue: question }, index));
6825
+ }) }) }));
6583
6826
  };
6584
6827
 
6585
6828
  const AgentResponse = ({ children }) => {
@@ -6587,7 +6830,7 @@ const AgentResponse = ({ children }) => {
6587
6830
  return (jsxRuntime.jsx("div", { className: classes.agentResponseContainer, children: children }));
6588
6831
  };
6589
6832
 
6590
- const TabularContent = ({ steps, currentTabValue, children }) => {
6833
+ const TabularContent = ({ steps, currentTabValue, children, questions = [], questionsStepsMap = {} }) => {
6591
6834
  const [tabValue, setTabValue] = React.useState(currentTabValue);
6592
6835
  const handleChangeTabValue = (_event, newValue) => {
6593
6836
  setTabValue(newValue);
@@ -6595,6 +6838,13 @@ const TabularContent = ({ steps, currentTabValue, children }) => {
6595
6838
  steps.forEach((step) => {
6596
6839
  step.step_status = "completed";
6597
6840
  });
6841
+ if (Object.keys(questionsStepsMap).length > 0) {
6842
+ Object.keys(questionsStepsMap).forEach((key) => {
6843
+ questionsStepsMap[key].forEach((step) => {
6844
+ step.step_status = "completed";
6845
+ });
6846
+ });
6847
+ }
6598
6848
  return (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(impactUiV3.Tabs, { onChange: handleChangeTabValue, orientation: "horizontal", tabNames: [
6599
6849
  {
6600
6850
  label: "Steps",
@@ -6607,7 +6857,7 @@ const TabularContent = ({ steps, currentTabValue, children }) => {
6607
6857
  icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
6608
6858
  },
6609
6859
  ], tabPanels: [
6610
- jsxRuntime.jsx(Steps, { steps: steps }),
6860
+ jsxRuntime.jsx(Steps, { steps: steps, questions: questions, questionsStepsMap: questionsStepsMap }),
6611
6861
  jsxRuntime.jsx(AgentResponse, { children: children }),
6612
6862
  ], value: tabValue }) }));
6613
6863
  };
@@ -6676,7 +6926,7 @@ const CombinedContent = ({ botData, props }) => {
6676
6926
  const validContent = renderedContent.filter(content => content !== null);
6677
6927
  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" })) }));
6678
6928
  if (isTabEnabled) {
6679
- return (jsxRuntime.jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", children: renderCombinedContent() }));
6929
+ return (jsxRuntime.jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", questions: botData?.utilityData?.questions || [], questionsStepsMap: botData?.utilityData?.questionsStepsMap || {}, children: renderCombinedContent() }));
6680
6930
  }
6681
6931
  return renderCombinedContent();
6682
6932
  };
@@ -9698,7 +9948,7 @@ const SmartBot = (props) => {
9698
9948
  }, [chatDataState, currentMode]);
9699
9949
  const fetchLegacyAgentInfo = async () => {
9700
9950
  try {
9701
- let legacyAgentScreenData = await fetchLegacyAgentScreen();
9951
+ let legacyAgentScreenData = await utils.fetchLegacyAgentScreen();
9702
9952
  setLegacyAgentScreen(legacyAgentScreenData);
9703
9953
  }
9704
9954
  catch (error) {
@@ -10069,7 +10319,7 @@ const SmartBot = (props) => {
10069
10319
  },
10070
10320
  icon: jsxRuntime.jsx(SvgNavigationIcon, {}),
10071
10321
  },
10072
- ], utilityList: utilityList, isAssistantThinking: loader, isCustomScreen: showChatPlaceholder, customScreenJsx: jsxRuntime.jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
10322
+ ], utilityList: utilityList, isAssistantThinking: loader, isCustomScreen: showChatPlaceholder, customScreenJsx: jsxRuntime.jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId, fieldNumber: fieldNumber, setFieldNumber: setFieldNumber }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
10073
10323
  freeTextHeading: "Try adding more details :",
10074
10324
  freeTextContent: "Alan works better when you provide more context and pointed questions",
10075
10325
  }, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSuggestionBanner, onCloseSuggestionBanner: () => {