@e-llm-studio/instant-learning 0.0.272 → 0.0.273
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/_components/ChatComponent.js +1 -1
- package/dist/cjs/features/IL-OTJ/ILOTJ.js +1 -1
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +1 -1
- package/dist/cjs/features/IL-OTJ/_components/ChatComponents/NormalChat.js +1 -1
- package/dist/cjs/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
- package/dist/cjs/features/InstantLearning/_components/ChatComponent.js +1 -1
- package/dist/cjs/features/InstantLearning/_components/ContextualChatComponent.js +1 -1
- package/dist/features/DocumentLearning/_components/ChatComponent.js +1 -1
- package/dist/features/IL-OTJ/ILOTJ.js +1 -1
- package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +1 -1
- package/dist/features/IL-OTJ/_components/ChatComponents/NormalChat.js +1 -1
- package/dist/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
- package/dist/features/InstantLearning/_components/ChatComponent.js +1 -1
- package/dist/features/InstantLearning/_components/ContextualChatComponent.js +1 -1
- package/dist/types/src/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__makeTemplateObject as e,__spreadArray as t,__assign as n,__awaiter as i,__generator as o,__rest as a}from"tslib";import{jsx as r,jsxs as s,Fragment as l}from"react/jsx-runtime";import{useRef as d,useState as c,useMemo as u,useEffect as h,useCallback as m,useLayoutEffect as v}from"react";import{keyframes as C,Box as p}from"@mui/material";import g from"@mui/material/Tooltip";import f from"react-markdown";import S from"rehype-raw";import b from"axios";import{v4 as y}from"uuid";import{startChatStream as x}from"@e-llm-studio/streaming-response";import{WatchMeWork as w}from"@e-llm-studio/watch-me-work";import R from"./ChatHeader.js";import k from"../MessageRendering/MessageRendering.js";import{Skeleton as _}from"../atoms/SkeletonLoader/SkeletonLoader.js";import{ActionableButton as E}from"../MessageRendering/ClickableChatComponents.js";import T from"../AudioWaveform.js";import M from"./ChatComponent.module.css.js";import I from"../../InstantLearning.module.css.js";import{ScrollToBottom as N}from"../_svg/ScrollToBottom.js";import{useHeaderObserver as D,extractTextFromChildren as L}from"../../helpers/utils.js";import{SendButton as F}from"../_svg/SendButton.js";import A from"../_svg/SparkleIcon.js";import{UserIcon as W}from"../_svg/UserIcon.js";var z,q=function(q){var B=q.chatAssistantName,P=q.organizationName,j=q.baseUrl,H=q.baseWebsocketUrl,Z=q.setIsNewChatClicked;q.ThinkingBulbIconComponent;var K=q.isFormSaveClicked,U=q.setIsFormSavedClicked,G=q.onResetLearningData,V=q.sendMessageInChat,O=q.setSendMessageInChat,J=q.isFormValidating,Q=q.chatTitle,X=q.customMetaData,Y=q.headerMessageHandlers;q.aiResponse;var $=q.setAIResponse,ee=q.onResetChat,te=q.initialChatMessage,ne=void 0===te?"":te,ie=q.onSave,oe=q.chatSize,ae=q.setChatSize,re=q.movingTowards,se=q.setCitations,le=q.textareaPlaceholder,de=void 0===le?"Tell me more about this learning...":le,ce=q.setCurrentRequestId,ue=q.showSavedMessage,he=void 0!==ue&&ue,me=q.savedMessage,ve=q.isError,Ce=void 0!==ve&&ve,pe=q.errorMessage,ge=void 0===pe?"There was an error saving your changes.":pe;q.isSaving;var fe=q.isHighlighted,Se=void 0!==fe&&fe,be=q.onStreamingStateChange,ye=q.onViewComparison;q.isCopyEnabled;var xe=q.onComparisonLinkClick,we=q.onSubmitFeedback,Re=B,ke=d("".concat(Re,"-").concat(P,"-").concat(y())),_e=d("".concat(y())),Ee=j,Te=d(null),Me=d(!0),Ie=d(null),Ne=d(null),De=c(""),Le=De[0],Fe=De[1],Ae=c([]),We=Ae[0],ze=Ae[1],qe=c(!1),Be=qe[0],Pe=qe[1],je=c(!1);je[0];var He=je[1],Ze=c(!0),Ke=Ze[0],Ue=Ze[1],Ge=c(!0);Ge[0];var Ve=Ge[1],Oe=c("");Oe[0];var Je=Oe[1],Qe=c(""),Xe=Qe[0],Ye=Qe[1],$e=c(!1),et=$e[0],tt=$e[1],nt=c(!1),it=nt[0],ot=nt[1],at=c(!0),rt=at[0],st=at[1],lt=c("100%");lt[0];var dt=lt[1],ct=c(null),ut=ct[0],ht=ct[1],mt=c(!1);mt[0];var vt=mt[1],Ct=c(!1),pt=Ct[0],gt=Ct[1],ft=d(null),St=d(new Set),bt=c(null),yt=bt[0],xt=bt[1],wt=c(!1),Rt=wt[0],kt=wt[1],_t=c(!1);_t[0],_t[1];var Et=c(null);Et[0],Et[1],d(null),d(null);var Tt=d(new Map),Mt=d(""),It=C(z||(z=e(["\n 0%, 80%, 100% {\n transform: scale(0);\n }\n 40% {\n transform: scale(1.0);\n }\n "],["\n 0%, 80%, 100% {\n transform: scale(0);\n }\n 40% {\n transform: scale(1.0);\n }\n "]))),Nt=u(function(){return""===(null==Le?void 0:Le.trim())||et},[Le,et]),Dt=u(function(){return J},[J]),Lt=u(function(){return Nt||et||J},[Nt,et,J]);h(function(){null==be||be(et)},[et,be]),h(function(){var e=Te.current,t=function(){if(e){var t=e.scrollTop,n=e.scrollHeight,i=e.clientHeight;st(n-t-i<=20)}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}},[We]);var Ft=D({handlers:Y,setResult:$}).processHeaderMessage;h(function(){he&>(!0)},[he]),h(function(){if(Rt){var e=setTimeout(function(){kt(!1)},3e3);return function(){return clearTimeout(e)}}},[Rt]),h(function(){K&&(Pt(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save this Learning"),U(!1))},[K]),h(function(){if(V)try{if(V.startsWith("__SKELETON__:")){var e=V.split(":"),i=e[1],o=e.slice(2).join(":"),a={role:"user",content:"",id:i,time:new Date,isSkeleton:!0,skeletonContent:o};return ze(function(e){return t(t([],e,!0),[a],!1)}),Pt(new KeyboardEvent("keydown",{key:"Enter"}),!1,o,!1,i),xt(i),O&&O(""),void setTimeout(function(){xt(null)},2e3)}if(V.startsWith("__SKELETON_END__::")){var r=V.split("::")[1]||"";return ze(function(e){return e.map(function(e){return e.isSkeleton?n(n({},e),{isSkeleton:!1,content:e.skeletonContent||r}):e})}),void(O&&O(""))}var s=y();Pt(new KeyboardEvent("keydown",{key:"Enter"}),!1,V,!1,s),xt(s),O&&O(""),setTimeout(function(){return xt(null)},2e3)}catch(e){console.error("Error handling sendMessageInChat signal",e)}},[V]),h(function(){Wt(),zt();var e=function(){var e,t=(null===(e=null==ft?void 0:ft.current)||void 0===e?void 0:e.clientHeight)||0,n="calc(100% - ".concat(t,"px - 10px)");dt(n)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[]);var At=m(function(e){var t="string"==typeof e?e:"smooth";Ie.current&&Ie.current.scrollIntoView({behavior:t,block:"end"}),Me.current&&setTimeout(function(){Ie.current&&Me.current&&Ie.current.scrollIntoView({behavior:t,block:"end"})},100)},[]);h(function(){if(!et){var e="";if(pt?e=me||"Thank you teacher for teaching me, your rule has been saved successfully.":Ce&&(e=ge||"I'm sorry, I couldn't save your changes. Please try again."),e){var n={role:"assistant",content:e,id:y(),citations:[],time:new Date};ze(function(e){return t(t([],e,!0),[n],!1)}),gt(!1),setTimeout(function(){return At("smooth")},100)}}},[pt,Ce,et,me,ge,At]),h(function(){Me.current&&At("smooth")},[At]);var Wt=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(Ee,"/api/chatbot/getChatSettings?name=").concat(Re,"&organizationName=").concat(P),headers:{}};b.request(e).then(function(e){var t,n,i;(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.chatSettings)&&""!==(null===(i=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)||void 0===i?void 0:i.chatInitialMessage)&&Ve(!0)}).catch(function(e){console.error(e)})},zt=function(){return i(void 0,void 0,void 0,function(){var e,t;return o(this,function(n){e="".concat(Ee,"/api/chat/history?name=").concat(Re,"&organizationName=").concat(P);try{t={method:"GET",params:{guestSessionId:ke.current},withCredentials:!0},b.get(e,t).then(function(e){var t=e.data;t.length>0?(ze(t),At()):Ve(!0)}).catch(function(e){console.error(e)})}catch(e){Pe(!1),console.error(e)}return[2]})})};function qt(e){return null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,function(e){return null==e?void 0:e.replace(/\*/g,"*")})}var Bt=function(e,i,o,a,r,s,l){var d,c,u,h,m,v,C,p,g,f,S,b,x,w,R,k,_,E,T,M,I,N,D,L,F,A,W,z,q,B,P,j,H,Z;if(null===(c=null===(d=null==e?void 0:e.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===c?void 0:c.header_message){var K={header_message:e.chatStream.continueChatResult.header_message,responsedata:null===(m=null===(h=null===(u=null==e?void 0:e.chatStream)||void 0===u?void 0:u.continueChatResult)||void 0===h?void 0:h.message)||void 0===m?void 0:m.content};Ft(K)}var U=null===(v=null==e?void 0:e.chatStream)||void 0===v?void 0:v.continueChatResult,G=null==U?void 0:U.isEnd,V=(null===(C=null==U?void 0:U.message)||void 0===C?void 0:C.citations)||[];G&&V.length>0&&se&&se(V);var O={role:"assistant",content:"",id:y()};if(null===(S=null===(f=null===(g=null===(p=null==e?void 0:e.chatStream)||void 0===p?void 0:p.continueChatResult)||void 0===g?void 0:g.message)||void 0===f?void 0:f.content)||void 0===S?void 0:S.includes("WaitMessage: "))He(!0),O.content=function(e){var t="WaitMessage: ",n=e.indexOf(t);if(-1!==n){var i=e.substring(n+13);return null==i?void 0:i.replaceAll("WaitMessage: ","")}return""}((null===(w=null===(x=null===(b=null==e?void 0:e.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===x?void 0:x.message)||void 0===w?void 0:w.content)+"\n\n"),""!==O.content&&(Pe(!1),ze(t(t([],We,!0),[{role:"user",content:r,time:a,isFirstQuestionSent:s||!1,id:l||(null===(k=null===(R=null==e?void 0:e.chatStream)||void 0===R?void 0:R.continueChatResult)||void 0===k?void 0:k.requestId)||"",reply:""},O],!1)));else{He(!1),O.content=null===(M=qt(null===(T=null===(E=null===(_=null==e?void 0:e.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===E?void 0:E.message)||void 0===T?void 0:T.content))||void 0===M?void 0:M.replaceAll("WaitMessage: ","");var J=null===(N=null===(I=null==e?void 0:e.chatStream)||void 0===I?void 0:I.continueChatResult)||void 0===N?void 0:N.requestId;"string"==typeof J&&J&&ce&&ce(J);var Q=function(e,i,o){var a,r,s,l,d,c,u,h,m,v,C,p,g,f,S,b,x,w,R,k,_,E,T,M,I,N,D,L,F,A,W,z,q,B,P={role:"assistant",content:"",id:y(),time:new Date,citations:[]};if(!1===(null===(r=null===(a=e.chatStream)||void 0===a?void 0:a.continueChatResult)||void 0===r?void 0:r.thinking_break)&&!0===(null===(l=null===(s=e.chatStream)||void 0===s?void 0:s.continueChatResult)||void 0===l?void 0:l.is_orchestrator)&&!1===(null===(c=null===(d=e.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===c?void 0:c.isEnd)&&(P.content=qt(e.chatStream.continueChatResult.message.content||"")),!0===(null===(h=null===(u=e.chatStream)||void 0===u?void 0:u.continueChatResult)||void 0===h?void 0:h.thinking_break)&&!0===(null===(v=null===(m=e.chatStream)||void 0===m?void 0:m.continueChatResult)||void 0===v?void 0:v.is_orchestrator)&&!1===(null===(p=null===(C=e.chatStream)||void 0===C?void 0:C.continueChatResult)||void 0===p?void 0:p.isEnd)&&(P.content="",i.push({responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!1})),!1===(null===(f=null===(g=e.chatStream)||void 0===g?void 0:g.continueChatResult)||void 0===f?void 0:f.thinking_break)&&!0===(null===(b=null===(S=e.chatStream)||void 0===S?void 0:S.continueChatResult)||void 0===b?void 0:b.is_orchestrator)&&!0===(null===(w=null===(x=e.chatStream)||void 0===x?void 0:x.continueChatResult)||void 0===w?void 0:w.isEnd)&&(P.content=qt(e.chatStream.continueChatResult.message.content)),!1===(null===(k=null===(R=e.chatStream)||void 0===R?void 0:R.continueChatResult)||void 0===k?void 0:k.thinking_break)&&!1===(null===(E=null===(_=e.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===E?void 0:E.is_orchestrator)&&!1===(null===(M=null===(T=e.chatStream)||void 0===T?void 0:T.continueChatResult)||void 0===M?void 0:M.isEnd)){if((Z=e.chatStream.continueChatResult).explainability_id&&Z.responded_by){var j=Z.explainability_id,H=Z.responded_by;o.has(j)||o.set(j,{responded_by:H,index:i.length})}o.has(e.chatStream.continueChatResult.explainability_id)?i[null==(K=o.get(e.chatStream.continueChatResult.explainability_id))?void 0:K.index]={responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!0,explainability_id:null!==(I=e.chatStream.continueChatResult.explainability_id)&&void 0!==I?I:"",isParallelToolResponse:!0}:i=t(t([],i,!0),[{responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!0,explainability_id:null!==(N=e.chatStream.continueChatResult.explainability_id)&&void 0!==N?N:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(L=null===(D=e.chatStream)||void 0===D?void 0:D.continueChatResult)||void 0===L?void 0:L.thinking_break)&&!1===(null===(A=null===(F=e.chatStream)||void 0===F?void 0:F.continueChatResult)||void 0===A?void 0:A.is_orchestrator)&&!1===(null===(z=null===(W=e.chatStream)||void 0===W?void 0:W.continueChatResult)||void 0===z?void 0:z.isEnd)){var Z,K;(Z=e.chatStream.continueChatResult).explainability_id&&Z.responded_by&&(j=Z.explainability_id,H=Z.responded_by,o.has(j)||o.set(j,{responded_by:H,index:i.length})),o.has(e.chatStream.continueChatResult.explainability_id)?i[null==(K=o.get(e.chatStream.continueChatResult.explainability_id))?void 0:K.index]={responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!1,explainability_id:null!==(q=e.chatStream.continueChatResult.explainability_id)&&void 0!==q?q:"",isParallelToolResponse:!0}:i.push({responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!1,explainability_id:null!==(B=e.chatStream.continueChatResult.explainability_id)&&void 0!==B?B:"",isParallelToolResponse:!1})}return n({orchestratorAndAgentsMessages:i},P)}(e,o,i);Q.time=new Date,Q.citations=V,Q.isEnd=null===(L=null===(D=null==e?void 0:e.chatStream)||void 0===D?void 0:D.continueChatResult)||void 0===L?void 0:L.isEnd,Q.requestId=null===(A=null===(F=null==e?void 0:e.chatStream)||void 0===F?void 0:F.continueChatResult)||void 0===A?void 0:A.requestId,Q.sessionId=ke.current,null===(W=Q.orchestratorAndAgentsMessages)||void 0===W||W.forEach(function(e){e&&e.header_message&&Ft(e)}),(""!==(null==Q?void 0:Q.content)||(null==Q?void 0:Q.orchestratorAndAgentsMessages)&&(null==Q?void 0:Q.orchestratorAndAgentsMessages.length)>0)&&(Pe(!1),ze(t(t([],We,!0),[{role:"user",content:r||"",time:a,isFirstQuestionSent:s||!1,id:l||(null===(q=null===(z=null==e?void 0:e.chatStream)||void 0===z?void 0:z.continueChatResult)||void 0===q?void 0:q.requestId)||"",requestId:null!==(j=null===(P=null===(B=null==e?void 0:e.chatStream)||void 0===B?void 0:B.continueChatResult)||void 0===P?void 0:P.requestId)&&void 0!==j?j:""},Q],!1))),Ue(null===(Z=null===(H=null==e?void 0:e.chatStream)||void 0===H?void 0:H.continueChatResult)||void 0===Z?void 0:Z.isEnd)}},Pt=function(e,i,o,a,r,s){var l,d,c=(void 0!==o?o:Le||"").trim(),u="Enter"===(null==e?void 0:e.key)&&!(null==e?void 0:e.shiftKey);if(u&&(null===(l=null==e?void 0:e.preventDefault)||void 0===l||l.call(e)),!(!c||et&&!o||(null==e?void 0:e.key)&&!u)){if("I want to add a rule description"===c){Ue(!1),Me.current=!0,tt(!0),!ut&&c&&ht(o||"manual_entry");var h=new Date;return ze(function(e){return t(t([],e.map(function(e,t){var i;return n(n({},e),{content:null===(i=qt(e.content))||void 0===i?void 0:i.replace("WaitMessage: ","")})}),!0),[{role:"user",content:c,time:h,isFirstQuestionSent:!1,id:r||y()}],!1)}),At("smooth"),void setTimeout(function(){ze(function(e){return t(t([],e,!0),[{role:"assistant",content:"I'd be happy to help you set up a new rule! To get started, could you tell me what kind of behavior or logic you would like this rule to follow?",id:y(),citations:[],time:new Date}],!1)}),At("smooth"),setTimeout(function(){tt(!1),Ue(!0)},500)},500)}Ue(!1),Me.current=!0,tt(!0),!ut&&c&&ht(o||"manual_entry");var m=new Date;ze(function(e){var i=e.map(function(e){var t;return n(n({},e),{content:null===(t=qt(e.content))||void 0===t?void 0:t.replace("WaitMessage: ","")})});return r&&i.some(function(e){return e.id===r})?i.map(function(e){return e.id===r?n(n({},e),{content:c}):e}):t(t([],i,!0),[{role:"user",content:c,time:m,isFirstQuestionSent:!1,id:r||y()}],!1)}),At("smooth");var v=new Map,C=[],p={WEBSOCKET_URL:H,organizationName:P,chatAssistantName:Re,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:c,requestId:"requestId-".concat(y()),customPrompt:"",enableForBackend:!1,guestSessionId:ke.current,chatPreviewId:_e.current,customMetaData:X,aiModel:"",onStreamEvent:function(e){return Bt(e,v,C,m,c,i,r)},onStreamEnd:function(e){Ue(!0),tt(!1),vt(!1);var i=Date.now(),o=Tt.current.get(Mt.current);if(o){var a=Math.round((i-o)/1e3).toFixed(1);ze(function(e){var i=t([],e,!0).reverse().findIndex(function(e){return"assistant"===e.role});if(-1===i)return e;var o=e.length-1-i;return e.map(function(e,t){return t===o?n(n({},e),{finalTimeTaken:a}):e})})}},onError:function(e){console.error("Stream error:",e),Ue(!0),tt(!1),vt(!1)}};if(c)Pe(!0),null===(d=Ne.current)||void 0===d||d.blur(),Fe(""),At(),Ye(r?"Just a moment, processing your request...":"Okay, got it. Let me take a moment to work on this and I'll get back to you shortly."),Tt.current.set(p.requestId,Date.now()),Mt.current=p.requestId,x(p);s&&s(!1)}},jt=d(null);v(function(){jt.current=Pt});var Ht=m(function(){for(var e,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return null===(e=jt.current)||void 0===e?void 0:e.call.apply(e,t([jt],n,!1))},[]),Zt=u(function(){return{p:function(e){e.node;var t=e.children;return a(e,["node","children"]),r("div",n({style:{margin:0,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px",fontFamily:"inherit"}},{children:t}))},button:function(e){e.node;var t=e.className,i=e.children,o=a(e,["node","className","children"]),l=L(i),d=o["data-value"],c="Tester Genie"===l;return r(E,n({},o,{className:t,handleStream:Ht,isStreamEnd:Ke,disabled:!!ut,isLastMessage:!0,style:{margin:0},isTesterGenie:c,"data-selected":ut===l||ut===d?"true":ut?"false":void 0},{children:s("span",n({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i,c&&s("svg",n({width:"16",height:"20",viewBox:"0 0 16 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[r("path",{d:"M7.20368 8.94768e-06C7.48895 -0.00208639 7.69331 0.364327 7.83856 0.57465C8.14381 1.01633 8.38012 1.87909 7.71077 2.14118C8.57167 2.21011 9.70406 2.93098 10.1785 3.64699C10.5932 4.27286 10.4559 5.16037 9.80301 5.56007L9.9502 7.16593C9.97671 7.44871 10.0265 7.87092 10.0299 8.14457C10.4213 8.23046 11.0787 8.55391 11.326 8.87592C11.5979 8.75656 11.9189 8.76963 12.1688 8.93469C12.3563 8.67751 12.5598 8.41456 12.7507 8.15787C12.3283 7.45155 12.5047 6.57745 13.2143 6.13784C13.5375 5.9377 13.9264 5.87277 14.2971 5.95705C14.0961 6.30964 13.8775 6.72182 13.6593 7.05857C13.7906 7.2436 13.9184 7.44225 14.044 7.63194L14.8022 7.63198C15.0349 7.30106 15.2515 6.90827 15.4835 6.59349C15.8623 7.0712 15.8156 7.79671 15.4734 8.28241C15.1318 8.76741 14.4886 8.9899 13.9118 8.88251C13.758 9.12108 13.5577 9.39243 13.3941 9.63201C13.7143 9.9316 13.7725 10.364 13.4067 10.6594C13.5231 10.8889 13.5309 11.1613 13.447 11.402C13.1502 12.2523 12.1724 12.5645 11.3474 12.5025C11.1171 12.4852 10.939 12.4698 10.7197 12.3953C10.8724 13.1271 10.7744 14.2031 10.5132 14.9051C10.1688 15.8304 9.43632 16.5569 8.54503 16.9655C7.90465 17.2706 7.21222 17.3607 6.50472 17.4505C5.74445 17.5471 4.75801 17.4362 4.08533 17.825C3.9327 17.9132 3.86566 18.0173 3.82943 18.1792C3.94996 18.5982 4.47858 18.6063 4.78474 18.8897C5.20191 19.2758 4.90716 19.9663 4.36611 19.9908C4.31476 19.9931 4.26867 19.9867 4.23186 19.9493C4.23089 19.8303 4.47587 19.7199 4.49787 19.5262C4.55075 19.0604 3.70014 19.0078 3.37835 18.8374C3.13013 18.706 2.99537 18.6309 2.82242 18.4021C2.63795 18.1579 2.58428 17.835 2.63138 17.5392C2.74868 16.7847 3.47123 16.393 4.12184 16.1497C4.61314 15.9659 5.46304 15.7158 5.52019 15.0793C5.58589 14.348 4.97543 13.5523 4.57739 12.9807C4.44275 12.7875 4.3039 12.579 4.16309 12.3919C4.18987 12.365 4.21049 12.3463 4.23916 12.3212C4.59619 12.6218 5.21209 12.6421 5.55038 12.2979C5.70457 12.144 5.78974 11.9342 5.78642 11.7164C5.78121 11.4493 5.63382 11.2002 5.4454 11.019C5.44704 10.9932 5.44824 10.9676 5.449 10.9419C5.4566 10.6648 5.37505 10.4902 5.1892 10.2943C5.18398 10.2538 5.17776 10.2134 5.17053 10.1732C5.08123 9.69297 4.71708 9.34182 4.23415 9.27108C4.16418 9.26083 3.96108 9.26105 3.92071 9.23344C3.90485 9.1828 3.9059 9.20792 3.91904 9.15527C4.22103 8.90139 4.14407 8.78214 4.31107 8.4846C4.42301 8.28513 4.73047 8.15239 4.95452 8.10701C4.96167 7.51076 5.03684 6.88562 5.10036 6.29144C5.12451 6.0655 5.12531 5.75046 5.1511 5.55257C4.11108 4.86747 4.39091 3.75946 5.25465 3.06391C5.84978 2.58469 6.34496 2.31002 7.10143 2.14517C7.01589 2.10416 6.93842 2.04811 6.87269 1.97972C6.77021 1.87349 6.70248 1.73857 6.67853 1.59293C6.60568 1.12096 7.04104 0.914625 7.18759 0.526392C7.26428 0.323403 7.03925 0.146075 7.20368 8.94768e-06Z",fill:"#475569"}),r("path",{d:"M7.459 4.5C7.48797 4.50312 7.71949 4.61154 7.76205 4.63061C8.27062 4.85835 8.87051 5.09164 9.35658 5.3582C9.36602 6.03495 9.37016 6.56625 8.70573 6.91519C8.6633 6.80883 8.63019 6.72409 8.56332 6.63044C8.43786 6.45568 8.24656 6.33963 8.03354 6.30909C7.8434 6.28211 7.65146 6.3197 7.49586 6.43503C7.21897 6.21256 6.76265 6.28197 6.5229 6.52486C6.39308 6.65639 6.34815 6.75074 6.28902 6.92344C5.59702 6.5957 5.58761 6.04267 5.60583 5.35582C5.89882 5.23844 6.21318 5.0724 6.50153 4.941C6.82145 4.79522 7.14482 4.6574 7.459 4.5Z",fill:"#D1EDFD"}),r("path",{d:"M11.0756 10.6406C11.1037 10.6701 11.1324 10.7706 11.1535 10.8145C11.2818 11.0817 11.4922 11.1945 11.7498 11.2977C11.5607 11.63 11.4567 11.8797 11.1034 12.0466L11.0839 12.0517C10.9262 12.0927 10.7996 12.0968 10.651 12.0135C10.4755 11.915 10.3807 11.6614 10.4792 11.478C10.6388 11.1809 10.8877 10.9272 11.0756 10.6406Z",fill:"#D1EDFD"}),r("path",{d:"M11.6036 9.1377C11.6993 9.11763 11.8391 9.16378 11.9294 9.19593C11.6952 9.50644 11.4706 9.81614 11.2327 10.1261L11.1572 10.2255C10.7581 9.73539 11.0333 9.24481 11.6036 9.1377Z",fill:"#D1EDFD"}),r("path",{d:"M7.49681 0.882812C7.53691 0.925159 7.61244 1.08523 7.63598 1.14156C7.74243 1.39673 7.75769 1.76908 7.38596 1.77504C7.28236 1.75599 7.15628 1.68938 7.13517 1.5783C7.0843 1.3107 7.35609 1.09964 7.48737 0.897583L7.49681 0.882812Z",fill:"#D1EDFD"}),r("path",{d:"M1.68305 6.17249C1.71659 6.1673 1.8134 6.16478 1.84892 6.16432C2.34052 6.15616 2.81496 6.34495 3.16655 6.68866C3.50847 7.01806 3.70349 7.47119 3.70765 7.94596C3.70896 8.42345 3.54045 8.85284 3.20281 9.19025C3.34033 9.28068 3.5321 9.52219 3.6543 9.65748C4.17158 9.39073 4.91447 9.69339 4.79675 10.3444C5.08751 10.5485 5.19656 10.8288 5.0585 11.1674C5.15418 11.2375 5.25595 11.3205 5.32383 11.4186C5.40228 11.5303 5.4309 11.6695 5.40291 11.8031C5.32228 12.1857 4.90085 12.3286 4.57669 12.1236C4.51367 12.0838 4.42258 11.9595 4.35299 11.9431C4.30669 11.9557 4.28453 11.9584 4.23644 11.9644C4.22885 11.9742 4.22118 11.9841 4.21343 11.9938C3.93597 12.3413 3.49234 12.4682 3.06933 12.5157C2.85285 12.518 2.70432 12.5146 2.49066 12.4609C1.80785 12.2892 1.50808 11.6167 1.70723 10.9639C1.829 10.5648 2.11891 10.2506 2.48939 10.0518C2.54655 10.132 2.57559 10.2191 2.64066 10.303C2.73571 10.2223 2.82048 10.1482 2.92363 10.0773C2.81023 9.95313 2.66811 9.7693 2.55817 9.63584C2.38871 9.6878 2.23026 9.72879 2.05298 9.74653C1.54239 9.80228 1.03118 9.64711 0.637735 9.31695C0.269964 9.01018 0.0453493 8.54827 0.00544736 8.07322C-0.0309495 7.60988 0.116099 7.15077 0.414918 6.79478C0.742554 6.41198 1.18728 6.21393 1.68305 6.17249Z",fill:"#475569"}),r("path",{d:"M1.79616 6.5951C2.54894 6.5619 3.18687 7.14364 3.22301 7.8963C3.25915 8.64894 2.67989 9.28913 1.92739 9.3282C1.17073 9.3675 0.526231 8.78435 0.489885 8.02753C0.45354 7.27071 1.03921 6.62849 1.79616 6.5951Z",fill:"#D1EDFD"}),r("path",{d:"M4.93607 11.4844C5.12839 11.6261 5.22049 11.9085 4.91876 11.9419C4.8067 11.8805 4.78491 11.8646 4.71094 11.7561C4.81572 11.6752 4.862 11.5925 4.93607 11.4844Z",fill:"#FEFEFD"}),r("path",{d:"M12.5164 3.58594L12.5715 3.59466C12.6589 3.65863 12.6908 3.94434 12.7882 4.05193C12.8789 4.15216 12.9155 4.17816 13.0326 4.24929C13.1363 4.31224 13.3325 4.34025 13.384 4.43124C13.3643 4.56218 13.0693 4.54857 12.9127 4.69344C12.6903 4.89898 12.7114 5.06971 12.5892 5.28622C12.5669 5.28439 12.5368 5.2868 12.5261 5.27346C12.4336 5.15843 12.4072 4.9308 12.3099 4.81465C12.1627 4.63903 11.9972 4.60054 11.7981 4.51372C11.7544 4.49467 11.7266 4.47099 11.7129 4.42649C11.7867 4.31876 12.0509 4.34309 12.2376 4.14892C12.43 3.94901 12.4155 3.72208 12.5164 3.58594Z",fill:"#475569"}),r("path",{d:"M2.13644 3.72656C2.24401 3.77084 2.29712 4.1268 2.431 4.25226C2.60327 4.41371 2.7311 4.41949 2.93246 4.52449C2.96024 4.53897 2.97173 4.56042 2.97671 4.58878C2.89584 4.6981 2.61854 4.70721 2.4596 4.85659C2.26275 5.04156 2.27341 5.29132 2.17022 5.42088C2.16192 5.41849 2.11671 5.40232 2.1156 5.40043C2.01291 5.21216 1.9836 5.04909 1.84812 4.87273C1.73599 4.72675 1.36534 4.69959 1.32812 4.56939C1.3835 4.47941 1.67823 4.44211 1.82291 4.30563C2.02737 4.11274 2.0042 3.8372 2.13644 3.72656Z",fill:"#475569"})]}))]}))}))}}},[Ht,Ke,ut]),Kt=u(function(){return We.some(function(e){return e.isSkeleton})},[We]),Ut=function(e){return i(void 0,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return we?[4,we(e)]:[3,2];case 1:n.sent(),ze(function(e){return t(t([],e,!0),[{role:"assistant",content:"Thanks for your feedback — this will help improve future suggestions.",id:y(),citations:[],time:new Date,isEnd:!0}],!1)}),setTimeout(function(){return At("smooth")},100),n.label=2;case 2:return[2]}})})};return console.log(We,"rendering messages"),s("div",n({className:"".concat(I.customFont," ").concat(M.chatContainer),style:{transition:"box-shadow 0.3s ease-in-out",boxShadow:Se&&!Kt?"0 0 20px 5px rgba(37, 99, 235, 0.5)":"none"}},{children:[s("div",n({ref:Te,className:M.scrollWrapper},{children:[r("div",n({ref:ft,className:M.stickyHeader},{children:r(R,{resetChatHistory:function(){var e="".concat(Ee,"/api/chat/resetHistory?name=").concat(Re,"&organizationName=").concat(P);try{var t={method:"GET",params:{guestSessionId:ke.current},withCredentials:!0};b.get(e,t).then(function(){Z(!0),Je(""),ht(null),St.current.clear(),_e.current="".concat(y()),ze([]),Ve(!0),null==ee||ee(),G&&G()}).catch(function(e){console.error(e)}).finally(function(){ke.current="".concat(Re,"-").concat(P,"-").concat(y())})}catch(e){Pe(!1),console.error(e)}},isStreamEnd:Ke,chatTitle:Q,onResize:ae,chatSize:oe,movingTowards:re})})),s("div",n({className:M.messagesList},{children:[s("div",n({className:M.initialMessageRow},{children:[r("div",n({className:M.iconWrapper},{children:r(A,{})})),r("div",n({className:M.welcomeTextWrapper},{children:r("div",n({className:M.welcomeMarkdownWrapper},{children:r("span",{children:r(f,n({rehypePlugins:[S],components:Zt},{children:ne}))})}))}))]})),We.length>0&&We.map(function(e,t){return s("div",n({className:M.messageRow},{children:["assistant"===e.role?r("div",n({className:M.assistantIconContainer},{children:r(A,{})})):r("div",{className:M.userSpacer}),r("div",n({className:M.messageContent},{children:"assistant"===e.role?s(l,{children:[e.orchestratorAndAgentsMessages&&e.orchestratorAndAgentsMessages.length>0&&r(w,{orchestratorAndAgentsMessages:null==e?void 0:e.orchestratorAndAgentsMessages,isStreamEnd:Ke,finalTimeTaken:null==e?void 0:e.finalTimeTaken},null==e?void 0:e.id),r(k,{index:t,content:null==e?void 0:e.content,role:null==e?void 0:e.role,messages:We,handleStream:Pt,isLastMessage:t===We.length-1,onSave:ie,citations:null==e?void 0:e.citations,setChatSize:ae,chatSize:oe,isStreamEnd:Ke,messageIsEnd:null==e?void 0:e.isEnd,onViewComparison:ye,onTypeResponseClick:function(){var e;kt(!0),null===(e=Ne.current)||void 0===e||e.focus()},onComparisonLinkClick:xe,baseURL:Ee,onFeedbackSubmit:Ut}),r("div",n({className:M.timestamp},{children:e.time&&!isNaN(new Date(e.time).getTime())?new Date(e.time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}))]}):s("div",n({className:M.userMessageWrapper},{children:[s("div",n({className:M.userMessageBubble,style:{transition:"box-shadow 0.3s ease-in-out",boxShadow:e.isSkeleton||Kt||e.id!==yt?"none":"0 0 15px 3px rgba(37, 99, 235, 0.6)"}},{children:[e.isSkeleton?s("div",n({style:{display:"flex",flexDirection:"column",gap:"12px",minWidth:"280px",padding:"8px 0"}},{children:[r(_,{variant:"text",width:"100%",height:16}),r(_,{variant:"text",width:"80%",height:16})]})):r(k,{index:t,content:null==e?void 0:e.content,role:null==e?void 0:e.role,messages:We,handleStream:Pt,isLastMessage:t===We.length-1,onSave:ie,citations:null==e?void 0:e.citations,isStreamEnd:Ke,messageIsEnd:null==e?void 0:e.isEnd,onViewComparison:ye,onComparisonLinkClick:xe,baseURL:Ee,onFeedbackSubmit:Ut}),r("div",n({style:{marginTop:"0.5rem"}},{children:r(W,{})}))]})),r("div",n({className:M.userTimestamp},{children:new Date(e.time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}))]}))}))]}),e.id)}),Be&&s("div",n({className:M.loadingRow},{children:[r("div",n({className:M.iconWrapper,style:{marginTop:"0.2rem"}},{children:r(A,{})})),r("div",n({className:M.loadingTextWrapper},{children:r("span",{children:Xe})}))]})),r("div",{ref:Ie,style:{float:"left",clear:"both"}})]}))]})),s("div",n({className:M.inputAreaWrapper},{children:[et&&s(p,n({sx:{display:"flex",alignItems:"center",gap:"8px",paddingBottom:"8px",paddingLeft:"4px",fontFamily:'"Plus Jakarta Sans", sans-serif',fontSize:"0.875rem",color:"#6b7280",width:"100%"}},{children:[r("span",{children:"Instant Learning AI is thinking"}),r(p,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(It," 1.4s infinite ease-in-out both"),animationDelay:"-0.32s"}}),r(p,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(It," 1.4s infinite ease-in-out both"),animationDelay:"-0.16s"}}),r(p,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(It," 1.4s infinite ease-in-out both")}})]})),r(g,n({title:J?"Please wait for the validation to be completed.":""},{children:s("div",n({className:"".concat(M.inputBoxContainer," ").concat(Dt?M.disabled:""),style:Rt?{boxShadow:"0 0 15px 3px rgba(37, 99, 235, 0.5)",borderColor:"#2563eb",transition:"box-shadow 0.3s ease-in-out, border-color 0.3s ease-in-out"}:{transition:"box-shadow 0.3s ease-in-out, border-color 0.3s ease-in-out"}},{children:[We.length>0&&!rt&&r("div",n({onMouseDown:function(e){e.preventDefault(),At("smooth")},className:M.scrollToBottomBtn},{children:r(N,{})})),s("div",n({style:{width:"100%",display:"flex"}},{children:[r("textarea",{ref:Ne,placeholder:de,value:Le||"",onChange:function(e){Fe(e.target.value)},onFocus:function(){return ot(!0)},onBlur:function(){return ot(!1)},onKeyDown:function(e){return Pt(e)},disabled:Dt,className:"no-scrollbar ".concat(M.chatTextarea),style:{minHeight:it?"120px":"50px",height:it?"120px":"50px",maxHeight:"120px"}}),r("span",n({className:M.sendButtonWrapper},{children:r("button",n({onClick:function(e){Pt(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:Lt,className:"".concat(M.sendButton," ").concat(Lt?M.disabled:M.active)},{children:r(F,{})}))}))]}))]}))}))]})),s("div",n({className:M.footerTools},{children:[r(g,n({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:r("span",n({className:M.footerToolItem},{children:r(T,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),r(g,n({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:r("span",n({className:M.footerToolItem},{children:r(T,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))};export{q as default};
|
|
1
|
+
import{__makeTemplateObject as e,__spreadArray as t,__assign as n,__awaiter as i,__generator as o,__rest as a}from"tslib";import{jsx as r,jsxs as s,Fragment as l}from"react/jsx-runtime";import{useRef as d,useState as c,useMemo as u,useEffect as h,useCallback as m,useLayoutEffect as v}from"react";import{keyframes as C,Box as p}from"@mui/material";import g from"@mui/material/Tooltip";import f from"react-markdown";import S from"rehype-raw";import b from"axios";import{v4 as y}from"uuid";import{startChatStreamSSE as x}from"@e-llm-studio/streaming-response";import{WatchMeWork as w}from"@e-llm-studio/watch-me-work";import R from"./ChatHeader.js";import k from"../MessageRendering/MessageRendering.js";import{Skeleton as _}from"../atoms/SkeletonLoader/SkeletonLoader.js";import{ActionableButton as E}from"../MessageRendering/ClickableChatComponents.js";import M from"../AudioWaveform.js";import T from"./ChatComponent.module.css.js";import I from"../../InstantLearning.module.css.js";import{ScrollToBottom as N}from"../_svg/ScrollToBottom.js";import{useHeaderObserver as D,extractTextFromChildren as L}from"../../helpers/utils.js";import{SendButton as F}from"../_svg/SendButton.js";import A from"../_svg/SparkleIcon.js";import{UserIcon as W}from"../_svg/UserIcon.js";var z,P=function(P){var q=P.chatAssistantName,j=P.organizationName,B=P.baseUrl;P.baseWebsocketUrl;var H=P.setIsNewChatClicked;P.ThinkingBulbIconComponent;var Z=P.isFormSaveClicked,U=P.setIsFormSavedClicked,K=P.onResetLearningData,G=P.sendMessageInChat,V=P.setSendMessageInChat,J=P.isFormValidating,O=P.chatTitle,Q=P.customMetaData,X=P.headerMessageHandlers;P.aiResponse;var Y=P.setAIResponse,$=P.onResetChat,ee=P.initialChatMessage,te=void 0===ee?"":ee,ne=P.onSave,ie=P.chatSize,oe=P.setChatSize,ae=P.movingTowards,re=P.setCitations,se=P.textareaPlaceholder,le=void 0===se?"Tell me more about this learning...":se,de=P.setCurrentRequestId,ce=P.showSavedMessage,ue=void 0!==ce&&ce,he=P.savedMessage,me=P.isError,ve=void 0!==me&&me,Ce=P.errorMessage,pe=void 0===Ce?"There was an error saving your changes.":Ce;P.isSaving;var ge=P.isHighlighted,fe=void 0!==ge&&ge,Se=P.onStreamingStateChange,be=P.onViewComparison;P.isCopyEnabled;var ye=P.onComparisonLinkClick,xe=P.onSubmitFeedback,we=q,Re=d("".concat(we,"-").concat(j,"-").concat(y())),ke=d("".concat(y())),_e=B,Ee=d(null),Me=d(!0),Te=d(null),Ie=d(null),Ne=c(""),De=Ne[0],Le=Ne[1],Fe=c([]),Ae=Fe[0],We=Fe[1],ze=c(!1),Pe=ze[0],qe=ze[1],je=c(!1);je[0];var Be=je[1],He=c(!0),Ze=He[0],Ue=He[1],Ke=c(!0);Ke[0];var Ge=Ke[1],Ve=c("");Ve[0];var Je=Ve[1],Oe=c(""),Qe=Oe[0],Xe=Oe[1],Ye=c(!1),$e=Ye[0],et=Ye[1],tt=c(!1),nt=tt[0],it=tt[1],ot=c(!0),at=ot[0],rt=ot[1],st=c("100%");st[0];var lt=st[1],dt=c(null),ct=dt[0],ut=dt[1],ht=c(!1);ht[0];var mt=ht[1],vt=c(!1),Ct=vt[0],pt=vt[1],gt=d(null),ft=d(new Set),St=c(null),bt=St[0],yt=St[1],xt=c(!1),wt=xt[0],Rt=xt[1],kt=c(!1);kt[0],kt[1];var _t=c(null);_t[0],_t[1],d(null),d(null);var Et=d(new Map),Mt=d(""),Tt=C(z||(z=e(["\n 0%, 80%, 100% {\n transform: scale(0);\n }\n 40% {\n transform: scale(1.0);\n }\n "],["\n 0%, 80%, 100% {\n transform: scale(0);\n }\n 40% {\n transform: scale(1.0);\n }\n "]))),It=u(function(){return""===(null==De?void 0:De.trim())||$e},[De,$e]),Nt=u(function(){return J},[J]),Dt=u(function(){return It||$e||J},[It,$e,J]);h(function(){null==Se||Se($e)},[$e,Se]),h(function(){var e=Ee.current,t=function(){if(e){var t=e.scrollTop,n=e.scrollHeight,i=e.clientHeight;rt(n-t-i<=20)}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}},[Ae]);var Lt=D({handlers:X,setResult:Y}).processHeaderMessage;h(function(){ue&&pt(!0)},[ue]),h(function(){if(wt){var e=setTimeout(function(){Rt(!1)},3e3);return function(){return clearTimeout(e)}}},[wt]),h(function(){Z&&(qt(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save this Learning"),U(!1))},[Z]),h(function(){if(G)try{if(G.startsWith("__SKELETON__:")){var e=G.split(":"),i=e[1],o=e.slice(2).join(":"),a={role:"user",content:"",id:i,time:new Date,isSkeleton:!0,skeletonContent:o};return We(function(e){return t(t([],e,!0),[a],!1)}),qt(new KeyboardEvent("keydown",{key:"Enter"}),!1,o,!1,i),yt(i),V&&V(""),void setTimeout(function(){yt(null)},2e3)}if(G.startsWith("__SKELETON_END__::")){var r=G.split("::")[1]||"";return We(function(e){return e.map(function(e){return e.isSkeleton?n(n({},e),{isSkeleton:!1,content:e.skeletonContent||r}):e})}),void(V&&V(""))}var s=y();qt(new KeyboardEvent("keydown",{key:"Enter"}),!1,G,!1,s),yt(s),V&&V(""),setTimeout(function(){return yt(null)},2e3)}catch(e){console.error("Error handling sendMessageInChat signal",e)}},[G]),h(function(){At(),Wt();var e=function(){var e,t=(null===(e=null==gt?void 0:gt.current)||void 0===e?void 0:e.clientHeight)||0,n="calc(100% - ".concat(t,"px - 10px)");lt(n)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[]);var Ft=m(function(e){var t="string"==typeof e?e:"smooth";Te.current&&Te.current.scrollIntoView({behavior:t,block:"end"}),Me.current&&setTimeout(function(){Te.current&&Me.current&&Te.current.scrollIntoView({behavior:t,block:"end"})},100)},[]);h(function(){if(!$e){var e="";if(Ct?e=he||"Thank you teacher for teaching me, your rule has been saved successfully.":ve&&(e=pe||"I'm sorry, I couldn't save your changes. Please try again."),e){var n={role:"assistant",content:e,id:y(),citations:[],time:new Date};We(function(e){return t(t([],e,!0),[n],!1)}),pt(!1),setTimeout(function(){return Ft("smooth")},100)}}},[Ct,ve,$e,he,pe,Ft]),h(function(){Me.current&&Ft("smooth")},[Ft]);var At=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(_e,"/api/chatbot/getChatSettings?name=").concat(we,"&organizationName=").concat(j),headers:{}};b.request(e).then(function(e){var t,n,i;(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.chatSettings)&&""!==(null===(i=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)||void 0===i?void 0:i.chatInitialMessage)&&Ge(!0)}).catch(function(e){console.error(e)})},Wt=function(){return i(void 0,void 0,void 0,function(){var e,t;return o(this,function(n){e="".concat(_e,"/api/chat/history?name=").concat(we,"&organizationName=").concat(j);try{t={method:"GET",params:{guestSessionId:Re.current},withCredentials:!0},b.get(e,t).then(function(e){var t=e.data;t.length>0?(We(t),Ft()):Ge(!0)}).catch(function(e){console.error(e)})}catch(e){qe(!1),console.error(e)}return[2]})})};function zt(e){return null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,function(e){return null==e?void 0:e.replace(/\*/g,"*")})}var Pt=function(e,i,o,a,r,s,l){var d,c,u,h,m,v,C,p,g,f,S,b,x,w,R,k,_,E,M,T,I,N,D,L,F,A,W,z,P,q,j,B,H,Z;if(null===(c=null===(d=null==e?void 0:e.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===c?void 0:c.header_message){var U={header_message:e.chatStream.continueChatResult.header_message,responsedata:null===(m=null===(h=null===(u=null==e?void 0:e.chatStream)||void 0===u?void 0:u.continueChatResult)||void 0===h?void 0:h.message)||void 0===m?void 0:m.content};Lt(U)}var K=null===(v=null==e?void 0:e.chatStream)||void 0===v?void 0:v.continueChatResult,G=null==K?void 0:K.isEnd,V=(null===(C=null==K?void 0:K.message)||void 0===C?void 0:C.citations)||[];G&&V.length>0&&re&&re(V);var J={role:"assistant",content:"",id:y()};if(null===(S=null===(f=null===(g=null===(p=null==e?void 0:e.chatStream)||void 0===p?void 0:p.continueChatResult)||void 0===g?void 0:g.message)||void 0===f?void 0:f.content)||void 0===S?void 0:S.includes("WaitMessage: "))Be(!0),J.content=function(e){var t="WaitMessage: ",n=e.indexOf(t);if(-1!==n){var i=e.substring(n+13);return null==i?void 0:i.replaceAll("WaitMessage: ","")}return""}((null===(w=null===(x=null===(b=null==e?void 0:e.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===x?void 0:x.message)||void 0===w?void 0:w.content)+"\n\n"),""!==J.content&&(qe(!1),We(t(t([],Ae,!0),[{role:"user",content:r,time:a,isFirstQuestionSent:s||!1,id:l||(null===(k=null===(R=null==e?void 0:e.chatStream)||void 0===R?void 0:R.continueChatResult)||void 0===k?void 0:k.requestId)||"",reply:""},J],!1)));else{Be(!1),J.content=null===(T=zt(null===(M=null===(E=null===(_=null==e?void 0:e.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===E?void 0:E.message)||void 0===M?void 0:M.content))||void 0===T?void 0:T.replaceAll("WaitMessage: ","");var O=null===(N=null===(I=null==e?void 0:e.chatStream)||void 0===I?void 0:I.continueChatResult)||void 0===N?void 0:N.requestId;"string"==typeof O&&O&&de&&de(O);var Q=function(e,i,o){var a,r,s,l,d,c,u,h,m,v,C,p,g,f,S,b,x,w,R,k,_,E,M,T,I,N,D,L,F,A,W,z,P,q,j={role:"assistant",content:"",id:y(),time:new Date,citations:[]};if(!1===(null===(r=null===(a=e.chatStream)||void 0===a?void 0:a.continueChatResult)||void 0===r?void 0:r.thinking_break)&&!0===(null===(l=null===(s=e.chatStream)||void 0===s?void 0:s.continueChatResult)||void 0===l?void 0:l.is_orchestrator)&&!1===(null===(c=null===(d=e.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===c?void 0:c.isEnd)&&(j.content=zt(e.chatStream.continueChatResult.message.content||"")),!0===(null===(h=null===(u=e.chatStream)||void 0===u?void 0:u.continueChatResult)||void 0===h?void 0:h.thinking_break)&&!0===(null===(v=null===(m=e.chatStream)||void 0===m?void 0:m.continueChatResult)||void 0===v?void 0:v.is_orchestrator)&&!1===(null===(p=null===(C=e.chatStream)||void 0===C?void 0:C.continueChatResult)||void 0===p?void 0:p.isEnd)&&(j.content="",i.push({responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!1})),!1===(null===(f=null===(g=e.chatStream)||void 0===g?void 0:g.continueChatResult)||void 0===f?void 0:f.thinking_break)&&!0===(null===(b=null===(S=e.chatStream)||void 0===S?void 0:S.continueChatResult)||void 0===b?void 0:b.is_orchestrator)&&!0===(null===(w=null===(x=e.chatStream)||void 0===x?void 0:x.continueChatResult)||void 0===w?void 0:w.isEnd)&&(j.content=zt(e.chatStream.continueChatResult.message.content)),!1===(null===(k=null===(R=e.chatStream)||void 0===R?void 0:R.continueChatResult)||void 0===k?void 0:k.thinking_break)&&!1===(null===(E=null===(_=e.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===E?void 0:E.is_orchestrator)&&!1===(null===(T=null===(M=e.chatStream)||void 0===M?void 0:M.continueChatResult)||void 0===T?void 0:T.isEnd)){if((Z=e.chatStream.continueChatResult).explainability_id&&Z.responded_by){var B=Z.explainability_id,H=Z.responded_by;o.has(B)||o.set(B,{responded_by:H,index:i.length})}o.has(e.chatStream.continueChatResult.explainability_id)?i[null==(U=o.get(e.chatStream.continueChatResult.explainability_id))?void 0:U.index]={responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!0,explainability_id:null!==(I=e.chatStream.continueChatResult.explainability_id)&&void 0!==I?I:"",isParallelToolResponse:!0}:i=t(t([],i,!0),[{responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!0,explainability_id:null!==(N=e.chatStream.continueChatResult.explainability_id)&&void 0!==N?N:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(L=null===(D=e.chatStream)||void 0===D?void 0:D.continueChatResult)||void 0===L?void 0:L.thinking_break)&&!1===(null===(A=null===(F=e.chatStream)||void 0===F?void 0:F.continueChatResult)||void 0===A?void 0:A.is_orchestrator)&&!1===(null===(z=null===(W=e.chatStream)||void 0===W?void 0:W.continueChatResult)||void 0===z?void 0:z.isEnd)){var Z,U;(Z=e.chatStream.continueChatResult).explainability_id&&Z.responded_by&&(B=Z.explainability_id,H=Z.responded_by,o.has(B)||o.set(B,{responded_by:H,index:i.length})),o.has(e.chatStream.continueChatResult.explainability_id)?i[null==(U=o.get(e.chatStream.continueChatResult.explainability_id))?void 0:U.index]={responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!1,explainability_id:null!==(P=e.chatStream.continueChatResult.explainability_id)&&void 0!==P?P:"",isParallelToolResponse:!0}:i.push({responsedata:e.chatStream.continueChatResult.message.content,responseFrom:e.chatStream.continueChatResult.responded_by,header_message:e.chatStream.continueChatResult.header_message,finalResponseStatus:!1,explainability_id:null!==(q=e.chatStream.continueChatResult.explainability_id)&&void 0!==q?q:"",isParallelToolResponse:!1})}return n({orchestratorAndAgentsMessages:i},j)}(e,o,i);Q.time=new Date,Q.citations=V,Q.isEnd=null===(L=null===(D=null==e?void 0:e.chatStream)||void 0===D?void 0:D.continueChatResult)||void 0===L?void 0:L.isEnd,Q.requestId=null===(A=null===(F=null==e?void 0:e.chatStream)||void 0===F?void 0:F.continueChatResult)||void 0===A?void 0:A.requestId,Q.sessionId=Re.current,null===(W=Q.orchestratorAndAgentsMessages)||void 0===W||W.forEach(function(e){e&&e.header_message&&Lt(e)}),(""!==(null==Q?void 0:Q.content)||(null==Q?void 0:Q.orchestratorAndAgentsMessages)&&(null==Q?void 0:Q.orchestratorAndAgentsMessages.length)>0)&&(qe(!1),We(t(t([],Ae,!0),[{role:"user",content:r||"",time:a,isFirstQuestionSent:s||!1,id:l||(null===(P=null===(z=null==e?void 0:e.chatStream)||void 0===z?void 0:z.continueChatResult)||void 0===P?void 0:P.requestId)||"",requestId:null!==(B=null===(j=null===(q=null==e?void 0:e.chatStream)||void 0===q?void 0:q.continueChatResult)||void 0===j?void 0:j.requestId)&&void 0!==B?B:""},Q],!1))),Ue(null===(Z=null===(H=null==e?void 0:e.chatStream)||void 0===H?void 0:H.continueChatResult)||void 0===Z?void 0:Z.isEnd)}},qt=function(e,i,o,a,r,s){var l,d,c=(void 0!==o?o:De||"").trim(),u="Enter"===(null==e?void 0:e.key)&&!(null==e?void 0:e.shiftKey);if(u&&(null===(l=null==e?void 0:e.preventDefault)||void 0===l||l.call(e)),!(!c||$e&&!o||(null==e?void 0:e.key)&&!u)){if("I want to add a rule description"===c){Ue(!1),Me.current=!0,et(!0),!ct&&c&&ut(o||"manual_entry");var h=new Date;return We(function(e){return t(t([],e.map(function(e,t){var i;return n(n({},e),{content:null===(i=zt(e.content))||void 0===i?void 0:i.replace("WaitMessage: ","")})}),!0),[{role:"user",content:c,time:h,isFirstQuestionSent:!1,id:r||y()}],!1)}),Ft("smooth"),void setTimeout(function(){We(function(e){return t(t([],e,!0),[{role:"assistant",content:"I'd be happy to help you set up a new rule! To get started, could you tell me what kind of behavior or logic you would like this rule to follow?",id:y(),citations:[],time:new Date}],!1)}),Ft("smooth"),setTimeout(function(){et(!1),Ue(!0)},500)},500)}Ue(!1),Me.current=!0,et(!0),!ct&&c&&ut(o||"manual_entry");var m=new Date;We(function(e){var i=e.map(function(e){var t;return n(n({},e),{content:null===(t=zt(e.content))||void 0===t?void 0:t.replace("WaitMessage: ","")})});return r&&i.some(function(e){return e.id===r})?i.map(function(e){return e.id===r?n(n({},e),{content:c}):e}):t(t([],i,!0),[{role:"user",content:c,time:m,isFirstQuestionSent:!1,id:r||y()}],!1)}),Ft("smooth");var v=new Map,C=[],p={API_URL:B,organizationName:j,chatAssistantName:we,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:c,requestId:"requestId-".concat(y()),customPrompt:"",enableForBackend:!1,guestSessionId:Re.current,chatPreviewId:ke.current,customMetaData:Q,aiModel:"",onStreamEvent:function(e){return Pt(e,v,C,m,c,i,r)},onStreamEnd:function(e){Ue(!0),et(!1),mt(!1);var i=Date.now(),o=Et.current.get(Mt.current);if(o){var a=Math.round((i-o)/1e3).toFixed(1);We(function(e){var i=t([],e,!0).reverse().findIndex(function(e){return"assistant"===e.role});if(-1===i)return e;var o=e.length-1-i;return e.map(function(e,t){return t===o?n(n({},e),{finalTimeTaken:a}):e})})}},onError:function(e){console.error("Stream error:",e),Ue(!0),et(!1),mt(!1)}};if(c)qe(!0),null===(d=Ie.current)||void 0===d||d.blur(),Le(""),Ft(),Xe(r?"Just a moment, processing your request...":"Okay, got it. Let me take a moment to work on this and I'll get back to you shortly."),Et.current.set(p.requestId,Date.now()),Mt.current=p.requestId,x(p);s&&s(!1)}},jt=d(null);v(function(){jt.current=qt});var Bt=m(function(){for(var e,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return null===(e=jt.current)||void 0===e?void 0:e.call.apply(e,t([jt],n,!1))},[]),Ht=u(function(){return{p:function(e){e.node;var t=e.children;return a(e,["node","children"]),r("div",n({style:{margin:0,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px",fontFamily:"inherit"}},{children:t}))},button:function(e){e.node;var t=e.className,i=e.children,o=a(e,["node","className","children"]),l=L(i),d=o["data-value"],c="Tester Genie"===l;return r(E,n({},o,{className:t,handleStream:Bt,isStreamEnd:Ze,disabled:!!ct,isLastMessage:!0,style:{margin:0},isTesterGenie:c,"data-selected":ct===l||ct===d?"true":ct?"false":void 0},{children:s("span",n({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i,c&&s("svg",n({width:"16",height:"20",viewBox:"0 0 16 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[r("path",{d:"M7.20368 8.94768e-06C7.48895 -0.00208639 7.69331 0.364327 7.83856 0.57465C8.14381 1.01633 8.38012 1.87909 7.71077 2.14118C8.57167 2.21011 9.70406 2.93098 10.1785 3.64699C10.5932 4.27286 10.4559 5.16037 9.80301 5.56007L9.9502 7.16593C9.97671 7.44871 10.0265 7.87092 10.0299 8.14457C10.4213 8.23046 11.0787 8.55391 11.326 8.87592C11.5979 8.75656 11.9189 8.76963 12.1688 8.93469C12.3563 8.67751 12.5598 8.41456 12.7507 8.15787C12.3283 7.45155 12.5047 6.57745 13.2143 6.13784C13.5375 5.9377 13.9264 5.87277 14.2971 5.95705C14.0961 6.30964 13.8775 6.72182 13.6593 7.05857C13.7906 7.2436 13.9184 7.44225 14.044 7.63194L14.8022 7.63198C15.0349 7.30106 15.2515 6.90827 15.4835 6.59349C15.8623 7.0712 15.8156 7.79671 15.4734 8.28241C15.1318 8.76741 14.4886 8.9899 13.9118 8.88251C13.758 9.12108 13.5577 9.39243 13.3941 9.63201C13.7143 9.9316 13.7725 10.364 13.4067 10.6594C13.5231 10.8889 13.5309 11.1613 13.447 11.402C13.1502 12.2523 12.1724 12.5645 11.3474 12.5025C11.1171 12.4852 10.939 12.4698 10.7197 12.3953C10.8724 13.1271 10.7744 14.2031 10.5132 14.9051C10.1688 15.8304 9.43632 16.5569 8.54503 16.9655C7.90465 17.2706 7.21222 17.3607 6.50472 17.4505C5.74445 17.5471 4.75801 17.4362 4.08533 17.825C3.9327 17.9132 3.86566 18.0173 3.82943 18.1792C3.94996 18.5982 4.47858 18.6063 4.78474 18.8897C5.20191 19.2758 4.90716 19.9663 4.36611 19.9908C4.31476 19.9931 4.26867 19.9867 4.23186 19.9493C4.23089 19.8303 4.47587 19.7199 4.49787 19.5262C4.55075 19.0604 3.70014 19.0078 3.37835 18.8374C3.13013 18.706 2.99537 18.6309 2.82242 18.4021C2.63795 18.1579 2.58428 17.835 2.63138 17.5392C2.74868 16.7847 3.47123 16.393 4.12184 16.1497C4.61314 15.9659 5.46304 15.7158 5.52019 15.0793C5.58589 14.348 4.97543 13.5523 4.57739 12.9807C4.44275 12.7875 4.3039 12.579 4.16309 12.3919C4.18987 12.365 4.21049 12.3463 4.23916 12.3212C4.59619 12.6218 5.21209 12.6421 5.55038 12.2979C5.70457 12.144 5.78974 11.9342 5.78642 11.7164C5.78121 11.4493 5.63382 11.2002 5.4454 11.019C5.44704 10.9932 5.44824 10.9676 5.449 10.9419C5.4566 10.6648 5.37505 10.4902 5.1892 10.2943C5.18398 10.2538 5.17776 10.2134 5.17053 10.1732C5.08123 9.69297 4.71708 9.34182 4.23415 9.27108C4.16418 9.26083 3.96108 9.26105 3.92071 9.23344C3.90485 9.1828 3.9059 9.20792 3.91904 9.15527C4.22103 8.90139 4.14407 8.78214 4.31107 8.4846C4.42301 8.28513 4.73047 8.15239 4.95452 8.10701C4.96167 7.51076 5.03684 6.88562 5.10036 6.29144C5.12451 6.0655 5.12531 5.75046 5.1511 5.55257C4.11108 4.86747 4.39091 3.75946 5.25465 3.06391C5.84978 2.58469 6.34496 2.31002 7.10143 2.14517C7.01589 2.10416 6.93842 2.04811 6.87269 1.97972C6.77021 1.87349 6.70248 1.73857 6.67853 1.59293C6.60568 1.12096 7.04104 0.914625 7.18759 0.526392C7.26428 0.323403 7.03925 0.146075 7.20368 8.94768e-06Z",fill:"#475569"}),r("path",{d:"M7.459 4.5C7.48797 4.50312 7.71949 4.61154 7.76205 4.63061C8.27062 4.85835 8.87051 5.09164 9.35658 5.3582C9.36602 6.03495 9.37016 6.56625 8.70573 6.91519C8.6633 6.80883 8.63019 6.72409 8.56332 6.63044C8.43786 6.45568 8.24656 6.33963 8.03354 6.30909C7.8434 6.28211 7.65146 6.3197 7.49586 6.43503C7.21897 6.21256 6.76265 6.28197 6.5229 6.52486C6.39308 6.65639 6.34815 6.75074 6.28902 6.92344C5.59702 6.5957 5.58761 6.04267 5.60583 5.35582C5.89882 5.23844 6.21318 5.0724 6.50153 4.941C6.82145 4.79522 7.14482 4.6574 7.459 4.5Z",fill:"#D1EDFD"}),r("path",{d:"M11.0756 10.6406C11.1037 10.6701 11.1324 10.7706 11.1535 10.8145C11.2818 11.0817 11.4922 11.1945 11.7498 11.2977C11.5607 11.63 11.4567 11.8797 11.1034 12.0466L11.0839 12.0517C10.9262 12.0927 10.7996 12.0968 10.651 12.0135C10.4755 11.915 10.3807 11.6614 10.4792 11.478C10.6388 11.1809 10.8877 10.9272 11.0756 10.6406Z",fill:"#D1EDFD"}),r("path",{d:"M11.6036 9.1377C11.6993 9.11763 11.8391 9.16378 11.9294 9.19593C11.6952 9.50644 11.4706 9.81614 11.2327 10.1261L11.1572 10.2255C10.7581 9.73539 11.0333 9.24481 11.6036 9.1377Z",fill:"#D1EDFD"}),r("path",{d:"M7.49681 0.882812C7.53691 0.925159 7.61244 1.08523 7.63598 1.14156C7.74243 1.39673 7.75769 1.76908 7.38596 1.77504C7.28236 1.75599 7.15628 1.68938 7.13517 1.5783C7.0843 1.3107 7.35609 1.09964 7.48737 0.897583L7.49681 0.882812Z",fill:"#D1EDFD"}),r("path",{d:"M1.68305 6.17249C1.71659 6.1673 1.8134 6.16478 1.84892 6.16432C2.34052 6.15616 2.81496 6.34495 3.16655 6.68866C3.50847 7.01806 3.70349 7.47119 3.70765 7.94596C3.70896 8.42345 3.54045 8.85284 3.20281 9.19025C3.34033 9.28068 3.5321 9.52219 3.6543 9.65748C4.17158 9.39073 4.91447 9.69339 4.79675 10.3444C5.08751 10.5485 5.19656 10.8288 5.0585 11.1674C5.15418 11.2375 5.25595 11.3205 5.32383 11.4186C5.40228 11.5303 5.4309 11.6695 5.40291 11.8031C5.32228 12.1857 4.90085 12.3286 4.57669 12.1236C4.51367 12.0838 4.42258 11.9595 4.35299 11.9431C4.30669 11.9557 4.28453 11.9584 4.23644 11.9644C4.22885 11.9742 4.22118 11.9841 4.21343 11.9938C3.93597 12.3413 3.49234 12.4682 3.06933 12.5157C2.85285 12.518 2.70432 12.5146 2.49066 12.4609C1.80785 12.2892 1.50808 11.6167 1.70723 10.9639C1.829 10.5648 2.11891 10.2506 2.48939 10.0518C2.54655 10.132 2.57559 10.2191 2.64066 10.303C2.73571 10.2223 2.82048 10.1482 2.92363 10.0773C2.81023 9.95313 2.66811 9.7693 2.55817 9.63584C2.38871 9.6878 2.23026 9.72879 2.05298 9.74653C1.54239 9.80228 1.03118 9.64711 0.637735 9.31695C0.269964 9.01018 0.0453493 8.54827 0.00544736 8.07322C-0.0309495 7.60988 0.116099 7.15077 0.414918 6.79478C0.742554 6.41198 1.18728 6.21393 1.68305 6.17249Z",fill:"#475569"}),r("path",{d:"M1.79616 6.5951C2.54894 6.5619 3.18687 7.14364 3.22301 7.8963C3.25915 8.64894 2.67989 9.28913 1.92739 9.3282C1.17073 9.3675 0.526231 8.78435 0.489885 8.02753C0.45354 7.27071 1.03921 6.62849 1.79616 6.5951Z",fill:"#D1EDFD"}),r("path",{d:"M4.93607 11.4844C5.12839 11.6261 5.22049 11.9085 4.91876 11.9419C4.8067 11.8805 4.78491 11.8646 4.71094 11.7561C4.81572 11.6752 4.862 11.5925 4.93607 11.4844Z",fill:"#FEFEFD"}),r("path",{d:"M12.5164 3.58594L12.5715 3.59466C12.6589 3.65863 12.6908 3.94434 12.7882 4.05193C12.8789 4.15216 12.9155 4.17816 13.0326 4.24929C13.1363 4.31224 13.3325 4.34025 13.384 4.43124C13.3643 4.56218 13.0693 4.54857 12.9127 4.69344C12.6903 4.89898 12.7114 5.06971 12.5892 5.28622C12.5669 5.28439 12.5368 5.2868 12.5261 5.27346C12.4336 5.15843 12.4072 4.9308 12.3099 4.81465C12.1627 4.63903 11.9972 4.60054 11.7981 4.51372C11.7544 4.49467 11.7266 4.47099 11.7129 4.42649C11.7867 4.31876 12.0509 4.34309 12.2376 4.14892C12.43 3.94901 12.4155 3.72208 12.5164 3.58594Z",fill:"#475569"}),r("path",{d:"M2.13644 3.72656C2.24401 3.77084 2.29712 4.1268 2.431 4.25226C2.60327 4.41371 2.7311 4.41949 2.93246 4.52449C2.96024 4.53897 2.97173 4.56042 2.97671 4.58878C2.89584 4.6981 2.61854 4.70721 2.4596 4.85659C2.26275 5.04156 2.27341 5.29132 2.17022 5.42088C2.16192 5.41849 2.11671 5.40232 2.1156 5.40043C2.01291 5.21216 1.9836 5.04909 1.84812 4.87273C1.73599 4.72675 1.36534 4.69959 1.32812 4.56939C1.3835 4.47941 1.67823 4.44211 1.82291 4.30563C2.02737 4.11274 2.0042 3.8372 2.13644 3.72656Z",fill:"#475569"})]}))]}))}))}}},[Bt,Ze,ct]),Zt=u(function(){return Ae.some(function(e){return e.isSkeleton})},[Ae]),Ut=function(e){return i(void 0,void 0,void 0,function(){return o(this,function(n){switch(n.label){case 0:return xe?[4,xe(e)]:[3,2];case 1:n.sent(),We(function(e){return t(t([],e,!0),[{role:"assistant",content:"Thanks for your feedback — this will help improve future suggestions.",id:y(),citations:[],time:new Date,isEnd:!0}],!1)}),setTimeout(function(){return Ft("smooth")},100),n.label=2;case 2:return[2]}})})};return console.log(Ae,"rendering messages"),s("div",n({className:"".concat(I.customFont," ").concat(T.chatContainer),style:{transition:"box-shadow 0.3s ease-in-out",boxShadow:fe&&!Zt?"0 0 20px 5px rgba(37, 99, 235, 0.5)":"none"}},{children:[s("div",n({ref:Ee,className:T.scrollWrapper},{children:[r("div",n({ref:gt,className:T.stickyHeader},{children:r(R,{resetChatHistory:function(){var e="".concat(_e,"/api/chat/resetHistory?name=").concat(we,"&organizationName=").concat(j);try{var t={method:"GET",params:{guestSessionId:Re.current},withCredentials:!0};b.get(e,t).then(function(){H(!0),Je(""),ut(null),ft.current.clear(),ke.current="".concat(y()),We([]),Ge(!0),null==$||$(),K&&K()}).catch(function(e){console.error(e)}).finally(function(){Re.current="".concat(we,"-").concat(j,"-").concat(y())})}catch(e){qe(!1),console.error(e)}},isStreamEnd:Ze,chatTitle:O,onResize:oe,chatSize:ie,movingTowards:ae})})),s("div",n({className:T.messagesList},{children:[s("div",n({className:T.initialMessageRow},{children:[r("div",n({className:T.iconWrapper},{children:r(A,{})})),r("div",n({className:T.welcomeTextWrapper},{children:r("div",n({className:T.welcomeMarkdownWrapper},{children:r("span",{children:r(f,n({rehypePlugins:[S],components:Ht},{children:te}))})}))}))]})),Ae.length>0&&Ae.map(function(e,t){return s("div",n({className:T.messageRow},{children:["assistant"===e.role?r("div",n({className:T.assistantIconContainer},{children:r(A,{})})):r("div",{className:T.userSpacer}),r("div",n({className:T.messageContent},{children:"assistant"===e.role?s(l,{children:[e.orchestratorAndAgentsMessages&&e.orchestratorAndAgentsMessages.length>0&&r(w,{orchestratorAndAgentsMessages:null==e?void 0:e.orchestratorAndAgentsMessages,isStreamEnd:Ze,finalTimeTaken:null==e?void 0:e.finalTimeTaken},null==e?void 0:e.id),r(k,{index:t,content:null==e?void 0:e.content,role:null==e?void 0:e.role,messages:Ae,handleStream:qt,isLastMessage:t===Ae.length-1,onSave:ne,citations:null==e?void 0:e.citations,setChatSize:oe,chatSize:ie,isStreamEnd:Ze,messageIsEnd:null==e?void 0:e.isEnd,onViewComparison:be,onTypeResponseClick:function(){var e;Rt(!0),null===(e=Ie.current)||void 0===e||e.focus()},onComparisonLinkClick:ye,baseURL:_e,onFeedbackSubmit:Ut}),r("div",n({className:T.timestamp},{children:e.time&&!isNaN(new Date(e.time).getTime())?new Date(e.time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}))]}):s("div",n({className:T.userMessageWrapper},{children:[s("div",n({className:T.userMessageBubble,style:{transition:"box-shadow 0.3s ease-in-out",boxShadow:e.isSkeleton||Zt||e.id!==bt?"none":"0 0 15px 3px rgba(37, 99, 235, 0.6)"}},{children:[e.isSkeleton?s("div",n({style:{display:"flex",flexDirection:"column",gap:"12px",minWidth:"280px",padding:"8px 0"}},{children:[r(_,{variant:"text",width:"100%",height:16}),r(_,{variant:"text",width:"80%",height:16})]})):r(k,{index:t,content:null==e?void 0:e.content,role:null==e?void 0:e.role,messages:Ae,handleStream:qt,isLastMessage:t===Ae.length-1,onSave:ne,citations:null==e?void 0:e.citations,isStreamEnd:Ze,messageIsEnd:null==e?void 0:e.isEnd,onViewComparison:be,onComparisonLinkClick:ye,baseURL:_e,onFeedbackSubmit:Ut}),r("div",n({style:{marginTop:"0.5rem"}},{children:r(W,{})}))]})),r("div",n({className:T.userTimestamp},{children:new Date(e.time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}))]}))}))]}),e.id)}),Pe&&s("div",n({className:T.loadingRow},{children:[r("div",n({className:T.iconWrapper,style:{marginTop:"0.2rem"}},{children:r(A,{})})),r("div",n({className:T.loadingTextWrapper},{children:r("span",{children:Qe})}))]})),r("div",{ref:Te,style:{float:"left",clear:"both"}})]}))]})),s("div",n({className:T.inputAreaWrapper},{children:[$e&&s(p,n({sx:{display:"flex",alignItems:"center",gap:"8px",paddingBottom:"8px",paddingLeft:"4px",fontFamily:'"Plus Jakarta Sans", sans-serif',fontSize:"0.875rem",color:"#6b7280",width:"100%"}},{children:[r("span",{children:"Instant Learning AI is thinking"}),r(p,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(Tt," 1.4s infinite ease-in-out both"),animationDelay:"-0.32s"}}),r(p,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(Tt," 1.4s infinite ease-in-out both"),animationDelay:"-0.16s"}}),r(p,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(Tt," 1.4s infinite ease-in-out both")}})]})),r(g,n({title:J?"Please wait for the validation to be completed.":""},{children:s("div",n({className:"".concat(T.inputBoxContainer," ").concat(Nt?T.disabled:""),style:wt?{boxShadow:"0 0 15px 3px rgba(37, 99, 235, 0.5)",borderColor:"#2563eb",transition:"box-shadow 0.3s ease-in-out, border-color 0.3s ease-in-out"}:{transition:"box-shadow 0.3s ease-in-out, border-color 0.3s ease-in-out"}},{children:[Ae.length>0&&!at&&r("div",n({onMouseDown:function(e){e.preventDefault(),Ft("smooth")},className:T.scrollToBottomBtn},{children:r(N,{})})),s("div",n({style:{width:"100%",display:"flex"}},{children:[r("textarea",{ref:Ie,placeholder:le,value:De||"",onChange:function(e){Le(e.target.value)},onFocus:function(){return it(!0)},onBlur:function(){return it(!1)},onKeyDown:function(e){return qt(e)},disabled:Nt,className:"no-scrollbar ".concat(T.chatTextarea),style:{minHeight:nt?"120px":"50px",height:nt?"120px":"50px",maxHeight:"120px"}}),r("span",n({className:T.sendButtonWrapper},{children:r("button",n({onClick:function(e){qt(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:Dt,className:"".concat(T.sendButton," ").concat(Dt?T.disabled:T.active)},{children:r(F,{})}))}))]}))]}))}))]})),s("div",n({className:T.footerTools},{children:[r(g,n({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:r("span",n({className:T.footerToolItem},{children:r(M,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),r(g,n({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:r("span",n({className:T.footerToolItem},{children:r(M,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))};export{P as default};
|
|
2
2
|
//# sourceMappingURL=NormalChat.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i}from"tslib";import{jsxs as e,jsx as t}from"react/jsx-runtime";import n,{useState as o,useEffect as l}from"react";import{InputDataReasoningCard as a}from"../../InputDataReasoningCard.js";import{ConditionSection as r}from"../../organisms/ConditionSection/ConditionSection.js";import{ConfigSection as d}from"../../organisms/ConfigSection/ConfigSection.js";import{ScopeSection as c}from"../../organisms/ScopeSection/ScopeSection.js";import{TextSection as s}from"../../organisms/TextSection/TextSection.js";import u from"../../AccordianSection.js";import{ButtonCognitiveIcon as p}from"../../_svg/ButtonCognitiveIcon.js";import{Loader2Icon as v,Pencil as f,Check as g,AlertTriangle as h}from"lucide-react";var y=function(o){var l=o.children,a=o.onAddVariant,r=o.isDisabled,d=n.Children.toArray(l);return e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[d.map(function(i,o){return e(n.Fragment,{children:[i,t("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},o)}),t("div",i({onClick:r?void 0:a,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:r?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:r?"not-allowed":"pointer",backgroundColor:r?"#f8fafc":"#FFFFFF",opacity:r?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))},m=function(m){var T,D,x,S,C,I,A,b,E,O,w,V=m.state,R=m.handlers,N=m.uiState,_=(null==N?void 0:N.highlights)||new Map,W=_.get("global_0")||{},j=o({}),F=j[0],M=j[1],k=o(null),B=k[0],L=k[1],q="rule-setup"===(null==N?void 0:N.activeEditId),z=n.useRef(new Map),P=o({title:"",scope:{}}),J=P[0],H=P[1],K=o(!1),U=K[0],$=K[1],Z=n.useRef(null==N?void 0:N.isAiStreaming);l(function(){q||U||H({title:V.ruleTitle,scope:V.scopeData})},[V.ruleTitle,V.scopeData,q,U]),l(function(){var i;if(Z.current&&!(null==N?void 0:N.isAiStreaming)&&U&&($(!1),null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null),null==N?void 0:N.setSendMessageInChat)){var e=V.ruleTitle!==J.title,t=JSON.stringify(V.scopeData)!==JSON.stringify(J.scope),n=[];if(e&&n.push("Title with ".concat(V.ruleTitle)),t){var o=[];V.scopeData.station&&o.push(V.scopeData.station),V.scopeData.tiers&&V.scopeData.tiers.length>0&&o.push(V.scopeData.tiers.join(", ")),n.push("Scope with ".concat(o.join(", ")))}var l=n.join(" and ");N.setSendMessageInChat("__SKELETON_END__::Update Rule Setup using ".concat(l))}Z.current=null==N?void 0:N.isAiStreaming},[null==N?void 0:N.isAiStreaming,U,V,J]);var G=function(){var i;R.setRuleTitle(J.title),J.scope.station!==V.scopeData.station&&R.onScopeChange("station",J.scope.station),JSON.stringify(J.scope.tiers)!==JSON.stringify(V.scopeData.tiers)&&R.onScopeChange("tiers",J.scope.tiers),null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null)},Q=function(){var i,e,t=V.ruleTitle!==J.title,n=JSON.stringify(V.scopeData)!==JSON.stringify(J.scope);if(t||n){if($(!0),null==N?void 0:N.setSendMessageInChat){var o="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),l=[];if(t){var a=(null===(e=V.ruleTitle)||void 0===e?void 0:e.trim())?"Title with ".concat(V.ruleTitle):"No Title";l.push(a)}if(n){var r=[];V.scopeData.station&&r.push("station: ".concat(V.scopeData.station)),V.scopeData.tiers&&V.scopeData.tiers.length>0&&r.push("tiers: ".concat(V.scopeData.tiers.join(", ")));var d=r.length>0?"with ".concat(r.join(" and ")):"No Tier Selected";l.push(d)}var c=l.join(" and ");N.setSendMessageInChat("__SKELETON__:".concat(o,":Update Rule Setup ").concat(c))}}else null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null)},X=n.useRef(null==N?void 0:N.defaultVariantOpen),Y=n.useRef(V.variantsByTier);n.useEffect(function(){var i,e,t,n,o=null,l=!1;if(X.current!==(null==N?void 0:N.defaultVariantOpen)&&(l=!0,X.current=null==N?void 0:N.defaultVariantOpen),V.variantsByTier,Y.current,l){if(null==(null==N?void 0:N.defaultVariantOpen)||(null==N?void 0:N.defaultVariantOpen)<0)return L(null),void(Y.current=V.variantsByTier);null===(e=null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,t;return null===(t=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===e||e.forEach(function(i){var e,t=i.toLowerCase().replace(/ /g,"_");((null===(e=V.variantsByTier)||void 0===e?void 0:e[t])||[]).forEach(function(i,e){(null==N?void 0:N.defaultVariantOpen)===e&&(o="".concat(t,"-variant-").concat(e)),(null==N?void 0:N.autoScrollVariantIndex)===e&&(o="".concat(t,"-variant-").concat(e))})}),o&&L(o)}null===B&&(null==N?void 0:N.defaultVariantOpen)>=0&&(null===(n=null===(t=null==N?void 0:N.tierOptions)||void 0===t?void 0:t.filter(function(i){var e,t;return null===(t=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===n||n.forEach(function(i){var e,t=i.toLowerCase().replace(/ /g,"_");((null===(e=V.variantsByTier)||void 0===e?void 0:e[t])||[])[N.defaultVariantOpen]&&L("".concat(t,"-variant-").concat(N.defaultVariantOpen))})),Y.current=V.variantsByTier},[V.variantsByTier,null==N?void 0:N.defaultVariantOpen,null===(T=V.scopeData)||void 0===T?void 0:T.tiers,null==N?void 0:N.tierOptions,null==N?void 0:N.autoScrollVariantIndex]);var ii=function(e){M(function(t){var n;return i(i({},t),((n={})[e]=!t[e],n))})},ei=function(i){var e,t=null===(e=V.fieldCitations)||void 0===e?void 0:e[i];return Array.isArray(t)&&t.length>0?t:V.citations},ti={marginTop:"-17px",position:"relative",zIndex:1};n.useCallback(function(i){i&&requestAnimationFrame(function(){setTimeout(function(){i.scrollIntoView({behavior:"smooth",block:"center"})},300)})},[]),l(function(){var i,e;null!=(null==N?void 0:N.autoScrollVariantIndex)&&(null===(e=null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,t;return null===(t=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===e||e.forEach(function(i){var e=i.toLowerCase().replace(/ /g,"_"),t="".concat(e,"-variant-").concat(N.autoScrollVariantIndex),n=z.current.get(t);n&&requestAnimationFrame(function(){setTimeout(function(){n.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==N?void 0:N.scrollTrigger]),console.log("CreateRule state:",V),console.log("CreateRule uiState:",N);var ni=function(i){return i?i.replace(/_/g," ").replace(/([a-zA-Z])(\d)/g,"$1 $2").replace(/\b\w/g,function(i){return i.toUpperCase()}):"Variant 1"},oi=!!(null==N?void 0:N.activeEditId);return e("div",i({className:"traffic-manager-template"},{children:[t("div",i({"data-edit-id":"rule-setup"},{children:t(u,i({title:{type:"other",label:(null==N?void 0:N.setupLabel)||"Rule Setup"},actionButtons:function(e,n){if(q)return null;var o=!!(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId;return t("div",i({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:t("button",i({title:o?"Save active edits first":"Edit",onClick:function(i){i.stopPropagation(),o?(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(N.activeEditId||null):(!function(){var i;(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId||(null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,"rule-setup"),H({title:V.ruleTitle,scope:V.scopeData}))}(),(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(null),e||n())},disabled:U,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:U?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:U?.5:1}},{children:t(f,{size:14})}))}))},footerData:{ruleTitle:V.ruleTitle,stations:[V.scopeData.station],tiers:null===(D=V.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==N?void 0:N.usedFor),readOnly:"Create"!==(null==N?void 0:N.usedFor),isAiStreaming:null==N?void 0:N.isAiStreaming,editFlow:"Edit"===(null==N?void 0:N.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[U&&e("div",i({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[t(v,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),t(s,i({id:"rule-title",title:N.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:V.ruleTitle,onChange:R.setRuleTitle,readOnly:"Create"!==(null==N?void 0:N.usedFor)||(null==N?void 0:N.isAiStreaming)||!q,isOpen:F.ruleTitle,onToggle:function(){return ii("ruleTitle")},isHighlighted:W.ruleTitle||!1,showCognitiveIcon:V.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(x=N.validationErrors)||void 0===x?void 0:x.ruleTitle},N)),V.citation.ruleTitle&&t("div",i({style:ti},{children:t(a,{isVisible:F.ruleTitle,citation:V.citation.ruleTitle,citations:ei("ruleTitle"),fieldName:"Rule Title",fieldValue:V.ruleTitle})})),t(c,i({id:"scope",title:"",required:!1,scopeData:V.scopeData,onScopeChange:R.onScopeChange,tierLabel:"Which tiers should this learning apply to?",stationLabel:"Which scope should this learning belong to?",highlights:W,isOpen:F.scopeData,onToggle:function(){return ii("scopeData")},showCognitiveIcon:V.citation.scopeData,cognitiveIcon:t(p,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(S=N.validationErrors)||void 0===S?void 0:S.station)||(null===(C=N.validationErrors)||void 0===C?void 0:C.tiers),stationErrorMessage:null===(I=N.validationErrors)||void 0===I?void 0:I.station,tierErrorMessage:null===(A=N.validationErrors)||void 0===A?void 0:A.tiers,readOnly:"Create"!==(null==N?void 0:N.usedFor)||(null==N?void 0:N.isAiStreaming)||!q},N)),V.citation.scopeData&&t("div",i({style:ti},{children:t(a,{isVisible:F.scopeData,citation:V.citation.scopeData,citations:ei("scopeData"),fieldName:"Scope",fieldValue:null===(E=null===(b=V.scopeData)||void 0===b?void 0:b.tiers)||void 0===E?void 0:E.join(", ")})})),!q||U?null:e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[t("button",i({onClick:G,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:Q,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)"}},{children:[t(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==N?void 0:N.pendingEditId)&&e("div",i({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"8px"}},{children:[t(h,{style:{color:"#C2410C"}}),t("div",i({style:{display:"flex",color:"#C2410C",fontSize:"13px",paddingTop:"8px",alignItems:"center"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]}))]}))}))})),null===(w=null===(O=null==N?void 0:N.tierOptions)||void 0===O?void 0:O.filter(function(i){var e,t;return null===(t=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===w?void 0:w.map(function(n,o,l){var c,p,v,f,g=n.toLowerCase().replace(/ /g,"_"),h=(null===(c=V.variantsByTier)||void 0===c?void 0:c[g])||[],m=h.length,T=!1;if(1===m){var D=h[0],x=!(null===(p=null==D?void 0:D.ruleDescription)||void 0===p?void 0:p.trim()),S=(null===(v=null==D?void 0:D.whenToApplyConditions)||void 0===v?void 0:v.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,C=(null===(f=null==D?void 0:D.whenNotToApplyConditions)||void 0===f?void 0:f.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;x&&!S&&!C&&(T=!0)}var I=T?void 0:"".concat(m," ").concat(1===m?"variant":"variants"," configured for this tier"),A=!((null==N?void 0:N.defaultTierOpen)>=0)||o===N.defaultTierOpen;return console.log("Rendering tier : ",n),t(u,i({variant:"tier-header",title:{type:"other",label:n},subtitle:I,defaultOpen:A,footerData:{description:"Variants for ".concat(n)}},{children:t(y,i({onAddVariant:function(){var i;return null===(i=R.addNewVariant)||void 0===i?void 0:i.call(R,g)},isDisabled:null==N?void 0:N.isAiStreaming},{children:h.map(function(n,o){var l,c,p,v,f,h,y,m,T,D,x,S=n.variantType||"default",C="".concat(g,"-variant-").concat(o),I=!0===n.is_variant,A="default"===S||"default_variant"===S;(null==N?void 0:N.defaultVariantOpen)>=0&&N.defaultVariantOpen;var b="".concat(g,"_").concat(o),E=_.get(b)||{},O=(null===(c=null===(l=N.separationItemsByTier)||void 0===l?void 0:l[g])||void 0===c?void 0:c.get(o))||[],w=(null===(v=null===(p=N.togglesByTier)||void 0===p?void 0:p[g])||void 0===v?void 0:v.get(o))||[];(null==N?void 0:N.autoScrollVariantIndex)===o||n.is_variant,console.log("Rendering ".concat(g," variant ").concat(o,":"),n),console.log("Rendering Variant : ",n),console.log("Open Accordion ID:",B,"Current Variant ID:",C);var V=null===(f=null==N?void 0:N.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(g,"-").concat(o)),W=null===(h=null==N?void 0:N.activeEditId)||void 0===h?void 0:h.startsWith("condition-wnta-".concat(g,"-").concat(o));return t("div",i({ref:function(i){i?z.current.set(C,i):z.current.delete(C)},style:{width:"100%"}},{children:t(u,i({title:{type:A?"default":"variant",label:ni(S),number:o+1,isNewVariant:I,isDefault:n.isDefault,isModified:n.isModified},defaultOpen:!0,expanded:B===C,onToggle:function(){var i,e=B===C;console.log("is closing:",e),L(e?null:C),null===(i=null==N?void 0:N.setActiveVariantAccordionIndex)||void 0===i||i.call(N,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:n.ruleDescription||""}},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[t(s,i({id:"rule-description-".concat(g,"-").concat(o),title:N.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:n.isReadOnly||(null==N?void 0:N.isAiStreaming)||oi&&(null==N?void 0:N.activeEditId)!=="rule-description-".concat(g,"-").concat(o),value:n.ruleDescription||"",onChange:function(i){return R.setRuleDescription(g,o,i)},isOpen:F["ruleDescription-".concat(g,"-").concat(o)],onToggle:function(){return ii("ruleDescription-".concat(g,"-").concat(o))},isHighlighted:E.ruleDescription||!1,showCognitiveIcon:null===(y=n.reasoning)||void 0===y?void 0:y.ruleDescription,tooltipDescription:"Why this Description?",errorMessage:null===(m=N.validationErrors)||void 0===m?void 0:m["ruleDescription-".concat(g,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==N?void 0:N.setSendMessageInChat,isAiStreaming:null==N?void 0:N.isAiStreaming,fieldName:"Rule Description"},N)),(null===(T=n.reasoning)||void 0===T?void 0:T.ruleDescription)&&t("div",i({style:ti},{children:t(a,{isVisible:F["ruleDescription-".concat(g,"-").concat(o)],citation:n.reasoning.ruleDescription,citations:ei("ruleDescription_".concat(g,"_").concat(o)),fieldName:"Rule Description",fieldValue:n.ruleDescription})})),t(r,i({id:"when-to-apply-".concat(g,"-").concat(o),idPrefix:"condition-wta",title:N.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:n.isReadOnly||(null==N?void 0:N.isAiStreaming)||oi&&!V,conditions:n.whenToApplyConditions||[],onAdd:function(){return R.addWhenToApply(g,o)},onRemove:function(i,e,t){return R.removeWhenToApply(i,e,t)},onEdit:function(i,e,t,n){return R.editWhenToApply(i,e,t,n)},index:o,tierKey:g,isHighlighted:E.wta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:ei("whenToApply_".concat(g,"_").concat(o)),bordered:!0,addLabel:"Add When to apply",isAiStreaming:N.isAiStreaming,errorMessage:(null===(D=N.validationErrors)||void 0===D?void 0:D["whenToApply-".concat(g,"-").concat(o)])||(null==N?void 0:N.conflictReason)},N)),t(r,i({id:"when-not-to-apply-".concat(g,"-").concat(o),idPrefix:"condition-wnta",title:N.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:n.isReadOnly||(null==N?void 0:N.isAiStreaming)||oi&&!W,conditions:n.whenNotToApplyConditions||[],onAdd:function(){return R.addWhenNotToApply(g,o)},onRemove:function(i,e,t){return R.removeWhenNotToApply(i,e,t)},onEdit:function(i,e,t,n){return R.editWhenNotToApply(i,e,t,n)},index:o,tierKey:g,isHighlighted:E.wnta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:ei("whenNotToApply_".concat(g,"_").concat(o)),bordered:!0,addLabel:"Add When NOT to apply",isAiStreaming:N.isAiStreaming},N)),t(d,i({id:"config-".concat(g,"-").concat(o),title:N.configTitle||"Configuration",required:!1,highlights:E,bordered:!0,readOnly:n.isReadOnly||(null==N?void 0:N.isAiStreaming)||oi,onConfigChange:function(i,e){return R.onConfigChange(g,o,i,e)},separationItems:O,toggles:w,index:o},N)),(null===(x=n.reasoning)||void 0===x?void 0:x.configData)&&t("div",i({style:ti},{children:t(a,{citation:n.reasoning.configData,citations:ei("configData_".concat(g,"_").concat(o)),fieldName:"Configuration",fieldValue:"Proposed Configuration"})}))]}))}),C)}),"".concat(g,"-variant-").concat(o))})}))}),"tier-".concat(o))})]}))};export{m as CreateRule};
|
|
1
|
+
import{__assign as i}from"tslib";import{jsxs as e,jsx as t}from"react/jsx-runtime";import n,{useState as o,useEffect as l}from"react";import{InputDataReasoningCard as a}from"../../InputDataReasoningCard.js";import{ConditionSection as r}from"../../organisms/ConditionSection/ConditionSection.js";import{ConfigSection as d}from"../../organisms/ConfigSection/ConfigSection.js";import{ScopeSection as c}from"../../organisms/ScopeSection/ScopeSection.js";import{TextSection as s}from"../../organisms/TextSection/TextSection.js";import u from"../../AccordianSection.js";import{ButtonCognitiveIcon as p}from"../../_svg/ButtonCognitiveIcon.js";import{Loader2Icon as v,Pencil as f,Check as g,AlertTriangle as h}from"lucide-react";var y=function(o){var l=o.children,a=o.onAddVariant,r=o.isDisabled,d=n.Children.toArray(l);return e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[d.map(function(i,o){return e(n.Fragment,{children:[i,t("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},o)}),t("div",i({onClick:r?void 0:a,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:r?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:r?"not-allowed":"pointer",backgroundColor:r?"#f8fafc":"#FFFFFF",opacity:r?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))},m=function(m){var T,D,x,S,C,A,I,b,E,O,w,V=m.state,R=m.handlers,_=m.uiState,N=(null==_?void 0:_.highlights)||new Map,W=N.get("global_0")||{},j=o({}),F=j[0],M=j[1],k=o(null),B=k[0],L=k[1],q="rule-setup"===(null==_?void 0:_.activeEditId),z=n.useRef(new Map),P=o({title:"",scope:{}}),J=P[0],H=P[1],K=o(!1),U=K[0],$=K[1],Z=n.useRef(null==_?void 0:_.isAiStreaming);l(function(){q||U||H({title:V.ruleTitle,scope:V.scopeData})},[V.ruleTitle,V.scopeData,q,U]),l(function(){var i;if(Z.current&&!(null==_?void 0:_.isAiStreaming)&&U&&($(!1),null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,null),null==_?void 0:_.setSendMessageInChat)){var e=V.ruleTitle!==J.title,t=JSON.stringify(V.scopeData)!==JSON.stringify(J.scope),n=[];if(e&&n.push("Title with ".concat(V.ruleTitle)),t){var o=[];V.scopeData.station&&o.push(V.scopeData.station),V.scopeData.tiers&&V.scopeData.tiers.length>0&&o.push(V.scopeData.tiers.join(", ")),n.push("Scope with ".concat(o.join(", ")))}var l=n.join(" and ");_.setSendMessageInChat("__SKELETON_END__::Update Rule Setup using ".concat(l))}Z.current=null==_?void 0:_.isAiStreaming},[null==_?void 0:_.isAiStreaming,U,V,J]);var G=function(){var i;R.setRuleTitle(J.title),J.scope.station!==V.scopeData.station&&R.onScopeChange("station",J.scope.station),JSON.stringify(J.scope.tiers)!==JSON.stringify(V.scopeData.tiers)&&R.onScopeChange("tiers",J.scope.tiers),null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,null)},Q=function(){var i,e,t=V.ruleTitle!==J.title,n=JSON.stringify(V.scopeData)!==JSON.stringify(J.scope);if(t||n){if($(!0),null==_?void 0:_.setSendMessageInChat){var o="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),l=[];if(t){var a=(null===(e=V.ruleTitle)||void 0===e?void 0:e.trim())?"Title with ".concat(V.ruleTitle):"No Title";l.push(a)}if(n){var r=[];V.scopeData.station&&r.push("station: ".concat(V.scopeData.station)),V.scopeData.tiers&&V.scopeData.tiers.length>0&&r.push("tiers: ".concat(V.scopeData.tiers.join(", ")));var d=r.length>0?"with ".concat(r.join(" and ")):"No Tier Selected";l.push(d)}var c=l.join(" and ");_.setSendMessageInChat("__SKELETON__:".concat(o,":Update Rule Setup ").concat(c))}}else null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,null)},X=n.useRef(null==_?void 0:_.defaultVariantOpen),Y=n.useRef(V.variantsByTier);n.useEffect(function(){var i,e,t,n,o=null,l=!1;if(X.current!==(null==_?void 0:_.defaultVariantOpen)&&(l=!0,X.current=null==_?void 0:_.defaultVariantOpen),V.variantsByTier,Y.current,l){if(null==(null==_?void 0:_.defaultVariantOpen)||(null==_?void 0:_.defaultVariantOpen)<0)return L(null),void(Y.current=V.variantsByTier);null===(e=null===(i=null==_?void 0:_.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,t;return null===(t=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===e||e.forEach(function(i){var e,t=i.toLowerCase().replace(/ /g,"_");((null===(e=V.variantsByTier)||void 0===e?void 0:e[t])||[]).forEach(function(i,e){(null==_?void 0:_.defaultVariantOpen)===e&&(o="".concat(t,"-variant-").concat(e)),(null==_?void 0:_.autoScrollVariantIndex)===e&&(o="".concat(t,"-variant-").concat(e))})}),o&&L(o)}null===B&&(null==_?void 0:_.defaultVariantOpen)>=0&&(null===(n=null===(t=null==_?void 0:_.tierOptions)||void 0===t?void 0:t.filter(function(i){var e,t;return null===(t=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===n||n.forEach(function(i){var e,t=i.toLowerCase().replace(/ /g,"_");((null===(e=V.variantsByTier)||void 0===e?void 0:e[t])||[])[_.defaultVariantOpen]&&L("".concat(t,"-variant-").concat(_.defaultVariantOpen))})),Y.current=V.variantsByTier},[V.variantsByTier,null==_?void 0:_.defaultVariantOpen,null===(T=V.scopeData)||void 0===T?void 0:T.tiers,null==_?void 0:_.tierOptions,null==_?void 0:_.autoScrollVariantIndex]);var ii=function(e){M(function(t){var n;return i(i({},t),((n={})[e]=!t[e],n))})},ei=function(i){var e,t,n,o=null===(e=V.fieldCitations)||void 0===e?void 0:e[i];if(Array.isArray(o)&&o.length>0)return o;var l=i.split("_").slice(0,-2).join("_"),a=null===(t=V.fieldCitations)||void 0===t?void 0:t[l];return Array.isArray(a)&&a.length>0?a:null!==(n=V.citations)&&void 0!==n?n:[]},ti={marginTop:"-17px",position:"relative",zIndex:1};n.useCallback(function(i){i&&requestAnimationFrame(function(){setTimeout(function(){i.scrollIntoView({behavior:"smooth",block:"center"})},300)})},[]),l(function(){var i,e;null!=(null==_?void 0:_.autoScrollVariantIndex)&&(null===(e=null===(i=null==_?void 0:_.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,t;return null===(t=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===e||e.forEach(function(i){var e=i.toLowerCase().replace(/ /g,"_"),t="".concat(e,"-variant-").concat(_.autoScrollVariantIndex),n=z.current.get(t);n&&requestAnimationFrame(function(){setTimeout(function(){n.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==_?void 0:_.scrollTrigger]),console.log("CreateRule state:",V),console.log("CreateRule uiState:",_);var ni=function(i){return i?i.replace(/_/g," ").replace(/([a-zA-Z])(\d)/g,"$1 $2").replace(/\b\w/g,function(i){return i.toUpperCase()}):"Variant 1"},oi=!!(null==_?void 0:_.activeEditId);return e("div",i({className:"traffic-manager-template"},{children:[t("div",i({"data-edit-id":"rule-setup"},{children:t(u,i({title:{type:"other",label:(null==_?void 0:_.setupLabel)||"Rule Setup"},actionButtons:function(e,n){if(q)return null;var o=!!(null==_?void 0:_.activeEditId)&&"rule-setup"!==_.activeEditId;return t("div",i({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:t("button",i({title:o?"Save active edits first":"Edit",onClick:function(i){i.stopPropagation(),o?(null==_?void 0:_.setPendingEditId)&&_.setPendingEditId(_.activeEditId||null):(!function(){var i;(null==_?void 0:_.activeEditId)&&"rule-setup"!==_.activeEditId||(null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,"rule-setup"),H({title:V.ruleTitle,scope:V.scopeData}))}(),(null==_?void 0:_.setPendingEditId)&&_.setPendingEditId(null),e||n())},disabled:U,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:U?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:U?.5:1}},{children:t(f,{size:14})}))}))},footerData:{ruleTitle:V.ruleTitle,stations:[V.scopeData.station],tiers:null===(D=V.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==_?void 0:_.usedFor),readOnly:"Create"!==(null==_?void 0:_.usedFor),isAiStreaming:null==_?void 0:_.isAiStreaming,editFlow:"Edit"===(null==_?void 0:_.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[U&&e("div",i({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[t(v,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),t(s,i({id:"rule-title",title:_.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:V.ruleTitle,onChange:R.setRuleTitle,readOnly:"Create"!==(null==_?void 0:_.usedFor)||(null==_?void 0:_.isAiStreaming)||!q,isOpen:F.ruleTitle,onToggle:function(){return ii("ruleTitle")},isHighlighted:W.ruleTitle||!1,showCognitiveIcon:V.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(x=_.validationErrors)||void 0===x?void 0:x.ruleTitle},_)),V.citation.ruleTitle&&t("div",i({style:ti},{children:t(a,{isVisible:F.ruleTitle,citation:V.citation.ruleTitle,citations:ei("ruleTitle"),fieldName:"Rule Title",fieldValue:V.ruleTitle})})),t(c,i({id:"scope",title:"",required:!1,scopeData:V.scopeData,onScopeChange:R.onScopeChange,tierLabel:"Which tiers should this learning apply to?",stationLabel:"Which scope should this learning belong to?",highlights:W,isOpen:F.scopeData,onToggle:function(){return ii("scopeData")},showCognitiveIcon:V.citation.scopeData,cognitiveIcon:t(p,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(S=_.validationErrors)||void 0===S?void 0:S.station)||(null===(C=_.validationErrors)||void 0===C?void 0:C.tiers),stationErrorMessage:null===(A=_.validationErrors)||void 0===A?void 0:A.station,tierErrorMessage:null===(I=_.validationErrors)||void 0===I?void 0:I.tiers,readOnly:"Create"!==(null==_?void 0:_.usedFor)||(null==_?void 0:_.isAiStreaming)||!q},_)),V.citation.scopeData&&t("div",i({style:ti},{children:t(a,{isVisible:F.scopeData,citation:V.citation.scopeData,citations:ei("scopeData"),fieldName:"Scope",fieldValue:null===(E=null===(b=V.scopeData)||void 0===b?void 0:b.tiers)||void 0===E?void 0:E.join(", ")})})),!q||U?null:e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[t("button",i({onClick:G,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:Q,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)"}},{children:[t(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==_?void 0:_.pendingEditId)&&e("div",i({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"8px"}},{children:[t(h,{style:{color:"#C2410C"}}),t("div",i({style:{display:"flex",color:"#C2410C",fontSize:"13px",paddingTop:"8px",alignItems:"center"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]}))]}))}))})),null===(w=null===(O=null==_?void 0:_.tierOptions)||void 0===O?void 0:O.filter(function(i){var e,t;return null===(t=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===w?void 0:w.map(function(n,o,l){var c,p,v,f,g=n.toLowerCase().replace(/ /g,"_"),h=(null===(c=V.variantsByTier)||void 0===c?void 0:c[g])||[],m=h.length,T=!1;if(1===m){var D=h[0],x=!(null===(p=null==D?void 0:D.ruleDescription)||void 0===p?void 0:p.trim()),S=(null===(v=null==D?void 0:D.whenToApplyConditions)||void 0===v?void 0:v.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,C=(null===(f=null==D?void 0:D.whenNotToApplyConditions)||void 0===f?void 0:f.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;x&&!S&&!C&&(T=!0)}var A=T?void 0:"".concat(m," ").concat(1===m?"variant":"variants"," configured for this tier"),I=!((null==_?void 0:_.defaultTierOpen)>=0)||o===_.defaultTierOpen;return console.log("Rendering tier : ",n),t(u,i({variant:"tier-header",title:{type:"other",label:n},subtitle:A,defaultOpen:I,footerData:{description:"Variants for ".concat(n)}},{children:t(y,i({onAddVariant:function(){var i;return null===(i=R.addNewVariant)||void 0===i?void 0:i.call(R,g)},isDisabled:null==_?void 0:_.isAiStreaming},{children:h.map(function(n,o){var l,c,p,v,f,h,y,m,T,D,x,S=n.variantType||"default",C="".concat(g,"-variant-").concat(o),A=!0===n.is_variant,I="default"===S||"default_variant"===S;(null==_?void 0:_.defaultVariantOpen)>=0&&_.defaultVariantOpen;var b="".concat(g,"_").concat(o),E=N.get(b)||{},O=(null===(c=null===(l=_.separationItemsByTier)||void 0===l?void 0:l[g])||void 0===c?void 0:c.get(o))||[],w=(null===(v=null===(p=_.togglesByTier)||void 0===p?void 0:p[g])||void 0===v?void 0:v.get(o))||[];(null==_?void 0:_.autoScrollVariantIndex)===o||n.is_variant,console.log("Rendering ".concat(g," variant ").concat(o,":"),n),console.log("Rendering Variant : ",n),console.log("Open Accordion ID:",B,"Current Variant ID:",C);var V=null===(f=null==_?void 0:_.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(g,"-").concat(o)),W=null===(h=null==_?void 0:_.activeEditId)||void 0===h?void 0:h.startsWith("condition-wnta-".concat(g,"-").concat(o));return t("div",i({ref:function(i){i?z.current.set(C,i):z.current.delete(C)},style:{width:"100%"}},{children:t(u,i({title:{type:I?"default":"variant",label:ni(S),number:o+1,isNewVariant:A,isDefault:n.isDefault,isModified:n.isModified},defaultOpen:!0,expanded:B===C,onToggle:function(){var i,e=B===C;console.log("is closing:",e),L(e?null:C),null===(i=null==_?void 0:_.setActiveVariantAccordionIndex)||void 0===i||i.call(_,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:n.ruleDescription||""}},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[t(s,i({id:"rule-description-".concat(g,"-").concat(o),title:_.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:n.isReadOnly||(null==_?void 0:_.isAiStreaming)||oi&&(null==_?void 0:_.activeEditId)!=="rule-description-".concat(g,"-").concat(o),value:n.ruleDescription||"",onChange:function(i){return R.setRuleDescription(g,o,i)},isOpen:F["ruleDescription-".concat(g,"-").concat(o)],onToggle:function(){return ii("ruleDescription-".concat(g,"-").concat(o))},isHighlighted:E.ruleDescription||!1,showCognitiveIcon:null===(y=n.reasoning)||void 0===y?void 0:y.ruleDescription,tooltipDescription:"Why this Description?",errorMessage:null===(m=_.validationErrors)||void 0===m?void 0:m["ruleDescription-".concat(g,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==_?void 0:_.setSendMessageInChat,isAiStreaming:null==_?void 0:_.isAiStreaming,fieldName:"Rule Description"},_)),(null===(T=n.reasoning)||void 0===T?void 0:T.ruleDescription)&&t("div",i({style:ti},{children:t(a,{isVisible:F["ruleDescription-".concat(g,"-").concat(o)],citation:n.reasoning.ruleDescription,citations:ei("ruleDescription_".concat(g,"_").concat(o)),fieldName:"Rule Description",fieldValue:n.ruleDescription})})),t(r,i({id:"when-to-apply-".concat(g,"-").concat(o),idPrefix:"condition-wta",title:_.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:n.isReadOnly||(null==_?void 0:_.isAiStreaming)||oi&&!V,conditions:n.whenToApplyConditions||[],onAdd:function(){return R.addWhenToApply(g,o)},onRemove:function(i,e,t){return R.removeWhenToApply(i,e,t)},onEdit:function(i,e,t,n){return R.editWhenToApply(i,e,t,n)},index:o,tierKey:g,isHighlighted:E.wta||!1,highlightedIds:null==_?void 0:_.highlightedIds,tooltipDescription:"Why this Condition?",citations:ei("whenToApply_".concat(g,"_").concat(o)),bordered:!0,addLabel:"Add When to apply",isAiStreaming:_.isAiStreaming,errorMessage:(null===(D=_.validationErrors)||void 0===D?void 0:D["whenToApply-".concat(g,"-").concat(o)])||(null==_?void 0:_.conflictReason)},_)),t(r,i({id:"when-not-to-apply-".concat(g,"-").concat(o),idPrefix:"condition-wnta",title:_.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:n.isReadOnly||(null==_?void 0:_.isAiStreaming)||oi&&!W,conditions:n.whenNotToApplyConditions||[],onAdd:function(){return R.addWhenNotToApply(g,o)},onRemove:function(i,e,t){return R.removeWhenNotToApply(i,e,t)},onEdit:function(i,e,t,n){return R.editWhenNotToApply(i,e,t,n)},index:o,tierKey:g,isHighlighted:E.wnta||!1,highlightedIds:null==_?void 0:_.highlightedIds,tooltipDescription:"Why this Condition?",citations:ei("whenNotToApply_".concat(g,"_").concat(o)),bordered:!0,addLabel:"Add When NOT to apply",isAiStreaming:_.isAiStreaming},_)),t(d,i({id:"config-".concat(g,"-").concat(o),title:_.configTitle||"Configuration",required:!1,highlights:E,bordered:!0,readOnly:n.isReadOnly||(null==_?void 0:_.isAiStreaming)||oi,onConfigChange:function(i,e){return R.onConfigChange(g,o,i,e)},separationItems:O,toggles:w,index:o},_)),(null===(x=n.reasoning)||void 0===x?void 0:x.configData)&&t("div",i({style:ti},{children:t(a,{citation:n.reasoning.configData,citations:ei("configData_".concat(g,"_").concat(o)),fieldName:"Configuration",fieldValue:"Proposed Configuration"})}))]}))}),C)}),"".concat(g,"-variant-").concat(o))})}))}),"tier-".concat(o))})]}))};export{m as CreateRule};
|
|
2
2
|
//# sourceMappingURL=CreateRule.js.map
|