@atlashub/smartstack 3.21.0 → 3.24.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.
Files changed (280) hide show
  1. package/dist/chunks/{AgentSkillsPage-7si3Ng8e.js → AgentSkillsPage-BWQSCYl-.js} +2 -2
  2. package/dist/chunks/{AgentSkillsPage-7si3Ng8e.js.map → AgentSkillsPage-BWQSCYl-.js.map} +1 -1
  3. package/dist/chunks/{AgentSkillsPage-D0cD1QdM.js → AgentSkillsPage-IQcMnBaD.js} +2 -2
  4. package/dist/chunks/{AgentSkillsPage-D0cD1QdM.js.map → AgentSkillsPage-IQcMnBaD.js.map} +1 -1
  5. package/dist/chunks/{AgentWorkloadPage-H_7ze33H.js → AgentWorkloadPage-DqrjkvWL.js} +2 -2
  6. package/dist/chunks/{AgentWorkloadPage-H_7ze33H.js.map → AgentWorkloadPage-DqrjkvWL.js.map} +1 -1
  7. package/dist/chunks/{AgentWorkloadPage-D4d86cdV.js → AgentWorkloadPage-w-HiyFYP.js} +2 -2
  8. package/dist/chunks/{AgentWorkloadPage-D4d86cdV.js.map → AgentWorkloadPage-w-HiyFYP.js.map} +1 -1
  9. package/dist/chunks/{ApiCatalogDetailPage-2ktkRrCb.js → ApiCatalogDetailPage-D3L8Yf4G.js} +3 -3
  10. package/dist/chunks/{ApiCatalogDetailPage-2ktkRrCb.js.map → ApiCatalogDetailPage-D3L8Yf4G.js.map} +1 -1
  11. package/dist/chunks/{ApiCatalogDetailPage-BQ53xuwD.js → ApiCatalogDetailPage-MPT3Kz6H.js} +2 -2
  12. package/dist/chunks/{ApiCatalogDetailPage-BQ53xuwD.js.map → ApiCatalogDetailPage-MPT3Kz6H.js.map} +1 -1
  13. package/dist/chunks/{ApiCatalogPage-BEqTDJz8.js → ApiCatalogPage-D4Hg3uiS.js} +2 -2
  14. package/dist/chunks/{ApiCatalogPage-BEqTDJz8.js.map → ApiCatalogPage-D4Hg3uiS.js.map} +1 -1
  15. package/dist/chunks/{ApiCatalogPage-BBkWSLI8.js → ApiCatalogPage-DRg5Cz0r.js} +2 -2
  16. package/dist/chunks/{ApiCatalogPage-BBkWSLI8.js.map → ApiCatalogPage-DRg5Cz0r.js.map} +1 -1
  17. package/dist/chunks/{ApplicationDetailPage-BYJ2YMPq.js → ApplicationDetailPage-Caizuyn2.js} +2 -2
  18. package/dist/chunks/{ApplicationDetailPage-BYJ2YMPq.js.map → ApplicationDetailPage-Caizuyn2.js.map} +1 -1
  19. package/dist/chunks/{ApplicationDetailPage-D8-bf1as.js → ApplicationDetailPage-CuCW6aMB.js} +4 -4
  20. package/dist/chunks/{ApplicationDetailPage-D8-bf1as.js.map → ApplicationDetailPage-CuCW6aMB.js.map} +1 -1
  21. package/dist/chunks/{ApplicationsDashboardPage-BBlLms2r.js → ApplicationsDashboardPage-B2MW8-Kc.js} +2 -2
  22. package/dist/chunks/{ApplicationsDashboardPage-BBlLms2r.js.map → ApplicationsDashboardPage-B2MW8-Kc.js.map} +1 -1
  23. package/dist/chunks/{ApplicationsDashboardPage-DTWZxJJM.js → ApplicationsDashboardPage-BDIjFIYZ.js} +3 -3
  24. package/dist/chunks/{ApplicationsDashboardPage-DTWZxJJM.js.map → ApplicationsDashboardPage-BDIjFIYZ.js.map} +1 -1
  25. package/dist/chunks/{ApplicationsGridPage-BQaMsK1K.js → ApplicationsGridPage-DV-FihKj.js} +2 -2
  26. package/dist/chunks/{ApplicationsGridPage-BQaMsK1K.js.map → ApplicationsGridPage-DV-FihKj.js.map} +1 -1
  27. package/dist/chunks/{ApplicationsGridPage-DbVcvezt.js → ApplicationsGridPage-DXsTfXPI.js} +2 -2
  28. package/dist/chunks/{ApplicationsGridPage-DbVcvezt.js.map → ApplicationsGridPage-DXsTfXPI.js.map} +1 -1
  29. package/dist/chunks/{ApplicationsListPage-DYKM2Yeo.js → ApplicationsListPage--CGkyBuJ.js} +2 -2
  30. package/dist/chunks/{ApplicationsListPage-DYKM2Yeo.js.map → ApplicationsListPage--CGkyBuJ.js.map} +1 -1
  31. package/dist/chunks/{ApplicationsListPage-C91v2rZt.js → ApplicationsListPage-JUX823bh.js} +2 -2
  32. package/dist/chunks/{ApplicationsListPage-C91v2rZt.js.map → ApplicationsListPage-JUX823bh.js.map} +1 -1
  33. package/dist/chunks/{ApplicationsPage-BCbgotIx.js → ApplicationsPage-6zgFye6w.js} +2 -2
  34. package/dist/chunks/{ApplicationsPage-BCbgotIx.js.map → ApplicationsPage-6zgFye6w.js.map} +1 -1
  35. package/dist/chunks/{ApplicationsPage-CW3-Hjlu.js → ApplicationsPage-CQPuuiO6.js} +4 -4
  36. package/dist/chunks/{ApplicationsPage-CW3-Hjlu.js.map → ApplicationsPage-CQPuuiO6.js.map} +1 -1
  37. package/dist/chunks/{AssignmentRulesPage-D8vfGDBN.js → AssignmentRulesPage-CFffeEbo.js} +2 -2
  38. package/dist/chunks/{AssignmentRulesPage-D8vfGDBN.js.map → AssignmentRulesPage-CFffeEbo.js.map} +1 -1
  39. package/dist/chunks/{AssignmentRulesPage-CxktlEMB.js → AssignmentRulesPage-D78UeUId.js} +2 -2
  40. package/dist/chunks/{AssignmentRulesPage-CxktlEMB.js.map → AssignmentRulesPage-D78UeUId.js.map} +1 -1
  41. package/dist/chunks/{AssignmentsPage-DmfBYQAD.js → AssignmentsPage-Cww2ifZF.js} +2 -2
  42. package/dist/chunks/{AssignmentsPage-DmfBYQAD.js.map → AssignmentsPage-Cww2ifZF.js.map} +1 -1
  43. package/dist/chunks/{AssignmentsPage-sRCCBmRc.js → AssignmentsPage-DE_QS2LO.js} +2 -2
  44. package/dist/chunks/{AssignmentsPage-sRCCBmRc.js.map → AssignmentsPage-DE_QS2LO.js.map} +1 -1
  45. package/dist/chunks/{AuthCallbackPage-C7XiZxKb.js → AuthCallbackPage-CA2nO6DG.js} +2 -2
  46. package/dist/chunks/{AuthCallbackPage-C7XiZxKb.js.map → AuthCallbackPage-CA2nO6DG.js.map} +1 -1
  47. package/dist/chunks/{AuthCallbackPage-BCe_bwJM.js → AuthCallbackPage-CDUAoX-N.js} +2 -2
  48. package/dist/chunks/{AuthCallbackPage-BCe_bwJM.js.map → AuthCallbackPage-CDUAoX-N.js.map} +1 -1
  49. package/dist/chunks/{ConfirmEmailPage-BUfGSqxF.js → ConfirmEmailPage-BqsILAYH.js} +2 -2
  50. package/dist/chunks/{ConfirmEmailPage-BUfGSqxF.js.map → ConfirmEmailPage-BqsILAYH.js.map} +1 -1
  51. package/dist/chunks/{ConfirmEmailPage-Buj4x-rx.js → ConfirmEmailPage-INeHCuMB.js} +2 -2
  52. package/dist/chunks/{ConfirmEmailPage-Buj4x-rx.js.map → ConfirmEmailPage-INeHCuMB.js.map} +1 -1
  53. package/dist/chunks/{CreateSupportTicketPage-CKDX_HQm.js → CreateSupportTicketPage-BWeuV2aU.js} +2 -2
  54. package/dist/chunks/{CreateSupportTicketPage-CKDX_HQm.js.map → CreateSupportTicketPage-BWeuV2aU.js.map} +1 -1
  55. package/dist/chunks/{CreateSupportTicketPage-0LgY-_pu.js → CreateSupportTicketPage-OBwF4v7b.js} +2 -2
  56. package/dist/chunks/{CreateSupportTicketPage-0LgY-_pu.js.map → CreateSupportTicketPage-OBwF4v7b.js.map} +1 -1
  57. package/dist/chunks/{DashboardPage-CUZ80NGV.js → DashboardPage-CKHqWrdS.js} +3 -3
  58. package/dist/chunks/{DashboardPage-CUZ80NGV.js.map → DashboardPage-CKHqWrdS.js.map} +1 -1
  59. package/dist/chunks/{DashboardPage-CaNOAstg.js → DashboardPage-COmc9b__.js} +3 -3
  60. package/dist/chunks/{DashboardPage-CaNOAstg.js.map → DashboardPage-COmc9b__.js.map} +1 -1
  61. package/dist/chunks/{DashboardPage-B48_rQFi.js → DashboardPage-CfKZHiSj.js} +2 -2
  62. package/dist/chunks/{DashboardPage-B48_rQFi.js.map → DashboardPage-CfKZHiSj.js.map} +1 -1
  63. package/dist/chunks/{DashboardPage-CUZV1J9t.js → DashboardPage-CwEZZ3jx.js} +2 -2
  64. package/dist/chunks/{DashboardPage-CUZV1J9t.js.map → DashboardPage-CwEZZ3jx.js.map} +1 -1
  65. package/dist/chunks/{EscalationConfigPage-CdzAbnGy.js → EscalationConfigPage--7lgZ0kJ.js} +2 -2
  66. package/dist/chunks/{EscalationConfigPage-CdzAbnGy.js.map → EscalationConfigPage--7lgZ0kJ.js.map} +1 -1
  67. package/dist/chunks/{EscalationConfigPage-CYGIl_e6.js → EscalationConfigPage-DPyiBcqV.js} +2 -2
  68. package/dist/chunks/{EscalationConfigPage-CYGIl_e6.js.map → EscalationConfigPage-DPyiBcqV.js.map} +1 -1
  69. package/dist/chunks/{ForceChangePasswordPage-lRpkwcX7.js → ForceChangePasswordPage-BE-6umub.js} +2 -2
  70. package/dist/chunks/{ForceChangePasswordPage-lRpkwcX7.js.map → ForceChangePasswordPage-BE-6umub.js.map} +1 -1
  71. package/dist/chunks/{ForceChangePasswordPage-CvmYAV3r.js → ForceChangePasswordPage-CnsYoWmV.js} +2 -2
  72. package/dist/chunks/{ForceChangePasswordPage-CvmYAV3r.js.map → ForceChangePasswordPage-CnsYoWmV.js.map} +1 -1
  73. package/dist/chunks/{ForgotPasswordPage-0u49E4Pw.js → ForgotPasswordPage-CSq4DnFF.js} +2 -2
  74. package/dist/chunks/{ForgotPasswordPage-0u49E4Pw.js.map → ForgotPasswordPage-CSq4DnFF.js.map} +1 -1
  75. package/dist/chunks/{ForgotPasswordPage-CxQUqKOm.js → ForgotPasswordPage-DZLVolAC.js} +2 -2
  76. package/dist/chunks/{ForgotPasswordPage-CxQUqKOm.js.map → ForgotPasswordPage-DZLVolAC.js.map} +1 -1
  77. package/dist/chunks/{GroupDetailPage-DFBvVO1S.js → GroupDetailPage-Bf9Wb_2j.js} +5 -5
  78. package/dist/chunks/{GroupDetailPage-DFBvVO1S.js.map → GroupDetailPage-Bf9Wb_2j.js.map} +1 -1
  79. package/dist/chunks/{GroupDetailPage-B2FkKrGG.js → GroupDetailPage-R-hf3rJ7.js} +2 -2
  80. package/dist/chunks/{GroupDetailPage-B2FkKrGG.js.map → GroupDetailPage-R-hf3rJ7.js.map} +1 -1
  81. package/dist/chunks/{MyAccessRequestsPage-C9IX4c0K.js → MyAccessRequestsPage-BIisvWM6.js} +2 -2
  82. package/dist/chunks/{MyAccessRequestsPage-C9IX4c0K.js.map → MyAccessRequestsPage-BIisvWM6.js.map} +1 -1
  83. package/dist/chunks/{MyAccessRequestsPage-D6pVULNM.js → MyAccessRequestsPage-BLSV7Tbx.js} +2 -2
  84. package/dist/chunks/{MyAccessRequestsPage-D6pVULNM.js.map → MyAccessRequestsPage-BLSV7Tbx.js.map} +1 -1
  85. package/dist/chunks/{MyTenantsPage-BEcYYdGR.js → MyTenantsPage-D-7k9CP1.js} +3 -3
  86. package/dist/chunks/{MyTenantsPage-BEcYYdGR.js.map → MyTenantsPage-D-7k9CP1.js.map} +1 -1
  87. package/dist/chunks/{MyTenantsPage-D9f85zjF.js → MyTenantsPage-DqGW6aDt.js} +2 -2
  88. package/dist/chunks/{MyTenantsPage-D9f85zjF.js.map → MyTenantsPage-DqGW6aDt.js.map} +1 -1
  89. package/dist/chunks/{MyTicketsPage-DJR8h6y1.js → MyTicketsPage--DgDsnZA.js} +2 -2
  90. package/dist/chunks/{MyTicketsPage-DJR8h6y1.js.map → MyTicketsPage--DgDsnZA.js.map} +1 -1
  91. package/dist/chunks/{MyTicketsPage-DiOUExKJ.js → MyTicketsPage-CqJ3Aqob.js} +2 -2
  92. package/dist/chunks/{MyTicketsPage-DiOUExKJ.js.map → MyTicketsPage-CqJ3Aqob.js.map} +1 -1
  93. package/dist/chunks/{NavigationAppsPage-CeHbxfZw.js → NavigationAppsPage-Bebis_RT.js} +2 -2
  94. package/dist/chunks/{NavigationAppsPage-CeHbxfZw.js.map → NavigationAppsPage-Bebis_RT.js.map} +1 -1
  95. package/dist/chunks/{NavigationAppsPage-If7tmCFY.js → NavigationAppsPage-THNPOAjv.js} +2 -2
  96. package/dist/chunks/{NavigationAppsPage-If7tmCFY.js.map → NavigationAppsPage-THNPOAjv.js.map} +1 -1
  97. package/dist/chunks/{NotificationsPage-C29Lln5o.js → NotificationsPage-CAbNW_Cn.js} +2 -2
  98. package/dist/chunks/{NotificationsPage-C29Lln5o.js.map → NotificationsPage-CAbNW_Cn.js.map} +1 -1
  99. package/dist/chunks/{NotificationsPage-BiaLRb0s.js → NotificationsPage-DxwizUhL.js} +2 -2
  100. package/dist/chunks/{NotificationsPage-BiaLRb0s.js.map → NotificationsPage-DxwizUhL.js.map} +1 -1
  101. package/dist/chunks/{OnboardingWizardPage-DQrBKNBq.js → OnboardingWizardPage-C6HlbJ3K.js} +2 -2
  102. package/dist/chunks/{OnboardingWizardPage-DQrBKNBq.js.map → OnboardingWizardPage-C6HlbJ3K.js.map} +1 -1
  103. package/dist/chunks/{OnboardingWizardPage-BQah4cI8.js → OnboardingWizardPage-CyC2zONO.js} +2 -2
  104. package/dist/chunks/{OnboardingWizardPage-BQah4cI8.js.map → OnboardingWizardPage-CyC2zONO.js.map} +1 -1
  105. package/dist/chunks/{PermissionDetailPage-Ckjdjvf9.js → PermissionDetailPage-BDHiNgky.js} +2 -2
  106. package/dist/chunks/{PermissionDetailPage-Ckjdjvf9.js.map → PermissionDetailPage-BDHiNgky.js.map} +1 -1
  107. package/dist/chunks/{PermissionDetailPage-Dh8v7mGj.js → PermissionDetailPage-C5K17ydY.js} +2 -2
  108. package/dist/chunks/{PermissionDetailPage-Dh8v7mGj.js.map → PermissionDetailPage-C5K17ydY.js.map} +1 -1
  109. package/dist/chunks/{PermissionsPage-l0PnY-EE.js → PermissionsPage-COI5LJPo.js} +2 -2
  110. package/dist/chunks/{PermissionsPage-l0PnY-EE.js.map → PermissionsPage-COI5LJPo.js.map} +1 -1
  111. package/dist/chunks/{PermissionsPage-DLy9U3P3.js → PermissionsPage-CkOwH2_d.js} +2 -2
  112. package/dist/chunks/{PermissionsPage-DLy9U3P3.js.map → PermissionsPage-CkOwH2_d.js.map} +1 -1
  113. package/dist/chunks/{PortalDashboardPage-DFBx38-x.js → PortalDashboardPage-CoEC4CmC.js} +2 -2
  114. package/dist/chunks/{PortalDashboardPage-DFBx38-x.js.map → PortalDashboardPage-CoEC4CmC.js.map} +1 -1
  115. package/dist/chunks/{PortalDashboardPage-rQYhrX0q.js → PortalDashboardPage-DrYymEf-.js} +2 -2
  116. package/dist/chunks/{PortalDashboardPage-rQYhrX0q.js.map → PortalDashboardPage-DrYymEf-.js.map} +1 -1
  117. package/dist/chunks/{PreferencesPage-BBu8yZQB.js → PreferencesPage-CJRaU3ba.js} +2 -2
  118. package/dist/chunks/{PreferencesPage-BBu8yZQB.js.map → PreferencesPage-CJRaU3ba.js.map} +1 -1
  119. package/dist/chunks/{PreferencesPage-B81MsNV1.js → PreferencesPage-Cqr9mAab.js} +2 -2
  120. package/dist/chunks/{PreferencesPage-B81MsNV1.js.map → PreferencesPage-Cqr9mAab.js.map} +1 -1
  121. package/dist/chunks/{ProfilePage-DDrl10zj.js → ProfilePage-BZVpg6-l.js} +2 -2
  122. package/dist/chunks/{ProfilePage-DDrl10zj.js.map → ProfilePage-BZVpg6-l.js.map} +1 -1
  123. package/dist/chunks/{ProfilePage-DPoXwdnc.js → ProfilePage-Cu_FITeL.js} +2 -2
  124. package/dist/chunks/{ProfilePage-DPoXwdnc.js.map → ProfilePage-Cu_FITeL.js.map} +1 -1
  125. package/dist/chunks/{ReferencesManagementPage-eFsKjIEK.js → ReferencesManagementPage-DUlVk9Ps.js} +3 -3
  126. package/dist/chunks/{ReferencesManagementPage-eFsKjIEK.js.map → ReferencesManagementPage-DUlVk9Ps.js.map} +1 -1
  127. package/dist/chunks/{ReferencesManagementPage-DhVsuElE.js → ReferencesManagementPage-ZCuYtqd7.js} +2 -2
  128. package/dist/chunks/{ReferencesManagementPage-DhVsuElE.js.map → ReferencesManagementPage-ZCuYtqd7.js.map} +1 -1
  129. package/dist/chunks/{RegisterPage-CiQib3-6.js → RegisterPage-C4xmVwh9.js} +2 -2
  130. package/dist/chunks/{RegisterPage-CiQib3-6.js.map → RegisterPage-C4xmVwh9.js.map} +1 -1
  131. package/dist/chunks/{RegisterPage-bXCcJD88.js → RegisterPage-DGyzoIHT.js} +2 -2
  132. package/dist/chunks/{RegisterPage-bXCcJD88.js.map → RegisterPage-DGyzoIHT.js.map} +1 -1
  133. package/dist/chunks/{ResetPasswordPage-Dqiahhnj.js → ResetPasswordPage-DqDD6VPR.js} +2 -2
  134. package/dist/chunks/{ResetPasswordPage-Dqiahhnj.js.map → ResetPasswordPage-DqDD6VPR.js.map} +1 -1
  135. package/dist/chunks/{ResetPasswordPage-CubPG3yv.js → ResetPasswordPage-Glu-aeqv.js} +2 -2
  136. package/dist/chunks/{ResetPasswordPage-CubPG3yv.js.map → ResetPasswordPage-Glu-aeqv.js.map} +1 -1
  137. package/dist/chunks/{ResolutionModal-Bg7XZmR1.js → ResolutionModal-CxjANAOP.js} +2 -2
  138. package/dist/chunks/{ResolutionModal-Bg7XZmR1.js.map → ResolutionModal-CxjANAOP.js.map} +1 -1
  139. package/dist/chunks/{ResolutionModal-DqRk_T0n.js → ResolutionModal-Duat18qV.js} +2 -2
  140. package/dist/chunks/{ResolutionModal-DqRk_T0n.js.map → ResolutionModal-Duat18qV.js.map} +1 -1
  141. package/dist/chunks/{RoleDetailPage-Blau6_4c.js → RoleDetailPage-BQffUSnt.js} +3 -3
  142. package/dist/chunks/{RoleDetailPage-Blau6_4c.js.map → RoleDetailPage-BQffUSnt.js.map} +1 -1
  143. package/dist/chunks/{RoleDetailPage-CiRVxxIP.js → RoleDetailPage-JTm5lD1_.js} +2 -2
  144. package/dist/chunks/{RoleDetailPage-CiRVxxIP.js.map → RoleDetailPage-JTm5lD1_.js.map} +1 -1
  145. package/dist/chunks/{RolesPage-Pm-RN3lP.js → RolesPage-B9rRzciI.js} +2 -2
  146. package/dist/chunks/{RolesPage-Pm-RN3lP.js.map → RolesPage-B9rRzciI.js.map} +1 -1
  147. package/dist/chunks/{RolesPage-Cb8joqdJ.js → RolesPage-BN8_zMOC.js} +2 -2
  148. package/dist/chunks/{RolesPage-Cb8joqdJ.js.map → RolesPage-BN8_zMOC.js.map} +1 -1
  149. package/dist/chunks/{SlaConfigPage-B86McKM6.js → SlaConfigPage-B7kZNig4.js} +2 -2
  150. package/dist/chunks/{SlaConfigPage-B86McKM6.js.map → SlaConfigPage-B7kZNig4.js.map} +1 -1
  151. package/dist/chunks/{SlaConfigPage-BY7gvYU6.js → SlaConfigPage-okvZfA_K.js} +2 -2
  152. package/dist/chunks/{SlaConfigPage-BY7gvYU6.js.map → SlaConfigPage-okvZfA_K.js.map} +1 -1
  153. package/dist/chunks/{SupportPermissionsPage-BYxcLMSd.js → SupportPermissionsPage-DGAPqJbl.js} +2 -2
  154. package/dist/chunks/{SupportPermissionsPage-BYxcLMSd.js.map → SupportPermissionsPage-DGAPqJbl.js.map} +1 -1
  155. package/dist/chunks/{SupportPermissionsPage-MXqXNJIZ.js → SupportPermissionsPage-Dg_wLOme.js} +2 -2
  156. package/dist/chunks/{SupportPermissionsPage-MXqXNJIZ.js.map → SupportPermissionsPage-Dg_wLOme.js.map} +1 -1
  157. package/dist/chunks/{TemplatesPage-BDguJ401.js → TemplatesPage-DT9fhlAU.js} +2 -2
  158. package/dist/chunks/{TemplatesPage-BDguJ401.js.map → TemplatesPage-DT9fhlAU.js.map} +1 -1
  159. package/dist/chunks/{TemplatesPage-DdnGgioU.js → TemplatesPage-DiEk538p.js} +2 -2
  160. package/dist/chunks/{TemplatesPage-DdnGgioU.js.map → TemplatesPage-DiEk538p.js.map} +1 -1
  161. package/dist/chunks/{TenantCard-ffwWsgFQ.js → TenantCard-BbSYk9_Z.js} +2 -2
  162. package/dist/chunks/{TenantCard-ffwWsgFQ.js.map → TenantCard-BbSYk9_Z.js.map} +1 -1
  163. package/dist/chunks/{TenantCard-CUjb6og9.js → TenantCard-CEkiKxcZ.js} +2 -2
  164. package/dist/chunks/{TenantCard-CUjb6og9.js.map → TenantCard-CEkiKxcZ.js.map} +1 -1
  165. package/dist/chunks/{TenantScopeSelector-Dz7i1I43.js → TenantScopeSelector-BWfYxvEa.js} +2 -2
  166. package/dist/chunks/{TenantScopeSelector-Dz7i1I43.js.map → TenantScopeSelector-BWfYxvEa.js.map} +1 -1
  167. package/dist/chunks/{TenantScopeSelector-Cym_Zyps.js → TenantScopeSelector-D-BKgQPV.js} +2 -2
  168. package/dist/chunks/{TenantScopeSelector-Cym_Zyps.js.map → TenantScopeSelector-D-BKgQPV.js.map} +1 -1
  169. package/dist/chunks/{TicketDetailPage-GOh9GX7E.js → TicketDetailPage-C1mNS9Up.js} +2 -2
  170. package/dist/chunks/{TicketDetailPage-GOh9GX7E.js.map → TicketDetailPage-C1mNS9Up.js.map} +1 -1
  171. package/dist/chunks/{TicketDetailPage-Du8WMyqf.js → TicketDetailPage-ieVDRh42.js} +2 -2
  172. package/dist/chunks/{TicketDetailPage-Du8WMyqf.js.map → TicketDetailPage-ieVDRh42.js.map} +1 -1
  173. package/dist/chunks/{TicketsPage-Bqd6moQy.js → TicketsPage-CnuWsnIW.js} +2 -2
  174. package/dist/chunks/{TicketsPage-Bqd6moQy.js.map → TicketsPage-CnuWsnIW.js.map} +1 -1
  175. package/dist/chunks/{TicketsPage-WdU4Bb7M.js → TicketsPage-jjyY15_D.js} +2 -2
  176. package/dist/chunks/{TicketsPage-WdU4Bb7M.js.map → TicketsPage-jjyY15_D.js.map} +1 -1
  177. package/dist/chunks/{UserCreateTicketPage-Cm1emgwR.js → UserCreateTicketPage-B8Tvf-ag.js} +2 -2
  178. package/dist/chunks/{UserCreateTicketPage-Cm1emgwR.js.map → UserCreateTicketPage-B8Tvf-ag.js.map} +1 -1
  179. package/dist/chunks/{UserCreateTicketPage-BPw-5Y_D.js → UserCreateTicketPage-DnOsDlfO.js} +2 -2
  180. package/dist/chunks/{UserCreateTicketPage-BPw-5Y_D.js.map → UserCreateTicketPage-DnOsDlfO.js.map} +1 -1
  181. package/dist/chunks/{UserDashboardPage-BP5WeXPS.js → UserDashboardPage-BrtkJ-NB.js} +2 -2
  182. package/dist/chunks/{UserDashboardPage-BP5WeXPS.js.map → UserDashboardPage-BrtkJ-NB.js.map} +1 -1
  183. package/dist/chunks/{UserDashboardPage-B53C8fUq.js → UserDashboardPage-KLB5CQP5.js} +2 -2
  184. package/dist/chunks/{UserDashboardPage-B53C8fUq.js.map → UserDashboardPage-KLB5CQP5.js.map} +1 -1
  185. package/dist/chunks/{UserDetailPage-B110bmGX.js → UserDetailPage-U7smBQoF.js} +5 -5
  186. package/dist/chunks/{UserDetailPage-B110bmGX.js.map → UserDetailPage-U7smBQoF.js.map} +1 -1
  187. package/dist/chunks/{UserDetailPage-CV2VCE46.js → UserDetailPage-_J6lcKAU.js} +2 -2
  188. package/dist/chunks/{UserDetailPage-CV2VCE46.js.map → UserDetailPage-_J6lcKAU.js.map} +1 -1
  189. package/dist/chunks/{UserTicketDetailPage-CCNJON1V.js → UserTicketDetailPage-CWoYQgH-.js} +2 -2
  190. package/dist/chunks/{UserTicketDetailPage-CCNJON1V.js.map → UserTicketDetailPage-CWoYQgH-.js.map} +1 -1
  191. package/dist/chunks/{UserTicketDetailPage-V0mLXrox.js → UserTicketDetailPage-DkufSlvZ.js} +2 -2
  192. package/dist/chunks/{UserTicketDetailPage-V0mLXrox.js.map → UserTicketDetailPage-DkufSlvZ.js.map} +1 -1
  193. package/dist/chunks/{UsersGroupsPage-CmdaU-z-.js → UsersGroupsPage-C38s2-Rq.js} +3 -3
  194. package/dist/chunks/{UsersGroupsPage-CmdaU-z-.js.map → UsersGroupsPage-C38s2-Rq.js.map} +1 -1
  195. package/dist/chunks/{UsersGroupsPage-BgfAMgEP.js → UsersGroupsPage-Dq3rAteo.js} +2 -2
  196. package/dist/chunks/{UsersGroupsPage-BgfAMgEP.js.map → UsersGroupsPage-Dq3rAteo.js.map} +1 -1
  197. package/dist/chunks/{UsersPage-Bg7033pp.js → UsersPage-B5C5KEUR.js} +2 -2
  198. package/dist/chunks/{UsersPage-Bg7033pp.js.map → UsersPage-B5C5KEUR.js.map} +1 -1
  199. package/dist/chunks/{UsersPage-TYAfwPY1.js → UsersPage-CXC9Hvq6.js} +2 -2
  200. package/dist/chunks/{UsersPage-TYAfwPY1.js.map → UsersPage-CXC9Hvq6.js.map} +1 -1
  201. package/dist/chunks/{accessRequestsApi-DZeDvzwv.js → accessRequestsApi-B-4TJ5_U.js} +2 -2
  202. package/dist/chunks/{accessRequestsApi-DZeDvzwv.js.map → accessRequestsApi-B-4TJ5_U.js.map} +1 -1
  203. package/dist/chunks/{accessRequestsApi-ZXFPCid2.js → accessRequestsApi-DZSfThpd.js} +2 -2
  204. package/dist/chunks/{accessRequestsApi-ZXFPCid2.js.map → accessRequestsApi-DZSfThpd.js.map} +1 -1
  205. package/dist/chunks/{aiApi-CsH8DXgs.js → aiApi-B20Teu2v.js} +2 -2
  206. package/dist/chunks/{aiApi-CsH8DXgs.js.map → aiApi-B20Teu2v.js.map} +1 -1
  207. package/dist/chunks/{aiApi-CVPzFTXa.js → aiApi-DMGz-RPM.js} +2 -2
  208. package/dist/chunks/{aiApi-CVPzFTXa.js.map → aiApi-DMGz-RPM.js.map} +1 -1
  209. package/dist/chunks/{applicationAnalyticsApi-B8AhFYLr.js → applicationAnalyticsApi-Bwa75Fzd.js} +2 -2
  210. package/dist/chunks/{applicationAnalyticsApi-B8AhFYLr.js.map → applicationAnalyticsApi-Bwa75Fzd.js.map} +1 -1
  211. package/dist/chunks/{applicationAnalyticsApi-Ce_1qOk-.js → applicationAnalyticsApi-CLBqRPfN.js} +2 -2
  212. package/dist/chunks/{applicationAnalyticsApi-Ce_1qOk-.js.map → applicationAnalyticsApi-CLBqRPfN.js.map} +1 -1
  213. package/dist/chunks/{groupsApi-BgCk2fsp.js → groupsApi-QzXI-5xu.js} +2 -2
  214. package/dist/chunks/{groupsApi-BgCk2fsp.js.map → groupsApi-QzXI-5xu.js.map} +1 -1
  215. package/dist/chunks/{groupsApi-BIbG665N.js → groupsApi-hB9kSWEd.js} +2 -2
  216. package/dist/chunks/{groupsApi-BIbG665N.js.map → groupsApi-hB9kSWEd.js.map} +1 -1
  217. package/dist/chunks/{index-Cb3LotuT.js → index--NGcBYUu.js} +3 -3
  218. package/dist/chunks/{index-Cb3LotuT.js.map → index--NGcBYUu.js.map} +1 -1
  219. package/dist/chunks/{index-C33zcyF4.js → index--aPwOFjF.js} +2 -2
  220. package/dist/chunks/{index-C33zcyF4.js.map → index--aPwOFjF.js.map} +1 -1
  221. package/dist/chunks/{index-sMr9qND_.js → index-0VrOtwP0.js} +2 -2
  222. package/dist/chunks/{index-sMr9qND_.js.map → index-0VrOtwP0.js.map} +1 -1
  223. package/dist/chunks/{index-DDKetfKq.js → index-37U271aw.js} +2 -2
  224. package/dist/chunks/{index-DDKetfKq.js.map → index-37U271aw.js.map} +1 -1
  225. package/dist/chunks/{index-B9fS7ir6.js → index-B7qZTuQ-.js} +2 -2
  226. package/dist/chunks/{index-B9fS7ir6.js.map → index-B7qZTuQ-.js.map} +1 -1
  227. package/dist/chunks/{index-CdjBY7L8.js → index-Bedzmqr-.js} +2 -2
  228. package/dist/chunks/{index-CdjBY7L8.js.map → index-Bedzmqr-.js.map} +1 -1
  229. package/dist/chunks/{index-CHG_O1fS.js → index-Betxo5g5.js} +2 -2
  230. package/dist/chunks/{index-CHG_O1fS.js.map → index-Betxo5g5.js.map} +1 -1
  231. package/dist/chunks/{index-jiGu-H8x.js → index-BmaJz475.js} +2 -2
  232. package/dist/chunks/{index-jiGu-H8x.js.map → index-BmaJz475.js.map} +1 -1
  233. package/dist/chunks/{index-C53JoVNk.js → index-Buhqag3v.js} +2 -2
  234. package/dist/chunks/{index-C53JoVNk.js.map → index-Buhqag3v.js.map} +1 -1
  235. package/dist/chunks/{index-DO0Rw7hX.js → index-C3VxlfKq.js} +2 -2
  236. package/dist/chunks/{index-DO0Rw7hX.js.map → index-C3VxlfKq.js.map} +1 -1
  237. package/dist/chunks/{index-CSQ60fpG.js → index-CgpRo8Oe.js} +2 -2
  238. package/dist/chunks/{index-CSQ60fpG.js.map → index-CgpRo8Oe.js.map} +1 -1
  239. package/dist/chunks/{index-B-e-ELsf.js → index-DOY0w8Iu.js} +8 -8
  240. package/dist/chunks/{index-B-e-ELsf.js.map → index-DOY0w8Iu.js.map} +1 -1
  241. package/dist/chunks/{index-D2REDIRX.js → index-DwuvIOrQ.js} +2 -2
  242. package/dist/chunks/{index-D2REDIRX.js.map → index-DwuvIOrQ.js.map} +1 -1
  243. package/dist/chunks/{index-DCcl7Qof.js → index-DzedSLdI.js} +2 -2
  244. package/dist/chunks/{index-DCcl7Qof.js.map → index-DzedSLdI.js.map} +1 -1
  245. package/dist/chunks/{index-2wUhd9Lu.js → index-IgLVXPg8.js} +10 -10
  246. package/dist/chunks/index-IgLVXPg8.js.map +1 -0
  247. package/dist/chunks/{index-CwSaRXXg.js → index-lpIzhufD.js} +1916 -1900
  248. package/dist/chunks/index-lpIzhufD.js.map +1 -0
  249. package/dist/chunks/{index-Cuwn2q-f.js → index-mLUKwbGl.js} +4 -4
  250. package/dist/chunks/{index-Cuwn2q-f.js.map → index-mLUKwbGl.js.map} +1 -1
  251. package/dist/chunks/{index-B0mk2tNY.js → index-tO6MMIFB.js} +2 -2
  252. package/dist/chunks/{index-B0mk2tNY.js.map → index-tO6MMIFB.js.map} +1 -1
  253. package/dist/chunks/{tenantIconMap-BpNANQ5s.js → tenantIconMap-BQD9byc8.js} +2 -2
  254. package/dist/chunks/{tenantIconMap-BpNANQ5s.js.map → tenantIconMap-BQD9byc8.js.map} +1 -1
  255. package/dist/chunks/{tenantIconMap-DtdUgvJO.js → tenantIconMap-CTMuSt18.js} +2 -2
  256. package/dist/chunks/{tenantIconMap-DtdUgvJO.js.map → tenantIconMap-CTMuSt18.js.map} +1 -1
  257. package/dist/chunks/{ticketingApi-Bu4rKwLl.js → ticketingApi-BNIdox5t.js} +2 -2
  258. package/dist/chunks/{ticketingApi-Bu4rKwLl.js.map → ticketingApi-BNIdox5t.js.map} +1 -1
  259. package/dist/chunks/{ticketingApi-r4Avm9iS.js → ticketingApi-J0vC_t7r.js} +2 -2
  260. package/dist/chunks/{ticketingApi-r4Avm9iS.js.map → ticketingApi-J0vC_t7r.js.map} +1 -1
  261. package/dist/chunks/{useAccessRequests-B9bF4swg.js → useAccessRequests-DCNNLnxk.js} +3 -3
  262. package/dist/chunks/{useAccessRequests-B9bF4swg.js.map → useAccessRequests-DCNNLnxk.js.map} +1 -1
  263. package/dist/chunks/{useAccessRequests-JyPUX3Om.js → useAccessRequests-DT7X4FAK.js} +2 -2
  264. package/dist/chunks/{useAccessRequests-JyPUX3Om.js.map → useAccessRequests-DT7X4FAK.js.map} +1 -1
  265. package/dist/chunks/{useUserAccessRequests-DjPQenC2.js → useUserAccessRequests-BYbmG4c7.js} +2 -2
  266. package/dist/chunks/{useUserAccessRequests-DjPQenC2.js.map → useUserAccessRequests-BYbmG4c7.js.map} +1 -1
  267. package/dist/chunks/{useUserAccessRequests-BB6FHW14.js → useUserAccessRequests-CylKxRN6.js} +2 -2
  268. package/dist/chunks/{useUserAccessRequests-BB6FHW14.js.map → useUserAccessRequests-CylKxRN6.js.map} +1 -1
  269. package/dist/hooks/useCollapsibleState.d.ts +5 -2
  270. package/dist/hooks/useCollapsibleState.d.ts.map +1 -1
  271. package/dist/i18n/config.d.ts +1 -0
  272. package/dist/i18n/config.d.ts.map +1 -1
  273. package/dist/main.d.ts +0 -1
  274. package/dist/main.d.ts.map +1 -1
  275. package/dist/smartstack.cjs +1 -1
  276. package/dist/smartstack.js +1 -1
  277. package/dist/utils/permissions.d.ts.map +1 -1
  278. package/package.json +1 -1
  279. package/dist/chunks/index-2wUhd9Lu.js.map +0 -1
  280. package/dist/chunks/index-CwSaRXXg.js.map +0 -1
@@ -1,5 +1,5 @@
1
- "use strict";const e=require("react/jsx-runtime"),n=require("react"),cs=require("axios"),ne=require("react-i18next"),jt=require("i18next"),Xa=require("i18next-browser-languagedetector"),w=require("react-router-dom"),Ya=require("@microsoft/signalr"),l=require("lucide-react"),ur=require("react-error-boundary"),Ot=require("react-dom"),As=require("modern-screenshot"),gt=require("react-resizable-panels"),Ja=require("dompurify");function mr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const oe=mr(Ya),xt=mr(l),Qe={none:"0px",small:"4px",medium:"8px",large:"12px",xlarge:"16px",xxlarge:"24px"},Qa={none:"Carré",small:"Léger",medium:"Moyen",large:"Arrondi",xlarge:"Très arrondi",xxlarge:"Pill"},_e={slate:{name:"Ardoise",shades:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"}},gray:{name:"Gris",shades:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"}},zinc:{name:"Zinc",shades:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"}},stone:{name:"Pierre",shades:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"}},indigo:{name:"Indigo",shades:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"}},violet:{name:"Violet",shades:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"}},blue:{name:"Bleu",shades:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"}},cyan:{name:"Cyan",shades:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"}},teal:{name:"Teal",shades:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"}},emerald:{name:"Émeraude",shades:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"}},amber:{name:"Ambre",shades:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"}},orange:{name:"Orange",shades:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"}},rose:{name:"Rose",shades:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},pink:{name:"Pink",shades:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"}}},Za={card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},ut={neutral:{name:"Neutre",icon:"⚪",colors:{light:{light:"#ffffff",medium:"#f4f4f5",dark:"#e4e4e7",border:"#d4d4d8"},dark:{light:"#1c1c1f",medium:"#27272a",dark:"#3f3f46",border:"#52525b"}}},ocean:{name:"Océan",icon:"🌊",colors:{light:{light:"#e0f2fe",medium:"#bae6fd",dark:"#7dd3fc",border:"#93c5fd"},dark:{light:"#141c24",medium:"#1a2836",dark:"#2a4a5e",border:"#3a5a70"}}},forest:{name:"Forêt",icon:"🌲",colors:{light:{light:"#d1fae5",medium:"#a7f3d0",dark:"#6ee7b7",border:"#86efac"},dark:{light:"#121d18",medium:"#182a22",dark:"#2a4a3a",border:"#3a5a4a"}}},sunset:{name:"Coucher de soleil",icon:"🌅",colors:{light:{light:"#fef3c7",medium:"#fde68a",dark:"#fbbf24",border:"#fcd34d"},dark:{light:"#1c1810",medium:"#2a2418",dark:"#4a3a24",border:"#5a4a34"}}},lavender:{name:"Lavande",icon:"💜",colors:{light:{light:"#ede9fe",medium:"#ddd6fe",dark:"#c4b5fd",border:"#c4b5fd"},dark:{light:"#1a1820",medium:"#24222e",dark:"#3a3650",border:"#4a4660"}}},rose:{name:"Rose",icon:"🌸",colors:{light:{light:"#fce7f3",medium:"#fbcfe8",dark:"#f9a8d4",border:"#f9a8d4"},dark:{light:"#1c1418",medium:"#2a1e24",dark:"#4a3040",border:"#5a4050"}}}},ds="neutral",mt=t=>{const s=_e[t]?.shades||_e.indigo.shades;return{name:"Clair",primary:_e.indigo.shades,accent:s,backgrounds:{app:"#fafafa",primary:"#ffffff",secondary:"#f4f4f5",tertiary:"#e4e4e7",card:"#ffffff",hover:"#f4f4f5",active:"#e4e4e7"},text:{primary:"#18181b",secondary:"#52525b",tertiary:"#71717a",muted:"#a1a1aa",inverse:"#fafafa"},border:{default:"#e4e4e7",subtle:"#f4f4f5",strong:"#d4d4d8"},status:{success:{bg:"#f0fdfa",text:"#0f766e",border:"#99f6e4",dot:"#14b8a6"},warning:{bg:"#fffbeb",text:"#b45309",border:"#fde68a",dot:"#f59e0b"},error:{bg:"#fff1f2",text:"#be123c",border:"#fecdd3",dot:"#f43f5e"},info:{bg:"#f0f9ff",text:"#0369a1",border:"#bae6fd",dot:"#0ea5e9"}},accentTransparent:{bg:`${s[50]}`,text:s[700],border:s[200]}}},pt=t=>{const s=_e[t]?.shades||_e.indigo.shades;return{name:"Sombre",primary:_e.indigo.shades,accent:s,backgrounds:{app:"#161618",primary:"#1c1c1f",secondary:"#232326",tertiary:"#2a2a2e",card:"#1c1c1f",hover:"#27272a",active:"#3f3f46"},text:{primary:"#fafafa",secondary:"#d4d4d8",tertiary:"#a1a1aa",muted:"#71717a",inverse:"#18181b"},border:{default:"#3f3f46",subtle:"#27272a",strong:"#52525b"},status:{success:{bg:"rgba(20, 184, 166, 0.15)",text:"#5eead4",border:"rgba(20, 184, 166, 0.3)",dot:"#14b8a6"},warning:{bg:"rgba(245, 158, 11, 0.15)",text:"#fbbf24",border:"rgba(245, 158, 11, 0.3)",dot:"#f59e0b"},error:{bg:"rgba(244, 63, 94, 0.15)",text:"#fb7185",border:"rgba(244, 63, 94, 0.3)",dot:"#f43f5e"},info:{bg:"rgba(14, 165, 233, 0.15)",text:"#7dd3fc",border:"rgba(14, 165, 233, 0.3)",dot:"#0ea5e9"}},accentTransparent:{bg:`rgba(${Ps(s[500])}, 0.15)`,text:s[300],border:`rgba(${Ps(s[500])}, 0.3)`}}};function Ps(t){const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return s?`${parseInt(s[1],16)}, ${parseInt(s[2],16)}, ${parseInt(s[3],16)}`:"99, 102, 241"}const yt={mode:"dark",borderRadius:Za,colors:{light:mt("indigo"),dark:pt("indigo")},accentColorKey:"indigo",itemPaletteKey:ds},en=[{id:"default",name:"Par défaut",description:"Style SmartStack classique avec coins arrondis",icon:"✨",config:{borderRadius:{card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"indigo",itemPaletteKey:"neutral"}},{id:"minimal",name:"Minimal",description:"Style épuré et professionnel",icon:"⚪",config:{borderRadius:{card:"medium",button:"small",badge:"small",input:"small",modal:"medium",menuItem:"small"},accentColorKey:"slate",itemPaletteKey:"neutral"}},{id:"corporate",name:"Corporate",description:"Style sobre pour environnement professionnel",icon:"🏢",config:{borderRadius:{card:"small",button:"small",badge:"medium",input:"small",modal:"medium",menuItem:"small"},accentColorKey:"gray",itemPaletteKey:"neutral"}},{id:"ocean",name:"Océan",description:"Teintes bleues apaisantes",icon:"🌊",config:{borderRadius:{card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"cyan",itemPaletteKey:"ocean"}},{id:"forest",name:"Forêt",description:"Tons verts naturels",icon:"🌲",config:{borderRadius:{card:"medium",button:"medium",badge:"medium",input:"medium",modal:"large",menuItem:"medium"},accentColorKey:"emerald",itemPaletteKey:"forest"}},{id:"sunset",name:"Coucher de soleil",description:"Couleurs chaudes et accueillantes",icon:"🌅",config:{borderRadius:{card:"large",button:"large",badge:"xxlarge",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"orange",itemPaletteKey:"sunset"}},{id:"lavender",name:"Lavande",description:"Tons violets élégants",icon:"💜",config:{borderRadius:{card:"xlarge",button:"large",badge:"xlarge",input:"large",modal:"xlarge",menuItem:"large"},accentColorKey:"violet",itemPaletteKey:"lavender"}},{id:"rose",name:"Rose",description:"Teintes roses douces",icon:"🌸",config:{borderRadius:{card:"xxlarge",button:"xlarge",badge:"xxlarge",input:"large",modal:"xxlarge",menuItem:"large"},accentColorKey:"pink",itemPaletteKey:"rose"}}],pr="smartstack-theme-config";class Tt extends Error{statusCode;details;constructor(s,r,a){super(s),this.name="AppError",this.statusCode=r,this.details=a}}class us extends Error{constructor(s="Network error occurred"){super(s),this.name="NetworkError"}}class xr extends Error{code;constructor(s="Authentication required",r){super(s),this.name="AuthenticationError",this.code=r}}class tn extends Error{constructor(s="Access denied"){super(s),this.name="ForbiddenError"}}const sn=10;class rn{queue=[];recentErrors=[];isProcessing=!1;batchSize=10;batchDelay=2e3;async logError(s,r,a){const o=typeof s=="string"?s:s.message;let c=o;if(a?.url){const d=String(a.url),u=a.status?` [${a.status}]`:"";c=`${o}${u} - ${d}`}const i={message:c,stack:typeof s=="string"?void 0:s.stack,url:window.location.href,component:r,level:"Error",metadata:a};this.storeRecentError(i),this.queue.push({type:"error",data:i}),this.processQueue()}async logCritical(s,r,a){const o=typeof s=="string"?s:s.message;let c=o;if(a?.url){const u=String(a.url),m=a.status?` [${a.status}]`:"";c=`${o}${m} - ${u}`}const i={message:c,stack:typeof s=="string"?void 0:s.stack,url:window.location.href,component:r,level:"Critical",metadata:a};return this.storeRecentError(i),await this.sendErrorWithResponse(i)}getRecentErrors(){return[...this.recentErrors]}clearRecentErrors(){this.recentErrors=[]}storeRecentError(s){this.recentErrors.unshift({...s,timestamp:new Date}),this.recentErrors.length>sn&&this.recentErrors.pop()}async logEvent(s,r,a){const o={event:s,category:r,data:a};this.queue.push({type:"event",data:o}),this.processQueue()}async processQueue(){if(this.isProcessing||this.queue.length===0)return;this.isProcessing=!0,await new Promise(r=>setTimeout(r,this.batchDelay));const s=this.queue.splice(0,this.batchSize);for(const r of s)try{r.type==="error"?await this.sendError(r.data):await this.sendEvent(r.data)}catch{}this.isProcessing=!1,this.queue.length>0&&this.processQueue()}async sendError(s){const r=localStorage.getItem("token");await fetch("/api/logs/client-error",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)})}async sendErrorWithResponse(s){const r=localStorage.getItem("token");try{const a=await fetch("/api/logs/client-error",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)});return a.ok&&a.status===200&&(await a.json()).ticketNumber||null}catch{return null}}async sendEvent(s){const r=localStorage.getItem("token");await fetch("/api/logs/client-event",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)})}}const Te=new rn;window.onerror=(t,s,r,a,o)=>{Te.logError(o||String(t),"window.onerror",{source:s,lineno:r,colno:a})};window.onunhandledrejection=t=>{Te.logError(t.reason instanceof Error?t.reason:String(t.reason),"unhandledrejection")};const Se=cs.create({timeout:3e4,headers:{"Content-Type":"application/json"}});Se.interceptors.request.use(t=>{const s=localStorage.getItem("token");s&&t.headers&&(t.headers.Authorization=`Bearer ${s}`);const r=crypto.randomUUID();t.headers&&(t.headers["X-Correlation-ID"]=r);const a=localStorage.getItem("i18nextLng")||navigator.language||"fr";t.headers&&(t.headers["Accept-Language"]=a);const o=localStorage.getItem("currentTenantSlug");return o&&t.headers&&!t.headers["X-Tenant-Slug"]&&(t.headers["X-Tenant-Slug"]=o),t},t=>(Te.logError(t,"apiClient.request"),Promise.reject(t)));Se.interceptors.response.use(t=>t,async t=>{const s=t.config?.headers?.["X-Correlation-ID"];if(cs.isCancel(t)||t.code==="ERR_CANCELED")return Promise.reject(t);if(!t.response){const i=new us("Impossible de se connecter au serveur. Vérifiez votre connexion internet.");return Te.logError(i,"apiClient.response",{correlationId:s}),Promise.reject(i)}const{status:r,data:a}=t.response,o=a?.message||a?.detail||a?.title||t.message,c=a?.code;switch(r){case 401:{const i=new xr(o,c);Te.logError(i,"apiClient.response",{correlationId:s,url:t.config?.url,code:c});const d=t.config?.url||"",m=["/api/user/preferences","/api/auth/session-info","/api/auth/refresh","/api/navigation/menu","/api/navigation/favorites","/api/navigation/contexts","/api/onboarding/status","/api/administration/tenants/tenant-analytics/track/"].some(p=>d.startsWith(p));if(!window.location.pathname.includes("/login")&&!m){localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user");const f=c==="SESSION_EXPIRED"?"/login?reason=session_expired":"/login";window.location.href=f}return Promise.reject(i)}case 403:{const i=new tn(o),d=["/api/administration/tenants/tenant-analytics/track/","/api/support/notifications"],u=t.config?.url||"";return d.some(p=>u.startsWith(p))||Te.logError(i,"apiClient.response",{correlationId:s,url:t.config?.url,method:t.config?.method}),Promise.reject(i)}case 404:return Promise.reject(new Tt(o||"Resource not found",r));case 400:return Promise.reject(new Tt(o||"Invalid request",r,a?.details||a?.errors));case 500:case 502:case 503:case 504:{const i=new Tt(o||"Server error",r);return Te.logCritical(i,"apiClient.response",{correlationId:s,url:t.config?.url,status:r}),Promise.reject(i)}default:{const i=new Tt(o,r,a?.details);return Te.logError(i,"apiClient.response",{correlationId:s,status:r}),Promise.reject(i)}}});const E={get:(t,s)=>Se.get(t,s).then(r=>r.data),post:(t,s,r)=>Se.post(t,s,r).then(a=>a.data),put:(t,s,r)=>Se.put(t,s,r).then(a=>a.data),patch:(t,s,r)=>Se.patch(t,s,r).then(a=>a.data),delete:(t,s)=>Se.delete(t,s).then(r=>r.data)},Ft={preferences:{get:()=>E.get("/api/user/preferences"),updateTheme:t=>E.put("/api/user/preferences/theme",t),updateLanguage:t=>E.put("/api/user/preferences/language",t),updateNotifications:t=>E.put("/api/user/preferences/notifications",t)},dashboard:{getAll:(t=30,s=10)=>E.get(`/api/user/dashboard/all?period=${t}&errorLimit=${s}`),getSessionAnalytics:(t=30)=>E.get(`/api/user/dashboard/session-analytics?period=${t}`),getLoginErrors:(t=10)=>E.get(`/api/user/dashboard/login-errors?limit=${t}`),getCurrentSession:()=>E.get("/api/user/dashboard/current-session"),getDeviceStats:()=>E.get("/api/user/dashboard/device-stats"),getWeeklyStats:(t=30)=>E.get(`/api/user/dashboard/weekly-stats?period=${t}`),getHourlyStats:(t=30)=>E.get(`/api/user/dashboard/hourly-stats?period=${t}`),getApplicationUsage:(t=30)=>E.get(`/api/user/dashboard/application-usage?period=${t}`)}},an=t=>({get:(s,r)=>Se.get(s,{...r,headers:t?{...r?.headers,"X-Tenant-Slug":t}:r?.headers}).then(a=>a.data),post:(s,r,a)=>Se.post(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),put:(s,r,a)=>Se.put(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),patch:(s,r,a)=>Se.patch(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),delete:(s,r)=>Se.delete(s,{...r,headers:t?{...r?.headers,"X-Tenant-Slug":t}:r?.headers}).then(a=>a.data)}),nn={PasswordResetMalfunction:1,FalsePositive:2,UrgentBusinessNeed:3,TechnicalSystemError:4,SupportTicketVerified:5},on=t=>({getAll:s=>t.get("/api/administration/users",{params:s}),getById:s=>t.get(`/api/administration/users/${s}`),create:s=>t.post("/api/administration/users",s),update:(s,r)=>t.put(`/api/administration/users/${s}`,r),sendPasswordResetLink:s=>t.post(`/api/administration/users/${s}/send-password-reset`),resetPasswordDirect:(s,r)=>t.post(`/api/administration/users/${s}/reset-password-direct`,r?{temporaryPassword:r}:{}),activate:s=>t.patch(`/api/administration/users/${s}/activate`),deactivate:s=>t.patch(`/api/administration/users/${s}/deactivate`),unlock:(s,r)=>t.post(`/api/administration/users/${s}/unlock`,r),clearFailedAttempts:s=>t.post(`/api/administration/users/${s}/clear-failed-attempts`),delete:s=>t.delete(`/api/administration/users/${s}`),getSessions:s=>t.get(`/api/administration/users/${s}/sessions`),endAllSessions:s=>t.post(`/api/administration/users/${s}/sessions/end-all`),endSession:(s,r)=>t.delete(`/api/administration/users/${s}/sessions/${r}`),getActivity:s=>t.get(`/api/administration/users/${s}/activity`),getCustomRole:s=>t.get(`/api/administration/users/${s}/custom-role`),createCustomRole:s=>t.post(`/api/administration/users/${s}/custom-role`),deleteCustomRole:s=>t.delete(`/api/administration/users/${s}/custom-role`),getHistory:(s,r=50)=>t.get(`/api/administration/users/${s}/history`,{params:{limit:r}}),restoreFromHistory:(s,r)=>t.post(`/api/administration/users/${s}/history/${r}/restore`),getOrganizationReferences:()=>t.get("/api/administration/users/organization-references"),references:{getCompanies:s=>t.get("/api/administration/users/references/companies",{params:s}),getDepartments:s=>t.get("/api/administration/users/references/departments",{params:s}),getJobTitles:s=>t.get("/api/administration/users/references/job-titles",{params:s}),getOffices:s=>t.get("/api/administration/users/references/offices",{params:s}),createCompany:(s,r)=>t.post(`/api/administration/users/references/companies${r?`?tenantId=${r}`:""}`,s),createDepartment:(s,r)=>t.post(`/api/administration/users/references/departments${r?`?tenantId=${r}`:""}`,s),createJobTitle:(s,r)=>t.post(`/api/administration/users/references/job-titles${r?`?tenantId=${r}`:""}`,s),createOffice:(s,r)=>t.post(`/api/administration/users/references/offices${r?`?tenantId=${r}`:""}`,s),updateCompany:(s,r)=>t.put(`/api/administration/users/references/companies/${s}`,r),updateDepartment:(s,r)=>t.put(`/api/administration/users/references/departments/${s}`,r),updateJobTitle:(s,r)=>t.put(`/api/administration/users/references/job-titles/${s}`,r),updateOffice:(s,r)=>t.put(`/api/administration/users/references/offices/${s}`,r),activateCompany:s=>t.patch(`/api/administration/users/references/companies/${s}/activate`),activateDepartment:s=>t.patch(`/api/administration/users/references/departments/${s}/activate`),activateJobTitle:s=>t.patch(`/api/administration/users/references/job-titles/${s}/activate`),activateOffice:s=>t.patch(`/api/administration/users/references/offices/${s}/activate`),deactivateCompany:s=>t.patch(`/api/administration/users/references/companies/${s}/deactivate`),deactivateDepartment:s=>t.patch(`/api/administration/users/references/departments/${s}/deactivate`),deactivateJobTitle:s=>t.patch(`/api/administration/users/references/job-titles/${s}/deactivate`),deactivateOffice:s=>t.patch(`/api/administration/users/references/offices/${s}/deactivate`),deleteCompany:s=>t.delete(`/api/administration/users/references/companies/${s}`),deleteDepartment:s=>t.delete(`/api/administration/users/references/departments/${s}`),deleteJobTitle:s=>t.delete(`/api/administration/users/references/job-titles/${s}`),deleteOffice:s=>t.delete(`/api/administration/users/references/offices/${s}`)},updateProfile:(s,r)=>t.put(`/api/administration/users/${s}/profile`,r),updateOrganization:(s,r)=>t.put(`/api/administration/users/${s}/organization`,r),updateJobInfo:(s,r)=>t.put(`/api/administration/users/${s}/job-info`,r),updatePhones:(s,r)=>t.put(`/api/administration/users/${s}/phones`,r),updateAddress:(s,r)=>t.put(`/api/administration/users/${s}/address`,r),updateContact:(s,r)=>t.put(`/api/administration/users/${s}/contact`,r),getTenants:s=>t.get(`/api/administration/users/${s}/tenants`),getGroups:s=>t.get(`/api/administration/users/${s}/groups`),getConsolidatedRoles:(s,r)=>{const a=r?`/api/administration/users/${s}/consolidated-roles?tenantId=${r}`:`/api/administration/users/${s}/consolidated-roles`;return t.get(a)},getApplicationAccess:(s,r)=>{const a=r?`/api/administration/users/${s}/application-access?tenantId=${r}`:`/api/administration/users/${s}/application-access`;return t.get(a)}}),ln=on,cn=t=>({getAll:s=>t.get("/api/administration/permissions/roles",{params:s}),getAssignable:()=>t.get("/api/administration/permissions/roles",{params:{excludeCategories:"Custom",minPermissionsCount:1}}),getServiceAssignable:()=>t.get("/api/administration/permissions/roles",{params:{forExternalApps:!0,minPermissionsCount:1}}),getByApplication:s=>t.get("/api/administration/permissions/roles",{params:{applicationId:s,excludeCategories:"Custom",minPermissionsCount:1}}),getById:s=>t.get(`/api/administration/permissions/roles/${s}`),create:s=>t.post("/api/administration/permissions/roles",s),update:(s,r)=>t.put(`/api/administration/permissions/roles/${s}`,r),delete:s=>t.delete(`/api/administration/permissions/roles/${s}`),assignUser:(s,r)=>t.post(`/api/administration/permissions/roles/${s}/users/${r}`),removeUser:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/users/${r}`),getGroups:s=>t.get(`/api/administration/permissions/roles/${s}/groups`),assignGroup:(s,r)=>t.post(`/api/administration/permissions/roles/${s}/groups/${r}`),removeGroup:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/groups/${r}`),getTranslations:s=>t.get(`/api/administration/permissions/roles/${s}/translations`),upsertTranslation:(s,r,a)=>t.put(`/api/administration/permissions/roles/${s}/translations/${r}`,a),deleteTranslation:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/translations/${r}`)}),dn=cn,un=t=>({getAll:s=>t.get("/api/administration/permissions",{params:s}),getById:s=>t.get(`/api/administration/permissions/${s}`),getTree:()=>t.get("/api/administration/permissions/tree"),getMatrix:()=>t.get("/api/administration/permissions/matrix"),delete:s=>t.delete(`/api/administration/permissions/${s}`)}),mn=un,pn=t=>({getAll:s=>t.get("/api/administration/applications",{params:s}),getById:s=>t.get(`/api/administration/applications/${s}`),update:(s,r)=>t.put(`/api/administration/applications/${s}`,r),activate:s=>t.patch(`/api/administration/applications/${s}/activate`),deactivate:s=>t.patch(`/api/administration/applications/${s}/deactivate`),getModules:s=>t.get(`/api/administration/applications/${s}/modules`),updateModule:(s,r,a)=>t.put(`/api/administration/applications/${s}/modules/${r}`,a),getModuleSections:(s,r)=>t.get(`/api/administration/applications/${s}/modules/${r}/sections`),reorderModules:(s,r)=>t.put(`/api/administration/applications/${s}/modules/reorder`,{items:r}),reorderSections:(s,r,a)=>t.put(`/api/administration/applications/${s}/modules/${r}/sections/reorder`,{items:a}),getTenants:s=>t.get(`/api/administration/applications/${s}/tenants`),getAvailableTenants:s=>t.get(`/api/administration/applications/${s}/tenants/available`),assignToTenant:(s,r,a)=>t.post(`/api/administration/applications/${s}/tenants/${r}`,a?{accessLevel:a}:{}),removeFromTenant:(s,r)=>t.delete(`/api/administration/applications/${s}/tenants/${r}`),updateTenantAccessLevel:(s,r,a)=>t.patch(`/api/administration/applications/${s}/tenants/${r}/access-level`,{accessLevel:a}),bulkAssignTenants:(s,r)=>t.post(`/api/administration/applications/${s}/tenants/bulk`,r)}),xn=pn,hn=t=>({getOverview:(s=30,r)=>t.get("/api/administration/users/dashboard/overview",{params:{days:s},signal:r?.signal}),getByStatus:s=>t.get("/api/administration/users/dashboard/by-status",{signal:s?.signal}),getByRole:s=>t.get("/api/administration/users/dashboard/by-role",{signal:s?.signal}),getByType:s=>t.get("/api/administration/users/dashboard/by-type",{signal:s?.signal}),getLoginActivity:(s=30,r)=>t.get("/api/administration/users/dashboard/login-activity",{params:{days:s},signal:r?.signal}),getTrends:(s=30,r)=>t.get("/api/administration/users/dashboard/trends",{params:{days:s},signal:r?.signal}),getRecentUsers:(s=10,r)=>t.get("/api/administration/users/dashboard/recent-users",{params:{limit:s},signal:r?.signal}),getSecurityAlerts:(s=3,r=24,a)=>t.get("/api/administration/users/dashboard/security-alerts",{params:{threshold:s,hours:r},signal:a?.signal}),getActiveSessions:s=>t.get("/api/administration/users/dashboard/active-sessions",{signal:s?.signal}),getLatestActiveSessions:(s=5,r)=>t.get("/api/administration/users/dashboard/latest-active-sessions",{params:{limit:s},signal:r?.signal})}),gn=hn,fn=t=>({getAll:()=>t.get("/api/administration/configuration/settings"),getByCategory:s=>t.get(`/api/administration/configuration/settings/${s}`),get:(s,r)=>t.get(`/api/administration/configuration/settings/${s}/${r}`),update:(s,r,a)=>t.put(`/api/administration/configuration/settings/${s}/${r}`,{value:a}),reset:(s,r)=>t.post(`/api/administration/configuration/settings/${s}/${r}/reset`),getHistory:(s,r)=>t.get(`/api/administration/configuration/settings/${s}/${r}/history`),getCategories:()=>t.get("/api/administration/configuration/settings/categories")}),bn=fn,vn=t=>({get:()=>t.get("/api/user/preferences"),getGlobal:()=>t.get("/api/user/preferences/global"),getForTenant:s=>t.get(`/api/user/preferences/for-tenant/${s}`),getThemeOverrides:()=>t.get("/api/user/preferences/theme-overrides"),deleteTenantOverride:()=>t.delete("/api/user/preferences/tenant-override"),applyToTenant:()=>t.post("/api/user/preferences/apply-to-tenant")}),yn=vn,jn=t=>({getConfig:()=>t.get("/api/administration/tenants/config"),getAll:s=>{const{excludeTypes:r,...a}=s||{},o=new URLSearchParams;a.page&&o.set("page",String(a.page)),a.pageSize&&o.set("pageSize",String(a.pageSize)),a.search&&o.set("search",a.search),a.status&&o.set("status",a.status),a.type&&o.set("type",a.type),a.sortBy&&o.set("sortBy",a.sortBy),a.sortDesc&&o.set("sortDesc","true"),r?.length&&r.forEach(i=>o.append("excludeTypes",i));const c=o.toString();return t.get(`/api/administration/tenants${c?`?${c}`:""}`)},getById:s=>t.get(`/api/administration/tenants/${s}`),createB2C:s=>t.post("/api/administration/tenants/b2c",s),createB2B:s=>t.post("/api/administration/tenants/b2b",s),update:(s,r)=>t.put(`/api/administration/tenants/${s}`,r),delete:s=>t.delete(`/api/administration/tenants/${s}`),activate:s=>t.post(`/api/administration/tenants/${s}/activate`),suspend:s=>t.post(`/api/administration/tenants/${s}/suspend`),archive:s=>t.delete(`/api/administration/tenants/${s}`),checkSlugAvailable:s=>t.get(`/api/administration/tenants/check-slug/${s}`),assignTemplate:(s,r)=>t.post(`/api/administration/tenants/${s}/template`,{templateId:r}),removeTemplate:s=>t.delete(`/api/administration/tenants/${s}/template`),getMembers:s=>t.get(`/api/administration/tenants/${s}/members`),getMember:(s,r)=>t.get(`/api/administration/tenants/${s}/members/${r}`),addMember:(s,r)=>t.post(`/api/administration/tenants/${s}/members`,r),removeMember:(s,r)=>t.delete(`/api/administration/tenants/${s}/members/${r}`),setMemberDefault:(s,r)=>t.patch(`/api/administration/tenants/${s}/members/${r}/set-default`),transferOwnership:(s,r)=>t.post(`/api/administration/tenants/${s}/members/transfer-ownership`,{toUserId:r}),assignRole:(s,r,a)=>t.post(`/api/administration/tenants/${s}/members/${r}/roles/${a}`),removeRole:(s,r,a)=>t.delete(`/api/administration/tenants/${s}/members/${r}/roles/${a}`),assignMemberRoles:(s,r,a)=>t.put(`/api/administration/tenants/${s}/members/${r}/roles`,{roleIds:a}),getMemberCustomRole:(s,r)=>t.get(`/api/administration/tenants/${s}/members/${r}/custom-role`),createMemberCustomRole:(s,r)=>t.post(`/api/administration/tenants/${s}/members/${r}/custom-role`),deleteMemberCustomRole:(s,r)=>t.delete(`/api/administration/tenants/${s}/members/${r}/custom-role`),getTenantRoles:s=>t.get(`/api/administration/tenants/${s}/roles`),getGroups:s=>t.get(`/api/administration/tenants/${s}/groups`),getAvailableGroups:s=>t.get(`/api/administration/tenants/${s}/groups/available`),addGroupToTenant:(s,r)=>t.post(`/api/administration/tenants/${s}/groups`,{groupId:r}),removeGroupFromTenant:(s,r)=>t.delete(`/api/administration/tenants/${s}/groups/${r}`),getApplications:s=>t.get(`/api/administration/tenants/${s}/applications`),getAvailableApplications:s=>t.get(`/api/administration/tenants/${s}/applications/available`),assignApplication:(s,r)=>t.post(`/api/administration/tenants/${s}/applications/${r}`),removeApplication:(s,r)=>t.delete(`/api/administration/tenants/${s}/applications/${r}`),bulkAssignApplications:(s,r)=>t.post(`/api/administration/tenants/${s}/applications/bulk`,r),toggleApplication:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/applications/${r}/toggle`,{isActive:a}),updateApplicationAccessLevel:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/applications/${r}/access-level`,{accessLevel:a}),getEffectiveTree:(s,r)=>t.get(`/api/administration/tenants/${s}/applications/${r}/effective-tree`),saveOverrides:(s,r,a)=>t.put(`/api/administration/tenants/${s}/applications/${r}/overrides`,a),getModules:s=>t.get(`/api/administration/tenants/${s}/modules`),getAvailableModules:s=>t.get(`/api/administration/tenants/${s}/modules/available`),assignModule:(s,r)=>t.post(`/api/administration/tenants/${s}/modules/${r}`),removeModule:(s,r)=>t.delete(`/api/administration/tenants/${s}/modules/${r}`),toggleModule:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/modules/${r}/toggle`,{isActive:a}),getSections:s=>t.get(`/api/administration/tenants/${s}/sections`),getAvailableSections:s=>t.get(`/api/administration/tenants/${s}/sections/available`),assignSection:(s,r)=>t.post(`/api/administration/tenants/${s}/sections/${r}`),removeSection:(s,r)=>t.delete(`/api/administration/tenants/${s}/sections/${r}`),toggleSection:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/sections/${r}/toggle`,{isActive:a}),getModulesWithSections:(s,r)=>t.get(`/api/administration/tenants/${s}/applications/${r}/modules-tree`),linkOrganisation:(s,r)=>t.post(`/api/administration/tenants/${s}/organisation`,{organisationId:r}),unlinkOrganisation:s=>t.delete(`/api/administration/tenants/${s}/organisation`)}),Nn=jn,wn=t=>({getAll:()=>t.get("/api/administration/tenants/templates"),getById:s=>t.get(`/api/administration/tenants/templates/${s}`),create:s=>t.post("/api/administration/tenants/templates",s),update:(s,r)=>t.put(`/api/administration/tenants/templates/${s}`,r),delete:s=>t.delete(`/api/administration/tenants/templates/${s}`),assignApplication:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/applications/${r}`),removeApplication:(s,r)=>t.delete(`/api/administration/tenants/templates/${s}/applications/${r}`),bulkAssignApplications:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/applications/bulk`,r),getTenants:s=>t.get(`/api/administration/tenants/templates/${s}/tenants`),getApplications:s=>t.get(`/api/administration/tenants/templates/${s}/applications`),getAvailableApplications:s=>t.get(`/api/administration/tenants/templates/${s}/applications/available`),updateApplicationAccessLevel:(s,r,a)=>t.patch(`/api/administration/tenants/templates/${s}/applications/${r}/access-level`,{accessLevel:a}),getApplicationModules:(s,r)=>t.get(`/api/administration/tenants/templates/${s}/applications/${r}/modules`),updateApplicationModules:(s,r,a)=>t.put(`/api/administration/tenants/templates/${s}/applications/${r}/modules`,a),getAiInstances:s=>t.get(`/api/administration/tenants/templates/${s}/ai-instances`),assignAiInstance:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/ai-instances/${r}`),removeAiInstance:(s,r)=>t.delete(`/api/administration/tenants/templates/${s}/ai-instances/${r}`)}),Sn=wn,Cn=t=>({getAll:s=>t.get("/api/administration/tenants/organisations",{params:s}),getAvailable:s=>t.get("/api/administration/tenants/organisations/available",{params:s?{search:s}:void 0}),getPendingVerification:()=>t.get("/api/administration/tenants/organisations/pending-verification"),getById:s=>t.get(`/api/administration/tenants/organisations/${s}`),findById:async s=>{const r=await Se.get(`/api/administration/tenants/organisations/${s}`,{validateStatus:a=>a===200||a===404});return r.status===200?r.data:null},create:s=>t.post("/api/administration/tenants/organisations",s),updateContact:(s,r)=>t.put(`/api/administration/tenants/organisations/${s}/contact`,r),updateAddress:(s,r)=>t.put(`/api/administration/tenants/organisations/${s}/address`,r),verify:(s,r)=>t.post(`/api/administration/tenants/organisations/${s}/verify`,{notes:r}),reject:(s,r)=>t.post(`/api/administration/tenants/organisations/${s}/reject`,{reason:r}),lookup:(s,r)=>t.get("/api/administration/tenants/organisations/lookup",{params:{countryCode:s,identifier:r}})}),kn=Cn,An=t=>({getAll:s=>t.get("/api/administration/tenants/my",{params:s?{search:s}:void 0}),getDefault:()=>t.get("/api/administration/tenants/my/default"),setDefault:s=>t.post(`/api/administration/tenants/${s}/set-default`),clearDefault:()=>t.delete("/api/administration/tenants/clear-default"),getFavorites:()=>t.get("/api/user/preferences/tenant-favorites"),addFavorite:s=>t.post(`/api/user/preferences/tenant-favorites/${s}`),removeFavorite:s=>t.delete(`/api/user/preferences/tenant-favorites/${s}`),recordRecent:s=>t.post(`/api/user/preferences/tenant-recent/${s}`)}),Pn=An,Tn=t=>({getAll:s=>t.get("/api/accounts",{params:s}),getById:s=>t.get(`/api/accounts/${s}`),create:s=>t.post("/api/accounts",s),update:(s,r)=>t.put(`/api/accounts/${s}`,r),delete:s=>t.delete(`/api/accounts/${s}`),activate:s=>t.patch(`/api/accounts/${s}/activate`),deactivate:s=>t.patch(`/api/accounts/${s}/deactivate`),rotateSecret:(s,r="Primary")=>t.post(`/api/accounts/${s}/rotate-secret?keySlot=${r}`),revokeSecondarySecret:s=>t.delete(`/api/accounts/${s}/secondary-secret`),assignRole:(s,r)=>t.post(`/api/accounts/${s}/roles`,r),removeRole:(s,r,a)=>t.delete(`/api/accounts/${s}/roles/${r}`,{params:a?{tenantId:a}:void 0}),generateSecret:()=>t.post("/api/accounts/generate-secret"),getAuditLogs:(s,r=1,a=20)=>t.get(`/api/accounts/${s}/audit-logs`,{params:{page:r,pageSize:a}}),getUsageStats:(s,r=30)=>t.get(`/api/accounts/${s}/usage-stats`,{params:{days:r}}),getKeyUsage:s=>t.get(`/api/accounts/${s}/key-usage`),getApiEndpoints:()=>t.get("/api/accounts/api-endpoints"),getAppApiAccess:s=>t.get(`/api/accounts/${s}/api-access`),updateApiAccess:(s,r,a)=>t.put(`/api/accounts/${s}/api-access/${r}`,a),removeApiAccess:(s,r)=>t.delete(`/api/accounts/${s}/api-access/${r}`)}),Rn=Tn,En=t=>({getNavigationLookup:()=>t.get("/api/apis/navigation-lookup")}),In=En,hr=t=>{const s=t?an(t):E;return{users:ln(s),roles:dn(s),permissions:mn(s),applications:xn(s),dashboard:gn(s),settings:bn(s),tenants:Nn(s),templates:Sn(s),organisations:kn(s),myTenants:Pn(s),preferences:yn(s),externalApps:Rn(s),apiCatalog:In(s)}},Ne=hr(),ge=(t,s,r)=>{const a=t[s];return a?typeof a=="function"?a():Promise.resolve(a):new Promise((o,c)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(c.bind(null,new Error("Unknown variable dynamic import: "+s+(s.split("/").length!==r?". Note that variables only represent file names one level deep.":""))))})},gr=async t=>{if(!t)return null;try{const[s,r,a,o,c,i,d,u,m,p,f,g,b,h,y,x,j,v,S,N,I,P,k,A,R,$,q,C,D,Y,T,z,Z,H]=await Promise.all([ge(Object.assign({"./locales/de/common.json":()=>Promise.resolve().then(()=>require("./common-BZM8Gf-R.js")),"./locales/en/common.json":()=>Promise.resolve().then(()=>require("./common-Daanch0E.js")),"./locales/fr/common.json":()=>Promise.resolve().then(()=>require("./common-lhAPHx3v.js")),"./locales/it/common.json":()=>Promise.resolve().then(()=>require("./common-B4gIg-Uo.js"))}),`./locales/${t}/common.json`,4),ge(Object.assign({"./locales/de/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-D8yOGHza.js")),"./locales/en/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-rEtU7BPw.js")),"./locales/fr/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-BI8iMTJl.js")),"./locales/it/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-BTkWh95c.js"))}),`./locales/${t}/navigation.json`,4),ge(Object.assign({"./locales/de/auth.json":()=>Promise.resolve().then(()=>require("./auth-C5zpZ9k7.js")),"./locales/en/auth.json":()=>Promise.resolve().then(()=>require("./auth-DL47kvnl.js")),"./locales/fr/auth.json":()=>Promise.resolve().then(()=>require("./auth-B-hELPDB.js")),"./locales/it/auth.json":()=>Promise.resolve().then(()=>require("./auth-CyPkCta2.js"))}),`./locales/${t}/auth.json`,4),ge(Object.assign({"./locales/de/admin.json":()=>Promise.resolve().then(()=>require("./admin-egO_sJAt.js")),"./locales/en/admin.json":()=>Promise.resolve().then(()=>require("./admin-DZG3lp_d.js")),"./locales/fr/admin.json":()=>Promise.resolve().then(()=>require("./admin-NyIkvXgM.js")),"./locales/it/admin.json":()=>Promise.resolve().then(()=>require("./admin-CtCAu1C-.js"))}),`./locales/${t}/admin.json`,4),ge(Object.assign({"./locales/de/support.json":()=>Promise.resolve().then(()=>require("./support-BU6GoEbW.js")),"./locales/en/support.json":()=>Promise.resolve().then(()=>require("./support-DnSiwJx7.js")),"./locales/fr/support.json":()=>Promise.resolve().then(()=>require("./support-B0kcB-tL.js")),"./locales/it/support.json":()=>Promise.resolve().then(()=>require("./support-Cm84X3pP.js"))}),`./locales/${t}/support.json`,4),ge(Object.assign({"./locales/de/docs.json":()=>Promise.resolve().then(()=>require("./docs-sqOeJ3Lg.js")),"./locales/en/docs.json":()=>Promise.resolve().then(()=>require("./docs-BR4q7sou.js")),"./locales/fr/docs.json":()=>Promise.resolve().then(()=>require("./docs-CDz8QplV.js")),"./locales/it/docs.json":()=>Promise.resolve().then(()=>require("./docs-DCOsvfv7.js"))}),`./locales/${t}/docs.json`,4),ge(Object.assign({"./locales/de/ai.json":()=>Promise.resolve().then(()=>require("./ai-BGanmkGz.js")),"./locales/en/ai.json":()=>Promise.resolve().then(()=>require("./ai-CnWgG5hN.js")),"./locales/fr/ai.json":()=>Promise.resolve().then(()=>require("./ai-wRnnMW5a.js")),"./locales/it/ai.json":()=>Promise.resolve().then(()=>require("./ai-Cgn4sP2c.js"))}),`./locales/${t}/ai.json`,4),ge(Object.assign({"./locales/de/communications.json":()=>Promise.resolve().then(()=>require("./communications-DBbKXpf1.js")),"./locales/en/communications.json":()=>Promise.resolve().then(()=>require("./communications-BPsS3Vfm.js")),"./locales/fr/communications.json":()=>Promise.resolve().then(()=>require("./communications-DElJaoVw.js")),"./locales/it/communications.json":()=>Promise.resolve().then(()=>require("./communications-BKaku0MU.js"))}),`./locales/${t}/communications.json`,4),ge(Object.assign({"./locales/de/entra.json":()=>Promise.resolve().then(()=>require("./entra-BadKCc7Y.js")),"./locales/en/entra.json":()=>Promise.resolve().then(()=>require("./entra-CfLYpxKq.js")),"./locales/fr/entra.json":()=>Promise.resolve().then(()=>require("./entra-Bc0Dwf7d.js")),"./locales/it/entra.json":()=>Promise.resolve().then(()=>require("./entra-DDgx1JoT.js"))}),`./locales/${t}/entra.json`,4),ge(Object.assign({"./locales/en/structure.json":()=>Promise.resolve().then(()=>require("./structure-BL5cd83u.js")),"./locales/fr/structure.json":()=>Promise.resolve().then(()=>require("./structure-BblXL_QG.js"))}),`./locales/${t}/structure.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-DLJ9mTYQ.js")),"./locales/en/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-pkUX3R0G.js")),"./locales/fr/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-Di_IL1wh.js")),"./locales/it/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-B65OLntJ.js"))}),`./locales/${t}/preferences.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/groups.json":()=>Promise.resolve().then(()=>require("./groups-DGDNx8Hf.js")),"./locales/en/groups.json":()=>Promise.resolve().then(()=>require("./groups-5uqhFMN4.js")),"./locales/fr/groups.json":()=>Promise.resolve().then(()=>require("./groups-Cp2Q-pWt.js")),"./locales/it/groups.json":()=>Promise.resolve().then(()=>require("./groups-cV3gnMYo.js"))}),`./locales/${t}/groups.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/en/ba.json":()=>Promise.resolve().then(()=>require("./ba-9HglDm-t.js")),"./locales/fr/ba.json":()=>Promise.resolve().then(()=>require("./ba-CXlHUyjN.js"))}),`./locales/${t}/ba.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-CsRMxznf.js")),"./locales/en/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-BUnDEWjL.js")),"./locales/fr/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-DRITa5fK.js")),"./locales/it/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-qLwE7c_z.js"))}),`./locales/${t}/docs-administration-users.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BHJfnRA-.js")),"./locales/en/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-CXsWrgCA.js")),"./locales/fr/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BLmrJB-I.js")),"./locales/it/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BmiGStz4.js"))}),`./locales/${t}/docs-administration-permissions.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-Cmjpaxwy.js")),"./locales/en/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-CvYnhoo5.js")),"./locales/fr/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-xhQOAORE.js")),"./locales/it/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-CuHqwklv.js"))}),`./locales/${t}/docs-administration-tenants.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-CPqGrO8q.js")),"./locales/en/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-EVzVu3kS.js")),"./locales/fr/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-B0zkD6zQ.js")),"./locales/it/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-DngqfS6k.js"))}),`./locales/${t}/docs-administration-ai.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-DRw16ooP.js")),"./locales/en/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-Da6XQxlv.js")),"./locales/fr/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-CofvuK9f.js")),"./locales/it/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-DW4kFs3z.js"))}),`./locales/${t}/docs-administration-workflows.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-D3hQEI3V.js")),"./locales/en/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-griadux5.js")),"./locales/fr/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-BbS4ZUu7.js")),"./locales/it/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-D0KuJ7Ps.js"))}),`./locales/${t}/docs-administration-entra.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-C6VsiHxH.js")),"./locales/en/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-DRYyRp3S.js")),"./locales/fr/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-BEepPuXf.js")),"./locales/it/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-BiZBTxgS.js"))}),`./locales/${t}/docs-administration-applications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-BdZl4hL4.js")),"./locales/en/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-DvZxFmnH.js")),"./locales/fr/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-CXro3iiT.js")),"./locales/it/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-B1YtxR_A.js"))}),`./locales/${t}/docs-administration-configuration.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-DSMqi4PQ.js")),"./locales/en/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-C3rm7u1h.js")),"./locales/fr/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-CJsMRPaR.js")),"./locales/it/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-_LdQyRjT.js"))}),`./locales/${t}/docs-administration-configuration-license.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-HRqVNkqP.js")),"./locales/en/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-XQ-IiS31.js")),"./locales/fr/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-B3IDsztG.js")),"./locales/it/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-DKbpQgBH.js"))}),`./locales/${t}/docs-administration-tenants-template.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-BtAQiVRM.js")),"./locales/en/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-Cs4N4jrq.js")),"./locales/fr/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-XRmC4aRE.js")),"./locales/it/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-D1T8STQX.js"))}),`./locales/${t}/docs-administration-tenants-business.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-DHGVmv0D.js")),"./locales/en/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-Bk0D7emY.js")),"./locales/fr/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-DSnrN4MO.js")),"./locales/it/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-KFjQQGdW.js"))}),`./locales/${t}/docs-administration-tenants-personal.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-B5w2xFPJ.js")),"./locales/en/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-Dh2ohplZ.js")),"./locales/fr/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-WV4RsrVj.js")),"./locales/it/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-DeZKiNkH.js"))}),`./locales/${t}/docs-administration-tenants-other.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-BbAfGAzk.js")),"./locales/en/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-cv88prRo.js")),"./locales/fr/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-Clm4Yhy7.js")),"./locales/it/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-Xtrdol6a.js"))}),`./locales/${t}/docs-administration-permissions-assignments.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-BXTwlVt_.js")),"./locales/en/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-DxKx9YEc.js")),"./locales/fr/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-DehK43TA.js")),"./locales/it/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-D2SCJxWE.js"))}),`./locales/${t}/docs-administration-tenants-applications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-CMJEiBDZ.js")),"./locales/en/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-BDCjPv_a.js")),"./locales/fr/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-DXBq6rZX.js")),"./locales/it/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-7mBPVsvv.js"))}),`./locales/${t}/docs-administration-tenants-access-requests.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-DV-_MnD2.js")),"./locales/en/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-BJS2qchs.js")),"./locales/fr/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-DDPYmh_7.js")),"./locales/it/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-BWchU3XZ.js"))}),`./locales/${t}/docs-administration-tenants-organisations.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-nvIWiI_l.js")),"./locales/en/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-yc0oKKrD.js")),"./locales/fr/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-jObWdig-.js")),"./locales/it/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-BtPIdbRr.js"))}),`./locales/${t}/docs-platform-support-tickets.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-D6Oy2YkN.js")),"./locales/en/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-sPBt_1c4.js")),"./locales/fr/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-BVpRmDsI.js")),"./locales/it/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-lQ9K3m9K.js"))}),`./locales/${t}/docs-administration-users-dashboard.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-Du_ykq8Q.js")),"./locales/en/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-CNWOU2Wq.js")),"./locales/fr/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-Dc8nUoSy.js")),"./locales/it/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-C5YUKBpW.js"))}),`./locales/${t}/docs-administration-users-references.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-WmOKFuUm.js")),"./locales/en/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-C6xh7MWi.js")),"./locales/fr/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-DgWpE7cP.js")),"./locales/it/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-7NuH5xFT.js"))}),`./locales/${t}/docs-administration-users-groups.json`,4).catch(()=>({default:{}}))]);return{common:s.default,navigation:r.default,auth:a.default,admin:o.default,support:c.default,docs:i.default,ai:d.default,communications:u.default,entra:m.default,structure:p.default||{},preferences:f.default||{},groups:g.default||{},ba:b.default||{},docsAdministrationUsers:h.default||{},docsAdministrationPermissions:y.default||{},docsAdministrationTenants:x.default||{},docsAdministrationAi:j.default||{},docsAdministrationWorkflows:v.default||{},docsAdministrationEntra:S.default||{},docsAdministrationApplications:N.default||{},docsAdministrationConfiguration:I.default||{},docsAdministrationConfigurationLicense:P.default||{},docsAdministrationTenantsTemplate:k.default||{},docsAdministrationTenantsBusiness:A.default||{},docsAdministrationTenantsPersonal:R.default||{},docsAdministrationTenantsOther:$.default||{},docsAdministrationPermissionsAssignments:q.default||{},docsAdministrationTenantsApplications:C.default||{},docsAdministrationTenantsAccessRequests:D.default||{},docsAdministrationTenantsOrganisations:Y.default||{},docsPlatformSupportTickets:T.default||{},docsAdministrationUsersDashboard:z.default||{},docsAdministrationUsersReferences:Z.default||{},docsAdministrationUsersGroups:H.default||{}}}catch(s){return console.warn(`Failed to load language: ${t}`,s),null}},Ln={},$n=()=>{const t=localStorage.getItem("i18nextLng");if(t&&["en","fr","de","it"].includes(t))return t;const s=navigator.language.split("-")[0];return["en","fr","de","it"].includes(s)?s:"en"},ts=$n();jt.use(Xa).use(ne.initReactI18next).init({resources:Ln,lng:ts,fallbackLng:"en",defaultNS:"common",ns:["common","navigation","auth","admin","support","docs","ai","communications","entra","structure","preferences","groups","ba","docsAdministrationUsers","docsAdministrationPermissions","docsAdministrationTenants","docsAdministrationAi","docsAdministrationWorkflows","docsAdministrationEntra","docsAdministrationApplications","docsAdministrationConfiguration","docsAdministrationConfigurationLicense","docsAdministrationTenantsTemplate","docsAdministrationTenantsBusiness","docsAdministrationTenantsPersonal","docsAdministrationTenantsOther","docsAdministrationPermissionsAssignments","docsAdministrationTenantsApplications","docsAdministrationTenantsAccessRequests","docsAdministrationTenantsOrganisations","docsPlatformSupportTickets","docsAdministrationUsersReferences","docsAdministrationUsersGroups"],interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator","htmlTag"],caches:["localStorage"]}});gr(ts).then(t=>{t&&Object.entries(t).forEach(([s,r])=>{jt.addResourceBundle(ts,s,r,!0,!0)})});const ms=async t=>{if(!jt.hasResourceBundle(t,"common")){const s=await gr(t);s&&Object.entries(s).forEach(([r,a])=>{jt.addResourceBundle(t,r,a,!0,!0)})}await jt.changeLanguage(t)},fr=n.createContext(void 0);function Dn(){if(typeof window>"u")return yt;try{const s=localStorage.getItem(pr);if(s){const r=JSON.parse(s);return{...yt,...r,borderRadius:{...yt.borderRadius,...r.borderRadius},itemPaletteKey:r.itemPaletteKey||ds,colors:{light:mt(r.accentColorKey||"indigo"),dark:pt(r.accentColorKey||"indigo")}}}}catch{}const t=window.matchMedia("(prefers-color-scheme: dark)").matches;return{...yt,mode:t?"dark":"light"}}function Rt(t){const s=t.accentColorKey||"indigo",r=t.borderRadius;return{mode:t.theme||"dark",accentColorKey:s,borderRadius:{card:r?.card||"large",button:r?.button||"medium",badge:r?.badge||"medium",input:r?.input||"medium",modal:r?.modal||"xlarge",menuItem:r?.menuItem||"medium"},itemPaletteKey:t.itemPaletteKey||ds,colors:{light:mt(s),dark:pt(s)}}}function Mn(t){const s=document.documentElement,r=t.mode==="dark"?t.colors.dark:t.colors.light,a=_e[t.accentColorKey]?.shades||_e.indigo.shades,o=ut[t.itemPaletteKey]||ut.neutral,c=t.mode==="dark"?o.colors.dark:o.colors.light;t.mode==="dark"?s.classList.add("dark"):s.classList.remove("dark"),s.style.setProperty("--radius-card",Qe[t.borderRadius.card]),s.style.setProperty("--radius-button",Qe[t.borderRadius.button]),s.style.setProperty("--radius-badge",Qe[t.borderRadius.badge]),s.style.setProperty("--radius-input",Qe[t.borderRadius.input]),s.style.setProperty("--radius-modal",Qe[t.borderRadius.modal]),s.style.setProperty("--radius-menu-item",Qe[t.borderRadius.menuItem]),Object.entries(a).forEach(([i,d])=>{s.style.setProperty(`--color-accent-${i}`,d)}),s.style.setProperty("--item-color-light",c.light),s.style.setProperty("--item-color-medium",c.medium),s.style.setProperty("--item-color-dark",c.dark),s.style.setProperty("--item-color-border",c.border),s.style.setProperty("--bg-app",r.backgrounds.app),s.style.setProperty("--bg-primary",r.backgrounds.primary),s.style.setProperty("--bg-secondary",r.backgrounds.secondary),s.style.setProperty("--bg-tertiary",r.backgrounds.tertiary),s.style.setProperty("--bg-card",r.backgrounds.card),s.style.setProperty("--bg-hover",r.backgrounds.hover),s.style.setProperty("--bg-active",r.backgrounds.active),s.style.setProperty("--text-primary",r.text.primary),s.style.setProperty("--text-secondary",r.text.secondary),s.style.setProperty("--text-tertiary",r.text.tertiary),s.style.setProperty("--text-muted",r.text.muted),s.style.setProperty("--text-inverse",r.text.inverse),s.style.setProperty("--border-color",r.border.default),s.style.setProperty("--border-subtle",r.border.subtle),s.style.setProperty("--border-strong",r.border.strong),s.style.setProperty("--success-bg",r.status.success.bg),s.style.setProperty("--success-text",r.status.success.text),s.style.setProperty("--success-border",r.status.success.border),s.style.setProperty("--success-dot",r.status.success.dot),s.style.setProperty("--warning-bg",r.status.warning.bg),s.style.setProperty("--warning-text",r.status.warning.text),s.style.setProperty("--warning-border",r.status.warning.border),s.style.setProperty("--warning-dot",r.status.warning.dot),s.style.setProperty("--error-bg",r.status.error.bg),s.style.setProperty("--error-text",r.status.error.text),s.style.setProperty("--error-border",r.status.error.border),s.style.setProperty("--error-dot",r.status.error.dot),s.style.setProperty("--info-bg",r.status.info.bg),s.style.setProperty("--info-text",r.status.info.text),s.style.setProperty("--info-border",r.status.info.border),s.style.setProperty("--info-dot",r.status.info.dot),s.style.setProperty("--accent-bg",r.accentTransparent.bg),s.style.setProperty("--accent-text",r.accentTransparent.text),s.style.setProperty("--accent-border",r.accentTransparent.border)}function br({children:t}){const[s,r]=n.useState(Dn),[a,o]=n.useState(!1),[c,i]=n.useState(null),[d,u]=n.useState(void 0),[m,p]=n.useState([]),{i18n:f}=ne.useTranslation(),g=n.useRef(null),b=n.useRef(!0),h=n.useRef(!1),y=n.useRef(!1),x=n.useCallback(async(T,z=void 0)=>{if(!localStorage.getItem("token")||y.current)return;let H=null;const J=localStorage.getItem("currentTenantId");if(z===void 0)J?H=J:H=null;else{if(z!==null&&J&&z!==J)return;H=z}try{o(!0),await Ft.preferences.updateTheme({mode:T.mode,accentColorKey:T.accentColorKey,borderRadius:{card:T.borderRadius.card,button:T.borderRadius.button,badge:T.borderRadius.badge,input:T.borderRadius.input,modal:T.borderRadius.modal,menuItem:T.borderRadius.menuItem},itemPaletteKey:T.itemPaletteKey,targetTenantId:H}),H&&!m.includes(H)&&p(fe=>[...fe,H])}catch(fe){console.error("[ThemeContext] ❌ Failed to save theme to server:",{error:fe,targetTenantId:H,mode:T.mode,accentColorKey:T.accentColorKey,localStorage_currentTenantId:localStorage.getItem("currentTenantId"),localStorage_currentTenantSlug:localStorage.getItem("currentTenantSlug")})}finally{o(!1)}},[m]),j=n.useCallback((T,z=void 0)=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{x(T,z)},1e3)},[x]);n.useLayoutEffect(()=>{Mn(s)},[s]),n.useEffect(()=>{const T={mode:s.mode,borderRadius:s.borderRadius,accentColorKey:s.accentColorKey,itemPaletteKey:s.itemPaletteKey};localStorage.setItem(pr,JSON.stringify(T)),!y.current&&!b.current&&j(s,d),b.current=!1},[s,j,d]),n.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const v=n.useCallback(async T=>{const z=localStorage.getItem("token"),Z=localStorage.getItem("currentTenantSlug");if(!z)return;const H=T==="global";if(!(!H&&!Z))try{o(!0);const J=H?await Ne.preferences.getGlobal():await Ne.preferences.get();i(J.scope);const fe=Rt(J);b.current=!0,r(fe),h.current=!0,J.language&&J.language!==f.language&&(ms(J.language),document.documentElement.lang=J.language)}catch(J){console.error("[ThemeContext] Failed to load theme from server:",J)}finally{o(!1)}},[f]),S=n.useCallback(async()=>{const T=localStorage.getItem("token"),z=localStorage.getItem("currentTenantSlug");if(!(!T||!z))try{o(!0);const Z=await Ne.preferences.applyToTenant();i(Z.scope)}catch(Z){throw console.error("[ThemeContext] Failed to create tenant-specific preferences:",Z),Z}finally{o(!1)}},[]),N=n.useCallback(async()=>{const T=localStorage.getItem("token"),z=localStorage.getItem("currentTenantSlug");if(!(!T||!z))try{o(!0);const Z=await Ne.preferences.deleteTenantOverride();i(Z.scope);const H=Rt(Z);b.current=!0,r(H)}catch(Z){throw console.error("[ThemeContext] Failed to delete tenant-specific preferences:",Z),Z}finally{o(!1)}},[]),I=n.useCallback(async()=>{if(localStorage.getItem("token"))try{const z=await Ne.preferences.getThemeOverrides();p(z)}catch(z){console.error("[ThemeContext] Failed to load tenant overrides:",z)}},[]),P=n.useCallback(async(T,z=!1)=>{if(g.current&&(clearTimeout(g.current),g.current=null),y.current=!0,h.current=!0,b.current=!0,u(T),z){y.current=!1;return}if(!localStorage.getItem("token")){y.current=!1;return}try{if(o(!0),T===null){const H=await Ne.preferences.getGlobal();i(H.scope);const J=Rt(H);b.current=!0,r(J)}else{const H=await Ne.preferences.getForTenant(T);i(H.scope);const J=Rt(H);b.current=!0,r(J)}}catch(H){console.error("[ThemeContext] Failed to load preferences for tenant:",H)}finally{o(!1),y.current=!1}},[]),k=n.useCallback(()=>{r(T=>({...T,mode:T.mode==="light"?"dark":"light",colors:{light:mt(T.accentColorKey),dark:pt(T.accentColorKey)}}))},[]),A=n.useCallback(T=>{r(z=>({...z,mode:T}))},[]),R=n.useCallback((T,z)=>{r(Z=>({...Z,borderRadius:{...Z.borderRadius,[T]:z}}))},[]),$=n.useCallback(T=>{_e[T]&&r(z=>({...z,accentColorKey:T,colors:{light:mt(T),dark:pt(T)}}))},[]),q=n.useCallback(T=>{ut[T]&&r(z=>({...z,itemPaletteKey:T}))},[]),C=n.useCallback(T=>{r(z=>{const Z=T.accentColorKey||z.accentColorKey;return{...z,...T,borderRadius:{...z.borderRadius,...T.borderRadius},accentColorKey:Z,itemPaletteKey:T.itemPaletteKey||z.itemPaletteKey,colors:{light:mt(Z),dark:pt(Z)}}})},[]),D=n.useCallback(()=>{r(yt)},[]),Y=n.useCallback(T=>Qe[s.borderRadius[T]],[s.borderRadius]);return e.jsx(fr.Provider,{value:{config:s,mode:s.mode,toggleMode:k,setMode:A,setBorderRadius:R,setAccentColor:$,setItemPalette:q,applyPreset:C,resetToDefault:D,getBorderRadius:Y,loadFromServer:v,isSyncing:a,scopeInfo:c,applyToTenant:S,resetToGlobal:N,selectedThemeTenant:d,setSelectedThemeTenant:P,tenantOverrides:m,loadTenantOverrides:I},children:t})}function Ct(){const t=n.useContext(fr);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t}let ft=null,at=null;const On={async getFeatureConfig(t){return ft||at||(at=(async()=>{try{return ft=(await cs.get("/api/config/features",{timeout:1e4,signal:t,headers:{"Content-Type":"application/json"}})).data,ft}finally{at=null}})(),at)},clearCache(){ft=null,at=null}},vr=n.createContext(void 0);function Fn({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(!0);n.useEffect(()=>{const i=new AbortController;return On.getFeatureConfig(i.signal).then(d=>{i.signal.aborted||r(d)}).catch(d=>{d.name==="CanceledError"||i.signal.aborted||(console.error("Failed to load feature config:",d),r({multiTenantEnabled:!0,enableB2B:!0,enableB2C:!0,useUrlRouting:!0}))}).finally(()=>{i.signal.aborted||o(!1)}),()=>i.abort()},[]);const c={config:s,isLoading:a,isMultiTenant:!0,isHybridMode:s?.multiTenantEnabled===!0&&s?.enableB2B===!1&&s?.enableB2C===!0,enableB2B:s?.enableB2B??!0,enableB2C:s?.enableB2C??!0,useUrlRouting:s?.useUrlRouting??!0};return e.jsx(vr.Provider,{value:c,children:t})}function _t(){const t=n.useContext(vr);if(!t)throw new Error("useFeatureConfig must be used within FeatureConfigProvider");return t}const yr="*";function kt(t,s){const r=t.toLowerCase(),a=s.toLowerCase();if(r==="*"||r===a)return!0;if(r.endsWith(".*")){const o=r.slice(0,-2);return a.startsWith(o+".")||a===o}return!1}function _n(t,s){if(t.includes(s))return!0;for(const r of t)if(kt(r,s))return!0;return!1}function Nt(t){return t.includes(yr)}function jr(t,s){if(!s||Nt(t))return!0;const r=s.toLowerCase(),a=r+".";for(const o of t){const c=o.toLowerCase();if(c===r||c.startsWith(a))return!0;if(c.endsWith(".*")){const i=c.slice(0,-1);if(r.startsWith(i)||a.startsWith(i))return!0}}return!1}const ps=n.createContext(void 0),nt="token",ot="user";function Nr({children:t}){const[s,r]=n.useState(()=>{if(typeof window<"u"){const m=localStorage.getItem(ot);if(m)try{return JSON.parse(m)}catch{return null}}return null}),[a,o]=n.useState(!0),c=n.useCallback((m,p)=>{localStorage.setItem(nt,m),localStorage.setItem(ot,JSON.stringify(p)),r(p)},[]),i=n.useCallback(async()=>{try{localStorage.getItem(nt)&&await E.post("/api/auth/logout")}catch{}localStorage.removeItem(nt),localStorage.removeItem("refreshToken"),localStorage.removeItem(ot),r(null),window.location.href="/login"},[]),d=n.useCallback(m=>{if(!s)return!1;if(Nt(s.permissions)||s.permissions.includes(m))return!0;for(const p of s.permissions)if(kt(p,m))return!0;return!1},[s]),u=n.useCallback(async()=>{if(localStorage.getItem(nt))try{const p=await E.get("/api/auth/me");r(p),localStorage.setItem(ot,JSON.stringify(p))}catch(p){console.error("Failed to refresh permissions:",p)}},[]);return n.useEffect(()=>{localStorage.getItem(nt)&&!s?E.get("/api/auth/me").then(p=>{r(p),localStorage.setItem(ot,JSON.stringify(p))}).catch(()=>{localStorage.removeItem(nt),localStorage.removeItem("refreshToken"),localStorage.removeItem(ot)}).finally(()=>o(!1)):o(!1)},[s]),e.jsx(ps.Provider,{value:{user:s,isAuthenticated:!!s,isLoading:a,login:c,logout:i,hasPermission:d,refreshPermissions:u},children:t})}function Pe(){const t=n.useContext(ps);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}function qn(){return n.useContext(ps)??null}function wr(t){return t.includes("*")}const Sr=n.createContext(void 0);function Cr({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(null),[c,i]=n.useState(!0),[d,u]=n.useState(null),m=n.useRef(null),p=n.useCallback(async h=>{try{i(!0),u(null);const[y,x]=await Promise.all([E.get("/api/administration/license",{signal:h}),E.get("/api/administration/license/usage",{signal:h}).catch(()=>null)]);h?.aborted||(r(y),o(x))}catch(y){if(y instanceof Error&&y.name==="CanceledError"||h?.aborted)return;u(y instanceof Error?y.message:"Failed to load license info"),console.error("Failed to fetch license:",y)}finally{h?.aborted||i(!1)}},[]);n.useEffect(()=>{m.current?.abort();const h=new AbortController;return m.current=h,p(h.signal),()=>h.abort()},[p]);const f=n.useCallback(h=>s?wr(s.enabledFeatures)?!0:s.enabledFeatures.some(y=>y.toLowerCase()===h.toLowerCase()):!1,[s]),g=n.useCallback(async()=>{m.current?.abort();const h=new AbortController;m.current=h,await p(h.signal)},[p]),b=n.useCallback(async(h,y)=>{try{const x=await E.post("/api/administration/license/activate",{licenseKey:h,apiKey:y||null});return x.success?(await g(),{success:!0}):{success:!1,error:x.errorMessage||"Activation failed"}}catch(x){return{success:!1,error:x instanceof Error?x.message:"Activation failed"}}},[g]);return e.jsx(Sr.Provider,{value:{license:s,usage:a,isLoading:c,error:d,isFeatureEnabled:f,isReadOnlyMode:s?.isReadOnlyMode??!1,refreshLicense:g,activateLicense:b},children:t})}function He(){const t=n.useContext(Sr);if(t===void 0)throw new Error("useLicense must be used within a LicenseProvider");return t}const kr=n.createContext(void 0),Xe="currentTenantId",Ye="currentTenantSlug",Be="isGlobalView";function Un({children:t}){const{isAuthenticated:s,user:r,refreshPermissions:a}=Pe(),{isLoading:o}=_t(),[c,i]=n.useState(null),[d,u]=n.useState([]),[m,p]=n.useState(!0),[f,g]=n.useState(null),[b,h]=n.useState(()=>localStorage.getItem(Be)==="true"),y=n.useRef(!1),x=n.useRef(""),j=d.filter(C=>C.type==="Business"),v=d.find(C=>C.type==="Personal")||null,S=n.useCallback((C,D)=>{if(u(C),C.length===0){i(null),h(!1),localStorage.removeItem(Xe),localStorage.removeItem(Ye),localStorage.removeItem(Be),p(!1);return}const Y=localStorage.getItem(Xe),T=Y?C.find(J=>J.id===Y):null;if(T?.status==="Active"){i(T),h(!1),localStorage.setItem(Xe,T.id),localStorage.setItem(Ye,T.slug),localStorage.removeItem(Be),p(!1);return}if(localStorage.getItem(Be)==="true"){h(!0),i(null),p(!1);return}const Z=C.find(J=>J.isDefault&&J.status==="Active");if(Z){i(Z),h(!1),localStorage.setItem(Xe,Z.id),localStorage.setItem(Ye,Z.slug),localStorage.removeItem(Be),p(!1);return}if(D){h(!0),i(null),localStorage.setItem(Be,"true"),p(!1);return}const H=C.find(J=>J.status==="Active");i(H||null),H&&(localStorage.setItem(Xe,H.id),localStorage.setItem(Ye,H.slug)),p(!1)},[]),N=n.useCallback(async C=>{const D=d.find(Y=>Y.id===C);if(!D)throw new Error("Tenant not found");if(D.status!=="Active")throw new Error("Cannot switch to inactive tenant");h(!1),localStorage.removeItem(Be),i(D),localStorage.setItem(Xe,C),localStorage.setItem(Ye,D.slug),await a()},[d,a]),I=n.useCallback(async()=>{h(!0),localStorage.setItem(Be,"true"),i(null),localStorage.removeItem(Xe),localStorage.removeItem(Ye),await a()},[a]),P=n.useCallback(async()=>{h(!1),localStorage.removeItem(Be);const C=d.find(T=>T.isDefault&&T.status==="Active"),D=d.find(T=>T.status==="Active"),Y=C||D||null;Y&&(i(Y),localStorage.setItem(Xe,Y.id),localStorage.setItem(Ye,Y.slug)),await a()},[d,a]),k=n.useCallback(async C=>{try{await Ne.myTenants.setDefault(C),u(D=>D.map(T=>({...T,isDefault:T.id===C}))),await N(C)}catch(D){throw console.error("[TenantContext] Failed to set default tenant:",D),D}},[N]),A=n.useCallback(async()=>{try{await Ne.myTenants.clearDefault(),u(C=>C.map(D=>({...D,isDefault:!1}))),await I()}catch(C){throw console.error("[TenantContext] Failed to clear default tenant:",C),C}},[I]),R=n.useCallback(async()=>{p(!0),g(null);try{await a()}catch(C){console.error("Failed to refresh tenants:",C),g("Failed to refresh tenants")}finally{p(!1)}},[a]);n.useEffect(()=>{if(!s||!r){y.current&&(u([]),i(null),p(!1),y.current=!1,x.current="");return}const C=r.tenants||[],D=C.map(Y=>`${Y.id}:${Y.status}:${Y.isDefault}`).sort((Y,T)=>Y.localeCompare(T)).join(",");if(!y.current||D!==x.current){y.current=!0,x.current=D;const Y=Nt(r.permissions||[]);S(C,Y),localStorage.getItem(Ye)&&a().catch(z=>console.error("[TenantContext] Failed to refresh permissions after tenant init:",z))}},[s,r,S,a]),n.useEffect(()=>{s||(i(null),u([]),h(!1),localStorage.removeItem(Xe),localStorage.removeItem(Ye),localStorage.removeItem(Be))},[s]);const $=r?Nt(r.permissions||[]):!1,q={currentTenant:c,userTenants:d,b2bTenants:j,personalTenant:v,isLoading:m||o,error:f,switchTenant:N,setDefaultTenant:k,clearDefaultTenant:A,refreshTenants:R,hasMultipleTenants:d.filter(C=>C.status==="Active").length>1,isCurrentTenantOwner:c?.isOwner??!1,hasGlobalRoles:$,isGlobalView:b,enterGlobalView:I,exitGlobalView:P};return e.jsx(kr.Provider,{value:q,children:t})}function Ee(){const t=n.useContext(kr);if(t===void 0)throw new Error("useTenant must be used within a TenantProvider");return t}const Et=5,Ar=n.createContext(null);function Pr({children:t}){const{i18n:s}=ne.useTranslation(),{isAuthenticated:r}=Pe(),{currentTenant:a,isLoading:o}=Ee(),[c,i]=n.useState([]),[d,u]=n.useState(!1),[m,p]=n.useState(null),[f,g]=n.useState(!1),b=n.useCallback(()=>{g(!0)},[]),h=n.useCallback(()=>{g(!1)},[]),y=n.useCallback(async()=>{try{u(!0),p(null);const A=(await E.get("/api/navigation/module-favorites")).map(R=>({id:R.id,code:R.code,label:R.label,icon:R.icon||"Star",route:R.route||"",applicationId:R.applicationId,applicationCode:R.applicationCode,applicationLabel:R.applicationLabel,displayOrder:R.displayOrder}));i(A)}catch(k){console.error("Failed to load favorite modules:",k),p("Erreur lors du chargement des favoris"),i([])}finally{u(!1)}},[]);n.useEffect(()=>{r&&!o?y():r||(i([]),p(null))},[r,o,a,y]),n.useEffect(()=>{const k=()=>{r&&!o&&y()};return s.on("languageChanged",k),()=>{s.off("languageChanged",k)}},[s,r,o,y]);const x=n.useCallback(async k=>{if(c.length>=Et||c.some(A=>A.id===k.id))return!1;try{return p(null),await E.post(`/api/navigation/module-favorites/${k.id}`),i(A=>[...A,{...k,displayOrder:A.length+1}]),!0}catch(A){return console.error("Failed to add favorite module:",A),await y(),!1}},[c,y]),j=n.useCallback(async k=>{try{return p(null),await E.delete(`/api/navigation/module-favorites/${k}`),i(A=>A.filter(R=>R.id!==k)),!0}catch(A){return console.error("Failed to remove favorite module:",A),await y(),!1}},[y]),v=n.useCallback(k=>c.some(A=>A.id===k),[c]),S=n.useCallback(async k=>v(k.id)?await j(k.id):await x(k),[v,j,x]),N=n.useCallback(async k=>{const A=k.slice(0,Et),R=A.map(q=>q.id),$=[...c];i(A.map((q,C)=>({...q,displayOrder:C+1})));try{return p(null),await E.put("/api/navigation/module-favorites/reorder",R),!0}catch(q){return console.error("Failed to reorder favorite modules:",q),i($),!1}},[c]),I=c.length<Et;return e.jsx(Ar.Provider,{value:{favorites:c,loading:d,error:m,addFavorite:x,removeFavorite:j,toggleFavorite:S,isFavorite:v,reorderFavorites:N,canAddMore:I,maxFavorites:Et,reload:y,expandFavorites:f,triggerExpand:b,clearExpand:h,requiresTenant:!1},children:t})}function Ke(){const t=n.useContext(Ar);if(!t)throw new Error("useFavorites must be used within a FavoritesProvider");return t}const Tr="smartstack-sidebar-collapsed",Rr=n.createContext(void 0);function zn(){if(typeof window>"u")return!1;try{return localStorage.getItem(Tr)==="true"}catch{return!1}}function Er({children:t}){const[s,r]=n.useState(zn);n.useEffect(()=>{localStorage.setItem(Tr,String(s))},[s]);const a=n.useCallback(()=>{r(i=>!i)},[]),o=n.useCallback(i=>{r(i)},[]),c=s?64:256;return e.jsx(Rr.Provider,{value:{isCollapsed:s,toggleCollapsed:a,setCollapsed:o,sidebarWidth:c},children:t})}function qt(){const t=n.useContext(Rr);if(t===void 0)throw new Error("useSidebar must be used within a SidebarProvider");return t}const Ir=["login","callback","logout","onboarding","system","applications","notifications"],Lr=n.createContext(void 0);function Bn(t){let s=t.split("/").filter(Boolean);return s.length>=2&&s[0]==="t"&&(s=s.slice(2)),s.length===0?{app:null,module:null}:Ir.includes(s[0])?{app:null,module:null}:{app:s[0]||null,module:s[1]||null}}function xs({children:t}){const s=w.useLocation(),{i18n:r}=ne.useTranslation(),{currentTenant:a,isLoading:o,isGlobalView:c}=Ee(),[i,d]=n.useState(null),[u,m]=n.useState([]),[p,f]=n.useState(!0),g=n.useRef(!1),b=n.useRef(void 0),h=n.useRef(0),y=c?"global":a?.id??"none";g.current&&y!==b.current&&!p&&f(!0);const{app:x,module:j}=Bn(s.pathname),v=n.useCallback(async()=>{try{const C=await E.get("/api/navigation/menu");d(C)}catch(C){console.error("Failed to fetch menu:",C)}},[]),S=n.useCallback(async()=>{try{const C=await E.get("/api/navigation/favorites");m(C)}catch(C){console.error("Failed to fetch favorites:",C)}},[]),N=n.useCallback(async()=>{const C=++h.current;if(f(!0),await v(),C===h.current){if(a){if(await S(),C!==h.current)return}else m([]);f(!1)}},[v,S,a]);n.useEffect(()=>{const C=localStorage.getItem("token"),D=c?"global":a?.id??"none";if(!(!C||o)){if(!g.current){g.current=!0,b.current=D,N();return}D!==b.current&&(b.current=D,N())}},[a?.id,c,o]),n.useEffect(()=>{const C=()=>{localStorage.getItem("token")&&N()};return r.on("languageChanged",C),()=>{r.off("languageChanged",C)}},[r,N]);const I=n.useCallback(C=>C.startsWith("core_")?C.slice(5):C.startsWith("ext_")?C.slice(4):C,[]),P=n.useCallback((C,D)=>C&&C.split("/").filter(Boolean)[D]||null,[]),k=n.useCallback(()=>i?.applications.find(C=>P(C.route,0)===x||I(C.code)===x),[i,x,P,I]),A=n.useCallback(()=>k()?.modules.find(D=>P(D.route,1)===j||I(D.code)===j),[k,j,P,I]),R=n.useCallback(C=>i?.applications.filter(D=>D.zone===C)||[],[i]),$=n.useCallback(C=>u.some(D=>D.id===C),[u]),q=n.useCallback(async C=>{if(a)try{$(C)?(await E.delete(`/api/navigation/favorites/${C}`),m(D=>D.filter(Y=>Y.id!==C))):(await E.post(`/api/navigation/favorites/${C}`,{}),await S())}catch(D){console.error("Failed to toggle favorite:",D)}},[a,$,S]);return e.jsx(Lr.Provider,{value:{menu:i,favorites:u,currentAppCode:x,currentModuleCode:j,isLoading:p,getCurrentApplication:k,getCurrentModule:A,getApplicationsByZone:R,getApplicationsForContext:R,toggleFavorite:q,isFavorite:$,refreshMenu:N},children:t})}function Ce(){const t=n.useContext(Lr);if(t===void 0)throw new Error("useNavigation must be used within a NavigationProvider");return t}const $r=n.createContext(null);function Dr({children:t}){const{isAuthenticated:s,refreshPermissions:r}=Pe(),{refreshMenu:a}=Ce(),o=n.useRef(null),[c,i]=n.useState(oe.HubConnectionState.Disconnected),d=n.useRef(new Set),u=n.useRef(new Set),m=n.useRef(!1),p=n.useCallback(async()=>{if(!m.current){m.current=!0;try{await Promise.all([r(),a()])}catch(x){console.error("[SignalR] Failed to refresh permissions:",x)}finally{m.current=!1}}},[r,a]),f=n.useCallback(async()=>{const x=localStorage.getItem("token");if(x&&!(o.current?.state===oe.HubConnectionState.Connected||o.current?.state===oe.HubConnectionState.Connecting))try{const j=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>x}).withAutomaticReconnect({nextRetryDelayInMilliseconds:v=>v.previousRetryCount===0?0:v.previousRetryCount===1?2e3:v.previousRetryCount===2?1e4:v.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();j.on("ReceiveNotification",v=>{d.current.forEach(S=>S(v))}),j.on("UnreadCountUpdate",v=>{u.current.forEach(S=>S(v))}),j.on("PermissionsChanged",p),j.onreconnecting(()=>{i(oe.HubConnectionState.Reconnecting)}),j.onreconnected(()=>{i(oe.HubConnectionState.Connected)}),j.onclose(()=>{i(oe.HubConnectionState.Disconnected)}),await j.start(),o.current=j,i(oe.HubConnectionState.Connected)}catch(j){console.error("[SignalR] Failed to connect:",j),i(oe.HubConnectionState.Disconnected)}},[p]),g=n.useCallback(async()=>{if(o.current)try{await o.current.stop(),o.current=null,i(oe.HubConnectionState.Disconnected)}catch(x){console.error("[SignalR] Failed to disconnect:",x)}},[]);n.useEffect(()=>(s?f():g(),()=>{g()}),[s,f,g]);const b=n.useCallback(x=>(d.current.add(x),()=>{d.current.delete(x)}),[]),h=n.useCallback(x=>(u.current.add(x),()=>{u.current.delete(x)}),[]),y={isConnected:c===oe.HubConnectionState.Connected,connectionState:c,onNotification:b,onUnreadCountUpdate:h};return e.jsx($r.Provider,{value:y,children:t})}function Mr(){const t=n.useContext($r);if(!t)throw new Error("useSignalRContext must be used within a SignalRProvider");return t}const Dt={register:async t=>E.post("/api/auth/register",t),confirmEmail:async t=>E.post("/api/auth/confirm-email",{token:t}),resendConfirmation:async t=>E.post("/api/auth/resend-confirmation",{email:t}),forgotPassword:async t=>E.post("/api/auth/forgot-password",{email:t}),resetPassword:async(t,s)=>E.post("/api/auth/reset-password",{token:t,newPassword:s}),login:async(t,s)=>{const r=await E.post("/api/auth/login",{email:t,password:s});return r.token&&(localStorage.setItem("token",r.token),localStorage.setItem("refreshToken",r.refreshToken)),r},logout:async()=>{try{await E.post("/api/auth/logout")}finally{localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user")}},changePassword:async(t,s)=>E.post("/api/auth/change-password",{currentPassword:t,newPassword:s}),refreshSession:async()=>{const t=await E.post("/api/auth/refresh");return t.token&&(localStorage.setItem("token",t.token),localStorage.setItem("refreshToken",t.refreshToken)),t},getSessionInfo:async t=>E.get("/api/auth/session-info",{signal:t?.signal})};function Or(t={}){const{checkIntervalMs:s=6e4,onSessionExpired:r,onWarningThreshold:a,enabled:o=!0}=t,[c,i]=n.useState({isActive:!0,timeRemainingSeconds:0,isWarning:!1,sessionInfo:null}),[d,u]=n.useState(!1),m=n.useRef(!1),p=n.useRef(null),f=n.useRef(null),g=n.useCallback(async h=>{if(!o)return;if(!localStorage.getItem("token")){i(x=>({...x,isActive:!1}));return}try{const x=await Dt.getSessionInfo({signal:h});if(h?.aborted)return;const j=Math.min(x.timeUntilIdleExpirySeconds,x.timeUntilAbsoluteExpirySeconds);i({isActive:!0,timeRemainingSeconds:j,isWarning:x.isWarningThreshold,sessionInfo:x}),x.isWarningThreshold&&!m.current&&(m.current=!0,a?.()),x.isWarningThreshold||(m.current=!1)}catch(x){if(x instanceof Error&&x.name==="CanceledError"||h?.aborted)return;i(j=>({...j,isActive:!1})),r?.()}},[o,r,a]),b=n.useCallback(async()=>{if(d)return!1;u(!0);try{return await Dt.refreshSession(),m.current=!1,await g(),!0}catch{return i(h=>({...h,isActive:!1})),!1}finally{u(!1)}},[d,g]);return n.useEffect(()=>{if(!o)return;f.current?.abort();const h=new AbortController;return f.current=h,g(h.signal),p.current=setInterval(()=>g(),s),()=>{h.abort(),p.current&&clearInterval(p.current)}},[o,s,g]),n.useEffect(()=>{if(!o)return;const h=()=>{c.isWarning&&g()},y=["mousedown","keydown","touchstart","scroll"];return y.forEach(x=>{window.addEventListener(x,h,{passive:!0})}),()=>{y.forEach(x=>{window.removeEventListener(x,h)})}},[o,c.isWarning,g]),{...c,isRefreshing:d,refreshSession:b,checkSession:g}}function Gn(t){if(t<=0)return"0:00";const s=Math.floor(t/60),r=t%60;if(s>=60){const a=Math.floor(s/60),o=s%60;return`${a}h ${o}min`}return`${s}:${r.toString().padStart(2,"0")}`}function Fr({isOpen:t,timeRemainingSeconds:s,onExtendSession:r,onLogout:a}){const{t:o}=ne.useTranslation("common"),[c,i]=n.useState(!1),[d,u]=n.useState(s);n.useEffect(()=>{u(s)},[s]),n.useEffect(()=>{if(!t||d<=0)return;const f=setInterval(()=>{u(g=>g<=1?(a(),0):g-1)},1e3);return()=>clearInterval(f)},[t,d,a]);const m=async()=>{i(!0);try{await r()||a()}finally{i(!1)}};if(!t)return null;const p=Math.max(0,Math.min(100,d/300*100));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-md bg-[var(--bg-card)] rounded-2xl shadow-2xl border border-amber-500/30 overflow-hidden animate-in fade-in zoom-in duration-200",children:[e.jsx("div",{className:"absolute top-0 left-0 h-1 bg-amber-500/30 w-full",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-amber-500 to-orange-500 transition-all duration-1000 ease-linear",style:{width:`${p}%`}})}),e.jsxs("div",{className:"p-6 pt-8",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-amber-500/20 flex items-center justify-center mb-4",children:e.jsx(l.Clock,{className:"w-8 h-8 text-amber-500"})}),e.jsx("h2",{className:"text-xl font-semibold text-[var(--text-primary)] mb-2",children:o("session.warningTitle","Session Expiring")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:o("session.warningMessage","Your session will expire due to inactivity.")}),e.jsx("div",{className:"text-4xl font-mono font-bold text-amber-500 tabular-nums",children:Gn(d)}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-2",children:o("session.remainingTime","remaining")})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("button",{onClick:a,className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 rounded-xl border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-all font-medium",children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),o("session.logout","Logout")]}),e.jsxs("button",{onClick:m,disabled:c,className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 rounded-xl font-medium transition-all bg-gradient-to-r from-amber-500 to-orange-500 text-white hover:from-amber-600 hover:to-orange-600 shadow-lg shadow-amber-500/30 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(l.RefreshCw,{className:`w-4 h-4 ${c?"animate-spin":""}`}),c?o("session.extending","Extending..."):o("session.extend","Continue Session")]})]})]})]})})}const Kn=n.createContext(void 0);function _r({children:t}){const{isAuthenticated:s,logout:r}=Pe(),a=n.useCallback(()=>{localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user"),window.location.href="/login?reason=session_expired"},[]),{isActive:o,timeRemainingSeconds:c,isWarning:i,refreshSession:d}=Or({enabled:s,checkIntervalMs:3e4,onSessionExpired:a}),u=n.useCallback(async()=>{try{await Dt.logout()}finally{r()}},[r]),m=n.useCallback(async()=>await d(),[d]);return e.jsxs(Kn.Provider,{value:{isSessionActive:o,timeRemainingSeconds:c,isWarning:i,refreshSession:d},children:[t,e.jsx(Fr,{isOpen:i&&s,timeRemainingSeconds:c,onExtendSession:m,onLogout:u})]})}const Hn=150;function Vn({children:t}){const s=qn(),r=s?.isAuthenticated??!1,a=s?.isLoading??!0,{currentTenant:o,isLoading:c,isGlobalView:i}=Ee(),{setSelectedThemeTenant:d,loadFromServer:u}=Ct(),m=n.useRef(null),p=n.useRef(!1),f=n.useRef(null),g=n.useRef(null),b=n.useCallback(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),h=n.useCallback(()=>m.current==="global"?!1:(b(),g.current=null,m.current="global",p.current=!0,u("global"),d(null,!0),!0),[b,u,d]),y=n.useCallback((v,S)=>{g.current=v,f.current=setTimeout(()=>{g.current===v&&(m.current=v,p.current=!0,g.current=null,d(v,!1)),f.current=null},Hn)},[d]),x=n.useCallback(()=>{if(!o)return;const v=o.id!==m.current,S=g.current!==null&&g.current!==o.id;!v&&!S||(b(),v?y(o.id,o.slug):g.current=null)},[o,b,y]),j=n.useCallback(()=>{b(),m.current=null,g.current=null,p.current=!1},[b]);return n.useEffect(()=>{if(!r){j();return}if(!(a||c)){if(i&&!o){h();return}o&&x()}},[r,a,c,o,i,h,x,j]),n.useEffect(()=>()=>{b()},[b]),e.jsx(e.Fragment,{children:t})}function Wn(t){const s=t.message.toLowerCase(),r=t.name.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("failed to fetch")||s.includes("econnrefused")||s.includes("timeout")?"network":s.includes("401")||s.includes("403")||s.includes("unauthorized")||s.includes("forbidden")||s.includes("permission")?"permission":s.includes("404")||s.includes("not found")?"notFound":r.includes("validation")||s.includes("validation")||s.includes("invalid")?"validation":"technical"}function Xn(){const t=Date.now().toString(36),s=Math.random().toString(36).substring(2,6);return`ERR-${t}-${s}`.toUpperCase()}const Yn={network:{icon:l.WifiOff,color:"text-orange-500",bgColor:"bg-orange-500/10"},permission:{icon:l.ShieldX,color:"text-red-500",bgColor:"bg-red-500/10"},notFound:{icon:l.FileWarning,color:"text-yellow-500",bgColor:"bg-yellow-500/10"},validation:{icon:l.AlertTriangle,color:"text-amber-500",bgColor:"bg-amber-500/10"},technical:{icon:l.Bug,color:"text-red-500",bgColor:"bg-red-500/10"}};function qr({error:t,resetErrorBoundary:s}){const{t:r}=ne.useTranslation("common"),[a,o]=n.useState(!1),[c]=n.useState(()=>Xn()),i=Wn(t),d=Yn[i],u=d.icon,m=()=>{window.history.length>2&&document.referrer?window.location.href=document.referrer:window.history.length>2?(window.history.back(),setTimeout(()=>window.location.reload(),50)):window.location.href="/"};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[var(--bg-primary)] p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`w-16 h-16 rounded-full ${d.bgColor} flex items-center justify-center mb-6`,children:e.jsx(u,{className:`w-8 h-8 ${d.color}`})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:r(`errors.${i}.title`,{defaultValue:r("errors.technical.title")})}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:r(`errors.${i}.description`,{defaultValue:r("errors.technical.description")})}),e.jsxs("div",{className:"mb-6 px-3 py-1.5 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[r("errors.errorId"),": "]}),e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:c})]}),!1,e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("button",{onClick:s,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),r("errors.retry")]}),e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),r("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),r("errors.home")]})]}),e.jsxs("p",{className:"mt-6 text-sm text-[var(--text-tertiary)]",children:[r("errors.persistsHelp")," ",e.jsx("a",{href:"mailto:support@atlashub.ch",className:"text-[var(--color-accent-500)] hover:underline",children:r("errors.contactSupport")})]})]})})})}function Jn(t,s){Te.logCritical(t,"GlobalErrorBoundary",{componentStack:s.componentStack})}function Qn(){window.location.reload()}function Ur({children:t}){return e.jsx(ur.ErrorBoundary,{FallbackComponent:qr,onError:Jn,onReset:Qn,children:t})}const Ut=n.createContext(null);function zr(){const t=n.useContext(Ut);if(!t)throw new Error("useSlotFill must be used within a SlotFillProvider");return t}function Br({children:t,initialFills:s}){const r=n.useMemo(()=>{const o=new Map;return s&&Object.entries(s).forEach(([c,i])=>{const d=o.get(c)||[];Array.isArray(i)?o.set(c,[...d,...i]):o.set(c,[...d,i])}),o},[s]),a=n.useMemo(()=>({fills:r,registerFill:(o,c)=>{const i=r.get(o)||[];r.set(o,[...i,c])},unregisterFill:(o,c)=>{const i=r.get(o)||[];r.set(o,i.filter(d=>d!==c))},getSlotContent:o=>r.get(o)||[]}),[r]);return e.jsx(Ut.Provider,{value:a,children:t})}function Gr({name:t,context:s={},children:r,fallback:a,wrapper:o}){const i=n.useContext(Ut)?.getSlotContent(t)||[],d=n.useMemo(()=>({slotName:t,context:s}),[t,s]),u=n.useMemo(()=>i.length===0?a||null:i.map((p,f)=>{const g=`${t}-${f}`;return e.jsx(n.Fragment,{children:Hr(p,d)},g)}),[i,t,d,a]),m=e.jsxs(e.Fragment,{children:[u,r]});return o?e.jsx(o,{children:m}):e.jsx(e.Fragment,{children:m})}function Kr({slot:t,children:s}){const{registerFill:r,unregisterFill:a}=zr();return n.useMemo(()=>(r(t,s),()=>a(t,s)),[t,s,r,a]),null}function Hr(t,s){if(t==null)return null;if(Array.isArray(t))return e.jsx(e.Fragment,{children:t.map((r,a)=>e.jsx(n.Fragment,{children:Hr(r,s)},`slot-item-${a}`))});if(n.isValidElement(t))return t;if(typeof t=="function"){const r=t;return e.jsx(r,{...s})}return t}function Zn(t){return(n.useContext(Ut)?.getSlotContent(t)?.length||0)>0}function eo(t){function s(a){return e.jsx(Gr,{...a,name:t})}s.displayName=`Slot(${t})`;function r({children:a}){return e.jsx(Kr,{slot:t,children:a})}return r.displayName=`Fill(${t})`,{Slot:s,Fill:r,slotName:t}}const Vr=n.createContext(null);function At(){const t=n.useContext(Vr);return t||{config:{},getPage:()=>{},getSlotContent:()=>{},getTableColumns:()=>[],getFormFields:()=>[],hasExtension:()=>!1}}function zt(t){const{getPage:s}=At();return s(t)}function to(t){const{getTableColumns:s}=At();return s(t)}function so(t){const{getFormFields:s}=At();return s(t)}function ro(t){const{hasExtension:s}=At();return s(t)}function Wr({config:t={},children:s}){const r=n.useMemo(()=>{const{pages:a={},slots:o={},tableColumns:c={},formFields:i={}}=t;return{config:t,getPage:d=>a[d],getSlotContent:d=>o[d],getTableColumns:d=>c[d]||[],getFormFields:d=>i[d]||[],hasExtension:d=>d in a||d in o||d in c||d in i}},[t]);return e.jsx(Vr.Provider,{value:r,children:e.jsx(Br,{initialFills:t.slots,children:s})})}class ao{pages=new Map;register(s,r,a=[]){this.pages.set(s,{key:s,defaultComponent:r,slots:a})}get(s){return this.pages.get(s)}resolve(s){return this.pages.get(s)?.defaultComponent}getAll(){return Array.from(this.pages.values())}has(s){return this.pages.has(s)}getSlots(s){return this.pages.get(s)?.slots||[]}keys(){return Array.from(this.pages.keys())}}const O=new ao;function no(t,s){function r(a){const o=zt(t);return o?e.jsx(o,{...a}):e.jsx(s,{...a})}return r.displayName=`Overridable(${t})`,r}function oo(t){const s=zt(t),r=O.get(t);return s||r?.defaultComponent}function io({pageKey:t,defaultComponent:s,params:r}){const a=zt(t),o={pageKey:t,params:r};return a?e.jsx(a,{...o}):e.jsx(s,{...o})}const _={ADMIN_INDEX:"administration",ADMIN_DASHBOARD:"administration.dashboard",USERS_LIST:"administration.users.list",USERS_DETAIL:"administration.users.detail",USERS_DASHBOARD:"administration.users.dashboard",USERS_GROUPS:"administration.users.groups",USERS_GROUPS_DETAIL:"administration.users.groups.detail",USERS_REFERENCES:"administration.users.references",ROLES_LIST:"administration.permissions.roles",ROLES_DETAIL:"administration.permissions.roles.detail",PERMISSIONS_LIST:"administration.permissions.permissions",PERMISSIONS_DETAIL:"administration.permissions.permissions.detail",ASSIGNMENTS:"administration.permissions.assignments",APPLICATIONS_INDEX:"administration.applications",APPLICATIONS_DASHBOARD:"administration.applications.dashboard",APPLICATIONS_LIST:"administration.applications.list",APPLICATIONS_DETAIL:"administration.applications.detail",AI_DASHBOARD:"administration.ai.dashboard",AI_SETTINGS:"administration.ai.settings",AI_SKILLS_LIST:"administration.ai.skills",AI_SKILLS_DETAIL:"administration.ai.skills.detail",AI_SKILLS_CREATE:"administration.ai.skills.create",AI_SKILLS_EDIT:"administration.ai.skills.edit",AI_BLOCKS_LIST:"administration.ai.skills.blocks",AI_BLOCKS_DETAIL:"administration.ai.skills.blocks.detail",AI_BLOCKS_CREATE:"administration.ai.skills.blocks.create",AI_BLOCKS_EDIT:"administration.ai.skills.blocks.edit",AI_MONITORING:"administration.ai.monitoring",AI_AGENTS:"administration.ai.agents",AI_AGENTS_DETAIL:"administration.ai.agents.detail",AI_AGENTS_EDIT:"administration.ai.agents.edit",WORKFLOWS_LIST:"administration.workflows.list",WORKFLOWS_DETAIL:"administration.workflows.detail",WORKFLOWS_CREATE:"administration.workflows.create",WORKFLOWS_EDIT:"administration.workflows.edit",WORKFLOWS_TRIGGERS:"administration.workflows.triggers",WORKFLOWS_HISTORY:"administration.workflows.history",EMAIL_TEMPLATES_LIST:"administration.workflows.email-templates",EMAIL_TEMPLATES_DETAIL:"administration.workflows.email-templates.detail",EMAIL_TEMPLATES_CREATE:"administration.workflows.email-templates.create",EMAIL_TEMPLATES_EDIT:"administration.workflows.email-templates.edit",SMS_TEMPLATES_LIST:"administration.workflows.email-templates.sms",ENTRA_DASHBOARD:"administration.entra.dashboard",ENTRA_GROUPS:"administration.entra.groups",ENTRA_USERS:"administration.entra.users",ENTRA_CONFLICTS:"administration.entra.conflicts",ENTRA_SETTINGS:"administration.entra.settings",TENANTS_DASHBOARD:"administration.tenants.dashboard",TENANTS_LIST:"administration.tenants.list",TENANTS_DETAIL:"administration.tenants.detail",TENANTS_CREATE:"administration.tenants.create",TENANTS_SETTINGS:"administration.tenants.settings",TENANTS_TYPE_SETTINGS:"administration.tenants.type-settings",TENANTS_TEMPLATE:"administration.tenants.template",TENANTS_TEMPLATE_CREATE:"administration.tenants.template.create",TENANTS_TEMPLATE_DETAIL:"administration.tenants.template.detail",TENANTS_BUSINESS:"administration.tenants.list.enterprise",TENANTS_PERSONAL:"administration.tenants.list.personal",TENANTS_OTHER:"administration.tenants.list.other",TENANTS_ACCESS_REQUESTS:"administration.tenants.access-requests",ORGANISATIONS_LIST:"administration.tenants.organisations",ORGANISATIONS_CREATE:"administration.tenants.organisations.create",ORGANISATIONS_DETAIL:"administration.tenants.organisations.detail",SETTINGS:"administration.configuration.settings",SETTINGS_GENERAL:"administration.configuration.settings.general",SETTINGS_FILE_UPLOAD:"administration.configuration.settings.file-upload",SETTINGS_LEGAL_FILE:"administration.configuration.settings.legal-file",APPSETTINGS:"administration.configuration.appsettings",APPSETTINGS_INFRASTRUCTURE:"administration.configuration.appsettings.infrastructure",APPSETTINGS_AUTHENTICATION:"administration.configuration.appsettings.authentication",APPSETTINGS_LOGGING:"administration.configuration.appsettings.logging",APPSETTINGS_EMAIL:"administration.configuration.appsettings.email",APPSETTINGS_ENTRA:"administration.configuration.appsettings.entra",LICENSE:"administration.configuration.license",API_ACCOUNTS_LIST:"api.accounts.list",API_ACCOUNTS_CREATE:"api.accounts.create",API_ACCOUNTS_DETAIL:"api.accounts.detail",API_CATALOG:"api.apis.catalog",API_CATALOG_DETAIL:"api.apis.catalog.detail",SUPPORT_DASHBOARD:"support.tickets",TICKETS_LIST:"support.tickets.list",TICKETS_DETAIL:"support.tickets.detail",TICKETS_ESCALATION:"support.tickets.escalation",TICKETS_NEW:"support.tickets.new",MY_TICKETS_LIST:"support.my-tickets",MY_TICKETS_DETAIL:"support.my-tickets.detail",MY_TICKETS_CREATE:"support.my-tickets.create",SUPPORT_SLA:"support.admin.sla",SUPPORT_TEMPLATES:"support.admin.templates",SUPPORT_PERMISSIONS:"support.admin.permissions",SUPPORT_ASSIGNMENT:"support.assignment",SUPPORT_ASSIGNMENT_SKILLS:"support.assignment.skills",SUPPORT_ASSIGNMENT_WORKLOAD:"support.assignment.workload",MYSPACE_DASHBOARD:"myspace.dashboard",USER_PROFILE:"myspace.profile",USER_PREFERENCES:"myspace.preferences",MYSPACE_TENANTS:"myspace.tenants.workspaces",MYSPACE_ACCESS_REQUESTS:"myspace.tenants.access-requests",MYSPACE_PORTAL:"myspace.portal",NOTIFICATIONS:"notifications",APPLICATIONS_HUB:"applications"};O.register(_.ADMIN_INDEX,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsGridPage-BQaMsK1K.js")).then(t=>({default:t.ApplicationsGridPage}))));O.register(_.ADMIN_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-B48_rQFi.js")).then(t=>({default:t.AdminDashboardPage}))));O.register(_.USERS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./UsersPage-TYAfwPY1.js")).then(t=>({default:t.UsersPage}))));O.register(_.USERS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./UserDetailPage-CV2VCE46.js")).then(t=>({default:t.UserDetailPage}))));O.register(_.USERS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-B48_rQFi.js")).then(t=>({default:t.AdminDashboardPage}))));O.register(_.USERS_GROUPS,n.lazy(()=>Promise.resolve().then(()=>require("./UsersGroupsPage-BgfAMgEP.js")).then(t=>({default:t.UsersGroupsPage}))));O.register(_.USERS_GROUPS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./GroupDetailPage-B2FkKrGG.js")).then(t=>({default:t.GroupDetailPage}))));O.register(_.USERS_REFERENCES,n.lazy(()=>Promise.resolve().then(()=>require("./ReferencesManagementPage-DhVsuElE.js")).then(t=>({default:t.ReferencesManagementPage}))));O.register(_.ROLES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./RolesPage-Pm-RN3lP.js")).then(t=>({default:t.RolesPage}))));O.register(_.ROLES_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./RoleDetailPage-CiRVxxIP.js")).then(t=>({default:t.RoleDetailPage}))));O.register(_.PERMISSIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./PermissionsPage-l0PnY-EE.js")).then(t=>({default:t.PermissionsPage}))));O.register(_.PERMISSIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./PermissionDetailPage-Dh8v7mGj.js")).then(t=>({default:t.PermissionDetailPage}))));O.register(_.ASSIGNMENTS,n.lazy(()=>Promise.resolve().then(()=>require("./AssignmentsPage-DmfBYQAD.js")).then(t=>({default:t.AssignmentsPage}))));O.register(_.APPLICATIONS_INDEX,n.lazy(()=>Promise.resolve().then(()=>require("./NavigationAppsPage-If7tmCFY.js")).then(t=>({default:t.NavigationAppsPage}))));O.register(_.APPLICATIONS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsDashboardPage-BBlLms2r.js")).then(t=>({default:t.ApplicationsDashboardPage}))));O.register(_.APPLICATIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsListPage-DYKM2Yeo.js")).then(t=>({default:t.ApplicationsListPage}))));O.register(_.APPLICATIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationDetailPage-BYJ2YMPq.js"))));O.register(_.AI_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiDashboardPage}))));O.register(_.AI_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiSettingsPage}))));O.register(_.AI_SKILLS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiSkillsListPage}))));O.register(_.AI_SKILLS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiSkillsDetailPage}))));O.register(_.AI_SKILLS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiSkillsEditPage}))));O.register(_.AI_SKILLS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiSkillsEditPage}))));O.register(_.AI_BLOCKS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiBlockDefinitionsListPage}))));O.register(_.AI_BLOCKS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiBlockDefinitionDetailPage}))));O.register(_.AI_BLOCKS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiBlockDefinitionEditPage}))));O.register(_.AI_BLOCKS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiBlockDefinitionEditPage}))));O.register(_.AI_MONITORING,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiMonitoringPage}))));O.register(_.AI_AGENTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiAgentsPage}))));O.register(_.AI_AGENTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiAgentDetailPage}))));O.register(_.AI_AGENTS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-CSQ60fpG.js")).then(t=>({default:t.AiAgentEditPage}))));O.register(_.WORKFLOWS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.WorkflowsListPage}))));O.register(_.WORKFLOWS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.WorkflowDetailPage}))));O.register(_.WORKFLOWS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.WorkflowCreatePage}))));O.register(_.WORKFLOWS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.WorkflowEditPage}))));O.register(_.WORKFLOWS_TRIGGERS,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.WorkflowsTriggersPage}))));O.register(_.WORKFLOWS_HISTORY,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.WorkflowHistoryPage}))));O.register(_.EMAIL_TEMPLATES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.EmailTemplatesListPage}))));O.register(_.EMAIL_TEMPLATES_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.EmailTemplateDetailPage}))));O.register(_.EMAIL_TEMPLATES_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.EmailTemplateCreatePage}))));O.register(_.EMAIL_TEMPLATES_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.EmailTemplateEditPage}))));O.register(_.SMS_TEMPLATES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-C53JoVNk.js")).then(t=>({default:t.SmsTemplatesListPage}))));O.register(_.ENTRA_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-DCcl7Qof.js")).then(t=>({default:t.EntraDashboardPage}))));O.register(_.ENTRA_GROUPS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DCcl7Qof.js")).then(t=>({default:t.EntraGroupsPage}))));O.register(_.ENTRA_USERS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DCcl7Qof.js")).then(t=>({default:t.EntraUsersPage}))));O.register(_.ENTRA_CONFLICTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DCcl7Qof.js")).then(t=>({default:t.EntraConflictsPage}))));O.register(_.ENTRA_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DCcl7Qof.js")).then(t=>({default:t.EntraSettingsPage}))));O.register(_.TENANTS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantsDashboardPage}))));O.register(_.TENANTS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantsPage}))));O.register(_.TENANTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantDetailPage}))));O.register(_.TENANTS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantCreatePage}))));O.register(_.TENANTS_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantSettingsPage}))));O.register(_.TENANTS_TYPE_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantTypeSettingsPage}))));O.register(_.TENANTS_TEMPLATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantsTemplatePage}))));O.register(_.TENANTS_TEMPLATE_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantTemplateCreatePage}))));O.register(_.TENANTS_TEMPLATE_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantTemplateDetailPage}))));O.register(_.TENANTS_BUSINESS,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantsBusinessPage}))));O.register(_.TENANTS_PERSONAL,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantsPersonalPage}))));O.register(_.TENANTS_OTHER,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantsOtherPage}))));O.register(_.TENANTS_ACCESS_REQUESTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.TenantAccessRequestsPage}))));O.register(_.ORGANISATIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.OrganisationsListPage}))));O.register(_.ORGANISATIONS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.OrganisationCreatePage}))));O.register(_.ORGANISATIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-sMr9qND_.js")).then(t=>({default:t.OrganisationDetailPage}))));O.register(_.SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CHG_O1fS.js")).then(t=>({default:t.SettingsPage}))));O.register(_.SETTINGS_GENERAL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CHG_O1fS.js")).then(t=>({default:t.GeneralSettingsSection}))));O.register(_.SETTINGS_FILE_UPLOAD,n.lazy(()=>Promise.resolve().then(()=>require("./index-CHG_O1fS.js")).then(t=>({default:t.FileUploadSettingsSection}))));O.register(_.SETTINGS_LEGAL_FILE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CHG_O1fS.js")).then(t=>({default:t.LegalFileSettingsSection}))));O.register(_.APPSETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-C33zcyF4.js")).then(t=>({default:t.AppSettingsPage}))));O.register(_.APPSETTINGS_INFRASTRUCTURE,n.lazy(()=>Promise.resolve().then(()=>require("./index-C33zcyF4.js")).then(t=>({default:t.InfrastructureSection}))));O.register(_.APPSETTINGS_AUTHENTICATION,n.lazy(()=>Promise.resolve().then(()=>require("./index-C33zcyF4.js")).then(t=>({default:t.AuthenticationSection}))));O.register(_.APPSETTINGS_LOGGING,n.lazy(()=>Promise.resolve().then(()=>require("./index-C33zcyF4.js")).then(t=>({default:t.LoggingSection}))));O.register(_.APPSETTINGS_EMAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-C33zcyF4.js")).then(t=>({default:t.EmailSection}))));O.register(_.APPSETTINGS_ENTRA,n.lazy(()=>Promise.resolve().then(()=>require("./index-C33zcyF4.js")).then(t=>({default:t.EntraSection}))));O.register(_.LICENSE,n.lazy(()=>Promise.resolve().then(()=>require("./index-D2REDIRX.js")).then(t=>({default:t.LicenseManagementPage}))));O.register(_.API_ACCOUNTS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-B0mk2tNY.js")).then(t=>({default:t.ExternalAppsListPage}))));O.register(_.API_ACCOUNTS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-B0mk2tNY.js")).then(t=>({default:t.ExternalAppCreatePage}))));O.register(_.API_ACCOUNTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-B0mk2tNY.js")).then(t=>({default:t.ExternalAppDetailPage}))));O.register(_.API_CATALOG,n.lazy(()=>Promise.resolve().then(()=>require("./ApiCatalogPage-BBkWSLI8.js")).then(t=>({default:t.ApiCatalogPage}))));O.register(_.API_CATALOG_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./ApiCatalogDetailPage-BQ53xuwD.js")).then(t=>({default:t.ApiCatalogDetailPage}))));O.register(_.SUPPORT_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-CUZV1J9t.js")).then(t=>({default:t.DashboardPage}))));O.register(_.TICKETS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./TicketsPage-WdU4Bb7M.js")).then(t=>({default:t.TicketsPage}))));O.register(_.TICKETS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./TicketDetailPage-Du8WMyqf.js")).then(t=>({default:t.TicketDetailPage}))));O.register(_.TICKETS_ESCALATION,n.lazy(()=>Promise.resolve().then(()=>require("./EscalationConfigPage-CdzAbnGy.js")).then(t=>({default:t.EscalationConfigPage}))));O.register(_.TICKETS_NEW,n.lazy(()=>Promise.resolve().then(()=>require("./CreateSupportTicketPage-CKDX_HQm.js")).then(t=>({default:t.CreateSupportTicketPage}))));O.register(_.MY_TICKETS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./MyTicketsPage-DJR8h6y1.js")).then(t=>({default:t.MyTicketsPage}))));O.register(_.MY_TICKETS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./UserTicketDetailPage-CCNJON1V.js")).then(t=>({default:t.UserTicketDetailPage}))));O.register(_.MY_TICKETS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./UserCreateTicketPage-Cm1emgwR.js")).then(t=>({default:t.UserCreateTicketPage}))));O.register(_.SUPPORT_SLA,n.lazy(()=>Promise.resolve().then(()=>require("./SlaConfigPage-B86McKM6.js")).then(t=>({default:t.SlaConfigPage}))));O.register(_.SUPPORT_TEMPLATES,n.lazy(()=>Promise.resolve().then(()=>require("./TemplatesPage-BDguJ401.js")).then(t=>({default:t.TemplatesPage}))));O.register(_.SUPPORT_PERMISSIONS,n.lazy(()=>Promise.resolve().then(()=>require("./SupportPermissionsPage-MXqXNJIZ.js")).then(t=>({default:t.SupportPermissionsPage}))));O.register(_.SUPPORT_ASSIGNMENT,n.lazy(()=>Promise.resolve().then(()=>require("./AssignmentRulesPage-D8vfGDBN.js")).then(t=>({default:t.AssignmentRulesPage}))));O.register(_.SUPPORT_ASSIGNMENT_SKILLS,n.lazy(()=>Promise.resolve().then(()=>require("./AgentSkillsPage-7si3Ng8e.js")).then(t=>({default:t.AgentSkillsPage}))));O.register(_.SUPPORT_ASSIGNMENT_WORKLOAD,n.lazy(()=>Promise.resolve().then(()=>require("./AgentWorkloadPage-D4d86cdV.js")).then(t=>({default:t.AgentWorkloadPage}))));O.register(_.MYSPACE_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./UserDashboardPage-B53C8fUq.js")).then(t=>({default:t.UserDashboardPage}))));O.register(_.USER_PROFILE,n.lazy(()=>Promise.resolve().then(()=>require("./ProfilePage-DPoXwdnc.js")).then(t=>({default:t.ProfilePage}))));O.register(_.USER_PREFERENCES,n.lazy(()=>Promise.resolve().then(()=>require("./PreferencesPage-B81MsNV1.js")).then(t=>({default:t.PreferencesPage}))));O.register(_.MYSPACE_TENANTS,n.lazy(()=>Promise.resolve().then(()=>require("./MyTenantsPage-D9f85zjF.js")).then(t=>({default:t.MyTenantsPage}))));O.register(_.MYSPACE_ACCESS_REQUESTS,n.lazy(()=>Promise.resolve().then(()=>require("./MyAccessRequestsPage-C9IX4c0K.js"))));O.register(_.MYSPACE_PORTAL,n.lazy(()=>Promise.resolve().then(()=>require("./PortalDashboardPage-DFBx38-x.js")).then(t=>({default:t.PortalDashboardPage}))));O.register(_.NOTIFICATIONS,n.lazy(()=>Promise.resolve().then(()=>require("./NotificationsPage-BiaLRb0s.js")).then(t=>({default:t.NotificationsPage}))));O.register(_.APPLICATIONS_HUB,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsPage-BCbgotIx.js")).then(t=>({default:t.ApplicationsPage}))));const lo=n.createContext(null);function co({config:t,children:s}){typeof window<"u"&&(window.__SMARTSTACK_CONFIG__=t);const r=n.useMemo(()=>({config:t}),[t]);return e.jsx(lo.Provider,{value:r,children:e.jsx(Ur,{children:e.jsx(Wr,{config:t.extensions,children:e.jsx(br,{children:e.jsx(Fn,{children:e.jsx(Nr,{children:e.jsx(Un,{children:e.jsx(Cr,{children:e.jsx(Pr,{children:e.jsx(Er,{children:e.jsx(_r,{children:e.jsx(Vn,{children:e.jsx(xs,{children:e.jsx(Dr,{children:s})})})})})})})})})})})})})})}const Xr="smartstack-doc-panel-size",Yr=n.createContext(void 0);function uo(){if(typeof window>"u")return 33;try{const t=localStorage.getItem(Xr);if(t){const s=parseFloat(t);if(s>=20&&s<=60)return s}}catch{}return 33}const Ts={"administration/users":"/docs/business/administration/users","administration/users/dashboard":"/docs/business/administration/users","administration/users/list":"/docs/business/administration/users","administration/users/create":"/docs/business/administration/users","administration/users/groups":"/docs/business/administration/users/groups","administration/users/references":"/docs/business/administration/users/references","administration/permissions":"/docs/business/administration/permissions","administration/permissions/roles":"/docs/business/administration/permissions","administration/permissions/permissions":"/docs/business/administration/permissions","administration/permissions/assignments":"/docs/business/administration/permissions/assignments","administration/applications":"/docs/business/administration/applications","administration/applications/list":"/docs/business/administration/applications","administration/applications/grid":"/docs/business/administration/applications","administration/applications/dashboard":"/docs/business/administration/applications","administration/tenants":"/docs/business/administration/tenants","administration/tenants/dashboard":"/docs/business/administration/tenants","administration/tenants/create":"/docs/business/administration/tenants","administration/tenants/list":"/docs/business/administration/tenants/business","administration/tenants/list/enterprise":"/docs/business/administration/tenants/business","administration/tenants/list/personal":"/docs/business/administration/tenants/personal","administration/tenants/list/other":"/docs/business/administration/tenants/other","administration/tenants/template":"/docs/business/administration/tenants/template","administration/tenants/business":"/docs/business/administration/tenants/business","administration/tenants/personal":"/docs/business/administration/tenants","administration/tenants/organisations":"/docs/business/administration/tenants/organisations","administration/tenants/organisations/create":"/docs/business/administration/tenants/organisations","administration/tenants/access-requests":"/docs/business/administration/tenants/access-requests","administration/tenants/applications":"/docs/business/administration/tenants/applications","administration/workflows":"/docs/business/administration/workflows","administration/workflows/list":"/docs/business/administration/workflows","administration/workflows/create":"/docs/business/administration/workflows","administration/workflows/triggers":"/docs/business/administration/workflows","administration/workflows/history":"/docs/business/administration/workflows","administration/workflows/email-templates":"/docs/business/administration/workflows","administration/workflows/email-templates/email":"/docs/business/administration/workflows","administration/workflows/email-templates/sms":"/docs/business/administration/workflows","administration/workflows/email-templates/create":"/docs/business/administration/workflows","administration/ai":"/docs/business/administration/ai","administration/ai/dashboard":"/docs/business/administration/ai","administration/ai/settings":"/docs/business/administration/ai","administration/ai/providers":"/docs/business/administration/ai","administration/ai/models":"/docs/business/administration/ai","administration/ai/prompts":"/docs/business/administration/ai","administration/ai/blocks":"/docs/business/administration/ai","administration/entra":"/docs/business/administration/entra","administration/entra/dashboard":"/docs/business/administration/entra","administration/entra/groups":"/docs/business/administration/entra","administration/entra/users":"/docs/business/administration/entra","administration/entra/conflicts":"/docs/business/administration/entra","administration/entra/settings":"/docs/business/administration/entra","administration/configuration":"/docs/business/administration/configuration","administration/configuration/settings":"/docs/business/administration/configuration","administration/configuration/appsettings":"/docs/business/administration/configuration","administration/configuration/license":"/docs/business/administration/configuration/license","support/tickets":"/system/docs/user/support-dashboard","support/tickets/list":"/docs/business/platform/support/tickets","support/tickets/escalation":"/system/docs/user/support-escalation","support/my-tickets":"/docs/business/platform/support/tickets","support/my-tickets/list":"/docs/business/platform/support/tickets","support/my-tickets/create":"/docs/business/platform/support/tickets","support/admin/sla":"/system/docs/user/support-sla","support/admin/templates":"/system/docs/user/support-templates","myspace/profile":"/system/docs/user/modules","myspace/preferences":"/system/docs/user/modules","myspace/tenants":"/system/docs/user/modules","myspace/portal":"/system/docs/user/modules"},Rs={administration:"/docs/business/administration/users",support:"/system/docs/user/support-dashboard",myspace:"/system/docs/user/modules"};function Es(t){const s=t.split("/").filter(Boolean),a=s[0]==="t"&&s.length>=3?2:0,o=s.slice(a),c=o[0],i=o.slice(1);if(i.length>0)for(let d=i.length;d>0;d--){const u=`${c}/${i.slice(0,d).join("/")}`;if(Ts[u])return Ts[u]}return c&&Rs[c]?Rs[c]:"/system/docs/user"}function Jr({children:t}){const[s,r]=n.useState(!1),[a,o]=n.useState(uo),[c,i]=n.useState(null),d=w.useLocation(),u=n.useRef(d.pathname);n.useEffect(()=>{u.current!==d.pathname&&(u.current=d.pathname,r(!1))},[d.pathname]),n.useEffect(()=>{a>=20&&a<=60&&localStorage.setItem(Xr,String(a))},[a]);const m=n.useCallback(b=>{const h=b||Es(d.pathname);i(h),r(!0)},[d.pathname]),p=n.useCallback(()=>{r(!1)},[]),f=n.useCallback(()=>{if(s)r(!1);else{const b=Es(d.pathname);i(b),r(!0)}},[s,d.pathname]),g=n.useCallback(b=>{b>=20&&b<=60&&o(b)},[]);return e.jsx(Yr.Provider,{value:{isOpen:s,panelSize:a,docUrl:c,openDocPanel:m,closeDocPanel:p,toggleDocPanel:f,setPanelSize:g},children:t})}function Bt(){const t=n.useContext(Yr);if(t===void 0)throw new Error("useDocPanel must be used within a DocPanelProvider");return t}class mo{captureBrowserInfo(){const s=navigator.userAgent;return{browser:this.getBrowserName(s),browserVersion:this.getBrowserVersion(s),os:this.getOSName(s),osVersion:this.getOSVersion(s),language:navigator.language,screenResolution:`${window.screen.width}x${window.screen.height}`,deviceType:this.getDeviceType(s)}}getBrowserName(s){return s.includes("Firefox")?"Firefox":s.includes("Edg/")?"Microsoft Edge":s.includes("Chrome")&&!s.includes("Edg/")?"Google Chrome":s.includes("Safari")&&!s.includes("Chrome")?"Safari":s.includes("Opera")||s.includes("OPR/")?"Opera":s.includes("MSIE")||s.includes("Trident/")?"Internet Explorer":"Unknown Browser"}getBrowserVersion(s){let r=null;return s.includes("Firefox")?r=/Firefox\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Edg/")?r=/Edg\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Chrome")&&!s.includes("Edg/")?r=/Chrome\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Safari")&&!s.includes("Chrome")?r=/Version\/(\d+(?:\.\d+)*)/.exec(s):s.includes("OPR/")&&(r=/OPR\/(\d+(?:\.\d+)*)/.exec(s)),r?r[1]:"Unknown"}getOSName(s){return s.includes("Windows NT 10")?"Windows 10/11":s.includes("Windows NT 6.3")?"Windows 8.1":s.includes("Windows NT 6.2")?"Windows 8":s.includes("Windows NT 6.1")?"Windows 7":s.includes("Windows")?"Windows":s.includes("Mac OS X")?"macOS":s.includes("Linux")&&s.includes("Android")?"Android":s.includes("Linux")?"Linux":s.includes("iPhone")||s.includes("iPad")?"iOS":s.includes("CrOS")?"Chrome OS":"Unknown OS"}getWindowsVersion(s){return s==="10.0"?"10/11":s==="6.3"?"8.1":s==="6.2"?"8":s==="6.1"?"7":s}getOSVersion(s){if(s.includes("Windows NT")){const r=/Windows NT (\d+\.\d+)/.exec(s);if(r)return this.getWindowsVersion(r[1])}if(s.includes("Mac OS X")){const r=/Mac OS X (\d+[._]\d+(?:[._]\d+)?)/.exec(s);if(r)return r[1].replace(/_/g,".")}if(s.includes("Android")){const r=/Android (\d+(?:\.\d+)*)/.exec(s);if(r)return r[1]}if(s.includes("iPhone OS")||s.includes("iPad")){const r=/(?:iPhone|iPad|CPU) OS (\d+[._]\d+(?:[._]\d+)?)/.exec(s);if(r)return r[1].replace(/_/g,".")}return"Unknown"}getDeviceType(s){return/Tablet|iPad/i.test(s)?"Tablet":/Mobile|iPhone|Android.*Mobile/i.test(s)?"Mobile":"Desktop"}formatForDescription(s){return[`Browser: ${s.browser} ${s.browserVersion}`,`OS: ${s.os} ${s.osVersion}`,`Device: ${s.deviceType}`,`Screen: ${s.screenResolution}`,`Language: ${s.language}`].join(`
2
- `)}}const Qr=new mo;function po(){return{captureContext:n.useCallback(()=>{const s=Qr.captureBrowserInfo(),r=Te.getRecentErrors().slice(0,5);return{sourceUrl:window.location.href,browser:{name:s.browser,version:s.browserVersion,language:s.language},os:{name:s.os,version:s.osVersion},device:{type:s.deviceType,screenResolution:s.screenResolution},recentErrors:r.map(a=>({message:a.message,stack:a.stack,component:a.component,timestamp:a.timestamp.toISOString()}))}},[])}}function xo(){const[t,s]=n.useState(new Set),r=n.useCallback(i=>{s(d=>{const u=new Set(d);return u.has(i)?u.delete(i):u.add(i),u})},[]),a=n.useCallback(()=>{s(new Set)},[]),o=n.useCallback(i=>{s(new Set(i))},[]),c=n.useCallback(i=>t.has(i),[t]);return{collapsedApps:t,toggleApp:r,expandAll:a,collapseAll:o,isAppCollapsed:c}}const hs="/api/myspace/application-tracking",ho="00000000-0000-0000-0000-000000000000",Is=t=>!!t&&t!==ho,Zr=t=>{const s=/^\/t\/[^/]+(\/.*)$/.exec(t);return s?s[1]:t},go=t=>{const s=Zr(t);return s.startsWith("/administration/")||s.startsWith("/support/")||s.startsWith("/myspace/")},ea=(t,s)=>{if(!t||typeof t!="object"||!("status"in t))return!0;const r=t.status;return!s.includes(r??-1)},fo=async(t,s)=>{const r=new Date,a=Math.floor((r.getTime()-s.getTime())/1e3);try{await E.post(`${hs}/end`,{accessId:t,endedAt:r.toISOString(),durationSeconds:a})}catch(o){ea(o,[401,408])&&console.error("Failed to end page tracking:",o)}},bo=async t=>{const s=new Date;try{return(await E.post(`${hs}/start`,{route:t,accessedAt:s.toISOString()})).accessId}catch(r){return ea(r,[401])&&console.error("Failed to track page access:",r),null}},vo=(t,s)=>{const r=localStorage.getItem("token");if(!r)return;const a=new Date,o=Math.floor((a.getTime()-s.getTime())/1e3);fetch(`${hs}/end`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({accessId:t,endedAt:a.toISOString(),durationSeconds:o}),keepalive:!0}).catch(()=>{})};function ta(){const t=w.useLocation(),s=n.useRef(new Date),r=n.useRef(null),a=n.useRef(!1);n.useEffect(()=>a.current?void 0:((async()=>{const c=Zr(t.pathname);go(c)&&(a.current=!0,Is(r.current)&&await fo(r.current,s.current),s.current=new Date,r.current=await bo(c),a.current=!1)})(),()=>{Is(r.current)&&vo(r.current,s.current)}),[t.pathname])}function yo(t={}){const{canEditSystemRoles:s=!1}=t,{t:r,i18n:a}=ne.useTranslation("admin"),[o,c]=n.useState(!0),[i,d]=n.useState(null),[u,m]=n.useState(null),[p,f]=n.useState(!1),[g,b]=n.useState(!1),[h,y]=n.useState([]),[x,j]=n.useState([]),[v,S]=n.useState(new Map),[N,I]=n.useState({}),[P,k]=n.useState({}),[A,R]=n.useState({}),[$,q]=n.useState({selectedRoleIds:[],resourceSearch:"",applicationFilter:"all",moduleFilter:"all",categoryFilter:"all"}),C=n.useRef(null),D=n.useRef(new Map),Y=n.useCallback((U,W,ee)=>{const te=U.has(ee),se=W.get(ee);if(!se)return{isDirect:te,isInherited:!1};const me=se.path.toLowerCase();let ie,ve,be=1/0;for(const Me of Array.from(U)){const Le=W.get(Me);if(!Le||Me===ee)continue;const ze=Le.path.toLowerCase();if((Le.isWildcard||ze.endsWith(".*"))&&kt(ze,me)){const We=ze.split(".").length;We<be&&(be=We,ie=Le.path,ve=Le.id)}}return{isDirect:te,isInherited:ie!==void 0,inheritedFromPath:ie,inheritedFromId:ve}},[]),T=n.useCallback((U,W)=>{const ee={};return Object.entries(U).forEach(([te,se])=>{const me=new Map;W.forEach((ie,ve)=>{const be=Y(se,W,ve);me.set(ve,be)}),ee[te]=me}),ee},[Y]),z=(U,W,ee,te)=>{const se=[],me=[];return U.resources.forEach(ie=>{const ve=ie.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),be=te.get(ve)||[],Ie={id:ie.id,path:ie.permissionPath,label:ie.label,applicationLabel:ee.label,moduleLabel:ie.label,parentModuleLabel:W.label,parentModuleId:W.id,parentSectionLabel:U.label,parentSectionId:U.id,level:"resource",permissions:be,totalPermissions:be.length};se.push(Ie),me.push(Ie)}),{childResources:se,nodes:me}},Z=(U,W,ee)=>{const te=[],se=[];return U.sections.forEach(me=>{const ie=me.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),ve=ee.get(ie)||[],{childResources:be,nodes:Ie}=z(me,U,W,ee),Me=be.reduce((et,We)=>et+We.totalPermissions,0),Le=ve.length+Me,ze={id:me.id,path:me.permissionPath,label:me.label,applicationLabel:W.label,moduleLabel:me.label,parentModuleLabel:U.label,parentModuleId:U.id,level:"section",permissions:ve,totalPermissions:Le,childResources:be.length>0?be:void 0};te.push(ze),se.push(ze),se.push(...Ie)}),{childSections:te,nodes:se}},H=(U,W,ee,te)=>{const se=U.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),me=ee.get(se)||[],{childSections:ie,nodes:ve}=Z(U,W,ee),be=ie.reduce((Me,Le)=>Me+Le.totalPermissions,0),Ie=me.length+be;te.push({id:U.id,path:U.permissionPath,label:U.label,applicationLabel:W.label,moduleLabel:U.label,level:"module",permissions:me,totalPermissions:Ie,childSections:ie.length>0?ie:void 0}),te.push(...ve)},J=(U,W,ee)=>{U.modules.forEach(te=>{H(te,U,W,ee)})},fe=n.useCallback((U,W)=>{const ee=[];if(!U||!U.applications||!W||!Array.isArray(W))return ee;const te=new Map;return W.forEach(se=>{const ie=se.path.toLowerCase().split(".");if(ie.length>=2){const ve=ie.slice(0,-1).join("."),be=te.get(ve)||[];be.push({id:se.id,action:ie.at(-1),path:se.path}),te.set(ve,be)}}),U.applications.forEach(se=>{J(se,te,ee)}),ee.sort((se,me)=>{const ie=se.applicationLabel.localeCompare(me.applicationLabel);return ie!==0?ie:se.moduleLabel.localeCompare(me.moduleLabel)})},[]),B=n.useCallback(async()=>{try{c(!0),d(null);const U=await Ne.permissions.getMatrix(),W={};U.roles.forEach(ie=>{W[ie.id]=new Set(ie.permissionIds)});const ee=new Map(U.permissions.map(ie=>[ie.id,ie])),te=fe(U.tree,U.permissions),se=T(W,ee);y(U.roles),j(te),S(ee),I(W),R(se);const me=Object.entries(W).reduce((ie,[ve,be])=>(ie[ve]=new Set(Array.from(be)),ie),{});k(me),D.current.clear()}catch(U){d(U instanceof Error?U.message:"Failed to load permission matrix data")}finally{c(!1)}},[fe,T]);n.useEffect(()=>{B()},[B,a.language]),n.useEffect(()=>{if(v.size>0){const U=T(N,v);R(U)}},[N,v,T]);const Q=n.useCallback(async()=>{if(D.current.size===0)return;const U=new Map(D.current);D.current.clear(),f(!0),m(null);try{const W=Array.from(U.entries()).map(async([se,me])=>{const ie=h.find(ve=>ve.id===se);ie&&await Ne.roles.update(se,{name:ie.name,shortName:ie.shortName,category:ie.category,description:ie.description||void 0,permissionIds:Array.from(me)})});await Promise.all(W);const ee=JSON.parse(JSON.stringify(Object.fromEntries(Object.entries(N).map(([se,me])=>[se,Array.from(me)])))),te=Object.entries(ee).reduce((se,[me,ie])=>(se[me]=new Set(ie),se),{});k(te),b(!0),setTimeout(()=>{b(!1)},3e3)}catch(W){console.error("Failed to save permission changes:",W);let ee="Failed to save changes";if(W&&typeof W=="object"&&"response"in W){const te=W.response;te?.status===403?ee=r("assignments.noPermissionToEditRole"):te?.data?.message&&(ee=te.data.message)}else W instanceof Error&&(ee=W.message);m(ee),await B()}finally{f(!1)}},[h,N,B]),M=n.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{Q()},500)},[Q]),re=n.useCallback((U,W)=>{h.find(te=>te.id===U)?.isSystem&&!s||I(te=>{const se=new Set(te[U]||[]);return se.has(W)?se.delete(W):se.add(W),D.current.set(U,se),M(),{...te,[U]:se}})},[h,s,M]),F=U=>{x.forEach(W=>{W.permissions.forEach(ee=>{U.add(ee.id)})})},K=n.useCallback((U,W)=>{h.find(te=>te.id===U)?.isSystem&&!s||I(te=>{const se=new Set;return W&&F(se),D.current.set(U,se),M(),{...te,[U]:se}})},[h,s,x,M]),V=(U,W,ee)=>{W.permissions.forEach(te=>{ee?U.add(te.id):U.delete(te.id)})},ae=n.useCallback((U,W)=>{I(ee=>{const te={...ee};return h.forEach(se=>{if(se.isSystem&&!s)return;const me=new Set(te[se.id]||[]);V(me,U,W),te[se.id]=me,D.current.set(se.id,me)}),M(),te})},[h,s,M]),ue=n.useCallback(U=>{q(W=>({...W,...U}))},[]),G=n.useCallback(()=>{const U=Object.entries(P).reduce((W,[ee,te])=>(W[ee]=new Set(Array.from(te)),W),{});I(U),D.current.clear(),C.current&&clearTimeout(C.current)},[P]),ce=n.useMemo(()=>h.filter(U=>$.selectedRoleIds.length===0?!0:$.selectedRoleIds.includes(U.id)),[h,$.selectedRoleIds]),de=n.useMemo(()=>x.filter(U=>!($.resourceSearch&&!U.moduleLabel.toLowerCase().includes($.resourceSearch.toLowerCase())||$.applicationFilter!=="all"&&U.applicationLabel!==$.applicationFilter||$.moduleFilter!=="all"&&U.moduleLabel!==$.moduleFilter)),[x,$]),he=n.useMemo(()=>Array.from(Object.entries(N)).some(([U,W])=>{const ee=P[U];return ee?W.size!==ee.size?!0:Array.from(W).some(te=>!ee.has(te)):W.size>0}),[N,P]),pe=n.useMemo(()=>{const U=new Map;return x.forEach(W=>{U.has(W.applicationLabel)||U.set(W.applicationLabel,{app:W.applicationLabel,label:W.applicationLabel})}),Array.from(U.values()).sort((W,ee)=>W.label.localeCompare(ee.label))},[x]),ye=n.useMemo(()=>x.filter(U=>U.level==="module").map(U=>({app:U.applicationLabel,module:U.label,label:U.label})).sort((U,W)=>U.label.localeCompare(W.label)),[x]),qe=n.useMemo(()=>{const U=new Set(h.map(ee=>ee.category));return["Global","Admin","Manager","Contributor","Viewer","Custom"].filter(ee=>U.has(ee))},[h]),Ue=n.useCallback((U,W)=>{const ee=A[U];return ee?ee.get(W)||{isDirect:!1,isInherited:!1}:{isDirect:!1,isInherited:!1}},[A]),Ve=n.useCallback(()=>{m(null)},[]);return{loading:o,error:i,saveError:u,saving:p,saveSuccess:g,roles:h,resources:x,permissions:v,assignments:N,inheritanceMap:A,filters:$,filteredRoles:ce,filteredResources:de,hasChanges:he,canEditSystemRoles:s,applications:pe,modules:ye,categories:qe,togglePermission:re,toggleAllForRole:K,toggleAllForResource:ae,updateFilters:ue,reloadData:B,resetChanges:G,saveChanges:Q,clearSaveError:Ve,getPermissionInheritance:Ue}}function sa(t={}){const s=n.useRef(null),[r,a]=n.useState(oe.HubConnectionState.Disconnected),o=n.useRef(t);o.current=t;const c=n.useCallback(()=>localStorage.getItem("token"),[]),i=n.useCallback(async()=>{const u=c();if(u&&s.current?.state!==oe.HubConnectionState.Connected)try{const m=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>u}).withAutomaticReconnect({nextRetryDelayInMilliseconds:p=>p.previousRetryCount===0?0:p.previousRetryCount===1?2e3:p.previousRetryCount===2?1e4:p.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();m.on("ReceiveNotification",p=>{o.current.onNotification?.(p)}),m.on("UnreadCountUpdate",p=>{o.current.onUnreadCountUpdate?.(p)}),m.on("PermissionsChanged",()=>{o.current.onPermissionsChanged?.()}),m.onreconnecting(()=>{a(oe.HubConnectionState.Reconnecting),o.current.onConnectionStateChange?.(oe.HubConnectionState.Reconnecting)}),m.onreconnected(()=>{a(oe.HubConnectionState.Connected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Connected)}),m.onclose(()=>{a(oe.HubConnectionState.Disconnected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Disconnected)}),await m.start(),s.current=m,a(oe.HubConnectionState.Connected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Connected)}catch(m){console.error("SignalR: Failed to connect",m),a(oe.HubConnectionState.Disconnected)}},[c]),d=n.useCallback(async()=>{if(s.current)try{await s.current.stop(),s.current=null,a(oe.HubConnectionState.Disconnected)}catch(u){console.error("SignalR: Failed to disconnect",u)}},[]);return n.useEffect(()=>(i(),()=>{d()}),[i,d]),n.useEffect(()=>{const u=m=>{m.key==="token"&&(m.newValue?i():d())};return window.addEventListener("storage",u),()=>window.removeEventListener("storage",u)},[i,d]),{connectionState:r,isConnected:r===oe.HubConnectionState.Connected,connect:i,disconnect:d}}function jo(){const{refreshPermissions:t,user:s}=Pe(),{refreshMenu:r}=Ce(),a=n.useRef(!1),o=n.useCallback(async()=>{if(!a.current){a.current=!0;try{await Promise.all([t(),r()])}catch(d){console.error("[PermissionSync] Failed to refresh permissions:",d)}finally{a.current=!1}}},[t,r]),{isConnected:c,connectionState:i}=sa({onPermissionsChanged:o});return{isConnected:c,connectionState:i,isAuthenticated:!!s}}function ra(t){const{ticketId:s,onCommentAdded:r,onTicketUpdated:a,onConnectionStateChange:o}=t,c=n.useRef(null),i=n.useRef(null),[d,u]=n.useState(oe.HubConnectionState.Disconnected),m=n.useCallback(()=>localStorage.getItem("token"),[]),p=n.useCallback(async h=>{if(c.current?.state===oe.HubConnectionState.Connected)try{await c.current.invoke("JoinTicket",h),i.current=h}catch(y){console.error("SignalR: Failed to join ticket group",y)}},[]),f=n.useCallback(async h=>{if(c.current?.state===oe.HubConnectionState.Connected)try{await c.current.invoke("LeaveTicket",h)}catch(y){console.error("SignalR: Failed to leave ticket group",y)}i.current=null},[]),g=n.useCallback(async()=>{const h=m();if(h){if(c.current?.state===oe.HubConnectionState.Connected)return c.current;try{const y=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>h}).withAutomaticReconnect({nextRetryDelayInMilliseconds:x=>x.previousRetryCount===0?0:x.previousRetryCount===1?2e3:x.previousRetryCount===2?1e4:x.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();return y.on("TicketCommentAdded",x=>{r?.(x)}),y.on("TicketUpdated",x=>{a?.(x)}),y.onreconnecting(()=>{u(oe.HubConnectionState.Reconnecting),o?.(oe.HubConnectionState.Reconnecting)}),y.onreconnected(async()=>{u(oe.HubConnectionState.Connected),o?.(oe.HubConnectionState.Connected),i.current&&await p(i.current)}),y.onclose(()=>{u(oe.HubConnectionState.Disconnected),o?.(oe.HubConnectionState.Disconnected)}),await y.start(),c.current=y,u(oe.HubConnectionState.Connected),o?.(oe.HubConnectionState.Connected),y}catch(y){return console.error("SignalR: Failed to connect",y),u(oe.HubConnectionState.Disconnected),null}}},[m,p,r,a,o]),b=n.useCallback(async()=>{if(i.current&&await f(i.current),c.current)try{await c.current.stop(),c.current=null,u(oe.HubConnectionState.Disconnected)}catch(h){console.error("SignalR: Failed to disconnect",h)}},[f]);return n.useEffect(()=>{let h=!0;return(async()=>(await g(),h&&s&&await p(s)))(),()=>{h=!1,b()}},[g,b,s,p]),n.useEffect(()=>{const h=async()=>{i.current&&i.current!==s&&await f(i.current),s&&s!==i.current&&await p(s)};c.current?.state===oe.HubConnectionState.Connected&&h()},[s,p,f]),{connectionState:d,isConnected:d===oe.HubConnectionState.Connected,joinTicket:p,leaveTicket:f}}function No(t,s,r,a){const o=[];for(const c of a.resources)c.route&&o.push({componentKey:c.componentKey,permissionPath:c.permissionPath,route:c.route,hasComponent:O.has(c.componentKey),requiredFeature:r,isOpen:s,level:"resource",applicationCode:t});return o}function wo(t,s,r,a){const o=[];for(const c of a.sections)c.route&&o.push({componentKey:c.componentKey,permissionPath:c.permissionPath,route:c.route,hasComponent:O.has(c.componentKey),requiredFeature:r,isOpen:s,level:"section",applicationCode:t}),o.push(...No(t,s,r,c));return o}function So(t,s,r){const a=[];for(const o of r.modules)o.route&&a.push({componentKey:o.componentKey,permissionPath:o.permissionPath,route:o.route,hasComponent:O.has(o.componentKey),requiredFeature:o.requiredFeature,isOpen:s,level:"module",applicationCode:t}),a.push(...wo(t,s,o.requiredFeature,o));return a}function Co(t){const s=[];for(const r of t)r.route&&s.push({componentKey:r.componentKey,permissionPath:r.permissionPath,route:r.route,hasComponent:O.has(r.componentKey),requiredFeature:r.requiredFeature,isOpen:r.isOpen,level:"application",applicationCode:r.code}),s.push(...So(r.code,r.isOpen,r));return s}function ko(){const{menu:t,isLoading:s}=Ce();return n.useMemo(()=>{if(!t||s)return{entries:[],byKey:new Map,isLoading:!0,byApplication:new Map};const r=Co(t.applications),a=new Map(r.map(c=>[c.componentKey,c])),o=new Map;for(const c of r){const i=o.get(c.applicationCode)||[];i.push(c),o.set(c.applicationCode,i)}return{entries:r,byKey:a,isLoading:!1,byApplication:o}},[t,s])}const Ao=(t,s,r)=>{const a=t.has(r),o=s.get(r);if(!o)return{isDirect:a,isInherited:!1};const c=o.path;let i,d,u=1/0;for(const p of Array.from(t)){const f=s.get(p);if(!(!f||!f.isWildcard||p===r)&&kt(f.path,c)){const g=f.path.split(".").length;g<u&&(u=g,i=f.path,d=f.id)}}return{isDirect:a,isInherited:i!==void 0,inheritedFromPath:i,inheritedFromId:d}},Ls=(t,s)=>{const r={};return Object.entries(t).forEach(([a,o])=>{const c=new Map;s.forEach((i,d)=>{const u=Ao(o,s,d);c.set(d,u)}),r[a]=c}),r},Po=t=>{const s=new Map;return t.forEach(r=>{const o=r.path.toLowerCase().split(".");if(o.length>=2){const c=o.slice(0,-1).join("."),i=s.get(c)||[];i.push({id:r.id,action:o.at(-1),path:r.path}),s.set(c,i)}}),s},Kt=(t,s)=>{const r=s.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,"");return t.get(r)||[]};function aa(t){const{entityId:s,tenantId:r,loadEntity:a,loadRoles:o}=t,{i18n:c}=ne.useTranslation(),[i,d]=n.useState(!0),[u,m]=n.useState(null),[p,f]=n.useState(null),[g,b]=n.useState([]),[h,y]=n.useState([]),[x,j]=n.useState(new Map),[v,S]=n.useState({}),[N,I]=n.useState({}),[P,k]=n.useState({selectedRoleIds:[],resourceSearch:"",applicationFilter:"all",moduleFilter:"all"}),A=!!r,R=n.useCallback((F,K,V,ae)=>{const ue=Kt(ae,K.permissionPath);F.push({id:K.id,path:K.permissionPath,label:K.label,applicationLabel:V.label,moduleLabel:K.label,level:"module",permissions:ue,totalPermissions:ue.length})},[]),$=n.useCallback((F,K,V,ae,ue)=>{const G=Kt(ue,K.permissionPath);K.resources.forEach(ce=>{const de=Kt(ue,ce.permissionPath);F.push({id:ce.id,path:ce.permissionPath,label:ce.label,applicationLabel:ae.label,moduleLabel:V.label,parentModuleLabel:V.label,parentModuleId:V.id,parentSectionLabel:K.label,parentSectionId:K.id,level:"resource",permissions:de,totalPermissions:de.length})}),F.push({id:K.id,path:K.permissionPath,label:K.label,applicationLabel:ae.label,moduleLabel:V.label,parentModuleLabel:V.label,parentModuleId:V.id,level:"section",permissions:G,totalPermissions:G.length})},[]),q=n.useCallback((F,K,V,ae)=>{R(ae,F,K,V),F.sections.forEach(ue=>{$(ae,ue,F,K,V)})},[R,$]),C=n.useCallback((F,K,V)=>{F.modules.forEach(ae=>{q(ae,F,K,V)})},[q]),D=n.useCallback((F,K)=>{if(!F?.applications||!Array.isArray(K))return[];const V=Po(K),ae=[];return F.applications.forEach(ue=>{C(ue,V,ae)}),ae.sort((ue,G)=>{const ce=ue.applicationLabel.localeCompare(G.applicationLabel);return ce!==0?ce:ue.moduleLabel.localeCompare(G.moduleLabel)})},[C]),Y=n.useCallback(async()=>{try{d(!0),m(null);const[F,K,V]=await Promise.all([a(s),o(s,r),Ne.permissions.getMatrix()]);f(F),b(K);const ae=new Set(K.map(pe=>pe.id)),ue=V.roles.filter(pe=>ae.has(pe.id)),G={};ue.forEach(pe=>{G[pe.id]=new Set(pe.permissionIds)});const ce=new Map(V.permissions.map(pe=>[pe.id,pe])),de=D(V.tree,V.permissions),he=Ls(G,ce);y(de),j(ce),S(G),I(he)}catch(F){m(F instanceof Error?F.message:"Failed to load permissions data")}finally{d(!1)}},[s,r,a,o,D]);n.useEffect(()=>{Y()},[Y,c.language]),n.useEffect(()=>{if(x.size>0){const F=Ls(v,x);I(F)}},[v,x]);const T=n.useMemo(()=>{const F=new Set;return Object.entries(N).forEach(([K,V])=>{V.forEach((ae,ue)=>{(ae.isDirect||ae.isInherited)&&F.add(ue)})}),F},[N]),z=F=>P.resourceSearch?F.label.toLowerCase().includes(P.resourceSearch.toLowerCase()):!0,Z=F=>P.applicationFilter==="all"?!0:F.applicationLabel===P.applicationFilter,H=F=>P.moduleFilter==="all"?!0:F.level==="module"?F.label===P.moduleFilter:F.parentModuleLabel===P.moduleFilter,J=n.useMemo(()=>h.filter(F=>z(F)&&Z(F)&&H(F)),[h,P]),fe=n.useMemo(()=>{const F=new Map;return h.forEach(K=>{F.has(K.applicationLabel)||F.set(K.applicationLabel,{app:K.applicationLabel,label:K.applicationLabel})}),Array.from(F.values()).sort((K,V)=>K.label.localeCompare(V.label))},[h]),B=n.useMemo(()=>h.filter(F=>F.level==="module").map(F=>({app:F.applicationLabel,module:F.label,label:F.label})).sort((F,K)=>F.label.localeCompare(K.label)),[h]),Q=n.useCallback(F=>{k(K=>({...K,...F}))},[]),M=n.useCallback((F,K)=>{const V=N[F];return V?V.get(K)||{isDirect:!1,isInherited:!1}:{isDirect:!1,isInherited:!1}},[N]),re=n.useCallback(F=>{const K=[];return g.forEach(V=>{const ae=N[V.id];if(ae){const ue=ae.get(F);ue&&(ue.isDirect||ue.isInherited)&&K.push(V)}}),K},[g,N]);return{loading:i,error:u,entity:p,roles:g,resources:h,assignments:v,inheritanceMap:N,effectivePermissions:T,filters:P,filteredResources:J,applications:fe,modules:B,updateFilters:Q,getPermissionInheritance:M,getPermissionSources:re,reloadData:Y,isTenantMode:A}}function To(t){const{userId:s,tenantId:r}=t,[a,o]=n.useState(null),[c,i]=n.useState([]),d=!!r,u=n.useCallback(async y=>Ne.users.getById(y),[]),m=n.useCallback(async(y,x)=>{const j=await Ne.users.getById(y);let v=[];try{const N=await Ne.users.getConsolidatedRoles(y,x);if(i(N),v=N.map(I=>({id:I.roleId,name:I.roleName,shortName:I.roleShortName||I.roleName,category:"Custom",description:null})),x)try{const P=(await Ne.tenants.getMembers(x)).find(k=>k.userId===y);o(P||null)}catch{o(null)}else o(null)}catch{i([]),o(null),v=j.roles}return Array.from(new Map(v.map(N=>[N.id,N])).values())},[]),p=aa({entityId:s,tenantId:r,loadEntity:u,loadRoles:m}),f=p.entity,g=p.roles,b=n.useCallback(y=>{const x=[];return g.forEach(j=>{const v=p.inheritanceMap[j.id];if(v){const S=v.get(y);S&&(S.isDirect||S.isInherited)&&x.push(j)}}),x},[g,p.inheritanceMap]),h=n.useCallback(async y=>{if(!d||!r||!a)throw new Error("Cannot assign tenant roles: not in tenant mode or no tenant member found");await Ne.tenants.assignMemberRoles(r,a.userId,y),await p.reloadData()},[d,r,a,p]);return{loading:p.loading,error:p.error,user:f,userRoles:g,resources:p.resources,assignments:p.assignments,inheritanceMap:p.inheritanceMap,effectivePermissions:p.effectivePermissions,filters:p.filters,filteredResources:p.filteredResources,applications:p.applications,modules:p.modules,updateFilters:p.updateFilters,getPermissionInheritance:p.getPermissionInheritance,getPermissionSources:b,reloadData:p.reloadData,isTenantMode:d,tenantMember:a,assignTenantRoles:h,consolidatedRoles:c}}function Gt(){const{mode:t,toggleMode:s}=Ct(),a=(t==="dark"?"dark":"light")==="light";return e.jsx("button",{onClick:s,className:"relative p-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-300 group",style:{borderRadius:"var(--radius-button)"},"aria-label":`Basculer vers le mode ${a?"sombre":"clair"}`,children:e.jsxs("div",{className:"relative w-6 h-6",children:[e.jsx(l.Sun,{className:`absolute inset-0 w-6 h-6 text-amber-500 transition-all duration-300 ${a?"opacity-100 rotate-0 scale-100":"opacity-0 rotate-90 scale-0"}`}),e.jsx(l.Moon,{className:`absolute inset-0 w-6 h-6 text-[var(--color-accent-400)] transition-all duration-300 ${a?"opacity-0 -rotate-90 scale-0":"opacity-100 rotate-0 scale-100"}`})]})})}const Ht=[{code:"en",label:"English",short:"EN"},{code:"fr",label:"Français",short:"FR"},{code:"de",label:"Deutsch",short:"DE"},{code:"it",label:"Italiano",short:"IT"}];function gs(){const{i18n:t}=ne.useTranslation(),{isAuthenticated:s}=Pe(),[r,a]=n.useState(!1),o=n.useRef(null),c=t.language?.split("-")[0]||"en",i=Ht.find(u=>u.code===c)||Ht[0],d=async u=>{if(await ms(u),document.documentElement.lang=u,a(!1),s)try{await Ft.preferences.updateLanguage({language:u})}catch{}};return n.useEffect(()=>{const u=m=>{o.current&&!o.current.contains(m.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]),e.jsxs("div",{ref:o,className:"relative",children:[e.jsx("button",{onClick:()=>a(!r),className:"relative p-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-300",style:{borderRadius:"var(--radius-button)"},"aria-label":"Change language",children:e.jsx("span",{className:"flex items-center justify-center w-6 h-6 text-xs font-bold text-[var(--text-secondary)]",children:i.short})}),r&&e.jsx("div",{className:"absolute right-0 mt-2 py-1 bg-[var(--bg-tertiary)] border border-[var(--border-color)] shadow-lg shadow-[var(--shadow-color)] z-50 overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:Ht.map(u=>{const m=u.code===c;return e.jsxs("button",{onClick:()=>d(u.code),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors whitespace-nowrap ${m?"bg-primary-600/10 text-primary-500":"text-[var(--text-secondary)] hover:bg-[var(--bg-secondary)] hover:text-[var(--text-primary)]"}`,children:[e.jsx("span",{className:"text-xs font-bold w-6",children:u.short}),e.jsx("span",{className:"text-sm font-medium",children:u.label}),m&&e.jsx(l.Check,{className:"w-4 h-4 ml-auto text-primary-500"})]},u.code)})})]})}function Ro(t,s){if(!s.useUrlRouting||!s.slug)return dt(t);if(t.startsWith(`/t/${s.slug}`))return t;const r=dt(t);return`/t/${s.slug}${r}`}function $s(t){const s=/^\/t\/([^/]+)/.exec(t);return s?s[1]:null}function dt(t){return t.replace(/^\/t\/[^/]+/,"")||"/"}function Ze(){const{currentTenant:t}=Ee(),{useUrlRouting:s}=_t();return n.useCallback(r=>Ro(r,{slug:t?.slug,useUrlRouting:s}),[t?.slug,s])}const Ds={background:"linear-gradient(to bottom right, var(--color-accent-500), var(--color-accent-600))"};function na(){const{t}=ne.useTranslation("navigation"),{user:s,logout:r}=Pe(),{refreshMenu:a}=Ce(),{refreshTenants:o}=Ee(),c=w.useLocation(),i=w.useNavigate(),d=Ze(),[u,m]=n.useState(!1),[p,f]=n.useState(!1),g=n.useRef(null),b=async()=>{f(!0);try{await E.post("/api/navigation/invalidate-cache").catch(()=>{}),await Promise.all([a(),o()])}catch(j){console.error("Failed to refresh cache:",j)}finally{f(!1),m(!1)}},h=j=>{const v=d(j);c.pathname!==v&&i(v),m(!1)};n.useEffect(()=>{function j(v){g.current&&!g.current.contains(v.target)&&m(!1)}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]),n.useEffect(()=>{function j(v){v.key==="Escape"&&m(!1)}return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[]);const y=()=>{if(!s)return"?";const j=s.firstName?.[0]||"",v=s.lastName?.[0]||"";return(j+v).toUpperCase()||s.email.at(0)?.toUpperCase()||"?"},x=()=>s?s.firstName||s.lastName?`${s.firstName||""} ${s.lastName||""}`.trim():s.email.split("@")[0]:"";return e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("button",{onClick:()=>m(!u),className:"flex items-center gap-2 p-1.5 pr-3 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-200 group",style:{borderRadius:"var(--radius-button)"},"aria-expanded":u,"aria-haspopup":"true",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm font-medium shadow-sm",style:Ds,children:y()}),e.jsx(l.ChevronDown,{className:`w-4 h-4 text-[var(--text-tertiary)] transition-transform duration-200 ${u?"rotate-180":""}`})]}),e.jsx("div",{className:`absolute right-0 mt-2 w-72 origin-top-right transition-all duration-200 ease-out ${u?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"p-4 bg-gradient-to-br from-[var(--bg-secondary)] to-[var(--bg-tertiary)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center text-white text-lg font-semibold shadow-lg",style:Ds,children:y()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-[var(--text-primary)] truncate",children:x()}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] truncate",children:s?.email})]})]})}),e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("button",{onClick:()=>h("/applications"),className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.LayoutGrid,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.applications")})]}),e.jsxs("button",{onClick:()=>h("/myspace"),className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.User,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.mySpace")})]})]})}),e.jsx("div",{className:"p-2",children:e.jsxs("button",{onClick:b,disabled:p,className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors disabled:opacity-50",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.RefreshCw,{className:`w-4 h-4 ${p?"animate-spin":""}`})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.refreshCache")})]})}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs("button",{onClick:()=>{m(!1),r()},className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-red-500/10 transition-colors group",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] group-hover:bg-red-500/20 flex items-center justify-center text-[var(--text-secondary)] group-hover:text-red-500 transition-colors",children:e.jsx(l.LogOut,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)] group-hover:text-red-500 transition-colors",children:t("avatarMenu.logout")})]})})]})})]})}const Eo={settings:l.Settings,users:l.Users,key:l.Key,briefcase:l.Briefcase,folder:l.FolderOpen,file:l.FileText,box:l.Box};function Io(t){return t&&Eo[t.toLowerCase()]||l.Box}function Ms({app:t,isFavorite:s,showFavorite:r,onToggleFavorite:a,onSelect:o}){const c=Io(t.icon);return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{onClick:o,className:"w-full flex flex-col items-center gap-2 p-3 hover:bg-[var(--bg-tertiary)] transition-all duration-200",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-[var(--color-accent-500)]/20 to-[var(--color-accent-600)]/20 flex items-center justify-center group-hover:from-[var(--color-accent-500)]/30 group-hover:to-[var(--color-accent-600)]/30 transition-all",style:{borderRadius:"var(--radius-card)"},children:e.jsx(c,{className:"w-6 h-6 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-xs font-medium text-[var(--text-primary)] text-center line-clamp-2",children:t.label})]}),r&&e.jsx("button",{onClick:i=>{i.stopPropagation(),a()},className:`absolute top-1 right-1 p-1.5 transition-all duration-200 ${s?"text-amber-500 bg-amber-500/10":"text-[var(--text-tertiary)] opacity-0 group-hover:opacity-100 hover:bg-[var(--bg-secondary)]"}`,style:{borderRadius:"var(--radius-button)"},title:s?"Retirer des favoris":"Ajouter aux favoris",children:e.jsx(l.Star,{className:`w-4 h-4 ${s?"fill-current":""}`})})]})}function oa(){const{t}=ne.useTranslation("navigation"),{favorites:s,menu:r,toggleFavorite:a,isFavorite:o}=Ce(),{currentTenant:c}=Ee(),[i,d]=n.useState(!1),u=n.useRef(null),m=w.useNavigate(),p=Ze(),f=!!c,g=r?.applications||[];n.useEffect(()=>{function h(y){u.current&&!u.current.contains(y.target)&&d(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]),n.useEffect(()=>{function h(y){y.key==="Escape"&&d(!1)}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]);const b=h=>{d(!1),h.route&&m(p(h.route))};return e.jsxs("div",{ref:u,className:"relative",children:[e.jsx("button",{onClick:()=>d(!i),className:"p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},"aria-expanded":i,"aria-haspopup":"true",title:t("appSwitcher.title","Applications"),children:e.jsx(l.LayoutGrid,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx("div",{className:`absolute right-0 mt-2 w-80 origin-top-right transition-all duration-200 ease-out ${i?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[s.length>0&&e.jsxs("div",{className:"p-3 border-b border-[var(--border-color)]",children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-3 h-3 text-amber-500 fill-amber-500"}),t("appSwitcher.favorites","Favoris")]}),e.jsx("div",{className:"grid grid-cols-3 gap-1 mt-2",children:s.slice(0,6).map(h=>e.jsx(Ms,{app:h,isFavorite:!0,showFavorite:f,onToggleFavorite:()=>a(h.id),onSelect:()=>{d(!1),h.route&&m(p(h.route))}},h.id))})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider",children:t("appSwitcher.allApps","Toutes les applications")}),g.length>0?e.jsx("div",{className:"grid grid-cols-3 gap-1 mt-2 max-h-64 overflow-y-auto",children:g.map(h=>e.jsx(Ms,{app:h,isFavorite:o(h.id),showFavorite:f,onToggleFavorite:()=>a(h.id),onSelect:()=>b(h)},h.id))}):e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-6",children:t("appSwitcher.noApps","Aucune application disponible")})]})]})})]})}function Lo(){const[t,s]=n.useState([]),r=n.useCallback(async()=>{try{const c=await Ne.myTenants.getFavorites();s(c)}catch{}},[]),a=n.useCallback(async c=>{const i=t.includes(c);try{if(i){const d=await Ne.myTenants.removeFavorite(c);s(d)}else{const d=await Ne.myTenants.addFavorite(c);s(d)}}catch(d){console.error("Failed to toggle favorite:",d)}},[t]),o=n.useCallback(c=>{Ne.myTenants.recordRecent(c).catch(console.error)},[]);return{favorites:t,loadFavorites:r,toggleFavorite:a,recordRecent:o}}const $o={Pending:"bg-blue-500",Active:"bg-emerald-500",Suspended:"bg-amber-500",Archived:"bg-gray-400"},Do={Pending:"En attente",Active:"Actif",Suspended:"Suspendu",Archived:"Archivé"};function Vt({tenant:t,isSelected:s,isFavorite:r,hasThemeOverride:a,onSelect:o,onToggleFavorite:c,showStatus:i=!0}){const d=t.type==="Business",u=t.status==="Active",m=(p,f)=>p?"bg-[var(--color-accent-500)]/10 text-[var(--color-accent-600)]":f?"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]":"opacity-50 cursor-not-allowed text-[var(--text-tertiary)]";return e.jsxs("div",{className:"flex items-center group",children:[e.jsxs("button",{onClick:o,disabled:!u,className:`flex-1 flex items-center gap-3 px-3 py-2.5 text-left transition-all duration-150 ${m(s,u)}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:`flex-shrink-0 w-8 h-8 flex items-center justify-center ${d?"bg-blue-500/10":"bg-violet-500/10"}`,style:{borderRadius:"var(--radius-card)"},children:d?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:t.name}),a&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--color-accent-500)]",title:"Thème personnalisé"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)] truncate",children:t.organisationName||t.slug}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${$o[t.status]}`}),t.status!=="Active"&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:Do[t.status]})]})]})]}),s&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] flex-shrink-0"})]}),c&&u&&e.jsx("button",{onClick:p=>{p.stopPropagation(),c()},className:`p-2 transition-colors ${r?"text-amber-500":"text-[var(--text-tertiary)] opacity-0 group-hover:opacity-100 hover:text-amber-500"}`,title:r?"Retirer des favoris":"Ajouter aux favoris",children:e.jsx(l.Star,{className:`w-4 h-4 ${r?"fill-amber-500":""}`})})]})}const ia="tenant_recents",ss=5;function la(){try{return JSON.parse(localStorage.getItem(ia)||"[]")}catch{return[]}}function Mo(t){const s=la().filter(r=>r!==t);s.unshift(t),localStorage.setItem(ia,JSON.stringify(s.slice(0,ss)))}const Oo=(t,s,r)=>{const a=o=>{t.current&&!t.current.contains(o.target)&&(s(!1),r(""))};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},Fo=(t,s)=>{const r=a=>{a.key==="Escape"&&(t(!1),s(""))};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},_o=(t,s,r,a,o)=>{const c=n.useMemo(()=>t.filter(u=>s.includes(u.id)&&u.status==="Active"),[t,s]),i=n.useMemo(()=>{if(o.trim())return[];const u=new Set(s);return r.map(m=>a.find(p=>p.id===m)).filter(m=>!!m&&m.status==="Active"&&!u.has(m.id)).slice(0,ss)},[r,a,s,o]),d=n.useMemo(()=>{const u=new Set([...s,...r.slice(0,ss)]);return t.filter(m=>!u.has(m.id))},[t,s,r]);return{favoriteTenants:c,recentTenants:i,otherTenants:d}};function qo(){const{t}=ne.useTranslation("navigation"),{refreshMenu:s}=Ce(),{currentTenant:r,userTenants:a,switchTenant:o,isLoading:c,hasMultipleTenants:i,hasGlobalRoles:d,isGlobalView:u,enterGlobalView:m}=Ee(),{tenantOverrides:p,loadTenantOverrides:f}=Ct(),[g,b]=n.useState(!1),[h,y]=n.useState(""),[x]=n.useState(()=>la()),j=n.useRef(null),v=n.useRef(null),{favorites:S,loadFavorites:N,toggleFavorite:I,recordRecent:P}=Lo();n.useEffect(()=>{g&&(N(),f())},[g,N,f]),n.useEffect(()=>{g&&v.current&&setTimeout(()=>v.current?.focus(),100)},[g]),n.useEffect(()=>Oo(j,b,y),[]),n.useEffect(()=>Fo(b,y),[]);const k=n.useCallback(async T=>{if(T===r?.id&&!u){b(!1);return}try{Mo(T),P(T),await o(T),b(!1),y(""),await s()}catch(z){console.error("Failed to switch tenant:",z)}},[r?.id,u,o,s,P]),A=n.useCallback(async()=>{await m(),b(!1),y(""),await s()},[m,s]),R=n.useCallback(async T=>{await I(T)},[I]),$=n.useMemo(()=>{if(!h.trim())return a;const T=h.toLowerCase();return a.filter(z=>z.name.toLowerCase().includes(T)||z.slug.toLowerCase().includes(T)||z.organisationName?.toLowerCase().includes(T))},[a,h]),{favoriteTenants:q,recentTenants:C,otherTenants:D}=_o($,S,x,a,h);if(c)return null;if(!(i||d)&&r){const T=r.type==="Business";return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-button)"},children:[T?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r.name})]})}return e.jsxs("div",{ref:j,className:"relative",children:[e.jsxs("button",{onClick:()=>b(!g),className:`flex items-center gap-2 px-3 py-1.5 border transition-colors ${u?"bg-emerald-500/10 border-emerald-500/30 hover:bg-emerald-500/20":"bg-[var(--bg-secondary)] border-[var(--border-color)] hover:bg-[var(--bg-tertiary)]"}`,style:{borderRadius:"var(--radius-button)"},"aria-expanded":g,"aria-haspopup":"true",children:[u&&e.jsxs(e.Fragment,{children:[e.jsx(l.Globe,{className:"w-4 h-4 text-emerald-600"}),e.jsx("span",{className:"text-sm font-medium text-emerald-700",children:t("tenants.selector.global","Global")})]}),!u&&r&&e.jsxs(e.Fragment,{children:[r.type==="Business"?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)] max-w-[120px] truncate",children:r.name})]}),!u&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(l.Building2,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("tenants.selector.select","Select")})]}),e.jsx(l.ChevronDown,{className:`w-4 h-4 text-[var(--text-tertiary)] transition-transform ${g?"rotate-180":""}`})]}),e.jsx("div",{className:`absolute left-0 mt-2 w-80 origin-top-left transition-all duration-200 ease-out z-50 ${g?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"relative",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{ref:v,type:"text",value:h,onChange:T=>y(T.target.value),placeholder:t("tenants.selector.search","Rechercher..."),className:"w-full pl-9 pr-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] focus:border-[var(--color-accent-500)] focus:outline-none",style:{borderRadius:"var(--radius-input)"}})]})}),e.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[d&&!h&&e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("button",{onClick:A,className:`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all duration-150 ${u?"bg-emerald-500/10 text-emerald-700":"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-emerald-500/10 flex items-center justify-center",style:{borderRadius:"var(--radius-card)"},children:e.jsx(l.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",children:t("tenants.selector.global","Global")}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:t("tenants.selector.globalDesc","Voir tous les tenants")})]}),u&&e.jsx(l.Check,{className:"w-4 h-4 text-emerald-600 flex-shrink-0"})]})}),q.length>0&&e.jsxs("div",{className:"p-2",children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Star,{className:"w-3 h-3 text-amber-500"}),t("tenants.selector.favorites","Favoris")]}),e.jsx("div",{className:"mt-1",children:q.map(T=>e.jsx(Vt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:!0,hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),C.length>0&&e.jsxs("div",{className:`p-2 ${q.length>0?"border-t border-[var(--border-color)]":""}`,children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Clock,{className:"w-3 h-3"}),t("tenants.selector.recent","Récents")]}),e.jsx("div",{className:"mt-1",children:C.map(T=>e.jsx(Vt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:S.includes(T.id),hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),D.length>0&&e.jsxs("div",{className:`p-2 ${q.length>0||C.length>0?"border-t border-[var(--border-color)]":""}`,children:[!h&&e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Building2,{className:"w-3 h-3"}),t("tenants.selector.all","Tous")]}),e.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto",children:D.map(T=>e.jsx(Vt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:S.includes(T.id),hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),h&&$.length===0&&e.jsx("div",{className:"p-4 text-center text-sm text-[var(--text-tertiary)]",children:t("tenants.selector.noResults","Aucun résultat")})]}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs(w.Link,{to:"/myspace/tenants",className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},onClick:()=>b(!1),children:[e.jsx(l.Eye,{className:"w-4 h-4"}),t("tenants.selector.viewAll","Voir tous mes espaces")," (",a.length,")"]})})]})})]})}function fs(t,s){return t?s===t?"current":"other":"global"}const Uo={getOverview:(t=30)=>E.get("/api/support/dashboard/overview",{params:{days:t}}),getByStatus:()=>E.get("/api/support/dashboard/by-status"),getByPriority:()=>E.get("/api/support/dashboard/by-priority"),getByType:(t=30)=>E.get("/api/support/dashboard/by-type",{params:{days:t}}),getAgentWorkload:()=>E.get("/api/support/dashboard/agent-workload"),getTrends:(t=30)=>E.get("/api/support/dashboard/trends",{params:{days:t}}),getSatisfactionStats:(t=30)=>E.get("/api/support/dashboard/satisfaction",{params:{days:t}}),getSlaCompliance:(t=30)=>E.get("/api/support/dashboard/sla-compliance",{params:{days:t}})},ca={getConfigurations:()=>E.get("/api/support/sla/configurations"),updateConfiguration:(t,s)=>E.put(`/api/support/sla/configurations/${t}`,s),getEscalationRules:()=>E.get("/api/support/sla/escalation-rules"),getBreachedTickets:(t=!0,s=!0)=>E.get("/api/support/sla/breached",{params:{responseBreached:t,resolutionBreached:s}}),getTicketsApproachingBreach:(t=60)=>E.get("/api/support/sla/approaching-breach",{params:{warningMinutes:t}}),getMetrics:(t,s)=>E.get("/api/support/sla/metrics",{params:{fromDate:t,toDate:s}}),escalateTicket:(t,s,r)=>E.post(`/api/support/sla/tickets/${t}/escalate`,{level:s,reason:r})},st={getAll:(t=1,s=20,r,a)=>E.get("/api/support/notifications",{params:{page:t,pageSize:s,isRead:r,tenantId:a}}),getUnread:(t=10)=>E.get("/api/support/notifications/unread",{params:{limit:t}}),getUnreadCount:()=>E.get("/api/support/notifications/unread/count"),markAsRead:t=>E.patch(`/api/support/notifications/${t}/read`),markAllAsRead:()=>E.patch("/api/support/notifications/read-all"),delete:t=>E.delete(`/api/support/notifications/${t}`),deleteAll:()=>E.delete("/api/support/notifications/all"),getPreferences:()=>E.get("/api/support/notifications/preferences"),updatePreferences:t=>E.put("/api/support/notifications/preferences",t)},Lt={getAll:(t,s=!0,r)=>E.get("/api/support/templates",{params:{category:t,activeOnly:s,language:r}}),getById:t=>E.get(`/api/support/templates/${t}`),getCategories:()=>E.get("/api/support/templates/categories"),getByCategory:t=>E.get(`/api/support/templates/by-category/${t}`),create:t=>E.post("/api/support/templates",t),update:(t,s)=>E.put(`/api/support/templates/${t}`,s),activate:t=>E.patch(`/api/support/templates/${t}/activate`),deactivate:t=>E.patch(`/api/support/templates/${t}/deactivate`),delete:t=>E.delete(`/api/support/templates/${t}`),render:(t,s)=>E.post(`/api/support/templates/${t}/render`,{variables:s})},rs={STARTED:"EntraSyncStarted",COMPLETED:"EntraSyncCompleted",FAILED:"EntraSyncFailed"};function zo(t,s,r){if(r){const o=s.relatedEntityId,c=t.filter(i=>!(i.type===rs.STARTED&&i.relatedEntityId===o));return[s,...c].slice(0,10)}return t.some(o=>o.id===s.id)?t:[s,...t].slice(0,10)}function Bo(t){return{id:t.id,type:t.type,title:t.title,message:t.message,relatedEntityType:t.relatedEntityType,relatedEntityId:t.relatedEntityId,actionUrl:t.actionUrl,isRead:t.isRead,readAt:t.readAt,createdAt:t.createdAt,tenantId:t.tenantId,tenantName:t.tenantName,tenantSlug:t.tenantSlug}}function Go(){const[t,s]=n.useState(0),[r,a]=n.useState([]),[o,c]=n.useState(!1),{isConnected:i,onNotification:d,onUnreadCountUpdate:u}=Mr(),{isFeatureEnabled:m}=He(),p=m("support");n.useEffect(()=>{const x=d(v=>{const S=Bo(v),N=v.type===rs.COMPLETED||v.type===rs.FAILED;a(I=>zo(I,S,N))}),j=u(v=>{s(v)});return()=>{x(),j()}},[d,u]),n.useEffect(()=>{if(!p)return;let x=!1;async function j(){try{const v=await st.getUnreadCount();x||s(v.count)}catch(v){x||console.error("Failed to load unread count:",v)}}return j(),()=>{x=!0}},[p]);const f=n.useCallback(async()=>{if(p)try{c(!0);const x=await st.getUnread(10);a(x)}catch(x){console.error("Failed to load notifications:",x)}finally{c(!1)}},[p]),g=n.useCallback(async x=>{try{await st.markAsRead(x),a(j=>j.map(v=>v.id===x?{...v,isRead:!0}:v)),s(j=>Math.max(0,j-1))}catch(j){console.error("Failed to mark as read:",j)}},[]),b=n.useCallback(async()=>{try{await st.markAllAsRead(),a(x=>x.map(j=>({...j,isRead:!0}))),s(0)}catch(x){console.error("Failed to mark all as read:",x)}},[]),h=n.useCallback(async x=>{try{await st.delete(x);const j=r.find(v=>v.id===x);a(v=>v.filter(S=>S.id!==x)),j&&!j.isRead&&s(v=>Math.max(0,v-1))}catch(j){console.error("Failed to delete notification:",j)}},[r]),y=n.useCallback(x=>{st.markAsRead(x),s(j=>Math.max(0,j-1))},[]);return{notifications:r,unreadCount:t,loading:o,isConnected:i,loadNotifications:f,markAsRead:g,markAllAsRead:b,deleteNotification:h,markAsReadSilent:y}}const bt={STARTED:"EntraSyncStarted",COMPLETED:"EntraSyncCompleted",FAILED:"EntraSyncFailed"};function da(){const t=w.useNavigate(),{currentTenant:s,hasMultipleTenants:r}=Ee(),[a,o]=n.useState(!1),c=n.useRef(null),{notifications:i,unreadCount:d,loading:u,isConnected:m,loadNotifications:p,markAsRead:f,markAllAsRead:g,deleteNotification:b,markAsReadSilent:h}=Go(),[,y]=n.useState(0);n.useEffect(()=>{if(!i.some(R=>R.type===bt.STARTED&&!R.isRead))return;const A=setInterval(()=>{y(R=>R+1)},1e3);return()=>clearInterval(A)},[i]),n.useEffect(()=>{a&&p()},[a,p]),n.useEffect(()=>{const k=A=>{c.current&&!c.current.contains(A.target)&&o(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);const x=(k,A)=>{A.stopPropagation(),f(k)},j=(k,A)=>{A.stopPropagation(),b(k)},v=k=>{k.isRead||h(k.id),o(!1),k.actionUrl&&t(k.actionUrl)},S=k=>{switch(k){case"TicketCreated":return"🎫";case"TicketAssigned":return"👤";case"TicketStatusChanged":case"StatusChanged":return"🔄";case"TicketCommented":case"CommentAdded":return"💬";case"TicketResolved":return"✅";case"TicketClosed":return"🔒";case"TicketUpdated":return"📝";case"SlaResponseBreached":case"SlaResolutionBreached":return"⚠️";case"SlaWarning":return"⏰";case"TicketEscalated":return"📈";case"SatisfactionRequested":return"⭐";case"GroupMemberAdded":return"👥";case"GroupMemberRemoved":return"🚪";case"RoleAssigned":return"🎭";case"RoleRemoved":return"🚫";case"RolePermissionsChanged":return"🔑";case"AccountUpdated":return"👤";case"SystemAnnouncement":return"📢";case bt.STARTED:return null;case bt.COMPLETED:return"✅";case bt.FAILED:return"❌";default:return"📌"}},N=k=>{const A=new Date(k).getTime(),R=Date.now(),$=Math.floor((R-A)/1e3),q=Math.floor($/60),C=$%60;return`${q.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`},I=k=>{const A=new Date(k),$=new Date().getTime()-A.getTime(),q=Math.floor($/6e4),C=Math.floor(q/60),D=Math.floor(C/24);return q<1?"Just now":q<60?`${q}m ago`:C<24?`${C}h ago`:D<7?`${D}d ago`:A.toLocaleDateString()},P=k=>{if(!r)return null;const A=fs(k.tenantId,s?.id??null);return A==="global"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-700",children:"System"}):A==="current"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] truncate max-w-[120px]",children:k.tenantName}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700 font-medium truncate max-w-[120px]",children:k.tenantName})};return e.jsxs("div",{className:"relative",ref:c,children:[e.jsxs("button",{onClick:()=>o(!a),className:"relative p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors","aria-label":"Notifications",children:[e.jsx(l.Bell,{className:"w-5 h-5"}),d>0&&e.jsx("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-red-500 text-white text-xs font-bold rounded-full flex items-center justify-center",children:d>9?"9+":d})]}),a&&e.jsxs("div",{className:"absolute right-0 mt-2 w-96 bg-[var(--bg-primary)] rounded-lg shadow-xl border border-[var(--border-color)] z-50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:"Notifications"}),m?e.jsx("span",{title:"Real-time connected",children:e.jsx(l.Wifi,{className:"w-3 h-3 text-green-500"})}):e.jsx("span",{title:"Offline mode",children:e.jsx(l.WifiOff,{className:"w-3 h-3 text-gray-400"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d>0&&e.jsxs("button",{onClick:g,className:"text-sm text-[var(--color-primary-600)] hover:underline flex items-center gap-1",children:[e.jsx(l.CheckCheck,{className:"w-4 h-4"}),"Mark all read"]}),e.jsx("button",{onClick:()=>o(!1),className:"p-1 rounded hover:bg-[var(--bg-hover)]",children:e.jsx(l.X,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"max-h-96 overflow-y-auto",children:[u&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}),!u&&i.length>0&&i.map(k=>{const A=k.type===bt.STARTED&&!k.isRead,R=S(k.type);return e.jsx("div",{role:"button",tabIndex:0,onClick:()=>v(k),onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),v(k))},className:`w-full text-left p-4 border-b border-[var(--border-color)] cursor-pointer hover:bg-[var(--bg-hover)] transition-colors ${k.isRead?"":"bg-blue-50/50 dark:bg-blue-900/10"} ${A?"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20":""}`,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"text-xl flex-shrink-0",children:A?e.jsx(l.RefreshCw,{className:"w-5 h-5 text-[var(--color-accent-600)] animate-spin"}):R}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:`text-sm ${k.isRead?"":"font-semibold"}`,children:k.title}),P(k)]}),A?e.jsxs("span",{className:"text-xs font-mono font-bold text-[var(--color-accent-600)] flex-shrink-0 bg-[var(--color-accent-100)] px-2 py-0.5 rounded",children:["⏱ ",N(k.createdAt)]}):e.jsx("span",{className:"text-xs text-[var(--text-secondary)] flex-shrink-0",children:I(k.createdAt)})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] line-clamp-2 mt-1",children:k.message})]}),e.jsxs("div",{className:"flex flex-col gap-1 flex-shrink-0",children:[!k.isRead&&!A&&e.jsx("button",{onClick:$=>x(k.id,$),className:"p-1 rounded hover:bg-[var(--bg-secondary)]",title:"Mark as read",children:e.jsx(l.Check,{className:"w-4 h-4 text-green-600"})}),!A&&e.jsx("button",{onClick:$=>j(k.id,$),className:"p-1 rounded hover:bg-[var(--bg-secondary)]",title:"Delete",children:e.jsx(l.Trash2,{className:"w-4 h-4 text-red-500"})})]})]})},k.id)}),!u&&i.length===0&&e.jsxs("div",{className:"py-8 text-center text-[var(--text-secondary)]",children:[e.jsx(l.Bell,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No notifications"})]})]}),e.jsx("div",{className:"p-3 border-t border-[var(--border-color)] text-center",children:e.jsx("button",{onClick:()=>{o(!1),t("/notifications")},className:"text-sm text-[var(--color-primary-600)] hover:underline",children:"View all notifications"})})]})]})}const Ko={default:{bg:"bg-[var(--bg-tertiary)]",text:"text-[var(--text-primary)]",border:"border-[var(--border-color)]",arrow:"bg-[var(--bg-tertiary)] border-[var(--border-color)]"},error:{bg:"bg-[var(--tooltip-error-bg)]",text:"text-[var(--error-text)]",border:"border-[var(--error-border)]",arrow:"bg-[var(--tooltip-error-bg)] border-[var(--error-border)]"},warning:{bg:"bg-[var(--tooltip-warning-bg)]",text:"text-[var(--warning-text)]",border:"border-[var(--warning-border)]",arrow:"bg-[var(--tooltip-warning-bg)] border-[var(--warning-border)]"},success:{bg:"bg-[var(--tooltip-success-bg)]",text:"text-[var(--success-text)]",border:"border-[var(--success-border)]",arrow:"bg-[var(--tooltip-success-bg)] border-[var(--success-border)]"},info:{bg:"bg-[var(--tooltip-info-bg)]",text:"text-[var(--info-text)]",border:"border-[var(--info-border)]",arrow:"bg-[var(--tooltip-info-bg)] border-[var(--info-border)]"}};function ua({content:t,children:s,position:r="top",variant:a="default",delay:o=200,disabled:c=!1,className:i=""}){const d=Ko[a],[u,m]=n.useState(!1),[p,f]=n.useState({top:0,left:0}),g=n.useRef(null),b=n.useRef(null),h=n.useRef(null),y=()=>{if(!g.current||!b.current)return;const S=g.current.getBoundingClientRect(),N=b.current.getBoundingClientRect(),I=window.scrollX,P=window.scrollY,k=8;let A=0,R=0;switch(r){case"top":A=S.top+P-N.height-k,R=S.left+I+(S.width-N.width)/2;break;case"bottom":A=S.bottom+P+k,R=S.left+I+(S.width-N.width)/2;break;case"left":A=S.top+P+(S.height-N.height)/2,R=S.left+I-N.width-k;break;case"right":A=S.top+P+(S.height-N.height)/2,R=S.right+I+k;break}const $=window.innerWidth,q=window.innerHeight,C=8;R<C?R=C:R+N.width>$-C&&(R=$-N.width-C),A<C+P?A=C+P:A+N.height>q+P-C&&(A=q+P-N.height-C),f({top:A,left:R})};n.useEffect(()=>(u&&(y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y)),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}),[u,r]);const x=()=>{c||!t||(h.current=setTimeout(()=>{m(!0)},o))},j=()=>{h.current&&(clearTimeout(h.current),h.current=null),m(!1)};n.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const v=()=>{const S=`absolute w-2 h-2 ${d.arrow} transform rotate-45`;switch(r){case"top":return`${S} -bottom-1 left-1/2 -translate-x-1/2 border-r border-b`;case"bottom":return`${S} -top-1 left-1/2 -translate-x-1/2 border-l border-t`;case"left":return`${S} -right-1 top-1/2 -translate-y-1/2 border-t border-r`;case"right":return`${S} -left-1 top-1/2 -translate-y-1/2 border-b border-l`}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:g,onMouseEnter:x,onMouseLeave:j,onFocus:x,onBlur:j,className:"inline-flex",children:s}),u&&t&&Ot.createPortal(e.jsxs("div",{ref:b,role:"tooltip",style:{position:"absolute",top:p.top,left:p.left,zIndex:9999},className:`
1
+ "use strict";const e=require("react/jsx-runtime"),n=require("react"),us=require("axios"),ne=require("react-i18next"),Dt=require("i18next"),Ya=require("i18next-browser-languagedetector"),w=require("react-router-dom"),Ja=require("@microsoft/signalr"),l=require("lucide-react"),pr=require("react-error-boundary"),Ft=require("react-dom"),Ts=require("modern-screenshot"),gt=require("react-resizable-panels"),Qa=require("dompurify");function xr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const oe=xr(Ja),xt=xr(l),Qe={none:"0px",small:"4px",medium:"8px",large:"12px",xlarge:"16px",xxlarge:"24px"},Za={none:"Carré",small:"Léger",medium:"Moyen",large:"Arrondi",xlarge:"Très arrondi",xxlarge:"Pill"},_e={slate:{name:"Ardoise",shades:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"}},gray:{name:"Gris",shades:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"}},zinc:{name:"Zinc",shades:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"}},stone:{name:"Pierre",shades:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"}},indigo:{name:"Indigo",shades:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"}},violet:{name:"Violet",shades:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"}},blue:{name:"Bleu",shades:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"}},cyan:{name:"Cyan",shades:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"}},teal:{name:"Teal",shades:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"}},emerald:{name:"Émeraude",shades:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"}},amber:{name:"Ambre",shades:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"}},orange:{name:"Orange",shades:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"}},rose:{name:"Rose",shades:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},pink:{name:"Pink",shades:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"}}},en={card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},ut={neutral:{name:"Neutre",icon:"⚪",colors:{light:{light:"#ffffff",medium:"#f4f4f5",dark:"#e4e4e7",border:"#d4d4d8"},dark:{light:"#1c1c1f",medium:"#27272a",dark:"#3f3f46",border:"#52525b"}}},ocean:{name:"Océan",icon:"🌊",colors:{light:{light:"#e0f2fe",medium:"#bae6fd",dark:"#7dd3fc",border:"#93c5fd"},dark:{light:"#141c24",medium:"#1a2836",dark:"#2a4a5e",border:"#3a5a70"}}},forest:{name:"Forêt",icon:"🌲",colors:{light:{light:"#d1fae5",medium:"#a7f3d0",dark:"#6ee7b7",border:"#86efac"},dark:{light:"#121d18",medium:"#182a22",dark:"#2a4a3a",border:"#3a5a4a"}}},sunset:{name:"Coucher de soleil",icon:"🌅",colors:{light:{light:"#fef3c7",medium:"#fde68a",dark:"#fbbf24",border:"#fcd34d"},dark:{light:"#1c1810",medium:"#2a2418",dark:"#4a3a24",border:"#5a4a34"}}},lavender:{name:"Lavande",icon:"💜",colors:{light:{light:"#ede9fe",medium:"#ddd6fe",dark:"#c4b5fd",border:"#c4b5fd"},dark:{light:"#1a1820",medium:"#24222e",dark:"#3a3650",border:"#4a4660"}}},rose:{name:"Rose",icon:"🌸",colors:{light:{light:"#fce7f3",medium:"#fbcfe8",dark:"#f9a8d4",border:"#f9a8d4"},dark:{light:"#1c1418",medium:"#2a1e24",dark:"#4a3040",border:"#5a4050"}}}},ms="neutral",mt=t=>{const s=_e[t]?.shades||_e.indigo.shades;return{name:"Clair",primary:_e.indigo.shades,accent:s,backgrounds:{app:"#fafafa",primary:"#ffffff",secondary:"#f4f4f5",tertiary:"#e4e4e7",card:"#ffffff",hover:"#f4f4f5",active:"#e4e4e7"},text:{primary:"#18181b",secondary:"#52525b",tertiary:"#71717a",muted:"#a1a1aa",inverse:"#fafafa"},border:{default:"#e4e4e7",subtle:"#f4f4f5",strong:"#d4d4d8"},status:{success:{bg:"#f0fdfa",text:"#0f766e",border:"#99f6e4",dot:"#14b8a6"},warning:{bg:"#fffbeb",text:"#b45309",border:"#fde68a",dot:"#f59e0b"},error:{bg:"#fff1f2",text:"#be123c",border:"#fecdd3",dot:"#f43f5e"},info:{bg:"#f0f9ff",text:"#0369a1",border:"#bae6fd",dot:"#0ea5e9"}},accentTransparent:{bg:`${s[50]}`,text:s[700],border:s[200]}}},pt=t=>{const s=_e[t]?.shades||_e.indigo.shades;return{name:"Sombre",primary:_e.indigo.shades,accent:s,backgrounds:{app:"#161618",primary:"#1c1c1f",secondary:"#232326",tertiary:"#2a2a2e",card:"#1c1c1f",hover:"#27272a",active:"#3f3f46"},text:{primary:"#fafafa",secondary:"#d4d4d8",tertiary:"#a1a1aa",muted:"#71717a",inverse:"#18181b"},border:{default:"#3f3f46",subtle:"#27272a",strong:"#52525b"},status:{success:{bg:"rgba(20, 184, 166, 0.15)",text:"#5eead4",border:"rgba(20, 184, 166, 0.3)",dot:"#14b8a6"},warning:{bg:"rgba(245, 158, 11, 0.15)",text:"#fbbf24",border:"rgba(245, 158, 11, 0.3)",dot:"#f59e0b"},error:{bg:"rgba(244, 63, 94, 0.15)",text:"#fb7185",border:"rgba(244, 63, 94, 0.3)",dot:"#f43f5e"},info:{bg:"rgba(14, 165, 233, 0.15)",text:"#7dd3fc",border:"rgba(14, 165, 233, 0.3)",dot:"#0ea5e9"}},accentTransparent:{bg:`rgba(${Rs(s[500])}, 0.15)`,text:s[300],border:`rgba(${Rs(s[500])}, 0.3)`}}};function Rs(t){const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return s?`${parseInt(s[1],16)}, ${parseInt(s[2],16)}, ${parseInt(s[3],16)}`:"99, 102, 241"}const yt={mode:"dark",borderRadius:en,colors:{light:mt("indigo"),dark:pt("indigo")},accentColorKey:"indigo",itemPaletteKey:ms},tn=[{id:"default",name:"Par défaut",description:"Style SmartStack classique avec coins arrondis",icon:"✨",config:{borderRadius:{card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"indigo",itemPaletteKey:"neutral"}},{id:"minimal",name:"Minimal",description:"Style épuré et professionnel",icon:"⚪",config:{borderRadius:{card:"medium",button:"small",badge:"small",input:"small",modal:"medium",menuItem:"small"},accentColorKey:"slate",itemPaletteKey:"neutral"}},{id:"corporate",name:"Corporate",description:"Style sobre pour environnement professionnel",icon:"🏢",config:{borderRadius:{card:"small",button:"small",badge:"medium",input:"small",modal:"medium",menuItem:"small"},accentColorKey:"gray",itemPaletteKey:"neutral"}},{id:"ocean",name:"Océan",description:"Teintes bleues apaisantes",icon:"🌊",config:{borderRadius:{card:"large",button:"medium",badge:"medium",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"cyan",itemPaletteKey:"ocean"}},{id:"forest",name:"Forêt",description:"Tons verts naturels",icon:"🌲",config:{borderRadius:{card:"medium",button:"medium",badge:"medium",input:"medium",modal:"large",menuItem:"medium"},accentColorKey:"emerald",itemPaletteKey:"forest"}},{id:"sunset",name:"Coucher de soleil",description:"Couleurs chaudes et accueillantes",icon:"🌅",config:{borderRadius:{card:"large",button:"large",badge:"xxlarge",input:"medium",modal:"xlarge",menuItem:"medium"},accentColorKey:"orange",itemPaletteKey:"sunset"}},{id:"lavender",name:"Lavande",description:"Tons violets élégants",icon:"💜",config:{borderRadius:{card:"xlarge",button:"large",badge:"xlarge",input:"large",modal:"xlarge",menuItem:"large"},accentColorKey:"violet",itemPaletteKey:"lavender"}},{id:"rose",name:"Rose",description:"Teintes roses douces",icon:"🌸",config:{borderRadius:{card:"xxlarge",button:"xlarge",badge:"xxlarge",input:"large",modal:"xxlarge",menuItem:"large"},accentColorKey:"pink",itemPaletteKey:"rose"}}],hr="smartstack-theme-config";class Pt extends Error{statusCode;details;constructor(s,r,a){super(s),this.name="AppError",this.statusCode=r,this.details=a}}class ps extends Error{constructor(s="Network error occurred"){super(s),this.name="NetworkError"}}class gr extends Error{code;constructor(s="Authentication required",r){super(s),this.name="AuthenticationError",this.code=r}}class sn extends Error{constructor(s="Access denied"){super(s),this.name="ForbiddenError"}}const rn=10;class an{queue=[];recentErrors=[];isProcessing=!1;batchSize=10;batchDelay=2e3;async logError(s,r,a){const o=typeof s=="string"?s:s.message;let c=o;if(a?.url){const d=String(a.url),u=a.status?` [${a.status}]`:"";c=`${o}${u} - ${d}`}const i={message:c,stack:typeof s=="string"?void 0:s.stack,url:window.location.href,component:r,level:"Error",metadata:a};this.storeRecentError(i),this.queue.push({type:"error",data:i}),this.processQueue()}async logCritical(s,r,a){const o=typeof s=="string"?s:s.message;let c=o;if(a?.url){const u=String(a.url),m=a.status?` [${a.status}]`:"";c=`${o}${m} - ${u}`}const i={message:c,stack:typeof s=="string"?void 0:s.stack,url:window.location.href,component:r,level:"Critical",metadata:a};return this.storeRecentError(i),await this.sendErrorWithResponse(i)}getRecentErrors(){return[...this.recentErrors]}clearRecentErrors(){this.recentErrors=[]}storeRecentError(s){this.recentErrors.unshift({...s,timestamp:new Date}),this.recentErrors.length>rn&&this.recentErrors.pop()}async logEvent(s,r,a){const o={event:s,category:r,data:a};this.queue.push({type:"event",data:o}),this.processQueue()}async processQueue(){if(this.isProcessing||this.queue.length===0)return;this.isProcessing=!0,await new Promise(r=>setTimeout(r,this.batchDelay));const s=this.queue.splice(0,this.batchSize);for(const r of s)try{r.type==="error"?await this.sendError(r.data):await this.sendEvent(r.data)}catch{}this.isProcessing=!1,this.queue.length>0&&this.processQueue()}async sendError(s){const r=localStorage.getItem("token");await fetch("/api/logs/client-error",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)})}async sendErrorWithResponse(s){const r=localStorage.getItem("token");try{const a=await fetch("/api/logs/client-error",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)});return a.ok&&a.status===200&&(await a.json()).ticketNumber||null}catch{return null}}async sendEvent(s){const r=localStorage.getItem("token");await fetch("/api/logs/client-event",{method:"POST",headers:{"Content-Type":"application/json",...r&&{Authorization:`Bearer ${r}`}},body:JSON.stringify(s)})}}const Te=new an;window.onerror=(t,s,r,a,o)=>{Te.logError(o||String(t),"window.onerror",{source:s,lineno:r,colno:a})};window.onunhandledrejection=t=>{Te.logError(t.reason instanceof Error?t.reason:String(t.reason),"unhandledrejection")};const Se=us.create({timeout:3e4,headers:{"Content-Type":"application/json"}});Se.interceptors.request.use(t=>{const s=localStorage.getItem("token");s&&t.headers&&(t.headers.Authorization=`Bearer ${s}`);const r=crypto.randomUUID();t.headers&&(t.headers["X-Correlation-ID"]=r);const a=localStorage.getItem("i18nextLng")||navigator.language||"fr";t.headers&&(t.headers["Accept-Language"]=a);const o=localStorage.getItem("currentTenantSlug");return o&&t.headers&&!t.headers["X-Tenant-Slug"]&&(t.headers["X-Tenant-Slug"]=o),t},t=>(Te.logError(t,"apiClient.request"),Promise.reject(t)));Se.interceptors.response.use(t=>t,async t=>{const s=t.config?.headers?.["X-Correlation-ID"];if(us.isCancel(t)||t.code==="ERR_CANCELED")return Promise.reject(t);if(!t.response){const i=new ps("Impossible de se connecter au serveur. Vérifiez votre connexion internet.");return Te.logError(i,"apiClient.response",{correlationId:s}),Promise.reject(i)}const{status:r,data:a}=t.response,o=a?.message||a?.detail||a?.title||t.message,c=a?.code;switch(r){case 401:{const i=new gr(o,c);Te.logError(i,"apiClient.response",{correlationId:s,url:t.config?.url,code:c});const d=t.config?.url||"",m=["/api/user/preferences","/api/auth/session-info","/api/auth/refresh","/api/navigation/menu","/api/navigation/favorites","/api/navigation/contexts","/api/onboarding/status","/api/administration/tenants/tenant-analytics/track/"].some(p=>d.startsWith(p));if(!window.location.pathname.includes("/login")&&!m){localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user");const f=c==="SESSION_EXPIRED"?"/login?reason=session_expired":"/login";window.location.href=f}return Promise.reject(i)}case 403:{const i=new sn(o),d=["/api/administration/tenants/tenant-analytics/track/","/api/support/notifications"],u=t.config?.url||"";return d.some(p=>u.startsWith(p))||Te.logError(i,"apiClient.response",{correlationId:s,url:t.config?.url,method:t.config?.method}),Promise.reject(i)}case 404:return Promise.reject(new Pt(o||"Resource not found",r));case 400:return Promise.reject(new Pt(o||"Invalid request",r,a?.details||a?.errors));case 500:case 502:case 503:case 504:{const i=new Pt(o||"Server error",r);return Te.logCritical(i,"apiClient.response",{correlationId:s,url:t.config?.url,status:r}),Promise.reject(i)}default:{const i=new Pt(o,r,a?.details);return Te.logError(i,"apiClient.response",{correlationId:s,status:r}),Promise.reject(i)}}});const E={get:(t,s)=>Se.get(t,s).then(r=>r.data),post:(t,s,r)=>Se.post(t,s,r).then(a=>a.data),put:(t,s,r)=>Se.put(t,s,r).then(a=>a.data),patch:(t,s,r)=>Se.patch(t,s,r).then(a=>a.data),delete:(t,s)=>Se.delete(t,s).then(r=>r.data)},_t={preferences:{get:()=>E.get("/api/user/preferences"),updateTheme:t=>E.put("/api/user/preferences/theme",t),updateLanguage:t=>E.put("/api/user/preferences/language",t),updateNotifications:t=>E.put("/api/user/preferences/notifications",t)},dashboard:{getAll:(t=30,s=10)=>E.get(`/api/user/dashboard/all?period=${t}&errorLimit=${s}`),getSessionAnalytics:(t=30)=>E.get(`/api/user/dashboard/session-analytics?period=${t}`),getLoginErrors:(t=10)=>E.get(`/api/user/dashboard/login-errors?limit=${t}`),getCurrentSession:()=>E.get("/api/user/dashboard/current-session"),getDeviceStats:()=>E.get("/api/user/dashboard/device-stats"),getWeeklyStats:(t=30)=>E.get(`/api/user/dashboard/weekly-stats?period=${t}`),getHourlyStats:(t=30)=>E.get(`/api/user/dashboard/hourly-stats?period=${t}`),getApplicationUsage:(t=30)=>E.get(`/api/user/dashboard/application-usage?period=${t}`)}},nn=t=>({get:(s,r)=>Se.get(s,{...r,headers:t?{...r?.headers,"X-Tenant-Slug":t}:r?.headers}).then(a=>a.data),post:(s,r,a)=>Se.post(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),put:(s,r,a)=>Se.put(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),patch:(s,r,a)=>Se.patch(s,r,{...a,headers:t?{...a?.headers,"X-Tenant-Slug":t}:a?.headers}).then(o=>o.data),delete:(s,r)=>Se.delete(s,{...r,headers:t?{...r?.headers,"X-Tenant-Slug":t}:r?.headers}).then(a=>a.data)}),on={PasswordResetMalfunction:1,FalsePositive:2,UrgentBusinessNeed:3,TechnicalSystemError:4,SupportTicketVerified:5},ln=t=>({getAll:s=>t.get("/api/administration/users",{params:s}),getById:s=>t.get(`/api/administration/users/${s}`),create:s=>t.post("/api/administration/users",s),update:(s,r)=>t.put(`/api/administration/users/${s}`,r),sendPasswordResetLink:s=>t.post(`/api/administration/users/${s}/send-password-reset`),resetPasswordDirect:(s,r)=>t.post(`/api/administration/users/${s}/reset-password-direct`,r?{temporaryPassword:r}:{}),activate:s=>t.patch(`/api/administration/users/${s}/activate`),deactivate:s=>t.patch(`/api/administration/users/${s}/deactivate`),unlock:(s,r)=>t.post(`/api/administration/users/${s}/unlock`,r),clearFailedAttempts:s=>t.post(`/api/administration/users/${s}/clear-failed-attempts`),delete:s=>t.delete(`/api/administration/users/${s}`),getSessions:s=>t.get(`/api/administration/users/${s}/sessions`),endAllSessions:s=>t.post(`/api/administration/users/${s}/sessions/end-all`),endSession:(s,r)=>t.delete(`/api/administration/users/${s}/sessions/${r}`),getActivity:s=>t.get(`/api/administration/users/${s}/activity`),getCustomRole:s=>t.get(`/api/administration/users/${s}/custom-role`),createCustomRole:s=>t.post(`/api/administration/users/${s}/custom-role`),deleteCustomRole:s=>t.delete(`/api/administration/users/${s}/custom-role`),getHistory:(s,r=50)=>t.get(`/api/administration/users/${s}/history`,{params:{limit:r}}),restoreFromHistory:(s,r)=>t.post(`/api/administration/users/${s}/history/${r}/restore`),getOrganizationReferences:()=>t.get("/api/administration/users/organization-references"),references:{getCompanies:s=>t.get("/api/administration/users/references/companies",{params:s}),getDepartments:s=>t.get("/api/administration/users/references/departments",{params:s}),getJobTitles:s=>t.get("/api/administration/users/references/job-titles",{params:s}),getOffices:s=>t.get("/api/administration/users/references/offices",{params:s}),createCompany:(s,r)=>t.post(`/api/administration/users/references/companies${r?`?tenantId=${r}`:""}`,s),createDepartment:(s,r)=>t.post(`/api/administration/users/references/departments${r?`?tenantId=${r}`:""}`,s),createJobTitle:(s,r)=>t.post(`/api/administration/users/references/job-titles${r?`?tenantId=${r}`:""}`,s),createOffice:(s,r)=>t.post(`/api/administration/users/references/offices${r?`?tenantId=${r}`:""}`,s),updateCompany:(s,r)=>t.put(`/api/administration/users/references/companies/${s}`,r),updateDepartment:(s,r)=>t.put(`/api/administration/users/references/departments/${s}`,r),updateJobTitle:(s,r)=>t.put(`/api/administration/users/references/job-titles/${s}`,r),updateOffice:(s,r)=>t.put(`/api/administration/users/references/offices/${s}`,r),activateCompany:s=>t.patch(`/api/administration/users/references/companies/${s}/activate`),activateDepartment:s=>t.patch(`/api/administration/users/references/departments/${s}/activate`),activateJobTitle:s=>t.patch(`/api/administration/users/references/job-titles/${s}/activate`),activateOffice:s=>t.patch(`/api/administration/users/references/offices/${s}/activate`),deactivateCompany:s=>t.patch(`/api/administration/users/references/companies/${s}/deactivate`),deactivateDepartment:s=>t.patch(`/api/administration/users/references/departments/${s}/deactivate`),deactivateJobTitle:s=>t.patch(`/api/administration/users/references/job-titles/${s}/deactivate`),deactivateOffice:s=>t.patch(`/api/administration/users/references/offices/${s}/deactivate`),deleteCompany:s=>t.delete(`/api/administration/users/references/companies/${s}`),deleteDepartment:s=>t.delete(`/api/administration/users/references/departments/${s}`),deleteJobTitle:s=>t.delete(`/api/administration/users/references/job-titles/${s}`),deleteOffice:s=>t.delete(`/api/administration/users/references/offices/${s}`)},updateProfile:(s,r)=>t.put(`/api/administration/users/${s}/profile`,r),updateOrganization:(s,r)=>t.put(`/api/administration/users/${s}/organization`,r),updateJobInfo:(s,r)=>t.put(`/api/administration/users/${s}/job-info`,r),updatePhones:(s,r)=>t.put(`/api/administration/users/${s}/phones`,r),updateAddress:(s,r)=>t.put(`/api/administration/users/${s}/address`,r),updateContact:(s,r)=>t.put(`/api/administration/users/${s}/contact`,r),getTenants:s=>t.get(`/api/administration/users/${s}/tenants`),getGroups:s=>t.get(`/api/administration/users/${s}/groups`),getConsolidatedRoles:(s,r)=>{const a=r?`/api/administration/users/${s}/consolidated-roles?tenantId=${r}`:`/api/administration/users/${s}/consolidated-roles`;return t.get(a)},getApplicationAccess:(s,r)=>{const a=r?`/api/administration/users/${s}/application-access?tenantId=${r}`:`/api/administration/users/${s}/application-access`;return t.get(a)}}),cn=ln,dn=t=>({getAll:s=>t.get("/api/administration/permissions/roles",{params:s}),getAssignable:()=>t.get("/api/administration/permissions/roles",{params:{excludeCategories:"Custom",minPermissionsCount:1}}),getServiceAssignable:()=>t.get("/api/administration/permissions/roles",{params:{forExternalApps:!0,minPermissionsCount:1}}),getByApplication:s=>t.get("/api/administration/permissions/roles",{params:{applicationId:s,excludeCategories:"Custom",minPermissionsCount:1}}),getById:s=>t.get(`/api/administration/permissions/roles/${s}`),create:s=>t.post("/api/administration/permissions/roles",s),update:(s,r)=>t.put(`/api/administration/permissions/roles/${s}`,r),delete:s=>t.delete(`/api/administration/permissions/roles/${s}`),assignUser:(s,r)=>t.post(`/api/administration/permissions/roles/${s}/users/${r}`),removeUser:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/users/${r}`),getGroups:s=>t.get(`/api/administration/permissions/roles/${s}/groups`),assignGroup:(s,r)=>t.post(`/api/administration/permissions/roles/${s}/groups/${r}`),removeGroup:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/groups/${r}`),getTranslations:s=>t.get(`/api/administration/permissions/roles/${s}/translations`),upsertTranslation:(s,r,a)=>t.put(`/api/administration/permissions/roles/${s}/translations/${r}`,a),deleteTranslation:(s,r)=>t.delete(`/api/administration/permissions/roles/${s}/translations/${r}`)}),un=dn,mn=t=>({getAll:s=>t.get("/api/administration/permissions",{params:s}),getById:s=>t.get(`/api/administration/permissions/${s}`),getTree:()=>t.get("/api/administration/permissions/tree"),getMatrix:()=>t.get("/api/administration/permissions/matrix"),delete:s=>t.delete(`/api/administration/permissions/${s}`)}),pn=mn,xn=t=>({getAll:s=>t.get("/api/administration/applications",{params:s}),getById:s=>t.get(`/api/administration/applications/${s}`),update:(s,r)=>t.put(`/api/administration/applications/${s}`,r),activate:s=>t.patch(`/api/administration/applications/${s}/activate`),deactivate:s=>t.patch(`/api/administration/applications/${s}/deactivate`),getModules:s=>t.get(`/api/administration/applications/${s}/modules`),updateModule:(s,r,a)=>t.put(`/api/administration/applications/${s}/modules/${r}`,a),getModuleSections:(s,r)=>t.get(`/api/administration/applications/${s}/modules/${r}/sections`),reorderModules:(s,r)=>t.put(`/api/administration/applications/${s}/modules/reorder`,{items:r}),reorderSections:(s,r,a)=>t.put(`/api/administration/applications/${s}/modules/${r}/sections/reorder`,{items:a}),getTenants:s=>t.get(`/api/administration/applications/${s}/tenants`),getAvailableTenants:s=>t.get(`/api/administration/applications/${s}/tenants/available`),assignToTenant:(s,r,a)=>t.post(`/api/administration/applications/${s}/tenants/${r}`,a?{accessLevel:a}:{}),removeFromTenant:(s,r)=>t.delete(`/api/administration/applications/${s}/tenants/${r}`),updateTenantAccessLevel:(s,r,a)=>t.patch(`/api/administration/applications/${s}/tenants/${r}/access-level`,{accessLevel:a}),bulkAssignTenants:(s,r)=>t.post(`/api/administration/applications/${s}/tenants/bulk`,r)}),hn=xn,gn=t=>({getOverview:(s=30,r)=>t.get("/api/administration/users/dashboard/overview",{params:{days:s},signal:r?.signal}),getByStatus:s=>t.get("/api/administration/users/dashboard/by-status",{signal:s?.signal}),getByRole:s=>t.get("/api/administration/users/dashboard/by-role",{signal:s?.signal}),getByType:s=>t.get("/api/administration/users/dashboard/by-type",{signal:s?.signal}),getLoginActivity:(s=30,r)=>t.get("/api/administration/users/dashboard/login-activity",{params:{days:s},signal:r?.signal}),getTrends:(s=30,r)=>t.get("/api/administration/users/dashboard/trends",{params:{days:s},signal:r?.signal}),getRecentUsers:(s=10,r)=>t.get("/api/administration/users/dashboard/recent-users",{params:{limit:s},signal:r?.signal}),getSecurityAlerts:(s=3,r=24,a)=>t.get("/api/administration/users/dashboard/security-alerts",{params:{threshold:s,hours:r},signal:a?.signal}),getActiveSessions:s=>t.get("/api/administration/users/dashboard/active-sessions",{signal:s?.signal}),getLatestActiveSessions:(s=5,r)=>t.get("/api/administration/users/dashboard/latest-active-sessions",{params:{limit:s},signal:r?.signal})}),fn=gn,bn=t=>({getAll:()=>t.get("/api/administration/configuration/settings"),getByCategory:s=>t.get(`/api/administration/configuration/settings/${s}`),get:(s,r)=>t.get(`/api/administration/configuration/settings/${s}/${r}`),update:(s,r,a)=>t.put(`/api/administration/configuration/settings/${s}/${r}`,{value:a}),reset:(s,r)=>t.post(`/api/administration/configuration/settings/${s}/${r}/reset`),getHistory:(s,r)=>t.get(`/api/administration/configuration/settings/${s}/${r}/history`),getCategories:()=>t.get("/api/administration/configuration/settings/categories")}),vn=bn,yn=t=>({get:()=>t.get("/api/user/preferences"),getGlobal:()=>t.get("/api/user/preferences/global"),getForTenant:s=>t.get(`/api/user/preferences/for-tenant/${s}`),getThemeOverrides:()=>t.get("/api/user/preferences/theme-overrides"),deleteTenantOverride:()=>t.delete("/api/user/preferences/tenant-override"),applyToTenant:()=>t.post("/api/user/preferences/apply-to-tenant")}),jn=yn,Nn=t=>({getConfig:()=>t.get("/api/administration/tenants/config"),getAll:s=>{const{excludeTypes:r,...a}=s||{},o=new URLSearchParams;a.page&&o.set("page",String(a.page)),a.pageSize&&o.set("pageSize",String(a.pageSize)),a.search&&o.set("search",a.search),a.status&&o.set("status",a.status),a.type&&o.set("type",a.type),a.sortBy&&o.set("sortBy",a.sortBy),a.sortDesc&&o.set("sortDesc","true"),r?.length&&r.forEach(i=>o.append("excludeTypes",i));const c=o.toString();return t.get(`/api/administration/tenants${c?`?${c}`:""}`)},getById:s=>t.get(`/api/administration/tenants/${s}`),createB2C:s=>t.post("/api/administration/tenants/b2c",s),createB2B:s=>t.post("/api/administration/tenants/b2b",s),update:(s,r)=>t.put(`/api/administration/tenants/${s}`,r),delete:s=>t.delete(`/api/administration/tenants/${s}`),activate:s=>t.post(`/api/administration/tenants/${s}/activate`),suspend:s=>t.post(`/api/administration/tenants/${s}/suspend`),archive:s=>t.delete(`/api/administration/tenants/${s}`),checkSlugAvailable:s=>t.get(`/api/administration/tenants/check-slug/${s}`),assignTemplate:(s,r)=>t.post(`/api/administration/tenants/${s}/template`,{templateId:r}),removeTemplate:s=>t.delete(`/api/administration/tenants/${s}/template`),getMembers:s=>t.get(`/api/administration/tenants/${s}/members`),getMember:(s,r)=>t.get(`/api/administration/tenants/${s}/members/${r}`),addMember:(s,r)=>t.post(`/api/administration/tenants/${s}/members`,r),removeMember:(s,r)=>t.delete(`/api/administration/tenants/${s}/members/${r}`),setMemberDefault:(s,r)=>t.patch(`/api/administration/tenants/${s}/members/${r}/set-default`),transferOwnership:(s,r)=>t.post(`/api/administration/tenants/${s}/members/transfer-ownership`,{toUserId:r}),assignRole:(s,r,a)=>t.post(`/api/administration/tenants/${s}/members/${r}/roles/${a}`),removeRole:(s,r,a)=>t.delete(`/api/administration/tenants/${s}/members/${r}/roles/${a}`),assignMemberRoles:(s,r,a)=>t.put(`/api/administration/tenants/${s}/members/${r}/roles`,{roleIds:a}),getMemberCustomRole:(s,r)=>t.get(`/api/administration/tenants/${s}/members/${r}/custom-role`),createMemberCustomRole:(s,r)=>t.post(`/api/administration/tenants/${s}/members/${r}/custom-role`),deleteMemberCustomRole:(s,r)=>t.delete(`/api/administration/tenants/${s}/members/${r}/custom-role`),getTenantRoles:s=>t.get(`/api/administration/tenants/${s}/roles`),getGroups:s=>t.get(`/api/administration/tenants/${s}/groups`),getAvailableGroups:s=>t.get(`/api/administration/tenants/${s}/groups/available`),addGroupToTenant:(s,r)=>t.post(`/api/administration/tenants/${s}/groups`,{groupId:r}),removeGroupFromTenant:(s,r)=>t.delete(`/api/administration/tenants/${s}/groups/${r}`),getApplications:s=>t.get(`/api/administration/tenants/${s}/applications`),getAvailableApplications:s=>t.get(`/api/administration/tenants/${s}/applications/available`),assignApplication:(s,r)=>t.post(`/api/administration/tenants/${s}/applications/${r}`),removeApplication:(s,r)=>t.delete(`/api/administration/tenants/${s}/applications/${r}`),bulkAssignApplications:(s,r)=>t.post(`/api/administration/tenants/${s}/applications/bulk`,r),toggleApplication:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/applications/${r}/toggle`,{isActive:a}),updateApplicationAccessLevel:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/applications/${r}/access-level`,{accessLevel:a}),getEffectiveTree:(s,r)=>t.get(`/api/administration/tenants/${s}/applications/${r}/effective-tree`),saveOverrides:(s,r,a)=>t.put(`/api/administration/tenants/${s}/applications/${r}/overrides`,a),getModules:s=>t.get(`/api/administration/tenants/${s}/modules`),getAvailableModules:s=>t.get(`/api/administration/tenants/${s}/modules/available`),assignModule:(s,r)=>t.post(`/api/administration/tenants/${s}/modules/${r}`),removeModule:(s,r)=>t.delete(`/api/administration/tenants/${s}/modules/${r}`),toggleModule:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/modules/${r}/toggle`,{isActive:a}),getSections:s=>t.get(`/api/administration/tenants/${s}/sections`),getAvailableSections:s=>t.get(`/api/administration/tenants/${s}/sections/available`),assignSection:(s,r)=>t.post(`/api/administration/tenants/${s}/sections/${r}`),removeSection:(s,r)=>t.delete(`/api/administration/tenants/${s}/sections/${r}`),toggleSection:(s,r,a)=>t.patch(`/api/administration/tenants/${s}/sections/${r}/toggle`,{isActive:a}),getModulesWithSections:(s,r)=>t.get(`/api/administration/tenants/${s}/applications/${r}/modules-tree`),linkOrganisation:(s,r)=>t.post(`/api/administration/tenants/${s}/organisation`,{organisationId:r}),unlinkOrganisation:s=>t.delete(`/api/administration/tenants/${s}/organisation`)}),wn=Nn,Sn=t=>({getAll:()=>t.get("/api/administration/tenants/templates"),getById:s=>t.get(`/api/administration/tenants/templates/${s}`),create:s=>t.post("/api/administration/tenants/templates",s),update:(s,r)=>t.put(`/api/administration/tenants/templates/${s}`,r),delete:s=>t.delete(`/api/administration/tenants/templates/${s}`),assignApplication:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/applications/${r}`),removeApplication:(s,r)=>t.delete(`/api/administration/tenants/templates/${s}/applications/${r}`),bulkAssignApplications:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/applications/bulk`,r),getTenants:s=>t.get(`/api/administration/tenants/templates/${s}/tenants`),getApplications:s=>t.get(`/api/administration/tenants/templates/${s}/applications`),getAvailableApplications:s=>t.get(`/api/administration/tenants/templates/${s}/applications/available`),updateApplicationAccessLevel:(s,r,a)=>t.patch(`/api/administration/tenants/templates/${s}/applications/${r}/access-level`,{accessLevel:a}),getApplicationModules:(s,r)=>t.get(`/api/administration/tenants/templates/${s}/applications/${r}/modules`),updateApplicationModules:(s,r,a)=>t.put(`/api/administration/tenants/templates/${s}/applications/${r}/modules`,a),getAiInstances:s=>t.get(`/api/administration/tenants/templates/${s}/ai-instances`),assignAiInstance:(s,r)=>t.post(`/api/administration/tenants/templates/${s}/ai-instances/${r}`),removeAiInstance:(s,r)=>t.delete(`/api/administration/tenants/templates/${s}/ai-instances/${r}`)}),Cn=Sn,kn=t=>({getAll:s=>t.get("/api/administration/tenants/organisations",{params:s}),getAvailable:s=>t.get("/api/administration/tenants/organisations/available",{params:s?{search:s}:void 0}),getPendingVerification:()=>t.get("/api/administration/tenants/organisations/pending-verification"),getById:s=>t.get(`/api/administration/tenants/organisations/${s}`),findById:async s=>{const r=await Se.get(`/api/administration/tenants/organisations/${s}`,{validateStatus:a=>a===200||a===404});return r.status===200?r.data:null},create:s=>t.post("/api/administration/tenants/organisations",s),updateContact:(s,r)=>t.put(`/api/administration/tenants/organisations/${s}/contact`,r),updateAddress:(s,r)=>t.put(`/api/administration/tenants/organisations/${s}/address`,r),verify:(s,r)=>t.post(`/api/administration/tenants/organisations/${s}/verify`,{notes:r}),reject:(s,r)=>t.post(`/api/administration/tenants/organisations/${s}/reject`,{reason:r}),lookup:(s,r)=>t.get("/api/administration/tenants/organisations/lookup",{params:{countryCode:s,identifier:r}})}),An=kn,Pn=t=>({getAll:s=>t.get("/api/administration/tenants/my",{params:s?{search:s}:void 0}),getDefault:()=>t.get("/api/administration/tenants/my/default"),setDefault:s=>t.post(`/api/administration/tenants/${s}/set-default`),clearDefault:()=>t.delete("/api/administration/tenants/clear-default"),getFavorites:()=>t.get("/api/user/preferences/tenant-favorites"),addFavorite:s=>t.post(`/api/user/preferences/tenant-favorites/${s}`),removeFavorite:s=>t.delete(`/api/user/preferences/tenant-favorites/${s}`),recordRecent:s=>t.post(`/api/user/preferences/tenant-recent/${s}`)}),Tn=Pn,Rn=t=>({getAll:s=>t.get("/api/accounts",{params:s}),getById:s=>t.get(`/api/accounts/${s}`),create:s=>t.post("/api/accounts",s),update:(s,r)=>t.put(`/api/accounts/${s}`,r),delete:s=>t.delete(`/api/accounts/${s}`),activate:s=>t.patch(`/api/accounts/${s}/activate`),deactivate:s=>t.patch(`/api/accounts/${s}/deactivate`),rotateSecret:(s,r="Primary")=>t.post(`/api/accounts/${s}/rotate-secret?keySlot=${r}`),revokeSecondarySecret:s=>t.delete(`/api/accounts/${s}/secondary-secret`),assignRole:(s,r)=>t.post(`/api/accounts/${s}/roles`,r),removeRole:(s,r,a)=>t.delete(`/api/accounts/${s}/roles/${r}`,{params:a?{tenantId:a}:void 0}),generateSecret:()=>t.post("/api/accounts/generate-secret"),getAuditLogs:(s,r=1,a=20)=>t.get(`/api/accounts/${s}/audit-logs`,{params:{page:r,pageSize:a}}),getUsageStats:(s,r=30)=>t.get(`/api/accounts/${s}/usage-stats`,{params:{days:r}}),getKeyUsage:s=>t.get(`/api/accounts/${s}/key-usage`),getApiEndpoints:()=>t.get("/api/accounts/api-endpoints"),getAppApiAccess:s=>t.get(`/api/accounts/${s}/api-access`),updateApiAccess:(s,r,a)=>t.put(`/api/accounts/${s}/api-access/${r}`,a),removeApiAccess:(s,r)=>t.delete(`/api/accounts/${s}/api-access/${r}`)}),En=Rn,In=t=>({getNavigationLookup:()=>t.get("/api/apis/navigation-lookup")}),Ln=In,fr=t=>{const s=t?nn(t):E;return{users:cn(s),roles:un(s),permissions:pn(s),applications:hn(s),dashboard:fn(s),settings:vn(s),tenants:wn(s),templates:Cn(s),organisations:An(s),myTenants:Tn(s),preferences:jn(s),externalApps:En(s),apiCatalog:Ln(s)}},Ne=fr(),ge=(t,s,r)=>{const a=t[s];return a?typeof a=="function"?a():Promise.resolve(a):new Promise((o,c)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(c.bind(null,new Error("Unknown variable dynamic import: "+s+(s.split("/").length!==r?". Note that variables only represent file names one level deep.":""))))})},ss=async t=>{if(!t)return null;try{const[s,r,a,o,c,i,d,u,m,p,f,h,b,g,y,x,j,v,S,N,I,P,k,A,R,$,q,C,D,Y,T,z,Z,H]=await Promise.all([ge(Object.assign({"./locales/de/common.json":()=>Promise.resolve().then(()=>require("./common-BZM8Gf-R.js")),"./locales/en/common.json":()=>Promise.resolve().then(()=>require("./common-Daanch0E.js")),"./locales/fr/common.json":()=>Promise.resolve().then(()=>require("./common-lhAPHx3v.js")),"./locales/it/common.json":()=>Promise.resolve().then(()=>require("./common-B4gIg-Uo.js"))}),`./locales/${t}/common.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-D8yOGHza.js")),"./locales/en/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-rEtU7BPw.js")),"./locales/fr/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-BI8iMTJl.js")),"./locales/it/navigation.json":()=>Promise.resolve().then(()=>require("./navigation-BTkWh95c.js"))}),`./locales/${t}/navigation.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/auth.json":()=>Promise.resolve().then(()=>require("./auth-C5zpZ9k7.js")),"./locales/en/auth.json":()=>Promise.resolve().then(()=>require("./auth-DL47kvnl.js")),"./locales/fr/auth.json":()=>Promise.resolve().then(()=>require("./auth-B-hELPDB.js")),"./locales/it/auth.json":()=>Promise.resolve().then(()=>require("./auth-CyPkCta2.js"))}),`./locales/${t}/auth.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/admin.json":()=>Promise.resolve().then(()=>require("./admin-egO_sJAt.js")),"./locales/en/admin.json":()=>Promise.resolve().then(()=>require("./admin-DZG3lp_d.js")),"./locales/fr/admin.json":()=>Promise.resolve().then(()=>require("./admin-NyIkvXgM.js")),"./locales/it/admin.json":()=>Promise.resolve().then(()=>require("./admin-CtCAu1C-.js"))}),`./locales/${t}/admin.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/support.json":()=>Promise.resolve().then(()=>require("./support-BU6GoEbW.js")),"./locales/en/support.json":()=>Promise.resolve().then(()=>require("./support-DnSiwJx7.js")),"./locales/fr/support.json":()=>Promise.resolve().then(()=>require("./support-B0kcB-tL.js")),"./locales/it/support.json":()=>Promise.resolve().then(()=>require("./support-Cm84X3pP.js"))}),`./locales/${t}/support.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs.json":()=>Promise.resolve().then(()=>require("./docs-sqOeJ3Lg.js")),"./locales/en/docs.json":()=>Promise.resolve().then(()=>require("./docs-BR4q7sou.js")),"./locales/fr/docs.json":()=>Promise.resolve().then(()=>require("./docs-CDz8QplV.js")),"./locales/it/docs.json":()=>Promise.resolve().then(()=>require("./docs-DCOsvfv7.js"))}),`./locales/${t}/docs.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/ai.json":()=>Promise.resolve().then(()=>require("./ai-BGanmkGz.js")),"./locales/en/ai.json":()=>Promise.resolve().then(()=>require("./ai-CnWgG5hN.js")),"./locales/fr/ai.json":()=>Promise.resolve().then(()=>require("./ai-wRnnMW5a.js")),"./locales/it/ai.json":()=>Promise.resolve().then(()=>require("./ai-Cgn4sP2c.js"))}),`./locales/${t}/ai.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/communications.json":()=>Promise.resolve().then(()=>require("./communications-DBbKXpf1.js")),"./locales/en/communications.json":()=>Promise.resolve().then(()=>require("./communications-BPsS3Vfm.js")),"./locales/fr/communications.json":()=>Promise.resolve().then(()=>require("./communications-DElJaoVw.js")),"./locales/it/communications.json":()=>Promise.resolve().then(()=>require("./communications-BKaku0MU.js"))}),`./locales/${t}/communications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/entra.json":()=>Promise.resolve().then(()=>require("./entra-BadKCc7Y.js")),"./locales/en/entra.json":()=>Promise.resolve().then(()=>require("./entra-CfLYpxKq.js")),"./locales/fr/entra.json":()=>Promise.resolve().then(()=>require("./entra-Bc0Dwf7d.js")),"./locales/it/entra.json":()=>Promise.resolve().then(()=>require("./entra-DDgx1JoT.js"))}),`./locales/${t}/entra.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/en/structure.json":()=>Promise.resolve().then(()=>require("./structure-BL5cd83u.js")),"./locales/fr/structure.json":()=>Promise.resolve().then(()=>require("./structure-BblXL_QG.js"))}),`./locales/${t}/structure.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-DLJ9mTYQ.js")),"./locales/en/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-pkUX3R0G.js")),"./locales/fr/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-Di_IL1wh.js")),"./locales/it/preferences.json":()=>Promise.resolve().then(()=>require("./preferences-B65OLntJ.js"))}),`./locales/${t}/preferences.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/groups.json":()=>Promise.resolve().then(()=>require("./groups-DGDNx8Hf.js")),"./locales/en/groups.json":()=>Promise.resolve().then(()=>require("./groups-5uqhFMN4.js")),"./locales/fr/groups.json":()=>Promise.resolve().then(()=>require("./groups-Cp2Q-pWt.js")),"./locales/it/groups.json":()=>Promise.resolve().then(()=>require("./groups-cV3gnMYo.js"))}),`./locales/${t}/groups.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/en/ba.json":()=>Promise.resolve().then(()=>require("./ba-9HglDm-t.js")),"./locales/fr/ba.json":()=>Promise.resolve().then(()=>require("./ba-CXlHUyjN.js"))}),`./locales/${t}/ba.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-CsRMxznf.js")),"./locales/en/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-BUnDEWjL.js")),"./locales/fr/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-DRITa5fK.js")),"./locales/it/docs-administration-users.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-qLwE7c_z.js"))}),`./locales/${t}/docs-administration-users.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BHJfnRA-.js")),"./locales/en/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-CXsWrgCA.js")),"./locales/fr/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BLmrJB-I.js")),"./locales/it/docs-administration-permissions.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-BmiGStz4.js"))}),`./locales/${t}/docs-administration-permissions.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-Cmjpaxwy.js")),"./locales/en/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-CvYnhoo5.js")),"./locales/fr/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-xhQOAORE.js")),"./locales/it/docs-administration-tenants.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-CuHqwklv.js"))}),`./locales/${t}/docs-administration-tenants.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-CPqGrO8q.js")),"./locales/en/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-EVzVu3kS.js")),"./locales/fr/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-B0zkD6zQ.js")),"./locales/it/docs-administration-ai.json":()=>Promise.resolve().then(()=>require("./docs-administration-ai-DngqfS6k.js"))}),`./locales/${t}/docs-administration-ai.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-DRw16ooP.js")),"./locales/en/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-Da6XQxlv.js")),"./locales/fr/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-CofvuK9f.js")),"./locales/it/docs-administration-workflows.json":()=>Promise.resolve().then(()=>require("./docs-administration-workflows-DW4kFs3z.js"))}),`./locales/${t}/docs-administration-workflows.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-D3hQEI3V.js")),"./locales/en/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-griadux5.js")),"./locales/fr/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-BbS4ZUu7.js")),"./locales/it/docs-administration-entra.json":()=>Promise.resolve().then(()=>require("./docs-administration-entra-D0KuJ7Ps.js"))}),`./locales/${t}/docs-administration-entra.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-C6VsiHxH.js")),"./locales/en/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-DRYyRp3S.js")),"./locales/fr/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-BEepPuXf.js")),"./locales/it/docs-administration-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-applications-BiZBTxgS.js"))}),`./locales/${t}/docs-administration-applications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-BdZl4hL4.js")),"./locales/en/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-DvZxFmnH.js")),"./locales/fr/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-CXro3iiT.js")),"./locales/it/docs-administration-configuration.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-B1YtxR_A.js"))}),`./locales/${t}/docs-administration-configuration.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-DSMqi4PQ.js")),"./locales/en/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-C3rm7u1h.js")),"./locales/fr/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-CJsMRPaR.js")),"./locales/it/docs-administration-configuration-license.json":()=>Promise.resolve().then(()=>require("./docs-administration-configuration-license-_LdQyRjT.js"))}),`./locales/${t}/docs-administration-configuration-license.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-HRqVNkqP.js")),"./locales/en/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-XQ-IiS31.js")),"./locales/fr/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-B3IDsztG.js")),"./locales/it/docs-administration-tenants-template.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-template-DKbpQgBH.js"))}),`./locales/${t}/docs-administration-tenants-template.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-BtAQiVRM.js")),"./locales/en/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-Cs4N4jrq.js")),"./locales/fr/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-XRmC4aRE.js")),"./locales/it/docs-administration-tenants-business.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-business-D1T8STQX.js"))}),`./locales/${t}/docs-administration-tenants-business.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-DHGVmv0D.js")),"./locales/en/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-Bk0D7emY.js")),"./locales/fr/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-DSnrN4MO.js")),"./locales/it/docs-administration-tenants-personal.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-personal-KFjQQGdW.js"))}),`./locales/${t}/docs-administration-tenants-personal.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-B5w2xFPJ.js")),"./locales/en/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-Dh2ohplZ.js")),"./locales/fr/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-WV4RsrVj.js")),"./locales/it/docs-administration-tenants-other.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-other-DeZKiNkH.js"))}),`./locales/${t}/docs-administration-tenants-other.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-BbAfGAzk.js")),"./locales/en/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-cv88prRo.js")),"./locales/fr/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-Clm4Yhy7.js")),"./locales/it/docs-administration-permissions-assignments.json":()=>Promise.resolve().then(()=>require("./docs-administration-permissions-assignments-Xtrdol6a.js"))}),`./locales/${t}/docs-administration-permissions-assignments.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-BXTwlVt_.js")),"./locales/en/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-DxKx9YEc.js")),"./locales/fr/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-DehK43TA.js")),"./locales/it/docs-administration-tenants-applications.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-applications-D2SCJxWE.js"))}),`./locales/${t}/docs-administration-tenants-applications.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-CMJEiBDZ.js")),"./locales/en/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-BDCjPv_a.js")),"./locales/fr/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-DXBq6rZX.js")),"./locales/it/docs-administration-tenants-access-requests.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-access-requests-7mBPVsvv.js"))}),`./locales/${t}/docs-administration-tenants-access-requests.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-DV-_MnD2.js")),"./locales/en/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-BJS2qchs.js")),"./locales/fr/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-DDPYmh_7.js")),"./locales/it/docs-administration-tenants-organisations.json":()=>Promise.resolve().then(()=>require("./docs-administration-tenants-organisations-BWchU3XZ.js"))}),`./locales/${t}/docs-administration-tenants-organisations.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-nvIWiI_l.js")),"./locales/en/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-yc0oKKrD.js")),"./locales/fr/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-jObWdig-.js")),"./locales/it/docs-platform-support-tickets.json":()=>Promise.resolve().then(()=>require("./docs-platform-support-tickets-BtPIdbRr.js"))}),`./locales/${t}/docs-platform-support-tickets.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-D6Oy2YkN.js")),"./locales/en/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-sPBt_1c4.js")),"./locales/fr/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-BVpRmDsI.js")),"./locales/it/docs-administration-users-dashboard.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-dashboard-lQ9K3m9K.js"))}),`./locales/${t}/docs-administration-users-dashboard.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-Du_ykq8Q.js")),"./locales/en/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-CNWOU2Wq.js")),"./locales/fr/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-Dc8nUoSy.js")),"./locales/it/docs-administration-users-references.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-references-C5YUKBpW.js"))}),`./locales/${t}/docs-administration-users-references.json`,4).catch(()=>({default:{}})),ge(Object.assign({"./locales/de/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-WmOKFuUm.js")),"./locales/en/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-C6xh7MWi.js")),"./locales/fr/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-DgWpE7cP.js")),"./locales/it/docs-administration-users-groups.json":()=>Promise.resolve().then(()=>require("./docs-administration-users-groups-7NuH5xFT.js"))}),`./locales/${t}/docs-administration-users-groups.json`,4).catch(()=>({default:{}}))]);return{common:s.default||{},navigation:r.default||{},auth:a.default||{},admin:o.default||{},support:c.default||{},docs:i.default||{},ai:d.default||{},communications:u.default||{},entra:m.default||{},structure:p.default||{},preferences:f.default||{},groups:h.default||{},ba:b.default||{},docsAdministrationUsers:g.default||{},docsAdministrationPermissions:y.default||{},docsAdministrationTenants:x.default||{},docsAdministrationAi:j.default||{},docsAdministrationWorkflows:v.default||{},docsAdministrationEntra:S.default||{},docsAdministrationApplications:N.default||{},docsAdministrationConfiguration:I.default||{},docsAdministrationConfigurationLicense:P.default||{},docsAdministrationTenantsTemplate:k.default||{},docsAdministrationTenantsBusiness:A.default||{},docsAdministrationTenantsPersonal:R.default||{},docsAdministrationTenantsOther:$.default||{},docsAdministrationPermissionsAssignments:q.default||{},docsAdministrationTenantsApplications:C.default||{},docsAdministrationTenantsAccessRequests:D.default||{},docsAdministrationTenantsOrganisations:Y.default||{},docsPlatformSupportTickets:T.default||{},docsAdministrationUsersDashboard:z.default||{},docsAdministrationUsersReferences:Z.default||{},docsAdministrationUsersGroups:H.default||{}}}catch(s){return console.warn(`Failed to load language: ${t}`,s),null}},$n={},Dn=()=>{const t=localStorage.getItem("i18nextLng");if(t&&["en","fr","de","it"].includes(t))return t;const s=navigator.language.split("-")[0];return["en","fr","de","it"].includes(s)?s:"en"},It=Dn();Dt.use(Ya).use(ne.initReactI18next).init({resources:$n,lng:It,fallbackLng:"en",defaultNS:"common",ns:["common","navigation","auth","admin","support","docs","ai","communications","entra","structure","preferences","groups","ba","docsAdministrationUsers","docsAdministrationPermissions","docsAdministrationTenants","docsAdministrationAi","docsAdministrationWorkflows","docsAdministrationEntra","docsAdministrationApplications","docsAdministrationConfiguration","docsAdministrationConfigurationLicense","docsAdministrationTenantsTemplate","docsAdministrationTenantsBusiness","docsAdministrationTenantsPersonal","docsAdministrationTenantsOther","docsAdministrationPermissionsAssignments","docsAdministrationTenantsApplications","docsAdministrationTenantsAccessRequests","docsAdministrationTenantsOrganisations","docsPlatformSupportTickets","docsAdministrationUsersReferences","docsAdministrationUsersGroups"],interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator","htmlTag"],caches:["localStorage"]}});const rs=(t,s)=>{Object.entries(s).forEach(([r,a])=>{Dt.addResourceBundle(t,r,a,!0,!0)})},Mn=(async()=>{const t=[];It!=="en"&&t.push(ss("en").then(s=>{s&&rs("en",s)})),t.push(ss(It).then(s=>{s&&rs(It,s)})),await Promise.all(t)})(),xs=async t=>{if(await Mn,!Dt.hasResourceBundle(t,"common")){const s=await ss(t);s&&rs(t,s)}await Dt.changeLanguage(t)},br=n.createContext(void 0);function On(){if(typeof window>"u")return yt;try{const s=localStorage.getItem(hr);if(s){const r=JSON.parse(s);return{...yt,...r,borderRadius:{...yt.borderRadius,...r.borderRadius},itemPaletteKey:r.itemPaletteKey||ms,colors:{light:mt(r.accentColorKey||"indigo"),dark:pt(r.accentColorKey||"indigo")}}}}catch{}const t=window.matchMedia("(prefers-color-scheme: dark)").matches;return{...yt,mode:t?"dark":"light"}}function Tt(t){const s=t.accentColorKey||"indigo",r=t.borderRadius;return{mode:t.theme||"dark",accentColorKey:s,borderRadius:{card:r?.card||"large",button:r?.button||"medium",badge:r?.badge||"medium",input:r?.input||"medium",modal:r?.modal||"xlarge",menuItem:r?.menuItem||"medium"},itemPaletteKey:t.itemPaletteKey||ms,colors:{light:mt(s),dark:pt(s)}}}function Fn(t){const s=document.documentElement,r=t.mode==="dark"?t.colors.dark:t.colors.light,a=_e[t.accentColorKey]?.shades||_e.indigo.shades,o=ut[t.itemPaletteKey]||ut.neutral,c=t.mode==="dark"?o.colors.dark:o.colors.light;t.mode==="dark"?s.classList.add("dark"):s.classList.remove("dark"),s.style.setProperty("--radius-card",Qe[t.borderRadius.card]),s.style.setProperty("--radius-button",Qe[t.borderRadius.button]),s.style.setProperty("--radius-badge",Qe[t.borderRadius.badge]),s.style.setProperty("--radius-input",Qe[t.borderRadius.input]),s.style.setProperty("--radius-modal",Qe[t.borderRadius.modal]),s.style.setProperty("--radius-menu-item",Qe[t.borderRadius.menuItem]),Object.entries(a).forEach(([i,d])=>{s.style.setProperty(`--color-accent-${i}`,d)}),s.style.setProperty("--item-color-light",c.light),s.style.setProperty("--item-color-medium",c.medium),s.style.setProperty("--item-color-dark",c.dark),s.style.setProperty("--item-color-border",c.border),s.style.setProperty("--bg-app",r.backgrounds.app),s.style.setProperty("--bg-primary",r.backgrounds.primary),s.style.setProperty("--bg-secondary",r.backgrounds.secondary),s.style.setProperty("--bg-tertiary",r.backgrounds.tertiary),s.style.setProperty("--bg-card",r.backgrounds.card),s.style.setProperty("--bg-hover",r.backgrounds.hover),s.style.setProperty("--bg-active",r.backgrounds.active),s.style.setProperty("--text-primary",r.text.primary),s.style.setProperty("--text-secondary",r.text.secondary),s.style.setProperty("--text-tertiary",r.text.tertiary),s.style.setProperty("--text-muted",r.text.muted),s.style.setProperty("--text-inverse",r.text.inverse),s.style.setProperty("--border-color",r.border.default),s.style.setProperty("--border-subtle",r.border.subtle),s.style.setProperty("--border-strong",r.border.strong),s.style.setProperty("--success-bg",r.status.success.bg),s.style.setProperty("--success-text",r.status.success.text),s.style.setProperty("--success-border",r.status.success.border),s.style.setProperty("--success-dot",r.status.success.dot),s.style.setProperty("--warning-bg",r.status.warning.bg),s.style.setProperty("--warning-text",r.status.warning.text),s.style.setProperty("--warning-border",r.status.warning.border),s.style.setProperty("--warning-dot",r.status.warning.dot),s.style.setProperty("--error-bg",r.status.error.bg),s.style.setProperty("--error-text",r.status.error.text),s.style.setProperty("--error-border",r.status.error.border),s.style.setProperty("--error-dot",r.status.error.dot),s.style.setProperty("--info-bg",r.status.info.bg),s.style.setProperty("--info-text",r.status.info.text),s.style.setProperty("--info-border",r.status.info.border),s.style.setProperty("--info-dot",r.status.info.dot),s.style.setProperty("--accent-bg",r.accentTransparent.bg),s.style.setProperty("--accent-text",r.accentTransparent.text),s.style.setProperty("--accent-border",r.accentTransparent.border)}function vr({children:t}){const[s,r]=n.useState(On),[a,o]=n.useState(!1),[c,i]=n.useState(null),[d,u]=n.useState(void 0),[m,p]=n.useState([]),{i18n:f}=ne.useTranslation(),h=n.useRef(null),b=n.useRef(!0),g=n.useRef(!1),y=n.useRef(!1),x=n.useCallback(async(T,z=void 0)=>{if(!localStorage.getItem("token")||y.current)return;let H=null;const J=localStorage.getItem("currentTenantId");if(z===void 0)J?H=J:H=null;else{if(z!==null&&J&&z!==J)return;H=z}try{o(!0),await _t.preferences.updateTheme({mode:T.mode,accentColorKey:T.accentColorKey,borderRadius:{card:T.borderRadius.card,button:T.borderRadius.button,badge:T.borderRadius.badge,input:T.borderRadius.input,modal:T.borderRadius.modal,menuItem:T.borderRadius.menuItem},itemPaletteKey:T.itemPaletteKey,targetTenantId:H}),H&&!m.includes(H)&&p(fe=>[...fe,H])}catch(fe){console.error("[ThemeContext] ❌ Failed to save theme to server:",{error:fe,targetTenantId:H,mode:T.mode,accentColorKey:T.accentColorKey,localStorage_currentTenantId:localStorage.getItem("currentTenantId"),localStorage_currentTenantSlug:localStorage.getItem("currentTenantSlug")})}finally{o(!1)}},[m]),j=n.useCallback((T,z=void 0)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{x(T,z)},1e3)},[x]);n.useLayoutEffect(()=>{Fn(s)},[s]),n.useEffect(()=>{const T={mode:s.mode,borderRadius:s.borderRadius,accentColorKey:s.accentColorKey,itemPaletteKey:s.itemPaletteKey};localStorage.setItem(hr,JSON.stringify(T)),!y.current&&!b.current&&j(s,d),b.current=!1},[s,j,d]),n.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const v=n.useCallback(async T=>{const z=localStorage.getItem("token"),Z=localStorage.getItem("currentTenantSlug");if(!z)return;const H=T==="global";if(!(!H&&!Z))try{o(!0);const J=H?await Ne.preferences.getGlobal():await Ne.preferences.get();i(J.scope);const fe=Tt(J);b.current=!0,r(fe),g.current=!0,J.language&&J.language!==f.language&&(await xs(J.language),document.documentElement.lang=J.language)}catch(J){console.error("[ThemeContext] Failed to load theme from server:",J)}finally{o(!1)}},[f]),S=n.useCallback(async()=>{const T=localStorage.getItem("token"),z=localStorage.getItem("currentTenantSlug");if(!(!T||!z))try{o(!0);const Z=await Ne.preferences.applyToTenant();i(Z.scope)}catch(Z){throw console.error("[ThemeContext] Failed to create tenant-specific preferences:",Z),Z}finally{o(!1)}},[]),N=n.useCallback(async()=>{const T=localStorage.getItem("token"),z=localStorage.getItem("currentTenantSlug");if(!(!T||!z))try{o(!0);const Z=await Ne.preferences.deleteTenantOverride();i(Z.scope);const H=Tt(Z);b.current=!0,r(H)}catch(Z){throw console.error("[ThemeContext] Failed to delete tenant-specific preferences:",Z),Z}finally{o(!1)}},[]),I=n.useCallback(async()=>{if(localStorage.getItem("token"))try{const z=await Ne.preferences.getThemeOverrides();p(z)}catch(z){console.error("[ThemeContext] Failed to load tenant overrides:",z)}},[]),P=n.useCallback(async(T,z=!1)=>{if(h.current&&(clearTimeout(h.current),h.current=null),y.current=!0,g.current=!0,b.current=!0,u(T),z){y.current=!1;return}if(!localStorage.getItem("token")){y.current=!1;return}try{if(o(!0),T===null){const H=await Ne.preferences.getGlobal();i(H.scope);const J=Tt(H);b.current=!0,r(J)}else{const H=await Ne.preferences.getForTenant(T);i(H.scope);const J=Tt(H);b.current=!0,r(J)}}catch(H){console.error("[ThemeContext] Failed to load preferences for tenant:",H)}finally{o(!1),y.current=!1}},[]),k=n.useCallback(()=>{r(T=>({...T,mode:T.mode==="light"?"dark":"light",colors:{light:mt(T.accentColorKey),dark:pt(T.accentColorKey)}}))},[]),A=n.useCallback(T=>{r(z=>({...z,mode:T}))},[]),R=n.useCallback((T,z)=>{r(Z=>({...Z,borderRadius:{...Z.borderRadius,[T]:z}}))},[]),$=n.useCallback(T=>{_e[T]&&r(z=>({...z,accentColorKey:T,colors:{light:mt(T),dark:pt(T)}}))},[]),q=n.useCallback(T=>{ut[T]&&r(z=>({...z,itemPaletteKey:T}))},[]),C=n.useCallback(T=>{r(z=>{const Z=T.accentColorKey||z.accentColorKey;return{...z,...T,borderRadius:{...z.borderRadius,...T.borderRadius},accentColorKey:Z,itemPaletteKey:T.itemPaletteKey||z.itemPaletteKey,colors:{light:mt(Z),dark:pt(Z)}}})},[]),D=n.useCallback(()=>{r(yt)},[]),Y=n.useCallback(T=>Qe[s.borderRadius[T]],[s.borderRadius]);return e.jsx(br.Provider,{value:{config:s,mode:s.mode,toggleMode:k,setMode:A,setBorderRadius:R,setAccentColor:$,setItemPalette:q,applyPreset:C,resetToDefault:D,getBorderRadius:Y,loadFromServer:v,isSyncing:a,scopeInfo:c,applyToTenant:S,resetToGlobal:N,selectedThemeTenant:d,setSelectedThemeTenant:P,tenantOverrides:m,loadTenantOverrides:I},children:t})}function St(){const t=n.useContext(br);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t}let ft=null,at=null;const _n={async getFeatureConfig(t){return ft||at||(at=(async()=>{try{return ft=(await us.get("/api/config/features",{timeout:1e4,signal:t,headers:{"Content-Type":"application/json"}})).data,ft}finally{at=null}})(),at)},clearCache(){ft=null,at=null}},yr=n.createContext(void 0);function qn({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(!0);n.useEffect(()=>{const i=new AbortController;return _n.getFeatureConfig(i.signal).then(d=>{i.signal.aborted||r(d)}).catch(d=>{d.name==="CanceledError"||i.signal.aborted||(console.error("Failed to load feature config:",d),r({multiTenantEnabled:!0,enableB2B:!0,enableB2C:!0,useUrlRouting:!0}))}).finally(()=>{i.signal.aborted||o(!1)}),()=>i.abort()},[]);const c={config:s,isLoading:a,isMultiTenant:!0,isHybridMode:s?.multiTenantEnabled===!0&&s?.enableB2B===!1&&s?.enableB2C===!0,enableB2B:s?.enableB2B??!0,enableB2C:s?.enableB2C??!0,useUrlRouting:s?.useUrlRouting??!0};return e.jsx(yr.Provider,{value:c,children:t})}function qt(){const t=n.useContext(yr);if(!t)throw new Error("useFeatureConfig must be used within FeatureConfigProvider");return t}const jr="*";function Ct(t,s){const r=t.toLowerCase(),a=s.toLowerCase();if(r==="*"||r===a)return!0;if(r.endsWith(".*")){const o=r.slice(0,-2);return a.startsWith(o+".")||a===o}return!1}function Un(t,s){if(t.includes(s))return!0;for(const r of t)if(Ct(r,s))return!0;return!1}function jt(t){return t.includes(jr)}function Nr(t,s){if(!s||jt(t))return!0;const r=s.toLowerCase(),a=r+".";for(const o of t){const c=o.toLowerCase();if(c==="*"||c===r||c.startsWith(a))return!0;if(c.endsWith(".*")){const i=c.slice(0,-1);if(r.startsWith(i)||a.startsWith(i))return!0}}return!1}const hs=n.createContext(void 0),nt="token",ot="user";function wr({children:t}){const[s,r]=n.useState(()=>{if(typeof window<"u"){const m=localStorage.getItem(ot);if(m)try{return JSON.parse(m)}catch{return null}}return null}),[a,o]=n.useState(!0),c=n.useCallback((m,p)=>{localStorage.setItem(nt,m),localStorage.setItem(ot,JSON.stringify(p)),r(p)},[]),i=n.useCallback(async()=>{try{localStorage.getItem(nt)&&await E.post("/api/auth/logout")}catch{}localStorage.removeItem(nt),localStorage.removeItem("refreshToken"),localStorage.removeItem(ot),r(null),window.location.href="/login"},[]),d=n.useCallback(m=>{if(!s)return!1;if(jt(s.permissions)||s.permissions.includes(m))return!0;for(const p of s.permissions)if(Ct(p,m))return!0;return!1},[s]),u=n.useCallback(async()=>{if(localStorage.getItem(nt))try{const p=await E.get("/api/auth/me");r(p),localStorage.setItem(ot,JSON.stringify(p))}catch(p){console.error("Failed to refresh permissions:",p)}},[]);return n.useEffect(()=>{localStorage.getItem(nt)&&!s?E.get("/api/auth/me").then(p=>{r(p),localStorage.setItem(ot,JSON.stringify(p))}).catch(()=>{localStorage.removeItem(nt),localStorage.removeItem("refreshToken"),localStorage.removeItem(ot)}).finally(()=>o(!1)):o(!1)},[s]),e.jsx(hs.Provider,{value:{user:s,isAuthenticated:!!s,isLoading:a,login:c,logout:i,hasPermission:d,refreshPermissions:u},children:t})}function Pe(){const t=n.useContext(hs);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}function zn(){return n.useContext(hs)??null}function Sr(t){return t.includes("*")}const Cr=n.createContext(void 0);function kr({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(null),[c,i]=n.useState(!0),[d,u]=n.useState(null),m=n.useRef(null),p=n.useCallback(async g=>{try{i(!0),u(null);const[y,x]=await Promise.all([E.get("/api/administration/license",{signal:g}),E.get("/api/administration/license/usage",{signal:g}).catch(()=>null)]);g?.aborted||(r(y),o(x))}catch(y){if(y instanceof Error&&y.name==="CanceledError"||g?.aborted)return;u(y instanceof Error?y.message:"Failed to load license info"),console.error("Failed to fetch license:",y)}finally{g?.aborted||i(!1)}},[]);n.useEffect(()=>{m.current?.abort();const g=new AbortController;return m.current=g,p(g.signal),()=>g.abort()},[p]);const f=n.useCallback(g=>s?Sr(s.enabledFeatures)?!0:s.enabledFeatures.some(y=>y.toLowerCase()===g.toLowerCase()):!1,[s]),h=n.useCallback(async()=>{m.current?.abort();const g=new AbortController;m.current=g,await p(g.signal)},[p]),b=n.useCallback(async(g,y)=>{try{const x=await E.post("/api/administration/license/activate",{licenseKey:g,apiKey:y||null});return x.success?(await h(),{success:!0}):{success:!1,error:x.errorMessage||"Activation failed"}}catch(x){return{success:!1,error:x instanceof Error?x.message:"Activation failed"}}},[h]);return e.jsx(Cr.Provider,{value:{license:s,usage:a,isLoading:c,error:d,isFeatureEnabled:f,isReadOnlyMode:s?.isReadOnlyMode??!1,refreshLicense:h,activateLicense:b},children:t})}function He(){const t=n.useContext(Cr);if(t===void 0)throw new Error("useLicense must be used within a LicenseProvider");return t}const Ar=n.createContext(void 0),Xe="currentTenantId",Ye="currentTenantSlug",Be="isGlobalView";function Bn({children:t}){const{isAuthenticated:s,user:r,refreshPermissions:a}=Pe(),{isLoading:o}=qt(),[c,i]=n.useState(null),[d,u]=n.useState([]),[m,p]=n.useState(!0),[f,h]=n.useState(null),[b,g]=n.useState(()=>localStorage.getItem(Be)==="true"),y=n.useRef(!1),x=n.useRef(""),j=d.filter(C=>C.type==="Business"),v=d.find(C=>C.type==="Personal")||null,S=n.useCallback((C,D)=>{if(u(C),C.length===0){i(null),g(!1),localStorage.removeItem(Xe),localStorage.removeItem(Ye),localStorage.removeItem(Be),p(!1);return}const Y=localStorage.getItem(Xe),T=Y?C.find(J=>J.id===Y):null;if(T?.status==="Active"){i(T),g(!1),localStorage.setItem(Xe,T.id),localStorage.setItem(Ye,T.slug),localStorage.removeItem(Be),p(!1);return}if(localStorage.getItem(Be)==="true"){g(!0),i(null),p(!1);return}const Z=C.find(J=>J.isDefault&&J.status==="Active");if(Z){i(Z),g(!1),localStorage.setItem(Xe,Z.id),localStorage.setItem(Ye,Z.slug),localStorage.removeItem(Be),p(!1);return}if(D){g(!0),i(null),localStorage.setItem(Be,"true"),p(!1);return}const H=C.find(J=>J.status==="Active");i(H||null),H&&(localStorage.setItem(Xe,H.id),localStorage.setItem(Ye,H.slug)),p(!1)},[]),N=n.useCallback(async C=>{const D=d.find(Y=>Y.id===C);if(!D)throw new Error("Tenant not found");if(D.status!=="Active")throw new Error("Cannot switch to inactive tenant");g(!1),localStorage.removeItem(Be),i(D),localStorage.setItem(Xe,C),localStorage.setItem(Ye,D.slug),await a()},[d,a]),I=n.useCallback(async()=>{g(!0),localStorage.setItem(Be,"true"),i(null),localStorage.removeItem(Xe),localStorage.removeItem(Ye),await a()},[a]),P=n.useCallback(async()=>{g(!1),localStorage.removeItem(Be);const C=d.find(T=>T.isDefault&&T.status==="Active"),D=d.find(T=>T.status==="Active"),Y=C||D||null;Y&&(i(Y),localStorage.setItem(Xe,Y.id),localStorage.setItem(Ye,Y.slug)),await a()},[d,a]),k=n.useCallback(async C=>{try{await Ne.myTenants.setDefault(C),u(D=>D.map(T=>({...T,isDefault:T.id===C}))),await N(C)}catch(D){throw console.error("[TenantContext] Failed to set default tenant:",D),D}},[N]),A=n.useCallback(async()=>{try{await Ne.myTenants.clearDefault(),u(C=>C.map(D=>({...D,isDefault:!1}))),await I()}catch(C){throw console.error("[TenantContext] Failed to clear default tenant:",C),C}},[I]),R=n.useCallback(async()=>{p(!0),h(null);try{await a()}catch(C){console.error("Failed to refresh tenants:",C),h("Failed to refresh tenants")}finally{p(!1)}},[a]);n.useEffect(()=>{if(!s||!r){y.current&&(u([]),i(null),p(!1),y.current=!1,x.current="");return}const C=r.tenants||[],D=C.map(Y=>`${Y.id}:${Y.status}:${Y.isDefault}`).sort((Y,T)=>Y.localeCompare(T)).join(",");if(!y.current||D!==x.current){y.current=!0,x.current=D;const Y=jt(r.permissions||[]);S(C,Y),localStorage.getItem(Ye)&&a().catch(z=>console.error("[TenantContext] Failed to refresh permissions after tenant init:",z))}},[s,r,S,a]),n.useEffect(()=>{s||(i(null),u([]),g(!1),localStorage.removeItem(Xe),localStorage.removeItem(Ye),localStorage.removeItem(Be))},[s]);const $=r?jt(r.permissions||[]):!1,q={currentTenant:c,userTenants:d,b2bTenants:j,personalTenant:v,isLoading:m||o,error:f,switchTenant:N,setDefaultTenant:k,clearDefaultTenant:A,refreshTenants:R,hasMultipleTenants:d.filter(C=>C.status==="Active").length>1,isCurrentTenantOwner:c?.isOwner??!1,hasGlobalRoles:$,isGlobalView:b,enterGlobalView:I,exitGlobalView:P};return e.jsx(Ar.Provider,{value:q,children:t})}function Ee(){const t=n.useContext(Ar);if(t===void 0)throw new Error("useTenant must be used within a TenantProvider");return t}const Rt=5,Pr=n.createContext(null);function Tr({children:t}){const{i18n:s}=ne.useTranslation(),{isAuthenticated:r}=Pe(),{currentTenant:a,isLoading:o}=Ee(),[c,i]=n.useState([]),[d,u]=n.useState(!1),[m,p]=n.useState(null),[f,h]=n.useState(!1),b=n.useCallback(()=>{h(!0)},[]),g=n.useCallback(()=>{h(!1)},[]),y=n.useCallback(async()=>{try{u(!0),p(null);const A=(await E.get("/api/navigation/module-favorites")).map(R=>({id:R.id,code:R.code,label:R.label,icon:R.icon||"Star",route:R.route||"",applicationId:R.applicationId,applicationCode:R.applicationCode,applicationLabel:R.applicationLabel,displayOrder:R.displayOrder}));i(A)}catch(k){console.error("Failed to load favorite modules:",k),p("Erreur lors du chargement des favoris"),i([])}finally{u(!1)}},[]);n.useEffect(()=>{r&&!o?y():r||(i([]),p(null))},[r,o,a,y]),n.useEffect(()=>{const k=()=>{r&&!o&&y()};return s.on("languageChanged",k),()=>{s.off("languageChanged",k)}},[s,r,o,y]);const x=n.useCallback(async k=>{if(c.length>=Rt||c.some(A=>A.id===k.id))return!1;try{return p(null),await E.post(`/api/navigation/module-favorites/${k.id}`),i(A=>[...A,{...k,displayOrder:A.length+1}]),!0}catch(A){return console.error("Failed to add favorite module:",A),await y(),!1}},[c,y]),j=n.useCallback(async k=>{try{return p(null),await E.delete(`/api/navigation/module-favorites/${k}`),i(A=>A.filter(R=>R.id!==k)),!0}catch(A){return console.error("Failed to remove favorite module:",A),await y(),!1}},[y]),v=n.useCallback(k=>c.some(A=>A.id===k),[c]),S=n.useCallback(async k=>v(k.id)?await j(k.id):await x(k),[v,j,x]),N=n.useCallback(async k=>{const A=k.slice(0,Rt),R=A.map(q=>q.id),$=[...c];i(A.map((q,C)=>({...q,displayOrder:C+1})));try{return p(null),await E.put("/api/navigation/module-favorites/reorder",R),!0}catch(q){return console.error("Failed to reorder favorite modules:",q),i($),!1}},[c]),I=c.length<Rt;return e.jsx(Pr.Provider,{value:{favorites:c,loading:d,error:m,addFavorite:x,removeFavorite:j,toggleFavorite:S,isFavorite:v,reorderFavorites:N,canAddMore:I,maxFavorites:Rt,reload:y,expandFavorites:f,triggerExpand:b,clearExpand:g,requiresTenant:!1},children:t})}function Ke(){const t=n.useContext(Pr);if(!t)throw new Error("useFavorites must be used within a FavoritesProvider");return t}const Rr="smartstack-sidebar-collapsed",Er=n.createContext(void 0);function Gn(){if(typeof window>"u")return!1;try{return localStorage.getItem(Rr)==="true"}catch{return!1}}function Ir({children:t}){const[s,r]=n.useState(Gn);n.useEffect(()=>{localStorage.setItem(Rr,String(s))},[s]);const a=n.useCallback(()=>{r(i=>!i)},[]),o=n.useCallback(i=>{r(i)},[]),c=s?64:256;return e.jsx(Er.Provider,{value:{isCollapsed:s,toggleCollapsed:a,setCollapsed:o,sidebarWidth:c},children:t})}function Ut(){const t=n.useContext(Er);if(t===void 0)throw new Error("useSidebar must be used within a SidebarProvider");return t}const Lr=["login","callback","logout","onboarding","system","applications","notifications"],$r=n.createContext(void 0);function Kn(t){let s=t.split("/").filter(Boolean);return s.length>=2&&s[0]==="t"&&(s=s.slice(2)),s.length===0?{app:null,module:null}:Lr.includes(s[0])?{app:null,module:null}:{app:s[0]||null,module:s[1]||null}}function gs({children:t}){const s=w.useLocation(),{i18n:r}=ne.useTranslation(),{currentTenant:a,isLoading:o,isGlobalView:c}=Ee(),[i,d]=n.useState(null),[u,m]=n.useState([]),[p,f]=n.useState(!0),h=n.useRef(!1),b=n.useRef(void 0),g=n.useRef(0),y=c?"global":a?.id??"none";h.current&&y!==b.current&&!p&&f(!0);const{app:x,module:j}=Kn(s.pathname),v=n.useCallback(async()=>{try{const C=await E.get("/api/navigation/menu");d(C)}catch(C){console.error("Failed to fetch menu:",C)}},[]),S=n.useCallback(async()=>{try{const C=await E.get("/api/navigation/favorites");m(C)}catch(C){console.error("Failed to fetch favorites:",C)}},[]),N=n.useCallback(async()=>{const C=++g.current;if(f(!0),await v(),C===g.current){if(a){if(await S(),C!==g.current)return}else m([]);f(!1)}},[v,S,a]);n.useEffect(()=>{const C=localStorage.getItem("token"),D=c?"global":a?.id??"none";if(!(!C||o)){if(!h.current){h.current=!0,b.current=D,N();return}D!==b.current&&(b.current=D,N())}},[a?.id,c,o]),n.useEffect(()=>{const C=()=>{localStorage.getItem("token")&&N()};return r.on("languageChanged",C),()=>{r.off("languageChanged",C)}},[r,N]);const I=n.useCallback(C=>C.startsWith("core_")?C.slice(5):C.startsWith("ext_")?C.slice(4):C,[]),P=n.useCallback((C,D)=>C&&C.split("/").filter(Boolean)[D]||null,[]),k=n.useCallback(()=>i?.applications.find(C=>P(C.route,0)===x||I(C.code)===x),[i,x,P,I]),A=n.useCallback(()=>k()?.modules.find(D=>P(D.route,1)===j||I(D.code)===j),[k,j,P,I]),R=n.useCallback(C=>i?.applications.filter(D=>D.zone===C)||[],[i]),$=n.useCallback(C=>u.some(D=>D.id===C),[u]),q=n.useCallback(async C=>{if(a)try{$(C)?(await E.delete(`/api/navigation/favorites/${C}`),m(D=>D.filter(Y=>Y.id!==C))):(await E.post(`/api/navigation/favorites/${C}`,{}),await S())}catch(D){console.error("Failed to toggle favorite:",D)}},[a,$,S]);return e.jsx($r.Provider,{value:{menu:i,favorites:u,currentAppCode:x,currentModuleCode:j,isLoading:p,getCurrentApplication:k,getCurrentModule:A,getApplicationsByZone:R,getApplicationsForContext:R,toggleFavorite:q,isFavorite:$,refreshMenu:N},children:t})}function Ce(){const t=n.useContext($r);if(t===void 0)throw new Error("useNavigation must be used within a NavigationProvider");return t}const Dr=n.createContext(null);function Mr({children:t}){const{isAuthenticated:s,refreshPermissions:r}=Pe(),{refreshMenu:a}=Ce(),o=n.useRef(null),[c,i]=n.useState(oe.HubConnectionState.Disconnected),d=n.useRef(new Set),u=n.useRef(new Set),m=n.useRef(!1),p=n.useCallback(async()=>{if(!m.current){m.current=!0;try{await Promise.all([r(),a()])}catch(x){console.error("[SignalR] Failed to refresh permissions:",x)}finally{m.current=!1}}},[r,a]),f=n.useCallback(async()=>{const x=localStorage.getItem("token");if(x&&!(o.current?.state===oe.HubConnectionState.Connected||o.current?.state===oe.HubConnectionState.Connecting))try{const j=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>x}).withAutomaticReconnect({nextRetryDelayInMilliseconds:v=>v.previousRetryCount===0?0:v.previousRetryCount===1?2e3:v.previousRetryCount===2?1e4:v.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();j.on("ReceiveNotification",v=>{d.current.forEach(S=>S(v))}),j.on("UnreadCountUpdate",v=>{u.current.forEach(S=>S(v))}),j.on("PermissionsChanged",p),j.onreconnecting(()=>{i(oe.HubConnectionState.Reconnecting)}),j.onreconnected(()=>{i(oe.HubConnectionState.Connected)}),j.onclose(()=>{i(oe.HubConnectionState.Disconnected)}),await j.start(),o.current=j,i(oe.HubConnectionState.Connected)}catch(j){console.error("[SignalR] Failed to connect:",j),i(oe.HubConnectionState.Disconnected)}},[p]),h=n.useCallback(async()=>{if(o.current)try{await o.current.stop(),o.current=null,i(oe.HubConnectionState.Disconnected)}catch(x){console.error("[SignalR] Failed to disconnect:",x)}},[]);n.useEffect(()=>(s?f():h(),()=>{h()}),[s,f,h]);const b=n.useCallback(x=>(d.current.add(x),()=>{d.current.delete(x)}),[]),g=n.useCallback(x=>(u.current.add(x),()=>{u.current.delete(x)}),[]),y={isConnected:c===oe.HubConnectionState.Connected,connectionState:c,onNotification:b,onUnreadCountUpdate:g};return e.jsx(Dr.Provider,{value:y,children:t})}function Or(){const t=n.useContext(Dr);if(!t)throw new Error("useSignalRContext must be used within a SignalRProvider");return t}const Mt={register:async t=>E.post("/api/auth/register",t),confirmEmail:async t=>E.post("/api/auth/confirm-email",{token:t}),resendConfirmation:async t=>E.post("/api/auth/resend-confirmation",{email:t}),forgotPassword:async t=>E.post("/api/auth/forgot-password",{email:t}),resetPassword:async(t,s)=>E.post("/api/auth/reset-password",{token:t,newPassword:s}),login:async(t,s)=>{const r=await E.post("/api/auth/login",{email:t,password:s});return r.token&&(localStorage.setItem("token",r.token),localStorage.setItem("refreshToken",r.refreshToken)),r},logout:async()=>{try{await E.post("/api/auth/logout")}finally{localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user")}},changePassword:async(t,s)=>E.post("/api/auth/change-password",{currentPassword:t,newPassword:s}),refreshSession:async()=>{const t=await E.post("/api/auth/refresh");return t.token&&(localStorage.setItem("token",t.token),localStorage.setItem("refreshToken",t.refreshToken)),t},getSessionInfo:async t=>E.get("/api/auth/session-info",{signal:t?.signal})};function Fr(t={}){const{checkIntervalMs:s=6e4,onSessionExpired:r,onWarningThreshold:a,enabled:o=!0}=t,[c,i]=n.useState({isActive:!0,timeRemainingSeconds:0,isWarning:!1,sessionInfo:null}),[d,u]=n.useState(!1),m=n.useRef(!1),p=n.useRef(null),f=n.useRef(null),h=n.useCallback(async g=>{if(!o)return;if(!localStorage.getItem("token")){i(x=>({...x,isActive:!1}));return}try{const x=await Mt.getSessionInfo({signal:g});if(g?.aborted)return;const j=Math.min(x.timeUntilIdleExpirySeconds,x.timeUntilAbsoluteExpirySeconds);i({isActive:!0,timeRemainingSeconds:j,isWarning:x.isWarningThreshold,sessionInfo:x}),x.isWarningThreshold&&!m.current&&(m.current=!0,a?.()),x.isWarningThreshold||(m.current=!1)}catch(x){if(x instanceof Error&&x.name==="CanceledError"||g?.aborted)return;i(j=>({...j,isActive:!1})),r?.()}},[o,r,a]),b=n.useCallback(async()=>{if(d)return!1;u(!0);try{return await Mt.refreshSession(),m.current=!1,await h(),!0}catch{return i(g=>({...g,isActive:!1})),!1}finally{u(!1)}},[d,h]);return n.useEffect(()=>{if(!o)return;f.current?.abort();const g=new AbortController;return f.current=g,h(g.signal),p.current=setInterval(()=>h(),s),()=>{g.abort(),p.current&&clearInterval(p.current)}},[o,s,h]),n.useEffect(()=>{if(!o)return;const g=()=>{c.isWarning&&h()},y=["mousedown","keydown","touchstart","scroll"];return y.forEach(x=>{window.addEventListener(x,g,{passive:!0})}),()=>{y.forEach(x=>{window.removeEventListener(x,g)})}},[o,c.isWarning,h]),{...c,isRefreshing:d,refreshSession:b,checkSession:h}}function Hn(t){if(t<=0)return"0:00";const s=Math.floor(t/60),r=t%60;if(s>=60){const a=Math.floor(s/60),o=s%60;return`${a}h ${o}min`}return`${s}:${r.toString().padStart(2,"0")}`}function _r({isOpen:t,timeRemainingSeconds:s,onExtendSession:r,onLogout:a}){const{t:o}=ne.useTranslation("common"),[c,i]=n.useState(!1),[d,u]=n.useState(s);n.useEffect(()=>{u(s)},[s]),n.useEffect(()=>{if(!t||d<=0)return;const f=setInterval(()=>{u(h=>h<=1?(a(),0):h-1)},1e3);return()=>clearInterval(f)},[t,d,a]);const m=async()=>{i(!0);try{await r()||a()}finally{i(!1)}};if(!t)return null;const p=Math.max(0,Math.min(100,d/300*100));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-md bg-[var(--bg-card)] rounded-2xl shadow-2xl border border-amber-500/30 overflow-hidden animate-in fade-in zoom-in duration-200",children:[e.jsx("div",{className:"absolute top-0 left-0 h-1 bg-amber-500/30 w-full",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-amber-500 to-orange-500 transition-all duration-1000 ease-linear",style:{width:`${p}%`}})}),e.jsxs("div",{className:"p-6 pt-8",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-amber-500/20 flex items-center justify-center mb-4",children:e.jsx(l.Clock,{className:"w-8 h-8 text-amber-500"})}),e.jsx("h2",{className:"text-xl font-semibold text-[var(--text-primary)] mb-2",children:o("session.warningTitle","Session Expiring")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:o("session.warningMessage","Your session will expire due to inactivity.")}),e.jsx("div",{className:"text-4xl font-mono font-bold text-amber-500 tabular-nums",children:Hn(d)}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-2",children:o("session.remainingTime","remaining")})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("button",{onClick:a,className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 rounded-xl border border-[var(--border-color)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-all font-medium",children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),o("session.logout","Logout")]}),e.jsxs("button",{onClick:m,disabled:c,className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 rounded-xl font-medium transition-all bg-gradient-to-r from-amber-500 to-orange-500 text-white hover:from-amber-600 hover:to-orange-600 shadow-lg shadow-amber-500/30 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(l.RefreshCw,{className:`w-4 h-4 ${c?"animate-spin":""}`}),c?o("session.extending","Extending..."):o("session.extend","Continue Session")]})]})]})]})})}const Vn=n.createContext(void 0);function qr({children:t}){const{isAuthenticated:s,logout:r}=Pe(),a=n.useCallback(()=>{localStorage.removeItem("token"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user"),window.location.href="/login?reason=session_expired"},[]),{isActive:o,timeRemainingSeconds:c,isWarning:i,refreshSession:d}=Fr({enabled:s,checkIntervalMs:3e4,onSessionExpired:a}),u=n.useCallback(async()=>{try{await Mt.logout()}finally{r()}},[r]),m=n.useCallback(async()=>await d(),[d]);return e.jsxs(Vn.Provider,{value:{isSessionActive:o,timeRemainingSeconds:c,isWarning:i,refreshSession:d},children:[t,e.jsx(_r,{isOpen:i&&s,timeRemainingSeconds:c,onExtendSession:m,onLogout:u})]})}const Wn=150;function Xn({children:t}){const s=zn(),r=s?.isAuthenticated??!1,a=s?.isLoading??!0,{currentTenant:o,isLoading:c,isGlobalView:i}=Ee(),{setSelectedThemeTenant:d,loadFromServer:u}=St(),m=n.useRef(null),p=n.useRef(!1),f=n.useRef(null),h=n.useRef(null),b=n.useCallback(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),g=n.useCallback(()=>m.current==="global"?!1:(b(),h.current=null,m.current="global",p.current=!0,u("global"),d(null,!0),!0),[b,u,d]),y=n.useCallback((v,S)=>{h.current=v,f.current=setTimeout(()=>{h.current===v&&(m.current=v,p.current=!0,h.current=null,d(v,!1)),f.current=null},Wn)},[d]),x=n.useCallback(()=>{if(!o)return;const v=o.id!==m.current,S=h.current!==null&&h.current!==o.id;!v&&!S||(b(),v?y(o.id,o.slug):h.current=null)},[o,b,y]),j=n.useCallback(()=>{b(),m.current=null,h.current=null,p.current=!1},[b]);return n.useEffect(()=>{if(!r){j();return}if(!(a||c)){if(i&&!o){g();return}o&&x()}},[r,a,c,o,i,g,x,j]),n.useEffect(()=>()=>{b()},[b]),e.jsx(e.Fragment,{children:t})}function Yn(t){const s=t.message.toLowerCase(),r=t.name.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("failed to fetch")||s.includes("econnrefused")||s.includes("timeout")?"network":s.includes("401")||s.includes("403")||s.includes("unauthorized")||s.includes("forbidden")||s.includes("permission")?"permission":s.includes("404")||s.includes("not found")?"notFound":r.includes("validation")||s.includes("validation")||s.includes("invalid")?"validation":"technical"}function Jn(){const t=Date.now().toString(36),s=Math.random().toString(36).substring(2,6);return`ERR-${t}-${s}`.toUpperCase()}const Qn={network:{icon:l.WifiOff,color:"text-orange-500",bgColor:"bg-orange-500/10"},permission:{icon:l.ShieldX,color:"text-red-500",bgColor:"bg-red-500/10"},notFound:{icon:l.FileWarning,color:"text-yellow-500",bgColor:"bg-yellow-500/10"},validation:{icon:l.AlertTriangle,color:"text-amber-500",bgColor:"bg-amber-500/10"},technical:{icon:l.Bug,color:"text-red-500",bgColor:"bg-red-500/10"}};function Ur({error:t,resetErrorBoundary:s}){const{t:r}=ne.useTranslation("common"),[a,o]=n.useState(!1),[c]=n.useState(()=>Jn()),i=Yn(t),d=Qn[i],u=d.icon,m=()=>{window.history.length>2&&document.referrer?window.location.href=document.referrer:window.history.length>2?(window.history.back(),setTimeout(()=>window.location.reload(),50)):window.location.href="/"};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[var(--bg-primary)] p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`w-16 h-16 rounded-full ${d.bgColor} flex items-center justify-center mb-6`,children:e.jsx(u,{className:`w-8 h-8 ${d.color}`})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:r(`errors.${i}.title`,{defaultValue:r("errors.technical.title")})}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:r(`errors.${i}.description`,{defaultValue:r("errors.technical.description")})}),e.jsxs("div",{className:"mb-6 px-3 py-1.5 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[r("errors.errorId"),": "]}),e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:c})]}),!1,e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("button",{onClick:s,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),r("errors.retry")]}),e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),r("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),r("errors.home")]})]}),e.jsxs("p",{className:"mt-6 text-sm text-[var(--text-tertiary)]",children:[r("errors.persistsHelp")," ",e.jsx("a",{href:"mailto:support@atlashub.ch",className:"text-[var(--color-accent-500)] hover:underline",children:r("errors.contactSupport")})]})]})})})}function Zn(t,s){Te.logCritical(t,"GlobalErrorBoundary",{componentStack:s.componentStack})}function eo(){window.location.reload()}function zr({children:t}){return e.jsx(pr.ErrorBoundary,{FallbackComponent:Ur,onError:Zn,onReset:eo,children:t})}const zt=n.createContext(null);function Br(){const t=n.useContext(zt);if(!t)throw new Error("useSlotFill must be used within a SlotFillProvider");return t}function Gr({children:t,initialFills:s}){const r=n.useMemo(()=>{const o=new Map;return s&&Object.entries(s).forEach(([c,i])=>{const d=o.get(c)||[];Array.isArray(i)?o.set(c,[...d,...i]):o.set(c,[...d,i])}),o},[s]),a=n.useMemo(()=>({fills:r,registerFill:(o,c)=>{const i=r.get(o)||[];r.set(o,[...i,c])},unregisterFill:(o,c)=>{const i=r.get(o)||[];r.set(o,i.filter(d=>d!==c))},getSlotContent:o=>r.get(o)||[]}),[r]);return e.jsx(zt.Provider,{value:a,children:t})}function Kr({name:t,context:s={},children:r,fallback:a,wrapper:o}){const i=n.useContext(zt)?.getSlotContent(t)||[],d=n.useMemo(()=>({slotName:t,context:s}),[t,s]),u=n.useMemo(()=>i.length===0?a||null:i.map((p,f)=>{const h=`${t}-${f}`;return e.jsx(n.Fragment,{children:Vr(p,d)},h)}),[i,t,d,a]),m=e.jsxs(e.Fragment,{children:[u,r]});return o?e.jsx(o,{children:m}):e.jsx(e.Fragment,{children:m})}function Hr({slot:t,children:s}){const{registerFill:r,unregisterFill:a}=Br();return n.useMemo(()=>(r(t,s),()=>a(t,s)),[t,s,r,a]),null}function Vr(t,s){if(t==null)return null;if(Array.isArray(t))return e.jsx(e.Fragment,{children:t.map((r,a)=>e.jsx(n.Fragment,{children:Vr(r,s)},`slot-item-${a}`))});if(n.isValidElement(t))return t;if(typeof t=="function"){const r=t;return e.jsx(r,{...s})}return t}function to(t){return(n.useContext(zt)?.getSlotContent(t)?.length||0)>0}function so(t){function s(a){return e.jsx(Kr,{...a,name:t})}s.displayName=`Slot(${t})`;function r({children:a}){return e.jsx(Hr,{slot:t,children:a})}return r.displayName=`Fill(${t})`,{Slot:s,Fill:r,slotName:t}}const Wr=n.createContext(null);function kt(){const t=n.useContext(Wr);return t||{config:{},getPage:()=>{},getSlotContent:()=>{},getTableColumns:()=>[],getFormFields:()=>[],hasExtension:()=>!1}}function Bt(t){const{getPage:s}=kt();return s(t)}function ro(t){const{getTableColumns:s}=kt();return s(t)}function ao(t){const{getFormFields:s}=kt();return s(t)}function no(t){const{hasExtension:s}=kt();return s(t)}function Xr({config:t={},children:s}){const r=n.useMemo(()=>{const{pages:a={},slots:o={},tableColumns:c={},formFields:i={}}=t;return{config:t,getPage:d=>a[d],getSlotContent:d=>o[d],getTableColumns:d=>c[d]||[],getFormFields:d=>i[d]||[],hasExtension:d=>d in a||d in o||d in c||d in i}},[t]);return e.jsx(Wr.Provider,{value:r,children:e.jsx(Gr,{initialFills:t.slots,children:s})})}class oo{pages=new Map;register(s,r,a=[]){this.pages.set(s,{key:s,defaultComponent:r,slots:a})}get(s){return this.pages.get(s)}resolve(s){return this.pages.get(s)?.defaultComponent}getAll(){return Array.from(this.pages.values())}has(s){return this.pages.has(s)}getSlots(s){return this.pages.get(s)?.slots||[]}keys(){return Array.from(this.pages.keys())}}const O=new oo;function io(t,s){function r(a){const o=Bt(t);return o?e.jsx(o,{...a}):e.jsx(s,{...a})}return r.displayName=`Overridable(${t})`,r}function lo(t){const s=Bt(t),r=O.get(t);return s||r?.defaultComponent}function co({pageKey:t,defaultComponent:s,params:r}){const a=Bt(t),o={pageKey:t,params:r};return a?e.jsx(a,{...o}):e.jsx(s,{...o})}const _={ADMIN_INDEX:"administration",ADMIN_DASHBOARD:"administration.dashboard",USERS_LIST:"administration.users.list",USERS_DETAIL:"administration.users.detail",USERS_DASHBOARD:"administration.users.dashboard",USERS_GROUPS:"administration.users.groups",USERS_GROUPS_DETAIL:"administration.users.groups.detail",USERS_REFERENCES:"administration.users.references",ROLES_LIST:"administration.permissions.roles",ROLES_DETAIL:"administration.permissions.roles.detail",PERMISSIONS_LIST:"administration.permissions.permissions",PERMISSIONS_DETAIL:"administration.permissions.permissions.detail",ASSIGNMENTS:"administration.permissions.assignments",APPLICATIONS_INDEX:"administration.applications",APPLICATIONS_DASHBOARD:"administration.applications.dashboard",APPLICATIONS_LIST:"administration.applications.list",APPLICATIONS_DETAIL:"administration.applications.detail",AI_DASHBOARD:"administration.ai.dashboard",AI_SETTINGS:"administration.ai.settings",AI_SKILLS_LIST:"administration.ai.skills",AI_SKILLS_DETAIL:"administration.ai.skills.detail",AI_SKILLS_CREATE:"administration.ai.skills.create",AI_SKILLS_EDIT:"administration.ai.skills.edit",AI_BLOCKS_LIST:"administration.ai.skills.blocks",AI_BLOCKS_DETAIL:"administration.ai.skills.blocks.detail",AI_BLOCKS_CREATE:"administration.ai.skills.blocks.create",AI_BLOCKS_EDIT:"administration.ai.skills.blocks.edit",AI_MONITORING:"administration.ai.monitoring",AI_AGENTS:"administration.ai.agents",AI_AGENTS_DETAIL:"administration.ai.agents.detail",AI_AGENTS_EDIT:"administration.ai.agents.edit",WORKFLOWS_LIST:"administration.workflows.list",WORKFLOWS_DETAIL:"administration.workflows.detail",WORKFLOWS_CREATE:"administration.workflows.create",WORKFLOWS_EDIT:"administration.workflows.edit",WORKFLOWS_TRIGGERS:"administration.workflows.triggers",WORKFLOWS_HISTORY:"administration.workflows.history",EMAIL_TEMPLATES_LIST:"administration.workflows.email-templates",EMAIL_TEMPLATES_DETAIL:"administration.workflows.email-templates.detail",EMAIL_TEMPLATES_CREATE:"administration.workflows.email-templates.create",EMAIL_TEMPLATES_EDIT:"administration.workflows.email-templates.edit",SMS_TEMPLATES_LIST:"administration.workflows.email-templates.sms",ENTRA_DASHBOARD:"administration.entra.dashboard",ENTRA_GROUPS:"administration.entra.groups",ENTRA_USERS:"administration.entra.users",ENTRA_CONFLICTS:"administration.entra.conflicts",ENTRA_SETTINGS:"administration.entra.settings",TENANTS_DASHBOARD:"administration.tenants.dashboard",TENANTS_LIST:"administration.tenants.list",TENANTS_DETAIL:"administration.tenants.detail",TENANTS_CREATE:"administration.tenants.create",TENANTS_SETTINGS:"administration.tenants.settings",TENANTS_TYPE_SETTINGS:"administration.tenants.type-settings",TENANTS_TEMPLATE:"administration.tenants.template",TENANTS_TEMPLATE_CREATE:"administration.tenants.template.create",TENANTS_TEMPLATE_DETAIL:"administration.tenants.template.detail",TENANTS_BUSINESS:"administration.tenants.list.enterprise",TENANTS_PERSONAL:"administration.tenants.list.personal",TENANTS_OTHER:"administration.tenants.list.other",TENANTS_ACCESS_REQUESTS:"administration.tenants.access-requests",ORGANISATIONS_LIST:"administration.tenants.organisations",ORGANISATIONS_CREATE:"administration.tenants.organisations.create",ORGANISATIONS_DETAIL:"administration.tenants.organisations.detail",SETTINGS:"administration.configuration.settings",SETTINGS_GENERAL:"administration.configuration.settings.general",SETTINGS_FILE_UPLOAD:"administration.configuration.settings.file-upload",SETTINGS_LEGAL_FILE:"administration.configuration.settings.legal-file",APPSETTINGS:"administration.configuration.appsettings",APPSETTINGS_INFRASTRUCTURE:"administration.configuration.appsettings.infrastructure",APPSETTINGS_AUTHENTICATION:"administration.configuration.appsettings.authentication",APPSETTINGS_LOGGING:"administration.configuration.appsettings.logging",APPSETTINGS_EMAIL:"administration.configuration.appsettings.email",APPSETTINGS_ENTRA:"administration.configuration.appsettings.entra",LICENSE:"administration.configuration.license",API_ACCOUNTS_LIST:"api.accounts.list",API_ACCOUNTS_CREATE:"api.accounts.create",API_ACCOUNTS_DETAIL:"api.accounts.detail",API_CATALOG:"api.apis.catalog",API_CATALOG_DETAIL:"api.apis.catalog.detail",SUPPORT_DASHBOARD:"support.tickets",TICKETS_LIST:"support.tickets.list",TICKETS_DETAIL:"support.tickets.detail",TICKETS_ESCALATION:"support.tickets.escalation",TICKETS_NEW:"support.tickets.new",MY_TICKETS_LIST:"support.my-tickets",MY_TICKETS_DETAIL:"support.my-tickets.detail",MY_TICKETS_CREATE:"support.my-tickets.create",SUPPORT_SLA:"support.admin.sla",SUPPORT_TEMPLATES:"support.admin.templates",SUPPORT_PERMISSIONS:"support.admin.permissions",SUPPORT_ASSIGNMENT:"support.assignment",SUPPORT_ASSIGNMENT_SKILLS:"support.assignment.skills",SUPPORT_ASSIGNMENT_WORKLOAD:"support.assignment.workload",MYSPACE_DASHBOARD:"myspace.dashboard",USER_PROFILE:"myspace.profile",USER_PREFERENCES:"myspace.preferences",MYSPACE_TENANTS:"myspace.tenants.workspaces",MYSPACE_ACCESS_REQUESTS:"myspace.tenants.access-requests",MYSPACE_PORTAL:"myspace.portal",NOTIFICATIONS:"notifications",APPLICATIONS_HUB:"applications"};O.register(_.ADMIN_INDEX,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsGridPage-DV-FihKj.js")).then(t=>({default:t.ApplicationsGridPage}))));O.register(_.ADMIN_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-CfKZHiSj.js")).then(t=>({default:t.AdminDashboardPage}))));O.register(_.USERS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./UsersPage-CXC9Hvq6.js")).then(t=>({default:t.UsersPage}))));O.register(_.USERS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./UserDetailPage-_J6lcKAU.js")).then(t=>({default:t.UserDetailPage}))));O.register(_.USERS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-CfKZHiSj.js")).then(t=>({default:t.AdminDashboardPage}))));O.register(_.USERS_GROUPS,n.lazy(()=>Promise.resolve().then(()=>require("./UsersGroupsPage-Dq3rAteo.js")).then(t=>({default:t.UsersGroupsPage}))));O.register(_.USERS_GROUPS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./GroupDetailPage-R-hf3rJ7.js")).then(t=>({default:t.GroupDetailPage}))));O.register(_.USERS_REFERENCES,n.lazy(()=>Promise.resolve().then(()=>require("./ReferencesManagementPage-ZCuYtqd7.js")).then(t=>({default:t.ReferencesManagementPage}))));O.register(_.ROLES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./RolesPage-B9rRzciI.js")).then(t=>({default:t.RolesPage}))));O.register(_.ROLES_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./RoleDetailPage-JTm5lD1_.js")).then(t=>({default:t.RoleDetailPage}))));O.register(_.PERMISSIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./PermissionsPage-COI5LJPo.js")).then(t=>({default:t.PermissionsPage}))));O.register(_.PERMISSIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./PermissionDetailPage-C5K17ydY.js")).then(t=>({default:t.PermissionDetailPage}))));O.register(_.ASSIGNMENTS,n.lazy(()=>Promise.resolve().then(()=>require("./AssignmentsPage-Cww2ifZF.js")).then(t=>({default:t.AssignmentsPage}))));O.register(_.APPLICATIONS_INDEX,n.lazy(()=>Promise.resolve().then(()=>require("./NavigationAppsPage-THNPOAjv.js")).then(t=>({default:t.NavigationAppsPage}))));O.register(_.APPLICATIONS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsDashboardPage-B2MW8-Kc.js")).then(t=>({default:t.ApplicationsDashboardPage}))));O.register(_.APPLICATIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsListPage--CGkyBuJ.js")).then(t=>({default:t.ApplicationsListPage}))));O.register(_.APPLICATIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationDetailPage-Caizuyn2.js"))));O.register(_.AI_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiDashboardPage}))));O.register(_.AI_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiSettingsPage}))));O.register(_.AI_SKILLS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiSkillsListPage}))));O.register(_.AI_SKILLS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiSkillsDetailPage}))));O.register(_.AI_SKILLS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiSkillsEditPage}))));O.register(_.AI_SKILLS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiSkillsEditPage}))));O.register(_.AI_BLOCKS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiBlockDefinitionsListPage}))));O.register(_.AI_BLOCKS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiBlockDefinitionDetailPage}))));O.register(_.AI_BLOCKS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiBlockDefinitionEditPage}))));O.register(_.AI_BLOCKS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiBlockDefinitionEditPage}))));O.register(_.AI_MONITORING,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiMonitoringPage}))));O.register(_.AI_AGENTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiAgentsPage}))));O.register(_.AI_AGENTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiAgentDetailPage}))));O.register(_.AI_AGENTS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-CgpRo8Oe.js")).then(t=>({default:t.AiAgentEditPage}))));O.register(_.WORKFLOWS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.WorkflowsListPage}))));O.register(_.WORKFLOWS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.WorkflowDetailPage}))));O.register(_.WORKFLOWS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.WorkflowCreatePage}))));O.register(_.WORKFLOWS_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.WorkflowEditPage}))));O.register(_.WORKFLOWS_TRIGGERS,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.WorkflowsTriggersPage}))));O.register(_.WORKFLOWS_HISTORY,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.WorkflowHistoryPage}))));O.register(_.EMAIL_TEMPLATES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.EmailTemplatesListPage}))));O.register(_.EMAIL_TEMPLATES_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.EmailTemplateDetailPage}))));O.register(_.EMAIL_TEMPLATES_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.EmailTemplateCreatePage}))));O.register(_.EMAIL_TEMPLATES_EDIT,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.EmailTemplateEditPage}))));O.register(_.SMS_TEMPLATES_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-Buhqag3v.js")).then(t=>({default:t.SmsTemplatesListPage}))));O.register(_.ENTRA_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-DzedSLdI.js")).then(t=>({default:t.EntraDashboardPage}))));O.register(_.ENTRA_GROUPS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DzedSLdI.js")).then(t=>({default:t.EntraGroupsPage}))));O.register(_.ENTRA_USERS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DzedSLdI.js")).then(t=>({default:t.EntraUsersPage}))));O.register(_.ENTRA_CONFLICTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DzedSLdI.js")).then(t=>({default:t.EntraConflictsPage}))));O.register(_.ENTRA_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-DzedSLdI.js")).then(t=>({default:t.EntraSettingsPage}))));O.register(_.TENANTS_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantsDashboardPage}))));O.register(_.TENANTS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantsPage}))));O.register(_.TENANTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantDetailPage}))));O.register(_.TENANTS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantCreatePage}))));O.register(_.TENANTS_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantSettingsPage}))));O.register(_.TENANTS_TYPE_SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantTypeSettingsPage}))));O.register(_.TENANTS_TEMPLATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantsTemplatePage}))));O.register(_.TENANTS_TEMPLATE_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantTemplateCreatePage}))));O.register(_.TENANTS_TEMPLATE_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantTemplateDetailPage}))));O.register(_.TENANTS_BUSINESS,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantsBusinessPage}))));O.register(_.TENANTS_PERSONAL,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantsPersonalPage}))));O.register(_.TENANTS_OTHER,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantsOtherPage}))));O.register(_.TENANTS_ACCESS_REQUESTS,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.TenantAccessRequestsPage}))));O.register(_.ORGANISATIONS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.OrganisationsListPage}))));O.register(_.ORGANISATIONS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.OrganisationCreatePage}))));O.register(_.ORGANISATIONS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-0VrOtwP0.js")).then(t=>({default:t.OrganisationDetailPage}))));O.register(_.SETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index-Betxo5g5.js")).then(t=>({default:t.SettingsPage}))));O.register(_.SETTINGS_GENERAL,n.lazy(()=>Promise.resolve().then(()=>require("./index-Betxo5g5.js")).then(t=>({default:t.GeneralSettingsSection}))));O.register(_.SETTINGS_FILE_UPLOAD,n.lazy(()=>Promise.resolve().then(()=>require("./index-Betxo5g5.js")).then(t=>({default:t.FileUploadSettingsSection}))));O.register(_.SETTINGS_LEGAL_FILE,n.lazy(()=>Promise.resolve().then(()=>require("./index-Betxo5g5.js")).then(t=>({default:t.LegalFileSettingsSection}))));O.register(_.APPSETTINGS,n.lazy(()=>Promise.resolve().then(()=>require("./index--aPwOFjF.js")).then(t=>({default:t.AppSettingsPage}))));O.register(_.APPSETTINGS_INFRASTRUCTURE,n.lazy(()=>Promise.resolve().then(()=>require("./index--aPwOFjF.js")).then(t=>({default:t.InfrastructureSection}))));O.register(_.APPSETTINGS_AUTHENTICATION,n.lazy(()=>Promise.resolve().then(()=>require("./index--aPwOFjF.js")).then(t=>({default:t.AuthenticationSection}))));O.register(_.APPSETTINGS_LOGGING,n.lazy(()=>Promise.resolve().then(()=>require("./index--aPwOFjF.js")).then(t=>({default:t.LoggingSection}))));O.register(_.APPSETTINGS_EMAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index--aPwOFjF.js")).then(t=>({default:t.EmailSection}))));O.register(_.APPSETTINGS_ENTRA,n.lazy(()=>Promise.resolve().then(()=>require("./index--aPwOFjF.js")).then(t=>({default:t.EntraSection}))));O.register(_.LICENSE,n.lazy(()=>Promise.resolve().then(()=>require("./index-DwuvIOrQ.js")).then(t=>({default:t.LicenseManagementPage}))));O.register(_.API_ACCOUNTS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./index-tO6MMIFB.js")).then(t=>({default:t.ExternalAppsListPage}))));O.register(_.API_ACCOUNTS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./index-tO6MMIFB.js")).then(t=>({default:t.ExternalAppCreatePage}))));O.register(_.API_ACCOUNTS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./index-tO6MMIFB.js")).then(t=>({default:t.ExternalAppDetailPage}))));O.register(_.API_CATALOG,n.lazy(()=>Promise.resolve().then(()=>require("./ApiCatalogPage-DRg5Cz0r.js")).then(t=>({default:t.ApiCatalogPage}))));O.register(_.API_CATALOG_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./ApiCatalogDetailPage-MPT3Kz6H.js")).then(t=>({default:t.ApiCatalogDetailPage}))));O.register(_.SUPPORT_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./DashboardPage-CwEZZ3jx.js")).then(t=>({default:t.DashboardPage}))));O.register(_.TICKETS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./TicketsPage-jjyY15_D.js")).then(t=>({default:t.TicketsPage}))));O.register(_.TICKETS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./TicketDetailPage-ieVDRh42.js")).then(t=>({default:t.TicketDetailPage}))));O.register(_.TICKETS_ESCALATION,n.lazy(()=>Promise.resolve().then(()=>require("./EscalationConfigPage--7lgZ0kJ.js")).then(t=>({default:t.EscalationConfigPage}))));O.register(_.TICKETS_NEW,n.lazy(()=>Promise.resolve().then(()=>require("./CreateSupportTicketPage-BWeuV2aU.js")).then(t=>({default:t.CreateSupportTicketPage}))));O.register(_.MY_TICKETS_LIST,n.lazy(()=>Promise.resolve().then(()=>require("./MyTicketsPage--DgDsnZA.js")).then(t=>({default:t.MyTicketsPage}))));O.register(_.MY_TICKETS_DETAIL,n.lazy(()=>Promise.resolve().then(()=>require("./UserTicketDetailPage-CWoYQgH-.js")).then(t=>({default:t.UserTicketDetailPage}))));O.register(_.MY_TICKETS_CREATE,n.lazy(()=>Promise.resolve().then(()=>require("./UserCreateTicketPage-B8Tvf-ag.js")).then(t=>({default:t.UserCreateTicketPage}))));O.register(_.SUPPORT_SLA,n.lazy(()=>Promise.resolve().then(()=>require("./SlaConfigPage-B7kZNig4.js")).then(t=>({default:t.SlaConfigPage}))));O.register(_.SUPPORT_TEMPLATES,n.lazy(()=>Promise.resolve().then(()=>require("./TemplatesPage-DT9fhlAU.js")).then(t=>({default:t.TemplatesPage}))));O.register(_.SUPPORT_PERMISSIONS,n.lazy(()=>Promise.resolve().then(()=>require("./SupportPermissionsPage-Dg_wLOme.js")).then(t=>({default:t.SupportPermissionsPage}))));O.register(_.SUPPORT_ASSIGNMENT,n.lazy(()=>Promise.resolve().then(()=>require("./AssignmentRulesPage-CFffeEbo.js")).then(t=>({default:t.AssignmentRulesPage}))));O.register(_.SUPPORT_ASSIGNMENT_SKILLS,n.lazy(()=>Promise.resolve().then(()=>require("./AgentSkillsPage-BWQSCYl-.js")).then(t=>({default:t.AgentSkillsPage}))));O.register(_.SUPPORT_ASSIGNMENT_WORKLOAD,n.lazy(()=>Promise.resolve().then(()=>require("./AgentWorkloadPage-w-HiyFYP.js")).then(t=>({default:t.AgentWorkloadPage}))));O.register(_.MYSPACE_DASHBOARD,n.lazy(()=>Promise.resolve().then(()=>require("./UserDashboardPage-KLB5CQP5.js")).then(t=>({default:t.UserDashboardPage}))));O.register(_.USER_PROFILE,n.lazy(()=>Promise.resolve().then(()=>require("./ProfilePage-Cu_FITeL.js")).then(t=>({default:t.ProfilePage}))));O.register(_.USER_PREFERENCES,n.lazy(()=>Promise.resolve().then(()=>require("./PreferencesPage-Cqr9mAab.js")).then(t=>({default:t.PreferencesPage}))));O.register(_.MYSPACE_TENANTS,n.lazy(()=>Promise.resolve().then(()=>require("./MyTenantsPage-DqGW6aDt.js")).then(t=>({default:t.MyTenantsPage}))));O.register(_.MYSPACE_ACCESS_REQUESTS,n.lazy(()=>Promise.resolve().then(()=>require("./MyAccessRequestsPage-BIisvWM6.js"))));O.register(_.MYSPACE_PORTAL,n.lazy(()=>Promise.resolve().then(()=>require("./PortalDashboardPage-CoEC4CmC.js")).then(t=>({default:t.PortalDashboardPage}))));O.register(_.NOTIFICATIONS,n.lazy(()=>Promise.resolve().then(()=>require("./NotificationsPage-DxwizUhL.js")).then(t=>({default:t.NotificationsPage}))));O.register(_.APPLICATIONS_HUB,n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsPage-6zgFye6w.js")).then(t=>({default:t.ApplicationsPage}))));const uo=n.createContext(null);function mo({config:t,children:s}){typeof window<"u"&&(window.__SMARTSTACK_CONFIG__=t);const r=n.useMemo(()=>({config:t}),[t]);return e.jsx(uo.Provider,{value:r,children:e.jsx(zr,{children:e.jsx(Xr,{config:t.extensions,children:e.jsx(vr,{children:e.jsx(qn,{children:e.jsx(wr,{children:e.jsx(Bn,{children:e.jsx(kr,{children:e.jsx(Tr,{children:e.jsx(Ir,{children:e.jsx(qr,{children:e.jsx(Xn,{children:e.jsx(gs,{children:e.jsx(Mr,{children:s})})})})})})})})})})})})})})}const Yr="smartstack-doc-panel-size",Jr=n.createContext(void 0);function po(){if(typeof window>"u")return 33;try{const t=localStorage.getItem(Yr);if(t){const s=parseFloat(t);if(s>=20&&s<=60)return s}}catch{}return 33}const Es={"administration/users":"/docs/business/administration/users","administration/users/dashboard":"/docs/business/administration/users","administration/users/list":"/docs/business/administration/users","administration/users/create":"/docs/business/administration/users","administration/users/groups":"/docs/business/administration/users/groups","administration/users/references":"/docs/business/administration/users/references","administration/permissions":"/docs/business/administration/permissions","administration/permissions/roles":"/docs/business/administration/permissions","administration/permissions/permissions":"/docs/business/administration/permissions","administration/permissions/assignments":"/docs/business/administration/permissions/assignments","administration/applications":"/docs/business/administration/applications","administration/applications/list":"/docs/business/administration/applications","administration/applications/grid":"/docs/business/administration/applications","administration/applications/dashboard":"/docs/business/administration/applications","administration/tenants":"/docs/business/administration/tenants","administration/tenants/dashboard":"/docs/business/administration/tenants","administration/tenants/create":"/docs/business/administration/tenants","administration/tenants/list":"/docs/business/administration/tenants/business","administration/tenants/list/enterprise":"/docs/business/administration/tenants/business","administration/tenants/list/personal":"/docs/business/administration/tenants/personal","administration/tenants/list/other":"/docs/business/administration/tenants/other","administration/tenants/template":"/docs/business/administration/tenants/template","administration/tenants/business":"/docs/business/administration/tenants/business","administration/tenants/personal":"/docs/business/administration/tenants","administration/tenants/organisations":"/docs/business/administration/tenants/organisations","administration/tenants/organisations/create":"/docs/business/administration/tenants/organisations","administration/tenants/access-requests":"/docs/business/administration/tenants/access-requests","administration/tenants/applications":"/docs/business/administration/tenants/applications","administration/workflows":"/docs/business/administration/workflows","administration/workflows/list":"/docs/business/administration/workflows","administration/workflows/create":"/docs/business/administration/workflows","administration/workflows/triggers":"/docs/business/administration/workflows","administration/workflows/history":"/docs/business/administration/workflows","administration/workflows/email-templates":"/docs/business/administration/workflows","administration/workflows/email-templates/email":"/docs/business/administration/workflows","administration/workflows/email-templates/sms":"/docs/business/administration/workflows","administration/workflows/email-templates/create":"/docs/business/administration/workflows","administration/ai":"/docs/business/administration/ai","administration/ai/dashboard":"/docs/business/administration/ai","administration/ai/settings":"/docs/business/administration/ai","administration/ai/providers":"/docs/business/administration/ai","administration/ai/models":"/docs/business/administration/ai","administration/ai/prompts":"/docs/business/administration/ai","administration/ai/blocks":"/docs/business/administration/ai","administration/entra":"/docs/business/administration/entra","administration/entra/dashboard":"/docs/business/administration/entra","administration/entra/groups":"/docs/business/administration/entra","administration/entra/users":"/docs/business/administration/entra","administration/entra/conflicts":"/docs/business/administration/entra","administration/entra/settings":"/docs/business/administration/entra","administration/configuration":"/docs/business/administration/configuration","administration/configuration/settings":"/docs/business/administration/configuration","administration/configuration/appsettings":"/docs/business/administration/configuration","administration/configuration/license":"/docs/business/administration/configuration/license","support/tickets":"/system/docs/user/support-dashboard","support/tickets/list":"/docs/business/platform/support/tickets","support/tickets/escalation":"/system/docs/user/support-escalation","support/my-tickets":"/docs/business/platform/support/tickets","support/my-tickets/list":"/docs/business/platform/support/tickets","support/my-tickets/create":"/docs/business/platform/support/tickets","support/admin/sla":"/system/docs/user/support-sla","support/admin/templates":"/system/docs/user/support-templates","myspace/profile":"/system/docs/user/modules","myspace/preferences":"/system/docs/user/modules","myspace/tenants":"/system/docs/user/modules","myspace/portal":"/system/docs/user/modules"},Is={administration:"/docs/business/administration/users",support:"/system/docs/user/support-dashboard",myspace:"/system/docs/user/modules"};function Ls(t){const s=t.split("/").filter(Boolean),a=s[0]==="t"&&s.length>=3?2:0,o=s.slice(a),c=o[0],i=o.slice(1);if(i.length>0)for(let d=i.length;d>0;d--){const u=`${c}/${i.slice(0,d).join("/")}`;if(Es[u])return Es[u]}return c&&Is[c]?Is[c]:"/system/docs/user"}function Qr({children:t}){const[s,r]=n.useState(!1),[a,o]=n.useState(po),[c,i]=n.useState(null),d=w.useLocation(),u=n.useRef(d.pathname);n.useEffect(()=>{u.current!==d.pathname&&(u.current=d.pathname,r(!1))},[d.pathname]),n.useEffect(()=>{a>=20&&a<=60&&localStorage.setItem(Yr,String(a))},[a]);const m=n.useCallback(b=>{const g=b||Ls(d.pathname);i(g),r(!0)},[d.pathname]),p=n.useCallback(()=>{r(!1)},[]),f=n.useCallback(()=>{if(s)r(!1);else{const b=Ls(d.pathname);i(b),r(!0)}},[s,d.pathname]),h=n.useCallback(b=>{b>=20&&b<=60&&o(b)},[]);return e.jsx(Jr.Provider,{value:{isOpen:s,panelSize:a,docUrl:c,openDocPanel:m,closeDocPanel:p,toggleDocPanel:f,setPanelSize:h},children:t})}function Gt(){const t=n.useContext(Jr);if(t===void 0)throw new Error("useDocPanel must be used within a DocPanelProvider");return t}class xo{captureBrowserInfo(){const s=navigator.userAgent;return{browser:this.getBrowserName(s),browserVersion:this.getBrowserVersion(s),os:this.getOSName(s),osVersion:this.getOSVersion(s),language:navigator.language,screenResolution:`${window.screen.width}x${window.screen.height}`,deviceType:this.getDeviceType(s)}}getBrowserName(s){return s.includes("Firefox")?"Firefox":s.includes("Edg/")?"Microsoft Edge":s.includes("Chrome")&&!s.includes("Edg/")?"Google Chrome":s.includes("Safari")&&!s.includes("Chrome")?"Safari":s.includes("Opera")||s.includes("OPR/")?"Opera":s.includes("MSIE")||s.includes("Trident/")?"Internet Explorer":"Unknown Browser"}getBrowserVersion(s){let r=null;return s.includes("Firefox")?r=/Firefox\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Edg/")?r=/Edg\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Chrome")&&!s.includes("Edg/")?r=/Chrome\/(\d+(?:\.\d+)*)/.exec(s):s.includes("Safari")&&!s.includes("Chrome")?r=/Version\/(\d+(?:\.\d+)*)/.exec(s):s.includes("OPR/")&&(r=/OPR\/(\d+(?:\.\d+)*)/.exec(s)),r?r[1]:"Unknown"}getOSName(s){return s.includes("Windows NT 10")?"Windows 10/11":s.includes("Windows NT 6.3")?"Windows 8.1":s.includes("Windows NT 6.2")?"Windows 8":s.includes("Windows NT 6.1")?"Windows 7":s.includes("Windows")?"Windows":s.includes("Mac OS X")?"macOS":s.includes("Linux")&&s.includes("Android")?"Android":s.includes("Linux")?"Linux":s.includes("iPhone")||s.includes("iPad")?"iOS":s.includes("CrOS")?"Chrome OS":"Unknown OS"}getWindowsVersion(s){return s==="10.0"?"10/11":s==="6.3"?"8.1":s==="6.2"?"8":s==="6.1"?"7":s}getOSVersion(s){if(s.includes("Windows NT")){const r=/Windows NT (\d+\.\d+)/.exec(s);if(r)return this.getWindowsVersion(r[1])}if(s.includes("Mac OS X")){const r=/Mac OS X (\d+[._]\d+(?:[._]\d+)?)/.exec(s);if(r)return r[1].replace(/_/g,".")}if(s.includes("Android")){const r=/Android (\d+(?:\.\d+)*)/.exec(s);if(r)return r[1]}if(s.includes("iPhone OS")||s.includes("iPad")){const r=/(?:iPhone|iPad|CPU) OS (\d+[._]\d+(?:[._]\d+)?)/.exec(s);if(r)return r[1].replace(/_/g,".")}return"Unknown"}getDeviceType(s){return/Tablet|iPad/i.test(s)?"Tablet":/Mobile|iPhone|Android.*Mobile/i.test(s)?"Mobile":"Desktop"}formatForDescription(s){return[`Browser: ${s.browser} ${s.browserVersion}`,`OS: ${s.os} ${s.osVersion}`,`Device: ${s.deviceType}`,`Screen: ${s.screenResolution}`,`Language: ${s.language}`].join(`
2
+ `)}}const Zr=new xo;function ho(){return{captureContext:n.useCallback(()=>{const s=Zr.captureBrowserInfo(),r=Te.getRecentErrors().slice(0,5);return{sourceUrl:window.location.href,browser:{name:s.browser,version:s.browserVersion,language:s.language},os:{name:s.os,version:s.osVersion},device:{type:s.deviceType,screenResolution:s.screenResolution},recentErrors:r.map(a=>({message:a.message,stack:a.stack,component:a.component,timestamp:a.timestamp.toISOString()}))}},[])}}function go(){const[t,s]=n.useState(new Set),[r,a]=n.useState(new Set),o=n.useCallback(p=>{s(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]),c=n.useCallback(p=>{a(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]),i=n.useCallback(()=>{s(new Set),a(new Set)},[]),d=n.useCallback((p,f)=>{s(new Set(p)),a(new Set(f))},[]),u=n.useCallback(p=>t.has(p),[t]),m=n.useCallback(p=>r.has(p),[r]);return{collapsedContexts:t,collapsedApps:r,toggleContext:o,toggleApp:c,expandAll:i,collapseAll:d,isContextCollapsed:u,isAppCollapsed:m}}const fs="/api/myspace/application-tracking",fo="00000000-0000-0000-0000-000000000000",$s=t=>!!t&&t!==fo,ea=t=>{const s=/^\/t\/[^/]+(\/.*)$/.exec(t);return s?s[1]:t},bo=t=>{const s=ea(t);return s.startsWith("/administration/")||s.startsWith("/support/")||s.startsWith("/myspace/")},ta=(t,s)=>{if(!t||typeof t!="object"||!("status"in t))return!0;const r=t.status;return!s.includes(r??-1)},vo=async(t,s)=>{const r=new Date,a=Math.floor((r.getTime()-s.getTime())/1e3);try{await E.post(`${fs}/end`,{accessId:t,endedAt:r.toISOString(),durationSeconds:a})}catch(o){ta(o,[401,408])&&console.error("Failed to end page tracking:",o)}},yo=async t=>{const s=new Date;try{return(await E.post(`${fs}/start`,{route:t,accessedAt:s.toISOString()})).accessId}catch(r){return ta(r,[401])&&console.error("Failed to track page access:",r),null}},jo=(t,s)=>{const r=localStorage.getItem("token");if(!r)return;const a=new Date,o=Math.floor((a.getTime()-s.getTime())/1e3);fetch(`${fs}/end`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({accessId:t,endedAt:a.toISOString(),durationSeconds:o}),keepalive:!0}).catch(()=>{})};function sa(){const t=w.useLocation(),s=n.useRef(new Date),r=n.useRef(null),a=n.useRef(!1);n.useEffect(()=>a.current?void 0:((async()=>{const c=ea(t.pathname);bo(c)&&(a.current=!0,$s(r.current)&&await vo(r.current,s.current),s.current=new Date,r.current=await yo(c),a.current=!1)})(),()=>{$s(r.current)&&jo(r.current,s.current)}),[t.pathname])}function No(t={}){const{canEditSystemRoles:s=!1}=t,{t:r,i18n:a}=ne.useTranslation("admin"),[o,c]=n.useState(!0),[i,d]=n.useState(null),[u,m]=n.useState(null),[p,f]=n.useState(!1),[h,b]=n.useState(!1),[g,y]=n.useState([]),[x,j]=n.useState([]),[v,S]=n.useState(new Map),[N,I]=n.useState({}),[P,k]=n.useState({}),[A,R]=n.useState({}),[$,q]=n.useState({selectedRoleIds:[],resourceSearch:"",applicationFilter:"all",moduleFilter:"all",categoryFilter:"all"}),C=n.useRef(null),D=n.useRef(new Map),Y=n.useCallback((U,W,ee)=>{const te=U.has(ee),se=W.get(ee);if(!se)return{isDirect:te,isInherited:!1};const me=se.path.toLowerCase();let ie,ve,be=1/0;for(const Me of Array.from(U)){const Le=W.get(Me);if(!Le||Me===ee)continue;const ze=Le.path.toLowerCase();if((Le.isWildcard||ze.endsWith(".*"))&&Ct(ze,me)){const We=ze.split(".").length;We<be&&(be=We,ie=Le.path,ve=Le.id)}}return{isDirect:te,isInherited:ie!==void 0,inheritedFromPath:ie,inheritedFromId:ve}},[]),T=n.useCallback((U,W)=>{const ee={};return Object.entries(U).forEach(([te,se])=>{const me=new Map;W.forEach((ie,ve)=>{const be=Y(se,W,ve);me.set(ve,be)}),ee[te]=me}),ee},[Y]),z=(U,W,ee,te)=>{const se=[],me=[];return U.resources.forEach(ie=>{const ve=ie.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),be=te.get(ve)||[],Ie={id:ie.id,path:ie.permissionPath,label:ie.label,applicationLabel:ee.label,moduleLabel:ie.label,parentModuleLabel:W.label,parentModuleId:W.id,parentSectionLabel:U.label,parentSectionId:U.id,level:"resource",permissions:be,totalPermissions:be.length};se.push(Ie),me.push(Ie)}),{childResources:se,nodes:me}},Z=(U,W,ee)=>{const te=[],se=[];return U.sections.forEach(me=>{const ie=me.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),ve=ee.get(ie)||[],{childResources:be,nodes:Ie}=z(me,U,W,ee),Me=be.reduce((et,We)=>et+We.totalPermissions,0),Le=ve.length+Me,ze={id:me.id,path:me.permissionPath,label:me.label,applicationLabel:W.label,moduleLabel:me.label,parentModuleLabel:U.label,parentModuleId:U.id,level:"section",permissions:ve,totalPermissions:Le,childResources:be.length>0?be:void 0};te.push(ze),se.push(ze),se.push(...Ie)}),{childSections:te,nodes:se}},H=(U,W,ee,te)=>{const se=U.permissionPath.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,""),me=ee.get(se)||[],{childSections:ie,nodes:ve}=Z(U,W,ee),be=ie.reduce((Me,Le)=>Me+Le.totalPermissions,0),Ie=me.length+be;te.push({id:U.id,path:U.permissionPath,label:U.label,applicationLabel:W.label,moduleLabel:U.label,level:"module",permissions:me,totalPermissions:Ie,childSections:ie.length>0?ie:void 0}),te.push(...ve)},J=(U,W,ee)=>{U.modules.forEach(te=>{H(te,U,W,ee)})},fe=n.useCallback((U,W)=>{const ee=[];if(!U||!U.applications||!W||!Array.isArray(W))return ee;const te=new Map;return W.forEach(se=>{const ie=se.path.toLowerCase().split(".");if(ie.length>=2){const ve=ie.slice(0,-1).join("."),be=te.get(ve)||[];be.push({id:se.id,action:ie.at(-1),path:se.path}),te.set(ve,be)}}),U.applications.forEach(se=>{J(se,te,ee)}),ee.sort((se,me)=>{const ie=se.applicationLabel.localeCompare(me.applicationLabel);return ie!==0?ie:se.moduleLabel.localeCompare(me.moduleLabel)})},[]),B=n.useCallback(async()=>{try{c(!0),d(null);const U=await Ne.permissions.getMatrix(),W={};U.roles.forEach(ie=>{W[ie.id]=new Set(ie.permissionIds)});const ee=new Map(U.permissions.map(ie=>[ie.id,ie])),te=fe(U.tree,U.permissions),se=T(W,ee);y(U.roles),j(te),S(ee),I(W),R(se);const me=Object.entries(W).reduce((ie,[ve,be])=>(ie[ve]=new Set(Array.from(be)),ie),{});k(me),D.current.clear()}catch(U){d(U instanceof Error?U.message:"Failed to load permission matrix data")}finally{c(!1)}},[fe,T]);n.useEffect(()=>{B()},[B,a.language]),n.useEffect(()=>{if(v.size>0){const U=T(N,v);R(U)}},[N,v,T]);const Q=n.useCallback(async()=>{if(D.current.size===0)return;const U=new Map(D.current);D.current.clear(),f(!0),m(null);try{const W=Array.from(U.entries()).map(async([se,me])=>{const ie=g.find(ve=>ve.id===se);ie&&await Ne.roles.update(se,{name:ie.name,shortName:ie.shortName,category:ie.category,description:ie.description||void 0,permissionIds:Array.from(me)})});await Promise.all(W);const ee=JSON.parse(JSON.stringify(Object.fromEntries(Object.entries(N).map(([se,me])=>[se,Array.from(me)])))),te=Object.entries(ee).reduce((se,[me,ie])=>(se[me]=new Set(ie),se),{});k(te),b(!0),setTimeout(()=>{b(!1)},3e3)}catch(W){console.error("Failed to save permission changes:",W);let ee="Failed to save changes";if(W&&typeof W=="object"&&"response"in W){const te=W.response;te?.status===403?ee=r("assignments.noPermissionToEditRole"):te?.data?.message&&(ee=te.data.message)}else W instanceof Error&&(ee=W.message);m(ee),await B()}finally{f(!1)}},[g,N,B]),M=n.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{Q()},500)},[Q]),re=n.useCallback((U,W)=>{g.find(te=>te.id===U)?.isSystem&&!s||I(te=>{const se=new Set(te[U]||[]);return se.has(W)?se.delete(W):se.add(W),D.current.set(U,se),M(),{...te,[U]:se}})},[g,s,M]),F=U=>{x.forEach(W=>{W.permissions.forEach(ee=>{U.add(ee.id)})})},K=n.useCallback((U,W)=>{g.find(te=>te.id===U)?.isSystem&&!s||I(te=>{const se=new Set;return W&&F(se),D.current.set(U,se),M(),{...te,[U]:se}})},[g,s,x,M]),V=(U,W,ee)=>{W.permissions.forEach(te=>{ee?U.add(te.id):U.delete(te.id)})},ae=n.useCallback((U,W)=>{I(ee=>{const te={...ee};return g.forEach(se=>{if(se.isSystem&&!s)return;const me=new Set(te[se.id]||[]);V(me,U,W),te[se.id]=me,D.current.set(se.id,me)}),M(),te})},[g,s,M]),ue=n.useCallback(U=>{q(W=>({...W,...U}))},[]),G=n.useCallback(()=>{const U=Object.entries(P).reduce((W,[ee,te])=>(W[ee]=new Set(Array.from(te)),W),{});I(U),D.current.clear(),C.current&&clearTimeout(C.current)},[P]),ce=n.useMemo(()=>g.filter(U=>$.selectedRoleIds.length===0?!0:$.selectedRoleIds.includes(U.id)),[g,$.selectedRoleIds]),de=n.useMemo(()=>x.filter(U=>!($.resourceSearch&&!U.moduleLabel.toLowerCase().includes($.resourceSearch.toLowerCase())||$.applicationFilter!=="all"&&U.applicationLabel!==$.applicationFilter||$.moduleFilter!=="all"&&U.moduleLabel!==$.moduleFilter)),[x,$]),he=n.useMemo(()=>Array.from(Object.entries(N)).some(([U,W])=>{const ee=P[U];return ee?W.size!==ee.size?!0:Array.from(W).some(te=>!ee.has(te)):W.size>0}),[N,P]),pe=n.useMemo(()=>{const U=new Map;return x.forEach(W=>{U.has(W.applicationLabel)||U.set(W.applicationLabel,{app:W.applicationLabel,label:W.applicationLabel})}),Array.from(U.values()).sort((W,ee)=>W.label.localeCompare(ee.label))},[x]),ye=n.useMemo(()=>x.filter(U=>U.level==="module").map(U=>({app:U.applicationLabel,module:U.label,label:U.label})).sort((U,W)=>U.label.localeCompare(W.label)),[x]),qe=n.useMemo(()=>{const U=new Set(g.map(ee=>ee.category));return["Global","Admin","Manager","Contributor","Viewer","Custom"].filter(ee=>U.has(ee))},[g]),Ue=n.useCallback((U,W)=>{const ee=A[U];return ee?ee.get(W)||{isDirect:!1,isInherited:!1}:{isDirect:!1,isInherited:!1}},[A]),Ve=n.useCallback(()=>{m(null)},[]);return{loading:o,error:i,saveError:u,saving:p,saveSuccess:h,roles:g,resources:x,permissions:v,assignments:N,inheritanceMap:A,filters:$,filteredRoles:ce,filteredResources:de,hasChanges:he,canEditSystemRoles:s,applications:pe,modules:ye,categories:qe,togglePermission:re,toggleAllForRole:K,toggleAllForResource:ae,updateFilters:ue,reloadData:B,resetChanges:G,saveChanges:Q,clearSaveError:Ve,getPermissionInheritance:Ue}}function ra(t={}){const s=n.useRef(null),[r,a]=n.useState(oe.HubConnectionState.Disconnected),o=n.useRef(t);o.current=t;const c=n.useCallback(()=>localStorage.getItem("token"),[]),i=n.useCallback(async()=>{const u=c();if(u&&s.current?.state!==oe.HubConnectionState.Connected)try{const m=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>u}).withAutomaticReconnect({nextRetryDelayInMilliseconds:p=>p.previousRetryCount===0?0:p.previousRetryCount===1?2e3:p.previousRetryCount===2?1e4:p.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();m.on("ReceiveNotification",p=>{o.current.onNotification?.(p)}),m.on("UnreadCountUpdate",p=>{o.current.onUnreadCountUpdate?.(p)}),m.on("PermissionsChanged",()=>{o.current.onPermissionsChanged?.()}),m.onreconnecting(()=>{a(oe.HubConnectionState.Reconnecting),o.current.onConnectionStateChange?.(oe.HubConnectionState.Reconnecting)}),m.onreconnected(()=>{a(oe.HubConnectionState.Connected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Connected)}),m.onclose(()=>{a(oe.HubConnectionState.Disconnected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Disconnected)}),await m.start(),s.current=m,a(oe.HubConnectionState.Connected),o.current.onConnectionStateChange?.(oe.HubConnectionState.Connected)}catch(m){console.error("SignalR: Failed to connect",m),a(oe.HubConnectionState.Disconnected)}},[c]),d=n.useCallback(async()=>{if(s.current)try{await s.current.stop(),s.current=null,a(oe.HubConnectionState.Disconnected)}catch(u){console.error("SignalR: Failed to disconnect",u)}},[]);return n.useEffect(()=>(i(),()=>{d()}),[i,d]),n.useEffect(()=>{const u=m=>{m.key==="token"&&(m.newValue?i():d())};return window.addEventListener("storage",u),()=>window.removeEventListener("storage",u)},[i,d]),{connectionState:r,isConnected:r===oe.HubConnectionState.Connected,connect:i,disconnect:d}}function wo(){const{refreshPermissions:t,user:s}=Pe(),{refreshMenu:r}=Ce(),a=n.useRef(!1),o=n.useCallback(async()=>{if(!a.current){a.current=!0;try{await Promise.all([t(),r()])}catch(d){console.error("[PermissionSync] Failed to refresh permissions:",d)}finally{a.current=!1}}},[t,r]),{isConnected:c,connectionState:i}=ra({onPermissionsChanged:o});return{isConnected:c,connectionState:i,isAuthenticated:!!s}}function aa(t){const{ticketId:s,onCommentAdded:r,onTicketUpdated:a,onConnectionStateChange:o}=t,c=n.useRef(null),i=n.useRef(null),[d,u]=n.useState(oe.HubConnectionState.Disconnected),m=n.useCallback(()=>localStorage.getItem("token"),[]),p=n.useCallback(async g=>{if(c.current?.state===oe.HubConnectionState.Connected)try{await c.current.invoke("JoinTicket",g),i.current=g}catch(y){console.error("SignalR: Failed to join ticket group",y)}},[]),f=n.useCallback(async g=>{if(c.current?.state===oe.HubConnectionState.Connected)try{await c.current.invoke("LeaveTicket",g)}catch(y){console.error("SignalR: Failed to leave ticket group",y)}i.current=null},[]),h=n.useCallback(async()=>{const g=m();if(g){if(c.current?.state===oe.HubConnectionState.Connected)return c.current;try{const y=new oe.HubConnectionBuilder().withUrl("/hubs/notifications",{accessTokenFactory:()=>g}).withAutomaticReconnect({nextRetryDelayInMilliseconds:x=>x.previousRetryCount===0?0:x.previousRetryCount===1?2e3:x.previousRetryCount===2?1e4:x.previousRetryCount<5?3e4:null}).configureLogging(oe.LogLevel.Warning).build();return y.on("TicketCommentAdded",x=>{r?.(x)}),y.on("TicketUpdated",x=>{a?.(x)}),y.onreconnecting(()=>{u(oe.HubConnectionState.Reconnecting),o?.(oe.HubConnectionState.Reconnecting)}),y.onreconnected(async()=>{u(oe.HubConnectionState.Connected),o?.(oe.HubConnectionState.Connected),i.current&&await p(i.current)}),y.onclose(()=>{u(oe.HubConnectionState.Disconnected),o?.(oe.HubConnectionState.Disconnected)}),await y.start(),c.current=y,u(oe.HubConnectionState.Connected),o?.(oe.HubConnectionState.Connected),y}catch(y){return console.error("SignalR: Failed to connect",y),u(oe.HubConnectionState.Disconnected),null}}},[m,p,r,a,o]),b=n.useCallback(async()=>{if(i.current&&await f(i.current),c.current)try{await c.current.stop(),c.current=null,u(oe.HubConnectionState.Disconnected)}catch(g){console.error("SignalR: Failed to disconnect",g)}},[f]);return n.useEffect(()=>{let g=!0;return(async()=>(await h(),g&&s&&await p(s)))(),()=>{g=!1,b()}},[h,b,s,p]),n.useEffect(()=>{const g=async()=>{i.current&&i.current!==s&&await f(i.current),s&&s!==i.current&&await p(s)};c.current?.state===oe.HubConnectionState.Connected&&g()},[s,p,f]),{connectionState:d,isConnected:d===oe.HubConnectionState.Connected,joinTicket:p,leaveTicket:f}}function So(t,s,r,a){const o=[];for(const c of a.resources)c.route&&o.push({componentKey:c.componentKey,permissionPath:c.permissionPath,route:c.route,hasComponent:O.has(c.componentKey),requiredFeature:r,isOpen:s,level:"resource",applicationCode:t});return o}function Co(t,s,r,a){const o=[];for(const c of a.sections)c.route&&o.push({componentKey:c.componentKey,permissionPath:c.permissionPath,route:c.route,hasComponent:O.has(c.componentKey),requiredFeature:r,isOpen:s,level:"section",applicationCode:t}),o.push(...So(t,s,r,c));return o}function ko(t,s,r){const a=[];for(const o of r.modules)o.route&&a.push({componentKey:o.componentKey,permissionPath:o.permissionPath,route:o.route,hasComponent:O.has(o.componentKey),requiredFeature:o.requiredFeature,isOpen:s,level:"module",applicationCode:t}),a.push(...Co(t,s,o.requiredFeature,o));return a}function Ao(t){const s=[];for(const r of t)r.route&&s.push({componentKey:r.componentKey,permissionPath:r.permissionPath,route:r.route,hasComponent:O.has(r.componentKey),requiredFeature:r.requiredFeature,isOpen:r.isOpen,level:"application",applicationCode:r.code}),s.push(...ko(r.code,r.isOpen,r));return s}function Po(){const{menu:t,isLoading:s}=Ce();return n.useMemo(()=>{if(!t||s)return{entries:[],byKey:new Map,isLoading:!0,byApplication:new Map};const r=Ao(t.applications),a=new Map(r.map(c=>[c.componentKey,c])),o=new Map;for(const c of r){const i=o.get(c.applicationCode)||[];i.push(c),o.set(c.applicationCode,i)}return{entries:r,byKey:a,isLoading:!1,byApplication:o}},[t,s])}const To=(t,s,r)=>{const a=t.has(r),o=s.get(r);if(!o)return{isDirect:a,isInherited:!1};const c=o.path;let i,d,u=1/0;for(const p of Array.from(t)){const f=s.get(p);if(!(!f||!f.isWildcard||p===r)&&Ct(f.path,c)){const h=f.path.split(".").length;h<u&&(u=h,i=f.path,d=f.id)}}return{isDirect:a,isInherited:i!==void 0,inheritedFromPath:i,inheritedFromId:d}},Ds=(t,s)=>{const r={};return Object.entries(t).forEach(([a,o])=>{const c=new Map;s.forEach((i,d)=>{const u=To(o,s,d);c.set(d,u)}),r[a]=c}),r},Ro=t=>{const s=new Map;return t.forEach(r=>{const o=r.path.toLowerCase().split(".");if(o.length>=2){const c=o.slice(0,-1).join("."),i=s.get(c)||[];i.push({id:r.id,action:o.at(-1),path:r.path}),s.set(c,i)}}),s},Ht=(t,s)=>{const r=s.toLowerCase().replace(/\.\*$/,"").replace(/\*$/,"");return t.get(r)||[]};function na(t){const{entityId:s,tenantId:r,loadEntity:a,loadRoles:o}=t,{i18n:c}=ne.useTranslation(),[i,d]=n.useState(!0),[u,m]=n.useState(null),[p,f]=n.useState(null),[h,b]=n.useState([]),[g,y]=n.useState([]),[x,j]=n.useState(new Map),[v,S]=n.useState({}),[N,I]=n.useState({}),[P,k]=n.useState({selectedRoleIds:[],resourceSearch:"",applicationFilter:"all",moduleFilter:"all"}),A=!!r,R=n.useCallback((F,K,V,ae)=>{const ue=Ht(ae,K.permissionPath);F.push({id:K.id,path:K.permissionPath,label:K.label,applicationLabel:V.label,moduleLabel:K.label,level:"module",permissions:ue,totalPermissions:ue.length})},[]),$=n.useCallback((F,K,V,ae,ue)=>{const G=Ht(ue,K.permissionPath);K.resources.forEach(ce=>{const de=Ht(ue,ce.permissionPath);F.push({id:ce.id,path:ce.permissionPath,label:ce.label,applicationLabel:ae.label,moduleLabel:V.label,parentModuleLabel:V.label,parentModuleId:V.id,parentSectionLabel:K.label,parentSectionId:K.id,level:"resource",permissions:de,totalPermissions:de.length})}),F.push({id:K.id,path:K.permissionPath,label:K.label,applicationLabel:ae.label,moduleLabel:V.label,parentModuleLabel:V.label,parentModuleId:V.id,level:"section",permissions:G,totalPermissions:G.length})},[]),q=n.useCallback((F,K,V,ae)=>{R(ae,F,K,V),F.sections.forEach(ue=>{$(ae,ue,F,K,V)})},[R,$]),C=n.useCallback((F,K,V)=>{F.modules.forEach(ae=>{q(ae,F,K,V)})},[q]),D=n.useCallback((F,K)=>{if(!F?.applications||!Array.isArray(K))return[];const V=Ro(K),ae=[];return F.applications.forEach(ue=>{C(ue,V,ae)}),ae.sort((ue,G)=>{const ce=ue.applicationLabel.localeCompare(G.applicationLabel);return ce!==0?ce:ue.moduleLabel.localeCompare(G.moduleLabel)})},[C]),Y=n.useCallback(async()=>{try{d(!0),m(null);const[F,K,V]=await Promise.all([a(s),o(s,r),Ne.permissions.getMatrix()]);f(F),b(K);const ae=new Set(K.map(pe=>pe.id)),ue=V.roles.filter(pe=>ae.has(pe.id)),G={};ue.forEach(pe=>{G[pe.id]=new Set(pe.permissionIds)});const ce=new Map(V.permissions.map(pe=>[pe.id,pe])),de=D(V.tree,V.permissions),he=Ds(G,ce);y(de),j(ce),S(G),I(he)}catch(F){m(F instanceof Error?F.message:"Failed to load permissions data")}finally{d(!1)}},[s,r,a,o,D]);n.useEffect(()=>{Y()},[Y,c.language]),n.useEffect(()=>{if(x.size>0){const F=Ds(v,x);I(F)}},[v,x]);const T=n.useMemo(()=>{const F=new Set;return Object.entries(N).forEach(([K,V])=>{V.forEach((ae,ue)=>{(ae.isDirect||ae.isInherited)&&F.add(ue)})}),F},[N]),z=F=>P.resourceSearch?F.label.toLowerCase().includes(P.resourceSearch.toLowerCase()):!0,Z=F=>P.applicationFilter==="all"?!0:F.applicationLabel===P.applicationFilter,H=F=>P.moduleFilter==="all"?!0:F.level==="module"?F.label===P.moduleFilter:F.parentModuleLabel===P.moduleFilter,J=n.useMemo(()=>g.filter(F=>z(F)&&Z(F)&&H(F)),[g,P]),fe=n.useMemo(()=>{const F=new Map;return g.forEach(K=>{F.has(K.applicationLabel)||F.set(K.applicationLabel,{app:K.applicationLabel,label:K.applicationLabel})}),Array.from(F.values()).sort((K,V)=>K.label.localeCompare(V.label))},[g]),B=n.useMemo(()=>g.filter(F=>F.level==="module").map(F=>({app:F.applicationLabel,module:F.label,label:F.label})).sort((F,K)=>F.label.localeCompare(K.label)),[g]),Q=n.useCallback(F=>{k(K=>({...K,...F}))},[]),M=n.useCallback((F,K)=>{const V=N[F];return V?V.get(K)||{isDirect:!1,isInherited:!1}:{isDirect:!1,isInherited:!1}},[N]),re=n.useCallback(F=>{const K=[];return h.forEach(V=>{const ae=N[V.id];if(ae){const ue=ae.get(F);ue&&(ue.isDirect||ue.isInherited)&&K.push(V)}}),K},[h,N]);return{loading:i,error:u,entity:p,roles:h,resources:g,assignments:v,inheritanceMap:N,effectivePermissions:T,filters:P,filteredResources:J,applications:fe,modules:B,updateFilters:Q,getPermissionInheritance:M,getPermissionSources:re,reloadData:Y,isTenantMode:A}}function Eo(t){const{userId:s,tenantId:r}=t,[a,o]=n.useState(null),[c,i]=n.useState([]),d=!!r,u=n.useCallback(async y=>Ne.users.getById(y),[]),m=n.useCallback(async(y,x)=>{const j=await Ne.users.getById(y);let v=[];try{const N=await Ne.users.getConsolidatedRoles(y,x);if(i(N),v=N.map(I=>({id:I.roleId,name:I.roleName,shortName:I.roleShortName||I.roleName,category:"Custom",description:null})),x)try{const P=(await Ne.tenants.getMembers(x)).find(k=>k.userId===y);o(P||null)}catch{o(null)}else o(null)}catch{i([]),o(null),v=j.roles}return Array.from(new Map(v.map(N=>[N.id,N])).values())},[]),p=na({entityId:s,tenantId:r,loadEntity:u,loadRoles:m}),f=p.entity,h=p.roles,b=n.useCallback(y=>{const x=[];return h.forEach(j=>{const v=p.inheritanceMap[j.id];if(v){const S=v.get(y);S&&(S.isDirect||S.isInherited)&&x.push(j)}}),x},[h,p.inheritanceMap]),g=n.useCallback(async y=>{if(!d||!r||!a)throw new Error("Cannot assign tenant roles: not in tenant mode or no tenant member found");await Ne.tenants.assignMemberRoles(r,a.userId,y),await p.reloadData()},[d,r,a,p]);return{loading:p.loading,error:p.error,user:f,userRoles:h,resources:p.resources,assignments:p.assignments,inheritanceMap:p.inheritanceMap,effectivePermissions:p.effectivePermissions,filters:p.filters,filteredResources:p.filteredResources,applications:p.applications,modules:p.modules,updateFilters:p.updateFilters,getPermissionInheritance:p.getPermissionInheritance,getPermissionSources:b,reloadData:p.reloadData,isTenantMode:d,tenantMember:a,assignTenantRoles:g,consolidatedRoles:c}}function Kt(){const{mode:t,toggleMode:s}=St(),a=(t==="dark"?"dark":"light")==="light";return e.jsx("button",{onClick:s,className:"relative p-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-300 group",style:{borderRadius:"var(--radius-button)"},"aria-label":`Basculer vers le mode ${a?"sombre":"clair"}`,children:e.jsxs("div",{className:"relative w-6 h-6",children:[e.jsx(l.Sun,{className:`absolute inset-0 w-6 h-6 text-amber-500 transition-all duration-300 ${a?"opacity-100 rotate-0 scale-100":"opacity-0 rotate-90 scale-0"}`}),e.jsx(l.Moon,{className:`absolute inset-0 w-6 h-6 text-[var(--color-accent-400)] transition-all duration-300 ${a?"opacity-0 -rotate-90 scale-0":"opacity-100 rotate-0 scale-100"}`})]})})}const Vt=[{code:"en",label:"English",short:"EN"},{code:"fr",label:"Français",short:"FR"},{code:"de",label:"Deutsch",short:"DE"},{code:"it",label:"Italiano",short:"IT"}];function bs(){const{i18n:t}=ne.useTranslation(),{isAuthenticated:s}=Pe(),[r,a]=n.useState(!1),o=n.useRef(null),c=t.language?.split("-")[0]||"en",i=Vt.find(u=>u.code===c)||Vt[0],d=async u=>{if(await xs(u),document.documentElement.lang=u,a(!1),s)try{await _t.preferences.updateLanguage({language:u})}catch{}};return n.useEffect(()=>{const u=m=>{o.current&&!o.current.contains(m.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]),e.jsxs("div",{ref:o,className:"relative",children:[e.jsx("button",{onClick:()=>a(!r),className:"relative p-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-300",style:{borderRadius:"var(--radius-button)"},"aria-label":"Change language",children:e.jsx("span",{className:"flex items-center justify-center w-6 h-6 text-xs font-bold text-[var(--text-secondary)]",children:i.short})}),r&&e.jsx("div",{className:"absolute right-0 mt-2 py-1 bg-[var(--bg-tertiary)] border border-[var(--border-color)] shadow-lg shadow-[var(--shadow-color)] z-50 overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:Vt.map(u=>{const m=u.code===c;return e.jsxs("button",{onClick:()=>d(u.code),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors whitespace-nowrap ${m?"bg-primary-600/10 text-primary-500":"text-[var(--text-secondary)] hover:bg-[var(--bg-secondary)] hover:text-[var(--text-primary)]"}`,children:[e.jsx("span",{className:"text-xs font-bold w-6",children:u.short}),e.jsx("span",{className:"text-sm font-medium",children:u.label}),m&&e.jsx(l.Check,{className:"w-4 h-4 ml-auto text-primary-500"})]},u.code)})})]})}function Io(t,s){if(!s.useUrlRouting||!s.slug)return dt(t);if(t.startsWith(`/t/${s.slug}`))return t;const r=dt(t);return`/t/${s.slug}${r}`}function Ms(t){const s=/^\/t\/([^/]+)/.exec(t);return s?s[1]:null}function dt(t){return t.replace(/^\/t\/[^/]+/,"")||"/"}function Ze(){const{currentTenant:t}=Ee(),{useUrlRouting:s}=qt();return n.useCallback(r=>Io(r,{slug:t?.slug,useUrlRouting:s}),[t?.slug,s])}const Os={background:"linear-gradient(to bottom right, var(--color-accent-500), var(--color-accent-600))"};function oa(){const{t}=ne.useTranslation("navigation"),{user:s,logout:r}=Pe(),{refreshMenu:a}=Ce(),{refreshTenants:o}=Ee(),c=w.useLocation(),i=w.useNavigate(),d=Ze(),[u,m]=n.useState(!1),[p,f]=n.useState(!1),h=n.useRef(null),b=async()=>{f(!0);try{await E.post("/api/navigation/invalidate-cache").catch(()=>{}),await Promise.all([a(),o()])}catch(j){console.error("Failed to refresh cache:",j)}finally{f(!1),m(!1)}},g=j=>{const v=d(j);c.pathname!==v&&i(v),m(!1)};n.useEffect(()=>{function j(v){h.current&&!h.current.contains(v.target)&&m(!1)}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]),n.useEffect(()=>{function j(v){v.key==="Escape"&&m(!1)}return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[]);const y=()=>{if(!s)return"?";const j=s.firstName?.[0]||"",v=s.lastName?.[0]||"";return(j+v).toUpperCase()||s.email.at(0)?.toUpperCase()||"?"},x=()=>s?s.firstName||s.lastName?`${s.firstName||""} ${s.lastName||""}`.trim():s.email.split("@")[0]:"";return e.jsxs("div",{ref:h,className:"relative",children:[e.jsxs("button",{onClick:()=>m(!u),className:"flex items-center gap-2 p-1.5 pr-3 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-all duration-200 group",style:{borderRadius:"var(--radius-button)"},"aria-expanded":u,"aria-haspopup":"true",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm font-medium shadow-sm",style:Os,children:y()}),e.jsx(l.ChevronDown,{className:`w-4 h-4 text-[var(--text-tertiary)] transition-transform duration-200 ${u?"rotate-180":""}`})]}),e.jsx("div",{className:`absolute right-0 mt-2 w-72 origin-top-right transition-all duration-200 ease-out ${u?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"p-4 bg-gradient-to-br from-[var(--bg-secondary)] to-[var(--bg-tertiary)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center text-white text-lg font-semibold shadow-lg",style:Os,children:y()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-[var(--text-primary)] truncate",children:x()}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] truncate",children:s?.email})]})]})}),e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("button",{onClick:()=>g("/applications"),className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.LayoutGrid,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.applications")})]}),e.jsxs("button",{onClick:()=>g("/myspace"),className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.User,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.mySpace")})]})]})}),e.jsx("div",{className:"p-2",children:e.jsxs("button",{onClick:b,disabled:p,className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-[var(--bg-tertiary)] transition-colors disabled:opacity-50",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[var(--text-secondary)]",children:e.jsx(l.RefreshCw,{className:`w-4 h-4 ${p?"animate-spin":""}`})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t("avatarMenu.refreshCache")})]})}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs("button",{onClick:()=>{m(!1),r()},className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-red-500/10 transition-colors group",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--bg-tertiary)] group-hover:bg-red-500/20 flex items-center justify-center text-[var(--text-secondary)] group-hover:text-red-500 transition-colors",children:e.jsx(l.LogOut,{className:"w-4 h-4"})}),e.jsx("span",{className:"font-medium text-[var(--text-primary)] group-hover:text-red-500 transition-colors",children:t("avatarMenu.logout")})]})})]})})]})}const Lo={settings:l.Settings,users:l.Users,key:l.Key,briefcase:l.Briefcase,folder:l.FolderOpen,file:l.FileText,box:l.Box};function $o(t){return t&&Lo[t.toLowerCase()]||l.Box}function Fs({app:t,isFavorite:s,showFavorite:r,onToggleFavorite:a,onSelect:o}){const c=$o(t.icon);return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{onClick:o,className:"w-full flex flex-col items-center gap-2 p-3 hover:bg-[var(--bg-tertiary)] transition-all duration-200",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-[var(--color-accent-500)]/20 to-[var(--color-accent-600)]/20 flex items-center justify-center group-hover:from-[var(--color-accent-500)]/30 group-hover:to-[var(--color-accent-600)]/30 transition-all",style:{borderRadius:"var(--radius-card)"},children:e.jsx(c,{className:"w-6 h-6 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-xs font-medium text-[var(--text-primary)] text-center line-clamp-2",children:t.label})]}),r&&e.jsx("button",{onClick:i=>{i.stopPropagation(),a()},className:`absolute top-1 right-1 p-1.5 transition-all duration-200 ${s?"text-amber-500 bg-amber-500/10":"text-[var(--text-tertiary)] opacity-0 group-hover:opacity-100 hover:bg-[var(--bg-secondary)]"}`,style:{borderRadius:"var(--radius-button)"},title:s?"Retirer des favoris":"Ajouter aux favoris",children:e.jsx(l.Star,{className:`w-4 h-4 ${s?"fill-current":""}`})})]})}function ia(){const{t}=ne.useTranslation("navigation"),{favorites:s,menu:r,toggleFavorite:a,isFavorite:o}=Ce(),{currentTenant:c}=Ee(),[i,d]=n.useState(!1),u=n.useRef(null),m=w.useNavigate(),p=Ze(),f=!!c,h=r?.applications||[];n.useEffect(()=>{function g(y){u.current&&!u.current.contains(y.target)&&d(!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),n.useEffect(()=>{function g(y){y.key==="Escape"&&d(!1)}return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[]);const b=g=>{d(!1),g.route&&m(p(g.route))};return e.jsxs("div",{ref:u,className:"relative",children:[e.jsx("button",{onClick:()=>d(!i),className:"p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},"aria-expanded":i,"aria-haspopup":"true",title:t("appSwitcher.title","Applications"),children:e.jsx(l.LayoutGrid,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx("div",{className:`absolute right-0 mt-2 w-80 origin-top-right transition-all duration-200 ease-out ${i?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[s.length>0&&e.jsxs("div",{className:"p-3 border-b border-[var(--border-color)]",children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-3 h-3 text-amber-500 fill-amber-500"}),t("appSwitcher.favorites","Favoris")]}),e.jsx("div",{className:"grid grid-cols-3 gap-1 mt-2",children:s.slice(0,6).map(g=>e.jsx(Fs,{app:g,isFavorite:!0,showFavorite:f,onToggleFavorite:()=>a(g.id),onSelect:()=>{d(!1),g.route&&m(p(g.route))}},g.id))})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider",children:t("appSwitcher.allApps","Toutes les applications")}),h.length>0?e.jsx("div",{className:"grid grid-cols-3 gap-1 mt-2 max-h-64 overflow-y-auto",children:h.map(g=>e.jsx(Fs,{app:g,isFavorite:o(g.id),showFavorite:f,onToggleFavorite:()=>a(g.id),onSelect:()=>b(g)},g.id))}):e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-6",children:t("appSwitcher.noApps","Aucune application disponible")})]})]})})]})}function Do(){const[t,s]=n.useState([]),r=n.useCallback(async()=>{try{const c=await Ne.myTenants.getFavorites();s(c)}catch{}},[]),a=n.useCallback(async c=>{const i=t.includes(c);try{if(i){const d=await Ne.myTenants.removeFavorite(c);s(d)}else{const d=await Ne.myTenants.addFavorite(c);s(d)}}catch(d){console.error("Failed to toggle favorite:",d)}},[t]),o=n.useCallback(c=>{Ne.myTenants.recordRecent(c).catch(console.error)},[]);return{favorites:t,loadFavorites:r,toggleFavorite:a,recordRecent:o}}const Mo={Pending:"bg-blue-500",Active:"bg-emerald-500",Suspended:"bg-amber-500",Archived:"bg-gray-400"},Oo={Pending:"En attente",Active:"Actif",Suspended:"Suspendu",Archived:"Archivé"};function Wt({tenant:t,isSelected:s,isFavorite:r,hasThemeOverride:a,onSelect:o,onToggleFavorite:c,showStatus:i=!0}){const d=t.type==="Business",u=t.status==="Active",m=(p,f)=>p?"bg-[var(--color-accent-500)]/10 text-[var(--color-accent-600)]":f?"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]":"opacity-50 cursor-not-allowed text-[var(--text-tertiary)]";return e.jsxs("div",{className:"flex items-center group",children:[e.jsxs("button",{onClick:o,disabled:!u,className:`flex-1 flex items-center gap-3 px-3 py-2.5 text-left transition-all duration-150 ${m(s,u)}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:`flex-shrink-0 w-8 h-8 flex items-center justify-center ${d?"bg-blue-500/10":"bg-violet-500/10"}`,style:{borderRadius:"var(--radius-card)"},children:d?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:t.name}),a&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--color-accent-500)]",title:"Thème personnalisé"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)] truncate",children:t.organisationName||t.slug}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Mo[t.status]}`}),t.status!=="Active"&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:Oo[t.status]})]})]})]}),s&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] flex-shrink-0"})]}),c&&u&&e.jsx("button",{onClick:p=>{p.stopPropagation(),c()},className:`p-2 transition-colors ${r?"text-amber-500":"text-[var(--text-tertiary)] opacity-0 group-hover:opacity-100 hover:text-amber-500"}`,title:r?"Retirer des favoris":"Ajouter aux favoris",children:e.jsx(l.Star,{className:`w-4 h-4 ${r?"fill-amber-500":""}`})})]})}const la="tenant_recents",as=5;function ca(){try{return JSON.parse(localStorage.getItem(la)||"[]")}catch{return[]}}function Fo(t){const s=ca().filter(r=>r!==t);s.unshift(t),localStorage.setItem(la,JSON.stringify(s.slice(0,as)))}const _o=(t,s,r)=>{const a=o=>{t.current&&!t.current.contains(o.target)&&(s(!1),r(""))};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},qo=(t,s)=>{const r=a=>{a.key==="Escape"&&(t(!1),s(""))};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},Uo=(t,s,r,a,o)=>{const c=n.useMemo(()=>t.filter(u=>s.includes(u.id)&&u.status==="Active"),[t,s]),i=n.useMemo(()=>{if(o.trim())return[];const u=new Set(s);return r.map(m=>a.find(p=>p.id===m)).filter(m=>!!m&&m.status==="Active"&&!u.has(m.id)).slice(0,as)},[r,a,s,o]),d=n.useMemo(()=>{const u=new Set([...s,...r.slice(0,as)]);return t.filter(m=>!u.has(m.id))},[t,s,r]);return{favoriteTenants:c,recentTenants:i,otherTenants:d}};function zo(){const{t}=ne.useTranslation("navigation"),{refreshMenu:s}=Ce(),{currentTenant:r,userTenants:a,switchTenant:o,isLoading:c,hasMultipleTenants:i,hasGlobalRoles:d,isGlobalView:u,enterGlobalView:m}=Ee(),{tenantOverrides:p,loadTenantOverrides:f}=St(),[h,b]=n.useState(!1),[g,y]=n.useState(""),[x]=n.useState(()=>ca()),j=n.useRef(null),v=n.useRef(null),{favorites:S,loadFavorites:N,toggleFavorite:I,recordRecent:P}=Do();n.useEffect(()=>{h&&(N(),f())},[h,N,f]),n.useEffect(()=>{h&&v.current&&setTimeout(()=>v.current?.focus(),100)},[h]),n.useEffect(()=>_o(j,b,y),[]),n.useEffect(()=>qo(b,y),[]);const k=n.useCallback(async T=>{if(T===r?.id&&!u){b(!1);return}try{Fo(T),P(T),await o(T),b(!1),y(""),await s()}catch(z){console.error("Failed to switch tenant:",z)}},[r?.id,u,o,s,P]),A=n.useCallback(async()=>{await m(),b(!1),y(""),await s()},[m,s]),R=n.useCallback(async T=>{await I(T)},[I]),$=n.useMemo(()=>{if(!g.trim())return a;const T=g.toLowerCase();return a.filter(z=>z.name.toLowerCase().includes(T)||z.slug.toLowerCase().includes(T)||z.organisationName?.toLowerCase().includes(T))},[a,g]),{favoriteTenants:q,recentTenants:C,otherTenants:D}=Uo($,S,x,a,g);if(c)return null;if(!(i||d)&&r){const T=r.type==="Business";return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-button)"},children:[T?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r.name})]})}return e.jsxs("div",{ref:j,className:"relative",children:[e.jsxs("button",{onClick:()=>b(!h),className:`flex items-center gap-2 px-3 py-1.5 border transition-colors ${u?"bg-emerald-500/10 border-emerald-500/30 hover:bg-emerald-500/20":"bg-[var(--bg-secondary)] border-[var(--border-color)] hover:bg-[var(--bg-tertiary)]"}`,style:{borderRadius:"var(--radius-button)"},"aria-expanded":h,"aria-haspopup":"true",children:[u&&e.jsxs(e.Fragment,{children:[e.jsx(l.Globe,{className:"w-4 h-4 text-emerald-600"}),e.jsx("span",{className:"text-sm font-medium text-emerald-700",children:t("tenants.selector.global","Global")})]}),!u&&r&&e.jsxs(e.Fragment,{children:[r.type==="Business"?e.jsx(l.Building2,{className:"w-4 h-4 text-blue-500"}):e.jsx(l.User,{className:"w-4 h-4 text-violet-500"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)] max-w-[120px] truncate",children:r.name})]}),!u&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(l.Building2,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("tenants.selector.select","Select")})]}),e.jsx(l.ChevronDown,{className:`w-4 h-4 text-[var(--text-tertiary)] transition-transform ${h?"rotate-180":""}`})]}),e.jsx("div",{className:`absolute left-0 mt-2 w-80 origin-top-left transition-all duration-200 ease-out z-50 ${h?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"}`,children:e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border-color)] shadow-xl overflow-hidden",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"relative",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{ref:v,type:"text",value:g,onChange:T=>y(T.target.value),placeholder:t("tenants.selector.search","Rechercher..."),className:"w-full pl-9 pr-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] focus:border-[var(--color-accent-500)] focus:outline-none",style:{borderRadius:"var(--radius-input)"}})]})}),e.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[d&&!g&&e.jsx("div",{className:"p-2 border-b border-[var(--border-color)]",children:e.jsxs("button",{onClick:A,className:`w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all duration-150 ${u?"bg-emerald-500/10 text-emerald-700":"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-emerald-500/10 flex items-center justify-center",style:{borderRadius:"var(--radius-card)"},children:e.jsx(l.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",children:t("tenants.selector.global","Global")}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:t("tenants.selector.globalDesc","Voir tous les tenants")})]}),u&&e.jsx(l.Check,{className:"w-4 h-4 text-emerald-600 flex-shrink-0"})]})}),q.length>0&&e.jsxs("div",{className:"p-2",children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Star,{className:"w-3 h-3 text-amber-500"}),t("tenants.selector.favorites","Favoris")]}),e.jsx("div",{className:"mt-1",children:q.map(T=>e.jsx(Wt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:!0,hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),C.length>0&&e.jsxs("div",{className:`p-2 ${q.length>0?"border-t border-[var(--border-color)]":""}`,children:[e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Clock,{className:"w-3 h-3"}),t("tenants.selector.recent","Récents")]}),e.jsx("div",{className:"mt-1",children:C.map(T=>e.jsx(Wt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:S.includes(T.id),hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),D.length>0&&e.jsxs("div",{className:`p-2 ${q.length>0||C.length>0?"border-t border-[var(--border-color)]":""}`,children:[!g&&e.jsxs("p",{className:"px-2 py-1 text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(l.Building2,{className:"w-3 h-3"}),t("tenants.selector.all","Tous")]}),e.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto",children:D.map(T=>e.jsx(Wt,{tenant:T,isSelected:!u&&r?.id===T.id,isFavorite:S.includes(T.id),hasThemeOverride:p.includes(T.id),onSelect:()=>k(T.id),onToggleFavorite:()=>R(T.id)},T.id))})]}),g&&$.length===0&&e.jsx("div",{className:"p-4 text-center text-sm text-[var(--text-tertiary)]",children:t("tenants.selector.noResults","Aucun résultat")})]}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs(w.Link,{to:"/myspace/tenants",className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},onClick:()=>b(!1),children:[e.jsx(l.Eye,{className:"w-4 h-4"}),t("tenants.selector.viewAll","Voir tous mes espaces")," (",a.length,")"]})})]})})]})}function vs(t,s){return t?s===t?"current":"other":"global"}const Bo={getOverview:(t=30)=>E.get("/api/support/dashboard/overview",{params:{days:t}}),getByStatus:()=>E.get("/api/support/dashboard/by-status"),getByPriority:()=>E.get("/api/support/dashboard/by-priority"),getByType:(t=30)=>E.get("/api/support/dashboard/by-type",{params:{days:t}}),getAgentWorkload:()=>E.get("/api/support/dashboard/agent-workload"),getTrends:(t=30)=>E.get("/api/support/dashboard/trends",{params:{days:t}}),getSatisfactionStats:(t=30)=>E.get("/api/support/dashboard/satisfaction",{params:{days:t}}),getSlaCompliance:(t=30)=>E.get("/api/support/dashboard/sla-compliance",{params:{days:t}})},da={getConfigurations:()=>E.get("/api/support/sla/configurations"),updateConfiguration:(t,s)=>E.put(`/api/support/sla/configurations/${t}`,s),getEscalationRules:()=>E.get("/api/support/sla/escalation-rules"),getBreachedTickets:(t=!0,s=!0)=>E.get("/api/support/sla/breached",{params:{responseBreached:t,resolutionBreached:s}}),getTicketsApproachingBreach:(t=60)=>E.get("/api/support/sla/approaching-breach",{params:{warningMinutes:t}}),getMetrics:(t,s)=>E.get("/api/support/sla/metrics",{params:{fromDate:t,toDate:s}}),escalateTicket:(t,s,r)=>E.post(`/api/support/sla/tickets/${t}/escalate`,{level:s,reason:r})},st={getAll:(t=1,s=20,r,a)=>E.get("/api/support/notifications",{params:{page:t,pageSize:s,isRead:r,tenantId:a}}),getUnread:(t=10)=>E.get("/api/support/notifications/unread",{params:{limit:t}}),getUnreadCount:()=>E.get("/api/support/notifications/unread/count"),markAsRead:t=>E.patch(`/api/support/notifications/${t}/read`),markAllAsRead:()=>E.patch("/api/support/notifications/read-all"),delete:t=>E.delete(`/api/support/notifications/${t}`),deleteAll:()=>E.delete("/api/support/notifications/all"),getPreferences:()=>E.get("/api/support/notifications/preferences"),updatePreferences:t=>E.put("/api/support/notifications/preferences",t)},Lt={getAll:(t,s=!0,r)=>E.get("/api/support/templates",{params:{category:t,activeOnly:s,language:r}}),getById:t=>E.get(`/api/support/templates/${t}`),getCategories:()=>E.get("/api/support/templates/categories"),getByCategory:t=>E.get(`/api/support/templates/by-category/${t}`),create:t=>E.post("/api/support/templates",t),update:(t,s)=>E.put(`/api/support/templates/${t}`,s),activate:t=>E.patch(`/api/support/templates/${t}/activate`),deactivate:t=>E.patch(`/api/support/templates/${t}/deactivate`),delete:t=>E.delete(`/api/support/templates/${t}`),render:(t,s)=>E.post(`/api/support/templates/${t}/render`,{variables:s})},ns={STARTED:"EntraSyncStarted",COMPLETED:"EntraSyncCompleted",FAILED:"EntraSyncFailed"};function Go(t,s,r){if(r){const o=s.relatedEntityId,c=t.filter(i=>!(i.type===ns.STARTED&&i.relatedEntityId===o));return[s,...c].slice(0,10)}return t.some(o=>o.id===s.id)?t:[s,...t].slice(0,10)}function Ko(t){return{id:t.id,type:t.type,title:t.title,message:t.message,relatedEntityType:t.relatedEntityType,relatedEntityId:t.relatedEntityId,actionUrl:t.actionUrl,isRead:t.isRead,readAt:t.readAt,createdAt:t.createdAt,tenantId:t.tenantId,tenantName:t.tenantName,tenantSlug:t.tenantSlug}}function Ho(){const[t,s]=n.useState(0),[r,a]=n.useState([]),[o,c]=n.useState(!1),{isConnected:i,onNotification:d,onUnreadCountUpdate:u}=Or(),{isFeatureEnabled:m}=He(),p=m("support");n.useEffect(()=>{const x=d(v=>{const S=Ko(v),N=v.type===ns.COMPLETED||v.type===ns.FAILED;a(I=>Go(I,S,N))}),j=u(v=>{s(v)});return()=>{x(),j()}},[d,u]),n.useEffect(()=>{if(!p)return;let x=!1;async function j(){try{const v=await st.getUnreadCount();x||s(v.count)}catch(v){x||console.error("Failed to load unread count:",v)}}return j(),()=>{x=!0}},[p]);const f=n.useCallback(async()=>{if(p)try{c(!0);const x=await st.getUnread(10);a(x)}catch(x){console.error("Failed to load notifications:",x)}finally{c(!1)}},[p]),h=n.useCallback(async x=>{try{await st.markAsRead(x),a(j=>j.map(v=>v.id===x?{...v,isRead:!0}:v)),s(j=>Math.max(0,j-1))}catch(j){console.error("Failed to mark as read:",j)}},[]),b=n.useCallback(async()=>{try{await st.markAllAsRead(),a(x=>x.map(j=>({...j,isRead:!0}))),s(0)}catch(x){console.error("Failed to mark all as read:",x)}},[]),g=n.useCallback(async x=>{try{await st.delete(x);const j=r.find(v=>v.id===x);a(v=>v.filter(S=>S.id!==x)),j&&!j.isRead&&s(v=>Math.max(0,v-1))}catch(j){console.error("Failed to delete notification:",j)}},[r]),y=n.useCallback(x=>{st.markAsRead(x),s(j=>Math.max(0,j-1))},[]);return{notifications:r,unreadCount:t,loading:o,isConnected:i,loadNotifications:f,markAsRead:h,markAllAsRead:b,deleteNotification:g,markAsReadSilent:y}}const bt={STARTED:"EntraSyncStarted",COMPLETED:"EntraSyncCompleted",FAILED:"EntraSyncFailed"};function ua(){const t=w.useNavigate(),{currentTenant:s,hasMultipleTenants:r}=Ee(),[a,o]=n.useState(!1),c=n.useRef(null),{notifications:i,unreadCount:d,loading:u,isConnected:m,loadNotifications:p,markAsRead:f,markAllAsRead:h,deleteNotification:b,markAsReadSilent:g}=Ho(),[,y]=n.useState(0);n.useEffect(()=>{if(!i.some(R=>R.type===bt.STARTED&&!R.isRead))return;const A=setInterval(()=>{y(R=>R+1)},1e3);return()=>clearInterval(A)},[i]),n.useEffect(()=>{a&&p()},[a,p]),n.useEffect(()=>{const k=A=>{c.current&&!c.current.contains(A.target)&&o(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);const x=(k,A)=>{A.stopPropagation(),f(k)},j=(k,A)=>{A.stopPropagation(),b(k)},v=k=>{k.isRead||g(k.id),o(!1),k.actionUrl&&t(k.actionUrl)},S=k=>{switch(k){case"TicketCreated":return"🎫";case"TicketAssigned":return"👤";case"TicketStatusChanged":case"StatusChanged":return"🔄";case"TicketCommented":case"CommentAdded":return"💬";case"TicketResolved":return"✅";case"TicketClosed":return"🔒";case"TicketUpdated":return"📝";case"SlaResponseBreached":case"SlaResolutionBreached":return"⚠️";case"SlaWarning":return"⏰";case"TicketEscalated":return"📈";case"SatisfactionRequested":return"⭐";case"GroupMemberAdded":return"👥";case"GroupMemberRemoved":return"🚪";case"RoleAssigned":return"🎭";case"RoleRemoved":return"🚫";case"RolePermissionsChanged":return"🔑";case"AccountUpdated":return"👤";case"SystemAnnouncement":return"📢";case bt.STARTED:return null;case bt.COMPLETED:return"✅";case bt.FAILED:return"❌";default:return"📌"}},N=k=>{const A=new Date(k).getTime(),R=Date.now(),$=Math.floor((R-A)/1e3),q=Math.floor($/60),C=$%60;return`${q.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`},I=k=>{const A=new Date(k),$=new Date().getTime()-A.getTime(),q=Math.floor($/6e4),C=Math.floor(q/60),D=Math.floor(C/24);return q<1?"Just now":q<60?`${q}m ago`:C<24?`${C}h ago`:D<7?`${D}d ago`:A.toLocaleDateString()},P=k=>{if(!r)return null;const A=vs(k.tenantId,s?.id??null);return A==="global"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-700",children:"System"}):A==="current"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] truncate max-w-[120px]",children:k.tenantName}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700 font-medium truncate max-w-[120px]",children:k.tenantName})};return e.jsxs("div",{className:"relative",ref:c,children:[e.jsxs("button",{onClick:()=>o(!a),className:"relative p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors","aria-label":"Notifications",children:[e.jsx(l.Bell,{className:"w-5 h-5"}),d>0&&e.jsx("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-red-500 text-white text-xs font-bold rounded-full flex items-center justify-center",children:d>9?"9+":d})]}),a&&e.jsxs("div",{className:"absolute right-0 mt-2 w-96 bg-[var(--bg-primary)] rounded-lg shadow-xl border border-[var(--border-color)] z-50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:"Notifications"}),m?e.jsx("span",{title:"Real-time connected",children:e.jsx(l.Wifi,{className:"w-3 h-3 text-green-500"})}):e.jsx("span",{title:"Offline mode",children:e.jsx(l.WifiOff,{className:"w-3 h-3 text-gray-400"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d>0&&e.jsxs("button",{onClick:h,className:"text-sm text-[var(--color-primary-600)] hover:underline flex items-center gap-1",children:[e.jsx(l.CheckCheck,{className:"w-4 h-4"}),"Mark all read"]}),e.jsx("button",{onClick:()=>o(!1),className:"p-1 rounded hover:bg-[var(--bg-hover)]",children:e.jsx(l.X,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"max-h-96 overflow-y-auto",children:[u&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}),!u&&i.length>0&&i.map(k=>{const A=k.type===bt.STARTED&&!k.isRead,R=S(k.type);return e.jsx("div",{role:"button",tabIndex:0,onClick:()=>v(k),onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),v(k))},className:`w-full text-left p-4 border-b border-[var(--border-color)] cursor-pointer hover:bg-[var(--bg-hover)] transition-colors ${k.isRead?"":"bg-blue-50/50 dark:bg-blue-900/10"} ${A?"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20":""}`,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"text-xl flex-shrink-0",children:A?e.jsx(l.RefreshCw,{className:"w-5 h-5 text-[var(--color-accent-600)] animate-spin"}):R}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:`text-sm ${k.isRead?"":"font-semibold"}`,children:k.title}),P(k)]}),A?e.jsxs("span",{className:"text-xs font-mono font-bold text-[var(--color-accent-600)] flex-shrink-0 bg-[var(--color-accent-100)] px-2 py-0.5 rounded",children:["⏱ ",N(k.createdAt)]}):e.jsx("span",{className:"text-xs text-[var(--text-secondary)] flex-shrink-0",children:I(k.createdAt)})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] line-clamp-2 mt-1",children:k.message})]}),e.jsxs("div",{className:"flex flex-col gap-1 flex-shrink-0",children:[!k.isRead&&!A&&e.jsx("button",{onClick:$=>x(k.id,$),className:"p-1 rounded hover:bg-[var(--bg-secondary)]",title:"Mark as read",children:e.jsx(l.Check,{className:"w-4 h-4 text-green-600"})}),!A&&e.jsx("button",{onClick:$=>j(k.id,$),className:"p-1 rounded hover:bg-[var(--bg-secondary)]",title:"Delete",children:e.jsx(l.Trash2,{className:"w-4 h-4 text-red-500"})})]})]})},k.id)}),!u&&i.length===0&&e.jsxs("div",{className:"py-8 text-center text-[var(--text-secondary)]",children:[e.jsx(l.Bell,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No notifications"})]})]}),e.jsx("div",{className:"p-3 border-t border-[var(--border-color)] text-center",children:e.jsx("button",{onClick:()=>{o(!1),t("/notifications")},className:"text-sm text-[var(--color-primary-600)] hover:underline",children:"View all notifications"})})]})]})}const Vo={default:{bg:"bg-[var(--bg-tertiary)]",text:"text-[var(--text-primary)]",border:"border-[var(--border-color)]",arrow:"bg-[var(--bg-tertiary)] border-[var(--border-color)]"},error:{bg:"bg-[var(--tooltip-error-bg)]",text:"text-[var(--error-text)]",border:"border-[var(--error-border)]",arrow:"bg-[var(--tooltip-error-bg)] border-[var(--error-border)]"},warning:{bg:"bg-[var(--tooltip-warning-bg)]",text:"text-[var(--warning-text)]",border:"border-[var(--warning-border)]",arrow:"bg-[var(--tooltip-warning-bg)] border-[var(--warning-border)]"},success:{bg:"bg-[var(--tooltip-success-bg)]",text:"text-[var(--success-text)]",border:"border-[var(--success-border)]",arrow:"bg-[var(--tooltip-success-bg)] border-[var(--success-border)]"},info:{bg:"bg-[var(--tooltip-info-bg)]",text:"text-[var(--info-text)]",border:"border-[var(--info-border)]",arrow:"bg-[var(--tooltip-info-bg)] border-[var(--info-border)]"}};function ma({content:t,children:s,position:r="top",variant:a="default",delay:o=200,disabled:c=!1,className:i=""}){const d=Vo[a],[u,m]=n.useState(!1),[p,f]=n.useState({top:0,left:0}),h=n.useRef(null),b=n.useRef(null),g=n.useRef(null),y=()=>{if(!h.current||!b.current)return;const S=h.current.getBoundingClientRect(),N=b.current.getBoundingClientRect(),I=window.scrollX,P=window.scrollY,k=8;let A=0,R=0;switch(r){case"top":A=S.top+P-N.height-k,R=S.left+I+(S.width-N.width)/2;break;case"bottom":A=S.bottom+P+k,R=S.left+I+(S.width-N.width)/2;break;case"left":A=S.top+P+(S.height-N.height)/2,R=S.left+I-N.width-k;break;case"right":A=S.top+P+(S.height-N.height)/2,R=S.right+I+k;break}const $=window.innerWidth,q=window.innerHeight,C=8;R<C?R=C:R+N.width>$-C&&(R=$-N.width-C),A<C+P?A=C+P:A+N.height>q+P-C&&(A=q+P-N.height-C),f({top:A,left:R})};n.useEffect(()=>(u&&(y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y)),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}),[u,r]);const x=()=>{c||!t||(g.current=setTimeout(()=>{m(!0)},o))},j=()=>{g.current&&(clearTimeout(g.current),g.current=null),m(!1)};n.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const v=()=>{const S=`absolute w-2 h-2 ${d.arrow} transform rotate-45`;switch(r){case"top":return`${S} -bottom-1 left-1/2 -translate-x-1/2 border-r border-b`;case"bottom":return`${S} -top-1 left-1/2 -translate-x-1/2 border-l border-t`;case"left":return`${S} -right-1 top-1/2 -translate-y-1/2 border-t border-r`;case"right":return`${S} -left-1 top-1/2 -translate-y-1/2 border-b border-l`}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:h,onMouseEnter:x,onMouseLeave:j,onFocus:x,onBlur:j,className:"inline-flex",children:s}),u&&t&&Ft.createPortal(e.jsxs("div",{ref:b,role:"tooltip",style:{position:"absolute",top:p.top,left:p.left,zIndex:9999},className:`
3
3
  px-3 py-2 text-sm font-medium
4
4
  ${d.bg} ${d.text}
5
5
  border ${d.border}
@@ -8,25 +8,25 @@
8
8
  max-w-xs
9
9
  tooltip-animation
10
10
  ${i}
11
- `,children:[t,e.jsx("div",{className:v()})]}),document.body)]})}const It="support_error_context";class Ho{async captureContext(){const s={url:window.location.href,timestamp:new Date,recentErrors:Te.getRecentErrors(),browserInfo:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,screenWidth:window.screen.width,screenHeight:window.screen.height}};try{const r=await this.captureScreenshot();s.screenshot=r}catch{Te.logError(new Error("Failed to capture screenshot"),"ErrorContextService")}return s}async captureScreenshot(){try{const r=await As.domToJpeg(document.body,{scale:1,quality:.85,backgroundColor:"#1a1a2e",style:{transform:"none"},filter:a=>{if(a instanceof HTMLElement){const o=a.tagName?.toUpperCase();return o!=="IFRAME"&&o!=="VIDEO"}return!0}});return r.length>4*1024*1024?await this.recompressScreenshot(r,.7):r}catch(s){console.error("[ErrorContextService] Screenshot capture failed:",s);try{return await As.domToJpeg(document.body,{scale:.75,quality:.8,backgroundColor:"#1a1a2e"})}catch(r){console.error("[ErrorContextService] Fallback also failed:",r);return}}}async recompressScreenshot(s,r){return new Promise(a=>{const o=new Image;o.onload=()=>{const c=document.createElement("canvas");c.width=o.width,c.height=o.height;const i=c.getContext("2d");if(i){i.drawImage(o,0,0);const d=c.toDataURL("image/jpeg",r);a(d)}else a(s)},o.onerror=()=>a(s),o.src=s})}saveContext(s){try{const r=JSON.stringify(s);try{sessionStorage.setItem(It,r)}catch{const o={...s,screenshot:void 0};sessionStorage.setItem(It,JSON.stringify(o))}}catch(r){console.error("[ErrorContextService] Failed to save context:",r)}}loadContext(){try{const s=sessionStorage.getItem(It);if(s){const r=JSON.parse(s);return r.timestamp=new Date(r.timestamp),r.recentErrors=r.recentErrors.map(a=>({...a,timestamp:new Date(a.timestamp)})),r.screenshot&&!r.screenshot.startsWith("data:image/")&&(r.screenshot=void 0),r}}catch(s){console.warn("[ErrorContextService] Failed to load context:",s)}return null}clearContext(){sessionStorage.removeItem(It)}formatErrorsForDescription(s){return s.length===0?"":s.slice(0,5).map((a,o)=>{const c=a.timestamp.toLocaleTimeString();return`${o+1}. [${c}] ${a.message}${a.component?` (${a.component})`:""}`}).join(`
12
- `)}}const $t=new Ho,Wt="ticket_drafts",Os=5,Fs=7;class Vo{getDrafts(){try{const s=localStorage.getItem(Wt);return s?JSON.parse(s).map(a=>({...a,createdAt:new Date(a.createdAt),updatedAt:new Date(a.updatedAt)})):[]}catch{return[]}}saveDrafts(s){try{const r=s.map(o=>({...o,createdAt:o.createdAt.toISOString(),updatedAt:o.updatedAt.toISOString()})),a=JSON.stringify(r);return localStorage.setItem(Wt,a),!0}catch(r){if(console.error("[TicketDraftService] Failed to save drafts:",r),r instanceof DOMException&&r.name==="QuotaExceededError")try{const a=s.map(o=>({...o,screenshot:void 0,attachments:void 0,createdAt:o.createdAt.toISOString(),updatedAt:o.updatedAt.toISOString()}));return localStorage.setItem(Wt,JSON.stringify(a)),!0}catch(a){console.error("[TicketDraftService] Still failed without large data:",a)}return!1}}cleanupExpiredDrafts(){const s=this.getDrafts(),r=new Date,a=Fs*24*60*60*1e3,o=s.filter(c=>r.getTime()-c.updatedAt.getTime()<a);o.length!==s.length&&this.saveDrafts(o)}getAllDrafts(){return this.cleanupExpiredDrafts(),this.getDrafts().sort((s,r)=>r.updatedAt.getTime()-s.updatedAt.getTime())}getDraft(s){return this.getAllDrafts().find(a=>a.id===s)||null}createDraft(){const s=this.getAllDrafts();if(s.length>=Os){const c=s.at(-1);this.deleteDraft(c.id)}const r=new Date,a={id:crypto.randomUUID(),type:null,title:"",description:"",priority:"Medium",includeScreenshot:!0,includeErrorLogs:!0,createdAt:r,updatedAt:r},o=[a,...this.getDrafts().slice(0,Os-1)];return this.saveDrafts(o),a}updateDraft(s,r){const a=this.getDrafts(),o=a.findIndex(d=>d.id===s);if(o===-1)return{success:!1,draft:null};const c={...a[o],...r,updatedAt:new Date};a[o]=c;const i=this.saveDrafts(a);return{success:i,draft:i?c:null}}deleteDraft(s){const r=this.getDrafts(),a=r.filter(o=>o.id!==s);return a.length===r.length?!1:(this.saveDrafts(a),!0)}getDraftCount(){return this.getAllDrafts().length}hasDrafts(){return this.getDraftCount()>0}getTimeUntilExpiration(s){const r=Fs*24*60*60*1e3,a=s.updatedAt.getTime()+r,o=Math.max(0,a-Date.now()),c=Math.floor(o/(1440*60*1e3)),i=Math.floor(o%(1440*60*1e3)/(3600*1e3));return{days:c,hours:i}}}const Ge=new Vo;function ma({variant:t="icon",className:s=""}){const{t:r}=ne.useTranslation(["common","support"]),a=w.useNavigate(),{hasPermission:o}=Pe(),[c,i]=n.useState(!1),[d,u]=n.useState(!1),[m,p]=n.useState([]),f=n.useRef(null),g=o("support.my-tickets.create");n.useEffect(()=>{d&&p(Ge.getAllDrafts())},[d]),n.useEffect(()=>{const S=N=>{f.current&&!f.current.contains(N.target)&&u(!1)};return d&&document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[d]);const b=async S=>{i(!0),u(!1);const I=(S?Ge.getDraft(S):null)?.screenshot;let P=null;if(I)$t.clearContext();else try{P=await $t.captureContext(),$t.saveContext(P)}catch{}i(!1);const k=S?`/support/my-tickets/create?draft=${S}`:"/support/my-tickets/create";a(k)},h=async()=>{const S=Ge.getAllDrafts();S.length>0?(p(S),u(!0)):await b()},y=(S,N)=>{S.stopPropagation(),Ge.deleteDraft(N);const I=Ge.getAllDrafts();p(I),I.length===0&&u(!1)},x=S=>S.title?S.title.length>30?S.title.substring(0,30)+"...":S.title:S.type?r(`support:tickets.types.${S.type}`):r("common:drafts.untitled"),j=S=>{const I=new Date().getTime()-S.getTime(),P=Math.floor(I/6e4),k=Math.floor(I/36e5),A=Math.floor(I/864e5);return P<1?r("common:drafts.justNow"):P<60?r("common:drafts.minutesAgo",{count:P}):k<24?r("common:drafts.hoursAgo",{count:k}):r("common:drafts.daysAgo",{count:A})};if(!g)return null;const v=()=>e.jsxs("div",{ref:f,className:"absolute right-0 top-full mt-2 w-80 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-xl z-50",children:[e.jsxs("div",{className:"p-3 border-b border-[var(--border-color)]",children:[e.jsx("h3",{className:"font-medium text-sm",children:r("common:drafts.existingDrafts")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:r("common:drafts.selectOrCreate")})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto",children:m.map(S=>{const N=Ge.getTimeUntilExpiration(S);return e.jsxs("button",{type:"button",onClick:()=>b(S.id),className:"w-full p-3 flex items-start gap-3 hover:bg-[var(--bg-hover)] transition-colors text-left border-b border-[var(--border-color)] last:border-b-0 cursor-pointer",children:[e.jsx(l.FileEdit,{className:"w-4 h-4 text-[var(--text-secondary)] mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:x(S)}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)] mt-1 flex-wrap",children:[S.tenantName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] truncate max-w-[120px]",children:S.tenantName}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"•"})]}),e.jsx(l.Clock,{className:"w-3 h-3"}),e.jsx("span",{children:j(S.updatedAt)}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"•"}),e.jsx("span",{className:"text-[var(--warning-text)]",children:N.days>0?r("common:drafts.expiresInDays",{count:N.days}):r("common:drafts.expiresInHours",{count:N.hours})})]})]}),e.jsx("button",{onClick:I=>y(I,S.id),className:"p-1.5 rounded hover:bg-[var(--error-bg)] text-[var(--text-secondary)] hover:text-[var(--error-text)] transition-colors",title:r("common:actions.delete"),children:e.jsx(l.Trash2,{className:"w-4 h-4"})})]},S.id)})}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs("button",{onClick:()=>b(),className:"w-full flex items-center justify-center gap-2 px-4 py-2 bg-[var(--color-primary-600)] text-white rounded-lg hover:bg-[var(--color-primary-700)] transition-colors text-sm",children:[e.jsx(l.Plus,{className:"w-4 h-4"}),r("common:drafts.createNew")]})})]});return t==="icon"?e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(ua,{content:r("common:actions.createTicket"),position:"bottom",children:e.jsx("button",{onClick:h,disabled:c,className:`p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-50 ${s}`,children:c?e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}):e.jsx(l.Headset,{className:"w-5 h-5"})})}),d&&v()]}):e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:h,disabled:c,className:`flex items-center gap-2 px-4 py-2 bg-[var(--color-primary-600)] text-white rounded-lg hover:bg-[var(--color-primary-700)] transition-colors disabled:opacity-50 ${s}`,children:[c?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Headset,{className:"w-4 h-4"}),r("common:actions.createTicket")]}),d&&v()]})}function wt({onMenuToggle:t}){const{t:s}=ne.useTranslation("navigation"),[r,a]=n.useState(!1),o=Ze(),{menu:c}=Ce(),{logout:i}=Pe(),d=c?.applications||[];return e.jsx("header",{className:"fixed top-0 left-0 right-0 z-50 bg-[var(--bg-primary)]/80 backdrop-blur-lg border-b border-[var(--border-color)]",children:e.jsxs("nav",{className:"px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[t&&e.jsx("button",{onClick:t,className:"lg:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.Menu,{className:"w-5 h-5"})}),e.jsxs(w.Link,{to:o("/applications"),className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-10 h-10 animated-gradient flex items-center justify-center",style:{borderRadius:"var(--radius-card)"},children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qo,{}),e.jsx("div",{className:"h-6 w-px bg-[var(--border-color)]"}),e.jsx(oa,{}),e.jsx("div",{className:"h-6 w-px bg-[var(--border-color)]"}),e.jsx(gs,{}),e.jsx(Gt,{}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 pl-3 border-l border-[var(--border-color)]",children:[!1,e.jsx(ma,{}),e.jsx(da,{}),e.jsx(na,{})]}),e.jsx("button",{onClick:()=>a(!r),className:"sm:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:r?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})})]})]}),r&&e.jsx("div",{className:"sm:hidden py-4 border-t border-[var(--border-color)]",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[d.map(u=>e.jsx(w.Link,{to:o(u.route||"#"),className:"px-3 py-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},onClick:()=>a(!1),children:u.label},u.id)),e.jsx("hr",{className:"my-2 border-[var(--border-color)]"}),e.jsxs("button",{onClick:()=>{a(!1),i()},className:"flex items-center gap-2 px-3 py-2 hover:bg-[var(--bg-tertiary)] transition-colors text-red-500",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),s("header.logout")]})]})})]})})}function as({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function ns(t){if(!t)return l.Box;const s=xt;if(s[t])return s[t];const r=t.toLowerCase(),a=Object.keys(s).find(o=>o.toLowerCase()===r);return a?s[a]:l.Box}function Wo({module:t,isActive:s,isCollapsed:r,onClose:a,buildUrl:o}){const[c,i]=n.useState(!1),[d,u]=n.useState({top:0,left:0}),m=n.useRef(null),p=n.useRef(null),f=()=>{if(r){if(m.current&&(clearTimeout(m.current),m.current=null),p.current){const b=p.current.getBoundingClientRect();u({top:b.top,left:b.right+8})}i(!0)}},g=()=>{r&&(m.current=setTimeout(()=>{i(!1)},150))};return n.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),e.jsxs("div",{ref:p,className:"relative",onMouseEnter:f,onMouseLeave:g,children:[e.jsxs(w.Link,{to:o(t.route),onClick:a,className:`flex items-center transition-colors ${r?"justify-center px-2 py-2":"gap-3 px-3 py-2"} ${s?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:r?`${t.label} (${t.applicationLabel})`:void 0,children:[e.jsx(as,{name:t.icon,className:"w-4 h-4 flex-shrink-0"}),!r&&e.jsx("span",{className:"text-sm font-medium truncate",children:t.label})]}),r&&c&&Ot.createPortal(e.jsx("div",{className:"fixed z-[9999] pointer-events-auto",style:{top:d.top,left:d.left},onMouseEnter:f,onMouseLeave:g,children:e.jsx("div",{className:"px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg whitespace-nowrap",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.label})})}),document.body)]})}function Xo({module:t,isExpanded:s,onToggle:r,onNavigate:a,currentPath:o,isCollapsed:c}){const[i,d]=n.useState(!1),[u,m]=n.useState({top:0,left:0}),[p,f]=n.useState(new Set),g=n.useRef(null),b=n.useRef(null),h=ns(t.icon),y=t.route?o===t.route:o.includes(`/${t.code}`),x=(t.sections?.length??0)>0,j=t.label;n.useEffect(()=>{if(!t.sections)return;const P=t.sections.find(k=>k.resources?.some(A=>A.route&&o.startsWith(A.route)));P&&!p.has(P.id)&&f(k=>new Set([...k,P.id]))},[o,t.sections,p]);const v=P=>{f(k=>{const A=new Set(k);return A.has(P)?A.delete(P):A.add(P),A})},S=()=>{if(c){if(g.current&&(clearTimeout(g.current),g.current=null),b.current){const P=b.current.getBoundingClientRect();m({top:P.top,left:P.right+8})}d(!0)}},N=()=>{c&&(g.current=setTimeout(()=>{d(!1)},150))};n.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const I=()=>{x&&!c?r():t.route&&a(t.route)};return e.jsxs("div",{ref:b,className:"relative",onMouseEnter:S,onMouseLeave:N,children:[e.jsxs("button",{onClick:I,className:`w-full flex items-center transition-all duration-200 ${c?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${y?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:c&&!x?j:void 0,children:[e.jsx(h,{className:"w-5 h-5 flex-shrink-0"}),!c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left font-medium text-sm truncate",children:j}),x&&(s?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}))]})]}),c&&i&&Ot.createPortal(e.jsx("div",{className:"fixed z-[9999] pointer-events-auto",style:{top:u.top,left:u.left},onMouseEnter:S,onMouseLeave:N,children:e.jsxs("div",{className:"min-w-[200px] bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"px-3 py-2 border-b border-[var(--border-color)]",children:e.jsx("span",{className:"text-sm font-semibold text-[var(--text-primary)]",children:j})}),e.jsx("div",{className:"p-1.5",children:x?t.sections.map(P=>{const k=ns(P.icon),A=P.route&&o===P.route;return e.jsxs("button",{onClick:()=>P.route&&a(P.route),className:`w-full flex items-center gap-2.5 px-2.5 py-2 transition-colors ${A?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(k,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:P.label})]},P.id)}):t.route&&e.jsxs("button",{onClick:()=>a(t.route),className:"w-full flex items-center gap-2.5 px-2.5 py-2 hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(h,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:"Ouvrir"})]})})]})}),document.body),!c&&s&&x&&e.jsx("div",{className:"ml-4 pl-4 border-l border-[var(--border-color)] mt-1 space-y-1",children:t.sections.map(P=>e.jsx(Yo,{section:P,currentPath:o,onNavigate:a,isCollapsed:c,isExpanded:p.has(P.id),onToggle:()=>v(P.id)},P.id))})]})}function Yo({section:t,currentPath:s,onNavigate:r,isCollapsed:a,isExpanded:o,onToggle:c}){const i=ns(t.icon),d=t.route&&(s===t.route||s.startsWith(t.route+"/")),u=(t.resources?.length??0)>0,m=t.label,p=f=>{f.preventDefault(),t.route&&r(t.route),u&&c()};return a?null:e.jsxs("div",{children:[e.jsxs("button",{onClick:p,className:`w-full flex items-center gap-3 px-3 py-2 transition-all duration-200 ${d?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(i,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"flex-1 text-sm text-left",children:m}),u&&(o?e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)] flex-shrink-0"}):e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)] flex-shrink-0"}))]}),o&&u&&e.jsx("div",{className:"ml-4 pl-3 border-l border-[var(--border-color)] mt-1 space-y-0.5",children:t.resources.map(f=>e.jsx(Jo,{resource:f,currentPath:s,onNavigate:r},f.id))})]})}function Jo({resource:t,currentPath:s,onNavigate:r}){const a=t.route&&s.startsWith(t.route),o=c=>{c.preventDefault(),t.route&&r(t.route)};return e.jsxs("button",{onClick:o,className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 transition-all duration-200 ${a?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-current flex-shrink-0"}),e.jsx("span",{className:"text-xs text-left",children:t.label})]})}const Qo=(t,s)=>{if(t?.modules)return t.modules.find(r=>r.sections?.length?r.sections.some(a=>a.route&&(s===a.route||s.startsWith(a.route+"/"))):!1)},Zo=(t,s)=>!!t.route&&s.startsWith(t.route)&&(t.sections?.length??0)>0,ei=(t,s)=>{if(!t)return;const r=Qo(t,s);return r||t.modules.find(a=>Zo(a,s))};function pa({isOpen:t,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),o=w.useNavigate(),{getCurrentApplication:c,isLoading:i,currentAppCode:d,menu:u}=Ce(),{favorites:m,loading:p}=Ke(),{expandFavorites:f,clearExpand:g}=Ke(),{isCollapsed:b,toggleCollapsed:h}=qt(),y=Ze(),[x,j]=n.useState(new Set),[v,S]=n.useState(!1);n.useEffect(()=>{f&&(queueMicrotask(()=>{S(!1)}),g())},[f,g]);const N=c(),I=n.useCallback(R=>{if(u)for(const $ of u.applications){const q=$.modules.find(C=>C.id===R.id);if(q?.sections?.length){const C=[...q.sections].sort((D,Y)=>D.displayOrder-Y.displayOrder)[0];if(C.route)return C.route}}return R.route},[u]);n.useEffect(()=>{if(!N)return;const R=ei(N,a.pathname);R&&!x.has(R.id)&&queueMicrotask(()=>{j($=>new Set([...$,R.id]))})},[a.pathname,N,x]);const P=R=>{j($=>{const q=new Set($);return q.has(R)?q.delete(R):q.add(R),q})},k=R=>{o(y(R)),s()},A=N?.label??"";return N?e.jsxs(e.Fragment,{children:[t&&e.jsx("button",{type:"button",className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:s,"aria-label":"Close sidebar"}),e.jsxs("aside",{className:`group/sidebar fixed top-16 bottom-0 left-0 bg-[var(--bg-primary)] border-r border-[var(--border-color)] transform transition-all duration-300 z-50 overflow-visible ${b?"w-16":"w-64"} ${t?"translate-x-0":"-translate-x-full lg:translate-x-0"}`,children:[e.jsxs("button",{onClick:h,className:"hidden lg:flex absolute top-1/2 -translate-y-1/2 w-3 h-16 items-center justify-center group/toggle transition-all duration-200 z-[9999]",style:{right:"-12px"},title:b?r("sidebar.expand","Agrandir le menu"):r("sidebar.collapse","Réduire le menu"),children:[e.jsx("div",{className:"absolute left-0 w-[3px] h-full bg-[var(--border-color)] group-hover/toggle:bg-[var(--color-accent-500)] transition-colors duration-200 rounded-full"}),e.jsx("div",{className:"absolute right-0 w-4 h-4 flex items-center justify-center bg-[var(--bg-secondary)] border border-[var(--border-color)] group-hover/toggle:border-[var(--color-accent-500)] group-hover/toggle:text-[var(--color-accent-500)] text-[var(--text-muted)] rounded-full shadow-sm transition-all duration-200",children:b?e.jsx(l.ChevronRight,{className:"w-3 h-3"}):e.jsx(l.ChevronLeft,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:`${b?"p-2":"p-4"}`,children:[e.jsxs("div",{className:"flex items-center justify-between group/header",children:[b?e.jsx("div",{className:"w-full flex justify-center",children:e.jsx("div",{className:"w-10 h-10 flex items-center justify-center bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-700)] text-white shadow-sm",style:{borderRadius:"var(--radius-button)"},title:A,children:e.jsx(as,{name:N.icon||"LayoutGrid",className:"w-5 h-5"})})}):e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 flex-shrink-0 flex items-center justify-center bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-700)] text-white shadow-sm",style:{borderRadius:"var(--radius-button)"},children:e.jsx(as,{name:N.icon||"LayoutGrid",className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"font-semibold text-[var(--text-primary)] truncate",children:A}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 text-[10px] font-medium bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",style:{borderRadius:"4px"},children:[N.modules.length," ",N.modules.length===1?"module":"modules"]})})]})]}),e.jsx("button",{onClick:s,className:"lg:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsx("div",{className:`mt-3 h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent ${b?"mx-1":""}`})]}),e.jsxs("nav",{className:`flex-1 overflow-y-auto overflow-x-hidden space-y-1 ${b?"p-2 pt-3":"p-3"}`,children:[!p&&m.length>0&&e.jsxs("div",{className:"mb-4",children:[!b&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 mb-1",children:[e.jsxs("button",{onClick:()=>S(!v),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[e.jsx("div",{className:`transition-transform duration-200 ${v?"":"rotate-90"}`,children:e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"})}),e.jsx(l.Star,{className:"w-3.5 h-3.5 text-amber-500"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:y("/myspace/preferences?tab=favorites"),onClick:s,className:"p-1.5 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),(b||!v)&&e.jsx("div",{className:"space-y-0.5",children:m.map(R=>{const $=I(R);return e.jsx(Wo,{module:{...R,route:$},isActive:a.pathname.startsWith($),isCollapsed:b,onClose:s,buildUrl:y},R.id)})}),!b&&e.jsxs("div",{className:"mt-4 pt-4",children:[e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent mb-3"}),e.jsxs("div",{className:"flex items-center gap-2 px-3",children:[e.jsx("div",{className:"w-1 h-3.5 bg-gradient-to-b from-[var(--color-accent-500)] to-[var(--color-accent-300)] rounded-full"}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider",children:r("sidebar.navigation","Navigation")})]})]}),b&&e.jsx("div",{className:"my-3 mx-1",children:e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent"})})]}),i&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[var(--color-accent-500)] border-t-transparent rounded-full animate-spin"})}),!i&&N.modules.length>0&&N.modules.map(R=>e.jsx(Xo,{module:R,isExpanded:x.has(R.id),onToggle:()=>P(R.id),onNavigate:k,currentPath:a.pathname,isCollapsed:b},R.id)),!i&&N.modules.length===0&&!b&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-8",children:r("sidebar.noModules","Aucun module disponible")})]}),!b&&e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"mb-3 h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent"}),e.jsxs("button",{onClick:()=>k(`/${d||"administration"}`),className:"w-full flex items-center gap-2 px-3 py-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-all",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(l.ChevronLeft,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:r("sidebar.backToApps","Retour aux applications")})]})]})]})]})]}):null}const _s=60,ti=33;function si(){const{t}=ne.useTranslation("common"),{isOpen:s,docUrl:r,closeDocPanel:a,panelSize:o,setPanelSize:c}=Bt();if(!s||!r)return null;const i=r.startsWith("http")?r:window.location.origin+r,d=i.includes("?")?"&":"?",u=`${i}${d}embedded=true`,m=o>=_s-1,p=()=>{c(m?ti:_s)};return e.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg-primary)] border-l border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsx("h3",{className:"font-semibold text-sm flex items-center gap-2",children:t("docPanel.title")}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:p,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t(m?"docPanel.minimize":"docPanel.maximize"),children:m?e.jsx(l.Minimize2,{className:"w-4 h-4"}):e.jsx(l.Maximize2,{className:"w-4 h-4"})}),e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t("docPanel.openInNewTab"),children:e.jsx(l.ExternalLink,{className:"w-4 h-4"})}),e.jsx("button",{onClick:a,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t("docPanel.close"),children:e.jsx(l.X,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("iframe",{src:u,title:t("docPanel.title"),className:"w-full h-full border-0"})})]})}function ri({children:t}){const{isOpen:s,panelSize:r,setPanelSize:a}=Bt(),[o,c]=gt.useGroupCallbackRef(),i=n.useRef(r),[d,u]=n.useState(!1);if(n.useEffect(()=>{u(!!o)},[o]),n.useEffect(()=>{o&&d&&i.current!==r&&(o.setLayout({"main-content":100-r,"doc-panel":r}),i.current=r)},[r,o,d]),!s)return e.jsx(e.Fragment,{children:t});const m=f=>{i.current=f.asPercentage,a(f.asPercentage)},p={"main-content":100-r,"doc-panel":r};return e.jsxs(gt.Group,{orientation:"horizontal",className:"h-full",defaultLayout:p,groupRef:c,children:[e.jsx(gt.Panel,{id:"main-content",minSize:40,maxSize:80,children:e.jsx("div",{className:"w-full h-full overflow-auto",children:t})}),e.jsx(gt.Separator,{className:"w-1 bg-[var(--border-color)] hover:bg-[var(--color-primary-400)] transition-colors cursor-col-resize group/separator relative",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover/separator:bg-[var(--color-primary-100)]/20"})}),e.jsx(gt.Panel,{id:"doc-panel",minSize:20,maxSize:60,onResize:m,children:e.jsx(si,{})})]})}function ai(){const{t}=ne.useTranslation("common"),{isOpen:s,openDocPanel:r}=Bt();return s?null:e.jsxs("button",{onClick:()=>r(),className:"hidden lg:flex fixed right-0 top-1/2 -translate-y-1/2 w-3 h-16 items-center justify-center group/toggle transition-all duration-200 z-[100]",title:t("docPanel.open"),"aria-label":t("docPanel.open"),children:[e.jsx("div",{className:"absolute right-0 w-[3px] h-full bg-[var(--border-color)] group-hover/toggle:bg-[var(--color-primary-500)] transition-colors duration-200 rounded-full"}),e.jsx("div",{className:"absolute left-0 -translate-x-full w-6 h-6 flex items-center justify-center bg-[var(--bg-secondary)] border border-[var(--border-color)] group-hover/toggle:border-[var(--color-primary-500)] group-hover/toggle:text-[var(--color-primary-500)] text-[var(--text-muted)] rounded-full shadow-sm transition-all duration-200",children:e.jsx(l.BookOpen,{className:"w-3 h-3"})}),e.jsx("div",{className:"absolute right-6 top-1/2 -translate-y-1/2 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-md shadow-lg opacity-0 group-hover/toggle:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap text-xs font-medium text-[var(--text-primary)]",children:t("docPanel.title")})]})}function ni(){const{t}=ne.useTranslation("admin"),{license:s,isLoading:r,isReadOnlyMode:a}=He(),{user:o}=Pe(),c=Ze(),[i,d]=n.useState(!1);if(r||!s||i)return null;const u=o?.roles?.includes("SuperAdmin")??!1,m=o?.permissions?.some(j=>j.startsWith("administration.configuration.license")||j==="administration.configuration.*"||j==="administration.*")??!1;if(!u&&!m)return null;const p=s.isInTrial&&s.trialDaysRemaining<=7,f=!s.isInTrial&&s.daysUntilExpiration<=30&&s.status==="Active";if(!(a||p||f))return null;const b=a,h=b?"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800 text-red-800 dark:text-red-200":"bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200",y=b?l.Shield:l.AlertTriangle;let x;return a?x=t("license.alert.readOnly","Your license has expired. The platform is in read-only mode."):p?x=t("license.alert.trialExpiring","Your trial expires in {{days}} days. Activate a license to continue using the platform.",{days:s.trialDaysRemaining}):x=t("license.alert.expiringSoon","Your license expires in {{days}} days. Renew to avoid service interruption.",{days:s.daysUntilExpiration}),e.jsx("div",{className:`border-b ${h}`,children:e.jsxs("div",{className:"px-4 sm:px-6 lg:px-8 py-2 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(y,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate",children:x})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(w.Link,{to:c("/administration/configuration/license"),className:`text-xs font-medium px-3 py-1 rounded-md transition-colors ${b?"bg-red-100 dark:bg-red-900/40 hover:bg-red-200 dark:hover:bg-red-800/40":"bg-amber-100 dark:bg-amber-900/40 hover:bg-amber-200 dark:hover:bg-amber-800/40"}`,children:t("license.alert.manage","Manage")}),e.jsx("button",{onClick:()=>d(!0),className:"p-1 rounded-md hover:bg-black/10 dark:hover:bg-white/10 transition-colors","aria-label":t("common:dismiss","Dismiss"),children:e.jsx(l.X,{className:"w-3.5 h-3.5"})})]})]})})}function xa(){const{t}=ne.useTranslation("admin"),{license:s,isLoading:r,isReadOnlyMode:a}=He(),{user:o}=Pe(),c=Ze();if(r)return null;const i=o?.roles?.includes("SuperAdmin")??!1,d=o?.permissions?.some(b=>b.startsWith("administration.configuration.license")||b==="administration.configuration.*"||b==="administration.*")??!1;if(!i&&!d)return null;let u,m,p;if(a)u="error",m=l.Shield,p=t("license.contentBanner.expired","Your license has expired. The platform is in restricted mode. Please renew or activate a new license.");else if(s?.status==="Revoked")u="error",m=l.Shield,p=t("license.contentBanner.revoked","Your license has been revoked. Please contact support or activate a new license.");else if(s?.status==="Expired")u="error",m=l.AlertTriangle,p=t("license.contentBanner.expired","Your license has expired. The platform is in restricted mode. Please renew or activate a new license.");else if(s?.status==="NoLicense"||!s)u="warning",m=l.Key,p=t("license.contentBanner.noLicense","No license is activated. Activate a license to use the platform without restrictions.");else if(s.isInTrial&&s.trialDaysRemaining<=7)u="warning",m=l.Clock,p=t("license.contentBanner.trialUrgent","Your trial expires in {{days}} days. Activate a license now to avoid losing access.",{days:s.trialDaysRemaining});else if(s.isInTrial&&s.trialDaysRemaining>7)u="info",m=l.Clock,p=t("license.contentBanner.trial","You are using a trial license. {{days}} days remaining. Activate a license to unlock the full platform.",{days:s.trialDaysRemaining});else return null;const f={error:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",info:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]"},g={error:"bg-[var(--error-border)] hover:opacity-80 text-white",warning:"bg-[var(--warning-border)] hover:opacity-80 text-white",info:"bg-[var(--info-border)] hover:opacity-80 text-white"};return e.jsx("div",{className:`mb-4 rounded-lg border p-4 ${f[u]}`,"data-testid":"license-content-banner",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(m,{className:"w-5 h-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:p})]}),e.jsx(w.Link,{to:c("/administration/configuration/license"),className:`text-xs font-medium px-4 py-1.5 rounded-md transition-opacity flex-shrink-0 ${g[u]}`,children:t("license.contentBanner.activate","Activate license")})]})})}function oi(){const[t,s]=n.useState(!1),{currentAppCode:r}=Ce(),{isCollapsed:a}=qt(),o=!!r,c=()=>o?a?"lg:pl-16":"lg:pl-64":"";return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(wt,{onMenuToggle:()=>s(!t)}),o&&e.jsx(pa,{isOpen:t,onClose:()=>s(!1)}),e.jsxs("main",{className:`pt-16 transition-all duration-300 h-[calc(100vh-4rem)] ${c()}`,children:[e.jsx(ni,{}),e.jsx(ri,{children:e.jsxs("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:[e.jsx(xa,{}),e.jsx(w.Outlet,{})]})})]}),e.jsx(ai,{})]})}function ha(){return e.jsx(Jr,{children:e.jsx(oi,{})})}const ii=Object.freeze(Object.defineProperty({__proto__:null,AppLayout:ha},Symbol.toStringTag,{value:"Module"}));function li(){return e.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"text-center mb-8",children:e.jsxs("a",{href:"/",className:"inline-flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-6 h-6 text-white"})}),e.jsx("span",{className:"text-2xl font-bold gradient-text",children:"SmartStack"})]})}),e.jsx("div",{className:"bg-[var(--bg-secondary)] rounded-2xl border border-[var(--border-color)] p-8",children:e.jsx(w.Outlet,{})})]})})}function bs(){const{t}=ne.useTranslation("navigation"),{isAuthenticated:s}=Pe(),[r,a]=n.useState(!1);return e.jsx("header",{className:"fixed top-0 left-0 right-0 z-50 bg-[var(--bg-primary)]/80 backdrop-blur-lg border-b border-[var(--border-color)]",children:e.jsxs("nav",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsxs("a",{href:"/",className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-10 h-10 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[!1,e.jsx(gs,{}),e.jsx(Gt,{}),s?e.jsx(na,{}):e.jsx("a",{href:"/login",className:"hidden md:inline-flex px-4 py-2 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors",children:t("header.login")}),e.jsx("button",{onClick:()=>a(!r),className:"md:hidden p-2 rounded-lg hover:bg-[var(--bg-tertiary)] transition-colors",children:r?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})})]})]}),r&&e.jsx("div",{className:"md:hidden py-4 border-t border-[var(--border-color)]",children:e.jsx("div",{className:"flex flex-col gap-4",children:!s&&e.jsx("a",{href:"/login",className:"px-4 py-2 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors text-center",children:t("header.login")})})})]})})}function vs(){const t=new Date().getFullYear();return e.jsx("footer",{className:"bg-[var(--bg-secondary)] border-t border-[var(--border-color)]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-8",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsxs("a",{href:"/",className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]}),e.jsx("p",{className:"text-[var(--text-tertiary)] text-sm",children:"Le socle moderne pour vos applications d'entreprise."})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Produit"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#features",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Fonctionnalités"})}),e.jsx("li",{children:e.jsx("a",{href:"#modules",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Modules"})}),e.jsx("li",{children:e.jsx("a",{href:"#pricing",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Tarifs"})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Entreprise"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#about",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"À propos"})}),e.jsx("li",{children:e.jsx("a",{href:"#contact",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Contact"})}),e.jsx("li",{children:e.jsx("a",{href:"#careers",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Carrières"})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Légal"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#privacy",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Confidentialité"})}),e.jsx("li",{children:e.jsx("a",{href:"#terms",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Conditions"})}),e.jsx("li",{children:e.jsx("a",{href:"#security",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Sécurité"})})]})]})]}),e.jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--border-color)] flex flex-col sm:flex-row items-center justify-between gap-4",children:[e.jsxs("p",{className:"text-[var(--text-tertiary)] text-sm",children:["© ",t," SmartStack. Tous droits réservés."]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("a",{href:"https://github.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Github,{className:"w-5 h-5"})}),e.jsx("a",{href:"https://twitter.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Twitter,{className:"w-5 h-5"})}),e.jsx("a",{href:"https://linkedin.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Linkedin,{className:"w-5 h-5"})})]})]})]})})}const ci=[{title:"Infrastructure",description:"Architecture technique, structure du projet et technologies utilisees",href:"/system/docs/developer/infrastructure",category:"developer",tags:[".NET 10","React 19","EF Core","SQL Server","architecture"],icon:l.Server},{title:"Installation",description:"Guide complet pour installer et configurer l'environnement de developpement",href:"/system/docs/developer/installation",category:"developer",tags:["setup","configuration","prerequisites","npm","dotnet","CLI","MCP"],icon:l.Download},{title:"Base de donnees",description:"Modele conceptuel de donnees avec schemas, tables et relations",href:"/system/docs/developer/database",category:"developer",tags:["MCD","Schemas","Relations","SQL","EF Core","migrations","ERD","diagramme","nav","auth","usr","support","ten","ai","wkf","cfg","entra","ref","loc","lic","Contexts","Applications","Modules","Sections","Resources","ContextMaintenance","Users","Roles","UserRoles","Permissions","RolePermissions","RefreshTokens","Sessions","Profiles","Preferences","Tickets","TicketComments","TicketAttachments","TicketTemplates","Notifications","Tenants","TenantApplications","TenantUsers","Providers","Models","Prompts","PromptVersions","PromptExecutions","Workflows","WorkflowSteps","WorkflowExecutions","EmailTemplates","Settings","SettingCategories","Groups","GroupMembers","SyncStates","Companies","Departments","Positions","Languages","Translations","Licenses","LicenseFeatures","Status","Type","Priority","TenantId","UserId","RoleId","PermissionId","CreatedAt","UpdatedAt","CreatedBy","UpdatedBy","IsDeleted","DeletedAt","TenantStatus","TicketStatus","TicketPriority","TicketType","UserType","Theme","Pending","Active","Suspended","Archived","Open","InProgress","Resolved","Closed","Low","Medium","High","Critical","Bug","FeatureRequest","Support","Question"],icon:l.Database},{title:"Architecture Dual-DbContext",description:"Separation Core/Extensions pour la distribution NuGet et les projets client",href:"/system/docs/developer/dual-dbcontext",category:"developer",tags:["CoreDbContext","ExtensionsDbContext","NuGet","Migrations","schema"],icon:l.Layers},{title:"FK Cross-Schema",description:"Comment referencer les entites Core depuis vos entites Extensions",href:"/system/docs/developer/cross-schema-fk",category:"developer",tags:["ICoreDataService","GUID FK","No Navigation","foreign key"],icon:l.Link2},{title:"Mode Multi-Tenant",description:"Configuration Single-Tenant vs Multi-Tenant et migration entre les modes",href:"/system/docs/developer/multi-tenant-mode",category:"developer",tags:["Single-Tenant","Multi-Tenant","Configuration","tenant","workspace"],icon:l.Building2},{title:"Integration Microsoft Teams",description:"Embarquer SmartStack dans Teams via Website Tab sans developpement",href:"/system/docs/developer/teams-integration",category:"developer",tags:["Microsoft Teams","Teams","Website Tab","iframe","SSO","embedding"],icon:l.Monitor},{title:"Architecture",description:"Vue d'ensemble de l'architecture fonctionnelle de SmartStack",href:"/system/docs/user/architecture",category:"user",tags:["architecture","modules","navigation","contextes"],icon:l.Layers},{title:"Modules",description:"Liste des modules disponibles et leur configuration",href:"/system/docs/user/modules",category:"user",tags:["modules","fonctionnalites","features"],icon:l.FileText},{title:"Module Support",description:"Documentation complete du module de ticketing et support client",href:"/system/docs/user/support",category:"user",tags:["tickets","support","SLA","escalation","templates"],icon:l.Headphones},{title:"Intelligence Artificielle",description:"Configuration des providers IA, prompts et integrations",href:"/system/docs/user/ai",category:"user",tags:["IA","AI","prompts","OpenAI","Claude","providers"],icon:l.Bot},{title:"Parametres Systeme",description:"Configuration globale et parametres de la plateforme",href:"/system/docs/user/settings",category:"user",tags:["settings","configuration","parametres","systeme"],icon:l.Settings},{title:"Presentation SmartStack",description:"Presentation interactive de la plateforme SmartStack",href:"/system/docs/presentation",category:"user",tags:["presentation","slides","demo","overview"],icon:l.Presentation}];function di({className:t="",placeholder:s="Rechercher...",onResultClick:r}){const[a,o]=n.useState(""),[c,i]=n.useState(!1),[d,u]=n.useState(0),m=n.useRef(null),p=n.useRef(null),f=w.useNavigate(),g=n.useMemo(()=>{if(!a.trim())return[];const j=a.toLowerCase().split(" ").filter(Boolean);return ci.filter(v=>{const S=[v.title,v.description,...v.tags,v.category].join(" ").toLowerCase();return j.every(N=>S.includes(N))})},[a]);n.useEffect(()=>{u(0)},[g]);const b=j=>{if(!(!c||g.length===0))switch(j.key){case"ArrowDown":j.preventDefault(),u(v=>(v+1)%g.length);break;case"ArrowUp":j.preventDefault(),u(v=>(v-1+g.length)%g.length);break;case"Enter":j.preventDefault(),g[d]&&h(g[d]);break;case"Escape":i(!1),o(""),m.current?.blur();break}},h=j=>{f(j.href),o(""),i(!1),r?.()};n.useEffect(()=>{const j=v=>{p.current&&!p.current.contains(v.target)&&m.current&&!m.current.contains(v.target)&&i(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const y=j=>j==="developer"?"Developpeur":"Utilisateur",x=j=>j==="developer"?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400";return e.jsxs("div",{className:`relative ${t}`,children:[e.jsxs("div",{className:"relative",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{ref:m,type:"text",value:a,onChange:j=>{o(j.target.value),i(!0)},onFocus:()=>i(!0),onKeyDown:b,placeholder:s,className:"w-full pl-9 pr-8 py-2 text-sm bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary-400)] focus:border-transparent"}),a&&e.jsx("button",{onClick:()=>{o(""),m.current?.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-[var(--bg-hover)]",children:e.jsx(l.X,{className:"w-3 h-3 text-[var(--text-tertiary)]"})})]}),c&&a.trim()&&e.jsxs("div",{ref:p,className:"absolute top-full left-0 right-0 mt-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg overflow-hidden z-50 max-h-80 overflow-y-auto",children:[g.length===0?e.jsxs("div",{className:"p-4 text-center text-[var(--text-secondary)] text-sm",children:['Aucun resultat pour "',a,'"']}):e.jsx("div",{className:"py-1",children:g.map((j,v)=>{const S=j.icon;return e.jsxs("button",{onClick:()=>h(j),onMouseEnter:()=>u(v),className:`w-full flex items-start gap-3 px-3 py-2 text-left transition-colors ${v===d?"bg-[var(--color-primary-600)]/10":"hover:bg-[var(--bg-hover)]"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${v===d?"bg-[var(--color-primary-600)] text-white":"bg-[var(--bg-secondary)]"}`,children:e.jsx(S,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:j.title}),e.jsx("span",{className:`px-1.5 py-0.5 text-xs rounded ${x(j.category)}`,children:y(j.category)})]}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate mt-0.5",children:j.description})]}),e.jsx(l.ArrowRight,{className:`w-4 h-4 flex-shrink-0 mt-2 ${v===d?"text-[var(--color-primary-600)]":"text-[var(--text-tertiary)]"}`})]},j.href)})}),e.jsxs("div",{className:"px-3 py-2 border-t border-[var(--border-color)] bg-[var(--bg-secondary)] text-xs text-[var(--text-tertiary)] flex items-center gap-4",children:[e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"↑↓"})," naviguer"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"↵"})," ouvrir"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"esc"})," fermer"]})]})]})]})}const ui=[{title:"Accueil",href:"/system/docs",icon:l.Book},{title:"Developpeur",href:"/system/docs/developer",icon:l.Code,children:[{title:"Infrastructure",href:"/system/docs/developer/infrastructure"},{title:"Installation",href:"/system/docs/developer/installation"},{title:"Base de donnees",href:"/system/docs/developer/database"},{title:"Dual-DbContext",href:"/system/docs/developer/dual-dbcontext"},{title:"FK Cross-Schema",href:"/system/docs/developer/cross-schema-fk"},{title:"Tenant",href:"/system/docs/developer/tenants",children:[{title:"Mode Multi-Tenant",href:"/system/docs/developer/tenants/multi-tenant-mode"},{title:"Tenant B2C",href:"/system/docs/developer/tenants/b2c"}]},{title:"Integration Teams",href:"/system/docs/developer/teams-integration"},{title:"Tests de Securite",href:"/system/docs/developer/testing/security"}]},{title:"Utilisateur",href:"/system/docs/user",icon:l.Users,children:[{title:"Architecture",href:"/system/docs/user/architecture"},{title:"Modules",href:"/system/docs/user/modules"}]},{title:"Analyse metier",href:"/system/docs/ba",icon:l.BarChart3}];function Xt({item:t,isChild:s=!1,depth:r=0}){const o=w.useLocation().pathname===t.href,c="icon"in t?t.icon:null;return e.jsxs(w.NavLink,{to:t.href,className:`flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${o?"bg-[var(--color-primary-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]"} ${s?"ml-6":""} ${r>1?"ml-12":""}`,children:[c&&e.jsx(c,{className:"w-4 h-4"}),!c&&s&&e.jsx(l.ChevronRight,{className:"w-3 h-3"}),t.title]})}function ga(){const[t,s]=n.useState(!1),r=w.useLocation(),[a]=w.useSearchParams(),o=a.get("embedded")==="true",c=p=>r.pathname===p.href?!0:"children"in p&&Array.isArray(p.children)?p.children.some(f=>r.pathname===f.href?!0:"children"in f&&Array.isArray(f.children)?f.children.some(g=>r.pathname===g.href):!1):!1,i=p=>r.pathname===p.href?!0:p.children?p.children.some(f=>r.pathname===f.href):!1,d=p=>p.children&&i(p)?e.jsx("div",{className:"mt-1 space-y-1",children:p.children.map(f=>e.jsx(Xt,{item:f,isChild:!0,depth:2},f.href))}):null,u=p=>p.children&&c(p)?e.jsx("div",{className:"mt-1 space-y-1",children:p.children.map(f=>e.jsxs("div",{children:[e.jsx(Xt,{item:f,isChild:!0}),d(f)]},f.href))}):null,m=()=>e.jsx("nav",{className:"space-y-1",children:ui.map(p=>e.jsxs("div",{children:[e.jsx(Xt,{item:p}),u(p)]},p.href))});return o?e.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:e.jsx("main",{className:"p-4 lg:p-6",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(w.Outlet,{})})})}):e.jsx(xs,{children:e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)] flex flex-col",children:[e.jsx(bs,{}),e.jsxs("div",{className:"flex-1 flex pt-16",children:[e.jsx("button",{className:"lg:hidden fixed bottom-4 right-4 z-50 p-3 rounded-full bg-[var(--color-primary-600)] text-white shadow-lg",onClick:()=>s(!t),children:t?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})}),t&&e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 z-40 bg-black/50",onClick:()=>s(!1),"aria-label":"Close sidebar"}),e.jsx("aside",{className:`fixed lg:sticky top-16 z-40 lg:z-0 h-[calc(100vh-4rem)] w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] overflow-y-auto transition-transform lg:translate-x-0 ${t?"translate-x-0":"-translate-x-full"}`,children:e.jsxs("div",{className:"p-4",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx(l.Book,{className:"w-5 h-5 text-[var(--color-primary-600)]"}),"Documentation"]}),e.jsx(di,{className:"mb-4",placeholder:"Rechercher dans la doc...",onResultClick:()=>s(!1)}),e.jsx(m,{})]})}),e.jsx("main",{className:"flex-1 min-w-0 p-6 lg:p-8",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(w.Outlet,{})})})]}),e.jsx(vs,{})]})})}const mi=Object.freeze(Object.defineProperty({__proto__:null,DocsLayout:ga},Symbol.toStringTag,{value:"Module"}));function fa(){return e.jsx(xs,{children:e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)] flex flex-col",children:[e.jsx(bs,{}),e.jsx("main",{className:"flex-1 pt-16",children:e.jsx(w.Outlet,{})}),e.jsx(vs,{})]})})}const pi=Object.freeze(Object.defineProperty({__proto__:null,PublicLayout:fa},Symbol.toStringTag,{value:"Module"}));function xi({items:t,className:s=""}){return e.jsx("nav",{"aria-label":"Breadcrumb",className:`flex items-center gap-1 text-sm ${s}`,children:t.map((r,a)=>{const o=a===t.length-1,c=a===0;return e.jsxs("div",{className:"flex items-center gap-1",children:[a>0&&e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),o&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--text-primary)] font-medium",children:[r.icon,r.label]}),!o&&r.href&&e.jsxs(w.Link,{to:r.href,className:"flex items-center gap-1.5 text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",children:[c&&!r.icon&&e.jsx(l.Home,{className:"w-4 h-4"}),r.icon,r.label]}),!o&&!r.href&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[r.icon,r.label]})]},`${a}-${r.label}`)})})}function Yt(t,s){return s.split(".").reduce((r,a)=>{if(r&&typeof r=="object"&&a in r)return r[a]},t)}function hi(t){return t==="right"?"justify-end":t==="center"?"justify-center":""}function gi(t,s){const r=s.toLowerCase();return Object.values(t).some(a=>a==null?!1:String(a).toLowerCase().includes(r))}function fi({data:t,columns:s,loading:r=!1,searchable:a=!1,searchPlaceholder:o="Rechercher...",pagination:c,onRowClick:i,getRowKey:d=(N,I)=>String(I),emptyMessage:u="Aucune donnée",emptyIcon:m,headerActions:p,striped:f=!0,compact:g=!1,className:b="",selectable:h=!1,selectedKeys:y=new Set,onSelectionChange:x,searchFilter:j=gi,defaultSortKey:v,defaultSortDirection:S="asc"}){const[N,I]=n.useState(""),[P,k]=n.useState(v||null),[A,R]=n.useState(S),[$,q]=n.useState(1),[C,D]=n.useState(c?.pageSize||10),Y=Array.isArray(t)?t:[],T=n.useMemo(()=>N?Y.filter(G=>j(G,N)):Y,[Y,N,j]),z=n.useMemo(()=>P?[...T].sort((G,ce)=>{const de=Yt(G,P),he=Yt(ce,P);if(de===he)return 0;if(de==null)return 1;if(he==null)return-1;const pe=String(de).localeCompare(String(he),void 0,{numeric:!0});return A==="asc"?pe:-pe}):T,[T,P,A]),Z=n.useMemo(()=>{if(!c)return z;const G=($-1)*C;return z.slice(G,G+C)},[z,c,$,C]),H=c?Math.ceil(z.length/C):1,J=z.length,fe=c?($-1)*C+1:1,B=c?Math.min($*C,J):J,Q=G=>{P===G?R(ce=>ce==="asc"?"desc":"asc"):(k(G),R("asc"))},M=G=>{q(Math.max(1,Math.min(G,H)))},re=()=>{if(!x)return;const G=Z.map((de,he)=>d(de,he));if(G.every(de=>y.has(de))){const de=new Set(y);G.forEach(he=>de.delete(he)),x(de)}else{const de=new Set(y);G.forEach(he=>de.add(he)),x(de)}},F=G=>{if(!x)return;const ce=new Set(y);ce.has(G)?ce.delete(G):ce.add(G),x(ce)},K=G=>{I(G),q(1)},V=g?"px-3 py-2":"px-4 py-3",ae=g?"px-3 py-2":"px-4 py-3",ue=G=>G.sortable?P===G.key?A==="asc"?e.jsx(l.ChevronUp,{className:"w-4 h-4"}):e.jsx(l.ChevronDown,{className:"w-4 h-4"}):e.jsx(l.ChevronsUpDown,{className:"w-4 h-4 opacity-30"}):null;return e.jsxs("div",{className:`${b}`,children:[(a||p)&&e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-4",children:[a&&e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)] pointer-events-none"}),e.jsx("input",{type:"text",value:N,onChange:G=>K(G.target.value),placeholder:o,className:"input w-full pl-10 pr-10"}),N&&e.jsx("button",{onClick:()=>K(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:e.jsx(l.X,{className:"w-4 h-4"})})]}),p&&e.jsx("div",{className:"flex items-center gap-2",children:p})]}),e.jsx("div",{className:"overflow-x-auto border border-[var(--border-color)] rounded-lg",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)] border-b border-[var(--border-color)]",children:e.jsxs("tr",{children:[h&&e.jsx("th",{className:`${ae} w-12`,children:e.jsx("input",{type:"checkbox",checked:Z.length>0&&Z.every((G,ce)=>y.has(d(G,ce))),onChange:re,className:"rounded border-[var(--border-color)]"})}),s.map(G=>e.jsx("th",{className:`${ae} text-${G.align||"left"} text-sm font-medium text-[var(--text-secondary)] ${G.hideOnMobile?"hidden md:table-cell":""} ${G.sortable?"cursor-pointer hover:bg-[var(--bg-tertiary)] select-none":""}`,style:{width:G.width},onClick:()=>G.sortable&&Q(G.key),children:e.jsxs("div",{className:`flex items-center gap-1 ${hi(G.align)}`,children:[e.jsx("span",{children:G.label}),ue(G)]})},G.key))]})}),e.jsxs("tbody",{children:[r&&e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(h?1:0),className:"py-12 text-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 mx-auto animate-spin text-[var(--color-primary-500)]"})})}),!r&&Z.length===0&&e.jsx("tr",{children:e.jsxs("td",{colSpan:s.length+(h?1:0),className:"py-12 text-center",children:[m&&e.jsx("div",{className:"mb-3",children:m}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:u})]})}),!r&&Z.length>0&&Z.map((G,ce)=>{const de=d(G,ce),he=y.has(de),pe=($-1)*C+ce;return e.jsxs("tr",{onClick:()=>i?.(G,pe),className:`
11
+ `,children:[t,e.jsx("div",{className:v()})]}),document.body)]})}const Et="support_error_context";class Wo{async captureContext(){const s={url:window.location.href,timestamp:new Date,recentErrors:Te.getRecentErrors(),browserInfo:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,screenWidth:window.screen.width,screenHeight:window.screen.height}};try{const r=await this.captureScreenshot();s.screenshot=r}catch{Te.logError(new Error("Failed to capture screenshot"),"ErrorContextService")}return s}async captureScreenshot(){try{const r=await Ts.domToJpeg(document.body,{scale:1,quality:.85,backgroundColor:"#1a1a2e",style:{transform:"none"},filter:a=>{if(a instanceof HTMLElement){const o=a.tagName?.toUpperCase();return o!=="IFRAME"&&o!=="VIDEO"}return!0}});return r.length>4*1024*1024?await this.recompressScreenshot(r,.7):r}catch(s){console.error("[ErrorContextService] Screenshot capture failed:",s);try{return await Ts.domToJpeg(document.body,{scale:.75,quality:.8,backgroundColor:"#1a1a2e"})}catch(r){console.error("[ErrorContextService] Fallback also failed:",r);return}}}async recompressScreenshot(s,r){return new Promise(a=>{const o=new Image;o.onload=()=>{const c=document.createElement("canvas");c.width=o.width,c.height=o.height;const i=c.getContext("2d");if(i){i.drawImage(o,0,0);const d=c.toDataURL("image/jpeg",r);a(d)}else a(s)},o.onerror=()=>a(s),o.src=s})}saveContext(s){try{const r=JSON.stringify(s);try{sessionStorage.setItem(Et,r)}catch{const o={...s,screenshot:void 0};sessionStorage.setItem(Et,JSON.stringify(o))}}catch(r){console.error("[ErrorContextService] Failed to save context:",r)}}loadContext(){try{const s=sessionStorage.getItem(Et);if(s){const r=JSON.parse(s);return r.timestamp=new Date(r.timestamp),r.recentErrors=r.recentErrors.map(a=>({...a,timestamp:new Date(a.timestamp)})),r.screenshot&&!r.screenshot.startsWith("data:image/")&&(r.screenshot=void 0),r}}catch(s){console.warn("[ErrorContextService] Failed to load context:",s)}return null}clearContext(){sessionStorage.removeItem(Et)}formatErrorsForDescription(s){return s.length===0?"":s.slice(0,5).map((a,o)=>{const c=a.timestamp.toLocaleTimeString();return`${o+1}. [${c}] ${a.message}${a.component?` (${a.component})`:""}`}).join(`
12
+ `)}}const $t=new Wo,Xt="ticket_drafts",_s=5,qs=7;class Xo{getDrafts(){try{const s=localStorage.getItem(Xt);return s?JSON.parse(s).map(a=>({...a,createdAt:new Date(a.createdAt),updatedAt:new Date(a.updatedAt)})):[]}catch{return[]}}saveDrafts(s){try{const r=s.map(o=>({...o,createdAt:o.createdAt.toISOString(),updatedAt:o.updatedAt.toISOString()})),a=JSON.stringify(r);return localStorage.setItem(Xt,a),!0}catch(r){if(console.error("[TicketDraftService] Failed to save drafts:",r),r instanceof DOMException&&r.name==="QuotaExceededError")try{const a=s.map(o=>({...o,screenshot:void 0,attachments:void 0,createdAt:o.createdAt.toISOString(),updatedAt:o.updatedAt.toISOString()}));return localStorage.setItem(Xt,JSON.stringify(a)),!0}catch(a){console.error("[TicketDraftService] Still failed without large data:",a)}return!1}}cleanupExpiredDrafts(){const s=this.getDrafts(),r=new Date,a=qs*24*60*60*1e3,o=s.filter(c=>r.getTime()-c.updatedAt.getTime()<a);o.length!==s.length&&this.saveDrafts(o)}getAllDrafts(){return this.cleanupExpiredDrafts(),this.getDrafts().sort((s,r)=>r.updatedAt.getTime()-s.updatedAt.getTime())}getDraft(s){return this.getAllDrafts().find(a=>a.id===s)||null}createDraft(){const s=this.getAllDrafts();if(s.length>=_s){const c=s.at(-1);this.deleteDraft(c.id)}const r=new Date,a={id:crypto.randomUUID(),type:null,title:"",description:"",priority:"Medium",includeScreenshot:!0,includeErrorLogs:!0,createdAt:r,updatedAt:r},o=[a,...this.getDrafts().slice(0,_s-1)];return this.saveDrafts(o),a}updateDraft(s,r){const a=this.getDrafts(),o=a.findIndex(d=>d.id===s);if(o===-1)return{success:!1,draft:null};const c={...a[o],...r,updatedAt:new Date};a[o]=c;const i=this.saveDrafts(a);return{success:i,draft:i?c:null}}deleteDraft(s){const r=this.getDrafts(),a=r.filter(o=>o.id!==s);return a.length===r.length?!1:(this.saveDrafts(a),!0)}getDraftCount(){return this.getAllDrafts().length}hasDrafts(){return this.getDraftCount()>0}getTimeUntilExpiration(s){const r=qs*24*60*60*1e3,a=s.updatedAt.getTime()+r,o=Math.max(0,a-Date.now()),c=Math.floor(o/(1440*60*1e3)),i=Math.floor(o%(1440*60*1e3)/(3600*1e3));return{days:c,hours:i}}}const Ge=new Xo;function pa({variant:t="icon",className:s=""}){const{t:r}=ne.useTranslation(["common","support"]),a=w.useNavigate(),{hasPermission:o}=Pe(),[c,i]=n.useState(!1),[d,u]=n.useState(!1),[m,p]=n.useState([]),f=n.useRef(null),h=o("support.my-tickets.create");n.useEffect(()=>{d&&p(Ge.getAllDrafts())},[d]),n.useEffect(()=>{const S=N=>{f.current&&!f.current.contains(N.target)&&u(!1)};return d&&document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[d]);const b=async S=>{i(!0),u(!1);const I=(S?Ge.getDraft(S):null)?.screenshot;let P=null;if(I)$t.clearContext();else try{P=await $t.captureContext(),$t.saveContext(P)}catch{}i(!1);const k=S?`/support/my-tickets/create?draft=${S}`:"/support/my-tickets/create";a(k)},g=async()=>{const S=Ge.getAllDrafts();S.length>0?(p(S),u(!0)):await b()},y=(S,N)=>{S.stopPropagation(),Ge.deleteDraft(N);const I=Ge.getAllDrafts();p(I),I.length===0&&u(!1)},x=S=>S.title?S.title.length>30?S.title.substring(0,30)+"...":S.title:S.type?r(`support:tickets.types.${S.type}`):r("common:drafts.untitled"),j=S=>{const I=new Date().getTime()-S.getTime(),P=Math.floor(I/6e4),k=Math.floor(I/36e5),A=Math.floor(I/864e5);return P<1?r("common:drafts.justNow"):P<60?r("common:drafts.minutesAgo",{count:P}):k<24?r("common:drafts.hoursAgo",{count:k}):r("common:drafts.daysAgo",{count:A})};if(!h)return null;const v=()=>e.jsxs("div",{ref:f,className:"absolute right-0 top-full mt-2 w-80 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-xl z-50",children:[e.jsxs("div",{className:"p-3 border-b border-[var(--border-color)]",children:[e.jsx("h3",{className:"font-medium text-sm",children:r("common:drafts.existingDrafts")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:r("common:drafts.selectOrCreate")})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto",children:m.map(S=>{const N=Ge.getTimeUntilExpiration(S);return e.jsxs("button",{type:"button",onClick:()=>b(S.id),className:"w-full p-3 flex items-start gap-3 hover:bg-[var(--bg-hover)] transition-colors text-left border-b border-[var(--border-color)] last:border-b-0 cursor-pointer",children:[e.jsx(l.FileEdit,{className:"w-4 h-4 text-[var(--text-secondary)] mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:x(S)}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)] mt-1 flex-wrap",children:[S.tenantName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] truncate max-w-[120px]",children:S.tenantName}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"•"})]}),e.jsx(l.Clock,{className:"w-3 h-3"}),e.jsx("span",{children:j(S.updatedAt)}),e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"•"}),e.jsx("span",{className:"text-[var(--warning-text)]",children:N.days>0?r("common:drafts.expiresInDays",{count:N.days}):r("common:drafts.expiresInHours",{count:N.hours})})]})]}),e.jsx("button",{onClick:I=>y(I,S.id),className:"p-1.5 rounded hover:bg-[var(--error-bg)] text-[var(--text-secondary)] hover:text-[var(--error-text)] transition-colors",title:r("common:actions.delete"),children:e.jsx(l.Trash2,{className:"w-4 h-4"})})]},S.id)})}),e.jsx("div",{className:"p-2 border-t border-[var(--border-color)]",children:e.jsxs("button",{onClick:()=>b(),className:"w-full flex items-center justify-center gap-2 px-4 py-2 bg-[var(--color-primary-600)] text-white rounded-lg hover:bg-[var(--color-primary-700)] transition-colors text-sm",children:[e.jsx(l.Plus,{className:"w-4 h-4"}),r("common:drafts.createNew")]})})]});return t==="icon"?e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(ma,{content:r("common:actions.createTicket"),position:"bottom",children:e.jsx("button",{onClick:g,disabled:c,className:`p-2 rounded-lg hover:bg-[var(--bg-hover)] transition-colors disabled:opacity-50 ${s}`,children:c?e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}):e.jsx(l.Headset,{className:"w-5 h-5"})})}),d&&v()]}):e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:g,disabled:c,className:`flex items-center gap-2 px-4 py-2 bg-[var(--color-primary-600)] text-white rounded-lg hover:bg-[var(--color-primary-700)] transition-colors disabled:opacity-50 ${s}`,children:[c?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Headset,{className:"w-4 h-4"}),r("common:actions.createTicket")]}),d&&v()]})}function Nt({onMenuToggle:t}){const{t:s}=ne.useTranslation("navigation"),[r,a]=n.useState(!1),o=Ze(),{menu:c}=Ce(),{logout:i}=Pe(),d=c?.applications||[];return e.jsx("header",{className:"fixed top-0 left-0 right-0 z-50 bg-[var(--bg-primary)]/80 backdrop-blur-lg border-b border-[var(--border-color)]",children:e.jsxs("nav",{className:"px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[t&&e.jsx("button",{onClick:t,className:"lg:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.Menu,{className:"w-5 h-5"})}),e.jsxs(w.Link,{to:o("/applications"),className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-10 h-10 animated-gradient flex items-center justify-center",style:{borderRadius:"var(--radius-card)"},children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(zo,{}),e.jsx("div",{className:"h-6 w-px bg-[var(--border-color)]"}),e.jsx(ia,{}),e.jsx("div",{className:"h-6 w-px bg-[var(--border-color)]"}),e.jsx(bs,{}),e.jsx(Kt,{}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 pl-3 border-l border-[var(--border-color)]",children:[!1,e.jsx(pa,{}),e.jsx(ua,{}),e.jsx(oa,{})]}),e.jsx("button",{onClick:()=>a(!r),className:"sm:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:r?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})})]})]}),r&&e.jsx("div",{className:"sm:hidden py-4 border-t border-[var(--border-color)]",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[d.map(u=>e.jsx(w.Link,{to:o(u.route||"#"),className:"px-3 py-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},onClick:()=>a(!1),children:u.label},u.id)),e.jsx("hr",{className:"my-2 border-[var(--border-color)]"}),e.jsxs("button",{onClick:()=>{a(!1),i()},className:"flex items-center gap-2 px-3 py-2 hover:bg-[var(--bg-tertiary)] transition-colors text-red-500",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),s("header.logout")]})]})})]})})}function os({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function is(t){if(!t)return l.Box;const s=xt;if(s[t])return s[t];const r=t.toLowerCase(),a=Object.keys(s).find(o=>o.toLowerCase()===r);return a?s[a]:l.Box}function Yo({module:t,isActive:s,isCollapsed:r,onClose:a,buildUrl:o}){const[c,i]=n.useState(!1),[d,u]=n.useState({top:0,left:0}),m=n.useRef(null),p=n.useRef(null),f=()=>{if(r){if(m.current&&(clearTimeout(m.current),m.current=null),p.current){const b=p.current.getBoundingClientRect();u({top:b.top,left:b.right+8})}i(!0)}},h=()=>{r&&(m.current=setTimeout(()=>{i(!1)},150))};return n.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),e.jsxs("div",{ref:p,className:"relative",onMouseEnter:f,onMouseLeave:h,children:[e.jsxs(w.Link,{to:o(t.route),onClick:a,className:`flex items-center transition-colors ${r?"justify-center px-2 py-2":"gap-3 px-3 py-2"} ${s?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:r?`${t.label} (${t.applicationLabel})`:void 0,children:[e.jsx(os,{name:t.icon,className:"w-4 h-4 flex-shrink-0"}),!r&&e.jsx("span",{className:"text-sm font-medium truncate",children:t.label})]}),r&&c&&Ft.createPortal(e.jsx("div",{className:"fixed z-[9999] pointer-events-auto",style:{top:d.top,left:d.left},onMouseEnter:f,onMouseLeave:h,children:e.jsx("div",{className:"px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg whitespace-nowrap",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:t.label})})}),document.body)]})}function Jo({module:t,isExpanded:s,onToggle:r,onNavigate:a,currentPath:o,isCollapsed:c}){const[i,d]=n.useState(!1),[u,m]=n.useState({top:0,left:0}),[p,f]=n.useState(new Set),h=n.useRef(null),b=n.useRef(null),g=is(t.icon),y=t.route?o===t.route:o.includes(`/${t.code}`),x=(t.sections?.length??0)>0,j=t.label;n.useEffect(()=>{if(!t.sections)return;const P=t.sections.find(k=>k.resources?.some(A=>A.route&&o.startsWith(A.route)));P&&!p.has(P.id)&&f(k=>new Set([...k,P.id]))},[o,t.sections,p]);const v=P=>{f(k=>{const A=new Set(k);return A.has(P)?A.delete(P):A.add(P),A})},S=()=>{if(c){if(h.current&&(clearTimeout(h.current),h.current=null),b.current){const P=b.current.getBoundingClientRect();m({top:P.top,left:P.right+8})}d(!0)}},N=()=>{c&&(h.current=setTimeout(()=>{d(!1)},150))};n.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const I=()=>{x&&!c?r():t.route&&a(t.route)};return e.jsxs("div",{ref:b,className:"relative",onMouseEnter:S,onMouseLeave:N,children:[e.jsxs("button",{onClick:I,className:`w-full flex items-center transition-all duration-200 ${c?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${y?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:c&&!x?j:void 0,children:[e.jsx(g,{className:"w-5 h-5 flex-shrink-0"}),!c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left font-medium text-sm truncate",children:j}),x&&(s?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)] flex-shrink-0"}))]})]}),c&&i&&Ft.createPortal(e.jsx("div",{className:"fixed z-[9999] pointer-events-auto",style:{top:u.top,left:u.left},onMouseEnter:S,onMouseLeave:N,children:e.jsxs("div",{className:"min-w-[200px] bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg",style:{borderRadius:"var(--radius-card)"},children:[e.jsx("div",{className:"px-3 py-2 border-b border-[var(--border-color)]",children:e.jsx("span",{className:"text-sm font-semibold text-[var(--text-primary)]",children:j})}),e.jsx("div",{className:"p-1.5",children:x?t.sections.map(P=>{const k=is(P.icon),A=P.route&&o===P.route;return e.jsxs("button",{onClick:()=>P.route&&a(P.route),className:`w-full flex items-center gap-2.5 px-2.5 py-2 transition-colors ${A?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(k,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:P.label})]},P.id)}):t.route&&e.jsxs("button",{onClick:()=>a(t.route),className:"w-full flex items-center gap-2.5 px-2.5 py-2 hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(g,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:"Ouvrir"})]})})]})}),document.body),!c&&s&&x&&e.jsx("div",{className:"ml-4 pl-4 border-l border-[var(--border-color)] mt-1 space-y-1",children:t.sections.map(P=>e.jsx(Qo,{section:P,currentPath:o,onNavigate:a,isCollapsed:c,isExpanded:p.has(P.id),onToggle:()=>v(P.id)},P.id))})]})}function Qo({section:t,currentPath:s,onNavigate:r,isCollapsed:a,isExpanded:o,onToggle:c}){const i=is(t.icon),d=t.route&&(s===t.route||s.startsWith(t.route+"/")),u=(t.resources?.length??0)>0,m=t.label,p=f=>{f.preventDefault(),t.route&&r(t.route),u&&c()};return a?null:e.jsxs("div",{children:[e.jsxs("button",{onClick:p,className:`w-full flex items-center gap-3 px-3 py-2 transition-all duration-200 ${d?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(i,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"flex-1 text-sm text-left",children:m}),u&&(o?e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)] flex-shrink-0"}):e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)] flex-shrink-0"}))]}),o&&u&&e.jsx("div",{className:"ml-4 pl-3 border-l border-[var(--border-color)] mt-1 space-y-0.5",children:t.resources.map(f=>e.jsx(Zo,{resource:f,currentPath:s,onNavigate:r},f.id))})]})}function Zo({resource:t,currentPath:s,onNavigate:r}){const a=t.route&&s.startsWith(t.route),o=c=>{c.preventDefault(),t.route&&r(t.route)};return e.jsxs("button",{onClick:o,className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 transition-all duration-200 ${a?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"hover:bg-[var(--bg-tertiary)] text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-current flex-shrink-0"}),e.jsx("span",{className:"text-xs text-left",children:t.label})]})}const ei=(t,s)=>{if(t?.modules)return t.modules.find(r=>r.sections?.length?r.sections.some(a=>a.route&&(s===a.route||s.startsWith(a.route+"/"))):!1)},ti=(t,s)=>!!t.route&&s.startsWith(t.route)&&(t.sections?.length??0)>0,si=(t,s)=>{if(!t)return;const r=ei(t,s);return r||t.modules.find(a=>ti(a,s))};function xa({isOpen:t,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),o=w.useNavigate(),{getCurrentApplication:c,isLoading:i,currentAppCode:d,menu:u}=Ce(),{favorites:m,loading:p}=Ke(),{expandFavorites:f,clearExpand:h}=Ke(),{isCollapsed:b,toggleCollapsed:g}=Ut(),y=Ze(),[x,j]=n.useState(new Set),[v,S]=n.useState(!1);n.useEffect(()=>{f&&(queueMicrotask(()=>{S(!1)}),h())},[f,h]);const N=c(),I=n.useCallback(R=>{if(u)for(const $ of u.applications){const q=$.modules.find(C=>C.id===R.id);if(q?.sections?.length){const C=[...q.sections].sort((D,Y)=>D.displayOrder-Y.displayOrder)[0];if(C.route)return C.route}}return R.route},[u]);n.useEffect(()=>{if(!N)return;const R=si(N,a.pathname);R&&!x.has(R.id)&&queueMicrotask(()=>{j($=>new Set([...$,R.id]))})},[a.pathname,N,x]);const P=R=>{j($=>{const q=new Set($);return q.has(R)?q.delete(R):q.add(R),q})},k=R=>{o(y(R)),s()},A=N?.label??"";return N?e.jsxs(e.Fragment,{children:[t&&e.jsx("button",{type:"button",className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:s,"aria-label":"Close sidebar"}),e.jsxs("aside",{className:`group/sidebar fixed top-16 bottom-0 left-0 bg-[var(--bg-primary)] border-r border-[var(--border-color)] transform transition-all duration-300 z-50 overflow-visible ${b?"w-16":"w-64"} ${t?"translate-x-0":"-translate-x-full lg:translate-x-0"}`,children:[e.jsxs("button",{onClick:g,className:"hidden lg:flex absolute top-1/2 -translate-y-1/2 w-3 h-16 items-center justify-center group/toggle transition-all duration-200 z-[9999]",style:{right:"-12px"},title:b?r("sidebar.expand","Agrandir le menu"):r("sidebar.collapse","Réduire le menu"),children:[e.jsx("div",{className:"absolute left-0 w-[3px] h-full bg-[var(--border-color)] group-hover/toggle:bg-[var(--color-accent-500)] transition-colors duration-200 rounded-full"}),e.jsx("div",{className:"absolute right-0 w-4 h-4 flex items-center justify-center bg-[var(--bg-secondary)] border border-[var(--border-color)] group-hover/toggle:border-[var(--color-accent-500)] group-hover/toggle:text-[var(--color-accent-500)] text-[var(--text-muted)] rounded-full shadow-sm transition-all duration-200",children:b?e.jsx(l.ChevronRight,{className:"w-3 h-3"}):e.jsx(l.ChevronLeft,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:`${b?"p-2":"p-4"}`,children:[e.jsxs("div",{className:"flex items-center justify-between group/header",children:[b?e.jsx("div",{className:"w-full flex justify-center",children:e.jsx("div",{className:"w-10 h-10 flex items-center justify-center bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-700)] text-white shadow-sm",style:{borderRadius:"var(--radius-button)"},title:A,children:e.jsx(os,{name:N.icon||"LayoutGrid",className:"w-5 h-5"})})}):e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 flex-shrink-0 flex items-center justify-center bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-700)] text-white shadow-sm",style:{borderRadius:"var(--radius-button)"},children:e.jsx(os,{name:N.icon||"LayoutGrid",className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"font-semibold text-[var(--text-primary)] truncate",children:A}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 text-[10px] font-medium bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",style:{borderRadius:"4px"},children:[N.modules.length," ",N.modules.length===1?"module":"modules"]})})]})]}),e.jsx("button",{onClick:s,className:"lg:hidden p-2 hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsx("div",{className:`mt-3 h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent ${b?"mx-1":""}`})]}),e.jsxs("nav",{className:`flex-1 overflow-y-auto overflow-x-hidden space-y-1 ${b?"p-2 pt-3":"p-3"}`,children:[!p&&m.length>0&&e.jsxs("div",{className:"mb-4",children:[!b&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 mb-1",children:[e.jsxs("button",{onClick:()=>S(!v),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[e.jsx("div",{className:`transition-transform duration-200 ${v?"":"rotate-90"}`,children:e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"})}),e.jsx(l.Star,{className:"w-3.5 h-3.5 text-amber-500"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:y("/myspace/preferences?tab=favorites"),onClick:s,className:"p-1.5 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),(b||!v)&&e.jsx("div",{className:"space-y-0.5",children:m.map(R=>{const $=I(R);return e.jsx(Yo,{module:{...R,route:$},isActive:a.pathname.startsWith($),isCollapsed:b,onClose:s,buildUrl:y},R.id)})}),!b&&e.jsxs("div",{className:"mt-4 pt-4",children:[e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent mb-3"}),e.jsxs("div",{className:"flex items-center gap-2 px-3",children:[e.jsx("div",{className:"w-1 h-3.5 bg-gradient-to-b from-[var(--color-accent-500)] to-[var(--color-accent-300)] rounded-full"}),e.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider",children:r("sidebar.navigation","Navigation")})]})]}),b&&e.jsx("div",{className:"my-3 mx-1",children:e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent"})})]}),i&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[var(--color-accent-500)] border-t-transparent rounded-full animate-spin"})}),!i&&N.modules.length>0&&N.modules.map(R=>e.jsx(Jo,{module:R,isExpanded:x.has(R.id),onToggle:()=>P(R.id),onNavigate:k,currentPath:a.pathname,isCollapsed:b},R.id)),!i&&N.modules.length===0&&!b&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] text-center py-8",children:r("sidebar.noModules","Aucun module disponible")})]}),!b&&e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"mb-3 h-px bg-gradient-to-r from-transparent via-[var(--border-color)] to-transparent"}),e.jsxs("button",{onClick:()=>k(`/${d||"administration"}`),className:"w-full flex items-center gap-2 px-3 py-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-all",style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(l.ChevronLeft,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:r("sidebar.backToApps","Retour aux applications")})]})]})]})]})]}):null}const Us=60,ri=33;function ai(){const{t}=ne.useTranslation("common"),{isOpen:s,docUrl:r,closeDocPanel:a,panelSize:o,setPanelSize:c}=Gt();if(!s||!r)return null;const i=r.startsWith("http")?r:window.location.origin+r,d=i.includes("?")?"&":"?",u=`${i}${d}embedded=true`,m=o>=Us-1,p=()=>{c(m?ri:Us)};return e.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg-primary)] border-l border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border-color)] bg-[var(--bg-secondary)]",children:[e.jsx("h3",{className:"font-semibold text-sm flex items-center gap-2",children:t("docPanel.title")}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:p,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t(m?"docPanel.minimize":"docPanel.maximize"),children:m?e.jsx(l.Minimize2,{className:"w-4 h-4"}):e.jsx(l.Maximize2,{className:"w-4 h-4"})}),e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t("docPanel.openInNewTab"),children:e.jsx(l.ExternalLink,{className:"w-4 h-4"})}),e.jsx("button",{onClick:a,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",title:t("docPanel.close"),children:e.jsx(l.X,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("iframe",{src:u,title:t("docPanel.title"),className:"w-full h-full border-0"})})]})}function ni({children:t}){const{isOpen:s,panelSize:r,setPanelSize:a}=Gt(),[o,c]=gt.useGroupCallbackRef(),i=n.useRef(r),[d,u]=n.useState(!1);if(n.useEffect(()=>{u(!!o)},[o]),n.useEffect(()=>{o&&d&&i.current!==r&&(o.setLayout({"main-content":100-r,"doc-panel":r}),i.current=r)},[r,o,d]),!s)return e.jsx(e.Fragment,{children:t});const m=f=>{i.current=f.asPercentage,a(f.asPercentage)},p={"main-content":100-r,"doc-panel":r};return e.jsxs(gt.Group,{orientation:"horizontal",className:"h-full",defaultLayout:p,groupRef:c,children:[e.jsx(gt.Panel,{id:"main-content",minSize:40,maxSize:80,children:e.jsx("div",{className:"w-full h-full overflow-auto",children:t})}),e.jsx(gt.Separator,{className:"w-1 bg-[var(--border-color)] hover:bg-[var(--color-primary-400)] transition-colors cursor-col-resize group/separator relative",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover/separator:bg-[var(--color-primary-100)]/20"})}),e.jsx(gt.Panel,{id:"doc-panel",minSize:20,maxSize:60,onResize:m,children:e.jsx(ai,{})})]})}function oi(){const{t}=ne.useTranslation("common"),{isOpen:s,openDocPanel:r}=Gt();return s?null:e.jsxs("button",{onClick:()=>r(),className:"hidden lg:flex fixed right-0 top-1/2 -translate-y-1/2 w-3 h-16 items-center justify-center group/toggle transition-all duration-200 z-[100]",title:t("docPanel.open"),"aria-label":t("docPanel.open"),children:[e.jsx("div",{className:"absolute right-0 w-[3px] h-full bg-[var(--border-color)] group-hover/toggle:bg-[var(--color-primary-500)] transition-colors duration-200 rounded-full"}),e.jsx("div",{className:"absolute left-0 -translate-x-full w-6 h-6 flex items-center justify-center bg-[var(--bg-secondary)] border border-[var(--border-color)] group-hover/toggle:border-[var(--color-primary-500)] group-hover/toggle:text-[var(--color-primary-500)] text-[var(--text-muted)] rounded-full shadow-sm transition-all duration-200",children:e.jsx(l.BookOpen,{className:"w-3 h-3"})}),e.jsx("div",{className:"absolute right-6 top-1/2 -translate-y-1/2 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-md shadow-lg opacity-0 group-hover/toggle:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap text-xs font-medium text-[var(--text-primary)]",children:t("docPanel.title")})]})}function ii(){const{t}=ne.useTranslation("admin"),{license:s,isLoading:r,isReadOnlyMode:a}=He(),{user:o}=Pe(),c=Ze(),[i,d]=n.useState(!1);if(r||!s||i)return null;const u=o?.roles?.includes("SuperAdmin")??!1,m=o?.permissions?.some(j=>j.startsWith("administration.configuration.license")||j==="administration.configuration.*"||j==="administration.*")??!1;if(!u&&!m)return null;const p=s.isInTrial&&s.trialDaysRemaining<=7,f=!s.isInTrial&&s.daysUntilExpiration<=30&&s.status==="Active";if(!(a||p||f))return null;const b=a,g=b?"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800 text-red-800 dark:text-red-200":"bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-200",y=b?l.Shield:l.AlertTriangle;let x;return a?x=t("license.alert.readOnly","Your license has expired. The platform is in read-only mode."):p?x=t("license.alert.trialExpiring","Your trial expires in {{days}} days. Activate a license to continue using the platform.",{days:s.trialDaysRemaining}):x=t("license.alert.expiringSoon","Your license expires in {{days}} days. Renew to avoid service interruption.",{days:s.daysUntilExpiration}),e.jsx("div",{className:`border-b ${g}`,children:e.jsxs("div",{className:"px-4 sm:px-6 lg:px-8 py-2 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(y,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate",children:x})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(w.Link,{to:c("/administration/configuration/license"),className:`text-xs font-medium px-3 py-1 rounded-md transition-colors ${b?"bg-red-100 dark:bg-red-900/40 hover:bg-red-200 dark:hover:bg-red-800/40":"bg-amber-100 dark:bg-amber-900/40 hover:bg-amber-200 dark:hover:bg-amber-800/40"}`,children:t("license.alert.manage","Manage")}),e.jsx("button",{onClick:()=>d(!0),className:"p-1 rounded-md hover:bg-black/10 dark:hover:bg-white/10 transition-colors","aria-label":t("common:dismiss","Dismiss"),children:e.jsx(l.X,{className:"w-3.5 h-3.5"})})]})]})})}function ha(){const{t}=ne.useTranslation("admin"),{license:s,isLoading:r,isReadOnlyMode:a}=He(),{user:o}=Pe(),c=Ze();if(r)return null;const i=o?.roles?.includes("SuperAdmin")??!1,d=o?.permissions?.some(b=>b.startsWith("administration.configuration.license")||b==="administration.configuration.*"||b==="administration.*")??!1;if(!i&&!d)return null;let u,m,p;if(a)u="error",m=l.Shield,p=t("license.contentBanner.expired","Your license has expired. The platform is in restricted mode. Please renew or activate a new license.");else if(s?.status==="Revoked")u="error",m=l.Shield,p=t("license.contentBanner.revoked","Your license has been revoked. Please contact support or activate a new license.");else if(s?.status==="Expired")u="error",m=l.AlertTriangle,p=t("license.contentBanner.expired","Your license has expired. The platform is in restricted mode. Please renew or activate a new license.");else if(s?.status==="NoLicense"||!s)u="warning",m=l.Key,p=t("license.contentBanner.noLicense","No license is activated. Activate a license to use the platform without restrictions.");else if(s.isInTrial&&s.trialDaysRemaining<=7)u="warning",m=l.Clock,p=t("license.contentBanner.trialUrgent","Your trial expires in {{days}} days. Activate a license now to avoid losing access.",{days:s.trialDaysRemaining});else if(s.isInTrial&&s.trialDaysRemaining>7)u="info",m=l.Clock,p=t("license.contentBanner.trial","You are using a trial license. {{days}} days remaining. Activate a license to unlock the full platform.",{days:s.trialDaysRemaining});else return null;const f={error:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",info:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]"},h={error:"bg-[var(--error-border)] hover:opacity-80 text-white",warning:"bg-[var(--warning-border)] hover:opacity-80 text-white",info:"bg-[var(--info-border)] hover:opacity-80 text-white"};return e.jsx("div",{className:`mb-4 rounded-lg border p-4 ${f[u]}`,"data-testid":"license-content-banner",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(m,{className:"w-5 h-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:p})]}),e.jsx(w.Link,{to:c("/administration/configuration/license"),className:`text-xs font-medium px-4 py-1.5 rounded-md transition-opacity flex-shrink-0 ${h[u]}`,children:t("license.contentBanner.activate","Activate license")})]})})}function li(){const[t,s]=n.useState(!1),{currentAppCode:r}=Ce(),{isCollapsed:a}=Ut(),o=!!r,c=()=>o?a?"lg:pl-16":"lg:pl-64":"";return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(Nt,{onMenuToggle:()=>s(!t)}),o&&e.jsx(xa,{isOpen:t,onClose:()=>s(!1)}),e.jsxs("main",{className:`pt-16 transition-all duration-300 h-[calc(100vh-4rem)] ${c()}`,children:[e.jsx(ii,{}),e.jsx(ni,{children:e.jsxs("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:[e.jsx(ha,{}),e.jsx(w.Outlet,{})]})})]}),e.jsx(oi,{})]})}function ga(){return e.jsx(Qr,{children:e.jsx(li,{})})}const ci=Object.freeze(Object.defineProperty({__proto__:null,AppLayout:ga},Symbol.toStringTag,{value:"Module"}));function di(){return e.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"text-center mb-8",children:e.jsxs("a",{href:"/",className:"inline-flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-6 h-6 text-white"})}),e.jsx("span",{className:"text-2xl font-bold gradient-text",children:"SmartStack"})]})}),e.jsx("div",{className:"bg-[var(--bg-secondary)] rounded-2xl border border-[var(--border-color)] p-8",children:e.jsx(w.Outlet,{})})]})})}function ys(){const{t}=ne.useTranslation("navigation"),{isAuthenticated:s}=Pe(),[r,a]=n.useState(!1);return e.jsx("header",{className:"fixed top-0 left-0 right-0 z-50 bg-[var(--bg-primary)]/80 backdrop-blur-lg border-b border-[var(--border-color)]",children:e.jsxs("nav",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsxs("a",{href:"/",className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-10 h-10 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[!1,e.jsx(bs,{}),e.jsx(Kt,{}),s?e.jsx(oa,{}):e.jsx("a",{href:"/login",className:"hidden md:inline-flex px-4 py-2 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors",children:t("header.login")}),e.jsx("button",{onClick:()=>a(!r),className:"md:hidden p-2 rounded-lg hover:bg-[var(--bg-tertiary)] transition-colors",children:r?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})})]})]}),r&&e.jsx("div",{className:"md:hidden py-4 border-t border-[var(--border-color)]",children:e.jsx("div",{className:"flex flex-col gap-4",children:!s&&e.jsx("a",{href:"/login",className:"px-4 py-2 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-medium transition-colors text-center",children:t("header.login")})})})]})})}function js(){const t=new Date().getFullYear();return e.jsx("footer",{className:"bg-[var(--bg-secondary)] border-t border-[var(--border-color)]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-8",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsxs("a",{href:"/",className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl animated-gradient flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-5 h-5 text-white"})}),e.jsx("span",{className:"text-xl font-bold gradient-text",children:"SmartStack"})]}),e.jsx("p",{className:"text-[var(--text-tertiary)] text-sm",children:"Le socle moderne pour vos applications d'entreprise."})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Produit"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#features",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Fonctionnalités"})}),e.jsx("li",{children:e.jsx("a",{href:"#modules",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Modules"})}),e.jsx("li",{children:e.jsx("a",{href:"#pricing",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Tarifs"})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Entreprise"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#about",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"À propos"})}),e.jsx("li",{children:e.jsx("a",{href:"#contact",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Contact"})}),e.jsx("li",{children:e.jsx("a",{href:"#careers",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Carrières"})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)] mb-4",children:"Légal"}),e.jsxs("ul",{className:"space-y-2",children:[e.jsx("li",{children:e.jsx("a",{href:"#privacy",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Confidentialité"})}),e.jsx("li",{children:e.jsx("a",{href:"#terms",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Conditions"})}),e.jsx("li",{children:e.jsx("a",{href:"#security",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] text-sm transition-colors",children:"Sécurité"})})]})]})]}),e.jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--border-color)] flex flex-col sm:flex-row items-center justify-between gap-4",children:[e.jsxs("p",{className:"text-[var(--text-tertiary)] text-sm",children:["© ",t," SmartStack. Tous droits réservés."]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("a",{href:"https://github.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Github,{className:"w-5 h-5"})}),e.jsx("a",{href:"https://twitter.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Twitter,{className:"w-5 h-5"})}),e.jsx("a",{href:"https://linkedin.com",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:e.jsx(l.Linkedin,{className:"w-5 h-5"})})]})]})]})})}const ui=[{title:"Infrastructure",description:"Architecture technique, structure du projet et technologies utilisees",href:"/system/docs/developer/infrastructure",category:"developer",tags:[".NET 10","React 19","EF Core","SQL Server","architecture"],icon:l.Server},{title:"Installation",description:"Guide complet pour installer et configurer l'environnement de developpement",href:"/system/docs/developer/installation",category:"developer",tags:["setup","configuration","prerequisites","npm","dotnet","CLI","MCP"],icon:l.Download},{title:"Base de donnees",description:"Modele conceptuel de donnees avec schemas, tables et relations",href:"/system/docs/developer/database",category:"developer",tags:["MCD","Schemas","Relations","SQL","EF Core","migrations","ERD","diagramme","nav","auth","usr","support","ten","ai","wkf","cfg","entra","ref","loc","lic","Contexts","Applications","Modules","Sections","Resources","ContextMaintenance","Users","Roles","UserRoles","Permissions","RolePermissions","RefreshTokens","Sessions","Profiles","Preferences","Tickets","TicketComments","TicketAttachments","TicketTemplates","Notifications","Tenants","TenantApplications","TenantUsers","Providers","Models","Prompts","PromptVersions","PromptExecutions","Workflows","WorkflowSteps","WorkflowExecutions","EmailTemplates","Settings","SettingCategories","Groups","GroupMembers","SyncStates","Companies","Departments","Positions","Languages","Translations","Licenses","LicenseFeatures","Status","Type","Priority","TenantId","UserId","RoleId","PermissionId","CreatedAt","UpdatedAt","CreatedBy","UpdatedBy","IsDeleted","DeletedAt","TenantStatus","TicketStatus","TicketPriority","TicketType","UserType","Theme","Pending","Active","Suspended","Archived","Open","InProgress","Resolved","Closed","Low","Medium","High","Critical","Bug","FeatureRequest","Support","Question"],icon:l.Database},{title:"Architecture Dual-DbContext",description:"Separation Core/Extensions pour la distribution NuGet et les projets client",href:"/system/docs/developer/dual-dbcontext",category:"developer",tags:["CoreDbContext","ExtensionsDbContext","NuGet","Migrations","schema"],icon:l.Layers},{title:"FK Cross-Schema",description:"Comment referencer les entites Core depuis vos entites Extensions",href:"/system/docs/developer/cross-schema-fk",category:"developer",tags:["ICoreDataService","GUID FK","No Navigation","foreign key"],icon:l.Link2},{title:"Mode Multi-Tenant",description:"Configuration Single-Tenant vs Multi-Tenant et migration entre les modes",href:"/system/docs/developer/multi-tenant-mode",category:"developer",tags:["Single-Tenant","Multi-Tenant","Configuration","tenant","workspace"],icon:l.Building2},{title:"Integration Microsoft Teams",description:"Embarquer SmartStack dans Teams via Website Tab sans developpement",href:"/system/docs/developer/teams-integration",category:"developer",tags:["Microsoft Teams","Teams","Website Tab","iframe","SSO","embedding"],icon:l.Monitor},{title:"Architecture",description:"Vue d'ensemble de l'architecture fonctionnelle de SmartStack",href:"/system/docs/user/architecture",category:"user",tags:["architecture","modules","navigation","contextes"],icon:l.Layers},{title:"Modules",description:"Liste des modules disponibles et leur configuration",href:"/system/docs/user/modules",category:"user",tags:["modules","fonctionnalites","features"],icon:l.FileText},{title:"Module Support",description:"Documentation complete du module de ticketing et support client",href:"/system/docs/user/support",category:"user",tags:["tickets","support","SLA","escalation","templates"],icon:l.Headphones},{title:"Intelligence Artificielle",description:"Configuration des providers IA, prompts et integrations",href:"/system/docs/user/ai",category:"user",tags:["IA","AI","prompts","OpenAI","Claude","providers"],icon:l.Bot},{title:"Parametres Systeme",description:"Configuration globale et parametres de la plateforme",href:"/system/docs/user/settings",category:"user",tags:["settings","configuration","parametres","systeme"],icon:l.Settings},{title:"Presentation SmartStack",description:"Presentation interactive de la plateforme SmartStack",href:"/system/docs/presentation",category:"user",tags:["presentation","slides","demo","overview"],icon:l.Presentation}];function mi({className:t="",placeholder:s="Rechercher...",onResultClick:r}){const[a,o]=n.useState(""),[c,i]=n.useState(!1),[d,u]=n.useState(0),m=n.useRef(null),p=n.useRef(null),f=w.useNavigate(),h=n.useMemo(()=>{if(!a.trim())return[];const j=a.toLowerCase().split(" ").filter(Boolean);return ui.filter(v=>{const S=[v.title,v.description,...v.tags,v.category].join(" ").toLowerCase();return j.every(N=>S.includes(N))})},[a]);n.useEffect(()=>{u(0)},[h]);const b=j=>{if(!(!c||h.length===0))switch(j.key){case"ArrowDown":j.preventDefault(),u(v=>(v+1)%h.length);break;case"ArrowUp":j.preventDefault(),u(v=>(v-1+h.length)%h.length);break;case"Enter":j.preventDefault(),h[d]&&g(h[d]);break;case"Escape":i(!1),o(""),m.current?.blur();break}},g=j=>{f(j.href),o(""),i(!1),r?.()};n.useEffect(()=>{const j=v=>{p.current&&!p.current.contains(v.target)&&m.current&&!m.current.contains(v.target)&&i(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const y=j=>j==="developer"?"Developpeur":"Utilisateur",x=j=>j==="developer"?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400";return e.jsxs("div",{className:`relative ${t}`,children:[e.jsxs("div",{className:"relative",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{ref:m,type:"text",value:a,onChange:j=>{o(j.target.value),i(!0)},onFocus:()=>i(!0),onKeyDown:b,placeholder:s,className:"w-full pl-9 pr-8 py-2 text-sm bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary-400)] focus:border-transparent"}),a&&e.jsx("button",{onClick:()=>{o(""),m.current?.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-[var(--bg-hover)]",children:e.jsx(l.X,{className:"w-3 h-3 text-[var(--text-tertiary)]"})})]}),c&&a.trim()&&e.jsxs("div",{ref:p,className:"absolute top-full left-0 right-0 mt-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg overflow-hidden z-50 max-h-80 overflow-y-auto",children:[h.length===0?e.jsxs("div",{className:"p-4 text-center text-[var(--text-secondary)] text-sm",children:['Aucun resultat pour "',a,'"']}):e.jsx("div",{className:"py-1",children:h.map((j,v)=>{const S=j.icon;return e.jsxs("button",{onClick:()=>g(j),onMouseEnter:()=>u(v),className:`w-full flex items-start gap-3 px-3 py-2 text-left transition-colors ${v===d?"bg-[var(--color-primary-600)]/10":"hover:bg-[var(--bg-hover)]"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${v===d?"bg-[var(--color-primary-600)] text-white":"bg-[var(--bg-secondary)]"}`,children:e.jsx(S,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:j.title}),e.jsx("span",{className:`px-1.5 py-0.5 text-xs rounded ${x(j.category)}`,children:y(j.category)})]}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] truncate mt-0.5",children:j.description})]}),e.jsx(l.ArrowRight,{className:`w-4 h-4 flex-shrink-0 mt-2 ${v===d?"text-[var(--color-primary-600)]":"text-[var(--text-tertiary)]"}`})]},j.href)})}),e.jsxs("div",{className:"px-3 py-2 border-t border-[var(--border-color)] bg-[var(--bg-secondary)] text-xs text-[var(--text-tertiary)] flex items-center gap-4",children:[e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"↑↓"})," naviguer"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"↵"})," ouvrir"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-[var(--bg-primary)] border border-[var(--border-color)]",children:"esc"})," fermer"]})]})]})]})}const pi=[{title:"Accueil",href:"/system/docs",icon:l.Book},{title:"Developpeur",href:"/system/docs/developer",icon:l.Code,children:[{title:"Infrastructure",href:"/system/docs/developer/infrastructure"},{title:"Installation",href:"/system/docs/developer/installation"},{title:"Base de donnees",href:"/system/docs/developer/database"},{title:"Dual-DbContext",href:"/system/docs/developer/dual-dbcontext"},{title:"FK Cross-Schema",href:"/system/docs/developer/cross-schema-fk"},{title:"Tenant",href:"/system/docs/developer/tenants",children:[{title:"Mode Multi-Tenant",href:"/system/docs/developer/tenants/multi-tenant-mode"},{title:"Tenant B2C",href:"/system/docs/developer/tenants/b2c"}]},{title:"Integration Teams",href:"/system/docs/developer/teams-integration"},{title:"Tests de Securite",href:"/system/docs/developer/testing/security"}]},{title:"Utilisateur",href:"/system/docs/user",icon:l.Users,children:[{title:"Architecture",href:"/system/docs/user/architecture"},{title:"Modules",href:"/system/docs/user/modules"}]},{title:"Analyse metier",href:"/system/docs/ba",icon:l.BarChart3}];function Yt({item:t,isChild:s=!1,depth:r=0}){const o=w.useLocation().pathname===t.href,c="icon"in t?t.icon:null;return e.jsxs(w.NavLink,{to:t.href,className:`flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${o?"bg-[var(--color-primary-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]"} ${s?"ml-6":""} ${r>1?"ml-12":""}`,children:[c&&e.jsx(c,{className:"w-4 h-4"}),!c&&s&&e.jsx(l.ChevronRight,{className:"w-3 h-3"}),t.title]})}function fa(){const[t,s]=n.useState(!1),r=w.useLocation(),[a]=w.useSearchParams(),o=a.get("embedded")==="true",c=p=>r.pathname===p.href?!0:"children"in p&&Array.isArray(p.children)?p.children.some(f=>r.pathname===f.href?!0:"children"in f&&Array.isArray(f.children)?f.children.some(h=>r.pathname===h.href):!1):!1,i=p=>r.pathname===p.href?!0:p.children?p.children.some(f=>r.pathname===f.href):!1,d=p=>p.children&&i(p)?e.jsx("div",{className:"mt-1 space-y-1",children:p.children.map(f=>e.jsx(Yt,{item:f,isChild:!0,depth:2},f.href))}):null,u=p=>p.children&&c(p)?e.jsx("div",{className:"mt-1 space-y-1",children:p.children.map(f=>e.jsxs("div",{children:[e.jsx(Yt,{item:f,isChild:!0}),d(f)]},f.href))}):null,m=()=>e.jsx("nav",{className:"space-y-1",children:pi.map(p=>e.jsxs("div",{children:[e.jsx(Yt,{item:p}),u(p)]},p.href))});return o?e.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:e.jsx("main",{className:"p-4 lg:p-6",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(w.Outlet,{})})})}):e.jsx(gs,{children:e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)] flex flex-col",children:[e.jsx(ys,{}),e.jsxs("div",{className:"flex-1 flex pt-16",children:[e.jsx("button",{className:"lg:hidden fixed bottom-4 right-4 z-50 p-3 rounded-full bg-[var(--color-primary-600)] text-white shadow-lg",onClick:()=>s(!t),children:t?e.jsx(l.X,{className:"w-6 h-6"}):e.jsx(l.Menu,{className:"w-6 h-6"})}),t&&e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 z-40 bg-black/50",onClick:()=>s(!1),"aria-label":"Close sidebar"}),e.jsx("aside",{className:`fixed lg:sticky top-16 z-40 lg:z-0 h-[calc(100vh-4rem)] w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] overflow-y-auto transition-transform lg:translate-x-0 ${t?"translate-x-0":"-translate-x-full"}`,children:e.jsxs("div",{className:"p-4",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx(l.Book,{className:"w-5 h-5 text-[var(--color-primary-600)]"}),"Documentation"]}),e.jsx(mi,{className:"mb-4",placeholder:"Rechercher dans la doc...",onResultClick:()=>s(!1)}),e.jsx(m,{})]})}),e.jsx("main",{className:"flex-1 min-w-0 p-6 lg:p-8",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(w.Outlet,{})})})]}),e.jsx(js,{})]})})}const xi=Object.freeze(Object.defineProperty({__proto__:null,DocsLayout:fa},Symbol.toStringTag,{value:"Module"}));function ba(){return e.jsx(gs,{children:e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)] flex flex-col",children:[e.jsx(ys,{}),e.jsx("main",{className:"flex-1 pt-16",children:e.jsx(w.Outlet,{})}),e.jsx(js,{})]})})}const hi=Object.freeze(Object.defineProperty({__proto__:null,PublicLayout:ba},Symbol.toStringTag,{value:"Module"}));function gi({items:t,className:s=""}){return e.jsx("nav",{"aria-label":"Breadcrumb",className:`flex items-center gap-1 text-sm ${s}`,children:t.map((r,a)=>{const o=a===t.length-1,c=a===0;return e.jsxs("div",{className:"flex items-center gap-1",children:[a>0&&e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),o&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--text-primary)] font-medium",children:[r.icon,r.label]}),!o&&r.href&&e.jsxs(w.Link,{to:r.href,className:"flex items-center gap-1.5 text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",children:[c&&!r.icon&&e.jsx(l.Home,{className:"w-4 h-4"}),r.icon,r.label]}),!o&&!r.href&&e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[r.icon,r.label]})]},`${a}-${r.label}`)})})}function Jt(t,s){return s.split(".").reduce((r,a)=>{if(r&&typeof r=="object"&&a in r)return r[a]},t)}function fi(t){return t==="right"?"justify-end":t==="center"?"justify-center":""}function bi(t,s){const r=s.toLowerCase();return Object.values(t).some(a=>a==null?!1:String(a).toLowerCase().includes(r))}function vi({data:t,columns:s,loading:r=!1,searchable:a=!1,searchPlaceholder:o="Rechercher...",pagination:c,onRowClick:i,getRowKey:d=(N,I)=>String(I),emptyMessage:u="Aucune donnée",emptyIcon:m,headerActions:p,striped:f=!0,compact:h=!1,className:b="",selectable:g=!1,selectedKeys:y=new Set,onSelectionChange:x,searchFilter:j=bi,defaultSortKey:v,defaultSortDirection:S="asc"}){const[N,I]=n.useState(""),[P,k]=n.useState(v||null),[A,R]=n.useState(S),[$,q]=n.useState(1),[C,D]=n.useState(c?.pageSize||10),Y=Array.isArray(t)?t:[],T=n.useMemo(()=>N?Y.filter(G=>j(G,N)):Y,[Y,N,j]),z=n.useMemo(()=>P?[...T].sort((G,ce)=>{const de=Jt(G,P),he=Jt(ce,P);if(de===he)return 0;if(de==null)return 1;if(he==null)return-1;const pe=String(de).localeCompare(String(he),void 0,{numeric:!0});return A==="asc"?pe:-pe}):T,[T,P,A]),Z=n.useMemo(()=>{if(!c)return z;const G=($-1)*C;return z.slice(G,G+C)},[z,c,$,C]),H=c?Math.ceil(z.length/C):1,J=z.length,fe=c?($-1)*C+1:1,B=c?Math.min($*C,J):J,Q=G=>{P===G?R(ce=>ce==="asc"?"desc":"asc"):(k(G),R("asc"))},M=G=>{q(Math.max(1,Math.min(G,H)))},re=()=>{if(!x)return;const G=Z.map((de,he)=>d(de,he));if(G.every(de=>y.has(de))){const de=new Set(y);G.forEach(he=>de.delete(he)),x(de)}else{const de=new Set(y);G.forEach(he=>de.add(he)),x(de)}},F=G=>{if(!x)return;const ce=new Set(y);ce.has(G)?ce.delete(G):ce.add(G),x(ce)},K=G=>{I(G),q(1)},V=h?"px-3 py-2":"px-4 py-3",ae=h?"px-3 py-2":"px-4 py-3",ue=G=>G.sortable?P===G.key?A==="asc"?e.jsx(l.ChevronUp,{className:"w-4 h-4"}):e.jsx(l.ChevronDown,{className:"w-4 h-4"}):e.jsx(l.ChevronsUpDown,{className:"w-4 h-4 opacity-30"}):null;return e.jsxs("div",{className:`${b}`,children:[(a||p)&&e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-4",children:[a&&e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)] pointer-events-none"}),e.jsx("input",{type:"text",value:N,onChange:G=>K(G.target.value),placeholder:o,className:"input w-full pl-10 pr-10"}),N&&e.jsx("button",{onClick:()=>K(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:e.jsx(l.X,{className:"w-4 h-4"})})]}),p&&e.jsx("div",{className:"flex items-center gap-2",children:p})]}),e.jsx("div",{className:"overflow-x-auto border border-[var(--border-color)] rounded-lg",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)] border-b border-[var(--border-color)]",children:e.jsxs("tr",{children:[g&&e.jsx("th",{className:`${ae} w-12`,children:e.jsx("input",{type:"checkbox",checked:Z.length>0&&Z.every((G,ce)=>y.has(d(G,ce))),onChange:re,className:"rounded border-[var(--border-color)]"})}),s.map(G=>e.jsx("th",{className:`${ae} text-${G.align||"left"} text-sm font-medium text-[var(--text-secondary)] ${G.hideOnMobile?"hidden md:table-cell":""} ${G.sortable?"cursor-pointer hover:bg-[var(--bg-tertiary)] select-none":""}`,style:{width:G.width},onClick:()=>G.sortable&&Q(G.key),children:e.jsxs("div",{className:`flex items-center gap-1 ${fi(G.align)}`,children:[e.jsx("span",{children:G.label}),ue(G)]})},G.key))]})}),e.jsxs("tbody",{children:[r&&e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(g?1:0),className:"py-12 text-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 mx-auto animate-spin text-[var(--color-primary-500)]"})})}),!r&&Z.length===0&&e.jsx("tr",{children:e.jsxs("td",{colSpan:s.length+(g?1:0),className:"py-12 text-center",children:[m&&e.jsx("div",{className:"mb-3",children:m}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:u})]})}),!r&&Z.length>0&&Z.map((G,ce)=>{const de=d(G,ce),he=y.has(de),pe=($-1)*C+ce;return e.jsxs("tr",{onClick:()=>i?.(G,pe),className:`
13
13
  border-b border-[var(--border-color)] last:border-b-0
14
14
  ${f&&ce%2===1?"bg-[var(--bg-secondary)]/50":""}
15
15
  ${i?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}
16
16
  ${he?"bg-[var(--accent-bg)]":""}
17
17
  transition-colors
18
- `,children:[h&&e.jsx("td",{className:`${V} w-12`,onClick:ye=>ye.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:he,onChange:()=>F(de),className:"rounded border-[var(--border-color)]"})}),s.map(ye=>e.jsx("td",{className:`${V} text-${ye.align||"left"} ${ye.hideOnMobile?"hidden md:table-cell":""}`,children:ye.render?ye.render(G,pe):String(Yt(G,ye.key)??"")},ye.key))]},de)})]})]})}),c&&J>0&&e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[fe,"-",B," sur ",J]}),c.showSizeSelector&&e.jsx("select",{value:C,onChange:G=>{D(Number(G.target.value)),q(1)},className:"input py-1 text-sm",children:(c.pageSizeOptions||[10,25,50,100]).map(G=>e.jsxs("option",{value:G,children:[G," / page"]},G))})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>M(1),disabled:$===1,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Première page",children:e.jsx(l.ChevronsLeft,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>M($-1),disabled:$===1,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Page précédente",children:e.jsx(l.ChevronLeft,{className:"w-4 h-4"})}),e.jsxs("span",{className:"px-3 text-sm",children:["Page ",$," / ",H]}),e.jsx("button",{onClick:()=>M($+1),disabled:$===H,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Page suivante",children:e.jsx(l.ChevronRight,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>M(H),disabled:$===H,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Dernière page",children:e.jsx(l.ChevronsRight,{className:"w-4 h-4"})})]})]})]})}function bi({data:t,viewMode:s,onViewModeChange:r,renderTable:a,renderCards:o,renderKanban:c,showTableView:i=!0,showCardsView:d=!0,showKanbanView:u=!0,tableLabel:m="Table",cardsLabel:p="Cards",kanbanLabel:f="Kanban"}){const[g,b]=n.useState("table"),h=s??g,y=r??b,j=[{mode:"table",label:m,icon:l.LayoutList,show:i},{mode:"cards",label:p,icon:l.LayoutGrid,show:d},{mode:"kanban",label:f,icon:l.Columns3,show:u}].filter(v=>v.show);return e.jsxs("div",{className:"space-y-4",children:[j.length>1&&e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] w-fit",children:j.map(({mode:v,label:S,icon:N})=>e.jsxs("button",{onClick:()=>y(v),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${h===v?"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(N,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:S})]},v))}),e.jsxs("div",{children:[h==="table"&&a&&a(t),h==="cards"&&o&&o(t),h==="kanban"&&c&&c(t)]})]})}function ba({viewMode:t,onChange:s,showTable:r=!0,showCards:a=!0,showKanban:o=!0,tableLabel:c="Table",cardsLabel:i="Cards",kanbanLabel:d="Kanban"}){const m=[{mode:"table",label:c,icon:l.LayoutList,show:r},{mode:"cards",label:i,icon:l.LayoutGrid,show:a},{mode:"kanban",label:d,icon:l.Columns3,show:o}].filter(p=>p.show);return m.length<=1?null:e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:m.map(({mode:p,label:f,icon:g})=>e.jsxs("button",{onClick:()=>s(p),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${t===p?"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(g,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:f})]},p))})}const qs=["from-violet-500 to-purple-500","from-blue-500 to-cyan-500","from-emerald-500 to-teal-500","from-orange-500 to-amber-500","from-pink-500 to-rose-500","from-indigo-500 to-blue-500","from-fuchsia-500 to-pink-500","from-cyan-500 to-blue-500"];function vi(t){let s=0;for(let r=0;r<t.length;r++)s=t.charCodeAt(r)+((s<<5)-s);return qs[Math.abs(s)%qs.length]}function yi(t){return t.split(" ").map(s=>s.at(0)).join("").toUpperCase().slice(0,2)}function ji({name:t,size:s="md",className:r=""}){const a={xs:"w-6 h-6 text-xs",sm:"w-8 h-8 text-xs",md:"w-10 h-10 text-sm",lg:"w-12 h-12 text-base",xl:"w-16 h-16 text-lg"},o={xs:"",sm:"shadow-md",md:"shadow-lg shadow-primary-500/20",lg:"shadow-lg shadow-primary-500/20",xl:"shadow-xl shadow-primary-500/25"};return e.jsx("div",{className:`${a[s]} ${o[s]} rounded-full bg-gradient-to-br ${vi(t)} flex items-center justify-center text-white font-semibold ${r}`,children:yi(t)})}function Mt({status:t,label:s,showDot:r=!0,size:a="md"}){const o={active:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",inactive:"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)] border-[var(--border-color)]",pending:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",error:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]"},c={active:"bg-[var(--success-dot)]",inactive:"bg-[var(--text-muted)]",pending:"bg-[var(--warning-dot)]",warning:"bg-[var(--warning-dot)]",error:"bg-[var(--error-dot)]"},i={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-xs"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 ${i[a]} rounded-[var(--radius-badge)] font-medium border ${o[t]}`,children:[r&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c[t]}`}),s]})}function Ni({role:t,variant:s="default",icon:r}){const a={accent:"bg-[var(--accent-bg)] text-[var(--accent-text)] border-[var(--accent-border)]",default:"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-[var(--radius-badge)] text-xs font-medium border ${a[s]}`,children:[r,t]})}function va({title:t,count:s,color:r,children:a,isDragOver:o,isDropDisabled:c,onDragOver:i,onDragLeave:d,onDrop:u}){const m={success:"bg-[var(--success-dot)]",warning:"bg-[var(--warning-dot)]",error:"bg-[var(--error-dot)]",default:"bg-[var(--text-muted)]"};return e.jsxs("div",{className:`min-w-[280px] flex-1 rounded-lg p-2 transition-colors ${o&&!c?"bg-[var(--color-accent-500)]/10 ring-2 ring-[var(--color-accent-500)]/50":""} ${c?"opacity-40":""}`,onDragOver:c?void 0:i,onDragLeave:d,onDrop:c?void 0:u,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${m[r]}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:t}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:s})]}),e.jsx("div",{className:"space-y-3 min-h-[100px]",children:a})]})}function ya({children:t,onClick:s,draggable:r=!0,isDragging:a,onDragStart:o,onDragEnd:c}){return e.jsx("div",{draggable:r,onClick:s,onKeyDown:s?i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),s())}:void 0,role:s?"button":void 0,tabIndex:s?0:void 0,onDragStart:o,onDragEnd:c,className:`bg-[var(--bg-card)] border border-[var(--border-color)] rounded-[var(--radius-card)] p-4 transition-all hover:shadow-md hover:border-[var(--color-accent-500)]/30 cursor-grab active:cursor-grabbing ${a?"opacity-50 scale-95":""}`,children:t})}function ja({page:t,totalPages:s,totalCount:r,pageSize:a=20,onPageChange:o,itemLabel:c="éléments",showInfo:i=!0,showFirstLast:d=!0}){const u=(t-1)*a+1,m=Math.min(t*a,r),p=()=>{const f=[];if(s<=7)for(let g=1;g<=s;g++)f.push(g);else{f.push(1),t>3&&f.push("ellipsis");const g=Math.max(2,t-1),b=Math.min(s-1,t+1);for(let h=g;h<=b;h++)f.includes(h)||f.push(h);t<s-2&&f.push("ellipsis"),f.includes(s)||f.push(s)}return f};return e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4",children:[i&&e.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Affichage de"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:u})," ","à"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:m})," ","sur"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:r})," ",c]}),s>1&&e.jsxs("div",{className:"flex items-center gap-1",children:[d&&e.jsx("button",{onClick:()=>o(1),disabled:t===1,className:"hidden sm:flex btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Première page",children:e.jsx(l.ChevronsLeft,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>o(Math.max(1,t-1)),disabled:t===1,className:"btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Page précédente",children:e.jsx(l.ChevronLeft,{className:"w-5 h-5"})}),e.jsx("div",{className:"flex items-center gap-1",children:p().map((f,g)=>f==="ellipsis"?e.jsx("span",{className:"px-2 text-[var(--text-muted)]",children:"..."},`ellipsis-${g}`):e.jsx("button",{onClick:()=>o(f),className:`w-10 h-10 rounded-[var(--radius-button)] text-sm font-medium transition-all ${t===f?"bg-[var(--color-accent-600)] text-white shadow-lg shadow-[var(--color-accent-500)]/30":"btn btn-secondary hover:bg-[var(--bg-hover)]"}`,children:f},`page-${f}`))}),e.jsx("button",{onClick:()=>o(Math.min(s,t+1)),disabled:t===s,className:"btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Page suivante",children:e.jsx(l.ChevronRight,{className:"w-5 h-5"})}),d&&e.jsx("button",{onClick:()=>o(s),disabled:t===s,className:"hidden sm:flex btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Dernière page",children:e.jsx(l.ChevronsRight,{className:"w-4 h-4"})})]})]})})}const Us={default:"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",primary:"bg-[var(--accent-bg)] text-[var(--color-primary-600)]",success:"bg-[var(--success-bg)] text-[var(--success-text)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)]",error:"bg-[var(--error-bg)] text-[var(--error-text)]",info:"bg-[var(--info-bg)] text-[var(--info-text)]"};function ys({avatar:t,title:s,subtitle:r,description:a,stats:o,badge:c,links:i,actions:d,tags:u,onClick:m,className:p="",customHeader:f,customBody:g,customFooter:b}){const h=["bg-[var(--bg-card)]","border-2 border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]","rounded-[var(--radius-card)]","overflow-hidden","transition-all","hover:shadow-lg hover:border-[var(--color-accent-400)]","flex flex-col",m?"cursor-pointer":"",p].filter(Boolean).join(" "),y=()=>t?t.imageUrl?e.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden flex-shrink-0 shadow-lg",children:e.jsx("img",{src:t.imageUrl,alt:s,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold shadow-lg flex-shrink-0",style:{backgroundColor:t.color},children:t.letter}):null,x=()=>{if(!c)return null;const N=c.icon,I=c.color?{color:c.color}:{};return e.jsxs("div",{className:"group relative",children:[N&&e.jsx(N,{className:"w-5 h-5 text-[var(--color-accent-700)] dark:text-[var(--color-accent-400)]",style:I}),c.tooltip&&e.jsx("div",{className:"absolute top-full right-0 mt-1 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded text-xs text-[var(--text-secondary)] whitespace-nowrap opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-10",children:c.tooltip})]})},j=()=>f||e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-4 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y(),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)]",children:s}),r&&e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:r})]})]}),x()]})}),v=()=>g||e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[a&&e.jsx("div",{className:"text-sm text-[var(--text-secondary)] line-clamp-2",children:typeof a=="string"?e.jsx("p",{children:a}):a}),o&&e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-3",children:typeof o=="string"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:o.split(" ")[0]})," ",o.split(" ").slice(1).join(" ")]}):o}),(u?.length??0)>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:u?.map(N=>N.onClick?e.jsx("button",{type:"button",className:`text-xs px-2 py-1 rounded-full cursor-pointer hover:opacity-80 ${Us[N.variant||"default"]}`,onClick:N.onClick,children:N.label},N.label):e.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${Us[N.variant||"default"]}`,children:N.label},N.label))}),(i?.length??0)>0&&e.jsx("div",{className:"space-y-1.5 pt-2 mt-3 border-t border-[var(--border-color)]",children:i?.map(N=>{const I=N.icon;return N.href?e.jsxs("a",{href:N.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",onClick:P=>P.stopPropagation(),children:[e.jsx(I,{className:"w-3.5 h-3.5"}),N.label]},N.label):e.jsxs("button",{onClick:P=>{P.stopPropagation(),N.onClick?.()},className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",children:[e.jsx(I,{className:"w-3.5 h-3.5"}),N.label]},N.label)})}),e.jsx("div",{className:"flex-1 min-h-4"}),S()]}),S=()=>b||(!d||d.length===0?null:e.jsx("div",{className:"space-y-2 mt-3",children:d.map(N=>{const I=N.icon,P=N.variant||"primary",R=`btn btn-sm flex items-center justify-center gap-1 w-full ${{primary:"bg-[var(--color-accent-500)] hover:bg-[var(--color-accent-600)] text-white",secondary:"bg-[var(--color-accent-700)] hover:bg-[var(--color-accent-800)] text-white",ghost:"bg-transparent border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-secondary)]"}[P]} ${N.disabled?"opacity-50 cursor-not-allowed":""}`,$=N.loading&&e.jsx("span",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),q=!N.loading&&I&&e.jsx(I,{className:"w-4 h-4"});return N.href?e.jsxs("a",{href:N.href,target:"_blank",rel:"noopener noreferrer",className:R,onClick:C=>C.stopPropagation(),children:[$,q,N.label]},N.label):e.jsxs("button",{onClick:C=>{C.stopPropagation(),N.onClick?.()},disabled:N.disabled||N.loading,className:R,children:[$,q,N.label]},N.label)})}));return m?e.jsxs("button",{type:"button",className:`${h} text-left w-full`,onClick:m,children:[j(),v()]}):e.jsxs("div",{className:h,children:[j(),v()]})}function wi({name:t,code:s,description:r,modelCount:a,color:o,websiteUrl:c,docsUrl:i,apiKeyUrl:d,adminApiKeyUrl:u,hasAdminKey:m=!1,badgeIcon:p,badgeTooltip:f,onGetApiKey:g,onGetAdminApiKey:b,labels:h={}}){const{websiteLabel:y="Site officiel",docsLabel:x="Documentation API",apiKeyLabel:j="Obtenir une clé API",adminApiKeyLabel:v="Obtenir une clé API Admin",modelsLabel:S="modèle(s)"}=h,N=[];c&&N.push({icon:l.ExternalLink,label:y,href:c}),i&&N.push({icon:l.BookOpen,label:x,href:i});const I=[];return d?I.push({label:j,href:d,variant:"primary"}):g&&I.push({label:j,onClick:g,variant:"primary"}),m&&(u?I.push({label:v,href:u,variant:"secondary"}):b&&I.push({label:v,onClick:b,variant:"secondary"})),e.jsx(ys,{avatar:{letter:t.at(0)?.toUpperCase()??"",color:o},title:t,subtitle:s,description:r,stats:`${a} ${S}`,badge:p?{icon:p,tooltip:f}:void 0,links:N,actions:I})}function Si({name:t,code:s,category:r,isActive:a=!0,isSystem:o=!1,icon:c,iconColor:i="var(--color-accent-500)",translationsCount:d,onEdit:u,onDelete:m,onClick:p,labels:f={}}){const{systemLabel:g="System",inactiveLabel:b="Inactif",activeLabel:h="Actif",editLabel:y="Modifier",deleteLabel:x="Supprimer"}=f,j=[{label:r,variant:"default"}];o&&j.push({label:g,variant:"info"});const v=[];u&&v.push({label:y,onClick:u,variant:"ghost"}),m&&!o&&v.push({label:x,onClick:m,variant:"ghost"});const S=e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-4 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[c?e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center shadow-lg",style:{backgroundColor:i},children:e.jsx(c,{className:"w-5 h-5 text-white"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold shadow-lg",style:{backgroundColor:i},children:t.at(0)?.toUpperCase()}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)]",children:t}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:s})]})]}),e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${a?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),a?h:b]})]})}),N=e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(I=>e.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${I.variant==="info"?"bg-[var(--info-bg)] text-[var(--info-text)]":"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"}`,children:I.label},I.label))}),d!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-3 text-[var(--text-tertiary)]",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m5 8 6 6"}),e.jsx("path",{d:"m4 14 6-6 2-3"}),e.jsx("path",{d:"M2 5h12"}),e.jsx("path",{d:"M7 2h1"}),e.jsx("path",{d:"m22 22-5-10-5 10"}),e.jsx("path",{d:"M14 18h6"})]}),e.jsx("span",{className:"text-xs",children:d})]}),e.jsx("div",{className:"flex-1 min-h-4"}),v.length>0&&e.jsx("div",{className:"flex items-center justify-end gap-1 mt-3 pt-3 border-t border-[var(--border-color)]",children:v.map(I=>e.jsx("button",{onClick:P=>{P.stopPropagation(),I.onClick?.()},className:"p-1.5 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] transition-all",title:I.label,children:I.label===y?e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"})}):e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})},I.label))})]});return e.jsx(ys,{title:t,subtitle:s,onClick:p,customHeader:S,customBody:N})}function Ci({columns:t,items:s,getItemId:r,getItemColumn:a,onMoveItem:o,renderCard:c,loading:i=!1,onAddItem:d,onCardClick:u,cardActions:m,emptyColumnMessage:p="Aucun élément",className:f="",columnMinWidth:g="280px",disabled:b=!1}){const[h,y]=n.useState(null),[x,j]=n.useState(null),[v,S]=n.useState(null),N=n.useCallback(C=>{C.onClick(),S(null)},[]),I=n.useCallback((C,D)=>e.jsxs("button",{onClick:Y=>{Y.stopPropagation(),N(C)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-[var(--bg-tertiary)]",children:[C.icon,C.label]},D),[N]),P=n.useCallback(C=>s.filter(D=>a(D)===C),[s,a]),k=(C,D)=>{b||(y(D),C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",D))},A=(C,D)=>{b||!h||(C.preventDefault(),C.dataTransfer.dropEffect="move",j(D))},R=()=>{j(null)},$=(C,D)=>{if(b)return;C.preventDefault();const Y=C.dataTransfer.getData("text/plain");Y&&o(Y,D),y(null),j(null)},q=()=>{y(null),j(null)};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-500)]"})}):e.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${f}`,children:t.map(C=>{const D=P(C.id),Y=x===C.id,T=C.maxItems!==void 0&&D.length>=C.maxItems;return e.jsxs("div",{className:`flex-shrink-0 flex flex-col rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)] ${Y?"ring-2 ring-[var(--color-primary-500)]":""}`,style:{minWidth:g,maxWidth:g},onDragOver:z=>A(z,C.id),onDragLeave:R,onDrop:z=>$(z,C.id),children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[C.color&&e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:C.color}}),e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)]",children:C.title}),e.jsxs("span",{className:"text-xs text-[var(--text-secondary)] px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)]",children:[D.length,C.maxItems!==void 0&&` / ${C.maxItems}`]})]}),d&&C.canAddItem!==!1&&!T&&e.jsx("button",{onClick:()=>d(C.id),className:"btn btn-ghost p-1 hover:bg-[var(--bg-tertiary)]",title:"Ajouter","aria-label":`Ajouter à ${C.title}`,children:e.jsx(l.Plus,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex-1 p-2 space-y-2 overflow-y-auto max-h-[calc(100vh-300px)]",children:[D.length===0?e.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)] text-sm",children:p}):D.map((z,Z)=>{const H=r(z),J=h===H,fe=m?.(z);return e.jsxs("div",{draggable:!b,onDragStart:B=>k(B,H),onDragEnd:q,onClick:()=>u?.(z),onKeyDown:u?B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),u(z))}:void 0,role:u?"button":void 0,tabIndex:u?0:void 0,className:`
18
+ `,children:[g&&e.jsx("td",{className:`${V} w-12`,onClick:ye=>ye.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:he,onChange:()=>F(de),className:"rounded border-[var(--border-color)]"})}),s.map(ye=>e.jsx("td",{className:`${V} text-${ye.align||"left"} ${ye.hideOnMobile?"hidden md:table-cell":""}`,children:ye.render?ye.render(G,pe):String(Jt(G,ye.key)??"")},ye.key))]},de)})]})]})}),c&&J>0&&e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[fe,"-",B," sur ",J]}),c.showSizeSelector&&e.jsx("select",{value:C,onChange:G=>{D(Number(G.target.value)),q(1)},className:"input py-1 text-sm",children:(c.pageSizeOptions||[10,25,50,100]).map(G=>e.jsxs("option",{value:G,children:[G," / page"]},G))})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>M(1),disabled:$===1,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Première page",children:e.jsx(l.ChevronsLeft,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>M($-1),disabled:$===1,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Page précédente",children:e.jsx(l.ChevronLeft,{className:"w-4 h-4"})}),e.jsxs("span",{className:"px-3 text-sm",children:["Page ",$," / ",H]}),e.jsx("button",{onClick:()=>M($+1),disabled:$===H,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Page suivante",children:e.jsx(l.ChevronRight,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>M(H),disabled:$===H,className:"btn btn-ghost p-2 disabled:opacity-30",title:"Dernière page",children:e.jsx(l.ChevronsRight,{className:"w-4 h-4"})})]})]})]})}function yi({data:t,viewMode:s,onViewModeChange:r,renderTable:a,renderCards:o,renderKanban:c,showTableView:i=!0,showCardsView:d=!0,showKanbanView:u=!0,tableLabel:m="Table",cardsLabel:p="Cards",kanbanLabel:f="Kanban"}){const[h,b]=n.useState("table"),g=s??h,y=r??b,j=[{mode:"table",label:m,icon:l.LayoutList,show:i},{mode:"cards",label:p,icon:l.LayoutGrid,show:d},{mode:"kanban",label:f,icon:l.Columns3,show:u}].filter(v=>v.show);return e.jsxs("div",{className:"space-y-4",children:[j.length>1&&e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] w-fit",children:j.map(({mode:v,label:S,icon:N})=>e.jsxs("button",{onClick:()=>y(v),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${g===v?"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(N,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:S})]},v))}),e.jsxs("div",{children:[g==="table"&&a&&a(t),g==="cards"&&o&&o(t),g==="kanban"&&c&&c(t)]})]})}function va({viewMode:t,onChange:s,showTable:r=!0,showCards:a=!0,showKanban:o=!0,tableLabel:c="Table",cardsLabel:i="Cards",kanbanLabel:d="Kanban"}){const m=[{mode:"table",label:c,icon:l.LayoutList,show:r},{mode:"cards",label:i,icon:l.LayoutGrid,show:a},{mode:"kanban",label:d,icon:l.Columns3,show:o}].filter(p=>p.show);return m.length<=1?null:e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:m.map(({mode:p,label:f,icon:h})=>e.jsxs("button",{onClick:()=>s(p),className:`px-3 py-1.5 rounded-[var(--radius-button)] text-sm font-medium flex items-center gap-2 transition-all ${t===p?"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(h,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:f})]},p))})}const zs=["from-violet-500 to-purple-500","from-blue-500 to-cyan-500","from-emerald-500 to-teal-500","from-orange-500 to-amber-500","from-pink-500 to-rose-500","from-indigo-500 to-blue-500","from-fuchsia-500 to-pink-500","from-cyan-500 to-blue-500"];function ji(t){let s=0;for(let r=0;r<t.length;r++)s=t.charCodeAt(r)+((s<<5)-s);return zs[Math.abs(s)%zs.length]}function Ni(t){return t.split(" ").map(s=>s.at(0)).join("").toUpperCase().slice(0,2)}function wi({name:t,size:s="md",className:r=""}){const a={xs:"w-6 h-6 text-xs",sm:"w-8 h-8 text-xs",md:"w-10 h-10 text-sm",lg:"w-12 h-12 text-base",xl:"w-16 h-16 text-lg"},o={xs:"",sm:"shadow-md",md:"shadow-lg shadow-primary-500/20",lg:"shadow-lg shadow-primary-500/20",xl:"shadow-xl shadow-primary-500/25"};return e.jsx("div",{className:`${a[s]} ${o[s]} rounded-full bg-gradient-to-br ${ji(t)} flex items-center justify-center text-white font-semibold ${r}`,children:Ni(t)})}function Ot({status:t,label:s,showDot:r=!0,size:a="md"}){const o={active:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",inactive:"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)] border-[var(--border-color)]",pending:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",error:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]"},c={active:"bg-[var(--success-dot)]",inactive:"bg-[var(--text-muted)]",pending:"bg-[var(--warning-dot)]",warning:"bg-[var(--warning-dot)]",error:"bg-[var(--error-dot)]"},i={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-xs"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 ${i[a]} rounded-[var(--radius-badge)] font-medium border ${o[t]}`,children:[r&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c[t]}`}),s]})}function Si({role:t,variant:s="default",icon:r}){const a={accent:"bg-[var(--accent-bg)] text-[var(--accent-text)] border-[var(--accent-border)]",default:"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-[var(--radius-badge)] text-xs font-medium border ${a[s]}`,children:[r,t]})}function ya({title:t,count:s,color:r,children:a,isDragOver:o,isDropDisabled:c,onDragOver:i,onDragLeave:d,onDrop:u}){const m={success:"bg-[var(--success-dot)]",warning:"bg-[var(--warning-dot)]",error:"bg-[var(--error-dot)]",default:"bg-[var(--text-muted)]"};return e.jsxs("div",{className:`min-w-[280px] flex-1 rounded-lg p-2 transition-colors ${o&&!c?"bg-[var(--color-accent-500)]/10 ring-2 ring-[var(--color-accent-500)]/50":""} ${c?"opacity-40":""}`,onDragOver:c?void 0:i,onDragLeave:d,onDrop:c?void 0:u,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${m[r]}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:t}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:s})]}),e.jsx("div",{className:"space-y-3 min-h-[100px]",children:a})]})}function ja({children:t,onClick:s,draggable:r=!0,isDragging:a,onDragStart:o,onDragEnd:c}){return e.jsx("div",{draggable:r,onClick:s,onKeyDown:s?i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),s())}:void 0,role:s?"button":void 0,tabIndex:s?0:void 0,onDragStart:o,onDragEnd:c,className:`bg-[var(--bg-card)] border border-[var(--border-color)] rounded-[var(--radius-card)] p-4 transition-all hover:shadow-md hover:border-[var(--color-accent-500)]/30 cursor-grab active:cursor-grabbing ${a?"opacity-50 scale-95":""}`,children:t})}function Na({page:t,totalPages:s,totalCount:r,pageSize:a=20,onPageChange:o,itemLabel:c="éléments",showInfo:i=!0,showFirstLast:d=!0}){const u=(t-1)*a+1,m=Math.min(t*a,r),p=()=>{const f=[];if(s<=7)for(let h=1;h<=s;h++)f.push(h);else{f.push(1),t>3&&f.push("ellipsis");const h=Math.max(2,t-1),b=Math.min(s-1,t+1);for(let g=h;g<=b;g++)f.includes(g)||f.push(g);t<s-2&&f.push("ellipsis"),f.includes(s)||f.push(s)}return f};return e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4",children:[i&&e.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Affichage de"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:u})," ","à"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:m})," ","sur"," ",e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:r})," ",c]}),s>1&&e.jsxs("div",{className:"flex items-center gap-1",children:[d&&e.jsx("button",{onClick:()=>o(1),disabled:t===1,className:"hidden sm:flex btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Première page",children:e.jsx(l.ChevronsLeft,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>o(Math.max(1,t-1)),disabled:t===1,className:"btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Page précédente",children:e.jsx(l.ChevronLeft,{className:"w-5 h-5"})}),e.jsx("div",{className:"flex items-center gap-1",children:p().map((f,h)=>f==="ellipsis"?e.jsx("span",{className:"px-2 text-[var(--text-muted)]",children:"..."},`ellipsis-${h}`):e.jsx("button",{onClick:()=>o(f),className:`w-10 h-10 rounded-[var(--radius-button)] text-sm font-medium transition-all ${t===f?"bg-[var(--color-accent-600)] text-white shadow-lg shadow-[var(--color-accent-500)]/30":"btn btn-secondary hover:bg-[var(--bg-hover)]"}`,children:f},`page-${f}`))}),e.jsx("button",{onClick:()=>o(Math.min(s,t+1)),disabled:t===s,className:"btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Page suivante",children:e.jsx(l.ChevronRight,{className:"w-5 h-5"})}),d&&e.jsx("button",{onClick:()=>o(s),disabled:t===s,className:"hidden sm:flex btn btn-secondary p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:"Dernière page",children:e.jsx(l.ChevronsRight,{className:"w-4 h-4"})})]})]})})}const Bs={default:"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",primary:"bg-[var(--accent-bg)] text-[var(--color-primary-600)]",success:"bg-[var(--success-bg)] text-[var(--success-text)]",warning:"bg-[var(--warning-bg)] text-[var(--warning-text)]",error:"bg-[var(--error-bg)] text-[var(--error-text)]",info:"bg-[var(--info-bg)] text-[var(--info-text)]"};function Ns({avatar:t,title:s,subtitle:r,description:a,stats:o,badge:c,links:i,actions:d,tags:u,onClick:m,className:p="",customHeader:f,customBody:h,customFooter:b}){const g=["bg-[var(--bg-card)]","border-2 border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]","rounded-[var(--radius-card)]","overflow-hidden","transition-all","hover:shadow-lg hover:border-[var(--color-accent-400)]","flex flex-col",m?"cursor-pointer":"",p].filter(Boolean).join(" "),y=()=>t?t.imageUrl?e.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden flex-shrink-0 shadow-lg",children:e.jsx("img",{src:t.imageUrl,alt:s,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold shadow-lg flex-shrink-0",style:{backgroundColor:t.color},children:t.letter}):null,x=()=>{if(!c)return null;const N=c.icon,I=c.color?{color:c.color}:{};return e.jsxs("div",{className:"group relative",children:[N&&e.jsx(N,{className:"w-5 h-5 text-[var(--color-accent-700)] dark:text-[var(--color-accent-400)]",style:I}),c.tooltip&&e.jsx("div",{className:"absolute top-full right-0 mt-1 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded text-xs text-[var(--text-secondary)] whitespace-nowrap opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-10",children:c.tooltip})]})},j=()=>f||e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-4 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y(),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)]",children:s}),r&&e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:r})]})]}),x()]})}),v=()=>h||e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[a&&e.jsx("div",{className:"text-sm text-[var(--text-secondary)] line-clamp-2",children:typeof a=="string"?e.jsx("p",{children:a}):a}),o&&e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-3",children:typeof o=="string"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:o.split(" ")[0]})," ",o.split(" ").slice(1).join(" ")]}):o}),(u?.length??0)>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:u?.map(N=>N.onClick?e.jsx("button",{type:"button",className:`text-xs px-2 py-1 rounded-full cursor-pointer hover:opacity-80 ${Bs[N.variant||"default"]}`,onClick:N.onClick,children:N.label},N.label):e.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${Bs[N.variant||"default"]}`,children:N.label},N.label))}),(i?.length??0)>0&&e.jsx("div",{className:"space-y-1.5 pt-2 mt-3 border-t border-[var(--border-color)]",children:i?.map(N=>{const I=N.icon;return N.href?e.jsxs("a",{href:N.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",onClick:P=>P.stopPropagation(),children:[e.jsx(I,{className:"w-3.5 h-3.5"}),N.label]},N.label):e.jsxs("button",{onClick:P=>{P.stopPropagation(),N.onClick?.()},className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] transition-colors",children:[e.jsx(I,{className:"w-3.5 h-3.5"}),N.label]},N.label)})}),e.jsx("div",{className:"flex-1 min-h-4"}),S()]}),S=()=>b||(!d||d.length===0?null:e.jsx("div",{className:"space-y-2 mt-3",children:d.map(N=>{const I=N.icon,P=N.variant||"primary",R=`btn btn-sm flex items-center justify-center gap-1 w-full ${{primary:"bg-[var(--color-accent-500)] hover:bg-[var(--color-accent-600)] text-white",secondary:"bg-[var(--color-accent-700)] hover:bg-[var(--color-accent-800)] text-white",ghost:"bg-transparent border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-secondary)]"}[P]} ${N.disabled?"opacity-50 cursor-not-allowed":""}`,$=N.loading&&e.jsx("span",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),q=!N.loading&&I&&e.jsx(I,{className:"w-4 h-4"});return N.href?e.jsxs("a",{href:N.href,target:"_blank",rel:"noopener noreferrer",className:R,onClick:C=>C.stopPropagation(),children:[$,q,N.label]},N.label):e.jsxs("button",{onClick:C=>{C.stopPropagation(),N.onClick?.()},disabled:N.disabled||N.loading,className:R,children:[$,q,N.label]},N.label)})}));return m?e.jsxs("button",{type:"button",className:`${g} text-left w-full`,onClick:m,children:[j(),v()]}):e.jsxs("div",{className:g,children:[j(),v()]})}function Ci({name:t,code:s,description:r,modelCount:a,color:o,websiteUrl:c,docsUrl:i,apiKeyUrl:d,adminApiKeyUrl:u,hasAdminKey:m=!1,badgeIcon:p,badgeTooltip:f,onGetApiKey:h,onGetAdminApiKey:b,labels:g={}}){const{websiteLabel:y="Site officiel",docsLabel:x="Documentation API",apiKeyLabel:j="Obtenir une clé API",adminApiKeyLabel:v="Obtenir une clé API Admin",modelsLabel:S="modèle(s)"}=g,N=[];c&&N.push({icon:l.ExternalLink,label:y,href:c}),i&&N.push({icon:l.BookOpen,label:x,href:i});const I=[];return d?I.push({label:j,href:d,variant:"primary"}):h&&I.push({label:j,onClick:h,variant:"primary"}),m&&(u?I.push({label:v,href:u,variant:"secondary"}):b&&I.push({label:v,onClick:b,variant:"secondary"})),e.jsx(Ns,{avatar:{letter:t.at(0)?.toUpperCase()??"",color:o},title:t,subtitle:s,description:r,stats:`${a} ${S}`,badge:p?{icon:p,tooltip:f}:void 0,links:N,actions:I})}function ki({name:t,code:s,category:r,isActive:a=!0,isSystem:o=!1,icon:c,iconColor:i="var(--color-accent-500)",translationsCount:d,onEdit:u,onDelete:m,onClick:p,labels:f={}}){const{systemLabel:h="System",inactiveLabel:b="Inactif",activeLabel:g="Actif",editLabel:y="Modifier",deleteLabel:x="Supprimer"}=f,j=[{label:r,variant:"default"}];o&&j.push({label:h,variant:"info"});const v=[];u&&v.push({label:y,onClick:u,variant:"ghost"}),m&&!o&&v.push({label:x,onClick:m,variant:"ghost"});const S=e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-4 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[c?e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center shadow-lg",style:{backgroundColor:i},children:e.jsx(c,{className:"w-5 h-5 text-white"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold shadow-lg",style:{backgroundColor:i},children:t.at(0)?.toUpperCase()}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-[var(--text-primary)]",children:t}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:s})]})]}),e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${a?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),a?g:b]})]})}),N=e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(I=>e.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${I.variant==="info"?"bg-[var(--info-bg)] text-[var(--info-text)]":"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"}`,children:I.label},I.label))}),d!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-3 text-[var(--text-tertiary)]",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m5 8 6 6"}),e.jsx("path",{d:"m4 14 6-6 2-3"}),e.jsx("path",{d:"M2 5h12"}),e.jsx("path",{d:"M7 2h1"}),e.jsx("path",{d:"m22 22-5-10-5 10"}),e.jsx("path",{d:"M14 18h6"})]}),e.jsx("span",{className:"text-xs",children:d})]}),e.jsx("div",{className:"flex-1 min-h-4"}),v.length>0&&e.jsx("div",{className:"flex items-center justify-end gap-1 mt-3 pt-3 border-t border-[var(--border-color)]",children:v.map(I=>e.jsx("button",{onClick:P=>{P.stopPropagation(),I.onClick?.()},className:"p-1.5 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] transition-all",title:I.label,children:I.label===y?e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"})}):e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})},I.label))})]});return e.jsx(Ns,{title:t,subtitle:s,onClick:p,customHeader:S,customBody:N})}function Ai({columns:t,items:s,getItemId:r,getItemColumn:a,onMoveItem:o,renderCard:c,loading:i=!1,onAddItem:d,onCardClick:u,cardActions:m,emptyColumnMessage:p="Aucun élément",className:f="",columnMinWidth:h="280px",disabled:b=!1}){const[g,y]=n.useState(null),[x,j]=n.useState(null),[v,S]=n.useState(null),N=n.useCallback(C=>{C.onClick(),S(null)},[]),I=n.useCallback((C,D)=>e.jsxs("button",{onClick:Y=>{Y.stopPropagation(),N(C)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-[var(--bg-tertiary)]",children:[C.icon,C.label]},D),[N]),P=n.useCallback(C=>s.filter(D=>a(D)===C),[s,a]),k=(C,D)=>{b||(y(D),C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",D))},A=(C,D)=>{b||!g||(C.preventDefault(),C.dataTransfer.dropEffect="move",j(D))},R=()=>{j(null)},$=(C,D)=>{if(b)return;C.preventDefault();const Y=C.dataTransfer.getData("text/plain");Y&&o(Y,D),y(null),j(null)},q=()=>{y(null),j(null)};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-500)]"})}):e.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${f}`,children:t.map(C=>{const D=P(C.id),Y=x===C.id,T=C.maxItems!==void 0&&D.length>=C.maxItems;return e.jsxs("div",{className:`flex-shrink-0 flex flex-col rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)] ${Y?"ring-2 ring-[var(--color-primary-500)]":""}`,style:{minWidth:h,maxWidth:h},onDragOver:z=>A(z,C.id),onDragLeave:R,onDrop:z=>$(z,C.id),children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[C.color&&e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:C.color}}),e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)]",children:C.title}),e.jsxs("span",{className:"text-xs text-[var(--text-secondary)] px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)]",children:[D.length,C.maxItems!==void 0&&` / ${C.maxItems}`]})]}),d&&C.canAddItem!==!1&&!T&&e.jsx("button",{onClick:()=>d(C.id),className:"btn btn-ghost p-1 hover:bg-[var(--bg-tertiary)]",title:"Ajouter","aria-label":`Ajouter à ${C.title}`,children:e.jsx(l.Plus,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex-1 p-2 space-y-2 overflow-y-auto max-h-[calc(100vh-300px)]",children:[D.length===0?e.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)] text-sm",children:p}):D.map((z,Z)=>{const H=r(z),J=g===H,fe=m?.(z);return e.jsxs("div",{draggable:!b,onDragStart:B=>k(B,H),onDragEnd:q,onClick:()=>u?.(z),onKeyDown:u?B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),u(z))}:void 0,role:u?"button":void 0,tabIndex:u?0:void 0,className:`
19
19
  relative group
20
20
  bg-[var(--bg-card)] border border-[var(--border-color)] rounded-lg
21
21
  ${b?"":"cursor-grab active:cursor-grabbing"}
22
22
  ${J?"opacity-50 ring-2 ring-[var(--color-primary-500)]":""}
23
23
  ${u?"hover:border-[var(--color-primary-500)]":""}
24
24
  transition-all
25
- `,children:[!b&&e.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-6 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(l.GripVertical,{className:"w-4 h-4 text-[var(--text-secondary)]"})}),e.jsx("div",{className:`p-3 ${b?"":"pl-6"}`,children:c(z,Z)}),(fe?.length??0)>0&&e.jsxs("div",{className:"absolute top-2 right-2",children:[e.jsx("button",{onClick:B=>{B.stopPropagation(),S(v===H?null:H)},className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100 hover:bg-[var(--bg-tertiary)]","aria-label":"Actions",children:e.jsx(l.MoreHorizontal,{className:"w-4 h-4"})}),v===H&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"fixed inset-0 z-40",onClick:()=>S(null),"aria-label":"Close menu"}),e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-lg shadow-lg py-1 min-w-[150px]",children:fe?.map((B,Q)=>I(B,Q))})]})]})]},H)}),Y&&D.length>0&&e.jsx("div",{className:"h-16 border-2 border-dashed border-[var(--color-primary-500)] rounded-lg bg-[var(--accent-bg)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm text-[var(--color-primary-500)]",children:"Déposer ici"})})]})]},C.id)})})}function ki({title:t,subtitle:s,icon:r,actions:a}){return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[r,t]}),s&&e.jsx("p",{className:"text-[var(--text-secondary)]",children:s})]}),a&&e.jsx("div",{className:"flex items-center gap-3",children:a})]})}const Jt={granted:{icon:l.Check,color:"var(--success-text)",bg:"var(--success-bg)",label:"Accordé"},denied:{icon:l.X,color:"var(--error-text)",bg:"var(--error-bg)",label:"Refusé"},partial:{icon:l.Minus,color:"var(--warning-text)",bg:"var(--warning-bg)",label:"Partiel"},inherited:{icon:l.Check,color:"var(--info-text)",bg:"var(--info-bg)",label:"Hérité"},none:{icon:l.Minus,color:"var(--text-tertiary)",bg:"transparent",label:"Non défini"}};function Ai({rows:t,columns:s,getRowId:r,getRowLabel:a,getRowGroup:o,getRowSubGroup:c,getRowIcon:i,isRowLocked:d,getRowChildCount:u,getColumnId:m,getColumnLabel:p,getColumnShortLabel:f,isColumnLocked:g,getColumnColor:b,getCellState:h,onCellClick:y,loading:x=!1,showLegend:j=!0,searchable:v=!1,rowColumnWidth:S="250px",cellWidth:N="44px",className:I="",emptyMessage:P="Aucune donnée",canEditLocked:k=!1}){const[A,R]=n.useState(new Set),[$,q]=n.useState(""),C=n.useMemo(()=>{const B=new Map;return t.forEach(Q=>{const M=o?.(Q)||"_default",re=c?.(Q);B.has(M)||B.set(M,{rows:[],subGroups:new Map});const F=B.get(M);re?(F.subGroups.has(re)||F.subGroups.set(re,[]),F.subGroups.get(re).push(Q)):F.rows.push(Q)}),B},[t,o,c]),D=n.useCallback((B,Q)=>{const M=new Map;return B.forEach((re,F)=>{const K=re.filter(V=>a(V).toLowerCase().includes(Q));K.length>0&&M.set(F,K)}),M},[a]),Y=n.useMemo(()=>{if(!$)return C;const B=$.toLowerCase(),Q=new Map;return C.forEach((M,re)=>{const F=M.rows.filter(V=>a(V).toLowerCase().includes(B)),K=D(M.subGroups,B);(F.length>0||K.size>0)&&Q.set(re,{rows:F,subGroups:K})}),Q},[C,$,a,D]),T=B=>{R(Q=>{const M=new Set(Q);return M.has(B)?M.delete(B):M.add(B),M})},z=n.useCallback((B,Q,M,re)=>{y&&(M&&!k||re&&!k||y(B,Q))},[y,k]),Z=n.useCallback((B,Q)=>!(!y||B&&!k||Q&&!k),[y,k]),H=(B,Q)=>`w-full h-full min-h-[32px] flex items-center justify-center rounded transition-colors ${B?"hover:opacity-80 cursor-pointer":"cursor-default"} ${Q!=="none"?"":"opacity-30"}`,J=n.useCallback((B,Q,M,re,F,K,V,ae)=>{const ue=re.icon,G=Z(F,K);return e.jsx("td",{className:"px-0 py-1 text-center",style:{width:N},children:e.jsx("button",{type:"button",onClick:()=>z(B,Q,F,K),disabled:!G,className:H(G,M),style:{backgroundColor:re.bg},title:`${a(V)} × ${p(ae)}: ${re.label}`,children:M!=="none"&&e.jsx(ue,{className:"w-4 h-4",style:{color:re.color}})})},`${B}-${Q}`)},[y,k,z,N,a,p,Z,H]),fe=n.useCallback((B,Q,M,re,F)=>{const K=r(B),V=d?.(B)||!1,ae=i?.(B),ue=Q%2===0?"bg-[var(--bg-primary)]":"bg-[var(--bg-secondary)]/50",G=Q%2===0?"":"bg-[var(--bg-secondary)]/50";return e.jsxs("tr",{className:`hover:bg-[var(--bg-tertiary)] ${G}`,children:[e.jsx("td",{className:`sticky left-0 z-10 px-3 py-2 pl-12 ${ue}`,style:{width:re},children:e.jsxs("div",{className:"flex items-center gap-2",children:[ae,V&&e.jsx(l.Lock,{className:"w-3 h-3 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:a(B)})]})}),M.map(ce=>{const de=m(ce),he=g?.(ce)||!1,pe=F(K,de),ye=Jt[pe];return J(K,de,pe,ye,V,he,B,ce)})]},K)},[r,d,i,a,m,g,J]);return x?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-500)]"})}):t.length===0||s.length===0?e.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:P}):e.jsxs("div",{className:`space-y-4 ${I}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[v&&e.jsxs("div",{className:"relative max-w-xs",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("input",{type:"text",value:$,onChange:B=>q(B.target.value),placeholder:"Rechercher...",className:"input pl-10 w-full"})]}),j&&e.jsx("div",{className:"flex items-center gap-4 text-xs",children:Object.entries(Jt).map(([B,Q])=>{if(B==="none")return null;const M=Q.icon;return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center",style:{backgroundColor:Q.bg},children:e.jsx(M,{className:"w-3 h-3",style:{color:Q.color}})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:Q.label})]},B)})})]}),e.jsx("div",{className:"overflow-x-auto border border-[var(--border-color)] rounded-lg",children:e.jsxs("table",{className:"border-collapse",style:{width:"auto"},children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-[var(--bg-secondary)] px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider border-b border-[var(--border-color)]",style:{width:S,minWidth:S,height:"120px",verticalAlign:"bottom",paddingBottom:"12px"},children:"Ressource"}),s.map(B=>{const Q=m(B),M=f?.(B)||p(B),re=g?.(B),F=b?.(B);return e.jsx("th",{className:"relative overflow-visible border-b border-[var(--border-color)]",style:{width:N,minWidth:N,maxWidth:N,height:"120px",padding:0,verticalAlign:"bottom"},children:e.jsx("div",{className:"absolute bottom-2 left-1/2",style:{transform:"translateX(-6px) rotate(-55deg)",transformOrigin:"bottom left",width:"100px"},children:e.jsxs("div",{className:"flex items-center gap-1",children:[re&&e.jsx(l.Lock,{className:"w-3 h-3 flex-shrink-0 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-[10px] font-medium text-[var(--text-primary)] whitespace-nowrap",style:{color:F},title:p(B),children:M})]})})},Q)})]})}),e.jsx("tbody",{children:Array.from(Y.entries()).map(([B,Q])=>{const M=A.has(B),re=B==="_default",F=Q.rows.length+Array.from(Q.subGroups.values()).reduce((K,V)=>K+V.length,0);return e.jsxs("tbody",{children:[!re&&e.jsxs("tr",{className:"bg-[var(--color-accent-900)]/30",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-2 bg-[var(--color-accent-900)]/30",style:{width:S},children:e.jsxs("button",{onClick:()=>T(B),className:"flex items-center gap-2 w-full text-left hover:opacity-80",children:[M?e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--color-accent-400)]"}):e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--color-accent-400)]"}),e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-300)] uppercase",children:B}),e.jsxs("span",{className:"text-xs text-[var(--color-accent-400)]",children:["(",F,")"]})]})}),e.jsx("td",{colSpan:s.length})]}),!M&&e.jsxs(e.Fragment,{children:[Q.rows.map((K,V)=>{const ae=r(K),ue=d?.(K)||!1,G=i?.(K),ce=u?.(K),de=V%2===0?"bg-[var(--bg-primary)]":"bg-[var(--bg-secondary)]/50",he=V%2===0?"":"bg-[var(--bg-secondary)]/50";return e.jsxs("tr",{className:`hover:bg-[var(--bg-tertiary)] ${he}`,children:[e.jsx("td",{className:`sticky left-0 z-10 px-3 py-2 ${de}`,style:{width:S},children:e.jsxs("div",{className:"flex items-center gap-2",children:[G,ue&&e.jsx(l.Lock,{className:"w-3 h-3 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:a(K)}),ce!==void 0&&e.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",ce,")"]})]})}),s.map(pe=>{const ye=m(pe),qe=g?.(pe)||!1,Ue=h(ae,ye),Ve=Jt[Ue];return J(ae,ye,Ue,Ve,ue,qe,K,pe)})]},ae)}),Array.from(Q.subGroups.entries()).map(([K,V])=>e.jsxs("tbody",{children:[e.jsxs("tr",{className:"bg-[var(--bg-tertiary)]",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-1 pl-8 bg-[var(--bg-tertiary)]",style:{width:S},children:e.jsxs("span",{className:"text-xs font-semibold text-[var(--text-secondary)] uppercase",children:[K," (",V.length,")"]})}),e.jsx("td",{colSpan:s.length})]}),V.map((ae,ue)=>fe(ae,ue,s,S,h))]},K))]})]},B)})})]})})]})}const Pi=[{size:"none",icon:"square"},{size:"small",icon:"rounded"},{size:"medium",icon:"rounded"},{size:"large",icon:"rounded"},{size:"xlarge",icon:"rounded"},{size:"xxlarge",icon:"rounded"}];function it({label:t,element:s,value:r,onChange:a}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Pi.map(({size:o})=>e.jsx("button",{onClick:()=>a(s,o),className:`px-3 py-2 text-xs font-medium transition-all ${r===o?"bg-[var(--color-accent-500)] text-white":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,style:{borderRadius:Qe[o]},children:Qa[o]},o))})]})}const Ti=({selectedThemeTenant:t,setSelectedThemeTenant:s,currentTenant:r,t:a})=>e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Globe,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:a("theme.scope.title","Portée du thème")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:a("theme.scope.description","Choisissez si ce thème s'applique à tous vos espaces ou uniquement à l'espace actuel")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>s(null),className:`flex-1 flex items-center gap-3 p-4 transition-all border ${t===null?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Globe,{className:`w-5 h-5 ${t===null?"text-[var(--color-accent-500)]":"text-[var(--text-muted)]"}`}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:`font-medium ${t===null?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:a("theme.scope.global","Global")}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5",children:a("theme.scope.globalDesc","Tous les espaces")})]}),t===null&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] ml-auto"})]}),e.jsxs("button",{type:"button",onClick:()=>s(r.id),className:`flex-1 flex items-center gap-3 p-4 transition-all border ${t===r.id?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Building2,{className:`w-5 h-5 ${t===r.id?"text-[var(--color-accent-500)]":"text-[var(--text-muted)]"}`}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:`font-medium ${t===r.id?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:r.name}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5",children:a("theme.scope.tenantDesc","Espace actuel uniquement")})]}),t===r.id&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] ml-auto"})]})]})]});function Ri({onSync:t,isSyncing:s=!1,syncSuccess:r=!1}){const{t:a}=ne.useTranslation("preferences"),{config:o,mode:c,setMode:i,setBorderRadius:d,setAccentColor:u,setItemPalette:m,applyPreset:p,resetToDefault:f,selectedThemeTenant:g,setSelectedThemeTenant:b}=Ct(),{currentTenant:h,hasMultipleTenants:y}=Ee(),x=y&&h;return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-[var(--text-primary)]",children:"Personnalisation"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Personnalisez l'apparence de l'interface"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsxs("button",{type:"button",onClick:t,disabled:s,className:"flex items-center gap-2 px-3 py-2 text-sm font-medium text-white bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{borderRadius:"var(--radius-button)"},children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),"Sync..."]}),!s&&r&&e.jsxs(e.Fragment,{children:[e.jsx(l.Check,{className:"w-4 h-4"}),"Synchronisé"]}),!s&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),"Synchroniser"]})]}),e.jsxs("button",{onClick:f,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--text-secondary)] bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:[e.jsx(l.RotateCcw,{className:"w-4 h-4"}),"Réinitialiser"]})]})]}),x&&e.jsx(Ti,{selectedThemeTenant:g,setSelectedThemeTenant:b,currentTenant:h,t:a}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Thèmes prédéfinis"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:en.map(j=>{const v=o.accentColorKey===j.config.accentColorKey&&JSON.stringify(o.borderRadius)===JSON.stringify(j.config.borderRadius);return e.jsxs("button",{onClick:()=>p(j.config),className:`p-4 text-left transition-all border ${v?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-2xl",children:j.icon}),v&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)]"})]}),e.jsx("div",{className:"font-semibold text-[var(--text-primary)]",children:j.name}),e.jsx("div",{className:"text-xs text-[var(--text-muted)] mt-1",children:j.description})]},j.id)})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Mode d'affichage"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>i("light"),className:`flex-1 flex items-center justify-center gap-3 p-4 transition-all border ${c==="light"?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Sun,{className:`w-5 h-5 ${c==="light"?"text-amber-500":"text-[var(--text-muted)]"}`}),e.jsx("span",{className:`font-medium ${c==="light"?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:"Clair"})]}),e.jsxs("button",{onClick:()=>i("dark"),className:`flex-1 flex items-center justify-center gap-3 p-4 transition-all border ${c==="dark"?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Moon,{className:`w-5 h-5 ${c==="dark"?"text-[var(--color-accent-400)]":"text-[var(--text-muted)]"}`}),e.jsx("span",{className:`font-medium ${c==="dark"?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:"Sombre"})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Palette,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Couleur d'accent"})]}),e.jsx("div",{className:"flex flex-wrap gap-3",children:Object.entries(_e).map(([j,{name:v,shades:S}])=>e.jsx("button",{onClick:()=>u(j),className:`relative w-10 h-10 transition-all ${o.accentColorKey===j?"ring-2 ring-offset-2 ring-[var(--border-strong)]":""}`,style:{backgroundColor:S[500],borderRadius:"var(--radius-button)"},title:v,children:o.accentColorKey===j&&e.jsx(l.Check,{className:"absolute inset-0 m-auto w-5 h-5 text-white"})},j))}),e.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:["Couleur actuelle: ",e.jsx("span",{className:"font-medium text-[var(--color-accent-500)]",children:_e[o.accentColorKey]?.name})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Layers,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Palette des éléments"})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Choisissez une palette de couleurs pour les cards et éléments de l'interface"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:Object.entries(ut).map(([j,v])=>{const S=c==="dark"?v.colors.dark:v.colors.light,N=o.itemPaletteKey===j;return e.jsxs("button",{onClick:()=>m(j),className:`p-4 text-left transition-all border ${N?"border-[var(--color-accent-500)] ring-2 ring-[var(--color-accent-500)] ring-opacity-30":"border-[var(--border-color)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-xl",children:v.icon}),N&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)]"})]}),e.jsxs("div",{className:"flex h-8 mb-3 rounded overflow-hidden border",style:{borderColor:S.dark},children:[e.jsx("div",{className:"flex-1",style:{backgroundColor:S.light}}),e.jsx("div",{className:"flex-1",style:{backgroundColor:S.medium}}),e.jsx("div",{className:"flex-1",style:{backgroundColor:S.dark}})]}),e.jsx("div",{className:"font-semibold text-[var(--text-primary)] text-sm",children:v.name})]},j)})}),e.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:["Palette actuelle: ",e.jsx("span",{className:"font-medium text-[var(--color-accent-500)]",children:ut[o.itemPaletteKey]?.name})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Square,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Style des coins"})]}),e.jsxs("div",{className:"space-y-4 p-4 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-card)"},children:[e.jsx(it,{label:"Cards & Containers",element:"card",value:o.borderRadius.card,onChange:d}),e.jsx(it,{label:"Boutons",element:"button",value:o.borderRadius.button,onChange:d}),e.jsx(it,{label:"Badges",element:"badge",value:o.borderRadius.badge,onChange:d}),e.jsx(it,{label:"Champs de saisie",element:"input",value:o.borderRadius.input,onChange:d}),e.jsx(it,{label:"Modales",element:"modal",value:o.borderRadius.modal,onChange:d}),e.jsx(it,{label:"Éléments de menu",element:"menuItem",value:o.borderRadius.menuItem,onChange:d})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Circle,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Aperçu"})]}),e.jsx("div",{className:"p-6 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-card)"},children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:"badge-success px-3 py-1 text-xs font-medium",children:"Succès"}),e.jsx("span",{className:"badge-warning px-3 py-1 text-xs font-medium",children:"Attention"}),e.jsx("span",{className:"badge-error px-3 py-1 text-xs font-medium",children:"Erreur"}),e.jsx("span",{className:"badge-info px-3 py-1 text-xs font-medium",children:"Info"}),e.jsx("span",{className:"badge-accent px-3 py-1 text-xs font-medium",children:"Accent"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{className:"btn btn-primary",children:"Bouton primaire"}),e.jsx("button",{className:"btn btn-secondary",children:"Bouton secondaire"}),e.jsx("button",{className:"btn btn-ghost",children:"Bouton ghost"})]}),e.jsx("div",{children:e.jsx("input",{type:"text",placeholder:"Champ de saisie exemple...",className:"input w-full"})}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-600)] flex items-center justify-center text-white font-bold",style:{borderRadius:"var(--radius-button)"},children:"A"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-[var(--text-primary)]",children:["Exemple de card (",ut[o.itemPaletteKey]?.name,")"]}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:"Cette card utilise la palette sélectionnée"})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"card p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Card 1"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"Aperçu du style"})]}),e.jsxs("div",{className:"card p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Card 2"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"Aperçu du style"})]})]})]})})]})]})}function Ei({title:t,description:s,icon:r,showBackButton:a=!0,backUrl:o,children:c}){const{t:i}=ne.useTranslation("common"),d=w.useNavigate(),u=()=>{d(o||-1)};return e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] p-8",children:e.jsxs("div",{className:"max-w-md w-full text-center",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-full bg-gradient-to-br from-amber-100 to-orange-100 dark:from-amber-900/30 dark:to-orange-900/30 flex items-center justify-center",children:r||e.jsx(l.Construction,{className:"w-10 h-10 text-amber-600 dark:text-amber-400"})}),e.jsx("h2",{className:"text-2xl font-bold text-[var(--text-primary)] mb-3",children:t||i("underDevelopment.title","En cours de développement")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:s||i("underDevelopment.description","Cette fonctionnalité est actuellement en cours de développement et sera disponible prochainement.")}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-8",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"300ms"}})]}),e.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:i("underDevelopment.workInProgress","Travail en cours")})]}),c,a&&e.jsxs("button",{onClick:u,className:"btn btn-secondary inline-flex items-center gap-2",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),i("common.back","Retour")]})]})})}function Ii({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}const Li=[{path:"/administration",icon:l.LayoutDashboard,labelKey:"sidebar.dashboard",exact:!0},{path:"/administration/users",icon:l.Users,labelKey:"sidebar.users"},{path:"/administration/roles",icon:l.Key,labelKey:"sidebar.roles"}];function $i({isOpen:t=!0,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),{favorites:o,loading:c}=Ke(),{expandFavorites:i,clearExpand:d}=Ke(),[u,m]=n.useState(!1);n.useEffect(()=>{i&&(queueMicrotask(()=>{m(!1)}),d())},[i,d]);const p=(g,b)=>b?a.pathname===g:a.pathname.startsWith(g),f=e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"lg:hidden flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("span",{className:"font-semibold",children:"Menu"}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-[var(--bg-tertiary)]",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[!c&&o.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("button",{onClick:()=>m(!u),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[u?e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"}):e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5"}),e.jsx(l.Star,{className:"w-3.5 h-3.5"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:"/myspace/preferences?tab=favorites",onClick:s,className:"p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),!u&&e.jsx("div",{className:"space-y-0.5",children:o.map(g=>{const b=a.pathname===g.route;return e.jsxs(w.Link,{to:g.route,onClick:s,className:`flex items-center gap-3 px-3 py-2 transition-colors ${b?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:`${g.label} (${g.applicationLabel})`,children:[e.jsx(Ii,{name:g.icon,className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium truncate",children:g.label})]},g.id)})}),e.jsx("div",{className:"my-3 border-b border-[var(--border-color)]"})]}),Li.map(g=>{const b=g.icon,h=p(g.path,g.exact);return e.jsxs(w.Link,{to:g.path,onClick:s,className:`flex items-center gap-3 px-3 py-2.5 transition-colors ${h?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(b,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:r(g.labelKey)})]},g.path)})]})]});return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"hidden lg:block w-64 h-[calc(100vh-4rem)] fixed top-16 left-0 bg-[var(--bg-secondary)] border-r border-[var(--border-color)]",children:f}),t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 bg-black/50 z-40",onClick:s,"aria-label":"Close sidebar"}),e.jsx("aside",{className:"lg:hidden fixed top-0 left-0 h-full w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] z-50",children:f})]})]})}function zs({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Di({isOpen:t=!0,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),{favorites:o,loading:c}=Ke(),{expandFavorites:i,clearExpand:d}=Ke(),{isCollapsed:u,toggleCollapsed:m}=qt(),{getApplicationsByZone:p}=Ce(),[f,g]=n.useState(!1),y=p("personal").find(v=>v.code==="myspace"||v.code==="core_myspace")?.modules||[];n.useEffect(()=>{i&&(queueMicrotask(()=>{g(!1)}),d())},[i,d]);const x=(v,S)=>S?a.pathname===v:a.pathname.startsWith(v),j=e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"lg:hidden flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("span",{className:"font-semibold",children:"Menu"}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-[var(--bg-tertiary)]",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("nav",{className:`flex-1 overflow-y-auto space-y-1 ${u?"p-2":"p-4"}`,children:[!c&&o.length>0&&e.jsxs("div",{className:"mb-4",children:[!u&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("button",{onClick:()=>g(!f),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[f?e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"}):e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5"}),e.jsx(l.Star,{className:"w-3.5 h-3.5"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:"/myspace/preferences?tab=favorites",onClick:s,className:"p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),(u||!f)&&e.jsx("div",{className:"space-y-0.5",children:o.map(v=>{const S=a.pathname===v.route;return e.jsxs(w.Link,{to:v.route,onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2":"gap-3 px-3 py-2"} ${S?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?`${v.label} (${v.applicationLabel})`:void 0,children:[e.jsx(zs,{name:v.icon,className:"w-4 h-4 flex-shrink-0"}),!u&&e.jsx("span",{className:"text-sm font-medium truncate",children:v.label}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:v.label})})]},v.id)})}),!u&&e.jsx("div",{className:"my-3 border-b border-[var(--border-color)]"})]}),e.jsxs(w.Link,{to:"/myspace",onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${x("/myspace",!0)?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?r("sidebar.dashboard"):void 0,children:[e.jsx(l.LayoutDashboard,{className:"w-5 h-5 flex-shrink-0"}),!u&&e.jsx("span",{className:"font-medium",children:r("sidebar.dashboard")}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("sidebar.dashboard")})})]}),y.map(v=>{const S=v.route||`/myspace/${v.code}`,N=x(S);return e.jsxs(w.Link,{to:S,onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${N?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?v.label:void 0,children:[e.jsx(zs,{name:v.icon||"Star",className:"w-5 h-5 flex-shrink-0"}),!u&&e.jsx("span",{className:"font-medium",children:v.label}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:v.label})})]},v.id)})]}),e.jsx("div",{className:`border-t border-[var(--border-color)] ${u?"p-2":"p-3"}`,children:e.jsx("button",{onClick:m,className:`hidden lg:flex w-full items-center transition-all text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] ${u?"justify-center px-2 py-2":"gap-2 px-3 py-2"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?r("sidebar.expand","Agrandir le menu"):r("sidebar.collapse","Réduire le menu"),children:u?e.jsx(l.PanelLeft,{className:"w-5 h-5"}):e.jsxs(e.Fragment,{children:[e.jsx(l.PanelLeftClose,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:r("sidebar.collapse","Réduire")})]})})})]});return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:`hidden lg:block h-[calc(100vh-4rem)] fixed top-16 left-0 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] transition-all duration-300 ${u?"w-16":"w-64"}`,children:j}),t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 bg-black/50 z-40",onClick:s,"aria-label":"Close sidebar"}),e.jsx("aside",{className:"lg:hidden fixed top-0 left-0 h-full w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] z-50",children:j})]})]})}function Mi(t){const s=t.message.toLowerCase(),r=t.name.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("failed to fetch")||s.includes("econnrefused")||s.includes("timeout")?"network":s.includes("401")||s.includes("403")||s.includes("unauthorized")||s.includes("forbidden")||s.includes("permission")?"permission":s.includes("404")||s.includes("not found")?"notFound":r.includes("validation")||s.includes("validation")||s.includes("invalid")?"validation":"technical"}function Oi(){const t=Date.now().toString(36),s=Math.random().toString(36).substring(2,6);return`ERR-${t}-${s}`.toUpperCase()}const Fi={network:{icon:l.WifiOff,color:"text-orange-500",bgColor:"bg-orange-500/10"},permission:{icon:l.ShieldX,color:"text-red-500",bgColor:"bg-red-500/10"},notFound:{icon:l.FileWarning,color:"text-yellow-500",bgColor:"bg-yellow-500/10"},validation:{icon:l.AlertTriangle,color:"text-amber-500",bgColor:"bg-amber-500/10"},technical:{icon:l.Bug,color:"text-red-500",bgColor:"bg-red-500/10"}};function _i({error:t,resetErrorBoundary:s}){const{t:r}=ne.useTranslation("common"),[a,o]=n.useState(!1),[c]=n.useState(()=>Oi()),i=Mi(t),d=Fi[i],u=d.icon,m=()=>{window.history.length>2&&document.referrer?window.location.href=document.referrer:window.history.length>2?(window.history.back(),setTimeout(()=>window.location.reload(),50)):window.location.href="/"};return e.jsx("div",{className:"flex items-center justify-center min-h-[400px] p-6",children:e.jsx("div",{className:"max-w-md w-full p-6 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-xl shadow-lg",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`w-14 h-14 rounded-full ${d.bgColor} flex items-center justify-center mb-4`,children:e.jsx(u,{className:`w-7 h-7 ${d.color}`})}),e.jsx("h2",{className:"text-xl font-bold text-[var(--text-primary)] mb-2",children:r(`errors.${i}.title`,{defaultValue:r("errors.technical.title")})}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:r(`errors.${i}.description`,{defaultValue:r("errors.technical.description")})}),e.jsxs("div",{className:"mb-4 px-2 py-1 bg-[var(--bg-tertiary)] rounded border border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[r("errors.errorId"),": "]}),e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:c})]}),!1,e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs("button",{onClick:s,className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-3 rounded-lg bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white text-sm font-medium transition-all",children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),r("errors.retry")]}),e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-3 rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] text-sm font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),r("errors.goBack")]})]})]})})})}function qi(t,s){Te.logError(t,"RouteErrorBoundary",{componentStack:s.componentStack})}function Ui({children:t}){return e.jsx(ur.ErrorBoundary,{FallbackComponent:_i,onError:qi,onReset:()=>{window.location.reload()},children:t})}function zi({feature:t,children:s,fallback:r,minimal:a=!1}){const{t:o}=ne.useTranslation("admin"),{isFeatureEnabled:c,license:i,isLoading:d}=He();return d?e.jsx(e.Fragment,{children:s}):c(t)?e.jsx(e.Fragment,{children:s}):r?e.jsx(e.Fragment,{children:r}):a?e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 rounded text-sm",children:[e.jsx(l.Lock,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:o("license.featureLocked","Locked")})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 bg-gray-50 dark:bg-gray-800/50 rounded-xl border-2 border-dashed border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(l.Lock,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:o("license.featureNotAvailable","Feature Not Available")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-sm mb-4",children:o("license.upgradeToAccess","Upgrade your license to access the {{feature}} feature.",{feature:t})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx(l.Sparkles,{className:"w-4 h-4"}),e.jsx("span",{children:o("license.currentEdition","Current: {{edition}}",{edition:i?.edition||"Unknown"})})]})]})}function Na({open:t,onOpenChange:s}){const{t:r}=ne.useTranslation("admin"),{activateLicense:a,license:o}=He(),{refreshMenu:c}=Ce(),[i,d]=n.useState(""),[u,m]=n.useState(""),[p,f]=n.useState(!1),[g,b]=n.useState(!1),[h,y]=n.useState(null),[x,j]=n.useState(!1),v=o?.hasApiKey??!1,S=async()=>{if(!i.trim()){y(r("license.errors.keyRequired","License key is required"));return}b(!0),y(null),j(!1);const I=await a(i.trim(),u.trim()||void 0);b(!1),I.success?(j(!0),await c(),setTimeout(()=>{d(""),m(""),f(!1),j(!1),s(!1)},1500)):y(I.error||r("license.errors.activationFailed","Activation failed"))},N=()=>{g||(d(""),m(""),f(!1),y(null),j(!1),s(!1))};return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:N,"aria-label":"Close dialog"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900/30 rounded-lg",children:e.jsx(l.Key,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("license.activateTitle","Activate License")})]}),e.jsx("button",{onClick:N,disabled:g,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50",children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("license.activateDescription","Enter your license key to activate the product. The key is a JWT token provided by AtlasHub.")}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("license.keyLabel","License Key")}),e.jsx("textarea",{value:i,onChange:I=>{d(I.target.value),y(null)},placeholder:r("license.keyPlaceholder","eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."),rows:6,disabled:g||x,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-mono text-xs bg-white dark:bg-gray-900 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed resize-none"})]}),v&&!p?e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4 text-green-600 dark:text-green-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-green-700 dark:text-green-300 flex-1",children:r("license.apiKeyConfigured","API key is already configured")}),e.jsx("button",{type:"button",onClick:()=>f(!0),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:r("license.apiKeyChange","Change")})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("license.apiKeyLabel","API Key")}),e.jsx("input",{type:"text",value:u,onChange:I=>{m(I.target.value),y(null)},placeholder:r("license.apiKeyPlaceholder","sslk_..."),disabled:g||x,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-mono text-sm bg-white dark:bg-gray-900 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("license.apiKeyDescription","API key provided by AtlasHub for server authentication (sslk_...).")})]}),h&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:h})]}),x&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx(l.CheckCircle,{className:"w-5 h-5 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-green-700 dark:text-green-300",children:r("license.activationSuccess","License activated successfully!")})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[r("license.activationHelp","Need a license key? Contact us at")," ",e.jsx("a",{href:"mailto:support@atlashub.ch",className:"text-blue-600 dark:text-blue-400 hover:underline",children:"support@atlashub.ch"})," ",r("license.activationHelpOr","or visit")," ",e.jsx("a",{href:"https://www.atlashub.ch",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:"www.atlashub.ch"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 px-6 py-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[e.jsx("button",{onClick:N,disabled:g,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("common:cancel","Cancel")}),e.jsxs("button",{onClick:S,disabled:g||x||!i.trim(),className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2",children:[g&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),x&&e.jsx(l.CheckCircle,{className:"w-4 h-4"}),g?r("license.activating","Activating..."):x?r("license.activated","Activated!"):r("license.activate","Activate")]})]})]})]}):null}function Bi({showDetails:t=!1}){const{t:s}=ne.useTranslation("admin"),{license:r,isLoading:a}=He();if(a||!r)return null;const{status:o,edition:c,isInTrial:i,trialDaysRemaining:d,isReadOnlyMode:u,daysUntilExpiration:m}=r;if(u)return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 rounded-full text-sm font-medium",children:[e.jsx(l.XCircle,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.readOnlyMode","Read-only mode")})]});if(i){const p=d<=7?"text-amber-800 dark:text-amber-200 bg-amber-100 dark:bg-amber-900/30":"text-blue-800 dark:text-blue-200 bg-blue-100 dark:bg-blue-900/30";return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium ${p}`,children:[e.jsx(l.Clock,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.trialDaysRemaining","{{days}} trial days left",{days:d})})]})}return m<=30&&o==="Active"?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-amber-100 dark:bg-amber-900/30 text-amber-800 dark:text-amber-200 rounded-full text-sm font-medium",children:[e.jsx(l.AlertTriangle,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.expiresIn","Expires in {{days}} days",{days:m})})]}):o==="Active"?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 rounded-full text-sm font-medium",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4"}),e.jsx("span",{children:s(`license.edition.${c.toLowerCase()}`,{defaultValue:c})}),t&&e.jsxs("span",{className:"text-xs opacity-75",children:["(",m," ",s("license.daysLeft","days left"),")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 rounded-full text-sm font-medium",children:[e.jsx(l.Shield,{className:"w-4 h-4"}),e.jsx("span",{children:s(`license.status.${o.toLowerCase()}`,{defaultValue:o})})]})}function os({reason:t,tenantName:s,permissionPath:r,applicationsUrl:a,userRoles:o,userPermissions:c}){const{t:i}=ne.useTranslation("common"),{menu:d}=Ce(),u=w.useLocation(),m=()=>{window.history.length>2?window.history.back():window.location.href="/"},p=r?.split(".")[0],f=n.useMemo(()=>c?.filter(v=>{if(v==="*")return!0;const S=v.toLowerCase();return p&&(S.startsWith(p.toLowerCase()+".")||S===p.toLowerCase())})??[],[c,p]),g=r&&(o?.length||c),b=n.useMemo(()=>{const v=u.pathname.split("/").filter(Boolean),S=v[0]==="t"?v.slice(2):v,N=S[0],I=S[1],P=S[2],k=S[3],A=T=>/^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(T),R=T=>T.replace(/^(core_|ext_)/,""),$=T=>T.charAt(0).toUpperCase()+T.slice(1).replace(/-/g," "),q=d?.applications.find(T=>T.route?.split("/").filter(Boolean)[0]===N||R(T.code)===N),C=I?q?.modules.find(T=>T.route?.split("/").filter(Boolean)[1]===I||R(T.code)===I):void 0,D=P&&!A(P)?C?.sections.find(T=>T.route?.split("/").filter(Boolean)[2]===P||R(T.code)===P):void 0,Y=k&&!A(k)?D?.resources.find(T=>T.route?.split("/").filter(Boolean)[3]===k||R(T.code)===k):void 0;return{application:q?.label||(N?$(N):void 0),module:C?.label||(I&&!A(I)?$(I):void 0),section:D?.label||(P&&!A(P)?$(P):void 0),resource:Y?.label||(k&&!A(k)?$(k):void 0)}},[d,u.pathname]),h=n.useMemo(()=>{const v=[];return b.application&&v.push(`- ${i("errors.accessDenied.ticket.applicationLabel")}: ${b.application}`),b.module&&v.push(`- ${i("errors.accessDenied.ticket.moduleLabel")}: ${b.module}`),b.section&&v.push(`- ${i("errors.accessDenied.ticket.sectionLabel")}: ${b.section}`),b.resource&&v.push(`- ${i("errors.accessDenied.ticket.resourceLabel")}: ${b.resource}`),v.length===0?"":`
25
+ `,children:[!b&&e.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-6 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(l.GripVertical,{className:"w-4 h-4 text-[var(--text-secondary)]"})}),e.jsx("div",{className:`p-3 ${b?"":"pl-6"}`,children:c(z,Z)}),(fe?.length??0)>0&&e.jsxs("div",{className:"absolute top-2 right-2",children:[e.jsx("button",{onClick:B=>{B.stopPropagation(),S(v===H?null:H)},className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100 hover:bg-[var(--bg-tertiary)]","aria-label":"Actions",children:e.jsx(l.MoreHorizontal,{className:"w-4 h-4"})}),v===H&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"fixed inset-0 z-40",onClick:()=>S(null),"aria-label":"Close menu"}),e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-lg shadow-lg py-1 min-w-[150px]",children:fe?.map((B,Q)=>I(B,Q))})]})]})]},H)}),Y&&D.length>0&&e.jsx("div",{className:"h-16 border-2 border-dashed border-[var(--color-primary-500)] rounded-lg bg-[var(--accent-bg)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm text-[var(--color-primary-500)]",children:"Déposer ici"})})]})]},C.id)})})}function Pi({title:t,subtitle:s,icon:r,actions:a}){return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[r,t]}),s&&e.jsx("p",{className:"text-[var(--text-secondary)]",children:s})]}),a&&e.jsx("div",{className:"flex items-center gap-3",children:a})]})}const Qt={granted:{icon:l.Check,color:"var(--success-text)",bg:"var(--success-bg)",label:"Accordé"},denied:{icon:l.X,color:"var(--error-text)",bg:"var(--error-bg)",label:"Refusé"},partial:{icon:l.Minus,color:"var(--warning-text)",bg:"var(--warning-bg)",label:"Partiel"},inherited:{icon:l.Check,color:"var(--info-text)",bg:"var(--info-bg)",label:"Hérité"},none:{icon:l.Minus,color:"var(--text-tertiary)",bg:"transparent",label:"Non défini"}};function Ti({rows:t,columns:s,getRowId:r,getRowLabel:a,getRowGroup:o,getRowSubGroup:c,getRowIcon:i,isRowLocked:d,getRowChildCount:u,getColumnId:m,getColumnLabel:p,getColumnShortLabel:f,isColumnLocked:h,getColumnColor:b,getCellState:g,onCellClick:y,loading:x=!1,showLegend:j=!0,searchable:v=!1,rowColumnWidth:S="250px",cellWidth:N="44px",className:I="",emptyMessage:P="Aucune donnée",canEditLocked:k=!1}){const[A,R]=n.useState(new Set),[$,q]=n.useState(""),C=n.useMemo(()=>{const B=new Map;return t.forEach(Q=>{const M=o?.(Q)||"_default",re=c?.(Q);B.has(M)||B.set(M,{rows:[],subGroups:new Map});const F=B.get(M);re?(F.subGroups.has(re)||F.subGroups.set(re,[]),F.subGroups.get(re).push(Q)):F.rows.push(Q)}),B},[t,o,c]),D=n.useCallback((B,Q)=>{const M=new Map;return B.forEach((re,F)=>{const K=re.filter(V=>a(V).toLowerCase().includes(Q));K.length>0&&M.set(F,K)}),M},[a]),Y=n.useMemo(()=>{if(!$)return C;const B=$.toLowerCase(),Q=new Map;return C.forEach((M,re)=>{const F=M.rows.filter(V=>a(V).toLowerCase().includes(B)),K=D(M.subGroups,B);(F.length>0||K.size>0)&&Q.set(re,{rows:F,subGroups:K})}),Q},[C,$,a,D]),T=B=>{R(Q=>{const M=new Set(Q);return M.has(B)?M.delete(B):M.add(B),M})},z=n.useCallback((B,Q,M,re)=>{y&&(M&&!k||re&&!k||y(B,Q))},[y,k]),Z=n.useCallback((B,Q)=>!(!y||B&&!k||Q&&!k),[y,k]),H=(B,Q)=>`w-full h-full min-h-[32px] flex items-center justify-center rounded transition-colors ${B?"hover:opacity-80 cursor-pointer":"cursor-default"} ${Q!=="none"?"":"opacity-30"}`,J=n.useCallback((B,Q,M,re,F,K,V,ae)=>{const ue=re.icon,G=Z(F,K);return e.jsx("td",{className:"px-0 py-1 text-center",style:{width:N},children:e.jsx("button",{type:"button",onClick:()=>z(B,Q,F,K),disabled:!G,className:H(G,M),style:{backgroundColor:re.bg},title:`${a(V)} × ${p(ae)}: ${re.label}`,children:M!=="none"&&e.jsx(ue,{className:"w-4 h-4",style:{color:re.color}})})},`${B}-${Q}`)},[y,k,z,N,a,p,Z,H]),fe=n.useCallback((B,Q,M,re,F)=>{const K=r(B),V=d?.(B)||!1,ae=i?.(B),ue=Q%2===0?"bg-[var(--bg-primary)]":"bg-[var(--bg-secondary)]/50",G=Q%2===0?"":"bg-[var(--bg-secondary)]/50";return e.jsxs("tr",{className:`hover:bg-[var(--bg-tertiary)] ${G}`,children:[e.jsx("td",{className:`sticky left-0 z-10 px-3 py-2 pl-12 ${ue}`,style:{width:re},children:e.jsxs("div",{className:"flex items-center gap-2",children:[ae,V&&e.jsx(l.Lock,{className:"w-3 h-3 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:a(B)})]})}),M.map(ce=>{const de=m(ce),he=h?.(ce)||!1,pe=F(K,de),ye=Qt[pe];return J(K,de,pe,ye,V,he,B,ce)})]},K)},[r,d,i,a,m,h,J]);return x?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-500)]"})}):t.length===0||s.length===0?e.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:P}):e.jsxs("div",{className:`space-y-4 ${I}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[v&&e.jsxs("div",{className:"relative max-w-xs",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("input",{type:"text",value:$,onChange:B=>q(B.target.value),placeholder:"Rechercher...",className:"input pl-10 w-full"})]}),j&&e.jsx("div",{className:"flex items-center gap-4 text-xs",children:Object.entries(Qt).map(([B,Q])=>{if(B==="none")return null;const M=Q.icon;return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center",style:{backgroundColor:Q.bg},children:e.jsx(M,{className:"w-3 h-3",style:{color:Q.color}})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:Q.label})]},B)})})]}),e.jsx("div",{className:"overflow-x-auto border border-[var(--border-color)] rounded-lg",children:e.jsxs("table",{className:"border-collapse",style:{width:"auto"},children:[e.jsx("thead",{className:"bg-[var(--bg-secondary)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-[var(--bg-secondary)] px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider border-b border-[var(--border-color)]",style:{width:S,minWidth:S,height:"120px",verticalAlign:"bottom",paddingBottom:"12px"},children:"Ressource"}),s.map(B=>{const Q=m(B),M=f?.(B)||p(B),re=h?.(B),F=b?.(B);return e.jsx("th",{className:"relative overflow-visible border-b border-[var(--border-color)]",style:{width:N,minWidth:N,maxWidth:N,height:"120px",padding:0,verticalAlign:"bottom"},children:e.jsx("div",{className:"absolute bottom-2 left-1/2",style:{transform:"translateX(-6px) rotate(-55deg)",transformOrigin:"bottom left",width:"100px"},children:e.jsxs("div",{className:"flex items-center gap-1",children:[re&&e.jsx(l.Lock,{className:"w-3 h-3 flex-shrink-0 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-[10px] font-medium text-[var(--text-primary)] whitespace-nowrap",style:{color:F},title:p(B),children:M})]})})},Q)})]})}),e.jsx("tbody",{children:Array.from(Y.entries()).map(([B,Q])=>{const M=A.has(B),re=B==="_default",F=Q.rows.length+Array.from(Q.subGroups.values()).reduce((K,V)=>K+V.length,0);return e.jsxs("tbody",{children:[!re&&e.jsxs("tr",{className:"bg-[var(--color-accent-900)]/30",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-2 bg-[var(--color-accent-900)]/30",style:{width:S},children:e.jsxs("button",{onClick:()=>T(B),className:"flex items-center gap-2 w-full text-left hover:opacity-80",children:[M?e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--color-accent-400)]"}):e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--color-accent-400)]"}),e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-300)] uppercase",children:B}),e.jsxs("span",{className:"text-xs text-[var(--color-accent-400)]",children:["(",F,")"]})]})}),e.jsx("td",{colSpan:s.length})]}),!M&&e.jsxs(e.Fragment,{children:[Q.rows.map((K,V)=>{const ae=r(K),ue=d?.(K)||!1,G=i?.(K),ce=u?.(K),de=V%2===0?"bg-[var(--bg-primary)]":"bg-[var(--bg-secondary)]/50",he=V%2===0?"":"bg-[var(--bg-secondary)]/50";return e.jsxs("tr",{className:`hover:bg-[var(--bg-tertiary)] ${he}`,children:[e.jsx("td",{className:`sticky left-0 z-10 px-3 py-2 ${de}`,style:{width:S},children:e.jsxs("div",{className:"flex items-center gap-2",children:[G,ue&&e.jsx(l.Lock,{className:"w-3 h-3 text-[var(--warning-text)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:a(K)}),ce!==void 0&&e.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",ce,")"]})]})}),s.map(pe=>{const ye=m(pe),qe=h?.(pe)||!1,Ue=g(ae,ye),Ve=Qt[Ue];return J(ae,ye,Ue,Ve,ue,qe,K,pe)})]},ae)}),Array.from(Q.subGroups.entries()).map(([K,V])=>e.jsxs("tbody",{children:[e.jsxs("tr",{className:"bg-[var(--bg-tertiary)]",children:[e.jsx("td",{className:"sticky left-0 z-10 px-3 py-1 pl-8 bg-[var(--bg-tertiary)]",style:{width:S},children:e.jsxs("span",{className:"text-xs font-semibold text-[var(--text-secondary)] uppercase",children:[K," (",V.length,")"]})}),e.jsx("td",{colSpan:s.length})]}),V.map((ae,ue)=>fe(ae,ue,s,S,g))]},K))]})]},B)})})]})})]})}const Ri=[{size:"none",icon:"square"},{size:"small",icon:"rounded"},{size:"medium",icon:"rounded"},{size:"large",icon:"rounded"},{size:"xlarge",icon:"rounded"},{size:"xxlarge",icon:"rounded"}];function it({label:t,element:s,value:r,onChange:a}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ri.map(({size:o})=>e.jsx("button",{onClick:()=>a(s,o),className:`px-3 py-2 text-xs font-medium transition-all ${r===o?"bg-[var(--color-accent-500)] text-white":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,style:{borderRadius:Qe[o]},children:Za[o]},o))})]})}const Ei=({selectedThemeTenant:t,setSelectedThemeTenant:s,currentTenant:r,t:a})=>e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Globe,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:a("theme.scope.title","Portée du thème")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:a("theme.scope.description","Choisissez si ce thème s'applique à tous vos espaces ou uniquement à l'espace actuel")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>s(null),className:`flex-1 flex items-center gap-3 p-4 transition-all border ${t===null?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Globe,{className:`w-5 h-5 ${t===null?"text-[var(--color-accent-500)]":"text-[var(--text-muted)]"}`}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:`font-medium ${t===null?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:a("theme.scope.global","Global")}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5",children:a("theme.scope.globalDesc","Tous les espaces")})]}),t===null&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] ml-auto"})]}),e.jsxs("button",{type:"button",onClick:()=>s(r.id),className:`flex-1 flex items-center gap-3 p-4 transition-all border ${t===r.id?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Building2,{className:`w-5 h-5 ${t===r.id?"text-[var(--color-accent-500)]":"text-[var(--text-muted)]"}`}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:`font-medium ${t===r.id?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:r.name}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5",children:a("theme.scope.tenantDesc","Espace actuel uniquement")})]}),t===r.id&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)] ml-auto"})]})]})]});function Ii({onSync:t,isSyncing:s=!1,syncSuccess:r=!1}){const{t:a}=ne.useTranslation("preferences"),{config:o,mode:c,setMode:i,setBorderRadius:d,setAccentColor:u,setItemPalette:m,applyPreset:p,resetToDefault:f,selectedThemeTenant:h,setSelectedThemeTenant:b}=St(),{currentTenant:g,hasMultipleTenants:y}=Ee(),x=y&&g;return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-[var(--text-primary)]",children:"Personnalisation"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Personnalisez l'apparence de l'interface"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsxs("button",{type:"button",onClick:t,disabled:s,className:"flex items-center gap-2 px-3 py-2 text-sm font-medium text-white bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",style:{borderRadius:"var(--radius-button)"},children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),"Sync..."]}),!s&&r&&e.jsxs(e.Fragment,{children:[e.jsx(l.Check,{className:"w-4 h-4"}),"Synchronisé"]}),!s&&!r&&e.jsxs(e.Fragment,{children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),"Synchroniser"]})]}),e.jsxs("button",{onClick:f,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--text-secondary)] bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors",style:{borderRadius:"var(--radius-button)"},children:[e.jsx(l.RotateCcw,{className:"w-4 h-4"}),"Réinitialiser"]})]})]}),x&&e.jsx(Ei,{selectedThemeTenant:h,setSelectedThemeTenant:b,currentTenant:g,t:a}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Thèmes prédéfinis"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:tn.map(j=>{const v=o.accentColorKey===j.config.accentColorKey&&JSON.stringify(o.borderRadius)===JSON.stringify(j.config.borderRadius);return e.jsxs("button",{onClick:()=>p(j.config),className:`p-4 text-left transition-all border ${v?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-2xl",children:j.icon}),v&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)]"})]}),e.jsx("div",{className:"font-semibold text-[var(--text-primary)]",children:j.name}),e.jsx("div",{className:"text-xs text-[var(--text-muted)] mt-1",children:j.description})]},j.id)})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Mode d'affichage"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>i("light"),className:`flex-1 flex items-center justify-center gap-3 p-4 transition-all border ${c==="light"?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Sun,{className:`w-5 h-5 ${c==="light"?"text-amber-500":"text-[var(--text-muted)]"}`}),e.jsx("span",{className:`font-medium ${c==="light"?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:"Clair"})]}),e.jsxs("button",{onClick:()=>i("dark"),className:`flex-1 flex items-center justify-center gap-3 p-4 transition-all border ${c==="dark"?"border-[var(--color-accent-500)] bg-[var(--accent-bg)]":"border-[var(--border-color)] bg-[var(--bg-secondary)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsx(l.Moon,{className:`w-5 h-5 ${c==="dark"?"text-[var(--color-accent-400)]":"text-[var(--text-muted)]"}`}),e.jsx("span",{className:`font-medium ${c==="dark"?"text-[var(--text-primary)]":"text-[var(--text-secondary)]"}`,children:"Sombre"})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Palette,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Couleur d'accent"})]}),e.jsx("div",{className:"flex flex-wrap gap-3",children:Object.entries(_e).map(([j,{name:v,shades:S}])=>e.jsx("button",{onClick:()=>u(j),className:`relative w-10 h-10 transition-all ${o.accentColorKey===j?"ring-2 ring-offset-2 ring-[var(--border-strong)]":""}`,style:{backgroundColor:S[500],borderRadius:"var(--radius-button)"},title:v,children:o.accentColorKey===j&&e.jsx(l.Check,{className:"absolute inset-0 m-auto w-5 h-5 text-white"})},j))}),e.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:["Couleur actuelle: ",e.jsx("span",{className:"font-medium text-[var(--color-accent-500)]",children:_e[o.accentColorKey]?.name})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Layers,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Palette des éléments"})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Choisissez une palette de couleurs pour les cards et éléments de l'interface"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:Object.entries(ut).map(([j,v])=>{const S=c==="dark"?v.colors.dark:v.colors.light,N=o.itemPaletteKey===j;return e.jsxs("button",{onClick:()=>m(j),className:`p-4 text-left transition-all border ${N?"border-[var(--color-accent-500)] ring-2 ring-[var(--color-accent-500)] ring-opacity-30":"border-[var(--border-color)] hover:border-[var(--border-strong)]"}`,style:{borderRadius:"var(--radius-card)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-xl",children:v.icon}),N&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-500)]"})]}),e.jsxs("div",{className:"flex h-8 mb-3 rounded overflow-hidden border",style:{borderColor:S.dark},children:[e.jsx("div",{className:"flex-1",style:{backgroundColor:S.light}}),e.jsx("div",{className:"flex-1",style:{backgroundColor:S.medium}}),e.jsx("div",{className:"flex-1",style:{backgroundColor:S.dark}})]}),e.jsx("div",{className:"font-semibold text-[var(--text-primary)] text-sm",children:v.name})]},j)})}),e.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:["Palette actuelle: ",e.jsx("span",{className:"font-medium text-[var(--color-accent-500)]",children:ut[o.itemPaletteKey]?.name})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Square,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Style des coins"})]}),e.jsxs("div",{className:"space-y-4 p-4 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-card)"},children:[e.jsx(it,{label:"Cards & Containers",element:"card",value:o.borderRadius.card,onChange:d}),e.jsx(it,{label:"Boutons",element:"button",value:o.borderRadius.button,onChange:d}),e.jsx(it,{label:"Badges",element:"badge",value:o.borderRadius.badge,onChange:d}),e.jsx(it,{label:"Champs de saisie",element:"input",value:o.borderRadius.input,onChange:d}),e.jsx(it,{label:"Modales",element:"modal",value:o.borderRadius.modal,onChange:d}),e.jsx(it,{label:"Éléments de menu",element:"menuItem",value:o.borderRadius.menuItem,onChange:d})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Circle,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("h3",{className:"text-sm font-semibold text-[var(--text-primary)] uppercase tracking-wider",children:"Aperçu"})]}),e.jsx("div",{className:"p-6 bg-[var(--bg-secondary)] border border-[var(--border-color)]",style:{borderRadius:"var(--radius-card)"},children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:"badge-success px-3 py-1 text-xs font-medium",children:"Succès"}),e.jsx("span",{className:"badge-warning px-3 py-1 text-xs font-medium",children:"Attention"}),e.jsx("span",{className:"badge-error px-3 py-1 text-xs font-medium",children:"Erreur"}),e.jsx("span",{className:"badge-info px-3 py-1 text-xs font-medium",children:"Info"}),e.jsx("span",{className:"badge-accent px-3 py-1 text-xs font-medium",children:"Accent"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{className:"btn btn-primary",children:"Bouton primaire"}),e.jsx("button",{className:"btn btn-secondary",children:"Bouton secondaire"}),e.jsx("button",{className:"btn btn-ghost",children:"Bouton ghost"})]}),e.jsx("div",{children:e.jsx("input",{type:"text",placeholder:"Champ de saisie exemple...",className:"input w-full"})}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-600)] flex items-center justify-center text-white font-bold",style:{borderRadius:"var(--radius-button)"},children:"A"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-[var(--text-primary)]",children:["Exemple de card (",ut[o.itemPaletteKey]?.name,")"]}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:"Cette card utilise la palette sélectionnée"})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"card p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Card 1"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"Aperçu du style"})]}),e.jsxs("div",{className:"card p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Card 2"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:"Aperçu du style"})]})]})]})})]})]})}function Li({title:t,description:s,icon:r,showBackButton:a=!0,backUrl:o,children:c}){const{t:i}=ne.useTranslation("common"),d=w.useNavigate(),u=()=>{d(o||-1)};return e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[400px] p-8",children:e.jsxs("div",{className:"max-w-md w-full text-center",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-full bg-gradient-to-br from-amber-100 to-orange-100 dark:from-amber-900/30 dark:to-orange-900/30 flex items-center justify-center",children:r||e.jsx(l.Construction,{className:"w-10 h-10 text-amber-600 dark:text-amber-400"})}),e.jsx("h2",{className:"text-2xl font-bold text-[var(--text-primary)] mb-3",children:t||i("underDevelopment.title","En cours de développement")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:s||i("underDevelopment.description","Cette fonctionnalité est actuellement en cours de développement et sera disponible prochainement.")}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-8",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse",style:{animationDelay:"300ms"}})]}),e.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:i("underDevelopment.workInProgress","Travail en cours")})]}),c,a&&e.jsxs("button",{onClick:u,className:"btn btn-secondary inline-flex items-center gap-2",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),i("common.back","Retour")]})]})})}function $i({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}const Di=[{path:"/administration",icon:l.LayoutDashboard,labelKey:"sidebar.dashboard",exact:!0},{path:"/administration/users",icon:l.Users,labelKey:"sidebar.users"},{path:"/administration/roles",icon:l.Key,labelKey:"sidebar.roles"}];function Mi({isOpen:t=!0,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),{favorites:o,loading:c}=Ke(),{expandFavorites:i,clearExpand:d}=Ke(),[u,m]=n.useState(!1);n.useEffect(()=>{i&&(queueMicrotask(()=>{m(!1)}),d())},[i,d]);const p=(h,b)=>b?a.pathname===h:a.pathname.startsWith(h),f=e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"lg:hidden flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("span",{className:"font-semibold",children:"Menu"}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-[var(--bg-tertiary)]",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[!c&&o.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("button",{onClick:()=>m(!u),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[u?e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"}):e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5"}),e.jsx(l.Star,{className:"w-3.5 h-3.5"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:"/myspace/preferences?tab=favorites",onClick:s,className:"p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),!u&&e.jsx("div",{className:"space-y-0.5",children:o.map(h=>{const b=a.pathname===h.route;return e.jsxs(w.Link,{to:h.route,onClick:s,className:`flex items-center gap-3 px-3 py-2 transition-colors ${b?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:`${h.label} (${h.applicationLabel})`,children:[e.jsx($i,{name:h.icon,className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium truncate",children:h.label})]},h.id)})}),e.jsx("div",{className:"my-3 border-b border-[var(--border-color)]"})]}),Di.map(h=>{const b=h.icon,g=p(h.path,h.exact);return e.jsxs(w.Link,{to:h.path,onClick:s,className:`flex items-center gap-3 px-3 py-2.5 transition-colors ${g?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},children:[e.jsx(b,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:r(h.labelKey)})]},h.path)})]})]});return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"hidden lg:block w-64 h-[calc(100vh-4rem)] fixed top-16 left-0 bg-[var(--bg-secondary)] border-r border-[var(--border-color)]",children:f}),t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 bg-black/50 z-40",onClick:s,"aria-label":"Close sidebar"}),e.jsx("aside",{className:"lg:hidden fixed top-0 left-0 h-full w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] z-50",children:f})]})]})}function Gs({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Oi({isOpen:t=!0,onClose:s}){const{t:r}=ne.useTranslation(["navigation","common"]),a=w.useLocation(),{favorites:o,loading:c}=Ke(),{expandFavorites:i,clearExpand:d}=Ke(),{isCollapsed:u,toggleCollapsed:m}=Ut(),{getApplicationsByZone:p}=Ce(),[f,h]=n.useState(!1),y=p("personal").find(v=>v.code==="myspace"||v.code==="core_myspace")?.modules||[];n.useEffect(()=>{i&&(queueMicrotask(()=>{h(!1)}),d())},[i,d]);const x=(v,S)=>S?a.pathname===v:a.pathname.startsWith(v),j=e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"lg:hidden flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("span",{className:"font-semibold",children:"Menu"}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-[var(--bg-tertiary)]",style:{borderRadius:"var(--radius-button)"},children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("nav",{className:`flex-1 overflow-y-auto space-y-1 ${u?"p-2":"p-4"}`,children:[!c&&o.length>0&&e.jsxs("div",{className:"mb-4",children:[!u&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("button",{onClick:()=>h(!f),className:"flex items-center gap-2 text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider hover:text-[var(--text-primary)] transition-colors",children:[f?e.jsx(l.ChevronRight,{className:"w-3.5 h-3.5"}):e.jsx(l.ChevronDown,{className:"w-3.5 h-3.5"}),e.jsx(l.Star,{className:"w-3.5 h-3.5"}),r("common:favorites.quickAccess")]}),e.jsx(w.Link,{to:"/myspace/preferences?tab=favorites",onClick:s,className:"p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",style:{borderRadius:"var(--radius-button)"},title:r("common:favorites.manage"),children:e.jsx(l.Settings,{className:"w-3.5 h-3.5"})})]}),(u||!f)&&e.jsx("div",{className:"space-y-0.5",children:o.map(v=>{const S=a.pathname===v.route;return e.jsxs(w.Link,{to:v.route,onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2":"gap-3 px-3 py-2"} ${S?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?`${v.label} (${v.applicationLabel})`:void 0,children:[e.jsx(Gs,{name:v.icon,className:"w-4 h-4 flex-shrink-0"}),!u&&e.jsx("span",{className:"text-sm font-medium truncate",children:v.label}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:v.label})})]},v.id)})}),!u&&e.jsx("div",{className:"my-3 border-b border-[var(--border-color)]"})]}),e.jsxs(w.Link,{to:"/myspace",onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${x("/myspace",!0)?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?r("sidebar.dashboard"):void 0,children:[e.jsx(l.LayoutDashboard,{className:"w-5 h-5 flex-shrink-0"}),!u&&e.jsx("span",{className:"font-medium",children:r("sidebar.dashboard")}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("sidebar.dashboard")})})]}),y.map(v=>{const S=v.route||`/myspace/${v.code}`,N=x(S);return e.jsxs(w.Link,{to:S,onClick:s,className:`relative group flex items-center transition-colors ${u?"justify-center px-2 py-2.5":"gap-3 px-3 py-2.5"} ${N?"bg-[var(--accent-bg)] text-[var(--color-accent-500)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?v.label:void 0,children:[e.jsx(Gs,{name:v.icon||"Star",className:"w-5 h-5 flex-shrink-0"}),!u&&e.jsx("span",{className:"font-medium",children:v.label}),u&&e.jsx("div",{className:"absolute left-full top-0 ml-2 px-3 py-2 bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50",style:{borderRadius:"var(--radius-menu-item)"},children:e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:v.label})})]},v.id)})]}),e.jsx("div",{className:`border-t border-[var(--border-color)] ${u?"p-2":"p-3"}`,children:e.jsx("button",{onClick:m,className:`hidden lg:flex w-full items-center transition-all text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] ${u?"justify-center px-2 py-2":"gap-2 px-3 py-2"}`,style:{borderRadius:"var(--radius-menu-item)"},title:u?r("sidebar.expand","Agrandir le menu"):r("sidebar.collapse","Réduire le menu"),children:u?e.jsx(l.PanelLeft,{className:"w-5 h-5"}):e.jsxs(e.Fragment,{children:[e.jsx(l.PanelLeftClose,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:r("sidebar.collapse","Réduire")})]})})})]});return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:`hidden lg:block h-[calc(100vh-4rem)] fixed top-16 left-0 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] transition-all duration-300 ${u?"w-16":"w-64"}`,children:j}),t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"lg:hidden fixed inset-0 bg-black/50 z-40",onClick:s,"aria-label":"Close sidebar"}),e.jsx("aside",{className:"lg:hidden fixed top-0 left-0 h-full w-64 bg-[var(--bg-secondary)] border-r border-[var(--border-color)] z-50",children:j})]})]})}function Fi(t){const s=t.message.toLowerCase(),r=t.name.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("failed to fetch")||s.includes("econnrefused")||s.includes("timeout")?"network":s.includes("401")||s.includes("403")||s.includes("unauthorized")||s.includes("forbidden")||s.includes("permission")?"permission":s.includes("404")||s.includes("not found")?"notFound":r.includes("validation")||s.includes("validation")||s.includes("invalid")?"validation":"technical"}function _i(){const t=Date.now().toString(36),s=Math.random().toString(36).substring(2,6);return`ERR-${t}-${s}`.toUpperCase()}const qi={network:{icon:l.WifiOff,color:"text-orange-500",bgColor:"bg-orange-500/10"},permission:{icon:l.ShieldX,color:"text-red-500",bgColor:"bg-red-500/10"},notFound:{icon:l.FileWarning,color:"text-yellow-500",bgColor:"bg-yellow-500/10"},validation:{icon:l.AlertTriangle,color:"text-amber-500",bgColor:"bg-amber-500/10"},technical:{icon:l.Bug,color:"text-red-500",bgColor:"bg-red-500/10"}};function Ui({error:t,resetErrorBoundary:s}){const{t:r}=ne.useTranslation("common"),[a,o]=n.useState(!1),[c]=n.useState(()=>_i()),i=Fi(t),d=qi[i],u=d.icon,m=()=>{window.history.length>2&&document.referrer?window.location.href=document.referrer:window.history.length>2?(window.history.back(),setTimeout(()=>window.location.reload(),50)):window.location.href="/"};return e.jsx("div",{className:"flex items-center justify-center min-h-[400px] p-6",children:e.jsx("div",{className:"max-w-md w-full p-6 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-xl shadow-lg",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:`w-14 h-14 rounded-full ${d.bgColor} flex items-center justify-center mb-4`,children:e.jsx(u,{className:`w-7 h-7 ${d.color}`})}),e.jsx("h2",{className:"text-xl font-bold text-[var(--text-primary)] mb-2",children:r(`errors.${i}.title`,{defaultValue:r("errors.technical.title")})}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:r(`errors.${i}.description`,{defaultValue:r("errors.technical.description")})}),e.jsxs("div",{className:"mb-4 px-2 py-1 bg-[var(--bg-tertiary)] rounded border border-[var(--border-color)]",children:[e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[r("errors.errorId"),": "]}),e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:c})]}),!1,e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs("button",{onClick:s,className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-3 rounded-lg bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white text-sm font-medium transition-all",children:[e.jsx(l.RefreshCw,{className:"w-4 h-4"}),r("errors.retry")]}),e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-3 rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] text-sm font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),r("errors.goBack")]})]})]})})})}function zi(t,s){Te.logError(t,"RouteErrorBoundary",{componentStack:s.componentStack})}function Bi({children:t}){return e.jsx(pr.ErrorBoundary,{FallbackComponent:Ui,onError:zi,onReset:()=>{window.location.reload()},children:t})}function Gi({feature:t,children:s,fallback:r,minimal:a=!1}){const{t:o}=ne.useTranslation("admin"),{isFeatureEnabled:c,license:i,isLoading:d}=He();return d?e.jsx(e.Fragment,{children:s}):c(t)?e.jsx(e.Fragment,{children:s}):r?e.jsx(e.Fragment,{children:r}):a?e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 rounded text-sm",children:[e.jsx(l.Lock,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:o("license.featureLocked","Locked")})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 bg-gray-50 dark:bg-gray-800/50 rounded-xl border-2 border-dashed border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(l.Lock,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:o("license.featureNotAvailable","Feature Not Available")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-sm mb-4",children:o("license.upgradeToAccess","Upgrade your license to access the {{feature}} feature.",{feature:t})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx(l.Sparkles,{className:"w-4 h-4"}),e.jsx("span",{children:o("license.currentEdition","Current: {{edition}}",{edition:i?.edition||"Unknown"})})]})]})}function wa({open:t,onOpenChange:s}){const{t:r}=ne.useTranslation("admin"),{activateLicense:a,license:o}=He(),{refreshMenu:c}=Ce(),[i,d]=n.useState(""),[u,m]=n.useState(""),[p,f]=n.useState(!1),[h,b]=n.useState(!1),[g,y]=n.useState(null),[x,j]=n.useState(!1),v=o?.hasApiKey??!1,S=async()=>{if(!i.trim()){y(r("license.errors.keyRequired","License key is required"));return}b(!0),y(null),j(!1);const I=await a(i.trim(),u.trim()||void 0);b(!1),I.success?(j(!0),await c(),setTimeout(()=>{d(""),m(""),f(!1),j(!1),s(!1)},1500)):y(I.error||r("license.errors.activationFailed","Activation failed"))},N=()=>{h||(d(""),m(""),f(!1),y(null),j(!1),s(!1))};return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:N,"aria-label":"Close dialog"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900/30 rounded-lg",children:e.jsx(l.Key,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("license.activateTitle","Activate License")})]}),e.jsx("button",{onClick:N,disabled:h,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50",children:e.jsx(l.X,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("license.activateDescription","Enter your license key to activate the product. The key is a JWT token provided by AtlasHub.")}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("license.keyLabel","License Key")}),e.jsx("textarea",{value:i,onChange:I=>{d(I.target.value),y(null)},placeholder:r("license.keyPlaceholder","eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."),rows:6,disabled:h||x,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-mono text-xs bg-white dark:bg-gray-900 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed resize-none"})]}),v&&!p?e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4 text-green-600 dark:text-green-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-green-700 dark:text-green-300 flex-1",children:r("license.apiKeyConfigured","API key is already configured")}),e.jsx("button",{type:"button",onClick:()=>f(!0),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:r("license.apiKeyChange","Change")})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("license.apiKeyLabel","API Key")}),e.jsx("input",{type:"text",value:u,onChange:I=>{m(I.target.value),y(null)},placeholder:r("license.apiKeyPlaceholder","sslk_..."),disabled:h||x,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-mono text-sm bg-white dark:bg-gray-900 text-gray-900 dark:text-white placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("license.apiKeyDescription","API key provided by AtlasHub for server authentication (sslk_...).")})]}),g&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:g})]}),x&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx(l.CheckCircle,{className:"w-5 h-5 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-green-700 dark:text-green-300",children:r("license.activationSuccess","License activated successfully!")})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[r("license.activationHelp","Need a license key? Contact us at")," ",e.jsx("a",{href:"mailto:support@atlashub.ch",className:"text-blue-600 dark:text-blue-400 hover:underline",children:"support@atlashub.ch"})," ",r("license.activationHelpOr","or visit")," ",e.jsx("a",{href:"https://www.atlashub.ch",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:"www.atlashub.ch"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 px-6 py-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[e.jsx("button",{onClick:N,disabled:h,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("common:cancel","Cancel")}),e.jsxs("button",{onClick:S,disabled:h||x||!i.trim(),className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2",children:[h&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),x&&e.jsx(l.CheckCircle,{className:"w-4 h-4"}),h?r("license.activating","Activating..."):x?r("license.activated","Activated!"):r("license.activate","Activate")]})]})]})]}):null}function Ki({showDetails:t=!1}){const{t:s}=ne.useTranslation("admin"),{license:r,isLoading:a}=He();if(a||!r)return null;const{status:o,edition:c,isInTrial:i,trialDaysRemaining:d,isReadOnlyMode:u,daysUntilExpiration:m}=r;if(u)return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 rounded-full text-sm font-medium",children:[e.jsx(l.XCircle,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.readOnlyMode","Read-only mode")})]});if(i){const p=d<=7?"text-amber-800 dark:text-amber-200 bg-amber-100 dark:bg-amber-900/30":"text-blue-800 dark:text-blue-200 bg-blue-100 dark:bg-blue-900/30";return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium ${p}`,children:[e.jsx(l.Clock,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.trialDaysRemaining","{{days}} trial days left",{days:d})})]})}return m<=30&&o==="Active"?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-amber-100 dark:bg-amber-900/30 text-amber-800 dark:text-amber-200 rounded-full text-sm font-medium",children:[e.jsx(l.AlertTriangle,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.expiresIn","Expires in {{days}} days",{days:m})})]}):o==="Active"?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 rounded-full text-sm font-medium",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4"}),e.jsx("span",{children:s(`license.edition.${c.toLowerCase()}`,{defaultValue:c})}),t&&e.jsxs("span",{className:"text-xs opacity-75",children:["(",m," ",s("license.daysLeft","days left"),")"]})]}):e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 rounded-full text-sm font-medium",children:[e.jsx(l.Shield,{className:"w-4 h-4"}),e.jsx("span",{children:s(`license.status.${o.toLowerCase()}`,{defaultValue:o})})]})}function ls({reason:t,tenantName:s,permissionPath:r,applicationsUrl:a,userRoles:o,userPermissions:c}){const{t:i}=ne.useTranslation("common"),{menu:d}=Ce(),u=w.useLocation(),m=()=>{window.history.length>2?window.history.back():window.location.href="/"},p=r?.split(".")[0],f=n.useMemo(()=>c?.filter(v=>{if(v==="*")return!0;const S=v.toLowerCase();return p&&(S.startsWith(p.toLowerCase()+".")||S===p.toLowerCase())})??[],[c,p]),h=r&&(o?.length||c),b=n.useMemo(()=>{const v=u.pathname.split("/").filter(Boolean),S=v[0]==="t"?v.slice(2):v,N=S[0],I=S[1],P=S[2],k=S[3],A=T=>/^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(T),R=T=>T.replace(/^(core_|ext_)/,""),$=T=>T.charAt(0).toUpperCase()+T.slice(1).replace(/-/g," "),q=d?.applications.find(T=>T.route?.split("/").filter(Boolean)[0]===N||R(T.code)===N),C=I?q?.modules.find(T=>T.route?.split("/").filter(Boolean)[1]===I||R(T.code)===I):void 0,D=P&&!A(P)?C?.sections.find(T=>T.route?.split("/").filter(Boolean)[2]===P||R(T.code)===P):void 0,Y=k&&!A(k)?D?.resources.find(T=>T.route?.split("/").filter(Boolean)[3]===k||R(T.code)===k):void 0;return{application:q?.label||(N?$(N):void 0),module:C?.label||(I&&!A(I)?$(I):void 0),section:D?.label||(P&&!A(P)?$(P):void 0),resource:Y?.label||(k&&!A(k)?$(k):void 0)}},[d,u.pathname]),g=n.useMemo(()=>{const v=[];return b.application&&v.push(`- ${i("errors.accessDenied.ticket.applicationLabel")}: ${b.application}`),b.module&&v.push(`- ${i("errors.accessDenied.ticket.moduleLabel")}: ${b.module}`),b.section&&v.push(`- ${i("errors.accessDenied.ticket.sectionLabel")}: ${b.section}`),b.resource&&v.push(`- ${i("errors.accessDenied.ticket.resourceLabel")}: ${b.resource}`),v.length===0?"":`
26
26
 
27
27
  ${i("errors.accessDenied.ticket.navigationContext")}:
28
28
  ${v.join(`
29
- `)}`},[b,i]),y=n.useMemo(()=>{if(!t||!r||!s||!a)return null;const S=`${a.replace(/\/applications$/,"")}/support/my-tickets/create`,N=t==="tenant"?"ApplicationRequest":"Support",I=r.split(".")[0],P=t==="tenant"?i("errors.accessDenied.ticket.accessSubject",{permissionPath:r,tenantName:s}):i("errors.accessDenied.ticket.permissionSubject",{permissionPath:r,tenantName:s}),A=(t==="tenant"?i("errors.accessDenied.ticket.accessBody",{appCode:I,tenantName:s,permissionPath:r}):i("errors.accessDenied.ticket.permissionBody",{permissionPath:r,tenantName:s}))+h,R=new URLSearchParams({type:N,subject:P,body:A});return`${S}?${R.toString()}`},[t,r,s,a,i,h]),j=t==="tenant"&&s?i("errors.accessDenied.tenantNotAvailable",{tenantName:s}):t==="permission"&&s?i("errors.accessDenied.permissionMissing",{tenantName:s}):s?i("errors.accessDenied.tenantDescription",{tenantName:s}):i("errors.accessDenied.description");return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-6",children:e.jsx(l.ShieldX,{className:"w-8 h-8 text-red-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:i("errors.accessDenied.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:j}),g&&e.jsxs("div",{className:"w-full mb-6 bg-[var(--bg-secondary)] rounded-lg border border-[var(--border-color)] divide-y divide-[var(--border-color)]",children:[e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:i("errors.accessDenied.requiredPermission")}),e.jsx("p",{className:"text-sm font-mono font-medium text-red-500",children:r})]}),(o?.length??0)>0&&e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-2",children:i("errors.accessDenied.yourRoles")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 justify-center",children:o?.map(v=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:v},v))})]}),c&&e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-2",children:i("errors.accessDenied.yourPermissionsFor",{appCode:p??""})}),f.length>0?e.jsx("div",{className:"flex flex-col gap-1 items-start",children:f.map(v=>e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:v},v))}):e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] italic",children:i("errors.accessDenied.noPermissions")})]})]}),!g&&r&&e.jsxs("div",{className:"w-full mb-6 p-3 bg-[var(--bg-secondary)] rounded-lg border border-[var(--border-color)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:i("errors.accessDenied.requiredPermission")}),e.jsx("p",{className:"text-sm font-mono text-[var(--text-primary)]",children:r})]}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[y&&e.jsxs("a",{href:y,className:"flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.TicketPlus,{className:"w-4 h-4"}),i(t==="tenant"?"errors.accessDenied.requestAccess":"errors.accessDenied.requestPermission")]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[a?e.jsxs("a",{href:a,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.LayoutGrid,{className:"w-4 h-4"}),i("errors.accessDenied.goToApplications")]}):e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),i("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),i("errors.home")]})]})]})]})})})}function Gi(){const{t}=ne.useTranslation("common"),{logout:s}=Pe();return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-orange-500/10 flex items-center justify-center mb-6",children:e.jsx(l.Building2,{className:"w-8 h-8 text-orange-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:t("errors.noActiveWorkspace.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("errors.noActiveWorkspace.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("a",{href:"mailto:support@atlashub.ch",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.Mail,{className:"w-4 h-4"}),t("errors.noActiveWorkspace.contactAdmin")]}),e.jsxs("button",{onClick:()=>{s()},className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),t("errors.noActiveWorkspace.logout")]})]}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mt-6",children:t("errors.noActiveWorkspace.hint")})]})})})}function St(){return e.jsx("div",{className:"flex items-center justify-center min-h-[400px] w-full",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(l.Loader2,{className:"w-10 h-10 animate-spin text-[var(--color-primary-500)]"}),e.jsx("span",{className:"text-sm text-[var(--color-text-secondary)]",children:"Chargement..."})]})})}function wa(){const{user:t,isLoading:s}=Pe(),r=w.useLocation(),{currentAppCode:a,currentModuleCode:o,isLoading:c,menu:i}=Ce(),{currentTenant:d,userTenants:u,isLoading:m,isGlobalView:p}=Ee(),f=d?.id||"global",g=n.useRef(null),b=(S,N)=>{const I=`${S}:${N}:${r.pathname}`;g.current!==I&&(g.current=I,E.post("/security/access-denied",{reason:S,permissionPath:N,attemptedPath:r.pathname}).catch(()=>{}))},h=n.useRef(d?.id);let y=!1;if(d?.id!==h.current&&(h.current=d?.id,y=!0),s)return e.jsx(St,{});if(!t)return e.jsx(w.Navigate,{to:"/login",state:{from:r},replace:!0});if(y||c||m||!i)return e.jsx(St,{});if(!d&&!p&&!u.some(N=>N.status==="Active"))return e.jsx(Gi,{});if(!a)return e.jsx(w.Outlet,{},f);if(Ir.includes(a))return e.jsx(w.Outlet,{},f);const j=(i?.applications||[]).find(S=>S.route?.split("/").filter(Boolean)[0]===a||S.code===a);if(j?.isOpen)return e.jsx(w.Outlet,{},f);if(!j){const S=[a,o].filter(Boolean).join("."),N=d?.slug?`/t/${d.slug}/applications`:"/applications";return b("tenant",S),e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(wt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(os,{reason:"tenant",tenantName:d?.name,permissionPath:S,applicationsUrl:N,userRoles:t.roles,userPermissions:t.permissions})})})]})}const v=[a,o].filter(Boolean).join(".");if(!jr(t.permissions,v)&&j.accessLevel!=="RequestAccess"){const S=d?.slug?`/t/${d.slug}/applications`:"/applications";return b("permission",v),e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(wt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(os,{reason:"permission",tenantName:d?.name,permissionPath:v,applicationsUrl:S,userRoles:t.roles,userPermissions:t.permissions})})})]})}return e.jsx(w.Outlet,{},f)}function Bs(){const{slug:t}=w.useParams(),s=w.useNavigate(),r=w.useLocation(),{currentTenant:a,userTenants:o,switchTenant:c,isLoading:i,isGlobalView:d}=Ee(),{useUrlRouting:u,isLoading:m}=_t(),p=n.useRef(!1),f=n.useRef(null),g=n.useRef(null);return n.useEffect(()=>{if(i||m||!u||d)return;const b=t||$s(r.pathname),h=b!==g.current;if(g.current=b,!!h&&b&&b!==a?.slug){const y=o.find(x=>x.slug===b&&x.status==="Active");if(y)f.current=b,c(y.id).then(()=>{f.current=null}).catch(x=>{f.current=null,console.error("[TenantRouteWrapper] Failed to switch tenant:",x)});else if(a){const x=dt(r.pathname);s(`/t/${a.slug}${x}`,{replace:!0})}else s("/",{replace:!0})}},[t,r.pathname,a?.slug,o,u,i,m,d,c,s]),n.useEffect(()=>{if(i||m||p.current)return;const b=r.pathname,h=$s(b);if(d&&h){p.current=!0;const y=dt(b);s(y,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(!u&&h){p.current=!0;const y=dt(b);s(y,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(u&&a&&!h&&!d&&b!=="/"&&!b.startsWith("/login")&&!b.startsWith("/auth")&&!b.startsWith("/public")){p.current=!0,s(`/t/${a.slug}${b}`,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(u&&a&&h&&!d&&h!==a.slug&&h!==f.current){p.current=!0;const y=dt(b);s(`/t/${a.slug}${y}`,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}},[r.pathname,a?.slug,u,i,m,d,s]),e.jsx(w.Outlet,{})}function Oe({to:t,replace:s=!0}){const{slug:r}=w.useParams(),a=r?`/t/${r}${t}`:t;return e.jsx(w.Navigate,{to:a,replace:s})}function Ki(){const{t}=ne.useTranslation("admin"),{license:s}=He(),r=Ze();return!s||s.status==="NoLicense"?e.jsx(Na,{open:!0,onOpenChange:()=>{}}):e.jsxs("div",{className:"fixed inset-0 z-40 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[e.jsx("div",{className:"flex justify-center pt-8 pb-4",children:e.jsx("div",{className:"p-4 bg-red-100 dark:bg-red-900/30 rounded-full",children:e.jsx(l.Lock,{className:"w-10 h-10 text-red-600 dark:text-red-400"})})}),e.jsxs("div",{className:"px-6 pb-6 text-center",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-white mb-2",children:t("license.guard.title","License Required")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:t("license.guard.description","Your license has expired or is invalid. Access to this area is restricted. Please activate a valid license to continue using the platform.")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs(w.Link,{to:r("/administration/configuration/license"),className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(l.Settings,{className:"w-4 h-4"}),t("license.guard.manageLicense","Manage License")]}),e.jsxs(w.Link,{to:r("/myspace/profile"),className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(l.User,{className:"w-4 h-4"}),t("license.guard.myProfile","My Profile")]})]})]})]})]})}const Hi=["/myspace","/administration/configuration"];function Vi(t){const s=/^\/t\/[^/]+\/(.*)/.exec(t);return s?`/${s[1]}`:t}function Sa(){const{license:t,isLoading:s,isReadOnlyMode:r}=He(),a=w.useLocation();if(s)return e.jsx(w.Outlet,{});const o=Vi(a.pathname);return Hi.some(i=>o.startsWith(i))?e.jsx(w.Outlet,{}):!t?.isValid||r?e.jsxs(e.Fragment,{children:[e.jsx(w.Outlet,{}),e.jsx(Ki,{})]}):e.jsx(w.Outlet,{})}function js({feature:t}){const{t:s}=ne.useTranslation("admin"),{isFeatureEnabled:r,license:a,isLoading:o}=He();return o?e.jsx(w.Outlet,{}):r(t)?e.jsx(w.Outlet,{}):e.jsx("div",{className:"flex items-center justify-center min-h-[60vh] p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 bg-gray-50 dark:bg-gray-800/50 rounded-xl border-2 border-dashed border-gray-200 dark:border-gray-700 max-w-md",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(l.Lock,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:s("license.featureNotAvailable","Feature Not Available")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-sm mb-4",children:s("license.upgradeToAccess","Upgrade your license to access the {{feature}} feature.",{feature:t})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx(l.Sparkles,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.currentEdition","Current: {{edition}}",{edition:a?.edition||"Unknown"})})]})]})})}function Wi(){return ta(),null}function Xi(){return w.useInRouterContext()?e.jsx(Wi,{}):null}const vt="/api/administration/tenants/tenant-analytics",is={getDashboardStats:async(t=30)=>await E.get(`${vt}/dashboard`,{params:{period:t}}),getTopTenants:async(t=10,s=30,r="access")=>await E.get(`${vt}/top-tenants`,{params:{limit:t,period:s,sortBy:r}}),getTrends:async(t=30)=>await E.get(`${vt}/trends`,{params:{period:t}}),trackStart:async t=>await E.post(`${vt}/track/start`,{tenantId:t}),trackEnd:async t=>{await E.post(`${vt}/track/end`,{accessId:t})}},Yi="/api/administration/tenants/tenant-analytics";function Ji(){const{currentTenant:t}=Ee(),{isAuthenticated:s}=Pe(),r=n.useRef(null),a=n.useRef(null),o=n.useRef(!1);n.useEffect(()=>{if(!s)return;const c=window.location.pathname;if(c.startsWith("/auth/")||c.startsWith("/login"))return;const i=t?.id??null;return i===a.current||o.current?void 0:(o.current=!0,(async()=>{if(r.current){try{await is.trackEnd(r.current)}catch{}r.current=null}if(a.current=i,i)try{const u=await is.trackStart(i);r.current=u.accessId}catch{r.current=null}o.current=!1})(),()=>{if(r.current){const u=localStorage.getItem("token");if(!u)return;fetch(`${Yi}/track/end`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify({accessId:r.current}),keepalive:!0}).catch(()=>{}),r.current=null,a.current=null}})},[t?.id,s])}function Qi(){return Ji(),null}const Gs=n.lazy(()=>Promise.resolve().then(()=>mi).then(t=>({default:t.DocsLayout}))),Zi=n.lazy(()=>Promise.resolve().then(()=>require("./DocsIndexPage-BPfi0FQD.js")).then(t=>({default:t.DocsIndexPage}))),el=n.lazy(()=>Promise.resolve().then(()=>require("./SmartStackPresentationPage-52Nb7F0X.js")).then(t=>({default:t.SmartStackPresentationPage}))),tl=n.lazy(()=>Promise.resolve().then(()=>require("./DeveloperIndexPage-CtBfD2JI.js")).then(t=>({default:t.DeveloperIndexPage}))),sl=n.lazy(()=>Promise.resolve().then(()=>require("./InfrastructurePage-D4ZjLzI_.js")).then(t=>({default:t.InfrastructurePage}))),rl=n.lazy(()=>Promise.resolve().then(()=>require("./InstallationPage-BJ-GBVPp.js")).then(t=>({default:t.InstallationPage}))),al=n.lazy(()=>Promise.resolve().then(()=>require("./DatabasePage-DAzb3FnS.js")).then(t=>({default:t.DatabasePage}))),nl=n.lazy(()=>Promise.resolve().then(()=>require("./DualDbContextPage-Dz8NAewk.js")).then(t=>({default:t.DualDbContextPage}))),ol=n.lazy(()=>Promise.resolve().then(()=>require("./CrossSchemaFkPage-DqFNORYd.js")).then(t=>({default:t.CrossSchemaFkPage}))),il=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.TenantIndexPage}))),ll=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.MultiTenantModePage}))),cl=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.TenantB2CPage}))),dl=n.lazy(()=>Promise.resolve().then(()=>require("./TeamsIntegrationPage-DXj5MDRS.js")).then(t=>({default:t.TeamsIntegrationPage}))),ul=n.lazy(()=>Promise.resolve().then(()=>require("./index-CdORB0b4.js")).then(t=>({default:t.SecurityTestingPage}))),ml=n.lazy(()=>Promise.resolve().then(()=>require("./UserIndexPage-DahU6wzK.js")).then(t=>({default:t.UserIndexPage}))),pl=n.lazy(()=>Promise.resolve().then(()=>require("./ArchitecturePage-Cn_XCDAo.js")).then(t=>({default:t.ArchitecturePage}))),xl=n.lazy(()=>Promise.resolve().then(()=>require("./ModulesPage-lz8DUm3X.js")).then(t=>({default:t.ModulesPage}))),hl=n.lazy(()=>Promise.resolve().then(()=>require("./SlaDocPage-D44QWNY8.js")).then(t=>({default:t.SlaDocPage}))),gl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportIndexPage-CsDQ35Cu.js")).then(t=>({default:t.SupportIndexPage}))),fl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportDashboardDocPage-DfV-9_8r.js")).then(t=>({default:t.SupportDashboardDocPage}))),bl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportTicketsDocPage-B_603CpY.js")).then(t=>({default:t.SupportTicketsDocPage}))),vl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportMyTicketsDocPage-Dbp6XBnH.js")).then(t=>({default:t.SupportMyTicketsDocPage}))),yl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportTemplatesDocPage-BkeDpR-8.js")).then(t=>({default:t.SupportTemplatesDocPage}))),jl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportEscalationDocPage-C65oCDZL.js")).then(t=>({default:t.SupportEscalationDocPage}))),Nl=n.lazy(()=>Promise.resolve().then(()=>require("./AiDocPage-CM7j_50_.js")).then(t=>({default:t.AiDocPage}))),wl=n.lazy(()=>Promise.resolve().then(()=>require("./SettingsDocPage-Dqj8KzOa.js")).then(t=>({default:t.SettingsDocPage}))),Sl=n.lazy(()=>Promise.resolve().then(()=>require("./ThemeDocPage-B6x55uSE.js")).then(t=>({default:t.ThemeDocPage}))),Cl=n.lazy(()=>Promise.resolve().then(()=>require("./BaIndexPage-Df6ld4jp.js")).then(t=>({default:t.BaIndexPage}))),Ks=n.lazy(()=>Promise.resolve().then(()=>require("./BaViewerPage-CX3yS6tI.js")).then(t=>({default:t.BaViewerPage}))),kl=n.lazy(()=>Promise.resolve().then(()=>require("./index-CO5QP9C1.js"))),Al=n.lazy(()=>Promise.resolve().then(()=>require("./index-BASU1QDx.js"))),Pl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DYJbiXHU.js"))),Tl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BBQMnq4P.js"))),Rl=n.lazy(()=>Promise.resolve().then(()=>require("./index-Bz8ggekC.js"))),El=n.lazy(()=>Promise.resolve().then(()=>require("./index-D1WPBG1_.js"))),Il=n.lazy(()=>Promise.resolve().then(()=>require("./index-DIuoVYFu.js"))),Ll=n.lazy(()=>Promise.resolve().then(()=>require("./index-Cdu0fSs8.js"))),$l=n.lazy(()=>Promise.resolve().then(()=>require("./index-BVUCDL0k.js"))),Dl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DRT2wvEs.js"))),Ml=n.lazy(()=>Promise.resolve().then(()=>require("./index-xCGnOlox.js"))),Ol=n.lazy(()=>Promise.resolve().then(()=>require("./index-DQBVnnd6.js"))),Fl=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0rFTzxZ.js"))),_l=n.lazy(()=>Promise.resolve().then(()=>require("./index-HWG-CG1i.js"))),ql=n.lazy(()=>Promise.resolve().then(()=>require("./index-DlX3cwCY.js"))),Ul=n.lazy(()=>Promise.resolve().then(()=>require("./index-IuHTxwV6.js"))),zl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DiazxhY7.js"))),Bl=n.lazy(()=>Promise.resolve().then(()=>require("./index-i8XTb32s.js"))),Gl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BHim8lfc.js"))),Kl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BEpBEF5G.js"))),Hl=n.lazy(()=>Promise.resolve().then(()=>require("./index-p2jNjCTo.js")));function Vl(){return e.jsxs(e.Fragment,{children:[e.jsxs(w.Route,{path:"/system/docs",element:e.jsx(Gs,{}),children:[e.jsx(w.Route,{index:!0,element:e.jsx(Zi,{})}),e.jsx(w.Route,{path:"developer",element:e.jsx(tl,{})}),e.jsx(w.Route,{path:"developer/infrastructure",element:e.jsx(sl,{})}),e.jsx(w.Route,{path:"developer/installation",element:e.jsx(rl,{})}),e.jsx(w.Route,{path:"developer/database",element:e.jsx(al,{})}),e.jsx(w.Route,{path:"developer/dual-dbcontext",element:e.jsx(nl,{})}),e.jsx(w.Route,{path:"developer/cross-schema-fk",element:e.jsx(ol,{})}),e.jsx(w.Route,{path:"developer/tenants",element:e.jsx(il,{})}),e.jsx(w.Route,{path:"developer/tenants/multi-tenant-mode",element:e.jsx(ll,{})}),e.jsx(w.Route,{path:"developer/tenants/b2c",element:e.jsx(cl,{})}),e.jsx(w.Route,{path:"developer/multi-tenant-mode",element:e.jsx(w.Navigate,{to:"/system/docs/developer/tenants/multi-tenant-mode",replace:!0})}),e.jsx(w.Route,{path:"developer/teams-integration",element:e.jsx(dl,{})}),e.jsx(w.Route,{path:"developer/testing/security",element:e.jsx(ul,{})}),e.jsx(w.Route,{path:"user",element:e.jsx(ml,{})}),e.jsx(w.Route,{path:"user/architecture",element:e.jsx(pl,{})}),e.jsx(w.Route,{path:"user/modules",element:e.jsx(xl,{})}),e.jsx(w.Route,{path:"user/support",element:e.jsx(gl,{})}),e.jsx(w.Route,{path:"user/support-dashboard",element:e.jsx(fl,{})}),e.jsx(w.Route,{path:"user/support-tickets",element:e.jsx(bl,{})}),e.jsx(w.Route,{path:"user/support-my-tickets",element:e.jsx(vl,{})}),e.jsx(w.Route,{path:"user/support-sla",element:e.jsx(hl,{})}),e.jsx(w.Route,{path:"user/support-templates",element:e.jsx(yl,{})}),e.jsx(w.Route,{path:"user/support-escalation",element:e.jsx(jl,{})}),e.jsx(w.Route,{path:"user/ai",element:e.jsx(Nl,{})}),e.jsx(w.Route,{path:"user/settings",element:e.jsx(wl,{})}),e.jsx(w.Route,{path:"user/theme",element:e.jsx(Sl,{})}),e.jsx(w.Route,{path:"ba",element:e.jsx(Cl,{})}),e.jsx(w.Route,{path:"ba/:appCode",element:e.jsx(Ks,{})}),e.jsx(w.Route,{path:"ba/:appCode/:moduleCode",element:e.jsx(Ks,{})})]}),e.jsxs(w.Route,{path:"/docs/business",element:e.jsx(Gs,{}),children:[e.jsx(w.Route,{path:"administration/users",element:e.jsx(kl,{})}),e.jsx(w.Route,{path:"administration/users/dashboard",element:e.jsx(Al,{})}),e.jsx(w.Route,{path:"administration/users/references",element:e.jsx(Pl,{})}),e.jsx(w.Route,{path:"administration/users/groups",element:e.jsx(Tl,{})}),e.jsx(w.Route,{path:"administration/permissions",element:e.jsx(Rl,{})}),e.jsx(w.Route,{path:"administration/permissions/assignments",element:e.jsx(El,{})}),e.jsx(w.Route,{path:"administration/tenants",element:e.jsx(Il,{})}),e.jsx(w.Route,{path:"administration/tenants/template",element:e.jsx(Ll,{})}),e.jsx(w.Route,{path:"administration/tenants/business",element:e.jsx($l,{})}),e.jsx(w.Route,{path:"administration/tenants/personal",element:e.jsx(Dl,{})}),e.jsx(w.Route,{path:"administration/tenants/other",element:e.jsx(Ml,{})}),e.jsx(w.Route,{path:"administration/tenants/applications",element:e.jsx(Ol,{})}),e.jsx(w.Route,{path:"administration/tenants/access-requests",element:e.jsx(Fl,{})}),e.jsx(w.Route,{path:"administration/tenants/organisations",element:e.jsx(_l,{})}),e.jsx(w.Route,{path:"administration/ai",element:e.jsx(ql,{})}),e.jsx(w.Route,{path:"administration/workflows",element:e.jsx(Ul,{})}),e.jsx(w.Route,{path:"administration/entra",element:e.jsx(zl,{})}),e.jsx(w.Route,{path:"administration/applications",element:e.jsx(Bl,{})}),e.jsx(w.Route,{path:"administration/configuration",element:e.jsx(Gl,{})}),e.jsx(w.Route,{path:"administration/configuration/license",element:e.jsx(Kl,{})}),e.jsx(w.Route,{path:"platform/support/tickets",element:e.jsx(Hl,{})})]}),e.jsx(w.Route,{path:"/system/docs/presentation",element:e.jsx(el,{})}),e.jsx(w.Route,{path:"/docs/*",element:e.jsx(w.Navigate,{to:"/system/docs",replace:!0})}),e.jsx(w.Route,{path:"/docs",element:e.jsx(w.Navigate,{to:"/system/docs",replace:!0})})]})}const Wl={"administration.configuration.settings":{defaultTab:"general",tabs:["general","file-upload","legal-file"]},"administration.configuration.appsettings":{defaultTab:"infrastructure",tabs:["infrastructure","authentication","logging","email","entra"]}},Xl=[{icon:l.Users,title:"Gestion des Utilisateurs",description:"Créez, modifiez et gérez vos utilisateurs avec une interface intuitive. Profils complets, avatars et informations personnalisables.",color:"from-blue-500 to-cyan-500"},{icon:l.Bell,title:"Gestion des Notifications",description:"Système de notifications en temps réel. Email, push, in-app. Templates personnalisables et historique complet.",color:"from-amber-500 to-orange-500"},{icon:l.HeadphonesIcon,title:"Gestion du Support",description:"Système de tickets intégré pour le support client. Suivi, priorités, assignation et statistiques.",color:"from-emerald-500 to-teal-500"},{icon:l.Shield,title:"Panneau Administrateur",description:"Dashboard complet pour administrer votre plateforme. Métriques, logs, configuration et monitoring.",color:"from-purple-500 to-pink-500"},{icon:l.Key,title:"Gestion des Rôles",description:"RBAC avancé avec permissions granulaires. Hiérarchie de rôles, wildcards et héritage des droits.",color:"from-red-500 to-rose-500"},{icon:l.Layers,title:"Architecture Modulaire",description:"Structure en 5 niveaux : Contexte, Application, Module, Section, Resource. Extensible et maintenable.",color:"from-indigo-500 to-violet-500"}],Yl=[{icon:l.Zap,text:"Démarrage rapide"},{icon:l.Lock,text:"Sécurité intégrée"},{icon:l.Rocket,text:"Performance optimale"}],Jl=[".NET 10","React 19","TypeScript","EF Core","SQL Server","Tailwind CSS"];function Ql(){return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("section",{className:"relative pt-32 pb-20 md:pt-40 md:pb-32 overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 rounded-full bg-primary-500/10 blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 rounded-full bg-accent-500/10 blur-3xl"}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px] rounded-full bg-gradient-to-r from-primary-500/5 to-accent-500/5 blur-3xl"})]}),e.jsx("div",{className:"relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-primary-500/10 border border-primary-500/20 mb-8",children:[e.jsx(l.Zap,{className:"w-4 h-4 text-primary-500"}),e.jsx("span",{className:"text-sm font-medium text-primary-500",children:"Version 1.0 disponible"})]}),e.jsxs("h1",{className:"text-4xl sm:text-5xl md:text-6xl lg:text-7xl font-bold tracking-tight mb-6",children:["Le socle moderne pour",e.jsx("br",{}),e.jsx("span",{className:"gradient-text",children:"vos applications"})]}),e.jsx("p",{className:"max-w-2xl mx-auto text-lg md:text-xl text-[var(--text-secondary)] mb-10",children:"SmartStack est une plateforme complète pour créer des applications d'entreprise. Authentification, rôles, notifications et support intégrés."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4 mb-16",children:[e.jsxs("a",{href:"/register",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40",children:["Commencer gratuitement",e.jsx(l.ArrowRight,{className:"w-5 h-5"})]}),e.jsx("a",{href:"#features",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-semibold transition-all",children:"Découvrir les fonctionnalités"})]}),e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-6",children:Yl.map(t=>e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[e.jsx(t.icon,{className:"w-5 h-5 text-primary-500"}),e.jsx("span",{children:t.text})]},t.text))})]})})]}),e.jsx("section",{className:"py-8 bg-[var(--bg-secondary)] border-y border-[var(--border-color)]",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-8 md:gap-12",children:[e.jsx("span",{className:"text-[var(--text-tertiary)] text-sm uppercase tracking-wider",children:"Construit avec"}),Jl.map(t=>e.jsx("span",{className:"text-[var(--text-secondary)] font-medium",children:t},t))]})})}),e.jsx("section",{id:"features",className:"py-20 md:py-32",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Tout ce dont vous avez besoin"}),e.jsx("p",{className:"max-w-2xl mx-auto text-[var(--text-secondary)]",children:"SmartStack inclut toutes les fonctionnalités essentielles pour démarrer votre projet d'entreprise."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Xl.map(t=>e.jsxs("div",{className:"group p-6 rounded-2xl bg-[var(--bg-card)] border border-[var(--border-color)] hover-card",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl bg-gradient-to-br ${t.color} flex items-center justify-center mb-4`,children:e.jsx(t.icon,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:t.title}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:t.description})]},t.title))})]})}),e.jsx("section",{id:"modules",className:"py-20 md:py-32 bg-[var(--bg-secondary)]",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-6",children:["Architecture modulaire",e.jsx("br",{}),e.jsx("span",{className:"gradient-text",children:"prête pour la production"})]}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-8",children:"SmartStack utilise une architecture en 5 niveaux qui permet une organisation claire et une extensibilité maximale. Chaque niveau correspond à un scope de permissions."}),e.jsx("ul",{className:"space-y-4 mb-8",children:["Contexte - Environnements séparés (Platform, Business, Personal)","Application - Apps au sein d'un contexte (Admin, MySpace)","Module - Fonctionnalités (Users, Roles, Profile)","Section - Sous-divisions des modules","Resource - Éléments individuels"].map(t=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-primary-500/10 flex items-center justify-center mt-0.5",children:e.jsx(l.Check,{className:"w-4 h-4 text-primary-500"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t})]},t))})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-primary-500/20 to-accent-500/20 rounded-3xl blur-2xl"}),e.jsx("div",{className:"relative p-8 rounded-3xl bg-[var(--bg-card)] border border-[var(--border-color)]",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-primary-500/10 to-primary-500/5 border border-primary-500/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-primary-500"}),e.jsx("span",{className:"font-semibold text-primary-500",children:"Contexte: Platform"})]}),e.jsxs("div",{className:"ml-4 mt-3 p-3 rounded-lg bg-accent-500/10 border border-accent-500/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-500"}),e.jsx("span",{className:"font-medium text-accent-500",children:"Application: Admin"})]}),e.jsxs("div",{className:"ml-4 mt-2 space-y-2",children:[e.jsx("div",{className:"p-2 rounded bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:"Module: Users"})]})}),e.jsx("div",{className:"p-2 rounded bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Key,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:"Module: Roles"})]})})]})]})]})})})]})]})})}),e.jsx("section",{id:"contact",className:"py-20 md:py-32",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsx("div",{className:"relative overflow-hidden rounded-3xl animated-gradient p-px",children:e.jsxs("div",{className:"relative rounded-3xl bg-[var(--bg-primary)] p-8 md:p-16 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Prêt à commencer ?"}),e.jsx("p",{className:"max-w-2xl mx-auto text-[var(--text-secondary)] mb-8",children:"Lancez votre projet d'entreprise avec SmartStack. Tout est déjà configuré pour vous permettre de vous concentrer sur votre métier."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"/register",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40",children:["Créer un compte",e.jsx(l.ArrowRight,{className:"w-5 h-5"})]}),e.jsx("a",{href:"/contact",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-semibold transition-all",children:"Nous contacter"})]})]})})})})]})}const Zl=(t,s)=>{const r=s.exec(t);return r?r[1]:""},ec=[{detect:t=>t.includes("edg/")||t.includes("edge/"),name:"Edge",pattern:/Edg(?:e)?\/(\d+)/i},{detect:t=>t.includes("opr/")||t.includes("opera"),name:"Opera",pattern:/(?:OPR|Opera)\/(\d+)/i},{detect:t=>t.includes("chrome")&&!t.includes("edg"),name:"Chrome",pattern:/Chrome\/(\d+)/i},{detect:t=>t.includes("safari")&&!t.includes("chrome"),name:"Safari",pattern:/Version\/(\d+)/i},{detect:t=>t.includes("firefox"),name:"Firefox",pattern:/Firefox\/(\d+)/i},{detect:t=>t.includes("msie")||t.includes("trident"),name:"Internet Explorer",pattern:/(?:MSIE |rv:)(\d+)/i}],tc=(t,s)=>{const r=ec.find(a=>a.detect(t));return r?{browser:r.name,version:Zl(s,r.pattern)}:{browser:"Unknown",version:""}},sc={"windows nt 10":"10/11","windows nt 6.3":"8.1","windows nt 6.2":"8","windows nt 6.1":"7"},rc=t=>{for(const[s,r]of Object.entries(sc))if(t.includes(s))return r;return""},ac=[{detect:t=>t.includes("windows nt"),name:"Windows",getVersion:t=>rc(t)},{detect:t=>t.includes("windows"),name:"Windows",getVersion:()=>""},{detect:t=>t.includes("iphone"),name:"iOS",getVersion:(t,s)=>{const r=/OS (\d+)_/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("ipad"),name:"iPadOS",getVersion:(t,s)=>{const r=/OS (\d+)_/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("mac os x"),name:"macOS",getVersion:(t,s)=>{const r=/Mac OS X (\d+)[._](\d+)/i.exec(s);return r?`${r[1]}.${r[2]}`:""}},{detect:t=>t.includes("android"),name:"Android",getVersion:(t,s)=>{const r=/Android (\d+)/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("linux"),name:"Linux",getVersion:()=>""},{detect:t=>t.includes("cros"),name:"Chrome OS",getVersion:()=>""}],nc=(t,s)=>{const r=ac.find(a=>a.detect(t));if(r){const a=r.getVersion(t,s);return{os:r.name,version:a}}return{os:"Unknown",version:""}},oc=t=>/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk)/i.test(t)?"Tablet":/(android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile|phone)/i.test(t)?"Mobile":"Desktop";function ic(t){if(!t)return{browser:"Unknown",browserVersion:"",os:"Unknown",osVersion:"",device:"Unknown",formatted:"Unknown"};const s=t.toLowerCase(),{browser:r,version:a}=tc(s,t),{os:o,version:c}=nc(s,t),i=oc(s);let d=r;if(o!=="Unknown"){const u=a?a+" ":"",m=c?" "+c:"";d=`${r} ${u}sur ${o}${m}`}return{browser:r,browserVersion:a,os:o,osVersion:c,device:i,formatted:d}}function Ca(){const t=navigator.userAgent.toLowerCase();return/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(t)?"tablet":/(android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile|phone)/.test(t)?"mobile":/(windows|macintosh|linux|x11)/.test(t)?"desktop":"unknown"}async function ka(){try{const t=await fetch("https://api.ipify.org?format=json",{method:"GET",signal:AbortSignal.timeout(5e3)});return t.ok&&(await t.json()).ip||null}catch{return null}}function lc(){const[t,s]=n.useState(""),[r,a]=n.useState(""),[o,c]=n.useState(!1),[i,d]=n.useState(!1),[u,m]=n.useState("auth"),[p,f]=n.useState(null),[g]=n.useState(()=>{const h=new URLSearchParams(window.location.search).get("redirect_uri");return h?(sessionStorage.setItem("sso_redirect_uri",h),h):sessionStorage.getItem("sso_redirect_uri")}),b=n.useCallback(async h=>{h.preventDefault(),f(null),m("auth"),d(!0);try{Te.logEvent("login_attempt","auth",{email:t});const y=Ca(),x=await ka(),j=await E.post("/api/auth/login",{email:t,password:r,deviceType:y,clientIp:x});localStorage.setItem("token",j.token),localStorage.setItem("refreshToken",j.refreshToken),localStorage.setItem("user",JSON.stringify(j.user)),Te.logEvent("login_success","auth",{email:t}),m("prefs");try{if(!(await E.get("/api/onboarding/status")).hasCompletedOnboarding){window.location.href="/auth/onboarding";return}}catch{}try{const v=await Ft.preferences.get(),S={mode:v.theme||"dark",accentColorKey:v.accentColorKey||"indigo",borderRadius:v.borderRadius||{},itemPaletteKey:v.itemPaletteKey||"neutral"};localStorage.setItem("smartstack-theme-config",JSON.stringify(S)),v.language&&localStorage.setItem("i18nextLng",v.language)}catch{}if(localStorage.removeItem("currentTenantId"),localStorage.removeItem("currentTenantSlug"),localStorage.removeItem("isGlobalView"),g){sessionStorage.removeItem("sso_redirect_uri");const v=g.includes("?")?"&":"?";window.location.href=`${g}${v}token=${encodeURIComponent(j.token)}&refreshToken=${encodeURIComponent(j.refreshToken)}`;return}window.location.href="/myspace"}catch(y){if(y instanceof us)f({message:y.message,code:"NETWORK_ERROR"});else if(y instanceof xr)f({message:y.message,code:y.code});else{const x=y instanceof Error?y.message:"Une erreur inattendue est survenue";f({message:x})}Te.logError(y instanceof Error?y:new Error(String(y)),"LoginPage.handleSubmit",{email:t})}finally{d(!1)}},[t,r,g]);return{email:t,setEmail:s,password:r,setPassword:a,showPassword:o,setShowPassword:c,isLoading:i,loadingStep:u,error:p,handleSubmit:b}}const cc=[{icon:l.Shield,title:"Sécurité avancée",description:"Authentification multi-facteurs et contrôle d'accès granulaire"},{icon:l.Zap,title:"Performance optimale",description:"Interface rapide et réactive pour une productivité maximale"},{icon:l.Users,title:"Collaboration",description:"Gestion des équipes et permissions centralisée"},{icon:l.BarChart3,title:"Analytics",description:"Tableaux de bord et rapports en temps réel"}],dc=t=>{switch(t){case"ACCOUNT_DISABLED":return e.jsx(l.UserX,{className:"w-5 h-5 flex-shrink-0"});case"ACCOUNT_LOCKED":return e.jsx(l.Clock,{className:"w-5 h-5 flex-shrink-0"});case"EXTERNAL_AUTH_REQUIRED":return e.jsx(l.KeyRound,{className:"w-5 h-5 flex-shrink-0"});case"NETWORK_ERROR":return e.jsx(l.WifiOff,{className:"w-5 h-5 flex-shrink-0"});default:return e.jsx(l.AlertCircle,{className:"w-5 h-5 flex-shrink-0"})}},uc=t=>{switch(t){case"ACCOUNT_DISABLED":return"bg-orange-500/10 border-orange-500/20 text-orange-600 dark:text-orange-400";case"ACCOUNT_LOCKED":return"bg-amber-500/10 border-amber-500/20 text-amber-600 dark:text-amber-400";case"EXTERNAL_AUTH_REQUIRED":return"bg-blue-500/10 border-blue-500/20 text-blue-600 dark:text-blue-400";case"NETWORK_ERROR":return"bg-gray-500/10 border-gray-500/20 text-gray-600 dark:text-gray-400";default:return"bg-red-500/10 border-red-500/20 text-red-500"}};function mc(){const{email:t,setEmail:s,password:r,setPassword:a,showPassword:o,setShowPassword:c,isLoading:i,loadingStep:d,error:u,handleSubmit:m}=lc();return e.jsxs("div",{className:"min-h-screen flex",children:[e.jsxs("div",{className:"hidden lg:flex lg:w-1/2 xl:w-[55%] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 animated-gradient"}),e.jsx("div",{className:"absolute inset-0 opacity-10",style:{backgroundImage:"radial-gradient(circle at 1px 1px, white 1px, transparent 0)",backgroundSize:"40px 40px"}}),e.jsx("div",{className:"absolute top-20 left-20 w-72 h-72 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-20 right-20 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/3 w-64 h-64 bg-white/5 rounded-full blur-2xl animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"relative z-10 flex flex-col justify-between p-12 xl:p-16 text-white w-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-sm rounded-xl flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-7 h-7 text-white"})}),e.jsx("span",{className:"text-2xl font-bold",children:"SmartStack"})]}),e.jsxs("div",{className:"max-w-lg",children:[e.jsx("h1",{className:"text-4xl xl:text-5xl font-bold leading-tight mb-6",children:"Votre plateforme de gestion unifiée"}),e.jsx("p",{className:"text-xl text-white/80 mb-12",children:"Simplifiez vos processus, centralisez vos données et boostez la productivité de votre équipe."}),e.jsx("div",{className:"grid grid-cols-2 gap-6",children:cc.map(p=>e.jsxs("div",{className:"bg-white/10 backdrop-blur-sm rounded-2xl p-5 hover:bg-white/15 transition-colors",children:[e.jsx(p.icon,{className:"w-8 h-8 mb-3 text-white/90"}),e.jsx("h3",{className:"font-semibold mb-1",children:p.title}),e.jsx("p",{className:"text-sm text-white/70",children:p.description})]},p.title))})]}),e.jsxs("p",{className:"text-sm text-white/60",children:["© ",new Date().getFullYear()," SmartStack — Plateforme de gestion unifiée"]})]})]}),e.jsxs("div",{className:"w-full lg:w-1/2 xl:w-[45%] flex flex-col relative bg-[var(--bg-primary)]",children:[e.jsx("div",{className:"lg:hidden absolute inset-0",children:e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-96 h-96 rounded-full bg-primary-500/20 blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-96 h-96 rounded-full bg-accent-500/20 blur-3xl animate-pulse",style:{animationDelay:"1s"}})]})}),e.jsxs("div",{className:"absolute top-6 right-6 z-10 flex items-center gap-2",children:[e.jsx("a",{href:"/",className:"p-2 rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-colors",title:"Retour à l'accueil",children:e.jsx(l.Home,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx(Gt,{})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-6 sm:p-8 lg:p-12",children:e.jsxs("div",{className:"w-full max-w-md relative",children:[e.jsxs("div",{className:"lg:hidden flex flex-col items-center mb-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl animated-gradient flex items-center justify-center mb-4 shadow-lg",children:e.jsx(l.Layers,{className:"w-8 h-8 text-white"})}),e.jsx("h1",{className:"text-2xl font-bold",children:"SmartStack"})]}),e.jsxs("div",{className:"hidden lg:block mb-8",children:[e.jsx("h2",{className:"text-3xl font-bold mb-2",children:"Bienvenue"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"Connectez-vous à votre compte pour continuer"})]}),u&&e.jsxs("div",{className:`mb-6 p-4 rounded-xl border text-sm flex items-start gap-3 ${uc(u.code)}`,children:[dc(u.code),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:u.message}),u.code==="ACCOUNT_DISABLED"&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:"Contactez le support si vous pensez qu'il s'agit d'une erreur."}),u.code==="EXTERNAL_AUTH_REQUIRED"&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:"Utilisez les boutons Microsoft ou Google ci-dessous."})]})]}),e.jsxs("form",{onSubmit:m,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-2",children:"Adresse email"}),e.jsxs("div",{className:"relative",children:[e.jsx(l.Mail,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]"}),e.jsx("input",{id:"email",type:"email",value:t,onChange:p=>s(p.target.value),placeholder:"vous@exemple.com",required:!0,className:"w-full pl-12 pr-4 py-3.5 rounded-xl bg-[var(--bg-tertiary)] border border-[var(--border-color)] focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 outline-none transition-all placeholder:text-[var(--text-tertiary)]"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-2",children:"Mot de passe"}),e.jsxs("div",{className:"relative",children:[e.jsx(l.Lock,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]"}),e.jsx("input",{id:"password",type:o?"text":"password",value:r,onChange:p=>a(p.target.value),placeholder:"••••••••",required:!0,className:"w-full pl-12 pr-12 py-3.5 rounded-xl bg-[var(--bg-tertiary)] border border-[var(--border-color)] focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 outline-none transition-all placeholder:text-[var(--text-tertiary)]"}),e.jsx("button",{type:"button",onClick:()=>c(!o),className:"absolute right-4 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:o?e.jsx(l.EyeOff,{className:"w-5 h-5"}):e.jsx(l.Eye,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)] bg-[var(--bg-tertiary)] text-primary-600 focus:ring-primary-500/20"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:"Se souvenir de moi"})]}),e.jsx("a",{href:"/forgot-password",className:"text-primary-500 hover:text-primary-600 font-medium transition-colors",children:"Mot de passe oublié ?"})]}),e.jsx("button",{type:"submit",disabled:i,className:"w-full py-3.5 px-4 rounded-xl bg-primary-600 hover:bg-primary-700 disabled:bg-primary-600/50 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40 disabled:shadow-none flex items-center justify-center gap-2",children:i?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}),d==="auth"?"Connexion en cours...":"Chargement des préférences..."]}):"Se connecter"})]}),e.jsxs("div",{className:"relative my-8",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-[var(--border-color)]"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-4 bg-[var(--bg-primary)] text-[var(--text-tertiary)]",children:"Ou continuer avec"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>window.location.href="/api/auth/microsoft",className:"flex items-center justify-center gap-3 py-3.5 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-medium transition-all",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"1",y:"1",width:"9",height:"9",fill:"#F25022"}),e.jsx("rect",{x:"11",y:"1",width:"9",height:"9",fill:"#7FBA00"}),e.jsx("rect",{x:"1",y:"11",width:"9",height:"9",fill:"#00A4EF"}),e.jsx("rect",{x:"11",y:"11",width:"9",height:"9",fill:"#FFB900"})]}),"Microsoft"]}),e.jsxs("button",{type:"button",onClick:()=>window.location.href="/api/auth/google",className:"flex items-center justify-center gap-3 py-3.5 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-medium transition-all",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Google"]})]}),e.jsxs("p",{className:"text-center text-[var(--text-secondary)] mt-8",children:["Nouveau sur SmartStack ?"," ",e.jsx("a",{href:"/register",className:"text-primary-500 hover:text-primary-600 font-semibold transition-colors",children:"Créer un compte"})]})]})}),e.jsx("div",{className:"p-6 text-center",children:e.jsxs("p",{className:"text-sm text-[var(--text-tertiary)]",children:["© ",new Date().getFullYear()," SmartStack. Tous droits réservés."]})})]})]})}function pc(){const{t}=ne.useTranslation("common"),s=w.useNavigate(),r=()=>{window.history.length>2?s(-1):s("/")};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[var(--bg-primary)] p-4",children:e.jsx("div",{className:"max-w-md w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-yellow-500/10 flex items-center justify-center mb-6",children:e.jsx(l.FileWarning,{className:"w-8 h-8 text-yellow-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:t("errors.notFound.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("errors.notFound.description")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mb-6 font-mono",children:window.location.pathname}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("button",{onClick:r,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),t("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),t("errors.home")]})]})]})})})}const xc=n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsPage-BCbgotIx.js")).then(t=>({default:t.ApplicationsPage}))),hc=n.lazy(()=>Promise.resolve().then(()=>require("./NotificationsPage-BiaLRb0s.js")).then(t=>({default:t.NotificationsPage}))),gc=n.lazy(()=>Promise.resolve().then(()=>pi).then(t=>({default:t.PublicLayout}))),Qt=n.lazy(()=>Promise.resolve().then(()=>ii).then(t=>({default:t.AppLayout}))),fc=n.lazy(()=>Promise.resolve().then(()=>require("./RegisterPage-CiQib3-6.js")).then(t=>({default:t.RegisterPage}))),bc=n.lazy(()=>Promise.resolve().then(()=>require("./ConfirmEmailPage-BUfGSqxF.js")).then(t=>({default:t.ConfirmEmailPage}))),vc=n.lazy(()=>Promise.resolve().then(()=>require("./ForgotPasswordPage-0u49E4Pw.js")).then(t=>({default:t.ForgotPasswordPage}))),yc=n.lazy(()=>Promise.resolve().then(()=>require("./ResetPasswordPage-CubPG3yv.js")).then(t=>({default:t.ResetPasswordPage}))),jc=n.lazy(()=>Promise.resolve().then(()=>require("./ForceChangePasswordPage-lRpkwcX7.js")).then(t=>({default:t.ForceChangePasswordPage}))),Nc=n.lazy(()=>Promise.resolve().then(()=>require("./AuthCallbackPage-C7XiZxKb.js")).then(t=>({default:t.AuthCallbackPage}))),wc=n.lazy(()=>Promise.resolve().then(()=>require("./OnboardingWizardPage-DQrBKNBq.js")).then(t=>({default:t.OnboardingWizardPage}))),Sc={".detail":"/:id",".edit":"/:id/edit",".create":"/create",".new":"/new",".duplicate":"/:id/duplicate",".settings":"/:id/settings",".configure":"/:id/configure",".permissions":"/:id/permissions",".members":"/:id/members",".history":"/:id/history",".logs":"/:id/logs",".analytics":"/:id/analytics",".preview":"/:id/preview",".versions":"/:id/versions",".comments":"/:id/comments",".attachments":"/:id/attachments",".audit":"/:id/audit",".export":"/:id/export",".notifications":"/:id/notifications",".schedule":"/:id/schedule",".workflow":"/:id/workflow",".summary":"/:id/summary",".test":"/:id/test",".runs":"/:id/runs",".import":"/import"};function Ns(t,s){const r=[];for(const[a,o]of Object.entries(Sc)){const c=`${t}${a}`,i=O.resolve(c);if(i){const d=s.replace(/^\//,"")+o;r.push({path:d,Component:i})}}return r}function Cc(t,s,r,a){const o=[],c=r.route?.replace(`/${a}/`,"")||`${t.code}/${s.code}/${r.code}`,i=O.resolve(r.componentKey);if(i){const d=i;o.push(e.jsx(w.Route,{path:c,element:e.jsx(d,{})},r.componentKey))}if(r.route)for(const d of Ns(r.componentKey,c)){const u=d.Component;o.push(e.jsx(w.Route,{path:d.path,element:e.jsx(u,{})},`${r.componentKey}-implicit-${d.path}`))}return o}function kc(t,s,r){const a=[],o=s.route?.replace(`/${r}/`,"")||`${t.code}/${s.code}`,c=Wl[s.componentKey];if(c){const d=O.resolve(s.componentKey);if(d){const u=c.tabs.map(m=>{const p=`${s.componentKey}.${m}`,f=O.resolve(p);return f?e.jsx(w.Route,{path:m,element:e.jsx(f,{})},p):null}).filter(Boolean);return a.push(e.jsxs(w.Route,{path:o,element:e.jsx(d,{}),children:[e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:c.defaultTab,replace:!0})}),u]},s.componentKey)),a}}const i=O.resolve(s.componentKey);if(i){const d=i;a.push(e.jsx(w.Route,{path:o,element:e.jsx(d,{})},s.componentKey))}if(!i&&s.resources.length>0){const d=s.resources[0];a.push(e.jsx(w.Route,{path:o,element:e.jsx(w.Navigate,{to:d.code,replace:!0})},`${s.componentKey}-redirect`))}if(s.route)for(const d of Ns(s.componentKey,o)){const u=d.Component;a.push(e.jsx(w.Route,{path:d.path,element:e.jsx(u,{})},`${s.componentKey}-implicit-${d.path}`))}for(const d of s.resources){const u=Cc(t,s,d,r);a.push(...u)}return a}function Ac(t,s){const r=[],a=t.route?.replace(`/${s}/`,"")||t.code,o=O.resolve(t.componentKey);if(o){const c=o;r.push(e.jsx(w.Route,{path:a,element:e.jsx(c,{})},t.componentKey))}if(!o&&t.sections.length>0){const c=t.sections[0];r.push(e.jsx(w.Route,{path:a,element:e.jsx(w.Navigate,{to:c.code,replace:!0})},`${t.componentKey}-redirect`))}if(t.route)for(const c of Ns(t.componentKey,a)){const i=c.Component;r.push(e.jsx(w.Route,{path:c.path,element:e.jsx(i,{})},`${t.componentKey}-implicit-${c.path}`))}for(const c of t.sections){const i=kc(t,c,s);r.push(...i)}return r}function Pc(t){const s=[],r=O.resolve(t.componentKey);if(r){const a=r;s.push(e.jsx(w.Route,{index:!0,element:e.jsx(a,{})},`${t.code}-index`))}else if(t.modules.length>0){const a=t.modules[0],o=a.route?.replace(/^\//,"").replace(new RegExp(`^${t.code}/?`),"")||a.code;s.push(e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:o,replace:!0})},`${t.code}-index`))}for(const a of t.modules){const o=Ac(a,t.code);a.requiredFeature?s.push(e.jsx(w.Route,{element:e.jsx(js,{feature:a.requiredFeature}),children:o},`feature-${a.componentKey}`)):s.push(...o)}return s}function Tc(t,s){return t.requiredFeature?[e.jsx(w.Route,{element:e.jsx(js,{feature:t.requiredFeature}),children:s},`feature-${t.code}`)]:s}function Rc(t){switch(t){case"administration":return[e.jsx(w.Route,{path:"settings",element:e.jsx(w.Navigate,{to:"../configuration/settings",relative:"path",replace:!0})},"legacy-settings"),e.jsx(w.Route,{path:"settings/*",element:e.jsx(Oe,{to:"/administration/configuration/settings"})},"legacy-settings-wc"),e.jsx(w.Route,{path:"appsettings",element:e.jsx(w.Navigate,{to:"../configuration/appsettings",relative:"path",replace:!0})},"legacy-appsettings"),e.jsx(w.Route,{path:"appsettings/*",element:e.jsx(Oe,{to:"/administration/configuration/appsettings"})},"legacy-appsettings-wc"),e.jsx(w.Route,{path:"email-templates",element:e.jsx(w.Navigate,{to:"../workflows/email-templates",relative:"path",replace:!0})},"legacy-email-templates"),e.jsx(w.Route,{path:"email-templates/list",element:e.jsx(w.Navigate,{to:"../../workflows/email-templates",relative:"path",replace:!0})},"legacy-email-templates-list"),e.jsx(w.Route,{path:"email-templates/create",element:e.jsx(w.Navigate,{to:"../../workflows/email-templates/create",relative:"path",replace:!0})},"legacy-email-templates-create"),e.jsx(w.Route,{path:"workflows/templates",element:e.jsx(w.Navigate,{to:"../email-templates",relative:"path",replace:!0})},"legacy-wf-templates"),e.jsx(w.Route,{path:"workflows/templates/*",element:e.jsx(Oe,{to:"/administration/workflows/email-templates"})},"legacy-wf-templates-wc"),e.jsx(w.Route,{path:"tenants/business",element:e.jsx(w.Navigate,{to:"../tenants/list/enterprise",replace:!0})},"legacy-tenants-biz"),e.jsx(w.Route,{path:"tenants/personal",element:e.jsx(w.Navigate,{to:"../tenants/list/personal",replace:!0})},"legacy-tenants-perso")];case"support":return[e.jsx(w.Route,{path:"dashboard",element:e.jsx(w.Navigate,{to:"tickets",replace:!0})},"legacy-dashboard"),e.jsx(w.Route,{path:"sla",element:e.jsx(w.Navigate,{to:"admin/sla",replace:!0})},"legacy-sla"),e.jsx(w.Route,{path:"templates",element:e.jsx(w.Navigate,{to:"admin/templates",replace:!0})},"legacy-templates"),e.jsx(w.Route,{path:"admin/escalation",element:e.jsx(w.Navigate,{to:"tickets/escalation",replace:!0})},"legacy-admin-esc")];default:return[]}}function Ec(){const{isLoading:t,menu:s}=Ce(),{currentTenant:r}=Ee(),{user:a}=Pe(),o=w.useLocation();if(t)return e.jsx(St,{});const c=o.pathname.split("/").filter(Boolean),i=c[0]==="t"?c.slice(2):c,d=i.slice(0,2).join("."),u=r?.slug?`/t/${r.slug}/applications`:"/applications",m=i[0]?.toLowerCase(),f=(m?s?.applications.some(g=>g.code?.toLowerCase()===m)??!1:!1)?"permission":"tenant";return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(wt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(os,{reason:f,tenantName:r?.name,permissionPath:d||void 0,applicationsUrl:u,userRoles:a?.roles,userPermissions:a?.permissions})})})]})}function Ic(){const{isLoading:t}=Ce();return!!localStorage.getItem("token")&&t?e.jsx(St,{}):e.jsx(pc,{})}function Lc(){const{menu:t,isLoading:s}=Ce(),r=n.useMemo(()=>!t||s?[]:t.applications.map(o=>{const c=o.route?.replace(/^\//,"")||o.code,i=Pc(o),d=Tc(o,i),u=Rc(o.code);return e.jsxs(w.Route,{path:c,element:e.jsx(Qt,{}),children:[d,u]},o.code)}),[t,s]),a=e.jsx(e.Fragment,{children:e.jsx(w.Route,{element:e.jsx(wa,{}),children:e.jsxs(w.Route,{element:e.jsx(Sa,{}),children:[r,e.jsx(w.Route,{path:"applications",element:e.jsx(Qt,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(xc,{})})}),e.jsx(w.Route,{path:"notifications",element:e.jsx(Qt,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(hc,{})})}),e.jsx(w.Route,{path:"administration/external-apps",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"administration/external-apps/*",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"api/external-apps",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"api/external-apps/*",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"support-client",element:e.jsx(Oe,{to:"/support/my-tickets"})}),e.jsx(w.Route,{path:"support-client/*",element:e.jsx(Oe,{to:"/support/my-tickets"})}),e.jsx(w.Route,{path:"user",element:e.jsx(Oe,{to:"/myspace"})}),e.jsx(w.Route,{path:"user/*",element:e.jsx(Oe,{to:"/myspace"})}),e.jsx(w.Route,{path:"*",element:e.jsx(Ec,{})})]})})});return e.jsxs(n.Suspense,{fallback:e.jsx(St,{}),children:[e.jsx(Xi,{}),e.jsx(Qi,{}),e.jsxs(w.Routes,{children:[e.jsx(w.Route,{path:"/",element:e.jsx(gc,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(Ql,{})})}),Vl(),e.jsx(w.Route,{path:"/login",element:e.jsx(mc,{})}),e.jsx(w.Route,{path:"/register",element:e.jsx(fc,{})}),e.jsx(w.Route,{path:"/confirm-email",element:e.jsx(bc,{})}),e.jsx(w.Route,{path:"/forgot-password",element:e.jsx(vc,{})}),e.jsx(w.Route,{path:"/reset-password",element:e.jsx(yc,{})}),e.jsx(w.Route,{path:"/force-change-password",element:e.jsx(jc,{})}),e.jsx(w.Route,{path:"/auth/callback",element:e.jsx(Nc,{})}),e.jsx(w.Route,{path:"/auth/onboarding",element:e.jsx(wc,{})}),e.jsx(w.Route,{path:"/t/:slug",element:e.jsx(Bs,{}),children:a}),e.jsx(w.Route,{element:e.jsx(Bs,{}),children:a}),e.jsx(w.Route,{path:"/admin",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/admin/*",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/administration/*",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/support/*",element:e.jsx(w.Navigate,{to:"/support",replace:!0})}),e.jsx(w.Route,{path:"/dashboard",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal/myspace",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal/myspace/*",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/user",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/user/*",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/business",element:e.jsx(w.Navigate,{to:"/applications",replace:!0})}),e.jsx(w.Route,{path:"/business/support-client/*",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"/support-client/*",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"/support-client",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"*",element:e.jsx(Ic,{})})]})]})}function Hs({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function $c(t,s){return t?"bg-[var(--color-accent-100)] border border-[var(--color-accent-500)]":s?"opacity-50 cursor-not-allowed bg-[var(--bg-secondary)]":"bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] border border-transparent hover:border-[var(--border-color)]"}function Aa({isOpen:t,onClose:s}){const{t:r}=ne.useTranslation(["common","navigation"]),{menu:a}=Ce(),{favorites:o,toggleFavorite:c,isFavorite:i,canAddMore:d,maxFavorites:u}=Ke();if(!t)return null;const m=[];a?.applications.forEach(f=>{(f.modules?.length??0)>0&&m.push({app:f,modules:f.modules})});const p=(f,g)=>{const b=[...f.sections||[]].sort((x,j)=>x.displayOrder-j.displayOrder),h=b.length>0&&b[0].route?b[0].route:`/${g.code}/${f.code}`,y={id:f.id,code:f.code,label:f.label,icon:f.icon||"Star",route:h,applicationCode:g.code,applicationLabel:g.label};c(y)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-modal)] shadow-xl w-full max-w-lg max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-5 h-5 text-[var(--color-accent-500)]"}),r("common:favorites.manageTitle")]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r("common:favorites.selectModules",{count:o.length,max:u})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>{const f={component:"FavoritesModal",url:window.location.href},g=`https://github.com/anthropics/claude-code/issues/new?title=${encodeURIComponent("[Bug] Favorites Modal")}&body=${encodeURIComponent(`## Context
29
+ `)}`},[b,i]),y=n.useMemo(()=>{if(!t||!r||!s||!a)return null;const S=`${a.replace(/\/applications$/,"")}/support/my-tickets/create`,N=t==="tenant"?"ApplicationRequest":"Support",I=r.split(".")[0],P=t==="tenant"?i("errors.accessDenied.ticket.accessSubject",{permissionPath:r,tenantName:s}):i("errors.accessDenied.ticket.permissionSubject",{permissionPath:r,tenantName:s}),A=(t==="tenant"?i("errors.accessDenied.ticket.accessBody",{appCode:I,tenantName:s,permissionPath:r}):i("errors.accessDenied.ticket.permissionBody",{permissionPath:r,tenantName:s}))+g,R=new URLSearchParams({type:N,subject:P,body:A});return`${S}?${R.toString()}`},[t,r,s,a,i,g]),j=t==="tenant"&&s?i("errors.accessDenied.tenantNotAvailable",{tenantName:s}):t==="permission"&&s?i("errors.accessDenied.permissionMissing",{tenantName:s}):s?i("errors.accessDenied.tenantDescription",{tenantName:s}):i("errors.accessDenied.description");return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-6",children:e.jsx(l.ShieldX,{className:"w-8 h-8 text-red-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:i("errors.accessDenied.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:j}),h&&e.jsxs("div",{className:"w-full mb-6 bg-[var(--bg-secondary)] rounded-lg border border-[var(--border-color)] divide-y divide-[var(--border-color)]",children:[e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:i("errors.accessDenied.requiredPermission")}),e.jsx("p",{className:"text-sm font-mono font-medium text-red-500",children:r})]}),(o?.length??0)>0&&e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-2",children:i("errors.accessDenied.yourRoles")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 justify-center",children:o?.map(v=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:v},v))})]}),c&&e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-2",children:i("errors.accessDenied.yourPermissionsFor",{appCode:p??""})}),f.length>0?e.jsx("div",{className:"flex flex-col gap-1 items-start",children:f.map(v=>e.jsx("span",{className:"text-xs font-mono text-[var(--text-secondary)]",children:v},v))}):e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] italic",children:i("errors.accessDenied.noPermissions")})]})]}),!h&&r&&e.jsxs("div",{className:"w-full mb-6 p-3 bg-[var(--bg-secondary)] rounded-lg border border-[var(--border-color)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:i("errors.accessDenied.requiredPermission")}),e.jsx("p",{className:"text-sm font-mono text-[var(--text-primary)]",children:r})]}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[y&&e.jsxs("a",{href:y,className:"flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.TicketPlus,{className:"w-4 h-4"}),i(t==="tenant"?"errors.accessDenied.requestAccess":"errors.accessDenied.requestPermission")]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[a?e.jsxs("a",{href:a,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.LayoutGrid,{className:"w-4 h-4"}),i("errors.accessDenied.goToApplications")]}):e.jsxs("button",{onClick:m,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),i("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),i("errors.home")]})]})]})]})})})}function Hi(){const{t}=ne.useTranslation("common"),{logout:s}=Pe();return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-lg w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-orange-500/10 flex items-center justify-center mb-6",children:e.jsx(l.Building2,{className:"w-8 h-8 text-orange-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:t("errors.noActiveWorkspace.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("errors.noActiveWorkspace.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("a",{href:"mailto:support@atlashub.ch",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.Mail,{className:"w-4 h-4"}),t("errors.noActiveWorkspace.contactAdmin")]}),e.jsxs("button",{onClick:()=>{s()},className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.LogOut,{className:"w-4 h-4"}),t("errors.noActiveWorkspace.logout")]})]}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mt-6",children:t("errors.noActiveWorkspace.hint")})]})})})}function wt(){return e.jsx("div",{className:"flex items-center justify-center min-h-[400px] w-full",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(l.Loader2,{className:"w-10 h-10 animate-spin text-[var(--color-primary-500)]"}),e.jsx("span",{className:"text-sm text-[var(--color-text-secondary)]",children:"Chargement..."})]})})}function Sa(){const{user:t,isLoading:s}=Pe(),r=w.useLocation(),{currentAppCode:a,currentModuleCode:o,isLoading:c,menu:i}=Ce(),{currentTenant:d,userTenants:u,isLoading:m,isGlobalView:p}=Ee(),f=d?.id||"global",h=n.useRef(null),b=(S,N)=>{const I=`${S}:${N}:${r.pathname}`;h.current!==I&&(h.current=I,E.post("/security/access-denied",{reason:S,permissionPath:N,attemptedPath:r.pathname}).catch(()=>{}))},g=n.useRef(d?.id);let y=!1;if(d?.id!==g.current&&(g.current=d?.id,y=!0),s)return e.jsx(wt,{});if(!t)return e.jsx(w.Navigate,{to:"/login",state:{from:r},replace:!0});if(y||c||m||!i)return e.jsx(wt,{});if(!d&&!p&&!u.some(N=>N.status==="Active"))return e.jsx(Hi,{});if(!a)return e.jsx(w.Outlet,{},f);if(Lr.includes(a))return e.jsx(w.Outlet,{},f);const j=(i?.applications||[]).find(S=>S.route?.split("/").filter(Boolean)[0]===a||S.code===a);if(j?.isOpen)return e.jsx(w.Outlet,{},f);if(!j){const S=[a,o].filter(Boolean).join("."),N=d?.slug?`/t/${d.slug}/applications`:"/applications";return b("tenant",S),e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(Nt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(ls,{reason:"tenant",tenantName:d?.name,permissionPath:S,applicationsUrl:N,userRoles:t.roles,userPermissions:t.permissions})})})]})}const v=[a,o].filter(Boolean).join(".");if(!Nr(t.permissions,v)&&j.accessLevel!=="RequestAccess"){const S=d?.slug?`/t/${d.slug}/applications`:"/applications";return b("permission",v),e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(Nt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(ls,{reason:"permission",tenantName:d?.name,permissionPath:v,applicationsUrl:S,userRoles:t.roles,userPermissions:t.permissions})})})]})}return e.jsx(w.Outlet,{},f)}function Ks(){const{slug:t}=w.useParams(),s=w.useNavigate(),r=w.useLocation(),{currentTenant:a,userTenants:o,switchTenant:c,isLoading:i,isGlobalView:d}=Ee(),{useUrlRouting:u,isLoading:m}=qt(),p=n.useRef(!1),f=n.useRef(null),h=n.useRef(null);return n.useEffect(()=>{if(i||m||!u||d)return;const b=t||Ms(r.pathname),g=b!==h.current;if(h.current=b,!!g&&b&&b!==a?.slug){const y=o.find(x=>x.slug===b&&x.status==="Active");if(y)f.current=b,c(y.id).then(()=>{f.current=null}).catch(x=>{f.current=null,console.error("[TenantRouteWrapper] Failed to switch tenant:",x)});else if(a){const x=dt(r.pathname);s(`/t/${a.slug}${x}`,{replace:!0})}else s("/",{replace:!0})}},[t,r.pathname,a?.slug,o,u,i,m,d,c,s]),n.useEffect(()=>{if(i||m||p.current)return;const b=r.pathname,g=Ms(b);if(d&&g){p.current=!0;const y=dt(b);s(y,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(!u&&g){p.current=!0;const y=dt(b);s(y,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(u&&a&&!g&&!d&&b!=="/"&&!b.startsWith("/login")&&!b.startsWith("/auth")&&!b.startsWith("/public")){p.current=!0,s(`/t/${a.slug}${b}`,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}if(u&&a&&g&&!d&&g!==a.slug&&g!==f.current){p.current=!0;const y=dt(b);s(`/t/${a.slug}${y}`,{replace:!0}),setTimeout(()=>{p.current=!1},100);return}},[r.pathname,a?.slug,u,i,m,d,s]),e.jsx(w.Outlet,{})}function Oe({to:t,replace:s=!0}){const{slug:r}=w.useParams(),a=r?`/t/${r}${t}`:t;return e.jsx(w.Navigate,{to:a,replace:s})}function Vi(){const{t}=ne.useTranslation("admin"),{license:s}=He(),r=Ze();return!s||s.status==="NoLicense"?e.jsx(wa,{open:!0,onOpenChange:()=>{}}):e.jsxs("div",{className:"fixed inset-0 z-40 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[e.jsx("div",{className:"flex justify-center pt-8 pb-4",children:e.jsx("div",{className:"p-4 bg-red-100 dark:bg-red-900/30 rounded-full",children:e.jsx(l.Lock,{className:"w-10 h-10 text-red-600 dark:text-red-400"})})}),e.jsxs("div",{className:"px-6 pb-6 text-center",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-white mb-2",children:t("license.guard.title","License Required")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:t("license.guard.description","Your license has expired or is invalid. Access to this area is restricted. Please activate a valid license to continue using the platform.")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs(w.Link,{to:r("/administration/configuration/license"),className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(l.Settings,{className:"w-4 h-4"}),t("license.guard.manageLicense","Manage License")]}),e.jsxs(w.Link,{to:r("/myspace/profile"),className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(l.User,{className:"w-4 h-4"}),t("license.guard.myProfile","My Profile")]})]})]})]})]})}const Wi=["/myspace","/administration/configuration"];function Xi(t){const s=/^\/t\/[^/]+\/(.*)/.exec(t);return s?`/${s[1]}`:t}function Ca(){const{license:t,isLoading:s,isReadOnlyMode:r}=He(),a=w.useLocation();if(s)return e.jsx(w.Outlet,{});const o=Xi(a.pathname);return Wi.some(i=>o.startsWith(i))?e.jsx(w.Outlet,{}):!t?.isValid||r?e.jsxs(e.Fragment,{children:[e.jsx(w.Outlet,{}),e.jsx(Vi,{})]}):e.jsx(w.Outlet,{})}function ws({feature:t}){const{t:s}=ne.useTranslation("admin"),{isFeatureEnabled:r,license:a,isLoading:o}=He();return o?e.jsx(w.Outlet,{}):r(t)?e.jsx(w.Outlet,{}):e.jsx("div",{className:"flex items-center justify-center min-h-[60vh] p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 bg-gray-50 dark:bg-gray-800/50 rounded-xl border-2 border-dashed border-gray-200 dark:border-gray-700 max-w-md",children:[e.jsx("div",{className:"p-4 bg-gray-100 dark:bg-gray-700 rounded-full mb-4",children:e.jsx(l.Lock,{className:"w-8 h-8 text-gray-400 dark:text-gray-500"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:s("license.featureNotAvailable","Feature Not Available")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-sm mb-4",children:s("license.upgradeToAccess","Upgrade your license to access the {{feature}} feature.",{feature:t})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx(l.Sparkles,{className:"w-4 h-4"}),e.jsx("span",{children:s("license.currentEdition","Current: {{edition}}",{edition:a?.edition||"Unknown"})})]})]})})}function Yi(){return sa(),null}function Ji(){return w.useInRouterContext()?e.jsx(Yi,{}):null}const vt="/api/administration/tenants/tenant-analytics",cs={getDashboardStats:async(t=30)=>await E.get(`${vt}/dashboard`,{params:{period:t}}),getTopTenants:async(t=10,s=30,r="access")=>await E.get(`${vt}/top-tenants`,{params:{limit:t,period:s,sortBy:r}}),getTrends:async(t=30)=>await E.get(`${vt}/trends`,{params:{period:t}}),trackStart:async t=>await E.post(`${vt}/track/start`,{tenantId:t}),trackEnd:async t=>{await E.post(`${vt}/track/end`,{accessId:t})}},Qi="/api/administration/tenants/tenant-analytics";function Zi(){const{currentTenant:t}=Ee(),{isAuthenticated:s}=Pe(),r=n.useRef(null),a=n.useRef(null),o=n.useRef(!1);n.useEffect(()=>{if(!s)return;const c=window.location.pathname;if(c.startsWith("/auth/")||c.startsWith("/login"))return;const i=t?.id??null;return i===a.current||o.current?void 0:(o.current=!0,(async()=>{if(r.current){try{await cs.trackEnd(r.current)}catch{}r.current=null}if(a.current=i,i)try{const u=await cs.trackStart(i);r.current=u.accessId}catch{r.current=null}o.current=!1})(),()=>{if(r.current){const u=localStorage.getItem("token");if(!u)return;fetch(`${Qi}/track/end`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify({accessId:r.current}),keepalive:!0}).catch(()=>{}),r.current=null,a.current=null}})},[t?.id,s])}function el(){return Zi(),null}const Hs=n.lazy(()=>Promise.resolve().then(()=>xi).then(t=>({default:t.DocsLayout}))),tl=n.lazy(()=>Promise.resolve().then(()=>require("./DocsIndexPage-BPfi0FQD.js")).then(t=>({default:t.DocsIndexPage}))),sl=n.lazy(()=>Promise.resolve().then(()=>require("./SmartStackPresentationPage-52Nb7F0X.js")).then(t=>({default:t.SmartStackPresentationPage}))),rl=n.lazy(()=>Promise.resolve().then(()=>require("./DeveloperIndexPage-CtBfD2JI.js")).then(t=>({default:t.DeveloperIndexPage}))),al=n.lazy(()=>Promise.resolve().then(()=>require("./InfrastructurePage-D4ZjLzI_.js")).then(t=>({default:t.InfrastructurePage}))),nl=n.lazy(()=>Promise.resolve().then(()=>require("./InstallationPage-BJ-GBVPp.js")).then(t=>({default:t.InstallationPage}))),ol=n.lazy(()=>Promise.resolve().then(()=>require("./DatabasePage-DAzb3FnS.js")).then(t=>({default:t.DatabasePage}))),il=n.lazy(()=>Promise.resolve().then(()=>require("./DualDbContextPage-Dz8NAewk.js")).then(t=>({default:t.DualDbContextPage}))),ll=n.lazy(()=>Promise.resolve().then(()=>require("./CrossSchemaFkPage-DqFNORYd.js")).then(t=>({default:t.CrossSchemaFkPage}))),cl=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.TenantIndexPage}))),dl=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.MultiTenantModePage}))),ul=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0AgM8YN.js")).then(t=>({default:t.TenantB2CPage}))),ml=n.lazy(()=>Promise.resolve().then(()=>require("./TeamsIntegrationPage-DXj5MDRS.js")).then(t=>({default:t.TeamsIntegrationPage}))),pl=n.lazy(()=>Promise.resolve().then(()=>require("./index-CdORB0b4.js")).then(t=>({default:t.SecurityTestingPage}))),xl=n.lazy(()=>Promise.resolve().then(()=>require("./UserIndexPage-DahU6wzK.js")).then(t=>({default:t.UserIndexPage}))),hl=n.lazy(()=>Promise.resolve().then(()=>require("./ArchitecturePage-Cn_XCDAo.js")).then(t=>({default:t.ArchitecturePage}))),gl=n.lazy(()=>Promise.resolve().then(()=>require("./ModulesPage-lz8DUm3X.js")).then(t=>({default:t.ModulesPage}))),fl=n.lazy(()=>Promise.resolve().then(()=>require("./SlaDocPage-D44QWNY8.js")).then(t=>({default:t.SlaDocPage}))),bl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportIndexPage-CsDQ35Cu.js")).then(t=>({default:t.SupportIndexPage}))),vl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportDashboardDocPage-DfV-9_8r.js")).then(t=>({default:t.SupportDashboardDocPage}))),yl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportTicketsDocPage-B_603CpY.js")).then(t=>({default:t.SupportTicketsDocPage}))),jl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportMyTicketsDocPage-Dbp6XBnH.js")).then(t=>({default:t.SupportMyTicketsDocPage}))),Nl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportTemplatesDocPage-BkeDpR-8.js")).then(t=>({default:t.SupportTemplatesDocPage}))),wl=n.lazy(()=>Promise.resolve().then(()=>require("./SupportEscalationDocPage-C65oCDZL.js")).then(t=>({default:t.SupportEscalationDocPage}))),Sl=n.lazy(()=>Promise.resolve().then(()=>require("./AiDocPage-CM7j_50_.js")).then(t=>({default:t.AiDocPage}))),Cl=n.lazy(()=>Promise.resolve().then(()=>require("./SettingsDocPage-Dqj8KzOa.js")).then(t=>({default:t.SettingsDocPage}))),kl=n.lazy(()=>Promise.resolve().then(()=>require("./ThemeDocPage-B6x55uSE.js")).then(t=>({default:t.ThemeDocPage}))),Al=n.lazy(()=>Promise.resolve().then(()=>require("./BaIndexPage-Df6ld4jp.js")).then(t=>({default:t.BaIndexPage}))),Vs=n.lazy(()=>Promise.resolve().then(()=>require("./BaViewerPage-CX3yS6tI.js")).then(t=>({default:t.BaViewerPage}))),Pl=n.lazy(()=>Promise.resolve().then(()=>require("./index-CO5QP9C1.js"))),Tl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BASU1QDx.js"))),Rl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DYJbiXHU.js"))),El=n.lazy(()=>Promise.resolve().then(()=>require("./index-BBQMnq4P.js"))),Il=n.lazy(()=>Promise.resolve().then(()=>require("./index-Bz8ggekC.js"))),Ll=n.lazy(()=>Promise.resolve().then(()=>require("./index-D1WPBG1_.js"))),$l=n.lazy(()=>Promise.resolve().then(()=>require("./index-DIuoVYFu.js"))),Dl=n.lazy(()=>Promise.resolve().then(()=>require("./index-Cdu0fSs8.js"))),Ml=n.lazy(()=>Promise.resolve().then(()=>require("./index-BVUCDL0k.js"))),Ol=n.lazy(()=>Promise.resolve().then(()=>require("./index-DRT2wvEs.js"))),Fl=n.lazy(()=>Promise.resolve().then(()=>require("./index-xCGnOlox.js"))),_l=n.lazy(()=>Promise.resolve().then(()=>require("./index-DQBVnnd6.js"))),ql=n.lazy(()=>Promise.resolve().then(()=>require("./index-C0rFTzxZ.js"))),Ul=n.lazy(()=>Promise.resolve().then(()=>require("./index-HWG-CG1i.js"))),zl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DlX3cwCY.js"))),Bl=n.lazy(()=>Promise.resolve().then(()=>require("./index-IuHTxwV6.js"))),Gl=n.lazy(()=>Promise.resolve().then(()=>require("./index-DiazxhY7.js"))),Kl=n.lazy(()=>Promise.resolve().then(()=>require("./index-i8XTb32s.js"))),Hl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BHim8lfc.js"))),Vl=n.lazy(()=>Promise.resolve().then(()=>require("./index-BEpBEF5G.js"))),Wl=n.lazy(()=>Promise.resolve().then(()=>require("./index-p2jNjCTo.js")));function Xl(){return e.jsxs(e.Fragment,{children:[e.jsxs(w.Route,{path:"/system/docs",element:e.jsx(Hs,{}),children:[e.jsx(w.Route,{index:!0,element:e.jsx(tl,{})}),e.jsx(w.Route,{path:"developer",element:e.jsx(rl,{})}),e.jsx(w.Route,{path:"developer/infrastructure",element:e.jsx(al,{})}),e.jsx(w.Route,{path:"developer/installation",element:e.jsx(nl,{})}),e.jsx(w.Route,{path:"developer/database",element:e.jsx(ol,{})}),e.jsx(w.Route,{path:"developer/dual-dbcontext",element:e.jsx(il,{})}),e.jsx(w.Route,{path:"developer/cross-schema-fk",element:e.jsx(ll,{})}),e.jsx(w.Route,{path:"developer/tenants",element:e.jsx(cl,{})}),e.jsx(w.Route,{path:"developer/tenants/multi-tenant-mode",element:e.jsx(dl,{})}),e.jsx(w.Route,{path:"developer/tenants/b2c",element:e.jsx(ul,{})}),e.jsx(w.Route,{path:"developer/multi-tenant-mode",element:e.jsx(w.Navigate,{to:"/system/docs/developer/tenants/multi-tenant-mode",replace:!0})}),e.jsx(w.Route,{path:"developer/teams-integration",element:e.jsx(ml,{})}),e.jsx(w.Route,{path:"developer/testing/security",element:e.jsx(pl,{})}),e.jsx(w.Route,{path:"user",element:e.jsx(xl,{})}),e.jsx(w.Route,{path:"user/architecture",element:e.jsx(hl,{})}),e.jsx(w.Route,{path:"user/modules",element:e.jsx(gl,{})}),e.jsx(w.Route,{path:"user/support",element:e.jsx(bl,{})}),e.jsx(w.Route,{path:"user/support-dashboard",element:e.jsx(vl,{})}),e.jsx(w.Route,{path:"user/support-tickets",element:e.jsx(yl,{})}),e.jsx(w.Route,{path:"user/support-my-tickets",element:e.jsx(jl,{})}),e.jsx(w.Route,{path:"user/support-sla",element:e.jsx(fl,{})}),e.jsx(w.Route,{path:"user/support-templates",element:e.jsx(Nl,{})}),e.jsx(w.Route,{path:"user/support-escalation",element:e.jsx(wl,{})}),e.jsx(w.Route,{path:"user/ai",element:e.jsx(Sl,{})}),e.jsx(w.Route,{path:"user/settings",element:e.jsx(Cl,{})}),e.jsx(w.Route,{path:"user/theme",element:e.jsx(kl,{})}),e.jsx(w.Route,{path:"ba",element:e.jsx(Al,{})}),e.jsx(w.Route,{path:"ba/:appCode",element:e.jsx(Vs,{})}),e.jsx(w.Route,{path:"ba/:appCode/:moduleCode",element:e.jsx(Vs,{})})]}),e.jsxs(w.Route,{path:"/docs/business",element:e.jsx(Hs,{}),children:[e.jsx(w.Route,{path:"administration/users",element:e.jsx(Pl,{})}),e.jsx(w.Route,{path:"administration/users/dashboard",element:e.jsx(Tl,{})}),e.jsx(w.Route,{path:"administration/users/references",element:e.jsx(Rl,{})}),e.jsx(w.Route,{path:"administration/users/groups",element:e.jsx(El,{})}),e.jsx(w.Route,{path:"administration/permissions",element:e.jsx(Il,{})}),e.jsx(w.Route,{path:"administration/permissions/assignments",element:e.jsx(Ll,{})}),e.jsx(w.Route,{path:"administration/tenants",element:e.jsx($l,{})}),e.jsx(w.Route,{path:"administration/tenants/template",element:e.jsx(Dl,{})}),e.jsx(w.Route,{path:"administration/tenants/business",element:e.jsx(Ml,{})}),e.jsx(w.Route,{path:"administration/tenants/personal",element:e.jsx(Ol,{})}),e.jsx(w.Route,{path:"administration/tenants/other",element:e.jsx(Fl,{})}),e.jsx(w.Route,{path:"administration/tenants/applications",element:e.jsx(_l,{})}),e.jsx(w.Route,{path:"administration/tenants/access-requests",element:e.jsx(ql,{})}),e.jsx(w.Route,{path:"administration/tenants/organisations",element:e.jsx(Ul,{})}),e.jsx(w.Route,{path:"administration/ai",element:e.jsx(zl,{})}),e.jsx(w.Route,{path:"administration/workflows",element:e.jsx(Bl,{})}),e.jsx(w.Route,{path:"administration/entra",element:e.jsx(Gl,{})}),e.jsx(w.Route,{path:"administration/applications",element:e.jsx(Kl,{})}),e.jsx(w.Route,{path:"administration/configuration",element:e.jsx(Hl,{})}),e.jsx(w.Route,{path:"administration/configuration/license",element:e.jsx(Vl,{})}),e.jsx(w.Route,{path:"platform/support/tickets",element:e.jsx(Wl,{})})]}),e.jsx(w.Route,{path:"/system/docs/presentation",element:e.jsx(sl,{})}),e.jsx(w.Route,{path:"/docs/*",element:e.jsx(w.Navigate,{to:"/system/docs",replace:!0})}),e.jsx(w.Route,{path:"/docs",element:e.jsx(w.Navigate,{to:"/system/docs",replace:!0})})]})}const Yl={"administration.configuration.settings":{defaultTab:"general",tabs:["general","file-upload","legal-file"]},"administration.configuration.appsettings":{defaultTab:"infrastructure",tabs:["infrastructure","authentication","logging","email","entra"]}},Jl=[{icon:l.Users,title:"Gestion des Utilisateurs",description:"Créez, modifiez et gérez vos utilisateurs avec une interface intuitive. Profils complets, avatars et informations personnalisables.",color:"from-blue-500 to-cyan-500"},{icon:l.Bell,title:"Gestion des Notifications",description:"Système de notifications en temps réel. Email, push, in-app. Templates personnalisables et historique complet.",color:"from-amber-500 to-orange-500"},{icon:l.HeadphonesIcon,title:"Gestion du Support",description:"Système de tickets intégré pour le support client. Suivi, priorités, assignation et statistiques.",color:"from-emerald-500 to-teal-500"},{icon:l.Shield,title:"Panneau Administrateur",description:"Dashboard complet pour administrer votre plateforme. Métriques, logs, configuration et monitoring.",color:"from-purple-500 to-pink-500"},{icon:l.Key,title:"Gestion des Rôles",description:"RBAC avancé avec permissions granulaires. Hiérarchie de rôles, wildcards et héritage des droits.",color:"from-red-500 to-rose-500"},{icon:l.Layers,title:"Architecture Modulaire",description:"Structure en 5 niveaux : Contexte, Application, Module, Section, Resource. Extensible et maintenable.",color:"from-indigo-500 to-violet-500"}],Ql=[{icon:l.Zap,text:"Démarrage rapide"},{icon:l.Lock,text:"Sécurité intégrée"},{icon:l.Rocket,text:"Performance optimale"}],Zl=[".NET 10","React 19","TypeScript","EF Core","SQL Server","Tailwind CSS"];function ec(){return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("section",{className:"relative pt-32 pb-20 md:pt-40 md:pb-32 overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 rounded-full bg-primary-500/10 blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 rounded-full bg-accent-500/10 blur-3xl"}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px] rounded-full bg-gradient-to-r from-primary-500/5 to-accent-500/5 blur-3xl"})]}),e.jsx("div",{className:"relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-primary-500/10 border border-primary-500/20 mb-8",children:[e.jsx(l.Zap,{className:"w-4 h-4 text-primary-500"}),e.jsx("span",{className:"text-sm font-medium text-primary-500",children:"Version 1.0 disponible"})]}),e.jsxs("h1",{className:"text-4xl sm:text-5xl md:text-6xl lg:text-7xl font-bold tracking-tight mb-6",children:["Le socle moderne pour",e.jsx("br",{}),e.jsx("span",{className:"gradient-text",children:"vos applications"})]}),e.jsx("p",{className:"max-w-2xl mx-auto text-lg md:text-xl text-[var(--text-secondary)] mb-10",children:"SmartStack est une plateforme complète pour créer des applications d'entreprise. Authentification, rôles, notifications et support intégrés."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4 mb-16",children:[e.jsxs("a",{href:"/register",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40",children:["Commencer gratuitement",e.jsx(l.ArrowRight,{className:"w-5 h-5"})]}),e.jsx("a",{href:"#features",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-semibold transition-all",children:"Découvrir les fonctionnalités"})]}),e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-6",children:Ql.map(t=>e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[e.jsx(t.icon,{className:"w-5 h-5 text-primary-500"}),e.jsx("span",{children:t.text})]},t.text))})]})})]}),e.jsx("section",{className:"py-8 bg-[var(--bg-secondary)] border-y border-[var(--border-color)]",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-8 md:gap-12",children:[e.jsx("span",{className:"text-[var(--text-tertiary)] text-sm uppercase tracking-wider",children:"Construit avec"}),Zl.map(t=>e.jsx("span",{className:"text-[var(--text-secondary)] font-medium",children:t},t))]})})}),e.jsx("section",{id:"features",className:"py-20 md:py-32",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Tout ce dont vous avez besoin"}),e.jsx("p",{className:"max-w-2xl mx-auto text-[var(--text-secondary)]",children:"SmartStack inclut toutes les fonctionnalités essentielles pour démarrer votre projet d'entreprise."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Jl.map(t=>e.jsxs("div",{className:"group p-6 rounded-2xl bg-[var(--bg-card)] border border-[var(--border-color)] hover-card",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl bg-gradient-to-br ${t.color} flex items-center justify-center mb-4`,children:e.jsx(t.icon,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:t.title}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:t.description})]},t.title))})]})}),e.jsx("section",{id:"modules",className:"py-20 md:py-32 bg-[var(--bg-secondary)]",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-6",children:["Architecture modulaire",e.jsx("br",{}),e.jsx("span",{className:"gradient-text",children:"prête pour la production"})]}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-8",children:"SmartStack utilise une architecture en 5 niveaux qui permet une organisation claire et une extensibilité maximale. Chaque niveau correspond à un scope de permissions."}),e.jsx("ul",{className:"space-y-4 mb-8",children:["Contexte - Environnements séparés (Platform, Business, Personal)","Application - Apps au sein d'un contexte (Admin, MySpace)","Module - Fonctionnalités (Users, Roles, Profile)","Section - Sous-divisions des modules","Resource - Éléments individuels"].map(t=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-primary-500/10 flex items-center justify-center mt-0.5",children:e.jsx(l.Check,{className:"w-4 h-4 text-primary-500"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t})]},t))})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-primary-500/20 to-accent-500/20 rounded-3xl blur-2xl"}),e.jsx("div",{className:"relative p-8 rounded-3xl bg-[var(--bg-card)] border border-[var(--border-color)]",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-r from-primary-500/10 to-primary-500/5 border border-primary-500/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-primary-500"}),e.jsx("span",{className:"font-semibold text-primary-500",children:"Contexte: Platform"})]}),e.jsxs("div",{className:"ml-4 mt-3 p-3 rounded-lg bg-accent-500/10 border border-accent-500/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-500"}),e.jsx("span",{className:"font-medium text-accent-500",children:"Application: Admin"})]}),e.jsxs("div",{className:"ml-4 mt-2 space-y-2",children:[e.jsx("div",{className:"p-2 rounded bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Users,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:"Module: Users"})]})}),e.jsx("div",{className:"p-2 rounded bg-[var(--bg-tertiary)] border border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Key,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:"Module: Roles"})]})})]})]})]})})})]})]})})}),e.jsx("section",{id:"contact",className:"py-20 md:py-32",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsx("div",{className:"relative overflow-hidden rounded-3xl animated-gradient p-px",children:e.jsxs("div",{className:"relative rounded-3xl bg-[var(--bg-primary)] p-8 md:p-16 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Prêt à commencer ?"}),e.jsx("p",{className:"max-w-2xl mx-auto text-[var(--text-secondary)] mb-8",children:"Lancez votre projet d'entreprise avec SmartStack. Tout est déjà configuré pour vous permettre de vous concentrer sur votre métier."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"/register",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-primary-600 hover:bg-primary-700 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40",children:["Créer un compte",e.jsx(l.ArrowRight,{className:"w-5 h-5"})]}),e.jsx("a",{href:"/contact",className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-semibold transition-all",children:"Nous contacter"})]})]})})})})]})}const tc=(t,s)=>{const r=s.exec(t);return r?r[1]:""},sc=[{detect:t=>t.includes("edg/")||t.includes("edge/"),name:"Edge",pattern:/Edg(?:e)?\/(\d+)/i},{detect:t=>t.includes("opr/")||t.includes("opera"),name:"Opera",pattern:/(?:OPR|Opera)\/(\d+)/i},{detect:t=>t.includes("chrome")&&!t.includes("edg"),name:"Chrome",pattern:/Chrome\/(\d+)/i},{detect:t=>t.includes("safari")&&!t.includes("chrome"),name:"Safari",pattern:/Version\/(\d+)/i},{detect:t=>t.includes("firefox"),name:"Firefox",pattern:/Firefox\/(\d+)/i},{detect:t=>t.includes("msie")||t.includes("trident"),name:"Internet Explorer",pattern:/(?:MSIE |rv:)(\d+)/i}],rc=(t,s)=>{const r=sc.find(a=>a.detect(t));return r?{browser:r.name,version:tc(s,r.pattern)}:{browser:"Unknown",version:""}},ac={"windows nt 10":"10/11","windows nt 6.3":"8.1","windows nt 6.2":"8","windows nt 6.1":"7"},nc=t=>{for(const[s,r]of Object.entries(ac))if(t.includes(s))return r;return""},oc=[{detect:t=>t.includes("windows nt"),name:"Windows",getVersion:t=>nc(t)},{detect:t=>t.includes("windows"),name:"Windows",getVersion:()=>""},{detect:t=>t.includes("iphone"),name:"iOS",getVersion:(t,s)=>{const r=/OS (\d+)_/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("ipad"),name:"iPadOS",getVersion:(t,s)=>{const r=/OS (\d+)_/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("mac os x"),name:"macOS",getVersion:(t,s)=>{const r=/Mac OS X (\d+)[._](\d+)/i.exec(s);return r?`${r[1]}.${r[2]}`:""}},{detect:t=>t.includes("android"),name:"Android",getVersion:(t,s)=>{const r=/Android (\d+)/i.exec(s);return r?r[1]:""}},{detect:t=>t.includes("linux"),name:"Linux",getVersion:()=>""},{detect:t=>t.includes("cros"),name:"Chrome OS",getVersion:()=>""}],ic=(t,s)=>{const r=oc.find(a=>a.detect(t));if(r){const a=r.getVersion(t,s);return{os:r.name,version:a}}return{os:"Unknown",version:""}},lc=t=>/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk)/i.test(t)?"Tablet":/(android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile|phone)/i.test(t)?"Mobile":"Desktop";function cc(t){if(!t)return{browser:"Unknown",browserVersion:"",os:"Unknown",osVersion:"",device:"Unknown",formatted:"Unknown"};const s=t.toLowerCase(),{browser:r,version:a}=rc(s,t),{os:o,version:c}=ic(s,t),i=lc(s);let d=r;if(o!=="Unknown"){const u=a?a+" ":"",m=c?" "+c:"";d=`${r} ${u}sur ${o}${m}`}return{browser:r,browserVersion:a,os:o,osVersion:c,device:i,formatted:d}}function ka(){const t=navigator.userAgent.toLowerCase();return/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(t)?"tablet":/(android|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile|phone)/.test(t)?"mobile":/(windows|macintosh|linux|x11)/.test(t)?"desktop":"unknown"}async function Aa(){try{const t=await fetch("https://api.ipify.org?format=json",{method:"GET",signal:AbortSignal.timeout(5e3)});return t.ok&&(await t.json()).ip||null}catch{return null}}function dc(){const[t,s]=n.useState(""),[r,a]=n.useState(""),[o,c]=n.useState(!1),[i,d]=n.useState(!1),[u,m]=n.useState("auth"),[p,f]=n.useState(null),[h]=n.useState(()=>{const g=new URLSearchParams(window.location.search).get("redirect_uri");return g?(sessionStorage.setItem("sso_redirect_uri",g),g):sessionStorage.getItem("sso_redirect_uri")}),b=n.useCallback(async g=>{g.preventDefault(),f(null),m("auth"),d(!0);try{Te.logEvent("login_attempt","auth",{email:t});const y=ka(),x=await Aa(),j=await E.post("/api/auth/login",{email:t,password:r,deviceType:y,clientIp:x});localStorage.setItem("token",j.token),localStorage.setItem("refreshToken",j.refreshToken),localStorage.setItem("user",JSON.stringify(j.user)),Te.logEvent("login_success","auth",{email:t}),m("prefs");try{if(!(await E.get("/api/onboarding/status")).hasCompletedOnboarding){window.location.href="/auth/onboarding";return}}catch{}try{const v=await _t.preferences.get(),S={mode:v.theme||"dark",accentColorKey:v.accentColorKey||"indigo",borderRadius:v.borderRadius||{},itemPaletteKey:v.itemPaletteKey||"neutral"};localStorage.setItem("smartstack-theme-config",JSON.stringify(S)),v.language&&localStorage.setItem("i18nextLng",v.language)}catch{}if(localStorage.removeItem("currentTenantId"),localStorage.removeItem("currentTenantSlug"),localStorage.removeItem("isGlobalView"),h){sessionStorage.removeItem("sso_redirect_uri");const v=h.includes("?")?"&":"?";window.location.href=`${h}${v}token=${encodeURIComponent(j.token)}&refreshToken=${encodeURIComponent(j.refreshToken)}`;return}window.location.href="/myspace"}catch(y){if(y instanceof ps)f({message:y.message,code:"NETWORK_ERROR"});else if(y instanceof gr)f({message:y.message,code:y.code});else{const x=y instanceof Error?y.message:"Une erreur inattendue est survenue";f({message:x})}Te.logError(y instanceof Error?y:new Error(String(y)),"LoginPage.handleSubmit",{email:t})}finally{d(!1)}},[t,r,h]);return{email:t,setEmail:s,password:r,setPassword:a,showPassword:o,setShowPassword:c,isLoading:i,loadingStep:u,error:p,handleSubmit:b}}const uc=[{icon:l.Shield,title:"Sécurité avancée",description:"Authentification multi-facteurs et contrôle d'accès granulaire"},{icon:l.Zap,title:"Performance optimale",description:"Interface rapide et réactive pour une productivité maximale"},{icon:l.Users,title:"Collaboration",description:"Gestion des équipes et permissions centralisée"},{icon:l.BarChart3,title:"Analytics",description:"Tableaux de bord et rapports en temps réel"}],mc=t=>{switch(t){case"ACCOUNT_DISABLED":return e.jsx(l.UserX,{className:"w-5 h-5 flex-shrink-0"});case"ACCOUNT_LOCKED":return e.jsx(l.Clock,{className:"w-5 h-5 flex-shrink-0"});case"EXTERNAL_AUTH_REQUIRED":return e.jsx(l.KeyRound,{className:"w-5 h-5 flex-shrink-0"});case"NETWORK_ERROR":return e.jsx(l.WifiOff,{className:"w-5 h-5 flex-shrink-0"});default:return e.jsx(l.AlertCircle,{className:"w-5 h-5 flex-shrink-0"})}},pc=t=>{switch(t){case"ACCOUNT_DISABLED":return"bg-orange-500/10 border-orange-500/20 text-orange-600 dark:text-orange-400";case"ACCOUNT_LOCKED":return"bg-amber-500/10 border-amber-500/20 text-amber-600 dark:text-amber-400";case"EXTERNAL_AUTH_REQUIRED":return"bg-blue-500/10 border-blue-500/20 text-blue-600 dark:text-blue-400";case"NETWORK_ERROR":return"bg-gray-500/10 border-gray-500/20 text-gray-600 dark:text-gray-400";default:return"bg-red-500/10 border-red-500/20 text-red-500"}};function xc(){const{email:t,setEmail:s,password:r,setPassword:a,showPassword:o,setShowPassword:c,isLoading:i,loadingStep:d,error:u,handleSubmit:m}=dc();return e.jsxs("div",{className:"min-h-screen flex",children:[e.jsxs("div",{className:"hidden lg:flex lg:w-1/2 xl:w-[55%] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 animated-gradient"}),e.jsx("div",{className:"absolute inset-0 opacity-10",style:{backgroundImage:"radial-gradient(circle at 1px 1px, white 1px, transparent 0)",backgroundSize:"40px 40px"}}),e.jsx("div",{className:"absolute top-20 left-20 w-72 h-72 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-20 right-20 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/3 w-64 h-64 bg-white/5 rounded-full blur-2xl animate-pulse",style:{animationDelay:"2s"}}),e.jsxs("div",{className:"relative z-10 flex flex-col justify-between p-12 xl:p-16 text-white w-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-sm rounded-xl flex items-center justify-center",children:e.jsx(l.Layers,{className:"w-7 h-7 text-white"})}),e.jsx("span",{className:"text-2xl font-bold",children:"SmartStack"})]}),e.jsxs("div",{className:"max-w-lg",children:[e.jsx("h1",{className:"text-4xl xl:text-5xl font-bold leading-tight mb-6",children:"Votre plateforme de gestion unifiée"}),e.jsx("p",{className:"text-xl text-white/80 mb-12",children:"Simplifiez vos processus, centralisez vos données et boostez la productivité de votre équipe."}),e.jsx("div",{className:"grid grid-cols-2 gap-6",children:uc.map(p=>e.jsxs("div",{className:"bg-white/10 backdrop-blur-sm rounded-2xl p-5 hover:bg-white/15 transition-colors",children:[e.jsx(p.icon,{className:"w-8 h-8 mb-3 text-white/90"}),e.jsx("h3",{className:"font-semibold mb-1",children:p.title}),e.jsx("p",{className:"text-sm text-white/70",children:p.description})]},p.title))})]}),e.jsxs("p",{className:"text-sm text-white/60",children:["© ",new Date().getFullYear()," SmartStack — Plateforme de gestion unifiée"]})]})]}),e.jsxs("div",{className:"w-full lg:w-1/2 xl:w-[45%] flex flex-col relative bg-[var(--bg-primary)]",children:[e.jsx("div",{className:"lg:hidden absolute inset-0",children:e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-96 h-96 rounded-full bg-primary-500/20 blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-96 h-96 rounded-full bg-accent-500/20 blur-3xl animate-pulse",style:{animationDelay:"1s"}})]})}),e.jsxs("div",{className:"absolute top-6 right-6 z-10 flex items-center gap-2",children:[e.jsx("a",{href:"/",className:"p-2 rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] transition-colors",title:"Retour à l'accueil",children:e.jsx(l.Home,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx(Kt,{})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-6 sm:p-8 lg:p-12",children:e.jsxs("div",{className:"w-full max-w-md relative",children:[e.jsxs("div",{className:"lg:hidden flex flex-col items-center mb-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl animated-gradient flex items-center justify-center mb-4 shadow-lg",children:e.jsx(l.Layers,{className:"w-8 h-8 text-white"})}),e.jsx("h1",{className:"text-2xl font-bold",children:"SmartStack"})]}),e.jsxs("div",{className:"hidden lg:block mb-8",children:[e.jsx("h2",{className:"text-3xl font-bold mb-2",children:"Bienvenue"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"Connectez-vous à votre compte pour continuer"})]}),u&&e.jsxs("div",{className:`mb-6 p-4 rounded-xl border text-sm flex items-start gap-3 ${pc(u.code)}`,children:[mc(u.code),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:u.message}),u.code==="ACCOUNT_DISABLED"&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:"Contactez le support si vous pensez qu'il s'agit d'une erreur."}),u.code==="EXTERNAL_AUTH_REQUIRED"&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:"Utilisez les boutons Microsoft ou Google ci-dessous."})]})]}),e.jsxs("form",{onSubmit:m,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-2",children:"Adresse email"}),e.jsxs("div",{className:"relative",children:[e.jsx(l.Mail,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]"}),e.jsx("input",{id:"email",type:"email",value:t,onChange:p=>s(p.target.value),placeholder:"vous@exemple.com",required:!0,className:"w-full pl-12 pr-4 py-3.5 rounded-xl bg-[var(--bg-tertiary)] border border-[var(--border-color)] focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 outline-none transition-all placeholder:text-[var(--text-tertiary)]"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-2",children:"Mot de passe"}),e.jsxs("div",{className:"relative",children:[e.jsx(l.Lock,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]"}),e.jsx("input",{id:"password",type:o?"text":"password",value:r,onChange:p=>a(p.target.value),placeholder:"••••••••",required:!0,className:"w-full pl-12 pr-12 py-3.5 rounded-xl bg-[var(--bg-tertiary)] border border-[var(--border-color)] focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 outline-none transition-all placeholder:text-[var(--text-tertiary)]"}),e.jsx("button",{type:"button",onClick:()=>c(!o),className:"absolute right-4 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",children:o?e.jsx(l.EyeOff,{className:"w-5 h-5"}):e.jsx(l.Eye,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)] bg-[var(--bg-tertiary)] text-primary-600 focus:ring-primary-500/20"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:"Se souvenir de moi"})]}),e.jsx("a",{href:"/forgot-password",className:"text-primary-500 hover:text-primary-600 font-medium transition-colors",children:"Mot de passe oublié ?"})]}),e.jsx("button",{type:"submit",disabled:i,className:"w-full py-3.5 px-4 rounded-xl bg-primary-600 hover:bg-primary-700 disabled:bg-primary-600/50 text-white font-semibold transition-all shadow-lg shadow-primary-500/25 hover:shadow-primary-500/40 disabled:shadow-none flex items-center justify-center gap-2",children:i?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}),d==="auth"?"Connexion en cours...":"Chargement des préférences..."]}):"Se connecter"})]}),e.jsxs("div",{className:"relative my-8",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-[var(--border-color)]"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-4 bg-[var(--bg-primary)] text-[var(--text-tertiary)]",children:"Ou continuer avec"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>window.location.href="/api/auth/microsoft",className:"flex items-center justify-center gap-3 py-3.5 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-medium transition-all",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"1",y:"1",width:"9",height:"9",fill:"#F25022"}),e.jsx("rect",{x:"11",y:"1",width:"9",height:"9",fill:"#7FBA00"}),e.jsx("rect",{x:"1",y:"11",width:"9",height:"9",fill:"#00A4EF"}),e.jsx("rect",{x:"11",y:"11",width:"9",height:"9",fill:"#FFB900"})]}),"Microsoft"]}),e.jsxs("button",{type:"button",onClick:()=>window.location.href="/api/auth/google",className:"flex items-center justify-center gap-3 py-3.5 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] border border-[var(--border-color)] font-medium transition-all",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Google"]})]}),e.jsxs("p",{className:"text-center text-[var(--text-secondary)] mt-8",children:["Nouveau sur SmartStack ?"," ",e.jsx("a",{href:"/register",className:"text-primary-500 hover:text-primary-600 font-semibold transition-colors",children:"Créer un compte"})]})]})}),e.jsx("div",{className:"p-6 text-center",children:e.jsxs("p",{className:"text-sm text-[var(--text-tertiary)]",children:["© ",new Date().getFullYear()," SmartStack. Tous droits réservés."]})})]})]})}function hc(){const{t}=ne.useTranslation("common"),s=w.useNavigate(),r=()=>{window.history.length>2?s(-1):s("/")};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[var(--bg-primary)] p-4",children:e.jsx("div",{className:"max-w-md w-full p-8 bg-[var(--bg-card)] border border-[var(--border-color)] rounded-2xl shadow-xl",children:e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-yellow-500/10 flex items-center justify-center mb-6",children:e.jsx(l.FileWarning,{className:"w-8 h-8 text-yellow-500"})}),e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:t("errors.notFound.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("errors.notFound.description")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mb-6 font-mono",children:window.location.pathname}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 w-full",children:[e.jsxs("button",{onClick:r,className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-all",children:[e.jsx(l.ArrowLeft,{className:"w-4 h-4"}),t("errors.goBack")]}),e.jsxs("a",{href:"/",className:"flex-1 flex items-center justify-center gap-2 py-3 px-4 rounded-xl bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] text-[var(--text-primary)] font-medium transition-all",children:[e.jsx(l.Home,{className:"w-4 h-4"}),t("errors.home")]})]})]})})})}const gc=n.lazy(()=>Promise.resolve().then(()=>require("./ApplicationsPage-6zgFye6w.js")).then(t=>({default:t.ApplicationsPage}))),fc=n.lazy(()=>Promise.resolve().then(()=>require("./NotificationsPage-DxwizUhL.js")).then(t=>({default:t.NotificationsPage}))),bc=n.lazy(()=>Promise.resolve().then(()=>hi).then(t=>({default:t.PublicLayout}))),Zt=n.lazy(()=>Promise.resolve().then(()=>ci).then(t=>({default:t.AppLayout}))),vc=n.lazy(()=>Promise.resolve().then(()=>require("./RegisterPage-C4xmVwh9.js")).then(t=>({default:t.RegisterPage}))),yc=n.lazy(()=>Promise.resolve().then(()=>require("./ConfirmEmailPage-BqsILAYH.js")).then(t=>({default:t.ConfirmEmailPage}))),jc=n.lazy(()=>Promise.resolve().then(()=>require("./ForgotPasswordPage-CSq4DnFF.js")).then(t=>({default:t.ForgotPasswordPage}))),Nc=n.lazy(()=>Promise.resolve().then(()=>require("./ResetPasswordPage-Glu-aeqv.js")).then(t=>({default:t.ResetPasswordPage}))),wc=n.lazy(()=>Promise.resolve().then(()=>require("./ForceChangePasswordPage-BE-6umub.js")).then(t=>({default:t.ForceChangePasswordPage}))),Sc=n.lazy(()=>Promise.resolve().then(()=>require("./AuthCallbackPage-CA2nO6DG.js")).then(t=>({default:t.AuthCallbackPage}))),Cc=n.lazy(()=>Promise.resolve().then(()=>require("./OnboardingWizardPage-C6HlbJ3K.js")).then(t=>({default:t.OnboardingWizardPage}))),kc={".detail":"/:id",".edit":"/:id/edit",".create":"/create",".new":"/new",".duplicate":"/:id/duplicate",".settings":"/:id/settings",".configure":"/:id/configure",".permissions":"/:id/permissions",".members":"/:id/members",".history":"/:id/history",".logs":"/:id/logs",".analytics":"/:id/analytics",".preview":"/:id/preview",".versions":"/:id/versions",".comments":"/:id/comments",".attachments":"/:id/attachments",".audit":"/:id/audit",".export":"/:id/export",".notifications":"/:id/notifications",".schedule":"/:id/schedule",".workflow":"/:id/workflow",".summary":"/:id/summary",".test":"/:id/test",".runs":"/:id/runs",".import":"/import"};function Ss(t,s){const r=[];for(const[a,o]of Object.entries(kc)){const c=`${t}${a}`,i=O.resolve(c);if(i){const d=s.replace(/^\//,"")+o;r.push({path:d,Component:i})}}return r}function Ac(t,s,r,a){const o=[],c=r.route?.replace(`/${a}/`,"")||`${t.code}/${s.code}/${r.code}`,i=O.resolve(r.componentKey);if(i){const d=i;o.push(e.jsx(w.Route,{path:c,element:e.jsx(d,{})},r.componentKey))}if(r.route)for(const d of Ss(r.componentKey,c)){const u=d.Component;o.push(e.jsx(w.Route,{path:d.path,element:e.jsx(u,{})},`${r.componentKey}-implicit-${d.path}`))}return o}function Pc(t,s,r){const a=[],o=s.route?.replace(`/${r}/`,"")||`${t.code}/${s.code}`,c=Yl[s.componentKey];if(c){const d=O.resolve(s.componentKey);if(d){const u=c.tabs.map(m=>{const p=`${s.componentKey}.${m}`,f=O.resolve(p);return f?e.jsx(w.Route,{path:m,element:e.jsx(f,{})},p):null}).filter(Boolean);return a.push(e.jsxs(w.Route,{path:o,element:e.jsx(d,{}),children:[e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:c.defaultTab,replace:!0})}),u]},s.componentKey)),a}}const i=O.resolve(s.componentKey);if(i){const d=i;a.push(e.jsx(w.Route,{path:o,element:e.jsx(d,{})},s.componentKey))}if(!i&&s.resources.length>0){const d=s.resources[0];a.push(e.jsx(w.Route,{path:o,element:e.jsx(w.Navigate,{to:d.code,replace:!0})},`${s.componentKey}-redirect`))}if(s.route)for(const d of Ss(s.componentKey,o)){const u=d.Component;a.push(e.jsx(w.Route,{path:d.path,element:e.jsx(u,{})},`${s.componentKey}-implicit-${d.path}`))}for(const d of s.resources){const u=Ac(t,s,d,r);a.push(...u)}return a}function Tc(t,s){const r=[],a=t.route?.replace(`/${s}/`,"")||t.code,o=O.resolve(t.componentKey);if(o){const c=o;r.push(e.jsx(w.Route,{path:a,element:e.jsx(c,{})},t.componentKey))}if(!o&&t.sections.length>0){const c=t.sections[0];r.push(e.jsx(w.Route,{path:a,element:e.jsx(w.Navigate,{to:c.code,replace:!0})},`${t.componentKey}-redirect`))}if(t.route)for(const c of Ss(t.componentKey,a)){const i=c.Component;r.push(e.jsx(w.Route,{path:c.path,element:e.jsx(i,{})},`${t.componentKey}-implicit-${c.path}`))}for(const c of t.sections){const i=Pc(t,c,s);r.push(...i)}return r}function Rc(t){const s=[],r=O.resolve(t.componentKey);if(r){const a=r;s.push(e.jsx(w.Route,{index:!0,element:e.jsx(a,{})},`${t.code}-index`))}else if(t.modules.length>0){const a=t.modules[0],o=a.route?.replace(/^\//,"").replace(new RegExp(`^${t.code}/?`),"")||a.code;s.push(e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:o,replace:!0})},`${t.code}-index`))}for(const a of t.modules){const o=Tc(a,t.code);a.requiredFeature?s.push(e.jsx(w.Route,{element:e.jsx(ws,{feature:a.requiredFeature}),children:o},`feature-${a.componentKey}`)):s.push(...o)}return s}function Ec(t,s){return t.requiredFeature?[e.jsx(w.Route,{element:e.jsx(ws,{feature:t.requiredFeature}),children:s},`feature-${t.code}`)]:s}function Ic(t){switch(t){case"administration":return[e.jsx(w.Route,{path:"settings",element:e.jsx(w.Navigate,{to:"../configuration/settings",relative:"path",replace:!0})},"legacy-settings"),e.jsx(w.Route,{path:"settings/*",element:e.jsx(Oe,{to:"/administration/configuration/settings"})},"legacy-settings-wc"),e.jsx(w.Route,{path:"appsettings",element:e.jsx(w.Navigate,{to:"../configuration/appsettings",relative:"path",replace:!0})},"legacy-appsettings"),e.jsx(w.Route,{path:"appsettings/*",element:e.jsx(Oe,{to:"/administration/configuration/appsettings"})},"legacy-appsettings-wc"),e.jsx(w.Route,{path:"email-templates",element:e.jsx(w.Navigate,{to:"../workflows/email-templates",relative:"path",replace:!0})},"legacy-email-templates"),e.jsx(w.Route,{path:"email-templates/list",element:e.jsx(w.Navigate,{to:"../../workflows/email-templates",relative:"path",replace:!0})},"legacy-email-templates-list"),e.jsx(w.Route,{path:"email-templates/create",element:e.jsx(w.Navigate,{to:"../../workflows/email-templates/create",relative:"path",replace:!0})},"legacy-email-templates-create"),e.jsx(w.Route,{path:"workflows/templates",element:e.jsx(w.Navigate,{to:"../email-templates",relative:"path",replace:!0})},"legacy-wf-templates"),e.jsx(w.Route,{path:"workflows/templates/*",element:e.jsx(Oe,{to:"/administration/workflows/email-templates"})},"legacy-wf-templates-wc"),e.jsx(w.Route,{path:"tenants/business",element:e.jsx(w.Navigate,{to:"../tenants/list/enterprise",replace:!0})},"legacy-tenants-biz"),e.jsx(w.Route,{path:"tenants/personal",element:e.jsx(w.Navigate,{to:"../tenants/list/personal",replace:!0})},"legacy-tenants-perso")];case"support":return[e.jsx(w.Route,{path:"dashboard",element:e.jsx(w.Navigate,{to:"tickets",replace:!0})},"legacy-dashboard"),e.jsx(w.Route,{path:"sla",element:e.jsx(w.Navigate,{to:"admin/sla",replace:!0})},"legacy-sla"),e.jsx(w.Route,{path:"templates",element:e.jsx(w.Navigate,{to:"admin/templates",replace:!0})},"legacy-templates"),e.jsx(w.Route,{path:"admin/escalation",element:e.jsx(w.Navigate,{to:"tickets/escalation",replace:!0})},"legacy-admin-esc")];default:return[]}}function Lc(){const{isLoading:t,menu:s}=Ce(),{currentTenant:r}=Ee(),{user:a}=Pe(),o=w.useLocation();if(t)return e.jsx(wt,{});const c=o.pathname.split("/").filter(Boolean),i=c[0]==="t"?c.slice(2):c,d=i.slice(0,2).join("."),u=r?.slug?`/t/${r.slug}/applications`:"/applications",m=i[0]?.toLowerCase(),f=(m?s?.applications.some(h=>h.code?.toLowerCase()===m)??!1:!1)?"permission":"tenant";return e.jsxs("div",{className:"min-h-screen bg-[var(--bg-primary)]",children:[e.jsx(Nt,{onMenuToggle:()=>{}}),e.jsx("main",{className:"pt-16 transition-all duration-300 h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"p-4 sm:p-6 lg:px-10 h-full overflow-auto",children:e.jsx(ls,{reason:f,tenantName:r?.name,permissionPath:d||void 0,applicationsUrl:u,userRoles:a?.roles,userPermissions:a?.permissions})})})]})}function $c(){const{isLoading:t}=Ce();return!!localStorage.getItem("token")&&t?e.jsx(wt,{}):e.jsx(hc,{})}function Dc(){const{menu:t,isLoading:s}=Ce(),r=n.useMemo(()=>!t||s?[]:t.applications.map(o=>{const c=o.route?.replace(/^\//,"")||o.code,i=Rc(o),d=Ec(o,i),u=Ic(o.code);return e.jsxs(w.Route,{path:c,element:e.jsx(Zt,{}),children:[d,u]},o.code)}),[t,s]),a=e.jsx(e.Fragment,{children:e.jsx(w.Route,{element:e.jsx(Sa,{}),children:e.jsxs(w.Route,{element:e.jsx(Ca,{}),children:[r,e.jsx(w.Route,{path:"applications",element:e.jsx(Zt,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(gc,{})})}),e.jsx(w.Route,{path:"notifications",element:e.jsx(Zt,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(fc,{})})}),e.jsx(w.Route,{path:"administration/external-apps",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"administration/external-apps/*",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"api/external-apps",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"api/external-apps/*",element:e.jsx(Oe,{to:"/api/accounts/list"})}),e.jsx(w.Route,{path:"support-client",element:e.jsx(Oe,{to:"/support/my-tickets"})}),e.jsx(w.Route,{path:"support-client/*",element:e.jsx(Oe,{to:"/support/my-tickets"})}),e.jsx(w.Route,{path:"user",element:e.jsx(Oe,{to:"/myspace"})}),e.jsx(w.Route,{path:"user/*",element:e.jsx(Oe,{to:"/myspace"})}),e.jsx(w.Route,{path:"*",element:e.jsx(Lc,{})})]})})});return e.jsxs(n.Suspense,{fallback:e.jsx(wt,{}),children:[e.jsx(Ji,{}),e.jsx(el,{}),e.jsxs(w.Routes,{children:[e.jsx(w.Route,{path:"/",element:e.jsx(bc,{}),children:e.jsx(w.Route,{index:!0,element:e.jsx(ec,{})})}),Xl(),e.jsx(w.Route,{path:"/login",element:e.jsx(xc,{})}),e.jsx(w.Route,{path:"/register",element:e.jsx(vc,{})}),e.jsx(w.Route,{path:"/confirm-email",element:e.jsx(yc,{})}),e.jsx(w.Route,{path:"/forgot-password",element:e.jsx(jc,{})}),e.jsx(w.Route,{path:"/reset-password",element:e.jsx(Nc,{})}),e.jsx(w.Route,{path:"/force-change-password",element:e.jsx(wc,{})}),e.jsx(w.Route,{path:"/auth/callback",element:e.jsx(Sc,{})}),e.jsx(w.Route,{path:"/auth/onboarding",element:e.jsx(Cc,{})}),e.jsx(w.Route,{path:"/t/:slug",element:e.jsx(Ks,{}),children:a}),e.jsx(w.Route,{element:e.jsx(Ks,{}),children:a}),e.jsx(w.Route,{path:"/admin",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/admin/*",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/administration/*",element:e.jsx(w.Navigate,{to:"/administration",replace:!0})}),e.jsx(w.Route,{path:"/platform/support/*",element:e.jsx(w.Navigate,{to:"/support",replace:!0})}),e.jsx(w.Route,{path:"/dashboard",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal/myspace",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/personal/myspace/*",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/user",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/user/*",element:e.jsx(w.Navigate,{to:"/myspace",replace:!0})}),e.jsx(w.Route,{path:"/business",element:e.jsx(w.Navigate,{to:"/applications",replace:!0})}),e.jsx(w.Route,{path:"/business/support-client/*",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"/support-client/*",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"/support-client",element:e.jsx(w.Navigate,{to:"/support/my-tickets",replace:!0})}),e.jsx(w.Route,{path:"*",element:e.jsx($c,{})})]})]})}function Ws({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Mc(t,s){return t?"bg-[var(--color-accent-100)] border border-[var(--color-accent-500)]":s?"opacity-50 cursor-not-allowed bg-[var(--bg-secondary)]":"bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] border border-transparent hover:border-[var(--border-color)]"}function Pa({isOpen:t,onClose:s}){const{t:r}=ne.useTranslation(["common","navigation"]),{menu:a}=Ce(),{favorites:o,toggleFavorite:c,isFavorite:i,canAddMore:d,maxFavorites:u}=Ke();if(!t)return null;const m=[];a?.applications.forEach(f=>{(f.modules?.length??0)>0&&m.push({app:f,modules:f.modules})});const p=(f,h)=>{const b=[...f.sections||[]].sort((x,j)=>x.displayOrder-j.displayOrder),g=b.length>0&&b[0].route?b[0].route:`/${h.code}/${f.code}`,y={id:f.id,code:f.code,label:f.label,icon:f.icon||"Star",route:g,applicationCode:h.code,applicationLabel:h.label};c(y)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-modal)] shadow-xl w-full max-w-lg max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-5 h-5 text-[var(--color-accent-500)]"}),r("common:favorites.manageTitle")]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r("common:favorites.selectModules",{count:o.length,max:u})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>{const f={component:"FavoritesModal",url:window.location.href},h=`https://github.com/anthropics/claude-code/issues/new?title=${encodeURIComponent("[Bug] Favorites Modal")}&body=${encodeURIComponent(`## Context
30
30
  - Component: ${f.component}
31
31
  - URL: ${f.url}
32
32
 
@@ -43,6 +43,6 @@ ${v.join(`
43
43
  ## Expected Behavior
44
44
 
45
45
  ## Actual Behavior
46
- `)}`;window.open(g,"_blank")},className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors text-[var(--text-secondary)]",title:r("common:buttons.reportBug"),children:e.jsx(l.Bug,{className:"w-5 h-5"})}),e.jsx("button",{onClick:s,className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(l.X,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[m.map(({app:f,modules:g})=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Hs,{name:f.icon||"Folder",className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:f.label})]}),e.jsx("div",{className:"space-y-1 ml-6",children:g.map(b=>{const h=i(b.id),y=!h&&!d;return e.jsxs("button",{onClick:()=>p(b,f),disabled:y,className:`w-full flex items-center gap-3 p-2.5 rounded-[var(--radius-button)] transition-all ${$c(h,y)}`,children:[e.jsx("div",{className:`w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] ${h?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]"}`,children:e.jsx(Hs,{name:b.icon||"Star",className:"w-4 h-4"})}),e.jsx("span",{className:`flex-1 text-left text-sm ${h?"font-medium text-[var(--color-accent-700)]":"text-[var(--text-primary)]"}`,children:b.label}),h&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-600)]"})]},b.id)})})]},f.id)),m.length===0&&e.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:r("common:favorites.noModules")})]}),e.jsx("div",{className:"p-4 border-t border-[var(--border-color)]",children:e.jsx("button",{onClick:s,className:"w-full px-4 py-2 bg-[var(--color-accent-600)] text-white rounded-[var(--radius-button)] hover:bg-[var(--color-accent-700)] transition-colors font-medium",children:r("common:actions.done")})})]})})}function Dc({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Mc({className:t=""}){const{t:s}=ne.useTranslation(["common"]),r=w.useNavigate(),{favorites:a,maxFavorites:o}=Ke(),{triggerExpand:c}=Ke(),{menu:i}=Ce(),[d,u]=n.useState(!1),m=o-a.length,p=g=>{if(i)for(const b of i.applications){const h=b.modules.find(y=>y.id===g.id);if(h?.sections?.length){const y=[...h.sections].sort((x,j)=>x.displayOrder-j.displayOrder)[0];if(y.route)return y.route}}return g.route},f=g=>{const b=p(g);b&&(c(),r(b))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`bg-[var(--bg-card)] border border-[var(--border-color)] rounded-[var(--radius-card)] p-4 ${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:s("common:favorites.quickAccess")})]}),e.jsxs("button",{onClick:()=>u(!0),className:"flex items-center gap-1.5 px-2 py-1 text-xs font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)] rounded-[var(--radius-button)] transition-colors",children:[e.jsx(l.Settings2,{className:"w-3.5 h-3.5"}),s("common:favorites.manage")]})]}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-1",children:[a.map(g=>e.jsxs("button",{onClick:()=>f(g),className:"flex flex-col items-center gap-1.5 min-w-[80px] p-3 bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] rounded-[var(--radius-card)] transition-all group",title:`${g.applicationLabel} - ${g.label}`,children:[e.jsx("div",{className:"w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] bg-[var(--color-accent-100)] text-[var(--color-accent-600)] group-hover:bg-[var(--color-accent-600)] group-hover:text-white transition-colors",children:e.jsx(Dc,{name:g.icon||"Star",className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)] group-hover:text-[var(--text-primary)] truncate max-w-[70px]",children:g.label})]},g.id)),Array.from({length:m}).map((g,b)=>e.jsxs("button",{onClick:()=>u(!0),className:"flex flex-col items-center justify-center gap-1.5 min-w-[80px] p-3 border-2 border-dashed border-[var(--border-color)] hover:border-[var(--color-accent-500)] rounded-[var(--radius-card)] transition-colors group",children:[e.jsx("div",{className:"w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] bg-[var(--bg-tertiary)] text-[var(--text-muted)] group-hover:bg-[var(--color-accent-100)] group-hover:text-[var(--color-accent-600)] transition-colors",children:e.jsx(l.Plus,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs text-[var(--text-muted)] group-hover:text-[var(--text-secondary)]",children:s("common:favorites.add")})]},`empty-slot-${b}`))]})]}),e.jsx(Aa,{isOpen:d,onClose:()=>u(!1)})]})}function Oc({activities:t,loading:s=!1}){return s?e.jsx("div",{className:"animate-pulse space-y-4",children:[1,2,3].map(r=>e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-8 h-8 bg-[var(--bg-secondary)] rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-4 bg-[var(--bg-secondary)] rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-3 bg-[var(--bg-secondary)] rounded w-1/4"})]})]},`skeleton-${r}`))}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(l.RefreshCcw,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"No activity recorded yet"})]}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-0.5 bg-[var(--border-color)]"}),e.jsx("div",{className:"space-y-4",children:t.map((r,a)=>e.jsx(Fc,{activity:r,isLast:a===t.length-1},r.id))})]})}function Fc({activity:t,isLast:s}){const{icon:r,color:a,bgColor:o}=Uc(t.action),c=r;return e.jsxs("div",{className:"relative flex gap-4 pl-0",children:[e.jsx("div",{className:`relative z-10 w-8 h-8 rounded-full flex items-center justify-center ${o}`,children:e.jsx(c,{className:`w-4 h-4 ${a}`})}),e.jsx("div",{className:"flex-1 pb-4 ",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm",children:[t.changedByUserName?e.jsx("span",{className:"font-medium",children:t.changedByUserName}):e.jsx("span",{className:"font-medium text-[var(--text-secondary)]",children:"System"})," ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:Jc(t)})]}),t.fieldChanged&&t.oldValue&&t.newValue&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"px-2 py-0.5 bg-[var(--error-bg)] text-[var(--error-text)] rounded line-through",children:t.oldValue}),e.jsx(l.ArrowRight,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"px-2 py-0.5 bg-[var(--success-bg)] text-[var(--success-text)] rounded",children:t.newValue})]})]}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] whitespace-nowrap",children:Qc(t.createdAt)})]})})]})}const _c={Created:{icon:l.PlusCircle,color:"text-[var(--success-text)]",bgColor:"bg-[var(--success-bg)]"},StatusChanged:{icon:l.RefreshCcw,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},PriorityChanged:{icon:l.AlertTriangle,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},Assigned:{icon:l.UserPlus,color:"text-[var(--accent-text)]",bgColor:"bg-[var(--accent-bg)]"},Commented:{icon:l.MessageSquare,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},AttachmentAdded:{icon:l.Paperclip,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"},Resolved:{icon:l.CheckCircle,color:"text-[var(--success-text)]",bgColor:"bg-[var(--success-bg)]"},Closed:{icon:l.XCircle,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"},Reopened:{icon:l.RefreshCcw,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},SlaBreached:{icon:l.AlertTriangle,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},Escalated:{icon:l.TrendingUp,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},Updated:{icon:l.Edit,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},Deleted:{icon:l.Trash2,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},OnHold:{icon:l.Pause,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},InProgress:{icon:l.Play,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"}},qc={icon:l.RefreshCcw,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"};function Uc(t){return _c[t]||qc}const zc=t=>t.oldValue&&t.newValue?`changed status from ${t.oldValue} to ${t.newValue}`:"changed the status",Bc=t=>t.oldValue&&t.newValue?`changed priority from ${t.oldValue} to ${t.newValue}`:"changed the priority",Gc=t=>t.newValue?`assigned to ${t.newValue}`:"unassigned the ticket",Kc=t=>t.newValue==="internal"?"added an internal note":"added a comment",Hc=t=>t.newValue?`added attachment: ${t.newValue}`:"added an attachment",Vc=t=>t.newValue==="response"?"Response SLA was breached":"Resolution SLA was breached",Wc=t=>t.newValue?`escalated to ${t.newValue}`:"escalated this ticket",Xc=t=>t.fieldChanged?`updated ${t.fieldChanged}`:"updated the ticket",Yc={Created:()=>"created this ticket",StatusChanged:zc,PriorityChanged:Bc,Assigned:Gc,Commented:Kc,AttachmentAdded:Hc,Resolved:()=>"resolved this ticket",Closed:()=>"closed this ticket",Reopened:()=>"reopened this ticket",SlaBreached:Vc,Escalated:Wc,Updated:Xc,OnHold:()=>"put this ticket on hold",InProgress:()=>"started working on this ticket"};function Jc(t){const s=Yc[t.action];return s?s(t):t.action.toLowerCase()}function Qc(t){const s=new Date(t),a=new Date().getTime()-s.getTime(),o=Math.floor(a/6e4),c=Math.floor(o/60),i=Math.floor(c/24);return o<1?"Just now":o<60?`${o}m ago`:c<24?`${c}h ago`:i<7?`${i}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Zc({responseDueAt:t,resolutionDueAt:s,responseBreached:r,resolutionBreached:a,firstResponseAt:o,isPaused:c,responseSlaPercentage:i=0,resolutionSlaPercentage:d=0,showDetails:u=!1}){const m=new Date,p=new Date(t),f=new Date(s),g=p.getTime()-m.getTime(),b=f.getTime()-m.getTime(),h=!!o;let y="ok",x="green",j=l.CheckCircle;c?(y="paused",x="gray",j=l.Pause):r||a?(y="breached",x="red",j=l.XCircle):(!h&&g<1800*1e3||b<3600*1e3)&&(y="warning",x="yellow",j=l.AlertTriangle);const v={green:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",yellow:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",red:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",gray:"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]"};return u?e.jsxs("div",{className:`p-3 rounded-lg border ${v[x]}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(j,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[y==="paused"&&"SLA Paused",y==="breached"&&"SLA Breached",y==="warning"&&"SLA Warning",y==="ok"&&"Within SLA"]})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"opacity-80",children:"Response"}),r&&e.jsx("span",{className:"text-[var(--error-text)] font-medium",children:"Breached"}),!r&&h&&e.jsx("span",{className:"text-[var(--success-text)] font-medium",children:"Completed"}),!r&&!h&&e.jsx("span",{children:Ws(g)})]}),!h&&!r&&e.jsx(Vs,{percentage:i})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"opacity-80",children:"Resolution"}),a?e.jsx("span",{className:"text-[var(--error-text)] font-medium",children:"Breached"}):e.jsx("span",{children:Ws(b)})]}),!a&&e.jsx(Vs,{percentage:d})]})]})]}):e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium border ${v[x]}`,children:[e.jsx(j,{className:"w-3 h-3"}),y==="paused"&&"SLA Paused",y==="breached"&&"SLA Breached",y==="warning"&&"SLA Warning",y==="ok"&&"Within SLA"]})}function Vs({percentage:t}){const s=()=>t>=90?"bg-[var(--error-text)]":t>=75?"bg-[var(--warning-text)]":"bg-[var(--success-text)]";return e.jsx("div",{className:"h-1.5 bg-white/50 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${s()}`,style:{width:`${Math.min(t,100)}%`}})})}function Ws(t){if(t<=0)return"Overdue";const s=Math.floor(t/(1e3*60)),r=Math.floor(s/60),a=Math.floor(r/24);if(a>0){const o=r%24;return o>0?`${a}d ${o}h`:`${a}d`}if(r>0){const o=s%60;return o>0?`${r}h ${o}m`:`${r}h`}return`${s}m`}const Xs={Greeting:"bg-[var(--info-bg)] text-[var(--info-text)]",Acknowledgment:"bg-[var(--success-bg)] text-[var(--success-text)]",RequestInfo:"bg-[var(--warning-bg)] text-[var(--warning-text)]",InProgress:"bg-[var(--info-bg)] text-[var(--info-text)]",Resolution:"bg-[var(--accent-bg)] text-[var(--accent-text)]",Escalation:"bg-[var(--warning-bg)] text-[var(--warning-text)]",OnHold:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]",Closure:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]",Rejection:"bg-[var(--error-bg)] text-[var(--error-text)]",General:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"},ed=[{code:"fr",label:"Français"},{code:"en",label:"English"},{code:"de",label:"Deutsch"},{code:"it",label:"Italiano"}];function td({isOpen:t,onClose:s,onSelect:r,ticketVariables:a}){const{t:o,i18n:c}=ne.useTranslation("support"),[i,d]=n.useState([]),[u,m]=n.useState(!1),[p,f]=n.useState(null),[g,b]=n.useState(""),[h,y]=n.useState(""),[x,j]=n.useState(c.language?.substring(0,2)||"fr"),[v,S]=n.useState([]),N=n.useCallback(A=>{m(!0),Promise.all([Lt.getAll(void 0,!0,A),Lt.getCategories()]).then(([R,$])=>{d(R),S($)}).catch(console.error).finally(()=>m(!1))},[]);n.useEffect(()=>{t&&(j(c.language?.substring(0,2)||"fr"),N(c.language?.substring(0,2)||"fr"))},[t,c.language,N]);const I=A=>{j(A),N(A)};if(!t)return null;const P=i.filter(A=>{const R=!g||A.title.toLowerCase().includes(g.toLowerCase())||A.content.toLowerCase().includes(g.toLowerCase()),$=!h||A.category===h;return R&&$}),k=async A=>{try{f(A.id);const R=await Lt.render(A.id,a);r(R.content),s()}catch(R){console.error("Failed to render template:",R)}finally{f(null)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",onClick:s,onKeyDown:A=>A.key==="Escape"&&s(),role:"presentation",children:e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-xl shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col",onClick:A=>A.stopPropagation(),role:"presentation",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.FileText,{className:"w-5 h-5 text-[var(--color-primary-500)]"}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:o("templatePicker.title")})]}),e.jsx("button",{onClick:s,className:"p-1 rounded hover:bg-[var(--bg-secondary)]",children:e.jsx(l.X,{className:"w-5 h-5 text-[var(--text-secondary)]"})})]}),e.jsxs("div",{className:"p-3 space-y-2 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Globe,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("div",{className:"flex gap-1",children:ed.map(A=>e.jsx("button",{onClick:()=>I(A.code),className:`px-2 py-1 text-xs rounded transition-colors ${x===A.code?"bg-[var(--color-primary-500)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]"}`,children:A.label},A.code))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(l.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:g,onChange:A=>b(A.target.value),placeholder:o("templatePicker.searchPlaceholder"),className:"w-full pl-9 pr-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-lg outline-none focus:ring-1 focus:ring-[var(--color-primary-500)]",autoFocus:!0})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("button",{onClick:()=>y(""),className:`px-2 py-1 text-xs rounded-full transition-colors ${h?"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]":"bg-[var(--color-primary-500)] text-white"}`,children:o("templatePicker.allCategories")}),v.map(A=>e.jsx("button",{onClick:()=>y(A===h?"":A),className:`px-2 py-1 text-xs rounded-full transition-colors ${A===h?"bg-[var(--color-primary-500)] text-white":`${Xs[A]||"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"} hover:opacity-80`}`,children:o(`templates.categories.${A}`,{defaultValue:A})},A))]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[u&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--text-tertiary)]"})}),!u&&P.length===0&&e.jsx("p",{className:"text-center py-8 text-sm text-[var(--text-tertiary)]",children:o("templatePicker.noResults")}),!u&&P.length>0&&e.jsx("div",{className:"space-y-1",children:P.map(A=>e.jsxs("button",{onClick:()=>k(A),disabled:p!==null,className:"w-full text-left p-3 rounded-lg hover:bg-[var(--bg-secondary)] transition-colors group disabled:opacity-50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full ${Xs[A.category]||"bg-[var(--bg-secondary)]"}`,children:o(`templates.categories.${A.category}`,{defaultValue:A.category})}),e.jsx("span",{className:"font-medium text-sm text-[var(--text-primary)]",children:A.title}),p===A.id&&e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin ml-auto"})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] line-clamp-2",children:A.content})]},A.id))})]}),e.jsx("div",{className:"p-3 border-t border-[var(--border-color)]",children:e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center",children:o("templatePicker.selectTemplate")})})]})})}const Ys={Created:{icon:l.Clock,color:"var(--color-primary-500)",labelKey:"history.actions.Created"},StatusChanged:{icon:l.ArrowRightLeft,color:"var(--info-text)",labelKey:"history.actions.StatusChanged"},PriorityChanged:{icon:l.AlertTriangle,color:"var(--warning-text)",labelKey:"history.actions.PriorityChanged"},Assigned:{icon:l.UserPlus,color:"var(--success-text)",labelKey:"history.actions.Assigned"},Unassigned:{icon:l.UserPlus,color:"var(--text-secondary)",labelKey:"history.actions.Unassigned"},Commented:{icon:l.MessageSquare,color:"var(--color-primary-500)",labelKey:"history.actions.Commented"},InternalCommented:{icon:l.MessageSquare,color:"var(--warning-text)",labelKey:"history.actions.InternalCommented"},AttachmentAdded:{icon:l.Paperclip,color:"var(--success-text)",labelKey:"history.actions.AttachmentAdded"},AttachmentRemoved:{icon:l.Paperclip,color:"var(--error-text)",labelKey:"history.actions.AttachmentRemoved"},Resolved:{icon:l.CheckCircle,color:"var(--success-text)",labelKey:"history.actions.Resolved"},Closed:{icon:l.XCircle,color:"var(--text-secondary)",labelKey:"history.actions.Closed"},Reopened:{icon:l.RotateCcw,color:"var(--warning-text)",labelKey:"history.actions.Reopened"},Rejected:{icon:l.XCircle,color:"var(--error-text)",labelKey:"history.actions.Rejected"},SlaResponseBreached:{icon:l.AlertTriangle,color:"var(--error-text)",labelKey:"history.actions.SlaResponseBreached"},SlaResolutionBreached:{icon:l.AlertTriangle,color:"var(--error-text)",labelKey:"history.actions.SlaResolutionBreached"},Escalated:{icon:l.ArrowRightLeft,color:"var(--warning-text)",labelKey:"history.actions.Escalated"},TitleChanged:{icon:l.MessageSquare,color:"var(--text-secondary)",labelKey:"history.actions.TitleChanged"},DescriptionChanged:{icon:l.MessageSquare,color:"var(--text-secondary)",labelKey:"history.actions.DescriptionChanged"},TypeChanged:{icon:l.ArrowRightLeft,color:"var(--text-secondary)",labelKey:"history.actions.TypeChanged"},SatisfactionSubmitted:{icon:l.CheckCircle,color:"var(--success-text)",labelKey:"history.actions.SatisfactionSubmitted"}},Pa=(t,s,r)=>{const a=new Date(t),c=new Date().getTime()-a.getTime(),i=Math.floor(c/6e4),d=Math.floor(c/36e5),u=Math.floor(c/864e5);return i<1?s("history.timeAgo.now"):i<60?s("history.timeAgo.minutes",{count:i}):d<24?s("history.timeAgo.hours",{count:d}):u<7?s("history.timeAgo.days",{count:u}):a.toLocaleDateString(r,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})},sd=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,Js=t=>t?.startsWith("image/")||!1,rd=(t,s)=>t?"px-4 py-2.5 shadow-sm rounded-2xl bg-[var(--warning-bg)] border border-[var(--warning-border)]":s?"px-4 py-2.5 shadow-sm rounded-2xl rounded-tr-md bg-[var(--color-accent-600)] text-white":"px-4 py-2.5 shadow-sm rounded-2xl rounded-tl-md bg-[var(--bg-card)] border border-[var(--border-color)]";function ad(t,s,r){const a=[];(r?t:t.filter(i=>!i.isInternal)).forEach(i=>{a.push({type:"comment",id:`comment-${i.id}`,timestamp:new Date(i.createdAt),data:i})});const c=["Commented","InternalCommented"];return s.filter(i=>!c.includes(i.action)).forEach(i=>{a.push({type:"activity",id:`activity-${i.id}`,timestamp:new Date(i.createdAt),data:i})}),a.sort((i,d)=>i.timestamp.getTime()-d.timestamp.getTime()),a}function nd({activity:t,t:s,locale:r}){const a=Ys[t.action]||Ys.Created,o=a.icon;return e.jsx("div",{className:"flex justify-center my-4",children:e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[var(--bg-secondary)] border border-[var(--border-color)] text-sm",children:[e.jsx(o,{className:"w-4 h-4",style:{color:a.color}}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:s(a.labelKey)}),t.newValue&&t.action==="StatusChanged"&&e.jsxs("span",{className:"font-medium text-[var(--text-primary)]",children:["→ ",t.newValue]}),t.newValue&&t.action==="Assigned"&&e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t.newValue}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:Pa(t.createdAt,s,r)})]})})}const od=t=>{const s=t.trim().split(/\s+/);return s.length>=2?((s[0]?.at(0)??"")+(s.at(-1)?.at(0)??"")).toUpperCase():t.slice(0,2).toUpperCase()},id=t=>{const s=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];let r=0;for(let a=0;a<t.length;a++)r=t.charCodeAt(a)+((r<<5)-r);return s[Math.abs(r)%s.length]};function Qs({src:t,alt:s,className:r,onClick:a}){const[o,c]=n.useState(null),[i,d]=n.useState(!0),[u,m]=n.useState(!1);return n.useEffect(()=>{let p=!0;const f=new AbortController;return Se.get(t,{responseType:"blob",signal:f.signal}).then(g=>{if(p){const b=URL.createObjectURL(g.data);c(b),d(!1)}}).catch(()=>{p&&(m(!0),d(!1))}),()=>{p=!1,f.abort(),o&&URL.revokeObjectURL(o)}},[t]),i?e.jsx("button",{type:"button",className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,onClick:a,children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--text-tertiary)]"})}):u||!o?e.jsx("button",{type:"button",className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,onClick:a,children:e.jsx(l.Image,{className:"w-6 h-6 text-[var(--text-tertiary)]"})}):e.jsx("img",{src:o,alt:s,className:r,onClick:a})}function ld({comment:t,isOwn:s,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,t:i,locale:d}){const[u,m]=n.useState(null),p=new Date(t.createdAt).getTime(),f=a.filter(x=>{const j=new Date(x.createdAt).getTime();return Math.abs(j-p)<6e4}),g=f.filter(x=>Js(x.contentType)),b=f.filter(x=>!Js(x.contentType)),h=od(t.userName),y=id(t.userName);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex gap-3 mb-4 ${s?"flex-row-reverse":"flex-row"}`,children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0 text-white text-sm font-semibold shadow-sm",style:{backgroundColor:y},title:t.userName,children:h}),e.jsxs("div",{className:`flex flex-col max-w-[70%] ${s?"items-end":"items-start"}`,children:[e.jsxs("div",{className:`flex items-center gap-2 mb-1 ${s?"flex-row-reverse":"flex-row"}`,children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t.userName}),r&&t.isInternal&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]",children:i("conversation.internalNoteLabel")}),t.isEdited&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:i("conversation.edited")})]}),e.jsxs("div",{className:rd(t.isInternal||!1,s),children:[e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:t.content}),g.length>0&&e.jsx("div",{className:`mt-3 grid gap-2 ${g.length>1?"grid-cols-2":"grid-cols-1"}`,children:g.map(x=>e.jsxs("button",{className:"relative cursor-pointer rounded-lg overflow-hidden group",onClick:()=>m(x),type:"button",children:[e.jsx(Qs,{src:o(x),alt:x.fileName,className:"w-full h-32 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(l.Eye,{className:"w-6 h-6 text-white opacity-0 group-hover:opacity-100 transition-opacity"})})]},x.id))}),b.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:b.map(x=>e.jsxs("button",{onClick:()=>c(x),className:`flex items-center gap-2 w-full p-2 rounded-lg transition-colors ${s&&!t.isInternal?"bg-white/10 hover:bg-white/20":"bg-[var(--bg-secondary)] hover:bg-[var(--bg-tertiary)]"}`,children:[e.jsx(l.FileText,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs truncate flex-1 text-left",children:x.fileName}),e.jsx("span",{className:"text-xs opacity-70",children:sd(x.fileSize)}),e.jsx(l.Download,{className:"w-3.5 h-3.5"})]},x.id))})]}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] mt-1 px-1",children:Pa(t.createdAt,i,d)})]})]}),u&&e.jsx("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>m(null),onKeyDown:x=>x.key==="Escape"&&m(null),role:"presentation",children:e.jsxs("div",{className:"relative max-w-4xl max-h-[90vh] w-full",children:[e.jsx("button",{onClick:()=>m(null),className:"absolute -top-10 right-0 text-white hover:text-gray-300",children:e.jsx(l.X,{className:"w-6 h-6"})}),e.jsx(Qs,{src:o(u),alt:u?.fileName,className:"max-w-full max-h-[80vh] mx-auto object-contain rounded-lg",onClick:x=>x.stopPropagation()}),e.jsxs("div",{className:"mt-4 flex items-center justify-center gap-4",children:[e.jsx("p",{className:"text-white text-sm",children:u.fileName}),e.jsxs("button",{onClick:x=>{x.stopPropagation(),c(u)},className:"btn btn-secondary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),i("conversation.download")]})]})]})})]})}const cd=(t,s,r)=>t?r("conversation.internalPlaceholder","Ajouter une note interne..."):s?r("conversation.supportPlaceholder","Répondre au client..."):r("conversation.clientPlaceholder","Écrire un message..."),dd=t=>`flex items-end gap-2 rounded-xl border ${t?"border-[var(--warning-border)] bg-[var(--warning-bg)]/30":"border-[var(--border-color)] bg-[var(--bg-secondary)]"} p-2`,ud=(t,s)=>`p-2.5 rounded-lg transition-colors ${t?"bg-[var(--color-primary-600)] text-white hover:bg-[var(--color-primary-700)]":"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]"} disabled:opacity-50`;function md({isConnected:t,commentCount:s,t:r}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border-color)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.MessageSquare,{className:"w-5 h-5 text-[var(--color-accent-600)]"}),e.jsx("h2",{className:"font-semibold",children:r("conversation.title","Conversation")}),e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["(",s,")"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",title:r(t?"conversation.realtimeActive":"conversation.realtimeInactive"),children:[t?e.jsx(l.Wifi,{className:"w-4 h-4 text-[var(--success-text)]"}):e.jsx(l.WifiOff,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:`text-xs ${t?"text-[var(--success-text)]":"text-[var(--text-tertiary)]"}`,children:r(t?"conversation.live":"conversation.offline")})]})]})}function pd({t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-[var(--text-secondary)]",children:[e.jsx(l.MessageSquare,{className:"w-12 h-12 mb-3 opacity-50"}),e.jsx("p",{children:t("conversation.empty","Aucun message pour le moment")}),e.jsx("p",{className:"text-sm mt-1",children:t("conversation.startHint","Commencez la conversation ci-dessous")})]})}function xd({timeline:t,currentUserName:s,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,messagesEndRef:i,t:d,locale:u}){return e.jsxs(e.Fragment,{children:[t.map(m=>{if(m.type==="activity")return e.jsx(nd,{activity:m.data,t:d,locale:u},m.id);const p=m.data,f=p.userName===s;return e.jsx(ld,{comment:p,isOwn:f,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,t:d,locale:u},m.id)}),e.jsx("div",{ref:i})]})}function hd({isInternalComment:t,onToggle:s,t:r}){return e.jsx("div",{className:"mb-2",children:e.jsxs("label",{className:"inline-flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a=>s(a.target.checked),className:"rounded border-[var(--border-color)]"}),e.jsx("span",{className:`text-sm ${t?"text-[var(--warning-text)] font-medium":"text-[var(--text-secondary)]"}`,children:r("conversation.internalNote","Note interne (invisible pour le client)")})]})})}function gd({newComment:t,onCommentChange:s,onKeyDown:r,onSend:a,isInternalComment:o,onInternalToggle:c,sending:i,isSupport:d,textareaRef:u,ticketVariables:m,onOpenTemplatePicker:p,t:f}){const g=t.trim();return e.jsxs("div",{className:"border-t border-[var(--border-color)] bg-[var(--bg-card)] p-3",children:[d&&e.jsx(hd,{isInternalComment:o,onToggle:c,t:f}),e.jsxs("div",{className:dd(o),children:[e.jsx("textarea",{ref:u,value:t,onChange:b=>s(b.target.value),onKeyDown:r,placeholder:cd(o,d,f),className:"flex-1 bg-transparent border-none outline-none resize-none text-sm min-h-[24px] max-h-[150px] py-1 px-2",rows:1}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[d&&m&&p&&e.jsx("button",{onClick:p,className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--color-primary-500)] hover:bg-[var(--bg-tertiary)] transition-colors",title:f("templatePicker.buttonTitle"),children:e.jsx(l.FileText,{className:"w-4 h-4"})}),e.jsx("button",{onClick:a,disabled:!g||i,className:ud(!!g),children:i?e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}):e.jsx(l.Send,{className:"w-5 h-5"})})]})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-2 text-center",children:f("conversation.hint","Appuyez sur Entrée pour envoyer, Maj+Entrée pour un saut de ligne")})]})}function fd({t}){return e.jsx("div",{className:"border-t border-[var(--border-color)] bg-[var(--bg-secondary)] p-4 text-center",children:e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t("conversation.closed","Ce ticket est fermé. Aucun nouveau message ne peut être ajouté.")})})}function Ta({comments:t,activities:s,attachments:r,isSupport:a,isClosed:o,isConnected:c,currentUserName:i,ticketVariables:d,onAddComment:u,onDownloadAttachment:m,getAttachmentUrl:p}){const{t:f,i18n:g}=ne.useTranslation("support"),[b,h]=n.useState(""),[y,x]=n.useState(!1),[j,v]=n.useState(!1),[S,N]=n.useState(!1),I=n.useRef(null),P=n.useRef(null),k=ad(t,s,a),A=t.filter(C=>a||!C.isInternal).length;n.useEffect(()=>{I.current?.scrollIntoView({behavior:"smooth"})},[k.length]),n.useEffect(()=>{P.current&&(P.current.style.height="auto",P.current.style.height=`${Math.min(P.current.scrollHeight,150)}px`)},[b]);const R=async()=>{if(!(!b.trim()||j))try{v(!0),await u(b,y),h(""),x(!1)}finally{v(!1)}},$=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),R())},q=C=>{h(D=>D?D+`
47
- `+C:C)};return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx(md,{isConnected:c,commentCount:A,t:f}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 bg-[var(--bg-primary)]",children:k.length===0?e.jsx(pd,{t:f}):e.jsx(xd,{timeline:k,currentUserName:i,isSupport:a,attachments:r,getAttachmentUrl:p,onDownloadAttachment:m,messagesEndRef:I,t:f,locale:g.language})}),o?e.jsx(fd,{t:f}):e.jsx(gd,{newComment:b,onCommentChange:h,onKeyDown:$,onSend:R,isInternalComment:y,onInternalToggle:x,sending:j,isSupport:a,textareaRef:P,ticketVariables:d,onOpenTemplatePicker:a&&d?()=>N(!0):void 0,t:f}),d&&e.jsx(td,{isOpen:S,onClose:()=>N(!1),onSelect:q,ticketVariables:d})]})}const Zs=t=>{const s=t.contentType?.toLowerCase()||"",a=t.fileName.toLowerCase().split(".").pop()||"";if(s.startsWith("image/"))return"image";if(s==="application/pdf")return"pdf";if(s.startsWith("text/")||s==="application/json")return"text";if(s.startsWith("video/"))return"video";if(s.startsWith("audio/"))return"audio";const o=["png","jpg","jpeg","gif","webp","svg","bmp","ico"],c=["txt","csv","json","md","xml","log","html","css","js","ts"],i=["mp4","webm","ogg","mov","avi"],d=["mp3","wav","ogg","aac","m4a"];return o.includes(a)?"image":a==="pdf"?"pdf":c.includes(a)?"text":i.includes(a)?"video":d.includes(a)?"audio":"unknown"},er=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`;function bd({attachment:t,getUrl:s,onClose:r,onDownload:a}){const{t:o}=ne.useTranslation("support"),[c,i]=n.useState(1),[d,u]=n.useState(0),[m,p]=n.useState(!0),[f,g]=n.useState(null),[b,h]=n.useState(null),[y,x]=n.useState(!1),[j,v]=n.useState(null),S=n.useRef(null),N=t?Zs(t):"unknown";n.useEffect(()=>{if(S.current?.id===t?.id||(S.current=t,j&&URL.revokeObjectURL(j),i(1),u(0),p(!0),g(null),h(null),v(null),x(!1),!t))return;const $=Zs(t),q=s(t),C=new AbortController;return $==="text"?Se.get(q,{signal:C.signal,responseType:"text"}).then(D=>{h(D.data),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(g(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):$==="image"||$==="video"||$==="audio"?Se.get(q,{signal:C.signal,responseType:"blob"}).then(D=>{const Y=URL.createObjectURL(D.data);v(Y),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(g(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):$==="pdf"?Se.get(q,{signal:C.signal,responseType:"blob"}).then(D=>{const Y=URL.createObjectURL(D.data);v(Y),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(g(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):p(!1),()=>{C.abort()}},[t,s,o]),n.useEffect(()=>()=>{j&&URL.revokeObjectURL(j)},[j]),n.useEffect(()=>{if(!t)return;const $=q=>{q.key==="Escape"&&(y?x(!1):r()),(q.key==="+"||q.key==="=")&&(q.preventDefault(),i(C=>Math.min(C+.25,3))),q.key==="-"&&(q.preventDefault(),i(C=>Math.max(C-.25,.25))),q.key==="r"&&!q.ctrlKey&&!q.metaKey&&(q.preventDefault(),u(C=>(C+90)%360)),q.key==="f"&&(q.preventDefault(),x(C=>!C))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[t,y,r]);const I=n.useCallback(()=>i($=>Math.min($+.25,3)),[]),P=n.useCallback(()=>i($=>Math.max($-.25,.25)),[]),k=n.useCallback(()=>u($=>($+90)%360),[]);if(!t)return null;const A=()=>{if(m&&N!=="pdf"&&N!=="image"&&N!=="video"&&N!=="audio")return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})});if(f)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center px-8",children:[e.jsx(l.AlertTriangle,{className:"w-12 h-12 text-[var(--warning-text)]"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:f}),e.jsxs("button",{onClick:()=>a(t),className:"btn btn-primary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),o("filePreview.download","Télécharger le fichier")]})]});switch(N){case"image":return e.jsx("div",{className:"relative flex items-center justify-center h-full overflow-auto p-4",children:j?e.jsx("img",{src:j,alt:t.fileName,className:"max-w-none transition-transform duration-200",style:{transform:`scale(${c}) rotate(${d}deg)`,maxHeight:y?"90vh":"70vh"},onClick:$=>$.stopPropagation()}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"pdf":return e.jsx("div",{className:"h-full w-full",children:j?e.jsx("iframe",{src:`${j}#toolbar=1&navpanes=0`,className:"w-full h-full border-0 rounded",title:t.fileName}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"text":return e.jsx("div",{className:"h-full overflow-auto p-4",children:e.jsx("pre",{className:"text-sm text-[var(--text-primary)] font-mono whitespace-pre-wrap break-words bg-[var(--bg-secondary)] p-4 rounded-lg",children:b})});case"video":return e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:j?e.jsx("video",{src:j,controls:!0,className:"max-w-full max-h-[70vh] rounded-lg",children:o("filePreview.videoNotSupported","Votre navigateur ne supporte pas la lecture vidéo.")}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"audio":return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-6 p-4",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-[var(--color-accent-500)]/20 flex items-center justify-center",children:e.jsx(l.File,{className:"w-12 h-12 text-[var(--color-accent-500)]"})}),e.jsx("p",{className:"text-lg font-medium text-[var(--text-primary)]",children:t.fileName}),j?e.jsx("audio",{src:j,controls:!0,className:"w-full max-w-md",children:o("filePreview.audioNotSupported","Votre navigateur ne supporte pas la lecture audio.")}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})})]});default:return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center px-8",children:[e.jsx("div",{className:"w-20 h-20 rounded-xl bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(l.FileText,{className:"w-10 h-10 text-[var(--text-tertiary)]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-medium text-[var(--text-primary)] mb-1",children:t.fileName}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:er(t.fileSize)})]}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:o("filePreview.noPreview","Aperçu non disponible pour ce type de fichier")}),e.jsxs("button",{onClick:()=>a(t),className:"btn btn-primary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),o("filePreview.download","Télécharger le fichier")]})]})}},R=e.jsxs("div",{className:"fixed inset-0 bg-black/90 backdrop-blur-sm flex flex-col z-[100]",onClick:r,onKeyDown:$=>{$.key==="Escape"&&r()},role:"dialog","aria-modal":"true","aria-label":t.fileName,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-black/50",onClick:$=>$.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(l.FileText,{className:"w-5 h-5 text-white/70 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-white font-medium truncate",children:t.fileName}),e.jsx("p",{className:"text-xs text-white/50",children:er(t.fileSize)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[N==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:P,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.zoomOut","Zoom arrière (-)")||"Zoom out",children:e.jsx(l.ZoomOut,{className:"w-5 h-5"})}),e.jsxs("span",{className:"text-white/70 text-sm min-w-[3rem] text-center",children:[Math.round(c*100),"%"]}),e.jsx("button",{onClick:I,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.zoomIn","Zoom avant (+)")||"Zoom in",children:e.jsx(l.ZoomIn,{className:"w-5 h-5"})}),e.jsx("button",{onClick:k,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.rotate","Rotation (R)")||"Rotate",children:e.jsx(l.RotateCw,{className:"w-5 h-5"})}),e.jsx("div",{className:"w-px h-6 bg-white/20 mx-1"})]}),e.jsx("button",{onClick:()=>x($=>!$),className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.fullscreen","Plein écran (F)")||"Fullscreen",children:y?e.jsx(l.Minimize2,{className:"w-5 h-5"}):e.jsx(l.Maximize2,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>a(t),className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.download","Télécharger")||"Download",children:e.jsx(l.Download,{className:"w-5 h-5"})}),e.jsx("button",{onClick:r,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("common.close","Fermer (Échap)")||"Close",children:e.jsx(l.X,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",onClick:$=>$.stopPropagation(),children:A()}),e.jsx("div",{className:"px-4 py-2 bg-black/50 text-center",onClick:$=>$.stopPropagation(),children:e.jsx("p",{className:"text-xs text-white/40",children:o("filePreview.shortcuts","Raccourcis: Échap pour fermer • +/- pour zoomer • R pour rotation • F pour plein écran")})})]});return Ot.createPortal(R,document.body)}const tr={Low:{bg:"var(--info-bg)",text:"var(--info-text)"},Medium:{bg:"var(--warning-bg)",text:"var(--warning-text)"},High:{bg:"var(--error-bg)",text:"var(--error-text)"},Critical:{bg:"var(--error-text)",text:"white"}},vd=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,sr=t=>t?.startsWith("image/")||!1;function yd({src:t,alt:s,className:r,onClick:a}){const[o,c]=n.useState(null),[i,d]=n.useState(!0),[u,m]=n.useState(!1);return n.useEffect(()=>{let p=!0;const f=new AbortController;return Se.get(t,{responseType:"blob",signal:f.signal}).then(g=>{if(p){const b=URL.createObjectURL(g.data);c(b),d(!1)}}).catch(()=>{p&&(m(!0),d(!1))}),()=>{p=!1,f.abort(),o&&URL.revokeObjectURL(o)}},[t]),i?e.jsx("div",{className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,children:e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--text-tertiary)]"})}):u||!o?e.jsx("div",{className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,children:e.jsx(l.Image,{className:"w-4 h-4 text-[var(--text-tertiary)]"})}):e.jsx("img",{src:o,alt:s,className:r,onClick:a})}const jd={Created:{icon:l.Plus,color:"var(--success-text)"},StatusChanged:{icon:l.Edit,color:"var(--info-text)"},Assigned:{icon:l.UserCheck,color:"var(--color-accent-600)"},Unassigned:{icon:l.User,color:"var(--warning-text)"},Commented:{icon:l.MessageSquare,color:"var(--text-secondary)"},PriorityChanged:{icon:l.AlertTriangle,color:"var(--warning-text)"},Resolved:{icon:l.CheckCircle,color:"var(--success-text)"},Closed:{icon:l.XCircle,color:"var(--text-tertiary)"},Reopened:{icon:l.RotateCcw,color:"var(--warning-text)"},Escalated:{icon:l.ArrowUpCircle,color:"var(--error-text)"},Started:{icon:l.Play,color:"var(--info-text)"},Paused:{icon:l.Pause,color:"var(--warning-text)"}},Nd=(t,s)=>{const r=new Date(t),o=new Date().getTime()-r.getTime(),c=Math.floor(o/6e4),i=Math.floor(o/36e5),d=Math.floor(o/864e5);return c<1?s("sidebar.timeAgo.justNow",{defaultValue:"Just now"}):c<60?s("sidebar.timeAgo.minutes",{count:c}):i<24?s("sidebar.timeAgo.hours",{count:i}):d<7?s("sidebar.timeAgo.days",{count:d}):r.toLocaleDateString(void 0,{day:"numeric",month:"short"})},wd=10*1024*1024,rr=[".pdf",".doc",".docx",".xls",".xlsx",".txt",".csv",".zip",".png",".jpg",".jpeg",".gif",".webp"];function lt({section:t,icon:s,title:r,count:a,isExpanded:o,onToggle:c}){return e.jsxs("button",{onClick:()=>c(t),className:"w-full flex items-center gap-2 py-2 px-3 hover:bg-[var(--bg-secondary)] transition-colors rounded-lg",children:[o?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)]"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx(s,{className:"w-4 h-4 text-[var(--color-accent-600)]"}),e.jsx("span",{className:"font-medium text-sm flex-1 text-left",children:r}),a!==void 0&&a>0&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:a})]})}function Ra({ticket:t,attachments:s,activities:r,isSupport:a,saving:o,uploading:c,layout:i="compact",onAssign:d,onStatusChange:u,onResolve:m,onCloseTicket:p,onReopen:f,onEscalate:g,onDownloadAttachment:b,onUploadAttachment:h,getAttachmentUrl:y}){const{t:x}=ne.useTranslation("support"),[j,v]=n.useState(new Set(i==="grid"?["info","system","errors","attachments","actions","history"]:["info","attachments","actions"])),[S,N]=n.useState(null),[I,P]=n.useState(!1),[k,A]=n.useState(null),R=n.useRef(null),$=n.useCallback(M=>{if(M.type.startsWith("image/"))return!0;const re="."+M.name.split(".").pop()?.toLowerCase();return rr.includes(re)},[]),q=n.useCallback(async M=>{if(!(!M||!h)){A(null);for(let re=0;re<M.length;re++){const F=M[re];if(F.size>wd){A(x("sidebar.fileTooLarge","File too large (max 10 MB)"));continue}if(!$(F)){A(x("sidebar.fileTypeNotAllowed","File type not allowed"));continue}try{await h(F)}catch{A(x("sidebar.uploadError","Upload failed"))}}}},[h,$,x]),C=n.useCallback(M=>{M.preventDefault(),M.stopPropagation()},[]),D=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!0)},[]),Y=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!1)},[]),T=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!1),q(M.dataTransfer.files)},[q]),z=s.filter(M=>sr(M.contentType)),Z=s.filter(M=>!sr(M.contentType)),H=t.clientContext,J=n.useCallback(M=>{v(re=>{const F=new Set(re);return F.has(M)?F.delete(M):F.add(M),F})},[]),fe=t.status==="Closed"||t.status==="Rejected",B=i==="grid",Q=B?"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] overflow-hidden":"px-2 py-1 border-b border-[var(--border-color)]";return e.jsxs("div",{className:B?"":"h-full flex flex-col bg-[var(--bg-card)] overflow-hidden",children:[e.jsxs("div",{className:B?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4":"flex-1 overflow-y-auto",children:[e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"info",icon:l.FileText,title:x("details.info","Informations"),isExpanded:j.has("info"),onToggle:J}),j.has("info")&&e.jsx("div",{className:"px-3 pb-3",children:e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.type","Type")}),e.jsx("dd",{className:"font-medium",children:x(`tickets.types.${t.type}`,{defaultValue:t.type})})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.priority","Priority")}),e.jsx("dd",{children:e.jsx("span",{className:"inline-block px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:tr[t.priority]?.bg,color:tr[t.priority]?.text},children:x(`tickets.priorities.${t.priority}`,{defaultValue:t.priority})})})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.createdBy","Created by")}),e.jsx("dd",{children:t.createdByName||x("sidebar.unknown","Unknown")})]}),e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.assignedTo","Assigned to")}),e.jsxs("dd",{className:"flex flex-col items-end gap-1",children:[(t?.assignees?.length??0)>0?e.jsx("div",{className:"space-y-1",children:t?.assignees?.map(M=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-sm",children:M.fullName}),M.isPrimary&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-[var(--color-accent-600)] text-white rounded-md",children:x("sidebar.primary","primary")}),M.assignedViaGroupName&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-[var(--bg-secondary)] text-[var(--text-secondary)] rounded-md",children:["(",x("sidebar.viaGroup",{groupName:M.assignedViaGroupName}),")"]})]},M.userId))}):e.jsx("span",{className:"text-sm",children:x("sidebar.unassigned","Unassigned")}),d&&e.jsx("button",{onClick:d,className:"p-1 hover:bg-[var(--bg-secondary)] rounded mt-1",children:e.jsx(l.UserPlus,{className:"w-3.5 h-3.5 text-[var(--color-accent-600)]"})})]})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.createdAt","Created")}),e.jsx("dd",{className:"text-xs",children:new Date(t.createdAt).toLocaleString()})]}),t.updatedAt&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.updatedAt","Updated")}),e.jsx("dd",{className:"text-xs",children:new Date(t.updatedAt).toLocaleString()})]})]})})]}),a&&H&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"system",icon:l.Monitor,title:x("details.systemInfo","Infos système"),isExpanded:j.has("system"),onToggle:J}),j.has("system")&&e.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[H?.sourceUrl&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Globe,{className:"w-3 h-3"}),x("sidebar.url","URL")]}),e.jsx("p",{className:"text-xs font-mono break-all",children:H.sourceUrl})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[H.browser&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Globe,{className:"w-3 h-3"}),x("sidebar.browser","Browser")]}),e.jsx("p",{className:"text-xs font-medium",children:H.browser.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:H.browser.version})]}),H.os&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Laptop,{className:"w-3 h-3"}),x("sidebar.os","OS")]}),e.jsx("p",{className:"text-xs font-medium",children:H.os.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:H.os.version})]})]}),H.device&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Smartphone,{className:"w-3 h-3"}),x("sidebar.device","Device")]}),e.jsxs("p",{className:"text-xs font-medium",children:[H.device.type||x("sidebar.defaultDeviceType","Desktop"),H.device.screenResolution&&` • ${H.device.screenResolution}`]})]})]})]}),a&&H&&(H?.recentErrors?.length??0)>0&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"errors",icon:l.Bug,title:x("details.errors","Erreurs"),count:H?.recentErrors?.length??0,isExpanded:j.has("errors"),onToggle:J}),j.has("errors")&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:H?.recentErrors?.slice(0,3).map((M,re)=>e.jsxs("div",{className:"p-2 bg-[var(--error-bg)]/30 border border-[var(--error-border)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(l.AlertTriangle,{className:"w-3 h-3 text-[var(--error-text)]"}),M.component&&e.jsx("span",{className:"text-xs px-1 py-0.5 bg-[var(--bg-secondary)] rounded",children:M.component})]}),e.jsx("p",{className:"text-xs font-medium text-[var(--error-text)] line-clamp-2",children:M.message})]},`error-${re}`))})]}),e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"attachments",icon:l.File,title:x("details.attachments","Pièces jointes"),count:s.length,isExpanded:j.has("attachments"),onToggle:J}),j.has("attachments")&&e.jsxs("div",{className:"px-3 pb-3",children:[z.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)] mb-2 flex items-center gap-1",children:[e.jsx(l.Image,{className:"w-3 h-3"}),x("sidebar.images","Images")," (",z.length,")"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:z.map(M=>e.jsxs("button",{type:"button",className:"relative cursor-pointer rounded overflow-hidden border border-[var(--border-color)] aspect-square group",onClick:()=>N(M),children:[e.jsx(yd,{src:y(M),alt:M.fileName,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(l.Eye,{className:"w-5 h-5 text-white opacity-0 group-hover:opacity-100 transition-opacity"})})]},M.id))})]}),Z.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)] mb-2 flex items-center gap-1",children:[e.jsx(l.FileText,{className:"w-3 h-3"}),x("sidebar.documents","Documents")," (",Z.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:Z.map(M=>e.jsxs("div",{className:"flex items-center gap-2 w-full p-2 bg-[var(--bg-secondary)] rounded-lg hover:bg-[var(--bg-tertiary)] transition-colors group",children:[e.jsxs("button",{onClick:()=>N(M),className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[e.jsx(l.FileText,{className:"w-4 h-4 text-[var(--text-secondary)] flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs block truncate",children:M.fileName}),e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)]",children:vd(M.fileSize)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>N(M),className:"p-1 rounded hover:bg-[var(--bg-primary)] transition-colors opacity-0 group-hover:opacity-100",title:x("filePreview.view","Aperçu")||"View",children:e.jsx(l.Eye,{className:"w-3.5 h-3.5 text-[var(--color-accent-500)]"})}),e.jsx("button",{onClick:()=>b(M),className:"p-1 rounded hover:bg-[var(--bg-primary)] transition-colors",title:x("filePreview.download","Télécharger")||"Download",children:e.jsx(l.Download,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})})]})]},M.id))})]}),a&&!fe&&h&&e.jsxs("div",{children:[e.jsx("input",{ref:R,type:"file",multiple:!0,onChange:M=>q(M.target.files),accept:rr.join(","),className:"hidden"}),e.jsx("div",{className:`border-2 border-dashed rounded-lg p-3 text-center transition-colors cursor-pointer ${I?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]/10":"border-[var(--border-color)] hover:border-[var(--color-accent-500)]"}`,onClick:()=>R.current?.click(),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),R.current?.click())},role:"button",tabIndex:0,onDragOver:C,onDragEnter:D,onDragLeave:Y,onDrop:T,children:c?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-1",children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:x("sidebar.uploading","Uploading...")})]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Plus,{className:"w-5 h-5 mx-auto mb-1 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:I?x("sidebar.dropHere","Drop here"):x("sidebar.addFile","Add a file")})]})}),k&&e.jsx("p",{className:"mt-2 text-xs text-[var(--error-text)]",children:k})]}),s.length===0&&(!a||fe||!h)&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center py-2",children:x("sidebar.noAttachments","No attachments")})]})]}),a&&!B&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"actions",icon:l.User,title:x("details.actions","Actions"),isExpanded:j.has("actions"),onToggle:J}),j.has("actions")&&e.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[t.status==="Open"&&u&&e.jsx("button",{onClick:()=>u("InProgress"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:x("sidebar.startProcessing","Start processing")}),t.status==="InProgress"&&e.jsxs(e.Fragment,{children:[u&&e.jsx("button",{onClick:()=>u("OnHold"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:x("sidebar.putOnHold","Put on hold")}),m&&e.jsxs("button",{onClick:m,disabled:o,className:"btn btn-primary w-full text-sm py-2",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4 mr-2"}),x("sidebar.resolve","Resolve")]})]}),t.status==="OnHold"&&u&&e.jsx("button",{onClick:()=>u("InProgress"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:x("sidebar.resume","Resume")}),t.status==="Resolved"&&p&&e.jsxs("button",{onClick:p,disabled:o,className:"btn btn-primary w-full text-sm py-2",children:[e.jsx(l.XCircle,{className:"w-4 h-4 mr-2"}),x("sidebar.closeTicket","Close ticket")]}),(t.status==="Closed"||t.status==="Resolved")&&f&&e.jsxs("button",{onClick:f,disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:[e.jsx(l.RotateCcw,{className:"w-4 h-4 mr-2"}),x("sidebar.reopen","Reopen")]}),!fe&&g&&e.jsxs("button",{onClick:g,disabled:o,className:"btn w-full text-sm py-2 border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[e.jsx(l.ArrowUpCircle,{className:"w-4 h-4 mr-2"}),x("sidebar.escalate","Escalate")]}),o&&e.jsx("div",{className:"flex items-center justify-center py-2",children:e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--color-primary-600)]"})})]})]}),a&&r.length>0&&e.jsxs("div",{className:B?Q:"px-2 py-1",children:[e.jsx(lt,{section:"history",icon:l.History,title:x("details.history","History"),count:r.length,isExpanded:j.has("history"),onToggle:J}),j.has("history")&&e.jsx("div",{className:"px-3 pb-3",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-3 top-2 bottom-2 w-0.5 bg-[var(--border-color)]"}),e.jsx("div",{className:"space-y-3",children:r.slice(0,10).map((M,re)=>{const F=jd[M.action]||{icon:l.Edit,color:"var(--text-secondary)"},K=F.icon,V=x(`history.actions.${M.action}`,{defaultValue:M.action});return e.jsxs("div",{className:"relative flex gap-3 pl-1",children:[e.jsx("div",{className:"relative z-10 w-5 h-5 rounded-full flex items-center justify-center bg-[var(--bg-card)] border border-[var(--border-color)]",style:{color:F.color},children:e.jsx(K,{className:"w-3 h-3"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-medium text-[var(--text-primary)]",children:[V,M.newValue&&e.jsxs("span",{className:"text-[var(--text-secondary)] font-normal",children:[" → ",M.newValue]})]}),e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)]",children:Nd(M.createdAt,x)})]})]},`activity-${M.action}-${re}`)})}),r.length>10&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center mt-3",children:x("sidebar.moreActivities",{count:r.length-10})})]})})]})]}),e.jsx(bd,{attachment:S,getUrl:y,onClose:()=>N(null),onDownload:b})]})}const Zt=["Open","InProgress","Resolved","Closed"],Je={Open:{label:"Ouvert",icon:l.Clock,color:"var(--warning-text)"},InProgress:{label:"En cours",icon:l.Play,color:"var(--info-text)"},OnHold:{label:"En attente",icon:l.Pause,color:"var(--warning-text)"},Resolved:{label:"Résolu",icon:l.CheckCircle,color:"var(--success-text)"},Closed:{label:"Fermé",icon:l.XCircle,color:"var(--text-secondary)"},Rejected:{label:"Rejeté",icon:l.AlertTriangle,color:"var(--error-text)"}},Sd=t=>new Date(t).toLocaleDateString("fr-FR",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}),Cd=t=>t.isActive?"ring-4 ring-opacity-30":t.isPast?"bg-[var(--success-bg)]":"bg-[var(--bg-secondary)] border-2 border-[var(--border-color)]",kd=(t,s)=>{if(t.isActive)return s.color;if(t.isPast)return"var(--success-bg)"},Ad=(t,s)=>({backgroundColor:kd(t,s),boxShadow:t.isActive?`0 0 0 4px ${s.color}30`:void 0}),Pd=t=>t.isActive?"white":t.isPast?"var(--success-text)":"var(--text-tertiary)",Td=t=>t.isActive?"text-[var(--text-primary)]":t.isPast?"text-[var(--success-text)]":"text-[var(--text-tertiary)]",Rd=(t,s)=>t.isPast?"var(--success-text)":t.isActive?s.color:"var(--border-color)";function Ed({step:t,config:s}){const r=t.icon;return e.jsx("div",{className:`relative w-10 h-10 rounded-full flex items-center justify-center shrink-0 transition-all ${Cd(t)}`,style:Ad(t,s),children:e.jsx(r,{className:"w-5 h-5",style:{color:Pd(t)}})})}function Id({step:t}){return e.jsxs("div",{className:"mt-2 text-center",children:[e.jsx("p",{className:`text-xs font-medium ${Td(t)}`,children:t.label}),t.date&&(t.isActive||t.isPast)&&e.jsx("p",{className:"text-[10px] text-[var(--text-secondary)] mt-0.5",children:Sd(t.date)})]})}function Ld({step:t,config:s,isLast:r}){return r?null:e.jsx("div",{className:"flex-1 h-0.5 mx-2 mt-[-20px]",style:{backgroundColor:Rd(t,s)}})}function $d({currentStatus:t,createdAt:s,resolvedAt:r,closedAt:a,activities:o=[],isSupport:c,saving:i,assignees:d,onAssign:u,onStatusChange:m,onResolve:p,onCloseTicket:f,onReopen:g,onEscalate:b}){const{t:h}=ne.useTranslation("support"),y=t==="Rejected",x=o.some(S=>S.action==="Reopened"),v=(()=>{if(y)return[{status:"Open",label:h("tickets.statuses.Open",Je.Open.label),icon:Je.Open.icon,date:s,isActive:!1,isPast:!0,isFuture:!1},{status:"Rejected",label:h("tickets.statuses.Rejected",Je.Rejected.label),icon:Je.Rejected.icon,date:a,isActive:!0,isPast:!1,isFuture:!1}];const S=Zt.indexOf(t),N=[],I={Open:s};o.filter(k=>k.action==="StatusChanged"&&k.newValue).forEach(k=>{k.newValue&&(I[k.newValue]=k.createdAt)}),r&&(I.Resolved=r),a&&(I.Closed=a);const P=o.some(k=>k.action==="StatusChanged"&&k.newValue==="OnHold");if(Zt.forEach(k=>{const A=Je[k],R=k===t?S:Zt.indexOf(k),$=k===t,q=R<S,C=R>S;N.push({status:k,label:h(`tickets.statuses.${k}`,{defaultValue:A.label}),icon:A.icon,date:I[k],isActive:$,isPast:q,isFuture:C})}),P){const k=N.findIndex(A=>A.status==="Resolved");N.splice(k,0,{status:"OnHold",label:h("tickets.statuses.OnHold",Je.OnHold.label),icon:Je.OnHold.icon,date:I.OnHold,isActive:t==="OnHold",isPast:t!=="OnHold"&&t!=="Open"&&t!=="InProgress",isFuture:!1})}return N})();return e.jsx("div",{className:"w-full px-4 py-2 bg-[var(--bg-card)] border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[v.map((S,N)=>{const I=Je[S.status],P=N===v.length-1;return e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsxs("div",{className:`flex flex-col items-center ${S.isFuture?"opacity-40":""}`,children:[e.jsx(Ed,{step:S,config:I}),e.jsx(Id,{step:S})]}),e.jsx(Ld,{step:S,config:I,isLast:P})]},S.status)}),x&&e.jsxs("div",{className:"ml-2 flex items-center gap-1 text-[10px] text-[var(--warning-text)] shrink-0",children:[e.jsx(l.RotateCcw,{className:"w-3 h-3"}),e.jsx("span",{children:h("workflow.reopened","Réouvert")})]})]}),c&&e.jsx("div",{className:"w-px h-12 bg-[var(--border-color)] shrink-0"}),c&&e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[(d?.length??0)>0?e.jsxs("div",{className:"flex items-center -space-x-1.5",title:d?.map(S=>S.fullName).join(", "),children:[d?.slice(0,3).map(S=>e.jsx("div",{className:"w-7 h-7 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white text-[10px] font-medium border-2 border-[var(--bg-card)]",title:`${S.fullName}${S.isPrimary?` (${h("workflow.primary","principal")})`:""}${S.assignedViaGroupName?` (${h("workflow.viaGroup","via")} ${S.assignedViaGroupName})`:""}`,children:S.fullName.charAt(0).toUpperCase()},S.userId)),(d?.length??0)>3&&e.jsxs("div",{className:"w-7 h-7 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[10px] font-medium text-[var(--text-secondary)] border-2 border-[var(--bg-card)]",children:["+",(d?.length??0)-3]})]}):e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)] italic",children:h("workflow.notAssigned","Non assigné")}),u&&e.jsx("button",{onClick:u,className:"w-7 h-7 rounded-full border border-dashed border-[var(--border-color)] flex items-center justify-center hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-secondary)] transition-colors",title:h("workflow.assign","Assigner"),children:e.jsx(l.UserPlus,{className:"w-3.5 h-3.5 text-[var(--color-accent-600)]"})})]}),i&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--color-primary-600)]"}),t==="Open"&&m&&e.jsxs("button",{onClick:()=>m("InProgress"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Play,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.start","Commencer")]}),t==="InProgress"&&m&&e.jsxs("button",{onClick:()=>m("OnHold"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Pause,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.hold","En attente")]}),t==="InProgress"&&p&&e.jsxs("button",{onClick:p,disabled:i,className:"btn btn-primary btn-sm text-xs",children:[e.jsx(l.CheckCircle,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.resolve","Résoudre")]}),t==="OnHold"&&m&&e.jsxs("button",{onClick:()=>m("InProgress"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Play,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.resume","Reprendre")]}),t==="Resolved"&&f&&e.jsxs("button",{onClick:f,disabled:i,className:"btn btn-primary btn-sm text-xs",children:[e.jsx(l.XCircle,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.close","Fermer")]}),(t==="Closed"||t==="Resolved")&&g&&e.jsxs("button",{onClick:g,disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.RotateCcw,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.reopen","Réouvrir")]}),t!=="Closed"&&t!=="Rejected"&&b&&e.jsxs("button",{onClick:b,disabled:i,className:"btn btn-sm text-xs border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[e.jsx(l.ArrowUpCircle,{className:"w-3.5 h-3.5 mr-1"}),h("workflow.actions.escalate","Escalader")]})]})]})})}const ct={Proposed:{border:"border-blue-500",bg:"bg-blue-50",text:"text-blue-900"},Approved:{border:"border-green-500",bg:"bg-green-50",text:"text-green-900"},Rejected:{border:"border-red-500",bg:"bg-red-50",text:"text-red-900"},Superseded:{border:"border-gray-400",bg:"bg-gray-50",text:"text-gray-700"}},ar={Proposed:l.Clock,Approved:l.CheckCircle,Rejected:l.XCircle,Superseded:l.AlertCircle};function Dd({ticketId:t,solutions:s,activeSolution:r,mode:a,onProposeSolution:o,onApproveSolution:c,onRejectSolution:i,isLoading:d}){const{t:u}=ne.useTranslation("support"),[m,p]=n.useState(!1),[f,g]=n.useState(""),[b,h]=n.useState(!1),[y,x]=n.useState(""),[j,v]=n.useState(!1),[S,N]=n.useState(!1),I=n.useCallback(async()=>{if(!(!f.trim()||!o)){p(!0);try{await o(f),g("")}finally{p(!1)}}},[f,o]),P=n.useCallback(()=>{v(!0)},[]),k=n.useCallback(async()=>{if(!(!y.trim()||!i)){h(!0);try{await i(y),x(""),v(!1)}finally{h(!1)}}},[y,i]),A=R=>{if(!R.autoCloseAt)return null;const $=new Date(R.autoCloseAt),q=new Date,C=$.getTime()-q.getTime(),D=Math.ceil(C/(1e3*60*60*24));return D>0?D:0};return s.length===0&&a==="support"&&o?e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:u("solution.proposeSolution","Propose Solution")}),e.jsx("textarea",{value:f,onChange:R=>g(R.target.value),placeholder:u("solution.enterSolution","Enter solution..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:m||d}),e.jsx("div",{className:"mt-3 flex gap-2 justify-end",children:e.jsx("button",{onClick:I,disabled:!f.trim()||m||d,className:"btn btn-primary flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.proposeSolution","Propose Solution")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Send,{className:"w-4 h-4"}),u("solution.proposeSolution","Propose Solution")]})})})]}):e.jsxs("div",{className:"space-y-4",children:[r&&e.jsxs("div",{className:`rounded-lg border-2 p-4 ${ct[r.status].border} ${ct[r.status].bg}`,children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const R=ar[r.status];return e.jsx(R,{className:`w-5 h-5 ${ct[r.status].text}`})})(),e.jsxs("div",{children:[e.jsx("h4",{className:`font-semibold ${ct[r.status].text}`,children:u(`solution.status.${r.status.toLowerCase()}`,r.status)}),e.jsxs("p",{className:"text-sm opacity-75",children:[u("solution.solutionNumber","Solution #"),r.solutionNumber," - ",u("solution.proposedBy","Proposed by")," ",r.proposedByUserName||"Unknown"]})]})]})}),e.jsx("div",{className:"bg-white/50 rounded p-3 mb-3 max-h-32 overflow-y-auto",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:r.content})}),r.status==="Proposed"&&r.autoCloseAt&&e.jsx("div",{className:"mb-3 p-2 bg-yellow-100/50 border-l-2 border-yellow-500 rounded",children:e.jsxs("p",{className:"text-sm",children:[u("solution.autoCloseWarning","Will be auto-approved in")," ",e.jsxs("strong",{children:[A(r)," ",u("solution.autoCloseCountdown","days")]}),r.autoCloseWarningSent&&e.jsxs(e.Fragment,{children:[" (",u("solution.warningEmailSent","warning email sent"),")"]})]})}),r.status==="Approved"&&e.jsxs("p",{className:"text-sm",children:[u("solution.approvedBy","Approved by")," ",r.approvedByUserName||"Unknown"," on ",r.approvedAt&&new Date(r.approvedAt).toLocaleDateString()]}),r.status==="Rejected"&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm mb-2",children:[u("solution.rejectedBy","Rejected by")," ",r.rejectedByUserName||"Unknown"," on ",r.rejectedAt&&new Date(r.rejectedAt).toLocaleDateString()]}),r.rejectionReason&&e.jsxs("p",{className:"text-sm bg-white/30 p-2 rounded italic",children:[u("solution.rejectionReason","Reason"),": ",r.rejectionReason]})]}),a==="client"&&r.status==="Proposed"&&e.jsxs("div",{className:"mt-3 flex gap-2 justify-end",children:[e.jsx("button",{onClick:P,disabled:b||d,className:"btn btn-secondary text-sm py-1.5",children:u("solution.rejectSolution","Reject")}),e.jsx("button",{onClick:c,disabled:b||d||!c,className:"btn btn-primary text-sm py-1.5 flex items-center gap-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}),u("solution.acceptSolution","Approve")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.CheckCircle,{className:"w-3 h-3"}),u("solution.acceptSolution","Approve")]})})]})]}),a==="support"&&o&&!r&&e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] p-4",children:[e.jsx("h4",{className:"font-semibold mb-3",children:u("solution.proposeSolution","Propose Solution")}),e.jsx("textarea",{value:f,onChange:R=>g(R.target.value),placeholder:u("solution.enterSolution","Enter solution..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:m||d}),e.jsx("div",{className:"mt-3 flex gap-2 justify-end",children:e.jsx("button",{onClick:I,disabled:!f.trim()||m||d,className:"btn btn-primary flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.proposeSolution","Propose Solution")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Send,{className:"w-4 h-4"}),u("solution.proposeSolution","Propose Solution")]})})})]}),s.length>1&&e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("button",{onClick:()=>N(!S),className:"w-full flex items-center gap-2 p-4 hover:bg-[var(--bg-secondary)] transition-colors",children:[S?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)]"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsxs("h4",{className:"font-semibold",children:[u("solution.solutionHistory","Solution History")," (",s.length,")"]})]}),S&&e.jsx("div",{className:"border-t border-[var(--border-color)] p-4 space-y-3",children:s.map(R=>e.jsxs("div",{className:`rounded-lg border p-3 ${ct[R.status].border}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const $=ar[R.status];return e.jsx($,{className:`w-4 h-4 ${ct[R.status].text}`})})(),e.jsx("span",{className:"text-sm font-medium",children:u(`solution.status.${R.status.toLowerCase()}`,R.status)}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:["#",R.solutionNumber]})]}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:new Date(R.proposedAt).toLocaleDateString()})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 line-clamp-2",children:R.content}),e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[u("solution.proposedBy","Proposed by")," ",R.proposedByUserName||"Unknown"]})]},R.id))})]}),s.length===0&&a==="client"&&e.jsx("div",{className:"text-center py-6 text-[var(--text-tertiary)]",children:e.jsx("p",{children:u("solution.noSolutions","No solutions proposed yet")})}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg shadow-lg p-6 w-96 max-w-[90vw]",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:u("solution.rejectSolution","Reject Solution")}),e.jsx("textarea",{value:y,onChange:R=>x(R.target.value),placeholder:u("solution.enterRejectReason","Enter reason for rejection..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:b}),e.jsxs("div",{className:"mt-4 flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>v(!1),disabled:b,className:"btn btn-secondary",children:u("common:cancel","Cancel")}),e.jsx("button",{onClick:k,disabled:!y.trim()||b,className:"btn btn-primary flex items-center gap-2",children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.rejectSolution","Reject")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.XCircle,{className:"w-4 h-4"}),u("solution.rejectSolution","Reject")]})})]})]})})]})}const Md={getCached:t=>E.get(`/api/support/ai-routing/cached/${t}`)},Ea={analyze:t=>E.get(`/api/support/ai-routing/analyze/${t}`)},Ia={summarize:t=>E.post(`/api/support/ai-routing/summarize/${t}`)},La={applyRouting:(t,s)=>E.post(`/api/support/ai-routing/apply/${t}`,s)},nr=Object.freeze(Object.defineProperty({__proto__:null,analyzeApi:Ea,cachedAiApi:Md,routingApi:La,summarizeApi:Ia},Symbol.toStringTag,{value:"Module"}));function $a({classification:t}){const{t:s}=ne.useTranslation("support");if(!t)return null;const r=o=>o>.8?"bg-[var(--success-bg)] text-[var(--success-text)]":o>.5?"bg-[var(--warning-bg)] text-[var(--warning-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]",a=o=>o>.8?s("aiClassification.confidence.high"):o>.5?s("aiClassification.confidence.medium"):s("aiClassification.confidence.low");return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)]",children:s(`tickets.types.${t.suggestedType}`)}),e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-[var(--warning-bg)] text-[var(--warning-text)]",children:s(`tickets.priorities.${t.suggestedPriority}`)}),e.jsxs("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${r(t.confidenceScore)}`,children:[a(t.confidenceScore)," (",Math.round(t.confidenceScore*100),"%)"]})]})}function Da(t){const[s,r]=n.useState(t?.initialData??null),[a,o]=n.useState(!1),[c,i]=n.useState(null),d=n.useRef(null),u=n.useRef(!1);n.useEffect(()=>(u.current=!1,()=>{u.current=!0,d.current?.abort()}),[]);const m=n.useCallback(async g=>{d.current?.abort();const b=new AbortController;d.current=b,o(!0),i(null);try{const h=await g(b.signal);!u.current&&!b.signal.aborted&&r(h)}catch(h){!u.current&&!b.signal.aborted&&i(h instanceof Error?h.message:"Unknown error")}finally{!u.current&&!b.signal.aborted&&o(!1)}},[]),p=n.useCallback(()=>{d.current?.abort(),u.current||o(!1)},[]),f=n.useCallback(()=>{r(null),i(null),o(!1)},[]);return{data:s,loading:a,error:c,execute:m,cancel:p,reset:f}}function Od({ticketId:t,cachedClassification:s,cachedRouting:r,cachedGeneratedAt:a,processing:o,onProcessingStart:c,onProcessingEnd:i}){const{t:d}=ne.useTranslation("support"),u=s||r?{classification:s??null,routingSuggestion:r??null,isAiAvailable:!0,errorCode:null,errorMessage:null}:void 0,{data:m,loading:p,error:f,execute:g,reset:b}=Da({initialData:u}),[h,y]=n.useState(!1),x=n.useCallback(async()=>{c?.(),await g(async()=>{const N=await Ea.analyze(t);return i?.(),N})},[t,g,c,i]),j=n.useCallback(async()=>{if(m?.routingSuggestion)try{y(!0);const N={assignToUserId:m.routingSuggestion.suggestedAgents[0]?.userId,assignToGroupId:m.routingSuggestion.suggestedGroupId??void 0,applyPriorityAdjustment:m.routingSuggestion.priorityAdjustment!==null};await La.applyRouting(t,N),b()}catch{}finally{y(!1)}},[m,b,d]);if(f&&!m)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:d("aiRouting.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:f}),e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("common:actions.retry")]})]})]})});if(!m)return o?e.jsx("div",{className:"card p-4 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--info-text)] flex-shrink-0"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:d("aiRouting.processing")})]})}):e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm flex items-center gap-2",children:[p?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Sparkles,{className:"w-4 h-4"}),d("aiRouting.analyze")]});if(p&&!m)return e.jsx("div",{className:"card p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})});if(!m.isAiAvailable){const N=m.errorCode?`aiRouting.errors.${m.errorCode}`:null,I=N&&d(N)!==N?d(N):m.errorMessage??d("aiRouting.notConfigured");return e.jsx("div",{className:"card p-4 bg-[var(--warning-bg)]/10 border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:I})]})})}if(!m.classification&&!m.routingSuggestion)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:d("aiRouting.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:m.errorMessage??d("aiRouting.notAvailable")}),e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("common:actions.retry")]})]})]})});const v=m?.routingSuggestion,S=a&&!p?new Date(a):null;return e.jsx("div",{className:"card p-6 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"space-y-4",children:[m?.errorMessage&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-[var(--warning-text)] bg-[var(--warning-bg)]/20 rounded p-2",children:[e.jsx(l.AlertCircle,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),e.jsx("p",{children:m.errorMessage})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.Sparkles,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0 mt-1"}),e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:d("aiRouting.suggestedRouting")}),e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm flex items-center gap-1",title:d("aiRouting.refresh"),children:[p?e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("aiRouting.refresh")]})]}),S&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-3",children:d("aiRouting.generatedAt",{date:S.toLocaleString()})}),e.jsxs("div",{className:"space-y-3",children:[m?.classification&&e.jsx($a,{classification:m.classification}),(v?.suggestedAgents?.length??0)>0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-2",children:d("aiRouting.suggestedAgents")}),e.jsx("div",{className:"space-y-1",children:v?.suggestedAgents?.map(N=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium",children:N.userName||N.userId}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[Math.round(N.matchScore*100),"%"]})]},N.userId))})]}),v?.suggestedGroupName&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-1",children:d("aiRouting.suggestedGroup")}),e.jsx("p",{className:"font-medium",children:v.suggestedGroupName})]}),v?.reasoning&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-1",children:d("aiRouting.reasoning")}),e.jsx("p",{className:"italic",children:v.reasoning})]}),e.jsx("div",{className:"pt-3 border-t border-[var(--border-color)] flex gap-2",children:v&&e.jsxs("button",{onClick:j,disabled:h,className:"btn btn-primary btn-sm flex items-center gap-2 flex-1 justify-center",children:[h?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Check,{className:"w-4 h-4"}),d("aiRouting.apply")]})})]})]})]})]})})}function Fd({ticketId:t,cachedSummary:s,cachedGeneratedAt:r,processing:a,onProcessingStart:o,onProcessingEnd:c}){const{t:i}=ne.useTranslation("support"),d=s?{summary:s,isAiAvailable:!0,errorCode:null,errorMessage:null}:void 0,{data:u,loading:m,error:p,execute:f}=Da({initialData:d}),g=n.useCallback(async()=>{o?.(),await f(async()=>{const y=await Ia.summarize(t);return c?.(),y})},[t,f,o,c]);if(p&&!u)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:i("aiSummary.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:p}),e.jsxs("button",{onClick:g,disabled:m,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("common:actions.retry")]})]})]})});if(!u)return a?e.jsx("div",{className:"card p-4 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--info-text)] flex-shrink-0"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:i("aiSummary.processing")})]})}):e.jsxs("button",{onClick:g,disabled:m,className:"btn btn-secondary btn-sm flex items-center gap-2",children:[m?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Zap,{className:"w-4 h-4"}),i("aiSummary.generate")]});if(m&&!u)return e.jsx("div",{className:"card p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})});if(!u.isAiAvailable){const y=u.errorCode?`aiRouting.errors.${u.errorCode}`:null,x=y&&i(y)!==y?i(y):u.errorMessage??i("aiRouting.notConfigured");return e.jsx("div",{className:"card p-4 bg-[var(--warning-bg)]/10 border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:x})]})})}if(!u.summary){const y=u.errorCode?`aiSummary.errors.${u.errorCode}`:null,x=y&&i(y)!==y?i(y):u.errorMessage??i("aiSummary.error");return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:i("aiSummary.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:x}),e.jsxs("button",{onClick:g,disabled:m,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("common:actions.retry")]})]})]})})}const b=u.summary,h=r&&!m?new Date(r):null;return e.jsxs("div",{className:"card p-6 bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(l.Zap,{className:"w-5 h-5"}),i("aiSummary.title")]}),e.jsxs("button",{onClick:g,disabled:m,className:"btn btn-secondary btn-sm flex items-center gap-1",title:i("aiSummary.refresh"),children:[m?e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("aiSummary.refresh")]})]}),h&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-3",children:i("aiSummary.generatedAt",{date:h.toLocaleString()})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.summary")}),e.jsx("p",{className:"text-sm",children:b.summary})]}),b.keyPoints.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.keyPoints")}),e.jsx("ul",{className:"list-disc list-inside space-y-1",children:b.keyPoints.map((y,x)=>e.jsx("li",{className:"text-sm",children:y},`point-${x}`))})]}),b.sentiment&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.sentiment")}),e.jsx("p",{className:"text-sm",children:b.sentiment})]}),(b.blockers?.length??0)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.blockers")}),e.jsx("ul",{className:"space-y-2",children:b.blockers?.map((y,x)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded bg-[var(--warning-bg)] text-[var(--warning-text)] flex-shrink-0 mt-0.5",children:x+1}),e.jsx("span",{className:"text-sm",children:y})]},`blocker-${x}`))})]})]})]})}const je={tickets:{getAll:t=>E.get("/api/support/tickets",{params:t}),getMyTickets:t=>E.get("/api/support/tickets/my-assigned",{params:t}),getById:t=>E.get(`/api/support/tickets/${t}`),create:t=>E.post("/api/support/tickets",t),update:(t,s)=>E.put(`/api/support/tickets/${t}`,s),updateStatus:(t,s)=>E.patch(`/api/support/tickets/${t}/status`,{status:s}),assign:(t,s,r,a)=>E.patch(`/api/support/tickets/${t}/assign`,{assignedToUserId:s,userIds:r,groupIds:a}),resolve:(t,s)=>E.patch(`/api/support/tickets/${t}/resolve`,{resolution:s}),close:t=>E.patch(`/api/support/tickets/${t}/close`),reopen:t=>E.patch(`/api/support/tickets/${t}/reopen`),addComment:(t,s)=>E.post(`/api/support/tickets/${t}/comments`,s),delete:t=>E.delete(`/api/support/tickets/${t}`),getStats:t=>E.get("/api/support/tickets/stats",{params:{tenantId:t}}),getMyAssignedStats:()=>E.get("/api/support/tickets/my-assigned/stats"),getAttachmentUrl:(t,s)=>`/api/support/tickets/${t}/attachments/${s}`,downloadAttachment:(t,s)=>E.get(`/api/support/tickets/${t}/attachments/${s}`,{responseType:"blob"}),uploadAttachment:(t,s)=>{const r=new FormData;return r.append("file",s),E.post(`/api/support/tickets/${t}/attachments`,r,{headers:{"Content-Type":"multipart/form-data"}})},getActivities:(t,s=10)=>E.get(`/api/support/tickets/${t}/activities`,{params:{limit:s}}),getTicketingProvider:()=>E.get("/api/support/tickets/provider"),getGlpiSyncStats:()=>E.get("/api/support/tickets/glpi-sync-stats"),proposeSolution:(t,s)=>E.post(`/api/support/tickets/${t}/solutions`,{content:s}),getSolutions:t=>E.get(`/api/support/tickets/${t}/solutions`),approveSolution:t=>E.patch(`/api/support/tickets/${t}/solutions/approve`),rejectSolution:(t,s)=>E.patch(`/api/support/tickets/${t}/solutions/reject`,{reason:s})}},Fe={getAll:t=>E.get("/api/support/my-tickets",{params:t}),getById:t=>E.get(`/api/support/my-tickets/${t}`),create:t=>E.post("/api/support/my-tickets",t),update:(t,s)=>E.put(`/api/support/my-tickets/${t}`,s),addComment:(t,s)=>E.post(`/api/support/my-tickets/${t}/comments`,{content:s}),getStats:()=>E.get("/api/support/my-tickets/stats"),uploadAttachment:(t,s)=>{const r=new FormData;return r.append("file",s),E.post(`/api/support/my-tickets/${t}/attachments`,r,{headers:{"Content-Type":"multipart/form-data"}})},downloadAttachment:(t,s)=>E.get(`/api/support/my-tickets/${t}/attachments/${s}`,{responseType:"blob"}),deleteAttachment:(t,s)=>E.delete(`/api/support/my-tickets/${t}/attachments/${s}`),getActivities:(t,s=10)=>E.get(`/api/support/my-tickets/${t}/activities`,{params:{limit:s}}),getAttachmentUrl:(t,s)=>`/api/support/my-tickets/${t}/attachments/${s}`,submitSatisfaction:(t,s)=>E.post(`/api/support/my-tickets/${t}/satisfaction`,s),getSatisfaction:t=>E.get(`/api/support/my-tickets/${t}/satisfaction`),getSolutions:t=>E.get(`/api/support/my-tickets/${t}/solutions`),approveSolution:t=>E.patch(`/api/support/my-tickets/${t}/solutions/approve`),rejectSolution:(t,s)=>E.patch(`/api/support/my-tickets/${t}/solutions/reject`,{reason:s})},_d={getAll:()=>E.get("/api/support/assignment"),getById:t=>E.get(`/api/support/assignment/${t}`),create:t=>E.post("/api/support/assignment",t),update:(t,s)=>E.put(`/api/support/assignment/${t}`,s),delete:t=>E.delete(`/api/support/assignment/${t}`),activate:t=>E.patch(`/api/support/assignment/${t}/activate`),deactivate:t=>E.patch(`/api/support/assignment/${t}/deactivate`)},qd={getAll:()=>E.get("/api/support/assignment/skills"),getByAgent:t=>E.get("/api/support/assignment/skills",{params:{userId:t}}),update:(t,s)=>E.put(`/api/support/assignment/skills/${t}`,s)},Ud={getByAgent:t=>E.get(`/api/support/assignment/availability/${t}`),update:(t,s)=>E.put(`/api/support/assignment/availability/${t}`,s)},zd={getByTicket:(t,s=1,r=50)=>E.get("/api/support/assignment/logs",{params:{ticketId:t,page:s,pageSize:r}})},Bd={getByAgent:t=>E.get(`/api/support/assignment/workload/${t}`),getAll:()=>E.get("/api/support/assignment/workload")};function ws(){const{currentTenant:t}=Ee(),[s,r]=n.useState(null),[a,o]=n.useState(!!t),[c,i]=n.useState(null),d=n.useCallback(async()=>{if(!t){r(null);return}o(!0),i(null);try{const u=await je.tickets.getTicketingProvider();r(u)}catch{i("Failed to load ticketing provider configuration"),r(null)}finally{o(!1)}},[t]);return n.useEffect(()=>{d()},[d]),{provider:s?.provider??"SmartStack",isGlpi:s?.provider==="Glpi",isConfigured:s?.isConfigured??!1,glpiBaseUrl:s?.glpiBaseUrl??void 0,loading:a,error:c,refresh:d}}const ls={Open:"pending",InProgress:"active",OnHold:"warning",Resolved:"active",Closed:"inactive",Rejected:"error"},or={Low:{bg:"var(--info-bg)",text:"var(--info-text)"},Medium:{bg:"var(--warning-bg)",text:"var(--warning-text)"},High:{bg:"var(--error-bg)",text:"var(--error-text)"},Critical:{bg:"var(--error-text)",text:"white"}},Gd=["conversation","description","information","assignment","ai"],Kd={Open:"statusDescriptions.Open",InProgress:"statusDescriptions.InProgress",OnHold:"statusDescriptions.OnHold",Resolved:"statusDescriptions.Resolved",Closed:"statusDescriptions.Closed",Rejected:"statusDescriptions.Rejected"};function Hd({satisfaction:t,showRatingForm:s,ratingValue:r,ratingComment:a,submittingRating:o,onShowForm:c,onRatingChange:i,onCommentChange:d,onCancel:u,onSubmit:m,t:p}){return t?e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 mb-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500 fill-amber-500"}),p("satisfaction.yourRating","Votre évaluation")]}),e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[[1,2,3,4,5].map(f=>e.jsx(l.Star,{className:`w-5 h-5 ${f<=t.rating?"text-amber-500 fill-amber-500":"text-[var(--text-tertiary)]"}`},f)),e.jsxs("span",{className:"ml-2 text-sm text-[var(--text-secondary)]",children:[t.rating,"/5"]})]}),t.comment&&e.jsxs("p",{className:"text-sm text-[var(--text-secondary)] italic",children:['"',t.comment,'"']})]}):s?e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 mb-3",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500"}),p("satisfaction.rateTitle","Évaluez cette résolution")]}),e.jsx("div",{className:"flex items-center gap-1 mb-3",children:[1,2,3,4,5].map(f=>e.jsx("button",{type:"button",onClick:()=>i(f),className:"p-1 hover:scale-110 transition-transform",children:e.jsx(l.Star,{className:`w-7 h-7 transition-colors ${f<=r?"text-amber-500 fill-amber-500":"text-[var(--text-tertiary)] hover:text-amber-300"}`})},f))}),e.jsx("textarea",{value:a,onChange:f=>d(f.target.value),placeholder:p("satisfaction.commentPlaceholder","Commentaire (optionnel)..."),className:"input w-full h-20 mb-3 text-sm"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:u,className:"btn btn-secondary btn-sm",children:p("common.cancel","Annuler")}),e.jsxs("button",{onClick:m,disabled:r===0||o,className:"btn btn-primary btn-sm",children:[o?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-1"}):e.jsx(l.Star,{className:"w-4 h-4 mr-1"}),p("satisfaction.submit","Envoyer")]})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500"}),p("satisfaction.askTitle","Comment évaluez-vous cette résolution ?")]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:p("satisfaction.askDescription","Votre avis nous aide à améliorer notre service.")})]}),e.jsxs("button",{onClick:c,className:"btn btn-primary btn-sm",children:[e.jsx(l.Star,{className:"w-4 h-4 mr-1"}),p("satisfaction.rateButton","Évaluer")]})]})}function Vd({show:t,resolution:s,saving:r,onResolutionChange:a,onClose:o,onResolve:c,t:i}){return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:i("resolve.title","Proposer une solution")}),e.jsx("textarea",{value:s,onChange:d=>a(d.target.value),placeholder:i("resolve.placeholder","Décrivez la résolution..."),className:"input w-full h-32 mb-4"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:o,className:"btn btn-secondary",children:i("common.cancel","Annuler")}),e.jsxs("button",{onClick:c,disabled:!s.trim()||r,className:"btn btn-primary",children:[r&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),i("resolve.confirm","Proposer")]})]})]})}):null}function Wd({show:t,filteredUsers:s,selectedUserIds:r,selectedGroupIds:a,groups:o,userSearchQuery:c,groupSearchQuery:i,loadingUsers:d,loadingGroups:u,saving:m,activeTab:p,onUserSearchChange:f,onGroupSearchChange:g,onSelectUser:b,onSelectGroup:h,onTabChange:y,onClose:x,onAssign:j,t:v}){const S=n.useMemo(()=>{if(!i.trim())return o;const N=i.toLowerCase();return o.filter(I=>I.name.toLowerCase().includes(N))},[o,i]);return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4 max-h-[80vh] flex flex-col",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:v("assign.title","Assigner le ticket")}),e.jsxs("div",{className:"flex gap-2 mb-4 border-b border-[var(--border-color)]",children:[e.jsx("button",{onClick:()=>y("users"),className:`pb-2 px-3 font-medium transition-colors border-b-2 ${p==="users"?"border-[var(--color-accent-500)] text-[var(--color-accent-500)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:v("assign.tabUsers","Utilisateurs")}),e.jsx("button",{onClick:()=>y("groups"),className:`pb-2 px-3 font-medium transition-colors border-b-2 ${p==="groups"?"border-[var(--color-accent-500)] text-[var(--color-accent-500)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:v("assign.tabGroups","Groupes")})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(l.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:p==="users"?c:i,onChange:N=>p==="users"?f(N.target.value):g(N.target.value),placeholder:p==="users"?v("assign.searchUserPlaceholder","Rechercher un utilisateur..."):v("assign.searchGroupPlaceholder","Rechercher un groupe..."),className:"input w-full pl-10",autoFocus:!0})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto mb-4",children:[p==="users"&&e.jsx(e.Fragment,{children:d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:s.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-[var(--text-tertiary)]",children:v("assign.noUsersFound","Aucun utilisateur trouvé")}):s.map(N=>e.jsxs("button",{onClick:()=>b(N.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[var(--bg-secondary)] transition-colors border-t border-[var(--border-color)] first:border-t-0 ${r.includes(N.id)?"bg-[var(--color-accent-500)]/10":""}`,children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border-color)] rounded flex items-center justify-center flex-shrink-0",children:r.includes(N.id)&&e.jsx("div",{className:"w-3 h-3 bg-[var(--color-accent-500)] rounded-sm"})}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white font-medium text-sm flex-shrink-0",children:N.fullName.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:N.fullName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:N.email})]})]},N.id))})}),p==="groups"&&e.jsx(e.Fragment,{children:u?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:S.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-[var(--text-tertiary)]",children:v("assign.noGroupsFound","Aucun groupe trouvé")}):S.map(N=>e.jsxs("button",{onClick:()=>h(N.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[var(--bg-secondary)] transition-colors border-t border-[var(--border-color)] first:border-t-0 ${a.includes(N.id)?"bg-[var(--color-accent-500)]/10":""}`,children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border-color)] rounded flex items-center justify-center flex-shrink-0",children:a.includes(N.id)&&e.jsx("div",{className:"w-3 h-3 bg-[var(--color-accent-500)] rounded-sm"})}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white font-medium text-sm flex-shrink-0",children:N.name.charAt(0).toUpperCase()}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:N.name})}),e.jsx("span",{className:"text-xs px-2 py-1 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] flex-shrink-0",children:N.memberCount})]},N.id))})})]}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-4 px-3 py-2 bg-[var(--bg-secondary)] rounded",children:v("assign.selectedSummary","{{userCount}} utilisateur(s), {{groupCount}} groupe(s) sélectionné(s)",{userCount:r.length,groupCount:a.length})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{x(),f(""),g("")},className:"btn btn-secondary",children:v("common.cancel","Annuler")}),e.jsxs("button",{onClick:j,disabled:m||d||u,className:"btn btn-primary",children:[m&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),v("assign.confirm","Assigner")]})]})]})}):null}const Xd=["Supervisor","Manager","Director"];function Yd({show:t,escalationLevel:s,escalationReason:r,saving:a,onLevelChange:o,onReasonChange:c,onClose:i,onEscalate:d,t:u}){return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--warning-bg)] flex items-center justify-center",children:e.jsx(l.ArrowUpCircle,{className:"w-5 h-5 text-[var(--warning-text)]"})}),e.jsx("h2",{className:"text-xl font-bold",children:u("escalate.title")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:u("escalate.description")}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:u("escalate.level")}),e.jsx("div",{className:"space-y-2",children:Xd.map(m=>e.jsxs("button",{onClick:()=>o(m),className:`w-full flex items-center gap-3 px-4 py-3 text-left rounded-lg border transition-colors ${s===m?"border-[var(--warning-border)] bg-[var(--warning-bg)]":"border-[var(--border-color)] hover:bg-[var(--bg-secondary)]"}`,children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center ${s===m?"border-[var(--warning-text)]":"border-[var(--border-color)]"}`,children:s===m&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-[var(--warning-text)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:u(`escalate.levels.${m}`)}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:u(`escalate.levels.${m}Desc`)})]})]},m))})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:u("escalate.reason")}),e.jsx("textarea",{value:r,onChange:m=>c(m.target.value),placeholder:u("escalate.reasonPlaceholder"),className:"input w-full h-24"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{i(),o("Supervisor"),c("")},className:"btn btn-secondary",children:u("common.cancel")}),e.jsxs("button",{onClick:d,disabled:a,className:"btn border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[a&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),e.jsx(l.ArrowUpCircle,{className:"w-4 h-4 mr-2"}),u("escalate.confirm")]})]})]})}):null}function Jd(t){return{id:t.id,ticketNumber:t.ticketNumber,title:t.title,description:t.description,type:t.type,status:t.status,priority:t.priority,createdByName:t.createdBy?.fullName,assignedToName:t.assignedTo?.fullName,resolution:t.resolution,resolvedAt:t.resolvedAt,closedAt:t.closedAt,assignees:t.assignees,comments:t.comments.map(s=>({id:s.id,userName:s.userName,content:s.content,isInternal:s.isInternal,isEdited:s.isEdited,createdAt:s.createdAt})),attachments:t.attachments.map(s=>({id:s.id,fileName:s.fileName,contentType:s.contentType,fileSize:s.fileSize,createdAt:s.createdAt})),createdAt:t.createdAt,updatedAt:t.updatedAt,clientContext:t.clientContext,externalProvider:t.externalProvider,externalId:t.externalId,externalUrl:t.externalUrl,isExternallyManaged:t.isExternallyManaged,solutions:t.solutions,activeSolution:t.activeSolution,hasPendingSolution:t.hasPendingSolution}}function Qd(t){return{id:t.id,ticketNumber:t.ticketNumber,title:t.title,description:t.description,type:t.type,status:t.status,priority:t.priority,resolution:t.resolution,resolvedAt:t.resolvedAt,closedAt:t.closedAt,comments:t.comments.map(s=>({id:s.id,userName:s.userName,content:s.content,isInternal:!1,isEdited:s.isEdited,createdAt:s.createdAt})),attachments:t.attachments.map(s=>({id:s.id,fileName:s.fileName,fileSize:s.fileSize,createdAt:s.createdAt})),createdAt:t.createdAt,updatedAt:t.updatedAt,solutions:t.solutions,activeSolution:t.activeSolution,hasPendingSolution:t.hasPendingSolution}}function ir(t,s){return s==="support"?Jd(t):Qd(t)}const Zd=()=>{const[t,s]=n.useState(null),[r,a]=n.useState(!0),[o,c]=n.useState(!1),[i,d]=n.useState(!1),[u,m]=n.useState(null),[p,f]=n.useState([]),[g,b]=n.useState(!1),[h,y]=n.useState({title:"",priority:"Medium"}),[x,j]=n.useState(!1),[v,S]=n.useState(!1),[N,I]=n.useState(!1),[P,k]=n.useState(""),[A,R]=n.useState("Supervisor"),[$,q]=n.useState(""),[C,D]=n.useState([]),[Y,T]=n.useState([]),[z,Z]=n.useState([]),[H,J]=n.useState(!1),[fe,B]=n.useState(""),[Q,M]=n.useState(""),[re,F]=n.useState([]),[K,V]=n.useState(!1),[ae,ue]=n.useState("users"),[G,ce]=n.useState(null),[de,he]=n.useState(!1),[pe,ye]=n.useState(0),[qe,Ue]=n.useState(""),[Ve,U]=n.useState(!1);return{ticket:t,setTicket:s,loading:r,setLoading:a,saving:o,setSaving:c,uploading:i,setUploading:d,error:u,setError:m,activities:p,setActivities:f,isEditing:g,setIsEditing:b,editForm:h,setEditForm:y,showAssignModal:x,setShowAssignModal:j,showResolveModal:v,setShowResolveModal:S,showEscalateModal:N,setShowEscalateModal:I,resolution:P,setResolution:k,escalationLevel:A,setEscalationLevel:R,escalationReason:$,setEscalationReason:q,users:C,setUsers:D,selectedUserIds:Y,setSelectedUserIds:T,selectedGroupIds:z,setSelectedGroupIds:Z,loadingUsers:H,setLoadingUsers:J,userSearchQuery:fe,setUserSearchQuery:B,groupSearchQuery:Q,setGroupSearchQuery:M,groups:re,setGroups:F,loadingGroups:K,setLoadingGroups:V,assignModalTab:ae,setAssignModalTab:ue,satisfaction:G,setSatisfaction:ce,showRatingForm:de,setShowRatingForm:he,ratingValue:pe,setRatingValue:ye,ratingComment:qe,setRatingComment:Ue,submittingRating:Ve,setSubmittingRating:U}},eu=(t,s)=>t?s?.email||"":(s?.firstName&&s?.lastName?`${s.firstName} ${s.lastName}`:s?.email)||"",tu=(t,s,r)=>{const a=s.get("tab");t==="conversation"?a&&(s.delete("tab"),r(s,{replace:!0})):a!==t&&r({tab:t},{replace:!0})},su=(t,s)=>{const r=t.get("tab");return r&&s.includes(r)?r:"conversation"};function ru({ticket:t,isSupport:s,isEditing:r,saving:a,editForm:o,error:c,onEditToggle:i,onSave:d,onEditFormChange:u,onErrorClear:m,t:p}){return e.jsxs("div",{className:"flex-shrink-0 border-b border-[var(--border-color)] bg-[var(--bg-card)] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>window.history.back(),className:"btn btn-ghost p-2",children:e.jsx(l.ArrowLeft,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-sm text-[var(--text-secondary)]",children:t.ticketNumber}),t.externalId&&t.externalUrl&&e.jsxs("a",{href:t.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] hover:opacity-80",children:[e.jsx(l.ExternalLink,{className:"w-3 h-3"}),"GLPI #",t.externalId]}),e.jsx(Mt,{status:ls[t.status]||"pending",label:t.status}),e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:or[t.priority]?.bg,color:or[t.priority]?.text},children:t.priority})]}),s&&r?e.jsx("input",{type:"text",value:o.title,onChange:f=>u({...o,title:f.target.value}),className:"input w-full text-lg font-bold"}):e.jsx("h1",{className:"text-lg font-bold truncate",children:t.title})]}),e.jsx("div",{className:"flex items-center gap-2",children:s&&r?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>i(!1),className:"btn btn-ghost p-2",children:e.jsx(l.X,{className:"w-5 h-5"})}),e.jsx("button",{onClick:d,disabled:a,className:"btn btn-primary",children:a?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Save,{className:"w-4 h-4"})})]}):e.jsx(e.Fragment,{children:s&&!t.isExternallyManaged&&e.jsx("button",{onClick:()=>i(!0),className:"btn btn-ghost p-2",title:"Modifier",children:e.jsx(l.Edit2,{className:"w-5 h-5"})})})})]}),c&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(l.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm flex-1",children:c}),e.jsx("button",{onClick:m,className:"p-1 hover:bg-[var(--error-border)] rounded",children:e.jsx(l.X,{className:"w-4 h-4"})})]}),t.isExternallyManaged&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--info-bg)] border border-[var(--info-border)] flex items-center gap-3",children:[e.jsx(l.ShieldAlert,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm font-medium text-[var(--info-text)]",children:p("glpi.readOnlyBanner","This ticket is managed by GLPI and is read-only.")})}),t.externalUrl&&e.jsxs("a",{href:t.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-sm bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] hover:opacity-80 flex items-center gap-1.5",children:[e.jsx(l.ExternalLink,{className:"w-4 h-4"}),p("glpi.viewInGlpi","View in GLPI")]})]})]})}function au({ticket:t,isSupport:s,satisfaction:r,showRatingForm:a,ratingValue:o,ratingComment:c,submittingRating:i,onShowRatingForm:d,onRatingChange:u,onCommentChange:m,onCancelRating:p,onSubmitRating:f,t:g}){return e.jsxs(e.Fragment,{children:[!s&&e.jsx("div",{className:"mt-3 p-3 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:g(Kd[t.status]||"statusDescriptions.InProgress")})}),t.resolution&&e.jsxs("div",{className:"mt-3 p-4 rounded-lg bg-[var(--success-bg)] border border-[var(--success-border)]",children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 text-[var(--success-text)] mb-1",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4"}),g("resolution.title","Résolution")]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.resolution})]}),!s&&(t.status==="Resolved"||t.status==="Closed")&&e.jsx("div",{className:"mt-3 p-4 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:e.jsx(Hd,{satisfaction:r,showRatingForm:a,ratingValue:o,ratingComment:c,submittingRating:i,onShowForm:d,onRatingChange:u,onCommentChange:m,onCancel:p,onSubmit:f,t:g})})]})}function nu({activeTab:t,commentCount:s,isSupport:r,assigneeCount:a,onTabChange:o,t:c}){const i=[{id:"conversation",icon:l.MessageSquare,label:c("tabs.conversation"),badge:s},{id:"description",icon:l.FileText,label:c("tabs.description"),badge:0},{id:"information",icon:l.Info,label:c("tabs.information"),badge:0},...r?[{id:"assignment",icon:l.Users,label:c("tabs.assignment"),badge:a},{id:"ai",icon:l.Sparkles,label:c("tabs.ai"),badge:0}]:[]];return e.jsx("div",{className:"flex-shrink-0 flex border-b border-[var(--border-color)] bg-[var(--bg-card)]",children:i.map(({id:d,icon:u,label:m,badge:p})=>e.jsxs("button",{onClick:()=>o(d),className:`flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors border-b-2 ${t===d?"border-[var(--color-accent-600)] text-[var(--color-accent-600)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--border-color)]"}`,children:[e.jsx(u,{className:"w-4 h-4"}),m,p>0&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:p})]},d))})}function ou({activeTab:t,ticket:s,activities:r,isSupport:a,isClosed:o,isReadOnly:c,isConnected:i,currentUserName:d,saving:u,uploading:m,onAddComment:p,onDownloadAttachment:f,onUploadAttachment:g,onStatusChange:b,onAssign:h,onResolve:y,onClose:x,onReopen:j,onEscalate:v,getAttachmentUrl:S,onProposeSolution:N,onApproveSolution:I,onRejectSolution:P,t:k}){if(t==="description")return e.jsx("div",{className:"h-full overflow-y-auto p-6 bg-[var(--bg-primary)]",children:s.description?e.jsx("div",{className:"prose prose-sm max-w-none text-[var(--text-primary)] leading-relaxed [&_a]:text-[var(--color-accent-600)] [&_a]:underline",dangerouslySetInnerHTML:{__html:Ja.sanitize(s.description)}}):e.jsx("p",{className:"text-[var(--text-tertiary)] italic",children:k("tabs.noDescription")})});if(t==="conversation"){const A=n.useMemo(()=>{if(s)return{ticketNumber:s.ticketNumber??"",ticketTitle:s.title??"",userName:s.createdBy?.fullName??"",userFirstName:s.createdBy?.fullName?.split(" ")[0]??"",userLastName:s.createdBy?.fullName?.split(" ").slice(1).join(" ")??"",userEmail:s.createdBy?.email??"",priority:s.priority??"",type:s.type??"",status:s.status??"",agentName:s.assignedTo?.fullName??"",agentFirstName:s.assignedTo?.fullName?.split(" ")[0]??"",createdAt:s.createdAt?new Date(s.createdAt).toLocaleDateString():"",resolvedAt:s.resolvedAt?new Date(s.resolvedAt).toLocaleDateString():"",resolution:s.resolution??""}},[s]);return e.jsxs("div",{className:"h-full flex flex-col",children:[(s.activeSolution||s.hasPendingSolution||a&&!o&&s.status!=="Closed")&&e.jsx("div",{className:"p-4 border-b border-[var(--border-color)]",children:e.jsx(Dd,{ticketId:s.id,solutions:s.solutions??[],activeSolution:s.activeSolution,mode:a?"support":"client",onProposeSolution:!c&&a?N:void 0,onApproveSolution:c?void 0:I,onRejectSolution:c?void 0:P,isLoading:u})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ta,{ticketId:s.id,comments:s.comments,activities:r.map(R=>({id:R.id,action:R.action,oldValue:R.oldValue??null,newValue:R.newValue??null,changedByUserName:"changedByUserName"in R?R.changedByUserName:null,createdAt:R.createdAt})),attachments:s.attachments,isSupport:a,isClosed:o||c,isConnected:i,currentUserName:d,ticketVariables:A,onAddComment:p,onDownloadAttachment:f,getAttachmentUrl:S})})]})}return t==="assignment"?e.jsx(iu,{ticket:s,canAssign:!c&&!!h,onAssign:h,t:k}):t==="ai"?e.jsx(cu,{ticket:s,t:k}):e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(Ra,{ticket:s,attachments:s.attachments,activities:r.map(A=>({action:A.action,newValue:A.newValue,createdAt:A.createdAt})),isSupport:a,saving:u,uploading:m,isReadOnly:c,layout:"grid",onAssign:c?void 0:h,onStatusChange:c?void 0:b,onResolve:c?void 0:y,onCloseTicket:c?void 0:x,onReopen:c?void 0:j,onEscalate:c?void 0:v,onDownloadAttachment:f,onUploadAttachment:c?void 0:g,getAttachmentUrl:S})})})}function iu({ticket:t,canAssign:s,onAssign:r,t:a}){const[o,c]=n.useState([]),[i,d]=n.useState(!1);n.useEffect(()=>{t?.id&&(d(!0),zd.getByTicket(t.id).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1)))},[t?.id]);const u=t.assignees??[];return e.jsx("div",{className:"h-full overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)]",children:a("tabs.assignmentCurrentAssignees")}),s&&r&&e.jsx("button",{onClick:r,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:a("tabs.assignmentAssign")})]}),u.length===0?e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] italic",children:a("tabs.assignmentNoAssignees")}):e.jsx("div",{className:"space-y-2",children:u.map(m=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md bg-[var(--bg-secondary)]",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-100)] text-[var(--color-accent-700)] flex items-center justify-center text-xs font-medium",children:(m.fullName||m.email||"?").charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:m.fullName||m.email}),m.assignedViaGroupName&&e.jsx("div",{className:"text-xs text-[var(--text-tertiary)]",children:a("tabs.assignmentViaGroup",{group:m.assignedViaGroupName})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m.isPrimary&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-[var(--info-bg)] text-[var(--info-text)]",children:a("tabs.assignmentPrimary")}),m.assignedAt&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:new Date(m.assignedAt).toLocaleDateString()})]})]},m.userId))})]}),e.jsxs("div",{className:"card p-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)] mb-4",children:a("tabs.assignmentLogs")}),i&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!i&&o.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] italic",children:a("tabs.assignmentNoLogs")}),!i&&o.length>0&&e.jsx("div",{className:"space-y-2",children:o.map(m=>e.jsxs("div",{className:"flex items-start gap-3 p-2 rounded-md border border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsx("div",{className:`mt-0.5 w-2 h-2 rounded-full flex-shrink-0 ${m.success?"bg-[var(--success-text)]":"bg-[var(--error-text)]"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-[var(--text-primary)]",children:[e.jsx("span",{className:"font-medium",children:m.strategyUsed}),m.reason&&e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[" — ",m.reason]})]}),e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:new Date(m.createdAt).toLocaleString()})]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${m.success?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]"}`,children:m.success?a("tabs.assignmentSuccess"):a("tabs.assignmentFailed")})]},m.id))})]})]})})}const lu=12e4;function lr(t){const s=sessionStorage.getItem(t);return s?Date.now()-Number(s)>lu?(sessionStorage.removeItem(t),!1):!0:!1}function cu({ticket:t,t:s}){const[r,a]=n.useState(null),[o,c]=n.useState(!0),i=`ai_routing_${t.id}`,d=`ai_summary_${t.id}`,[u,m]=n.useState(()=>lr(i)),[p,f]=n.useState(()=>lr(d));n.useEffect(()=>{let x=!1;return(async()=>{try{const{cachedAiApi:v}=await Promise.resolve().then(()=>nr),S=await v.getCached(t.id);x||(a(S),S.routingSuggestion&&(sessionStorage.removeItem(i),m(!1)),S.summary&&(sessionStorage.removeItem(d),f(!1)))}catch{}finally{x||c(!1)}})(),()=>{x=!0}},[t.id,i,d]),n.useEffect(()=>{if(!u&&!p)return;let x=!1;const v=setInterval(async()=>{try{const{cachedAiApi:S}=await Promise.resolve().then(()=>nr),N=await S.getCached(t.id);if(x)return;a(N),u&&N.routingSuggestion&&(sessionStorage.removeItem(i),m(!1)),p&&N.summary&&(sessionStorage.removeItem(d),f(!1))}catch{}},3e3);return()=>{x=!0,clearInterval(v)}},[u,p,t.id,i,d]);const g=n.useCallback(()=>{sessionStorage.setItem(i,Date.now().toString()),m(!0)},[i]),b=n.useCallback(()=>{sessionStorage.removeItem(i),m(!1)},[i]),h=n.useCallback(()=>{sessionStorage.setItem(d,Date.now().toString()),f(!0)},[d]),y=n.useCallback(()=>{sessionStorage.removeItem(d),f(!1)},[d]);return o?e.jsx("div",{className:"h-full overflow-y-auto p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"h-full overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-4",children:[(t.aiClassification||r?.classification)&&e.jsxs("div",{className:"card p-4",children:[e.jsx("h3",{className:"font-semibold text-sm mb-3 text-[var(--text-primary)]",children:s("aiClassification.title")}),e.jsx($a,{classification:t.aiClassification||r?.classification})]}),e.jsx(Od,{ticketId:t.id,cachedClassification:r?.classification,cachedRouting:r?.routingSuggestion,cachedGeneratedAt:r?.routingSuggestionGeneratedAt,processing:u,onProcessingStart:g,onProcessingEnd:b}),e.jsx(Fd,{ticketId:t.id,cachedSummary:r?.summary,cachedGeneratedAt:r?.summaryGeneratedAt,processing:p,onProcessingStart:h,onProcessingEnd:y})]})})}function du({mode:t}){const{id:s}=w.useParams(),r=w.useNavigate(),{t:a}=ne.useTranslation("support"),{user:o,hasPermission:c}=Pe(),[i,d]=w.useSearchParams(),{isGlpi:u}=ws(),m=t==="support",p=eu(m,o),[f,g]=n.useState(()=>su(i,Gd));n.useEffect(()=>{tu(f,i,d)},[f,i,d]);const{ticket:b,setTicket:h,loading:y,setLoading:x,saving:j,setSaving:v,uploading:S,setUploading:N,error:I,setError:P,activities:k,setActivities:A,isEditing:R,setIsEditing:$,editForm:q,setEditForm:C,showAssignModal:D,setShowAssignModal:Y,showResolveModal:T,setShowResolveModal:z,showEscalateModal:Z,setShowEscalateModal:H,resolution:J,setResolution:fe,escalationLevel:B,setEscalationLevel:Q,escalationReason:M,setEscalationReason:re,users:F,setUsers:K,selectedUserIds:V,setSelectedUserIds:ae,selectedGroupIds:ue,setSelectedGroupIds:G,loadingUsers:ce,setLoadingUsers:de,userSearchQuery:he,setUserSearchQuery:pe,groupSearchQuery:ye,setGroupSearchQuery:qe,groups:Ue,setGroups:Ve,loadingGroups:U,setLoadingGroups:W,assignModalTab:ee,setAssignModalTab:te,satisfaction:se,setSatisfaction:me,showRatingForm:ie,setShowRatingForm:ve,ratingValue:be,setRatingValue:Ie,ratingComment:Me,setRatingComment:Le,submittingRating:ze,setSubmittingRating:et}=Zd(),We=n.useCallback(async()=>{if(s)try{const X=m?await je.tickets.getActivities(s,50):await Fe.getActivities(s,50);A(X)}catch(X){console.error("Failed to load activities",X)}},[s,m]),Pt=n.useCallback(async()=>{if(!(!s||m))try{const X=await Fe.getSatisfaction(s);me(X)}catch(X){console.error("Failed to load satisfaction",X)}},[s,m]),ke=n.useCallback(async()=>{if(s)try{if(x(!0),P(null),m){const X=await je.tickets.getById(s);if(!X){h(null);return}h(ir(X,t)),C({title:X.title,priority:X.priority})}else{const X=await Fe.getById(s);if(!X){h(null);return}h(ir(X,t)),Pt()}We()}catch(X){P(a("error.loadFailed","Impossible de charger le ticket")),console.error(X)}finally{x(!1)}},[s,m,t,We,Pt,a]),L=n.useCallback(X=>{if(X.ticketId===s){if(!m&&X.isInternal)return;h(xe=>!xe||xe.comments.some(De=>De.id===X.id)?xe:{...xe,comments:[...xe.comments,{id:X.id,userName:X.userName,content:X.content,isInternal:X.isInternal,isEdited:X.isEdited,createdAt:X.createdAt}]})}},[s,m]),le=n.useCallback(X=>{X.ticketId===s&&ke()},[s,ke]),{isConnected:we}=ra({ticketId:s,onCommentAdded:L,onTicketUpdated:le});n.useEffect(()=>{ke()},[ke]),n.useEffect(()=>{(async()=>{if(!(!D||F.length>0||!m))try{de(!0);const xe=await E.get("/api/support/tickets/assignable-users"),De=Array.isArray(xe)?xe:[];K(De.map(Re=>({id:Re.id,email:Re.email,fullName:`${Re.firstName} ${Re.lastName}`}))),(b?.assignees?.length??0)>0&&b?.assignees&&ae(b.assignees.map(Re=>Re.userId))}catch(xe){console.error("Failed to load users",xe)}finally{de(!1)}})()},[D,F.length,m,b?.assignees]),n.useEffect(()=>{(async()=>{if(!(!D||!m))try{W(!0);const xe=await E.get("/api/support/tickets/assignable-groups"),De=Array.isArray(xe)?xe:[];Ve(De.map(Re=>({id:Re.id,name:Re.name,memberCount:Re.memberCount})))}catch(xe){console.error("Failed to load groups",xe)}finally{W(!1)}})()},[D,m]);const Ae=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.update(s,{title:q.title,priority:q.priority,description:b?.description||""}),await ke(),$(!1)}catch{P(a("error.updateFailed","Impossible de mettre à jour le ticket"))}finally{v(!1)}},$e=async X=>{if(!(!s||!m))try{v(!0),await je.tickets.updateStatus(s,X),await ke()}catch{P(a("error.statusFailed","Impossible de changer le statut"))}finally{v(!1)}},ht=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.assign(s,V.length>0?V[0]:null,V.length>0?V:void 0,ue.length>0?ue:void 0),await ke(),Y(!1),ae([]),G([]),te("users")}catch{P(a("error.assignFailed","Impossible d'assigner le ticket"))}finally{v(!1)}},rt=async()=>{if(!(!s||!J.trim()||!m))try{v(!0),await je.tickets.proposeSolution(s,J),await ke(),z(!1),fe("")}catch{P(a("error.resolveFailed","Impossible de proposer une solution"))}finally{v(!1)}},Ma=async X=>{if(s)try{v(!0),m&&await je.tickets.proposeSolution(s,X),await ke()}catch{P(a("error.resolveFailed","Impossible de proposer une solution"))}finally{v(!1)}},Oa=async()=>{if(s)try{v(!0),m?await je.tickets.approveSolution(s):await Fe.approveSolution(s),await ke()}catch{P(a("error.approveFailed","Impossible d'approuver la solution"))}finally{v(!1)}},Fa=async X=>{if(s)try{v(!0),m?await je.tickets.rejectSolution(s,X):await Fe.rejectSolution(s,X),await ke()}catch{P(a("error.rejectFailed","Impossible de rejeter la solution"))}finally{v(!1)}},Ss=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.close(s),await ke()}catch{P(a("error.closeFailed","Impossible de fermer le ticket"))}finally{v(!1)}},Cs=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.reopen(s),await ke()}catch{P(a("error.reopenFailed","Impossible de réouvrir le ticket"))}finally{v(!1)}},_a=async()=>{if(!(!s||!m||!B))try{v(!0),await ca.escalateTicket(s,B,M||void 0),await ke(),H(!1),Q("Supervisor"),re("")}catch{P(a("error.escalateFailed","Failed to escalate ticket"))}finally{v(!1)}},qa=async(X,xe)=>{!s||!X.trim()||(m?await je.tickets.addComment(s,{content:X,isInternal:xe}):await Fe.addComment(s,X),await ke())},Ua=async()=>{if(!(!s||be===0||m))try{et(!0);const X=await Fe.submitSatisfaction(s,{rating:be,comment:Me.trim()||void 0});me(X),ve(!1),Ie(0),Le("")}catch(X){const xe=X instanceof Error?X.message:a("error.ratingFailed","Failed to submit rating");P(xe)}finally{et(!1)}},za=async X=>{if(s)try{const xe=m?await je.tickets.downloadAttachment(s,X.id):await Fe.downloadAttachment(s,X.id),De=window.URL.createObjectURL(xe),Re=document.createElement("a");Re.href=De,Re.setAttribute("download",X.fileName),document.body.appendChild(Re),Re.click(),Re.remove(),window.URL.revokeObjectURL(De)}catch{P(a("error.downloadFailed","Impossible de télécharger le fichier"))}},Ba=async X=>{if(!(!s||!m))try{N(!0),await je.tickets.uploadAttachment(s,X),await ke()}catch(xe){throw P(a("error.uploadFailed","Failed to upload file")),xe}finally{N(!1)}},Ga=X=>s?m?je.tickets.getAttachmentUrl(s,X.id):`/api/support/my-tickets/${s}/attachments/${X.id}`:"",Ka=n.useMemo(()=>{if(!he.trim())return F;const X=he.toLowerCase();return F.filter(xe=>xe.fullName.toLowerCase().includes(X)||xe.email.toLowerCase().includes(X))},[F,he]),Ha=n.useCallback(X=>{ae(xe=>xe.includes(X)?xe.filter(De=>De!==X):[...xe,X])},[]),Va=n.useCallback(X=>{G(xe=>xe.includes(X)?xe.filter(De=>De!==X):[...xe,X])},[]);if(y)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-600)]"})});if(!b)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsx(l.AlertTriangle,{className:"w-12 h-12 mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:a("error.notFound","Ticket non trouvé")}),e.jsx("button",{onClick:()=>r(-1),className:"btn btn-secondary",children:a("common.goBack","Retour")})]});const Wa=b.status==="Closed"||b.status==="Rejected",tt=u||!!b.isExternallyManaged,ks=!tt&&c("support.tickets.assign");return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(ru,{ticket:b,isSupport:m,isEditing:R,saving:j,editForm:q,error:I,onEditToggle:$,onSave:Ae,onEditFormChange:C,onErrorClear:()=>P(null),t:a}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx(au,{ticket:b,isSupport:m,satisfaction:se,showRatingForm:ie,ratingValue:be,ratingComment:Me,submittingRating:ze,onShowRatingForm:()=>ve(!0),onRatingChange:Ie,onCommentChange:Le,onCancelRating:()=>{ve(!1),Ie(0),Le("")},onSubmitRating:Ua,t:a}),e.jsx($d,{currentStatus:b.status,createdAt:b.createdAt,resolvedAt:b.resolvedAt,closedAt:b.closedAt,activities:k.map(X=>({action:X.action,newValue:X.newValue,createdAt:X.createdAt})),isSupport:m,saving:j,assignees:b.assignees,onAssign:ks?()=>Y(!0):void 0,onStatusChange:tt?void 0:$e,onResolve:tt?void 0:()=>z(!0),onCloseTicket:tt?void 0:Ss,onReopen:tt?void 0:Cs,onEscalate:tt?void 0:()=>H(!0)})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsx(nu,{activeTab:f,commentCount:b.comments.length,isSupport:m,assigneeCount:b.assignees?.length??0,onTabChange:g,t:a}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(ou,{activeTab:f,ticket:b,activities:k,isSupport:m,isClosed:Wa,isReadOnly:tt,isConnected:we,currentUserName:p,saving:j,uploading:S,onAddComment:qa,onDownloadAttachment:za,onUploadAttachment:Ba,onStatusChange:$e,onAssign:ks?()=>Y(!0):void 0,onResolve:()=>z(!0),onClose:Ss,onReopen:Cs,onEscalate:()=>H(!0),getAttachmentUrl:Ga,onProposeSolution:Ma,onApproveSolution:Oa,onRejectSolution:Fa,t:a})})]}),e.jsx(Vd,{show:m&&T,resolution:J,saving:j,onResolutionChange:fe,onClose:()=>z(!1),onResolve:rt,t:a}),e.jsx(Wd,{show:m&&D,filteredUsers:Ka,selectedUserIds:V,selectedGroupIds:ue,groups:Ue,userSearchQuery:he,groupSearchQuery:ye,loadingUsers:ce,loadingGroups:U,saving:j,activeTab:ee,onUserSearchChange:pe,onGroupSearchChange:qe,onSelectUser:Ha,onSelectGroup:Va,onTabChange:te,onClose:()=>{Y(!1),ae([]),G([]),te("users"),pe(""),qe("")},onAssign:ht,t:a}),e.jsx(Yd,{show:m&&Z,escalationLevel:B,escalationReason:M,saving:j,onLevelChange:Q,onReasonChange:re,onClose:()=>H(!1),onEscalate:_a,t:a})]})}const cr="support_tickets_view_mode",uu={Open:["InProgress","OnHold","Rejected"],InProgress:["OnHold","Resolved","Rejected"],OnHold:["InProgress","Resolved","Open"],Resolved:["Closed","Open"],Closed:["Open"],Rejected:["Open"]};function dr(t,s){return t===s?!1:uu[t]?.includes(s)??!1}const es={Low:"var(--info-bg)",Medium:"var(--warning-bg)",High:"var(--error-bg)",Critical:"var(--error-text)"};function mu({mode:t,showDrafts:s=!1,basePath:r,title:a,subtitle:o,createPath:c}){const{t:i}=ne.useTranslation(["support","admin","common"]),d=w.useNavigate(),{currentTenant:u,userTenants:m,hasMultipleTenants:p,isGlobalView:f}=Ee(),{isGlpi:g}=ws(),[b,h]=n.useState([]),[y,x]=n.useState(null),[j,v]=n.useState(!0),[S,N]=n.useState(1),[I,P]=n.useState(1),[k,A]=n.useState(0),[R,$]=n.useState(""),[q,C]=n.useState(""),[D,Y]=n.useState(""),[T,z]=n.useState(""),[Z,H]=n.useState(""),[J,fe]=n.useState(()=>localStorage.getItem(cr)||"table"),[B,Q]=n.useState(!1),[M,re]=n.useState([]),[F,K]=n.useState(!0),[V,ae]=n.useState(null),[ue,G]=n.useState(null),[ce,de]=n.useState(null),he=(t==="admin"||t==="assigned")&&(p||f),pe=n.useCallback(async()=>{try{v(!0);const L={page:S,pageSize:20,search:R||void 0,status:q||void 0,type:D||void 0,priority:T||void 0,tenantId:Z||void 0};let le;t==="admin"?le=await je.tickets.getAll(L):t==="assigned"?le=await je.tickets.getMyTickets(L):le=await Fe.getAll(L),h(le?.items??[]),P(le?.totalPages??1),A(le?.totalCount??0)}catch(L){console.error("Failed to load tickets:",L),h([]),P(1),A(0)}finally{v(!1)}},[t,S,R,q,D,T,Z]),ye=n.useCallback(async()=>{try{let L;t==="admin"?L=await je.tickets.getStats(Z||void 0):t==="assigned"?L=await je.tickets.getMyAssignedStats():L=await Fe.getStats(),x(L)}catch(L){console.error("Failed to load stats:",L)}},[t,Z]);n.useEffect(()=>{pe()},[pe]),n.useEffect(()=>{ye()},[ye]),n.useEffect(()=>{if(s){const L=Ge.getAllDrafts();re(L)}},[s]),n.useEffect(()=>{localStorage.setItem(cr,J)},[J]);const qe=L=>{Ge.deleteDraft(L),re(Ge.getAllDrafts())},Ue=L=>{d(`${c}?draft=${L.id}`)},Ve=L=>{const we=new Date().getTime()-L.getTime(),Ae=Math.floor(we/6e4),$e=Math.floor(we/36e5),ht=Math.floor(we/864e5);return Ae<1?i("common:time.justNow","Just now"):Ae<60?i("common:time.minutesAgo",{count:Ae}):$e<24?i("common:time.hoursAgo",{count:$e}):i("common:time.daysAgo",{count:ht})},U=L=>{L.preventDefault(),N(1),pe()},W=L=>{g||ae(L)},ee=()=>{ae(null),G(null)},te=(L,le)=>{L.preventDefault(),G(le)},se=()=>{G(null)},me=L=>V?dr(V.status,L):!1,ie=async(L,le)=>{if(L.preventDefault(),de(null),!V||V.status===le){ae(null),G(null);return}if(!dr(V.status,le)){de(i("list.invalidTransition",{from:i(`tickets.statuses.${V.status}`),to:i(`tickets.statuses.${le}`)})),ae(null),G(null),setTimeout(()=>de(null),4e3);return}try{h(we=>we.map(Ae=>Ae.id===V.id?{...Ae,status:le}:Ae)),(t==="admin"||t==="assigned")&&await je.tickets.updateStatus(V.id,le),ye(),pe()}catch(we){console.error("Failed to update ticket status:",we);const Ae=we?.response?.data?.message||we?.response?.data?.detail||"";de(Ae||i("list.statusUpdateFailed")),setTimeout(()=>de(null),4e3),pe()}finally{ae(null),G(null)}},ve=async L=>{if(confirm(i("list.confirmDelete",{number:L.ticketNumber})))try{await je.tickets.delete(L.id),pe(),ye()}catch(le){console.error("Failed to delete ticket:",le)}},be=L=>`${r}/${L}`,Ie=L=>{if(!he)return null;const le="tenantId"in L?L.tenantId??null:null,we="tenantName"in L?L.tenantName??null:null,Ae=fs(le,u?.id??null);return Ae==="global"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-700",children:"System"}):Ae==="current"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] truncate max-w-[120px]",children:we}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700 font-medium truncate max-w-[120px]",children:we})},Me=()=>{if(!y)return null;const L=y,le=y,we=t==="admin"||t==="assigned",Ae=we?[{label:i("list.stats.total"),value:L.total,color:"blue"},{label:i("list.stats.open"),value:L.open,color:"yellow"},{label:i("list.stats.inProgress"),value:L.inProgress,color:"blue"},{label:i("list.stats.onHold"),value:L.onHold,color:"yellow"},{label:i("list.stats.resolved"),value:L.resolved,color:"green"},{label:i("list.stats.closed"),value:L.closed,color:"neutral"},{label:i("list.stats.critical"),value:L.critical,color:"red"},{label:i("list.stats.highPriority"),value:L.highPriority,color:"yellow"}]:[{label:i("list.stats.total"),value:le.total,color:"blue"},{label:i("list.stats.open"),value:le.open,color:"yellow"},{label:i("list.stats.inProgress"),value:le.inProgress,color:"blue"},{label:i("list.stats.resolved"),value:le.resolved,color:"green"},{label:i("list.stats.closed"),value:le.closed,color:"neutral"}],$e={blue:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]",green:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",yellow:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",red:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",neutral:"bg-[var(--bg-secondary)] text-[var(--text-primary)] border-[var(--border-color)]"},ht=we?"lg:grid-cols-8":"lg:grid-cols-5";return e.jsx("div",{className:`grid grid-cols-2 md:grid-cols-4 ${ht} gap-4 mb-6`,children:Ae.map(rt=>e.jsxs("div",{className:`card p-4 text-center border ${$e[rt.color]}`,children:[e.jsx("div",{className:"text-2xl font-bold",children:rt.value}),e.jsx("div",{className:"text-sm opacity-80",children:rt.label})]},rt.label))})},Le=()=>e.jsxs("div",{className:"card overflow-hidden",children:[e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.number")}),he&&e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.tenant","Workspace")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.title")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.type")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.status")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.priority")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.assignee")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.comments")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.created")}),e.jsx("th",{className:"text-right p-4 font-medium",children:i("list.table.actions")})]})}),e.jsx("tbody",{children:b.map(L=>e.jsxs("tr",{className:"border-b border-[var(--border-color)] hover:bg-[var(--bg-hover)] cursor-pointer",onClick:()=>d(be(L.id)),children:[e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"font-mono text-sm",children:L.ticketNumber})}),he&&e.jsx("td",{className:"p-4",children:Ie(L)}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-medium",children:L.title}),L.isExternallyManaged&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"GLPI"})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})})}),e.jsx("td",{className:"p-4",children:e.jsx(Mt,{status:ls[L.status]||"pending",label:i(`tickets.statuses.${L.status}`,{defaultValue:L.status})})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium",style:{backgroundColor:es[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})})}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"assignedToName"in L&&L.assignedToName||"-"}),"assigneeCount"in L&&L.assigneeCount>1&&e.jsxs("span",{className:"ml-1 text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:["+",L.assigneeCount-1]})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm",children:L.commentCount})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:new Date(L.createdAt).toLocaleDateString()})}),e.jsx("td",{className:"p-4 text-right",onClick:le=>le.stopPropagation(),children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>d(be(L.id)),className:"btn btn-ghost p-2",title:i("list.actions.view"),children:e.jsx(l.Eye,{className:"w-4 h-4"})}),L.externalUrl&&e.jsx("a",{href:L.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-ghost p-2 text-[var(--info-text)]",title:"Open in GLPI",onClick:le=>le.stopPropagation(),children:e.jsx(l.ExternalLink,{className:"w-4 h-4"})}),t==="admin"&&!g&&e.jsx("button",{onClick:()=>ve(L),disabled:L.isExternallyManaged,className:"btn btn-ghost p-2 text-[var(--error-text)] disabled:opacity-50 disabled:cursor-not-allowed",title:L.isExternallyManaged?"Cannot delete externally managed tickets":i("list.actions.delete"),children:e.jsx(l.Trash2,{className:"w-4 h-4"})})]})})]},L.id))})]}),b.length===0&&!j&&e.jsxs("div",{className:"p-8 text-center text-[var(--text-secondary)]",children:[e.jsx(l.Headphones,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsxs("p",{children:[t==="admin"&&i("list.empty.admin"),t==="assigned"&&i("list.empty.assigned"),t==="user"&&i("list.empty.user")]}),t==="user"&&!g&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary mt-4",children:[e.jsx(l.Plus,{className:"w-4 h-4 mr-2"}),i("list.empty.createFirst")]})]})]}),ze=()=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[b.map(L=>e.jsxs("button",{type:"button",className:"card p-4 hover:shadow-lg cursor-pointer transition-shadow text-left w-full",onClick:()=>d(be(L.id)),children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm text-[var(--text-secondary)]",children:L.ticketNumber}),Ie(L)]}),e.jsx(Mt,{status:ls[L.status]||"pending",label:i(`tickets.statuses.${L.status}`,{defaultValue:L.status})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-medium line-clamp-2 flex-1",children:L.title}),L.isExternallyManaged&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] whitespace-nowrap",children:"GLPI"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded-[var(--radius-badge)] bg-[var(--bg-secondary)]",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})}),e.jsx("span",{className:"text-xs px-2 py-1 rounded-[var(--radius-badge)]",style:{backgroundColor:es[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-[var(--text-secondary)]",children:[e.jsx("span",{children:new Date(L.createdAt).toLocaleDateString()}),e.jsx("span",{children:i("list.comments_other",{count:L.commentCount})})]})]},L.id)),b.length===0&&!j&&e.jsxs("div",{className:"col-span-full card p-12 text-center",children:[e.jsx(l.Headphones,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsxs("p",{className:"text-[var(--text-secondary)]",children:[t==="admin"&&i("list.empty.admin"),t==="assigned"&&i("list.empty.assigned"),t==="user"&&i("list.empty.user")]}),t==="user"&&!g&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary mt-4",children:[e.jsx(l.Plus,{className:"w-4 h-4 mr-2"}),i("list.empty.createFirst")]})]})]}),et=L=>e.jsxs(ya,{onClick:()=>d(be(L.id)),isDragging:V?.id===L.id,onDragStart:()=>W(L),onDragEnd:ee,children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)] mb-1",children:[e.jsx("span",{children:L.ticketNumber}),Ie(L)]}),e.jsx("div",{className:"font-medium mb-2 line-clamp-2",children:L.title}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-[var(--radius-badge)]",style:{backgroundColor:es[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:i("list.comments_other",{count:L.commentCount})})]})]},L.id),We=()=>{const L=[{status:"Open",label:i("tickets.statuses.Open"),color:"warning"},{status:"InProgress",label:i("tickets.statuses.InProgress"),color:"default"},{status:"OnHold",label:i("tickets.statuses.OnHold"),color:"warning"},{status:"Resolved",label:i("tickets.statuses.Resolved"),color:"success"},{status:"Closed",label:i("tickets.statuses.Closed"),color:"default"}];return e.jsxs("div",{className:"space-y-3",children:[ce&&e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]",children:[e.jsx("span",{className:"text-sm text-[var(--error-text)]",children:ce}),e.jsx("button",{onClick:()=>de(null),className:"ml-auto text-[var(--error-text)] hover:opacity-70",children:"×"})]}),e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4",children:L.map(le=>{const we=b.filter($e=>$e.status===le.status),Ae=V!=null&&!me(le.status)&&V.status!==le.status;return e.jsx(va,{title:le.label,count:we.length,color:le.color,isDragOver:ue===le.status,isDropDisabled:Ae,onDragOver:$e=>te($e,le.status),onDragLeave:se,onDrop:$e=>ie($e,le.status),children:we.map(et)},le.status)})})]})},Pt=()=>!s||M.length===0?null:e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.FileEdit,{className:"w-5 h-5 text-[var(--warning-text)]"}),e.jsx("h2",{className:"font-semibold",children:i("common:drafts.title","Drafts")}),e.jsx("span",{className:"px-2 py-0.5 text-xs bg-[var(--warning-bg)] text-[var(--warning-text)] rounded-full",children:M.length})]}),e.jsx("button",{onClick:()=>K(!F),className:"btn btn-ghost text-sm",children:F?i("common:actions.hide","Hide"):i("common:actions.show","Show")})]}),F&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:M.map(L=>e.jsx("button",{type:"button",className:"p-3 bg-[var(--bg-secondary)] rounded-lg border border-[var(--warning-border)] hover:border-[var(--warning-text)] transition-colors cursor-pointer text-left w-full",onClick:()=>Ue(L),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:L.title||i("common:drafts.untitled","Untitled draft")}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-[var(--text-secondary)] flex-wrap",children:[L.tenantName&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded truncate max-w-[120px]",children:L.tenantName}),L.type&&e.jsx("span",{className:"px-1.5 py-0.5 bg-[var(--bg-tertiary)] rounded",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(l.Clock,{className:"w-3 h-3"}),Ve(L.updatedAt)]})]})]}),e.jsx("button",{onClick:le=>{le.stopPropagation(),qe(L.id)},className:"p-1 hover:bg-[var(--error-bg)] rounded text-[var(--text-secondary)] hover:text-[var(--error-text)]",title:i("common:actions.delete","Delete"),children:e.jsx(l.X,{className:"w-4 h-4"})})]})},L.id))})]}),ke=()=>t==="admin"||t==="assigned"?he?"md:grid-cols-4":"md:grid-cols-3":"md:grid-cols-2";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(l.Headphones,{className:"w-6 h-6"}),a]}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:o})]}),!g&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary flex items-center gap-2",children:[e.jsx(l.Plus,{className:"w-4 h-4"}),i("list.newTicket")]})]}),Me(),Pt(),e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("form",{onSubmit:U,className:"flex-1 flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("input",{type:"text",placeholder:i("list.searchPlaceholder"),value:R,onChange:L=>$(L.target.value),className:"input w-full pl-10"})]}),e.jsx("button",{type:"submit",className:"btn btn-secondary",children:i("list.search")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Q(!B),className:`btn ${B?"btn-primary":"btn-secondary"} flex items-center gap-2`,children:[e.jsx(l.Filter,{className:"w-4 h-4"}),i("list.filters")]}),e.jsx(ba,{viewMode:J,onChange:fe})]})]}),B&&e.jsxs("div",{className:`card p-4 grid grid-cols-1 ${ke()} gap-4`,children:[he&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.tenant","Workspace")}),e.jsxs("select",{value:Z,onChange:L=>{H(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allTenants","All Workspaces")}),m.filter(L=>L.status==="Active").map(L=>e.jsx("option",{value:L.id,children:L.name},L.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.status")}),e.jsxs("select",{value:q,onChange:L=>{C(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allStatuses")}),e.jsx("option",{value:"Open",children:i("tickets.statuses.Open")}),e.jsx("option",{value:"InProgress",children:i("tickets.statuses.InProgress")}),e.jsx("option",{value:"OnHold",children:i("tickets.statuses.OnHold")}),e.jsx("option",{value:"Resolved",children:i("tickets.statuses.Resolved")}),e.jsx("option",{value:"Closed",children:i("tickets.statuses.Closed")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.type")}),e.jsxs("select",{value:D,onChange:L=>{Y(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allTypes")}),e.jsx("option",{value:"Bug",children:i("tickets.types.Bug")}),e.jsx("option",{value:"FeatureRequest",children:i("tickets.types.FeatureRequest")}),e.jsx("option",{value:"ApplicationRequest",children:i("tickets.types.ApplicationRequest")}),e.jsx("option",{value:"Support",children:i("tickets.types.Support")}),e.jsx("option",{value:"Question",children:i("tickets.types.Question")})]})]}),(t==="admin"||t==="assigned")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.priority")}),e.jsxs("select",{value:T,onChange:L=>{z(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allPriorities")}),e.jsx("option",{value:"Low",children:i("tickets.priorities.Low")}),e.jsx("option",{value:"Medium",children:i("tickets.priorities.Medium")}),e.jsx("option",{value:"High",children:i("tickets.priorities.High")}),e.jsx("option",{value:"Critical",children:i("tickets.priorities.Critical")})]})]})]}),j?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-600)]"})}):e.jsxs(e.Fragment,{children:[J==="table"&&Le(),J==="cards"&&ze(),J==="kanban"&&We()]}),!j&&I>1&&e.jsx(ja,{page:S,totalPages:I,totalCount:k,onPageChange:N})]})}exports.ActivityTimeline=Oc;exports.AdminSidebar=$i;exports.AppHeader=wt;exports.AppLayout=ha;exports.AppSwitcher=oa;exports.AuthLayout=li;exports.AuthProvider=Nr;exports.Avatar=ji;exports.Breadcrumb=xi;exports.CreateTicketButton=ma;exports.DataTable=fi;exports.DataView=bi;exports.DocPanelProvider=Jr;exports.DocsLayout=ga;exports.DynamicRouter=Lc;exports.EntityCard=ys;exports.ErrorFallback=qr;exports.ExtendablePage=io;exports.ExtensionProvider=Wr;exports.FavoritesBar=Mc;exports.FavoritesModal=Aa;exports.FavoritesProvider=Pr;exports.FeatureGate=zi;exports.FeatureRouteGuard=js;exports.Fill=Kr;exports.Footer=vs;exports.GlobalErrorBoundary=Ur;exports.Header=bs;exports.KanbanBoard=Ci;exports.KanbanCard=ya;exports.KanbanColumn=va;exports.LanguageSwitcher=gs;exports.LicenseActivationDialog=Na;exports.LicenseContentBanner=xa;exports.LicenseGuard=Sa;exports.LicenseProvider=Cr;exports.LicenseStatusBadge=Bi;exports.ModuleSidebar=pa;exports.NetworkError=us;exports.NotificationBell=da;exports.PAGE_KEYS=_;exports.PageHeader=ki;exports.PageRegistry=O;exports.Pagination=ja;exports.PermissionMatrix=Ai;exports.ProtectedRoute=wa;exports.ProviderCard=wi;exports.PublicLayout=fa;exports.RoleBadge=Ni;exports.RouteErrorBoundary=Ui;exports.SessionProvider=_r;exports.SessionWarningModal=Fr;exports.SidebarProvider=Er;exports.SignalRProvider=Dr;exports.SlaBadge=Zc;exports.Slot=Gr;exports.SlotFillProvider=Br;exports.SmartStackProvider=co;exports.StatusBadge=Mt;exports.TemplateCard=Si;exports.ThemeCustomizer=Ri;exports.ThemeProvider=br;exports.ThemeSwitcher=Gt;exports.TicketConversation=Ta;exports.TicketDetailView=du;exports.TicketSidebar=Ra;exports.TicketsListView=mu;exports.Tooltip=ua;exports.UnderDevelopment=Ei;exports.UnlockReason=nn;exports.UserSidebar=Di;exports.ViewToggle=ba;exports.WILDCARD_PERMISSION=yr;exports.adminApi=Ne;exports.api=E;exports.apiClient=Se;exports.authApi=Dt;exports.availabilityApi=Ud;exports.browserInfoService=Qr;exports.changeLanguage=ms;exports.createAdminApi=hr;exports.createSlotFill=eo;exports.dashboardApi=Uo;exports.detectDeviceType=Ca;exports.errorContextService=$t;exports.getClientIpAddress=ka;exports.getTenantBadgeVariant=fs;exports.hasAllLicenseFeatures=wr;exports.hasFullAccess=Nt;exports.hasPermission=_n;exports.hasRouteAccess=jr;exports.logService=Te;exports.matchesWildcard=kt;exports.myTicketsApi=Fe;exports.notificationsApi=st;exports.parseUserAgent=ic;exports.rulesApi=_d;exports.skillsApi=qd;exports.slaApi=ca;exports.supportApi=je;exports.templatesApi=Lt;exports.tenantAnalyticsApi=is;exports.ticketDraftService=Ge;exports.useActivePage=oo;exports.useAuth=Pe;exports.useClientContext=po;exports.useCollapsibleState=xo;exports.useDocPanel=Bt;exports.useEntityPermissions=aa;exports.useExtensions=At;exports.useFavorites=Ke;exports.useFeatureConfig=_t;exports.useFormFieldExtensions=so;exports.useHasExtension=ro;exports.useLicense=He;exports.useNavigation=Ce;exports.usePageOverride=zt;exports.usePageTracking=ta;exports.usePermissionMatrix=yo;exports.usePermissionSync=jo;exports.useRouteConfig=ko;exports.useSessionMonitor=Or;exports.useSidebar=qt;exports.useSignalR=sa;exports.useSignalRContext=Mr;exports.useSlotFill=zr;exports.useSlotHasContent=Zn;exports.useTableColumnExtensions=to;exports.useTenant=Ee;exports.useTenantUrl=Ze;exports.useTheme=Ct;exports.useTicketSignalR=ra;exports.useTicketingProvider=ws;exports.useUserPermissions=To;exports.userApi=Ft;exports.withPageOverride=no;exports.workloadApi=Bd;
48
- //# sourceMappingURL=index-2wUhd9Lu.js.map
46
+ `)}`;window.open(h,"_blank")},className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors text-[var(--text-secondary)]",title:r("common:buttons.reportBug"),children:e.jsx(l.Bug,{className:"w-5 h-5"})}),e.jsx("button",{onClick:s,className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(l.X,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[m.map(({app:f,modules:h})=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ws,{name:f.icon||"Folder",className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:f.label})]}),e.jsx("div",{className:"space-y-1 ml-6",children:h.map(b=>{const g=i(b.id),y=!g&&!d;return e.jsxs("button",{onClick:()=>p(b,f),disabled:y,className:`w-full flex items-center gap-3 p-2.5 rounded-[var(--radius-button)] transition-all ${Mc(g,y)}`,children:[e.jsx("div",{className:`w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] ${g?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-tertiary)] text-[var(--text-secondary)]"}`,children:e.jsx(Ws,{name:b.icon||"Star",className:"w-4 h-4"})}),e.jsx("span",{className:`flex-1 text-left text-sm ${g?"font-medium text-[var(--color-accent-700)]":"text-[var(--text-primary)]"}`,children:b.label}),g&&e.jsx(l.Check,{className:"w-4 h-4 text-[var(--color-accent-600)]"})]},b.id)})})]},f.id)),m.length===0&&e.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:r("common:favorites.noModules")})]}),e.jsx("div",{className:"p-4 border-t border-[var(--border-color)]",children:e.jsx("button",{onClick:s,className:"w-full px-4 py-2 bg-[var(--color-accent-600)] text-white rounded-[var(--radius-button)] hover:bg-[var(--color-accent-700)] transition-colors font-medium",children:r("common:actions.done")})})]})})}function Oc({name:t,className:s}){const a=xt[t];return a?e.jsx(a,{className:s}):e.jsx(l.Star,{className:s})}function Fc({className:t=""}){const{t:s}=ne.useTranslation(["common"]),r=w.useNavigate(),{favorites:a,maxFavorites:o}=Ke(),{triggerExpand:c}=Ke(),{menu:i}=Ce(),[d,u]=n.useState(!1),m=o-a.length,p=h=>{if(i)for(const b of i.applications){const g=b.modules.find(y=>y.id===h.id);if(g?.sections?.length){const y=[...g.sections].sort((x,j)=>x.displayOrder-j.displayOrder)[0];if(y.route)return y.route}}return h.route},f=h=>{const b=p(h);b&&(c(),r(b))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`bg-[var(--bg-card)] border border-[var(--border-color)] rounded-[var(--radius-card)] p-4 ${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-[var(--color-accent-500)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:s("common:favorites.quickAccess")})]}),e.jsxs("button",{onClick:()=>u(!0),className:"flex items-center gap-1.5 px-2 py-1 text-xs font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)] rounded-[var(--radius-button)] transition-colors",children:[e.jsx(l.Settings2,{className:"w-3.5 h-3.5"}),s("common:favorites.manage")]})]}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-1",children:[a.map(h=>e.jsxs("button",{onClick:()=>f(h),className:"flex flex-col items-center gap-1.5 min-w-[80px] p-3 bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] rounded-[var(--radius-card)] transition-all group",title:`${h.applicationLabel} - ${h.label}`,children:[e.jsx("div",{className:"w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] bg-[var(--color-accent-100)] text-[var(--color-accent-600)] group-hover:bg-[var(--color-accent-600)] group-hover:text-white transition-colors",children:e.jsx(Oc,{name:h.icon||"Star",className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)] group-hover:text-[var(--text-primary)] truncate max-w-[70px]",children:h.label})]},h.id)),Array.from({length:m}).map((h,b)=>e.jsxs("button",{onClick:()=>u(!0),className:"flex flex-col items-center justify-center gap-1.5 min-w-[80px] p-3 border-2 border-dashed border-[var(--border-color)] hover:border-[var(--color-accent-500)] rounded-[var(--radius-card)] transition-colors group",children:[e.jsx("div",{className:"w-8 h-8 flex items-center justify-center rounded-[var(--radius-button)] bg-[var(--bg-tertiary)] text-[var(--text-muted)] group-hover:bg-[var(--color-accent-100)] group-hover:text-[var(--color-accent-600)] transition-colors",children:e.jsx(l.Plus,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs text-[var(--text-muted)] group-hover:text-[var(--text-secondary)]",children:s("common:favorites.add")})]},`empty-slot-${b}`))]})]}),e.jsx(Pa,{isOpen:d,onClose:()=>u(!1)})]})}function _c({activities:t,loading:s=!1}){return s?e.jsx("div",{className:"animate-pulse space-y-4",children:[1,2,3].map(r=>e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-8 h-8 bg-[var(--bg-secondary)] rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-4 bg-[var(--bg-secondary)] rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-3 bg-[var(--bg-secondary)] rounded w-1/4"})]})]},`skeleton-${r}`))}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(l.RefreshCcw,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"No activity recorded yet"})]}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-0.5 bg-[var(--border-color)]"}),e.jsx("div",{className:"space-y-4",children:t.map((r,a)=>e.jsx(qc,{activity:r,isLast:a===t.length-1},r.id))})]})}function qc({activity:t,isLast:s}){const{icon:r,color:a,bgColor:o}=Bc(t.action),c=r;return e.jsxs("div",{className:"relative flex gap-4 pl-0",children:[e.jsx("div",{className:`relative z-10 w-8 h-8 rounded-full flex items-center justify-center ${o}`,children:e.jsx(c,{className:`w-4 h-4 ${a}`})}),e.jsx("div",{className:"flex-1 pb-4 ",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm",children:[t.changedByUserName?e.jsx("span",{className:"font-medium",children:t.changedByUserName}):e.jsx("span",{className:"font-medium text-[var(--text-secondary)]",children:"System"})," ",e.jsx("span",{className:"text-[var(--text-secondary)]",children:Zc(t)})]}),t.fieldChanged&&t.oldValue&&t.newValue&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"px-2 py-0.5 bg-[var(--error-bg)] text-[var(--error-text)] rounded line-through",children:t.oldValue}),e.jsx(l.ArrowRight,{className:"w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("span",{className:"px-2 py-0.5 bg-[var(--success-bg)] text-[var(--success-text)] rounded",children:t.newValue})]})]}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)] whitespace-nowrap",children:ed(t.createdAt)})]})})]})}const Uc={Created:{icon:l.PlusCircle,color:"text-[var(--success-text)]",bgColor:"bg-[var(--success-bg)]"},StatusChanged:{icon:l.RefreshCcw,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},PriorityChanged:{icon:l.AlertTriangle,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},Assigned:{icon:l.UserPlus,color:"text-[var(--accent-text)]",bgColor:"bg-[var(--accent-bg)]"},Commented:{icon:l.MessageSquare,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},AttachmentAdded:{icon:l.Paperclip,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"},Resolved:{icon:l.CheckCircle,color:"text-[var(--success-text)]",bgColor:"bg-[var(--success-bg)]"},Closed:{icon:l.XCircle,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"},Reopened:{icon:l.RefreshCcw,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},SlaBreached:{icon:l.AlertTriangle,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},Escalated:{icon:l.TrendingUp,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},Updated:{icon:l.Edit,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"},Deleted:{icon:l.Trash2,color:"text-[var(--error-text)]",bgColor:"bg-[var(--error-bg)]"},OnHold:{icon:l.Pause,color:"text-[var(--warning-text)]",bgColor:"bg-[var(--warning-bg)]"},InProgress:{icon:l.Play,color:"text-[var(--info-text)]",bgColor:"bg-[var(--info-bg)]"}},zc={icon:l.RefreshCcw,color:"text-[var(--text-secondary)]",bgColor:"bg-[var(--bg-secondary)]"};function Bc(t){return Uc[t]||zc}const Gc=t=>t.oldValue&&t.newValue?`changed status from ${t.oldValue} to ${t.newValue}`:"changed the status",Kc=t=>t.oldValue&&t.newValue?`changed priority from ${t.oldValue} to ${t.newValue}`:"changed the priority",Hc=t=>t.newValue?`assigned to ${t.newValue}`:"unassigned the ticket",Vc=t=>t.newValue==="internal"?"added an internal note":"added a comment",Wc=t=>t.newValue?`added attachment: ${t.newValue}`:"added an attachment",Xc=t=>t.newValue==="response"?"Response SLA was breached":"Resolution SLA was breached",Yc=t=>t.newValue?`escalated to ${t.newValue}`:"escalated this ticket",Jc=t=>t.fieldChanged?`updated ${t.fieldChanged}`:"updated the ticket",Qc={Created:()=>"created this ticket",StatusChanged:Gc,PriorityChanged:Kc,Assigned:Hc,Commented:Vc,AttachmentAdded:Wc,Resolved:()=>"resolved this ticket",Closed:()=>"closed this ticket",Reopened:()=>"reopened this ticket",SlaBreached:Xc,Escalated:Yc,Updated:Jc,OnHold:()=>"put this ticket on hold",InProgress:()=>"started working on this ticket"};function Zc(t){const s=Qc[t.action];return s?s(t):t.action.toLowerCase()}function ed(t){const s=new Date(t),a=new Date().getTime()-s.getTime(),o=Math.floor(a/6e4),c=Math.floor(o/60),i=Math.floor(c/24);return o<1?"Just now":o<60?`${o}m ago`:c<24?`${c}h ago`:i<7?`${i}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function td({responseDueAt:t,resolutionDueAt:s,responseBreached:r,resolutionBreached:a,firstResponseAt:o,isPaused:c,responseSlaPercentage:i=0,resolutionSlaPercentage:d=0,showDetails:u=!1}){const m=new Date,p=new Date(t),f=new Date(s),h=p.getTime()-m.getTime(),b=f.getTime()-m.getTime(),g=!!o;let y="ok",x="green",j=l.CheckCircle;c?(y="paused",x="gray",j=l.Pause):r||a?(y="breached",x="red",j=l.XCircle):(!g&&h<1800*1e3||b<3600*1e3)&&(y="warning",x="yellow",j=l.AlertTriangle);const v={green:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",yellow:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",red:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",gray:"bg-[var(--bg-secondary)] text-[var(--text-secondary)] border-[var(--border-color)]"};return u?e.jsxs("div",{className:`p-3 rounded-lg border ${v[x]}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(j,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[y==="paused"&&"SLA Paused",y==="breached"&&"SLA Breached",y==="warning"&&"SLA Warning",y==="ok"&&"Within SLA"]})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"opacity-80",children:"Response"}),r&&e.jsx("span",{className:"text-[var(--error-text)] font-medium",children:"Breached"}),!r&&g&&e.jsx("span",{className:"text-[var(--success-text)] font-medium",children:"Completed"}),!r&&!g&&e.jsx("span",{children:Ys(h)})]}),!g&&!r&&e.jsx(Xs,{percentage:i})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"opacity-80",children:"Resolution"}),a?e.jsx("span",{className:"text-[var(--error-text)] font-medium",children:"Breached"}):e.jsx("span",{children:Ys(b)})]}),!a&&e.jsx(Xs,{percentage:d})]})]})]}):e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium border ${v[x]}`,children:[e.jsx(j,{className:"w-3 h-3"}),y==="paused"&&"SLA Paused",y==="breached"&&"SLA Breached",y==="warning"&&"SLA Warning",y==="ok"&&"Within SLA"]})}function Xs({percentage:t}){const s=()=>t>=90?"bg-[var(--error-text)]":t>=75?"bg-[var(--warning-text)]":"bg-[var(--success-text)]";return e.jsx("div",{className:"h-1.5 bg-white/50 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${s()}`,style:{width:`${Math.min(t,100)}%`}})})}function Ys(t){if(t<=0)return"Overdue";const s=Math.floor(t/(1e3*60)),r=Math.floor(s/60),a=Math.floor(r/24);if(a>0){const o=r%24;return o>0?`${a}d ${o}h`:`${a}d`}if(r>0){const o=s%60;return o>0?`${r}h ${o}m`:`${r}h`}return`${s}m`}const Js={Greeting:"bg-[var(--info-bg)] text-[var(--info-text)]",Acknowledgment:"bg-[var(--success-bg)] text-[var(--success-text)]",RequestInfo:"bg-[var(--warning-bg)] text-[var(--warning-text)]",InProgress:"bg-[var(--info-bg)] text-[var(--info-text)]",Resolution:"bg-[var(--accent-bg)] text-[var(--accent-text)]",Escalation:"bg-[var(--warning-bg)] text-[var(--warning-text)]",OnHold:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]",Closure:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]",Rejection:"bg-[var(--error-bg)] text-[var(--error-text)]",General:"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"},sd=[{code:"fr",label:"Français"},{code:"en",label:"English"},{code:"de",label:"Deutsch"},{code:"it",label:"Italiano"}];function rd({isOpen:t,onClose:s,onSelect:r,ticketVariables:a}){const{t:o,i18n:c}=ne.useTranslation("support"),[i,d]=n.useState([]),[u,m]=n.useState(!1),[p,f]=n.useState(null),[h,b]=n.useState(""),[g,y]=n.useState(""),[x,j]=n.useState(c.language?.substring(0,2)||"fr"),[v,S]=n.useState([]),N=n.useCallback(A=>{m(!0),Promise.all([Lt.getAll(void 0,!0,A),Lt.getCategories()]).then(([R,$])=>{d(R),S($)}).catch(console.error).finally(()=>m(!1))},[]);n.useEffect(()=>{t&&(j(c.language?.substring(0,2)||"fr"),N(c.language?.substring(0,2)||"fr"))},[t,c.language,N]);const I=A=>{j(A),N(A)};if(!t)return null;const P=i.filter(A=>{const R=!h||A.title.toLowerCase().includes(h.toLowerCase())||A.content.toLowerCase().includes(h.toLowerCase()),$=!g||A.category===g;return R&&$}),k=async A=>{try{f(A.id);const R=await Lt.render(A.id,a);r(R.content),s()}catch(R){console.error("Failed to render template:",R)}finally{f(null)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",onClick:s,onKeyDown:A=>A.key==="Escape"&&s(),role:"presentation",children:e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-xl shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col",onClick:A=>A.stopPropagation(),role:"presentation",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.FileText,{className:"w-5 h-5 text-[var(--color-primary-500)]"}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:o("templatePicker.title")})]}),e.jsx("button",{onClick:s,className:"p-1 rounded hover:bg-[var(--bg-secondary)]",children:e.jsx(l.X,{className:"w-5 h-5 text-[var(--text-secondary)]"})})]}),e.jsxs("div",{className:"p-3 space-y-2 border-b border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Globe,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("div",{className:"flex gap-1",children:sd.map(A=>e.jsx("button",{onClick:()=>I(A.code),className:`px-2 py-1 text-xs rounded transition-colors ${x===A.code?"bg-[var(--color-primary-500)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]"}`,children:A.label},A.code))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(l.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:h,onChange:A=>b(A.target.value),placeholder:o("templatePicker.searchPlaceholder"),className:"w-full pl-9 pr-3 py-2 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded-lg outline-none focus:ring-1 focus:ring-[var(--color-primary-500)]",autoFocus:!0})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("button",{onClick:()=>y(""),className:`px-2 py-1 text-xs rounded-full transition-colors ${g?"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]":"bg-[var(--color-primary-500)] text-white"}`,children:o("templatePicker.allCategories")}),v.map(A=>e.jsx("button",{onClick:()=>y(A===g?"":A),className:`px-2 py-1 text-xs rounded-full transition-colors ${A===g?"bg-[var(--color-primary-500)] text-white":`${Js[A]||"bg-[var(--bg-secondary)] text-[var(--text-secondary)]"} hover:opacity-80`}`,children:o(`templates.categories.${A}`,{defaultValue:A})},A))]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[u&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--text-tertiary)]"})}),!u&&P.length===0&&e.jsx("p",{className:"text-center py-8 text-sm text-[var(--text-tertiary)]",children:o("templatePicker.noResults")}),!u&&P.length>0&&e.jsx("div",{className:"space-y-1",children:P.map(A=>e.jsxs("button",{onClick:()=>k(A),disabled:p!==null,className:"w-full text-left p-3 rounded-lg hover:bg-[var(--bg-secondary)] transition-colors group disabled:opacity-50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full ${Js[A.category]||"bg-[var(--bg-secondary)]"}`,children:o(`templates.categories.${A.category}`,{defaultValue:A.category})}),e.jsx("span",{className:"font-medium text-sm text-[var(--text-primary)]",children:A.title}),p===A.id&&e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin ml-auto"})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] line-clamp-2",children:A.content})]},A.id))})]}),e.jsx("div",{className:"p-3 border-t border-[var(--border-color)]",children:e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center",children:o("templatePicker.selectTemplate")})})]})})}const Qs={Created:{icon:l.Clock,color:"var(--color-primary-500)",labelKey:"history.actions.Created"},StatusChanged:{icon:l.ArrowRightLeft,color:"var(--info-text)",labelKey:"history.actions.StatusChanged"},PriorityChanged:{icon:l.AlertTriangle,color:"var(--warning-text)",labelKey:"history.actions.PriorityChanged"},Assigned:{icon:l.UserPlus,color:"var(--success-text)",labelKey:"history.actions.Assigned"},Unassigned:{icon:l.UserPlus,color:"var(--text-secondary)",labelKey:"history.actions.Unassigned"},Commented:{icon:l.MessageSquare,color:"var(--color-primary-500)",labelKey:"history.actions.Commented"},InternalCommented:{icon:l.MessageSquare,color:"var(--warning-text)",labelKey:"history.actions.InternalCommented"},AttachmentAdded:{icon:l.Paperclip,color:"var(--success-text)",labelKey:"history.actions.AttachmentAdded"},AttachmentRemoved:{icon:l.Paperclip,color:"var(--error-text)",labelKey:"history.actions.AttachmentRemoved"},Resolved:{icon:l.CheckCircle,color:"var(--success-text)",labelKey:"history.actions.Resolved"},Closed:{icon:l.XCircle,color:"var(--text-secondary)",labelKey:"history.actions.Closed"},Reopened:{icon:l.RotateCcw,color:"var(--warning-text)",labelKey:"history.actions.Reopened"},Rejected:{icon:l.XCircle,color:"var(--error-text)",labelKey:"history.actions.Rejected"},SlaResponseBreached:{icon:l.AlertTriangle,color:"var(--error-text)",labelKey:"history.actions.SlaResponseBreached"},SlaResolutionBreached:{icon:l.AlertTriangle,color:"var(--error-text)",labelKey:"history.actions.SlaResolutionBreached"},Escalated:{icon:l.ArrowRightLeft,color:"var(--warning-text)",labelKey:"history.actions.Escalated"},TitleChanged:{icon:l.MessageSquare,color:"var(--text-secondary)",labelKey:"history.actions.TitleChanged"},DescriptionChanged:{icon:l.MessageSquare,color:"var(--text-secondary)",labelKey:"history.actions.DescriptionChanged"},TypeChanged:{icon:l.ArrowRightLeft,color:"var(--text-secondary)",labelKey:"history.actions.TypeChanged"},SatisfactionSubmitted:{icon:l.CheckCircle,color:"var(--success-text)",labelKey:"history.actions.SatisfactionSubmitted"}},Ta=(t,s,r)=>{const a=new Date(t),c=new Date().getTime()-a.getTime(),i=Math.floor(c/6e4),d=Math.floor(c/36e5),u=Math.floor(c/864e5);return i<1?s("history.timeAgo.now"):i<60?s("history.timeAgo.minutes",{count:i}):d<24?s("history.timeAgo.hours",{count:d}):u<7?s("history.timeAgo.days",{count:u}):a.toLocaleDateString(r,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})},ad=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,Zs=t=>t?.startsWith("image/")||!1,nd=(t,s)=>t?"px-4 py-2.5 shadow-sm rounded-2xl bg-[var(--warning-bg)] border border-[var(--warning-border)]":s?"px-4 py-2.5 shadow-sm rounded-2xl rounded-tr-md bg-[var(--color-accent-600)] text-white":"px-4 py-2.5 shadow-sm rounded-2xl rounded-tl-md bg-[var(--bg-card)] border border-[var(--border-color)]";function od(t,s,r){const a=[];(r?t:t.filter(i=>!i.isInternal)).forEach(i=>{a.push({type:"comment",id:`comment-${i.id}`,timestamp:new Date(i.createdAt),data:i})});const c=["Commented","InternalCommented"];return s.filter(i=>!c.includes(i.action)).forEach(i=>{a.push({type:"activity",id:`activity-${i.id}`,timestamp:new Date(i.createdAt),data:i})}),a.sort((i,d)=>i.timestamp.getTime()-d.timestamp.getTime()),a}function id({activity:t,t:s,locale:r}){const a=Qs[t.action]||Qs.Created,o=a.icon;return e.jsx("div",{className:"flex justify-center my-4",children:e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[var(--bg-secondary)] border border-[var(--border-color)] text-sm",children:[e.jsx(o,{className:"w-4 h-4",style:{color:a.color}}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:s(a.labelKey)}),t.newValue&&t.action==="StatusChanged"&&e.jsxs("span",{className:"font-medium text-[var(--text-primary)]",children:["→ ",t.newValue]}),t.newValue&&t.action==="Assigned"&&e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:t.newValue}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:Ta(t.createdAt,s,r)})]})})}const ld=t=>{const s=t.trim().split(/\s+/);return s.length>=2?((s[0]?.at(0)??"")+(s.at(-1)?.at(0)??"")).toUpperCase():t.slice(0,2).toUpperCase()},cd=t=>{const s=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];let r=0;for(let a=0;a<t.length;a++)r=t.charCodeAt(a)+((r<<5)-r);return s[Math.abs(r)%s.length]};function er({src:t,alt:s,className:r,onClick:a}){const[o,c]=n.useState(null),[i,d]=n.useState(!0),[u,m]=n.useState(!1);return n.useEffect(()=>{let p=!0;const f=new AbortController;return Se.get(t,{responseType:"blob",signal:f.signal}).then(h=>{if(p){const b=URL.createObjectURL(h.data);c(b),d(!1)}}).catch(()=>{p&&(m(!0),d(!1))}),()=>{p=!1,f.abort(),o&&URL.revokeObjectURL(o)}},[t]),i?e.jsx("button",{type:"button",className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,onClick:a,children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--text-tertiary)]"})}):u||!o?e.jsx("button",{type:"button",className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,onClick:a,children:e.jsx(l.Image,{className:"w-6 h-6 text-[var(--text-tertiary)]"})}):e.jsx("img",{src:o,alt:s,className:r,onClick:a})}function dd({comment:t,isOwn:s,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,t:i,locale:d}){const[u,m]=n.useState(null),p=new Date(t.createdAt).getTime(),f=a.filter(x=>{const j=new Date(x.createdAt).getTime();return Math.abs(j-p)<6e4}),h=f.filter(x=>Zs(x.contentType)),b=f.filter(x=>!Zs(x.contentType)),g=ld(t.userName),y=cd(t.userName);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex gap-3 mb-4 ${s?"flex-row-reverse":"flex-row"}`,children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0 text-white text-sm font-semibold shadow-sm",style:{backgroundColor:y},title:t.userName,children:g}),e.jsxs("div",{className:`flex flex-col max-w-[70%] ${s?"items-end":"items-start"}`,children:[e.jsxs("div",{className:`flex items-center gap-2 mb-1 ${s?"flex-row-reverse":"flex-row"}`,children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t.userName}),r&&t.isInternal&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]",children:i("conversation.internalNoteLabel")}),t.isEdited&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:i("conversation.edited")})]}),e.jsxs("div",{className:nd(t.isInternal||!1,s),children:[e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:t.content}),h.length>0&&e.jsx("div",{className:`mt-3 grid gap-2 ${h.length>1?"grid-cols-2":"grid-cols-1"}`,children:h.map(x=>e.jsxs("button",{className:"relative cursor-pointer rounded-lg overflow-hidden group",onClick:()=>m(x),type:"button",children:[e.jsx(er,{src:o(x),alt:x.fileName,className:"w-full h-32 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(l.Eye,{className:"w-6 h-6 text-white opacity-0 group-hover:opacity-100 transition-opacity"})})]},x.id))}),b.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:b.map(x=>e.jsxs("button",{onClick:()=>c(x),className:`flex items-center gap-2 w-full p-2 rounded-lg transition-colors ${s&&!t.isInternal?"bg-white/10 hover:bg-white/20":"bg-[var(--bg-secondary)] hover:bg-[var(--bg-tertiary)]"}`,children:[e.jsx(l.FileText,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs truncate flex-1 text-left",children:x.fileName}),e.jsx("span",{className:"text-xs opacity-70",children:ad(x.fileSize)}),e.jsx(l.Download,{className:"w-3.5 h-3.5"})]},x.id))})]}),e.jsx("div",{className:"text-[10px] text-[var(--text-tertiary)] mt-1 px-1",children:Ta(t.createdAt,i,d)})]})]}),u&&e.jsx("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>m(null),onKeyDown:x=>x.key==="Escape"&&m(null),role:"presentation",children:e.jsxs("div",{className:"relative max-w-4xl max-h-[90vh] w-full",children:[e.jsx("button",{onClick:()=>m(null),className:"absolute -top-10 right-0 text-white hover:text-gray-300",children:e.jsx(l.X,{className:"w-6 h-6"})}),e.jsx(er,{src:o(u),alt:u?.fileName,className:"max-w-full max-h-[80vh] mx-auto object-contain rounded-lg",onClick:x=>x.stopPropagation()}),e.jsxs("div",{className:"mt-4 flex items-center justify-center gap-4",children:[e.jsx("p",{className:"text-white text-sm",children:u.fileName}),e.jsxs("button",{onClick:x=>{x.stopPropagation(),c(u)},className:"btn btn-secondary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),i("conversation.download")]})]})]})})]})}const ud=(t,s,r)=>t?r("conversation.internalPlaceholder","Ajouter une note interne..."):s?r("conversation.supportPlaceholder","Répondre au client..."):r("conversation.clientPlaceholder","Écrire un message..."),md=t=>`flex items-end gap-2 rounded-xl border ${t?"border-[var(--warning-border)] bg-[var(--warning-bg)]/30":"border-[var(--border-color)] bg-[var(--bg-secondary)]"} p-2`,pd=(t,s)=>`p-2.5 rounded-lg transition-colors ${t?"bg-[var(--color-primary-600)] text-white hover:bg-[var(--color-primary-700)]":"bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]"} disabled:opacity-50`;function xd({isConnected:t,commentCount:s,t:r}){return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border-color)] bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.MessageSquare,{className:"w-5 h-5 text-[var(--color-accent-600)]"}),e.jsx("h2",{className:"font-semibold",children:r("conversation.title","Conversation")}),e.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["(",s,")"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",title:r(t?"conversation.realtimeActive":"conversation.realtimeInactive"),children:[t?e.jsx(l.Wifi,{className:"w-4 h-4 text-[var(--success-text)]"}):e.jsx(l.WifiOff,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:`text-xs ${t?"text-[var(--success-text)]":"text-[var(--text-tertiary)]"}`,children:r(t?"conversation.live":"conversation.offline")})]})]})}function hd({t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-[var(--text-secondary)]",children:[e.jsx(l.MessageSquare,{className:"w-12 h-12 mb-3 opacity-50"}),e.jsx("p",{children:t("conversation.empty","Aucun message pour le moment")}),e.jsx("p",{className:"text-sm mt-1",children:t("conversation.startHint","Commencez la conversation ci-dessous")})]})}function gd({timeline:t,currentUserName:s,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,messagesEndRef:i,t:d,locale:u}){return e.jsxs(e.Fragment,{children:[t.map(m=>{if(m.type==="activity")return e.jsx(id,{activity:m.data,t:d,locale:u},m.id);const p=m.data,f=p.userName===s;return e.jsx(dd,{comment:p,isOwn:f,isSupport:r,attachments:a,getAttachmentUrl:o,onDownloadAttachment:c,t:d,locale:u},m.id)}),e.jsx("div",{ref:i})]})}function fd({isInternalComment:t,onToggle:s,t:r}){return e.jsx("div",{className:"mb-2",children:e.jsxs("label",{className:"inline-flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a=>s(a.target.checked),className:"rounded border-[var(--border-color)]"}),e.jsx("span",{className:`text-sm ${t?"text-[var(--warning-text)] font-medium":"text-[var(--text-secondary)]"}`,children:r("conversation.internalNote","Note interne (invisible pour le client)")})]})})}function bd({newComment:t,onCommentChange:s,onKeyDown:r,onSend:a,isInternalComment:o,onInternalToggle:c,sending:i,isSupport:d,textareaRef:u,ticketVariables:m,onOpenTemplatePicker:p,t:f}){const h=t.trim();return e.jsxs("div",{className:"border-t border-[var(--border-color)] bg-[var(--bg-card)] p-3",children:[d&&e.jsx(fd,{isInternalComment:o,onToggle:c,t:f}),e.jsxs("div",{className:md(o),children:[e.jsx("textarea",{ref:u,value:t,onChange:b=>s(b.target.value),onKeyDown:r,placeholder:ud(o,d,f),className:"flex-1 bg-transparent border-none outline-none resize-none text-sm min-h-[24px] max-h-[150px] py-1 px-2",rows:1}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[d&&m&&p&&e.jsx("button",{onClick:p,className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--color-primary-500)] hover:bg-[var(--bg-tertiary)] transition-colors",title:f("templatePicker.buttonTitle"),children:e.jsx(l.FileText,{className:"w-4 h-4"})}),e.jsx("button",{onClick:a,disabled:!h||i,className:pd(!!h),children:i?e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin"}):e.jsx(l.Send,{className:"w-5 h-5"})})]})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-2 text-center",children:f("conversation.hint","Appuyez sur Entrée pour envoyer, Maj+Entrée pour un saut de ligne")})]})}function vd({t}){return e.jsx("div",{className:"border-t border-[var(--border-color)] bg-[var(--bg-secondary)] p-4 text-center",children:e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t("conversation.closed","Ce ticket est fermé. Aucun nouveau message ne peut être ajouté.")})})}function Ra({comments:t,activities:s,attachments:r,isSupport:a,isClosed:o,isConnected:c,currentUserName:i,ticketVariables:d,onAddComment:u,onDownloadAttachment:m,getAttachmentUrl:p}){const{t:f,i18n:h}=ne.useTranslation("support"),[b,g]=n.useState(""),[y,x]=n.useState(!1),[j,v]=n.useState(!1),[S,N]=n.useState(!1),I=n.useRef(null),P=n.useRef(null),k=od(t,s,a),A=t.filter(C=>a||!C.isInternal).length;n.useEffect(()=>{I.current?.scrollIntoView({behavior:"smooth"})},[k.length]),n.useEffect(()=>{P.current&&(P.current.style.height="auto",P.current.style.height=`${Math.min(P.current.scrollHeight,150)}px`)},[b]);const R=async()=>{if(!(!b.trim()||j))try{v(!0),await u(b,y),g(""),x(!1)}finally{v(!1)}},$=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),R())},q=C=>{g(D=>D?D+`
47
+ `+C:C)};return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx(xd,{isConnected:c,commentCount:A,t:f}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 bg-[var(--bg-primary)]",children:k.length===0?e.jsx(hd,{t:f}):e.jsx(gd,{timeline:k,currentUserName:i,isSupport:a,attachments:r,getAttachmentUrl:p,onDownloadAttachment:m,messagesEndRef:I,t:f,locale:h.language})}),o?e.jsx(vd,{t:f}):e.jsx(bd,{newComment:b,onCommentChange:g,onKeyDown:$,onSend:R,isInternalComment:y,onInternalToggle:x,sending:j,isSupport:a,textareaRef:P,ticketVariables:d,onOpenTemplatePicker:a&&d?()=>N(!0):void 0,t:f}),d&&e.jsx(rd,{isOpen:S,onClose:()=>N(!1),onSelect:q,ticketVariables:d})]})}const tr=t=>{const s=t.contentType?.toLowerCase()||"",a=t.fileName.toLowerCase().split(".").pop()||"";if(s.startsWith("image/"))return"image";if(s==="application/pdf")return"pdf";if(s.startsWith("text/")||s==="application/json")return"text";if(s.startsWith("video/"))return"video";if(s.startsWith("audio/"))return"audio";const o=["png","jpg","jpeg","gif","webp","svg","bmp","ico"],c=["txt","csv","json","md","xml","log","html","css","js","ts"],i=["mp4","webm","ogg","mov","avi"],d=["mp3","wav","ogg","aac","m4a"];return o.includes(a)?"image":a==="pdf"?"pdf":c.includes(a)?"text":i.includes(a)?"video":d.includes(a)?"audio":"unknown"},sr=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`;function yd({attachment:t,getUrl:s,onClose:r,onDownload:a}){const{t:o}=ne.useTranslation("support"),[c,i]=n.useState(1),[d,u]=n.useState(0),[m,p]=n.useState(!0),[f,h]=n.useState(null),[b,g]=n.useState(null),[y,x]=n.useState(!1),[j,v]=n.useState(null),S=n.useRef(null),N=t?tr(t):"unknown";n.useEffect(()=>{if(S.current?.id===t?.id||(S.current=t,j&&URL.revokeObjectURL(j),i(1),u(0),p(!0),h(null),g(null),v(null),x(!1),!t))return;const $=tr(t),q=s(t),C=new AbortController;return $==="text"?Se.get(q,{signal:C.signal,responseType:"text"}).then(D=>{g(D.data),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(h(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):$==="image"||$==="video"||$==="audio"?Se.get(q,{signal:C.signal,responseType:"blob"}).then(D=>{const Y=URL.createObjectURL(D.data);v(Y),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(h(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):$==="pdf"?Se.get(q,{signal:C.signal,responseType:"blob"}).then(D=>{const Y=URL.createObjectURL(D.data);v(Y),p(!1)}).catch(D=>{D.name==="CanceledError"||D.code==="ERR_CANCELED"||(h(o("filePreview.loadError","Impossible de charger le fichier")),p(!1))}):p(!1),()=>{C.abort()}},[t,s,o]),n.useEffect(()=>()=>{j&&URL.revokeObjectURL(j)},[j]),n.useEffect(()=>{if(!t)return;const $=q=>{q.key==="Escape"&&(y?x(!1):r()),(q.key==="+"||q.key==="=")&&(q.preventDefault(),i(C=>Math.min(C+.25,3))),q.key==="-"&&(q.preventDefault(),i(C=>Math.max(C-.25,.25))),q.key==="r"&&!q.ctrlKey&&!q.metaKey&&(q.preventDefault(),u(C=>(C+90)%360)),q.key==="f"&&(q.preventDefault(),x(C=>!C))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[t,y,r]);const I=n.useCallback(()=>i($=>Math.min($+.25,3)),[]),P=n.useCallback(()=>i($=>Math.max($-.25,.25)),[]),k=n.useCallback(()=>u($=>($+90)%360),[]);if(!t)return null;const A=()=>{if(m&&N!=="pdf"&&N!=="image"&&N!=="video"&&N!=="audio")return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})});if(f)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center px-8",children:[e.jsx(l.AlertTriangle,{className:"w-12 h-12 text-[var(--warning-text)]"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:f}),e.jsxs("button",{onClick:()=>a(t),className:"btn btn-primary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),o("filePreview.download","Télécharger le fichier")]})]});switch(N){case"image":return e.jsx("div",{className:"relative flex items-center justify-center h-full overflow-auto p-4",children:j?e.jsx("img",{src:j,alt:t.fileName,className:"max-w-none transition-transform duration-200",style:{transform:`scale(${c}) rotate(${d}deg)`,maxHeight:y?"90vh":"70vh"},onClick:$=>$.stopPropagation()}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"pdf":return e.jsx("div",{className:"h-full w-full",children:j?e.jsx("iframe",{src:`${j}#toolbar=1&navpanes=0`,className:"w-full h-full border-0 rounded",title:t.fileName}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"text":return e.jsx("div",{className:"h-full overflow-auto p-4",children:e.jsx("pre",{className:"text-sm text-[var(--text-primary)] font-mono whitespace-pre-wrap break-words bg-[var(--bg-secondary)] p-4 rounded-lg",children:b})});case"video":return e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:j?e.jsx("video",{src:j,controls:!0,className:"max-w-full max-h-[70vh] rounded-lg",children:o("filePreview.videoNotSupported","Votre navigateur ne supporte pas la lecture vidéo.")}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-white"})})});case"audio":return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-6 p-4",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-[var(--color-accent-500)]/20 flex items-center justify-center",children:e.jsx(l.File,{className:"w-12 h-12 text-[var(--color-accent-500)]"})}),e.jsx("p",{className:"text-lg font-medium text-[var(--text-primary)]",children:t.fileName}),j?e.jsx("audio",{src:j,controls:!0,className:"w-full max-w-md",children:o("filePreview.audioNotSupported","Votre navigateur ne supporte pas la lecture audio.")}):e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})})]});default:return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-center px-8",children:[e.jsx("div",{className:"w-20 h-20 rounded-xl bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(l.FileText,{className:"w-10 h-10 text-[var(--text-tertiary)]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-medium text-[var(--text-primary)] mb-1",children:t.fileName}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:sr(t.fileSize)})]}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:o("filePreview.noPreview","Aperçu non disponible pour ce type de fichier")}),e.jsxs("button",{onClick:()=>a(t),className:"btn btn-primary",children:[e.jsx(l.Download,{className:"w-4 h-4 mr-2"}),o("filePreview.download","Télécharger le fichier")]})]})}},R=e.jsxs("div",{className:"fixed inset-0 bg-black/90 backdrop-blur-sm flex flex-col z-[100]",onClick:r,onKeyDown:$=>{$.key==="Escape"&&r()},role:"dialog","aria-modal":"true","aria-label":t.fileName,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-black/50",onClick:$=>$.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(l.FileText,{className:"w-5 h-5 text-white/70 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-white font-medium truncate",children:t.fileName}),e.jsx("p",{className:"text-xs text-white/50",children:sr(t.fileSize)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[N==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:P,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.zoomOut","Zoom arrière (-)")||"Zoom out",children:e.jsx(l.ZoomOut,{className:"w-5 h-5"})}),e.jsxs("span",{className:"text-white/70 text-sm min-w-[3rem] text-center",children:[Math.round(c*100),"%"]}),e.jsx("button",{onClick:I,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.zoomIn","Zoom avant (+)")||"Zoom in",children:e.jsx(l.ZoomIn,{className:"w-5 h-5"})}),e.jsx("button",{onClick:k,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.rotate","Rotation (R)")||"Rotate",children:e.jsx(l.RotateCw,{className:"w-5 h-5"})}),e.jsx("div",{className:"w-px h-6 bg-white/20 mx-1"})]}),e.jsx("button",{onClick:()=>x($=>!$),className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.fullscreen","Plein écran (F)")||"Fullscreen",children:y?e.jsx(l.Minimize2,{className:"w-5 h-5"}):e.jsx(l.Maximize2,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>a(t),className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("filePreview.download","Télécharger")||"Download",children:e.jsx(l.Download,{className:"w-5 h-5"})}),e.jsx("button",{onClick:r,className:"p-2 text-white/70 hover:text-white hover:bg-white/10 rounded-lg transition-colors",title:o("common.close","Fermer (Échap)")||"Close",children:e.jsx(l.X,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",onClick:$=>$.stopPropagation(),children:A()}),e.jsx("div",{className:"px-4 py-2 bg-black/50 text-center",onClick:$=>$.stopPropagation(),children:e.jsx("p",{className:"text-xs text-white/40",children:o("filePreview.shortcuts","Raccourcis: Échap pour fermer • +/- pour zoomer • R pour rotation • F pour plein écran")})})]});return Ft.createPortal(R,document.body)}const rr={Low:{bg:"var(--info-bg)",text:"var(--info-text)"},Medium:{bg:"var(--warning-bg)",text:"var(--warning-text)"},High:{bg:"var(--error-bg)",text:"var(--error-text)"},Critical:{bg:"var(--error-text)",text:"white"}},jd=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,ar=t=>t?.startsWith("image/")||!1;function Nd({src:t,alt:s,className:r,onClick:a}){const[o,c]=n.useState(null),[i,d]=n.useState(!0),[u,m]=n.useState(!1);return n.useEffect(()=>{let p=!0;const f=new AbortController;return Se.get(t,{responseType:"blob",signal:f.signal}).then(h=>{if(p){const b=URL.createObjectURL(h.data);c(b),d(!1)}}).catch(()=>{p&&(m(!0),d(!1))}),()=>{p=!1,f.abort(),o&&URL.revokeObjectURL(o)}},[t]),i?e.jsx("div",{className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,children:e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--text-tertiary)]"})}):u||!o?e.jsx("div",{className:`flex items-center justify-center bg-[var(--bg-secondary)] ${r}`,children:e.jsx(l.Image,{className:"w-4 h-4 text-[var(--text-tertiary)]"})}):e.jsx("img",{src:o,alt:s,className:r,onClick:a})}const wd={Created:{icon:l.Plus,color:"var(--success-text)"},StatusChanged:{icon:l.Edit,color:"var(--info-text)"},Assigned:{icon:l.UserCheck,color:"var(--color-accent-600)"},Unassigned:{icon:l.User,color:"var(--warning-text)"},Commented:{icon:l.MessageSquare,color:"var(--text-secondary)"},PriorityChanged:{icon:l.AlertTriangle,color:"var(--warning-text)"},Resolved:{icon:l.CheckCircle,color:"var(--success-text)"},Closed:{icon:l.XCircle,color:"var(--text-tertiary)"},Reopened:{icon:l.RotateCcw,color:"var(--warning-text)"},Escalated:{icon:l.ArrowUpCircle,color:"var(--error-text)"},Started:{icon:l.Play,color:"var(--info-text)"},Paused:{icon:l.Pause,color:"var(--warning-text)"}},Sd=(t,s)=>{const r=new Date(t),o=new Date().getTime()-r.getTime(),c=Math.floor(o/6e4),i=Math.floor(o/36e5),d=Math.floor(o/864e5);return c<1?s("sidebar.timeAgo.justNow",{defaultValue:"Just now"}):c<60?s("sidebar.timeAgo.minutes",{count:c}):i<24?s("sidebar.timeAgo.hours",{count:i}):d<7?s("sidebar.timeAgo.days",{count:d}):r.toLocaleDateString(void 0,{day:"numeric",month:"short"})},Cd=10*1024*1024,nr=[".pdf",".doc",".docx",".xls",".xlsx",".txt",".csv",".zip",".png",".jpg",".jpeg",".gif",".webp"];function lt({section:t,icon:s,title:r,count:a,isExpanded:o,onToggle:c}){return e.jsxs("button",{onClick:()=>c(t),className:"w-full flex items-center gap-2 py-2 px-3 hover:bg-[var(--bg-secondary)] transition-colors rounded-lg",children:[o?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)]"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx(s,{className:"w-4 h-4 text-[var(--color-accent-600)]"}),e.jsx("span",{className:"font-medium text-sm flex-1 text-left",children:r}),a!==void 0&&a>0&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:a})]})}function Ea({ticket:t,attachments:s,activities:r,isSupport:a,saving:o,uploading:c,layout:i="compact",onAssign:d,onStatusChange:u,onResolve:m,onCloseTicket:p,onReopen:f,onEscalate:h,onDownloadAttachment:b,onUploadAttachment:g,getAttachmentUrl:y}){const{t:x}=ne.useTranslation("support"),[j,v]=n.useState(new Set(i==="grid"?["info","system","errors","attachments","actions","history"]:["info","attachments","actions"])),[S,N]=n.useState(null),[I,P]=n.useState(!1),[k,A]=n.useState(null),R=n.useRef(null),$=n.useCallback(M=>{if(M.type.startsWith("image/"))return!0;const re="."+M.name.split(".").pop()?.toLowerCase();return nr.includes(re)},[]),q=n.useCallback(async M=>{if(!(!M||!g)){A(null);for(let re=0;re<M.length;re++){const F=M[re];if(F.size>Cd){A(x("sidebar.fileTooLarge","File too large (max 10 MB)"));continue}if(!$(F)){A(x("sidebar.fileTypeNotAllowed","File type not allowed"));continue}try{await g(F)}catch{A(x("sidebar.uploadError","Upload failed"))}}}},[g,$,x]),C=n.useCallback(M=>{M.preventDefault(),M.stopPropagation()},[]),D=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!0)},[]),Y=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!1)},[]),T=n.useCallback(M=>{M.preventDefault(),M.stopPropagation(),P(!1),q(M.dataTransfer.files)},[q]),z=s.filter(M=>ar(M.contentType)),Z=s.filter(M=>!ar(M.contentType)),H=t.clientContext,J=n.useCallback(M=>{v(re=>{const F=new Set(re);return F.has(M)?F.delete(M):F.add(M),F})},[]),fe=t.status==="Closed"||t.status==="Rejected",B=i==="grid",Q=B?"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] overflow-hidden":"px-2 py-1 border-b border-[var(--border-color)]";return e.jsxs("div",{className:B?"":"h-full flex flex-col bg-[var(--bg-card)] overflow-hidden",children:[e.jsxs("div",{className:B?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4":"flex-1 overflow-y-auto",children:[e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"info",icon:l.FileText,title:x("details.info","Informations"),isExpanded:j.has("info"),onToggle:J}),j.has("info")&&e.jsx("div",{className:"px-3 pb-3",children:e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.type","Type")}),e.jsx("dd",{className:"font-medium",children:x(`tickets.types.${t.type}`,{defaultValue:t.type})})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.priority","Priority")}),e.jsx("dd",{children:e.jsx("span",{className:"inline-block px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:rr[t.priority]?.bg,color:rr[t.priority]?.text},children:x(`tickets.priorities.${t.priority}`,{defaultValue:t.priority})})})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.createdBy","Created by")}),e.jsx("dd",{children:t.createdByName||x("sidebar.unknown","Unknown")})]}),e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.assignedTo","Assigned to")}),e.jsxs("dd",{className:"flex flex-col items-end gap-1",children:[(t?.assignees?.length??0)>0?e.jsx("div",{className:"space-y-1",children:t?.assignees?.map(M=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-sm",children:M.fullName}),M.isPrimary&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-[var(--color-accent-600)] text-white rounded-md",children:x("sidebar.primary","primary")}),M.assignedViaGroupName&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-[var(--bg-secondary)] text-[var(--text-secondary)] rounded-md",children:["(",x("sidebar.viaGroup",{groupName:M.assignedViaGroupName}),")"]})]},M.userId))}):e.jsx("span",{className:"text-sm",children:x("sidebar.unassigned","Unassigned")}),d&&e.jsx("button",{onClick:d,className:"p-1 hover:bg-[var(--bg-secondary)] rounded mt-1",children:e.jsx(l.UserPlus,{className:"w-3.5 h-3.5 text-[var(--color-accent-600)]"})})]})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.createdAt","Created")}),e.jsx("dd",{className:"text-xs",children:new Date(t.createdAt).toLocaleString()})]}),t.updatedAt&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--text-tertiary)]",children:x("sidebar.updatedAt","Updated")}),e.jsx("dd",{className:"text-xs",children:new Date(t.updatedAt).toLocaleString()})]})]})})]}),a&&H&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"system",icon:l.Monitor,title:x("details.systemInfo","Infos système"),isExpanded:j.has("system"),onToggle:J}),j.has("system")&&e.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[H?.sourceUrl&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Globe,{className:"w-3 h-3"}),x("sidebar.url","URL")]}),e.jsx("p",{className:"text-xs font-mono break-all",children:H.sourceUrl})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[H.browser&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Globe,{className:"w-3 h-3"}),x("sidebar.browser","Browser")]}),e.jsx("p",{className:"text-xs font-medium",children:H.browser.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:H.browser.version})]}),H.os&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Laptop,{className:"w-3 h-3"}),x("sidebar.os","OS")]}),e.jsx("p",{className:"text-xs font-medium",children:H.os.name}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:H.os.version})]})]}),H.device&&e.jsxs("div",{className:"p-2 bg-[var(--bg-secondary)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text-tertiary)] mb-1",children:[e.jsx(l.Smartphone,{className:"w-3 h-3"}),x("sidebar.device","Device")]}),e.jsxs("p",{className:"text-xs font-medium",children:[H.device.type||x("sidebar.defaultDeviceType","Desktop"),H.device.screenResolution&&` • ${H.device.screenResolution}`]})]})]})]}),a&&H&&(H?.recentErrors?.length??0)>0&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"errors",icon:l.Bug,title:x("details.errors","Erreurs"),count:H?.recentErrors?.length??0,isExpanded:j.has("errors"),onToggle:J}),j.has("errors")&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:H?.recentErrors?.slice(0,3).map((M,re)=>e.jsxs("div",{className:"p-2 bg-[var(--error-bg)]/30 border border-[var(--error-border)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(l.AlertTriangle,{className:"w-3 h-3 text-[var(--error-text)]"}),M.component&&e.jsx("span",{className:"text-xs px-1 py-0.5 bg-[var(--bg-secondary)] rounded",children:M.component})]}),e.jsx("p",{className:"text-xs font-medium text-[var(--error-text)] line-clamp-2",children:M.message})]},`error-${re}`))})]}),e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"attachments",icon:l.File,title:x("details.attachments","Pièces jointes"),count:s.length,isExpanded:j.has("attachments"),onToggle:J}),j.has("attachments")&&e.jsxs("div",{className:"px-3 pb-3",children:[z.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)] mb-2 flex items-center gap-1",children:[e.jsx(l.Image,{className:"w-3 h-3"}),x("sidebar.images","Images")," (",z.length,")"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:z.map(M=>e.jsxs("button",{type:"button",className:"relative cursor-pointer rounded overflow-hidden border border-[var(--border-color)] aspect-square group",onClick:()=>N(M),children:[e.jsx(Nd,{src:y(M),alt:M.fileName,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(l.Eye,{className:"w-5 h-5 text-white opacity-0 group-hover:opacity-100 transition-opacity"})})]},M.id))})]}),Z.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)] mb-2 flex items-center gap-1",children:[e.jsx(l.FileText,{className:"w-3 h-3"}),x("sidebar.documents","Documents")," (",Z.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:Z.map(M=>e.jsxs("div",{className:"flex items-center gap-2 w-full p-2 bg-[var(--bg-secondary)] rounded-lg hover:bg-[var(--bg-tertiary)] transition-colors group",children:[e.jsxs("button",{onClick:()=>N(M),className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[e.jsx(l.FileText,{className:"w-4 h-4 text-[var(--text-secondary)] flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs block truncate",children:M.fileName}),e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)]",children:jd(M.fileSize)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>N(M),className:"p-1 rounded hover:bg-[var(--bg-primary)] transition-colors opacity-0 group-hover:opacity-100",title:x("filePreview.view","Aperçu")||"View",children:e.jsx(l.Eye,{className:"w-3.5 h-3.5 text-[var(--color-accent-500)]"})}),e.jsx("button",{onClick:()=>b(M),className:"p-1 rounded hover:bg-[var(--bg-primary)] transition-colors",title:x("filePreview.download","Télécharger")||"Download",children:e.jsx(l.Download,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})})]})]},M.id))})]}),a&&!fe&&g&&e.jsxs("div",{children:[e.jsx("input",{ref:R,type:"file",multiple:!0,onChange:M=>q(M.target.files),accept:nr.join(","),className:"hidden"}),e.jsx("div",{className:`border-2 border-dashed rounded-lg p-3 text-center transition-colors cursor-pointer ${I?"border-[var(--color-accent-500)] bg-[var(--color-accent-500)]/10":"border-[var(--border-color)] hover:border-[var(--color-accent-500)]"}`,onClick:()=>R.current?.click(),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),R.current?.click())},role:"button",tabIndex:0,onDragOver:C,onDragEnter:D,onDragLeave:Y,onDrop:T,children:c?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-1",children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:x("sidebar.uploading","Uploading...")})]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Plus,{className:"w-5 h-5 mx-auto mb-1 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:I?x("sidebar.dropHere","Drop here"):x("sidebar.addFile","Add a file")})]})}),k&&e.jsx("p",{className:"mt-2 text-xs text-[var(--error-text)]",children:k})]}),s.length===0&&(!a||fe||!g)&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center py-2",children:x("sidebar.noAttachments","No attachments")})]})]}),a&&!B&&e.jsxs("div",{className:Q,children:[e.jsx(lt,{section:"actions",icon:l.User,title:x("details.actions","Actions"),isExpanded:j.has("actions"),onToggle:J}),j.has("actions")&&e.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[t.status==="Open"&&u&&e.jsx("button",{onClick:()=>u("InProgress"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:x("sidebar.startProcessing","Start processing")}),t.status==="InProgress"&&e.jsxs(e.Fragment,{children:[u&&e.jsx("button",{onClick:()=>u("OnHold"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:x("sidebar.putOnHold","Put on hold")}),m&&e.jsxs("button",{onClick:m,disabled:o,className:"btn btn-primary w-full text-sm py-2",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4 mr-2"}),x("sidebar.resolve","Resolve")]})]}),t.status==="OnHold"&&u&&e.jsx("button",{onClick:()=>u("InProgress"),disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:x("sidebar.resume","Resume")}),t.status==="Resolved"&&p&&e.jsxs("button",{onClick:p,disabled:o,className:"btn btn-primary w-full text-sm py-2",children:[e.jsx(l.XCircle,{className:"w-4 h-4 mr-2"}),x("sidebar.closeTicket","Close ticket")]}),(t.status==="Closed"||t.status==="Resolved")&&f&&e.jsxs("button",{onClick:f,disabled:o,className:"btn btn-secondary w-full text-sm py-2",children:[e.jsx(l.RotateCcw,{className:"w-4 h-4 mr-2"}),x("sidebar.reopen","Reopen")]}),!fe&&h&&e.jsxs("button",{onClick:h,disabled:o,className:"btn w-full text-sm py-2 border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[e.jsx(l.ArrowUpCircle,{className:"w-4 h-4 mr-2"}),x("sidebar.escalate","Escalate")]}),o&&e.jsx("div",{className:"flex items-center justify-center py-2",children:e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--color-primary-600)]"})})]})]}),a&&r.length>0&&e.jsxs("div",{className:B?Q:"px-2 py-1",children:[e.jsx(lt,{section:"history",icon:l.History,title:x("details.history","History"),count:r.length,isExpanded:j.has("history"),onToggle:J}),j.has("history")&&e.jsx("div",{className:"px-3 pb-3",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-3 top-2 bottom-2 w-0.5 bg-[var(--border-color)]"}),e.jsx("div",{className:"space-y-3",children:r.slice(0,10).map((M,re)=>{const F=wd[M.action]||{icon:l.Edit,color:"var(--text-secondary)"},K=F.icon,V=x(`history.actions.${M.action}`,{defaultValue:M.action});return e.jsxs("div",{className:"relative flex gap-3 pl-1",children:[e.jsx("div",{className:"relative z-10 w-5 h-5 rounded-full flex items-center justify-center bg-[var(--bg-card)] border border-[var(--border-color)]",style:{color:F.color},children:e.jsx(K,{className:"w-3 h-3"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-medium text-[var(--text-primary)]",children:[V,M.newValue&&e.jsxs("span",{className:"text-[var(--text-secondary)] font-normal",children:[" → ",M.newValue]})]}),e.jsx("p",{className:"text-[10px] text-[var(--text-tertiary)]",children:Sd(M.createdAt,x)})]})]},`activity-${M.action}-${re}`)})}),r.length>10&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] text-center mt-3",children:x("sidebar.moreActivities",{count:r.length-10})})]})})]})]}),e.jsx(yd,{attachment:S,getUrl:y,onClose:()=>N(null),onDownload:b})]})}const es=["Open","InProgress","Resolved","Closed"],Je={Open:{label:"Ouvert",icon:l.Clock,color:"var(--warning-text)"},InProgress:{label:"En cours",icon:l.Play,color:"var(--info-text)"},OnHold:{label:"En attente",icon:l.Pause,color:"var(--warning-text)"},Resolved:{label:"Résolu",icon:l.CheckCircle,color:"var(--success-text)"},Closed:{label:"Fermé",icon:l.XCircle,color:"var(--text-secondary)"},Rejected:{label:"Rejeté",icon:l.AlertTriangle,color:"var(--error-text)"}},kd=t=>new Date(t).toLocaleDateString("fr-FR",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}),Ad=t=>t.isActive?"ring-4 ring-opacity-30":t.isPast?"bg-[var(--success-bg)]":"bg-[var(--bg-secondary)] border-2 border-[var(--border-color)]",Pd=(t,s)=>{if(t.isActive)return s.color;if(t.isPast)return"var(--success-bg)"},Td=(t,s)=>({backgroundColor:Pd(t,s),boxShadow:t.isActive?`0 0 0 4px ${s.color}30`:void 0}),Rd=t=>t.isActive?"white":t.isPast?"var(--success-text)":"var(--text-tertiary)",Ed=t=>t.isActive?"text-[var(--text-primary)]":t.isPast?"text-[var(--success-text)]":"text-[var(--text-tertiary)]",Id=(t,s)=>t.isPast?"var(--success-text)":t.isActive?s.color:"var(--border-color)";function Ld({step:t,config:s}){const r=t.icon;return e.jsx("div",{className:`relative w-10 h-10 rounded-full flex items-center justify-center shrink-0 transition-all ${Ad(t)}`,style:Td(t,s),children:e.jsx(r,{className:"w-5 h-5",style:{color:Rd(t)}})})}function $d({step:t}){return e.jsxs("div",{className:"mt-2 text-center",children:[e.jsx("p",{className:`text-xs font-medium ${Ed(t)}`,children:t.label}),t.date&&(t.isActive||t.isPast)&&e.jsx("p",{className:"text-[10px] text-[var(--text-secondary)] mt-0.5",children:kd(t.date)})]})}function Dd({step:t,config:s,isLast:r}){return r?null:e.jsx("div",{className:"flex-1 h-0.5 mx-2 mt-[-20px]",style:{backgroundColor:Id(t,s)}})}function Md({currentStatus:t,createdAt:s,resolvedAt:r,closedAt:a,activities:o=[],isSupport:c,saving:i,assignees:d,onAssign:u,onStatusChange:m,onResolve:p,onCloseTicket:f,onReopen:h,onEscalate:b}){const{t:g}=ne.useTranslation("support"),y=t==="Rejected",x=o.some(S=>S.action==="Reopened"),v=(()=>{if(y)return[{status:"Open",label:g("tickets.statuses.Open",Je.Open.label),icon:Je.Open.icon,date:s,isActive:!1,isPast:!0,isFuture:!1},{status:"Rejected",label:g("tickets.statuses.Rejected",Je.Rejected.label),icon:Je.Rejected.icon,date:a,isActive:!0,isPast:!1,isFuture:!1}];const S=es.indexOf(t),N=[],I={Open:s};o.filter(k=>k.action==="StatusChanged"&&k.newValue).forEach(k=>{k.newValue&&(I[k.newValue]=k.createdAt)}),r&&(I.Resolved=r),a&&(I.Closed=a);const P=o.some(k=>k.action==="StatusChanged"&&k.newValue==="OnHold");if(es.forEach(k=>{const A=Je[k],R=k===t?S:es.indexOf(k),$=k===t,q=R<S,C=R>S;N.push({status:k,label:g(`tickets.statuses.${k}`,{defaultValue:A.label}),icon:A.icon,date:I[k],isActive:$,isPast:q,isFuture:C})}),P){const k=N.findIndex(A=>A.status==="Resolved");N.splice(k,0,{status:"OnHold",label:g("tickets.statuses.OnHold",Je.OnHold.label),icon:Je.OnHold.icon,date:I.OnHold,isActive:t==="OnHold",isPast:t!=="OnHold"&&t!=="Open"&&t!=="InProgress",isFuture:!1})}return N})();return e.jsx("div",{className:"w-full px-4 py-2 bg-[var(--bg-card)] border-b border-[var(--border-color)]",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[v.map((S,N)=>{const I=Je[S.status],P=N===v.length-1;return e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsxs("div",{className:`flex flex-col items-center ${S.isFuture?"opacity-40":""}`,children:[e.jsx(Ld,{step:S,config:I}),e.jsx($d,{step:S})]}),e.jsx(Dd,{step:S,config:I,isLast:P})]},S.status)}),x&&e.jsxs("div",{className:"ml-2 flex items-center gap-1 text-[10px] text-[var(--warning-text)] shrink-0",children:[e.jsx(l.RotateCcw,{className:"w-3 h-3"}),e.jsx("span",{children:g("workflow.reopened","Réouvert")})]})]}),c&&e.jsx("div",{className:"w-px h-12 bg-[var(--border-color)] shrink-0"}),c&&e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[(d?.length??0)>0?e.jsxs("div",{className:"flex items-center -space-x-1.5",title:d?.map(S=>S.fullName).join(", "),children:[d?.slice(0,3).map(S=>e.jsx("div",{className:"w-7 h-7 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white text-[10px] font-medium border-2 border-[var(--bg-card)]",title:`${S.fullName}${S.isPrimary?` (${g("workflow.primary","principal")})`:""}${S.assignedViaGroupName?` (${g("workflow.viaGroup","via")} ${S.assignedViaGroupName})`:""}`,children:S.fullName.charAt(0).toUpperCase()},S.userId)),(d?.length??0)>3&&e.jsxs("div",{className:"w-7 h-7 rounded-full bg-[var(--bg-tertiary)] flex items-center justify-center text-[10px] font-medium text-[var(--text-secondary)] border-2 border-[var(--bg-card)]",children:["+",(d?.length??0)-3]})]}):e.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)] italic",children:g("workflow.notAssigned","Non assigné")}),u&&e.jsx("button",{onClick:u,className:"w-7 h-7 rounded-full border border-dashed border-[var(--border-color)] flex items-center justify-center hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-secondary)] transition-colors",title:g("workflow.assign","Assigner"),children:e.jsx(l.UserPlus,{className:"w-3.5 h-3.5 text-[var(--color-accent-600)]"})})]}),i&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin text-[var(--color-primary-600)]"}),t==="Open"&&m&&e.jsxs("button",{onClick:()=>m("InProgress"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Play,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.start","Commencer")]}),t==="InProgress"&&m&&e.jsxs("button",{onClick:()=>m("OnHold"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Pause,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.hold","En attente")]}),t==="InProgress"&&p&&e.jsxs("button",{onClick:p,disabled:i,className:"btn btn-primary btn-sm text-xs",children:[e.jsx(l.CheckCircle,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.resolve","Résoudre")]}),t==="OnHold"&&m&&e.jsxs("button",{onClick:()=>m("InProgress"),disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.Play,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.resume","Reprendre")]}),t==="Resolved"&&f&&e.jsxs("button",{onClick:f,disabled:i,className:"btn btn-primary btn-sm text-xs",children:[e.jsx(l.XCircle,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.close","Fermer")]}),(t==="Closed"||t==="Resolved")&&h&&e.jsxs("button",{onClick:h,disabled:i,className:"btn btn-secondary btn-sm text-xs",children:[e.jsx(l.RotateCcw,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.reopen","Réouvrir")]}),t!=="Closed"&&t!=="Rejected"&&b&&e.jsxs("button",{onClick:b,disabled:i,className:"btn btn-sm text-xs border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[e.jsx(l.ArrowUpCircle,{className:"w-3.5 h-3.5 mr-1"}),g("workflow.actions.escalate","Escalader")]})]})]})})}const ct={Proposed:{border:"border-blue-500",bg:"bg-blue-50",text:"text-blue-900"},Approved:{border:"border-green-500",bg:"bg-green-50",text:"text-green-900"},Rejected:{border:"border-red-500",bg:"bg-red-50",text:"text-red-900"},Superseded:{border:"border-gray-400",bg:"bg-gray-50",text:"text-gray-700"}},or={Proposed:l.Clock,Approved:l.CheckCircle,Rejected:l.XCircle,Superseded:l.AlertCircle};function Od({ticketId:t,solutions:s,activeSolution:r,mode:a,onProposeSolution:o,onApproveSolution:c,onRejectSolution:i,isLoading:d}){const{t:u}=ne.useTranslation("support"),[m,p]=n.useState(!1),[f,h]=n.useState(""),[b,g]=n.useState(!1),[y,x]=n.useState(""),[j,v]=n.useState(!1),[S,N]=n.useState(!1),I=n.useCallback(async()=>{if(!(!f.trim()||!o)){p(!0);try{await o(f),h("")}finally{p(!1)}}},[f,o]),P=n.useCallback(()=>{v(!0)},[]),k=n.useCallback(async()=>{if(!(!y.trim()||!i)){g(!0);try{await i(y),x(""),v(!1)}finally{g(!1)}}},[y,i]),A=R=>{if(!R.autoCloseAt)return null;const $=new Date(R.autoCloseAt),q=new Date,C=$.getTime()-q.getTime(),D=Math.ceil(C/(1e3*60*60*24));return D>0?D:0};return s.length===0&&a==="support"&&o?e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] p-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:u("solution.proposeSolution","Propose Solution")}),e.jsx("textarea",{value:f,onChange:R=>h(R.target.value),placeholder:u("solution.enterSolution","Enter solution..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:m||d}),e.jsx("div",{className:"mt-3 flex gap-2 justify-end",children:e.jsx("button",{onClick:I,disabled:!f.trim()||m||d,className:"btn btn-primary flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.proposeSolution","Propose Solution")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Send,{className:"w-4 h-4"}),u("solution.proposeSolution","Propose Solution")]})})})]}):e.jsxs("div",{className:"space-y-4",children:[r&&e.jsxs("div",{className:`rounded-lg border-2 p-4 ${ct[r.status].border} ${ct[r.status].bg}`,children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const R=or[r.status];return e.jsx(R,{className:`w-5 h-5 ${ct[r.status].text}`})})(),e.jsxs("div",{children:[e.jsx("h4",{className:`font-semibold ${ct[r.status].text}`,children:u(`solution.status.${r.status.toLowerCase()}`,r.status)}),e.jsxs("p",{className:"text-sm opacity-75",children:[u("solution.solutionNumber","Solution #"),r.solutionNumber," - ",u("solution.proposedBy","Proposed by")," ",r.proposedByUserName||"Unknown"]})]})]})}),e.jsx("div",{className:"bg-white/50 rounded p-3 mb-3 max-h-32 overflow-y-auto",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:r.content})}),r.status==="Proposed"&&r.autoCloseAt&&e.jsx("div",{className:"mb-3 p-2 bg-yellow-100/50 border-l-2 border-yellow-500 rounded",children:e.jsxs("p",{className:"text-sm",children:[u("solution.autoCloseWarning","Will be auto-approved in")," ",e.jsxs("strong",{children:[A(r)," ",u("solution.autoCloseCountdown","days")]}),r.autoCloseWarningSent&&e.jsxs(e.Fragment,{children:[" (",u("solution.warningEmailSent","warning email sent"),")"]})]})}),r.status==="Approved"&&e.jsxs("p",{className:"text-sm",children:[u("solution.approvedBy","Approved by")," ",r.approvedByUserName||"Unknown"," on ",r.approvedAt&&new Date(r.approvedAt).toLocaleDateString()]}),r.status==="Rejected"&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm mb-2",children:[u("solution.rejectedBy","Rejected by")," ",r.rejectedByUserName||"Unknown"," on ",r.rejectedAt&&new Date(r.rejectedAt).toLocaleDateString()]}),r.rejectionReason&&e.jsxs("p",{className:"text-sm bg-white/30 p-2 rounded italic",children:[u("solution.rejectionReason","Reason"),": ",r.rejectionReason]})]}),a==="client"&&r.status==="Proposed"&&e.jsxs("div",{className:"mt-3 flex gap-2 justify-end",children:[e.jsx("button",{onClick:P,disabled:b||d,className:"btn btn-secondary text-sm py-1.5",children:u("solution.rejectSolution","Reject")}),e.jsx("button",{onClick:c,disabled:b||d||!c,className:"btn btn-primary text-sm py-1.5 flex items-center gap-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}),u("solution.acceptSolution","Approve")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.CheckCircle,{className:"w-3 h-3"}),u("solution.acceptSolution","Approve")]})})]})]}),a==="support"&&o&&!r&&e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] p-4",children:[e.jsx("h4",{className:"font-semibold mb-3",children:u("solution.proposeSolution","Propose Solution")}),e.jsx("textarea",{value:f,onChange:R=>h(R.target.value),placeholder:u("solution.enterSolution","Enter solution..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:m||d}),e.jsx("div",{className:"mt-3 flex gap-2 justify-end",children:e.jsx("button",{onClick:I,disabled:!f.trim()||m||d,className:"btn btn-primary flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.proposeSolution","Propose Solution")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.Send,{className:"w-4 h-4"}),u("solution.proposeSolution","Propose Solution")]})})})]}),s.length>1&&e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("button",{onClick:()=>N(!S),className:"w-full flex items-center gap-2 p-4 hover:bg-[var(--bg-secondary)] transition-colors",children:[S?e.jsx(l.ChevronDown,{className:"w-4 h-4 text-[var(--text-tertiary)]"}):e.jsx(l.ChevronRight,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsxs("h4",{className:"font-semibold",children:[u("solution.solutionHistory","Solution History")," (",s.length,")"]})]}),S&&e.jsx("div",{className:"border-t border-[var(--border-color)] p-4 space-y-3",children:s.map(R=>e.jsxs("div",{className:`rounded-lg border p-3 ${ct[R.status].border}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const $=or[R.status];return e.jsx($,{className:`w-4 h-4 ${ct[R.status].text}`})})(),e.jsx("span",{className:"text-sm font-medium",children:u(`solution.status.${R.status.toLowerCase()}`,R.status)}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:["#",R.solutionNumber]})]}),e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:new Date(R.proposedAt).toLocaleDateString()})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 line-clamp-2",children:R.content}),e.jsxs("p",{className:"text-xs text-[var(--text-tertiary)]",children:[u("solution.proposedBy","Proposed by")," ",R.proposedByUserName||"Unknown"]})]},R.id))})]}),s.length===0&&a==="client"&&e.jsx("div",{className:"text-center py-6 text-[var(--text-tertiary)]",children:e.jsx("p",{children:u("solution.noSolutions","No solutions proposed yet")})}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[var(--bg-card)] rounded-lg shadow-lg p-6 w-96 max-w-[90vw]",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:u("solution.rejectSolution","Reject Solution")}),e.jsx("textarea",{value:y,onChange:R=>x(R.target.value),placeholder:u("solution.enterRejectReason","Enter reason for rejection..."),className:"w-full p-3 border border-[var(--border-color)] rounded-lg bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none",rows:4,disabled:b}),e.jsxs("div",{className:"mt-4 flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>v(!1),disabled:b,className:"btn btn-secondary",children:u("common:cancel","Cancel")}),e.jsx("button",{onClick:k,disabled:!y.trim()||b,className:"btn btn-primary flex items-center gap-2",children:b?e.jsxs(e.Fragment,{children:[e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}),u("solution.rejectSolution","Reject")]}):e.jsxs(e.Fragment,{children:[e.jsx(l.XCircle,{className:"w-4 h-4"}),u("solution.rejectSolution","Reject")]})})]})]})})]})}const Fd={getCached:t=>E.get(`/api/support/ai-routing/cached/${t}`)},Ia={analyze:t=>E.get(`/api/support/ai-routing/analyze/${t}`)},La={summarize:t=>E.post(`/api/support/ai-routing/summarize/${t}`)},$a={applyRouting:(t,s)=>E.post(`/api/support/ai-routing/apply/${t}`,s)},ir=Object.freeze(Object.defineProperty({__proto__:null,analyzeApi:Ia,cachedAiApi:Fd,routingApi:$a,summarizeApi:La},Symbol.toStringTag,{value:"Module"}));function Da({classification:t}){const{t:s}=ne.useTranslation("support");if(!t)return null;const r=o=>o>.8?"bg-[var(--success-bg)] text-[var(--success-text)]":o>.5?"bg-[var(--warning-bg)] text-[var(--warning-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]",a=o=>o>.8?s("aiClassification.confidence.high"):o>.5?s("aiClassification.confidence.medium"):s("aiClassification.confidence.low");return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)]",children:s(`tickets.types.${t.suggestedType}`)}),e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-[var(--warning-bg)] text-[var(--warning-text)]",children:s(`tickets.priorities.${t.suggestedPriority}`)}),e.jsxs("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${r(t.confidenceScore)}`,children:[a(t.confidenceScore)," (",Math.round(t.confidenceScore*100),"%)"]})]})}function Ma(t){const[s,r]=n.useState(t?.initialData??null),[a,o]=n.useState(!1),[c,i]=n.useState(null),d=n.useRef(null),u=n.useRef(!1);n.useEffect(()=>(u.current=!1,()=>{u.current=!0,d.current?.abort()}),[]);const m=n.useCallback(async h=>{d.current?.abort();const b=new AbortController;d.current=b,o(!0),i(null);try{const g=await h(b.signal);!u.current&&!b.signal.aborted&&r(g)}catch(g){!u.current&&!b.signal.aborted&&i(g instanceof Error?g.message:"Unknown error")}finally{!u.current&&!b.signal.aborted&&o(!1)}},[]),p=n.useCallback(()=>{d.current?.abort(),u.current||o(!1)},[]),f=n.useCallback(()=>{r(null),i(null),o(!1)},[]);return{data:s,loading:a,error:c,execute:m,cancel:p,reset:f}}function _d({ticketId:t,cachedClassification:s,cachedRouting:r,cachedGeneratedAt:a,processing:o,onProcessingStart:c,onProcessingEnd:i}){const{t:d}=ne.useTranslation("support"),u=s||r?{classification:s??null,routingSuggestion:r??null,isAiAvailable:!0,errorCode:null,errorMessage:null}:void 0,{data:m,loading:p,error:f,execute:h,reset:b}=Ma({initialData:u}),[g,y]=n.useState(!1),x=n.useCallback(async()=>{c?.(),await h(async()=>{const N=await Ia.analyze(t);return i?.(),N})},[t,h,c,i]),j=n.useCallback(async()=>{if(m?.routingSuggestion)try{y(!0);const N={assignToUserId:m.routingSuggestion.suggestedAgents[0]?.userId,assignToGroupId:m.routingSuggestion.suggestedGroupId??void 0,applyPriorityAdjustment:m.routingSuggestion.priorityAdjustment!==null};await $a.applyRouting(t,N),b()}catch{}finally{y(!1)}},[m,b,d]);if(f&&!m)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:d("aiRouting.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:f}),e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("common:actions.retry")]})]})]})});if(!m)return o?e.jsx("div",{className:"card p-4 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--info-text)] flex-shrink-0"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:d("aiRouting.processing")})]})}):e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm flex items-center gap-2",children:[p?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Sparkles,{className:"w-4 h-4"}),d("aiRouting.analyze")]});if(p&&!m)return e.jsx("div",{className:"card p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})});if(!m.isAiAvailable){const N=m.errorCode?`aiRouting.errors.${m.errorCode}`:null,I=N&&d(N)!==N?d(N):m.errorMessage??d("aiRouting.notConfigured");return e.jsx("div",{className:"card p-4 bg-[var(--warning-bg)]/10 border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:I})]})})}if(!m.classification&&!m.routingSuggestion)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:d("aiRouting.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:m.errorMessage??d("aiRouting.notAvailable")}),e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("common:actions.retry")]})]})]})});const v=m?.routingSuggestion,S=a&&!p?new Date(a):null;return e.jsx("div",{className:"card p-6 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"space-y-4",children:[m?.errorMessage&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-[var(--warning-text)] bg-[var(--warning-bg)]/20 rounded p-2",children:[e.jsx(l.AlertCircle,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),e.jsx("p",{children:m.errorMessage})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.Sparkles,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0 mt-1"}),e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:d("aiRouting.suggestedRouting")}),e.jsxs("button",{onClick:x,disabled:p,className:"btn btn-secondary btn-sm flex items-center gap-1",title:d("aiRouting.refresh"),children:[p?e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(l.RefreshCw,{className:"w-3 h-3"}),d("aiRouting.refresh")]})]}),S&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-3",children:d("aiRouting.generatedAt",{date:S.toLocaleString()})}),e.jsxs("div",{className:"space-y-3",children:[m?.classification&&e.jsx(Da,{classification:m.classification}),(v?.suggestedAgents?.length??0)>0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-2",children:d("aiRouting.suggestedAgents")}),e.jsx("div",{className:"space-y-1",children:v?.suggestedAgents?.map(N=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium",children:N.userName||N.userId}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[Math.round(N.matchScore*100),"%"]})]},N.userId))})]}),v?.suggestedGroupName&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-1",children:d("aiRouting.suggestedGroup")}),e.jsx("p",{className:"font-medium",children:v.suggestedGroupName})]}),v?.reasoning&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-[var(--text-secondary)] mb-1",children:d("aiRouting.reasoning")}),e.jsx("p",{className:"italic",children:v.reasoning})]}),e.jsx("div",{className:"pt-3 border-t border-[var(--border-color)] flex gap-2",children:v&&e.jsxs("button",{onClick:j,disabled:g,className:"btn btn-primary btn-sm flex items-center gap-2 flex-1 justify-center",children:[g?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Check,{className:"w-4 h-4"}),d("aiRouting.apply")]})})]})]})]})]})})}function qd({ticketId:t,cachedSummary:s,cachedGeneratedAt:r,processing:a,onProcessingStart:o,onProcessingEnd:c}){const{t:i}=ne.useTranslation("support"),d=s?{summary:s,isAiAvailable:!0,errorCode:null,errorMessage:null}:void 0,{data:u,loading:m,error:p,execute:f}=Ma({initialData:d}),h=n.useCallback(async()=>{o?.(),await f(async()=>{const y=await La.summarize(t);return c?.(),y})},[t,f,o,c]);if(p&&!u)return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:i("aiSummary.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:p}),e.jsxs("button",{onClick:h,disabled:m,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("common:actions.retry")]})]})]})});if(!u)return a?e.jsx("div",{className:"card p-4 bg-[var(--info-bg)]/10 border border-[var(--info-border)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--info-text)] flex-shrink-0"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:i("aiSummary.processing")})]})}):e.jsxs("button",{onClick:h,disabled:m,className:"btn btn-secondary btn-sm flex items-center gap-2",children:[m?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Zap,{className:"w-4 h-4"}),i("aiSummary.generate")]});if(m&&!u)return e.jsx("div",{className:"card p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})});if(!u.isAiAvailable){const y=u.errorCode?`aiRouting.errors.${u.errorCode}`:null,x=y&&i(y)!==y?i(y):u.errorMessage??i("aiRouting.notConfigured");return e.jsx("div",{className:"card p-4 bg-[var(--warning-bg)]/10 border border-[var(--warning-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--warning-text)] flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:x})]})})}if(!u.summary){const y=u.errorCode?`aiSummary.errors.${u.errorCode}`:null,x=y&&i(y)!==y?i(y):u.errorMessage??i("aiSummary.error");return e.jsx("div",{className:"card p-4 bg-[var(--error-bg)]/10 border border-[var(--error-border)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(l.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-[var(--error-text)] font-medium mb-1",children:i("aiSummary.error")}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:x}),e.jsxs("button",{onClick:h,disabled:m,className:"btn btn-secondary btn-sm mt-2 flex items-center gap-1",children:[e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("common:actions.retry")]})]})]})})}const b=u.summary,g=r&&!m?new Date(r):null;return e.jsxs("div",{className:"card p-6 bg-[var(--bg-secondary)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(l.Zap,{className:"w-5 h-5"}),i("aiSummary.title")]}),e.jsxs("button",{onClick:h,disabled:m,className:"btn btn-secondary btn-sm flex items-center gap-1",title:i("aiSummary.refresh"),children:[m?e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"}):e.jsx(l.RefreshCw,{className:"w-3 h-3"}),i("aiSummary.refresh")]})]}),g&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mb-3",children:i("aiSummary.generatedAt",{date:g.toLocaleString()})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.summary")}),e.jsx("p",{className:"text-sm",children:b.summary})]}),b.keyPoints.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.keyPoints")}),e.jsx("ul",{className:"list-disc list-inside space-y-1",children:b.keyPoints.map((y,x)=>e.jsx("li",{className:"text-sm",children:y},`point-${x}`))})]}),b.sentiment&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.sentiment")}),e.jsx("p",{className:"text-sm",children:b.sentiment})]}),(b.blockers?.length??0)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-2 font-medium",children:i("aiSummary.blockers")}),e.jsx("ul",{className:"space-y-2",children:b.blockers?.map((y,x)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded bg-[var(--warning-bg)] text-[var(--warning-text)] flex-shrink-0 mt-0.5",children:x+1}),e.jsx("span",{className:"text-sm",children:y})]},`blocker-${x}`))})]})]})]})}const je={tickets:{getAll:t=>E.get("/api/support/tickets",{params:t}),getMyTickets:t=>E.get("/api/support/tickets/my-assigned",{params:t}),getById:t=>E.get(`/api/support/tickets/${t}`),create:t=>E.post("/api/support/tickets",t),update:(t,s)=>E.put(`/api/support/tickets/${t}`,s),updateStatus:(t,s)=>E.patch(`/api/support/tickets/${t}/status`,{status:s}),assign:(t,s,r,a)=>E.patch(`/api/support/tickets/${t}/assign`,{assignedToUserId:s,userIds:r,groupIds:a}),resolve:(t,s)=>E.patch(`/api/support/tickets/${t}/resolve`,{resolution:s}),close:t=>E.patch(`/api/support/tickets/${t}/close`),reopen:t=>E.patch(`/api/support/tickets/${t}/reopen`),addComment:(t,s)=>E.post(`/api/support/tickets/${t}/comments`,s),delete:t=>E.delete(`/api/support/tickets/${t}`),getStats:t=>E.get("/api/support/tickets/stats",{params:{tenantId:t}}),getMyAssignedStats:()=>E.get("/api/support/tickets/my-assigned/stats"),getAttachmentUrl:(t,s)=>`/api/support/tickets/${t}/attachments/${s}`,downloadAttachment:(t,s)=>E.get(`/api/support/tickets/${t}/attachments/${s}`,{responseType:"blob"}),uploadAttachment:(t,s)=>{const r=new FormData;return r.append("file",s),E.post(`/api/support/tickets/${t}/attachments`,r,{headers:{"Content-Type":"multipart/form-data"}})},getActivities:(t,s=10)=>E.get(`/api/support/tickets/${t}/activities`,{params:{limit:s}}),getTicketingProvider:()=>E.get("/api/support/tickets/provider"),getGlpiSyncStats:()=>E.get("/api/support/tickets/glpi-sync-stats"),proposeSolution:(t,s)=>E.post(`/api/support/tickets/${t}/solutions`,{content:s}),getSolutions:t=>E.get(`/api/support/tickets/${t}/solutions`),approveSolution:t=>E.patch(`/api/support/tickets/${t}/solutions/approve`),rejectSolution:(t,s)=>E.patch(`/api/support/tickets/${t}/solutions/reject`,{reason:s})}},Fe={getAll:t=>E.get("/api/support/my-tickets",{params:t}),getById:t=>E.get(`/api/support/my-tickets/${t}`),create:t=>E.post("/api/support/my-tickets",t),update:(t,s)=>E.put(`/api/support/my-tickets/${t}`,s),addComment:(t,s)=>E.post(`/api/support/my-tickets/${t}/comments`,{content:s}),getStats:()=>E.get("/api/support/my-tickets/stats"),uploadAttachment:(t,s)=>{const r=new FormData;return r.append("file",s),E.post(`/api/support/my-tickets/${t}/attachments`,r,{headers:{"Content-Type":"multipart/form-data"}})},downloadAttachment:(t,s)=>E.get(`/api/support/my-tickets/${t}/attachments/${s}`,{responseType:"blob"}),deleteAttachment:(t,s)=>E.delete(`/api/support/my-tickets/${t}/attachments/${s}`),getActivities:(t,s=10)=>E.get(`/api/support/my-tickets/${t}/activities`,{params:{limit:s}}),getAttachmentUrl:(t,s)=>`/api/support/my-tickets/${t}/attachments/${s}`,submitSatisfaction:(t,s)=>E.post(`/api/support/my-tickets/${t}/satisfaction`,s),getSatisfaction:t=>E.get(`/api/support/my-tickets/${t}/satisfaction`),getSolutions:t=>E.get(`/api/support/my-tickets/${t}/solutions`),approveSolution:t=>E.patch(`/api/support/my-tickets/${t}/solutions/approve`),rejectSolution:(t,s)=>E.patch(`/api/support/my-tickets/${t}/solutions/reject`,{reason:s})},Ud={getAll:()=>E.get("/api/support/assignment"),getById:t=>E.get(`/api/support/assignment/${t}`),create:t=>E.post("/api/support/assignment",t),update:(t,s)=>E.put(`/api/support/assignment/${t}`,s),delete:t=>E.delete(`/api/support/assignment/${t}`),activate:t=>E.patch(`/api/support/assignment/${t}/activate`),deactivate:t=>E.patch(`/api/support/assignment/${t}/deactivate`)},zd={getAll:()=>E.get("/api/support/assignment/skills"),getByAgent:t=>E.get("/api/support/assignment/skills",{params:{userId:t}}),update:(t,s)=>E.put(`/api/support/assignment/skills/${t}`,s)},Bd={getByAgent:t=>E.get(`/api/support/assignment/availability/${t}`),update:(t,s)=>E.put(`/api/support/assignment/availability/${t}`,s)},Gd={getByTicket:(t,s=1,r=50)=>E.get("/api/support/assignment/logs",{params:{ticketId:t,page:s,pageSize:r}})},Kd={getByAgent:t=>E.get(`/api/support/assignment/workload/${t}`),getAll:()=>E.get("/api/support/assignment/workload")};function Cs(){const{currentTenant:t}=Ee(),[s,r]=n.useState(null),[a,o]=n.useState(!!t),[c,i]=n.useState(null),d=n.useCallback(async()=>{if(!t){r(null);return}o(!0),i(null);try{const u=await je.tickets.getTicketingProvider();r(u)}catch{i("Failed to load ticketing provider configuration"),r(null)}finally{o(!1)}},[t]);return n.useEffect(()=>{d()},[d]),{provider:s?.provider??"SmartStack",isGlpi:s?.provider==="Glpi",isConfigured:s?.isConfigured??!1,glpiBaseUrl:s?.glpiBaseUrl??void 0,loading:a,error:c,refresh:d}}const ds={Open:"pending",InProgress:"active",OnHold:"warning",Resolved:"active",Closed:"inactive",Rejected:"error"},lr={Low:{bg:"var(--info-bg)",text:"var(--info-text)"},Medium:{bg:"var(--warning-bg)",text:"var(--warning-text)"},High:{bg:"var(--error-bg)",text:"var(--error-text)"},Critical:{bg:"var(--error-text)",text:"white"}},Hd=["conversation","description","information","assignment","ai"],Vd={Open:"statusDescriptions.Open",InProgress:"statusDescriptions.InProgress",OnHold:"statusDescriptions.OnHold",Resolved:"statusDescriptions.Resolved",Closed:"statusDescriptions.Closed",Rejected:"statusDescriptions.Rejected"};function Wd({satisfaction:t,showRatingForm:s,ratingValue:r,ratingComment:a,submittingRating:o,onShowForm:c,onRatingChange:i,onCommentChange:d,onCancel:u,onSubmit:m,t:p}){return t?e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 mb-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500 fill-amber-500"}),p("satisfaction.yourRating","Votre évaluation")]}),e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[[1,2,3,4,5].map(f=>e.jsx(l.Star,{className:`w-5 h-5 ${f<=t.rating?"text-amber-500 fill-amber-500":"text-[var(--text-tertiary)]"}`},f)),e.jsxs("span",{className:"ml-2 text-sm text-[var(--text-secondary)]",children:[t.rating,"/5"]})]}),t.comment&&e.jsxs("p",{className:"text-sm text-[var(--text-secondary)] italic",children:['"',t.comment,'"']})]}):s?e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 mb-3",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500"}),p("satisfaction.rateTitle","Évaluez cette résolution")]}),e.jsx("div",{className:"flex items-center gap-1 mb-3",children:[1,2,3,4,5].map(f=>e.jsx("button",{type:"button",onClick:()=>i(f),className:"p-1 hover:scale-110 transition-transform",children:e.jsx(l.Star,{className:`w-7 h-7 transition-colors ${f<=r?"text-amber-500 fill-amber-500":"text-[var(--text-tertiary)] hover:text-amber-300"}`})},f))}),e.jsx("textarea",{value:a,onChange:f=>d(f.target.value),placeholder:p("satisfaction.commentPlaceholder","Commentaire (optionnel)..."),className:"input w-full h-20 mb-3 text-sm"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:u,className:"btn btn-secondary btn-sm",children:p("common.cancel","Annuler")}),e.jsxs("button",{onClick:m,disabled:r===0||o,className:"btn btn-primary btn-sm",children:[o?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-1"}):e.jsx(l.Star,{className:"w-4 h-4 mr-1"}),p("satisfaction.submit","Envoyer")]})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2",children:[e.jsx(l.Star,{className:"w-4 h-4 text-amber-500"}),p("satisfaction.askTitle","Comment évaluez-vous cette résolution ?")]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:p("satisfaction.askDescription","Votre avis nous aide à améliorer notre service.")})]}),e.jsxs("button",{onClick:c,className:"btn btn-primary btn-sm",children:[e.jsx(l.Star,{className:"w-4 h-4 mr-1"}),p("satisfaction.rateButton","Évaluer")]})]})}function Xd({show:t,resolution:s,saving:r,onResolutionChange:a,onClose:o,onResolve:c,t:i}){return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:i("resolve.title","Proposer une solution")}),e.jsx("textarea",{value:s,onChange:d=>a(d.target.value),placeholder:i("resolve.placeholder","Décrivez la résolution..."),className:"input w-full h-32 mb-4"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:o,className:"btn btn-secondary",children:i("common.cancel","Annuler")}),e.jsxs("button",{onClick:c,disabled:!s.trim()||r,className:"btn btn-primary",children:[r&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),i("resolve.confirm","Proposer")]})]})]})}):null}function Yd({show:t,filteredUsers:s,selectedUserIds:r,selectedGroupIds:a,groups:o,userSearchQuery:c,groupSearchQuery:i,loadingUsers:d,loadingGroups:u,saving:m,activeTab:p,onUserSearchChange:f,onGroupSearchChange:h,onSelectUser:b,onSelectGroup:g,onTabChange:y,onClose:x,onAssign:j,t:v}){const S=n.useMemo(()=>{if(!i.trim())return o;const N=i.toLowerCase();return o.filter(I=>I.name.toLowerCase().includes(N))},[o,i]);return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4 max-h-[80vh] flex flex-col",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:v("assign.title","Assigner le ticket")}),e.jsxs("div",{className:"flex gap-2 mb-4 border-b border-[var(--border-color)]",children:[e.jsx("button",{onClick:()=>y("users"),className:`pb-2 px-3 font-medium transition-colors border-b-2 ${p==="users"?"border-[var(--color-accent-500)] text-[var(--color-accent-500)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:v("assign.tabUsers","Utilisateurs")}),e.jsx("button",{onClick:()=>y("groups"),className:`pb-2 px-3 font-medium transition-colors border-b-2 ${p==="groups"?"border-[var(--color-accent-500)] text-[var(--color-accent-500)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:v("assign.tabGroups","Groupes")})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(l.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:p==="users"?c:i,onChange:N=>p==="users"?f(N.target.value):h(N.target.value),placeholder:p==="users"?v("assign.searchUserPlaceholder","Rechercher un utilisateur..."):v("assign.searchGroupPlaceholder","Rechercher un groupe..."),className:"input w-full pl-10",autoFocus:!0})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto mb-4",children:[p==="users"&&e.jsx(e.Fragment,{children:d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:s.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-[var(--text-tertiary)]",children:v("assign.noUsersFound","Aucun utilisateur trouvé")}):s.map(N=>e.jsxs("button",{onClick:()=>b(N.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[var(--bg-secondary)] transition-colors border-t border-[var(--border-color)] first:border-t-0 ${r.includes(N.id)?"bg-[var(--color-accent-500)]/10":""}`,children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border-color)] rounded flex items-center justify-center flex-shrink-0",children:r.includes(N.id)&&e.jsx("div",{className:"w-3 h-3 bg-[var(--color-accent-500)] rounded-sm"})}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white font-medium text-sm flex-shrink-0",children:N.fullName.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:N.fullName}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] truncate",children:N.email})]})]},N.id))})}),p==="groups"&&e.jsx(e.Fragment,{children:u?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:S.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-[var(--text-tertiary)]",children:v("assign.noGroupsFound","Aucun groupe trouvé")}):S.map(N=>e.jsxs("button",{onClick:()=>g(N.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[var(--bg-secondary)] transition-colors border-t border-[var(--border-color)] first:border-t-0 ${a.includes(N.id)?"bg-[var(--color-accent-500)]/10":""}`,children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[var(--border-color)] rounded flex items-center justify-center flex-shrink-0",children:a.includes(N.id)&&e.jsx("div",{className:"w-3 h-3 bg-[var(--color-accent-500)] rounded-sm"})}),e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-500)] flex items-center justify-center text-white font-medium text-sm flex-shrink-0",children:N.name.charAt(0).toUpperCase()}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:N.name})}),e.jsx("span",{className:"text-xs px-2 py-1 rounded bg-[var(--bg-tertiary)] text-[var(--text-secondary)] flex-shrink-0",children:N.memberCount})]},N.id))})})]}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-4 px-3 py-2 bg-[var(--bg-secondary)] rounded",children:v("assign.selectedSummary","{{userCount}} utilisateur(s), {{groupCount}} groupe(s) sélectionné(s)",{userCount:r.length,groupCount:a.length})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{x(),f(""),h("")},className:"btn btn-secondary",children:v("common.cancel","Annuler")}),e.jsxs("button",{onClick:j,disabled:m||d||u,className:"btn btn-primary",children:[m&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),v("assign.confirm","Assigner")]})]})]})}):null}const Jd=["Supervisor","Manager","Director"];function Qd({show:t,escalationLevel:s,escalationReason:r,saving:a,onLevelChange:o,onReasonChange:c,onClose:i,onEscalate:d,t:u}){return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50",children:e.jsxs("div",{className:"card w-full max-w-lg p-6 m-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--warning-bg)] flex items-center justify-center",children:e.jsx(l.ArrowUpCircle,{className:"w-5 h-5 text-[var(--warning-text)]"})}),e.jsx("h2",{className:"text-xl font-bold",children:u("escalate.title")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:u("escalate.description")}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:u("escalate.level")}),e.jsx("div",{className:"space-y-2",children:Jd.map(m=>e.jsxs("button",{onClick:()=>o(m),className:`w-full flex items-center gap-3 px-4 py-3 text-left rounded-lg border transition-colors ${s===m?"border-[var(--warning-border)] bg-[var(--warning-bg)]":"border-[var(--border-color)] hover:bg-[var(--bg-secondary)]"}`,children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center ${s===m?"border-[var(--warning-text)]":"border-[var(--border-color)]"}`,children:s===m&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-[var(--warning-text)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:u(`escalate.levels.${m}`)}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)]",children:u(`escalate.levels.${m}Desc`)})]})]},m))})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:u("escalate.reason")}),e.jsx("textarea",{value:r,onChange:m=>c(m.target.value),placeholder:u("escalate.reasonPlaceholder"),className:"input w-full h-24"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{i(),o("Supervisor"),c("")},className:"btn btn-secondary",children:u("common.cancel")}),e.jsxs("button",{onClick:d,disabled:a,className:"btn border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:bg-[var(--warning-border)]",children:[a&&e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin mr-2"}),e.jsx(l.ArrowUpCircle,{className:"w-4 h-4 mr-2"}),u("escalate.confirm")]})]})]})}):null}function Zd(t){return{id:t.id,ticketNumber:t.ticketNumber,title:t.title,description:t.description,type:t.type,status:t.status,priority:t.priority,createdByName:t.createdBy?.fullName,assignedToName:t.assignedTo?.fullName,resolution:t.resolution,resolvedAt:t.resolvedAt,closedAt:t.closedAt,assignees:t.assignees,comments:t.comments.map(s=>({id:s.id,userName:s.userName,content:s.content,isInternal:s.isInternal,isEdited:s.isEdited,createdAt:s.createdAt})),attachments:t.attachments.map(s=>({id:s.id,fileName:s.fileName,contentType:s.contentType,fileSize:s.fileSize,createdAt:s.createdAt})),createdAt:t.createdAt,updatedAt:t.updatedAt,clientContext:t.clientContext,externalProvider:t.externalProvider,externalId:t.externalId,externalUrl:t.externalUrl,isExternallyManaged:t.isExternallyManaged,solutions:t.solutions,activeSolution:t.activeSolution,hasPendingSolution:t.hasPendingSolution}}function eu(t){return{id:t.id,ticketNumber:t.ticketNumber,title:t.title,description:t.description,type:t.type,status:t.status,priority:t.priority,resolution:t.resolution,resolvedAt:t.resolvedAt,closedAt:t.closedAt,comments:t.comments.map(s=>({id:s.id,userName:s.userName,content:s.content,isInternal:!1,isEdited:s.isEdited,createdAt:s.createdAt})),attachments:t.attachments.map(s=>({id:s.id,fileName:s.fileName,fileSize:s.fileSize,createdAt:s.createdAt})),createdAt:t.createdAt,updatedAt:t.updatedAt,solutions:t.solutions,activeSolution:t.activeSolution,hasPendingSolution:t.hasPendingSolution}}function cr(t,s){return s==="support"?Zd(t):eu(t)}const tu=()=>{const[t,s]=n.useState(null),[r,a]=n.useState(!0),[o,c]=n.useState(!1),[i,d]=n.useState(!1),[u,m]=n.useState(null),[p,f]=n.useState([]),[h,b]=n.useState(!1),[g,y]=n.useState({title:"",priority:"Medium"}),[x,j]=n.useState(!1),[v,S]=n.useState(!1),[N,I]=n.useState(!1),[P,k]=n.useState(""),[A,R]=n.useState("Supervisor"),[$,q]=n.useState(""),[C,D]=n.useState([]),[Y,T]=n.useState([]),[z,Z]=n.useState([]),[H,J]=n.useState(!1),[fe,B]=n.useState(""),[Q,M]=n.useState(""),[re,F]=n.useState([]),[K,V]=n.useState(!1),[ae,ue]=n.useState("users"),[G,ce]=n.useState(null),[de,he]=n.useState(!1),[pe,ye]=n.useState(0),[qe,Ue]=n.useState(""),[Ve,U]=n.useState(!1);return{ticket:t,setTicket:s,loading:r,setLoading:a,saving:o,setSaving:c,uploading:i,setUploading:d,error:u,setError:m,activities:p,setActivities:f,isEditing:h,setIsEditing:b,editForm:g,setEditForm:y,showAssignModal:x,setShowAssignModal:j,showResolveModal:v,setShowResolveModal:S,showEscalateModal:N,setShowEscalateModal:I,resolution:P,setResolution:k,escalationLevel:A,setEscalationLevel:R,escalationReason:$,setEscalationReason:q,users:C,setUsers:D,selectedUserIds:Y,setSelectedUserIds:T,selectedGroupIds:z,setSelectedGroupIds:Z,loadingUsers:H,setLoadingUsers:J,userSearchQuery:fe,setUserSearchQuery:B,groupSearchQuery:Q,setGroupSearchQuery:M,groups:re,setGroups:F,loadingGroups:K,setLoadingGroups:V,assignModalTab:ae,setAssignModalTab:ue,satisfaction:G,setSatisfaction:ce,showRatingForm:de,setShowRatingForm:he,ratingValue:pe,setRatingValue:ye,ratingComment:qe,setRatingComment:Ue,submittingRating:Ve,setSubmittingRating:U}},su=(t,s)=>t?s?.email||"":(s?.firstName&&s?.lastName?`${s.firstName} ${s.lastName}`:s?.email)||"",ru=(t,s,r)=>{const a=s.get("tab");t==="conversation"?a&&(s.delete("tab"),r(s,{replace:!0})):a!==t&&r({tab:t},{replace:!0})},au=(t,s)=>{const r=t.get("tab");return r&&s.includes(r)?r:"conversation"};function nu({ticket:t,isSupport:s,isEditing:r,saving:a,editForm:o,error:c,onEditToggle:i,onSave:d,onEditFormChange:u,onErrorClear:m,t:p}){return e.jsxs("div",{className:"flex-shrink-0 border-b border-[var(--border-color)] bg-[var(--bg-card)] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>window.history.back(),className:"btn btn-ghost p-2",children:e.jsx(l.ArrowLeft,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-sm text-[var(--text-secondary)]",children:t.ticketNumber}),t.externalId&&t.externalUrl&&e.jsxs("a",{href:t.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] hover:opacity-80",children:[e.jsx(l.ExternalLink,{className:"w-3 h-3"}),"GLPI #",t.externalId]}),e.jsx(Ot,{status:ds[t.status]||"pending",label:t.status}),e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:lr[t.priority]?.bg,color:lr[t.priority]?.text},children:t.priority})]}),s&&r?e.jsx("input",{type:"text",value:o.title,onChange:f=>u({...o,title:f.target.value}),className:"input w-full text-lg font-bold"}):e.jsx("h1",{className:"text-lg font-bold truncate",children:t.title})]}),e.jsx("div",{className:"flex items-center gap-2",children:s&&r?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>i(!1),className:"btn btn-ghost p-2",children:e.jsx(l.X,{className:"w-5 h-5"})}),e.jsx("button",{onClick:d,disabled:a,className:"btn btn-primary",children:a?e.jsx(l.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(l.Save,{className:"w-4 h-4"})})]}):e.jsx(e.Fragment,{children:s&&!t.isExternallyManaged&&e.jsx("button",{onClick:()=>i(!0),className:"btn btn-ghost p-2",title:"Modifier",children:e.jsx(l.Edit2,{className:"w-5 h-5"})})})})]}),c&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(l.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"text-sm flex-1",children:c}),e.jsx("button",{onClick:m,className:"p-1 hover:bg-[var(--error-border)] rounded",children:e.jsx(l.X,{className:"w-4 h-4"})})]}),t.isExternallyManaged&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--info-bg)] border border-[var(--info-border)] flex items-center gap-3",children:[e.jsx(l.ShieldAlert,{className:"w-5 h-5 text-[var(--info-text)] flex-shrink-0"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm font-medium text-[var(--info-text)]",children:p("glpi.readOnlyBanner","This ticket is managed by GLPI and is read-only.")})}),t.externalUrl&&e.jsxs("a",{href:t.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-sm bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] hover:opacity-80 flex items-center gap-1.5",children:[e.jsx(l.ExternalLink,{className:"w-4 h-4"}),p("glpi.viewInGlpi","View in GLPI")]})]})]})}function ou({ticket:t,isSupport:s,satisfaction:r,showRatingForm:a,ratingValue:o,ratingComment:c,submittingRating:i,onShowRatingForm:d,onRatingChange:u,onCommentChange:m,onCancelRating:p,onSubmitRating:f,t:h}){return e.jsxs(e.Fragment,{children:[!s&&e.jsx("div",{className:"mt-3 p-3 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:h(Vd[t.status]||"statusDescriptions.InProgress")})}),t.resolution&&e.jsxs("div",{className:"mt-3 p-4 rounded-lg bg-[var(--success-bg)] border border-[var(--success-border)]",children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2 text-[var(--success-text)] mb-1",children:[e.jsx(l.CheckCircle,{className:"w-4 h-4"}),h("resolution.title","Résolution")]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.resolution})]}),!s&&(t.status==="Resolved"||t.status==="Closed")&&e.jsx("div",{className:"mt-3 p-4 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:e.jsx(Wd,{satisfaction:r,showRatingForm:a,ratingValue:o,ratingComment:c,submittingRating:i,onShowForm:d,onRatingChange:u,onCommentChange:m,onCancel:p,onSubmit:f,t:h})})]})}function iu({activeTab:t,commentCount:s,isSupport:r,assigneeCount:a,onTabChange:o,t:c}){const i=[{id:"conversation",icon:l.MessageSquare,label:c("tabs.conversation"),badge:s},{id:"description",icon:l.FileText,label:c("tabs.description"),badge:0},{id:"information",icon:l.Info,label:c("tabs.information"),badge:0},...r?[{id:"assignment",icon:l.Users,label:c("tabs.assignment"),badge:a},{id:"ai",icon:l.Sparkles,label:c("tabs.ai"),badge:0}]:[]];return e.jsx("div",{className:"flex-shrink-0 flex border-b border-[var(--border-color)] bg-[var(--bg-card)]",children:i.map(({id:d,icon:u,label:m,badge:p})=>e.jsxs("button",{onClick:()=>o(d),className:`flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors border-b-2 ${t===d?"border-[var(--color-accent-600)] text-[var(--color-accent-600)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--border-color)]"}`,children:[e.jsx(u,{className:"w-4 h-4"}),m,p>0&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:p})]},d))})}function lu({activeTab:t,ticket:s,activities:r,isSupport:a,isClosed:o,isReadOnly:c,isConnected:i,currentUserName:d,saving:u,uploading:m,onAddComment:p,onDownloadAttachment:f,onUploadAttachment:h,onStatusChange:b,onAssign:g,onResolve:y,onClose:x,onReopen:j,onEscalate:v,getAttachmentUrl:S,onProposeSolution:N,onApproveSolution:I,onRejectSolution:P,t:k}){if(t==="description")return e.jsx("div",{className:"h-full overflow-y-auto p-6 bg-[var(--bg-primary)]",children:s.description?e.jsx("div",{className:"prose prose-sm max-w-none text-[var(--text-primary)] leading-relaxed [&_a]:text-[var(--color-accent-600)] [&_a]:underline",dangerouslySetInnerHTML:{__html:Qa.sanitize(s.description)}}):e.jsx("p",{className:"text-[var(--text-tertiary)] italic",children:k("tabs.noDescription")})});if(t==="conversation"){const A=n.useMemo(()=>{if(s)return{ticketNumber:s.ticketNumber??"",ticketTitle:s.title??"",userName:s.createdBy?.fullName??"",userFirstName:s.createdBy?.fullName?.split(" ")[0]??"",userLastName:s.createdBy?.fullName?.split(" ").slice(1).join(" ")??"",userEmail:s.createdBy?.email??"",priority:s.priority??"",type:s.type??"",status:s.status??"",agentName:s.assignedTo?.fullName??"",agentFirstName:s.assignedTo?.fullName?.split(" ")[0]??"",createdAt:s.createdAt?new Date(s.createdAt).toLocaleDateString():"",resolvedAt:s.resolvedAt?new Date(s.resolvedAt).toLocaleDateString():"",resolution:s.resolution??""}},[s]);return e.jsxs("div",{className:"h-full flex flex-col",children:[(s.activeSolution||s.hasPendingSolution||a&&!o&&s.status!=="Closed")&&e.jsx("div",{className:"p-4 border-b border-[var(--border-color)]",children:e.jsx(Od,{ticketId:s.id,solutions:s.solutions??[],activeSolution:s.activeSolution,mode:a?"support":"client",onProposeSolution:!c&&a?N:void 0,onApproveSolution:c?void 0:I,onRejectSolution:c?void 0:P,isLoading:u})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ra,{ticketId:s.id,comments:s.comments,activities:r.map(R=>({id:R.id,action:R.action,oldValue:R.oldValue??null,newValue:R.newValue??null,changedByUserName:"changedByUserName"in R?R.changedByUserName:null,createdAt:R.createdAt})),attachments:s.attachments,isSupport:a,isClosed:o||c,isConnected:i,currentUserName:d,ticketVariables:A,onAddComment:p,onDownloadAttachment:f,getAttachmentUrl:S})})]})}return t==="assignment"?e.jsx(cu,{ticket:s,canAssign:!c&&!!g,onAssign:g,t:k}):t==="ai"?e.jsx(uu,{ticket:s,t:k}):e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(Ea,{ticket:s,attachments:s.attachments,activities:r.map(A=>({action:A.action,newValue:A.newValue,createdAt:A.createdAt})),isSupport:a,saving:u,uploading:m,isReadOnly:c,layout:"grid",onAssign:c?void 0:g,onStatusChange:c?void 0:b,onResolve:c?void 0:y,onCloseTicket:c?void 0:x,onReopen:c?void 0:j,onEscalate:c?void 0:v,onDownloadAttachment:f,onUploadAttachment:c?void 0:h,getAttachmentUrl:S})})})}function cu({ticket:t,canAssign:s,onAssign:r,t:a}){const[o,c]=n.useState([]),[i,d]=n.useState(!1);n.useEffect(()=>{t?.id&&(d(!0),Gd.getByTicket(t.id).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1)))},[t?.id]);const u=t.assignees??[];return e.jsx("div",{className:"h-full overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)]",children:a("tabs.assignmentCurrentAssignees")}),s&&r&&e.jsx("button",{onClick:r,className:"text-xs px-3 py-1.5 rounded-md bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors",children:a("tabs.assignmentAssign")})]}),u.length===0?e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] italic",children:a("tabs.assignmentNoAssignees")}):e.jsx("div",{className:"space-y-2",children:u.map(m=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md bg-[var(--bg-secondary)]",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--color-accent-100)] text-[var(--color-accent-700)] flex items-center justify-center text-xs font-medium",children:(m.fullName||m.email||"?").charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:m.fullName||m.email}),m.assignedViaGroupName&&e.jsx("div",{className:"text-xs text-[var(--text-tertiary)]",children:a("tabs.assignmentViaGroup",{group:m.assignedViaGroupName})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m.isPrimary&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-[var(--info-bg)] text-[var(--info-text)]",children:a("tabs.assignmentPrimary")}),m.assignedAt&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:new Date(m.assignedAt).toLocaleDateString()})]})]},m.userId))})]}),e.jsxs("div",{className:"card p-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-[var(--text-primary)] mb-4",children:a("tabs.assignmentLogs")}),i&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(l.Loader2,{className:"w-5 h-5 animate-spin text-[var(--text-tertiary)]"})}),!i&&o.length===0&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] italic",children:a("tabs.assignmentNoLogs")}),!i&&o.length>0&&e.jsx("div",{className:"space-y-2",children:o.map(m=>e.jsxs("div",{className:"flex items-start gap-3 p-2 rounded-md border border-[var(--border-color)] bg-[var(--bg-primary)]",children:[e.jsx("div",{className:`mt-0.5 w-2 h-2 rounded-full flex-shrink-0 ${m.success?"bg-[var(--success-text)]":"bg-[var(--error-text)]"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-[var(--text-primary)]",children:[e.jsx("span",{className:"font-medium",children:m.strategyUsed}),m.reason&&e.jsxs("span",{className:"text-[var(--text-secondary)]",children:[" — ",m.reason]})]}),e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mt-0.5",children:new Date(m.createdAt).toLocaleString()})]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${m.success?"bg-[var(--success-bg)] text-[var(--success-text)]":"bg-[var(--error-bg)] text-[var(--error-text)]"}`,children:m.success?a("tabs.assignmentSuccess"):a("tabs.assignmentFailed")})]},m.id))})]})]})})}const du=12e4;function dr(t){const s=sessionStorage.getItem(t);return s?Date.now()-Number(s)>du?(sessionStorage.removeItem(t),!1):!0:!1}function uu({ticket:t,t:s}){const[r,a]=n.useState(null),[o,c]=n.useState(!0),i=`ai_routing_${t.id}`,d=`ai_summary_${t.id}`,[u,m]=n.useState(()=>dr(i)),[p,f]=n.useState(()=>dr(d));n.useEffect(()=>{let x=!1;return(async()=>{try{const{cachedAiApi:v}=await Promise.resolve().then(()=>ir),S=await v.getCached(t.id);x||(a(S),S.routingSuggestion&&(sessionStorage.removeItem(i),m(!1)),S.summary&&(sessionStorage.removeItem(d),f(!1)))}catch{}finally{x||c(!1)}})(),()=>{x=!0}},[t.id,i,d]),n.useEffect(()=>{if(!u&&!p)return;let x=!1;const v=setInterval(async()=>{try{const{cachedAiApi:S}=await Promise.resolve().then(()=>ir),N=await S.getCached(t.id);if(x)return;a(N),u&&N.routingSuggestion&&(sessionStorage.removeItem(i),m(!1)),p&&N.summary&&(sessionStorage.removeItem(d),f(!1))}catch{}},3e3);return()=>{x=!0,clearInterval(v)}},[u,p,t.id,i,d]);const h=n.useCallback(()=>{sessionStorage.setItem(i,Date.now().toString()),m(!0)},[i]),b=n.useCallback(()=>{sessionStorage.removeItem(i),m(!1)},[i]),g=n.useCallback(()=>{sessionStorage.setItem(d,Date.now().toString()),f(!0)},[d]),y=n.useCallback(()=>{sessionStorage.removeItem(d),f(!1)},[d]);return o?e.jsx("div",{className:"h-full overflow-y-auto p-6 flex items-center justify-center",children:e.jsx(l.Loader2,{className:"w-6 h-6 animate-spin text-[var(--color-primary-600)]"})}):e.jsx("div",{className:"h-full overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-4",children:[(t.aiClassification||r?.classification)&&e.jsxs("div",{className:"card p-4",children:[e.jsx("h3",{className:"font-semibold text-sm mb-3 text-[var(--text-primary)]",children:s("aiClassification.title")}),e.jsx(Da,{classification:t.aiClassification||r?.classification})]}),e.jsx(_d,{ticketId:t.id,cachedClassification:r?.classification,cachedRouting:r?.routingSuggestion,cachedGeneratedAt:r?.routingSuggestionGeneratedAt,processing:u,onProcessingStart:h,onProcessingEnd:b}),e.jsx(qd,{ticketId:t.id,cachedSummary:r?.summary,cachedGeneratedAt:r?.summaryGeneratedAt,processing:p,onProcessingStart:g,onProcessingEnd:y})]})})}function mu({mode:t}){const{id:s}=w.useParams(),r=w.useNavigate(),{t:a}=ne.useTranslation("support"),{user:o,hasPermission:c}=Pe(),[i,d]=w.useSearchParams(),{isGlpi:u}=Cs(),m=t==="support",p=su(m,o),[f,h]=n.useState(()=>au(i,Hd));n.useEffect(()=>{ru(f,i,d)},[f,i,d]);const{ticket:b,setTicket:g,loading:y,setLoading:x,saving:j,setSaving:v,uploading:S,setUploading:N,error:I,setError:P,activities:k,setActivities:A,isEditing:R,setIsEditing:$,editForm:q,setEditForm:C,showAssignModal:D,setShowAssignModal:Y,showResolveModal:T,setShowResolveModal:z,showEscalateModal:Z,setShowEscalateModal:H,resolution:J,setResolution:fe,escalationLevel:B,setEscalationLevel:Q,escalationReason:M,setEscalationReason:re,users:F,setUsers:K,selectedUserIds:V,setSelectedUserIds:ae,selectedGroupIds:ue,setSelectedGroupIds:G,loadingUsers:ce,setLoadingUsers:de,userSearchQuery:he,setUserSearchQuery:pe,groupSearchQuery:ye,setGroupSearchQuery:qe,groups:Ue,setGroups:Ve,loadingGroups:U,setLoadingGroups:W,assignModalTab:ee,setAssignModalTab:te,satisfaction:se,setSatisfaction:me,showRatingForm:ie,setShowRatingForm:ve,ratingValue:be,setRatingValue:Ie,ratingComment:Me,setRatingComment:Le,submittingRating:ze,setSubmittingRating:et}=tu(),We=n.useCallback(async()=>{if(s)try{const X=m?await je.tickets.getActivities(s,50):await Fe.getActivities(s,50);A(X)}catch(X){console.error("Failed to load activities",X)}},[s,m]),At=n.useCallback(async()=>{if(!(!s||m))try{const X=await Fe.getSatisfaction(s);me(X)}catch(X){console.error("Failed to load satisfaction",X)}},[s,m]),ke=n.useCallback(async()=>{if(s)try{if(x(!0),P(null),m){const X=await je.tickets.getById(s);if(!X){g(null);return}g(cr(X,t)),C({title:X.title,priority:X.priority})}else{const X=await Fe.getById(s);if(!X){g(null);return}g(cr(X,t)),At()}We()}catch(X){P(a("error.loadFailed","Impossible de charger le ticket")),console.error(X)}finally{x(!1)}},[s,m,t,We,At,a]),L=n.useCallback(X=>{if(X.ticketId===s){if(!m&&X.isInternal)return;g(xe=>!xe||xe.comments.some(De=>De.id===X.id)?xe:{...xe,comments:[...xe.comments,{id:X.id,userName:X.userName,content:X.content,isInternal:X.isInternal,isEdited:X.isEdited,createdAt:X.createdAt}]})}},[s,m]),le=n.useCallback(X=>{X.ticketId===s&&ke()},[s,ke]),{isConnected:we}=aa({ticketId:s,onCommentAdded:L,onTicketUpdated:le});n.useEffect(()=>{ke()},[ke]),n.useEffect(()=>{(async()=>{if(!(!D||F.length>0||!m))try{de(!0);const xe=await E.get("/api/support/tickets/assignable-users"),De=Array.isArray(xe)?xe:[];K(De.map(Re=>({id:Re.id,email:Re.email,fullName:`${Re.firstName} ${Re.lastName}`}))),(b?.assignees?.length??0)>0&&b?.assignees&&ae(b.assignees.map(Re=>Re.userId))}catch(xe){console.error("Failed to load users",xe)}finally{de(!1)}})()},[D,F.length,m,b?.assignees]),n.useEffect(()=>{(async()=>{if(!(!D||!m))try{W(!0);const xe=await E.get("/api/support/tickets/assignable-groups"),De=Array.isArray(xe)?xe:[];Ve(De.map(Re=>({id:Re.id,name:Re.name,memberCount:Re.memberCount})))}catch(xe){console.error("Failed to load groups",xe)}finally{W(!1)}})()},[D,m]);const Ae=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.update(s,{title:q.title,priority:q.priority,description:b?.description||""}),await ke(),$(!1)}catch{P(a("error.updateFailed","Impossible de mettre à jour le ticket"))}finally{v(!1)}},$e=async X=>{if(!(!s||!m))try{v(!0),await je.tickets.updateStatus(s,X),await ke()}catch{P(a("error.statusFailed","Impossible de changer le statut"))}finally{v(!1)}},ht=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.assign(s,V.length>0?V[0]:null,V.length>0?V:void 0,ue.length>0?ue:void 0),await ke(),Y(!1),ae([]),G([]),te("users")}catch{P(a("error.assignFailed","Impossible d'assigner le ticket"))}finally{v(!1)}},rt=async()=>{if(!(!s||!J.trim()||!m))try{v(!0),await je.tickets.proposeSolution(s,J),await ke(),z(!1),fe("")}catch{P(a("error.resolveFailed","Impossible de proposer une solution"))}finally{v(!1)}},Oa=async X=>{if(s)try{v(!0),m&&await je.tickets.proposeSolution(s,X),await ke()}catch{P(a("error.resolveFailed","Impossible de proposer une solution"))}finally{v(!1)}},Fa=async()=>{if(s)try{v(!0),m?await je.tickets.approveSolution(s):await Fe.approveSolution(s),await ke()}catch{P(a("error.approveFailed","Impossible d'approuver la solution"))}finally{v(!1)}},_a=async X=>{if(s)try{v(!0),m?await je.tickets.rejectSolution(s,X):await Fe.rejectSolution(s,X),await ke()}catch{P(a("error.rejectFailed","Impossible de rejeter la solution"))}finally{v(!1)}},ks=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.close(s),await ke()}catch{P(a("error.closeFailed","Impossible de fermer le ticket"))}finally{v(!1)}},As=async()=>{if(!(!s||!m))try{v(!0),await je.tickets.reopen(s),await ke()}catch{P(a("error.reopenFailed","Impossible de réouvrir le ticket"))}finally{v(!1)}},qa=async()=>{if(!(!s||!m||!B))try{v(!0),await da.escalateTicket(s,B,M||void 0),await ke(),H(!1),Q("Supervisor"),re("")}catch{P(a("error.escalateFailed","Failed to escalate ticket"))}finally{v(!1)}},Ua=async(X,xe)=>{!s||!X.trim()||(m?await je.tickets.addComment(s,{content:X,isInternal:xe}):await Fe.addComment(s,X),await ke())},za=async()=>{if(!(!s||be===0||m))try{et(!0);const X=await Fe.submitSatisfaction(s,{rating:be,comment:Me.trim()||void 0});me(X),ve(!1),Ie(0),Le("")}catch(X){const xe=X instanceof Error?X.message:a("error.ratingFailed","Failed to submit rating");P(xe)}finally{et(!1)}},Ba=async X=>{if(s)try{const xe=m?await je.tickets.downloadAttachment(s,X.id):await Fe.downloadAttachment(s,X.id),De=window.URL.createObjectURL(xe),Re=document.createElement("a");Re.href=De,Re.setAttribute("download",X.fileName),document.body.appendChild(Re),Re.click(),Re.remove(),window.URL.revokeObjectURL(De)}catch{P(a("error.downloadFailed","Impossible de télécharger le fichier"))}},Ga=async X=>{if(!(!s||!m))try{N(!0),await je.tickets.uploadAttachment(s,X),await ke()}catch(xe){throw P(a("error.uploadFailed","Failed to upload file")),xe}finally{N(!1)}},Ka=X=>s?m?je.tickets.getAttachmentUrl(s,X.id):`/api/support/my-tickets/${s}/attachments/${X.id}`:"",Ha=n.useMemo(()=>{if(!he.trim())return F;const X=he.toLowerCase();return F.filter(xe=>xe.fullName.toLowerCase().includes(X)||xe.email.toLowerCase().includes(X))},[F,he]),Va=n.useCallback(X=>{ae(xe=>xe.includes(X)?xe.filter(De=>De!==X):[...xe,X])},[]),Wa=n.useCallback(X=>{G(xe=>xe.includes(X)?xe.filter(De=>De!==X):[...xe,X])},[]);if(y)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-600)]"})});if(!b)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsx(l.AlertTriangle,{className:"w-12 h-12 mb-4 text-[var(--text-tertiary)]"}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-4",children:a("error.notFound","Ticket non trouvé")}),e.jsx("button",{onClick:()=>r(-1),className:"btn btn-secondary",children:a("common.goBack","Retour")})]});const Xa=b.status==="Closed"||b.status==="Rejected",tt=u||!!b.isExternallyManaged,Ps=!tt&&c("support.tickets.assign");return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(nu,{ticket:b,isSupport:m,isEditing:R,saving:j,editForm:q,error:I,onEditToggle:$,onSave:Ae,onEditFormChange:C,onErrorClear:()=>P(null),t:a}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx(ou,{ticket:b,isSupport:m,satisfaction:se,showRatingForm:ie,ratingValue:be,ratingComment:Me,submittingRating:ze,onShowRatingForm:()=>ve(!0),onRatingChange:Ie,onCommentChange:Le,onCancelRating:()=>{ve(!1),Ie(0),Le("")},onSubmitRating:za,t:a}),e.jsx(Md,{currentStatus:b.status,createdAt:b.createdAt,resolvedAt:b.resolvedAt,closedAt:b.closedAt,activities:k.map(X=>({action:X.action,newValue:X.newValue,createdAt:X.createdAt})),isSupport:m,saving:j,assignees:b.assignees,onAssign:Ps?()=>Y(!0):void 0,onStatusChange:tt?void 0:$e,onResolve:tt?void 0:()=>z(!0),onCloseTicket:tt?void 0:ks,onReopen:tt?void 0:As,onEscalate:tt?void 0:()=>H(!0)})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsx(iu,{activeTab:f,commentCount:b.comments.length,isSupport:m,assigneeCount:b.assignees?.length??0,onTabChange:h,t:a}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(lu,{activeTab:f,ticket:b,activities:k,isSupport:m,isClosed:Xa,isReadOnly:tt,isConnected:we,currentUserName:p,saving:j,uploading:S,onAddComment:Ua,onDownloadAttachment:Ba,onUploadAttachment:Ga,onStatusChange:$e,onAssign:Ps?()=>Y(!0):void 0,onResolve:()=>z(!0),onClose:ks,onReopen:As,onEscalate:()=>H(!0),getAttachmentUrl:Ka,onProposeSolution:Oa,onApproveSolution:Fa,onRejectSolution:_a,t:a})})]}),e.jsx(Xd,{show:m&&T,resolution:J,saving:j,onResolutionChange:fe,onClose:()=>z(!1),onResolve:rt,t:a}),e.jsx(Yd,{show:m&&D,filteredUsers:Ha,selectedUserIds:V,selectedGroupIds:ue,groups:Ue,userSearchQuery:he,groupSearchQuery:ye,loadingUsers:ce,loadingGroups:U,saving:j,activeTab:ee,onUserSearchChange:pe,onGroupSearchChange:qe,onSelectUser:Va,onSelectGroup:Wa,onTabChange:te,onClose:()=>{Y(!1),ae([]),G([]),te("users"),pe(""),qe("")},onAssign:ht,t:a}),e.jsx(Qd,{show:m&&Z,escalationLevel:B,escalationReason:M,saving:j,onLevelChange:Q,onReasonChange:re,onClose:()=>H(!1),onEscalate:qa,t:a})]})}const ur="support_tickets_view_mode",pu={Open:["InProgress","OnHold","Rejected"],InProgress:["OnHold","Resolved","Rejected"],OnHold:["InProgress","Resolved","Open"],Resolved:["Closed","Open"],Closed:["Open"],Rejected:["Open"]};function mr(t,s){return t===s?!1:pu[t]?.includes(s)??!1}const ts={Low:"var(--info-bg)",Medium:"var(--warning-bg)",High:"var(--error-bg)",Critical:"var(--error-text)"};function xu({mode:t,showDrafts:s=!1,basePath:r,title:a,subtitle:o,createPath:c}){const{t:i}=ne.useTranslation(["support","admin","common"]),d=w.useNavigate(),{currentTenant:u,userTenants:m,hasMultipleTenants:p,isGlobalView:f}=Ee(),{isGlpi:h}=Cs(),[b,g]=n.useState([]),[y,x]=n.useState(null),[j,v]=n.useState(!0),[S,N]=n.useState(1),[I,P]=n.useState(1),[k,A]=n.useState(0),[R,$]=n.useState(""),[q,C]=n.useState(""),[D,Y]=n.useState(""),[T,z]=n.useState(""),[Z,H]=n.useState(""),[J,fe]=n.useState(()=>localStorage.getItem(ur)||"table"),[B,Q]=n.useState(!1),[M,re]=n.useState([]),[F,K]=n.useState(!0),[V,ae]=n.useState(null),[ue,G]=n.useState(null),[ce,de]=n.useState(null),he=(t==="admin"||t==="assigned")&&(p||f),pe=n.useCallback(async()=>{try{v(!0);const L={page:S,pageSize:20,search:R||void 0,status:q||void 0,type:D||void 0,priority:T||void 0,tenantId:Z||void 0};let le;t==="admin"?le=await je.tickets.getAll(L):t==="assigned"?le=await je.tickets.getMyTickets(L):le=await Fe.getAll(L),g(le?.items??[]),P(le?.totalPages??1),A(le?.totalCount??0)}catch(L){console.error("Failed to load tickets:",L),g([]),P(1),A(0)}finally{v(!1)}},[t,S,R,q,D,T,Z]),ye=n.useCallback(async()=>{try{let L;t==="admin"?L=await je.tickets.getStats(Z||void 0):t==="assigned"?L=await je.tickets.getMyAssignedStats():L=await Fe.getStats(),x(L)}catch(L){console.error("Failed to load stats:",L)}},[t,Z]);n.useEffect(()=>{pe()},[pe]),n.useEffect(()=>{ye()},[ye]),n.useEffect(()=>{if(s){const L=Ge.getAllDrafts();re(L)}},[s]),n.useEffect(()=>{localStorage.setItem(ur,J)},[J]);const qe=L=>{Ge.deleteDraft(L),re(Ge.getAllDrafts())},Ue=L=>{d(`${c}?draft=${L.id}`)},Ve=L=>{const we=new Date().getTime()-L.getTime(),Ae=Math.floor(we/6e4),$e=Math.floor(we/36e5),ht=Math.floor(we/864e5);return Ae<1?i("common:time.justNow","Just now"):Ae<60?i("common:time.minutesAgo",{count:Ae}):$e<24?i("common:time.hoursAgo",{count:$e}):i("common:time.daysAgo",{count:ht})},U=L=>{L.preventDefault(),N(1),pe()},W=L=>{h||ae(L)},ee=()=>{ae(null),G(null)},te=(L,le)=>{L.preventDefault(),G(le)},se=()=>{G(null)},me=L=>V?mr(V.status,L):!1,ie=async(L,le)=>{if(L.preventDefault(),de(null),!V||V.status===le){ae(null),G(null);return}if(!mr(V.status,le)){de(i("list.invalidTransition",{from:i(`tickets.statuses.${V.status}`),to:i(`tickets.statuses.${le}`)})),ae(null),G(null),setTimeout(()=>de(null),4e3);return}try{g(we=>we.map(Ae=>Ae.id===V.id?{...Ae,status:le}:Ae)),(t==="admin"||t==="assigned")&&await je.tickets.updateStatus(V.id,le),ye(),pe()}catch(we){console.error("Failed to update ticket status:",we);const Ae=we?.response?.data?.message||we?.response?.data?.detail||"";de(Ae||i("list.statusUpdateFailed")),setTimeout(()=>de(null),4e3),pe()}finally{ae(null),G(null)}},ve=async L=>{if(confirm(i("list.confirmDelete",{number:L.ticketNumber})))try{await je.tickets.delete(L.id),pe(),ye()}catch(le){console.error("Failed to delete ticket:",le)}},be=L=>`${r}/${L}`,Ie=L=>{if(!he)return null;const le="tenantId"in L?L.tenantId??null:null,we="tenantName"in L?L.tenantName??null:null,Ae=vs(le,u?.id??null);return Ae==="global"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 border border-purple-200 dark:border-purple-700",children:"System"}):Ae==="current"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)] truncate max-w-[120px]",children:we}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700 font-medium truncate max-w-[120px]",children:we})},Me=()=>{if(!y)return null;const L=y,le=y,we=t==="admin"||t==="assigned",Ae=we?[{label:i("list.stats.total"),value:L.total,color:"blue"},{label:i("list.stats.open"),value:L.open,color:"yellow"},{label:i("list.stats.inProgress"),value:L.inProgress,color:"blue"},{label:i("list.stats.onHold"),value:L.onHold,color:"yellow"},{label:i("list.stats.resolved"),value:L.resolved,color:"green"},{label:i("list.stats.closed"),value:L.closed,color:"neutral"},{label:i("list.stats.critical"),value:L.critical,color:"red"},{label:i("list.stats.highPriority"),value:L.highPriority,color:"yellow"}]:[{label:i("list.stats.total"),value:le.total,color:"blue"},{label:i("list.stats.open"),value:le.open,color:"yellow"},{label:i("list.stats.inProgress"),value:le.inProgress,color:"blue"},{label:i("list.stats.resolved"),value:le.resolved,color:"green"},{label:i("list.stats.closed"),value:le.closed,color:"neutral"}],$e={blue:"bg-[var(--info-bg)] text-[var(--info-text)] border-[var(--info-border)]",green:"bg-[var(--success-bg)] text-[var(--success-text)] border-[var(--success-border)]",yellow:"bg-[var(--warning-bg)] text-[var(--warning-text)] border-[var(--warning-border)]",red:"bg-[var(--error-bg)] text-[var(--error-text)] border-[var(--error-border)]",neutral:"bg-[var(--bg-secondary)] text-[var(--text-primary)] border-[var(--border-color)]"},ht=we?"lg:grid-cols-8":"lg:grid-cols-5";return e.jsx("div",{className:`grid grid-cols-2 md:grid-cols-4 ${ht} gap-4 mb-6`,children:Ae.map(rt=>e.jsxs("div",{className:`card p-4 text-center border ${$e[rt.color]}`,children:[e.jsx("div",{className:"text-2xl font-bold",children:rt.value}),e.jsx("div",{className:"text-sm opacity-80",children:rt.label})]},rt.label))})},Le=()=>e.jsxs("div",{className:"card overflow-hidden",children:[e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-color)]",children:[e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.number")}),he&&e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.tenant","Workspace")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.title")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.type")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.status")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.priority")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.assignee")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.comments")}),e.jsx("th",{className:"text-left p-4 font-medium",children:i("list.table.created")}),e.jsx("th",{className:"text-right p-4 font-medium",children:i("list.table.actions")})]})}),e.jsx("tbody",{children:b.map(L=>e.jsxs("tr",{className:"border-b border-[var(--border-color)] hover:bg-[var(--bg-hover)] cursor-pointer",onClick:()=>d(be(L.id)),children:[e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"font-mono text-sm",children:L.ticketNumber})}),he&&e.jsx("td",{className:"p-4",children:Ie(L)}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-medium",children:L.title}),L.isExternallyManaged&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"GLPI"})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})})}),e.jsx("td",{className:"p-4",children:e.jsx(Ot,{status:ds[L.status]||"pending",label:i(`tickets.statuses.${L.status}`,{defaultValue:L.status})})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium",style:{backgroundColor:ts[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})})}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"assignedToName"in L&&L.assignedToName||"-"}),"assigneeCount"in L&&L.assigneeCount>1&&e.jsxs("span",{className:"ml-1 text-xs px-1.5 py-0.5 rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]",children:["+",L.assigneeCount-1]})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm",children:L.commentCount})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:new Date(L.createdAt).toLocaleDateString()})}),e.jsx("td",{className:"p-4 text-right",onClick:le=>le.stopPropagation(),children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>d(be(L.id)),className:"btn btn-ghost p-2",title:i("list.actions.view"),children:e.jsx(l.Eye,{className:"w-4 h-4"})}),L.externalUrl&&e.jsx("a",{href:L.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-ghost p-2 text-[var(--info-text)]",title:"Open in GLPI",onClick:le=>le.stopPropagation(),children:e.jsx(l.ExternalLink,{className:"w-4 h-4"})}),t==="admin"&&!h&&e.jsx("button",{onClick:()=>ve(L),disabled:L.isExternallyManaged,className:"btn btn-ghost p-2 text-[var(--error-text)] disabled:opacity-50 disabled:cursor-not-allowed",title:L.isExternallyManaged?"Cannot delete externally managed tickets":i("list.actions.delete"),children:e.jsx(l.Trash2,{className:"w-4 h-4"})})]})})]},L.id))})]}),b.length===0&&!j&&e.jsxs("div",{className:"p-8 text-center text-[var(--text-secondary)]",children:[e.jsx(l.Headphones,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsxs("p",{children:[t==="admin"&&i("list.empty.admin"),t==="assigned"&&i("list.empty.assigned"),t==="user"&&i("list.empty.user")]}),t==="user"&&!h&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary mt-4",children:[e.jsx(l.Plus,{className:"w-4 h-4 mr-2"}),i("list.empty.createFirst")]})]})]}),ze=()=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[b.map(L=>e.jsxs("button",{type:"button",className:"card p-4 hover:shadow-lg cursor-pointer transition-shadow text-left w-full",onClick:()=>d(be(L.id)),children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm text-[var(--text-secondary)]",children:L.ticketNumber}),Ie(L)]}),e.jsx(Ot,{status:ds[L.status]||"pending",label:i(`tickets.statuses.${L.status}`,{defaultValue:L.status})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-medium line-clamp-2 flex-1",children:L.title}),L.isExternallyManaged&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)] whitespace-nowrap",children:"GLPI"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-xs px-2 py-1 rounded-[var(--radius-badge)] bg-[var(--bg-secondary)]",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})}),e.jsx("span",{className:"text-xs px-2 py-1 rounded-[var(--radius-badge)]",style:{backgroundColor:ts[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-[var(--text-secondary)]",children:[e.jsx("span",{children:new Date(L.createdAt).toLocaleDateString()}),e.jsx("span",{children:i("list.comments_other",{count:L.commentCount})})]})]},L.id)),b.length===0&&!j&&e.jsxs("div",{className:"col-span-full card p-12 text-center",children:[e.jsx(l.Headphones,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsxs("p",{className:"text-[var(--text-secondary)]",children:[t==="admin"&&i("list.empty.admin"),t==="assigned"&&i("list.empty.assigned"),t==="user"&&i("list.empty.user")]}),t==="user"&&!h&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary mt-4",children:[e.jsx(l.Plus,{className:"w-4 h-4 mr-2"}),i("list.empty.createFirst")]})]})]}),et=L=>e.jsxs(ja,{onClick:()=>d(be(L.id)),isDragging:V?.id===L.id,onDragStart:()=>W(L),onDragEnd:ee,children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)] mb-1",children:[e.jsx("span",{children:L.ticketNumber}),Ie(L)]}),e.jsx("div",{className:"font-medium mb-2 line-clamp-2",children:L.title}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-[var(--radius-badge)]",style:{backgroundColor:ts[L.priority],color:L.priority==="Critical"?"white":"inherit"},children:i(`tickets.priorities.${L.priority}`,{defaultValue:L.priority})}),e.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:i("list.comments_other",{count:L.commentCount})})]})]},L.id),We=()=>{const L=[{status:"Open",label:i("tickets.statuses.Open"),color:"warning"},{status:"InProgress",label:i("tickets.statuses.InProgress"),color:"default"},{status:"OnHold",label:i("tickets.statuses.OnHold"),color:"warning"},{status:"Resolved",label:i("tickets.statuses.Resolved"),color:"success"},{status:"Closed",label:i("tickets.statuses.Closed"),color:"default"}];return e.jsxs("div",{className:"space-y-3",children:[ce&&e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]",children:[e.jsx("span",{className:"text-sm text-[var(--error-text)]",children:ce}),e.jsx("button",{onClick:()=>de(null),className:"ml-auto text-[var(--error-text)] hover:opacity-70",children:"×"})]}),e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4",children:L.map(le=>{const we=b.filter($e=>$e.status===le.status),Ae=V!=null&&!me(le.status)&&V.status!==le.status;return e.jsx(ya,{title:le.label,count:we.length,color:le.color,isDragOver:ue===le.status,isDropDisabled:Ae,onDragOver:$e=>te($e,le.status),onDragLeave:se,onDrop:$e=>ie($e,le.status),children:we.map(et)},le.status)})})]})},At=()=>!s||M.length===0?null:e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.FileEdit,{className:"w-5 h-5 text-[var(--warning-text)]"}),e.jsx("h2",{className:"font-semibold",children:i("common:drafts.title","Drafts")}),e.jsx("span",{className:"px-2 py-0.5 text-xs bg-[var(--warning-bg)] text-[var(--warning-text)] rounded-full",children:M.length})]}),e.jsx("button",{onClick:()=>K(!F),className:"btn btn-ghost text-sm",children:F?i("common:actions.hide","Hide"):i("common:actions.show","Show")})]}),F&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:M.map(L=>e.jsx("button",{type:"button",className:"p-3 bg-[var(--bg-secondary)] rounded-lg border border-[var(--warning-border)] hover:border-[var(--warning-text)] transition-colors cursor-pointer text-left w-full",onClick:()=>Ue(L),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:L.title||i("common:drafts.untitled","Untitled draft")}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-[var(--text-secondary)] flex-wrap",children:[L.tenantName&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded truncate max-w-[120px]",children:L.tenantName}),L.type&&e.jsx("span",{className:"px-1.5 py-0.5 bg-[var(--bg-tertiary)] rounded",children:i(`tickets.types.${L.type}`,{defaultValue:L.type})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(l.Clock,{className:"w-3 h-3"}),Ve(L.updatedAt)]})]})]}),e.jsx("button",{onClick:le=>{le.stopPropagation(),qe(L.id)},className:"p-1 hover:bg-[var(--error-bg)] rounded text-[var(--text-secondary)] hover:text-[var(--error-text)]",title:i("common:actions.delete","Delete"),children:e.jsx(l.X,{className:"w-4 h-4"})})]})},L.id))})]}),ke=()=>t==="admin"||t==="assigned"?he?"md:grid-cols-4":"md:grid-cols-3":"md:grid-cols-2";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(l.Headphones,{className:"w-6 h-6"}),a]}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:o})]}),!h&&e.jsxs("button",{onClick:()=>d(c),className:"btn btn-primary flex items-center gap-2",children:[e.jsx(l.Plus,{className:"w-4 h-4"}),i("list.newTicket")]})]}),Me(),At(),e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("form",{onSubmit:U,className:"flex-1 flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(l.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-secondary)]"}),e.jsx("input",{type:"text",placeholder:i("list.searchPlaceholder"),value:R,onChange:L=>$(L.target.value),className:"input w-full pl-10"})]}),e.jsx("button",{type:"submit",className:"btn btn-secondary",children:i("list.search")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Q(!B),className:`btn ${B?"btn-primary":"btn-secondary"} flex items-center gap-2`,children:[e.jsx(l.Filter,{className:"w-4 h-4"}),i("list.filters")]}),e.jsx(va,{viewMode:J,onChange:fe})]})]}),B&&e.jsxs("div",{className:`card p-4 grid grid-cols-1 ${ke()} gap-4`,children:[he&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.tenant","Workspace")}),e.jsxs("select",{value:Z,onChange:L=>{H(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allTenants","All Workspaces")}),m.filter(L=>L.status==="Active").map(L=>e.jsx("option",{value:L.id,children:L.name},L.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.status")}),e.jsxs("select",{value:q,onChange:L=>{C(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allStatuses")}),e.jsx("option",{value:"Open",children:i("tickets.statuses.Open")}),e.jsx("option",{value:"InProgress",children:i("tickets.statuses.InProgress")}),e.jsx("option",{value:"OnHold",children:i("tickets.statuses.OnHold")}),e.jsx("option",{value:"Resolved",children:i("tickets.statuses.Resolved")}),e.jsx("option",{value:"Closed",children:i("tickets.statuses.Closed")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.type")}),e.jsxs("select",{value:D,onChange:L=>{Y(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allTypes")}),e.jsx("option",{value:"Bug",children:i("tickets.types.Bug")}),e.jsx("option",{value:"FeatureRequest",children:i("tickets.types.FeatureRequest")}),e.jsx("option",{value:"ApplicationRequest",children:i("tickets.types.ApplicationRequest")}),e.jsx("option",{value:"Support",children:i("tickets.types.Support")}),e.jsx("option",{value:"Question",children:i("tickets.types.Question")})]})]}),(t==="admin"||t==="assigned")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:i("list.filter.priority")}),e.jsxs("select",{value:T,onChange:L=>{z(L.target.value),N(1)},className:"input w-full",children:[e.jsx("option",{value:"",children:i("list.filter.allPriorities")}),e.jsx("option",{value:"Low",children:i("tickets.priorities.Low")}),e.jsx("option",{value:"Medium",children:i("tickets.priorities.Medium")}),e.jsx("option",{value:"High",children:i("tickets.priorities.High")}),e.jsx("option",{value:"Critical",children:i("tickets.priorities.Critical")})]})]})]}),j?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(l.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-primary-600)]"})}):e.jsxs(e.Fragment,{children:[J==="table"&&Le(),J==="cards"&&ze(),J==="kanban"&&We()]}),!j&&I>1&&e.jsx(Na,{page:S,totalPages:I,totalCount:k,onPageChange:N})]})}exports.ActivityTimeline=_c;exports.AdminSidebar=Mi;exports.AppHeader=Nt;exports.AppLayout=ga;exports.AppSwitcher=ia;exports.AuthLayout=di;exports.AuthProvider=wr;exports.Avatar=wi;exports.Breadcrumb=gi;exports.CreateTicketButton=pa;exports.DataTable=vi;exports.DataView=yi;exports.DocPanelProvider=Qr;exports.DocsLayout=fa;exports.DynamicRouter=Dc;exports.EntityCard=Ns;exports.ErrorFallback=Ur;exports.ExtendablePage=co;exports.ExtensionProvider=Xr;exports.FavoritesBar=Fc;exports.FavoritesModal=Pa;exports.FavoritesProvider=Tr;exports.FeatureGate=Gi;exports.FeatureRouteGuard=ws;exports.Fill=Hr;exports.Footer=js;exports.GlobalErrorBoundary=zr;exports.Header=ys;exports.KanbanBoard=Ai;exports.KanbanCard=ja;exports.KanbanColumn=ya;exports.LanguageSwitcher=bs;exports.LicenseActivationDialog=wa;exports.LicenseContentBanner=ha;exports.LicenseGuard=Ca;exports.LicenseProvider=kr;exports.LicenseStatusBadge=Ki;exports.ModuleSidebar=xa;exports.NetworkError=ps;exports.NotificationBell=ua;exports.PAGE_KEYS=_;exports.PageHeader=Pi;exports.PageRegistry=O;exports.Pagination=Na;exports.PermissionMatrix=Ti;exports.ProtectedRoute=Sa;exports.ProviderCard=Ci;exports.PublicLayout=ba;exports.RoleBadge=Si;exports.RouteErrorBoundary=Bi;exports.SessionProvider=qr;exports.SessionWarningModal=_r;exports.SidebarProvider=Ir;exports.SignalRProvider=Mr;exports.SlaBadge=td;exports.Slot=Kr;exports.SlotFillProvider=Gr;exports.SmartStackProvider=mo;exports.StatusBadge=Ot;exports.TemplateCard=ki;exports.ThemeCustomizer=Ii;exports.ThemeProvider=vr;exports.ThemeSwitcher=Kt;exports.TicketConversation=Ra;exports.TicketDetailView=mu;exports.TicketSidebar=Ea;exports.TicketsListView=xu;exports.Tooltip=ma;exports.UnderDevelopment=Li;exports.UnlockReason=on;exports.UserSidebar=Oi;exports.ViewToggle=va;exports.WILDCARD_PERMISSION=jr;exports.adminApi=Ne;exports.api=E;exports.apiClient=Se;exports.authApi=Mt;exports.availabilityApi=Bd;exports.browserInfoService=Zr;exports.changeLanguage=xs;exports.createAdminApi=fr;exports.createSlotFill=so;exports.dashboardApi=Bo;exports.detectDeviceType=ka;exports.errorContextService=$t;exports.getClientIpAddress=Aa;exports.getTenantBadgeVariant=vs;exports.hasAllLicenseFeatures=Sr;exports.hasFullAccess=jt;exports.hasPermission=Un;exports.hasRouteAccess=Nr;exports.logService=Te;exports.matchesWildcard=Ct;exports.myTicketsApi=Fe;exports.notificationsApi=st;exports.parseUserAgent=cc;exports.rulesApi=Ud;exports.skillsApi=zd;exports.slaApi=da;exports.supportApi=je;exports.templatesApi=Lt;exports.tenantAnalyticsApi=cs;exports.ticketDraftService=Ge;exports.useActivePage=lo;exports.useAuth=Pe;exports.useClientContext=ho;exports.useCollapsibleState=go;exports.useDocPanel=Gt;exports.useEntityPermissions=na;exports.useExtensions=kt;exports.useFavorites=Ke;exports.useFeatureConfig=qt;exports.useFormFieldExtensions=ao;exports.useHasExtension=no;exports.useLicense=He;exports.useNavigation=Ce;exports.usePageOverride=Bt;exports.usePageTracking=sa;exports.usePermissionMatrix=No;exports.usePermissionSync=wo;exports.useRouteConfig=Po;exports.useSessionMonitor=Fr;exports.useSidebar=Ut;exports.useSignalR=ra;exports.useSignalRContext=Or;exports.useSlotFill=Br;exports.useSlotHasContent=to;exports.useTableColumnExtensions=ro;exports.useTenant=Ee;exports.useTenantUrl=Ze;exports.useTheme=St;exports.useTicketSignalR=aa;exports.useTicketingProvider=Cs;exports.useUserPermissions=Eo;exports.userApi=_t;exports.withPageOverride=io;exports.workloadApi=Kd;
48
+ //# sourceMappingURL=index-IgLVXPg8.js.map