@atlashub/smartstack 3.39.0-preview.1049 → 3.40.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 (273) hide show
  1. package/dist/chunks/{AgentSkillsPage-DgqyaZwI.js → AgentSkillsPage-BS_W2KTh.js} +2 -2
  2. package/dist/chunks/{AgentSkillsPage-DgqyaZwI.js.map → AgentSkillsPage-BS_W2KTh.js.map} +1 -1
  3. package/dist/chunks/{AgentSkillsPage-ojivq0Cu.js → AgentSkillsPage-CmDFLnp7.js} +2 -2
  4. package/dist/chunks/{AgentSkillsPage-ojivq0Cu.js.map → AgentSkillsPage-CmDFLnp7.js.map} +1 -1
  5. package/dist/chunks/{AgentWorkloadPage-BGGTfOLs.js → AgentWorkloadPage-C8IvYfhT.js} +2 -2
  6. package/dist/chunks/{AgentWorkloadPage-BGGTfOLs.js.map → AgentWorkloadPage-C8IvYfhT.js.map} +1 -1
  7. package/dist/chunks/{AgentWorkloadPage-DWsC5VoS.js → AgentWorkloadPage-JXsQbwuM.js} +2 -2
  8. package/dist/chunks/{AgentWorkloadPage-DWsC5VoS.js.map → AgentWorkloadPage-JXsQbwuM.js.map} +1 -1
  9. package/dist/chunks/{ApiCatalogDetailPage-7EifQOAh.js → ApiCatalogDetailPage-CYOt34Vy.js} +2 -2
  10. package/dist/chunks/{ApiCatalogDetailPage-7EifQOAh.js.map → ApiCatalogDetailPage-CYOt34Vy.js.map} +1 -1
  11. package/dist/chunks/{ApiCatalogDetailPage-BD7XE4xK.js → ApiCatalogDetailPage-wFZDsTGy.js} +3 -3
  12. package/dist/chunks/{ApiCatalogDetailPage-BD7XE4xK.js.map → ApiCatalogDetailPage-wFZDsTGy.js.map} +1 -1
  13. package/dist/chunks/{ApiCatalogPage-BfPoZGD3.js → ApiCatalogPage-Bdm3HNGP.js} +2 -2
  14. package/dist/chunks/{ApiCatalogPage-BfPoZGD3.js.map → ApiCatalogPage-Bdm3HNGP.js.map} +1 -1
  15. package/dist/chunks/{ApiCatalogPage-BOPTnk-b.js → ApiCatalogPage-m_TWQyGv.js} +2 -2
  16. package/dist/chunks/{ApiCatalogPage-BOPTnk-b.js.map → ApiCatalogPage-m_TWQyGv.js.map} +1 -1
  17. package/dist/chunks/ApplicationDetailPage-C2BSpEoW.js +2 -0
  18. package/dist/chunks/{ApplicationDetailPage-CWdz0TS4.js.map → ApplicationDetailPage-C2BSpEoW.js.map} +1 -1
  19. package/dist/chunks/{ApplicationDetailPage-CDQqViuH.js → ApplicationDetailPage-CcgDAP-J.js} +503 -501
  20. package/dist/chunks/{ApplicationDetailPage-CDQqViuH.js.map → ApplicationDetailPage-CcgDAP-J.js.map} +1 -1
  21. package/dist/chunks/{ApplicationsDashboardPage-ZyXm2Cd1.js → ApplicationsDashboardPage-CDIjziL3.js} +3 -3
  22. package/dist/chunks/{ApplicationsDashboardPage-ZyXm2Cd1.js.map → ApplicationsDashboardPage-CDIjziL3.js.map} +1 -1
  23. package/dist/chunks/{ApplicationsDashboardPage-BH4S3qA2.js → ApplicationsDashboardPage-DslDyNzJ.js} +2 -2
  24. package/dist/chunks/{ApplicationsDashboardPage-BH4S3qA2.js.map → ApplicationsDashboardPage-DslDyNzJ.js.map} +1 -1
  25. package/dist/chunks/{ApplicationsGridPage-D0fU1_Le.js → ApplicationsGridPage-BCjsQGU0.js} +2 -2
  26. package/dist/chunks/{ApplicationsGridPage-D0fU1_Le.js.map → ApplicationsGridPage-BCjsQGU0.js.map} +1 -1
  27. package/dist/chunks/{ApplicationsGridPage-C1WF2Htv.js → ApplicationsGridPage-CIfKiCND.js} +2 -2
  28. package/dist/chunks/{ApplicationsGridPage-C1WF2Htv.js.map → ApplicationsGridPage-CIfKiCND.js.map} +1 -1
  29. package/dist/chunks/{ApplicationsListPage-Cxvt2_WQ.js → ApplicationsListPage-CT75kNcH.js} +2 -2
  30. package/dist/chunks/{ApplicationsListPage-Cxvt2_WQ.js.map → ApplicationsListPage-CT75kNcH.js.map} +1 -1
  31. package/dist/chunks/{ApplicationsListPage-B3ItaY4r.js → ApplicationsListPage-D2B4PZ5n.js} +2 -2
  32. package/dist/chunks/{ApplicationsListPage-B3ItaY4r.js.map → ApplicationsListPage-D2B4PZ5n.js.map} +1 -1
  33. package/dist/chunks/{ApplicationsPage-BqfNR-kc.js → ApplicationsPage-CaTBtduL.js} +2 -2
  34. package/dist/chunks/{ApplicationsPage-BqfNR-kc.js.map → ApplicationsPage-CaTBtduL.js.map} +1 -1
  35. package/dist/chunks/{ApplicationsPage-DuxuWfrN.js → ApplicationsPage-DW1LhL0U.js} +4 -4
  36. package/dist/chunks/{ApplicationsPage-DuxuWfrN.js.map → ApplicationsPage-DW1LhL0U.js.map} +1 -1
  37. package/dist/chunks/{AssignmentRulesPage-CR1C7V0a.js → AssignmentRulesPage-Bt9M0ki7.js} +2 -2
  38. package/dist/chunks/{AssignmentRulesPage-CR1C7V0a.js.map → AssignmentRulesPage-Bt9M0ki7.js.map} +1 -1
  39. package/dist/chunks/{AssignmentRulesPage-C4Jouh2g.js → AssignmentRulesPage-Y7xv60NY.js} +2 -2
  40. package/dist/chunks/{AssignmentRulesPage-C4Jouh2g.js.map → AssignmentRulesPage-Y7xv60NY.js.map} +1 -1
  41. package/dist/chunks/{AssignmentsPage-v8QUJkE7.js → AssignmentsPage-1eQGTjTi.js} +2 -2
  42. package/dist/chunks/{AssignmentsPage-v8QUJkE7.js.map → AssignmentsPage-1eQGTjTi.js.map} +1 -1
  43. package/dist/chunks/{AssignmentsPage-CjuGAd8n.js → AssignmentsPage-RURdPvfZ.js} +2 -2
  44. package/dist/chunks/{AssignmentsPage-CjuGAd8n.js.map → AssignmentsPage-RURdPvfZ.js.map} +1 -1
  45. package/dist/chunks/{AuthCallbackPage-BxIXPUJk.js → AuthCallbackPage-8hF0jYlK.js} +2 -2
  46. package/dist/chunks/{AuthCallbackPage-BxIXPUJk.js.map → AuthCallbackPage-8hF0jYlK.js.map} +1 -1
  47. package/dist/chunks/{AuthCallbackPage-CuS-efzY.js → AuthCallbackPage-DPL68Asu.js} +2 -2
  48. package/dist/chunks/{AuthCallbackPage-CuS-efzY.js.map → AuthCallbackPage-DPL68Asu.js.map} +1 -1
  49. package/dist/chunks/{ConfirmEmailPage-CWIqy2bT.js → ConfirmEmailPage-BKlpZkVk.js} +2 -2
  50. package/dist/chunks/{ConfirmEmailPage-CWIqy2bT.js.map → ConfirmEmailPage-BKlpZkVk.js.map} +1 -1
  51. package/dist/chunks/{ConfirmEmailPage-CkN8IfP-.js → ConfirmEmailPage-CawSZypI.js} +2 -2
  52. package/dist/chunks/{ConfirmEmailPage-CkN8IfP-.js.map → ConfirmEmailPage-CawSZypI.js.map} +1 -1
  53. package/dist/chunks/{CreateSupportTicketPage-Df0ow5ge.js → CreateSupportTicketPage-AwbMbBIH.js} +2 -2
  54. package/dist/chunks/{CreateSupportTicketPage-Df0ow5ge.js.map → CreateSupportTicketPage-AwbMbBIH.js.map} +1 -1
  55. package/dist/chunks/{CreateSupportTicketPage-CmrDfFxP.js → CreateSupportTicketPage-Dg1YW1eA.js} +2 -2
  56. package/dist/chunks/{CreateSupportTicketPage-CmrDfFxP.js.map → CreateSupportTicketPage-Dg1YW1eA.js.map} +1 -1
  57. package/dist/chunks/{DashboardPage-B4Pi5P3O.js → DashboardPage-B4YxOF-9.js} +3 -3
  58. package/dist/chunks/{DashboardPage-B4Pi5P3O.js.map → DashboardPage-B4YxOF-9.js.map} +1 -1
  59. package/dist/chunks/{DashboardPage-wEKZ_DWf.js → DashboardPage-BZxjinar.js} +2 -2
  60. package/dist/chunks/{DashboardPage-wEKZ_DWf.js.map → DashboardPage-BZxjinar.js.map} +1 -1
  61. package/dist/chunks/{DashboardPage-BAqpoxCW.js → DashboardPage-Bo09y8r7.js} +3 -3
  62. package/dist/chunks/{DashboardPage-BAqpoxCW.js.map → DashboardPage-Bo09y8r7.js.map} +1 -1
  63. package/dist/chunks/{DashboardPage-BT5kFaQA.js → DashboardPage-Cq5adDjP.js} +2 -2
  64. package/dist/chunks/{DashboardPage-BT5kFaQA.js.map → DashboardPage-Cq5adDjP.js.map} +1 -1
  65. package/dist/chunks/{EscalationConfigPage-4pF38E4N.js → EscalationConfigPage-C8Hv5naz.js} +2 -2
  66. package/dist/chunks/{EscalationConfigPage-4pF38E4N.js.map → EscalationConfigPage-C8Hv5naz.js.map} +1 -1
  67. package/dist/chunks/{EscalationConfigPage-Bcifnt_h.js → EscalationConfigPage-DNAqMRxA.js} +2 -2
  68. package/dist/chunks/{EscalationConfigPage-Bcifnt_h.js.map → EscalationConfigPage-DNAqMRxA.js.map} +1 -1
  69. package/dist/chunks/{ForceChangePasswordPage-CBaMV_PS.js → ForceChangePasswordPage-BURE_vNg.js} +2 -2
  70. package/dist/chunks/{ForceChangePasswordPage-CBaMV_PS.js.map → ForceChangePasswordPage-BURE_vNg.js.map} +1 -1
  71. package/dist/chunks/{ForceChangePasswordPage-ClDXluX1.js → ForceChangePasswordPage-C6jDZshk.js} +2 -2
  72. package/dist/chunks/{ForceChangePasswordPage-ClDXluX1.js.map → ForceChangePasswordPage-C6jDZshk.js.map} +1 -1
  73. package/dist/chunks/{ForgotPasswordPage--ueWRNSO.js → ForgotPasswordPage-C5HLYbz4.js} +2 -2
  74. package/dist/chunks/{ForgotPasswordPage--ueWRNSO.js.map → ForgotPasswordPage-C5HLYbz4.js.map} +1 -1
  75. package/dist/chunks/{ForgotPasswordPage-CzpAkP5R.js → ForgotPasswordPage-D3ZQBtjd.js} +2 -2
  76. package/dist/chunks/{ForgotPasswordPage-CzpAkP5R.js.map → ForgotPasswordPage-D3ZQBtjd.js.map} +1 -1
  77. package/dist/chunks/{GroupDetailPage-dXNOoSXE.js → GroupDetailPage-CTuzp9Vp.js} +5 -5
  78. package/dist/chunks/{GroupDetailPage-dXNOoSXE.js.map → GroupDetailPage-CTuzp9Vp.js.map} +1 -1
  79. package/dist/chunks/{GroupDetailPage-BIgBzQk0.js → GroupDetailPage-NJc2zCxC.js} +2 -2
  80. package/dist/chunks/{GroupDetailPage-BIgBzQk0.js.map → GroupDetailPage-NJc2zCxC.js.map} +1 -1
  81. package/dist/chunks/{MyAccessRequestsPage-K2NXkdy4.js → MyAccessRequestsPage-Cvr29Pnq.js} +2 -2
  82. package/dist/chunks/{MyAccessRequestsPage-K2NXkdy4.js.map → MyAccessRequestsPage-Cvr29Pnq.js.map} +1 -1
  83. package/dist/chunks/{MyAccessRequestsPage-Be8VvLhh.js → MyAccessRequestsPage-t6I24rHN.js} +2 -2
  84. package/dist/chunks/{MyAccessRequestsPage-Be8VvLhh.js.map → MyAccessRequestsPage-t6I24rHN.js.map} +1 -1
  85. package/dist/chunks/{MyTenantsPage-BXx1nPC8.js → MyTenantsPage-Dy2RZ_Ei.js} +2 -2
  86. package/dist/chunks/{MyTenantsPage-BXx1nPC8.js.map → MyTenantsPage-Dy2RZ_Ei.js.map} +1 -1
  87. package/dist/chunks/{MyTenantsPage-B9ZAUeCa.js → MyTenantsPage-SvDCQ4Wt.js} +3 -3
  88. package/dist/chunks/{MyTenantsPage-B9ZAUeCa.js.map → MyTenantsPage-SvDCQ4Wt.js.map} +1 -1
  89. package/dist/chunks/{MyTicketsPage-C9MSmmR5.js → MyTicketsPage-C3lEBFD9.js} +2 -2
  90. package/dist/chunks/{MyTicketsPage-C9MSmmR5.js.map → MyTicketsPage-C3lEBFD9.js.map} +1 -1
  91. package/dist/chunks/{MyTicketsPage-d0PoJpnX.js → MyTicketsPage-DydDgFyz.js} +2 -2
  92. package/dist/chunks/{MyTicketsPage-d0PoJpnX.js.map → MyTicketsPage-DydDgFyz.js.map} +1 -1
  93. package/dist/chunks/{NavigationAppsPage-CJ3BjLlz.js → NavigationAppsPage-Dyv767w8.js} +2 -2
  94. package/dist/chunks/{NavigationAppsPage-CJ3BjLlz.js.map → NavigationAppsPage-Dyv767w8.js.map} +1 -1
  95. package/dist/chunks/{NavigationAppsPage-8t2xbddT.js → NavigationAppsPage-WqSspaVo.js} +2 -2
  96. package/dist/chunks/{NavigationAppsPage-8t2xbddT.js.map → NavigationAppsPage-WqSspaVo.js.map} +1 -1
  97. package/dist/chunks/{NotificationsPage-_62-bmuk.js → NotificationsPage-Di4I95PM.js} +2 -2
  98. package/dist/chunks/{NotificationsPage-_62-bmuk.js.map → NotificationsPage-Di4I95PM.js.map} +1 -1
  99. package/dist/chunks/{NotificationsPage-CLHfVUxm.js → NotificationsPage-elSovpBw.js} +2 -2
  100. package/dist/chunks/{NotificationsPage-CLHfVUxm.js.map → NotificationsPage-elSovpBw.js.map} +1 -1
  101. package/dist/chunks/{OnboardingWizardPage-Dkc22Jc4.js → OnboardingWizardPage-fdWdkwiT.js} +2 -2
  102. package/dist/chunks/{OnboardingWizardPage-Dkc22Jc4.js.map → OnboardingWizardPage-fdWdkwiT.js.map} +1 -1
  103. package/dist/chunks/{OnboardingWizardPage-D1rzD6gR.js → OnboardingWizardPage-nPLe2buQ.js} +2 -2
  104. package/dist/chunks/{OnboardingWizardPage-D1rzD6gR.js.map → OnboardingWizardPage-nPLe2buQ.js.map} +1 -1
  105. package/dist/chunks/{PermissionDetailPage-BSvSe4SI.js → PermissionDetailPage-B8C7tWFP.js} +2 -2
  106. package/dist/chunks/{PermissionDetailPage-BSvSe4SI.js.map → PermissionDetailPage-B8C7tWFP.js.map} +1 -1
  107. package/dist/chunks/{PermissionDetailPage-_HhbxzlG.js → PermissionDetailPage-IUgUaTkE.js} +2 -2
  108. package/dist/chunks/{PermissionDetailPage-_HhbxzlG.js.map → PermissionDetailPage-IUgUaTkE.js.map} +1 -1
  109. package/dist/chunks/{PermissionsPage-Xb92YAHn.js → PermissionsPage-CmX5sQf2.js} +2 -2
  110. package/dist/chunks/{PermissionsPage-Xb92YAHn.js.map → PermissionsPage-CmX5sQf2.js.map} +1 -1
  111. package/dist/chunks/{PermissionsPage-B0M4gA5m.js → PermissionsPage-Kg0rduOM.js} +2 -2
  112. package/dist/chunks/{PermissionsPage-B0M4gA5m.js.map → PermissionsPage-Kg0rduOM.js.map} +1 -1
  113. package/dist/chunks/{PortalDashboardPage-DTeMESj9.js → PortalDashboardPage-CCAYuhtI.js} +2 -2
  114. package/dist/chunks/{PortalDashboardPage-DTeMESj9.js.map → PortalDashboardPage-CCAYuhtI.js.map} +1 -1
  115. package/dist/chunks/{PortalDashboardPage-pt9hipR4.js → PortalDashboardPage-Dme1XmzN.js} +2 -2
  116. package/dist/chunks/{PortalDashboardPage-pt9hipR4.js.map → PortalDashboardPage-Dme1XmzN.js.map} +1 -1
  117. package/dist/chunks/{PreferencesPage-Cy30AWIN.js → PreferencesPage-Ct6xWAFp.js} +2 -2
  118. package/dist/chunks/{PreferencesPage-Cy30AWIN.js.map → PreferencesPage-Ct6xWAFp.js.map} +1 -1
  119. package/dist/chunks/{PreferencesPage-CsHVGMgp.js → PreferencesPage-Db2RjMpm.js} +2 -2
  120. package/dist/chunks/{PreferencesPage-CsHVGMgp.js.map → PreferencesPage-Db2RjMpm.js.map} +1 -1
  121. package/dist/chunks/{ProfilePage-6Gf7igUI.js → ProfilePage-D6Xb1ALH.js} +2 -2
  122. package/dist/chunks/{ProfilePage-6Gf7igUI.js.map → ProfilePage-D6Xb1ALH.js.map} +1 -1
  123. package/dist/chunks/{ProfilePage-BzBWkztf.js → ProfilePage-DN2s-lfp.js} +2 -2
  124. package/dist/chunks/{ProfilePage-BzBWkztf.js.map → ProfilePage-DN2s-lfp.js.map} +1 -1
  125. package/dist/chunks/{ReferencesManagementPage-DEDoHrnU.js → ReferencesManagementPage-B5mcshG1.js} +2 -2
  126. package/dist/chunks/{ReferencesManagementPage-DEDoHrnU.js.map → ReferencesManagementPage-B5mcshG1.js.map} +1 -1
  127. package/dist/chunks/{ReferencesManagementPage-DD1QiFYr.js → ReferencesManagementPage-DB975ktX.js} +3 -3
  128. package/dist/chunks/{ReferencesManagementPage-DD1QiFYr.js.map → ReferencesManagementPage-DB975ktX.js.map} +1 -1
  129. package/dist/chunks/{RegisterPage-asdx33fV.js → RegisterPage-ZskZrLZH.js} +2 -2
  130. package/dist/chunks/{RegisterPage-asdx33fV.js.map → RegisterPage-ZskZrLZH.js.map} +1 -1
  131. package/dist/chunks/{RegisterPage-CIPHRYkl.js → RegisterPage-b8yIPVgh.js} +2 -2
  132. package/dist/chunks/{RegisterPage-CIPHRYkl.js.map → RegisterPage-b8yIPVgh.js.map} +1 -1
  133. package/dist/chunks/{ResetPasswordPage-B4Dj24vU.js → ResetPasswordPage-CeAvfsE-.js} +2 -2
  134. package/dist/chunks/{ResetPasswordPage-B4Dj24vU.js.map → ResetPasswordPage-CeAvfsE-.js.map} +1 -1
  135. package/dist/chunks/{ResetPasswordPage-B8MWH_Vi.js → ResetPasswordPage-Dzp5dCp8.js} +2 -2
  136. package/dist/chunks/{ResetPasswordPage-B8MWH_Vi.js.map → ResetPasswordPage-Dzp5dCp8.js.map} +1 -1
  137. package/dist/chunks/{ResolutionModal-Cs6T441o.js → ResolutionModal-CRVN7gHv.js} +2 -2
  138. package/dist/chunks/{ResolutionModal-Cs6T441o.js.map → ResolutionModal-CRVN7gHv.js.map} +1 -1
  139. package/dist/chunks/{ResolutionModal-rLoFOxm9.js → ResolutionModal-DJOw1sLT.js} +2 -2
  140. package/dist/chunks/{ResolutionModal-rLoFOxm9.js.map → ResolutionModal-DJOw1sLT.js.map} +1 -1
  141. package/dist/chunks/{RoleDetailPage-Pkw0wU5g.js → RoleDetailPage-CLVoFVF8.js} +2 -2
  142. package/dist/chunks/{RoleDetailPage-Pkw0wU5g.js.map → RoleDetailPage-CLVoFVF8.js.map} +1 -1
  143. package/dist/chunks/{RoleDetailPage-CNFG6j6P.js → RoleDetailPage-XGnPD_8C.js} +3 -3
  144. package/dist/chunks/{RoleDetailPage-CNFG6j6P.js.map → RoleDetailPage-XGnPD_8C.js.map} +1 -1
  145. package/dist/chunks/{RolesPage-BHEkMR2O.js → RolesPage-BnAMpR2b.js} +2 -2
  146. package/dist/chunks/{RolesPage-BHEkMR2O.js.map → RolesPage-BnAMpR2b.js.map} +1 -1
  147. package/dist/chunks/{RolesPage-D35jwDJU.js → RolesPage-Czj9LMkL.js} +2 -2
  148. package/dist/chunks/{RolesPage-D35jwDJU.js.map → RolesPage-Czj9LMkL.js.map} +1 -1
  149. package/dist/chunks/{SlaConfigPage-DtonDehw.js → SlaConfigPage-HM0MpIlg.js} +2 -2
  150. package/dist/chunks/{SlaConfigPage-DtonDehw.js.map → SlaConfigPage-HM0MpIlg.js.map} +1 -1
  151. package/dist/chunks/{SlaConfigPage-C5Jstix-.js → SlaConfigPage-ZRyAs8aY.js} +2 -2
  152. package/dist/chunks/{SlaConfigPage-C5Jstix-.js.map → SlaConfigPage-ZRyAs8aY.js.map} +1 -1
  153. package/dist/chunks/{SupportPermissionsPage-6pC73oCY.js → SupportPermissionsPage-CxJuGgcQ.js} +2 -2
  154. package/dist/chunks/{SupportPermissionsPage-6pC73oCY.js.map → SupportPermissionsPage-CxJuGgcQ.js.map} +1 -1
  155. package/dist/chunks/{SupportPermissionsPage-CsJKGt__.js → SupportPermissionsPage-DNd323OK.js} +2 -2
  156. package/dist/chunks/{SupportPermissionsPage-CsJKGt__.js.map → SupportPermissionsPage-DNd323OK.js.map} +1 -1
  157. package/dist/chunks/{TemplatesPage-DjmYOGEC.js → TemplatesPage-CdwPLsHj.js} +2 -2
  158. package/dist/chunks/{TemplatesPage-DjmYOGEC.js.map → TemplatesPage-CdwPLsHj.js.map} +1 -1
  159. package/dist/chunks/{TemplatesPage-DlY91VO_.js → TemplatesPage-Co3ygZvF.js} +2 -2
  160. package/dist/chunks/{TemplatesPage-DlY91VO_.js.map → TemplatesPage-Co3ygZvF.js.map} +1 -1
  161. package/dist/chunks/{TenantCard-BHLcv2gD.js → TenantCard-CmCfIK2F.js} +2 -2
  162. package/dist/chunks/{TenantCard-BHLcv2gD.js.map → TenantCard-CmCfIK2F.js.map} +1 -1
  163. package/dist/chunks/{TenantCard-DGCKVvKI.js → TenantCard-DI66acce.js} +2 -2
  164. package/dist/chunks/{TenantCard-DGCKVvKI.js.map → TenantCard-DI66acce.js.map} +1 -1
  165. package/dist/chunks/{TenantScopeSelector-dsSwnOWg.js → TenantScopeSelector-5NOwmFX2.js} +2 -2
  166. package/dist/chunks/{TenantScopeSelector-dsSwnOWg.js.map → TenantScopeSelector-5NOwmFX2.js.map} +1 -1
  167. package/dist/chunks/{TenantScopeSelector-CU5z5PJH.js → TenantScopeSelector-CEFgxiWt.js} +2 -2
  168. package/dist/chunks/{TenantScopeSelector-CU5z5PJH.js.map → TenantScopeSelector-CEFgxiWt.js.map} +1 -1
  169. package/dist/chunks/{TicketDetailPage-BQHMaRmq.js → TicketDetailPage-BhZ-mpv7.js} +2 -2
  170. package/dist/chunks/{TicketDetailPage-BQHMaRmq.js.map → TicketDetailPage-BhZ-mpv7.js.map} +1 -1
  171. package/dist/chunks/{TicketDetailPage-Bk_0uQ3B.js → TicketDetailPage-BxOiOG22.js} +2 -2
  172. package/dist/chunks/{TicketDetailPage-Bk_0uQ3B.js.map → TicketDetailPage-BxOiOG22.js.map} +1 -1
  173. package/dist/chunks/{TicketsPage-CufUJctx.js → TicketsPage-BiTvIcM8.js} +2 -2
  174. package/dist/chunks/{TicketsPage-CufUJctx.js.map → TicketsPage-BiTvIcM8.js.map} +1 -1
  175. package/dist/chunks/{TicketsPage-C8QQ4SKy.js → TicketsPage-CSiinHME.js} +2 -2
  176. package/dist/chunks/{TicketsPage-C8QQ4SKy.js.map → TicketsPage-CSiinHME.js.map} +1 -1
  177. package/dist/chunks/{UserCreateTicketPage-DoEMtJoe.js → UserCreateTicketPage-B3TW1oV7.js} +2 -2
  178. package/dist/chunks/{UserCreateTicketPage-DoEMtJoe.js.map → UserCreateTicketPage-B3TW1oV7.js.map} +1 -1
  179. package/dist/chunks/{UserCreateTicketPage-XxjNlR9K.js → UserCreateTicketPage-BszUd_WZ.js} +2 -2
  180. package/dist/chunks/{UserCreateTicketPage-XxjNlR9K.js.map → UserCreateTicketPage-BszUd_WZ.js.map} +1 -1
  181. package/dist/chunks/{UserDashboardPage-fdhZwMLg.js → UserDashboardPage-C6MvatAb.js} +2 -2
  182. package/dist/chunks/{UserDashboardPage-fdhZwMLg.js.map → UserDashboardPage-C6MvatAb.js.map} +1 -1
  183. package/dist/chunks/{UserDashboardPage-BV1d2hMG.js → UserDashboardPage-Dtt9VzG_.js} +2 -2
  184. package/dist/chunks/{UserDashboardPage-BV1d2hMG.js.map → UserDashboardPage-Dtt9VzG_.js.map} +1 -1
  185. package/dist/chunks/{UserDetailPage-C97e-Dax.js → UserDetailPage-BEEV2vlJ.js} +5 -5
  186. package/dist/chunks/{UserDetailPage-C97e-Dax.js.map → UserDetailPage-BEEV2vlJ.js.map} +1 -1
  187. package/dist/chunks/{UserDetailPage-BcA7Vhb2.js → UserDetailPage-Dw5OHheZ.js} +2 -2
  188. package/dist/chunks/{UserDetailPage-BcA7Vhb2.js.map → UserDetailPage-Dw5OHheZ.js.map} +1 -1
  189. package/dist/chunks/{UserTicketDetailPage-BA2syxXG.js → UserTicketDetailPage-B4YkzzbR.js} +2 -2
  190. package/dist/chunks/{UserTicketDetailPage-BA2syxXG.js.map → UserTicketDetailPage-B4YkzzbR.js.map} +1 -1
  191. package/dist/chunks/{UserTicketDetailPage-CXuZVAa2.js → UserTicketDetailPage-DCFV-0ny.js} +2 -2
  192. package/dist/chunks/{UserTicketDetailPage-CXuZVAa2.js.map → UserTicketDetailPage-DCFV-0ny.js.map} +1 -1
  193. package/dist/chunks/{UsersGroupsPage-CPVk31Dh.js → UsersGroupsPage-CY-l9fTp.js} +3 -3
  194. package/dist/chunks/{UsersGroupsPage-CPVk31Dh.js.map → UsersGroupsPage-CY-l9fTp.js.map} +1 -1
  195. package/dist/chunks/{UsersGroupsPage-DS2YiUE4.js → UsersGroupsPage-c28vYHN9.js} +2 -2
  196. package/dist/chunks/{UsersGroupsPage-DS2YiUE4.js.map → UsersGroupsPage-c28vYHN9.js.map} +1 -1
  197. package/dist/chunks/{UsersPage-BIXWHFmG.js → UsersPage-1sLlq9QD.js} +2 -2
  198. package/dist/chunks/{UsersPage-BIXWHFmG.js.map → UsersPage-1sLlq9QD.js.map} +1 -1
  199. package/dist/chunks/{UsersPage-DS8aWUKj.js → UsersPage-Bm-uNxh0.js} +2 -2
  200. package/dist/chunks/{UsersPage-DS8aWUKj.js.map → UsersPage-Bm-uNxh0.js.map} +1 -1
  201. package/dist/chunks/{accessRequestsApi-C-r0mrCH.js → accessRequestsApi-CJPjyEkH.js} +2 -2
  202. package/dist/chunks/{accessRequestsApi-C-r0mrCH.js.map → accessRequestsApi-CJPjyEkH.js.map} +1 -1
  203. package/dist/chunks/{accessRequestsApi-k3ZwhcFb.js → accessRequestsApi-D_pj1wl6.js} +2 -2
  204. package/dist/chunks/{accessRequestsApi-k3ZwhcFb.js.map → accessRequestsApi-D_pj1wl6.js.map} +1 -1
  205. package/dist/chunks/{aiApi-B-H-76wM.js → aiApi-ByF-oo1J.js} +2 -2
  206. package/dist/chunks/{aiApi-B-H-76wM.js.map → aiApi-ByF-oo1J.js.map} +1 -1
  207. package/dist/chunks/{aiApi-CcdrBILv.js → aiApi-Dt3fj0dU.js} +2 -2
  208. package/dist/chunks/{aiApi-CcdrBILv.js.map → aiApi-Dt3fj0dU.js.map} +1 -1
  209. package/dist/chunks/{applicationAnalyticsApi-CO3tk6Ju.js → applicationAnalyticsApi-BgG3SGJm.js} +2 -2
  210. package/dist/chunks/{applicationAnalyticsApi-CO3tk6Ju.js.map → applicationAnalyticsApi-BgG3SGJm.js.map} +1 -1
  211. package/dist/chunks/{applicationAnalyticsApi-CLVdVLDu.js → applicationAnalyticsApi-ktD65iLO.js} +2 -2
  212. package/dist/chunks/{applicationAnalyticsApi-CLVdVLDu.js.map → applicationAnalyticsApi-ktD65iLO.js.map} +1 -1
  213. package/dist/chunks/{groupsApi-DExOJZPF.js → groupsApi-C-FLWPCO.js} +2 -2
  214. package/dist/chunks/{groupsApi-DExOJZPF.js.map → groupsApi-C-FLWPCO.js.map} +1 -1
  215. package/dist/chunks/{groupsApi-CyqyYsmi.js → groupsApi-CBI5vMLa.js} +2 -2
  216. package/dist/chunks/{groupsApi-CyqyYsmi.js.map → groupsApi-CBI5vMLa.js.map} +1 -1
  217. package/dist/chunks/{index-DtAReZI6.js → index-B727-QSU.js} +2 -2
  218. package/dist/chunks/{index-DtAReZI6.js.map → index-B727-QSU.js.map} +1 -1
  219. package/dist/chunks/{index-BlOgmQzc.js → index-B9q3vx13.js} +2 -2
  220. package/dist/chunks/{index-BlOgmQzc.js.map → index-B9q3vx13.js.map} +1 -1
  221. package/dist/chunks/{index-VSQ2prtJ.js → index-BD-REzV9.js} +2 -2
  222. package/dist/chunks/{index-VSQ2prtJ.js.map → index-BD-REzV9.js.map} +1 -1
  223. package/dist/chunks/{index-XOOiD_zY.js → index-BDRogQH_.js} +3 -3
  224. package/dist/chunks/{index-XOOiD_zY.js.map → index-BDRogQH_.js.map} +1 -1
  225. package/dist/chunks/{index-DOQyf5yZ.js → index-C-DYxdvd.js} +8 -8
  226. package/dist/chunks/{index-DOQyf5yZ.js.map → index-C-DYxdvd.js.map} +1 -1
  227. package/dist/chunks/{index-Cq80YBne.js → index-CBtjGPod.js} +105 -105
  228. package/dist/chunks/{index-Cq80YBne.js.map → index-CBtjGPod.js.map} +1 -1
  229. package/dist/chunks/{index-dlXYTPWH.js → index-CF1cvNUL.js} +4 -4
  230. package/dist/chunks/{index-dlXYTPWH.js.map → index-CF1cvNUL.js.map} +1 -1
  231. package/dist/chunks/{index-COA_xJVJ.js → index-CH0pTHy1.js} +2 -2
  232. package/dist/chunks/{index-COA_xJVJ.js.map → index-CH0pTHy1.js.map} +1 -1
  233. package/dist/chunks/{index-DjZQ6ZG_.js → index-Ca88RIuT.js} +2 -2
  234. package/dist/chunks/{index-DjZQ6ZG_.js.map → index-Ca88RIuT.js.map} +1 -1
  235. package/dist/chunks/{index-Cj-9tGpd.js → index-CkWvsvKW.js} +2 -2
  236. package/dist/chunks/{index-Cj-9tGpd.js.map → index-CkWvsvKW.js.map} +1 -1
  237. package/dist/chunks/{index-EL_ZNnMH.js → index-CzYKE5fL.js} +2 -2
  238. package/dist/chunks/{index-EL_ZNnMH.js.map → index-CzYKE5fL.js.map} +1 -1
  239. package/dist/chunks/{index-qXfYaEmV.js → index-D32ol7lq.js} +2 -2
  240. package/dist/chunks/{index-qXfYaEmV.js.map → index-D32ol7lq.js.map} +1 -1
  241. package/dist/chunks/{index-DMQQ0KyA.js → index-D7hmx9IX.js} +2 -2
  242. package/dist/chunks/{index-DMQQ0KyA.js.map → index-D7hmx9IX.js.map} +1 -1
  243. package/dist/chunks/{index-BetDcNZm.js → index-DThcQmwZ.js} +2 -2
  244. package/dist/chunks/{index-BetDcNZm.js.map → index-DThcQmwZ.js.map} +1 -1
  245. package/dist/chunks/{index-C7h5yvcP.js → index-D_3J6ziZ.js} +2 -2
  246. package/dist/chunks/{index-C7h5yvcP.js.map → index-D_3J6ziZ.js.map} +1 -1
  247. package/dist/chunks/{index-C_nDTEP5.js → index-JSjfMShT.js} +2 -2
  248. package/dist/chunks/{index-C_nDTEP5.js.map → index-JSjfMShT.js.map} +1 -1
  249. package/dist/chunks/{index-COXxU0FH.js → index-gzXJw_ow.js} +3 -3
  250. package/dist/chunks/{index-COXxU0FH.js.map → index-gzXJw_ow.js.map} +1 -1
  251. package/dist/chunks/{index-jJxtz2bs.js → index-rRAbl04H.js} +2 -2
  252. package/dist/chunks/{index-jJxtz2bs.js.map → index-rRAbl04H.js.map} +1 -1
  253. package/dist/chunks/{tenantIconMap-Ddvguo0l.js → tenantIconMap-Cw-hQ9n4.js} +2 -2
  254. package/dist/chunks/{tenantIconMap-Ddvguo0l.js.map → tenantIconMap-Cw-hQ9n4.js.map} +1 -1
  255. package/dist/chunks/{tenantIconMap-DBa5MjIz.js → tenantIconMap-DinwojNW.js} +2 -2
  256. package/dist/chunks/{tenantIconMap-DBa5MjIz.js.map → tenantIconMap-DinwojNW.js.map} +1 -1
  257. package/dist/chunks/{ticketingApi-Cr6QSv0g.js → ticketingApi-CcWdebXv.js} +2 -2
  258. package/dist/chunks/{ticketingApi-Cr6QSv0g.js.map → ticketingApi-CcWdebXv.js.map} +1 -1
  259. package/dist/chunks/{ticketingApi-D6s75rOB.js → ticketingApi-x0BwZ1NH.js} +2 -2
  260. package/dist/chunks/{ticketingApi-D6s75rOB.js.map → ticketingApi-x0BwZ1NH.js.map} +1 -1
  261. package/dist/chunks/{useAccessRequests-VuQT-n-P.js → useAccessRequests-BBTIYht3.js} +2 -2
  262. package/dist/chunks/{useAccessRequests-VuQT-n-P.js.map → useAccessRequests-BBTIYht3.js.map} +1 -1
  263. package/dist/chunks/{useAccessRequests-CanI2ypo.js → useAccessRequests-BBUj9XY9.js} +71 -71
  264. package/dist/chunks/{useAccessRequests-CanI2ypo.js.map → useAccessRequests-BBUj9XY9.js.map} +1 -1
  265. package/dist/chunks/{useUserAccessRequests-BEVZLX_M.js → useUserAccessRequests-BKQxcOXH.js} +2 -2
  266. package/dist/chunks/{useUserAccessRequests-BEVZLX_M.js.map → useUserAccessRequests-BKQxcOXH.js.map} +1 -1
  267. package/dist/chunks/{useUserAccessRequests-Ba40FDLm.js → useUserAccessRequests-BPUPiP55.js} +2 -2
  268. package/dist/chunks/{useUserAccessRequests-Ba40FDLm.js.map → useUserAccessRequests-BPUPiP55.js.map} +1 -1
  269. package/dist/pages/platform/administration/applications/ApplicationDetailPage.d.ts.map +1 -1
  270. package/dist/smartstack.cjs +1 -1
  271. package/dist/smartstack.js +1 -1
  272. package/package.json +1 -1
  273. package/dist/chunks/ApplicationDetailPage-CWdz0TS4.js +0 -2
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),U=require("react-router-dom"),J=require("react-i18next"),a=require("lucide-react"),w=require("./index-XOOiD_zY.js"),ae=require("@tiptap/react"),ie=require("@tiptap/starter-kit"),le=require("@tiptap/extension-link"),ne=require("@tiptap/extension-image"),oe=require("@tiptap/extension-placeholder"),ce=require("@tiptap/extension-text-align"),de=require("@tiptap/extension-underline"),me=require("@tiptap/extension-text-style"),xe=require("@tiptap/extension-color"),pe=require("@tiptap/extension-highlight"),ue=require("@monaco-editor/react"),F={emailTemplates:{getAll:t=>w.api.get("/api/administration/workflows/email-templates",{params:t}),getById:t=>w.api.get(`/api/administration/workflows/email-templates/${t}`),getByCode:t=>w.api.get(`/api/administration/workflows/email-templates/by-code/${t}`),create:t=>w.api.post("/api/administration/workflows/email-templates",t),update:(t,s)=>w.api.put(`/api/administration/workflows/email-templates/${t}`,s),delete:t=>w.api.delete(`/api/administration/workflows/email-templates/${t}`),activate:t=>w.api.patch(`/api/administration/workflows/email-templates/${t}/activate`),deactivate:t=>w.api.patch(`/api/administration/workflows/email-templates/${t}/deactivate`),preview:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/preview`,s),testSend:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/test-send`,s),getTranslation:(t,s)=>w.api.get(`/api/administration/workflows/email-templates/${t}/translations/${s}`),createTranslation:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/translations`,s),updateTranslation:(t,s,x)=>w.api.put(`/api/administration/workflows/email-templates/${t}/translations/${s}`,x)},workflows:{getAll:t=>w.api.get("/api/administration/workflows/definitions",{params:t}),getById:t=>w.api.get(`/api/administration/workflows/definitions/${t}`),create:t=>w.api.post("/api/administration/workflows/definitions",t),update:(t,s)=>w.api.put(`/api/administration/workflows/definitions/${t}`,s),delete:t=>w.api.delete(`/api/administration/workflows/definitions/${t}`),activate:t=>w.api.patch(`/api/administration/workflows/definitions/${t}/activate`),deactivate:t=>w.api.patch(`/api/administration/workflows/definitions/${t}/deactivate`),addStep:(t,s)=>w.api.post(`/api/administration/workflows/definitions/${t}/steps`,s),updateStep:(t,s,x)=>w.api.put(`/api/administration/workflows/definitions/${t}/steps/${s}`,x),deleteStep:(t,s)=>w.api.delete(`/api/administration/workflows/definitions/${t}/steps/${s}`),reorderSteps:(t,s)=>w.api.post(`/api/administration/workflows/definitions/${t}/steps/reorder`,{stepOrder:s})},triggers:{getAll:()=>w.api.get("/api/administration/workflows/definitions/triggers")}};function ve(){const{t}=J.useTranslation("communications"),s=U.useNavigate(),{currentTenant:x,isGlobalView:i}=w.useTenant(),[r,g]=l.useState([]),[u,k]=l.useState(!0),[v,d]=l.useState(""),[n,E]=l.useState("table"),[M,L]=l.useState(1),h=20,f=l.useCallback(async()=>{try{k(!0);const p=await F.emailTemplates.getAll({search:v||void 0});g(Array.isArray(p)?p:[])}catch(p){console.error("Failed to load templates:",p)}finally{k(!1)}},[v]);l.useEffect(()=>{f()},[f,x?.id,i]);const c=p=>{p.preventDefault(),L(1),f()},C=async(p,V)=>{if(V?.stopPropagation(),p.isSystem){alert(t("emailTemplates.cannotDeleteSystem"));return}if(confirm(t("emailTemplates.confirmDelete",{name:p.name})))try{await F.emailTemplates.delete(p.id),f()}catch(G){console.error("Failed to delete template:",G)}},B=(M-1)*h,T=r.slice(B,B+h),I=Math.ceil(r.length/h),A={transactional:r.filter(p=>p.category==="transactional"),notification:r.filter(p=>p.category==="notification"),marketing:r.filter(p=>p.category==="marketing"),system:r.filter(p=>p.category==="system")},b=p=>t(`emailTemplates.categories.${p.toLowerCase()}`)||p,S=()=>e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"w-12 px-4 py-3",children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.code")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.name")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:t("emailTemplates.columns.category")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:t("emailTemplates.columns.translations")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.status")}),e.jsx("th",{className:"w-32 px-4 py-3"})]})}),e.jsxs("tbody",{className:"divide-y divide-[var(--border-color)]",children:[u&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]})})}),!u&&T.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(a.Mail,{className:"w-8 h-8 text-[var(--text-tertiary)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.noResults")})]})})}),!u&&T.length>0&&T.map(p=>e.jsxs("tr",{className:"group hover:bg-[var(--bg-hover)] transition-all cursor-pointer",onClick:()=>s(`/administration/workflows/email-templates/${p.id}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:V=>V.stopPropagation(),children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Mail,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("code",{className:"text-sm bg-[var(--bg-secondary)] px-2 py-0.5 rounded text-[var(--text-primary)]",children:p.code})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] group-hover:text-primary-600 transition-colors",children:p.name}),p.isSystem&&e.jsx("span",{className:"inline-flex items-center gap-1 mt-1 px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"System"})]})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:b(p.category)})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:p.languages.length})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(w.StatusBadge,{status:p.isActive?"active":"inactive",label:p.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:V=>V.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/email-templates/${p.id}`),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-primary-600 hover:bg-[var(--accent-bg)] transition-all",title:t("emailTemplates.view"),children:e.jsx(a.Eye,{className:"w-4 h-4"})}),e.jsx("button",{onClick:V=>{V.stopPropagation(),s(`/administration/workflows/email-templates/${p.id}/edit`)},className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--info-text)] hover:bg-[var(--info-bg)] transition-all",title:t("emailTemplates.edit.title"),children:e.jsx(a.Edit2,{className:"w-4 h-4"})}),!p.isSystem&&e.jsx("button",{onClick:V=>C(p,V),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-all",title:t("emailTemplates.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})})]},p.id))]})]})}),P=()=>u?e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):T.length===0?e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg bg-[var(--color-accent-50)] flex items-center justify-center mb-3",children:e.jsx(a.Mail,{className:"w-8 h-8 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.noResults")})]}):T.map(p=>e.jsx(w.TemplateCard,{name:p.name,code:p.code,category:b(p.category),isActive:p.isActive,isSystem:p.isSystem,icon:a.Mail,iconColor:"var(--color-accent-500)",translationsCount:p.languages.length,onClick:()=>s(`/administration/workflows/email-templates/${p.id}`),onEdit:()=>s(`/administration/workflows/email-templates/${p.id}/edit`),onDelete:()=>C(p),labels:{activeLabel:t("emailTemplates.active"),inactiveLabel:t("emailTemplates.inactive"),systemLabel:"System",editLabel:t("emailTemplates.edit.title"),deleteLabel:t("emailTemplates.delete")}},p.id)),_=()=>e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:P()}),O=p=>p==="transactional"?"bg-[var(--success-dot)]":p==="notification"?"bg-[var(--warning-dot)]":p==="marketing"?"bg-blue-500":"bg-[var(--text-muted)]",m=p=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/email-templates/${p.id}`),className:"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-md hover:border-[var(--color-accent-400)] cursor-pointer text-left w-full",children:[e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-3 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--color-accent-500)] flex items-center justify-center shadow-lg",children:e.jsx(a.Mail,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-[var(--text-primary)] truncate",children:p.name}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:p.code})]})]})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${p.isActive?"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 ${p.isActive?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),p.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")]}),e.jsxs("div",{className:"flex items-center gap-1 text-[var(--text-tertiary)]",children:[e.jsx(a.Languages,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:p.languages.length})]})]})})]},p.id),D=()=>e.jsx("div",{className:"flex gap-6 overflow-x-auto pb-4",children:u?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):e.jsx(e.Fragment,{children:Object.entries(A).map(([p,V])=>e.jsxs("div",{className:"min-w-[280px] flex-1 rounded-lg p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${O(p)}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:b(p)}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:V.length})]}),e.jsxs("div",{className:"space-y-3 min-h-[100px]",children:[V.map(m),V.length===0&&e.jsxs("div",{className:"border-2 border-dashed border-[var(--color-accent-200)] rounded-lg p-6 text-center",children:[e.jsx(a.Mail,{className:"w-6 h-6 mx-auto mb-2 text-[var(--text-muted)]"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t("emailTemplates.noResults")})]})]})]},p))})});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates")}]}),e.jsx(w.PageHeader,{title:t("emailTemplates.title"),subtitle:`${r.length} templates`,icon:e.jsx(a.Mail,{className:"w-6 h-6"}),actions:e.jsxs("button",{onClick:()=>s("/administration/workflows/email-templates/create"),className:"btn btn-primary",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.create")]})}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("form",{onSubmit:c,className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(a.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:v,onChange:p=>d(p.target.value),placeholder:t("emailTemplates.searchPlaceholder"),className:"input w-full pl-10"})]}),e.jsxs("button",{type:"submit",className:"btn btn-secondary",children:[e.jsx(a.Filter,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Filtres"})]})]}),e.jsx(w.ViewToggle,{viewMode:n,onChange:E,tableLabel:"Table",cardsLabel:"Cards",kanbanLabel:"Kanban"})]})}),n==="table"&&S(),n==="cards"&&_(),n==="kanban"&&D(),n!=="kanban"&&r.length>0&&e.jsx(w.Pagination,{page:M,totalPages:I,totalCount:r.length,pageSize:h,onPageChange:L,itemLabel:"templates"})]})}function he(){const{t}=J.useTranslation("communications"),s=U.useNavigate(),[x,i]=l.useState(!1),[r,g]=l.useState(null),[u,k]=l.useState({code:"",name:"",description:"",category:"transactional"}),v=async d=>{d.preventDefault(),i(!0),g(null);try{const n=await F.emailTemplates.create({code:u.code,name:u.name,description:u.description||void 0,category:u.category});s(`/administration/email-templates/${n.id}`)}catch(n){const E=n instanceof Error?n.message:"An error occurred while creating the template";g(E)}finally{i(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:t("emailTemplates.create","Create")}]}),e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("button",{onClick:()=>s("/administration/email-templates/list"),className:"flex items-center gap-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors mb-4",children:[e.jsx(a.ArrowLeft,{className:"w-4 h-4"}),t("emailTemplates.backToList")]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-violet-500 to-purple-500 flex items-center justify-center shadow-lg shadow-primary-500/20",children:e.jsx(a.Mail,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("emailTemplates.createTitle")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:t("emailTemplates.description")})]})]})]}),e.jsxs("form",{onSubmit:v,className:"space-y-6 max-w-2xl",children:[r&&e.jsx("div",{className:"p-4 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] text-sm border border-[var(--error-border)]",children:r}),e.jsxs("div",{className:"card p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("emailTemplates.form.code")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:u.code,onChange:d=>k(n=>({...n,code:d.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")})),placeholder:"e.g., welcome-email",className:"input w-full"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-1.5",children:t("emailTemplates.form.codeHelp")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("emailTemplates.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:u.name,onChange:d=>k(n=>({...n,name:d.target.value})),placeholder:"e.g., Welcome Email",className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("emailTemplates.form.description")}),e.jsx("textarea",{value:u.description,onChange:d=>k(n=>({...n,description:d.target.value})),rows:3,placeholder:t("emailTemplates.form.descriptionPlaceholder"),className:"input w-full resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("emailTemplates.form.category")}),e.jsxs("select",{value:u.category,onChange:d=>k(n=>({...n,category:d.target.value})),className:"input w-full",children:[e.jsx("option",{value:"transactional",children:t("emailTemplates.categories.transactional")}),e.jsx("option",{value:"marketing",children:t("emailTemplates.categories.marketing")}),e.jsx("option",{value:"notification",children:t("emailTemplates.categories.notification")}),e.jsx("option",{value:"system",children:t("emailTemplates.categories.system")})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>s("/administration/email-templates/list"),className:"btn btn-secondary",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:x,className:"btn btn-primary disabled:opacity-50",children:[x?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]})]})}const be=[{name:"userName",description:"Nom complet de l'utilisateur"},{name:"firstName",description:"Prenom"},{name:"lastName",description:"Nom de famille"},{name:"displayName",description:"Nom d'affichage (Entra)"},{name:"email",description:"Adresse email"},{name:"phoneNumber",description:"Telephone fixe"},{name:"mobilePhone",description:"Telephone mobile"},{name:"city",description:"Ville"},{name:"country",description:"Pays"},{name:"streetAddress",description:"Adresse"},{name:"postalCode",description:"Code postal"},{name:"company",description:"Nom de l'entreprise"},{name:"department",description:"Departement"},{name:"jobTitle",description:"Fonction/Poste"},{name:"office",description:"Bureau/Site"},{name:"employeeId",description:"Numero d'employe"},{name:"managerName",description:"Nom du manager"}],ge=[{name:"company_logo_url",description:"URL du logo de l'entreprise"},{name:"appName",description:"Nom de l'application"},{name:"resetUrl",description:"Lien de reinitialisation du mot de passe"},{name:"confirmUrl",description:"Lien de confirmation d'email"},{name:"adminName",description:"Nom de l'administrateur (action admin)"},{name:"expiresIn",description:"Delai d'expiration du lien"},{name:"currentDate",description:"Date actuelle"},{name:"currentYear",description:"Annee en cours"}];function fe(){const{t,i18n:s}=J.useTranslation("communications"),{id:x}=U.useParams(),i=U.useNavigate(),[r,g]=l.useState(null),[u,k]=l.useState(!0),[v,d]=U.useSearchParams(),n=v.get("tab")||"preview",E=y=>d({tab:y}),[M,L]=l.useState(null),[h,f]=l.useState(null),[c,C]=l.useState(!1),[B,T]=l.useState(!1),[I,A]=l.useState(null),[b,S]=l.useState(null),[P,_]=l.useState(!1),[O,m]=l.useState(""),D=l.useCallback(async()=>{if(x)try{k(!0),L(null);const y=await F.emailTemplates.getById(x);g(y)}catch(y){console.error("Failed to load template:",y),L(t("emailTemplates.detail.errors.loadFailed"))}finally{k(!1)}},[x,t]);l.useEffect(()=>{D()},[D]);const p=async()=>{if(!(!x||!r))try{C(!0),L(null),await F.emailTemplates.update(x,{name:r.name,description:r.description||void 0,category:r.category,isActive:!0}),f(t("emailTemplates.detail.success.activated")),D()}catch(y){console.error("Failed to activate template:",y),L(t("emailTemplates.detail.errors.activateFailed"))}finally{C(!1)}},V=async()=>{if(!(!x||!r))try{C(!0),L(null),await F.emailTemplates.update(x,{name:r.name,description:r.description||void 0,category:r.category,isActive:!1}),f(t("emailTemplates.detail.success.deactivated")),D()}catch(y){console.error("Failed to deactivate template:",y),L(t("emailTemplates.detail.errors.deactivateFailed"))}finally{C(!1)}},G=async()=>{if(!(!x||!r)){if(r.isSystem){L(t("emailTemplates.cannotDeleteSystem"));return}try{C(!0),L(null),await F.emailTemplates.delete(x),i("/administration/workflows/email-templates")}catch(y){console.error("Failed to delete template:",y),L(t("emailTemplates.detail.errors.deleteFailed")),T(!1)}finally{C(!1)}}},Z=async y=>{if(x)try{_(!0),A(y);const o=await F.emailTemplates.preview(x,{languageCode:y});S({subject:o.subject,htmlBody:o.htmlBody})}catch(o){console.error("Failed to preview template:",o),L(t("emailTemplates.detail.errors.previewFailed"))}finally{_(!1)}},Q=()=>{A(null),S(null)},z=l.useMemo(()=>{let y=[];if(r?.variablesJson)try{const o=JSON.parse(r.variablesJson);Array.isArray(o)?y=o.filter(N=>N?.name):typeof o=="object"&&(y=Object.entries(o).filter(([N])=>N&&N!=="undefined").map(([N,$])=>({name:N,description:typeof $=="object"&&$!==null?$.description:void 0,type:typeof $=="object"&&$!==null?$.type:void 0,required:typeof $=="object"&&$!==null?$.required:!1})))}catch{}return{user:be,email:ge,custom:y}},[r?.variablesJson]);l.useEffect(()=>{if(r?.translations&&r.translations.length>0){const y=s.language.split("-")[0],o=r.translations.find(N=>N.languageCode===y);m(o?.languageCode||r.translations[0].languageCode)}},[r?.translations,s.language]);const j=l.useMemo(()=>!r?.translations||!O?null:r.translations.find(y=>y.languageCode===O)||null,[r?.translations,O]),q=[{id:"preview",label:t("emailTemplates.detail.tabs.preview"),icon:e.jsx(a.Eye,{className:"w-4 h-4"})},{id:"info",label:t("emailTemplates.detail.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"translations",label:t("emailTemplates.detail.tabs.translations"),icon:e.jsx(a.Languages,{className:"w-4 h-4"})}],H=y=>t(`emailTemplates.categories.${y.toLowerCase()}`)||y,K=y=>t(`languages.${y}`,{defaultValue:y.toUpperCase()});return u?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:r?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>i("/administration/workflows/email-templates"),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:r.name}),r.isSystem&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:t("emailTemplates.detail.system")}),e.jsx("span",{className:`px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium ${r.isActive?"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]":"bg-[var(--error-bg)] text-[var(--error-text)] border border-[var(--error-border)]"}`,children:r.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")})]}),r.description&&e.jsx("p",{className:"text-sm sm:text-base text-[var(--text-secondary)] mt-1",children:r.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${x}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("emailTemplates.edit.title")})]}),e.jsxs("button",{onClick:r.isActive?V:p,disabled:c,className:`flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border transition-colors ${r.isActive?"border-[var(--warning-border)] text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"border-[var(--success-border)] text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,children:[c&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),!c&&r.isActive&&e.jsx(a.Pause,{className:"w-4 h-4"}),!c&&!r.isActive&&e.jsx(a.Play,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:r.isActive?t("emailTemplates.deactivate"):t("emailTemplates.activate")})]}),e.jsxs("button",{onClick:()=>T(!0),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--error-border)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(a.Trash2,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("emailTemplates.delete")})]})]})]}),M&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),M]}),h&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),h]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:q.map(y=>e.jsxs("button",{onClick:()=>E(y.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${n===y.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[y.icon,e.jsx("span",{className:"hidden sm:inline",children:y.label}),y.id==="translations"&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-xs ${n===y.id?"bg-white/20":"bg-[var(--bg-tertiary)]"}`,children:r.translations.length})]},y.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[n==="preview"&&e.jsxs("div",{className:"space-y-6",children:[r.translations.length>0?e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"text-sm font-medium text-[var(--text-secondary)]",children:[t("emailTemplates.detail.previewLanguage",{defaultValue:"Langue"}),":"]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-tertiary)] rounded-[var(--radius-button)]",children:r.translations.map(y=>e.jsx("button",{onClick:()=>m(y.languageCode),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${O===y.languageCode?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:K(y.languageCode)},y.languageCode))})]}),e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${x}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),t("emailTemplates.edit.title")]})]}):e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(a.Mail,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"mb-4",children:t("emailTemplates.detail.noTranslations")}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${x}/edit`,className:"inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addFirstTranslation")]})]}),j&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Mail,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.subject")})]}),e.jsx("div",{className:"px-4 py-3",children:e.jsx("p",{className:"text-[var(--text-primary)] font-medium",children:j.subject})})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.FileText,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.emailBody",{defaultValue:"Contenu de l'email"})})]}),e.jsxs("button",{onClick:()=>Z(j.languageCode),className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Eye,{className:"w-3 h-3"}),t("emailTemplates.detail.fullPreview",{defaultValue:"Plein ecran"})]})]}),e.jsx("div",{className:"bg-white",children:e.jsx("iframe",{srcDoc:j.htmlBody,className:"w-full min-h-[400px] border-0",title:"Email Preview",sandbox:"allow-same-origin"})})]}),j.textBody&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.FileText,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.textVersion",{defaultValue:"Version texte"})})]}),e.jsx("div",{className:"px-4 py-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-[var(--text-secondary)] font-mono",children:j.textBody})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Code,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.variables")})]}),e.jsxs("div",{className:"p-4 space-y-4 max-h-[500px] overflow-y-auto",children:[z.custom.length>0&&e.jsx(ee,{title:t("emailTemplates.detail.customVariables"),variables:z.custom,t,defaultExpanded:!0}),e.jsx(ee,{title:t("emailTemplates.detail.userVariables"),variables:z.user,t,defaultExpanded:!1}),e.jsx(ee,{title:t("emailTemplates.detail.emailVariables"),variables:z.email,t,defaultExpanded:!1})]})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Settings,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.quickInfo")})]}),e.jsxs("div",{className:"p-4 space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.form.code")}),e.jsx("code",{className:"px-2 py-0.5 bg-[var(--bg-tertiary)] rounded text-[var(--text-primary)] text-xs",children:r.code})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.form.category")}),e.jsx("span",{className:"text-[var(--text-primary)]",children:H(r.category)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.columns.translations")}),e.jsxs("span",{className:"text-[var(--text-primary)]",children:[r.translations.length,"/4"]})]})]})]})]})]})]}),n==="info"&&e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:r.code})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.name")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:r.name})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.description")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] min-h-[60px]",children:r.description||e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"-"})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.category")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:H(r.category)})]}),r.applicationId&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.application")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:r.applicationId})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.createdAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(r.createdAt).toLocaleString()})]}),r.updatedAt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.updatedAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(r.updatedAt).toLocaleString()})]})]})]})]})}),n==="translations"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.detail.translationsTitle")," (",r.translations.length,")"]}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${x}/edit`,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addTranslation")]})]}),r.translations.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("emailTemplates.detail.noTranslations")}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${x}/edit`,className:"inline-flex items-center gap-2 mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addFirstTranslation")]})]}):e.jsx("div",{className:"space-y-3",children:r.translations.map(y=>e.jsx(ye,{translation:y,templateId:x,onPreview:()=>Z(y.languageCode),t,getLanguageLabel:K},y.id))})]})]}),B&&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-card)] border border-[var(--border-color)] p-6 max-w-md w-full shadow-xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:t("emailTemplates.detail.confirmDelete.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("emailTemplates.confirmDelete",{name:r.name})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>T(!1),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:G,disabled:c,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--error-600)] hover:bg-[var(--error-700)] text-white font-medium transition-colors disabled:opacity-50",children:[c?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),t("emailTemplates.delete")]})]})]})}),I&&b&&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-card)] border border-[var(--border-color)] p-6 max-w-4xl w-full max-h-[90vh] overflow-hidden shadow-xl flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.detail.preview")," - ",K(I)]}),e.jsxs("button",{onClick:Q,className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("span",{className:"sr-only",children:"Close"}),"×"]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.subject")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:b.subject})]}),e.jsx("div",{className:"flex-1 overflow-auto border border-[var(--border-color)] rounded-[var(--radius-card)] bg-white",children:e.jsx("iframe",{srcDoc:b.htmlBody,className:"w-full h-full min-h-[400px]",title:"Email Preview"})})]})}),P&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-white"})})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.detail.notFound")}),e.jsx("button",{onClick:()=>i("/administration/workflows/email-templates"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("emailTemplates.backToList")})]})}function ye({translation:t,templateId:s,onPreview:x,t:i,getLanguageLabel:r}){const g=U.useNavigate(),[u,k]=l.useState(!1);return e.jsxs("div",{className:"rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors overflow-hidden",children:[e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)] uppercase",children:t.languageCode})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:r(t.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:t.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>k(!u),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[u?e.jsx(a.ChevronUp,{className:"w-4 h-4"}):e.jsx(a.ChevronDown,{className:"w-4 h-4"}),u?i("emailTemplates.detail.collapse",{defaultValue:"Reduire"}):i("emailTemplates.detail.expand",{defaultValue:"Voir le contenu"})]}),e.jsxs("button",{onClick:x,className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(a.Eye,{className:"w-4 h-4"}),i("emailTemplates.detail.preview")]}),e.jsxs("button",{onClick:()=>g(`/administration/workflows/email-templates/${s}/edit`),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),i("emailTemplates.edit.title")]})]})]})}),u&&e.jsx("div",{className:"border-t border-[var(--border-color)]",children:e.jsx("div",{className:"bg-white max-h-[300px] overflow-auto",children:e.jsx("iframe",{srcDoc:t.htmlBody,className:"w-full min-h-[200px] border-0",title:`Email Preview - ${t.languageCode}`,sandbox:"allow-same-origin"})})})]})}function ee({title:t,variables:s,t:x,defaultExpanded:i=!1}){const[r,g]=l.useState(i);return e.jsxs("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>g(!r),className:"w-full flex items-center justify-between px-3 py-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:s.length}),r?e.jsx(a.ChevronUp,{className:"w-3 h-3"}):e.jsx(a.ChevronDown,{className:"w-3 h-3"})]})]}),r&&e.jsx("div",{className:"p-2 space-y-1",children:s.map(u=>e.jsx(je,{variable:u,t:x},u.name))})]})}function je({variable:t,t:s}){const[x,i]=l.useState(!1),r=`{{ ${t.name} }}`,g=()=>{navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),2e3)};return e.jsxs("div",{className:"group flex items-center justify-between p-2 rounded hover:bg-[var(--bg-tertiary)] transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono text-[var(--color-accent-600)]",children:r}),t.required&&e.jsx("span",{className:"text-xs text-[var(--error-text)]",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 truncate",children:t.description})]}),e.jsx("button",{onClick:g,className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-[var(--bg-hover)] transition-all",title:s("emailTemplates.detail.copyVariable",{defaultValue:"Copier"}),children:x?e.jsx(a.Check,{className:"w-3.5 h-3.5 text-[var(--success-text)]"}):e.jsx(a.Copy,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})})]})}const W=({onClick:t,isActive:s=!1,disabled:x=!1,title:i,children:r})=>e.jsx("button",{type:"button",onClick:t,disabled:x,title:i,className:`p-1.5 rounded transition-colors ${s?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)]":"hover:bg-[var(--bg-hover)] text-[var(--text-secondary)]"} ${x?"opacity-50 cursor-not-allowed":""}`,children:r}),Y=()=>e.jsx("div",{className:"w-px h-6 bg-[var(--border-color)] mx-1"});function we({content:t,onChange:s,placeholder:x,className:i}){const[r,g]=l.useState("visual"),[u,k]=l.useState(t),[v,d]=l.useState(""),[n,E]=l.useState(!1),[M,L]=l.useState(""),[h,f]=l.useState(!1),c=ae.useEditor({extensions:[ie.configure({heading:{levels:[1,2,3]}}),le.configure({openOnClick:!1,HTMLAttributes:{class:"text-[var(--color-accent-600)] underline"}}),ne.configure({HTMLAttributes:{class:"max-w-full h-auto rounded"}}),oe.configure({placeholder:x||"Commencez a ecrire votre email..."}),ce.configure({types:["heading","paragraph"]}),de,me.TextStyle,xe.Color,pe.configure({multicolor:!0})],content:t,onUpdate:({editor:P})=>{const _=P.getHTML();s(_),k(_)},editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[300px] p-4"}}});l.useEffect(()=>{r==="visual"&&c&&u!==c.getHTML()&&c.commands.setContent(u)},[r,c,u]),l.useEffect(()=>{c&&c.getHTML()!==u&&k(c.getHTML())},[c,u]);const C=l.useCallback(P=>{const _=P||"";k(_),s(_)},[s]),B=l.useCallback(()=>{c&&c.commands.setContent(u),g("visual")},[c,u]),T=l.useCallback(()=>{c&&k(c.getHTML()),g("code")},[c]),I=l.useCallback(()=>{v&&c&&(c.chain().focus().extendMarkRange("link").setLink({href:v}).run(),d(""),E(!1))},[c,v]),A=l.useCallback(()=>{c&&(c.chain().focus().unsetLink().run(),E(!1))},[c]),b=l.useCallback(()=>{M&&c&&(c.chain().focus().setImage({src:M}).run(),L(""),f(!1))},[c,M]),S=l.useCallback(P=>{if(c){const _=`{{ ${P} }}`;c.chain().focus().insertContent(`<span class="variable-tag" data-variable="${P}">${_}</span>`).run()}},[c]);return l.useEffect(()=>(typeof window<"u"&&(window.__emailEditorInsertVariable=S),()=>{typeof window<"u"&&delete window.__emailEditorInsertVariable}),[S]),c?e.jsxs("div",{className:`border border-[var(--border-color)] rounded-lg overflow-hidden bg-[var(--bg-primary)] ${i||""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b border-[var(--border-color)] bg-[var(--bg-tertiary)]",children:[e.jsxs("div",{className:"flex items-center gap-1 mr-2",children:[e.jsxs("button",{type:"button",onClick:B,className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${r==="visual"?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Eye,{className:"w-3 h-3"}),"Visuel"]}),e.jsxs("button",{type:"button",onClick:T,className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${r==="code"?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Code,{className:"w-3 h-3"}),"Code"]})]}),r==="visual"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().undo().run(),disabled:!c.can().undo(),title:"Annuler",children:e.jsx(a.Undo,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().redo().run(),disabled:!c.can().redo(),title:"Retablir",children:e.jsx(a.Redo,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().toggleHeading({level:1}).run(),isActive:c.isActive("heading",{level:1}),title:"Titre 1",children:e.jsx(a.Heading1,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleHeading({level:2}).run(),isActive:c.isActive("heading",{level:2}),title:"Titre 2",children:e.jsx(a.Heading2,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleHeading({level:3}).run(),isActive:c.isActive("heading",{level:3}),title:"Titre 3",children:e.jsx(a.Heading3,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().toggleBold().run(),isActive:c.isActive("bold"),title:"Gras",children:e.jsx(a.Bold,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleItalic().run(),isActive:c.isActive("italic"),title:"Italique",children:e.jsx(a.Italic,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleUnderline().run(),isActive:c.isActive("underline"),title:"Souligne",children:e.jsx(a.Underline,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleStrike().run(),isActive:c.isActive("strike"),title:"Barre",children:e.jsx(a.Strikethrough,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().setTextAlign("left").run(),isActive:c.isActive({textAlign:"left"}),title:"Aligner a gauche",children:e.jsx(a.AlignLeft,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().setTextAlign("center").run(),isActive:c.isActive({textAlign:"center"}),title:"Centrer",children:e.jsx(a.AlignCenter,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().setTextAlign("right").run(),isActive:c.isActive({textAlign:"right"}),title:"Aligner a droite",children:e.jsx(a.AlignRight,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().toggleBulletList().run(),isActive:c.isActive("bulletList"),title:"Liste a puces",children:e.jsx(a.List,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleOrderedList().run(),isActive:c.isActive("orderedList"),title:"Liste numerotee",children:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().toggleBlockquote().run(),isActive:c.isActive("blockquote"),title:"Citation",children:e.jsx(a.Quote,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().setHorizontalRule().run(),title:"Ligne horizontale",children:e.jsx(a.Minus,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsxs("div",{className:"relative",children:[e.jsx(W,{onClick:()=>E(!n),isActive:c.isActive("link")||n,title:"Lien",children:e.jsx(a.Link,{className:"w-4 h-4"})}),n&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 flex items-center gap-2",children:[e.jsx("input",{type:"url",value:v,onChange:P=>d(P.target.value),placeholder:"https://...",className:"px-2 py-1 text-sm border border-[var(--border-color)] rounded bg-[var(--bg-primary)] text-[var(--text-primary)] w-48",onKeyDown:P=>P.key==="Enter"&&I()}),e.jsx("button",{type:"button",onClick:I,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),c.isActive("link")&&e.jsx("button",{type:"button",onClick:A,className:"p-1 text-[var(--error-text)] hover:bg-[var(--error-bg)] rounded",children:e.jsx(a.X,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(W,{onClick:()=>f(!h),isActive:h,title:"Image",children:e.jsx(a.Image,{className:"w-4 h-4"})}),h&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 flex items-center gap-2",children:[e.jsx("input",{type:"url",value:M,onChange:P=>L(P.target.value),placeholder:"URL de l'image...",className:"px-2 py-1 text-sm border border-[var(--border-color)] rounded bg-[var(--bg-primary)] text-[var(--text-primary)] w-48",onKeyDown:P=>P.key==="Enter"&&b()}),e.jsx("button",{type:"button",onClick:b,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:()=>f(!1),className:"p-1 text-[var(--error-text)] hover:bg-[var(--error-bg)] rounded",children:e.jsx(a.X,{className:"w-4 h-4"})})]})]}),e.jsx(W,{onClick:()=>{c.chain().focus().insertContent('<img src="{{ company_logo_url }}" alt="Logo" style="max-width: 200px; height: auto;" />').run()},title:"Inserer le logo",children:e.jsx("span",{className:"text-xs font-medium",children:"Logo"})}),e.jsx(Y,{}),e.jsxs("div",{className:"relative group",children:[e.jsx(W,{onClick:()=>{},title:"Couleur du texte",children:e.jsx(a.Palette,{className:"w-4 h-4"})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 hidden group-hover:grid grid-cols-5 gap-1",children:["#000000","#374151","#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"].map(P=>e.jsx("button",{type:"button",onClick:()=>c.chain().focus().setColor(P).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:P}},P))})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(W,{onClick:()=>{},title:"Surligner",children:e.jsx(a.Highlighter,{className:"w-4 h-4"})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 hidden group-hover:grid grid-cols-5 gap-1",children:["#fef08a","#bbf7d0","#bfdbfe","#ddd6fe","#fbcfe8"].map(P=>e.jsx("button",{type:"button",onClick:()=>c.chain().focus().toggleHighlight({color:P}).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:P}},P))})]})]})]}),e.jsx("div",{className:"min-h-[400px]",children:r==="visual"?e.jsx(ae.EditorContent,{editor:c,className:"[&_.ProseMirror]:min-h-[400px] [&_.ProseMirror]:p-4 [&_.ProseMirror]:focus:outline-none [&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.ProseMirror_p.is-editor-empty:first-child::before]:text-[var(--text-tertiary)] [&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left [&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0 [&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"}):e.jsx(ue,{height:"400px",language:"html",theme:"vs-dark",value:u,onChange:C,options:{minimap:{enabled:!1},fontSize:13,wordWrap:"on",formatOnPaste:!0,automaticLayout:!0,scrollBeyondLastLine:!1,lineNumbers:"on",tabSize:2,folding:!0,renderWhitespace:"selection"}})})]}):e.jsx("div",{className:"flex items-center justify-center h-64 bg-[var(--bg-secondary)] rounded-lg",children:e.jsx("div",{className:"animate-pulse text-[var(--text-tertiary)]",children:"Chargement de l'editeur..."})})}const Ne=[{name:"userName",description:"Nom complet de l'utilisateur"},{name:"firstName",description:"Prenom"},{name:"lastName",description:"Nom de famille"},{name:"displayName",description:"Nom d'affichage (Entra)"},{name:"email",description:"Adresse email"},{name:"phoneNumber",description:"Telephone fixe"},{name:"mobilePhone",description:"Telephone mobile"},{name:"city",description:"Ville"},{name:"country",description:"Pays"},{name:"streetAddress",description:"Adresse"},{name:"postalCode",description:"Code postal"},{name:"company",description:"Nom de l'entreprise"},{name:"department",description:"Departement"},{name:"jobTitle",description:"Fonction/Poste"},{name:"office",description:"Bureau/Site"},{name:"employeeId",description:"Numero d'employe"},{name:"managerName",description:"Nom du manager"}],ke=[{name:"company_logo_url",description:"URL du logo de l'entreprise"},{name:"appName",description:"Nom de l'application"},{name:"resetUrl",description:"Lien de reinitialisation du mot de passe"},{name:"confirmUrl",description:"Lien de confirmation d'email"},{name:"adminName",description:"Nom de l'administrateur (action admin)"},{name:"expiresIn",description:"Delai d'expiration du lien"},{name:"currentDate",description:"Date actuelle"},{name:"currentYear",description:"Annee en cours"}],se=["fr","en","de","it"],Te={userName:"Jean Dupont",firstName:"Jean",lastName:"Dupont",displayName:"Jean Dupont",email:"jean.dupont@example.com",user_email:"jean.dupont@example.com",userEmail:"jean.dupont@example.com",phoneNumber:"+41 21 123 45 67",phone:"+41 21 123 45 67",mobilePhone:"+41 79 123 45 67",mobile:"+41 79 123 45 67",city:"Lausanne",country:"Suisse",streetAddress:"Rue du Lac 15",address:"Rue du Lac 15, 1003 Lausanne",postalCode:"1003",zipCode:"1003",company:"SmartStack SA",companyName:"SmartStack SA",company_name:"SmartStack SA",organization:"SmartStack SA",department:"Informatique",jobTitle:"Developpeur Senior",job_title:"Developpeur Senior",position:"Developpeur Senior",office:"Lausanne HQ",employeeId:"EMP-001234",employee_id:"EMP-001234",managerName:"Marie Martin",manager:"Marie Martin",manager_name:"Marie Martin",company_logo_url:"https://example.com/logo.png",logo_url:"https://example.com/logo.png",logoUrl:"https://example.com/logo.png",appName:"SmartStack",app_name:"SmartStack",applicationName:"SmartStack",siteName:"SmartStack",site_name:"SmartStack",resetUrl:"https://app.smartstack.ch/reset-password?token=abc123",reset_url:"https://app.smartstack.ch/reset-password?token=abc123",resetLink:"https://app.smartstack.ch/reset-password?token=abc123",reset_link:"https://app.smartstack.ch/reset-password?token=abc123",confirmUrl:"https://app.smartstack.ch/confirm-email?token=xyz789",confirm_url:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmationUrl:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmation_url:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmLink:"https://app.smartstack.ch/confirm-email?token=xyz789",activationUrl:"https://app.smartstack.ch/activate?token=xyz789",activation_url:"https://app.smartstack.ch/activate?token=xyz789",activationLink:"https://app.smartstack.ch/activate?token=xyz789",loginUrl:"https://app.smartstack.ch/login",login_url:"https://app.smartstack.ch/login",loginLink:"https://app.smartstack.ch/login",dashboardUrl:"https://app.smartstack.ch/dashboard",dashboard_url:"https://app.smartstack.ch/dashboard",profileUrl:"https://app.smartstack.ch/profile",profile_url:"https://app.smartstack.ch/profile",unsubscribeUrl:"https://app.smartstack.ch/unsubscribe?token=abc",unsubscribe_url:"https://app.smartstack.ch/unsubscribe?token=abc",adminName:"Admin Systeme",admin_name:"Admin Systeme",adminEmail:"admin@smartstack.ch",admin_email:"admin@smartstack.ch",supportEmail:"support@atlashub.ch",support_email:"support@atlashub.ch",supportPhone:"+41 21 123 00 00",support_phone:"+41 21 123 00 00",expiresIn:"24 heures",expires_in:"24 heures",expirationTime:"24 heures",expiration_time:"24 heures",expiryDate:"16 janvier 2026",expiry_date:"16 janvier 2026",currentDate:new Date().toLocaleDateString("fr-CH"),current_date:new Date().toLocaleDateString("fr-CH"),date:new Date().toLocaleDateString("fr-CH"),today:new Date().toLocaleDateString("fr-CH"),currentYear:new Date().getFullYear().toString(),current_year:new Date().getFullYear().toString(),year:new Date().getFullYear().toString(),currentTime:new Date().toLocaleTimeString("fr-CH"),current_time:new Date().toLocaleTimeString("fr-CH"),time:new Date().toLocaleTimeString("fr-CH"),temporaryPassword:"TempPass123!",temporary_password:"TempPass123!",tempPassword:"TempPass123!",temp_password:"TempPass123!",newPassword:"NewPass456!",new_password:"NewPass456!",password:"********",token:"abc123xyz789",verificationCode:"123456",verification_code:"123456",code:"123456",otp:"123456",ticketId:"TKT-2026-00123",ticket_id:"TKT-2026-00123",ticketNumber:"TKT-2026-00123",ticket_number:"TKT-2026-00123",ticketSubject:"Question technique",ticket_subject:"Question technique",ticketStatus:"En cours",ticket_status:"En cours",orderId:"ORD-2026-00456",order_id:"ORD-2026-00456",orderNumber:"ORD-2026-00456",order_number:"ORD-2026-00456",invoiceId:"INV-2026-00789",invoice_id:"INV-2026-00789",invoiceNumber:"INV-2026-00789",invoice_number:"INV-2026-00789",amount:"CHF 150.00",total:"CHF 150.00",price:"CHF 150.00",reason:"Mise a jour de securite",message:"Votre demande a ete traitee avec succes.",description:"Description de l'element",title:"Titre de l'element",name:"Nom de l'element",value:"Valeur exemple",count:"5",number:"42",id:"12345"};function Ce(t){const s=t.toLowerCase();return s.includes("url")||s.includes("link")?"https://app.smartstack.ch/example":s.includes("email")||s.includes("mail")?"exemple@smartstack.ch":s.includes("phone")||s.includes("tel")||s.includes("mobile")?"+41 21 123 45 67":s.includes("date")||s.includes("time")||s.includes("at")?new Date().toLocaleDateString("fr-CH"):s.includes("year")?new Date().getFullYear().toString():s.includes("name")||s.includes("nom")?"Jean Dupont":s.includes("password")||s.includes("pwd")||s.includes("pass")?"MotDePasse123!":s.includes("code")||s.includes("token")||s.includes("otp")?"123456":s.includes("id")||s.includes("number")||s.includes("num")?"12345":s.includes("amount")||s.includes("price")||s.includes("total")||s.includes("cost")?"CHF 100.00":s.includes("count")||s.includes("qty")||s.includes("quantity")?"5":`[${t.replace(/_/g," ").replace(/([A-Z])/g," $1").trim().toLowerCase()}]`}function X(t){if(!t)return t;let s=t;return s=s.replace(/\{\{\s*(\w+)\s*\}\}/g,(x,i)=>Te[i]||Ce(i)),s=s.replace(/\{%\s*if\s+\w+\s*%\}([\s\S]*?)\{%\s*endif\s*%\}/gi,"$1"),s=s.replace(/\{%\s*else\s*%\}[\s\S]*?(?=\{%|\$)/gi,""),s=s.replace(/\{%[^%]*%\}/g,""),s}function Se(){const{t}=J.useTranslation("communications"),{id:s}=U.useParams(),x=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState(!1),[d,n]=U.useSearchParams(),E=d.get("tab")||"info",M=o=>n({tab:o}),[L,h]=l.useState(null),[f,c]=l.useState(null),[C,B]=l.useState({name:"",description:"",category:""}),[T,I]=l.useState(null),[A,b]=l.useState(!1),[S,P]=l.useState(!1),[_,O]=l.useState(!0),[m,D]=l.useState(!1),p=l.useMemo(()=>{let o=[];if(i?.variablesJson)try{const N=JSON.parse(i.variablesJson);Array.isArray(N)?o=N.filter($=>$?.name):typeof N=="object"&&(o=Object.entries(N).filter(([$])=>$&&$!=="undefined").map(([$,R])=>({name:$,description:typeof R=="object"&&R!==null?R.description:void 0,type:typeof R=="object"&&R!==null?R.type:void 0,required:typeof R=="object"&&R!==null?R.required:!1})))}catch{}return{user:Ne,email:ke,custom:o}},[i?.variablesJson]),V=l.useCallback(async()=>{if(s)try{u(!0),h(null);const o=await F.emailTemplates.getById(s);r(o),B({name:o.name,description:o.description||"",category:o.category})}catch(o){console.error("Failed to load template:",o),h(t("emailTemplates.edit.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{V()},[V]);const G=async o=>{if(o.preventDefault(),!(!s||!i))try{v(!0),h(null),await F.emailTemplates.update(s,{name:C.name,description:C.description||void 0,category:C.category,isActive:i.isActive}),c(t("emailTemplates.edit.success.saved")),V()}catch(N){console.error("Failed to save template:",N),h(t("emailTemplates.edit.errors.saveFailed"))}finally{v(!1)}},Z=()=>{const o=i?.translations.map($=>$.languageCode)||[],N=se.filter($=>!o.includes($));if(N.length===0){h(t("emailTemplates.edit.errors.allLanguagesExist"));return}I({languageCode:N[0],subject:"",htmlBody:"",textBody:""}),b(!0)},Q=o=>{I({languageCode:o.languageCode,subject:o.subject,htmlBody:o.htmlBody,textBody:o.textBody||""}),b(!1)},z=async()=>{if(!(!s||!T))try{P(!0),h(null),A?(await F.emailTemplates.createTranslation(s,{languageCode:T.languageCode,subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),c(t("emailTemplates.edit.success.translationAdded"))):(await F.emailTemplates.updateTranslation(s,T.languageCode,{subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),c(t("emailTemplates.edit.success.translationUpdated"))),I(null),V()}catch(o){console.error("Failed to save translation:",o),h(t("emailTemplates.edit.errors.translationSaveFailed"))}finally{P(!1)}},j=async o=>{if(s&&!(!o||!confirm(t("emailTemplates.edit.confirmDeleteTranslation"))))try{P(!0),h(null),h("Delete translation API not implemented yet")}catch(N){console.error("Failed to delete translation:",N),h(t("emailTemplates.edit.errors.translationDeleteFailed"))}finally{P(!1)}},q=[{id:"info",label:t("emailTemplates.edit.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"translations",label:t("emailTemplates.edit.tabs.translations"),icon:e.jsx(a.Languages,{className:"w-4 h-4"})}],H=o=>t(`languages.${o}`,{defaultValue:o.toUpperCase()});if(g)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})});if(!i)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.detail.notFound")}),e.jsx("button",{onClick:()=>x("/administration/workflows/email-templates"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("emailTemplates.backToList")})]});const K=i.translations.map(o=>o.languageCode),y=se.filter(o=>!K.includes(o));return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:i?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x(`/administration/workflows/email-templates/${s}`),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:t("emailTemplates.edit.title")}),i.isSystem&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:t("emailTemplates.edit.systemTemplate")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:i.code})]})]}),L&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),L]}),f&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),f]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:q.map(o=>e.jsxs("button",{onClick:()=>M(o.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${E===o.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[o.icon,e.jsx("span",{className:"hidden sm:inline",children:o.label})]},o.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[E==="info"&&e.jsxs("form",{onSubmit:G,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:i.code}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("emailTemplates.edit.codeReadOnly")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:C.name,onChange:o=>B(N=>({...N,name:o.target.value})),className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.description")}),e.jsx("textarea",{value:C.description,onChange:o=>B(N=>({...N,description:o.target.value})),rows:3,placeholder:t("emailTemplates.form.descriptionPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:border-[var(--color-accent-500)] focus:ring-1 focus:ring-[var(--color-accent-500)]"})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.form.category")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsxs("select",{required:!0,value:C.category,onChange:o=>B(N=>({...N,category:o.target.value})),className:"input w-full",children:[e.jsx("option",{value:"transactional",children:t("emailTemplates.categories.transactional")}),e.jsx("option",{value:"notification",children:t("emailTemplates.categories.notification")}),e.jsx("option",{value:"marketing",children:t("emailTemplates.categories.marketing")}),e.jsx("option",{value:"system",children:t("emailTemplates.categories.system")})]})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-[var(--border-color)]",children:[e.jsx("button",{type:"button",onClick:()=>x(`/administration/workflows/email-templates/${s}`),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:k,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors disabled:opacity-50",children:[k?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]}),E==="translations"&&!T&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.edit.tabs.translations")," (",i.translations.length,"/4)"]}),y.length>0&&e.jsxs("button",{onClick:Z,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.edit.addTranslation")]})]}),i.translations.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("emailTemplates.detail.noTranslations")})]}):e.jsx("div",{className:"space-y-3",children:i.translations.map(o=>e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)] uppercase",children:o.languageCode})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:H(o.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] truncate max-w-md",children:o.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Q(o),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Settings,{className:"w-4 h-4"}),t("emailTemplates.edit.editTranslation")]}),e.jsx("button",{onClick:()=>j(o.languageCode),disabled:S,className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})]})},o.id))})]}),E==="translations"&&T&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t(A?"emailTemplates.edit.addTranslation":"emailTemplates.edit.editTranslation")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>O(!_),className:`flex items-center gap-1 px-2 py-1 rounded text-sm transition-colors ${_?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Columns,{className:"w-4 h-4"}),t("emailTemplates.edit.showPreview")]}),e.jsx("button",{onClick:()=>I(null),className:"text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:t("common.cancel")})]})]}),e.jsxs("div",{className:`grid gap-6 ${_?"grid-cols-1 xl:grid-cols-2":"grid-cols-1"}`,children:[e.jsxs("div",{className:"space-y-4",children:[A&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.language")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("select",{value:T.languageCode,onChange:o=>I(N=>N?{...N,languageCode:o.target.value}:null),className:"input w-full max-w-xs",children:y.map(o=>e.jsx("option",{value:o,children:H(o)},o))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.subject")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:T.subject,onChange:o=>I(N=>N?{...N,subject:o.target.value}:null),placeholder:t("emailTemplates.edit.subjectPlaceholder"),className:"input w-full"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.htmlBody")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx(we,{content:T.htmlBody,onChange:o=>I(N=>N?{...N,htmlBody:o}:null),placeholder:t("emailTemplates.edit.htmlBodyPlaceholder")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.edit.textBody")}),e.jsx("textarea",{value:T.textBody,onChange:o=>I(N=>N?{...N,textBody:o.target.value}:null),rows:4,placeholder:t("emailTemplates.edit.textBodyPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:border-[var(--color-accent-500)] focus:ring-1 focus:ring-[var(--color-accent-500)]"}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("emailTemplates.edit.textBodyHelp")})]})]}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Code,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.edit.availableVariables")})]}),e.jsxs("div",{className:"p-3 space-y-3 max-h-[300px] overflow-auto",children:[p.custom.length>0&&e.jsx(te,{title:t("emailTemplates.detail.customVariables"),variables:p.custom,onInsert:o=>{const N=`{{ ${o} }}`;I($=>$?{...$,htmlBody:$.htmlBody+N}:null)},defaultExpanded:!0}),e.jsx(te,{title:t("emailTemplates.detail.userVariables"),variables:p.user,onInsert:o=>{const N=`{{ ${o} }}`;I($=>$?{...$,htmlBody:$.htmlBody+N}:null)},defaultExpanded:!1}),e.jsx(te,{title:t("emailTemplates.detail.emailVariables"),variables:p.email,onInsert:o=>{const N=`{{ ${o} }}`;I($=>$?{...$,htmlBody:$.htmlBody+N}:null)},defaultExpanded:!1})]})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Eye,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.edit.livePreview")})]}),e.jsx("button",{onClick:()=>D(!0),className:"p-1 rounded hover:bg-[var(--bg-hover)] transition-colors",title:t("emailTemplates.edit.fullscreen"),children:e.jsx(a.Maximize2,{className:"w-4 h-4 text-[var(--text-tertiary)]"})})]}),e.jsxs("div",{className:"px-4 py-2 border-b border-[var(--border-color)] bg-[var(--bg-tertiary)]/50",children:[e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:t("emailTemplates.edit.subject")}),e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:T.subject?X(T.subject):e.jsx("span",{className:"text-[var(--text-tertiary)] italic",children:t("emailTemplates.edit.subjectPlaceholder")})})]}),e.jsx("div",{className:"flex-1 bg-white min-h-[300px]",children:T.htmlBody?e.jsx("iframe",{srcDoc:`<!DOCTYPE html>
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),U=require("react-router-dom"),J=require("react-i18next"),a=require("lucide-react"),w=require("./index-BDRogQH_.js"),ae=require("@tiptap/react"),ie=require("@tiptap/starter-kit"),le=require("@tiptap/extension-link"),ne=require("@tiptap/extension-image"),oe=require("@tiptap/extension-placeholder"),ce=require("@tiptap/extension-text-align"),de=require("@tiptap/extension-underline"),me=require("@tiptap/extension-text-style"),xe=require("@tiptap/extension-color"),pe=require("@tiptap/extension-highlight"),ue=require("@monaco-editor/react"),F={emailTemplates:{getAll:t=>w.api.get("/api/administration/workflows/email-templates",{params:t}),getById:t=>w.api.get(`/api/administration/workflows/email-templates/${t}`),getByCode:t=>w.api.get(`/api/administration/workflows/email-templates/by-code/${t}`),create:t=>w.api.post("/api/administration/workflows/email-templates",t),update:(t,s)=>w.api.put(`/api/administration/workflows/email-templates/${t}`,s),delete:t=>w.api.delete(`/api/administration/workflows/email-templates/${t}`),activate:t=>w.api.patch(`/api/administration/workflows/email-templates/${t}/activate`),deactivate:t=>w.api.patch(`/api/administration/workflows/email-templates/${t}/deactivate`),preview:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/preview`,s),testSend:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/test-send`,s),getTranslation:(t,s)=>w.api.get(`/api/administration/workflows/email-templates/${t}/translations/${s}`),createTranslation:(t,s)=>w.api.post(`/api/administration/workflows/email-templates/${t}/translations`,s),updateTranslation:(t,s,x)=>w.api.put(`/api/administration/workflows/email-templates/${t}/translations/${s}`,x)},workflows:{getAll:t=>w.api.get("/api/administration/workflows/definitions",{params:t}),getById:t=>w.api.get(`/api/administration/workflows/definitions/${t}`),create:t=>w.api.post("/api/administration/workflows/definitions",t),update:(t,s)=>w.api.put(`/api/administration/workflows/definitions/${t}`,s),delete:t=>w.api.delete(`/api/administration/workflows/definitions/${t}`),activate:t=>w.api.patch(`/api/administration/workflows/definitions/${t}/activate`),deactivate:t=>w.api.patch(`/api/administration/workflows/definitions/${t}/deactivate`),addStep:(t,s)=>w.api.post(`/api/administration/workflows/definitions/${t}/steps`,s),updateStep:(t,s,x)=>w.api.put(`/api/administration/workflows/definitions/${t}/steps/${s}`,x),deleteStep:(t,s)=>w.api.delete(`/api/administration/workflows/definitions/${t}/steps/${s}`),reorderSteps:(t,s)=>w.api.post(`/api/administration/workflows/definitions/${t}/steps/reorder`,{stepOrder:s})},triggers:{getAll:()=>w.api.get("/api/administration/workflows/definitions/triggers")}};function ve(){const{t}=J.useTranslation("communications"),s=U.useNavigate(),{currentTenant:x,isGlobalView:i}=w.useTenant(),[r,g]=l.useState([]),[u,k]=l.useState(!0),[v,d]=l.useState(""),[n,E]=l.useState("table"),[M,L]=l.useState(1),h=20,f=l.useCallback(async()=>{try{k(!0);const p=await F.emailTemplates.getAll({search:v||void 0});g(Array.isArray(p)?p:[])}catch(p){console.error("Failed to load templates:",p)}finally{k(!1)}},[v]);l.useEffect(()=>{f()},[f,x?.id,i]);const c=p=>{p.preventDefault(),L(1),f()},C=async(p,V)=>{if(V?.stopPropagation(),p.isSystem){alert(t("emailTemplates.cannotDeleteSystem"));return}if(confirm(t("emailTemplates.confirmDelete",{name:p.name})))try{await F.emailTemplates.delete(p.id),f()}catch(G){console.error("Failed to delete template:",G)}},B=(M-1)*h,T=r.slice(B,B+h),I=Math.ceil(r.length/h),A={transactional:r.filter(p=>p.category==="transactional"),notification:r.filter(p=>p.category==="notification"),marketing:r.filter(p=>p.category==="marketing"),system:r.filter(p=>p.category==="system")},b=p=>t(`emailTemplates.categories.${p.toLowerCase()}`)||p,S=()=>e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"w-12 px-4 py-3",children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.code")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.name")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:t("emailTemplates.columns.category")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:t("emailTemplates.columns.translations")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("emailTemplates.columns.status")}),e.jsx("th",{className:"w-32 px-4 py-3"})]})}),e.jsxs("tbody",{className:"divide-y divide-[var(--border-color)]",children:[u&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]})})}),!u&&T.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(a.Mail,{className:"w-8 h-8 text-[var(--text-tertiary)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.noResults")})]})})}),!u&&T.length>0&&T.map(p=>e.jsxs("tr",{className:"group hover:bg-[var(--bg-hover)] transition-all cursor-pointer",onClick:()=>s(`/administration/workflows/email-templates/${p.id}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:V=>V.stopPropagation(),children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Mail,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("code",{className:"text-sm bg-[var(--bg-secondary)] px-2 py-0.5 rounded text-[var(--text-primary)]",children:p.code})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] group-hover:text-primary-600 transition-colors",children:p.name}),p.isSystem&&e.jsx("span",{className:"inline-flex items-center gap-1 mt-1 px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"System"})]})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:b(p.category)})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm",children:p.languages.length})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(w.StatusBadge,{status:p.isActive?"active":"inactive",label:p.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:V=>V.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/email-templates/${p.id}`),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-primary-600 hover:bg-[var(--accent-bg)] transition-all",title:t("emailTemplates.view"),children:e.jsx(a.Eye,{className:"w-4 h-4"})}),e.jsx("button",{onClick:V=>{V.stopPropagation(),s(`/administration/workflows/email-templates/${p.id}/edit`)},className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--info-text)] hover:bg-[var(--info-bg)] transition-all",title:t("emailTemplates.edit.title"),children:e.jsx(a.Edit2,{className:"w-4 h-4"})}),!p.isSystem&&e.jsx("button",{onClick:V=>C(p,V),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-all",title:t("emailTemplates.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})})]},p.id))]})]})}),P=()=>u?e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):T.length===0?e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg bg-[var(--color-accent-50)] flex items-center justify-center mb-3",children:e.jsx(a.Mail,{className:"w-8 h-8 text-[var(--color-accent-500)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.noResults")})]}):T.map(p=>e.jsx(w.TemplateCard,{name:p.name,code:p.code,category:b(p.category),isActive:p.isActive,isSystem:p.isSystem,icon:a.Mail,iconColor:"var(--color-accent-500)",translationsCount:p.languages.length,onClick:()=>s(`/administration/workflows/email-templates/${p.id}`),onEdit:()=>s(`/administration/workflows/email-templates/${p.id}/edit`),onDelete:()=>C(p),labels:{activeLabel:t("emailTemplates.active"),inactiveLabel:t("emailTemplates.inactive"),systemLabel:"System",editLabel:t("emailTemplates.edit.title"),deleteLabel:t("emailTemplates.delete")}},p.id)),_=()=>e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:P()}),O=p=>p==="transactional"?"bg-[var(--success-dot)]":p==="notification"?"bg-[var(--warning-dot)]":p==="marketing"?"bg-blue-500":"bg-[var(--text-muted)]",m=p=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/email-templates/${p.id}`),className:"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-md hover:border-[var(--color-accent-400)] cursor-pointer text-left w-full",children:[e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-3 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--color-accent-500)] flex items-center justify-center shadow-lg",children:e.jsx(a.Mail,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-[var(--text-primary)] truncate",children:p.name}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:p.code})]})]})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${p.isActive?"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 ${p.isActive?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),p.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")]}),e.jsxs("div",{className:"flex items-center gap-1 text-[var(--text-tertiary)]",children:[e.jsx(a.Languages,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:p.languages.length})]})]})})]},p.id),D=()=>e.jsx("div",{className:"flex gap-6 overflow-x-auto pb-4",children:u?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):e.jsx(e.Fragment,{children:Object.entries(A).map(([p,V])=>e.jsxs("div",{className:"min-w-[280px] flex-1 rounded-lg p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${O(p)}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:b(p)}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:V.length})]}),e.jsxs("div",{className:"space-y-3 min-h-[100px]",children:[V.map(m),V.length===0&&e.jsxs("div",{className:"border-2 border-dashed border-[var(--color-accent-200)] rounded-lg p-6 text-center",children:[e.jsx(a.Mail,{className:"w-6 h-6 mx-auto mb-2 text-[var(--text-muted)]"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t("emailTemplates.noResults")})]})]})]},p))})});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates")}]}),e.jsx(w.PageHeader,{title:t("emailTemplates.title"),subtitle:`${r.length} templates`,icon:e.jsx(a.Mail,{className:"w-6 h-6"}),actions:e.jsxs("button",{onClick:()=>s("/administration/workflows/email-templates/create"),className:"btn btn-primary",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.create")]})}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("form",{onSubmit:c,className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(a.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:v,onChange:p=>d(p.target.value),placeholder:t("emailTemplates.searchPlaceholder"),className:"input w-full pl-10"})]}),e.jsxs("button",{type:"submit",className:"btn btn-secondary",children:[e.jsx(a.Filter,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Filtres"})]})]}),e.jsx(w.ViewToggle,{viewMode:n,onChange:E,tableLabel:"Table",cardsLabel:"Cards",kanbanLabel:"Kanban"})]})}),n==="table"&&S(),n==="cards"&&_(),n==="kanban"&&D(),n!=="kanban"&&r.length>0&&e.jsx(w.Pagination,{page:M,totalPages:I,totalCount:r.length,pageSize:h,onPageChange:L,itemLabel:"templates"})]})}function he(){const{t}=J.useTranslation("communications"),s=U.useNavigate(),[x,i]=l.useState(!1),[r,g]=l.useState(null),[u,k]=l.useState({code:"",name:"",description:"",category:"transactional"}),v=async d=>{d.preventDefault(),i(!0),g(null);try{const n=await F.emailTemplates.create({code:u.code,name:u.name,description:u.description||void 0,category:u.category});s(`/administration/email-templates/${n.id}`)}catch(n){const E=n instanceof Error?n.message:"An error occurred while creating the template";g(E)}finally{i(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:t("emailTemplates.create","Create")}]}),e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("button",{onClick:()=>s("/administration/email-templates/list"),className:"flex items-center gap-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors mb-4",children:[e.jsx(a.ArrowLeft,{className:"w-4 h-4"}),t("emailTemplates.backToList")]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-violet-500 to-purple-500 flex items-center justify-center shadow-lg shadow-primary-500/20",children:e.jsx(a.Mail,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("emailTemplates.createTitle")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:t("emailTemplates.description")})]})]})]}),e.jsxs("form",{onSubmit:v,className:"space-y-6 max-w-2xl",children:[r&&e.jsx("div",{className:"p-4 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] text-sm border border-[var(--error-border)]",children:r}),e.jsxs("div",{className:"card p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("emailTemplates.form.code")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:u.code,onChange:d=>k(n=>({...n,code:d.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")})),placeholder:"e.g., welcome-email",className:"input w-full"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-1.5",children:t("emailTemplates.form.codeHelp")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("emailTemplates.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:u.name,onChange:d=>k(n=>({...n,name:d.target.value})),placeholder:"e.g., Welcome Email",className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("emailTemplates.form.description")}),e.jsx("textarea",{value:u.description,onChange:d=>k(n=>({...n,description:d.target.value})),rows:3,placeholder:t("emailTemplates.form.descriptionPlaceholder"),className:"input w-full resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("emailTemplates.form.category")}),e.jsxs("select",{value:u.category,onChange:d=>k(n=>({...n,category:d.target.value})),className:"input w-full",children:[e.jsx("option",{value:"transactional",children:t("emailTemplates.categories.transactional")}),e.jsx("option",{value:"marketing",children:t("emailTemplates.categories.marketing")}),e.jsx("option",{value:"notification",children:t("emailTemplates.categories.notification")}),e.jsx("option",{value:"system",children:t("emailTemplates.categories.system")})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>s("/administration/email-templates/list"),className:"btn btn-secondary",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:x,className:"btn btn-primary disabled:opacity-50",children:[x?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]})]})}const be=[{name:"userName",description:"Nom complet de l'utilisateur"},{name:"firstName",description:"Prenom"},{name:"lastName",description:"Nom de famille"},{name:"displayName",description:"Nom d'affichage (Entra)"},{name:"email",description:"Adresse email"},{name:"phoneNumber",description:"Telephone fixe"},{name:"mobilePhone",description:"Telephone mobile"},{name:"city",description:"Ville"},{name:"country",description:"Pays"},{name:"streetAddress",description:"Adresse"},{name:"postalCode",description:"Code postal"},{name:"company",description:"Nom de l'entreprise"},{name:"department",description:"Departement"},{name:"jobTitle",description:"Fonction/Poste"},{name:"office",description:"Bureau/Site"},{name:"employeeId",description:"Numero d'employe"},{name:"managerName",description:"Nom du manager"}],ge=[{name:"company_logo_url",description:"URL du logo de l'entreprise"},{name:"appName",description:"Nom de l'application"},{name:"resetUrl",description:"Lien de reinitialisation du mot de passe"},{name:"confirmUrl",description:"Lien de confirmation d'email"},{name:"adminName",description:"Nom de l'administrateur (action admin)"},{name:"expiresIn",description:"Delai d'expiration du lien"},{name:"currentDate",description:"Date actuelle"},{name:"currentYear",description:"Annee en cours"}];function fe(){const{t,i18n:s}=J.useTranslation("communications"),{id:x}=U.useParams(),i=U.useNavigate(),[r,g]=l.useState(null),[u,k]=l.useState(!0),[v,d]=U.useSearchParams(),n=v.get("tab")||"preview",E=y=>d({tab:y}),[M,L]=l.useState(null),[h,f]=l.useState(null),[c,C]=l.useState(!1),[B,T]=l.useState(!1),[I,A]=l.useState(null),[b,S]=l.useState(null),[P,_]=l.useState(!1),[O,m]=l.useState(""),D=l.useCallback(async()=>{if(x)try{k(!0),L(null);const y=await F.emailTemplates.getById(x);g(y)}catch(y){console.error("Failed to load template:",y),L(t("emailTemplates.detail.errors.loadFailed"))}finally{k(!1)}},[x,t]);l.useEffect(()=>{D()},[D]);const p=async()=>{if(!(!x||!r))try{C(!0),L(null),await F.emailTemplates.update(x,{name:r.name,description:r.description||void 0,category:r.category,isActive:!0}),f(t("emailTemplates.detail.success.activated")),D()}catch(y){console.error("Failed to activate template:",y),L(t("emailTemplates.detail.errors.activateFailed"))}finally{C(!1)}},V=async()=>{if(!(!x||!r))try{C(!0),L(null),await F.emailTemplates.update(x,{name:r.name,description:r.description||void 0,category:r.category,isActive:!1}),f(t("emailTemplates.detail.success.deactivated")),D()}catch(y){console.error("Failed to deactivate template:",y),L(t("emailTemplates.detail.errors.deactivateFailed"))}finally{C(!1)}},G=async()=>{if(!(!x||!r)){if(r.isSystem){L(t("emailTemplates.cannotDeleteSystem"));return}try{C(!0),L(null),await F.emailTemplates.delete(x),i("/administration/workflows/email-templates")}catch(y){console.error("Failed to delete template:",y),L(t("emailTemplates.detail.errors.deleteFailed")),T(!1)}finally{C(!1)}}},Z=async y=>{if(x)try{_(!0),A(y);const o=await F.emailTemplates.preview(x,{languageCode:y});S({subject:o.subject,htmlBody:o.htmlBody})}catch(o){console.error("Failed to preview template:",o),L(t("emailTemplates.detail.errors.previewFailed"))}finally{_(!1)}},Q=()=>{A(null),S(null)},z=l.useMemo(()=>{let y=[];if(r?.variablesJson)try{const o=JSON.parse(r.variablesJson);Array.isArray(o)?y=o.filter(N=>N?.name):typeof o=="object"&&(y=Object.entries(o).filter(([N])=>N&&N!=="undefined").map(([N,$])=>({name:N,description:typeof $=="object"&&$!==null?$.description:void 0,type:typeof $=="object"&&$!==null?$.type:void 0,required:typeof $=="object"&&$!==null?$.required:!1})))}catch{}return{user:be,email:ge,custom:y}},[r?.variablesJson]);l.useEffect(()=>{if(r?.translations&&r.translations.length>0){const y=s.language.split("-")[0],o=r.translations.find(N=>N.languageCode===y);m(o?.languageCode||r.translations[0].languageCode)}},[r?.translations,s.language]);const j=l.useMemo(()=>!r?.translations||!O?null:r.translations.find(y=>y.languageCode===O)||null,[r?.translations,O]),q=[{id:"preview",label:t("emailTemplates.detail.tabs.preview"),icon:e.jsx(a.Eye,{className:"w-4 h-4"})},{id:"info",label:t("emailTemplates.detail.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"translations",label:t("emailTemplates.detail.tabs.translations"),icon:e.jsx(a.Languages,{className:"w-4 h-4"})}],H=y=>t(`emailTemplates.categories.${y.toLowerCase()}`)||y,K=y=>t(`languages.${y}`,{defaultValue:y.toUpperCase()});return u?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:r?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>i("/administration/workflows/email-templates"),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:r.name}),r.isSystem&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:t("emailTemplates.detail.system")}),e.jsx("span",{className:`px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium ${r.isActive?"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]":"bg-[var(--error-bg)] text-[var(--error-text)] border border-[var(--error-border)]"}`,children:r.isActive?t("emailTemplates.active"):t("emailTemplates.inactive")})]}),r.description&&e.jsx("p",{className:"text-sm sm:text-base text-[var(--text-secondary)] mt-1",children:r.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${x}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("emailTemplates.edit.title")})]}),e.jsxs("button",{onClick:r.isActive?V:p,disabled:c,className:`flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border transition-colors ${r.isActive?"border-[var(--warning-border)] text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"border-[var(--success-border)] text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,children:[c&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),!c&&r.isActive&&e.jsx(a.Pause,{className:"w-4 h-4"}),!c&&!r.isActive&&e.jsx(a.Play,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:r.isActive?t("emailTemplates.deactivate"):t("emailTemplates.activate")})]}),e.jsxs("button",{onClick:()=>T(!0),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--error-border)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(a.Trash2,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("emailTemplates.delete")})]})]})]}),M&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),M]}),h&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),h]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:q.map(y=>e.jsxs("button",{onClick:()=>E(y.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${n===y.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[y.icon,e.jsx("span",{className:"hidden sm:inline",children:y.label}),y.id==="translations"&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-xs ${n===y.id?"bg-white/20":"bg-[var(--bg-tertiary)]"}`,children:r.translations.length})]},y.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[n==="preview"&&e.jsxs("div",{className:"space-y-6",children:[r.translations.length>0?e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"text-sm font-medium text-[var(--text-secondary)]",children:[t("emailTemplates.detail.previewLanguage",{defaultValue:"Langue"}),":"]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-tertiary)] rounded-[var(--radius-button)]",children:r.translations.map(y=>e.jsx("button",{onClick:()=>m(y.languageCode),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${O===y.languageCode?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:K(y.languageCode)},y.languageCode))})]}),e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${x}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),t("emailTemplates.edit.title")]})]}):e.jsxs("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:[e.jsx(a.Mail,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"mb-4",children:t("emailTemplates.detail.noTranslations")}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${x}/edit`,className:"inline-flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addFirstTranslation")]})]}),j&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Mail,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.subject")})]}),e.jsx("div",{className:"px-4 py-3",children:e.jsx("p",{className:"text-[var(--text-primary)] font-medium",children:j.subject})})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.FileText,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.emailBody",{defaultValue:"Contenu de l'email"})})]}),e.jsxs("button",{onClick:()=>Z(j.languageCode),className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Eye,{className:"w-3 h-3"}),t("emailTemplates.detail.fullPreview",{defaultValue:"Plein ecran"})]})]}),e.jsx("div",{className:"bg-white",children:e.jsx("iframe",{srcDoc:j.htmlBody,className:"w-full min-h-[400px] border-0",title:"Email Preview",sandbox:"allow-same-origin"})})]}),j.textBody&&e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.FileText,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.textVersion",{defaultValue:"Version texte"})})]}),e.jsx("div",{className:"px-4 py-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-[var(--text-secondary)] font-mono",children:j.textBody})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Code,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.variables")})]}),e.jsxs("div",{className:"p-4 space-y-4 max-h-[500px] overflow-y-auto",children:[z.custom.length>0&&e.jsx(ee,{title:t("emailTemplates.detail.customVariables"),variables:z.custom,t,defaultExpanded:!0}),e.jsx(ee,{title:t("emailTemplates.detail.userVariables"),variables:z.user,t,defaultExpanded:!1}),e.jsx(ee,{title:t("emailTemplates.detail.emailVariables"),variables:z.email,t,defaultExpanded:!1})]})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Settings,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.detail.quickInfo")})]}),e.jsxs("div",{className:"p-4 space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.form.code")}),e.jsx("code",{className:"px-2 py-0.5 bg-[var(--bg-tertiary)] rounded text-[var(--text-primary)] text-xs",children:r.code})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.form.category")}),e.jsx("span",{className:"text-[var(--text-primary)]",children:H(r.category)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[var(--text-tertiary)]",children:t("emailTemplates.columns.translations")}),e.jsxs("span",{className:"text-[var(--text-primary)]",children:[r.translations.length,"/4"]})]})]})]})]})]})]}),n==="info"&&e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:r.code})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.name")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:r.name})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.description")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] min-h-[60px]",children:r.description||e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"-"})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.category")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:H(r.category)})]}),r.applicationId&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.application")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:r.applicationId})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.createdAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(r.createdAt).toLocaleString()})]}),r.updatedAt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.updatedAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(r.updatedAt).toLocaleString()})]})]})]})]})}),n==="translations"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.detail.translationsTitle")," (",r.translations.length,")"]}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${x}/edit`,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addTranslation")]})]}),r.translations.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("emailTemplates.detail.noTranslations")}),e.jsxs(U.Link,{to:`/administration/workflows/email-templates/${x}/edit`,className:"inline-flex items-center gap-2 mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.detail.addFirstTranslation")]})]}):e.jsx("div",{className:"space-y-3",children:r.translations.map(y=>e.jsx(ye,{translation:y,templateId:x,onPreview:()=>Z(y.languageCode),t,getLanguageLabel:K},y.id))})]})]}),B&&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-card)] border border-[var(--border-color)] p-6 max-w-md w-full shadow-xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:t("emailTemplates.detail.confirmDelete.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("emailTemplates.confirmDelete",{name:r.name})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>T(!1),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:G,disabled:c,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--error-600)] hover:bg-[var(--error-700)] text-white font-medium transition-colors disabled:opacity-50",children:[c?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),t("emailTemplates.delete")]})]})]})}),I&&b&&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-card)] border border-[var(--border-color)] p-6 max-w-4xl w-full max-h-[90vh] overflow-hidden shadow-xl flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.detail.preview")," - ",K(I)]}),e.jsxs("button",{onClick:Q,className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx("span",{className:"sr-only",children:"Close"}),"×"]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.detail.subject")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:b.subject})]}),e.jsx("div",{className:"flex-1 overflow-auto border border-[var(--border-color)] rounded-[var(--radius-card)] bg-white",children:e.jsx("iframe",{srcDoc:b.htmlBody,className:"w-full h-full min-h-[400px]",title:"Email Preview"})})]})}),P&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-white"})})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.detail.notFound")}),e.jsx("button",{onClick:()=>i("/administration/workflows/email-templates"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("emailTemplates.backToList")})]})}function ye({translation:t,templateId:s,onPreview:x,t:i,getLanguageLabel:r}){const g=U.useNavigate(),[u,k]=l.useState(!1);return e.jsxs("div",{className:"rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors overflow-hidden",children:[e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)] uppercase",children:t.languageCode})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:r(t.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:t.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>k(!u),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[u?e.jsx(a.ChevronUp,{className:"w-4 h-4"}):e.jsx(a.ChevronDown,{className:"w-4 h-4"}),u?i("emailTemplates.detail.collapse",{defaultValue:"Reduire"}):i("emailTemplates.detail.expand",{defaultValue:"Voir le contenu"})]}),e.jsxs("button",{onClick:x,className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",children:[e.jsx(a.Eye,{className:"w-4 h-4"}),i("emailTemplates.detail.preview")]}),e.jsxs("button",{onClick:()=>g(`/administration/workflows/email-templates/${s}/edit`),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),i("emailTemplates.edit.title")]})]})]})}),u&&e.jsx("div",{className:"border-t border-[var(--border-color)]",children:e.jsx("div",{className:"bg-white max-h-[300px] overflow-auto",children:e.jsx("iframe",{srcDoc:t.htmlBody,className:"w-full min-h-[200px] border-0",title:`Email Preview - ${t.languageCode}`,sandbox:"allow-same-origin"})})})]})}function ee({title:t,variables:s,t:x,defaultExpanded:i=!1}){const[r,g]=l.useState(i);return e.jsxs("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>g(!r),className:"w-full flex items-center justify-between px-3 py-2 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:s.length}),r?e.jsx(a.ChevronUp,{className:"w-3 h-3"}):e.jsx(a.ChevronDown,{className:"w-3 h-3"})]})]}),r&&e.jsx("div",{className:"p-2 space-y-1",children:s.map(u=>e.jsx(je,{variable:u,t:x},u.name))})]})}function je({variable:t,t:s}){const[x,i]=l.useState(!1),r=`{{ ${t.name} }}`,g=()=>{navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),2e3)};return e.jsxs("div",{className:"group flex items-center justify-between p-2 rounded hover:bg-[var(--bg-tertiary)] transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono text-[var(--color-accent-600)]",children:r}),t.required&&e.jsx("span",{className:"text-xs text-[var(--error-text)]",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 truncate",children:t.description})]}),e.jsx("button",{onClick:g,className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-[var(--bg-hover)] transition-all",title:s("emailTemplates.detail.copyVariable",{defaultValue:"Copier"}),children:x?e.jsx(a.Check,{className:"w-3.5 h-3.5 text-[var(--success-text)]"}):e.jsx(a.Copy,{className:"w-3.5 h-3.5 text-[var(--text-tertiary)]"})})]})}const W=({onClick:t,isActive:s=!1,disabled:x=!1,title:i,children:r})=>e.jsx("button",{type:"button",onClick:t,disabled:x,title:i,className:`p-1.5 rounded transition-colors ${s?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)]":"hover:bg-[var(--bg-hover)] text-[var(--text-secondary)]"} ${x?"opacity-50 cursor-not-allowed":""}`,children:r}),Y=()=>e.jsx("div",{className:"w-px h-6 bg-[var(--border-color)] mx-1"});function we({content:t,onChange:s,placeholder:x,className:i}){const[r,g]=l.useState("visual"),[u,k]=l.useState(t),[v,d]=l.useState(""),[n,E]=l.useState(!1),[M,L]=l.useState(""),[h,f]=l.useState(!1),c=ae.useEditor({extensions:[ie.configure({heading:{levels:[1,2,3]}}),le.configure({openOnClick:!1,HTMLAttributes:{class:"text-[var(--color-accent-600)] underline"}}),ne.configure({HTMLAttributes:{class:"max-w-full h-auto rounded"}}),oe.configure({placeholder:x||"Commencez a ecrire votre email..."}),ce.configure({types:["heading","paragraph"]}),de,me.TextStyle,xe.Color,pe.configure({multicolor:!0})],content:t,onUpdate:({editor:P})=>{const _=P.getHTML();s(_),k(_)},editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[300px] p-4"}}});l.useEffect(()=>{r==="visual"&&c&&u!==c.getHTML()&&c.commands.setContent(u)},[r,c,u]),l.useEffect(()=>{c&&c.getHTML()!==u&&k(c.getHTML())},[c,u]);const C=l.useCallback(P=>{const _=P||"";k(_),s(_)},[s]),B=l.useCallback(()=>{c&&c.commands.setContent(u),g("visual")},[c,u]),T=l.useCallback(()=>{c&&k(c.getHTML()),g("code")},[c]),I=l.useCallback(()=>{v&&c&&(c.chain().focus().extendMarkRange("link").setLink({href:v}).run(),d(""),E(!1))},[c,v]),A=l.useCallback(()=>{c&&(c.chain().focus().unsetLink().run(),E(!1))},[c]),b=l.useCallback(()=>{M&&c&&(c.chain().focus().setImage({src:M}).run(),L(""),f(!1))},[c,M]),S=l.useCallback(P=>{if(c){const _=`{{ ${P} }}`;c.chain().focus().insertContent(`<span class="variable-tag" data-variable="${P}">${_}</span>`).run()}},[c]);return l.useEffect(()=>(typeof window<"u"&&(window.__emailEditorInsertVariable=S),()=>{typeof window<"u"&&delete window.__emailEditorInsertVariable}),[S]),c?e.jsxs("div",{className:`border border-[var(--border-color)] rounded-lg overflow-hidden bg-[var(--bg-primary)] ${i||""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b border-[var(--border-color)] bg-[var(--bg-tertiary)]",children:[e.jsxs("div",{className:"flex items-center gap-1 mr-2",children:[e.jsxs("button",{type:"button",onClick:B,className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${r==="visual"?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Eye,{className:"w-3 h-3"}),"Visuel"]}),e.jsxs("button",{type:"button",onClick:T,className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${r==="code"?"bg-[var(--color-accent-600)] text-white":"bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Code,{className:"w-3 h-3"}),"Code"]})]}),r==="visual"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().undo().run(),disabled:!c.can().undo(),title:"Annuler",children:e.jsx(a.Undo,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().redo().run(),disabled:!c.can().redo(),title:"Retablir",children:e.jsx(a.Redo,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().toggleHeading({level:1}).run(),isActive:c.isActive("heading",{level:1}),title:"Titre 1",children:e.jsx(a.Heading1,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleHeading({level:2}).run(),isActive:c.isActive("heading",{level:2}),title:"Titre 2",children:e.jsx(a.Heading2,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleHeading({level:3}).run(),isActive:c.isActive("heading",{level:3}),title:"Titre 3",children:e.jsx(a.Heading3,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().toggleBold().run(),isActive:c.isActive("bold"),title:"Gras",children:e.jsx(a.Bold,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleItalic().run(),isActive:c.isActive("italic"),title:"Italique",children:e.jsx(a.Italic,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleUnderline().run(),isActive:c.isActive("underline"),title:"Souligne",children:e.jsx(a.Underline,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleStrike().run(),isActive:c.isActive("strike"),title:"Barre",children:e.jsx(a.Strikethrough,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().setTextAlign("left").run(),isActive:c.isActive({textAlign:"left"}),title:"Aligner a gauche",children:e.jsx(a.AlignLeft,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().setTextAlign("center").run(),isActive:c.isActive({textAlign:"center"}),title:"Centrer",children:e.jsx(a.AlignCenter,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().setTextAlign("right").run(),isActive:c.isActive({textAlign:"right"}),title:"Aligner a droite",children:e.jsx(a.AlignRight,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().toggleBulletList().run(),isActive:c.isActive("bulletList"),title:"Liste a puces",children:e.jsx(a.List,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().toggleOrderedList().run(),isActive:c.isActive("orderedList"),title:"Liste numerotee",children:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsx(W,{onClick:()=>c.chain().focus().toggleBlockquote().run(),isActive:c.isActive("blockquote"),title:"Citation",children:e.jsx(a.Quote,{className:"w-4 h-4"})}),e.jsx(W,{onClick:()=>c.chain().focus().setHorizontalRule().run(),title:"Ligne horizontale",children:e.jsx(a.Minus,{className:"w-4 h-4"})}),e.jsx(Y,{}),e.jsxs("div",{className:"relative",children:[e.jsx(W,{onClick:()=>E(!n),isActive:c.isActive("link")||n,title:"Lien",children:e.jsx(a.Link,{className:"w-4 h-4"})}),n&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 flex items-center gap-2",children:[e.jsx("input",{type:"url",value:v,onChange:P=>d(P.target.value),placeholder:"https://...",className:"px-2 py-1 text-sm border border-[var(--border-color)] rounded bg-[var(--bg-primary)] text-[var(--text-primary)] w-48",onKeyDown:P=>P.key==="Enter"&&I()}),e.jsx("button",{type:"button",onClick:I,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),c.isActive("link")&&e.jsx("button",{type:"button",onClick:A,className:"p-1 text-[var(--error-text)] hover:bg-[var(--error-bg)] rounded",children:e.jsx(a.X,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(W,{onClick:()=>f(!h),isActive:h,title:"Image",children:e.jsx(a.Image,{className:"w-4 h-4"})}),h&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 flex items-center gap-2",children:[e.jsx("input",{type:"url",value:M,onChange:P=>L(P.target.value),placeholder:"URL de l'image...",className:"px-2 py-1 text-sm border border-[var(--border-color)] rounded bg-[var(--bg-primary)] text-[var(--text-primary)] w-48",onKeyDown:P=>P.key==="Enter"&&b()}),e.jsx("button",{type:"button",onClick:b,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:()=>f(!1),className:"p-1 text-[var(--error-text)] hover:bg-[var(--error-bg)] rounded",children:e.jsx(a.X,{className:"w-4 h-4"})})]})]}),e.jsx(W,{onClick:()=>{c.chain().focus().insertContent('<img src="{{ company_logo_url }}" alt="Logo" style="max-width: 200px; height: auto;" />').run()},title:"Inserer le logo",children:e.jsx("span",{className:"text-xs font-medium",children:"Logo"})}),e.jsx(Y,{}),e.jsxs("div",{className:"relative group",children:[e.jsx(W,{onClick:()=>{},title:"Couleur du texte",children:e.jsx(a.Palette,{className:"w-4 h-4"})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 hidden group-hover:grid grid-cols-5 gap-1",children:["#000000","#374151","#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"].map(P=>e.jsx("button",{type:"button",onClick:()=>c.chain().focus().setColor(P).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:P}},P))})]}),e.jsxs("div",{className:"relative group",children:[e.jsx(W,{onClick:()=>{},title:"Surligner",children:e.jsx(a.Highlighter,{className:"w-4 h-4"})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-lg z-10 hidden group-hover:grid grid-cols-5 gap-1",children:["#fef08a","#bbf7d0","#bfdbfe","#ddd6fe","#fbcfe8"].map(P=>e.jsx("button",{type:"button",onClick:()=>c.chain().focus().toggleHighlight({color:P}).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:P}},P))})]})]})]}),e.jsx("div",{className:"min-h-[400px]",children:r==="visual"?e.jsx(ae.EditorContent,{editor:c,className:"[&_.ProseMirror]:min-h-[400px] [&_.ProseMirror]:p-4 [&_.ProseMirror]:focus:outline-none [&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.ProseMirror_p.is-editor-empty:first-child::before]:text-[var(--text-tertiary)] [&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left [&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0 [&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none"}):e.jsx(ue,{height:"400px",language:"html",theme:"vs-dark",value:u,onChange:C,options:{minimap:{enabled:!1},fontSize:13,wordWrap:"on",formatOnPaste:!0,automaticLayout:!0,scrollBeyondLastLine:!1,lineNumbers:"on",tabSize:2,folding:!0,renderWhitespace:"selection"}})})]}):e.jsx("div",{className:"flex items-center justify-center h-64 bg-[var(--bg-secondary)] rounded-lg",children:e.jsx("div",{className:"animate-pulse text-[var(--text-tertiary)]",children:"Chargement de l'editeur..."})})}const Ne=[{name:"userName",description:"Nom complet de l'utilisateur"},{name:"firstName",description:"Prenom"},{name:"lastName",description:"Nom de famille"},{name:"displayName",description:"Nom d'affichage (Entra)"},{name:"email",description:"Adresse email"},{name:"phoneNumber",description:"Telephone fixe"},{name:"mobilePhone",description:"Telephone mobile"},{name:"city",description:"Ville"},{name:"country",description:"Pays"},{name:"streetAddress",description:"Adresse"},{name:"postalCode",description:"Code postal"},{name:"company",description:"Nom de l'entreprise"},{name:"department",description:"Departement"},{name:"jobTitle",description:"Fonction/Poste"},{name:"office",description:"Bureau/Site"},{name:"employeeId",description:"Numero d'employe"},{name:"managerName",description:"Nom du manager"}],ke=[{name:"company_logo_url",description:"URL du logo de l'entreprise"},{name:"appName",description:"Nom de l'application"},{name:"resetUrl",description:"Lien de reinitialisation du mot de passe"},{name:"confirmUrl",description:"Lien de confirmation d'email"},{name:"adminName",description:"Nom de l'administrateur (action admin)"},{name:"expiresIn",description:"Delai d'expiration du lien"},{name:"currentDate",description:"Date actuelle"},{name:"currentYear",description:"Annee en cours"}],se=["fr","en","de","it"],Te={userName:"Jean Dupont",firstName:"Jean",lastName:"Dupont",displayName:"Jean Dupont",email:"jean.dupont@example.com",user_email:"jean.dupont@example.com",userEmail:"jean.dupont@example.com",phoneNumber:"+41 21 123 45 67",phone:"+41 21 123 45 67",mobilePhone:"+41 79 123 45 67",mobile:"+41 79 123 45 67",city:"Lausanne",country:"Suisse",streetAddress:"Rue du Lac 15",address:"Rue du Lac 15, 1003 Lausanne",postalCode:"1003",zipCode:"1003",company:"SmartStack SA",companyName:"SmartStack SA",company_name:"SmartStack SA",organization:"SmartStack SA",department:"Informatique",jobTitle:"Developpeur Senior",job_title:"Developpeur Senior",position:"Developpeur Senior",office:"Lausanne HQ",employeeId:"EMP-001234",employee_id:"EMP-001234",managerName:"Marie Martin",manager:"Marie Martin",manager_name:"Marie Martin",company_logo_url:"https://example.com/logo.png",logo_url:"https://example.com/logo.png",logoUrl:"https://example.com/logo.png",appName:"SmartStack",app_name:"SmartStack",applicationName:"SmartStack",siteName:"SmartStack",site_name:"SmartStack",resetUrl:"https://app.smartstack.ch/reset-password?token=abc123",reset_url:"https://app.smartstack.ch/reset-password?token=abc123",resetLink:"https://app.smartstack.ch/reset-password?token=abc123",reset_link:"https://app.smartstack.ch/reset-password?token=abc123",confirmUrl:"https://app.smartstack.ch/confirm-email?token=xyz789",confirm_url:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmationUrl:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmation_url:"https://app.smartstack.ch/confirm-email?token=xyz789",confirmLink:"https://app.smartstack.ch/confirm-email?token=xyz789",activationUrl:"https://app.smartstack.ch/activate?token=xyz789",activation_url:"https://app.smartstack.ch/activate?token=xyz789",activationLink:"https://app.smartstack.ch/activate?token=xyz789",loginUrl:"https://app.smartstack.ch/login",login_url:"https://app.smartstack.ch/login",loginLink:"https://app.smartstack.ch/login",dashboardUrl:"https://app.smartstack.ch/dashboard",dashboard_url:"https://app.smartstack.ch/dashboard",profileUrl:"https://app.smartstack.ch/profile",profile_url:"https://app.smartstack.ch/profile",unsubscribeUrl:"https://app.smartstack.ch/unsubscribe?token=abc",unsubscribe_url:"https://app.smartstack.ch/unsubscribe?token=abc",adminName:"Admin Systeme",admin_name:"Admin Systeme",adminEmail:"admin@smartstack.ch",admin_email:"admin@smartstack.ch",supportEmail:"support@atlashub.ch",support_email:"support@atlashub.ch",supportPhone:"+41 21 123 00 00",support_phone:"+41 21 123 00 00",expiresIn:"24 heures",expires_in:"24 heures",expirationTime:"24 heures",expiration_time:"24 heures",expiryDate:"16 janvier 2026",expiry_date:"16 janvier 2026",currentDate:new Date().toLocaleDateString("fr-CH"),current_date:new Date().toLocaleDateString("fr-CH"),date:new Date().toLocaleDateString("fr-CH"),today:new Date().toLocaleDateString("fr-CH"),currentYear:new Date().getFullYear().toString(),current_year:new Date().getFullYear().toString(),year:new Date().getFullYear().toString(),currentTime:new Date().toLocaleTimeString("fr-CH"),current_time:new Date().toLocaleTimeString("fr-CH"),time:new Date().toLocaleTimeString("fr-CH"),temporaryPassword:"TempPass123!",temporary_password:"TempPass123!",tempPassword:"TempPass123!",temp_password:"TempPass123!",newPassword:"NewPass456!",new_password:"NewPass456!",password:"********",token:"abc123xyz789",verificationCode:"123456",verification_code:"123456",code:"123456",otp:"123456",ticketId:"TKT-2026-00123",ticket_id:"TKT-2026-00123",ticketNumber:"TKT-2026-00123",ticket_number:"TKT-2026-00123",ticketSubject:"Question technique",ticket_subject:"Question technique",ticketStatus:"En cours",ticket_status:"En cours",orderId:"ORD-2026-00456",order_id:"ORD-2026-00456",orderNumber:"ORD-2026-00456",order_number:"ORD-2026-00456",invoiceId:"INV-2026-00789",invoice_id:"INV-2026-00789",invoiceNumber:"INV-2026-00789",invoice_number:"INV-2026-00789",amount:"CHF 150.00",total:"CHF 150.00",price:"CHF 150.00",reason:"Mise a jour de securite",message:"Votre demande a ete traitee avec succes.",description:"Description de l'element",title:"Titre de l'element",name:"Nom de l'element",value:"Valeur exemple",count:"5",number:"42",id:"12345"};function Ce(t){const s=t.toLowerCase();return s.includes("url")||s.includes("link")?"https://app.smartstack.ch/example":s.includes("email")||s.includes("mail")?"exemple@smartstack.ch":s.includes("phone")||s.includes("tel")||s.includes("mobile")?"+41 21 123 45 67":s.includes("date")||s.includes("time")||s.includes("at")?new Date().toLocaleDateString("fr-CH"):s.includes("year")?new Date().getFullYear().toString():s.includes("name")||s.includes("nom")?"Jean Dupont":s.includes("password")||s.includes("pwd")||s.includes("pass")?"MotDePasse123!":s.includes("code")||s.includes("token")||s.includes("otp")?"123456":s.includes("id")||s.includes("number")||s.includes("num")?"12345":s.includes("amount")||s.includes("price")||s.includes("total")||s.includes("cost")?"CHF 100.00":s.includes("count")||s.includes("qty")||s.includes("quantity")?"5":`[${t.replace(/_/g," ").replace(/([A-Z])/g," $1").trim().toLowerCase()}]`}function X(t){if(!t)return t;let s=t;return s=s.replace(/\{\{\s*(\w+)\s*\}\}/g,(x,i)=>Te[i]||Ce(i)),s=s.replace(/\{%\s*if\s+\w+\s*%\}([\s\S]*?)\{%\s*endif\s*%\}/gi,"$1"),s=s.replace(/\{%\s*else\s*%\}[\s\S]*?(?=\{%|\$)/gi,""),s=s.replace(/\{%[^%]*%\}/g,""),s}function Se(){const{t}=J.useTranslation("communications"),{id:s}=U.useParams(),x=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState(!1),[d,n]=U.useSearchParams(),E=d.get("tab")||"info",M=o=>n({tab:o}),[L,h]=l.useState(null),[f,c]=l.useState(null),[C,B]=l.useState({name:"",description:"",category:""}),[T,I]=l.useState(null),[A,b]=l.useState(!1),[S,P]=l.useState(!1),[_,O]=l.useState(!0),[m,D]=l.useState(!1),p=l.useMemo(()=>{let o=[];if(i?.variablesJson)try{const N=JSON.parse(i.variablesJson);Array.isArray(N)?o=N.filter($=>$?.name):typeof N=="object"&&(o=Object.entries(N).filter(([$])=>$&&$!=="undefined").map(([$,R])=>({name:$,description:typeof R=="object"&&R!==null?R.description:void 0,type:typeof R=="object"&&R!==null?R.type:void 0,required:typeof R=="object"&&R!==null?R.required:!1})))}catch{}return{user:Ne,email:ke,custom:o}},[i?.variablesJson]),V=l.useCallback(async()=>{if(s)try{u(!0),h(null);const o=await F.emailTemplates.getById(s);r(o),B({name:o.name,description:o.description||"",category:o.category})}catch(o){console.error("Failed to load template:",o),h(t("emailTemplates.edit.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{V()},[V]);const G=async o=>{if(o.preventDefault(),!(!s||!i))try{v(!0),h(null),await F.emailTemplates.update(s,{name:C.name,description:C.description||void 0,category:C.category,isActive:i.isActive}),c(t("emailTemplates.edit.success.saved")),V()}catch(N){console.error("Failed to save template:",N),h(t("emailTemplates.edit.errors.saveFailed"))}finally{v(!1)}},Z=()=>{const o=i?.translations.map($=>$.languageCode)||[],N=se.filter($=>!o.includes($));if(N.length===0){h(t("emailTemplates.edit.errors.allLanguagesExist"));return}I({languageCode:N[0],subject:"",htmlBody:"",textBody:""}),b(!0)},Q=o=>{I({languageCode:o.languageCode,subject:o.subject,htmlBody:o.htmlBody,textBody:o.textBody||""}),b(!1)},z=async()=>{if(!(!s||!T))try{P(!0),h(null),A?(await F.emailTemplates.createTranslation(s,{languageCode:T.languageCode,subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),c(t("emailTemplates.edit.success.translationAdded"))):(await F.emailTemplates.updateTranslation(s,T.languageCode,{subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),c(t("emailTemplates.edit.success.translationUpdated"))),I(null),V()}catch(o){console.error("Failed to save translation:",o),h(t("emailTemplates.edit.errors.translationSaveFailed"))}finally{P(!1)}},j=async o=>{if(s&&!(!o||!confirm(t("emailTemplates.edit.confirmDeleteTranslation"))))try{P(!0),h(null),h("Delete translation API not implemented yet")}catch(N){console.error("Failed to delete translation:",N),h(t("emailTemplates.edit.errors.translationDeleteFailed"))}finally{P(!1)}},q=[{id:"info",label:t("emailTemplates.edit.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"translations",label:t("emailTemplates.edit.tabs.translations"),icon:e.jsx(a.Languages,{className:"w-4 h-4"})}],H=o=>t(`languages.${o}`,{defaultValue:o.toUpperCase()});if(g)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})});if(!i)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("emailTemplates.detail.notFound")}),e.jsx("button",{onClick:()=>x("/administration/workflows/email-templates"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("emailTemplates.backToList")})]});const K=i.translations.map(o=>o.languageCode),y=se.filter(o=>!K.includes(o));return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.emailTemplates","Email Templates"),href:"/administration/workflows/email-templates"},{label:i?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x(`/administration/workflows/email-templates/${s}`),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:t("emailTemplates.edit.title")}),i.isSystem&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:t("emailTemplates.edit.systemTemplate")})]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:i.code})]})]}),L&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),L]}),f&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),f]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:q.map(o=>e.jsxs("button",{onClick:()=>M(o.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${E===o.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[o.icon,e.jsx("span",{className:"hidden sm:inline",children:o.label})]},o.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[E==="info"&&e.jsxs("form",{onSubmit:G,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:i.code}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("emailTemplates.edit.codeReadOnly")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:C.name,onChange:o=>B(N=>({...N,name:o.target.value})),className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.form.description")}),e.jsx("textarea",{value:C.description,onChange:o=>B(N=>({...N,description:o.target.value})),rows:3,placeholder:t("emailTemplates.form.descriptionPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:border-[var(--color-accent-500)] focus:ring-1 focus:ring-[var(--color-accent-500)]"})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.form.category")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsxs("select",{required:!0,value:C.category,onChange:o=>B(N=>({...N,category:o.target.value})),className:"input w-full",children:[e.jsx("option",{value:"transactional",children:t("emailTemplates.categories.transactional")}),e.jsx("option",{value:"notification",children:t("emailTemplates.categories.notification")}),e.jsx("option",{value:"marketing",children:t("emailTemplates.categories.marketing")}),e.jsx("option",{value:"system",children:t("emailTemplates.categories.system")})]})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-[var(--border-color)]",children:[e.jsx("button",{type:"button",onClick:()=>x(`/administration/workflows/email-templates/${s}`),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:k,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors disabled:opacity-50",children:[k?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]}),E==="translations"&&!T&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("emailTemplates.edit.tabs.translations")," (",i.translations.length,"/4)"]}),y.length>0&&e.jsxs("button",{onClick:Z,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("emailTemplates.edit.addTranslation")]})]}),i.translations.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.Languages,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("emailTemplates.detail.noTranslations")})]}):e.jsx("div",{className:"space-y-3",children:i.translations.map(o=>e.jsx("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)] uppercase",children:o.languageCode})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:H(o.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] truncate max-w-md",children:o.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Q(o),className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--color-accent-600)] hover:bg-[var(--color-accent-50)] dark:hover:bg-[var(--color-accent-900)] transition-colors",children:[e.jsx(a.Settings,{className:"w-4 h-4"}),t("emailTemplates.edit.editTranslation")]}),e.jsx("button",{onClick:()=>j(o.languageCode),disabled:S,className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] text-sm text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})]})},o.id))})]}),E==="translations"&&T&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t(A?"emailTemplates.edit.addTranslation":"emailTemplates.edit.editTranslation")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>O(!_),className:`flex items-center gap-1 px-2 py-1 rounded text-sm transition-colors ${_?"bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[e.jsx(a.Columns,{className:"w-4 h-4"}),t("emailTemplates.edit.showPreview")]}),e.jsx("button",{onClick:()=>I(null),className:"text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:t("common.cancel")})]})]}),e.jsxs("div",{className:`grid gap-6 ${_?"grid-cols-1 xl:grid-cols-2":"grid-cols-1"}`,children:[e.jsxs("div",{className:"space-y-4",children:[A&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.language")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("select",{value:T.languageCode,onChange:o=>I(N=>N?{...N,languageCode:o.target.value}:null),className:"input w-full max-w-xs",children:y.map(o=>e.jsx("option",{value:o,children:H(o)},o))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.subject")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:T.subject,onChange:o=>I(N=>N?{...N,subject:o.target.value}:null),placeholder:t("emailTemplates.edit.subjectPlaceholder"),className:"input w-full"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("emailTemplates.edit.htmlBody")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx(we,{content:T.htmlBody,onChange:o=>I(N=>N?{...N,htmlBody:o}:null),placeholder:t("emailTemplates.edit.htmlBodyPlaceholder")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("emailTemplates.edit.textBody")}),e.jsx("textarea",{value:T.textBody,onChange:o=>I(N=>N?{...N,textBody:o.target.value}:null),rows:4,placeholder:t("emailTemplates.edit.textBodyPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:border-[var(--color-accent-500)] focus:ring-1 focus:ring-[var(--color-accent-500)]"}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("emailTemplates.edit.textBodyHelp")})]})]}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center gap-2",children:[e.jsx(a.Code,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.edit.availableVariables")})]}),e.jsxs("div",{className:"p-3 space-y-3 max-h-[300px] overflow-auto",children:[p.custom.length>0&&e.jsx(te,{title:t("emailTemplates.detail.customVariables"),variables:p.custom,onInsert:o=>{const N=`{{ ${o} }}`;I($=>$?{...$,htmlBody:$.htmlBody+N}:null)},defaultExpanded:!0}),e.jsx(te,{title:t("emailTemplates.detail.userVariables"),variables:p.user,onInsert:o=>{const N=`{{ ${o} }}`;I($=>$?{...$,htmlBody:$.htmlBody+N}:null)},defaultExpanded:!1}),e.jsx(te,{title:t("emailTemplates.detail.emailVariables"),variables:p.email,onInsert:o=>{const N=`{{ ${o} }}`;I($=>$?{...$,htmlBody:$.htmlBody+N}:null)},defaultExpanded:!1})]})]}),e.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"px-4 py-2 bg-[var(--bg-tertiary)] border-b border-[var(--border-color)] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Eye,{className:"w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-secondary)]",children:t("emailTemplates.edit.livePreview")})]}),e.jsx("button",{onClick:()=>D(!0),className:"p-1 rounded hover:bg-[var(--bg-hover)] transition-colors",title:t("emailTemplates.edit.fullscreen"),children:e.jsx(a.Maximize2,{className:"w-4 h-4 text-[var(--text-tertiary)]"})})]}),e.jsxs("div",{className:"px-4 py-2 border-b border-[var(--border-color)] bg-[var(--bg-tertiary)]/50",children:[e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:t("emailTemplates.edit.subject")}),e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:T.subject?X(T.subject):e.jsx("span",{className:"text-[var(--text-tertiary)] italic",children:t("emailTemplates.edit.subjectPlaceholder")})})]}),e.jsx("div",{className:"flex-1 bg-white min-h-[300px]",children:T.htmlBody?e.jsx("iframe",{srcDoc:`<!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="UTF-8">
@@ -101,4 +101,4 @@
101
101
  </head>
