@e-llm-studio/instant-learning 0.1.1-alpha.26 → 0.1.1-alpha.28

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
- import{__assign as e,__awaiter as i,__generator as t}from"tslib";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{useState as a,useEffect as l}from"react";import{Box as o,CircularProgress as s,Dialog as c,DialogTitle as u,Typography as d,IconButton as p,DialogContent as m}from"@mui/material";import I from"@mui/icons-material/Close";import{useLearningTemplateStore as h}from"../../LearningManagement/store/useLearningTemplateStore.js";import f from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import b from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";var W=function(e,n){return i(void 0,void 0,void 0,function(){var i,r;return t(this,function(t){switch(t.label){case 0:return[4,fetch("".concat("https://devllmstudio.creativeworkspace.ai","/instant_learning/ilotj/application/getValueType/").concat(e),{headers:{Authorization:"Bearer ".concat(n)}})];case 1:if(!(i=t.sent()).ok)throw new Error("Failed to fetch value type");return[4,i.json()];case 2:return r=t.sent(),console.log("Fetched value type data:",r),!r||Array.isArray(r.data)&&0===r.data.length?[2,null]:[2,r.data[0].value_type_name||r.valueTypeName||r.templateName]}})})},Z=function(){var i=a(!0),t=i[0],l=i[1];return r(c,e({open:t,onClose:function(){return l(!1)},fullWidth:!0,maxWidth:"lg",PaperProps:{sx:{borderRadius:"16px",minHeight:"70vh",overflow:"hidden"}}},{children:[r(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",px:3,py:2}},{children:[n(d,e({variant:"h6",fontWeight:600},{children:"Teach Me"})),n(p,e({onClick:function(){return l(!1)}},{children:n(I,{})}))]})),n(m,e({dividers:!0,sx:{p:3,backgroundColor:"#fafafa"}},{children:"There is some issue with the selected template. Kindly check steps to resolve."}))]}))},O={Default:f,"Radio Traffic Learning":b,Category:function(){return n("div",{children:"Category Template - Coming Soon!"})}},C=function(r){var c=h(function(e){return e.templateMap[r.app_integration_id]}),u=h(function(e){return e.setTemplateData}),d=a(!0),p=d[0],m=d[1],I=a(!1),f=I[0],b=I[1];if(l(function(){if(r.isOpen&&r.app_integration_id)if(c)m(!1);else{i(void 0,void 0,void 0,function(){var e,i;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,3,4]),m(!0),b(!1),[4,W(r.app_integration_id,"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25uZWN0b3JNYXAiOnt9LCJfaWQiOiI2OGI5OTExMWY1YWYyNzkwYTViN2Q3NzEiLCJlbWFpbCI6Im1vaGFtbWVkLmZhaXp1ZGRpbkB0ZWNob2x1dGlvbi5jb20iLCJmaXJzdG5hbWUiOiJNb2hhbW1lZCIsImxhc3RuYW1lIjoiRmFpenVkZGluIiwicm9sZSI6WyI2OTQwMWNmZTMwMzg5ODMwZWRlZDU4YmYiLCI2OGVmYjhiNTBhN2UwZWZlZTc5NTFhNWQiLCI2OTBiNmUwYmY3OGVmNTYyNzMxMzY0MTEiLCI2ODk5YzFlNmFkOWQwOGRhZGQxYzVlOTgiLCI2ODk5YzFlNmFkOWQwOGRhZGQxYzVlOWEiLCI2ODk5YzFlNmFkOWQwOGRhZGQxYzVlOTYiLCI2ODk5YzUyMjRkNmRjNDFjZDFmYjc5NWEiLCI2ODk5YzMzYWU5ZmQ0MWYzZjkwOGVkZDAiXSwiZGVwYXJ0bWVudHMiOltdLCJzdGF0dXMiOiJBQ1RJVkUiLCJyZXNldF90b2tlbiI6bnVsbCwiY3JlYXRlZEF0IjoiMjAyNS0wOS0wNFQxMzoxNjowMS43OThaIiwiam9pbmVkT24iOiIyMDI1LTA5LTA0VDEzOjE2OjAxLjc5OFoiLCJ1c2VyVmFsaWRpdHkiOiIyMDI1LTExLTE0VDE1OjA3OjM0LjE1NVoiLCJlbXBsb3llbWVudFR5cGUiOiJJbnRlcm4iLCJkZXNpZ25hdGlvbiI6IkZ1bGwgU3RhY2sgRGV2ZWxvcGVyIC0gSW50ZXJuIiwiZGVwYXJ0bWVudCI6IkRpZ2l0YWwgVHJhbnNmb3JtYXRpb24iLCJlbXBsb3llZUlkIjoiSU5UMDU0MiIsIm9yZ2FuaXphdGlvbiI6W10sImdyb3VwcyI6W10sInJvbGVuYW1lIjpbIk9yZyBVc2VyIiwiQ29udGV4dElMTW9kZSBBZG1pbiIsIkFnZW50IEdlbmllIE1vZGUgVXNlciIsIkFnZW50IEdlbmllIE1vZGUgQWRtaW4iLCJUZXN0IElMIC0gRmFpeiBBZG1pbiIsIk9iamVjdCBEZXRlY3Rpb24gTW9kZSBUZXN0IEFkbWluIiwiQWdlbnQgR2VuaWUgTW9kZSBNYW5hZ2VyIiwiT3JnIEFkbWluIl0sImlhdCI6MTc3OTA5MjI3NSwiZXhwIjoxNzc5MjY1MDc1fQ.De1vmWMkbC0xLE1JAHejXHCOcdZ4CCUCfeFl_LcMWBk")];case 1:return e=t.sent(),u(r.app_integration_id,e),[3,4];case 2:return i=t.sent(),console.error(i),b(!0),u(r.app_integration_id,"ERROR"),[3,4];case 3:return m(!1),[7];case 4:return[2]}})})}},[r.isOpen,r.app_integration_id,c]),p)return n(o,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n(s,{size:32})}));if(f||!c)return n(Z,{});var C=O[c];return C?n(C,e({},r)):(console.warn("No renderer found for template: ".concat(c)),n(Z,{}))};export{C as default};
1
+ import{__assign as e,__awaiter as t,__generator as r}from"tslib";import{jsx as n,jsxs as i}from"react/jsx-runtime";import{useState as a,useEffect as o}from"react";import{Box as s,CircularProgress as l,Dialog as c,DialogTitle as u,Typography as p,IconButton as d,DialogContent as f}from"@mui/material";import m from"@mui/icons-material/Close";import{useLearningTemplateStore as h}from"../../LearningManagement/store/useLearningTemplateStore.js";import g from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import v from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";var y=function(){var t=a(!0),r=t[0],o=t[1];return i(c,e({open:r,onClose:function(){return o(!1)},fullWidth:!0,maxWidth:"lg",PaperProps:{sx:{borderRadius:"16px",minHeight:"70vh",overflow:"hidden"}}},{children:[i(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",px:3,py:2}},{children:[n(p,e({variant:"h6",fontWeight:600},{children:"Teach Me"})),n(d,e({onClick:function(){return o(!1)}},{children:n(m,{})}))]})),n(f,e({dividers:!0,sx:{p:3,backgroundColor:"#fafafa"}},{children:"There is some issue with the selected template. Kindly check steps to resolve."}))]}))},_={Default:g,"Radio Traffic Learning":v,Category:function(){return n("div",{children:"Category Template - Coming Soon!"})}},T=function(i){var c=h(function(e){return e.templateMap[i.app_integration_id]}),u=h(function(e){return e.setTemplateData}),p=a(!0),d=p[0],f=p[1],m=a(!1),g=m[0],v=m[1];if(o(function(){if(i.isOpen&&i.app_integration_id)if(c)f(!1);else{t(void 0,void 0,void 0,function(){var e,n;return r(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,4]),f(!0),v(!1),[4,(o=i.app_integration_id,s=i.token,t(void 0,void 0,void 0,function(){var e,t;return r(this,function(r){switch(r.label){case 0:return[4,fetch("".concat("https://devllmstudio.creativeworkspace.ai","/instant_learning/ilotj/application/getValueType/").concat(o),{headers:{Authorization:"Bearer ".concat(s)}})];case 1:if(!(e=r.sent()).ok)throw new Error("Failed to fetch value type");return[4,e.json()];case 2:return t=r.sent(),console.log("Fetched value type data:",t),!t||Array.isArray(t.data)&&0===t.data.length?[2,null]:[2,t.data[0].value_type_name||t.valueTypeName||t.templateName]}})}))];case 1:return e=a.sent(),u(i.app_integration_id,e),[3,4];case 2:return n=a.sent(),console.error(n),v(!0),u(i.app_integration_id,"ERROR"),[3,4];case 3:return f(!1),[7];case 4:return[2]}var o,s})})}},[i.isOpen,i.app_integration_id,c]),d)return n(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n(l,{size:32})}));if(g||!c)return n(y,{});var T=_[c];return T?n(T,e({},i)):(console.warn("No renderer found for template: ".concat(c)),n(y,{}))};export{T as default};
2
2
  //# sourceMappingURL=TeachMeWrapper.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e,__generator as t,__assign as n}from"tslib";import{jsxs as r,Fragment as o,jsx as i}from"react/jsx-runtime";import{useRef as l,useState as a,useEffect as s}from"react";import{useLearningTemplateStore as u}from"../store/useLearningTemplateStore.js";import c from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as d,exportRuleSet as p,deleteRule as m,deleteQuestion as f,alterQuestionPriority as v}from"../apis/scopeApis.js";import g from"../components/RuleContentSkeleton.js";import{Toast as h}from"primereact/toast";import y from"./ContentLogic.js";import T from"../components/ErrorStateDisplay.js";import w from"../shared/SuccessToastContent.js";import S from"../shared/ErrorToastContent.js";import{findNodeById as b}from"../utils/treeUtils.js";import C from"../styles/LearningContent.module.css.js";import I from"../components/ConfirmationModal.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as j}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import R from"../../IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../store/useAuthStore.js";import"../store/useConfigStore.js";import"../store/useEnvStore.js";import"../components/ToolTip.js";var _=function(_){var O,L=_.noRulesTitle,k=void 0===L?"No rules have been added !":L,x=_.noRulesDesc,M=void 0===x?"Start by adding rules that should apply across all stations.":x,D=_.noRulesButtonText,N=void 0===D?"Create New Rule":D,E=_.deleteRuleSuccessMessage,F=void 0===E?"Rule deleted successfully!":E,V=_.deleteVariantSuccessMessage,A=void 0===V?"Variant deleted successfully!":V,J=_.deleteRuleErrorMessage,P=void 0===J?"Failed to delete rule. Please try again.":J,U=_.deleteVariantErrorMessage,B=void 0===U?"Failed to delete variant. Please try again.":U,W=_.deleteModalTitle,G=void 0===W?"Delete":W,q=_.deleteRuleModalWarning,H=void 0===q?"This will permanently delete the rule configuration.":q,z=_.deleteVariantModalWarning,K=void 0===z?"This will permanently delete the variant configuration.":z,Q=_.deleteConfirmText,X=void 0===Q?"Delete":Q,Y=_.onRefreshRuleSets,Z=_.app_integration_id,$=_.token,ee=u(function(e){return e.selectedRuleSetId}),te=u(function(e){return e.scopeTreeData}),ne=u(function(e){return e.sidebarTab}),re=u(function(e){return e.setInitialRules}),oe=u(function(e){return e.currentRules});u(function(e){return e.createdVariantInfo});var ie=u(function(e){return e.resetCreatedVariantInfo}),le=u(function(e){return e.isILModalTriggered}),ae=u(function(e){return e.setIsILModalTriggered}),se=l(null),ue=a(!1),ce=ue[0],de=ue[1],pe=a(null),me=pe[0],fe=pe[1],ve=a(null),ge=ve[0],he=ve[1],ye=a(null),Te=ye[0],we=ye[1],Se=a(null),be=Se[0],Ce=Se[1],Ie=a(!1),je=Ie[0],Re=Ie[1],_e=a(null),Oe=_e[0],Le=_e[1],ke=a(!1),xe=ke[0],Me=ke[1],De=a(""),Ne=De[0],Ee=De[1],Fe=a(null),Ve=Fe[0],Ae=Fe[1],Je=a(!1),Pe=Je[0],Ue=Je[1],Be=a(!1),We=Be[0],Ge=Be[1],qe=a("ruleDeletion"),He=qe[0],ze=qe[1],Ke=a(null),Qe=Ke[0],Xe=Ke[1],Ye=a(!1),Ze=Ye[0],$e=Ye[1],et=a(!1),tt=et[0],nt=et[1],rt=u.getState().tiers,ot=a(null),it=ot[0],lt=ot[1],at=a(null),st=at[0],ut=at[1],ct=a(null),dt=ct[0],pt=ct[1],mt=function(){fe(null),he(null),de(!0),Ce(0)},ft=function(){de(!1),ae(!1),fe(null),he(null),we(null),Ce(null),Ge(!1),nt(!1),vt(),lt(null),ut(null),pt(null),Y&&Y(!1,ee||void 0)};s(function(){vt()},[ee,re]),s(function(){le&&de(!0)},[le]);var vt=function(r){return void 0===r&&(r=!1),e(void 0,void 0,void 0,function(){var e,o,i,l,a,s,c,p,m,f,v,g,h,y,T,w,S,b,C;return t(this,function(t){switch(t.label){case 0:if(!ee)return re([]),[2];r||Re(!0),Le(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,d(ee,$)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(o=e.data,console.log("rulesData==",o),i=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),l=Object.entries(o).filter(function(e){var t=e[0],n=e[1];return!i.has(t)&&Array.isArray(n)}),a=l.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,n;return null!==(n=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==n?n:[]}))}),s=a.flatMap(function(e){return Array.from(e)}),c=s.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),p=new Set(Object.entries(c).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),m=function(e){return e.map(function(e){var t;return n(n({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return n(n({},e),{isLinked:!!e.link_id&&p.has(e.link_id)})})})})},f=l.map(function(e,t){var n,r=e[0],o=e[1],i=rt.find(function(e){return e.tier_name===r});return{id:null!==(n=null==i?void 0:i.tier_id)&&void 0!==n?n:String(t+1),name:r.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"These are the system-wide learnings applied across all stations.":"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:m(o)}}),(v=u.getState().createdVariantInfo)&&v.length>0?(g=Object.fromEntries(l.map(function(e,t){return[e[0],String(t+1)]})),h=new Set(v.map(function(e){return g[e.tierName]}).filter(Boolean)),y=f.map(function(e){return n(n({},e),{isOpen:e.isOpen||h.has(e.id)})}),re(y),(T=null===(C=null===(b=null===(S=v[0])||void 0===S?void 0:S.variants)||void 0===b?void 0:b[0])||void 0===C?void 0:C.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(T,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return ie()},1e4)},500):ie()):re(f),[3,5]):(re([]),[2]);case 3:return w=t.sent(),console.error("Failed to fetch rule details",w),404!==(null==w?void 0:w.status)&&Le((null==w?void 0:w.message)||"Failed to load rules. Please try again."),re([]),[3,5];case 4:return r||Re(!1),[7];case 5:return[2]}})})},gt=ee?b((null==te?void 0:te.data)||null,ee):null,ht=gt?{ruleSetId:gt.id,ruleSetName:gt.name,ruleSetDesc:"",ruleCount:null===(O=null==gt?void 0:gt.metrics)||void 0===O?void 0:O.learningsCount}:void 0,yt=function(){if("stations"===ne)return"custom";if(!gt)return"global";switch(gt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Tt=function(e){if(!e)return i("p",{children:"Are you sure you want to delete this rule? This action cannot be undone."});var t=null==oe?void 0:oe.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return r("p",{children:["Are you sure you want to delete"," ",i("span",n({className:C.semibold},{children:null==t?void 0:t.ruleTitle}))," rule? This action cannot be undone."]})},wt={editingRule:me,editingTier:ge,editingVariants:Te,focusedVariantIndex:be,setFocusedVariantIndex:Ce,triggerAddVariant:We,triggerFixGaps:tt,copiedRule:it,copiedSourceTier:st,copiedTargetTier:dt,initialDraftMessage:Ne,app_integration_id:Z,modeId:"019dde79-0494-78d7-ba5b-54a35d20f0fc"};return r(o,ht?{children:[i(h,{ref:se}),i("div",n({className:C.container},{children:je?i(g,{}):Oe?i(T,{errorMessage:Oe,onRetry:vt}):i(y,{onAddRule:mt,onDeleteRule:function(e){Ae(e)},onEditRule:function(e,t){fe(e),he(t||null),we(e.variants||null),Ce(null),Ge(!0),de(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==oe?void 0:oe.find(function(e){return e.name===n}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===t}))&&void 0!==l?l:null==oe?void 0:oe.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(a=s.variants)||void 0===a?void 0:a.findIndex(function(t){return t.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;fe(s),he(n||null),we(s.variants||null),Ce(c),de(!0),"resolve_gaps"===r&&nt(!0)}},onDeleteVariant:function(e,t){Xe({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,n,r,o,l,a,s;return t(this,function(t){switch(t.label){case 0:if(!ee)return[2];Me(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(ee)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,o=(null==ht?void 0:ht.ruleSetName)?"".concat(ht.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ee,".csv"),r.download=o,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=se.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:C.successToast,content:i(w,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=se.current)||void 0===s||s.show({severity:"error",sticky:!1,className:C.errorToast,content:i(S,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Me(!1),[7];case 5:return[2]}})})},isExporting:xe,onToggleSuccess:function(){return vt(!0)},onReorderRules:function(n,r,o,l,a){return e(void 0,void 0,void 0,function(){var e,s,u;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v(n,r,o,l,a)];case 1:return t.sent(),vt(!0),null===(s=se.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:C.successToast,content:i(w,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=t.sent(),console.error("Failed to reorder rules:",e),vt(!0),null===(u=se.current)||void 0===u||u.show({severity:"error",sticky:!1,className:C.errorToast,content:i(S,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:Y,setDeleteConfirmationUsedFor:ze,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==oe?void 0:oe.find(function(e){return e.name===r}))||void 0===i?void 0:i.rules)||void 0===l?void 0:l.find(function(e){return e.ruleId===t});if(a){var s=["Add a new learning with the following details:","- Rule Title: ".concat(n),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");Ee(s),lt(a),ut(r),pt(o),fe(null),he(null),we(null),Ce(null),de(!0)}}})})),ce&&i(j,{children:i(R,{isOpen:ce,onClose:ft,initialScope:yt(),ruleSet:ht,app_integration_id:Z,pluginPayload:wt})}),i(I,{isOpen:!!Ve,title:G,description:Tt(Ve),warning:H,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,o,l;return t(this,function(t){switch(t.label){case 0:if(!Ve)return[2];Ue(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(Ve)];case 2:return t.sent(),Ae(null),null===(n=se.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:C.successToast,content:i(w,{message:F})}),vt(),Y&&Y(!1,ee||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=se.current)||void 0===r||r.show({severity:"error",sticky:!1,className:C.errorToast,content:i(S,{message:(null===(l=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||P})}),[3,5];case 4:return Ue(!1),[7];case 5:return[2]}})})},onCancel:function(){return Ae(null)},isLoading:Pe}),i(I,{isOpen:!!Qe,title:G,description:"variantDeletion"===He?i("span",{children:"Are you sure you want to delete this variant? This action cannot be undone."}):Tt((null==Qe?void 0:Qe.ruleId)||null),warning:"ruleDeletion"===He?H:K,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,o,l;return t(this,function(t){switch(t.label){case 0:if(!Qe)return[2];$e(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==He?[3,3]:[4,f(Qe.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,m(Qe.variantId)];case 4:t.sent(),t.label=5;case 5:return Xe(null),null===(n=se.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:C.successToast,content:i(w,{message:"ruleDeletion"===He?F:A})}),vt(),Y&&Y(!1,ee||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=se.current)||void 0===r||r.show({severity:"error",sticky:!1,className:C.errorToast,content:i(S,{message:(null===(l=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===He?P:B)})}),[3,8];case 7:return $e(!1),[7];case 8:return[2]}})})},onCancel:function(){return Xe(null)},isLoading:Ze})]}:{children:[i(c,{onCreate:mt,title:k,desc:M,button:N}),ce&&i(j,{children:i(R,{isOpen:ce,onClose:ft,initialScope:yt(),ruleSet:ht,app_integration_id:Z,pluginPayload:wt})})]})};export{_ as default};
