@object-ui/console 3.0.2 → 3.1.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 (242) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/AdvancedChartImpl-Q6xhwCd2.js +7 -0
  3. package/dist/assets/AdvancedChartImpl-Q6xhwCd2.js.br +0 -0
  4. package/dist/assets/AdvancedChartImpl-Q6xhwCd2.js.gz +0 -0
  5. package/dist/assets/AppManagementPage-Bqi2RIF_.js +1 -0
  6. package/dist/assets/AppManagementPage-Bqi2RIF_.js.br +0 -0
  7. package/dist/assets/AppManagementPage-Bqi2RIF_.js.gz +0 -0
  8. package/dist/assets/AuditLogPage-Bhvo34U0.js +1 -0
  9. package/dist/assets/AuditLogPage-Bhvo34U0.js.br +0 -0
  10. package/dist/assets/AuditLogPage-Bhvo34U0.js.gz +0 -0
  11. package/dist/assets/{ChartImpl-2ivTljUi.js → ChartImpl-SceZDRuZ.js} +1 -1
  12. package/dist/assets/ChartImpl-SceZDRuZ.js.br +0 -0
  13. package/dist/assets/ChartImpl-SceZDRuZ.js.gz +0 -0
  14. package/dist/assets/CreateAppPage-BBV1-x1E.js +1 -0
  15. package/dist/assets/CreateAppPage-BBV1-x1E.js.br +0 -0
  16. package/dist/assets/CreateAppPage-BBV1-x1E.js.gz +0 -0
  17. package/dist/assets/DashboardDesignPage-Dsve6QAo.js +1 -0
  18. package/dist/assets/DashboardDesignPage-Dsve6QAo.js.br +0 -0
  19. package/dist/assets/DashboardDesignPage-Dsve6QAo.js.gz +0 -0
  20. package/dist/assets/DashboardView-DxpkEpzI.js +1 -0
  21. package/dist/assets/DashboardView-DxpkEpzI.js.br +0 -0
  22. package/dist/assets/DashboardView-DxpkEpzI.js.gz +0 -0
  23. package/dist/assets/EditAppPage-4REKKtym.js +1 -0
  24. package/dist/assets/EditAppPage-4REKKtym.js.br +0 -0
  25. package/dist/assets/EditAppPage-4REKKtym.js.gz +0 -0
  26. package/dist/assets/{ForgotPasswordPage-DUfjj-wh.js → ForgotPasswordPage-_rDOa2Zl.js} +1 -1
  27. package/dist/assets/KanbanEnhanced-Cy_rTBDD.js +1 -0
  28. package/dist/assets/KanbanEnhanced-Cy_rTBDD.js.br +0 -0
  29. package/dist/assets/KanbanEnhanced-Cy_rTBDD.js.gz +0 -0
  30. package/dist/assets/KanbanImpl-BNUeFn31.js +1 -0
  31. package/dist/assets/KanbanImpl-BNUeFn31.js.br +0 -0
  32. package/dist/assets/KanbanImpl-BNUeFn31.js.gz +0 -0
  33. package/dist/assets/{LoginPage-2CoFvwsL.js → LoginPage-BXP5VJhw.js} +1 -1
  34. package/dist/assets/{MarkdownImpl-BshtTFK2.js → MarkdownImpl-DQVBgcsA.js} +2 -2
  35. package/dist/assets/MarkdownImpl-DQVBgcsA.js.br +0 -0
  36. package/dist/assets/MarkdownImpl-DQVBgcsA.js.gz +0 -0
  37. package/dist/assets/OrgManagementPage-9aUMu-3n.js +1 -0
  38. package/dist/assets/OrgManagementPage-9aUMu-3n.js.br +0 -0
  39. package/dist/assets/OrgManagementPage-9aUMu-3n.js.gz +0 -0
  40. package/dist/assets/PageDesignPage-bfUbiZI-.js +1 -0
  41. package/dist/assets/PageDesignPage-bfUbiZI-.js.br +0 -0
  42. package/dist/assets/PageDesignPage-bfUbiZI-.js.gz +0 -0
  43. package/dist/assets/PageView-BNyUOHBp.js +2 -0
  44. package/dist/assets/PageView-BNyUOHBp.js.br +0 -0
  45. package/dist/assets/PageView-BNyUOHBp.js.gz +0 -0
  46. package/dist/assets/PermissionManagementPage-CfKXMrSe.js +1 -0
  47. package/dist/assets/PermissionManagementPage-CfKXMrSe.js.br +0 -0
  48. package/dist/assets/PermissionManagementPage-CfKXMrSe.js.gz +0 -0
  49. package/dist/assets/ProfilePage-aGYrzo6-.js +1 -0
  50. package/dist/assets/ProfilePage-aGYrzo6-.js.br +0 -0
  51. package/dist/assets/ProfilePage-aGYrzo6-.js.gz +0 -0
  52. package/dist/assets/RecordDetailView-Cbo06TgT.js +1 -0
  53. package/dist/assets/RecordDetailView-Cbo06TgT.js.br +0 -0
  54. package/dist/assets/RecordDetailView-Cbo06TgT.js.gz +0 -0
  55. package/dist/assets/RegisterPage-By5Xlwoy.js +1 -0
  56. package/dist/assets/ReportView-DYDYKXxz.js +1 -0
  57. package/dist/assets/ReportView-DYDYKXxz.js.br +0 -0
  58. package/dist/assets/ReportView-DYDYKXxz.js.gz +0 -0
  59. package/dist/assets/RoleManagementPage-DvuObd50.js +1 -0
  60. package/dist/assets/RoleManagementPage-DvuObd50.js.br +0 -0
  61. package/dist/assets/RoleManagementPage-DvuObd50.js.gz +0 -0
  62. package/dist/assets/SearchResultsPage-BXv9faGO.js +1 -0
  63. package/dist/assets/SearchResultsPage-BXv9faGO.js.br +0 -0
  64. package/dist/assets/SearchResultsPage-BXv9faGO.js.gz +0 -0
  65. package/dist/assets/SystemHubPage-DInbGUIC.js +1 -0
  66. package/dist/assets/SystemHubPage-DInbGUIC.js.br +0 -0
  67. package/dist/assets/SystemHubPage-DInbGUIC.js.gz +0 -0
  68. package/dist/assets/UserManagementPage-DfN7rtzx.js +1 -0
  69. package/dist/assets/UserManagementPage-DfN7rtzx.js.br +0 -0
  70. package/dist/assets/UserManagementPage-DfN7rtzx.js.gz +0 -0
  71. package/dist/assets/data-adapter-Cnk_Mp2r.js +1 -0
  72. package/dist/assets/data-adapter-Cnk_Mp2r.js.br +0 -0
  73. package/dist/assets/data-adapter-Cnk_Mp2r.js.gz +0 -0
  74. package/dist/assets/framework-0M39ZRTM.js +10 -0
  75. package/dist/assets/framework-0M39ZRTM.js.br +0 -0
  76. package/dist/assets/framework-0M39ZRTM.js.gz +0 -0
  77. package/dist/assets/index-B5fEfHjB.css +1 -0
  78. package/dist/assets/index-B5fEfHjB.css.br +0 -0
  79. package/dist/assets/index-B5fEfHjB.css.gz +0 -0
  80. package/dist/assets/index-BlrxLcAr.js +1 -0
  81. package/dist/assets/index-BlrxLcAr.js.br +0 -0
  82. package/dist/assets/index-BlrxLcAr.js.gz +0 -0
  83. package/dist/assets/index-o38_J709.js +9 -0
  84. package/dist/assets/index-o38_J709.js.br +0 -0
  85. package/dist/assets/index-o38_J709.js.gz +0 -0
  86. package/dist/assets/infrastructure-CShH4S9_.js +1 -0
  87. package/dist/assets/infrastructure-CShH4S9_.js.br +0 -0
  88. package/dist/assets/infrastructure-CShH4S9_.js.gz +0 -0
  89. package/dist/assets/maplibre-gl-Hx2FX3ON.js +811 -0
  90. package/dist/assets/maplibre-gl-Hx2FX3ON.js.br +0 -0
  91. package/dist/assets/maplibre-gl-Hx2FX3ON.js.gz +0 -0
  92. package/dist/assets/plugins-core-DBl14Uqc.js +8 -0
  93. package/dist/assets/plugins-core-DBl14Uqc.js.br +0 -0
  94. package/dist/assets/plugins-core-DBl14Uqc.js.gz +0 -0
  95. package/dist/assets/plugins-views-g4Cu3W3w.js +62 -0
  96. package/dist/assets/plugins-views-g4Cu3W3w.js.br +0 -0
  97. package/dist/assets/plugins-views-g4Cu3W3w.js.gz +0 -0
  98. package/dist/assets/ui-components-BuNW5g1I.js +36 -0
  99. package/dist/assets/ui-components-BuNW5g1I.js.br +0 -0
  100. package/dist/assets/ui-components-BuNW5g1I.js.gz +0 -0
  101. package/dist/assets/ui-components-D5YXsttd.css +1 -0
  102. package/dist/assets/ui-components-D5YXsttd.css.br +0 -0
  103. package/dist/assets/ui-components-D5YXsttd.css.gz +0 -0
  104. package/dist/assets/ui-layout-BSKYz8QD.js +1 -0
  105. package/dist/assets/ui-layout-BSKYz8QD.js.br +0 -0
  106. package/dist/assets/ui-layout-BSKYz8QD.js.gz +0 -0
  107. package/dist/assets/{vendor-charts-CSvoW-yB.js → vendor-charts-BbkZFaMp.js} +2 -2
  108. package/dist/assets/vendor-charts-BbkZFaMp.js.br +0 -0
  109. package/dist/assets/vendor-charts-BbkZFaMp.js.gz +0 -0
  110. package/dist/assets/vendor-dndkit-D1_B-HIy.js +5 -0
  111. package/dist/assets/vendor-dndkit-D1_B-HIy.js.br +0 -0
  112. package/dist/assets/vendor-dndkit-D1_B-HIy.js.gz +0 -0
  113. package/dist/assets/vendor-i18n-CikIh7Op.js +9 -0
  114. package/dist/assets/vendor-i18n-CikIh7Op.js.br +0 -0
  115. package/dist/assets/vendor-i18n-CikIh7Op.js.gz +0 -0
  116. package/dist/assets/{vendor-icons-CQ8b-fGy.js → vendor-icons-CsQ20zph.js} +3425 -3535
  117. package/dist/assets/vendor-icons-CsQ20zph.js.br +0 -0
  118. package/dist/assets/vendor-icons-CsQ20zph.js.gz +0 -0
  119. package/dist/assets/vendor-objectstack-aMKO1xRi.js +34 -0
  120. package/dist/assets/vendor-objectstack-aMKO1xRi.js.br +0 -0
  121. package/dist/assets/vendor-objectstack-aMKO1xRi.js.gz +0 -0
  122. package/dist/assets/{vendor-radix-BbeYj_o4.js → vendor-radix-CWYRmupg.js} +1 -1
  123. package/dist/assets/vendor-radix-CWYRmupg.js.br +0 -0
  124. package/dist/assets/vendor-radix-CWYRmupg.js.gz +0 -0
  125. package/dist/assets/vendor-react-BEJ2LWyF.js +60 -0
  126. package/dist/assets/vendor-react-BEJ2LWyF.js.br +0 -0
  127. package/dist/assets/vendor-react-BEJ2LWyF.js.gz +0 -0
  128. package/dist/assets/vendor-ui-utils-tMfURc0Z.js +1 -0
  129. package/dist/assets/vendor-ui-utils-tMfURc0Z.js.br +0 -0
  130. package/dist/assets/vendor-ui-utils-tMfURc0Z.js.gz +0 -0
  131. package/dist/assets/vendor-zod-DxQVy2_o.js +39 -0
  132. package/dist/assets/vendor-zod-DxQVy2_o.js.br +0 -0
  133. package/dist/assets/vendor-zod-DxQVy2_o.js.gz +0 -0
  134. package/dist/index.html +23 -22
  135. package/dist/index.html.br +0 -0
  136. package/dist/index.html.gz +0 -0
  137. package/dist/stats.html +37 -36
  138. package/package.json +49 -46
  139. package/dist/assets/AdvancedChartImpl-DAS1mU9o.js +0 -7
  140. package/dist/assets/AdvancedChartImpl-DAS1mU9o.js.br +0 -0
  141. package/dist/assets/AdvancedChartImpl-DAS1mU9o.js.gz +0 -0
  142. package/dist/assets/AuditLogPage-CyY7VZJW.js +0 -1
  143. package/dist/assets/AuditLogPage-CyY7VZJW.js.br +0 -0
  144. package/dist/assets/AuditLogPage-CyY7VZJW.js.gz +0 -0
  145. package/dist/assets/ChartImpl-2ivTljUi.js.br +0 -0
  146. package/dist/assets/ChartImpl-2ivTljUi.js.gz +0 -0
  147. package/dist/assets/DashboardView-CikFb_lD.js +0 -1
  148. package/dist/assets/DashboardView-CikFb_lD.js.br +0 -0
  149. package/dist/assets/DashboardView-CikFb_lD.js.gz +0 -0
  150. package/dist/assets/KanbanEnhanced-CwlMhI0l.js +0 -1
  151. package/dist/assets/KanbanEnhanced-CwlMhI0l.js.br +0 -0
  152. package/dist/assets/KanbanEnhanced-CwlMhI0l.js.gz +0 -0
  153. package/dist/assets/KanbanImpl-BsMtStI7.js +0 -1
  154. package/dist/assets/KanbanImpl-BsMtStI7.js.br +0 -0
  155. package/dist/assets/KanbanImpl-BsMtStI7.js.gz +0 -0
  156. package/dist/assets/MarkdownImpl-BshtTFK2.js.br +0 -0
  157. package/dist/assets/MarkdownImpl-BshtTFK2.js.gz +0 -0
  158. package/dist/assets/OrgManagementPage-BJt5Iiun.js +0 -1
  159. package/dist/assets/OrgManagementPage-BJt5Iiun.js.br +0 -0
  160. package/dist/assets/OrgManagementPage-BJt5Iiun.js.gz +0 -0
  161. package/dist/assets/PageView-CQP2T84v.js +0 -1
  162. package/dist/assets/PageView-CQP2T84v.js.br +0 -0
  163. package/dist/assets/PageView-CQP2T84v.js.gz +0 -0
  164. package/dist/assets/ProfilePage-MVUfKMrp.js +0 -1
  165. package/dist/assets/ProfilePage-MVUfKMrp.js.br +0 -0
  166. package/dist/assets/ProfilePage-MVUfKMrp.js.gz +0 -0
  167. package/dist/assets/RecordDetailView-IO2ShB0a.js +0 -1
  168. package/dist/assets/RecordDetailView-IO2ShB0a.js.br +0 -0
  169. package/dist/assets/RecordDetailView-IO2ShB0a.js.gz +0 -0
  170. package/dist/assets/RegisterPage-B9itUVYp.js +0 -1
  171. package/dist/assets/ReportView-BfR7RjL9.js +0 -1
  172. package/dist/assets/ReportView-BfR7RjL9.js.br +0 -0
  173. package/dist/assets/ReportView-BfR7RjL9.js.gz +0 -0
  174. package/dist/assets/RoleManagementPage-BRqaeF_L.js +0 -1
  175. package/dist/assets/RoleManagementPage-BRqaeF_L.js.br +0 -0
  176. package/dist/assets/RoleManagementPage-BRqaeF_L.js.gz +0 -0
  177. package/dist/assets/SearchResultsPage-DaxRxhBY.js +0 -1
  178. package/dist/assets/SearchResultsPage-DaxRxhBY.js.br +0 -0
  179. package/dist/assets/SearchResultsPage-DaxRxhBY.js.gz +0 -0
  180. package/dist/assets/UserManagementPage-DOH6ql6-.js +0 -1
  181. package/dist/assets/UserManagementPage-DOH6ql6-.js.br +0 -0
  182. package/dist/assets/UserManagementPage-DOH6ql6-.js.gz +0 -0
  183. package/dist/assets/ViewDesignerPage-BbwrZa9D.js +0 -1
  184. package/dist/assets/ViewDesignerPage-BbwrZa9D.js.br +0 -0
  185. package/dist/assets/ViewDesignerPage-BbwrZa9D.js.gz +0 -0
  186. package/dist/assets/data-adapter-CIsDmDZ2.js +0 -1
  187. package/dist/assets/data-adapter-CIsDmDZ2.js.br +0 -0
  188. package/dist/assets/data-adapter-CIsDmDZ2.js.gz +0 -0
  189. package/dist/assets/framework-mHWN965c.js +0 -10
  190. package/dist/assets/framework-mHWN965c.js.br +0 -0
  191. package/dist/assets/framework-mHWN965c.js.gz +0 -0
  192. package/dist/assets/index-5NGcxsNI.js +0 -56
  193. package/dist/assets/index-5NGcxsNI.js.br +0 -0
  194. package/dist/assets/index-5NGcxsNI.js.gz +0 -0
  195. package/dist/assets/index-CUnVdETN.css +0 -1
  196. package/dist/assets/index-CUnVdETN.css.br +0 -0
  197. package/dist/assets/index-CUnVdETN.css.gz +0 -0
  198. package/dist/assets/infrastructure-Di0WqY4l.js +0 -1
  199. package/dist/assets/infrastructure-Di0WqY4l.js.br +0 -0
  200. package/dist/assets/infrastructure-Di0WqY4l.js.gz +0 -0
  201. package/dist/assets/maplibre-gl-D2AsLM0J.js +0 -811
  202. package/dist/assets/maplibre-gl-D2AsLM0J.js.br +0 -0
  203. package/dist/assets/maplibre-gl-D2AsLM0J.js.gz +0 -0
  204. package/dist/assets/plugins-core-HuzSJDPK.js +0 -4
  205. package/dist/assets/plugins-core-HuzSJDPK.js.br +0 -0
  206. package/dist/assets/plugins-core-HuzSJDPK.js.gz +0 -0
  207. package/dist/assets/plugins-views-JvEQp7xT.js +0 -60
  208. package/dist/assets/plugins-views-JvEQp7xT.js.br +0 -0
  209. package/dist/assets/plugins-views-JvEQp7xT.js.gz +0 -0
  210. package/dist/assets/ui-components-CseD2Dpn.js +0 -31
  211. package/dist/assets/ui-components-CseD2Dpn.js.br +0 -0
  212. package/dist/assets/ui-components-CseD2Dpn.js.gz +0 -0
  213. package/dist/assets/ui-components-GrNdJOi1.css +0 -1
  214. package/dist/assets/ui-components-GrNdJOi1.css.br +0 -0
  215. package/dist/assets/ui-components-GrNdJOi1.css.gz +0 -0
  216. package/dist/assets/ui-layout-CF_1bNSv.js +0 -1
  217. package/dist/assets/ui-layout-CF_1bNSv.js.br +0 -0
  218. package/dist/assets/ui-layout-CF_1bNSv.js.gz +0 -0
  219. package/dist/assets/vendor-charts-CSvoW-yB.js.br +0 -0
  220. package/dist/assets/vendor-charts-CSvoW-yB.js.gz +0 -0
  221. package/dist/assets/vendor-dndkit-DRGpK6sP.js +0 -5
  222. package/dist/assets/vendor-dndkit-DRGpK6sP.js.br +0 -0
  223. package/dist/assets/vendor-dndkit-DRGpK6sP.js.gz +0 -0
  224. package/dist/assets/vendor-i18n-D5KbMT7w.js +0 -9
  225. package/dist/assets/vendor-i18n-D5KbMT7w.js.br +0 -0
  226. package/dist/assets/vendor-i18n-D5KbMT7w.js.gz +0 -0
  227. package/dist/assets/vendor-icons-CQ8b-fGy.js.br +0 -0
  228. package/dist/assets/vendor-icons-CQ8b-fGy.js.gz +0 -0
  229. package/dist/assets/vendor-objectstack-BbgElG6O.js +0 -37
  230. package/dist/assets/vendor-objectstack-BbgElG6O.js.br +0 -0
  231. package/dist/assets/vendor-objectstack-BbgElG6O.js.gz +0 -0
  232. package/dist/assets/vendor-radix-BbeYj_o4.js.br +0 -0
  233. package/dist/assets/vendor-radix-BbeYj_o4.js.gz +0 -0
  234. package/dist/assets/vendor-react-Dy_xkBQQ.js +0 -60
  235. package/dist/assets/vendor-react-Dy_xkBQQ.js.br +0 -0
  236. package/dist/assets/vendor-react-Dy_xkBQQ.js.gz +0 -0
  237. package/dist/assets/vendor-ui-utils-h6yAcIi9.js +0 -1
  238. package/dist/assets/vendor-ui-utils-h6yAcIi9.js.br +0 -0
  239. package/dist/assets/vendor-ui-utils-h6yAcIi9.js.gz +0 -0
  240. package/dist/assets/vendor-zod-Dpl-cylz.js +0 -39
  241. package/dist/assets/vendor-zod-Dpl-cylz.js.br +0 -0
  242. package/dist/assets/vendor-zod-Dpl-cylz.js.gz +0 -0
