@e-llm-studio/instant-learning 0.1.1-alpha.72 → 0.1.1-alpha.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("lucide-react"),s=require("./store/useLearningTemplateStore.js"),a=require("primereact/toast"),i=require("./styles/LearningTemplateManagement.module.css.js"),o=require("./LearningTemplateLayout.js"),l=require("./components/EmptyLearningState.js"),u=require("./store/useAuthStore.js"),c=require("./apis/scopeApis.js"),d=require("./hooks/useLearningTemplateQueryParams.js"),p=require("./components/ConfirmationModal.js"),f=require("./components/LearningTemplateManagementSkeleton.js"),g=require("./utils/treeUtils.js"),S=require("./store/useEnvStore.js"),m=require("./store/useConfigStore.js"),v=require("./components/ToolTip.js"),_=require("./components/CreateRuleSetLegacyModal.js"),h=require("./store/usePermissionsStore.js"),y=require("./store/useAppSecRolesStore.js"),T=require("./queries/useApprovalQueries.js"),b=require("./RuleContent/AddScopeModal.js"),C=require("react-router-dom"),L=require("./shared/SuccessToastContent.js"),j=require("./shared/ErrorToastContent.js"),E=require("./RuleContent/RenameScopeModal.js"),A=[{id:"learnings",label:"Learnings",icon:r.BookOpen,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:r.Users}],R=new Set(A.map(function(e){return e.id}));exports.default=function(r){var w,O=this,I=r.userDetails,q=r.llmStudioUrl,N=r.audacyBackendUrl,P=r.ilLabels,k=r.config,x=r.rbacConfig,D=r.app_integration_id,U=r.backwardCompatibility,M=void 0!==U&&U,B=s.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),G=s.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),F=s.useLearningTemplateStore(function(e){return e.error}),Q=s.useLearningTemplateStore(function(e){return e.setError}),Y=s.useLearningTemplateStore(function(e){return e.setStations}),K=s.useLearningTemplateStore(function(e){return e.scopeTreeData}),H=s.useLearningTemplateStore(function(e){return e.setScopeTreeData}),V=n.useState({isOpen:!1,type:"GLOBAL"}),W=V[0],z=V[1],J=n.useState(!1),X=J[0],Z=J[1],$=n.useState(!1),ee=$[0],te=$[1],ne=n.useState("learnings"),re=ne[0],se=ne[1],ae=n.useState(null),ie=ae[0],oe=ae[1],le=n.useState(null),ue=le[0],ce=le[1],de=n.useRef(null),pe=n.useRef(null),fe=n.useRef(null),ge=u.default();ge.user;var Se=ge.setUser,me=m.useConfigStore(),ve=me.setConfig,_e=me.setIlLabels,he=e.__spreadArray([{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},e.__assign({type:"SCOPE",label:"Scope"},!M&&{addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"})],M?[]:[{type:"SUBSCOPE",label:"Subscope"}],!0),ye=function(){try{return C.useLocation()}catch(e){return{search:""}}}();n.useEffect(function(){var e=new URLSearchParams(window.location.search),t=e.get(d.QUERY_PARAM_KEYS.RULESET_ID),n=e.get(d.QUERY_PARAM_KEYS.SECTION),r=n&&R.has(n)?n:"learnings";(null==t?void 0:t.length)&&G&&se&&(G(t),se(r))},[null==ye?void 0:ye.search,se,G]);var Te=h.usePermissionsStore(function(e){return e.fetchPermissions}),be=h.usePermissionsStore(function(e){return e.hasPermission}),Ce=y.useAppSecRolesStore(function(e){return e.setRoles}),Le=S.default(function(e){return e.appsecRbacUrl})===x.appsecRbacUrl,je=T.useGetAppSecRolesQuery(x.applicationId,Le).data;n.useEffect(function(){je&&Ce(je.map(function(e){return{_id:e._id,name:e.name}}))},[je,Ce]),n.useEffect(function(){var e;console.log("userDetails",I),Se(I),console.log("llmStudioUrl",q),console.log("audacyBackendUrl",N),S.default.getState().setLlmStudioUrl(q),S.default.getState().setAudacyBackendUrl(N),S.default.getState().setRbacConfig(x),ve(k),_e(P),s.useLearningTemplateStore.getState().setAppIntegrationId(null!=D?D:null),s.useLearningTemplateStore.getState().setBackwardCompatibility(M),s.useLearningTemplateStore.getState().setToken(null!==(e=I.accessToken)&&void 0!==e?e:null)},[I,Se,q,N,x,k,ve,P,_e,D,M]),n.useEffect(function(){(null==I?void 0:I.accessToken)&&q&&c.fetchTiers()},[D,null==I?void 0:I.accessToken,q]);var Ee=function(t){return void 0===t&&(t=!0),e.__awaiter(O,void 0,void 0,function(){var n,r,a,i,o,l;return e.__generator(this,function(u){switch(u.label){case 0:t&&Z(!0),Q(null),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,Te(x.applicationId)];case 2:return u.sent(),n=function(t){if(!h.usePermissionsStore.getState().hasPermission("ilotj.scope.view",t.id))return null;var r=t.children?t.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return e.__assign(e.__assign({},t),{children:r})},[4,c.fetchScopes(D,I.accessToken)];case 3:return(r=u.sent())&&r.data&&r.data.data&&(a=r.data.data,Array.isArray(a)&&(a=a.length>0?a[0]:null),a?(i=n(a))?(oe(null),H({data:i}),pe.current?(G(pe.current),se("learnings"),pe.current=null):s.useLearningTemplateStore.getState().selectedRuleSetId||G(i.id)):(oe(null!==(l=a.id)&&void 0!==l?l:null),H(null)):(oe(null),H(null))),[3,6];case 4:return o=u.sent(),console.error("Failed to fetch rule sets or permissions",o),Q("Failed to load data. Please try again later."),[3,6];case 5:return Z(!1),[7];case 6:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==I?void 0:I.accessToken)||void 0===e?void 0:e.length)&&Le?Ee(!0):console.warn("Error: Trying to fetch rules without access token",I)},[null==I?void 0:I.accessToken,Q,Y,x.applicationId,Le]);var Ae=function(n){return e.__awaiter(O,void 0,void 0,function(){var r,s,a,o;return e.__generator(this,function(l){switch(l.label){case 0:te(!0),l.label=1;case 1:return l.trys.push([1,4,5,6]),W.scopeId?[4,c.renameScope({scope_id:W.scopeId,scope_name:n})]:[2];case 2:return l.sent(),[4,Ee(!0)];case 3:return l.sent(),z(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,6];case 4:throw r=l.sent(),console.error("An error occurred during scope rename.",r),null===(s=fe.current)||void 0===s||s.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(o=null===(a=null==r?void 0:r.response)||void 0===a?void 0:a.data)||void 0===o?void 0:o.message)||"There was an error renaming the scope. Please try again."})}),r;case 5:return te(!1),[7];case 6:return[2]}})})},Re=function(t,n,r){return e.__awaiter(O,void 0,void 0,function(){var n,r,a,i,o,l,u,d;return e.__generator(this,function(p){switch(p.label){case 0:te(!0),p.label=1;case 1:return p.trys.push([1,4,5,6]),[4,c.deleteRuleSet(t,I.accessToken)];case 2:return p.sent(),s.useLearningTemplateStore.getState().selectedRuleSetId===t&&(n=s.useLearningTemplateStore.getState().scopeTreeData,(r=g.findNodePathById((null==n?void 0:n.data)||null,t))&&r.length>1&&(a=r[r.length-2],G(a),se("learnings"))),[4,Ee(!0)];case 3:return p.sent(),z(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(o=fe.current)||void 0===o||o.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=p.sent(),console.error("An error occurred during scope deletion.",i),null===(l=fe.current)||void 0===l||l.show({severity:"error",summary:"Delete Failed",detail:(null===(d=null===(u=null==i?void 0:i.response)||void 0===u?void 0:u.data)||void 0===d?void 0:d.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return te(!1),[7];case 6:return[2]}})})},we=K,Oe=ue?{data:{id:ue.stationId,name:ue.stationName,type:"STATION",metrics:{learningsCount:ue.learningsCount,stationsCount:0},children:[]}}:we,Ie=!!(null==Oe?void 0:Oe.data);null===(w=null==Oe?void 0:Oe.data)||void 0===w||w.type;var qe=h.usePermissionsStore(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",x.applicationResourceId||""),Ne=(ue?A.filter(function(e){return"stations"!==e.id}):A).filter(function(e){return!(!M&&"access"===e.id)});return t.jsx(v.TooltipProvider,{children:t.jsxs("div",e.__assign({className:i.default.learningManagementContainer},{children:[t.jsx("div",e.__assign({className:i.default.mainWrapper},{children:X?t.jsx(f.default,{}):F?t.jsxs("div",e.__assign({className:i.default.errorContainer},{children:[t.jsx("div",e.__assign({className:i.default.errorTitle},{children:"Error Loading Data"})),t.jsx("p",e.__assign({className:i.default.errorDesc},{children:F})),t.jsx("button",e.__assign({onClick:function(){return Ee(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):Ie?t.jsx(o.default,{onOpenCreateModal:function(){return z({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return z({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return z({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(O,void 0,void 0,function(){var a,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return a=s.useLearningTemplateStore.getState().scopeTreeData,i=g.findNodePathById((null==a?void 0:a.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,Re(t)];case 1:return e.sent(),[3,3];case 2:z({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return be("ilotj.scope.delete",e)},canEditScope:function(e){return be("ilotj.scope.edit",e)},canCreateScope:function(e){return be("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),d.setQueryParams(((n={})[d.QUERY_PARAM_KEYS.SECTION]="learnings"===t?null:t,n)),se(t),G(e)},activeSectionId:re,scopeTreeData:Oe,sectionsConfig:Ne,onViewStation:function(e){de.current=B,ce(e),se("learnings"),G(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(pe.current=t),Ee(e)},nodeTypesConfig:he,app_integration_id:D,token:I.accessToken}):t.jsx(l.default,{onCreate:function(){return z({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:qe,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return e.__awaiter(O,void 0,void 0,function(){var n,r,a,o,l,u,d,p,f;return e.__generator(this,function(e){switch(e.label){case 0:if(!(n=(null===(o=null===(a=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id)||ie))return null===(l=fe.current)||void 0===l||l.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:"Unable to identify the global scope for this access request."})}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.requestAccess(n)];case 2:return e.sent(),null===(u=fe.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:i.default.successToast,content:t.jsx(L.default,{message:"Access request submitted successfully!"})}),[3,4];case 3:return r=e.sent(),null===(d=fe.current)||void 0===d||d.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(f=null===(p=null==r?void 0:r.response)||void 0===p?void 0:p.data)||void 0===f?void 0:f.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),t.jsx(a.Toast,{ref:fe}),M&&W.isOpen&&"DELETE"!==W.type&&"RENAME"!==W.type?t.jsx(_.default,{isOpen:!0,onClose:function(){return z(e.__assign(e.__assign({},W),{isOpen:!1}))},onSubmit:function(t){return e.__awaiter(O,void 0,void 0,function(){var n,r,a,i,o,l,u,d,p,f,g,S,m,v,_,h,y,T,b,C;return e.__generator(this,function(L){switch(L.label){case 0:te(!0),n=s.useLearningTemplateStore.getState().backwardCompatibility,L.label=1;case 1:return L.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(a=t,i="SCOPE"===W.type&&W.parentId,o=i?"genreRuleSet":W.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:W.parentId||null,scopeName:a,scopeReferenceMetadata:{},applicationMappingId:D}),[4,c.createRuleSet(r,I.accessToken)];case 2:if(l=L.sent(),!(u=null===(v=null==l?void 0:l.data)||void 0===v?void 0:v.scopeId))return[3,10];if(pe.current=u,d=n&&(null===(_=r.topic)||void 0===_?void 0:_.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==W.type&&W.parentId,!d&&!p)return[3,10];if(!(f=n?null===(y=null===(h=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===h?void 0:h.data)||void 0===y?void 0:y.id:W.parentId))return[3,10];if(!M)return[3,7];L.label=3;case 3:return L.trys.push([3,5,,6]),[4,c.inheritScopeBackwardCompatible({source_scope_id:f,target_scope_id:u})];case 4:return L.sent(),[3,6];case 5:return g=L.sent(),console.error("Failed to inherit rules for the new scope:",g),[3,6];case 6:return[3,10];case 7:return L.trys.push([7,9,,10]),[4,c.inheritScope({source_scope_id:f,target_scope_id:u,application_mapping_id:D||"",is_copy_parent_variant_id:!1})];case 8:return L.sent(),[3,10];case 9:return S=L.sent(),console.error("Failed to inherit rules for the new scope:",S),[3,10];case 10:return[4,Ee(!0)];case 11:return L.sent(),z(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw m=L.sent(),console.error("An error occurred during scope creation.",m),null===(T=fe.current)||void 0===T||T.show({severity:"error",summary:"Creation Failed",detail:(null===(C=null===(b=null==m?void 0:m.response)||void 0===b?void 0:b.data)||void 0===C?void 0:C.message)||"There was an error creating the scope. Please try again."}),m;case 13:return te(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ie,canCreateGlobal:qe}):t.jsxs(t.Fragment,{children:[t.jsx(b.default,{isOpen:W.isOpen&&"DELETE"!==W.type&&"RENAME"!==W.type,onClose:function(){return z(e.__assign(e.__assign({},W),{isOpen:!1}))},onCreate:function(e){return Ae(null!=e?e:"")},hasGlobalRuleSet:Ie}),t.jsx(E.default,{isOpen:W.isOpen&&"RENAME"===W.type,onClose:function(){return z(e.__assign(e.__assign({},W),{isOpen:!1}))},onSave:Ae,initialName:W.initialName})]}),t.jsx(p.default,{isOpen:W.isOpen&&"DELETE"===W.type,onCancel:function(){return z(e.__assign(e.__assign({},W),{isOpen:!1}))},onConfirm:function(){return Re(W.scopeId,W.initialName,W.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:W.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ee})]}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("lucide-react"),s=require("./store/useLearningTemplateStore.js"),a=require("primereact/toast"),i=require("./styles/LearningTemplateManagement.module.css.js"),o=require("./LearningTemplateLayout.js"),l=require("./components/EmptyLearningState.js"),u=require("./store/useAuthStore.js"),c=require("./apis/scopeApis.js"),d=require("./hooks/useLearningTemplateQueryParams.js"),p=require("./components/ConfirmationModal.js"),f=require("./components/LearningTemplateManagementSkeleton.js"),g=require("./utils/treeUtils.js"),S=require("./store/useEnvStore.js"),m=require("./store/useConfigStore.js"),v=require("./components/ToolTip.js"),_=require("./components/CreateRuleSetLegacyModal.js"),h=require("./store/usePermissionsStore.js"),y=require("./store/useAppSecRolesStore.js"),T=require("./queries/useApprovalQueries.js"),b=require("./RuleContent/AddScopeModal.js"),C=require("react-router-dom"),L=require("./shared/SuccessToastContent.js"),j=require("./shared/ErrorToastContent.js"),E=require("./RuleContent/RenameScopeModal.js"),A=[{id:"learnings",label:"Learnings",icon:r.BookOpen,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:r.Users}],R=new Set(A.map(function(e){return e.id}));exports.default=function(r){var w,O=this,I=r.userDetails,q=r.llmStudioUrl,N=r.audacyBackendUrl,P=r.ilLabels,k=r.config,x=r.rbacConfig,D=r.app_integration_id,U=r.backwardCompatibility,M=void 0!==U&&U,B=s.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),G=s.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),F=s.useLearningTemplateStore(function(e){return e.error}),Q=s.useLearningTemplateStore(function(e){return e.setError}),Y=s.useLearningTemplateStore(function(e){return e.setStations}),K=s.useLearningTemplateStore(function(e){return e.scopeTreeData}),z=s.useLearningTemplateStore(function(e){return e.setScopeTreeData}),H=n.useState({isOpen:!1,type:"GLOBAL"}),V=H[0],W=H[1],J=n.useState(!1),X=J[0],Z=J[1],$=n.useState(!1),ee=$[0],te=$[1],ne=n.useState("learnings"),re=ne[0],se=ne[1],ae=n.useState(null),ie=ae[0],oe=ae[1],le=n.useState(null),ue=le[0],ce=le[1],de=n.useRef(null),pe=n.useRef(null),fe=n.useRef(null),ge=u.default();ge.user;var Se=ge.setUser,me=m.useConfigStore(),ve=me.setConfig,_e=me.setIlLabels,he=e.__spreadArray([{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},e.__assign({type:"SCOPE",label:"Scope"},!M&&{addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"})],M?[]:[{type:"SUBSCOPE",label:"Subscope"}],!0),ye=function(){try{return C.useLocation()}catch(e){return{search:""}}}();n.useEffect(function(){var e=new URLSearchParams(window.location.search),t=e.get(d.QUERY_PARAM_KEYS.RULESET_ID),n=e.get(d.QUERY_PARAM_KEYS.SECTION),r=n&&R.has(n)?n:"learnings";(null==t?void 0:t.length)&&G&&se&&(G(t),se(r))},[null==ye?void 0:ye.search,se,G]);var Te=h.usePermissionsStore(function(e){return e.fetchPermissions}),be=h.usePermissionsStore(function(e){return e.hasPermission}),Ce=y.useAppSecRolesStore(function(e){return e.setRoles}),Le=S.default(function(e){return e.appsecRbacUrl})===x.appsecRbacUrl,je=T.useGetAppSecRolesQuery(x.applicationId,Le).data;n.useEffect(function(){je&&Ce(je.map(function(e){return{_id:e._id,name:e.name}}))},[je,Ce]),n.useEffect(function(){var e;console.log("userDetails",I),Se(I),console.log("llmStudioUrl",q),console.log("audacyBackendUrl",N),S.default.getState().setLlmStudioUrl(q),S.default.getState().setAudacyBackendUrl(N),S.default.getState().setRbacConfig(x),ve(k),_e(P),s.useLearningTemplateStore.getState().setAppIntegrationId(null!=D?D:null),s.useLearningTemplateStore.getState().setBackwardCompatibility(M),s.useLearningTemplateStore.getState().setToken(null!==(e=I.accessToken)&&void 0!==e?e:null)},[I,Se,q,N,x,k,ve,P,_e,D,M]),n.useEffect(function(){(null==I?void 0:I.accessToken)&&q&&c.fetchTiers()},[D,null==I?void 0:I.accessToken,q]);var Ee=function(t){return void 0===t&&(t=!0),e.__awaiter(O,void 0,void 0,function(){var n,r,a,i,o,l;return e.__generator(this,function(u){switch(u.label){case 0:t&&Z(!0),Q(null),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,Te(x.applicationId)];case 2:return u.sent(),n=function(t){if(!h.usePermissionsStore.getState().hasPermission("ilotj.scope.view",t.id))return null;var r=t.children?t.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return e.__assign(e.__assign({},t),{children:r})},[4,c.fetchScopes(D,I.accessToken)];case 3:return(r=u.sent())&&r.data&&r.data.data&&(a=r.data.data,Array.isArray(a)&&(a=a.length>0?a[0]:null),a?(i=n(a))?(oe(null),z({data:i}),pe.current?(G(pe.current),se("learnings"),pe.current=null):s.useLearningTemplateStore.getState().selectedRuleSetId||G(i.id)):(oe(null!==(l=a.id)&&void 0!==l?l:null),z(null)):(oe(null),z(null))),[3,6];case 4:return o=u.sent(),console.error("Failed to fetch rule sets or permissions",o),Q("Failed to load data. Please try again later."),[3,6];case 5:return Z(!1),[7];case 6:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==I?void 0:I.accessToken)||void 0===e?void 0:e.length)&&Le?Ee(!0):console.warn("Error: Trying to fetch rules without access token",I)},[null==I?void 0:I.accessToken,Q,Y,x.applicationId,Le]);var Ae=function(n){return e.__awaiter(O,void 0,void 0,function(){var r,s,a,o;return e.__generator(this,function(l){switch(l.label){case 0:te(!0),l.label=1;case 1:return l.trys.push([1,4,5,6]),V.scopeId?[4,c.renameScope({scope_id:V.scopeId,scope_name:n})]:[2];case 2:return l.sent(),[4,Ee(!0)];case 3:return l.sent(),W(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,6];case 4:throw r=l.sent(),console.error("An error occurred during scope rename.",r),null===(s=fe.current)||void 0===s||s.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(o=null===(a=null==r?void 0:r.response)||void 0===a?void 0:a.data)||void 0===o?void 0:o.message)||"There was an error renaming the scope. Please try again."})}),r;case 5:return te(!1),[7];case 6:return[2]}})})},Re=function(t,n,r){return e.__awaiter(O,void 0,void 0,function(){var n,r,a,i,o,l,u,d;return e.__generator(this,function(p){switch(p.label){case 0:te(!0),p.label=1;case 1:return p.trys.push([1,4,5,6]),[4,c.deleteRuleSet(t,I.accessToken)];case 2:return p.sent(),s.useLearningTemplateStore.getState().selectedRuleSetId===t&&(n=s.useLearningTemplateStore.getState().scopeTreeData,(r=g.findNodePathById((null==n?void 0:n.data)||null,t))&&r.length>1&&(a=r[r.length-2],G(a),se("learnings"))),[4,Ee(!0)];case 3:return p.sent(),W(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(o=fe.current)||void 0===o||o.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=p.sent(),console.error("An error occurred during scope deletion.",i),null===(l=fe.current)||void 0===l||l.show({severity:"error",summary:"Delete Failed",detail:(null===(d=null===(u=null==i?void 0:i.response)||void 0===u?void 0:u.data)||void 0===d?void 0:d.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return te(!1),[7];case 6:return[2]}})})},we=K,Oe=ue?{data:{id:ue.stationId,name:ue.stationName,type:"STATION",metrics:{learningsCount:ue.learningsCount,stationsCount:0},children:[]}}:we,Ie=!!(null==Oe?void 0:Oe.data);null===(w=null==Oe?void 0:Oe.data)||void 0===w||w.type;var qe=h.usePermissionsStore(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",x.applicationResourceId||""),Ne=(ue?A.filter(function(e){return"stations"!==e.id}):A).filter(function(e){return!(!M&&"access"===e.id)});return t.jsx(v.TooltipProvider,{children:t.jsxs("div",e.__assign({className:i.default.learningManagementContainer},{children:[t.jsx("div",e.__assign({className:i.default.mainWrapper},{children:X?t.jsx(f.default,{}):F?t.jsxs("div",e.__assign({className:i.default.errorContainer},{children:[t.jsx("div",e.__assign({className:i.default.errorTitle},{children:"Error Loading Data"})),t.jsx("p",e.__assign({className:i.default.errorDesc},{children:F})),t.jsx("button",e.__assign({onClick:function(){return Ee(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):Ie?t.jsx(o.default,{onOpenCreateModal:function(){return W({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return W({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return W({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(O,void 0,void 0,function(){var a,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return a=s.useLearningTemplateStore.getState().scopeTreeData,i=g.findNodePathById((null==a?void 0:a.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,Re(t)];case 1:return e.sent(),[3,3];case 2:W({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return be("ilotj.scope.delete",e)},canEditScope:function(e){return be("ilotj.scope.edit",e)},canCreateScope:function(e){return be("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),d.setQueryParams(((n={})[d.QUERY_PARAM_KEYS.SECTION]="learnings"===t?null:t,n)),se(t),G(e)},activeSectionId:re,scopeTreeData:Oe,sectionsConfig:Ne,onViewStation:function(e){de.current=B,ce(e),se("learnings"),G(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(pe.current=t),Ee(e)},nodeTypesConfig:he,app_integration_id:D,token:I.accessToken}):t.jsx(l.default,{onCreate:function(){return W({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:qe,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return e.__awaiter(O,void 0,void 0,function(){var n,r,a,o,l,u,d,p,f;return e.__generator(this,function(e){switch(e.label){case 0:if(!(n=(null===(o=null===(a=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id)||ie))return null===(l=fe.current)||void 0===l||l.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:"Unable to identify the global scope for this access request."})}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.requestAccess(n)];case 2:return e.sent(),null===(u=fe.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:i.default.successToast,content:t.jsx(L.default,{message:"Access request submitted successfully!"})}),[3,4];case 3:return r=e.sent(),null===(d=fe.current)||void 0===d||d.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(f=null===(p=null==r?void 0:r.response)||void 0===p?void 0:p.data)||void 0===f?void 0:f.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),t.jsx(a.Toast,{ref:fe,pt:{root:{style:{zIndex:9999}}}}),M&&V.isOpen&&"DELETE"!==V.type&&"RENAME"!==V.type?t.jsx(_.default,{isOpen:!0,onClose:function(){return W(e.__assign(e.__assign({},V),{isOpen:!1}))},onSubmit:function(t){return e.__awaiter(O,void 0,void 0,function(){var n,r,a,i,o,l,u,d,p,f,g,S,m,v,_,h,y,T,b,C;return e.__generator(this,function(L){switch(L.label){case 0:te(!0),n=s.useLearningTemplateStore.getState().backwardCompatibility,L.label=1;case 1:return L.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(a=t,i="SCOPE"===V.type&&V.parentId,o=i?"genreRuleSet":V.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:V.parentId||null,scopeName:a,scopeReferenceMetadata:{},applicationMappingId:D}),[4,c.createRuleSet(r,I.accessToken)];case 2:if(l=L.sent(),!(u=null===(v=null==l?void 0:l.data)||void 0===v?void 0:v.scopeId))return[3,10];if(pe.current=u,d=n&&(null===(_=r.topic)||void 0===_?void 0:_.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==V.type&&V.parentId,!d&&!p)return[3,10];if(!(f=n?null===(y=null===(h=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===h?void 0:h.data)||void 0===y?void 0:y.id:V.parentId))return[3,10];if(!M)return[3,7];L.label=3;case 3:return L.trys.push([3,5,,6]),[4,c.inheritScopeBackwardCompatible({source_scope_id:f,target_scope_id:u})];case 4:return L.sent(),[3,6];case 5:return g=L.sent(),console.error("Failed to inherit rules for the new scope:",g),[3,6];case 6:return[3,10];case 7:return L.trys.push([7,9,,10]),[4,c.inheritScope({source_scope_id:f,target_scope_id:u,application_mapping_id:D||"",is_copy_parent_variant_id:!1})];case 8:return L.sent(),[3,10];case 9:return S=L.sent(),console.error("Failed to inherit rules for the new scope:",S),[3,10];case 10:return[4,Ee(!0)];case 11:return L.sent(),W(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw m=L.sent(),console.error("An error occurred during scope creation.",m),null===(T=fe.current)||void 0===T||T.show({severity:"error",summary:"Creation Failed",detail:(null===(C=null===(b=null==m?void 0:m.response)||void 0===b?void 0:b.data)||void 0===C?void 0:C.message)||"There was an error creating the scope. Please try again."}),m;case 13:return te(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ie,canCreateGlobal:qe}):t.jsxs(t.Fragment,{children:[t.jsx(b.default,{isOpen:V.isOpen&&"DELETE"!==V.type&&"RENAME"!==V.type,onClose:function(){return W(e.__assign(e.__assign({},V),{isOpen:!1}))},onCreate:function(e){return Ae(null!=e?e:"")},hasGlobalRuleSet:Ie}),t.jsx(E.default,{isOpen:V.isOpen&&"RENAME"===V.type,onClose:function(){return W(e.__assign(e.__assign({},V),{isOpen:!1}))},onSave:Ae,initialName:V.initialName})]}),t.jsx(p.default,{isOpen:V.isOpen&&"DELETE"===V.type,onCancel:function(){return W(e.__assign(e.__assign({},V),{isOpen:!1}))},onConfirm:function(){return Re(V.scopeId,V.initialName,V.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:V.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ee})]}))})};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});require("../../../node_modules/style-inject/dist/style-inject.es.js").default(".Sidebar-module_sidebar__BhVQw{background-color:#fff;border-right:1px solid #e3e6ea;display:flex;flex-direction:column;height:calc(100vh - 140px);overflow:hidden;padding-top:1.25rem;position:relative;width:fit-content;width:340px}.Sidebar-module_tabsContainer__n542w{margin-bottom:1.25rem;padding:0 1.25rem}.Sidebar-module_tabsWrapper__z6rAx{background-color:#f3f4f6cc;border-radius:.5rem;display:grid;gap:.25rem;grid-template-columns:1fr 1fr;padding:.25rem}.Sidebar-module_tab__79tnm{align-items:center;background:#0000;border:none;border-radius:.375rem;color:#64748b;cursor:pointer;display:flex;font-size:.875rem;font-weight:600;gap:.5rem;justify-content:center;padding:.5rem .75rem;transition:all .2s}.Sidebar-module_tab__79tnm:hover{color:#2563eb}.Sidebar-module_tabActive__amUJ5{background-color:#fff;box-shadow:0 1px 2px 0 #0000000d;color:#2563eb;font-weight:700}.Sidebar-module_searchContainer__KMtRV{margin-bottom:1rem;padding:0 1.25rem}.Sidebar-module_searchWrapper__4ejma{display:flex;gap:.5rem}.Sidebar-module_searchInputWrapper__VI9Qk{align-items:center;display:flex;flex:1;position:relative;width:100%}.Sidebar-module_searchIcon__iyv9p{color:#9ca3af;left:.75rem;position:absolute;top:50%;transform:translateY(-50%)}.Sidebar-module_searchInput__oVmKU{background-color:#fff;border:1px solid #f0f2f5;border-radius:.5rem;box-shadow:0 1px 2px 0 #0000000d;font-size:.875rem;outline:none;padding:.5rem 1rem .5rem 2.25rem;transition:all .2s;width:100%}.Sidebar-module_searchInput__oVmKU:focus{border-color:#2563eb;box-shadow:0 0 0 2px #2563eb33}.Sidebar-module_searchInput__oVmKU::placeholder{color:#9ca3af}.Sidebar-module_searchRightContainer__JZf8q{align-items:center;display:flex;gap:.5rem;position:absolute;right:1rem;top:50%;transform:translateY(-50%)}.Sidebar-module_searchCountBadge__JdOCA{background-color:#fde047;border-radius:.25rem;color:#374151;font-size:.75rem;font-weight:500;padding:.125rem .375rem}.Sidebar-module_searchClearButton__TCsGU{align-items:center;background:#0000;border:none;color:#9ca3af;cursor:pointer;display:flex;margin:0;outline:none;padding:0;transition:color .2s ease}.Sidebar-module_searchClearButton__TCsGU:hover{color:#4b5563}.Sidebar-module_filterButton__OA1Bn{background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;cursor:pointer;padding:.5rem;transition:background-color .2s,border-color .2s}.Sidebar-module_filterButton__OA1Bn:hover{background-color:#f0f2f5}.Sidebar-module_filterButton__OA1Bn svg{color:#19213d}.Sidebar-module_divider__EIZV1{background-color:#f0f2f5;height:1.5px;margin:0 1.25rem 1rem;width:100%}.Sidebar-module_content__iG2Ya{flex:1;overflow-y:auto;padding:0 1.25rem}.Sidebar-module_content__iG2Ya::-webkit-scrollbar{width:4px}.Sidebar-module_content__iG2Ya::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.Sidebar-module_section__ChTDq{margin-bottom:1.5rem}.Sidebar-module_sectionTitle__EC2Bt{color:#19213d;font-size:.875rem;font-weight:600;margin-bottom:.75rem}.Sidebar-module_sectionList__TErRr{display:flex;flex-direction:column;gap:.75rem}.Sidebar-module_createButtonContainer__EECqj{background-color:#fff;border-top:1px solid #e5e7eb;bottom:0;box-shadow:0 -4px 20px #0000000d;left:0;padding:1rem;position:absolute;width:100%;z-index:50}.Sidebar-module_createButton__wE7-a{align-items:center;background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;color:#19213d;cursor:pointer;display:flex;font-size:.75rem;font-weight:500;gap:.5rem;justify-content:center;padding:.75rem;transition:all .2s;width:100%}.Sidebar-module_createButton__wE7-a:hover{background-color:#f3f4f6;box-shadow:0 1px 2px 0 #0000000d}.Sidebar-module_createButton__wE7-a:active{transform:scale(.99)}.Sidebar-module_emptyContent__TV90P{align-items:center;color:#9ca3af;display:flex;flex-direction:column;font-size:.875rem;height:10rem;justify-content:center}"),exports.default={sidebar:"Sidebar-module_sidebar__BhVQw",tabsContainer:"Sidebar-module_tabsContainer__n542w",tabsWrapper:"Sidebar-module_tabsWrapper__z6rAx",tab:"Sidebar-module_tab__79tnm",tabActive:"Sidebar-module_tabActive__amUJ5",searchContainer:"Sidebar-module_searchContainer__KMtRV",searchWrapper:"Sidebar-module_searchWrapper__4ejma",searchInputWrapper:"Sidebar-module_searchInputWrapper__VI9Qk",searchIcon:"Sidebar-module_searchIcon__iyv9p",searchInput:"Sidebar-module_searchInput__oVmKU",searchRightContainer:"Sidebar-module_searchRightContainer__JZf8q",searchCountBadge:"Sidebar-module_searchCountBadge__JdOCA",searchClearButton:"Sidebar-module_searchClearButton__TCsGU",filterButton:"Sidebar-module_filterButton__OA1Bn",divider:"Sidebar-module_divider__EIZV1",content:"Sidebar-module_content__iG2Ya",section:"Sidebar-module_section__ChTDq",sectionTitle:"Sidebar-module_sectionTitle__EC2Bt",sectionList:"Sidebar-module_sectionList__TErRr",createButtonContainer:"Sidebar-module_createButtonContainer__EECqj",createButton:"Sidebar-module_createButton__wE7-a",emptyContent:"Sidebar-module_emptyContent__TV90P"};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});require("../../../node_modules/style-inject/dist/style-inject.es.js").default(".Sidebar-module_sidebar__BhVQw{background-color:#fff;border-right:1px solid #e3e6ea;display:flex;flex-direction:column;height:calc(100vh - 140px);overflow:hidden;padding-top:1.25rem;position:relative;width:340px;width:fit-content}.Sidebar-module_tabsContainer__n542w{margin-bottom:1.25rem;padding:0 1.25rem}.Sidebar-module_tabsWrapper__z6rAx{background-color:#f3f4f6cc;border-radius:.5rem;display:grid;gap:.25rem;grid-template-columns:1fr 1fr;padding:.25rem}.Sidebar-module_tab__79tnm{align-items:center;background:#0000;border:none;border-radius:.375rem;color:#64748b;cursor:pointer;display:flex;font-size:.875rem;font-weight:600;gap:.5rem;justify-content:center;padding:.5rem .75rem;transition:all .2s}.Sidebar-module_tab__79tnm:hover{color:#2563eb}.Sidebar-module_tabActive__amUJ5{background-color:#fff;box-shadow:0 1px 2px 0 #0000000d;color:#2563eb;font-weight:700}.Sidebar-module_searchContainer__KMtRV{margin-bottom:1rem;padding:0 1.25rem}.Sidebar-module_searchWrapper__4ejma{display:flex;gap:.5rem}.Sidebar-module_searchInputWrapper__VI9Qk{align-items:center;display:flex;flex:1;position:relative;width:100%}.Sidebar-module_searchIcon__iyv9p{color:#9ca3af;left:.75rem;position:absolute;top:50%;transform:translateY(-50%)}.Sidebar-module_searchInput__oVmKU{background-color:#fff;border:1px solid #f0f2f5;border-radius:.5rem;box-shadow:0 1px 2px 0 #0000000d;font-size:.875rem;outline:none;padding:.5rem 1rem .5rem 2.25rem;transition:all .2s;width:100%}.Sidebar-module_searchInput__oVmKU:focus{border-color:#2563eb;box-shadow:0 0 0 2px #2563eb33}.Sidebar-module_searchInput__oVmKU::placeholder{color:#9ca3af}.Sidebar-module_searchRightContainer__JZf8q{align-items:center;display:flex;gap:.5rem;position:absolute;right:1rem;top:50%;transform:translateY(-50%)}.Sidebar-module_searchCountBadge__JdOCA{background-color:#fde047;border-radius:.25rem;color:#374151;font-size:.75rem;font-weight:500;padding:.125rem .375rem}.Sidebar-module_searchClearButton__TCsGU{align-items:center;background:#0000;border:none;color:#9ca3af;cursor:pointer;display:flex;margin:0;outline:none;padding:0;transition:color .2s ease}.Sidebar-module_searchClearButton__TCsGU:hover{color:#4b5563}.Sidebar-module_filterButton__OA1Bn{background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;cursor:pointer;padding:.5rem;transition:background-color .2s,border-color .2s}.Sidebar-module_filterButton__OA1Bn:hover{background-color:#f0f2f5}.Sidebar-module_filterButton__OA1Bn svg{color:#19213d}.Sidebar-module_divider__EIZV1{background-color:#f0f2f5;height:1.5px;margin:0 1.25rem 1rem;width:100%}.Sidebar-module_content__iG2Ya{flex:1;overflow-y:auto;padding:0 1.25rem}.Sidebar-module_content__iG2Ya::-webkit-scrollbar{width:4px}.Sidebar-module_content__iG2Ya::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.Sidebar-module_section__ChTDq{margin-bottom:1.5rem}.Sidebar-module_sectionTitle__EC2Bt{color:#19213d;font-size:.875rem;font-weight:600;margin-bottom:.75rem}.Sidebar-module_sectionList__TErRr{display:flex;flex-direction:column;gap:.75rem}.Sidebar-module_createButtonContainer__EECqj{background-color:#fff;border-top:1px solid #e5e7eb;bottom:0;box-shadow:0 -4px 20px #0000000d;left:0;padding:1rem;position:absolute;width:100%;z-index:50}.Sidebar-module_createButton__wE7-a{align-items:center;background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;color:#19213d;cursor:pointer;display:flex;font-size:.75rem;font-weight:500;gap:.5rem;justify-content:center;padding:.75rem;transition:all .2s;width:100%}.Sidebar-module_createButton__wE7-a:hover{background-color:#f3f4f6;box-shadow:0 1px 2px 0 #0000000d}.Sidebar-module_createButton__wE7-a:active{transform:scale(.99)}.Sidebar-module_emptyContent__TV90P{align-items:center;color:#9ca3af;display:flex;flex-direction:column;font-size:.875rem;height:10rem;justify-content:center}"),exports.default={sidebar:"Sidebar-module_sidebar__BhVQw",tabsContainer:"Sidebar-module_tabsContainer__n542w",tabsWrapper:"Sidebar-module_tabsWrapper__z6rAx",tab:"Sidebar-module_tab__79tnm",tabActive:"Sidebar-module_tabActive__amUJ5",searchContainer:"Sidebar-module_searchContainer__KMtRV",searchWrapper:"Sidebar-module_searchWrapper__4ejma",searchInputWrapper:"Sidebar-module_searchInputWrapper__VI9Qk",searchIcon:"Sidebar-module_searchIcon__iyv9p",searchInput:"Sidebar-module_searchInput__oVmKU",searchRightContainer:"Sidebar-module_searchRightContainer__JZf8q",searchCountBadge:"Sidebar-module_searchCountBadge__JdOCA",searchClearButton:"Sidebar-module_searchClearButton__TCsGU",filterButton:"Sidebar-module_filterButton__OA1Bn",divider:"Sidebar-module_divider__EIZV1",content:"Sidebar-module_content__iG2Ya",section:"Sidebar-module_section__ChTDq",sectionTitle:"Sidebar-module_sectionTitle__EC2Bt",sectionList:"Sidebar-module_sectionList__TErRr",createButtonContainer:"Sidebar-module_createButtonContainer__EECqj",createButton:"Sidebar-module_createButton__wE7-a",emptyContent:"Sidebar-module_emptyContent__TV90P"};
2
2
  //# sourceMappingURL=Sidebar.module.css.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}from"lucide-react";import{useLearningTemplateStore as p}from"./store/useLearningTemplateStore.js";import{Toast as m}from"primereact/toast";import f from"./styles/LearningTemplateManagement.module.css.js";import v from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import g from"./store/useAuthStore.js";import{fetchTiers as y,fetchScopes as S,inheritScope as b,inheritScopeBackwardCompatible as C,createRuleSet as T,renameScope as E,deleteRuleSet as O,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as A,setQueryParams as L}from"./hooks/useLearningTemplateQueryParams.js";import I from"./components/ConfirmationModal.js";import R from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as j}from"./utils/treeUtils.js";import N from"./store/useEnvStore.js";import{useConfigStore as k}from"./store/useConfigStore.js";import{TooltipProvider as D}from"./components/ToolTip.js";import _ from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as P}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as U}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import M from"./RuleContent/AddScopeModal.js";import{useLocation as B}from"react-router-dom";import F from"./shared/SuccessToastContent.js";import q from"./shared/ErrorToastContent.js";import x from"./RuleContent/RenameScopeModal.js";var Q=[{id:"learnings",label:"Learnings",icon:u,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:d}],H=new Set(Q.map(function(e){return e.id}));function K(u){var d,K=this,V=u.userDetails,W=u.llmStudioUrl,Y=u.audacyBackendUrl,z=u.ilLabels,J=u.config,X=u.rbacConfig,Z=u.app_integration_id,$=u.backwardCompatibility,ee=void 0!==$&&$,te=p(function(e){return e.selectedRuleSetId}),ne=p(function(e){return e.setSelectedRuleSetId}),re=p(function(e){return e.error}),oe=p(function(e){return e.setError}),se=p(function(e){return e.setStations}),ie=p(function(e){return e.scopeTreeData}),ae=p(function(e){return e.setScopeTreeData}),le=a({isOpen:!1,type:"GLOBAL"}),ce=le[0],ue=le[1],de=a(!1),pe=de[0],me=de[1],fe=a(!1),ve=fe[0],he=fe[1],ge=a("learnings"),ye=ge[0],Se=ge[1],be=a(null),Ce=be[0],Te=be[1],Ee=a(null),Oe=Ee[0],we=Ee[1],Ae=l(null),Le=l(null),Ie=l(null),Re=g();Re.user;var je=Re.setUser,Ne=k(),ke=Ne.setConfig,De=Ne.setIlLabels,_e=e([{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},t({type:"SCOPE",label:"Scope"},!ee&&{addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"})],ee?[]:[{type:"SUBSCOPE",label:"Subscope"}],!0),Pe=function(){try{return B()}catch(e){return{search:""}}}();c(function(){var e=new URLSearchParams(window.location.search),t=e.get(A.RULESET_ID),n=e.get(A.SECTION),r=n&&H.has(n)?n:"learnings";(null==t?void 0:t.length)&&ne&&Se&&(ne(t),Se(r))},[null==Pe?void 0:Pe.search,Se,ne]);var Ue=P(function(e){return e.fetchPermissions}),Ge=P(function(e){return e.hasPermission}),Me=U(function(e){return e.setRoles}),Be=N(function(e){return e.appsecRbacUrl})===X.appsecRbacUrl,Fe=G(X.applicationId,Be).data;c(function(){Fe&&Me(Fe.map(function(e){return{_id:e._id,name:e.name}}))},[Fe,Me]),c(function(){var e;console.log("userDetails",V),je(V),console.log("llmStudioUrl",W),console.log("audacyBackendUrl",Y),N.getState().setLlmStudioUrl(W),N.getState().setAudacyBackendUrl(Y),N.getState().setRbacConfig(X),ke(J),De(z),p.getState().setAppIntegrationId(null!=Z?Z:null),p.getState().setBackwardCompatibility(ee),p.getState().setToken(null!==(e=V.accessToken)&&void 0!==e?e:null)},[V,je,W,Y,X,J,ke,z,De,Z,ee]),c(function(){(null==V?void 0:V.accessToken)&&W&&y()},[Z,null==V?void 0:V.accessToken,W]);var qe=function(e){return void 0===e&&(e=!0),n(K,void 0,void 0,function(){var n,o,s,i,a,l;return r(this,function(r){switch(r.label){case 0:e&&me(!0),oe(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Ue(X.applicationId)];case 2:return r.sent(),n=function(e){if(!P.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,S(Z,V.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))?(Te(null),ae({data:i}),Le.current?(ne(Le.current),Se("learnings"),Le.current=null):p.getState().selectedRuleSetId||ne(i.id)):(Te(null!==(l=s.id)&&void 0!==l?l:null),ae(null)):(Te(null),ae(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),oe("Failed to load data. Please try again later."),[3,6];case 5:return me(!1),[7];case 6:return[2]}})})};c(function(){var e;(null===(e=null==V?void 0:V.accessToken)||void 0===e?void 0:e.length)&&Be?qe(!0):console.warn("Error: Trying to fetch rules without access token",V)},[null==V?void 0:V.accessToken,oe,se,X.applicationId,Be]);var xe=function(e){return n(K,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]),ce.scopeId?[4,E({scope_id:ce.scopeId,scope_name:e})]:[2];case 2:return r.sent(),[4,qe(!0)];case 3:return r.sent(),ue(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=Ie.current)||void 0===s||s.show({severity:"error",sticky:!1,className:f.errorToast,content:o(q,{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(K,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,O(e,V.accessToken)];case 2:return r.sent(),p.getState().selectedRuleSetId===e&&(n=p.getState().scopeTreeData,(o=j((null==n?void 0:n.data)||null,e))&&o.length>1&&(s=o[o.length-2],ne(s),Se("learnings"))),[4,qe(!0)];case 3:return r.sent(),ue(function(e){return t(t({},e),{isOpen:!1})}),null===(a=Ie.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=Ie.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]}})})},He=ie,Ke=Oe?{data:{id:Oe.stationId,name:Oe.stationName,type:"STATION",metrics:{learningsCount:Oe.learningsCount,stationsCount:0},children:[]}}:He,Ve=!!(null==Ke?void 0:Ke.data);null===(d=null==Ke?void 0:Ke.data)||void 0===d||d.type;var We=P(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",X.applicationResourceId||""),Ye=(Oe?Q.filter(function(e){return"stations"!==e.id}):Q).filter(function(e){return!(!ee&&"access"===e.id)});return o(D,{children:s("div",t({className:f.learningManagementContainer},{children:[o("div",t({className:f.mainWrapper},{children:pe?o(R,{}):re?s("div",t({className:f.errorContainer},{children:[o("div",t({className:f.errorTitle},{children:"Error Loading Data"})),o("p",t({className:f.errorDesc},{children:re})),o("button",t({onClick:function(){return qe(!0)},className:f.tryAgainBtn},{children:"Try Again"}))]})):Ve?o(v,{onOpenCreateModal:function(){return ue({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return ue({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return ue({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,t,o){return n(K,void 0,void 0,function(){var n,s,i;return r(this,function(r){switch(r.label){case 0:return n=p.getState().scopeTreeData,s=j((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:ue({isOpen:!0,type:"DELETE",scopeId:e,initialName:t,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Ge("ilotj.scope.delete",e)},canEditScope:function(e){return Ge("ilotj.scope.edit",e)},canCreateScope:function(e){return Ge("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),L(((n={})[A.SECTION]="learnings"===t?null:t,n)),Se(t),ne(e)},activeSectionId:ye,scopeTreeData:Ke,sectionsConfig:Ye,onViewStation:function(e){Ae.current=te,we(e),Se("learnings"),ne(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Le.current=t),qe(e)},nodeTypesConfig:_e,app_integration_id:Z,token:V.accessToken}):o(h,{onCreate:function(){return ue({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(K,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=p.getState().scopeTreeData)||void 0===n?void 0:n.data)||void 0===s?void 0:s.id)||Ce))return null===(i=Ie.current)||void 0===i||i.show({severity:"error",sticky:!1,className:f.errorToast,content:o(q,{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=Ie.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:f.successToast,content:o(F,{message:"Access request submitted successfully!"})}),[3,4];case 3:return t=r.sent(),null===(l=Ie.current)||void 0===l||l.show({severity:"error",sticky:!1,className:f.errorToast,content:o(q,{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(m,{ref:Ie}),ee&&ce.isOpen&&"DELETE"!==ce.type&&"RENAME"!==ce.type?o(_,{isOpen:!0,onClose:function(){return ue(t(t({},ce),{isOpen:!1}))},onSubmit:function(e){return n(K,void 0,void 0,function(){var n,o,s,i,a,l,c,u,d,m,f,v,h,g,y,S,E,O,w,A;return r(this,function(r){switch(r.label){case 0:he(!0),n=p.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"===ce.type&&ce.parentId,a=i?"genreRuleSet":ce.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ce.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:Z}),[4,T(o,V.accessToken)];case 2:if(l=r.sent(),!(c=null===(g=null==l?void 0:l.data)||void 0===g?void 0:g.scopeId))return[3,10];if(Le.current=c,u=n&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!n&&"GLOBAL"!==ce.type&&ce.parentId,!u&&!d)return[3,10];if(!(m=n?null===(E=null===(S=p.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===E?void 0:E.id:ce.parentId))return[3,10];if(!ee)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,C({source_scope_id:m,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,b({source_scope_id:m,target_scope_id:c,application_mapping_id:Z||"",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,qe(!0)];case 11:return r.sent(),ue(function(e){return t(t({},e),{isOpen:!1})}),[3,14];case 12:throw h=r.sent(),console.error("An error occurred during scope creation.",h),null===(O=Ie.current)||void 0===O||O.show({severity:"error",summary:"Creation Failed",detail:(null===(A=null===(w=null==h?void 0:h.response)||void 0===w?void 0:w.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),h;case 13:return he(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ve,canCreateGlobal:We}):s(i,{children:[o(M,{isOpen:ce.isOpen&&"DELETE"!==ce.type&&"RENAME"!==ce.type,onClose:function(){return ue(t(t({},ce),{isOpen:!1}))},onCreate:function(e){return xe(null!=e?e:"")},hasGlobalRuleSet:Ve}),o(x,{isOpen:ce.isOpen&&"RENAME"===ce.type,onClose:function(){return ue(t(t({},ce),{isOpen:!1}))},onSave:xe,initialName:ce.initialName})]}),o(I,{isOpen:ce.isOpen&&"DELETE"===ce.type,onCancel:function(){return ue(t(t({},ce),{isOpen:!1}))},onConfirm:function(){return Qe(ce.scopeId,ce.initialName,ce.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",t({className:f.highlight},{children:ce.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ve})]}))})}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}from"lucide-react";import{useLearningTemplateStore as p}from"./store/useLearningTemplateStore.js";import{Toast as m}from"primereact/toast";import f from"./styles/LearningTemplateManagement.module.css.js";import v from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import g from"./store/useAuthStore.js";import{fetchTiers as y,fetchScopes as S,inheritScope as b,inheritScopeBackwardCompatible as C,createRuleSet as T,renameScope as E,deleteRuleSet as O,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as A,setQueryParams as I}from"./hooks/useLearningTemplateQueryParams.js";import L from"./components/ConfirmationModal.js";import R from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as j}from"./utils/treeUtils.js";import N from"./store/useEnvStore.js";import{useConfigStore as k}from"./store/useConfigStore.js";import{TooltipProvider as D}from"./components/ToolTip.js";import _ from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as P}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as U}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import M from"./RuleContent/AddScopeModal.js";import{useLocation as B}from"react-router-dom";import F from"./shared/SuccessToastContent.js";import q from"./shared/ErrorToastContent.js";import x from"./RuleContent/RenameScopeModal.js";var Q=[{id:"learnings",label:"Learnings",icon:u,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:d}],z=new Set(Q.map(function(e){return e.id}));function H(u){var d,H=this,K=u.userDetails,V=u.llmStudioUrl,W=u.audacyBackendUrl,Y=u.ilLabels,J=u.config,X=u.rbacConfig,Z=u.app_integration_id,$=u.backwardCompatibility,ee=void 0!==$&&$,te=p(function(e){return e.selectedRuleSetId}),ne=p(function(e){return e.setSelectedRuleSetId}),re=p(function(e){return e.error}),oe=p(function(e){return e.setError}),se=p(function(e){return e.setStations}),ie=p(function(e){return e.scopeTreeData}),ae=p(function(e){return e.setScopeTreeData}),le=a({isOpen:!1,type:"GLOBAL"}),ce=le[0],ue=le[1],de=a(!1),pe=de[0],me=de[1],fe=a(!1),ve=fe[0],he=fe[1],ge=a("learnings"),ye=ge[0],Se=ge[1],be=a(null),Ce=be[0],Te=be[1],Ee=a(null),Oe=Ee[0],we=Ee[1],Ae=l(null),Ie=l(null),Le=l(null),Re=g();Re.user;var je=Re.setUser,Ne=k(),ke=Ne.setConfig,De=Ne.setIlLabels,_e=e([{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},t({type:"SCOPE",label:"Scope"},!ee&&{addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"})],ee?[]:[{type:"SUBSCOPE",label:"Subscope"}],!0),Pe=function(){try{return B()}catch(e){return{search:""}}}();c(function(){var e=new URLSearchParams(window.location.search),t=e.get(A.RULESET_ID),n=e.get(A.SECTION),r=n&&z.has(n)?n:"learnings";(null==t?void 0:t.length)&&ne&&Se&&(ne(t),Se(r))},[null==Pe?void 0:Pe.search,Se,ne]);var Ue=P(function(e){return e.fetchPermissions}),Ge=P(function(e){return e.hasPermission}),Me=U(function(e){return e.setRoles}),Be=N(function(e){return e.appsecRbacUrl})===X.appsecRbacUrl,Fe=G(X.applicationId,Be).data;c(function(){Fe&&Me(Fe.map(function(e){return{_id:e._id,name:e.name}}))},[Fe,Me]),c(function(){var e;console.log("userDetails",K),je(K),console.log("llmStudioUrl",V),console.log("audacyBackendUrl",W),N.getState().setLlmStudioUrl(V),N.getState().setAudacyBackendUrl(W),N.getState().setRbacConfig(X),ke(J),De(Y),p.getState().setAppIntegrationId(null!=Z?Z:null),p.getState().setBackwardCompatibility(ee),p.getState().setToken(null!==(e=K.accessToken)&&void 0!==e?e:null)},[K,je,V,W,X,J,ke,Y,De,Z,ee]),c(function(){(null==K?void 0:K.accessToken)&&V&&y()},[Z,null==K?void 0:K.accessToken,V]);var qe=function(e){return void 0===e&&(e=!0),n(H,void 0,void 0,function(){var n,o,s,i,a,l;return r(this,function(r){switch(r.label){case 0:e&&me(!0),oe(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Ue(X.applicationId)];case 2:return r.sent(),n=function(e){if(!P.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,S(Z,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))?(Te(null),ae({data:i}),Ie.current?(ne(Ie.current),Se("learnings"),Ie.current=null):p.getState().selectedRuleSetId||ne(i.id)):(Te(null!==(l=s.id)&&void 0!==l?l:null),ae(null)):(Te(null),ae(null))),[3,6];case 4:return a=r.sent(),console.error("Failed to fetch rule sets or permissions",a),oe("Failed to load data. Please try again later."),[3,6];case 5:return me(!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)&&Be?qe(!0):console.warn("Error: Trying to fetch rules without access token",K)},[null==K?void 0:K.accessToken,oe,se,X.applicationId,Be]);var xe=function(e){return n(H,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]),ce.scopeId?[4,E({scope_id:ce.scopeId,scope_name:e})]:[2];case 2:return r.sent(),[4,qe(!0)];case 3:return r.sent(),ue(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=Le.current)||void 0===s||s.show({severity:"error",sticky:!1,className:f.errorToast,content:o(q,{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(H,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,O(e,K.accessToken)];case 2:return r.sent(),p.getState().selectedRuleSetId===e&&(n=p.getState().scopeTreeData,(o=j((null==n?void 0:n.data)||null,e))&&o.length>1&&(s=o[o.length-2],ne(s),Se("learnings"))),[4,qe(!0)];case 3:return r.sent(),ue(function(e){return t(t({},e),{isOpen:!1})}),null===(a=Le.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=Le.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=ie,He=Oe?{data:{id:Oe.stationId,name:Oe.stationName,type:"STATION",metrics:{learningsCount:Oe.learningsCount,stationsCount:0},children:[]}}:ze,Ke=!!(null==He?void 0:He.data);null===(d=null==He?void 0:He.data)||void 0===d||d.type;var Ve=P(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",X.applicationResourceId||""),We=(Oe?Q.filter(function(e){return"stations"!==e.id}):Q).filter(function(e){return!(!ee&&"access"===e.id)});return o(D,{children:s("div",t({className:f.learningManagementContainer},{children:[o("div",t({className:f.mainWrapper},{children:pe?o(R,{}):re?s("div",t({className:f.errorContainer},{children:[o("div",t({className:f.errorTitle},{children:"Error Loading Data"})),o("p",t({className:f.errorDesc},{children:re})),o("button",t({onClick:function(){return qe(!0)},className:f.tryAgainBtn},{children:"Try Again"}))]})):Ke?o(v,{onOpenCreateModal:function(){return ue({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return ue({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return ue({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,t,o){return n(H,void 0,void 0,function(){var n,s,i;return r(this,function(r){switch(r.label){case 0:return n=p.getState().scopeTreeData,s=j((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:ue({isOpen:!0,type:"DELETE",scopeId:e,initialName:t,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Ge("ilotj.scope.delete",e)},canEditScope:function(e){return Ge("ilotj.scope.edit",e)},canCreateScope:function(e){return Ge("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),I(((n={})[A.SECTION]="learnings"===t?null:t,n)),Se(t),ne(e)},activeSectionId:ye,scopeTreeData:He,sectionsConfig:We,onViewStation:function(e){Ae.current=te,we(e),Se("learnings"),ne(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Ie.current=t),qe(e)},nodeTypesConfig:_e,app_integration_id:Z,token:K.accessToken}):o(h,{onCreate:function(){return ue({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:Ve,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return n(H,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=p.getState().scopeTreeData)||void 0===n?void 0:n.data)||void 0===s?void 0:s.id)||Ce))return null===(i=Le.current)||void 0===i||i.show({severity:"error",sticky:!1,className:f.errorToast,content:o(q,{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=Le.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:f.successToast,content:o(F,{message:"Access request submitted successfully!"})}),[3,4];case 3:return t=r.sent(),null===(l=Le.current)||void 0===l||l.show({severity:"error",sticky:!1,className:f.errorToast,content:o(q,{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(m,{ref:Le,pt:{root:{style:{zIndex:9999}}}}),ee&&ce.isOpen&&"DELETE"!==ce.type&&"RENAME"!==ce.type?o(_,{isOpen:!0,onClose:function(){return ue(t(t({},ce),{isOpen:!1}))},onSubmit:function(e){return n(H,void 0,void 0,function(){var n,o,s,i,a,l,c,u,d,m,f,v,h,g,y,S,E,O,w,A;return r(this,function(r){switch(r.label){case 0:he(!0),n=p.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"===ce.type&&ce.parentId,a=i?"genreRuleSet":ce.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ce.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:Z}),[4,T(o,K.accessToken)];case 2:if(l=r.sent(),!(c=null===(g=null==l?void 0:l.data)||void 0===g?void 0:g.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"!==ce.type&&ce.parentId,!u&&!d)return[3,10];if(!(m=n?null===(E=null===(S=p.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===E?void 0:E.id:ce.parentId))return[3,10];if(!ee)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,C({source_scope_id:m,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,b({source_scope_id:m,target_scope_id:c,application_mapping_id:Z||"",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,qe(!0)];case 11:return r.sent(),ue(function(e){return t(t({},e),{isOpen:!1})}),[3,14];case 12:throw h=r.sent(),console.error("An error occurred during scope creation.",h),null===(O=Le.current)||void 0===O||O.show({severity:"error",summary:"Creation Failed",detail:(null===(A=null===(w=null==h?void 0:h.response)||void 0===w?void 0:w.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),h;case 13:return he(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ke,canCreateGlobal:Ve}):s(i,{children:[o(M,{isOpen:ce.isOpen&&"DELETE"!==ce.type&&"RENAME"!==ce.type,onClose:function(){return ue(t(t({},ce),{isOpen:!1}))},onCreate:function(e){return xe(null!=e?e:"")},hasGlobalRuleSet:Ke}),o(x,{isOpen:ce.isOpen&&"RENAME"===ce.type,onClose:function(){return ue(t(t({},ce),{isOpen:!1}))},onSave:xe,initialName:ce.initialName})]}),o(L,{isOpen:ce.isOpen&&"DELETE"===ce.type,onCancel:function(){return ue(t(t({},ce),{isOpen:!1}))},onConfirm:function(){return Qe(ce.scopeId,ce.initialName,ce.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",t({className:f.highlight},{children:ce.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ve})]}))})}export{H as default};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -1,2 +1,2 @@
1
- import e from"../../../node_modules/style-inject/dist/style-inject.es.js";var r={sidebar:"Sidebar-module_sidebar__BhVQw",tabsContainer:"Sidebar-module_tabsContainer__n542w",tabsWrapper:"Sidebar-module_tabsWrapper__z6rAx",tab:"Sidebar-module_tab__79tnm",tabActive:"Sidebar-module_tabActive__amUJ5",searchContainer:"Sidebar-module_searchContainer__KMtRV",searchWrapper:"Sidebar-module_searchWrapper__4ejma",searchInputWrapper:"Sidebar-module_searchInputWrapper__VI9Qk",searchIcon:"Sidebar-module_searchIcon__iyv9p",searchInput:"Sidebar-module_searchInput__oVmKU",searchRightContainer:"Sidebar-module_searchRightContainer__JZf8q",searchCountBadge:"Sidebar-module_searchCountBadge__JdOCA",searchClearButton:"Sidebar-module_searchClearButton__TCsGU",filterButton:"Sidebar-module_filterButton__OA1Bn",divider:"Sidebar-module_divider__EIZV1",content:"Sidebar-module_content__iG2Ya",section:"Sidebar-module_section__ChTDq",sectionTitle:"Sidebar-module_sectionTitle__EC2Bt",sectionList:"Sidebar-module_sectionList__TErRr",createButtonContainer:"Sidebar-module_createButtonContainer__EECqj",createButton:"Sidebar-module_createButton__wE7-a",emptyContent:"Sidebar-module_emptyContent__TV90P"};e(".Sidebar-module_sidebar__BhVQw{background-color:#fff;border-right:1px solid #e3e6ea;display:flex;flex-direction:column;height:calc(100vh - 140px);overflow:hidden;padding-top:1.25rem;position:relative;width:fit-content;width:340px}.Sidebar-module_tabsContainer__n542w{margin-bottom:1.25rem;padding:0 1.25rem}.Sidebar-module_tabsWrapper__z6rAx{background-color:#f3f4f6cc;border-radius:.5rem;display:grid;gap:.25rem;grid-template-columns:1fr 1fr;padding:.25rem}.Sidebar-module_tab__79tnm{align-items:center;background:#0000;border:none;border-radius:.375rem;color:#64748b;cursor:pointer;display:flex;font-size:.875rem;font-weight:600;gap:.5rem;justify-content:center;padding:.5rem .75rem;transition:all .2s}.Sidebar-module_tab__79tnm:hover{color:#2563eb}.Sidebar-module_tabActive__amUJ5{background-color:#fff;box-shadow:0 1px 2px 0 #0000000d;color:#2563eb;font-weight:700}.Sidebar-module_searchContainer__KMtRV{margin-bottom:1rem;padding:0 1.25rem}.Sidebar-module_searchWrapper__4ejma{display:flex;gap:.5rem}.Sidebar-module_searchInputWrapper__VI9Qk{align-items:center;display:flex;flex:1;position:relative;width:100%}.Sidebar-module_searchIcon__iyv9p{color:#9ca3af;left:.75rem;position:absolute;top:50%;transform:translateY(-50%)}.Sidebar-module_searchInput__oVmKU{background-color:#fff;border:1px solid #f0f2f5;border-radius:.5rem;box-shadow:0 1px 2px 0 #0000000d;font-size:.875rem;outline:none;padding:.5rem 1rem .5rem 2.25rem;transition:all .2s;width:100%}.Sidebar-module_searchInput__oVmKU:focus{border-color:#2563eb;box-shadow:0 0 0 2px #2563eb33}.Sidebar-module_searchInput__oVmKU::placeholder{color:#9ca3af}.Sidebar-module_searchRightContainer__JZf8q{align-items:center;display:flex;gap:.5rem;position:absolute;right:1rem;top:50%;transform:translateY(-50%)}.Sidebar-module_searchCountBadge__JdOCA{background-color:#fde047;border-radius:.25rem;color:#374151;font-size:.75rem;font-weight:500;padding:.125rem .375rem}.Sidebar-module_searchClearButton__TCsGU{align-items:center;background:#0000;border:none;color:#9ca3af;cursor:pointer;display:flex;margin:0;outline:none;padding:0;transition:color .2s ease}.Sidebar-module_searchClearButton__TCsGU:hover{color:#4b5563}.Sidebar-module_filterButton__OA1Bn{background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;cursor:pointer;padding:.5rem;transition:background-color .2s,border-color .2s}.Sidebar-module_filterButton__OA1Bn:hover{background-color:#f0f2f5}.Sidebar-module_filterButton__OA1Bn svg{color:#19213d}.Sidebar-module_divider__EIZV1{background-color:#f0f2f5;height:1.5px;margin:0 1.25rem 1rem;width:100%}.Sidebar-module_content__iG2Ya{flex:1;overflow-y:auto;padding:0 1.25rem}.Sidebar-module_content__iG2Ya::-webkit-scrollbar{width:4px}.Sidebar-module_content__iG2Ya::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.Sidebar-module_section__ChTDq{margin-bottom:1.5rem}.Sidebar-module_sectionTitle__EC2Bt{color:#19213d;font-size:.875rem;font-weight:600;margin-bottom:.75rem}.Sidebar-module_sectionList__TErRr{display:flex;flex-direction:column;gap:.75rem}.Sidebar-module_createButtonContainer__EECqj{background-color:#fff;border-top:1px solid #e5e7eb;bottom:0;box-shadow:0 -4px 20px #0000000d;left:0;padding:1rem;position:absolute;width:100%;z-index:50}.Sidebar-module_createButton__wE7-a{align-items:center;background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;color:#19213d;cursor:pointer;display:flex;font-size:.75rem;font-weight:500;gap:.5rem;justify-content:center;padding:.75rem;transition:all .2s;width:100%}.Sidebar-module_createButton__wE7-a:hover{background-color:#f3f4f6;box-shadow:0 1px 2px 0 #0000000d}.Sidebar-module_createButton__wE7-a:active{transform:scale(.99)}.Sidebar-module_emptyContent__TV90P{align-items:center;color:#9ca3af;display:flex;flex-direction:column;font-size:.875rem;height:10rem;justify-content:center}");export{r as default};
1
+ import e from"../../../node_modules/style-inject/dist/style-inject.es.js";var r={sidebar:"Sidebar-module_sidebar__BhVQw",tabsContainer:"Sidebar-module_tabsContainer__n542w",tabsWrapper:"Sidebar-module_tabsWrapper__z6rAx",tab:"Sidebar-module_tab__79tnm",tabActive:"Sidebar-module_tabActive__amUJ5",searchContainer:"Sidebar-module_searchContainer__KMtRV",searchWrapper:"Sidebar-module_searchWrapper__4ejma",searchInputWrapper:"Sidebar-module_searchInputWrapper__VI9Qk",searchIcon:"Sidebar-module_searchIcon__iyv9p",searchInput:"Sidebar-module_searchInput__oVmKU",searchRightContainer:"Sidebar-module_searchRightContainer__JZf8q",searchCountBadge:"Sidebar-module_searchCountBadge__JdOCA",searchClearButton:"Sidebar-module_searchClearButton__TCsGU",filterButton:"Sidebar-module_filterButton__OA1Bn",divider:"Sidebar-module_divider__EIZV1",content:"Sidebar-module_content__iG2Ya",section:"Sidebar-module_section__ChTDq",sectionTitle:"Sidebar-module_sectionTitle__EC2Bt",sectionList:"Sidebar-module_sectionList__TErRr",createButtonContainer:"Sidebar-module_createButtonContainer__EECqj",createButton:"Sidebar-module_createButton__wE7-a",emptyContent:"Sidebar-module_emptyContent__TV90P"};e(".Sidebar-module_sidebar__BhVQw{background-color:#fff;border-right:1px solid #e3e6ea;display:flex;flex-direction:column;height:calc(100vh - 140px);overflow:hidden;padding-top:1.25rem;position:relative;width:340px;width:fit-content}.Sidebar-module_tabsContainer__n542w{margin-bottom:1.25rem;padding:0 1.25rem}.Sidebar-module_tabsWrapper__z6rAx{background-color:#f3f4f6cc;border-radius:.5rem;display:grid;gap:.25rem;grid-template-columns:1fr 1fr;padding:.25rem}.Sidebar-module_tab__79tnm{align-items:center;background:#0000;border:none;border-radius:.375rem;color:#64748b;cursor:pointer;display:flex;font-size:.875rem;font-weight:600;gap:.5rem;justify-content:center;padding:.5rem .75rem;transition:all .2s}.Sidebar-module_tab__79tnm:hover{color:#2563eb}.Sidebar-module_tabActive__amUJ5{background-color:#fff;box-shadow:0 1px 2px 0 #0000000d;color:#2563eb;font-weight:700}.Sidebar-module_searchContainer__KMtRV{margin-bottom:1rem;padding:0 1.25rem}.Sidebar-module_searchWrapper__4ejma{display:flex;gap:.5rem}.Sidebar-module_searchInputWrapper__VI9Qk{align-items:center;display:flex;flex:1;position:relative;width:100%}.Sidebar-module_searchIcon__iyv9p{color:#9ca3af;left:.75rem;position:absolute;top:50%;transform:translateY(-50%)}.Sidebar-module_searchInput__oVmKU{background-color:#fff;border:1px solid #f0f2f5;border-radius:.5rem;box-shadow:0 1px 2px 0 #0000000d;font-size:.875rem;outline:none;padding:.5rem 1rem .5rem 2.25rem;transition:all .2s;width:100%}.Sidebar-module_searchInput__oVmKU:focus{border-color:#2563eb;box-shadow:0 0 0 2px #2563eb33}.Sidebar-module_searchInput__oVmKU::placeholder{color:#9ca3af}.Sidebar-module_searchRightContainer__JZf8q{align-items:center;display:flex;gap:.5rem;position:absolute;right:1rem;top:50%;transform:translateY(-50%)}.Sidebar-module_searchCountBadge__JdOCA{background-color:#fde047;border-radius:.25rem;color:#374151;font-size:.75rem;font-weight:500;padding:.125rem .375rem}.Sidebar-module_searchClearButton__TCsGU{align-items:center;background:#0000;border:none;color:#9ca3af;cursor:pointer;display:flex;margin:0;outline:none;padding:0;transition:color .2s ease}.Sidebar-module_searchClearButton__TCsGU:hover{color:#4b5563}.Sidebar-module_filterButton__OA1Bn{background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;cursor:pointer;padding:.5rem;transition:background-color .2s,border-color .2s}.Sidebar-module_filterButton__OA1Bn:hover{background-color:#f0f2f5}.Sidebar-module_filterButton__OA1Bn svg{color:#19213d}.Sidebar-module_divider__EIZV1{background-color:#f0f2f5;height:1.5px;margin:0 1.25rem 1rem;width:100%}.Sidebar-module_content__iG2Ya{flex:1;overflow-y:auto;padding:0 1.25rem}.Sidebar-module_content__iG2Ya::-webkit-scrollbar{width:4px}.Sidebar-module_content__iG2Ya::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.Sidebar-module_section__ChTDq{margin-bottom:1.5rem}.Sidebar-module_sectionTitle__EC2Bt{color:#19213d;font-size:.875rem;font-weight:600;margin-bottom:.75rem}.Sidebar-module_sectionList__TErRr{display:flex;flex-direction:column;gap:.75rem}.Sidebar-module_createButtonContainer__EECqj{background-color:#fff;border-top:1px solid #e5e7eb;bottom:0;box-shadow:0 -4px 20px #0000000d;left:0;padding:1rem;position:absolute;width:100%;z-index:50}.Sidebar-module_createButton__wE7-a{align-items:center;background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;color:#19213d;cursor:pointer;display:flex;font-size:.75rem;font-weight:500;gap:.5rem;justify-content:center;padding:.75rem;transition:all .2s;width:100%}.Sidebar-module_createButton__wE7-a:hover{background-color:#f3f4f6;box-shadow:0 1px 2px 0 #0000000d}.Sidebar-module_createButton__wE7-a:active{transform:scale(.99)}.Sidebar-module_emptyContent__TV90P{align-items:center;color:#9ca3af;display:flex;flex-direction:column;font-size:.875rem;height:10rem;justify-content:center}");export{r as default};
2
2
  //# sourceMappingURL=Sidebar.module.css.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-llm-studio/instant-learning",
3
- "version": "0.1.1-alpha.72",
3
+ "version": "0.1.1-alpha.74",
4
4
  "author": "Devesh Patel",
5
5
  "description": "",
6
6
  "license": "MIT",