@atlashub/smartstack 3.21.0 → 3.25.0
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/chunks/{AgentSkillsPage-7si3Ng8e.js → AgentSkillsPage-BWQSCYl-.js} +2 -2
- package/dist/chunks/{AgentSkillsPage-7si3Ng8e.js.map → AgentSkillsPage-BWQSCYl-.js.map} +1 -1
- package/dist/chunks/{AgentSkillsPage-D0cD1QdM.js → AgentSkillsPage-IQcMnBaD.js} +2 -2
- package/dist/chunks/{AgentSkillsPage-D0cD1QdM.js.map → AgentSkillsPage-IQcMnBaD.js.map} +1 -1
- package/dist/chunks/{AgentWorkloadPage-H_7ze33H.js → AgentWorkloadPage-DqrjkvWL.js} +2 -2
- package/dist/chunks/{AgentWorkloadPage-H_7ze33H.js.map → AgentWorkloadPage-DqrjkvWL.js.map} +1 -1
- package/dist/chunks/{AgentWorkloadPage-D4d86cdV.js → AgentWorkloadPage-w-HiyFYP.js} +2 -2
- package/dist/chunks/{AgentWorkloadPage-D4d86cdV.js.map → AgentWorkloadPage-w-HiyFYP.js.map} +1 -1
- package/dist/chunks/{ApiCatalogDetailPage-2ktkRrCb.js → ApiCatalogDetailPage-D3L8Yf4G.js} +3 -3
- package/dist/chunks/{ApiCatalogDetailPage-2ktkRrCb.js.map → ApiCatalogDetailPage-D3L8Yf4G.js.map} +1 -1
- package/dist/chunks/{ApiCatalogDetailPage-BQ53xuwD.js → ApiCatalogDetailPage-MPT3Kz6H.js} +2 -2
- package/dist/chunks/{ApiCatalogDetailPage-BQ53xuwD.js.map → ApiCatalogDetailPage-MPT3Kz6H.js.map} +1 -1
- package/dist/chunks/{ApiCatalogPage-BEqTDJz8.js → ApiCatalogPage-D4Hg3uiS.js} +2 -2
- package/dist/chunks/{ApiCatalogPage-BEqTDJz8.js.map → ApiCatalogPage-D4Hg3uiS.js.map} +1 -1
- package/dist/chunks/{ApiCatalogPage-BBkWSLI8.js → ApiCatalogPage-DRg5Cz0r.js} +2 -2
- package/dist/chunks/{ApiCatalogPage-BBkWSLI8.js.map → ApiCatalogPage-DRg5Cz0r.js.map} +1 -1
- package/dist/chunks/{ApplicationDetailPage-BYJ2YMPq.js → ApplicationDetailPage-Caizuyn2.js} +2 -2
- package/dist/chunks/{ApplicationDetailPage-BYJ2YMPq.js.map → ApplicationDetailPage-Caizuyn2.js.map} +1 -1
- package/dist/chunks/{ApplicationDetailPage-D8-bf1as.js → ApplicationDetailPage-CuCW6aMB.js} +4 -4
- package/dist/chunks/{ApplicationDetailPage-D8-bf1as.js.map → ApplicationDetailPage-CuCW6aMB.js.map} +1 -1
- package/dist/chunks/{ApplicationsDashboardPage-BBlLms2r.js → ApplicationsDashboardPage-B2MW8-Kc.js} +2 -2
- package/dist/chunks/{ApplicationsDashboardPage-BBlLms2r.js.map → ApplicationsDashboardPage-B2MW8-Kc.js.map} +1 -1
- package/dist/chunks/{ApplicationsDashboardPage-DTWZxJJM.js → ApplicationsDashboardPage-BDIjFIYZ.js} +3 -3
- package/dist/chunks/{ApplicationsDashboardPage-DTWZxJJM.js.map → ApplicationsDashboardPage-BDIjFIYZ.js.map} +1 -1
- package/dist/chunks/{ApplicationsGridPage-BQaMsK1K.js → ApplicationsGridPage-DV-FihKj.js} +2 -2
- package/dist/chunks/{ApplicationsGridPage-BQaMsK1K.js.map → ApplicationsGridPage-DV-FihKj.js.map} +1 -1
- package/dist/chunks/{ApplicationsGridPage-DbVcvezt.js → ApplicationsGridPage-DXsTfXPI.js} +2 -2
- package/dist/chunks/{ApplicationsGridPage-DbVcvezt.js.map → ApplicationsGridPage-DXsTfXPI.js.map} +1 -1
- package/dist/chunks/{ApplicationsListPage-DYKM2Yeo.js → ApplicationsListPage--CGkyBuJ.js} +2 -2
- package/dist/chunks/{ApplicationsListPage-DYKM2Yeo.js.map → ApplicationsListPage--CGkyBuJ.js.map} +1 -1
- package/dist/chunks/{ApplicationsListPage-C91v2rZt.js → ApplicationsListPage-JUX823bh.js} +2 -2
- package/dist/chunks/{ApplicationsListPage-C91v2rZt.js.map → ApplicationsListPage-JUX823bh.js.map} +1 -1
- package/dist/chunks/{ApplicationsPage-BCbgotIx.js → ApplicationsPage-6zgFye6w.js} +2 -2
- package/dist/chunks/{ApplicationsPage-BCbgotIx.js.map → ApplicationsPage-6zgFye6w.js.map} +1 -1
- package/dist/chunks/{ApplicationsPage-CW3-Hjlu.js → ApplicationsPage-CQPuuiO6.js} +4 -4
- package/dist/chunks/{ApplicationsPage-CW3-Hjlu.js.map → ApplicationsPage-CQPuuiO6.js.map} +1 -1
- package/dist/chunks/{AssignmentRulesPage-D8vfGDBN.js → AssignmentRulesPage-CFffeEbo.js} +2 -2
- package/dist/chunks/{AssignmentRulesPage-D8vfGDBN.js.map → AssignmentRulesPage-CFffeEbo.js.map} +1 -1
- package/dist/chunks/{AssignmentRulesPage-CxktlEMB.js → AssignmentRulesPage-D78UeUId.js} +2 -2
- package/dist/chunks/{AssignmentRulesPage-CxktlEMB.js.map → AssignmentRulesPage-D78UeUId.js.map} +1 -1
- package/dist/chunks/{AssignmentsPage-DmfBYQAD.js → AssignmentsPage-Cww2ifZF.js} +2 -2
- package/dist/chunks/{AssignmentsPage-DmfBYQAD.js.map → AssignmentsPage-Cww2ifZF.js.map} +1 -1
- package/dist/chunks/{AssignmentsPage-sRCCBmRc.js → AssignmentsPage-DE_QS2LO.js} +2 -2
- package/dist/chunks/{AssignmentsPage-sRCCBmRc.js.map → AssignmentsPage-DE_QS2LO.js.map} +1 -1
- package/dist/chunks/{AuthCallbackPage-C7XiZxKb.js → AuthCallbackPage-CA2nO6DG.js} +2 -2
- package/dist/chunks/{AuthCallbackPage-C7XiZxKb.js.map → AuthCallbackPage-CA2nO6DG.js.map} +1 -1
- package/dist/chunks/{AuthCallbackPage-BCe_bwJM.js → AuthCallbackPage-CDUAoX-N.js} +2 -2
- package/dist/chunks/{AuthCallbackPage-BCe_bwJM.js.map → AuthCallbackPage-CDUAoX-N.js.map} +1 -1
- package/dist/chunks/{ConfirmEmailPage-BUfGSqxF.js → ConfirmEmailPage-BqsILAYH.js} +2 -2
- package/dist/chunks/{ConfirmEmailPage-BUfGSqxF.js.map → ConfirmEmailPage-BqsILAYH.js.map} +1 -1
- package/dist/chunks/{ConfirmEmailPage-Buj4x-rx.js → ConfirmEmailPage-INeHCuMB.js} +2 -2
- package/dist/chunks/{ConfirmEmailPage-Buj4x-rx.js.map → ConfirmEmailPage-INeHCuMB.js.map} +1 -1
- package/dist/chunks/{CreateSupportTicketPage-CKDX_HQm.js → CreateSupportTicketPage-BWeuV2aU.js} +2 -2
- package/dist/chunks/{CreateSupportTicketPage-CKDX_HQm.js.map → CreateSupportTicketPage-BWeuV2aU.js.map} +1 -1
- package/dist/chunks/{CreateSupportTicketPage-0LgY-_pu.js → CreateSupportTicketPage-OBwF4v7b.js} +2 -2
- package/dist/chunks/{CreateSupportTicketPage-0LgY-_pu.js.map → CreateSupportTicketPage-OBwF4v7b.js.map} +1 -1
- package/dist/chunks/{DashboardPage-CUZ80NGV.js → DashboardPage-CKHqWrdS.js} +3 -3
- package/dist/chunks/{DashboardPage-CUZ80NGV.js.map → DashboardPage-CKHqWrdS.js.map} +1 -1
- package/dist/chunks/{DashboardPage-CaNOAstg.js → DashboardPage-COmc9b__.js} +3 -3
- package/dist/chunks/{DashboardPage-CaNOAstg.js.map → DashboardPage-COmc9b__.js.map} +1 -1
- package/dist/chunks/{DashboardPage-B48_rQFi.js → DashboardPage-CfKZHiSj.js} +2 -2
- package/dist/chunks/{DashboardPage-B48_rQFi.js.map → DashboardPage-CfKZHiSj.js.map} +1 -1
- package/dist/chunks/{DashboardPage-CUZV1J9t.js → DashboardPage-CwEZZ3jx.js} +2 -2
- package/dist/chunks/{DashboardPage-CUZV1J9t.js.map → DashboardPage-CwEZZ3jx.js.map} +1 -1
- package/dist/chunks/{EscalationConfigPage-CdzAbnGy.js → EscalationConfigPage--7lgZ0kJ.js} +2 -2
- package/dist/chunks/{EscalationConfigPage-CdzAbnGy.js.map → EscalationConfigPage--7lgZ0kJ.js.map} +1 -1
- package/dist/chunks/{EscalationConfigPage-CYGIl_e6.js → EscalationConfigPage-DPyiBcqV.js} +2 -2
- package/dist/chunks/{EscalationConfigPage-CYGIl_e6.js.map → EscalationConfigPage-DPyiBcqV.js.map} +1 -1
- package/dist/chunks/{ForceChangePasswordPage-lRpkwcX7.js → ForceChangePasswordPage-BE-6umub.js} +2 -2
- package/dist/chunks/{ForceChangePasswordPage-lRpkwcX7.js.map → ForceChangePasswordPage-BE-6umub.js.map} +1 -1
- package/dist/chunks/{ForceChangePasswordPage-CvmYAV3r.js → ForceChangePasswordPage-CnsYoWmV.js} +2 -2
- package/dist/chunks/{ForceChangePasswordPage-CvmYAV3r.js.map → ForceChangePasswordPage-CnsYoWmV.js.map} +1 -1
- package/dist/chunks/{ForgotPasswordPage-0u49E4Pw.js → ForgotPasswordPage-CSq4DnFF.js} +2 -2
- package/dist/chunks/{ForgotPasswordPage-0u49E4Pw.js.map → ForgotPasswordPage-CSq4DnFF.js.map} +1 -1
- package/dist/chunks/{ForgotPasswordPage-CxQUqKOm.js → ForgotPasswordPage-DZLVolAC.js} +2 -2
- package/dist/chunks/{ForgotPasswordPage-CxQUqKOm.js.map → ForgotPasswordPage-DZLVolAC.js.map} +1 -1
- package/dist/chunks/{GroupDetailPage-DFBvVO1S.js → GroupDetailPage-Bf9Wb_2j.js} +5 -5
- package/dist/chunks/{GroupDetailPage-DFBvVO1S.js.map → GroupDetailPage-Bf9Wb_2j.js.map} +1 -1
- package/dist/chunks/{GroupDetailPage-B2FkKrGG.js → GroupDetailPage-R-hf3rJ7.js} +2 -2
- package/dist/chunks/{GroupDetailPage-B2FkKrGG.js.map → GroupDetailPage-R-hf3rJ7.js.map} +1 -1
- package/dist/chunks/{MyAccessRequestsPage-C9IX4c0K.js → MyAccessRequestsPage-BIisvWM6.js} +2 -2
- package/dist/chunks/{MyAccessRequestsPage-C9IX4c0K.js.map → MyAccessRequestsPage-BIisvWM6.js.map} +1 -1
- package/dist/chunks/{MyAccessRequestsPage-D6pVULNM.js → MyAccessRequestsPage-BLSV7Tbx.js} +2 -2
- package/dist/chunks/{MyAccessRequestsPage-D6pVULNM.js.map → MyAccessRequestsPage-BLSV7Tbx.js.map} +1 -1
- package/dist/chunks/{MyTenantsPage-BEcYYdGR.js → MyTenantsPage-D-7k9CP1.js} +3 -3
- package/dist/chunks/{MyTenantsPage-BEcYYdGR.js.map → MyTenantsPage-D-7k9CP1.js.map} +1 -1
- package/dist/chunks/{MyTenantsPage-D9f85zjF.js → MyTenantsPage-DqGW6aDt.js} +2 -2
- package/dist/chunks/{MyTenantsPage-D9f85zjF.js.map → MyTenantsPage-DqGW6aDt.js.map} +1 -1
- package/dist/chunks/{MyTicketsPage-DJR8h6y1.js → MyTicketsPage--DgDsnZA.js} +2 -2
- package/dist/chunks/{MyTicketsPage-DJR8h6y1.js.map → MyTicketsPage--DgDsnZA.js.map} +1 -1
- package/dist/chunks/{MyTicketsPage-DiOUExKJ.js → MyTicketsPage-CqJ3Aqob.js} +2 -2
- package/dist/chunks/{MyTicketsPage-DiOUExKJ.js.map → MyTicketsPage-CqJ3Aqob.js.map} +1 -1
- package/dist/chunks/{NavigationAppsPage-CeHbxfZw.js → NavigationAppsPage-Bebis_RT.js} +2 -2
- package/dist/chunks/{NavigationAppsPage-CeHbxfZw.js.map → NavigationAppsPage-Bebis_RT.js.map} +1 -1
- package/dist/chunks/{NavigationAppsPage-If7tmCFY.js → NavigationAppsPage-THNPOAjv.js} +2 -2
- package/dist/chunks/{NavigationAppsPage-If7tmCFY.js.map → NavigationAppsPage-THNPOAjv.js.map} +1 -1
- package/dist/chunks/{NotificationsPage-C29Lln5o.js → NotificationsPage-CAbNW_Cn.js} +2 -2
- package/dist/chunks/{NotificationsPage-C29Lln5o.js.map → NotificationsPage-CAbNW_Cn.js.map} +1 -1
- package/dist/chunks/{NotificationsPage-BiaLRb0s.js → NotificationsPage-DxwizUhL.js} +2 -2
- package/dist/chunks/{NotificationsPage-BiaLRb0s.js.map → NotificationsPage-DxwizUhL.js.map} +1 -1
- package/dist/chunks/{OnboardingWizardPage-DQrBKNBq.js → OnboardingWizardPage-C6HlbJ3K.js} +2 -2
- package/dist/chunks/{OnboardingWizardPage-DQrBKNBq.js.map → OnboardingWizardPage-C6HlbJ3K.js.map} +1 -1
- package/dist/chunks/{OnboardingWizardPage-BQah4cI8.js → OnboardingWizardPage-CyC2zONO.js} +2 -2
- package/dist/chunks/{OnboardingWizardPage-BQah4cI8.js.map → OnboardingWizardPage-CyC2zONO.js.map} +1 -1
- package/dist/chunks/{PermissionDetailPage-Ckjdjvf9.js → PermissionDetailPage-BDHiNgky.js} +2 -2
- package/dist/chunks/{PermissionDetailPage-Ckjdjvf9.js.map → PermissionDetailPage-BDHiNgky.js.map} +1 -1
- package/dist/chunks/{PermissionDetailPage-Dh8v7mGj.js → PermissionDetailPage-C5K17ydY.js} +2 -2
- package/dist/chunks/{PermissionDetailPage-Dh8v7mGj.js.map → PermissionDetailPage-C5K17ydY.js.map} +1 -1
- package/dist/chunks/{PermissionsPage-l0PnY-EE.js → PermissionsPage-COI5LJPo.js} +2 -2
- package/dist/chunks/{PermissionsPage-l0PnY-EE.js.map → PermissionsPage-COI5LJPo.js.map} +1 -1
- package/dist/chunks/{PermissionsPage-DLy9U3P3.js → PermissionsPage-CkOwH2_d.js} +2 -2
- package/dist/chunks/{PermissionsPage-DLy9U3P3.js.map → PermissionsPage-CkOwH2_d.js.map} +1 -1
- package/dist/chunks/{PortalDashboardPage-DFBx38-x.js → PortalDashboardPage-CoEC4CmC.js} +2 -2
- package/dist/chunks/{PortalDashboardPage-DFBx38-x.js.map → PortalDashboardPage-CoEC4CmC.js.map} +1 -1
- package/dist/chunks/{PortalDashboardPage-rQYhrX0q.js → PortalDashboardPage-DrYymEf-.js} +2 -2
- package/dist/chunks/{PortalDashboardPage-rQYhrX0q.js.map → PortalDashboardPage-DrYymEf-.js.map} +1 -1
- package/dist/chunks/{PreferencesPage-BBu8yZQB.js → PreferencesPage-CJRaU3ba.js} +2 -2
- package/dist/chunks/{PreferencesPage-BBu8yZQB.js.map → PreferencesPage-CJRaU3ba.js.map} +1 -1
- package/dist/chunks/{PreferencesPage-B81MsNV1.js → PreferencesPage-Cqr9mAab.js} +2 -2
- package/dist/chunks/{PreferencesPage-B81MsNV1.js.map → PreferencesPage-Cqr9mAab.js.map} +1 -1
- package/dist/chunks/{ProfilePage-DDrl10zj.js → ProfilePage-BZVpg6-l.js} +2 -2
- package/dist/chunks/{ProfilePage-DDrl10zj.js.map → ProfilePage-BZVpg6-l.js.map} +1 -1
- package/dist/chunks/{ProfilePage-DPoXwdnc.js → ProfilePage-Cu_FITeL.js} +2 -2
- package/dist/chunks/{ProfilePage-DPoXwdnc.js.map → ProfilePage-Cu_FITeL.js.map} +1 -1
- package/dist/chunks/{ReferencesManagementPage-eFsKjIEK.js → ReferencesManagementPage-DUlVk9Ps.js} +3 -3
- package/dist/chunks/{ReferencesManagementPage-eFsKjIEK.js.map → ReferencesManagementPage-DUlVk9Ps.js.map} +1 -1
- package/dist/chunks/{ReferencesManagementPage-DhVsuElE.js → ReferencesManagementPage-ZCuYtqd7.js} +2 -2
- package/dist/chunks/{ReferencesManagementPage-DhVsuElE.js.map → ReferencesManagementPage-ZCuYtqd7.js.map} +1 -1
- package/dist/chunks/{RegisterPage-CiQib3-6.js → RegisterPage-C4xmVwh9.js} +2 -2
- package/dist/chunks/{RegisterPage-CiQib3-6.js.map → RegisterPage-C4xmVwh9.js.map} +1 -1
- package/dist/chunks/{RegisterPage-bXCcJD88.js → RegisterPage-DGyzoIHT.js} +2 -2
- package/dist/chunks/{RegisterPage-bXCcJD88.js.map → RegisterPage-DGyzoIHT.js.map} +1 -1
- package/dist/chunks/{ResetPasswordPage-Dqiahhnj.js → ResetPasswordPage-DqDD6VPR.js} +2 -2
- package/dist/chunks/{ResetPasswordPage-Dqiahhnj.js.map → ResetPasswordPage-DqDD6VPR.js.map} +1 -1
- package/dist/chunks/{ResetPasswordPage-CubPG3yv.js → ResetPasswordPage-Glu-aeqv.js} +2 -2
- package/dist/chunks/{ResetPasswordPage-CubPG3yv.js.map → ResetPasswordPage-Glu-aeqv.js.map} +1 -1
- package/dist/chunks/{ResolutionModal-Bg7XZmR1.js → ResolutionModal-CxjANAOP.js} +2 -2
- package/dist/chunks/{ResolutionModal-Bg7XZmR1.js.map → ResolutionModal-CxjANAOP.js.map} +1 -1
- package/dist/chunks/{ResolutionModal-DqRk_T0n.js → ResolutionModal-Duat18qV.js} +2 -2
- package/dist/chunks/{ResolutionModal-DqRk_T0n.js.map → ResolutionModal-Duat18qV.js.map} +1 -1
- package/dist/chunks/{RoleDetailPage-Blau6_4c.js → RoleDetailPage-BQffUSnt.js} +3 -3
- package/dist/chunks/{RoleDetailPage-Blau6_4c.js.map → RoleDetailPage-BQffUSnt.js.map} +1 -1
- package/dist/chunks/{RoleDetailPage-CiRVxxIP.js → RoleDetailPage-JTm5lD1_.js} +2 -2
- package/dist/chunks/{RoleDetailPage-CiRVxxIP.js.map → RoleDetailPage-JTm5lD1_.js.map} +1 -1
- package/dist/chunks/{RolesPage-Pm-RN3lP.js → RolesPage-B9rRzciI.js} +2 -2
- package/dist/chunks/{RolesPage-Pm-RN3lP.js.map → RolesPage-B9rRzciI.js.map} +1 -1
- package/dist/chunks/{RolesPage-Cb8joqdJ.js → RolesPage-BN8_zMOC.js} +2 -2
- package/dist/chunks/{RolesPage-Cb8joqdJ.js.map → RolesPage-BN8_zMOC.js.map} +1 -1
- package/dist/chunks/{SlaConfigPage-B86McKM6.js → SlaConfigPage-B7kZNig4.js} +2 -2
- package/dist/chunks/{SlaConfigPage-B86McKM6.js.map → SlaConfigPage-B7kZNig4.js.map} +1 -1
- package/dist/chunks/{SlaConfigPage-BY7gvYU6.js → SlaConfigPage-okvZfA_K.js} +2 -2
- package/dist/chunks/{SlaConfigPage-BY7gvYU6.js.map → SlaConfigPage-okvZfA_K.js.map} +1 -1
- package/dist/chunks/{SupportPermissionsPage-BYxcLMSd.js → SupportPermissionsPage-DGAPqJbl.js} +2 -2
- package/dist/chunks/{SupportPermissionsPage-BYxcLMSd.js.map → SupportPermissionsPage-DGAPqJbl.js.map} +1 -1
- package/dist/chunks/{SupportPermissionsPage-MXqXNJIZ.js → SupportPermissionsPage-Dg_wLOme.js} +2 -2
- package/dist/chunks/{SupportPermissionsPage-MXqXNJIZ.js.map → SupportPermissionsPage-Dg_wLOme.js.map} +1 -1
- package/dist/chunks/{TemplatesPage-BDguJ401.js → TemplatesPage-DT9fhlAU.js} +2 -2
- package/dist/chunks/{TemplatesPage-BDguJ401.js.map → TemplatesPage-DT9fhlAU.js.map} +1 -1
- package/dist/chunks/{TemplatesPage-DdnGgioU.js → TemplatesPage-DiEk538p.js} +2 -2
- package/dist/chunks/{TemplatesPage-DdnGgioU.js.map → TemplatesPage-DiEk538p.js.map} +1 -1
- package/dist/chunks/{TenantCard-ffwWsgFQ.js → TenantCard-BbSYk9_Z.js} +2 -2
- package/dist/chunks/{TenantCard-ffwWsgFQ.js.map → TenantCard-BbSYk9_Z.js.map} +1 -1
- package/dist/chunks/{TenantCard-CUjb6og9.js → TenantCard-CEkiKxcZ.js} +2 -2
- package/dist/chunks/{TenantCard-CUjb6og9.js.map → TenantCard-CEkiKxcZ.js.map} +1 -1
- package/dist/chunks/{TenantScopeSelector-Dz7i1I43.js → TenantScopeSelector-BWfYxvEa.js} +2 -2
- package/dist/chunks/{TenantScopeSelector-Dz7i1I43.js.map → TenantScopeSelector-BWfYxvEa.js.map} +1 -1
- package/dist/chunks/{TenantScopeSelector-Cym_Zyps.js → TenantScopeSelector-D-BKgQPV.js} +2 -2
- package/dist/chunks/{TenantScopeSelector-Cym_Zyps.js.map → TenantScopeSelector-D-BKgQPV.js.map} +1 -1
- package/dist/chunks/{TicketDetailPage-GOh9GX7E.js → TicketDetailPage-C1mNS9Up.js} +2 -2
- package/dist/chunks/{TicketDetailPage-GOh9GX7E.js.map → TicketDetailPage-C1mNS9Up.js.map} +1 -1
- package/dist/chunks/{TicketDetailPage-Du8WMyqf.js → TicketDetailPage-ieVDRh42.js} +2 -2
- package/dist/chunks/{TicketDetailPage-Du8WMyqf.js.map → TicketDetailPage-ieVDRh42.js.map} +1 -1
- package/dist/chunks/{TicketsPage-Bqd6moQy.js → TicketsPage-CnuWsnIW.js} +2 -2
- package/dist/chunks/{TicketsPage-Bqd6moQy.js.map → TicketsPage-CnuWsnIW.js.map} +1 -1
- package/dist/chunks/{TicketsPage-WdU4Bb7M.js → TicketsPage-jjyY15_D.js} +2 -2
- package/dist/chunks/{TicketsPage-WdU4Bb7M.js.map → TicketsPage-jjyY15_D.js.map} +1 -1
- package/dist/chunks/{UserCreateTicketPage-Cm1emgwR.js → UserCreateTicketPage-B8Tvf-ag.js} +2 -2
- package/dist/chunks/{UserCreateTicketPage-Cm1emgwR.js.map → UserCreateTicketPage-B8Tvf-ag.js.map} +1 -1
- package/dist/chunks/{UserCreateTicketPage-BPw-5Y_D.js → UserCreateTicketPage-DnOsDlfO.js} +2 -2
- package/dist/chunks/{UserCreateTicketPage-BPw-5Y_D.js.map → UserCreateTicketPage-DnOsDlfO.js.map} +1 -1
- package/dist/chunks/{UserDashboardPage-BP5WeXPS.js → UserDashboardPage-BrtkJ-NB.js} +2 -2
- package/dist/chunks/{UserDashboardPage-BP5WeXPS.js.map → UserDashboardPage-BrtkJ-NB.js.map} +1 -1
- package/dist/chunks/{UserDashboardPage-B53C8fUq.js → UserDashboardPage-KLB5CQP5.js} +2 -2
- package/dist/chunks/{UserDashboardPage-B53C8fUq.js.map → UserDashboardPage-KLB5CQP5.js.map} +1 -1
- package/dist/chunks/{UserDetailPage-B110bmGX.js → UserDetailPage-U7smBQoF.js} +5 -5
- package/dist/chunks/{UserDetailPage-B110bmGX.js.map → UserDetailPage-U7smBQoF.js.map} +1 -1
- package/dist/chunks/{UserDetailPage-CV2VCE46.js → UserDetailPage-_J6lcKAU.js} +2 -2
- package/dist/chunks/{UserDetailPage-CV2VCE46.js.map → UserDetailPage-_J6lcKAU.js.map} +1 -1
- package/dist/chunks/{UserTicketDetailPage-CCNJON1V.js → UserTicketDetailPage-CWoYQgH-.js} +2 -2
- package/dist/chunks/{UserTicketDetailPage-CCNJON1V.js.map → UserTicketDetailPage-CWoYQgH-.js.map} +1 -1
- package/dist/chunks/{UserTicketDetailPage-V0mLXrox.js → UserTicketDetailPage-DkufSlvZ.js} +2 -2
- package/dist/chunks/{UserTicketDetailPage-V0mLXrox.js.map → UserTicketDetailPage-DkufSlvZ.js.map} +1 -1
- package/dist/chunks/{UsersGroupsPage-CmdaU-z-.js → UsersGroupsPage-C38s2-Rq.js} +3 -3
- package/dist/chunks/{UsersGroupsPage-CmdaU-z-.js.map → UsersGroupsPage-C38s2-Rq.js.map} +1 -1
- package/dist/chunks/{UsersGroupsPage-BgfAMgEP.js → UsersGroupsPage-Dq3rAteo.js} +2 -2
- package/dist/chunks/{UsersGroupsPage-BgfAMgEP.js.map → UsersGroupsPage-Dq3rAteo.js.map} +1 -1
- package/dist/chunks/{UsersPage-Bg7033pp.js → UsersPage-B5C5KEUR.js} +2 -2
- package/dist/chunks/{UsersPage-Bg7033pp.js.map → UsersPage-B5C5KEUR.js.map} +1 -1
- package/dist/chunks/{UsersPage-TYAfwPY1.js → UsersPage-CXC9Hvq6.js} +2 -2
- package/dist/chunks/{UsersPage-TYAfwPY1.js.map → UsersPage-CXC9Hvq6.js.map} +1 -1
- package/dist/chunks/{accessRequestsApi-DZeDvzwv.js → accessRequestsApi-B-4TJ5_U.js} +2 -2
- package/dist/chunks/{accessRequestsApi-DZeDvzwv.js.map → accessRequestsApi-B-4TJ5_U.js.map} +1 -1
- package/dist/chunks/{accessRequestsApi-ZXFPCid2.js → accessRequestsApi-DZSfThpd.js} +2 -2
- package/dist/chunks/{accessRequestsApi-ZXFPCid2.js.map → accessRequestsApi-DZSfThpd.js.map} +1 -1
- package/dist/chunks/{aiApi-CsH8DXgs.js → aiApi-B20Teu2v.js} +2 -2
- package/dist/chunks/{aiApi-CsH8DXgs.js.map → aiApi-B20Teu2v.js.map} +1 -1
- package/dist/chunks/{aiApi-CVPzFTXa.js → aiApi-DMGz-RPM.js} +2 -2
- package/dist/chunks/{aiApi-CVPzFTXa.js.map → aiApi-DMGz-RPM.js.map} +1 -1
- package/dist/chunks/{applicationAnalyticsApi-B8AhFYLr.js → applicationAnalyticsApi-Bwa75Fzd.js} +2 -2
- package/dist/chunks/{applicationAnalyticsApi-B8AhFYLr.js.map → applicationAnalyticsApi-Bwa75Fzd.js.map} +1 -1
- package/dist/chunks/{applicationAnalyticsApi-Ce_1qOk-.js → applicationAnalyticsApi-CLBqRPfN.js} +2 -2
- package/dist/chunks/{applicationAnalyticsApi-Ce_1qOk-.js.map → applicationAnalyticsApi-CLBqRPfN.js.map} +1 -1
- package/dist/chunks/{groupsApi-BgCk2fsp.js → groupsApi-QzXI-5xu.js} +2 -2
- package/dist/chunks/{groupsApi-BgCk2fsp.js.map → groupsApi-QzXI-5xu.js.map} +1 -1
- package/dist/chunks/{groupsApi-BIbG665N.js → groupsApi-hB9kSWEd.js} +2 -2
- package/dist/chunks/{groupsApi-BIbG665N.js.map → groupsApi-hB9kSWEd.js.map} +1 -1
- package/dist/chunks/{index-Cb3LotuT.js → index--NGcBYUu.js} +3 -3
- package/dist/chunks/{index-Cb3LotuT.js.map → index--NGcBYUu.js.map} +1 -1
- package/dist/chunks/{index-C33zcyF4.js → index--aPwOFjF.js} +2 -2
- package/dist/chunks/{index-C33zcyF4.js.map → index--aPwOFjF.js.map} +1 -1
- package/dist/chunks/{index-sMr9qND_.js → index-0VrOtwP0.js} +2 -2
- package/dist/chunks/{index-sMr9qND_.js.map → index-0VrOtwP0.js.map} +1 -1
- package/dist/chunks/{index-DDKetfKq.js → index-37U271aw.js} +2 -2
- package/dist/chunks/{index-DDKetfKq.js.map → index-37U271aw.js.map} +1 -1
- package/dist/chunks/{index-B9fS7ir6.js → index-B7qZTuQ-.js} +2 -2
- package/dist/chunks/{index-B9fS7ir6.js.map → index-B7qZTuQ-.js.map} +1 -1
- package/dist/chunks/{index-CdjBY7L8.js → index-Bedzmqr-.js} +2 -2
- package/dist/chunks/{index-CdjBY7L8.js.map → index-Bedzmqr-.js.map} +1 -1
- package/dist/chunks/{index-CHG_O1fS.js → index-Betxo5g5.js} +2 -2
- package/dist/chunks/{index-CHG_O1fS.js.map → index-Betxo5g5.js.map} +1 -1
- package/dist/chunks/{index-jiGu-H8x.js → index-BmaJz475.js} +2 -2
- package/dist/chunks/{index-jiGu-H8x.js.map → index-BmaJz475.js.map} +1 -1
- package/dist/chunks/{index-C53JoVNk.js → index-Buhqag3v.js} +2 -2
- package/dist/chunks/{index-C53JoVNk.js.map → index-Buhqag3v.js.map} +1 -1
- package/dist/chunks/{index-DO0Rw7hX.js → index-C3VxlfKq.js} +2 -2
- package/dist/chunks/{index-DO0Rw7hX.js.map → index-C3VxlfKq.js.map} +1 -1
- package/dist/chunks/{index-CSQ60fpG.js → index-CgpRo8Oe.js} +2 -2
- package/dist/chunks/{index-CSQ60fpG.js.map → index-CgpRo8Oe.js.map} +1 -1
- package/dist/chunks/{index-B-e-ELsf.js → index-DOY0w8Iu.js} +8 -8
- package/dist/chunks/{index-B-e-ELsf.js.map → index-DOY0w8Iu.js.map} +1 -1
- package/dist/chunks/{index-D2REDIRX.js → index-DwuvIOrQ.js} +2 -2
- package/dist/chunks/{index-D2REDIRX.js.map → index-DwuvIOrQ.js.map} +1 -1
- package/dist/chunks/{index-DCcl7Qof.js → index-DzedSLdI.js} +2 -2
- package/dist/chunks/{index-DCcl7Qof.js.map → index-DzedSLdI.js.map} +1 -1
- package/dist/chunks/{index-2wUhd9Lu.js → index-IgLVXPg8.js} +10 -10
- package/dist/chunks/index-IgLVXPg8.js.map +1 -0
- package/dist/chunks/{index-CwSaRXXg.js → index-lpIzhufD.js} +1916 -1900
- package/dist/chunks/index-lpIzhufD.js.map +1 -0
- package/dist/chunks/{index-Cuwn2q-f.js → index-mLUKwbGl.js} +4 -4
- package/dist/chunks/{index-Cuwn2q-f.js.map → index-mLUKwbGl.js.map} +1 -1
- package/dist/chunks/{index-B0mk2tNY.js → index-tO6MMIFB.js} +2 -2
- package/dist/chunks/{index-B0mk2tNY.js.map → index-tO6MMIFB.js.map} +1 -1
- package/dist/chunks/{tenantIconMap-BpNANQ5s.js → tenantIconMap-BQD9byc8.js} +2 -2
- package/dist/chunks/{tenantIconMap-BpNANQ5s.js.map → tenantIconMap-BQD9byc8.js.map} +1 -1
- package/dist/chunks/{tenantIconMap-DtdUgvJO.js → tenantIconMap-CTMuSt18.js} +2 -2
- package/dist/chunks/{tenantIconMap-DtdUgvJO.js.map → tenantIconMap-CTMuSt18.js.map} +1 -1
- package/dist/chunks/{ticketingApi-Bu4rKwLl.js → ticketingApi-BNIdox5t.js} +2 -2
- package/dist/chunks/{ticketingApi-Bu4rKwLl.js.map → ticketingApi-BNIdox5t.js.map} +1 -1
- package/dist/chunks/{ticketingApi-r4Avm9iS.js → ticketingApi-J0vC_t7r.js} +2 -2
- package/dist/chunks/{ticketingApi-r4Avm9iS.js.map → ticketingApi-J0vC_t7r.js.map} +1 -1
- package/dist/chunks/{useAccessRequests-B9bF4swg.js → useAccessRequests-DCNNLnxk.js} +3 -3
- package/dist/chunks/{useAccessRequests-B9bF4swg.js.map → useAccessRequests-DCNNLnxk.js.map} +1 -1
- package/dist/chunks/{useAccessRequests-JyPUX3Om.js → useAccessRequests-DT7X4FAK.js} +2 -2
- package/dist/chunks/{useAccessRequests-JyPUX3Om.js.map → useAccessRequests-DT7X4FAK.js.map} +1 -1
- package/dist/chunks/{useUserAccessRequests-DjPQenC2.js → useUserAccessRequests-BYbmG4c7.js} +2 -2
- package/dist/chunks/{useUserAccessRequests-DjPQenC2.js.map → useUserAccessRequests-BYbmG4c7.js.map} +1 -1
- package/dist/chunks/{useUserAccessRequests-BB6FHW14.js → useUserAccessRequests-CylKxRN6.js} +2 -2
- package/dist/chunks/{useUserAccessRequests-BB6FHW14.js.map → useUserAccessRequests-CylKxRN6.js.map} +1 -1
- package/dist/hooks/useCollapsibleState.d.ts +5 -2
- package/dist/hooks/useCollapsibleState.d.ts.map +1 -1
- package/dist/i18n/config.d.ts +1 -0
- package/dist/i18n/config.d.ts.map +1 -1
- package/dist/main.d.ts +0 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/smartstack.cjs +1 -1
- package/dist/smartstack.js +1 -1
- package/dist/utils/permissions.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/index-2wUhd9Lu.js.map +0 -1
- package/dist/chunks/index-CwSaRXXg.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),ie=require("react-router-dom"),ce=require("react-i18next"),t=require("lucide-react"),z=require("./groupsApi-BIbG665N.js"),oe=require("./index-2wUhd9Lu.js"),Re=require("./roleUtils-tv67Lrey.js"),Ie=require("./TenantScopeSelector-Cym_Zyps.js"),de=require("./tenantIconMap-DtdUgvJO.js"),pe=require("./PermissionPopover-CtYTz7MK.js"),We=require("./useTabNavigation-BVtbCTd5.js");function ze(s){const x=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const l in s)if(l!=="default"){const c=Object.getOwnPropertyDescriptor(s,l);Object.defineProperty(x,l,c.get?c:{enumerable:!0,get:()=>s[l]})}}return x.default=s,Object.freeze(x)}const _e=ze(t),Ce={Global:{bg:"bg-[var(--accent-bg)]",text:"text-[var(--color-accent-500)]"},Admin:{bg:"bg-[var(--error-bg)]",text:"text-[var(--error-text)]"},Manager:{bg:"bg-[var(--warning-bg)]",text:"text-[var(--warning-text)]"},Contributor:{bg:"bg-[var(--success-bg)]",text:"text-[var(--success-text)]"},Viewer:{bg:"bg-[var(--info-bg)]",text:"text-[var(--info-text)]"},Custom:{bg:"bg-[var(--accent-bg)]",text:"text-[var(--color-accent-700)]"}},Se={bg:"bg-[var(--bg-secondary)]",text:"text-[var(--text-secondary)]"};function Ve({groupId:s,assignedRoles:x=[],onSave:l,roles:c,loading:d=!1,tenantId:o,isGlobalScope:k=!0,adminTenants:y=[]}){const{t:v}=ce.useTranslation(["admin","groups"]),h=Array.isArray(c)?c:[],[P,j]=r.useState(""),[S,F]=r.useState("all"),[U,q]=r.useState(null),[T,L]=r.useState(!1),[X,Y]=r.useState(null),R=r.useRef(!1),[O,E]=r.useState([]);r.useEffect(()=>{let n=!1;return z.groupsApi.getTenants(s).then(w=>{n||E(w.map(m=>({id:m.tenantId,name:m.tenantName})))}).catch(()=>{n||E([])}),()=>{n=!0}},[s]);const[C,V]=r.useState([]),[G,J]=r.useState(!0);r.useEffect(()=>{let n=!1;return J(!0),z.groupsApi.getInheritedRoles(s).then(w=>{n||V(w)}).catch(()=>{n||V([])}).finally(()=>{n||J(!1)}),()=>{n=!0}},[s]);const M=r.useMemo(()=>[...O].sort((n,w)=>n.name.localeCompare(w.name)),[O]),H=r.useMemo(()=>{let n=x;if(S==="global"?n=n.filter(m=>m.isGlobal):S!=="all"&&(n=n.filter(m=>m.isGlobal||m.tenantId===S)),!P.trim())return n;const w=P.toLowerCase().trim();return n.filter(m=>m.roleName.toLowerCase().includes(w)||m.tenantName?.toLowerCase().includes(w))},[x,P,S]),se=r.useMemo(()=>{const n=new Map;for(const w of h)n.set(w.id,w);return n},[h]),D=r.useCallback(async(n,w,m)=>{if(!R.current){R.current=!0,q(n+(w||"global")),Y(null);try{await z.groupsApi.removeRole(s,n,m?void 0:w??void 0),await l([])}catch(I){console.error("Failed to remove role assignment:",I),Y(v("admin:userRoles.errors.removeFailed","Erreur lors du retrait du rôle"))}finally{q(null),R.current=!1}}},[s,l,v]),B=r.useCallback(()=>L(!0),[]),re=r.useCallback(()=>L(!1),[]),ee=r.useCallback(async()=>{await l([])},[l]);return e.jsxs("div",{className:"space-y-4",children:[X&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] flex items-center gap-3",children:[e.jsx(t.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0"}),e.jsx("p",{className:"flex-1 text-[var(--error-text)]",children:X}),e.jsx("button",{onClick:()=>Y(null),className:"ml-auto",children:e.jsx(t.X,{className:"w-4 h-4 text-[var(--error-text)]"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:P,onChange:n=>j(n.target.value),placeholder:v("admin:userRoles.search","Rechercher un rôle..."),className:"w-full pl-10 pr-4 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:S,onChange:n=>F(n.target.value),className:"px-3 py-2 pr-8 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] appearance-none focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:v("admin:userRoles.scopeAll","Tous les tenants")}),e.jsx("option",{value:"global",children:v("admin:roles.global","Global")}),M.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]}),e.jsx(t.ChevronDown,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none text-[var(--text-tertiary)]"})]})]}),e.jsxs("button",{onClick:B,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors text-sm font-medium",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),v("admin:userRoles.assignRole","Assigner un rôle")]})]}),d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}):e.jsxs("div",{className:"overflow-x-auto",children:[e.jsxs("table",{className:"w-full border border-[var(--border-color)] rounded-[var(--radius-card)] overflow-hidden",children:[e.jsx("thead",{className:"bg-[var(--bg-tertiary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.name","Rôle")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.category","Catégorie")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.tenant","Tenant")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)] w-24",children:v("admin:roles.actions","Actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:H.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-[var(--text-muted)]",children:x.length===0?v("admin:userRoles.noAssignedRoles","Aucun rôle assigné à ce groupe"):v("admin:userRoles.noRoles","Aucun rôle trouvé")})}):H.map(n=>{const w=se.get(n.roleId),m=w?.category||"Custom",I=Ce[m]||Se,Q=w?Re.getCustomRoleIcon(w.code):null,p=n.roleId+(n.tenantId||"global"),f=U===p;return e.jsxs("tr",{className:"hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Q&&e.jsx("span",{children:Q}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:n.roleName})]}),n.roleDescription&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 max-w-xs truncate",children:n.roleDescription})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${I.bg} ${I.text}`,children:m})}),e.jsx("td",{className:"px-4 py-3",children:n.isGlobal?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--info-bg)] text-[var(--info-text)]",children:[e.jsx(t.Globe,{className:"w-3 h-3"}),v("admin:roles.global","Global")]}):e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--accent-bg)] text-[var(--color-accent-700)]",children:[e.jsx(t.Building2,{className:"w-3 h-3"}),n.tenantName||v("admin:roles.unknownTenant","Tenant")]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>D(n.roleId,n.tenantId,n.isGlobal),disabled:f,className:"p-1.5 rounded-[var(--radius-button)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors disabled:opacity-50",title:v("admin:userRoles.removeRole","Retirer le rôle"),children:f?e.jsx(t.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(t.Trash2,{className:"w-4 h-4"})})})]},p)})})]}),x.length>0&&e.jsx("div",{className:"px-4 py-2 text-xs text-[var(--text-muted)] bg-[var(--bg-tertiary)] border-t border-[var(--border-color)]",children:H.length!==x.length?v("admin:userRoles.totalFiltered","{{filtered}} / {{count}} rôle(s) affiché(s)",{filtered:H.length,count:x.length}):v("admin:userRoles.totalAssigned","{{count}} rôle(s) assigné(s)",{count:x.length})})]}),T&&e.jsx(Xe,{groupId:s,assignedRoles:x,initialTenantId:o,initialIsGlobalScope:k,adminTenants:y,onAssigned:ee,onClose:re}),G?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(t.Loader2,{className:"w-5 h-5 animate-spin text-[var(--color-accent-500)]"})}):C.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.GitMerge,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)]",children:v("groups:hierarchy.inheritedRoles","Rôles hérités")}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["(",C.length,")"]})]}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:v("groups:hierarchy.inheritedRolesInfo","Ces rôles sont hérités des groupes ancêtres. Ils ne peuvent pas être retirés directement — modifiez le groupe ancêtre pour les gérer.")}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border border-[var(--border-color)] rounded-[var(--radius-card)] overflow-hidden",children:[e.jsx("thead",{className:"bg-[var(--bg-tertiary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.name","Rôle")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.tenant","Tenant")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("groups:hierarchy.inheritedFrom","Hérité de")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:C.map(n=>{const m=se.get(n.roleId)?.category||"Custom",I=Ce[m]||Se;return e.jsxs("tr",{className:"bg-[var(--bg-secondary)] opacity-80",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:n.roleName}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${I.bg} ${I.text}`,children:m})]}),n.roleDescription&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 max-w-xs truncate",children:n.roleDescription})]}),e.jsx("td",{className:"px-4 py-3",children:n.isGlobal?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--info-bg)] text-[var(--info-text)]",children:[e.jsx(t.Globe,{className:"w-3 h-3"}),v("admin:roles.global","Global")]}):e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--accent-bg)] text-[var(--color-accent-700)]",children:[e.jsx(t.Building2,{className:"w-3 h-3"}),n.tenantName||v("admin:roles.unknownTenant","Tenant")]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[e.jsx(t.GitMerge,{className:"w-3 h-3"}),n.inheritedFromGroupName,e.jsxs("span",{className:"text-[var(--text-muted)]",children:["(",v("groups:hierarchy.level","Niveau {{level}}",{level:n.level}),")"]})]})})]},n.roleId+(n.tenantId||"global"))})})]})})]})]})}function Xe({groupId:s,assignedRoles:x,initialTenantId:l,initialIsGlobalScope:c,adminTenants:d,onAssigned:o,onClose:k}){const{t:y}=ce.useTranslation(["admin","groups","common"]),[v,h]=r.useState(""),[P,j]=r.useState("all"),[S,F]=r.useState("all"),[U,q]=r.useState(null),[T,L]=r.useState(null),X=r.useRef(!1),[Y,R]=r.useState([]),[O,E]=r.useState(!0);r.useEffect(()=>{let p=!1;return E(!0),oe.adminApi.roles.getAssignable().then(f=>{p||R(Array.isArray(f)?f:[])}).catch(()=>{p||R([])}).finally(()=>{p||E(!1)}),()=>{p=!0}},[]);const[C,V]=r.useState(null);r.useEffect(()=>{let p=!1;return z.groupsApi.getTenants(s).then(f=>{p||V(new Set(f.map(_=>_.tenantId)))}).catch(()=>{p||V(null)}),()=>{p=!0}},[s]);const[G,J]=r.useState([]);r.useEffect(()=>{if(!C||C.size===0){J([]);return}let p=!1;const f=Array.from(C);return Promise.all(f.map(_=>oe.adminApi.tenants.getApplications(_))).then(_=>{if(p)return;const u=new Map;for(const N of _)for(const i of N)u.has(i.applicationId)||u.set(i.applicationId,i.label);J(Array.from(u.entries()).map(([N,i])=>({id:N,name:i})).sort((N,i)=>N.name.localeCompare(i.name)))}).catch(()=>{p||J([])}),()=>{p=!0}},[C]);const M=r.useMemo(()=>C?d.filter(p=>C.has(p.tenantId)):d,[d,C]),[H,se]=r.useState(()=>{if(c||!l)return"global";const p=d.find(f=>f.tenantId===l);return p?{tenantId:p.tenantId,tenantSlug:p.tenantSlug,tenantUserId:"",tenantName:p.tenantName}:"global"}),D=H==="global",B=D?void 0:H.tenantId,re=r.useMemo(()=>{const p=new Set;for(const f of x)(D&&f.isGlobal||!D&&f.tenantId===B)&&p.add(f.roleId);return p},[x,D,B]),[ee,n]=r.useState(null);r.useEffect(()=>{if(D||!B){n(null);return}let p=!1;return oe.adminApi.tenants.getApplications(B).then(f=>{p||n(new Set(f.map(_=>_.applicationId)))}).catch(()=>{p||n(null)}),()=>{p=!0}},[D,B]);const w=r.useMemo(()=>D||!ee?Y:Y.filter(p=>!p.applicationId||ee.has(p.applicationId)),[Y,D,ee]),m=r.useMemo(()=>{const p=new Set(w.map(f=>f.category||"Custom"));return["all",...Array.from(p).sort((f,_)=>f.localeCompare(_))]},[w]),I=r.useMemo(()=>{let p=w;if(S!=="all"&&(p=p.filter(f=>f.applicationId===S)),P!=="all"&&(p=p.filter(f=>(f.category||"Custom")===P)),v.trim()){const f=v.toLowerCase().trim();p=p.filter(_=>_.name.toLowerCase().includes(f)||_.shortName?.toLowerCase().includes(f)||_.description?.toLowerCase().includes(f))}return p},[w,S,P,v]),Q=r.useCallback(async p=>{if(!X.current){X.current=!0,q(p),L(null);try{await z.groupsApi.assignRole(s,{roleId:p,isInheritable:!0,tenantId:!D&&B?B:void 0}),await o()}catch(f){console.error("Failed to assign role:",f),L(y("admin:userRoles.errors.assignFailed","Erreur lors de l'assignation du rôle"))}finally{q(null),X.current=!1}}},[s,D,B,o,y]);return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"relative w-full max-w-2xl h-[80vh] bg-[var(--bg-card)] rounded-[var(--radius-card)] shadow-2xl border border-[var(--border-color)] overflow-hidden flex flex-col animate-in fade-in zoom-in duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{children:e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:y("admin:userRoles.assignRole","Assigner un rôle")})}),e.jsx(Ie.TenantScopeSelector,{value:H,onChange:se,adminTenants:M})]}),e.jsx("button",{onClick:k,className:"p-1.5 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-5 h-5"})})]}),T&&e.jsxs("div",{className:"mx-6 mt-3 p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] flex items-center gap-3",children:[e.jsx(t.AlertCircle,{className:"w-4 h-4 text-[var(--error-text)] flex-shrink-0"}),e.jsx("p",{className:"flex-1 text-sm text-[var(--error-text)]",children:T}),e.jsx("button",{onClick:()=>L(null),children:e.jsx(t.X,{className:"w-3.5 h-3.5 text-[var(--error-text)]"})})]}),e.jsxs("div",{className:"px-6 py-3 border-b border-[var(--border-color)] flex flex-col gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:v,onChange:p=>h(p.target.value),placeholder:y("admin:userRoles.search","Rechercher un rôle..."),className:"w-full pl-10 pr-4 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Filter,{className:"w-4 h-4 text-[var(--text-secondary)] shrink-0"}),e.jsxs("select",{value:S,onChange:p=>F(p.target.value),className:"flex-1 min-w-0 px-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:y("admin:userRoles.filterByApplication","Toutes les applications")}),G.map(p=>e.jsx("option",{value:p.id,children:p.name},p.id))]}),e.jsxs("select",{value:P,onChange:p=>j(p.target.value),className:"flex-1 min-w-0 px-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:y("admin:userRoles.filterByCategory","Toutes les catégories")}),m.filter(p=>p!=="all").map(p=>e.jsx("option",{value:p,children:p},p))]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:O?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}):e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[var(--bg-tertiary)] sticky top-0 z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-6 py-2.5 text-sm font-medium text-[var(--text-secondary)]",children:y("admin:roles.name","Rôle")}),e.jsx("th",{className:"text-left px-4 py-2.5 text-sm font-medium text-[var(--text-secondary)]",children:y("admin:roles.category","Catégorie")}),e.jsx("th",{className:"text-right px-6 py-2.5 text-sm font-medium text-[var(--text-secondary)] w-32",children:y("admin:roles.actions","Actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:I.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:"px-6 py-12 text-center",children:[e.jsx(t.Search,{className:"w-8 h-8 mx-auto mb-2 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-muted)]",children:y("admin:userRoles.noRoles","Aucun rôle trouvé")})]})}):I.map(p=>{const f=re.has(p.id),_=Ce[p.category||"Custom"]||Se,u=Re.getCustomRoleIcon(p.code),N=U===p.id;return e.jsxs("tr",{className:`transition-colors ${f?"bg-[var(--accent-bg)] opacity-60":"hover:bg-[var(--bg-hover)]"}`,children:[e.jsx("td",{className:"px-6 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[u&&e.jsx("span",{children:u}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:p.name}),p.description&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 max-w-sm truncate",children:p.description})]})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${_.bg} ${_.text}`,children:p.category||"Custom"})}),e.jsx("td",{className:"px-6 py-3 text-right",children:f?e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:y("admin:userRoles.alreadyAssigned","Déjà assigné")}):e.jsxs("button",{onClick:()=>Q(p.id),disabled:N,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white text-xs font-medium hover:bg-[var(--color-accent-700)] transition-colors disabled:opacity-50",children:[N?e.jsx(t.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(t.Plus,{className:"w-3.5 h-3.5"}),y("admin:userRoles.assign","Assigner")]})})]},p.id)})})]})}),e.jsx("div",{className:"px-6 py-3 border-t border-[var(--border-color)] bg-[var(--bg-tertiary)] flex justify-end",children:e.jsx("button",{onClick:k,className:"px-4 py-2 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors text-sm font-medium",children:y("common:close","Fermer")})})]})})}const Qe=s=>s?"bg-[var(--color-accent-600)] border-[var(--color-accent-600)]":"border-[var(--border-color)]",He=s=>s?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]/5":"border-[var(--border-color)] hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-hover)]",Ke=s=>s?"bg-[var(--color-accent-600)] border-[var(--color-accent-600)]":"border-[var(--border-color)]",Ye=(s,x,l)=>{if(!s)return[];const c=l.toLowerCase().trim();return s.filter(d=>!x.has(d.id)).filter(d=>c?d.name.toLowerCase().includes(c)||d.slug.toLowerCase().includes(c)||d.type.toLowerCase().includes(c):!0)},Je=(s,x)=>{if(!s)return[];if(!x.trim())return s;const l=x.toLowerCase().trim();return s.filter(c=>c.tenantName.toLowerCase().includes(l)||c.tenantSlug.toLowerCase().includes(l)||c.tenantType.toLowerCase().includes(l))};function Ze({groupId:s,groupName:x}){const{t:l}=ce.useTranslation(["admin","groups"]),c=ie.useNavigate(),{getIconForType:d}=de.useTenantTypeSettings(),[o,k]=r.useState(null),[y,v]=r.useState([]),[h,P]=r.useState(null),[j,S]=r.useState(!0),[F,U]=r.useState(!1),[q,T]=r.useState(""),[L,X]=r.useState(null),[Y,R]=r.useState(null),[O,E]=r.useState(null),[C,V]=r.useState([]),[G,J]=r.useState(""),[M,H]=r.useState("cards"),[se,D]=r.useState(!1),B=r.useCallback(async()=>{try{S(!0);const[u,N]=await Promise.all([z.groupsApi.getTenants(s),z.groupsApi.getInheritedTenants(s)]);k(u),v(N)}catch(u){console.error("Failed to load group tenants:",u),R(l("groups:tenants.loadError","Erreur lors du chargement des tenants"))}finally{S(!1)}},[s,l]),re=async()=>{try{const u=await oe.adminApi.tenants.getAll();P(u.items)}catch(u){console.error("Failed to load all tenants:",u)}};r.useEffect(()=>{B(),re()},[B]);const ee=async u=>{const N=o?.find(i=>i.tenantId===u);if(confirm(l("groups:tenants.confirmRemove",`Êtes-vous sûr de vouloir retirer le groupe "${x}" du tenant "${N?.tenantName}" ?`)))try{X(u),R(null),await z.groupsApi.removeFromTenant(s,u),await B(),E(l("groups:tenants.removeSuccess","Tenant retiré avec succès")),setTimeout(()=>E(null),3e3)}catch(i){console.error("Failed to remove tenant:",i);const A=i?.response?.data?.message||l("groups:tenants.removeError","Erreur lors du retrait du tenant");R(A)}finally{X(null)}},n=async()=>{let u=0;const N=[];for(const i of C)try{await z.groupsApi.addToTenant(s,{tenantId:i}),u++}catch{const A=f?.find(K=>K.id===i)?.name;N.push(A||i)}return{successCount:u,failedTenants:N}},w=async()=>{if(C.length!==0)try{D(!0),R(null);const{successCount:u,failedTenants:N}=await n();await B(),U(!1),T(""),V([]),N.length===0?(E(l("groups:tenants.addSelectedSuccess",{count:u})),setTimeout(()=>E(null),3e3)):u>0?R(l("groups:tenants.addPartialError",{success:u,failed:N.join(", ")})):R(l("groups:tenants.addSelectedError","Erreur lors de l'ajout des tenants"))}catch(u){console.error("Failed to add tenants:",u),R(l("groups:tenants.addSelectedError","Erreur lors de l'ajout des tenants"))}finally{D(!1)}},m=u=>{V(N=>N.includes(u)?N.filter(i=>i!==u):[...N,u])},I=()=>{if(!f)return;const u=f.map(i=>i.id),N=u.every(i=>C.includes(i));V(N?[]:u)},Q=r.useMemo(()=>new Set(o?.map(u=>u.tenantId)??[]),[o]),f=r.useMemo(()=>Ye(h,Q,q),[h,Q,q]),_=r.useMemo(()=>Je(o,G),[o,G]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.Building2,{className:"w-5 h-5"}),l("groups:tenants.title","Tenants du groupe"),o&&e.jsx("span",{className:"ml-2 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:o.length})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>U(!0),className:"flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),l("groups:tenants.add","Ajouter")]}),e.jsx("button",{onClick:B,className:"flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.RefreshCw,{className:"w-4 h-4"})})]})]}),(o?.length??0)>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",placeholder:l("groups:tenants.searchPlaceholderPage","Rechercher un tenant..."),value:G,onChange:u=>J(u.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:[e.jsxs("button",{onClick:()=>H("cards"),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${M==="cards"?"bg-[var(--color-accent-600)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(t.LayoutGrid,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:l("groups:tenants.viewCards","Cartes")})]}),e.jsxs("button",{onClick:()=>H("table"),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${M==="table"?"bg-[var(--color-accent-600)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(t.LayoutList,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:l("groups:tenants.viewTable","Table")})]})]})]})]}),Y&&e.jsxs("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/20 flex items-center gap-3",children:[e.jsx(t.AlertTriangle,{className:"w-5 h-5 text-red-500 flex-shrink-0"}),e.jsx("p",{className:"text-red-500",children:Y}),e.jsx("button",{onClick:()=>R(null),className:"ml-auto",children:e.jsx(t.X,{className:"w-4 h-4 text-red-500"})})]}),O&&e.jsxs("div",{className:"p-4 rounded-lg bg-green-500/10 border border-green-500/20 flex items-center gap-3",children:[e.jsx(t.CheckCircle,{className:"w-5 h-5 text-green-500 flex-shrink-0"}),e.jsx("p",{className:"text-green-500",children:O})]}),e.jsx("div",{className:"p-4 rounded-lg bg-blue-500/10 border border-blue-500/20",children:e.jsx("p",{className:"text-sm text-blue-500",children:l("groups:tenants.info","Les utilisateurs de ce groupe auront automatiquement accès aux tenants listés ci-dessous via leur appartenance au groupe.")})}),j&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}),!j&&(!o||o.length===0)&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(t.Building2,{className:"w-12 h-12 mx-auto mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:l("groups:tenants.noTenants","Ce groupe n'est associé à aucun tenant")}),e.jsxs("button",{onClick:()=>U(!0),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),l("groups:tenants.addFirst","Ajouter un premier tenant")]})]}),!j&&(o?.length??0)>0&&(_?.length??0)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(t.Search,{className:"w-12 h-12 mx-auto mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:l("groups:tenants.noResults","Aucun tenant ne correspond à votre recherche")})]}),!j&&(_?.length??0)>0&&M==="cards"&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:_?.map(u=>e.jsx("div",{role:"button",tabIndex:0,onClick:()=>c(`/administration/tenants/${u.tenantId}`),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),c(`/administration/tenants/${u.tenantId}`))},className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] transition-colors cursor-pointer text-left",children:(()=>{const N=d(u.tenantType),i=de.getLucideIcon(N.icon),A=de.getColorClasses(N.color);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:`p-2 rounded-lg ${A.bg}`,children:e.jsx(i,{className:`w-5 h-5 ${A.text}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--color-accent-500)] hover:underline truncate",children:u.tenantName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:u.tenantSlug})]})]}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${A.bg} ${A.text}`,children:u.tenantType})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-color)] space-y-1",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[l("groups:tenants.addedAt","Ajouté le"),": ",new Date(u.addedAt).toLocaleDateString()]}),u.addedBy&&e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[l("groups:tenants.addedBy","Par"),": ",u.addedBy]})]}),e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsxs("button",{onClick:K=>{K.stopPropagation(),ee(u.tenantId)},disabled:L===u.tenantId,className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",children:[L===u.tenantId?e.jsx(t.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(t.Trash2,{className:"w-3 h-3"}),l("common.remove","Retirer")]})})]})})()},u.tenantId))}),!j&&(_?.length??0)>0&&M!=="cards"&&e.jsx("div",{className:"rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:l("groups:tenants.tableHeaders.name","Nom")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:l("groups:tenants.tableHeaders.slug","Slug")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:l("groups:tenants.tableHeaders.type","Type")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:l("groups:tenants.tableHeaders.addedAt","Ajouté le")}),e.jsx("th",{className:"w-24 px-4 py-3"})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:_?.map(u=>e.jsxs("tr",{onClick:()=>c(`/administration/tenants/${u.tenantId}`),className:"hover:bg-[var(--bg-hover)] transition-colors cursor-pointer",children:[(()=>{const N=d(u.tenantType),i=de.getLucideIcon(N.icon),A=de.getColorClasses(N.color);return e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-1.5 rounded-lg ${A.bg}`,children:e.jsx(i,{className:`w-4 h-4 ${A.text}`})}),e.jsx("span",{className:"text-sm font-medium text-[var(--color-accent-500)] hover:underline",children:u.tenantName})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden md:table-cell",children:u.tenantSlug}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${A.bg} ${A.text}`,children:u.tenantType})})]})})(),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-tertiary)] hidden lg:table-cell",children:new Date(u.addedAt).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("button",{onClick:N=>{N.stopPropagation(),ee(u.tenantId)},disabled:L===u.tenantId,className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",children:[L===u.tenantId?e.jsx(t.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(t.Trash2,{className:"w-3 h-3"}),l("common.remove","Retirer")]})})]},u.tenantId))})]})}),!j&&y.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.GitBranch,{className:"w-5 h-5"}),l("groups:tenants.inheritedTitle"),e.jsx("span",{className:"ml-1 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:y.length})]}),e.jsx("div",{className:"p-4 rounded-lg bg-[var(--info-bg)] border border-[var(--info-border)]",children:e.jsx("p",{className:"text-sm text-[var(--info-text)]",children:l("groups:tenants.inheritedInfo")})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:y.map(u=>e.jsx("button",{type:"button",onClick:()=>c(`/administration/tenants/${u.tenantId}`),className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-dashed border-[var(--border-color)] hover:border-[var(--color-accent-500)] transition-colors cursor-pointer text-left",children:(()=>{const N=d(u.tenantType),i=de.getLucideIcon(N.icon),A=de.getColorClasses(N.color);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:`p-2 rounded-lg ${A.bg}`,children:e.jsx(i,{className:`w-5 h-5 ${A.text}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--color-accent-500)] hover:underline truncate",children:u.tenantName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:u.tenantSlug})]})]}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${A.bg} ${A.text}`,children:u.tenantType})]}),e.jsx("div",{className:"mt-3 pt-3 border-t border-[var(--border-color)]",children:e.jsxs(ie.Link,{to:`/administration/users/groups/${u.inheritedFromGroupId}`,onClick:K=>K.stopPropagation(),className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] hover:text-[var(--color-accent-500)] transition-colors",children:[e.jsx(t.Link,{className:"w-3 h-3"}),l("groups:tenants.inheritedFrom")," ",e.jsx("span",{className:"font-medium",children:u.inheritedFromGroupName})]})})]})})()},`inherited-${u.tenantId}-${u.inheritedFromGroupId}`))})]}),F&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"w-full max-w-lg mx-4 bg-[var(--bg-primary)] rounded-[var(--radius-card)] shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:l("groups:tenants.addModalTitle","Ajouter le groupe à des tenants")}),e.jsx("button",{onClick:()=>{U(!1),T(""),V([])},className:"p-1 rounded hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-5 h-5 text-[var(--text-secondary)]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",placeholder:l("groups:tenants.searchPlaceholder","Rechercher un tenant..."),value:q,onChange:u=>T(u.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),(f?.length??0)>0&&e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsxs("button",{onClick:I,className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:[e.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${Qe(f.every(u=>C.includes(u.id)))}`,children:f.every(u=>C.includes(u.id))&&e.jsx(t.Check,{className:"w-3 h-3 text-white"})}),f.every(u=>C.includes(u.id))?l("groups:tenants.deselectAll","Tout désélectionner"):l("groups:tenants.selectAll","Tout sélectionner")]}),C.length>0&&e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[C.length," ",l("common.selected","sélectionné(s)")]})]}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:!f||f.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(t.Building2,{className:"w-8 h-8 mx-auto mb-2 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:l("groups:tenants.noAvailableTenants","Aucun tenant disponible")})]}):f.map(u=>{const N=C.includes(u.id),i=d(u.type),A=de.getLucideIcon(i.icon),K=de.getColorClasses(i.color);return e.jsxs("button",{type:"button",onClick:()=>m(u.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors text-left ${He(N)}`,children:[e.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center flex-shrink-0 transition-colors ${Ke(N)}`,children:N&&e.jsx(t.Check,{className:"w-3 h-3 text-white"})}),e.jsx("div",{className:`p-2 rounded-lg ${K.bg}`,children:e.jsx(A,{className:`w-4 h-4 ${K.text}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:u.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:u.slug})]}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${K.bg} ${K.text}`,children:u.type})]},u.id)})})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-[var(--border-color)]",children:[e.jsx("button",{onClick:()=>{U(!1),T(""),V([])},className:"px-4 py-2 rounded-lg bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:l("common.cancel","Annuler")}),e.jsxs("button",{onClick:w,disabled:C.length===0||se,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[se?e.jsx(t.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(t.Plus,{className:"w-4 h-4"}),l("groups:tenants.addSelected",{count:C.length})]})]})]})})]})}function et({groupId:s,groupName:x,isSyncedFromEntra:l}){const{t:c}=ce.useTranslation(["admin","groups"]),d=ie.useNavigate(),[o,k]=r.useState(null),[y,v]=r.useState(null),[h,P]=r.useState(!0),[j,S]=r.useState(!1),[F,U]=r.useState(""),[q,T]=r.useState(null),[L,X]=r.useState(null),[Y,R]=r.useState(null),[O,E]=r.useState("table"),[C,V]=r.useState(new Set),[G,J]=r.useState(!1),M=r.useCallback(async()=>{try{P(!0);const m=await z.groupsApi.getMembers(s);k(m)}catch(m){console.error("Failed to load group members:",m),X(c("groups:members.loadError","Erreur lors du chargement des membres"))}finally{P(!1)}},[s,c]),H=async()=>{try{const m=await oe.adminApi.users.getAll({isActive:!0,globalScope:!0}),I=Array.isArray(m)?m:m.items;v(I)}catch(m){console.error("Failed to load all users:",m)}};r.useEffect(()=>{M(),H()},[M]);const se=async()=>{if(C.size!==0)try{J(!0),X(null);const m=Array.from(C);for(const I of m)await z.groupsApi.addMember(s,{userId:I});await M(),S(!1),U(""),V(new Set),R(c("groups:members.addMultipleSuccess",{count:m.length})),setTimeout(()=>R(null),3e3)}catch(m){console.error("Failed to add members:",m);const I=m?.response?.data?.message||c("groups:members.addError","Erreur lors de l'ajout des membres");X(I)}finally{J(!1)}},D=m=>{V(I=>{const Q=new Set(I);return Q.has(m)?Q.delete(m):Q.add(m),Q})},B=async m=>{const I=o?.find(Q=>Q.userId===m);if(confirm(c("groups:members.confirmRemove",{userName:I?.fullName,groupName:x})))try{T(m),X(null),await z.groupsApi.removeMember(s,m),await M(),R(c("groups:members.removeSuccess","Membre retiré avec succès")),setTimeout(()=>R(null),3e3)}catch(Q){console.error("Failed to remove member:",Q);const p=Q?.response?.data?.message||c("groups:members.removeError","Erreur lors du retrait du membre");X(p)}finally{T(null)}},ee=y?.filter(m=>!o?.some(I=>I.userId===m.id))?.filter(m=>{if(!F.trim())return!0;const I=F.toLowerCase().trim();return m.fullName.toLowerCase().includes(I)||m.email.toLowerCase().includes(I)}),n=m=>m.split(" ").map(I=>I.charAt(0)).slice(0,2).join("").toUpperCase(),w=m=>m?"p-2 transition-colors bg-[var(--color-accent-500)] text-white":"p-2 transition-colors bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.Users,{className:"w-5 h-5"}),c("groups:members.title","Membres du groupe"),o&&e.jsx("span",{className:"ml-2 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:o.length})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center rounded-lg border border-[var(--border-color)] overflow-hidden",children:[e.jsx("button",{onClick:()=>E("table"),className:w(O==="table"),title:c("common.tableView","Vue tableau"),children:e.jsx(t.Table,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>E("card"),className:w(O==="card"),title:c("common.cardView","Vue cartes"),children:e.jsx(t.LayoutGrid,{className:"w-4 h-4"})})]}),!l&&e.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),c("groups:members.add","Ajouter des membres")]}),e.jsxs("button",{onClick:M,className:"flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(t.RefreshCw,{className:"w-4 h-4"}),c("common.refresh","Actualiser")]})]})]}),L&&e.jsxs("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/20 flex items-center gap-3",children:[e.jsx(t.AlertTriangle,{className:"w-5 h-5 text-red-500 flex-shrink-0"}),e.jsx("p",{className:"text-red-500",children:L}),e.jsx("button",{onClick:()=>X(null),className:"ml-auto",children:e.jsx(t.X,{className:"w-4 h-4 text-red-500"})})]}),Y&&e.jsxs("div",{className:"p-4 rounded-lg bg-green-500/10 border border-green-500/20 flex items-center gap-3",children:[e.jsx(t.CheckCircle,{className:"w-5 h-5 text-green-500 flex-shrink-0"}),e.jsx("p",{className:"text-green-500",children:Y})]}),e.jsx("div",{className:"p-4 rounded-lg bg-blue-500/10 border border-blue-500/20",children:e.jsx("p",{className:"text-sm text-blue-500",children:c("groups:members.info","Les membres de ce groupe héritent automatiquement des rôles et permissions attribués au groupe.")})}),l&&e.jsxs("div",{className:"p-4 rounded-lg bg-amber-500/10 border border-amber-500/20 flex items-start gap-3",children:[e.jsx(t.Info,{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-amber-500",children:c("groups:members.readOnlyEntra","Les membres de ce groupe sont synchronisés depuis Microsoft Entra ID et ne peuvent pas être modifiés ici.")})]}),h&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}),!h&&(!o||o.length===0)&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(t.Users,{className:"w-12 h-12 mx-auto mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:c("groups:members.noMembers","Ce groupe n'a aucun membre")}),!l&&e.jsxs("button",{onClick:()=>S(!0),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),c("groups:members.addFirst","Ajouter un premier membre")]})]}),!h&&(o?.length??0)>0&&O==="table"&&e.jsx("div",{className:"overflow-x-auto rounded-[var(--radius-card)] border border-[var(--border-color)]",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("groups:members.table.member","Membre")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("groups:members.table.email","Email")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("groups:members.table.addedAt","Ajouté le")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("groups:members.table.addedBy","Par")}),!l&&e.jsx("th",{className:"px-4 py-3 text-right text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("common.actions","Actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:o?.map(m=>e.jsxs("tr",{className:"bg-[var(--bg-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("button",{className:"flex items-center gap-3 cursor-pointer text-left bg-transparent border-0 p-0 hover:opacity-80 transition-opacity",onClick:()=>d(`/administration/users/${m.userId}`),children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)]/10 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-xs font-medium text-[var(--color-accent-500)]",children:n(m.fullName)})}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)] hover:text-[var(--color-accent-500)]",children:m.fullName})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)]",children:m.email}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)]",children:new Date(m.addedAt).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)]",children:m.addedBy||"-"}),!l&&e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs("button",{onClick:()=>B(m.userId),disabled:q===m.userId,className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",children:[q===m.userId?e.jsx(t.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(t.Trash2,{className:"w-3 h-3"}),c("common.remove","Retirer")]})})]},m.userId))})]})}),!h&&(o?.length??0)>0&&O!=="table"&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:o?.map(m=>e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] transition-colors",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("button",{className:"flex items-start gap-3 min-w-0 cursor-pointer text-left bg-transparent border-0 p-0 hover:opacity-80 transition-opacity",onClick:()=>d(`/administration/users/${m.userId}`),children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-500)]/10 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-sm font-medium text-[var(--color-accent-500)]",children:n(m.fullName)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--text-primary)] truncate",children:m.fullName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:m.email})]})]})}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-color)] space-y-1",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[c("groups:members.addedAt","Ajouté le"),": ",new Date(m.addedAt).toLocaleDateString()]}),m.addedBy&&e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[c("groups:members.addedBy","Par"),": ",m.addedBy]})]}),!l&&e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsxs("button",{onClick:()=>B(m.userId),disabled:q===m.userId,className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",children:[q===m.userId?e.jsx(t.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(t.Trash2,{className:"w-3 h-3"}),c("common.remove","Retirer")]})})]},m.userId))}),j&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"w-full max-w-lg mx-4 bg-[var(--bg-primary)] rounded-[var(--radius-card)] shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:c("groups:members.addModalTitle","Ajouter des membres au groupe")}),C.size>0&&e.jsx("p",{className:"text-sm text-[var(--color-accent-500)] mt-1",children:c("groups:members.selectedCount",{count:C.size})})]}),e.jsx("button",{onClick:()=>{S(!1),U(""),V(new Set)},className:"p-1 rounded hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-5 h-5 text-[var(--text-secondary)]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",placeholder:c("groups:members.searchPlaceholder","Rechercher un utilisateur..."),value:F,onChange:m=>U(m.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:!ee||ee.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(t.Users,{className:"w-8 h-8 mx-auto mb-2 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:c("groups:members.noAvailableUsers","Aucun utilisateur disponible")})]}):ee.map(m=>{const I=C.has(m.id);return e.jsxs("button",{onClick:()=>D(m.id),disabled:G,className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors text-left disabled:opacity-50 ${I?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]/10":"border-[var(--border-color)] hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center flex-shrink-0 transition-colors ${I?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]":"border-[var(--border-color)]"}`,children:I&&e.jsx(t.Check,{className:"w-3 h-3 text-white"})}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-500)]/10 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-sm font-medium text-[var(--color-accent-500)]",children:n(m.fullName)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:m.fullName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:m.email})]})]},m.id)})})]}),e.jsxs("div",{className:"flex justify-between items-center gap-2 p-4 border-t border-[var(--border-color)]",children:[e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:C.size>0&&e.jsx("button",{onClick:()=>V(new Set),className:"text-[var(--color-accent-500)] hover:underline",children:c("common.clearSelection","Effacer la sélection")})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{S(!1),U(""),V(new Set)},className:"px-4 py-2 rounded-lg bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:c("common.cancel","Annuler")}),e.jsx("button",{onClick:se,disabled:C.size===0||G,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:G?e.jsxs(e.Fragment,{children:[e.jsx(t.Loader2,{className:"w-4 h-4 animate-spin"}),c("common.adding","Ajout...")]}):e.jsxs(e.Fragment,{children:[e.jsx(t.Plus,{className:"w-4 h-4"}),c("groups:members.addSelected",{count:C.size})]})})]})]})]})})]})}function tt(s){const{groupId:x,tenantId:l}=s,c=r.useCallback(async h=>z.groupsApi.getById(h),[]),d=r.useCallback(async(h,P)=>{const[j,S]=await Promise.all([z.groupsApi.getById(h),oe.adminApi.permissions.getMatrix()]),F=new Map(S.roles.map(T=>[T.id,T])),U=j.roles.map(T=>{const L=F.get(T.roleId);return L?{id:T.roleId,name:L.name,shortName:L.shortName||L.name,category:L.category||"Custom",description:L.description??null,tenantId:T.tenantId??null,tenantName:T.tenantName??null,isGlobal:T.isGlobal}:null}).filter(T=>T!==null);return P?U.filter(T=>T.isGlobal||T.tenantId===P):U},[]),o=oe.useEntityPermissions({entityId:x,tenantId:l,loadEntity:c,loadRoles:d}),k=o.entity,y=o.roles,v=r.useCallback(h=>{const P=[];return y.forEach(j=>{const S=o.inheritanceMap[j.id];if(S){const F=S.get(h);F&&(F.isDirect||F.isInherited)&&P.push(j)}}),P},[y,o.inheritanceMap]);return{loading:o.loading,error:o.error,group:k,groupRoles:y,resources:o.resources,assignments:o.assignments,inheritanceMap:o.inheritanceMap,effectivePermissions:o.effectivePermissions,filters:o.filters,filteredResources:o.filteredResources,applications:o.applications,modules:o.modules,updateFilters:o.updateFilters,getPermissionInheritance:o.getPermissionInheritance,getPermissionSources:v,reloadData:o.reloadData,isTenantMode:o.isTenantMode}}function st(s){const x=new Map;return s.forEach(l=>{const c=l.isGlobal?"__global__":l.tenantId||"__unknown__";x.has(c)||x.set(c,{isGlobal:l.isGlobal,displayName:l.tenantName})}),Array.from(x.entries()).map(([l,c])=>({key:l,isGlobal:c.isGlobal,displayName:c.displayName}))}function rt(s,x){const l=[];return s.forEach(c=>{const d=x(c.name)?"Custom":"Direct";l.find(o=>o.type===d)||l.push({type:d})}),l}const at={"*":e.jsx(t.Shield,{className:"h-3.5 w-3.5"}),read:e.jsx(t.Eye,{className:"h-3.5 w-3.5"}),create:e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),update:e.jsx(t.Edit,{className:"h-3.5 w-3.5"}),delete:e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),assign:e.jsx(t.UserPlus,{className:"h-3.5 w-3.5"}),execute:e.jsx(t.Play,{className:"h-3.5 w-3.5"})},nt={"*":"bg-[var(--accent-bg)] text-[var(--accent-text)] border-[var(--accent-border)]",read:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]",create:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",update:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",delete:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",assign:"bg-[var(--accent-bg)] text-[var(--accent-text)] border-[var(--accent-border)]",execute:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]"};function ot({groupId:s,compact:x=!1,tenantId:l,tenantSlug:c}){const{t:d}=ce.useTranslation("admin"),o=ie.useNavigate(),{loading:k,error:y,group:v,groupRoles:h,filteredResources:P,effectivePermissions:j,filters:S,applications:F,modules:U,updateFilters:q,getPermissionSources:T,reloadData:L,isTenantMode:X}=tt({groupId:s,tenantId:l}),{collapsedApps:Y,toggleApp:R}=oe.useCollapsibleState(),[O,E]=r.useState(new Set),[C,V]=r.useState(new Set),[G,J]=r.useState(new Set),[M,H]=r.useState(null),[se,D]=r.useState(null),[B,re]=r.useState(new Set),[ee,n]=r.useState(null),[w,m]=r.useState(!1),[I,Q]=r.useState(null),p=r.useMemo(()=>oe.createAdminApi(c),[c]),f=r.useMemo(()=>z.createGroupsApi(c),[c]);r.useEffect(()=>{(async()=>{try{m(!0);const g=await f.getCustomRole(s);g?(D(g.id),re(new Set((g.permissions??[]).map(b=>b.id)))):(D(null),re(new Set))}catch(g){g instanceof Error&&g.message.includes("404")||console.error("Failed to load custom role:",g),D(null),re(new Set)}finally{m(!1)}})()},[s,f]);const _=async a=>{if(ee===null)try{n(a),Q(null);let g=se,b=new Set(B);g||(g=(await f.createCustomRole(s)).id,D(g),b=new Set);const $=new Set(b);$.has(a)?$.delete(a):$.add(a);const te=await p.roles.getById(g);await p.roles.update(g,{name:te.name,shortName:te.shortName||void 0,category:te.category||void 0,description:te.description||void 0,permissionIds:Array.from($)}),re($),await L()}catch(g){console.error("Failed to toggle permission:",g),Q(d("groupPermissions.toggleError","Erreur lors de la modification de la permission. Veuillez réessayer.")),setTimeout(()=>Q(null),5e3)}finally{n(null)}},u=a=>{H(M===a?null:a)},N=a=>{J(g=>{const b=new Set(g);return b.has(a)?b.delete(a):b.add(a),b})},i=a=>{E(g=>{const b=new Set(g);return b.has(a)?b.delete(a):b.add(a),b})},A=a=>{V(g=>{const b=new Set(g);return b.has(a)?b.delete(a):b.add(a),b})},K=r.useCallback(a=>{const g=[...a.permissions];return a.childSections&&a.childSections.forEach(b=>{g.push(...b.permissions)}),g},[]),he=r.useCallback((a,g=!1)=>{if(g)return pe.calculatePermissionStatus(a,ae=>j.has(ae));const b=K(a),$=b.filter(ae=>j.has(ae.id)).length,te=b.length;let Z;return $===0?Z="none":$===te?Z="all":Z=b.every(le=>!j.has(le.id)||le.action==="read")&&b.some(le=>le.action==="read"&&j.has(le.id))?"read-only":"some",{status:Z,grantedCount:$}},[j,K]),be=a=>a.filter(g=>{const{status:b}=pe.calculateModuleWithSectionsStatus(g.module,g.sections,$=>j.has($));return G.has(b)}),ge=a=>G.size===0?a:a.map(g=>({...g,modules:be(g.modules)})).filter(g=>g.modules.length>0),fe=r.useMemo(()=>{let a=pe.groupByApplicationWithSections(P);return ge(a)},[P,G,j]),Ae=r.useMemo(()=>fe.reduce((a,g)=>a+g.modules.length,0),[fe]),Pe=(a,g)=>{a.find(b=>b.id===g.id&&b.tenantId===g.tenantId)||a.push(g)},Ge=a=>{const g=[];return a.permissions.forEach(b=>{j.has(b.id)&&T(b.id).forEach($=>{Pe(g,$)})}),g},ve=a=>a.startsWith("group_")&&a.endsWith("_custom"),Me=a=>ve(a.name)?d("groupPermissions.customBadge","Custom"):a.shortName||a.name,ke=r.useMemo(()=>v?{id:se||`group_${s}_custom`,name:v.name,shortName:v.name,category:"Custom",description:null,isSystem:!1,permissions:[],permissionIds:[]}:null,[v,se,s]),Fe=r.useCallback((a,g)=>{const b=j.has(g),$=B.has(g),te=b?T(g):[],Z=te.find(ae=>!ve(ae.name));return{isDirect:$,isInherited:b&&!$&&te.length>0,inheritedFromPath:Z?Z.name:void 0,inheritedFromId:Z?.id}},[j,B,T]);if(k)return e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(t.Loader2,{className:"h-8 w-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"ml-3 text-[var(--text-secondary)]",children:d("groupPermissions.loading","Chargement des permissions...")})]});if(y)return e.jsx("div",{className:"rounded-[var(--radius-card)] bg-[var(--error-bg)] p-4 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(t.AlertCircle,{className:"h-5 w-5 text-[var(--error-text)]"}),e.jsx("p",{className:"ml-2 text-sm text-[var(--error-text)]",children:y})]})});if(!v)return e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(t.Shield,{className:"h-12 w-12 mx-auto mb-4 text-[var(--text-muted)]"}),e.jsx("p",{children:d("groupPermissions.noGroup","Groupe non trouvé")})]});const Le=a=>a==="resource"?"pl-28":a==="section"?"pl-22":"pl-16",$e=a=>a==="resource"?e.jsx(t.Database,{className:"h-3.5 w-3.5 text-[var(--text-muted)]"}):a==="section"?e.jsx(t.FileText,{className:"h-3.5 w-3.5 text-[var(--text-muted)]"}):e.jsx(t.Box,{className:"h-3.5 w-3.5 text-[var(--text-secondary)]"}),Ee=a=>a==="resource"?"text-[var(--text-muted)] italic":a==="section"?"text-[var(--text-secondary)]":"font-medium text-[var(--text-primary)]",De=(a,g)=>a.map((b,$)=>ye(b,g+$,"resource",!1,!1)),Be=(a,g,b)=>{const{section:$,resources:te}=a,Z=te.length>0,ae=C.has($.id);return e.jsxs(r.Fragment,{children:[ye($,g+b+1,"section",Z,ae),Z&&!ae&&De(te,g+b+2)]},$.id)},Ue=(a,g,b,$)=>!b||$?null:a.map((te,Z)=>Be(te,g,Z)),ye=(a,g,b,$=!1,te=!1)=>{const Z=b==="section",{status:ae,grantedCount:le}=he(a,Z),xe=Z?a.permissions.length:K(a).length,qe=pe.getPermissionCellBackground(ae),me=Ge(a),Te=M===a.id,Oe=Le(b);return e.jsxs("tr",{className:`hover:bg-[var(--bg-hover)] ${g%2===0?"item-light":"item-medium"}`,children:[e.jsx("td",{className:`sticky left-0 z-10 ${g%2===0?"item-light":"item-medium"} px-3 py-2 ${Oe}`,style:{width:"280px",minWidth:"280px",maxWidth:"280px"},children:e.jsxs("div",{className:"flex items-center gap-2",children:[$&&e.jsx("button",{onClick:()=>b==="module"?i(a.id):A(a.id),className:"p-0.5 hover:bg-[var(--bg-hover)] rounded",children:te?e.jsx(t.ChevronRight,{className:"h-3 w-3 text-[var(--text-muted)]"}):e.jsx(t.ChevronDown,{className:"h-3 w-3 text-[var(--text-muted)]"})}),$e(b),e.jsx("span",{className:`text-sm ${Ee(b)}`,children:a.label}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["(",xe,")"]})]})}),e.jsxs("td",{className:`px-0 py-1 text-center relative ${qe}`,style:{width:"60px",minWidth:"60px",maxWidth:"60px"},children:[e.jsx("button",{type:"button",onClick:()=>u(a.id),className:`w-full h-full min-h-[36px] flex items-center justify-center rounded transition-colors hover:opacity-80 ${Te?"ring-2 ring-[var(--color-accent-500)]":""}`,title:`${a.label}: ${le}/${xe}`,children:e.jsx(pe.PermissionStatusIndicator,{status:ae,grantedCount:le,totalCount:xe})}),Te&&v&&ke&&e.jsx(pe.PermissionPopover,{mode:"editable",role:ke,resource:a,onClose:()=>H(null),onTogglePermission:_,getPermissionInheritance:Fe})]}),e.jsx("td",{className:"px-3 py-2",style:{width:"140px",minWidth:"140px"},children:e.jsx("div",{className:"flex flex-wrap gap-1",children:me.length>0?me.map(W=>{const ne=ve(W.name),ue=Me(W),je=W.isGlobal?e.jsx(t.Globe,{className:"h-2.5 w-2.5 text-[var(--info-text)]"}):e.jsx(t.Building2,{className:"h-2.5 w-2.5 text-[var(--warning-text)]"}),Ne=W.isGlobal?d("groupPermissions.globalScope","Global"):W.tenantName||d("groupPermissions.tenantScope","Tenant");return e.jsxs("button",{onClick:()=>!ne&&o(`/administration/permissions/roles/${W.id}`),className:`inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-full transition-all ${ne?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)] border border-[var(--color-accent-300)] dark:border-[var(--color-accent-700)] cursor-default":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)] cursor-pointer hover:ring-1 hover:ring-[var(--color-accent-500)] hover:shadow-sm"}`,title:`${ne?d("groupPermissions.customRoleTooltip","Rôle personnalisé"):d("groupPermissions.clickToViewRole","Cliquer pour voir le rôle")} (${Ne})`,children:[je,ue,ne&&e.jsx(t.Star,{className:"h-3 w-3"})]},`${W.id}-${W.tenantId||"global"}`)}):e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"-"})})}),e.jsx("td",{className:"px-3 py-2",style:{width:"120px",minWidth:"120px"},children:e.jsx("div",{className:"flex flex-wrap gap-1",children:me.length>0?st(me).map(({key:W,isGlobal:ne,displayName:ue})=>e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 text-xs rounded-full ${ne?"bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]"}`,children:ne?d("groupPermissions.globalScope","Global"):ue||d("groupPermissions.tenantScope","Tenant")},W)):e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"-"})})}),e.jsx("td",{className:"px-3 py-2",style:{width:"100px",minWidth:"100px"},children:e.jsx("div",{className:"flex flex-wrap gap-1",children:me.length>0?rt(me,ve).map((W,ne)=>e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-full ${W.type==="Direct"?"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]":"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)] border border-[var(--color-accent-300)] dark:border-[var(--color-accent-700)]"}`,title:W.type==="Custom"?d("groupPermissions.customPermissions","Permissions personnalisées"):d("groupPermissions.directAssignmentTooltip","Rôle assigné directement au groupe"),children:[W.type==="Direct"&&e.jsx(t.UserCheck,{className:"h-3 w-3"}),W.type==="Custom"&&e.jsx(t.User,{className:"h-3 w-3"}),W.type==="Direct"?d("groupPermissions.directAssignment","Direct"):d("groupPermissions.customSource","Custom")]},`source-${W.type}-${ne}`)):e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"-"})})}),e.jsx("td",{className:"px-3 py-2",style:{minWidth:"200px"},children:e.jsx("div",{className:"flex flex-wrap gap-1.5 items-center relative",children:a.permissions.filter(W=>j.has(W.id)).map(W=>{const ne=B.has(W.id),ue=ee===W.id,je=nt[W.action]||"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]",Ne=at[W.action]||e.jsx(t.Eye,{className:"h-3.5 w-3.5"});return e.jsxs("button",{onClick:()=>_(W.id),disabled:ue||w||!ne,className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-[var(--radius-badge)] border text-xs font-medium transition-all ${je} ${ne?"ring-2 ring-[var(--color-accent-600)] dark:ring-[var(--color-accent-400)] hover:opacity-80 cursor-pointer":"opacity-60 cursor-not-allowed"} disabled:opacity-50`,title:ne?d("groupPermissions.clickToRemove","Cliquer pour retirer"):d("groupPermissions.grantedByRole","Accordé par un rôle"),children:[ue?e.jsx(t.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):Ne,e.jsx("span",{className:"capitalize",children:d(`assignments.actions.${W.action==="*"?"all":W.action}.label`)}),ne&&e.jsx(t.Star,{className:"h-3 w-3"})]},W.id)})})})]},a.id)};return e.jsxs("div",{children:[!x&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-start lg:gap-6",children:[e.jsxs("div",{className:"w-full lg:w-72 lg:flex-shrink-0 space-y-4 mb-4 lg:mb-0 lg:sticky lg:top-4",children:[e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--text-primary)] mb-3",children:d("groupPermissions.filters.title","Filtres")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-[var(--text-secondary)]",children:d("groupPermissions.filters.application","Application")}),e.jsxs("select",{value:S.applicationFilter,onChange:a=>q({applicationFilter:a.target.value,moduleFilter:"all"}),className:"w-full px-3 py-1.5 text-sm bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:d("groupPermissions.filters.allApplications","Toutes les applications")}),F.map(a=>e.jsx("option",{value:a.app,children:a.label},a.app))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-[var(--text-secondary)]",children:d("groupPermissions.filters.module","Module")}),e.jsxs("select",{value:S.moduleFilter,onChange:a=>q({moduleFilter:a.target.value}),className:"w-full px-3 py-1.5 text-sm bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:d("groupPermissions.filters.allModules","Tous les modules")}),U.filter(a=>S.applicationFilter==="all"||a.app===S.applicationFilter).map(a=>e.jsx("option",{value:a.module,children:a.label},`${a.app}:${a.module}`))]})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border-color)]",children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)] block mb-2",children:d("groupPermissions.filterByStatus","Filtrer par statut")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs("button",{onClick:()=>N("all"),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full border transition-colors ${G.has("all")?"bg-[var(--success-bg)] border-[var(--success-border)] text-[var(--success-text)]":"bg-[var(--bg-tertiary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--success-border)]"}`,children:[e.jsx(t.Check,{className:`h-3 w-3 ${G.has("all")?"":"text-[var(--success-dot)]"}`}),d("assignments.complete")]}),e.jsxs("button",{onClick:()=>N("some"),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full border transition-colors ${G.has("some")?"bg-[var(--warning-bg)] border-[var(--warning-border)] text-[var(--warning-text)]":"bg-[var(--bg-tertiary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--warning-border)]"}`,children:[e.jsx(t.Star,{className:`h-3 w-3 ${G.has("some")?"":"text-[var(--warning-dot)]"}`}),d("assignments.partial")]}),e.jsxs("button",{onClick:()=>N("read-only"),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full border transition-colors ${G.has("read-only")?"bg-[var(--info-bg)] border-[var(--info-border)] text-[var(--info-text)]":"bg-[var(--bg-tertiary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--info-border)]"}`,children:[e.jsx(t.Eye,{className:`h-3 w-3 ${G.has("read-only")?"":"text-[var(--info-dot)]"}`}),d("assignments.readOnly")]}),e.jsxs("button",{onClick:()=>N("none"),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full border transition-colors ${G.has("none")?"bg-[var(--error-bg)] border-[var(--error-border)] text-[var(--error-text)]":"bg-[var(--bg-tertiary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--error-border)]"}`,children:[e.jsx(t.Ban,{className:`h-3 w-3 ${G.has("none")?"":"text-[var(--text-muted)]"}`}),d("assignments.none")]})]}),G.size>0&&e.jsx("button",{onClick:()=>J(new Set),className:"mt-2 text-xs text-[var(--color-accent-500)] hover:text-[var(--color-accent-600)] underline",children:d("assignments.clearFilters")})]}),e.jsx("div",{className:"mt-4 pt-4 border-t border-[var(--border-color)]",children:e.jsxs("span",{className:"px-2.5 py-1 text-xs font-semibold rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:[Ae," ",d("assignments.modules")]})})]}),e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--text-primary)] mb-3",children:d("groupPermissions.assignedRoles","Rôles assignés")}),h.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(a=>{const g=ve(a.name),b=a.isGlobal?e.jsx(t.Globe,{className:"h-3 w-3 text-[var(--info-text)]"}):e.jsx(t.Building2,{className:"h-3 w-3 text-[var(--warning-text)]"}),$=a.isGlobal?d("groupPermissions.globalScope","Global"):a.tenantName||d("groupPermissions.tenantScope","Tenant");return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:()=>!g&&o(`/administration/permissions/roles/${a.id}`),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-full bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)] transition-all ${g?"cursor-default":"cursor-pointer hover:ring-2 hover:ring-[var(--color-accent-500)] hover:shadow-md"}`,title:g?d("groupPermissions.customRoleTooltip","Rôle personnalisé"):d("groupPermissions.clickToViewRole","Cliquer pour voir le rôle"),children:[e.jsx(t.Shield,{className:"h-3.5 w-3.5"}),a.shortName||a.name]}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-full ${a.isGlobal?"bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]":"bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]"}`,title:a.isGlobal?d("groupPermissions.globalScopeTooltip","Ce rôle s'applique à tous les tenants"):d("groupPermissions.tenantScopeTooltip","Ce rôle s'applique uniquement à ce tenant: {{tenant}}",{tenant:a.tenantName}),children:[b,e.jsx("span",{className:"hidden sm:inline",children:$})]})]},`${a.id}-${a.tenantId||"global"}`)})}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-muted)]",children:[e.jsx(t.Info,{className:"h-4 w-4"}),e.jsx("span",{children:d("groupPermissions.noRolesInfo","Ce groupe n'a aucun rôle.")})]})]}),X&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-[var(--radius-card)] bg-[var(--accent-bg)] border border-[var(--accent-border)]",children:[e.jsx(t.Shield,{className:"h-4 w-4 text-[var(--accent-text)]"}),e.jsx("span",{className:"text-sm text-[var(--accent-text)]",children:d("groupPermissions.tenantModeInfo","Affichage des permissions dans le contexte du tenant.")})]}),I&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]",children:[e.jsx(t.AlertCircle,{className:"h-4 w-4 text-[var(--error-text)]"}),e.jsx("span",{className:"text-sm text-[var(--error-text)]",children:I})]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"overflow-x-auto overflow-y-visible",children:e.jsxs("table",{className:"border-collapse",style:{width:"auto"},children:[e.jsx("thead",{className:"item-medium border-b border-[var(--item-color-border)]",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"sticky left-0 z-20 item-medium px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"280px",minWidth:"280px",maxWidth:"280px",height:"48px",verticalAlign:"middle"},children:d("assignments.resource")}),e.jsx("th",{scope:"col",className:"px-2 text-center text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"60px",minWidth:"60px",maxWidth:"60px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.status","Statut")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"140px",minWidth:"140px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.sourceRoles","Rôles sources")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"120px",minWidth:"120px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.tenant","Tenant")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"100px",minWidth:"100px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.source","Source")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{minWidth:"200px",height:"48px",verticalAlign:"middle"},children:d("assignments.permissions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--item-color-border)]",children:fe.map(a=>{const g=a.application,b=Y.has(g);return e.jsxs(r.Fragment,{children:[e.jsxs("tr",{className:"bg-[var(--color-accent-900)]/30 dark:bg-[var(--color-accent-900)]/50",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-3 bg-[var(--color-accent-900)]/30 dark:bg-[var(--color-accent-900)]/50",style:{width:"280px",minWidth:"280px",maxWidth:"280px"},children:e.jsxs("button",{onClick:()=>R(g),className:"flex items-center gap-3 w-full text-left hover:opacity-80",children:[b?e.jsx(t.ChevronRight,{className:"h-5 w-5 text-[var(--color-accent-400)]"}):e.jsx(t.ChevronDown,{className:"h-5 w-5 text-[var(--color-accent-400)]"}),e.jsx(t.FolderOpen,{className:"h-5 w-5 text-[var(--color-accent-400)]"}),e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-300)] uppercase tracking-wider",children:a.application}),e.jsxs("span",{className:"text-xs text-[var(--color-accent-400)] ml-auto",children:[a.modules.length," module",a.modules.length>1?"s":""]})]})}),e.jsx("td",{colSpan:5,className:"px-0 py-3"})]}),!b&&a.modules.map(($,te)=>{const{module:Z,sections:ae}=$,le=ae.length>0,xe=O.has(Z.id);return e.jsxs(r.Fragment,{children:[ye(Z,te,"module",le,xe),Ue(ae,te,le,xe)]},Z.id)})]},g)})})]})}),Ae===0&&e.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:d("assignments.noResources")})]})]})}),x&&e.jsx("div",{className:"overflow-x-auto overflow-y-visible",children:e.jsxs("table",{className:"border-collapse",style:{width:"auto"},children:[e.jsx("thead",{className:"item-medium border-b border-[var(--item-color-border)]",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"sticky left-0 z-20 item-medium px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"280px",minWidth:"280px",maxWidth:"280px",height:"48px",verticalAlign:"middle"},children:d("assignments.resource")}),e.jsx("th",{scope:"col",className:"px-2 text-center text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"60px",minWidth:"60px",maxWidth:"60px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.status","Statut")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"140px",minWidth:"140px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.sourceRoles","Rôles sources")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"120px",minWidth:"120px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.tenant","Tenant")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"100px",minWidth:"100px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.source","Source")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{minWidth:"200px",height:"48px",verticalAlign:"middle"},children:d("assignments.permissions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--item-color-border)]",children:fe.map(a=>e.jsx(r.Fragment,{children:a.modules.map((g,b)=>e.jsx(r.Fragment,{children:ye(g.module,b,"module",!1,!1)},g.module.id))},a.application))})]})})]})}function lt({groupId:s,tenantId:x}){const{t:l}=ce.useTranslation(["groups","admin"]),[c,d]=r.useState([]),[o,k]=r.useState(!0),[y,v]=r.useState(new Set),h=r.useCallback(async()=>{k(!0);try{const j=await z.groupsApi.getApplicationAccess(s,x);d(j)}catch{d([])}finally{k(!1)}},[s,x]);r.useEffect(()=>{h()},[h]);const P=j=>{v(S=>{const F=new Set(S);return F.has(j)?F.delete(j):F.add(j),F})};return o?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):c.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(t.Boxes,{className:"w-12 h-12 mx-auto mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{children:l("groups:applications.noAccess")})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:l("groups:applications.title")}),e.jsx("button",{onClick:()=>{h()},className:"p-2 rounded-[var(--radius-button)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]",title:l("admin:common.refresh","Refresh"),children:e.jsx(t.RefreshCw,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"space-y-2",children:c.map(j=>e.jsx(it,{app:j,isExpanded:y.has(j.applicationId),onToggle:()=>P(j.applicationId)},j.applicationId))})]})}function it({app:s,isExpanded:x,onToggle:l}){const{t:c}=ce.useTranslation(["groups","admin"]),d=_e,o=s.icon?d[s.icon]:null,k=r.useMemo(()=>{const y={};for(const v of s.permissions){const h=v.moduleName||"_global";y[h]||(y[h]={moduleName:v.moduleName||c("groups:applications.globalPermissions"),permissions:[]}),y[h].permissions.push(v)}return Object.values(y)},[s.permissions,c]);return e.jsxs("div",{className:"border border-[var(--border-color)] rounded-[var(--radius-card)] bg-[var(--bg-card)] overflow-hidden",children:[e.jsxs("button",{onClick:l,className:"w-full flex items-center gap-3 p-4 text-left hover:bg-[var(--bg-hover)] transition-colors",children:[x?e.jsx(t.ChevronDown,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}):e.jsx(t.ChevronRight,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}),e.jsx("div",{className:"w-9 h-9 rounded-[var(--radius-button)] bg-[var(--color-accent-500)]/10 flex items-center justify-center flex-shrink-0",children:o?e.jsx(o,{className:"w-5 h-5 text-[var(--color-accent-600)]"}):e.jsx(t.Layers,{className:"w-5 h-5 text-[var(--color-accent-600)]"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] truncate",children:s.applicationLabel}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] truncate",children:s.applicationCode})]}),s.hasFullAccess?e.jsx("span",{className:"px-2.5 py-1 text-xs font-medium rounded-full bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)] flex-shrink-0",children:c("groups:applications.fullAccess")}):e.jsx("span",{className:"px-2.5 py-1 text-xs font-medium rounded-full bg-[var(--color-accent-500)]/10 text-[var(--color-accent-600)] border border-[var(--color-accent-500)]/20 flex-shrink-0",children:c("groups:applications.permissionCount",{count:s.permissions.length})}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)] flex items-center gap-1 flex-shrink-0",children:[e.jsx(t.Shield,{className:"w-3.5 h-3.5"}),s.roles.length]})]}),x&&e.jsxs("div",{className:"border-t border-[var(--border-color)] p-4 space-y-4 bg-[var(--bg-secondary)]",children:[e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider mb-2",children:c("groups:applications.rolesGrantingAccess")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.roles.map(y=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-full bg-[var(--bg-card)] border border-[var(--border-color)] text-[var(--text-primary)]",children:[e.jsx(t.Shield,{className:"w-3 h-3 text-[var(--color-accent-500)]"}),y.roleName]},y.roleId))})]}),!s.hasFullAccess&&s.permissions.length>0&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider mb-2",children:c("groups:applications.permissionsDetail")}),e.jsx("div",{className:"space-y-3",children:k.map(y=>e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-[var(--text-secondary)] mb-1",children:y.moduleName}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:y.permissions.map(v=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded bg-[var(--bg-card)] border border-[var(--border-color)] text-[var(--text-secondary)]",children:[e.jsx(t.Key,{className:"w-2.5 h-2.5 text-[var(--text-tertiary)]"}),v.action||ct(v.path)]},v.path))})]},y.moduleName))})]}),s.hasFullAccess&&e.jsx("p",{className:"text-xs text-[var(--success-text)] italic",children:c("groups:applications.fullAccessDescription")})]})]})}function ct(s){return s.split(".").at(-1)}function dt({className:s="",showSwitch:x=!0,onSwitchClick:l}){const{t:c}=ce.useTranslation("admin"),{currentTenant:d,hasMultipleTenants:o,isGlobalView:k}=oe.useTenant();if(!k&&(!o||!d))return null;if(k)return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-4 py-2.5 border bg-emerald-500/5 border-emerald-500/20 ${s}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 flex items-center justify-center bg-emerald-500/10",style:{borderRadius:"var(--radius-card)"},children:e.jsx(t.Globe,{className:"w-4 h-4 text-emerald-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-emerald-700",children:c("scope.banner.globalMode","Vue globale")}),e.jsx("p",{className:"text-xs text-emerald-600/70 mt-0.5",children:c("scope.banner.globalModeDesc","Vous voyez les données de tous les tenants")})]})]}),x&&l&&e.jsxs("button",{onClick:l,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-emerald-700 hover:text-emerald-800 hover:bg-emerald-500/10 transition-colors",style:{borderRadius:"var(--radius-button)"},children:[e.jsx(t.ArrowRightLeft,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:c("scope.banner.selectTenant","Sélectionner un tenant")})]})]});const y=d?.type==="Business";return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-4 py-2.5 border bg-[var(--color-accent-500)]/5 border-[var(--color-accent-500)]/20 ${s}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`flex-shrink-0 w-8 h-8 flex items-center justify-center ${y?"bg-blue-500/10":"bg-violet-500/10"}`,style:{borderRadius:"var(--radius-card)"},children:y?e.jsx(t.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(t.User,{className:"w-4 h-4 text-violet-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:c("scope.banner.tenantMode","Espace de travail: {{tenantName}}",{tenantName:d?.name})}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:c("scope.banner.tenantModeDesc","Les modifications s'appliquent uniquement à ce tenant")})]})]}),x&&l&&e.jsxs("button",{onClick:l,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:[e.jsx(t.ArrowRightLeft,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:c("scope.banner.switchScope","Changer de scope")})]})]})}const xt=["info","hierarchy","members","roles","tenants","applications","permissions"],we=s=>s?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s):!1,mt=()=>{const[s,x]=r.useState(null),[l,c]=r.useState(null),[d,o]=r.useState(!1),[k,y]=r.useState(!0),[v,h]=r.useState(!1),[P,j]=r.useState(null),[S,F]=r.useState(null),[U,q]=r.useState(!1),[T,L]=r.useState({name:"",description:""});return{group:s,setGroup:x,roles:l,setRoles:c,rolesLoading:d,setRolesLoading:o,loading:k,setLoading:y,saving:v,setSaving:h,error:P,setError:j,success:S,setSuccess:F,isEditing:U,setIsEditing:q,formData:T,setFormData:L}};function ut({groupId:s,group:x,onRefresh:l,onSuccess:c,onError:d}){const{t:o}=ce.useTranslation(["admin","groups"]),[k,y]=r.useState([]),[v,h]=r.useState(!1),[P,j]=r.useState(!1),[S,F]=r.useState(!1),[U,q]=r.useState(!1),[T,L]=r.useState(""),[X,Y]=r.useState(""),[R,O]=r.useState(!1),[E,C]=r.useState(""),[V,G]=r.useState(""),[J,M]=r.useState(!1),[H,se]=r.useState([]),[D,B]=r.useState(!1),re=r.useCallback(async()=>{try{h(!0);const i=await z.groupsApi.getAll();y(i)}catch{}finally{h(!1)}},[]);r.useEffect(()=>{(P||S)&&re()},[P,S,re]),r.useEffect(()=>{if(!x.parentGroupId)return;(async()=>{try{B(!0);const A=await z.groupsApi.getInheritedMembers(s);se(A)}catch{}finally{B(!1)}})()},[s,x.parentGroupId]);const ee=r.useMemo(()=>{const i=new Map;for(const A of H){const K=A.inheritedFromGroupId;i.has(K)||i.set(K,{groupId:A.inheritedFromGroupId,groupName:A.inheritedFromGroupName,level:A.level,members:[]}),i.get(K).members.push(A)}return Array.from(i.values()).sort((A,K)=>A.level-K.level)},[H]),w=((i,A)=>{const K=new Set,he=[i];for(;he.length>0;){const be=he.shift();K.add(be),A.filter(ge=>ge.parentGroupId===be).forEach(ge=>he.push(ge.id))}return K})(s,k),m=k.filter(i=>!w.has(i.id)&&i.isActive).filter(i=>!T||i.name.toLowerCase().includes(T.toLowerCase())),I=new Set(x.childGroups?.map(i=>i.id)||[]),Q=k.filter(i=>i.id!==s&&!I.has(i.id)&&i.isActive).filter(i=>i.parentGroupId!==s).filter(i=>!X||i.name.toLowerCase().includes(X.toLowerCase())),p=async i=>{try{O(!0),await z.groupsApi.setParentGroup(s,{parentGroupId:i}),await l(),c(o("groups:hierarchy.parentSet")),j(!1),L("")}catch{d(o("groups:hierarchy.errors.setParentFailed"))}finally{O(!1)}},f=async()=>{try{O(!0),await z.groupsApi.setParentGroup(s,{parentGroupId:null}),await l(),c(o("groups:hierarchy.parentCleared"))}catch{d(o("groups:hierarchy.errors.clearParentFailed"))}finally{O(!1)}},_=async i=>{try{O(!0),await z.groupsApi.setParentGroup(i,{parentGroupId:s}),await l(),c(o("groups:hierarchy.childAdded")),F(!1),Y("")}catch{d(o("groups:hierarchy.errors.addChildFailed"))}finally{O(!1)}},u=async(i,A)=>{if(confirm(o("groups:hierarchy.confirmRemoveChild",{name:A})))try{O(!0),await z.groupsApi.setParentGroup(i,{parentGroupId:null}),await l(),c(o("groups:hierarchy.childRemoved"))}catch{d(o("groups:hierarchy.errors.removeChildFailed"))}finally{O(!1)}},N=async i=>{if(i.preventDefault(),!!E.trim())try{O(!0),await z.groupsApi.create({name:E.trim(),description:V.trim()||void 0,isSecurityGroup:J,parentGroupId:s}),await l(),c(o("groups:hierarchy.childCreated")),q(!1),C(""),G(""),M(!1)}catch{d(o("groups:hierarchy.errors.createChildFailed"))}finally{O(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--info-bg)] border border-[var(--info-border)]",children:e.jsx("p",{className:"text-sm text-[var(--info-text)]",children:o("groups:hierarchy.info")})}),e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.CornerDownRight,{className:"w-5 h-5"}),o("groups:hierarchy.parentGroup")]}),!x.parentGroupId&&!P&&e.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),o("groups:hierarchy.setParent")]})]}),x.parentGroupId?e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsxs(ie.Link,{to:`/administration/users/groups/${x.parentGroupId}`,className:"flex items-center gap-3 text-sm font-medium text-[var(--color-accent-500)] hover:underline",children:[e.jsx("div",{className:"p-2 rounded-lg bg-[var(--accent-bg)]",children:e.jsx(t.GitBranch,{className:"w-4 h-4 text-[var(--color-accent-500)]"})}),x.parentGroupName||x.parentGroupId]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{j(!0)},className:"flex items-center gap-1 px-2 py-1 text-xs rounded-[var(--radius-button)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(t.Edit3,{className:"w-3 h-3"}),o("common:edit","Modifier")]}),e.jsxs("button",{onClick:f,disabled:R,className:"flex items-center gap-1 px-2 py-1 text-xs rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(t.Unlink,{className:"w-3 h-3"}),o("groups:hierarchy.clearParent")]})]})]}):P?null:e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:o("groups:hierarchy.noParent")}),P&&e.jsxs("div",{className:"mt-4 p-4 rounded-lg border border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",value:T,onChange:i=>L(i.target.value),placeholder:o("groups:hierarchy.searchGroups"),className:"w-full pl-9 pr-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),e.jsx("button",{onClick:()=>{j(!1),L("")},className:"p-2 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"max-h-48 overflow-y-auto space-y-1",children:[v&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(t.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!v&&m.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-4",children:o("groups:hierarchy.noGroupsAvailable")}),!v&&m.length>0&&m.map(i=>e.jsxs("button",{onClick:()=>p(i.id),disabled:R,className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx(t.GitBranch,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:i.name}),i.parentGroupName&&e.jsxs("span",{className:"ml-2 text-xs text-[var(--text-tertiary)]",children:["(",o("groups:hierarchy.childOf")," ",i.parentGroupName,")"]})]})]},i.id))]})]})]}),x.parentGroupId&&e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2 mb-4",children:[e.jsx(t.Users,{className:"w-5 h-5"}),o("groups:hierarchy.inheritedMembers"),!D&&e.jsx("span",{className:"ml-1 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:H.length})]}),e.jsx("div",{className:"p-4 rounded-lg bg-[var(--info-bg)] border border-[var(--info-border)] mb-4",children:e.jsx("p",{className:"text-sm text-[var(--info-text)]",children:o("groups:hierarchy.inheritedMembersInfo")})}),D&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(t.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!D&&H.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-4",children:o("groups:hierarchy.noInheritedMembers")}),!D&&ee.length>0&&e.jsx("div",{className:"space-y-4",children:ee.map(i=>e.jsxs("div",{className:"p-4 rounded-lg border border-dashed border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsxs(ie.Link,{to:`/administration/users/groups/${i.groupId}`,className:"text-sm font-medium text-[var(--color-accent-500)] hover:underline flex items-center gap-1.5",children:[e.jsx(t.GitBranch,{className:"w-4 h-4"}),i.groupName]}),e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:o("groups:hierarchy.level",{level:i.level})})]}),e.jsx("div",{className:"space-y-1",children:i.members.map(A=>e.jsxs(ie.Link,{to:`/administration/users/${A.userId}`,className:"flex items-center gap-3 p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("div",{className:"p-1.5 rounded-full bg-[var(--bg-secondary)]",children:e.jsx(t.Users,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:A.fullName}),e.jsx("span",{className:"ml-2 text-xs text-[var(--text-tertiary)]",children:A.email})]})]},A.userId))})]},i.groupId))})]}),e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.GitBranch,{className:"w-5 h-5"}),o("groups:hierarchy.childGroups"),e.jsx("span",{className:"ml-1 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:x.childGroups?.length||0})]}),!S&&!U&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>q(!0),className:"flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),o("groups:hierarchy.createChild")]}),e.jsxs("button",{onClick:()=>F(!0),className:"flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(t.GitBranch,{className:"w-4 h-4"}),o("groups:hierarchy.addExisting")]})]})]}),S&&e.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",value:X,onChange:i=>Y(i.target.value),placeholder:o("groups:hierarchy.searchGroups"),className:"w-full pl-9 pr-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),e.jsx("button",{onClick:()=>{F(!1),Y("")},className:"p-2 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"max-h-48 overflow-y-auto space-y-1",children:[v&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(t.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!v&&Q.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-4",children:o("groups:hierarchy.noGroupsAvailable")}),!v&&Q.length>0&&Q.map(i=>e.jsxs("button",{onClick:()=>_(i.id),disabled:R,className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx(t.Plus,{className:"w-4 h-4 text-[var(--color-accent-500)] flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:i.name}),i.parentGroupName&&e.jsxs("span",{className:"ml-2 text-xs text-[var(--text-tertiary)]",children:["(",o("groups:hierarchy.childOf")," ",i.parentGroupName,")"]})]})]},i.id))]})]}),U&&e.jsxs("form",{onSubmit:N,className:"mb-4 p-4 rounded-lg border border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--text-primary)]",children:o("groups:hierarchy.createChild")}),e.jsx("button",{type:"button",onClick:()=>{q(!1),C(""),G(""),M(!1)},className:"p-1 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-[var(--text-secondary)] mb-1",children:[o("admin:groups.groupName")," *"]}),e.jsx("input",{type:"text",value:E,onChange:i=>C(i.target.value),placeholder:o("admin:groups.groupNamePlaceholder"),className:"w-full px-3 py-2 text-sm rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",required:!0,autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--text-secondary)] mb-1",children:o("groups:detail.info.description")}),e.jsx("input",{type:"text",value:V,onChange:i=>G(i.target.value),placeholder:o("admin:groups.descriptionPlaceholder"),className:"w-full px-3 py-2 text-sm rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:J,onChange:i=>M(i.target.checked),className:"rounded border-[var(--border-color)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:o("admin:groups.isSecurityGroup")})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:()=>{q(!1),C(""),G(""),M(!1)},className:"px-3 py-1.5 text-sm rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:o("common:cancel","Annuler")}),e.jsxs("button",{type:"submit",disabled:!E.trim()||R,className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[R?e.jsx(t.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(t.Plus,{className:"w-4 h-4"}),o("common:create","Créer")]})]})]})]}),(x.childGroups?.length??0)>0?e.jsx("div",{className:"space-y-2",children:x.childGroups.map(i=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsxs(ie.Link,{to:`/administration/users/groups/${i.id}`,className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-[var(--accent-bg)]",children:e.jsx(t.GitBranch,{className:"w-4 h-4 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:i.name}),!i.isActive&&e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded-[var(--radius-badge)] bg-[var(--warning-bg)] text-[var(--warning-text)]",children:o("common.inactive","Inactive")})]}),e.jsxs("button",{onClick:()=>u(i.id,i.name),disabled:R,className:"flex items-center gap-1 px-2 py-1 text-xs rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(t.Unlink,{className:"w-3 h-3"}),o("groups:hierarchy.removeChild")]})]},i.id))}):!S&&!U?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(t.GitBranch,{className:"w-8 h-8 mx-auto mb-2 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:o("groups:hierarchy.noChildren")}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-2",children:[e.jsxs("button",{onClick:()=>q(!0),className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),o("groups:hierarchy.createChild")]}),e.jsxs("button",{onClick:()=>F(!0),className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(t.GitBranch,{className:"w-4 h-4"}),o("groups:hierarchy.addExisting")]})]})]}):null]})]})}function pt(){const{t:s}=ce.useTranslation(["admin","groups"]),{id:x}=ie.useParams(),l=ie.useNavigate(),{currentTenant:c,hasMultipleTenants:d}=oe.useTenant(),{tenants:o}=Ie.useAdminTenants(),{activeTab:k,setActiveTab:y}=We.useTabNavigation("info",xt),v=r.useRef(new Set(["info"])),{group:h,setGroup:P,roles:j,setRoles:S,rolesLoading:F,setRolesLoading:U,loading:q,setLoading:T,saving:L,setSaving:X,error:Y,setError:R,success:O,setSuccess:E,isEditing:C,setIsEditing:V,formData:G,setFormData:J}=mt(),M=r.useCallback(async(n=!1)=>{if(!(!x||!we(x)))try{n||T(!0);const w=await z.groupsApi.getById(x);P(w),J({name:w.name,description:w.description||""})}catch(w){console.error("Failed to load group:",w),R(s("groups:detail.errors.loadFailed","Erreur lors du chargement du groupe"))}finally{n||T(!1)}},[x,s]),H=r.useCallback(async()=>{try{U(!0);const n=await oe.adminApi.roles.getAssignable();S(Array.isArray(n)?n:[])}catch(n){console.error("Failed to load roles:",n),S([])}finally{U(!1)}},[]);r.useEffect(()=>{x&&we(x)&&M()},[x,M]),r.useEffect(()=>{v.current.has(k)||v.current.add(k),(k==="roles"||k==="permissions")&&j===null&&!F&&H()},[k,j,F]);const se=r.useCallback(async()=>{if(!(!x||!h))try{X(!0),R(null),await z.groupsApi.update(x,{name:G.name,description:G.description||void 0}),await M(),E(s("groups:detail.saveSuccess","Groupe mis à jour avec succès")),V(!1),setTimeout(()=>E(null),3e3)}catch(n){console.error("Failed to save group:",n),R(s("groups:detail.errors.saveFailed","Erreur lors de l'enregistrement"))}finally{X(!1)}},[x,h,G,M,s]),D=r.useCallback(async()=>{if(x)try{await z.groupsApi.activate(x),await M(),E(s("groups:detail.activateSuccess","Groupe activé")),setTimeout(()=>E(null),3e3)}catch(n){console.error("Failed to activate group:",n),R(s("groups:detail.errors.activateFailed","Erreur lors de l'activation"))}},[x,M,s]),B=r.useCallback(async()=>{if(x)try{await z.groupsApi.deactivate(x),await M(),E(s("groups:detail.deactivateSuccess","Groupe désactivé")),setTimeout(()=>E(null),3e3)}catch(n){console.error("Failed to deactivate group:",n),R(s("groups:detail.errors.deactivateFailed","Erreur lors de la désactivation"))}},[x,M,s]),re=r.useCallback(async()=>{if(!x||!h)return;const n=h.isSyncedFromEntra?s("groups:detail.confirmDeleteEntra",{name:h.name,defaultValue:`Le groupe "${h.name}" est synchronisé depuis Entra ID. Il sera recréé lors de la prochaine synchronisation.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),ie=require("react-router-dom"),ce=require("react-i18next"),t=require("lucide-react"),z=require("./groupsApi-hB9kSWEd.js"),oe=require("./index-IgLVXPg8.js"),Re=require("./roleUtils-tv67Lrey.js"),Ie=require("./TenantScopeSelector-D-BKgQPV.js"),de=require("./tenantIconMap-CTMuSt18.js"),pe=require("./PermissionPopover-CtYTz7MK.js"),We=require("./useTabNavigation-BVtbCTd5.js");function ze(s){const x=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const l in s)if(l!=="default"){const c=Object.getOwnPropertyDescriptor(s,l);Object.defineProperty(x,l,c.get?c:{enumerable:!0,get:()=>s[l]})}}return x.default=s,Object.freeze(x)}const _e=ze(t),Ce={Global:{bg:"bg-[var(--accent-bg)]",text:"text-[var(--color-accent-500)]"},Admin:{bg:"bg-[var(--error-bg)]",text:"text-[var(--error-text)]"},Manager:{bg:"bg-[var(--warning-bg)]",text:"text-[var(--warning-text)]"},Contributor:{bg:"bg-[var(--success-bg)]",text:"text-[var(--success-text)]"},Viewer:{bg:"bg-[var(--info-bg)]",text:"text-[var(--info-text)]"},Custom:{bg:"bg-[var(--accent-bg)]",text:"text-[var(--color-accent-700)]"}},Se={bg:"bg-[var(--bg-secondary)]",text:"text-[var(--text-secondary)]"};function Ve({groupId:s,assignedRoles:x=[],onSave:l,roles:c,loading:d=!1,tenantId:o,isGlobalScope:k=!0,adminTenants:y=[]}){const{t:v}=ce.useTranslation(["admin","groups"]),h=Array.isArray(c)?c:[],[P,j]=r.useState(""),[S,F]=r.useState("all"),[U,q]=r.useState(null),[T,L]=r.useState(!1),[X,Y]=r.useState(null),R=r.useRef(!1),[O,E]=r.useState([]);r.useEffect(()=>{let n=!1;return z.groupsApi.getTenants(s).then(w=>{n||E(w.map(m=>({id:m.tenantId,name:m.tenantName})))}).catch(()=>{n||E([])}),()=>{n=!0}},[s]);const[C,V]=r.useState([]),[G,J]=r.useState(!0);r.useEffect(()=>{let n=!1;return J(!0),z.groupsApi.getInheritedRoles(s).then(w=>{n||V(w)}).catch(()=>{n||V([])}).finally(()=>{n||J(!1)}),()=>{n=!0}},[s]);const M=r.useMemo(()=>[...O].sort((n,w)=>n.name.localeCompare(w.name)),[O]),H=r.useMemo(()=>{let n=x;if(S==="global"?n=n.filter(m=>m.isGlobal):S!=="all"&&(n=n.filter(m=>m.isGlobal||m.tenantId===S)),!P.trim())return n;const w=P.toLowerCase().trim();return n.filter(m=>m.roleName.toLowerCase().includes(w)||m.tenantName?.toLowerCase().includes(w))},[x,P,S]),se=r.useMemo(()=>{const n=new Map;for(const w of h)n.set(w.id,w);return n},[h]),D=r.useCallback(async(n,w,m)=>{if(!R.current){R.current=!0,q(n+(w||"global")),Y(null);try{await z.groupsApi.removeRole(s,n,m?void 0:w??void 0),await l([])}catch(I){console.error("Failed to remove role assignment:",I),Y(v("admin:userRoles.errors.removeFailed","Erreur lors du retrait du rôle"))}finally{q(null),R.current=!1}}},[s,l,v]),B=r.useCallback(()=>L(!0),[]),re=r.useCallback(()=>L(!1),[]),ee=r.useCallback(async()=>{await l([])},[l]);return e.jsxs("div",{className:"space-y-4",children:[X&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] flex items-center gap-3",children:[e.jsx(t.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0"}),e.jsx("p",{className:"flex-1 text-[var(--error-text)]",children:X}),e.jsx("button",{onClick:()=>Y(null),className:"ml-auto",children:e.jsx(t.X,{className:"w-4 h-4 text-[var(--error-text)]"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:P,onChange:n=>j(n.target.value),placeholder:v("admin:userRoles.search","Rechercher un rôle..."),className:"w-full pl-10 pr-4 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:S,onChange:n=>F(n.target.value),className:"px-3 py-2 pr-8 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] appearance-none focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:v("admin:userRoles.scopeAll","Tous les tenants")}),e.jsx("option",{value:"global",children:v("admin:roles.global","Global")}),M.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]}),e.jsx(t.ChevronDown,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none text-[var(--text-tertiary)]"})]})]}),e.jsxs("button",{onClick:B,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors text-sm font-medium",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),v("admin:userRoles.assignRole","Assigner un rôle")]})]}),d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}):e.jsxs("div",{className:"overflow-x-auto",children:[e.jsxs("table",{className:"w-full border border-[var(--border-color)] rounded-[var(--radius-card)] overflow-hidden",children:[e.jsx("thead",{className:"bg-[var(--bg-tertiary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.name","Rôle")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.category","Catégorie")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.tenant","Tenant")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)] w-24",children:v("admin:roles.actions","Actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:H.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-[var(--text-muted)]",children:x.length===0?v("admin:userRoles.noAssignedRoles","Aucun rôle assigné à ce groupe"):v("admin:userRoles.noRoles","Aucun rôle trouvé")})}):H.map(n=>{const w=se.get(n.roleId),m=w?.category||"Custom",I=Ce[m]||Se,Q=w?Re.getCustomRoleIcon(w.code):null,p=n.roleId+(n.tenantId||"global"),f=U===p;return e.jsxs("tr",{className:"hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Q&&e.jsx("span",{children:Q}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:n.roleName})]}),n.roleDescription&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 max-w-xs truncate",children:n.roleDescription})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${I.bg} ${I.text}`,children:m})}),e.jsx("td",{className:"px-4 py-3",children:n.isGlobal?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--info-bg)] text-[var(--info-text)]",children:[e.jsx(t.Globe,{className:"w-3 h-3"}),v("admin:roles.global","Global")]}):e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--accent-bg)] text-[var(--color-accent-700)]",children:[e.jsx(t.Building2,{className:"w-3 h-3"}),n.tenantName||v("admin:roles.unknownTenant","Tenant")]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>D(n.roleId,n.tenantId,n.isGlobal),disabled:f,className:"p-1.5 rounded-[var(--radius-button)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors disabled:opacity-50",title:v("admin:userRoles.removeRole","Retirer le rôle"),children:f?e.jsx(t.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(t.Trash2,{className:"w-4 h-4"})})})]},p)})})]}),x.length>0&&e.jsx("div",{className:"px-4 py-2 text-xs text-[var(--text-muted)] bg-[var(--bg-tertiary)] border-t border-[var(--border-color)]",children:H.length!==x.length?v("admin:userRoles.totalFiltered","{{filtered}} / {{count}} rôle(s) affiché(s)",{filtered:H.length,count:x.length}):v("admin:userRoles.totalAssigned","{{count}} rôle(s) assigné(s)",{count:x.length})})]}),T&&e.jsx(Xe,{groupId:s,assignedRoles:x,initialTenantId:o,initialIsGlobalScope:k,adminTenants:y,onAssigned:ee,onClose:re}),G?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(t.Loader2,{className:"w-5 h-5 animate-spin text-[var(--color-accent-500)]"})}):C.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.GitMerge,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)]",children:v("groups:hierarchy.inheritedRoles","Rôles hérités")}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["(",C.length,")"]})]}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:v("groups:hierarchy.inheritedRolesInfo","Ces rôles sont hérités des groupes ancêtres. Ils ne peuvent pas être retirés directement — modifiez le groupe ancêtre pour les gérer.")}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border border-[var(--border-color)] rounded-[var(--radius-card)] overflow-hidden",children:[e.jsx("thead",{className:"bg-[var(--bg-tertiary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.name","Rôle")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("admin:roles.tenant","Tenant")}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-medium text-[var(--text-secondary)]",children:v("groups:hierarchy.inheritedFrom","Hérité de")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:C.map(n=>{const m=se.get(n.roleId)?.category||"Custom",I=Ce[m]||Se;return e.jsxs("tr",{className:"bg-[var(--bg-secondary)] opacity-80",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:n.roleName}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${I.bg} ${I.text}`,children:m})]}),n.roleDescription&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 max-w-xs truncate",children:n.roleDescription})]}),e.jsx("td",{className:"px-4 py-3",children:n.isGlobal?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--info-bg)] text-[var(--info-text)]",children:[e.jsx(t.Globe,{className:"w-3 h-3"}),v("admin:roles.global","Global")]}):e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--accent-bg)] text-[var(--color-accent-700)]",children:[e.jsx(t.Building2,{className:"w-3 h-3"}),n.tenantName||v("admin:roles.unknownTenant","Tenant")]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[e.jsx(t.GitMerge,{className:"w-3 h-3"}),n.inheritedFromGroupName,e.jsxs("span",{className:"text-[var(--text-muted)]",children:["(",v("groups:hierarchy.level","Niveau {{level}}",{level:n.level}),")"]})]})})]},n.roleId+(n.tenantId||"global"))})})]})})]})]})}function Xe({groupId:s,assignedRoles:x,initialTenantId:l,initialIsGlobalScope:c,adminTenants:d,onAssigned:o,onClose:k}){const{t:y}=ce.useTranslation(["admin","groups","common"]),[v,h]=r.useState(""),[P,j]=r.useState("all"),[S,F]=r.useState("all"),[U,q]=r.useState(null),[T,L]=r.useState(null),X=r.useRef(!1),[Y,R]=r.useState([]),[O,E]=r.useState(!0);r.useEffect(()=>{let p=!1;return E(!0),oe.adminApi.roles.getAssignable().then(f=>{p||R(Array.isArray(f)?f:[])}).catch(()=>{p||R([])}).finally(()=>{p||E(!1)}),()=>{p=!0}},[]);const[C,V]=r.useState(null);r.useEffect(()=>{let p=!1;return z.groupsApi.getTenants(s).then(f=>{p||V(new Set(f.map(_=>_.tenantId)))}).catch(()=>{p||V(null)}),()=>{p=!0}},[s]);const[G,J]=r.useState([]);r.useEffect(()=>{if(!C||C.size===0){J([]);return}let p=!1;const f=Array.from(C);return Promise.all(f.map(_=>oe.adminApi.tenants.getApplications(_))).then(_=>{if(p)return;const u=new Map;for(const N of _)for(const i of N)u.has(i.applicationId)||u.set(i.applicationId,i.label);J(Array.from(u.entries()).map(([N,i])=>({id:N,name:i})).sort((N,i)=>N.name.localeCompare(i.name)))}).catch(()=>{p||J([])}),()=>{p=!0}},[C]);const M=r.useMemo(()=>C?d.filter(p=>C.has(p.tenantId)):d,[d,C]),[H,se]=r.useState(()=>{if(c||!l)return"global";const p=d.find(f=>f.tenantId===l);return p?{tenantId:p.tenantId,tenantSlug:p.tenantSlug,tenantUserId:"",tenantName:p.tenantName}:"global"}),D=H==="global",B=D?void 0:H.tenantId,re=r.useMemo(()=>{const p=new Set;for(const f of x)(D&&f.isGlobal||!D&&f.tenantId===B)&&p.add(f.roleId);return p},[x,D,B]),[ee,n]=r.useState(null);r.useEffect(()=>{if(D||!B){n(null);return}let p=!1;return oe.adminApi.tenants.getApplications(B).then(f=>{p||n(new Set(f.map(_=>_.applicationId)))}).catch(()=>{p||n(null)}),()=>{p=!0}},[D,B]);const w=r.useMemo(()=>D||!ee?Y:Y.filter(p=>!p.applicationId||ee.has(p.applicationId)),[Y,D,ee]),m=r.useMemo(()=>{const p=new Set(w.map(f=>f.category||"Custom"));return["all",...Array.from(p).sort((f,_)=>f.localeCompare(_))]},[w]),I=r.useMemo(()=>{let p=w;if(S!=="all"&&(p=p.filter(f=>f.applicationId===S)),P!=="all"&&(p=p.filter(f=>(f.category||"Custom")===P)),v.trim()){const f=v.toLowerCase().trim();p=p.filter(_=>_.name.toLowerCase().includes(f)||_.shortName?.toLowerCase().includes(f)||_.description?.toLowerCase().includes(f))}return p},[w,S,P,v]),Q=r.useCallback(async p=>{if(!X.current){X.current=!0,q(p),L(null);try{await z.groupsApi.assignRole(s,{roleId:p,isInheritable:!0,tenantId:!D&&B?B:void 0}),await o()}catch(f){console.error("Failed to assign role:",f),L(y("admin:userRoles.errors.assignFailed","Erreur lors de l'assignation du rôle"))}finally{q(null),X.current=!1}}},[s,D,B,o,y]);return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"relative w-full max-w-2xl h-[80vh] bg-[var(--bg-card)] rounded-[var(--radius-card)] shadow-2xl border border-[var(--border-color)] overflow-hidden flex flex-col animate-in fade-in zoom-in duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{children:e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:y("admin:userRoles.assignRole","Assigner un rôle")})}),e.jsx(Ie.TenantScopeSelector,{value:H,onChange:se,adminTenants:M})]}),e.jsx("button",{onClick:k,className:"p-1.5 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-5 h-5"})})]}),T&&e.jsxs("div",{className:"mx-6 mt-3 p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] flex items-center gap-3",children:[e.jsx(t.AlertCircle,{className:"w-4 h-4 text-[var(--error-text)] flex-shrink-0"}),e.jsx("p",{className:"flex-1 text-sm text-[var(--error-text)]",children:T}),e.jsx("button",{onClick:()=>L(null),children:e.jsx(t.X,{className:"w-3.5 h-3.5 text-[var(--error-text)]"})})]}),e.jsxs("div",{className:"px-6 py-3 border-b border-[var(--border-color)] flex flex-col gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:v,onChange:p=>h(p.target.value),placeholder:y("admin:userRoles.search","Rechercher un rôle..."),className:"w-full pl-10 pr-4 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Filter,{className:"w-4 h-4 text-[var(--text-secondary)] shrink-0"}),e.jsxs("select",{value:S,onChange:p=>F(p.target.value),className:"flex-1 min-w-0 px-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:y("admin:userRoles.filterByApplication","Toutes les applications")}),G.map(p=>e.jsx("option",{value:p.id,children:p.name},p.id))]}),e.jsxs("select",{value:P,onChange:p=>j(p.target.value),className:"flex-1 min-w-0 px-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:y("admin:userRoles.filterByCategory","Toutes les catégories")}),m.filter(p=>p!=="all").map(p=>e.jsx("option",{value:p,children:p},p))]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:O?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}):e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[var(--bg-tertiary)] sticky top-0 z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-6 py-2.5 text-sm font-medium text-[var(--text-secondary)]",children:y("admin:roles.name","Rôle")}),e.jsx("th",{className:"text-left px-4 py-2.5 text-sm font-medium text-[var(--text-secondary)]",children:y("admin:roles.category","Catégorie")}),e.jsx("th",{className:"text-right px-6 py-2.5 text-sm font-medium text-[var(--text-secondary)] w-32",children:y("admin:roles.actions","Actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:I.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:"px-6 py-12 text-center",children:[e.jsx(t.Search,{className:"w-8 h-8 mx-auto mb-2 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-muted)]",children:y("admin:userRoles.noRoles","Aucun rôle trouvé")})]})}):I.map(p=>{const f=re.has(p.id),_=Ce[p.category||"Custom"]||Se,u=Re.getCustomRoleIcon(p.code),N=U===p.id;return e.jsxs("tr",{className:`transition-colors ${f?"bg-[var(--accent-bg)] opacity-60":"hover:bg-[var(--bg-hover)]"}`,children:[e.jsx("td",{className:"px-6 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[u&&e.jsx("span",{children:u}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:p.name}),p.description&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 max-w-sm truncate",children:p.description})]})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${_.bg} ${_.text}`,children:p.category||"Custom"})}),e.jsx("td",{className:"px-6 py-3 text-right",children:f?e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:y("admin:userRoles.alreadyAssigned","Déjà assigné")}):e.jsxs("button",{onClick:()=>Q(p.id),disabled:N,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white text-xs font-medium hover:bg-[var(--color-accent-700)] transition-colors disabled:opacity-50",children:[N?e.jsx(t.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(t.Plus,{className:"w-3.5 h-3.5"}),y("admin:userRoles.assign","Assigner")]})})]},p.id)})})]})}),e.jsx("div",{className:"px-6 py-3 border-t border-[var(--border-color)] bg-[var(--bg-tertiary)] flex justify-end",children:e.jsx("button",{onClick:k,className:"px-4 py-2 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors text-sm font-medium",children:y("common:close","Fermer")})})]})})}const Qe=s=>s?"bg-[var(--color-accent-600)] border-[var(--color-accent-600)]":"border-[var(--border-color)]",He=s=>s?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]/5":"border-[var(--border-color)] hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-hover)]",Ke=s=>s?"bg-[var(--color-accent-600)] border-[var(--color-accent-600)]":"border-[var(--border-color)]",Ye=(s,x,l)=>{if(!s)return[];const c=l.toLowerCase().trim();return s.filter(d=>!x.has(d.id)).filter(d=>c?d.name.toLowerCase().includes(c)||d.slug.toLowerCase().includes(c)||d.type.toLowerCase().includes(c):!0)},Je=(s,x)=>{if(!s)return[];if(!x.trim())return s;const l=x.toLowerCase().trim();return s.filter(c=>c.tenantName.toLowerCase().includes(l)||c.tenantSlug.toLowerCase().includes(l)||c.tenantType.toLowerCase().includes(l))};function Ze({groupId:s,groupName:x}){const{t:l}=ce.useTranslation(["admin","groups"]),c=ie.useNavigate(),{getIconForType:d}=de.useTenantTypeSettings(),[o,k]=r.useState(null),[y,v]=r.useState([]),[h,P]=r.useState(null),[j,S]=r.useState(!0),[F,U]=r.useState(!1),[q,T]=r.useState(""),[L,X]=r.useState(null),[Y,R]=r.useState(null),[O,E]=r.useState(null),[C,V]=r.useState([]),[G,J]=r.useState(""),[M,H]=r.useState("cards"),[se,D]=r.useState(!1),B=r.useCallback(async()=>{try{S(!0);const[u,N]=await Promise.all([z.groupsApi.getTenants(s),z.groupsApi.getInheritedTenants(s)]);k(u),v(N)}catch(u){console.error("Failed to load group tenants:",u),R(l("groups:tenants.loadError","Erreur lors du chargement des tenants"))}finally{S(!1)}},[s,l]),re=async()=>{try{const u=await oe.adminApi.tenants.getAll();P(u.items)}catch(u){console.error("Failed to load all tenants:",u)}};r.useEffect(()=>{B(),re()},[B]);const ee=async u=>{const N=o?.find(i=>i.tenantId===u);if(confirm(l("groups:tenants.confirmRemove",`Êtes-vous sûr de vouloir retirer le groupe "${x}" du tenant "${N?.tenantName}" ?`)))try{X(u),R(null),await z.groupsApi.removeFromTenant(s,u),await B(),E(l("groups:tenants.removeSuccess","Tenant retiré avec succès")),setTimeout(()=>E(null),3e3)}catch(i){console.error("Failed to remove tenant:",i);const A=i?.response?.data?.message||l("groups:tenants.removeError","Erreur lors du retrait du tenant");R(A)}finally{X(null)}},n=async()=>{let u=0;const N=[];for(const i of C)try{await z.groupsApi.addToTenant(s,{tenantId:i}),u++}catch{const A=f?.find(K=>K.id===i)?.name;N.push(A||i)}return{successCount:u,failedTenants:N}},w=async()=>{if(C.length!==0)try{D(!0),R(null);const{successCount:u,failedTenants:N}=await n();await B(),U(!1),T(""),V([]),N.length===0?(E(l("groups:tenants.addSelectedSuccess",{count:u})),setTimeout(()=>E(null),3e3)):u>0?R(l("groups:tenants.addPartialError",{success:u,failed:N.join(", ")})):R(l("groups:tenants.addSelectedError","Erreur lors de l'ajout des tenants"))}catch(u){console.error("Failed to add tenants:",u),R(l("groups:tenants.addSelectedError","Erreur lors de l'ajout des tenants"))}finally{D(!1)}},m=u=>{V(N=>N.includes(u)?N.filter(i=>i!==u):[...N,u])},I=()=>{if(!f)return;const u=f.map(i=>i.id),N=u.every(i=>C.includes(i));V(N?[]:u)},Q=r.useMemo(()=>new Set(o?.map(u=>u.tenantId)??[]),[o]),f=r.useMemo(()=>Ye(h,Q,q),[h,Q,q]),_=r.useMemo(()=>Je(o,G),[o,G]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.Building2,{className:"w-5 h-5"}),l("groups:tenants.title","Tenants du groupe"),o&&e.jsx("span",{className:"ml-2 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:o.length})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>U(!0),className:"flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),l("groups:tenants.add","Ajouter")]}),e.jsx("button",{onClick:B,className:"flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.RefreshCw,{className:"w-4 h-4"})})]})]}),(o?.length??0)>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",placeholder:l("groups:tenants.searchPlaceholderPage","Rechercher un tenant..."),value:G,onChange:u=>J(u.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:[e.jsxs("button",{onClick:()=>H("cards"),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${M==="cards"?"bg-[var(--color-accent-600)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(t.LayoutGrid,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:l("groups:tenants.viewCards","Cartes")})]}),e.jsxs("button",{onClick:()=>H("table"),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${M==="table"?"bg-[var(--color-accent-600)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(t.LayoutList,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:l("groups:tenants.viewTable","Table")})]})]})]})]}),Y&&e.jsxs("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/20 flex items-center gap-3",children:[e.jsx(t.AlertTriangle,{className:"w-5 h-5 text-red-500 flex-shrink-0"}),e.jsx("p",{className:"text-red-500",children:Y}),e.jsx("button",{onClick:()=>R(null),className:"ml-auto",children:e.jsx(t.X,{className:"w-4 h-4 text-red-500"})})]}),O&&e.jsxs("div",{className:"p-4 rounded-lg bg-green-500/10 border border-green-500/20 flex items-center gap-3",children:[e.jsx(t.CheckCircle,{className:"w-5 h-5 text-green-500 flex-shrink-0"}),e.jsx("p",{className:"text-green-500",children:O})]}),e.jsx("div",{className:"p-4 rounded-lg bg-blue-500/10 border border-blue-500/20",children:e.jsx("p",{className:"text-sm text-blue-500",children:l("groups:tenants.info","Les utilisateurs de ce groupe auront automatiquement accès aux tenants listés ci-dessous via leur appartenance au groupe.")})}),j&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}),!j&&(!o||o.length===0)&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(t.Building2,{className:"w-12 h-12 mx-auto mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:l("groups:tenants.noTenants","Ce groupe n'est associé à aucun tenant")}),e.jsxs("button",{onClick:()=>U(!0),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),l("groups:tenants.addFirst","Ajouter un premier tenant")]})]}),!j&&(o?.length??0)>0&&(_?.length??0)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(t.Search,{className:"w-12 h-12 mx-auto mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:l("groups:tenants.noResults","Aucun tenant ne correspond à votre recherche")})]}),!j&&(_?.length??0)>0&&M==="cards"&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:_?.map(u=>e.jsx("div",{role:"button",tabIndex:0,onClick:()=>c(`/administration/tenants/${u.tenantId}`),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),c(`/administration/tenants/${u.tenantId}`))},className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] transition-colors cursor-pointer text-left",children:(()=>{const N=d(u.tenantType),i=de.getLucideIcon(N.icon),A=de.getColorClasses(N.color);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:`p-2 rounded-lg ${A.bg}`,children:e.jsx(i,{className:`w-5 h-5 ${A.text}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--color-accent-500)] hover:underline truncate",children:u.tenantName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:u.tenantSlug})]})]}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${A.bg} ${A.text}`,children:u.tenantType})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-color)] space-y-1",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[l("groups:tenants.addedAt","Ajouté le"),": ",new Date(u.addedAt).toLocaleDateString()]}),u.addedBy&&e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[l("groups:tenants.addedBy","Par"),": ",u.addedBy]})]}),e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsxs("button",{onClick:K=>{K.stopPropagation(),ee(u.tenantId)},disabled:L===u.tenantId,className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",children:[L===u.tenantId?e.jsx(t.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(t.Trash2,{className:"w-3 h-3"}),l("common.remove","Retirer")]})})]})})()},u.tenantId))}),!j&&(_?.length??0)>0&&M!=="cards"&&e.jsx("div",{className:"rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:l("groups:tenants.tableHeaders.name","Nom")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:l("groups:tenants.tableHeaders.slug","Slug")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:l("groups:tenants.tableHeaders.type","Type")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:l("groups:tenants.tableHeaders.addedAt","Ajouté le")}),e.jsx("th",{className:"w-24 px-4 py-3"})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:_?.map(u=>e.jsxs("tr",{onClick:()=>c(`/administration/tenants/${u.tenantId}`),className:"hover:bg-[var(--bg-hover)] transition-colors cursor-pointer",children:[(()=>{const N=d(u.tenantType),i=de.getLucideIcon(N.icon),A=de.getColorClasses(N.color);return e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-1.5 rounded-lg ${A.bg}`,children:e.jsx(i,{className:`w-4 h-4 ${A.text}`})}),e.jsx("span",{className:"text-sm font-medium text-[var(--color-accent-500)] hover:underline",children:u.tenantName})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)] hidden md:table-cell",children:u.tenantSlug}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${A.bg} ${A.text}`,children:u.tenantType})})]})})(),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-tertiary)] hidden lg:table-cell",children:new Date(u.addedAt).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("button",{onClick:N=>{N.stopPropagation(),ee(u.tenantId)},disabled:L===u.tenantId,className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",children:[L===u.tenantId?e.jsx(t.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(t.Trash2,{className:"w-3 h-3"}),l("common.remove","Retirer")]})})]},u.tenantId))})]})}),!j&&y.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.GitBranch,{className:"w-5 h-5"}),l("groups:tenants.inheritedTitle"),e.jsx("span",{className:"ml-1 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:y.length})]}),e.jsx("div",{className:"p-4 rounded-lg bg-[var(--info-bg)] border border-[var(--info-border)]",children:e.jsx("p",{className:"text-sm text-[var(--info-text)]",children:l("groups:tenants.inheritedInfo")})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:y.map(u=>e.jsx("button",{type:"button",onClick:()=>c(`/administration/tenants/${u.tenantId}`),className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-dashed border-[var(--border-color)] hover:border-[var(--color-accent-500)] transition-colors cursor-pointer text-left",children:(()=>{const N=d(u.tenantType),i=de.getLucideIcon(N.icon),A=de.getColorClasses(N.color);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:`p-2 rounded-lg ${A.bg}`,children:e.jsx(i,{className:`w-5 h-5 ${A.text}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--color-accent-500)] hover:underline truncate",children:u.tenantName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:u.tenantSlug})]})]}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${A.bg} ${A.text}`,children:u.tenantType})]}),e.jsx("div",{className:"mt-3 pt-3 border-t border-[var(--border-color)]",children:e.jsxs(ie.Link,{to:`/administration/users/groups/${u.inheritedFromGroupId}`,onClick:K=>K.stopPropagation(),className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] hover:text-[var(--color-accent-500)] transition-colors",children:[e.jsx(t.Link,{className:"w-3 h-3"}),l("groups:tenants.inheritedFrom")," ",e.jsx("span",{className:"font-medium",children:u.inheritedFromGroupName})]})})]})})()},`inherited-${u.tenantId}-${u.inheritedFromGroupId}`))})]}),F&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"w-full max-w-lg mx-4 bg-[var(--bg-primary)] rounded-[var(--radius-card)] shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:l("groups:tenants.addModalTitle","Ajouter le groupe à des tenants")}),e.jsx("button",{onClick:()=>{U(!1),T(""),V([])},className:"p-1 rounded hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-5 h-5 text-[var(--text-secondary)]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",placeholder:l("groups:tenants.searchPlaceholder","Rechercher un tenant..."),value:q,onChange:u=>T(u.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),(f?.length??0)>0&&e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsxs("button",{onClick:I,className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:[e.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${Qe(f.every(u=>C.includes(u.id)))}`,children:f.every(u=>C.includes(u.id))&&e.jsx(t.Check,{className:"w-3 h-3 text-white"})}),f.every(u=>C.includes(u.id))?l("groups:tenants.deselectAll","Tout désélectionner"):l("groups:tenants.selectAll","Tout sélectionner")]}),C.length>0&&e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[C.length," ",l("common.selected","sélectionné(s)")]})]}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:!f||f.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(t.Building2,{className:"w-8 h-8 mx-auto mb-2 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:l("groups:tenants.noAvailableTenants","Aucun tenant disponible")})]}):f.map(u=>{const N=C.includes(u.id),i=d(u.type),A=de.getLucideIcon(i.icon),K=de.getColorClasses(i.color);return e.jsxs("button",{type:"button",onClick:()=>m(u.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors text-left ${He(N)}`,children:[e.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center flex-shrink-0 transition-colors ${Ke(N)}`,children:N&&e.jsx(t.Check,{className:"w-3 h-3 text-white"})}),e.jsx("div",{className:`p-2 rounded-lg ${K.bg}`,children:e.jsx(A,{className:`w-4 h-4 ${K.text}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:u.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:u.slug})]}),e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${K.bg} ${K.text}`,children:u.type})]},u.id)})})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-[var(--border-color)]",children:[e.jsx("button",{onClick:()=>{U(!1),T(""),V([])},className:"px-4 py-2 rounded-lg bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:l("common.cancel","Annuler")}),e.jsxs("button",{onClick:w,disabled:C.length===0||se,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[se?e.jsx(t.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(t.Plus,{className:"w-4 h-4"}),l("groups:tenants.addSelected",{count:C.length})]})]})]})})]})}function et({groupId:s,groupName:x,isSyncedFromEntra:l}){const{t:c}=ce.useTranslation(["admin","groups"]),d=ie.useNavigate(),[o,k]=r.useState(null),[y,v]=r.useState(null),[h,P]=r.useState(!0),[j,S]=r.useState(!1),[F,U]=r.useState(""),[q,T]=r.useState(null),[L,X]=r.useState(null),[Y,R]=r.useState(null),[O,E]=r.useState("table"),[C,V]=r.useState(new Set),[G,J]=r.useState(!1),M=r.useCallback(async()=>{try{P(!0);const m=await z.groupsApi.getMembers(s);k(m)}catch(m){console.error("Failed to load group members:",m),X(c("groups:members.loadError","Erreur lors du chargement des membres"))}finally{P(!1)}},[s,c]),H=async()=>{try{const m=await oe.adminApi.users.getAll({isActive:!0,globalScope:!0}),I=Array.isArray(m)?m:m.items;v(I)}catch(m){console.error("Failed to load all users:",m)}};r.useEffect(()=>{M(),H()},[M]);const se=async()=>{if(C.size!==0)try{J(!0),X(null);const m=Array.from(C);for(const I of m)await z.groupsApi.addMember(s,{userId:I});await M(),S(!1),U(""),V(new Set),R(c("groups:members.addMultipleSuccess",{count:m.length})),setTimeout(()=>R(null),3e3)}catch(m){console.error("Failed to add members:",m);const I=m?.response?.data?.message||c("groups:members.addError","Erreur lors de l'ajout des membres");X(I)}finally{J(!1)}},D=m=>{V(I=>{const Q=new Set(I);return Q.has(m)?Q.delete(m):Q.add(m),Q})},B=async m=>{const I=o?.find(Q=>Q.userId===m);if(confirm(c("groups:members.confirmRemove",{userName:I?.fullName,groupName:x})))try{T(m),X(null),await z.groupsApi.removeMember(s,m),await M(),R(c("groups:members.removeSuccess","Membre retiré avec succès")),setTimeout(()=>R(null),3e3)}catch(Q){console.error("Failed to remove member:",Q);const p=Q?.response?.data?.message||c("groups:members.removeError","Erreur lors du retrait du membre");X(p)}finally{T(null)}},ee=y?.filter(m=>!o?.some(I=>I.userId===m.id))?.filter(m=>{if(!F.trim())return!0;const I=F.toLowerCase().trim();return m.fullName.toLowerCase().includes(I)||m.email.toLowerCase().includes(I)}),n=m=>m.split(" ").map(I=>I.charAt(0)).slice(0,2).join("").toUpperCase(),w=m=>m?"p-2 transition-colors bg-[var(--color-accent-500)] text-white":"p-2 transition-colors bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.Users,{className:"w-5 h-5"}),c("groups:members.title","Membres du groupe"),o&&e.jsx("span",{className:"ml-2 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:o.length})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center rounded-lg border border-[var(--border-color)] overflow-hidden",children:[e.jsx("button",{onClick:()=>E("table"),className:w(O==="table"),title:c("common.tableView","Vue tableau"),children:e.jsx(t.Table,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>E("card"),className:w(O==="card"),title:c("common.cardView","Vue cartes"),children:e.jsx(t.LayoutGrid,{className:"w-4 h-4"})})]}),!l&&e.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),c("groups:members.add","Ajouter des membres")]}),e.jsxs("button",{onClick:M,className:"flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--bg-primary)] border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(t.RefreshCw,{className:"w-4 h-4"}),c("common.refresh","Actualiser")]})]})]}),L&&e.jsxs("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/20 flex items-center gap-3",children:[e.jsx(t.AlertTriangle,{className:"w-5 h-5 text-red-500 flex-shrink-0"}),e.jsx("p",{className:"text-red-500",children:L}),e.jsx("button",{onClick:()=>X(null),className:"ml-auto",children:e.jsx(t.X,{className:"w-4 h-4 text-red-500"})})]}),Y&&e.jsxs("div",{className:"p-4 rounded-lg bg-green-500/10 border border-green-500/20 flex items-center gap-3",children:[e.jsx(t.CheckCircle,{className:"w-5 h-5 text-green-500 flex-shrink-0"}),e.jsx("p",{className:"text-green-500",children:Y})]}),e.jsx("div",{className:"p-4 rounded-lg bg-blue-500/10 border border-blue-500/20",children:e.jsx("p",{className:"text-sm text-blue-500",children:c("groups:members.info","Les membres de ce groupe héritent automatiquement des rôles et permissions attribués au groupe.")})}),l&&e.jsxs("div",{className:"p-4 rounded-lg bg-amber-500/10 border border-amber-500/20 flex items-start gap-3",children:[e.jsx(t.Info,{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-amber-500",children:c("groups:members.readOnlyEntra","Les membres de ce groupe sont synchronisés depuis Microsoft Entra ID et ne peuvent pas être modifiés ici.")})]}),h&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-accent-500)]"})}),!h&&(!o||o.length===0)&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(t.Users,{className:"w-12 h-12 mx-auto mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:c("groups:members.noMembers","Ce groupe n'a aucun membre")}),!l&&e.jsxs("button",{onClick:()=>S(!0),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),c("groups:members.addFirst","Ajouter un premier membre")]})]}),!h&&(o?.length??0)>0&&O==="table"&&e.jsx("div",{className:"overflow-x-auto rounded-[var(--radius-card)] border border-[var(--border-color)]",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("groups:members.table.member","Membre")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("groups:members.table.email","Email")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("groups:members.table.addedAt","Ajouté le")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("groups:members.table.addedBy","Par")}),!l&&e.jsx("th",{className:"px-4 py-3 text-right text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider",children:c("common.actions","Actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border-color)]",children:o?.map(m=>e.jsxs("tr",{className:"bg-[var(--bg-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("button",{className:"flex items-center gap-3 cursor-pointer text-left bg-transparent border-0 p-0 hover:opacity-80 transition-opacity",onClick:()=>d(`/administration/users/${m.userId}`),children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)]/10 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-xs font-medium text-[var(--color-accent-500)]",children:n(m.fullName)})}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)] hover:text-[var(--color-accent-500)]",children:m.fullName})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)]",children:m.email}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)]",children:new Date(m.addedAt).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3 text-sm text-[var(--text-secondary)]",children:m.addedBy||"-"}),!l&&e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs("button",{onClick:()=>B(m.userId),disabled:q===m.userId,className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",children:[q===m.userId?e.jsx(t.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(t.Trash2,{className:"w-3 h-3"}),c("common.remove","Retirer")]})})]},m.userId))})]})}),!h&&(o?.length??0)>0&&O!=="table"&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:o?.map(m=>e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] transition-colors",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("button",{className:"flex items-start gap-3 min-w-0 cursor-pointer text-left bg-transparent border-0 p-0 hover:opacity-80 transition-opacity",onClick:()=>d(`/administration/users/${m.userId}`),children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-500)]/10 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-sm font-medium text-[var(--color-accent-500)]",children:n(m.fullName)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--text-primary)] truncate",children:m.fullName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:m.email})]})]})}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-[var(--border-color)] space-y-1",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[c("groups:members.addedAt","Ajouté le"),": ",new Date(m.addedAt).toLocaleDateString()]}),m.addedBy&&e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[c("groups:members.addedBy","Par"),": ",m.addedBy]})]}),!l&&e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsxs("button",{onClick:()=>B(m.userId),disabled:q===m.userId,className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",children:[q===m.userId?e.jsx(t.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(t.Trash2,{className:"w-3 h-3"}),c("common.remove","Retirer")]})})]},m.userId))}),j&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"w-full max-w-lg mx-4 bg-[var(--bg-primary)] rounded-[var(--radius-card)] shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:c("groups:members.addModalTitle","Ajouter des membres au groupe")}),C.size>0&&e.jsx("p",{className:"text-sm text-[var(--color-accent-500)] mt-1",children:c("groups:members.selectedCount",{count:C.size})})]}),e.jsx("button",{onClick:()=>{S(!1),U(""),V(new Set)},className:"p-1 rounded hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-5 h-5 text-[var(--text-secondary)]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",placeholder:c("groups:members.searchPlaceholder","Rechercher un utilisateur..."),value:F,onChange:m=>U(m.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:!ee||ee.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(t.Users,{className:"w-8 h-8 mx-auto mb-2 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:c("groups:members.noAvailableUsers","Aucun utilisateur disponible")})]}):ee.map(m=>{const I=C.has(m.id);return e.jsxs("button",{onClick:()=>D(m.id),disabled:G,className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors text-left disabled:opacity-50 ${I?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]/10":"border-[var(--border-color)] hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center flex-shrink-0 transition-colors ${I?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]":"border-[var(--border-color)]"}`,children:I&&e.jsx(t.Check,{className:"w-3 h-3 text-white"})}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-500)]/10 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-sm font-medium text-[var(--color-accent-500)]",children:n(m.fullName)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:m.fullName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:m.email})]})]},m.id)})})]}),e.jsxs("div",{className:"flex justify-between items-center gap-2 p-4 border-t border-[var(--border-color)]",children:[e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:C.size>0&&e.jsx("button",{onClick:()=>V(new Set),className:"text-[var(--color-accent-500)] hover:underline",children:c("common.clearSelection","Effacer la sélection")})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{S(!1),U(""),V(new Set)},className:"px-4 py-2 rounded-lg bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:c("common.cancel","Annuler")}),e.jsx("button",{onClick:se,disabled:C.size===0||G,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:G?e.jsxs(e.Fragment,{children:[e.jsx(t.Loader2,{className:"w-4 h-4 animate-spin"}),c("common.adding","Ajout...")]}):e.jsxs(e.Fragment,{children:[e.jsx(t.Plus,{className:"w-4 h-4"}),c("groups:members.addSelected",{count:C.size})]})})]})]})]})})]})}function tt(s){const{groupId:x,tenantId:l}=s,c=r.useCallback(async h=>z.groupsApi.getById(h),[]),d=r.useCallback(async(h,P)=>{const[j,S]=await Promise.all([z.groupsApi.getById(h),oe.adminApi.permissions.getMatrix()]),F=new Map(S.roles.map(T=>[T.id,T])),U=j.roles.map(T=>{const L=F.get(T.roleId);return L?{id:T.roleId,name:L.name,shortName:L.shortName||L.name,category:L.category||"Custom",description:L.description??null,tenantId:T.tenantId??null,tenantName:T.tenantName??null,isGlobal:T.isGlobal}:null}).filter(T=>T!==null);return P?U.filter(T=>T.isGlobal||T.tenantId===P):U},[]),o=oe.useEntityPermissions({entityId:x,tenantId:l,loadEntity:c,loadRoles:d}),k=o.entity,y=o.roles,v=r.useCallback(h=>{const P=[];return y.forEach(j=>{const S=o.inheritanceMap[j.id];if(S){const F=S.get(h);F&&(F.isDirect||F.isInherited)&&P.push(j)}}),P},[y,o.inheritanceMap]);return{loading:o.loading,error:o.error,group:k,groupRoles:y,resources:o.resources,assignments:o.assignments,inheritanceMap:o.inheritanceMap,effectivePermissions:o.effectivePermissions,filters:o.filters,filteredResources:o.filteredResources,applications:o.applications,modules:o.modules,updateFilters:o.updateFilters,getPermissionInheritance:o.getPermissionInheritance,getPermissionSources:v,reloadData:o.reloadData,isTenantMode:o.isTenantMode}}function st(s){const x=new Map;return s.forEach(l=>{const c=l.isGlobal?"__global__":l.tenantId||"__unknown__";x.has(c)||x.set(c,{isGlobal:l.isGlobal,displayName:l.tenantName})}),Array.from(x.entries()).map(([l,c])=>({key:l,isGlobal:c.isGlobal,displayName:c.displayName}))}function rt(s,x){const l=[];return s.forEach(c=>{const d=x(c.name)?"Custom":"Direct";l.find(o=>o.type===d)||l.push({type:d})}),l}const at={"*":e.jsx(t.Shield,{className:"h-3.5 w-3.5"}),read:e.jsx(t.Eye,{className:"h-3.5 w-3.5"}),create:e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),update:e.jsx(t.Edit,{className:"h-3.5 w-3.5"}),delete:e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),assign:e.jsx(t.UserPlus,{className:"h-3.5 w-3.5"}),execute:e.jsx(t.Play,{className:"h-3.5 w-3.5"})},nt={"*":"bg-[var(--accent-bg)] text-[var(--accent-text)] border-[var(--accent-border)]",read:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]",create:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",update:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",delete:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",assign:"bg-[var(--accent-bg)] text-[var(--accent-text)] border-[var(--accent-border)]",execute:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]"};function ot({groupId:s,compact:x=!1,tenantId:l,tenantSlug:c}){const{t:d}=ce.useTranslation("admin"),o=ie.useNavigate(),{loading:k,error:y,group:v,groupRoles:h,filteredResources:P,effectivePermissions:j,filters:S,applications:F,modules:U,updateFilters:q,getPermissionSources:T,reloadData:L,isTenantMode:X}=tt({groupId:s,tenantId:l}),{collapsedApps:Y,toggleApp:R}=oe.useCollapsibleState(),[O,E]=r.useState(new Set),[C,V]=r.useState(new Set),[G,J]=r.useState(new Set),[M,H]=r.useState(null),[se,D]=r.useState(null),[B,re]=r.useState(new Set),[ee,n]=r.useState(null),[w,m]=r.useState(!1),[I,Q]=r.useState(null),p=r.useMemo(()=>oe.createAdminApi(c),[c]),f=r.useMemo(()=>z.createGroupsApi(c),[c]);r.useEffect(()=>{(async()=>{try{m(!0);const g=await f.getCustomRole(s);g?(D(g.id),re(new Set((g.permissions??[]).map(b=>b.id)))):(D(null),re(new Set))}catch(g){g instanceof Error&&g.message.includes("404")||console.error("Failed to load custom role:",g),D(null),re(new Set)}finally{m(!1)}})()},[s,f]);const _=async a=>{if(ee===null)try{n(a),Q(null);let g=se,b=new Set(B);g||(g=(await f.createCustomRole(s)).id,D(g),b=new Set);const $=new Set(b);$.has(a)?$.delete(a):$.add(a);const te=await p.roles.getById(g);await p.roles.update(g,{name:te.name,shortName:te.shortName||void 0,category:te.category||void 0,description:te.description||void 0,permissionIds:Array.from($)}),re($),await L()}catch(g){console.error("Failed to toggle permission:",g),Q(d("groupPermissions.toggleError","Erreur lors de la modification de la permission. Veuillez réessayer.")),setTimeout(()=>Q(null),5e3)}finally{n(null)}},u=a=>{H(M===a?null:a)},N=a=>{J(g=>{const b=new Set(g);return b.has(a)?b.delete(a):b.add(a),b})},i=a=>{E(g=>{const b=new Set(g);return b.has(a)?b.delete(a):b.add(a),b})},A=a=>{V(g=>{const b=new Set(g);return b.has(a)?b.delete(a):b.add(a),b})},K=r.useCallback(a=>{const g=[...a.permissions];return a.childSections&&a.childSections.forEach(b=>{g.push(...b.permissions)}),g},[]),he=r.useCallback((a,g=!1)=>{if(g)return pe.calculatePermissionStatus(a,ae=>j.has(ae));const b=K(a),$=b.filter(ae=>j.has(ae.id)).length,te=b.length;let Z;return $===0?Z="none":$===te?Z="all":Z=b.every(le=>!j.has(le.id)||le.action==="read")&&b.some(le=>le.action==="read"&&j.has(le.id))?"read-only":"some",{status:Z,grantedCount:$}},[j,K]),be=a=>a.filter(g=>{const{status:b}=pe.calculateModuleWithSectionsStatus(g.module,g.sections,$=>j.has($));return G.has(b)}),ge=a=>G.size===0?a:a.map(g=>({...g,modules:be(g.modules)})).filter(g=>g.modules.length>0),fe=r.useMemo(()=>{let a=pe.groupByApplicationWithSections(P);return ge(a)},[P,G,j]),Ae=r.useMemo(()=>fe.reduce((a,g)=>a+g.modules.length,0),[fe]),Pe=(a,g)=>{a.find(b=>b.id===g.id&&b.tenantId===g.tenantId)||a.push(g)},Ge=a=>{const g=[];return a.permissions.forEach(b=>{j.has(b.id)&&T(b.id).forEach($=>{Pe(g,$)})}),g},ve=a=>a.startsWith("group_")&&a.endsWith("_custom"),Me=a=>ve(a.name)?d("groupPermissions.customBadge","Custom"):a.shortName||a.name,ke=r.useMemo(()=>v?{id:se||`group_${s}_custom`,name:v.name,shortName:v.name,category:"Custom",description:null,isSystem:!1,permissions:[],permissionIds:[]}:null,[v,se,s]),Fe=r.useCallback((a,g)=>{const b=j.has(g),$=B.has(g),te=b?T(g):[],Z=te.find(ae=>!ve(ae.name));return{isDirect:$,isInherited:b&&!$&&te.length>0,inheritedFromPath:Z?Z.name:void 0,inheritedFromId:Z?.id}},[j,B,T]);if(k)return e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(t.Loader2,{className:"h-8 w-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"ml-3 text-[var(--text-secondary)]",children:d("groupPermissions.loading","Chargement des permissions...")})]});if(y)return e.jsx("div",{className:"rounded-[var(--radius-card)] bg-[var(--error-bg)] p-4 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(t.AlertCircle,{className:"h-5 w-5 text-[var(--error-text)]"}),e.jsx("p",{className:"ml-2 text-sm text-[var(--error-text)]",children:y})]})});if(!v)return e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(t.Shield,{className:"h-12 w-12 mx-auto mb-4 text-[var(--text-muted)]"}),e.jsx("p",{children:d("groupPermissions.noGroup","Groupe non trouvé")})]});const Le=a=>a==="resource"?"pl-28":a==="section"?"pl-22":"pl-16",$e=a=>a==="resource"?e.jsx(t.Database,{className:"h-3.5 w-3.5 text-[var(--text-muted)]"}):a==="section"?e.jsx(t.FileText,{className:"h-3.5 w-3.5 text-[var(--text-muted)]"}):e.jsx(t.Box,{className:"h-3.5 w-3.5 text-[var(--text-secondary)]"}),Ee=a=>a==="resource"?"text-[var(--text-muted)] italic":a==="section"?"text-[var(--text-secondary)]":"font-medium text-[var(--text-primary)]",De=(a,g)=>a.map((b,$)=>ye(b,g+$,"resource",!1,!1)),Be=(a,g,b)=>{const{section:$,resources:te}=a,Z=te.length>0,ae=C.has($.id);return e.jsxs(r.Fragment,{children:[ye($,g+b+1,"section",Z,ae),Z&&!ae&&De(te,g+b+2)]},$.id)},Ue=(a,g,b,$)=>!b||$?null:a.map((te,Z)=>Be(te,g,Z)),ye=(a,g,b,$=!1,te=!1)=>{const Z=b==="section",{status:ae,grantedCount:le}=he(a,Z),xe=Z?a.permissions.length:K(a).length,qe=pe.getPermissionCellBackground(ae),me=Ge(a),Te=M===a.id,Oe=Le(b);return e.jsxs("tr",{className:`hover:bg-[var(--bg-hover)] ${g%2===0?"item-light":"item-medium"}`,children:[e.jsx("td",{className:`sticky left-0 z-10 ${g%2===0?"item-light":"item-medium"} px-3 py-2 ${Oe}`,style:{width:"280px",minWidth:"280px",maxWidth:"280px"},children:e.jsxs("div",{className:"flex items-center gap-2",children:[$&&e.jsx("button",{onClick:()=>b==="module"?i(a.id):A(a.id),className:"p-0.5 hover:bg-[var(--bg-hover)] rounded",children:te?e.jsx(t.ChevronRight,{className:"h-3 w-3 text-[var(--text-muted)]"}):e.jsx(t.ChevronDown,{className:"h-3 w-3 text-[var(--text-muted)]"})}),$e(b),e.jsx("span",{className:`text-sm ${Ee(b)}`,children:a.label}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["(",xe,")"]})]})}),e.jsxs("td",{className:`px-0 py-1 text-center relative ${qe}`,style:{width:"60px",minWidth:"60px",maxWidth:"60px"},children:[e.jsx("button",{type:"button",onClick:()=>u(a.id),className:`w-full h-full min-h-[36px] flex items-center justify-center rounded transition-colors hover:opacity-80 ${Te?"ring-2 ring-[var(--color-accent-500)]":""}`,title:`${a.label}: ${le}/${xe}`,children:e.jsx(pe.PermissionStatusIndicator,{status:ae,grantedCount:le,totalCount:xe})}),Te&&v&&ke&&e.jsx(pe.PermissionPopover,{mode:"editable",role:ke,resource:a,onClose:()=>H(null),onTogglePermission:_,getPermissionInheritance:Fe})]}),e.jsx("td",{className:"px-3 py-2",style:{width:"140px",minWidth:"140px"},children:e.jsx("div",{className:"flex flex-wrap gap-1",children:me.length>0?me.map(W=>{const ne=ve(W.name),ue=Me(W),je=W.isGlobal?e.jsx(t.Globe,{className:"h-2.5 w-2.5 text-[var(--info-text)]"}):e.jsx(t.Building2,{className:"h-2.5 w-2.5 text-[var(--warning-text)]"}),Ne=W.isGlobal?d("groupPermissions.globalScope","Global"):W.tenantName||d("groupPermissions.tenantScope","Tenant");return e.jsxs("button",{onClick:()=>!ne&&o(`/administration/permissions/roles/${W.id}`),className:`inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-full transition-all ${ne?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)] border border-[var(--color-accent-300)] dark:border-[var(--color-accent-700)] cursor-default":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)] cursor-pointer hover:ring-1 hover:ring-[var(--color-accent-500)] hover:shadow-sm"}`,title:`${ne?d("groupPermissions.customRoleTooltip","Rôle personnalisé"):d("groupPermissions.clickToViewRole","Cliquer pour voir le rôle")} (${Ne})`,children:[je,ue,ne&&e.jsx(t.Star,{className:"h-3 w-3"})]},`${W.id}-${W.tenantId||"global"}`)}):e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"-"})})}),e.jsx("td",{className:"px-3 py-2",style:{width:"120px",minWidth:"120px"},children:e.jsx("div",{className:"flex flex-wrap gap-1",children:me.length>0?st(me).map(({key:W,isGlobal:ne,displayName:ue})=>e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 text-xs rounded-full ${ne?"bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]"}`,children:ne?d("groupPermissions.globalScope","Global"):ue||d("groupPermissions.tenantScope","Tenant")},W)):e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"-"})})}),e.jsx("td",{className:"px-3 py-2",style:{width:"100px",minWidth:"100px"},children:e.jsx("div",{className:"flex flex-wrap gap-1",children:me.length>0?rt(me,ve).map((W,ne)=>e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-full ${W.type==="Direct"?"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]":"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)] border border-[var(--color-accent-300)] dark:border-[var(--color-accent-700)]"}`,title:W.type==="Custom"?d("groupPermissions.customPermissions","Permissions personnalisées"):d("groupPermissions.directAssignmentTooltip","Rôle assigné directement au groupe"),children:[W.type==="Direct"&&e.jsx(t.UserCheck,{className:"h-3 w-3"}),W.type==="Custom"&&e.jsx(t.User,{className:"h-3 w-3"}),W.type==="Direct"?d("groupPermissions.directAssignment","Direct"):d("groupPermissions.customSource","Custom")]},`source-${W.type}-${ne}`)):e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"-"})})}),e.jsx("td",{className:"px-3 py-2",style:{minWidth:"200px"},children:e.jsx("div",{className:"flex flex-wrap gap-1.5 items-center relative",children:a.permissions.filter(W=>j.has(W.id)).map(W=>{const ne=B.has(W.id),ue=ee===W.id,je=nt[W.action]||"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]",Ne=at[W.action]||e.jsx(t.Eye,{className:"h-3.5 w-3.5"});return e.jsxs("button",{onClick:()=>_(W.id),disabled:ue||w||!ne,className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-[var(--radius-badge)] border text-xs font-medium transition-all ${je} ${ne?"ring-2 ring-[var(--color-accent-600)] dark:ring-[var(--color-accent-400)] hover:opacity-80 cursor-pointer":"opacity-60 cursor-not-allowed"} disabled:opacity-50`,title:ne?d("groupPermissions.clickToRemove","Cliquer pour retirer"):d("groupPermissions.grantedByRole","Accordé par un rôle"),children:[ue?e.jsx(t.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):Ne,e.jsx("span",{className:"capitalize",children:d(`assignments.actions.${W.action==="*"?"all":W.action}.label`)}),ne&&e.jsx(t.Star,{className:"h-3 w-3"})]},W.id)})})})]},a.id)};return e.jsxs("div",{children:[!x&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-start lg:gap-6",children:[e.jsxs("div",{className:"w-full lg:w-72 lg:flex-shrink-0 space-y-4 mb-4 lg:mb-0 lg:sticky lg:top-4",children:[e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--text-primary)] mb-3",children:d("groupPermissions.filters.title","Filtres")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-[var(--text-secondary)]",children:d("groupPermissions.filters.application","Application")}),e.jsxs("select",{value:S.applicationFilter,onChange:a=>q({applicationFilter:a.target.value,moduleFilter:"all"}),className:"w-full px-3 py-1.5 text-sm bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:d("groupPermissions.filters.allApplications","Toutes les applications")}),F.map(a=>e.jsx("option",{value:a.app,children:a.label},a.app))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-[var(--text-secondary)]",children:d("groupPermissions.filters.module","Module")}),e.jsxs("select",{value:S.moduleFilter,onChange:a=>q({moduleFilter:a.target.value}),className:"w-full px-3 py-1.5 text-sm bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-[var(--radius-input)] text-[var(--text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"all",children:d("groupPermissions.filters.allModules","Tous les modules")}),U.filter(a=>S.applicationFilter==="all"||a.app===S.applicationFilter).map(a=>e.jsx("option",{value:a.module,children:a.label},`${a.app}:${a.module}`))]})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border-color)]",children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)] block mb-2",children:d("groupPermissions.filterByStatus","Filtrer par statut")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs("button",{onClick:()=>N("all"),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full border transition-colors ${G.has("all")?"bg-[var(--success-bg)] border-[var(--success-border)] text-[var(--success-text)]":"bg-[var(--bg-tertiary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--success-border)]"}`,children:[e.jsx(t.Check,{className:`h-3 w-3 ${G.has("all")?"":"text-[var(--success-dot)]"}`}),d("assignments.complete")]}),e.jsxs("button",{onClick:()=>N("some"),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full border transition-colors ${G.has("some")?"bg-[var(--warning-bg)] border-[var(--warning-border)] text-[var(--warning-text)]":"bg-[var(--bg-tertiary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--warning-border)]"}`,children:[e.jsx(t.Star,{className:`h-3 w-3 ${G.has("some")?"":"text-[var(--warning-dot)]"}`}),d("assignments.partial")]}),e.jsxs("button",{onClick:()=>N("read-only"),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full border transition-colors ${G.has("read-only")?"bg-[var(--info-bg)] border-[var(--info-border)] text-[var(--info-text)]":"bg-[var(--bg-tertiary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--info-border)]"}`,children:[e.jsx(t.Eye,{className:`h-3 w-3 ${G.has("read-only")?"":"text-[var(--info-dot)]"}`}),d("assignments.readOnly")]}),e.jsxs("button",{onClick:()=>N("none"),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full border transition-colors ${G.has("none")?"bg-[var(--error-bg)] border-[var(--error-border)] text-[var(--error-text)]":"bg-[var(--bg-tertiary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--error-border)]"}`,children:[e.jsx(t.Ban,{className:`h-3 w-3 ${G.has("none")?"":"text-[var(--text-muted)]"}`}),d("assignments.none")]})]}),G.size>0&&e.jsx("button",{onClick:()=>J(new Set),className:"mt-2 text-xs text-[var(--color-accent-500)] hover:text-[var(--color-accent-600)] underline",children:d("assignments.clearFilters")})]}),e.jsx("div",{className:"mt-4 pt-4 border-t border-[var(--border-color)]",children:e.jsxs("span",{className:"px-2.5 py-1 text-xs font-semibold rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:[Ae," ",d("assignments.modules")]})})]}),e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--text-primary)] mb-3",children:d("groupPermissions.assignedRoles","Rôles assignés")}),h.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(a=>{const g=ve(a.name),b=a.isGlobal?e.jsx(t.Globe,{className:"h-3 w-3 text-[var(--info-text)]"}):e.jsx(t.Building2,{className:"h-3 w-3 text-[var(--warning-text)]"}),$=a.isGlobal?d("groupPermissions.globalScope","Global"):a.tenantName||d("groupPermissions.tenantScope","Tenant");return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:()=>!g&&o(`/administration/permissions/roles/${a.id}`),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-full bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)] transition-all ${g?"cursor-default":"cursor-pointer hover:ring-2 hover:ring-[var(--color-accent-500)] hover:shadow-md"}`,title:g?d("groupPermissions.customRoleTooltip","Rôle personnalisé"):d("groupPermissions.clickToViewRole","Cliquer pour voir le rôle"),children:[e.jsx(t.Shield,{className:"h-3.5 w-3.5"}),a.shortName||a.name]}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-full ${a.isGlobal?"bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]":"bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]"}`,title:a.isGlobal?d("groupPermissions.globalScopeTooltip","Ce rôle s'applique à tous les tenants"):d("groupPermissions.tenantScopeTooltip","Ce rôle s'applique uniquement à ce tenant: {{tenant}}",{tenant:a.tenantName}),children:[b,e.jsx("span",{className:"hidden sm:inline",children:$})]})]},`${a.id}-${a.tenantId||"global"}`)})}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-muted)]",children:[e.jsx(t.Info,{className:"h-4 w-4"}),e.jsx("span",{children:d("groupPermissions.noRolesInfo","Ce groupe n'a aucun rôle.")})]})]}),X&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-[var(--radius-card)] bg-[var(--accent-bg)] border border-[var(--accent-border)]",children:[e.jsx(t.Shield,{className:"h-4 w-4 text-[var(--accent-text)]"}),e.jsx("span",{className:"text-sm text-[var(--accent-text)]",children:d("groupPermissions.tenantModeInfo","Affichage des permissions dans le contexte du tenant.")})]}),I&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]",children:[e.jsx(t.AlertCircle,{className:"h-4 w-4 text-[var(--error-text)]"}),e.jsx("span",{className:"text-sm text-[var(--error-text)]",children:I})]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"overflow-x-auto overflow-y-visible",children:e.jsxs("table",{className:"border-collapse",style:{width:"auto"},children:[e.jsx("thead",{className:"item-medium border-b border-[var(--item-color-border)]",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"sticky left-0 z-20 item-medium px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"280px",minWidth:"280px",maxWidth:"280px",height:"48px",verticalAlign:"middle"},children:d("assignments.resource")}),e.jsx("th",{scope:"col",className:"px-2 text-center text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"60px",minWidth:"60px",maxWidth:"60px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.status","Statut")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"140px",minWidth:"140px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.sourceRoles","Rôles sources")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"120px",minWidth:"120px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.tenant","Tenant")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"100px",minWidth:"100px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.source","Source")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{minWidth:"200px",height:"48px",verticalAlign:"middle"},children:d("assignments.permissions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--item-color-border)]",children:fe.map(a=>{const g=a.application,b=Y.has(g);return e.jsxs(r.Fragment,{children:[e.jsxs("tr",{className:"bg-[var(--color-accent-900)]/30 dark:bg-[var(--color-accent-900)]/50",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-3 bg-[var(--color-accent-900)]/30 dark:bg-[var(--color-accent-900)]/50",style:{width:"280px",minWidth:"280px",maxWidth:"280px"},children:e.jsxs("button",{onClick:()=>R(g),className:"flex items-center gap-3 w-full text-left hover:opacity-80",children:[b?e.jsx(t.ChevronRight,{className:"h-5 w-5 text-[var(--color-accent-400)]"}):e.jsx(t.ChevronDown,{className:"h-5 w-5 text-[var(--color-accent-400)]"}),e.jsx(t.FolderOpen,{className:"h-5 w-5 text-[var(--color-accent-400)]"}),e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-300)] uppercase tracking-wider",children:a.application}),e.jsxs("span",{className:"text-xs text-[var(--color-accent-400)] ml-auto",children:[a.modules.length," module",a.modules.length>1?"s":""]})]})}),e.jsx("td",{colSpan:5,className:"px-0 py-3"})]}),!b&&a.modules.map(($,te)=>{const{module:Z,sections:ae}=$,le=ae.length>0,xe=O.has(Z.id);return e.jsxs(r.Fragment,{children:[ye(Z,te,"module",le,xe),Ue(ae,te,le,xe)]},Z.id)})]},g)})})]})}),Ae===0&&e.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:d("assignments.noResources")})]})]})}),x&&e.jsx("div",{className:"overflow-x-auto overflow-y-visible",children:e.jsxs("table",{className:"border-collapse",style:{width:"auto"},children:[e.jsx("thead",{className:"item-medium border-b border-[var(--item-color-border)]",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"sticky left-0 z-20 item-medium px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"280px",minWidth:"280px",maxWidth:"280px",height:"48px",verticalAlign:"middle"},children:d("assignments.resource")}),e.jsx("th",{scope:"col",className:"px-2 text-center text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"60px",minWidth:"60px",maxWidth:"60px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.status","Statut")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"140px",minWidth:"140px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.sourceRoles","Rôles sources")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"120px",minWidth:"120px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.tenant","Tenant")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{width:"100px",minWidth:"100px",height:"48px",verticalAlign:"middle"},children:d("groupPermissions.source","Source")}),e.jsx("th",{scope:"col",className:"px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",style:{minWidth:"200px",height:"48px",verticalAlign:"middle"},children:d("assignments.permissions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--item-color-border)]",children:fe.map(a=>e.jsx(r.Fragment,{children:a.modules.map((g,b)=>e.jsx(r.Fragment,{children:ye(g.module,b,"module",!1,!1)},g.module.id))},a.application))})]})})]})}function lt({groupId:s,tenantId:x}){const{t:l}=ce.useTranslation(["groups","admin"]),[c,d]=r.useState([]),[o,k]=r.useState(!0),[y,v]=r.useState(new Set),h=r.useCallback(async()=>{k(!0);try{const j=await z.groupsApi.getApplicationAccess(s,x);d(j)}catch{d([])}finally{k(!1)}},[s,x]);r.useEffect(()=>{h()},[h]);const P=j=>{v(S=>{const F=new Set(S);return F.has(j)?F.delete(j):F.add(j),F})};return o?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(t.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):c.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(t.Boxes,{className:"w-12 h-12 mx-auto mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{children:l("groups:applications.noAccess")})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:l("groups:applications.title")}),e.jsx("button",{onClick:()=>{h()},className:"p-2 rounded-[var(--radius-button)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]",title:l("admin:common.refresh","Refresh"),children:e.jsx(t.RefreshCw,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"space-y-2",children:c.map(j=>e.jsx(it,{app:j,isExpanded:y.has(j.applicationId),onToggle:()=>P(j.applicationId)},j.applicationId))})]})}function it({app:s,isExpanded:x,onToggle:l}){const{t:c}=ce.useTranslation(["groups","admin"]),d=_e,o=s.icon?d[s.icon]:null,k=r.useMemo(()=>{const y={};for(const v of s.permissions){const h=v.moduleName||"_global";y[h]||(y[h]={moduleName:v.moduleName||c("groups:applications.globalPermissions"),permissions:[]}),y[h].permissions.push(v)}return Object.values(y)},[s.permissions,c]);return e.jsxs("div",{className:"border border-[var(--border-color)] rounded-[var(--radius-card)] bg-[var(--bg-card)] overflow-hidden",children:[e.jsxs("button",{onClick:l,className:"w-full flex items-center gap-3 p-4 text-left hover:bg-[var(--bg-hover)] transition-colors",children:[x?e.jsx(t.ChevronDown,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}):e.jsx(t.ChevronRight,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}),e.jsx("div",{className:"w-9 h-9 rounded-[var(--radius-button)] bg-[var(--color-accent-500)]/10 flex items-center justify-center flex-shrink-0",children:o?e.jsx(o,{className:"w-5 h-5 text-[var(--color-accent-600)]"}):e.jsx(t.Layers,{className:"w-5 h-5 text-[var(--color-accent-600)]"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] truncate",children:s.applicationLabel}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] truncate",children:s.applicationCode})]}),s.hasFullAccess?e.jsx("span",{className:"px-2.5 py-1 text-xs font-medium rounded-full bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)] flex-shrink-0",children:c("groups:applications.fullAccess")}):e.jsx("span",{className:"px-2.5 py-1 text-xs font-medium rounded-full bg-[var(--color-accent-500)]/10 text-[var(--color-accent-600)] border border-[var(--color-accent-500)]/20 flex-shrink-0",children:c("groups:applications.permissionCount",{count:s.permissions.length})}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)] flex items-center gap-1 flex-shrink-0",children:[e.jsx(t.Shield,{className:"w-3.5 h-3.5"}),s.roles.length]})]}),x&&e.jsxs("div",{className:"border-t border-[var(--border-color)] p-4 space-y-4 bg-[var(--bg-secondary)]",children:[e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider mb-2",children:c("groups:applications.rolesGrantingAccess")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.roles.map(y=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-full bg-[var(--bg-card)] border border-[var(--border-color)] text-[var(--text-primary)]",children:[e.jsx(t.Shield,{className:"w-3 h-3 text-[var(--color-accent-500)]"}),y.roleName]},y.roleId))})]}),!s.hasFullAccess&&s.permissions.length>0&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider mb-2",children:c("groups:applications.permissionsDetail")}),e.jsx("div",{className:"space-y-3",children:k.map(y=>e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-[var(--text-secondary)] mb-1",children:y.moduleName}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:y.permissions.map(v=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded bg-[var(--bg-card)] border border-[var(--border-color)] text-[var(--text-secondary)]",children:[e.jsx(t.Key,{className:"w-2.5 h-2.5 text-[var(--text-tertiary)]"}),v.action||ct(v.path)]},v.path))})]},y.moduleName))})]}),s.hasFullAccess&&e.jsx("p",{className:"text-xs text-[var(--success-text)] italic",children:c("groups:applications.fullAccessDescription")})]})]})}function ct(s){return s.split(".").at(-1)}function dt({className:s="",showSwitch:x=!0,onSwitchClick:l}){const{t:c}=ce.useTranslation("admin"),{currentTenant:d,hasMultipleTenants:o,isGlobalView:k}=oe.useTenant();if(!k&&(!o||!d))return null;if(k)return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-4 py-2.5 border bg-emerald-500/5 border-emerald-500/20 ${s}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 flex items-center justify-center bg-emerald-500/10",style:{borderRadius:"var(--radius-card)"},children:e.jsx(t.Globe,{className:"w-4 h-4 text-emerald-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-emerald-700",children:c("scope.banner.globalMode","Vue globale")}),e.jsx("p",{className:"text-xs text-emerald-600/70 mt-0.5",children:c("scope.banner.globalModeDesc","Vous voyez les données de tous les tenants")})]})]}),x&&l&&e.jsxs("button",{onClick:l,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-emerald-700 hover:text-emerald-800 hover:bg-emerald-500/10 transition-colors",style:{borderRadius:"var(--radius-button)"},children:[e.jsx(t.ArrowRightLeft,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:c("scope.banner.selectTenant","Sélectionner un tenant")})]})]});const y=d?.type==="Business";return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-4 py-2.5 border bg-[var(--color-accent-500)]/5 border-[var(--color-accent-500)]/20 ${s}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`flex-shrink-0 w-8 h-8 flex items-center justify-center ${y?"bg-blue-500/10":"bg-violet-500/10"}`,style:{borderRadius:"var(--radius-card)"},children:y?e.jsx(t.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(t.User,{className:"w-4 h-4 text-violet-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:c("scope.banner.tenantMode","Espace de travail: {{tenantName}}",{tenantName:d?.name})}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:c("scope.banner.tenantModeDesc","Les modifications s'appliquent uniquement à ce tenant")})]})]}),x&&l&&e.jsxs("button",{onClick:l,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:[e.jsx(t.ArrowRightLeft,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:c("scope.banner.switchScope","Changer de scope")})]})]})}const xt=["info","hierarchy","members","roles","tenants","applications","permissions"],we=s=>s?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s):!1,mt=()=>{const[s,x]=r.useState(null),[l,c]=r.useState(null),[d,o]=r.useState(!1),[k,y]=r.useState(!0),[v,h]=r.useState(!1),[P,j]=r.useState(null),[S,F]=r.useState(null),[U,q]=r.useState(!1),[T,L]=r.useState({name:"",description:""});return{group:s,setGroup:x,roles:l,setRoles:c,rolesLoading:d,setRolesLoading:o,loading:k,setLoading:y,saving:v,setSaving:h,error:P,setError:j,success:S,setSuccess:F,isEditing:U,setIsEditing:q,formData:T,setFormData:L}};function ut({groupId:s,group:x,onRefresh:l,onSuccess:c,onError:d}){const{t:o}=ce.useTranslation(["admin","groups"]),[k,y]=r.useState([]),[v,h]=r.useState(!1),[P,j]=r.useState(!1),[S,F]=r.useState(!1),[U,q]=r.useState(!1),[T,L]=r.useState(""),[X,Y]=r.useState(""),[R,O]=r.useState(!1),[E,C]=r.useState(""),[V,G]=r.useState(""),[J,M]=r.useState(!1),[H,se]=r.useState([]),[D,B]=r.useState(!1),re=r.useCallback(async()=>{try{h(!0);const i=await z.groupsApi.getAll();y(i)}catch{}finally{h(!1)}},[]);r.useEffect(()=>{(P||S)&&re()},[P,S,re]),r.useEffect(()=>{if(!x.parentGroupId)return;(async()=>{try{B(!0);const A=await z.groupsApi.getInheritedMembers(s);se(A)}catch{}finally{B(!1)}})()},[s,x.parentGroupId]);const ee=r.useMemo(()=>{const i=new Map;for(const A of H){const K=A.inheritedFromGroupId;i.has(K)||i.set(K,{groupId:A.inheritedFromGroupId,groupName:A.inheritedFromGroupName,level:A.level,members:[]}),i.get(K).members.push(A)}return Array.from(i.values()).sort((A,K)=>A.level-K.level)},[H]),w=((i,A)=>{const K=new Set,he=[i];for(;he.length>0;){const be=he.shift();K.add(be),A.filter(ge=>ge.parentGroupId===be).forEach(ge=>he.push(ge.id))}return K})(s,k),m=k.filter(i=>!w.has(i.id)&&i.isActive).filter(i=>!T||i.name.toLowerCase().includes(T.toLowerCase())),I=new Set(x.childGroups?.map(i=>i.id)||[]),Q=k.filter(i=>i.id!==s&&!I.has(i.id)&&i.isActive).filter(i=>i.parentGroupId!==s).filter(i=>!X||i.name.toLowerCase().includes(X.toLowerCase())),p=async i=>{try{O(!0),await z.groupsApi.setParentGroup(s,{parentGroupId:i}),await l(),c(o("groups:hierarchy.parentSet")),j(!1),L("")}catch{d(o("groups:hierarchy.errors.setParentFailed"))}finally{O(!1)}},f=async()=>{try{O(!0),await z.groupsApi.setParentGroup(s,{parentGroupId:null}),await l(),c(o("groups:hierarchy.parentCleared"))}catch{d(o("groups:hierarchy.errors.clearParentFailed"))}finally{O(!1)}},_=async i=>{try{O(!0),await z.groupsApi.setParentGroup(i,{parentGroupId:s}),await l(),c(o("groups:hierarchy.childAdded")),F(!1),Y("")}catch{d(o("groups:hierarchy.errors.addChildFailed"))}finally{O(!1)}},u=async(i,A)=>{if(confirm(o("groups:hierarchy.confirmRemoveChild",{name:A})))try{O(!0),await z.groupsApi.setParentGroup(i,{parentGroupId:null}),await l(),c(o("groups:hierarchy.childRemoved"))}catch{d(o("groups:hierarchy.errors.removeChildFailed"))}finally{O(!1)}},N=async i=>{if(i.preventDefault(),!!E.trim())try{O(!0),await z.groupsApi.create({name:E.trim(),description:V.trim()||void 0,isSecurityGroup:J,parentGroupId:s}),await l(),c(o("groups:hierarchy.childCreated")),q(!1),C(""),G(""),M(!1)}catch{d(o("groups:hierarchy.errors.createChildFailed"))}finally{O(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--info-bg)] border border-[var(--info-border)]",children:e.jsx("p",{className:"text-sm text-[var(--info-text)]",children:o("groups:hierarchy.info")})}),e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.CornerDownRight,{className:"w-5 h-5"}),o("groups:hierarchy.parentGroup")]}),!x.parentGroupId&&!P&&e.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),o("groups:hierarchy.setParent")]})]}),x.parentGroupId?e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsxs(ie.Link,{to:`/administration/users/groups/${x.parentGroupId}`,className:"flex items-center gap-3 text-sm font-medium text-[var(--color-accent-500)] hover:underline",children:[e.jsx("div",{className:"p-2 rounded-lg bg-[var(--accent-bg)]",children:e.jsx(t.GitBranch,{className:"w-4 h-4 text-[var(--color-accent-500)]"})}),x.parentGroupName||x.parentGroupId]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{j(!0)},className:"flex items-center gap-1 px-2 py-1 text-xs rounded-[var(--radius-button)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(t.Edit3,{className:"w-3 h-3"}),o("common:edit","Modifier")]}),e.jsxs("button",{onClick:f,disabled:R,className:"flex items-center gap-1 px-2 py-1 text-xs rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(t.Unlink,{className:"w-3 h-3"}),o("groups:hierarchy.clearParent")]})]})]}):P?null:e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:o("groups:hierarchy.noParent")}),P&&e.jsxs("div",{className:"mt-4 p-4 rounded-lg border border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",value:T,onChange:i=>L(i.target.value),placeholder:o("groups:hierarchy.searchGroups"),className:"w-full pl-9 pr-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),e.jsx("button",{onClick:()=>{j(!1),L("")},className:"p-2 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"max-h-48 overflow-y-auto space-y-1",children:[v&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(t.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!v&&m.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-4",children:o("groups:hierarchy.noGroupsAvailable")}),!v&&m.length>0&&m.map(i=>e.jsxs("button",{onClick:()=>p(i.id),disabled:R,className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx(t.GitBranch,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:i.name}),i.parentGroupName&&e.jsxs("span",{className:"ml-2 text-xs text-[var(--text-tertiary)]",children:["(",o("groups:hierarchy.childOf")," ",i.parentGroupName,")"]})]})]},i.id))]})]})]}),x.parentGroupId&&e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2 mb-4",children:[e.jsx(t.Users,{className:"w-5 h-5"}),o("groups:hierarchy.inheritedMembers"),!D&&e.jsx("span",{className:"ml-1 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:H.length})]}),e.jsx("div",{className:"p-4 rounded-lg bg-[var(--info-bg)] border border-[var(--info-border)] mb-4",children:e.jsx("p",{className:"text-sm text-[var(--info-text)]",children:o("groups:hierarchy.inheritedMembersInfo")})}),D&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(t.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!D&&H.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-4",children:o("groups:hierarchy.noInheritedMembers")}),!D&&ee.length>0&&e.jsx("div",{className:"space-y-4",children:ee.map(i=>e.jsxs("div",{className:"p-4 rounded-lg border border-dashed border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsxs(ie.Link,{to:`/administration/users/groups/${i.groupId}`,className:"text-sm font-medium text-[var(--color-accent-500)] hover:underline flex items-center gap-1.5",children:[e.jsx(t.GitBranch,{className:"w-4 h-4"}),i.groupName]}),e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:o("groups:hierarchy.level",{level:i.level})})]}),e.jsx("div",{className:"space-y-1",children:i.members.map(A=>e.jsxs(ie.Link,{to:`/administration/users/${A.userId}`,className:"flex items-center gap-3 p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("div",{className:"p-1.5 rounded-full bg-[var(--bg-secondary)]",children:e.jsx(t.Users,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:A.fullName}),e.jsx("span",{className:"ml-2 text-xs text-[var(--text-tertiary)]",children:A.email})]})]},A.userId))})]},i.groupId))})]}),e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.GitBranch,{className:"w-5 h-5"}),o("groups:hierarchy.childGroups"),e.jsx("span",{className:"ml-1 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:x.childGroups?.length||0})]}),!S&&!U&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>q(!0),className:"flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),o("groups:hierarchy.createChild")]}),e.jsxs("button",{onClick:()=>F(!0),className:"flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(t.GitBranch,{className:"w-4 h-4"}),o("groups:hierarchy.addExisting")]})]})]}),S&&e.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(t.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",value:X,onChange:i=>Y(i.target.value),placeholder:o("groups:hierarchy.searchGroups"),className:"w-full pl-9 pr-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",autoFocus:!0})]}),e.jsx("button",{onClick:()=>{F(!1),Y("")},className:"p-2 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"max-h-48 overflow-y-auto space-y-1",children:[v&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(t.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!v&&Q.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-4",children:o("groups:hierarchy.noGroupsAvailable")}),!v&&Q.length>0&&Q.map(i=>e.jsxs("button",{onClick:()=>_(i.id),disabled:R,className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx(t.Plus,{className:"w-4 h-4 text-[var(--color-accent-500)] flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:i.name}),i.parentGroupName&&e.jsxs("span",{className:"ml-2 text-xs text-[var(--text-tertiary)]",children:["(",o("groups:hierarchy.childOf")," ",i.parentGroupName,")"]})]})]},i.id))]})]}),U&&e.jsxs("form",{onSubmit:N,className:"mb-4 p-4 rounded-lg border border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-[var(--text-primary)]",children:o("groups:hierarchy.createChild")}),e.jsx("button",{type:"button",onClick:()=>{q(!1),C(""),G(""),M(!1)},className:"p-1 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.X,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-[var(--text-secondary)] mb-1",children:[o("admin:groups.groupName")," *"]}),e.jsx("input",{type:"text",value:E,onChange:i=>C(i.target.value),placeholder:o("admin:groups.groupNamePlaceholder"),className:"w-full px-3 py-2 text-sm rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",required:!0,autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--text-secondary)] mb-1",children:o("groups:detail.info.description")}),e.jsx("input",{type:"text",value:V,onChange:i=>G(i.target.value),placeholder:o("admin:groups.descriptionPlaceholder"),className:"w-full px-3 py-2 text-sm rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:J,onChange:i=>M(i.target.checked),className:"rounded border-[var(--border-color)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:o("admin:groups.isSecurityGroup")})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:()=>{q(!1),C(""),G(""),M(!1)},className:"px-3 py-1.5 text-sm rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:o("common:cancel","Annuler")}),e.jsxs("button",{type:"submit",disabled:!E.trim()||R,className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[R?e.jsx(t.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(t.Plus,{className:"w-4 h-4"}),o("common:create","Créer")]})]})]})]}),(x.childGroups?.length??0)>0?e.jsx("div",{className:"space-y-2",children:x.childGroups.map(i=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsxs(ie.Link,{to:`/administration/users/groups/${i.id}`,className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-[var(--accent-bg)]",children:e.jsx(t.GitBranch,{className:"w-4 h-4 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:i.name}),!i.isActive&&e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded-[var(--radius-badge)] bg-[var(--warning-bg)] text-[var(--warning-text)]",children:o("common.inactive","Inactive")})]}),e.jsxs("button",{onClick:()=>u(i.id,i.name),disabled:R,className:"flex items-center gap-1 px-2 py-1 text-xs rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(t.Unlink,{className:"w-3 h-3"}),o("groups:hierarchy.removeChild")]})]},i.id))}):!S&&!U?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(t.GitBranch,{className:"w-8 h-8 mx-auto mb-2 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:o("groups:hierarchy.noChildren")}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-2",children:[e.jsxs("button",{onClick:()=>q(!0),className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:[e.jsx(t.Plus,{className:"w-4 h-4"}),o("groups:hierarchy.createChild")]}),e.jsxs("button",{onClick:()=>F(!0),className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(t.GitBranch,{className:"w-4 h-4"}),o("groups:hierarchy.addExisting")]})]})]}):null]})]})}function pt(){const{t:s}=ce.useTranslation(["admin","groups"]),{id:x}=ie.useParams(),l=ie.useNavigate(),{currentTenant:c,hasMultipleTenants:d}=oe.useTenant(),{tenants:o}=Ie.useAdminTenants(),{activeTab:k,setActiveTab:y}=We.useTabNavigation("info",xt),v=r.useRef(new Set(["info"])),{group:h,setGroup:P,roles:j,setRoles:S,rolesLoading:F,setRolesLoading:U,loading:q,setLoading:T,saving:L,setSaving:X,error:Y,setError:R,success:O,setSuccess:E,isEditing:C,setIsEditing:V,formData:G,setFormData:J}=mt(),M=r.useCallback(async(n=!1)=>{if(!(!x||!we(x)))try{n||T(!0);const w=await z.groupsApi.getById(x);P(w),J({name:w.name,description:w.description||""})}catch(w){console.error("Failed to load group:",w),R(s("groups:detail.errors.loadFailed","Erreur lors du chargement du groupe"))}finally{n||T(!1)}},[x,s]),H=r.useCallback(async()=>{try{U(!0);const n=await oe.adminApi.roles.getAssignable();S(Array.isArray(n)?n:[])}catch(n){console.error("Failed to load roles:",n),S([])}finally{U(!1)}},[]);r.useEffect(()=>{x&&we(x)&&M()},[x,M]),r.useEffect(()=>{v.current.has(k)||v.current.add(k),(k==="roles"||k==="permissions")&&j===null&&!F&&H()},[k,j,F]);const se=r.useCallback(async()=>{if(!(!x||!h))try{X(!0),R(null),await z.groupsApi.update(x,{name:G.name,description:G.description||void 0}),await M(),E(s("groups:detail.saveSuccess","Groupe mis à jour avec succès")),V(!1),setTimeout(()=>E(null),3e3)}catch(n){console.error("Failed to save group:",n),R(s("groups:detail.errors.saveFailed","Erreur lors de l'enregistrement"))}finally{X(!1)}},[x,h,G,M,s]),D=r.useCallback(async()=>{if(x)try{await z.groupsApi.activate(x),await M(),E(s("groups:detail.activateSuccess","Groupe activé")),setTimeout(()=>E(null),3e3)}catch(n){console.error("Failed to activate group:",n),R(s("groups:detail.errors.activateFailed","Erreur lors de l'activation"))}},[x,M,s]),B=r.useCallback(async()=>{if(x)try{await z.groupsApi.deactivate(x),await M(),E(s("groups:detail.deactivateSuccess","Groupe désactivé")),setTimeout(()=>E(null),3e3)}catch(n){console.error("Failed to deactivate group:",n),R(s("groups:detail.errors.deactivateFailed","Erreur lors de la désactivation"))}},[x,M,s]),re=r.useCallback(async()=>{if(!x||!h)return;const n=h.isSyncedFromEntra?s("groups:detail.confirmDeleteEntra",{name:h.name,defaultValue:`Le groupe "${h.name}" est synchronisé depuis Entra ID. Il sera recréé lors de la prochaine synchronisation.
|
|
2
2
|
|
|
3
3
|
Êtes-vous sûr de vouloir le supprimer ?`}):s("groups:detail.confirmDelete",{name:h.name,defaultValue:`Êtes-vous sûr de vouloir supprimer le groupe "${h.name}" ?`});if(confirm(n))try{await z.groupsApi.delete(x),l("/administration/users/groups")}catch(w){console.error("Failed to delete group:",w),R(s("groups:detail.errors.deleteFailed","Erreur lors de la suppression"))}},[x,h,l,s]),ee=[{id:"info",label:s("groups:detail.tabs.info","Informations"),icon:t.Users},{id:"hierarchy",label:s("groups:detail.tabs.hierarchy","Hiérarchie"),icon:t.GitBranch},{id:"members",label:s("groups:detail.tabs.members","Membres"),icon:t.Users},{id:"roles",label:s("groups:detail.tabs.roles","Rôles"),icon:t.Shield},{id:"tenants",label:s("groups:detail.tabs.tenants","Tenants"),icon:t.Building2},{id:"applications",label:s("groups:detail.tabs.applications","Applications"),icon:t.AppWindow},{id:"permissions",label:s("groups:detail.tabs.permissions","Permissions"),icon:t.Key}];return!x||!we(x)?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(t.AlertTriangle,{className:"w-12 h-12 mx-auto mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:s("groups:detail.invalidId","ID de groupe invalide")})]})}):q?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(t.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):h?e.jsxs("div",{className:"space-y-6",children:[e.jsx(oe.Breadcrumb,{items:[{label:s("admin:nav.administration","Administration"),href:"/administration"},{label:s("admin:nav.groups","Groupes"),href:"/administration/users/groups"},{label:h.name}]}),d&&c&&e.jsx(dt,{}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>l(-1),className:"p-2 rounded-lg bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(t.ArrowLeft,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-3 rounded-xl ${h.isSecurityGroup?"bg-[var(--info-bg)] text-[var(--info-text)]":"bg-[var(--accent-bg)] text-[var(--color-accent-500)]"}`,children:h.isSecurityGroup?e.jsx(t.Shield,{className:"w-6 h-6"}):e.jsx(t.Users,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:h.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[h.isActive?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--success-bg)] text-[var(--success-text)]",children:[e.jsx(t.CheckCircle,{className:"w-3 h-3"}),s("common.active","Actif")]}):e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--error-bg)] text-[var(--error-text)]",children:[e.jsx(t.AlertTriangle,{className:"w-3 h-3"}),s("common.inactive","Inactif")]}),h.isSyncedFromEntra&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--color-accent-500)]/10 text-[var(--color-accent-500)]",children:[e.jsx(t.Cloud,{className:"w-3 h-3"}),"Entra ID"]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[h.isActive?e.jsxs("button",{onClick:B,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--warning-dot)] text-white hover:opacity-90 transition-colors",children:[e.jsx(t.AlertTriangle,{className:"w-4 h-4"}),s("common.deactivate","Désactiver")]}):e.jsxs("button",{onClick:D,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--success-dot)] text-white hover:opacity-90 transition-colors",children:[e.jsx(t.CheckCircle,{className:"w-4 h-4"}),s("common.activate","Activer")]}),e.jsxs("button",{onClick:re,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--error-dot)] text-white hover:opacity-90 transition-colors",children:[e.jsx(t.Trash2,{className:"w-4 h-4"}),s("common.delete","Supprimer")]})]})]}),Y&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] flex items-center gap-3",children:[e.jsx(t.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-[var(--error-text)]",children:Y}),e.jsx("button",{onClick:()=>M(),className:"mt-1 text-sm text-[var(--error-text)] hover:opacity-80 underline",children:s("common:actions.retry","Réessayer")})]}),e.jsx("button",{onClick:()=>R(null),className:"ml-auto self-start",children:e.jsx(t.X,{className:"w-4 h-4 text-[var(--error-text)]"})})]}),O&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] flex items-center gap-3",children:[e.jsx(t.CheckCircle,{className:"w-5 h-5 text-[var(--success-text)] flex-shrink-0"}),e.jsx("p",{className:"text-[var(--success-text)]",children:O})]}),e.jsx("div",{className:"border-b border-[var(--border-color)]",children:e.jsx("nav",{className:"flex gap-1 overflow-x-auto pb-px",children:ee.map(n=>e.jsxs("button",{onClick:()=>y(n.id),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${k===n.id?"border-[var(--color-accent-500)] text-[var(--color-accent-500)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--border-color)]"}`,children:[e.jsx(n.icon,{className:"w-4 h-4"}),n.label]},n.id))})}),k==="info"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.Users,{className:"w-5 h-5"}),s("groups:detail.info.basicInfo","Informations de base")]}),!h.isSyncedFromEntra&&!C&&e.jsxs("button",{onClick:()=>V(!0),className:"flex items-center gap-1 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(t.Edit3,{className:"w-4 h-4"}),s("common.edit","Modifier")]}),C&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{V(!1),J({name:h.name,description:h.description||""})},className:"px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:s("common.cancel","Annuler")}),e.jsxs("button",{onClick:se,disabled:L,className:"flex items-center gap-1 px-3 py-1.5 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors disabled:opacity-50",children:[L?e.jsx(t.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(t.Save,{className:"w-4 h-4"}),s("common.save","Enregistrer")]})]})]}),C?e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:s("groups:detail.info.name","Nom")}),e.jsx("input",{type:"text",value:G.name,onChange:n=>J(w=>({...w,name:n.target.value})),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:s("groups:detail.info.description","Description")}),e.jsx("textarea",{value:G.description,onChange:n=>J(w=>({...w,description:n.target.value})),rows:3,className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]})]}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] uppercase tracking-wider mb-1",children:s("groups:detail.info.name","Nom")}),e.jsx("p",{className:"text-sm text-[var(--text-primary)] font-medium",children:h.name})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] uppercase tracking-wider mb-1",children:s("groups:detail.info.type","Type")}),e.jsx("p",{className:"text-sm text-[var(--text-primary)] font-medium",children:h.isSecurityGroup?s("groups:detail.info.securityGroup","Groupe de sécurité"):s("groups:detail.info.distributionGroup","Groupe de distribution")})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-secondary)] sm:col-span-2",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] uppercase tracking-wider mb-1",children:s("groups:detail.info.description","Description")}),e.jsx("p",{className:"text-sm text-[var(--text-primary)]",children:h.description||"-"})]})]})]}),h.isSyncedFromEntra&&e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2 mb-4",children:[e.jsx(t.Cloud,{className:"w-5 h-5"}),s("groups:detail.info.entraInfo","Microsoft Entra ID")]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] uppercase tracking-wider mb-1",children:s("groups:detail.info.entraObjectId","Object ID")}),e.jsx("p",{className:"text-sm text-[var(--text-primary)] font-mono",children:h.entraObjectId})]}),h.mail&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] uppercase tracking-wider mb-1",children:s("groups:detail.info.mail","Email")}),e.jsxs("p",{className:"text-sm text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(t.Mail,{className:"w-4 h-4"}),h.mail]})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] uppercase tracking-wider mb-1",children:s("groups:detail.info.lastSync","Dernière synchronisation")}),e.jsx("p",{className:"text-sm text-[var(--text-primary)]",children:h.lastEntraSyncAt?new Date(h.lastEntraSyncAt).toLocaleString():"-"})]})]}),e.jsx("div",{className:"mt-4 p-3 rounded-lg bg-[var(--info-bg)] border border-[var(--info-border)]",children:e.jsx("p",{className:"text-sm text-[var(--info-text)]",children:s("groups:detail.info.entraNote","Ce groupe est synchronisé depuis Microsoft Entra ID. Les informations de base ne peuvent pas être modifiées ici.")})})]}),e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)] flex items-center gap-2 mb-4",children:[e.jsx(t.Users,{className:"w-5 h-5"}),s("groups:detail.info.members","Membres"),e.jsx("span",{className:"ml-2 px-2 py-0.5 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:h.members?.length||0})]}),(h.members?.length??0)>0?e.jsxs("div",{className:"space-y-2",children:[h.members.slice(0,5).map(n=>e.jsxs(ie.Link,{to:`/administration/users/${n.userId}`,className:"flex items-center gap-3 p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--accent-bg)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-medium text-[var(--color-accent-500)]",children:n.fullName.charAt(0)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:n.fullName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:n.email})]})]},n.userId)),h.members.length>5&&e.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-2",children:s("groups:detail.info.moreMembers","+ {{count}} autres membres",{count:h.members.length-5})})]}):e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:s("groups:detail.info.noMembers","Aucun membre dans ce groupe")})]}),e.jsxs("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)]",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-4",children:s("groups:detail.info.metadata","Métadonnées")}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] uppercase tracking-wider mb-1",children:s("common.createdAt","Créé le")}),e.jsx("p",{className:"text-sm text-[var(--text-primary)]",children:new Date(h.createdAt).toLocaleString()})]}),h.updatedAt&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] uppercase tracking-wider mb-1",children:s("common.updatedAt","Modifié le")}),e.jsx("p",{className:"text-sm text-[var(--text-primary)]",children:new Date(h.updatedAt).toLocaleString()})]}),h.createdBy&&e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--bg-secondary)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] uppercase tracking-wider mb-1",children:s("common.createdBy","Créé par")}),e.jsx("p",{className:"text-sm text-[var(--text-primary)]",children:h.createdBy})]})]})]})]}),k==="hierarchy"&&x&&e.jsx(ut,{groupId:x,group:h,onRefresh:M,onSuccess:n=>{E(n),setTimeout(()=>E(null),3e3)},onError:R}),k==="members"&&x&&e.jsx(et,{groupId:x,groupName:h.name,isSyncedFromEntra:h.isSyncedFromEntra}),k==="roles"&&x&&e.jsx(Ve,{groupId:x,assignedRoles:h.roles||[],onSave:async()=>{await M(!0)},roles:j??[],loading:F,isGlobalScope:!0,adminTenants:o.map(n=>({tenantId:n.id,tenantSlug:n.slug,tenantName:n.name,tenantType:n.type}))}),k==="tenants"&&x&&e.jsx(Ze,{groupId:x,groupName:h.name}),k==="applications"&&x&&e.jsx(lt,{groupId:x}),k==="permissions"&&x&&e.jsx(ot,{groupId:x})]}):e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(t.AlertTriangle,{className:"w-12 h-12 mx-auto mb-4 text-[var(--warning-text)]"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:s("groups:detail.notFound","Groupe non trouvé")})]})})}exports.GroupDetailPage=pt;
|
|
4
|
-
//# sourceMappingURL=GroupDetailPage-
|
|
4
|
+
//# sourceMappingURL=GroupDetailPage-R-hf3rJ7.js.map
|