@@ -0,0 +1,9 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChartImpl-SceZDRuZ.js","assets/vendor-react-BEJ2LWyF.js","assets/vendor-charts-BbkZFaMp.js","assets/vendor-ui-utils-tMfURc0Z.js","assets/vendor-i18n-CikIh7Op.js","assets/AdvancedChartImpl-Q6xhwCd2.js","assets/KanbanImpl-BNUeFn31.js","assets/vendor-dndkit-D1_B-HIy.js","assets/ui-components-BuNW5g1I.js","assets/framework-0M39ZRTM.js","assets/vendor-objectstack-aMKO1xRi.js","assets/vendor-zod-DxQVy2_o.js","assets/vendor-icons-CsQ20zph.js","assets/vendor-radix-CWYRmupg.js","assets/infrastructure-CShH4S9_.js","assets/ui-components-D5YXsttd.css","assets/KanbanEnhanced-Cy_rTBDD.js","assets/plugins-core-DBl14Uqc.js","assets/plugins-views-g4Cu3W3w.js","assets/plugins-views-P3eB-els.css","assets/RecordDetailView-Cbo06TgT.js","assets/data-adapter-Cnk_Mp2r.js","assets/ui-layout-BSKYz8QD.js","assets/DashboardView-DxpkEpzI.js","assets/PageView-BNyUOHBp.js","assets/ReportView-DYDYKXxz.js","assets/SearchResultsPage-BXv9faGO.js","assets/CreateAppPage-BBV1-x1E.js","assets/index-BlrxLcAr.js","assets/EditAppPage-4REKKtym.js","assets/PageDesignPage-bfUbiZI-.js","assets/DashboardDesignPage-Dsve6QAo.js","assets/LoginPage-BXP5VJhw.js","assets/RegisterPage-By5Xlwoy.js","assets/ForgotPasswordPage-_rDOa2Zl.js","assets/SystemHubPage-DInbGUIC.js","assets/AppManagementPage-Bqi2RIF_.js","assets/UserManagementPage-DfN7rtzx.js","assets/systemObjects-DSpePIIy.js","assets/OrgManagementPage-9aUMu-3n.js","assets/RoleManagementPage-DvuObd50.js","assets/PermissionManagementPage-CfKXMrSe.js","assets/AuditLogPage-Bhvo34U0.js","assets/ProfilePage-aGYrzo6-.js","assets/maplibre-gl-Hx2FX3ON.js","assets/MarkdownImpl-DQVBgcsA.js"])))=>i.map(i=>d[i]);
2
+ import{r as i,j as t,f as Oe,L as we,B as ae,u as Kn,h as We,i as ss,k as rs,l as ct,m as z,N as He,c as Yn,n as os}from"./vendor-react-BEJ2LWyF.js";import{aP as Jn,aE as is,aF as ls,aw as Ae,aB as Te,w as Ce,x as Se,aC as ye,y as De,aQ as ln,z as ie,aK as it,aH as cs,at as Le,au as Xe,av as $e,aG as ds,aD as us,aI as ms,aR as cn,aS as dn,aT as un,aU as ps,B as Y,c as q,S as hs,aV as gs,h as fs,i as xs,j as bs,G as js,as as ys,ax as vs,aW as ws,aX as Ns,aY as Cs,aZ as Ss,a_ as Ds,a$ as ks,b0 as Fs,b1 as _s,b2 as Es,b3 as As,b4 as ve,b5 as pe,b6 as bt,b7 as mt,b8 as pt,b9 as ht,ba as Ts,ap as J,p as Ge,N as ke,P as Vs,J as Rs,K as Ms,bb as Os,$ as Zn,a0 as Qn,a1 as Xn,a2 as ea,a3 as Ne,aN as H,aa as X,bc as Ve,ab as Gt,aJ as Ps,ac as Is,aL as Ls,aM as $s,D as ta,O as na,l as aa,n as sa,o as ra,bd as mn}from"./ui-components-BuNW5g1I.js";import{V as zs,O as pn,M as Bs}from"./plugins-core-DBl14Uqc.js";import{E as Kt,t as Us,C as Z,o as Hs,c as Yt,s as Pe,f as Ie,h as Ke,i as Ye,v as qs,w as oa,S as Ws,x as Gs,y as Ks}from"./framework-0M39ZRTM.js";import{b as K,T as Ys,a as ia}from"./vendor-ui-utils-tMfURc0Z.js";import{c as gt,u as me,b as la,d as ca,g as hn,A as jt,P as Js,e as yt,I as Zs}from"./infrastructure-CShH4S9_.js";import{O as da}from"./data-adapter-Cnk_Mp2r.js";import{N as Qs,A as Xs}from"./ui-layout-BSKYz8QD.js";import{k as gn,aQ as Re,m as Fe,at as ua,n as et,aw as er,S as qe,a as Je,aa as tr,Q as ma,aF as nr,aR as ar,w as be,aS as Ct,aT as St,aU as pa,as as sr,aV as fn,L as dt,g as Jt,aI as xn,aP as rr,aB as or,l as ir,C as Dt,aW as lr,aX as ha,ak as cr,aY as ga,T as fa,r as dr,aZ as ur,b as xa,j as ba,d as mr,_ as pr,a_ as hr,G as lt,J as gr,K as fr,ar as kt,a$ as xr,av as br,V as jr,b0 as yr,ah as vr,ai as wr,b1 as Nr,R as ja,X as Cr,c as Sr,O as Dr,I as kr,b2 as Fr,b3 as _r}from"./vendor-icons-CsQ20zph.js";import{u as ya,L as Er,D as Ar,R as Tr,M as Vr}from"./plugins-views-g4Cu3W3w.js";import{u as Rr,a as bn,K as Mr,P as Or,b as Pr,D as Ir,c as Lr,S as $r,v as zr,d as Br,C as Ur}from"./vendor-dndkit-D1_B-HIy.js";import{G as Hr}from"./vendor-objectstack-aMKO1xRi.js";import{o as Zt,s as te,_ as qr,t as Wr,n as vt}from"./vendor-zod-DxQVy2_o.js";import"./vendor-radix-CWYRmupg.js";import"./vendor-i18n-CikIh7Op.js";import"./vendor-charts-BbkZFaMp.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const l of r.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function a(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(s){if(s.ep)return;s.ep=!0;const r=a(s);fetch(s.href,r)}})();const va=i.createContext(null);function ze(e){return e&&typeof e=="object"&&"items"in e&&Array.isArray(e.items)?e.items:[]}async function jn(e){const n=e.getClient(),[a,o,s,r,l]=await Promise.all([n.meta.getItems("app").catch(()=>({items:[]})),n.meta.getItems("object").catch(()=>({items:[]})),n.meta.getItems("dashboard").catch(()=>({items:[]})),n.meta.getItems("report").catch(()=>({items:[]})),n.meta.getItems("page").catch(()=>({items:[]}))]);return{apps:ze(a),objects:ze(o),dashboards:ze(s),reports:ze(r),pages:ze(l)}}function Gr({children:e,adapter:n}){const[a,o]=i.useState({apps:[],objects:[],dashboards:[],reports:[],pages:[],loading:!0,error:null}),s=i.useRef(n);s.current=n;const r=i.useCallback(async()=>{o(c=>({...c,loading:!0,error:null}));try{const c=await jn(s.current);o({...c,loading:!1,error:null})}catch(c){o(d=>({...d,loading:!1,error:c instanceof Error?c:new Error(String(c))}))}},[]);i.useEffect(()=>{let c=!1;return(async()=>{try{const d=await jn(n);c||o({...d,loading:!1,error:null})}catch(d){c||o(u=>({...u,loading:!1,error:d instanceof Error?d:new Error(String(d))}))}})(),()=>{c=!0}},[n]);const l={...a,refresh:r};return t.jsx(va.Provider,{value:l,children:e})}function Ze(){const e=i.useContext(va);if(!e)throw new Error("useMetadata must be used within a <MetadataProvider>");return e}const wa=i.createContext(null);function Qe(){return i.useContext(wa)}function Kr({children:e,adapter:n}){const[a,o]=i.useState(n??null);return i.useEffect(()=>{if(n){o(n);return}let s=!1;async function r(){try{const l=new da({baseUrl:"",autoReconnect:!0,maxReconnectAttempts:5,reconnectDelay:1e3,cache:{maxSize:50,ttl:3e5}});await l.connect(),s||o(l)}catch(l){s||console.error("[Console] Failed to initialize:",l)}}return r(),()=>{s=!0}},[n]),t.jsx(wa.Provider,{value:a,children:e})}const Na=i.createContext(null);function Yr({children:e,user:n={},app:a={},data:o={}}){const s=i.useMemo(()=>{const r={user:n,app:a,data:o},l=new Kt(r);return{user:n,app:a,data:o,evaluator:l}},[n,a,o]);return t.jsx(Na.Provider,{value:s,children:e})}function Ca(){const e=i.useContext(Na);if(!e){const n={user:{},app:{},data:{}};return{...n,evaluator:new Kt(n)}}return e}function ut(e,n){if(e==null||e===!0||e==="true")return!0;if(e===!1||e==="false")return!1;if(typeof e=="string"&&e.includes("${"))try{return n.evaluateCondition(e)}catch{return!0}return!0}const Sa="objectui-recent-items",Jr=8;function yn(){try{const e=localStorage.getItem(Sa);return e?JSON.parse(e):[]}catch{return[]}}function vn(e){try{localStorage.setItem(Sa,JSON.stringify(e))}catch{}}function Da(){const[e,n]=i.useState(yn);i.useEffect(()=>{n(yn())},[]);const a=i.useCallback(s=>{n(r=>{const l=r.filter(d=>d.id!==s.id),c=[{...s,visitedAt:new Date().toISOString()},...l].slice(0,Jr);return vn(c),c})},[]),o=i.useCallback(()=>{n([]),vn([])},[]);return{recentItems:e,addRecentItem:a,clearRecentItems:o}}const ka="objectui-favorites",wn=20;function Nn(){try{const e=localStorage.getItem(ka);return e?JSON.parse(e):[]}catch{return[]}}function tt(e){try{localStorage.setItem(ka,JSON.stringify(e))}catch{}}function Zr(){const[e,n]=i.useState(Nn);i.useEffect(()=>{n(Nn())},[]);const a=i.useCallback(c=>{n(d=>{if(d.some(m=>m.id===c.id))return d;const u=[{...c,favoritedAt:new Date().toISOString()},...d].slice(0,wn);return tt(u),u})},[]),o=i.useCallback(c=>{n(d=>{const u=d.filter(m=>m.id!==c);return tt(u),u})},[]),s=i.useCallback(c=>{n(d=>{const m=d.some(p=>p.id===c.id)?d.filter(p=>p.id!==c.id):[{...c,favoritedAt:new Date().toISOString()},...d].slice(0,wn);return tt(m),m})},[]),r=i.useCallback(c=>e.some(d=>d.id===c),[e]),l=i.useCallback(()=>{n([]),tt([])},[]);return{favorites:e,addFavorite:a,removeFavorite:o,toggleFavorite:s,isFavorite:r,clearFavorites:l}}const Fa="objectui-nav-pins",Qr=20;function Cn(){try{const e=localStorage.getItem(Fa);if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Sn(e){try{localStorage.setItem(Fa,JSON.stringify(e))}catch{}}function Xr(){const[e,n]=i.useState(Cn);i.useEffect(()=>{n(Cn())},[]);const a=i.useCallback((l,c)=>{n(d=>{const u=d.filter(p=>p!==l),m=c?[...u,l].slice(0,Qr):u;return Sn(m),m})},[]),o=i.useCallback(l=>e.includes(l),[e]),s=i.useCallback(l=>l.map(c=>{const d=e.includes(c.id),u=c.children?.length?s(c.children):c.children;return d!==(c.pinned??!1)||u!==c.children?{...c,pinned:d,children:u}:c}),[e]),r=i.useCallback(()=>{n([]),Sn([])},[]);return{pinnedIds:e,togglePin:a,isPinned:o,applyPins:s,clearPins:r}}function ee(e,n){if(e!=null){if(typeof e=="string")return e;if(n){const a=n(e.key,{defaultValue:e.defaultValue,...e.params});if(a&&a!==e.key)return a}return e.defaultValue||e.key}}function eo(e){const n=`objectui-nav-order-${e}`,[a,o]=i.useState(()=>{try{const c=localStorage.getItem(n);if(!c)return{};const d=JSON.parse(c);if(typeof d!="object"||d===null||Array.isArray(d))return{};const u={};for(const[m,p]of Object.entries(d))Array.isArray(p)&&p.every(g=>typeof g=="string")&&(u[m]=p);return u}catch{return{}}}),s=i.useCallback(c=>{o(c);try{localStorage.setItem(n,JSON.stringify(c))}catch{}},[n]),r=i.useCallback(c=>{const d=a.__root__;if(!d)return c;const u=new Map(c.map(p=>[p.id,p])),m=[];for(const p of d){const g=u.get(p);g&&(m.push(g),u.delete(p))}return u.forEach(p=>m.push(p)),m},[a]),l=i.useCallback(c=>{const d=c.map(u=>u.id);s({...a,__root__:d})},[a,s]);return{applyOrder:r,handleReorder:l}}function Be(e){if(!e)return Re;if(be[e])return be[e];const n=e.split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join("");return be[n]?be[n]:Re}function to({activeAppName:e,onAppChange:n}){const{isMobile:a}=Jn(),{user:o,signOut:s}=gt(),r=Oe(),{t:l}=me(),{objectLabel:c}=la();i.useEffect(()=>{let W=0;const Q=le=>{W=le.touches[0].clientX},se=le=>{const ce=le.changedTouches[0].clientX-W;W<30&&ce>50&&a&&document.querySelector('[data-sidebar="trigger"]')?.dispatchEvent(new MouseEvent("click",{bubbles:!0}))};return document.addEventListener("touchstart",Q,{passive:!0}),document.addEventListener("touchend",se,{passive:!0}),()=>{document.removeEventListener("touchstart",Q),document.removeEventListener("touchend",se)}},[a]);const{recentItems:d}=Da(),{favorites:u,removeFavorite:m}=Zr(),{apps:p}=Ze(),x=(p||[]).filter(D=>D.active!==!1),h=x.find(D=>D.name===e)||x[0],F=h?.branding?.logo,y=h?.branding?.primaryColor,{applyOrder:k,handleReorder:E}=eo(e),{togglePin:A,applyPins:f}=Xr(),N=h?.areas||[],[b,j]=i.useState(()=>N.length>0?N[0].id:null);i.useEffect(()=>{N.length>0?j(D=>N.some(G=>G.id===D)?D:N[0].id):j(null)},[e,N.length]);const R=N.find(D=>D.id===b)?.navigation||h?.navigation||[],S=i.useMemo(()=>{const D=k(R);return f(D)},[R,k,f]),[M,v]=i.useState(""),[_,T]=i.useState(!1),{evaluator:L}=Ca(),U=i.useCallback(D=>ut(D,L),[L]),{can:P}=ca(),$=i.useCallback(D=>D.every(G=>{const W=G.split(":"),[Q,se]=W.length>=2?[W[0],W[1]]:[G,"read"];return P(Q,se)}),[P]),O=h?`/apps/${e}`:"",I=i.useMemo(()=>[{id:"sys-settings",label:"System Settings",type:"url",url:"/system",icon:"settings"},{id:"sys-apps",label:"Applications",type:"url",url:"/system/apps",icon:"layout-grid"},{id:"sys-users",label:"Users",type:"url",url:"/system/users",icon:"users"},{id:"sys-orgs",label:"Organizations",type:"url",url:"/system/organizations",icon:"building-2"},{id:"sys-roles",label:"Roles",type:"url",url:"/system/roles",icon:"shield"},{id:"sys-create-app",label:"Create App",type:"url",url:"/create-app",icon:"plus"}],[]);return t.jsxs(t.Fragment,{children:[t.jsxs(is,{collapsible:"icon",children:[t.jsx(ls,{children:t.jsx(Ae,{children:t.jsx(Te,{children:h?t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsxs(ye,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[t.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground",style:y?{backgroundColor:y}:void 0,children:F?t.jsx("img",{src:F,alt:ee(h.label,l),className:"size-6 object-contain"}):i.createElement(Be(h.icon),{className:"size-4"})}),t.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[t.jsx("span",{className:"truncate font-semibold",children:ee(h.label,l)}),t.jsx("span",{className:"truncate text-xs",children:ee(h.description,l)||`${x.length} Apps Available`})]}),t.jsx(gn,{className:"ml-auto"})]})}),t.jsxs(De,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",align:"start",side:a?"bottom":"right",sideOffset:4,children:[t.jsx(ln,{className:"text-xs text-muted-foreground",children:"Switch Application"}),x.map(D=>t.jsxs(ie,{onClick:()=>n(D.name),className:"gap-2 p-2",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-sm border",children:D.icon?i.createElement(Be(D.icon),{className:"size-3"}):t.jsx(Re,{className:"size-3"})}),ee(D.label,l),h.name===D.name&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]},D.name)),t.jsx(it,{}),t.jsxs(ie,{className:"gap-2 p-2",onClick:()=>r(`/apps/${e}/create-app`),"data-testid":"add-app-btn",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border bg-background",children:t.jsx(Fe,{className:"size-4"})}),t.jsx("div",{className:"font-medium text-muted-foreground",children:"Add App"})]}),t.jsxs(ie,{className:"gap-2 p-2",onClick:()=>r(`/apps/${e}/edit-app/${e}`),"data-testid":"edit-app-btn",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border bg-background",children:t.jsx(ua,{className:"size-4"})}),t.jsx("div",{className:"font-medium text-muted-foreground",children:"Edit App"})]}),t.jsxs(ie,{className:"gap-2 p-2",onClick:()=>r(`/apps/${e}/system/apps`),"data-testid":"manage-all-apps-btn",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border bg-background",children:t.jsx(et,{className:"size-4"})}),t.jsx("div",{className:"font-medium text-muted-foreground",children:"Manage All Apps"})]})]})]}):t.jsxs(ye,{size:"lg",onClick:()=>r("/system"),"data-testid":"system-sidebar-header",children:[t.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:t.jsx(et,{className:"size-4"})}),t.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[t.jsx("span",{className:"truncate font-semibold",children:"System Console"}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:"No apps configured"})]})]})})})}),t.jsx(cs,{children:h?t.jsxs(t.Fragment,{children:[N.length>1&&t.jsxs(Le,{children:[t.jsxs(Xe,{className:"flex items-center gap-1.5",children:[t.jsx(er,{className:"h-3.5 w-3.5"}),"Area"]}),t.jsx($e,{children:t.jsx(Ae,{children:N.map(D=>{const G=Be(D.icon),W=D.id===b;return t.jsx(Te,{children:t.jsxs(ye,{isActive:W,tooltip:D.label,onClick:()=>j(D.id),children:[t.jsx(G,{className:"h-4 w-4"}),t.jsx("span",{children:D.label})]})},D.id)})})})]}),t.jsx(Le,{className:"py-0",children:t.jsxs($e,{className:"relative",children:[t.jsx(qe,{className:"pointer-events-none absolute left-2 top-1/2 size-4 -translate-y-1/2 select-none opacity-70"}),t.jsx(ds,{placeholder:"Search navigation...",value:M,onChange:D=>v(D.target.value),className:"pl-8"})]})}),t.jsx(Qs,{items:S,basePath:O,evaluateVisibility:U,checkPermission:$,searchQuery:M,enablePinning:!0,onPinToggle:A,enableReorder:!0,onReorder:E,resolveObjectLabel:(D,G)=>c({name:D,label:G}),t:l}),d.length>0&&t.jsxs(Le,{children:[t.jsxs(Xe,{className:"flex items-center gap-1.5 cursor-pointer select-none",onClick:()=>T(D=>!D),children:[t.jsx(Je,{className:`h-3 w-3 transition-transform duration-150 ${_?"rotate-90":""}`}),t.jsx(tr,{className:"h-3.5 w-3.5"}),"Recent"]}),_&&t.jsx($e,{children:t.jsx(Ae,{children:d.slice(0,5).map(D=>t.jsx(Te,{children:t.jsx(ye,{asChild:!0,tooltip:D.label,children:t.jsxs(we,{to:D.href,children:[t.jsx("span",{className:"text-muted-foreground",children:D.type==="dashboard"?"📊":D.type==="report"?"📈":"📄"}),t.jsx("span",{className:"truncate",children:D.label})]})})},D.id))})})]}),u.length>0&&t.jsxs(Le,{children:[t.jsxs(Xe,{className:"flex items-center gap-1.5",children:[t.jsx(ma,{className:"h-3.5 w-3.5"}),"Favorites"]}),t.jsx($e,{children:t.jsx(Ae,{children:u.slice(0,8).map(D=>t.jsxs(Te,{children:[t.jsx(ye,{asChild:!0,tooltip:D.label,children:t.jsxs(we,{to:D.href,children:[t.jsx("span",{className:"text-muted-foreground",children:D.type==="dashboard"?"📊":D.type==="report"?"📈":D.type==="page"?"📄":"📋"}),t.jsx("span",{className:"truncate",children:D.label})]})}),t.jsx(us,{showOnHover:!0,onClick:G=>{G.stopPropagation(),m(D.id)},"aria-label":`Remove ${D.label} from favorites`,children:t.jsx(nr,{className:"h-3 w-3"})})]},D.id))})})]})]}):t.jsxs(Le,{"data-testid":"system-fallback-nav",children:[t.jsxs(Xe,{className:"flex items-center gap-1.5",children:[t.jsx(et,{className:"h-3.5 w-3.5"}),"System"]}),t.jsx($e,{children:t.jsx(Ae,{children:I.map(D=>{const G=Be(D.icon);return t.jsx(Te,{children:t.jsx(ye,{asChild:!0,tooltip:D.label,children:t.jsxs(we,{to:D.url||"/system",children:[t.jsx(G,{className:"h-4 w-4"}),t.jsx("span",{children:D.label})]})})},D.id)})})})]})}),t.jsx(ms,{children:t.jsx(Ae,{children:t.jsx(Te,{children:t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsxs(ye,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[t.jsxs(cn,{className:"h-8 w-8 rounded-lg",children:[t.jsx(dn,{src:o?.image??"/avatars/user.jpg",alt:o?.name??"User"}),t.jsx(un,{className:"rounded-lg bg-primary text-primary-foreground",children:hn(o)})]}),t.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[t.jsx("span",{className:"truncate font-semibold",children:o?.name??"User"}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:o?.email??""})]}),t.jsx(gn,{className:"ml-auto size-4"})]})}),t.jsxs(De,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",side:a?"bottom":"right",align:"end",sideOffset:4,children:[t.jsx(ln,{className:"p-0 font-normal",children:t.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[t.jsxs(cn,{className:"h-8 w-8 rounded-lg",children:[t.jsx(dn,{src:o?.image??"/avatars/user.jpg",alt:o?.name??"User"}),t.jsx(un,{className:"rounded-lg bg-primary text-primary-foreground",children:hn(o)})]}),t.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[t.jsx("span",{className:"truncate font-semibold",children:o?.name??"User"}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:o?.email??""})]})]})}),t.jsx(it,{}),t.jsx(ps,{children:t.jsxs(ie,{onClick:()=>r(h?`/apps/${e}/system`:"/system"),children:[t.jsx(et,{className:"mr-2 h-4 w-4"}),"Settings"]})}),t.jsx(it,{}),t.jsxs(ie,{className:"text-destructive focus:text-destructive",onClick:()=>s(),children:[t.jsx(ar,{className:"mr-2 h-4 w-4"}),"Log out"]})]})]})})})})]}),a&&t.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom",children:(h?R:I).filter(D=>D.type!=="group").slice(0,5).map(D=>{const G=Be(D.icon),W=h?`/apps/${e}`:"";let Q=D.url||"#";return D.type==="object"?(Q=`${W}/${D.objectName}`,D.viewName&&(Q+=`/view/${D.viewName}`)):D.type==="dashboard"?Q=D.dashboardName?`${W}/dashboard/${D.dashboardName}`:"#":D.type==="page"&&(Q=D.pageName?`${W}/page/${D.pageName}`:"#"),t.jsxs(we,{to:Q,className:"flex flex-col items-center gap-0.5 px-2 py-1.5 text-muted-foreground hover:text-foreground transition-colors min-w-[44px] min-h-[44px] justify-center",children:[t.jsx(G,{className:"h-5 w-5"}),t.jsx("span",{className:"text-[10px] truncate max-w-[60px]",children:ee(D.label,l)})]},D.id)})})]})}function no(e){const{url:n,channel:a,autoReconnect:o=!0,reconnectInterval:s=1e3,maxReconnectAttempts:r=10,authToken:l}=e,[c,d]=i.useState("disconnected"),[u,m]=i.useState(null),[p,g]=i.useState([]),[x,h]=i.useState(null),F=i.useRef(null),y=i.useRef(0),k=i.useRef(null),E=i.useRef(new Map),A=i.useRef([]),f=i.useRef(!0),N=i.useRef(!1),b=i.useCallback(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null)},[]),j=i.useCallback(_=>{for(;A.current.length>0;){const T=A.current.shift(),L={type:T.type,channel:a,data:T.data,timestamp:new Date().toISOString()};_.send(JSON.stringify(L))}},[a]),w=i.useCallback(()=>{if(typeof WebSocket>"u"){h(new Error("WebSocket is not available in this environment")),d("error");return}if(!n){h(new Error("WebSocket URL is required")),d("error");return}try{const L=new URL(n);if(L.protocol!=="ws:"&&L.protocol!=="wss:"){h(new Error("WebSocket URL must use ws: or wss: protocol")),d("error");return}}catch{h(new Error("Invalid WebSocket URL")),d("error");return}F.current&&(N.current=!0,F.current.close(),F.current=null),N.current=!1,d("connecting"),h(null);const _=l?`${n}?token=${encodeURIComponent(l)}&channel=${encodeURIComponent(a)}`:`${n}?channel=${encodeURIComponent(a)}`;let T;try{T=new WebSocket(_)}catch(L){if(!f.current)return;const U=L instanceof Error?L:new Error("Failed to create WebSocket connection");h(U),d("error");return}F.current=T,T.onopen=()=>{f.current&&(d("connected"),h(null),y.current=0,j(T))},T.onmessage=L=>{if(f.current)try{const U=JSON.parse(String(L.data));if(U.channel!==a)return;m(U),g($=>[...$,U]);const P=E.current.get(U.type);P&&P.forEach($=>$(U.data))}catch{}},T.onerror=()=>{f.current&&(h(new Error("WebSocket connection error")),d("error"))},T.onclose=()=>{if(f.current){if(F.current=null,N.current){d("disconnected");return}if(o&&y.current<r){d("reconnecting");const L=Math.min(s*Math.pow(2,y.current),3e4);y.current+=1,k.current=setTimeout(()=>{f.current&&w()},L)}else d("disconnected")}}},[n,a,l,o,s,r,j]),R=i.useCallback(()=>{b(),N.current=!0,y.current=0,F.current&&(F.current.close(),F.current=null),d("disconnected")},[b]),S=i.useCallback(()=>{b(),y.current=0,w()},[w,b]),M=i.useCallback((_,T)=>{const L=F.current;if(L&&L.readyState===WebSocket.OPEN){const U={type:_,channel:a,data:T,timestamp:new Date().toISOString()};L.send(JSON.stringify(U))}else A.current.push({type:_,data:T})},[a]),v=i.useCallback((_,T)=>(E.current.has(_)||E.current.set(_,new Set),E.current.get(_).add(T),()=>{const L=E.current.get(_);L&&(L.delete(T),L.size===0&&E.current.delete(_))}),[]);return i.useEffect(()=>(f.current=!0,n&&w(),()=>{f.current=!1,b(),N.current=!0,F.current&&(F.current.close(),F.current=null)}),[n,a,l]),{connectionState:c,isConnected:c==="connected",lastMessage:u,messages:p,send:M,subscribe:v,disconnect:R,reconnect:S,error:x}}let Dn=0;function ao(){return Dn+=1,`conflict-${Date.now()}-${Dn}`}let kn=0;function nt(){return kn+=1,`ver-${Date.now()}-${kn}`}function so(e,n,a){const[o,s]=i.useState([]),[r,l]=i.useState([]),c=i.useMemo(()=>o.length===0?0:o[o.length-1].version,[o]),d=r.length>0,u=i.useCallback((y,k)=>{s(E=>{const A=E.length===0?1:E[E.length-1].version+1,f={id:nt(),version:A,timestamp:new Date().toISOString(),userId:e,userName:n,changes:y,message:k};return[...E,f]})},[e,n]),m=i.useCallback((y,k,E)=>{l(A=>{const f=A.find(b=>b.id===y);if(!f)return A;let N;switch(k){case"local":N=f.localValue;break;case"remote":N=f.remoteValue;break;case"merge":N=E??f.localValue;break}return s(b=>{const j=b.length===0?1:b[b.length-1].version+1,w={id:nt(),version:j,timestamp:new Date().toISOString(),userId:e,userName:n,changes:{[f.field]:{before:f.baseValue,after:N}},message:`Resolved conflict on "${f.field}" using ${k} strategy`};return[...b,w]}),A.filter(b=>b.id!==y)})},[e,n]),p=i.useCallback(y=>{l(k=>{if(k.length===0)return k;const E={};for(const A of k)E[A.field]={before:A.baseValue,after:y==="local"?A.localValue:A.remoteValue};return s(A=>{const f=A.length===0?1:A[A.length-1].version+1,N={id:nt(),version:f,timestamp:new Date().toISOString(),userId:e,userName:n,changes:E,message:`Resolved all conflicts using ${y} strategy`};return[...A,N]}),[]})},[e,n]),g=i.useCallback(y=>{const k=o.findIndex(N=>N.id===y);if(k===-1)return null;const E={};for(let N=0;N<=k;N++){const b=o[N];for(const[j,w]of Object.entries(b.changes))E[j]=w.after}const A={},f={};for(const N of o)for(const[b,j]of Object.entries(N.changes))f[b]=j.after;for(const[N,b]of Object.entries(E))f[N]!==b&&(A[N]={before:f[N],after:b});return Object.keys(A).length>0&&s(N=>{const b=N.length===0?1:N[N.length-1].version+1,j={id:nt(),version:b,timestamp:new Date().toISOString(),userId:e,userName:n,changes:A,message:`Reverted to version ${o[k].version}`};return[...N,j]}),E},[o,e,n]),x=i.useCallback((y,k)=>{const E=o.findIndex(M=>M.id===y),A=o.findIndex(M=>M.id===k);if(E===-1||A===-1)return null;const[f,N]=E<A?[E,A]:[A,E],b=M=>{const v={};for(let _=0;_<=M;_++)for(const[T,L]of Object.entries(o[_].changes))v[T]=L.after;return v},j=b(f),w=b(N),R=new Set([...Object.keys(j),...Object.keys(w)]),S={};for(const M of R){const v=j[M],_=w[M];v!==_&&(S[M]={before:v,after:_})}return S},[o]),h=i.useCallback(y=>{const k={...y,id:ao()};l(E=>[...E,k])},[]),F=i.useCallback(()=>{s([]),l([])},[]);return{versions:o,currentVersion:c,conflicts:r,hasConflicts:d,recordVersion:u,resolveConflict:m,resolveAllConflicts:p,revertToVersion:g,compareVersions:x,addConflict:h,clearHistory:F}}const ro={sm:24,md:32,lg:40},oo={active:"#22c55e",idle:"#f59e0b",away:"#94a3b8"};function io(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function lo({users:e,maxVisible:n=5,size:a="md",showStatus:o=!0,className:s}){const r=ro[a],l=Math.round(r*.3),c=Math.round(r*.35),d=Math.max(8,Math.round(r*.28)),u=i.useMemo(()=>e.slice(0,n),[e,n]),m=Math.max(0,e.length-n),p={display:"inline-flex",alignItems:"center",flexDirection:"row-reverse",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},g={width:`${r}px`,height:`${r}px`,borderRadius:"50%",border:"2px solid #fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${c}px`,fontWeight:600,color:"#fff",position:"relative",flexShrink:0,overflow:"hidden",boxSizing:"border-box"},x={...g,backgroundColor:"#e2e8f0",color:"#475569",marginLeft:`-${l}px`},h={position:"absolute",bottom:"-1px",right:"-1px",width:`${d}px`,height:`${d}px`,borderRadius:"50%",border:"2px solid #fff",boxSizing:"border-box"},F=i.useMemo(()=>[...u].reverse(),[u]);return ae.createElement("div",{style:p,className:s,role:"group","aria-label":`${e.length} user${e.length!==1?"s":""} present`},m>0&&ae.createElement("div",{key:"overflow",style:x,title:`${m} more user${m!==1?"s":""}`},`+${m}`),F.map((y,k)=>ae.createElement("div",{key:y.userId,style:{...g,backgroundColor:y.color,marginLeft:k>0||m>0?`-${l}px`:"0"},title:`${y.userName} (${y.status})`},y.avatar?ae.createElement("img",{src:y.avatar,alt:y.userName,style:{width:"100%",height:"100%",objectFit:"cover"}}):io(y.userName),o&&ae.createElement("span",{style:{...h,backgroundColor:oo[y.status]}}))))}const co={theme:"system",setTheme:()=>null},_a=i.createContext(co);function uo({children:e,defaultTheme:n="system",storageKey:a="vite-ui-theme",...o}){const[s,r]=i.useState(()=>localStorage.getItem(a)||n);i.useEffect(()=>{const c=window.document.documentElement;if(c.classList.remove("light","dark"),s==="system"){const d=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";c.classList.add(d);return}c.classList.add(s)},[s]);const l={theme:s,setTheme:c=>{localStorage.setItem(a,c),r(c)}};return t.jsx(_a.Provider,{...o,value:l,children:e})}const Qt=()=>{const e=i.useContext(_a);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};function mo(){const{theme:e,setTheme:n}=Qt(),{t:a}=me();return t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsxs(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[t.jsx(Ct,{className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),t.jsx(St,{className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),t.jsx("span",{className:"sr-only",children:a("console.theme.toggle")})]})}),t.jsxs(De,{align:"end",children:[t.jsxs(ie,{onClick:()=>n("light"),className:"gap-2",children:[t.jsx(Ct,{className:"h-4 w-4"}),a("console.theme.light"),e==="light"&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]}),t.jsxs(ie,{onClick:()=>n("dark"),className:"gap-2",children:[t.jsx(St,{className:"h-4 w-4"}),a("console.theme.dark"),e==="dark"&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]}),t.jsxs(ie,{onClick:()=>n("system"),className:"gap-2",children:[t.jsx(pa,{className:"h-4 w-4"}),a("console.theme.system"),e==="system"&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]})]})]})}const po=[{code:"en",label:"English"},{code:"zh",label:"中文"},{code:"ja",label:"日本語"},{code:"ko",label:"한국어"},{code:"de",label:"Deutsch"},{code:"fr",label:"Français"},{code:"es",label:"Español"},{code:"pt",label:"Português"},{code:"ru",label:"Русский"},{code:"ar",label:"العربية"}];function ho(){const{t:e,language:n,changeLanguage:a}=me();return t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsxs(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[t.jsx(sr,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("console.localeSwitcher.label")})]})}),t.jsx(De,{align:"end",className:"max-h-72 overflow-y-auto",children:po.map(o=>t.jsxs(ie,{onClick:()=>a(o.code),className:"gap-2",children:[o.label,n===o.code&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]},o.code))})]})}const go={connected:{label:"Connected",color:"text-green-500",icon:Jt},connecting:{label:"Connecting...",color:"text-yellow-500",icon:dt},reconnecting:{label:"Reconnecting...",color:"text-yellow-500",icon:dt},disconnected:{label:"Disconnected",color:"text-muted-foreground",icon:fn},error:{label:"Connection Error",color:"text-destructive",icon:fn}};function fo({state:e,className:n}){const a=go[e],o=a.icon,[s,r]=i.useState(!1);return i.useEffect(()=>{if(e==="connected"){r(!0);const l=setTimeout(()=>r(!1),2e3);return()=>clearTimeout(l)}r(!1)},[e]),e==="connected"&&!s?null:t.jsxs("div",{className:q("flex items-center gap-1.5 text-xs font-medium px-2 py-1 rounded-md transition-opacity duration-300",a.color,e==="connected"&&"bg-green-500/10",e==="error"&&"bg-destructive/10",e==="reconnecting"&&"bg-yellow-500/10",n),title:a.label,children:[t.jsx(o,{className:q("h-3.5 w-3.5",(e==="connecting"||e==="reconnecting")&&"animate-spin")}),t.jsx("span",{className:"hidden sm:inline",children:a.label})]})}const wt={create:{icon:Fe,color:"text-green-500"},update:{icon:ua,color:"text-blue-500"},delete:{icon:ir,color:"text-red-500"},comment:{icon:or,color:"text-amber-500"}};function xo(e){const n=new Date(e).getTime();if(Number.isNaN(n))return"";const a=Math.floor((Date.now()-n)/1e3);if(a<60)return`${Math.max(a,0)}s ago`;const o=Math.floor(a/60);if(o<60)return`${o}m ago`;const s=Math.floor(o/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function bo({activities:e=[],className:n}){const[a,o]=i.useState(!1),[s,r]=i.useState(!1),[l,c]=i.useState({create:!0,update:!0,delete:!0,comment:!0}),d=m=>{c(p=>({...p,[m]:!p[m]}))},u=e.filter(m=>l[m.type]);return t.jsxs(hs,{open:a,onOpenChange:o,children:[t.jsx(gs,{asChild:!0,children:t.jsxs(Y,{variant:"ghost",size:"icon",className:n??"h-8 w-8","aria-label":"Activity feed",children:[t.jsx(xn,{className:"h-4 w-4"}),e.length>0&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-primary text-[9px] font-bold text-primary-foreground flex items-center justify-center",children:e.length>9?"9+":e.length})]})}),t.jsxs(fs,{side:"right",className:"w-80 sm:w-96",children:[t.jsx(xs,{children:t.jsxs(bs,{className:"flex items-center justify-between",children:["Recent Activity",t.jsxs(Y,{variant:s?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>r(!s),children:[t.jsx(rr,{className:"h-3.5 w-3.5 mr-1"}),"Filter"]})]})}),s&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3 px-1",children:Object.keys(wt).map(m=>{const{icon:p,color:g}=wt[m],x=l[m];return t.jsxs(js,{variant:x?"default":"outline",className:"cursor-pointer select-none gap-1 capitalize",onClick:()=>d(m),children:[t.jsx(p,{className:`h-3 w-3 ${x?"":g}`}),m]},m)})}),u.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-16 text-muted-foreground",children:[t.jsx(xn,{className:"h-8 w-8 opacity-40"}),t.jsx("p",{className:"text-sm",children:"No recent activity"})]}):t.jsx("ul",{className:"mt-4 space-y-1 overflow-y-auto max-h-[calc(100vh-8rem)]",children:u.map(m=>{const{icon:p,color:g}=wt[m.type];return t.jsxs("li",{className:"flex items-start gap-3 rounded-md px-2 py-2 hover:bg-muted/50 transition-colors",children:[t.jsx("span",{className:`mt-0.5 shrink-0 ${g}`,children:t.jsx(p,{className:"h-4 w-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm leading-snug",children:m.description}),t.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[m.user," · ",xo(m.timestamp)]})]})]},m.id)})})]})]})}function Ue(e){return e.replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())}const jo=[{userId:"u1",userName:"Alice Chen",color:"#3498db",status:"active",lastActivity:new Date().toISOString()},{userId:"u2",userName:"Bob Smith",color:"#2ecc71",status:"idle",lastActivity:new Date().toISOString()},{userId:"u3",userName:"Carol Li",color:"#e74c3c",status:"active",lastActivity:new Date().toISOString()}];function yo({appName:e,objects:n,connectionState:a,presenceUsers:o,activities:s}){const r=Kn(),l=We(),{isOnline:c}=Us(),d=Qe(),{t:u}=me(),[m,p]=i.useState(null),[g,x]=i.useState(null),h=i.useCallback(async()=>{if(d)try{const[j,w]=await Promise.all([d.find("sys_presence").catch(()=>({data:[]})),d.find("sys_activity",{$orderby:{timestamp:"desc"},$top:20}).catch(()=>({data:[]}))]);if(j.data?.length){const S=j.data.filter(M=>typeof M.userId=="string");S.length&&p(S)}if(w.data?.length){const S=w.data.filter(M=>typeof M.type=="string");S.length&&x(S)}}catch{}},[d]);i.useEffect(()=>{h()},[h]);const F=o??m??jo,y=s??g??[],k=r.pathname.split("/").filter(Boolean),E=l.appName||k[1],A=k[2],f=`/apps/${E}`,N=n.map(j=>({label:j.label||j.name,href:`${f}/${j.name}`})),b=[{label:e,href:f}];if(A==="dashboard")b.push({label:u("console.breadcrumb.dashboards"),href:`${b[0].href}`}),k[3]&&b.push({label:Ue(k[3])});else if(A==="page")b.push({label:u("console.breadcrumb.pages"),href:`${b[0].href}`}),k[3]&&b.push({label:Ue(k[3])});else if(A==="report")b.push({label:u("console.breadcrumb.reports"),href:`${b[0].href}`}),k[3]&&b.push({label:Ue(k[3])});else if(A==="system")b.push({label:u("console.breadcrumb.system")}),k[3]&&b.push({label:Ue(k[3])});else if(A){const j=n.find(w=>w.name===A);if(j)if(b.push({label:j.label||A,href:`/apps/${E}/${A}`,siblings:N}),k[3]==="record"&&k[4]){const w=k[4].length>12?`${k[4].slice(0,8)}…`:k[4];b.push({label:`#${w}`})}else k[3]==="view"&&k[4]&&b.push({label:Ue(k[4])})}return t.jsxs("div",{className:"flex items-center justify-between w-full h-full px-2 sm:px-3 md:px-4 gap-1.5 sm:gap-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 min-w-0 flex-1",children:[t.jsx(ys,{className:"md:hidden shrink-0"}),t.jsx(vs,{orientation:"vertical",className:"h-4 md:hidden shrink-0"}),t.jsx(ws,{className:"hidden sm:flex min-w-0",children:t.jsx(Ns,{children:b.map((j,w)=>t.jsxs(i.Fragment,{children:[w>0&&t.jsx(Cs,{}),t.jsx(Ss,{children:w===b.length-1||!j.href?j.siblings&&j.siblings.length>1?t.jsxs(Ce,{children:[t.jsxs(Se,{className:"flex items-center gap-1 text-sm font-medium",children:[j.label,t.jsx(Dt,{className:"h-3 w-3"})]}),t.jsx(De,{align:"start",className:"max-h-64 overflow-y-auto",children:j.siblings.map(R=>t.jsx(ie,{asChild:!0,children:t.jsx(we,{to:R.href,className:"w-full",children:R.label})},R.href))})]}):t.jsx(Ds,{className:"truncate max-w-[200px]",children:j.label}):j.siblings&&j.siblings.length>1?t.jsxs(Ce,{children:[t.jsxs(Se,{className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[j.label,t.jsx(Dt,{className:"h-3 w-3"})]}),t.jsx(De,{align:"start",className:"max-h-64 overflow-y-auto",children:j.siblings.map(R=>t.jsx(ie,{asChild:!0,children:t.jsx(we,{to:R.href,className:"w-full",children:R.label})},R.href))})]}):t.jsx(ks,{asChild:!0,children:t.jsx(we,{to:j.href,className:"truncate max-w-[150px]",children:j.label})})})]},w))})}),t.jsx("span",{className:"text-sm font-medium sm:hidden truncate min-w-0",children:b[b.length-1]?.label||e})]}),t.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1 md:gap-2 shrink-0",children:[!c&&t.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 text-xs font-medium",children:[t.jsx("span",{className:"h-2 w-2 rounded-full bg-yellow-500 animate-pulse"}),"Offline"]}),a&&t.jsx(fo,{state:a}),F.length>0&&t.jsx("div",{className:"hidden md:flex items-center shrink-0",title:"Users currently online",children:t.jsx(lo,{users:F,size:"sm",maxVisible:3,showStatus:!0})}),t.jsxs("button",{onClick:()=>document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0})),className:"hidden lg:flex relative items-center gap-2 w-50 xl:w-70 h-8 px-3 text-sm rounded-md border bg-muted/50 text-muted-foreground hover:bg-muted transition-colors",children:[t.jsx(qe,{className:"h-4 w-4"}),t.jsx("span",{className:"flex-1 text-left",children:"Search..."}),t.jsxs("kbd",{className:"pointer-events-none inline-flex h-5 items-center gap-0.5 rounded border bg-muted px-1.5 text-[10px] font-medium text-muted-foreground",children:[t.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),t.jsx(Y,{variant:"ghost",size:"icon",className:"lg:hidden h-8 w-8 shrink-0",onClick:()=>document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0})),children:t.jsx(qe,{className:"h-4 w-4"})}),t.jsx("div",{className:"hidden sm:flex shrink-0 relative",children:t.jsx(bo,{activities:y})}),t.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 hidden md:flex shrink-0",children:t.jsx(lr,{className:"h-4 w-4"})}),t.jsx("div",{className:"hidden sm:flex shrink-0",children:t.jsx(mo,{})}),t.jsx("div",{className:"hidden sm:flex shrink-0",children:t.jsx(ho,{})})]})]})}const vo=768,wo=1024;function No(){const{setOpen:e,isMobile:n}=Jn();i.useEffect(()=>{function a(){const o=window.innerWidth;o>=vo&&o<wo&&e(!1)}return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e,n])}function Co({children:e}){return No(),t.jsx(t.Fragment,{children:e})}function So({children:e,activeAppName:n,activeApp:a,onAppChange:o,objects:s,connectionState:r}){return t.jsx(Xs,{sidebar:t.jsx(to,{activeAppName:n,onAppChange:o}),navbar:t.jsx(yo,{appName:ee(a?.label)||n,objects:s,connectionState:r}),className:"p-0 overflow-hidden bg-muted/5",branding:a?.branding?{primaryColor:a.branding.primaryColor,accentColor:a.branding.accentColor,favicon:a.branding.favicon,logo:a.branding.logo,title:a.label?`${ee(a.label)} — ObjectStack Console`:void 0}:void 0,children:t.jsx(Co,{children:e})})}function Fn(e){if(!e)return Re;if(be[e])return be[e];const n=e.split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join("");return be[n]?be[n]:Re}function Do({apps:e,activeApp:n,objects:a,onAppChange:o}){const[s,r]=i.useState(!1),l=Oe(),{appName:c}=We(),{setTheme:d}=Qt(),{evaluator:u}=Ca(),{t:m}=me();i.useEffect(()=>{const h=F=>{F.key==="k"&&(F.metaKey||F.ctrlKey)&&(F.preventDefault(),r(y=>!y))};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]);const p=`/apps/${c||n?.name}`,g=i.useCallback(h=>{r(!1),h()},[]),x=Ea(n?.navigation||[]).filter(h=>ut(h.visible??h.visibleOn,u));return t.jsxs(Fs,{open:s,onOpenChange:r,children:[t.jsx(_s,{placeholder:m("console.commandPalette.placeholder")}),t.jsxs(Es,{children:[t.jsx(As,{children:m("console.commandPalette.noResults")}),x.filter(h=>h.type==="object").length>0&&t.jsx(ve,{heading:m("console.commandPalette.objects"),children:x.filter(h=>h.type==="object").map(h=>{const F=Fn(h.icon);return t.jsxs(pe,{value:`object ${ee(h.label,m)} ${h.objectName}`,onSelect:()=>g(()=>l(`${p}/${h.objectName}`)),children:[t.jsx(F,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)})]},h.id)})}),x.filter(h=>h.type==="dashboard").length>0&&t.jsx(ve,{heading:m("console.commandPalette.dashboards"),children:x.filter(h=>h.type==="dashboard").map(h=>t.jsxs(pe,{value:`dashboard ${ee(h.label,m)} ${h.dashboardName}`,onSelect:()=>g(()=>l(`${p}/dashboard/${h.dashboardName}`)),children:[t.jsx(ha,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)})]},h.id))}),x.filter(h=>h.type==="page").length>0&&t.jsx(ve,{heading:m("console.commandPalette.pages"),children:x.filter(h=>h.type==="page").map(h=>t.jsxs(pe,{value:`page ${ee(h.label,m)} ${h.pageName}`,onSelect:()=>g(()=>l(`${p}/page/${h.pageName}`)),children:[t.jsx(cr,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)})]},h.id))}),x.filter(h=>h.type==="report").length>0&&t.jsx(ve,{heading:m("console.commandPalette.reports"),children:x.filter(h=>h.type==="report").map(h=>t.jsxs(pe,{value:`report ${ee(h.label,m)} ${h.reportName}`,onSelect:()=>g(()=>l(`${p}/report/${h.reportName}`)),children:[t.jsx(ga,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)})]},h.id))}),e.filter(h=>h.active!==!1).length>1&&t.jsxs(t.Fragment,{children:[t.jsx(bt,{}),t.jsx(ve,{heading:m("console.commandPalette.switchApp"),children:e.filter(h=>h.active!==!1).map(h=>{const F=Fn(h.icon);return t.jsxs(pe,{value:`app ${ee(h.label,m)} ${h.name}`,onSelect:()=>g(()=>o(h.name)),children:[t.jsx(F,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)}),h.name===n?.name&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:m("console.commandPalette.current")})]},h.name)})})]}),t.jsx(bt,{}),t.jsxs(ve,{heading:m("console.commandPalette.preferences"),children:[t.jsxs(pe,{value:"theme light",onSelect:()=>g(()=>d("light")),children:[t.jsx(Ct,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.lightTheme")})]}),t.jsxs(pe,{value:"theme dark",onSelect:()=>g(()=>d("dark")),children:[t.jsx(St,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.darkTheme")})]}),t.jsxs(pe,{value:"theme system",onSelect:()=>g(()=>d("system")),children:[t.jsx(pa,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.systemTheme")})]})]}),t.jsx(bt,{}),t.jsxs(ve,{heading:m("console.commandPalette.actions"),children:[t.jsxs(pe,{value:"create new app application",onSelect:()=>g(()=>l(`${p}/create-app`)),children:[t.jsx(Fe,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.createApp")})]}),t.jsxs(pe,{value:"search all results full page",onSelect:()=>g(()=>l(`${p}/search`)),children:[t.jsx(qe,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.openFullSearch")})]})]})]})]})}function Ea(e){const n=[];for(const a of e)a.type==="group"&&a.children?n.push(...Ea(a.children)):n.push(a);return n}function ko({error:e,onReset:n}){const{t:a}=me();return t.jsx("div",{className:"flex h-full items-center justify-center p-8",children:t.jsxs("div",{className:"max-w-md text-center",children:[t.jsxs(mt,{children:[t.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10",children:t.jsx(fa,{className:"h-6 w-6 text-destructive"})}),t.jsx(pt,{children:a("console.errors.somethingWentWrong")}),t.jsx(ht,{className:"mb-4",children:e.message||a("console.errors.unexpectedError")}),t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsxs(Y,{variant:"outline",size:"sm",onClick:n,className:"gap-2",children:[t.jsx(dr,{className:"h-4 w-4"}),a("console.errors.tryAgain")]}),t.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>{window.location.href="/"},className:"gap-2",children:[t.jsx(ur,{className:"h-4 w-4"}),a("console.errors.goHome")]})]})]}),!1]})})}class Fo extends i.Component{constructor(n){super(n),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,a){console.error("[ErrorBoundary] Caught error:",n,a),this.props.onError?.(n,a)}resetErrorBoundary=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError&&this.state.error?this.props.fallback?typeof this.props.fallback=="function"?this.props.fallback({error:this.state.error,reset:this.resetErrorBoundary}):this.props.fallback:t.jsx(ko,{error:this.state.error,onReset:this.resetErrorBoundary}):this.props.children}}function de({message:e}){const{t:n}=me(),[a,o]=i.useState(0),s=i.useMemo(()=>[n("console.loadingSteps.connecting"),n("console.loadingSteps.loadingConfig"),n("console.loadingSteps.preparingWorkspace")],[n]);return i.useEffect(()=>{if(e)return;const r=setInterval(()=>{o(l=>Math.min(l+1,s.length-1))},1200);return()=>clearInterval(r)},[e,s.length]),t.jsx("div",{className:"flex flex-col items-center justify-center h-screen bg-background",children:t.jsxs("div",{className:"flex flex-col items-center gap-6",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-0 bg-primary/20 rounded-2xl blur-xl animate-pulse"}),t.jsx("div",{className:"relative bg-linear-to-br from-primary to-primary/80 p-4 rounded-2xl shadow-lg",children:t.jsx(Re,{className:"h-10 w-10 text-primary-foreground"})})]}),t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:n("console.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n("console.initializing")})]}),e?t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 bg-muted/50 rounded-full",children:[t.jsx(Ts,{className:"h-4 w-4 text-primary"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:e})]}):t.jsx("div",{className:"flex flex-col gap-2 w-64",children:s.map((r,l)=>t.jsxs("div",{className:"flex items-center gap-2.5 text-sm transition-opacity duration-300",style:{opacity:l<=a?1:.3},children:[l<a?t.jsx(Jt,{className:"h-4 w-4 text-primary shrink-0"}):l===a?t.jsx(dt,{className:"h-4 w-4 text-primary shrink-0 animate-spin"}):t.jsx("div",{className:"h-4 w-4 rounded-full border border-muted-foreground/30 shrink-0"}),t.jsx("span",{className:l<=a?"text-foreground":"text-muted-foreground",children:r})]},r))})]})})}const _o=ae.lazy(()=>J(()=>import("./ChartImpl-SceZDRuZ.js"),__vite__mapDeps([0,1,2,3,4]))),Eo=ae.lazy(()=>J(()=>import("./AdvancedChartImpl-Q6xhwCd2.js"),__vite__mapDeps([5,1,2,3,4]))),Ao=({schema:e})=>t.jsx(i.Suspense,{fallback:t.jsx(Ge,{className:"w-full h-48 sm:h-64 md:h-80 lg:h-[400px]"}),children:t.jsx(_o,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),_e=({schema:e})=>{const n=ae.useMemo(()=>{let a=e.series,o=e.xAxisKey,s=e.config;if(o||(e.index?o=e.index:e.category&&(o=e.category)),a||(e.categories?a=e.categories.map(r=>({dataKey:r})):e.value&&(a=[{dataKey:e.value}])),!s&&a){const r=e.colors||["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))"],l={};a.forEach((c,d)=>{l[c.dataKey]={label:c.dataKey,color:r[d%r.length]}}),s=l}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:s,xAxisKey:o,series:a,className:e.className}},[e]);return t.jsx(i.Suspense,{fallback:t.jsx(Ge,{className:"w-full h-48 sm:h-64 md:h-80 lg:h-[400px]"}),children:t.jsx(Eo,{chartType:n.chartType,data:n.data,config:n.config,xAxisKey:n.xAxisKey,series:n.series,className:n.className})})};function To(e,n){const{field:a,function:o,groupBy:s}=n,r={};for(const l of e){const c=String(l[s]??"Unknown");r[c]||(r[c]=[]),r[c].push(l)}return Object.entries(r).map(([l,c])=>{const d=c.map(m=>Number(m[a])||0);let u;switch(o){case"count":u=c.length;break;case"avg":u=d.length>0?d.reduce((m,p)=>m+p,0)/d.length:0;break;case"min":u=d.length>0?Math.min(...d):0;break;case"max":u=d.length>0?Math.max(...d):0;break;case"sum":default:u=d.reduce((m,p)=>m+p,0);break}return{[s]:l,[a]:u}})}const Xt=e=>{const{schema:n}=e,a=i.useContext(Hs),o=e.dataSource||a?.dataSource,s=Yt(n.bind),[r,l]=i.useState([]),[c,d]=i.useState(!1);i.useEffect(()=>{let g=!0;const x=async()=>{if(!(!o||!n.objectName)){g&&d(!0);try{let h;if(n.aggregate&&typeof o.aggregate=="function"){const F=await o.aggregate(n.objectName,{field:n.aggregate.field,function:n.aggregate.function,groupBy:n.aggregate.groupBy,filter:n.filter});h=Array.isArray(F)?F:[]}else if(typeof o.find=="function"){const F=await o.find(n.objectName,{$filter:n.filter});h=Pe(F),n.aggregate&&h.length>0&&(h=To(h,n.aggregate))}else return;g&&l(h)}catch(h){console.error("[ObjectChart] Fetch error:",h)}finally{g&&d(!1)}}};return n.objectName&&!s&&!n.data&&x(),()=>{g=!1}},[n.objectName,o,s,n.data,n.filter,n.aggregate]);const u=s||n.data||r,m=Array.isArray(u)?u:[],p={...n,data:m};return c&&m.length===0?t.jsx("div",{className:"flex items-center justify-center text-muted-foreground text-sm p-4 "+(n.className||""),children:"Loading chart data…"}):!o&&n.objectName&&m.length===0?t.jsxs("div",{className:"flex items-center justify-center text-muted-foreground text-sm p-4 "+(n.className||""),children:['No data source available for "',n.objectName,'"']}):t.jsx(_e,{...e,schema:p})};Z.register("object-chart",Xt,{namespace:"plugin-charts",label:"Object Chart",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"data",type:"array",label:"Data",description:"Optional static data"},{name:"filter",type:"array",label:"Filter"},{name:"aggregate",type:"object",label:"Aggregate",description:"Aggregation config: { field, function, groupBy }"}]});Z.register("bar-chart",Ao,{namespace:"plugin-charts",label:"Bar Chart",category:"plugin",inputs:[{name:"data",type:"array",label:"Data",required:!0},{name:"dataKey",type:"string",label:"Data Key",defaultValue:"value"},{name:"xAxisKey",type:"string",label:"X-Axis Key",defaultValue:"name"},{name:"height",type:"number",label:"Height",defaultValue:400},{name:"color",type:"color",label:"Color",defaultValue:"#8884d8"}],defaultProps:{data:[{name:"Jan",value:400},{name:"Feb",value:300},{name:"Mar",value:600},{name:"Apr",value:800},{name:"May",value:500}],dataKey:"value",xAxisKey:"name",height:400,color:"#8884d8"}});Z.register("chart",Xt,{namespace:"view",category:"view",label:"Chart",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"type",type:"string",label:"Chart Type"},{name:"categoryField",type:"string",label:"Category Field"},{name:"valueField",type:"string",label:"Value Field"}]});Z.register("chart",_e,{namespace:"plugin-charts",label:"Chart",category:"plugin",inputs:[{name:"chartType",type:"enum",label:"Chart Type",enum:[{label:"Bar",value:"bar"},{label:"Line",value:"line"},{label:"Area",value:"area"},{label:"Pie",value:"pie"},{label:"Donut",value:"donut"},{label:"Radar",value:"radar"},{label:"Scatter",value:"scatter"}],defaultValue:"bar"},{name:"data",type:"code",label:"Data (JSON)",required:!0},{name:"config",type:"code",label:"Config (JSON)"},{name:"xAxisKey",type:"string",label:"X Axis Key",defaultValue:"name"},{name:"series",type:"code",label:"Series (JSON Array)",required:!0},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{chartType:"bar",data:[{name:"Jan",sales:400,revenue:240},{name:"Feb",sales:300,revenue:139},{name:"Mar",sales:600,revenue:380},{name:"Apr",sales:800,revenue:430},{name:"May",sales:500,revenue:220}],config:{sales:{label:"Sales",color:"#8884d8"},revenue:{label:"Revenue",color:"#82ca9d"}},xAxisKey:"name",series:[{dataKey:"sales"},{dataKey:"revenue"}]}});Z.register("chart:bar",_e,{namespace:"plugin-charts",label:"Bar Chart (Alias)",category:"plugin",defaultProps:{chartType:"bar"}});Z.register("pie-chart",_e,{namespace:"plugin-charts",label:"Pie Chart",category:"plugin",defaultProps:{chartType:"pie"}});Z.register("donut-chart",_e,{namespace:"plugin-charts",label:"Donut Chart",category:"plugin",defaultProps:{chartType:"donut"}});Z.register("radar-chart",_e,{namespace:"plugin-charts",label:"Radar Chart",category:"plugin",defaultProps:{chartType:"radar"}});Z.register("scatter-chart",_e,{namespace:"plugin-charts",label:"Scatter Chart",category:"plugin",defaultProps:{chartType:"scatter"}});const Vo=({schema:e,dataSource:n,className:a,onRowClick:o,onCardClick:s,...r})=>{const[l,c]=i.useState([]),[d,u]=i.useState(null),[m,p]=i.useState(!1),[g,x]=i.useState(null),h=Yt(e.bind);i.useEffect(()=>{let b=!0;return(async()=>{if(!(!n||!e.objectName))try{const w=await n.getObjectSchema(e.objectName);b&&u(w)}catch(w){console.warn("Failed to fetch object def",w)}})(),()=>{b=!1}},[e.objectName,n]),i.useEffect(()=>{let b=!0;const j=async()=>{if(!(!n||typeof n.find!="function"||!e.objectName)){b&&p(!0);try{const w=Ke(d?.fields),R=await n.find(e.objectName,{options:{$top:100},$filter:e.filter,...w.length>0?{$expand:w}:{}}),S=Pe(R);console.log(`[ObjectKanban] Extracted data (length: ${S.length})`),b&&c(S)}catch(w){console.error("[ObjectKanban] Fetch error:",w),b&&x(w)}finally{b&&p(!1)}}};return e.objectName&&!h&&!e.data&&!r.data&&j(),()=>{b=!1}},[e.objectName,n,h,e.data,e.filter,r.data,d]);const F=r.data||h||e.data||l,y=i.useMemo(()=>{if(!Array.isArray(F))return[];let b=e.cardTitle||e.titleField;if(!b&&d){if(d.titleFormat){const w=/\{(.+?)\}/.exec(d.titleFormat);w&&(b=w[1])}!b&&d.NAME_FIELD_KEY&&(b=d.NAME_FIELD_KEY)}const j=["name","title","subject","label","display_name"];return F.map(w=>{let R=b?w[b]:void 0;if(!R){for(const S of j)if(w[S]){R=w[S];break}}return{...w,id:w.id||w._id,title:R||"Untitled"}})},[F,e,d]),k=i.useMemo(()=>{if(e.columns&&e.columns.length>0)if(typeof e.columns[0]=="string"){if(!e.groupBy)return e.columns.map(b=>({id:b,title:b}))}else return e.columns;if(e.groupBy&&d?.fields?.[e.groupBy]?.options)return d.fields[e.groupBy].options.map(b=>({id:b.value,title:b.label}));if(e.groupBy&&y.length>0){const b=new Set(y.map(j=>j[e.groupBy]));return Array.from(b).map(j=>({id:String(j),title:String(j)}))}return[]},[e.columns,e.groupBy,y,d]),E=e.swimlaneField||e.grouping?.fields?.[0]?.field,A={...e,data:y,columns:k,className:a||e.className,...E?{swimlaneField:E}:{}},f=Ie({navigation:e.navigation,objectName:e.objectName,onRowClick:o??s});if(g)return t.jsxs("div",{className:"p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive",children:["Error loading kanban data: ",g.message]});const N=e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1).replace(/_/g," ")} Detail`:"Card Details";return t.jsxs(t.Fragment,{children:[t.jsx(Aa,{schema:{...A,onCardClick:b=>{f.handleClick(b),s?.(b)}}}),f.isOverlay&&t.jsx(ke,{...f,title:N,children:b=>t.jsx("div",{className:"space-y-3",children:Object.entries(b).map(([j,w])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:j.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(w??"—")})]},j))})})]})},Ro=ae.lazy(()=>J(()=>import("./KanbanImpl-BNUeFn31.js"),__vite__mapDeps([6,1,7,8,9,10,11,3,12,13,4,2,14,15]))),Mo=ae.lazy(()=>J(()=>import("./KanbanEnhanced-Cy_rTBDD.js"),__vite__mapDeps([16,1,17,8,9,10,11,3,12,13,4,2,14,15,7,18,19]))),Aa=({schema:e})=>{const n=ae.useMemo(()=>{const{columns:a=[],data:o,groupBy:s,coverImageField:r}=e,l=c=>{if(!r)return c;const d=c[r];if(!d)return c;const u=typeof d=="string"?d:d?.url;return u?{...c,coverImage:u}:c};if(o&&s&&Array.isArray(o)){const c={};a.forEach(u=>{u.id&&(c[String(u.id).toLowerCase()]=u.id),u.title&&(c[String(u.title).toLowerCase()]=u.id)});const d=o.reduce((u,m)=>{const p=String(m[s]??""),g=c[p.toLowerCase()]??p;return u[g]||(u[g]=[]),u[g].push(l(m)),u},{});return a.map(u=>({...u,cards:[...(u.cards||[]).map(l),...d[u.id]||[]]}))}return a.map(c=>({...c,cards:(c.cards||[]).map(l)}))},[e]);return t.jsx(i.Suspense,{fallback:t.jsx(Ge,{className:"w-full h-[600px]"}),children:t.jsx(Ro,{columns:n,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,coverImageField:e.coverImageField,conditionalFormatting:e.conditionalFormatting,swimlaneField:e.swimlaneField})})};Z.register("kanban-ui",Aa,{namespace:"plugin-kanban",label:"Kanban Board",icon:"LayoutDashboard",category:"plugin",inputs:[{name:"columns",type:"array",label:"Columns",description:"Array of { id, title, cards, limit, className }",required:!0},{name:"onCardMove",type:"code",label:"On Card Move",description:"Callback when a card is moved",advanced:!0},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{columns:[{id:"todo",title:"To Do",cards:[{id:"card-1",title:"Task 1",description:"This is the first task",badges:[{label:"High Priority",variant:"destructive"},{label:"Feature",variant:"default"}]},{id:"card-2",title:"Task 2",description:"This is the second task",badges:[{label:"Bug",variant:"destructive"}]}]},{id:"in-progress",title:"In Progress",limit:3,cards:[{id:"card-3",title:"Task 3",description:"Currently working on this",badges:[{label:"In Progress",variant:"default"}]}]},{id:"done",title:"Done",cards:[{id:"card-4",title:"Task 4",description:"This task is completed",badges:[{label:"Completed",variant:"outline"}]},{id:"card-5",title:"Task 5",description:"Another completed task",badges:[{label:"Completed",variant:"outline"}]}]}],className:"w-full"}});Z.register("kanban-enhanced",({schema:e})=>{const n=ae.useMemo(()=>{const{columns:a=[],data:o,groupBy:s}=e;if(o&&s&&Array.isArray(o)){const r=o.reduce((l,c)=>{const d=c[s];return l[d]||(l[d]=[]),l[d].push(c),l},{});return a.map(l=>({...l,cards:[...l.cards||[],...r[l.id]||[]]}))}return a},[e]);return t.jsx(i.Suspense,{fallback:t.jsx(Ge,{className:"w-full h-[600px]"}),children:t.jsx(Mo,{columns:n,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,conditionalFormatting:e.conditionalFormatting})})},{namespace:"plugin-kanban",label:"Kanban Board (Enhanced)",icon:"LayoutGrid",category:"plugin",inputs:[{name:"columns",type:"array",label:"Columns",required:!0},{name:"enableVirtualScrolling",type:"boolean",label:"Virtual Scrolling",defaultValue:!1},{name:"virtualScrollThreshold",type:"number",label:"Virtual Scroll Threshold",defaultValue:50},{name:"onCardMove",type:"code",label:"On Card Move",advanced:!0},{name:"onColumnToggle",type:"code",label:"On Column Toggle",advanced:!0},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{columns:[],enableVirtualScrolling:!1,virtualScrollThreshold:50,className:"w-full"}});const Ta=({schema:e,...n})=>{const{dataSource:a}=Ye()||{};return t.jsx(Vo,{schema:e,dataSource:a,...n})};Z.register("object-kanban",Ta,{namespace:"plugin-kanban",label:"Object Kanban",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"}]});Z.register("kanban",Ta,{namespace:"view",label:"Kanban Board",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"}]});const en="bg-blue-500 text-white",Oo=new Date,_n={"calendar.today":"Today","calendar.month":"Month","calendar.week":"Week","calendar.day":"Day","calendar.newEvent":"New event","calendar.moreEvents":"+{{count}} more"};function Va(){try{const e=me();return e.t("calendar.today")==="calendar.today"?{t:(a,o)=>{let s=_n[a]||a;if(o)for(const[r,l]of Object.entries(o))s=s.replace(`{{${r}}}`,String(l));return s},language:"en"}:{t:e.t,language:e.language}}catch{return{t:(e,n)=>{let a=_n[e]||e;if(n)for(const[o,s]of Object.entries(n))a=a.replace(`{{${o}}}`,String(s));return a},language:"en"}}}function Ra({events:e=[],view:n="month",currentDate:a=Oo,locale:o="default",onEventClick:s,onDateClick:r,onViewChange:l,onNavigate:c,onAddClick:d,onEventDrop:u,className:m}){const[p,g]=i.useState(n),[x,h]=i.useState(a),{t:F,language:y}=Va(),k=o!=="default"?o:y;i.useEffect(()=>{h(a)},[a]),i.useEffect(()=>{g(n)},[n]);const E=i.useRef(l);E.current=l,i.useEffect(()=>{const v=window.matchMedia("(max-width: 639px)"),_=T=>{T.matches&&(g("day"),E.current?.("day"))};return _(v),v.addEventListener("change",_),()=>v.removeEventListener("change",_)},[]);const A=()=>{const v=new Date(x);p==="month"?v.setMonth(v.getMonth()-1):p==="week"?v.setDate(v.getDate()-7):v.setDate(v.getDate()-1),h(v),c?.(v)},f=()=>{const v=new Date(x);p==="month"?v.setMonth(v.getMonth()+1):p==="week"?v.setDate(v.getDate()+7):v.setDate(v.getDate()+1),h(v),c?.(v)},N=()=>{const v=new Date;h(v),c?.(v)},b=v=>{g(v),l?.(v)},j=()=>{if(p==="month")return x.toLocaleDateString(k,{month:"long",year:"numeric"});if(p==="week"){const v=Ma(x),_=new Date(v);return _.setDate(_.getDate()+6),`${v.toLocaleDateString(k,{month:"short",day:"numeric"})} - ${_.toLocaleDateString(k,{month:"short",day:"numeric",year:"numeric"})}`}else return x.toLocaleDateString(k,{weekday:"long",month:"long",day:"numeric",year:"numeric"})},w=i.useRef(0),R=v=>{w.current=v.touches[0].clientX},S=v=>{const _=w.current-v.changedTouches[0].clientX;if(Math.abs(_)>50){const T=new Date(x);p==="day"?T.setDate(T.getDate()+(_>0?1:-1)):p==="week"?T.setDate(T.getDate()+(_>0?7:-7)):T.setMonth(T.getMonth()+(_>0?1:-1)),h(T),c?.(T)}},M=v=>{v&&(h(v),c?.(v))};return t.jsxs("div",{role:"region","aria-label":"Calendar",className:q("flex flex-col h-full bg-background min-w-0 overflow-hidden",m),children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center bg-muted/50 rounded-lg p-1 gap-1",children:[t.jsx(Y,{variant:"ghost",size:"sm",onClick:N,className:"h-8","aria-label":"Go to today",children:F("calendar.today")}),t.jsx("div",{className:"h-4 w-px bg-border mx-1"}),t.jsx(Y,{variant:"ghost",size:"icon","aria-label":"Previous period",onClick:A,className:"h-8 w-8",children:t.jsx(xa,{className:"h-4 w-4"})}),t.jsx(Y,{variant:"ghost",size:"icon","aria-label":"Next period",onClick:f,className:"h-8 w-8",children:t.jsx(Je,{className:"h-4 w-4"})})]}),t.jsxs(Vs,{children:[t.jsx(Rs,{asChild:!0,children:t.jsxs(Y,{variant:"ghost","aria-label":`Current date: ${j()}`,className:q("text-base sm:text-xl font-semibold h-auto px-2 sm:px-3 py-1 hover:bg-muted/50 transition-colors","flex items-center gap-2"),children:[t.jsx(ba,{className:"h-5 w-5 text-muted-foreground"}),t.jsx("span",{children:j()})]})}),t.jsx(Ms,{className:"w-auto p-0",align:"start",children:t.jsx(Os,{mode:"single",selected:x,onSelect:M,initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Zn,{value:p,onValueChange:b,children:[t.jsx(Qn,{className:"w-32 bg-background",children:t.jsx(Xn,{})}),t.jsxs(ea,{children:[t.jsx(Ne,{value:"day",children:F("calendar.day")}),t.jsx(Ne,{value:"week",children:F("calendar.week")}),t.jsx(Ne,{value:"month",children:F("calendar.month")})]})]}),d&&t.jsxs(Y,{onClick:d,size:"sm",className:"gap-1",children:[t.jsx(Fe,{className:"h-4 w-4"}),F("calendar.newEvent")]})]})]}),t.jsxs("div",{className:"flex-1 overflow-auto",onTouchStart:R,onTouchEnd:S,children:[p==="month"&&t.jsx(Io,{date:x,events:e,locale:k,onEventClick:s,onDateClick:r,onEventDrop:u}),p==="week"&&t.jsx(Lo,{date:x,events:e,locale:k,onEventClick:s,onDateClick:r}),p==="day"&&t.jsx($o,{date:x,events:e,onEventClick:s,onDateClick:r})]})]})}function Ma(e){const n=new Date(e),a=n.getDay(),o=n.getDate()-a;return n.setDate(o),n}function Po(e){const n=e.getFullYear(),a=e.getMonth(),o=new Date(n,a,1),s=new Date(n,a+1,0),r=o.getDay(),l=[];for(let d=r-1;d>=0;d--){const u=new Date(o.getTime());u.setDate(u.getDate()-(d+1)),l.push(u)}for(let d=1;d<=s.getDate();d++)l.push(new Date(n,a,d));const c=42-l.length;for(let d=1;d<=c;d++){const u=new Date(s.getTime());u.setDate(u.getDate()+d),l.push(u)}return l}function Oa(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function Pa(e,n){return n.filter(a=>{const o=new Date(a.start),s=a.end?new Date(a.end):new Date(o),r=new Date(e);r.setHours(0,0,0,0);const l=new Date(e);l.setHours(23,59,59,999);const c=new Date(o);c.setHours(0,0,0,0);const d=new Date(s);return d.setHours(23,59,59,999),r<=d&&l>=c})}function Io({date:e,events:n,locale:a="default",onEventClick:o,onDateClick:s,onEventDrop:r}){const l=i.useMemo(()=>Po(e),[e.getFullYear(),e.getMonth()]),c=i.useMemo(()=>new Date,[]),{t:d}=Va(),u=i.useMemo(()=>{const f=new Date(2024,0,7);return Array.from({length:7},(N,b)=>{const j=new Date(f);return j.setDate(j.getDate()+b),j.toLocaleDateString(a,{weekday:"short"})})},[a]),[m,p]=i.useState(null),[g,x]=i.useState(null),h=i.useMemo(()=>{const f=new Map;for(const N of n){const b=new Date(N.start),j=N.end?new Date(N.end):new Date(b);b.setHours(0,0,0,0),j.setHours(0,0,0,0);const w=new Date(b);for(;w<=j;){const R=`${w.getFullYear()}-${w.getMonth()}-${w.getDate()}`,S=f.get(R);S?S.push(N):f.set(R,[N]),w.setDate(w.getDate()+1)}}return f},[n]),F=(f,N)=>{p(N.id),f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",String(N.id))},y=()=>{p(null),x(null)},k=(f,N)=>{f.preventDefault(),f.dataTransfer.dropEffect="move",x(N)},E=f=>{f.currentTarget.contains(f.relatedTarget)||x(null)},A=(f,N)=>{if(f.preventDefault(),x(null),p(null),!r)return;const b=f.dataTransfer.getData("text/plain"),j=n.find(T=>String(T.id)===b);if(!j)return;const w=new Date(j.start),R=new Date(w);R.setHours(0,0,0,0);const S=new Date(N);S.setHours(0,0,0,0);const M=S.getTime()-R.getTime();if(M===0)return;const v=new Date(w.getTime()+M);let _;j.end&&(_=new Date(new Date(j.end).getTime()+M)),r(j,v,_)};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{role:"row",className:"grid grid-cols-7 border-b",children:u.map(f=>t.jsx("div",{role:"columnheader",className:"p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",children:f},f))}),t.jsx("div",{role:"grid","aria-label":"Calendar grid",className:"grid grid-cols-7 flex-1 auto-rows-fr",children:l.map((f,N)=>{const b=`${f.getFullYear()}-${f.getMonth()}-${f.getDate()}`,j=h.get(b)||[],w=f.getMonth()===e.getMonth(),R=Oa(f,c);return t.jsxs("div",{role:"gridcell","aria-label":`${f.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${j.length>0?`, ${j.length} event${j.length>1?"s":""}`:""}`,className:q("border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",!w&&"bg-muted/50 text-muted-foreground opacity-50",g===N&&"ring-2 ring-primary"),onClick:()=>s?.(f),onDragOver:S=>k(S,N),onDragLeave:E,onDrop:S=>A(S,f),children:[t.jsx("div",{className:q("text-sm font-medium mb-2",R&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),...R?{"aria-current":"date"}:{},children:f.getDate()}),t.jsxs("div",{className:"space-y-1",children:[j.slice(0,3).map(S=>t.jsx("div",{role:"button",title:S.title,"aria-label":S.title,draggable:!!r,onDragStart:M=>F(M,S),onDragEnd:y,className:q("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",S.color?.startsWith("#")?"text-white":S.color||en,m===S.id&&"opacity-50"),style:S.color&&S.color.startsWith("#")?{backgroundColor:S.color}:void 0,onClick:M=>{M.stopPropagation(),o?.(S)},children:S.title},S.id)),j.length>3&&t.jsx("div",{className:"text-xs text-muted-foreground px-2",children:d("calendar.moreEvents",{count:j.length-3})})]})]},N)})})]})}function Lo({date:e,events:n,locale:a="default",onEventClick:o,onDateClick:s}){const r=i.useRef(null),l=p=>{s&&(r.current=setTimeout(()=>{s(p)},500))},c=()=>{r.current&&(clearTimeout(r.current),r.current=null)},d=Ma(e),u=Array.from({length:7},(p,g)=>{const x=new Date(d);return x.setDate(x.getDate()+g),x}),m=new Date;return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{className:"grid grid-cols-7 border-b",children:u.map(p=>{const g=Oa(p,m);return t.jsxs("div",{className:"p-3 text-center border-r last:border-r-0",children:[t.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:p.toLocaleDateString(a,{weekday:"short"})}),t.jsx("div",{className:q("text-lg font-semibold mt-1",g&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"),children:p.getDate()})]},p.toISOString())})}),t.jsx("div",{role:"grid",className:"grid grid-cols-7 flex-1",children:u.map(p=>{const g=Pa(p,n);return t.jsx("div",{role:"gridcell","aria-label":`${p.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${g.length>0?`, ${g.length} event${g.length>1?"s":""}`:""}`,className:"border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",onClick:()=>s?.(p),onTouchStart:()=>l(p),onTouchEnd:c,children:t.jsx("div",{className:"space-y-2",children:g.map(x=>t.jsxs("div",{role:"button",title:x.title,"aria-label":x.title,className:q("text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",x.color?.startsWith("#")?"text-white":x.color||en),style:x.color&&x.color.startsWith("#")?{backgroundColor:x.color}:void 0,onClick:h=>{h.stopPropagation(),o?.(x)},children:[t.jsx("div",{className:"font-medium truncate",children:x.title}),!x.allDay&&t.jsx("div",{className:"text-xs opacity-90 mt-1",children:x.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})})]},x.id))})},p.toISOString())})})]})}function $o({date:e,events:n,onEventClick:a,onDateClick:o}){const s=Pa(e,n),r=Array.from({length:24},(u,m)=>m),l=i.useRef(null),c=u=>{o&&(l.current=setTimeout(()=>{const m=new Date(e);m.setHours(u,0,0,0),o(m)},500))},d=()=>{l.current&&(clearTimeout(l.current),l.current=null)};return t.jsx("div",{className:"flex flex-col h-full",children:t.jsx("div",{role:"list",className:"flex-1 overflow-auto",children:r.map(u=>{const m=s.filter(p=>p.allDay?u===0:p.start.getHours()===u);return t.jsxs("div",{role:"listitem",className:"flex border-b min-h-[60px]",children:[t.jsx("div",{className:"w-20 p-2 text-sm text-muted-foreground border-r",children:u===0?"12 AM":u<12?`${u} AM`:u===12?"12 PM":`${u-12} PM`}),t.jsx("div",{className:"flex-1 p-2 space-y-2",onTouchStart:()=>c(u),onTouchEnd:d,children:m.map(p=>t.jsxs("div",{title:p.title,"aria-label":p.title,className:q("px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",p.color?.startsWith("#")?"text-white":p.color||en),style:p.color&&p.color.startsWith("#")?{backgroundColor:p.color}:void 0,onClick:()=>a?.(p),children:[t.jsx("div",{className:"font-medium truncate",children:p.title}),!p.allDay&&t.jsxs("div",{className:"text-xs opacity-90 mt-1",children:[p.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"}),p.end&&` - ${p.end.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})}`]})]},p.id))})]},u)})})})}function zo(e){return"data"in e&&e.data?e.data:"staticData"in e&&e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function Bo(e){if(e){if(typeof e=="string"){const n=e.split(" "),a=n[0],o=n[1]?.toLowerCase()==="desc"?"desc":"asc";return{[a]:o}}if(Array.isArray(e))return e.reduce((n,a)=>(a.field&&a.order&&(n[a.field]=a.order),n),{})}}function Uo(e){return"filter"in e&&e.filter&&typeof e.filter=="object"&&"calendar"in e.filter?e.filter.calendar:e.calendar?e.calendar:e.startDateField||e.dateField?{startDateField:e.startDateField||e.dateField,endDateField:e.endDateField||e.endField,titleField:e.titleField||"name",colorField:e.colorField,allDayField:e.allDayField}:null}const Ho=({schema:e,dataSource:n,className:a,onEventClick:o,onRowClick:s,onDateClick:r,onNavigate:l,onViewChange:c,onEventDrop:d,locale:u,...m})=>{const[p,g]=i.useState([]),[x,h]=i.useState(!0),[F,y]=i.useState(null),[k,E]=i.useState(null),[A,f]=i.useState(new Date),[N,b]=i.useState("month"),[j,w]=i.useState(0),R=i.useCallback(async()=>{w(O=>O+1)},[]),{ref:S,isRefreshing:M,pullDistance:v}=ya({onRefresh:R,enabled:!!n&&!!e.objectName}),_=i.useMemo(()=>zo(e),[e.data,e.staticData,e.objectName]),T=i.useMemo(()=>Uo(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),L=_?.provider==="value",U=i.useRef(null);U.current=k,i.useEffect(()=>{let O=!0;return(async()=>{try{if(!O)return;if(h(!0),L&&_?.provider==="value"){O&&(g(_.items),h(!1));return}if(e.data||m.data){const D=e.data||m.data;if(Array.isArray(D)){g(D),h(!1);return}}if(!n||typeof n.find!="function")throw new Error("DataSource required for object/api providers");if(_?.provider==="object"){const D=_.object,G=Ke(U.current?.fields),W=await n.find(D,{$filter:e.filter,$orderby:Bo(e.sort),...G.length>0?{$expand:G}:{}});let Q=Pe(W);O&&g(Q)}else _?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectCalendar"),O&&g([]));O&&h(!1)}catch(D){console.error("[ObjectCalendar] Error fetching data:",D),O&&(y(D),h(!1))}})(),()=>{O=!1}},[_,n,L,e.filter,e.sort,j]),i.useEffect(()=>{!L&&n&&(async()=>{try{if(!n)return;const I=_?.provider==="object"?_.object:e.objectName;if(!I)return;const D=await n.getObjectSchema(I);E(D)}catch(I){console.error("Failed to fetch object schema:",I)}})()},[e.objectName,n,L,_]);const P=i.useMemo(()=>{if(!T||!p.length)return[];const{startDateField:O,endDateField:I,titleField:D,colorField:G}=T;return p.map((W,Q)=>{const se=W[O],le=I?W[I]:null,ce=W[D]||"Untitled",xt=G?W[G]:void 0;return{id:W.id||W._id||`event-${Q}`,title:ce,start:se?new Date(se):new Date,end:le?new Date(le):void 0,color:xt,allDay:!le,data:W}}).filter(W=>!isNaN(W.start.getTime()))},[p,T]);i.useCallback(()=>{r?.(new Date)},[r]);const $=Ie({navigation:e.navigation,objectName:e.objectName,onRowClick:s});return x?t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading calendar..."})})}):F?t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsxs("div",{className:"text-destructive",children:["Error: ",F.message]})})}):T?t.jsxs("div",{ref:S,className:a,children:[v>0&&t.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:v},children:M?"Refreshing…":"Pull to refresh"}),t.jsx("div",{className:"border rounded-lg bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]",children:t.jsx(Ra,{events:P,currentDate:A,view:e.defaultView||"month",locale:u,onEventClick:O=>{$.handleClick(O.data),o?.(O.data)},onDateClick:r,onNavigate:O=>{f(O),l?.(O)},onViewChange:O=>{b(O),c?.(O)},onAddClick:void 0,onEventDrop:d?(O,I,D)=>{d(O.data,I,D)}:void 0})}),$.isOverlay&&t.jsx(ke,{...$,title:"Event Details",children:O=>t.jsx("div",{className:"space-y-3",children:Object.entries(O).map(([I,D])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:I.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(D??"—")})]},I))})})]}):t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Calendar configuration required. Please specify startDateField and titleField."})})})};Z.register("calendar-view",({schema:e,className:n,onAction:a,...o})=>{const s=ae.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((l,c)=>{const d=e.titleField||"title",u=e.startDateField||"start",m=e.endDateField||"end",p=e.colorField||"color",g=e.allDayField||"allDay";return{id:l._id||l.id||c,title:l[d]||"Untitled Event",start:new Date(l[u]),end:l[m]?new Date(l[m]):void 0,allDay:l[g],color:l[p],data:l}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]),r=l=>{a?.({type:"event-click",payload:l})};return t.jsx(Ra,{className:n,events:s,onEventClick:r,...o})},{namespace:"plugin-calendar",label:"Calendar View",inputs:[{name:"data",type:"array",label:"Data",description:"Array of record objects to display as events"},{name:"titleField",type:"string",label:"Title Field",defaultValue:"title",description:"Field name to use for event title"},{name:"startDateField",type:"string",label:"Start Date Field",defaultValue:"start",description:"Field name for event start date"},{name:"endDateField",type:"string",label:"End Date Field",defaultValue:"end",description:"Field name for event end date (optional)"},{name:"allDayField",type:"string",label:"All Day Field",defaultValue:"allDay",description:"Field name for all-day flag"},{name:"colorField",type:"string",label:"Color Field",defaultValue:"color",description:"Field name for event color"},{name:"colorMapping",type:"object",label:"Color Mapping",description:'Map field values to colors (e.g., {meeting: "blue", deadline: "red"})'},{name:"view",type:"enum",enum:["month","week","day"],defaultValue:"month",label:"View Mode",description:"Calendar view mode (month, week, or day)"},{name:"currentDate",type:"string",label:"Current Date",description:"ISO date string for initial calendar date"},{name:"allowCreate",type:"boolean",label:"Allow Create",defaultValue:!1,description:"Allow creating events by clicking on dates"},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{view:"month",titleField:"title",startDateField:"start",endDateField:"end",allDayField:"allDay",colorField:"color",allowCreate:!1,data:[{id:1,title:"Team Meeting",start:new Date(new Date().setHours(10,0,0,0)).toISOString(),end:new Date(new Date().setHours(11,0,0,0)).toISOString(),color:"#3b82f6",allDay:!1},{id:2,title:"Project Deadline",start:new Date(new Date().setDate(new Date().getDate()+3)).toISOString(),color:"#ef4444",allDay:!0},{id:3,title:"Conference",start:new Date(new Date().setDate(new Date().getDate()+7)).toISOString(),end:new Date(new Date().setDate(new Date().getDate()+9)).toISOString(),color:"#10b981",allDay:!0}],className:"h-[600px] border rounded-lg"}});const Ia=({schema:e,data:n,loading:a,...o})=>{const{dataSource:s}=Ye()||{};return t.jsx(Ho,{schema:e,dataSource:s,...o})};Z.register("object-calendar",Ia,{namespace:"plugin-calendar",label:"Object Calendar",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"calendar",type:"object",label:"Calendar Config",description:"startDateField, endDateField, titleField, colorField"}]});Z.register("calendar",Ia,{namespace:"view",label:"Calendar View",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"calendar",type:"object",label:"Calendar Config",description:"startDateField, endDateField, titleField, colorField"}]});function qo({open:e,onToggle:n,className:a}){return t.jsxs(Y,{size:"sm",variant:e?"secondary":"outline",onClick:n,className:`shadow-none gap-2 ${a||""}`,title:"Toggle Metadata Inspector",children:[t.jsx(hr,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden lg:inline",children:"Metadata"})]})}function Wo({sections:e,open:n}){if(!n)return null;const[a,o]=i.useState(["0"]),[s,r]=i.useState(null),l=async(d,u)=>{try{await navigator.clipboard.writeText(JSON.stringify(d,null,2)),r(u),setTimeout(()=>r(null),2e3)}catch(m){console.error("Failed to copy:",m)}},c=d=>{o(u=>u.includes(d)?u.filter(m=>m!==d):[...u,d])};return t.jsxs("div",{className:"w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all",children:[t.jsxs("div",{className:"px-4 py-3 border-b bg-muted/5 flex items-center justify-between",children:[t.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Metadata Inspector"}),t.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:"JSON"})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:e.map((d,u)=>{const m=String(u),p=a.includes(m),g=s===u;return t.jsxs("div",{className:"border-b last:border-b-0",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors",children:[t.jsxs("button",{onClick:()=>c(m),className:"flex-1 flex items-center justify-between text-left",children:[t.jsx("h4",{className:"text-xs font-semibold text-foreground",children:d.title}),p?t.jsx(Dt,{className:"h-3 w-3 text-muted-foreground ml-2"}):t.jsx(Je,{className:"h-3 w-3 text-muted-foreground ml-2"})]}),t.jsx("button",{onClick:()=>l(d.data,u),className:"p-1 hover:bg-muted rounded transition-colors ml-2",title:"Copy JSON",children:g?t.jsx(mr,{className:"h-3 w-3 text-green-600"}):t.jsx(pr,{className:"h-3 w-3 text-muted-foreground"})})]}),p&&t.jsx("div",{className:"px-4 pb-4",children:t.jsx("div",{className:"relative rounded-md border border-border/50 bg-muted/5 overflow-hidden",children:t.jsx("pre",{className:"text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90",children:JSON.stringify(d.data,null,2)})})})]},u)})})]})}function Go(){const e=i.useMemo(()=>{try{return typeof window<"u"?qs(window.location.search).enabled:!1}catch{return!1}},[]),[n,a]=i.useState(e);return{showDebug:n,toggleDebug:()=>a(o=>!o)}}const La={"=":"equals","==":"equals","!=":"notEquals","<>":"notEquals",">":"greaterThan","<":"lessThan",">=":"greaterOrEqual","<=":"lessOrEqual",contains:"contains",not_contains:"notContains",is_empty:"isEmpty",is_not_empty:"isNotEmpty",in:"in",not_in:"notIn","not in":"notIn",before:"before",after:"after",between:"between",equals:"equals",notEquals:"notEquals",greaterThan:"greaterThan",lessThan:"lessThan",greaterOrEqual:"greaterOrEqual",lessOrEqual:"lessOrEqual",notContains:"notContains",isEmpty:"isEmpty",isNotEmpty:"isNotEmpty",notIn:"notIn"},Ko={equals:"=",notEquals:"!=",greaterThan:">",lessThan:"<",greaterOrEqual:">=",lessOrEqual:"<=",contains:"contains",notContains:"not_contains",isEmpty:"is_empty",isNotEmpty:"is_not_empty",in:"in",notIn:"not in",before:"before",after:"after",between:"between"};function Yo(e){const n=(e||"").toLowerCase();return["integer","int","float","double","number","currency","money","percent","rating"].includes(n)?"number":["date","datetime","datetime_tz","timestamp"].includes(n)?"date":["boolean","bool","checkbox","switch"].includes(n)?"boolean":["select","picklist","single_select","multi_select","enum"].includes(n)?"select":"text"}function Ft(e){if(!Array.isArray(e)||e.length<2)return null;const[n,a,o]=e;return typeof n!="string"||typeof a!="string"?null:{id:crypto.randomUUID(),field:n,operator:La[a]||a,value:o??""}}function En(e){if(Array.isArray(e)){const n=Ft(e);return n?[n]:[]}return typeof e=="object"&&e!==null&&e.field?[{id:e.id||crypto.randomUUID(),field:e.field,operator:La[e.operator]||e.operator||"equals",value:e.value??""}]:[]}function Jo(e){if(!Array.isArray(e)||e.length===0)return{logic:"and",conditions:[]};if(typeof e[0]=="string"&&(e[0]==="and"||e[0]==="or")){const a=e[0],s=e.slice(1).flatMap(r=>En(r));return{logic:a,conditions:s}}if(e.length>=2&&e.length<=3&&typeof e[0]=="string"&&typeof e[1]=="string"&&!Array.isArray(e[0])&&!Array.isArray(e[2])){const a=Ft(e);return{logic:"and",conditions:a?[a]:[]}}if(Array.isArray(e[0])||typeof e[0]=="object"&&e[0]!==null&&!Array.isArray(e[0]))return{logic:"and",conditions:e.flatMap(o=>En(o))};const n=Ft(e);return{logic:"and",conditions:n?[n]:[]}}function Zo(e,n){const a=n.filter(o=>o.field).map(o=>[o.field,Ko[o.operator]||o.operator,o.value]);return a.length===0?[]:a.length===1&&e==="and"?a[0]:e==="or"?["or",...a]:a}function An(e){return e.split(",").map(n=>n.trim()).filter(Boolean)}function Qo(e){return e.split(",").map(n=>Number(n.trim())).filter(n=>!isNaN(n)&&n>0)}const tn={grid:"Grid",kanban:"Kanban",calendar:"Calendar",gallery:"Gallery",timeline:"Timeline",gantt:"Gantt",map:"Map",chart:"Chart"},Xo=Object.keys(tn),ei=[{value:"compact",gapClass:"gap-0"},{value:"short",gapClass:"gap-px"},{value:"medium",gapClass:"gap-0.5"},{value:"tall",gapClass:"gap-1"},{value:"extra_tall",gapClass:"gap-1.5"}];function ti(e){return e.fields?Object.entries(e.fields).map(([n,a])=>({value:n,label:a.label||n,type:Yo(a.type),options:a.options})):[]}function ni(e){const n=Jo(e);return{id:"root",logic:n.logic,conditions:n.conditions}}function ai(e){return(Array.isArray(e)?e:[]).map(n=>({id:n.id||crypto.randomUUID(),field:n.field||"",order:n.order||n.direction||"asc"}))}function je({renderSummary:e,children:n}){const[a,o]=ae.useState(!1);return t.jsxs(t.Fragment,{children:[e(()=>o(s=>!s)),a&&n]})}const si=5;function ri({colName:e,label:n,idx:a,total:o,onToggle:s,onMove:r}){const{attributes:l,listeners:c,setNodeRef:d,transform:u,transition:m,isDragging:p}=Br({id:e}),g={transform:Ur.Transform.toString(u),transition:m,zIndex:p?10:void 0,opacity:p?.5:void 0};return t.jsxs("div",{ref:d,style:g,"data-field-name":e,"data-field-label":n,className:"flex items-center gap-1 text-xs hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1 group",children:[t.jsx("span",{...l,...c,className:"shrink-0 cursor-grab touch-none","data-testid":`col-drag-handle-${e}`,children:t.jsx(lt,{className:"h-3 w-3 text-muted-foreground/50"})}),t.jsx("button",{type:"button","data-testid":`col-eye-${e}`,className:"h-5 w-5 flex items-center justify-center rounded hover:bg-accent shrink-0",onClick:()=>s(e,!1),"aria-label":`Hide ${n}`,children:t.jsx(fr,{className:"h-3.5 w-3.5 text-primary"})}),t.jsx("span",{className:"truncate flex-1",children:n}),t.jsx("button",{type:"button","data-testid":`col-move-up-${e}`,className:"h-5 w-5 flex items-center justify-center rounded hover:bg-accent disabled:opacity-30 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",disabled:a===0,onClick:()=>r(e,"up"),"aria-label":`Move ${n} up`,children:t.jsx(lt,{className:"h-3 w-3 rotate-90"})}),t.jsx("button",{type:"button","data-testid":`col-move-down-${e}`,className:"h-5 w-5 flex items-center justify-center rounded hover:bg-accent disabled:opacity-30 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",disabled:a===o-1,onClick:()=>r(e,"down"),"aria-label":`Move ${n} down`,children:t.jsx(lt,{className:"h-3 w-3 -rotate-90"})})]})}function oi({columns:e,fieldOptions:n,onToggle:a,onMove:o,onReorder:s}){const r=Rr(bn(Or,{activationConstraint:{distance:si}}),bn(Mr)),l=ae.useCallback(c=>{const{active:d,over:u}=c;if(!u||d.id===u.id)return;const m=e.indexOf(String(d.id)),p=e.indexOf(String(u.id));m===-1||p===-1||s(Pr(e,m,p))},[e,s]);return t.jsx(Ir,{sensors:r,collisionDetection:Lr,onDragEnd:l,children:t.jsx($r,{items:e,strategy:zr,children:e.map((c,d)=>{const u=n.find(m=>m.value===c);return t.jsx(ri,{colName:c,label:u?.label||c,idx:d,total:e.length,onToggle:a,onMove:o},c)})})})}const ue=e=>e.type==null||e.type==="grid",ii=e=>e.type==null||["grid","kanban","gallery"].includes(e.type),$a=e=>e.type==null||["grid","calendar","timeline","gantt"].includes(e.type),li=e=>e.type==null||["grid","kanban"].includes(e.type),Tn=e=>e.type==null||["grid","kanban"].includes(e.type),ci=e=>e.type==null||["grid","gallery"].includes(e.type);function di(e){const{t:n,fieldOptions:a,objectDef:o,updateField:s,filterGroupValue:r,sortItemsValue:l}=e,c=a.map(u=>({value:u.value,label:u.label})),d=[{value:"",label:n("console.objectView.none")},...c];return{breadcrumb:[n("console.objectView.page")],sections:[ui(n,o),mi(n),pi(n,s),hi(n,s),gi(n,s),fi(n,a,d,o,s,r,l),xi(n,a,d,s),bi(n,s),ji(n,s),yi(n,s)]}}function ui(e,n){return{key:"general",title:e("console.objectView.general"),hint:e("console.objectView.generalHint"),fields:[{key:"label",label:e("console.objectView.title"),type:"custom",render:(a,o)=>t.jsx(H,{label:e("console.objectView.title"),children:t.jsx(X,{"data-testid":"view-title-input",className:"h-7 text-xs w-32 text-right",value:a||"",onChange:s=>o(s.target.value)})})},{key:"description",label:e("console.objectView.description"),type:"custom",render:(a,o)=>t.jsx(H,{label:e("console.objectView.description"),children:t.jsx(X,{"data-testid":"view-description-input",className:"h-7 text-xs w-32 text-right",value:a??"",placeholder:n.description||e("console.objectView.noDescription"),onChange:s=>o(s.target.value)})})},{key:"type",label:e("console.objectView.viewType"),type:"custom",render:(a,o)=>t.jsx(H,{label:e("console.objectView.viewType"),children:t.jsx("select",{"data-testid":"view-type-select",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground",value:a||"grid",onChange:s=>o(s.target.value),children:Xo.map(s=>t.jsx("option",{value:s,children:tn[s]},s))})})}]}}function mi(e){const n=["showSearch","showSort","showFilters","showHideFields","showGroup","showColor","showDensity"];return{key:"toolbar",title:e("console.objectView.toolbar"),hint:e("console.objectView.toolbarHint"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_toolbarSummary",label:e("console.objectView.toolbar"),type:"custom",render:(a,o,s)=>{const r=n.length,l=n.filter(c=>s[c]!==!1).length;return t.jsx("div",{className:"flex items-center gap-1.5 py-1","data-testid":"toolbar-summary-chip",children:t.jsx("span",{className:"inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:e("console.objectView.toolbarEnabledCount",{count:l,total:r})})})}},ne("showSearch",e("console.objectView.enableSearch"),"toggle-showSearch",!0),ne("showSort",e("console.objectView.enableSort"),"toggle-showSort",!0),ne("showFilters",e("console.objectView.enableFilter"),"toggle-showFilters",!0),ne("showHideFields",e("console.objectView.enableHideFields"),"toggle-showHideFields",!0),ne("showGroup",e("console.objectView.enableGroup"),"toggle-showGroup",!0,!1,void 0,ii),ne("showColor",e("console.objectView.enableColor"),"toggle-showColor",!0,!1,void 0,$a),ne("showDensity",e("console.objectView.enableDensity"),"toggle-showDensity",!0,!1,void 0,ue)]}}function pi(e,n){return{key:"navigation",title:e("console.objectView.navigationSection"),hint:e("console.objectView.navigationHint"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_navigationMode",label:e("console.objectView.navigationMode"),type:"custom",render:(a,o,s)=>{const r=s.navigation?.mode||"page";return t.jsx(H,{label:e("console.objectView.navigationMode"),children:t.jsxs("select",{"data-testid":"select-navigation-mode",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:r,onChange:l=>{const c=l.target.value;n("navigation",{...s.navigation||{},mode:c}),n("clickIntoRecordDetails",c!=="none")},children:[t.jsx("option",{value:"page",children:"Page"}),t.jsx("option",{value:"drawer",children:"Drawer"}),t.jsx("option",{value:"modal",children:"Modal"}),t.jsx("option",{value:"split",children:"Split"}),t.jsx("option",{value:"popover",children:"Popover"}),t.jsx("option",{value:"new_window",children:"New Window"}),t.jsx("option",{value:"none",children:"None"})]})})}},{key:"_navigationWidth",label:e("console.objectView.navigationWidth"),type:"custom",helpText:e("console.objectView.navigationWidthHint"),visibleWhen:a=>["drawer","modal","split"].includes(a.navigation?.mode||"page"),render:(a,o,s)=>{const r=s.navigation?.mode||"page";return t.jsx(H,{label:e("console.objectView.navigationWidth"),children:t.jsx(X,{"data-testid":"input-navigation-width",className:"h-7 text-xs w-24 text-right",value:s.navigation?.width??"",placeholder:"600px",onChange:l=>n("navigation",{...s.navigation||{},mode:r,width:l.target.value})})})}},{key:"_navigationOpenNewTab",label:e("console.objectView.openNewTab"),type:"custom",helpText:e("console.objectView.openNewTabHint"),visibleWhen:a=>["page","new_window"].includes(a.navigation?.mode||"page"),render:(a,o,s)=>{const r=s.navigation?.mode||"page";return t.jsx(H,{label:e("console.objectView.openNewTab"),children:t.jsx(Ve,{"data-testid":"toggle-navigation-openNewTab",checked:s.navigation?.openNewTab===!0,onCheckedChange:l=>n("navigation",{...s.navigation||{},mode:r,openNewTab:l}),className:"scale-75"})})}}]}}function hi(e,n){return{key:"records",title:e("console.objectView.records"),hint:e("console.objectView.recordsHint"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_selectionType",label:e("console.objectView.selectionMode"),type:"custom",render:(a,o,s)=>t.jsx(H,{label:e("console.objectView.selectionMode"),children:t.jsxs("select",{"data-testid":"select-selection-type",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:s.selection?.type||"multiple",onChange:r=>n("selection",{type:r.target.value}),children:[t.jsx("option",{value:"none",children:e("console.objectView.selectionNone")}),t.jsx("option",{value:"single",children:e("console.objectView.selectionSingle")}),t.jsx("option",{value:"multiple",children:e("console.objectView.selectionMultiple")})]})})},{key:"_addRecord",label:e("console.objectView.addRecordEnabled"),type:"custom",render:(a,o,s)=>{const r=s.addRecordViaForm===!0||s.addRecord?.enabled===!0;return t.jsxs(t.Fragment,{children:[t.jsx(H,{label:e("console.objectView.addRecordEnabled"),children:t.jsx(Ve,{"data-testid":"toggle-addRecord-enabled",checked:r,onCheckedChange:l=>{n("addRecordViaForm",l),n("addRecord",{...s.addRecord||{},enabled:l})},className:"scale-75"})}),r&&t.jsxs(t.Fragment,{children:[t.jsx(H,{label:e("console.objectView.addRecordPosition"),children:t.jsxs("select",{"data-testid":"select-addRecord-position",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[100px]",value:s.addRecord?.position||"top",onChange:l=>n("addRecord",{...s.addRecord||{},enabled:!0,position:l.target.value}),children:[t.jsx("option",{value:"top",children:"Top"}),t.jsx("option",{value:"bottom",children:"Bottom"})]})}),t.jsx(H,{label:e("console.objectView.addRecordMode"),children:t.jsxs("select",{"data-testid":"select-addRecord-mode",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[100px]",value:s.addRecord?.mode||"form",onChange:l=>n("addRecord",{...s.addRecord||{},enabled:!0,mode:l.target.value}),children:[t.jsx("option",{value:"inline",children:"Inline"}),t.jsx("option",{value:"form",children:"Form"}),t.jsx("option",{value:"modal",children:"Modal"})]})}),t.jsx(H,{label:e("console.objectView.addRecordFormView"),children:t.jsx(X,{"data-testid":"input-addRecord-formView",className:"h-7 text-xs w-24 text-right",value:s.addRecord?.formView??"",onChange:l=>n("addRecord",{...s.addRecord||{},enabled:!0,formView:l.target.value})})})]})]})}}]}}function gi(e,n){return{key:"exportPrint",title:e("console.objectView.exportPrint"),hint:e("console.objectView.exportPrintHint"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_export",label:e("console.objectView.allowExport"),type:"custom",render:(a,o,s)=>{const r=s.exportOptions!=null||s.allowExport===!0;return t.jsxs(t.Fragment,{children:[t.jsx(H,{label:e("console.objectView.allowExport"),children:t.jsx(Ve,{"data-testid":"toggle-allowExport",checked:r,onCheckedChange:l=>n("allowExport",l),className:"scale-75"})}),r&&t.jsxs(t.Fragment,{children:[t.jsx(H,{label:e("console.objectView.exportFormats"),children:t.jsx("div",{"data-testid":"export-formats",className:"flex flex-wrap gap-1",children:["csv","xlsx","json","pdf"].map(l=>t.jsxs("label",{className:"flex items-center gap-1 text-xs cursor-pointer",children:[t.jsx(Gt,{"data-testid":`export-format-${l}`,checked:(s.exportOptions?.formats||[]).includes(l),onCheckedChange:c=>{const d=s.exportOptions?.formats||[],u=c?[...d,l]:d.filter(m=>m!==l);n("exportOptions",{...s.exportOptions||{},formats:u})},className:"h-3.5 w-3.5"}),l]},l))})}),t.jsx(H,{label:e("console.objectView.exportMaxRecords"),children:t.jsx(X,{"data-testid":"input-export-maxRecords",className:"h-7 text-xs w-20 text-right",type:"number",value:s.exportOptions?.maxRecords??"",placeholder:"0",onChange:l=>n("exportOptions",{...s.exportOptions||{},maxRecords:Number(l.target.value)||void 0})})}),t.jsx(H,{label:e("console.objectView.exportIncludeHeaders"),children:t.jsx(Ve,{"data-testid":"toggle-export-includeHeaders",checked:s.exportOptions?.includeHeaders!==!1,onCheckedChange:l=>n("exportOptions",{...s.exportOptions||{},includeHeaders:l}),className:"scale-75"})}),t.jsx(H,{label:e("console.objectView.exportFileNamePrefix"),children:t.jsx(X,{"data-testid":"input-export-fileNamePrefix",className:"h-7 text-xs w-24 text-right",value:s.exportOptions?.fileNamePrefix??"",placeholder:"export",onChange:l=>n("exportOptions",{...s.exportOptions||{},fileNamePrefix:l.target.value})})})]})]})}},ne("showRecordCount",e("console.objectView.showRecordCount"),"toggle-showRecordCount",!1,!0,void 0,ue),ne("allowPrinting",e("console.objectView.allowPrinting"),"toggle-allowPrinting",!1,!0,void 0,ue)]}}function fi(e,n,a,o,s,r,l){return{key:"data",title:e("console.objectView.data"),hint:e("console.objectView.listConfigHint"),collapsible:!0,fields:[{key:"_source",label:e("console.objectView.source"),type:"custom",render:()=>t.jsx(H,{label:e("console.objectView.source"),value:o.label||o.name})},{key:"_columns",label:e("console.objectView.fields"),type:"custom",render:(c,d,u)=>{const m=Array.isArray(u.columns)?u.columns.length:0,p=m>0?e("console.objectView.fieldsVisible",{count:m}):e("console.objectView.none"),g=(y,k)=>{const E=Array.isArray(u.columns)?[...u.columns]:[];if(k&&!E.includes(y))E.push(y);else if(!k){const A=E.indexOf(y);A>=0&&E.splice(A,1)}s("columns",E)},x=(y,k)=>{const E=Array.isArray(u.columns)?[...u.columns]:[],A=E.indexOf(y);if(A<0)return;const f=k==="up"?A-1:A+1;f<0||f>=E.length||([E[A],E[f]]=[E[f],E[A]],s("columns",E))},h=()=>{s("columns",n.map(y=>y.value))},F=()=>{s("columns",[])};return t.jsx(je,{renderSummary:y=>t.jsx(H,{label:e("console.objectView.fields"),value:p,onClick:y}),children:t.jsxs("div",{"data-testid":"column-selector",className:"pb-2 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-1 pb-1",children:[t.jsx(X,{"data-testid":"column-search-input",className:"h-6 text-xs flex-1",placeholder:e("console.objectView.searchFields"),onChange:y=>{const k=y.target,E=k.closest('[data-testid="column-selector"]');if(!E)return;const A=k.value.toLowerCase();E.querySelectorAll("[data-field-name]").forEach(f=>{const N=f.getAttribute("data-field-name")||"",b=f.getAttribute("data-field-label")||"";f.style.display=!A||N.toLowerCase().includes(A)||b.toLowerCase().includes(A)?"":"none"})}}),t.jsx("button",{type:"button","data-testid":"column-show-all",className:"text-xs text-primary hover:underline whitespace-nowrap",onClick:h,children:e("console.objectView.showAllFields")}),t.jsx("button",{type:"button","data-testid":"column-hide-all",className:"text-xs text-primary hover:underline whitespace-nowrap",onClick:F,children:e("console.objectView.hideAllFields")})]}),t.jsxs("div",{className:"space-y-0.5 max-h-48 overflow-auto",children:[Array.isArray(u.columns)&&u.columns.length>0&&t.jsx("div",{"data-testid":"selected-columns",className:"space-y-0.5 pb-1 mb-1 border-b border-border/50",children:t.jsx(oi,{columns:u.columns,fieldOptions:n,onToggle:g,onMove:x,onReorder:y=>s("columns",y)})}),n.filter(y=>!Array.isArray(u.columns)||!u.columns.includes(y.value)).map(y=>t.jsxs("div",{"data-field-name":y.value,"data-field-label":y.label,className:"flex items-center gap-1 text-xs cursor-pointer hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1",children:[t.jsx(lt,{className:"h-3 w-3 text-muted-foreground/20 shrink-0"}),t.jsx("button",{type:"button","data-testid":`col-eye-${y.value}`,className:"h-5 w-5 flex items-center justify-center rounded hover:bg-accent shrink-0",onClick:()=>g(y.value,!0),"aria-label":`Show ${y.label}`,children:t.jsx(gr,{className:"h-3.5 w-3.5 text-muted-foreground"})}),t.jsx("span",{className:"truncate text-muted-foreground",children:y.label})]},y.value))]})]})})}},{key:"_filterBy",label:e("console.objectView.filterBy"),type:"custom",render:(c,d,u)=>{const m=r.conditions.length,p=m>0?e("console.objectView.filtersCount",{count:m}):e("console.objectView.none");return t.jsx(je,{renderSummary:g=>t.jsx(H,{label:e("console.objectView.filterBy"),value:p,onClick:g}),children:t.jsx("div",{"data-testid":"inline-filter-builder",className:"pb-2",children:t.jsx(Ps,{fields:n,value:r,onChange:g=>{const x=Zo(g.logic,g.conditions.map(h=>({field:h.field,operator:h.operator,value:h.value})));s("filter",x)},className:"[&_button]:h-7 [&_button]:text-xs [&_input]:h-7 [&_input]:text-xs",showClearAll:!0})})})}},{key:"_sortBy",label:e("console.objectView.sortBy"),type:"custom",render:(c,d,u)=>{const m=Array.isArray(u.sort)?u.sort.filter(g=>g.field).length:0,p=m>0?e("console.objectView.sortsCount",{count:m}):e("console.objectView.none");return t.jsx(je,{renderSummary:g=>t.jsx(H,{label:e("console.objectView.sortBy"),value:p,onClick:g}),children:t.jsx("div",{"data-testid":"inline-sort-builder",className:"pb-2",children:t.jsx(Is,{fields:n.map(g=>({value:g.value,label:g.label})),value:l,onChange:g=>{const x=g.map(h=>({id:h.id,field:h.field,order:h.order}));s("sort",x)},className:"[&_button]:h-7 [&_button]:text-xs"})})})}},{key:"_groupBy",label:e("console.objectView.groupBy"),type:"custom",visibleWhen:ci,render:(c,d,u)=>{const m=u.type||"grid",p=u.kanban?.groupByField||u.kanban?.groupField||u.groupBy||"";return t.jsx(H,{label:e("console.objectView.groupBy"),children:t.jsxs("select",{"data-testid":"data-groupBy",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:p,onChange:g=>{if(s("groupBy",g.target.value),m==="kanban"){const x=u.kanban||{};s("kanban",{...x,groupByField:g.target.value})}},children:[t.jsx("option",{value:"",children:e("console.objectView.none")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})})}},{key:"_pageSize",label:e("console.objectView.pageSize"),type:"custom",render:(c,d,u)=>t.jsx(H,{label:e("console.objectView.pageSize"),children:t.jsx(X,{"data-testid":"input-pagination-pageSize",className:"h-7 text-xs w-20 text-right",type:"number",value:u.pagination?.pageSize??"",placeholder:"25",onChange:m=>{const p=Number(m.target.value)||void 0;s("pagination",{...u.pagination||{},pageSize:p})}})})},{key:"_pageSizeOptions",label:e("console.objectView.pageSizeOptions"),type:"custom",render:(c,d,u)=>t.jsx(H,{label:e("console.objectView.pageSizeOptions"),children:t.jsx(X,{"data-testid":"input-pagination-pageSizeOptions",className:"h-7 text-xs w-28 text-right",value:(u.pagination?.pageSizeOptions||[]).join(", "),placeholder:"10, 25, 50, 100",onChange:m=>{const p=Qo(m.target.value);s("pagination",{...u.pagination||{},pageSizeOptions:p.length?p:void 0})}})})},Nt("searchableFields",e("console.objectView.searchableFields"),"searchable-fields-selector","searchable-field",n,s,"selected"),Nt("filterableFields",e("console.objectView.filterableFields"),"filterable-fields-selector","filterable-field",n,s,"selected"),Nt("hiddenFields",e("console.objectView.hiddenFields"),"hidden-fields-selector","hidden-field",n,s,"hidden"),{key:"_quickFilters",label:e("console.objectView.quickFilters"),type:"custom",render:(c,d,u)=>t.jsx(je,{renderSummary:m=>t.jsx(H,{label:e("console.objectView.quickFilters"),value:`${(u.quickFilters||[]).length} filters`,onClick:m}),children:t.jsxs("div",{"data-testid":"quick-filters-editor",className:"pb-2 space-y-1",children:[(u.quickFilters||[]).map((m,p)=>t.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[t.jsx(X,{"data-testid":`quick-filter-label-${p}`,className:"h-6 text-xs flex-1",value:m.label||"",placeholder:"Label",onChange:g=>{const x=[...u.quickFilters||[]];x[p]={...x[p],label:g.target.value},s("quickFilters",x)}}),t.jsx(Gt,{"data-testid":`quick-filter-default-${p}`,checked:m.defaultActive===!0,onCheckedChange:g=>{const x=[...u.quickFilters||[]];x[p]={...x[p],defaultActive:g},s("quickFilters",x)},className:"h-3.5 w-3.5"}),t.jsx("button",{type:"button",className:"text-destructive hover:text-destructive/80 text-xs",onClick:()=>{const g=(u.quickFilters||[]).filter((x,h)=>h!==p);s("quickFilters",g)},children:"✕"})]},m.id||p)),t.jsxs("button",{type:"button","data-testid":"add-quick-filter",className:"text-xs text-primary hover:underline",onClick:()=>{const m={id:crypto.randomUUID(),label:"",filters:[],defaultActive:!1};s("quickFilters",[...u.quickFilters||[],m])},children:["+ ",e("console.objectView.addQuickFilter")]})]})})},ne("virtualScroll",e("console.objectView.virtualScroll"),"toggle-virtualScroll",!1,!0,void 0,ue),{key:"_typeOptions",label:"Type-specific options",type:"custom",render:(c,d,u)=>{const m=u.type||"grid",p=(g,x,h)=>{const F=u[g]||{};s(g,{...F,[x]:h})};return m==="grid"?t.jsx("div",{"data-testid":"type-options-section",className:"hidden"}):t.jsxs("div",{"data-testid":"type-options-section",className:"pt-1 space-y-2",children:[m==="kanban"&&t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.groupByField")}),t.jsxs("select",{"data-testid":"type-opt-kanban-groupByField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.kanban?.groupByField||u.kanban?.groupField||"",onChange:g=>p("kanban","groupByField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),m==="calendar"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.startDateField")}),t.jsxs("select",{"data-testid":"type-opt-calendar-startDateField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.calendar?.startDateField||"",onChange:g=>p("calendar","startDateField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.endDateField")}),t.jsxs("select",{"data-testid":"type-opt-calendar-endDateField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.calendar?.endDateField||"",onChange:g=>p("calendar","endDateField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.titleField")}),t.jsxs("select",{"data-testid":"type-opt-calendar-titleField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.calendar?.titleField||"",onChange:g=>p("calendar","titleField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]})]}),m==="map"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.latitudeField")}),t.jsxs("select",{"data-testid":"type-opt-map-latitudeField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.map?.latitudeField||"",onChange:g=>p("map","latitudeField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.longitudeField")}),t.jsxs("select",{"data-testid":"type-opt-map-longitudeField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.map?.longitudeField||"",onChange:g=>p("map","longitudeField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]})]}),m==="gallery"&&t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.imageField")}),t.jsxs("select",{"data-testid":"type-opt-gallery-imageField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.gallery?.imageField||"",onChange:g=>p("gallery","imageField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),(m==="timeline"||m==="gantt")&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.dateField")}),t.jsxs("select",{"data-testid":`type-opt-${m}-dateField`,className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u[m]?.dateField||u[m]?.startDateField||"",onChange:g=>p(m,"dateField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.titleField")}),t.jsxs("select",{"data-testid":`type-opt-${m}-titleField`,className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u[m]?.titleField||"",onChange:g=>p(m,"titleField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]})]})]})}}]}}function xi(e,n,a,o){return{key:"appearance",title:e("console.objectView.appearance"),collapsible:!0,defaultCollapsed:!0,fields:[ne("striped",e("console.objectView.striped"),"toggle-striped",!1,!0,void 0,ue),ne("bordered",e("console.objectView.bordered"),"toggle-bordered",!1,!0,void 0,ue),{key:"color",label:e("console.objectView.color"),type:"custom",visibleWhen:$a,render:(s,r)=>t.jsx(H,{label:e("console.objectView.color"),children:t.jsxs("select",{"data-testid":"appearance-color",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:s||"",onChange:l=>r(l.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.none")}),n.map(l=>t.jsx("option",{value:l.value,children:l.label},l.value))]})})},ne("wrapHeaders",e("console.objectView.wrapHeaders"),"toggle-wrapHeaders",!1,!0,void 0,ue),ne("showDescription",e("console.objectView.showFieldDescriptions"),"toggle-showDescription",!0),ne("resizable",e("console.objectView.resizableColumns"),"toggle-resizable",!1,!0,void 0,ue),{key:"rowHeight",label:e("console.objectView.rowHeight"),type:"custom",visibleWhen:ue,render:(s,r)=>t.jsx(H,{label:e("console.objectView.rowHeight"),children:t.jsx("div",{className:"flex gap-0.5","data-testid":"appearance-rowHeight",role:"radiogroup","aria-label":e("console.objectView.rowHeight"),children:ei.map(l=>t.jsx("button",{type:"button",role:"radio","aria-checked":(s||"compact")===l.value,"aria-label":l.value,"data-testid":`row-height-${l.value}`,className:`h-7 w-7 rounded border flex items-center justify-center ${(s||"compact")===l.value?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:bg-accent/50"}`,onClick:()=>r(l.value),title:l.value,children:t.jsxs("div",{className:`flex flex-col items-center justify-center w-4 h-4 ${l.gapClass}`,children:[t.jsx("div",{className:"w-3.5 h-px bg-current rounded-full"}),t.jsx("div",{className:"w-3.5 h-px bg-current rounded-full"}),t.jsx("div",{className:"w-3.5 h-px bg-current rounded-full"})]})},l.value))})})},{key:"_conditionalFormatting",label:e("console.objectView.conditionalFormatting"),type:"custom",visibleWhen:li,render:(s,r,l)=>t.jsx(je,{renderSummary:c=>t.jsx(H,{label:e("console.objectView.conditionalFormatting"),value:`${(l.conditionalFormatting||[]).length} rules`,onClick:c}),children:t.jsxs("div",{"data-testid":"conditional-formatting-editor",className:"pb-2 space-y-1",children:[(l.conditionalFormatting||[]).map((c,d)=>t.jsxs("div",{className:"flex items-center gap-1 text-xs border rounded p-1",children:[t.jsxs("select",{"data-testid":`cf-field-${d}`,className:"text-xs h-6 rounded border border-input bg-background px-1 flex-1",value:c.field||"",onChange:u=>{const m=[...l.conditionalFormatting||[]];m[d]={...m[d],field:u.target.value},o("conditionalFormatting",m)},children:[t.jsx("option",{value:"",children:"Field"}),n.map(u=>t.jsx("option",{value:u.value,children:u.label},u.value))]}),t.jsxs("select",{"data-testid":`cf-operator-${d}`,className:"text-xs h-6 rounded border border-input bg-background px-1",value:c.operator||"equals",onChange:u=>{const m=[...l.conditionalFormatting||[]];m[d]={...m[d],operator:u.target.value},o("conditionalFormatting",m)},children:[t.jsx("option",{value:"equals",children:"="}),t.jsx("option",{value:"not_equals",children:"≠"}),t.jsx("option",{value:"contains",children:"contains"}),t.jsx("option",{value:"greater_than",children:">"}),t.jsx("option",{value:"less_than",children:"<"}),t.jsx("option",{value:"in",children:"in"})]}),t.jsx(X,{"data-testid":`cf-value-${d}`,className:"h-6 text-xs w-16",value:String(c.value??""),placeholder:"Value",onChange:u=>{const m=[...l.conditionalFormatting||[]];m[d]={...m[d],value:u.target.value},o("conditionalFormatting",m)}}),t.jsx("button",{type:"button",className:"text-destructive hover:text-destructive/80 text-xs",onClick:()=>{const u=(l.conditionalFormatting||[]).filter((m,p)=>p!==d);o("conditionalFormatting",u)},children:"✕"})]},d)),t.jsxs("button",{type:"button","data-testid":"add-conditional-rule",className:"text-xs text-primary hover:underline",onClick:()=>{const c={field:"",operator:"equals",value:""};o("conditionalFormatting",[...l.conditionalFormatting||[],c])},children:["+ ",e("console.objectView.addRule")]})]})})},{key:"_emptyState",label:"Empty state",type:"custom",render:(s,r,l)=>t.jsxs(t.Fragment,{children:[t.jsx(H,{label:e("console.objectView.emptyStateTitle"),children:t.jsx(X,{"data-testid":"input-emptyState-title",className:"h-7 text-xs w-28 text-right",value:l.emptyState?.title??"",onChange:c=>o("emptyState",{...l.emptyState||{},title:c.target.value})})}),t.jsx(H,{label:e("console.objectView.emptyStateMessage"),children:t.jsx(X,{"data-testid":"input-emptyState-message",className:"h-7 text-xs w-28 text-right",value:l.emptyState?.message??"",onChange:c=>o("emptyState",{...l.emptyState||{},message:c.target.value})})}),t.jsx(H,{label:e("console.objectView.emptyStateIcon"),children:t.jsx(X,{"data-testid":"input-emptyState-icon",className:"h-7 text-xs w-28 text-right",value:l.emptyState?.icon??"",onChange:c=>o("emptyState",{...l.emptyState||{},icon:c.target.value})})})]})}]}}function bi(e,n){return{key:"userActions",title:e("console.objectView.userActions"),collapsible:!0,defaultCollapsed:!0,fields:[ne("inlineEdit",e("console.objectView.inlineEdit"),"toggle-inlineEdit",!0,!1,void 0,ue),ne("addDeleteRecordsInline",e("console.objectView.addDeleteRecordsInline"),"toggle-addDeleteRecordsInline",!0,!1,void 0,ue),{key:"_rowActions",label:e("console.objectView.rowActions"),type:"custom",visibleWhen:Tn,render:(a,o,s)=>t.jsx(je,{renderSummary:r=>t.jsx(H,{label:e("console.objectView.rowActions"),value:`${(s.rowActions||[]).length} actions`,onClick:r}),children:t.jsx("div",{"data-testid":"row-actions-selector",className:"pb-2 space-y-0.5 max-h-36 overflow-auto",children:t.jsx(X,{"data-testid":"input-rowActions",className:"h-7 text-xs w-full",value:(s.rowActions||[]).join(", "),placeholder:"edit, delete, duplicate",onChange:r=>{n("rowActions",An(r.target.value))}})})})},{key:"_bulkActions",label:e("console.objectView.bulkActions"),type:"custom",visibleWhen:Tn,render:(a,o,s)=>t.jsx(je,{renderSummary:r=>t.jsx(H,{label:e("console.objectView.bulkActions"),value:`${(s.bulkActions||[]).length} actions`,onClick:r}),children:t.jsx("div",{"data-testid":"bulk-actions-selector",className:"pb-2 space-y-0.5 max-h-36 overflow-auto",children:t.jsx(X,{"data-testid":"input-bulkActions",className:"h-7 text-xs w-full",value:(s.bulkActions||[]).join(", "),placeholder:"delete, export, assign",onChange:r=>{n("bulkActions",An(r.target.value))}})})})}]}}function ji(e,n){return{key:"sharing",title:e("console.objectView.sharing"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_sharingEnabled",label:e("console.objectView.sharingEnabled"),type:"custom",render:(a,o,s)=>t.jsx(H,{label:e("console.objectView.sharingEnabled"),children:t.jsx(Ve,{"data-testid":"toggle-sharing-enabled",checked:s.sharing?.enabled===!0,onCheckedChange:r=>n("sharing",{...s.sharing||{},enabled:r}),className:"scale-75"})})},{key:"_sharingVisibility",label:e("console.objectView.sharingVisibility"),type:"custom",visibleWhen:a=>a.sharing?.enabled===!0,render:(a,o,s)=>t.jsx(H,{label:e("console.objectView.sharingVisibility"),children:t.jsxs("select",{"data-testid":"select-sharing-visibility",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:s.sharing?.visibility||"private",onChange:r=>n("sharing",{...s.sharing||{},enabled:!0,visibility:r.target.value}),children:[t.jsx("option",{value:"private",children:"Private"}),t.jsx("option",{value:"team",children:"Team"}),t.jsx("option",{value:"organization",children:"Organization"}),t.jsx("option",{value:"public",children:"Public"})]})})}]}}function yi(e,n){return{key:"accessibility",title:e("console.objectView.accessibility"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_ariaLabel",label:e("console.objectView.ariaLabel"),type:"custom",render:(a,o,s)=>t.jsx(H,{label:e("console.objectView.ariaLabel"),children:t.jsx(X,{"data-testid":"input-aria-label",className:"h-7 text-xs w-28 text-right",value:s.aria?.label??"",onChange:r=>n("aria",{...s.aria||{},label:r.target.value})})})},{key:"_ariaDescribedBy",label:e("console.objectView.ariaDescribedBy"),type:"custom",render:(a,o,s)=>t.jsx(H,{label:e("console.objectView.ariaDescribedBy"),children:t.jsx(X,{"data-testid":"input-aria-describedBy",className:"h-7 text-xs w-28 text-right",value:s.aria?.describedBy??"",onChange:r=>n("aria",{...s.aria||{},describedBy:r.target.value})})})},{key:"_ariaLive",label:e("console.objectView.ariaLive"),type:"custom",render:(a,o,s)=>t.jsx(H,{label:e("console.objectView.ariaLive"),children:t.jsxs("select",{"data-testid":"select-aria-live",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[100px]",value:s.aria?.live||"off",onChange:r=>n("aria",{...s.aria||{},live:r.target.value}),children:[t.jsx("option",{value:"off",children:"Off"}),t.jsx("option",{value:"polite",children:"Polite"}),t.jsx("option",{value:"assertive",children:"Assertive"})]})})}]}}function ne(e,n,a,o=!1,s=!1,r,l){return{key:e,label:n,type:"custom",disabledWhen:r,visibleWhen:l,render:(c,d,u)=>t.jsx(H,{label:n,children:t.jsx(Ve,{"data-testid":a,checked:s?c===!0:o?c!==!1:!!c,disabled:!1,onCheckedChange:m=>d(m),className:"scale-75"})})}}function Nt(e,n,a,o,s,r,l,c){return{key:`_${e}`,label:n,type:"custom",visibleWhen:c,render:(d,u,m)=>t.jsx(je,{renderSummary:p=>t.jsx(H,{label:n,value:`${(m[e]||[]).length} ${l}`,onClick:p}),children:t.jsx("div",{"data-testid":a,className:"pb-2 space-y-0.5 max-h-36 overflow-auto",children:s.map(p=>t.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1",children:[t.jsx(Gt,{"data-testid":`${o}-${p.value}`,checked:(m[e]||[]).includes(p.value),onCheckedChange:g=>{const x=m[e]||[],h=g?[...x,p.value]:x.filter(F=>F!==p.value);r(e,h)},className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:p.label})]},p.value))})})}}function vi({open:e,onClose:n,mode:a="edit",activeView:o,objectDef:s,onViewUpdate:r,onSave:l,onCreate:c}){const{t:d}=me(),u=i.useRef(null),m=i.useMemo(()=>({id:`view_${Date.now()}`,label:d("console.objectView.newView"),type:"grid",columns:[],filter:[],sort:[],showSearch:!0,showFilters:!0,showSort:!0}),[]),p=a==="create"?"create":o.id,g=i.useMemo(()=>({...o}),[p]),x=a==="create"?m:g,{draft:h,isDirty:F,updateField:y,discard:k,undo:E,redo:A,canUndo:f,canRedo:N}=Ls(x,{mode:a,onUpdate:r});i.useEffect(()=>{e&&u.current&&u.current.focus()},[e]);const b=i.useMemo(()=>ti(s),[s.fields]),j=i.useMemo(()=>ni(h.filter),[h.filter]),w=i.useMemo(()=>ai(h.sort),[h.sort]),R=i.useMemo(()=>di({t:d,fieldOptions:b,objectDef:s,updateField:y,filterGroupValue:j,sortItemsValue:w}),[d,b,s,y,j,w]),S=h.type||"grid",M=i.useMemo(()=>({...R,breadcrumb:[d("console.objectView.page"),tn[S]||S]}),[R,d,S]),v=i.useCallback(()=>{a==="create"?c?.(h):l?.(h),k()},[h,l,c,a,k]),_=i.useCallback(()=>{if(a==="create"){n();return}k()},[k,a,n]),T=d(a==="create"?"console.objectView.createView":"console.objectView.configureView");return t.jsx($s,{open:e,onClose:n,schema:M,draft:h,isDirty:F,onFieldChange:y,onSave:v,onDiscard:_,onUndo:E,onRedo:A,canUndo:f,canRedo:N,undoLabel:d("designer.undo"),redoLabel:d("designer.redo"),objectDef:s,saveLabel:d("console.objectView.save"),discardLabel:d("console.objectView.discard"),panelRef:u,role:"complementary",ariaLabel:T,tabIndex:-1,testId:"view-config-panel",closeTitle:d("console.objectView.closePanel"),footerTestId:"view-config-footer",saveTestId:"view-config-save",discardTestId:"view-config-discard",className:"transition-all overflow-hidden"})}function wi({objectName:e,objectLabel:n,dataSource:a,onEdit:o,onRefresh:s}){const r=Oe(),{appName:l}=We(),c=`/apps/${l}`,{execute:d,loading:u,error:m,runner:p}=oa({context:{objectName:e,objectLabel:n||e,baseUrl:c}});i.useEffect(()=>{p.registerHandler("create",async()=>(o?.(null),{success:!0})),p.registerHandler("delete",async y=>{const k=y.params?.recordId||y.recordId;if(!k)return{success:!1,error:"No record ID provided"};try{return await a.delete(e,k),s?.(),K.success(`${n||e} deleted successfully`),{success:!0,reload:!0}}catch(E){return K.error(`Failed to delete ${n||e}`,{description:E.message}),{success:!1,error:E.message}}}),p.registerHandler("navigate",async y=>{const k=y.params?.url||y.url;return k&&r(k.startsWith("/")?k:`${c}/${k}`),{success:!0}}),p.registerHandler("refresh",async()=>(s?.(),{success:!0,reload:!0}))},[p,e,a,o,s,r,c]);const g=i.useCallback(()=>{o?.(null)},[o]),x=i.useCallback(async y=>d({type:"delete",confirmText:"Are you sure you want to delete this record?",params:{recordId:y}}),[d]),h=i.useCallback(y=>{r(`${c}/${e}/view/${y}`)},[r,c,e]),F=i.useCallback(y=>{r(`${c}/${e}/record/${y}`)},[r,c,e]);return{execute:d,create:g,deleteRecord:x,navigateToView:h,navigateToRecord:F,loading:u,error:m}}const Ni={grid:kt,kanban:Nr,calendar:ba,gallery:wr,timeline:vr,gantt:yr,map:jr,chart:ga},Ci=[{type:"grid",label:"Grid",description:"Spreadsheet-style rows and columns"},{type:"kanban",label:"Kanban",description:"Drag cards between columns"},{type:"calendar",label:"Calendar",description:"View records on a calendar"},{type:"gallery",label:"Gallery",description:"Visual card layout"},{type:"timeline",label:"Timeline",description:"Chronological event view"},{type:"gantt",label:"Gantt",description:"Project timeline with dependencies"},{type:"map",label:"Map",description:"Geographic location view"},{type:"chart",label:"Chart",description:"Data visualization"}],Si={id:"current-user",name:"Demo User"};function Vn({objectDef:e,recordId:n,dataSource:a,onEdit:o}){const{user:s}=gt(),r=s?{id:s.id,name:s.name,avatar:s.image}:Si,[l,c]=i.useState([]);i.useEffect(()=>{if(!a||!e?.name||!n)return;const p=`${e.name}:${n}`;a.find("sys_comment",{$filter:`threadId eq '${p}'`,$orderby:"createdAt asc"}).then(g=>{g.data?.length&&c(g.data.map(x=>({id:x.id,type:"comment",actor:x.author?.name??"Unknown",actorAvatarUrl:x.author?.avatar,body:x.content,createdAt:x.createdAt,updatedAt:x.updatedAt,parentId:x.parentId,reactions:x.reactions?Object.entries(x.reactions).map(([h,F])=>({emoji:h,count:F.length,reacted:F.includes(r.id)})):void 0})))}).catch(()=>{})},[a,e?.name,n,r.id]);const d=i.useCallback(async p=>{const g={id:crypto.randomUUID(),type:"comment",actor:r.name,actorAvatarUrl:"avatar"in r?r.avatar:void 0,body:p,createdAt:new Date().toISOString()};if(c(x=>[...x,g]),a){const x=`${e.name}:${n}`;a.create("sys_comment",{id:g.id,threadId:x,author:r,content:p,mentions:[],createdAt:g.createdAt}).catch(()=>{})}},[r,a,e?.name,n]),u=i.useCallback(async(p,g)=>{const x={id:crypto.randomUUID(),type:"comment",actor:r.name,actorAvatarUrl:"avatar"in r?r.avatar:void 0,body:g,createdAt:new Date().toISOString(),parentId:p};if(c(h=>[...h,x].map(y=>y.id===p?{...y,replyCount:(y.replyCount??0)+1}:y)),a){const h=`${e.name}:${n}`;a.create("sys_comment",{id:x.id,threadId:h,author:r,content:g,mentions:[],createdAt:x.createdAt,parentId:p}).catch(()=>{})}},[r,a,e?.name,n]),m=i.useCallback((p,g)=>{c(x=>x.map(h=>{if(h.id!==p)return h;const F=[...h.reactions??[]],y=F.findIndex(E=>E.emoji===g);if(y>=0){const E=F[y];E.reacted?E.count<=1?F.splice(y,1):F[y]={...E,count:E.count-1,reacted:!1}:F[y]={...E,count:E.count+1,reacted:!0}}else F.push({emoji:g,count:1,reacted:!0});const k={...h,reactions:F};return a&&a.update("sys_comment",String(p),{$toggleReaction:{emoji:g,userId:r.id}}).catch(()=>{}),k}))},[r.id,a]);return t.jsxs("div",{className:"h-full bg-background overflow-auto p-3 sm:p-4 lg:p-6",children:[t.jsx(Ar,{schema:{type:"detail-view",objectName:e.name,resourceId:n,showBack:!1,showEdit:!0,title:e.label,sections:[{title:"Details",fields:Object.keys(e.fields||{}).map(p=>({name:p,label:e.fields[p].label||p,type:e.fields[p].type||"text"}))}]},dataSource:a,onEdit:()=>o({_id:n,id:n})}),t.jsx("div",{className:"mt-6 border-t pt-6",children:t.jsx(Tr,{config:{position:"bottom",collapsible:!0,defaultCollapsed:!0,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:l,onAddComment:d,onAddReply:u,onToggleReaction:m})})]})}function Rn({dataSource:e,objects:n,onEdit:a}){const o=Oe(),{objectName:s,viewId:r}=We(),[l,c]=ss(),{showDebug:d,toggleDebug:u}=Go(),{t:m}=me(),{objectLabel:p,objectDescription:g}=la(),[x,h]=i.useState(!1),[F,y]=i.useState("edit"),[k,E]=i.useState(null),A=i.useCallback(C=>{if(E(C),I(B=>B+1),e?.updateViewConfig){const B=s,oe=C.id;B&&oe?e.updateViewConfig(B,oe,C).catch(xe=>{console.error("[ViewConfigPanel] Failed to persist view config:",xe)}):console.warn("[ViewConfigPanel] Cannot persist view config: missing objectName or viewId.")}else console.warn("[ViewConfigPanel] dataSource.updateViewConfig is not available. View config saved locally only.")},[e,s]),f=i.useCallback(async C=>{try{if(e?.create){const B={objectName:s,...C};await e.create("sys_view",B)}h(!1),y("edit"),I(B=>B+1)}catch(B){console.error("[ViewConfigPanel] Failed to create view:",B)}},[e,s]),[N,b]=i.useState(void 0),{user:j}=gt(),w=j?.role==="admin",{can:R}=ca(),S=n.find(C=>C.name===s);if(!S)return t.jsx("div",{className:"h-full p-4 flex items-center justify-center",children:t.jsxs(mt,{children:[t.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:t.jsx(kt,{className:"h-6 w-6 text-muted-foreground"})}),t.jsx(pt,{children:m("console.objectView.objectNotFound")}),t.jsxs(ht,{children:[m("console.objectView.objectNotFoundDescription",{objectName:s})," ",m("console.objectView.objectNotFoundHint")]})]})});const M=i.useMemo(()=>{const C=S.listViews||S.list_views||{},B=Object.entries(C).map(([oe,xe])=>({id:oe,...xe,type:xe.type||"grid"}));return B.length===0&&B.push({id:"all",label:m("console.objectView.allRecords"),type:"grid",columns:S.fields?Object.keys(S.fields).slice(0,5):[]}),B},[S]),v=r||l.get("view")||M[0]?.id,_=M.find(C=>C.id===v)||M[0],T=k&&k.id===_?.id?{..._,...k}:_,L=i.useCallback((C,B)=>{E(oe=>({...oe||{},id:_?.id,[C]:B}))},[_?.id]),U=C=>{const B=M.find(oe=>oe.id===C);B&&(h(!1),r?o(`../${B.id}`,{relative:"path"}):o(`view/${B.id}`))},P=i.useCallback(()=>{y("create"),h(!0)},[]),$=i.useCallback((C,B)=>{if(C==="settings"){const oe=M.find(xe=>xe.type===B);oe&&U(oe.id),y("edit"),h(!0)}},[M,U]),[O,I]=i.useState(0),D=wi({objectName:S.name,objectLabel:S.label,dataSource:e,onEdit:a,onRefresh:()=>I(C=>C+1)}),{lastMessage:G}=no({channel:`object:${S.name}`}),W=S.name?`user-${S.name}`:"current-user",{hasConflicts:Q,resolveAllConflicts:se}=so(W);i.useEffect(()=>{G&&(Q&&se("remote"),I(C=>C+1))},[G,Q,se]),i.useEffect(()=>{e?.find&&S.name&&e.find(S.name,{limit:0}).then(C=>{typeof C?.total=="number"?b(C.total):Array.isArray(C?.data)?b(C.data.length):Array.isArray(C)&&b(C.length)}).catch(()=>{})},[e,S.name,O]);const le=i.useMemo(()=>T?.navigation??S.navigation??{mode:"page"},[T?.navigation,S.navigation]),ce=l.get("recordId"),xt=i.useCallback((C,B)=>{if(B==="new_window"){const oe=window.location.pathname.replace(/\/view\/.*$/,"");window.open(`${oe}/record/${String(C)}`,"_blank");return}(B==="view"||!B||B==="page")&&(r?o(`../../record/${String(C)}`,{relative:"path"}):o(`record/${String(C)}`))},[o,r]),re=Ie({navigation:le,objectName:S.name,onNavigate:xt}),nn=()=>{re.close();const C=new URLSearchParams(l);C.delete("recordId"),c(C)};i.useEffect(()=>{ce&&!re.isOpen?re.open({_id:ce,id:ce}):!ce&&re.isOpen&&re.close()},[ce]);const an=i.useCallback(({schema:C,dataSource:B,onEdit:oe,className:xe})=>{const on=`${s}-${T.id}-${O}`,V=T;if(V.type==="chart"){const ge=V.chart||{};return t.jsx(Xt,{dataSource:B,schema:{type:"object-chart",objectName:S.name,chartType:ge.chartType,xAxisField:ge.xAxisField,yAxisFields:ge.yAxisFields,aggregation:ge.aggregation,series:ge.series,config:ge.config,filter:ge.filter}},on)}const as={...C,rowHeight:V.rowHeight??C.rowHeight,densityMode:V.densityMode??C.densityMode,inlineEdit:V.inlineEdit??V.editRecordsInline??C.inlineEdit,appearance:V.showDescription!=null?{showDescription:V.showDescription}:C.appearance,showSearch:V.showSearch??C.showSearch,showSort:V.showSort??C.showSort,showFilters:V.showFilters??C.showFilters,showHideFields:V.showHideFields??C.showHideFields,showGroup:V.showGroup??C.showGroup,showColor:V.showColor??C.showColor,showDensity:V.showDensity??C.showDensity,allowExport:V.allowExport??C.allowExport,exportOptions:V.allowExport===!1?void 0:V.exportOptions??C.exportOptions,striped:V.striped??C.striped,bordered:V.bordered??C.bordered,color:V.color??C.color,wrapHeaders:V.wrapHeaders??C.wrapHeaders,clickIntoRecordDetails:V.clickIntoRecordDetails??C.clickIntoRecordDetails,addRecordViaForm:V.addRecordViaForm??C.addRecordViaForm,addDeleteRecordsInline:V.addDeleteRecordsInline??C.addDeleteRecordsInline,collapseAllByDefault:V.collapseAllByDefault??C.collapseAllByDefault,fieldTextColor:V.fieldTextColor??C.fieldTextColor,prefixField:V.prefixField??C.prefixField,showDescription:V.showDescription??C.showDescription,navigation:V.navigation??C.navigation,selection:V.selection??C.selection,pagination:V.pagination??C.pagination,searchableFields:V.searchableFields??C.searchableFields,filterableFields:V.filterableFields??C.filterableFields,resizable:V.resizable??C.resizable,hiddenFields:V.hiddenFields??C.hiddenFields,rowActions:V.rowActions??C.rowActions,bulkActions:V.bulkActions??C.bulkActions,sharing:V.sharing??C.sharing,addRecord:V.addRecord??C.addRecord,conditionalFormatting:V.conditionalFormatting??C.conditionalFormatting,quickFilters:V.quickFilters??C.quickFilters,showRecordCount:V.showRecordCount??C.showRecordCount,allowPrinting:V.allowPrinting??C.allowPrinting,virtualScroll:V.virtualScroll??C.virtualScroll,emptyState:V.emptyState??C.emptyState,aria:V.aria??C.aria,tabs:C.tabs,...V.filter?.length?{filters:V.filter}:{},...V.sort?.length?{sort:V.sort}:{},options:{kanban:{groupBy:V.kanban?.groupByField||V.kanban?.groupField||"status",groupField:V.kanban?.groupByField||V.kanban?.groupField||"status",titleField:V.kanban?.titleField||S.titleField||"name",cardFields:V.kanban?.columns},calendar:{startDateField:V.calendar?.startDateField||"due_date",endDateField:V.calendar?.endDateField,titleField:V.calendar?.titleField||"name",colorField:V.calendar?.colorField,allDayField:V.calendar?.allDayField,defaultView:V.calendar?.defaultView},timeline:{dateField:V.timeline?.dateField||"due_date",titleField:V.timeline?.titleField||S.titleField||"name",descriptionField:V.timeline?.descriptionField},map:{locationField:V.map?.locationField,titleField:V.map?.titleField||S.titleField||"name",latitudeField:V.map?.latitudeField,longitudeField:V.map?.longitudeField,zoom:V.map?.zoom,center:V.map?.center},gallery:{imageField:V.gallery?.imageField||"image",titleField:V.gallery?.titleField||S.titleField||"name",subtitleField:V.gallery?.subtitleField},gantt:{startDateField:V.gantt?.startDateField||"start_date",endDateField:V.gantt?.endDateField||"end_date",titleField:V.gantt?.titleField||"name",progressField:V.gantt?.progressField,dependenciesField:V.gantt?.dependenciesField,colorField:V.gantt?.colorField},chart:{chartType:V.chart?.chartType,xAxisField:V.chart?.xAxisField,yAxisFields:V.chart?.yAxisFields,aggregation:V.chart?.aggregation,series:V.chart?.series,config:V.chart?.config}}};return t.jsx(Er,{schema:as,className:xe,onEdit:oe,onRowClick:ge=>{re.handleClick(ge)},dataSource:B},on)},[T,S,s,O,re]),sn=i.useMemo(()=>M.map(C=>C.id===v&&k&&k.id===C.id?{...C,...k}:C),[M,v,k]),rn=i.useMemo(()=>({type:"object-view",objectName:S.name,layout:"page",showSearch:T?.showSearch!==!1,showFilters:T?.showFilters!==!1,showSort:T?.showSort!==!1,showCreate:!1,showRefresh:!0,allowCreateView:w,viewActions:w?[{type:"settings"},{type:"share"},{type:"duplicate"},{type:"delete"}]:[],onNavigate:(C,B)=>{B==="edit"?a?.({_id:C,id:C}):B==="view"&&(r?o(`../../record/${String(C)}`,{relative:"path"}):o(`record/${String(C)}`))}}),[S.name,a,T?.showSearch,T?.showFilters,T?.showSort,o,r,w]);return t.jsxs("div",{className:"h-full flex flex-col bg-background min-w-0 overflow-hidden",children:[t.jsxs("div",{className:"flex justify-between items-center py-2.5 sm:py-3 px-3 sm:px-4 border-b shrink-0 bg-background z-10",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0 flex-1",children:[t.jsx("div",{className:"bg-primary/10 p-1.5 sm:p-2 rounded-md shrink-0",children:t.jsx(kt,{className:"h-4 w-4 text-primary"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mb-0.5",children:[t.jsx("span",{className:"truncate",children:p(S)}),t.jsx(Je,{className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate font-medium text-foreground",children:T?.label||m("console.objectView.allRecords")})]}),t.jsx("h1",{className:"text-base sm:text-lg font-semibold tracking-tight text-foreground truncate",children:p(S)}),S.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate hidden sm:block max-w-md",children:g(S)})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 shrink-0",children:[R(S.name,"create")&&t.jsxs(Y,{size:"sm",onClick:D.create,className:"shadow-none gap-1.5 sm:gap-2 h-8 sm:h-9",children:[t.jsx(Fe,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:m("console.objectView.new")})]}),S.actions?.some(C=>C.locations?.includes("list_toolbar"))&&t.jsx(Ws,{schema:{type:"action:bar",location:"list_toolbar",actions:S.actions,size:"sm",variant:"outline"}}),w&&t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsx(Y,{size:"sm",variant:"ghost",className:"shadow-none h-8 sm:h-9 px-2",title:m("console.objectView.designTools"),children:t.jsx(xr,{className:"h-4 w-4"})})}),t.jsxs(De,{align:"end",className:"w-48",children:[t.jsxs(ie,{onClick:u,children:[t.jsx(qo,{open:d,onToggle:u,className:"hidden"}),m("console.objectView.metadataInspector")]}),t.jsx(it,{}),t.jsxs(ie,{onClick:()=>{y("edit"),h(C=>!C)},children:[t.jsx(br,{className:"h-4 w-4 mr-2"}),m("console.objectView.editView")]}),t.jsxs(ie,{onClick:()=>{y("create"),h(!0)},children:[t.jsx(Fe,{className:"h-4 w-4 mr-2"}),m("console.objectView.addView")]})]})]})]})]}),M.length>1&&t.jsx("div",{className:"border-b px-3 sm:px-4 bg-background overflow-x-auto shrink-0",children:t.jsx(zs,{views:M.map(C=>({id:C.id,label:C.label,type:C.type,hasActiveFilters:Array.isArray(C.filter)&&C.filter.length>0,hasActiveSort:Array.isArray(C.sort)&&C.sort.length>0})),activeViewId:v,onViewChange:U,viewTypeIcons:Ni,config:{...S.viewTabBar,reorderable:w?!0:S.viewTabBar?.reorderable},onAddView:w?()=>{y("create"),h(!0)}:void 0,onRenameView:(C,B)=>{console.info("[ViewTabBar] Rename view:",C,B)},onDuplicateView:C=>{console.info("[ViewTabBar] Duplicate view:",C)},onDeleteView:C=>{console.info("[ViewTabBar] Delete view:",C)},onSetDefaultView:C=>{console.info("[ViewTabBar] Set default view:",C)},onShareView:C=>{console.info("[ViewTabBar] Share view:",C)},onPinView:(C,B)=>{console.info("[ViewTabBar] Pin view:",C,B)},onReorderViews:C=>{console.info("[ViewTabBar] Reorder views:",C)},onChangeViewType:(C,B)=>{console.info("[ViewTabBar] Change view type:",C,B)},onConfigView:w?C=>{U(C),y("edit"),h(!0)}:void 0,availableViewTypes:Ci})}),t.jsxs("div",{className:"flex-1 overflow-hidden relative flex flex-row",children:[re.mode==="split"&&re.isOpen?t.jsx(ke,{...re,setIsOpen:C=>{C||nn()},title:p(S),mainContent:t.jsxs("div",{className:"flex-1 min-w-0 relative h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 relative overflow-auto p-3 sm:p-4",children:t.jsx(pn,{schema:rn,dataSource:e,views:sn,activeViewId:v,onViewChange:U,onEdit:C=>a?.(C),onRowClick:C=>{re.handleClick(C)},renderListView:an,onCreateView:P,onViewAction:$})}),typeof N=="number"&&t.jsx("div",{"data-testid":"record-count-footer",className:"border-t px-3 sm:px-4 py-1.5 text-xs text-muted-foreground bg-muted/5 shrink-0",children:m("console.objectView.recordCount",{count:N})})]}),children:C=>{const B=C._id||C.id;return t.jsx(Vn,{objectDef:S,recordId:B,dataSource:e,onEdit:a})}}):t.jsx("div",{className:"flex-1 min-w-0 relative h-full flex flex-col",children:t.jsx("div",{className:"flex-1 relative overflow-auto p-3 sm:p-4",children:t.jsx(pn,{schema:rn,dataSource:e,views:sn,activeViewId:v,onViewChange:U,onEdit:C=>a?.(C),onRowClick:C=>{re.handleClick(C)},renderListView:an,onCreateView:P,onViewAction:$})})}),t.jsx(Wo,{open:d&&w,sections:[{title:"View Configuration",data:T},{title:"Object Definition",data:S}]}),t.jsx("div",{"data-testid":"view-config-panel-wrapper",className:`transition-[max-width,opacity] duration-300 ease-in-out overflow-hidden ${x&&w?"max-w-[280px] opacity-100":"max-w-0 opacity-0"}`,children:t.jsx(vi,{open:x&&w,onClose:()=>{h(!1),y("edit")},mode:F,activeView:T,objectDef:S,recordCount:N,onSave:A,onViewUpdate:L,onCreate:f})})]}),re.mode!=="split"&&t.jsx(ke,{...re,setIsOpen:C=>{C||nn()},title:S.label,className:re.mode==="drawer"?"w-[90vw] sm:max-w-2xl p-0 overflow-hidden":void 0,children:C=>{const B=C._id||C.id;return t.jsx(Vn,{objectDef:S,recordId:B,dataSource:e,onEdit:a})}})]})}function Di({children:e,authUrl:n}){const[a,o]=i.useState(null),[s,r]=i.useState(void 0),[l,c]=i.useState(!0);return i.useEffect(()=>{let d=!1;async function u(){try{const m=new da({baseUrl:"",autoReconnect:!1});await m.connect();const p=await m.getDiscovery();if(!d)if(p?.mode==="preview")r({autoLogin:p.previewMode?.autoLogin??!0,simulatedRole:p.previewMode?.simulatedRole??"admin",simulatedUserName:p.previewMode?.simulatedUserName??"Preview User",readOnly:p.previewMode?.readOnly??!1,expiresInSeconds:p.previewMode?.expiresInSeconds??0,bannerMessage:p.previewMode?.bannerMessage}),o(!1);else{const g=p?.services?.auth?.enabled??!0;o(g)}}catch(m){d||(console.warn("[ConditionalAuthWrapper] Failed to fetch discovery, defaulting to auth enabled:",m),o(!0))}finally{d||c(!1)}}return u(),()=>{d=!0}},[]),l?t.jsx(de,{}):s?t.jsx(jt,{authUrl:n,previewMode:s,children:e}):a?t.jsx(jt,{authUrl:n,children:e}):t.jsx(jt,{authUrl:n,enabled:!1,children:e})}function ki(){const{t:e}=me(),[n,a]=i.useState(!1),o=i.useMemo(()=>[{title:e("console.shortcuts.groups.general"),shortcuts:[{keys:["⌘","K"],description:e("console.shortcuts.openCommandPalette")},{keys:["?"],description:e("console.shortcuts.showShortcuts")},{keys:["Esc"],description:e("console.shortcuts.closeDialog")}]},{title:e("console.shortcuts.groups.navigation"),shortcuts:[{keys:["B"],description:e("console.shortcuts.toggleSidebar")},{keys:["⌘","/"],description:e("console.shortcuts.focusSearch")}]},{title:e("console.shortcuts.groups.dataViews"),shortcuts:[{keys:["N"],description:e("console.shortcuts.createRecord")},{keys:["R"],description:e("console.shortcuts.refreshData")},{keys:["⌘","E"],description:e("console.shortcuts.editRecord")}]},{title:e("console.shortcuts.groups.preferences"),shortcuts:[{keys:["⌘","D"],description:e("console.shortcuts.toggleDarkMode")}]}],[e]);return i.useEffect(()=>{function s(r){const l=r.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.isContentEditable||r.key==="?"&&!r.metaKey&&!r.ctrlKey&&!r.altKey&&(r.preventDefault(),a(c=>!c))}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[]),t.jsx(ta,{open:n,onOpenChange:a,children:t.jsxs(na,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[t.jsxs(aa,{children:[t.jsx(sa,{children:e("console.shortcuts.title")}),t.jsx(ra,{children:e("console.shortcuts.description")})]}),t.jsx("div",{className:"space-y-6 pt-2",children:o.map(s=>t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:s.title}),t.jsx("div",{className:"space-y-2",children:s.shortcuts.map((r,l)=>t.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[t.jsx("span",{className:"text-sm",children:r.description}),t.jsx("div",{className:"flex items-center gap-1",children:r.keys.map((c,d)=>t.jsx("kbd",{className:"inline-flex h-6 min-w-[24px] items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground",children:c},d))})]},l))})]},s.title))})]})})}const Mn="objectui-onboarding-dismissed",at=[{icon:ha,title:"Navigate Your Apps",description:"Use the sidebar to browse objects, dashboards, pages, and reports. Switch between apps using the dropdown in the sidebar header."},{icon:qe,title:"Quick Search",description:"Press ⌘K (or Ctrl+K) to open the command palette and quickly jump to any object, dashboard, or page."},{icon:ma,title:"Favorites & Recent",description:"Star frequently used items to pin them in the sidebar. Recently visited items also appear for quick access."},{icon:ja,title:"Keyboard Shortcuts",description:"Press ? to view all keyboard shortcuts. Use them to speed up your workflow with CRUD operations and navigation."}];function Fi(){const[e,n]=i.useState(!1),[a,o]=i.useState(0);i.useEffect(()=>{try{if(!localStorage.getItem(Mn)){const m=setTimeout(()=>n(!0),800);return()=>clearTimeout(m)}}catch{}},[]);const s=()=>{n(!1);try{localStorage.setItem(Mn,new Date().toISOString())}catch{}},r=()=>{a<at.length-1?o(u=>u+1):s()},l=at[a],c=l.icon,d=a===at.length-1;return t.jsx(ta,{open:e,onOpenChange:u=>{u||s()},children:t.jsxs(na,{className:"sm:max-w-md",children:[t.jsxs(aa,{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs(sa,{className:"flex items-center gap-2",children:[t.jsx(ja,{className:"h-5 w-5 text-primary"}),"Welcome to ObjectUI"]}),t.jsxs(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:s,children:[t.jsx(Cr,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]}),t.jsx(ra,{children:"Let's get you started with a quick tour."})]}),t.jsxs("div",{className:"flex flex-col items-center gap-4 py-6 text-center",children:[t.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:t.jsx(c,{className:"h-8 w-8 text-primary"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-lg font-semibold",children:l.title}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:l.description})]})]}),t.jsx("div",{className:"flex items-center justify-center gap-1.5",children:at.map((u,m)=>t.jsx("button",{className:`h-2 w-2 rounded-full transition-colors ${m===a?"bg-primary":"bg-muted-foreground/30"}`,onClick:()=>o(m),"aria-label":`Go to step ${m+1}`},m))}),t.jsxs("div",{className:"flex items-center justify-between pt-2",children:[t.jsx(Y,{variant:"ghost",size:"sm",onClick:s,children:"Skip"}),t.jsxs(Y,{size:"sm",onClick:r,children:[d?"Get Started":"Next",!d&&t.jsx(Sr,{className:"ml-1 h-4 w-4"})]})]})]})})}let _i=0;function On(e="nav"){return`${e}_${Date.now()}_${++_i}`}function Pn(e,n){return[...e,n]}function _t(e,n,a){return e.filter(o=>!(o.type===n&&(n==="page"&&o.pageName===a||n==="dashboard"&&o.dashboardName===a))).map(o=>o.children&&o.children.length>0?{...o,children:_t(o.children,n,a)}:o)}function Et(e,n,a,o){return e.map(s=>{let r=s;return n==="page"&&s.type==="page"&&s.pageName===a?r={...s,pageName:o}:n==="dashboard"&&s.type==="dashboard"&&s.dashboardName===a&&(r={...s,dashboardName:o}),r.children&&r.children.length>0?{...r,children:Et(r.children,n,a,o)}:r})}function st(e,n){return e.length!==n.length?!1:e===n?!0:JSON.stringify(e)===JSON.stringify(n)}function Ei(){const e=Qe(),{apps:n,refresh:a}=Ze(),o=i.useRef(e);o.current=e;const s=i.useRef(a);s.current=a;const r=i.useCallback(async(f,N)=>{const b=o.current?.getClient();b&&await b.meta.saveItem("app",f,N),await s.current?.()},[]),l=i.useCallback(f=>n.find(N=>N.name===f),[n]),c=i.useCallback(async(f,N,b)=>{const j=l(f);if(!j)return;const w=j.navigation??[],R={id:On("nav_page"),type:"page",label:b||N,pageName:N,icon:"FileText"},S=Pn(w,R),M={...j,navigation:S};try{await r(f,M),K.success(`Navigation updated: added page "${b||N}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...j,navigation:w}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),d=i.useCallback(async(f,N,b)=>{const j=l(f);if(!j)return;const w=j.navigation??[],R={id:On("nav_dash"),type:"dashboard",label:b||N,dashboardName:N,icon:"LayoutDashboard"},S=Pn(w,R),M={...j,navigation:S};try{await r(f,M),K.success(`Navigation updated: added dashboard "${b||N}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...j,navigation:w}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),u=i.useCallback(async(f,N)=>{const b=l(f);if(!b)return;const j=b.navigation??[],w=_t(j,"page",N);if(st(w,j))return;const R={...b,navigation:w};try{await r(f,R),K.success(`Navigation updated: removed page "${N}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...b,navigation:j}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),m=i.useCallback(async(f,N)=>{const b=l(f);if(!b)return;const j=b.navigation??[],w=_t(j,"dashboard",N);if(st(w,j))return;const R={...b,navigation:w};try{await r(f,R),K.success(`Navigation updated: removed dashboard "${N}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...b,navigation:j}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),p=i.useCallback(async(f,N,b)=>{const j=l(f);if(!j)return;const w=j.navigation??[],R=Et(w,"page",N,b);if(st(R,w))return;const S={...j,navigation:R};try{await r(f,S),K.success(`Navigation updated: renamed page "${N}" → "${b}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...j,navigation:w}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),g=i.useCallback(async(f,N,b)=>{const j=l(f);if(!j)return;const w=j.navigation??[],R=Et(w,"dashboard",N,b);if(st(R,w))return;const S={...j,navigation:R};try{await r(f,S),K.success(`Navigation updated: renamed dashboard "${N}" → "${b}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...j,navigation:w}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),x=f=>f&&typeof f=="object"&&"name"in f?f.name:void 0,h=i.useCallback(async(f,N)=>{for(const b of n){const j=x(b);j&&await c(j,f,N)}},[n,c]),F=i.useCallback(async(f,N)=>{for(const b of n){const j=x(b);j&&await d(j,f,N)}},[n,d]),y=i.useCallback(async f=>{for(const N of n){const b=x(N);b&&await u(b,f)}},[n,u]),k=i.useCallback(async f=>{for(const N of n){const b=x(N);b&&await m(b,f)}},[n,m]),E=i.useCallback(async(f,N)=>{for(const b of n){const j=x(b);j&&await p(j,f,N)}},[n,p]),A=i.useCallback(async(f,N)=>{for(const b of n){const j=x(b);j&&await g(j,f,N)}},[n,g]);return{syncPageCreated:c,syncDashboardCreated:d,syncPageDeleted:u,syncDashboardDeleted:m,syncPageRenamed:p,syncDashboardRenamed:g,syncPageCreatedAllApps:h,syncDashboardCreatedAllApps:F,syncPageDeletedAllApps:y,syncDashboardDeletedAllApps:k,syncPageRenamedAllApps:E,syncDashboardRenamedAllApps:A}}function Ai(){const{pages:e,dashboards:n,apps:a}=Ze(),o=Qe(),s=i.useRef(o);s.current=o;const{syncPageCreated:r,syncDashboardCreated:l,syncPageDeleted:c,syncDashboardDeleted:d}=Ei(),u=i.useRef(null),m=i.useRef(null),p=i.useRef(0),g=i.useRef(!1),x=h=>h&&typeof h=="object"&&"name"in h?h.name:void 0;return i.useEffect(()=>{if(g.current)return;const h=new Set((e??[]).map(w=>w.name).filter(Boolean)),F=new Set((n??[]).map(w=>w.name).filter(Boolean)),y=u.current,k=m.current;if(y===null||k===null){u.current=h,m.current=F;return}const E=[...h].filter(w=>!y.has(w)),A=[...y].filter(w=>!h.has(w)),f=[...F].filter(w=>!k.has(w)),N=[...k].filter(w=>!F.has(w));if(E.length===0&&A.length===0&&f.length===0&&N.length===0){u.current=h,m.current=F;return}const b=++p.current;g.current=!0;let j=!1;return(async()=>{try{for(const w of a){if(j||p.current!==b)break;const R=x(w);if(R){for(const S of E){if(j)break;await r(R,S)}for(const S of A){if(j)break;await c(R,S)}for(const S of f){if(j)break;await l(R,S)}for(const S of N){if(j)break;await d(R,S)}}}}finally{p.current===b&&(u.current=h,m.current=F,g.current=!1)}})(),()=>{j=!0}},[e,n,a,r,l,c,d]),null}function Ti(e){const{theme:n="system"}=Qt();return t.jsx(Ys,{theme:n,className:"toaster group",icons:{success:t.jsx(Jt,{className:"h-4 w-4"}),info:t.jsx(kr,{className:"h-4 w-4"}),warning:t.jsx(fa,{className:"h-4 w-4"}),error:t.jsx(Dr,{className:"h-4 w-4"}),loading:t.jsx(dt,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})}const Vi=i.lazy(()=>J(()=>import("./RecordDetailView-Cbo06TgT.js"),__vite__mapDeps([20,1,18,9,10,11,8,3,12,13,4,2,14,15,19,17,7,21,22])).then(e=>({default:e.RecordDetailView}))),Ri=i.lazy(()=>J(()=>import("./DashboardView-DxpkEpzI.js"),__vite__mapDeps([23,1,18,9,10,11,8,3,12,13,4,2,14,15,19,17,7,21,22])).then(e=>({default:e.DashboardView}))),Mi=i.lazy(()=>J(()=>import("./PageView-BNyUOHBp.js"),__vite__mapDeps([24,8,1,9,10,11,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.PageView}))),Oi=i.lazy(()=>J(()=>import("./ReportView-DYDYKXxz.js"),__vite__mapDeps([25,1,18,9,10,11,8,3,12,13,4,2,14,15,19,17,7,21,22])).then(e=>({default:e.ReportView}))),Pi=i.lazy(()=>J(()=>import("./SearchResultsPage-BXv9faGO.js"),__vite__mapDeps([26,1,8,9,10,11,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.SearchResultsPage}))),At=i.lazy(()=>J(()=>import("./CreateAppPage-BBV1-x1E.js"),__vite__mapDeps([27,1,28,9,10,11,8,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.CreateAppPage}))),Ii=i.lazy(()=>J(()=>import("./EditAppPage-4REKKtym.js"),__vite__mapDeps([29,1,28,9,10,11,8,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.EditAppPage}))),Li=i.lazy(()=>J(()=>import("./PageDesignPage-bfUbiZI-.js"),__vite__mapDeps([30,1,28,9,10,11,8,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.PageDesignPage}))),$i=i.lazy(()=>J(()=>import("./DashboardDesignPage-Dsve6QAo.js"),__vite__mapDeps([31,1,28,9,10,11,8,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.DashboardDesignPage}))),zi=i.lazy(()=>J(()=>import("./LoginPage-BXP5VJhw.js"),__vite__mapDeps([32,1,14,4])).then(e=>({default:e.LoginPage}))),Bi=i.lazy(()=>J(()=>import("./RegisterPage-By5Xlwoy.js"),__vite__mapDeps([33,1,14,4])).then(e=>({default:e.RegisterPage}))),Ui=i.lazy(()=>J(()=>import("./ForgotPasswordPage-_rDOa2Zl.js"),__vite__mapDeps([34,1,14,4])).then(e=>({default:e.ForgotPasswordPage}))),Tt=i.lazy(()=>J(()=>import("./SystemHubPage-DInbGUIC.js"),__vite__mapDeps([35,1,8,9,10,11,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.SystemHubPage}))),Vt=i.lazy(()=>J(()=>import("./AppManagementPage-Bqi2RIF_.js"),__vite__mapDeps([36,1,8,9,10,11,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.AppManagementPage}))),Rt=i.lazy(()=>J(()=>import("./UserManagementPage-DfN7rtzx.js"),__vite__mapDeps([37,1,14,4,8,9,10,11,3,12,13,2,15,38,17,7,18,19,21,22])).then(e=>({default:e.UserManagementPage}))),Mt=i.lazy(()=>J(()=>import("./OrgManagementPage-9aUMu-3n.js"),__vite__mapDeps([39,1,14,4,8,9,10,11,3,12,13,2,15,38,17,7,18,19,21,22])).then(e=>({default:e.OrgManagementPage}))),Ot=i.lazy(()=>J(()=>import("./RoleManagementPage-DvuObd50.js"),__vite__mapDeps([40,1,14,4,8,9,10,11,3,12,13,2,15,38,17,7,18,19,21,22])).then(e=>({default:e.RoleManagementPage}))),Pt=i.lazy(()=>J(()=>import("./PermissionManagementPage-CfKXMrSe.js"),__vite__mapDeps([41,1,14,4,8,9,10,11,3,12,13,2,15,38,17,7,18,19,21,22])).then(e=>({default:e.PermissionManagementPage}))),It=i.lazy(()=>J(()=>import("./AuditLogPage-Bhvo34U0.js"),__vite__mapDeps([42,1,8,9,10,11,3,12,13,4,2,14,15,38,17,7,18,19,21,22])).then(e=>({default:e.AuditLogPage}))),Lt=i.lazy(()=>J(()=>import("./ProfilePage-aGYrzo6-.js"),__vite__mapDeps([43,1,14,4,8,9,10,11,3,12,13,2,15])).then(e=>({default:e.ProfilePage})));function rt({children:e}){return t.jsx(Kr,{children:t.jsx(Hi,{children:e})})}function Hi({children:e}){const n=Qe();return n?t.jsx(Gr,{adapter:n,children:e}):t.jsx(de,{})}function qi(){const[e,n]=i.useState("disconnected"),{user:a}=gt(),o=Qe(),s=Oe(),r=Kn(),{appName:l}=We(),{apps:c,objects:d,loading:u}=Ze(),m=c.filter(P=>P.active!==!1),p=c.find(P=>P.name===l)||m.find(P=>P.isDefault===!0)||m[0],[g,x]=i.useState(!1),[h,F]=i.useState(null),[y,k]=i.useState(0),{addRecentItem:E}=Da(),{execute:A,runner:f}=oa();Gs({dataSource:o??void 0,onUndo:P=>{K.info(`Undo: ${P.description}`,{duration:4e3}),k($=>$+1)},onRedo:P=>{K.info(`Redo: ${P.description}`,{duration:3e3}),k($=>$+1)}}),i.useEffect(()=>{f.registerHandler("crud_success",async P=>(x(!1),k($=>$+1),K.success(P.params?.message??"Record saved successfully"),{success:!0,reload:!0})),f.registerHandler("dialog_cancel",async()=>(x(!1),{success:!0}))},[f]),i.useEffect(()=>{if(!o)return;const P=o.onConnectionStateChange($=>{n($.state),$.error&&console.error("[Console] Connection error:",$.error)});return n(o.getConnectionState()),P},[o]);let j=r.pathname.split("/").filter(P=>P)[2];(j==="view"||j==="record"||j==="page"||j==="dashboard"||j==="design")&&(j="");const w=d.find(P=>P.name===j),R=i.useCallback(()=>{const P=w?.label||"Record";A({type:"crud_success",params:{message:h?`${P} updated successfully`:`${P} created successfully`}})},[A,h,w?.label]),S=i.useCallback(()=>{A({type:"dialog_cancel"})},[A]);i.useEffect(()=>{if(!p)return;const P=r.pathname.split("/").filter(Boolean);let $=P[2];($==="view"||$==="record"||$==="page"||$==="dashboard"||$==="design")&&($="");const O=`/apps/${p.name}`,I=d;if($){const D=I.find(G=>G.name===$);D&&E({id:`object:${D.name}`,label:D.label||D.name,href:`${O}/${D.name}`,type:"object"})}else P[2]==="dashboard"&&P[3]?E({id:`dashboard:${P[3]}`,label:P[3].replace(/[-_]/g," ").replace(/\b\w/g,D=>D.toUpperCase()),href:`${O}/dashboard/${P[3]}`,type:"dashboard"}):P[2]==="report"&&P[3]&&E({id:`report:${P[3]}`,label:P[3].replace(/[-_]/g," ").replace(/\b\w/g,D=>D.toUpperCase()),href:`${O}/report/${P[3]}`,type:"report"})},[r.pathname,E]);const M=P=>{F(P),x(!0)},v=P=>{s(`/apps/${P}`)},_=i.useMemo(()=>new Kt({user:a?{name:a.name,email:a.email,role:a.role??"user"}:{},app:p||{},data:h||{}}),[a,p,h]);if(!o||u)return t.jsx(de,{});const T=r.pathname.endsWith("/create-app"),L=r.pathname.includes("/system");if(!p&&!T&&!L)return t.jsx("div",{className:"h-screen flex items-center justify-center",children:t.jsxs(mt,{children:[t.jsx(pt,{children:"No Apps Configured"}),t.jsx(ht,{children:"No applications have been registered. Create your first app or visit System Settings to configure your environment."}),t.jsxs("div",{className:"mt-4 flex flex-col sm:flex-row items-center gap-3",children:[t.jsx(Y,{onClick:()=>s("/create-app"),"data-testid":"create-first-app-btn",children:"Create Your First App"}),t.jsx(Y,{variant:"outline",onClick:()=>s("/system"),"data-testid":"go-to-settings-btn",children:"System Settings"})]})]})});if(!p&&(T||L))return t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsxs(ct,{children:[t.jsx(z,{path:"create-app",element:t.jsx(At,{})}),t.jsx(z,{path:"system",element:t.jsx(Tt,{})}),t.jsx(z,{path:"system/apps",element:t.jsx(Vt,{})}),t.jsx(z,{path:"system/users",element:t.jsx(Rt,{})}),t.jsx(z,{path:"system/organizations",element:t.jsx(Mt,{})}),t.jsx(z,{path:"system/roles",element:t.jsx(Ot,{})}),t.jsx(z,{path:"system/permissions",element:t.jsx(Pt,{})}),t.jsx(z,{path:"system/audit-log",element:t.jsx(It,{})}),t.jsx(z,{path:"system/profile",element:t.jsx(Lt,{})})]})});const U=a?{name:a.name,email:a.email,role:a.role??"user"}:{name:"Anonymous",email:"",role:"guest"};return t.jsxs(Yr,{user:U,app:p,data:{},children:[t.jsx(Ai,{}),t.jsxs(So,{activeAppName:p.name,activeApp:p,onAppChange:v,objects:d,connectionState:e,children:[t.jsx(Do,{apps:c,activeApp:p,objects:d,onAppChange:v}),t.jsx(ki,{}),t.jsx(Fi,{}),t.jsxs(Ks,{dataSource:o||{},children:[t.jsx(Fo,{children:t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsxs(ct,{children:[t.jsx(z,{path:"/",element:t.jsx(He,{to:za(p.navigation||[]),replace:!0})}),t.jsx(z,{path:":objectName",element:t.jsx(Rn,{dataSource:o,objects:d,onEdit:M})}),t.jsx(z,{path:":objectName/view/:viewId",element:t.jsx(Rn,{dataSource:o,objects:d,onEdit:M})}),t.jsx(z,{path:":objectName/record/:recordId",element:t.jsx(Vi,{dataSource:o,objects:d,onEdit:M},y)}),t.jsx(z,{path:"dashboard/:dashboardName",element:t.jsx(Ri,{dataSource:o})}),t.jsx(z,{path:"report/:reportName",element:t.jsx(Oi,{dataSource:o})}),t.jsx(z,{path:"page/:pageName",element:t.jsx(Mi,{})}),t.jsx(z,{path:"design/page/:pageName",element:t.jsx(Li,{})}),t.jsx(z,{path:"design/dashboard/:dashboardName",element:t.jsx($i,{})}),t.jsx(z,{path:"search",element:t.jsx(Pi,{})}),t.jsx(z,{path:"create-app",element:t.jsx(At,{})}),t.jsx(z,{path:"edit-app/:editAppName",element:t.jsx(Ii,{})}),t.jsx(z,{path:"system",element:t.jsx(Tt,{})}),t.jsx(z,{path:"system/apps",element:t.jsx(Vt,{})}),t.jsx(z,{path:"system/users",element:t.jsx(Rt,{})}),t.jsx(z,{path:"system/organizations",element:t.jsx(Mt,{})}),t.jsx(z,{path:"system/roles",element:t.jsx(Ot,{})}),t.jsx(z,{path:"system/permissions",element:t.jsx(Pt,{})}),t.jsx(z,{path:"system/audit-log",element:t.jsx(It,{})}),t.jsx(z,{path:"system/profile",element:t.jsx(Lt,{})})]})})}),w&&t.jsx(Bs,{schema:{type:"object-form",formType:"modal",objectName:w.name,mode:h?"edit":"create",recordId:h?.id,title:`${h?"Edit":"Create"} ${w?.label}`,description:h?`Update details for ${w?.label}`:`Add a new ${w?.label} to your database.`,open:g,onOpenChange:x,modalSize:"lg",layout:"vertical",fields:w.fields?Array.isArray(w.fields)?w.fields.filter(P=>typeof P=="string"?!0:ut(P.visible,_)).map(P=>typeof P=="string"?P:P.name):Object.entries(w.fields).filter(([P,$])=>ut($.visible,_)).map(([P])=>P):[],onSuccess:R,onCancel:S,showSubmit:!0,showCancel:!0,submitText:"Save Record",cancelText:"Cancel"},dataSource:o},h?.id||"new")]})]})]})}function za(e){if(!e||e.length===0)return"";for(const n of e){if(n.type==="object")return n.viewName?`${n.objectName}/view/${n.viewName}`:`${n.objectName}`;if(n.type==="page")return n.pageName?`page/${n.pageName}`:"";if(n.type==="dashboard")return n.dashboardName?`dashboard/${n.dashboardName}`:"";if(n.type!=="url"&&n.type==="group"&&n.children){const a=za(n.children);if(a!=="")return a}}return""}function Wi(){const{apps:e,loading:n,error:a}=Ze(),o=Oe(),s=e.filter(l=>l.active!==!1),r=s.find(l=>l.isDefault===!0)||s[0];return n?t.jsx(de,{}):r?t.jsx(He,{to:`/apps/${r.name}`,replace:!0}):t.jsx("div",{className:"h-screen flex items-center justify-center",children:t.jsxs(mt,{children:[t.jsx(pt,{children:a?"Failed to Load Configuration":"No Apps Configured"}),t.jsx(ht,{children:a?"There was an error loading the configuration. You can still create an app or access System Settings.":"No applications have been registered. Create your first app or configure your system."}),t.jsxs("div",{className:"mt-4 flex flex-col sm:flex-row items-center gap-3",children:[t.jsx(Y,{onClick:()=>o("/create-app"),"data-testid":"create-first-app-btn",children:"Create Your First App"}),t.jsx(Y,{variant:"outline",onClick:()=>o("/system"),"data-testid":"go-to-settings-btn",children:"System Settings"})]})]})})}function Gi(){return t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsxs(ct,{children:[t.jsx(z,{path:"/",element:t.jsx(Tt,{})}),t.jsx(z,{path:"apps",element:t.jsx(Vt,{})}),t.jsx(z,{path:"users",element:t.jsx(Rt,{})}),t.jsx(z,{path:"organizations",element:t.jsx(Mt,{})}),t.jsx(z,{path:"roles",element:t.jsx(Ot,{})}),t.jsx(z,{path:"permissions",element:t.jsx(Pt,{})}),t.jsx(z,{path:"audit-log",element:t.jsx(It,{})}),t.jsx(z,{path:"profile",element:t.jsx(Lt,{})})]})})}function Ki(){return t.jsxs(uo,{defaultTheme:"system",storageKey:"object-ui-theme",children:[t.jsx(Ti,{position:"bottom-right"}),t.jsxs(Di,{authUrl:"/api/auth",children:[t.jsx(Js,{}),t.jsx(rs,{basename:"/console/".replace(/\/$/,"")||"/",children:t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsxs(ct,{children:[t.jsx(z,{path:"/login",element:t.jsx(zi,{})}),t.jsx(z,{path:"/register",element:t.jsx(Bi,{})}),t.jsx(z,{path:"/forgot-password",element:t.jsx(Ui,{})}),t.jsx(z,{path:"/system/*",element:t.jsx(yt,{fallback:t.jsx(He,{to:"/login"}),loadingFallback:t.jsx(de,{}),children:t.jsx(rt,{children:t.jsx(Gi,{})})})}),t.jsx(z,{path:"/create-app",element:t.jsx(yt,{fallback:t.jsx(He,{to:"/login"}),loadingFallback:t.jsx(de,{}),children:t.jsx(rt,{children:t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsx(At,{})})})})}),t.jsx(z,{path:"/apps/:appName/*",element:t.jsx(yt,{fallback:t.jsx(He,{to:"/login"}),loadingFallback:t.jsx(de,{}),children:t.jsx(rt,{children:t.jsx(qi,{})})})}),t.jsx(z,{path:"/",element:t.jsx(rt,{children:t.jsx(Wi,{})})})]})})})]})]})}function In(){const e=typeof window<"u"?window.innerWidth:1024;return e<640?35:e<1024?50:60}function Yi(){const e=typeof window<"u"?window.innerWidth:1024;return e<640?120:e<1024?200:300}function Ji({tasks:e,viewMode:n="month",startDate:a,endDate:o,onTaskClick:s,onTaskUpdate:r,onViewChange:l,onAddClick:c,className:d,inlineEdit:u=!1}){const[m,p]=i.useState(new Date),[g,x]=i.useState(typeof window<"u"&&window.innerWidth<640?32:40),[h,F]=i.useState(In()),[y,k]=i.useState(null),[E,A]=i.useState({});i.useEffect(()=>{const v=()=>{x(window.innerWidth<640?32:40),F(In())};return window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]);const f=i.useMemo(()=>{let v=a?new Date(a):new Date,_=o?new Date(o):new Date;return!a&&e.length>0&&(v=new Date(Math.min(...e.map(T=>T.start.getTime()))),v.setDate(v.getDate()-7)),!o&&e.length>0&&(_=new Date(Math.max(...e.map(T=>T.end.getTime()))),_.setDate(_.getDate()+14)),v.setHours(0,0,0,0),_.setHours(23,59,59,999),{start:v,end:_}},[a,o,e]),N=i.useMemo(()=>{const v=[],_=new Date(f.start);for(;_<=f.end;)v.push({date:new Date(_),label:_.getDate().toString(),isWeekend:_.getDay()===0||_.getDay()===6}),_.setDate(_.getDate()+1);return v},[f]),b=Yi(),j=i.useRef(null),w=i.useRef(null),R=i.useRef(null),S=v=>{j.current&&(j.current.scrollLeft=v.currentTarget.scrollLeft),w.current&&(w.current.scrollTop=v.currentTarget.scrollTop)},M=v=>{f.end.getTime()-f.start.getTime();const _=h,T=1e3*60*60*24,L=v.start.getTime()-f.start.getTime(),U=v.end.getTime()-v.start.getTime(),P=L/T*_,$=Math.max(U/T*_,_);return{left:P,width:$}};return t.jsxs("div",{className:q("flex flex-col h-full bg-background border rounded-lg overflow-hidden min-w-0",d),children:[t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>c?.(),"aria-label":"Create new task",children:[t.jsx(Fe,{className:"h-4 w-4 mr-1 sm:mr-2"}),t.jsx("span",{className:"hidden sm:inline",children:"New Task"}),t.jsx("span",{className:"sm:hidden",children:"New"})]}),t.jsx("div",{className:"h-4 w-px bg-border mx-1 sm:mx-2"}),t.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Previous period",children:t.jsx(xa,{className:"h-4 w-4"})}),t.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Next period",children:t.jsx(Je,{className:"h-4 w-4"})}),t.jsx("span",{className:"font-semibold text-xs sm:text-sm",children:f.start.toLocaleDateString(void 0,{month:"long",year:"numeric"})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Zn,{value:n,onValueChange:v=>l?.(v),children:[t.jsx(Qn,{className:"w-[100px] sm:w-[120px] h-8",children:t.jsx(Xn,{})}),t.jsxs(ea,{children:[t.jsx(Ne,{value:"day",children:"Day View"}),t.jsx(Ne,{value:"week",children:"Week View"}),t.jsx(Ne,{value:"month",children:"Month View"}),t.jsx(Ne,{value:"quarter",children:"Quarter View"})]})]}),t.jsxs("div",{className:"flex bg-muted rounded-md p-1",children:[t.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>F(v=>Math.max(15,v-10)),"aria-label":"Zoom out",children:t.jsx(Fr,{className:"h-3 w-3"})}),t.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>F(v=>Math.min(120,v+10)),"aria-label":"Zoom in",children:t.jsx(_r,{className:"h-3 w-3"})})]})]})]}),t.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden",children:[t.jsxs("div",{className:"flex border-b bg-muted/30 shrink-0 h-10 sm:h-[50px]",children:[t.jsxs("div",{className:"flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm",style:{width:b,minWidth:b},children:[t.jsx("div",{className:"flex-1",children:"Task Name"}),t.jsx("div",{className:"w-16 sm:w-20 text-right hidden sm:block",children:"Start"}),t.jsx("div",{className:"w-16 sm:w-20 text-right hidden sm:block",children:"End"})]}),t.jsx("div",{className:"flex-1 overflow-hidden",ref:j,children:t.jsx("div",{className:"flex h-full",style:{width:N.length*h},children:N.map((v,_)=>t.jsxs("div",{className:q("flex flex-col items-center justify-center border-r text-xs text-muted-foreground h-full",v.isWeekend&&"bg-muted/50"),style:{width:h,minWidth:h},children:[t.jsx("span",{className:"font-medium text-foreground",children:v.label}),t.jsx("span",{className:"text-[10px] opacity-70",children:v.date.toLocaleDateString(void 0,{weekday:"narrow"})})]},_))})})]}),t.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[t.jsx("div",{className:"overflow-hidden border-r bg-card z-10 shadow-sm",ref:w,style:{width:b,minWidth:b},children:e.map(v=>{const _=u&&y===v.id;return t.jsxs("div",{className:"flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",style:{height:g},onClick:()=>!_&&s?.(v),onDoubleClick:()=>{u&&r&&(k(v.id),A({title:v.title,start:v.start.toLocaleDateString("en-CA"),end:v.end.toLocaleDateString("en-CA"),progress:String(v.progress)}))},children:[t.jsxs("div",{className:"flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:v.color||"#3b82f6"}}),_?t.jsx("input",{className:"border rounded px-1 py-0.5 text-xs w-full bg-background",value:E.title||"",onChange:T=>A(L=>({...L,title:T.target.value})),onKeyDown:T=>{T.key==="Enter"?(r?.(v,{title:E.title,start:new Date(E.start),end:new Date(E.end),progress:Number(E.progress)||0}),k(null)):T.key==="Escape"&&k(null)},onClick:T=>T.stopPropagation(),autoFocus:!0}):t.jsxs("span",{className:"flex flex-col min-w-0",children:[t.jsx("span",{className:"truncate",children:v.title}),t.jsxs("span",{className:"text-[10px] text-muted-foreground sm:hidden",children:[v.start.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})," → ",v.end.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})]})]})]}),t.jsx("div",{className:"w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block",children:_?t.jsx("input",{type:"date",className:"border rounded px-1 py-0.5 text-xs w-full bg-background",value:E.start||"",onChange:T=>A(L=>({...L,start:T.target.value})),onClick:T=>T.stopPropagation()}):v.start.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})}),t.jsx("div",{className:"w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block",children:_?t.jsx("input",{type:"date",className:"border rounded px-1 py-0.5 text-xs w-full bg-background",value:E.end||"",onChange:T=>A(L=>({...L,end:T.target.value})),onClick:T=>T.stopPropagation()}):v.end.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})})]},v.id)})}),t.jsx("div",{className:"flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]",ref:R,onScroll:S,children:t.jsx("div",{style:{width:N.length*h},children:t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-0 flex pointer-events-none z-0",children:N.map((v,_)=>t.jsx("div",{className:q("border-r h-full",v.isWeekend&&"bg-muted/20"),style:{width:h,minWidth:h}},_))}),e.map(v=>{const _=M(v);return t.jsx("div",{className:"relative border-b hover:bg-black/5",style:{height:g},children:t.jsxs("div",{className:"absolute top-1 sm:top-2 h-[calc(100%-8px)] sm:h-[calc(100%-16px)] rounded-sm bg-primary border border-primary-foreground/20 shadow-sm cursor-pointer hover:brightness-110 flex items-center px-2 group",style:{left:_.left,width:_.width,backgroundColor:v.color||"#3b82f6"},onClick:()=>s?.(v),children:[v.progress>0&&t.jsx("div",{className:"absolute left-0 top-0 bottom-0 bg-black/20 rounded-l-sm",style:{width:`${v.progress}%`}}),t.jsxs("span",{className:"text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity",children:[Math.round(v.progress),"%"]})]})},v.id)}),t.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-red-500 z-20 pointer-events-none",style:{left:(new Date().getTime()-f.start.getTime())/(1e3*60*60*24)*h},children:t.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 -ml-[3px]"})})]})})})]})]})]})}function Zi(e){return e.data?e.data:e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function Qi(e){if(e){if(typeof e=="string"){const n=e.split(" "),a=n[0],o=n[1]?.toLowerCase()==="desc"?"desc":"asc";return{[a]:o}}if(Array.isArray(e))return e.reduce((n,a)=>(a.field&&a.order&&(n[a.field]=a.order),n),{})}}function Xi(e){let n=null;if(e.startDateField&&e.endDateField)return n={startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||"name",progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField},n;if(e.gantt&&(n=e.gantt),n){const a=Hr.safeParse(n);return a.success||console.warn("[ObjectGantt] Invalid gantt configuration:",a.error.format()),n}return null}const el=({schema:e,dataSource:n,className:a,onTaskClick:o,onRowClick:s,...r})=>{const[l,c]=i.useState([]),[d,u]=i.useState(!0),[m,p]=i.useState(null),[g,x]=i.useState(null),h=Zi(e),F=i.useMemo(()=>h,[JSON.stringify(h)]),y=Xi(e),k=F?.provider==="value";i.useEffect(()=>{(async()=>{try{if(u(!0),r.data&&Array.isArray(r.data)){c(r.data),u(!1);return}if(k&&F?.provider==="value"){c(F.items),u(!1);return}if(!n||typeof n.find!="function")throw new Error("DataSource required for object/api providers");if(F?.provider==="object"){const N=F.object,b=Ke(g?.fields),j=await n.find(N,{$filter:e.filter,$orderby:Qi(e.sort),...b.length>0?{$expand:b}:{}});let w=Pe(j);c(w)}else F?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectGantt"),c([]));u(!1)}catch(N){p(N),u(!1)}})()},[F,n,k,e.filter,e.sort,g]),i.useEffect(()=>{!k&&n&&(async()=>{try{if(!n)return;const N=F?.provider==="object"?F.object:e.objectName;if(!N)return;const b=await n.getObjectSchema(N);x(b)}catch(N){console.error("Failed to fetch object schema:",N)}})()},[e.objectName,n,k,F]);const E=i.useMemo(()=>{if(!y||!l.length)return[];const{startDateField:f,endDateField:N,titleField:b,progressField:j,dependenciesField:w,colorField:R}=y;return l.map((S,M)=>{const v=S[f],_=S[N],T=S[b]||"Untitled Task",L=j?S[j]:0,U=w?S[w]:[],P=R?S[R]:void 0;return{id:S.id||S._id||`task-${M}`,title:T,start:v?new Date(v):new Date,end:_?new Date(_):new Date,progress:Math.min(100,Math.max(0,L||0)),dependencies:Array.isArray(U)?U:[],color:P,data:S}}).filter(S=>!isNaN(S.start.getTime())&&!isNaN(S.end.getTime()))},[l,y]),A=Ie({navigation:e.navigation,objectName:e.objectName,onRowClick:s});return d?t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading Gantt chart..."})})}):m?t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsxs("div",{className:"text-destructive",children:["Error: ",m.message]})})}):y?t.jsxs("div",{className:a,children:[t.jsx("div",{className:"h-[calc(100vh-200px)] min-h-[600px]",children:t.jsx(Ji,{tasks:E,onTaskClick:f=>{A.handleClick(f.data),o?.(f.data)},onAddClick:()=>{}})}),A.isOverlay&&t.jsx(ke,{...A,title:"Task Details",children:f=>t.jsx("div",{className:"space-y-3",children:Object.entries(f).map(([N,b])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:N.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(b??"—")})]},N))})})]}):t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Gantt configuration required. Please specify startDateField, endDateField, and titleField."})})})},Ba=({schema:e})=>{const{dataSource:n}=Ye()||{};return t.jsx(el,{schema:e,dataSource:n})};Z.register("object-gantt",Ba,{namespace:"plugin-gantt",label:"Object Gantt",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"gantt",type:"object",label:"Gantt Config",description:"startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField"}]});Z.register("gantt",Ba,{namespace:"view",label:"Gantt View",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"gantt",type:"object",label:"Gantt Config",description:"startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField"}]});const tl=10080*60*1e3;function nl(e){const n=e.flatMap(s=>(s.items||[]).flatMap(r=>[r.startDate,r.endDate])),a=Math.min(...n.map(s=>new Date(s).getTime())),o=Math.max(...n.map(s=>new Date(s).getTime()));return{minDate:new Date(a).toISOString().split("T")[0],maxDate:new Date(o).toISOString().split("T")[0]}}function al(e,n,a,o){const s=new Date(e).getTime(),r=new Date(n).getTime(),l=new Date(a).getTime(),d=new Date(o).getTime()-l,u=s-l,m=r-s;return{start:u/d*100,width:m/d*100}}function ot(e,n){const a=new Date(e);return n==="short"?a.toLocaleDateString():n==="long"?a.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):a.toISOString().split("T")[0]}const Ua=({schema:e,className:n,...a})=>{const{variant:o="vertical",items:s=[],dateFormat:r="short",onItemClick:l}=e;if(o==="vertical")return t.jsx(Ha,{className:n,...a,children:s.map((c,d)=>t.jsxs(qa,{className:q(c.className,l&&"cursor-pointer"),onClick:()=>l?.(c),children:[t.jsx($t,{variant:c.variant||"default",children:c.icon&&t.jsx("span",{className:"text-xs",children:c.icon})}),t.jsxs(Wa,{children:[c.time&&t.jsx(Bt,{dateTime:c.time,children:ot(c.time,r)}),c.title&&t.jsx(zt,{children:c.title}),c.description&&t.jsx(Ut,{className:"line-clamp-2 sm:line-clamp-none",children:c.description}),c.content&&mn(c.content)]})]},d))});if(o==="horizontal")return t.jsx(Ga,{className:q("overflow-x-auto [-webkit-overflow-scrolling:touch]",n),...a,children:s.map((c,d)=>t.jsxs(Ka,{className:q(c.className,l&&"cursor-pointer"),onClick:()=>l?.(c),children:[t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx($t,{variant:c.variant||"default",children:c.icon&&t.jsx("span",{className:"text-xs",children:c.icon})}),t.jsxs("div",{className:"mt-4 text-center",children:[c.time&&t.jsx(Bt,{dateTime:c.time,children:ot(c.time,r)}),c.title&&t.jsx(zt,{children:c.title}),c.description&&t.jsx(Ut,{className:"text-center line-clamp-2 sm:line-clamp-none",children:c.description}),c.content&&mn(c.content)]})]}),d<s.length-1&&t.jsx("div",{className:"absolute left-full w-16 border-t-2 border-gray-200 top-3"})]},d))});if(o==="gantt"){const c=nl(s),d=e.minDate||c.minDate,u=e.maxDate||c.maxDate,m=e.timeScale||"month",g=(()=>{const x=[],h=new Date(d),F=new Date(u);if(m==="month"){const y=new Date(h);for(;y<=F;)x.push(y.toLocaleDateString("en-US",{month:"short",year:"numeric"})),y.setMonth(y.getMonth()+1)}else if(m==="week"){const y=new Date(h);for(;y<=F;)x.push(`Week ${Math.ceil((y.getTime()-h.getTime())/tl)+1}`),y.setDate(y.getDate()+7)}else if(m==="day"){const y=new Date(h);for(;y<=F;)x.push(y.toLocaleDateString("en-US",{month:"short",day:"numeric"})),y.setDate(y.getDate()+1)}return x})();return t.jsxs(Ya,{className:q("overflow-x-auto [-webkit-overflow-scrolling:touch]",n),...a,children:[t.jsxs(Ja,{children:[t.jsx(Ht,{className:"flex items-center px-2 sm:px-4 py-2 sm:py-3",children:t.jsx("span",{className:"font-semibold text-xs sm:text-sm",children:e.rowLabel||"Items"})}),t.jsx(qt,{children:t.jsx("div",{className:"flex h-full",children:g.map((x,h)=>t.jsx("div",{className:"flex-1 px-1 sm:px-2 py-2 sm:py-3 border-r text-xs font-medium text-center",children:x},h))})})]}),t.jsx("div",{children:t.jsxs("div",{className:"flex",children:[t.jsx(Ht,{children:s.map((x,h)=>t.jsx(Wt,{children:t.jsx(Za,{title:x.label,className:"truncate",children:x.label})},h))}),t.jsx(qt,{className:"relative",children:s.map((x,h)=>t.jsx(Wt,{className:"relative",children:(x.items||[]).map((F,y)=>{const k=al(F.startDate,F.endDate,d,u);return t.jsx(Qa,{start:k.start,width:k.width,variant:F.variant||"default",onClick:()=>l?.(F,x,h,y),title:`${F.title||""}
3
+ ${ot(F.startDate,r)} - ${ot(F.endDate,r)}`,children:t.jsx(Xa,{children:F.title})},y)})},h))})]})})]})}return null};Z.register("timeline",Ua,{namespace:"plugin-timeline",label:"Timeline",category:"data-display",inputs:[{name:"variant",type:"enum",enum:["vertical","horizontal","gantt"],label:"Timeline Variant",defaultValue:"vertical"},{name:"items",type:"array",label:"Timeline Items",description:"For vertical/horizontal: Array of { time, title, description, variant, icon, content }. For gantt: Array of { label, items: [{ title, startDate, endDate, variant }] }"},{name:"dateFormat",type:"enum",enum:["short","long","iso"],label:"Date Format",defaultValue:"short"},{name:"timeScale",type:"enum",enum:["day","week","month"],label:"Time Scale (Gantt only)",defaultValue:"month"},{name:"rowLabel",type:"string",label:"Row Label (Gantt only)",defaultValue:"Items"},{name:"minDate",type:"string",label:"Min Date (Gantt only)",description:"Override auto-calculated min date (YYYY-MM-DD)"},{name:"maxDate",type:"string",label:"Max Date (Gantt only)",description:"Override auto-calculated max date (YYYY-MM-DD)"},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{variant:"vertical",dateFormat:"short",items:[{time:"2024-01-15",title:"Project Started",description:"Kickoff meeting and initial planning",variant:"success",icon:"🚀"},{time:"2024-02-01",title:"First Milestone",description:"Completed initial design phase",variant:"info",icon:"🎨"},{time:"2024-03-15",title:"Beta Release",description:"Released beta version to testers",variant:"warning",icon:"⚡"},{time:"2024-04-01",title:"Launch",description:"Official product launch",variant:"success",icon:"🎉"}]},examples:{vertical:{variant:"vertical",dateFormat:"long",items:[{time:"2024-01-15",title:"Project Started",description:"Kickoff meeting and initial planning",variant:"success"},{time:"2024-02-01",title:"First Milestone",description:"Completed initial design phase",variant:"info"}]},horizontal:{variant:"horizontal",dateFormat:"short",items:[{time:"2024-01-01",title:"Q1",description:"First quarter",variant:"default"},{time:"2024-04-01",title:"Q2",description:"Second quarter",variant:"info"},{time:"2024-07-01",title:"Q3",description:"Third quarter",variant:"warning"},{time:"2024-10-01",title:"Q4",description:"Fourth quarter",variant:"success"}]},gantt:{variant:"gantt",dateFormat:"short",timeScale:"month",rowLabel:"Projects",items:[{label:"Backend Development",items:[{title:"API Design",startDate:"2024-01-01",endDate:"2024-01-31",variant:"success"},{title:"Implementation",startDate:"2024-02-01",endDate:"2024-03-31",variant:"info"}]},{label:"Frontend Development",items:[{title:"UI Design",startDate:"2024-01-15",endDate:"2024-02-15",variant:"warning"},{title:"Component Dev",startDate:"2024-02-15",endDate:"2024-04-15",variant:"default"}]},{label:"Testing",items:[{title:"QA Phase",startDate:"2024-03-01",endDate:"2024-04-30",variant:"danger"}]}]}}});const sl=Zt({title:te().optional(),date:te().optional(),description:te().optional(),variant:te().optional()}),rl=Zt({mapping:sl.optional(),objectName:te().optional(),titleField:te().optional(),dateField:te().optional(),startDateField:te().optional(),endDateField:te().optional(),descriptionField:te().optional(),groupByField:te().optional(),colorField:te().optional(),scale:qr(["hour","day","week","month","quarter","year"]).optional()}),ol=({schema:e,dataSource:n,className:a,onRowClick:o,onItemClick:s,...r})=>{const[l,c]=i.useState([]),[d,u]=i.useState(!1),[m,p]=i.useState(null),[g,x]=i.useState(0),[h,F]=i.useState(null),y=e.timeline;i.useEffect(()=>{const M=rl.safeParse(e);M.success||console.warn("[ObjectTimeline] Invalid timeline configuration:",M.error.format())},[e]);const k=Yt(e.bind);i.useEffect(()=>{let M=!0;return(async()=>{if(!(!n||typeof n.getObjectSchema!="function"||!e.objectName))try{const _=await n.getObjectSchema(e.objectName);M&&F(_)}catch(_){console.warn("Failed to fetch object def for ObjectTimeline",_)}})(),()=>{M=!1}},[e.objectName,n]),i.useEffect(()=>{const M=async()=>{if(!(!n||typeof n.find!="function"||!e.objectName)){u(!0);try{const v=Ke(h?.fields),_=await n.find(e.objectName,{options:{$top:100},...v.length>0?{$expand:v}:{}}),T=Pe(_);c(T)}catch(v){console.error(v),p(v)}finally{u(!1)}}};e.objectName&&!k&&!e.items&&!r.data&&M()},[e.objectName,n,k,e.items,r.data,g,h]);const E=r.data||k||l;let A=e.items;if(!A&&E&&Array.isArray(E)){const M=y?.titleField??e.mapping?.title??e.titleField??"name",v=y?.startDateField??e.mapping?.date??e.startDateField??e.dateField??"date",_=y?.endDateField??e.endDateField??v,T=e.mapping?.description??e.descriptionField??"description",L=e.mapping?.variant??"variant",U=y?.groupByField??e.groupByField,P=y?.colorField??e.colorField;A=E.map($=>({title:$[M],time:$[v],startDate:$[v],endDate:$[_],description:$[T],variant:$[L]||"default",...U?{group:$[U]}:{},...P?{color:$[P]}:{},_data:$}))}const f=i.useCallback(async()=>{x(M=>M+1)},[]),{ref:N,isRefreshing:b,pullDistance:j}=ya({onRefresh:f,enabled:!!e.objectName&&!!n}),w=Ie({navigation:e.navigation,objectName:e.objectName,onRowClick:o??s}),R=y?.scale??e.scale,S={...e,items:A||[],className:a||e.className,...R?{timeScale:R}:{},onItemClick:M=>{const v=M._data||M;w.handleClick(v),s?.(v)}};return m?t.jsxs("div",{className:"p-4 text-red-500",children:["Error loading timeline: ",m.message]}):t.jsxs("div",{ref:N,className:"relative overflow-auto h-full min-w-0",children:[j>0&&t.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:j},children:b?"Refreshing…":"Pull to refresh"}),t.jsx(Ua,{schema:S}),w.isOverlay&&t.jsx(ke,{...w,title:"Timeline Item",children:M=>t.jsx("div",{className:"space-y-3",children:Object.entries(M).map(([v,_])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:v.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(_??"—")})]},v))})})]})},Ha=i.forwardRef(({className:e,...n},a)=>t.jsx("ol",{ref:a,className:q("relative border-l border-gray-200",e),...n}));Ha.displayName="Timeline";const il=ia("ml-6",{variants:{density:{default:"mb-10",compact:"mb-3",comfortable:"mb-6"}},defaultVariants:{density:"default"}}),qa=i.forwardRef(({className:e,density:n,...a},o)=>t.jsx("li",{ref:o,className:q(il({density:n}),e),...a}));qa.displayName="TimelineItem";const ll=ia("absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center",{variants:{variant:{default:"bg-blue-200 border-blue-400",success:"bg-emerald-200 border-emerald-500",warning:"bg-amber-200 border-amber-500",danger:"bg-red-200 border-red-500",info:"bg-purple-200 border-purple-500",todo:"bg-slate-200 border-slate-400","in-progress":"bg-blue-200 border-blue-500",done:"bg-emerald-200 border-emerald-500"}},defaultVariants:{variant:"default"}}),$t=i.forwardRef(({className:e,variant:n="default",...a},o)=>t.jsx("div",{ref:o,className:q(ll({variant:n}),e),...a}));$t.displayName="TimelineMarker";const Wa=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:e,...n}));Wa.displayName="TimelineContent";const zt=i.forwardRef(({className:e,...n},a)=>t.jsx("h3",{ref:a,className:q("font-semibold text-lg mb-1",e),...n}));zt.displayName="TimelineTitle";const Bt=i.forwardRef(({className:e,...n},a)=>t.jsx("time",{ref:a,className:q("text-sm font-normal text-gray-500 mb-2 block",e),...n}));Bt.displayName="TimelineTime";const Ut=i.forwardRef(({className:e,...n},a)=>t.jsx("p",{ref:a,className:q("text-base text-gray-700",e),...n}));Ut.displayName="TimelineDescription";const Ga=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("relative flex overflow-x-auto py-8",e),...n}));Ga.displayName="TimelineHorizontal";const Ka=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("flex-shrink-0 w-64 relative",e),...n}));Ka.displayName="TimelineHorizontalItem";const Ya=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("relative w-full border rounded-lg overflow-hidden",e),...n}));Ya.displayName="TimelineGantt";const Ja=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("flex border-b bg-gray-50",e),...n}));Ja.displayName="TimelineGanttHeader";const Ht=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("w-48 border-r bg-white",e),...n}));Ht.displayName="TimelineGanttRowLabels";const qt=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("flex-1 overflow-x-auto",e),...n}));qt.displayName="TimelineGanttGrid";const Wt=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("flex items-center border-b min-h-12",e),...n}));Wt.displayName="TimelineGanttRow";const Za=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("px-4 py-2 font-medium text-sm truncate",e),...n}));Za.displayName="TimelineGanttLabel";const Qa=i.forwardRef(({className:e,start:n=0,width:a=100,variant:o="default",...s},r)=>{const l={default:"bg-blue-500 hover:bg-blue-600",success:"bg-green-500 hover:bg-green-600",warning:"bg-yellow-500 hover:bg-yellow-600",danger:"bg-red-500 hover:bg-red-600",info:"bg-purple-500 hover:bg-purple-600"};return t.jsx("div",{ref:r,className:q("absolute h-8 rounded-md transition-colors cursor-pointer",l[o],e),style:{left:`${n}%`,width:`${a}%`},...s})});Qa.displayName="TimelineGanttBar";const Xa=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("px-2 py-1 text-white text-xs font-medium truncate",e),...n}));Xa.displayName="TimelineGanttBarContent";const es=({schema:e,...n})=>{const{dataSource:a}=Ye()||{};return t.jsx(ol,{schema:e,dataSource:a,...n})};Z.register("object-timeline",es,{namespace:"plugin-timeline",label:"Object Timeline",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"variant",type:"enum",enum:["vertical","horizontal","gantt"],defaultValue:"vertical"}]});Z.register("timeline",es,{namespace:"view",label:"Timeline View",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"variant",type:"enum",enum:["vertical","horizontal","gantt"],defaultValue:"vertical"}]});const cl=i.createContext(null);function dl(e,n){const a=Array.isArray(e)?e[0]:e?e.x:0,o=Array.isArray(e)?e[1]:e?e.y:0,s=Array.isArray(n)?n[0]:n?n.x:0,r=Array.isArray(n)?n[1]:n?n.y:0;return a===s&&o===r}function he(e,n){if(e===n)return!0;if(!e||!n)return!1;if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let a=0;a<e.length;a++)if(!he(e[a],n[a]))return!1;return!0}else if(Array.isArray(n))return!1;if(typeof e=="object"&&typeof n=="object"){const a=Object.keys(e),o=Object.keys(n);if(a.length!==o.length)return!1;for(const s of a)if(!n.hasOwnProperty(s)||!he(e[s],n[s]))return!1;return!0}return!1}function Ln(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function $n(e,n){const a=n.viewState||n,o={};if("longitude"in a&&"latitude"in a&&(a.longitude!==e.center.lng||a.latitude!==e.center.lat)){const s=e.center.constructor;o.center=new s(a.longitude,a.latitude)}return"zoom"in a&&a.zoom!==e.zoom&&(o.zoom=a.zoom),"bearing"in a&&a.bearing!==e.bearing&&(o.bearing=a.bearing),"pitch"in a&&a.pitch!==e.pitch&&(o.pitch=a.pitch),a.padding&&e.padding&&!he(a.padding,e.padding)&&(o.padding=a.padding),o}const ul=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function zn(e){if(!e)return null;if(typeof e=="string"||("toJS"in e&&(e=e.toJS()),!e.layers))return e;const n={};for(const o of e.layers)n[o.id]=o;const a=e.layers.map(o=>{let s=null;"interactive"in o&&(s=Object.assign({},o),delete s.interactive);const r=n[o.ref];if(r){s=s||Object.assign({},o),delete s.ref;for(const l of ul)l in r&&(s[l]=r[l])}return s||o});return{...e,layers:a}}const Bn={version:8,sources:{},layers:[]},Un={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},Hn={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},qn={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},ml=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],pl=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class Me{constructor(n,a,o){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=s=>{const r=this.props[qn[s.type]];r?r(s):s.type==="error"&&console.error(s.error)},this._onCameraEvent=s=>{if(this._internalUpdate)return;s.viewState=this._propsedCameraUpdate||Ln(this._map.transform);const r=this.props[Hn[s.type]];r&&r(s)},this._onCameraUpdate=s=>this._internalUpdate?s:(this._propsedCameraUpdate=Ln(s),$n(s,this.props)),this._onPointerEvent=s=>{(s.type==="mousemove"||s.type==="mouseout")&&this._updateHover(s);const r=this.props[Un[s.type]];r&&(this.props.interactiveLayerIds&&s.type!=="mouseover"&&s.type!=="mouseout"&&(s.features=this._hoveredFeatures||this._queryRenderedFeatures(s.point)),r(s),delete s.features)},this._MapClass=n,this.props=a,this._initialize(o)}get map(){return this._map}setProps(n){const a=this.props;this.props=n;const o=this._updateSettings(n,a),s=this._updateSize(n),r=this._updateViewState(n);this._updateStyle(n,a),this._updateStyleComponents(n),this._updateHandlers(n,a),(o||s||r&&!this._map.isMoving())&&this.redraw()}static reuse(n,a){const o=Me.savedMaps.pop();if(!o)return null;const s=o.map,r=s.getContainer();for(a.className=r.className;r.childNodes.length>0;)a.appendChild(r.childNodes[0]);s._container=a;const l=s._resizeObserver;l&&(l.disconnect(),l.observe(a)),o.setProps({...n,styleDiffing:!1}),s.resize();const{initialViewState:c}=n;return c&&(c.bounds?s.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):o._updateViewState(c)),s.isStyleLoaded()?s.fire("load"):s.once("style.load",()=>s.fire("load")),s._update(),o}_initialize(n){const{props:a}=this,{mapStyle:o=Bn}=a,s={...a,...a.initialViewState,container:n,style:zn(o)},r=s.initialViewState||s.viewState||s;if(Object.assign(s,{center:[r.longitude||0,r.latitude||0],zoom:r.zoom||0,pitch:r.pitch||0,bearing:r.bearing||0}),a.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,a.gl)}const l=new this._MapClass(s);r.padding&&l.setPadding(r.padding),a.cursor&&(l.getCanvas().style.cursor=a.cursor),l.transformCameraUpdate=this._onCameraUpdate,l.on("style.load",()=>{this._styleComponents={light:l.getLight(),sky:l.getSky(),projection:l.getProjection?.(),terrain:l.getTerrain()},this._updateStyleComponents(this.props)}),l.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in Un)l.on(c,this._onPointerEvent);for(const c in Hn)l.on(c,this._onCameraEvent);for(const c in qn)l.on(c,this._onEvent);this._map=l}recycle(){this.map.getContainer().querySelector("[mapboxgl-children]")?.remove(),Me.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const n=this._map;n.style&&(n._frame&&(n._frame.cancel(),n._frame=null),n._render())}_updateSize(n){const{viewState:a}=n;if(a){const o=this._map;if(a.width!==o.transform.width||a.height!==o.transform.height)return o.resize(),!0}return!1}_updateViewState(n){const a=this._map,o=a.transform;if(!a.isMoving()){const r=$n(o,n);if(Object.keys(r).length>0)return this._internalUpdate=!0,a.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(n,a){const o=this._map;let s=!1;for(const r of ml)r in n&&!he(n[r],a[r])&&(s=!0,o[`set${r[0].toUpperCase()}${r.slice(1)}`]?.call(o,n[r]));return s}_updateStyle(n,a){if(n.cursor!==a.cursor&&(this._map.getCanvas().style.cursor=n.cursor||""),n.mapStyle!==a.mapStyle){const{mapStyle:o=Bn,styleDiffing:s=!0}=n,r={diff:s};"localIdeographFontFamily"in n&&(r.localIdeographFontFamily=n.localIdeographFontFamily),this._map.setStyle(zn(o),r)}}_updateStyleComponents({light:n,projection:a,sky:o,terrain:s}){const r=this._map,l=this._styleComponents;r.style._loaded&&(n&&!he(n,l.light)&&(l.light=n,r.setLight(n)),a&&!he(a,l.projection)&&a!==l.projection?.type&&(l.projection=typeof a=="string"?{type:a}:a,r.setProjection?.(l.projection)),o&&!he(o,l.sky)&&(l.sky=o,r.setSky(o)),s!==void 0&&!he(s,l.terrain)&&(!s||r.getSource(s.source))&&(l.terrain=s,r.setTerrain(s)))}_updateHandlers(n,a){const o=this._map;for(const s of pl){const r=n[s]??!0,l=a[s]??!0;he(r,l)||(r?o[s].enable(r):o[s].disable())}}_queryRenderedFeatures(n){const a=this._map,{interactiveLayerIds:o=[]}=this.props;try{return a.queryRenderedFeatures(n,{layers:o.filter(a.getLayer.bind(a))})}catch{return[]}}_updateHover(n){const{props:a}=this;if(a.interactiveLayerIds&&(a.onMouseMove||a.onMouseEnter||a.onMouseLeave)){const s=n.type,r=this._hoveredFeatures?.length>0,l=this._queryRenderedFeatures(n.point),c=l.length>0;!c&&r&&(n.type="mouseleave",this._onPointerEvent(n)),this._hoveredFeatures=l,c&&!r&&(n.type="mouseenter",this._onPointerEvent(n)),n.type=s}else this._hoveredFeatures=null}}Me.savedMaps=[];const hl=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function gl(e){if(!e)return null;const n=e.map,a={getMap:()=>n};for(const o of fl(n))!(o in a)&&!hl.includes(o)&&(a[o]=n[o].bind(n));return a}function fl(e){const n=new Set;let a=e;for(;a;){for(const o of Object.getOwnPropertyNames(a))o[0]!=="_"&&typeof e[o]=="function"&&o!=="fire"&&o!=="setEventedParent"&&n.add(o);a=Object.getPrototypeOf(a)}return Array.from(n)}const xl=typeof document<"u"?i.useLayoutEffect:i.useEffect;function bl(e,n){const{RTLTextPlugin:a,maxParallelImageRequests:o,workerCount:s,workerUrl:r}=n;if(a&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:l,lazy:c=!0}=typeof a=="string"?{pluginUrl:a}:a;e.setRTLTextPlugin(l,d=>{d&&console.error(d)},c)}o!==void 0&&e.setMaxParallelImageRequests(o),s!==void 0&&e.setWorkerCount(s),r!==void 0&&e.setWorkerUrl(r)}const ft=i.createContext(null);function jl(e,n){const a=i.useContext(cl),[o,s]=i.useState(null),r=i.useRef(),{current:l}=i.useRef({mapLib:null,map:null});i.useEffect(()=>{const u=e.mapLib;let m=!0,p;return Promise.resolve(u||J(()=>import("./maplibre-gl-Hx2FX3ON.js").then(g=>g.m),__vite__mapDeps([44,1]))).then(g=>{if(!m)return;if(!g)throw new Error("Invalid mapLib");const x="Map"in g?g:g.default;if(!x.Map)throw new Error("Invalid mapLib");bl(x,e),e.reuseMaps&&(p=Me.reuse(e,r.current)),p||(p=new Me(x.Map,e,r.current)),l.map=gl(p),l.mapLib=x,s(p),a?.onMapMount(l.map,e.id)}).catch(g=>{const{onError:x}=e;x?x({type:"error",target:null,originalEvent:null,error:g}):console.error(g)}),()=>{m=!1,p&&(a?.onMapUnmount(e.id),e.reuseMaps?p.recycle():p.destroy())}},[]),xl(()=>{o&&o.setProps(e)}),i.useImperativeHandle(n,()=>l.map,[o]);const c=i.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),d={height:"100%"};return i.createElement("div",{id:e.id,ref:r,style:c},o&&i.createElement(ft.Provider,{value:l},i.createElement("div",{"mapboxgl-children":"",style:d},e.children)))}const yl=i.forwardRef(jl),vl=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function fe(e,n){if(!e||!n)return;const a=e.style;for(const o in n){const s=n[o];Number.isFinite(s)&&!vl.test(o)?a[o]=`${s}px`:a[o]=s}}function ts(e,n){if(e===n)return null;const a=Wn(e),o=Wn(n),s=[];for(const r of o)a.has(r)||s.push(r);for(const r of a)o.has(r)||s.push(r);return s.length===0?null:s}function Wn(e){return new Set(e?e.trim().split(/\s+/):[])}const Gn=i.memo(i.forwardRef((e,n)=>{const{map:a,mapLib:o}=i.useContext(ft),s=i.useRef({props:e}),r=i.useMemo(()=>{let k=!1;i.Children.forEach(e.children,f=>{f&&(k=!0)});const E={...e,element:k?document.createElement("div"):void 0},A=new o.Marker(E);return A.setLngLat([e.longitude,e.latitude]),A.getElement().addEventListener("click",f=>{s.current.props.onClick?.({type:"click",target:A,originalEvent:f})}),A.on("dragstart",f=>{const N=f;N.lngLat=r.getLngLat(),s.current.props.onDragStart?.(N)}),A.on("drag",f=>{const N=f;N.lngLat=r.getLngLat(),s.current.props.onDrag?.(N)}),A.on("dragend",f=>{const N=f;N.lngLat=r.getLngLat(),s.current.props.onDragEnd?.(N)}),A},[]);i.useEffect(()=>(r.addTo(a.getMap()),()=>{r.remove()}),[]);const{longitude:l,latitude:c,offset:d,style:u,draggable:m=!1,popup:p=null,rotation:g=0,rotationAlignment:x="auto",pitchAlignment:h="auto"}=e;i.useEffect(()=>{fe(r.getElement(),u)},[u]),i.useImperativeHandle(n,()=>r,[]);const F=s.current.props;(r.getLngLat().lng!==l||r.getLngLat().lat!==c)&&r.setLngLat([l,c]),d&&!dl(r.getOffset(),d)&&r.setOffset(d),r.isDraggable()!==m&&r.setDraggable(m),r.getRotation()!==g&&r.setRotation(g),r.getRotationAlignment()!==x&&r.setRotationAlignment(x),r.getPitchAlignment()!==h&&r.setPitchAlignment(h),r.getPopup()!==p&&r.setPopup(p);const y=ts(F.className,e.className);if(y)for(const k of y)r.toggleClassName(k);return s.current.props=e,Yn.createPortal(e.children,r.getElement())})),wl=i.memo(i.forwardRef((e,n)=>{const{map:a,mapLib:o}=i.useContext(ft),s=i.useMemo(()=>document.createElement("div"),[]),r=i.useRef({props:e}),l=i.useMemo(()=>{const c={...e},d=new o.Popup(c);return d.setLngLat([e.longitude,e.latitude]),d.once("open",u=>{r.current.props.onOpen?.(u)}),d},[]);if(i.useEffect(()=>{const c=d=>{r.current.props.onClose?.(d)};return l.on("close",c),l.setDOMContent(s).addTo(a.getMap()),()=>{l.off("close",c),l.isOpen()&&l.remove()}},[]),i.useEffect(()=>{fe(l.getElement(),e.style)},[e.style]),i.useImperativeHandle(n,()=>l,[]),l.isOpen()){const c=r.current.props;(l.getLngLat().lng!==e.longitude||l.getLngLat().lat!==e.latitude)&&l.setLngLat([e.longitude,e.latitude]),e.offset&&!he(c.offset,e.offset)&&l.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(l.options.anchor=e.anchor,l.setMaxWidth(e.maxWidth));const d=ts(c.className,e.className);if(d)for(const u of d)l.toggleClassName(u);r.current.props=e}return Yn.createPortal(e.children,s)}));function Ee(e,n,a,o){const s=i.useContext(ft),r=i.useMemo(()=>e(s),[]);return i.useEffect(()=>{const l=n,c=null,d=typeof n=="function"?n:null,{map:u}=s;return u.hasControl(r)||(u.addControl(r,l?.position),c&&c(s)),()=>{d&&d(s),u.hasControl(r)&&u.removeControl(r)}},[]),r}function Nl(e){const n=Ee(({mapLib:a})=>new a.AttributionControl(e),{position:e.position});return i.useEffect(()=>{fe(n._container,e.style)},[e.style]),null}i.memo(Nl);function Cl(e){const n=Ee(({mapLib:a})=>new a.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return i.useEffect(()=>{fe(n._controlContainer,e.style)},[e.style]),null}i.memo(Cl);function Sl(e,n){const a=i.useRef({props:e}),o=Ee(({mapLib:s})=>{const r=new s.GeolocateControl(e),l=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||l()},r.on("geolocate",c=>{a.current.props.onGeolocate?.(c)}),r.on("error",c=>{a.current.props.onError?.(c)}),r.on("outofmaxbounds",c=>{a.current.props.onOutOfMaxBounds?.(c)}),r.on("trackuserlocationstart",c=>{a.current.props.onTrackUserLocationStart?.(c)}),r.on("trackuserlocationend",c=>{a.current.props.onTrackUserLocationEnd?.(c)}),r},{position:e.position});return a.current.props=e,i.useImperativeHandle(n,()=>o,[]),i.useEffect(()=>{fe(o._container,e.style)},[e.style]),null}i.memo(i.forwardRef(Sl));function Dl(e){const n=Ee(({mapLib:a})=>new a.NavigationControl(e),{position:e.position});return i.useEffect(()=>{fe(n._container,e.style)},[e.style]),null}const kl=i.memo(Dl);function Fl(e){const n=Ee(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),a=i.useRef(e),o=a.current;a.current=e;const{style:s}=e;return e.maxWidth!==void 0&&e.maxWidth!==o.maxWidth&&(n.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==o.unit&&n.setUnit(e.unit),i.useEffect(()=>{fe(n._container,s)},[s]),null}i.memo(Fl);function _l(e){const n=Ee(({mapLib:a})=>new a.TerrainControl(e),{position:e.position});return i.useEffect(()=>{fe(n._container,e.style)},[e.style]),null}i.memo(_l);function El(e){const n=Ee(({mapLib:a})=>new a.LogoControl(e),{position:e.position});return i.useEffect(()=>{fe(n._container,e.style)},[e.style]),null}i.memo(El);const Al=Zt({latitudeField:te().optional(),longitudeField:te().optional(),locationField:te().optional(),titleField:te().optional(),descriptionField:te().optional(),zoom:vt().optional(),center:Wr([vt(),vt()]).optional()});function Tl(e){return e.data?e.data:e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function Vl(e){if(e){if(typeof e=="string"){const n=e.split(" "),a=n[0],o=n[1]?.toLowerCase()==="desc"?"desc":"asc";return{[a]:o}}if(Array.isArray(e))return e.reduce((n,a)=>(a.field&&a.order&&(n[a.field]=a.order),n),{})}}function Rl(e){if(e.locationField||e.latitudeField)return{locationField:e.locationField,latitudeField:e.latitudeField,longitudeField:e.longitudeField,titleField:e.titleField||"name",descriptionField:e.descriptionField,zoom:e.zoom,center:e.center};let n=null;if(e.filter&&typeof e.filter=="object"&&"map"in e.filter?n=e.filter.map:e.map&&(n=e.map),n){const a=Al.safeParse(n);return a.success||console.warn("[ObjectMap] Invalid map configuration:",a.error.format()),n}return{latitudeField:"latitude",longitudeField:"longitude",locationField:"location",titleField:"name",descriptionField:"description",zoom:10,center:[0,0]}}function Ml(e,n){if(n.latitudeField&&n.longitudeField){const a=e[n.latitudeField],o=e[n.longitudeField];if(typeof a=="number"&&typeof o=="number")return[a,o]}if(n.locationField){const a=e[n.locationField];if(typeof a=="object"&&a!==null){const o=a.lat||a.latitude,s=a.lng||a.lon||a.longitude;if(typeof o=="number"&&typeof s=="number")return[o,s]}if(typeof a=="string"){const o=a.split(",").map(s=>parseFloat(s.trim()));if(o.length===2&&!isNaN(o[0])&&!isNaN(o[1]))return[o[0],o[1]]}if(Array.isArray(a)&&a.length===2){const o=parseFloat(a[0]),s=parseFloat(a[1]);if(!isNaN(o)&&!isNaN(s))return[o,s]}}return null}function Ol(e,n,a=50){if(e.length<=1||n>=15)return e.map(l=>({id:l.id,coordinates:l.coordinates,markers:[l],isCluster:!1}));const o=a/Math.pow(2,n),s=new Map;e.forEach(l=>{const c=Math.floor(l.coordinates[0]/o),d=Math.floor(l.coordinates[1]/o),u=`${c}:${d}`;s.has(u)||s.set(u,[]),s.get(u).push(l)});const r=[];return s.forEach((l,c)=>{if(l.length===1)r.push({id:l[0].id,coordinates:l[0].coordinates,markers:l,isCluster:!1});else{const d=l.reduce((m,p)=>m+p.coordinates[0],0)/l.length,u=l.reduce((m,p)=>m+p.coordinates[1],0)/l.length;r.push({id:`cluster-${c}`,coordinates:[d,u],markers:l,isCluster:!0})}}),r}const Pl=({schema:e,dataSource:n,className:a,onMarkerClick:o,onRowClick:s,onEdit:r,onDelete:l,enableClustering:c,clusterRadius:d=50,...u})=>{const[m,p]=i.useState([]),[g,x]=i.useState(!0),[h,F]=i.useState(null),[y,k]=i.useState(null),[E,A]=i.useState(null),[f,N]=i.useState(""),b=Tl(e),j=i.useMemo(()=>b,[JSON.stringify(b)]),w=Rl(e),R=j?.provider==="value";i.useEffect(()=>{(async()=>{try{if(x(!0),u.data){const I=u.data;if(Array.isArray(I)){p(I),x(!1);return}}if(e.data){const I=e.data;if(Array.isArray(I)){p(I),x(!1);return}}if(R&&j?.provider==="value"){p(j.items),x(!1);return}if(!n||typeof n.find!="function")throw new Error("DataSource required for object/api providers");if(j?.provider==="object"){const I=j.object,D=Ke(y?.fields),G=await n.find(I,{$filter:e.filter,$orderby:Vl(e.sort),...D.length>0?{$expand:D}:{}});let W=Pe(G);p(W)}else j?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectMap"),p([]));x(!1)}catch(I){F(I),x(!1)}})()},[j,n,R,e.filter,e.sort,y]),i.useEffect(()=>{!R&&n&&(async()=>{try{if(!n)return;const I=j?.provider==="object"?j.object:e.objectName;if(!I)return;const D=await n.getObjectSchema(I);k(D)}catch(I){console.error("Failed to fetch object schema:",I)}})()},[e.objectName,n,R,j]);const{markers:S,invalidCount:M}=i.useMemo(()=>{let O=0;return{markers:m.map((D,G)=>{const W=Ml(D,w);if(!W)return O++,null;const Q=w.titleField?D[w.titleField]:"Marker",se=w.descriptionField?D[w.descriptionField]:void 0,[le,ce]=W;return!isFinite(le)||!isFinite(ce)||le<-90||le>90||ce<-180||ce>180?(O++,null):{id:D.id||D._id||`marker-${G}`,title:Q,description:se,coordinates:[ce,le],data:D}}).filter(D=>D!==null),invalidCount:O}},[m,w]),v=i.useMemo(()=>S.find(O=>O.id===E),[S,E]),[_,T]=i.useState(w.zoom||3),L=Ie({navigation:e.navigation,objectName:e.objectName,onRowClick:s}),U=i.useMemo(()=>{if(!f.trim())return S;const O=f.toLowerCase();return S.filter(I=>I.title?.toLowerCase().includes(O)||I.description?.toLowerCase().includes(O))},[S,f]),P=i.useMemo(()=>c??(e.enableClustering||U.length>100)?Ol(U,_,d):U.map(I=>({id:I.id,coordinates:I.coordinates,markers:[I],isCluster:!1})),[U,_,c,d,e]),$=i.useMemo(()=>{if(!U.length)return{longitude:w.center?.[1]||0,latitude:w.center?.[0]||0,zoom:w.zoom||2};const O=U.map(se=>se.coordinates[0]),I=U.map(se=>se.coordinates[1]),D=Math.min(...O),G=Math.max(...O),W=Math.min(...I),Q=Math.max(...I);return{longitude:(D+G)/2,latitude:(W+Q)/2,zoom:w.zoom||3}},[U,w]);return g?t.jsx("div",{className:q("min-w-0 overflow-hidden",a),children:t.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg border",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading map..."})})}):h?t.jsx("div",{className:q("min-w-0 overflow-hidden",a),children:t.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg border",children:t.jsxs("div",{className:"text-destructive",children:["Error: ",h.message]})})}):t.jsxs("div",{className:q("min-w-0 overflow-hidden",a),children:[M>0&&t.jsx("div",{className:"mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded",children:`${M} record${M!==1?"s":""} with missing or invalid coordinates excluded from the map.`}),S.length>0&&t.jsx("div",{className:"mb-2",children:t.jsx("input",{type:"text",value:f,onChange:O=>N(O.target.value),placeholder:"Search locations…",className:"w-full px-3 py-2 text-sm border rounded-md bg-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})}),t.jsx("div",{className:"relative border rounded-lg overflow-hidden bg-muted h-[300px] sm:h-[400px] md:h-[500px] lg:h-[600px] w-full",children:t.jsxs(yl,{initialViewState:$,style:{width:"100%",height:"100%"},mapStyle:"https://demotiles.maplibre.org/style.json",touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,onZoom:O=>T(Math.round(O.viewState.zoom)),children:[t.jsx(kl,{position:"top-right",showCompass:!0,showZoom:!0}),P.map(O=>O.isCluster?t.jsx(Gn,{longitude:O.coordinates[0],latitude:O.coordinates[1],anchor:"center",children:t.jsx("div",{className:"flex items-center justify-center rounded-full bg-primary text-primary-foreground font-bold text-xs cursor-pointer hover:scale-110 transition-transform shadow-md",style:{width:Math.min(48,24+O.markers.length*2),height:Math.min(48,24+O.markers.length*2)},title:`${O.markers.length} markers`,children:O.markers.length})},O.id):t.jsx(Gn,{longitude:O.coordinates[0],latitude:O.coordinates[1],anchor:"bottom",onClick:I=>{I.originalEvent.stopPropagation();const D=O.markers[0];A(D.id),L.handleClick(D.data),o?.(D.data)},children:t.jsx("div",{className:"text-2xl cursor-pointer hover:scale-110 transition-transform",children:"📍"})},O.id)),v&&t.jsx(wl,{longitude:v.coordinates[0],latitude:v.coordinates[1],anchor:"top",onClose:()=>A(null),closeOnClick:!1,children:t.jsxs("div",{className:"p-2 min-w-[150px] sm:min-w-[200px]",children:[t.jsx("h3",{className:"font-bold text-sm mb-1",children:v.title}),v.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:v.description}),t.jsxs("div",{className:"mt-2 text-xs flex gap-2",children:[r&&t.jsx("button",{className:"text-blue-500 hover:underline",onClick:()=>r(v.data),children:"Edit"}),l&&t.jsx("button",{className:"text-red-500 hover:underline",onClick:()=>l(v.data),children:"Delete"})]})]})})]})}),L.isOverlay&&t.jsx(ke,{...L,title:"Location Details",children:O=>t.jsx("div",{className:"space-y-3",children:Object.entries(O).map(([I,D])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:I.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(D??"—")})]},I))})})]})},ns=({schema:e,...n})=>{const{dataSource:a}=Ye()||{};return t.jsx(Pl,{schema:e,dataSource:a,...n})};console.log("Registering object-map...");Z.register("object-map",ns,{namespace:"plugin-map",label:"Object Map",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"map",type:"object",label:"Map Config",description:"latitudeField, longitudeField, titleField"}]});Z.register("map",ns,{namespace:"view",label:"Map View",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"map",type:"object",label:"Map Config",description:"latitudeField, longitudeField, titleField"}]});const Il=ae.lazy(()=>J(()=>import("./MarkdownImpl-DQVBgcsA.js"),__vite__mapDeps([45,1]))),Ll=({schema:e})=>t.jsx(i.Suspense,{fallback:t.jsx(Ge,{className:"w-full h-[200px]"}),children:t.jsx(Il,{content:e.content||"",className:e.className})});Z.register("markdown",Ll,{namespace:"plugin-markdown",label:"Markdown",category:"plugin",inputs:[{name:"content",type:"string",label:"Markdown Content",required:!0,inputType:"textarea"},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{content:`# Hello World
4
+
5
+ This is a **markdown** component with *formatting* support.
6
+
7
+ - Item 1
8
+ - Item 2
9
+ - Item 3`}});async function $l(e){try{const n=await fetch(`/api/v1/i18n/${e}`);return n.ok?await n.json():(console.warn(`[i18n] Failed to load translations for '${e}': HTTP ${n.status}`),{})}catch(n){return console.warn(`[i18n] Failed to load translations for '${e}':`,n),{}}}async function zl(){os.createRoot(document.getElementById("root")).render(t.jsx(ae.StrictMode,{children:t.jsx(Vr,{pwa:{enabled:!0,name:"ObjectUI Console",shortName:"Console"},children:t.jsx(Zs,{loadLanguage:$l,children:t.jsx(Ki,{})})})}))}zl();export{Wo as M,lo as P,Qe as a,Ze as b,ee as r,Go as u};