@e-llm-studio/instant-learning 0.1.1-alpha.18 → 0.1.1-alpha.19

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("react/jsx-runtime"),i=require("../../../features/LearningManagement/components/InstantLearningModal.js");exports.default=function(r){var t=r.pluginPayload||{},a=t.editingRule,n=t.editingTier,d=t.editingVariants,s=t.focusedVariantIndex,o=t.setFocusedVariantIndex,u=t.triggerAddVariant,g=t.triggerFixGaps,c=t.copiedRule,l=t.copiedSourceTier,p=t.copiedTargetTier,x=t.initialDraftMessage;return e.jsx(i.default,{isOpen:r.isOpen,onClose:r.onClose,initialScope:r.initialScope,ruleSet:r.ruleSet,editingRule:a,editingTier:n,editingVariants:d,focusedVariantIndex:s,setFocusedVariantIndex:o,triggerAddVariant:u,triggerFixGaps:g,copiedRule:c,copiedSourceTier:l,copiedTargetTier:p,initialDraftMessage:x})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../features/LearningManagement/components/InstantLearningModal.js");exports.default=function(i){var a=i.pluginPayload||{},n=a.editingRule,r=a.editingTier,o=a.editingVariants,d=a.focusedVariantIndex,u=a.setFocusedVariantIndex,c=a.triggerAddVariant,s=a.triggerFixGaps,l=a.copiedRule,p=a.copiedSourceTier,g=a.copiedTargetTier,I=a.initialDraftMessage,m=a.app_integration_id,w=a.modeId,x={"Separation rule":"I would want to add a separation rule","Max priority rule":"I would want to set a max priority rule","Break code matching":"I would want to add a break code matching rule","Inventory code matching":"I would want to add a inventory window matching rule","Enter a rule description":"I want to add a rule description","Tester Genie":"Loading prompt..."},y="<p><span>Hi! 👋 I'm your Instant Learning Concierge.</span>\n <span>How would you like to get started? You can select an option below or describe the rule you’d like to create.</span>\n ".concat(["Separation rule","Max priority rule","Break code matching","Inventory code matching","Enter a rule description","Tester Genie"].map(function(e){return'<button class="clickable-button" data-value="'.concat(x[e],'">').concat(e,"</button>")}).join(""),"</p>");return e.jsx(t.default,{isOpen:i.isOpen,onClose:i.onClose,initialScope:i.initialScope,ruleSet:i.ruleSet,editingRule:n,editingTier:r,editingVariants:o,focusedVariantIndex:d,setFocusedVariantIndex:u,triggerAddVariant:c,triggerFixGaps:s,copiedRule:l,copiedSourceTier:p,copiedTargetTier:g,initialDraftMessage:I,initialChatMessage:y,applicationIntegrationId:m,modeId:w})};
2
2
  //# sourceMappingURL=RadioTrafficLearningRenderer.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 C}from"../utils/treeUtils.js";import b 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 R}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 j 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";var O=function(O){var _,L=O.noRulesTitle,k=void 0===L?"No rules have been added !":L,x=O.noRulesDesc,M=void 0===x?"Start by adding rules that should apply across all stations.":x,D=O.noRulesButtonText,N=void 0===D?"Create New Rule":D,E=O.deleteRuleSuccessMessage,F=void 0===E?"Rule deleted successfully!":E,V=O.deleteVariantSuccessMessage,A=void 0===V?"Variant deleted successfully!":V,J=O.deleteRuleErrorMessage,P=void 0===J?"Failed to delete rule. Please try again.":J,U=O.deleteVariantErrorMessage,B=void 0===U?"Failed to delete variant. Please try again.":U,W=O.deleteModalTitle,G=void 0===W?"Delete":W,q=O.deleteRuleModalWarning,H=void 0===q?"This will permanently delete the rule configuration.":q,z=O.deleteVariantModalWarning,K=void 0===z?"This will permanently delete the variant configuration.":z,Q=O.deleteConfirmText,X=void 0===Q?"Delete":Q,Y=O.onRefreshRuleSets,Z=O.app_integration_id,$=O.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),Ce=Se[0],be=Se[1],Ie=a(!1),Re=Ie[0],je=Ie[1],Oe=a(null),_e=Oe[0],Le=Oe[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),be(0)},ft=function(){de(!1),ae(!1),fe(null),he(null),we(null),be(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,C,b;return t(this,function(t){switch(t.label){case 0:if(!ee)return re([]),[2];r||je(!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===(b=null===(C=null===(S=v[0])||void 0===S?void 0:S.variants)||void 0===C?void 0:C[0])||void 0===b?void 0:b.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||je(!1),[7];case 5:return[2]}})})},gt=ee?C((null==te?void 0:te.data)||null,ee):null,ht=gt?{ruleSetId:gt.id,ruleSetName:gt.name,ruleSetDesc:"",ruleCount:null===(_=null==gt?void 0:gt.metrics)||void 0===_?void 0:_.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:b.semibold},{children:null==t?void 0:t.ruleTitle}))," rule? This action cannot be undone."]})},wt={editingRule:me,editingTier:ge,editingVariants:Te,focusedVariantIndex:Ce,setFocusedVariantIndex:be,triggerAddVariant:We,triggerFixGaps:tt,copiedRule:it,copiedSourceTier:st,copiedTargetTier:dt,initialDraftMessage:Ne};return r(o,ht?{children:[i(h,{ref:se}),i("div",n({className:b.container},{children:Re?i(g,{}):_e?i(T,{errorMessage:_e,onRetry:vt}):i(y,{onAddRule:mt,onDeleteRule:function(e){Ae(e)},onEditRule:function(e,t){fe(e),he(t||null),we(e.variants||null),be(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),be(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:b.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:b.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:b.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:b.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),be(null),de(!0)}}})})),ce&&i(R,{children:i(j,{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:b.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:b.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:b.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:b.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(R,{children:i(j,{isOpen:ce,onClose:ft,initialScope:yt(),ruleSet:ht,app_integration_id:Z,pluginPayload:wt})})]})};export{O 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 R}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 j 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";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),Re=Ie[0],je=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||je(!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||je(!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:Re?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(R,{children:i(j,{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(R,{children:i(j,{isOpen:ce,onClose:ft,initialScope:yt(),ruleSet:ht,app_integration_id:Z,pluginPayload:wt})})]})};export{_ as default};
2
2
  //# sourceMappingURL=RuleContent.js.map
@@ -1,2 +1,2 @@
1
- var e={publishFeedback:"/instant_learning/save",submitChatFeedback:"/instant_learning/feedback/teachme_otj",saveInstantLearningQuestion:"/instant_learning/getLearningQuestionId",fetchScopes:"/instant_learning/ilotj/scope",renameScope:"/instant_learning/scope",getRulesInRuleSetById:"/instant_learning/ilotj/rules/scope",createRuleSet:"/instant_learning/ilotj/scope",fetchStationsByKeyword:"/backend/traffic-manager/station/search/{keyword}",saveRuleSet:"/backend/traffic-manager/station/ruleset",getRuleOverrideHistory:"/instant_learning/learnings/inheritance/change_log",deleteRuleSet:"/instant_learning/ilotj/scope/{ruleSetId}",deleteRule:"/instant_learning/learning/{ruleId}/delete",deleteQuestion:"/instant_learning/question/{questionId}",deleteTier:"instant_learning/scopes/{scopeId}/tiers/{tierId}",updateVariant:"/instant_learning/v2/update/rule",inheritScope:"/instant_learning/learnings/rules/inherit-scope",updateStation:"/backend/traffic-manager/station/update",exportRuleSet:"/instant_learning/export-ruleset",toggleVariant:"/instant_learning/toggle_variant",alterRulePriority:"/instant_learning/v2/alterPriority",fetchRulesByQuestionId:"/instant_learning/learnings/rules/fetch_by_rule_id/{questionId}/{scopeId}?include_config=True",retrieveGenreScopes:"/instant_learning/learnings/retrieve_genre_scopes",searchScopes:"/instant_learning/learnings/search_scopes",sessionValidation:"/instant_learning/session-validation"};export{e as API_ENDPOINTS};
1
+ var e={publishFeedback:"/instant_learning/ilotj/variants",submitChatFeedback:"/instant_learning/feedback/teachme_otj",saveInstantLearningQuestion:"/instant_learning/getLearningQuestionId",fetchScopes:"/instant_learning/ilotj/scope",renameScope:"/instant_learning/scope",getRulesInRuleSetById:"/instant_learning/ilotj/rules/scope",createRuleSet:"/instant_learning/ilotj/scope",fetchStationsByKeyword:"/backend/traffic-manager/station/search/{keyword}",saveRuleSet:"/backend/traffic-manager/station/ruleset",getRuleOverrideHistory:"/instant_learning/learnings/inheritance/change_log",deleteRuleSet:"/instant_learning/ilotj/scope/{ruleSetId}",deleteRule:"/instant_learning/learning/{ruleId}/delete",deleteQuestion:"/instant_learning/question/{questionId}",deleteTier:"instant_learning/scopes/{scopeId}/tiers/{tierId}",updateVariant:"/instant_learning/v2/update/rule",inheritScope:"/instant_learning/learnings/rules/inherit-scope",updateStation:"/backend/traffic-manager/station/update",exportRuleSet:"/instant_learning/export-ruleset",toggleVariant:"/instant_learning/toggle_variant",alterRulePriority:"/instant_learning/v2/alterPriority",fetchRulesByQuestionId:"/instant_learning/learnings/rules/fetch_by_rule_id/{questionId}/{scopeId}?include_config=True",retrieveGenreScopes:"/instant_learning/learnings/retrieve_genre_scopes",searchScopes:"/instant_learning/learnings/search_scopes",sessionValidation:"/instant_learning/session-validation"};export{e as API_ENDPOINTS};
2
2
  //# sourceMappingURL=apiConfig.js.map