@atlashub/smartstack 3.30.0 → 3.31.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 (272) hide show
  1. package/dist/chunks/{AgentSkillsPage-CVq3qZoe.js → AgentSkillsPage-CDMhqrhE.js} +2 -2
  2. package/dist/chunks/{AgentSkillsPage-CVq3qZoe.js.map → AgentSkillsPage-CDMhqrhE.js.map} +1 -1
  3. package/dist/chunks/{AgentSkillsPage-DJb49NMA.js → AgentSkillsPage-DcvOMm5k.js} +2 -2
  4. package/dist/chunks/{AgentSkillsPage-DJb49NMA.js.map → AgentSkillsPage-DcvOMm5k.js.map} +1 -1
  5. package/dist/chunks/{AgentWorkloadPage-D_nk3gKj.js → AgentWorkloadPage-DYBPNzjQ.js} +2 -2
  6. package/dist/chunks/{AgentWorkloadPage-D_nk3gKj.js.map → AgentWorkloadPage-DYBPNzjQ.js.map} +1 -1
  7. package/dist/chunks/{AgentWorkloadPage-oHEi-sFh.js → AgentWorkloadPage-YpJSDaWc.js} +2 -2
  8. package/dist/chunks/{AgentWorkloadPage-oHEi-sFh.js.map → AgentWorkloadPage-YpJSDaWc.js.map} +1 -1
  9. package/dist/chunks/{ApiCatalogDetailPage-Cr0q2HnB.js → ApiCatalogDetailPage-9r1axtCg.js} +3 -3
  10. package/dist/chunks/{ApiCatalogDetailPage-Cr0q2HnB.js.map → ApiCatalogDetailPage-9r1axtCg.js.map} +1 -1
  11. package/dist/chunks/{ApiCatalogDetailPage-DX8buBkV.js → ApiCatalogDetailPage-TjCQ8_A8.js} +2 -2
  12. package/dist/chunks/{ApiCatalogDetailPage-DX8buBkV.js.map → ApiCatalogDetailPage-TjCQ8_A8.js.map} +1 -1
  13. package/dist/chunks/{ApiCatalogPage-DqboIzZE.js → ApiCatalogPage-COxazTnz.js} +2 -2
  14. package/dist/chunks/{ApiCatalogPage-DqboIzZE.js.map → ApiCatalogPage-COxazTnz.js.map} +1 -1
  15. package/dist/chunks/{ApiCatalogPage-DN7sazvI.js → ApiCatalogPage-QRysH0pT.js} +2 -2
  16. package/dist/chunks/{ApiCatalogPage-DN7sazvI.js.map → ApiCatalogPage-QRysH0pT.js.map} +1 -1
  17. package/dist/chunks/{ApplicationDetailPage-CCNjr64K.js → ApplicationDetailPage-Dbx01Ikm.js} +4 -4
  18. package/dist/chunks/{ApplicationDetailPage-CCNjr64K.js.map → ApplicationDetailPage-Dbx01Ikm.js.map} +1 -1
  19. package/dist/chunks/{ApplicationDetailPage--9YwwS5A.js → ApplicationDetailPage-jSHy3MPz.js} +2 -2
  20. package/dist/chunks/{ApplicationDetailPage--9YwwS5A.js.map → ApplicationDetailPage-jSHy3MPz.js.map} +1 -1
  21. package/dist/chunks/{ApplicationsDashboardPage-Bs-Xgca4.js → ApplicationsDashboardPage-CclKc0wI.js} +3 -3
  22. package/dist/chunks/{ApplicationsDashboardPage-Bs-Xgca4.js.map → ApplicationsDashboardPage-CclKc0wI.js.map} +1 -1
  23. package/dist/chunks/{ApplicationsDashboardPage-BSsHN3Yj.js → ApplicationsDashboardPage-CxWmOc1x.js} +2 -2
  24. package/dist/chunks/{ApplicationsDashboardPage-BSsHN3Yj.js.map → ApplicationsDashboardPage-CxWmOc1x.js.map} +1 -1
  25. package/dist/chunks/{ApplicationsGridPage-s1WEzOXS.js → ApplicationsGridPage-BJXWXwyI.js} +2 -2
  26. package/dist/chunks/{ApplicationsGridPage-s1WEzOXS.js.map → ApplicationsGridPage-BJXWXwyI.js.map} +1 -1
  27. package/dist/chunks/{ApplicationsGridPage-DDysNWJ5.js → ApplicationsGridPage-D2l8cM3o.js} +2 -2
  28. package/dist/chunks/{ApplicationsGridPage-DDysNWJ5.js.map → ApplicationsGridPage-D2l8cM3o.js.map} +1 -1
  29. package/dist/chunks/{ApplicationsListPage-B3CSMiV0.js → ApplicationsListPage-CMosl3my.js} +2 -2
  30. package/dist/chunks/{ApplicationsListPage-B3CSMiV0.js.map → ApplicationsListPage-CMosl3my.js.map} +1 -1
  31. package/dist/chunks/{ApplicationsListPage-B6ZCecIl.js → ApplicationsListPage-Dc6NGQ61.js} +2 -2
  32. package/dist/chunks/{ApplicationsListPage-B6ZCecIl.js.map → ApplicationsListPage-Dc6NGQ61.js.map} +1 -1
  33. package/dist/chunks/{ApplicationsPage-BBaiBM--.js → ApplicationsPage-DH7tpMlF.js} +2 -2
  34. package/dist/chunks/{ApplicationsPage-BBaiBM--.js.map → ApplicationsPage-DH7tpMlF.js.map} +1 -1
  35. package/dist/chunks/{ApplicationsPage-ztPwoAGt.js → ApplicationsPage-DI-iMqoJ.js} +4 -4
  36. package/dist/chunks/{ApplicationsPage-ztPwoAGt.js.map → ApplicationsPage-DI-iMqoJ.js.map} +1 -1
  37. package/dist/chunks/{AssignmentRulesPage-DFSVFFXr.js → AssignmentRulesPage-B5UbujbZ.js} +2 -2
  38. package/dist/chunks/{AssignmentRulesPage-DFSVFFXr.js.map → AssignmentRulesPage-B5UbujbZ.js.map} +1 -1
  39. package/dist/chunks/{AssignmentRulesPage-CK4L4rBO.js → AssignmentRulesPage-E79QBSLb.js} +2 -2
  40. package/dist/chunks/{AssignmentRulesPage-CK4L4rBO.js.map → AssignmentRulesPage-E79QBSLb.js.map} +1 -1
  41. package/dist/chunks/{AssignmentsPage-JCLpyg94.js → AssignmentsPage-CDFaL1gT.js} +2 -2
  42. package/dist/chunks/{AssignmentsPage-JCLpyg94.js.map → AssignmentsPage-CDFaL1gT.js.map} +1 -1
  43. package/dist/chunks/{AssignmentsPage-Bp7oQD7Q.js → AssignmentsPage-CPeKJjyK.js} +2 -2
  44. package/dist/chunks/{AssignmentsPage-Bp7oQD7Q.js.map → AssignmentsPage-CPeKJjyK.js.map} +1 -1
  45. package/dist/chunks/{AuthCallbackPage-Bl9xlJ3h.js → AuthCallbackPage-BZ3Ocos5.js} +2 -2
  46. package/dist/chunks/{AuthCallbackPage-Bl9xlJ3h.js.map → AuthCallbackPage-BZ3Ocos5.js.map} +1 -1
  47. package/dist/chunks/{AuthCallbackPage-CzMHz4jy.js → AuthCallbackPage-Bml48QpH.js} +2 -2
  48. package/dist/chunks/{AuthCallbackPage-CzMHz4jy.js.map → AuthCallbackPage-Bml48QpH.js.map} +1 -1
  49. package/dist/chunks/{ConfirmEmailPage-M7mJgXvn.js → ConfirmEmailPage-DP1XPaKK.js} +2 -2
  50. package/dist/chunks/{ConfirmEmailPage-M7mJgXvn.js.map → ConfirmEmailPage-DP1XPaKK.js.map} +1 -1
  51. package/dist/chunks/{ConfirmEmailPage-D_8T1vqV.js → ConfirmEmailPage-DyzslZ06.js} +2 -2
  52. package/dist/chunks/{ConfirmEmailPage-D_8T1vqV.js.map → ConfirmEmailPage-DyzslZ06.js.map} +1 -1
  53. package/dist/chunks/{CreateSupportTicketPage-BNEGavlu.js → CreateSupportTicketPage-Bz2KrMik.js} +2 -2
  54. package/dist/chunks/{CreateSupportTicketPage-BNEGavlu.js.map → CreateSupportTicketPage-Bz2KrMik.js.map} +1 -1
  55. package/dist/chunks/{CreateSupportTicketPage-C2X2mfds.js → CreateSupportTicketPage-hKjKM0Bh.js} +2 -2
  56. package/dist/chunks/{CreateSupportTicketPage-C2X2mfds.js.map → CreateSupportTicketPage-hKjKM0Bh.js.map} +1 -1
  57. package/dist/chunks/{DashboardPage-4oy2YqvT.js → DashboardPage-B4nAd8Tj.js} +2 -2
  58. package/dist/chunks/{DashboardPage-4oy2YqvT.js.map → DashboardPage-B4nAd8Tj.js.map} +1 -1
  59. package/dist/chunks/{DashboardPage-D5MRMxEV.js → DashboardPage-C9qgPBS-.js} +3 -3
  60. package/dist/chunks/{DashboardPage-D5MRMxEV.js.map → DashboardPage-C9qgPBS-.js.map} +1 -1
  61. package/dist/chunks/{DashboardPage-CO-8B8EI.js → DashboardPage-CjbNGMo1.js} +3 -3
  62. package/dist/chunks/{DashboardPage-CO-8B8EI.js.map → DashboardPage-CjbNGMo1.js.map} +1 -1
  63. package/dist/chunks/{DashboardPage-CPArUG-S.js → DashboardPage-rN7IFlTR.js} +2 -2
  64. package/dist/chunks/{DashboardPage-CPArUG-S.js.map → DashboardPage-rN7IFlTR.js.map} +1 -1
  65. package/dist/chunks/{EscalationConfigPage-DnjLFXnL.js → EscalationConfigPage-CGv2L62M.js} +2 -2
  66. package/dist/chunks/{EscalationConfigPage-DnjLFXnL.js.map → EscalationConfigPage-CGv2L62M.js.map} +1 -1
  67. package/dist/chunks/{EscalationConfigPage-CwdnfJbJ.js → EscalationConfigPage-DpYDmsgw.js} +2 -2
  68. package/dist/chunks/{EscalationConfigPage-CwdnfJbJ.js.map → EscalationConfigPage-DpYDmsgw.js.map} +1 -1
  69. package/dist/chunks/{ForceChangePasswordPage-ZEIfyqwE.js → ForceChangePasswordPage-CLI_fpF4.js} +2 -2
  70. package/dist/chunks/{ForceChangePasswordPage-ZEIfyqwE.js.map → ForceChangePasswordPage-CLI_fpF4.js.map} +1 -1
  71. package/dist/chunks/{ForceChangePasswordPage-sh-3h_H9.js → ForceChangePasswordPage-Db6sOrZN.js} +2 -2
  72. package/dist/chunks/{ForceChangePasswordPage-sh-3h_H9.js.map → ForceChangePasswordPage-Db6sOrZN.js.map} +1 -1
  73. package/dist/chunks/{ForgotPasswordPage-B4M6-xeM.js → ForgotPasswordPage-BhMz2B6A.js} +2 -2
  74. package/dist/chunks/{ForgotPasswordPage-B4M6-xeM.js.map → ForgotPasswordPage-BhMz2B6A.js.map} +1 -1
  75. package/dist/chunks/{ForgotPasswordPage-MIu-U7p0.js → ForgotPasswordPage-D06arMXO.js} +2 -2
  76. package/dist/chunks/{ForgotPasswordPage-MIu-U7p0.js.map → ForgotPasswordPage-D06arMXO.js.map} +1 -1
  77. package/dist/chunks/{GroupDetailPage-4XK3Bs_r.js → GroupDetailPage-BCM8KBCd.js} +5 -5
  78. package/dist/chunks/{GroupDetailPage-4XK3Bs_r.js.map → GroupDetailPage-BCM8KBCd.js.map} +1 -1
  79. package/dist/chunks/{GroupDetailPage-C-kvtd2T.js → GroupDetailPage-CGMV3bWt.js} +2 -2
  80. package/dist/chunks/{GroupDetailPage-C-kvtd2T.js.map → GroupDetailPage-CGMV3bWt.js.map} +1 -1
  81. package/dist/chunks/{MyAccessRequestsPage-CP41FzHi.js → MyAccessRequestsPage-BBrwEomx.js} +2 -2
  82. package/dist/chunks/{MyAccessRequestsPage-CP41FzHi.js.map → MyAccessRequestsPage-BBrwEomx.js.map} +1 -1
  83. package/dist/chunks/{MyAccessRequestsPage-DzrXTrVi.js → MyAccessRequestsPage-CrlWe3gd.js} +2 -2
  84. package/dist/chunks/{MyAccessRequestsPage-DzrXTrVi.js.map → MyAccessRequestsPage-CrlWe3gd.js.map} +1 -1
  85. package/dist/chunks/{MyTenantsPage-V_SwYio2.js → MyTenantsPage-BOV34_rJ.js} +3 -3
  86. package/dist/chunks/{MyTenantsPage-V_SwYio2.js.map → MyTenantsPage-BOV34_rJ.js.map} +1 -1
  87. package/dist/chunks/{MyTenantsPage-CZRkMbh8.js → MyTenantsPage-CK4-klmd.js} +2 -2
  88. package/dist/chunks/{MyTenantsPage-CZRkMbh8.js.map → MyTenantsPage-CK4-klmd.js.map} +1 -1
  89. package/dist/chunks/{MyTicketsPage-DnvAIeyr.js → MyTicketsPage-CFZ1G4dG.js} +2 -2
  90. package/dist/chunks/{MyTicketsPage-DnvAIeyr.js.map → MyTicketsPage-CFZ1G4dG.js.map} +1 -1
  91. package/dist/chunks/{MyTicketsPage-DOUhaLal.js → MyTicketsPage-DuhpwhZx.js} +2 -2
  92. package/dist/chunks/{MyTicketsPage-DOUhaLal.js.map → MyTicketsPage-DuhpwhZx.js.map} +1 -1
  93. package/dist/chunks/{NavigationAppsPage-DfTa4jCG.js → NavigationAppsPage-BnNQRfBP.js} +2 -2
  94. package/dist/chunks/{NavigationAppsPage-DfTa4jCG.js.map → NavigationAppsPage-BnNQRfBP.js.map} +1 -1
  95. package/dist/chunks/{NavigationAppsPage-DXvpLsbt.js → NavigationAppsPage-DdJxEoTZ.js} +2 -2
  96. package/dist/chunks/{NavigationAppsPage-DXvpLsbt.js.map → NavigationAppsPage-DdJxEoTZ.js.map} +1 -1
  97. package/dist/chunks/{NotificationsPage-I1yCk7tk.js → NotificationsPage-BllOlagk.js} +2 -2
  98. package/dist/chunks/{NotificationsPage-I1yCk7tk.js.map → NotificationsPage-BllOlagk.js.map} +1 -1
  99. package/dist/chunks/{NotificationsPage-D76MdAs-.js → NotificationsPage-D1T_ozHl.js} +2 -2
  100. package/dist/chunks/{NotificationsPage-D76MdAs-.js.map → NotificationsPage-D1T_ozHl.js.map} +1 -1
  101. package/dist/chunks/{OnboardingWizardPage-BRUzcl1A.js → OnboardingWizardPage-CioLaCYz.js} +2 -2
  102. package/dist/chunks/{OnboardingWizardPage-BRUzcl1A.js.map → OnboardingWizardPage-CioLaCYz.js.map} +1 -1
  103. package/dist/chunks/{OnboardingWizardPage-DtWUPCh3.js → OnboardingWizardPage-CrAQt7qL.js} +2 -2
  104. package/dist/chunks/{OnboardingWizardPage-DtWUPCh3.js.map → OnboardingWizardPage-CrAQt7qL.js.map} +1 -1
  105. package/dist/chunks/{PermissionDetailPage-CUNKbl7t.js → PermissionDetailPage-BIG78-1-.js} +2 -2
  106. package/dist/chunks/{PermissionDetailPage-CUNKbl7t.js.map → PermissionDetailPage-BIG78-1-.js.map} +1 -1
  107. package/dist/chunks/{PermissionDetailPage-DJJGbXoX.js → PermissionDetailPage-CvPqugYu.js} +2 -2
  108. package/dist/chunks/{PermissionDetailPage-DJJGbXoX.js.map → PermissionDetailPage-CvPqugYu.js.map} +1 -1
  109. package/dist/chunks/{PermissionsPage-B8wmawPV.js → PermissionsPage-CDSuc8vw.js} +2 -2
  110. package/dist/chunks/{PermissionsPage-B8wmawPV.js.map → PermissionsPage-CDSuc8vw.js.map} +1 -1
  111. package/dist/chunks/{PermissionsPage-Dbjcctuh.js → PermissionsPage-XaOrGrPZ.js} +2 -2
  112. package/dist/chunks/{PermissionsPage-Dbjcctuh.js.map → PermissionsPage-XaOrGrPZ.js.map} +1 -1
  113. package/dist/chunks/{PortalDashboardPage-BeNfBZmb.js → PortalDashboardPage-BsWVXkMe.js} +2 -2
  114. package/dist/chunks/{PortalDashboardPage-BeNfBZmb.js.map → PortalDashboardPage-BsWVXkMe.js.map} +1 -1
  115. package/dist/chunks/{PortalDashboardPage-zii0ll57.js → PortalDashboardPage-oSD7oQhJ.js} +2 -2
  116. package/dist/chunks/{PortalDashboardPage-zii0ll57.js.map → PortalDashboardPage-oSD7oQhJ.js.map} +1 -1
  117. package/dist/chunks/{PreferencesPage-BCpuIGzv.js → PreferencesPage-DD0_XWdT.js} +2 -2
  118. package/dist/chunks/{PreferencesPage-BCpuIGzv.js.map → PreferencesPage-DD0_XWdT.js.map} +1 -1
  119. package/dist/chunks/{PreferencesPage-BmvrBaAD.js → PreferencesPage-ca2BOdoH.js} +2 -2
  120. package/dist/chunks/{PreferencesPage-BmvrBaAD.js.map → PreferencesPage-ca2BOdoH.js.map} +1 -1
  121. package/dist/chunks/{ProfilePage-mf5wI0-n.js → ProfilePage-Bex_JN5N.js} +2 -2
  122. package/dist/chunks/{ProfilePage-mf5wI0-n.js.map → ProfilePage-Bex_JN5N.js.map} +1 -1
  123. package/dist/chunks/{ProfilePage-eowQd59_.js → ProfilePage-C8tUIOnb.js} +2 -2
  124. package/dist/chunks/{ProfilePage-eowQd59_.js.map → ProfilePage-C8tUIOnb.js.map} +1 -1
  125. package/dist/chunks/{ReferencesManagementPage-CLsaUNqA.js → ReferencesManagementPage-B-FXS2ln.js} +2 -2
  126. package/dist/chunks/{ReferencesManagementPage-CLsaUNqA.js.map → ReferencesManagementPage-B-FXS2ln.js.map} +1 -1
  127. package/dist/chunks/{ReferencesManagementPage-8UPgkVE8.js → ReferencesManagementPage-C8KZprkI.js} +3 -3
  128. package/dist/chunks/{ReferencesManagementPage-8UPgkVE8.js.map → ReferencesManagementPage-C8KZprkI.js.map} +1 -1
  129. package/dist/chunks/{RegisterPage-CNyHSbqs.js → RegisterPage-BYt__zKJ.js} +2 -2
  130. package/dist/chunks/{RegisterPage-CNyHSbqs.js.map → RegisterPage-BYt__zKJ.js.map} +1 -1
  131. package/dist/chunks/{RegisterPage-57X-ILDb.js → RegisterPage-MWcVu-LY.js} +2 -2
  132. package/dist/chunks/{RegisterPage-57X-ILDb.js.map → RegisterPage-MWcVu-LY.js.map} +1 -1
  133. package/dist/chunks/{ResetPasswordPage-CyV8l-Zo.js → ResetPasswordPage-DaJiMj5Z.js} +2 -2
  134. package/dist/chunks/{ResetPasswordPage-CyV8l-Zo.js.map → ResetPasswordPage-DaJiMj5Z.js.map} +1 -1
  135. package/dist/chunks/{ResetPasswordPage-JW8-mh_k.js → ResetPasswordPage-rCLUIj_T.js} +2 -2
  136. package/dist/chunks/{ResetPasswordPage-JW8-mh_k.js.map → ResetPasswordPage-rCLUIj_T.js.map} +1 -1
  137. package/dist/chunks/{ResolutionModal-CjwE73NX.js → ResolutionModal-DeuPnLWg.js} +2 -2
  138. package/dist/chunks/{ResolutionModal-CjwE73NX.js.map → ResolutionModal-DeuPnLWg.js.map} +1 -1
  139. package/dist/chunks/{ResolutionModal-wddG59kg.js → ResolutionModal-j7Rp6apG.js} +2 -2
  140. package/dist/chunks/{ResolutionModal-wddG59kg.js.map → ResolutionModal-j7Rp6apG.js.map} +1 -1
  141. package/dist/chunks/{RoleDetailPage-CrioVHFI.js → RoleDetailPage-CLtZWX17.js} +3 -3
  142. package/dist/chunks/{RoleDetailPage-CrioVHFI.js.map → RoleDetailPage-CLtZWX17.js.map} +1 -1
  143. package/dist/chunks/{RoleDetailPage-TUOGR1ow.js → RoleDetailPage-TGyGmLMM.js} +2 -2
  144. package/dist/chunks/{RoleDetailPage-TUOGR1ow.js.map → RoleDetailPage-TGyGmLMM.js.map} +1 -1
  145. package/dist/chunks/{RolesPage-sJBWaNff.js → RolesPage-C0c5G9e7.js} +2 -2
  146. package/dist/chunks/{RolesPage-sJBWaNff.js.map → RolesPage-C0c5G9e7.js.map} +1 -1
  147. package/dist/chunks/{RolesPage-CAcols3D.js → RolesPage-Dm03fBBf.js} +2 -2
  148. package/dist/chunks/{RolesPage-CAcols3D.js.map → RolesPage-Dm03fBBf.js.map} +1 -1
  149. package/dist/chunks/{SlaConfigPage-BPGRloOS.js → SlaConfigPage-B4WDzEKi.js} +2 -2
  150. package/dist/chunks/{SlaConfigPage-BPGRloOS.js.map → SlaConfigPage-B4WDzEKi.js.map} +1 -1
  151. package/dist/chunks/{SlaConfigPage-D5TRn7Ir.js → SlaConfigPage-Cwo9NwxH.js} +2 -2
  152. package/dist/chunks/{SlaConfigPage-D5TRn7Ir.js.map → SlaConfigPage-Cwo9NwxH.js.map} +1 -1
  153. package/dist/chunks/{SupportPermissionsPage-UXmYLrIq.js → SupportPermissionsPage-CL12dFy-.js} +2 -2
  154. package/dist/chunks/{SupportPermissionsPage-UXmYLrIq.js.map → SupportPermissionsPage-CL12dFy-.js.map} +1 -1
  155. package/dist/chunks/{SupportPermissionsPage-Dc2bWTzG.js → SupportPermissionsPage-CneIhl30.js} +2 -2
  156. package/dist/chunks/{SupportPermissionsPage-Dc2bWTzG.js.map → SupportPermissionsPage-CneIhl30.js.map} +1 -1
  157. package/dist/chunks/{TemplatesPage-nTY85sNA.js → TemplatesPage-DStKmwHT.js} +2 -2
  158. package/dist/chunks/{TemplatesPage-nTY85sNA.js.map → TemplatesPage-DStKmwHT.js.map} +1 -1
  159. package/dist/chunks/{TemplatesPage-dmPlqqiD.js → TemplatesPage-X4Rrhs9p.js} +2 -2
  160. package/dist/chunks/{TemplatesPage-dmPlqqiD.js.map → TemplatesPage-X4Rrhs9p.js.map} +1 -1
  161. package/dist/chunks/{TenantCard-BhT-31ls.js → TenantCard-BUBYWtvR.js} +2 -2
  162. package/dist/chunks/{TenantCard-BhT-31ls.js.map → TenantCard-BUBYWtvR.js.map} +1 -1
  163. package/dist/chunks/{TenantCard-BUXfstRZ.js → TenantCard-CAgiB-NG.js} +2 -2
  164. package/dist/chunks/{TenantCard-BUXfstRZ.js.map → TenantCard-CAgiB-NG.js.map} +1 -1
  165. package/dist/chunks/{TenantScopeSelector-3_mzBLNI.js → TenantScopeSelector-B9vtpIZx.js} +2 -2
  166. package/dist/chunks/{TenantScopeSelector-3_mzBLNI.js.map → TenantScopeSelector-B9vtpIZx.js.map} +1 -1
  167. package/dist/chunks/{TenantScopeSelector-B-SRDR2R.js → TenantScopeSelector-BAoah-mL.js} +2 -2
  168. package/dist/chunks/{TenantScopeSelector-B-SRDR2R.js.map → TenantScopeSelector-BAoah-mL.js.map} +1 -1
  169. package/dist/chunks/{TicketDetailPage-xN3wPnFL.js → TicketDetailPage-BFcP4X8s.js} +2 -2
  170. package/dist/chunks/{TicketDetailPage-xN3wPnFL.js.map → TicketDetailPage-BFcP4X8s.js.map} +1 -1
  171. package/dist/chunks/{TicketDetailPage-B4cR3rOC.js → TicketDetailPage-D_Npnt4A.js} +2 -2
  172. package/dist/chunks/{TicketDetailPage-B4cR3rOC.js.map → TicketDetailPage-D_Npnt4A.js.map} +1 -1
  173. package/dist/chunks/{TicketsPage-Dwi2xpMI.js → TicketsPage-DBP9kalU.js} +2 -2
  174. package/dist/chunks/{TicketsPage-Dwi2xpMI.js.map → TicketsPage-DBP9kalU.js.map} +1 -1
  175. package/dist/chunks/{TicketsPage-CkHgXSxU.js → TicketsPage-p21DLhUb.js} +2 -2
  176. package/dist/chunks/{TicketsPage-CkHgXSxU.js.map → TicketsPage-p21DLhUb.js.map} +1 -1
  177. package/dist/chunks/{UserCreateTicketPage-D2a3EOey.js → UserCreateTicketPage-DOwShnG8.js} +2 -2
  178. package/dist/chunks/{UserCreateTicketPage-D2a3EOey.js.map → UserCreateTicketPage-DOwShnG8.js.map} +1 -1
  179. package/dist/chunks/{UserCreateTicketPage-bcbSLglE.js → UserCreateTicketPage-lvlvp2u6.js} +2 -2
  180. package/dist/chunks/{UserCreateTicketPage-bcbSLglE.js.map → UserCreateTicketPage-lvlvp2u6.js.map} +1 -1
  181. package/dist/chunks/{UserDashboardPage-ZMsx8LWw.js → UserDashboardPage-C_tm7Pld.js} +2 -2
  182. package/dist/chunks/{UserDashboardPage-ZMsx8LWw.js.map → UserDashboardPage-C_tm7Pld.js.map} +1 -1
  183. package/dist/chunks/{UserDashboardPage-DwnDRNoW.js → UserDashboardPage-Dp6q6FEW.js} +2 -2
  184. package/dist/chunks/{UserDashboardPage-DwnDRNoW.js.map → UserDashboardPage-Dp6q6FEW.js.map} +1 -1
  185. package/dist/chunks/{UserDetailPage-CZyV-zsg.js → UserDetailPage-6grZ6gmV.js} +5 -5
  186. package/dist/chunks/{UserDetailPage-CZyV-zsg.js.map → UserDetailPage-6grZ6gmV.js.map} +1 -1
  187. package/dist/chunks/{UserDetailPage-BRFowOFL.js → UserDetailPage-DXLxO7LF.js} +2 -2
  188. package/dist/chunks/{UserDetailPage-BRFowOFL.js.map → UserDetailPage-DXLxO7LF.js.map} +1 -1
  189. package/dist/chunks/{UserTicketDetailPage-BstGk_BP.js → UserTicketDetailPage-Ch9IfCPo.js} +2 -2
  190. package/dist/chunks/{UserTicketDetailPage-BstGk_BP.js.map → UserTicketDetailPage-Ch9IfCPo.js.map} +1 -1
  191. package/dist/chunks/{UserTicketDetailPage-DzB_pELt.js → UserTicketDetailPage-a4II5VEE.js} +2 -2
  192. package/dist/chunks/{UserTicketDetailPage-DzB_pELt.js.map → UserTicketDetailPage-a4II5VEE.js.map} +1 -1
  193. package/dist/chunks/{UsersGroupsPage-BygTv_kK.js → UsersGroupsPage-B7Er0V4l.js} +3 -3
  194. package/dist/chunks/{UsersGroupsPage-BygTv_kK.js.map → UsersGroupsPage-B7Er0V4l.js.map} +1 -1
  195. package/dist/chunks/{UsersGroupsPage-DTmhzttW.js → UsersGroupsPage-BeAv4QfV.js} +2 -2
  196. package/dist/chunks/{UsersGroupsPage-DTmhzttW.js.map → UsersGroupsPage-BeAv4QfV.js.map} +1 -1
  197. package/dist/chunks/{UsersPage-DcwLyMAX.js → UsersPage-0M1FLqOe.js} +2 -2
  198. package/dist/chunks/{UsersPage-DcwLyMAX.js.map → UsersPage-0M1FLqOe.js.map} +1 -1
  199. package/dist/chunks/{UsersPage-TIqSHgHj.js → UsersPage-ZR9r9vvf.js} +2 -2
  200. package/dist/chunks/{UsersPage-TIqSHgHj.js.map → UsersPage-ZR9r9vvf.js.map} +1 -1
  201. package/dist/chunks/{accessRequestsApi-3FjMFbpa.js → accessRequestsApi-BJH8EE1K.js} +2 -2
  202. package/dist/chunks/{accessRequestsApi-3FjMFbpa.js.map → accessRequestsApi-BJH8EE1K.js.map} +1 -1
  203. package/dist/chunks/{accessRequestsApi-B6dsJzvH.js → accessRequestsApi-CBpF5d54.js} +2 -2
  204. package/dist/chunks/{accessRequestsApi-B6dsJzvH.js.map → accessRequestsApi-CBpF5d54.js.map} +1 -1
  205. package/dist/chunks/{aiApi-9G4wG_mT.js → aiApi-CkkWAvNB.js} +2 -2
  206. package/dist/chunks/{aiApi-9G4wG_mT.js.map → aiApi-CkkWAvNB.js.map} +1 -1
  207. package/dist/chunks/{aiApi-DXOdsoxr.js → aiApi-Dl7a2lWz.js} +2 -2
  208. package/dist/chunks/{aiApi-DXOdsoxr.js.map → aiApi-Dl7a2lWz.js.map} +1 -1
  209. package/dist/chunks/{applicationAnalyticsApi-DhOd6idI.js → applicationAnalyticsApi-BwcSE_H1.js} +2 -2
  210. package/dist/chunks/{applicationAnalyticsApi-DhOd6idI.js.map → applicationAnalyticsApi-BwcSE_H1.js.map} +1 -1
  211. package/dist/chunks/{applicationAnalyticsApi-D0DEp9Y-.js → applicationAnalyticsApi-DKMmDvWk.js} +2 -2
  212. package/dist/chunks/{applicationAnalyticsApi-D0DEp9Y-.js.map → applicationAnalyticsApi-DKMmDvWk.js.map} +1 -1
  213. package/dist/chunks/{groupsApi-Db8G2lLs.js → groupsApi-BzDV3_Jc.js} +2 -2
  214. package/dist/chunks/{groupsApi-Db8G2lLs.js.map → groupsApi-BzDV3_Jc.js.map} +1 -1
  215. package/dist/chunks/{groupsApi-lbxNsHFv.js → groupsApi-CQ4vFMdP.js} +2 -2
  216. package/dist/chunks/{groupsApi-lbxNsHFv.js.map → groupsApi-CQ4vFMdP.js.map} +1 -1
  217. package/dist/chunks/{index-DEtq-xUL.js → index-BBmMbSZV.js} +8 -8
  218. package/dist/chunks/{index-DEtq-xUL.js.map → index-BBmMbSZV.js.map} +1 -1
  219. package/dist/chunks/{index-D0HS542b.js → index-BLlESTfA.js} +2 -2
  220. package/dist/chunks/{index-D0HS542b.js.map → index-BLlESTfA.js.map} +1 -1
  221. package/dist/chunks/{index-DUS-tunb.js → index-BPMjxWVx.js} +2 -2
  222. package/dist/chunks/{index-DUS-tunb.js.map → index-BPMjxWVx.js.map} +1 -1
  223. package/dist/chunks/{index-TiWOcC0g.js → index-CEbwdURd.js} +2 -2
  224. package/dist/chunks/{index-TiWOcC0g.js.map → index-CEbwdURd.js.map} +1 -1
  225. package/dist/chunks/{index-DF93KQFR.js → index-CUZygY5Q.js} +2 -2
  226. package/dist/chunks/{index-DF93KQFR.js.map → index-CUZygY5Q.js.map} +1 -1
  227. package/dist/chunks/{index-BI2dc1FS.js → index-Ci1SqFiY.js} +2 -2
  228. package/dist/chunks/{index-BI2dc1FS.js.map → index-Ci1SqFiY.js.map} +1 -1
  229. package/dist/chunks/{index-CTGSmYvs.js → index-Cib93xtp.js} +2 -2
  230. package/dist/chunks/{index-CTGSmYvs.js.map → index-Cib93xtp.js.map} +1 -1
  231. package/dist/chunks/{index-DqbVFB1H.js → index-CoHIgn5H.js} +2 -2
  232. package/dist/chunks/{index-DqbVFB1H.js.map → index-CoHIgn5H.js.map} +1 -1
  233. package/dist/chunks/{index-CN2WRyg1.js → index-CpY95_ro.js} +294 -292
  234. package/dist/chunks/{index-CN2WRyg1.js.map → index-CpY95_ro.js.map} +1 -1
  235. package/dist/chunks/{index-DjC1u2hI.js → index-D-2xSu5W.js} +3 -3
  236. package/dist/chunks/{index-DjC1u2hI.js.map → index-D-2xSu5W.js.map} +1 -1
  237. package/dist/chunks/{index-Bn8HzILk.js → index-D18t9DhC.js} +4 -4
  238. package/dist/chunks/{index-Bn8HzILk.js.map → index-D18t9DhC.js.map} +1 -1
  239. package/dist/chunks/{index-cAikSVW0.js → index-DK5czlkn.js} +9 -9
  240. package/dist/chunks/{index-cAikSVW0.js.map → index-DK5czlkn.js.map} +1 -1
  241. package/dist/chunks/{index-DLekpNSE.js → index-DQd324n7.js} +2 -2
  242. package/dist/chunks/{index-DLekpNSE.js.map → index-DQd324n7.js.map} +1 -1
  243. package/dist/chunks/{index-CgtbaFf5.js → index-Dbq-x5H9.js} +2 -2
  244. package/dist/chunks/{index-CgtbaFf5.js.map → index-Dbq-x5H9.js.map} +1 -1
  245. package/dist/chunks/{index-xhRXN1Jq.js → index-Det9dEaQ.js} +2 -2
  246. package/dist/chunks/{index-xhRXN1Jq.js.map → index-Det9dEaQ.js.map} +1 -1
  247. package/dist/chunks/{index-HsAOBno4.js → index-bgT9XOKZ.js} +2 -2
  248. package/dist/chunks/{index-HsAOBno4.js.map → index-bgT9XOKZ.js.map} +1 -1
  249. package/dist/chunks/{index-CUICSveU.js → index-h7ZrwrQg.js} +2 -2
  250. package/dist/chunks/{index-CUICSveU.js.map → index-h7ZrwrQg.js.map} +1 -1
  251. package/dist/chunks/{index-DwqLhQ8S.js → index-k4USDz2P.js} +2 -2
  252. package/dist/chunks/{index-DwqLhQ8S.js.map → index-k4USDz2P.js.map} +1 -1
  253. package/dist/chunks/{tenantIconMap-CHeS7oLt.js → tenantIconMap-7ihIWxAh.js} +2 -2
  254. package/dist/chunks/{tenantIconMap-CHeS7oLt.js.map → tenantIconMap-7ihIWxAh.js.map} +1 -1
  255. package/dist/chunks/{tenantIconMap-__FKj6CN.js → tenantIconMap-Dk6K-UTE.js} +2 -2
  256. package/dist/chunks/{tenantIconMap-__FKj6CN.js.map → tenantIconMap-Dk6K-UTE.js.map} +1 -1
  257. package/dist/chunks/{ticketingApi-DF4RwD_6.js → ticketingApi-BCMKkzlv.js} +2 -2
  258. package/dist/chunks/{ticketingApi-DF4RwD_6.js.map → ticketingApi-BCMKkzlv.js.map} +1 -1
  259. package/dist/chunks/{ticketingApi-Cj239hYB.js → ticketingApi-Dwn7pl5z.js} +2 -2
  260. package/dist/chunks/{ticketingApi-Cj239hYB.js.map → ticketingApi-Dwn7pl5z.js.map} +1 -1
  261. package/dist/chunks/{useAccessRequests-CFam8zFR.js → useAccessRequests-Du7CvowE.js} +3 -3
  262. package/dist/chunks/{useAccessRequests-CFam8zFR.js.map → useAccessRequests-Du7CvowE.js.map} +1 -1
  263. package/dist/chunks/{useAccessRequests-CViOUwyF.js → useAccessRequests-gJ7yhWyi.js} +2 -2
  264. package/dist/chunks/{useAccessRequests-CViOUwyF.js.map → useAccessRequests-gJ7yhWyi.js.map} +1 -1
  265. package/dist/chunks/{useUserAccessRequests-CslSQeBJ.js → useUserAccessRequests-5wWea2Jg.js} +2 -2
  266. package/dist/chunks/{useUserAccessRequests-CslSQeBJ.js.map → useUserAccessRequests-5wWea2Jg.js.map} +1 -1
  267. package/dist/chunks/{useUserAccessRequests-B-Cs6NX1.js → useUserAccessRequests-Bk_v8egy.js} +2 -2
  268. package/dist/chunks/{useUserAccessRequests-B-Cs6NX1.js.map → useUserAccessRequests-Bk_v8egy.js.map} +1 -1
  269. package/dist/components/routing/ProtectedRoute.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
