@e-llm-studio/instant-learning 0.0.272 → 0.0.274

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),a=require("@mui/material"),s=require("@mui/material/Tooltip"),i=require("react-markdown"),o=require("rehype-raw"),r=require("axios"),l=require("uuid"),u=require("@e-llm-studio/streaming-response"),d=require("@e-llm-studio/watch-me-work"),c=require("./ChatHeader.js"),h=require("../MessageRendering/MessageRendering.js"),v=require("../atoms/SkeletonLoader/SkeletonLoader.js"),m=require("../MessageRendering/ClickableChatComponents.js"),f=require("../AudioWaveform.js"),g=require("./ChatComponent.module.css.js"),C=require("../../InstantLearning.module.css.js"),p=require("../_svg/ScrollToBottom.js"),_=require("../../helpers/utils.js"),x=require("../_svg/SendButton.js"),S=require("../_svg/SparkleIcon.js"),y=require("../_svg/UserIcon.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var R,j=b(s),w=b(i),k=b(o),E=b(r);exports.default=function(s){var i=s.chatAssistantName,o=s.organizationName,r=s.baseUrl,b=s.baseWebsocketUrl,M=s.setIsNewChatClicked;s.ThinkingBulbIconComponent;var T=s.isFormSaveClicked,I=s.setIsFormSavedClicked,A=s.onResetLearningData,N=s.sendMessageInChat,D=s.setSendMessageInChat,q=s.isFormValidating,L=s.chatTitle,F=s.customMetaData,W=s.headerMessageHandlers;s.aiResponse;var B=s.setAIResponse,z=s.onResetChat,P=s.initialChatMessage,H=void 0===P?"":P,U=s.onSave,Z=s.chatSize,K=s.setChatSize,O=s.movingTowards,G=s.setCitations,V=s.textareaPlaceholder,J=void 0===V?"Tell me more about this learning...":V,Q=s.setCurrentRequestId,X=s.showSavedMessage,Y=void 0!==X&&X,$=s.savedMessage,ee=s.isError,te=void 0!==ee&&ee,ne=s.errorMessage,ae=void 0===ne?"There was an error saving your changes.":ne;s.isSaving;var se=s.isHighlighted,ie=void 0!==se&&se,oe=s.onStreamingStateChange,re=s.onViewComparison;s.isCopyEnabled;var le=s.onComparisonLinkClick,ue=s.onSubmitFeedback,de=i,ce=n.useRef("".concat(de,"-").concat(o,"-").concat(l.v4())),he=n.useRef("".concat(l.v4())),ve=r,me=n.useRef(null),fe=n.useRef(!0),ge=n.useRef(null),Ce=n.useRef(null),pe=n.useState(""),_e=pe[0],xe=pe[1],Se=n.useState([]),ye=Se[0],be=Se[1],Re=n.useState(!1),je=Re[0],we=Re[1],ke=n.useState(!1);ke[0];var Ee=ke[1],Me=n.useState(!0),Te=Me[0],Ie=Me[1],Ae=n.useState(!0);Ae[0];var Ne=Ae[1],De=n.useState("");De[0];var qe=De[1],Le=n.useState(""),Fe=Le[0],We=Le[1],Be=n.useState(!1),ze=Be[0],Pe=Be[1],He=n.useState(!1),Ue=He[0],Ze=He[1],Ke=n.useState(!0),Oe=Ke[0],Ge=Ke[1],Ve=n.useState("100%");Ve[0];var Je=Ve[1],Qe=n.useState(null),Xe=Qe[0],Ye=Qe[1],$e=n.useState(!1);$e[0];var et=$e[1],tt=n.useState(!1),nt=tt[0],at=tt[1],st=n.useRef(null),it=n.useRef(new Set),ot=n.useState(null),rt=ot[0],lt=ot[1],ut=n.useState(!1),dt=ut[0],ct=ut[1],ht=n.useState(!1);ht[0],ht[1];var vt=n.useState(null);vt[0],vt[1],n.useRef(null),n.useRef(null);var mt=n.useRef(new Map),ft=n.useRef(""),gt=a.keyframes(R||(R=e.__makeTemplateObject(["\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 "]))),Ct=n.useMemo(function(){return""===(null==_e?void 0:_e.trim())||ze},[_e,ze]),pt=n.useMemo(function(){return q},[q]),_t=n.useMemo(function(){return Ct||ze||q},[Ct,ze,q]);n.useEffect(function(){null==oe||oe(ze)},[ze,oe]),n.useEffect(function(){var e=me.current,t=function(){if(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;Ge(n-t-a<=20)}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}},[ye]);var xt=_.useHeaderObserver({handlers:W,setResult:B}).processHeaderMessage;n.useEffect(function(){Y&&at(!0)},[Y]),n.useEffect(function(){if(dt){var e=setTimeout(function(){ct(!1)},3e3);return function(){return clearTimeout(e)}}},[dt]),n.useEffect(function(){T&&(wt(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save this Learning"),I(!1))},[T]),n.useEffect(function(){if(N)try{if(N.startsWith("__SKELETON__:")){var t=N.split(":"),n=t[1],a=t.slice(2).join(":"),s={role:"user",content:"",id:n,time:new Date,isSkeleton:!0,skeletonContent:a};return be(function(t){return e.__spreadArray(e.__spreadArray([],t,!0),[s],!1)}),wt(new KeyboardEvent("keydown",{key:"Enter"}),!1,a,!1,n),lt(n),D&&D(""),void setTimeout(function(){lt(null)},2e3)}if(N.startsWith("__SKELETON_END__::")){var i=N.split("::")[1]||"";return be(function(t){return t.map(function(t){return t.isSkeleton?e.__assign(e.__assign({},t),{isSkeleton:!1,content:t.skeletonContent||i}):t})}),void(D&&D(""))}var o=l.v4();wt(new KeyboardEvent("keydown",{key:"Enter"}),!1,N,!1,o),lt(o),D&&D(""),setTimeout(function(){return lt(null)},2e3)}catch(e){console.error("Error handling sendMessageInChat signal",e)}},[N]),n.useEffect(function(){yt(),bt();var e=function(){var e,t=(null===(e=null==st?void 0:st.current)||void 0===e?void 0:e.clientHeight)||0,n="calc(100% - ".concat(t,"px - 10px)");Je(n)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[]);var St=n.useCallback(function(e){var t="string"==typeof e?e:"smooth";ge.current&&ge.current.scrollIntoView({behavior:t,block:"end"}),fe.current&&setTimeout(function(){ge.current&&fe.current&&ge.current.scrollIntoView({behavior:t,block:"end"})},100)},[]);n.useEffect(function(){if(!ze){var t="";if(nt?t=$||"Thank you teacher for teaching me, your rule has been saved successfully.":te&&(t=ae||"I'm sorry, I couldn't save your changes. Please try again."),t){var n={role:"assistant",content:t,id:l.v4(),citations:[],time:new Date};be(function(t){return e.__spreadArray(e.__spreadArray([],t,!0),[n],!1)}),at(!1),setTimeout(function(){return St("smooth")},100)}}},[nt,te,ze,$,ae,St]),n.useEffect(function(){fe.current&&St("smooth")},[St]);var yt=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(ve,"/api/chatbot/getChatSettings?name=").concat(de,"&organizationName=").concat(o),headers:{}};E.default.request(e).then(function(e){var t,n,a;(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.chatSettings)&&""!==(null===(a=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)||void 0===a?void 0:a.chatInitialMessage)&&Ne(!0)}).catch(function(e){console.error(e)})},bt=function(){return e.__awaiter(void 0,void 0,void 0,function(){var t,n;return e.__generator(this,function(e){t="".concat(ve,"/api/chat/history?name=").concat(de,"&organizationName=").concat(o);try{n={method:"GET",params:{guestSessionId:ce.current},withCredentials:!0},E.default.get(t,n).then(function(e){var t=e.data;t.length>0?(be(t),St()):Ne(!0)}).catch(function(e){console.error(e)})}catch(e){we(!1),console.error(e)}return[2]})})};function Rt(e){return null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,function(e){return null==e?void 0:e.replace(/\*/g,"&ast;")})}var jt=function(t,n,a,s,i,o,r){var u,d,c,h,v,m,f,g,C,p,_,x,S,y,b,R,j,w,k,E,M,T,I,A,N,D,q,L,F,W,B,z,P,H;if(null===(d=null===(u=null==t?void 0:t.chatStream)||void 0===u?void 0:u.continueChatResult)||void 0===d?void 0:d.header_message){var U={header_message:t.chatStream.continueChatResult.header_message,responsedata:null===(v=null===(h=null===(c=null==t?void 0:t.chatStream)||void 0===c?void 0:c.continueChatResult)||void 0===h?void 0:h.message)||void 0===v?void 0:v.content};xt(U)}var Z=null===(m=null==t?void 0:t.chatStream)||void 0===m?void 0:m.continueChatResult,K=null==Z?void 0:Z.isEnd,O=(null===(f=null==Z?void 0:Z.message)||void 0===f?void 0:f.citations)||[];K&&O.length>0&&G&&G(O);var V={role:"assistant",content:"",id:l.v4()};if(null===(_=null===(p=null===(C=null===(g=null==t?void 0:t.chatStream)||void 0===g?void 0:g.continueChatResult)||void 0===C?void 0:C.message)||void 0===p?void 0:p.content)||void 0===_?void 0:_.includes("WaitMessage: "))Ee(!0),V.content=function(e){var t="WaitMessage: ",n=e.indexOf(t);if(-1!==n){var a=e.substring(n+13);return null==a?void 0:a.replaceAll("WaitMessage: ","")}return""}((null===(y=null===(S=null===(x=null==t?void 0:t.chatStream)||void 0===x?void 0:x.continueChatResult)||void 0===S?void 0:S.message)||void 0===y?void 0:y.content)+"\n\n"),""!==V.content&&(we(!1),be(e.__spreadArray(e.__spreadArray([],ye,!0),[{role:"user",content:i,time:s,isFirstQuestionSent:o||!1,id:r||(null===(R=null===(b=null==t?void 0:t.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===R?void 0:R.requestId)||"",reply:""},V],!1)));else{Ee(!1),V.content=null===(E=Rt(null===(k=null===(w=null===(j=null==t?void 0:t.chatStream)||void 0===j?void 0:j.continueChatResult)||void 0===w?void 0:w.message)||void 0===k?void 0:k.content))||void 0===E?void 0:E.replaceAll("WaitMessage: ","");var J=null===(T=null===(M=null==t?void 0:t.chatStream)||void 0===M?void 0:M.continueChatResult)||void 0===T?void 0:T.requestId;"string"==typeof J&&J&&Q&&Q(J);var X=function(t,n,a){var s,i,o,r,u,d,c,h,v,m,f,g,C,p,_,x,S,y,b,R,j,w,k,E,M,T,I,A,N,D,q,L,F,W,B={role:"assistant",content:"",id:l.v4(),time:new Date,citations:[]};if(!1===(null===(i=null===(s=t.chatStream)||void 0===s?void 0:s.continueChatResult)||void 0===i?void 0:i.thinking_break)&&!0===(null===(r=null===(o=t.chatStream)||void 0===o?void 0:o.continueChatResult)||void 0===r?void 0:r.is_orchestrator)&&!1===(null===(d=null===(u=t.chatStream)||void 0===u?void 0:u.continueChatResult)||void 0===d?void 0:d.isEnd)&&(B.content=Rt(t.chatStream.continueChatResult.message.content||"")),!0===(null===(h=null===(c=t.chatStream)||void 0===c?void 0:c.continueChatResult)||void 0===h?void 0:h.thinking_break)&&!0===(null===(m=null===(v=t.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===m?void 0:m.is_orchestrator)&&!1===(null===(g=null===(f=t.chatStream)||void 0===f?void 0:f.continueChatResult)||void 0===g?void 0:g.isEnd)&&(B.content="",n.push({responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!1})),!1===(null===(p=null===(C=t.chatStream)||void 0===C?void 0:C.continueChatResult)||void 0===p?void 0:p.thinking_break)&&!0===(null===(x=null===(_=t.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===x?void 0:x.is_orchestrator)&&!0===(null===(y=null===(S=t.chatStream)||void 0===S?void 0:S.continueChatResult)||void 0===y?void 0:y.isEnd)&&(B.content=Rt(t.chatStream.continueChatResult.message.content)),!1===(null===(R=null===(b=t.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===R?void 0:R.thinking_break)&&!1===(null===(w=null===(j=t.chatStream)||void 0===j?void 0:j.continueChatResult)||void 0===w?void 0:w.is_orchestrator)&&!1===(null===(E=null===(k=t.chatStream)||void 0===k?void 0:k.continueChatResult)||void 0===E?void 0:E.isEnd)){if((H=t.chatStream.continueChatResult).explainability_id&&H.responded_by){var z=H.explainability_id,P=H.responded_by;a.has(z)||a.set(z,{responded_by:P,index:n.length})}a.has(t.chatStream.continueChatResult.explainability_id)?n[null==(U=a.get(t.chatStream.continueChatResult.explainability_id))?void 0:U.index]={responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!0,explainability_id:null!==(M=t.chatStream.continueChatResult.explainability_id)&&void 0!==M?M:"",isParallelToolResponse:!0}:n=e.__spreadArray(e.__spreadArray([],n,!0),[{responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!0,explainability_id:null!==(T=t.chatStream.continueChatResult.explainability_id)&&void 0!==T?T:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(A=null===(I=t.chatStream)||void 0===I?void 0:I.continueChatResult)||void 0===A?void 0:A.thinking_break)&&!1===(null===(D=null===(N=t.chatStream)||void 0===N?void 0:N.continueChatResult)||void 0===D?void 0:D.is_orchestrator)&&!1===(null===(L=null===(q=t.chatStream)||void 0===q?void 0:q.continueChatResult)||void 0===L?void 0:L.isEnd)){var H,U;(H=t.chatStream.continueChatResult).explainability_id&&H.responded_by&&(z=H.explainability_id,P=H.responded_by,a.has(z)||a.set(z,{responded_by:P,index:n.length})),a.has(t.chatStream.continueChatResult.explainability_id)?n[null==(U=a.get(t.chatStream.continueChatResult.explainability_id))?void 0:U.index]={responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!1,explainability_id:null!==(F=t.chatStream.continueChatResult.explainability_id)&&void 0!==F?F:"",isParallelToolResponse:!0}:n.push({responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!1,explainability_id:null!==(W=t.chatStream.continueChatResult.explainability_id)&&void 0!==W?W:"",isParallelToolResponse:!1})}return e.__assign({orchestratorAndAgentsMessages:n},B)}(t,a,n);X.time=new Date,X.citations=O,X.isEnd=null===(A=null===(I=null==t?void 0:t.chatStream)||void 0===I?void 0:I.continueChatResult)||void 0===A?void 0:A.isEnd,X.requestId=null===(D=null===(N=null==t?void 0:t.chatStream)||void 0===N?void 0:N.continueChatResult)||void 0===D?void 0:D.requestId,X.sessionId=ce.current,null===(q=X.orchestratorAndAgentsMessages)||void 0===q||q.forEach(function(e){e&&e.header_message&&xt(e)}),(""!==(null==X?void 0:X.content)||(null==X?void 0:X.orchestratorAndAgentsMessages)&&(null==X?void 0:X.orchestratorAndAgentsMessages.length)>0)&&(we(!1),be(e.__spreadArray(e.__spreadArray([],ye,!0),[{role:"user",content:i||"",time:s,isFirstQuestionSent:o||!1,id:r||(null===(F=null===(L=null==t?void 0:t.chatStream)||void 0===L?void 0:L.continueChatResult)||void 0===F?void 0:F.requestId)||"",requestId:null!==(z=null===(B=null===(W=null==t?void 0:t.chatStream)||void 0===W?void 0:W.continueChatResult)||void 0===B?void 0:B.requestId)&&void 0!==z?z:""},X],!1))),Ie(null===(H=null===(P=null==t?void 0:t.chatStream)||void 0===P?void 0:P.continueChatResult)||void 0===H?void 0:H.isEnd)}},wt=function(t,n,a,s,i,r){var d,c,h=(void 0!==a?a:_e||"").trim(),v="Enter"===(null==t?void 0:t.key)&&!(null==t?void 0:t.shiftKey);if(v&&(null===(d=null==t?void 0:t.preventDefault)||void 0===d||d.call(t)),!(!h||ze&&!a||(null==t?void 0:t.key)&&!v)){if("I want to add a rule description"===h){Ie(!1),fe.current=!0,Pe(!0),!Xe&&h&&Ye(a||"manual_entry");var m=new Date;return be(function(t){return e.__spreadArray(e.__spreadArray([],t.map(function(t,n){var a;return e.__assign(e.__assign({},t),{content:null===(a=Rt(t.content))||void 0===a?void 0:a.replace("WaitMessage: ","")})}),!0),[{role:"user",content:h,time:m,isFirstQuestionSent:!1,id:i||l.v4()}],!1)}),St("smooth"),void setTimeout(function(){be(function(t){return e.__spreadArray(e.__spreadArray([],t,!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:l.v4(),citations:[],time:new Date}],!1)}),St("smooth"),setTimeout(function(){Pe(!1),Ie(!0)},500)},500)}Ie(!1),fe.current=!0,Pe(!0),!Xe&&h&&Ye(a||"manual_entry");var f=new Date;be(function(t){var n=t.map(function(t){var n;return e.__assign(e.__assign({},t),{content:null===(n=Rt(t.content))||void 0===n?void 0:n.replace("WaitMessage: ","")})});return i&&n.some(function(e){return e.id===i})?n.map(function(t){return t.id===i?e.__assign(e.__assign({},t),{content:h}):t}):e.__spreadArray(e.__spreadArray([],n,!0),[{role:"user",content:h,time:f,isFirstQuestionSent:!1,id:i||l.v4()}],!1)}),St("smooth");var g=new Map,C=[],p={WEBSOCKET_URL:b,organizationName:o,chatAssistantName:de,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:h,requestId:"requestId-".concat(l.v4()),customPrompt:"",enableForBackend:!1,guestSessionId:ce.current,chatPreviewId:he.current,customMetaData:F,aiModel:"",onStreamEvent:function(e){return jt(e,g,C,f,h,n,i)},onStreamEnd:function(t){Ie(!0),Pe(!1),et(!1);var n=Date.now(),a=mt.current.get(ft.current);if(a){var s=Math.round((n-a)/1e3).toFixed(1);be(function(t){var n=e.__spreadArray([],t,!0).reverse().findIndex(function(e){return"assistant"===e.role});if(-1===n)return t;var a=t.length-1-n;return t.map(function(t,n){return n===a?e.__assign(e.__assign({},t),{finalTimeTaken:s}):t})})}},onError:function(e){console.error("Stream error:",e),Ie(!0),Pe(!1),et(!1)}};if(h)we(!0),null===(c=Ce.current)||void 0===c||c.blur(),xe(""),St(),We(i?"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."),mt.current.set(p.requestId,Date.now()),ft.current=p.requestId,u.startChatStream(p);r&&r(!1)}},kt=n.useRef(null);n.useLayoutEffect(function(){kt.current=wt});var Et=n.useCallback(function(){for(var t,n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];return null===(t=kt.current)||void 0===t?void 0:t.call.apply(t,e.__spreadArray([kt],n,!1))},[]),Mt=n.useMemo(function(){return{p:function(n){n.node;var a=n.children;return e.__rest(n,["node","children"]),t.jsx("div",e.__assign({style:{margin:0,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px",fontFamily:"inherit"}},{children:a}))},button:function(n){n.node;var a=n.className,s=n.children,i=e.__rest(n,["node","className","children"]),o=_.extractTextFromChildren(s),r=i["data-value"],l=Xe===o||Xe===r,u=!!Xe,d="Tester Genie"===o;return t.jsx(m.ActionableButton,e.__assign({},i,{className:a,handleStream:Et,isStreamEnd:Te,disabled:u,isLastMessage:!0,style:{margin:0},isTesterGenie:d,"data-selected":l?"true":Xe?"false":void 0},{children:t.jsxs("span",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[s,d&&t.jsxs("svg",e.__assign({width:"16",height:"20",viewBox:"0 0 16 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"})]}))]}))}))}}},[Et,Te,Xe]),Tt=n.useMemo(function(){return ye.some(function(e){return e.isSkeleton})},[ye]),It=function(t){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(n){switch(n.label){case 0:return ue?[4,ue(t)]:[3,2];case 1:n.sent(),be(function(t){return e.__spreadArray(e.__spreadArray([],t,!0),[{role:"assistant",content:"Thanks for your feedback — this will help improve future suggestions.",id:l.v4(),citations:[],time:new Date,isEnd:!0}],!1)}),setTimeout(function(){return St("smooth")},100),n.label=2;case 2:return[2]}})})};return console.log(ye,"rendering messages"),t.jsxs("div",e.__assign({className:"".concat(C.default.customFont," ").concat(g.default.chatContainer),style:{transition:"box-shadow 0.3s ease-in-out",boxShadow:ie&&!Tt?"0 0 20px 5px rgba(37, 99, 235, 0.5)":"none"}},{children:[t.jsxs("div",e.__assign({ref:me,className:g.default.scrollWrapper},{children:[t.jsx("div",e.__assign({ref:st,className:g.default.stickyHeader},{children:t.jsx(c.default,{resetChatHistory:function(){var e="".concat(ve,"/api/chat/resetHistory?name=").concat(de,"&organizationName=").concat(o);try{var t={method:"GET",params:{guestSessionId:ce.current},withCredentials:!0};E.default.get(e,t).then(function(){M(!0),qe(""),Ye(null),it.current.clear(),he.current="".concat(l.v4()),be([]),Ne(!0),null==z||z(),A&&A()}).catch(function(e){console.error(e)}).finally(function(){ce.current="".concat(de,"-").concat(o,"-").concat(l.v4())})}catch(e){we(!1),console.error(e)}},isStreamEnd:Te,chatTitle:L,onResize:K,chatSize:Z,movingTowards:O})})),t.jsxs("div",e.__assign({className:g.default.messagesList},{children:[t.jsxs("div",e.__assign({className:g.default.initialMessageRow},{children:[t.jsx("div",e.__assign({className:g.default.iconWrapper},{children:t.jsx(S.default,{})})),t.jsx("div",e.__assign({className:g.default.welcomeTextWrapper},{children:t.jsx("div",e.__assign({className:g.default.welcomeMarkdownWrapper},{children:t.jsx("span",{children:t.jsx(w.default,e.__assign({rehypePlugins:[k.default],components:Mt},{children:H}))})}))}))]})),ye.length>0&&ye.map(function(n,a){return t.jsxs("div",e.__assign({className:g.default.messageRow},{children:["assistant"===n.role?t.jsx("div",e.__assign({className:g.default.assistantIconContainer},{children:t.jsx(S.default,{})})):t.jsx("div",{className:g.default.userSpacer}),t.jsx("div",e.__assign({className:g.default.messageContent},{children:"assistant"===n.role?t.jsxs(t.Fragment,{children:[n.orchestratorAndAgentsMessages&&n.orchestratorAndAgentsMessages.length>0&&t.jsx(d.WatchMeWork,{orchestratorAndAgentsMessages:null==n?void 0:n.orchestratorAndAgentsMessages,isStreamEnd:Te,finalTimeTaken:null==n?void 0:n.finalTimeTaken},null==n?void 0:n.id),t.jsx(h.default,{index:a,content:null==n?void 0:n.content,role:null==n?void 0:n.role,messages:ye,handleStream:wt,isLastMessage:a===ye.length-1,onSave:U,citations:null==n?void 0:n.citations,setChatSize:K,chatSize:Z,isStreamEnd:Te,messageIsEnd:null==n?void 0:n.isEnd,onViewComparison:re,onTypeResponseClick:function(){var e;ct(!0),null===(e=Ce.current)||void 0===e||e.focus()},onComparisonLinkClick:le,baseURL:ve,onFeedbackSubmit:It}),t.jsx("div",e.__assign({className:g.default.timestamp},{children:n.time&&!isNaN(new Date(n.time).getTime())?new Date(n.time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}))]}):t.jsxs("div",e.__assign({className:g.default.userMessageWrapper},{children:[t.jsxs("div",e.__assign({className:g.default.userMessageBubble,style:{transition:"box-shadow 0.3s ease-in-out",boxShadow:n.isSkeleton||Tt||n.id!==rt?"none":"0 0 15px 3px rgba(37, 99, 235, 0.6)"}},{children:[n.isSkeleton?t.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"12px",minWidth:"280px",padding:"8px 0"}},{children:[t.jsx(v.Skeleton,{variant:"text",width:"100%",height:16}),t.jsx(v.Skeleton,{variant:"text",width:"80%",height:16})]})):t.jsx(h.default,{index:a,content:null==n?void 0:n.content,role:null==n?void 0:n.role,messages:ye,handleStream:wt,isLastMessage:a===ye.length-1,onSave:U,citations:null==n?void 0:n.citations,isStreamEnd:Te,messageIsEnd:null==n?void 0:n.isEnd,onViewComparison:re,onComparisonLinkClick:le,baseURL:ve,onFeedbackSubmit:It}),t.jsx("div",e.__assign({style:{marginTop:"0.5rem"}},{children:t.jsx(y.UserIcon,{})}))]})),t.jsx("div",e.__assign({className:g.default.userTimestamp},{children:new Date(n.time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}))]}))}))]}),n.id)}),je&&t.jsxs("div",e.__assign({className:g.default.loadingRow},{children:[t.jsx("div",e.__assign({className:g.default.iconWrapper,style:{marginTop:"0.2rem"}},{children:t.jsx(S.default,{})})),t.jsx("div",e.__assign({className:g.default.loadingTextWrapper},{children:t.jsx("span",{children:Fe})}))]})),t.jsx("div",{ref:ge,style:{float:"left",clear:"both"}})]}))]})),t.jsxs("div",e.__assign({className:g.default.inputAreaWrapper},{children:[ze&&t.jsxs(a.Box,e.__assign({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:[t.jsx("span",{children:"Instant Learning AI is thinking"}),t.jsx(a.Box,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(gt," 1.4s infinite ease-in-out both"),animationDelay:"-0.32s"}}),t.jsx(a.Box,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(gt," 1.4s infinite ease-in-out both"),animationDelay:"-0.16s"}}),t.jsx(a.Box,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(gt," 1.4s infinite ease-in-out both")}})]})),t.jsx(j.default,e.__assign({title:q?"Please wait for the validation to be completed.":""},{children:t.jsxs("div",e.__assign({className:"".concat(g.default.inputBoxContainer," ").concat(pt?g.default.disabled:""),style:dt?{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:[ye.length>0&&!Oe&&t.jsx("div",e.__assign({onMouseDown:function(e){e.preventDefault(),St("smooth")},className:g.default.scrollToBottomBtn},{children:t.jsx(p.ScrollToBottom,{})})),t.jsxs("div",e.__assign({style:{width:"100%",display:"flex"}},{children:[t.jsx("textarea",{ref:Ce,placeholder:J,value:_e||"",onChange:function(e){xe(e.target.value)},onFocus:function(){return Ze(!0)},onBlur:function(){return Ze(!1)},onKeyDown:function(e){return wt(e)},disabled:pt,className:"no-scrollbar ".concat(g.default.chatTextarea),style:{minHeight:Ue?"120px":"50px",height:Ue?"120px":"50px",maxHeight:"120px"}}),t.jsx("span",e.__assign({className:g.default.sendButtonWrapper},{children:t.jsx("button",e.__assign({onClick:function(e){wt(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:_t,className:"".concat(g.default.sendButton," ").concat(_t?g.default.disabled:g.default.active)},{children:t.jsx(x.SendButton,{})}))}))]}))]}))}))]})),t.jsxs("div",e.__assign({className:g.default.footerTools},{children:[t.jsx(j.default,e.__assign({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("span",e.__assign({className:g.default.footerToolItem},{children:t.jsx(f.default,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),t.jsx(j.default,e.__assign({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("span",e.__assign({className:g.default.footerToolItem},{children:t.jsx(f.default,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),a=require("@mui/material"),s=require("@mui/material/Tooltip"),i=require("react-markdown"),o=require("rehype-raw"),r=require("axios"),l=require("uuid"),u=require("@e-llm-studio/streaming-response"),d=require("@e-llm-studio/watch-me-work"),c=require("./ChatHeader.js"),h=require("../MessageRendering/MessageRendering.js"),v=require("../atoms/SkeletonLoader/SkeletonLoader.js"),m=require("../MessageRendering/ClickableChatComponents.js"),f=require("../AudioWaveform.js"),g=require("./ChatComponent.module.css.js"),C=require("../../InstantLearning.module.css.js"),p=require("../_svg/ScrollToBottom.js"),_=require("../../helpers/utils.js"),x=require("../_svg/SendButton.js"),S=require("../_svg/SparkleIcon.js"),y=require("../_svg/UserIcon.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var R,j=b(s),w=b(i),k=b(o),E=b(r);exports.default=function(s){var i=s.chatAssistantName,o=s.organizationName,r=s.baseUrl;s.baseWebsocketUrl;var b=s.setIsNewChatClicked;s.ThinkingBulbIconComponent;var M=s.isFormSaveClicked,T=s.setIsFormSavedClicked,I=s.onResetLearningData,A=s.sendMessageInChat,N=s.setSendMessageInChat,D=s.isFormValidating,q=s.chatTitle,L=s.customMetaData,F=s.headerMessageHandlers;s.aiResponse;var W=s.setAIResponse,B=s.onResetChat,P=s.initialChatMessage,z=void 0===P?"":P,H=s.onSave,U=s.chatSize,Z=s.setChatSize,K=s.movingTowards,O=s.setCitations,G=s.textareaPlaceholder,V=void 0===G?"Tell me more about this learning...":G,J=s.setCurrentRequestId,Q=s.showSavedMessage,X=void 0!==Q&&Q,Y=s.savedMessage,$=s.isError,ee=void 0!==$&&$,te=s.errorMessage,ne=void 0===te?"There was an error saving your changes.":te;s.isSaving;var ae=s.isHighlighted,se=void 0!==ae&&ae,ie=s.onStreamingStateChange,oe=s.onViewComparison;s.isCopyEnabled;var re=s.onComparisonLinkClick,le=s.onSubmitFeedback,ue=i,de=n.useRef("".concat(ue,"-").concat(o,"-").concat(l.v4())),ce=n.useRef("".concat(l.v4())),he=r,ve=n.useRef(null),me=n.useRef(!0),fe=n.useRef(null),ge=n.useRef(null),Ce=n.useState(""),pe=Ce[0],_e=Ce[1],xe=n.useState([]),Se=xe[0],ye=xe[1],be=n.useState(!1),Re=be[0],je=be[1],we=n.useState(!1);we[0];var ke=we[1],Ee=n.useState(!0),Me=Ee[0],Te=Ee[1],Ie=n.useState(!0);Ie[0];var Ae=Ie[1],Ne=n.useState("");Ne[0];var De=Ne[1],qe=n.useState(""),Le=qe[0],Fe=qe[1],We=n.useState(!1),Be=We[0],Pe=We[1],ze=n.useState(!1),He=ze[0],Ue=ze[1],Ze=n.useState(!0),Ke=Ze[0],Oe=Ze[1],Ge=n.useState("100%");Ge[0];var Ve=Ge[1],Je=n.useState(null),Qe=Je[0],Xe=Je[1],Ye=n.useState(!1);Ye[0];var $e=Ye[1],et=n.useState(!1),tt=et[0],nt=et[1],at=n.useRef(null),st=n.useRef(new Set),it=n.useState(null),ot=it[0],rt=it[1],lt=n.useState(!1),ut=lt[0],dt=lt[1],ct=n.useState(!1);ct[0],ct[1];var ht=n.useState(null);ht[0],ht[1],n.useRef(null),n.useRef(null);var vt=n.useRef(new Map),mt=n.useRef(""),ft=a.keyframes(R||(R=e.__makeTemplateObject(["\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 "]))),gt=n.useMemo(function(){return""===(null==pe?void 0:pe.trim())||Be},[pe,Be]),Ct=n.useMemo(function(){return D},[D]),pt=n.useMemo(function(){return gt||Be||D},[gt,Be,D]);n.useEffect(function(){null==ie||ie(Be)},[Be,ie]),n.useEffect(function(){var e=ve.current,t=function(){if(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;Oe(n-t-a<=20)}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}},[Se]);var _t=_.useHeaderObserver({handlers:F,setResult:W}).processHeaderMessage;n.useEffect(function(){X&&nt(!0)},[X]),n.useEffect(function(){if(ut){var e=setTimeout(function(){dt(!1)},3e3);return function(){return clearTimeout(e)}}},[ut]),n.useEffect(function(){M&&(jt(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save this Learning"),T(!1))},[M]),n.useEffect(function(){if(A)try{if(A.startsWith("__SKELETON__:")){var t=A.split(":"),n=t[1],a=t.slice(2).join(":"),s={role:"user",content:"",id:n,time:new Date,isSkeleton:!0,skeletonContent:a};return ye(function(t){return e.__spreadArray(e.__spreadArray([],t,!0),[s],!1)}),jt(new KeyboardEvent("keydown",{key:"Enter"}),!1,a,!1,n),rt(n),N&&N(""),void setTimeout(function(){rt(null)},2e3)}if(A.startsWith("__SKELETON_END__::")){var i=A.split("::")[1]||"";return ye(function(t){return t.map(function(t){return t.isSkeleton?e.__assign(e.__assign({},t),{isSkeleton:!1,content:t.skeletonContent||i}):t})}),void(N&&N(""))}var o=l.v4();jt(new KeyboardEvent("keydown",{key:"Enter"}),!1,A,!1,o),rt(o),N&&N(""),setTimeout(function(){return rt(null)},2e3)}catch(e){console.error("Error handling sendMessageInChat signal",e)}},[A]),n.useEffect(function(){St(),yt();var e=function(){var e,t=(null===(e=null==at?void 0:at.current)||void 0===e?void 0:e.clientHeight)||0,n="calc(100% - ".concat(t,"px - 10px)");Ve(n)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[]);var xt=n.useCallback(function(e){var t="string"==typeof e?e:"smooth";fe.current&&fe.current.scrollIntoView({behavior:t,block:"end"}),me.current&&setTimeout(function(){fe.current&&me.current&&fe.current.scrollIntoView({behavior:t,block:"end"})},100)},[]);n.useEffect(function(){if(!Be){var t="";if(tt?t=Y||"Thank you teacher for teaching me, your rule has been saved successfully.":ee&&(t=ne||"I'm sorry, I couldn't save your changes. Please try again."),t){var n={role:"assistant",content:t,id:l.v4(),citations:[],time:new Date};ye(function(t){return e.__spreadArray(e.__spreadArray([],t,!0),[n],!1)}),nt(!1),setTimeout(function(){return xt("smooth")},100)}}},[tt,ee,Be,Y,ne,xt]),n.useEffect(function(){me.current&&xt("smooth")},[xt]);var St=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(he,"/api/chatbot/getChatSettings?name=").concat(ue,"&organizationName=").concat(o),headers:{}};E.default.request(e).then(function(e){var t,n,a;(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.chatSettings)&&""!==(null===(a=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)||void 0===a?void 0:a.chatInitialMessage)&&Ae(!0)}).catch(function(e){console.error(e)})},yt=function(){return e.__awaiter(void 0,void 0,void 0,function(){var t,n;return e.__generator(this,function(e){t="".concat(he,"/api/chat/history?name=").concat(ue,"&organizationName=").concat(o);try{n={method:"GET",params:{guestSessionId:de.current},withCredentials:!0},E.default.get(t,n).then(function(e){var t=e.data;t.length>0?(ye(t),xt()):Ae(!0)}).catch(function(e){console.error(e)})}catch(e){je(!1),console.error(e)}return[2]})})};function bt(e){return null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,function(e){return null==e?void 0:e.replace(/\*/g,"&ast;")})}var Rt=function(t,n,a,s,i,o,r){var u,d,c,h,v,m,f,g,C,p,_,x,S,y,b,R,j,w,k,E,M,T,I,A,N,D,q,L,F,W,B,P,z,H;if(null===(d=null===(u=null==t?void 0:t.chatStream)||void 0===u?void 0:u.continueChatResult)||void 0===d?void 0:d.header_message){var U={header_message:t.chatStream.continueChatResult.header_message,responsedata:null===(v=null===(h=null===(c=null==t?void 0:t.chatStream)||void 0===c?void 0:c.continueChatResult)||void 0===h?void 0:h.message)||void 0===v?void 0:v.content};_t(U)}var Z=null===(m=null==t?void 0:t.chatStream)||void 0===m?void 0:m.continueChatResult,K=null==Z?void 0:Z.isEnd,G=(null===(f=null==Z?void 0:Z.message)||void 0===f?void 0:f.citations)||[];K&&G.length>0&&O&&O(G);var V={role:"assistant",content:"",id:l.v4()};if(null===(_=null===(p=null===(C=null===(g=null==t?void 0:t.chatStream)||void 0===g?void 0:g.continueChatResult)||void 0===C?void 0:C.message)||void 0===p?void 0:p.content)||void 0===_?void 0:_.includes("WaitMessage: "))ke(!0),V.content=function(e){var t="WaitMessage: ",n=e.indexOf(t);if(-1!==n){var a=e.substring(n+13);return null==a?void 0:a.replaceAll("WaitMessage: ","")}return""}((null===(y=null===(S=null===(x=null==t?void 0:t.chatStream)||void 0===x?void 0:x.continueChatResult)||void 0===S?void 0:S.message)||void 0===y?void 0:y.content)+"\n\n"),""!==V.content&&(je(!1),ye(e.__spreadArray(e.__spreadArray([],Se,!0),[{role:"user",content:i,time:s,isFirstQuestionSent:o||!1,id:r||(null===(R=null===(b=null==t?void 0:t.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===R?void 0:R.requestId)||"",reply:""},V],!1)));else{ke(!1),V.content=null===(E=bt(null===(k=null===(w=null===(j=null==t?void 0:t.chatStream)||void 0===j?void 0:j.continueChatResult)||void 0===w?void 0:w.message)||void 0===k?void 0:k.content))||void 0===E?void 0:E.replaceAll("WaitMessage: ","");var Q=null===(T=null===(M=null==t?void 0:t.chatStream)||void 0===M?void 0:M.continueChatResult)||void 0===T?void 0:T.requestId;"string"==typeof Q&&Q&&J&&J(Q);var X=function(t,n,a){var s,i,o,r,u,d,c,h,v,m,f,g,C,p,_,x,S,y,b,R,j,w,k,E,M,T,I,A,N,D,q,L,F,W,B={role:"assistant",content:"",id:l.v4(),time:new Date,citations:[]};if(!1===(null===(i=null===(s=t.chatStream)||void 0===s?void 0:s.continueChatResult)||void 0===i?void 0:i.thinking_break)&&!0===(null===(r=null===(o=t.chatStream)||void 0===o?void 0:o.continueChatResult)||void 0===r?void 0:r.is_orchestrator)&&!1===(null===(d=null===(u=t.chatStream)||void 0===u?void 0:u.continueChatResult)||void 0===d?void 0:d.isEnd)&&(B.content=bt(t.chatStream.continueChatResult.message.content||"")),!0===(null===(h=null===(c=t.chatStream)||void 0===c?void 0:c.continueChatResult)||void 0===h?void 0:h.thinking_break)&&!0===(null===(m=null===(v=t.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===m?void 0:m.is_orchestrator)&&!1===(null===(g=null===(f=t.chatStream)||void 0===f?void 0:f.continueChatResult)||void 0===g?void 0:g.isEnd)&&(B.content="",n.push({responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!1})),!1===(null===(p=null===(C=t.chatStream)||void 0===C?void 0:C.continueChatResult)||void 0===p?void 0:p.thinking_break)&&!0===(null===(x=null===(_=t.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===x?void 0:x.is_orchestrator)&&!0===(null===(y=null===(S=t.chatStream)||void 0===S?void 0:S.continueChatResult)||void 0===y?void 0:y.isEnd)&&(B.content=bt(t.chatStream.continueChatResult.message.content)),!1===(null===(R=null===(b=t.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===R?void 0:R.thinking_break)&&!1===(null===(w=null===(j=t.chatStream)||void 0===j?void 0:j.continueChatResult)||void 0===w?void 0:w.is_orchestrator)&&!1===(null===(E=null===(k=t.chatStream)||void 0===k?void 0:k.continueChatResult)||void 0===E?void 0:E.isEnd)){if((H=t.chatStream.continueChatResult).explainability_id&&H.responded_by){var P=H.explainability_id,z=H.responded_by;a.has(P)||a.set(P,{responded_by:z,index:n.length})}a.has(t.chatStream.continueChatResult.explainability_id)?n[null==(U=a.get(t.chatStream.continueChatResult.explainability_id))?void 0:U.index]={responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!0,explainability_id:null!==(M=t.chatStream.continueChatResult.explainability_id)&&void 0!==M?M:"",isParallelToolResponse:!0}:n=e.__spreadArray(e.__spreadArray([],n,!0),[{responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!0,explainability_id:null!==(T=t.chatStream.continueChatResult.explainability_id)&&void 0!==T?T:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(A=null===(I=t.chatStream)||void 0===I?void 0:I.continueChatResult)||void 0===A?void 0:A.thinking_break)&&!1===(null===(D=null===(N=t.chatStream)||void 0===N?void 0:N.continueChatResult)||void 0===D?void 0:D.is_orchestrator)&&!1===(null===(L=null===(q=t.chatStream)||void 0===q?void 0:q.continueChatResult)||void 0===L?void 0:L.isEnd)){var H,U;(H=t.chatStream.continueChatResult).explainability_id&&H.responded_by&&(P=H.explainability_id,z=H.responded_by,a.has(P)||a.set(P,{responded_by:z,index:n.length})),a.has(t.chatStream.continueChatResult.explainability_id)?n[null==(U=a.get(t.chatStream.continueChatResult.explainability_id))?void 0:U.index]={responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!1,explainability_id:null!==(F=t.chatStream.continueChatResult.explainability_id)&&void 0!==F?F:"",isParallelToolResponse:!0}:n.push({responsedata:t.chatStream.continueChatResult.message.content,responseFrom:t.chatStream.continueChatResult.responded_by,header_message:t.chatStream.continueChatResult.header_message,finalResponseStatus:!1,explainability_id:null!==(W=t.chatStream.continueChatResult.explainability_id)&&void 0!==W?W:"",isParallelToolResponse:!1})}return e.__assign({orchestratorAndAgentsMessages:n},B)}(t,a,n);X.time=new Date,X.citations=G,X.isEnd=null===(A=null===(I=null==t?void 0:t.chatStream)||void 0===I?void 0:I.continueChatResult)||void 0===A?void 0:A.isEnd,X.requestId=null===(D=null===(N=null==t?void 0:t.chatStream)||void 0===N?void 0:N.continueChatResult)||void 0===D?void 0:D.requestId,X.sessionId=de.current,null===(q=X.orchestratorAndAgentsMessages)||void 0===q||q.forEach(function(e){e&&e.header_message&&_t(e)}),(""!==(null==X?void 0:X.content)||(null==X?void 0:X.orchestratorAndAgentsMessages)&&(null==X?void 0:X.orchestratorAndAgentsMessages.length)>0)&&(je(!1),ye(e.__spreadArray(e.__spreadArray([],Se,!0),[{role:"user",content:i||"",time:s,isFirstQuestionSent:o||!1,id:r||(null===(F=null===(L=null==t?void 0:t.chatStream)||void 0===L?void 0:L.continueChatResult)||void 0===F?void 0:F.requestId)||"",requestId:null!==(P=null===(B=null===(W=null==t?void 0:t.chatStream)||void 0===W?void 0:W.continueChatResult)||void 0===B?void 0:B.requestId)&&void 0!==P?P:""},X],!1))),Te(null===(H=null===(z=null==t?void 0:t.chatStream)||void 0===z?void 0:z.continueChatResult)||void 0===H?void 0:H.isEnd)}},jt=function(t,n,a,s,i,d){var c,h,v=(void 0!==a?a:pe||"").trim(),m="Enter"===(null==t?void 0:t.key)&&!(null==t?void 0:t.shiftKey);if(m&&(null===(c=null==t?void 0:t.preventDefault)||void 0===c||c.call(t)),!(!v||Be&&!a||(null==t?void 0:t.key)&&!m)){if("I want to add a rule description"===v){Te(!1),me.current=!0,Pe(!0),!Qe&&v&&Xe(a||"manual_entry");var f=new Date;return ye(function(t){return e.__spreadArray(e.__spreadArray([],t.map(function(t,n){var a;return e.__assign(e.__assign({},t),{content:null===(a=bt(t.content))||void 0===a?void 0:a.replace("WaitMessage: ","")})}),!0),[{role:"user",content:v,time:f,isFirstQuestionSent:!1,id:i||l.v4()}],!1)}),xt("smooth"),void setTimeout(function(){ye(function(t){return e.__spreadArray(e.__spreadArray([],t,!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:l.v4(),citations:[],time:new Date}],!1)}),xt("smooth"),setTimeout(function(){Pe(!1),Te(!0)},500)},500)}Te(!1),me.current=!0,Pe(!0),!Qe&&v&&Xe(a||"manual_entry");var g=new Date;ye(function(t){var n=t.map(function(t){var n;return e.__assign(e.__assign({},t),{content:null===(n=bt(t.content))||void 0===n?void 0:n.replace("WaitMessage: ","")})});return i&&n.some(function(e){return e.id===i})?n.map(function(t){return t.id===i?e.__assign(e.__assign({},t),{content:v}):t}):e.__spreadArray(e.__spreadArray([],n,!0),[{role:"user",content:v,time:g,isFirstQuestionSent:!1,id:i||l.v4()}],!1)}),xt("smooth");var C=new Map,p=[],_={API_URL:r,organizationName:o,chatAssistantName:ue,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:v,requestId:"requestId-".concat(l.v4()),customPrompt:"",enableForBackend:!1,guestSessionId:de.current,chatPreviewId:ce.current,customMetaData:L,aiModel:"",onStreamEvent:function(e){return Rt(e,C,p,g,v,n,i)},onStreamEnd:function(t){Te(!0),Pe(!1),$e(!1);var n=Date.now(),a=vt.current.get(mt.current);if(a){var s=Math.round((n-a)/1e3).toFixed(1);ye(function(t){var n=e.__spreadArray([],t,!0).reverse().findIndex(function(e){return"assistant"===e.role});if(-1===n)return t;var a=t.length-1-n;return t.map(function(t,n){return n===a?e.__assign(e.__assign({},t),{finalTimeTaken:s}):t})})}},onError:function(e){console.error("Stream error:",e),Te(!0),Pe(!1),$e(!1)}};if(v)je(!0),null===(h=ge.current)||void 0===h||h.blur(),_e(""),xt(),Fe(i?"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."),vt.current.set(_.requestId,Date.now()),mt.current=_.requestId,u.startChatStreamSSE(_);d&&d(!1)}},wt=n.useRef(null);n.useLayoutEffect(function(){wt.current=jt});var kt=n.useCallback(function(){for(var t,n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];return null===(t=wt.current)||void 0===t?void 0:t.call.apply(t,e.__spreadArray([wt],n,!1))},[]),Et=n.useMemo(function(){return{p:function(n){n.node;var a=n.children;return e.__rest(n,["node","children"]),t.jsx("div",e.__assign({style:{margin:0,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px",fontFamily:"inherit"}},{children:a}))},button:function(n){n.node;var a=n.className,s=n.children,i=e.__rest(n,["node","className","children"]),o=_.extractTextFromChildren(s),r=i["data-value"],l=Qe===o||Qe===r,u=!!Qe,d="Tester Genie"===o;return t.jsx(m.ActionableButton,e.__assign({},i,{className:a,handleStream:kt,isStreamEnd:Me,disabled:u,isLastMessage:!0,style:{margin:0},isTesterGenie:d,"data-selected":l?"true":Qe?"false":void 0},{children:t.jsxs("span",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[s,d&&t.jsxs("svg",e.__assign({width:"16",height:"20",viewBox:"0 0 16 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"}),t.jsx("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"})]}))]}))}))}}},[kt,Me,Qe]),Mt=n.useMemo(function(){return Se.some(function(e){return e.isSkeleton})},[Se]),Tt=function(t){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(n){switch(n.label){case 0:return le?[4,le(t)]:[3,2];case 1:n.sent(),ye(function(t){return e.__spreadArray(e.__spreadArray([],t,!0),[{role:"assistant",content:"Thanks for your feedback — this will help improve future suggestions.",id:l.v4(),citations:[],time:new Date,isEnd:!0}],!1)}),setTimeout(function(){return xt("smooth")},100),n.label=2;case 2:return[2]}})})};return console.log(Se,"rendering messages"),t.jsxs("div",e.__assign({className:"".concat(C.default.customFont," ").concat(g.default.chatContainer),style:{transition:"box-shadow 0.3s ease-in-out",boxShadow:se&&!Mt?"0 0 20px 5px rgba(37, 99, 235, 0.5)":"none"}},{children:[t.jsxs("div",e.__assign({ref:ve,className:g.default.scrollWrapper},{children:[t.jsx("div",e.__assign({ref:at,className:g.default.stickyHeader},{children:t.jsx(c.default,{resetChatHistory:function(){var e="".concat(he,"/api/chat/resetHistory?name=").concat(ue,"&organizationName=").concat(o);try{var t={method:"GET",params:{guestSessionId:de.current},withCredentials:!0};E.default.get(e,t).then(function(){b(!0),De(""),Xe(null),st.current.clear(),ce.current="".concat(l.v4()),ye([]),Ae(!0),null==B||B(),I&&I()}).catch(function(e){console.error(e)}).finally(function(){de.current="".concat(ue,"-").concat(o,"-").concat(l.v4())})}catch(e){je(!1),console.error(e)}},isStreamEnd:Me,chatTitle:q,onResize:Z,chatSize:U,movingTowards:K})})),t.jsxs("div",e.__assign({className:g.default.messagesList},{children:[t.jsxs("div",e.__assign({className:g.default.initialMessageRow},{children:[t.jsx("div",e.__assign({className:g.default.iconWrapper},{children:t.jsx(S.default,{})})),t.jsx("div",e.__assign({className:g.default.welcomeTextWrapper},{children:t.jsx("div",e.__assign({className:g.default.welcomeMarkdownWrapper},{children:t.jsx("span",{children:t.jsx(w.default,e.__assign({rehypePlugins:[k.default],components:Et},{children:z}))})}))}))]})),Se.length>0&&Se.map(function(n,a){return t.jsxs("div",e.__assign({className:g.default.messageRow},{children:["assistant"===n.role?t.jsx("div",e.__assign({className:g.default.assistantIconContainer},{children:t.jsx(S.default,{})})):t.jsx("div",{className:g.default.userSpacer}),t.jsx("div",e.__assign({className:g.default.messageContent},{children:"assistant"===n.role?t.jsxs(t.Fragment,{children:[n.orchestratorAndAgentsMessages&&n.orchestratorAndAgentsMessages.length>0&&t.jsx(d.WatchMeWork,{orchestratorAndAgentsMessages:null==n?void 0:n.orchestratorAndAgentsMessages,isStreamEnd:Me,finalTimeTaken:null==n?void 0:n.finalTimeTaken},null==n?void 0:n.id),t.jsx(h.default,{index:a,content:null==n?void 0:n.content,role:null==n?void 0:n.role,messages:Se,handleStream:jt,isLastMessage:a===Se.length-1,onSave:H,citations:null==n?void 0:n.citations,setChatSize:Z,chatSize:U,isStreamEnd:Me,messageIsEnd:null==n?void 0:n.isEnd,onViewComparison:oe,onTypeResponseClick:function(){var e;dt(!0),null===(e=ge.current)||void 0===e||e.focus()},onComparisonLinkClick:re,baseURL:he,onFeedbackSubmit:Tt}),t.jsx("div",e.__assign({className:g.default.timestamp},{children:n.time&&!isNaN(new Date(n.time).getTime())?new Date(n.time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}))]}):t.jsxs("div",e.__assign({className:g.default.userMessageWrapper},{children:[t.jsxs("div",e.__assign({className:g.default.userMessageBubble,style:{transition:"box-shadow 0.3s ease-in-out",boxShadow:n.isSkeleton||Mt||n.id!==ot?"none":"0 0 15px 3px rgba(37, 99, 235, 0.6)"}},{children:[n.isSkeleton?t.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"12px",minWidth:"280px",padding:"8px 0"}},{children:[t.jsx(v.Skeleton,{variant:"text",width:"100%",height:16}),t.jsx(v.Skeleton,{variant:"text",width:"80%",height:16})]})):t.jsx(h.default,{index:a,content:null==n?void 0:n.content,role:null==n?void 0:n.role,messages:Se,handleStream:jt,isLastMessage:a===Se.length-1,onSave:H,citations:null==n?void 0:n.citations,isStreamEnd:Me,messageIsEnd:null==n?void 0:n.isEnd,onViewComparison:oe,onComparisonLinkClick:re,baseURL:he,onFeedbackSubmit:Tt}),t.jsx("div",e.__assign({style:{marginTop:"0.5rem"}},{children:t.jsx(y.UserIcon,{})}))]})),t.jsx("div",e.__assign({className:g.default.userTimestamp},{children:new Date(n.time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}))]}))}))]}),n.id)}),Re&&t.jsxs("div",e.__assign({className:g.default.loadingRow},{children:[t.jsx("div",e.__assign({className:g.default.iconWrapper,style:{marginTop:"0.2rem"}},{children:t.jsx(S.default,{})})),t.jsx("div",e.__assign({className:g.default.loadingTextWrapper},{children:t.jsx("span",{children:Le})}))]})),t.jsx("div",{ref:fe,style:{float:"left",clear:"both"}})]}))]})),t.jsxs("div",e.__assign({className:g.default.inputAreaWrapper},{children:[Be&&t.jsxs(a.Box,e.__assign({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:[t.jsx("span",{children:"Instant Learning AI is thinking"}),t.jsx(a.Box,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(ft," 1.4s infinite ease-in-out both"),animationDelay:"-0.32s"}}),t.jsx(a.Box,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(ft," 1.4s infinite ease-in-out both"),animationDelay:"-0.16s"}}),t.jsx(a.Box,{sx:{width:"5px",height:"5px",bgcolor:"#6b7280",borderRadius:"50%",animation:"".concat(ft," 1.4s infinite ease-in-out both")}})]})),t.jsx(j.default,e.__assign({title:D?"Please wait for the validation to be completed.":""},{children:t.jsxs("div",e.__assign({className:"".concat(g.default.inputBoxContainer," ").concat(Ct?g.default.disabled:""),style:ut?{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:[Se.length>0&&!Ke&&t.jsx("div",e.__assign({onMouseDown:function(e){e.preventDefault(),xt("smooth")},className:g.default.scrollToBottomBtn},{children:t.jsx(p.ScrollToBottom,{})})),t.jsxs("div",e.__assign({style:{width:"100%",display:"flex"}},{children:[t.jsx("textarea",{ref:ge,placeholder:V,value:pe||"",onChange:function(e){_e(e.target.value)},onFocus:function(){return Ue(!0)},onBlur:function(){return Ue(!1)},onKeyDown:function(e){return jt(e)},disabled:Ct,className:"no-scrollbar ".concat(g.default.chatTextarea),style:{minHeight:He?"120px":"50px",height:He?"120px":"50px",maxHeight:"120px"}}),t.jsx("span",e.__assign({className:g.default.sendButtonWrapper},{children:t.jsx("button",e.__assign({onClick:function(e){jt(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:pt,className:"".concat(g.default.sendButton," ").concat(pt?g.default.disabled:g.default.active)},{children:t.jsx(x.SendButton,{})}))}))]}))]}))}))]})),t.jsxs("div",e.__assign({className:g.default.footerTools},{children:[t.jsx(j.default,e.__assign({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("span",e.__assign({className:g.default.footerToolItem},{children:t.jsx(f.default,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),t.jsx(j.default,e.__assign({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("span",e.__assign({className:g.default.footerToolItem},{children:t.jsx(f.default,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))};
2
2
  //# sourceMappingURL=NormalChat.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),e=require("react/jsx-runtime"),t=require("react"),n=require("../../InputDataReasoningCard.js"),o=require("../../organisms/ConditionSection/ConditionSection.js"),l=require("../../organisms/ConfigSection/ConfigSection.js"),a=require("../../organisms/ScopeSection/ScopeSection.js"),r=require("../../organisms/TextSection/TextSection.js"),s=require("../../AccordianSection.js"),d=require("../../_svg/ButtonCognitiveIcon.js"),c=require("lucide-react");function u(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var v=u(t),p=function(t){var n=t.children,o=t.onAddVariant,l=t.isDisabled,a=v.default.Children.toArray(n);return e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[a.map(function(i,t){return e.jsxs(v.default.Fragment,{children:[i,e.jsx("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},t)}),e.jsx("div",i.__assign({onClick:l?void 0:o,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:l?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:l?"not-allowed":"pointer",backgroundColor:l?"#f8fafc":"#FFFFFF",opacity:l?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))};exports.CreateRule=function(u){var g,f,h,x,y,_,S,D,T,m,C,I=u.state,j=u.handlers,A=u.uiState,b=(null==A?void 0:A.highlights)||new Map,E=b.get("global_0")||{},O=t.useState({}),w=O[0],R=O[1],V=t.useState(null),N=V[0],W=V[1],q="rule-setup"===(null==A?void 0:A.activeEditId),M=v.default.useRef(new Map),F=t.useState({title:"",scope:{}}),k=F[0],B=F[1],L=t.useState(!1),P=L[0],z=L[1],J=v.default.useRef(null==A?void 0:A.isAiStreaming);t.useEffect(function(){q||P||B({title:I.ruleTitle,scope:I.scopeData})},[I.ruleTitle,I.scopeData,q,P]),t.useEffect(function(){var i;if(J.current&&!(null==A?void 0:A.isAiStreaming)&&P&&(z(!1),null===(i=null==A?void 0:A.setActiveEditId)||void 0===i||i.call(A,null),null==A?void 0:A.setSendMessageInChat)){var e=I.ruleTitle!==k.title,t=JSON.stringify(I.scopeData)!==JSON.stringify(k.scope),n=[];if(e&&n.push("Title with ".concat(I.ruleTitle)),t){var o=[];I.scopeData.station&&o.push(I.scopeData.station),I.scopeData.tiers&&I.scopeData.tiers.length>0&&o.push(I.scopeData.tiers.join(", ")),n.push("Scope with ".concat(o.join(", ")))}var l=n.join(" and ");A.setSendMessageInChat("__SKELETON_END__::Update Rule Setup using ".concat(l))}J.current=null==A?void 0:A.isAiStreaming},[null==A?void 0:A.isAiStreaming,P,I,k]);var H=function(){var i;j.setRuleTitle(k.title),k.scope.station!==I.scopeData.station&&j.onScopeChange("station",k.scope.station),JSON.stringify(k.scope.tiers)!==JSON.stringify(I.scopeData.tiers)&&j.onScopeChange("tiers",k.scope.tiers),null===(i=null==A?void 0:A.setActiveEditId)||void 0===i||i.call(A,null)},K=function(){var i,e,t=I.ruleTitle!==k.title,n=JSON.stringify(I.scopeData)!==JSON.stringify(k.scope);if(t||n){if(z(!0),null==A?void 0:A.setSendMessageInChat){var o="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),l=[];if(t){var a=(null===(e=I.ruleTitle)||void 0===e?void 0:e.trim())?"Title with ".concat(I.ruleTitle):"No Title";l.push(a)}if(n){var r=[];I.scopeData.station&&r.push("station: ".concat(I.scopeData.station)),I.scopeData.tiers&&I.scopeData.tiers.length>0&&r.push("tiers: ".concat(I.scopeData.tiers.join(", ")));var s=r.length>0?"with ".concat(r.join(" and ")):"No Tier Selected";l.push(s)}var d=l.join(" and ");A.setSendMessageInChat("__SKELETON__:".concat(o,":Update Rule Setup ").concat(d))}}else null===(i=null==A?void 0:A.setActiveEditId)||void 0===i||i.call(A,null)},U=v.default.useRef(null==A?void 0:A.defaultVariantOpen),$=v.default.useRef(I.variantsByTier);v.default.useEffect(function(){var i,e,t,n,o=null,l=!1;if(U.current!==(null==A?void 0:A.defaultVariantOpen)&&(l=!0,U.current=null==A?void 0:A.defaultVariantOpen),I.variantsByTier,$.current,l){if(null==(null==A?void 0:A.defaultVariantOpen)||(null==A?void 0:A.defaultVariantOpen)<0)return W(null),void($.current=I.variantsByTier);null===(e=null===(i=null==A?void 0:A.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,t;return null===(t=null===(e=I.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=I.variantsByTier)||void 0===e?void 0:e[t])||[]).forEach(function(i,e){(null==A?void 0:A.defaultVariantOpen)===e&&(o="".concat(t,"-variant-").concat(e)),(null==A?void 0:A.autoScrollVariantIndex)===e&&(o="".concat(t,"-variant-").concat(e))})}),o&&W(o)}null===N&&(null==A?void 0:A.defaultVariantOpen)>=0&&(null===(n=null===(t=null==A?void 0:A.tierOptions)||void 0===t?void 0:t.filter(function(i){var e,t;return null===(t=null===(e=I.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=I.variantsByTier)||void 0===e?void 0:e[t])||[])[A.defaultVariantOpen]&&W("".concat(t,"-variant-").concat(A.defaultVariantOpen))})),$.current=I.variantsByTier},[I.variantsByTier,null==A?void 0:A.defaultVariantOpen,null===(g=I.scopeData)||void 0===g?void 0:g.tiers,null==A?void 0:A.tierOptions,null==A?void 0:A.autoScrollVariantIndex]);var Z=function(e){R(function(t){var n;return i.__assign(i.__assign({},t),((n={})[e]=!t[e],n))})},G=function(i){var e,t=null===(e=I.fieldCitations)||void 0===e?void 0:e[i];return Array.isArray(t)&&t.length>0?t:I.citations},Q={marginTop:"-17px",position:"relative",zIndex:1};v.default.useCallback(function(i){i&&requestAnimationFrame(function(){setTimeout(function(){i.scrollIntoView({behavior:"smooth",block:"center"})},300)})},[]),t.useEffect(function(){var i,e;null!=(null==A?void 0:A.autoScrollVariantIndex)&&(null===(e=null===(i=null==A?void 0:A.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,t;return null===(t=null===(e=I.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(A.autoScrollVariantIndex),n=M.current.get(t);n&&requestAnimationFrame(function(){setTimeout(function(){n.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==A?void 0:A.scrollTrigger]),console.log("CreateRule state:",I),console.log("CreateRule uiState:",A);var X=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"},Y=!!(null==A?void 0:A.activeEditId);return e.jsxs("div",i.__assign({className:"traffic-manager-template"},{children:[e.jsx("div",i.__assign({"data-edit-id":"rule-setup"},{children:e.jsx(s.default,i.__assign({title:{type:"other",label:(null==A?void 0:A.setupLabel)||"Rule Setup"},actionButtons:function(t,n){if(q)return null;var o=!!(null==A?void 0:A.activeEditId)&&"rule-setup"!==A.activeEditId;return e.jsx("div",i.__assign({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:e.jsx("button",i.__assign({title:o?"Save active edits first":"Edit",onClick:function(i){i.stopPropagation(),o?(null==A?void 0:A.setPendingEditId)&&A.setPendingEditId(A.activeEditId||null):(!function(){var i;(null==A?void 0:A.activeEditId)&&"rule-setup"!==A.activeEditId||(null===(i=null==A?void 0:A.setActiveEditId)||void 0===i||i.call(A,"rule-setup"),B({title:I.ruleTitle,scope:I.scopeData}))}(),(null==A?void 0:A.setPendingEditId)&&A.setPendingEditId(null),t||n())},disabled:P,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:P?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:P?.5:1}},{children:e.jsx(c.Pencil,{size:14})}))}))},footerData:{ruleTitle:I.ruleTitle,stations:[I.scopeData.station],tiers:null===(f=I.scopeData)||void 0===f?void 0:f.tiers},defaultOpen:"Create"===(null==A?void 0:A.usedFor),readOnly:"Create"!==(null==A?void 0:A.usedFor),isAiStreaming:null==A?void 0:A.isAiStreaming,editFlow:"Edit"===(null==A?void 0:A.usedFor)},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[P&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[e.jsx(c.Loader2Icon,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),e.jsx(r.TextSection,i.__assign({id:"rule-title",title:A.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:I.ruleTitle,onChange:j.setRuleTitle,readOnly:"Create"!==(null==A?void 0:A.usedFor)||(null==A?void 0:A.isAiStreaming)||!q,isOpen:w.ruleTitle,onToggle:function(){return Z("ruleTitle")},isHighlighted:E.ruleTitle||!1,showCognitiveIcon:I.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(h=A.validationErrors)||void 0===h?void 0:h.ruleTitle},A)),I.citation.ruleTitle&&e.jsx("div",i.__assign({style:Q},{children:e.jsx(n.InputDataReasoningCard,{isVisible:w.ruleTitle,citation:I.citation.ruleTitle,citations:G("ruleTitle"),fieldName:"Rule Title",fieldValue:I.ruleTitle})})),e.jsx(a.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:I.scopeData,onScopeChange:j.onScopeChange,tierLabel:"Which tiers should this learning apply to?",stationLabel:"Which scope should this learning belong to?",highlights:E,isOpen:w.scopeData,onToggle:function(){return Z("scopeData")},showCognitiveIcon:I.citation.scopeData,cognitiveIcon:e.jsx(d.ButtonCognitiveIcon,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(x=A.validationErrors)||void 0===x?void 0:x.station)||(null===(y=A.validationErrors)||void 0===y?void 0:y.tiers),stationErrorMessage:null===(_=A.validationErrors)||void 0===_?void 0:_.station,tierErrorMessage:null===(S=A.validationErrors)||void 0===S?void 0:S.tiers,readOnly:"Create"!==(null==A?void 0:A.usedFor)||(null==A?void 0:A.isAiStreaming)||!q},A)),I.citation.scopeData&&e.jsx("div",i.__assign({style:Q},{children:e.jsx(n.InputDataReasoningCard,{isVisible:w.scopeData,citation:I.citation.scopeData,citations:G("scopeData"),fieldName:"Scope",fieldValue:null===(T=null===(D=I.scopeData)||void 0===D?void 0:D.tiers)||void 0===T?void 0:T.join(", ")})})),!q||P?null:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e.jsxs("div",i.__assign({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[e.jsx("button",i.__assign({onClick:H,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e.jsxs("button",i.__assign({onClick:K,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:[e.jsx(c.Check,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==A?void 0:A.pendingEditId)&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"8px"}},{children:[e.jsx(c.AlertTriangle,{style:{color:"#C2410C"}}),e.jsx("div",i.__assign({style:{display:"flex",color:"#C2410C",fontSize:"13px",paddingTop:"8px",alignItems:"center"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]}))]}))}))})),null===(C=null===(m=null==A?void 0:A.tierOptions)||void 0===m?void 0:m.filter(function(i){var e,t;return null===(t=null===(e=I.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===C?void 0:C.map(function(t,a,d){var c,u,v,g,f=t.toLowerCase().replace(/ /g,"_"),h=(null===(c=I.variantsByTier)||void 0===c?void 0:c[f])||[],x=h.length,y=!1;if(1===x){var _=h[0],S=!(null===(u=null==_?void 0:_.ruleDescription)||void 0===u?void 0:u.trim()),D=(null===(v=null==_?void 0:_.whenToApplyConditions)||void 0===v?void 0:v.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,T=(null===(g=null==_?void 0:_.whenNotToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;S&&!D&&!T&&(y=!0)}var m=y?void 0:"".concat(x," ").concat(1===x?"variant":"variants"," configured for this tier"),C=!((null==A?void 0:A.defaultTierOpen)>=0)||a===A.defaultTierOpen;return console.log("Rendering tier : ",t),e.jsx(s.default,i.__assign({variant:"tier-header",title:{type:"other",label:t},subtitle:m,defaultOpen:C,footerData:{description:"Variants for ".concat(t)}},{children:e.jsx(p,i.__assign({onAddVariant:function(){var i;return null===(i=j.addNewVariant)||void 0===i?void 0:i.call(j,f)},isDisabled:null==A?void 0:A.isAiStreaming},{children:h.map(function(t,a){var d,c,u,v,p,g,h,x,y,_,S,D=t.variantType||"default",T="".concat(f,"-variant-").concat(a),m=!0===t.is_variant,C="default"===D||"default_variant"===D;(null==A?void 0:A.defaultVariantOpen)>=0&&A.defaultVariantOpen;var I="".concat(f,"_").concat(a),E=b.get(I)||{},O=(null===(c=null===(d=A.separationItemsByTier)||void 0===d?void 0:d[f])||void 0===c?void 0:c.get(a))||[],R=(null===(v=null===(u=A.togglesByTier)||void 0===u?void 0:u[f])||void 0===v?void 0:v.get(a))||[];(null==A?void 0:A.autoScrollVariantIndex)===a||t.is_variant,console.log("Rendering ".concat(f," variant ").concat(a,":"),t),console.log("Rendering Variant : ",t),console.log("Open Accordion ID:",N,"Current Variant ID:",T);var V=null===(p=null==A?void 0:A.activeEditId)||void 0===p?void 0:p.startsWith("condition-wta-".concat(f,"-").concat(a)),q=null===(g=null==A?void 0:A.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(f,"-").concat(a));return e.jsx("div",i.__assign({ref:function(i){i?M.current.set(T,i):M.current.delete(T)},style:{width:"100%"}},{children:e.jsx(s.default,i.__assign({title:{type:C?"default":"variant",label:X(D),number:a+1,isNewVariant:m,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:N===T,onToggle:function(){var i,e=N===T;console.log("is closing:",e),W(e?null:T),null===(i=null==A?void 0:A.setActiveVariantAccordionIndex)||void 0===i||i.call(A,e?null:a)},variant:"rule-behavior",footerData:{ruleTitle:D,description:t.ruleDescription||""}},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[e.jsx(r.TextSection,i.__assign({id:"rule-description-".concat(f,"-").concat(a),title:A.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:t.isReadOnly||(null==A?void 0:A.isAiStreaming)||Y&&(null==A?void 0:A.activeEditId)!=="rule-description-".concat(f,"-").concat(a),value:t.ruleDescription||"",onChange:function(i){return j.setRuleDescription(f,a,i)},isOpen:w["ruleDescription-".concat(f,"-").concat(a)],onToggle:function(){return Z("ruleDescription-".concat(f,"-").concat(a))},isHighlighted:E.ruleDescription||!1,showCognitiveIcon:null===(h=t.reasoning)||void 0===h?void 0:h.ruleDescription,tooltipDescription:"Why this Description?",errorMessage:null===(x=A.validationErrors)||void 0===x?void 0:x["ruleDescription-".concat(f,"-").concat(a)],enableInlineEdit:!0,setSendMessageInChat:null==A?void 0:A.setSendMessageInChat,isAiStreaming:null==A?void 0:A.isAiStreaming,fieldName:"Rule Description"},A)),(null===(y=t.reasoning)||void 0===y?void 0:y.ruleDescription)&&e.jsx("div",i.__assign({style:Q},{children:e.jsx(n.InputDataReasoningCard,{isVisible:w["ruleDescription-".concat(f,"-").concat(a)],citation:t.reasoning.ruleDescription,citations:G("ruleDescription_".concat(f,"_").concat(a)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),e.jsx(o.ConditionSection,i.__assign({id:"when-to-apply-".concat(f,"-").concat(a),idPrefix:"condition-wta",title:A.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:t.isReadOnly||(null==A?void 0:A.isAiStreaming)||Y&&!V,conditions:t.whenToApplyConditions||[],onAdd:function(){return j.addWhenToApply(f,a)},onRemove:function(i,e,t){return j.removeWhenToApply(i,e,t)},onEdit:function(i,e,t,n){return j.editWhenToApply(i,e,t,n)},index:a,tierKey:f,isHighlighted:E.wta||!1,highlightedIds:null==A?void 0:A.highlightedIds,tooltipDescription:"Why this Condition?",citations:G("whenToApply_".concat(f,"_").concat(a)),bordered:!0,addLabel:"Add When to apply",isAiStreaming:A.isAiStreaming,errorMessage:(null===(_=A.validationErrors)||void 0===_?void 0:_["whenToApply-".concat(f,"-").concat(a)])||(null==A?void 0:A.conflictReason)},A)),e.jsx(o.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(f,"-").concat(a),idPrefix:"condition-wnta",title:A.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:t.isReadOnly||(null==A?void 0:A.isAiStreaming)||Y&&!q,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return j.addWhenNotToApply(f,a)},onRemove:function(i,e,t){return j.removeWhenNotToApply(i,e,t)},onEdit:function(i,e,t,n){return j.editWhenNotToApply(i,e,t,n)},index:a,tierKey:f,isHighlighted:E.wnta||!1,highlightedIds:null==A?void 0:A.highlightedIds,tooltipDescription:"Why this Condition?",citations:G("whenNotToApply_".concat(f,"_").concat(a)),bordered:!0,addLabel:"Add When NOT to apply",isAiStreaming:A.isAiStreaming},A)),e.jsx(l.ConfigSection,i.__assign({id:"config-".concat(f,"-").concat(a),title:A.configTitle||"Configuration",required:!1,highlights:E,bordered:!0,readOnly:t.isReadOnly||(null==A?void 0:A.isAiStreaming)||Y,onConfigChange:function(i,e){return j.onConfigChange(f,a,i,e)},separationItems:O,toggles:R,index:a},A)),(null===(S=t.reasoning)||void 0===S?void 0:S.configData)&&e.jsx("div",i.__assign({style:Q},{children:e.jsx(n.InputDataReasoningCard,{citation:t.reasoning.configData,citations:G("configData_".concat(f,"_").concat(a)),fieldName:"Configuration",fieldValue:"Proposed Configuration"})}))]}))}),T)}),"".concat(f,"-variant-").concat(a))})}))}),"tier-".concat(a))})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),e=require("react/jsx-runtime"),t=require("react"),n=require("../../InputDataReasoningCard.js"),o=require("../../organisms/ConditionSection/ConditionSection.js"),l=require("../../organisms/ConfigSection/ConfigSection.js"),a=require("../../organisms/ScopeSection/ScopeSection.js"),r=require("../../organisms/TextSection/TextSection.js"),s=require("../../AccordianSection.js"),d=require("../../_svg/ButtonCognitiveIcon.js"),c=require("lucide-react");function u(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var v=u(t),p=function(t){var n=t.children,o=t.onAddVariant,l=t.isDisabled,a=v.default.Children.toArray(n);return e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[a.map(function(i,t){return e.jsxs(v.default.Fragment,{children:[i,e.jsx("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},t)}),e.jsx("div",i.__assign({onClick:l?void 0:o,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:l?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:l?"not-allowed":"pointer",backgroundColor:l?"#f8fafc":"#FFFFFF",opacity:l?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))};exports.CreateRule=function(u){var g,f,h,x,y,_,S,D,T,m,C,I=u.state,j=u.handlers,A=u.uiState,b=(null==A?void 0:A.highlights)||new Map,E=b.get("global_0")||{},O=t.useState({}),w=O[0],R=O[1],V=t.useState(null),N=V[0],W=V[1],q="rule-setup"===(null==A?void 0:A.activeEditId),M=v.default.useRef(new Map),F=t.useState({title:"",scope:{}}),k=F[0],B=F[1],L=t.useState(!1),P=L[0],z=L[1],J=v.default.useRef(null==A?void 0:A.isAiStreaming);t.useEffect(function(){q||P||B({title:I.ruleTitle,scope:I.scopeData})},[I.ruleTitle,I.scopeData,q,P]),t.useEffect(function(){var i;if(J.current&&!(null==A?void 0:A.isAiStreaming)&&P&&(z(!1),null===(i=null==A?void 0:A.setActiveEditId)||void 0===i||i.call(A,null),null==A?void 0:A.setSendMessageInChat)){var e=I.ruleTitle!==k.title,t=JSON.stringify(I.scopeData)!==JSON.stringify(k.scope),n=[];if(e&&n.push("Title with ".concat(I.ruleTitle)),t){var o=[];I.scopeData.station&&o.push(I.scopeData.station),I.scopeData.tiers&&I.scopeData.tiers.length>0&&o.push(I.scopeData.tiers.join(", ")),n.push("Scope with ".concat(o.join(", ")))}var l=n.join(" and ");A.setSendMessageInChat("__SKELETON_END__::Update Rule Setup using ".concat(l))}J.current=null==A?void 0:A.isAiStreaming},[null==A?void 0:A.isAiStreaming,P,I,k]);var H=function(){var i;j.setRuleTitle(k.title),k.scope.station!==I.scopeData.station&&j.onScopeChange("station",k.scope.station),JSON.stringify(k.scope.tiers)!==JSON.stringify(I.scopeData.tiers)&&j.onScopeChange("tiers",k.scope.tiers),null===(i=null==A?void 0:A.setActiveEditId)||void 0===i||i.call(A,null)},K=function(){var i,e,t=I.ruleTitle!==k.title,n=JSON.stringify(I.scopeData)!==JSON.stringify(k.scope);if(t||n){if(z(!0),null==A?void 0:A.setSendMessageInChat){var o="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),l=[];if(t){var a=(null===(e=I.ruleTitle)||void 0===e?void 0:e.trim())?"Title with ".concat(I.ruleTitle):"No Title";l.push(a)}if(n){var r=[];I.scopeData.station&&r.push("station: ".concat(I.scopeData.station)),I.scopeData.tiers&&I.scopeData.tiers.length>0&&r.push("tiers: ".concat(I.scopeData.tiers.join(", ")));var s=r.length>0?"with ".concat(r.join(" and ")):"No Tier Selected";l.push(s)}var d=l.join(" and ");A.setSendMessageInChat("__SKELETON__:".concat(o,":Update Rule Setup ").concat(d))}}else null===(i=null==A?void 0:A.setActiveEditId)||void 0===i||i.call(A,null)},U=v.default.useRef(null==A?void 0:A.defaultVariantOpen),$=v.default.useRef(I.variantsByTier);v.default.useEffect(function(){var i,e,t,n,o=null,l=!1;if(U.current!==(null==A?void 0:A.defaultVariantOpen)&&(l=!0,U.current=null==A?void 0:A.defaultVariantOpen),I.variantsByTier,$.current,l){if(null==(null==A?void 0:A.defaultVariantOpen)||(null==A?void 0:A.defaultVariantOpen)<0)return W(null),void($.current=I.variantsByTier);null===(e=null===(i=null==A?void 0:A.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,t;return null===(t=null===(e=I.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=I.variantsByTier)||void 0===e?void 0:e[t])||[]).forEach(function(i,e){(null==A?void 0:A.defaultVariantOpen)===e&&(o="".concat(t,"-variant-").concat(e)),(null==A?void 0:A.autoScrollVariantIndex)===e&&(o="".concat(t,"-variant-").concat(e))})}),o&&W(o)}null===N&&(null==A?void 0:A.defaultVariantOpen)>=0&&(null===(n=null===(t=null==A?void 0:A.tierOptions)||void 0===t?void 0:t.filter(function(i){var e,t;return null===(t=null===(e=I.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=I.variantsByTier)||void 0===e?void 0:e[t])||[])[A.defaultVariantOpen]&&W("".concat(t,"-variant-").concat(A.defaultVariantOpen))})),$.current=I.variantsByTier},[I.variantsByTier,null==A?void 0:A.defaultVariantOpen,null===(g=I.scopeData)||void 0===g?void 0:g.tiers,null==A?void 0:A.tierOptions,null==A?void 0:A.autoScrollVariantIndex]);var Z=function(e){R(function(t){var n;return i.__assign(i.__assign({},t),((n={})[e]=!t[e],n))})},G=function(i){var e,t,n,o=i.split("_"),l=o[o.length-1],a=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,r=null===(e=I.fieldCitations)||void 0===e?void 0:e[a];if(Array.isArray(r)&&r.length>0)return r;var s=null===(t=I.fieldCitations)||void 0===t?void 0:t[i];return Array.isArray(s)&&s.length>0?s:null!==(n=I.citations)&&void 0!==n?n:[]},Q={marginTop:"-17px",position:"relative",zIndex:1};v.default.useCallback(function(i){i&&requestAnimationFrame(function(){setTimeout(function(){i.scrollIntoView({behavior:"smooth",block:"center"})},300)})},[]),t.useEffect(function(){var i,e;null!=(null==A?void 0:A.autoScrollVariantIndex)&&(null===(e=null===(i=null==A?void 0:A.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,t;return null===(t=null===(e=I.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(A.autoScrollVariantIndex),n=M.current.get(t);n&&requestAnimationFrame(function(){setTimeout(function(){n.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==A?void 0:A.scrollTrigger]),console.log("CreateRule state:",I),console.log("CreateRule uiState:",A);var X=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"},Y=!!(null==A?void 0:A.activeEditId);return e.jsxs("div",i.__assign({className:"traffic-manager-template"},{children:[e.jsx("div",i.__assign({"data-edit-id":"rule-setup"},{children:e.jsx(s.default,i.__assign({title:{type:"other",label:(null==A?void 0:A.setupLabel)||"Rule Setup"},actionButtons:function(t,n){if(q)return null;var o=!!(null==A?void 0:A.activeEditId)&&"rule-setup"!==A.activeEditId;return e.jsx("div",i.__assign({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:e.jsx("button",i.__assign({title:o?"Save active edits first":"Edit",onClick:function(i){i.stopPropagation(),o?(null==A?void 0:A.setPendingEditId)&&A.setPendingEditId(A.activeEditId||null):(!function(){var i;(null==A?void 0:A.activeEditId)&&"rule-setup"!==A.activeEditId||(null===(i=null==A?void 0:A.setActiveEditId)||void 0===i||i.call(A,"rule-setup"),B({title:I.ruleTitle,scope:I.scopeData}))}(),(null==A?void 0:A.setPendingEditId)&&A.setPendingEditId(null),t||n())},disabled:P,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:P?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:P?.5:1}},{children:e.jsx(c.Pencil,{size:14})}))}))},footerData:{ruleTitle:I.ruleTitle,stations:[I.scopeData.station],tiers:null===(f=I.scopeData)||void 0===f?void 0:f.tiers},defaultOpen:"Create"===(null==A?void 0:A.usedFor),readOnly:"Create"!==(null==A?void 0:A.usedFor),isAiStreaming:null==A?void 0:A.isAiStreaming,editFlow:"Edit"===(null==A?void 0:A.usedFor)},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[P&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[e.jsx(c.Loader2Icon,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),e.jsx(r.TextSection,i.__assign({id:"rule-title",title:A.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:I.ruleTitle,onChange:j.setRuleTitle,readOnly:"Create"!==(null==A?void 0:A.usedFor)||(null==A?void 0:A.isAiStreaming)||!q,isOpen:w.ruleTitle,onToggle:function(){return Z("ruleTitle")},isHighlighted:E.ruleTitle||!1,showCognitiveIcon:I.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(h=A.validationErrors)||void 0===h?void 0:h.ruleTitle},A)),I.citation.ruleTitle&&e.jsx("div",i.__assign({style:Q},{children:e.jsx(n.InputDataReasoningCard,{isVisible:w.ruleTitle,citation:I.citation.ruleTitle,citations:G("ruleTitle"),fieldName:"Rule Title",fieldValue:I.ruleTitle})})),e.jsx(a.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:I.scopeData,onScopeChange:j.onScopeChange,tierLabel:"Which tiers should this learning apply to?",stationLabel:"Which scope should this learning belong to?",highlights:E,isOpen:w.scopeData,onToggle:function(){return Z("scopeData")},showCognitiveIcon:I.citation.scopeData,cognitiveIcon:e.jsx(d.ButtonCognitiveIcon,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(x=A.validationErrors)||void 0===x?void 0:x.station)||(null===(y=A.validationErrors)||void 0===y?void 0:y.tiers),stationErrorMessage:null===(_=A.validationErrors)||void 0===_?void 0:_.station,tierErrorMessage:null===(S=A.validationErrors)||void 0===S?void 0:S.tiers,readOnly:"Create"!==(null==A?void 0:A.usedFor)||(null==A?void 0:A.isAiStreaming)||!q},A)),I.citation.scopeData&&e.jsx("div",i.__assign({style:Q},{children:e.jsx(n.InputDataReasoningCard,{isVisible:w.scopeData,citation:I.citation.scopeData,citations:G("scopeData"),fieldName:"Scope",fieldValue:null===(T=null===(D=I.scopeData)||void 0===D?void 0:D.tiers)||void 0===T?void 0:T.join(", ")})})),!q||P?null:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e.jsxs("div",i.__assign({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[e.jsx("button",i.__assign({onClick:H,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e.jsxs("button",i.__assign({onClick:K,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:[e.jsx(c.Check,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==A?void 0:A.pendingEditId)&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"8px"}},{children:[e.jsx(c.AlertTriangle,{style:{color:"#C2410C"}}),e.jsx("div",i.__assign({style:{display:"flex",color:"#C2410C",fontSize:"13px",paddingTop:"8px",alignItems:"center"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]}))]}))}))})),null===(C=null===(m=null==A?void 0:A.tierOptions)||void 0===m?void 0:m.filter(function(i){var e,t;return null===(t=null===(e=I.scopeData)||void 0===e?void 0:e.tiers)||void 0===t?void 0:t.includes(i)}))||void 0===C?void 0:C.map(function(t,a,d){var c,u,v,g,f=t.toLowerCase().replace(/ /g,"_"),h=(null===(c=I.variantsByTier)||void 0===c?void 0:c[f])||[],x=h.length,y=!1;if(1===x){var _=h[0],S=!(null===(u=null==_?void 0:_.ruleDescription)||void 0===u?void 0:u.trim()),D=(null===(v=null==_?void 0:_.whenToApplyConditions)||void 0===v?void 0:v.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,T=(null===(g=null==_?void 0:_.whenNotToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;S&&!D&&!T&&(y=!0)}var m=y?void 0:"".concat(x," ").concat(1===x?"variant":"variants"," configured for this tier"),C=!((null==A?void 0:A.defaultTierOpen)>=0)||a===A.defaultTierOpen;return console.log("Rendering tier : ",t),e.jsx(s.default,i.__assign({variant:"tier-header",title:{type:"other",label:t},subtitle:m,defaultOpen:C,footerData:{description:"Variants for ".concat(t)}},{children:e.jsx(p,i.__assign({onAddVariant:function(){var i;return null===(i=j.addNewVariant)||void 0===i?void 0:i.call(j,f)},isDisabled:null==A?void 0:A.isAiStreaming},{children:h.map(function(t,a){var d,c,u,v,p,g,h,x,y,_,S,D=t.variantType||"default",T="".concat(f,"-variant-").concat(a),m=!0===t.is_variant,C="default"===D||"default_variant"===D;(null==A?void 0:A.defaultVariantOpen)>=0&&A.defaultVariantOpen;var I="".concat(f,"_").concat(a),E=b.get(I)||{},O=(null===(c=null===(d=A.separationItemsByTier)||void 0===d?void 0:d[f])||void 0===c?void 0:c.get(a))||[],R=(null===(v=null===(u=A.togglesByTier)||void 0===u?void 0:u[f])||void 0===v?void 0:v.get(a))||[];(null==A?void 0:A.autoScrollVariantIndex)===a||t.is_variant,console.log("Rendering ".concat(f," variant ").concat(a,":"),t),console.log("Rendering Variant : ",t),console.log("Open Accordion ID:",N,"Current Variant ID:",T);var V=null===(p=null==A?void 0:A.activeEditId)||void 0===p?void 0:p.startsWith("condition-wta-".concat(f,"-").concat(a)),q=null===(g=null==A?void 0:A.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(f,"-").concat(a));return e.jsx("div",i.__assign({ref:function(i){i?M.current.set(T,i):M.current.delete(T)},style:{width:"100%"}},{children:e.jsx(s.default,i.__assign({title:{type:C?"default":"variant",label:X(D),number:a+1,isNewVariant:m,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:N===T,onToggle:function(){var i,e=N===T;console.log("is closing:",e),W(e?null:T),null===(i=null==A?void 0:A.setActiveVariantAccordionIndex)||void 0===i||i.call(A,e?null:a)},variant:"rule-behavior",footerData:{ruleTitle:D,description:t.ruleDescription||""}},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[e.jsx(r.TextSection,i.__assign({id:"rule-description-".concat(f,"-").concat(a),title:A.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:t.isReadOnly||(null==A?void 0:A.isAiStreaming)||Y&&(null==A?void 0:A.activeEditId)!=="rule-description-".concat(f,"-").concat(a),value:t.ruleDescription||"",onChange:function(i){return j.setRuleDescription(f,a,i)},isOpen:w["ruleDescription-".concat(f,"-").concat(a)],onToggle:function(){return Z("ruleDescription-".concat(f,"-").concat(a))},isHighlighted:E.ruleDescription||!1,showCognitiveIcon:null===(h=t.reasoning)||void 0===h?void 0:h.ruleDescription,tooltipDescription:"Why this Description?",errorMessage:null===(x=A.validationErrors)||void 0===x?void 0:x["ruleDescription-".concat(f,"-").concat(a)],enableInlineEdit:!0,setSendMessageInChat:null==A?void 0:A.setSendMessageInChat,isAiStreaming:null==A?void 0:A.isAiStreaming,fieldName:"Rule Description"},A)),(null===(y=t.reasoning)||void 0===y?void 0:y.ruleDescription)&&e.jsx("div",i.__assign({style:Q},{children:e.jsx(n.InputDataReasoningCard,{isVisible:w["ruleDescription-".concat(f,"-").concat(a)],citation:t.reasoning.ruleDescription,citations:G("ruleDescription_".concat(f,"_").concat(a)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),e.jsx(o.ConditionSection,i.__assign({id:"when-to-apply-".concat(f,"-").concat(a),idPrefix:"condition-wta",title:A.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:t.isReadOnly||(null==A?void 0:A.isAiStreaming)||Y&&!V,conditions:t.whenToApplyConditions||[],onAdd:function(){return j.addWhenToApply(f,a)},onRemove:function(i,e,t){return j.removeWhenToApply(i,e,t)},onEdit:function(i,e,t,n){return j.editWhenToApply(i,e,t,n)},index:a,tierKey:f,isHighlighted:E.wta||!1,highlightedIds:null==A?void 0:A.highlightedIds,tooltipDescription:"Why this Condition?",citations:G("whenToApply_".concat(f,"_").concat(a)),bordered:!0,addLabel:"Add When to apply",isAiStreaming:A.isAiStreaming,errorMessage:(null===(_=A.validationErrors)||void 0===_?void 0:_["whenToApply-".concat(f,"-").concat(a)])||(null==A?void 0:A.conflictReason)},A)),e.jsx(o.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(f,"-").concat(a),idPrefix:"condition-wnta",title:A.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:t.isReadOnly||(null==A?void 0:A.isAiStreaming)||Y&&!q,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return j.addWhenNotToApply(f,a)},onRemove:function(i,e,t){return j.removeWhenNotToApply(i,e,t)},onEdit:function(i,e,t,n){return j.editWhenNotToApply(i,e,t,n)},index:a,tierKey:f,isHighlighted:E.wnta||!1,highlightedIds:null==A?void 0:A.highlightedIds,tooltipDescription:"Why this Condition?",citations:G("whenNotToApply_".concat(f,"_").concat(a)),bordered:!0,addLabel:"Add When NOT to apply",isAiStreaming:A.isAiStreaming},A)),e.jsx(l.ConfigSection,i.__assign({id:"config-".concat(f,"-").concat(a),title:A.configTitle||"Configuration",required:!1,highlights:E,bordered:!0,readOnly:t.isReadOnly||(null==A?void 0:A.isAiStreaming)||Y,onConfigChange:function(i,e){return j.onConfigChange(f,a,i,e)},separationItems:O,toggles:R,index:a},A)),(null===(S=t.reasoning)||void 0===S?void 0:S.configData)&&e.jsx("div",i.__assign({style:Q},{children:e.jsx(n.InputDataReasoningCard,{citation:t.reasoning.configData,citations:G("configData_".concat(f,"_").concat(a)),fieldName:"Configuration",fieldValue:"Proposed Configuration"})}))]}))}),T)}),"".concat(f,"-variant-").concat(a))})}))}),"tier-".concat(a))})]}))};
2
2
  //# sourceMappingURL=CreateRule.js.map