102
102
  <body>${X(T.htmlBody)}</body>
103
103
  </html>`,className:"w-full h-full min-h-[500px] border-0",title:"Email Preview Fullscreen",sandbox:"allow-same-origin"})})]})})]})]})}function te({title:t,variables:s,onInsert:x,defaultExpanded:i=!1}){const[r,g]=l.useState(i);return e.jsxs("div",{className:"border border-[var(--border-color)] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>g(!r),className:"w-full flex items-center justify-between px-2 py-1.5 bg-[var(--bg-tertiary)] hover:bg-[var(--bg-hover)] transition-colors text-left",children:[e.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:t}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:s.length}),r?e.jsx(a.ChevronUp,{className:"w-3 h-3"}):e.jsx(a.ChevronDown,{className:"w-3 h-3"})]})]}),r&&e.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:s.map(u=>e.jsx(Le,{variable:u,onInsert:x},u.name))})]})}function Le({variable:t,onInsert:s}){const[x,i]=l.useState(!1),r=`{{ ${t.name} }}`,g=()=>{s(t.name),i(!0),setTimeout(()=>i(!1),1e3)};return e.jsxs("button",{onClick:g,className:"group inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-[var(--bg-tertiary)] hover:bg-[var(--color-accent-100)] dark:hover:bg-[var(--color-accent-900)] transition-colors text-xs",title:t.description||`Inserer ${r}`,children:[e.jsx("code",{className:"font-mono text-[var(--color-accent-600)]",children:t.name}),x&&e.jsx(a.Check,{className:"w-2.5 h-2.5 text-[var(--success-text)]"})]})}function Ae(){const{t}=J.useTranslation("communications");return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("communications.title","Communications"),href:"/administration/communications"},{label:t("communications.smsTemplates","SMS Templates")}]}),e.jsx(w.PageHeader,{title:t("smsTemplates.title","SMS Templates"),subtitle:t("smsTemplates.subtitle","Manage SMS notification templates"),icon:e.jsx(a.MessageSquare,{className:"w-6 h-6"})}),e.jsx("div",{className:"card",children:e.jsx(w.UnderDevelopment,{title:t("smsTemplates.underDevelopment.title","SMS Templates"),description:t("smsTemplates.underDevelopment.description","SMS notification templates will be available soon. This feature will allow you to create and manage SMS templates for automated notifications."),icon:e.jsx(a.MessageSquare,{className:"w-10 h-10 text-amber-600 dark:text-amber-400"}),showBackButton:!0,backUrl:"/administration/workflows/email-templates"})})]})}function Pe(){const{t}=J.useTranslation("communications"),s=U.useNavigate(),{currentTenant:x,isGlobalView:i}=w.useTenant(),[r,g]=l.useState([]),[u,k]=l.useState(!0),[v,d]=l.useState(""),[n,E]=l.useState("table"),[M,L]=l.useState(1),h=20,f=l.useCallback(async()=>{try{k(!0);const m=await F.workflows.getAll({search:v||void 0});g(Array.isArray(m)?m:[])}catch(m){console.error("Failed to load workflows:",m)}finally{k(!1)}},[v]);l.useEffect(()=>{f()},[f,x?.id,i]);const c=m=>{m.preventDefault(),L(1),f()},C=async(m,D)=>{D.stopPropagation();try{m.isActive?await F.workflows.deactivate(m.id):await F.workflows.activate(m.id),f()}catch(p){console.error("Failed to toggle workflow:",p)}},B=async(m,D)=>{if(D.stopPropagation(),m.isSystem){alert(t("workflows.cannotDeleteSystem"));return}if(confirm(t("workflows.confirmDelete",{name:m.name})))try{await F.workflows.delete(m.id),f()}catch(p){console.error("Failed to delete workflow:",p)}},T=(M-1)*h,I=r.slice(T,T+h),A=Math.ceil(r.length/h),b=r.filter(m=>m.isActive),S=r.filter(m=>!m.isActive),P=()=>e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[var(--bg-secondary)]",children:[e.jsx("th",{className:"w-12 px-4 py-3",children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("workflows.columns.name")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden md:table-cell",children:t("workflows.columns.trigger")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:t("workflows.columns.steps")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider hidden lg:table-cell",children:t("workflows.columns.priority")}),e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-[var(--text-tertiary)] uppercase tracking-wider",children:t("workflows.columns.status")}),e.jsx("th",{className:"w-32 px-4 py-3"})]})}),e.jsxs("tbody",{className:"divide-y divide-[var(--border-color)]",children:[u&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]})})}),!u&&I.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--bg-secondary)] flex items-center justify-center",children:e.jsx(a.Workflow,{className:"w-8 h-8 text-[var(--text-tertiary)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("workflows.noResults")})]})})}),!u&&I.length>0&&I.map(m=>e.jsxs("tr",{className:"group hover:bg-[var(--bg-hover)] transition-all cursor-pointer",onClick:()=>s(`/administration/workflows/${m.id}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:D=>D.stopPropagation(),children:e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--border-color)]"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center shadow-md",children:e.jsx(a.Workflow,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-[var(--text-primary)] group-hover:text-primary-600 transition-colors",children:m.name}),m.description&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] truncate max-w-xs",children:m.description}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[m.isSystem&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]",children:"System"}),i&&m.tenantName&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:m.tenantName})]})]})]})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Zap,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:m.triggerName})]})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsxs("span",{className:"px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:[m.stepCount," ",t("workflows.columns.steps").toLowerCase()]})}),e.jsx("td",{className:"px-4 py-3 hidden lg:table-cell",children:e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:m.priority})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(w.StatusBadge,{status:m.isActive?"active":"inactive",label:m.isActive?t("workflows.active"):t("workflows.inactive")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:D=>D.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/${m.id}`),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-primary-600 hover:bg-[var(--accent-bg)] transition-all",title:t("workflows.edit"),children:e.jsx(a.Eye,{className:"w-4 h-4"})}),e.jsx("button",{onClick:D=>C(m,D),className:`p-2 rounded-lg transition-all ${m.isActive?"text-[var(--text-tertiary)] hover:text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"text-[var(--text-tertiary)] hover:text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,title:m.isActive?t("workflows.deactivate"):t("workflows.activate"),children:m.isActive?e.jsx(a.Pause,{className:"w-4 h-4"}):e.jsx(a.Play,{className:"w-4 h-4"})}),e.jsx("button",{onClick:D=>{D.stopPropagation(),s(`/administration/workflows/${m.id}/edit`)},className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--info-text)] hover:bg-[var(--info-bg)] transition-all",title:t("workflows.edit"),children:e.jsx(a.Edit2,{className:"w-4 h-4"})}),!m.isSystem&&e.jsx("button",{onClick:D=>B(m,D),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-all",title:t("workflows.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})})]},m.id))]})]})}),_=()=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[u&&e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}),!u&&I.length===0&&e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg bg-[var(--bg-secondary)] flex items-center justify-center mb-3",children:e.jsx(a.Workflow,{className:"w-8 h-8 text-[var(--text-tertiary)]"})}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("workflows.noResults")})]}),!u&&I.length>0&&I.map(m=>e.jsxs("button",{onClick:()=>s(`/administration/workflows/${m.id}`),className:"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)] cursor-pointer flex flex-col text-left",type:"button",children:[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:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center shadow-lg",children:e.jsx(a.Workflow,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-[var(--text-primary)] truncate",children:m.name}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(a.Zap,{className:"w-3 h-3 text-amber-500"}),m.triggerName]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m.isSystem&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400",children:"System"}),i&&m.tenantName&&e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400",children:m.tenantName}),e.jsx("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${m.isActive?"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:m.isActive?t("workflows.active"):t("workflows.inactive")})]})]})}),e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[m.description&&e.jsx("p",{className:"text-sm text-[var(--text-secondary)] line-clamp-2 mb-3",children:m.description}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-tertiary)] mb-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-[var(--bg-secondary)]",children:[m.stepCount," ",t("workflows.columns.steps").toLowerCase()]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-[var(--bg-secondary)]",children:["P",m.priority]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1 pt-3 border-t border-[var(--border-color)]",onClick:D=>D.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/${m.id}`),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-primary-600 hover:bg-[var(--accent-bg)] transition-all",title:t("workflows.view"),children:e.jsx(a.Eye,{className:"w-4 h-4"})}),e.jsx("button",{onClick:D=>C(m,D),className:`p-2 rounded-lg transition-all ${m.isActive?"text-[var(--text-tertiary)] hover:text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"text-[var(--text-tertiary)] hover:text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,title:m.isActive?t("workflows.deactivate"):t("workflows.activate"),children:m.isActive?e.jsx(a.Pause,{className:"w-4 h-4"}):e.jsx(a.Play,{className:"w-4 h-4"})}),e.jsx("button",{onClick:D=>{D.stopPropagation(),s(`/administration/workflows/${m.id}/edit`)},className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--info-text)] hover:bg-[var(--info-bg)] transition-all",title:t("workflows.edit"),children:e.jsx(a.Edit2,{className:"w-4 h-4"})}),!m.isSystem&&e.jsx("button",{onClick:D=>B(m,D),className:"p-2 rounded-lg text-[var(--text-tertiary)] hover:text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-all",title:t("workflows.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})]})]},m.id))]}),O=()=>e.jsx("div",{className:"flex gap-6 overflow-x-auto pb-4",children:u?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("common.loading",{defaultValue:"Chargement..."})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-[320px] flex-1 rounded-lg p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--success-dot)]"}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:t("workflows.active")}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:b.length})]}),e.jsxs("div",{className:"space-y-3 min-h-[100px]",children:[b.map(m=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/${m.id}`),className:"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-md hover:border-[var(--color-accent-400)] cursor-pointer text-left w-full",children:[e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-3 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center shadow-md",children:e.jsx(a.Workflow,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-[var(--text-primary)] truncate",children:m.name}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(a.Zap,{className:"w-3 h-3 text-amber-500"}),m.triggerName]})]})]})}),e.jsxs("div",{className:"p-3 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-md bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:[m.stepCount," steps"]}),e.jsx("span",{onClick:D=>C(m,D),role:"button",tabIndex:-1,className:"text-xs px-2 py-1 rounded-md bg-[var(--warning-bg)] text-[var(--warning-text)] hover:opacity-80 transition-opacity",children:t("workflows.deactivate")})]})]},m.id)),b.length===0&&e.jsxs("div",{className:"border border-dashed border-[var(--border-color)] rounded-lg p-6 text-center",children:[e.jsx(a.Play,{className:"w-6 h-6 mx-auto mb-2 text-[var(--text-muted)]"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t("workflows.noResults")})]})]})]}),e.jsxs("div",{className:"min-w-[320px] flex-1 rounded-lg p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--text-muted)]"}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:t("workflows.inactive")}),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.length})]}),e.jsxs("div",{className:"space-y-3 min-h-[100px]",children:[S.map(m=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/${m.id}`),className:"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-md hover:border-[var(--color-accent-400)] cursor-pointer opacity-75 text-left w-full",children:[e.jsx("div",{className:"bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20 p-3 border-b border-[var(--color-accent-200)] dark:border-[var(--color-accent-800)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-gray-400 to-gray-500 flex items-center justify-center shadow-md",children:e.jsx(a.Workflow,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-[var(--text-primary)] truncate",children:m.name}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-tertiary)]",children:[e.jsx(a.Zap,{className:"w-3 h-3 text-amber-500"}),m.triggerName]})]})]})}),e.jsxs("div",{className:"p-3 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-md bg-[var(--bg-secondary)] text-[var(--text-secondary)]",children:[m.stepCount," steps"]}),e.jsx("span",{onClick:D=>C(m,D),role:"button",tabIndex:-1,className:"text-xs px-2 py-1 rounded-md bg-[var(--success-bg)] text-[var(--success-text)] hover:opacity-80 transition-opacity",children:t("workflows.activate")})]})]},m.id)),S.length===0&&e.jsxs("div",{className:"border border-dashed border-[var(--border-color)] rounded-lg p-6 text-center",children:[e.jsx(a.Pause,{className:"w-6 h-6 mx-auto mb-2 text-[var(--text-muted)]"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t("workflows.noResults")})]})]})]})]})});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title")}]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("workflows.title")}),e.jsxs("p",{className:"text-sm text-[var(--text-tertiary)] mt-1",children:[r.length," workflows"]})]}),e.jsxs("button",{onClick:()=>s("/administration/workflows/create"),className:"btn btn-primary",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("workflows.create")]})]}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("form",{onSubmit:c,className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(a.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",value:v,onChange:m=>d(m.target.value),placeholder:t("workflows.searchPlaceholder"),className:"input w-full pl-10"})]}),e.jsxs("button",{type:"submit",className:"btn btn-secondary",children:[e.jsx(a.Filter,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Filtres"})]})]}),e.jsx(w.ViewToggle,{viewMode:n,onChange:E,tableLabel:"Table",cardsLabel:"Cards",kanbanLabel:"Kanban"})]})}),n==="table"&&P(),n==="cards"&&_(),n==="kanban"&&O(),n!=="kanban"&&r.length>0&&e.jsx(w.Pagination,{page:M,totalPages:A,totalCount:r.length,pageSize:h,onPageChange:L,itemLabel:"workflows"})]})}function Ee(){const{t}=J.useTranslation("communications"),[s,x]=l.useState([]),[i,r]=l.useState(!0),[g,u]=l.useState(null);l.useEffect(()=>{(async()=>{try{r(!0);const n=await F.triggers.getAll();x(Array.isArray(n)?n:[])}catch(n){console.error("Failed to load triggers:",n)}finally{r(!1)}})()},[]);const k=d=>{switch(d){case"UserEvent":return"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20";case"TicketEvent":return"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20";case"SystemEvent":return"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border-[var(--border-color)]";case"Scheduled":return"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20";default:return"bg-[var(--bg-tertiary)] text-[var(--text-secondary)] border-[var(--border-color)]"}},v=d=>{if(!d)return[];try{return JSON.parse(d)}catch{return[]}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:t("triggers.title")}]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("triggers.title")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] mt-1",children:t("triggers.description")})]}),i?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-primary-500"}),e.jsx("span",{className:"mt-3 text-sm text-[var(--text-secondary)]",children:t("workflows.loadingTriggers")})]}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-3",children:[s.map(d=>{const n=v(d.availableVariablesJson);return e.jsxs("button",{type:"button",onClick:()=>u(d),className:`card p-4 cursor-pointer transition-all text-left w-full ${g?.id===d.id?"ring-2 ring-[var(--color-accent-500)] border-[var(--color-accent-500)]":"hover:border-[var(--color-accent-500)]/50"}`,children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-lg bg-amber-500/10",children:e.jsx(a.Zap,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:d.name}),e.jsx("code",{className:"text-sm text-[var(--text-tertiary)] bg-[var(--bg-secondary)] px-1.5 py-0.5 rounded",children:d.code})]})]}),e.jsx("span",{className:`px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium border ${k(d.triggerType)}`,children:d.triggerType})]}),e.jsx("div",{className:"mt-3 flex items-center gap-4 text-sm text-[var(--text-tertiary)]",children:e.jsxs("span",{children:[n.length," ",t("triggers.variables")]})})]},d.id)}),s.length===0&&e.jsxs("div",{className:"card p-12 text-center",children:[e.jsx(a.Zap,{className:"w-12 h-12 mx-auto text-[var(--text-muted)] mb-3"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"No triggers available"})]})]}),e.jsx("div",{className:"lg:col-span-1",children:g?e.jsxs("div",{className:"card p-5 sticky top-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-5 pb-4 border-b border-[var(--border-color)]",children:[e.jsx("div",{className:"p-2 rounded-lg bg-[var(--accent-bg)]",children:e.jsx(a.Info,{className:"w-5 h-5 text-[var(--accent-text)]"})}),e.jsx("h2",{className:"font-semibold text-[var(--text-primary)]",children:t("triggers.details")})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider",children:t("triggers.name")}),e.jsx("p",{className:"font-medium text-[var(--text-primary)] mt-1",children:g.name})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider",children:t("triggers.code")}),e.jsx("code",{className:"block bg-[var(--bg-secondary)] px-3 py-2 rounded-lg text-sm text-[var(--text-primary)] mt-1 font-mono",children:g.code})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider",children:t("triggers.type")}),e.jsx("div",{className:"mt-1",children:e.jsx("span",{className:`inline-flex px-2.5 py-1 rounded-[var(--radius-badge)] text-xs font-medium border ${k(g.triggerType)}`,children:g.triggerType})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider",children:t("triggers.availableVariables")}),e.jsxs("div",{className:"mt-2 space-y-1.5 max-h-48 overflow-y-auto",children:[v(g.availableVariablesJson).map(d=>e.jsxs("code",{className:"flex items-center gap-2 bg-[var(--bg-secondary)] px-3 py-2 rounded-lg text-xs text-[var(--text-primary)] font-mono",children:[e.jsx("span",{className:"text-amber-500",children:"{{"}),e.jsx("span",{children:d}),e.jsx("span",{className:"text-amber-500",children:"}}"})]},d)),v(g.availableVariablesJson).length===0&&e.jsx("p",{className:"text-sm text-[var(--text-muted)] italic",children:"No variables available"})]})]})]})]}):e.jsxs("div",{className:"card p-8 text-center bg-[var(--bg-secondary)]/50",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--bg-secondary)] flex items-center justify-center mx-auto mb-4",children:e.jsx(a.Info,{className:"w-8 h-8 text-[var(--text-muted)]"})}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("triggers.selectToViewDetails")})]})})]})]})}function De(){const{t}=J.useTranslation("communications"),s=U.useNavigate(),[x,i]=l.useState(!1),[r,g]=l.useState(null),[u,k]=l.useState([]),[v,d]=l.useState(!0),[n,E]=l.useState({code:"",name:"",description:"",triggerId:"",priority:0});l.useEffect(()=>{(async()=>{try{d(!0);const f=await F.triggers.getAll();k(f)}catch(f){console.error("Failed to load triggers:",f)}finally{d(!1)}})()},[]);const M=async h=>{h.preventDefault(),i(!0),g(null);try{const f=await F.workflows.create({code:n.code,name:n.name,description:n.description||void 0,triggerId:n.triggerId,priority:n.priority});s(`/administration/workflows/${f.id}`)}catch(f){const c=f instanceof Error?f.message:"An error occurred while creating the workflow";g(c)}finally{i(!1)}},L=u.find(h=>h.id===n.triggerId);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:t("workflows.create","Create")}]}),e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("button",{onClick:()=>s("/administration/workflows/list"),className:"flex items-center gap-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors mb-4",children:[e.jsx(a.ArrowLeft,{className:"w-4 h-4"}),t("workflows.backToList")]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-emerald-500 to-teal-500 flex items-center justify-center shadow-lg shadow-emerald-500/20",children:e.jsx(a.Workflow,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)]",children:t("workflows.createTitle")}),e.jsx("p",{className:"text-sm text-[var(--text-tertiary)]",children:t("workflows.description")})]})]})]}),e.jsxs("form",{onSubmit:M,className:"space-y-6 max-w-2xl",children:[r&&e.jsx("div",{className:"p-4 rounded-lg bg-[var(--error-bg)] text-[var(--error-text)] text-sm border border-[var(--error-border)]",children:r}),e.jsxs("div",{className:"card p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("workflows.form.code")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:n.code,onChange:h=>E(f=>({...f,code:h.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")})),placeholder:"e.g., user-welcome-flow",className:"input w-full"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-1.5",children:t("workflows.form.codeHelp")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("workflows.form.name")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:n.name,onChange:h=>E(f=>({...f,name:h.target.value})),placeholder:"e.g., User Welcome Flow",className:"input w-full"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("workflows.form.description")}),e.jsx("textarea",{value:n.description,onChange:h=>E(f=>({...f,description:h.target.value})),rows:3,placeholder:t("workflows.form.descriptionPlaceholder"),className:"input w-full resize-none"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:[t("workflows.form.trigger")," ",e.jsx("span",{className:"text-[var(--error-text)]",children:"*"})]}),v?e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] py-2",children:[e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),t("workflows.loadingTriggers")]}):e.jsxs("select",{required:!0,value:n.triggerId,onChange:h=>E(f=>({...f,triggerId:h.target.value})),className:"input w-full",children:[e.jsx("option",{value:"",children:t("workflows.form.selectTrigger")}),u.map(h=>e.jsxs("option",{value:h.id,children:[h.name," (",h.code,")"]},h.id))]}),L&&e.jsxs("div",{className:"mt-3 p-3 rounded-lg bg-[var(--bg-secondary)] border border-[var(--border-color)]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[e.jsx(a.Zap,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{children:t("workflows.form.triggerSelected")})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-[var(--radius-badge)] bg-amber-500/10 text-amber-600 border border-amber-500/20",children:L.triggerType}),e.jsx("code",{className:"text-xs text-[var(--text-tertiary)]",children:L.code})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1.5",children:t("workflows.form.priority")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("input",{type:"range",min:0,max:100,value:n.priority,onChange:h=>E(f=>({...f,priority:parseInt(h.target.value)||0})),className:"flex-1 h-2 bg-[var(--bg-secondary)] rounded-lg appearance-none cursor-pointer accent-[var(--color-accent-600)]"}),e.jsx("input",{type:"number",min:0,max:100,value:n.priority,onChange:h=>E(f=>({...f,priority:Math.min(100,Math.max(0,parseInt(h.target.value)||0))})),className:"input w-20 text-center"})]}),e.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-1.5",children:t("workflows.form.priorityHelp")})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>s("/administration/workflows/list"),className:"btn btn-secondary",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:x||!n.triggerId,className:"btn btn-primary disabled:opacity-50",children:[x?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]})]})}const $e={SendEmail:e.jsx(a.Mail,{className:"w-4 h-4"}),Wait:e.jsx(a.Clock,{className:"w-4 h-4"}),Condition:e.jsx(a.GitBranch,{className:"w-4 h-4"}),Webhook:e.jsx(a.Webhook,{className:"w-4 h-4"})},Ie={SendEmail:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",Wait:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",Condition:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",Webhook:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"};function Me(){const{t}=J.useTranslation("communications"),{id:s}=U.useParams(),x=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState("info"),[d,n]=l.useState(null),[E,M]=l.useState(null),[L,h]=l.useState(!1),[f,c]=l.useState(!1),C=l.useCallback(async()=>{if(s)try{u(!0),n(null);const b=await F.workflows.getById(s);r(b)}catch(b){console.error("Failed to load workflow:",b),n(t("workflows.detail.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{C()},[C]);const B=async()=>{if(s)try{h(!0),n(null),await F.workflows.activate(s),M(t("workflows.detail.success.activated")),C()}catch(b){console.error("Failed to activate workflow:",b),n(t("workflows.detail.errors.activateFailed"))}finally{h(!1)}},T=async()=>{if(s)try{h(!0),n(null),await F.workflows.deactivate(s),M(t("workflows.detail.success.deactivated")),C()}catch(b){console.error("Failed to deactivate workflow:",b),n(t("workflows.detail.errors.deactivateFailed"))}finally{h(!1)}},I=async()=>{if(!(!s||!i)){if(i.isSystem){n(t("workflows.cannotDeleteSystem"));return}try{h(!0),n(null),await F.workflows.delete(s),x("/administration/workflows/list")}catch(b){console.error("Failed to delete workflow:",b),n(t("workflows.detail.errors.deleteFailed")),c(!1)}finally{h(!1)}}},A=[{id:"info",label:t("workflows.detail.tabs.info"),icon:e.jsx(a.Settings,{className:"w-4 h-4"})},{id:"steps",label:t("workflows.detail.tabs.steps"),icon:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}];return g?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):i?e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:i?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x("/administration/workflows/list"),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:i.name}),i.isSystem&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]",children:[e.jsx(a.Lock,{className:"w-3 h-3"}),t("workflows.detail.system")]}),i.tenantName&&e.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-[var(--radius-badge)] text-xs bg-[var(--bg-secondary)] text-[var(--text-secondary)] border border-[var(--border-color)]",children:i.tenantName}),e.jsx("span",{className:`px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium ${i.isActive?"bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]":"bg-[var(--error-bg)] text-[var(--error-text)] border border-[var(--error-border)]"}`,children:i.isActive?t("workflows.active"):t("workflows.inactive")})]}),i.description&&e.jsx("p",{className:"text-sm sm:text-base text-[var(--text-secondary)] mt-1",children:i.description})]}),e.jsx("div",{className:"flex items-center gap-2",children:!i.isSystem&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>x(`/administration/workflows/${s}/edit`),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:bg-[var(--bg-hover)] text-[var(--text-primary)] transition-colors",children:[e.jsx(a.Edit,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("workflows.edit")})]}),e.jsxs("button",{onClick:i.isActive?T:B,disabled:L,className:`flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border transition-colors ${i.isActive?"border-[var(--warning-border)] text-[var(--warning-text)] hover:bg-[var(--warning-bg)]":"border-[var(--success-border)] text-[var(--success-text)] hover:bg-[var(--success-bg)]"}`,children:[L&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),!L&&i.isActive&&e.jsx(a.Pause,{className:"w-4 h-4"}),!L&&!i.isActive&&e.jsx(a.Play,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:i.isActive?t("workflows.deactivate"):t("workflows.activate")})]}),e.jsxs("button",{onClick:()=>c(!0),className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] border border-[var(--error-border)] text-[var(--error-text)] hover:bg-[var(--error-bg)] transition-colors",children:[e.jsx(a.Trash2,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:t("workflows.delete")})]})]})})]}),d&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),d]}),E&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),E]}),i.isSystem&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border border-[var(--warning-border)] text-[var(--warning-text)] flex items-center gap-2",children:[e.jsx(a.Lock,{className:"w-5 h-5 flex-shrink-0"}),t("workflows.detail.systemReadOnly")]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:A.map(b=>e.jsxs("button",{onClick:()=>v(b.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${k===b.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[b.icon,e.jsx("span",{className:"hidden sm:inline",children:b.label}),b.id==="steps"&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-xs ${k===b.id?"bg-white/20":"bg-[var(--bg-tertiary)]"}`,children:i.steps.length})]},b.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[k==="info"&&e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-mono text-sm",children:i.code})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.name")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:i.name})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.description")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] min-h-[60px]",children:i.description||e.jsx("span",{className:"text-[var(--text-tertiary)]",children:"-"})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.trigger")}),e.jsxs("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:[e.jsx("div",{className:"font-medium",children:i.triggerName}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] font-mono",children:i.triggerCode})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.priority")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:i.priority})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.detail.createdAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(i.createdAt).toLocaleString()})]}),i.updatedAt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.detail.updatedAt")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] text-sm",children:new Date(i.updatedAt).toLocaleString()})]})]})]})]})}),k==="steps"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[t("workflows.detail.stepsTitle")," (",i.steps.length,")"]}),!i.isSystem&&e.jsxs(U.Link,{to:`/administration/workflows/${s}/edit`,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("workflows.detail.addStep")]})]}),i.steps.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.ListOrdered,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("workflows.detail.noSteps")}),!i.isSystem&&e.jsxs(U.Link,{to:`/administration/workflows/${s}/edit`,className:"inline-flex items-center gap-2 mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),t("workflows.detail.addFirstStep")]})]}):e.jsx("div",{className:"space-y-3",children:i.steps.sort((b,S)=>b.stepOrder-S.stepOrder).map((b,S)=>e.jsx(Fe,{step:b,index:S,isLast:S===i.steps.length-1,t},b.id))})]})]}),f&&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-card)] border border-[var(--border-color)] p-6 max-w-md w-full shadow-xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:t("workflows.detail.confirmDelete.title")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:t("workflows.confirmDelete",{name:i.name})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>c(!1),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:I,disabled:L,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--error-600)] hover:bg-[var(--error-700)] text-white font-medium transition-colors disabled:opacity-50",children:[L?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),t("workflows.delete")]})]})]})})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("workflows.detail.notFound")}),e.jsx("button",{onClick:()=>x("/administration/workflows/list"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("workflows.backToList")})]})}function Fe({step:t,index:s,isLast:x,t:i}){const r=$e[t.stepType]||e.jsx(a.Settings,{className:"w-4 h-4"}),g=Ie[t.stepType]||"bg-gray-100 text-gray-700",u=()=>{switch(t.stepType){case"SendEmail":return t.emailTemplateName?i("workflows.detail.stepDetails.emailTemplate",{template:t.emailTemplateName}):i("workflows.detail.stepDetails.noTemplate");case"Wait":return i("workflows.detail.stepDetails.waitMinutes",{minutes:t.delayMinutes||0});case"Condition":return i("workflows.detail.stepDetails.condition");case"Webhook":if(t.configurationJson)try{return JSON.parse(t.configurationJson).url||i("workflows.detail.stepDetails.webhookConfigured")}catch{return i("workflows.detail.stepDetails.webhookConfigured")}return i("workflows.detail.stepDetails.noWebhook");default:return""}};return e.jsxs("div",{className:"relative",children:[!x&&e.jsx("div",{className:"absolute left-6 top-14 bottom-0 w-0.5 bg-[var(--border-color)]",style:{height:"calc(100% - 20px)"}}),e.jsxs("div",{className:"flex items-start gap-4 p-4 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)]",children:s+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium ${g}`,children:[r,i(`workflows.stepTypes.${t.stepType}`)]})}),e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:t.name}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-0.5",children:u()})]})]})]})}const Be={SendEmail:e.jsx(a.Mail,{className:"w-4 h-4"}),Wait:e.jsx(a.Clock,{className:"w-4 h-4"}),Condition:e.jsx(a.GitBranch,{className:"w-4 h-4"}),Webhook:e.jsx(a.Webhook,{className:"w-4 h-4"})},_e={SendEmail:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",Wait:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",Condition:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",Webhook:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"},Ve=["SendEmail","Wait","Condition","Webhook"];function We({workflowId:t,steps:s,onStepsChange:x,readOnly:i=!1}){const{t:r}=J.useTranslation("communications"),[g,u]=l.useState(!1),[k,v]=l.useState(null),[d,n]=l.useState(null),[E,M]=l.useState(!1),[L,h]=l.useState(!1),[f,c]=l.useState(!1),[C,B]=l.useState(null),[T,I]=l.useState([]),[A,b]=l.useState(!1),[S,P]=l.useState({name:"",stepType:"",emailTemplateId:"",delayMinutes:5,configurationJson:""}),_=async()=>{if(!(T.length>0))try{b(!0);const j=await F.emailTemplates.getAll({isActive:!0});I(j)}catch(j){console.error("Failed to load email templates:",j)}finally{b(!1)}},O=()=>{P({name:"",stepType:"",emailTemplateId:"",delayMinutes:5,configurationJson:""})},m=()=>{O(),_(),M(!0)},D=j=>{B(j),_(),P({name:j.name,stepType:j.stepType,emailTemplateId:j.emailTemplateId||"",delayMinutes:j.delayMinutes||5,configurationJson:j.configurationJson||""}),h(!0)},p=j=>{B(j),c(!0)},V=async j=>{if(j.preventDefault(),!S.name||!S.stepType){v(r("workflows.steps.errors.nameRequired"));return}try{u(!0),v(null);const q={name:S.name,stepType:S.stepType,emailTemplateId:S.stepType==="SendEmail"&&S.emailTemplateId||void 0,delayMinutes:S.stepType==="Wait"?S.delayMinutes:void 0,configurationJson:["Condition","Webhook"].includes(S.stepType)&&S.configurationJson||void 0};await F.workflows.addStep(t,q),n(r("workflows.steps.success.added")),M(!1),O(),x()}catch(q){console.error("Failed to add step:",q),v(r("workflows.steps.errors.addFailed"))}finally{u(!1)}},G=async j=>{if(j.preventDefault(),!C||!S.name||!S.stepType){v(r("workflows.steps.errors.nameRequired"));return}try{u(!0),v(null);const q={name:S.name,stepOrder:C.stepOrder,isActive:C.isActive,emailTemplateId:S.stepType==="SendEmail"&&S.emailTemplateId||void 0,delayMinutes:S.stepType==="Wait"?S.delayMinutes:void 0,configurationJson:["Condition","Webhook"].includes(S.stepType)&&S.configurationJson||void 0};await F.workflows.updateStep(t,C.id,q),n(r("workflows.steps.success.updated")),h(!1),B(null),O(),x()}catch(q){console.error("Failed to update step:",q),v(r("workflows.steps.errors.updateFailed"))}finally{u(!1)}},Z=async()=>{if(C)try{u(!0),v(null),await F.workflows.deleteStep(t,C.id),n(r("workflows.steps.success.deleted")),c(!1),B(null),x()}catch(j){console.error("Failed to delete step:",j),v(r("workflows.steps.errors.deleteFailed"))}finally{u(!1)}},Q=async(j,q)=>{const H=[...s].sort((o,N)=>o.stepOrder-N.stepOrder),K=H.findIndex(o=>o.id===j.id),y=q==="up"?K-1:K+1;if(!(y<0||y>=H.length))try{u(!0),v(null);const o=H[y],N={name:j.name,stepOrder:o.stepOrder,isActive:j.isActive,emailTemplateId:j.emailTemplateId||void 0,delayMinutes:j.delayMinutes||void 0,configurationJson:j.configurationJson||void 0};await F.workflows.updateStep(t,j.id,N);const $={name:o.name,stepOrder:j.stepOrder,isActive:o.isActive,emailTemplateId:o.emailTemplateId||void 0,delayMinutes:o.delayMinutes||void 0,configurationJson:o.configurationJson||void 0};await F.workflows.updateStep(t,o.id,$),x()}catch(o){console.error("Failed to reorder steps:",o),v(r("workflows.steps.errors.updateFailed"))}finally{u(!1)}};l.useEffect(()=>{if(d){const j=setTimeout(()=>n(null),3e3);return()=>clearTimeout(j)}},[d]),l.useEffect(()=>{if(k){const j=setTimeout(()=>v(null),5e3);return()=>clearTimeout(j)}},[k]);const z=[...s].sort((j,q)=>j.stepOrder-q.stepOrder);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:[r("workflows.steps.title")," (",s.length,")"]}),!i&&e.jsxs("button",{onClick:m,className:"flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors",children:[e.jsx(a.Plus,{className:"w-4 h-4"}),r("workflows.steps.add")]})]}),k&&e.jsxs("div",{className:"p-3 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2 text-sm",children:[e.jsx(a.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),k]}),d&&e.jsxs("div",{className:"p-3 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2 text-sm",children:[e.jsx(a.CheckCircle,{className:"w-4 h-4 flex-shrink-0"}),d]}),s.length===0?e.jsxs("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:[e.jsx(a.ListOrdered,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:r("workflows.steps.noSteps")}),!i&&e.jsx("p",{className:"text-sm mt-2",children:r("workflows.steps.addFirstStep")})]}):e.jsx("div",{className:"space-y-2",children:z.map((j,q)=>e.jsx(Ue,{step:j,index:q,isFirst:q===0,isLast:q===z.length-1,onEdit:()=>D(j),onDelete:()=>p(j),onMoveUp:()=>Q(j,"up"),onMoveDown:()=>Q(j,"down"),readOnly:i,loading:g,t:r},j.id))}),E&&e.jsx(re,{title:r("workflows.steps.add"),formData:S,setFormData:P,emailTemplates:T,loadingTemplates:A,loading:g,onSubmit:V,onClose:()=>{M(!1),O()},t:r}),L&&C&&e.jsx(re,{title:r("workflows.steps.edit"),formData:S,setFormData:P,emailTemplates:T,loadingTemplates:A,loading:g,onSubmit:G,onClose:()=>{h(!1),B(null),O()},t:r}),f&&C&&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-card)] border border-[var(--border-color)] p-6 max-w-md w-full shadow-xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)] mb-2",children:r("workflows.steps.delete")}),e.jsx("p",{className:"text-[var(--text-secondary)] mb-6",children:r("workflows.steps.confirmDelete")}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>{c(!1),B(null)},className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:r("common.cancel")}),e.jsxs("button",{onClick:Z,disabled:g,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--error-600)] hover:bg-[var(--error-700)] text-white font-medium transition-colors disabled:opacity-50",children:[g?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),r("workflows.steps.delete")]})]})]})})]})}function Ue({step:t,index:s,isFirst:x,isLast:i,onEdit:r,onDelete:g,onMoveUp:u,onMoveDown:k,readOnly:v,loading:d,t:n}){const E=Be[t.stepType]||e.jsx(a.Settings,{className:"w-4 h-4"}),M=_e[t.stepType]||"bg-gray-100 text-gray-700",L=()=>{switch(t.stepType){case"SendEmail":return t.emailTemplateName||n("workflows.detail.stepDetails.noTemplate");case"Wait":return n("workflows.detail.stepDetails.waitMinutes",{minutes:t.delayMinutes||0});case"Condition":return n("workflows.detail.stepDetails.condition");case"Webhook":if(t.configurationJson)try{return JSON.parse(t.configurationJson).url||n("workflows.detail.stepDetails.webhookConfigured")}catch{return n("workflows.detail.stepDetails.webhookConfigured")}return n("workflows.detail.stepDetails.noWebhook");default:return""}};return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-[var(--radius-card)] bg-[var(--bg-primary)] border border-[var(--border-color)] hover:border-[var(--color-accent-300)] transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-bold text-[var(--color-accent-700)] dark:text-[var(--color-accent-300)]",children:s+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-0.5",children:e.jsxs("span",{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${M}`,children:[E,n(`workflows.stepTypes.${t.stepType}`)]})}),e.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate",children:t.name}),e.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:L()})]}),!v&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:u,disabled:x||d,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:n("workflows.steps.moveUp"),children:e.jsx(a.ChevronUp,{className:"w-4 h-4"})}),e.jsx("button",{onClick:k,disabled:i||d,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:n("workflows.steps.moveDown"),children:e.jsx(a.ChevronDown,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,disabled:d,className:"p-1.5 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] hover:text-[var(--color-accent-600)] disabled:opacity-30 transition-colors",title:n("workflows.steps.edit"),children:e.jsx(a.Edit,{className:"w-4 h-4"})}),e.jsx("button",{onClick:g,disabled:d,className:"p-1.5 rounded hover:bg-[var(--error-bg)] text-[var(--text-secondary)] hover:text-[var(--error-text)] disabled:opacity-30 transition-colors",title:n("workflows.steps.delete"),children:e.jsx(a.Trash2,{className:"w-4 h-4"})})]})]})}function re({title:t,formData:s,setFormData:x,emailTemplates:i,loadingTemplates:r,loading:g,onSubmit:u,onClose:k,t:v}){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-card)] border border-[var(--border-color)] w-full max-w-lg shadow-xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border-color)]",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--text-primary)]",children:t}),e.jsx("button",{onClick:k,className:"p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-secondary)] transition-colors",children:e.jsx(a.X,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:u,className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[v("workflows.steps.form.name")," *"]}),e.jsx("input",{type:"text",required:!0,value:s.name,onChange:d=>x(n=>({...n,name:d.target.value})),placeholder:v("workflows.steps.form.namePlaceholder"),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[v("workflows.steps.form.type")," *"]}),e.jsxs("select",{required:!0,value:s.stepType,onChange:d=>x(n=>({...n,stepType:d.target.value})),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"",children:v("workflows.steps.form.selectType")}),Ve.map(d=>e.jsx("option",{value:d,children:v(`workflows.stepTypes.${d}`)},d))]})]}),s.stepType==="SendEmail"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.emailTemplate")}),e.jsxs("select",{value:s.emailTemplateId,onChange:d=>x(n=>({...n,emailTemplateId:d.target.value})),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"",children:v("workflows.steps.form.selectTemplate")}),r?e.jsx("option",{disabled:!0,children:"Loading..."}):i.map(d=>e.jsxs("option",{value:d.id,children:[d.name," (",d.code,")"]},d.id))]})]}),s.stepType==="Wait"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.delayMinutes")}),e.jsx("div",{className:"flex gap-2 mb-2",children:[{label:v("workflows.steps.form.delayPresets.5min"),value:5},{label:v("workflows.steps.form.delayPresets.15min"),value:15},{label:v("workflows.steps.form.delayPresets.1hour"),value:60},{label:v("workflows.steps.form.delayPresets.24hours"),value:1440}].map(d=>e.jsx("button",{type:"button",onClick:()=>x(n=>({...n,delayMinutes:d.value})),className:`px-2 py-1 text-xs rounded border transition-colors ${s.delayMinutes===d.value?"bg-[var(--color-accent-100)] border-[var(--color-accent-500)] text-[var(--color-accent-700)]":"border-[var(--border-color)] hover:bg-[var(--bg-hover)]"}`,children:d.label},d.value))}),e.jsx("input",{type:"number",min:1,value:s.delayMinutes,onChange:d=>x(n=>({...n,delayMinutes:parseInt(d.target.value)||1})),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),s.stepType==="Condition"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.condition")}),e.jsx("textarea",{value:s.configurationJson,onChange:d=>x(n=>({...n,configurationJson:d.target.value})),rows:4,placeholder:'{"field": "value", "operator": "equals"}',className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] font-mono text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none"}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:v("workflows.steps.form.conditionHelp")})]}),s.stepType==="Webhook"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.webhookUrl")}),e.jsx("input",{type:"url",value:s.configurationJson?(()=>{try{return JSON.parse(s.configurationJson).url||""}catch{return""}})():"",onChange:d=>{const n=s.configurationJson?JSON.parse(s.configurationJson):{};n.url=d.target.value,x(E=>({...E,configurationJson:JSON.stringify(n)}))},placeholder:v("workflows.steps.form.webhookUrlPlaceholder"),className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:v("workflows.steps.form.webhookMethod")}),e.jsxs("select",{value:s.configurationJson?(()=>{try{return JSON.parse(s.configurationJson).method||"POST"}catch{return"POST"}})():"POST",onChange:d=>{const n=s.configurationJson?JSON.parse(s.configurationJson):{};n.method=d.target.value,x(E=>({...E,configurationJson:JSON.stringify(n)}))},className:"w-full px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",children:[e.jsx("option",{value:"POST",children:"POST"}),e.jsx("option",{value:"PUT",children:"PUT"}),e.jsx("option",{value:"PATCH",children:"PATCH"}),e.jsx("option",{value:"GET",children:"GET"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-[var(--border-color)]",children:[e.jsx("button",{type:"button",onClick:k,className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:v("common.cancel")}),e.jsxs("button",{type:"submit",disabled:g,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors disabled:opacity-50",children:[g&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),v("common.save")]})]})]})]})})}function qe(){const{t}=J.useTranslation("communications"),{id:s}=U.useParams(),x=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState(!1),[d,n]=l.useState("info"),[E,M]=l.useState(null),[L,h]=l.useState(null),[f,c]=l.useState({name:"",description:"",priority:0}),C=l.useCallback(async()=>{if(s)try{u(!0),M(null);const A=await F.workflows.getById(s);r(A),c({name:A.name,description:A.description||"",priority:A.priority})}catch(A){console.error("Failed to load workflow:",A),M(t("workflows.edit.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{C()},[C]);const B=async A=>{if(A.preventDefault(),!(!s||!i)){if(i.isSystem){M(t("workflows.edit.errors.cannotEditSystem"));return}v(!0),M(null),h(null);try{const b={name:f.name,description:f.description||void 0,triggerId:i.triggerId,priority:f.priority};await F.workflows.update(s,b),h(t("workflows.edit.success.saved")),C()}catch(b){M(b instanceof Error?b.message:t("workflows.edit.errors.saveFailed"))}finally{v(!1)}}},T=()=>{C()},I=[{id:"info",label:t("workflows.edit.tabs.info"),icon:e.jsx(a.Save,{className:"w-4 h-4"})},{id:"steps",label:t("workflows.edit.tabs.steps"),icon:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}];return g?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(a.Loader2,{className:"w-8 h-8 animate-spin text-[var(--color-accent-500)]"})}):i?i.isSystem?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x(`/administration/workflows/${s}`),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:t("workflows.edit.title")})]}),e.jsx("div",{className:"p-6 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border border-[var(--warning-border)] text-[var(--warning-text)]",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(a.Lock,{className:"w-6 h-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:t("workflows.edit.systemWorkflow")}),e.jsx("p",{className:"text-sm mt-1",children:t("workflows.detail.systemReadOnly")})]})]})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:i?.name||""}]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x(`/administration/workflows/${s}`),className:"p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",children:e.jsx(a.ArrowLeft,{className:"w-5 h-5 text-[var(--text-secondary)]"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("h1",{className:"text-xl sm:text-2xl font-bold text-[var(--text-primary)]",children:[t("workflows.edit.title"),": ",i.name]}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:i.code})]})]}),E&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)] flex items-center gap-2",children:[e.jsx(a.AlertTriangle,{className:"w-5 h-5 flex-shrink-0"}),E]}),L&&e.jsxs("div",{className:"p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)] text-[var(--success-text)] flex items-center gap-2",children:[e.jsx(a.CheckCircle,{className:"w-5 h-5 flex-shrink-0"}),L]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:I.map(A=>e.jsxs("button",{onClick:()=>n(A.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${d===A.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[A.icon,e.jsx("span",{className:"hidden sm:inline",children:A.label}),A.id==="steps"&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-xs ${d===A.id?"bg-white/20":"bg-[var(--bg-tertiary)]"}`,children:i.steps.length})]},A.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[d==="info"&&e.jsxs("form",{onSubmit:B,className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.code")}),e.jsx("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-secondary)] font-mono text-sm cursor-not-allowed",children:i.code}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("workflows.edit.codeReadOnly")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:[t("workflows.form.name")," *"]}),e.jsx("input",{type:"text",required:!0,value:f.name,onChange:A=>c(b=>({...b,name:A.target.value})),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.description")}),e.jsx("textarea",{value:f.description,onChange:A=>c(b=>({...b,description:A.target.value})),rows:3,placeholder:t("workflows.form.descriptionPlaceholder"),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.trigger")}),e.jsxs("div",{className:"px-4 py-2 rounded-[var(--radius-input)] bg-[var(--bg-tertiary)] text-[var(--text-primary)]",children:[e.jsx("div",{className:"font-medium",children:i.triggerName}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] font-mono",children:i.triggerCode})]}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("workflows.edit.triggerReadOnly")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)] mb-1",children:t("workflows.form.priority")}),e.jsx("input",{type:"number",min:0,max:100,value:f.priority,onChange:A=>c(b=>({...b,priority:parseInt(A.target.value)||0})),className:"w-full px-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"}),e.jsx("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:t("workflows.form.priorityHelp")})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx("button",{type:"button",onClick:()=>x(`/administration/workflows/${s}`),className:"px-4 py-2 rounded-[var(--radius-button)] border border-[var(--border-color)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:k,className:"flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] hover:bg-[var(--color-accent-700)] text-white font-medium transition-colors disabled:opacity-50",children:[k?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]}),d==="steps"&&s&&e.jsx(We,{workflowId:s,steps:i.steps,onStepsChange:T})]})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[var(--text-secondary)]",children:t("workflows.detail.notFound")}),e.jsx("button",{onClick:()=>x("/administration/workflows/list"),className:"mt-4 px-4 py-2 rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white",children:t("workflows.backToList")})]})}function Oe(){const{t}=J.useTranslation("communications");return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w.Breadcrumb,{items:[{label:t("header.title"),href:"/administration"},{label:t("workflows.title"),href:"/administration/workflows"},{label:t("dashboard.title","History")}]}),e.jsx(w.UnderDevelopment,{title:t("dashboard.title"),description:t("dashboard.underDevelopment","Le tableau de bord des workflows sera disponible prochainement. Il affichera les statistiques d'exécution, les graphiques de performance et l'historique des workflows."),icon:e.jsx(a.History,{className:"w-10 h-10 text-amber-600"}),showBackButton:!0,backUrl:"/administration/workflows"})]})}exports.EmailTemplateCreatePage=he;exports.EmailTemplateDetailPage=fe;exports.EmailTemplateEditPage=Se;exports.EmailTemplatesListPage=ve;exports.SmsTemplatesListPage=Ae;exports.WorkflowCreatePage=De;exports.WorkflowDetailPage=Me;exports.WorkflowEditPage=qe;exports.WorkflowHistoryPage=Oe;exports.WorkflowsListPage=Pe;exports.WorkflowsTriggersPage=Ee;
104
- //# sourceMappingURL=index-qXfYaEmV.js.map
104
+ //# sourceMappingURL=index-D32ol7lq.js.map