@e-llm-studio/instant-learning 1.3.0-alpha.34 → 1.3.0-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +1 -1
- package/dist/cjs/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
- package/dist/cjs/features/LearningManagement/LearningManagement.js +1 -1
- package/dist/cjs/features/LearningManagement/LearningTemplateLayout.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +1 -1
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/cjs/features/LearningManagement/constants.js +1 -1
- package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +1 -1
- package/dist/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
- package/dist/features/LearningManagement/LearningManagement.js +1 -1
- package/dist/features/LearningManagement/LearningTemplateLayout.js +1 -1
- package/dist/features/LearningManagement/RuleContent/RuleContent.js +1 -1
- package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/features/LearningManagement/constants.js +1 -1
- package/dist/features/LearningManagement/store/useLMSConfigStore.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/_components/index.d.ts +1 -0
- package/dist/types/src/features/IL-OTJ/_components/index.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/LearningManagement.d.ts +2 -1
- package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts +1 -0
- package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts +1 -0
- package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/constants.d.ts +1 -0
- package/dist/types/src/features/LearningManagement/constants.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts +9 -0
- package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +8 -1
- package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js +0 -2
- package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js.map +0 -1
- package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +0 -2
- package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +0 -1
- package/dist/features/LearningManagement/assets/Search-result(add new).svg.js +0 -2
- package/dist/features/LearningManagement/assets/Search-result(add new).svg.js.map +0 -1
- package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +0 -2
- package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +0 -1
- package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts +0 -12
- package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.LEARNING_DT_PATH="learnings.tier.learning",exports.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH="middleDrawer.addScopeDialog",exports.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH="middleDrawer.addScopeDialog.learningApprovalSettings",exports.MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH="middleDrawer.treeMenu.contextMenu",exports.MIDDLE_DRAWER_DT_PATH="middleDrawer",exports.TIER_DT_PATH="learnings.tier",exports.VARIANT_DT_PATH="learnings.tier.learning.variant";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.EMPTY_STATE_DT_PATH="emptyStateLearning",exports.LEARNING_DT_PATH="learnings.tier.learning",exports.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH="middleDrawer.addScopeDialog",exports.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH="middleDrawer.addScopeDialog.learningApprovalSettings",exports.MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH="middleDrawer.treeMenu.contextMenu",exports.MIDDLE_DRAWER_DT_PATH="middleDrawer",exports.TIER_DT_PATH="learnings.tier",exports.VARIANT_DT_PATH="learnings.tier.learning.variant";
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zustand"),t=require("./useLearningTemplateStore.js"),n={pageTitle:"",middleDrawer:{scope:"",addScope:"",addSubScope:"",addScopeDialog:{title:"",subtitle:"",scopeName:"",learningApprovalSettings:{title:"",approvalRequired:{title:"",subtitle:""},publishWithoutApproval:{title:"",subtitle:""}},submitButton:"",cancel:""},treeMenu:{search:"",submenu:{learnings:"",access:"",changeHistory:""},contextMenu:{addScope:"",rename:"",delete:"",addSubScope:""}}},learnings:{header:{title:"",exportButton:"",addNewLearningButton:""},tier:{showTierHeader:!0,tierHeader:"",subtitle:"",tierHeaderNoOfLearnings:"",deleteDialog:{title:"",description:"",cancel:"",submit:""},learning:{inheritance:"",actions:{disable:"",enable:"",approve:"",reject:"",delete:""},approveDialog:{title:"",desc:"",footer:"",cancel:"",approveLearning:""},rejectDialog:{title:"",desc:"",feedbackTitle:"",feedbackPlaceholder:"",deleteCheckboxLabel:"",cancel:"",rejectLearning:""},deleteDialog:{title:"",desc:"",warningText:"",cancelText:"",deleteText:""}}}},agents:{LearningTerm:""}},a={showScope:!1,showConfiguration:!1,welcomeMessage:"Hi! 👋 I'm your Instant Learning Concierge.",welcomeMessageSubtitle:"How would you like to get started? You can select an option below or describe the rule you'd like to create.",actions:[{label:"Separation rule",value:"I would want to add a separation rule"},{label:"Max priority rule",value:"I would want to set a max priority rule"},{label:"Break code matching",value:"I would want to add a break code matching rule"},{label:"Inventory code matching",value:"I would want to add a inventory window matching rule"},{label:"Enter a rule description",value:"I want to add a rule description"},{label:"Tester Genie",value:"Loading prompt..."}],chatTitle:"Teach Me OTJ - {scope} - Add Learning",chatTitleEdit:"Teach Me OTJ - {scope} - Edit Learning",formTitle:"Rule setup",setupLabel:"Configure your IL",ruleTitle:"Main Rule Name",scopeLabel:"Define Scope",tierLabel:"Select Tiers",ruleDescriptionTitle:"Learning Explanation",whenToApplyTitle:"Trigger Events (When to Apply)",addWhenToApplyBtnLabel:"Add WTA",whenNotToApplyTitle:"Exclusion Events (When NOT to Apply)",addWhenNotToApplyBtnLabel:"Add WNTA",configTitle:"Advanced Settings",saveBtnLabel:"Save Rule",saveBtnLoadingLabel:"Saving Rule...",chatTextareaPlaceholder:"Tell me more about this learning.."},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zustand"),t=require("./useLearningTemplateStore.js"),n={pageTitle:"",middleDrawer:{scope:"",addScope:"",addSubScope:"",addScopeDialog:{title:"",subtitle:"",scopeName:"",learningApprovalSettings:{title:"",approvalRequired:{title:"",subtitle:""},publishWithoutApproval:{title:"",subtitle:""}},submitButton:"",cancel:""},treeMenu:{search:"",submenu:{learnings:"",access:"",changeHistory:""},contextMenu:{addScope:"",rename:"",delete:"",addSubScope:""}}},learnings:{header:{title:"",exportButton:"",addNewLearningButton:""},tier:{showTierHeader:!0,tierHeader:"",subtitle:"",tierHeaderNoOfLearnings:"",deleteDialog:{title:"",description:"",cancel:"",submit:""},learning:{inheritance:"",actions:{disable:"",enable:"",approve:"",reject:"",delete:""},approveDialog:{title:"",desc:"",footer:"",cancel:"",approveLearning:""},rejectDialog:{title:"",desc:"",feedbackTitle:"",feedbackPlaceholder:"",deleteCheckboxLabel:"",cancel:"",rejectLearning:""},deleteDialog:{title:"",desc:"",warningText:"",cancelText:"",deleteText:""}}}},emptyStateLearning:{title:"",desc:"",createNewLearning:"",noAccessTitle:"",noAccessDesc:"",requestAccessButton:""},agents:{LearningTerm:""}},a={showScope:!1,showConfiguration:!1,welcomeMessage:"Hi! 👋 I'm your Instant Learning Concierge.",welcomeMessageSubtitle:"How would you like to get started? You can select an option below or describe the rule you'd like to create.",actions:[{label:"Separation rule",value:"I would want to add a separation rule"},{label:"Max priority rule",value:"I would want to set a max priority rule"},{label:"Break code matching",value:"I would want to add a break code matching rule"},{label:"Inventory code matching",value:"I would want to add a inventory window matching rule"},{label:"Enter a rule description",value:"I want to add a rule description"},{label:"Tester Genie",value:"Loading prompt..."}],chatTitle:"Teach Me OTJ - {scope} - Add Learning",chatTitleEdit:"Teach Me OTJ - {scope} - Edit Learning",formTitle:"Rule setup",setupLabel:"Configure your IL",ruleTitle:"Main Rule Name",scopeLabel:"Define Scope",tierLabel:"Select Tiers",ruleDescriptionTitle:"Learning Explanation",whenToApplyTitle:"Trigger Events (When to Apply)",addWhenToApplyBtnLabel:"Add WTA",whenNotToApplyTitle:"Exclusion Events (When NOT to Apply)",addWhenNotToApplyBtnLabel:"Add WNTA",configTitle:"Advanced Settings",saveBtnLabel:"Save Rule",saveBtnLoadingLabel:"Saving Rule...",chatTextareaPlaceholder:"Tell me more about this learning.."},i=e.create(function(e){return{lmsConfig:n,setLMSConfig:function(t){return e({lmsConfig:t})},clearLMSConfig:function(){return e({lmsConfig:n})}}});var l=e.create(function(e){return{teachMeConfig:null,setTeachMeConfig:function(t){return e({teachMeConfig:t})},clearTeachMeConfig:function(){return e({teachMeConfig:null})}}});exports.defaultLMSConfig=n,exports.defaultTeachMeConfig=a,exports.dt=function(e,n,a){if(t.useLearningTemplateStore.getState().backwardCompatibility)return null!=n?n:"";var l=i.getState().lmsConfig,o=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},l);return"string"!=typeof o||""===o?null!=n?n:e:o.replace(/\{(\w+)\}/g,function(e,t){var n;return String(null!==(n=null==a?void 0:a[t])&&void 0!==n?n:"{".concat(t,"}"))})},exports.dtt=function(e,t,n){var a=l.getState().teachMeConfig,i=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},a);return"string"!=typeof i?null!=t?t:e:i.replace(/\{(\w+)\}/g,function(e,t){var a;return String(null!==(a=null==n?void 0:n[t])&&void 0!==a?a:"{".concat(t,"}"))})},exports.dttWelcomeMessageParts=function(){var e,t,n=null!==(e=l.getState().teachMeConfig)&&void 0!==e?e:a;return{greeting:n.welcomeMessage||a.welcomeMessage,subtitle:n.welcomeMessageSubtitle||a.welcomeMessageSubtitle,actions:(null===(t=n.actions)||void 0===t?void 0:t.length)?n.actions:a.actions}},exports.useLMSConfigStore=i,exports.useTeachMeConfigStore=l;
|
|
2
2
|
//# sourceMappingURL=useLMSConfigStore.js.map
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./features/InstantLearning/InstantLearning.js"),t=require("./features/WtaWnta/WtaWnta.js"),r=require("./features/DocumentLearning/DocumentLearning.js"),o=require("./features/IL-OTJ/ILOTJ.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./features/InstantLearning/InstantLearning.js"),t=require("./features/WtaWnta/WtaWnta.js"),r=require("./features/DocumentLearning/DocumentLearning.js"),o=require("./features/IL-OTJ/ILOTJ.js"),s=require("./features/IL-OTJ/_components/atoms/Button/Button.js"),n=require("./features/IL-OTJ/_components/atoms/Dropdown/Dropdown.js"),a=require("./features/IL-OTJ/_components/atoms/Toggle/Toggle.js"),i=require("./features/IL-OTJ/_components/atoms/Textarea/Textarea.js"),p=require("./features/IL-OTJ/_components/molecules/Condition/ConditionList.js"),u=require("./features/IL-OTJ/_components/molecules/Sections/SectionWrapper.js"),c=require("./features/IL-OTJ/_components/molecules/SeperationRow/SeparationRow.js"),T=require("./features/IL-OTJ/_components/organisms/ConfigSection/ConfigSection.js"),x=require("./features/IL-OTJ/_components/organisms/TextSection/TextSection.js"),m=require("./features/IL-OTJ/_components/organisms/ScopeSection/ScopeSection.js"),f=require("./features/IL-OTJ/_components/organisms/ConditionSection/ConditionSection.js"),g=require("./features/IL-OTJ/_components/templates/TrafficManager/TrafficManagerTemplate.js"),l=require("./features/IL-OTJ/_components/templates/Testing/Testing.js"),d=require("./features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js"),L=require("./features/IL-OTJ/helpers/utils.js"),I=require("./features/IL-OTJ/store/CitationsContext.js"),S=require("./features/IL-OTJ/ILOTJTest.js"),j=require("./features/LearningManagement/LearningManagement.js"),O=require("./features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js");require("tslib"),require("react/jsx-runtime"),exports.InstantLearning=e.default,exports.WtaWnta=t.default,exports.BookLearning=r.default,exports.ILOTJ=o.default,exports.Button=s.Button,exports.Dropdown=n.Dropdown,exports.Toggle=a.Toggle,exports.Textarea=i.Textarea,exports.ConditionList=p.ConditionList,exports.SectionWrapper=u.SectionWrapper,exports.SeparationRow=c.SeparationRow,exports.ConfigSection=T.ConfigSection,exports.TextSection=x.TextSection,exports.ScopeSection=m.ScopeSection,exports.ConditionSection=f.ConditionSection,exports.TrafficManagerTemplate=g.TrafficManagerTemplate,exports.Testing=l.Testing,Object.defineProperty(exports,"TemplateList",{enumerable:!0,get:function(){return d.TemplateList}}),exports.TemplateMap=d.TemplateMap,exports.extractAndParseResponse=L.extractAndParseResponse,exports.extractAndParseWithProperty=L.extractAndParseWithProperty,exports.extractTextFromChildren=L.extractTextFromChildren,exports.extractVariantIds=L.extractVariantIds,exports.parseValidationData=L.parseValidationData,exports.useHeaderObserver=L.useHeaderObserver,exports.CitationProvider=I.CitationProvider,exports.useCitations=I.useCitations,exports.dummyDat=S.dummyDat,exports.getVariantInfo=S.getVariantInfo,exports.LearningManagement=j.default,exports.TeachMePlugin=O.default,exports.TemplateRegistry=O.TemplateRegistry;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as i}from"react/jsx-runtime";import r from"./TeachMeWrapper.js";import
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as i}from"react/jsx-runtime";import{useEffect as n}from"react";import r from"./TeachMeWrapper.js";import t from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import o from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";import a from"../../../plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js";import{useTeachMeConfigStore as l}from"../../LearningManagement/store/useLMSConfigStore.js";import{useLearningTemplateStore as u}from"../../LearningManagement/store/useLearningTemplateStore.js";var s={Default:t,"Radio Traffic Learning":o,Guidelines:a},p=function(t){var o,a=t.app_integration_id,p=t.isOpen,f=t.onClose,m=t.pluginPayload,d=t.token,g=t.mode,c=l(function(e){return e.setTeachMeConfig});return l(function(e){return e.clearTeachMeConfig}),n(function(){(null==m?void 0:m.teachMe)&&c(m.teachMe),(null==m?void 0:m.tiers)&&u.getState().setTiers(null==m?void 0:m.tiers)},[m]),i(r,{app_integration_id:a,isOpen:p,onClose:f,token:d,templateRegistry:s,initialScope:null!==(o=null==m?void 0:m.initialScope)&&void 0!==o?o:"",ruleSet:null==m?void 0:m.ruleSet,pluginPayload:e(e({},m),{mode:g})})};export{s as TemplateRegistry,p as default};
|
|
2
2
|
//# sourceMappingURL=TeachMePlugin.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i}from"tslib";import{jsxs as e,jsx as n}from"react/jsx-runtime";import t,{useState as o,useEffect as l}from"react";import{InputDataReasoningCard as r}from"../../InputDataReasoningCard.js";import{ConditionSection as a}from"../../organisms/ConditionSection/ConditionSection.js";import{ConfigSection as d}from"../../organisms/ConfigSection/ConfigSection.js";import{ScopeSection as c}from"../../organisms/ScopeSection/ScopeSection.js";import{TextSection as u}from"../../organisms/TextSection/TextSection.js";import s from"../../AccordianSection.js";import{ButtonCognitiveIcon as v}from"../../_svg/ButtonCognitiveIcon.js";import{Loader2Icon as p,Pencil as f,Check as g,AlertTriangle as h}from"lucide-react";var y=function(o){var l=o.children,r=o.onAddVariant,a=o.isDisabled,d=o.showAddVariantBtn,c=void 0===d||d,u=t.Children.toArray(l);return e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[u.map(function(i,o){var l=!(o===u.length-1)||c;return e(t.Fragment,{children:[i,l&&n("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},o)}),c&&n("div",i({onClick:a?void 0:r,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:a?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:a?"not-allowed":"pointer",backgroundColor:a?"#f8fafc":"#FFFFFF",opacity:a?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))},m=function(m){var T,x,D,S,A,C,I,b,O,w,E,V,R=m.state,_=m.handlers,N=m.uiState,W=(null==N?void 0:N.highlights)||new Map,L=W.get("global_0")||{},B=o({}),F=B[0],M=B[1],j=o(null),k=j[0],z=j[1],q=o(function(){var i,e,n;if((null==N?void 0:N.defaultTierOpen)>=0&&(null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i[N.defaultTierOpen]))return N.tierOptions[N.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});q[0];var P=q[1],J="rule-setup"===(null==N?void 0:N.activeEditId),H=t.useRef(new Map),K=o(null),$=K[0],U=K[1],Z=o(null),G=Z[0],Q=Z[1],X=o(!1),Y=X[0],ii=X[1],ei=t.useRef(null==N?void 0:N.isAiStreaming);l(function(){ei.current&&!(null==N?void 0:N.isAiStreaming)&&Y&&ii(!1),ei.current=null==N?void 0:N.isAiStreaming},[null==N?void 0:N.isAiStreaming,Y]);var ni=function(){var i;U(null),Q(null),null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null)},ti=function(){var i,e,n=null!=$?$:R.ruleTitle,t=null!=G?G:R.scopeData,o=n!==R.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(R.scopeData);if(!o&&!l)return U(null),Q(null),void(null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null));if(null==N?void 0:N.setSendMessageInChat){var r="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),a=[];if(o&&a.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),l){var d=null==t?void 0:t.tiers,c=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";a.push(c)}var u=a.join(" and ");N.setSendMessageInChat("__SKELETON__:".concat(r,":Update Rule Setup ").concat(u))}ii(!0),U(null),Q(null),null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,null)},oi=null!==$?null==$?void 0:$.trim():(R.ruleTitle||"").trim(),li=null!=G?G:R.scopeData,ri=oi!==(R.ruleTitle||"").trim(),ai=JSON.stringify(li)!==JSON.stringify(R.scopeData),di=!ri&&!ai||""===oi,ci=t.useRef(null==N?void 0:N.defaultVariantOpen),ui=t.useRef(null==N?void 0:N.activeVariantAccordionIndex),si=t.useRef(null==N?void 0:N.defaultTierOpen),vi=t.useRef(null===(T=R.scopeData)||void 0===T?void 0:T.tiers),pi=t.useRef(R.variantsByTier);t.useEffect(function(){var i,e,n,t,o,l,r=null,a=!1;ci.current!==(null==N?void 0:N.defaultVariantOpen)&&(a=!0,ci.current=null==N?void 0:N.defaultVariantOpen),ui.current!==(null==N?void 0:N.activeVariantAccordionIndex)&&(a=!0,ui.current=null==N?void 0:N.activeVariantAccordionIndex),si.current!==(null==N?void 0:N.defaultTierOpen)&&(a=!0,si.current=null==N?void 0:N.defaultTierOpen);var d=(null===(i=R.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(vi.current)!==JSON.stringify(d)&&(a=!0,vi.current=d,d.length>0&&P(d[0].toLowerCase().replace(/ /g,"_")));var c=(null===(e=null==N?void 0:N.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||[],u=c.some(function(i){var e,n,t,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=pi.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=R.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(a=!0),a){var s=null!==(n=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==n?n:null==N?void 0:N.defaultVariantOpen;if(null==s||s<0)return z(null),void(pi.current=R.variantsByTier);c.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[];o[s]&&(r="".concat(t,"-variant-").concat(s)),null!=(null==N?void 0:N.autoScrollVariantIndex)&&o[N.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(N.autoScrollVariantIndex))}}),r&&z(r)}if(null===k){var v=null!==(t=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==t?t:null==N?void 0:N.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==N?void 0:N.tierOptions)||void 0===o?void 0:o.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===l||l.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&z("".concat(t,"-variant-").concat(v))}}))}pi.current=R.variantsByTier},[R.variantsByTier,null==N?void 0:N.defaultVariantOpen,null==N?void 0:N.activeVariantAccordionIndex,null===(x=R.scopeData)||void 0===x?void 0:x.tiers,null==N?void 0:N.tierOptions,null==N?void 0:N.autoScrollVariantIndex,null==N?void 0:N.defaultTierOpen]);var fi=function(e){M(function(n){var t;return i(i({},n),((t={})[e]=!n[e],t))})},gi=function(i){var e,n,t,o=i.split("_"),l=o[o.length-1],r=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,a=null===(e=R.fieldCitations)||void 0===e?void 0:e[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(n=R.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=R.citations)&&void 0!==t?t:[]},hi={marginTop:"-17px",position:"relative",zIndex:1};l(function(){var i,e;null!=(null==N?void 0:N.autoScrollVariantIndex)&&(null===(e=null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===e||e.forEach(function(i){var e=i.toLowerCase().replace(/ /g,"_"),n="".concat(e,"-variant-").concat(N.autoScrollVariantIndex),t=H.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==N?void 0:N.scrollTrigger]),console.log("CreateRule state:",R),console.log("CreateRule uiState:",N);var yi=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"},mi=!!(null==N?void 0:N.activeEditId);return e("div",i({className:"traffic-manager-template"},{children:[n("div",i({"data-edit-id":"rule-setup"},{children:n(s,i({title:{type:"other",label:(null==N?void 0:N.setupLabel)||"Rule Setup"},actionButtons:function(e,t){if(J)return null;var o=!!(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId;return n("div",i({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:n("button",i({title:o?"Save active edits first":"Edit",onClick:function(n){n.stopPropagation(),o?(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(N.activeEditId||null):(!function(){var e,n;(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId||(null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,"rule-setup"),U(null!==(n=R.ruleTitle)&&void 0!==n?n:""),Q(R.scopeData?i({},R.scopeData):{}))}(),(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(null),e||t())},disabled:Y,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:Y?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:Y?.5:1}},{children:n(f,{size:14})}))}))},footerData:{ruleTitle:R.ruleTitle,stations:[R.scopeData.station],tiers:null===(D=R.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==N?void 0:N.usedFor),readOnly:"Create"!==(null==N?void 0:N.usedFor),isAiStreaming:null==N?void 0:N.isAiStreaming,editFlow:"Edit"===(null==N?void 0:N.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[Y&&(null==N?void 0:N.isAiStreaming)&&e("div",i({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[n(p,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),n(u,i({id:"rule-title",title:N.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:J&&null!==$?$:R.ruleTitle,onChange:function(i){return J?U(i):_.setRuleTitle(i)},readOnly:(null==N?void 0:N.isAiStreaming)||!J,isOpen:F.ruleTitle,onToggle:function(){return fi("ruleTitle")},isHighlighted:L.ruleTitle||!1,showCognitiveIcon:R.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(S=N.validationErrors)||void 0===S?void 0:S.ruleTitle},N)),R.citation.ruleTitle&&n("div",i({style:hi},{children:n(r,{isVisible:F.ruleTitle,citation:R.citation.ruleTitle,citations:gi("ruleTitle"),fieldName:"Rule Title",fieldValue:R.ruleTitle})})),(null===(A=null==N?void 0:N.tierOptions)||void 0===A?void 0:A.length)>1&&n(c,i({id:"scope",title:"",required:!1,scopeData:J&&null!==G?G:R.scopeData,onScopeChange:function(e,n){J?Q(function(t){var o;return i(i({},null!=t?t:R.scopeData),((o={})[e]=n,o))}):_.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:L,isOpen:F.scopeData,onToggle:function(){return fi("scopeData")},showCognitiveIcon:R.citation.scopeData,cognitiveIcon:n(v,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(C=N.validationErrors)||void 0===C?void 0:C.station)||(null===(I=N.validationErrors)||void 0===I?void 0:I.tiers),stationErrorMessage:null===(b=N.validationErrors)||void 0===b?void 0:b.station,tierErrorMessage:null===(O=N.validationErrors)||void 0===O?void 0:O.tiers,readOnly:(null==N?void 0:N.isAiStreaming)||!J},N)),R.citation.scopeData&&n("div",i({style:hi},{children:n(r,{isVisible:F.scopeData,citation:R.citation.scopeData,citations:gi("scopeData"),fieldName:"Scope",fieldValue:null===(E=null===(w=R.scopeData)||void 0===w?void 0:w.tiers)||void 0===E?void 0:E.join(", ")})})),J?e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[n("button",i({onClick:ni,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:ti,disabled:di,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:di?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:di?.5:1}},{children:[n(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==N?void 0:N.pendingEditId)&&e("div",i({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[n(h,{size:14,style:{color:"#C2410C"}}),n("div",i({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),null===(V=null==N?void 0:N.tierOptions)||void 0===V?void 0:V.map(function(o,l){var c,v,p,f,g,h,m,T=o.toLowerCase().replace(/ /g,"_"),x=(null===(c=R.variantsByTier)||void 0===c?void 0:c[T])||[],D=null===(p=null===(v=R.scopeData)||void 0===v?void 0:v.tiers)||void 0===p?void 0:p.includes(o),S=x.length,A=!1;if(1===S){var C=x[0],I=!(null===(f=null==C?void 0:C.ruleDescription)||void 0===f?void 0:f.trim()),b=(null===(g=null==C?void 0:C.whenToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,O=(null===(h=null==C?void 0:C.whenNotToApplyConditions)||void 0===h?void 0:h.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!I||b||O||(A=!0)}var w=A?void 0:"".concat(S," ").concat(1===S?"variant":"variants"," configured for this tier"),E=n(y,i({onAddVariant:function(){var i;return null===(i=_.addNewVariant)||void 0===i?void 0:i.call(_,T)},isDisabled:!D||(null==N?void 0:N.isAiStreaming),showAddVariantBtn:"Edit"!==(null==N?void 0:N.usedFor)},{children:x.map(function(t,o){var l,c,v,p,f,g,h,y,m,x,S=t.variantType||"default",A="".concat(T,"-variant-").concat(o),C=!0===t.is_variant,I="default"===S||"default_variant"===S,b="".concat(T,"_").concat(o),O=W.get(b)||{},w=(null===(c=null===(l=N.separationItemsByTier)||void 0===l?void 0:l[T])||void 0===c?void 0:c.get(o))||[],E=(null===(p=null===(v=N.togglesByTier)||void 0===v?void 0:v[T])||void 0===p?void 0:p.get(o))||[],V=null===(f=null==N?void 0:N.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(T,"-").concat(o)),L=null===(g=null==N?void 0:N.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(T,"-").concat(o)),B=!D||t.isReadOnly||(null==N?void 0:N.isAiStreaming);return n("div",i({ref:function(i){i?H.current.set(A,i):H.current.delete(A)},style:{width:"100%",opacity:D?1:.7}},{children:n(s,i({title:{type:I?"default":"variant",label:yi(S),number:o+1,isNewVariant:C,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:k===A,onToggle:function(){var i,e=k===A;z(e?null:A),null===(i=null==N?void 0:N.setActiveVariantAccordionIndex)||void 0===i||i.call(N,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:t.ruleDescription||""},readOnly:B},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n(u,i({id:"rule-description-".concat(T,"-").concat(o),title:N.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:B||mi&&(null==N?void 0:N.activeEditId)!=="rule-description-".concat(T,"-").concat(o),value:t.ruleDescription||"",onChange:function(i){return _.setRuleDescription(T,o,i)},isOpen:F["ruleDescription-".concat(T)],onToggle:function(){return fi("ruleDescription-".concat(T))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(h=R.citation)||void 0===h?void 0:h["ruleDescription_".concat(T)],tooltipDescription:"Why this Description?",errorMessage:null===(y=N.validationErrors)||void 0===y?void 0:y["ruleDescription-".concat(T,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==N?void 0:N.setSendMessageInChat,isAiStreaming:null==N?void 0:N.isAiStreaming,fieldName:"Rule Description"},N)),(null===(m=R.citation)||void 0===m?void 0:m["ruleDescription_".concat(T)])&&n("div",i({style:hi},{children:n(r,{isVisible:F["ruleDescription-".concat(T)],citation:R.citation["ruleDescription_".concat(T)],citations:gi("ruleDescription_".concat(T,"_").concat(o)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),n(a,i({id:"when-to-apply-".concat(T,"-").concat(o),idPrefix:"condition-wta",title:N.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:B||mi&&!V,conditions:t.whenToApplyConditions||[],onAdd:function(){return _.addWhenToApply(T,o)},onRemove:function(i,e,n){return _.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenToApply(i,e,n,t)},index:o,tierKey:T,isHighlighted:O.wta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenToApply_".concat(T,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:N.isAiStreaming,errorMessage:(null===(x=N.validationErrors)||void 0===x?void 0:x["whenToApply-".concat(T,"-").concat(o)])||(null==N?void 0:N.conflictReason)},N)),n(a,i({id:"when-not-to-apply-".concat(T,"-").concat(o),idPrefix:"condition-wnta",title:N.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:B||mi&&!L,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return _.addWhenNotToApply(T,o)},onRemove:function(i,e,n){return _.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenNotToApply(i,e,n,t)},index:o,tierKey:T,isHighlighted:O.wnta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenNotToApply_".concat(T,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:N.isAiStreaming},N)),(null==N?void 0:N.showConfiguration)&&n(d,i({id:"config-".concat(T,"-").concat(o),title:N.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:B||mi&&(null==N?void 0:N.activeEditId)!=="config-".concat(T,"-").concat(o),onConfigChange:function(i,e){return _.onConfigChange(T,o,i,e)},separationItems:w,toggles:E,index:o},N))]}))}),A)}),"".concat(T,"-variant-").concat(o))})}));return 1===(null===(m=null==N?void 0:N.tierOptions)||void 0===m?void 0:m.length)?n(t.Fragment,{children:E},"tier-".concat(l)):n(s,i({variant:"tier-header",title:{type:"other",label:o},subtitle:w,defaultOpen:!0,footerData:{description:"Variants for ".concat(o)}},{children:E}),"tier-".concat(l))})]}))};export{m as CreateRule};
|
|
1
|
+
import{__assign as i}from"tslib";import{jsxs as e,jsx as n}from"react/jsx-runtime";import t,{useState as o,useEffect as l}from"react";import{InputDataReasoningCard as r}from"../../InputDataReasoningCard.js";import{ConditionSection as a}from"../../organisms/ConditionSection/ConditionSection.js";import{ConfigSection as d}from"../../organisms/ConfigSection/ConfigSection.js";import{ScopeSection as c}from"../../organisms/ScopeSection/ScopeSection.js";import{TextSection as u}from"../../organisms/TextSection/TextSection.js";import s from"../../AccordianSection.js";import{ButtonCognitiveIcon as v}from"../../_svg/ButtonCognitiveIcon.js";import{Loader2Icon as p,Pencil as f,Check as g,AlertTriangle as h}from"lucide-react";var y=function(o){var l=o.children,r=o.onAddVariant,a=o.isDisabled,d=o.showAddVariantBtn,c=void 0===d||d,u=t.Children.toArray(l);return e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[u.map(function(i,o){var l=!(o===u.length-1)||c;return e(t.Fragment,{children:[i,l&&n("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},o)}),c&&n("div",i({onClick:a?void 0:r,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:a?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:a?"not-allowed":"pointer",backgroundColor:a?"#f8fafc":"#FFFFFF",opacity:a?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))},m=function(m){var T,x,D,S,A,C,I,b,O,w,E,V,R=m.state,_=m.handlers,N=m.uiState,W=(null==N?void 0:N.highlights)||new Map,L=W.get("global_0")||{},B=o({}),F=B[0],M=B[1],j=o(null),k=j[0],z=j[1],q=o(function(){var i,e,n;if((null==N?void 0:N.defaultTierOpen)>=0&&(null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i[N.defaultTierOpen]))return N.tierOptions[N.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});q[0];var P=q[1],J="rule-setup"===(null==N?void 0:N.activeEditId),H=t.useRef(new Map),K=o(null),$=K[0],U=K[1],Z=o(null),G=Z[0],Q=Z[1],X=o(!1),Y=X[0],ii=X[1],ei=t.useRef(null==N?void 0:N.isAiStreaming);l(function(){ei.current&&!(null==N?void 0:N.isAiStreaming)&&Y&&ii(!1),ei.current=null==N?void 0:N.isAiStreaming},[null==N?void 0:N.isAiStreaming,Y]);var ni=function(){var i;U(null),Q(null),null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null)},ti=function(){var i,e,n=null!=$?$:R.ruleTitle,t=null!=G?G:R.scopeData,o=n!==R.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(R.scopeData);if(!o&&!l)return U(null),Q(null),void(null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null));if(null==N?void 0:N.setSendMessageInChat){var r="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),a=[];if(o&&a.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),l){var d=null==t?void 0:t.tiers,c=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";a.push(c)}var u=a.join(" and ");N.setSendMessageInChat("__SKELETON__:".concat(r,":Update Rule Setup ").concat(u))}ii(!0),U(null),Q(null),null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,null)},oi=null!==$?null==$?void 0:$.trim():(R.ruleTitle||"").trim(),li=null!=G?G:R.scopeData,ri=oi!==(R.ruleTitle||"").trim(),ai=JSON.stringify(li)!==JSON.stringify(R.scopeData),di=!ri&&!ai||""===oi,ci=t.useRef(null==N?void 0:N.defaultVariantOpen),ui=t.useRef(null==N?void 0:N.activeVariantAccordionIndex),si=t.useRef(null==N?void 0:N.defaultTierOpen),vi=t.useRef(null===(T=R.scopeData)||void 0===T?void 0:T.tiers),pi=t.useRef(R.variantsByTier);t.useEffect(function(){var i,e,n,t,o,l,r=null,a=!1;ci.current!==(null==N?void 0:N.defaultVariantOpen)&&(a=!0,ci.current=null==N?void 0:N.defaultVariantOpen),ui.current!==(null==N?void 0:N.activeVariantAccordionIndex)&&(a=!0,ui.current=null==N?void 0:N.activeVariantAccordionIndex),si.current!==(null==N?void 0:N.defaultTierOpen)&&(a=!0,si.current=null==N?void 0:N.defaultTierOpen);var d=(null===(i=R.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(vi.current)!==JSON.stringify(d)&&(a=!0,vi.current=d,d.length>0&&P(d[0].toLowerCase().replace(/ /g,"_")));var c=(null===(e=null==N?void 0:N.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||[],u=c.some(function(i){var e,n,t,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=pi.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=R.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(a=!0),a){var s=null!==(n=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==n?n:null==N?void 0:N.defaultVariantOpen;if(null==s||s<0)return z(null),void(pi.current=R.variantsByTier);c.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[];o[s]&&(r="".concat(t,"-variant-").concat(s)),null!=(null==N?void 0:N.autoScrollVariantIndex)&&o[N.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(N.autoScrollVariantIndex))}}),r&&z(r)}if(null===k){var v=null!==(t=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==t?t:null==N?void 0:N.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==N?void 0:N.tierOptions)||void 0===o?void 0:o.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===l||l.forEach(function(i,e){var n;if(!((null==N?void 0:N.defaultTierOpen)>=0&&e!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=R.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&z("".concat(t,"-variant-").concat(v))}}))}pi.current=R.variantsByTier},[R.variantsByTier,null==N?void 0:N.defaultVariantOpen,null==N?void 0:N.activeVariantAccordionIndex,null===(x=R.scopeData)||void 0===x?void 0:x.tiers,null==N?void 0:N.tierOptions,null==N?void 0:N.autoScrollVariantIndex,null==N?void 0:N.defaultTierOpen]);var fi=function(e){M(function(n){var t;return i(i({},n),((t={})[e]=!n[e],t))})},gi=function(i){var e,n,t,o=i.split("_"),l=o[o.length-1],r=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,a=null===(e=R.fieldCitations)||void 0===e?void 0:e[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(n=R.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=R.citations)&&void 0!==t?t:[]},hi={marginTop:"-17px",position:"relative",zIndex:1};l(function(){var i,e;null!=(null==N?void 0:N.autoScrollVariantIndex)&&(null===(e=null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=R.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===e||e.forEach(function(i){var e=i.toLowerCase().replace(/ /g,"_"),n="".concat(e,"-variant-").concat(N.autoScrollVariantIndex),t=H.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==N?void 0:N.scrollTrigger]),console.log("CreateRule state:",R),console.log("CreateRule uiState:",N);var yi=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"},mi=!!(null==N?void 0:N.activeEditId);return e("div",i({className:"traffic-manager-template"},{children:[n("div",i({"data-edit-id":"rule-setup"},{children:n(s,i({title:{type:"other",label:(null==N?void 0:N.setupLabel)||"Rule Setup"},actionButtons:function(e,t){if(J)return null;var o=!!(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId;return n("div",i({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:n("button",i({title:o?"Save active edits first":"Edit",onClick:function(n){n.stopPropagation(),o?(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(N.activeEditId||null):(!function(){var e,n;(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId||(null===(e=null==N?void 0:N.setActiveEditId)||void 0===e||e.call(N,"rule-setup"),U(null!==(n=R.ruleTitle)&&void 0!==n?n:""),Q(R.scopeData?i({},R.scopeData):{}))}(),(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(null),e||t())},disabled:Y,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:Y?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:Y?.5:1}},{children:n(f,{size:14})}))}))},footerData:{ruleTitle:R.ruleTitle,stations:[R.scopeData.station],tiers:null===(D=R.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==N?void 0:N.usedFor),readOnly:"Create"!==(null==N?void 0:N.usedFor),isAiStreaming:null==N?void 0:N.isAiStreaming,editFlow:"Edit"===(null==N?void 0:N.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[Y&&(null==N?void 0:N.isAiStreaming)&&e("div",i({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[n(p,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),n(u,i({id:"rule-title",title:N.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:J&&null!==$?$:R.ruleTitle,onChange:function(i){return J?U(i):_.setRuleTitle(i)},readOnly:(null==N?void 0:N.isAiStreaming)||!J,isOpen:F.ruleTitle,onToggle:function(){return fi("ruleTitle")},isHighlighted:L.ruleTitle||!1,showCognitiveIcon:R.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(S=N.validationErrors)||void 0===S?void 0:S.ruleTitle},N)),R.citation.ruleTitle&&n("div",i({style:hi},{children:n(r,{isVisible:F.ruleTitle,citation:R.citation.ruleTitle,citations:gi("ruleTitle"),fieldName:"Rule Title",fieldValue:R.ruleTitle})})),(null===(A=null==N?void 0:N.tierOptions)||void 0===A?void 0:A.length)>1&&n(c,i({id:"scope",title:"",required:!1,scopeData:J&&null!==G?G:R.scopeData,onScopeChange:function(e,n){J?Q(function(t){var o;return i(i({},null!=t?t:R.scopeData),((o={})[e]=n,o))}):_.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:L,isOpen:F.scopeData,onToggle:function(){return fi("scopeData")},showCognitiveIcon:R.citation.scopeData,cognitiveIcon:n(v,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(C=N.validationErrors)||void 0===C?void 0:C.station)||(null===(I=N.validationErrors)||void 0===I?void 0:I.tiers),stationErrorMessage:null===(b=N.validationErrors)||void 0===b?void 0:b.station,tierErrorMessage:null===(O=N.validationErrors)||void 0===O?void 0:O.tiers,readOnly:(null==N?void 0:N.isAiStreaming)||!J},N)),R.citation.scopeData&&n("div",i({style:hi},{children:n(r,{isVisible:F.scopeData,citation:R.citation.scopeData,citations:gi("scopeData"),fieldName:"Scope",fieldValue:null===(E=null===(w=R.scopeData)||void 0===w?void 0:w.tiers)||void 0===E?void 0:E.join(", ")})})),J?e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[n("button",i({onClick:ni,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:ti,disabled:di,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:di?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:di?.5:1}},{children:[n(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==N?void 0:N.pendingEditId)&&e("div",i({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[n(h,{size:14,style:{color:"#C2410C"}}),n("div",i({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),null===(V=null==N?void 0:N.tierOptions)||void 0===V?void 0:V.map(function(o,l){var c,v,p,f,g,h,m,T=o.toLowerCase().replace(/ /g,"_"),x=(null===(c=R.variantsByTier)||void 0===c?void 0:c[T])||[],D=null===(p=null===(v=R.scopeData)||void 0===v?void 0:v.tiers)||void 0===p?void 0:p.includes(o),S=x.length,A=!1;if(1===S){var C=x[0],I=!(null===(f=null==C?void 0:C.ruleDescription)||void 0===f?void 0:f.trim()),b=(null===(g=null==C?void 0:C.whenToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,O=(null===(h=null==C?void 0:C.whenNotToApplyConditions)||void 0===h?void 0:h.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!I||b||O||(A=!0)}var w=A?void 0:"".concat(S," ").concat(1===S?"variant":"variants"," configured for this tier"),E=n(y,i({onAddVariant:function(){var i;return null===(i=_.addNewVariant)||void 0===i?void 0:i.call(_,T)},isDisabled:!D||(null==N?void 0:N.isAiStreaming),showAddVariantBtn:"Edit"!==(null==N?void 0:N.usedFor)},{children:x.map(function(t,o){var l,c,v,p,f,g,h,y,m,x,S=t.variantType||"default",A="".concat(T,"-variant-").concat(o),C=!0===t.is_variant,I="default"===S||"default_variant"===S,b="".concat(T,"_").concat(o),O=W.get(b)||{},w=(null===(c=null===(l=N.separationItemsByTier)||void 0===l?void 0:l[T])||void 0===c?void 0:c.get(o))||[],E=(null===(p=null===(v=N.togglesByTier)||void 0===v?void 0:v[T])||void 0===p?void 0:p.get(o))||[],V=null===(f=null==N?void 0:N.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(T,"-").concat(o)),L=null===(g=null==N?void 0:N.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(T,"-").concat(o)),B=!D||t.isReadOnly||(null==N?void 0:N.isAiStreaming);return n("div",i({ref:function(i){i?H.current.set(A,i):H.current.delete(A)},style:{width:"100%",opacity:D?1:.7}},{children:n(s,i({title:{type:I?"default":"variant",label:yi(S),number:o+1,isNewVariant:C,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:1==(null==N?void 0:N.tierOptions.length)||k===A,onToggle:function(){var i,e=k===A;z(e?null:A),null===(i=null==N?void 0:N.setActiveVariantAccordionIndex)||void 0===i||i.call(N,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:t.ruleDescription||""},readOnly:B},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n(u,i({id:"rule-description-".concat(T,"-").concat(o),title:N.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:B||mi&&(null==N?void 0:N.activeEditId)!=="rule-description-".concat(T,"-").concat(o),value:t.ruleDescription||"",onChange:function(i){return _.setRuleDescription(T,o,i)},isOpen:F["ruleDescription-".concat(T)],onToggle:function(){return fi("ruleDescription-".concat(T))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(h=R.citation)||void 0===h?void 0:h["ruleDescription_".concat(T)],tooltipDescription:"Why this Description?",errorMessage:null===(y=N.validationErrors)||void 0===y?void 0:y["ruleDescription-".concat(T,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==N?void 0:N.setSendMessageInChat,isAiStreaming:null==N?void 0:N.isAiStreaming,fieldName:"Rule Description"},N)),(null===(m=R.citation)||void 0===m?void 0:m["ruleDescription_".concat(T)])&&n("div",i({style:hi},{children:n(r,{isVisible:F["ruleDescription-".concat(T)],citation:R.citation["ruleDescription_".concat(T)],citations:gi("ruleDescription_".concat(T,"_").concat(o)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),n(a,i({id:"when-to-apply-".concat(T,"-").concat(o),idPrefix:"condition-wta",title:N.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:B||mi&&!V,conditions:t.whenToApplyConditions||[],onAdd:function(){return _.addWhenToApply(T,o)},onRemove:function(i,e,n){return _.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenToApply(i,e,n,t)},index:o,tierKey:T,isHighlighted:O.wta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenToApply_".concat(T,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:N.isAiStreaming,errorMessage:(null===(x=N.validationErrors)||void 0===x?void 0:x["whenToApply-".concat(T,"-").concat(o)])||(null==N?void 0:N.conflictReason)},N)),n(a,i({id:"when-not-to-apply-".concat(T,"-").concat(o),idPrefix:"condition-wnta",title:N.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:B||mi&&!L,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return _.addWhenNotToApply(T,o)},onRemove:function(i,e,n){return _.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return _.editWhenNotToApply(i,e,n,t)},index:o,tierKey:T,isHighlighted:O.wnta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:gi("whenNotToApply_".concat(T,"_").concat(o)),bordered:!0,addLabel:(null==N?void 0:N.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:N.isAiStreaming},N)),(null==N?void 0:N.showConfiguration)&&n(d,i({id:"config-".concat(T,"-").concat(o),title:N.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:B||mi&&(null==N?void 0:N.activeEditId)!=="config-".concat(T,"-").concat(o),onConfigChange:function(i,e){return _.onConfigChange(T,o,i,e)},separationItems:w,toggles:E,index:o},N))]}))}),A)}),"".concat(T,"-variant-").concat(o))})}));return 1===(null===(m=null==N?void 0:N.tierOptions)||void 0===m?void 0:m.length)?n(t.Fragment,{children:E},"tier-".concat(l)):n(s,i({variant:"tier-header",title:{type:"other",label:o},subtitle:w,defaultOpen:!0,footerData:{description:"Variants for ".concat(o)}},{children:E}),"tier-".concat(l))})]}))};export{m as CreateRule};
|
|
2
2
|
//# sourceMappingURL=CreateRule.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as n,__awaiter as t,__generator as r}from"tslib";import{jsx as o,jsxs as i,Fragment as s}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as l}from"react";import{BookOpen as u,Users as d,History as p}from"lucide-react";import{useLearningTemplateStore as m}from"./store/useLearningTemplateStore.js";import{Toast as f}from"primereact/toast";import v from"./styles/LearningTemplateManagement.module.css.js";import g from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import y from"./store/useAuthStore.js";import{fetchTiers as S,getILInstance as b,fetchScopes as C,inheritScope as T,inheritScopeBackwardCompatible as L,createRuleSet as E,renameScope as I,deleteRuleSet as A,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as O,setQueryParams as j}from"./hooks/useLearningTemplateQueryParams.js";import R from"./components/ConfirmationModal.js";import _ from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as N}from"./utils/treeUtils.js";import k from"./store/useEnvStore.js";import{useConfigStore as D}from"./store/useConfigStore.js";import{TooltipProvider as M}from"./components/ToolTip.js";import P from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as U}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as G}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as B}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as F}from"./queries/useLMSConfigQuery.js";import q from"./RuleContent/AddScopeModal.js";import x from"./components/RuleContentSkeleton.js";import H from"./components/ErrorStateDisplay.js";import{useLocation as Q}from"react-router-dom";import z from"./shared/SuccessToastContent.js";import K from"./shared/ErrorToastContent.js";import V from"./RuleContent/RenameScopeModal.js";import{dt as W}from"./store/useLMSConfigStore.js";import{MIDDLE_DRAWER_DT_PATH as Y,MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH as J}from"./constants.js";function X(X){var Z,$,ee,ne=this,te=X.userDetails,re=X.llmStudioUrl,oe=X.audacyBackendUrl,ie=X.ilLabels,se=X.config,ae=X.rbacConfig,ce=X.auditLogConfig,le=X.app_integration_id,ue=X.backwardCompatibility,de=void 0!==ue&&ue,pe=m(function(e){return e.selectedRuleSetId}),me=m(function(e){return e.setSelectedRuleSetId}),fe=m(function(e){return e.error}),ve=m(function(e){return e.setError}),ge=m(function(e){return e.setStations}),he=m(function(e){return e.scopeTreeData}),ye=m(function(e){return e.setScopeTreeData}),Se=a({isOpen:!1,type:"GLOBAL"}),be=Se[0],Ce=Se[1],Te=a(!1),Le=Te[0],Ee=Te[1],Ie=a(!1),Ae=Ie[0],we=Ie[1],Oe=a("learnings"),je=Oe[0],Re=Oe[1],_e=a(null),Ne=_e[0],ke=_e[1],De=a(null),Me=De[0],Pe=De[1],Ue=c(null),Ge=c(null),Be=c(!1),Fe=c(null),qe=y();qe.user;var xe=qe.setUser,He=D(),Qe=He.setConfig,ze=He.setIlLabels,Ke=function(){try{return Q()}catch(e){return{search:""}}}();l(function(){if(!Be.current){var e=new URLSearchParams(window.location.search),n=e.get(O.RULESET_ID),t=e.get(O.SECTION),r=t&&fn.has(t)?t:"learnings";(null==n?void 0:n.length)&&me&&Re&&(me(n),Re(r),Be.current=!0)}},[null==Ke?void 0:Ke.search,Re,me]);var Ve=U(function(e){return e.fetchPermissions}),We=U(function(e){return e.hasPermission}),Ye=G(function(e){return e.setRoles}),Je=k(function(e){return e.appsecRbacUrl})===ae.appsecRbacUrl,Xe=B(ae.applicationId,Je).data,Ze=F(null!=le?le:"",de),$e=Ze.isLoading,en=Ze.isError,nn=Ze.refetch;Ze.isSuccess;var tn=a(0),rn=tn[0],on=tn[1];l(function(){if(!de&&le&&re){t(ne,void 0,void 0,function(){var e,n,t,o,i;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,b(le)];case 1:return e=r.sent(),"number"==typeof(n=null===(i=null===(o=null==e?void 0:e.learningManagement)||void 0===o?void 0:o.scopeAndHierarchy)||void 0===i?void 0:i.maxHierarchyLevels)&&n>0&&on(n-1),[3,3];case 2:return t=r.sent(),console.error("Failed to fetch IL instance for hierarchy levels:",t),[3,3];case 3:return[2]}})})}},[le,re]),l(function(){Xe&&Ye(Xe.map(function(e){return{_id:e._id,name:e.name}}))},[Xe,Ye]),l(function(){var e;console.log("userDetails",te),xe(te),console.log("llmStudioUrl",re),console.log("audacyBackendUrl",oe),k.getState().setLlmStudioUrl(re),k.getState().setAudacyBackendUrl(oe),k.getState().setRbacConfig(ae),k.getState().setAuditLogConfig(ce),Qe(se),ze(ie),m.getState().setAppIntegrationId(null!=le?le:null),m.getState().setBackwardCompatibility(de),m.getState().setToken(null!==(e=null==te?void 0:te.accessToken)&&void 0!==e?e:null)},[te,xe,re,oe,ae,ce,se,Qe,ie,ze,le,de]),l(function(){(null==te?void 0:te.accessToken)&&re&&S()},[le,null==te?void 0:te.accessToken,re]);var sn=function(n){return void 0===n&&(n=!0),t(ne,void 0,void 0,function(){var t,o,i,s,a,c;return r(this,function(r){switch(r.label){case 0:n&&Ee(!0),ve(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Ve(ae.applicationId)];case 2:return r.sent(),t=function(n){if(!U.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,C(le,te.accessToken)];case 3:return(o=r.sent())&&o.data&&o.data.data&&(i=o.data.data,Array.isArray(i)&&(i=i.length>0?i[0]:null),i?(s=t(i))?(ke(null),ye({data:s}),Ge.current?(me(Ge.current),Re("learnings"),Ge.current=null):m.getState().selectedRuleSetId||me(s.id)):(ke(null!==(c=i.id)&&void 0!==c?c:null),ye(null)):(ke(null),ye(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),ve("Failed to load data. Please try again later."),[3,6];case 5:return Ee(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==te?void 0:te.accessToken)||void 0===e?void 0:e.length)&&Je?sn(!0):console.warn("Error: Trying to fetch rules without access token",te)},[null==te?void 0:te.accessToken,ve,ge,ae.applicationId,Je]);var an=function(n,o,i){return t(ne,void 0,void 0,function(){var t,o,i,s,a,c,l,u;return r(this,function(r){switch(r.label){case 0:we(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,A(n,te.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===n&&(t=m.getState().scopeTreeData,(o=N((null==t?void 0:t.data)||null,n))&&o.length>1&&(i=o[o.length-2],me(i),Re("learnings"))),[4,sn(!0)];case 3:return r.sent(),Ce(function(n){return e(e({},n),{isOpen:!1})}),null===(a=Fe.current)||void 0===a||a.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return s=r.sent(),console.error("An error occurred during scope deletion.",s),null===(c=Fe.current)||void 0===c||c.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(l=null==s?void 0:s.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return we(!1),[7];case 6:return[2]}})})},cn=he,ln=Me?{data:{id:Me.stationId,name:Me.stationName,type:"STATION",metrics:{learningsCount:Me.learningsCount,stationsCount:0},children:[]}}:cn,un=!!(null==ln?void 0:ln.data);null===(Z=null==ln?void 0:ln.data)||void 0===Z||Z.type;var dn=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",ae.applicationResourceId||"");if($e)return o("div",e({className:v.learningManagementContainer},{children:o(x,{})}));if(en)return o("div",e({className:v.learningManagementContainer},{children:o(H,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return nn()},title:"Error Loading Configuration"})}));var pn=n(n([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(W("".concat(Y,".addScope"),"Add Scope")),addChildType:"SCOPE"}],Array.from({length:rn},function(){return e({type:"SCOPE",label:W("".concat(Y,".scope"),"Scope")},!de&&{addChildLabel:W("".concat(J,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})}),!0),de?[]:[{type:"SUBSCOPE",label:W("".concat(Y,".subScope"),"Subscope")}],!0),mn=[{id:"learnings",label:W("".concat(Y,".treeMenu.submenu.learnings"),"Learnings"),icon:u,badgeKey:"learningsCount"},{id:"access",label:W("".concat(Y,".treeMenu.submenu.access"),"Access"),icon:d},{id:"history",label:W("".concat(Y,".treeMenu.submenu.changeHistory"),"Change History"),icon:p}],fn=new Set(mn.map(function(e){return e.id})),vn=Me?mn.filter(function(e){return"stations"!==e.id}):mn;return o(M,{children:i("div",e({className:v.learningManagementContainer},{children:[o("div",e({className:v.mainWrapper},{children:Le?o(_,{}):fe?i("div",e({className:v.errorContainer},{children:[o("div",e({className:v.errorTitle},{children:"Error Loading Data"})),o("p",e({className:v.errorDesc},{children:fe})),o("button",e({onClick:function(){return sn(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):un?o(g,{onOpenCreateModal:function(){return Ce({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,n,t){return Ce({isOpen:!0,type:n,parentId:e,parentName:t})},onRenameChild:function(e,n){return Ce({isOpen:!0,type:"RENAME",scopeId:e,initialName:n})},onDeleteChild:function(e,n,o){return t(ne,void 0,void 0,function(){var t,i,s;return r(this,function(r){switch(r.label){case 0:return t=m.getState().scopeTreeData,i=N((null==t?void 0:t.data)||null,e),s=!!i&&3===i.length,0!==o?[3,2]:[4,an(e)];case 1:return r.sent(),[3,3];case 2:Ce({isOpen:!0,type:"DELETE",scopeId:e,initialName:n,isSubscope:s}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return We("ilotj.scope.delete",e)},canEditScope:function(e){return We("ilotj.scope.edit",e)},canCreateScope:function(e){return We("ilotj.scope.create",e)},onSectionSelect:function(e,n){var t;console.log("Section Selected:",{scopeId:e,sectionId:n}),j(((t={})[O.SECTION]="learnings"===n?null:n,t[O.RULESET_ID]=e,t)),Re(n),me(e)},activeSectionId:je,scopeTreeData:ln,sectionsConfig:vn,onViewStation:function(e){Ue.current=pe,Pe(e),Re("learnings"),me(e.stationId)},onRefreshRuleSets:function(e,n){void 0===e&&(e=!0),n&&(Ge.current=n),sn(e)},nodeTypesConfig:pn,app_integration_id:le,token:te.accessToken}):o(h,{onCreate:function(){return Ce({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope",canCreateRule:dn,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return t(ne,void 0,void 0,function(){var e,n,t,i,s,a,c,l,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(i=null===(t=m.getState().scopeTreeData)||void 0===t?void 0:t.data)||void 0===i?void 0:i.id)||Ne))return null===(s=Fe.current)||void 0===s||s.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:"Unable to identify the global scope for this access request."})}),[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,w(e)];case 2:return r.sent(),null===(a=Fe.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(z,{message:"Access request submitted successfully!"})}),[3,4];case 3:return n=r.sent(),null===(c=Fe.current)||void 0===c||c.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:(null===(u=null===(l=null==n?void 0:n.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),o(f,{ref:Fe,pt:{root:{style:{zIndex:9999}}}}),de&&be.isOpen&&"DELETE"!==be.type&&"RENAME"!==be.type?o(P,{isOpen:!0,onClose:function(){return Ce(e(e({},be),{isOpen:!1}))},onSubmit:function(n){return t(ne,void 0,void 0,function(){var t,o,i,s,a,c,l,u,d,p,f,v,g,h,y,S,b,C,I,A;return r(this,function(r){switch(r.label){case 0:we(!0),t=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof n?o=n:(i=n,s="SCOPE"===be.type&&be.parentId,a=s?"genreRuleSet":be.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:be.parentId||null,scopeName:i,scopeReferenceMetadata:{},applicationMappingId:le}),[4,E(o,te.accessToken)];case 2:if(c=r.sent(),!(l=null===(h=null==c?void 0:c.data)||void 0===h?void 0:h.scopeId))return[3,10];if(Ge.current=l,u=t&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!t&&"GLOBAL"!==be.type&&be.parentId,!u&&!d)return[3,10];if(!(p=t?null===(b=null===(S=m.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===b?void 0:b.id:be.parentId))return[3,10];if(!de)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,L({source_scope_id:p,target_scope_id:l})];case 4:return r.sent(),[3,6];case 5:return f=r.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return r.trys.push([7,9,,10]),[4,T({source_scope_id:p,target_scope_id:l,application_mapping_id:le||"",is_copy_parent_variant_id:!1})];case 8:return r.sent(),[3,10];case 9:return v=r.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,sn(!0)];case 11:return r.sent(),Ce(function(n){return e(e({},n),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(C=Fe.current)||void 0===C||C.show({severity:"error",summary:"Creation Failed",detail:(null===(A=null===(I=null==g?void 0:g.response)||void 0===I?void 0:I.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),g;case 13:return we(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:un,canCreateGlobal:dn,globalScopeId:null!==(ee=null===($=null==he?void 0:he.data)||void 0===$?void 0:$.id)&&void 0!==ee?ee:null}):i(s,{children:[o(q,{isOpen:be.isOpen&&"DELETE"!==be.type&&"RENAME"!==be.type,onClose:function(){return Ce(e(e({},be),{isOpen:!1}))},onCreate:function(e){e&&(Ge.current=e),sn(!0)},hasGlobalRuleSet:un,parentId:be.parentId}),o(V,{isOpen:be.isOpen&&"RENAME"===be.type,onClose:function(){return Ce(e(e({},be),{isOpen:!1}))},onSave:function(n){return t(ne,void 0,void 0,function(){var t,i,s,a,c,l;return r(this,function(r){switch(r.label){case 0:we(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),be.scopeId?(t=m.getState().backwardCompatibility,i=t?{scope_id:be.scopeId,scope_name:n}:{scope_id:be.scopeId,scope_type:"Custom",scope_name:n,description:"demo",application_mapping_id:le},[4,I(i,te.accessToken)]):[2];case 2:return r.sent(),[4,sn(!0)];case 3:return r.sent(),Ce(function(n){return e(e({},n),{isOpen:!1})}),[3,6];case 4:throw s=r.sent(),console.error("An error occurred during scope rename.",s),null===(a=Fe.current)||void 0===a||a.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:(null===(l=null===(c=null==s?void 0:s.response)||void 0===c?void 0:c.data)||void 0===l?void 0:l.message)||"There was an error renaming the scope. Please try again."})}),s;case 5:return we(!1),[7];case 6:return[2]}})})},initialName:be.initialName})]}),o(R,{isOpen:be.isOpen&&"DELETE"===be.type,onCancel:function(){return Ce(e(e({},be),{isOpen:!1}))},onConfirm:function(){return an(be.scopeId,be.initialName,be.isSubscope)},title:"Delete Scope",description:i(s,{children:["Deleting ",o("span",e({className:v.highlight},{children:be.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:Ae})]}))})}export{X as default};
|
|
1
|
+
import{__assign as e,__spreadArray as n,__awaiter as t,__generator as r}from"tslib";import{jsx as o,jsxs as s,Fragment as i}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as l}from"react";import{BookOpen as u,Users as d,History as p}from"lucide-react";import{useLearningTemplateStore as m}from"./store/useLearningTemplateStore.js";import{Toast as f}from"primereact/toast";import v from"./styles/LearningTemplateManagement.module.css.js";import g from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import y from"./store/useAuthStore.js";import{fetchTiers as S,getILInstance as b,fetchScopes as C,inheritScope as T,inheritScopeBackwardCompatible as L,createRuleSet as A,renameScope as E,deleteRuleSet as I,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as O,setQueryParams as R}from"./hooks/useLearningTemplateQueryParams.js";import j from"./components/ConfirmationModal.js";import N from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as _}from"./utils/treeUtils.js";import k from"./store/useEnvStore.js";import{useConfigStore as D}from"./store/useConfigStore.js";import{TooltipProvider as M}from"./components/ToolTip.js";import P from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as U}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as B}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as F}from"./queries/useLMSConfigQuery.js";import q from"./RuleContent/AddScopeModal.js";import x from"./components/RuleContentSkeleton.js";import H from"./components/ErrorStateDisplay.js";import{useLocation as Q}from"react-router-dom";import z from"./shared/SuccessToastContent.js";import K from"./shared/ErrorToastContent.js";import V from"./RuleContent/RenameScopeModal.js";import{dt as W}from"./store/useLMSConfigStore.js";import{MIDDLE_DRAWER_DT_PATH as Y,MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH as J,EMPTY_STATE_DT_PATH as X}from"./constants.js";function Z(Z){var $,ee,ne,te=this,re=Z.userDetails,oe=Z.llmStudioUrl,se=Z.audacyBackendUrl,ie=Z.ilLabels,ae=Z.config,ce=Z.rbacConfig,le=Z.auditLogConfig,ue=Z.app_integration_id,de=Z.backwardCompatibility,pe=void 0!==de&&de,me=Z.modeId,fe=m(function(e){return e.selectedRuleSetId}),ve=m(function(e){return e.setSelectedRuleSetId}),ge=m(function(e){return e.error}),he=m(function(e){return e.setError}),ye=m(function(e){return e.setStations}),Se=m(function(e){return e.scopeTreeData}),be=m(function(e){return e.setScopeTreeData}),Ce=a({isOpen:!1,type:"GLOBAL"}),Te=Ce[0],Le=Ce[1],Ae=a(!1),Ee=Ae[0],Ie=Ae[1],we=a(!1),Oe=we[0],Re=we[1],je=a("learnings"),Ne=je[0],_e=je[1],ke=a(null),De=ke[0],Me=ke[1],Pe=a(null),Ue=Pe[0],Be=Pe[1],Ge=c(null),Fe=c(null),qe=c(!1),xe=c(null),He=y();He.user;var Qe=He.setUser,ze=D(),Ke=ze.setConfig,Ve=ze.setIlLabels,We=function(){try{return Q()}catch(e){return{search:""}}}();l(function(){if(!qe.current){var e=new URLSearchParams(window.location.search),n=e.get(O.RULESET_ID),t=e.get(O.SECTION),r=t&&gn.has(t)?t:"learnings";(null==n?void 0:n.length)&&ve&&_e&&(ve(n),_e(r),qe.current=!0)}},[null==We?void 0:We.search,_e,ve]);var Ye=U(function(e){return e.fetchPermissions}),Je=U(function(e){return e.hasPermission}),Xe=B(function(e){return e.setRoles}),Ze=k(function(e){return e.appsecRbacUrl})===ce.appsecRbacUrl,$e=G(ce.applicationId,Ze).data,en=F(null!=ue?ue:"",pe),nn=en.isLoading,tn=en.isError,rn=en.refetch;en.isSuccess;var on=a(0),sn=on[0],an=on[1];l(function(){if(!pe&&ue&&oe){t(te,void 0,void 0,function(){var e,n,t,o,s;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,b(ue)];case 1:return e=r.sent(),"number"==typeof(n=null===(s=null===(o=null==e?void 0:e.learningManagement)||void 0===o?void 0:o.scopeAndHierarchy)||void 0===s?void 0:s.maxHierarchyLevels)&&n>0&&an(n-1),[3,3];case 2:return t=r.sent(),console.error("Failed to fetch IL instance for hierarchy levels:",t),[3,3];case 3:return[2]}})})}},[ue,oe]),l(function(){$e&&Xe($e.map(function(e){return{_id:e._id,name:e.name}}))},[$e,Xe]),l(function(){var e;console.log("userDetails",re),Qe(re),console.log("llmStudioUrl",oe),console.log("audacyBackendUrl",se),k.getState().setLlmStudioUrl(oe),k.getState().setAudacyBackendUrl(se),k.getState().setRbacConfig(ce),k.getState().setAuditLogConfig(le),Ke(ae),Ve(ie),m.getState().setAppIntegrationId(null!=ue?ue:null),m.getState().setBackwardCompatibility(pe),m.getState().setToken(null!==(e=null==re?void 0:re.accessToken)&&void 0!==e?e:null)},[re,Qe,oe,se,ce,le,ae,Ke,ie,Ve,ue,pe]),l(function(){(null==re?void 0:re.accessToken)&&oe&&S()},[ue,null==re?void 0:re.accessToken,oe]);var cn=function(n){return void 0===n&&(n=!0),t(te,void 0,void 0,function(){var t,o,s,i,a,c;return r(this,function(r){switch(r.label){case 0:n&&Ie(!0),he(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Ye(ce.applicationId)];case 2:return r.sent(),t=function(n){if(!U.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,C(ue,re.accessToken)];case 3:return(o=r.sent())&&o.data&&o.data.data&&(s=o.data.data,Array.isArray(s)&&(s=s.length>0?s[0]:null),s?(i=t(s))?(Me(null),be({data:i}),Fe.current?(ve(Fe.current),_e("learnings"),Fe.current=null):m.getState().selectedRuleSetId||ve(i.id)):(Me(null!==(c=s.id)&&void 0!==c?c:null),be(null)):(Me(null),be(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),he("Failed to load data. Please try again later."),[3,6];case 5:return Ie(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==re?void 0:re.accessToken)||void 0===e?void 0:e.length)&&Ze?cn(!0):console.warn("Error: Trying to fetch rules without access token",re)},[null==re?void 0:re.accessToken,he,ye,ce.applicationId,Ze]);var ln=function(n,o,s){return t(te,void 0,void 0,function(){var t,o,s,i,a,c,l,u;return r(this,function(r){switch(r.label){case 0:Re(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,I(n,re.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===n&&(t=m.getState().scopeTreeData,(o=_((null==t?void 0:t.data)||null,n))&&o.length>1&&(s=o[o.length-2],ve(s),_e("learnings"))),[4,cn(!0)];case 3:return r.sent(),Le(function(n){return e(e({},n),{isOpen:!1})}),null===(a=xe.current)||void 0===a||a.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=r.sent(),console.error("An error occurred during scope deletion.",i),null===(c=xe.current)||void 0===c||c.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(l=null==i?void 0:i.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return Re(!1),[7];case 6:return[2]}})})},un=Se,dn=Ue?{data:{id:Ue.stationId,name:Ue.stationName,type:"STATION",metrics:{learningsCount:Ue.learningsCount,stationsCount:0},children:[]}}:un,pn=!!(null==dn?void 0:dn.data);null===($=null==dn?void 0:dn.data)||void 0===$||$.type;var mn=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",ce.applicationResourceId||"");if(nn)return o("div",e({className:v.learningManagementContainer},{children:o(x,{})}));if(tn)return o("div",e({className:v.learningManagementContainer},{children:o(H,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return rn()},title:"Error Loading Configuration"})}));var fn=n(n([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(W("".concat(Y,".addScope"),"Add Scope")),addChildType:"SCOPE"}],Array.from({length:sn},function(){return e({type:"SCOPE",label:W("".concat(Y,".scope"),"Scope")},!pe&&{addChildLabel:W("".concat(J,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})}),!0),pe?[]:[{type:"SUBSCOPE",label:W("".concat(Y,".subScope"),"Subscope")}],!0),vn=[{id:"learnings",label:W("".concat(Y,".treeMenu.submenu.learnings"),"Learnings"),icon:u,badgeKey:"learningsCount"},{id:"access",label:W("".concat(Y,".treeMenu.submenu.access"),"Access"),icon:d},{id:"history",label:W("".concat(Y,".treeMenu.submenu.changeHistory"),"Change History"),icon:p}],gn=new Set(vn.map(function(e){return e.id})),hn=Ue?vn.filter(function(e){return"stations"!==e.id}):vn;return o(M,{children:s("div",e({className:v.learningManagementContainer},{children:[o("div",e({className:v.mainWrapper},{children:Ee?o(N,{}):ge?s("div",e({className:v.errorContainer},{children:[o("div",e({className:v.errorTitle},{children:"Error Loading Data"})),o("p",e({className:v.errorDesc},{children:ge})),o("button",e({onClick:function(){return cn(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):pn?o(g,{onOpenCreateModal:function(){return Le({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,n,t){return Le({isOpen:!0,type:n,parentId:e,parentName:t})},onRenameChild:function(e,n){return Le({isOpen:!0,type:"RENAME",scopeId:e,initialName:n})},onDeleteChild:function(e,n,o){return t(te,void 0,void 0,function(){var t,s,i;return r(this,function(r){switch(r.label){case 0:return t=m.getState().scopeTreeData,s=_((null==t?void 0:t.data)||null,e),i=!!s&&3===s.length,0!==o?[3,2]:[4,ln(e)];case 1:return r.sent(),[3,3];case 2:Le({isOpen:!0,type:"DELETE",scopeId:e,initialName:n,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Je("ilotj.scope.delete",e)},canEditScope:function(e){return Je("ilotj.scope.edit",e)},canCreateScope:function(e){return Je("ilotj.scope.create",e)},onSectionSelect:function(e,n){var t;console.log("Section Selected:",{scopeId:e,sectionId:n}),R(((t={})[O.SECTION]="learnings"===n?null:n,t[O.RULESET_ID]=e,t)),_e(n),ve(e)},activeSectionId:Ne,scopeTreeData:dn,sectionsConfig:hn,onViewStation:function(e){Ge.current=fe,Be(e),_e("learnings"),ve(e.stationId)},onRefreshRuleSets:function(e,n){void 0===e&&(e=!0),n&&(Fe.current=n),cn(e)},nodeTypesConfig:fn,app_integration_id:ue,token:re.accessToken,modeId:me}):o(h,{onCreate:function(){return Le({isOpen:!0,type:"GLOBAL"})},title:W("".concat(X,".title"),"No Global Scope has been added!"),desc:W("".concat(X,".desc"),"Start by creating a Global scope to define base learnings that apply across all stations."),button:W("".concat(X,".createNewLearning"),"Create Global Scope"),canCreateRule:mn,noAccessTitle:W("".concat(X,".noAccessTitle"),"Access Restricted"),noAccessDesc:W("".concat(X,".noAccessDesc"),"You do not have access for this application."),requestAccessButton:W("".concat(X,".requestAccessButton"),"Request Access"),onRequestAccess:function(){return t(te,void 0,void 0,function(){var e,n,t,s,i,a,c,l,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(s=null===(t=m.getState().scopeTreeData)||void 0===t?void 0:t.data)||void 0===s?void 0:s.id)||De))return null===(i=xe.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:"Unable to identify the global scope for this access request."})}),[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,w(e)];case 2:return r.sent(),null===(a=xe.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(z,{message:"Access request submitted successfully!"})}),[3,4];case 3:return n=r.sent(),null===(c=xe.current)||void 0===c||c.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:(null===(u=null===(l=null==n?void 0:n.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),o(f,{ref:xe,pt:{root:{style:{zIndex:9999}}}}),pe&&Te.isOpen&&"DELETE"!==Te.type&&"RENAME"!==Te.type?o(P,{isOpen:!0,onClose:function(){return Le(e(e({},Te),{isOpen:!1}))},onSubmit:function(n){return t(te,void 0,void 0,function(){var t,o,s,i,a,c,l,u,d,p,f,v,g,h,y,S,b,C,E,I;return r(this,function(r){switch(r.label){case 0:Re(!0),t=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof n?o=n:(s=n,i="SCOPE"===Te.type&&Te.parentId,a=i?"genreRuleSet":Te.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:Te.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:ue}),[4,A(o,re.accessToken)];case 2:if(c=r.sent(),!(l=null===(h=null==c?void 0:c.data)||void 0===h?void 0:h.scopeId))return[3,10];if(Fe.current=l,u=t&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!t&&"GLOBAL"!==Te.type&&Te.parentId,!u&&!d)return[3,10];if(!(p=t?null===(b=null===(S=m.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===b?void 0:b.id:Te.parentId))return[3,10];if(!pe)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,L({source_scope_id:p,target_scope_id:l})];case 4:return r.sent(),[3,6];case 5:return f=r.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return r.trys.push([7,9,,10]),[4,T({source_scope_id:p,target_scope_id:l,application_mapping_id:ue||"",is_copy_parent_variant_id:!1})];case 8:return r.sent(),[3,10];case 9:return v=r.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,cn(!0)];case 11:return r.sent(),Le(function(n){return e(e({},n),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(C=xe.current)||void 0===C||C.show({severity:"error",summary:"Creation Failed",detail:(null===(I=null===(E=null==g?void 0:g.response)||void 0===E?void 0:E.data)||void 0===I?void 0:I.message)||"There was an error creating the scope. Please try again."}),g;case 13:return Re(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:pn,canCreateGlobal:mn,globalScopeId:null!==(ne=null===(ee=null==Se?void 0:Se.data)||void 0===ee?void 0:ee.id)&&void 0!==ne?ne:null}):s(i,{children:[o(q,{isOpen:Te.isOpen&&"DELETE"!==Te.type&&"RENAME"!==Te.type,onClose:function(){return Le(e(e({},Te),{isOpen:!1}))},onCreate:function(e){e&&(Fe.current=e),cn(!0)},hasGlobalRuleSet:pn,parentId:Te.parentId}),o(V,{isOpen:Te.isOpen&&"RENAME"===Te.type,onClose:function(){return Le(e(e({},Te),{isOpen:!1}))},onSave:function(n){return t(te,void 0,void 0,function(){var t,s,i,a,c,l;return r(this,function(r){switch(r.label){case 0:Re(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),Te.scopeId?(t=m.getState().backwardCompatibility,s=t?{scope_id:Te.scopeId,scope_name:n}:{scope_id:Te.scopeId,scope_type:"Custom",scope_name:n,description:"demo",application_mapping_id:ue},[4,E(s,re.accessToken)]):[2];case 2:return r.sent(),[4,cn(!0)];case 3:return r.sent(),Le(function(n){return e(e({},n),{isOpen:!1})}),[3,6];case 4:throw i=r.sent(),console.error("An error occurred during scope rename.",i),null===(a=xe.current)||void 0===a||a.show({severity:"error",sticky:!1,className:v.errorToast,content:o(K,{message:(null===(l=null===(c=null==i?void 0:i.response)||void 0===c?void 0:c.data)||void 0===l?void 0:l.message)||"There was an error renaming the scope. Please try again."})}),i;case 5:return Re(!1),[7];case 6:return[2]}})})},initialName:Te.initialName})]}),o(j,{isOpen:Te.isOpen&&"DELETE"===Te.type,onCancel:function(){return Le(e(e({},Te),{isOpen:!1}))},onConfirm:function(){return ln(Te.scopeId,Te.initialName,Te.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",e({className:v.highlight},{children:Te.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:Oe})]}))})}export{Z as default};
|
|
2
2
|
//# sourceMappingURL=LearningManagement.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as o,jsx as n}from"react/jsx-runtime";import{useEffect as t}from"react";import i from"./RuleContent/RuleContent.js";import r from"./StationsContent/StationsContent.js";import a from"./RBAC/AccessManagementPanel.js";import"appsec-ui";import"./store/useAuthStore.js";import"./store/usePermissionsStore.js";import s from"./store/useEnvStore.js";import
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as o,jsx as n}from"react/jsx-runtime";import{useEffect as t}from"react";import i from"./RuleContent/RuleContent.js";import r from"./StationsContent/StationsContent.js";import a from"./RBAC/AccessManagementPanel.js";import"appsec-ui";import"./store/useAuthStore.js";import"./store/usePermissionsStore.js";import s from"./store/useEnvStore.js";import d from"./styles/LearningTemplateLayout.module.css.js";import{findNodeById as l}from"./utils/treeUtils.js";import c from"./SidebarWrapper.js";import{useLearningTemplateStore as u}from"./store/useLearningTemplateStore.js";import p from"./components/StationOnboarding/StationOnboardModal.js";import m from"./AuditLog/AuditLog.js";var f=function(f){var S,g,v=f.onOpenCreateModal,C=f.onRefreshRuleSets,h=f.scopeTreeData,R=f.onAddChild,j=f.onRenameChild,I=f.onDeleteChild,A=f.canDeleteScope,D=f.canEditScope,M=f.canCreateScope,O=f.onSectionSelect,T=f.onViewStation,w=f.activeSectionId,b=void 0===w?"learnings":w,k=f.sectionsConfig,y=f.nodeTypesConfig,L=f.app_integration_id,_=f.token,N=f.modeId,U=u(function(e){return e.isStationModalOpen}),x=u(function(e){return e.setStationModalOpen}),B=u(function(e){return e.isStationOnboardModalTriggered}),E=u(function(e){return e.setIsStationOnboardModalTriggered}),P=u(function(e){return e.selectedRuleSetId}),V=u(function(e){return e.rawAuditRuleData}),F=s(function(e){return e.auditLogConfig});u(function(e){return e.ruleData});var W=P?l((null==h?void 0:h.data)||null,P):null;return Boolean((null===(S=null==h?void 0:h.data)||void 0===S?void 0:S.id)&&P===h.data.id),t(function(){B&&x(!0)},[B,x,E]),o("div",e({className:d.container},{children:[n(c,{onOpenCreateModal:v,onRefreshRuleSets:C,scopeTreeData:h,onAddChild:R,onRenameChild:j,onDeleteChild:I,canDeleteScope:A,canEditScope:D,canCreateScope:M,onSectionSelect:O,activeSectionId:b,sectionsConfig:k,nodeTypesConfig:y}),n("div",e({id:"rule-template-layout-content",className:"".concat(d.content," relative flex-1 overflow-hidden")},{children:"stations"===b?n(r,{scopeId:P||"",scopeName:(null==W?void 0:W.name)||"Unknown Scope",stationsCount:null===(g=null==W?void 0:W.metrics)||void 0===g?void 0:g.stationsCount,onViewStation:T}):"access"===b?n(a,{selectedRuleSetId:P,scopeName:(null==W?void 0:W.name)||"Unknown Scope",useApplicationModuleForScopeAccess:!1}):"history"===b?(null==F?void 0:F.configId)?n(m,{configId:F.configId,scopeId:P||void 0,scopeName:(null==W?void 0:W.name)||"Unknown Scope",ruleData:V}):null:n(i,{onRefreshRuleSets:C,app_integration_id:L,token:_,modeId:N})})),n(p,{isOpen:U,onClose:function(){x(!1),E(!1)},onBoardStation:function(e){C(!0,e)},app_integration_id:L,token:_})]}))};export{f as default};
|
|
2
2
|
//# sourceMappingURL=LearningTemplateLayout.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__spreadArray as n,__assign as r}from"tslib";import{jsx as o,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useRef as a,useState as s,useEffect as u}from"react";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import d from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as p,exportRuleSet as m,deleteRule as f,deleteQuestion as v,alterQuestionPriority as g}from"../apis/scopeApis.js";import h from"../components/RuleContentSkeleton.js";import{Toast as T}from"primereact/toast";import y from"./ContentLogic.js";import w from"../components/ErrorStateDisplay.js";import S from"../shared/SuccessToastContent.js";import C from"../shared/ErrorToastContent.js";import{findNodeById as b}from"../utils/treeUtils.js";import j from"../styles/LearningContent.module.css.js";import R from"../components/ConfirmationModal.js";import{dt as D}from"../store/useLMSConfigStore.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 I}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 x from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import{LEARNING_DT_PATH as _,VARIANT_DT_PATH as L,TIER_DT_PATH as k}from"../constants.js";import"../store/usePermissionsStore.js";import"appsec-ui";import"../store/useAuthStore.js";import"../store/useEnvStore.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../store/useConfigStore.js";import"../config.js";import"../store/useAppSecRolesStore.js";import"@tanstack/react-query";import"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import"../AuditLog/ChangeLogDiff.js";import"../components/ToolTip.js";import"react-router-dom";var O=function(O){var M,A=O.noRulesTitle,N=void 0===A?"No rules have been added !":A,E=O.noRulesDesc,V=void 0===E?"Start by adding rules that should apply across all stations.":E,F=O.noRulesButtonText,P=void 0===F?"Create New Rule":F,B=O.deleteRuleSuccessMessage,J=void 0===B?"Rule deleted successfully!":B,U=O.deleteVariantSuccessMessage,W=void 0===U?"Variant deleted successfully!":U,q=O.deleteRuleErrorMessage,G=void 0===q?"Failed to delete rule. Please try again.":q,H=O.deleteVariantErrorMessage,$=void 0===H?"Failed to delete variant. Please try again.":H,z=O.deleteModalTitle,K=void 0===z?"Delete":z,Q=O.deleteRuleModalWarning,X=void 0===Q?"This will permanently delete the rule configuration.":Q,Y=O.deleteVariantModalWarning,Z=void 0===Y?"This will permanently delete the variant configuration.":Y,ee=O.deleteConfirmText,te=void 0===ee?"Delete":ee,ne=O.onRefreshRuleSets,re=O.app_integration_id,oe=O.token,ie=c(function(e){return e.selectedRuleSetId}),le=c(function(e){return e.scopeTreeData}),ae=c(function(e){return e.sidebarTab}),se=c(function(e){return e.setInitialRules}),ue=c(function(e){return e.currentRules}),ce=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var de=c(function(e){return e.resetCreatedVariantInfo}),pe=c(function(e){return e.isILModalTriggered}),me=c(function(e){return e.setIsILModalTriggered}),fe=a(null),ve=s(!1),ge=ve[0],he=ve[1],Te=s(null),ye=Te[0],we=Te[1],Se=s(null),Ce=Se[0],be=Se[1],je=s(null),Re=je[0],De=je[1],Ie=s(null),xe=Ie[0],_e=Ie[1],Le=s(!1),ke=Le[0],Oe=Le[1],Me=s(null),Ae=Me[0],Ne=Me[1],Ee=s(!1),Ve=Ee[0],Fe=Ee[1],Pe=s(""),Be=Pe[0],Je=Pe[1],Ue=s(null),We=Ue[0],qe=Ue[1],Ge=s(!1),He=Ge[0],$e=Ge[1],ze=s(!1),Ke=ze[0],Qe=ze[1],Xe=s("ruleDeletion"),Ye=Xe[0],Ze=Xe[1],et=s(null),tt=et[0],nt=et[1],rt=s(!1),ot=rt[0],it=rt[1],lt=s(!1),at=lt[0],st=lt[1],ut=c.getState().tiers,ct=s(null),dt=ct[0],pt=ct[1],mt=s(null),ft=mt[0],vt=mt[1],gt=s(null),ht=gt[0],Tt=gt[1],yt=function(){we(null),be(null),he(!0),_e(0)},wt=function(){he(!1),me(!1),we(null),be(null),De(null),_e(null),Qe(!1),st(!1),St(),pt(null),vt(null),Tt(null),ne&&ne(!1,ie||void 0)};u(function(){St()},[ie,se]),u(function(){pe&&he(!0)},[pe]);var St=function(o){return void 0===o&&(o=!1),e(void 0,void 0,void 0,function(){var e,i,l,a,s,u,d,m,f,v,g,h,T,y,w,S,C,b,j;return t(this,function(t){switch(t.label){case 0:if(!ie)return se([]),[2];o||Oe(!0),Ne(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(ie,oe)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(ce(e),i=e.data,console.log("rulesData==",i),l=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),a=Array.isArray(i.tiers)?n([],i.tiers,!0).sort(function(e,t){var n,r;return(null!==(n=e.tier_priority)&&void 0!==n?n:0)-(null!==(r=t.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var t=e[0],n=e[1];return!l.has(t)&&Array.isArray(n)}),s=a.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:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),m=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(e){return e.map(function(e){var t;return r(r({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return r(r({},e),{isLinked:!!e.link_id&&m.has(e.link_id)})})})})},v=a.map(function(e,t){var n,r=e[0],o=e[1],i=ut.find(function(e){return e.tier_name===r}),l=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(n=null==i?void 0:i.tier_id)&&void 0!==n?n:String(t+1),name:l.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"".concat(D("tier.subtitle","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:f(o)}}),(g=c.getState().createdVariantInfo)&&g.length>0?(h=Object.fromEntries(a.map(function(e,t){return[e[0],String(t+1)]})),T=new Set(g.map(function(e){return h[e.tierName]}).filter(Boolean)),y=v.map(function(e){return r(r({},e),{isOpen:e.isOpen||T.has(e.id)})}),se(y),(w=null===(j=null===(b=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===b?void 0:b[0])||void 0===j?void 0:j.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return de()},1e4)},500):de()):se(v),[3,5]):(se([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Ne((null==S?void 0:S.message)||"Failed to load rules. Please try again."),se([]),[3,5];case 4:return o||Oe(!1),[7];case 5:return[2]}})})},Ct=ie?b((null==le?void 0:le.data)||null,ie):null,bt=Ct?{ruleSetId:Ct.id,ruleSetName:Ct.name,ruleSetDesc:"",ruleCount:null===(M=null==Ct?void 0:Ct.metrics)||void 0===M?void 0:M.learningsCount}:void 0,jt=Boolean(null==le?void 0:le.data),Rt=Boolean(ie&&!Ct&&jt),Dt=function(){if("stations"===ae)return"custom";if(!Ct)return"global";switch(Ct.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},It=function(e){var t;if(!e)return o("p",{children:D("".concat(k,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var n=null==ue?void 0:ue.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return o("p",{children:D("".concat(k,".deleteDialog.description"),"Are you sure you want to delete ".concat(null==n?void 0:n.ruleTitle," rule? This action cannot be undone."),{rule_title:null!==(t=null==n?void 0:n.ruleTitle)&&void 0!==t?t:""})})},xt={editingRule:ye,editingTier:Ce,editingVariants:Re,focusedVariantIndex:xe,setFocusedVariantIndex:_e,triggerAddVariant:Ke,triggerFixGaps:at,copiedRule:dt,copiedSourceTier:ft,copiedTargetTier:ht,initialDraftMessage:Be,app_integration_id:re,modeId:"019dde79-0494-78d7-ba5b-54a35d20f0fc"};return bt?i(l,{children:[o(T,{ref:fe}),o("div",r({className:j.container},{children:ke?o(h,{}):Ae?o(w,{errorMessage:Ae,onRetry:St}):o(y,{onAddRule:yt,onDeleteRule:function(e){qe(e)},onEditRule:function(e,t){we(e),be(t||null),De(e.variants||null),_e(null),Qe(!0),he(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==ue?void 0:ue.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==ue?void 0:ue.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;we(s),be(n||null),De(s.variants||null),_e(c),he(!0),"resolve_gaps"===r&&st(!0)}},onDeleteVariant:function(e,t){nt({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l,a,s;return t(this,function(t){switch(t.label){case 0:if(!ie)return[2];Fe(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(ie)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==bt?void 0:bt.ruleSetName)?"".concat(bt.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ie,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=fe.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:j.successToast,content:o(S,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=fe.current)||void 0===s||s.show({severity:"error",sticky:!1,className:j.errorToast,content:o(C,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Fe(!1),[7];case 5:return[2]}})})},isExporting:Ve,onToggleSuccess:function(){return St(!0)},onReorderRules:function(n,r,i,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,g(n,r,i,l,a)];case 1:return t.sent(),St(!0),null===(s=fe.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:j.successToast,content:o(S,{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),St(!0),null===(u=fe.current)||void 0===u||u.show({severity:"error",sticky:!1,className:j.errorToast,content:o(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:ne,setDeleteConfirmationUsedFor:Ze,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==ue?void 0:ue.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");Je(s),pt(a),vt(r),Tt(o),we(null),be(null),De(null),_e(null),he(!0)}}})})),ge&&o(I,{children:o(x,{isOpen:ge,onClose:wt,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},xt),{initialScope:Dt(),ruleSet:bt})})}),o(R,{isOpen:!!We,title:D("".concat(_,".deleteDialog.title"),K),description:It(We),warning:D("".concat(_,".deleteDialog.warningText"),X),confirmText:D("".concat(_,".deleteDialog.deleteText"),te),cancelText:D("".concat(_,".deleteDialog.cancelText"),"Cancel"),loadingText:D("".concat(_,".deleteDialog.loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!We)return[2];$e(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(We)];case 2:return t.sent(),qe(null),null===(n=fe.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:j.successToast,content:o(S,{message:J})}),St(),ne&&ne(!1,ie||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=fe.current)||void 0===r||r.show({severity:"error",sticky:!1,className:j.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||G})}),[3,5];case 4:return $e(!1),[7];case 5:return[2]}})})},onCancel:function(){return qe(null)},isLoading:He}),o(R,{isOpen:!!tt,title:D("".concat(L,".deleteVariant.title"),K),description:"variantDeletion"===Ye?o("span",{children:D("".concat(L,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):It((null==tt?void 0:tt.ruleId)||null),warning:D("".concat(L,".deleteVariant.warningText"),"ruleDeletion"===Ye?X:Z),confirmText:D("".concat(L,".deleteDialog.deleteText"),te),cancelText:D("".concat(L,".cancelText"),"Cancel"),loadingText:D("".concat(L,".loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!tt)return[2];it(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==Ye?[3,3]:[4,v(tt.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(tt.variantId)];case 4:t.sent(),t.label=5;case 5:return nt(null),null===(n=fe.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:j.successToast,content:o(S,{message:"ruleDeletion"===Ye?J:W})}),St(),ne&&ne(!1,ie||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=fe.current)||void 0===r||r.show({severity:"error",sticky:!1,className:j.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===Ye?G:$)})}),[3,8];case 7:return it(!1),[7];case 8:return[2]}})})},onCancel:function(){return nt(null)},isLoading:ot})]}):Rt?o(w,{title:"Scope Not Found",errorMessage:"The selected scope does not exist. Please refresh the page or choose a valid scope.",onRetry:function(){return null==ne?void 0:ne(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:yt,title:N,desc:V,button:P}),ge&&o(I,{children:o(x,{isOpen:ge,onClose:wt,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},xt),{initialScope:Dt(),ruleSet:bt})})})]})};export{O as default};
|
|
1
|
+
import{__awaiter as e,__generator as t,__spreadArray as n,__assign as r}from"tslib";import{jsx as o,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useRef as a,useState as s,useEffect as u}from"react";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import d from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as p,exportRuleSet as m,deleteRule as f,deleteQuestion as v,alterQuestionPriority as g}from"../apis/scopeApis.js";import h from"../components/RuleContentSkeleton.js";import{Toast as T}from"primereact/toast";import y from"./ContentLogic.js";import w from"../components/ErrorStateDisplay.js";import S from"../shared/SuccessToastContent.js";import C from"../shared/ErrorToastContent.js";import{findNodeById as j}from"../utils/treeUtils.js";import R from"../styles/LearningContent.module.css.js";import b from"../components/ConfirmationModal.js";import{dt as I}from"../store/useLMSConfigStore.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 D}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 x from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import{LEARNING_DT_PATH as _,VARIANT_DT_PATH as L,TIER_DT_PATH as k}from"../constants.js";import"../store/usePermissionsStore.js";import"appsec-ui";import"../store/useAuthStore.js";import"../store/useEnvStore.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../store/useConfigStore.js";import"../config.js";import"../store/useAppSecRolesStore.js";import"@tanstack/react-query";import"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import"../AuditLog/ChangeLogDiff.js";import"../components/ToolTip.js";import"react-router-dom";var O=function(O){var M,A=O.noRulesTitle,N=void 0===A?"No rules have been added !":A,E=O.noRulesDesc,V=void 0===E?"Start by adding rules that should apply across all stations.":E,F=O.noRulesButtonText,P=void 0===F?"Create New Rule":F,B=O.deleteRuleSuccessMessage,J=void 0===B?"Rule deleted successfully!":B,U=O.deleteVariantSuccessMessage,W=void 0===U?"Variant deleted successfully!":U,q=O.deleteRuleErrorMessage,G=void 0===q?"Failed to delete rule. Please try again.":q,H=O.deleteVariantErrorMessage,$=void 0===H?"Failed to delete variant. Please try again.":H,z=O.deleteModalTitle,K=void 0===z?"Delete":z,Q=O.deleteRuleModalWarning,X=void 0===Q?"This will permanently delete the rule configuration.":Q,Y=O.deleteVariantModalWarning,Z=void 0===Y?"This will permanently delete the variant configuration.":Y,ee=O.deleteConfirmText,te=void 0===ee?"Delete":ee,ne=O.onRefreshRuleSets,re=O.app_integration_id,oe=O.token,ie=O.modeId,le=c(function(e){return e.selectedRuleSetId}),ae=c(function(e){return e.scopeTreeData}),se=c(function(e){return e.sidebarTab}),ue=c(function(e){return e.setInitialRules}),ce=c(function(e){return e.currentRules}),de=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var pe=c(function(e){return e.resetCreatedVariantInfo}),me=c(function(e){return e.isILModalTriggered}),fe=c(function(e){return e.setIsILModalTriggered}),ve=a(null),ge=s(!1),he=ge[0],Te=ge[1],ye=s(null),we=ye[0],Se=ye[1],Ce=s(null),je=Ce[0],Re=Ce[1],be=s(null),Ie=be[0],De=be[1],xe=s(null),_e=xe[0],Le=xe[1],ke=s(!1),Oe=ke[0],Me=ke[1],Ae=s(null),Ne=Ae[0],Ee=Ae[1],Ve=s(!1),Fe=Ve[0],Pe=Ve[1],Be=s(""),Je=Be[0],Ue=Be[1],We=s(null),qe=We[0],Ge=We[1],He=s(!1),$e=He[0],ze=He[1],Ke=s(!1),Qe=Ke[0],Xe=Ke[1],Ye=s("ruleDeletion"),Ze=Ye[0],et=Ye[1],tt=s(null),nt=tt[0],rt=tt[1],ot=s(!1),it=ot[0],lt=ot[1],at=s(!1),st=at[0],ut=at[1],ct=c.getState().tiers,dt=s(null),pt=dt[0],mt=dt[1],ft=s(null),vt=ft[0],gt=ft[1],ht=s(null),Tt=ht[0],yt=ht[1],wt=function(){Se(null),Re(null),Te(!0),Le(0)},St=function(){Te(!1),fe(!1),Se(null),Re(null),De(null),Le(null),Xe(!1),ut(!1),Ct(),mt(null),gt(null),yt(null),ne&&ne(!1,le||void 0)};u(function(){Ct()},[le,ue]),u(function(){me&&Te(!0)},[me]);var Ct=function(o){return void 0===o&&(o=!1),e(void 0,void 0,void 0,function(){var e,i,l,a,s,u,d,m,f,v,g,h,T,y,w,S,C,j,R;return t(this,function(t){switch(t.label){case 0:if(!le)return ue([]),[2];o||Me(!0),Ee(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(le,oe)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(de(e),i=e.data,console.log("rulesData==",i),l=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),a=Array.isArray(i.tiers)?n([],i.tiers,!0).sort(function(e,t){var n,r;return(null!==(n=e.tier_priority)&&void 0!==n?n:0)-(null!==(r=t.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var t=e[0],n=e[1];return!l.has(t)&&Array.isArray(n)}),s=a.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:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),m=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(e){return e.map(function(e){var t;return r(r({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return r(r({},e),{isLinked:!!e.link_id&&m.has(e.link_id)})})})})},v=a.map(function(e,t){var n,r=e[0],o=e[1],i=ct.find(function(e){return e.tier_name===r}),l=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(n=null==i?void 0:i.tier_id)&&void 0!==n?n:String(t+1),name:l.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"".concat(I("tier.subtitle","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:f(o)}}),(g=c.getState().createdVariantInfo)&&g.length>0?(h=Object.fromEntries(a.map(function(e,t){return[e[0],String(t+1)]})),T=new Set(g.map(function(e){return h[e.tierName]}).filter(Boolean)),y=v.map(function(e){return r(r({},e),{isOpen:e.isOpen||T.has(e.id)})}),ue(y),(w=null===(R=null===(j=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===j?void 0:j[0])||void 0===R?void 0:R.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return pe()},1e4)},500):pe()):ue(v),[3,5]):(ue([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Ee((null==S?void 0:S.message)||"Failed to load rules. Please try again."),ue([]),[3,5];case 4:return o||Me(!1),[7];case 5:return[2]}})})},jt=le?j((null==ae?void 0:ae.data)||null,le):null,Rt=jt?{ruleSetId:jt.id,ruleSetName:jt.name,ruleSetDesc:"",ruleCount:null===(M=null==jt?void 0:jt.metrics)||void 0===M?void 0:M.learningsCount}:void 0,bt=Boolean(null==ae?void 0:ae.data),It=Boolean(le&&!jt&&bt),Dt=function(){if("stations"===se)return"custom";if(!jt)return"global";switch(jt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},xt=function(e){var t;if(!e)return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var n=null==ce?void 0:ce.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete ".concat(null==n?void 0:n.ruleTitle," rule? This action cannot be undone."),{rule_title:null!==(t=null==n?void 0:n.ruleTitle)&&void 0!==t?t:""})})},_t={editingRule:we,editingTier:je,editingVariants:Ie,focusedVariantIndex:_e,setFocusedVariantIndex:Le,triggerAddVariant:Qe,triggerFixGaps:st,copiedRule:pt,copiedSourceTier:vt,copiedTargetTier:Tt,initialDraftMessage:Je,app_integration_id:re,modeId:ie};return Rt?i(l,{children:[o(T,{ref:ve}),o("div",r({className:R.container},{children:Oe?o(h,{}):Ne?o(w,{errorMessage:Ne,onRetry:Ct}):o(y,{onAddRule:wt,onDeleteRule:function(e){Ge(e)},onEditRule:function(e,t){Se(e),Re(t||null),De(e.variants||null),Le(null),Xe(!0),Te(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==ce?void 0:ce.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==ce?void 0:ce.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;Se(s),Re(n||null),De(s.variants||null),Le(c),Te(!0),"resolve_gaps"===r&&ut(!0)}},onDeleteVariant:function(e,t){rt({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l,a,s;return t(this,function(t){switch(t.label){case 0:if(!le)return[2];Pe(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(le)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==Rt?void 0:Rt.ruleSetName)?"".concat(Rt.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(le,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=ve.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=ve.current)||void 0===s||s.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Pe(!1),[7];case 5:return[2]}})})},isExporting:Fe,onToggleSuccess:function(){return Ct(!0)},onReorderRules:function(n,r,i,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,g(n,r,i,l,a)];case 1:return t.sent(),Ct(!0),null===(s=ve.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{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),Ct(!0),null===(u=ve.current)||void 0===u||u.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:ne,setDeleteConfirmationUsedFor:et,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==ce?void 0:ce.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");Ue(s),mt(a),gt(r),yt(o),Se(null),Re(null),De(null),Le(null),Te(!0)}}})})),he&&o(D,{children:o(x,{isOpen:he,onClose:St,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},_t),{initialScope:Dt(),ruleSet:Rt})})}),o(b,{isOpen:!!qe,title:I("".concat(_,".deleteDialog.title"),K),description:xt(qe),warning:I("".concat(_,".deleteDialog.warningText"),X),confirmText:I("".concat(_,".deleteDialog.deleteText"),te),cancelText:I("".concat(_,".deleteDialog.cancelText"),"Cancel"),loadingText:I("".concat(_,".deleteDialog.loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!qe)return[2];ze(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(qe)];case 2:return t.sent(),Ge(null),null===(n=ve.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:J})}),Ct(),ne&&ne(!1,le||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=ve.current)||void 0===r||r.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||G})}),[3,5];case 4:return ze(!1),[7];case 5:return[2]}})})},onCancel:function(){return Ge(null)},isLoading:$e}),o(b,{isOpen:!!nt,title:I("".concat(L,".deleteVariant.title"),K),description:"variantDeletion"===Ze?o("span",{children:I("".concat(L,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):xt((null==nt?void 0:nt.ruleId)||null),warning:I("".concat(L,".deleteVariant.warningText"),"ruleDeletion"===Ze?X:Z),confirmText:I("".concat(L,".deleteDialog.deleteText"),te),cancelText:I("".concat(L,".cancelText"),"Cancel"),loadingText:I("".concat(L,".loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!nt)return[2];lt(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==Ze?[3,3]:[4,v(nt.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(nt.variantId)];case 4:t.sent(),t.label=5;case 5:return rt(null),null===(n=ve.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"ruleDeletion"===Ze?J:W})}),Ct(),ne&&ne(!1,le||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=ve.current)||void 0===r||r.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===Ze?G:$)})}),[3,8];case 7:return lt(!1),[7];case 8:return[2]}})})},onCancel:function(){return rt(null)},isLoading:it})]}):It?o(w,{title:"Scope Not Found",errorMessage:"The selected scope does not exist. Please refresh the page or choose a valid scope.",onRetry:function(){return null==ne?void 0:ne(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:wt,title:N,desc:V,button:P}),he&&o(D,{children:o(x,{isOpen:he,onClose:St,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},_t),{initialScope:Dt(),ruleSet:Rt})})})]})};export{O as default};
|
|
2
2
|
//# sourceMappingURL=RuleContent.js.map
|