@@ -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"),O=require("react-i18next"),a=require("lucide-react"),w=require("./index-cAikSVW0.js"),ee=require("@tiptap/react"),se=require("@tiptap/starter-kit"),re=require("@tiptap/extension-link"),ie=require("@tiptap/extension-image"),le=require("@tiptap/extension-placeholder"),ne=require("@tiptap/extension-text-align"),oe=require("@tiptap/extension-underline"),ce=require("@tiptap/extension-text-style"),de=require("@tiptap/extension-color"),me=require("@tiptap/extension-highlight"),xe=require("@monaco-editor/react"),B={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,p)=>w.api.put(`/api/administration/workflows/email-templates/${t}/translations/${s}`,p)},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,p)=>w.api.put(`/api/administration/workflows/definitions/${t}/steps/${s}`,p),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 pe(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),{currentTenant:p,isGlobalView:i}=w.useTenant(),[r,g]=l.useState([]),[u,k]=l.useState(!0),[v,m]=l.useState(""),[n,D]=l.useState("table"),[F,A]=l.useState(1),h=20,f=l.useCallback(async()=>{try{k(!0);const x=await B.emailTemplates.getAll({search:v||void 0});g(Array.isArray(x)?x:[])}catch(x){console.error("Failed to load templates:",x)}finally{k(!1)}},[v,p?.id,i]);l.useEffect(()=>{f()},[f]);const d=x=>{x.preventDefault(),A(1),f()},C=async(x,V)=>{if(V?.stopPropagation(),x.isSystem){alert(t("emailTemplates.cannotDeleteSystem"));return}if(confirm(t("emailTemplates.confirmDelete",{name:x.name})))try{await B.emailTemplates.delete(x.id),f()}catch(K){console.error("Failed to delete template:",K)}},_=(F-1)*h,T=r.slice(_,_+h),M=Math.ceil(r.length/h),P={transactional:r.filter(x=>x.category==="transactional"),notification:r.filter(x=>x.category==="notification"),marketing:r.filter(x=>x.category==="marketing"),system:r.filter(x=>x.category==="system")},b=x=>t(`emailTemplates.categories.${x.toLowerCase()}`)||x,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(x=>e.jsxs("tr",{className:"group hover:bg-[var(--bg-hover)] transition-all cursor-pointer",onClick:()=>s(`/administration/workflows/email-templates/${x.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:x.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:x.name}),x.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(x.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:x.languages.length})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(w.StatusBadge,{status:x.isActive?"active":"inactive",label:x.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/${x.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/${x.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"})}),!x.isSystem&&e.jsx("button",{onClick:V=>C(x,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"})})]})})]},x.id))]})]})}),$=()=>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(x=>e.jsx(w.TemplateCard,{name:x.name,code:x.code,category:b(x.category),isActive:x.isActive,isSystem:x.isSystem,icon:a.Mail,iconColor:"var(--color-accent-500)",translationsCount:x.languages.length,onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),onEdit:()=>s(`/administration/workflows/email-templates/${x.id}/edit`),onDelete:()=>C(x),labels:{activeLabel:t("emailTemplates.active"),inactiveLabel:t("emailTemplates.inactive"),systemLabel:"System",editLabel:t("emailTemplates.edit.title"),deleteLabel:t("emailTemplates.delete")}},x.id)),W=()=>e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:$()}),L=x=>x==="transactional"?"bg-[var(--success-dot)]":x==="notification"?"bg-[var(--warning-dot)]":x==="marketing"?"bg-blue-500":"bg-[var(--text-muted)]",o=x=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/email-templates/${x.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:x.name}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:x.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 ${x.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 ${x.isActive?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),x.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:x.languages.length})]})]})})]},x.id),E=()=>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(P).map(([x,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 ${L(x)}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:b(x)}),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(o),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")})]})]})]},x))})});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:d,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:x=>m(x.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:D,tableLabel:"Table",cardsLabel:"Cards",kanbanLabel:"Kanban"})]})}),n==="table"&&S(),n==="cards"&&W(),n==="kanban"&&E(),n!=="kanban"&&r.length>0&&e.jsx(w.Pagination,{page:F,totalPages:M,totalCount:r.length,pageSize:h,onPageChange:A,itemLabel:"templates"})]})}function ue(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),[p,i]=l.useState(!1),[r,g]=l.useState(null),[u,k]=l.useState({code:"",name:"",description:"",category:"transactional"}),v=async m=>{m.preventDefault(),i(!0),g(null);try{const n=await B.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 D=n instanceof Error?n.message:"An error occurred while creating the template";g(D)}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:m=>k(n=>({...n,code:m.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:m=>k(n=>({...n,name:m.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:m=>k(n=>({...n,description:m.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:m=>k(n=>({...n,category:m.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:p,className:"btn btn-primary disabled:opacity-50",children:[p?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]})]})}const ve=[{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"}],he=[{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 be(){const{t,i18n:s}=O.useTranslation("communications"),{id:p}=U.useParams(),i=U.useNavigate(),[r,g]=l.useState(null),[u,k]=l.useState(!0),[v,m]=U.useSearchParams(),n=v.get("tab")||"preview",D=y=>m({tab:y}),[F,A]=l.useState(null),[h,f]=l.useState(null),[d,C]=l.useState(!1),[_,T]=l.useState(!1),[M,P]=l.useState(null),[b,S]=l.useState(null),[$,W]=l.useState(!1),[L,o]=l.useState(""),E=l.useCallback(async()=>{if(p)try{k(!0),A(null);const y=await B.emailTemplates.getById(p);g(y)}catch(y){console.error("Failed to load template:",y),A(t("emailTemplates.detail.errors.loadFailed"))}finally{k(!1)}},[p,t]);l.useEffect(()=>{E()},[E]);const x=async()=>{if(!(!p||!r))try{C(!0),A(null),await B.emailTemplates.update(p,{name:r.name,description:r.description||void 0,category:r.category,isActive:!0}),f(t("emailTemplates.detail.success.activated")),E()}catch(y){console.error("Failed to activate template:",y),A(t("emailTemplates.detail.errors.activateFailed"))}finally{C(!1)}},V=async()=>{if(!(!p||!r))try{C(!0),A(null),await B.emailTemplates.update(p,{name:r.name,description:r.description||void 0,category:r.category,isActive:!1}),f(t("emailTemplates.detail.success.deactivated")),E()}catch(y){console.error("Failed to deactivate template:",y),A(t("emailTemplates.detail.errors.deactivateFailed"))}finally{C(!1)}},K=async()=>{if(!(!p||!r)){if(r.isSystem){A(t("emailTemplates.cannotDeleteSystem"));return}try{C(!0),A(null),await B.emailTemplates.delete(p),i("/administration/workflows/email-templates")}catch(y){console.error("Failed to delete template:",y),A(t("emailTemplates.detail.errors.deleteFailed")),T(!1)}finally{C(!1)}}},Y=async y=>{if(p)try{W(!0),P(y);const c=await B.emailTemplates.preview(p,{languageCode:y});S({subject:c.subject,htmlBody:c.htmlBody})}catch(c){console.error("Failed to preview template:",c),A(t("emailTemplates.detail.errors.previewFailed"))}finally{W(!1)}},G=()=>{P(null),S(null)},J=l.useMemo(()=>{let y=[];if(r?.variablesJson)try{const c=JSON.parse(r.variablesJson);Array.isArray(c)?y=c.filter(N=>N?.name):typeof c=="object"&&(y=Object.entries(c).filter(([N])=>N&&N!=="undefined").map(([N,I])=>({name:N,description:typeof I=="object"&&I!==null?I.description:void 0,type:typeof I=="object"&&I!==null?I.type:void 0,required:typeof I=="object"&&I!==null?I.required:!1})))}catch{}return{user:ve,email:he,custom:y}},[r?.variablesJson]);l.useEffect(()=>{if(r?.translations&&r.translations.length>0){const y=s.language.split("-")[0],c=r.translations.find(N=>N.languageCode===y);o(c?.languageCode||r.translations[0].languageCode)}},[r?.translations,s.language]);const j=l.useMemo(()=>!r?.translations||!L?null:r.translations.find(y=>y.languageCode===L)||null,[r?.translations,L]),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"})}],z=y=>t(`emailTemplates.categories.${y.toLowerCase()}`)||y,R=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/${p}/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:x,disabled:d,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:[d&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),!d&&r.isActive&&e.jsx(a.Pause,{className:"w-4 h-4"}),!d&&!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")})]})]})]}),F&&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"}),F]}),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:()=>D(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:()=>o(y.languageCode),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${L===y.languageCode?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:R(y.languageCode)},y.languageCode))})]}),e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${p}/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/${p}/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:()=>Y(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:[J.custom.length>0&&e.jsx(Q,{title:t("emailTemplates.detail.customVariables"),variables:J.custom,t,defaultExpanded:!0}),e.jsx(Q,{title:t("emailTemplates.detail.userVariables"),variables:J.user,t,defaultExpanded:!1}),e.jsx(Q,{title:t("emailTemplates.detail.emailVariables"),variables:J.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:z(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:z(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/${p}/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/${p}/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(ge,{translation:y,templateId:p,onPreview:()=>Y(y.languageCode),t,getLanguageLabel:R},y.id))})]})]}),_&&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:K,disabled:d,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:[d?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),t("emailTemplates.delete")]})]})]})}),M&&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")," - ",R(M)]}),e.jsxs("button",{onClick:G,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"})})]})}),$&&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 ge({translation:t,templateId:s,onPreview:p,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:p,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 Q({title:t,variables:s,t:p,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(fe,{variable:u,t:p},u.name))})]})}function fe({variable:t,t:s}){const[p,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:p?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)]"})})]})}function ye({content:t,onChange:s,placeholder:p,className:i}){const[r,g]=l.useState("visual"),[u,k]=l.useState(t),[v,m]=l.useState(""),[n,D]=l.useState(!1),[F,A]=l.useState(""),[h,f]=l.useState(!1),d=ee.useEditor({extensions:[se.configure({heading:{levels:[1,2,3]}}),re.configure({openOnClick:!1,HTMLAttributes:{class:"text-[var(--color-accent-600)] underline"}}),ie.configure({HTMLAttributes:{class:"max-w-full h-auto rounded"}}),le.configure({placeholder:p||"Commencez a ecrire votre email..."}),ne.configure({types:["heading","paragraph"]}),oe,ce.TextStyle,de.Color,me.configure({multicolor:!0})],content:t,onUpdate:({editor:L})=>{const o=L.getHTML();s(o),k(o)},editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[300px] p-4"}}});l.useEffect(()=>{r==="visual"&&d&&u!==d.getHTML()&&d.commands.setContent(u)},[r,d,u]),l.useEffect(()=>{d&&k(d.getHTML())},[d?.getHTML()]);const C=l.useCallback(L=>{const o=L||"";k(o),s(o)},[s]),_=l.useCallback(()=>{d&&d.commands.setContent(u),g("visual")},[d,u]),T=l.useCallback(()=>{d&&k(d.getHTML()),g("code")},[d]),M=l.useCallback(()=>{v&&d&&(d.chain().focus().extendMarkRange("link").setLink({href:v}).run(),m(""),D(!1))},[d,v]),P=l.useCallback(()=>{d&&(d.chain().focus().unsetLink().run(),D(!1))},[d]),b=l.useCallback(()=>{F&&d&&(d.chain().focus().setImage({src:F}).run(),A(""),f(!1))},[d,F]),S=l.useCallback(L=>{if(d){const o=`{{ ${L} }}`;d.chain().focus().insertContent(`<span class="variable-tag" data-variable="${L}">${o}</span>`).run()}},[d]);if(l.useEffect(()=>(typeof window<"u"&&(window.__emailEditorInsertVariable=S),()=>{typeof window<"u"&&delete window.__emailEditorInsertVariable}),[S]),!d)return 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 $=({onClick:L,isActive:o=!1,disabled:E=!1,title:x,children:V})=>e.jsx("button",{type:"button",onClick:L,disabled:E,title:x,className:`p-1.5 rounded transition-colors ${o?"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)]"} ${E?"opacity-50 cursor-not-allowed":""}`,children:V}),W=()=>e.jsx("div",{className:"w-px h-6 bg-[var(--border-color)] mx-1"});return 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:_,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(W,{}),e.jsx($,{onClick:()=>d.chain().focus().undo().run(),disabled:!d.can().undo(),title:"Annuler",children:e.jsx(a.Undo,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().redo().run(),disabled:!d.can().redo(),title:"Retablir",children:e.jsx(a.Redo,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:1}).run(),isActive:d.isActive("heading",{level:1}),title:"Titre 1",children:e.jsx(a.Heading1,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:2}).run(),isActive:d.isActive("heading",{level:2}),title:"Titre 2",children:e.jsx(a.Heading2,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:3}).run(),isActive:d.isActive("heading",{level:3}),title:"Titre 3",children:e.jsx(a.Heading3,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBold().run(),isActive:d.isActive("bold"),title:"Gras",children:e.jsx(a.Bold,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleItalic().run(),isActive:d.isActive("italic"),title:"Italique",children:e.jsx(a.Italic,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleUnderline().run(),isActive:d.isActive("underline"),title:"Souligne",children:e.jsx(a.Underline,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleStrike().run(),isActive:d.isActive("strike"),title:"Barre",children:e.jsx(a.Strikethrough,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("left").run(),isActive:d.isActive({textAlign:"left"}),title:"Aligner a gauche",children:e.jsx(a.AlignLeft,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("center").run(),isActive:d.isActive({textAlign:"center"}),title:"Centrer",children:e.jsx(a.AlignCenter,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("right").run(),isActive:d.isActive({textAlign:"right"}),title:"Aligner a droite",children:e.jsx(a.AlignRight,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBulletList().run(),isActive:d.isActive("bulletList"),title:"Liste a puces",children:e.jsx(a.List,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleOrderedList().run(),isActive:d.isActive("orderedList"),title:"Liste numerotee",children:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBlockquote().run(),isActive:d.isActive("blockquote"),title:"Citation",children:e.jsx(a.Quote,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setHorizontalRule().run(),title:"Ligne horizontale",children:e.jsx(a.Minus,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsxs("div",{className:"relative",children:[e.jsx($,{onClick:()=>D(!n),isActive:d.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:L=>m(L.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:L=>L.key==="Enter"&&M()}),e.jsx("button",{type:"button",onClick:M,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),d.isActive("link")&&e.jsx("button",{type:"button",onClick:P,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($,{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:F,onChange:L=>A(L.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:L=>L.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($,{onClick:()=>{d.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(W,{}),e.jsxs("div",{className:"relative group",children:[e.jsx($,{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(L=>e.jsx("button",{type:"button",onClick:()=>d.chain().focus().setColor(L).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:L}},L))})]}),e.jsxs("div",{className:"relative group",children:[e.jsx($,{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(L=>e.jsx("button",{type:"button",onClick:()=>d.chain().focus().toggleHighlight({color:L}).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:L}},L))})]})]})]}),e.jsx("div",{className:"min-h-[400px]",children:r==="visual"?e.jsx(ee.EditorContent,{editor:d,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(xe,{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"}})})]})}const je=[{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"}],we=[{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"}],te=["fr","en","de","it"],Ne={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 ke(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 Z(t){if(!t)return t;let s=t;return s=s.replace(/\{\{\s*(\w+)\s*\}\}/g,(p,i)=>Ne[i]||ke(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 Te(){const{t}=O.useTranslation("communications"),{id:s}=U.useParams(),p=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState(!1),[m,n]=U.useSearchParams(),D=m.get("tab")||"info",F=c=>n({tab:c}),[A,h]=l.useState(null),[f,d]=l.useState(null),[C,_]=l.useState({name:"",description:"",category:""}),[T,M]=l.useState(null),[P,b]=l.useState(!1),[S,$]=l.useState(!1),[W,L]=l.useState(!0),[o,E]=l.useState(!1),x=l.useMemo(()=>{let c=[];if(i?.variablesJson)try{const N=JSON.parse(i.variablesJson);Array.isArray(N)?c=N.filter(I=>I?.name):typeof N=="object"&&(c=Object.entries(N).filter(([I])=>I&&I!=="undefined").map(([I,H])=>({name:I,description:typeof H=="object"&&H!==null?H.description:void 0,type:typeof H=="object"&&H!==null?H.type:void 0,required:typeof H=="object"&&H!==null?H.required:!1})))}catch{}return{user:je,email:we,custom:c}},[i?.variablesJson]),V=l.useCallback(async()=>{if(s)try{u(!0),h(null);const c=await B.emailTemplates.getById(s);r(c),_({name:c.name,description:c.description||"",category:c.category})}catch(c){console.error("Failed to load template:",c),h(t("emailTemplates.edit.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{V()},[V]);const K=async c=>{if(c.preventDefault(),!(!s||!i))try{v(!0),h(null),await B.emailTemplates.update(s,{name:C.name,description:C.description||void 0,category:C.category,isActive:i.isActive}),d(t("emailTemplates.edit.success.saved")),V()}catch(N){console.error("Failed to save template:",N),h(t("emailTemplates.edit.errors.saveFailed"))}finally{v(!1)}},Y=()=>{const c=i?.translations.map(I=>I.languageCode)||[],N=te.filter(I=>!c.includes(I));if(N.length===0){h(t("emailTemplates.edit.errors.allLanguagesExist"));return}M({languageCode:N[0],subject:"",htmlBody:"",textBody:""}),b(!0)},G=c=>{M({languageCode:c.languageCode,subject:c.subject,htmlBody:c.htmlBody,textBody:c.textBody||""}),b(!1)},J=async()=>{if(!(!s||!T))try{$(!0),h(null),P?(await B.emailTemplates.createTranslation(s,{languageCode:T.languageCode,subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),d(t("emailTemplates.edit.success.translationAdded"))):(await B.emailTemplates.updateTranslation(s,T.languageCode,{subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),d(t("emailTemplates.edit.success.translationUpdated"))),M(null),V()}catch(c){console.error("Failed to save translation:",c),h(t("emailTemplates.edit.errors.translationSaveFailed"))}finally{$(!1)}},j=async c=>{if(s&&!(!c||!confirm(t("emailTemplates.edit.confirmDeleteTranslation"))))try{$(!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{$(!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"})}],z=c=>t(`languages.${c}`,{defaultValue:c.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:()=>p("/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 R=i.translations.map(c=>c.languageCode),y=te.filter(c=>!R.includes(c));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:()=>p(`/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})]})]}),A&&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"}),A]}),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(c=>e.jsxs("button",{onClick:()=>F(c.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${D===c.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[c.icon,e.jsx("span",{className:"hidden sm:inline",children:c.label})]},c.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:K,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:c=>_(N=>({...N,name:c.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:c=>_(N=>({...N,description:c.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:c=>_(N=>({...N,category:c.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:()=>p(`/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")]})]})]}),D==="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:Y,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(c=>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:c.languageCode})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:z(c.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] truncate max-w-md",children:c.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>G(c),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(c.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"})})]})]})},c.id))})]}),D==="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(P?"emailTemplates.edit.addTranslation":"emailTemplates.edit.editTranslation")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>L(!W),className:`flex items-center gap-1 px-2 py-1 rounded text-sm transition-colors ${W?"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:()=>M(null),className:"text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:t("common.cancel")})]})]}),e.jsxs("div",{className:`grid gap-6 ${W?"grid-cols-1 xl:grid-cols-2":"grid-cols-1"}`,children:[e.jsxs("div",{className:"space-y-4",children:[P&&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:c=>M(N=>N?{...N,languageCode:c.target.value}:null),className:"input w-full max-w-xs",children:y.map(c=>e.jsx("option",{value:c,children:z(c)},c))})]}),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:c=>M(N=>N?{...N,subject:c.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(ye,{content:T.htmlBody,onChange:c=>M(N=>N?{...N,htmlBody:c}: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:c=>M(N=>N?{...N,textBody:c.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")})]})]}),W&&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:[x.custom.length>0&&e.jsx(X,{title:t("emailTemplates.detail.customVariables"),variables:x.custom,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!0}),e.jsx(X,{title:t("emailTemplates.detail.userVariables"),variables:x.user,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!1}),e.jsx(X,{title:t("emailTemplates.detail.emailVariables"),variables:x.email,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.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:()=>E(!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?Z(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"),O=require("react-i18next"),a=require("lucide-react"),w=require("./index-DK5czlkn.js"),ee=require("@tiptap/react"),se=require("@tiptap/starter-kit"),re=require("@tiptap/extension-link"),ie=require("@tiptap/extension-image"),le=require("@tiptap/extension-placeholder"),ne=require("@tiptap/extension-text-align"),oe=require("@tiptap/extension-underline"),ce=require("@tiptap/extension-text-style"),de=require("@tiptap/extension-color"),me=require("@tiptap/extension-highlight"),xe=require("@monaco-editor/react"),B={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,p)=>w.api.put(`/api/administration/workflows/email-templates/${t}/translations/${s}`,p)},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,p)=>w.api.put(`/api/administration/workflows/definitions/${t}/steps/${s}`,p),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 pe(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),{currentTenant:p,isGlobalView:i}=w.useTenant(),[r,g]=l.useState([]),[u,k]=l.useState(!0),[v,m]=l.useState(""),[n,D]=l.useState("table"),[F,A]=l.useState(1),h=20,f=l.useCallback(async()=>{try{k(!0);const x=await B.emailTemplates.getAll({search:v||void 0});g(Array.isArray(x)?x:[])}catch(x){console.error("Failed to load templates:",x)}finally{k(!1)}},[v,p?.id,i]);l.useEffect(()=>{f()},[f]);const d=x=>{x.preventDefault(),A(1),f()},C=async(x,V)=>{if(V?.stopPropagation(),x.isSystem){alert(t("emailTemplates.cannotDeleteSystem"));return}if(confirm(t("emailTemplates.confirmDelete",{name:x.name})))try{await B.emailTemplates.delete(x.id),f()}catch(K){console.error("Failed to delete template:",K)}},_=(F-1)*h,T=r.slice(_,_+h),M=Math.ceil(r.length/h),P={transactional:r.filter(x=>x.category==="transactional"),notification:r.filter(x=>x.category==="notification"),marketing:r.filter(x=>x.category==="marketing"),system:r.filter(x=>x.category==="system")},b=x=>t(`emailTemplates.categories.${x.toLowerCase()}`)||x,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(x=>e.jsxs("tr",{className:"group hover:bg-[var(--bg-hover)] transition-all cursor-pointer",onClick:()=>s(`/administration/workflows/email-templates/${x.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:x.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:x.name}),x.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(x.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:x.languages.length})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(w.StatusBadge,{status:x.isActive?"active":"inactive",label:x.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/${x.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/${x.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"})}),!x.isSystem&&e.jsx("button",{onClick:V=>C(x,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"})})]})})]},x.id))]})]})}),$=()=>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(x=>e.jsx(w.TemplateCard,{name:x.name,code:x.code,category:b(x.category),isActive:x.isActive,isSystem:x.isSystem,icon:a.Mail,iconColor:"var(--color-accent-500)",translationsCount:x.languages.length,onClick:()=>s(`/administration/workflows/email-templates/${x.id}`),onEdit:()=>s(`/administration/workflows/email-templates/${x.id}/edit`),onDelete:()=>C(x),labels:{activeLabel:t("emailTemplates.active"),inactiveLabel:t("emailTemplates.inactive"),systemLabel:"System",editLabel:t("emailTemplates.edit.title"),deleteLabel:t("emailTemplates.delete")}},x.id)),W=()=>e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:$()}),L=x=>x==="transactional"?"bg-[var(--success-dot)]":x==="notification"?"bg-[var(--warning-dot)]":x==="marketing"?"bg-blue-500":"bg-[var(--text-muted)]",o=x=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/email-templates/${x.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:x.name}),e.jsx("code",{className:"text-xs text-[var(--text-secondary)]",children:x.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 ${x.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 ${x.isActive?"bg-[var(--success-dot)]":"bg-[var(--text-muted)]"}`}),x.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:x.languages.length})]})]})})]},x.id),E=()=>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(P).map(([x,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 ${L(x)}`}),e.jsx("h3",{className:"font-semibold text-[var(--text-primary)]",children:b(x)}),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(o),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")})]})]})]},x))})});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:d,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:x=>m(x.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:D,tableLabel:"Table",cardsLabel:"Cards",kanbanLabel:"Kanban"})]})}),n==="table"&&S(),n==="cards"&&W(),n==="kanban"&&E(),n!=="kanban"&&r.length>0&&e.jsx(w.Pagination,{page:F,totalPages:M,totalCount:r.length,pageSize:h,onPageChange:A,itemLabel:"templates"})]})}function ue(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),[p,i]=l.useState(!1),[r,g]=l.useState(null),[u,k]=l.useState({code:"",name:"",description:"",category:"transactional"}),v=async m=>{m.preventDefault(),i(!0),g(null);try{const n=await B.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 D=n instanceof Error?n.message:"An error occurred while creating the template";g(D)}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:m=>k(n=>({...n,code:m.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:m=>k(n=>({...n,name:m.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:m=>k(n=>({...n,description:m.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:m=>k(n=>({...n,category:m.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:p,className:"btn btn-primary disabled:opacity-50",children:[p?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]})]})}const ve=[{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"}],he=[{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 be(){const{t,i18n:s}=O.useTranslation("communications"),{id:p}=U.useParams(),i=U.useNavigate(),[r,g]=l.useState(null),[u,k]=l.useState(!0),[v,m]=U.useSearchParams(),n=v.get("tab")||"preview",D=y=>m({tab:y}),[F,A]=l.useState(null),[h,f]=l.useState(null),[d,C]=l.useState(!1),[_,T]=l.useState(!1),[M,P]=l.useState(null),[b,S]=l.useState(null),[$,W]=l.useState(!1),[L,o]=l.useState(""),E=l.useCallback(async()=>{if(p)try{k(!0),A(null);const y=await B.emailTemplates.getById(p);g(y)}catch(y){console.error("Failed to load template:",y),A(t("emailTemplates.detail.errors.loadFailed"))}finally{k(!1)}},[p,t]);l.useEffect(()=>{E()},[E]);const x=async()=>{if(!(!p||!r))try{C(!0),A(null),await B.emailTemplates.update(p,{name:r.name,description:r.description||void 0,category:r.category,isActive:!0}),f(t("emailTemplates.detail.success.activated")),E()}catch(y){console.error("Failed to activate template:",y),A(t("emailTemplates.detail.errors.activateFailed"))}finally{C(!1)}},V=async()=>{if(!(!p||!r))try{C(!0),A(null),await B.emailTemplates.update(p,{name:r.name,description:r.description||void 0,category:r.category,isActive:!1}),f(t("emailTemplates.detail.success.deactivated")),E()}catch(y){console.error("Failed to deactivate template:",y),A(t("emailTemplates.detail.errors.deactivateFailed"))}finally{C(!1)}},K=async()=>{if(!(!p||!r)){if(r.isSystem){A(t("emailTemplates.cannotDeleteSystem"));return}try{C(!0),A(null),await B.emailTemplates.delete(p),i("/administration/workflows/email-templates")}catch(y){console.error("Failed to delete template:",y),A(t("emailTemplates.detail.errors.deleteFailed")),T(!1)}finally{C(!1)}}},Y=async y=>{if(p)try{W(!0),P(y);const c=await B.emailTemplates.preview(p,{languageCode:y});S({subject:c.subject,htmlBody:c.htmlBody})}catch(c){console.error("Failed to preview template:",c),A(t("emailTemplates.detail.errors.previewFailed"))}finally{W(!1)}},G=()=>{P(null),S(null)},J=l.useMemo(()=>{let y=[];if(r?.variablesJson)try{const c=JSON.parse(r.variablesJson);Array.isArray(c)?y=c.filter(N=>N?.name):typeof c=="object"&&(y=Object.entries(c).filter(([N])=>N&&N!=="undefined").map(([N,I])=>({name:N,description:typeof I=="object"&&I!==null?I.description:void 0,type:typeof I=="object"&&I!==null?I.type:void 0,required:typeof I=="object"&&I!==null?I.required:!1})))}catch{}return{user:ve,email:he,custom:y}},[r?.variablesJson]);l.useEffect(()=>{if(r?.translations&&r.translations.length>0){const y=s.language.split("-")[0],c=r.translations.find(N=>N.languageCode===y);o(c?.languageCode||r.translations[0].languageCode)}},[r?.translations,s.language]);const j=l.useMemo(()=>!r?.translations||!L?null:r.translations.find(y=>y.languageCode===L)||null,[r?.translations,L]),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"})}],z=y=>t(`emailTemplates.categories.${y.toLowerCase()}`)||y,R=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/${p}/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:x,disabled:d,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:[d&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),!d&&r.isActive&&e.jsx(a.Pause,{className:"w-4 h-4"}),!d&&!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")})]})]})]}),F&&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"}),F]}),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:()=>D(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:()=>o(y.languageCode),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${L===y.languageCode?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:R(y.languageCode)},y.languageCode))})]}),e.jsxs("button",{onClick:()=>i(`/administration/workflows/email-templates/${p}/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/${p}/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:()=>Y(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:[J.custom.length>0&&e.jsx(Q,{title:t("emailTemplates.detail.customVariables"),variables:J.custom,t,defaultExpanded:!0}),e.jsx(Q,{title:t("emailTemplates.detail.userVariables"),variables:J.user,t,defaultExpanded:!1}),e.jsx(Q,{title:t("emailTemplates.detail.emailVariables"),variables:J.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:z(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:z(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/${p}/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/${p}/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(ge,{translation:y,templateId:p,onPreview:()=>Y(y.languageCode),t,getLanguageLabel:R},y.id))})]})]}),_&&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:K,disabled:d,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:[d?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Trash2,{className:"w-4 h-4"}),t("emailTemplates.delete")]})]})]})}),M&&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")," - ",R(M)]}),e.jsxs("button",{onClick:G,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"})})]})}),$&&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 ge({translation:t,templateId:s,onPreview:p,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:p,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 Q({title:t,variables:s,t:p,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(fe,{variable:u,t:p},u.name))})]})}function fe({variable:t,t:s}){const[p,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:p?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)]"})})]})}function ye({content:t,onChange:s,placeholder:p,className:i}){const[r,g]=l.useState("visual"),[u,k]=l.useState(t),[v,m]=l.useState(""),[n,D]=l.useState(!1),[F,A]=l.useState(""),[h,f]=l.useState(!1),d=ee.useEditor({extensions:[se.configure({heading:{levels:[1,2,3]}}),re.configure({openOnClick:!1,HTMLAttributes:{class:"text-[var(--color-accent-600)] underline"}}),ie.configure({HTMLAttributes:{class:"max-w-full h-auto rounded"}}),le.configure({placeholder:p||"Commencez a ecrire votre email..."}),ne.configure({types:["heading","paragraph"]}),oe,ce.TextStyle,de.Color,me.configure({multicolor:!0})],content:t,onUpdate:({editor:L})=>{const o=L.getHTML();s(o),k(o)},editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[300px] p-4"}}});l.useEffect(()=>{r==="visual"&&d&&u!==d.getHTML()&&d.commands.setContent(u)},[r,d,u]),l.useEffect(()=>{d&&k(d.getHTML())},[d?.getHTML()]);const C=l.useCallback(L=>{const o=L||"";k(o),s(o)},[s]),_=l.useCallback(()=>{d&&d.commands.setContent(u),g("visual")},[d,u]),T=l.useCallback(()=>{d&&k(d.getHTML()),g("code")},[d]),M=l.useCallback(()=>{v&&d&&(d.chain().focus().extendMarkRange("link").setLink({href:v}).run(),m(""),D(!1))},[d,v]),P=l.useCallback(()=>{d&&(d.chain().focus().unsetLink().run(),D(!1))},[d]),b=l.useCallback(()=>{F&&d&&(d.chain().focus().setImage({src:F}).run(),A(""),f(!1))},[d,F]),S=l.useCallback(L=>{if(d){const o=`{{ ${L} }}`;d.chain().focus().insertContent(`<span class="variable-tag" data-variable="${L}">${o}</span>`).run()}},[d]);if(l.useEffect(()=>(typeof window<"u"&&(window.__emailEditorInsertVariable=S),()=>{typeof window<"u"&&delete window.__emailEditorInsertVariable}),[S]),!d)return 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 $=({onClick:L,isActive:o=!1,disabled:E=!1,title:x,children:V})=>e.jsx("button",{type:"button",onClick:L,disabled:E,title:x,className:`p-1.5 rounded transition-colors ${o?"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)]"} ${E?"opacity-50 cursor-not-allowed":""}`,children:V}),W=()=>e.jsx("div",{className:"w-px h-6 bg-[var(--border-color)] mx-1"});return 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:_,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(W,{}),e.jsx($,{onClick:()=>d.chain().focus().undo().run(),disabled:!d.can().undo(),title:"Annuler",children:e.jsx(a.Undo,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().redo().run(),disabled:!d.can().redo(),title:"Retablir",children:e.jsx(a.Redo,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:1}).run(),isActive:d.isActive("heading",{level:1}),title:"Titre 1",children:e.jsx(a.Heading1,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:2}).run(),isActive:d.isActive("heading",{level:2}),title:"Titre 2",children:e.jsx(a.Heading2,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleHeading({level:3}).run(),isActive:d.isActive("heading",{level:3}),title:"Titre 3",children:e.jsx(a.Heading3,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBold().run(),isActive:d.isActive("bold"),title:"Gras",children:e.jsx(a.Bold,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleItalic().run(),isActive:d.isActive("italic"),title:"Italique",children:e.jsx(a.Italic,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleUnderline().run(),isActive:d.isActive("underline"),title:"Souligne",children:e.jsx(a.Underline,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleStrike().run(),isActive:d.isActive("strike"),title:"Barre",children:e.jsx(a.Strikethrough,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("left").run(),isActive:d.isActive({textAlign:"left"}),title:"Aligner a gauche",children:e.jsx(a.AlignLeft,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("center").run(),isActive:d.isActive({textAlign:"center"}),title:"Centrer",children:e.jsx(a.AlignCenter,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setTextAlign("right").run(),isActive:d.isActive({textAlign:"right"}),title:"Aligner a droite",children:e.jsx(a.AlignRight,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBulletList().run(),isActive:d.isActive("bulletList"),title:"Liste a puces",children:e.jsx(a.List,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().toggleOrderedList().run(),isActive:d.isActive("orderedList"),title:"Liste numerotee",children:e.jsx(a.ListOrdered,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsx($,{onClick:()=>d.chain().focus().toggleBlockquote().run(),isActive:d.isActive("blockquote"),title:"Citation",children:e.jsx(a.Quote,{className:"w-4 h-4"})}),e.jsx($,{onClick:()=>d.chain().focus().setHorizontalRule().run(),title:"Ligne horizontale",children:e.jsx(a.Minus,{className:"w-4 h-4"})}),e.jsx(W,{}),e.jsxs("div",{className:"relative",children:[e.jsx($,{onClick:()=>D(!n),isActive:d.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:L=>m(L.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:L=>L.key==="Enter"&&M()}),e.jsx("button",{type:"button",onClick:M,className:"p-1 text-[var(--success-text)] hover:bg-[var(--success-bg)] rounded",children:e.jsx(a.Check,{className:"w-4 h-4"})}),d.isActive("link")&&e.jsx("button",{type:"button",onClick:P,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($,{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:F,onChange:L=>A(L.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:L=>L.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($,{onClick:()=>{d.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(W,{}),e.jsxs("div",{className:"relative group",children:[e.jsx($,{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(L=>e.jsx("button",{type:"button",onClick:()=>d.chain().focus().setColor(L).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:L}},L))})]}),e.jsxs("div",{className:"relative group",children:[e.jsx($,{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(L=>e.jsx("button",{type:"button",onClick:()=>d.chain().focus().toggleHighlight({color:L}).run(),className:"w-6 h-6 rounded border border-[var(--border-color)]",style:{backgroundColor:L}},L))})]})]})]}),e.jsx("div",{className:"min-h-[400px]",children:r==="visual"?e.jsx(ee.EditorContent,{editor:d,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(xe,{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"}})})]})}const je=[{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"}],we=[{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"}],te=["fr","en","de","it"],Ne={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 ke(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 Z(t){if(!t)return t;let s=t;return s=s.replace(/\{\{\s*(\w+)\s*\}\}/g,(p,i)=>Ne[i]||ke(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 Te(){const{t}=O.useTranslation("communications"),{id:s}=U.useParams(),p=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState(!1),[m,n]=U.useSearchParams(),D=m.get("tab")||"info",F=c=>n({tab:c}),[A,h]=l.useState(null),[f,d]=l.useState(null),[C,_]=l.useState({name:"",description:"",category:""}),[T,M]=l.useState(null),[P,b]=l.useState(!1),[S,$]=l.useState(!1),[W,L]=l.useState(!0),[o,E]=l.useState(!1),x=l.useMemo(()=>{let c=[];if(i?.variablesJson)try{const N=JSON.parse(i.variablesJson);Array.isArray(N)?c=N.filter(I=>I?.name):typeof N=="object"&&(c=Object.entries(N).filter(([I])=>I&&I!=="undefined").map(([I,H])=>({name:I,description:typeof H=="object"&&H!==null?H.description:void 0,type:typeof H=="object"&&H!==null?H.type:void 0,required:typeof H=="object"&&H!==null?H.required:!1})))}catch{}return{user:je,email:we,custom:c}},[i?.variablesJson]),V=l.useCallback(async()=>{if(s)try{u(!0),h(null);const c=await B.emailTemplates.getById(s);r(c),_({name:c.name,description:c.description||"",category:c.category})}catch(c){console.error("Failed to load template:",c),h(t("emailTemplates.edit.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{V()},[V]);const K=async c=>{if(c.preventDefault(),!(!s||!i))try{v(!0),h(null),await B.emailTemplates.update(s,{name:C.name,description:C.description||void 0,category:C.category,isActive:i.isActive}),d(t("emailTemplates.edit.success.saved")),V()}catch(N){console.error("Failed to save template:",N),h(t("emailTemplates.edit.errors.saveFailed"))}finally{v(!1)}},Y=()=>{const c=i?.translations.map(I=>I.languageCode)||[],N=te.filter(I=>!c.includes(I));if(N.length===0){h(t("emailTemplates.edit.errors.allLanguagesExist"));return}M({languageCode:N[0],subject:"",htmlBody:"",textBody:""}),b(!0)},G=c=>{M({languageCode:c.languageCode,subject:c.subject,htmlBody:c.htmlBody,textBody:c.textBody||""}),b(!1)},J=async()=>{if(!(!s||!T))try{$(!0),h(null),P?(await B.emailTemplates.createTranslation(s,{languageCode:T.languageCode,subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),d(t("emailTemplates.edit.success.translationAdded"))):(await B.emailTemplates.updateTranslation(s,T.languageCode,{subject:T.subject,htmlBody:T.htmlBody,textBody:T.textBody||void 0}),d(t("emailTemplates.edit.success.translationUpdated"))),M(null),V()}catch(c){console.error("Failed to save translation:",c),h(t("emailTemplates.edit.errors.translationSaveFailed"))}finally{$(!1)}},j=async c=>{if(s&&!(!c||!confirm(t("emailTemplates.edit.confirmDeleteTranslation"))))try{$(!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{$(!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"})}],z=c=>t(`languages.${c}`,{defaultValue:c.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:()=>p("/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 R=i.translations.map(c=>c.languageCode),y=te.filter(c=>!R.includes(c));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:()=>p(`/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})]})]}),A&&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"}),A]}),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(c=>e.jsxs("button",{onClick:()=>F(c.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${D===c.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[c.icon,e.jsx("span",{className:"hidden sm:inline",children:c.label})]},c.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:K,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:c=>_(N=>({...N,name:c.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:c=>_(N=>({...N,description:c.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:c=>_(N=>({...N,category:c.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:()=>p(`/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")]})]})]}),D==="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:Y,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(c=>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:c.languageCode})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:z(c.languageCode)}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] truncate max-w-md",children:c.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>G(c),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(c.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"})})]})]})},c.id))})]}),D==="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(P?"emailTemplates.edit.addTranslation":"emailTemplates.edit.editTranslation")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>L(!W),className:`flex items-center gap-1 px-2 py-1 rounded text-sm transition-colors ${W?"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:()=>M(null),className:"text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:t("common.cancel")})]})]}),e.jsxs("div",{className:`grid gap-6 ${W?"grid-cols-1 xl:grid-cols-2":"grid-cols-1"}`,children:[e.jsxs("div",{className:"space-y-4",children:[P&&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:c=>M(N=>N?{...N,languageCode:c.target.value}:null),className:"input w-full max-w-xs",children:y.map(c=>e.jsx("option",{value:c,children:z(c)},c))})]}),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:c=>M(N=>N?{...N,subject:c.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(ye,{content:T.htmlBody,onChange:c=>M(N=>N?{...N,htmlBody:c}: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:c=>M(N=>N?{...N,textBody:c.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")})]})]}),W&&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:[x.custom.length>0&&e.jsx(X,{title:t("emailTemplates.detail.customVariables"),variables:x.custom,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!0}),e.jsx(X,{title:t("emailTemplates.detail.userVariables"),variables:x.user,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.htmlBody+N}:null)},defaultExpanded:!1}),e.jsx(X,{title:t("emailTemplates.detail.emailVariables"),variables:x.email,onInsert:c=>{const N=`{{ ${c} }}`;M(I=>I?{...I,htmlBody:I.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:()=>E(!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?Z(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>${Z(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 X({title:t,variables:s,onInsert:p,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(Ce,{variable:u,onInsert:p},u.name))})]})}function Ce({variable:t,onInsert:s}){const[p,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}),p&&e.jsx(a.Check,{className:"w-2.5 h-2.5 text-[var(--success-text)]"})]})}function Se(){const{t}=O.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 Le(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),{currentTenant:p,isGlobalView:i}=w.useTenant(),[r,g]=l.useState([]),[u,k]=l.useState(!0),[v,m]=l.useState(""),[n,D]=l.useState("table"),[F,A]=l.useState(1),h=20,f=l.useCallback(async()=>{try{k(!0);const o=await B.workflows.getAll({search:v||void 0});g(Array.isArray(o)?o:[])}catch(o){console.error("Failed to load workflows:",o)}finally{k(!1)}},[v,p?.id,i]);l.useEffect(()=>{f()},[f]);const d=o=>{o.preventDefault(),A(1),f()},C=async(o,E)=>{E.stopPropagation();try{o.isActive?await B.workflows.deactivate(o.id):await B.workflows.activate(o.id),f()}catch(x){console.error("Failed to toggle workflow:",x)}},_=async(o,E)=>{if(E.stopPropagation(),o.isSystem){alert(t("workflows.cannotDeleteSystem"));return}if(confirm(t("workflows.confirmDelete",{name:o.name})))try{await B.workflows.delete(o.id),f()}catch(x){console.error("Failed to delete workflow:",x)}},T=(F-1)*h,M=r.slice(T,T+h),P=Math.ceil(r.length/h),b=r.filter(o=>o.isActive),S=r.filter(o=>!o.isActive),$=()=>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&&M.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&&M.length>0&&M.map(o=>e.jsxs("tr",{className:"group hover:bg-[var(--bg-hover)] transition-all cursor-pointer",onClick:()=>s(`/administration/workflows/${o.id}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:E=>E.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:o.name}),o.description&&e.jsx("p",{className:"text-sm text-[var(--text-tertiary)] truncate max-w-xs",children:o.description}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[o.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&&o.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:o.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:o.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:[o.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:o.priority})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(w.StatusBadge,{status:o.isActive?"active":"inactive",label:o.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:E=>E.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/${o.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:E=>C(o,E),className:`p-2 rounded-lg transition-all ${o.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:o.isActive?t("workflows.deactivate"):t("workflows.activate"),children:o.isActive?e.jsx(a.Pause,{className:"w-4 h-4"}):e.jsx(a.Play,{className:"w-4 h-4"})}),e.jsx("button",{onClick:E=>{E.stopPropagation(),s(`/administration/workflows/${o.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"})}),!o.isSystem&&e.jsx("button",{onClick:E=>_(o,E),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"})})]})})]},o.id))]})]})}),W=()=>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&&M.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&&M.length>0&&M.map(o=>e.jsxs("button",{onClick:()=>s(`/administration/workflows/${o.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:o.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"}),o.triggerName]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[o.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&&o.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:o.tenantName}),e.jsx("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-xs rounded-full font-medium ${o.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:o.isActive?t("workflows.active"):t("workflows.inactive")})]})]})}),e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[o.description&&e.jsx("p",{className:"text-sm text-[var(--text-secondary)] line-clamp-2 mb-3",children:o.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:[o.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",o.priority]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1 pt-3 border-t border-[var(--border-color)]",onClick:E=>E.stopPropagation(),children:[e.jsx("button",{onClick:()=>s(`/administration/workflows/${o.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:E=>C(o,E),className:`p-2 rounded-lg transition-all ${o.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:o.isActive?t("workflows.deactivate"):t("workflows.activate"),children:o.isActive?e.jsx(a.Pause,{className:"w-4 h-4"}):e.jsx(a.Play,{className:"w-4 h-4"})}),e.jsx("button",{onClick:E=>{E.stopPropagation(),s(`/administration/workflows/${o.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"})}),!o.isSystem&&e.jsx("button",{onClick:E=>_(o,E),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"})})]})]})]},o.id))]}),L=()=>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(o=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/${o.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:o.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"}),o.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:[o.stepCount," steps"]}),e.jsx("span",{onClick:E=>C(o,E),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")})]})]},o.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(o=>e.jsxs("button",{type:"button",onClick:()=>s(`/administration/workflows/${o.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:o.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"}),o.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:[o.stepCount," steps"]}),e.jsx("span",{onClick:E=>C(o,E),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")})]})]},o.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:d,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:o=>m(o.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:D,tableLabel:"Table",cardsLabel:"Cards",kanbanLabel:"Kanban"})]})}),n==="table"&&$(),n==="cards"&&W(),n==="kanban"&&L(),n!=="kanban"&&r.length>0&&e.jsx(w.Pagination,{page:F,totalPages:P,totalCount:r.length,pageSize:h,onPageChange:A,itemLabel:"workflows"})]})}function Ae(){const{t}=O.useTranslation("communications"),[s,p]=l.useState([]),[i,r]=l.useState(!0),[g,u]=l.useState(null);l.useEffect(()=>{(async()=>{try{r(!0);const n=await B.triggers.getAll();p(Array.isArray(n)?n:[])}catch(n){console.error("Failed to load triggers:",n)}finally{r(!1)}})()},[]);const k=m=>{switch(m){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=m=>{if(!m)return[];try{return JSON.parse(m)}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(m=>{const n=v(m.availableVariablesJson);return e.jsxs("button",{type:"button",onClick:()=>u(m),className:`card p-4 cursor-pointer transition-all text-left w-full ${g?.id===m.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:m.name}),e.jsx("code",{className:"text-sm text-[var(--text-tertiary)] bg-[var(--bg-secondary)] px-1.5 py-0.5 rounded",children:m.code})]})]}),e.jsx("span",{className:`px-2 py-1 rounded-[var(--radius-badge)] text-xs font-medium border ${k(m.triggerType)}`,children:m.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")]})})]},m.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(m=>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:m}),e.jsx("span",{className:"text-amber-500",children:"}}"})]},m)),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 Pe(){const{t}=O.useTranslation("communications"),s=U.useNavigate(),[p,i]=l.useState(!1),[r,g]=l.useState(null),[u,k]=l.useState([]),[v,m]=l.useState(!0),[n,D]=l.useState({code:"",name:"",description:"",triggerId:"",priority:0});l.useEffect(()=>{(async()=>{try{m(!0);const f=await B.triggers.getAll();k(f)}catch(f){console.error("Failed to load triggers:",f)}finally{m(!1)}})()},[]);const F=async h=>{h.preventDefault(),i(!0),g(null);try{const f=await B.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 d=f instanceof Error?f.message:"An error occurred while creating the workflow";g(d)}finally{i(!1)}},A=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:F,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=>D(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=>D(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=>D(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=>D(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))]}),A&&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:A.triggerType}),e.jsx("code",{className:"text-xs text-[var(--text-tertiary)]",children:A.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=>D(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=>D(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:p||!n.triggerId,className:"btn btn-primary disabled:opacity-50",children:[p?e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}):e.jsx(a.Save,{className:"w-4 h-4"}),t("common.save")]})]})]})]})}const Ee={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"})},De={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 $e(){const{t}=O.useTranslation("communications"),{id:s}=U.useParams(),p=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState("info"),[m,n]=l.useState(null),[D,F]=l.useState(null),[A,h]=l.useState(!1),[f,d]=l.useState(!1),C=l.useCallback(async()=>{if(s)try{u(!0),n(null);const b=await B.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 _=async()=>{if(s)try{h(!0),n(null),await B.workflows.activate(s),F(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 B.workflows.deactivate(s),F(t("workflows.detail.success.deactivated")),C()}catch(b){console.error("Failed to deactivate workflow:",b),n(t("workflows.detail.errors.deactivateFailed"))}finally{h(!1)}},M=async()=>{if(!(!s||!i)){if(i.isSystem){n(t("workflows.cannotDeleteSystem"));return}try{h(!0),n(null),await B.workflows.delete(s),p("/administration/workflows/list")}catch(b){console.error("Failed to delete workflow:",b),n(t("workflows.detail.errors.deleteFailed")),d(!1)}finally{h(!1)}}},P=[{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:()=>p("/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:()=>p(`/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:_,disabled:A,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:[A&&e.jsx(a.Loader2,{className:"w-4 h-4 animate-spin"}),!A&&i.isActive&&e.jsx(a.Pause,{className:"w-4 h-4"}),!A&&!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:()=>d(!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")})]})]})})]}),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]}),D&&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"}),D]}),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:P.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(Ie,{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:()=>d(!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:M,disabled:A,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:[A?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:()=>p("/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 Ie({step:t,index:s,isLast:p,t:i}){const r=Ee[t.stepType]||e.jsx(a.Settings,{className:"w-4 h-4"}),g=De[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:[!p&&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 Me={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"})},Fe={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"},Be=["SendEmail","Wait","Condition","Webhook"];function _e({workflowId:t,steps:s,onStepsChange:p,readOnly:i=!1}){const{t:r}=O.useTranslation("communications"),[g,u]=l.useState(!1),[k,v]=l.useState(null),[m,n]=l.useState(null),[D,F]=l.useState(!1),[A,h]=l.useState(!1),[f,d]=l.useState(!1),[C,_]=l.useState(null),[T,M]=l.useState([]),[P,b]=l.useState(!1),[S,$]=l.useState({name:"",stepType:"",emailTemplateId:"",delayMinutes:5,configurationJson:""}),W=async()=>{if(!(T.length>0))try{b(!0);const j=await B.emailTemplates.getAll({isActive:!0});M(j)}catch(j){console.error("Failed to load email templates:",j)}finally{b(!1)}},L=()=>{$({name:"",stepType:"",emailTemplateId:"",delayMinutes:5,configurationJson:""})},o=()=>{L(),W(),F(!0)},E=j=>{_(j),W(),$({name:j.name,stepType:j.stepType,emailTemplateId:j.emailTemplateId||"",delayMinutes:j.delayMinutes||5,configurationJson:j.configurationJson||""}),h(!0)},x=j=>{_(j),d(!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 B.workflows.addStep(t,q),n(r("workflows.steps.success.added")),F(!1),L(),p()}catch(q){console.error("Failed to add step:",q),v(r("workflows.steps.errors.addFailed"))}finally{u(!1)}},K=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 B.workflows.updateStep(t,C.id,q),n(r("workflows.steps.success.updated")),h(!1),_(null),L(),p()}catch(q){console.error("Failed to update step:",q),v(r("workflows.steps.errors.updateFailed"))}finally{u(!1)}},Y=async()=>{if(C)try{u(!0),v(null),await B.workflows.deleteStep(t,C.id),n(r("workflows.steps.success.deleted")),d(!1),_(null),p()}catch(j){console.error("Failed to delete step:",j),v(r("workflows.steps.errors.deleteFailed"))}finally{u(!1)}},G=async(j,q)=>{const z=[...s].sort((c,N)=>c.stepOrder-N.stepOrder),R=z.findIndex(c=>c.id===j.id),y=q==="up"?R-1:R+1;if(!(y<0||y>=z.length))try{u(!0),v(null);const c=z[y],N={name:j.name,stepOrder:c.stepOrder,isActive:j.isActive,emailTemplateId:j.emailTemplateId||void 0,delayMinutes:j.delayMinutes||void 0,configurationJson:j.configurationJson||void 0};await B.workflows.updateStep(t,j.id,N);const I={name:c.name,stepOrder:j.stepOrder,isActive:c.isActive,emailTemplateId:c.emailTemplateId||void 0,delayMinutes:c.delayMinutes||void 0,configurationJson:c.configurationJson||void 0};await B.workflows.updateStep(t,c.id,I),p()}catch(c){console.error("Failed to reorder steps:",c),v(r("workflows.steps.errors.updateFailed"))}finally{u(!1)}};l.useEffect(()=>{if(m){const j=setTimeout(()=>n(null),3e3);return()=>clearTimeout(j)}},[m]),l.useEffect(()=>{if(k){const j=setTimeout(()=>v(null),5e3);return()=>clearTimeout(j)}},[k]);const J=[...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:o,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]}),m&&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"}),m]}),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:J.map((j,q)=>e.jsx(Ve,{step:j,index:q,isFirst:q===0,isLast:q===J.length-1,onEdit:()=>E(j),onDelete:()=>x(j),onMoveUp:()=>G(j,"up"),onMoveDown:()=>G(j,"down"),readOnly:i,loading:g,t:r},j.id))}),D&&e.jsx(ae,{title:r("workflows.steps.add"),formData:S,setFormData:$,emailTemplates:T,loadingTemplates:P,loading:g,onSubmit:V,onClose:()=>{F(!1),L()},t:r}),A&&C&&e.jsx(ae,{title:r("workflows.steps.edit"),formData:S,setFormData:$,emailTemplates:T,loadingTemplates:P,loading:g,onSubmit:K,onClose:()=>{h(!1),_(null),L()},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:()=>{d(!1),_(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:Y,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 Ve({step:t,index:s,isFirst:p,isLast:i,onEdit:r,onDelete:g,onMoveUp:u,onMoveDown:k,readOnly:v,loading:m,t:n}){const D=Me[t.stepType]||e.jsx(a.Settings,{className:"w-4 h-4"}),F=Fe[t.stepType]||"bg-gray-100 text-gray-700",A=()=>{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 ${F}`,children:[D,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:A()})]}),!v&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:u,disabled:p||m,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||m,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:m,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:m,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 ae({title:t,formData:s,setFormData:p,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:m=>p(n=>({...n,name:m.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:m=>p(n=>({...n,stepType:m.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")}),Be.map(m=>e.jsx("option",{value:m,children:v(`workflows.stepTypes.${m}`)},m))]})]}),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:m=>p(n=>({...n,emailTemplateId:m.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(m=>e.jsxs("option",{value:m.id,children:[m.name," (",m.code,")"]},m.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(m=>e.jsx("button",{type:"button",onClick:()=>p(n=>({...n,delayMinutes:m.value})),className:`px-2 py-1 text-xs rounded border transition-colors ${s.delayMinutes===m.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:m.label},m.value))}),e.jsx("input",{type:"number",min:1,value:s.delayMinutes,onChange:m=>p(n=>({...n,delayMinutes:parseInt(m.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:m=>p(n=>({...n,configurationJson:m.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:m=>{const n=s.configurationJson?JSON.parse(s.configurationJson):{};n.url=m.target.value,p(D=>({...D,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:m=>{const n=s.configurationJson?JSON.parse(s.configurationJson):{};n.method=m.target.value,p(D=>({...D,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 We(){const{t}=O.useTranslation("communications"),{id:s}=U.useParams(),p=U.useNavigate(),[i,r]=l.useState(null),[g,u]=l.useState(!0),[k,v]=l.useState(!1),[m,n]=l.useState("info"),[D,F]=l.useState(null),[A,h]=l.useState(null),[f,d]=l.useState({name:"",description:"",priority:0}),C=l.useCallback(async()=>{if(s)try{u(!0),F(null);const P=await B.workflows.getById(s);r(P),d({name:P.name,description:P.description||"",priority:P.priority})}catch(P){console.error("Failed to load workflow:",P),F(t("workflows.edit.errors.loadFailed"))}finally{u(!1)}},[s,t]);l.useEffect(()=>{C()},[C]);const _=async P=>{if(P.preventDefault(),!(!s||!i)){if(i.isSystem){F(t("workflows.edit.errors.cannotEditSystem"));return}v(!0),F(null),h(null);try{const b={name:f.name,description:f.description||void 0,triggerId:i.triggerId,priority:f.priority};await B.workflows.update(s,b),h(t("workflows.edit.success.saved")),C()}catch(b){F(b instanceof Error?b.message:t("workflows.edit.errors.saveFailed"))}finally{v(!1)}}},T=()=>{C()},M=[{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:()=>p(`/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:()=>p(`/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})]})]}),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]}),A&&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"}),A]}),e.jsx("div",{className:"flex gap-1 p-1 bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)]",children:M.map(P=>e.jsxs("button",{onClick:()=>n(P.id),className:`flex items-center gap-2 px-4 py-2 rounded-[var(--radius-button)] font-medium transition-colors ${m===P.id?"bg-[var(--color-accent-600)] text-white":"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,children:[P.icon,e.jsx("span",{className:"hidden sm:inline",children:P.label}),P.id==="steps"&&e.jsx("span",{className:`ml-1 px-1.5 py-0.5 rounded text-xs ${m===P.id?"bg-white/20":"bg-[var(--bg-tertiary)]"}`,children:i.steps.length})]},P.id))}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-[var(--radius-card)] border border-[var(--border-color)] p-4 sm:p-6",children:[m==="info"&&e.jsxs("form",{onSubmit:_,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:P=>d(b=>({...b,name:P.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:P=>d(b=>({...b,description:P.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:P=>d(b=>({...b,priority:parseInt(P.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:()=>p(`/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")]})]})]}),m==="steps"&&s&&e.jsx(_e,{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:()=>p("/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 Ue(){const{t}=O.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=ue;exports.EmailTemplateDetailPage=be;exports.EmailTemplateEditPage=Te;exports.EmailTemplatesListPage=pe;exports.SmsTemplatesListPage=Se;exports.WorkflowCreatePage=Pe;exports.WorkflowDetailPage=$e;exports.WorkflowEditPage=We;exports.WorkflowHistoryPage=Ue;exports.WorkflowsListPage=Le;exports.WorkflowsTriggersPage=Ae;
104
- //# sourceMappingURL=index-DqbVFB1H.js.map
104
+ //# sourceMappingURL=index-CoHIgn5H.js.map