@e-llm-studio/instant-learning 0.0.83 → 0.0.85
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/cjs/features/DocumentLearning/DocumentLearning.js +1 -1
- package/dist/cjs/features/DocumentLearning/_components/BookLearningForm.js +1 -1
- package/dist/cjs/features/DocumentLearning/_components/ChatComponent.js +1 -1
- package/dist/cjs/features/DocumentLearning/_components/ConflictingLearningWarnCard.js +1 -1
- package/dist/cjs/features/InstantLearning/InstantLearning.js +1 -1
- package/dist/cjs/features/InstantLearning/_components/ChatComponent.js +1 -1
- package/dist/cjs/features/InstantLearning/_components/ConflictingLearningWarnCard.js +1 -1
- package/dist/cjs/features/InstantLearning/_components/ConflictingLearningWarnCardDB.js +1 -1
- package/dist/cjs/features/InstantLearning/_components/ContextualChatComponent.js +1 -1
- package/dist/cjs/features/InstantLearning/_components/ContextualConflictDBCard.js +1 -1
- package/dist/cjs/features/InstantLearning/_components/ContextualLearningForm.js +1 -1
- package/dist/cjs/features/InstantLearning/_components/LearningDetailsForm.js +1 -1
- package/dist/cjs/features/WtaWnta/WtaWnta.js +1 -1
- package/dist/cjs/features/WtaWnta/_components/AgentDetailsForm.js +1 -1
- package/dist/cjs/features/WtaWnta/_components/SimilarConflictingCard.js +1 -1
- package/dist/cjs/features/WtaWnta/_components/ValidationCard.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Box/Box.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Box/Box.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/ButtonBase/TouchRipple.js +5 -5
- package/dist/cjs/node_modules/@mui/material/ButtonBase/TouchRipple.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/CircularProgress/CircularProgress.js +5 -5
- package/dist/cjs/node_modules/@mui/material/CircularProgress/CircularProgress.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Container/Container.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Container/Container.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/GlobalStyles/GlobalStyles.js +1 -1
- package/dist/cjs/node_modules/@mui/material/GlobalStyles/GlobalStyles.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Grid/Grid.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Grid/Grid.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Hidden/HiddenCss.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Hidden/HiddenCss.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/LinearProgress/LinearProgress.js +7 -7
- package/dist/cjs/node_modules/@mui/material/LinearProgress/LinearProgress.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Link/getTextDecoration.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Link/getTextDecoration.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Popper/Popper.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Popper/Popper.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Skeleton/Skeleton.js +5 -5
- package/dist/cjs/node_modules/@mui/material/Skeleton/Skeleton.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Snackbar/Snackbar.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Snackbar/Snackbar.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Stack/Stack.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Stack/Stack.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/ToggleButton/ToggleButton.js +1 -1
- package/dist/cjs/node_modules/@mui/material/ToggleButton/ToggleButton.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Tooltip/Tooltip.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/Unstable_Grid2/Grid2.js +1 -1
- package/dist/cjs/node_modules/@mui/material/Unstable_Grid2/Grid2.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/styles/CssVarsProvider.js +1 -1
- package/dist/cjs/node_modules/@mui/material/styles/CssVarsProvider.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/styles/ThemeProvider.js +1 -1
- package/dist/cjs/node_modules/@mui/material/styles/ThemeProvider.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/styles/experimental_extendTheme.js +1 -1
- package/dist/cjs/node_modules/@mui/material/styles/experimental_extendTheme.js.map +1 -1
- package/dist/cjs/node_modules/@mui/material/styles/useTheme.js +1 -1
- package/dist/cjs/node_modules/@mui/material/styles/useTheme.js.map +1 -1
- package/dist/cjs/node_modules/@mui/system/esm/GlobalStyles/GlobalStyles.js +1 -1
- package/dist/cjs/node_modules/@mui/system/esm/GlobalStyles/GlobalStyles.js.map +1 -1
- package/dist/cjs/node_modules/@mui/system/esm/ThemeProvider/ThemeProvider.js +1 -1
- package/dist/cjs/node_modules/@mui/system/esm/ThemeProvider/ThemeProvider.js.map +1 -1
- package/dist/cjs/node_modules/@mui/system/esm/cssVars/createCssVarsProvider.js +1 -1
- package/dist/cjs/node_modules/@mui/system/esm/cssVars/createCssVarsProvider.js.map +1 -1
- package/dist/cjs/node_modules/@mui/system/esm/useThemeWithoutDefault.js +1 -1
- package/dist/cjs/node_modules/@mui/system/esm/useThemeWithoutDefault.js.map +1 -1
- package/dist/cjs/utils/instantLearning.utils.js +1 -1
- package/dist/features/DocumentLearning/DocumentLearning.js +1 -1
- package/dist/features/DocumentLearning/_components/BookLearningForm.js +1 -1
- package/dist/features/DocumentLearning/_components/ChatComponent.js +1 -1
- package/dist/features/DocumentLearning/_components/ConflictingLearningWarnCard.js +1 -1
- package/dist/features/InstantLearning/InstantLearning.js +1 -1
- package/dist/features/InstantLearning/_components/ChatComponent.js +1 -1
- package/dist/features/InstantLearning/_components/ConflictingLearningWarnCard.js +1 -1
- package/dist/features/InstantLearning/_components/ConflictingLearningWarnCardDB.js +1 -1
- package/dist/features/InstantLearning/_components/ContextualChatComponent.js +1 -1
- package/dist/features/InstantLearning/_components/ContextualConflictDBCard.js +1 -1
- package/dist/features/InstantLearning/_components/ContextualLearningForm.js +1 -1
- package/dist/features/InstantLearning/_components/LearningDetailsForm.js +1 -1
- package/dist/features/WtaWnta/WtaWnta.js +1 -1
- package/dist/features/WtaWnta/_components/AgentDetailsForm.js +1 -1
- package/dist/features/WtaWnta/_components/SimilarConflictingCard.js +1 -1
- package/dist/features/WtaWnta/_components/ValidationCard.js +1 -1
- package/dist/node_modules/@mui/material/Box/Box.js +1 -1
- package/dist/node_modules/@mui/material/Box/Box.js.map +1 -1
- package/dist/node_modules/@mui/material/ButtonBase/TouchRipple.js +5 -5
- package/dist/node_modules/@mui/material/ButtonBase/TouchRipple.js.map +1 -1
- package/dist/node_modules/@mui/material/CircularProgress/CircularProgress.js +5 -5
- package/dist/node_modules/@mui/material/CircularProgress/CircularProgress.js.map +1 -1
- package/dist/node_modules/@mui/material/Container/Container.js +1 -1
- package/dist/node_modules/@mui/material/Container/Container.js.map +1 -1
- package/dist/node_modules/@mui/material/GlobalStyles/GlobalStyles.js +1 -1
- package/dist/node_modules/@mui/material/GlobalStyles/GlobalStyles.js.map +1 -1
- package/dist/node_modules/@mui/material/Grid/Grid.js +1 -1
- package/dist/node_modules/@mui/material/Grid/Grid.js.map +1 -1
- package/dist/node_modules/@mui/material/Hidden/HiddenCss.js +1 -1
- package/dist/node_modules/@mui/material/Hidden/HiddenCss.js.map +1 -1
- package/dist/node_modules/@mui/material/LinearProgress/LinearProgress.js +7 -7
- package/dist/node_modules/@mui/material/LinearProgress/LinearProgress.js.map +1 -1
- package/dist/node_modules/@mui/material/Link/getTextDecoration.js +1 -1
- package/dist/node_modules/@mui/material/Link/getTextDecoration.js.map +1 -1
- package/dist/node_modules/@mui/material/Popper/Popper.js +1 -1
- package/dist/node_modules/@mui/material/Popper/Popper.js.map +1 -1
- package/dist/node_modules/@mui/material/Skeleton/Skeleton.js +5 -5
- package/dist/node_modules/@mui/material/Skeleton/Skeleton.js.map +1 -1
- package/dist/node_modules/@mui/material/Snackbar/Snackbar.js +1 -1
- package/dist/node_modules/@mui/material/Snackbar/Snackbar.js.map +1 -1
- package/dist/node_modules/@mui/material/Stack/Stack.js +1 -1
- package/dist/node_modules/@mui/material/Stack/Stack.js.map +1 -1
- package/dist/node_modules/@mui/material/ToggleButton/ToggleButton.js +1 -1
- package/dist/node_modules/@mui/material/ToggleButton/ToggleButton.js.map +1 -1
- package/dist/node_modules/@mui/material/Tooltip/Tooltip.js +1 -1
- package/dist/node_modules/@mui/material/Tooltip/Tooltip.js.map +1 -1
- package/dist/node_modules/@mui/material/Unstable_Grid2/Grid2.js +1 -1
- package/dist/node_modules/@mui/material/Unstable_Grid2/Grid2.js.map +1 -1
- package/dist/node_modules/@mui/material/styles/CssVarsProvider.js +1 -1
- package/dist/node_modules/@mui/material/styles/CssVarsProvider.js.map +1 -1
- package/dist/node_modules/@mui/material/styles/ThemeProvider.js +1 -1
- package/dist/node_modules/@mui/material/styles/ThemeProvider.js.map +1 -1
- package/dist/node_modules/@mui/material/styles/experimental_extendTheme.js +1 -1
- package/dist/node_modules/@mui/material/styles/experimental_extendTheme.js.map +1 -1
- package/dist/node_modules/@mui/material/styles/useTheme.js +1 -1
- package/dist/node_modules/@mui/material/styles/useTheme.js.map +1 -1
- package/dist/node_modules/@mui/system/esm/GlobalStyles/GlobalStyles.js +1 -1
- package/dist/node_modules/@mui/system/esm/GlobalStyles/GlobalStyles.js.map +1 -1
- package/dist/node_modules/@mui/system/esm/ThemeProvider/ThemeProvider.js +1 -1
- package/dist/node_modules/@mui/system/esm/ThemeProvider/ThemeProvider.js.map +1 -1
- package/dist/node_modules/@mui/system/esm/cssVars/createCssVarsProvider.js +1 -1
- package/dist/node_modules/@mui/system/esm/cssVars/createCssVarsProvider.js.map +1 -1
- package/dist/node_modules/@mui/system/esm/useThemeWithoutDefault.js +1 -1
- package/dist/node_modules/@mui/system/esm/useThemeWithoutDefault.js.map +1 -1
- package/dist/types/src/features/DocumentLearning/_components/BookLearningForm.d.ts.map +1 -1
- package/dist/types/src/features/InstantLearning/_components/ContextualConflictDBCard.d.ts +1 -0
- package/dist/types/src/features/InstantLearning/_components/ContextualConflictDBCard.d.ts.map +1 -1
- package/dist/types/src/features/InstantLearning/_components/ContextualLearningForm.d.ts.map +1 -1
- package/dist/types/src/utils/instantLearning.utils.d.ts +1 -0
- package/dist/types/src/utils/instantLearning.utils.d.ts.map +1 -1
- package/dist/utils/instantLearning.utils.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as e,__assign as n,__spreadArray as o,__rest as i,__generator as t}from"../../../node_modules/tslib/tslib.es6.mjs.js";import{jsx as l,jsxs as a,Fragment as r}from"react/jsx-runtime";import{useRef as s,useState as d,useMemo as c,useEffect as u,useCallback as v}from"react";import{d as g}from"../../../_virtual/index.js";import"../../../node_modules/uuid/dist/esm-browser/stringify.js";import h from"../../../node_modules/uuid/dist/esm-browser/v4.js";import m from"../../../node_modules/axios/lib/axios.js";import{ReactMarkdown as p}from"../../../node_modules/react-markdown/lib/react-markdown.js";import f from"./MinimizedThinkingSteps.js";import C from"./_svg/NewChatIcon.js";import y from"../InstantLearning.module.css.js";import _ from"../../../node_modules/@mui/material/Tooltip/Tooltip.js";import"../../../node_modules/@mui/material/Tooltip/tooltipClasses.js";import w from"../../../_virtual/index2.js";import b from"./AudioWaveform.js";import S from"./MessageRendering.js";import{sanitizePythonDictToJSON as x}from"../../../utils/instantLearning.utils.js";import{publishAgenticFeedbackForVariantIngestion as L}from"../../../service/InstantLearningService.js";import{parseValidationRecommendations as k}from"../../../utils/recommendationParser.js";var A=function(){return l("svg",n({width:"20px",height:"20px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:l("path",{d:"M9.91158 12H7.45579H4L2.02268 4.13539C2.0111 4.0893 2.00193 4.04246 2.00046 3.99497C1.97811 3.27397 2.77209 2.77366 3.46029 3.10388L22 12L3.46029 20.8961C2.77983 21.2226 1.99597 20.7372 2.00002 20.0293C2.00038 19.9658 2.01455 19.9032 2.03296 19.8425L3.5 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))},E=function(e){var o=e.resetChatHistory,i=e.isStreamEnd;return a("div",n({className:y.customFont,style:{width:"100%",padding:"0.75rem 0rem",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#fff",borderBottom:"1px solid #e5e7eb",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.04)"}},{children:[a("span",n({style:{fontSize:"1.25rem",fontWeight:700,color:"#1f2937",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:[l("span",n({style:{color:"#5928ED"}},{children:"InstantLearning.AI"}))," Contextual Chat"]})),l(_,n({title:"New chat",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:l("div",n({onClick:function(){console.log(C,"hello"),i&&o()},style:{height:"1.8rem",width:"1.8rem",marginLeft:"1rem",marginRight:"0.5rem",cursor:i?"pointer":"not-allowed",backgroundColor:"transparent",transition:"transform 0.2s ease-in-out, opacity 0.2s",opacity:i?.8:.4,pointerEvents:i?"auto":"none"},onMouseOver:function(e){i&&(e.currentTarget.style.opacity="1")},onMouseOut:function(e){i&&(e.currentTarget.style.opacity="0.8")}},{children:l(C,{})}))}))]}))},R=function(n,i,l,a){return e(void 0,void 0,void 0,(function(){var e,r,s,d,c,u,v,g,h,m;return t(this,(function(t){switch(t.label){case 0:e=n.delete_current_learning,r=n.deleted_similar_learning_ids,s=n.deleted_conflicting_learning_ids,console.log("Processing delete tool call:",n),d=o(o([],r||[],!0),s||[],!0),c=0,u=d,t.label=1;case 1:if(!(c<u.length))return[3,6];v=u[c],t.label=2;case 2:return t.trys.push([2,4,,5]),g={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:v,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(v),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},console.log("Deleting learning with ID: ".concat(v)),[4,L({baseUrl:i,organizationName:l,chatAssistantName:a,payload:g})];case 3:return(h=t.sent()).ok?console.log("Successfully deleted learning ".concat(v)):console.error("Failed to delete learning ".concat(v,":"),h.status,h.statusText),[3,5];case 4:return m=t.sent(),console.error("Error deleting learning ".concat(v,":"),m),[3,5];case 5:return c++,[3,1];case 6:return e&&console.log("Delete current learning flag is true - this will be handled later"),[2]}}))}))},T=function(e){var o=e.label,i=e.onToggle,t=d(!1),r=t[0],c=t[1],v=s(null);return u((function(){var e=v.current;e&&r&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[r]),a("span",n({ref:v,onClick:function(){var e=!r;c(e),i(o,e)},style:{cursor:"pointer",backgroundColor:r?"#E8F5E9":"#fbfaff",color:r?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){r||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){r||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[l("span",n({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:r?"scale(1.2)":"scale(1)",opacity:r?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:r?"✓":"+"})),l("span",{children:o})]}))},I=function(C){C.chatAssistantLogoUrl;var I=C.chatAssistantName,M=C.organizationName,F=C.baseUrl,D=C.setInstantLearningSuggestions,N=C.formDataState,j=C.setFormDataState;C.hasUserFilledForm;var O=C.setHasUserFilledForm,W=C.baseWebsocketUrl,B=C.setIsNewChatClicked,z=C.selectedText;C.ChatIconComponent,C.ggcAssistantName;var G=C.ThinkingBulbIconComponent;C.hasUserWrittenModification;var P=C.setExtractedModification,U=C.setSave,K=C.setExtractedTooltip,q=C.setIsSaveLoading;C.isSaveLoading,C.save,C.instantLearningSuggestions,C.template;var H=C.setShouldTriggerSave,J=C.validationWtaResponse,V=C.setValidationWtaResponse,Z=C.learningWtaResponse,Q=C.setLearningWtaResponse,Y=C.isFormSaveClicked,$=C.setIsFormSavedClicked,X=C.onDeleteLearning,ee=C.deleteLearningTrigger,ne=C.setDeleteLearningTrigger;C.onMergeLearning;var oe=C.mergeLearningTrigger,ie=C.setMergeLearningTrigger,te=C.onResetLearningData,le=C.setEditConflictingLearningTrigger,ae=C.setEditSimilarLearningTrigger,re=C.sendMessageInChat,se=C.setSendMessageInChat,de=C.setIsMergeLoading,ce=C.setExtractedHowToRespond,ue=C.setExtractedTopic,ve=C.setExtractedCategories,ge=C.setValidationRecommendations,he=C.validationRecommendations,me=C.addInReview,pe=C.editInReview,fe=C.deleteInReview,Ce=I,ye=s("".concat(Ce,"-").concat(M,"-").concat(h())),_e=s("".concat(h())),we=F,be=s(null),Se=s(null),xe=d([]),Le=xe[0],ke=xe[1],Ae=d(!1);Ae[0];var Ee=Ae[1],Re=d(""),Te=Re[0],Ie=Re[1],Me=d(""),Fe=Me[0],De=Me[1],Ne=d([]),je=Ne[0],Oe=Ne[1],We=d(!1),Be=We[0],ze=We[1],Ge=d(!1);Ge[0];var Pe=Ge[1],Ue=d(!0),Ke=Ue[0],qe=Ue[1],He=d(!0),Je=He[0],Ve=He[1],Ze=d("");Ze[0];var Qe=Ze[1],Ye=d(""),$e=Ye[0],Xe=Ye[1],en=d(!1),nn=en[0],on=en[1],tn=d(!1),ln=tn[0],an=tn[1],rn=d(!1),sn=rn[0],dn=rn[1],cn=d([]);cn[0];var un=cn[1],vn=d(new Set),gn=vn[0],hn=vn[1],mn=d(new Set),pn=mn[0],fn=mn[1],Cn=s(""),yn=s(""),_n=s(new Set),wn=c((function(){return""===(null==Te?void 0:Te.trim())||nn}),[Te,nn]),bn=d(fe||[]),Sn=bn[0],xn=bn[1],Ln=d(pe||[]),kn=Ln[0],An=Ln[1],En=s(null),Rn=d("100%"),Tn=Rn[0],In=Rn[1];c((function(){var e,n,o;return!(""===(null===(e=null==N?void 0:N.original)||void 0===e?void 0:e.trim())||(null==N?void 0:N.isTooltipEnabled)&&""===(null===(n=null==N?void 0:N.tooltip)||void 0===n?void 0:n.trim())||(null==N?void 0:N.isModificationEnabled)&&""===(null===(o=null==N?void 0:N.modification)||void 0===o?void 0:o.trim()))}),[N]),u((function(){var e='Please tell me how I should respond to "'.concat(z,'"? ');De(e)}),[N]),u((function(){var e=be.current,n=function(){var e=be.current;if(e){var n=e.scrollTop,o=e.scrollHeight,i=e.clientHeight;dn(!(o-(n+i)<=35))}};return e&&(e.addEventListener("scroll",n),n()),function(){e&&e.removeEventListener("scroll",n)}}),[sn,Ke,je]);var Mn=v((function(n){return e(void 0,void 0,void 0,(function(){var e,i,l,a,r,s,d;return t(this,(function(t){switch(t.label){case 0:if(e=JSON.stringify({deleted_similar_learning_ids:n.deleted_similar_learning_ids||[],deleted_conflicting_learning_ids:n.deleted_conflicting_learning_ids||[],delete_current_learning:n.delete_current_learning||!1}),_n.current.has(e))return console.log("Delete operation already processed, skipping callback execution:",e),[2];_n.current.add(e),console.log("Processing new delete operation:",e),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,R(n,F,M,Ce)];case 2:return t.sent(),i=n.deleted_similar_learning_ids,l=void 0===i?[]:i,a=n.deleted_conflicting_learning_ids,r=void 0===a?[]:a,s=o(o([],l||[],!0),r||[],!0),hn((function(e){var n=new Set(e);return s.forEach((function(e){return n.add(e)})),console.log("Added deleted learning IDs to tracking set:",Array.from(n)),n})),console.log("UI state updated after deletion of learnings:",s),[3,4];case 3:throw d=t.sent(),_n.current.delete(e),console.error("Error processing delete operation:",d),d;case 4:return[2]}}))}))}),[F,M,Ce,hn]),Fn=v((function(o){return e(void 0,void 0,void 0,(function(){var e,i,l,a,r,s,d,c,u,v,g,h;return t(this,(function(t){switch(t.label){case 0:de(!0),console.log("🔴 MERGE CALLBACK - Processing merge tool call:",o),t.label=1;case 1:if(t.trys.push([1,6,7,8]),e=o.merge_learnings,i=o.similar_learnings,l=o.conditions_whentoapply,a=o.conditions_whennottoapply,console.log("🔴 MERGE CALLBACK - Extracted data:"),console.log("merge_learnings:",e),console.log("similar_learnings:",i),console.log("conditions_whentoapply:",l),console.log("conditions_whennottoapply:",a),!e||!i||!Array.isArray(i))return console.log("Invalid merge tool data, skipping"),[2];console.log(" MERGE CALLBACK - Current formDataState before replacement:",N),console.log(" MERGE CALLBACK - Current whenToApply:",null==N?void 0:N.whenToApply),console.log(" MERGE CALLBACK - Current whenNotToApply:",null==N?void 0:N.whenNotToApply),l&&Array.isArray(l)&&(console.log(" MERGE CALLBACK - UNCONDITIONALLY replacing whenToApply conditions:",l),r=l.join(" OR "),console.log(" MERGE CALLBACK - New whenToApply string:",r),j((function(e){console.log(" MERGE CALLBACK - Previous formDataState:",e);var o=n(n({},e),{whenToApply:r,_mergeUpdate:!0,_mergeWTA:l});return console.log("MERGE CALLBACK - New formDataState:",o),o}))),a&&Array.isArray(a)&&(console.log(" MERGE CALLBACK - UNCONDITIONALLY replacing whenNotToApply conditions:",a),s=a.join(" OR "),console.log(" MERGE CALLBACK - New whenNotToApply string:",s),j((function(e){console.log(" MERGE CALLBACK - Previous formDataState for WNTA:",e);var o=n(n({},e),{whenNotToApply:s,_mergeUpdate:!0,_mergeWNTA:a});return console.log(" MERGE CALLBACK - New formDataState for WNTA:",o),o}))),fn((function(e){var n=new Set(e);return i.forEach((function(e){return n.add(e)})),console.log("Added merged learning IDs to tracking set:",Array.from(n)),n})),d=0,c=i,t.label=2;case 2:return d<c.length?(u=c[d],console.log("Sending delete request for merged learning ID: ".concat(u)),v={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:u,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(u),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},[4,L({baseUrl:F,organizationName:M,chatAssistantName:Ce,payload:v})]):[3,5];case 3:(g=t.sent()).ok?console.log("Successfully deleted merged learning ID ".concat(u)):console.error("Failed to delete merged learning ID ".concat(u,":"),g.statusText),t.label=4;case 4:return d++,[3,2];case 5:return[3,8];case 6:return h=t.sent(),console.error("Error processing merge operation:",h),[3,8];case 7:return console.log("switched off"),de(!1),[7];case 8:return[2]}}))}))}),[X,fn,j,de]),Dn=function(e,o,i,t){return c((function(){for(var l,a=[],r=/['"]conditions_whentoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\2).)*\2\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\3).)*\3\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])\s*,\s*['"]conditions_whennottoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\5).)*\5\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\6).)*\6\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])/,s=/['"]conditions_whentoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\2).)*\2\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\3).)*\3\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])\s*,\s*['"]conditions_whennottoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\5).)*\5\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\6).)*\6\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])/,d=/['"]is_valid['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflictingConditions['"]\s*:\s*\[\s*(?:\{[\s\S]*?['"]conflictType['"]\s*:\s*['"][^'"]+['"][\s\S]*?\}\s*,?\s*)*\]\s*,\s*['"]save['"]\s*:\s*(true|false|True|False)/,c=/['"]is_valid_db['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflicting_learnings['"]\s*:\s*\{[\s\S]*?\}\s*,\s*['"]similar_learnings['"]\s*:\s*\{[\s\S]*?\}\s*,\s*["']save["']\s*:\s*(true|false|True|False)/,u=/['"]delete_current_learning['"]\s*:\s*(true|false|True|False)\s*,\s*['"]deleted_similar_learning_ids['"]\s*:\s*\[[\s\S]*?\]\s*,\s*['"]deleted_conflicting_learning_ids['"]\s*:\s*\[[\s\S]*?\]/,v=/{\s*['"]merge_learnings['"]\s*:\s*(?:True|true)[\s\S]+?}/,g=/({[\s\S]*}|\[[\s\S]*\])/,h=/({[\s\S]*})/,m=0,p=(null===(l=e[e.length-1])||void 0===l?void 0:l.orchestratorAndAgentsMessages)||[];m<p.length;m++){var f=p[m],C=(null==f?void 0:f.responsedata)||"";console.log("🔍 RESPONSE DATA:",String(C)),String(C).includes("merge_learnings")&&(console.log("🔍 FOUND merge_learnings in response!"),console.log("🔍 Full response:",String(C))),String(C).includes("'merge_learnings'")&&(console.log("🔍 FOUND merge_learnings in response!"),console.log("🔍 Full response:",String(C)));var y=C.match(r);if(y)try{var _=w.parse("{".concat(y[0],"}"));a.push(_)}catch(e){console.error("Failed to parse JSON:",e)}var b=C.match(s);if(b)try{var S=x(b[0]||""),L=w.parse("{".concat(S,"}"));console.log("Contextual conditions detected:",L),a.push(n(n({},L),{_isContextual:!0}))}catch(e){console.error("Failed to parse contextual JSON:",e)}var A=C.match(d);if(console.log("validationObj before cond ",A),A)try{var E=x(C||"");(R=w.parse(E))&&"object"==typeof R&&"is_valid"in R&&"conflictingConditions"in R&&(console.log("Found validation data in response:",R),V(R),console.log("dbVal after set in chat",J))}catch(e){console.error("Failed to parse validation JSON:",e)}try{var R,T=x(C||"");if((R=w.parse(T))&&"object"==typeof R&&"is_valid_db"in R&&"conflicting_learnings"in R&&"similar_learnings"in R)console.log("Found validation data in response:",R),Q(R),console.log("dbVal after set in chat",Z);else if(F=C.match(c)){var I=x(F[0]||""),M=w.parse("{".concat(I,"}"));Q(M),console.log("dbVal after set in chat (regex fallback)",Z)}}catch(e){var F;if(console.log("JSON parsing failed, trying regex fallback for validation data"),F=C.match(c))try{I=x(F[0]||""),M=w.parse("{".concat(I,"}"));Q(M),console.log("dbVal after set in chat (regex fallback)",Z)}catch(e){console.error("Failed to parse validation JSON with regex fallback:",e)}}var D=C.match(u);if(D)try{var N=x(D[0]||""),j=w.parse("{".concat(N,"}"));console.log("Delete tool detected:",j),i&&i(j)}catch(e){console.error("Failed to parse delete tool JSON:",e)}console.log("🔍 Testing merge tool regex on response data...");var O=C.match(v);if(console.log("🔍 Merge tool regex match result:",O),O){console.log("🔍 MERGE TOOL REGEX MATCHED!");try{var W=O[0],B=x(W),z=w.parse(B);console.log("✅ Correctly parsed merge tool object:",z),t&&t(z)}catch(e){console.error("Failed to parse merge tool JSON:",e)}}var G=C.match(g);if(G&&C.includes("edit_actions"))try{console.log("Edit tool match found:",G[0]);B=x(G[0]);var P=w.parse(B);console.log("Edit tool detected and parsed successfully:",P),P.conflicting_learnings&&(le(P.conflicting_learnings),console.log("Setting edit conflicting learning trigger:",P.conflicting_learnings)),P.similar_learnings&&(ae(P.similar_learnings),console.log("Setting edit similar learning trigger:",P.similar_learnings))}catch(e){console.error("Failed to parse edit tool JSON:",e)}var U=C.match(h);if(U)try{B=x(U[0]);var K=w.parse(B);if(K.recommended_whentoapply||K.recommended_whennottoapply){console.log("Found recommendation data:",K);var q=k(K);console.log("Parsed recommendations:",q),o(q)}}catch(e){}}return a}),[e,i])}(je,ge,Mn,Fn);u((function(){var e,o,i=(null==Dn?void 0:Dn[(null==Dn?void 0:Dn.length)-1])||null;if(i){if(i._isContextual){console.log("Processing contextual suggestions:",i);var t=(null===(e=i.conditions_whentoapply)||void 0===e?void 0:e.map((function(e){return e.when_to_apply})))||[],l=(null===(o=i.conditions_whennottoapply)||void 0===o?void 0:o.map((function(e){return e.when_not_to_apply})))||[];j((function(e){return n(n({},e),{whenToApply:t,whenNotToApply:l,_contextualUpdate:!0})}))}else D(i);console.log("Parsed suggestions:",Dn)}}),[Dn]),u((function(){if(Z&&0!==gn.size){var e=Z.conflicting_learnings&&Object.values(Z.conflicting_learnings).some((function(e){return gn.has(e.id)})),o=Z.similar_learnings&&Object.values(Z.similar_learnings).some((function(e){return gn.has(e.id)}));if(e||o){var i=JSON.stringify({deletedIds:Array.from(gn).sort()});if(Cn.current!==i){var t=n({},Z);if(t.conflicting_learnings){var l=Object.values(t.conflicting_learnings).filter((function(e){return!gn.has(e.id)}));console.log("[ChatComponent] Re-keying conflicting learnings:",{originalKeys:Object.keys(t.conflicting_learnings),remainingCount:l.length,remainingLearnings:l.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var a={};l.forEach((function(e,n){var o=String.fromCharCode(65+n);a[o]=e,console.log("[ChatComponent] Conflicting learning ".concat(n," gets key '").concat(o,"':"),e.feedback.variant)})),t.conflicting_learnings=a,console.log("[ChatComponent] Final conflicting learnings keys:",Object.keys(a))}if(t.similar_learnings){var r=Object.values(t.similar_learnings).filter((function(e){return!gn.has(e.id)}));console.log("[ChatComponent] Re-keying similar learnings:",{originalKeys:Object.keys(t.similar_learnings),remainingCount:r.length,remainingLearnings:r.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var s={};r.forEach((function(e,n){var o=String.fromCharCode(65+n);s[o]=e,console.log("[ChatComponent] Similar learning ".concat(n," gets key '").concat(o,"':"),e.feedback.variant)})),t.similar_learnings=s,console.log("[ChatComponent] Final similar learnings keys:",Object.keys(s))}Cn.current=i,console.log("Filtered learningWtaResponse after deletion:",t),Q(t)}}}}),[gn,Z,Q]),u((function(){if(Z&&0!==pn.size&&(Z.similar_learnings&&Object.values(Z.similar_learnings).some((function(e){return pn.has(e.id)})))){var e=JSON.stringify({mergedIds:Array.from(pn).sort()});if(yn.current!==e){var o=n({},Z);if(o.similar_learnings){var i=Object.values(o.similar_learnings).filter((function(e){return!pn.has(e.id)}));console.log("[ChatComponent] Re-keying similar learnings after merge:",{originalKeys:Object.keys(o.similar_learnings),remainingCount:i.length,remainingLearnings:i.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var t={};i.forEach((function(e,n){var o=String.fromCharCode(65+n);t[o]=e,console.log("[ChatComponent] Similar learning ".concat(n," gets key '").concat(o,"':"),e.feedback.variant)})),o.similar_learnings=t,console.log("[ChatComponent] Final similar learnings keys after merge:",Object.keys(t))}yn.current=e,console.log("Filtered learningWtaResponse after merge:",o),Q(o)}}}),[pn,Z,Q]);var Nn=function(e){return c((function(){for(var n,o=[],i=/['"]howtorespond['"]\s*:\s*['"](.*?)['"]/g,t=/['"]topic['"]\s*:\s*['"](.*?)['"]/g,l=/['"]categories['"]\s*:\s*\[(.*?)\]/g,a=/['"]scope['"]\s*:\s*['"](Global|Assistant|User|Custom)['"]/g,r=0,s=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];r<s.length;r++){var d=s[r],c=(null==d?void 0:d.responsedata)||"",u={},v=i.exec(c);v&&v[1]&&(u.howtorespond=v[1]),i.lastIndex=0;var g=t.exec(c);g&&g[1]&&(u.topic=g[1]),t.lastIndex=0;var h=l.exec(c);if(h&&h[1]){var m=h[1].split(",").map((function(e){return e.trim().replace(/['"]/g,"")})).filter((function(e){return e.length>0}));u.categories=m}l.lastIndex=0;var p=a.exec(c);p&&p[1]&&(u.scope=p[1]),a.lastIndex=0,Object.keys(u).length>0&&o.push(u)}return o}),[e])}(je);u((function(){var e=(null==Nn?void 0:Nn[(null==Nn?void 0:Nn.length)-1])||null;e&&(e.howtorespond&&ce(e.howtorespond),e.topic&&ue(e.topic),e.categories&&Array.isArray(e.categories)&&ve(e.categories),e.scope&&j((function(o){if(o.scope.name===e.scope)return o;var i=null;return"User"===e.scope?i=[]:"Assistant"===e.scope&&(i={assistantName:I||"",conciergeId:I||""}),console.log("📌 Scope Set from Chat:",e.scope),n(n({},o),{scope:{name:e.scope,value:i}})})))}),[Nn,ce,ue,ve,j,I]);var jn=function(e){return c((function(){for(var n,o=[],i=/['"](\w+)['"]\s*:\s*['"](.*?)['"]/g,t=0,l=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];t<l.length;t++){var a=l[t],r=((null==a?void 0:a.responsedata)||"").match(i);if(r)try{var s=w.parse("{".concat(r[0],"}"));o.push(s)}catch(e){console.error("Failed to parse JSON for header message:",e)}}return o}),[e])}(je);u((function(){var e=(null==jn?void 0:jn[(null==jn?void 0:jn.length)-1])||null;e&&P(e.modification)}),[jn]);!function(e,n){u((function(){for(var o,i=0,t=(null===(o=e[e.length-1])||void 0===o?void 0:o.orchestratorAndAgentsMessages)||[];i<t.length;i++){for(var l=t[i],a=(null==l?void 0:l.responsedata)||"",r=/<wta>([\s\S]*?)<\/wta>/gi,s=[],d=void 0;null!==(d=r.exec(a));)console.log("match wta suggestion",d),s.push(d[1]);s.length&&n(s)}}),[e,n])}(je,un);var On=function(e){return c((function(){for(var n,o=[],i=/^\{\s*(['"])(\w+)\1\s*:\s*(['"])(.*?)\3\s*\}$/,t=0,l=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];t<l.length;t++){var a=l[t],r=((null==a?void 0:a.responsedata)||"").match(i);if(r){console.log("match: ",r[0]);try{var s=w.parse(r[0]);o.push(s)}catch(e){console.error("Failed to parse JSON:",e)}}}return o}),[e])}(je);u((function(){var e=(null==On?void 0:On[(null==On?void 0:On.length)-1])||null;e&&(console.log("latestParseTooltip: ",e),K(null==e?void 0:e.tooltip))}),[On]);var Wn=function(e){var n=d([]),o=n[0],i=n[1];return u((function(){for(var n,o=[],t=/\{\s*['"]save['"]\s*:\s*(True|False|true|false)\s*\}/,l=0,a=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];l<a.length;l++){var r=a[l],s=((null==r?void 0:r.responsedata)||"").match(t);if(s)try{var d=s[0].replace(/\bTrue\b/,"true").replace(/\bFalse\b/,"false").replace(/'/g,'"');console.log("corrected:",d);var c=w.parse(d);!0===c.save&&H(!0),o.push(c)}catch(e){console.error("Failed to parse JSON:",e)}}i(o)}),[e]),o}(je);u((function(){var e=(null==Wn?void 0:Wn[(null==Wn?void 0:Wn.length)-1])||null;if(e&&"boolean"==typeof e.save){q(!0);var n=setTimeout((function(){q(!1),U(e.save)}),200);return function(){clearTimeout(n)}}}),[Wn]),u((function(){Y&&(Kn(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save it"),$(!1))}),[Y]),u((function(){if(ee&&X){var e="Delete learning ".concat(ee);Kn(new KeyboardEvent("keydown",{key:"Enter"}),!1,e),ne&&ne(null)}}),[ee,X,ne]),u((function(){re&&(Kn(new KeyboardEvent("keydown",{key:"Enter"}),!1,re),se(""))}),[re]),u((function(){zn(),Gn();var e=function(){var e,n=(null===(e=null==En?void 0:En.current)||void 0===e?void 0:e.clientHeight)||0,o="calc(100% - ".concat(n,"px - 10px");In(o)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]);var Bn=v((function(){var e=be.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),dn(!1)}),100)}),[]);u((function(){(null==Le?void 0:Le.length)>0&&Bn()}),[Le]);var zn=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(we,"/api/chatbot/getChatSettings?name=").concat(Ce,"&organizationName=").concat(M),headers:{}};m.request(e).then((function(e){var n,o,i;(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)&&""!==(null===(i=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.chatSettings)||void 0===i?void 0:i.chatInitialMessage)&&Ve(!0)})).catch((function(e){console.error(e)}))},Gn=function(){return e(void 0,void 0,void 0,(function(){var e,n;return t(this,(function(o){e="".concat(we,"/api/chat/history?name=").concat(Ce,"&organizationName=").concat(M);try{n={method:"GET",params:{guestSessionId:ye.current},withCredentials:!0},m.get(e,n).then((function(e){var n=e.data;n.length>0?(Oe(n),Bn()):Ve(!0)})).catch((function(e){console.error(e)}))}catch(e){ze(!1),console.error(e)}return[2]}))}))};function Pn(e){return null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,(function(e){return null==e?void 0:e.replace(/\*/g,"*")}))}var Un=function(e,i,t,l,a,r){var s,d,c,u,v,g,m,p,f,C,y,_,w,b,S,x,L,k;console.log("userInput: ",a);var A={role:"assistant",content:"",id:h()};if(null===(u=null===(c=null===(d=null===(s=null==e?void 0:e.chatStream)||void 0===s?void 0:s.continueChatResult)||void 0===d?void 0:d.message)||void 0===c?void 0:c.content)||void 0===u?void 0:u.includes("WaitMessage: "))ze(!1),Pe(!0),A.content=function(e){var n="WaitMessage: ",o=e.indexOf(n);if(-1!==o){var i=e.substring(o+13);return null==i?void 0:i.replaceAll("WaitMessage: ","")}return""}((null===(m=null===(g=null===(v=null==e?void 0:e.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===g?void 0:g.message)||void 0===m?void 0:m.content)+"\n\n"),Oe(o(o([],je,!0),[{role:"user",content:a,time:l,isFirstQuestionSent:r||!1,id:(null===(f=null===(p=null==e?void 0:e.chatStream)||void 0===p?void 0:p.continueChatResult)||void 0===f?void 0:f.requestId)||"",reply:""},A],!1));else{ze(!1),Pe(!1),A.content=null===(w=Pn(null===(_=null===(y=null===(C=null==e?void 0:e.chatStream)||void 0===C?void 0:C.continueChatResult)||void 0===y?void 0:y.message)||void 0===_?void 0:_.content))||void 0===w?void 0:w.replaceAll("WaitMessage: ","");var E=function(e,i,t){var l,a,r,s,d,c,u,v,g,m,p,f,C,y,_,w,b,S,x,L,k,A,E,R,T,I,M,F,D,N,j,O,W,B,z,G,P,U,K,q,H,J,V,Z,Q,Y,$,X,ee,ne,oe,ie,te,le,ae,re,se,de,ce,ue,ve,ge,he,me,pe,fe,Ce,ye,_e,we,be,Se,xe,Le,ke,Ae,Ee,Re,Te,Ie,Me,Fe,De,Ne,je,Oe,We,Be,ze,Ge,Pe,Ue,Ke,qe,He,Je,Ve,Ze,Qe,Ye,$e,Xe,en,nn,on,tn,ln,an,rn,sn,dn,cn,un,vn,gn,hn,mn,pn,fn,Cn,yn,_n,wn,bn,Sn,xn,Ln,kn,An,En,Rn,Tn,In,Mn,Fn,Dn,Nn,jn,On,Wn,Bn,zn,Gn,Un,Kn,qn,Hn,Jn,Vn,Zn,Qn,Yn,$n,Xn,eo,no,oo,io,to,lo,ao,ro,so,co,uo,vo,go,ho,mo,po;console.log("event",e,Object.keys(e)),console.log("content: ",null==e?void 0:e.data);var fo={role:"assistant",content:"",id:h()};if(!1===(null===(r=null===(a=null===(l=null==e?void 0:e.data)||void 0===l?void 0:l.chatStream)||void 0===a?void 0:a.continueChatResult)||void 0===r?void 0:r.thinking_break)&&!0===(null===(c=null===(d=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===c?void 0:c.is_orchestrator)&&!1===(null===(g=null===(v=null===(u=null==e?void 0:e.data)||void 0===u?void 0:u.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===g?void 0:g.isEnd)&&(fo.content=null===(y=Pn(null===(C=null===(f=null===(p=null===(m=null==e?void 0:e.data)||void 0===m?void 0:m.chatStream)||void 0===p?void 0:p.continueChatResult)||void 0===f?void 0:f.message)||void 0===C?void 0:C.content))||void 0===y?void 0:y.replaceAll("WaitMessage: ","")),!0===(null===(b=null===(w=null===(_=null==e?void 0:e.data)||void 0===_?void 0:_.chatStream)||void 0===w?void 0:w.continueChatResult)||void 0===b?void 0:b.thinking_break)&&!0===(null===(L=null===(x=null===(S=null==e?void 0:e.data)||void 0===S?void 0:S.chatStream)||void 0===x?void 0:x.continueChatResult)||void 0===L?void 0:L.is_orchestrator)&&!1===(null===(E=null===(A=null===(k=null==e?void 0:e.data)||void 0===k?void 0:k.chatStream)||void 0===A?void 0:A.continueChatResult)||void 0===E?void 0:E.isEnd)&&(fo.content="",i.push({responsedata:null===(M=null===(I=null===(T=null===(R=null==e?void 0:e.data)||void 0===R?void 0:R.chatStream)||void 0===T?void 0:T.continueChatResult)||void 0===I?void 0:I.message)||void 0===M?void 0:M.content,responseFrom:null===(N=null===(D=null===(F=null==e?void 0:e.data)||void 0===F?void 0:F.chatStream)||void 0===D?void 0:D.continueChatResult)||void 0===N?void 0:N.responded_by,header_message:null===(W=null===(O=null===(j=null==e?void 0:e.data)||void 0===j?void 0:j.chatStream)||void 0===O?void 0:O.continueChatResult)||void 0===W?void 0:W.header_message,finalResponseStatus:!1,explainability_id:null!==(P=null===(G=null===(z=null===(B=null==e?void 0:e.data)||void 0===B?void 0:B.chatStream)||void 0===z?void 0:z.continueChatResult)||void 0===G?void 0:G.explainability_id)&&void 0!==P?P:"",isParallelToolResponse:!1})),!1===(null===(q=null===(K=null===(U=null==e?void 0:e.data)||void 0===U?void 0:U.chatStream)||void 0===K?void 0:K.continueChatResult)||void 0===q?void 0:q.thinking_break)&&!0===(null===(V=null===(J=null===(H=null==e?void 0:e.data)||void 0===H?void 0:H.chatStream)||void 0===J?void 0:J.continueChatResult)||void 0===V?void 0:V.is_orchestrator)&&!0===(null===(Y=null===(Q=null===(Z=null==e?void 0:e.data)||void 0===Z?void 0:Z.chatStream)||void 0===Q?void 0:Q.continueChatResult)||void 0===Y?void 0:Y.isEnd)&&(fo.content=null===(oe=Pn(null===(ne=null===(ee=null===(X=null===($=null==e?void 0:e.data)||void 0===$?void 0:$.chatStream)||void 0===X?void 0:X.continueChatResult)||void 0===ee?void 0:ee.message)||void 0===ne?void 0:ne.content))||void 0===oe?void 0:oe.replaceAll("WaitMessage: ","")),!1===(null===(le=null===(te=null===(ie=null==e?void 0:e.data)||void 0===ie?void 0:ie.chatStream)||void 0===te?void 0:te.continueChatResult)||void 0===le?void 0:le.thinking_break)&&!1===(null===(se=null===(re=null===(ae=null==e?void 0:e.data)||void 0===ae?void 0:ae.chatStream)||void 0===re?void 0:re.continueChatResult)||void 0===se?void 0:se.is_orchestrator)&&!1===(null===(ue=null===(ce=null===(de=null==e?void 0:e.data)||void 0===de?void 0:de.chatStream)||void 0===ce?void 0:ce.continueChatResult)||void 0===ue?void 0:ue.isEnd)){if((_o=null===(ge=null===(ve=null==e?void 0:e.data)||void 0===ve?void 0:ve.chatStream)||void 0===ge?void 0:ge.continueChatResult).explainability_id&&_o.responded_by){var Co=_o.explainability_id,yo=_o.responded_by;t.has(Co)||t.set(Co,{responded_by:yo,index:i.length})}t.has(null===(me=null===(he=null==e?void 0:e.data)||void 0===he?void 0:he.chatStream)||void 0===me?void 0:me.continueChatResult.explainability_id)?i[Lo=null==(wo=t.get(null===(Ce=null===(fe=null===(pe=null==e?void 0:e.data)||void 0===pe?void 0:pe.chatStream)||void 0===fe?void 0:fe.continueChatResult)||void 0===Ce?void 0:Ce.explainability_id))?void 0:wo.index]={responsedata:null===(be=null===(we=null===(_e=null===(ye=null==e?void 0:e.data)||void 0===ye?void 0:ye.chatStream)||void 0===_e?void 0:_e.continueChatResult)||void 0===we?void 0:we.message)||void 0===be?void 0:be.content,responseFrom:null===(Le=null===(xe=null===(Se=null==e?void 0:e.data)||void 0===Se?void 0:Se.chatStream)||void 0===xe?void 0:xe.continueChatResult)||void 0===Le?void 0:Le.responded_by,header_message:null===(Ee=null===(Ae=null===(ke=null==e?void 0:e.data)||void 0===ke?void 0:ke.chatStream)||void 0===Ae?void 0:Ae.continueChatResult)||void 0===Ee?void 0:Ee.header_message,finalResponseStatus:!0,explainability_id:null!==(Me=null===(Ie=null===(Te=null===(Re=null==e?void 0:e.data)||void 0===Re?void 0:Re.chatStream)||void 0===Te?void 0:Te.continueChatResult)||void 0===Ie?void 0:Ie.explainability_id)&&void 0!==Me?Me:"",isParallelToolResponse:!0}:i=o(o([],i,!0),[{responsedata:null===(je=null===(Ne=null===(De=null===(Fe=null==e?void 0:e.data)||void 0===Fe?void 0:Fe.chatStream)||void 0===De?void 0:De.continueChatResult)||void 0===Ne?void 0:Ne.message)||void 0===je?void 0:je.content,responseFrom:null===(Be=null===(We=null===(Oe=null==e?void 0:e.data)||void 0===Oe?void 0:Oe.chatStream)||void 0===We?void 0:We.continueChatResult)||void 0===Be?void 0:Be.responded_by,header_message:null===(Pe=null===(Ge=null===(ze=null==e?void 0:e.data)||void 0===ze?void 0:ze.chatStream)||void 0===Ge?void 0:Ge.continueChatResult)||void 0===Pe?void 0:Pe.header_message,finalResponseStatus:!0,explainability_id:null!==(He=null===(qe=null===(Ke=null===(Ue=null==e?void 0:e.data)||void 0===Ue?void 0:Ue.chatStream)||void 0===Ke?void 0:Ke.continueChatResult)||void 0===qe?void 0:qe.explainability_id)&&void 0!==He?He:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(Ze=null===(Ve=null===(Je=null==e?void 0:e.data)||void 0===Je?void 0:Je.chatStream)||void 0===Ve?void 0:Ve.continueChatResult)||void 0===Ze?void 0:Ze.thinking_break)&&!1===(null===($e=null===(Ye=null===(Qe=null==e?void 0:e.data)||void 0===Qe?void 0:Qe.chatStream)||void 0===Ye?void 0:Ye.continueChatResult)||void 0===$e?void 0:$e.is_orchestrator)&&!1===(null===(nn=null===(en=null===(Xe=null==e?void 0:e.data)||void 0===Xe?void 0:Xe.chatStream)||void 0===en?void 0:en.continueChatResult)||void 0===nn?void 0:nn.isEnd)){var _o,wo;(_o=null===(tn=null===(on=null==e?void 0:e.data)||void 0===on?void 0:on.chatStream)||void 0===tn?void 0:tn.continueChatResult).explainability_id&&_o.responded_by&&(Co=_o.explainability_id,yo=_o.responded_by,t.has(Co)||t.set(Co,{responded_by:yo,index:i.length})),t.has(null===(rn=null===(an=null===(ln=null==e?void 0:e.data)||void 0===ln?void 0:ln.chatStream)||void 0===an?void 0:an.continueChatResult)||void 0===rn?void 0:rn.explainability_id)?i[Lo=null==(wo=t.get(null===(cn=null===(dn=null===(sn=null==e?void 0:e.data)||void 0===sn?void 0:sn.chatStream)||void 0===dn?void 0:dn.continueChatResult)||void 0===cn?void 0:cn.explainability_id))?void 0:wo.index]={responsedata:null===(hn=null===(gn=null===(vn=null===(un=null==e?void 0:e.data)||void 0===un?void 0:un.chatStream)||void 0===vn?void 0:vn.continueChatResult)||void 0===gn?void 0:gn.message)||void 0===hn?void 0:hn.content,responseFrom:null===(fn=null===(pn=null===(mn=null==e?void 0:e.data)||void 0===mn?void 0:mn.chatStream)||void 0===pn?void 0:pn.continueChatResult)||void 0===fn?void 0:fn.responded_by,header_message:null===(_n=null===(yn=null===(Cn=null==e?void 0:e.data)||void 0===Cn?void 0:Cn.chatStream)||void 0===yn?void 0:yn.continueChatResult)||void 0===_n?void 0:_n.header_message,finalResponseStatus:!1,explainability_id:null!==(xn=null===(Sn=null===(bn=null===(wn=null==e?void 0:e.data)||void 0===wn?void 0:wn.chatStream)||void 0===bn?void 0:bn.continueChatResult)||void 0===Sn?void 0:Sn.explainability_id)&&void 0!==xn?xn:"",isParallelToolResponse:!0}:i.push({responsedata:null===(En=null===(An=null===(kn=null===(Ln=null==e?void 0:e.data)||void 0===Ln?void 0:Ln.chatStream)||void 0===kn?void 0:kn.continueChatResult)||void 0===An?void 0:An.message)||void 0===En?void 0:En.content,responseFrom:null===(In=null===(Tn=null===(Rn=null==e?void 0:e.data)||void 0===Rn?void 0:Rn.chatStream)||void 0===Tn?void 0:Tn.continueChatResult)||void 0===In?void 0:In.responded_by,header_message:null===(Dn=null===(Fn=null===(Mn=null==e?void 0:e.data)||void 0===Mn?void 0:Mn.chatStream)||void 0===Fn?void 0:Fn.continueChatResult)||void 0===Dn?void 0:Dn.header_message,finalResponseStatus:!1,explainability_id:null!==(Wn=null===(On=null===(jn=null===(Nn=null==e?void 0:e.data)||void 0===Nn?void 0:Nn.chatStream)||void 0===jn?void 0:jn.continueChatResult)||void 0===On?void 0:On.explainability_id)&&void 0!==Wn?Wn:"",isParallelToolResponse:!1})}var bo=null===(Un=null===(Gn=null===(zn=null===(Bn=null==e?void 0:e.data)||void 0===Bn?void 0:Bn.chatStream)||void 0===zn?void 0:zn.continueChatResult)||void 0===Gn?void 0:Gn.message)||void 0===Un?void 0:Un.annotations,So=(null===(Jn=null===(Hn=null===(qn=null===(Kn=null==e?void 0:e.data)||void 0===Kn?void 0:Kn.chatStream)||void 0===qn?void 0:qn.continueChatResult)||void 0===Hn?void 0:Hn.message)||void 0===Jn?void 0:Jn.userFeedbackId)||"",xo={role:"assistant",content:fo.content,orchestratorAndAgentsMessages:i,time:new Date,requestId:null!==(Yn=null===(Qn=null===(Zn=null===(Vn=null==e?void 0:e.data)||void 0===Vn?void 0:Vn.chatStream)||void 0===Zn?void 0:Zn.continueChatResult)||void 0===Qn?void 0:Qn.requestId)&&void 0!==Yn?Yn:"",citations:null===(no=null===(eo=null===(Xn=null===($n=null==e?void 0:e.data)||void 0===$n?void 0:$n.chatStream)||void 0===Xn?void 0:Xn.continueChatResult)||void 0===eo?void 0:eo.message)||void 0===no?void 0:no.citations,guides_utilized:null!==(ao=null===(lo=null===(to=null===(io=null===(oo=null==e?void 0:e.data)||void 0===oo?void 0:oo.chatStream)||void 0===io?void 0:io.continueChatResult)||void 0===to?void 0:to.message)||void 0===lo?void 0:lo.guides_utilized)&&void 0!==ao?ao:[],annotations:bo,resourceId:null===(co=null===(so=null===(ro=null==e?void 0:e.data)||void 0===ro?void 0:ro.chatStream)||void 0===so?void 0:so.continueChatResult)||void 0===co?void 0:co.resourceId,userFeedbackId:So,citationDisplayType:null!==(mo=null===(ho=null===(go=null===(vo=null===(uo=null==e?void 0:e.data)||void 0===uo?void 0:uo.chatStream)||void 0===vo?void 0:vo.continueChatResult)||void 0===go?void 0:go.message)||void 0===ho?void 0:ho.citationDisplayType)&&void 0!==mo?mo:""};if(bo)for(var Lo=0;Lo<(null==bo?void 0:bo.length);Lo++){var ko=bo[Lo];xo=n(n({},xo),{content:null===(po=null==xo?void 0:xo.content)||void 0===po?void 0:po.replace(null==ko?void 0:ko.text,(null==ko?void 0:ko.text)+"<sup>".concat(Lo,"</sup>"))})}return xo}({data:e},t,i);console.log("assistantObject",E),Oe(o(o([],je,!0),[{role:"user",content:a||"",time:l,isFirstQuestionSent:r||!1,requestId:null!==(x=null===(S=null===(b=null==e?void 0:e.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===S?void 0:S.requestId)&&void 0!==x?x:""},E],!1)),qe(null===(k=null===(L=null==e?void 0:e.chatStream)||void 0===L?void 0:L.continueChatResult)||void 0===k?void 0:k.isEnd)}},Kn=function(e,i,t){var l,a,r,s,d,c,u,v,m,p=(null==t?void 0:t.trim())||(null==Te?void 0:Te.trim())||"",f=function(e){return Array.isArray(e)?e.filter((function(e){return""!==e.trim()})):"string"==typeof e?e.split(" OR ").filter((function(e){return""!==e.trim()})):[]},C=f(null==N?void 0:N.whenToApply),y=f(null==N?void 0:N.whenNotToApply),_=null===(l=null==N?void 0:N.scope)||void 0===l?void 0:l.name,w=null;if(null===(a=null==N?void 0:N.scope)||void 0===a?void 0:a.value)try{switch(_){case"Assistant":w=N.scope.value.conciergeId||null;break;case"User":var b=N.scope.value;b.length>0&&(w=b[0].userId||null);break;case"Custom":var S=N.scope.value.scopeId;w=S?[S]:[];break;default:w=null}}catch(e){console.error("Error parsing scope_id:",e,N.scope),w=null}if(!("Enter"!==e.key||e.shiftKey||""===(null==t?void 0:t.trim())&&""===(null==Te?void 0:Te.trim())||nn)){on(!0);var x=new Date;Oe(o(o([],je.map((function(e,o){var i;return n(n({},e),{content:null===(i=Pn(e.content))||void 0===i?void 0:i.replace("WaitMessage: ","")})})),!0),[{role:"user",content:p,time:x,isFirstQuestionSent:!1}],!1));var L=p.toLowerCase(),k=L.startsWith("delete "),A=L.startsWith("edit "),E=L.startsWith("merge "),R=Sn,T=kn;if(k){console.log("Delete message detected, parsing for specific label...");if(oe=p.match(/^Delete (?:conflict|similar) learning ([A-Z])/i)){var I=oe[1];console.log('Found label "'.concat(I,'" in delete message.'));var F=(null==Z?void 0:Z.conflicting_learnings)||{},D=(null==Z?void 0:Z.similar_learnings)||{};if(se=n(n({},F),D)[I]){var j={question_id:se.id,variant_id:se.variant_id};if(Sn.some((function(e){return e.question_id===j.question_id})))console.log("Item already in delete state, not adding again."),R=Sn;else{var O=o(o([],Sn,!0),[j],!1);xn(O),R=O,console.log("Appended new deletion to in_review state:",j)}}else console.warn("Delete message parsed, but could not find learning for label:",I),R=Sn}else{console.warn("Could not parse label. Checking for generic delete (e.g., 'Delete similar learning').");F=(null==Z?void 0:Z.conflicting_learnings)||{},D=(null==Z?void 0:Z.similar_learnings)||{};var B=Object.values(F),z=Object.values(D),G=[];if(L.includes("similar learnings")&&z.length>1?(console.log("Found ".concat(z.length," similar learnings. Auto-selecting ALL for deletion.")),G=z):L.includes("conflicting learnings")&&B.length>1?(console.log("Found ".concat(B.length," conflicting learnings. Auto-selecting ALL for deletion.")),G=B):L.includes("similar learning")&&1===z.length?(console.log("Found 1 similar learning. Auto-selecting for deletion."),G=[z[0]]):L.includes("conflicting learning")&&1===B.length?(console.log("Found 1 conflicting learning. Auto-selecting for deletion."),G=[B[0]]):console.log("Generic delete message, but conditions not met (e.g., used 'learnings' for 1 item). No action taken."),G.length>0){for(var P=[],U=0,K=function(e){if(e&&e.id&&e.variant_id){var n={question_id:e.id,variant_id:e.variant_id};Sn.some((function(e){return e.question_id===n.question_id}))||(P.push(n),U++)}else console.warn("Skipping invalid learning object during auto-delete:",e)},q=0,H=G;q<H.length;q++){K(se=H[q])}if(U>0){O=o(o([],Sn,!0),P,!0);xn(O),R=O,console.log("Appended ".concat(U," new generic deletion(s) to in_review state:"),P)}else console.log("Item(s) already in delete state, not adding again."),R=Sn}else R=Sn}}else if(A){console.log("Edit message detected, parsing and persisting 'in_review.edit' state.");if(oe=p.match(/^Edit (?:conflict|similar) learning ([A-Z]) to respond with "([\s\S]*?)" with WTA: ([\s\S]*?) (?:and WNTA: ([\s\S]*)|and remove the WNTA conditions)$/i)){oe[0];I=oe[1];var V=oe[2],Q=oe[3],Y=oe[4];console.log('Found label "'.concat(I,'" in edit message.'));F=(null==Z?void 0:Z.conflicting_learnings)||{},D=(null==Z?void 0:Z.similar_learnings)||{};var $=n(n({},F),D)[I];if($){var X={id:$.id,feedback:{variant:V.trim(),when_to_apply:Q.trim(),when_not_to_apply:(Y||"").trim()},variant_id:$.variant_id};console.log("Constructed new edit object:",X);var ee=kn.filter((function(e){return e.id!==$.id})),ne=o(o([],ee,!0),[X],!1);An(ne),T=ne}else console.warn("Edit message parsed, but could not find learning for label:",I),T=kn}else console.warn("Could not parse edit message:",p),T=kn}else if(E){console.log("Merge message detected, parsing and persisting as 'in_review.delete' state.");var oe;if(oe=p.match(/^Merge (?:Similar|Conflicting) Learning ([A-Z])/i)){I=oe[1].toUpperCase();console.log('Found label "'.concat(I,'" in merge message.'));F=(null==Z?void 0:Z.conflicting_learnings)||{},D=(null==Z?void 0:Z.similar_learnings)||{};if(se=n(n({},F),D)[I]){var ie={question_id:se.id,variant_id:se.variant_id};if(Sn.some((function(e){return e.question_id===ie.question_id})))console.log("Item (from merge) already in delete state, not adding again."),R=Sn;else{O=o(o([],Sn,!0),[ie],!1);xn(O),R=O,console.log("Appended new MERGE-AS-DELETE to in_review state:",ie)}}else console.warn("Merge message parsed, but could not find learning for label:",I),R=Sn}else{console.warn("Could not parse label for merge. Checking for generic merge (e.g., 'Merge similar learning').");F=(null==Z?void 0:Z.conflicting_learnings)||{},D=(null==Z?void 0:Z.similar_learnings)||{},B=Object.values(F),z=Object.values(D);var te=[];if(L.includes("similar learnings")&&z.length>1?(console.log("Found ".concat(z.length," similar learnings. Auto-selecting ALL for MERGE.")),te=z):L.includes("conflicting learnings")&&B.length>1?(console.log("Found ".concat(B.length," conflicting learnings. Auto-selecting ALL for MERGE.")),te=B):L.includes("similar learning")&&1===z.length?(console.log("Found 1 similar learning. Auto-selecting for MERGE."),te=[z[0]]):L.includes("conflicting learning")&&1===B.length?(console.log("Found 1 conflicting learning. Auto-selecting for MERGE."),te=[B[0]]):console.log("Generic merge message, but conditions not met (e.g., used 'learnings' for 1 item). No action taken."),te.length>0){P=[],U=0;for(var le=function(e){if(e&&e.id&&e.variant_id){var n={question_id:e.id,variant_id:e.variant_id};Sn.some((function(e){return e.question_id===n.question_id}))||(P.push(n),U++)}else console.warn("Skipping invalid learning object during auto-merge:",e)},ae=0,re=te;ae<re.length;ae++){var se;le(se=re[ae])}if(U>0){O=o(o([],Sn,!0),P,!0);xn(O),R=O,console.log("Appended ".concat(U," new generic MERGE-AS-DELETE(s) to in_review state:"),P)}else console.log("Item(s) from generic merge already in delete state, not adding again."),R=Sn}else R=Sn}}var de=new Map,ce=[];Ee(!1);var ue=n(n(n({userQuery:null!==(r=null==N?void 0:N.question)&&void 0!==r?r:"",topic:null!==(s=null==N?void 0:N.topic.value)&&void 0!==s?s:"",variant:null!==(d=null==N?void 0:N.howToRespond)&&void 0!==d?d:"",whenToApply:C,whenNotToApply:y,scope:_,scope_id:w,categories:null!==(c=null==N?void 0:N.categories)&&void 0!==c?c:[],validation:null!=J?J:null,conflicting_learnings:null!==(u=null==Z?void 0:Z.conflicting_learnings)&&void 0!==u?u:"",similar_learnings:null!==(v=null==Z?void 0:Z.similar_learnings)&&void 0!==v?v:""},(null==he?void 0:he.wta)&&{recommended_whentoapply:he.wta}),(null==he?void 0:he.wnta)&&{recommended_whennottoapply:he.wnta}),{in_review:{delete:R,edit:T,add:me||[]},isFirstQuestion:0===je.length});console.log("🚀 Sending Custom MetaData to Chat Backend:",ue);var ve={WEBSOCKET_URL:W,organizationName:M,chatAssistantName:Ce,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:(null==t?void 0:t.trim())||(null==Te?void 0:Te.trim())||"",requestId:"requestId-".concat(h()),customPrompt:"",enableForBackend:!1,guestSessionId:ye.current,chatPreviewId:_e.current,customMetaData:ue,customMetaDataDebug:{conflicting_learnings_keys:(null==Z?void 0:Z.conflicting_learnings)?Object.keys(Z.conflicting_learnings):[],similar_learnings_keys:(null==Z?void 0:Z.similar_learnings)?Object.keys(Z.similar_learnings):[],conflicting_count:(null==Z?void 0:Z.conflicting_learnings)?Object.keys(Z.conflicting_learnings).length:0,similar_count:(null==Z?void 0:Z.similar_learnings)?Object.keys(Z.similar_learnings).length:0},aiModel:"",onStreamEvent:function(e){return Un(e,de,ce,x,p,i)},onStreamEnd:function(e){on(!1)},onError:function(e){return console.error("Stream error:",e)}};if(""!==(null==Te?void 0:Te.trim())||(null==t?void 0:t.trim())){ze(!0),null===(m=Se.current)||void 0===m||m.blur(),Ie(""),Bn();for(var ge="Thanks for sharing your thoughts. I'm putting together the most helpful suggestions now, so we can make sure this really fits your needs.".split(" "),pe="",fe=function(e){setTimeout((function(){pe+=ge[e]+" ",Xe(pe.trim())}),25*e)},we=0;we<ge.length;we++)fe(we);g.startChatStream(ve)}}},qn=s(new Set);return u((function(){if(oe&&!nn){if(qn.current.has(oe))return void console.log("[ChatComponent] ⚠️ Duplicate merge trigger ignored:",oe);console.log("[ChatComponent] 🔴 MERGE TRIGGER RECEIVED:",oe),qn.current.add(oe);var e=null,n="A";if(null==Z?void 0:Z.similar_learnings){var o=Object.values(Z.similar_learnings),i=o.findIndex((function(e){return(null==e?void 0:e.id)===oe}));-1!==i&&(e=o[i],n=String.fromCharCode(65+i))}if(e){var t="Merge Similar Learning ".concat(n," with current learning");console.log("[ChatComponent] ✅ Sending merge message to chat:",t),Kn(new KeyboardEvent("keydown",{key:"Enter"}),!1,t),console.log("[ChatComponent] Message sent successfully")}else console.log("[ChatComponent] ❌ Learning not found for ID:",oe);ie&&(ie(null),console.log("[ChatComponent] Trigger cleared"))}else oe&&nn&&console.log("[ChatComponent] ⚠️ Merge trigger received but streaming in progress:",oe)}),[oe,nn,ie]),c((function(){return{img:function(e){e.node;var o=i(e,["node"]);return l("img",n({},o,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==o?void 0:o.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var o=i(e,["node"]);return l("p",n({},o,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==o?void 0:o.children}))},code:function(e){e.node;var o=i(e,["node"]);return l("span",n({},o,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==o?void 0:o.children}))},ol:function(e){e.node;var o=i(e,["node"]);return l("ol",n({},o,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==o?void 0:o.children}))},ul:function(e){e.node;var o=i(e,["node"]);return l("ul",n({},o,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==o?void 0:o.children}))},wta:function(e){e.node;var n=i(e,["node"]);n.key||n["data-key"];var t=n.label||n.children||"Unknown label";return l(T,{label:t,onToggle:function(e,n){!function(e,n){var i=Array.isArray(e)?e[0]:e;null==Le||Le.length,Ee(!0),ke((function(e){return n?e.includes(i)?e:o(o([],e,!0),[i],!1):e.filter((function(e){return e!==i}))}))}(e,n)}})}}}),[]),a("div",n({className:y.customFont,style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#fbfaff",border:"1px solid #d1d5db",overflow:"hidden"}},{children:[a("div",n({style:{width:"100%",height:"100%",backgroundColor:"#fbfaff",maxWidth:"100%",overflow:"hidden"}},{children:[l("div",n({ref:En},{children:l(E,{resetChatHistory:function(){var e="".concat(we,"/api/chat/resetHistory?name=").concat(Ce,"&organizationName=").concat(M);V(null),Q(null);try{var n={method:"GET",params:{guestSessionId:ye.current},withCredentials:!0};m.get(e,n).then((function(){ce(""),ue(""),ve([]),An([]),B(!0),Ee(!1),ke([]),Qe(""),hn(new Set),xn([]),Cn.current="",_n.current.clear(),qn.current.clear(),ie&&ie(null),_e.current="".concat(h()),O(!1),Oe([]),Ve(!0),te?(console.log("[ChatComponent] 🔄 Calling onResetLearningData callback"),te()):console.log("[ChatComponent] ❌ onResetLearningData callback not available")})).catch((function(e){console.error(e)}))}catch(e){ze(!1),console.error(e)}},isStreamEnd:Ke})})),a("div",n({style:{width:"100%",height:Tn,maxHeight:Tn,overflowY:"auto",backgroundColor:"#fbfaff"},ref:be},{children:[l("div",n({className:"welcome-message",style:{alignItems:"flex-start",paddingLeft:"0.5rem",paddingTop:"1rem",maxWidth:"70%",fontSize:"1rem",lineHeight:"1.75rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333",fontWeight:"700",textAlign:"left"}},{children:l("span",{children:"I'm here to help fine-tune your learning so it works as accurately as it should."})})),a("div",n({style:{display:"flex",flexDirection:"row",fontFamily:"inherit",padding:"16px 10px 0px 16px",maxWidth:"80%"}},{children:[l("div",n({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.3rem"}},{children:a("svg",n({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[l("g",n({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:l("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),l("defs",{children:l("clipPath",n({id:"clip0_6004_60631"},{children:l("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),l("div",n({style:{display:"flex",flexDirection:"column",fontWeight:400,color:"#000"}},{children:l("div",n({style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:l("span",{children:l(p,n({components:{p:function(e){e.node;var o=i(e,["node"]);return l("p",n({},o,{style:{margin:0}},{children:null==o?void 0:o.children}))}}},{children:Fe}))})}))}))]})),je.length?je.map((function(e,o){return a("div",n({style:{display:"flex",padding:"0.5rem 1rem",maxWidth:"100%"}},{children:["assistant"==(null==e?void 0:e.role)&&l("div",n({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.5rem",marginRight:"1rem"}},{children:a("svg",n({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[l("g",n({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:l("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),l("defs",{children:l("clipPath",n({id:"clip0_6004_60631"},{children:l("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),a("div",n({style:{width:"100%"}},{children:["assistant"===e.role&&e.orchestratorAndAgentsMessages&&e.orchestratorAndAgentsMessages.length>0&&l(f,{orchestratorAndAgentsMessages:null==e?void 0:e.orchestratorAndAgentsMessages,isStreamEnd:Ke,isCurrentMessage:o===je.length-1,ThinkingBulbIconComponent:G}),"assistant"===(null==e?void 0:e.role)?l(S,{index:o,content:null==e?void 0:e.content,messages:je,handleStream:Kn}):l("span",{}),l("div",n({style:{display:"flex",justifyContent:"flex-end"}},{children:"user"===e.role?l("div",n({style:{backgroundColor:"#8694A10D",padding:"0 1rem",borderRadius:"8px",maxWidth:"80%"}},{children:l(S,{index:o,content:null==e?void 0:e.content,messages:je,handleStream:Kn,scrollToBottom:Bn})})):l("span",{})}))]}))]}))})):Je&&l(r,{}),Be&&a("div",n({style:{display:"flex",padding:"16px 16px 0px 16px"}},{children:[l("div",n({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.2rem"}},{children:a("svg",n({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[l("g",n({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:l("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),l("defs",{children:l("clipPath",n({id:"clip0_6004_60631"},{children:l("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),l("div",n({style:{display:"inline-flex",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",paddingBottom:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:l("span",{children:$e})}))]}))]}))]})),a("div",n({style:{width:"95%",height:"content-fit",backgroundColor:"#fbfaff",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"end",position:"relative"}},{children:[l("div",n({style:{visibility:sn?"visible":"hidden",position:"absolute",top:"-3rem",zIndex:0,pointerEvents:"none"}},{children:l("button",n({onClick:Bn,style:{borderRadius:"9999px",padding:0,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:"1px solid #d1d5db",pointerEvents:"auto",cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1,height:"2.25rem",width:"2.25rem",margin:"0.3rem"}},{children:l("svg",n({fill:"#000000",width:"16px",height:"16px",viewBox:"0 0 24 24",id:"down","data-name":"Flat Color",xmlns:"http://www.w3.org/2000/svg"},{children:l("path",{id:"primary",d:"M19.71,13.29a1,1,0,0,0-1.42,0L13,18.59V3a1,1,0,0,0-2,0V18.59l-5.29-5.3a1,1,0,0,0-1.42,1.42l7,7a1,1,0,0,0,1.42,0l7-7A1,1,0,0,0,19.71,13.29Z"})}))}))})),l("div",n({style:{width:"100%",backgroundColor:"#fff",display:"flex",alignItems:"end",gap:"0.5rem",border:"1px solid #E5E7EB",borderRadius:"8px"}},{children:a("div",n({style:{width:"100%",display:"flex"}},{children:[l("textarea",{ref:Se,placeholder:"Tell me more about this learning...",value:Te||"",onChange:function(e){return Ie(e.target.value)},onFocus:function(){return an(!0)},onBlur:function(){return an(!1)},onKeyDown:function(e){return Kn(e)},style:{flexGrow:1,padding:"0.5rem",borderRadius:"0.5rem",border:"none",fontSize:"1rem",lineHeight:"1.5rem",resize:"none",backgroundColor:"#fff",color:"inherit",minHeight:ln?"120px":"50px",height:ln?"120px":"50px",maxHeight:"120px",overflowY:"auto",fontFamily:"inherit",outline:"none",transition:"min-height 0.3s ease, background-color 0.3s ease",boxSizing:"border-box"}}),a("span",n({style:{display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"end"}},{children:[" ",l("button",n({onClick:function(e){Kn(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:wn,style:{padding:"0.5rem 0.75rem",borderRadius:"0.375rem",border:"none",backgroundColor:"white",color:wn?"#d1d5db":"#5928ed",fontWeight:"bold",fontSize:"1rem",cursor:wn?"not-allowed":"pointer",transition:"background-color 0.3s, color 0.3s",height:"50px"}},{children:l(A,{})}))]}))]}))}))]})),a("div",n({style:{width:"95%",display:"flex",gap:"0.25rem",flexDirection:"row"}},{children:[l(_,n({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:l("span",n({style:{width:"50%"}},{children:l(b,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),l(_,n({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:l("span",n({style:{width:"50%"}},{children:l(b,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))};export{I as default};
|
|
1
|
+
import{__awaiter as e,__assign as n,__spreadArray as o,__rest as i,__generator as t}from"../../../node_modules/tslib/tslib.es6.mjs.js";import{jsx as l,jsxs as a,Fragment as r}from"react/jsx-runtime";import{useRef as s,useState as d,useMemo as c,useEffect as u,useCallback as v}from"react";import{d as g}from"../../../_virtual/index.js";import"../../../node_modules/uuid/dist/esm-browser/stringify.js";import h from"../../../node_modules/uuid/dist/esm-browser/v4.js";import m from"../../../node_modules/axios/lib/axios.js";import{ReactMarkdown as p}from"../../../node_modules/react-markdown/lib/react-markdown.js";import f from"./MinimizedThinkingSteps.js";import C from"./_svg/NewChatIcon.js";import y from"../InstantLearning.module.css.js";import _ from"../../../node_modules/@mui/material/Tooltip/Tooltip.js";import"../../../node_modules/@mui/material/Tooltip/tooltipClasses.js";import w from"../../../_virtual/index2.js";import b from"./AudioWaveform.js";import S from"./MessageRendering.js";import{sanitizePythonDictToJSON as x,sanitizePythonDictToJSON2 as L}from"../../../utils/instantLearning.utils.js";import{publishAgenticFeedbackForVariantIngestion as k}from"../../../service/InstantLearningService.js";import{parseValidationRecommendations as A}from"../../../utils/recommendationParser.js";var E=function(){return l("svg",n({width:"20px",height:"20px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:l("path",{d:"M9.91158 12H7.45579H4L2.02268 4.13539C2.0111 4.0893 2.00193 4.04246 2.00046 3.99497C1.97811 3.27397 2.77209 2.77366 3.46029 3.10388L22 12L3.46029 20.8961C2.77983 21.2226 1.99597 20.7372 2.00002 20.0293C2.00038 19.9658 2.01455 19.9032 2.03296 19.8425L3.5 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))},R=function(e){var o=e.resetChatHistory,i=e.isStreamEnd;return a("div",n({className:y.customFont,style:{width:"100%",padding:"0.75rem 0rem",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#fff",borderBottom:"1px solid #e5e7eb",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.04)"}},{children:[a("span",n({style:{fontSize:"1.25rem",fontWeight:700,color:"#1f2937",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:[l("span",n({style:{color:"#5928ED"}},{children:"InstantLearning.AI"}))," Contextual Chat"]})),l(_,n({title:"New chat",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:l("div",n({onClick:function(){console.log(C,"hello"),i&&o()},style:{height:"1.8rem",width:"1.8rem",marginLeft:"1rem",marginRight:"0.5rem",cursor:i?"pointer":"not-allowed",backgroundColor:"transparent",transition:"transform 0.2s ease-in-out, opacity 0.2s",opacity:i?.8:.4,pointerEvents:i?"auto":"none"},onMouseOver:function(e){i&&(e.currentTarget.style.opacity="1")},onMouseOut:function(e){i&&(e.currentTarget.style.opacity="0.8")}},{children:l(C,{})}))}))]}))},T=function(n,i,l,a){return e(void 0,void 0,void 0,(function(){var e,r,s,d,c,u,v,g,h,m;return t(this,(function(t){switch(t.label){case 0:e=n.delete_current_learning,r=n.deleted_similar_learning_ids,s=n.deleted_conflicting_learning_ids,console.log("Processing delete tool call:",n),d=o(o([],r||[],!0),s||[],!0),c=0,u=d,t.label=1;case 1:if(!(c<u.length))return[3,6];v=u[c],t.label=2;case 2:return t.trys.push([2,4,,5]),g={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:v,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(v),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},console.log("Deleting learning with ID: ".concat(v)),[4,k({baseUrl:i,organizationName:l,chatAssistantName:a,payload:g})];case 3:return(h=t.sent()).ok?console.log("Successfully deleted learning ".concat(v)):console.error("Failed to delete learning ".concat(v,":"),h.status,h.statusText),[3,5];case 4:return m=t.sent(),console.error("Error deleting learning ".concat(v,":"),m),[3,5];case 5:return c++,[3,1];case 6:return e&&console.log("Delete current learning flag is true - this will be handled later"),[2]}}))}))},I=function(e){var o=e.label,i=e.onToggle,t=d(!1),r=t[0],c=t[1],v=s(null);return u((function(){var e=v.current;e&&r&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[r]),a("span",n({ref:v,onClick:function(){var e=!r;c(e),i(o,e)},style:{cursor:"pointer",backgroundColor:r?"#E8F5E9":"#fbfaff",color:r?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){r||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){r||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[l("span",n({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:r?"scale(1.2)":"scale(1)",opacity:r?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:r?"✓":"+"})),l("span",{children:o})]}))},M=function(C){C.chatAssistantLogoUrl;var M=C.chatAssistantName,F=C.organizationName,D=C.baseUrl,N=C.setInstantLearningSuggestions,j=C.formDataState,O=C.setFormDataState;C.hasUserFilledForm;var W=C.setHasUserFilledForm,B=C.baseWebsocketUrl,z=C.setIsNewChatClicked,G=C.selectedText;C.ChatIconComponent,C.ggcAssistantName;var P=C.ThinkingBulbIconComponent;C.hasUserWrittenModification;var U=C.setExtractedModification,K=C.setSave,q=C.setExtractedTooltip,H=C.setIsSaveLoading;C.isSaveLoading,C.save,C.instantLearningSuggestions,C.template;var J=C.setShouldTriggerSave,V=C.validationWtaResponse,Z=C.setValidationWtaResponse,Q=C.learningWtaResponse,Y=C.setLearningWtaResponse,$=C.isFormSaveClicked,X=C.setIsFormSavedClicked,ee=C.onDeleteLearning,ne=C.deleteLearningTrigger,oe=C.setDeleteLearningTrigger;C.onMergeLearning;var ie=C.mergeLearningTrigger,te=C.setMergeLearningTrigger,le=C.onResetLearningData,ae=C.setEditConflictingLearningTrigger,re=C.setEditSimilarLearningTrigger,se=C.sendMessageInChat,de=C.setSendMessageInChat,ce=C.setIsMergeLoading,ue=C.setExtractedHowToRespond,ve=C.setExtractedTopic,ge=C.setExtractedCategories,he=C.setValidationRecommendations,me=C.validationRecommendations,pe=C.addInReview,fe=C.editInReview,Ce=C.deleteInReview,ye=M,_e=s("".concat(ye,"-").concat(F,"-").concat(h())),we=s("".concat(h())),be=D,Se=s(null),xe=s(null),Le=d([]),ke=Le[0],Ae=Le[1],Ee=d(!1);Ee[0];var Re=Ee[1],Te=d(""),Ie=Te[0],Me=Te[1],Fe=d(""),De=Fe[0],Ne=Fe[1],je=d([]),Oe=je[0],We=je[1],Be=d(!1),ze=Be[0],Ge=Be[1],Pe=d(!1);Pe[0];var Ue=Pe[1],Ke=d(!0),qe=Ke[0],He=Ke[1],Je=d(!0),Ve=Je[0],Ze=Je[1],Qe=d("");Qe[0];var Ye=Qe[1],$e=d(""),Xe=$e[0],en=$e[1],nn=d(!1),on=nn[0],tn=nn[1],ln=d(!1),an=ln[0],rn=ln[1],sn=d(!1),dn=sn[0],cn=sn[1],un=d([]);un[0];var vn=un[1],gn=d(new Set),hn=gn[0],mn=gn[1],pn=d(new Set),fn=pn[0],Cn=pn[1],yn=s(""),_n=s(""),wn=s(new Set),bn=c((function(){return""===(null==Ie?void 0:Ie.trim())||on}),[Ie,on]),Sn=d(Ce||[]),xn=Sn[0],Ln=Sn[1],kn=d(fe||[]),An=kn[0],En=kn[1],Rn=s(null),Tn=d("100%"),In=Tn[0],Mn=Tn[1];c((function(){var e,n,o;return!(""===(null===(e=null==j?void 0:j.original)||void 0===e?void 0:e.trim())||(null==j?void 0:j.isTooltipEnabled)&&""===(null===(n=null==j?void 0:j.tooltip)||void 0===n?void 0:n.trim())||(null==j?void 0:j.isModificationEnabled)&&""===(null===(o=null==j?void 0:j.modification)||void 0===o?void 0:o.trim()))}),[j]),u((function(){var e='Please tell me how I should respond to "'.concat(G,'"? ');Ne(e)}),[j]),u((function(){var e=Se.current,n=function(){var e=Se.current;if(e){var n=e.scrollTop,o=e.scrollHeight,i=e.clientHeight;cn(!(o-(n+i)<=35))}};return e&&(e.addEventListener("scroll",n),n()),function(){e&&e.removeEventListener("scroll",n)}}),[dn,qe,Oe]);var Fn=v((function(n){return e(void 0,void 0,void 0,(function(){var e,i,l,a,r,s,d;return t(this,(function(t){switch(t.label){case 0:if(e=JSON.stringify({deleted_similar_learning_ids:n.deleted_similar_learning_ids||[],deleted_conflicting_learning_ids:n.deleted_conflicting_learning_ids||[],delete_current_learning:n.delete_current_learning||!1}),wn.current.has(e))return console.log("Delete operation already processed, skipping callback execution:",e),[2];wn.current.add(e),console.log("Processing new delete operation:",e),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,T(n,D,F,ye)];case 2:return t.sent(),i=n.deleted_similar_learning_ids,l=void 0===i?[]:i,a=n.deleted_conflicting_learning_ids,r=void 0===a?[]:a,s=o(o([],l||[],!0),r||[],!0),mn((function(e){var n=new Set(e);return s.forEach((function(e){return n.add(e)})),console.log("Added deleted learning IDs to tracking set:",Array.from(n)),n})),console.log("UI state updated after deletion of learnings:",s),[3,4];case 3:throw d=t.sent(),wn.current.delete(e),console.error("Error processing delete operation:",d),d;case 4:return[2]}}))}))}),[D,F,ye,mn]),Dn=v((function(o){return e(void 0,void 0,void 0,(function(){var e,i,l,a,r,s,d,c,u,v,g,h;return t(this,(function(t){switch(t.label){case 0:ce(!0),console.log("🔴 MERGE CALLBACK - Processing merge tool call:",o),t.label=1;case 1:if(t.trys.push([1,6,7,8]),e=o.merge_learnings,i=o.similar_learnings,l=o.conditions_whentoapply,a=o.conditions_whennottoapply,console.log("🔴 MERGE CALLBACK - Extracted data:"),console.log("merge_learnings:",e),console.log("similar_learnings:",i),console.log("conditions_whentoapply:",l),console.log("conditions_whennottoapply:",a),!e||!i||!Array.isArray(i))return console.log("Invalid merge tool data, skipping"),[2];console.log(" MERGE CALLBACK - Current formDataState before replacement:",j),console.log(" MERGE CALLBACK - Current whenToApply:",null==j?void 0:j.whenToApply),console.log(" MERGE CALLBACK - Current whenNotToApply:",null==j?void 0:j.whenNotToApply),l&&Array.isArray(l)&&(console.log(" MERGE CALLBACK - UNCONDITIONALLY replacing whenToApply conditions:",l),r=l.join(" OR "),console.log(" MERGE CALLBACK - New whenToApply string:",r),O((function(e){console.log(" MERGE CALLBACK - Previous formDataState:",e);var o=n(n({},e),{whenToApply:r,_mergeUpdate:!0,_mergeWTA:l});return console.log("MERGE CALLBACK - New formDataState:",o),o}))),a&&Array.isArray(a)&&(console.log(" MERGE CALLBACK - UNCONDITIONALLY replacing whenNotToApply conditions:",a),s=a.join(" OR "),console.log(" MERGE CALLBACK - New whenNotToApply string:",s),O((function(e){console.log(" MERGE CALLBACK - Previous formDataState for WNTA:",e);var o=n(n({},e),{whenNotToApply:s,_mergeUpdate:!0,_mergeWNTA:a});return console.log(" MERGE CALLBACK - New formDataState for WNTA:",o),o}))),Cn((function(e){var n=new Set(e);return i.forEach((function(e){return n.add(e)})),console.log("Added merged learning IDs to tracking set:",Array.from(n)),n})),d=0,c=i,t.label=2;case 2:return d<c.length?(u=c[d],console.log("Sending delete request for merged learning ID: ".concat(u)),v={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:u,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(u),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},[4,k({baseUrl:D,organizationName:F,chatAssistantName:ye,payload:v})]):[3,5];case 3:(g=t.sent()).ok?console.log("Successfully deleted merged learning ID ".concat(u)):console.error("Failed to delete merged learning ID ".concat(u,":"),g.statusText),t.label=4;case 4:return d++,[3,2];case 5:return[3,8];case 6:return h=t.sent(),console.error("Error processing merge operation:",h),[3,8];case 7:return console.log("switched off"),ce(!1),[7];case 8:return[2]}}))}))}),[ee,Cn,O,ce]),Nn=function(e,o,i,t){return c((function(){for(var l,a=[],r=/['"]conditions_whentoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\2).)*\2\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\3).)*\3\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])\s*,\s*['"]conditions_whennottoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\5).)*\5\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\6).)*\6\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])/,s=/['"]conditions_whentoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\2).)*\2\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\3).)*\3\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])\s*,\s*['"]conditions_whennottoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\5).)*\5\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\6).)*\6\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])/,d=/['"]is_valid['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflictingConditions['"]\s*:\s*\[\s*(?:\{[\s\S]*?['"]conflictType['"]\s*:\s*['"][^'"]+['"][\s\S]*?\}\s*,?\s*)*\]\s*,\s*['"]save['"]\s*:\s*(true|false|True|False)/,c=/['"]is_valid_db['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflicting_learnings['"]\s*:\s*([\s\S]*?)\s*,\s*['"]similar_learnings['"]\s*:\s*([\s\S]*)(?:\s*,\s*["']save["']\s*:\s*(true|false|True|False))?(?=\s*})/,u=/['"]delete_current_learning['"]\s*:\s*(true|false|True|False)\s*,\s*['"]deleted_similar_learning_ids['"]\s*:\s*\[[\s\S]*?\]\s*,\s*['"]deleted_conflicting_learning_ids['"]\s*:\s*\[[\s\S]*?\]/,v=/{\s*['"]merge_learnings['"]\s*:\s*(?:True|true)[\s\S]+?}/,g=/({[\s\S]*}|\[[\s\S]*\])/,h=/({[\s\S]*})/,m=0,p=(null===(l=e[e.length-1])||void 0===l?void 0:l.orchestratorAndAgentsMessages)||[];m<p.length;m++){var f=p[m],C=(null==f?void 0:f.responsedata)||"";console.log("🔍 RESPONSE DATA:",String(C)),String(C).includes("merge_learnings")&&(console.log("🔍 FOUND merge_learnings in response!"),console.log("🔍 Full response:",String(C))),String(C).includes("'merge_learnings'")&&(console.log("🔍 FOUND merge_learnings in response!"),console.log("🔍 Full response:",String(C)));var y=C.match(r);if(y)try{var _=w.parse("{".concat(y[0],"}"));a.push(_)}catch(e){console.error("Failed to parse JSON:",e)}var b=C.match(s);if(b)try{var S=x(b[0]||""),k=w.parse("{".concat(S,"}"));console.log("Contextual conditions detected:",k),a.push(n(n({},k),{_isContextual:!0}))}catch(e){console.error("Failed to parse contextual JSON:",e)}var E=C.match(d);if(console.log("validationObj before cond ",E),E)try{var R=x(C||"");(T=w.parse(R))&&"object"==typeof T&&"is_valid"in T&&"conflictingConditions"in T&&(console.log("Found validation data in response:",T),Z(T),console.log("dbVal after set in chat",V))}catch(e){console.error("Failed to parse validation JSON:",e)}try{var T,I=x(C||"");if((T=w.parse(I))&&"object"==typeof T&&"is_valid_db"in T&&"conflicting_learnings"in T&&"similar_learnings"in T)console.log("Found validation data in response:",T),Y(T),console.log("dbVal after set in chat",Q);else if(D=C.match(c)){var M=L(D[0]||""),F=w.parse("{".concat(M,"}"));Y(F),console.log("dbVal after set in chat (regex fallback)",Q)}}catch(e){var D;if(console.log("JSON parsing failed, trying regex fallback for validation data"),D=C.match(c))try{M=L(D[0]||""),F=w.parse("{".concat(M,"}"));Y(F),console.log("dbVal after set in chat (regex fallback)",Q)}catch(e){console.error("Failed to parse validation JSON with regex fallback:",e)}}var N=C.match(u);if(N)try{var j=x(N[0]||""),O=w.parse("{".concat(j,"}"));console.log("Delete tool detected:",O),i&&i(O)}catch(e){console.error("Failed to parse delete tool JSON:",e)}console.log("🔍 Testing merge tool regex on response data...");var W=C.match(v);if(console.log("🔍 Merge tool regex match result:",W),W){console.log("🔍 MERGE TOOL REGEX MATCHED!");try{var B=W[0],z=x(B),G=w.parse(z);console.log("✅ Correctly parsed merge tool object:",G),t&&t(G)}catch(e){console.error("Failed to parse merge tool JSON:",e)}}var P=C.match(g);if(P&&C.includes("edit_actions"))try{console.log("Edit tool match found:",P[0]);z=x(P[0]);var U=w.parse(z);console.log("Edit tool detected and parsed successfully:",U),U.conflicting_learnings&&(ae(U.conflicting_learnings),console.log("Setting edit conflicting learning trigger:",U.conflicting_learnings)),U.similar_learnings&&(re(U.similar_learnings),console.log("Setting edit similar learning trigger:",U.similar_learnings))}catch(e){console.error("Failed to parse edit tool JSON:",e)}var K=C.match(h);if(K)try{z=x(K[0]);var q=w.parse(z);if(q.recommended_whentoapply||q.recommended_whennottoapply){console.log("Found recommendation data:",q);var H=A(q);console.log("Parsed recommendations:",H),o(H)}}catch(e){}}return a}),[e,i])}(Oe,he,Fn,Dn);u((function(){var e,o,i=(null==Nn?void 0:Nn[(null==Nn?void 0:Nn.length)-1])||null;if(i){if(i._isContextual){console.log("Processing contextual suggestions:",i);var t=(null===(e=i.conditions_whentoapply)||void 0===e?void 0:e.map((function(e){return e.when_to_apply})))||[],l=(null===(o=i.conditions_whennottoapply)||void 0===o?void 0:o.map((function(e){return e.when_not_to_apply})))||[];O((function(e){return n(n({},e),{whenToApply:t,whenNotToApply:l,_contextualUpdate:!0})}))}else N(i);console.log("Parsed suggestions:",Nn)}}),[Nn]),u((function(){if(Q&&0!==hn.size){var e=Q.conflicting_learnings&&Object.values(Q.conflicting_learnings).some((function(e){return hn.has(e.id)})),o=Q.similar_learnings&&Object.values(Q.similar_learnings).some((function(e){return hn.has(e.id)}));if(e||o){var i=JSON.stringify({deletedIds:Array.from(hn).sort()});if(yn.current!==i){var t=n({},Q);if(t.conflicting_learnings){var l=Object.values(t.conflicting_learnings).filter((function(e){return!hn.has(e.id)}));console.log("[ChatComponent] Re-keying conflicting learnings:",{originalKeys:Object.keys(t.conflicting_learnings),remainingCount:l.length,remainingLearnings:l.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var a={};l.forEach((function(e,n){var o=String.fromCharCode(65+n);a[o]=e,console.log("[ChatComponent] Conflicting learning ".concat(n," gets key '").concat(o,"':"),e.feedback.variant)})),t.conflicting_learnings=a,console.log("[ChatComponent] Final conflicting learnings keys:",Object.keys(a))}if(t.similar_learnings){var r=Object.values(t.similar_learnings).filter((function(e){return!hn.has(e.id)}));console.log("[ChatComponent] Re-keying similar learnings:",{originalKeys:Object.keys(t.similar_learnings),remainingCount:r.length,remainingLearnings:r.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var s={};r.forEach((function(e,n){var o=String.fromCharCode(65+n);s[o]=e,console.log("[ChatComponent] Similar learning ".concat(n," gets key '").concat(o,"':"),e.feedback.variant)})),t.similar_learnings=s,console.log("[ChatComponent] Final similar learnings keys:",Object.keys(s))}yn.current=i,console.log("Filtered learningWtaResponse after deletion:",t),Y(t)}}}}),[hn,Q,Y]),u((function(){if(Q&&0!==fn.size&&(Q.similar_learnings&&Object.values(Q.similar_learnings).some((function(e){return fn.has(e.id)})))){var e=JSON.stringify({mergedIds:Array.from(fn).sort()});if(_n.current!==e){var o=n({},Q);if(o.similar_learnings){var i=Object.values(o.similar_learnings).filter((function(e){return!fn.has(e.id)}));console.log("[ChatComponent] Re-keying similar learnings after merge:",{originalKeys:Object.keys(o.similar_learnings),remainingCount:i.length,remainingLearnings:i.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var t={};i.forEach((function(e,n){var o=String.fromCharCode(65+n);t[o]=e,console.log("[ChatComponent] Similar learning ".concat(n," gets key '").concat(o,"':"),e.feedback.variant)})),o.similar_learnings=t,console.log("[ChatComponent] Final similar learnings keys after merge:",Object.keys(t))}_n.current=e,console.log("Filtered learningWtaResponse after merge:",o),Y(o)}}}),[fn,Q,Y]);var jn=function(e){return c((function(){for(var n,o=[],i=/['"]howtorespond['"]\s*:\s*['"](.*?)['"]/g,t=/['"]topic['"]\s*:\s*['"](.*?)['"]/g,l=/['"]categories['"]\s*:\s*\[(.*?)\]/g,a=/['"]scope['"]\s*:\s*['"](Global|Assistant|User|Custom)['"]/g,r=0,s=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];r<s.length;r++){var d=s[r],c=(null==d?void 0:d.responsedata)||"",u={},v=i.exec(c);v&&v[1]&&(u.howtorespond=v[1]),i.lastIndex=0;var g=t.exec(c);g&&g[1]&&(u.topic=g[1]),t.lastIndex=0;var h=l.exec(c);if(h&&h[1]){var m=h[1].split(",").map((function(e){return e.trim().replace(/['"]/g,"")})).filter((function(e){return e.length>0}));u.categories=m}l.lastIndex=0;var p=a.exec(c);p&&p[1]&&(u.scope=p[1]),a.lastIndex=0,Object.keys(u).length>0&&o.push(u)}return o}),[e])}(Oe);u((function(){var e=(null==jn?void 0:jn[(null==jn?void 0:jn.length)-1])||null;e&&(e.howtorespond&&ue(e.howtorespond),e.topic&&ve(e.topic),e.categories&&Array.isArray(e.categories)&&ge(e.categories),e.scope&&O((function(o){if(o.scope.name===e.scope)return o;var i=null;return"User"===e.scope?i=[]:"Assistant"===e.scope&&(i={assistantName:M||"",conciergeId:M||""}),console.log("📌 Scope Set from Chat:",e.scope),n(n({},o),{scope:{name:e.scope,value:i}})})))}),[jn,ue,ve,ge,O,M]);var On=function(e){return c((function(){for(var n,o=[],i=/['"](\w+)['"]\s*:\s*['"](.*?)['"]/g,t=0,l=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];t<l.length;t++){var a=l[t],r=((null==a?void 0:a.responsedata)||"").match(i);if(r)try{var s=w.parse("{".concat(r[0],"}"));o.push(s)}catch(e){console.error("Failed to parse JSON for header message:",e)}}return o}),[e])}(Oe);u((function(){var e=(null==On?void 0:On[(null==On?void 0:On.length)-1])||null;e&&U(e.modification)}),[On]);!function(e,n){u((function(){for(var o,i=0,t=(null===(o=e[e.length-1])||void 0===o?void 0:o.orchestratorAndAgentsMessages)||[];i<t.length;i++){for(var l=t[i],a=(null==l?void 0:l.responsedata)||"",r=/<wta>([\s\S]*?)<\/wta>/gi,s=[],d=void 0;null!==(d=r.exec(a));)console.log("match wta suggestion",d),s.push(d[1]);s.length&&n(s)}}),[e,n])}(Oe,vn);var Wn=function(e){return c((function(){for(var n,o=[],i=/^\{\s*(['"])(\w+)\1\s*:\s*(['"])(.*?)\3\s*\}$/,t=0,l=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];t<l.length;t++){var a=l[t],r=((null==a?void 0:a.responsedata)||"").match(i);if(r){console.log("match: ",r[0]);try{var s=w.parse(r[0]);o.push(s)}catch(e){console.error("Failed to parse JSON:",e)}}}return o}),[e])}(Oe);u((function(){var e=(null==Wn?void 0:Wn[(null==Wn?void 0:Wn.length)-1])||null;e&&(console.log("latestParseTooltip: ",e),q(null==e?void 0:e.tooltip))}),[Wn]);var Bn=function(e){var n=d([]),o=n[0],i=n[1];return u((function(){for(var n,o=[],t=/\{\s*['"]save['"]\s*:\s*(True|False|true|false)\s*\}/,l=0,a=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];l<a.length;l++){var r=a[l],s=((null==r?void 0:r.responsedata)||"").match(t);if(s)try{var d=s[0].replace(/\bTrue\b/,"true").replace(/\bFalse\b/,"false").replace(/'/g,'"');console.log("corrected:",d);var c=w.parse(d);!0===c.save&&J(!0),o.push(c)}catch(e){console.error("Failed to parse JSON:",e)}}i(o)}),[e]),o}(Oe);u((function(){var e=(null==Bn?void 0:Bn[(null==Bn?void 0:Bn.length)-1])||null;if(e&&"boolean"==typeof e.save){H(!0);var n=setTimeout((function(){H(!1),K(e.save)}),200);return function(){clearTimeout(n)}}}),[Bn]),u((function(){$&&(qn(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save it"),X(!1))}),[$]),u((function(){if(ne&&ee){var e="Delete learning ".concat(ne);qn(new KeyboardEvent("keydown",{key:"Enter"}),!1,e),oe&&oe(null)}}),[ne,ee,oe]),u((function(){se&&(qn(new KeyboardEvent("keydown",{key:"Enter"}),!1,se),de(""))}),[se]),u((function(){Gn(),Pn();var e=function(){var e,n=(null===(e=null==Rn?void 0:Rn.current)||void 0===e?void 0:e.clientHeight)||0,o="calc(100% - ".concat(n,"px - 10px");Mn(o)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]);var zn=v((function(){var e=Se.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),cn(!1)}),100)}),[]);u((function(){(null==ke?void 0:ke.length)>0&&zn()}),[ke]);var Gn=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(be,"/api/chatbot/getChatSettings?name=").concat(ye,"&organizationName=").concat(F),headers:{}};m.request(e).then((function(e){var n,o,i;(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)&&""!==(null===(i=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.chatSettings)||void 0===i?void 0:i.chatInitialMessage)&&Ze(!0)})).catch((function(e){console.error(e)}))},Pn=function(){return e(void 0,void 0,void 0,(function(){var e,n;return t(this,(function(o){e="".concat(be,"/api/chat/history?name=").concat(ye,"&organizationName=").concat(F);try{n={method:"GET",params:{guestSessionId:_e.current},withCredentials:!0},m.get(e,n).then((function(e){var n=e.data;n.length>0?(We(n),zn()):Ze(!0)})).catch((function(e){console.error(e)}))}catch(e){Ge(!1),console.error(e)}return[2]}))}))};function Un(e){return null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,(function(e){return null==e?void 0:e.replace(/\*/g,"*")}))}var Kn=function(e,i,t,l,a,r){var s,d,c,u,v,g,m,p,f,C,y,_,w,b,S,x,L,k;console.log("userInput: ",a);var A={role:"assistant",content:"",id:h()};if(null===(u=null===(c=null===(d=null===(s=null==e?void 0:e.chatStream)||void 0===s?void 0:s.continueChatResult)||void 0===d?void 0:d.message)||void 0===c?void 0:c.content)||void 0===u?void 0:u.includes("WaitMessage: "))Ge(!1),Ue(!0),A.content=function(e){var n="WaitMessage: ",o=e.indexOf(n);if(-1!==o){var i=e.substring(o+13);return null==i?void 0:i.replaceAll("WaitMessage: ","")}return""}((null===(m=null===(g=null===(v=null==e?void 0:e.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===g?void 0:g.message)||void 0===m?void 0:m.content)+"\n\n"),We(o(o([],Oe,!0),[{role:"user",content:a,time:l,isFirstQuestionSent:r||!1,id:(null===(f=null===(p=null==e?void 0:e.chatStream)||void 0===p?void 0:p.continueChatResult)||void 0===f?void 0:f.requestId)||"",reply:""},A],!1));else{Ge(!1),Ue(!1),A.content=null===(w=Un(null===(_=null===(y=null===(C=null==e?void 0:e.chatStream)||void 0===C?void 0:C.continueChatResult)||void 0===y?void 0:y.message)||void 0===_?void 0:_.content))||void 0===w?void 0:w.replaceAll("WaitMessage: ","");var E=function(e,i,t){var l,a,r,s,d,c,u,v,g,m,p,f,C,y,_,w,b,S,x,L,k,A,E,R,T,I,M,F,D,N,j,O,W,B,z,G,P,U,K,q,H,J,V,Z,Q,Y,$,X,ee,ne,oe,ie,te,le,ae,re,se,de,ce,ue,ve,ge,he,me,pe,fe,Ce,ye,_e,we,be,Se,xe,Le,ke,Ae,Ee,Re,Te,Ie,Me,Fe,De,Ne,je,Oe,We,Be,ze,Ge,Pe,Ue,Ke,qe,He,Je,Ve,Ze,Qe,Ye,$e,Xe,en,nn,on,tn,ln,an,rn,sn,dn,cn,un,vn,gn,hn,mn,pn,fn,Cn,yn,_n,wn,bn,Sn,xn,Ln,kn,An,En,Rn,Tn,In,Mn,Fn,Dn,Nn,jn,On,Wn,Bn,zn,Gn,Pn,Kn,qn,Hn,Jn,Vn,Zn,Qn,Yn,$n,Xn,eo,no,oo,io,to,lo,ao,ro,so,co,uo,vo,go,ho,mo,po;console.log("event",e,Object.keys(e)),console.log("content: ",null==e?void 0:e.data);var fo={role:"assistant",content:"",id:h()};if(!1===(null===(r=null===(a=null===(l=null==e?void 0:e.data)||void 0===l?void 0:l.chatStream)||void 0===a?void 0:a.continueChatResult)||void 0===r?void 0:r.thinking_break)&&!0===(null===(c=null===(d=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===c?void 0:c.is_orchestrator)&&!1===(null===(g=null===(v=null===(u=null==e?void 0:e.data)||void 0===u?void 0:u.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===g?void 0:g.isEnd)&&(fo.content=null===(y=Un(null===(C=null===(f=null===(p=null===(m=null==e?void 0:e.data)||void 0===m?void 0:m.chatStream)||void 0===p?void 0:p.continueChatResult)||void 0===f?void 0:f.message)||void 0===C?void 0:C.content))||void 0===y?void 0:y.replaceAll("WaitMessage: ","")),!0===(null===(b=null===(w=null===(_=null==e?void 0:e.data)||void 0===_?void 0:_.chatStream)||void 0===w?void 0:w.continueChatResult)||void 0===b?void 0:b.thinking_break)&&!0===(null===(L=null===(x=null===(S=null==e?void 0:e.data)||void 0===S?void 0:S.chatStream)||void 0===x?void 0:x.continueChatResult)||void 0===L?void 0:L.is_orchestrator)&&!1===(null===(E=null===(A=null===(k=null==e?void 0:e.data)||void 0===k?void 0:k.chatStream)||void 0===A?void 0:A.continueChatResult)||void 0===E?void 0:E.isEnd)&&(fo.content="",i.push({responsedata:null===(M=null===(I=null===(T=null===(R=null==e?void 0:e.data)||void 0===R?void 0:R.chatStream)||void 0===T?void 0:T.continueChatResult)||void 0===I?void 0:I.message)||void 0===M?void 0:M.content,responseFrom:null===(N=null===(D=null===(F=null==e?void 0:e.data)||void 0===F?void 0:F.chatStream)||void 0===D?void 0:D.continueChatResult)||void 0===N?void 0:N.responded_by,header_message:null===(W=null===(O=null===(j=null==e?void 0:e.data)||void 0===j?void 0:j.chatStream)||void 0===O?void 0:O.continueChatResult)||void 0===W?void 0:W.header_message,finalResponseStatus:!1,explainability_id:null!==(P=null===(G=null===(z=null===(B=null==e?void 0:e.data)||void 0===B?void 0:B.chatStream)||void 0===z?void 0:z.continueChatResult)||void 0===G?void 0:G.explainability_id)&&void 0!==P?P:"",isParallelToolResponse:!1})),!1===(null===(q=null===(K=null===(U=null==e?void 0:e.data)||void 0===U?void 0:U.chatStream)||void 0===K?void 0:K.continueChatResult)||void 0===q?void 0:q.thinking_break)&&!0===(null===(V=null===(J=null===(H=null==e?void 0:e.data)||void 0===H?void 0:H.chatStream)||void 0===J?void 0:J.continueChatResult)||void 0===V?void 0:V.is_orchestrator)&&!0===(null===(Y=null===(Q=null===(Z=null==e?void 0:e.data)||void 0===Z?void 0:Z.chatStream)||void 0===Q?void 0:Q.continueChatResult)||void 0===Y?void 0:Y.isEnd)&&(fo.content=null===(oe=Un(null===(ne=null===(ee=null===(X=null===($=null==e?void 0:e.data)||void 0===$?void 0:$.chatStream)||void 0===X?void 0:X.continueChatResult)||void 0===ee?void 0:ee.message)||void 0===ne?void 0:ne.content))||void 0===oe?void 0:oe.replaceAll("WaitMessage: ","")),!1===(null===(le=null===(te=null===(ie=null==e?void 0:e.data)||void 0===ie?void 0:ie.chatStream)||void 0===te?void 0:te.continueChatResult)||void 0===le?void 0:le.thinking_break)&&!1===(null===(se=null===(re=null===(ae=null==e?void 0:e.data)||void 0===ae?void 0:ae.chatStream)||void 0===re?void 0:re.continueChatResult)||void 0===se?void 0:se.is_orchestrator)&&!1===(null===(ue=null===(ce=null===(de=null==e?void 0:e.data)||void 0===de?void 0:de.chatStream)||void 0===ce?void 0:ce.continueChatResult)||void 0===ue?void 0:ue.isEnd)){if((_o=null===(ge=null===(ve=null==e?void 0:e.data)||void 0===ve?void 0:ve.chatStream)||void 0===ge?void 0:ge.continueChatResult).explainability_id&&_o.responded_by){var Co=_o.explainability_id,yo=_o.responded_by;t.has(Co)||t.set(Co,{responded_by:yo,index:i.length})}t.has(null===(me=null===(he=null==e?void 0:e.data)||void 0===he?void 0:he.chatStream)||void 0===me?void 0:me.continueChatResult.explainability_id)?i[Lo=null==(wo=t.get(null===(Ce=null===(fe=null===(pe=null==e?void 0:e.data)||void 0===pe?void 0:pe.chatStream)||void 0===fe?void 0:fe.continueChatResult)||void 0===Ce?void 0:Ce.explainability_id))?void 0:wo.index]={responsedata:null===(be=null===(we=null===(_e=null===(ye=null==e?void 0:e.data)||void 0===ye?void 0:ye.chatStream)||void 0===_e?void 0:_e.continueChatResult)||void 0===we?void 0:we.message)||void 0===be?void 0:be.content,responseFrom:null===(Le=null===(xe=null===(Se=null==e?void 0:e.data)||void 0===Se?void 0:Se.chatStream)||void 0===xe?void 0:xe.continueChatResult)||void 0===Le?void 0:Le.responded_by,header_message:null===(Ee=null===(Ae=null===(ke=null==e?void 0:e.data)||void 0===ke?void 0:ke.chatStream)||void 0===Ae?void 0:Ae.continueChatResult)||void 0===Ee?void 0:Ee.header_message,finalResponseStatus:!0,explainability_id:null!==(Me=null===(Ie=null===(Te=null===(Re=null==e?void 0:e.data)||void 0===Re?void 0:Re.chatStream)||void 0===Te?void 0:Te.continueChatResult)||void 0===Ie?void 0:Ie.explainability_id)&&void 0!==Me?Me:"",isParallelToolResponse:!0}:i=o(o([],i,!0),[{responsedata:null===(je=null===(Ne=null===(De=null===(Fe=null==e?void 0:e.data)||void 0===Fe?void 0:Fe.chatStream)||void 0===De?void 0:De.continueChatResult)||void 0===Ne?void 0:Ne.message)||void 0===je?void 0:je.content,responseFrom:null===(Be=null===(We=null===(Oe=null==e?void 0:e.data)||void 0===Oe?void 0:Oe.chatStream)||void 0===We?void 0:We.continueChatResult)||void 0===Be?void 0:Be.responded_by,header_message:null===(Pe=null===(Ge=null===(ze=null==e?void 0:e.data)||void 0===ze?void 0:ze.chatStream)||void 0===Ge?void 0:Ge.continueChatResult)||void 0===Pe?void 0:Pe.header_message,finalResponseStatus:!0,explainability_id:null!==(He=null===(qe=null===(Ke=null===(Ue=null==e?void 0:e.data)||void 0===Ue?void 0:Ue.chatStream)||void 0===Ke?void 0:Ke.continueChatResult)||void 0===qe?void 0:qe.explainability_id)&&void 0!==He?He:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(Ze=null===(Ve=null===(Je=null==e?void 0:e.data)||void 0===Je?void 0:Je.chatStream)||void 0===Ve?void 0:Ve.continueChatResult)||void 0===Ze?void 0:Ze.thinking_break)&&!1===(null===($e=null===(Ye=null===(Qe=null==e?void 0:e.data)||void 0===Qe?void 0:Qe.chatStream)||void 0===Ye?void 0:Ye.continueChatResult)||void 0===$e?void 0:$e.is_orchestrator)&&!1===(null===(nn=null===(en=null===(Xe=null==e?void 0:e.data)||void 0===Xe?void 0:Xe.chatStream)||void 0===en?void 0:en.continueChatResult)||void 0===nn?void 0:nn.isEnd)){var _o,wo;(_o=null===(tn=null===(on=null==e?void 0:e.data)||void 0===on?void 0:on.chatStream)||void 0===tn?void 0:tn.continueChatResult).explainability_id&&_o.responded_by&&(Co=_o.explainability_id,yo=_o.responded_by,t.has(Co)||t.set(Co,{responded_by:yo,index:i.length})),t.has(null===(rn=null===(an=null===(ln=null==e?void 0:e.data)||void 0===ln?void 0:ln.chatStream)||void 0===an?void 0:an.continueChatResult)||void 0===rn?void 0:rn.explainability_id)?i[Lo=null==(wo=t.get(null===(cn=null===(dn=null===(sn=null==e?void 0:e.data)||void 0===sn?void 0:sn.chatStream)||void 0===dn?void 0:dn.continueChatResult)||void 0===cn?void 0:cn.explainability_id))?void 0:wo.index]={responsedata:null===(hn=null===(gn=null===(vn=null===(un=null==e?void 0:e.data)||void 0===un?void 0:un.chatStream)||void 0===vn?void 0:vn.continueChatResult)||void 0===gn?void 0:gn.message)||void 0===hn?void 0:hn.content,responseFrom:null===(fn=null===(pn=null===(mn=null==e?void 0:e.data)||void 0===mn?void 0:mn.chatStream)||void 0===pn?void 0:pn.continueChatResult)||void 0===fn?void 0:fn.responded_by,header_message:null===(_n=null===(yn=null===(Cn=null==e?void 0:e.data)||void 0===Cn?void 0:Cn.chatStream)||void 0===yn?void 0:yn.continueChatResult)||void 0===_n?void 0:_n.header_message,finalResponseStatus:!1,explainability_id:null!==(xn=null===(Sn=null===(bn=null===(wn=null==e?void 0:e.data)||void 0===wn?void 0:wn.chatStream)||void 0===bn?void 0:bn.continueChatResult)||void 0===Sn?void 0:Sn.explainability_id)&&void 0!==xn?xn:"",isParallelToolResponse:!0}:i.push({responsedata:null===(En=null===(An=null===(kn=null===(Ln=null==e?void 0:e.data)||void 0===Ln?void 0:Ln.chatStream)||void 0===kn?void 0:kn.continueChatResult)||void 0===An?void 0:An.message)||void 0===En?void 0:En.content,responseFrom:null===(In=null===(Tn=null===(Rn=null==e?void 0:e.data)||void 0===Rn?void 0:Rn.chatStream)||void 0===Tn?void 0:Tn.continueChatResult)||void 0===In?void 0:In.responded_by,header_message:null===(Dn=null===(Fn=null===(Mn=null==e?void 0:e.data)||void 0===Mn?void 0:Mn.chatStream)||void 0===Fn?void 0:Fn.continueChatResult)||void 0===Dn?void 0:Dn.header_message,finalResponseStatus:!1,explainability_id:null!==(Wn=null===(On=null===(jn=null===(Nn=null==e?void 0:e.data)||void 0===Nn?void 0:Nn.chatStream)||void 0===jn?void 0:jn.continueChatResult)||void 0===On?void 0:On.explainability_id)&&void 0!==Wn?Wn:"",isParallelToolResponse:!1})}var bo=null===(Pn=null===(Gn=null===(zn=null===(Bn=null==e?void 0:e.data)||void 0===Bn?void 0:Bn.chatStream)||void 0===zn?void 0:zn.continueChatResult)||void 0===Gn?void 0:Gn.message)||void 0===Pn?void 0:Pn.annotations,So=(null===(Jn=null===(Hn=null===(qn=null===(Kn=null==e?void 0:e.data)||void 0===Kn?void 0:Kn.chatStream)||void 0===qn?void 0:qn.continueChatResult)||void 0===Hn?void 0:Hn.message)||void 0===Jn?void 0:Jn.userFeedbackId)||"",xo={role:"assistant",content:fo.content,orchestratorAndAgentsMessages:i,time:new Date,requestId:null!==(Yn=null===(Qn=null===(Zn=null===(Vn=null==e?void 0:e.data)||void 0===Vn?void 0:Vn.chatStream)||void 0===Zn?void 0:Zn.continueChatResult)||void 0===Qn?void 0:Qn.requestId)&&void 0!==Yn?Yn:"",citations:null===(no=null===(eo=null===(Xn=null===($n=null==e?void 0:e.data)||void 0===$n?void 0:$n.chatStream)||void 0===Xn?void 0:Xn.continueChatResult)||void 0===eo?void 0:eo.message)||void 0===no?void 0:no.citations,guides_utilized:null!==(ao=null===(lo=null===(to=null===(io=null===(oo=null==e?void 0:e.data)||void 0===oo?void 0:oo.chatStream)||void 0===io?void 0:io.continueChatResult)||void 0===to?void 0:to.message)||void 0===lo?void 0:lo.guides_utilized)&&void 0!==ao?ao:[],annotations:bo,resourceId:null===(co=null===(so=null===(ro=null==e?void 0:e.data)||void 0===ro?void 0:ro.chatStream)||void 0===so?void 0:so.continueChatResult)||void 0===co?void 0:co.resourceId,userFeedbackId:So,citationDisplayType:null!==(mo=null===(ho=null===(go=null===(vo=null===(uo=null==e?void 0:e.data)||void 0===uo?void 0:uo.chatStream)||void 0===vo?void 0:vo.continueChatResult)||void 0===go?void 0:go.message)||void 0===ho?void 0:ho.citationDisplayType)&&void 0!==mo?mo:""};if(bo)for(var Lo=0;Lo<(null==bo?void 0:bo.length);Lo++){var ko=bo[Lo];xo=n(n({},xo),{content:null===(po=null==xo?void 0:xo.content)||void 0===po?void 0:po.replace(null==ko?void 0:ko.text,(null==ko?void 0:ko.text)+"<sup>".concat(Lo,"</sup>"))})}return xo}({data:e},t,i);console.log("assistantObject",E),We(o(o([],Oe,!0),[{role:"user",content:a||"",time:l,isFirstQuestionSent:r||!1,requestId:null!==(x=null===(S=null===(b=null==e?void 0:e.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===S?void 0:S.requestId)&&void 0!==x?x:""},E],!1)),He(null===(k=null===(L=null==e?void 0:e.chatStream)||void 0===L?void 0:L.continueChatResult)||void 0===k?void 0:k.isEnd)}},qn=function(e,i,t){var l,a,r,s,d,c,u,v,m,p=(null==t?void 0:t.trim())||(null==Ie?void 0:Ie.trim())||"",f=function(e){return Array.isArray(e)?e.filter((function(e){return""!==e.trim()})):"string"==typeof e?e.split(" OR ").filter((function(e){return""!==e.trim()})):[]},C=f(null==j?void 0:j.whenToApply),y=f(null==j?void 0:j.whenNotToApply),_=null===(l=null==j?void 0:j.scope)||void 0===l?void 0:l.name,w=null;if(null===(a=null==j?void 0:j.scope)||void 0===a?void 0:a.value)try{switch(_){case"Assistant":w=j.scope.value.conciergeId||null;break;case"User":var b=j.scope.value;b.length>0&&(w=b[0].userId||null);break;case"Custom":var S=j.scope.value.scopeId;w=S?[S]:[];break;default:w=null}}catch(e){console.error("Error parsing scope_id:",e,j.scope),w=null}if(!("Enter"!==e.key||e.shiftKey||""===(null==t?void 0:t.trim())&&""===(null==Ie?void 0:Ie.trim())||on)){tn(!0);var x=new Date;We(o(o([],Oe.map((function(e,o){var i;return n(n({},e),{content:null===(i=Un(e.content))||void 0===i?void 0:i.replace("WaitMessage: ","")})})),!0),[{role:"user",content:p,time:x,isFirstQuestionSent:!1}],!1));var L=p.toLowerCase(),k=L.startsWith("delete "),A=L.startsWith("edit "),E=L.startsWith("merge "),R=xn,T=An;if(k){console.log("Delete message detected, parsing for specific label...");if(oe=p.match(/^Delete (?:conflict|similar) learning ([A-Z])/i)){var I=oe[1];console.log('Found label "'.concat(I,'" in delete message.'));var M=(null==Q?void 0:Q.conflicting_learnings)||{},D=(null==Q?void 0:Q.similar_learnings)||{};if(se=n(n({},M),D)[I]){var N={question_id:se.id,variant_id:se.variant_id};if(xn.some((function(e){return e.question_id===N.question_id})))console.log("Item already in delete state, not adding again."),R=xn;else{var O=o(o([],xn,!0),[N],!1);Ln(O),R=O,console.log("Appended new deletion to in_review state:",N)}}else console.warn("Delete message parsed, but could not find learning for label:",I),R=xn}else{console.warn("Could not parse label. Checking for generic delete (e.g., 'Delete similar learning').");M=(null==Q?void 0:Q.conflicting_learnings)||{},D=(null==Q?void 0:Q.similar_learnings)||{};var W=Object.values(M),z=Object.values(D),G=[];if(L.includes("similar learnings")&&z.length>1?(console.log("Found ".concat(z.length," similar learnings. Auto-selecting ALL for deletion.")),G=z):L.includes("conflicting learnings")&&W.length>1?(console.log("Found ".concat(W.length," conflicting learnings. Auto-selecting ALL for deletion.")),G=W):L.includes("similar learning")&&1===z.length?(console.log("Found 1 similar learning. Auto-selecting for deletion."),G=[z[0]]):L.includes("conflicting learning")&&1===W.length?(console.log("Found 1 conflicting learning. Auto-selecting for deletion."),G=[W[0]]):console.log("Generic delete message, but conditions not met (e.g., used 'learnings' for 1 item). No action taken."),G.length>0){for(var P=[],U=0,K=function(e){if(e&&e.id&&e.variant_id){var n={question_id:e.id,variant_id:e.variant_id};xn.some((function(e){return e.question_id===n.question_id}))||(P.push(n),U++)}else console.warn("Skipping invalid learning object during auto-delete:",e)},q=0,H=G;q<H.length;q++){K(se=H[q])}if(U>0){O=o(o([],xn,!0),P,!0);Ln(O),R=O,console.log("Appended ".concat(U," new generic deletion(s) to in_review state:"),P)}else console.log("Item(s) already in delete state, not adding again."),R=xn}else R=xn}}else if(A){console.log("Edit message detected, parsing and persisting 'in_review.edit' state.");if(oe=p.match(/^Edit (?:conflict|similar) learning ([A-Z]) to respond with "([\s\S]*?)" with WTA: ([\s\S]*?) (?:and WNTA: ([\s\S]*)|and remove the WNTA conditions)$/i)){oe[0];I=oe[1];var J=oe[2],Z=oe[3],Y=oe[4];console.log('Found label "'.concat(I,'" in edit message.'));M=(null==Q?void 0:Q.conflicting_learnings)||{},D=(null==Q?void 0:Q.similar_learnings)||{};var $=n(n({},M),D)[I];if($){var X={id:$.id,feedback:{variant:J.trim(),when_to_apply:Z.trim(),when_not_to_apply:(Y||"").trim()},variant_id:$.variant_id};console.log("Constructed new edit object:",X);var ee=An.filter((function(e){return e.id!==$.id})),ne=o(o([],ee,!0),[X],!1);En(ne),T=ne}else console.warn("Edit message parsed, but could not find learning for label:",I),T=An}else console.warn("Could not parse edit message:",p),T=An}else if(E){console.log("Merge message detected, parsing and persisting as 'in_review.delete' state.");var oe;if(oe=p.match(/^Merge (?:Similar|Conflicting) Learning ([A-Z])/i)){I=oe[1].toUpperCase();console.log('Found label "'.concat(I,'" in merge message.'));M=(null==Q?void 0:Q.conflicting_learnings)||{},D=(null==Q?void 0:Q.similar_learnings)||{};if(se=n(n({},M),D)[I]){var ie={question_id:se.id,variant_id:se.variant_id};if(xn.some((function(e){return e.question_id===ie.question_id})))console.log("Item (from merge) already in delete state, not adding again."),R=xn;else{O=o(o([],xn,!0),[ie],!1);Ln(O),R=O,console.log("Appended new MERGE-AS-DELETE to in_review state:",ie)}}else console.warn("Merge message parsed, but could not find learning for label:",I),R=xn}else{console.warn("Could not parse label for merge. Checking for generic merge (e.g., 'Merge similar learning').");M=(null==Q?void 0:Q.conflicting_learnings)||{},D=(null==Q?void 0:Q.similar_learnings)||{},W=Object.values(M),z=Object.values(D);var te=[];if(L.includes("similar learnings")&&z.length>1?(console.log("Found ".concat(z.length," similar learnings. Auto-selecting ALL for MERGE.")),te=z):L.includes("conflicting learnings")&&W.length>1?(console.log("Found ".concat(W.length," conflicting learnings. Auto-selecting ALL for MERGE.")),te=W):L.includes("similar learning")&&1===z.length?(console.log("Found 1 similar learning. Auto-selecting for MERGE."),te=[z[0]]):L.includes("conflicting learning")&&1===W.length?(console.log("Found 1 conflicting learning. Auto-selecting for MERGE."),te=[W[0]]):console.log("Generic merge message, but conditions not met (e.g., used 'learnings' for 1 item). No action taken."),te.length>0){P=[],U=0;for(var le=function(e){if(e&&e.id&&e.variant_id){var n={question_id:e.id,variant_id:e.variant_id};xn.some((function(e){return e.question_id===n.question_id}))||(P.push(n),U++)}else console.warn("Skipping invalid learning object during auto-merge:",e)},ae=0,re=te;ae<re.length;ae++){var se;le(se=re[ae])}if(U>0){O=o(o([],xn,!0),P,!0);Ln(O),R=O,console.log("Appended ".concat(U," new generic MERGE-AS-DELETE(s) to in_review state:"),P)}else console.log("Item(s) from generic merge already in delete state, not adding again."),R=xn}else R=xn}}var de=new Map,ce=[];Re(!1);var ue=n(n(n({userQuery:null!==(r=null==j?void 0:j.question)&&void 0!==r?r:"",topic:null!==(s=null==j?void 0:j.topic.value)&&void 0!==s?s:"",variant:null!==(d=null==j?void 0:j.howToRespond)&&void 0!==d?d:"",whenToApply:C,whenNotToApply:y,scope:_,scope_id:w,categories:null!==(c=null==j?void 0:j.categories)&&void 0!==c?c:[],validation:null!=V?V:null,conflicting_learnings:null!==(u=null==Q?void 0:Q.conflicting_learnings)&&void 0!==u?u:"",similar_learnings:null!==(v=null==Q?void 0:Q.similar_learnings)&&void 0!==v?v:""},(null==me?void 0:me.wta)&&{recommended_whentoapply:me.wta}),(null==me?void 0:me.wnta)&&{recommended_whennottoapply:me.wnta}),{in_review:{delete:R,edit:T,add:pe||[]},isFirstQuestion:0===Oe.length});console.log("🚀 Sending Custom MetaData to Chat Backend:",ue);var ve={WEBSOCKET_URL:B,organizationName:F,chatAssistantName:ye,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:(null==t?void 0:t.trim())||(null==Ie?void 0:Ie.trim())||"",requestId:"requestId-".concat(h()),customPrompt:"",enableForBackend:!1,guestSessionId:_e.current,chatPreviewId:we.current,customMetaData:ue,customMetaDataDebug:{conflicting_learnings_keys:(null==Q?void 0:Q.conflicting_learnings)?Object.keys(Q.conflicting_learnings):[],similar_learnings_keys:(null==Q?void 0:Q.similar_learnings)?Object.keys(Q.similar_learnings):[],conflicting_count:(null==Q?void 0:Q.conflicting_learnings)?Object.keys(Q.conflicting_learnings).length:0,similar_count:(null==Q?void 0:Q.similar_learnings)?Object.keys(Q.similar_learnings).length:0},aiModel:"",onStreamEvent:function(e){return Kn(e,de,ce,x,p,i)},onStreamEnd:function(e){tn(!1)},onError:function(e){return console.error("Stream error:",e)}};if(""!==(null==Ie?void 0:Ie.trim())||(null==t?void 0:t.trim())){Ge(!0),null===(m=xe.current)||void 0===m||m.blur(),Me(""),zn();for(var ge="Thanks for sharing your thoughts. I'm putting together the most helpful suggestions now, so we can make sure this really fits your needs.".split(" "),he="",fe=function(e){setTimeout((function(){he+=ge[e]+" ",en(he.trim())}),25*e)},Ce=0;Ce<ge.length;Ce++)fe(Ce);g.startChatStream(ve)}}},Hn=s(new Set);return u((function(){if(ie&&!on){if(Hn.current.has(ie))return void console.log("[ChatComponent] ⚠️ Duplicate merge trigger ignored:",ie);console.log("[ChatComponent] 🔴 MERGE TRIGGER RECEIVED:",ie),Hn.current.add(ie);var e=null,n="A";if(null==Q?void 0:Q.similar_learnings){var o=Object.values(Q.similar_learnings),i=o.findIndex((function(e){return(null==e?void 0:e.id)===ie}));-1!==i&&(e=o[i],n=String.fromCharCode(65+i))}if(e){var t="Merge Similar Learning ".concat(n," with current learning");console.log("[ChatComponent] ✅ Sending merge message to chat:",t),qn(new KeyboardEvent("keydown",{key:"Enter"}),!1,t),console.log("[ChatComponent] Message sent successfully")}else console.log("[ChatComponent] ❌ Learning not found for ID:",ie);te&&(te(null),console.log("[ChatComponent] Trigger cleared"))}else ie&&on&&console.log("[ChatComponent] ⚠️ Merge trigger received but streaming in progress:",ie)}),[ie,on,te]),c((function(){return{img:function(e){e.node;var o=i(e,["node"]);return l("img",n({},o,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==o?void 0:o.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var o=i(e,["node"]);return l("p",n({},o,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==o?void 0:o.children}))},code:function(e){e.node;var o=i(e,["node"]);return l("span",n({},o,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==o?void 0:o.children}))},ol:function(e){e.node;var o=i(e,["node"]);return l("ol",n({},o,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==o?void 0:o.children}))},ul:function(e){e.node;var o=i(e,["node"]);return l("ul",n({},o,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==o?void 0:o.children}))},wta:function(e){e.node;var n=i(e,["node"]);n.key||n["data-key"];var t=n.label||n.children||"Unknown label";return l(I,{label:t,onToggle:function(e,n){!function(e,n){var i=Array.isArray(e)?e[0]:e;null==ke||ke.length,Re(!0),Ae((function(e){return n?e.includes(i)?e:o(o([],e,!0),[i],!1):e.filter((function(e){return e!==i}))}))}(e,n)}})}}}),[]),a("div",n({className:y.customFont,style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#fbfaff",border:"1px solid #d1d5db",overflow:"hidden"}},{children:[a("div",n({style:{width:"100%",height:"100%",backgroundColor:"#fbfaff",maxWidth:"100%",overflow:"hidden"}},{children:[l("div",n({ref:Rn},{children:l(R,{resetChatHistory:function(){var e="".concat(be,"/api/chat/resetHistory?name=").concat(ye,"&organizationName=").concat(F);Z(null),Y(null);try{var n={method:"GET",params:{guestSessionId:_e.current},withCredentials:!0};m.get(e,n).then((function(){ue(""),ve(""),ge([]),En([]),z(!0),Re(!1),Ae([]),Ye(""),mn(new Set),Ln([]),yn.current="",wn.current.clear(),Hn.current.clear(),te&&te(null),we.current="".concat(h()),W(!1),We([]),Ze(!0),le?(console.log("[ChatComponent] 🔄 Calling onResetLearningData callback"),le()):console.log("[ChatComponent] ❌ onResetLearningData callback not available")})).catch((function(e){console.error(e)}))}catch(e){Ge(!1),console.error(e)}},isStreamEnd:qe})})),a("div",n({style:{width:"100%",height:In,maxHeight:In,overflowY:"auto",backgroundColor:"#fbfaff"},ref:Se},{children:[l("div",n({className:"welcome-message",style:{alignItems:"flex-start",paddingLeft:"0.5rem",paddingTop:"1rem",maxWidth:"70%",fontSize:"1rem",lineHeight:"1.75rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333",fontWeight:"700",textAlign:"left"}},{children:l("span",{children:"I'm here to help fine-tune your learning so it works as accurately as it should."})})),a("div",n({style:{display:"flex",flexDirection:"row",fontFamily:"inherit",padding:"16px 10px 0px 16px",maxWidth:"80%"}},{children:[l("div",n({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.3rem"}},{children:a("svg",n({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[l("g",n({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:l("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),l("defs",{children:l("clipPath",n({id:"clip0_6004_60631"},{children:l("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),l("div",n({style:{display:"flex",flexDirection:"column",fontWeight:400,color:"#000"}},{children:l("div",n({style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:l("span",{children:l(p,n({components:{p:function(e){e.node;var o=i(e,["node"]);return l("p",n({},o,{style:{margin:0}},{children:null==o?void 0:o.children}))}}},{children:De}))})}))}))]})),Oe.length?Oe.map((function(e,o){return a("div",n({style:{display:"flex",padding:"0.5rem 1rem",maxWidth:"100%"}},{children:["assistant"==(null==e?void 0:e.role)&&l("div",n({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.5rem",marginRight:"1rem"}},{children:a("svg",n({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[l("g",n({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:l("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),l("defs",{children:l("clipPath",n({id:"clip0_6004_60631"},{children:l("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),a("div",n({style:{width:"100%"}},{children:["assistant"===e.role&&e.orchestratorAndAgentsMessages&&e.orchestratorAndAgentsMessages.length>0&&l(f,{orchestratorAndAgentsMessages:null==e?void 0:e.orchestratorAndAgentsMessages,isStreamEnd:qe,isCurrentMessage:o===Oe.length-1,ThinkingBulbIconComponent:P}),"assistant"===(null==e?void 0:e.role)?l(S,{index:o,content:null==e?void 0:e.content,messages:Oe,handleStream:qn}):l("span",{}),l("div",n({style:{display:"flex",justifyContent:"flex-end"}},{children:"user"===e.role?l("div",n({style:{backgroundColor:"#8694A10D",padding:"0 1rem",borderRadius:"8px",maxWidth:"80%"}},{children:l(S,{index:o,content:null==e?void 0:e.content,messages:Oe,handleStream:qn,scrollToBottom:zn})})):l("span",{})}))]}))]}))})):Ve&&l(r,{}),ze&&a("div",n({style:{display:"flex",padding:"16px 16px 0px 16px"}},{children:[l("div",n({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.2rem"}},{children:a("svg",n({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[l("g",n({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:l("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),l("defs",{children:l("clipPath",n({id:"clip0_6004_60631"},{children:l("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),l("div",n({style:{display:"inline-flex",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",paddingBottom:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:l("span",{children:Xe})}))]}))]}))]})),a("div",n({style:{width:"95%",height:"content-fit",backgroundColor:"#fbfaff",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"end",position:"relative"}},{children:[l("div",n({style:{visibility:dn?"visible":"hidden",position:"absolute",top:"-3rem",zIndex:0,pointerEvents:"none"}},{children:l("button",n({onClick:zn,style:{borderRadius:"9999px",padding:0,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:"1px solid #d1d5db",pointerEvents:"auto",cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1,height:"2.25rem",width:"2.25rem",margin:"0.3rem"}},{children:l("svg",n({fill:"#000000",width:"16px",height:"16px",viewBox:"0 0 24 24",id:"down","data-name":"Flat Color",xmlns:"http://www.w3.org/2000/svg"},{children:l("path",{id:"primary",d:"M19.71,13.29a1,1,0,0,0-1.42,0L13,18.59V3a1,1,0,0,0-2,0V18.59l-5.29-5.3a1,1,0,0,0-1.42,1.42l7,7a1,1,0,0,0,1.42,0l7-7A1,1,0,0,0,19.71,13.29Z"})}))}))})),l("div",n({style:{width:"100%",backgroundColor:"#fff",display:"flex",alignItems:"end",gap:"0.5rem",border:"1px solid #E5E7EB",borderRadius:"8px"}},{children:a("div",n({style:{width:"100%",display:"flex"}},{children:[l("textarea",{ref:xe,placeholder:"Tell me more about this learning...",value:Ie||"",onChange:function(e){return Me(e.target.value)},onFocus:function(){return rn(!0)},onBlur:function(){return rn(!1)},onKeyDown:function(e){return qn(e)},style:{flexGrow:1,padding:"0.5rem",borderRadius:"0.5rem",border:"none",fontSize:"1rem",lineHeight:"1.5rem",resize:"none",backgroundColor:"#fff",color:"inherit",minHeight:an?"120px":"50px",height:an?"120px":"50px",maxHeight:"120px",overflowY:"auto",fontFamily:"inherit",outline:"none",transition:"min-height 0.3s ease, background-color 0.3s ease",boxSizing:"border-box"}}),a("span",n({style:{display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"end"}},{children:[" ",l("button",n({onClick:function(e){qn(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:bn,style:{padding:"0.5rem 0.75rem",borderRadius:"0.375rem",border:"none",backgroundColor:"white",color:bn?"#d1d5db":"#5928ed",fontWeight:"bold",fontSize:"1rem",cursor:bn?"not-allowed":"pointer",transition:"background-color 0.3s, color 0.3s",height:"50px"}},{children:l(E,{})}))]}))]}))}))]})),a("div",n({style:{width:"95%",display:"flex",gap:"0.25rem",flexDirection:"row"}},{children:[l(_,n({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:l("span",n({style:{width:"50%"}},{children:l(b,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),l(_,n({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:l("span",n({style:{width:"50%"}},{children:l(b,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))};export{M as default};
|
|
2
2
|
//# sourceMappingURL=ContextualChatComponent.js.map
|