@e-llm-studio/instant-learning 1.3.0-alpha.4 → 1.3.0-alpha.7

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/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"),n=require("./features/IL-OTJ/_components/atoms/Button/Button.js"),s=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"),L=require("./features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js"),d=require("./features/IL-OTJ/helpers/utils.js"),I=require("./features/IL-OTJ/store/CitationsContext.js"),S=require("./features/IL-OTJ/ILOTJTest.js"),O=require("./features/LearningManagement/LearningManagement.js");exports.InstantLearning=e.default,exports.WtaWnta=t.default,exports.BookLearning=r.default,exports.ILOTJ=o.default,exports.Button=n.Button,exports.Dropdown=s.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 L.TemplateList}}),exports.TemplateMap=L.TemplateMap,exports.extractAndParseResponse=d.extractAndParseResponse,exports.extractAndParseWithProperty=d.extractAndParseWithProperty,exports.extractTextFromChildren=d.extractTextFromChildren,exports.extractVariantIds=d.extractVariantIds,exports.parseValidationData=d.parseValidationData,exports.useHeaderObserver=d.useHeaderObserver,exports.CitationProvider=I.CitationProvider,exports.useCitations=I.useCitations,exports.getVariantInfo=S.getVariantInfo,exports.LearningManagement=O.default;
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"),n=require("./features/IL-OTJ/_components/atoms/Button/Button.js"),s=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"),L=require("./features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js"),d=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");require("tslib"),require("react/jsx-runtime"),exports.InstantLearning=e.default,exports.WtaWnta=t.default,exports.BookLearning=r.default,exports.ILOTJ=o.default,exports.Button=n.Button,exports.Dropdown=s.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 L.TemplateList}}),exports.TemplateMap=L.TemplateMap,exports.extractAndParseResponse=d.extractAndParseResponse,exports.extractAndParseWithProperty=d.extractAndParseWithProperty,exports.extractTextFromChildren=d.extractTextFromChildren,exports.extractVariantIds=d.extractVariantIds,exports.parseValidationData=d.parseValidationData,exports.useHeaderObserver=d.useHeaderObserver,exports.CitationProvider=I.CitationProvider,exports.useCitations=I.useCitations,exports.getVariantInfo=S.getVariantInfo,exports.LearningManagement=j.default;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as e,__assign as t}from"tslib";import{jsxs as i,jsx as o}from"react/jsx-runtime";import{useMemo as n,useEffect as r}from"react";import{AuditLog as l}from"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import{User as a,FileText as d,ExternalLink as c}from"lucide-react";var s=function(s){var h=s.configId,p=s.ruleData,g=s.scopeId,u=s.scopeName,f=(null==u?void 0:u.trim())||"Selected",m=n(function(){var t,i,o=[];g&&o.push(g);var n=(null===(t=null==p?void 0:p.data)||void 0===t?void 0:t.tier1)||(null==p?void 0:p.tier1)||[],r=(null===(i=null==p?void 0:p.data)||void 0===i?void 0:i.tier2)||(null==p?void 0:p.tier2)||[];return e(e([],n,!0),r,!0).forEach(function(e){(null==e?void 0:e.ruleId)&&o.push(e.ruleId),(null==e?void 0:e.variants)&&Array.isArray(e.variants)&&e.variants.forEach(function(e){(null==e?void 0:e.variantId)&&o.push(e.variantId)})}),o},[p,g]);return r(function(){console.log("Flattened External Resource IDs:",m)},[m]),i("div",t({style:{padding:"24px",fontFamily:"Arial, sans-serif"}},{children:[i("div",t({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[i("h1",t({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:[f," - Audit Log"]})),i("p",t({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:["Track all learning updates and modifications with the ",f," scope."]}))]})),o(l,{configId:h,getData:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/fetch"},distinctValuesApi:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/distinct-values"},query:{externalResourceId:m.length>0?m:[""],paginationLimit:10},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(e){return i("div",t({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[o(a,{size:16,color:"#64748b",style:{flexShrink:0}}),o("span",t({style:{fontWeight:500}},{children:e.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(e){var i,n,r=(i=e.changeTitle,(n=(i||"").toUpperCase()).includes("CREATE")?{color:"#2e7d32",backgroundColor:"#edf7ed",borderColor:"#c8e6c9",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:n.includes("UPDATE")||n.includes("TOGGLE")?{color:"#1565c0",backgroundColor:"#e3f2fd",borderColor:"#bbdefb",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:n.includes("DELETE")?{color:"#c62828",backgroundColor:"#fdeeed",borderColor:"#ffcdd2",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"#475569",backgroundColor:"#f8fafc",borderColor:"#cbd5e1",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),l=e.changeTitle?e.changeTitle.replace(/_/g," "):"—";return o("span",t({style:{color:r.color,backgroundColor:r.backgroundColor,border:"1px solid ".concat(r.borderColor),boxShadow:r.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:l}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(e){var n;return i("div",t({style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"4px 0"}},{children:[o(d,{size:16,color:"#94a3b8",style:{flexShrink:0,marginTop:"2px"}}),o("span",t({style:{color:"#334155",fontSize:"13px",lineHeight:1.5}},{children:null!==(n=e.actionText)&&void 0!==n?n:"—"}))]}))},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(e){var n,r=(null===(n=e.metadata)||void 0===n?void 0:n.redirect_url)||e.redirect_url;return r?o("div",t({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:i("a",t({href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"#2563eb",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",o(c,{size:14})]}))})):o("span",t({style:{color:"#94a3b8",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(e){if(!e.actionDate)return o("span",t({style:{color:"#94a3b8"}},{children:"—"}));var n=new Date(e.actionDate),r=n.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),l=n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return i("div",t({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"#475569"}},{children:[o("span",t({style:{fontWeight:500}},{children:r})),o("span",{children:l})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}})]}))};export{s as default};
1
+ import{__assign as e}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useMemo as o,useEffect as n}from"react";import{AuditLog as r}from"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import{User as l,FileText as a,ExternalLink as d}from"lucide-react";var c=function(c){var s=c.configId,h=c.ruleData,p=c.scopeId,g=c.scopeName,u=(null==g?void 0:g.trim())||"Selected",m=o(function(){var e=[];return p&&e.push(p),e},[h,p]);return n(function(){console.log("Flattened External Resource IDs:",m)},[m]),t("div",e({style:{padding:"24px",fontFamily:"Arial, sans-serif"}},{children:[t("div",e({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[t("h1",e({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:[u," - Audit Log"]})),t("p",e({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:["Track all learning updates and modifications with the ",u," scope."]}))]})),i(r,{configId:s,getData:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/fetch"},distinctValuesApi:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/distinct-values"},query:{externalResourceId:m.length>0?m:[""],paginationLimit:10},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(o){return t("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i(l,{size:16,color:"#64748b",style:{flexShrink:0}}),i("span",e({style:{fontWeight:500}},{children:o.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(t){var o,n,r=(o=t.changeTitle,(n=(o||"").toUpperCase()).includes("CREATE")?{color:"#2e7d32",backgroundColor:"#edf7ed",borderColor:"#c8e6c9",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:n.includes("UPDATE")||n.includes("TOGGLE")?{color:"#1565c0",backgroundColor:"#e3f2fd",borderColor:"#bbdefb",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:n.includes("DELETE")?{color:"#c62828",backgroundColor:"#fdeeed",borderColor:"#ffcdd2",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"#475569",backgroundColor:"#f8fafc",borderColor:"#cbd5e1",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),l=t.changeTitle?t.changeTitle.replace(/_/g," "):"—";return i("span",e({style:{color:r.color,backgroundColor:r.backgroundColor,border:"1px solid ".concat(r.borderColor),boxShadow:r.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:l}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(o){var n;return t("div",e({style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"4px 0"}},{children:[i(a,{size:16,color:"#94a3b8",style:{flexShrink:0,marginTop:"2px"}}),i("span",e({style:{color:"#334155",fontSize:"13px",lineHeight:1.5}},{children:null!==(n=o.actionText)&&void 0!==n?n:"—"}))]}))},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(o){var n,r=(null===(n=o.metadata)||void 0===n?void 0:n.redirect_url)||o.redirect_url;return r?i("div",e({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:t("a",e({href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"#2563eb",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",i(d,{size:14})]}))})):i("span",e({style:{color:"#94a3b8",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(o){if(!o.actionDate)return i("span",e({style:{color:"#94a3b8"}},{children:"—"}));var n=new Date(o.actionDate),r=n.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),l=n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return t("div",e({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"#475569"}},{children:[i("span",e({style:{fontWeight:500}},{children:r})),i("span",{children:l})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}})]}))};export{c as default};
2
2
  //# sourceMappingURL=AuditLog.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as e,__assign as t,__awaiter as n,__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 l,useEffect as c}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,fetchScopes as b,inheritScope as C,inheritScopeBackwardCompatible as T,createRuleSet as E,renameScope as L,deleteRuleSet as A,requestAccess as O}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as w,setQueryParams as I}from"./hooks/useLearningTemplateQueryParams.js";import R from"./components/ConfirmationModal.js";import j 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 _}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 M}from"./queries/useApprovalQueries.js";import B from"./RuleContent/AddScopeModal.js";import{useLocation as F}from"react-router-dom";import q from"./shared/SuccessToastContent.js";import x from"./shared/ErrorToastContent.js";import H from"./RuleContent/RenameScopeModal.js";var Q=[{id:"learnings",label:"Learnings",icon:u,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:d},{id:"history",label:"Change History",icon:p}],z=new Set(Q.map(function(e){return e.id}));function K(u){var d,p=this,K=u.userDetails,V=u.llmStudioUrl,W=u.audacyBackendUrl,Y=u.ilLabels,J=u.config,X=u.rbacConfig,Z=u.auditLogConfig,$=u.app_integration_id,ee=u.backwardCompatibility,te=void 0!==ee&&ee,ne=m(function(e){return e.selectedRuleSetId}),re=m(function(e){return e.setSelectedRuleSetId}),oe=m(function(e){return e.error}),se=m(function(e){return e.setError}),ie=m(function(e){return e.setStations}),ae=m(function(e){return e.scopeTreeData}),le=m(function(e){return e.setScopeTreeData}),ce=a({isOpen:!1,type:"GLOBAL"}),ue=ce[0],de=ce[1],pe=a(!1),me=pe[0],fe=pe[1],ve=a(!1),ge=ve[0],he=ve[1],ye=a("learnings"),Se=ye[0],be=ye[1],Ce=a(null),Te=Ce[0],Ee=Ce[1],Le=a(null),Ae=Le[0],Oe=Le[1],we=l(null),Ie=l(null),Re=l(null),je=y();je.user;var Ne=je.setUser,ke=D(),De=ke.setConfig,_e=ke.setIlLabels,Pe=e([{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},t({type:"SCOPE",label:"Scope"},!te&&{addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"})],te?[]:[{type:"SUBSCOPE",label:"Subscope"}],!0),Ue=function(){try{return F()}catch(e){return{search:""}}}();c(function(){var e=new URLSearchParams(window.location.search),t=e.get(w.RULESET_ID),n=e.get(w.SECTION),r=n&&z.has(n)?n:"learnings";(null==t?void 0:t.length)&&re&&be&&(re(t),be(r))},[null==Ue?void 0:Ue.search,be,re]);var Ge=U(function(e){return e.fetchPermissions}),Me=U(function(e){return e.hasPermission}),Be=G(function(e){return e.setRoles}),Fe=k(function(e){return e.appsecRbacUrl})===X.appsecRbacUrl,qe=M(X.applicationId,Fe).data;c(function(){qe&&Be(qe.map(function(e){return{_id:e._id,name:e.name}}))},[qe,Be]),c(function(){var e;console.log("userDetails",K),Ne(K),console.log("llmStudioUrl",V),console.log("audacyBackendUrl",W),k.getState().setLlmStudioUrl(V),k.getState().setAudacyBackendUrl(W),k.getState().setRbacConfig(X),k.getState().setAuditLogConfig(Z),De(J),_e(Y),m.getState().setAppIntegrationId(null!=$?$:null),m.getState().setBackwardCompatibility(te),m.getState().setToken(null!==(e=K.accessToken)&&void 0!==e?e:null)},[K,Ne,V,W,X,Z,J,De,Y,_e,$,te]),c(function(){(null==K?void 0:K.accessToken)&&V&&S()},[$,null==K?void 0:K.accessToken,V]);var xe=function(e){return void 0===e&&(e=!0),n(p,void 0,void 0,function(){var n,o,s,i,a,l;return r(this,function(r){switch(r.label){case 0:e&&fe(!0),se(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Ge(X.applicationId)];case 2:return r.sent(),n=function(e){if(!U.getState().hasPermission("ilotj.scope.view",e.id))return null;var r=e.children?e.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return t(t({},e),{children:r})},[4,b($,K.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=n(s))?(Ee(null),le({data:i}),Ie.current?(re(Ie.current),be("learnings"),Ie.current=null):m.getState().selectedRuleSetId||re(i.id)):(Ee(null!==(l=s.id)&&void 0!==l?l:null),le(null)):(Ee(null),le(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),se("Failed to load data. Please try again later."),[3,6];case 5:return fe(!1),[7];case 6:return[2]}})})};c(function(){var e;(null===(e=null==K?void 0:K.accessToken)||void 0===e?void 0:e.length)&&Fe?xe(!0):console.warn("Error: Trying to fetch rules without access token",K)},[null==K?void 0:K.accessToken,se,ie,X.applicationId,Fe]);var He=function(e){return n(p,void 0,void 0,function(){var n,s,i,a;return r(this,function(r){switch(r.label){case 0:he(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),ue.scopeId?[4,L({scope_id:ue.scopeId,scope_name:e})]:[2];case 2:return r.sent(),[4,xe(!0)];case 3:return r.sent(),de(function(e){return t(t({},e),{isOpen:!1})}),[3,6];case 4:throw n=r.sent(),console.error("An error occurred during scope rename.",n),null===(s=Re.current)||void 0===s||s.show({severity:"error",sticky:!1,className:v.errorToast,content:o(x,{message:(null===(a=null===(i=null==n?void 0:n.response)||void 0===i?void 0:i.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."})}),n;case 5:return he(!1),[7];case 6:return[2]}})})},Qe=function(e,o,s){return n(p,void 0,void 0,function(){var n,o,s,i,a,l,c,u;return r(this,function(r){switch(r.label){case 0:he(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,A(e,K.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===e&&(n=m.getState().scopeTreeData,(o=N((null==n?void 0:n.data)||null,e))&&o.length>1&&(s=o[o.length-2],re(s),be("learnings"))),[4,xe(!0)];case 3:return r.sent(),de(function(e){return t(t({},e),{isOpen:!1})}),null===(a=Re.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===(l=Re.current)||void 0===l||l.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(c=null==i?void 0:i.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return he(!1),[7];case 6:return[2]}})})},ze=ae,Ke=Ae?{data:{id:Ae.stationId,name:Ae.stationName,type:"STATION",metrics:{learningsCount:Ae.learningsCount,stationsCount:0},children:[]}}:ze,Ve=!!(null==Ke?void 0:Ke.data);null===(d=null==Ke?void 0:Ke.data)||void 0===d||d.type;var We=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",X.applicationResourceId||""),Ye=(Ae?Q.filter(function(e){return"stations"!==e.id}):Q).filter(function(e){return!(!te&&"access"===e.id)});return o(_,{children:s("div",t({className:v.learningManagementContainer},{children:[o("div",t({className:v.mainWrapper},{children:me?o(j,{}):oe?s("div",t({className:v.errorContainer},{children:[o("div",t({className:v.errorTitle},{children:"Error Loading Data"})),o("p",t({className:v.errorDesc},{children:oe})),o("button",t({onClick:function(){return xe(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):Ve?o(g,{onOpenCreateModal:function(){return de({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return de({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return de({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,t,o){return n(p,void 0,void 0,function(){var n,s,i;return r(this,function(r){switch(r.label){case 0:return n=m.getState().scopeTreeData,s=N((null==n?void 0:n.data)||null,e),i=!!s&&3===s.length,0!==o?[3,2]:[4,Qe(e)];case 1:return r.sent(),[3,3];case 2:de({isOpen:!0,type:"DELETE",scopeId:e,initialName:t,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Me("ilotj.scope.delete",e)},canEditScope:function(e){return Me("ilotj.scope.edit",e)},canCreateScope:function(e){return Me("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),I(((n={})[w.SECTION]="learnings"===t?null:t,n)),be(t),re(e)},activeSectionId:Se,scopeTreeData:Ke,sectionsConfig:Ye,onViewStation:function(e){we.current=ne,Oe(e),be("learnings"),re(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Ie.current=t),xe(e)},nodeTypesConfig:Pe,app_integration_id:$,token:K.accessToken}):o(h,{onCreate:function(){return de({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:We,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return n(p,void 0,void 0,function(){var e,t,n,s,i,a,l,c,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(s=null===(n=m.getState().scopeTreeData)||void 0===n?void 0:n.data)||void 0===s?void 0:s.id)||Te))return null===(i=Re.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.errorToast,content:o(x,{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,O(e)];case 2:return r.sent(),null===(a=Re.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(q,{message:"Access request submitted successfully!"})}),[3,4];case 3:return t=r.sent(),null===(l=Re.current)||void 0===l||l.show({severity:"error",sticky:!1,className:v.errorToast,content:o(x,{message:(null===(u=null===(c=null==t?void 0:t.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),o(f,{ref:Re,pt:{root:{style:{zIndex:9999}}}}),te&&ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type?o(P,{isOpen:!0,onClose:function(){return de(t(t({},ue),{isOpen:!1}))},onSubmit:function(e){return n(p,void 0,void 0,function(){var n,o,s,i,a,l,c,u,d,p,f,v,g,h,y,S,b,L,A,O;return r(this,function(r){switch(r.label){case 0:he(!0),n=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,n&&"object"==typeof e?o=e:(s=e,i="SCOPE"===ue.type&&ue.parentId,a=i?"genreRuleSet":ue.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ue.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:$}),[4,E(o,K.accessToken)];case 2:if(l=r.sent(),!(c=null===(h=null==l?void 0:l.data)||void 0===h?void 0:h.scopeId))return[3,10];if(Ie.current=c,u=n&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!n&&"GLOBAL"!==ue.type&&ue.parentId,!u&&!d)return[3,10];if(!(p=n?null===(b=null===(S=m.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===b?void 0:b.id:ue.parentId))return[3,10];if(!te)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,T({source_scope_id:p,target_scope_id:c})];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,C({source_scope_id:p,target_scope_id:c,application_mapping_id:$||"",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,xe(!0)];case 11:return r.sent(),de(function(e){return t(t({},e),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(L=Re.current)||void 0===L||L.show({severity:"error",summary:"Creation Failed",detail:(null===(O=null===(A=null==g?void 0:g.response)||void 0===A?void 0:A.data)||void 0===O?void 0:O.message)||"There was an error creating the scope. Please try again."}),g;case 13:return he(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ve,canCreateGlobal:We}):s(i,{children:[o(B,{isOpen:ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type,onClose:function(){return de(t(t({},ue),{isOpen:!1}))},onCreate:function(e){return He(null!=e?e:"")},hasGlobalRuleSet:Ve}),o(H,{isOpen:ue.isOpen&&"RENAME"===ue.type,onClose:function(){return de(t(t({},ue),{isOpen:!1}))},onSave:He,initialName:ue.initialName})]}),o(R,{isOpen:ue.isOpen&&"DELETE"===ue.type,onCancel:function(){return de(t(t({},ue),{isOpen:!1}))},onConfirm:function(){return Qe(ue.scopeId,ue.initialName,ue.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",t({className:v.highlight},{children:ue.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ge})]}))})}export{K as default};
1
+ import{__spreadArray as e,__assign as t,__awaiter as n,__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 l,useEffect as c}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,fetchScopes as b,inheritScope as C,inheritScopeBackwardCompatible as T,createRuleSet as E,renameScope as L,deleteRuleSet as A,requestAccess as O}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as w,setQueryParams as I}from"./hooks/useLearningTemplateQueryParams.js";import R from"./components/ConfirmationModal.js";import j 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 _}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 M}from"./queries/useApprovalQueries.js";import B from"./RuleContent/AddScopeModal.js";import{useLocation as F}from"react-router-dom";import q from"./shared/SuccessToastContent.js";import x from"./shared/ErrorToastContent.js";import H from"./RuleContent/RenameScopeModal.js";var Q=[{id:"learnings",label:"Learnings",icon:u,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:d},{id:"history",label:"Change History",icon:p}],z=new Set(Q.map(function(e){return e.id}));function K(u){var d,p=this,K=u.userDetails,V=u.llmStudioUrl,W=u.audacyBackendUrl,Y=u.ilLabels,J=u.config,X=u.rbacConfig,Z=u.auditLogConfig,$=u.app_integration_id,ee=u.backwardCompatibility,te=void 0!==ee&&ee,ne=m(function(e){return e.selectedRuleSetId}),re=m(function(e){return e.setSelectedRuleSetId}),oe=m(function(e){return e.error}),se=m(function(e){return e.setError}),ie=m(function(e){return e.setStations}),ae=m(function(e){return e.scopeTreeData}),le=m(function(e){return e.setScopeTreeData}),ce=a({isOpen:!1,type:"GLOBAL"}),ue=ce[0],de=ce[1],pe=a(!1),me=pe[0],fe=pe[1],ve=a(!1),ge=ve[0],he=ve[1],ye=a("learnings"),Se=ye[0],be=ye[1],Ce=a(null),Te=Ce[0],Ee=Ce[1],Le=a(null),Ae=Le[0],Oe=Le[1],we=l(null),Ie=l(null),Re=l(null),je=y();je.user;var Ne=je.setUser,ke=D(),De=ke.setConfig,_e=ke.setIlLabels,Pe=e([{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},t({type:"SCOPE",label:"Scope"},!te&&{addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"})],te?[]:[{type:"SUBSCOPE",label:"Subscope"}],!0),Ue=function(){try{return F()}catch(e){return{search:""}}}();c(function(){var e=new URLSearchParams(window.location.search),t=e.get(w.RULESET_ID),n=e.get(w.SECTION),r=n&&z.has(n)?n:"learnings";(null==t?void 0:t.length)&&re&&be&&(re(t),be(r))},[null==Ue?void 0:Ue.search,be,re]);var Ge=U(function(e){return e.fetchPermissions}),Me=U(function(e){return e.hasPermission}),Be=G(function(e){return e.setRoles}),Fe=k(function(e){return e.appsecRbacUrl})===X.appsecRbacUrl,qe=M(X.applicationId,Fe).data;c(function(){qe&&Be(qe.map(function(e){return{_id:e._id,name:e.name}}))},[qe,Be]),c(function(){var e;console.log("userDetails",K),Ne(K),console.log("llmStudioUrl",V),console.log("audacyBackendUrl",W),k.getState().setLlmStudioUrl(V),k.getState().setAudacyBackendUrl(W),k.getState().setRbacConfig(X),k.getState().setAuditLogConfig(Z),De(J),_e(Y),m.getState().setAppIntegrationId(null!=$?$:null),m.getState().setBackwardCompatibility(te),m.getState().setToken(null!==(e=K.accessToken)&&void 0!==e?e:null)},[K,Ne,V,W,X,Z,J,De,Y,_e,$,te]),c(function(){(null==K?void 0:K.accessToken)&&V&&(null==$?void 0:$.trim())&&S()},[$,null==K?void 0:K.accessToken,V]);var xe=function(e){return void 0===e&&(e=!0),n(p,void 0,void 0,function(){var n,o,s,i,a,l;return r(this,function(r){switch(r.label){case 0:e&&fe(!0),se(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Ge(X.applicationId)];case 2:return r.sent(),n=function(e){if(!U.getState().hasPermission("ilotj.scope.view",e.id))return null;var r=e.children?e.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return t(t({},e),{children:r})},[4,b($,K.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=n(s))?(Ee(null),le({data:i}),Ie.current?(re(Ie.current),be("learnings"),Ie.current=null):m.getState().selectedRuleSetId||re(i.id)):(Ee(null!==(l=s.id)&&void 0!==l?l:null),le(null)):(Ee(null),le(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),se("Failed to load data. Please try again later."),[3,6];case 5:return fe(!1),[7];case 6:return[2]}})})};c(function(){var e;(null===(e=null==K?void 0:K.accessToken)||void 0===e?void 0:e.length)&&Fe?xe(!0):console.warn("Error: Trying to fetch rules without access token",K)},[null==K?void 0:K.accessToken,se,ie,X.applicationId,Fe]);var He=function(e){return n(p,void 0,void 0,function(){var n,s,i,a;return r(this,function(r){switch(r.label){case 0:he(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),ue.scopeId?[4,L({scope_id:ue.scopeId,scope_name:e})]:[2];case 2:return r.sent(),[4,xe(!0)];case 3:return r.sent(),de(function(e){return t(t({},e),{isOpen:!1})}),[3,6];case 4:throw n=r.sent(),console.error("An error occurred during scope rename.",n),null===(s=Re.current)||void 0===s||s.show({severity:"error",sticky:!1,className:v.errorToast,content:o(x,{message:(null===(a=null===(i=null==n?void 0:n.response)||void 0===i?void 0:i.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."})}),n;case 5:return he(!1),[7];case 6:return[2]}})})},Qe=function(e,o,s){return n(p,void 0,void 0,function(){var n,o,s,i,a,l,c,u;return r(this,function(r){switch(r.label){case 0:he(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,A(e,K.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===e&&(n=m.getState().scopeTreeData,(o=N((null==n?void 0:n.data)||null,e))&&o.length>1&&(s=o[o.length-2],re(s),be("learnings"))),[4,xe(!0)];case 3:return r.sent(),de(function(e){return t(t({},e),{isOpen:!1})}),null===(a=Re.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===(l=Re.current)||void 0===l||l.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(c=null==i?void 0:i.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return he(!1),[7];case 6:return[2]}})})},ze=ae,Ke=Ae?{data:{id:Ae.stationId,name:Ae.stationName,type:"STATION",metrics:{learningsCount:Ae.learningsCount,stationsCount:0},children:[]}}:ze,Ve=!!(null==Ke?void 0:Ke.data);null===(d=null==Ke?void 0:Ke.data)||void 0===d||d.type;var We=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",X.applicationResourceId||""),Ye=(Ae?Q.filter(function(e){return"stations"!==e.id}):Q).filter(function(e){return!(!te&&"access"===e.id)});return o(_,{children:s("div",t({className:v.learningManagementContainer},{children:[o("div",t({className:v.mainWrapper},{children:me?o(j,{}):oe?s("div",t({className:v.errorContainer},{children:[o("div",t({className:v.errorTitle},{children:"Error Loading Data"})),o("p",t({className:v.errorDesc},{children:oe})),o("button",t({onClick:function(){return xe(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):Ve?o(g,{onOpenCreateModal:function(){return de({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return de({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return de({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,t,o){return n(p,void 0,void 0,function(){var n,s,i;return r(this,function(r){switch(r.label){case 0:return n=m.getState().scopeTreeData,s=N((null==n?void 0:n.data)||null,e),i=!!s&&3===s.length,0!==o?[3,2]:[4,Qe(e)];case 1:return r.sent(),[3,3];case 2:de({isOpen:!0,type:"DELETE",scopeId:e,initialName:t,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Me("ilotj.scope.delete",e)},canEditScope:function(e){return Me("ilotj.scope.edit",e)},canCreateScope:function(e){return Me("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),I(((n={})[w.SECTION]="learnings"===t?null:t,n)),be(t),re(e)},activeSectionId:Se,scopeTreeData:Ke,sectionsConfig:Ye,onViewStation:function(e){we.current=ne,Oe(e),be("learnings"),re(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Ie.current=t),xe(e)},nodeTypesConfig:Pe,app_integration_id:$,token:K.accessToken}):o(h,{onCreate:function(){return de({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:We,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return n(p,void 0,void 0,function(){var e,t,n,s,i,a,l,c,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(s=null===(n=m.getState().scopeTreeData)||void 0===n?void 0:n.data)||void 0===s?void 0:s.id)||Te))return null===(i=Re.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.errorToast,content:o(x,{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,O(e)];case 2:return r.sent(),null===(a=Re.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(q,{message:"Access request submitted successfully!"})}),[3,4];case 3:return t=r.sent(),null===(l=Re.current)||void 0===l||l.show({severity:"error",sticky:!1,className:v.errorToast,content:o(x,{message:(null===(u=null===(c=null==t?void 0:t.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),o(f,{ref:Re,pt:{root:{style:{zIndex:9999}}}}),te&&ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type?o(P,{isOpen:!0,onClose:function(){return de(t(t({},ue),{isOpen:!1}))},onSubmit:function(e){return n(p,void 0,void 0,function(){var n,o,s,i,a,l,c,u,d,p,f,v,g,h,y,S,b,L,A,O;return r(this,function(r){switch(r.label){case 0:he(!0),n=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,n&&"object"==typeof e?o=e:(s=e,i="SCOPE"===ue.type&&ue.parentId,a=i?"genreRuleSet":ue.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ue.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:$}),[4,E(o,K.accessToken)];case 2:if(l=r.sent(),!(c=null===(h=null==l?void 0:l.data)||void 0===h?void 0:h.scopeId))return[3,10];if(Ie.current=c,u=n&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!n&&"GLOBAL"!==ue.type&&ue.parentId,!u&&!d)return[3,10];if(!(p=n?null===(b=null===(S=m.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===b?void 0:b.id:ue.parentId))return[3,10];if(!te)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,T({source_scope_id:p,target_scope_id:c})];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,C({source_scope_id:p,target_scope_id:c,application_mapping_id:$||"",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,xe(!0)];case 11:return r.sent(),de(function(e){return t(t({},e),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(L=Re.current)||void 0===L||L.show({severity:"error",summary:"Creation Failed",detail:(null===(O=null===(A=null==g?void 0:g.response)||void 0===A?void 0:A.data)||void 0===O?void 0:O.message)||"There was an error creating the scope. Please try again."}),g;case 13:return he(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ve,canCreateGlobal:We}):s(i,{children:[o(B,{isOpen:ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type,onClose:function(){return de(t(t({},ue),{isOpen:!1}))},onCreate:function(e){return He(null!=e?e:"")},hasGlobalRuleSet:Ve}),o(H,{isOpen:ue.isOpen&&"RENAME"===ue.type,onClose:function(){return de(t(t({},ue),{isOpen:!1}))},onSave:He,initialName:ue.initialName})]}),o(R,{isOpen:ue.isOpen&&"DELETE"===ue.type,onCancel:function(){return de(t(t({},ue),{isOpen:!1}))},onConfirm:function(){return Qe(ue.scopeId,ue.initialName,ue.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",t({className:v.highlight},{children:ue.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ge})]}))})}export{K as default};
2
2
  //# sourceMappingURL=LearningManagement.js.map