1
+ import{__awaiter as e,__generator as t,__assign as n}from"tslib";import{jsxs as r,Fragment as o,jsx as i}from"react/jsx-runtime";import{useRef as l,useState as a,useEffect as s}from"react";import{useLearningTemplateStore as u}from"../store/useLearningTemplateStore.js";import c from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as d,exportRuleSet as p,deleteRule as m,deleteQuestion as f,alterQuestionPriority as v}from"../apis/scopeApis.js";import g from"../components/RuleContentSkeleton.js";import{Toast as h}from"primereact/toast";import y from"./ContentLogic.js";import T from"../components/ErrorStateDisplay.js";import w from"../shared/SuccessToastContent.js";import S from"../shared/ErrorToastContent.js";import{findNodeById as b}from"../utils/treeUtils.js";import C from"../styles/LearningContent.module.css.js";import I from"../components/ConfirmationModal.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as j}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import R from"../../IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../store/useAuthStore.js";import"../store/useConfigStore.js";import"../store/useEnvStore.js";import"../components/ToolTip.js";var _=function(_){var O,k=_.noRulesTitle,L=void 0===k?"No rules have been added !":k,x=_.noRulesDesc,M=void 0===x?"Start by adding rules that should apply across all stations.":x,D=_.noRulesButtonText,N=void 0===D?"Create New Rule":D,E=_.deleteRuleSuccessMessage,F=void 0===E?"Rule deleted successfully!":E,V=_.deleteVariantSuccessMessage,A=void 0===V?"Variant deleted successfully!":V,J=_.deleteRuleErrorMessage,P=void 0===J?"Failed to delete rule. Please try again.":J,U=_.deleteVariantErrorMessage,B=void 0===U?"Failed to delete variant. Please try again.":U,W=_.deleteModalTitle,G=void 0===W?"Delete":W,q=_.deleteRuleModalWarning,H=void 0===q?"This will permanently delete the rule configuration.":q,z=_.deleteVariantModalWarning,K=void 0===z?"This will permanently delete the variant configuration.":z,Q=_.deleteConfirmText,X=void 0===Q?"Delete":Q,Y=_.onRefreshRuleSets,Z=_.app_integration_id,$=_.token,ee=u(function(e){return e.selectedRuleSetId}),te=u(function(e){return e.scopeTreeData}),ne=u(function(e){return e.sidebarTab}),re=u(function(e){return e.setInitialRules}),oe=u(function(e){return e.currentRules});u(function(e){return e.createdVariantInfo});var ie=u(function(e){return e.resetCreatedVariantInfo}),le=u(function(e){return e.isILModalTriggered}),ae=u(function(e){return e.setIsILModalTriggered}),se=l(null),ue=a(!1),ce=ue[0],de=ue[1],pe=a(null),me=pe[0],fe=pe[1],ve=a(null),ge=ve[0],he=ve[1],ye=a(null),Te=ye[0],we=ye[1],Se=a(null),be=Se[0],Ce=Se[1],Ie=a(!1),je=Ie[0],Re=Ie[1],_e=a(null),Oe=_e[0],ke=_e[1],Le=a(!1),xe=Le[0],Me=Le[1],De=a(""),Ne=De[0],Ee=De[1],Fe=a(null),Ve=Fe[0],Ae=Fe[1],Je=a(!1),Pe=Je[0],Ue=Je[1],Be=a(!1),We=Be[0],Ge=Be[1],qe=a("ruleDeletion"),He=qe[0],ze=qe[1],Ke=a(null),Qe=Ke[0],Xe=Ke[1],Ye=a(!1),Ze=Ye[0],$e=Ye[1],et=a(!1),tt=et[0],nt=et[1],rt=u.getState().tiers,ot=a(null),it=ot[0],lt=ot[1],at=a(null),st=at[0],ut=at[1],ct=a(null),dt=ct[0],pt=ct[1],mt=function(){fe(null),he(null),de(!0),Ce(0)},ft=function(){de(!1),ae(!1),fe(null),he(null),we(null),Ce(null),Ge(!1),nt(!1),vt(),lt(null),ut(null),pt(null),Y&&Y(!1,ee||void 0)};s(function(){vt()},[ee,re]),s(function(){le&&de(!0)},[le]);var vt=function(r){return void 0===r&&(r=!1),e(void 0,void 0,void 0,function(){var e,o,i,l,a,s,c,p,m,f,v,g,h,y,T,w,S,b,C;return t(this,function(t){switch(t.label){case 0:if(!ee)return re([]),[2];r||Re(!0),ke(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,d(ee,$)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(o=e.data,console.log("rulesData==",o),i=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),l=Object.entries(o).filter(function(e){var t=e[0],n=e[1];return!i.has(t)&&Array.isArray(n)}),a=l.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,n;return null!==(n=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==n?n:[]}))}),s=a.flatMap(function(e){return Array.from(e)}),c=s.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),p=new Set(Object.entries(c).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),m=function(e){return e.map(function(e){var t;return n(n({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return n(n({},e),{isLinked:!!e.link_id&&p.has(e.link_id)})})})})},f=l.map(function(e,t){var n,r=e[0],o=e[1],i=rt.find(function(e){return e.tier_name===r});return{id:null!==(n=null==i?void 0:i.tier_id)&&void 0!==n?n:String(t+1),name:r.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"These are the system-wide learnings applied across all stations.":"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:m(o)}}),(v=u.getState().createdVariantInfo)&&v.length>0?(g=Object.fromEntries(l.map(function(e,t){return[e[0],String(t+1)]})),h=new Set(v.map(function(e){return g[e.tierName]}).filter(Boolean)),y=f.map(function(e){return n(n({},e),{isOpen:e.isOpen||h.has(e.id)})}),re(y),(T=null===(C=null===(b=null===(S=v[0])||void 0===S?void 0:S.variants)||void 0===b?void 0:b[0])||void 0===C?void 0:C.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(T,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return ie()},1e4)},500):ie()):re(f),[3,5]):(re([]),[2]);case 3:return w=t.sent(),console.error("Failed to fetch rule details",w),404!==(null==w?void 0:w.status)&&ke((null==w?void 0:w.message)||"Failed to load rules. Please try again."),re([]),[3,5];case 4:return r||Re(!1),[7];case 5:return[2]}})})},gt=ee?b((null==te?void 0:te.data)||null,ee):null,ht=gt?{ruleSetId:gt.id,ruleSetName:gt.name,ruleSetDesc:"",ruleCount:null===(O=null==gt?void 0:gt.metrics)||void 0===O?void 0:O.learningsCount}:void 0,yt=function(){if("stations"===ne)return"custom";if(!gt)return"global";switch(gt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Tt=function(e){if(!e)return i("p",{children:"Are you sure you want to delete this rule? This action cannot be undone."});var t=null==oe?void 0:oe.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return r("p",{children:["Are you sure you want to delete"," ",i("span",n({className:C.semibold},{children:null==t?void 0:t.ruleTitle}))," rule? This action cannot be undone."]})},wt={editingRule:me,editingTier:ge,editingVariants:Te,focusedVariantIndex:be,setFocusedVariantIndex:Ce,triggerAddVariant:We,triggerFixGaps:tt,copiedRule:it,copiedSourceTier:st,copiedTargetTier:dt,initialDraftMessage:Ne,app_integration_id:Z,modeId:"019dde79-0494-78d7-ba5b-54a35d20f0fc"};return r(o,ht?{children:[i(h,{ref:se}),i("div",n({className:C.container},{children:je?i(g,{}):Oe?i(T,{errorMessage:Oe,onRetry:vt}):i(y,{onAddRule:mt,onDeleteRule:function(e){Ae(e)},onEditRule:function(e,t){fe(e),he(t||null),we(e.variants||null),Ce(null),Ge(!0),de(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==oe?void 0:oe.find(function(e){return e.name===n}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===t}))&&void 0!==l?l:null==oe?void 0:oe.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(a=s.variants)||void 0===a?void 0:a.findIndex(function(t){return t.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;fe(s),he(n||null),we(s.variants||null),Ce(c),de(!0),"resolve_gaps"===r&&nt(!0)}},onDeleteVariant:function(e,t){Xe({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,n,r,o,l,a,s;return t(this,function(t){switch(t.label){case 0:if(!ee)return[2];Me(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(ee)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,o=(null==ht?void 0:ht.ruleSetName)?"".concat(ht.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ee,".csv"),r.download=o,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=se.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:C.successToast,content:i(w,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=se.current)||void 0===s||s.show({severity:"error",sticky:!1,className:C.errorToast,content:i(S,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Me(!1),[7];case 5:return[2]}})})},isExporting:xe,onToggleSuccess:function(){return vt(!0)},onReorderRules:function(n,r,o,l,a){return e(void 0,void 0,void 0,function(){var e,s,u;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v(n,r,o,l,a)];case 1:return t.sent(),vt(!0),null===(s=se.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:C.successToast,content:i(w,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=t.sent(),console.error("Failed to reorder rules:",e),vt(!0),null===(u=se.current)||void 0===u||u.show({severity:"error",sticky:!1,className:C.errorToast,content:i(S,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:Y,setDeleteConfirmationUsedFor:ze,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==oe?void 0:oe.find(function(e){return e.name===r}))||void 0===i?void 0:i.rules)||void 0===l?void 0:l.find(function(e){return e.ruleId===t});if(a){var s=["Add a new learning with the following details:","- Rule Title: ".concat(n),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");Ee(s),lt(a),ut(r),pt(o),fe(null),he(null),we(null),Ce(null),de(!0)}}})})),ce&&i(j,{children:i(R,{isOpen:ce,onClose:ft,initialScope:yt(),ruleSet:ht,app_integration_id:Z,pluginPayload:wt,token:$})}),i(I,{isOpen:!!Ve,title:G,description:Tt(Ve),warning:H,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,o,l;return t(this,function(t){switch(t.label){case 0:if(!Ve)return[2];Ue(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(Ve)];case 2:return t.sent(),Ae(null),null===(n=se.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:C.successToast,content:i(w,{message:F})}),vt(),Y&&Y(!1,ee||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=se.current)||void 0===r||r.show({severity:"error",sticky:!1,className:C.errorToast,content:i(S,{message:(null===(l=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||P})}),[3,5];case 4:return Ue(!1),[7];case 5:return[2]}})})},onCancel:function(){return Ae(null)},isLoading:Pe}),i(I,{isOpen:!!Qe,title:G,description:"variantDeletion"===He?i("span",{children:"Are you sure you want to delete this variant? This action cannot be undone."}):Tt((null==Qe?void 0:Qe.ruleId)||null),warning:"ruleDeletion"===He?H:K,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,o,l;return t(this,function(t){switch(t.label){case 0:if(!Qe)return[2];$e(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==He?[3,3]:[4,f(Qe.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,m(Qe.variantId)];case 4:t.sent(),t.label=5;case 5:return Xe(null),null===(n=se.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:C.successToast,content:i(w,{message:"ruleDeletion"===He?F:A})}),vt(),Y&&Y(!1,ee||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=se.current)||void 0===r||r.show({severity:"error",sticky:!1,className:C.errorToast,content:i(S,{message:(null===(l=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===He?P:B)})}),[3,8];case 7:return $e(!1),[7];case 8:return[2]}})})},onCancel:function(){return Xe(null)},isLoading:Ze})]}:{children:[i(c,{onCreate:mt,title:L,desc:M,button:N}),ce&&i(j,{children:i(R,{isOpen:ce,onClose:ft,initialScope:yt(),ruleSet:ht,app_integration_id:Z,pluginPayload:wt,token:$})})]})};export{_ as default};
2
2
  //# sourceMappingURL=RuleContent.js.map