@objectstack/console 17.6.0 → 17.7.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 (277) hide show
  1. package/CHANGELOG.md +428 -0
  2. package/dist/.objectstack-injection.json +2 -2
  3. package/dist/.objectui-sha +1 -1
  4. package/dist/assets/{ActionResultDialog-4kHDGnT3.js → ActionResultDialog-ChYnuROr.js} +3 -3
  5. package/dist/assets/{AiPendingActionsPage-JjOddm0h.js → AiPendingActionsPage-Dh3-i4BB.js} +1 -1
  6. package/dist/assets/{ApiConsolePage-BgS26lbp.js → ApiConsolePage-CKYEqlMs.js} +1 -1
  7. package/dist/assets/{AppDocsIndex-BDoH5ECM.js → AppDocsIndex-B5Tky2xg.js} +1 -1
  8. package/dist/assets/{AppManagementPage-CCgKmNTj.js → AppManagementPage-ZwyvnHpM.js} +1 -1
  9. package/dist/assets/ApprovalsInboxPage-DD4fe0Em.js +1 -0
  10. package/dist/assets/AuditLogPage-Sed6iMqP.js +1 -0
  11. package/dist/assets/BookPage-DYjUsQIc.js +1 -0
  12. package/dist/assets/{ComponentNavView-B5g9c6fx.js → ComponentNavView-DrlxM4SY.js} +1 -1
  13. package/dist/assets/CreateViewDialog-Cp72x_O7.js +1 -0
  14. package/dist/assets/{DashboardView-BOcovpPd.js → DashboardView-juicRxcP.js} +1 -1
  15. package/dist/assets/DocPage-CxJaQ-pC.js +1 -0
  16. package/dist/assets/{DocsIndex-DwW2QsYY.js → DocsIndex-LALVtIVR.js} +1 -1
  17. package/dist/assets/{DocsLayout-D63StSgd.js → DocsLayout-BAwlJQQf.js} +1 -1
  18. package/dist/assets/{DocsSlug-CP9fcabi.js → DocsSlug-CkF1E-Zs.js} +1 -1
  19. package/dist/assets/ExpressionProvider-Dr0e99r1.js +1 -0
  20. package/dist/assets/FlowRunsPage-R3W3t2s4.js +1 -0
  21. package/dist/assets/{IntegrationsPage-DvG0x0Nb.js → IntegrationsPage-DIuFLEbF.js} +2 -2
  22. package/dist/assets/InterfaceListPage-BfoCldGu.js +1 -0
  23. package/dist/assets/{MarketplaceInstalledPage-B7KETQG2.js → MarketplaceInstalledPage-DyjhcUNB.js} +1 -1
  24. package/dist/assets/MarketplacePackagePage-BbO27Pgs.js +4 -0
  25. package/dist/assets/MarketplacePage-DO2_b64U.js +1 -0
  26. package/dist/assets/{MetadataInspector-EP0I3-Kq.js → MetadataInspector-BQyu9pOE.js} +1 -1
  27. package/dist/assets/ObjectDataPage-DIY-yefK.js +1 -0
  28. package/dist/assets/PageView-C-qWu3Jw.js +1 -0
  29. package/dist/assets/ProfilePage-Qp8DL8CF.js +1 -0
  30. package/dist/assets/{PublicFormsPage-D3uCTR-8.js → PublicFormsPage-D3AT2EH9.js} +1 -1
  31. package/dist/assets/RecordDetailView-B3XBEgk2.js +3 -0
  32. package/dist/assets/{RecordFormPage-kiJI-ieF.js → RecordFormPage-CcoZfUJ3.js} +1 -1
  33. package/dist/assets/ReportDefaultInspector-DVcWM6sh.js +1 -0
  34. package/dist/assets/ReportView-pJCFptzp.js +2 -0
  35. package/dist/assets/RuntimeDraftBar-DObTyFu2.js +1 -0
  36. package/dist/assets/SchemaForm-BWSWYMLE.js +3 -0
  37. package/dist/assets/SearchResultsPage-ChVIzFob.js +1 -0
  38. package/dist/assets/{SettingsHub-DP1mrzEN.js → SettingsHub-CPP9FDe8.js} +1 -1
  39. package/dist/assets/{SettingsView-u7mc6pcc.js → SettingsView-CrHAROu9.js} +1 -1
  40. package/dist/assets/{SkeletonDetail-DIwlbHTr.js → SkeletonDetail-CP-35B8x.js} +1 -1
  41. package/dist/assets/{af-DPUgkQl0.js → af-Bhbso4Pg.js} +1 -1
  42. package/dist/assets/ai-BAPiCsNk.js +3 -0
  43. package/dist/assets/app-shell-eager-leaves-D9tgfJOe.js +1 -0
  44. package/dist/assets/{ar-B-6GTIRU.js → ar-DG8TAFtm.js} +1 -1
  45. package/dist/assets/{ar-DZ-wEl298ti.js → ar-DZ-BtSien-d.js} +1 -1
  46. package/dist/assets/{ar-EG-YBT90_S0.js → ar-EG-DpXC0zoY.js} +1 -1
  47. package/dist/assets/{ar-MA-3uT-EYh6.js → ar-MA-D1qVJLyE.js} +1 -1
  48. package/dist/assets/{ar-SA-SiQsjhhc.js → ar-SA-BIYKNgv8.js} +1 -1
  49. package/dist/assets/{ar-TN-CfzXjKzS.js → ar-TN-mUR5Mq3s.js} +1 -1
  50. package/dist/assets/{az-BqAfcNza.js → az-B7IqwHGK.js} +1 -1
  51. package/dist/assets/{be-CQgWXa9_.js → be-CnZyPaSX.js} +1 -1
  52. package/dist/assets/{be-tarask-BmNg0Sir.js → be-tarask--uMMCC7l.js} +1 -1
  53. package/dist/assets/{bg-D3evgRuS.js → bg-CZwuirtY.js} +1 -1
  54. package/dist/assets/{bn-uItkARwm.js → bn-BbOX0r-z.js} +1 -1
  55. package/dist/assets/{bs-DueReOpO.js → bs-B5W75cYR.js} +1 -1
  56. package/dist/assets/{ca-Cr3AHktR.js → ca-Be69LdIM.js} +1 -1
  57. package/dist/assets/{ckb-CTi5BET7.js → ckb-B-nKM1Vn.js} +1 -1
  58. package/dist/assets/{createDerive-CjN1i5vn.js → createDerive-CynsXU-B.js} +1 -1
  59. package/dist/assets/{cs-43mFX9jr.js → cs-qHngxH7l.js} +1 -1
  60. package/dist/assets/{cy-BBSkg3F8.js → cy-DscO2Pgf.js} +1 -1
  61. package/dist/assets/{da-C5oA5qcs.js → da-vibkaLMF.js} +1 -1
  62. package/dist/assets/data-adapter-BDsrq0TX.js +2 -0
  63. package/dist/assets/{de-AT-CApxwJzu.js → de-AT--JneEuBw.js} +1 -1
  64. package/dist/assets/{de-CPtbLlAf.js → de-BCT78XYW.js} +1 -1
  65. package/dist/assets/default-inspector-registry-Dktr6x_q.js +1 -0
  66. package/dist/assets/dist-yh3dYtHt.js +14 -0
  67. package/dist/assets/drillUrlFilters-N0RngQg6.js +1 -0
  68. package/dist/assets/{el-Dto2xBQU.js → el-Cl0y9T2b.js} +1 -1
  69. package/dist/assets/en-AU-By42tTB7.js +1 -0
  70. package/dist/assets/{en-CA-DKuJPN1U.js → en-CA-BqEEoj-Y.js} +1 -1
  71. package/dist/assets/en-GB-Cx8B9nkB.js +1 -0
  72. package/dist/assets/en-IE-CX9nv6uO.js +1 -0
  73. package/dist/assets/en-IN-ByGSBHa4.js +1 -0
  74. package/dist/assets/en-NZ-BPMwa2ZN.js +1 -0
  75. package/dist/assets/en-ZA-lj_N4R6c.js +1 -0
  76. package/dist/assets/{eo-BL8JXIWd.js → eo-oOXROuhF.js} +1 -1
  77. package/dist/assets/{es-BnoaNxsu.js → es-EudscwjH.js} +1 -1
  78. package/dist/assets/{et-tPYLNenO.js → et-CB-5LLh6.js} +1 -1
  79. package/dist/assets/{eu-CUBG6bT0.js → eu-B4-hcseX.js} +1 -1
  80. package/dist/assets/{fa-IR-Rr2d9xSs.js → fa-IR-CogavcMJ.js} +1 -1
  81. package/dist/assets/{fi-B0NVIZsV.js → fi-CIBE0mYa.js} +1 -1
  82. package/dist/assets/{formatLong-1-gt9bpo.js → formatLong-qqgm7lV1.js} +1 -1
  83. package/dist/assets/{fr-CA-CBDvLXFg.js → fr-CA-BugXMutW.js} +1 -1
  84. package/dist/assets/{fr-BbhHek8e.js → fr-CDReXYWW.js} +1 -1
  85. package/dist/assets/{fr-CH-WPNmwPn7.js → fr-CH-fiTiB6X1.js} +1 -1
  86. package/dist/assets/framework-CAuH4h0L.js +35 -0
  87. package/dist/assets/{fy-DvOBbvEF.js → fy-t_GzIAg_.js} +1 -1
  88. package/dist/assets/{gd-BQPiTPX5.js → gd-CSncIxtN.js} +1 -1
  89. package/dist/assets/getIcon-BDkBRQFw.js +1 -0
  90. package/dist/assets/{gl-BJCXK8uO.js → gl-_138Mj2S.js} +1 -1
  91. package/dist/assets/{gu-CctPRz3V.js → gu-COfH-YUT.js} +1 -1
  92. package/dist/assets/{he-CVFMk6p2.js → he-BXL4lOKY.js} +1 -1
  93. package/dist/assets/{hi-Ba30-RwS.js → hi-kXuYI0TJ.js} +1 -1
  94. package/dist/assets/{highlighted-body-OFNGDK62-BQ57IrBV.js → highlighted-body-OFNGDK62-CK7x7Gzm.js} +1 -1
  95. package/dist/assets/{hr-BZUqTbZs.js → hr-DAOsQWzI.js} +1 -1
  96. package/dist/assets/{ht-BLe05tPx.js → ht-Ch8SKz8p.js} +1 -1
  97. package/dist/assets/{hu-2CQ_Mkww.js → hu-q6W_rWPT.js} +1 -1
  98. package/dist/assets/{hy-CclcPG4H.js → hy-0M8OmwnM.js} +1 -1
  99. package/dist/assets/{i18n-BnUsCaSC.js → i18n-DTfZonAM.js} +3 -3
  100. package/dist/assets/i18n-locale-ar-O6rs-Cir.js +4 -0
  101. package/dist/assets/i18n-locale-de-CMc1jk4a.js +4 -0
  102. package/dist/assets/i18n-locale-en-CbRQO81h.js +4 -0
  103. package/dist/assets/i18n-locale-es-t47nyoCX.js +4 -0
  104. package/dist/assets/i18n-locale-fr-E425EqJM.js +4 -0
  105. package/dist/assets/i18n-locale-ja-y_fk77fz.js +4 -0
  106. package/dist/assets/i18n-locale-ko-CdnY2uCg.js +4 -0
  107. package/dist/assets/i18n-locale-pt-BaUOXS6y.js +4 -0
  108. package/dist/assets/i18n-locale-ru-pFlhX9wg.js +4 -0
  109. package/dist/assets/i18n-locale-zh-Dkj4ROTN.js +4 -0
  110. package/dist/assets/i18n-runtime-CdWyaiOD.js +1 -0
  111. package/dist/assets/{id-6JLB8s-f.js → id-BM_H1_jv.js} +1 -1
  112. package/dist/assets/index-ocmkyCt6.js +19 -0
  113. package/dist/assets/index-v2Ijn9Gr.css +2 -0
  114. package/dist/assets/{infrastructure-Cc34lEqb.js → infrastructure-CSnL6ntj.js} +2 -2
  115. package/dist/assets/integration-7NqwVHuJ.js +1 -0
  116. package/dist/assets/{is-to0CWzm1.js → is-B_7jXZfS.js} +1 -1
  117. package/dist/assets/isSameWeek-D90tBsli.js +1 -0
  118. package/dist/assets/{it-ea0B8Ujp.js → it-CBM0J9cD.js} +1 -1
  119. package/dist/assets/{it-CH-DhdfjP5Z.js → it-CH-BQltCNsR.js} +1 -1
  120. package/dist/assets/{ja-B1bzkgDW.js → ja-DBjnsx21.js} +1 -1
  121. package/dist/assets/{ja-Hira-CMrY5hXO.js → ja-Hira-BZfSmj1i.js} +1 -1
  122. package/dist/assets/{ka-DKSXLnXP.js → ka-HwpuKgUY.js} +1 -1
  123. package/dist/assets/{kk-DHwMv8Dn.js → kk-DLKA9paj.js} +1 -1
  124. package/dist/assets/{km-tpLG1xNr.js → km-BU5kermq.js} +1 -1
  125. package/dist/assets/{kn-MLreVnHA.js → kn-BNFqbCoi.js} +1 -1
  126. package/dist/assets/{ko-CI0DBazn.js → ko-D8n4uMqQ.js} +1 -1
  127. package/dist/assets/{lb-CmL572Xe.js → lb-B1empQ7m.js} +1 -1
  128. package/dist/assets/{lt-DRtUOLdw.js → lt-gMukpK3G.js} +1 -1
  129. package/dist/assets/{lv-COSHgkOP.js → lv-D2O5AnsZ.js} +1 -1
  130. package/dist/assets/{match-BQoOW8Cj.js → match-BTF6WqJh.js} +1 -1
  131. package/dist/assets/{match-B-ergJQb.js → match-Cyum2eeW.js} +1 -1
  132. package/dist/assets/{match-dfBS0YSQ.js → match-ScHH8kYk.js} +1 -1
  133. package/dist/assets/mermaid-GHXKKRXX-D4H6EVJQ.js +1 -0
  134. package/dist/assets/metadata-admin-CEhVmXFv.js +9 -0
  135. package/dist/assets/{mk-B0IH_YL_.js → mk-D-Zl0xVN.js} +1 -1
  136. package/dist/assets/{mn-P-QdQ2n3.js → mn-jJbTslgD.js} +1 -1
  137. package/dist/assets/{ms-CtyEOINy.js → ms-CUuJHLA4.js} +1 -1
  138. package/dist/assets/{mt-DfuZ2HRm.js → mt-yIcbfxKY.js} +1 -1
  139. package/dist/assets/{nb-2Hp-5Tnt.js → nb-D9WNypoj.js} +1 -1
  140. package/dist/assets/{nl-BE-mmxbfNoR.js → nl-BE-B1vKiw2h.js} +1 -1
  141. package/dist/assets/{nl-CZ_nLREz.js → nl-DC7b5e90.js} +1 -1
  142. package/dist/assets/{nn-ccWhYsNa.js → nn-uP4yJ9s0.js} +1 -1
  143. package/dist/assets/{oc-z504BFRV.js → oc-DHTqadJI.js} +1 -1
  144. package/dist/assets/{pl-DeQ7ASt-.js → pl-Bxnnizf5.js} +1 -1
  145. package/dist/assets/plugin-calendar-b7C35ANT.js +1 -0
  146. package/dist/assets/plugin-charts-b-yVtmdI.js +7 -0
  147. package/dist/assets/{plugin-chatbot-Ck47EhDX.js → plugin-chatbot-D1KW_oIO.js} +8 -8
  148. package/dist/assets/plugin-dashboard-DTkPoPEb.js +6 -0
  149. package/dist/assets/plugin-form-UIRm-FpQ.js +1 -0
  150. package/dist/assets/plugin-gantt-9dtc8zzX.js +63 -0
  151. package/dist/assets/plugin-grid-Cp4RKtMJ.js +10 -0
  152. package/dist/assets/plugin-kanban-B2JOPZIJ.js +1 -0
  153. package/dist/assets/plugin-map-CBJcVJYk.js +1 -0
  154. package/dist/assets/{plugin-markdown-BOkHcir_.js → plugin-markdown-CNlDzqP-.js} +1 -1
  155. package/dist/assets/plugin-report-IZzgQb-Q.js +59 -0
  156. package/dist/assets/plugin-timeline-DsmtjcJ3.js +1 -0
  157. package/dist/assets/plugin-tree-DTRPBdhe.js +1 -0
  158. package/dist/assets/plugin-view-D9ixsNDG.js +1 -0
  159. package/dist/assets/plugins-views-CnvkdSJK.js +3 -0
  160. package/dist/assets/{pt-BR-D80_lPYF.js → pt-BR-D416seHT.js} +1 -1
  161. package/dist/assets/{pt-CJJ1RmXd.js → pt-DwHBy9_c.js} +1 -1
  162. package/dist/assets/{ro-EuFb2TCj.js → ro-DDf1X3Np.js} +1 -1
  163. package/dist/assets/{ru-CMaVQScp.js → ru-8eM3mcgK.js} +1 -1
  164. package/dist/assets/{runtime-metadata-persistence-ClOTznqa.js → runtime-metadata-persistence-DX29lQ62.js} +1 -1
  165. package/dist/assets/{se-DsfdKLdF.js → se-D4JvQeRX.js} +1 -1
  166. package/dist/assets/{sk-BNV9omI8.js → sk-DvpgttGI.js} +1 -1
  167. package/dist/assets/{sl-DJS_nINU.js → sl-B3gCZ-_a.js} +1 -1
  168. package/dist/assets/{sq-HEgjcbHe.js → sq-CVaTmL0V.js} +1 -1
  169. package/dist/assets/{sr-CO0CFu4X.js → sr-CnH5Ffyz.js} +1 -1
  170. package/dist/assets/{sr-Latn-eE1Idzey.js → sr-Latn-Dw9w61q6.js} +1 -1
  171. package/dist/assets/src-BUry7633.js +2 -0
  172. package/dist/assets/{src-BU7L2v4J.js → src-DMDT5a27.js} +1 -1
  173. package/dist/assets/src-ZxH3AOCu.js +16 -0
  174. package/dist/assets/{studioEntry-WeMfaSGn.js → studioEntry-DAqcBFtr.js} +1 -1
  175. package/dist/assets/{submitRedirect-C2lfZSHt.js → submitRedirect-iy0oOi7I.js} +1 -1
  176. package/dist/assets/{sv-5uTzgQT3.js → sv-CU7wdxyK.js} +1 -1
  177. package/dist/assets/{ta-BzgdkBZG.js → ta-DPH6q0HR.js} +1 -1
  178. package/dist/assets/{te-Ct_pl7ZJ.js → te-BSaThkGV.js} +1 -1
  179. package/dist/assets/{th-DouAlk0-.js → th-NXP8_Qb8.js} +1 -1
  180. package/dist/assets/{tr-3XNBsI40.js → tr-DDXoH663.js} +1 -1
  181. package/dist/assets/types-zod-ChJ30y25.js +1 -0
  182. package/dist/assets/{ug-B9n24h9G.js → ug-Guus6pPe.js} +1 -1
  183. package/dist/assets/ui-components-D8wcRNrt.js +37 -0
  184. package/dist/assets/ui-layout-BYO3rRIl.js +1 -0
  185. package/dist/assets/{uk-DCAenByf.js → uk-uiy4vsp8.js} +1 -1
  186. package/dist/assets/use-book-data-DFTswcKm.js +1 -0
  187. package/dist/assets/{useActionModal-Blp4rhOk.js → useActionModal-h52Z5Pkl.js} +1 -1
  188. package/dist/assets/useCanAuthorMetadata-TDrVrYGB.js +1 -0
  189. package/dist/assets/useDatasetCatalog-BOd0Ybr1.js +1 -0
  190. package/dist/assets/{useNavTargetLabel-BOJncjIb.js → useNavTargetLabel-D8lRdb6O.js} +1 -1
  191. package/dist/assets/useOpenRecordList-C7oqUD3F.js +1 -0
  192. package/dist/assets/{usePackageL10n-Ci9uVkRZ.js → usePackageL10n-Jl2XiF2F.js} +1 -1
  193. package/dist/assets/{useSettingsLabel-CeMnMWsh.js → useSettingsLabel-CSpBDTdy.js} +1 -1
  194. package/dist/assets/{uz-Cyrl-JSeHEqu-.js → uz-Cyrl-Cmb5bvbf.js} +1 -1
  195. package/dist/assets/{uz-DT3s9bZS.js → uz-DJWxoTz4.js} +1 -1
  196. package/dist/assets/vendor-objectstack-C4eD5dbT.js +139 -0
  197. package/dist/assets/{vi-D2p-h6bY.js → vi-Bb3QoIJC.js} +1 -1
  198. package/dist/assets/{zh-CN-DHOKqAit.js → zh-CN-C-Hts1ZR.js} +1 -1
  199. package/dist/assets/{zh-HK-D4iIPY7I.js → zh-HK-CtBAZ_ZS.js} +1 -1
  200. package/dist/assets/{zh-TW-gORQ_tZh.js → zh-TW-B7DDahD-.js} +1 -1
  201. package/dist/chunk-membership.json +28 -26
  202. package/dist/eager-closure.json +107 -101
  203. package/dist/index.html +4 -4
  204. package/dist/sdui.manifest.json +486 -63
  205. package/package.json +1 -1
  206. package/dist/assets/ApprovalsInboxPage-C6S1vk0X.js +0 -1
  207. package/dist/assets/AuditLogPage-v2dKXMuk.js +0 -1
  208. package/dist/assets/BookPage-DwFMcTSN.js +0 -1
  209. package/dist/assets/CreateViewDialog-D3l-tYHM.js +0 -1
  210. package/dist/assets/DocPage-B6AkH5WI.js +0 -1
  211. package/dist/assets/ExpressionProvider-CrL6jhVq.js +0 -1
  212. package/dist/assets/FlowRunsPage-CxdaiUyk.js +0 -1
  213. package/dist/assets/InterfaceListPage-C4wPYohR.js +0 -1
  214. package/dist/assets/MarketplacePackagePage-CfgKDpNH.js +0 -4
  215. package/dist/assets/MarketplacePage-DNEyU5AE.js +0 -1
  216. package/dist/assets/ObjectDataPage-CykEm9MD.js +0 -1
  217. package/dist/assets/PageView-C6u86tni.js +0 -1
  218. package/dist/assets/ProfilePage-C3SjXMzi.js +0 -1
  219. package/dist/assets/RecordDetailView-DgR_zhP4.js +0 -3
  220. package/dist/assets/ReportDefaultInspector-BIinF0EQ.js +0 -1
  221. package/dist/assets/ReportView-BREO-ADE.js +0 -2
  222. package/dist/assets/RuntimeDraftBar-BCWfd2yS.js +0 -1
  223. package/dist/assets/SchemaForm-C4uMMZ13.js +0 -3
  224. package/dist/assets/SearchResultsPage-C6Hw_Lpn.js +0 -1
  225. package/dist/assets/ai-DPBykF2N.js +0 -3
  226. package/dist/assets/app-shell-eager-leaves-Cf2bM6uT.js +0 -1
  227. package/dist/assets/data-adapter-Cymvlczj.js +0 -1
  228. package/dist/assets/default-inspector-registry-Bs6GBn00.js +0 -1
  229. package/dist/assets/dist-BF-ssUpn.js +0 -14
  230. package/dist/assets/drillUrlFilters-hi-2d3DW.js +0 -1
  231. package/dist/assets/en-AU-FVwCiDJO.js +0 -1
  232. package/dist/assets/en-GB-DQ_y5VbJ.js +0 -1
  233. package/dist/assets/en-IE-DaXOhsZW.js +0 -1
  234. package/dist/assets/en-IN-CnRZnAom.js +0 -1
  235. package/dist/assets/en-NZ-CBZLEToK.js +0 -1
  236. package/dist/assets/en-ZA-BE59v0wZ.js +0 -1
  237. package/dist/assets/framework-DFR4HNtj.js +0 -35
  238. package/dist/assets/getIcon-Cfwf-Egt.js +0 -1
  239. package/dist/assets/i18n-locale-ar-92O_xtDZ.js +0 -4
  240. package/dist/assets/i18n-locale-de-T5ic3yH9.js +0 -4
  241. package/dist/assets/i18n-locale-en-rxr7WJYl.js +0 -4
  242. package/dist/assets/i18n-locale-es-D_WOifJ_.js +0 -4
  243. package/dist/assets/i18n-locale-fr-3cvyjMkp.js +0 -4
  244. package/dist/assets/i18n-locale-ja-DXlIkB8I.js +0 -4
  245. package/dist/assets/i18n-locale-ko-DngRpS45.js +0 -4
  246. package/dist/assets/i18n-locale-pt-BkPaFCqZ.js +0 -4
  247. package/dist/assets/i18n-locale-ru-E5wLh-y6.js +0 -4
  248. package/dist/assets/i18n-locale-zh-BL4_Yand.js +0 -4
  249. package/dist/assets/i18n-runtime-97_bDVjP.js +0 -1
  250. package/dist/assets/index-Cadlh4t_.css +0 -2
  251. package/dist/assets/index-D98sa5GF.js +0 -20
  252. package/dist/assets/integration-CeAF4JFT.js +0 -1
  253. package/dist/assets/isSameWeek-DBXaA1Gd.js +0 -1
  254. package/dist/assets/mermaid-GHXKKRXX-Bb17TtNP.js +0 -1
  255. package/dist/assets/metadata-admin-CABUxbJl.js +0 -9
  256. package/dist/assets/plugin-calendar-Cn5HaZU8.js +0 -1
  257. package/dist/assets/plugin-charts-B6RcFWbo.js +0 -7
  258. package/dist/assets/plugin-dashboard-DjEx8e5Y.js +0 -6
  259. package/dist/assets/plugin-form-CLDvL0up.js +0 -1
  260. package/dist/assets/plugin-gantt-CrVrxVdi.js +0 -63
  261. package/dist/assets/plugin-grid-D2rmQEW_.js +0 -11
  262. package/dist/assets/plugin-kanban-BUNHFfIC.js +0 -1
  263. package/dist/assets/plugin-map-y-7RQQC5.js +0 -1
  264. package/dist/assets/plugin-report-mT3jpna0.js +0 -59
  265. package/dist/assets/plugin-timeline-B1EF83D3.js +0 -1
  266. package/dist/assets/plugin-tree-MTHUt3_S.js +0 -1
  267. package/dist/assets/plugin-view-DHJI-ahf.js +0 -1
  268. package/dist/assets/plugins-views-CfkgqD30.js +0 -3
  269. package/dist/assets/src-BUtIBFDA.js +0 -1
  270. package/dist/assets/src-C0eXlKtx.js +0 -16
  271. package/dist/assets/types-zod-DXpXw10W.js +0 -1
  272. package/dist/assets/ui-components-D6cEVg0T.js +0 -37
  273. package/dist/assets/ui-layout-DgVDuPEM.js +0 -1
  274. package/dist/assets/use-book-data-CwRldFxP.js +0 -1
  275. package/dist/assets/useCanAuthorMetadata-BxCMgFRf.js +0 -1
  276. package/dist/assets/useOpenRecordList-BrwJFojQ.js +0 -1
  277. package/dist/assets/vendor-objectstack-DFqu45yM.js +0 -138
@@ -0,0 +1,16 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ui-components-BL3SEdAz.css","./plugin-dashboard-DnNKJB60.css"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{d as t,h as n,l as r,p as i,r as a,t as o,u as s,v as c}from"./vendor-react-BggL7APJ.js";import{a as l,p as u,v as d}from"./infrastructure-CSnL6ntj.js";import{$i as f,A as p,D as m,F as h,Fi as g,J as _,K as v,Ka as y,M as b,O as x,P as S,St as C,T as w,Ut as T,Wi as E,_t as D,br as O,c as k,d as A,ei as j,g as M,ha as N,it as P,j as ee,m as F,o as te,pa as ne,ra as re,rn as ie,st as ae,t as oe,ta as I,u as se,ut as ce,vt as le,w as ue,xn as de,zr as fe}from"./vendor-objectstack-C4eD5dbT.js";import{$n as L,$t as pe,At as me,Bn as he,Br as ge,Cr as _e,Dr as ve,Dt as ye,E as be,Er as xe,Et as Se,F as Ce,Fn as we,Fr as Te,Gr as Ee,Hr as De,In as Oe,Ir as ke,Jn as Ae,Jt as je,Kn as Me,Kt as Ne,Ln as Pe,Lr as Fe,Lt as Ie,Mn as Le,Mr as Re,Nn as ze,Nr as Be,Or as Ve,Pn as He,Pr as Ue,Pt as We,Qt as Ge,Rn as Ke,Rr as qe,Rt as Je,Si as R,T as Ye,Tr as Xe,Vn as Ze,Vr as Qe,Wr as $e,Wt as et,Yn as z,Zt as tt,an as nt,bi as B,cn as rt,dt as it,en as at,et as ot,ii as V,in as st,jn as ct,jr as lt,kn as ut,kr as dt,nn as ft,on as pt,qn as mt,rn as ht,sn as gt,tn as _t,zn as vt,zr as yt}from"./ui-components-D8wcRNrt.js";import{Ci as bt,E as xt,Et as St,Fr as Ct,G as wt,Hi as Tt,Mn as Et,Nt as Dt,Pt as Ot,Qi as kt,S as At,U as jt,Ui as Mt,Vn as Nt,W as Pt,X as Ft,Yr as It,at as Lt,b as Rt,cn as zt,gt as Bt,li as Vt,mi as Ht,on as Ut,rt as Wt,sn as Gt,ur as Kt,wi as qt,wt as Jt,xi as Yt}from"./framework-CAuH4h0L.js";import{d as Xt,f as Zt,g as Qt,m as $t,p as en,s as tn,t as nn,w as rn}from"./i18n-runtime-CdWyaiOD.js";import{d as an}from"./data-adapter-BDsrq0TX.js";import{r as on}from"./vendor-ui-utils-DIUdEYii.js";import{t as sn}from"./vendor-icon-activity-CkniytwY.js";import{t as cn}from"./vendor-icon-alarm-clock-Cydb_k9Y.js";import{t as ln}from"./vendor-icon-app-window-Ba5lrpTr.js";import{t as un}from"./vendor-icon-arrow-down-Bo-fuW7k.js";import{t as dn}from"./vendor-icon-arrow-right-RqsZZ458.js";import{t as fn}from"./vendor-icon-arrow-up-CzdjEQwQ.js";import{t as pn}from"./vendor-icon-asterisk-Dgld450r.js";import{t as mn}from"./vendor-icon-at-sign-B71HJHhC.js";import{t as hn}from"./vendor-icon-bell-6t8He8Wt.js";import{t as gn}from"./vendor-icon-book-open-DKPXYwQK.js";import{t as _n}from"./vendor-icon-bot-B9KkwkON.js";import{t as vn}from"./vendor-icon-box-YdZpEqfe.js";import{t as yn}from"./vendor-icon-boxes-D-Ov3dJw.js";import{t as bn}from"./vendor-icon-braces-DpucUCEz.js";import{t as xn}from"./vendor-icon-brain-circuit-t2dx4jHG.js";import{t as Sn}from"./vendor-icon-bug-BdoY1KRy.js";import{t as Cn}from"./vendor-icon-building-2-GgGvlXZt.js";import{t as wn}from"./vendor-icon-calendar-BsoUBIef.js";import{t as Tn}from"./vendor-icon-chart-area-D8lW2P2T.js";import{t as En}from"./vendor-icon-chart-column-DicJIApF.js";import{t as Dn}from"./vendor-icon-chart-line-DOxarYni.js";import{t as On}from"./vendor-icon-chart-no-axes-column-increasing-B83_C-Nw.js";import{t as kn}from"./vendor-icon-chart-no-axes-column-BfpSKd1L.js";import{t as An}from"./vendor-icon-chart-pie-OmZxepOF.js";import{t as jn}from"./vendor-icon-chart-scatter-Dw4KAem0.js";import{t as Mn}from"./vendor-icon-check-vpu9Zukp.js";import{t as Nn}from"./vendor-icon-chevron-down-BEf_jTEE.js";import{t as Pn}from"./vendor-icon-chevron-right-DbnKwHYQ.js";import{t as Fn}from"./vendor-icon-chevron-up-C-6o_0je.js";import{t as In}from"./vendor-icon-chevrons-down-up-BnOaG_Oo.js";import{t as Ln}from"./vendor-icon-chevrons-up-down-CbDukqtA.js";import{t as Rn}from"./vendor-icon-circle-alert-D1XTr_X9.js";import{t as zn}from"./vendor-icon-circle-check-Bq3OcFQN.js";import{t as Bn}from"./vendor-icon-circle-dot-vUSXdUmv.js";import{t as Vn}from"./vendor-icon-circle-pause-BtwoIgat.js";import{t as Hn}from"./vendor-icon-circle-play-BTJWb_ac.js";import{t as Un}from"./vendor-icon-circle-stop-DLu8C6yn.js";import{t as Wn}from"./vendor-icon-circle-x-Nkh1Yr7N.js";import{t as Gn}from"./vendor-icon-circle-5-gUQbxi.js";import{t as Kn}from"./vendor-icon-clipboard-list-Cj86xStJ.js";import{t as qn}from"./vendor-icon-clock-CTLnah0r.js";import{t as Jn}from"./vendor-icon-cloud-off-BcxbO-CE.js";import{t as Yn}from"./vendor-icon-cloud-eTQppJmM.js";import{t as Xn}from"./vendor-icon-code-xml-C9EWHSC8.js";import{t as Zn}from"./vendor-icon-code-C7LFGCxG.js";import{t as Qn}from"./vendor-icon-columns-3-DsEBPpuZ.js";import{t as $n}from"./vendor-icon-compass-CXq7Xl5b.js";import{t as er}from"./vendor-icon-copy-B5M-KdZo.js";import{t as tr}from"./vendor-icon-database-zap-7MfjG9vP.js";import{t as nr}from"./vendor-icon-database-C8JGjSkn.js";import{t as rr}from"./vendor-icon-diamond-L7C1CJFo.js";import{t as ir}from"./vendor-icon-donut-NivfVjRq.js";import{t as ar}from"./vendor-icon-download-C3csYSaD.js";import{t as or}from"./vendor-icon-earth-KgMAAeNO.js";import{t as sr}from"./vendor-icon-ellipsis-BjiiCS3N.js";import{t as cr}from"./vendor-icon-external-link-SBKz5x6R.js";import{t as lr}from"./vendor-icon-eye-off-Dy3GIcvl.js";import{t as ur}from"./vendor-icon-eye-C3HaEGOo.js";import{t as dr}from"./vendor-icon-file-braces-D8irpr63.js";import{t as fr}from"./vendor-icon-file-code-corner-CdiQRG_f.js";import{t as pr}from"./vendor-icon-file-pen-l-DSznsL.js";import{t as mr}from"./vendor-icon-file-plus-DMAKv9CD.js";import{t as hr}from"./vendor-icon-file-search-G3ut07Ux.js";import{t as gr}from"./vendor-icon-file-text-7BKAVNof.js";import{t as _r}from"./vendor-icon-file-x-BcqWCCDH.js";import{t as vr}from"./vendor-icon-flask-conical-CaTZd1FS.js";import{t as yr}from"./vendor-icon-folder-input-CeRcsOb0.js";import{t as br}from"./vendor-icon-folder-plus-DX3Wm6yc.js";import{t as xr}from"./vendor-icon-folder-tree-BQ1wv9bt.js";import{t as Sr}from"./vendor-icon-folder-GbhohOfU.js";import{t as Cr}from"./vendor-icon-folders-CbV1Socn.js";import{t as wr}from"./vendor-icon-funnel-CtmEg9FH.js";import{t as Tr}from"./vendor-icon-gauge-CIVyyDJV.js";import{t as Er}from"./vendor-icon-git-branch-CpQpJlYB.js";import{t as Dr}from"./vendor-icon-git-compare-arrows-BAqrva2j.js";import{t as Or}from"./vendor-icon-git-fork-DEQeROkn.js";import{t as kr}from"./vendor-icon-globe-BaOanPH5.js";import{t as Ar}from"./vendor-icon-grip-vertical-B01-ovq0.js";import{t as jr}from"./vendor-icon-hard-drive-DhSx4UAI.js";import{t as Mr}from"./vendor-icon-hash-Lkwzb5Ny.js";import{t as Nr}from"./vendor-icon-image-D2YAsa8l.js";import{t as Pr}from"./vendor-icon-inbox-ByVQ4l4S.js";import{t as Fr}from"./vendor-icon-info-DBwRTfSE.js";import{t as Ir}from"./vendor-icon-iteration-ccw-S525B89r.js";import{t as Lr}from"./vendor-icon-key-round-hQwGYgPA.js";import{t as Rr}from"./vendor-icon-languages-CI3j7ujw.js";import{t as zr}from"./vendor-icon-layers-DXBEefR1.js";import{t as Br}from"./vendor-icon-layout-dashboard-wba2hvZp.js";import{t as Vr}from"./vendor-icon-layout-grid-B3quJ1GF.js";import{t as Hr}from"./vendor-icon-link-2-EAo0juhN.js";import{t as Ur}from"./vendor-icon-link-RPcdxfUF.js";import{t as Wr}from"./vendor-icon-list-checks-Df4Wgu_H.js";import{t as Gr}from"./vendor-icon-list-TLz-7vfa.js";import{t as H}from"./vendor-icon-loader-circle-D3PsuVaD.js";import{t as Kr}from"./vendor-icon-lock-B_psRnly.js";import{t as qr}from"./vendor-icon-mail-BfkRvgNr.js";import{t as Jr}from"./vendor-icon-map-pin-BS-hHv53.js";import{t as Yr}from"./vendor-icon-maximize-2-C215UtMO.js";import{t as Xr}from"./vendor-icon-menu-9YHQR0RT.js";import{t as Zr}from"./vendor-icon-message-circle-BqNTtTOp.js";import{t as Qr}from"./vendor-icon-message-square-BObk9Jes.js";import{t as $r}from"./vendor-icon-minus-CMTDFpmk.js";import{t as ei}from"./vendor-icon-monitor-smartphone-CM4rljlr.js";import{t as ti}from"./vendor-icon-mouse-pointer-click-WdN96Sza.js";import{t as ni}from"./vendor-icon-octagon-x-DJaJymPi.js";import{t as ri}from"./vendor-icon-package-open-D7O9qUER.js";import{t as ii}from"./vendor-icon-package-B6zAlWd3.js";import{t as ai}from"./vendor-icon-palette-CazWMHVl.js";import{t as oi}from"./vendor-icon-panel-bottom-DmyC876M.js";import{t as si}from"./vendor-icon-panel-left-Cml87N0K.js";import{t as ci}from"./vendor-icon-panel-right-CzpSEi8j.js";import{t as li}from"./vendor-icon-panel-top-BRy5u3nR.js";import{t as ui}from"./vendor-icon-paperclip-zxZDBuvr.js";import{t as di}from"./vendor-icon-pencil-CMubUBjW.js";import{t as fi}from"./vendor-icon-phone-H1S8HSi1.js";import{t as pi}from"./vendor-icon-play-BfFoh-7G.js";import{t as mi}from"./vendor-icon-plug-CL1O_4J3.js";import{t as U}from"./vendor-icon-plus-BlfcDDsa.js";import{t as hi}from"./vendor-icon-power-CySrWbJV.js";import{t as gi}from"./vendor-icon-puzzle-D0_dPnVP.js";import{t as _i}from"./vendor-icon-rectangle-ellipsis-CAvWLjnI.js";import{t as vi}from"./vendor-icon-refresh-cw-BGjSPEfJ.js";import{t as yi}from"./vendor-icon-regex-B4Eime8Q.js";import{t as bi}from"./vendor-icon-repeat-_fqynyPW.js";import{t as xi}from"./vendor-icon-rocket-9sBBTCrW.js";import{t as Si}from"./vendor-icon-rotate-ccw-clock-DyTX5-aX.js";import{t as Ci}from"./vendor-icon-rotate-ccw-lr5YKsxC.js";import{t as wi}from"./vendor-icon-rows-3-Bl0iGPg_.js";import{t as Ti}from"./vendor-icon-save-CuavGNuU.js";import{t as Ei}from"./vendor-icon-scroll-text-DENjQLzo.js";import{t as Di}from"./vendor-icon-search-B2Uqtp_W.js";import{t as Oi}from"./vendor-icon-settings-2-BHIWdy1J.js";import{t as ki}from"./vendor-icon-shield-alert-CJYtPI9w.js";import{t as Ai}from"./vendor-icon-shield-check-CdDzbial.js";import{t as ji}from"./vendor-icon-shield-x-C3Af1iLQ.js";import{t as Mi}from"./vendor-icon-shield-DsNraEeY.js";import{t as Ni}from"./vendor-icon-sigma-DSt0XKnk.js";import{t as Pi}from"./vendor-icon-skip-forward-CfRT1Tc0.js";import{t as Fi}from"./vendor-icon-sparkles-RGpJ39Rc.js";import{t as Ii}from"./vendor-icon-square-check-big-B4UVzWzR.js";import{t as Li}from"./vendor-icon-square-D32ztiBM.js";import{t as Ri}from"./vendor-icon-star-DfusowFE.js";import{t as zi}from"./vendor-icon-step-forward-5ECOEIqn.js";import{t as Bi}from"./vendor-icon-store-CwiX9Ffi.js";import{t as Vi}from"./vendor-icon-table-2-DMQ6UahM.js";import{t as Hi}from"./vendor-icon-table-CeQhi8NL.js";import{t as Ui}from"./vendor-icon-tag-iKhUiq-2.js";import{t as Wi}from"./vendor-icon-timer-reset-Wg02gBEl.js";import{t as Gi}from"./vendor-icon-timer-DT4EckeV.js";import{t as Ki}from"./vendor-icon-trash-BLsWkwB9.js";import{t as qi}from"./vendor-icon-trending-down-C8VFA2s8.js";import{t as Ji}from"./vendor-icon-triangle-alert-D5n0T3q_.js";import{t as Yi}from"./vendor-icon-type-DudTuHpS.js";import{t as Xi}from"./vendor-icon-unplug-BgYklMNm.js";import{t as Zi}from"./vendor-icon-user-check-DDH3nUIb.js";import{t as Qi}from"./vendor-icon-users-Db5uTXC8.js";import{t as $i}from"./vendor-icon-variable-BIgoZQoz.js";import{t as ea}from"./vendor-icon-workflow-B9ASq0nN.js";import{t as ta}from"./vendor-icon-wrench-BX7gnYSA.js";import{t as na}from"./vendor-icon-x-CcLtgRNL.js";import{t as ra}from"./vendor-icon-zap-3ulAPCbu.js";import{t as ia}from"./vendor-icon-zoom-out-IlqZRNIF.js";import{t as aa}from"./vendor-icon-zoom-in-ShI9ftXk.js";import{n as oa,o as sa,s as ca}from"./createDerive-CynsXU-B.js";import{n as la}from"./assistantBus-DoNtw1Tf.js";import{a as ua,r as da}from"./ExpressionProvider-Dr0e99r1.js";import{a as fa,f as pa,i as ma,l as ha,p as ga,u as _a}from"./ActionResultDialog-ChYnuROr.js";import{A as va,C as ya,M as ba,N as xa,P as Sa,a as Ca,i as wa,j as Ta,k as Ea,x as Da}from"./RecordDetailView-B3XBEgk2.js";import{a as Oa,i as ka,n as Aa,o as ja,s as Ma,t as Na}from"./useNavTargetLabel-D8lRdb6O.js";import{f as Pa,m as Fa}from"./plugin-chatbot-D1KW_oIO.js";import"./app-shell-eager-leaves-D9tgfJOe.js";import{n as Ia}from"./utils-MjUhYVsx.js";import{D as La,S as Ra,T as za,a as Ba,f as Va,l as Ha,n as Ua,o as Wa,x as Ga,y as Ka}from"./default-inspector-registry-Dktr6x_q.js";import{a as qa,i as Ja,o as Ya,r as Xa,t as Za}from"./ui-layout-BYO3rRIl.js";import{f as Qa}from"./plugin-grid-Cp4RKtMJ.js";import{t as $a}from"./InterfaceListPage-BfoCldGu.js";import{t as eo}from"./getIcon-BDkBRQFw.js";import{$ as to,A as no,C as ro,D as io,E as ao,F as oo,G as so,H as co,I as lo,J as uo,K as fo,L as po,M as mo,N as ho,O as go,P as _o,Q as vo,R as yo,S as bo,T as xo,U as So,V as Co,X as wo,Y as To,Z as Eo,a as Do,at as Oo,b as ko,c as Ao,et as jo,f as Mo,h as No,i as Po,j as Fo,k as Io,nt as Lo,o as Ro,q as zo,r as Bo,rt as Vo,s as Ho,tt as Uo,u as Wo,v as Go,w as Ko,x as qo,y as Jo,z as Yo}from"./SchemaForm-BWSWYMLE.js";import{c as Xo,d as Zo,f as Qo,g as $o,i as W,n as es,r as G,t as ts}from"./i18n-DTfZonAM.js";import{C as ns,S as rs,_ as is,a as as,b as os,c as ss,d as cs,f as ls,g as K,h as us,i as ds,l as fs,m as ps,n as ms,o as hs,p as gs,r as _s,s as vs,t as ys,u as bs,v as q,w as xs,x as Ss,y as Cs}from"./ReportDefaultInspector-DVcWM6sh.js";import{n as ws,t as Ts}from"./useDatasetCatalog-BOd0Ybr1.js";import{r as Es,t as Ds}from"./componentRegistry-DlSbJucP.js";var J=e(c(),1),Y=o(),Os={info:(e,t)=>on.info(e,t),success:(e,t)=>on.success(e,t),warning:(e,t)=>on.warning(e,t),error:(e,t)=>on.error(e,t)};function ks(e,t){let n=Os[e.severity]??Os.info,r=e.actions?.[0],i=Ne(e.icon)?(0,Y.jsx)(et,{name:e.icon,className:`h-4 w-4`}):void 0,a=Ft(e,t),o=a?it[a]:void 0;n(e.title,{description:e.message,duration:e.duration===0?1/0:e.duration,dismissible:e.dismissible,...i?{icon:i}:{},...o?{position:o}:{},...r?{action:{label:r.label,onClick:r.onClick}}:{}})}function As(){let e={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},t=e.VITE_AI_BASE_URL;return t?t.replace(/\/$/,``):`${(e.VITE_SERVER_URL??``).replace(/\/$/,``)}/api/v1/ai`}function js(){let{agents:e,isLoading:t}=Pa({apiBase:As()}),n=(0,J.useRef)(!1);t&&(n.current=!0);let r=e.length>0;return{enabled:r,isLoading:r?!1:t||!n.current}}var Ms=`flow-palette-recents`,Ns=Ms,Ps=5;function Fs(){try{if(typeof localStorage>`u`)return[];let e=localStorage.getItem(Ns);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`).slice(0,Ps):[]}catch{return[]}}function Is(e){if(e)try{if(typeof localStorage>`u`)return;let t=[e,...Fs().filter(t=>t!==e)].slice(0,Ps);localStorage.setItem(Ns,JSON.stringify(t))}catch{}}var Ls=Ms;function Rs(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(0,5):[]}function zs(e){try{let t=localStorage.getItem(_a(Ls,e));return t?Rs(JSON.parse(t)):[]}catch{return[]}}function Bs(e,t){try{localStorage.setItem(_a(Ls,t),JSON.stringify(e))}catch{}}function Vs(e,t){if(!t)return{list:e,didMigrate:!1};let n;try{n=localStorage.getItem(Ls)}catch{return{list:e,didMigrate:!1}}if(n==null)return{list:e,didMigrate:!1};let r=[];try{r=Rs(JSON.parse(n))}catch{}try{localStorage.removeItem(Ls)}catch{}if(r.length===0)return{list:e,didMigrate:!0};let i=[...e];for(let e of r)i.includes(e)||i.push(e);return{list:i.slice(0,5),didMigrate:!0}}var Hs=(0,J.createContext)(null);function Us({children:e}){let{user:t}=u(),n=t?.id??null,r=ga(`flowPaletteRecents`),[i,a]=(0,J.useState)(()=>zs(n));pa(_a(Ls,n),e=>{a(Rs(e))});let o=(0,J.useMemo)(()=>ha(async e=>{r&&await r.save(e)},500),[r]);(0,J.useEffect)(()=>()=>void o.flush(),[o]);let s=(0,J.useCallback)(e=>{Bs(e,n),r&&o.schedule(e)},[n,r,o]),c=(0,J.useRef)(0);(0,J.useEffect)(()=>{let e=++c.current,t=!1;return(async()=>{let i=zs(n),s=r?Rs(await r.load().catch(()=>[])):[];if(t||e!==c.current)return;let{list:l,didMigrate:u}=Vs(s.length?s:i,n);a(l),Bs(l,n),u&&r&&o.schedule(l)})(),()=>{t=!0}},[r,n,o]);let l=(0,J.useCallback)(e=>{e&&a(t=>{let n=[e,...t.filter(t=>t!==e)].slice(0,5);return s(n),n})},[s]),d=(0,J.useMemo)(()=>({recents:i,recordRecent:l}),[i,l]);return(0,Y.jsx)(Hs.Provider,{value:d,children:e})}function Ws(){let e=(0,J.useContext)(Hs),[t,n]=(0,J.useState)(()=>Fs()),r=(0,J.useCallback)(e=>{Is(e),n(Fs())},[]);return e||{recents:t,recordRecent:r}}function Gs(){if(typeof globalThis>`u`)return null;let e=globalThis.Notification;return typeof e==`function`?e:null}function Ks(){return Gs()!==null}function qs(){let e=Gs();if(!e)return`unsupported`;let t=e.permission;return t===`granted`||t===`denied`?t:`default`}async function Js(){let e=Gs();if(!e)return`unsupported`;if(e.permission===`granted`||e.permission===`denied`)return e.permission;if(typeof e.requestPermission!=`function`)return qs();try{let t=await e.requestPermission();return t===`granted`||t===`denied`?t:`default`}catch{return qs()}}function Ys(e){let t=Gs();if(!t||t.permission!==`granted`)return!1;try{let n=new t(e.title,{...e.body?{body:e.body}:{},...e.tag?{tag:e.tag}:{}});return n.onclick=()=>{globalThis.focus?.(),e.onActivate?.(),n.close?.()},!0}catch{return!1}}var Xs=`objectui.notificationPreferences`,Zs=Object.freeze({toast:!0,desktop:!1});function Qs(e){let t=e;return{toast:typeof t?.toast==`boolean`?t.toast:Zs.toast,desktop:typeof t?.desktop==`boolean`?t.desktop:Zs.desktop}}function $s(e){if(typeof window>`u`)return Zs;try{let t=window.localStorage.getItem(_a(Xs,e));return Qs(t?JSON.parse(t):null)}catch{return Zs}}function ec(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(_a(Xs,e),JSON.stringify(t))}catch{}}var tc=new Set,nc=null;function rc(e,t){return(!nc||nc.key!==e)&&(nc={key:e,value:$s(t)}),nc.value}function ic(e,t){nc={key:e,value:t};for(let e of[...tc])e()}function ac(e){return tc.add(e),()=>{tc.delete(e)}}function oc(){let{user:e}=u(),t=e?.id??null,n=_a(Xs,t),r=(0,J.useSyncExternalStore)(ac,()=>rc(n,t),()=>rc(n,t));pa(n,e=>{ic(n,Qs(e))});let i=qs(),a=Ks(),o=(0,J.useCallback)(e=>{ec(t,e),ic(_a(Xs,t),e)},[t]),s=(0,J.useCallback)(e=>{o({...$s(t),toast:e})},[o,t]),c=(0,J.useCallback)(async()=>{let e=await Js();return o({...$s(t),desktop:e===`granted`}),e},[o,t]),l=(0,J.useCallback)(()=>{o({...$s(t),desktop:!1})},[o,t]);return(0,J.useMemo)(()=>({preferences:r,desktopPermission:i,desktopSupported:a,setToastEnabled:s,enableDesktop:c,disableDesktop:l}),[r,i,a,s,c,l])}function sc(e,t){if(!e)return``;let n=new Date(e).getTime();return Number.isNaN(n)?``:Xt(n,t)}function cc(e){let t=[],n=new Map;for(let r of e){let e=(r.type??``).trim(),i=(r.title??``).trim(),a=e||i?`${e}\u0000${i}`:`__row__${r.id}`,o=n.get(a);o||(o={key:a,type:r.type,title:r.title,items:[],unreadCount:0,latestCreatedAt:r.created_at},n.set(a,o),t.push(o)),o.items.push(r),r.is_read||(o.unreadCount+=1),r.created_at&&(!o.latestCreatedAt||r.created_at>o.latestCreatedAt)&&(o.latestCreatedAt=r.created_at)}return t}function lc({notifications:e,unreadCount:n,pendingApprovalsCount:r,activities:a,onMarkAllRead:o,onMarkRead:s,onMarkManyRead:c}){let{t:l}=rn(),u=nn(),d=t(),f=i(),{currentAppName:p}=ya(),{apps:m}=wt(),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(`notifications`),[y,b]=(0,J.useState)(`unread`),[x,S]=(0,J.useState)(()=>new Set),C=(0,J.useMemo)(()=>cc(e),[e]).reduce((e,t)=>e+ +(t.unreadCount>0),0),w=C+r,T=l(`sidebar.inboxAriaLabel`,{defaultValue:`Open inbox`}),E=(0,J.useRef)(null),[D,O]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let e=E.current;if(e!==null&&w>e){O(!0);let e=window.setTimeout(()=>O(!1),1200);return()=>window.clearTimeout(e)}E.current=w},[w]),(0,J.useEffect)(()=>{D||(E.current=w)},[D,w]);let k=()=>{g(!1);let e=p??f.appName;d(e?`/apps/${e}/system/approvals`:`/apps/setup/system/approvals`)},A=ja(m,p??f.appName),j=()=>{g(!1),d(`/apps/${A}/sys_inbox_message?view=mine`)},M=()=>{g(!1),d(`/apps/${A}/sys_activity`)},N=e=>{s(e.id);let t=Ma(e.action_url,A);if(!t){j();return}if(g(!1),t.kind===`external`){window.open(t.url,`_blank`,`noopener,noreferrer`);return}d(t.path)},P=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ee=e=>{let t=e.items.filter(e=>!e.is_read).map(e=>e.id);t.length!==0&&(c?c(t):t.forEach(s))},F=(e,t)=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>N(e),className:`w-full text-left ${t?`pl-9 pr-3 py-2`:`px-3 py-2.5`} hover:bg-accent transition-colors duration-150 ${e.is_read?``:`bg-accent/40`}`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-primary transition-opacity duration-200 ${e.is_read?`opacity-0`:`opacity-100`}`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium leading-tight truncate`,children:e.title}),e.body&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground line-clamp-2 mt-0.5`,children:e.body}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:sc(e.created_at,u)})]})]})});return(0,Y.jsxs)(Me,{open:h,onOpenChange:g,children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.jsxs)(B,{variant:`ghost`,size:`icon`,className:`h-8 w-8 relative shrink-0 ${D?`motion-safe:animate-bounce`:``}`,"aria-label":T,title:l(`sidebar.inbox`,{defaultValue:`Inbox`}),children:[(0,Y.jsx)(hn,{className:`h-4 w-4`}),w>0&&(0,Y.jsx)(`span`,{"data-testid":`inbox-bell-badge`,className:`absolute -top-0.5 -right-0.5 h-4 min-w-[16px] rounded-full bg-red-500 text-[10px] leading-4 text-white text-center px-1 motion-safe:animate-in motion-safe:zoom-in-50 motion-safe:fade-in-0 motion-safe:duration-200`,children:w>9?`9+`:w},w)]})}),(0,Y.jsxs)(mt,{align:`end`,sideOffset:8,className:`w-96 p-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-3 pt-3 pb-1`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-semibold`,children:l(`sidebar.inbox`,{defaultValue:`Inbox`})}),_===`notifications`&&n>0&&(0,Y.jsx)(`button`,{type:`button`,onClick:o,className:`text-xs text-muted-foreground hover:text-foreground`,children:l(`notifications.markAllRead`,{defaultValue:`Mark all read`})})]}),w>0&&(0,Y.jsxs)(`div`,{"data-testid":`inbox-badge-breakdown`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-3 pb-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{"data-testid":`inbox-badge-breakdown-total`,className:`font-medium text-foreground`,children:l(`notifications.badgeTotal`,{defaultValue:`{{total}} total`,total:w})}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Y.jsx)(`span`,{"data-testid":`inbox-badge-breakdown-notifications`,children:l(`notifications.badgeNotifications`,{defaultValue:`{{unread}} notifications`,unread:C})}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`+`}),(0,Y.jsx)(`span`,{"data-testid":`inbox-badge-breakdown-approvals`,children:l(`notifications.badgeApprovals`,{defaultValue:`{{approvals}} pending approvals`,approvals:r})})]}),(0,Y.jsxs)(Ge,{value:_,onValueChange:e=>v(e),className:`w-full`,children:[(0,Y.jsxs)(at,{className:`w-full justify-start rounded-none border-b bg-transparent px-1 h-9`,children:[(0,Y.jsxs)(_t,{value:`notifications`,className:`text-xs gap-1.5 data-[state=active]:bg-transparent`,children:[(0,Y.jsx)(hn,{className:`h-3.5 w-3.5`}),l(`sidebar.notifications`,{defaultValue:`Notifications`}),C>0&&(0,Y.jsx)(`span`,{className:`ml-0.5 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-red-500 px-1 text-[10px] text-white motion-safe:animate-in motion-safe:zoom-in-75 motion-safe:duration-200`,children:C>9?`9+`:C},`notif-${C}`)]}),(0,Y.jsxs)(_t,{value:`approvals`,className:`text-xs gap-1.5 data-[state=active]:bg-transparent`,children:[(0,Y.jsx)(Ii,{className:`h-3.5 w-3.5`}),l(`sidebar.approvals`,{defaultValue:`Approvals`}),r>0&&(0,Y.jsx)(`span`,{className:`ml-0.5 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-amber-500 px-1 text-[10px] text-white motion-safe:animate-in motion-safe:zoom-in-75 motion-safe:duration-200`,children:r>9?`9+`:r},`appr-${r}`)]}),(0,Y.jsxs)(_t,{value:`activity`,className:`text-xs gap-1.5 data-[state=active]:bg-transparent`,children:[(0,Y.jsx)(sn,{className:`h-3.5 w-3.5`}),l(`sidebar.activityFeed`,{defaultValue:`Activity feed`})]})]}),(0,Y.jsxs)(pe,{value:`notifications`,className:`m-0 max-h-80 overflow-auto`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 border-b px-2 py-1.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>b(`unread`),className:`text-xs px-2 py-1 rounded-md transition-colors ${y===`unread`?`bg-accent text-foreground font-medium`:`text-muted-foreground hover:text-foreground`}`,children:[l(`notifications.filterUnread`,{defaultValue:`Unread`}),C>0&&(0,Y.jsx)(`span`,{className:`ml-1 text-[10px] opacity-70`,children:C})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>b(`all`),className:`text-xs px-2 py-1 rounded-md transition-colors ${y===`all`?`bg-accent text-foreground font-medium`:`text-muted-foreground hover:text-foreground`}`,children:l(`notifications.filterAll`,{defaultValue:`All`})})]}),(()=>{let t=y===`unread`?e.filter(e=>!e.is_read):e;if(t.length===0)return(0,Y.jsx)(`div`,{className:`px-3 py-8 text-sm text-muted-foreground text-center motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-300`,children:y===`unread`?l(`notifications.emptyUnread`,{defaultValue:`You're all caught up`}):l(`notifications.empty`,{defaultValue:`No notifications`})});let n=cc(t);return(0,Y.jsx)(`ul`,{className:`divide-y`,children:n.map((e,t)=>{let n={className:`motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1 motion-safe:duration-200`,style:{animationDelay:`${Math.min(t,6)*20}ms`}};if(e.items.length===1)return(0,Y.jsx)(`li`,{...n,children:F(e.items[0],!1)},e.key);let r=x.has(e.key);return(0,Y.jsxs)(`li`,{...n,children:[(0,Y.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>P(e.key),"aria-expanded":r,className:`flex-1 min-w-0 text-left px-3 py-2.5 hover:bg-accent transition-colors duration-150 ${e.unreadCount>0?`bg-accent/40`:``}`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-primary transition-opacity duration-200 ${e.unreadCount>0?`opacity-100`:`opacity-0`}`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium leading-tight truncate`,children:e.title}),(0,Y.jsxs)(`span`,{className:`shrink-0 rounded-full bg-muted px-1.5 text-[10px] font-medium leading-4 text-muted-foreground`,"aria-label":l(`notifications.groupCount`,{defaultValue:`{{count}} notifications`,count:e.items.length}),children:[`×`,e.items.length]})]}),e.items[0].body&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground line-clamp-1 mt-0.5`,children:e.items[0].body}),(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:[sc(e.latestCreatedAt,u),e.unreadCount>0&&(0,Y.jsxs)(`span`,{className:`ml-1`,children:[`·`,` `,l(`notifications.groupUnread`,{defaultValue:`{{count}} unread`,count:e.unreadCount})]})]})]}),(0,Y.jsx)(Pn,{className:`mt-1 h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 ${r?`rotate-90`:``}`,"aria-hidden":!0})]})}),e.unreadCount>0&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ee(e),className:`shrink-0 px-2 text-[10px] text-muted-foreground hover:text-foreground hover:bg-accent transition-colors border-l`,title:l(`notifications.groupMarkReadTitle`,{defaultValue:`Mark all of this type read`}),children:l(`notifications.groupMarkRead`,{defaultValue:`Mark read`})})]}),r&&(0,Y.jsx)(`ul`,{className:`divide-y border-t bg-muted/20`,children:e.items.map(e=>(0,Y.jsx)(`li`,{children:F(e,!0)},e.id))})]},e.key)})})})(),(0,Y.jsx)(`div`,{className:`border-t px-3 py-2 text-center`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:j,className:`text-xs text-primary hover:underline`,children:l(`notifications.viewAll`,{defaultValue:`View all notifications`})})})]}),(0,Y.jsx)(pe,{value:`approvals`,className:`m-0 max-h-80 overflow-auto`,children:(0,Y.jsx)(`div`,{className:`px-3 py-6 text-center motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-300`,children:r>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ii,{className:`mx-auto h-6 w-6 text-amber-500 motion-safe:animate-in motion-safe:zoom-in-50 motion-safe:duration-300`}),(0,Y.jsx)(`div`,{className:`mt-2 text-sm font-medium`,children:l(`notifications.approvalsPending`,{defaultValue:`{{count}} pending approvals`,count:r})}),(0,Y.jsx)(B,{size:`sm`,className:`mt-3`,onClick:k,children:l(`notifications.viewApprovals`,{defaultValue:`View approvals`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:l(`notifications.noPendingApprovals`,{defaultValue:`No pending approvals`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:k,className:`mt-2 text-xs text-primary hover:underline`,children:l(`notifications.openApprovalsInbox`,{defaultValue:`Open Approvals Inbox`})})]})})}),(0,Y.jsxs)(pe,{value:`activity`,className:`m-0 max-h-80 overflow-auto`,children:[a.length===0?(0,Y.jsx)(`div`,{className:`px-3 py-8 text-sm text-muted-foreground text-center motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-300`,children:l(`layout.activityFeed.empty`,{defaultValue:`No recent activity`})}):(0,Y.jsx)(`ul`,{className:`divide-y`,children:a.slice(0,20).map((e,t)=>(0,Y.jsxs)(`li`,{className:`px-3 py-2.5 motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1 motion-safe:duration-200`,style:{animationDelay:`${Math.min(t,6)*20}ms`},children:[(0,Y.jsxs)(`div`,{className:`text-sm leading-tight truncate`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e.description})]}),(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:[sc(e.timestamp,u),` · `,e.objectName]})]},e.id))}),(0,Y.jsx)(`div`,{className:`border-t px-3 py-2 text-center`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:M,className:`text-xs text-primary hover:underline`,children:l(`layout.activityFeed.viewAll`,{defaultValue:`View all activity`})})})]})]})]})]})}function uc(e){return e===void 0||e===`ready`||e===`error`}function dc(e,t,n){return t!==void 0&&t!==`ready`||n.length===0?`unknown`:n.some(t=>t?.name===e)?`present`:`absent`}function fc(e){let{getItemsByType:t,getTypeStatus:n}=wt(),r=t(`object`),i=n?.(`object`);return{presence:dc(e,i,r),settled:uc(i)}}var pc={created:`create`,updated:`update`,deleted:`delete`,assigned:`update`,shared:`update`,commented:`comment`,mentioned:`comment`,system:`system`,completed:`system`,scheduled:`system`,login:`system`,logout:`system`},mc=`system`,hc=new Set;function gc(e){hc.has(e)||(hc.add(e),console.warn(`[app-shell] rendered a sys_activity row with type "${e}" through the generic "${mc}" presentation: no activity item type is mapped for it. \`sys_activity.type\` is author-extensible (ruled 2026-08-24) and is not validated on write, so a producer can store a value the platform never declared — the row is shown rather than dropped, and it no longer claims to be an update. Map it in ACTIVITY_TYPE_TO_ACTIVITY_ITEM_TYPE (@object-ui/app-shell, layout/activityItemType.ts) to give it its own presentation.`))}function _c(e){return(Object.prototype.hasOwnProperty.call(pc,e)?pc[e]:void 0)||(gc(e),mc)}function vc(e){let t=e.timestamp;return String(!t||t===`NOW()`||Number.isNaN(Date.parse(String(t)))?e.created_at??``:t)}function yc(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.type!=`string`||String(t.summary??``).trim().length===0?null:{id:String(t.id),type:_c(t.type),objectName:String(t.object_name??``),recordId:t.record_id==null?void 0:String(t.record_id),user:String(t.actor_name??``),description:String(t.summary??``),timestamp:vc(t)}}var bc=3e4,xc=1e4,Sc=6e4,Cc=12e4,wc=3e4,Tc=6e4,Ec=[],Dc=[],Oc=class{empty;pollMs;snapshot;key=null;listeners=new Set;runner=null;consumers=0;inFlight=!1;unavailable=!1;retiredAt=0;probesLeft=3;fetchedAt=0;timer=null;backoffMs;visibilityBound=!1;constructor(e,t){this.empty=e,this.pollMs=t,this.snapshot={value:e,status:`idle`},this.idleSnapshot=this.snapshot,this.backoffMs=t}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;idleSnapshot;attach(e,t){return e!==this.key&&(this.key=e,this.unavailable=!1,this.retiredAt=0,this.probesLeft=3,this.fetchedAt=0,this.backoffMs=this.pollMs,this.publish(this.empty,`idle`)),this.runner=t,this.consumers+=1,this.consumers===1&&(this.bindVisibility(),this.schedule()),this.refresh(),()=>{this.consumers=Math.max(0,this.consumers-1),this.consumers===0&&(this.stopPolling(),this.unbindVisibility())}}async refresh(e=!1){let t=this.runner;if(!t||this.inFlight)return;let n=this.unavailable;if(n&&!this.mayProbe()||!e&&!n&&this.fetchedAt&&Date.now()-this.fetchedAt<wc)return;this.inFlight=!0,this.snapshot.status===`idle`&&this.publish(this.snapshot.value,`loading`);let r=!1;try{let e=await t({markUnavailable:()=>n?this.spendProbe():this.retire(),markFailed:()=>{r=!0}});e===void 0?r&&(n?this.spendProbe():this.fail()):(this.unavailable=!1,this.probesLeft=3,this.fetchedAt=Date.now(),this.backoffMs=this.pollMs,this.publish(e,`ready`))}catch{n?this.spendProbe():this.fail()}finally{this.inFlight=!1,this.consumers>0&&this.schedule()}}mayProbe(){return this.probesLeft>0&&Date.now()-this.retiredAt>=6e4}retire(){this.unavailable=!0,this.retiredAt=Date.now(),this.fetchedAt=Date.now(),this.stopPolling(),this.publish(this.snapshot.value,`ready`)}spendProbe(){this.probesLeft=Math.max(0,this.probesLeft-1),this.retiredAt=Date.now(),this.fetchedAt=Date.now(),this.stopPolling()}fail(){this.backoffMs=Math.min(Math.max(this.backoffMs,this.pollMs)*2,Cc),this.publish(this.snapshot.value,`error`)}schedule(){if(this.timer)return;if(this.unavailable){if(this.probesLeft<=0)return;this.timer=setTimeout(()=>{this.timer=null,this.refresh(!0)},Tc);return}if(this.pollMs<=0)return;let e=typeof document<`u`&&document.hidden?Math.max(Sc,this.backoffMs):this.backoffMs;this.timer=setTimeout(()=>{this.timer=null,this.refresh(!0)},e)}onVisibilityChange=()=>{typeof document>`u`||document.hidden||this.consumers!==0&&(!this.unavailable||this.mayProbe())&&(this.stopPolling(),this.unavailable||(this.backoffMs=this.pollMs),this.refresh(!0))};bindVisibility(){this.pollMs<=0||this.visibilityBound||typeof document>`u`||(document.addEventListener(`visibilitychange`,this.onVisibilityChange),this.visibilityBound=!0)}unbindVisibility(){!this.visibilityBound||typeof document>`u`||(document.removeEventListener(`visibilitychange`,this.onVisibilityChange),this.visibilityBound=!1)}stopPolling(){this.timer&&=(clearTimeout(this.timer),null)}publish(e,t){if(!(Object.is(e,this.snapshot.value)&&t===this.snapshot.status)){this.snapshot={value:e,status:t};for(let e of[...this.listeners])e()}}reset(){this.stopPolling(),this.unbindVisibility(),this.snapshot={value:this.empty,status:`idle`},this.key=null,this.runner=null,this.consumers=0,this.inFlight=!1,this.unavailable=!1,this.retiredAt=0,this.probesLeft=3,this.fetchedAt=0,this.backoffMs=this.pollMs}};function kc(e,t,n){let r=(0,J.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),i=(0,J.useRef)(n);return(0,J.useEffect)(()=>{i.current=n}),(0,J.useEffect)(()=>{if(t)return e.attach(t,e=>i.current(e))},[e,t]),t?r:e.idleSnapshot}var Ac=new Oc(0,bc);function jc(e){let t=e,n=[];t?.id&&n.push(t.id),t?.email&&n.push(t.email);for(let e of t?.positions??[])e&&n.push(`position:${e}`);return n}function Mc(){let{user:e}=u(),t=jc(e);return kc(Ac,e?.id&&t.length>0?t.join(`,`):null,async({markUnavailable:e,markFailed:n})=>{let r=``.replace(/\/$/,``),i=new URLSearchParams({status:`pending`,approverId:t.join(`,`)}),a=await fetch(`${r}/api/v1/approvals/requests?${i}`,{credentials:`include`,headers:Ca()});if(a.status===404){e();return}if(!a.ok){n();return}let o=await a.json().catch(()=>null),s=new Set;for(let e of o?.data||[])s.add(e.id);return s.size}).value}var Nc=new Oc(Ec,0),Pc=new WeakMap,Fc=0;function Ic(e){if(!e||typeof e!=`object`)return null;let t=Pc.get(e);return t||(t=`adapter@${++Fc}`,Pc.set(e,t)),t}function Lc(e){return e.map(e=>yc(e)).filter(e=>e!==null)}function Rc(e){let t=e;return t?.httpStatus===404||t?.status===404||Yt(e,`OBJECT_NOT_FOUND`)}function zc(){let e=Pt(),t=fc(`sys_activity`);return kc(Nc,t.settled?Ic(e):null,async({markUnavailable:n,markFailed:r})=>{if(!e)return;if(t.presence===`absent`){n();return}let i=await Promise.resolve(e.find(`sys_activity`,{$orderby:{timestamp:`desc`},$top:20})).catch(e=>(Rc(e)?n():r(),null));if(i)return Lc(Array.isArray(i.data)?i.data:[])}).value}function Bc(e){let t=zc();return(0,J.useMemo)(()=>t.filter(e=>{let t=e.user.trim();return t.length>0&&t.toLowerCase()!==`system`}).slice(0,e),[t,e])}var Vc=new Oc(Dc,xc),Hc=new Set([`read`,`clicked`,`dismissed`]);function Uc(e,t){let n=new Map;for(let e of t){let t=e,r=t?.notification_id==null?``:String(t.notification_id);if(!r)continue;let i=String(t?.state??``),a=n.get(r);(!a||!Hc.has(a.state)&&Hc.has(i))&&n.set(r,{id:String(t?.id),state:i})}return e.map(e=>{let t=e,r=t?.notification_id==null?null:String(t.notification_id),i=r?n.get(r):void 0;return{id:String(t.id),notification_id:r,receipt_id:i?.id??null,type:t.topic??`notification`,title:t.title??``,body:t.body_md??null,action_url:t.action_url??null,is_read:i?Hc.has(i.state):!1,created_at:t.created_at,actor_id:typeof t.actor_id==`string`?t.actor_id:null}})}function Wc(e){let t=new Set;for(let n of e){let e=n?.notification_id;if(e==null)continue;let r=String(e);r&&t.add(r)}return[...t]}function Gc(){let e=Pt(),{user:t}=u(),n=t?.id,r=Ic(e);return kc(Vc,r&&n?`${r}:${n}`:null,async({markUnavailable:t,markFailed:r})=>{if(e&&n)try{let t=await Promise.resolve(e.find(`sys_inbox_message`,{$filter:{user_id:n},$orderby:{created_at:`desc`},$top:20})),r=Array.isArray(t?.data)?t.data:[],i=Wc(r),a=i.length===0?{data:[]}:await Promise.resolve(e.find(`sys_notification_receipt`,{$filter:{user_id:n,channel:`inbox`,notification_id:{$in:i}},$top:i.length})).catch(()=>({data:[]}));return Uc(r,Array.isArray(a?.data)?a.data:[])}catch(e){Rc(e)?t():r();return}})}var Kc=Object.freeze([]),qc={key:null,seen:[]};function Jc(e,t,n=500){let r=new Set(t),i=[...e.filter(e=>!r.has(e)),...t];return i.length>n?i.slice(i.length-n):i}function Yc(e,t){let n=t.map(e=>e.id);if(e!==qc.key)return qc.key=e,qc.seen=Jc([],n),Kc;let r=new Set(qc.seen),i=t.filter(t=>!r.has(t.id)&&!t.is_read&&!Xc(t,e));return qc.seen=Jc(qc.seen,n),i.length>0?i:Kc}function Xc(e,t){return typeof e.actor_id==`string`&&e.actor_id===t}function Zc(e){return e.length===0?null:{target:e[0],count:e.length,groups:cc([...e])}}function Qc({notifications:e,status:n,markRead:r}){let{t:a}=rn(),{user:o}=u(),s=o?.id??null,c=t(),l=i(),{currentAppName:d}=ya(),{apps:f}=wt(),p=oc(),m=ja(f,d??l.appName),h=(0,J.useRef)({markRead:r,navigate:c,hostAppSegment:m,preferences:p,t:a});(0,J.useEffect)(()=>{h.current={markRead:r,navigate:c,hostAppSegment:m,preferences:p,t:a}});let g=(0,J.useCallback)(e=>{let{markRead:t,navigate:n,hostAppSegment:r}=h.current;t(e.id);let i=Ma(e.action_url,r);if(!i){n(`/apps/${r}/sys_inbox_message?view=mine`);return}if(i.kind===`external`){window.open(i.url,`_blank`,`noopener,noreferrer`);return}n(i.path)},[]);(0,J.useEffect)(()=>{if(n!==`ready`||!s)return;let t=Zc(Yc(s,e));if(!t)return;let{preferences:r,t:i}=h.current,a=t.groups.length===1,o=t.groups[0],c=a?o.title||o.type:i(`notifications.arrivalMany`,{count:t.count,defaultValue:`{{count}} new messages`}),l=a?o.items.length>1?i(`notifications.arrivalRepeats`,{count:o.items.length,defaultValue:`{{count}} new messages on this topic`}):(t.target.body??void 0)||void 0:t.target.title;if(typeof document<`u`&&document.visibilityState===`visible`){if(!r.preferences.toast)return;ks({id:`inbox-arrival-${t.target.id}`,title:c,...l?{message:l}:{},severity:`info`,createdAt:new Date,icon:`Bell`,actions:[{label:i(`notifications.arrivalOpen`,{defaultValue:`View`}),onClick:()=>g(t.target)}]});return}r.preferences.desktop&&r.desktopPermission===`granted`&&Ys({title:c,...l?{body:l}:{},tag:`objectui-inbox-${o.type||o.key}`,onActivate:()=>g(t.target)})},[e,n,s,g])}var $c=new Set;function el(){let{value:e,status:t}=Gc(),[n,r]=(0,J.useState)($c),i=(0,J.useMemo)(()=>n.size===0?e:e.map(e=>n.has(e.id)?{...e,is_read:!0}:e),[e,n]),a=Mc(),o=i.reduce((e,t)=>e+ +!t.is_read,0),s=(0,J.useCallback)(async(e,t)=>{let n=``.replace(/\/$/,``);await fetch(`${n}/api/v1/notifications/${e}`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,...Ca()},body:JSON.stringify(t?{ids:t}:{})})},[]),c=(0,J.useCallback)(e=>{e.length!==0&&r(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})},[]),l=(0,J.useCallback)(async e=>{let t=i.find(t=>t.id===e);if(c([e]),t?.notification_id)try{await s(`read`,[t.notification_id])}catch{}},[i,c,s]),u=(0,J.useCallback)(async()=>{if(i.filter(e=>!e.is_read).length){c(i.map(e=>e.id));try{await s(`read/all`)}catch{}}},[i,c,s]),d=(0,J.useCallback)(async e=>{let t=new Set(e),n=i.filter(e=>t.has(e.id)&&!e.is_read).map(e=>e.notification_id).filter(e=>!!e);if(c(e),n.length)try{await s(`read`,n)}catch{}},[i,c,s]);return Qc({notifications:i,status:t,markRead:l}),{notifications:i,status:t,unreadCount:o,pendingApprovalsCount:a,markAllRead:u,markRead:l,markManyRead:d}}function tl(){let{execute:e}=Wt(),{getItem:t}=wt();return(0,J.useCallback)(n=>{(async()=>{let r=n.actionDef,i=r?.actionName;if(!i){console.warn(`[nav] action item has no actionDef.actionName — nothing to dispatch`,n?.id),on.error(`This menu item is not configured to run an action.`);return}let a;try{a=await t(`action`,i)}catch(e){console.warn(`[nav] failed to resolve action '${i}'`,e),on.error(`Could not load action "${i}".`);return}if(!a){console.warn(`[nav] action '${i}' is not defined — nav item ${n?.id} cannot run`),on.error(`Action "${i}" is not defined.`);return}try{let{params:t,...n}=a,i={...n},o=Array.isArray(t)?t:[];o.length>0&&(i.actionParams=o),r?.params&&typeof r.params==`object`&&(i.params={...r.params}),await e(i)}catch(e){console.warn(`[nav] action '${i}' failed`,e),on.error(`Action "${i}" failed to run.`)}})()},[e,t])}function nl(e){let t={any:!1,books:!1},n=e=>{for(let r of e??[])r?.type===`doc`&&(t.any=!0,typeof r.book==`string`&&(t.books=!0)),r?.type===`group`&&n(r.children)};for(let t of e)n(t);return t}function rl(e){let t=new Set;for(let n of e){let e=n?.name;typeof e==`string`&&e&&t.add(e)}return t}function il(e){let t=new Set;for(let n of e){let e=n?._packageId;typeof e==`string`&&e&&t.add(e)}return t}function al(e){let{getItemsByType:t,getTypeStatus:n}=wt(),r=(0,J.useContext)(jt)===null?{any:!1,books:!1}:nl(e),i=e=>!n||n(e)===`ready`,a=r.any?t(`doc`):void 0,o=r.books?t(`book`):void 0,s=r.any&&i(`doc`),c=!r.books||i(`book`);return(0,J.useMemo)(()=>{if(!s||!c||!a)return;let e=rl(a),t=il(a),n=o?rl(o):new Set,r=e=>n.has(e)||t.has(e);return({book:t,doc:n})=>(t===void 0||r(t))&&(n===void 0||e.has(n))},[s,c,a,o])}N();function ol(e,t){let n=new Set(t.filter(e=>typeof e==`string`));for(let t=1;t<1e4;t++){let r=`${e}_${t}`;if(!n.has(r))return r}return`${e}_${Date.now()}`}function sl(e,t){if(!t)return!0;let n=t.toLowerCase();return e.value.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||(e.group?.toLowerCase().includes(n)??!1)}function cl({label:e,ariaLabel:t,id:n,value:r,onCommit:i,options:a,placeholder:o,searchPlaceholder:s,emptyText:c,disabled:l,loading:u,allowCustom:d=!0,mono:f,className:p}){let[m,h]=J.useState(!1),[g,_]=J.useState(``),v=$o(),y=o??G(`engine.form.selectEllipsis`,v),b=s??G(`engine.inspector.combo.search`,v),x=c??G(`engine.inspector.combo.noMatch`,v),S=J.useId(),C=e?S:n,w=a.find(e=>e.value===r),T=w?w.label:r||(u?G(`engine.inspector.combo.loading`,v):y),E=J.useMemo(()=>a.filter(e=>sl(e,g)),[a,g]),D=J.useMemo(()=>{let e=[],t=new Map;for(let n of E){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[E]),O=g.trim(),k=d&&!!O&&!a.some(e=>e.value===O),[A,j=``]=G(`engine.inspector.combo.useCustom`,v).split(`{value}`),M=e=>{i(e),h(!1),_(``)},N=(0,Y.jsxs)(Me,{open:m,onOpenChange:e=>{h(e),e||_(``)},children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.jsxs)(B,{type:`button`,variant:`outline`,role:`combobox`,id:C,"aria-label":t,"aria-expanded":m,disabled:l,className:R(`h-8 w-full justify-between px-2 text-sm font-normal`,p),children:[(0,Y.jsx)(`span`,{className:R(`truncate`,f&&`font-mono`,!w&&!r&&`text-muted-foreground`),children:T}),(0,Y.jsx)(Ln,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,Y.jsx)(mt,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,Y.jsxs)(_e,{shouldFilter:!1,children:[(0,Y.jsx)(ve,{value:g,onValueChange:_,placeholder:b}),(0,Y.jsxs)(dt,{children:[!k&&E.length===0&&(0,Y.jsx)(Xe,{children:x}),k&&(0,Y.jsx)(xe,{children:(0,Y.jsx)(Ve,{value:`__custom__${O}`,onSelect:()=>M(O),children:(0,Y.jsxs)(`span`,{className:`truncate`,children:[A,(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`“`,O,`”`]}),j]})})}),D.map((e,t)=>(0,Y.jsx)(xe,{heading:e.heading||void 0,children:e.items.map(e=>(0,Y.jsxs)(Ve,{value:e.value,onSelect:()=>M(e.value),children:[(0,Y.jsx)(Mn,{className:R(`h-3.5 w-3.5`,e.value===r?`opacity-100`:`opacity-0`)}),(0,Y.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,Y.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,Y.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${t}`))]})]})})]});return e?(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{htmlFor:S,className:`text-xs text-muted-foreground`,children:e}),N]}):N}var ll=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function ul(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function dl(e){let t=e.reference;return typeof t==`string`&&t?t:void 0}function fl(e){switch(e){case`lookup`:case`master_detail`:case`masterDetail`:case`master-detail`:return`lookup`;case`date`:case`datetime`:case`time`:return`date`;case`number`:case`currency`:case`percent`:case`int`:case`integer`:case`float`:case`double`:case`autonumber`:return`number`;case`boolean`:case`toggle`:return`boolean`;default:return`string`}}function pl(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=ul(e.label,t),r=vo(e.fields).entries.map(e=>({name:e.name,label:ul(e.def.label,e.name),type:typeof e.def.type==`string`?e.def.type:void 0,def:e.def}));return{label:n,fields:r,relationships:r.filter(e=>e.type&&ll.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:dl(e.def)}))}}function ml(e,t,n){let r=e,i=[];for(let e of t.split(`.`)){let t=r.relationships.find(t=>t.name===e);if(!t?.referenceTo)return;let a=n[t.referenceTo];if(!a)return;i.push(t.label),r=a}return{target:r,labels:i}}function hl(e,t,n){let r=e.fields.map(t=>({value:t.name,label:t.label,type:t.type,group:e.label}));for(let i of t){let t=ml(e,i,n);if(!t)continue;let a=[...t.labels,t.target.label].join(` → `);for(let e of t.target.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:a})}return r}function gl(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>gl(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t||Object.values(n).some(e=>e&&typeof e==`object`&&gl(e,t))}function _l(){let e=sa(),[t,n]=J.useState({options:[],loading:!0});return J.useEffect(()=>{let t=!1;return n(e=>({...e,loading:!0})),e.list(`object`).then(e=>{if(t)return;let r=(Array.isArray(e)?e:[]).map(e=>({name:typeof e.name==`string`?e.name:``,label:ul(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label));n({options:r,loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function vl(e,t){let n=sa(),r=JSON.stringify(t),[i,a]=J.useState({relationships:[],fieldOptions:[],loading:!!e});return J.useEffect(()=>{if(!e){a({relationships:[],fieldOptions:[],loading:!1});return}let t=!1;return a(e=>({...e,loading:!0})),(async()=>{try{let i=await n.get(`object`,e);if(t)return;let o=pl(i,e),s=JSON.parse(r),c={[e]:o},l=async e=>{if(c[e])return c[e];let t;try{t=pl(await n.get(`object`,e),e)}catch{t=pl(null,e)}return c[e]=t,t};for(let e of s){let t=o;for(let n of e.split(`.`)){let e=t.relationships.find(e=>e.name===n);if(!e?.referenceTo)break;t=await l(e.referenceTo)}}if(t)return;let u=[...o.relationships];for(let e of s){if(e.split(`.`).length>=3)continue;let t=ml(o,e,c);if(t)for(let n of t.target.relationships)u.push({name:`${e}.${n.name}`,label:`${e}.${n.name}`,referenceTo:n.referenceTo})}a({relationships:u,fieldOptions:hl(o,s,c),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function yl(e){let t=sa(),[n,r]=J.useState({reports:0,dashboards:0,loading:!!e});return J.useEffect(()=>{if(!e){r({reports:0,dashboards:0,loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),(async()=>{let[i,a]=await Promise.all([t.list(`report`).catch(()=>[]),t.list(`dashboard`).catch(()=>[])]);n||r({reports:(Array.isArray(i)?i:[]).filter(t=>gl(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>gl(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}function bl(e,t,n=e=>`col ${e}`){if(typeof e==`string`)return e||n(t+1);if(e&&typeof e==`object`){let r=e;return String(r.label??r.field??n(t+1))}return n(t+1)}function xl(e){if(typeof e==`string`)return e||void 0;if(e&&typeof e==`object`){let t=e.field;return typeof t==`string`&&t?t:void 0}}function Sl(e){let t=new Set;for(let n of e){let e=xl(n);e&&t.add(e)}return t}function Cl(e,t,n){if(e)return t;let r={field:t};return n&&n!==t&&(r.label=n),r}function wl(e,t){return e===t?null:e>t?e-1:e}function Tl(e,t,n){if(e===t)return n;let r=e;return t<r&&--r,n<=r&&(r+=1),r}function El(e,t,n){return bl(e,t,e=>W(`engine.fieldsListEditor.colN`,n,{n:e}))}function Dl({variantKey:e,schema:t,columns:n,allStrings:r,objectName:i,objectFieldsOverride:a,selectedIndex:o,readOnly:s,onPatch:c,onSelectionChange:l}){let u=!s,d=$o(),{fields:f,loading:p,error:m}=co(i||void 0,a),h=J.useMemo(()=>{let e=new Map;for(let t of f)e.set(t.name,t.type);return e},[f]),[g,_]=J.useState(null),[v,y]=J.useState(null),b=J.useCallback(n=>{c({[e]:{...t,columns:n}})},[c,e,t]),x=J.useCallback(t=>{let i=Cl(r,t.name,t.label),a=os(n,i);b(a),l?.({kind:`column`,id:`${e}.columns[${a.length-1}]`,label:t.label})},[r,n,b,e,l]),S=J.useCallback(t=>{let r=xs(n,t,null);if(b(r),o!=null){let n=wl(o,t);n==null?l?.(null):l?.({kind:`column`,id:`${e}.columns[${n}]`,label:El(r[n],n,d)})}},[n,b,o,e,l,d]),C=J.useCallback((t,r)=>{if(t===r)return;let i=rs(n,t,r);if(b(i),o!=null){let n=Tl(o,t,r);l?.({kind:`column`,id:`${e}.columns[${n}]`,label:El(i[n],n,d)})}},[n,b,o,e,l,d]),w=J.useCallback(t=>{l?.({kind:`column`,id:`${e}.columns[${t}]`,label:El(n[t],t,d)})},[n,e,l,d]),T=Sl(n);return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:G(`engine.fieldsListEditor.columns`,d)}),(0,Y.jsx)(V,{variant:`outline`,className:`text-[10px]`,children:n.length})]}),n.length===0?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:G(`engine.fieldsListEditor.empty`,d)}):(0,Y.jsx)(`div`,{className:`space-y-1`,children:n.map((e,t)=>(0,Y.jsx)(vs,{index:t,label:El(e,t,d),fieldName:xl(e),fieldType:h.get(xl(e)??``)??`text`,selected:o===t,canEdit:u,dragging:g!==null,dropBefore:v===t&&g!==null&&g!==t,onSelect:()=>w(t),onRemove:()=>S(t),onDragStart:()=>_(t),onDragEnd:()=>{_(null),y(null)},onDragOverRow:()=>y(t),onDropRow:()=>{g!=null&&g!==t&&C(g,t),_(null),y(null)}},t))}),u&&(0,Y.jsx)(hs,{fields:f,usedNames:T,loading:p,error:m,onAdd:x})]})}var Ol=[`record`,`current_user`,`user`,`features`,`os`,`ctx`];function kl(e){if(e==null)return`null`;let t=typeof e;return t===`string`?JSON.stringify(e):t===`number`||t===`boolean`?String(e):Array.isArray(e)?`[${e.map(kl).join(`, `)}]`:JSON.stringify(String(e))}function Al(e){if(!e.field||!e.operator)return``;let t=`record[${JSON.stringify(e.field)}]`;switch(e.operator){case`equals`:return`${t} == ${kl(e.value)}`;case`not_equals`:return`${t} != ${kl(e.value)}`;case`greater_than`:return`${t} > ${kl(e.value)}`;case`less_than`:return`${t} < ${kl(e.value)}`;case`contains`:return`${t}.contains(${kl(e.value)})`;case`in`:return`${t} in ${kl(Array.isArray(e.value)?e.value:[e.value])}`;default:return``}}function jl(e){return typeof e.condition==`string`?e.condition:e.condition&&typeof e.condition==`object`&&typeof e.condition.source==`string`?e.condition.source:typeof e.expression==`string`?e.expression:Al(e)}function Ml(e){let t=jl(e),n={};if(e.style&&typeof e.style==`object`)for(let[t,r]of Object.entries(e.style))r!=null&&(n[t]=String(r));return e.backgroundColor&&(n.backgroundColor=String(e.backgroundColor)),e.textColor&&(n.color=String(e.textColor)),e.borderColor&&(n.borderColor=String(e.borderColor)),{condition:t,style:n}}function Nl({label:e,value:t,onChange:n,disabled:r}){return(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`input`,{type:`color`,value:/^#([0-9a-f]{6})$/i.test(t)?t:`#000000`,disabled:r,onChange:e=>n(e.target.value),className:`h-7 w-8 shrink-0 rounded border border-input bg-background p-0.5 disabled:opacity-60`,"aria-label":e}),(0,Y.jsx)(z,{value:t,placeholder:`#RRGGBB`,disabled:r,onChange:e=>n(e.target.value),className:`h-7 text-xs font-mono`})]})]})}function Pl({rules:e,onChange:t,objectName:n,fieldNames:r,disabled:i,t:a,onBlockingIssuesChange:o}){let s=J.useMemo(()=>Array.isArray(e)?e.map(Ml):[],[e]),[c,l]=J.useState({}),u=J.useCallback((e,t)=>{let n=t.filter(e=>e.severity===`error`).length;l(t=>t[e]===n?t:{...t,[e]:n})},[]),d=s.length,f=J.useMemo(()=>{let e=0;for(let[t,n]of Object.entries(c))Number(t)>=d||(e+=n);return e},[c,d]),p=J.useRef(o);J.useEffect(()=>{p.current=o}),J.useEffect(()=>{p.current?.(f)},[f]);let m=e=>t(e),h=(e,t)=>{let n=s.map((n,r)=>r===e?{...n,...t}:n);m(n)},g=(e,t,n)=>{let r={...s[e].style};n?r[t]=n:delete r[t],h(e,{style:r})},_=()=>m([...s,{condition:``,style:{}}]),v=e=>m(s.filter((t,n)=>n!==e)),y=(e,t)=>{let n=e+t;if(n<0||n>=s.length)return;let r=s.slice();[r[e],r[n]]=[r[n],r[e]],m(r)};return(0,Y.jsxs)(`div`,{className:`space-y-2`,"data-testid":`cf-editor`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:a(`engine.inspector.view.cf.title`)}),(0,Y.jsxs)(B,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 px-2 text-xs`,disabled:i,onClick:_,"data-testid":`cf-add`,children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),a(`engine.inspector.view.cf.add`)]})]}),s.length===0&&(0,Y.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground`,children:a(`engine.inspector.view.cf.empty`)}),s.map((e,t)=>(0,Y.jsxs)(`div`,{className:`rounded-md border border-border p-2 space-y-2`,"data-testid":`cf-rule-${t}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[a(`engine.inspector.view.cf.rule`),` `,t+1]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Y.jsx)(B,{type:`button`,size:`icon`,variant:`ghost`,className:`h-6 w-6`,disabled:i||t===0,onClick:()=>y(t,-1),"aria-label":a(`engine.inspector.view.cf.moveUp`),"data-testid":`cf-up-${t}`,children:(0,Y.jsx)(Fn,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(B,{type:`button`,size:`icon`,variant:`ghost`,className:`h-6 w-6`,disabled:i||t===s.length-1,onClick:()=>y(t,1),"aria-label":a(`engine.inspector.view.cf.moveDown`),"data-testid":`cf-down-${t}`,children:(0,Y.jsx)(Nn,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(B,{type:`button`,size:`icon`,variant:`ghost`,className:`h-6 w-6 text-destructive hover:text-destructive`,disabled:i,onClick:()=>v(t),"aria-label":a(`engine.inspector.view.cf.remove`),"data-testid":`cf-remove-${t}`,children:(0,Y.jsx)(Ki,{className:`h-3.5 w-3.5`})})]})]}),(0,Y.jsx)(Yo,{label:a(`engine.inspector.view.cf.when`),value:e.condition,disabled:i,placeholder:`record.status == 'overdue'`,objectName:n,fieldNames:r,scope:`record`,roots:Ol,onChange:e=>h(t,{condition:e}),onLintChange:e=>u(t,e),t:a,id:`cf-condition-${t}`}),(0,Y.jsxs)(`div`,{className:R(`grid gap-2 sm:grid-cols-3`),children:[(0,Y.jsx)(Nl,{label:a(`engine.inspector.view.cf.background`),value:e.style.backgroundColor??``,disabled:i,onChange:e=>g(t,`backgroundColor`,e)}),(0,Y.jsx)(Nl,{label:a(`engine.inspector.view.cf.text`),value:e.style.color??``,disabled:i,onChange:e=>g(t,`color`,e)}),(0,Y.jsx)(Nl,{label:a(`engine.inspector.view.cf.border`),value:e.style.borderColor??``,disabled:i,onChange:e=>g(t,`borderColor`,e)})]}),(0,Y.jsx)(`div`,{className:`rounded border border-dashed border-border px-2 py-1 text-xs`,style:e.style,"data-testid":`cf-preview-${t}`,children:a(`engine.inspector.view.cf.preview`)})]},t))]})}var Fl={io:`input`,unrepresentable:`any`},Il=new Set([`columns`,`data`,`name`]),Ll,Rl=!1;function zl(){if(Ll||Rl)return Ll;try{Ll=y(g,Fl)}catch(e){Rl=!0,typeof console<`u`&&console.warn(`[view-schema] failed to derive View JSONSchema from spec`,e)}return Ll}function Bl(){return zl()?.properties?.list}function Vl(){return zl()?.properties?.form}var Hl,Ul=!1;function Wl(){if(Hl||Ul)return Hl;try{Hl=y(fe,Fl)}catch(e){Ul=!0,typeof console<`u`&&console.warn(`[view-schema] failed to derive ListColumn JSONSchema from spec`,e)}return Hl}var Gl;function Kl(){if(Gl)return Gl;if(re&&typeof re==`object`){try{let e=JSON.parse(JSON.stringify(re));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!Il.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Gl=e}catch(e){typeof console<`u`&&console.warn(`[view-schema] failed to prepare viewForm from spec`,e);return}return Gl}}var ql=new Set([`form`,`detail`]);function Jl(e){return ql.has(e)}function Yl(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Xl(e,t){return typeof e==`string`&&ql.has(e)?e:typeof e==`string`&&e?`list`:typeof t==`string`&&ql.has(t)?`form`:`list`}function Zl(e){let t=e.config;return Yl(t)?[{storeKey:`config`,familyKey:Xl(e.viewKind,t.type),schema:t}]:[]}function Ql(e){return Zl(e)[0]}function $l(e,t){return Ql(e)}var eu=new Set([`current_user`,`user`,`ctx`,`os`,`features`,`app`,`page`]);function tu(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function nu(e){let t=e.visibleWhen,n;if(typeof t==`string`)n=t;else if(tu(t)){if(t.dialect!==void 0&&t.dialect!==`cel`)return null;n=t.source}return typeof n==`string`&&n.trim()||null}function ru(e){let t=e.fields;if(!Array.isArray(t))return[];let n=[];for(let e of t)typeof e==`string`&&e?n.push(e):tu(e)&&typeof e.field==`string`&&e.field&&n.push(e.field);return n}function iu(e){if(!e)return[];let t=e.sections===void 0?e.groups:e.sections;if(!Array.isArray(t))return[];let n=[];return t.forEach((e,t)=>{if(!tu(e))return;let r=typeof e.label==`string`&&e.label?e.label:``,i=typeof e.name==`string`&&e.name?e.name:``;n.push({index:t,title:r||i||`#${t+1}`,predicate:nu(e),members:ru(e)})}),n}function au(e){let t=new Map;for(let n of e)n.required===!0&&t.set(n.name,n.label||n.name);return t}function ou(e,t){let n=au(t),r=new Set;for(let t of e)t.predicate&&t.members.some(e=>n.has(e))&&r.add(t.predicate);return[...r]}function su(e,t,n){let r=au(t),i=[];for(let t of e){if(!t.predicate)continue;let e=t.members.filter(e=>r.has(e));if(e.length===0)continue;let a=n(t.predicate);if(!a)continue;let o=[...new Set(a.filter(e=>eu.has(e)))];if(o.length!==0)for(let n of new Set(e))i.push({sectionIndex:t.index,section:t.title,predicate:t.predicate,roots:o,field:n,fieldLabel:r.get(n)??n})}return i}var cu=null;function lu(){return cu||=n(async()=>{let{collectCelRootIdentifiers:e}=await import(`./vendor-objectstack-C4eD5dbT.js`).then(e=>e.ft);return{collectCelRootIdentifiers:e}},[],import.meta.url).then(({collectCelRootIdentifiers:e})=>typeof e==`function`?e:null).catch(()=>null),cu}function uu(e,t){if(!e)return null;try{let n=e(t);return n.ok?n.roots:null}catch{return null}}function du(e,t){let n=iu(e),r=JSON.stringify(ou(n,t)),[i,a]=J.useState({key:`[]`,roots:{}});return J.useEffect(()=>{let e=JSON.parse(r);if(e.length===0)return;let t=!1;return lu().then(n=>{if(t)return;let i={};for(let t of e)i[t]=uu(n,t);a({key:r,roots:i})}),()=>{t=!0}},[r]),i.key===r?su(n,t,e=>Object.prototype.hasOwnProperty.call(i.roots,e)?i.roots[e]:null):[]}function fu({label:e,value:t,onCommit:n,placeholder:r,searchPlaceholder:i,disabled:a}){let{options:o,loading:s}=_l();return(0,Y.jsx)(cl,{label:e,value:t,onCommit:n,options:o.map(e=>({value:e.name,label:e.label})),loading:s,placeholder:r,searchPlaceholder:i,disabled:a,mono:!0})}var pu=new Set([`type`,`object`,`label`,`columns`,`conditionalFormatting`]),mu={grid:`Table / List`,kanban:`Kanban`,calendar:`Calendar`,gallery:`Gallery`,gantt:`Gantt`,timeline:`Timeline`,map:`Map`,chart:`Chart`};function hu(e,t){let n=`engine.inspector.view.type.${e}`,r=G(n,t);return r===n?mu[e]??e:r}var gu=[`columns`,`data`,`name`];function _u(e,t){let n=e.data;return n&&typeof n==`object`&&typeof n.object==`string`&&n.object?{value:n.object,path:`data.object`}:typeof e.object==`string`&&e.object?{value:e.object,path:`object`}:typeof t.object==`string`&&t.object?{value:t.object,path:`top`}:{value:``,path:`top`}}function vu(e){return J.useMemo(()=>{let t=Bl()?.properties?.type?.enum;return(Array.isArray(t)&&t.length?t.filter(e=>typeof e==`string`):[`grid`,`kanban`,`calendar`,`gallery`,`gantt`,`timeline`]).map(t=>({value:t,label:hu(t,e)}))},[e])}function yu({draft:e,variantKey:t,familyKey:n,isHome:r,onPatch:i,readOnly:a,onClearSelection:o,onSelectionChange:s,onBlockingIssuesChange:c,objectFieldsOverride:l,locale:u,serverSchema:d}){let f=e[t]??{},p=Jl(n??t),m=typeof f.type==`string`?f.type:`grid`,h=vu(u),g=_u(f,e),_=typeof e.label==`string`&&e.label||(typeof f.label==`string`?f.label:``)||``,v=Array.isArray(f.columns)?f.columns:[],y=v.length>0&&v.every(e=>typeof e==`string`),{fields:b,loading:x,error:S}=co(g.value||void 0,l),C=J.useCallback(e=>G(e,u),[u]),w=J.useMemo(()=>b.map(e=>e.name),[b]),T=Array.isArray(f.conditionalFormatting)?f.conditionalFormatting:[],[E,D]=J.useState({variant:t,count:0}),O=J.useCallback(e=>{D(n=>n.variant===t&&n.count===e?n:{variant:t,count:e})},[t]),k=E.variant===t&&!p?E.count:0,A=du(p?f:void 0,b),j=k+(p?A.length:0),M=J.useRef(c);J.useEffect(()=>{M.current=c}),J.useEffect(()=>{M.current?.(j)},[j]);let N=J.useMemo(()=>{let e;return e=S?Wo(S):x?{status:`loading`}:Mo(b.map(e=>({name:e.name,label:e.label,type:e.type}))),{conditionScope:`none`,objectFields:e}},[b,x,S]),P=(()=>{let e=d?.properties;return p?e?.form:e?.list})(),{schema:ee,form:F}=J.useMemo(()=>as({bundledSchema:p?Vl():Bl(),bundledForm:p?void 0:Kl(),serverSchema:P,excludeFields:pu,sectionTitle:G(`engine.inspector.moreFields`,u)}),[p,P,u]),te=e=>{i({[t]:{...f,...e}})};return(0,Y.jsxs)(is,{kindLabel:G(`engine.inspector.view.kind`,u),title:String(_||e.name||t),onClose:()=>o?.(),closeLabel:G(`engine.inspector.view.close`,u),hideClose:r,children:[(0,Y.jsx)(q,{label:G(`engine.inspector.view.label`,u),value:_,onCommit:e=>{i({label:e,[t]:{...f,label:e}})},placeholder:G(`engine.inspector.view.labelPlaceholder`,u),disabled:a}),(0,Y.jsx)(K,{label:G(`engine.inspector.view.type`,u),value:m,options:h,unknownValueLabel:e=>Ss(hu(e,u),G(`engine.form.notFound`,u),u),onCommit:e=>te({type:e}),disabled:a}),(0,Y.jsx)(fu,{label:G(`engine.inspector.view.object`,u),value:g.value,onCommit:e=>{let n={object:e};f.data&&typeof f.data==`object`?n[t]={...f,data:{...f.data,object:e}}:g.path===`object`&&(n[t]={...f,object:e}),i(n)},placeholder:G(`engine.inspector.view.objectPlaceholder`,u),searchPlaceholder:G(`engine.inspector.dataset.searchObjects`,u),disabled:a}),p&&A.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-2 rounded-md border border-destructive/50 bg-destructive/5 p-2 text-[11px] leading-snug text-destructive`,role:`alert`,"data-testid":`view-gated-required-issues`,children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:G(`engine.inspector.view.gatedRequired.title`,u)}),A.map(e=>{let t={field:e.field,fieldLabel:e.fieldLabel,object:g.value,section:e.section,predicate:e.predicate};return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`p`,{children:W(`engine.inspector.view.gatedRequired.issue`,u,t)}),(0,Y.jsx)(`p`,{children:G(`engine.inspector.view.gatedRequired.remedies`,u)}),(0,Y.jsxs)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:[(0,Y.jsx)(`li`,{children:W(`engine.inspector.view.gatedRequired.remedyMove`,u,t)}),(0,Y.jsx)(`li`,{children:W(`engine.inspector.view.gatedRequired.remedyDrop`,u,t)}),(0,Y.jsx)(`li`,{children:W(`engine.inspector.view.gatedRequired.remedyUnrequire`,u,t)})]})]},`${e.sectionIndex}:${e.field}`)})]}),!p&&(0,Y.jsx)(`div`,{className:`border-t pt-3`,children:(0,Y.jsx)(Dl,{variantKey:t,schema:f,columns:v,allStrings:y,objectName:g.value||void 0,objectFieldsOverride:l,selectedIndex:null,readOnly:a,onPatch:i,onSelectionChange:s})}),!p&&(0,Y.jsx)(`div`,{className:`border-t pt-3`,children:(0,Y.jsx)(Pl,{rules:T,objectName:g.value||void 0,fieldNames:w,disabled:a,t:C,onChange:e=>te({conditionalFormatting:e.length>0?e:void 0}),onBlockingIssuesChange:O})}),(0,Y.jsx)(`div`,{className:`border-t pt-3`,children:ee?(0,Y.jsx)(Bo,{schema:ee,form:F,value:f,hiddenFields:[`type`,`object`,`label`],readOnly:a,widgetContext:N,onChange:e=>{let n={...e};for(let e of gu)e in f?n[e]=f[e]:delete n[e];i({[t]:n})}}):(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:G(`engine.inspector.view.noSchema`,u)})})]})}function bu(){try{let e=new URLSearchParams(window.location.search).get(Za);return e&&e!==``?e:null}catch{return null}}function xu(e,t){let n=(0,J.useRef)(!1),r=e!==null&&!n.current&&t(e);return(0,J.useEffect)(()=>{if(r){n.current=!0;try{let e=new URL(window.location.href);e.searchParams.delete(Za),window.history.replaceState(window.history.state,``,e)}catch{}}},[r]),r?e:null}function Su(e){let[t]=(0,J.useState)(bu);return xu(t,e)}function Cu(e,t,n){let[r]=(0,J.useState)(bu),i=n&&r!==null?e.find(e=>e?.name===r&&t(e)):void 0,a=Ot(void 0),o=Dt(Ht(i?.visible),a,{throwOnError:!0,label:`action "${i?.name??i?.label??`action:button`}" (visible)`}),s=i!==void 0&&Vt(i.visible)&&!o,{t:c}=rn(),l=(0,J.useRef)(!1);return(0,J.useEffect)(()=>{s&&i&&!l.current&&(l.current=!0,on.warning(c(`actions.notAvailableHere`,{defaultValue:`"{{action}}" is not available on the current page.`,action:i.label||i.name||``}),{id:`auto-trigger-refused:${i.name??i.label??``}`}))},[s,i,c]),xu(r,()=>i!==void 0&&!s)}function wu(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}${Za}=${encodeURIComponent(t)}`:e}var Tu=new Set([`archived`,`failed`]);function Eu(e){let t=String(e?.environment_type??``).trim().toLowerCase();return t===`production`||t===`prod`?`production`:t?`development`:e?.is_default===!0||e?.is_default===1?`production`:`development`}function Du(e){let{enabled:t,dataSource:n,authFetch:r,apiBase:i,refreshKey:a}=e,{activeOrganization:o}=u(),s=o?.id,[c,l]=(0,J.useState)(null);return(0,J.useEffect)(()=>{if(!t){l(null);return}let e=!1,a=async()=>{try{let e=(i||``).replace(/\/+$/,``),t=s?`?organizationId=${encodeURIComponent(s)}`:``,n=await r(`${e}/api/v1/cloud/environment-entitlements${t}`,{method:`GET`,credentials:`include`});if(!n.ok)return null;let a=(await n.json().catch(()=>null))?.data;return!a||typeof a!=`object`?null:{ready:!0,hasProductionEnv:a.hasProductionEnv===!0,canCreateDevelopmentEnv:a.development?.canCreate,plan:a.plan,upgradeUrl:a.upgradeUrl,contactSalesUrl:a.contactSalesUrl,source:`summary`}}catch{return null}},o=async()=>{try{let e={$top:200};s&&(e.$filter={organization_id:s});let t=await n.find(`sys_environment`,e);return{ready:!0,hasProductionEnv:(Array.isArray(t)?t:t?.data??[]).filter(e=>!Tu.has(String(e?.status??``))).some(e=>Eu(e)===`production`),canCreateDevelopmentEnv:void 0,source:`derived`}}catch{return{ready:!1,hasProductionEnv:!1,canCreateDevelopmentEnv:void 0,source:`unknown`}}};return(async()=>{let t=await a()??await o();e||l(t)})(),()=>{e=!0}},[t,s,i,r,n,a]),c}var Ou=19,ku=[`from-blue-500 to-indigo-600`,`from-violet-500 to-purple-600`,`from-pink-500 to-rose-600`,`from-amber-400 to-orange-500`,`from-emerald-500 to-teal-600`,`from-sky-500 to-cyan-600`,`from-fuchsia-500 to-pink-600`,`from-orange-500 to-red-600`,`from-indigo-500 to-blue-600`,`from-teal-500 to-green-600`],Au=`shadow-[0_4px_10px_-2px_rgb(0_0_0/0.25),inset_0_1px_0_0_rgb(255_255_255/0.45)]`;function ju(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function Mu({apps:e,favorites:t,onOpen:n,onBrowseMarketplace:r,isAdmin:i,canAuthorMetadata:a=!0,marketplaceEnabled:o=!0}){let{t:s}=rn(),{appLabel:c}=Zt(),[l,u]=(0,J.useState)(!1),d=(0,J.useMemo)(()=>new Set(t.filter(e=>e.id.startsWith(`app:`)).map(e=>e.id.slice(4))),[t]),f=(0,J.useMemo)(()=>[...e].sort((e,t)=>+!!d.has(t.name)-!!d.has(e.name)),[e,d]),p=f.length-Ou,m=l?f:f.slice(0,Ou);return(0,Y.jsxs)(`section`,{className:`mb-6`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-xl border border-border bg-muted text-muted-foreground`,children:(0,Y.jsx)(Vr,{className:`h-4 w-4`})}),(0,Y.jsx)(`h2`,{className:`text-base font-semibold tracking-tight`,children:s(`home.yourApps`,{defaultValue:`Your apps`})}),(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:f.length}),i&&a&&o&&(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,className:`ml-auto h-8 text-muted-foreground`,onClick:r,"data-testid":`browse-marketplace-btn`,children:[(0,Y.jsx)(Bi,{className:`mr-1.5 h-4 w-4`}),s(`home.browseMarketplace`,{defaultValue:`Browse App Marketplace`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-4 gap-1 sm:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10`,children:[m.map(e=>{let t=eo(e.icon),r=c({name:e.name,label:Ia(e.label,s)}),i=d.has(e.name),a=ku[ju(e.name)%ku.length];return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`group relative flex flex-col items-center gap-2 rounded-xl p-2.5 text-center transition hover:bg-muted/40 active:scale-[0.96]`,"data-testid":`app-tile-${e.name}`,children:[(0,Y.jsxs)(`span`,{className:R(`relative inline-flex h-12 w-12 items-center justify-center rounded-[13px]`,`bg-gradient-to-br text-white transition-transform group-hover:scale-105`,Au,a),children:[(0,Y.jsx)(t,{className:`h-6 w-6`}),i&&(0,Y.jsx)(`span`,{className:`absolute -right-1 -top-1 inline-flex h-4 w-4 items-center justify-center rounded-full bg-amber-400 ring-2 ring-background`,children:(0,Y.jsx)(Ri,{className:`h-2.5 w-2.5 fill-white text-white`})})]}),(0,Y.jsx)(`span`,{className:`w-full truncate text-xs font-medium`,children:r})]},e.name)}),!l&&p>0&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`group flex flex-col items-center gap-2 rounded-xl p-2.5 text-center transition hover:bg-muted/40 active:scale-[0.96]`,"data-testid":`apps-show-all`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex h-12 w-12 items-center justify-center rounded-[13px] border border-dashed border-border text-sm font-medium text-muted-foreground transition-colors group-hover:border-foreground/30 group-hover:text-foreground`,children:[`+`,p]}),(0,Y.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:s(`home.showMoreApps`,{defaultValue:`More`})})]})]}),l&&p>0&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(!1),className:`mt-2.5 text-xs text-primary hover:underline`,children:s(`home.showLess`,{defaultValue:`Show less`})})]})}function Nu(e){let t=e.slice(0,20);if(t.length===0)return`{
3
+ "id": "record-1"
4
+ }`;let n={};for(let e of t)n[e]=null;return JSON.stringify(n,null,2)}var Pu=JSON.stringify({id:`user-1`,organization_id:`org-1`,positions:[`admin`]},null,2),Fu=[];function Iu({open:e,onOpenChange:t,policyName:n,objectName:r,fieldNames:i=Fu,using:a,check:o,t:s}){let c=J.useMemo(()=>{let e=[];return a&&a.trim()&&e.push(`using`),o&&o.trim()&&e.push(`check`),e},[a,o]),[l,u]=J.useState(`using`),[d,f]=J.useState(`{}`),[p,m]=J.useState(Pu),[h,g]=J.useState(null),[_,v]=J.useState(null),[y,b]=J.useState(!1);J.useEffect(()=>{e&&(u(c[0]??`using`),f(Nu(i)),m(Pu),g(null),v(null))},[e]);let x=l===`using`?a??``:o??``;async function S(){g(null),v(null);let e=Lu(d,s(`perm.cel.test.record`),s);if(!e.ok)return v(e.error);let t=Lu(p,s(`perm.cel.test.user`),s);if(!t.ok)return v(t.error);b(!0);try{g(await Co(x,{record:e.value,currentUser:t.value}))}finally{b(!1)}}return(0,Y.jsx)(lt,{open:e,onOpenChange:t,children:(0,Y.jsxs)(Re,{className:`sm:max-w-2xl`,children:[(0,Y.jsxs)(Te,{children:[(0,Y.jsxs)(ke,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(vr,{className:`h-4 w-4 text-muted-foreground`}),s(`perm.cel.test.title`),n?(0,Y.jsxs)(`span`,{className:`text-muted-foreground font-normal`,children:[`· `,n]}):null]}),(0,Y.jsx)(Be,{children:s(`perm.cel.test.help`)})]}),c.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground italic py-4`,children:s(`perm.cel.test.noPredicate`)}):(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[c.length>1&&(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,role:`tablist`,"aria-label":s(`perm.cel.test.clause`),children:c.map(e=>(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":l===e,onClick:()=>{u(e),g(null)},className:R(`rounded-md border px-3 py-1 text-xs transition-colors`,l===e?`border-primary bg-primary text-primary-foreground`:`border-input bg-background hover:bg-accent`),children:s(e===`using`?`perm.rls.using`:`perm.rls.check`)},e))}),(0,Y.jsxs)(`div`,{className:`rounded-md border bg-muted/40 px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:[s(l===`using`?`perm.rls.using`:`perm.rls.check`),r?` · ${r}`:``]}),(0,Y.jsx)(`code`,{className:`block whitespace-pre-wrap break-words font-mono text-xs`,children:x})]}),(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-[10px] uppercase text-muted-foreground`,htmlFor:`cel-test-record`,children:s(`perm.cel.test.record`)}),(0,Y.jsx)(tt,{id:`cel-test-record`,value:d,onChange:e=>f(e.target.value),rows:8,spellCheck:!1,className:`font-mono text-xs`})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(L,{className:`text-[10px] uppercase text-muted-foreground`,htmlFor:`cel-test-user`,children:[s(`perm.cel.test.user`),` `,(0,Y.jsx)(`span`,{className:`font-mono normal-case`,children:`current_user`})]}),(0,Y.jsx)(tt,{id:`cel-test-user`,value:p,onChange:e=>m(e.target.value),rows:8,spellCheck:!1,className:`font-mono text-xs`})]})]}),_&&(0,Y.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs text-destructive`,children:[(0,Y.jsx)(Rn,{className:`mt-[1px] h-3.5 w-3.5 shrink-0`}),_]}),h&&(0,Y.jsx)(Ru,{outcome:h,t:s})]}),(0,Y.jsxs)(Ue,{children:[(0,Y.jsx)(B,{variant:`ghost`,onClick:()=>t(!1),children:s(`engine.cancel`)}),(0,Y.jsxs)(B,{onClick:S,disabled:y||c.length===0,children:[(0,Y.jsx)(vr,{className:`h-4 w-4 mr-1`}),s(`perm.cel.test.run`)]})]})]})})}function Lu(e,t,n){let r;try{r=JSON.parse(e||`{}`)}catch(e){return{ok:!1,error:`${t}: ${e.message}`}}return!r||typeof r!=`object`||Array.isArray(r)?{ok:!1,error:`${t}: ${n(`engine.celTest.notObject`)}`}:{ok:!0,value:r}}function Ru({outcome:e,t}){return e.status===`allow`?(0,Y.jsx)(Bu,{tone:`allow`,icon:(0,Y.jsx)(Ai,{className:`h-4 w-4 shrink-0`}),title:t(`perm.cel.test.allow`),children:t(`perm.cel.test.allowHint`)}):e.status===`deny`?(0,Y.jsx)(Bu,{tone:`deny`,icon:(0,Y.jsx)(ji,{className:`h-4 w-4 shrink-0`}),title:t(`perm.cel.test.deny`),children:t(`perm.cel.test.denyHint`)}):e.status===`value`?(0,Y.jsxs)(Bu,{tone:`warn`,icon:(0,Y.jsx)(Ji,{className:`h-4 w-4 shrink-0`}),title:t(`perm.cel.test.nonBool`),children:[(0,Y.jsx)(`code`,{className:`font-mono`,children:JSON.stringify(e.value)}),` — `,t(`perm.cel.test.nonBoolHint`)]}):e.status===`unavailable`?(0,Y.jsx)(Bu,{tone:`warn`,icon:(0,Y.jsx)(Ji,{className:`h-4 w-4 shrink-0`}),title:t(`perm.cel.test.unavailable`),children:t(`perm.cel.test.unavailableHint`)}):(0,Y.jsx)(Bu,{tone:`error`,icon:(0,Y.jsx)(Rn,{className:`h-4 w-4 shrink-0`}),title:t(`perm.cel.test.error`),children:(0,Y.jsx)(`code`,{className:`block whitespace-pre-wrap break-words font-mono text-[11px]`,children:e.messageKey?t(e.messageKey):e.message})})}var zu={allow:`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,deny:`border-destructive/40 bg-destructive/10 text-destructive`,warn:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400`,error:`border-destructive/40 bg-destructive/10 text-destructive`};function Bu({tone:e,icon:t,title:n,children:r}){return(0,Y.jsxs)(`div`,{className:R(`rounded-md border px-3 py-2 text-xs`,zu[e]),role:`status`,"aria-live":`polite`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[t,n]}),(0,Y.jsx)(`div`,{className:`mt-1 opacity-90`,children:r})]})}var Vu=[`priority`];function Hu(e){if(!e||typeof e!=`object`)return e;let t=Vu.filter(t=>t in e);if(t.length===0)return e;let n={...e};for(let e of t)delete n[e];return n}var Uu=[`all`,`select`,`insert`,`update`,`delete`],Wu=[`visible`,`hidden`,`default_on`,`default_off`];function Gu(e){if(Array.isArray(e))return e;if(typeof e==`string`&&e.trim())try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}return[]}function Ku(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e;if(typeof e==`string`&&e.trim())try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return{}}var qu=`h-8 rounded-md border border-input bg-background px-2 text-sm disabled:opacity-50`;function Ju({title:e,icon:t,count:n,children:r,defaultOpen:i}){let[a,o]=J.useState(!!i);return(0,Y.jsxs)(Fe,{open:a,onOpenChange:o,className:`border-b`,children:[(0,Y.jsxs)(yt,{className:`flex w-full items-center gap-2 px-6 py-2.5 text-left hover:bg-muted/40`,children:[(0,Y.jsx)(Pn,{className:R(`h-4 w-4 text-muted-foreground transition-transform`,a&&`rotate-90`)}),t,(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:e}),n!=null&&n>0&&(0,Y.jsx)(V,{variant:`secondary`,className:`text-[10px]`,children:n})]}),(0,Y.jsx)(qe,{className:`px-6 pb-4 pt-1`,children:r})]})}function Yu({draft:e,setDraft:t,writable:n,allSetNames:r,loadObjectFields:i,onCelErrorsChange:a,t:o}){let s=J.useMemo(()=>Gu(e.rowLevelSecurity).map(Hu),[e.rowLevelSecurity]),c=J.useMemo(()=>Ku(e.adminScope),[e.adminScope]),l=J.useMemo(()=>Ku(e.tabPermissions),[e.tabPermissions]),[u,d]=J.useState({}),f=J.useRef(new Set),p=J.useCallback(e=>{let t=(e??``).trim();t&&t!==`*`&&i&&(f.current.has(t)||(f.current.add(t),i(t).then(e=>d(n=>({...n,[t]:e}))).catch(()=>d(e=>({...e,[t]:[]})))))},[i]),m=e=>u[(e??``).trim()]??[],[h,g]=J.useState({}),_=J.useCallback((e,t)=>{let n=t.filter(e=>e.severity===`error`).length;g(t=>t[e]===n?t:{...t,[e]:n})},[]),[v,y]=J.useState(null);J.useEffect(()=>{s.forEach(e=>p(e.object)),g(e=>{let t=new Set;s.forEach((e,n)=>{t.add(`${n}:using`),t.add(`${n}:check`)});let n=!1,r={};for(let i of Object.keys(e))t.has(i)?r[i]=e[i]:n=!0;return n?r:e})},[s,p]);let b=J.useMemo(()=>Object.values(h).reduce((e,t)=>e+t,0),[h]),x=J.useRef(a);J.useEffect(()=>{x.current=a}),J.useEffect(()=>{x.current?.(b)},[b]);let S=v==null?void 0:s[v],C=e=>t(t=>({...t,rowLevelSecurity:e})),w=e=>t(t=>({...t,adminScope:{...Ku(t.adminScope),...e}})),T=typeof c.businessUnit==`string`&&c.businessUnit.trim()!==``,E=e=>{T&&w(e)},D=Object.keys(c).length>0,O=D&&typeof c.businessUnit!=`string`,k=e=>t(t=>({...t,tabPermissions:e})),A=Object.entries(l);return(0,Y.jsxs)(`div`,{className:`border-b bg-muted/10`,children:[(0,Y.jsxs)(Ju,{title:o(`perm.rls.title`),icon:(0,Y.jsx)(Kr,{className:`h-4 w-4 text-muted-foreground`}),count:s.length,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:o(`perm.rls.help`)}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[s.map((e,t)=>(0,Y.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2 bg-background`,children:[(e.label||e.description)&&(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[e.label&&(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),e.description&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(z,{value:e.name??``,disabled:!n,placeholder:o(`perm.rls.name`),onChange:n=>{let r=[...s];r[t]={...e,name:n.target.value},C(r)},className:`h-8 w-48`}),(0,Y.jsx)(z,{value:e.object??``,disabled:!n,placeholder:o(`perm.rls.object`),onChange:n=>{let r=[...s];r[t]={...e,object:n.target.value},C(r)},className:`h-8 w-40`}),(0,Y.jsx)(`select`,{value:e.operation??`all`,disabled:!n,onChange:n=>{let r=[...s];r[t]={...e,operation:n.target.value},C(r)},className:qu,children:Uu.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,Y.jsx)(rt,{checked:e.enabled!==!1,disabled:!n,onCheckedChange:n=>{let r=[...s];r[t]={...e,enabled:!!n},C(r)}}),o(`perm.rls.enabled`)]}),(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,className:`h-7 ml-auto text-xs text-muted-foreground`,onClick:()=>y(t),title:o(`perm.cel.test.title`),children:[(0,Y.jsx)(vr,{className:`h-3.5 w-3.5 mr-1`}),o(`perm.cel.test.run`)]}),n&&(0,Y.jsx)(B,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-muted-foreground hover:text-destructive`,onClick:()=>C(s.filter((e,n)=>n!==t)),children:(0,Y.jsx)(Ki,{className:`h-4 w-4`})})]}),(0,Y.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,Y.jsx)(Yo,{label:o(`perm.rls.using`),value:e.using??``,disabled:!n,placeholder:`organization_id == current_user.organization_id`,objectName:e.object,fieldNames:m(e.object),clause:`using`,onLintChange:e=>_(`${t}:using`,e),onChange:n=>{let r=[...s];r[t]={...e,using:n},C(r)},t:o}),(0,Y.jsx)(Yo,{label:o(`perm.rls.check`),value:e.check??``,disabled:!n,placeholder:o(`perm.rls.checkPlaceholder`),objectName:e.object,fieldNames:m(e.object),clause:`check`,onLintChange:e=>_(`${t}:check`,e),onChange:n=>{let r=[...s];r[t]={...e,check:n},C(r)},t:o})]})]},t)),s.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:o(`perm.rls.empty`)}),n&&(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:()=>C([...s,{name:``,object:`*`,operation:`all`,using:``,enabled:!0}]),children:[(0,Y.jsx)(U,{className:`h-4 w-4 mr-1`}),` `,o(`perm.rls.add`)]})]})]}),(0,Y.jsx)(Iu,{open:v!=null,onOpenChange:e=>y(e?v:null),policyName:S?.name||void 0,objectName:S?.object,fieldNames:m(S?.object),using:S?.using,check:S?.check,t:o}),(0,Y.jsxs)(Ju,{title:o(`perm.tabs.title`),icon:(0,Y.jsx)(li,{className:`h-4 w-4 text-muted-foreground`}),count:A.length,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:o(`perm.tabs.help`)}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[A.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(z,{value:e,disabled:!n,onChange:t=>{let n=t.target.value,r={};for(let[t,i]of A)r[t===e?n:t]=i;k(r)},className:`h-8 w-64`}),(0,Y.jsx)(`select`,{value:t,disabled:!n,onChange:t=>k({...l,[e]:t.target.value}),className:qu,children:Wu.map(e=>(0,Y.jsx)(`option`,{value:e,children:o(`perm.tabs.vis.${e}`)},e))}),n&&(0,Y.jsx)(B,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-muted-foreground hover:text-destructive`,onClick:()=>{let t={...l};delete t[e],k(t)},children:(0,Y.jsx)(Ki,{className:`h-4 w-4`})})]},e)),A.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:o(`perm.tabs.empty`)}),n&&(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:()=>{l[``]===void 0&&k({...l,"":`visible`})},children:[(0,Y.jsx)(U,{className:`h-4 w-4 mr-1`}),` `,o(`perm.tabs.add`)]})]})]}),(0,Y.jsxs)(Ju,{title:o(`perm.admin.title`),icon:(0,Y.jsx)(Mi,{className:`h-4 w-4 text-muted-foreground`}),count:+!!D,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:o(`perm.admin.help`)}),(0,Y.jsxs)(`div`,{className:`space-y-3 max-w-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs`,children:o(`perm.admin.businessUnit`)}),(0,Y.jsx)(z,{value:c.businessUnit??``,disabled:!n,onChange:e=>w({businessUnit:e.target.value}),className:`h-8 w-64`})]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs pb-1.5`,children:[(0,Y.jsx)(rt,{checked:!!c.includeSubtree,disabled:!n||!T,onCheckedChange:e=>E({includeSubtree:!!e})}),o(`perm.admin.includeSubtree`)]})]}),!T&&(0,Y.jsx)(`p`,{className:R(`text-xs`,O?`text-destructive`:`text-muted-foreground`),children:o(`perm.admin.businessUnitRequired`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[[`manageAssignments`,`perm.admin.manageAssignments`],[`manageBindings`,`perm.admin.manageBindings`],[`authorEnvironmentSets`,`perm.admin.authorEnvironmentSets`]].map(([e,t])=>(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,Y.jsx)(rt,{checked:!!c[e],disabled:!n||!T,onCheckedChange:t=>E({[e]:!!t})}),o(t)]},e))}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(L,{className:`text-xs`,children:o(`perm.admin.assignableSets`)}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[r.length===0&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o(`perm.admin.noSets`)}),r.map(e=>{let t=(c.assignablePermissionSets??[]).includes(e);return(0,Y.jsx)(`button`,{type:`button`,disabled:!n||!T,"aria-pressed":t,onClick:()=>{let n=c.assignablePermissionSets??[],r=t?n.filter(t=>t!==e):[...n,e];E({assignablePermissionSets:r})},className:R(`rounded-full border px-3 py-1 text-xs transition-colors disabled:opacity-50`,t?`border-primary bg-primary text-primary-foreground`:`border-input bg-background hover:bg-accent`),children:e},e)})]})]})]})]})]})}var Xu=`sys_permission_set`,Zu=`clone_permission_set`;function Qu(e){let t=(Array.isArray(e)?e:[]).find(e=>e?.name===Xu);return(Array.isArray(t?.actions)?t.actions:[]).find(e=>e?.name===Zu)}function $u(e,t,n){let{params:r,...i}=e,a={...n(Xu,i),objectName:Xu,params:{_rowRecord:t}};return Array.isArray(r)&&r.length>0&&(a.actionParams=r),a}var ed=[`name`,`label`,`isDefault`,`objects`,`fields`,`systemPermissions`,`rowLevelSecurity`,`tabPermissions`,`adminScope`];function td(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function nd(e){return e instanceof Set?e:new Set(e)}function rd(e,t){let n=nd(t),r={};for(let[t,i]of Object.entries(e.objects??{}))n.has(t)&&(r[t]=i);let i={};for(let[t,r]of Object.entries(e.fields??{}))n.has(td(t))&&(i[t]=r);return{objects:r,fields:i}}function id(e,t,n){let r=nd(n),i={};for(let[t,n]of Object.entries(e.objects??{}))r.has(t)||(i[t]=n);for(let[e,n]of Object.entries(t.objects??{}))r.has(e)&&(i[e]=n);let a={};for(let[t,n]of Object.entries(e.fields??{}))r.has(td(t))||(a[t]=n);for(let[e,n]of Object.entries(t.fields??{}))r.has(td(e))&&(a[e]=n);let o={...e};for(let e of ed)e in t&&(o[e]=t[e]);return o.objects=i,o.fields=a,o}function ad(e){let t=e?.code;return t!=null&&t._packageId!==`sys_metadata`&&e?.provenance!==`org`}function od(e,t){let n={private:`perm.owd.private`,public_read:`perm.owd.public_read`,public_read_write:`perm.owd.public_read_write`,controlled_by_parent:`perm.owd.controlled_by_parent`};return n[t]?e(n[t]):t}function sd(e){return[{key:`allowCreate`,short:`C`,tip:G(`perm.action.create`,e)},{key:`allowRead`,short:`R`,tip:G(`perm.action.read`,e)},{key:`allowEdit`,short:`U`,tip:G(`perm.action.edit`,e)},{key:`allowDelete`,short:`D`,tip:G(`perm.action.delete`,e)},{key:`allowTransfer`,short:`Tr`,tip:G(`perm.action.transfer`,e)},{key:`viewAllRecords`,short:`VA`,tip:G(`perm.action.viewAll`,e)},{key:`modifyAllRecords`,short:`MA`,tip:G(`perm.action.modifyAll`,e)}]}function cd({type:e,name:n,packageId:r,onDraftSaved:i,publishNonce:a,onOpenOwd:o,onDirtyChange:s,readOnly:c=!1,embedded:l=!1}){let u=t(),d=sa(),f=Pt(),{execute:p}=Wt(),m=wt(),h=xt(),{entries:g}=ca(d),_=g.find(t=>t.type===e),[v,y]=J.useState(!1),b=!r&&v,x=(b?!!_?.allowOrgOverride:!!(_?.allowOrgOverride||_?.allowRuntimeCreate))&&!c,S=b&&!_?.allowOrgOverride&&!!_?.allowRuntimeCreate,C=$o(),w=J.useCallback(e=>G(e,C),[C]),T=J.useMemo(()=>sd(C),[C]),[E,D]=J.useState({name:n,objects:{},fields:{}}),O=J.useRef(null),k=J.useCallback(e=>{try{O.current=JSON.stringify(e)}catch{O.current=null}D({...e})},[]),[A,j]=J.useState([]),[M,N]=J.useState({}),[ee,F]=J.useState(new Set),[te,ne]=J.useState(!0),[re,ie]=J.useState(!1),[ae,oe]=J.useState(null),[I,se]=J.useState(!1),[ce,le]=J.useState(!1),[ue,de]=J.useState(null),[fe,pe]=J.useState(null),[me,he]=J.useState(null),[ge,_e]=J.useState(``),[ve,ye]=J.useState(!1),[xe,Se]=J.useState(!1),[Ce,Ee]=J.useState(!1),[De,Oe]=J.useState(!1),[Ae,je]=J.useState([]);J.useEffect(()=>{let e=!1;return d.list(`permission`,{}).then(t=>{e||je((t||[]).map(e=>e?.name).filter(e=>!!e))}).catch(()=>{}),()=>{e=!0}},[d]),J.useEffect(()=>{let t=!1;return ne(!0),y(!1),se(!1),pe(null),de(null),(async()=>{try{let[i,a,o]=await Promise.all([d.layered(e,n).catch(()=>null),d.list(`object`,r?{packageId:r}:{}).catch(()=>[]),r?d.getDraft(e,n,{packageId:r}).catch(()=>null):Promise.resolve(null)]);if(t)return;y(ad(i));let s=(o?P(o.item??o):null)??i?.effective??i?.code??{name:n,objects:{}},c=(a??[]).map(e=>{let t=e?.item??e;return{name:String(t?.name??``),label:t?.label,accessDefault:t?.access?.default,owd:typeof t?.sharingModel==`string`?t.sharingModel:void 0,owdExternal:typeof t?.externalSharingModel==`string`?t.externalSharingModel:void 0}}).filter(e=>!!e.name).sort((e,t)=>e.name.localeCompare(t.name));j(c);let l={...s,name:String(s?.name??n),objects:s?.objects??{},fields:s?.fields??{}};if(r){let e=rd(l,c.map(e=>e.name));k({...l,objects:e.objects,fields:e.fields})}else k(l)}catch(e){oe(e?.message??String(e))}finally{t||ne(!1)}})(),()=>{t=!0}},[d,e,n,r,a,k]);async function Me(e){if(!M[e])try{let t=(await d.get(`object`,e))?.fields,n=(Array.isArray(t)?t.map(e=>({name:String(e?.name??``),label:e?.label})):t&&typeof t==`object`?Object.entries(t).map(([e,t])=>({name:String(t?.name??e),label:t?.label})):[]).filter(e=>!!e.name).sort((e,t)=>e.name.localeCompare(t.name));N(t=>({...t,[e]:n}))}catch{N(t=>({...t,[e]:[]}))}}let Ne=J.useCallback(async e=>{try{let t=(await d.get(`object`,e))?.fields,n=(Array.isArray(t)?t.map(e=>String(e?.name??``)):t&&typeof t==`object`?Object.entries(t).map(([e,t])=>String(t?.name??e)):[]).filter(Boolean);return Array.from(new Set(n)).sort((e,t)=>e.localeCompare(t))}catch{return[]}},[d]),[Pe,Fe]=J.useState(0),Ie=J.useMemo(()=>{let e=O.current;if(e==null)return!1;try{return JSON.stringify(E)!==e}catch{return!1}},[E]),Ve=J.useRef(s);J.useEffect(()=>{Ve.current=s}),J.useEffect(()=>{Ve.current?.(Ie)},[Ie]),J.useEffect(()=>()=>{Ve.current?.(!1)},[]),J.useEffect(()=>{if(!Ie)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[Ie]);function We(e){F(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),Me(e)),n})}function Ge(e,t,n){D(r=>{let i={...r.objects[e]??{},[t]:n};return t===`viewAllRecords`&&n&&(i.allowRead=!0),t===`modifyAllRecords`&&n&&(i.allowEdit=!0,i.allowRead=!0),{...r,objects:{...r.objects,[e]:i}}})}function Ke(e,t){D(n=>{if(t===`none`)return{...n,objects:{...n.objects,[e]:{}}};let r={...n.objects[e]??{}};for(let e of T)delete r[e.key];let i=t===`all`?T.map(e=>e.key):t===`crud`?[`allowCreate`,`allowRead`,`allowEdit`,`allowDelete`]:[`allowRead`];for(let e of i)r[e]=!0;return{...n,objects:{...n.objects,[e]:r}}})}function qe(e,t,n,r){let i=`${e}.${t}`;D(e=>{let t={...e.fields??{}},a={...t[i]??{readable:!0,editable:!1},[n]:r};return n===`readable`&&!r&&(a.editable=!1),n===`editable`&&r&&(a.readable=!0),t[i]=a,{...e,fields:t}})}function Je(e,t,n){n.length!==0&&D(r=>{let i={...r.fields??{}};for(let r of n){let n=`${e}.${r}`;t===`clear`?delete i[n]:i[n]=t===`readable`?{readable:!0,editable:!1}:{readable:!0,editable:!0}}return{...r,fields:i}})}function R(e){if(!r)return e;let t=rd(e,A.map(e=>e.name));return{...e,objects:t.objects,fields:t.fields}}async function Xe(t,n){let a=n??E;ie(!0),oe(null),se(!1),pe(null);try{let n=a;if(r){let t=A.map(e=>e.name),r=!1,i=await d.layered(e,a.name).catch(()=>(r=!0,null));if(r)throw Error(w(`perm.save.rereadFailed`));n=id(i?.effective??a,a,t)}if(await d.save(e,a.name,n,{force:t,...r?{mode:`draft`,packageId:r}:{}}),r)k(R(n)),i?.();else{let t=!1,r=await d.layered(e,a.name).catch(()=>(t=!0,null));k(R(r?.effective??n)),se(t)}he(null)}catch(e){if(e?.status===409&&Yt(e,`DESTRUCTIVE_CHANGE`)){let t=e?.body?.issues??[];he({issues:Array.isArray(t)?t:[],pending:a})}else!r&&e?.status===403&&Yt(e,`NOT_OVERRIDABLE`)?pe(e?.message??String(e)):oe(e?.message??String(e))}finally{ie(!1)}}async function Ze(){if(!ce){le(!0),oe(null),de(null);try{let e=Qu(await m.ensureType(`object`));if(!e)throw Error(w(`perm.clone.actionMissing`));let t=((f?await f.find(`sys_permission_set`,{$filter:{name:n},$top:1}):null)?.data??[])[0];if(!t)throw Error(W(`perm.clone.rowMissing`,C,{name:n}));let r=await p($u(e,t,h));if(!r.success)return;let i=r.data,a=typeof i?.record?.name==`string`?i.record.name:``;if(!a){oe(w(`perm.clone.noName`));return}l?de(a):u(`../${encodeURIComponent(a)}`,{relative:`path`})}catch(e){oe(e?.message??String(e))}finally{le(!1)}}}let Qe=J.useMemo(()=>{let e=ge.trim().toLowerCase();return A.filter(t=>{if(ve){let e=E.objects[t.name];if(!e||!Object.values(e).some(Boolean))return!1}return!e||t.name.toLowerCase().includes(e)||(t.label??``).toLowerCase().includes(e)})},[A,ge,ve,E.objects]),$e=[{label:w(`perm.stat.objectsGranted`),value:Object.values(E.objects).filter(e=>Object.values(e).some(Boolean)).length},{label:w(`perm.stat.fieldOverrides`),value:Object.keys(E.fields??{}).length}],et=(0,Y.jsxs)(B,{size:`sm`,onClick:()=>void Ze(),disabled:ce,title:w(`perm.clone.hint`),children:[ce?(0,Y.jsx)(H,{className:`h-4 w-4 mr-1 animate-spin`}):(0,Y.jsx)(er,{className:`h-4 w-4 mr-1`}),w(`perm.clone.action`)]});return te?(0,Y.jsx)(Ga,{entry:_,itemName:n,embedded:l,readOnly:c,children:(0,Y.jsxs)(`div`,{className:`p-6 text-sm text-muted-foreground flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`}),` `,w(`perm.loading`).replace(`{name}`,n)]})}):(0,Y.jsxs)(Ga,{entry:_??{type:e,label:e},itemName:n,subtitle:w(`perm.subtitle.set`),stats:$e,embedded:l,readOnly:c,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,onClick:()=>l?Oe(!0):u(`./history?type=${encodeURIComponent(e)}`),children:[(0,Y.jsx)(Si,{className:`h-4 w-4 mr-1`}),` `,w(`engine.edit.history`)]}),x&&(0,Y.jsxs)(B,{size:`sm`,onClick:()=>Xe(!1),disabled:re||Pe>0,title:Pe>0?w(`perm.cel.saveBlocked`):void 0,children:[re?(0,Y.jsx)(H,{className:`h-4 w-4 mr-1 animate-spin`}):(0,Y.jsx)(Ti,{className:`h-4 w-4 mr-1`}),w(`engine.edit.save`)]}),S&&et]}),children:[(0,Y.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[ae&&(0,Y.jsxs)(`div`,{className:`m-4 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive flex items-start gap-2`,children:[(0,Y.jsx)(Ji,{className:`h-4 w-4 mt-0.5 shrink-0`}),(0,Y.jsx)(`span`,{children:ae})]}),S&&(0,Y.jsxs)(`div`,{role:`note`,className:`m-4 rounded-md border bg-muted/40 p-3 text-sm flex items-start gap-2`,children:[(0,Y.jsx)(Kr,{className:`h-4 w-4 mt-0.5 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{children:w(`perm.clone.guidance`)})]}),fe!==null&&(0,Y.jsxs)(`div`,{role:`alert`,className:`m-4 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(Ji,{className:`h-4 w-4 mt-0.5 shrink-0`}),(0,Y.jsx)(`span`,{children:w(`perm.save.locked`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-start gap-3 pl-6`,children:[et,(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:fe})]})]}),ue!==null&&(0,Y.jsxs)(`div`,{role:`status`,className:`m-4 rounded-md border border-amber-300/60 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm text-amber-800 dark:text-amber-200 flex items-start gap-2`,children:[(0,Y.jsx)(er,{className:`h-4 w-4 mt-0.5 shrink-0`}),(0,Y.jsx)(`span`,{children:W(`perm.clone.done`,C,{name:ue})})]}),I&&(0,Y.jsxs)(`div`,{role:`status`,className:`m-4 rounded-md border border-amber-300/60 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm text-amber-800 dark:text-amber-200 flex items-start gap-2`,children:[(0,Y.jsx)(Ji,{className:`h-4 w-4 mt-0.5 shrink-0`}),(0,Y.jsx)(`span`,{children:w(`perm.save.rereadStale`)})]}),(0,Y.jsxs)(`div`,{className:`border-b bg-muted/30`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>Se(e=>!e),"aria-expanded":xe,className:`w-full px-6 py-2.5 flex items-center gap-2 text-left hover:bg-muted/50 transition-colors`,children:[xe?(0,Y.jsx)(Nn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):(0,Y.jsx)(Pn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`font-medium truncate`,children:E.label||E.name}),(0,Y.jsx)(V,{variant:`outline`,className:`text-[10px] shrink-0`,children:E.managedBy===`platform`?w(`perm.badge.platform`):E.managedBy===`package`||r?w(`perm.badge.package`):w(`perm.badge.custom`)}),!!E.isDefault&&(0,Y.jsx)(V,{variant:`secondary`,className:`text-[10px] shrink-0`,children:w(`perm.badge.default`)}),x&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:w(`perm.basics.editHint`)}),!x&&(0,Y.jsx)(V,{variant:`secondary`,className:`ml-auto shrink-0`,title:w(c?`engine.studio.pkg.readonlyHint`:S?`perm.readOnly.artifact.hint`:`perm.readOnly.hint`),children:w(c?`engine.studio.pkg.readonly`:S?`perm.readOnly.artifact`:`perm.readOnly`)})]}),xe&&(0,Y.jsxs)(`div`,{className:`px-6 pb-3 flex flex-wrap items-end gap-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{htmlFor:`perm-name`,className:`text-xs`,children:w(`perm.field.name`)}),(0,Y.jsx)(z,{id:`perm-name`,value:E.name,disabled:!x,onChange:e=>D(t=>({...t,name:e.target.value})),className:`h-8 w-56`})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{htmlFor:`perm-label`,className:`text-xs`,children:w(`perm.field.label`)}),(0,Y.jsx)(z,{id:`perm-label`,value:E.label??``,disabled:!x,onChange:e=>D(t=>({...t,label:e.target.value})),className:`h-8 w-72`})]})]})]}),x&&(E.systemPermissions??[]).length===0&&!Ce?(0,Y.jsxs)(`div`,{className:`px-6 py-2.5 border-b flex items-center gap-2 text-xs`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:w(`perm.field.systemCapabilities`)}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:w(`perm.cap.none`)}),(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ee(!0),children:[`+ `,w(`perm.cap.add`)]})]}):(0,Y.jsxs)(`div`,{className:`px-6 py-3 border-b`,children:[(0,Y.jsx)(L,{className:`text-xs`,children:w(`perm.field.systemCapabilities`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 mb-2`,children:w(`perm.field.systemCapabilitiesHelp`)}),(0,Y.jsx)(`div`,{"data-testid":`capability-scroll`,className:`max-h-[30vh] overflow-y-auto overscroll-contain`,children:(0,Y.jsx)(Ye,{value:JSON.stringify(E.systemPermissions??[]),onChange:e=>D(t=>({...t,systemPermissions:be(e)})),field:{name:`system_permissions`},dataSource:f,readonly:!x})})]}),(0,Y.jsxs)(`div`,{className:`px-6 py-3 border-b flex items-center gap-3`,children:[(0,Y.jsx)(z,{placeholder:w(`perm.filter.placeholder`),value:ge,onChange:e=>_e(e.target.value),className:`h-8 w-72`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(rt,{id:`only-enabled`,checked:ve,onCheckedChange:e=>ye(!!e)}),(0,Y.jsx)(L,{htmlFor:`only-enabled`,className:`text-xs`,children:w(`perm.filter.onlyGranted`)})]}),(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[Qe.length,` / `,A.length,` `,w(`perm.stat.objectsSuffix`)]})]}),(0,Y.jsx)(`div`,{className:`px-6 py-2 border-b flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:T.map(e=>(0,Y.jsxs)(`span`,{className:`whitespace-nowrap`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:e.short}),` `,e.tip]},e.key))}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[(0,Y.jsx)(ld,{objects:Qe,draft:E,expanded:ee,fieldsByObject:M,writable:x,objectActions:T,t:w,onToggleExpand:We,onObjectPerm:Ge,onFieldPerm:qe,onBulkSet:Ke,onFieldBulk:Je,onOpenOwd:o}),(0,Y.jsx)(Yu,{draft:E,setDraft:D,writable:x,allSetNames:Ae,loadObjectFields:Ne,onCelErrorsChange:Fe,t:w})]})]}),(0,Y.jsx)(lt,{open:!!me,onOpenChange:e=>!e&&he(null),children:(0,Y.jsxs)(Re,{children:[(0,Y.jsxs)(Te,{children:[(0,Y.jsxs)(ke,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Ji,{className:`h-4 w-4 text-amber-500`}),` `,w(`engine.edit.destructive`)]}),(0,Y.jsx)(Be,{children:w(`engine.edit.destructiveHint`)})]}),(0,Y.jsx)(`ul`,{className:`text-sm space-y-1 max-h-64 overflow-auto`,children:me?.issues.map((e,t)=>(0,Y.jsxs)(`li`,{className:`border-l-2 border-amber-500 pl-2`,children:[e.kind&&(0,Y.jsx)(V,{variant:`outline`,className:`mr-2`,children:e.kind}),e.message??JSON.stringify(e)]},t))}),(0,Y.jsxs)(Ue,{children:[(0,Y.jsx)(B,{variant:`ghost`,onClick:()=>he(null),children:w(`engine.cancel`)}),(0,Y.jsxs)(B,{variant:`destructive`,onClick:()=>me&&Xe(!0,me.pending),disabled:re,children:[re&&(0,Y.jsx)(H,{className:`h-4 w-4 mr-1 animate-spin`}),w(`engine.edit.forceSave`)]})]})]})}),l&&(0,Y.jsx)(ct,{open:De,onOpenChange:Oe,children:(0,Y.jsxs)(Le,{side:`right`,className:`w-[92vw] sm:max-w-[720px] p-0 flex flex-col gap-0`,children:[(0,Y.jsxs)(He,{className:`px-4 py-3 border-b`,children:[(0,Y.jsx)(we,{className:`text-base`,children:w(`engine.edit.history`)}),(0,Y.jsxs)(ze,{className:`text-xs`,children:[e,` / `,n]})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto p-4`,children:De&&(0,Y.jsx)(Ka,{type:e,name:n,client:d})})]})})]})}function ld({objects:e,draft:t,expanded:n,fieldsByObject:r,writable:i,objectActions:a,t:o,onToggleExpand:s,onObjectPerm:c,onFieldPerm:l,onBulkSet:u,onFieldBulk:d,onOpenOwd:f}){return(0,Y.jsxs)(`table`,{className:`w-full min-w-[960px] text-sm`,children:[(0,Y.jsx)(`thead`,{className:`sticky top-0 bg-background border-b z-10`,children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`text-left px-4 py-2 font-medium w-72`,children:o(`perm.col.object`)}),a.map(e=>(0,Y.jsx)(`th`,{className:`px-2 py-2 font-medium text-center w-14`,title:e.tip,children:e.short},e.key)),(0,Y.jsx)(`th`,{className:`px-2 py-2 font-medium w-44 text-right`,children:o(`perm.col.bulk`)})]})}),(0,Y.jsxs)(`tbody`,{children:[e.length===0&&(0,Y.jsx)(`tr`,{children:(0,Y.jsx)(`td`,{colSpan:a.length+2,className:`px-4 py-8 text-center text-muted-foreground`,children:o(`perm.filter.empty`)})}),e.map(e=>{let p=t.objects[e.name]??{},m=n.has(e.name);return(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsxs)(`tr`,{className:`border-b hover:bg-muted/30`,children:[(0,Y.jsxs)(`td`,{className:`px-2 py-1.5 align-middle`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>s(e.name),className:`inline-flex items-center gap-1.5 hover:text-foreground`,children:[m?(0,Y.jsx)(Nn,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(Pn,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),e.label&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,e.name,`)`]})]}),e.accessDefault===`private`&&(0,Y.jsx)(V,{variant:`outline`,className:`ml-2 border-amber-500/50 text-amber-600 dark:text-amber-400 text-[10px] px-1.5 py-0 align-middle`,title:o(`perm.posture.private.tip`),children:o(`perm.posture.private`)}),(0,Y.jsx)(V,{variant:`outline`,className:`ml-2 text-[10px] px-1.5 py-0 align-middle text-muted-foreground`+(f?` cursor-pointer hover:text-foreground hover:border-foreground/40 focus:outline-none focus:ring-1 focus:ring-primary`:``),title:o(f?`perm.owd.editLink`:`perm.owd.tip`),...f?{role:`button`,tabIndex:0,"data-testid":`owd-badge-${e.name}`,onClick:()=>f(e.name),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),f(e.name))}}:{},children:`OWD ${e.owd?od(o,e.owd):o(`perm.owd.defaultPrivate`)}`}),e.owdExternal&&(0,Y.jsx)(V,{variant:`outline`,className:`ml-1 text-[10px] px-1.5 py-0 align-middle text-muted-foreground`,title:o(`perm.owd.ext.tip`),children:`Ext ${od(o,e.owdExternal)}`})]}),a.map(t=>(0,Y.jsx)(`td`,{className:`text-center px-2 py-1.5`,children:(0,Y.jsx)(ge,{checked:!!p[t.key],disabled:!i,onCheckedChange:n=>c(e.name,t.key,!!n),"aria-label":`${e.name} ${t.tip}`})},t.key)),(0,Y.jsxs)(`td`,{className:`px-2 py-1.5 text-right space-x-1`,children:[(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,disabled:!i,onClick:()=>u(e.name,`read`),children:o(`perm.bulk.read`)}),(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,disabled:!i,onClick:()=>u(e.name,`crud`),children:o(`perm.bulk.crud`)}),(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,disabled:!i,onClick:()=>u(e.name,`all`),children:o(`perm.bulk.all`)}),(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,disabled:!i,onClick:()=>u(e.name,`none`),children:o(`perm.bulk.none`)})]})]}),m&&(0,Y.jsx)(`tr`,{className:`bg-muted/10`,children:(0,Y.jsx)(`td`,{colSpan:a.length+2,className:`px-12 py-3`,children:(0,Y.jsx)(ud,{objectName:e.name,fields:r[e.name],fieldsState:t.fields??{},writable:i,t:o,onFieldPerm:l,onFieldBulk:d})})})]},e.name)})]})]})}function ud({objectName:e,fields:t,fieldsState:n,writable:r,t:i,onFieldPerm:a,onFieldBulk:o}){let[s,c]=J.useState(``);if(!t)return(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`h-3 w-3 animate-spin`}),` `,i(`perm.field.loading`)]});if(t.length===0)return(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i(`perm.field.empty`)});let l=s.trim().toLowerCase(),u=l?t.filter(e=>e.name.toLowerCase().includes(l)||(e.label??``).toLowerCase().includes(l)):t,d=u.map(e=>e.name);return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t.length>6&&(0,Y.jsx)(z,{value:s,onChange:e=>c(e.target.value),placeholder:i(`perm.field.filter`),"aria-label":i(`perm.field.filter`),className:`h-7 w-44 text-xs`}),r&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,disabled:d.length===0,onClick:()=>o(e,`readable`,d),children:i(`perm.field.bulk.readable`)}),(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,disabled:d.length===0,onClick:()=>o(e,`writable`,d),children:i(`perm.field.bulk.writable`)}),(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,disabled:d.length===0,onClick:()=>o(e,`clear`,d),children:i(`perm.field.bulk.clear`)})]}),(0,Y.jsxs)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:[u.length,` / `,t.length]})]}),u.length===0?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i(`perm.field.filterEmpty`)}):(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`text-left py-1 font-medium`,children:i(`perm.field.col.name`)}),(0,Y.jsx)(`th`,{className:`px-2 py-1 font-medium w-16 text-center`,title:i(`perm.field.read`),children:i(`perm.field.read`)}),(0,Y.jsx)(`th`,{className:`px-2 py-1 font-medium w-16 text-center`,title:i(`perm.field.edit`),children:i(`perm.field.edit`)})]})}),(0,Y.jsx)(`tbody`,{children:u.map(t=>{let i=n[`${e}.${t.name}`]??{readable:!0,editable:!1};return(0,Y.jsxs)(`tr`,{className:`border-t border-muted`,children:[(0,Y.jsxs)(`td`,{className:`py-1`,children:[t.label??t.name,t.label&&(0,Y.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`(`,t.name,`)`]})]}),(0,Y.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,Y.jsx)(ge,{checked:!!i.readable,disabled:!r,onCheckedChange:n=>a(e,t.name,`readable`,!!n),"aria-label":`${e}.${t.name} readable`})}),(0,Y.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,Y.jsx)(ge,{checked:!!i.editable,disabled:!r,onCheckedChange:n=>a(e,t.name,`editable`,!!n),"aria-label":`${e}.${t.name} editable`})})]},t.name)})})]})]})}function dd(){return`${``.replace(/\/$/,``)}/api/v1`}function fd(e){let t=e,n=t?._packageId;return typeof n!=`string`||!n||n===`sys_metadata`?!1:t?._provenance!==`org`}function pd(e,t){let n=new Map;for(let e of t){let t=e,r=t?.name;typeof r==`string`&&r&&fd(t)&&n.set(r,t)}let r=[];for(let t of e){let e=t?.name;if(typeof e!=`string`||!e)continue;let i=n.get(e);if(!i)continue;let a=i.label,o=t.reason;r.push({name:e,label:typeof a==`string`&&a?a:e,enabled:t.enabled!==!1,...typeof o==`string`&&o.length>0?{reason:o}:{}})}return r.sort((e,t)=>e.label.localeCompare(t.label)||e.name.localeCompare(t.name))}function md(e){let t=e?.data;return!t||typeof t!=`object`||Array.isArray(t)?{}:t}function hd(e){return e?.success===!1}function gd(e){let t=e,n=t?.data?.flows??t?.flows??[];return Array.isArray(n)?n:[]}function _d(e){if(Array.isArray(e))return e;let t=e?.items;return Array.isArray(t)?t:[]}var vd=`global`;function yd(e){let t=e,n=t?.data?.records??t?.records??[];return Array.isArray(n)?n:[]}function bd(e){let t=e;return(t?.data?.hasMore??t?.hasMore)===!0}function xd(e){let t=new Map;for(let n of e){if(n?.metadata_type!==`action`||n?.organization_id!=null)continue;let e=n?.name;if(typeof e!=`string`||!e)continue;let r=n?.active;t.set(e,r!==!1&&r!==0)}return t}function Sd(e){let t=e;return typeof t?.objectName==`string`&&t.objectName.length>0?t.objectName:typeof t?.object==`string`&&t.object.length>0?t.object:vd}function Cd(e,t){let n=e;return typeof n?._packageId==`string`||typeof n?._provenance==`string`?e:t}function wd(e,t,n){let r=[],i=new Set,a=(e,t,a)=>{let o=e,s=o?.name;if(typeof s!=`string`||!s)return;let c=`${t}:${s}`;if(i.has(c)||(i.add(c),!fd(Cd(e,a))))return;let l=o?.label;r.push({name:s,objectName:t,label:typeof l==`string`&&l?l:s,enabled:n.get(s)??!0})},o=new Map;for(let t of e){let e=t;typeof e?.name==`string`&&e.name&&o.set(e.name,t)}for(let t of e){let e=t,n=e?.name;if(typeof n==`string`&&n)for(let r of Array.isArray(e?.actions)?e.actions:[])a(r,n,t)}for(let e of t){let t=Sd(e);a(e,t,o.get(t))}return r.sort((e,t)=>e.label.localeCompare(t.label)||e.objectName.localeCompare(t.objectName)||e.name.localeCompare(t.name))}var Td={Accept:`application/json`},Ed=1e3;async function Dd(e){return e.json().catch(()=>null)}async function Od(e,t){return fetch(`${dd()}${e}`,{credentials:`include`,headers:Td,cache:`no-store`,signal:t})}async function kd(e){let t=await Od(`/meta/object`,e);if(!t.ok)throw Error(`object metadata HTTP ${t.status}`);return _d(await Dd(t))}async function Ad(e){try{let t=await Od(`/meta/action`,e);return t.ok?_d(await Dd(t)):[]}catch(e){if(e?.name===`AbortError`)throw e;return[]}}async function jd(e){let t=await Od(`/data/sys_metadata_activation?top=${Ed}`,e);if(!t.ok)throw Error(`activation ledger HTTP ${t.status}`);let n=await Dd(t);if(bd(n))throw Error(`activation ledger returned more than ${Ed} rows; refusing to show a partial ledger because a missing row reads as "active"`);return xd(yd(n))}function Md(e){return`${e.objectName}:${e.name}`}function Nd({nonce:e=0}){let{t}=rn(),[n,r]=J.useState(null),[i,a]=J.useState(null),[o,s]=J.useState(null),[c,l]=J.useState({});J.useEffect(()=>{let e=new AbortController,n=!1;return a(null),(async()=>{try{let[t,i,a]=await Promise.all([kd(e.signal),Ad(e.signal),jd(e.signal)]);if(n)return;r(wd(t,i,a))}catch(i){if(n||e.signal.aborted)return;r([]),a(i instanceof Error&&i.message?i.message:t(`packagedAutomation.actionsLoadFailed`,{defaultValue:`Could not load packaged actions.`}))}})(),()=>{n=!0,e.abort()}},[e,t]);let u=J.useCallback(e=>{l(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})},[]);async function d(e,n){let i=Md(e);s(i),u(i);try{let a=await fetch(`${dd()}/actions/_activation/${encodeURIComponent(e.objectName)}/${encodeURIComponent(e.name)}`,{method:`POST`,credentials:`include`,headers:{...Td,"Content-Type":`application/json`},body:JSON.stringify({enabled:n})}),o=await Dd(a);if(!a.ok||hd(o)){l(e=>({...e,[i]:Kt(o,t(`packagedAutomation.toggleFailedHttp`,{defaultValue:`Could not change activation (HTTP {{status}}).`,status:a.status}))}));return}let s=md(o).enabled,c=typeof s==`boolean`?s:n;r(e=>e?.map(e=>Md(e)===i?{...e,enabled:c}:e)??e)}catch(e){l(n=>({...n,[i]:e instanceof Error&&e.message?e.message:t(`packagedAutomation.toggleFailed`,{defaultValue:`Could not change activation.`})}))}finally{s(null)}}return(0,Y.jsxs)(`section`,{className:`space-y-3`,"data-testid":`packaged-actions-section`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:t(`packagedAutomation.actionsHeading`,{defaultValue:`Packaged actions`})}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-2xl`,children:t(`packagedAutomation.actionsSubtitle`,{defaultValue:`Actions shipped by installed packages. Turn one off for this deployment and it stops running everywhere it is offered. Authoring your own action alongside it stays open in Studio.`})})]}),i&&(0,Y.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm`,children:i}),n===null&&(0,Y.jsxs)(`div`,{className:`space-y-2`,"data-testid":`packaged-actions-loading`,children:[(0,Y.jsx)(ut,{className:`h-10 w-full`}),(0,Y.jsx)(ut,{className:`h-10 w-full`})]}),n!==null&&n.length===0&&!i&&(0,Y.jsxs)(Se,{children:[(0,Y.jsx)(me,{children:t(`packagedAutomation.actionsEmptyTitle`,{defaultValue:`No packaged actions`})}),(0,Y.jsx)(ye,{children:t(`packagedAutomation.actionsEmptyBody`,{defaultValue:`No installed package declares an action on this deployment. Actions you author yourself live in Studio.`})})]}),n!==null&&n.length>0&&(0,Y.jsxs)(ft,{children:[(0,Y.jsx)(pt,{children:(0,Y.jsxs)(gt,{children:[(0,Y.jsx)(nt,{children:t(`packagedAutomation.colAction`,{defaultValue:`Action`})}),(0,Y.jsx)(nt,{className:`w-[200px]`,children:t(`packagedAutomation.colObject`,{defaultValue:`Object`})}),(0,Y.jsx)(nt,{className:`w-[220px]`,children:t(`packagedAutomation.colActivation`,{defaultValue:`Activation`})})]})}),(0,Y.jsx)(ht,{children:n.map(e=>{let n=Md(e),r=c[n];return(0,Y.jsxs)(gt,{"data-testid":`packaged-action-${e.objectName}-${e.name}`,children:[(0,Y.jsxs)(st,{className:`align-top`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,Y.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground`,children:e.name}),r&&(0,Y.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-destructive`,children:r})]}),(0,Y.jsx)(st,{className:`align-top`,children:(0,Y.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground`,children:e.objectName})}),(0,Y.jsx)(st,{className:`align-top`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(rt,{checked:e.enabled,disabled:o===n,onCheckedChange:t=>void d(e,t),"aria-label":t(`packagedAutomation.actionToggleLabel`,{defaultValue:`Activation for {{label}} on {{object}}`,label:e.label,object:e.objectName})}),(0,Y.jsx)(V,{variant:e.enabled?`default`:`secondary`,children:e.enabled?t(`packagedAutomation.on`,{defaultValue:`On`}):t(`packagedAutomation.off`,{defaultValue:`Off`})})]})})]},n)})})]})]})}var Pd={Accept:`application/json`};async function Fd(e){return e.json().catch(()=>null)}async function Id(e){let t=await fetch(`${dd()}/automation/_status`,{credentials:`include`,headers:Pd,cache:`no-store`,signal:e});if(!t.ok)throw Error(`automation status HTTP ${t.status}`);return gd(await Fd(t))}async function Ld(e){let t=await fetch(`${dd()}/meta/flow`,{credentials:`include`,headers:Pd,cache:`no-store`,signal:e});if(!t.ok)throw Error(`flow metadata HTTP ${t.status}`);return _d(await Fd(t))}function Rd(){let{t:e}=rn(),[t,n]=J.useState(null),[r,i]=J.useState(null),[a,o]=J.useState(0),[s,c]=J.useState(null),[l,u]=J.useState({}),[d,f]=J.useState(null),[p,m]=J.useState(null);J.useEffect(()=>{let t=new AbortController,r=!1;return i(null),(async()=>{try{let[e,i]=await Promise.all([Id(t.signal),Ld(t.signal)]);if(r)return;n(pd(e,i))}catch(a){if(r||t.signal.aborted)return;n([]),i(a instanceof Error&&a.message?a.message:e(`packagedAutomation.loadFailed`,{defaultValue:`Could not load packaged automation.`}))}})(),()=>{r=!0,t.abort()}},[a,e]);let h=J.useCallback(e=>{u(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})},[]);async function g(t,r){c(t.name),h(t.name),m(null);try{let i=await fetch(`${dd()}/automation/${encodeURIComponent(t.name)}/toggle`,{method:`POST`,credentials:`include`,headers:{...Pd,"Content-Type":`application/json`},body:JSON.stringify({enabled:r})}),a=await Fd(i);if(!i.ok||hd(a)){u(n=>({...n,[t.name]:Kt(a,e(`packagedAutomation.toggleFailedHttp`,{defaultValue:`Could not change activation (HTTP {{status}}).`,status:i.status}))}));return}let o=md(a).enabled,s=typeof o==`boolean`?o:r;n(e=>e?.map(e=>e.name===t.name?{...e,enabled:s}:e)??e)}catch(n){u(r=>({...r,[t.name]:n instanceof Error&&n.message?n.message:e(`packagedAutomation.toggleFailed`,{defaultValue:`Could not change activation.`})}))}finally{c(null)}}async function _(t){f({...t,busy:!0,refusal:null});try{let n=await fetch(`${dd()}/automation/${encodeURIComponent(t.source)}/clone`,{method:`POST`,credentials:`include`,headers:{...Pd,"Content-Type":`application/json`},body:JSON.stringify({name:t.name.trim(),label:t.label.trim()})}),r=await Fd(n);if(!n.ok||hd(r)){f({...t,busy:!1,refusal:Kt(r,e(`packagedAutomation.cloneFailedHttp`,{defaultValue:`Could not clone this flow (HTTP {{status}}).`,status:n.status}))});return}let i=md(r),a=i.flow?.name,s=i.notice;f(null),m({name:typeof a==`string`&&a?a:t.name.trim(),notice:typeof s==`string`?s:``}),o(e=>e+1)}catch(n){f({...t,busy:!1,refusal:n instanceof Error&&n.message?n.message:e(`packagedAutomation.cloneFailed`,{defaultValue:`Could not clone this flow.`})})}}let v=e(`packagedAutomation.title`,{defaultValue:`Packaged automation`}),y=!!d&&d.name.trim()!==``&&d.label.trim()!==``;return(0,Y.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold`,children:v}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-2xl`,children:e(`packagedAutomation.subtitle`,{defaultValue:`Flows and actions shipped by installed packages. Turn one off for this deployment, or clone a flow under a new name to customize it. Editing happens in Studio.`})})]}),(0,Y.jsx)(B,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(e=>e+1),"aria-label":e(`packagedAutomation.refresh`,{defaultValue:`Refresh`}),children:(0,Y.jsx)(vi,{className:`h-4 w-4`})})]}),(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e(`packagedAutomation.flowsHeading`,{defaultValue:`Packaged flows`})}),p&&(0,Y.jsxs)(`div`,{role:`status`,className:`rounded-md border border-border bg-muted/40 p-3 text-sm space-y-1`,children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:e(`packagedAutomation.cloneCreated`,{defaultValue:`Created flow "{{name}}".`,name:p.name})}),p.notice&&(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:p.notice})]}),r&&(0,Y.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm`,children:r}),t===null&&(0,Y.jsxs)(`div`,{className:`space-y-2`,"data-testid":`packaged-automation-loading`,children:[(0,Y.jsx)(ut,{className:`h-10 w-full`}),(0,Y.jsx)(ut,{className:`h-10 w-full`}),(0,Y.jsx)(ut,{className:`h-10 w-full`})]}),t!==null&&t.length===0&&!r&&(0,Y.jsxs)(Se,{children:[(0,Y.jsx)(me,{children:e(`packagedAutomation.emptyTitle`,{defaultValue:`No packaged flows`})}),(0,Y.jsx)(ye,{children:e(`packagedAutomation.emptyBody`,{defaultValue:`No installed package ships an automation flow on this deployment. Flows you author yourself live in Studio.`})})]}),t!==null&&t.length>0&&(0,Y.jsxs)(ft,{children:[(0,Y.jsx)(pt,{children:(0,Y.jsxs)(gt,{children:[(0,Y.jsx)(nt,{children:e(`packagedAutomation.colFlow`,{defaultValue:`Flow`})}),(0,Y.jsx)(nt,{className:`w-[220px]`,children:e(`packagedAutomation.colActivation`,{defaultValue:`Activation`})}),(0,Y.jsx)(nt,{className:`w-[140px] text-right`,children:e(`packagedAutomation.colActions`,{defaultValue:`Actions`})})]})}),(0,Y.jsx)(ht,{children:t.map(t=>{let n=l[t.name];return(0,Y.jsxs)(gt,{"data-testid":`packaged-flow-${t.name}`,children:[(0,Y.jsxs)(st,{className:`align-top`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:t.label}),(0,Y.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground`,children:t.name}),t.reason&&(0,Y.jsx)(`p`,{className:`mt-2 max-w-prose text-sm text-muted-foreground`,children:t.reason}),n&&(0,Y.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-destructive`,children:n})]}),(0,Y.jsx)(st,{className:`align-top`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(rt,{checked:t.enabled,disabled:s===t.name,onCheckedChange:e=>void g(t,e),"aria-label":e(`packagedAutomation.toggleLabel`,{defaultValue:`Activation for {{label}}`,label:t.label})}),(0,Y.jsx)(V,{variant:t.enabled?`default`:`secondary`,children:t.enabled?e(`packagedAutomation.on`,{defaultValue:`On`}):e(`packagedAutomation.off`,{defaultValue:`Off`})})]})}),(0,Y.jsx)(st,{className:`align-top text-right`,children:(0,Y.jsx)(B,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>f({source:t.name,name:``,label:``,refusal:null,busy:!1}),children:e(`packagedAutomation.clone`,{defaultValue:`Clone`})})})]},t.name)})})]}),(0,Y.jsx)(Nd,{nonce:a}),(0,Y.jsx)(lt,{open:!!d,onOpenChange:e=>!e&&f(null),children:(0,Y.jsxs)(Re,{children:[(0,Y.jsxs)(Te,{children:[(0,Y.jsx)(ke,{children:e(`packagedAutomation.cloneTitle`,{defaultValue:`Clone packaged flow`})}),(0,Y.jsx)(Be,{children:e(`packagedAutomation.cloneBody`,{defaultValue:`The copy carries the whole definition and takes a new machine name and label. Edit the copy in Studio.`})})]}),d&&(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{htmlFor:`packaged-clone-name`,children:e(`packagedAutomation.cloneName`,{defaultValue:`New machine name`})}),(0,Y.jsx)(z,{id:`packaged-clone-name`,value:d.name,onChange:e=>f({...d,name:e.target.value,refusal:null})})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{htmlFor:`packaged-clone-label`,children:e(`packagedAutomation.cloneLabel`,{defaultValue:`New label`})}),(0,Y.jsx)(z,{id:`packaged-clone-label`,value:d.label,onChange:e=>f({...d,label:e.target.value,refusal:null})})]}),d.refusal&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:d.refusal})]}),(0,Y.jsxs)(Ue,{children:[(0,Y.jsx)(B,{type:`button`,variant:`ghost`,onClick:()=>f(null),children:e(`packagedAutomation.cancel`,{defaultValue:`Cancel`})}),(0,Y.jsx)(B,{type:`button`,disabled:!y||!!d?.busy,onClick:()=>d&&void _(d),children:e(`packagedAutomation.cloneConfirm`,{defaultValue:`Create clone`})})]})]})})]})}function zd(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Bd(e){if(!zd(e))return;let t=e.config;if(zd(t)&&typeof t.type==`string`)return t.type;if(typeof e.type==`string`)return e.type;if(e.viewKind===`form`)return`form`;if(e.viewKind===`list`)return`list`}var Vd=(0,J.lazy)(()=>n(()=>import(`./metadata-admin-CEhVmXFv.js`).then(e=>({default:e.MetadataDirectoryPage})),__vite__mapDeps([0]),import.meta.url)),Hd=(0,J.lazy)(()=>n(()=>import(`./metadata-admin-CEhVmXFv.js`).then(e=>({default:e.MetadataResourceRouter})),__vite__mapDeps([0]),import.meta.url));function Ud({label:e}){return(0,Y.jsxs)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:[`Loading `,e,`…`]})}Es({ref:`metadata:directory`,label:`All Metadata Types`,source:`@object-ui/app-shell`,component:e=>(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Ud,{label:`metadata types`}),children:(0,Y.jsx)(Vd,{...e})})}),Es({ref:`metadata:resource`,label:`Metadata Resource`,source:`@object-ui/app-shell`,component:e=>(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Ud,{label:`metadata resource`}),children:(0,Y.jsx)(Hd,{...e})})}),Es({ref:`developer:packages`,label:`Packages`,source:`@object-ui/app-shell`,component:Va}),Es({ref:`automation:packaged`,label:`Packaged Automation`,source:`@object-ui/app-shell`,component:Rd}),za({type:`object`,label:`Objects`,description:`Domain entities — tables in the data model. Each object owns its fields, relationships, validations, and lifecycle hooks.`,domain:`data`,searchableFields:[`name`,`label`,`description`],listColumns:[{key:`name`,label:`Name`,width:`25%`},{key:`label`,label:`Label`,width:`25%`},{key:`description`,label:`Description`}]}),za({type:`field`,label:`Fields`,description:`Columns attached to objects — name, type, validation, and storage settings.`,domain:`data`,searchableFields:[`name`,`label`,`object`,`type`],listColumns:[{key:`name`,label:`Name`,width:`25%`},{key:`object`,label:`Object`,width:`20%`},{key:`type`,label:`Type`,width:`15%`},{key:`label`,label:`Label`}]}),za({type:`permission`,label:`Permission sets`,description:`Object-level CRUD + VAMA + lifecycle permissions, and field-level R/W. The only capability container (ADR-0090); distributed to users via positions.`,domain:`security`,EditPage:cd,searchableFields:[`name`,`label`],listColumns:[{key:`name`,label:`Name`,width:`30%`},{key:`label`,label:`Label`,width:`30%`},{key:`managedBy`,label:`Source`,width:`15%`,render:e=>e===`package`?`Package`:`Custom`}]}),za({type:`view`,label:`Views`,description:`Saved list / kanban / calendar / gantt configurations on top of an object.`,domain:`ui`,listColumns:[{key:`name`,label:`Name`,width:`30%`},{key:`object`,label:`Object`,width:`20%`},{key:`type`,label:`Type`,width:`15%`,render:(e,t)=>Bd(t)??`—`},{key:`label`,label:`Label`}],listFilter:e=>!ne(e)}),za({type:`dashboard`,label:`Dashboards`,description:`Composed dashboards with charts, KPIs, and tables.`,domain:`ui`,listColumns:[{key:`name`,label:`Name`,width:`30%`},{key:`label`,label:`Label`,width:`30%`},{key:`description`,label:`Description`}]});function Wd(e){if(!Object.prototype.hasOwnProperty.call(e,`requires`))return e;let t={...e};return delete t.requires,t}za({type:`page`,label:`Pages`,description:`Visual page layouts authored as JSON metadata.`,domain:`ui`,listColumns:[{key:`name`,label:`Name`,width:`30%`},{key:`label`,label:`Label`,width:`30%`},{key:`route`,label:`Route`}],fromDraft:Wd}),za({type:`book`,label:`Documentation Books`,description:`Documentation navigation spine — ordered groups with membership derived over docs (glob/tag rules), plus an explicit pages override for curated order.`,domain:`system`,searchableFields:[`name`,`label`,`description`,`slug`],listColumns:[{key:`name`,label:`Name`,width:`25%`},{key:`label`,label:`Label`,width:`25%`},{key:`audience`,label:`Audience`,width:`12%`,render:e=>e==null?`org`:typeof e==`object`&&e&&`permissionSet`in e?`permission set: ${e.permissionSet}`:String(e)},{key:`groups`,label:`Groups`,width:`10%`,render:e=>Array.isArray(e)?String(e.length):`0`},{key:`description`,label:`Description`}]});var Gd=`/api/v1/cloud-connection`;function Kd(e,t,n){for(let r of[t,n]){if(r===`expired_token`)return e(`cloudConnection.errors.expired`);if(r===`access_denied`)return e(`cloudConnection.errors.accessDenied`)}return null}async function qd(e,t){let n=await fetch(e,{credentials:`same-origin`,headers:{"Content-Type":`application/json`},...t}),r=await n.json().catch(()=>({}));if(!n.ok&&r?.success!==!0){let e=r?.error?.message??r?.error?.code??r?.error??`HTTP ${n.status}`;throw Object.assign(Error(typeof e==`string`?e:JSON.stringify(e)),{declaredCode:typeof r?.error?.declaredCode==`string`?r.error.declaredCode:void 0,code:typeof r?.error?.code==`string`?r.error.code:void 0})}return r}function Jd(){let{t:e}=rn(),t=nn(),[n,r]=(0,J.useState)({kind:`loading`}),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),c=(0,J.useRef)(null),l=(0,J.useRef)(e);(0,J.useEffect)(()=>{l.current=e},[e]);let u=(0,J.useCallback)(e=>{let t=e;return Kd(l.current,t?.declaredCode,t?.code)??t?.message??String(e)},[]),d=(0,J.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null)},[]),f=(0,J.useCallback)(async()=>{try{let e=(await qd(`${Gd}/status`))?.data??{environmentId:null,bound:!1,connection:null};r(e.bound?{kind:`bound`,status:e}:{kind:`unbound`})}catch(e){r({kind:`error`,message:u(e)})}},[u]);(0,J.useEffect)(()=>(f(),d),[f,d]);let p=(0,J.useCallback)((t,n)=>{let i=Math.max(t.interval,2)*1e3,a=async()=>{if(Date.now()-n>t.expires_in*1e3){r({kind:`error`,message:e(`cloudConnection.errors.expired`)});return}try{let n=await qd(`${Gd}/bind/poll`,{method:`POST`,body:JSON.stringify({device_code:t.device_code})});if(n?.data?.pending){c.current=setTimeout(a,i);return}if(n?.data?.bound||n?.success){await f();return}r({kind:`error`,message:Kd(e,n?.error?.declaredCode,n?.error?.code)??n?.error?.message??n?.error?.code??e(`cloudConnection.errors.bindFailed`)})}catch(e){r({kind:`error`,message:u(e)})}};c.current=setTimeout(a,i)},[u,f,e]),m=(0,J.useCallback)(async()=>{a(!0);try{let t=(await qd(`${Gd}/bind/start`,{method:`POST`,body:`{}`}))?.data;if(!t?.device_code||!t?.user_code)throw Error(e(`cloudConnection.errors.deviceCodeFailed`));let n=t.verification_uri_complete??t.verification_uri,i=!1;if(n)try{i=!!window.open(n,`_blank`,`noopener,width=520,height=720`)}catch{}r({kind:`waiting`,code:t,popupOpened:i}),p(t,Date.now())}catch(e){r({kind:`error`,message:u(e)})}finally{a(!1)}},[u,p,e]),h=(0,J.useCallback)(async()=>{a(!0);try{await qd(`${Gd}/unbind`,{method:`POST`,body:`{}`}),await f()}catch(e){r({kind:`error`,message:u(e)})}finally{a(!1)}},[u,f]),g=(0,J.useCallback)(async e=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)}catch{}},[]);if(n.kind===`loading`)return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border p-6 text-sm text-muted-foreground`,children:[(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),` `,e(`cloudConnection.checking`)]});if(n.kind===`error`)return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-destructive/40 bg-destructive/5 p-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-destructive`,children:[(0,Y.jsx)(Rn,{className:`h-4 w-4`,"aria-hidden":`true`}),` `,n.message]}),(0,Y.jsx)(`button`,{type:`button`,className:`self-start rounded-md border px-3 py-1.5 text-sm hover:bg-accent`,onClick:()=>{d(),f()},children:e(`cloudConnection.retry`)})]});if(n.kind===`waiting`){let t=n.code.verification_uri_complete??n.code.verification_uri;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-lg border p-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),n.popupOpened?e(`cloudConnection.waiting.popupOpened`):e(`cloudConnection.waiting.polling`)]}),!n.popupOpened&&t?(0,Y.jsxs)(`a`,{className:`inline-flex items-center gap-1.5 self-start rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,href:t,target:`_blank`,rel:`noreferrer`,children:[e(`cloudConnection.waiting.openApproval`),` `,(0,Y.jsx)(cr,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})]}):null,(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`code`,{className:`rounded-md bg-muted px-4 py-2 text-2xl font-semibold tracking-[0.25em]`,children:n.code.user_code}),(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm hover:bg-accent`,onClick:()=>void g(n.code.user_code),children:[(0,Y.jsx)(er,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),e(o?`cloudConnection.waiting.copied`:`cloudConnection.waiting.copy`)]})]}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e(`cloudConnection.waiting.codePrefilled`),n.popupOpened&&t?(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-primary underline-offset-2 hover:underline`,href:t,target:`_blank`,rel:`noreferrer`,children:[e(`cloudConnection.waiting.openItHere`),` `,(0,Y.jsx)(cr,{className:`h-3 w-3`,"aria-hidden":`true`})]})]}):null]}),(0,Y.jsx)(`button`,{type:`button`,className:`self-start rounded-md border px-3 py-1.5 text-sm hover:bg-accent`,onClick:()=>{d(),f()},children:e(`cloudConnection.waiting.cancel`)})]})}if(n.kind===`bound`){let r=n.status.connection??{},a=r.runtime_id??n.status.runtimeId;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-lg border p-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(zn,{className:`h-5 w-5 text-emerald-600`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e(`cloudConnection.bound.title`)})]}),(0,Y.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5 text-sm`,children:[r.name?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:e(`cloudConnection.bound.runtime`)}),(0,Y.jsx)(`dd`,{children:r.name})]}):null,r.organization_id?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:e(`cloudConnection.bound.organization`)}),(0,Y.jsx)(`dd`,{className:`font-mono`,children:r.organization_id})]}):null,r.account_email?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:e(`cloudConnection.bound.approvedBy`)}),(0,Y.jsx)(`dd`,{children:r.account_email})]}):null,a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:e(`cloudConnection.bound.runtimeId`)}),(0,Y.jsx)(`dd`,{className:`font-mono text-xs`,children:a})]}):null,n.status.environmentId?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:e(`cloudConnection.bound.environment`)}),(0,Y.jsx)(`dd`,{className:`font-mono`,children:n.status.environmentId})]}):null,r.bound_at?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground`,children:e(`cloudConnection.bound.since`)}),(0,Y.jsx)(`dd`,{children:new Date(r.bound_at).toLocaleString(t)})]}):null]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`cloudConnection.bound.privatePackages`)}),(0,Y.jsxs)(`button`,{type:`button`,disabled:i,className:`inline-flex items-center gap-1.5 self-start rounded-md border border-destructive/40 px-3 py-1.5 text-sm text-destructive hover:bg-destructive/5 disabled:opacity-50`,onClick:()=>void h(),children:[(0,Y.jsx)(Xi,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),` `,e(`cloudConnection.bound.disconnect`)]})]})}return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-lg border p-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Jn,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e(`cloudConnection.unbound.title`)})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`cloudConnection.unbound.body`)}),(0,Y.jsxs)(`button`,{type:`button`,disabled:i,className:`inline-flex items-center gap-1.5 self-start rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,onClick:()=>void m(),children:[i?(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}):(0,Y.jsx)(Yn,{className:`h-4 w-4`,"aria-hidden":`true`}),e(`cloudConnection.unbound.connect`)]})]})}kt.register(`cloud-connection:panel`,()=>(0,Y.jsx)(Jd,{}),{namespace:`app-shell`,label:`Cloud Connection Panel`,category:`plugin`,inputs:[]});var Yd=``.replace(/\/$/,``);function Xd(e){let t=d.get();return t?{...e,Authorization:`Bearer ${t}`}:e}function Zd(e){let t=Yd||(typeof window<`u`?window.location.origin:``);try{return new URL(e,t||void 0).toString()}catch{return e}}function Qd({text:e,label:t}){let[n,r]=(0,J.useState)(!1);return(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{}},children:[n?(0,Y.jsx)(Mn,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(er,{className:`h-3.5 w-3.5`}),t?(0,Y.jsx)(`span`,{className:`ml-1`,children:t}):null]})}function $d({text:e}){return(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`pre`,{className:`flex-1 overflow-x-auto rounded-md bg-muted px-3 py-2 text-xs leading-relaxed`,children:(0,Y.jsx)(`code`,{children:e})}),(0,Y.jsx)(Qd,{text:e})]})}function ef(){let{t:e}=rn(),[t,n]=(0,J.useState)(!0),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(null);(0,J.useEffect)(()=>{(async()=>{try{let e=await(await fetch(`${Yd}/api/v1/discovery`,{credentials:`include`})).json().catch(()=>({})),t=(e?.data??e)?.routes??{};i(typeof t.mcp==`string`?Zd(t.mcp):null)}catch(e){o(e?.message??String(e))}finally{n(!1)}})()},[]);let h=r?`${r}/skill`:null,g=(0,J.useMemo)(()=>{if(!r)return null;let e=btoa(JSON.stringify({url:r}));return`cursor://anysphere.cursor-deeplink/mcp/install?name=objectstack&config=${encodeURIComponent(e)}`},[r]);return t?(0,Y.jsxs)(`div`,{className:`space-y-3 p-1`,children:[(0,Y.jsx)(ut,{className:`h-10 w-full`}),(0,Y.jsx)(ut,{className:`h-40 w-full`})]}):r?(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(Qe,{children:[(0,Y.jsx)($e,{className:`pb-2`,children:(0,Y.jsxs)(Ee,{className:`flex items-center gap-2 text-base`,children:[(0,Y.jsx)(_n,{className:`h-4 w-4`}),e(`connectAgent.url.title`)]})}),(0,Y.jsxs)(De,{className:`space-y-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`connectAgent.url.body`)}),(0,Y.jsx)($d,{text:r}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[h&&(0,Y.jsx)(B,{variant:`outline`,size:`sm`,asChild:!0,children:(0,Y.jsxs)(`a`,{href:h,download:`SKILL.md`,children:[(0,Y.jsx)(ar,{className:`mr-1 h-3.5 w-3.5`}),e(`connectAgent.url.downloadSkill`)]})}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`connectAgent.url.skillHint`)})]})]})]}),(0,Y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Y.jsxs)(Qe,{children:[(0,Y.jsx)($e,{className:`pb-2`,children:(0,Y.jsx)(Ee,{className:`text-base`,children:`Claude (claude.ai / Desktop)`})}),(0,Y.jsxs)(De,{className:`space-y-2 text-sm`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connectAgent.claude.body`)}),(0,Y.jsx)($d,{text:r}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`connectAgent.claude.reachability`)})]})]}),(0,Y.jsxs)(Qe,{children:[(0,Y.jsx)($e,{className:`pb-2`,children:(0,Y.jsx)(Ee,{className:`text-base`,children:`Claude Code`})}),(0,Y.jsxs)(De,{className:`space-y-2 text-sm`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connectAgent.claudeCode.body`)}),(0,Y.jsx)($d,{text:`claude mcp add --transport http objectstack ${r}`}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connectAgent.claudeCode.plugin`)}),(0,Y.jsx)($d,{text:`claude plugin marketplace add objectstack-ai/claude-plugin`})]})]}),(0,Y.jsxs)(Qe,{children:[(0,Y.jsx)($e,{className:`pb-2`,children:(0,Y.jsxs)(Ee,{className:`flex items-center justify-between text-base`,children:[`Cursor`,g&&(0,Y.jsx)(B,{variant:`outline`,size:`sm`,asChild:!0,children:(0,Y.jsxs)(`a`,{href:g,children:[(0,Y.jsx)(cr,{className:`mr-1 h-3.5 w-3.5`}),e(`connectAgent.cursor.addButton`)]})})]})}),(0,Y.jsxs)(De,{className:`space-y-2 text-sm`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connectAgent.cursor.body`)}),(0,Y.jsx)($d,{text:JSON.stringify({mcpServers:{objectstack:{url:r}}},null,2)})]})]}),(0,Y.jsxs)(Qe,{children:[(0,Y.jsx)($e,{className:`pb-2`,children:(0,Y.jsx)(Ee,{className:`text-base`,children:`VS Code / Copilot`})}),(0,Y.jsxs)(De,{className:`space-y-2 text-sm`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connectAgent.vscode.body`)}),(0,Y.jsx)($d,{text:JSON.stringify({servers:{objectstack:{type:`http`,url:r}}},null,2)})]})]}),(0,Y.jsxs)(Qe,{children:[(0,Y.jsx)($e,{className:`pb-2`,children:(0,Y.jsx)(Ee,{className:`text-base`,children:`Codex CLI`})}),(0,Y.jsxs)(De,{className:`space-y-2 text-sm`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connectAgent.codex.body`)}),(0,Y.jsx)($d,{text:`[mcp_servers.objectstack]\nurl = "${r}"`})]})]}),(0,Y.jsxs)(Qe,{children:[(0,Y.jsx)($e,{className:`pb-2`,children:(0,Y.jsxs)(Ee,{className:`flex items-center gap-2 text-base`,children:[(0,Y.jsx)(Lr,{className:`h-4 w-4`}),e(`connectAgent.apiKey.title`),(0,Y.jsx)(V,{variant:`secondary`,children:e(`connectAgent.apiKey.badge`)})]})}),(0,Y.jsxs)(De,{className:`space-y-2 text-sm`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connectAgent.apiKey.body`)}),d?(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-amber-600 dark:text-amber-400`,children:e(`connectAgent.apiKey.showOnce`,{name:d.name})}),(0,Y.jsx)($d,{text:d.key}),(0,Y.jsx)($d,{text:`x-api-key: ${d.key}`}),(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>f(null),children:e(`connectAgent.apiKey.done`)})]}):(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(z,{value:s,onChange:e=>c(e.target.value),placeholder:e(`connectAgent.apiKey.namePlaceholder`),className:`h-8 max-w-56`}),(0,Y.jsx)(B,{size:`sm`,onClick:async()=>{u(!0),m(null);try{let e=await fetch(`${Yd}/api/v1/keys`,{method:`POST`,credentials:`include`,headers:Xd({"content-type":`application/json`}),body:JSON.stringify({name:s.trim()||`agent-key`})}),t=await e.json().catch(()=>({}));if(!e.ok||t?.success===!1)throw Error(t?.error?.message??t?.error??`HTTP ${e.status}`);let n=t?.data??t;f({name:n?.name??s,key:n?.key??``}),c(``)}catch(e){m(e?.message??String(e))}finally{u(!1)}},disabled:l,children:e(l?`connectAgent.apiKey.minting`:`connectAgent.apiKey.mint`)})]}),p&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 text-xs text-destructive`,children:[(0,Y.jsx)(Rn,{className:`h-3.5 w-3.5`}),` `,p]})]})]})]})]}):(0,Y.jsx)(Qe,{children:(0,Y.jsxs)(De,{className:`flex items-center gap-3 py-8 text-muted-foreground`,children:[(0,Y.jsx)(Rn,{className:`h-5 w-5 shrink-0`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`font-medium text-foreground`,children:e(`connectAgent.disabled.title`)}),(0,Y.jsx)(`div`,{className:`text-sm`,children:a||e(`connectAgent.disabled.body`)})]})]})})}kt.register(`mcp:connect-agent`,()=>(0,Y.jsx)(ef,{}),{namespace:`app-shell`,label:`Connect an Agent`,category:`plugin`,inputs:[]});var tf=`/api/v1/cloud/environments/production/sso-open`,nf=`/apps/cloud_control/sys_environment`,rf=`create_environment`;function af(e){let{activeOrganization:t}=u(),n=t?.id,r=(0,J.useMemo)(()=>l(),[]),[i,a]=(0,J.useState)({phase:`loading`});return(0,J.useEffect)(()=>{let t=!1,i=``.replace(/\/+$/,``),o=n?`?organizationId=${encodeURIComponent(n)}`:``;return(async()=>{try{let n=await r(`${i}/api/v1/cloud/environment-entitlements${o}`,{method:`GET`,credentials:`include`});if(!n.ok)throw Error(`entitlements ${n.status}`);let s=(await n.json().catch(()=>null))?.data;if(t)return;if(!s||typeof s!=`object`){a({phase:`unknown`});return}let c=s.hasProductionEnv===!0;a({phase:`ready`,hasProductionEnv:c}),c&&e&&r(`${i}${e}`,{method:`GET`,credentials:`include`}).catch(()=>{})}catch{t||a({phase:`unknown`})}})(),()=>{t=!0}},[r,n,e]),i}function of(e){window.location.href=e}function sf({properties:e}){let{t:n}=rn(),r=t(),i=af(e?.warmUrl),a=e?.openProductionUrl||tf,o=e?.environmentsRoute||nf,s=e?.createAction||rf;if(i.phase===`loading`)return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3`,"data-onboarding":`loading`,children:[(0,Y.jsx)(ut,{className:`h-11 w-44 rounded-md`}),(0,Y.jsx)(ut,{className:`h-11 w-44 rounded-md`})]});let c=i.phase===`ready`&&!i.hasProductionEnv?n(`cloudOnboarding.hintCreate`):n(`cloudOnboarding.hintReady`),l=i.phase===`ready`&&!i.hasProductionEnv;return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,"data-onboarding":i.phase,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3`,children:[l?(0,Y.jsxs)(B,{size:`lg`,onClick:()=>r(wu(o,s)),children:[(0,Y.jsx)(U,{className:`mr-2 h-4 w-4`}),n(`cloudOnboarding.createEnvironment`)]}):(0,Y.jsxs)(B,{size:`lg`,onClick:()=>of(a),children:[(0,Y.jsx)(xi,{className:`mr-2 h-4 w-4`}),n(`cloudOnboarding.openProduction`)]}),(0,Y.jsxs)(B,{size:`lg`,variant:`secondary`,onClick:()=>r(o),children:[(0,Y.jsx)(Oi,{className:`mr-2 h-4 w-4`}),n(`cloudOnboarding.manageEnvironments`)]})]}),(0,Y.jsx)(`p`,{className:`max-w-xl text-center text-sm text-muted-foreground`,children:c})]})}kt.register(`cloud:onboarding-next`,e=>(0,Y.jsx)(sf,{...e}),{namespace:`app-shell`,label:`Cloud Onboarding Next-Step`,category:`plugin`,inputs:[]});function cf({properties:e,className:t}){let{t:n}=rn(),r=Pt(),[i]=(0,J.useState)(()=>l()),a=Du({enabled:!0,dataSource:r,authFetch:i,apiBase:``}),o=e?.plan;return typeof o!=`string`||o===``||a?.source!==`summary`||a.plan!==o?null:(0,Y.jsx)(V,{variant:`secondary`,className:R(t),"data-plan-status":`current`,children:n(`cloudPlanStatus.current`)})}kt.register(`plan-status`,e=>(0,Y.jsx)(cf,{...e}),{namespace:`cloud`,skipFallback:!0,label:`Cloud Plan Status`,category:`plugin`,inputs:[]});var lf=`/api/v1/ai/effective-model`;function uf(e,t){return e===`code-default`?t(`aiModelStatus.sourceCodeDefault`):e===`inherits-conversational`?t(`aiModelStatus.sourceInherits`):e.startsWith(`env:`)?t(`aiModelStatus.sourcePinned`,{source:e.slice(4)}):e===`unknown`?t(`aiModelStatus.sourceUnknown`):e}function df(e){return e.startsWith(`env:`)?`default`:`secondary`}function ff(e){let t=(0,J.useMemo)(()=>l(),[]),[n,r]=(0,J.useState)({phase:`loading`});return(0,J.useEffect)(()=>{let n=!1,i=``.replace(/\/+$/,``);return(async()=>{try{let a=await t(`${i}${e}`,{method:`GET`,credentials:`include`});if(!a.ok){n||r({phase:`error`,status:a.status});return}let o=await a.json().catch(()=>null),s=o?.data??o;if(n)return;if(!s||typeof s!=`object`||!s.conversational){r({phase:`error`});return}r({phase:`ready`,report:s})}catch{n||r({phase:`error`})}})(),()=>{n=!0}},[t,e]),n}function pf({label:e,model:t,source:n,t:r}){return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-2 border-b border-border last:border-b-0`,children:[(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`code`,{className:`text-sm font-medium`,children:t??`—`}),(0,Y.jsx)(V,{variant:df(n),children:uf(n,r)})]})]})}function mf({properties:e}){let{t}=rn(),n=ff(e?.effectiveModelUrl||lf);if(n.phase===`loading`)return(0,Y.jsxs)(`div`,{className:`space-y-2`,"data-ai-model-status":`loading`,children:[(0,Y.jsx)(ut,{className:`h-5 w-3/4 rounded`}),(0,Y.jsx)(ut,{className:`h-10 w-full rounded`}),(0,Y.jsx)(ut,{className:`h-10 w-full rounded`})]});if(n.phase===`error`)return(0,Y.jsx)(`div`,{className:`text-sm text-muted-foreground`,"data-ai-model-status":`error`,children:n.status?t(`aiModelStatus.readFailedWithStatus`,{status:n.status}):t(`aiModelStatus.readFailed`)});let{report:r}=n,i=Object.entries(r.overrides).filter(([,e])=>e!=null),a=t(`aiModelStatus.modelUnknown`);return(0,Y.jsxs)(`div`,{className:`space-y-4`,"data-ai-model-status":`ready`,children:[(0,Y.jsxs)(`p`,{className:`text-sm text-foreground`,"data-testid":`ai-model-summary`,children:[t(`aiModelStatus.summary`,{conversational:r.conversational.model??a,conversationalSource:uf(r.conversational.source,t),structured:r.structured.model??a,structuredSource:uf(r.structured.source,t)}),r.routing?(0,Y.jsxs)(Y.Fragment,{children:[` `,t(`aiModelStatus.summaryRouting`,{free:r.routing.free,paid:r.routing.paid})]}):null]}),(0,Y.jsxs)(`div`,{className:`rounded-md border border-border px-3`,children:[(0,Y.jsx)(pf,{label:t(`aiModelStatus.rowConversational`),t,model:r.conversational.model,source:r.conversational.source}),(0,Y.jsx)(pf,{label:t(`aiModelStatus.rowStructured`),t,model:r.structured.model,source:r.structured.source}),(0,Y.jsx)(pf,{label:t(`aiModelStatus.rowReasoning`),t,model:r.reasoningEffort.effective,source:r.reasoningEffort.source})]}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:t(`aiModelStatus.overridesInEffect`)}),i.length===0?(0,Y.jsx)(`span`,{children:t(`aiModelStatus.noOverrides`)}):(0,Y.jsx)(`code`,{children:i.map(([e,t])=>`${e}=${t}`).join(` · `)})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(`aiModelStatus.adapter`),(0,Y.jsxs)(`code`,{children:[r.adapter,r.provider?` / ${r.provider}`:``]})]})]})}kt.register(`cloud:ai-model-status`,e=>(0,Y.jsx)(mf,{...e}),{namespace:`app-shell`,label:`Cloud AI Model Status`,category:`plugin`,inputs:[]});var hf=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}};kt.register(`attachments`,({schema:e,className:t,...n})=>{let r=St(),{user:i}=u(),{designer:a}=hf(n),o=r?.objectName,s=r?.recordId==null?``:String(r.recordId);return!o||!s?null:(0,Y.jsx)(`div`,{className:t,...a,children:(0,Y.jsx)(wa,{objectName:o,recordId:s,dataSource:r?.dataSource,currentUserId:i?.id})})},{namespace:`record`,skipFallback:!0,category:`record`,label:`Attachments`,icon:`Paperclip`,inputs:[{name:`className`,type:`string`}]});var gf=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r}=e||{};return{"data-obj-id":t,"data-obj-type":n,style:r}};kt.register(`search`,({className:e,schema:t,...n})=>{let{t:r}=rn(),[o,s]=(0,J.useState)(``),{objects:c}=wt(),l=Pt(),{appName:u}=i(),{currentAppName:d}=ya(),f=(0,J.useMemo)(()=>c||[],[c]),p=ot(),{results:m,isSearching:h}=Rt({query:o,objects:f,dataSource:l,enabled:!!l,getDisplayName:Ct,fieldReadPolicy:p}),g=`/apps/${u||d||``}`,_=r(`search.placeholder`,{defaultValue:`Search objects, dashboards, pages, reports…`}),v=r(`search.inputAriaLabel`,{defaultValue:`Search objects, dashboards, pages, reports`});return(0,Y.jsxs)(`div`,{className:e,"data-block":`global:search`,role:`search`,...gf(n),children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(Di,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(z,{type:`search`,className:`pl-8`,value:o,"aria-label":v,placeholder:_,onChange:e=>s(e.target.value)})]}),h&&(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:r(`console.commandPalette.searching`,{defaultValue:`Searching…`})}),m.length>0&&(0,Y.jsx)(`ul`,{className:`mt-2 grid gap-2`,"aria-label":r(`console.commandPalette.records`,{defaultValue:`Records`}),children:m.map(e=>{let t=eo(e.icon);return(0,Y.jsx)(`li`,{children:(0,Y.jsx)(a,{to:`${g}/${e.objectName}/record/${e.recordId}`,className:`block rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Y.jsx)(Qe,{className:`hover:bg-accent/50 transition-colors`,children:(0,Y.jsxs)(De,{className:`flex items-center gap-3 p-3`,children:[(0,Y.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-primary/10 text-primary`,children:(0,Y.jsx)(t,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.display}),e.subtitle&&(0,Y.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.subtitle})]}),(0,Y.jsx)(V,{variant:`outline`,className:`shrink-0 text-xs`,children:e.objectLabel})]})})})},`${e.objectName}:${e.recordId}`)})})]})},{namespace:`global`,skipFallback:!0,category:`navigation`,label:`Global Search`,icon:`Search`});var _f=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r}=e||{};return{"data-obj-id":t,"data-obj-type":n,style:r}};kt.register(`notifications`,({className:e,schema:t,...n})=>{let{notifications:r,unreadCount:i,pendingApprovalsCount:a,markAllRead:o,markRead:s,markManyRead:c}=el(),l=zc();return(0,Y.jsx)(`div`,{className:e,"data-block":`global:notifications`,..._f(n),children:(0,Y.jsx)(lc,{notifications:r,unreadCount:i,pendingApprovalsCount:a,activities:l,onMarkAllRead:o,onMarkRead:s,onMarkManyRead:c})})},{namespace:`global`,skipFallback:!0,category:`navigation`,label:`Notifications`,icon:`Bell`});var vf=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r}=e||{};return{"data-obj-id":t,"data-obj-type":n,style:r}};kt.register(`launcher`,({className:e,schema:n,...r})=>{let{t:i}=rn(),a=t(),{apps:o}=wt(),{favorites:s}=Da(),c=(0,J.useMemo)(()=>ka(o),[o]),l=(0,J.useCallback)(e=>a(`/apps/${Aa(e)??e?.name}`),[a]);return(0,Y.jsx)(`nav`,{className:e,"aria-label":i(`console.nav.launcherLabel`,{defaultValue:`App launcher`}),"data-block":`app:launcher`,...vf(r),children:(0,Y.jsx)(Mu,{apps:c,favorites:s,onOpen:l,isAdmin:!1,onBrowseMarketplace:()=>{}})})},{namespace:`app`,skipFallback:!0,category:`navigation`,label:`App Launcher`,icon:`LayoutGrid`});var yf=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r}=e||{};return{"data-obj-id":t,"data-obj-type":n,style:r}},bf=`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-foreground/80 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;kt.register(`menu`,({className:e,schema:t,...n})=>{let{t:r,language:o}=rn(),{apps:c,objects:l}=wt(),{appName:d}=i(),{currentAppName:f}=ya(),{pathname:p,search:m}=s(),{user:h,activeOrganization:g}=u(),_=tl(),v=Na(),{evaluator:y}=ua(),b=(0,J.useCallback)(e=>da(e,y),[y]),{can:x,hasCapabilities:S}=ot(),C=(0,J.useCallback)(e=>e.every(e=>{let t=e.split(`:`);return t.length>=2?x(t[0],t[1]):S([e])||x(e,`read`)}),[x,S]),w=(0,J.useMemo)(()=>new Set((l||[]).map(e=>e?.name).filter(Boolean)),[l]),T=(0,J.useCallback)((e,t)=>e!==`object`||w.size===0||w.has(t),[w]),E=(0,J.useMemo)(()=>{let e=(c||[]).filter(e=>e?.active!==!1);return Oa(e,d??f??null)},[c,d,f]),D=E?.areas??[],O=al([E?.navigation,...D.map(e=>e?.navigation)]),k=(0,J.useMemo)(()=>({evaluateVisibility:b,checkPermission:C,checkCapability:T,checkDocTarget:O,hasActionHandler:!0}),[b,C,T,O]),A=(0,J.useMemo)(()=>{let e=E?.areas||[];if(e.length>0){let t=e.find(e=>Xa(e?.navigation??[],k));if(t)return t.navigation??[]}return E?.navigation??[]},[E,k]),j=E?`/apps/${Aa(E)??E.name}`:``,M=(0,J.useMemo)(()=>({currentUserId:h?.id??null,currentOrgId:g?.id??null}),[h?.id,g?.id]),N=(0,J.useMemo)(()=>Ja(A,p,m,j,M)?.id??null,[A,p,m,j,M]),P=(0,J.useCallback)(e=>Ya(e,r,v,o),[r,v,o]);function ee(e){if(!b(e.visible)||e.requiredPermissions?.length&&!C(e.requiredPermissions)||e.requiresObject&&!T(`object`,e.requiresObject)||e.requiresService&&!T(`service`,e.requiresService)||e.type===`doc`&&O&&!O({book:e.book,doc:e.doc}))return null;if(e.type===`separator`)return(0,Y.jsx)(`li`,{"aria-hidden":`true`,className:`py-1`,children:(0,Y.jsx)(Oe,{})},e.id);if(e.type===`group`){let t=(e.children??[]).map(e=>ee(e)).filter(Boolean);return t.length===0?null:(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`div`,{className:`px-2 py-1 text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:P(e)}),(0,Y.jsx)(`ul`,{className:`ml-2 grid gap-0.5 border-l pl-2`,children:t})]},e.id)}let t=eo(e.icon),n=P(e),r=e.badge!==void 0&&e.badge!==null&&e.badge!==``?(0,Y.jsx)(V,{variant:e.badgeVariant??`secondary`,className:`ml-auto shrink-0`,children:e.badge}):null,i=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(t,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate`,children:n}),r]}),o=N!==null&&e.id===N,s=R(bf,o&&`bg-accent font-medium text-foreground`);if(e.type===`action`)return(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{type:`button`,className:s,onClick:()=>_(e),children:i})},e.id);let{href:c,external:l}=qa(e,j,M);return(0,Y.jsx)(`li`,{children:l?(0,Y.jsx)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,className:s,"aria-current":o?`page`:void 0,children:i}):(0,Y.jsx)(a,{to:c,className:s,"aria-current":o?`page`:void 0,children:i})},e.id)}let F=A.map(e=>ee(e)).filter(Boolean);return(0,Y.jsx)(`nav`,{className:e,"aria-label":r(`console.nav.menuLabel`,{defaultValue:`App navigation`}),"data-block":`nav:menu`,...yf(n),children:F.length>0?(0,Y.jsx)(`ul`,{className:`grid gap-0.5`,children:F}):(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-sm text-muted-foreground`,children:r(`console.nav.menuEmpty`,{defaultValue:`This app has no navigation entries you can open.`})})})},{namespace:`nav`,skipFallback:!0,category:`navigation`,label:`Nav Menu`,icon:`Menu`});function xf(){za({type:`__object_field`,label:`Field`,anchors:[{anchorType:`object`,source:`embedded`,editAs:`field`,embeddedPath:`fields`,extract:e=>Sf(e.fields),groupLabel:`Fields`,order:5}]}),za({type:`__object_index`,label:`Index`,anchors:[{anchorType:`object`,source:`embedded`,editAs:`index`,embeddedPath:`indexes`,extract:e=>{let t=e.indexes;return Array.isArray(t)?t.map((e,t)=>{let n=Array.isArray(e.fields)?e.fields.join(`,`):``;return{name:n?`idx_${n}`:`index_${t}`,...e}}):[]},groupLabel:`Indexes`,order:10}]}),za({type:`__object_validation`,label:`Embedded validation`,anchors:[{anchorType:`object`,source:`embedded`,editAs:`validation`,embeddedPath:`validations`,extract:e=>Sf(e.validations),groupLabel:`Embedded Validations`,order:15}]}),za({type:`hook`,anchors:[{anchorType:`object`,match:Ra(`object`),groupLabel:`Hooks`,order:20}],createFields:[`label`,`name`,`object`,`description`],createDerive:[{from:`label`,to:`name`,transform:`slugify`,untilUserEdits:!0}],createSchema:{type:`object`,required:[`label`,`name`,`object`],properties:{label:{type:`string`,title:`Label`,description:`Human-readable hook name.`},name:{type:`string`,title:`Name`,description:`Hook key (snake_case).`,pattern:`^[a-z_][a-z0-9_]*$`},object:{type:`string`,title:`Object`,widget:`ref:object`,description:`The object whose row lifecycle (beforeInsert / afterUpdate / …) this hook runs on.`},description:{type:`string`,title:`Description`,description:`What this hook does.`}}},createDefaults:{events:[]}}),za({type:`page`,anchors:[{anchorType:`object`,match:Ra(`object`),groupLabel:`Pages`,order:40}],createFields:[`label`,`name`,`object`,`type`,`kind`],createDerive:[{from:`label`,to:`name`,transform:`slugify`,untilUserEdits:!0}],createSchema:{type:`object`,required:[`label`,`name`,`type`],properties:{label:{type:`string`,title:`Label`,description:`Human-readable page title.`},name:{type:`string`,title:`Name`,description:`Page key (snake_case).`,pattern:`^[a-z_][a-z0-9_]*$`},type:{type:`string`,title:`Page type`,enum:[`list`,`record`,`home`,`app`,`utility`],default:`list`,description:`List / Interface page = a data view (Airtable-style: columns, filters, visualizations). Record page renders one object record.`},object:{type:`string`,title:`Object`,widget:`ref:object`,description:`The object this page reads from — the data source for a list page, or the record object for a record page.`},kind:{type:`string`,title:`Kind`,enum:[`full`,`slotted`],default:`full`,description:`full = the whole page; slotted = override only named slots of the default.`}}},createDefaults:{type:`list`,kind:`full`,regions:[]},createSeed:async(e,{client:t})=>{if(e?.type===`list`)return e?.object?{interfaceConfig:{source:String(e.object)}}:{};if(e?.type!==`record`||!e?.object)return{};try{let r=await t.get(`object`,String(e.object));if(!r||typeof r!=`object`)return{};let{buildDefaultPageSchema:i}=await n(async()=>{let{buildDefaultPageSchema:e}=await import(`./plugin-grid-Cp4RKtMJ.js`).then(e=>e.i);return{buildDefaultPageSchema:e}},__vite__mapDeps([0]),import.meta.url),a=i(r),o={};return Array.isArray(a?.regions)&&a.regions.length&&(o.regions=a.regions),a?.template&&(o.template=a.template),o}catch{return{}}}}),za({type:`view`,anchors:[{anchorType:`object`,match:Ra([`object`,`config.data.object`]),groupLabel:`Views`,order:30}],createFields:[`label`,`name`,`object`,`viewKind`,`kind`,`formType`],createDerive:[{from:`label`,to:`name`,transform:`slugify`,untilUserEdits:!0}],createSchema:{type:`object`,required:[`label`,`name`,`object`,`viewKind`],properties:{label:{type:`string`,title:`Label`,description:`Human-readable view name.`},name:{type:`string`,title:`Name`,description:`View key (snake_case). Qualified to <object>.<key> on save.`,pattern:`^[a-z_][a-z0-9_]*$`},object:{type:`string`,title:`Object`,widget:`ref:object`,description:`The object this view displays.`},viewKind:{type:`string`,title:`View family`,enum:[`list`,`form`],default:`list`,description:`List views show many records as a collection (grid, kanban, …). Form views show one record as a field layout (simple, tabbed, …).`},kind:{type:`string`,title:`List layout`,enum:[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`chart`],default:`grid`,description:`Pick a starter layout. Switch later in the designer.`,visibleOn:`data.viewKind == 'list'`},formType:{type:`string`,title:`Form layout`,enum:[`simple`,`tabbed`,`wizard`,`split`,`drawer`,`modal`],default:`simple`,description:`Pick a starter form layout. Switch later in the designer.`,visibleOn:`data.viewKind == 'form'`}}},createBuildBody:e=>{let t=String(e.object??``),n=String(e.name??``),r=n.includes(`.`)||!t?n:`${t}.${n}`,i=e.viewKind===`form`,a=e.formType||`simple`,o=i?{type:a,data:{provider:`object`,object:t},sections:a===`wizard`?[{label:`Step 1`,fields:[]}]:[]}:{type:e.kind||`grid`,columns:[],data:{provider:`object`,object:t}};return{name:r,object:t,viewKind:i?`form`:`list`,label:e.label,config:o}}}),za({type:`flow`,anchors:[{anchorType:`object`,match:Ra([`object`,`on.object`,`trigger.object`]),groupLabel:`Flows`,order:50}],createFields:[`label`,`name`,`type`,`description`],createDerive:[{from:`label`,to:`name`,transform:`slugify`,untilUserEdits:!0}],createDefaults:{type:`autolaunched`,nodes:[],edges:[]}}),za({type:`permission`,anchors:[{anchorType:`object`,match:(e,t)=>{let n=e?.objects;return!!n&&typeof n==`object`&&t in n},groupLabel:`Permissions`,order:60}],createFields:[`label`,`name`],createDerive:[{from:`label`,to:`name`,transform:`slugify`,untilUserEdits:!0}],createDefaults:{objects:{}}}),za({type:`action`,anchors:[{anchorType:`object`,match:Ra([`object`,`target.object`,`on.object`]),groupLabel:`Actions`,order:55}],createFields:[`label`,`name`,`objectName`,`icon`],createDerive:[{from:`label`,to:`name`,transform:`slugify`,untilUserEdits:!0}],createSchema:{type:`object`,required:[`label`,`name`],properties:{label:{type:`string`,title:`Label`,description:`Human-readable action name.`},name:{type:`string`,title:`Name`,description:`Action key (snake_case). Used in URLs.`,pattern:`^[a-z_][a-z0-9_]*$`},objectName:{type:`string`,title:`Object`,widget:`ref:object`,description:`The object this action is bound to. Leave empty for a global / record-scoped action.`},icon:{type:`string`,title:`Icon`,widget:`icon`,description:`Optional icon shown on the action button.`}}},createDefaults:{type:`script`,body:{language:`js`,source:`return { success: true };`}}}),za({type:`dashboard`,anchors:[{anchorType:`object`,match:Ra([`object`,`data.object`]),groupLabel:`Dashboards`,order:80}],createFields:[`label`,`name`,`description`],createDerive:[{from:`label`,to:`name`,transform:`slugify`,untilUserEdits:!0}],createDefaults:{widgets:[]}}),za({type:`report`,anchors:[{anchorType:`object`,match:Ra([`object`,`data.object`]),groupLabel:`Reports`,order:81}],createFields:[`label`,`name`,`description`],createDerive:[{from:`label`,to:`name`,transform:`slugify`,untilUserEdits:!0}],createDefaults:{type:`summary`,drilldown:!0}}),za({type:`object`,iconName:`database`,domain:`data`,createFields:[`label`,`pluralLabel`,`name`,`description`],createDerive:[{from:`label`,to:`name`,transform:`slugify`,untilUserEdits:!0},{from:`label`,to:`pluralLabel`,transform:`plural-en`,untilUserEdits:!0}],createDefaults:{fields:{}},searchableFields:[`name`,`label`,`pluralLabel`,`description`],listColumns:[{key:`name`,label:`Name`,width:`24%`},{key:`label`,label:`Label`,width:`22%`},{key:`pluralLabel`,label:`Plural`,width:`22%`},{key:`fields`,label:`Fields`,width:`90px`,render:e=>e==null?`—`:Array.isArray(e)?e.length:typeof e==`object`?Object.keys(e).length:0},{key:`description`,label:`Description`}]})}function Sf(e){return Array.isArray(e)?e:e&&typeof e==`object`?Object.entries(e).map(([e,t])=>({name:e,...t&&typeof t==`object`?t:{}})):[]}var Cf={name:{type:`string`,title:`Name`,description:`Machine name. snake_case, used as the URL path and DB key.`,pattern:`^[a-z_][a-z0-9_]*$`},label:{type:`string`,title:`Label`,description:`Human-readable display name.`},description:{type:`string`,title:`Description`,format:`multiline`}},wf={position:{type:`object`,title:`Position`,required:[`name`],properties:{...Cf}},permission:{type:`object`,title:`Permission`,required:[`id`,`resource`,`actions`,`description`],properties:{id:{type:`string`,title:`ID`,description:`Stable identifier (e.g. crm.account.read).`},resource:{type:`string`,title:`Resource`,description:`What this permission applies to.`,enum:[`data.object`,`data.record`,`data.field`,`ui.view`,`ui.dashboard`,`ui.report`,`system.config`,`system.plugin`,`system.api`,`system.service`,`storage.file`,`storage.database`,`network.http`,`network.websocket`,`process.spawn`,`process.env`]},actions:{type:`array`,title:`Actions`,description:`Permitted operations on the resource.`,items:{type:`string`,enum:[`create`,`read`,`update`,`delete`,`execute`,`admin`,`manage`,`configure`,`import`,`export`,`share`]}},description:{type:`string`,title:`Description`,description:`Why this permission exists (shown in admin UIs).`},scope:{type:`string`,title:`Scope`,enum:[`tenant`,`user`,`plugin`,`global`,`resource`],default:`tenant`},required:{type:`boolean`,title:`Required`,description:`Must be present for the holder to function.`},justification:{type:`string`,title:`Justification`}}},translation:{type:`object`,title:`Translation Bundle`,required:[`name`],properties:{name:{...Cf.name,description:`Bundle id (e.g. zh_CN, en_US, package-locale).`},label:Cf.label,description:Cf.description,locale:{type:`string`,title:`Locale`,description:`BCP-47 tag, e.g. en, zh-Hans, ja-JP.`},strings:{type:`object`,title:`Strings`,description:`Key → translated string map.`}}},tool:{type:`object`,title:`AI Tool`,required:[`name`],properties:{...Cf,kind:{type:`string`,title:`Kind`,enum:[`function`,`http`,`mcp`]},inputSchema:{type:`object`,title:`Input Schema (JSON Schema)`},outputSchema:{type:`object`,title:`Output Schema (JSON Schema)`}}},skill:{type:`object`,title:`AI Skill`,required:[`name`],properties:{...Cf,instructions:{type:`string`,title:`Instructions`,format:`multiline`},tools:{type:`array`,title:`Tools`,items:{type:`string`}},surface:{type:`string`,title:`Surface`,description:`Agent surface this skill binds to (ADR-0063).`,enum:[`ask`,`build`,`both`]},triggerPhrases:{type:`array`,title:`Trigger Phrases`,description:`Natural-language phrases that activate this skill.`,items:{type:`string`}},triggerConditions:{type:`array`,title:`Trigger Conditions`,description:`Programmatic activation conditions (context field / operator / value). The activation-critical field — previously only hand-editable (objectstack-ai/objectstack#1878 / objectstack-ai/objectstack#1895).`,items:{type:`object`,properties:{field:{type:`string`,title:`Field`},operator:{type:`string`,title:`Operator`,enum:[`eq`,`neq`,`in`,`not_in`,`contains`]},value:{type:`string`,title:`Value`}}}}}},app:{type:`object`,title:`Application`,required:[`name`],properties:{...Cf,icon:{type:`string`,title:`Icon`},navigation:{type:`array`,title:`Navigation`,items:{type:`object`}}}},page:{type:`object`,title:`Page`,required:[`name`],properties:{...Cf,route:{type:`string`,title:`Route`,description:`URL path under the app.`},layout:{type:`string`,title:`Layout`}}},view:{type:`object`,title:`View`,required:[`name`],properties:{...Cf,type:{type:`string`,title:`View Type`,enum:[`grid`,`kanban`,`calendar`,`gantt`,`simple`,`tabbed`,`wizard`,`split`,`drawer`,`modal`]}}},dashboard:{type:`object`,title:`Dashboard`,required:[`name`],properties:{...Cf,widgets:{type:`array`,title:`Widgets`,items:{type:`object`}}}},report:{type:`object`,title:`Report`,required:[`name`],properties:{...Cf,object:{type:`string`,title:`Object`},filters:{type:`array`,title:`Filters`,items:{type:`object`}}}},book:{type:`object`,title:`Documentation Book`,required:[`name`,`groups`],properties:{...Cf,slug:{type:`string`,title:`Slug`,description:`Portal URL segment; defaults to the name without its package prefix.`},icon:{type:`string`,title:`Icon`},order:{type:`number`,title:`Order`,description:`Orders books within the portal.`},audience:{title:`Audience`,description:`Access audience. 'org' (default) inherits the package grant; 'public' is anonymously readable; { permissionSet } gates by a permission set the reader must hold (ADR-0090).`,oneOf:[{type:`string`,enum:[`org`,`public`]},{type:`object`,title:`Permission-set gated`,properties:{permissionSet:{type:`string`,title:`Permission set`}},required:[`permissionSet`]}]},groups:{type:`array`,title:`Groups (spine)`,description:`Ordered sections. Membership is derived from each group's include rule — edit the structure visually in the Preview tab.`,items:{type:`object`,required:[`key`,`label`],properties:{key:{type:`string`,title:`Key`,pattern:`^[a-z][a-z0-9_]*$`},label:{type:`string`,title:`Label`},order:{type:`number`,title:`Order`},include:{title:`Include rule`,description:`Glob over doc names (e.g. crm_guide_*) or { tag }.`},package:{type:`string`,title:`Package scope`},pages:{type:`array`,title:`Explicit pages (override)`,items:{}}}}}}},email_template:{type:`object`,title:`Email Template`,required:[`name`,`label`,`subject`,`bodyHtml`],properties:{...Cf,category:{type:`string`,title:`Category`,enum:[`auth`,`notification`,`workflow`,`marketing`,`custom`],default:`custom`},locale:{type:`string`,title:`Locale`,default:`en-US`,description:`BCP-47 tag (en-US, zh-CN, …)`},subject:{type:`string`,title:`Subject`,description:`Supports {{var.path}} interpolation`},bodyHtml:{type:`string`,title:`HTML Body`,format:`multiline`},bodyText:{type:`string`,title:`Plain-Text Body`,format:`multiline`},variables:{type:`array`,title:`Variables`,items:{type:`object`}},fromOverride:{type:`object`,title:`From Override`},replyTo:{type:`string`,title:`Reply-To`},active:{type:`boolean`,title:`Active`,default:!0},isSystem:{type:`boolean`,title:`System Template`,default:!1}}}};function Tf(){for(let[e,t]of Object.entries(wf))za({type:e,defaultSchema:t,fieldOrder:[`name`,`label`,`description`]});za({type:`doc`,createFields:[`label`,`name`,`description`],createDerive:[{from:`label`,to:`name`,transform:`slugify`}],createDefaults:{content:``}})}function Ef({status:e,reason:t}){if(!e)return null;let n=(e,n)=>(0,Y.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium ${e}`,title:t||void 0,children:n});switch(e){case`ok`:return n(`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,`connected`);case`error`:return n(`bg-destructive/10 text-destructive`,`connect failed`);case`blocked`:return n(`bg-amber-500/10 text-amber-600 dark:text-amber-400`,`blocked by policy`);case`unvalidated`:return n(`bg-muted text-muted-foreground`,`not connected`);default:return n(`bg-muted text-muted-foreground`,e)}}var Df=[{value:`managed`,label:`Managed (ObjectStack owns the schema)`},{value:`external`,label:`External (read existing schema as-is)`},{value:`validate-only`,label:`Validate only`}],Of=``.replace(/\/+$/,``),kf=e=>e.format===`password`;function Af(e){let t=e?.configSchema?.properties??{},n={};for(let[e,r]of Object.entries(t))kf(r)||r.default!==void 0&&(n[e]=r.default);return n}function jf(e){let t=J.useMemo(()=>l(),[]),n=sa(),r=$o(),[i,a]=J.useState([]),[o,s]=J.useState(!0),[c,u]=J.useState(null),d=J.useCallback(async(e,n)=>{let r=await t(`${Of}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`},...n}),i=await r.text(),a=i;try{a=JSON.parse(i)}catch{}if(!r.ok){let e=a&&typeof a.error==`object`&&a.error?.message||(a&&typeof a.error==`string`?a.error:void 0)||a&&a.message||`HTTP ${r.status}`;throw Error(e)}return a&&typeof a.success==`boolean`&&`data`in a?a.data:a},[t]),f=J.useCallback(async()=>{s(!0);try{let e=await d(`/api/v1/datasources`);a(Array.isArray(e?.datasources)?e.datasources:[])}catch(e){on.error(`Load datasources: ${e.message}`),a([])}finally{s(!1)}},[d]);J.useEffect(()=>{f()},[f]);let p=async e=>{u(`test:${e}`);try{let t=await d(`/api/v1/datasources/${encodeURIComponent(e)}/test`,{method:`POST`,body:`{}`});on.success(t?.ok===!1?`${e}: ${t?.error??`failed`}`:`${e}: connection ok${t?.latencyMs==null?``:` (${t.latencyMs}ms)`}`),f()}catch(t){on.error(`${e}: ${t.message}`)}finally{u(null)}},m=async e=>{if(window.confirm(`Delete datasource “${e}”? This cannot be undone.`)){u(`del:${e}`);try{await d(`/api/v1/datasources/${encodeURIComponent(e)}`,{method:`DELETE`}),on.success(`Deleted ${e}.`),f()}catch(t){on.error(`Delete ${e}: ${t.message}`)}finally{u(null)}}},[h,g]=J.useState([]),[_,v]=J.useState(!1),[y,b]=J.useState(null),[x,S]=J.useState(null),[C,w]=J.useState(!1),[T,E]=J.useState(!1),[D,O]=J.useState(null),[k,A]=J.useState(!1),j=J.useCallback(async()=>{if(h.length)return h;try{let e=await d(`/api/v1/datasources/drivers`),t=Array.isArray(e?.drivers)?e.drivers:[];return g(t),t}catch(e){return on.error(`Load drivers: ${e.message}`),[]}},[d,h]),M=J.useMemo(()=>h.find(e=>e.id===x?.driver),[h,x?.driver]),N=async()=>{let e=await j(),t=e.find(e=>e.id!==`memory`)??e[0];b(null),w(!1),O(null),S({name:``,label:``,driver:t?.id??``,schemaMode:`managed`,storedSchemaMode:null,config:Af(t),secret:``}),v(!0)},P=async e=>{let t=await j();u(`edit:${e.name}`);try{let n=(await d(`/api/v1/datasources/${encodeURIComponent(e.name)}`))?.datasource??{};b(e.name),w(!!n.hasSecret),O(null),S({name:n.name??e.name,label:n.label??``,driver:n.driver??e.driver??t[0]?.id??``,schemaMode:n.schemaMode??`managed`,storedSchemaMode:n.schemaMode??`managed`,config:{...n.config??{}},secret:``}),v(!0)}catch(t){on.error(`Open ${e.name}: ${t.message}`)}finally{u(null)}},ee=e=>{S(t=>t&&{...t,driver:e,config:Af(h.find(t=>t.id===e)),secret:``}),O(null)},F=(e,t)=>S(n=>n&&{...n,config:{...n.config,[e]:t}}),te=e=>{let t={label:e.label||void 0,driver:e.driver,schemaMode:e.schemaMode,config:e.config};return e.schemaMode!==`managed`&&(e.storedSchemaMode===null||e.storedSchemaMode===`managed`)&&(t.external={}),e.secret&&(t.secret=e.secret),t},ne=async()=>{if(x){A(!0),O(null);try{let e=await d(`/api/v1/datasources/test`,{method:`POST`,body:JSON.stringify({driver:x.driver,config:x.config,...x.secret?{secret:x.secret}:{}})}),t=e?.result??e;t?.ok===!1?O({ok:!1,text:t?.error??`Connection failed`}):O({ok:!0,text:`Connection ok${t?.latencyMs==null?``:` (${t.latencyMs}ms)`}`})}catch(e){O({ok:!1,text:e.message})}finally{A(!1)}}},re=async()=>{if(x){E(!0);try{y?(await d(`/api/v1/datasources/${encodeURIComponent(y)}`,{method:`PATCH`,body:JSON.stringify(te(x))}),on.success(`Updated ${y}.`)):(await d(`/api/v1/datasources`,{method:`POST`,body:JSON.stringify({name:x.name,...te(x)})}),on.success(`Created ${x.name}.`)),v(!1),f()}catch(e){on.error(`Save: ${e.message}`)}finally{E(!1)}}},ie=y?!0:/^[a-z_][a-z0-9_]*$/.test(x?.name??``),ae=!!x&&!!x.driver&&ie&&!T,[oe,I]=J.useState(null),[se,ce]=J.useState(null),[le,ue]=J.useState(new Set),[de,fe]=J.useState(!1),pe=async e=>{I(e),ce(null),ue(new Set);try{let t=await d(`/api/v1/datasources/${encodeURIComponent(e)}/remote-tables`);ce(Array.isArray(t?.tables)?t.tables:[])}catch(t){on.error(`Introspect ${e}: ${t.message}`),ce([])}},me=e=>ue(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),ge=async()=>{if(!oe||le.size===0)return;fe(!0);let e=0,t=[];for(let r of le)try{let{draft:t}=await d(`/api/v1/datasources/${encodeURIComponent(oe)}/object-draft`,{method:`POST`,body:JSON.stringify({table:r})});await n.save(`object`,t.name,t.definition),e+=1}catch(e){t.push(`${r}: ${e.message}`)}fe(!1),e&&on.success(`Synced ${e} object${e>1?`s`:``} from ${oe}.`),t.length&&on.error(`Failed: ${t.join(`; `)}`),I(null)},_e=(e,t)=>{let n=t.title||e,i=(M?.configSchema?.required??[]).includes(e);if(kf(t))return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(L,{className:`text-xs`,children:[n,i&&!y?` *`:``]}),(0,Y.jsx)(z,{type:`password`,value:x?.secret??``,placeholder:y&&C?`•••••••• (leave blank to keep)`:``,onChange:e=>S(t=>t&&{...t,secret:e.target.value})}),t.description&&(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:t.description})]},e);let a=x?.config[e];if(t.type===`boolean`)return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-1`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(L,{className:`text-xs`,children:n}),t.description&&(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:t.description})]}),(0,Y.jsx)(rt,{checked:!!a,onCheckedChange:t=>F(e,t)})]},e);if(Array.isArray(t.enum))return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(L,{className:`text-xs`,children:[n,i?` *`:``]}),(0,Y.jsxs)(Pe,{value:a==null?``:String(a),onValueChange:t=>F(e,t),children:[(0,Y.jsx)(he,{children:(0,Y.jsx)(Ze,{placeholder:G(`engine.form.selectEllipsis`,r)})}),(0,Y.jsx)(Ke,{children:t.enum.map(e=>(0,Y.jsx)(vt,{value:String(e),children:String(e)},String(e)))})]})]},e);let o=t.type===`number`||t.type===`integer`;return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(L,{className:`text-xs`,children:[n,i?` *`:``]}),(0,Y.jsx)(z,{type:o?`number`:`text`,value:a==null?``:String(a),onChange:t=>F(e,o?t.target.value===``?void 0:Number(t.target.value):t.target.value)}),t.description&&(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:t.description})]},e)};return(0,Y.jsxs)(`div`,{className:`mx-auto max-w-4xl px-6 py-8`,children:[(0,Y.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold`,children:[(0,Y.jsx)(nr,{className:`h-5 w-5`}),` Datasources`]}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Connect external databases and sync their tables in as objects.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:()=>void f(),disabled:o,children:[(0,Y.jsx)(vi,{className:`mr-1.5 h-4 w-4`+(o?` animate-spin`:``)}),` Refresh`]}),(0,Y.jsxs)(B,{size:`sm`,onClick:()=>void N(),children:[(0,Y.jsx)(U,{className:`mr-1.5 h-4 w-4`}),` New datasource`]})]})]}),o?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-sm text-muted-foreground`,children:[(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`}),` Loading…`]}):i.length===0?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-dashed bg-muted/20 py-16 text-center text-sm text-muted-foreground`,children:[`No datasources yet. Click `,(0,Y.jsx)(`span`,{className:`font-medium`,children:`New datasource`}),` to connect one.`]}):(0,Y.jsx)(`div`,{className:`divide-y rounded-lg border bg-card`,children:i.map(e=>{let t=e.origin===`code`;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,Y.jsx)(nr,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.label||e.name}),(0,Y.jsx)(`code`,{className:`text-[11px] text-muted-foreground`,children:e.name})]}),(0,Y.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono`,children:e.driver}),(0,Y.jsx)(Ef,{status:e.status,reason:e.statusReason}),e.origin&&(0,Y.jsxs)(`span`,{children:[`· `,e.origin]})]}),e.statusReason&&(e.status===`error`||e.status===`blocked`)&&(0,Y.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,title:e.statusReason,children:e.statusReason})]}),(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,disabled:c===`test:${e.name}`,onClick:()=>void p(e.name),children:[c===`test:${e.name}`?(0,Y.jsx)(H,{className:`mr-1.5 h-4 w-4 animate-spin`}):(0,Y.jsx)(mi,{className:`mr-1.5 h-4 w-4`}),` Test`]}),(0,Y.jsxs)(B,{variant:`secondary`,size:`sm`,onClick:()=>void pe(e.name),children:[(0,Y.jsx)(yn,{className:`mr-1.5 h-4 w-4`}),` Sync objects`]}),!t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,title:`Edit`,disabled:c===`edit:${e.name}`,onClick:()=>void P(e),children:c===`edit:${e.name}`?(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`}):(0,Y.jsx)(di,{className:`h-4 w-4`})}),(0,Y.jsx)(B,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-destructive hover:text-destructive`,title:`Delete`,disabled:c===`del:${e.name}`,onClick:()=>void m(e.name),children:c===`del:${e.name}`?(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`}):(0,Y.jsx)(Ki,{className:`h-4 w-4`})})]})]},e.name)})}),(0,Y.jsx)(lt,{open:_,onOpenChange:e=>{e||v(!1)},children:(0,Y.jsxs)(Re,{className:`max-w-lg`,children:[(0,Y.jsxs)(Te,{children:[(0,Y.jsx)(ke,{children:y?`Edit “${y}”`:`New datasource`}),(0,Y.jsx)(Be,{children:y?`Update the connection. Leave the credential blank to keep the current one.`:`Connect an external database. Credentials are encrypted and never stored in metadata.`})]}),x&&(0,Y.jsxs)(`div`,{className:`max-h-[60vh] space-y-3 overflow-y-auto pr-1`,children:[!y&&(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs`,children:`Name *`}),(0,Y.jsx)(z,{value:x.name,placeholder:`my_database`,onChange:e=>S(t=>t&&{...t,name:e.target.value})}),!ie&&x.name.length>0&&(0,Y.jsx)(`p`,{className:`text-[11px] text-destructive`,children:`Lowercase letters, digits, and underscores; must not start with a digit.`})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs`,children:`Label`}),(0,Y.jsx)(z,{value:x.label,placeholder:`Human-friendly name`,onChange:e=>S(t=>t&&{...t,label:e.target.value})})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs`,children:`Driver *`}),(0,Y.jsxs)(Pe,{value:x.driver,onValueChange:ee,disabled:!!y,children:[(0,Y.jsx)(he,{children:(0,Y.jsx)(Ze,{placeholder:`Choose a driver`})}),(0,Y.jsx)(Ke,{children:h.map(e=>(0,Y.jsx)(vt,{value:e.id,children:e.label},e.id))})]}),M?.description&&(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:M.description})]}),Object.entries(M?.configSchema?.properties??{}).map(([e,t])=>_e(e,t)),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs`,children:`Schema mode`}),(0,Y.jsxs)(Pe,{value:x.schemaMode,onValueChange:e=>S(t=>t&&{...t,schemaMode:e}),children:[(0,Y.jsx)(he,{children:(0,Y.jsx)(Ze,{})}),(0,Y.jsx)(Ke,{children:Df.map(e=>(0,Y.jsx)(vt,{value:e.value,children:e.label},e.value))})]})]}),D&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs `+(D.ok?`text-emerald-600`:`text-destructive`),children:[D.ok?(0,Y.jsx)(zn,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(Wn,{className:`h-3.5 w-3.5`}),D.text]})]}),(0,Y.jsxs)(Ue,{className:`gap-2 sm:justify-between`,children:[(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,disabled:!x?.driver||k,onClick:()=>void ne(),children:[k?(0,Y.jsx)(H,{className:`mr-1.5 h-4 w-4 animate-spin`}):(0,Y.jsx)(mi,{className:`mr-1.5 h-4 w-4`}),` Test connection`]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>v(!1),children:`Cancel`}),(0,Y.jsxs)(B,{size:`sm`,disabled:!ae,onClick:()=>void re(),children:[T&&(0,Y.jsx)(H,{className:`mr-1.5 h-4 w-4 animate-spin`}),y?`Save changes`:`Create datasource`]})]})]})]})}),(0,Y.jsx)(lt,{open:!!oe,onOpenChange:e=>{e||I(null)},children:(0,Y.jsxs)(Re,{className:`max-w-lg`,children:[(0,Y.jsxs)(Te,{children:[(0,Y.jsxs)(ke,{children:[`Sync objects from “`,oe,`”`]}),(0,Y.jsx)(Be,{children:`Pick the remote tables to import as objects. Each becomes an object definition.`})]}),se==null?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 py-8 text-sm text-muted-foreground`,children:[(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`}),` Introspecting…`]}):se.length===0?(0,Y.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No remote tables found on this datasource.`}):(0,Y.jsx)(`div`,{className:`max-h-[50vh] space-y-1 overflow-y-auto`,children:se.map(e=>{let t=e.schema?`${e.schema}.${e.name}`:e.name;return(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-accent`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:le.has(e.name),onChange:()=>me(e.name),className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`flex-1`,children:t}),e.columnCount!=null&&(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[e.columnCount,` cols`]})]},t)})}),(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center justify-end gap-2`,children:[(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>I(null),children:`Cancel`}),(0,Y.jsxs)(B,{size:`sm`,disabled:de||le.size===0,onClick:()=>void ge(),children:[de?(0,Y.jsx)(H,{className:`mr-1.5 h-4 w-4 animate-spin`}):(0,Y.jsx)(yn,{className:`mr-1.5 h-4 w-4`}),`Create `,le.size||``,` object`,le.size===1?``:`s`]})]})]})})]})}var Mf=!1;function Nf(){Mf||(Mf=!0,za({type:`datasource`,label:`Datasources`,domain:`data`,ListPage:jf}))}function X({toolbar:e,children:t}){return(0,Y.jsxs)(`div`,{className:`rounded-lg border bg-background overflow-hidden flex flex-col h-full`,children:[e!=null&&(0,Y.jsx)(`div`,{className:`flex items-center justify-end border-b bg-muted/20 px-2 py-1 min-h-[32px]`,children:e}),(0,Y.jsx)(`div`,{className:`bg-background flex-1 min-h-0 overflow-auto`,children:t})]})}function Pf({tone:e=`info`,children:t}){return(0,Y.jsxs)(`div`,{className:`m-4 rounded border p-3 text-sm flex items-start gap-2 ${e===`warn`?`text-amber-800 bg-amber-50 border-amber-200`:e===`error`?`text-destructive bg-destructive/5 border-destructive/30`:`text-muted-foreground border-muted`}`,children:[e!==`info`&&(0,Y.jsx)(Rn,{className:`h-4 w-4 mt-0.5 shrink-0`}),(0,Y.jsx)(`div`,{className:`flex-1`,children:t})]})}function Ff({icon:e,title:t,description:n,action:r,tone:i=`info`}){let a=i===`warn`?`text-amber-700 bg-amber-50/40 border-amber-200/60`:`text-muted-foreground border-dashed border-muted-foreground/25 bg-muted/10`,o=e??(0,Y.jsx)(Pr,{className:`h-8 w-8 opacity-50`});return(0,Y.jsx)(`div`,{className:`h-full w-full flex items-center justify-center p-6`,children:(0,Y.jsxs)(`div`,{className:`max-w-md w-full rounded-lg border ${a} px-6 py-10 flex flex-col items-center gap-3 text-center`,children:[(0,Y.jsx)(`div`,{className:`text-foreground/60`,children:o}),(0,Y.jsx)(`div`,{className:`text-sm font-medium text-foreground/90`,children:t}),n&&(0,Y.jsx)(`div`,{className:`text-xs leading-relaxed`,children:n}),r&&(0,Y.jsx)(`div`,{className:`mt-1`,children:r})]})})}function If(){let e=$o();return(0,Y.jsx)(`div`,{className:`font-medium`,children:G(`engine.previewShell.renderFailed`,e)})}var Z=class extends J.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error(`[MetadataPreview] render failed`,e)}render(){return this.state.error?(0,Y.jsxs)(Pf,{tone:`error`,children:[(0,Y.jsx)(If,{}),(0,Y.jsx)(`div`,{className:`text-xs mt-1 font-mono opacity-80`,children:this.state.error.message}),this.props.fallbackHint&&(0,Y.jsx)(`div`,{className:`text-xs mt-2 opacity-70`,children:this.props.fallbackHint})]}):this.props.children}};function Lf({title:e,entries:t,selectedId:n,onSelect:r,onAdd:i,addLabel:a}){return t.length===0&&!i?null:(0,Y.jsxs)(`div`,{className:`border-b bg-muted/30 px-3 py-2`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5`,children:e}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[t.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e)},className:R(`rounded border bg-background px-2 py-0.5 text-xs hover:border-primary/50 cursor-pointer`,n===e.id&&`ring-2 ring-primary border-primary`),children:e.label},e.id)),i&&(0,Y.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},className:`rounded border border-dashed bg-background px-2 py-0.5 text-xs text-muted-foreground hover:border-primary hover:text-primary cursor-pointer inline-flex items-center gap-1`,"aria-label":a??`Add`,title:a??`Add`,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:a??`Add`})]})]})]})}var Rf=J.lazy(async()=>({default:(await n(()=>import(`./dist-Dc_9i5rZ.js`).then(e=>e.n),[],import.meta.url)).Editor}));function zf(e){let t=e.languages.typescript;t.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.typescriptDefaults.setCompilerOptions({jsx:t.JsxEmit.React,target:t.ScriptTarget.Latest,allowNonTsExtensions:!0,allowJs:!0,noEmit:!0})}function Bf({draft:e,onPatch:t,readOnly:n,fallbackDelayMs:r=4e3,mode:i=`split`,locale:a}){let o=e.kind===`react`?`react`:`html`,s=typeof e.source==`string`?e.source:``,[c,l]=J.useState(s),u=J.useRef(s);J.useEffect(()=>{s!==u.current&&(l(s),u.current=s)},[s]);let[d,f]=Wa(r),[p,m]=J.useState(()=>typeof document<`u`&&document.documentElement.classList.contains(`dark`)?`vs-dark`:`light`);J.useEffect(()=>{if(typeof document>`u`)return;let e=document.documentElement,t=new MutationObserver(()=>m(e.classList.contains(`dark`)?`vs-dark`:`light`));return t.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let h=e=>{let n=e??``;l(n),u.current=n,t?.({source:n})},g=J.useMemo(()=>({...e,type:e.type??`page`}),[e]),_=(0,Y.jsx)(`div`,{ref:f,className:`h-full min-h-[260px] overflow-hidden bg-background`,children:d?(0,Y.jsx)(`textarea`,{value:c,onChange:e=>h(e.target.value),readOnly:n,spellCheck:!1,"aria-label":G(`engine.sourcePageEditor.source`,a),className:`h-full w-full resize-none bg-background p-3 font-mono text-xs leading-relaxed outline-none`}):(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(ut,{className:`h-full w-full`}),children:(0,Y.jsx)(Rf,{value:c,language:`typescript`,path:o===`react`?`page.tsx`:`page.html.tsx`,theme:p,beforeMount:zf,onChange:h,options:{readOnly:n,minimap:{enabled:!1},fontSize:12,lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,folding:!0,wordWrap:`on`,tabSize:2,scrollbar:{verticalScrollbarSize:10,horizontalScrollbarSize:10}}})})}),v=(0,Y.jsx)(`div`,{className:`h-full min-h-[260px] overflow-auto bg-muted/20`,children:(0,Y.jsx)(Z,{fallbackHint:G(`engine.sourcePageEditor.renderFailed`,a),children:(0,Y.jsx)(Bt,{schema:g})})});return i===`editor`?_:i===`preview`?(0,Y.jsx)(X,{hint:`page · ${o} source`,children:v}):(0,Y.jsx)(X,{hint:`page · ${o} source`,children:(0,Y.jsxs)(`div`,{className:`grid h-full grid-cols-1 divide-y divide-border lg:grid-cols-2 lg:divide-x lg:divide-y-0`,children:[_,v]})})}var Vf={grid:{label:`Grid`,labelKey:`engine.pageBlockCanvas.type.grid`,category:`data`,Icon:Vr},"object-grid":{label:`Table`,labelKey:`engine.pageBlockCanvas.type.objectGrid`,category:`data`,Icon:Hi},"object-form":{label:`Form`,labelKey:`engine.pageBlockCanvas.type.objectForm`,category:`data`,Icon:_i},"object-metric":{label:`Metric`,labelKey:`engine.pageBlockCanvas.type.objectMetric`,category:`data`,Icon:Tr},"object-kanban":{label:`Kanban`,labelKey:`engine.pageBlockCanvas.type.objectKanban`,category:`data`,Icon:Qn},"page:header":{label:`Header`,labelKey:`engine.pageBlockCanvas.type.pageHeader`,category:`layout`,Icon:li},"page:footer":{label:`Footer`,labelKey:`engine.pageBlockCanvas.type.pageFooter`,category:`layout`,Icon:oi},"page:sidebar":{label:`Sidebar`,labelKey:`engine.pageBlockCanvas.type.pageSidebar`,category:`layout`,Icon:si},"page:tabs":{label:`Tabs`,labelKey:`engine.pageBlockCanvas.type.pageTabs`,category:`layout`,Icon:Cr},"page:accordion":{label:`Accordion`,labelKey:`engine.pageBlockCanvas.type.pageAccordion`,category:`layout`,Icon:Ln},"page:card":{label:`Card`,labelKey:`engine.pageBlockCanvas.type.pageCard`,category:`layout`,Icon:Li},"page:section":{label:`Section`,labelKey:`engine.pageBlockCanvas.type.pageSection`,category:`layout`,Icon:zr},"record:details":{label:`Record details`,labelKey:`engine.pageBlockCanvas.type.recordDetails`,category:`record`,Icon:gr},"record:highlights":{label:`Highlights`,labelKey:`engine.pageBlockCanvas.type.recordHighlights`,category:`record`,Icon:Ui},"record:related_list":{label:`Related list`,labelKey:`engine.pageBlockCanvas.type.recordRelatedList`,category:`record`,Icon:Wr},"record:activity":{label:`Activity timeline`,labelKey:`engine.pageBlockCanvas.type.recordActivity`,category:`record`,Icon:sn},"record:discussion":{label:`Discussion`,labelKey:`engine.pageBlockCanvas.type.recordDiscussion`,category:`record`,Icon:Qr},"record:path":{label:`Stage path`,labelKey:`engine.pageBlockCanvas.type.recordPath`,category:`record`,Icon:$n},"record:alert":{label:`Alert banner`,labelKey:`engine.pageBlockCanvas.type.recordAlert`,category:`record`,Icon:Ji},"record:quick_actions":{label:`Quick actions`,labelKey:`engine.pageBlockCanvas.type.recordQuickActions`,category:`record`,Icon:ra},"record:reference_rail":{label:`Reference rail`,labelKey:`engine.pageBlockCanvas.type.recordReferenceRail`,category:`record`,Icon:gn},"record:history":{label:`History`,labelKey:`engine.pageBlockCanvas.type.recordHistory`,category:`record`,Icon:Si},"nav:menu":{label:`Nav menu`,labelKey:`engine.pageBlockCanvas.type.navMenu`,category:`navigation`,Icon:Xr},"nav:breadcrumb":{label:`Breadcrumb`,labelKey:`engine.pageBlockCanvas.type.navBreadcrumb`,category:`navigation`,Icon:$n},"global:search":{label:`Global search`,labelKey:`engine.pageBlockCanvas.type.globalSearch`,category:`navigation`,Icon:Di},"ai:suggestion":{label:`AI suggestion`,labelKey:`engine.pageBlockCanvas.type.aiSuggestion`,category:`ai`,Icon:Fi},"element:text":{label:`Text`,labelKey:`engine.pageBlockCanvas.type.elementText`,category:`element`,Icon:Yi},"element:number":{label:`Number`,labelKey:`engine.pageBlockCanvas.type.elementNumber`,category:`element`,Icon:Mr},"element:image":{label:`Image`,labelKey:`engine.pageBlockCanvas.type.elementImage`,category:`element`,Icon:Nr},"element:divider":{label:`Divider`,labelKey:`engine.pageBlockCanvas.type.elementDivider`,category:`element`,Icon:$r},"element:button":{label:`Button`,labelKey:`engine.pageBlockCanvas.type.elementButton`,category:`element`,Icon:ti},"element:definition-list":{label:`Definition list`,labelKey:`engine.pageBlockCanvas.type.elementDefinitionList`,category:`element`,Icon:Gr},"element:repeater":{label:`Repeater`,labelKey:`engine.pageBlockCanvas.type.elementRepeater`,category:`element`,Icon:wi}},Hf=[[`record:discussion`,`record:chatter`]],Uf={data:`engine.pageBlockCanvas.category.data`,layout:`engine.pageBlockCanvas.category.layout`,record:`engine.pageBlockCanvas.category.record`,navigation:`engine.pageBlockCanvas.category.navigation`,element:`engine.pageBlockCanvas.category.element`,ai:`engine.pageBlockCanvas.category.ai`,misc:`engine.pageBlockCanvas.category.misc`},Wf=(()=>{let e={data:[],layout:[],record:[],navigation:[],element:[],ai:[],misc:[]};for(let[t,n]of Object.entries(Vf))e[n.category].push(t);return[`data`,`layout`,`record`,`element`,`navigation`,`ai`,`misc`].map(t=>({category:t,types:e[t]})).filter(e=>e.types.length>0)})(),Gf=vn,Kf={data:{icon:`text-emerald-500 dark:text-emerald-400`,badge:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300`},layout:{icon:`text-slate-500 dark:text-slate-400`,badge:`border-slate-200 bg-slate-50 text-slate-700 dark:border-slate-800 dark:bg-slate-900/40 dark:text-slate-300`},record:{icon:`text-blue-500 dark:text-blue-400`,badge:`border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900 dark:bg-blue-950/40 dark:text-blue-300`},navigation:{icon:`text-indigo-500 dark:text-indigo-400`,badge:`border-indigo-200 bg-indigo-50 text-indigo-700 dark:border-indigo-900 dark:bg-indigo-950/40 dark:text-indigo-300`},element:{icon:`text-teal-500 dark:text-teal-400`,badge:`border-teal-200 bg-teal-50 text-teal-700 dark:border-teal-900 dark:bg-teal-950/40 dark:text-teal-300`},ai:{icon:`text-violet-500 dark:text-violet-400`,badge:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/40 dark:text-violet-300`},misc:{icon:`text-zinc-500 dark:text-zinc-400`,badge:`border-zinc-200 bg-zinc-50 text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900/40 dark:text-zinc-400`}};function qf(e){let t=Vf[e];if(t)return{Icon:t.Icon,category:t.category};for(let t of Hf)if(t.includes(e))for(let e of t){let t=Vf[e];if(t)return{Icon:t.Icon,category:t.category}}}function Jf(e){return Kf[qf(e)?.category??`misc`]}var Yf={"object-grid":[{name:`objectName`,label:`engine.inspector.pageBlock.field.object-grid.objectName`,kind:`object-picker`},{name:`columns`,label:`engine.inspector.pageBlock.field.object-grid.columns`,kind:`field-list`,objectFrom:`self`,objectProp:`objectName`},{name:`pageSize`,label:`engine.inspector.pageBlock.field.object-grid.pageSize`,kind:`number`,placeholder:{literal:`20`}}],"object-form":[{name:`objectName`,label:`engine.inspector.pageBlock.field.object-form.objectName`,kind:`object-picker`},{name:`mode`,label:`engine.inspector.pageBlock.field.object-form.mode`,kind:`select`,options:[{value:`create`,label:`engine.inspector.pageBlock.option.mode.create`},{value:`edit`,label:`engine.inspector.pageBlock.option.mode.edit`},{value:`view`,label:`engine.inspector.pageBlock.option.mode.view`}]},{name:`formType`,label:`engine.inspector.pageBlock.field.object-form.formType`,kind:`select`,options:[{value:`simple`,label:`engine.inspector.pageBlock.option.formType.simple`},{value:`tabbed`,label:`engine.inspector.pageBlock.option.formType.tabbed`},{value:`wizard`,label:`engine.inspector.pageBlock.option.formType.wizard`},{value:`split`,label:`engine.inspector.pageBlock.option.formType.split`},{value:`drawer`,label:`engine.inspector.pageBlock.option.formType.drawer`},{value:`modal`,label:`engine.inspector.pageBlock.option.formType.modal`}]},{name:`layout`,label:`engine.inspector.pageBlock.field.object-form.layout`,kind:`select`,options:[{value:`vertical`,label:`engine.inspector.pageBlock.option.layout.vertical`},{value:`horizontal`,label:`engine.inspector.pageBlock.option.layout.horizontal`}]},{name:`columns`,label:`engine.inspector.pageBlock.field.object-form.columns`,kind:`number`,placeholder:{literal:`2`}},{name:`fields`,label:`engine.inspector.pageBlock.field.object-form.fields`,kind:`field-list`,objectFrom:`self`,objectProp:`objectName`},{name:`title`,label:`engine.inspector.pageBlock.field.object-form.title`,kind:`text`},{name:`description`,label:`engine.inspector.pageBlock.field.object-form.description`,kind:`text`}],"object-metric":[{name:`objectName`,label:`engine.inspector.pageBlock.field.object-metric.objectName`,kind:`object-picker`},{name:`label`,label:`engine.inspector.pageBlock.field.object-metric.label`,kind:`text`},{name:`description`,label:`engine.inspector.pageBlock.field.object-metric.description`,kind:`text`},{name:`icon`,label:`engine.inspector.pageBlock.field.object-metric.icon`,kind:`text`,placeholder:{key:`engine.inspector.pageBlock.placeholder.object-metric.icon`}},{name:`colorVariant`,label:`engine.inspector.pageBlock.field.object-metric.colorVariant`,kind:`color`,options:[{value:`default`,label:`engine.inspector.pageBlock.option.colorVariant.default`},{value:`blue`,label:`engine.inspector.pageBlock.option.colorVariant.blue`},{value:`teal`,label:`engine.inspector.pageBlock.option.colorVariant.teal`},{value:`orange`,label:`engine.inspector.pageBlock.option.colorVariant.orange`},{value:`purple`,label:`engine.inspector.pageBlock.option.colorVariant.purple`},{value:`success`,label:`engine.inspector.pageBlock.option.colorVariant.success`},{value:`warning`,label:`engine.inspector.pageBlock.option.colorVariant.warning`},{value:`danger`,label:`engine.inspector.pageBlock.option.colorVariant.danger`}]},{name:`format`,label:`engine.inspector.pageBlock.field.object-metric.format`,kind:`select`,options:[{value:`number`,label:`engine.inspector.pageBlock.option.format.number`},{value:`currency`,label:`engine.inspector.pageBlock.option.format.currency`},{value:`percent`,label:`engine.inspector.pageBlock.option.format.percent`}]},{name:`prefix`,label:`engine.inspector.pageBlock.field.object-metric.prefix`,kind:`text`},{name:`suffix`,label:`engine.inspector.pageBlock.field.object-metric.suffix`,kind:`text`}],"object-kanban":[{name:`objectName`,label:`engine.inspector.pageBlock.field.object-kanban.objectName`,kind:`object-picker`},{name:`groupBy`,label:`engine.inspector.pageBlock.field.object-kanban.groupBy`,kind:`field-picker`,objectFrom:`self`,objectProp:`objectName`},{name:`titleField`,label:`engine.inspector.pageBlock.field.object-kanban.titleField`,kind:`field-picker`,objectFrom:`self`,objectProp:`objectName`},{name:`cardFields`,label:`engine.inspector.pageBlock.field.object-kanban.cardFields`,kind:`field-list`,objectFrom:`self`,objectProp:`objectName`},{name:`limit`,label:`engine.inspector.pageBlock.field.object-kanban.limit`,kind:`number`,placeholder:{literal:`100`}}],grid:[{name:`columns`,label:`engine.inspector.pageBlock.field.grid.columns`,kind:`number`,placeholder:{literal:`3`}},{name:`gap`,label:`engine.inspector.pageBlock.field.grid.gap`,kind:`number`,placeholder:{literal:`4`}}],"element:text":[{name:`content`,label:`engine.inspector.pageBlock.field.element:text.content`,kind:`text`,placeholder:{key:`engine.inspector.pageBlock.placeholder.element:text.content`}},{name:`variant`,label:`engine.inspector.pageBlock.field.element:text.variant`,kind:`select`,options:[{value:`h1`,label:`engine.inspector.pageBlock.option.variant.h1`},{value:`h2`,label:`engine.inspector.pageBlock.option.variant.h2`},{value:`h3`,label:`engine.inspector.pageBlock.option.variant.h3`},{value:`h4`,label:`engine.inspector.pageBlock.option.variant.h4`},{value:`h5`,label:`engine.inspector.pageBlock.option.variant.h5`},{value:`h6`,label:`engine.inspector.pageBlock.option.variant.h6`},{value:`body`,label:`engine.inspector.pageBlock.option.variant.body`},{value:`caption`,label:`engine.inspector.pageBlock.option.variant.caption`},{value:`overline`,label:`engine.inspector.pageBlock.option.variant.overline`}]},{name:`align`,label:`engine.inspector.pageBlock.field.element:text.align`,kind:`select`,options:[{value:`left`,label:`engine.inspector.pageBlock.option.align.left`},{value:`center`,label:`engine.inspector.pageBlock.option.align.center`},{value:`right`,label:`engine.inspector.pageBlock.option.align.right`}]}],"element:image":[{name:`src`,label:`engine.inspector.pageBlock.field.element:image.src`,kind:`text`,placeholder:{literal:`https://…`}},{name:`alt`,label:`engine.inspector.pageBlock.field.element:image.alt`,kind:`text`},{name:`fit`,label:`engine.inspector.pageBlock.field.element:image.fit`,kind:`select`,options:[{value:`cover`,label:`engine.inspector.pageBlock.option.fit.cover`},{value:`contain`,label:`engine.inspector.pageBlock.option.fit.contain`},{value:`fill`,label:`engine.inspector.pageBlock.option.fit.fill`}]}],"element:definition-list":[{name:`items`,label:`engine.inspector.pageBlock.field.element:definition-list.items`,kind:`array`,addLabel:`engine.inspector.pageBlock.add.element:definition-list.items`,itemFields:[{name:`term`,label:`engine.inspector.pageBlock.field.element:definition-list.items.term`,kind:`text`},{name:`description`,label:`engine.inspector.pageBlock.field.element:definition-list.items.description`,kind:`text`}]},{name:`columns`,label:`engine.inspector.pageBlock.field.element:definition-list.columns`,kind:`number`,placeholder:{literal:`1`}},{name:`inline`,label:`engine.inspector.pageBlock.field.element:definition-list.inline`,kind:`boolean`}],"element:repeater":[{name:`object`,label:`engine.inspector.pageBlock.field.element:repeater.object`,kind:`object-picker`},{name:`titleField`,label:`engine.inspector.pageBlock.field.element:repeater.titleField`,kind:`field-picker`,objectFrom:`self`,objectProp:`object`},{name:`fields`,label:`engine.inspector.pageBlock.field.element:repeater.fields`,kind:`field-list`,objectFrom:`self`,objectProp:`object`},{name:`limit`,label:`engine.inspector.pageBlock.field.element:repeater.limit`,kind:`number`,placeholder:{literal:`10`}},{name:`emptyText`,label:`engine.inspector.pageBlock.field.element:repeater.emptyText`,kind:`text`},{name:`divided`,label:`engine.inspector.pageBlock.field.element:repeater.divided`,kind:`boolean`}],"element:number":[{name:`object`,label:`engine.inspector.pageBlock.field.element:number.object`,kind:`object-picker`},{name:`field`,label:`engine.inspector.pageBlock.field.element:number.field`,kind:`field-picker`,objectFrom:`self`,objectProp:`object`},{name:`aggregate`,label:`engine.inspector.pageBlock.field.element:number.aggregate`,kind:`select`,options:[{value:`count`,label:`engine.inspector.pageBlock.option.aggregate.count`},{value:`sum`,label:`engine.inspector.pageBlock.option.aggregate.sum`},{value:`avg`,label:`engine.inspector.pageBlock.option.aggregate.avg`},{value:`min`,label:`engine.inspector.pageBlock.option.aggregate.min`},{value:`max`,label:`engine.inspector.pageBlock.option.aggregate.max`}]},{name:`format`,label:`engine.inspector.pageBlock.field.element:number.format`,kind:`select`,options:[{value:`number`,label:`engine.inspector.pageBlock.option.format.number`},{value:`currency`,label:`engine.inspector.pageBlock.option.format.currency`},{value:`percent`,label:`engine.inspector.pageBlock.option.format.percent`}]},{name:`prefix`,label:`engine.inspector.pageBlock.field.element:number.prefix`,kind:`text`},{name:`suffix`,label:`engine.inspector.pageBlock.field.element:number.suffix`,kind:`text`}],"element:button":[{name:`label`,label:`engine.inspector.pageBlock.field.element:button.label`,kind:`text`},{name:`variant`,label:`engine.inspector.pageBlock.field.element:button.variant`,kind:`select`,options:[{value:`primary`,label:`engine.inspector.pageBlock.option.variant.primary`},{value:`secondary`,label:`engine.inspector.pageBlock.option.variant.secondary`},{value:`danger`,label:`engine.inspector.pageBlock.option.variant.danger`},{value:`ghost`,label:`engine.inspector.pageBlock.option.variant.ghost`},{value:`link`,label:`engine.inspector.pageBlock.option.variant.link`}]},{name:`size`,label:`engine.inspector.pageBlock.field.element:button.size`,kind:`select`,options:[{value:`small`,label:`engine.inspector.pageBlock.option.size.small`},{value:`medium`,label:`engine.inspector.pageBlock.option.size.medium`},{value:`large`,label:`engine.inspector.pageBlock.option.size.large`}]},{name:`icon`,label:`engine.inspector.pageBlock.field.element:button.icon`,kind:`text`,placeholder:{key:`engine.inspector.pageBlock.placeholder.element:button.icon`}},{name:`action`,label:`engine.inspector.pageBlock.field.element:button.action`,kind:`json`,placeholder:{literal:`{ "type": "url", "target": "/environments" }`}}],"page:header":[{name:`title`,label:`engine.inspector.pageBlock.field.page:header.title`,kind:`text`},{name:`subtitle`,label:`engine.inspector.pageBlock.field.page:header.subtitle`,kind:`text`}],"page:card":[{name:`title`,label:`engine.inspector.pageBlock.field.page:card.title`,kind:`text`},{name:`bordered`,label:`engine.inspector.pageBlock.field.page:card.bordered`,kind:`boolean`}],"page:tabs":[{name:`items`,label:`engine.inspector.pageBlock.field.page:tabs.items`,kind:`array`,addLabel:`engine.inspector.pageBlock.add.page:tabs.items`,itemFields:[{name:`value`,label:`engine.inspector.pageBlock.field.page:tabs.items.value`,kind:`text`},{name:`label`,label:`engine.inspector.pageBlock.field.page:tabs.items.label`,kind:`text`}]}],"page:accordion":[{name:`items`,label:`engine.inspector.pageBlock.field.page:accordion.items`,kind:`array`,addLabel:`engine.inspector.pageBlock.add.page:accordion.items`,itemFields:[{name:`label`,label:`engine.inspector.pageBlock.field.page:accordion.items.label`,kind:`text`}]}],"record:related_list":[{name:`objectName`,label:`engine.inspector.pageBlock.field.record:related_list.objectName`,kind:`object-picker`},{name:`relationshipField`,label:`engine.inspector.pageBlock.field.record:related_list.relationshipField`,kind:`field-picker`,objectFrom:`self`,objectProp:`objectName`},{name:`title`,label:`engine.inspector.pageBlock.field.record:related_list.title`,kind:`text`},{name:`limit`,label:`engine.inspector.pageBlock.field.record:related_list.limit`,kind:`number`,placeholder:{literal:`10`}}],"record:highlights":[{name:`fields`,label:`engine.inspector.pageBlock.field.record:highlights.fields`,kind:`field-list`,objectFrom:`page`}],"record:details":[{name:`sections`,label:`engine.inspector.pageBlock.field.record:details.sections`,kind:`array`,addLabel:`engine.inspector.pageBlock.add.record:details.sections`,itemFields:[{name:`name`,label:`engine.inspector.pageBlock.field.record:details.sections.name`,kind:`text`,placeholder:{key:`engine.inspector.pageBlock.placeholder.record:details.sections.name`}},{name:`label`,label:`engine.inspector.pageBlock.field.record:details.sections.label`,kind:`text`},{name:`columns`,label:`engine.inspector.pageBlock.field.record:details.sections.columns`,kind:`number`,placeholder:{literal:`2`}},{name:`fields`,label:`engine.inspector.pageBlock.field.record:details.sections.fields`,kind:`field-list`,objectFrom:`page`}]}],"record:alert":[{name:`severity`,label:`engine.inspector.pageBlock.field.record:alert.severity`,kind:`select`,options:[{value:`info`,label:`engine.inspector.pageBlock.option.severity.info`},{value:`warning`,label:`engine.inspector.pageBlock.option.severity.warning`},{value:`error`,label:`engine.inspector.pageBlock.option.severity.error`},{value:`success`,label:`engine.inspector.pageBlock.option.severity.success`}]},{name:`title`,label:`engine.inspector.pageBlock.field.record:alert.title`,kind:`text`},{name:`body`,label:`engine.inspector.pageBlock.field.record:alert.body`,kind:`text`},{name:`icon`,label:`engine.inspector.pageBlock.field.record:alert.icon`,kind:`text`,placeholder:{key:`engine.inspector.pageBlock.placeholder.record:alert.icon`}},{name:`dismissible`,label:`engine.inspector.pageBlock.field.record:alert.dismissible`,kind:`boolean`}],"record:path":[{name:`statusField`,label:`engine.inspector.pageBlock.field.record:path.statusField`,kind:`field-picker`,objectFrom:`page`},{name:`stages`,label:`engine.inspector.pageBlock.field.record:path.stages`,kind:`array`,addLabel:`engine.inspector.pageBlock.add.record:path.stages`,itemFields:[{name:`value`,label:`engine.inspector.pageBlock.field.record:path.stages.value`,kind:`text`},{name:`label`,label:`engine.inspector.pageBlock.field.record:path.stages.label`,kind:`text`}]}],"record:quick_actions":[{name:`actionNames`,label:`engine.inspector.pageBlock.field.record:quick_actions.actionNames`,kind:`string-list`,placeholder:{key:`engine.inspector.pageBlock.placeholder.record:quick_actions.actionNames`}},{name:`location`,label:`engine.inspector.pageBlock.field.record:quick_actions.location`,kind:`select`,options:[{value:`record_header`,label:`engine.inspector.pageBlock.option.location.record_header`},{value:`record_more`,label:`engine.inspector.pageBlock.option.location.record_more`},{value:`record_section`,label:`engine.inspector.pageBlock.option.location.record_section`},{value:`record_related`,label:`engine.inspector.pageBlock.option.location.record_related`},{value:`list_toolbar`,label:`engine.inspector.pageBlock.option.location.list_toolbar`},{value:`list_item`,label:`engine.inspector.pageBlock.option.location.list_item`}]}]};function Xf(e){return!!e&&Array.isArray(Yf[e])&&Yf[e].length>0}var Zf={"object-kanban":[`groupField`]};function Qf(e,t){let n=(e&&Zf[e]||[]).filter(e=>e in t);if(n.length===0)return t;let r={...t};for(let e of n)delete r[e];return r}function $f(){let e=sa(),[t,n]=J.useState([]),[r,i]=J.useState(!0),[a,o]=J.useState(null);return J.useEffect(()=>{let t=!1;return i(!0),o(null),e.list(`object`).then(e=>{if(t)return;let r=(e??[]).map(e=>e&&typeof e==`object`&&`item`in e?e.item:e).filter(e=>typeof e?.name==`string`&&e.name).map(e=>({value:e.name,label:e.label?`${e.label} (${e.name})`:e.name})).sort((e,t)=>e.value.localeCompare(t.value));n(r),i(!1)}).catch(e=>{t||(n([]),i(!1),o(e?.message??String(e)))}),()=>{t=!0}},[e]),{options:t,loading:r,error:a}}function ep(e){let{fields:t}=co(e);return J.useMemo(()=>t.filter(e=>!e.hidden).map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name})),[t])}function tp({label:e,value:t,onCommit:n,disabled:r,locale:i}){let{options:a}=$f();return a.length===0?(0,Y.jsx)(q,{label:e,value:t??``,placeholder:G(`engine.inspector.pageBlock.objectPlaceholder`,i),onCommit:n,disabled:r,mono:!0}):(0,Y.jsx)(K,{label:e,value:t||void 0,options:a,onCommit:n,disabled:r})}function np({label:e,objectName:t,value:n,onCommit:r,disabled:i}){let a=ep(t);return!t||a.length===0?(0,Y.jsx)(q,{label:e,value:n??``,onCommit:r,disabled:i,mono:!0}):(0,Y.jsx)(K,{label:e,value:n||void 0,options:a,onCommit:r,disabled:i})}function rp({label:e,objectName:t,value:n,onChange:r,disabled:i,locale:a}){let o=ep(t),s=Array.isArray(n)?n:[];return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:e}),s.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[o.length>0?(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsxs)(Pe,{value:e?String(e):``,onValueChange:e=>{let n=[...s];n[t]=e,r(n)},disabled:i,children:[(0,Y.jsx)(he,{className:`h-8`,children:(0,Y.jsx)(Ze,{placeholder:`—`})}),(0,Y.jsx)(Ke,{children:o.map(e=>(0,Y.jsx)(vt,{value:e.value,children:e.label},e.value))})]})}):(0,Y.jsx)(z,{className:`h-8 text-sm`,value:String(e??``),placeholder:G(`engine.inspector.pageBlock.fieldPlaceholder`,a),disabled:i,onChange:e=>{let n=[...s];n[t]=e.target.value,r(n)}}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,disabled:i,"aria-label":G(`engine.inspector.pageBlock.list.remove`,a),onClick:()=>r(s.filter((e,n)=>n!==t)),children:(0,Y.jsx)(na,{className:`h-4 w-4`})})]},t)),!i&&(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r([...s,``]),children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),` `,G(`engine.inspector.pageBlock.list.add`,a)]})]})}function ip(e){if(e===void 0)return``;try{return JSON.stringify(e,null,2)}catch{return``}}function ap({label:e,value:t,onCommit:n,disabled:r,placeholder:i,locale:a}){let o=J.useMemo(()=>ip(t),[t]),[s,c]=J.useState(o),[l,u]=J.useState(!1);return J.useEffect(()=>{c(o),u(!1)},[o]),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onBlur:()=>{if(r)return;let e=s.trim();if(e===``){u(!1),n(void 0);return}try{let t=JSON.parse(e);u(!1),n(t)}catch{u(!0)}},disabled:r,placeholder:i,spellCheck:!1,rows:Math.min(12,Math.max(2,s.split(`
5
+ `).length)),className:`w-full rounded border border-input bg-background px-2 py-1.5 text-xs font-mono outline-none focus:ring-1 focus:ring-primary resize-y disabled:opacity-60`}),l&&(0,Y.jsx)(`div`,{className:`text-[11px] text-destructive`,children:G(`engine.form.invalidJson`,a)})]})}function op({name:e,value:t,onCommit:n,disabled:r,locale:i}){return typeof t==`boolean`?(0,Y.jsx)(cs,{label:e,value:t,onCommit:n,disabled:r}):typeof t==`number`?(0,Y.jsx)(gs,{label:e,value:t,onCommit:e=>n(e),disabled:r}):t===null||typeof t==`string`?(0,Y.jsx)(q,{label:e,value:t??``,onCommit:n,disabled:r,mono:!0}):(0,Y.jsx)(ap,{label:e,value:t,onCommit:n,disabled:r,locale:i})}function sp({label:e,value:t,onChange:n,disabled:r,options:i}){let a=J.useId();return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{id:a,className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsx)(So,{ariaLabelledBy:a,value:t,onChange:n,disabled:r,options:i})]})}var cp=new Set([`children`,`body`]),lp=Symbol(`remove`);function up(e){let t=e.split(`.`),n=[];for(let e of t){let t=/^([a-zA-Z_]\w*)(?:\[(\d+)\])?$/.exec(e);if(!t)return null;n.push({key:t[1],index:t[2]==null?-1:Number(t[2])})}return n.length>0?n:null}function dp(e){let t=[];for(let n of e)t.push(n.key),n.index>=0&&t.push(n.index);return t}function fp(e,t){let n=e;for(let e of t){if(n==null)return null;n=n[e]}return n??null}function pp(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(typeof r==`number`){let t=Array.isArray(e)?[...e]:[];return i.length===0?n===lp?t.splice(r,1):t[r]=n:t[r]=pp(t[r],i,n),t}let a={...e||{}};return i.length===0?n===lp?delete a[r]:a[r]=n:a[r]=pp(a[r],i,n),a}function mp(e,t){return fp(e,dp(t))}function hp(e,t,n){let r=dp(t),i=pp(e,r,n===null?lp:n),a=r[0];return{[a]:i[a]}}function gp(e,t){let n=dp(t),r=n[n.length-1];if(typeof r!=`number`)return null;let i=fp(e,n.slice(0,-1));return Array.isArray(i)?{siblings:i,index:r}:null}function _p(e,t,n){let r=dp(t),i=pp(e,r.slice(0,-1),n),a=r[0];return{[a]:i[a]}}function vp({selection:e,draft:t,onPatch:n,onClearSelection:r,onSelectionChange:i,onBlockingIssuesChange:a,locale:o,readOnly:s}){let c=/^slot:([a-zA-Z_]+):(\d+)(?:\.(.+))?$/.exec(e.id),l=c?null:up(e.id),u=c?c[1]:``,d=c?Number(c[2]):-1,f=c?c[3]:void 0,p=f?up(f):null,m=t.slots&&typeof t.slots==`object`?t.slots:{},h=c?Array.isArray(m[u])?m[u]:m[u]==null?[]:[m[u]]:[],g=c?h[d]??null:null,_=e=>n({slots:{...m,[u]:e}}),v=e=>_(e===null?h.filter((e,t)=>t!==d):h.map((t,n)=>n===d?e:t)),y=c?p?mp(g||{},p):g:l?mp(t,l):null,b=c?p?gp(g||{},p):{siblings:h,index:d}:l?gp(t,l):null,[x,S]=J.useState({block:e.id,count:0}),C=J.useCallback(t=>{S(n=>n.block===e.id&&n.count===t?n:{block:e.id,count:t})},[e.id]),w=x.block===e.id?x.count:0,T=J.useRef(a);if(J.useEffect(()=>{T.current=a}),J.useEffect(()=>{T.current?.(w)},[w]),!c&&!l||!y)return(0,Y.jsx)(is,{kindLabel:G(`engine.inspector.pageBlock.kind`,o),title:e.label??e.id,onClose:r,closeLabel:G(`engine.inspector.pageBlock.close`,o),children:(0,Y.jsx)(ls,{message:e.id})});let E=e=>c?v(p?{...g,...hp(g||{},p,{...y,...e})}:{...y,...e}):n(hp(t,l,{...y,...e})),D=Qf(y.type,y.properties||{}),O=typeof t?.object==`string`?t.object:void 0,k=e=>e.objectFrom===`page`?O:e.objectProp!=null&&D[e.objectProp]!=null?String(D[e.objectProp]):void 0,A=e=>D[e]??y[e],j=(e,t)=>E({properties:{...D,[e]:t}}),M=new Set((Xf(y.type)?Yf[y.type]:[]).map(e=>e.name)),N=Object.keys(D).filter(e=>!M.has(e)&&!cp.has(e)),P=e=>G(e,o),ee=e=>e.map(e=>({...e,label:G(e.label,o)})),F=e=>e===void 0?void 0:e.key===void 0?e.literal:G(e.key,o),te=(e,t,n,r=``)=>{let i=`${r}${e.name}`;switch(e.kind){case`number`:return(0,Y.jsx)(gs,{label:P(e.label),value:typeof t(e.name)==`number`?t(e.name):void 0,placeholder:F(e.placeholder),onCommit:t=>n(e.name,t),disabled:s},i);case`boolean`:return(0,Y.jsx)(cs,{label:P(e.label),value:!!t(e.name),onCommit:t=>n(e.name,t),disabled:s},i);case`color`:return(0,Y.jsx)(sp,{label:P(e.label),value:t(e.name)==null?void 0:String(t(e.name)),onChange:t=>n(e.name,t),disabled:s,options:e.options?ee(e.options):void 0},i);case`select`:return(0,Y.jsx)(K,{label:P(e.label),value:t(e.name)==null?void 0:String(t(e.name)),options:ee(e.options),onCommit:t=>n(e.name,t),disabled:s},i);case`json`:return(0,Y.jsx)(ap,{label:P(e.label),value:t(e.name),placeholder:F(e.placeholder),locale:o,onCommit:t=>n(e.name,t),disabled:s},i);case`string-list`:{let r=Array.isArray(t(e.name))?t(e.name):[];return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:P(e.label)}),r.map((t,i)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(z,{className:`h-8 text-sm`,value:String(t??``),placeholder:F(e.placeholder),disabled:s,onChange:t=>{let a=[...r];a[i]=t.target.value,n(e.name,a)}}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,disabled:s,"aria-label":G(`engine.inspector.pageBlock.list.remove`,o),onClick:()=>n(e.name,r.filter((e,t)=>t!==i)),children:(0,Y.jsx)(na,{className:`h-4 w-4`})})]},i)),!s&&(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(e.name,[...r,``]),children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),` `,G(`engine.inspector.pageBlock.list.add`,o)]})]},i)}case`array`:{let r=Array.isArray(t(e.name))?t(e.name):[];return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:P(e.label)}),r.map((t,a)=>{let c=t&&typeof t==`object`?t:{};return(0,Y.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border p-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`#`,a+1]}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,disabled:s,"aria-label":G(`engine.inspector.pageBlock.list.removeItem`,o),onClick:()=>n(e.name,r.filter((e,t)=>t!==a)),children:(0,Y.jsx)(Ki,{className:`h-3.5 w-3.5`})})]}),e.itemFields.map(t=>te(t,e=>c[e],(t,i)=>{let o=[...r];o[a]={...c,[t]:i},n(e.name,o)},`${i}-${a}-`))]},a)}),!s&&(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(e.name,[...r,{}]),children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),` `,P(e.addLabel)]})]},i)}case`object-picker`:return(0,Y.jsx)(tp,{label:P(e.label),locale:o,value:t(e.name)==null?void 0:String(t(e.name)),onCommit:t=>n(e.name,t),disabled:s},i);case`field-picker`:return(0,Y.jsx)(np,{label:P(e.label),objectName:k(e),value:t(e.name)==null?void 0:String(t(e.name)),onCommit:t=>n(e.name,t),disabled:s},i);case`field-list`:return(0,Y.jsx)(rp,{label:P(e.label),objectName:k(e),locale:o,value:t(e.name),onChange:t=>n(e.name,t),disabled:s},i);default:return(0,Y.jsx)(q,{label:P(e.label),value:t(e.name)==null?``:String(t(e.name)),placeholder:F(e.placeholder),onCommit:t=>n(e.name,t),disabled:s},i)}},ne=()=>{c?v(p?{...g,...hp(g||{},p,null)}:null):n(hp(t,l,null)),r()},re=e=>e.map(e=>e.index>=0?`${e.key}[${e.index}]`:e.key).join(`.`);return(0,Y.jsxs)(is,{kindLabel:G(`engine.inspector.pageBlock.kind`,o),title:String(y.id||y.type||e.id),onClose:r,closeLabel:G(`engine.inspector.pageBlock.close`,o),headerActions:b?(0,Y.jsx)(us,{index:b.index,total:b.siblings.length,onMove:e=>{if(!b)return;if(c){if(p){let t=rs(b.siblings,b.index,e);v({...g,..._p(g||{},p,t)});let n=re([...p.slice(0,-1),{key:p[p.length-1].key,index:e}]);i?.({kind:`block`,id:`slot:${u}:${d}.${n}`,label:String(y.id||y.type||e)})}else _(rs(h,d,e)),i?.({kind:`block`,id:`slot:${u}:${e}`,label:String(y.id||y.type||e)});return}let r=rs(b.siblings,b.index,e);n(_p(t,l,r));let a=re([...l.slice(0,-1),{key:l[l.length-1].key,index:e}]);i?.({kind:`block`,id:a,label:String(y.id||y.type||a)})},upLabel:G(`engine.inspector.reorder.up`,o),downLabel:G(`engine.inspector.reorder.down`,o),disabled:s}):void 0,footer:(0,Y.jsx)(ps,{label:G(`engine.inspector.pageBlock.remove`,o),onClick:ne,disabled:s}),children:[(0,Y.jsx)(q,{label:G(`engine.inspector.pageBlock.type`,o),value:y.type??``,onCommit:e=>E({type:e}),disabled:s,mono:!0}),(0,Y.jsx)(q,{label:G(`engine.inspector.pageBlock.id`,o),value:y.id??``,onCommit:e=>E({id:e}),disabled:s,mono:!0}),(0,Y.jsx)(q,{label:G(`engine.inspector.pageBlock.className`,o),value:y.className??``,onCommit:e=>E({className:e}),disabled:s,mono:!0}),(0,Y.jsx)(po,{label:G(`engine.inspector.pageBlock.visibleWhen`,o),value:Jo(y.visibleWhen),onCommit:e=>E({visibleWhen:ko(y.visibleWhen,e)}),objectName:O,disabled:s,onBlockingIssuesChange:C}),Xf(y.type)&&(0,Y.jsxs)(`div`,{className:`space-y-3 border-t border-border pt-3`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:G(`engine.inspector.pageBlock.properties`,o)}),Yf[y.type].map(e=>te(e,A,j))]}),N.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-3 border-t border-border pt-3`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:G(`engine.inspector.pageBlock.advanced`,o)}),N.map(e=>(0,Y.jsx)(op,{name:e,value:D[e],onCommit:t=>j(e,t),disabled:s,locale:o},e))]})]})}var yp=new Set([`simple`,`tabbed`,`wizard`,`split`]),bp=new Set([`drawer`,`modal`]);function xp(e){return typeof e==`string`&&bp.has(e)}function Sp(e){return typeof e==`string`&&yp.has(e)?e:`simple`}function Cp(e){let t={...e,type:String(e?.type??``)},n=t.properties&&typeof t.properties==`object`?t.properties:void 0;return xp(n?.formType??t.formType)&&(n&&(t.properties={...n,formType:`simple`}),`formType`in t&&(t.formType=`simple`)),t}function wp(e=`300px`){let t=J.useRef(null),[n,r]=J.useState(()=>typeof IntersectionObserver>`u`);return J.useEffect(()=>{if(n)return;let i=t.current;if(!i)return;let a=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(r(!0),a.disconnect())},{rootMargin:e});return a.observe(i),()=>a.disconnect()},[n,e]),{ref:t,inView:n}}function Tp({block:e,maxHeightClass:t=`max-h-72`,locale:n}){let r=String(e?.type??``),{ref:i,inView:a}=wp();return(0,Y.jsx)(`div`,{ref:i,className:R(`pointer-events-none select-none overflow-hidden p-3`,t),children:a?(0,Y.jsx)(Z,{fallbackHint:W(`engine.pageBlockCanvas.renderFailed`,n,{type:r}),children:(0,Y.jsx)(Lt,{children:(0,Y.jsx)(Bt,{schema:Cp(e)})})}):(0,Y.jsx)(`div`,{className:`min-h-[64px] animate-pulse rounded bg-muted/40`,"aria-hidden":`true`})})}var Ep={1:`grid-cols-1`,2:`grid-cols-2`,3:`grid-cols-3`,4:`grid-cols-4`,5:`grid-cols-5`,6:`grid-cols-6`};function Dp(e,t){let n=e?.properties||{};switch(e?.type){case`page:tabs`:case`page:accordion`:return(Array.isArray(n.items)?n.items:[]).map((e,n)=>({label:e?.label||e?.key||W(`engine.pageBlockCanvas.itemN`,t,{n:n+1}),pathSuffix:`properties.items[${n}].children`,children:Array.isArray(e?.children)?e.children:[]}));case`page:card`:return Array.isArray(n.body)&&!Array.isArray(n.children)?[{label:G(`engine.pageBlockCanvas.body`,t),pathSuffix:`properties.body`,children:n.body}]:[{label:G(`engine.pageBlockCanvas.body`,t),pathSuffix:`properties.children`,children:Array.isArray(n.children)?n.children:[]}];case`page:section`:case`grid`:return[{label:G(`engine.pageBlockCanvas.content`,t),pathSuffix:`properties.children`,children:Array.isArray(n.children)?n.children:[]}];default:return Array.isArray(n.children)?[{label:G(`engine.pageBlockCanvas.content`,t),pathSuffix:`properties.children`,children:n.children}]:[]}}var Op=[`header`,`actions`,`alerts`,`highlights`,`details`,`tabs`,`discussion`];function kp(e){let t=e||{};return Op.map(e=>{let n=t[e];return{name:e,components:Array.isArray(n)?n:n==null?[]:[n]}})}function Ap(e){let t={};for(let n of e){let e=Array.isArray(n.components)?n.components:[];e.length!==0&&n.name&&(t[n.name]=e)}return t}function jp(e){let t=e.slots;if(e.kind===`slotted`&&t&&typeof t==`object`&&!Array.isArray(t))return{regions:kp(t),shape:`slots`};let n=e.regions;if(Array.isArray(n))return{regions:n,shape:`regions`};let r=e.children;return Array.isArray(r)?{regions:[{name:`children`,components:r}],shape:`children`}:{regions:[],shape:`regions`}}function Mp(e,t,n,r){return e===`children`?`children[${n}]`:e===`slots`?`slot:${r}:${n}`:`regions[${t}].components[${n}]`}function Np(e){return typeof e.label==`string`&&e.label||typeof e.title==`string`&&e.title||typeof e.id==`string`&&e.id||String(e.type??`block`)}var Pp=`text/x-objectui-pageblock`;function Fp({draft:e,onPatch:t,selection:n,onSelectionChange:r,locale:i}){let a=!t,{regions:o,shape:s}=J.useMemo(()=>jp(e),[e]),c=n?.kind===`block`?String(n.id):null,l=J.useCallback(e=>{if(s===`children`){let n=e.flatMap(e=>Array.isArray(e.components)?e.components:[]);t?.({children:n})}else s===`slots`?t?.({slots:Ap(e)}):t?.({regions:e})},[t,s]),u=J.useCallback((e,n)=>{if(!t)return;let i=o.map(e=>({...e,components:Array.isArray(e.components)?[...e.components]:[]})),a=i[e.region]?.components;if(!a)return;let[c]=a.splice(e.comp,1);if(!c)return;let u=i[n.region]?.components;if(!u)return;let d=u.length;if(`appendEnd`in n)d=u.length;else if(n.before!=null){let t=n.before;e.region===n.region&&e.comp<t&&--t,d=t}else if(n.after!=null){let t=n.after+1;e.region===n.region&&e.comp<n.after+1&&--t,d=t}u.splice(d,0,c),l(i);let f=Mp(s,n.region,d,i[n.region]?.name);r?.({kind:`block`,id:f,label:Np(c)})},[t,r,o,l,s]),d=J.useCallback((e,n)=>{if(!t)return;let i=o.map(e=>({...e,components:Array.isArray(e.components)?[...e.components]:[]}));i[e]||(i[e]={name:`region_${e+1}`,components:[]});let a={type:n};i[e].components.push(a),l(i);let c=i[e].components.length-1;r?.({kind:`block`,id:Mp(s,e,c,i[e]?.name),label:Np(a)})},[t,r,o,l,s]),f=J.useCallback((e,n,r)=>{if(!t)return;let i=o.map(e=>({...e,components:Array.isArray(e.components)?[...e.components]:[]})),a=i[e]?.components?.[n];a&&(i[e].components[n]={...a,label:r||void 0},l(i))},[t,o,l]),p=J.useCallback(()=>{if(!t)return;let e=[...o,{name:`region_${o.length+1}`,components:[]}];l(e)},[t,o,l]),m=J.useCallback((n,i,a)=>{if(!t)return;let o=/^slot:([a-zA-Z_]+):(\d+)$/.exec(n),s=up(i);if(!s)return;let c=dp(s);if(o){let s=o[1],l=Number(o[2]),u=e.slots||{},d=u[s],f=Array.isArray(d)?[...d]:d==null?[]:[d],p=f[l];if(!p)return;let m=fp(p,c)||[];f[l]=pp(p,c,[...m,{type:a}]),t({slots:{...u,[s]:f}}),r?.({kind:`block`,id:`${n}.${i}[${m.length}]`,label:a})}else{let o=up(`${n}.${i}`);if(!o)return;let s=dp(o),c=fp(e,s)||[],l=pp(e,s,[...c,{type:a}]);t({[s[0]]:l[s[0]]}),r?.({kind:`block`,id:`${n}.${i}[${c.length}]`,label:a})}},[t,e,r]),h=J.useCallback(e=>{e.target===e.currentTarget&&c&&r?.(null)},[r,c]);return o.length===0?(0,Y.jsx)(`div`,{className:`h-full overflow-auto bg-muted/20`,onClick:h,children:(0,Y.jsx)(`div`,{className:`mx-auto max-w-3xl px-6 py-8`,children:(0,Y.jsxs)(`div`,{className:`rounded-lg border-2 border-dashed bg-background py-16 px-6 text-center space-y-3`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:G(`engine.pageBlockCanvas.noRegions`,i)}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:G(`engine.pageBlockCanvas.noRegionsHint`,i)}),!a&&(0,Y.jsx)(`div`,{className:`pt-2`,children:(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,className:`gap-1.5 border-dashed`,onClick:p,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5`}),G(`engine.pageBlockCanvas.addRegion`,i)]})})]})})}):(0,Y.jsx)(`div`,{className:`h-full overflow-auto bg-muted/20`,onClick:h,children:(0,Y.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-6 space-y-5`,onClick:h,children:[o.map((e,t)=>(0,Y.jsx)(Ip,{region:e,regionIdx:t,shape:s,selectedId:c,readOnly:a,onSelectBlock:(n,i)=>r?.({kind:`block`,id:Mp(s,t,n,e.name),label:Np(i)}),onMoveBlock:u,onAddBlock:d,onRenameLabel:f,baseIdOf:n=>Mp(s,t,n,e.name),onSelectId:(e,t)=>r?.({kind:`block`,id:e,label:t}),onAddNested:m,locale:i},t)),!a&&s===`regions`&&(0,Y.jsx)(`div`,{className:`pt-1`,children:(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,className:`gap-1.5 text-muted-foreground`,onClick:p,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5`}),G(`engine.pageBlockCanvas.addRegion`,i)]})})]})})}function Ip({region:e,regionIdx:t,shape:n,selectedId:r,readOnly:i,onSelectBlock:a,onMoveBlock:o,onAddBlock:s,onRenameLabel:c,onSelectId:l,onAddNested:u,locale:d}){let f=Array.isArray(e.components)?e.components:[],[p,m]=J.useState(!1);return(0,Y.jsxs)(`section`,{className:R(`rounded-md transition-colors`,p&&`bg-primary/5 ring-1 ring-primary/30 -mx-1 px-1 py-1`),onDragOver:e=>{if(i)return;let t=e.dataTransfer.types;t&&Array.from(t).includes(Pp)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,m(!0))},onDragLeave:e=>{e.currentTarget===e.target&&m(!1)},onDrop:e=>{if(i||(m(!1),e.defaultPrevented))return;e.preventDefault();let n=e.dataTransfer.getData(Pp);if(n)try{let e=JSON.parse(n);if(typeof e.region!=`number`||typeof e.comp!=`number`)return;o(e,{region:t,appendEnd:!0})}catch{}},children:[(0,Y.jsxs)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground pl-1 mb-2 flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:e.name||W(`engine.pageBlockCanvas.regionN`,d,{n:t+1})}),e.width&&(0,Y.jsxs)(`span`,{className:`normal-case text-[10px] text-muted-foreground/60`,children:[`· `,e.width]}),p&&(0,Y.jsx)(`span`,{className:`text-primary normal-case text-[10px]`,children:G(`engine.pageBlockCanvas.dropHere`,d)})]}),(0,Y.jsxs)(`div`,{className:`space-y-2.5`,children:[f.length===0?(0,Y.jsx)(`div`,{className:`rounded border border-dashed bg-background/50 py-6 px-4 text-center text-xs text-muted-foreground`,children:G(n===`slots`?`engine.pageBlockCanvas.slotInherited`:`engine.pageBlockCanvas.regionEmpty`,d)}):f.map((s,f)=>{let p=Mp(n,t,f,e.name);return(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsx)(Lp,{block:s,regionIdx:t,compIdx:f,selected:p===r,readOnly:i,onClick:()=>a(f,s),onMoveBlock:o,onRenameLabel:e=>c(t,f,e),locale:d}),(0,Y.jsx)(Rp,{block:s,baseId:p,selectedId:r,readOnly:i,onSelectId:l,onAddNested:u,locale:d})]},`${t}:${f}`)}),!i&&(0,Y.jsx)(`div`,{className:`pt-1`,children:(0,Y.jsx)(zp,{onPick:e=>s(t,e),locale:d})})]})]})}function Lp({block:e,regionIdx:t,compIdx:n,selected:r,readOnly:i,onClick:a,onMoveBlock:o,onRenameLabel:s,locale:c}){let l=String(e.type??``),u=qf(l)?.Icon??Gf,d=Jf(l),f=Np(e),p=!i,[m,h]=J.useState(null),g=e=>{e.dataTransfer.setData(Pp,JSON.stringify({region:t,comp:n})),e.dataTransfer.effectAllowed=`move`},_=e=>{if(!p)return;let t=e.dataTransfer.types;if(!t||!Array.from(t).includes(Pp))return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=e.currentTarget.getBoundingClientRect();h(e.clientY-n.top<n.height/2?`before`:`after`)},v=()=>h(null),y=e=>{if(i)return;e.preventDefault(),e.stopPropagation();let r=m??`before`;h(null);let a=e.dataTransfer.getData(Pp);if(a)try{let e=JSON.parse(a);if(e.region===t&&e.comp===n)return;o(e,r===`before`?{region:t,before:n}:{region:t,after:n})}catch{}},[b,x]=J.useState(!1),[S,C]=J.useState(f);J.useEffect(()=>{C(f)},[f]);let w=e=>{i||(e.preventDefault(),e.stopPropagation(),C(f),x(!0))},T=()=>{if(i){x(!1);return}let e=S.trim();e&&e!==f&&s(e),x(!1)},E=()=>{C(f),x(!1)},D=Dp(e).length>0;return(0,Y.jsxs)(`div`,{className:R(`relative`,m===`before`&&`pt-1.5`),onDragOver:_,onDragLeave:v,onDrop:y,children:[m===`before`&&(0,Y.jsx)(`div`,{className:`absolute left-0 right-0 -top-0.5 h-0.5 bg-primary rounded-full`}),(0,Y.jsx)(`div`,{className:R(`group relative rounded-md border bg-card transition-colors hover:border-primary/40`,r?`border-primary ring-2 ring-primary/30 shadow-sm`:`border-border`),children:D?(0,Y.jsxs)(`button`,{type:`button`,onClick:a,draggable:p,onDragStart:g,className:R(`flex w-full items-center justify-between gap-2 rounded-md px-3.5 py-2.5 text-left`,i&&`cursor-default`,p&&`cursor-grab active:cursor-grabbing`),"aria-pressed":r,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,children:[p&&(0,Y.jsx)(Ar,{className:`h-3.5 w-3.5 text-muted-foreground/40 shrink-0 group-hover:text-muted-foreground/80`,"aria-hidden":`true`}),(0,Y.jsx)(u,{className:R(`h-3.5 w-3.5 shrink-0`,d.icon)}),b?(0,Y.jsx)(`input`,{autoFocus:!0,value:S,onChange:e=>C(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),T()):e.key===`Escape`&&(e.preventDefault(),E())},onBlur:T,className:`text-sm font-medium px-1 py-0.5 -mx-1 -my-0.5 rounded border border-primary bg-background outline-none min-w-0 flex-1`}):(0,Y.jsx)(`span`,{className:R(`text-sm font-medium truncate`,!i&&`cursor-text`),onDoubleClick:w,title:i?void 0:G(`designer.canvas.renameHint`,c),children:f}),e.id&&e.id!==f&&(0,Y.jsxs)(`code`,{className:`text-[10px] text-muted-foreground/70 font-mono truncate`,children:[`#`,e.id]})]}),(0,Y.jsx)(V,{variant:`outline`,className:R(`text-[10px] shrink-0 font-mono`,d.badge),children:l})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Tp,{block:e,locale:c}),(0,Y.jsx)(`button`,{type:`button`,onClick:a,draggable:p,onDragStart:g,"aria-label":W(`engine.pageBlockCanvas.select`,c,{label:f}),"aria-pressed":r,className:R(`absolute inset-0 z-10 rounded-md`,i&&`cursor-default`,p&&`cursor-grab active:cursor-grabbing`)}),(0,Y.jsxs)(`div`,{className:R(`pointer-events-none absolute right-1.5 top-1.5 z-20 flex items-center gap-1 transition-opacity`,r?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:[p&&(0,Y.jsx)(Ar,{className:`h-3.5 w-3.5 text-muted-foreground/60`,"aria-hidden":`true`}),(0,Y.jsx)(V,{variant:`outline`,className:R(`text-[10px] font-mono shadow-sm bg-background/90 backdrop-blur`,d.badge),children:l})]})]})}),m===`after`&&(0,Y.jsx)(`div`,{className:`absolute left-0 right-0 -bottom-1 h-0.5 bg-primary rounded-full`})]})}function Rp({block:e,baseId:t,selectedId:n,readOnly:r,onSelectId:i,onAddNested:a,locale:o}){let s=Dp(e,o);if(s.length===0)return null;let c=Ep[e?.type===`grid`?Math.min(6,Math.max(1,Number(e.properties?.columns)||1)):1]??`grid-cols-1`;return(0,Y.jsx)(`div`,{className:`ml-5 mt-1.5 space-y-2.5 border-l border-dashed border-border pl-3`,children:s.map((e,s)=>(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground/70`,children:e.label}),e.children.length===0?(0,Y.jsx)(`div`,{className:`rounded border border-dashed bg-background/40 py-2 px-3 text-[11px] text-muted-foreground`,children:G(`engine.pageBlockCanvas.groupEmpty`,o)}):(0,Y.jsx)(`div`,{className:R(`grid gap-2`,c),children:e.children.map((r,a)=>{let s=`${t}.${e.pathSuffix}[${a}]`,c=String(r?.type??``),l=s===n;return(0,Y.jsxs)(`div`,{className:R(`group relative rounded-md border bg-card transition-colors hover:border-primary/40`,l?`border-primary ring-2 ring-primary/30 shadow-sm`:`border-border`),children:[(0,Y.jsx)(Tp,{block:r,maxHeightClass:`max-h-56`,locale:o}),(0,Y.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i(s,Np(r))},"aria-label":W(`engine.pageBlockCanvas.select`,o,{label:Np(r)}),"aria-pressed":l,className:`absolute inset-0 z-10 rounded-md cursor-pointer`}),(0,Y.jsx)(`div`,{className:R(`pointer-events-none absolute right-1.5 top-1.5 z-20 transition-opacity`,l?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:(0,Y.jsx)(V,{variant:`outline`,className:R(`text-[10px] font-mono shadow-sm bg-background/90 backdrop-blur`,Jf(c).badge),children:c})})]},a)})}),!r&&(0,Y.jsx)(zp,{onPick:n=>a(t,e.pathSuffix,n),locale:o})]},s))})}function zp({onPick:e,locale:t}){let[n,r]=J.useState(!1),[i,a]=J.useState(``),o=i.trim().toLowerCase(),s=J.useMemo(()=>o?Wf.map(e=>({category:e.category,types:e.types.filter(e=>{let n=Vf[e];return e.includes(o)||G(n.labelKey,t).toLowerCase().includes(o)})})).filter(e=>e.types.length>0):Wf,[o,t]);return(0,Y.jsxs)(Me,{open:n,onOpenChange:e=>{r(e),e||a(``)},children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,className:`gap-1.5 border-dashed`,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5`}),G(`engine.inspector.add.block`,t)]})}),(0,Y.jsxs)(mt,{align:`start`,className:`w-[320px] p-0 max-h-[480px] overflow-hidden flex flex-col`,children:[(0,Y.jsx)(`div`,{className:`p-2 border-b`,children:(0,Y.jsx)(`input`,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),placeholder:G(`engine.pageBlockCanvas.searchTypes`,t),className:`h-7 w-full px-2 text-sm border rounded bg-background outline-none focus:ring-1 focus:ring-primary`})}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto p-1`,children:s.length===0?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground p-4 text-center`,children:G(`engine.pageBlockCanvas.noMatch`,t)}):s.map(n=>(0,Y.jsxs)(`div`,{className:`mb-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground px-2 py-1`,children:G(Uf[n.category],t)}),n.types.map(n=>{let i=Vf[n],o=i.Icon,s=Jf(n);return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{e(n),r(!1),a(``)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm hover:bg-accent text-left`,children:[(0,Y.jsx)(o,{className:R(`h-3.5 w-3.5 shrink-0`,s.icon)}),(0,Y.jsx)(`span`,{className:`truncate`,children:G(i.labelKey,t)}),(0,Y.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground/70 font-mono truncate`,children:n})]},n)})]},n.category))})]})]})}function Bp({draft:e,editing:t,selection:n,onSelectionChange:r,onPatch:i,locale:a}){let o=J.useMemo(()=>{let t=e.type??`page`;return{...e,type:t}},[e]),s=!!(t&&r),c=s&&!!i,l=n&&n.kind===`block`?n.id:null,u=ot(),d=!!e?.interfaceConfig?.source,f=J.useMemo(()=>Array.isArray(e.regions)?`regions`:`children`,[e]),p=J.useMemo(()=>{if(f===`regions`){let t=e.regions,n=[];return t.forEach((e,t)=>{(Array.isArray(e.components)?e.components:[]).forEach((r,i)=>{n.push({id:`regions[${t}].components[${i}]`,label:r.id||r.type||`${e.name??`region ${t+1}`} · ${i+1}`})})}),n}return(Array.isArray(e.children)?e.children:[]).map((e,t)=>({id:`children[${t}]`,label:e.id||e.type||W(`engine.pagePreview.blockN`,a,{n:t+1})}))},[e,f,a]),m=J.useCallback(()=>{if(!c)return;let t={type:`container`};if(f===`regions`){let n=Array.isArray(e.regions)?[...e.regions]:[],a=n.length-1;a<0&&(n.push({name:`main`,components:[]}),a=0);let o={...n[a]},s=Array.isArray(o.components)?[...o.components]:[];s.push(t),o.components=s,n[a]=o,i({regions:n}),r?.({kind:`block`,id:`regions[${a}].components[${s.length-1}]`,label:t.type});return}let n=[...Array.isArray(e.children)?e.children:[],t];i({children:n}),r?.({kind:`block`,id:`children[${n.length-1}]`,label:t.type})},[c,e,i,r,f]),h=e?.type===`record`?e?.object:void 0,[g,_]=J.useState([]),[v,y]=J.useState(null),[b,x]=J.useState(null);J.useEffect(()=>{if(!h){_([]),y(null),x(null);return}let e=!1;return(async()=>{try{let t={headers:{accept:`application/json`},credentials:`include`},n=await(await fetch(`/api/v1/meta/object/${encodeURIComponent(h)}`,t)).json().catch(()=>null),r=n?.item??n?.data??n,i=It(r?.fields),a=u?.isLoaded?i.filter(e=>u.checkField(h,e,`read`)):i,o=a.length>0?`?$top=50&$expand=${encodeURIComponent(a.join(`,`))}`:`?$top=50`,s=await(await fetch(`/api/v1/data/${encodeURIComponent(h)}${o}`,t)).json().catch(()=>null),c=Array.isArray(s?.records)?s.records:Array.isArray(s?.items)?s.items:Array.isArray(s?.data)?s.data:Array.isArray(s)?s:[];if(e)return;_(c),y(r),x(e=>e??c[0]?.id??c[0]?._id??c[0]?.name??null)}catch{e||(_([]),y(null))}})(),()=>{e=!0}},[h,u]);let S=e=>e?.id??e?._id??e?.name,C=e=>String(e?.name??e?.title??e?.label??e?.subject??S(e)??G(`engine.pagePreview.recordFallback`,a)),w=J.useMemo(()=>g.length?g.find(e=>String(S(e))===String(b))??g[0]:null,[g,b]),T=e?.kind===`slotted`,E=J.useMemo(()=>{if(!T)return o;try{let t=e?.slots??{};return Qa(v??void 0,{slots:t})}catch{return o}},[T,o,e,v]),D=e=>!h||!w?e:(0,Y.jsxs)(Jt,{objectName:h,recordId:S(w),data:w,objectSchema:v??void 0,embedded:!0,children:[g.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b bg-muted/30 text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:G(`engine.pagePreview.previewRecord`,a)}),(0,Y.jsx)(`select`,{className:`h-7 rounded-md border bg-background px-2 text-xs max-w-[260px]`,value:String(b??``),onChange:e=>x(e.target.value),children:g.map(e=>{let t=S(e);return(0,Y.jsx)(`option`,{value:String(t),children:C(e)},String(t))})}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/70 shrink-0`,children:W(g.length===1?`engine.pagePreview.sampleOne`:`engine.pagePreview.sampleOther`,a,{count:g.length})})]}),e]});if(d)return(0,Y.jsx)(X,{hint:`page · interface`,children:(0,Y.jsx)(Z,{fallbackHint:G(`engine.pagePreview.interfaceFailed`,a),children:(0,Y.jsx)($a,{page:e,onConfigChange:c?t=>i({interfaceConfig:{...e.interfaceConfig||{},...t}}):void 0})})});let O=e.kind;return O===`react`||O===`html`?(0,Y.jsx)(Bf,{draft:e,onPatch:c?i:void 0,readOnly:!c,locale:a}):!o||Object.keys(o).length<=1?(0,Y.jsxs)(X,{hint:`page${s?` · design`:``}`,children:[s&&f===`regions`?(0,Y.jsx)(Fp,{draft:e,onPatch:c?i:void 0,selection:n??null,onSelectionChange:r,locale:a}):s?(0,Y.jsx)(Lf,{title:G(`engine.inspector.pageBlock.outlineLabel`,a),entries:p,selectedId:l,onSelect:e=>r?.({kind:`block`,id:e.id,label:e.label}),onAdd:c?m:void 0,addLabel:G(`engine.inspector.add.block`,a)}):null,!s&&(0,Y.jsx)(Pf,{children:G(`engine.pagePreview.addComponents`,a)})]}):s&&f===`regions`?(0,Y.jsx)(X,{hint:`page · design`,children:D((0,Y.jsx)(Fp,{draft:e,onPatch:c?i:void 0,selection:n??null,onSelectionChange:r,locale:a}))}):(0,Y.jsx)(X,{hint:`page${s?` · design`:``}`,children:(0,Y.jsxs)(Z,{fallbackHint:G(`engine.pagePreview.schemaFailed`,a),children:[s&&(0,Y.jsx)(Lf,{title:G(`engine.inspector.pageBlock.outlineLabel`,a),entries:p,selectedId:l,onSelect:e=>r?.({kind:`block`,id:e.id,label:e.label}),onAdd:c?m:void 0,addLabel:G(`engine.inspector.add.block`,a)}),D((0,Y.jsx)(`div`,{className:`min-h-[200px] max-h-[70vh] overflow-auto p-4`,children:(0,Y.jsx)(Bt,{schema:E})}))]})})}function Vp(e,t){return e.split(/(\{\w+\})/).map((e,n)=>{let r=/^\{(\w+)\}$/.exec(e);return J.createElement(J.Fragment,{key:n},r&&r[1]in t?t[r[1]]:e)})}function Hp(e,t){let n=[t?.object,t?.data?.object,e.object,e.data?.object];for(let e of n)if(typeof e==`string`&&e)return e}var Up=[`kanban`,`calendar`,`gallery`,`timeline`,`gantt`,`map`,`chart`,`tree`];function Wp(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Gp(e){if(!(`options`in e))return e;let{options:t,...n}=e;if(!Wp(t))return n;let r={...n};for(let e of Up){let i=t[e];if(!Wp(i))continue;let a=n[e];a===void 0?r[e]={...i}:Wp(a)&&(r[e]={...i,...a})}return r}function Kp(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e,n=t.field??t.name;return n?{...t,name:n,readOnly:t.readOnly??t.readonly}:t}return String(e)}function qp(e,t){return{type:`object-form`,objectName:e,mode:`create`,formType:Sp(typeof t.type==`string`?t.type:`simple`),sections:Array.isArray(t.sections)?t.sections.map(e=>({...e,fields:Array.isArray(e?.fields)?e.fields.map(Kp):[]})):void 0,fields:Array.isArray(t.fields)?t.fields:void 0,showSubmit:!1,showCancel:!1}}function Jp({label:e}){return!e||!e.trim()?null:(0,Y.jsx)(`h3`,{className:`border-b px-3 py-2 text-sm font-medium text-foreground truncate`,children:e})}function Yp({name:e,draft:t,editing:n,locale:r}){let i=J.useMemo(()=>Ql(t)?.schema,[t]),a=J.useMemo(()=>Hp(t,i),[t,i]),o=!!n,s=I(t.label,r),{listViews:c,defaultViewId:l,defaultViewType:u}=J.useMemo(()=>{if(!i)return{listViews:{},defaultViewId:void 0,defaultViewType:`grid`};let n=String(e)||`default`;return{listViews:{[n]:{...Gp(i),label:i.label??t.label??e}},defaultViewId:n,defaultViewType:i.type??`grid`}},[i,t,e]),d=J.useMemo(()=>({type:`object-view`,objectName:a,defaultViewType:u,defaultListView:l,listViews:c,showSearch:!0,showFilters:!0,showCreate:!1,showViewSwitcher:!0}),[a,u,l,c]);if(!i&&t.type){let e={...t};return(0,Y.jsx)(X,{hint:`view · ${e.type}${o?` · design`:``}`,children:(0,Y.jsx)(Z,{fallbackHint:G(`engine.viewPreview.schemaFailed`,r),children:(0,Y.jsx)(`div`,{className:`min-h-[300px] max-h-[75vh] overflow-auto`,children:(0,Y.jsx)(Lt,{children:(0,Y.jsx)(Bt,{schema:e})})})})})}if(!a)return(0,Y.jsxs)(X,{hint:`view${o?` · design`:``}`,children:[(0,Y.jsx)(Jp,{label:s}),(0,Y.jsx)(Pf,{tone:`warn`,children:Vp(G(`engine.viewPreview.noObject`,r),{object:(0,Y.jsx)(`code`,{children:G(`engine.inspector.view.object`,r)})})})]});if(t.viewKind===`form`&&i){let e=String(i.type??`simple`),t=qp(a,i);return(0,Y.jsxs)(X,{hint:`view · ${e} · form${o?` · design`:``}`,children:[(0,Y.jsx)(Jp,{label:s}),(0,Y.jsx)(Z,{fallbackHint:G(`engine.viewPreview.formFailed`,r),children:(0,Y.jsx)(`div`,{className:`min-h-[300px] max-h-[75vh] overflow-auto`,children:(0,Y.jsx)(Lt,{children:(0,Y.jsx)(Bt,{schema:t})})})})]})}return(0,Y.jsxs)(X,{hint:`view · ${u}${o?` · design`:``}`,children:[(0,Y.jsx)(Jp,{label:s}),(0,Y.jsx)(Z,{fallbackHint:G(`engine.viewPreview.listFailed`,r),children:(0,Y.jsx)(`div`,{className:`min-h-[300px] max-h-[75vh] overflow-auto`,children:(0,Y.jsx)(Lt,{children:(0,Y.jsx)(Bt,{schema:d})})})})]})}var Xp={metric:{id:`metric`,label:`Metric (KPI)`,labelKey:`engine.widgetPicker.type.metric`,category:`kpi`,icon:Mr},bar:{id:`bar`,label:`Bar chart`,labelKey:`engine.widgetPicker.type.bar`,category:`chart`,icon:On},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,labelKey:`engine.widgetPicker.type.horizontalBar`,category:`chart`,icon:kn},line:{id:`line`,label:`Line chart`,labelKey:`engine.widgetPicker.type.line`,category:`chart`,icon:Dn},area:{id:`area`,label:`Area chart`,labelKey:`engine.widgetPicker.type.area`,category:`chart`,icon:Tn},pie:{id:`pie`,label:`Pie chart`,labelKey:`engine.widgetPicker.type.pie`,category:`chart`,icon:An},donut:{id:`donut`,label:`Donut chart`,labelKey:`engine.widgetPicker.type.donut`,category:`chart`,icon:ir},scatter:{id:`scatter`,label:`Scatter plot`,labelKey:`engine.widgetPicker.type.scatter`,category:`chart`,icon:jn},funnel:{id:`funnel`,label:`Funnel`,labelKey:`engine.widgetPicker.type.funnel`,category:`chart`,icon:qi},table:{id:`table`,label:`Data table`,labelKey:`engine.widgetPicker.type.table`,category:`data`,icon:Vi},pivot:{id:`pivot`,label:`Pivot table`,labelKey:`engine.widgetPicker.type.pivot`,category:`data`,icon:nr}},Zp={kpi:`engine.widgetPicker.category.kpi`,chart:`engine.widgetPicker.category.chart`,data:`engine.widgetPicker.category.data`},Qp=[`kpi`,`chart`,`data`].map(e=>({category:e,types:Object.values(Xp).filter(t=>t.category===e)})),$p=sn;function em({onAdd:e,label:t=`Add widget`}){let[n,r]=J.useState(!1),[i,a]=J.useState(``),o=J.useRef(null),s=$o(),c=J.useMemo(()=>{let e=i.trim().toLowerCase();return e?Qp.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||G(t.labelKey,s).toLowerCase().includes(e))})).filter(e=>e.types.length):Qp},[i,s]);return(0,Y.jsxs)(Me,{open:n,onOpenChange:e=>{r(e),e||a(``)},children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),t]})}),(0,Y.jsxs)(mt,{align:`end`,sideOffset:4,className:`w-72 p-0`,onOpenAutoFocus:e=>{e.preventDefault(),o.current?.focus()},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,Y.jsx)(Di,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`input`,{ref:o,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:G(`engine.widgetPicker.search`,s),className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,Y.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,Y.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:G(`engine.widgetPicker.noMatches`,s)}):c.map(t=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:G(Zp[t.category],s)}),t.types.map(t=>{let n=Xp[t.id]?.icon??$p;return(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,Y.jsx)(n,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`font-medium truncate`,children:G(t.labelKey,s)}),(0,Y.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id)})]},t.category))})]})]})}var tm=J.lazy(()=>n(()=>import(`./plugin-dashboard-DTkPoPEb.js`).then(e=>e.t).then(e=>({default:e.DashboardRenderer})),__vite__mapDeps([0,1]),import.meta.url));function nm({draft:e,editing:t,onPatch:n,selection:r,onSelectionChange:i,locale:a}){let o=Pt(),s=Array.isArray(e.widgets)?e.widgets:[],c=!!(t&&i),l=c&&!!n,u=r&&r.kind===`widget`?r.id:null,d=J.useCallback(e=>{if(!i)return;if(!e){i(null);return}let t=s.find(t=>t?.id===e);i({kind:`widget`,id:e,label:I(t?.title,a)||e})},[i,s,a]),f=J.useCallback(e=>{n&&n({widgets:e})},[n]),p=J.useCallback(e=>{if(!l)return;let t=ol(`widget`,s.map(e=>e?.id).filter(Boolean)),r=Xp[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`,o={id:t,type:e,title:a,...r?.defaults??{}};n({widgets:os(s,o)}),i?.({kind:`widget`,id:t,label:a})},[l,s,n,i]),m=J.useCallback((e,t)=>{if(!l)return;let r=t.trim();n({widgets:s.map(t=>t?.id===e?{...t,title:tn(t.title,a,r)}:t)}),i?.({kind:`widget`,id:e,label:r||e})},[l,s,n,i,a]),h=u?s.find(e=>e?.id===u)??null:null,g=s.length===1,_=J.useMemo(()=>g?{...e,columns:1}:e,[e,g]),v=l?(0,Y.jsx)(em,{onAdd:p,label:G(`engine.inspector.add.widget`,a)}):null;return s.length===0?(0,Y.jsx)(X,{hint:`dashboard${c?` · design`:``}`,toolbar:v,children:(0,Y.jsx)(Pf,{children:G(`engine.dashboardPreview.empty`,a)})}):(0,Y.jsx)(X,{hint:`dashboard · ${s.length} widget${s.length===1?``:`s`}${c?` · design`:``}`,toolbar:v,children:(0,Y.jsxs)(Z,{fallbackHint:G(`engine.dashboardPreview.malformed`,a),children:[l&&h?(0,Y.jsx)(rm,{widget:h,locale:a,onRename:e=>m(h.id,e),onClose:()=>i?.(null)}):null,(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsxs)(`div`,{className:`p-6 text-sm text-muted-foreground flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`}),` `,G(`engine.dashboardPreview.loading`,a)]}),children:(0,Y.jsx)(`div`,{className:`p-3 max-h-[70vh] overflow-auto`,children:(0,Y.jsx)(`div`,{className:g?void 0:`min-w-[768px]`,children:(0,Y.jsx)(tm,{schema:_,dataSource:o,designMode:c,selectedWidgetId:u,onWidgetClick:c?d:void 0,onWidgetsReorder:c&&n?f:void 0,hideHeaderText:!0})})})})]})})}function rm({widget:e,locale:t,onRename:n,onClose:r}){let i=I(e.title,t)??e.id??``,[a,o]=J.useState(!1),[s,c]=J.useState(i),l=J.useRef(null);J.useEffect(()=>{c(i),o(!1)},[e.id,i]),J.useEffect(()=>{a&&l.current?.select()},[a]);let u=()=>{let e=s.trim();e&&e!==i&&n(e),o(!1)},d=()=>{c(i),o(!1)},f=Xp[e.type]?.icon??null;return(0,Y.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b bg-primary/5 px-3 py-1.5 text-xs`,children:[f?(0,Y.jsx)(f,{className:`h-3.5 w-3.5 text-primary`}):null,(0,Y.jsx)(`span`,{className:`rounded bg-primary px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary-foreground`,children:G(`engine.dashboardPreview.selected`,t)}),a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`input`,{ref:l,value:s,onChange:e=>c(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),u()):e.key===`Escape`&&(e.preventDefault(),d())},className:`flex-1 min-w-0 rounded border bg-background px-2 py-0.5 text-xs outline-none focus:ring-1 focus:ring-primary`}),(0,Y.jsx)(`button`,{type:`button`,onClick:u,className:`rounded p-1 hover:bg-primary/10`,"aria-label":G(`engine.dashboardPreview.saveTitle`,t),children:(0,Y.jsx)(Mn,{className:`h-3.5 w-3.5`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex-1 min-w-0 truncate text-left font-medium hover:underline`,title:G(`engine.dashboardPreview.clickToRename`,t),children:i||(0,Y.jsx)(`span`,{className:`italic text-muted-foreground`,children:G(`engine.dashboardPreview.untitled`,t)})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`rounded p-1 hover:bg-primary/10`,"aria-label":G(`engine.dashboardPreview.renameWidget`,t),children:(0,Y.jsx)(di,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`rounded p-1 hover:bg-primary/10`,"aria-label":G(`engine.dashboardPreview.clearSelection`,t),children:(0,Y.jsx)(na,{className:`h-3.5 w-3.5`})})]})}var im=J.lazy(()=>n(()=>import(`./plugin-report-IZzgQb-Q.js`).then(e=>e.t).then(e=>({default:e.ReportRenderer})),__vite__mapDeps([0]),import.meta.url));function am({draft:e,locale:t}){let n=Pt(),r=e,i=typeof r.dataset==`string`&&!!r.dataset,a=r.type===`joined`&&Array.isArray(r.blocks)&&r.blocks.some(e=>typeof e?.dataset==`string`&&!!e.dataset);if(i||a){let i=Array.isArray(r.rows)?r.rows.filter(Boolean):[],o=a?`report · joined · ${r.blocks.length} block${r.blocks.length===1?``:`s`}`:`report · dataset "${r.dataset}"${i.length?` · by `+i.join(`, `):``}`;return(0,Y.jsx)(X,{hint:o,children:(0,Y.jsx)(Z,{fallbackHint:G(`engine.reportPreview.renderFailed`,t),children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-xs text-muted-foreground`,children:[(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`}),` `,G(`engine.reportPreview.loading`,t)]}),children:(0,Y.jsx)(`div`,{className:`p-3 min-h-[200px] max-h-[70vh] overflow-auto`,children:(0,Y.jsx)(im,{schema:e,dataSource:n})})})})})}let o=r.type===`joined`;return(0,Y.jsx)(X,{children:(0,Y.jsx)(Ff,{icon:(0,Y.jsx)(nr,{className:`h-8 w-8`}),title:G(o?`engine.reportPreview.joinedEmpty`:`engine.reportPreview.empty`,t),description:G(o?`engine.reportPreview.joinedEmptyHint`:`engine.reportPreview.emptyHint`,t)})})}function om(e,t){return I(e,t)??``}function sm(e,t){let n=Ya({...e,label:void 0},void 0,t);return typeof n==`string`?n:``}function cm(e,t,n){return e.label===void 0?sm(e,n):om(e.label,t)}function lm(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return t;let r=e,i=dm(r,n)??n.trim();return{...r,[i]:t}}function um(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return;let n={...e},r=dm(n,t);return r!==void 0&&delete n[r],Object.values(n).some(e=>typeof e==`string`)?n:void 0}function dm(e,t){let n=t.trim();return[n,n.split(`-`)[0]].find(t=>Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]==`string`)}var fm=`text/x-objectui-nav`;function pm(e){return typeof e.type==`string`&&e.type?e.type:`untyped`}function mm(e){switch(e){case`object`:return nr;case`page`:return gr;case`dashboard`:return Br;case`report`:return En;case`url`:return Ur;case`group`:return Sr;case`action`:return ti;case`component`:return gi;case`doc`:return gn;case`separator`:return $r;default:return $n}}var hm={object:{icon:`text-blue-500`,badge:`border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900 dark:bg-blue-950/40 dark:text-blue-300`},page:{icon:`text-violet-500`,badge:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/40 dark:text-violet-300`},dashboard:{icon:`text-teal-500`,badge:`border-teal-200 bg-teal-50 text-teal-700 dark:border-teal-900 dark:bg-teal-950/40 dark:text-teal-300`},report:{icon:`text-amber-500`,badge:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-300`},url:{icon:`text-indigo-500`,badge:`border-indigo-200 bg-indigo-50 text-indigo-700 dark:border-indigo-900 dark:bg-indigo-950/40 dark:text-indigo-300`},group:{icon:`text-slate-500`,badge:`border-slate-200 bg-slate-50 text-slate-700 dark:border-slate-800 dark:bg-slate-900/40 dark:text-slate-300`},action:{icon:`text-rose-500`,badge:`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-300`},component:{icon:`text-cyan-500`,badge:`border-cyan-200 bg-cyan-50 text-cyan-700 dark:border-cyan-900 dark:bg-cyan-950/40 dark:text-cyan-300`},doc:{icon:`text-emerald-500`,badge:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300`},separator:{icon:`text-zinc-400`,badge:`border-zinc-200 bg-zinc-50 text-zinc-500 dark:border-zinc-800 dark:bg-zinc-900/40 dark:text-zinc-400`},untyped:{icon:`text-amber-500`,badge:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-300`}};function gm(e){return hm[e]??hm.untyped}function _m(e,t,n,r){return cm(e,n,r).trim()||W(`engine.appNav.item`,n,{n:t+1})}function vm(e){let t=e=>typeof e==`string`&&e?e:void 0;switch(e.type){case`object`:return t(e.objectName);case`page`:return t(e.pageName);case`dashboard`:return t(e.dashboardName);case`report`:return t(e.reportName);case`url`:return t(e.url);case`component`:return t(e.componentRef);case`action`:return t(e.actionDef?.actionName);case`doc`:return t(e.doc)??t(e.book);default:return}}function ym({draft:e,rootKey:t,onPatch:n,selection:r,onSelectionChange:i}){let a=$o(),o=Na(),s=J.useMemo(()=>{let n=e[t];return Array.isArray(n)?n:[]},[e,t]),c=r&&r.kind===`nav`?r.id:null,[l,u]=J.useState(null),d=J.useCallback(e=>{n&&n({[t]:e})},[n,t]),f=J.useCallback(()=>{if(!n)return;let e=new Set(s.map(e=>typeof e.id==`string`?e.id:``).filter(Boolean)),r=`nav_item_${s.length+1}`;for(let t=s.length+2;e.has(r);t++)r=`nav_item_${t}`;let c={id:r,type:`object`},l=os(s,c);d(l),i?.({kind:`nav`,id:`${t}[${l.length-1}]`,label:_m(c,l.length-1,a,o)})},[n,s,d,t,i,a,o]),p=J.useCallback(e=>{if(!n)return;let r=xs(s,e,null);d(r),c===`${t}[${e}]`&&i?.(null)},[n,s,d,t,c,i]),m=J.useCallback((e,r)=>{if(!n)return;let o=s[e]??{},l={...o,label:lm(o.label,r,a)},u=xs(s,e,l);d(u),c===`${t}[${e}]`&&i?.({kind:`nav`,id:`${t}[${e}]`,label:r})},[n,s,d,t,c,i,a]),h=J.useCallback((e,r)=>{if(!n)return;let c=r;if(e<r&&(c=r-1),c===e)return;let l=rs(s,e,c);d(l),i?.({kind:`nav`,id:`${t}[${c}]`,label:_m(l[c]??{},c,a,o)})},[n,s,d,t,i,a,o]);return(0,Y.jsxs)(`div`,{className:`rounded-md border bg-card/40`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,Y.jsx)(`span`,{className:`font-medium uppercase tracking-wide text-muted-foreground`,children:G(`engine.appNav.heading`,a)}),(0,Y.jsxs)(V,{variant:`outline`,className:`text-[10px]`,children:[s.length,` `,s.length===1?G(`engine.appNav.itemOne`,a):G(`engine.appNav.itemOther`,a)]})]}),n&&(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:f,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),` `,G(`engine.appNav.addItem`,a)]})]}),(0,Y.jsx)(`div`,{className:`space-y-1.5 p-2`,onDragOver:e=>{n&&e.dataTransfer.types.includes(fm)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`)},onDrop:e=>{n&&e.dataTransfer.types.includes(fm)&&(e.preventDefault(),l!=null&&(h(l,s.length),u(null)))},children:s.length===0?(0,Y.jsx)(`div`,{className:`rounded border border-dashed px-3 py-4 text-center text-[11px] text-muted-foreground`,children:G(n?`engine.appNav.empty`:`engine.appNav.emptyReadonly`,a)}):s.map((e,r)=>(0,Y.jsx)(bm,{item:e,index:r,depth:0,path:`${t}[${r}]`,locale:a,targetLabel:o,selectedId:c,canEdit:!!n,onClick:(e,t)=>i?.({kind:`nav`,id:e,label:t}),onRename:e=>m(r,e),onRemove:()=>p(r),onDragStart:()=>u(r),onDragEnd:()=>u(null),onDropBefore:()=>{l!=null&&(h(l,r),u(null))}},r))})]})}function bm({item:e,index:t,depth:n,path:r,locale:i,targetLabel:a,selectedId:o,canEdit:s,onClick:c,onRename:l,onRemove:u,onDragStart:d,onDragEnd:f,onDropBefore:p}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(xm,{item:e,index:t,depth:n,path:r,locale:i,targetLabel:a,isSelected:o===r,canEdit:s&&n===0,onClick:()=>c(r,_m(e,t,i,a)),onRename:l,onRemove:u,onDragStart:d,onDragEnd:f,onDropBefore:p}),Array.isArray(e.children)&&e.children.map((e,t)=>{let l=`${r}.children[${t}]`;return(0,Y.jsx)(bm,{item:e,index:t,depth:n+1,path:l,locale:i,targetLabel:a,selectedId:o,canEdit:s,onClick:c,onRename:()=>void 0,onRemove:()=>void 0,onDragStart:()=>void 0,onDragEnd:()=>void 0,onDropBefore:()=>void 0},t)})]})}function xm({item:e,index:t,depth:n,path:r,locale:i,targetLabel:a,isSelected:o,canEdit:s,onClick:c,onRename:l,onRemove:u,onDragStart:d,onDragEnd:f,onDropBefore:p}){let m=pm(e),h=mm(m),g=gm(m),_=vm(e),v=_m(e,t,i,a),y=om(e.label,i).trim(),[b,x]=J.useState(!1),[S,C]=J.useState(y),[w,T]=J.useState(!1),[E,D]=J.useState(null);return J.useEffect(()=>{b||C(y)},[y,b]),(0,Y.jsxs)(`div`,{className:`relative`,style:{paddingLeft:n*16},children:[E===`before`&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 -top-0.5 h-0.5 rounded bg-primary`}),(0,Y.jsxs)(`button`,{type:`button`,draggable:s&&!b,onDragStart:e=>{s&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(fm,r),d())},onDragEnd:f,onDragOver:e=>{s&&e.dataTransfer.types.includes(fm)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,D(`before`))},onDragLeave:()=>D(null),onDrop:e=>{s&&e.dataTransfer.types.includes(fm)&&(e.preventDefault(),e.stopPropagation(),D(null),p())},onClick:c,onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1),"aria-pressed":o,className:`group flex w-full items-center gap-2 rounded-md border bg-card px-2.5 py-2 text-left text-xs transition-colors hover:border-primary/40 ${o?`border-primary ring-1 ring-primary`:`border-border`} ${s&&!b?`cursor-grab active:cursor-grabbing`:``}`,children:[s?(0,Y.jsx)(Ar,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/50 group-hover:text-muted-foreground`}):(0,Y.jsx)(`span`,{className:`w-3.5`}),(0,Y.jsx)(h,{className:R(`h-3.5 w-3.5 shrink-0`,g.icon)}),b?(0,Y.jsx)(`input`,{autoFocus:!0,value:S,placeholder:v,onChange:e=>C(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>{x(!1);let e=S.trim();e&&e!==y&&l(e)},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.target.blur()):e.key===`Escape`&&(e.preventDefault(),C(y),x(!1))},className:`flex-1 min-w-0 rounded border border-input bg-background px-1.5 py-0.5 text-xs outline-none focus:border-primary`}):(0,Y.jsx)(`span`,{className:`flex-1 min-w-0 truncate font-medium`,onDoubleClick:e=>{s&&(e.stopPropagation(),x(!0))},children:v}),(0,Y.jsx)(V,{variant:`outline`,className:R(`text-[10px] font-medium`,g.badge),children:m}),_&&(0,Y.jsx)(`code`,{className:`ml-0 text-[10px] text-muted-foreground truncate max-w-[10rem]`,children:_}),s&&w&&!b&&(0,Y.jsx)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),u()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),u())},className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,"aria-label":G(`engine.appNav.removeItem`,i),children:(0,Y.jsx)(Ki,{className:`h-3 w-3`})})]})]})}var Sm=Object.keys({object:!0,dashboard:!0,page:!0,url:!0,report:!0,action:!0,component:!0,doc:!0,group:!0,separator:!0});function Cm(e,t){switch(t){case`object`:return typeof e.objectName==`string`?e.objectName:void 0;case`dashboard`:return typeof e.dashboardName==`string`?e.dashboardName:void 0;case`page`:return typeof e.pageName==`string`?e.pageName:void 0;case`report`:return typeof e.reportName==`string`?e.reportName:void 0;case`url`:return typeof e.url==`string`?e.url:void 0;case`component`:return typeof e.componentRef==`string`?e.componentRef:void 0;case`action`:{let t=e.actionDef;return t&&typeof t.actionName==`string`?t.actionName:void 0}case`doc`:return typeof e.doc==`string`?e.doc:typeof e.book==`string`?e.book:void 0;default:return}}function wm(e,t,n,r,i){return Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return null;let a=typeof e.type==`string`&&Sm.includes(e.type)?e.type:void 0;if(a===`separator`)return{id:typeof e.id==`string`?e.id:void 0,label:``,kind:a};let o=Cm(e,a);if(!om(e.label,r).trim()&&!e.children&&!o)return null;let s=cm(e,r,i).trim(),c,l=!1;if(a&&t)try{let n=qa(e,`/apps/${encodeURIComponent(t)}`);n.href&&n.href!==`#`&&(c=n.href,l=n.external)}catch{c=void 0}let u=Array.isArray(e.children)?wm(e.children,t,n,r,i):void 0;return{id:typeof e.id==`string`?e.id:void 0,label:s||n,kind:a,target:o,href:c,external:l,children:u}}).filter(e=>e!==null):[]}function Tm(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(!r||typeof r!=`object`)continue;let e=r;n.push({id:typeof e.id==`string`&&e.id?e.id:void 0,label:I(e.label,t)||void 0,description:I(e.description,t)||void 0})}return n}function Em(e){switch(e){case`object`:return nr;case`page`:return gr;case`dashboard`:return Br;case`report`:return En;case`url`:return Ur;case`group`:return Sr;case`action`:return ti;case`component`:return gi;case`doc`:return gn;case`separator`:return $r;default:return $n}}function Dm(e){for(let t of e){if(t.kind===`group`){let e=t.children?Dm(t.children):void 0;if(e)return e;continue}if(t.kind!==`url`&&t.kind!==`separator`&&t.kind!==`action`&&t.kind!==`doc`&&t.href)return t}}function Om({name:e,draft:t,editing:n,selection:r,onSelectionChange:i,onPatch:a,locale:o}){let s=String(t.name??e??``),c=I(t.label,o)??s,l=G(`engine.appPreview.unnamed`,o),u=Na(),{rootKey:d,navItems:f}=J.useMemo(()=>{let e=[[`nav`,t.nav],[`navigation`,t.navigation],[`tabs`,t.tabs],[`items`,t.items],[`menu`,t.menu]];for(let[t,n]of e)if(Array.isArray(n)&&n.length)return{rootKey:t,navItems:wm(n,s,l,o,u)};return{rootKey:null,navItems:[]}},[t,s,l,o,u]),p=J.useMemo(()=>Dm(f),[f]),m=Tm(t.areas,o),h=d??`navigation`,g=!!(n&&i),_=g&&!!a,v=r&&r.kind===`nav`?r.id:null,y=g?(e,t)=>i({kind:`nav`,id:e,label:t.label}):void 0,b=s?`/apps/${encodeURIComponent(s)}/`:null;return(0,Y.jsx)(X,{hint:`app`,toolbar:b&&(0,Y.jsxs)(`a`,{href:b,target:`_blank`,rel:`noreferrer`,className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,title:G(`engine.appPreview.openTitle`,o),children:[G(`engine.appPreview.open`,o),` `,(0,Y.jsx)(cr,{className:`h-3 w-3`})]}),children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`rounded border bg-muted/30 p-3`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:c}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono mt-0.5`,children:s}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:p?(0,Y.jsxs)(Y.Fragment,{children:[G(`engine.appPreview.homeFirst`,o),(0,Y.jsxs)(`span`,{className:`ml-1.5`,children:[`→ `,p.label]})]}):(0,Y.jsx)(Y.Fragment,{children:G(`engine.appPreview.homeNone`,o)})})]}),m.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:G(`engine.appPreview.areas`,o)}),(0,Y.jsx)(`ul`,{className:`border rounded divide-y`,children:m.map((e,t)=>(0,Y.jsxs)(`li`,{className:`px-3 py-2 text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[e.label&&(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.id&&(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.id})]}),e.description&&(0,Y.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:e.description})]},t))})]}),g?(0,Y.jsx)(ym,{draft:t,rootKey:h,onPatch:_?a:void 0,selection:r??null,onSelectionChange:i}):f.length===0?(0,Y.jsx)(Pf,{children:Vp(G(`engine.appPreview.empty`,o),{navigation:(0,Y.jsx)(`code`,{children:`navigation`})})}):(0,Y.jsx)(`div`,{className:`border rounded divide-y`,children:f.map((e,t)=>(0,Y.jsx)(km,{item:e,depth:0,path:`${d}[${t}]`,onSelect:y,selectedId:v,locale:o},t))})]})})})}function km({item:e,depth:t,path:n,onSelect:r,selectedId:i,locale:a}){let o=Em(e.kind),s=e.href;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/40 ${r?`cursor-pointer`:``} ${i===n?`bg-primary/5 ring-1 ring-primary`:``}`,style:{paddingLeft:`${12+t*16}px`},onClick:r?t=>{t.stopPropagation(),r(n,e)}:void 0,children:[(0,Y.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`font-medium truncate`,children:e.label}),e.kind?(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider opacity-60`,children:e.kind}):(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-amber-700`,title:G(`engine.appPreview.noTypeTitle`,a),children:G(`engine.appPreview.noType`,a)}),e.target&&(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground truncate`,children:e.target}),s&&(0,Y.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`ml-auto font-mono text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[s,` `,(0,Y.jsx)(cr,{className:`h-3 w-3`})]})]}),e.children?.map((e,o)=>(0,Y.jsx)(km,{item:e,depth:t+1,path:`${n}.children[${o}]`,onSelect:r,selectedId:i,locale:a},o))]})}function Am(e){let{type:t,locale:n}=e;switch(t){case`text`:case`password`:return(0,Y.jsx)(jm,{...e,icon:t===`password`?(0,Y.jsx)(Kr,{className:`h-3.5 w-3.5`}):void 0});case`email`:return(0,Y.jsx)(jm,{...e,icon:(0,Y.jsx)(mn,{className:`h-3.5 w-3.5`}),placeholder:e.placeholder??`name@example.com`});case`url`:return(0,Y.jsx)(jm,{...e,icon:(0,Y.jsx)(kr,{className:`h-3.5 w-3.5`}),placeholder:e.placeholder??`https://…`});case`phone`:return(0,Y.jsx)(jm,{...e,icon:(0,Y.jsx)(fi,{className:`h-3.5 w-3.5`}),placeholder:e.placeholder??`+1 555 …`});case`number`:case`currency`:case`percent`:case`autonumber`:return(0,Y.jsx)(jm,{...e,icon:(0,Y.jsx)(Mr,{className:`h-3.5 w-3.5`}),placeholder:e.placeholder??`0`});case`date`:case`datetime`:return(0,Y.jsx)(jm,{...e,icon:(0,Y.jsx)(wn,{className:`h-3.5 w-3.5`}),placeholder:G(`designer.stub.pickDate`,n)});case`time`:return(0,Y.jsx)(jm,{...e,icon:(0,Y.jsx)(qn,{className:`h-3.5 w-3.5`}),placeholder:`hh:mm`});case`textarea`:case`markdown`:case`html`:case`richtext`:case`json`:case`code`:return(0,Y.jsx)(Mm,{...e,mono:t===`json`||t===`code`});case`boolean`:case`toggle`:return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 h-8`,children:[(0,Y.jsx)(rt,{disabled:!0}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.placeholder??G(`designer.stub.off`,n)})]});case`select`:case`radio`:return(0,Y.jsx)(Nm,{...e,single:!0});case`multiselect`:case`checkboxes`:case`tags`:return(0,Y.jsx)(Nm,{...e,single:!1});case`lookup`:case`master_detail`:case`tree`:return(0,Y.jsx)(Pm,{...e});case`image`:case`avatar`:return(0,Y.jsx)(Fm,{icon:(0,Y.jsx)(Nr,{className:`h-4 w-4`}),label:G(t===`avatar`?`designer.stub.uploadAvatar`:`designer.stub.uploadImage`,n)});case`file`:case`video`:case`audio`:case`signature`:return(0,Y.jsx)(Fm,{icon:(0,Y.jsx)(ui,{className:`h-4 w-4`}),label:W(`designer.stub.upload`,n,{type:t})});case`qrcode`:return(0,Y.jsx)(Fm,{icon:(0,Y.jsx)(ui,{className:`h-4 w-4`}),label:G(`designer.stub.qrcode`,n)});case`color`:return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 h-8`,children:[(0,Y.jsx)(`span`,{className:`inline-block h-6 w-6 rounded border`,style:{background:`#3b82f6`}}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`#3b82f6`}),(0,Y.jsx)(ai,{className:`h-3.5 w-3.5 text-muted-foreground`})]});case`rating`:return(0,Y.jsx)(`div`,{className:`flex items-center gap-0.5 h-8`,children:[0,1,2,3,4].map(e=>(0,Y.jsx)(Ri,{className:`h-4 w-4 `+(e<3?`fill-amber-400 text-amber-400`:`text-muted-foreground/40`)},e))});case`slider`:return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 h-8`,children:[(0,Y.jsxs)(`div`,{className:`relative flex-1 h-1.5 rounded bg-muted`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-2/5 rounded bg-primary`}),(0,Y.jsx)(`div`,{className:`absolute h-3 w-3 -top-[3px] left-[40%] rounded-full border-2 border-primary bg-background`})]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:`40`})]});case`progress`:return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 h-8`,children:[(0,Y.jsx)(`div`,{className:`relative flex-1 h-2 rounded bg-muted`,children:(0,Y.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-3/5 rounded bg-emerald-500`})}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:`60%`})]});case`location`:return(0,Y.jsx)(jm,{...e,icon:(0,Y.jsx)(Jr,{className:`h-3.5 w-3.5`}),placeholder:G(`designer.stub.latLng`,n)});case`address`:return(0,Y.jsx)(Mm,{...e,placeholder:e.placeholder??G(`designer.stub.address`,n)});case`formula`:case`summary`:return(0,Y.jsx)(`div`,{className:`h-8 px-2 flex items-center text-xs font-mono bg-muted/40 border rounded text-muted-foreground`,children:e.formula?`ƒ ${e.formula}`:`ƒ ${G(`designer.stub.computed`,n)}`});case`composite`:return(0,Y.jsx)(`div`,{className:`p-2 border-dashed border-2 rounded text-[11px] text-muted-foreground italic`,children:G(`designer.stub.composite`,n)});case`repeater`:return(0,Y.jsx)(`div`,{className:`p-2 border-dashed border-2 rounded text-[11px] text-muted-foreground italic`,children:G(`designer.stub.repeater`,n)});case`vector`:return(0,Y.jsxs)(`div`,{className:`h-8 px-2 flex items-center text-xs font-mono bg-muted/40 border rounded text-muted-foreground`,children:[`[0.124, 0.337, …] `,e.placeholder?`(${e.placeholder})`:``]});default:return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(z,{disabled:!0,placeholder:e.placeholder??`(${t})`,className:`h-8 text-sm`}),(0,Y.jsx)(V,{variant:`outline`,className:`text-[10px]`,children:t})]})}}function jm({placeholder:e,icon:t}){return(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(z,{disabled:!0,placeholder:e??``,className:`h-8 text-sm `+(t?`pl-8`:``)}),t&&(0,Y.jsx)(`div`,{className:`absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`,children:t})]})}function Mm({placeholder:e,mono:t}){return(0,Y.jsx)(`textarea`,{disabled:!0,placeholder:e??``,className:`w-full min-h-[60px] text-sm rounded-md border bg-background px-2 py-1.5 disabled:opacity-100 `+(t?`font-mono text-xs`:``)})}function Nm({options:e,placeholder:t,single:n,locale:r}){let i=(e??[]).filter(e=>e.value||e.label),a=i.slice(0,n?1:3);return n?(0,Y.jsxs)(`div`,{className:`h-8 px-2 flex items-center justify-between text-sm border rounded bg-background text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:a[0]?.label||a[0]?.value||t||G(`designer.stub.select`,r)}),(0,Y.jsx)(Nn,{className:`h-3.5 w-3.5 shrink-0`})]}):(0,Y.jsxs)(`div`,{className:`min-h-8 px-1.5 py-1 flex items-center flex-wrap gap-1 border rounded bg-background`,children:[a.length===0?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground px-1`,children:t||G(`designer.stub.pickMulti`,r)}):a.map((e,t)=>(0,Y.jsx)(V,{variant:`secondary`,className:`text-[10px]`,children:e.label||e.value},t)),i.length>a.length&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,i.length-a.length]})]})}function Pm({referenceTo:e,placeholder:t,locale:n}){let r=e?fs.lookup:null;return(0,Y.jsxs)(`div`,{className:`h-8 px-2 flex items-center gap-2 border rounded bg-background text-sm text-muted-foreground`,children:[(0,Y.jsx)(Hr,{className:`h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate flex-1`,children:t||(e?W(`designer.stub.searchRef`,n,{ref:e}):G(`designer.stub.chooseRelated`,n))}),e&&(0,Y.jsxs)(V,{variant:`outline`,className:`text-[10px] shrink-0`,children:[`→ `,e]}),!e&&(0,Y.jsx)(Di,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}),r&&null]})}function Fm({icon:e,label:t}){return(0,Y.jsxs)(`div`,{className:`h-16 w-full border-2 border-dashed rounded flex flex-col items-center justify-center gap-1 text-muted-foreground bg-muted/20`,children:[e,(0,Y.jsx)(`span`,{className:`text-[11px]`,children:t})]})}var Im=(e,t)=>e?G(`engine.fieldType.${e.id}`,t):void 0,Lm=(e,t)=>G(`engine.fieldCategory.${e}`,t);function Rm({objectName:e,draft:t,baseline:n,onPatch:r,selection:i,onSelectionChange:a,locale:o}){let s=!r,{enabled:c}=js(),l=J.useMemo(()=>vo(t.fields),[t]),u=J.useMemo(()=>n?zo(n.fields,t.fields):null,[n,t]),d=u?u.counts.added+u.counts.changed+u.counts.removed:0,[f,p]=J.useState(!1);J.useEffect(()=>{f&&d===0&&p(!1)},[f,d]);let m=f&&d>0,h=e=>m?u?.byName[e]?.status:void 0,g=e=>m?u?.byName[e]?.changedKeys??[]:[],_=J.useMemo(()=>to(t.fieldGroups),[t]),v=_.length>0,y=J.useMemo(()=>uo(l,_,{includeEmptyDeclared:!s}),[l,_,s]),[b,x]=J.useState({}),S=e=>e??`__ungrouped__`,C=J.useCallback(e=>{let t=e??`__ungrouped__`;x(e=>({...e,[t]:!e[t]}))},[]),w=y.length>0&&y.every(e=>b[S(e.key)]),T=J.useCallback(e=>{x(()=>{let t={};for(let n of y)t[S(n.key)]=e;return t})},[y]),E=i?.kind===`field`?String(i.id):null,D=l.entries.filter(e=>!!e.def.required).length,O=J.useCallback(e=>{a&&a({kind:`field`,id:e.name,label:typeof e.def.label==`string`?e.def.label:e.name})},[a]),[k,A]=J.useState(()=>new Set),j=J.useRef(null),M=J.useMemo(()=>y.flatMap(e=>e.entries.map(e=>e.name)),[y]);J.useEffect(()=>{A(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>l.entries.some(t=>t.name===e)));return t.size===e.size?e:t})},[l]);let N=J.useCallback((e,t)=>{let n=e.name;if(!s&&t&&(t.metaKey||t.ctrlKey)){A(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),j.current=n;return}if(!s&&t&&t.shiftKey&&j.current&&j.current!==n){let e=M.indexOf(j.current),t=M.indexOf(n);if(e>=0&&t>=0){let[n,r]=e<t?[e,t]:[t,e];A(new Set(M.slice(n,r+1)));return}}k.size&&A(new Set),j.current=n,O(e)},[s,M,k,O]),P=J.useCallback(()=>A(new Set),[]),ee=J.useCallback(()=>{if(!r||k.size===0)return;let e=l.entries.filter(e=>!k.has(e.name));r({fields:Oo({shape:l.shape,entries:e})}),E&&k.has(E)&&a?.(null),A(new Set)},[r,k,l,E,a]),F=J.useCallback(e=>{if(!r||k.size===0)return;let t=l.entries.map(t=>k.has(t.name)?{name:t.name,def:{...t.def,group:e??void 0}}:t);r({fields:Oo({shape:l.shape,entries:t})})},[r,k,l]),te=J.useCallback((e,t)=>{if(!r)return;let n=l.entries.map(e=>e.name),i=e===`select`?`status`:e,o=1,s=i;for(;n.includes(s);)o+=1,s=`${i}_${o}`;let c=Eo(s,e);t&&(c.def={...c.def,group:t});let u=l.entries.length;if(t){for(let e=l.entries.length-1;e>=0;--e)if(l.entries[e].def.group===t){u=e+1;break}}let d=l.entries.slice();d.splice(u,0,c),r({fields:Oo({shape:l.shape,entries:d})}),a?.({kind:`field`,id:s,label:String(c.def.label??s)})},[r,a,l]),ne=J.useCallback(()=>{if(!r)return;let e=W(`designer.canvas.sectionN`,o,{n:_.length+1}),t=so(_,e),n=t[t.length-1];r({fieldGroups:t}),x(e=>({...e,[n.key]:!1}))},[r,_,o]),re=J.useCallback((e,t)=>{r&&r({fieldGroups:Uo(_,e,t)})},[r,_]),ie=J.useCallback(e=>{if(!r)return;let t=fo(l,e);r({fieldGroups:jo(_,e),fields:Oo(t)})},[r,_,l]),ae=J.useCallback((e,t)=>{r&&r({fieldGroups:wo(_,e,t)})},[r,_]),oe=J.useCallback((e,t,n)=>{if(!r||e===t)return;let i=l.entries.slice(),a=i.findIndex(t=>t.name===e);if(a<0)return;let[o]=i.splice(a,1),s=i.findIndex(e=>e.name===t),c=s>=0?i[s]:void 0;if(c){let e=typeof c.def.group==`string`?c.def.group:void 0;e!==(typeof o.def.group==`string`?o.def.group:void 0)&&(o.def={...o.def,group:e})}s<0?i.push(o):i.splice(n===`before`?s:s+1,0,o),r({fields:Oo({shape:l.shape,entries:i})})},[r,l]),I=J.useCallback((e,t)=>{if(!r)return;let n=l.entries.slice(),i=n.findIndex(t=>t.name===e);if(i<0)return;let a=typeof n[i].def.group==`string`?n[i].def.group:null,o=i+t;for(;o>=0&&o<n.length&&(typeof n[o].def.group==`string`?n[o].def.group:null)!==a;)o+=t;if(o<0||o>=n.length)return;let s=n[i];n[i]=n[o],n[o]=s,r({fields:Oo({shape:l.shape,entries:n})})},[r,l]),se=J.useCallback((e,t)=>{if(!r)return;let n=l.entries.slice(),i=n.findIndex(t=>t.name===e);if(i<0)return;let[a]=n.splice(i,1);if((typeof a.def.group==`string`?a.def.group:null)===t){n.splice(i,0,a);return}a.def={...a.def,group:t??void 0};let o=n.length;for(let e=n.length-1;e>=0;--e)if((typeof n[e].def.group==`string`?n[e].def.group:null)===t){o=e+1;break}n.splice(o,0,a),r({fields:Oo({shape:l.shape,entries:n})})},[r,l]),ce=J.useCallback((e,t)=>{if(!r)return;let n=l.entries.map(n=>n.name===e?{name:e,def:{...n.def,label:t||void 0}}:n);r({fields:Oo({shape:l.shape,entries:n})})},[r,l]),le=J.useCallback(e=>{e.target===e.currentTarget&&E&&a?.(null)},[a,E]),ue=l.entries.length===0,de=v||y.length>1;return(0,Y.jsxs)(`div`,{className:`h-full overflow-auto bg-muted/20`,onClick:le,"data-object-name":e,children:[!s&&k.size>0&&(0,Y.jsx)(Bm,{count:k.size,groups:_,onMoveToGroup:F,onDelete:ee,onClear:P,locale:o}),(0,Y.jsxs)(`div`,{className:`mx-auto max-w-3xl px-6 py-6 space-y-4`,onClick:le,children:[!ue&&(0,Y.jsx)(zm,{fieldCount:l.entries.length,requiredCount:D,sectionCount:_.length,allCollapsed:w,onToggleAll:de?()=>T(!w):void 0,reviewAvailable:d>0,reviewing:m,diffCounts:u?.counts,onToggleReview:()=>p(e=>!e),locale:o}),ue?(0,Y.jsx)(Gm,{onAdd:s?void 0:te,locale:o,aiEnabled:c}):(0,Y.jsx)(`div`,{className:`space-y-5`,children:y.map(e=>{let t=e.key?_.findIndex(t=>t.key===e.key):-1;return(0,Y.jsxs)(Vm,{groupKey:e.key,label:e.key===null?G(`designer.canvas.ungrouped`,o):e.label,count:e.entries.length,showHeader:de,collapsed:!!b[S(e.key)],onToggleCollapse:()=>C(e.key),readOnly:s,locale:o,canMoveUp:t>0,canMoveDown:t>=0&&t<_.length-1,onRename:e.key?t=>re(e.key,t):void 0,onRemove:e.key?()=>ie(e.key):void 0,onMove:e.key?t=>ae(e.key,t):void 0,onAddField:s?void 0:t=>te(t,e.key),onDropField:s?void 0:se,children:[e.entries.map(e=>(0,Y.jsx)(Wm,{entry:e,selected:e.name===E,multiSelected:k.has(e.name),diffStatus:h(e.name),changedKeys:g(e.name),readOnly:s,locale:o,onClick:t=>N(e,t),onReorder:s?void 0:oe,onRenameLabel:s?void 0:ce,onMoveOffset:s?void 0:t=>I(e.name,t)},e.name)),e.entries.length===0&&(0,Y.jsx)(`div`,{className:`rounded-md border border-dashed bg-background/40 px-3 py-4 text-center text-[11px] text-muted-foreground`,children:G(s?`designer.canvas.emptySection`:`designer.canvas.dropHint`,o)})]},e.key??`__ungrouped__`)})}),m&&u&&u.removed.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-destructive/80 pl-1`,children:G(`designer.canvas.diffRemoved`,o)}),u.removed.map(e=>(0,Y.jsx)(Um,{entry:e,locale:o},e.name))]}),!ue&&!s&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Y.jsx)(Km,{onPick:e=>te(e),locale:o}),(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,className:`gap-1.5 text-muted-foreground hover:text-foreground`,onClick:ne,children:[(0,Y.jsx)(br,{className:`h-3.5 w-3.5`}),G(`designer.canvas.addSection`,o)]}),c&&(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,className:`gap-1.5 ml-auto text-primary/80 hover:text-primary`,onClick:()=>la(),children:[(0,Y.jsx)(Fi,{className:`h-3.5 w-3.5`}),G(`designer.canvas.askAi`,o)]})]})]})]})}function zm({fieldCount:e,requiredCount:t,sectionCount:n,allCollapsed:r,onToggleAll:i,reviewAvailable:a,reviewing:o,diffCounts:s,onToggleReview:c,locale:l}){return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:o&&s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-emerald-600 dark:text-emerald-400`,children:s.added}),` `,G(`designer.canvas.diffAdded`,l),(0,Y.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Y.jsx)(`span`,{className:`font-medium text-amber-600 dark:text-amber-400`,children:s.changed}),` `,G(`designer.canvas.diffChanged`,l),(0,Y.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Y.jsx)(`span`,{className:`font-medium text-destructive`,children:s.removed}),` `,G(`designer.canvas.diffRemoved`,l),(0,Y.jsx)(`span`,{className:`text-muted-foreground/40 normal-case ml-1`,children:G(`designer.canvas.reviewVsPublished`,l)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e}),` `,G(`designer.canvas.fields`,l),(0,Y.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Y.jsx)(`span`,{className:`font-medium text-foreground/80`,children:t}),` `,G(`designer.canvas.required`,l),n>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,Y.jsx)(`span`,{className:`font-medium text-foreground/80`,children:n}),` `,G(`designer.canvas.sections`,l)]})]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[a&&c&&(0,Y.jsxs)(`button`,{type:`button`,onClick:c,className:R(`inline-flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors`,o?`bg-primary/10 text-primary hover:bg-primary/15`:`hover:bg-accent hover:text-foreground`),children:[(0,Y.jsx)(Dr,{className:`h-3 w-3`}),G(o?`designer.canvas.reviewExit`:`designer.canvas.reviewChanges`,l)]}),i&&(0,Y.jsxs)(`button`,{type:`button`,onClick:i,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 hover:bg-accent hover:text-foreground transition-colors`,children:[r?(0,Y.jsx)(Ln,{className:`h-3 w-3`}):(0,Y.jsx)(In,{className:`h-3 w-3`}),G(r?`designer.canvas.expandAll`:`designer.canvas.collapseAll`,l)]})]})]})}function Bm({count:e,groups:t,onMoveToGroup:n,onDelete:r,onClear:i,locale:a}){let[o,s]=J.useState(!1);return(0,Y.jsxs)(`div`,{className:`sticky top-0 z-20 flex items-center gap-2 border-b border-primary/20 bg-primary/10 backdrop-blur px-6 py-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:W(`designer.canvas.bulkSelected`,a,{n:e})}),(0,Y.jsx)(`span`,{className:`text-muted-foreground text-[11px] hidden md:inline`,children:G(`designer.canvas.bulkHint`,a)}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[t.length>0&&(0,Y.jsxs)(Me,{open:o,onOpenChange:s,children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5 bg-background/70`,children:[(0,Y.jsx)(yr,{className:`h-3.5 w-3.5`}),G(`designer.canvas.bulkMoveTo`,a),(0,Y.jsx)(Nn,{className:`h-3 w-3`})]})}),(0,Y.jsxs)(mt,{align:`end`,className:`w-52 p-1 max-h-[300px] overflow-auto`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{n(null),s(!1)},className:`w-full text-left px-2 py-1.5 rounded text-sm hover:bg-accent`,children:G(`designer.canvas.ungrouped`,a)}),t.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{n(e.key),s(!1)},className:`w-full text-left px-2 py-1.5 rounded text-sm hover:bg-accent truncate`,children:e.label||e.key},e.key))]})]}),(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5 bg-background/70 text-destructive hover:text-destructive`,onClick:r,children:[(0,Y.jsx)(Ki,{className:`h-3.5 w-3.5`}),G(`designer.canvas.bulkDelete`,a)]}),(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,className:`h-7 gap-1.5`,onClick:i,children:[(0,Y.jsx)(na,{className:`h-3.5 w-3.5`}),G(`designer.canvas.bulkClear`,a)]})]})]})}function Vm({groupKey:e,label:t,count:n,showHeader:r,collapsed:i,onToggleCollapse:a,readOnly:o,locale:s,canMoveUp:c,canMoveDown:l,onRename:u,onRemove:d,onMove:f,onAddField:p,onDropField:m,children:h}){let[g,_]=J.useState(!1);return(0,Y.jsxs)(`section`,{className:R(`space-y-2.5 rounded-md transition-colors`,g&&`bg-primary/5 ring-1 ring-primary/30 -mx-1 px-1 py-1`),onDragOver:e=>{if(!m)return;let t=e.dataTransfer.types;t&&Array.from(t).includes(`text/x-objectui-field`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,_(!0))},onDragLeave:e=>{e.currentTarget===e.target&&_(!1)},onDrop:t=>{if(!m)return;if(t.defaultPrevented){_(!1);return}t.preventDefault();let n=t.dataTransfer.getData(`text/x-objectui-field`);_(!1),n&&m(n,e)},children:[r&&(0,Y.jsx)(Hm,{label:t,count:n,collapsed:i,onToggleCollapse:a,readOnly:o,locale:s,canMoveUp:c,canMoveDown:l,dropActive:g,onRename:u,onRemove:d,onMove:f,onAddField:p}),!i&&(0,Y.jsx)(`div`,{className:`space-y-2.5`,children:h})]})}function Hm({label:e,count:t,collapsed:n,onToggleCollapse:r,readOnly:i,locale:a,canMoveUp:o,canMoveDown:s,dropActive:c,onRename:l,onRemove:u,onMove:d,onAddField:f}){let[p,m]=J.useState(!1),[h,g]=J.useState(e);J.useEffect(()=>{g(e)},[e]);let _=()=>{if(!l){m(!1);return}let t=h.trim();t&&t!==e&&l(t),m(!1)},v=n?Pn:Nn;return(0,Y.jsxs)(`div`,{className:`group/sec flex items-center gap-1.5 pl-0.5 min-h-[24px]`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center h-5 w-5 rounded text-muted-foreground hover:bg-accent hover:text-foreground transition-colors shrink-0`,"aria-label":G(n?`designer.canvas.expandSection`:`designer.canvas.collapseSection`,a),"aria-expanded":!n,children:(0,Y.jsx)(v,{className:`h-3.5 w-3.5`})}),p?(0,Y.jsx)(`input`,{autoFocus:!0,value:h,onChange:e=>g(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.stopPropagation(),t.key===`Enter`?(t.preventDefault(),_()):t.key===`Escape`&&(t.preventDefault(),g(e),m(!1))},onBlur:_,className:`text-[11px] font-medium uppercase tracking-wider px-1 py-0.5 -my-0.5 rounded border border-primary bg-background outline-none min-w-0 flex-1 max-w-[220px]`}):(0,Y.jsx)(`span`,{className:R(`text-[11px] font-medium uppercase tracking-wider text-muted-foreground truncate`,l&&`cursor-text hover:text-foreground`),onDoubleClick:l?()=>{g(e),m(!0)}:void 0,title:l?G(`designer.canvas.renameHint`,a):void 0,children:e}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60 tabular-nums shrink-0`,children:t}),c&&(0,Y.jsx)(`span`,{className:`text-primary normal-case text-[10px] font-normal`,children:G(`designer.canvas.dropToAssign`,a)}),!i&&(d||u||f)&&(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 opacity-0 group-hover/sec:opacity-100 focus-within:opacity-100 transition-opacity`,children:[f&&(0,Y.jsx)(Km,{onPick:f,compact:!0,locale:a}),d&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>d(-1),disabled:!o,className:`h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-30 disabled:pointer-events-none`,"aria-label":G(`designer.canvas.moveSectionUp`,a),children:(0,Y.jsx)(fn,{className:`h-3 w-3`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>d(1),disabled:!s,className:`h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-30 disabled:pointer-events-none`,"aria-label":G(`designer.canvas.moveSectionDown`,a),children:(0,Y.jsx)(un,{className:`h-3 w-3`})})]}),u&&(0,Y.jsx)(`button`,{type:`button`,onClick:u,className:`h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,"aria-label":G(`designer.canvas.removeSection`,a),title:G(`designer.canvas.removeSectionHint`,a),children:(0,Y.jsx)(Ki,{className:`h-3 w-3`})})]})]})}function Um({entry:e,locale:t}){let n=e.def,r=typeof n.type==`string`?n.type:`text`,i=fs[r]?.Icon,a=typeof n.label==`string`?n.label:e.name;return(0,Y.jsx)(`div`,{className:`rounded-md border border-dashed border-destructive/30 bg-destructive/[0.03] px-3.5 py-2.5 opacity-80`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[i&&(0,Y.jsx)(i,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/50`}),(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate line-through text-muted-foreground`,children:a}),(0,Y.jsx)(`code`,{className:`text-[10px] text-muted-foreground/60 font-mono truncate line-through`,children:e.name})]}),(0,Y.jsx)(V,{className:`text-[10px] font-medium border-transparent bg-destructive/15 text-destructive shrink-0`,children:G(`designer.canvas.diffRemoved`,t)})]})})}function Wm({entry:e,selected:t,multiSelected:n,diffStatus:r,changedKeys:i,readOnly:a,locale:o,onClick:s,onReorder:c,onRenameLabel:l,onMoveOffset:u}){let d=e.def,f=typeof d.type==`string`?d.type:`text`,p=fs[f],m=p?.Icon,h=ss[p?.category??`advanced`],g=typeof d.label==`string`?d.label:e.name,_=!!d.required,v=typeof d.description==`string`?d.description:null,y=Array.isArray(d.options)?d.options.map(e=>({value:String(e.value??``),label:typeof e.label==`string`?e.label:void 0})):void 0,b=typeof d.reference==`string`?d.reference:void 0,x=d.expression,S=typeof x==`string`?x:x&&typeof x==`object`&&typeof x.source==`string`?x.source:typeof d.formula==`string`?d.formula:void 0,C=typeof d.placeholder==`string`?d.placeholder:void 0,[w,T]=J.useState(null),E=!!c,[D,O]=J.useState(!1),[k,A]=J.useState(g);J.useEffect(()=>{A(g)},[g]);let j=e=>{l&&(e.preventDefault(),e.stopPropagation(),A(g),O(!0))},M=()=>{if(!l){O(!1);return}let t=k.trim();t&&t!==g&&l(e.name,t),O(!1)},N=()=>{A(g),O(!1)};return(0,Y.jsxs)(`div`,{className:R(`relative`,w===`before`&&`pt-1.5`),onDragOver:e=>{if(!E)return;let t=e.dataTransfer.types;if(!t||!Array.from(t).includes(`text/x-objectui-field`))return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=e.currentTarget.getBoundingClientRect(),r=e.clientY-n.top<n.height/2?`before`:`after`;T(r)},onDragLeave:()=>T(null),onDrop:t=>{if(!c)return;t.preventDefault(),t.stopPropagation();let n=t.dataTransfer.getData(`text/x-objectui-field`);T(null),n&&n!==e.name&&c(n,e.name,w??`before`)},children:[w===`before`&&(0,Y.jsx)(`div`,{className:`absolute left-0 right-0 -top-0.5 h-0.5 bg-primary rounded-full`}),(0,Y.jsxs)(`div`,{role:`button`,tabIndex:a?-1:0,onClick:s,onKeyDown:e=>{if(e.target===e.currentTarget){if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){u&&(e.preventDefault(),u(e.key===`ArrowUp`?-1:1));return}(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s?.())}},draggable:E,onDragStart:t=>{t.dataTransfer.setData(`text/x-objectui-field`,e.name),t.dataTransfer.effectAllowed=`move`},className:R(`group block w-full text-left rounded-md border bg-card px-3.5 py-2.5 transition-colors`,`hover:border-primary/40 hover:bg-card outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,t?`border-primary ring-2 ring-primary/30 shadow-sm`:`border-border`,n&&`border-primary/60 ring-2 ring-primary/40 bg-primary/[0.04]`,r===`added`&&`border-l-[3px] border-l-emerald-500`,r===`changed`&&`border-l-[3px] border-l-amber-500`,a&&`cursor-default`,E&&`cursor-grab active:cursor-grabbing`),"aria-pressed":t||n,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[n&&(0,Y.jsx)(Ii,{className:`h-3.5 w-3.5 text-primary shrink-0`,"aria-hidden":`true`}),E&&!n&&(0,Y.jsx)(Ar,{className:`h-3.5 w-3.5 text-muted-foreground/40 shrink-0 group-hover:text-muted-foreground/80`,"aria-hidden":`true`}),m&&(0,Y.jsx)(m,{className:R(`h-3.5 w-3.5 shrink-0`,h.icon)}),D?(0,Y.jsx)(`input`,{autoFocus:!0,value:k,onChange:e=>A(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),M()):e.key===`Escape`&&(e.preventDefault(),N())},onBlur:M,className:`text-sm font-medium px-1 py-0.5 -mx-1 -my-0.5 rounded border border-primary bg-background outline-none min-w-0 flex-1`}):(0,Y.jsx)(`span`,{className:R(`text-sm font-medium truncate`,l&&`cursor-text`),onDoubleClick:j,title:l?G(`designer.canvas.renameHint`,o):void 0,children:g}),_&&(0,Y.jsx)(`span`,{className:`text-destructive text-sm`,children:`*`}),(0,Y.jsx)(`code`,{className:`text-[10px] text-muted-foreground/70 font-mono truncate`,children:e.name})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[r===`added`&&(0,Y.jsx)(V,{className:`text-[10px] font-medium border-transparent bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,children:G(`designer.canvas.diffAdded`,o)}),r===`changed`&&(0,Y.jsx)(V,{className:`text-[10px] font-medium border-transparent bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:i&&i.length?W(`designer.canvas.diffChangedKeys`,o,{keys:i.join(`, `)}):void 0,children:G(`designer.canvas.diffChanged`,o)}),(0,Y.jsx)(V,{variant:`outline`,className:R(`text-[10px] font-medium`,h.badge),children:Im(p,o)??f})]})]}),v&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1.5 line-clamp-1`,children:v}),(0,Y.jsx)(Am,{type:f,label:g,placeholder:C,options:y,referenceTo:b,formula:S,locale:o})]}),w===`after`&&(0,Y.jsx)(`div`,{className:`absolute left-0 right-0 -bottom-1 h-0.5 bg-primary rounded-full`})]})}function Gm({onAdd:e,locale:t,aiEnabled:n}){return(0,Y.jsxs)(`div`,{className:`rounded-lg border-2 border-dashed bg-background py-16 px-6 text-center space-y-3`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium`,children:G(`designer.canvas.noFields`,t)}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:G(`designer.canvas.noFieldsHint`,t)}),e&&(0,Y.jsxs)(`div`,{className:`pt-2 flex items-center justify-center gap-2`,children:[(0,Y.jsx)(Km,{onPick:e,locale:t}),n&&(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,className:`gap-1.5 text-primary/80 hover:text-primary`,onClick:()=>la(),children:[(0,Y.jsx)(Fi,{className:`h-3.5 w-3.5`}),G(`designer.canvas.askAiGenerate`,t)]})]})]})}function Km({onPick:e,compact:t,locale:n}){let[r,i]=J.useState(!1),[a,o]=J.useState(``),s=a.trim().toLowerCase(),c=J.useMemo(()=>s?bs.map(e=>({category:e.category,types:e.types.filter(e=>{let t=fs[e],r=Im(t,n)??``;return e.includes(s)||t.label.toLowerCase().includes(s)||r.toLowerCase().includes(s)})})).filter(e=>e.types.length>0):bs,[s,a]);return(0,Y.jsxs)(Me,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Y.jsx)(Ae,{asChild:!0,children:t?(0,Y.jsx)(`button`,{type:`button`,className:`h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":G(`designer.canvas.addFieldToSection`,n),title:G(`designer.canvas.addFieldToSection`,n),children:(0,Y.jsx)(U,{className:`h-3 w-3`})}):(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,className:`gap-1.5 border-dashed`,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5`}),G(`designer.canvas.addField`,n)]})}),(0,Y.jsxs)(mt,{align:`start`,className:`w-[320px] p-0 max-h-[480px] overflow-hidden flex flex-col`,children:[(0,Y.jsx)(`div`,{className:`p-2 border-b`,children:(0,Y.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),placeholder:G(`designer.canvas.searchFieldType`,n),className:`h-7 w-full px-2 text-sm border rounded bg-background outline-none focus:ring-1 focus:ring-primary`})}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto p-1`,children:c.length===0?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground p-4 text-center`,children:G(`designer.canvas.noMatchingTypes`,n)}):c.map(t=>(0,Y.jsxs)(`div`,{className:`mb-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground px-2 pt-2 pb-1`,children:Lm(t.category,n)}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-0.5`,children:t.types.map(t=>{let r=fs[t],a=r.Icon;return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{e(t),i(!1),o(``)},className:`flex items-center gap-2 px-2 py-1.5 rounded text-left text-xs hover:bg-accent`,children:[(0,Y.jsx)(a,{className:R(`h-3.5 w-3.5 shrink-0`,ss[r.category].icon)}),(0,Y.jsx)(`span`,{className:`truncate`,children:Im(r,n)})]},t)})})]},t.category))})]})]})}function qm({name:e,draft:t,baseline:n,onPatch:r,selection:i,onSelectionChange:a,locale:o}){let s=String(t.name??e??``);return s?(0,Y.jsx)(X,{hint:`object · designer`,children:(0,Y.jsx)(Z,{fallbackHint:G(`engine.objectPreview.renderFailed`,o),children:(0,Y.jsx)(Rm,{objectName:s,draft:t,baseline:n,onPatch:r,selection:i,onSelectionChange:a,locale:o})})}):(0,Y.jsx)(X,{hint:`object`,children:(0,Y.jsx)(Pf,{children:G(`designer.canvas.nameToStart`,o)})})}function Jm(e){let t=new Set;for(let n of e.matchAll(/\{\{\s*([a-zA-Z_][\w.]*)\s*\}\}/g))t.add(n[1]);for(let n of e.matchAll(/\$\{\s*([a-zA-Z_][\w.]*)\s*\}/g))t.add(n[1]);return Array.from(t).sort()}function Ym(e,t){return t[e]??``}function Xm(e,t){return e.replace(/\{\{\s*([a-zA-Z_][\w.]*)\s*\}\}/g,(e,n)=>Ym(n,t)).replace(/\$\{\s*([a-zA-Z_][\w.]*)\s*\}/g,(e,n)=>Ym(n,t))}function Zm({draft:e,locale:t}){let n=String(e.subject??``),r=String(e.from??e.fromAddress??``),i=String(e.to??``),a=String(e.bodyHtml??e.html??e.body??``),o=String(e.bodyText??e.text??``),s=J.useMemo(()=>{let e=new Set;for(let t of Jm(n))e.add(t);for(let t of Jm(a))e.add(t);for(let t of Jm(o))e.add(t);return Array.from(e).sort()},[n,a,o]),[c,l]=J.useState({}),u=Xm(n,c),d=`<!doctype html><html><head><meta charset="utf-8"><style>
6
+ html,body{margin:0;padding:16px;font:14px -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#111;background:#fff;}
7
+ a{color:#2563eb;}
8
+ </style></head><body>${(a?Xm(a,c):Xm(o,c).replace(/\n/g,`<br/>`))||`<p style="color:#888">${G(`engine.emailTemplatePreview.emptyBody`,t)}</p>`}</body></html>`;return!a&&!o&&!n?(0,Y.jsx)(X,{hint:`email_template`,children:(0,Y.jsx)(Pf,{children:G(`engine.emailTemplatePreview.empty`,t)})}):(0,Y.jsx)(X,{hint:`email_template`,children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`grid lg:grid-cols-[1fr_220px] gap-0`,children:[(0,Y.jsxs)(`div`,{className:`p-3 space-y-3 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`rounded border bg-muted/30 px-3 py-2 text-xs space-y-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-12 text-muted-foreground shrink-0`,children:G(`engine.emailTemplatePreview.from`,t)}),(0,Y.jsx)(`span`,{className:`font-mono truncate`,children:r||`—`})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-12 text-muted-foreground shrink-0`,children:G(`engine.emailTemplatePreview.to`,t)}),(0,Y.jsx)(`span`,{className:`font-mono truncate`,children:i||`—`})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-12 text-muted-foreground shrink-0`,children:G(`engine.emailTemplatePreview.subject`,t)}),(0,Y.jsx)(`span`,{className:`font-medium truncate`,children:u||`—`})]})]}),(0,Y.jsx)(`iframe`,{title:G(`engine.emailTemplatePreview.frameTitle`,t),srcDoc:d,sandbox:`allow-same-origin`,className:`w-full min-h-[400px] max-h-[60vh] border rounded bg-white`})]}),(0,Y.jsxs)(`div`,{className:`border-l bg-muted/20 p-3 text-xs space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground`,children:[(0,Y.jsx)(qr,{className:`h-3 w-3`}),` `,G(`engine.emailTemplatePreview.variables`,t)]}),s.length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:Vp(G(`engine.emailTemplatePreview.noVariables`,t),{var:(0,Y.jsx)(`code`,{children:`{{var}}`})})}):(0,Y.jsx)(`div`,{className:`space-y-2`,children:s.map(e=>(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`block font-mono text-[10px] text-muted-foreground mb-0.5`,children:e}),(0,Y.jsx)(`input`,{type:`text`,value:c[e]??``,onChange:t=>l(n=>({...n,[e]:t.target.value})),placeholder:W(`engine.emailTemplatePreview.samplePlaceholder`,t,{name:e}),className:`w-full text-xs px-2 py-1 border rounded bg-background`})]},e))})]})]})})})}var Qm=212;function $m(e,t){let n=0;return e.forEach((e,r)=>{let{width:i,height:a}=io(Ko(e.nodes,e.edges)),o=Math.min(1,t/Math.max(i,1));n+=(r>0?8:0)+14+(e.label?16:0)+a*o}),n}function eh(e){return e.length===0?66:86+$m(e,Qm)}function th(e,t){let{key:n,label:r}=e;if(n===`try`)return G(`engine.flowRegion.try`,t);if(n===`catch`)return G(`engine.flowRegion.catch`,t);if(n===`body`)return r===`Body`?G(`engine.flowRegion.body`,t):r;let i=/^branch-(\d+)$/.exec(n);if(i){let e=Number(i[1])+1;if(r===`Branch ${e}`)return W(`engine.flowRegion.branchN`,t,{n:e})}return r}function nh({node:e,x:t,y:n,selected:r,onSelect:i}){let a=sh(e.type),o=!!i;return(0,Y.jsxs)(`div`,{"data-region-node-id":e.id,role:o?`button`:void 0,tabIndex:o?0:void 0,"aria-pressed":o?!!r:void 0,onClick:o?e=>{e.stopPropagation(),i()}:void 0,onKeyDown:o?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),i())}:void 0,className:R(`absolute flex items-center gap-2 rounded-lg border bg-card px-2 py-1.5 shadow-sm`,o&&`cursor-pointer`,r?`border-primary ring-2 ring-primary/30`:`border-border/70`),style:{left:t,top:n,width:240,height:66},children:[(0,Y.jsx)(`div`,{className:R(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md`,a.chip),children:(0,Y.jsx)(ch,{type:e.type,className:R(`h-4 w-4`,a.icon)})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-[12px] font-semibold leading-tight text-foreground`,title:e.label||e.id,children:e.label||e.id}),(0,Y.jsx)(`div`,{className:R(`text-[10px] font-semibold uppercase tracking-[0.08em]`,a.label),children:e.type})]})]})}function rh({region:e,maxWidth:t,selectedNodeId:n,onSelectNode:r}){let i=J.useMemo(()=>Ko(e.nodes,e.edges),[e.nodes,e.edges]),{width:a,height:o}=J.useMemo(()=>io(i),[i]),s=Math.min(1,t/Math.max(a,1));return(0,Y.jsx)(`div`,{className:`relative`,style:{width:a*s,height:o*s},children:(0,Y.jsxs)(`div`,{className:`absolute left-0 top-0`,style:{width:a,height:o,transform:`scale(${s})`,transformOrigin:`top left`},children:[(0,Y.jsx)(`svg`,{className:`pointer-events-none absolute left-0 top-0 overflow-visible`,width:a,height:o,children:e.edges.map((e,t)=>{let n=i.get(e.source),r=i.get(e.target);if(!n||!r)return null;let a=mo(e),o=a?ho(n):ro(n),s=a?ho(r):_o(r);return(0,Y.jsx)(`path`,{d:a?bo(o,s):no(o,s),strokeDasharray:a?`5 4`:void 0,className:R(`fill-none`,a?`stroke-amber-500/60`:`stroke-muted-foreground/40`),strokeWidth:1.5},e.id||`${e.source}-${e.target}-${t}`)})}),e.nodes.map(e=>{let t=i.get(e.id);return t?(0,Y.jsx)(nh,{node:e,x:t.x,y:t.y,selected:n===e.id,onSelect:r?()=>r(e):void 0},e.id):null})]})})}function ih({regions:e,maxWidth:t,selected:n,onSelectNode:r,locale:i}){return(0,Y.jsx)(`div`,{className:`flex flex-col`,style:{gap:8},children:e.map(e=>{let a=th(e,i);return(0,Y.jsxs)(`div`,{className:`rounded-md border border-dashed border-border/60 bg-muted/20`,style:{padding:6},children:[a&&(0,Y.jsx)(`div`,{className:`text-[9px] font-semibold uppercase tracking-wide text-muted-foreground/80`,style:{height:16,lineHeight:`12px`,paddingBottom:4},children:a}),(0,Y.jsx)(rh,{region:e,maxWidth:t,selectedNodeId:n&&n.regionKey===e.key?n.nodeId:null,onSelectNode:r?t=>r(e.key,t):void 0})]},e.key)})})}function ah(e){switch(e){case`start`:return pi;case`end`:return Un;case`decision`:case`branch`:case`gateway`:return rr;case`wait`:case`timer`:case`delay`:return Wi;case`boundary_event`:case`signal`:return ra;case`subflow`:case`flow`:return ea;case`create_record`:return mr;case`update_record`:return pr;case`delete_record`:return _r;case`get_record`:return hr;case`http_request`:case`webhook`:return kr;case`notify`:return hn;case`script`:case`script_task`:return Zn;case`screen`:case`user_task`:return ei;case`approval`:return Zi;case`connector_action`:case`service_task`:return mi;case`assignment`:return $i;case`loop`:case`for_each`:return bi;case`map`:return Wr;case`parallel_gateway`:case`join_gateway`:case`parallel`:return Or;case`try_catch`:return ki;default:return Bn}}var oh={start:{icon:`text-emerald-600 dark:text-emerald-400`,accent:`border-l-emerald-500`,label:`text-emerald-600 dark:text-emerald-400`,chip:`bg-emerald-500/10 ring-1 ring-inset ring-emerald-500/20 dark:bg-emerald-400/10`},end:{icon:`text-rose-600 dark:text-rose-400`,accent:`border-l-rose-500`,label:`text-rose-600 dark:text-rose-400`,chip:`bg-rose-500/10 ring-1 ring-inset ring-rose-500/20 dark:bg-rose-400/10`},decision:{icon:`text-amber-600 dark:text-amber-400`,accent:`border-l-amber-500`,label:`text-amber-600 dark:text-amber-400`,chip:`bg-amber-500/10 ring-1 ring-inset ring-amber-500/20 dark:bg-amber-400/10`},wait:{icon:`text-blue-600 dark:text-blue-400`,accent:`border-l-blue-500`,label:`text-blue-600 dark:text-blue-400`,chip:`bg-blue-500/10 ring-1 ring-inset ring-blue-500/20 dark:bg-blue-400/10`},signal:{icon:`text-violet-600 dark:text-violet-400`,accent:`border-l-violet-500`,label:`text-violet-600 dark:text-violet-400`,chip:`bg-violet-500/10 ring-1 ring-inset ring-violet-500/20 dark:bg-violet-400/10`},subflow:{icon:`text-indigo-600 dark:text-indigo-400`,accent:`border-l-indigo-500`,label:`text-indigo-600 dark:text-indigo-400`,chip:`bg-indigo-500/10 ring-1 ring-inset ring-indigo-500/20 dark:bg-indigo-400/10`},task:{icon:`text-slate-500 dark:text-slate-400`,accent:`border-l-slate-400`,label:`text-slate-500 dark:text-slate-400`,chip:`bg-slate-500/10 ring-1 ring-inset ring-slate-500/20 dark:bg-slate-400/10`},record:{icon:`text-cyan-600 dark:text-cyan-400`,accent:`border-l-cyan-500`,label:`text-cyan-600 dark:text-cyan-400`,chip:`bg-cyan-500/10 ring-1 ring-inset ring-cyan-500/20 dark:bg-cyan-400/10`},integration:{icon:`text-fuchsia-600 dark:text-fuchsia-400`,accent:`border-l-fuchsia-500`,label:`text-fuchsia-600 dark:text-fuchsia-400`,chip:`bg-fuchsia-500/10 ring-1 ring-inset ring-fuchsia-500/20 dark:bg-fuchsia-400/10`},approval:{icon:`text-teal-600 dark:text-teal-400`,accent:`border-l-teal-500`,label:`text-teal-600 dark:text-teal-400`,chip:`bg-teal-500/10 ring-1 ring-inset ring-teal-500/20 dark:bg-teal-400/10`},loop:{icon:`text-sky-600 dark:text-sky-400`,accent:`border-l-sky-500`,label:`text-sky-600 dark:text-sky-400`,chip:`bg-sky-500/10 ring-1 ring-inset ring-sky-500/20 dark:bg-sky-400/10`},screen:{icon:`text-pink-600 dark:text-pink-400`,accent:`border-l-pink-500`,label:`text-pink-600 dark:text-pink-400`,chip:`bg-pink-500/10 ring-1 ring-inset ring-pink-500/20 dark:bg-pink-400/10`},assignment:{icon:`text-purple-600 dark:text-purple-400`,accent:`border-l-purple-500`,label:`text-purple-600 dark:text-purple-400`,chip:`bg-purple-500/10 ring-1 ring-inset ring-purple-500/20 dark:bg-purple-400/10`}};function sh(e){switch(e){case`start`:return oh.start;case`end`:return oh.end;case`decision`:case`branch`:case`gateway`:case`parallel_gateway`:case`join_gateway`:case`parallel`:return oh.decision;case`wait`:case`timer`:case`delay`:return oh.wait;case`boundary_event`:case`signal`:case`try_catch`:return oh.signal;case`subflow`:case`flow`:return oh.subflow;case`approval`:return oh.approval;case`loop`:case`for_each`:case`map`:return oh.loop;case`screen`:case`user_task`:return oh.screen;case`assignment`:return oh.assignment;case`create_record`:case`update_record`:case`delete_record`:case`get_record`:return oh.record;case`http`:case`http_request`:case`notify`:case`connector_action`:case`script`:case`webhook`:case`service_task`:case`script_task`:return oh.integration;default:return oh.task}}function ch({type:e,className:t}){return J.createElement(ah(e),{className:t,"aria-hidden":!0})}var lh=[`Data`,`Logic`,`Human`,`Integration`,`Flow`];function uh(e){switch(e){case`create_record`:case`update_record`:case`delete_record`:case`get_record`:return`Data`;case`decision`:case`branch`:case`gateway`:case`loop`:case`for_each`:case`map`:case`assignment`:case`parallel_gateway`:case`join_gateway`:case`parallel`:case`try_catch`:return`Logic`;case`approval`:case`screen`:case`user_task`:return`Human`;case`http`:case`http_request`:case`notify`:case`connector_action`:case`script`:case`webhook`:case`service_task`:case`script_task`:return`Integration`;default:return`Flow`}}var dh=[{type:`create_record`,label:`Create record`,hint:`Insert a new record`,category:`Data`},{type:`update_record`,label:`Update record`,hint:`Modify an existing record`,category:`Data`},{type:`get_record`,label:`Get record`,hint:`Query records`,category:`Data`},{type:`delete_record`,label:`Delete record`,hint:`Remove matching records`,category:`Data`},{type:`decision`,label:`Decision`,hint:`Branch on a condition`,category:`Logic`},{type:`loop`,label:`Loop`,hint:`Iterate over a collection`,category:`Logic`},{type:`assignment`,label:`Set variables`,hint:`Assign flow variables`,category:`Logic`},{type:`parallel`,label:`Parallel`,hint:`Run branches concurrently, join at end`,category:`Logic`},{type:`try_catch`,label:`Try / Catch`,hint:`Protect steps with error handling and retry`,category:`Logic`},{type:`approval`,label:`Approval`,hint:`Pause for a human decision`,category:`Human`},{type:`screen`,label:`Screen`,hint:`Collect input from a user`,category:`Human`},{type:`http`,label:`HTTP request`,hint:`Call an external API`,category:`Integration`},{type:`notify`,label:`Notify`,hint:`Send a notification to users`,category:`Integration`},{type:`connector_action`,label:`Connector`,hint:`Run an integration action`,category:`Integration`},{type:`script`,label:`Script`,hint:`Run custom code`,category:`Integration`},{type:`subflow`,label:`Subflow`,hint:`Invoke another flow`,category:`Flow`},{type:`wait`,label:`Wait`,hint:`Pause for an event or timer`,category:`Flow`},{type:`end`,label:`End`,hint:`Terminate the flow`,category:`Flow`}];function fh(e,t){let n=dh.find(t=>t.type===e),r=n?n.label:e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `);return Qo(e,t,r)}function ph(e){switch(e){case`start`:return{};case`wait`:return{waitEventConfig:{eventType:`timer`,timerDuration:`PT1H`}};case`connector_action`:return{connectorConfig:{connectorId:``,actionId:``,input:{}}};case`boundary_event`:return{boundaryConfig:{attachedToNodeId:``,eventType:`error`,interrupting:!0}};case`approval`:return{config:{approvers:[{type:`manager`}],behavior:`first_response`,lockRecord:!0}};case`notify`:return{config:{channels:[`inbox`],recipients:[]}};case`http`:case`http_request`:return{config:{method:`GET`}};case`script`:return{};default:return{}}}function mh({id:e,locale:t,type:n,label:r,summary:i,position:a,selected:o,editable:s,runState:c,dimmed:l,invalid:u,badge:d,onPointerDown:f,onSelect:p,onAppend:m,onAddReviseLoop:h,regions:g,expanded:_,onToggleExpand:v,height:y,selectedNestedNode:b,onSelectNestedNode:x}){let S=sh(n),C=!!g&&g.length>0;return(0,Y.jsxs)(`div`,{className:`group absolute transition-opacity duration-200`,"data-invalid":u||void 0,"data-node-id":e,style:{left:a.x,top:a.y,width:240,height:y??66,opacity:l?.35:1},children:[(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":o,onPointerDown:f,onClick:e=>{e.stopPropagation(),p?.()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p?.())},style:{height:66},className:R(`group flex w-full items-center gap-3 rounded-xl border bg-card px-2.5 py-2 text-left shadow-sm outline-none`,`transition-[transform,box-shadow,border-color] duration-150 ease-out will-change-transform`,`hover:-translate-y-0.5 hover:shadow-lg hover:shadow-foreground/[0.06] focus-visible:ring-2 focus-visible:ring-primary/40`,s?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,c===`active`?`border-sky-500 shadow-md shadow-sky-500/20 ring-2 ring-sky-400/60`:c===`visited`?`border-emerald-500/70 ring-1 ring-emerald-400/40`:o?`border-primary shadow-md ring-2 ring-primary/30`:u?`border-destructive ring-2 ring-destructive/50`:`border-border/80`),children:[(0,Y.jsx)(`div`,{className:R(`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg transition-transform duration-150 group-hover:scale-105`,S.chip,c===`active`&&`animate-pulse`),children:(0,Y.jsx)(ch,{type:n,className:R(`h-[18px] w-[18px]`,S.icon)})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{title:r,className:`truncate text-[13px] font-semibold leading-tight text-foreground`,children:r}),(0,Y.jsxs)(`div`,{className:`mt-1 flex items-baseline gap-1.5 leading-tight`,children:[(0,Y.jsx)(`span`,{className:R(`shrink-0 text-[10px] font-semibold uppercase tracking-[0.08em]`,S.label),children:n}),i&&(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[10px] text-muted-foreground`,title:i,children:i})]})]})]}),C&&v&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":G(_?`engine.flowCanvas.collapseRegions`:`engine.flowCanvas.expandRegions`,t),title:G(_?`engine.flowCanvas.collapseRegions`:`engine.flowCanvas.expandRegions`,t),"aria-expanded":!!_,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),v()},className:`absolute right-1.5 top-1.5 z-20 inline-flex h-5 w-5 items-center justify-center rounded-md border bg-background/90 text-muted-foreground shadow-sm transition-colors hover:border-primary hover:text-primary`,children:(0,Y.jsx)(Pn,{className:R(`h-3.5 w-3.5 transition-transform`,_&&`rotate-90`)})}),C&&_&&(0,Y.jsx)(`div`,{className:`rounded-lg border bg-card shadow-sm`,style:{marginTop:6,padding:6},onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:(0,Y.jsx)(ih,{regions:g,maxWidth:Qm,selected:b,onSelectNode:x,locale:t})}),d&&(0,Y.jsx)(`span`,{title:d.title,"data-problem":d.level,className:R(`absolute -right-2 -top-2 z-20 inline-flex h-5 w-5 items-center justify-center rounded-full border bg-background shadow-sm`,d.level===`error`?`border-destructive/50 text-destructive`:`border-amber-500/50 text-amber-600 dark:text-amber-400`),children:d.level===`error`?(0,Y.jsx)(Rn,{className:`h-3 w-3`}):(0,Y.jsx)(Ji,{className:`h-3 w-3`})}),s&&n!==`end`&&(0,Y.jsx)(`button`,{type:`button`,title:G(`engine.flowCanvas.addConnected`,t),"aria-label":G(`engine.flowCanvas.addConnected`,t),onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),m?.()},className:R(`absolute left-1/2 -bottom-3 z-10 inline-flex h-6 w-6 -translate-x-1/2 items-center justify-center rounded-full border bg-background text-muted-foreground shadow-sm transition-colors`,`opacity-0 hover:border-primary hover:text-primary group-hover:opacity-100 focus-visible:opacity-100`),children:(0,Y.jsx)(U,{className:`h-3.5 w-3.5`})}),h&&(0,Y.jsx)(`button`,{type:`button`,title:G(`engine.flowCanvas.addReviseLoop`,t),"aria-label":G(`engine.flowCanvas.addReviseLoopShort`,t),onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),h()},className:R(`absolute -right-3 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full border bg-background text-amber-600 shadow-sm transition-colors dark:text-amber-400`,`opacity-0 hover:border-amber-500 hover:text-amber-600 group-hover:opacity-100 focus-visible:opacity-100 dark:hover:text-amber-400`),children:(0,Y.jsx)(Ir,{className:`h-3.5 w-3.5`})})]})}var hh=`p-0 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:pt-1 [&_[cmdk-group-heading]]:text-[10px] [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-[0.08em] [&_[cmdk-group-heading]]:text-muted-foreground [&:not(:first-child)]:mt-1 [&:not(:first-child)]:border-t [&:not(:first-child)]:border-border/60 [&:not(:first-child)]:pt-1`;function gh({locale:e,items:t=dh,onPick:n,open:r,onOpenChange:i,children:a}){let[o,s]=J.useState(``),{recents:c,recordRecent:l}=Ws(),u=J.useRef(null),[d,f]=J.useState(r);r!==d&&(f(r),r||s(``));let p=o.trim().toLowerCase(),m=J.useMemo(()=>p?t.filter(t=>t.label.toLowerCase().includes(p)||(t.hint??``).toLowerCase().includes(p)||t.type.toLowerCase().includes(p)||Qo(t.type,e,t.label).toLowerCase().includes(p)||(Zo(t.type,e,t.hint)??``).toLowerCase().includes(p)):t,[t,p,e]),h=J.useMemo(()=>{let e=new Map;for(let t of m){let n=t.category??uh(t.type),r=e.get(n)??[];r.push(t),e.set(n,r)}return lh.map(t=>[t,e.get(t)??[]]).filter(([,e])=>e.length>0)},[m]),g=J.useMemo(()=>{if(p)return[];let e=new Map(t.map(e=>[e.type,e]));return c.map(t=>e.get(t)).filter(e=>!!e)},[t,c,p]),_=e=>{l(e),n(e)},v=(t,n)=>{let r=sh(t.type),i=Qo(t.type,e,t.label),a=Zo(t.type,e,t.hint);return(0,Y.jsxs)(Ve,{value:n?`recent:${t.type}`:t.type,onSelect:()=>_(t.type),className:`gap-2.5 rounded-lg px-2 py-1.5 [&_svg]:size-[15px]`,children:[(0,Y.jsx)(`span`,{className:R(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md`,r.chip),children:(0,Y.jsx)(ch,{type:t.type,className:R(`h-[15px] w-[15px]`,r.icon)})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-[13px] font-medium`,children:i}),a&&(0,Y.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:a})]})]},n?`recent:${t.type}`:t.type)};return(0,Y.jsxs)(Me,{open:r,onOpenChange:i,children:[(0,Y.jsx)(Ae,{asChild:!0,children:a}),(0,Y.jsx)(mt,{align:`end`,sideOffset:6,className:`w-60 overflow-hidden rounded-xl border bg-popover/95 p-0 shadow-xl shadow-foreground/[0.08] ring-1 ring-black/[0.03] backdrop-blur-md`,onOpenAutoFocus:e=>{e.preventDefault(),u.current?.focus()},children:(0,Y.jsxs)(_e,{shouldFilter:!1,loop:!0,className:`bg-transparent`,children:[(0,Y.jsx)(ve,{ref:u,value:o,onValueChange:s,placeholder:G(`engine.flowPalette.search`,e),className:`h-9 text-[13px]`}),(0,Y.jsxs)(dt,{className:`max-h-[56vh] p-1`,children:[(0,Y.jsx)(Xe,{className:`py-6 text-center text-xs text-muted-foreground`,children:G(`engine.flowPalette.empty`,e)}),g.length>0&&(0,Y.jsx)(xe,{heading:G(`engine.flowPalette.recent`,e),className:hh,children:g.map(e=>v(e,!0))}),h.map(([t,n])=>(0,Y.jsx)(xe,{heading:G(`engine.flowPalette.category.${t.toLowerCase()}`,e),className:hh,children:n.map(e=>v(e))},t))]})]})})]})}function _h(e,t){let n=new Map;for(let t of e)n.set(t.type,t);for(let e of t){if(!e?.type||e.deprecated||Array.isArray(e.paradigms)&&e.paradigms.length>0&&!e.paradigms.includes(`flow`))continue;let t=n.get(e.type);n.set(e.type,{type:e.type,label:e.name||t?.label||e.type,hint:e.description||t?.hint,category:t?.category??uh(e.type)})}return[...n.values()]}function vh(){let[e,t]=(0,J.useState)([]),n=(0,J.useRef)(!0);return(0,J.useEffect)(()=>{n.current=!0;let e=new AbortController;return(async()=>{try{let r=await fetch(`${dd()}/automation/actions`,{credentials:`include`,headers:{"Content-Type":`application/json`},signal:e.signal});if(!r.ok)return;let i=(await r.json())?.data?.actions;if(!Array.isArray(i)||i.length===0)return;n.current&&t(i)}catch{}})(),()=>{n.current=!1,e.abort()}},[]),e}function yh(){let e=vh();return(0,J.useMemo)(()=>e.length?_h(dh,e):dh,[e])}function bh(){let e=vh();return(0,J.useMemo)(()=>{let t={};for(let n of e)n?.type&&n.configSchema!==void 0&&n.configSchema!==null&&(t[n.type]=n.configSchema);return t},[e])}var xh=se.shape.dialect.value;function Sh(e,t){if(typeof e!=`string`||t.length!==2||t[0]!==`config`)return!1;let n=`${t[1]}.*`;return F.some(t=>t.nodeType===e&&t.role===`value`&&t.path===n)}function Ch(e){return w(e)&&e.dialect===xh&&typeof e.source==`string`}function wh(e,t){if(Ch(e)){if(e.source===t)return e;let n={...e,source:t};return delete n.ast,n}return{dialect:xh,source:t}}function Th(e){let t=A.safeParse(e);return t.success?null:t.error.issues.map(e=>e.message)}function Eh(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.split(`.`),i=t;for(let t of e.slice(0,-1)){let e=i[t],n=typeof e==`object`&&e?Object.assign(Array.isArray(e)?[]:{},e):{};i[t]=n,i=n}i[e[e.length-1]]=r}return{extra:{...t,vars:t},record:t}}function Dh(e,t,n){let r=Th(e);if(r)return{ok:!1,error:r.join(` `)};let{dialect:i,source:a}=e;try{let e=C(`value`,{dialect:i,source:a});if(e.errors.length>0)return{ok:!1,error:e.errors.map(e=>`${k} ${e.message}`).join(` `)};let r=ae.evaluate({dialect:i,source:a},Eh(t));return r.ok?{ok:!0,value:r.value}:{ok:!1,error:W(`engine.flowSim.note.celEvaluationFailed`,n,{message:r.error.message})}}catch(e){return{ok:!1,error:e.message||G(`engine.flowSim.note.evaluationFailed`,n)}}}function Oh(e,t,n){try{if(e===void 0)return{kind:`absent`};let r=ee(e);if(r)return{kind:`fault`,error:r.message};if(typeof e==`string`){if(!e.trim())return{kind:`fault`,error:b}}else{let t=S.safeParse(e);if(!t.success)return{kind:`fault`,error:t.error.issues.map(e=>e.path.length?`${e.path.join(`.`)}: ${e.message}`:e.message).join(` `)}}let i=e;return kh(i,ao(i)??``,t,n)}catch(e){return{kind:`fault`,error:e.message||G(`engine.flowSim.note.evaluationFailed`,n)}}}function kh(e,t,n,r){try{let i=C(`predicate`,e);if(i.errors.length>0)return{kind:`fault`,error:i.errors.map(e=>e.message).join(` `)};let a=ae.evaluate({dialect:`cel`,source:t},Eh(n));return a.ok?{kind:`value`,result:!!a.value}:{kind:`fault`,error:W(`engine.flowSim.note.celConditionFailed`,r,{message:a.error.message})}}catch(e){return{kind:`fault`,error:e.message||G(`engine.flowSim.note.evaluationFailed`,r)}}}function Ah(e,t,n){let r=m(e);if(r)return{kind:`fault`,error:r.message};let i=e;return i.trim()?kh(i,i,t,n):{kind:`value`,result:!1}}function jh(e,t){let n=new Map;for(let t of e)n.set(t,[]);for(let e of t)n.has(e.source)&&n.has(e.target)&&n.get(e.source).push(e.target);let r=new Map(e.map(e=>[e,0])),i=[],a=e=>{let t=[{id:e,i:0}];for(r.set(e,1),i.push(e);t.length;){let e=t[t.length-1],a=n.get(e.id)??[];if(e.i<a.length){let n=a[e.i++],o=r.get(n);if(o===1){let e=i.indexOf(n);return[...i.slice(e),n]}o===0&&(r.set(n,1),i.push(n),t.push({id:n,i:0}))}else r.set(e.id,2),i.pop(),t.pop()}return null};for(let t of e)if(r.get(t)===0){let e=a(t);if(e)return e}return null}function Mh(e,t,n){let r=[],i=[],a=e.map(e=>e.id),o=new Set;for(let e of a){if(!e){r.push({level:`error`,message:G(`engine.flowValidate.nodeMissingId`,n)});continue}o.has(e)&&r.push({level:`error`,nodeId:e,message:W(`engine.flowValidate.duplicateNodeId`,n,{id:e})}),o.add(e)}for(let e of t)o.has(e.source)||r.push({level:`error`,edge:{source:e.source,target:e.target},message:W(`engine.flowValidate.edgeSourceMissing`,n,{source:e.source})}),o.has(e.target)||r.push({level:`error`,edge:{source:e.source,target:e.target},message:W(`engine.flowValidate.edgeTargetMissing`,n,{target:e.target})});let s=new Set(t.map(e=>e.target)),c=e.filter(e=>e.type===`start`),l=e.filter(e=>!s.has(e.id)),u;c.length===1?(u=c[0].id,s.has(u)&&i.push({level:`warning`,nodeId:u,message:G(`engine.flowValidate.startHasIncoming`,n)})):c.length>1?r.push({level:`error`,message:W(`engine.flowValidate.multipleStart`,n,{count:c.length})}):l.length===1?(u=l[0].id,i.push({level:`warning`,nodeId:u,message:G(`engine.flowValidate.noStartUsingRoot`,n)})):l.length===0?r.push({level:`error`,message:G(`engine.flowValidate.noEntry`,n)}):r.push({level:`error`,message:W(`engine.flowValidate.ambiguousEntry`,n,{count:l.length})});for(let a of e){if(a.type!==`decision`)continue;let e=t.filter(e=>e.source===a.id),o=e.filter(e=>e.isDefault);o.length>1&&r.push({level:`error`,nodeId:a.id,message:W(`engine.flowValidate.decisionMultipleDefaults`,n,{id:a.id,count:o.length})}),e.length===0?i.push({level:`warning`,nodeId:a.id,message:W(`engine.flowValidate.decisionNoBranches`,n,{id:a.id})}):o.length===0&&e.every(e=>ao(e.condition))&&i.push({level:`warning`,nodeId:a.id,message:W(`engine.flowValidate.decisionNoDefault`,n,{id:a.id})})}if(u){let r=new Set([u]),a=[u];for(;a.length;){let e=a.shift();for(let n of t)n.source===e&&o.has(n.target)&&!r.has(n.target)&&(r.add(n.target),a.push(n.target))}for(let t of e)r.has(t.id)||i.push({level:`warning`,nodeId:t.id,message:W(`engine.flowValidate.nodeUnreachable`,n,{id:t.id})})}let d=t.filter(e=>e.type!==`back`),f=jh(a.filter(e=>!!e),d);return f&&r.push({level:`error`,nodeId:f[0],cycle:f,message:W(`engine.flowValidate.cycleDetected`,n,{cycle:f.join(` → `)})}),{errors:r,warnings:i,startNodeId:u}}function Q(e,t,n,r={}){return{id:e,path:[`config`,e],label:t,kind:n,...r}}function Nh(e,t,n,r,i={}){return{id:`${e}.${t}`,path:[e,t],label:n,kind:r,...i}}var Ph=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`].map(e=>({value:e,label:e})),Fh={start:[Q(`triggerType`,`Trigger`,`select`,{help:`When this flow starts. Record triggers fire on data changes; schedule triggers fire on a cron.`,options:[{value:`record-after-create`,label:`Record created`},{value:`record-after-update`,label:`Record updated`},{value:`record-after-write`,label:`Record created or updated`},{value:`record-before-update`,label:`Record before update`},{value:`record-after-delete`,label:`Record deleted`},{value:`schedule`,label:`Schedule (cron)`},{value:`time_relative`,label:`Time-relative (date sweep)`},{value:`manual`,label:`Manual / autolaunched`},{value:`api`,label:`Webhook / API`}]}),Q(`secret`,`Secret`,`secret`,{flowKind:[`api`],help:`The per-flow secret the inbound hook verifies every post against. Write-only: a saved secret is never shown here, and leaving this blank keeps it.`,unsetNotice:`No secret entered. An API-triggered flow is refused unless its start node carries a secret. A secret already saved on this flow is kept when this is left blank.`}),Q(`objectName`,`Object`,`reference`,{ref:{kind:`object`},placeholder:`crm_lead`,help:`Target object for record / scheduled-scan triggers.`,showWhen:{field:`triggerType`,equals:[`record-after-create`,`record-after-update`,`record-after-write`,`record-before-update`,`record-after-delete`,`schedule`,`api`]}}),Q(`condition`,`Entry condition`,`expression`,{conditionBuilder:!0,placeholder:`status == "qualifying" && previous.status != "qualifying"`,help:'CEL predicate — the flow runs only when this is true (for time-relative sweeps it gates each matched record). Leave empty to run on every event. On a "created or updated" trigger, `previous == null` selects the create path.',showWhen:{field:`triggerType`,equals:[`record-after-create`,`record-after-update`,`record-after-write`,`record-before-update`,`record-after-delete`,`schedule`,`time_relative`,`api`]}}),{id:`schedule.expression`,path:[`config`,`schedule`,`expression`],fallbackPath:[`config`,`cron`],label:`Cron schedule`,kind:`text`,placeholder:`0 7 * * *`,help:`Cron expression — when the flow runs. A time-relative sweep defaults to daily if left empty.`,showWhen:{field:`triggerType`,equals:[`schedule`,`time_relative`]}},{id:`timeRelative.object`,path:[`config`,`timeRelative`,`object`],label:`Sweep object`,kind:`reference`,ref:{kind:`object`},placeholder:`contracts`,help:`Object whose records are swept each run.`,showWhen:{field:`triggerType`,equals:[`time_relative`]}},{id:`timeRelative.dateField`,path:[`config`,`timeRelative`,`dateField`],label:`Date field`,kind:`text`,placeholder:`end_date`,help:`The date / datetime field compared against today.`,showWhen:{field:`triggerType`,equals:[`time_relative`]}},{id:`timeRelative.withinDays`,path:[`config`,`timeRelative`,`withinDays`],label:`Within days`,kind:`number`,placeholder:`30`,help:`Range mode: fire while the date is within N days of today (negative = overdue lookback). Leave empty if using Offset days.`,showWhen:{field:`triggerType`,equals:[`time_relative`]}},{id:`timeRelative.offsetDays`,path:[`config`,`timeRelative`,`offsetDays`],label:`Offset days`,kind:`numberList`,placeholder:`60`,help:`Offset mode: fire when the date is exactly today + each offset (e.g. 60, 30, 7). Leave empty if using Within days.`,showWhen:{field:`triggerType`,equals:[`time_relative`]}},{id:`timeRelative.filter`,path:[`config`,`timeRelative`,`filter`],label:`Extra filter`,kind:`keyValue`,help:`Optional filter ANDed with the date window (e.g. status = active).`,showWhen:{field:`triggerType`,equals:[`time_relative`]}},{id:`timeRelative.maxRecords`,path:[`config`,`timeRelative`,`maxRecords`],label:`Max records / run`,kind:`number`,placeholder:`1000`,help:`Cap on records launched per sweep (default 1000).`,showWhen:{field:`triggerType`,equals:[`time_relative`]}},Q(`criteria`,`Entry condition (legacy)`,`expression`,{placeholder:`status == "active"`,help:`Legacy key — prefer "Entry condition" (condition).`,showWhen:{field:`__legacy__`,equals:[]}})],end:[Q(`outcome`,`Outcome`,`select`,{options:[{value:`completed`,label:`Completed`},{value:`refused`,label:`Refused`}],defaultValue:`completed`,help:`How the run ends here. "Completed" is the ordinary terminal and is what an omitted key applies. "Refused" records a first-class refusal — a successful evaluation that says no — and requires a message saying why (a {token} template), authored in the field below.`}),Q(`message`,`Why the run was refused`,`textarea`,{placeholder:`Refused: {record.name} is a confirmed duplicate`,help:`Required when the outcome is "Refused", and refused on a completed end — a completion renders nothing, so the key would be a silent no-op. A {token} template interpolated at run time (e.g. {record.name}), exactly like a screen Description.`,showWhen:{field:`outcome`,equals:[`refused`]}})],decision:[Q(`conditions`,`Branches`,`objectList`,{help:`Each branch has a label, a CEL expression (no {braces}), and a target node. Branches are tried in order and the first match wins. A branch whose expression is "true" is the catch-all: picking its target marks that out-edge as the default path, taken only when no other branch matched. Picking a target wires the branch’s outgoing edge (creating or updating it); clearing it detaches that edge.`,columns:[{key:`label`,label:`Label`,kind:`text`,placeholder:`Has deals`},{key:`expression`,label:`Expression`,kind:`expression`,placeholder:`expiring_deals.length > 0`},{key:`target`,label:`Target`,kind:`reference`,placeholder:`next node`,ref:{kind:`node`}}]}),Q(`condition`,`Condition (single)`,`expression`,{placeholder:`amount > 10000`,help:"Inert — nothing reads this. The engine only honours `condition` on a Start node (the trigger gate); on a Decision it gates nothing. Shown so a stored value is not invisible. Move the predicate to a branch above, or to the outgoing edge’s own condition, then clear this.",showWhen:{field:`__legacy__`,equals:[]}}),Q(`mode`,`Branch mode`,`select`,{options:[{value:`exclusive`,label:`Exclusive`},{value:`inclusive`,label:`Inclusive`}],help:`For a decision that branches on its out-edge conditions: Exclusive takes only the first edge that holds, in edge order (what leaving this unset means); Inclusive takes every edge that holds. The default edge runs when none holds. Not allowed together with Branches above.`})],assignment:[Q(`assignments`,`Assignments`,`keyValue`,{help:`Set variables: each key is a variable, each value an expression or literal.`})],loop:[Q(`collection`,`Collection`,`expression`,{placeholder:`{leadList}`,refMode:`template`,help:`Expression resolving to the items to iterate.`}),Q(`iteratorVariable`,`Item variable`,`text`,{placeholder:`item`})],map:[Q(`collection`,`Collection`,`expression`,{placeholder:`{items}`,refMode:`template`,help:`Expression resolving to the array to process, one item at a time.`}),Q(`flowName`,`Per-item flow`,`reference`,{ref:{kind:`flow`},placeholder:`one_task_signoff`,help:`Subflow run for each item — it may pause (e.g. an approval).`}),Q(`iteratorVariable`,`Item variable`,`text`,{placeholder:`item`}),Q(`itemObject`,`Item object`,`reference`,{ref:{kind:`object`},placeholder:`showcase_task`,help:`When items are records, the object they belong to (exposes each item as the child’s record).`}),Q(`outputVariable`,`Output variable`,`text`,{placeholder:`results`,help:`Each item’s subflow output, collected in order.`})],create_record:[Q(`objectName`,`Object`,`reference`,{ref:{kind:`object`},placeholder:`contract`}),Q(`fields`,`Field values`,`keyValue`,{help:`Field values to write on the new record.`}),Q(`outputVariable`,`Output variable`,`text`,{placeholder:`newRecord`})],update_record:[Q(`objectName`,`Object`,`reference`,{ref:{kind:`object`},placeholder:`contract`}),Q(`filter`,`Filter`,`keyValue`,{help:`Field/value pairs identifying the record(s) to update (e.g. id → {recordId}).`}),Q(`fields`,`Field values`,`keyValue`,{help:`Field values to write.`})],delete_record:[Q(`objectName`,`Object`,`reference`,{ref:{kind:`object`},placeholder:`contract`}),Q(`filter`,`Filter`,`keyValue`,{help:`Field/value pairs identifying the record(s) to delete.`})],get_record:[Q(`objectName`,`Object`,`reference`,{ref:{kind:`object`},placeholder:`contract`}),Q(`filter`,`Filter`,`keyValue`,{help:`Field/value pairs to match (e.g. status → active). Operator values like {"$ne": null} are preserved.`}),Q(`limit`,`Limit`,`number`,{placeholder:`100`}),Q(`outputVariable`,`Output variable`,`text`,{placeholder:`records`})],http_request:[Q(`method`,`Method`,`select`,{options:Ph}),Q(`url`,`URL`,`text`,{placeholder:`https://api.example.com/v1/contracts`}),Q(`headers`,`Headers`,`keyValue`,{help:`Request headers (e.g. Authorization, Content-Type).`}),Q(`body`,`Body`,`textarea`,{placeholder:`{ "key": "value" }`,help:`Request payload (JSON or expression).`}),Q(`outputVariable`,`Output variable`,`text`,{placeholder:`response`}),{id:`timeoutMs`,path:[`timeoutMs`],label:`Timeout (ms)`,kind:`number`,placeholder:`30000`}],script:[Q(`function`,`Function`,`text`,{placeholder:`score_lead`,help:`Registered function to call — declared via defineStack({ functions }). Required: it is what this step runs.`}),Q(`inputs`,`Inputs`,`keyValue`,{help:`Values passed to the function; {var} references resolve against the live flow variables.`}),Q(`outputVariable`,`Output variable`,`text`,{placeholder:`aiResult`,help:`Flow variable the function's return value is bound to, for later steps.`}),Q(`actionType`,`Action type (retired)`,`text`,{help:`Retired in spec 17 — "email"/"slack" never delivered anything, and any other value was just the function name. Use a notify node for messages, a Slack connector for Slack, or move the name into Function.`,showWhen:{field:`__legacy__`,equals:[]}}),Q(`template`,`Template (retired)`,`text`,{help:`Retired in spec 17 — it fed a side effect that never rendered or sent a message. A notify node carries its own title/message.`,showWhen:{field:`__legacy__`,equals:[]}}),Q(`recipients`,`Recipients (retired)`,`stringList`,{help:`Retired in spec 17 — these addresses were logged, never messaged. Use a notify node, whose recipients reach the messaging service.`,showWhen:{field:`__legacy__`,equals:[]}}),Q(`variables`,`Template variables (retired)`,`keyValue`,{help:`Retired in spec 17 — injected into a template nothing rendered. A notify node carries structured data in payload.`,showWhen:{field:`__legacy__`,equals:[]}}),Q(`script`,`Code (not executed, retired)`,`textarea`,{placeholder:`return { ok: true };`,help:`Retired in spec 17 — inline scripts were NEVER executed by the built-in runtime (no server-side sandbox). Move the logic into a registered function and name it in Function.`,refMode:`expression`,showWhen:{field:`__legacy__`,equals:[]}}),{id:`timeoutMs`,path:[`timeoutMs`],label:`Timeout (ms)`,kind:`number`,placeholder:`30000`}],screen:[Q(`title`,`Title`,`text`,{placeholder:`Request a discount`,help:`Heading shown above the screen.`}),Q(`description`,`Description`,`textarea`,{placeholder:`Enter the deal amount and the discount you want.`,help:`Body text. Interpolates {var} references (e.g. {approval_path}).`}),Q(`fields`,`Fields`,`objectList`,{help:`Input fields collected on this screen. Leave empty for a message-only screen.`,columns:[{key:`name`,label:`Name`,kind:`text`,placeholder:`discount`},{key:`label`,label:`Label`,kind:`text`,placeholder:`Discount %`},{key:`type`,label:`Type`,kind:`text`,placeholder:`number`},{key:`required`,label:`Required`,kind:`boolean`},{key:`visibleWhen`,label:`Visible when`,kind:`expression`,placeholder:`createOpportunity == true`}]}),Q(`waitForInput`,`Wait for input`,`boolean`,{help:`Pause to show this screen even with no fields (a message / confirmation). A field-less screen with this off is a server pass-through.`}),Q(`objectName`,`Object form`,`reference`,{ref:{kind:`object`},placeholder:`crm_account`,help:`Render this object’s full create/edit form (incl. master-detail) instead of a flat field list.`}),Q(`idVariable`,`Saved-record variable`,`text`,{placeholder:`account_id`,help:`Object form only: variable bound to the saved record’s id, for later steps.`}),Q(`mode`,`Form mode`,`select`,{defaultValue:`create`,options:[{value:`create`,label:`Create`},{value:`edit`,label:`Edit`}],help:`Object form only.`}),Q(`defaults`,`Form defaults`,`keyValue`,{help:`Object form only: prefilled values (e.g. account → {account_id}).`})],approval:[Q(`approvers`,`Approvers`,`objectList`,{help:`Who may act on this step. Wire the node’s out-edges with labels "approve" and "reject".`,columns:[{key:`type`,label:`Type`,kind:`select`,options:[{value:`manager`,label:`Manager`},{value:`position`,label:`Position`},{value:`department`,label:`Department`},{value:`team`,label:`Team`},{value:`field`,label:`Field`},{value:`expression`,label:`Expression (CEL)`},{value:`org_membership_level`,label:`Organization membership tier`},{value:`user`,label:`User`}]},{key:`value`,label:`Value`,kind:`reference`,placeholder:"User id / membership tier / position / team / department / field — per `type`",ref:{kindFrom:`type`,objectSource:`$trigger`,map:{user:`user`,position:`position`,org_membership_level:`org-membership-level`,role:`org-membership-level`,team:`team`,department:`department`,manager:`manager`,field:`object-field`,queue:`queue`}}},{key:`resolveAs`,label:`Resolve as`,kind:`select`,options:[{value:`user`,label:`User ids (default)`},{value:`department`,label:`Department ids → members`},{value:`position`,label:`Position names → holders`},{value:`team`,label:`Team ids → members`}]},{key:`group`,label:`Group`,kind:`text`,placeholder:`legal / finance — for per-group sign-off`}]}),Q(`behavior`,`Behavior`,`select`,{options:[{value:`first_response`,label:`First response wins`},{value:`unanimous`,label:`Unanimous (all approve)`},{value:`quorum`,label:`Quorum (M of N approve)`},{value:`per_group`,label:`Per group (each group signs off)`}],defaultValue:`first_response`,help:`How multiple approvers combine. Any rejection is a veto in every mode.`}),Q(`minApprovals`,`Min approvals`,`number`,{placeholder:`1`,help:`Approvals required — total for quorum, per group for per_group. Clamped server-side so it can never deadlock.`}),Q(`lockRecord`,`Lock record`,`boolean`,{defaultValue:`true`,help:`Lock the triggering record from edits while this node is pending.`}),Q(`approvalStatusField`,`Status field`,`reference`,{ref:{kind:`object-field`,objectSource:`$trigger`},placeholder:`approval_status`,help:`Business-object field to mirror request status onto (pending/approved/rejected). Should be readonly.`}),Q(`onEmptyApprovers`,`If no approver resolves`,`select`,{options:[{value:`admin_rescue`,label:`Hold for admin takeover (default)`},{value:`fail`,label:`Fail the node (config bug)`},{value:`auto_approve`,label:`Auto-approve (waves through!)`}],defaultValue:`admin_rescue`,help:`What an empty resolved approver slate does at node entry. Auto-approve silently waves the record through — opt in deliberately.`}),{id:`escalation.enabled`,path:[`config`,`escalation`,`enabled`],label:`SLA escalation`,kind:`boolean`,defaultValue:`true`,help:`Escalate when a decision is not recorded within the timeout.`},{id:`escalation.timeoutHours`,path:[`config`,`escalation`,`timeoutHours`],label:`Timeout (hours)`,kind:`number`,placeholder:`24`,showWhen:{field:`escalation.enabled`,equals:[`true`]}},{id:`escalation.action`,path:[`config`,`escalation`,`action`],label:`On timeout`,kind:`select`,defaultValue:`notify`,options:[{value:`notify`,label:`Notify`},{value:`reassign`,label:`Reassign`},{value:`auto_approve`,label:`Auto-approve`},{value:`auto_reject`,label:`Auto-reject`}],showWhen:{field:`escalation.enabled`,equals:[`true`]}},{id:`escalation.escalateTo`,path:[`config`,`escalation`,`escalateTo`],label:`Escalate to`,kind:`reference`,ref:{kind:`position`},placeholder:`position machine name / user id`,showWhen:{field:`escalation.enabled`,equals:[`true`]}},{id:`escalation.notifySubmitter`,path:[`config`,`escalation`,`notifySubmitter`],label:`Notify submitter`,kind:`boolean`,defaultValue:`true`,showWhen:{field:`escalation.enabled`,equals:[`true`]}},Q(`maxRevisions`,`Max revisions`,`number`,{placeholder:`3`,defaultValue:`3`,help:`Max send-backs for revision before the request auto-rejects (0 disables send-back). Needs a "revise" out-edge to take effect.`})],wait:[Nh(`waitEventConfig`,`eventType`,`Wait for`,`select`,{options:[{value:`timer`,label:`Timer`},{value:`signal`,label:`Signal`},{value:`webhook`,label:`Webhook`},{value:`manual`,label:`Manual`},{value:`condition`,label:`Condition`}],fallbackPath:[`config`,`eventType`]}),Nh(`waitEventConfig`,`timerDuration`,`Duration`,`text`,{placeholder:`PT1H · P3D`,help:`ISO 8601 duration (e.g. PT1H, P3D).`,showWhen:{field:`waitEventConfig.eventType`,equals:[`timer`]},fallbackPath:[`config`,`timerDuration`]}),Nh(`waitEventConfig`,`signalName`,`Signal name`,`text`,{placeholder:`contract.renewed`,showWhen:{field:`waitEventConfig.eventType`,equals:[`signal`,`webhook`]},fallbackPath:[`config`,`signalName`]})],subflow:[Q(`flowName`,`Flow`,`reference`,{ref:{kind:`flow`},placeholder:`escalation_flow`}),Q(`input`,`Input mapping`,`keyValue`,{help:`Values passed to the subflow’s input variables.`}),Q(`outputVariable`,`Output variable`,`text`,{placeholder:`subResult`}),{id:`timeoutMs`,path:[`timeoutMs`],label:`Timeout (ms)`,kind:`number`,placeholder:`60000`}],notify:[Q(`recipients`,`Recipients`,`stringList`,{help:`User id(s) / audience selector(s) to notify. At least one is required.`}),Q(`title`,`Title`,`text`,{placeholder:`Your request was approved`,help:`Notification title (required).`}),Q(`message`,`Message`,`textarea`,{placeholder:`Supports {var} template references.`,help:`Notification body.`}),Q(`channels`,`Channels`,`stringList`,{help:`Channels to fan out to (default: inbox — e.g. inbox · email · push).`}),Q(`topic`,`Topic`,`text`,{placeholder:`notify`,help:`Event topic (default: "notify").`}),Q(`severity`,`Severity`,`select`,{options:[{value:`info`,label:`Info`},{value:`warning`,label:`Warning`},{value:`critical`,label:`Critical`}],help:`Notification severity.`}),Q(`sourceObject`,`Link object`,`text`,{placeholder:`sys_approval_request`,help:`Object of the record the notification links to (requires Link record id).`}),Q(`sourceId`,`Link record id`,`text`,{help:`Record id the notification links to (requires Link object).`}),Q(`url`,`Click-through URL`,`text`,{help:`Explicit link; overrides the one synthesized from Link object/record.`})],connector_action:[Nh(`connectorConfig`,`connectorId`,`Connector`,`reference`,{ref:{kind:`connector`},placeholder:`slack · email · salesforce`}),Nh(`connectorConfig`,`actionId`,`Action`,`reference`,{ref:{kind:`connector-action`,connectorSource:`connectorId`},placeholder:`sendMessage · send`}),Nh(`connectorConfig`,`input`,`Input`,`keyValue`,{help:`Mapped inputs for the connector action.`}),{id:`timeoutMs`,path:[`timeoutMs`],label:`Timeout (ms)`,kind:`number`,placeholder:`30000`}],parallel:[],try_catch:[Q(`errorVariable`,`Error variable`,`text`,{placeholder:`$error`,help:`Variable the caught error is bound to inside the catch region.`})],parallel_gateway:[],join_gateway:[],boundary_event:[Nh(`boundaryConfig`,`attachedToNodeId`,`Attached to`,`reference`,{ref:{kind:`node`},placeholder:`host node id`,help:`Host node this boundary event monitors.`}),Nh(`boundaryConfig`,`eventType`,`Event type`,`select`,{options:[{value:`error`,label:`Error`},{value:`timer`,label:`Timer`},{value:`signal`,label:`Signal`},{value:`cancel`,label:`Cancel`}]}),Nh(`boundaryConfig`,`interrupting`,`Interrupting`,`boolean`,{defaultValue:`true`,help:`Cancel the host activity when this event fires.`}),Nh(`boundaryConfig`,`errorCode`,`Error code`,`text`,{placeholder:`TIMEOUT (empty = all)`,showWhen:{field:`boundaryConfig.eventType`,equals:[`error`]}}),Nh(`boundaryConfig`,`timerDuration`,`Duration`,`text`,{placeholder:`PT1H`,showWhen:{field:`boundaryConfig.eventType`,equals:[`timer`]}}),Nh(`boundaryConfig`,`signalName`,`Signal name`,`text`,{placeholder:`contract.cancelled`,showWhen:{field:`boundaryConfig.eventType`,equals:[`signal`]}})],legacy_action:[Q(`action`,`Action`,`text`,{placeholder:`sendEmail · createTask · update · query`}),Q(`objectName`,`Object`,`reference`,{ref:{kind:`object`},placeholder:`contract`}),Q(`recordId`,`Record`,`expression`,{placeholder:`record.id`}),Q(`params`,`Parameters`,`keyValue`,{help:`Action inputs. Values auto-typed: 3 → number, true → boolean.`}),Q(`fields`,`Field values`,`keyValue`),Q(`outputVariable`,`Output variable`,`text`,{placeholder:`result`})]},Ih={action:`legacy_action`,http:`http_request`,branch:`decision`,gateway:`decision`,condition:`decision`,timer:`wait`,delay:`wait`,flow:`subflow`,invoke:`subflow`,task:`legacy_action`,user_task:`screen`,service_task:`connector_action`,script_task:`script`,notification:`connector_action`,signal:`boundary_event`,webhook:`connector_action`,for_each:`loop`};function Lh(e){return e?Fh[Ih[e]??e]??[]:[]}function Rh(e){return e.path[0]===`config`}function zh(e,t){let n=Lh(t);if(!e)return n;let r=e.filter(Rh),i=n.filter(e=>!Rh(e)),a=new Set(i.map(e=>e.path[e.path.length-1]));return[...r.filter(e=>!a.has(e.path[e.path.length-1])),...i]}function Bh(e,t){if(!t)return e;let n={...e};return t.label&&(n.label=t.label),e.options&&t.opts&&(n.options=e.options.map(e=>({...e,label:t.opts[e.value]??e.label}))),n}function Vh(e,t,n){let r=ts(e,n.id)??ts(t,n.id);if(!r)return n;let i={...n};return r.label&&(i.label=r.label),r.help&&(i.help=r.help),n.unsetNotice&&r.unsetNotice&&(i.unsetNotice=r.unsetNotice),n.options&&r.opts&&(i.options=n.options.map(e=>({...e,label:r.opts[e.value]??e.label}))),n.columns&&r.cols&&(i.columns=n.columns.map(e=>Bh(e,r.cols[e.key]))),i}function Hh(e,t,n){if(!e||!es(n))return t;let r=Ih[e]??e;return t.map(t=>Vh(e,r,t))}function Uh(e,t){let n=t=>{let n=e;for(let e of t)if(n&&typeof n==`object`&&!Array.isArray(n))n=n[e];else return;return n},r=n(t.path);return r===void 0?t.fallbackPath?n(t.fallbackPath):void 0:r}function Wh(e){return e.path.length>=2&&e.path[0]===`config`?e.path[1]:void 0}function Gh(e,t,n,r){return!e.showWhen&&!e.flowKind||Jh(e,t)?!0:Yh(e,t,n,r)}function Kh(e){return e==null||e===``}function qh(e,t){return e.unsetNotice?e.kind===`secret`?typeof t!=`string`||t.trim()===``:Kh(t):!1}function Jh(e,t){return!Kh(Uh(t,e))}function Yh(e,t,n,r){if(e.flowKind&&(r===void 0||!e.flowKind.includes(r)))return!1;if(!e.showWhen)return!0;let i=n.find(t=>t.id===e.showWhen.field);if(!i)return!1;let a=Uh(t,i),o=Kh(a)?i.defaultValue:a,s=typeof o==`boolean`?String(o):o;return typeof s==`string`&&e.showWhen.equals.includes(s)}function Xh(e,t,n,r){return!e.showWhen&&!e.flowKind||!Jh(e,t)||Yh(e,t,n,r)?null:e.showWhen?n.some(t=>t.id===e.showWhen.field)?`controller-off`:`no-controller`:`controller-off`}var Zh=[`start`,`create_record`,`update_record`,`delete_record`,`get_record`,`decision`,`assignment`,`loop`,`http_request`,`script`,`screen`,`approval`,`wait`,`subflow`,`map`,`connector_action`,`parallel`,`try_catch`,`end`],Qh=new Set([`record-after-create`,`record-after-update`,`record-after-write`,`record-before-write`,`record-before-update`,`record-after-delete`]),$h=new Set([`record-after-update`,`record-before-update`,`record-after-write`,`record-before-write`]);function eg(e){return Array.isArray(e)?e:[]}function tg(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function $(e){return typeof e==`string`&&e?e:void 0}function ng(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function rg(e){if($(e.type)!==`connector_action`)return;let t=tg(e.connectorConfig),n=$(t.connectorId),r=$(t.actionId);return n&&r?{connectorId:n,actionId:r}:void 0}function ig(e){return eg(e.nodes).some(e=>!!rg(tg(e)))}function ag(e,t,n){if(!Array.isArray(e)||!t||!n)return;let r=e.find(e=>ng(e)&&e.name===t);if(!r||!Array.isArray(r.actions))return;let i=r.actions.find(e=>ng(e)&&e.key===n)?.outputSchema;return ng(i)?i:void 0}function og(e){if(!ng(e))return[];let t=e.properties;return ng(t)?Object.keys(t).filter(e=>e.length>0):[]}function sg(e,t){let n=new Map;for(let e of t){let t=$(e.source),r=$(e.target);if(!t||!r)continue;let i=n.get(r);i?i.push(t):n.set(r,[t])}let r=new Set,i=[...n.get(e)??[]];for(;i.length;){let t=i.pop();if(!(t===e||r.has(t))){r.add(t);for(let e of n.get(t)??[])i.push(e)}}return r}function cg(e,t){let n=$(e.type),r=tg(e.config),i=$(e.id)??``,a=$(e.label),o=a&&a!==i?a:i||void 0,s=[],c=(e,t=`outputs`)=>{e&&!s.some(t=>t.token===e)&&s.push({token:e,label:e,detail:o,group:t})};if((n===`loop`||n===`map`)&&c($(r.iteratorVariable),`loop`),c($(r.outputVariable)),c($(r.idVariable)),n===`assignment`){let e=r.assignments;if(Array.isArray(e))for(let t of e){let e=tg(t);c($(e.variable)??$(e.name)??$(e.key))}else if(e&&typeof e==`object`)for(let t of Object.keys(e))c(t)}if(n===`screen`||n===`user_task`)for(let e of eg(r.fields))c($(tg(e).name));if(n===`approval`&&i){c(`${i}.decision`);for(let e of eg(r.decisionOutputs)){let t=typeof e==`string`?e:$(tg(e).key);t&&c(`${i}.${t}`)}}let l=i?rg(e):void 0;if(l){let e=ag(t,l.connectorId,l.actionId);for(let t of og(e))c(`${i}.${t}`)}return s}function lg(e){let t=new Set;return e.filter(e=>!t.has(e.token)&&(t.add(e.token),!0))}function ug(e,t,n,r){let i=eg(e.nodes).map(tg),a=eg(e.edges),o=[];for(let t of eg(e.variables)){let e=tg(t),r=$(e.name);if(!r)continue;let i=$(e.type);o.push({token:r,label:r,detail:i?W(`engine.flowScope.detail.variableTyped`,n,{type:i}):G(`engine.flowScope.detail.variable`,n),group:`variables`})}if(!t)return{refs:lg(o)};let s=sg(t,a),c=i.find(e=>$(e.type)===`start`),l=$(c?.id);for(let e of i){let n=$(e.id);if(n&&n!==t&&s.has(n)&&n!==l)for(let t of cg(e,r))o.push(t)}if(c){let e=tg(c.config),r=$(e.triggerType),i=$(e.objectName),a=!!r&&Qh.has(r),u=l===t||!!l&&s.has(l);if(a&&i&&u){let e=l===t,a=$h.has(r);return e||o.push({token:`record`,label:`record`,detail:W(`engine.flowScope.detail.triggerRecord`,n,{object:i}),group:`trigger`}),a&&o.push({token:`previous`,label:`previous`,detail:G(`engine.flowScope.detail.previousRecord`,n),group:`trigger`}),{refs:lg(o),trigger:{objectName:i,fieldPrefix:e?``:`record.`,includePrevious:a}}}}return{refs:lg(o)}}function dg(e,t,n){let r=$(t.source);if(!r||$(t.type)===`fault`)return[];let i=eg(e.nodes).map(tg).find(e=>$(e.id)===r);return!i||$(i.type)===`start`?[]:cg(i,n)}function fg(e,t,n,r){let i=ug(e,$(t.source),n,r),a=lg([...i.refs,...dg(e,t,r)]);return i.trigger?{refs:a,trigger:i.trigger}:{refs:a}}function pg(e,t,n){let r=[];for(let i of t){if(!i?.name)continue;let t=`${e.fieldPrefix}${i.name}`,a=i.label&&i.label!==i.name?i.label:i.type;r.push({token:t,label:t,detail:a,group:`trigger`}),e.includePrevious&&r.push({token:`previous.${i.name}`,label:`previous.${i.name}`,detail:a?W(`engine.flowScope.detail.priorOf`,n,{detail:a}):G(`engine.flowScope.detail.priorValue`,n),group:`trigger`})}return r}var mg=new Set([`true`,`false`,`null`,`in`]),hg=new Set([`env`,`request`,`context`,`user`,`now`,`today`,`self`,`data`]);function gg(e){let t=new Set;for(let n of e){let e=n.token.split(`.`)[0];e&&t.add(e)}return t}function _g(e,t,n=2){if(Math.abs(e.length-t.length)>n)return n+1;let r=Array(t.length+1);for(let e=0;e<=t.length;e++)r[e]=e;for(let i=1;i<=e.length;i++){let a=r[0];r[0]=i;let o=r[0];for(let n=1;n<=t.length;n++){let s=r[n];r[n]=Math.min(r[n]+1,r[n-1]+1,a+(e[i-1]===t[n-1]?0:1)),a=s,r[n]<o&&(o=r[n])}if(o>n)return n+1}return r[t.length]}var vg=new Set([`map`,`filter`,`exists`,`all`,`exists_one`]);function yg(e){let t=[],n=/\.\s*([A-Za-z_]\w*)\s*\(\s*([A-Za-z_]\w*)\s*,/g,r;for(;r=n.exec(e);){if(!vg.has(r[1]))continue;let n=e.indexOf(`(`,r.index),i=e.length,a=0;for(let t=n;t<e.length;t++)if(e[t]===`(`)a++;else if(e[t]===`)`&&--a===0){i=t;break}t.push({name:r[2],open:n,close:i})}return t}function bg(e){let t=e.replace(/'(?:[^'\\]|\\.)*'/g,` `).replace(/"(?:[^"\\]|\\.)*"/g,` `),n=yg(t),r=[],i=/(?<![.\w$])([A-Za-z_$][\w$]*)/g,a;for(;a=i.exec(t);){let e=a[1],i=a.index;/^\s*\(/.test(t.slice(i+e.length))||mg.has(e)||n.some(t=>t.name===e&&i>t.open&&i<t.close)||r.push(e)}return r}function xg(e,t,n){let r=``;if(typeof e==`string`?r=e:e&&typeof e==`object`&&(r=String(e.source??``)),!r.trim()||n.size===0)return[];let i=r;if(t===`template`){let e=r.match(/\{([^{}]+)\}/g);if(!e)return[];i=e.map(e=>e.slice(1,-1)).join(` ; `)}let a=new Set,o=[];for(let e of bg(i)){if(a.has(e)||(a.add(e),n.has(e)||hg.has(e)||e.startsWith(`$`)))continue;let t,r=3;for(let i of n){let n=_g(e,i,2);n<r&&(r=n,t=i)}o.push({token:e,suggestion:r<=2?t:void 0})}return o}function Sg(e,t){if(e.length===1){let n=e[0];return n.suggestion?W(`engine.flowRef.unknownWithSuggestion`,t,{token:n.token,suggestion:n.suggestion}):W(`engine.flowRef.notInScope`,t,{token:n.token})}return W(`engine.flowRef.notInScopeMulti`,t,{tokens:e.map(e=>`\`${e.token}\``).join(`, `)})}var Cg=/(?:^|[^{])\{\s*([A-Za-z_$][\w.$]*)\s*\}(?!\})/;function wg(e,t,n){let r=0;for(let i of e)if(i===t)r++;else if(i===n&&(r--,r<0))return!1;return r===0}function Tg(e,t,n){let r=``,i;if(typeof t==`string`)r=t;else if(t&&typeof t==`object`){let e=t;i=e.dialect,r=e.source??``}if(!r.trim())return null;if(e===`template`){if(i&&i!==`template`)return{message:W(`engine.flowExpr.templateDialect`,n,{dialect:i})};wg(r.replace(/\{\{/g,``).replace(/\}\}/g,``),`{`,`}`);let e=Cg.exec(r);return e?{message:W(`engine.flowExpr.singleBraceTemplate`,n,{ref:e[1]})}:null}if(i&&i!==`cel`)return{message:W(`engine.flowExpr.celDialect`,n,{dialect:i})};let a=Cg.exec(r);return a?{message:W(`engine.flowExpr.braceInCondition`,n,{ref:a[1]})}:wg(r,`(`,`)`)?wg(r,`[`,`]`)?null:{message:W(`engine.flowExpr.unbalancedBrackets`,n,{source:r})}:{message:W(`engine.flowExpr.unbalancedParens`,n,{source:r})}}var Eg=/\{([^{}]+)\}/g;function Dg(e,t){return e?t?e.replace(Eg,(e,n)=>{let r=t[String(n).trim()];return r==null?e:String(r)}):e:``}var Og=`record`;function kg(e){return new Set([...Object.keys(xa(Kg(e),{})),Og])}var Ag=new Set([`all`,`exists`,`exists_one`,`map`,`filter`]);function jg(e){return!!e&&typeof e==`object`&&typeof e.op==`string`}function Mg(e,t,n){if(Array.isArray(e)){for(let r of e)Mg(r,t,n);return}if(jg(e)){if(e.op===`id`){typeof e.args==`string`&&!t.has(e.args)&&n.add(e.args);return}if(e.op===`rcall`&&Array.isArray(e.args)){let[r,i,a]=e.args;if(Mg(i,t,n),typeof r==`string`&&Ag.has(r)&&Array.isArray(a)&&jg(a[0])&&a[0].op===`id`&&typeof a[0].args==`string`){let e=new Set(t);e.add(a[0].args),Mg(a.slice(1),e,n);return}Mg(a,t,n);return}Mg(e.args,t,n)}}function Ng(e){let t=le(e);if(t){let e=new Set;return Mg(t,new Set,e),{ok:!0,roots:[...e]}}return ce(e)}function Pg(e,t,n){if(e==null||typeof e==`string`&&!e.trim())return;let r=m(e);if(r)return r.message;let i=e,a=C(`predicate`,i);if(a.errors.length>0)return a.errors.map(e=>e.message).join(` `);let o=Ng(i);if(!o.ok)return o.error;let s=kg(t),c=o.roots.filter(e=>!s.has(e));if(c.length===0)return;let l=ba(Kg(t)).map(e=>e.name);return c.map(e=>{let t=D(e,l);return t?W(`engine.flowRef.notAScreenFieldWithSuggestion`,n,{token:e,suggestion:t}):W(`engine.flowRef.notAScreenField`,n,{token:e})}).join(`; `)}function Fg(e,t){let n=e.config?.fields;if(!Array.isArray(n))return[];let r=[];for(let i of n){if(!i||typeof i!=`object`)continue;let n=i;if(typeof n.name!=`string`||!n.name)continue;let a=Pg(n.visibleWhen,e,t);a&&r.push({name:n.name,error:a})}return r}function Ig(e){return typeof e==`string`?e:void 0}function Lg(e){return typeof e==`number`?e:void 0}function Rg(e){if(Array.isArray(e))return e.every(e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&typeof e.label==`string`)?e:void 0}var zg={name:e=>typeof e==`string`&&e?e:void 0,label:Ig,type:Ig,required:e=>e===!0,options:Rg,defaultValue:e=>e,placeholder:Ig,min:Lg,max:Lg,inlineHelpText:Ig,reference:Ig,visibleWhen:Ig},Bg=Object.keys(zg);function Vg(e,t,n){let r=zg[t](n[t]);r!==void 0&&(e[t]=r)}function Hg(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n,r=zg.name(e.name);if(r===void 0)continue;let i={name:r};for(let t of Bg)Vg(i,t,e);t.push(i)}return t}function Ug(e){return typeof e==`string`?e.search(Eg)>=0:Array.isArray(e)?e.some(Ug):e&&typeof e==`object`?Object.values(e).some(Ug):!1}function Wg(e){let t=[];for(let n of e)Ug(n.defaultValue)&&t.push({name:n.name,label:n.label||n.name,literal:typeof n.defaultValue==`string`?n.defaultValue:JSON.stringify(n.defaultValue)});return t}function Gg(e,t){return ba(e).length-Sa(e,t).length}function Kg(e){let t=e.config&&typeof e.config==`object`?e.config:{},n=typeof t.objectName==`string`&&t.objectName?t.objectName:void 0,r=t.mode===`edit`?`edit`:t.mode===`create`?`create`:void 0,i=t.defaults&&typeof t.defaults==`object`&&!Array.isArray(t.defaults)?t.defaults:void 0;return{nodeId:e.id,title:typeof t.title==`string`?t.title:void 0,description:typeof t.description==`string`?t.description:void 0,fields:Hg(t.fields),kind:n?`object-form`:`fields`,objectName:n,mode:r,defaults:i,idVariable:typeof t.idVariable==`string`?t.idVariable:void 0}}function qg(e){return Array.isArray(e)?e:[]}function Jg(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Yg(e){return typeof e==`string`&&e?e:void 0}function Xg(e,t,n){let r=Tg(`predicate`,e,n);if(r)return{level:`error`,message:r.message};if(t&&t.size>0){let r=xg(e,`predicate`,t);if(r.length>0)return{level:`warning`,message:Sg(r,n)}}return null}function Zg(e,t,n){let r=Tg(`predicate`,e,n);if(r)return{level:`error`,message:r.message};let i=Pg(e,t,n);return i?{level:`warning`,message:i}:null}function Qg(e,t,n){return e===`screen`&&t===`fields`&&n===`visibleWhen`}function $g(e,t,n){let r=qg(e.nodes).map(Jg),i=qg(e.edges).map(Jg),a=Yg(r.find(e=>Yg(e.type)===`start`)?.id),o=[];for(let i of r){let r=Yg(i.id),s=Yg(i.type);if(!r||!s)continue;let c=r===a?null:gg(ug(e,r,void 0,n).refs);for(let e of Hh(s,Lh(s),t))if(e.kind===`expression`&&e.refMode!==`template`){let n=Xg(Uh(i,e),c,t);n&&o.push({target:{kind:`node`,nodeId:r},level:n.level,message:n.message})}else if(e.kind===`objectList`&&e.columns){let n=e.columns.filter(e=>e.kind===`expression`);if(n.length===0)continue;let a={id:r,config:Jg(i.config)};for(let l of qg(Uh(i,e))){let i=Jg(l),u=Yg(i.label);for(let l of n){let n=Qg(s,e.id,l.key)?Zg(i[l.key],a,t):Xg(i[l.key],c,t);if(n){let e=u||l.label;o.push({target:{kind:`node`,nodeId:r},level:n.level,message:e?`${e}: ${n.message}`:n.message})}}}}}for(let r of i){let i=Yg(r.source),s=Yg(r.target);if(!i||!s||r.isDefault===!0)continue;let c=i===a?null:gg(fg(e,r,void 0,n).refs),l=Xg(r.condition,c,t);l&&o.push({target:{kind:`edge`,source:i,target:s},level:l.level,message:l.message})}return o}function e_(e,t){return`${e}->${t}`}function t_(e,t,n){let r=e.findIndex(e=>e.source===t&&e.target===n);return r>=0?go(e[r],r):`${t}->${n}#-1`}function n_(e){return Array.isArray(e)?e:typeof e!=`string`||!e?[]:e.split(`.`).map(e=>{let t=Number(e);return Number.isInteger(t)&&String(t)===e?t:e})}function r_(e,t){if(e.edge){let{source:n,target:r}=e.edge;return{target:{kind:`edge`,source:n,target:r,edgeKey:t_(t,n,r)}}}if(e.cycle&&e.cycle.length>=2){let n=e.cycle,r=n[n.length-2],i=n[n.length-1],a=[],o=[];for(let e=0;e<n.length-1;e++)a.push(n[e]),o.push({source:n[e],target:n[e+1]});return{target:{kind:`edge`,source:r,target:i,edgeKey:t_(t,r,i)},highlight:{nodeIds:a,edges:o}}}return e.nodeId?{target:{kind:`node`,nodeId:e.nodeId}}:{target:{kind:`flow`}}}function i_(e,t,n){let r=n_(e);if(r.length>=2&&typeof r[1]==`number`){let e=r[1];if(r[0]===`nodes`&&t[e]?.id)return{kind:`node`,nodeId:t[e].id};if(r[0]===`edges`&&n[e]){let t=n[e];return{kind:`edge`,source:t.source,target:t.target,edgeKey:go(t,e)}}}return{kind:`flow`}}function a_(e){return e.kind===`node`?`n:${e.nodeId}`:e.kind===`edge`?`e:${e.source}->${e.target}`:`flow`}function o_({nodes:e,edges:t,serverDiagnostics:n,variables:r,locale:i,connectors:a}){let o=[],s=Mh(e,t,i),c=(e,n)=>{n.forEach((n,r)=>{let{target:i,highlight:a}=r_(n,t);o.push({id:`structural:${e}:${r}:${a_(i)}`,level:e,message:n.message,target:i,source:`structural`,...a?{highlight:a}:{}})})};return c(`error`,s.errors),c(`warning`,s.warnings),(n??[]).forEach((n,r)=>{let i=n.severity===`warning`?`warning`:`error`,a=i_(n.path,e,t);o.push({id:`server:${r}:${a_(a)}`,level:i,message:n.message,target:a,source:`server`})}),$g({nodes:e,edges:t,variables:r??[]},i,a).forEach((e,n)=>{let r=e.target.kind===`edge`?{kind:`edge`,source:e.target.source,target:e.target.target,edgeKey:t_(t,e.target.source,e.target.target)}:{kind:`node`,nodeId:e.target.nodeId};o.push({id:`expression:${e.level}:${n}:${a_(r)}`,level:e.level,message:e.message,target:r,source:`expression`})}),o.map((e,t)=>[e,t]).sort((e,t)=>e[0].level===t[0].level?e[1]-t[1]:e[0].level===`error`?-1:1).map(([e])=>e)}function s_(e){return{level:e.some(e=>e.level===`error`)?`error`:`warning`,title:e.map(e=>e.message).join(`
9
+ `),count:e.length}}function c_(e){let t=new Map,n=new Map;for(let r of e)if(r.target.kind===`node`){let e=t.get(r.target.nodeId)??[];e.push(r),t.set(r.target.nodeId,e)}else if(r.target.kind===`edge`){let e=e_(r.target.source,r.target.target),t=n.get(e)??[];t.push(r),n.set(e,t)}let r=new Map;for(let[e,n]of t)r.set(e,s_(n));let i=new Map;for(let[e,t]of n)i.set(e,s_(t));return{byNode:r,byEdge:i}}function l_(e){let t=new Set,n=new Set;for(let r of e)if(r.level===`error`){r.target.kind===`node`?t.add(r.target.nodeId):r.target.kind===`edge`&&n.add(e_(r.target.source,r.target.target));for(let e of r.highlight?.nodeIds??[])t.add(e);for(let e of r.highlight?.edges??[])n.add(e_(e.source,e.target))}return{invalidNodeIds:[...t],invalidEdges:n}}var u_=.4,d_=1.6,f_=4;function p_({nodes:e,edges:t,editable:n,designMode:r,selectedId:i,selectedEdgeId:a,locale:o,activeNodeId:s,visitedNodeIds:c,traversedEdgeIds:l,invalidNodeIds:u,invalidEdges:d,onRevealProblem:f,problems:p,revealSignal:m,onSelect:h,onSelectEdge:g,selectedNestedPath:_,onSelectNested:v,onPatch:y}){let b=J.useMemo(()=>oo(e),[e]),x=J.useRef(null),[S,C]=J.useState(1),[w,T]=J.useState({x:0,y:0}),[E,D]=J.useState(!1),O=yh(),[k,A]=J.useState(null),j=J.useRef(null),M=J.useRef(null),[N,P]=J.useState(()=>new Set),ee=J.useCallback(e=>{let t=N.has(e);P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),t&&_?.containerId===e&&v?.(null)},[N,_,v]),F=J.useMemo(()=>{let e=new Map;for(let t of b){let n=Fo(t);n.length>0&&e.set(t.id,n)}return e},[b]),te=J.useMemo(()=>{let e=new Map;for(let t of b){let n=N.has(t.id)?F.get(t.id):void 0;e.set(t.id,n?eh(n):66)}return e},[b,F,N]),{positions:ne,heights:re,size:ie}=J.useMemo(()=>xo(b,t,e=>te.get(e.id)??66),[b,t,te]),ae=J.useMemo(()=>new Set(c??[]),[c]),oe=J.useMemo(()=>new Set(l??[]),[l]),I=J.useMemo(()=>new Set(u??[]),[u]),se=(c?.length??0)>0||!!s,{byNode:ce,byEdge:le}=J.useMemo(()=>c_(p??[]),[p]),ue=J.useMemo(()=>(p??[]).filter(e=>e.level===`error`),[p]),de=J.useCallback(e=>k&&k.id===e?{x:k.x,y:k.y}:ne.get(e)??{x:0,y:0},[k,ne]),fe=J.useCallback((e,t,n)=>{if(!y)return;let r=b.findIndex(t=>t.id===e);if(r<0)return;let i={...b[r],position:{x:t,y:n}};y({nodes:xs(b,r,i)})},[b,y]),L=J.useCallback((e,n)=>{if(!y)return;let r=ol(`node`,b.map(e=>e.id).filter(Boolean)),i=fh(e,o),a=n?.at,s={id:r,type:e,label:i,...ph(e),...a?{position:{x:a.x,y:a.y}}:{}},c={nodes:os(b,s)};if(n?.from){let e={id:ol(`edge`,t.map(e=>e.id).filter(Boolean)),source:n.from,target:r},i=b.find(e=>e.id===n.from);if(i?.type===`decision`){let r=(Array.isArray(i.config?.conditions)?i.config.conditions:[])[t.filter(e=>e.source===n.from).length];if(r&&typeof r==`object`){let t=typeof r.expression==`string`?r.expression.trim():``,n=typeof r.label==`string`?r.label.trim():``;n&&(e.label=n),t===`true`?e.isDefault=!0:t&&(e.condition=t)}}c.edges=os(t,e)}y(c),h(s),D(!1)},[t,b,y,h,de,o]),pe=J.useCallback((e,n=`create_record`)=>{if(!y)return;let r=t.findIndex(t=>t===e);if(r<0)return;let i=ol(`node`,b.map(e=>e.id).filter(Boolean)),a=de(e.source),s=de(e.target),c={x:(a.x+s.x)/2,y:(a.y+s.y)/2},l={id:i,type:n,label:fh(n,o),...ph(n),position:{x:c.x,y:c.y}},u={...e,target:i},d={id:ol(`edge`,[...t.map(e=>e.id).filter(Boolean),`edge`]),source:i,target:e.target},f=xs(t,r,u);y({nodes:os(b,l),edges:os(f,d)}),h(l)},[t,b,y,h,de,o]),me=J.useCallback(e=>{if(!y||!b.some(t=>t.id===e))return;let n=ol(`node`,b.map(e=>e.id).filter(Boolean)),r={id:n,type:`wait`,label:G(`engine.flowCanvas.awaitingRevision`,o),waitEventConfig:{eventType:`signal`,signalName:`revision`}},i=t.map(e=>e.id).filter(Boolean),a=ol(`edge`,i),s=ol(`edge`,[...i,a]),c={id:a,source:e,target:n,label:`revise`},l={id:s,source:n,target:e,label:`resubmit`,type:`back`};y({nodes:os(b,r),edges:os(os(t,c),l)}),h(r)},[t,b,y,h,o]),he=J.useMemo(()=>{let e=new Set;for(let n of t)typeof n.label==`string`&&n.label.trim().toLowerCase()===`revise`&&e.add(n.source);return e},[t]),ge=J.useCallback(e=>{y&&(y({nodes:b.filter(t=>t.id!==e),edges:t.filter(t=>t.source!==e&&t.target!==e)}),h(null))},[t,b,y,h]),_e=J.useCallback(e=>t=>{if(t.button!==0||!n&&!r||(t.stopPropagation(),!n))return;let i=de(e);j.current={nodeId:e,startX:t.clientX,startY:t.clientY,originX:i.x,originY:i.y,moved:!1},t.currentTarget.setPointerCapture?.(t.pointerId)},[r,n,de]),ve=J.useCallback(e=>{let t=j.current;if(!t)return;let n=(e.clientX-t.startX)/S,r=(e.clientY-t.startY)/S;!t.moved&&Math.hypot(e.clientX-t.startX,e.clientY-t.startY)<f_||(t.moved=!0,A({id:t.nodeId,x:Math.max(0,t.originX+n),y:Math.max(0,t.originY+r)}))},[S]),ye=J.useCallback(e=>{let t=j.current;j.current=null,t&&(e.currentTarget.releasePointerCapture?.(e.pointerId),t.moved&&k&&fe(t.nodeId,Math.round(k.x),Math.round(k.y)),A(null))},[k,fe]),be=J.useCallback(e=>{e.button===0&&(h(null),M.current={startX:e.clientX,startY:e.clientY,originX:w.x,originY:w.y},e.currentTarget.setPointerCapture?.(e.pointerId))},[h,w.x,w.y]),xe=J.useCallback(e=>{let t=M.current;t&&T({x:t.originX+(e.clientX-t.startX),y:t.originY+(e.clientY-t.startY)})},[]),Se=J.useCallback(e=>{M.current&&e.currentTarget.releasePointerCapture?.(e.pointerId),M.current=null},[]),Ce=e=>Math.min(d_,Math.max(u_,e)),we=J.useCallback(()=>{let e=x.current;if(!e)return;let t=(e.clientWidth-32)/ie.width,n=(e.clientHeight-32)/ie.height,r=Ce(Math.min(t,n));C(r),T({x:(e.clientWidth-ie.width*r)/2,y:Math.max(16,(e.clientHeight-ie.height*r)/2)})},[ie.height,ie.width]);J.useEffect(()=>{let e=x.current;e&&(C(1),T({x:(e.clientWidth-ie.width)/2,y:Math.max(16,(e.clientHeight-ie.height)/2)}))},[]),J.useEffect(()=>{if(!m)return;let e=x.current;if(!e)return;let t=m.target,n=null;if(t.kind===`node`){let e=ne.get(t.nodeId);e&&(n={x:e.x+120,y:e.y+(re.get(t.nodeId)??66)/2})}else if(t.kind===`edge`){let e=ne.get(t.source),r=ne.get(t.target);e&&r&&(n=Io(ro(e,re.get(t.source)??66),_o(r)))}n&&T({x:e.clientWidth/2-n.x*S,y:e.clientHeight/2-n.y*S})},[m?.nonce]);let Te=J.useCallback(e=>{if(n&&i&&(e.key===`Delete`||e.key===`Backspace`)){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)return;e.preventDefault(),ge(i)}},[ge,n,i]);return(0,Y.jsxs)(`div`,{className:`relative h-full min-h-[320px] w-full overflow-hidden`,children:[ue.length>0&&(0,Y.jsxs)(`div`,{className:`absolute left-2 top-2 z-30 max-w-[min(60%,420px)] space-y-1`,children:[ue.slice(0,3).map(e=>{let t=!!f&&e.target.kind!==`flow`;return(0,Y.jsxs)(`button`,{type:`button`,role:`alert`,disabled:!t,onPointerDown:e=>e.stopPropagation(),onClick:t?t=>{t.stopPropagation(),f(e)}:void 0,title:t?G(`engine.flowCanvas.reveal`,o):void 0,className:R(`flex w-full items-start gap-1.5 rounded-lg border border-destructive/40 bg-destructive/10 px-2.5 py-1.5 text-left text-[11px] leading-snug text-destructive shadow-sm backdrop-blur-sm transition-colors`,t&&`cursor-pointer hover:border-destructive/60 hover:bg-destructive/20`),children:[(0,Y.jsx)(Ji,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Y.jsx)(`span`,{children:e.message})]},e.id)}),ue.length>3&&(0,Y.jsx)(`div`,{className:`px-2.5 text-[10px] text-destructive/80`,children:W(`engine.flowCanvas.moreErrors`,o,{count:ue.length-3})})]}),(0,Y.jsxs)(`div`,{className:`absolute right-2 top-2 z-30 flex items-center gap-1.5`,children:[n&&(0,Y.jsx)(gh,{locale:o,items:O,open:E,onOpenChange:D,onPick:e=>L(e,{from:i??void 0}),children:(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border bg-background/90 px-2.5 py-1.5 text-xs font-medium shadow-sm backdrop-blur-sm transition-colors hover:border-primary/50 hover:bg-accent hover:text-foreground`,children:[(0,Y.jsx)(U,{className:`h-3.5 w-3.5`}),G(`engine.inspector.add.node`,o)]})}),(0,Y.jsxs)(`div`,{className:`flex items-center rounded-lg border bg-background/90 shadow-sm backdrop-blur-sm`,children:[(0,Y.jsx)(`button`,{type:`button`,title:G(`engine.flowCanvas.zoomOut`,o),"aria-label":G(`engine.flowCanvas.zoomOut`,o),onClick:()=>C(e=>Ce(e-.15)),className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground hover:text-foreground`,children:(0,Y.jsx)(ia,{className:`h-3.5 w-3.5`})}),(0,Y.jsxs)(`span`,{className:`w-10 text-center text-[11px] tabular-nums text-muted-foreground`,children:[Math.round(S*100),`%`]}),(0,Y.jsx)(`button`,{type:`button`,title:G(`engine.flowCanvas.zoomIn`,o),"aria-label":G(`engine.flowCanvas.zoomIn`,o),onClick:()=>C(e=>Ce(e+.15)),className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground hover:text-foreground`,children:(0,Y.jsx)(aa,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,title:G(`engine.flowCanvas.fit`,o),"aria-label":G(`engine.flowCanvas.fit`,o),onClick:we,className:`inline-flex h-7 w-7 items-center justify-center border-l text-muted-foreground hover:text-foreground`,children:(0,Y.jsx)(Yr,{className:`h-3.5 w-3.5`})})]})]}),(0,Y.jsx)(`div`,{ref:x,tabIndex:0,role:`application`,"aria-label":G(`engine.flowCanvas.canvas`,o),onKeyDown:Te,onPointerDown:be,onPointerMove:e=>{xe(e),ve(e)},onPointerUp:e=>{Se(e),ye(e)},className:R(`h-full w-full cursor-grab outline-none active:cursor-grabbing`,`bg-muted/15 dark:bg-background/30`,`shadow-[inset_0_0_90px_rgba(0,0,0,0.05)]`),style:{backgroundImage:`radial-gradient(circle at 1px 1px, hsl(var(--border)) 1px, transparent 0)`,backgroundSize:`${18*S}px ${18*S}px`,backgroundPosition:`${w.x}px ${w.y}px`},children:(0,Y.jsxs)(`div`,{className:`relative origin-top-left`,style:{width:ie.width,height:ie.height,transform:`translate(${w.x}px, ${w.y}px) scale(${S})`},children:[(0,Y.jsxs)(`svg`,{className:`pointer-events-none absolute left-0 top-0 overflow-visible`,width:ie.width,height:ie.height,children:[(0,Y.jsxs)(`defs`,{children:[(0,Y.jsx)(`marker`,{id:`flow-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,Y.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-muted-foreground/55`})}),(0,Y.jsx)(`marker`,{id:`flow-arrow-back`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,Y.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-amber-500/80`})}),(0,Y.jsx)(`marker`,{id:`flow-arrow-error`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,Y.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-destructive`})})]}),t.map((e,t)=>{let i=ne.get(e.source),s=ne.get(e.target);if(!i||!s)return null;let c=mo(e),l=!c&&!!d?.has(`${e.source}->${e.target}`),u=k?.id===e.source?de(e.source):i,f=k?.id===e.target?de(e.target):s,p=c?ho(u):ro(u,re.get(e.source)??66),m=c?ho(f):_o(f),h=c?qo(p,m):Io(p,m),_=ao(e.condition),v=e.isDefault?`else`:_?`if ${_}`:e.label,y=go(e,t),b=le.get(e_(e.source,e.target)),x=oe.has(y),S=a===y,C=c?bo(p,m):no(p,m),w=r&&!!g;return(0,Y.jsxs)(`g`,{"data-invalid":l||void 0,children:[(0,Y.jsx)(`path`,{d:C,strokeLinecap:`round`,strokeDasharray:c?`5 4`:void 0,className:R(`fill-none transition-[stroke] duration-150`,x?`stroke-sky-500`:S?`stroke-primary`:l?`stroke-destructive`:c?`stroke-amber-500/70`:se?`stroke-muted-foreground/20`:`stroke-muted-foreground/40`),strokeWidth:x||S||l?2.5:1.75,markerEnd:l?`url(#flow-arrow-error)`:c?`url(#flow-arrow-back)`:`url(#flow-arrow)`}),w&&(0,Y.jsx)(`path`,{d:C,className:`pointer-events-auto cursor-pointer fill-none stroke-transparent`,strokeWidth:14,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),g(e,y)},children:(0,Y.jsx)(`title`,{children:l?W(`engine.flowCanvas.edge.undeclaredCycle`,o,{source:e.source,target:e.target}):c?W(`engine.flowCanvas.edge.backEdge`,o,{source:e.source,target:e.target}):`${e.source} → ${e.target}`})}),v&&(0,Y.jsx)(`foreignObject`,{x:h.x-60,y:h.y-11,width:120,height:22,className:R(w&&`pointer-events-auto`),children:(0,Y.jsx)(`div`,{className:`flex justify-center`,children:(0,Y.jsx)(`span`,{onPointerDown:w?e=>e.stopPropagation():void 0,onClick:w?t=>{t.stopPropagation(),g(e,y)}:void 0,className:R(`max-w-full truncate rounded-full border bg-background/95 px-2 py-0.5 text-[10px] font-medium shadow-sm backdrop-blur-sm transition-colors`,w&&`cursor-pointer hover:border-primary/60`,S?`border-primary text-primary`:l?`border-destructive/60 text-destructive`:c?`border-amber-500/50 text-amber-600 dark:text-amber-400`:`border-border text-muted-foreground`),children:v})})}),b&&(0,Y.jsx)(`foreignObject`,{x:h.x-9,y:h.y-30,width:18,height:18,className:`pointer-events-auto overflow-visible`,children:(0,Y.jsx)(`span`,{title:b.title,"data-problem":b.level,className:R(`inline-flex h-[18px] w-[18px] items-center justify-center rounded-full border bg-background shadow-sm`,b.level===`error`?`border-destructive/50 text-destructive`:`border-amber-500/50 text-amber-600 dark:text-amber-400`),children:b.level===`error`?(0,Y.jsx)(Rn,{className:`h-3 w-3`}):(0,Y.jsx)(Ji,{className:`h-3 w-3`})})}),n&&!c&&(0,Y.jsx)(`foreignObject`,{x:v?h.x+66:h.x-11,y:h.y-11,width:22,height:22,className:`pointer-events-auto`,children:(0,Y.jsx)(`button`,{type:`button`,title:G(`engine.flowCanvas.insertNode`,o),"aria-label":G(`engine.flowCanvas.insertNode`,o),onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),pe(e)},className:`inline-flex h-[22px] w-[22px] items-center justify-center rounded-full border bg-background/90 text-muted-foreground opacity-50 shadow-sm backdrop-blur-sm transition-all hover:scale-110 hover:border-primary hover:bg-background hover:text-primary hover:opacity-100 focus-visible:opacity-100`,children:(0,Y.jsx)(U,{className:`h-3 w-3`})})})]},e.id||`${e.source}-${e.target}-${t}`)})]}),b.map(e=>{let t=s===e.id?`active`:ae.has(e.id)?`visited`:void 0;return(0,Y.jsx)(mh,{id:e.id,locale:o,type:e.type,label:e.label||e.id,summary:m_(e,o),position:de(e.id),selected:i===e.id,editable:n,runState:t,dimmed:se&&!t,onPointerDown:_e(e.id),onSelect:()=>r&&h(e),onAppend:()=>L(`create_record`,{from:e.id}),onAddReviseLoop:n&&e.type===`approval`&&!he.has(e.id)?()=>me(e.id):void 0,invalid:I.has(e.id),badge:ce.get(e.id),regions:F.get(e.id),expanded:N.has(e.id),onToggleExpand:F.has(e.id)?()=>ee(e.id):void 0,height:re.get(e.id),selectedNestedNode:_?.containerId===e.id?{regionKey:_.regionKey,nodeId:_.nodeId}:null,onSelectNestedNode:r&&v?(t,n)=>v({containerId:e.id,regionKey:t,nodeId:n.id},n):void 0},e.id)})]})})]})}function m_(e,t){let n=e.config,r=e=>typeof e==`string`&&e?e:void 0,i=(t,n)=>{let i=e[t];return i&&typeof i==`object`?r(i[n]):void 0},a=e=>n?r(n[e]):void 0,o=(e,t)=>{let i=n?.[e];return i&&typeof i==`object`&&!Array.isArray(i)?r(i[t]):void 0};if(e.type===`start`)return a(`condition`)||a(`criteria`)||a(`objectName`)||o(`schedule`,`expression`)||o(`schedule`,`cron`)||a(`cron`)||a(`schedule`)||o(`timeRelative`,`object`)||a(`triggerType`);if(e.type===`decision`){let e=n?.conditions;if(Array.isArray(e)&&e.length){let n=e.map(e=>e&&typeof e==`object`?r(e.label):void 0).filter(Boolean);return n.length?n.join(` / `):W(`engine.flowCanvas.summary.branches`,t,{count:e.length})}return a(`condition`)}if(e.type===`script`)return a(`function`)||a(`actionType`)||a(`template`)||(n&&n.script?G(`engine.flowCanvas.summary.code`,t):void 0);if(e.type===`approval`){let e=n?.approvers,r=Array.isArray(e)?e.length:0,i=a(`behavior`);if(r>0){let e=W(r===1?`engine.flowCanvas.summary.approversOne`:`engine.flowCanvas.summary.approversOther`,t,{count:r});return i===`unanimous`?`${e} · ${G(`engine.flowCanvas.summary.unanimous`,t)}`:e}return i||void 0}return a(`objectName`)||i(`connectorConfig`,`actionId`)||i(`waitEventConfig`,`timerDuration`)||i(`waitEventConfig`,`eventType`)||i(`boundaryConfig`,`eventType`)||a(`condition`)||a(`flowName`)||a(`url`)||a(`collection`)||a(`action`)||a(`flow`)||a(`event`)||a(`duration`)||void 0}var h_=`nested-node`,g_=/^(.+?)::(body|try|catch|branch-\d+)::(.+)$/,__=/^branch-(\d+)$/;function v_(e){return`${e.containerId}::${e.regionKey}::${e.nodeId}`}function y_(e){let t=g_.exec(e);return t?{containerId:t[1],regionKey:t[2],nodeId:t[3]}:null}function b_(e){if(e===`body`||e===`try`||e===`catch`)return{kind:`key`,key:e};let t=__.exec(e);return t?{kind:`branch`,index:Number(t[1])}:null}function x_(e,t){if(e===`body`)return`Body`;if(e===`try`)return`Try`;if(e===`catch`)return`Catch`;let n=__.exec(e);if(n){let e=Number(n[1]),r=t&&typeof t.config==`object`&&t.config?t.config:{},i=(Array.isArray(r.branches)?r.branches:[])[e],a=i&&typeof i==`object`?i.name:void 0;return typeof a==`string`&&a?a:`Branch ${e+1}`}return e}function S_(e){return Array.isArray(e)?e:[]}function C_(e){let t=e.config;return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}function w_(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return Array.isArray(t.nodes)?t:null}function T_(e,t){return t.kind===`key`?w_(e[t.key]):w_((Array.isArray(e.branches)?e.branches:[])[t.index])}function E_(e,t,n,r,i,a){let o=C_(n),s=T_(o,r);if(!s||i<0||i>=s.nodes.length)return null;let c={...s,nodes:xs(s.nodes,i,a)},l=r.kind===`key`?{...o,[r.key]:c}:{...o,branches:xs(Array.isArray(o.branches)?o.branches:[],r.index,c)},u={...n,config:l};return{nodes:xs(e,t,u)}}function D_(e,t){let n=S_(e.nodes);if(t.kind===`nested-node`){let e=y_(t.id),r=e?b_(e.regionKey):null;if(!e||!r)return null;let i=n.findIndex(t=>t?.id===e.containerId),a=i>=0?n[i]:null;if(!a)return null;let o=T_(C_(a),r),s=o?o.nodes.findIndex(t=>t?.id===e.nodeId):-1,c=o&&s>=0?o.nodes[s]:null;return c?{node:c,nested:!0,scopeAnchorId:a.id,container:a,regionKey:e.regionKey,regionLabel:x_(e.regionKey,a),write:e=>E_(n,i,a,r,s,e)}:null}let r=n.findIndex(e=>e?.id===t.id),i=r>=0?n[r]:null;return i?{node:i,nested:!1,scopeAnchorId:i.id,write:e=>({nodes:xs(n,r,e)})}:null}var O_=500,k_=`default`,A_=(...e)=>e.filter(e=>!!e).join(` `)||void 0,j_=new Set([`start`]),M_=new Set([`create_record`,`update_record`,`delete_record`,`get_record`,`http_request`,`connector_action`]),N_=new Set([`join_gateway`,`subflow`,`boundary_event`,`parallel`,`try_catch`]),P_=(e,t)=>e.id||`${e.source}->${e.target}#${t}`,F_=e=>typeof e==`string`&&e?e:void 0,I_=/^[A-Za-z_$][\w$]*(?:\.(?:[A-Za-z_$][\w$]*|\d+))*$/;function L_(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function R_(e){if(e==null)return``;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}var z_=class{nodes=new Map;edges=[];mocks={};seq=0;state={status:`idle`,variables:{},steps:[],frontier:[],activeNodeId:null,visitedNodeIds:[],traversedEdgeIds:[]};locale;constructor(e,t,n){for(let t of e)this.nodes.set(t.id,t);this.edges=t,this.locale=n}say(e,t){return t?W(e,this.locale,t):G(e,this.locale)}reset(e={},t={}){let n=Mh([...this.nodes.values()],this.edges,this.locale);return this.mocks=t,this.seq=0,this.state={status:n.errors.length?`error`:`idle`,variables:{...e},steps:[],frontier:n.startNodeId?[n.startNodeId]:[],activeNodeId:null,visitedNodeIds:[],traversedEdgeIds:[],error:n.errors.length?n.errors[0].message:void 0},n}get done(){return this.state.status===`done`||this.state.status===`error`}step(){let e=this.state;if(e.status===`error`||e.status===`done`||e.status===`paused`)return null;if(this.seq>=O_)return e.status=`error`,e.error=this.say(`engine.flowSim.note.stepLimit`,{max:O_}),null;let t=e.frontier.shift();if(!t)return e.status=`done`,e.activeNodeId=null,null;let n=this.nodes.get(t);if(!n)return this.record(t,`unknown`,t,`error`,{error:this.say(`engine.flowSim.note.nodeNotFound`,{id:t})});e.status=`running`,e.activeNodeId=t,e.visitedNodeIds.includes(t)||e.visitedNodeIds.push(t);let r=this.execute(n);return e.status===`running`&&e.frontier.length===0&&(e.status=`done`,e.activeNodeId=null),r}runToEnd(){let e=0;for(;this.state.status!==`done`&&this.state.status!==`error`&&this.state.status!==`paused`&&!(++e>505);)this.step();return this.state}resume(e={}){let t=this.state;if(t.status!==`paused`||!t.activeNodeId)return;let n=this.nodes.get(t.activeNodeId);if(e.screenOutputs&&n?.type===`screen`&&Object.assign(t.variables,e.screenOutputs),t.pausedReason=void 0,t.status=`running`,n?.type===`approval`)this.resumeApproval(n,e.decision);else if(n){let e=this.route(n);(e.gated||e.error)&&this.record(n.id,n.type,n.label,e.error?`error`:`ok`,{edges:e.evals,error:e.error,note:A_(this.say(`engine.flowSim.note.resumed`),e.note)})}t.status===`running`&&t.frontier.length===0&&(t.status=`done`,t.activeNodeId=null)}resumeApproval(e,t){let n=(t??``).trim(),r=this.route(e,n?{label:n,claims:e=>(e??``).trim().toLowerCase()===n.toLowerCase()}:void 0),i=r.evals.filter(e=>e.selected).map(e=>e.target);this.record(e.id,`approval`,e.label,r.error?`error`:`ok`,{edges:r.gated||r.error?r.evals:void 0,error:r.error,note:A_(n?this.say(`engine.flowSim.note.decisionTaken`,{decision:t??``,taken:i.length?i.join(`, `):this.say(`engine.flowSim.note.decisionNoneTaken`)}):this.say(`engine.flowSim.note.noDecision`),r.note)})}execute(e){let t=e.type;if(t===`end`)return this.record(e.id,t,e.label,`ok`,{note:this.say(`engine.flowSim.note.flowEnd`)});if(t===`decision`)return this.executeDecision(e);if(t===`assignment`)return this.executeAssignment(e);if(N_.has(t))return this.proceed(e,`skipped`,{note:this.say(`engine.flowSim.note.unsupported`,{type:t})});if(t===`parallel_gateway`)return this.proceed(e,`ok`,{note:this.say(`engine.flowSim.note.parallelSplit`)});if(t===`approval`)return this.state.status=`paused`,this.state.pausedReason=`approval`,this.record(e.id,t,e.label,`paused`,{note:this.say(`engine.flowSim.note.approvalReached`)});if(t===`wait`)return this.state.status=`paused`,this.state.pausedReason=`wait`,this.record(e.id,t,e.label,`paused`,{note:this.say(`engine.flowSim.note.waitReached`)});if(t===`screen`){let n=Array.isArray(e.config?.fields)?e.config.fields:[],r=e.config?.waitForInput;if(r===!0||n.length>0&&r!==!1){this.state.status=`paused`,this.state.pausedReason=`screen`;let n=Fg(e,this.locale);return this.record(e.id,t,e.label,`paused`,{note:this.say(`engine.flowSim.note.screenReached`),error:n.length?this.say(`engine.flowSim.note.screenUnevaluable`,{fields:n.map(e=>this.say(`engine.flowSim.note.screenUnevaluableField`,{name:e.name,reason:e.error.split(`
10
+ `)[0]})).join(`; `)}):void 0})}return this.proceed(e,`ok`,{note:this.say(`engine.flowSim.note.screenNoInput`)})}if(t===`loop`)return this.proceed(e,`ok`,{note:this.executeLoop(e)});if(M_.has(t)||t===`script`){let t=this.applyMock(e);return this.proceed(e,`mocked`,{wrote:t,note:this.mockNote(e)})}return this.proceed(e,`ok`,{note:j_.has(t)?void 0:this.say(`engine.flowSim.note.passThrough`,{type:t})})}proceed(e,t,n={}){let r=this.route(e);return this.record(e.id,e.type,e.label,r.error?`error`:t,{...n,edges:r.gated||r.error?r.evals:void 0,error:r.error,note:A_(n.note,r.note)})}executeDecision(e){let t=this.decisionBranch(e);if(`error`in t)return this.record(e.id,`decision`,e.label,`error`,{error:t.error});let n=this.route(e,t.selection),r=this.edges.some(t=>t.source===e.id&&t.type!==`fault`);return this.record(e.id,`decision`,e.label,n.error?`error`:`ok`,{edges:n.evals,error:n.error,note:A_(t.note,n.note,r?void 0:this.say(`engine.flowSim.note.decisionNoOutEdge`))})}decisionBranch(e){let t=e.config?.conditions;if(!Array.isArray(t)||t.length===0)return{};for(let[e,n]of t.entries()){let t=n&&typeof n==`object`?n:{},r=Ah(t.expression,this.state.variables,this.locale);if(r.kind===`fault`)return{error:`config.conditions[${e}].expression: ${r.error}`};if(!r.result)continue;let i=typeof t.label==`string`&&t.label?t.label:void 0;return i?{selection:{label:i,claims:e=>e===i},note:this.say(`engine.flowSim.note.branchMatched`,{label:i})}:{}}return{selection:{label:k_,claims:e=>e===k_},note:this.say(`engine.flowSim.note.noConditionMatched`,{label:k_})}}executeAssignment(e){let t=e.config??{},n=t.assignments,r=[];if(Array.isArray(n)){for(let e of n)if(e&&typeof e==`object`){let t=e,n=t.variable??t.name??t.key;typeof n==`string`&&n&&r.push({key:n,value:t.value,slot:!1})}}else if(n&&typeof n==`object`){let t=Sh(e.type,[`config`,`assignments`]);for(let[e,i]of Object.entries(n))r.push({key:e,value:i,slot:t})}else for(let[e,n]of Object.entries(t))r.push({key:e,value:n,slot:!1});let i={},a=[];for(let{key:t,value:n,slot:o}of r){let r;if(o&&w(n)){let a=Dh(n,this.state.variables,this.locale);if(!a.ok)return this.record(e.id,`assignment`,e.label,`error`,{wrote:Object.keys(i).length?i:void 0,error:`assignments.${t}: ${a.error}`});r=a.value}else{let e=[];r=this.interpolateValue(n,e);for(let n of e)a.push(this.say(`engine.flowSim.note.unmodelledToken`,{token:n,key:t}))}this.state.variables[t]=r,i[t]=r}return this.proceed(e,`ok`,{wrote:Object.keys(i).length?i:void 0,note:A_(Object.keys(i).length?void 0:this.say(`engine.flowSim.note.noAssignments`),a.length?this.say(`engine.flowSim.note.unmodelled`,{tokens:a.join(`, `)}):void 0)})}interpolateValue(e,t){if(typeof e==`string`)return this.interpolateString(e,t);if(Array.isArray(e))return e.map(e=>this.interpolateValue(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=this.interpolateValue(i,t);return n}return e}interpolateString(e,t){if(!e.includes(`{`))return e;let n=/^\{([^{}]+)\}$/.exec(e);if(n){let r=this.resolveToken(n[1]);return r.modelled?r.value:(t.push(e),e)}return e.replace(/\{([^{}]+)\}/g,(e,n)=>{let r=this.resolveToken(n);return r.modelled?R_(r.value):(t.push(e),e)})}resolveToken(e){let t=e.trim();if(!t)return{modelled:!0,value:void 0};if(t.startsWith(`$User.`)||!I_.test(t))return{modelled:!1};let n=this.state.variables,[r,...i]=t.split(`.`);return Object.prototype.hasOwnProperty.call(n,r)?{modelled:!0,value:L_(n[r],i)}:{modelled:!0,value:Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0}}executeLoop(e){let t=F_(e.config?.collection),n=F_(e.config?.iteratorVariable),r=this.say(`engine.flowSim.note.loopSinglePass`);if(t){let e=this.resolveRef(t);Array.isArray(e)?(r=this.say(`engine.flowSim.note.loopCollection`,{ref:t,count:e.length}),n&&e.length&&(this.state.variables[n]=e[0])):e!==void 0&&(r=this.say(`engine.flowSim.note.loopNotArray`,{ref:t}))}return r}resolveRef(e){let t=e.match(/^\{(.+)\}$/),n=(t?t[1]:e).trim();return this.state.variables[n]}applyMock(e){let t=e.config??{},n=this.mocks[e.id],r={},i=F_(t.outputVariable);return i&&(r[i]=n===void 0?{}:n,this.state.variables[i]=r[i]),Object.keys(r).length?r:void 0}mockNote(e){if(e.type===`script`){let t=F_(e.config?.function);if(t)return this.say(`engine.flowSim.note.mockedCall`,{fn:t});let n=F_(e.config?.actionType);return n&&n!==`code`?this.say(`engine.flowSim.note.retiredAction`,{action:n}):this.say(`engine.flowSim.note.retiredScript`)}return this.say(`engine.flowSim.note.mocked`,{type:e.type.replace(/_/g,` `)})}route(e,t){let n=this.state.variables,r=this.edges.map((e,t)=>({e,i:t})).filter(t=>t.e.source===e.id&&t.e.type!==`fault`),i=[],a=r;if(t){let e=r.filter(e=>t.claims(e.e.label));e.length===0&&t.label===k_&&(e=r.filter(e=>e.e.isDefault===!0)),e.length>0?a=e:i.push(this.say(`engine.flowSim.note.noBranchLabel`,{label:t.label}))}let o=[],s=[],c=!1,l=0;for(let{e,i:t}of a){if(e.condition===void 0)continue;c=!0;let r=ao(e.condition),i=Oh(e.condition,n,this.locale);if(i.kind!==`value`){let n=i.kind===`fault`?i.error:this.say(`engine.flowSim.note.evaluationFailed`);return o.push({edgeId:P_(e,t),target:e.target,condition:r,result:!1,error:n,selected:!1}),{evals:o,gated:c,error:r?`${r}: ${n}`:n}}let a=i.result&&l===0;i.result&&l++,a&&s.push({e,i:t}),o.push({edgeId:P_(e,t),target:e.target,condition:r,result:i.result,selected:a})}for(let{e,i:t}of a){if(e.condition!==void 0||!e.isDefault)continue;c=!0;let n=l===0;n&&s.push({e,i:t}),o.push({edgeId:P_(e,t),target:e.target,isDefault:!0,result:n,selected:n})}for(let{e,i:t}of a)e.condition!==void 0||e.isDefault||(s.push({e,i:t}),o.push({edgeId:P_(e,t),target:e.target,result:!0,selected:!0}));l>1&&i.push(this.say(`engine.flowSim.note.multipleMatched`)),a.length>0&&s.length===0&&i.push(this.say(`engine.flowSim.note.noEdgeTaken`));for(let{e,i:t}of s)this.traverse(e,t);return{evals:o,gated:c,note:i.length?i.join(` `):void 0}}traverse(e,t){let n=P_(e,t);this.state.traversedEdgeIds.includes(n)||this.state.traversedEdgeIds.push(n),this.nodes.has(e.target)&&this.state.frontier.push(e.target)}record(e,t,n,r,i={}){let a={seq:this.seq++,nodeId:e,type:t,label:n||e,status:r,...i};return this.state.steps.push(a),r===`error`&&this.state.status!==`paused`&&(this.state.status=`error`,this.state.error=i.error),a}};function B_({node:e,variables:t,className:n,locale:r}){let i=Pt(),a=wt(),o=J.useMemo(()=>Kg(e),[e]),s=Ta(o),c=s?a.objects:void 0,l=Dg(o.title,t),u=Dg(o.description,t),d=s?`obj:${o.objectName}:${o.mode??`create`}`:`fields:`+ba(o).map(e=>`${e.name}:${e.type??``}:${+!!e.required}:${e.visibleWhen??``}:${e.defaultValue===void 0?``:JSON.stringify(e.defaultValue)}`).join(`|`),f=!l&&!u&&!s&&ba(o).length===0;return(0,Y.jsxs)(`div`,{className:R(`overflow-hidden rounded-md border bg-background`,n),children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5 border-b bg-muted/30 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:G(`engine.screenPreview.header`,r)}),(0,Y.jsx)(`div`,{className:`max-h-[60vh] overflow-auto p-4`,children:f?(0,Y.jsx)(ye,{className:`text-sm italic`,children:G(`engine.screenPreview.empty`,r)}):(0,Y.jsxs)(Y.Fragment,{children:[l&&(0,Y.jsx)(`h3`,{className:`text-base font-semibold leading-tight`,children:l}),u&&(0,Y.jsx)(`p`,{className:R(`whitespace-pre-line text-sm text-muted-foreground`,l&&`mt-1`),children:u}),(0,Y.jsx)(V_,{spec:o,adapter:i,objects:c,locale:r},d),!s&&ba(o).length>0&&(0,Y.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,Y.jsx)(B,{size:`sm`,disabled:!0,children:G(`engine.screenPreview.submit`,r)})})]})})]})}function V_({spec:e,adapter:t,objects:n,locale:r}){let[i,a]=J.useState(()=>va(e)),o=Gg(e,i),s=Ta(e)?[]:Wg(Sa(e,i));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ea,{screen:e,values:i,onValueChange:(e,t)=>a(n=>({...n,[e]:t})),dataSource:t??void 0,objects:n,objectForm:{showSubmit:!1,showCancel:!1,noDataSourceMessage:G(`engine.screenPreview.noDataSource`,r)}}),s.length>0&&(0,Y.jsx)(`ul`,{className:`mt-3 space-y-1 text-[11px] text-muted-foreground`,children:s.map(e=>(0,Y.jsxs)(`li`,{"data-default-template":e.name,children:[W(`engine.screenPreview.defaultTemplate`,r,{field:e.label}),` `,(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono`,children:e.literal})]},e.name))}),o>0&&(0,Y.jsx)(`p`,{className:`mt-3 text-[11px] italic text-muted-foreground`,children:W(o===1?`engine.screenPreview.hiddenOne`:`engine.screenPreview.hiddenOther`,r,{count:o})})]})}function H_(e){let t=e.trim();if(t!==``){if(t===`true`)return!0;if(t===`false`)return!1;if(/^-?\d+(\.\d+)?$/.test(t))return Number(t);if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.parse(t)}catch{return e}return e}}var U_=new Set([`create_record`,`update_record`,`delete_record`,`get_record`,`http_request`,`connector_action`,`script`]);function W_(e){let t=[];for(let n of e){if(!U_.has(n.type))continue;let e=n.config??{},r=[];typeof e.outputVariable==`string`&&e.outputVariable&&r.push(e.outputVariable),t.push({id:n.id,label:n.label||n.id,type:n.type,outputs:r})}return t}var G_={ok:`bg-emerald-100 text-emerald-700`,mocked:`bg-violet-100 text-violet-700`,paused:`bg-amber-100 text-amber-700`,skipped:`bg-zinc-100 text-zinc-600`,error:`bg-rose-100 text-rose-700`};function K_({nodes:e,edges:t,variables:n,locale:r,onRunStateChange:i}){let a=J.useRef(null),[o,s]=J.useState(null),[c,l]=J.useState(null),u=J.useMemo(()=>n.filter(e=>e.isInput),[n]),d=J.useMemo(()=>W_(e),[e]),[f,p]=J.useState({}),[m,h]=J.useState([]),[g,_]=J.useState({}),v=J.useCallback(()=>{let e=a.current;if(!e)return;let t=e.state;s({...t,steps:[...t.steps],variables:{...t.variables},frontier:[...t.frontier],visitedNodeIds:[...t.visitedNodeIds],traversedEdgeIds:[...t.traversedEdgeIds]}),i?.({activeNodeId:t.activeNodeId,visitedNodeIds:[...t.visitedNodeIds],traversedEdgeIds:[...t.traversedEdgeIds]})},[i]),y=J.useCallback(()=>{let e={};for(let t of u){let n=f[t.name],r=n==null?void 0:H_(n);e[t.name]=r===void 0?t.defaultValue:r}for(let t of m){let n=t.k.trim();n&&(e[n]=H_(t.v))}return e},[u,f,m]),b=J.useCallback(()=>{let e={};for(let[t,n]of Object.entries(g))n!=null&&n.trim()!==``&&(e[t]=H_(n));return e},[g]),x=J.useCallback(()=>{let n=new z_(e,t,r);a.current=n,l(n.reset(y(),b())),v()},[e,t,y,b,v,r]),S=J.useCallback(()=>(a.current||x(),a.current),[x]),C=()=>{let e=a.current;if(e&&e.state.status===`paused`){if(e.state.pausedReason===`approval`){v();return}e.resume()}else x(),e=a.current;e.runToEnd(),v()},w=()=>{S().step(),v()},T=()=>E(),E=e=>{let t=S();t.resume(e?{decision:e}:{}),t.runToEnd(),v()},D=()=>{a.current=null,s(null),l(null),i?.(null)},O=o?.status??`idle`,k=(c?.errors.length??0)>0,A=J.useMemo(()=>{if(o?.status!==`paused`||o.pausedReason!==`screen`||!o.activeNodeId)return null;let t=e.find(e=>e.id===o.activeNodeId);return t?{node:t,variables:o.variables}:null},[o,e]),j=J.useMemo(()=>{if(o?.status!==`paused`||o.pausedReason!==`approval`||!o.activeNodeId)return null;let n=e.find(e=>e.id===o.activeNodeId);return n?{node:n,decisions:[...new Set(t.filter(e=>e.source===n.id&&typeof e.label==`string`&&e.label.trim()).map(e=>e.label.trim()))]}:null},[o,e,t]);return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b bg-muted/30 px-3 py-2`,children:[(0,Y.jsxs)(B,{size:`sm`,className:`h-7 gap-1 px-2`,onClick:C,disabled:k,children:[(0,Y.jsx)(pi,{className:`h-3.5 w-3.5`}),` `,G(`engine.flowSim.run`,r)]}),(0,Y.jsxs)(B,{size:`sm`,variant:`outline`,className:`h-7 gap-1 px-2`,onClick:w,disabled:k||O===`done`||O===`error`,children:[(0,Y.jsx)(zi,{className:`h-3.5 w-3.5`}),` `,G(`engine.flowSim.step`,r)]}),O===`paused`&&(j&&j.decisions.length>0?(0,Y.jsx)(`div`,{className:`flex items-center gap-1`,children:j.decisions.map(e=>(0,Y.jsxs)(B,{size:`sm`,variant:`outline`,className:`h-7 gap-1 px-2 capitalize`,onClick:()=>E(e),title:W(`engine.flowSim.resumeBranch`,r,{branch:e}),children:[(0,Y.jsx)(Pn,{className:`h-3.5 w-3.5`}),` `,e]},e))}):(0,Y.jsxs)(B,{size:`sm`,variant:`outline`,className:`h-7 gap-1 px-2`,onClick:T,children:[(0,Y.jsx)(Pn,{className:`h-3.5 w-3.5`}),` `,G(`engine.flowSim.continue`,r)]})),(0,Y.jsxs)(B,{size:`sm`,variant:`ghost`,className:`h-7 gap-1 px-2 text-muted-foreground`,onClick:D,children:[(0,Y.jsx)(Ci,{className:`h-3.5 w-3.5`}),` `,G(`engine.flowSim.reset`,r)]}),(0,Y.jsx)(`span`,{className:R(`ml-auto rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase`,G_[O===`idle`||O===`running`?`ok`:O]??`bg-muted`),children:G(`engine.flowSim.status.${O}`,r)})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-auto p-3`,children:[c&&(c.errors.length>0||c.warnings.length>0)&&(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[c.errors.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 rounded border border-rose-200 bg-rose-50 px-2 py-1 text-rose-700`,children:[(0,Y.jsx)(Rn,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{children:e.message})]},`e${t}`)),c.warnings.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 rounded border border-amber-200 bg-amber-50 px-2 py-1 text-amber-700`,children:[(0,Y.jsx)(Ji,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{children:e.message})]},`w${t}`))]}),A&&(0,Y.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:G(`engine.flowSim.screen`,r)}),(0,Y.jsx)(B_,{node:A.node,variables:A.variables,locale:r})]}),u.length>0&&(0,Y.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:G(`engine.flowSim.inputs`,r)}),u.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(L,{className:`w-24 shrink-0 truncate font-mono text-[11px]`,title:e.name,children:e.name}),(0,Y.jsx)(z,{value:f[e.name]??(e.defaultValue==null?``:String(e.defaultValue)),onChange:t=>p(n=>({...n,[e.name]:t.target.value})),placeholder:e.type??G(`engine.flowSim.valuePlaceholder`,r),className:`h-7 flex-1 text-xs`})]},e.name))]}),(0,Y.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:G(`engine.flowSim.setVariables`,r)}),(0,Y.jsxs)(`button`,{type:`button`,className:`ml-auto inline-flex items-center gap-0.5 rounded border px-1.5 py-0.5 text-[10px] hover:bg-muted/50`,onClick:()=>h(e=>[...e,{k:``,v:``}]),children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),` `,G(`engine.flowSim.add`,r)]})]}),m.length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.flowSim.setVariablesHint`,r)}):m.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(z,{value:e.k,onChange:e=>h(n=>n.map((n,r)=>r===t?{...n,k:e.target.value}:n)),placeholder:G(`engine.flowSim.namePlaceholder`,r),className:`h-7 w-24 shrink-0 font-mono text-[11px]`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`=`}),(0,Y.jsx)(z,{value:e.v,onChange:e=>h(n=>n.map((n,r)=>r===t?{...n,v:e.target.value}:n)),placeholder:G(`engine.flowSim.valuePlaceholder`,r),className:`h-7 flex-1 text-xs`}),(0,Y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded p-1 text-muted-foreground hover:bg-muted/50 hover:text-rose-600`,onClick:()=>h(e=>e.filter((e,n)=>n!==t)),"aria-label":G(`engine.flowSim.removeVariable`,r),children:(0,Y.jsx)(Ki,{className:`h-3 w-3`})})]},t))]}),d.length>0&&(0,Y.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:G(`engine.flowSim.mockOutputs`,r)}),d.map(e=>(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Y.jsxs)(L,{className:`flex items-baseline gap-1.5 text-[11px]`,title:e.id,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),(0,Y.jsx)(`span`,{className:`text-[9px] uppercase text-muted-foreground`,children:e.type.replace(/_/g,` `)}),e.outputs.length>0&&(0,Y.jsxs)(`span`,{className:`truncate font-mono text-[10px] text-violet-600`,children:[`→ `,e.outputs.join(`, `)]})]}),(0,Y.jsx)(z,{value:g[e.id]??``,onChange:t=>_(n=>({...n,[e.id]:t.target.value})),placeholder:e.type===`script`&&e.outputs.length?`{ "${e.outputs[0]}": … }`:G(`engine.flowSim.mockPlaceholder`,r),className:`h-7 w-full font-mono text-[11px]`})]},e.id))]}),o&&(0,Y.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:G(`engine.flowSim.variables`,r)}),Object.keys(o.variables).length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.flowSim.noVars`,r)}):(0,Y.jsx)(`ul`,{className:`space-y-1`,children:Object.entries(o.variables).map(([e,t])=>(0,Y.jsxs)(`li`,{className:`flex items-baseline gap-1.5 rounded border bg-background px-1.5 py-1`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[11px]`,children:e}),(0,Y.jsxs)(`span`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:[`= `,typeof t==`object`?JSON.stringify(t):String(t)]})]},e))})]}),o&&o.steps.length>0&&(0,Y.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:G(`engine.flowSim.timeline`,r)}),(0,Y.jsx)(`ol`,{className:`space-y-1`,children:o.steps.map(e=>(0,Y.jsxs)(`li`,{className:`rounded border bg-background p-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.seq+1}),(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),(0,Y.jsx)(`span`,{className:`text-[10px] uppercase text-muted-foreground`,children:e.type}),(0,Y.jsx)(`span`,{className:R(`ml-auto rounded px-1 py-0.5 text-[9px] font-semibold uppercase`,G_[e.status]),children:G(`engine.flowSim.stepStatus.${e.status}`,r)})]}),e.note&&(0,Y.jsx)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:e.note}),e.error&&(0,Y.jsx)(`div`,{className:`mt-0.5 text-[10px] text-rose-600`,children:e.error}),e.wrote&&(0,Y.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[10px] text-violet-600`,children:[`→ `,Object.keys(e.wrote).join(`, `)]}),e.edges&&e.edges.length>0&&(0,Y.jsx)(`ul`,{className:`mt-0.5 space-y-0.5`,children:e.edges.map(e=>(0,Y.jsxs)(`li`,{className:`space-y-0.5`,children:[(0,Y.jsxs)(`div`,{className:R(`flex items-center gap-1 font-mono text-[10px]`,e.selected?`text-sky-700`:`text-muted-foreground`),children:[(0,Y.jsx)(`span`,{children:e.selected?`▶`:`·`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.isDefault?`else`:e.condition??`→ ${e.target}`}),(0,Y.jsx)(`span`,{className:R(`ml-auto`,e.error&&`text-rose-600`),children:e.error?G(`engine.flowSim.edge.error`,r):e.result?`true`:`false`})]}),e.error&&(0,Y.jsx)(`div`,{className:`pl-3 text-[10px] text-rose-600`,children:e.error})]},e.edgeId))})]},e.seq))})]}),!o&&!k&&(0,Y.jsx)(`p`,{className:`italic text-muted-foreground`,children:G(`engine.flowSim.idleHint`,r)})]})]})}function q_(e){if(!e)return;if(typeof e==`string`)return e||void 0;let t=e.message;return typeof t==`string`&&t?t:void 0}function J_(e){let t=[],n=[];for(let r of e){let e={step:r,children:[]};if(r.parentNodeId==null)n.length=0,t.push(e);else{for(;n.length>0&&n[n.length-1].step.nodeId!==r.parentNodeId;)n.pop();n.length>0?n[n.length-1].children.push(e):t.push(e)}n.push(e)}return t}function Y_(e){return e.branch==null?{branch:e.iteration,legacy:!0}:{branch:e.branch,iteration:e.iteration,legacy:!1}}function X_(e,t){let{regionKind:n,iteration:r}=e;if(!n)return null;switch(n){case`loop-body`:return r==null?G(`engine.flowRuns.iteration`,t):W(`engine.flowRuns.iterationN`,t,{n:r+1});case`parallel-branch`:{let n=Y_(e);return n.branch==null?G(`engine.flowRuns.branch`,t):n.iteration==null?W(`engine.flowRuns.branchN`,t,{n:n.branch+1}):W(`engine.flowRuns.branchNIterationM`,t,{n:n.branch+1,m:n.iteration+1})}case`try`:return G(`engine.flowRuns.try`,t);case`catch`:return G(`engine.flowRuns.catch`,t);default:return r==null?n:`${n} ${r+1}`}}function Z_(e){if(e.regionKind===`parallel-branch`){let{branch:t,iteration:n,legacy:r}=Y_(e);return`parallel-branch#${r?`legacy:`:``}branch=${t??``}#iteration=${n??``}`}return`${e.regionKind??``}#${e.iteration??``}`}function Q_(e,t){let n=[],r;for(let i of e){let e=Z_(i.step);n.length===0||e!==r?(n.push({label:X_(i.step,t),items:[i]}),r=e):n[n.length-1].items.push(i)}return n}async function $_(e,t){try{let n=await fetch(`${dd()}/automation/${encodeURIComponent(e)}/runs?limit=25`,{credentials:`include`,headers:{"Content-Type":`application/json`},signal:t});if(!n.ok)return null;let r=await n.json(),i=r?.data?.runs??r?.runs;return Array.isArray(i)?i:null}catch{return null}}var ev={completed:{icon:zn,cls:`text-emerald-600 dark:text-emerald-400`,labelKey:`engine.flowRuns.status.completed`},failed:{icon:Rn,cls:`text-rose-600 dark:text-rose-400`,labelKey:`engine.flowRuns.status.failed`},paused:{icon:Vn,cls:`text-amber-600 dark:text-amber-400`,labelKey:`engine.flowRuns.status.paused`},running:{icon:H,cls:`text-sky-600 dark:text-sky-400`,labelKey:`engine.flowRuns.status.running`},cancelled:{icon:Pi,cls:`text-muted-foreground`,labelKey:`engine.flowRuns.status.cancelled`}};function tv(e,t){let n=ev[e];return n?{icon:n.icon,cls:n.cls,label:G(n.labelKey,t)}:{icon:qn,cls:`text-muted-foreground`,label:e}}function nv(e,t){if(!e)return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleString(t)}function rv(e){return e==null?null:e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/6e4)}m`}function iv({step:e,depth:t=0}){let n=e.status===`success`?`text-emerald-600 dark:text-emerald-400`:e.status===`failure`?`text-rose-600 dark:text-rose-400`:`text-muted-foreground`,r=q_(e.error),i=Array.isArray(e.warnings)?e.warnings.filter(e=>typeof e==`string`&&e.length>0):[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`li`,{className:`flex items-baseline gap-1.5 py-0.5`,style:t?{paddingLeft:t*12}:void 0,children:[(0,Y.jsx)(`span`,{className:R(`shrink-0 text-[9px] font-semibold uppercase`,n),children:e.status}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-[10px]`,title:e.nodeId,children:e.nodeId}),e.nodeType&&(0,Y.jsx)(`span`,{className:`shrink-0 text-[9px] uppercase text-muted-foreground`,children:e.nodeType}),i.length>0&&(0,Y.jsx)(Ji,{"aria-hidden":!0,className:`h-2.5 w-2.5 shrink-0 text-amber-600 dark:text-amber-400`}),rv(e.durationMs)&&(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:rv(e.durationMs)}),r&&(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-[9px] text-rose-600`,title:r,children:r})]}),i.map((e,n)=>(0,Y.jsxs)(`li`,{className:`flex items-baseline gap-1 py-0.5 text-amber-700 dark:text-amber-400`,style:{paddingLeft:(t+1)*12},children:[(0,Y.jsx)(Ji,{"aria-hidden":!0,className:`h-2.5 w-2.5 shrink-0 self-center`}),(0,Y.jsx)(`span`,{className:`min-w-0 break-words text-[9px]`,title:e,children:e})]},n))]})}function av({label:e,depth:t}){return(0,Y.jsxs)(`li`,{className:`flex items-center gap-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground/80`,style:{paddingLeft:t*12},children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/50`,children:`↳`}),e]})}function ov({node:e,depth:t,locale:n}){let r=e.children.length>0?Q_(e.children,n):[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(iv,{step:e.step,depth:t}),r.map((e,r)=>(0,Y.jsxs)(J.Fragment,{children:[e.label!=null&&(0,Y.jsx)(av,{label:e.label,depth:t+1}),e.items.map((r,i)=>(0,Y.jsx)(ov,{node:r,depth:e.label==null?t+1:t+2,locale:n},`${r.step.nodeId}#${i}`))]},r))]})}function sv({run:e,locale:t}){let n=nn(),[r,i]=J.useState(!1),a=tv(e.status,t),o=a.icon,s=Array.isArray(e.steps)?e.steps:[],c=q_(e.error);return(0,Y.jsxs)(`li`,{className:`rounded border bg-background`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-1.5 p-1.5 text-left`,"aria-expanded":r,children:[r?(0,Y.jsx)(Nn,{className:`h-3 w-3 shrink-0 text-muted-foreground`}):(0,Y.jsx)(Pn,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),(0,Y.jsx)(o,{className:R(`h-3.5 w-3.5 shrink-0`,a.cls,e.status===`running`&&`animate-spin`)}),(0,Y.jsx)(`span`,{className:R(`shrink-0 text-[10px] font-semibold`,a.cls),children:a.label}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-[10px] text-muted-foreground`,title:e.id,children:nv(e.startedAt,n)}),rv(e.durationMs)&&(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground`,children:rv(e.durationMs)})]}),r&&(0,Y.jsxs)(`div`,{className:`border-t px-2 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`pb-1 font-mono text-[9px] text-muted-foreground`,title:e.id,children:[W(`engine.flowRuns.runId`,t,{id:e.id}),e.trigger?.type&&` · ${W(`engine.flowRuns.trigger`,t,{type:e.trigger.type})}`]}),c&&(0,Y.jsx)(`div`,{className:`pb-1 text-[10px] text-rose-600`,children:c}),s.length===0?(0,Y.jsx)(ye,{className:`text-[10px] italic`,children:G(`engine.flowRuns.noSteps`,t)}):(0,Y.jsx)(`ul`,{children:J_(s).map((e,n)=>(0,Y.jsx)(ov,{node:e,depth:0,locale:t},`${e.step.nodeId}#${n}`))})]})]})}function cv({flowName:e,locale:t}){let[n,r]=J.useState([]),[i,a]=J.useState(`loading`),[o,s]=J.useState(0);return J.useEffect(()=>{let t=new AbortController,n=!0;return a(`loading`),(async()=>{let i=await $_(e,t.signal);n&&(i===null?a(`unavailable`):(r(i),a(`ready`)))})(),()=>{n=!1,t.abort()}},[e,o]),(0,Y.jsxs)(`div`,{className:`flex h-full flex-col p-3 text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 pb-2 font-medium text-muted-foreground`,children:[(0,Y.jsx)(qn,{className:`h-3 w-3`}),` `,G(`engine.flowRuns.title`,t),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>s(e=>e+1),title:G(`engine.flowRuns.refresh`,t),"aria-label":G(`engine.flowRuns.refresh`,t),className:`ml-auto rounded p-0.5 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,children:(0,Y.jsx)(vi,{className:R(`h-3 w-3`,i===`loading`&&`animate-spin`)})})]}),i===`unavailable`?(0,Y.jsx)(`div`,{className:`italic text-muted-foreground`,children:G(`engine.flowRuns.unavailable`,t)}):i===`ready`&&n.length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.flowRuns.empty`,t)}):(0,Y.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto`,children:n.map(e=>(0,Y.jsx)(sv,{run:e,locale:t},e.id))})]})}function lv(e){return e.target.kind===`node`?e.target.nodeId:e.target.kind===`edge`?`${e.target.source} → ${e.target.target}`:`flow`}function uv({problems:e,selectedKey:t,onSelectProblem:n,locale:r}){let i=e.filter(e=>e.level===`error`).length,a=e.length-i;return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2 font-medium text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:G(`engine.flowProblems.title`,r)}),i>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive`,children:[(0,Y.jsx)(Rn,{className:`h-3 w-3`}),` `,i]}),a>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-amber-600 dark:text-amber-400`,children:[(0,Y.jsx)(Ji,{className:`h-3 w-3`}),` `,a]})]}),e.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-1.5 p-4 text-center text-muted-foreground`,children:[(0,Y.jsx)(zn,{className:`h-5 w-5 text-emerald-500`}),(0,Y.jsx)(`span`,{children:G(`engine.flowProblems.empty`,r)})]}):(0,Y.jsx)(`ul`,{className:`flex-1 overflow-auto p-1.5`,children:e.map(e=>{let i=e.target.kind===`edge`,a=e.target.kind===`flow`,o=e.target.kind===`node`?`node:${e.target.nodeId}`:e.target.kind===`edge`?e.target.edgeKey:null,s=!!o&&o===t,c=e.level===`error`?Rn:Ji,l=i?Er:Bn;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>n(e),className:R(`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors`,a?`cursor-default`:`cursor-pointer hover:bg-accent`,s&&`bg-accent ring-1 ring-primary/40`),children:[(0,Y.jsx)(c,{className:R(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`error`?`text-destructive`:`text-amber-500`)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block leading-snug text-foreground`,children:e.message}),(0,Y.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(l,{className:`h-2.5 w-2.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate font-mono`,children:lv(e)}),e.source===`server`&&(0,Y.jsxs)(`span`,{className:`uppercase tracking-wide`,children:[`· `,G(`engine.flowProblems.sourceSchema`,r)]}),e.source===`expression`&&(0,Y.jsxs)(`span`,{className:`uppercase tracking-wide`,children:[`· `,G(`engine.flowProblems.sourceExpression`,r)]})]})]})]})},e.id)})})]})}var dv=[`connectorConfig`,`input`],fv=dv.join(`.`),pv=fv;function mv(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function hv(e,t,n){if(!Array.isArray(e)||!t||!n)return;let r=e.find(e=>mv(e)&&e.name===t);if(!r||!Array.isArray(r.actions))return;let i=r.actions.find(e=>mv(e)&&e.key===n)?.inputSchema;return mv(i)?i:void 0}function gv(e){let t={...e,id:`${fv}.${e.id}`,path:[...dv,...e.path.slice(1)]};return e.showWhen&&(t.showWhen={...e.showWhen,field:`${fv}.${e.showWhen.field}`}),t}function _v(e){let t=Go(e);if(!t||t.length===0)return null;let n=t.map(gv),r=[];for(let e of n){let t=e.path[dv.length];t&&!r.includes(t)&&r.push(t)}return{fields:n,declaredKeys:r,open:(mv(e)?e.additionalProperties:void 0)!==!1}}function vv(e,t){if(!mv(e))return{};let n={};for(let[r,i]of Object.entries(e))t.includes(r)||(n[r]=i);return n}function yv(e,t,n){let r=mv(e)?e:{},i={};for(let[e,a]of Object.entries(r))n.includes(e)?i[e]=a:Object.prototype.hasOwnProperty.call(t,e)&&(i[e]=t[e]);for(let[e,n]of Object.entries(t))Object.prototype.hasOwnProperty.call(i,e)||(i[e]=n);return Object.keys(i).length?i:void 0}function bv(e,t,n){if(!t||Array.isArray(n))return e;let r=e.findIndex(e=>e.id===pv);if(r===-1)return e;let i=e[r],a=Object.keys(vv(n,t.declaredKeys)).length>0,o=t.open||a;return[...e.slice(0,r),...t.fields,...o?[{...i,omitKeys:t.declaredKeys}]:[],...e.slice(r+1)]}function xv(e){let[t,n]=J.useState([]);return J.useEffect(()=>{if(!e)return;let t=!1,r=new AbortController;return(async()=>{try{let e=await fetch(`${dd()}/automation/connectors`,{credentials:`include`,headers:{Accept:`application/json`},signal:r.signal});if(!e.ok)return;let i=await e.json(),a=i?.data?.connectors??i?.connectors??[];!t&&Array.isArray(a)&&n(a)}catch{}})(),()=>{t=!0,r.abort()}},[e]),t}function Sv({draft:e,editing:t,selection:n,onSelectionChange:r,onPatch:i,locale:a,diagnostics:o}){let s=e,c=J.useMemo(()=>Array.isArray(s.nodes)?s.nodes:[],[s.nodes]),l=J.useMemo(()=>Array.isArray(s.edges)?s.edges:[],[s.edges]),u=Array.isArray(s.variables)?s.variables:[],d=!!(t&&r),f=d&&!!i,p=n&&n.kind===`node`?n.id:null,m=n&&n.kind===`edge`?n.id:null,h=J.useMemo(()=>n&&n.kind===`nested-node`?y_(n.id):null,[n]),[g,_]=J.useState(!1),[v,y]=J.useState(!1),[b,x]=J.useState(!1),[S,C]=J.useState(!1),[w,T]=J.useState(null),E=xv(ig(s)),D=J.useMemo(()=>o_({nodes:c,edges:l,serverDiagnostics:o,variables:u,locale:a,connectors:E}),[c,l,o,s.variables,a,E]),O=D.filter(e=>e.level===`error`).length,{invalidNodeIds:k,invalidEdges:A}=J.useMemo(()=>l_(D),[D]),[j,M]=J.useState(null),N=p?`node:${p}`:m??null,P=J.useCallback(e=>{if(e.target.kind===`node`){let{nodeId:t}=e.target,n=c.find(e=>e.id===t);r?.({kind:`node`,id:t,label:n?.label||t})}else e.target.kind===`edge`&&r?.({kind:`edge`,id:e.target.edgeKey,label:`${e.target.source} → ${e.target.target}`});M(t=>({target:e.target,nonce:(t?.nonce??0)+1}))},[c,r]),ee=J.useCallback(()=>{if(!f)return;let e={id:ol(`node`,c.map(e=>e.id).filter(Boolean)),type:`start`,label:fh(`start`,a)};i({nodes:os(c,e)}),r?.({kind:`node`,id:e.id,label:e.label||e.id})},[f,c,i,r,a]),F=typeof s.name==`string`&&s.name?s.name:``,te=String(s.type??`autolaunched`),ne=String(s.status??(s.active?`active`:`draft`)),re=String(s.runAs??`user`),ie=s.version==null?void 0:String(s.version),ae=s.errorHandling?.strategy;return c.length===0?(0,Y.jsx)(X,{hint:`flow${d?` · design`:``}`,children:f?(0,Y.jsx)(`div`,{className:`p-3`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-2 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:ee,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),G(`engine.inspector.add.node`,a)]})}):(0,Y.jsx)(Pf,{children:G(`engine.flowPreview.emptyHint`,a)})}):(0,Y.jsx)(X,{hint:`flow · ${c.length} node${c.length===1?``:`s`}`,children:(0,Y.jsx)(Z,{fallbackHint:G(`engine.flowPreview.malformed`,a),children:(0,Y.jsxs)(`div`,{className:`grid gap-0 h-full min-h-[440px] `+(g||v||b||S?`lg:grid-cols-[1fr_240px]`:`grid-cols-1`),children:[(0,Y.jsxs)(`div`,{className:`flex flex-col min-w-0 min-h-0`,children:[(0,Y.jsxs)(`div`,{className:`rounded-none border-b bg-muted/30 px-3 py-2 text-xs flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,Y.jsx)(Cv,{icon:ra,label:G(`engine.flowPreview.pill.trigger`,a),value:Xo(`type`,te,a)}),(0,Y.jsx)(Cv,{icon:Bn,label:G(`engine.flowPreview.pill.status`,a),value:Xo(`status`,ne,a),tone:ne===`active`?`green`:ne===`draft`?`gray`:`amber`}),(0,Y.jsx)(Cv,{icon:Oi,label:G(`engine.flowPreview.pill.runAs`,a),value:Xo(`runAs`,re,a)}),ie&&(0,Y.jsx)(Cv,{label:`v`,value:ie}),ae&&(0,Y.jsx)(Cv,{icon:Er,label:G(`engine.flowPreview.pill.onError`,a),value:Xo(`onError`,ae,a)}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[!g&&!b&&!S&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>!e),className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-[11px] font-medium transition-colors `+(v?`border-violet-500 bg-violet-50 text-violet-700`:`border-border text-muted-foreground hover:bg-muted/50 hover:text-foreground`),title:G(v?`engine.flowPreview.hideVars`:`engine.flowPreview.showVars`,a),children:[(0,Y.jsx)(ci,{className:`h-3 w-3`}),` `,G(`engine.flowPreview.variables`,a)]}),F&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{x(e=>!e),_(!1),C(!1)},className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-[11px] font-medium transition-colors `+(b?`border-emerald-500 bg-emerald-50 text-emerald-700`:`border-border text-muted-foreground hover:bg-muted/50 hover:text-foreground`),title:G(`engine.flowPreview.runsTitle`,a),children:[(0,Y.jsx)(Si,{className:`h-3 w-3`}),` `,G(`engine.flowPreview.runs`,a)]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{C(e=>!e),_(!1),x(!1)},className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-[11px] font-medium transition-colors `+(S?`border-rose-500 bg-rose-50 text-rose-700`:`border-border text-muted-foreground hover:bg-muted/50 hover:text-foreground`),title:G(`engine.flowPreview.problemsTitle`,a),children:[(0,Y.jsx)(Rn,{className:`h-3 w-3`}),` `,G(`engine.flowPreview.problems`,a),D.length>0&&(0,Y.jsx)(`span`,{className:`ml-0.5 inline-flex min-w-[16px] items-center justify-center rounded-full px-1 text-[10px] font-semibold `+(O>0?`bg-destructive/15 text-destructive`:`bg-amber-500/15 text-amber-600`),children:D.length})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{_(e=>!e),x(!1),C(!1)},className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-[11px] font-medium transition-colors `+(g?`border-sky-500 bg-sky-50 text-sky-700`:`border-border text-muted-foreground hover:bg-muted/50 hover:text-foreground`),children:[(0,Y.jsx)(Sn,{className:`h-3 w-3`}),` `,G(`engine.flowPreview.debug`,a)]})]})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,Y.jsx)(p_,{nodes:c,edges:l,editable:f,designMode:d,selectedId:p,selectedEdgeId:m,locale:a,activeNodeId:w?.activeNodeId??null,visitedNodeIds:w?.visitedNodeIds,traversedEdgeIds:w?.traversedEdgeIds,invalidNodeIds:k,invalidEdges:A,onRevealProblem:P,problems:D,revealSignal:j,onSelect:e=>e?r?.({kind:`node`,id:e.id,label:e.label||e.id}):r?.(null),onSelectEdge:(e,t)=>e?r?.({kind:`edge`,id:t,label:`${e.source} → ${e.target}`}):r?.(null),selectedNestedPath:h,onSelectNested:(e,t)=>e?r?.({kind:h_,id:v_(e),label:t?.label||e.nodeId}):r?.(null),onPatch:i})})]}),S?(0,Y.jsx)(`div`,{className:`border-l bg-muted/20`,children:(0,Y.jsx)(uv,{problems:D,selectedKey:N,onSelectProblem:P,locale:a})}):g?(0,Y.jsx)(`div`,{className:`border-l bg-muted/20`,children:(0,Y.jsx)(K_,{nodes:c,edges:l,variables:u,locale:a,onRunStateChange:T})}):b&&F?(0,Y.jsx)(`div`,{className:`border-l bg-muted/20`,children:(0,Y.jsx)(cv,{flowName:F,locale:a})}):v?(0,Y.jsxs)(`div`,{className:`border-l bg-muted/20 p-3 text-xs space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground`,children:[(0,Y.jsx)($i,{className:`h-3 w-3`}),` `,G(`engine.flowPreview.variables`,a)]}),u.length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.flowPreview.noVars`,a)}):(0,Y.jsx)(`ul`,{className:`space-y-1.5`,children:u.map((e,t)=>(0,Y.jsxs)(`li`,{className:`rounded border bg-background p-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-1 flex-wrap`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.name}),e.type&&(0,Y.jsx)(`span`,{className:`text-[10px] uppercase text-muted-foreground`,children:e.type}),e.isInput&&(0,Y.jsx)(`span`,{className:`text-[9px] font-semibold uppercase px-1 rounded bg-sky-100 text-sky-700`,children:G(`engine.flowPreview.varIn`,a)}),e.isOutput&&(0,Y.jsx)(`span`,{className:`text-[9px] font-semibold uppercase px-1 rounded bg-emerald-100 text-emerald-700`,children:G(`engine.flowPreview.varOut`,a)})]}),e.defaultValue!==void 0&&(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground font-mono truncate`,children:[`= `,String(e.defaultValue)]})]},e.name||t))})]}):null]})})})}function Cv({icon:e,label:t,value:n,tone:r=`gray`}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e&&(0,Y.jsx)(e,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[t,`:`]}),(0,Y.jsx)(`span`,{className:`font-medium ${r===`green`?`text-emerald-700`:r===`amber`?`text-amber-700`:`text-foreground`}`,children:n})]})}function wv({agentName:e,locale:t}){return r()?(0,Y.jsxs)(a,{to:`/ai/${encodeURIComponent(Fa(e))}?new=1`,target:`_blank`,rel:`noreferrer`,className:`text-xs inline-flex items-center gap-1 text-muted-foreground hover:text-foreground`,title:G(`engine.agentPreview.tryInChatTitle`,t),children:[G(`engine.agentPreview.tryInChat`,t),` `,(0,Y.jsx)(cr,{className:`h-3 w-3`})]}):null}function Tv({name:e,draft:t,locale:n}){let r=t,i=String(r.name??e??``),a=String(r.label??i),o=String(r.role??``),s=r.avatar||void 0,c=String(r.instructions??``),l=r.active!==!1,u=r.model??{},d=Array.isArray(r.skills)?r.skills:[],f=r.planning,p=r.memory,m=r.guardrails,h=Array.isArray(r.permissions)?r.permissions:[];return!i&&!c&&d.length===0?(0,Y.jsx)(X,{hint:`agent`,children:(0,Y.jsx)(Pf,{children:G(`engine.agentPreview.empty`,n)})}):(0,Y.jsx)(X,{hint:`agent`,toolbar:i&&(0,Y.jsx)(wv,{agentName:i,locale:n}),children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`grid lg:grid-cols-[1fr_240px] gap-0`,children:[(0,Y.jsxs)(`div`,{className:`p-3 space-y-3 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`rounded border bg-muted/30 p-3 flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-background border flex items-center justify-center shrink-0 overflow-hidden`,children:s?(0,Y.jsx)(`img`,{src:s,alt:``,className:`h-full w-full object-cover`}):(0,Y.jsx)(_n,{className:`h-5 w-5 text-muted-foreground`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate`,children:a}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:i})]}),o&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:o}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]`,children:[(0,Y.jsx)(Mv,{icon:l?ur:lr,label:G(l?`engine.agentPreview.active`:`engine.agentPreview.disabled`,n),tone:l?`green`:`gray`}),u.provider&&(0,Y.jsx)(Mv,{icon:Fi,label:`${u.provider}${u.model?` · ${u.model}`:``}`,mono:!0}),u.temperature!=null&&(0,Y.jsx)(Mv,{icon:Tr,label:W(`engine.agentPreview.temperature`,n,{value:String(u.temperature)})}),u.maxTokens!=null&&(0,Y.jsx)(Mv,{label:W(`engine.agentPreview.maxTokens`,n,{count:String(u.maxTokens)})})]})]})]}),(0,Y.jsx)(Ev,{title:G(`engine.agentPreview.instructions`,n),icon:Ei,children:c?(0,Y.jsx)(`pre`,{className:`m-0 rounded border bg-background p-2.5 text-xs whitespace-pre-wrap font-mono max-h-[40vh] overflow-auto`,children:c}):(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.agentPreview.noInstructions`,n)})}),(0,Y.jsx)(Ev,{title:G(`engine.agentPreview.capabilities`,n),icon:Fi,children:(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(Ov,{label:G(`engine.agentPreview.skills`,n),emptyHint:G(`engine.agentPreview.noSkills`,n),items:d.map(e=>({key:e,label:e})),icon:Fi,tone:`violet`,mono:!0}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:G(`engine.agentPreview.toolsNote`,n)})]})})]}),(0,Y.jsxs)(`div`,{className:`border-l bg-muted/20 p-3 text-xs space-y-3`,children:[f&&Object.keys(f).length>0&&(0,Y.jsx)(kv,{icon:xn,title:G(`engine.agentPreview.planning`,n),children:(0,Y.jsx)(Av,{data:f,keys:[`maxIterations`],locale:n})}),p&&Object.keys(p).length>0&&(0,Y.jsx)(kv,{icon:sn,title:G(`engine.agentPreview.memory`,n),children:(0,Y.jsx)(Av,{data:{"short.maxMessages":p.shortTerm?.maxMessages,"long.enabled":p.longTerm?.enabled,"long.store":p.longTerm?.store},keys:[`short.maxMessages`,`long.enabled`,`long.store`],locale:n})}),m&&Object.keys(m).length>0&&(0,Y.jsx)(kv,{icon:Mi,title:G(`engine.agentPreview.guardrails`,n),children:(0,Y.jsx)(Av,{data:m,keys:Object.keys(m).slice(0,6),locale:n})}),h.length>0&&(0,Y.jsx)(kv,{icon:Kr,title:G(`engine.agentPreview.permissions`,n),children:(0,Y.jsx)(`ul`,{className:`space-y-0.5`,children:h.map(e=>(0,Y.jsx)(`li`,{className:`font-mono`,children:e},e))})}),!f&&!p&&!m&&h.length===0&&(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.agentPreview.defaults`,n)})]})]})})})}function Ev({title:e,icon:t,children:n}){return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[t&&(0,Y.jsx)(t,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e})]}),n]})}var Dv={violet:{chip:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/40 dark:text-violet-300`,icon:`text-violet-500 dark:text-violet-400`}};function Ov({label:e,emptyHint:t,items:n,icon:r,tone:i,mono:a=!1}){let o=i?Dv[i]:null;return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground tracking-wider mb-1`,children:e}),n.length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:t}):(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.map(e=>(0,Y.jsxs)(`span`,{className:R(`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[11px]`,o?o.chip:`bg-background`,a&&`font-mono`),children:[r&&(0,Y.jsx)(r,{className:R(`h-3 w-3 shrink-0`,o?.icon)}),e.label,e.hint&&(0,Y.jsx)(`span`,{className:`text-[9px] uppercase opacity-70`,children:e.hint})]},e.key))})]})}function kv({icon:e,title:t,children:n}){return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase text-muted-foreground tracking-wider mb-1`,children:[(0,Y.jsx)(e,{className:`h-3 w-3`}),` `,t]}),n]})}function Av({data:e,keys:t,locale:n}){let r=t.map(t=>[t,jv(e,t)]).filter(([,e])=>e!=null);return r.length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.agentPreview.noValues`,n)}):(0,Y.jsx)(`dl`,{className:`space-y-0.5`,children:r.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground font-mono truncate`,children:e}),(0,Y.jsx)(`dd`,{className:`font-mono text-right truncate`,children:String(t)})]},e))})}function jv(e,t){let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r}function Mv({icon:e,label:t,tone:n=`gray`,mono:r=!1}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e&&(0,Y.jsx)(e,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`${n===`green`?`text-emerald-700`:n===`amber`?`text-amber-700`:`text-foreground`} ${r?`font-mono`:``}`,children:t})]})}function Nv(e){return!!e&&typeof e==`object`&&typeof e.properties==`object`}function Pv(e){return e?Array.isArray(e.type)?e.type.join(`|`):e.type===`array`&&e.items?`${Pv(e.items)}[]`:e.$ref?e.$ref.split(`/`).pop()||`ref`:e.type??`any`:`any`}function Fv(e){if(e.default!==void 0)return e.default;if(Array.isArray(e.enum)&&e.enum.length)return e.enum[0];switch(Array.isArray(e.type)?e.type[0]:e.type){case`string`:return e.format?`<${e.format}>`:`<string>`;case`number`:case`integer`:return 0;case`boolean`:return!1;case`array`:return[];case`object`:return{};default:return null}}var Iv=`developer:api-console`;function Lv({toolName:e,locale:t}){return r()?(0,Y.jsx)(Rv,{toolName:e,locale:t}):null}function Rv({toolName:e,locale:t}){let{appName:n}=i();if(!n)return null;let r=new URLSearchParams({path:`/api/v1/ai/tools/${encodeURIComponent(e)}/execute`,method:`POST`}),o=Ds(Iv).join(`/`);return(0,Y.jsxs)(a,{to:`/apps/${encodeURIComponent(n)}/component/${o}?${r.toString()}`,target:`_blank`,rel:`noreferrer`,className:`text-xs inline-flex items-center gap-1 text-muted-foreground hover:text-foreground`,title:G(`engine.toolPreview.openApiConsoleTitle`,t),children:[G(`engine.toolPreview.openApiConsole`,t),` `,(0,Y.jsx)(cr,{className:`h-3 w-3`})]})}function zv({name:e,draft:t,locale:n}){let r=t,i=String(r.name??e??``),a=String(r.label??i),o=String(r.description??``),s=r.objectName||void 0,c=r.parameters??{},l=r.outputSchema??void 0,u=Nv(c)?c.properties??{}:{},d=new Set(Array.isArray(c.required)?c.required:[]),f=J.useMemo(()=>{let e={};for(let t of d)u[t]&&(e[t]=Fv(u[t]));if(Object.keys(e).length===0){let t=Object.keys(u)[0];t&&(e[t]=Fv(u[t]))}return e},[u,d]);return!i&&!o&&Object.keys(u).length===0?(0,Y.jsx)(X,{hint:`tool`,children:(0,Y.jsx)(Pf,{children:G(`engine.toolPreview.empty`,n)})}):(0,Y.jsx)(X,{hint:`tool`,toolbar:i&&(0,Y.jsx)(Lv,{toolName:i,locale:n}),children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`rounded border bg-muted/30 p-3 space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(ta,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate`,children:a}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:i})]}),s&&(0,Y.jsx)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]`,children:(0,Y.jsx)(Hv,{icon:nr,label:s,mono:!0})})]})]}),o&&(0,Y.jsx)(`div`,{className:`pl-6 text-xs text-foreground whitespace-pre-wrap`,children:o})]}),(0,Y.jsx)(Vv,{title:G(`engine.toolPreview.inputParameters`,n),count:Object.keys(u).length,children:Object.keys(u).length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.toolPreview.noParameters`,n)}):(0,Y.jsx)(Bv,{props:u,required:d,locale:n})}),Object.keys(u).length>0&&(0,Y.jsx)(Vv,{title:G(`engine.toolPreview.exampleCall`,n),icon:dr,children:(0,Y.jsx)(`pre`,{className:`m-0 rounded border bg-background p-2.5 text-xs font-mono overflow-auto max-h-[200px]`,children:`{
11
+ "tool": "${i}",
12
+ "arguments": ${JSON.stringify(f,null,2).replace(/\n/g,`
13
+ `)}
14
+ }`})}),Nv(l)&&l.properties&&Object.keys(l.properties).length>0&&(0,Y.jsx)(Vv,{title:G(`engine.toolPreview.outputSchema`,n),count:Object.keys(l.properties).length,icon:vn,children:(0,Y.jsx)(Bv,{props:l.properties,required:new Set(Array.isArray(l.required)?l.required:[]),locale:n})})]})})})}function Bv({props:e,required:t,locale:n}){let r=Object.keys(e);return(0,Y.jsx)(`div`,{className:`rounded border bg-background overflow-hidden`,children:(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`bg-muted/30 text-left text-[10px] uppercase tracking-wider text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 font-medium`,children:G(`engine.toolPreview.col.name`,n)}),(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 font-medium`,children:G(`engine.toolPreview.col.type`,n)}),(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 font-medium`,children:G(`engine.toolPreview.col.description`,n)})]})}),(0,Y.jsx)(`tbody`,{className:`divide-y`,children:r.map(r=>{let i=e[r],a=t.has(r);return(0,Y.jsxs)(`tr`,{className:`align-top`,children:[(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5 font-mono`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a?(0,Y.jsx)(zn,{className:`h-3 w-3 text-emerald-600`}):(0,Y.jsx)(Pn,{className:`h-3 w-3 text-muted-foreground`}),r,a&&(0,Y.jsx)(`span`,{className:`text-[9px] uppercase text-emerald-700 ml-1`,children:G(`engine.toolPreview.required`,n)})]})}),(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5 font-mono text-muted-foreground`,children:Pv(i)}),(0,Y.jsxs)(`td`,{className:`px-2.5 py-1.5`,children:[i.description&&(0,Y.jsx)(`div`,{children:i.description}),Array.isArray(i.enum)&&i.enum.length>0&&(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:W(`engine.toolPreview.enum`,n,{values:i.enum.map(e=>JSON.stringify(e)).join(` | `)})}),i.default!==void 0&&(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[G(`engine.toolPreview.default`,n),` `,(0,Y.jsx)(`code`,{className:`font-mono`,children:JSON.stringify(i.default)})]}),i.format&&(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:W(`engine.toolPreview.format`,n,{format:i.format})})]})]},r)})})]})})}function Vv({title:e,count:t,icon:n,children:r}){return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[n&&(0,Y.jsx)(n,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e}),t!=null&&(0,Y.jsxs)(`span`,{className:`opacity-70`,children:[`(`,t,`)`]})]}),r]})}function Hv({icon:e,label:t,mono:n=!1}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e&&(0,Y.jsx)(e,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-foreground ${n?`font-mono`:``}`,children:t})]})}var Uv=[{key:`allowCreate`,short:`C`,long:`engine.permissionPreview.cap.create`},{key:`allowRead`,short:`R`,long:`engine.permissionPreview.cap.read`},{key:`allowEdit`,short:`U`,long:`engine.permissionPreview.cap.edit`},{key:`allowDelete`,short:`D`,long:`engine.permissionPreview.cap.delete`},{key:`allowExport`,short:`E`,long:`engine.permissionPreview.cap.export`},{key:`allowTransfer`,short:`T`,long:`engine.permissionPreview.cap.transfer`},{key:`viewAllRecords`,short:`V*`,long:`engine.permissionPreview.cap.viewAll`,danger:!0},{key:`modifyAllRecords`,short:`M*`,long:`engine.permissionPreview.cap.modifyAll`,danger:!0}],Wv=[`own`,`own_and_reports`,`unit`,`unit_and_below`,`org`],Gv={own:`own`,own_and_reports:`own+reports`,unit:`unit`,unit_and_below:`unit+below`,org:`org`};function Kv(e){return typeof e==`string`&&e?e:void 0}function qv(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;t.push({name:Kv(e.name),label:Kv(e.label),description:Kv(e.description)})}return t}function Jv(e){let t=[];for(let[n,r]of Object.entries(e)){r.allowEdit&&!r.allowRead&&t.push({object:n,messageKey:`engine.permissionPreview.warn.editWithoutRead`}),r.allowDelete&&!r.allowRead&&t.push({object:n,messageKey:`engine.permissionPreview.warn.deleteWithoutRead`}),r.modifyAllRecords&&!r.viewAllRecords&&t.push({object:n,messageKey:`engine.permissionPreview.warn.modifyAllWithoutViewAll`});let e=r.readScope?Wv.indexOf(r.readScope):-1,i=r.writeScope?Wv.indexOf(r.writeScope):-1;e>=0&&i>e&&t.push({object:n,messageKey:`engine.permissionPreview.warn.writeWiderThanRead`,vars:{write:Gv[r.writeScope],read:Gv[r.readScope]}})}return t}function Yv({name:e,draft:t,locale:n}){let r=t,i=String(r.name??e??``),a=String(r.label??i),o=!!r.isDefault,s=r.objects??{},c=r.fields??{},l=Array.isArray(r.systemPermissions)?r.systemPermissions:[],u=r.tabPermissions??{},d=Array.isArray(r.rowLevelSecurity)?r.rowLevelSecurity:[],f=qv(d),p=J.useMemo(()=>Object.keys(s).sort(),[s]),m=J.useMemo(()=>Jv(s),[s]),h=J.useMemo(()=>{let e=new Map;for(let[t,n]of Object.entries(c)){let[r,...i]=t.split(`.`);if(!r||i.length===0)continue;let a=i.join(`.`);(n.readable===!1||n.editable===!0)&&(e.has(r)||e.set(r,[]),e.get(r).push({field:a,perm:n}))}return e},[c]);return p.length===0&&l.length===0&&Object.keys(u).length===0&&d.length===0?(0,Y.jsx)(X,{hint:`permission`,children:(0,Y.jsx)(Pf,{children:G(`engine.permissionPreview.empty`,n)})}):(0,Y.jsx)(X,{hint:`permission · ${p.length} object${p.length===1?``:`s`}`,children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-muted/30 p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[o?(0,Y.jsx)(Ri,{className:`h-4 w-4 mt-0.5 text-amber-600 shrink-0`}):(0,Y.jsx)(Ai,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate`,children:a}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:i}),(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:G(o?`engine.permissionPreview.kind.default`:`engine.permissionPreview.kind.set`,n)})]}),(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]`,children:[(0,Y.jsx)($v,{icon:zr,label:W(`engine.permissionPreview.pill.objects`,n,{count:p.length})}),(0,Y.jsx)($v,{icon:Ui,label:W(`engine.permissionPreview.pill.systemPerms`,n,{count:l.length})}),(0,Y.jsx)($v,{icon:ur,label:W(`engine.permissionPreview.pill.tabs`,n,{count:Object.keys(u).length})}),(0,Y.jsx)($v,{icon:Kr,label:W(`engine.permissionPreview.pill.rls`,n,{count:d.length})})]})]})]})}),p.length>0&&(0,Y.jsxs)(Qv,{title:G(`engine.permissionPreview.section.objects`,n),count:p.length,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-background overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`bg-muted/30 text-[10px] uppercase tracking-wider text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 text-left font-medium sticky left-0 bg-muted/30`,children:G(`engine.permissionPreview.col.object`,n)}),Uv.map(e=>(0,Y.jsx)(`th`,{className:`px-1.5 py-1.5 text-center font-medium`,title:G(e.long,n),children:e.short},e.key)),(0,Y.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium`,title:G(`engine.permissionPreview.col.scopeTitle`,n),children:G(`engine.permissionPreview.col.scope`,n)})]})}),(0,Y.jsx)(`tbody`,{className:`divide-y`,children:p.map(e=>{let t=s[e]??{};return(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`px-2.5 py-1 font-mono sticky left-0 bg-background`,children:e}),Uv.map(e=>{let r=!!t[e.key];return(0,Y.jsx)(`td`,{className:`px-1.5 py-1 text-center`,children:(0,Y.jsx)(Xv,{granted:r,danger:e.danger,locale:n})},e.key)}),(0,Y.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap text-[10px] text-muted-foreground`,children:t.readScope||t.writeScope?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{title:G(`engine.permissionPreview.readScope`,n),children:t.readScope?Gv[t.readScope]:`—`}),(0,Y.jsx)(`span`,{className:`mx-1 opacity-50`,children:`/`}),(0,Y.jsx)(`span`,{title:G(`engine.permissionPreview.writeScope`,n),children:t.writeScope?Gv[t.writeScope]:`—`})]}):(0,Y.jsx)(`span`,{className:`opacity-40`,children:G(`engine.permissionPreview.scopeDefault`,n)})})]},e)})})]})}),(0,Y.jsx)(Zv,{locale:n})]}),h.size>0&&(0,Y.jsx)(Qv,{title:G(`engine.permissionPreview.section.fields`,n),count:Array.from(h.values()).reduce((e,t)=>e+t.length,0),children:(0,Y.jsx)(`div`,{className:`rounded border bg-background divide-y text-xs`,children:Array.from(h.entries()).sort().map(([e,t])=>(0,Y.jsxs)(`div`,{className:`px-2.5 py-2`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-[11px] mb-1`,children:e}),(0,Y.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:t.map(({field:e,perm:t})=>(0,Y.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded border bg-muted/30 px-1.5 py-0.5`,title:`readable=${t.readable!==!1}, editable=${!!t.editable}`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e}),t.readable===!1&&(0,Y.jsx)(`span`,{className:`text-[9px] uppercase text-red-700`,children:G(`engine.permissionPreview.fls.hidden`,n)}),t.editable&&(0,Y.jsx)(`span`,{className:`text-[9px] uppercase text-emerald-700`,children:G(`engine.permissionPreview.fls.editable`,n)})]},e))})]},e))})}),f.length>0&&(0,Y.jsx)(Qv,{title:G(`perm.rls.title`,n),count:f.length,children:(0,Y.jsx)(`ul`,{className:`rounded border bg-background divide-y text-xs`,children:f.map((e,t)=>(0,Y.jsxs)(`li`,{className:`px-2.5 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[e.label&&(0,Y.jsx)(`span`,{className:`font-medium`,children:e.label}),e.name&&(0,Y.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.name})]}),e.description&&(0,Y.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:e.description})]},t))})}),l.length>0&&(0,Y.jsx)(Qv,{title:G(`engine.permissionPreview.section.system`,n),count:l.length,children:(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:l.map(e=>(0,Y.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded border bg-background px-1.5 py-0.5 text-[11px] font-mono`,children:e},e))})}),Object.keys(u).length>0&&(0,Y.jsx)(Qv,{title:G(`engine.permissionPreview.section.tabs`,n),count:Object.keys(u).length,children:(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(u).map(([e,t])=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border bg-background px-1.5 py-0.5 text-[11px]`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e}),(0,Y.jsx)(`span`,{className:t===`hidden`?`text-[9px] uppercase text-red-700`:t===`visible`||t===`default_on`?`text-[9px] uppercase text-emerald-700`:`text-[9px] uppercase text-muted-foreground`,children:t})]},e))})}),m.length>0&&(0,Y.jsxs)(`div`,{className:`rounded border border-amber-200 bg-amber-50 p-2.5 text-xs space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-amber-800`,children:[(0,Y.jsx)(Ji,{className:`h-3.5 w-3.5`}),` `,W(m.length===1?`engine.permissionPreview.sanityOne`:`engine.permissionPreview.sanityOther`,n,{count:m.length})]}),(0,Y.jsx)(`ul`,{className:`space-y-0.5`,children:m.map((e,t)=>(0,Y.jsxs)(`li`,{className:`text-amber-900`,children:[(0,Y.jsx)(`code`,{className:`font-mono`,children:e.object}),`:`,` `,e.vars?W(e.messageKey,n,e.vars):G(e.messageKey,n)]},t))})]})]})})})}function Xv({granted:e,danger:t,locale:n}){return e?(0,Y.jsx)(zn,{className:`inline-block h-3.5 w-3.5 ${t?`text-amber-600`:`text-emerald-600`}`,"aria-label":G(`engine.permissionPreview.granted`,n)}):(0,Y.jsx)(Gn,{className:`inline-block h-3 w-3 text-muted-foreground/40`,"aria-label":G(`engine.permissionPreview.notGranted`,n)})}function Zv({locale:e}){return(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(zn,{className:`h-3 w-3 text-emerald-600`}),` `,G(`engine.permissionPreview.granted`,e)]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(zn,{className:`h-3 w-3 text-amber-600`}),` `,G(`engine.permissionPreview.legend.bypass`,e)]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(Gn,{className:`h-3 w-3 text-muted-foreground/40`}),` `,G(`engine.permissionPreview.notGranted`,e)]}),(0,Y.jsx)(`span`,{className:`ml-auto font-mono`,children:G(`engine.permissionPreview.legend.key`,e)})]})}function Qv({title:e,count:t,children:n}){return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,Y.jsx)(`span`,{children:e}),t!=null&&(0,Y.jsxs)(`span`,{className:`opacity-70`,children:[`(`,t,`)`]})]}),n]})}function $v({icon:e,label:t}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e&&(0,Y.jsx)(e,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{children:t})]})}function ey(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;return t.en??t[`en-US`]??Object.values(t)[0]??``}return String(e)}function ty(e){switch(e){case`url`:return Hr;case`modal`:return Vr;case`flow`:return ea;case`api`:return kr;case`form`:return di;default:return Xn}}function ny(e){switch(e){case`primary`:case`default`:case void 0:return`bg-primary text-primary-foreground hover:opacity-90`;case`danger`:case`destructive`:return`bg-red-600 text-white hover:bg-red-700`;case`secondary`:return`bg-secondary text-secondary-foreground hover:opacity-90`;case`ghost`:return`bg-transparent text-foreground hover:bg-accent`;case`link`:return`bg-transparent text-primary underline-offset-2 hover:underline px-0`;default:return`border bg-background text-foreground hover:bg-accent`}}function ry(e,t,n,r){if(!t&&!n)return G(`engine.actionPreview.handler.none`,r);let i={target:String(t)};switch(e){case`url`:return W(`engine.actionPreview.handler.url`,r,i);case`flow`:return W(`engine.actionPreview.handler.flow`,r,i);case`modal`:return W(`engine.actionPreview.handler.modal`,r,i);case`api`:return W(`engine.actionPreview.handler.api`,r,i);case`form`:return W(`engine.actionPreview.handler.form`,r,{...i,path:t??`?`});case`script`:return n?G(`engine.actionPreview.handler.scriptBody`,r):W(`engine.actionPreview.handler.scriptNamed`,r,i);default:return W(`engine.actionPreview.handler.invoke`,r,i)}}function iy(e,t){return e.split(/(\{\w+\})/).map((e,n)=>{let r=/^\{(\w+)\}$/.exec(e);return(0,Y.jsx)(J.Fragment,{children:r&&r[1]in t?t[r[1]]:e},n)})}function ay({name:e,draft:t,locale:n}){let r=t,i=String(r.name??e??``),a=ey(r.label)||i,o=r.icon||void 0,s=String(r.type??`script`),c=r.target,l=r.variant||void 0,u=String(r.component??``),d=Array.isArray(r.locations)?r.locations:[],f=Array.isArray(r.requiredPermissions)?r.requiredPermissions.filter(e=>typeof e==`string`):[],p=!!r.refreshAfter,m=r.aiExposed,h=ey(r.confirmText),g=ey(r.successMessage),_=Array.isArray(r.params)?r.params:[],v=r.resultDialog,y=r.body,b=r.objectName||void 0,x=r.visible,S=r.disabled,C=r.method||`POST`,w=r.bodyExtra,T=ty(s),E=u===`action:icon`;return!i&&!a?(0,Y.jsx)(X,{hint:`action`,children:(0,Y.jsx)(Pf,{children:G(`engine.actionPreview.empty`,n)})}):(0,Y.jsx)(X,{hint:`action`,children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-muted/30 p-4 flex items-center justify-center min-h-[80px]`,children:(0,Y.jsx)(oy,{label:a,icon:o,variant:l,iconOnly:E,disabled:!!S&&typeof S==`boolean`})}),(0,Y.jsxs)(`div`,{className:`rounded border bg-background p-3 text-xs space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:a}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:i})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]`,children:[(0,Y.jsx)(hy,{icon:T,label:W(`engine.actionPreview.pill.type`,n,{type:s})}),b&&(0,Y.jsx)(hy,{icon:Li,label:W(`engine.actionPreview.pill.object`,n,{object:b}),mono:!0}),l&&(0,Y.jsx)(hy,{label:W(`engine.actionPreview.pill.variant`,n,{variant:l})}),u&&(0,Y.jsx)(hy,{icon:sr,label:u}),p&&(0,Y.jsx)(hy,{icon:vi,label:G(`engine.actionPreview.pill.refreshAfter`,n)}),m===!1&&(0,Y.jsx)(hy,{icon:_n,label:G(`engine.actionPreview.pill.aiOptedOut`,n),tone:`amber`}),m===!0&&(0,Y.jsx)(hy,{icon:Fi,label:G(`engine.actionPreview.pill.aiExposed`,n)})]}),d.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:G(`engine.actionPreview.locations`,n)}),d.map(e=>(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-[10px] font-mono`,children:e},e))]}),f.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,"data-testid":`action-preview-required-permissions`,children:[(0,Y.jsx)(Kr,{className:`h-3 w-3 text-amber-700`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:G(`engine.actionPreview.requires`,n)}),f.map(e=>(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-[10px] font-mono`,children:e},e))]}),!!(typeof x==`string`||x&&typeof x==`object`)&&(0,Y.jsx)(py,{label:G(`engine.actionPreview.visibleWhen`,n),value:x,icon:ur}),S!=null&&typeof S!=`boolean`&&(0,Y.jsx)(py,{label:G(`engine.actionPreview.disabledWhen`,n),value:S,icon:Kr})]}),(0,Y.jsxs)(`div`,{className:`rounded border border-blue-200 bg-blue-50 p-2.5 text-xs`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-blue-900 mb-0.5`,children:[(0,Y.jsx)(T,{className:`h-3.5 w-3.5`}),` `,G(`engine.actionPreview.onClick`,n)]}),(0,Y.jsx)(`div`,{className:`text-blue-950 font-mono break-all`,children:ry(s,c,!!y?.source,n)}),h&&(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-1.5 text-amber-900`,children:[(0,Y.jsx)(Ji,{className:`h-3 w-3 mt-0.5`}),(0,Y.jsxs)(`span`,{children:[G(`engine.actionPreview.firstAsks`,n),` `,(0,Y.jsx)(`em`,{children:h})]})]}),g&&(0,Y.jsxs)(`div`,{className:`mt-1.5 text-blue-950`,children:[G(`engine.actionPreview.onSuccess`,n),` `,(0,Y.jsx)(`em`,{children:g})]})]}),d.length>0&&(0,Y.jsxs)(my,{title:G(`engine.actionPreview.section.placement`,n),children:[f.length>0&&(0,Y.jsx)(`div`,{className:`text-[11px] text-amber-700`,"data-testid":`action-preview-capability-gate-note`,children:iy(G(`engine.actionPreview.capabilityGateNote`,n),{capabilities:(0,Y.jsx)(`span`,{className:`font-mono`,children:f.join(` + `)})})}),(0,Y.jsx)(_y,{locations:d,label:a,icon:o,variant:l,iconOnly:E,locale:n})]}),s===`api`&&!!c&&(0,Y.jsx)(my,{title:G(`engine.actionPreview.section.testRequest`,n),icon:kr,children:(0,Y.jsx)(vy,{target:c,method:C,bodyExtra:w,params:_,locale:n})}),_.length>0&&(0,Y.jsx)(my,{title:G(`engine.actionPreview.section.inputDialog`,n),count:_.length,children:(0,Y.jsx)(cy,{title:a,params:_,variant:l,locale:n})}),v&&(0,Y.jsx)(my,{title:G(`engine.actionPreview.section.resultDialog`,n),icon:ur,children:(0,Y.jsx)(fy,{dialog:v,locale:n})}),y?.source&&(0,Y.jsx)(my,{title:W(`engine.actionPreview.section.scriptBody`,n,{language:y.language??`expression`}),icon:Xn,children:(0,Y.jsx)(`pre`,{className:`m-0 rounded border bg-background p-2.5 text-xs font-mono whitespace-pre-wrap max-h-[200px] overflow-auto`,children:y.source})})]})})})}function oy({label:e,icon:t,variant:n,iconOnly:r,disabled:i}){let a=`inline-flex items-center gap-1.5 rounded px-3 py-1.5 text-sm font-medium pointer-events-none ${ny(n)} ${i?`opacity-50`:``}`;return(0,Y.jsxs)(`button`,{type:`button`,className:a,"aria-disabled":!0,disabled:!0,children:[t&&(0,Y.jsx)(sy,{name:t}),!r&&(0,Y.jsx)(`span`,{children:e})]})}function sy({name:e}){let t=je(e);return t?(0,Y.jsx)(t,{className:`h-4 w-4`,"aria-hidden":!0}):(0,Y.jsx)(`span`,{className:`inline-flex h-4 min-w-4 items-center justify-center rounded bg-white/30 px-1 text-[9px] uppercase font-mono`,children:e.slice(0,3)})}function cy({title:e,params:t,variant:n,locale:r}){return(0,Y.jsxs)(`div`,{className:`rounded border bg-background shadow-sm`,children:[(0,Y.jsx)(`div`,{className:`border-b bg-muted/30 px-3 py-2 text-xs font-medium`,children:e}),(0,Y.jsx)(`div`,{className:`p-3 space-y-2`,children:t.map((e,t)=>{let n=e.name??e.field??`param_${t}`,i=ey(e.label)||n;return(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Y.jsxs)(`label`,{className:`text-xs flex items-center gap-1`,children:[i,e.required&&(0,Y.jsx)(`span`,{className:`text-red-600 text-[10px]`,children:`*`}),(0,Y.jsx)(`span`,{className:`ml-1 font-mono text-[9px] text-muted-foreground`,children:n}),e.type&&(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:e.type})]}),dy(e,i,r),e.helpText&&(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e.helpText})]},t)})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t bg-muted/20 px-3 py-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:!0,className:`text-xs px-2.5 py-1 rounded border bg-background pointer-events-none`,children:G(`engine.cancel`,r)}),(0,Y.jsx)(`button`,{type:`button`,disabled:!0,className:`text-xs px-2.5 py-1 rounded pointer-events-none ${ny(n||`primary`)}`,children:G(`engine.actionPreview.dialog.ok`,r)})]})]})}var ly=`(inherited from the bound field)`;function uy(e){if(!e.type)return{widget:void 0,degraded:!1};let t=e.reference??(e.field?ly:void 0),n=ma({name:e.name??``,label:``,type:e.type,referenceTo:t});return{widget:n?`text`:fa(e.type),degraded:n}}function dy(e,t,n){let r=`w-full text-xs px-2 py-1 border rounded bg-background pointer-events-none`;if(e.carryOver)return(0,Y.jsxs)(`div`,{className:`${r} flex items-center gap-1.5 text-muted-foreground`,"data-testid":`action-preview-carry-over`,children:[(0,Y.jsx)(Kr,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`truncate`,children:G(`engine.actionPreview.param.carryOver`,n)})]});let i=e.placeholder||(e.defaultFromRow?G(`engine.actionPreview.param.fromRow`,n):``),a=e.defaultValue,o=a==null?``:String(a),s=Array.isArray(e.options)?e.options:[],{widget:c,degraded:l}=uy(e),u=e=>(0,Y.jsx)(`input`,{type:e,className:r,placeholder:i,value:o,readOnly:!0}),d=(0,Y.jsxs)(`select`,{className:r,disabled:!0,value:``,children:[(0,Y.jsx)(`option`,{value:``,children:i||W(`engine.actionPreview.param.selectPlaceholder`,n,{label:t})}),s.map((e,t)=>(0,Y.jsx)(`option`,{value:e.value,children:ey(e.label)},t))]}),f=e=>(0,Y.jsx)(`div`,{className:`text-[10px] text-amber-700`,children:e});if(c===void 0)return s.length>0?d:u(`text`);if(l)return(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Y.jsx)(`input`,{type:`text`,className:r,placeholder:i||W(`engine.actionPreview.param.recordIdPlaceholder`,n,{label:t}),value:o,readOnly:!0}),f(iy(G(`engine.actionPreview.param.noReference`,n),{reference:(0,Y.jsx)(`code`,{className:`font-mono`,children:`reference`})}))]});switch(c){case`boolean`:return(0,Y.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-xs`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,disabled:!0,className:`pointer-events-none`}),` `,G(`engine.actionPreview.param.toggle`,n)]});case`textarea`:case`html`:return(0,Y.jsx)(`textarea`,{className:`${r} min-h-[48px]`,placeholder:i,value:o,readOnly:!0});case`select`:return s.length>0?d:(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[d,f(G(`engine.actionPreview.param.noChoices`,n))]});case`number`:return u(`number`);case`date`:return u(`date`);case`datetime`:return u(`datetime-local`);case`lookup`:return(0,Y.jsxs)(`button`,{type:`button`,disabled:!0,role:`combobox`,"aria-expanded":!1,"aria-haspopup":`dialog`,className:`${r} flex items-center gap-1.5 text-left text-muted-foreground`,children:[(0,Y.jsx)(Di,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`truncate`,children:i||(e.reference==null?G(`engine.actionPreview.param.searchRecords`,n):W(`engine.actionPreview.param.searchObject`,n,{object:e.reference}))})]});default:return u(`text`)}}function fy({dialog:e,locale:t}){let n=ey(e.title)||G(`engine.actionPreview.result.title`,t),r=ey(e.description),i=ey(e.acknowledge)||G(`engine.actionPreview.result.acknowledge`,t),a=e.fields??[];return(0,Y.jsxs)(`div`,{className:`rounded border bg-background shadow-sm`,children:[(0,Y.jsx)(`div`,{className:`border-b bg-muted/30 px-3 py-2 text-xs font-medium`,children:n}),(0,Y.jsxs)(`div`,{className:`p-3 space-y-2 text-xs`,children:[r&&(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:r}),a.length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.actionPreview.result.fullJson`,t)}):(0,Y.jsx)(`ul`,{className:`space-y-1.5`,children:a.map((t,n)=>(0,Y.jsx)(`li`,{className:`rounded border bg-muted/20 p-2`,children:(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:ey(t.label)||t.path}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:t.path}),(0,Y.jsx)(`span`,{className:`ml-auto font-mono text-[9px] uppercase text-muted-foreground`,children:t.format??e.format??`json`})]})},n))})]}),(0,Y.jsx)(`div`,{className:`flex items-center justify-end border-t bg-muted/20 px-3 py-2`,children:(0,Y.jsx)(`button`,{type:`button`,disabled:!0,className:`text-xs px-2.5 py-1 rounded bg-primary text-primary-foreground pointer-events-none`,children:i})})]})}function py({label:e,value:t,icon:n}){let r=typeof t==`string`?t:t?.source??JSON.stringify(t);return(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 pt-0.5`,children:[(0,Y.jsx)(n,{className:`h-3 w-3 mt-0.5 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`:`]}),(0,Y.jsx)(`code`,{className:`font-mono break-all`,children:r})]})}function my({title:e,count:t,icon:n,children:r}){return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[n&&(0,Y.jsx)(n,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e}),t!=null&&(0,Y.jsxs)(`span`,{className:`opacity-70`,children:[`(`,t,`)`]})]}),r]})}function hy({icon:e,label:t,tone:n=`gray`,mono:r=!1}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e&&(0,Y.jsx)(e,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`${n===`green`?`text-emerald-700`:n===`amber`?`text-amber-700`:`text-foreground`} ${r?`font-mono`:``}`,children:t})]})}function gy({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-mono uppercase tracking-wider text-muted-foreground/70`,children:e}),t]})}function _y({locations:e,label:t,icon:n,variant:r,iconOnly:i,locale:a}){let o=(0,Y.jsx)(oy,{label:t,icon:n,variant:r,iconOnly:i}),s=(0,Y.jsx)(`div`,{className:`divide-y rounded border bg-background`,children:[0,1].map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[11px]`,children:W(`engine.actionPreview.placement.row`,a,{n:e+1})}),(0,Y.jsx)(`div`,{className:`origin-right scale-90`,children:o})]},e))});return(0,Y.jsxs)(`div`,{className:`space-y-2.5`,children:[e.includes(`record_header`)&&(0,Y.jsx)(gy,{label:`record_header`,children:(0,Y.jsxs)(`div`,{className:`rounded border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`h-6 w-6 rounded bg-muted`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium`,children:G(`engine.actionPreview.placement.sampleRecord`,a)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:G(`engine.actionPreview.placement.recordDetail`,a)})]})]}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,children:o})]}),(0,Y.jsx)(`div`,{className:`p-3 text-[10px] text-muted-foreground`,children:G(`engine.actionPreview.placement.recordBody`,a)})]})}),e.includes(`list_toolbar`)&&(0,Y.jsx)(gy,{label:`list_toolbar`,children:(0,Y.jsxs)(`div`,{className:`rounded border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium`,children:G(`engine.actionPreview.placement.records`,a)}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,children:o})]}),(0,Y.jsx)(`div`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:G(`engine.actionPreview.placement.rows`,a)})]})}),e.includes(`list_item`)&&(0,Y.jsx)(gy,{label:`list_item`,children:s}),e.includes(`record_section`)&&(0,Y.jsx)(gy,{label:`record_section`,children:(0,Y.jsxs)(`div`,{className:`rounded border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:G(`engine.actionPreview.placement.section`,a)}),o]}),(0,Y.jsx)(`div`,{className:`p-3 text-[10px] text-muted-foreground`,children:G(`engine.actionPreview.placement.sectionBody`,a)})]})}),e.includes(`record_related`)&&(0,Y.jsx)(gy,{label:`record_related`,children:s}),e.includes(`record_more`)&&(0,Y.jsx)(gy,{label:`record_more`,children:(0,Y.jsxs)(`div`,{className:`w-52 rounded border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b px-3 py-1.5 text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(sr,{className:`h-3.5 w-3.5`}),` `,G(`engine.actionPreview.placement.more`,a)]}),(0,Y.jsx)(`div`,{className:`px-2 py-1.5 text-xs`,children:(0,Y.jsx)(`div`,{className:`rounded px-1 py-0.5 hover:bg-accent`,children:t})})]})})]})}function vy({target:e,method:t,bodyExtra:n,params:r,locale:i}){let a=(t||`POST`).toUpperCase(),[o,s]=J.useState(null),[c,l]=J.useState(!1),u=n&&typeof n==`object`?n:{};return(0,Y.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Y.jsxs)(`div`,{className:`rounded border bg-background p-2 font-mono text-[11px] break-all`,children:[(0,Y.jsx)(`span`,{className:`font-semibold`,children:a}),` `,e]}),Object.keys(u).length>0&&(0,Y.jsx)(`pre`,{className:`m-0 rounded border bg-muted/30 p-2 text-[10px] font-mono whitespace-pre-wrap`,children:JSON.stringify(u,null,2)}),r.length>0&&(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:W(r.length>1?`engine.actionPreview.api.paramsOther`:`engine.actionPreview.api.paramsOne`,i,{count:r.length})}),a!==`GET`&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px] text-amber-700`,children:[(0,Y.jsx)(Ji,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{children:W(`engine.actionPreview.api.liveWarning`,i,{method:a})})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:async()=>{l(!0),s(null);try{let t=typeof localStorage<`u`?localStorage.getItem(`auth-session-token`):null,n={"Content-Type":`application/json`};t&&(n.Authorization=`Bearer ${t}`);let r={method:a,headers:n,credentials:`include`};a!==`GET`&&a!==`HEAD`&&(r.body=JSON.stringify(u));let i=await fetch(e,r),o=await i.text(),c=o;try{c=JSON.parse(o)}catch{}s({status:i.status,ok:i.ok,body:c})}catch(e){s({status:0,ok:!1,error:e instanceof Error?e.message:String(e)})}finally{l(!1)}},disabled:c,className:`inline-flex items-center gap-1.5 rounded border bg-background px-2.5 py-1 text-xs font-medium hover:bg-accent disabled:opacity-50`,children:[(0,Y.jsx)(kr,{className:`h-3.5 w-3.5`}),` `,G(c?`engine.actionPreview.api.sending`:`engine.actionPreview.api.send`,i)]}),o&&(0,Y.jsxs)(`div`,{className:`rounded border p-2 `+(o.ok?`border-green-300 bg-green-50`:`border-red-300 bg-red-50`),children:[(0,Y.jsx)(`div`,{className:`mb-1 text-[11px] font-medium`,children:o.error?G(`engine.actionPreview.api.networkError`,i):`HTTP `+o.status+(o.ok?` OK`:``)}),(0,Y.jsx)(`pre`,{className:`m-0 max-h-[200px] overflow-auto text-[10px] font-mono whitespace-pre-wrap`,children:o.error??(typeof o.body==`string`?o.body:JSON.stringify(o.body,null,2))})]})]})}var yy={"@yearly":`0 0 1 1 *`,"@annually":`0 0 1 1 *`,"@monthly":`0 0 1 * *`,"@weekly":`0 0 * * 0`,"@daily":`0 0 * * *`,"@midnight":`0 0 * * *`,"@hourly":`0 * * * *`};function by(e,t,n){let r={values:new Set,any:!1};if(e===`*`){for(let e=t;e<=n;e++)r.values.add(e);return r.any=!0,r}for(let i of e.split(`,`)){let e,a=i;if(i.includes(`/`)){let[t,n]=i.split(`/`);a=t,e=n}let o=e?Math.max(1,parseInt(e,10)||1):1,s=t,c=n;if(a!==`*`){if(a.includes(`-`)){let[e,t]=a.split(`-`).map(e=>parseInt(e,10));if(Number.isNaN(e)||Number.isNaN(t))return null;s=e,c=t}else{let e=parseInt(a,10);if(Number.isNaN(e))return null;s=e,c=e}}for(let e=s;e<=c;e+=o)e>=t&&e<=n&&r.values.add(e)}return r}function xy(e){let t=(yy[e.trim()]??e.trim()).split(/\s+/);if(t.length!==5&&t.length!==6)return null;let[n,r,i,a,o]=t.length===6?t.slice(1):t,s=by(n,0,59),c=by(r,0,23),l=by(i,1,31),u=by(a,1,12),d=by(o===`7`?`0`:o,0,6);return!s||!c||!l||!u||!d?null:{minute:s,hour:c,dom:l,month:u,dow:d}}function Sy(e,t,n){let r=xy(e);if(!r)return[];let i=[],a=new Date(t.getTime());a.setSeconds(0,0),a.setMinutes(a.getMinutes()+1);let o=t.getTime()+316224e5;for(;i.length<n&&a.getTime()<=o;)r.minute.values.has(a.getMinutes())&&r.hour.values.has(a.getHours())&&r.month.values.has(a.getMonth()+1)&&(r.dom.any||r.dow.any?r.dom.values.has(a.getDate())&&r.dow.values.has(a.getDay()):r.dom.values.has(a.getDate())||r.dow.values.has(a.getDay()))&&i.push(new Date(a.getTime())),a.setMinutes(a.getMinutes()+1);return i}function Cy(e){let t=/^(\d+)\s*(ms|s|m|h|d)$/.exec(e.trim());if(!t)return null;let n=parseInt(t[1],10);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;case`d`:return n*864e5;default:return null}}function wy(e,t,n){let r=[];for(let i=1;i<=n;i++)r.push(new Date(t.getTime()+i*e));return r}function Ty(e,t){return e.toLocaleString(t,{weekday:`short`,month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function Ey(e){if(e.schedule&&typeof e.schedule==`object`){let t=e.schedule,n=String(t.type??``),r=t.timezone??e.timezone??e.tz;if(n===`cron`){let e=t.expression;return{cron:typeof e==`string`?e:e&&typeof e==`object`&&typeof e.source==`string`?e.source:void 0,timezone:r}}if(n===`interval`){let e=Number(t.intervalMs);return{every:Number.isFinite(e)&&e>0?Dy(e):void 0,timezone:r}}if(n===`once`)return{at:typeof t.at==`string`?t.at:void 0,timezone:r}}let t=typeof e.cron==`string`?e.cron:typeof e.schedule==`string`?e.schedule:void 0,n=e.every??e.interval;return{cron:t,every:typeof n==`string`?n:typeof n==`number`?Dy(n):void 0,at:typeof e.at==`string`?e.at:typeof e.runAt==`string`?e.runAt:void 0,timezone:e.timezone??e.tz}}function Dy(e){return e%864e5==0?`${e/864e5}d`:e%36e5==0?`${e/36e5}h`:e%6e4==0?`${e/6e4}m`:e%1e3==0?`${e/1e3}s`:`${e}ms`}function Oy({name:e,draft:t,locale:n}){let r=nn(),i=t,a=String(i.name??e??``),o=String(i.label??a),s=i.description??``,{cron:c,every:l,at:u,timezone:d}=Ey(i),f=i.handler??i.target??i.function??i.functionName,p=i.active!==!1&&i.enabled!==!1,m=i.retryPolicy,h=m?.maxRetries??i.maxRetries??i.retries,g=m?.backoffMs,_=i.timeout??i.timeoutMs,v=i.concurrency,y=l?Cy(l):null,{nextFires:b,deltas:x}=J.useMemo(()=>{let e=new Date,t=[];if(c)t=Sy(c,e,5);else if(y)t=wy(y,e,5);else if(u){let e=Date.parse(u);Number.isNaN(e)||(t=[new Date(e)])}return{nextFires:t,deltas:t.map(t=>ky(t.getTime()-e.getTime()))}},[c,y,u]),S=c&&b.length===0||l&&!y;return!a&&!c&&!l&&!u&&!f?(0,Y.jsx)(X,{hint:`job`,children:(0,Y.jsx)(Pf,{children:G(`engine.jobPreview.empty`,n)})}):(0,Y.jsx)(X,{hint:`job`,children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-muted/30 p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(cn,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate`,children:o}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:a})]}),s&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:s}),(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]`,children:[(0,Y.jsx)(My,{icon:hi,label:G(p?`engine.jobPreview.active`:`engine.jobPreview.paused`,n),tone:p?`green`:`gray`}),d&&(0,Y.jsx)(My,{icon:or,label:d,mono:!0}),h!=null&&(0,Y.jsx)(My,{icon:Ci,label:g?W(`engine.jobPreview.retriesBackoff`,n,{count:String(h),backoff:Dy(g)}):W(`engine.jobPreview.retries`,n,{count:String(h)})}),_!=null&&(0,Y.jsx)(My,{icon:Gi,label:W(`engine.jobPreview.timeout`,n,{duration:Dy(_)})}),v!=null&&(0,Y.jsx)(My,{label:W(`engine.jobPreview.concurrency`,n,{count:String(v)})})]})]})]})}),(0,Y.jsx)(jy,{title:G(`engine.jobPreview.schedule`,n),icon:wn,children:(0,Y.jsxs)(`div`,{className:`rounded border bg-background p-2.5 text-xs space-y-1`,children:[c&&(0,Y.jsx)(Ay,{label:`Cron`,children:(0,Y.jsx)(`code`,{className:`font-mono`,children:c})}),l&&(0,Y.jsxs)(Ay,{label:G(`engine.jobPreview.every`,n),children:[(0,Y.jsx)(`code`,{className:`font-mono`,children:l}),!y&&(0,Y.jsx)(`span`,{className:`ml-2 text-amber-700`,children:G(`engine.jobPreview.unparseable`,n)})]}),u&&(0,Y.jsx)(Ay,{label:G(`engine.jobPreview.at`,n),children:(0,Y.jsx)(`code`,{className:`font-mono`,children:u})}),!c&&!l&&!u&&(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.jobPreview.noSchedule`,n)})]})}),(c||y||u)&&(0,Y.jsx)(jy,{title:W(b.length===1?`engine.jobPreview.nextRunOne`:`engine.jobPreview.nextRunOther`,n,{count:Math.max(b.length,1)}),icon:qn,children:b.length===0?(0,Y.jsx)(`div`,{className:`text-xs text-amber-700`,children:G(S?`engine.jobPreview.noFireTime`:`engine.jobPreview.noUpcoming`,n)}):(0,Y.jsx)(`ul`,{className:`rounded border bg-background divide-y text-xs`,children:b.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`w-4 text-right text-muted-foreground text-[10px]`,children:t+1}),(0,Y.jsx)(qn,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`font-mono`,children:Ty(e,r)}),(0,Y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:x[t]==null?G(`engine.jobPreview.inNow`,n):W(`engine.jobPreview.inDelta`,n,{delta:x[t]})})]},t))})}),(0,Y.jsx)(jy,{title:G(`engine.jobPreview.handler`,n),icon:Xn,children:f?(0,Y.jsxs)(`div`,{className:`rounded border bg-background px-2.5 py-1.5 text-xs flex items-center gap-2`,children:[(0,Y.jsx)(Hn,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`code`,{className:`font-mono break-all`,children:f})]}):(0,Y.jsx)(`div`,{className:`text-xs text-amber-700`,children:G(`engine.jobPreview.noHandler`,n)})})]})})})}function ky(e){if(e<=0)return null;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<48?`${r}h`:`${Math.round(r/24)}d`}function Ay({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsxs)(`span`,{className:`text-muted-foreground w-12 shrink-0`,children:[e,`:`]}),(0,Y.jsx)(`span`,{className:`break-all`,children:t})]})}function jy({title:e,icon:t,children:n}){return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[t&&(0,Y.jsx)(t,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e})]}),n]})}function My({icon:e,label:t,tone:n=`gray`,mono:r=!1}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e&&(0,Y.jsx)(e,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`${n===`green`?`text-emerald-700`:`text-foreground`} ${r?`font-mono`:``}`,children:t})]})}var Ny=[{key:`objects`,label:`engine.translationPreview.category.objects`,icon:Wr,flat:!1},{key:`apps`,label:`engine.translationPreview.category.apps`,icon:ln,flat:!1},{key:`messages`,label:`engine.translationPreview.category.messages`,icon:Zr,flat:!0},{key:`validationMessages`,label:`engine.translationPreview.category.validationMessages`,icon:ki,flat:!0},{key:`globalActions`,label:`engine.translationPreview.category.globalActions`,icon:Kn,flat:!0},{key:`dashboards`,label:`engine.translationPreview.category.dashboards`,icon:Br,flat:!1},{key:`settings`,label:`engine.translationPreview.category.settings`,icon:Oi,flat:!0},{key:`metadataForms`,label:`engine.translationPreview.category.metadataForms`,icon:gr,flat:!1}];function Py({name:e,draft:t,locale:n}){let r=t,i=r.locale??r.language??`?`,a=r.label??r.name??e??``,o=r.description,s=r.data??r,c=Ny.map(e=>{let t=s?.[e.key];if(!t||typeof t!=`object`)return{...e,count:0,sample:[]};let n=Object.entries(t);return{...e,count:n.length,sample:n.slice(0,5)}}),l=c.reduce((e,t)=>e+t.count,0),u=c.filter(e=>e.count>0).length,d=Math.round(u/Ny.length*100);return l===0?(0,Y.jsx)(X,{hint:`translation · ${i}`,children:(0,Y.jsx)(Pf,{children:G(`engine.translationPreview.empty`,n)})}):(0,Y.jsx)(X,{hint:`translation · ${i} · ${l} keys`,children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-muted/30 p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(Rr,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate`,children:a}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-emerald-50 border border-emerald-200 px-1.5 py-0.5 text-[10px] font-mono text-emerald-800`,children:[(0,Y.jsx)(or,{className:`h-3 w-3`}),` `,i]})]}),o&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:o}),(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 text-[11px]`,children:[(0,Y.jsx)(Tr,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:G(`engine.translationPreview.coverage`,n)}),(0,Y.jsx)(`div`,{className:`h-1.5 w-32 rounded-full bg-muted overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${d}%`}})}),(0,Y.jsxs)(`span`,{className:`font-mono`,children:[u,`/`,Ny.length,` (`,d,`%)`]}),(0,Y.jsx)(`span`,{className:`ml-3 text-muted-foreground`,children:W(`engine.translationPreview.totalKeys`,n,{count:l})})]})]})]})}),(0,Y.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:c.map(e=>(0,Y.jsx)(Fy,{cat:e,locale:n},e.key))})]})})})}function Fy({cat:e,locale:t}){let n=e.icon;return(0,Y.jsxs)(`div`,{className:`rounded border bg-background ${e.count===0?`opacity-60`:``}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b px-2.5 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(n,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:G(e.label,t)})]}),(0,Y.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-mono`,children:e.count})]}),(0,Y.jsx)(`div`,{className:`px-2.5 py-1.5 min-h-[3.5rem]`,children:e.count===0?(0,Y.jsx)(ye,{className:`text-[11px] italic`,children:G(`engine.translationPreview.categoryEmpty`,t)}):(0,Y.jsxs)(`ul`,{className:`space-y-0.5 text-[11px]`,children:[e.sample.map(([n,r])=>(0,Y.jsxs)(`li`,{className:`flex items-baseline gap-2 truncate`,children:[(0,Y.jsx)(`code`,{className:`font-mono text-muted-foreground shrink-0`,children:n}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:Iy(r,e.flat,t)})]},n)),e.count>e.sample.length&&(0,Y.jsx)(`li`,{className:`text-[10px] text-muted-foreground italic`,children:W(`engine.translationPreview.more`,t,{count:e.count-e.sample.length})})]})})]})}function Iy(e,t,n){if(t)return typeof e==`string`?`"${e}"`:e==null?`∅`:String(e);if(e&&typeof e==`object`){let t=Object.keys(e).length;return W(`engine.translationPreview.keyCount`,n,{count:t})}return String(e??`∅`)}function Ly({name:e,draft:t,locale:n}){let r=t,i=String(r.name??e??``),a=String(r.label??i),o=r.description??``;return i?(0,Y.jsx)(X,{hint:`position`,children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-muted/30 p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(Qi,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate`,children:a}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:i})]}),o&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:o})]})]})}),(0,Y.jsx)(`div`,{className:`rounded border border-blue-200 bg-blue-50 p-2.5 text-[11px] text-blue-900`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,Y.jsx)(Ai,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:G(`engine.positionPreview.noAccess`,n)}),(0,Y.jsx)(`div`,{className:`opacity-90 mt-0.5`,children:Vp(G(`engine.positionPreview.bind`,n),{name:(0,Y.jsx)(`code`,{className:`font-mono`,children:i}),permissionSets:(0,Y.jsx)(`strong`,{children:G(`engine.positionPreview.permissionSets`,n)})})})]})]})})]})})}):(0,Y.jsx)(X,{hint:`position`,children:(0,Y.jsx)(Pf,{children:G(`engine.positionPreview.empty`,n)})})}function Ry({name:e,draft:t,locale:n}){let r=t,i=String(r.name??e??``),a=String(r.label??i),o=r.description??``,s=r.instructions??``,c=Array.isArray(r.tools)?r.tools:[],l=Array.isArray(r.triggerConditions)?r.triggerConditions:[],u=r.active!==!1,d=r.model??void 0;return i?(0,Y.jsx)(X,{hint:`skill`,children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-muted/30 p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(Fi,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate`,children:a}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:i})]}),o&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:o}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]`,children:[(0,Y.jsx)(Vy,{icon:hi,label:G(u?`engine.skillPreview.active`:`engine.skillPreview.disabled`,n),tone:u?`green`:`gray`}),d&&(0,Y.jsx)(Vy,{label:W(`engine.skillPreview.model`,n,{model:d}),mono:!0})]})]})]})}),(0,Y.jsx)(By,{title:G(`engine.skillPreview.instructions`,n),icon:gn,children:s?(0,Y.jsx)(`pre`,{className:`rounded border bg-background p-2.5 text-xs font-mono whitespace-pre-wrap break-words max-h-64 overflow-auto`,children:s}):(0,Y.jsx)(`div`,{className:`text-xs text-amber-700`,children:G(`engine.skillPreview.noInstructions`,n)})}),(0,Y.jsxs)(By,{title:W(`engine.skillPreview.tools`,n,{count:c.length}),icon:ta,children:[c.length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.skillPreview.noTools`,n)}):(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:c.map(e=>{let t=e.includes(`*`);return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-mono border ${t?`border-amber-300 bg-amber-50 text-amber-900`:`border-border bg-muted/40`}`,children:[t&&(0,Y.jsx)(pn,{className:`h-3 w-3`}),e]},e)})}),c.some(e=>e.includes(`*`))&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-amber-700`,children:G(`engine.skillPreview.wildcardNote`,n)})]}),l.length>0&&(0,Y.jsxs)(By,{title:W(`engine.skillPreview.triggerConditions`,n,{count:l.length}),icon:wr,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-background overflow-hidden`,children:(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`bg-muted/30 text-left text-[10px] uppercase tracking-wider text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 font-medium`,children:G(`engine.skillPreview.col.field`,n)}),(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 font-medium`,children:G(`engine.skillPreview.col.operator`,n)}),(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 font-medium`,children:G(`engine.skillPreview.col.value`,n)})]})}),(0,Y.jsx)(`tbody`,{className:`divide-y`,children:l.map((e,t)=>(0,Y.jsxs)(`tr`,{className:`align-top`,children:[(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5 font-mono break-all`,children:zy(e.field,n)}),(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5 font-mono text-muted-foreground`,children:zy(e.operator,n)}),(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5 font-mono break-all`,children:zy(e.value,n)})]},t))})]})}),l.length>1&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:G(`engine.skillPreview.allMustHold`,n)})]})]})})}):(0,Y.jsx)(X,{hint:`skill`,children:(0,Y.jsx)(Pf,{children:G(`engine.skillPreview.empty`,n)})})}function zy(e,t){return typeof e==`string`&&e!==``?e:Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):(0,Y.jsx)(`span`,{className:`text-amber-700`,title:G(`engine.skillPreview.missingTitle`,t),children:G(`engine.skillPreview.missing`,t)})}function By({title:e,icon:t,children:n}){return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[t&&(0,Y.jsx)(t,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e})]}),n]})}function Vy({icon:e,label:t,tone:n=`gray`,mono:r=!1}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e&&(0,Y.jsx)(e,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`${n===`green`?`text-emerald-700`:`text-foreground`} ${r?`font-mono`:``}`,children:t})]})}var Hy=class extends Error{constructor(){super(`external_service_unavailable`),this.name=`ExternalServiceUnavailableError`}},Uy=l();function Wy(){return``.replace(/\/+$/,``)}function Gy(e){return`${Wy()}/api/v1/datasources/${encodeURIComponent(e)}/external`}async function Ky(e){try{return await e.json()}catch{return}}function qy(e){let t=e?.error;if(!t||typeof t!=`object`)return``;let{code:n}=t;return typeof n==`string`?n:``}async function Jy(e,t){let n=await Ky(e);if(!e.ok)throw e.status===503&&qy(n)===`SERVICE_UNAVAILABLE`?new Hy:Error(La(n)??`${e.status} ${e.statusText}`);let r=n;if(r?.success!==!0||!r.data||typeof r.data!=`object`)throw Error(`${t} answered ${e.status} without the { success: true, data } envelope.`);return r.data}async function Yy(e,t={}){let n=t.schema?`?schema=${encodeURIComponent(t.schema)}`:``,r=`${Gy(e)}/tables${n}`;return(await Jy(await Uy(r,{method:`GET`,headers:{Accept:`application/json`}}),r)).tables}async function Xy(e,t,n={}){let r=`${Gy(e)}/tables/${encodeURIComponent(t)}/draft`;return(await Jy(await Uy(r,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(n)}),r)).draft}async function Zy(e){let t=`${Gy(e)}/refresh-catalog`;return(await Jy(await Uy(t,{method:`POST`,headers:{Accept:`application/json`}}),t)).catalog}async function Qy(e){let t=`${Gy(e)}/validate`;return Jy(await Uy(t,{method:`POST`,headers:{Accept:`application/json`}}),t)}async function $y(e){an(`object`,e.definition,`importObjectDraft`);let t=await Uy(`${Wy()}/api/v1/meta/object/${encodeURIComponent(e.name)}`,{method:`PUT`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(e.definition)});if(t.ok)return;let n=await Ky(t),r=n?.error;throw Error(La(n)??(typeof r==`string`&&r?r:`${t.status} ${t.statusText}`))}var eb=Symbol(`external-service-unavailable`);function tb({datasource:e,table:t,open:n,onOpenChange:r,onImported:i}){let a=$o(),[o,s]=J.useState(`loading`),[c,l]=J.useState(null),[u,d]=J.useState(null);J.useEffect(()=>{if(!n||!t)return;let r=!1;return s(`loading`),l(null),d(null),(async()=>{try{let n=await Xy(e,t.name,{remoteSchema:t.schema});if(r)return;l(n),s(`ready`)}catch(e){if(r)return;d(e instanceof Hy?eb:e instanceof Error?e.message:String(e)),s(`error`)}})(),()=>{r=!0}},[n,t,e]);let f=J.useCallback(async()=>{if(c){s(`importing`),d(null);try{await $y(c),s(`done`),i?.(c.name)}catch(e){d(e instanceof Error?e.message:String(e)),s(`ready`)}}},[c,i]),p=t?[t.schema,t.name].filter(Boolean).join(`.`):``,m=u===eb?G(`engine.externalDatasource.unavailable`,a):u;return(0,Y.jsx)(lt,{open:n,onOpenChange:r,children:(0,Y.jsxs)(Re,{className:`max-w-2xl`,children:[(0,Y.jsxs)(Te,{children:[(0,Y.jsxs)(ke,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(nr,{className:`h-4 w-4`}),G(`engine.externalDatasource.import.title`,a)]}),(0,Y.jsx)(Be,{children:Vp(G(`engine.externalDatasource.import.intro`,a),{table:(0,Y.jsx)(`span`,{className:`font-mono`,children:p}),datasource:(0,Y.jsx)(`span`,{className:`font-mono`,children:e})})})]}),o===`loading`&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 py-8 justify-center text-sm text-muted-foreground`,children:[(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`}),` `,G(`engine.externalDatasource.import.generating`,a)]}),o===`error`&&(0,Y.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:m}),o===`done`&&c&&(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Y.jsx)(zn,{className:`h-8 w-8 text-emerald-500`}),(0,Y.jsx)(`div`,{className:`text-sm`,children:Vp(G(`engine.externalDatasource.import.done`,a),{name:(0,Y.jsx)(`span`,{className:`font-mono font-medium`,children:c.name})})}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:G(`engine.externalDatasource.import.doneNext`,a)})]}),(o===`ready`||o===`importing`)&&c&&(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:G(`engine.externalDatasource.import.objectName`,a)}),(0,Y.jsx)(`span`,{className:`font-mono font-medium`,children:c.name})]}),m&&(0,Y.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/5 p-2 text-xs text-destructive`,children:m}),c.review.length>0&&(0,Y.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 dark:bg-amber-950/20 p-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-300`,children:[(0,Y.jsx)(Ji,{className:`h-3.5 w-3.5`}),W(c.review.length===1?`engine.externalDatasource.import.reviewOne`:`engine.externalDatasource.import.reviewOther`,a,{count:c.review.length})]}),(0,Y.jsx)(`ul`,{className:`mt-1.5 space-y-1 text-[11px] text-amber-900/90 dark:text-amber-200/80`,children:c.review.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-wrap gap-x-1.5`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e.column}),(0,Y.jsxs)(`span`,{className:`text-amber-700/70 dark:text-amber-400/70`,children:[`(`,e.remoteType,`)`]}),(0,Y.jsxs)(`span`,{children:[`— `,e.note]})]},e.column))})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,Y.jsx)(fr,{className:`h-3 w-3`}),` `,G(`engine.externalDatasource.import.source`,a)]}),(0,Y.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded border bg-muted/30 p-2.5 text-[11px] leading-relaxed font-mono`,children:c.source})]})]}),(0,Y.jsx)(Ue,{children:o===`done`?(0,Y.jsx)(B,{onClick:()=>r(!1),children:G(`engine.close`,a)}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{variant:`ghost`,onClick:()=>r(!1),disabled:o===`importing`,children:G(`engine.cancel`,a)}),(0,Y.jsx)(B,{onClick:f,disabled:o!==`ready`||!c,children:o===`importing`?(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(H,{className:`h-3.5 w-3.5 animate-spin`}),` `,G(`engine.externalDatasource.import.importing`,a)]}):G(`engine.externalDatasource.import.title`,a)})]})})]})})}function nb({datasource:e}){let t=nn(),n=$o(),[r,i]=J.useState(`idle`),[a,o]=J.useState([]),[s,c]=J.useState(null),[l,u]=J.useState(``),[d,f]=J.useState(null),[p,m]=J.useState(!1),h=J.useCallback(async()=>{i(`loading`),c(null);try{let t=await Yy(e);o(t),i(`loaded`)}catch(e){e instanceof Hy?i(`unavailable`):(c(e instanceof Error?e.message:String(e)),i(`error`))}},[e]);J.useEffect(()=>{h()},[h]);let g=J.useMemo(()=>{let e=l.trim().toLowerCase();return e?a.filter(t=>[t.schema,t.name].filter(Boolean).join(`.`).toLowerCase().includes(e)):a},[a,l]),_=e=>{f(e),m(!0)};return r===`unavailable`?(0,Y.jsx)(rb,{locale:n}):(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Y.jsx)(Di,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:G(`engine.externalDatasource.browser.filter`,n),className:`w-full rounded border bg-background pl-7 pr-2 py-1.5 text-xs outline-none focus:ring-1 focus:ring-ring`})]}),(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:()=>void h(),disabled:r===`loading`,children:[r===`loading`?(0,Y.jsx)(H,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(vi,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`ml-1.5`,children:G(`engine.externalDatasource.browser.refresh`,n)})]})]}),s&&(0,Y.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/5 p-2.5 text-xs text-destructive`,children:s}),r===`loading`&&a.length===0&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground`,children:[(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`}),` `,G(`engine.externalDatasource.browser.introspecting`,n)]}),r===`loaded`&&g.length===0&&(0,Y.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:a.length===0?G(`engine.externalDatasource.browser.noRemoteTables`,n):G(`engine.externalDatasource.browser.noMatch`,n)}),g.length>0&&(0,Y.jsx)(`div`,{className:`rounded border bg-background overflow-hidden`,children:(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{className:`bg-muted/40 text-muted-foreground`,children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 text-left font-medium`,children:G(`engine.externalDatasource.browser.colTable`,n)}),(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 text-right font-medium`,children:G(`engine.externalDatasource.browser.colColumns`,n)}),(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 text-right font-medium`,children:G(`engine.externalDatasource.browser.colRows`,n)}),(0,Y.jsx)(`th`,{className:`px-2.5 py-1.5 w-px`})]})}),(0,Y.jsx)(`tbody`,{className:`divide-y`,children:g.map(e=>{let r=[e.schema,e.name].filter(Boolean).join(`.`);return(0,Y.jsxs)(`tr`,{className:`hover:bg-muted/30`,children:[(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-mono`,children:[(0,Y.jsx)(Vi,{className:`h-3.5 w-3.5 text-muted-foreground`}),e.schema&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.schema,`.`]}),(0,Y.jsx)(`span`,{className:`font-medium`,children:e.name})]})}),(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5 text-right tabular-nums`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,Y.jsx)(Qn,{className:`h-3 w-3`}),e.columnCount]})}),(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5 text-right tabular-nums text-muted-foreground`,children:typeof e.rowCountEstimate==`number`?e.rowCountEstimate.toLocaleString(t):`—`}),(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5`,children:(0,Y.jsxs)(B,{variant:`ghost`,size:`sm`,onClick:()=>_(e),children:[(0,Y.jsx)(ar,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`ml-1.5`,children:G(`engine.externalDatasource.browser.import`,n)})]})})]},r)})})]})}),(0,Y.jsx)(tb,{datasource:e,table:d,open:p,onOpenChange:m})]})}function rb({locale:e}){return(0,Y.jsx)(`div`,{className:`rounded border border-amber-300 bg-amber-50 dark:bg-amber-950/20 p-3 text-xs text-amber-900 dark:text-amber-200`,children:Vp(G(`engine.externalDatasource.browser.unavailable`,e),{service:(0,Y.jsx)(`span`,{className:`font-mono`,children:`external-datasource`})})})}var ib={missing_table:`engine.externalDatasource.diff.missingTable`,missing_column:`engine.externalDatasource.diff.missingColumn`,type_mismatch:`engine.externalDatasource.diff.typeMismatch`,nullability_mismatch:`engine.externalDatasource.diff.nullabilityMismatch`,unmapped_column:`engine.externalDatasource.diff.unmappedColumn`,pk_mismatch:`engine.externalDatasource.diff.pkMismatch`,index_mismatch:`engine.externalDatasource.diff.indexMismatch`,unmapped_index:`engine.externalDatasource.diff.unmappedIndex`,default_mismatch:`engine.externalDatasource.diff.defaultMismatch`,unreachable:`engine.externalDatasource.diff.unreachable`};function ab({datasource:e}){let t=$o(),[n,r]=J.useState(`idle`),[i,a]=J.useState([]),[o,s]=J.useState(null),[c,l]=J.useState(null),u=J.useCallback(async()=>{r(`running`),l(null);try{let t=await Qy(e);a(t.results),s(t.ok),r(`done`)}catch(e){e instanceof Hy?r(`unavailable`):(l(e instanceof Error?e.message:String(e)),r(`error`))}},[e]);return n===`unavailable`?(0,Y.jsx)(`div`,{className:`rounded border border-amber-300 bg-amber-50 dark:bg-amber-950/20 p-3 text-xs text-amber-900 dark:text-amber-200`,children:G(`engine.externalDatasource.check.unavailable`,t)}):(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Vp(G(`engine.externalDatasource.check.intro`,t),{datasource:(0,Y.jsx)(`span`,{className:`font-mono`,children:e})})}),(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:()=>void u(),disabled:n===`running`,children:[n===`running`?(0,Y.jsx)(H,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(Hn,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`ml-1.5`,children:G(`engine.externalDatasource.check.run`,t)})]})]}),c&&(0,Y.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/5 p-2.5 text-xs text-destructive`,children:c}),n===`done`&&o!==null&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded border p-2.5 text-sm ${o?`border-emerald-300 bg-emerald-50 dark:bg-emerald-950/20 text-emerald-800 dark:text-emerald-300`:`border-destructive/40 bg-destructive/5 text-destructive`}`,children:[o?(0,Y.jsx)(zn,{className:`h-4 w-4`}):(0,Y.jsx)(ki,{className:`h-4 w-4`}),o?W(i.length===1?`engine.externalDatasource.check.allMatchOne`:`engine.externalDatasource.check.allMatchOther`,t,{count:i.length}):W(i.length===1?`engine.externalDatasource.check.divergeOne`:`engine.externalDatasource.check.divergeOther`,t,{diverged:i.filter(e=>!e.ok).length,count:i.length})]}),n===`done`&&i.length===0&&(0,Y.jsx)(`div`,{className:`py-8 text-center text-sm text-muted-foreground`,children:G(`engine.externalDatasource.check.noObjects`,t)}),i.length>0&&(0,Y.jsx)(`ul`,{className:`space-y-2`,children:i.map(e=>(0,Y.jsx)(ob,{result:e,locale:t},e.object))})]})}function ob({result:e,locale:t}){return(0,Y.jsxs)(`li`,{className:`rounded border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[e.ok?(0,Y.jsx)(Ai,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,Y.jsx)(ki,{className:`h-3.5 w-3.5 text-destructive`}),(0,Y.jsx)(`span`,{className:`font-mono text-xs font-medium`,children:e.object}),!e.ok&&(0,Y.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:W(e.diffs.length===1?`engine.externalDatasource.check.diffsOne`:`engine.externalDatasource.check.diffsOther`,t,{count:e.diffs.length})})]}),e.diffs.length>0&&(0,Y.jsx)(`ul`,{className:`border-t divide-y`,children:e.diffs.map((e,n)=>(0,Y.jsx)(sb,{diff:e,locale:t},`${e.kind}:${e.column??``}:${n}`))})]})}function sb({diff:e,locale:t}){let n=ib[e.kind],r=[e.remoteSchema,e.remoteName].filter(Boolean).join(`.`),i=e.severity===`error`;return(0,Y.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 px-2.5 py-1.5 text-[11px]`,children:[(0,Y.jsx)(`span`,{className:`rounded px-1 py-0.5 font-medium uppercase tracking-wide text-[9px] ${i?`bg-destructive/10 text-destructive`:`bg-amber-100 text-amber-800 dark:bg-amber-950/40 dark:text-amber-300`}`,children:n?G(n,t):e.kind}),r&&(0,Y.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:r}),e.column&&(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`.`,e.column]}),(e.expected!==void 0||e.actual!==void 0)&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:Vp(G(`engine.externalDatasource.check.expectedActual`,t),{expected:(0,Y.jsx)(`span`,{className:`font-mono`,children:e.expected??`—`}),actual:(0,Y.jsx)(`span`,{className:`font-mono`,children:e.actual??`—`})})})]})}function cb({datasource:e,schemaMode:t,allowWrites:n,locale:r}){let i=nn(),[a,o]=J.useState(null),[s,c]=J.useState(!1),[l,u]=J.useState(null),d=J.useCallback(async()=>{if(e){c(!0),u(null);try{let t=await Zy(e);o(t)}catch(e){u(e instanceof Hy?G(`engine.externalDatasource.unavailable`,r):e instanceof Error?e.message:String(e))}finally{c(!1)}}},[e,r]);return e?(0,Y.jsxs)(`div`,{className:`rounded border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b bg-muted/30 px-3 py-2`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium`,children:[(0,Y.jsx)(tr,{className:`h-4 w-4 text-sky-500`}),G(`engine.externalDatasource.title`,r)]}),(0,Y.jsx)(`span`,{className:`rounded border bg-background px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:t??`external`}),(0,Y.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider ${n?`bg-amber-100 text-amber-800 dark:bg-amber-950/40 dark:text-amber-300`:`bg-muted text-muted-foreground`}`,children:G(n?`engine.externalDatasource.writesAllowed`:`engine.externalDatasource.readOnly`,r)}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[a?.snapshotAt&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(qn,{className:`h-3 w-3`}),W(`engine.externalDatasource.snapshot`,r,{time:lb(a.snapshotAt,i)})]}),(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:()=>void d(),disabled:s,children:[s?(0,Y.jsx)(H,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(vi,{className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`ml-1.5`,children:G(`engine.externalDatasource.refresh`,r)})]})]})]}),l&&(0,Y.jsx)(`div`,{className:`border-b border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:l}),(0,Y.jsxs)(Ge,{defaultValue:`tables`,className:`p-3`,children:[(0,Y.jsxs)(at,{children:[(0,Y.jsx)(_t,{value:`tables`,children:G(`engine.externalDatasource.tables`,r)}),(0,Y.jsx)(_t,{value:`validation`,children:G(`engine.externalDatasource.validation`,r)})]}),(0,Y.jsx)(pe,{value:`tables`,className:`mt-3`,children:(0,Y.jsx)(nb,{datasource:e})}),(0,Y.jsx)(pe,{value:`validation`,className:`mt-3`,children:(0,Y.jsx)(ab,{datasource:e})})]})]}):(0,Y.jsx)(`div`,{className:`rounded border bg-muted/20 p-3 text-xs text-muted-foreground`,children:G(`engine.externalDatasource.saveFirst`,r)})}function lb(e,t){let n=new Date(e).getTime();if(Number.isNaN(n))return e;try{return new Date(n).toLocaleString(t)}catch{return e}}var ub=/pass|secret|key|token|credential|auth/i;function db(e){return ub.test(e)}function fb(e){return e==null||e===``?`∅`:`••••••`}function pb(e,t){return e==null?`∅`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`[${e.length}]`:typeof e==`object`?W(`engine.datasourcePreview.keyCount`,t,{count:Object.keys(e).length}):String(e)}function mb({name:e,draft:t,locale:n}){let r=t,i=String(r.name??e??``),a=String(r.label??i),o=r.description??``,s=r.driver??G(`engine.datasourcePreview.unknownDriver`,n),c=r.active!==!1,l=r.config??{},u=r.pool,d=r.ssl,f=r.schemaMode??`managed`,p=f!==`managed`,m=!!(r.external??void 0)?.allowWrites,h=Object.entries(l);return!i&&h.length===0?(0,Y.jsx)(X,{hint:`datasource`,children:(0,Y.jsx)(Pf,{children:G(`engine.datasourcePreview.empty`,n)})}):(0,Y.jsx)(X,{hint:`datasource · ${s}`,children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-muted/30 p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(nr,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate`,children:a}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:i})]}),o&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:o}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border bg-background px-1.5 py-0.5 font-mono`,children:[(0,Y.jsx)(jr,{className:`h-3 w-3 text-muted-foreground`}),` `,s]}),(0,Y.jsx)(_b,{icon:hi,label:G(c?`engine.datasourcePreview.active`:`engine.datasourcePreview.disabled`,n),tone:c?`green`:`gray`})]})]})]})}),p&&(0,Y.jsx)(cb,{datasource:String(e??``),schemaMode:f,allowWrites:m,locale:n}),(0,Y.jsx)(gb,{title:G(`engine.datasourcePreview.connection`,n),icon:Kr,children:h.length===0?(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.datasourcePreview.noConfig`,n)}):(0,Y.jsx)(`div`,{className:`rounded border bg-background overflow-hidden`,children:(0,Y.jsx)(`table`,{className:`w-full text-xs`,children:(0,Y.jsx)(`tbody`,{className:`divide-y`,children:h.map(([e,t])=>{let r=db(e);return(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5 align-top w-40 font-mono text-muted-foreground`,children:e}),(0,Y.jsx)(`td`,{className:`px-2.5 py-1.5 font-mono break-all`,children:r?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{children:fb(t)}),(0,Y.jsx)(`span`,{className:`rounded bg-amber-50 border border-amber-200 px-1 py-0.5 text-[9px] uppercase tracking-wider text-amber-800`,children:G(`engine.datasourcePreview.redacted`,n)})]}):pb(t,n)})]},e)})})})})}),(0,Y.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,Y.jsx)(hb,{title:G(`engine.datasourcePreview.pool`,n),icon:sn,value:u,locale:n}),(0,Y.jsx)(hb,{title:`SSL`,icon:Ai,value:typeof d==`boolean`?{enabled:d}:d,locale:n})]})]})})})}function hb({title:e,icon:t,value:n,locale:r}){let i=n&&typeof n==`object`&&Object.keys(n).length>0;return(0,Y.jsxs)(`div`,{className:`rounded border bg-background ${i?``:`opacity-60`}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b px-2.5 py-1.5`,children:[(0,Y.jsx)(t,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:e})]}),(0,Y.jsx)(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:i?(0,Y.jsx)(`dl`,{className:`space-y-0.5`,children:Object.entries(n).slice(0,6).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2 truncate`,children:[(0,Y.jsxs)(`dt`,{className:`text-muted-foreground font-mono shrink-0`,children:[e,`:`]}),(0,Y.jsx)(`dd`,{className:`font-mono truncate`,children:db(e)?fb(t):pb(t,r)})]},e))}):(0,Y.jsx)(ye,{className:`text-[11px] italic`,children:G(`engine.datasourcePreview.notConfigured`,r)})})]})}function gb({title:e,icon:t,children:n}){return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[t&&(0,Y.jsx)(t,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e})]}),n]})}function _b({icon:e,label:t,tone:n=`gray`,mono:r=!1}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e&&(0,Y.jsx)(e,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`${n===`green`?`text-emerald-700`:n===`amber`?`text-amber-700`:`text-foreground`} ${r?`font-mono`:``}`,children:t})]})}function vb(e){if(e){if(typeof e==`string`)return e;if(typeof e==`object`&&typeof e.source==`string`)return e.source}}function yb(e){switch(e){case`error`:return{ring:`border-red-200 bg-red-50 dark:border-red-900 dark:bg-red-950/40`,text:`text-red-700 dark:text-red-300`,icon:ni};case`warning`:return{ring:`border-amber-200 bg-amber-50 dark:border-amber-900 dark:bg-amber-950/40`,text:`text-amber-800 dark:text-amber-300`,icon:Ji};default:return{ring:`border-blue-200 bg-blue-50 dark:border-blue-900 dark:bg-blue-950/40`,text:`text-blue-800 dark:text-blue-300`,icon:Fr}}}function bb({name:e,draft:t,locale:n}){let r=t,i=String(r.name??e??``),a=String(r.label??i),o=r.description??``,s=r.type??`script`,c=r.message??``,l=r.severity??`error`,u=r.active!==!1,d=Array.isArray(r.events)?r.events:[],f=r.priority,p=Array.isArray(r.tags)?r.tags:[],m=yb(l);return i?(0,Y.jsx)(X,{hint:`validation · ${s}`,children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(`div`,{className:`rounded border bg-muted/30 p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(ki,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate`,children:a}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:i}),(0,Y.jsx)(`span`,{className:`rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono`,children:s})]}),o&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:o}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]`,children:[(0,Y.jsx)(Eb,{icon:hi,label:G(u?`engine.validationPreview.active`:`engine.validationPreview.disabled`,n),tone:u?`green`:`gray`}),f!=null&&(0,Y.jsx)(Eb,{label:W(`engine.validationPreview.priority`,n,{priority:f})}),d.length>0&&(0,Y.jsx)(Eb,{label:W(`engine.validationPreview.on`,n,{events:d.join(`, `)})})]})]})]})}),(0,Y.jsx)(`div`,{className:`rounded border p-2.5 text-xs ${m.ring}`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 ${m.text}`,children:[(0,Y.jsx)(m.icon,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`font-medium uppercase tracking-wider text-[10px]`,children:l}),(0,Y.jsx)(`div`,{className:`font-normal mt-0.5 text-foreground`,children:c||(0,Y.jsx)(`span`,{className:`italic text-muted-foreground`,children:G(`engine.validationPreview.noMessage`,n)})})]})]})}),(0,Y.jsx)(Sb,{type:s,d:r,locale:n}),p.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground uppercase tracking-wider mb-1`,children:G(`engine.validationPreview.tags`,n)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:p.map(e=>(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded border bg-muted/40 px-1.5 py-0.5 text-[11px] font-mono`,children:e},e))})]})]})})}):(0,Y.jsx)(X,{hint:`validation`,children:(0,Y.jsx)(Pf,{children:G(`engine.validationPreview.empty`,n)})})}var xb={unique:`engine.validationPreview.removed.unique`,async:`engine.validationPreview.removed.async`,custom:`engine.validationPreview.removed.custom`};function Sb({type:e,d:t,locale:n}){let r=xb[e];if(r)return(0,Y.jsx)(Tb,{title:G(`engine.validationPreview.notARule`,n),icon:ki,children:(0,Y.jsxs)(`div`,{className:`rounded border border-amber-200 bg-amber-50 p-2.5 text-xs text-amber-900 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:Vp(G(`engine.validationPreview.removedType`,n),{type:(0,Y.jsx)(`code`,{className:`font-mono`,children:e})})}),(0,Y.jsx)(`div`,{className:`mt-1`,children:G(r,n)})]})});switch(e){case`script`:return(0,Y.jsx)(Tb,{title:G(`engine.validationPreview.condition`,n),icon:Xn,children:(0,Y.jsx)(wb,{value:vb(t.condition),locale:n})});case`conditional`:{let e=t.then,r=t.otherwise;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Tb,{title:G(`engine.validationPreview.when`,n),icon:Xn,children:(0,Y.jsx)(wb,{value:vb(t.when),locale:n})}),(0,Y.jsx)(Tb,{title:G(`engine.validationPreview.thenApply`,n),icon:ki,children:(0,Y.jsx)(Cb,{rule:e,emptyHint:G(`engine.validationPreview.noNested`,n),locale:n})}),r&&(0,Y.jsx)(Tb,{title:G(`engine.validationPreview.otherwiseApply`,n),icon:ki,children:(0,Y.jsx)(Cb,{rule:r,emptyHint:`—`,locale:n})})]})}case`state_machine`:{let e=t.transitions&&typeof t.transitions==`object`&&!Array.isArray(t.transitions)?t.transitions:{},r=Object.entries(e),i=t.field,a=Array.isArray(t.initialStates)?t.initialStates:[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Tb,{title:i?W(`engine.validationPreview.transitionsOn`,n,{field:i}):G(`engine.validationPreview.transitions`,n),icon:ea,children:r.length===0?(0,Y.jsx)(`div`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:G(`engine.validationPreview.noTransitions`,n)}):(0,Y.jsx)(`ul`,{className:`rounded border bg-background divide-y text-xs`,children:r.map(([e,t])=>(0,Y.jsxs)(`li`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e}),(0,Y.jsx)(dn,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`font-mono text-emerald-700 dark:text-emerald-400`,children:Array.isArray(t)&&t.length>0?t.join(` | `):G(`engine.validationPreview.deadEnd`,n)})]},e))})}),a.length>0&&(0,Y.jsx)(Tb,{title:G(`engine.validationPreview.createdIn`,n),icon:Ni,children:(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>(0,Y.jsx)(`span`,{className:`rounded border bg-muted/40 px-1.5 py-0.5 text-[11px] font-mono`,children:e},e))})})]})}case`format`:{let e=t.regex,r=t.format,i=t.field;return(0,Y.jsx)(Tb,{title:i?W(`engine.validationPreview.formatOn`,n,{field:i}):G(`engine.validationPreview.format`,n),icon:yi,children:(0,Y.jsxs)(`div`,{className:`rounded border bg-background p-2.5 text-xs space-y-1`,children:[r&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:G(`engine.validationPreview.builtIn`,n)}),` `,(0,Y.jsx)(`code`,{className:`font-mono`,children:r})]}),e&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:G(`engine.validationPreview.regex`,n)}),` `,(0,Y.jsx)(`code`,{className:`font-mono break-all`,children:e})]}),!r&&!e&&(0,Y.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:G(`engine.validationPreview.noFormat`,n)})]})})}case`cross_field`:{let e=Array.isArray(t.fields)?t.fields:[],r=vb(t.condition);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Tb,{title:G(`engine.validationPreview.fieldsInvolved`,n),icon:Ni,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[e.map(e=>(0,Y.jsx)(`span`,{className:`rounded border bg-muted/40 px-1.5 py-0.5 text-[11px] font-mono`,children:e},e)),e.length===0&&(0,Y.jsx)(ye,{className:`text-xs italic`,children:G(`engine.validationPreview.none`,n)})]})}),(0,Y.jsx)(Tb,{title:G(`engine.validationPreview.crossFieldCondition`,n),icon:Xn,children:(0,Y.jsx)(wb,{value:r,locale:n})})]})}case`json_schema`:{let e=t.field,r=t.schema,i=r&&typeof r==`object`?JSON.stringify(r,null,2):void 0;return(0,Y.jsx)(Tb,{title:e?W(`engine.validationPreview.jsonSchemaOn`,n,{field:e}):`JSON Schema`,icon:bn,children:i?(0,Y.jsx)(`pre`,{className:`m-0 rounded border bg-background p-2.5 text-xs font-mono overflow-auto max-h-[240px]`,children:i}):(0,Y.jsx)(`div`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:G(`engine.validationPreview.noJsonSchema`,n)})})}default:return(0,Y.jsx)(Tb,{title:G(`engine.validationPreview.rule`,n),icon:ki,children:(0,Y.jsx)(`div`,{className:`rounded border bg-background p-2.5 text-xs text-muted-foreground italic`,children:W(`engine.validationPreview.unknownType`,n,{type:e})})})}}function Cb({rule:e,emptyHint:t,locale:n}){if(!e||typeof e!=`object`)return(0,Y.jsx)(`div`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:t});let r=String(e.type??``),i=vb(e.condition)??vb(e.when);return(0,Y.jsxs)(`div`,{className:`rounded border bg-background p-2.5 text-xs space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Y.jsx)(`span`,{className:`rounded border bg-muted/40 px-1.5 py-0.5 text-[10px] font-mono`,children:r||G(`engine.validationPreview.noType`,n)}),typeof e.name==`string`&&(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.name})]}),typeof e.message==`string`&&e.message&&(0,Y.jsx)(`div`,{className:`text-foreground`,children:e.message}),i&&(0,Y.jsx)(`pre`,{className:`m-0 rounded border bg-muted/30 p-2 font-mono whitespace-pre-wrap break-words`,children:i})]})}function wb({value:e,locale:t}){return e?(0,Y.jsx)(`pre`,{className:`rounded border bg-background p-2.5 text-xs font-mono whitespace-pre-wrap break-words`,children:e}):(0,Y.jsx)(`div`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:G(`engine.validationPreview.noExpression`,t)})}function Tb({title:e,icon:t,children:n}){return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[t&&(0,Y.jsx)(t,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e})]}),n]})}function Eb({icon:e,label:t,tone:n=`gray`,mono:r=!1}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e&&(0,Y.jsx)(e,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`${n===`green`?`text-emerald-700 dark:text-emerald-400`:`text-foreground`} ${r?`font-mono`:``}`,children:t})]})}var Db=J.lazy(()=>n(()=>import(`./plugin-charts-b-yVtmdI.js`).then(e=>e.t).then(e=>({default:e.ChartRenderer})),__vite__mapDeps([0]),import.meta.url));function Ob({draft:e,locale:t}){let n=Pt(),{fieldLabel:r}=en(),i=Qt(),a=nn(),o=e.object,s=J.useMemo(()=>(Array.isArray(e.measures)?e.measures:[]).map(e=>String(e?.name??``)).filter(Boolean),[e]),c=J.useMemo(()=>(Array.isArray(e.dimensions)?e.dimensions:[]).map(e=>String(e?.name??``)).filter(Boolean),[e]),l=J.useMemo(()=>{let t=Array.isArray(e.dimensions)?e.dimensions:[],n={};for(let e of t){let t=String(e?.name??``),r=String(e?.field??``);t&&r&&(n[t]=r)}return n},[e]),u=At(o,l,c),d=!!o&&s.length>0,[f,p]=J.useState({status:`idle`,rows:[]}),m=J.useCallback(async()=>{if(d){p({status:`loading`,rows:[]});try{let t=await n.queryDataset(e,{dimensions:c,measures:s});p({status:`ok`,rows:Array.isArray(t?.rows)?t.rows:[],fields:Array.isArray(t?.fields)?t.fields:[],object:t?.object})}catch(e){if(e?.code===`ANALYTICS_NOT_INSTALLED`){p({status:`not-installed`,rows:[]});return}p({status:`error`,rows:[],error:String(e?.message??e)})}}},[n,e,c,s,d]),h=`${o??``}|${c.join(`,`)}|${s.join(`,`)}`;if(J.useEffect(()=>{d&&m()},[h]),!o)return(0,Y.jsx)(X,{children:(0,Y.jsx)(Ff,{icon:(0,Y.jsx)(En,{className:`h-8 w-8`}),title:G(`engine.datasetPreview.pickObject`,t),description:G(`engine.datasetPreview.pickObjectHint`,t)})});if(s.length===0)return(0,Y.jsx)(X,{children:(0,Y.jsx)(Ff,{icon:(0,Y.jsx)(En,{className:`h-8 w-8`}),title:G(`engine.datasetPreview.addMeasure`,t),description:G(`engine.datasetPreview.addMeasureHint`,t)})});let g=f.status===`ok`?f.fields:void 0,_=f.status===`ok`?f.object:void 0,{measureField:v,headerLabel:y}=Ut(g,_,r,$t(i)),b=[...c,...s],x=Et(f.rows,u),S=e=>{let t=v(e)?.format;return typeof t==`string`&&t.includes(`%`)},C=s.filter(S),w=C.length>0&&C.length<s.length;return(0,Y.jsx)(X,{hint:`dataset · ${o}${c.length?` · by `+c.join(`, `):``}`,children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>void m(),disabled:f.status===`loading`,className:`inline-flex items-center gap-1.5 rounded-md border bg-background px-3 py-1.5 text-xs font-medium hover:bg-accent disabled:opacity-50`,children:[f.status===`loading`?(0,Y.jsx)(H,{className:`h-3.5 w-3.5 animate-spin`}):(0,Y.jsx)(En,{className:`h-3.5 w-3.5`}),G(`engine.datasetPreview.run`,t)]}),(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[W(s.length===1?`engine.datasetPreview.measureOne`:`engine.datasetPreview.measureOther`,t,{count:s.length}),` · `,W(c.length===1?`engine.datasetPreview.dimensionOne`:`engine.datasetPreview.dimensionOther`,t,{count:c.length})]})]}),f.status===`error`&&(0,Y.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:[(0,Y.jsx)(Ji,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`break-words`,children:f.error})]}),f.status===`not-installed`&&(0,Y.jsx)(Ff,{icon:(0,Y.jsx)(ri,{className:`h-8 w-8`}),title:G(`engine.datasetPreview.notInstalled`,t),description:G(`engine.datasetPreview.notInstalledHint`,t)}),f.status===`ok`&&f.rows.length===0&&(0,Y.jsx)(Ff,{icon:(0,Y.jsx)(En,{className:`h-8 w-8`}),title:G(`engine.datasetPreview.noRows`,t),description:G(`engine.datasetPreview.noRowsHint`,t)}),f.rows.length>0&&c.length>=1&&(0,Y.jsx)(Z,{fallbackHint:G(`engine.datasetPreview.chartFailed`,t),children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`h-[260px] flex items-center justify-center text-xs text-muted-foreground`,children:(0,Y.jsx)(H,{className:`h-4 w-4 animate-spin`})}),children:(0,Y.jsxs)(`div`,{className:`rounded-md border p-2`,children:[(0,Y.jsx)(Db,{schema:{data:x,xAxisKey:c[0],chartType:w?`combo`:`bar`,series:s.map(e=>({dataKey:e,label:y(e),chartType:w&&S(e)?`line`:`bar`}))}}),w&&(0,Y.jsx)(`p`,{className:`mt-1 px-1 text-[10px] text-muted-foreground`,children:W(`engine.datasetPreview.ratioAxis`,t,{measures:C.map(y).join(`, `)})})]})})}),f.rows.length>0&&(0,Y.jsx)(`div`,{className:`overflow-auto max-h-[60vh] rounded-md border`,children:(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{className:`bg-muted/40`,children:(0,Y.jsx)(`tr`,{children:b.map(e=>(0,Y.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:y(e)},e))})}),(0,Y.jsx)(`tbody`,{children:x.map((e,t)=>(0,Y.jsx)(`tr`,{className:`border-t`,children:b.map(t=>(0,Y.jsx)(`td`,{className:`px-2 py-1 tabular-nums whitespace-nowrap`,children:s.includes(t)?zt(e[t],v(t)?.format,v(t)?.currency,v(t)?.percentScale,a):Gt(e[t],a)},t))},t))})]})})]})})}function kb(e,t){return Array.isArray(e)?e.map((e,n)=>{if(!e||typeof e!=`object`)return null;let r=String(e.key??``).trim(),i=String(e.label??r??``).trim();return!r&&!i?null:{g:{key:r||t,label:i||r||`(unnamed)`,order:typeof e.order==`number`?e.order:void 0,include:Ab(e.include),package:typeof e.package==`string`?e.package:void 0,pages:jb(e.pages)},i:n}}).filter(e=>e!==null).sort((e,t)=>(e.g.order??0)-(t.g.order??0)||e.i-t.i).map(e=>e.g):[]}function Ab(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`&&typeof e.tag==`string`)return{tag:e.tag}}function jb(e){if(Array.isArray(e))return e.map(e=>typeof e==`string`?{literal:e}:e&&typeof e==`object`?{doc:typeof e.doc==`string`?e.doc:void 0,href:typeof e.href==`string`?e.href:void 0,label:typeof e.label==`string`?e.label:void 0,badge:typeof e.badge==`string`?e.badge:void 0,icon:typeof e.icon==`string`?e.icon:void 0}:null).filter(e=>e!==null)}function Mb(e,t){return e===`public`?{icon:(0,Y.jsx)(kr,{className:`h-3 w-3`}),label:G(`engine.bookPreview.audience.public`,t),tone:`text-emerald-700 bg-emerald-50 border-emerald-200`}:e&&typeof e==`object`&&typeof e.permissionSet==`string`?{icon:(0,Y.jsx)(Kr,{className:`h-3 w-3`}),label:W(`engine.bookPreview.audience.permissionSet`,t,{name:e.permissionSet}),tone:`text-amber-800 bg-amber-50 border-amber-200`}:{icon:(0,Y.jsx)(Cn,{className:`h-3 w-3`}),label:G(`engine.bookPreview.audience.org`,t),tone:`text-muted-foreground bg-muted/40 border-muted`}}function Nb({name:e,draft:t,locale:n}){let r=t,i=String(r.name??e??``).trim(),a=String(r.label??i),o=typeof r.description==`string`?r.description:``,s=typeof r.slug==`string`?r.slug:``,c=G(`engine.bookPreview.noKey`,n),l=J.useMemo(()=>kb(r.groups,c),[r.groups,c]),u=Mb(r.audience,n);if(!i)return(0,Y.jsx)(X,{hint:`book`,children:(0,Y.jsx)(Ff,{icon:(0,Y.jsx)(gn,{className:`h-8 w-8 opacity-50`}),title:G(`engine.bookPreview.nameTitle`,n),description:G(`engine.bookPreview.nameDescription`,n)})});let d=`/meta/book/${encodeURIComponent(i)}/tree`;return(0,Y.jsx)(X,{hint:`book · spine`,toolbar:(0,Y.jsxs)(`a`,{href:d,target:`_blank`,rel:`noreferrer`,className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,title:G(`engine.bookPreview.treeTitle`,n),children:[G(`engine.bookPreview.tree`,n),` `,(0,Y.jsx)(cr,{className:`h-3 w-3`})]}),children:(0,Y.jsx)(Z,{children:(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`rounded border bg-muted/30 p-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(gn,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:a}),(0,Y.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-medium ${u.tone}`,children:[u.icon,u.label]})]}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono mt-0.5`,children:i}),s&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:Vp(G(`engine.bookPreview.slug`,n),{slug:(0,Y.jsx)(`code`,{className:`font-mono`,children:s})})}),o&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1.5`,children:o})]}),l.length===0?(0,Y.jsx)(Ff,{icon:(0,Y.jsx)(xr,{className:`h-8 w-8 opacity-50`}),title:G(`engine.bookPreview.noGroups`,n),tone:`warn`,description:Vp(G(`engine.bookPreview.noGroupsDescription`,n),{groups:(0,Y.jsx)(`code`,{children:`groups`}),include:(0,Y.jsx)(`code`,{children:`include`}),glob:(0,Y.jsx)(`code`,{children:`crm_guide_*`}),tag:(0,Y.jsx)(`code`,{children:`{ tag }`})})}):(0,Y.jsx)(`div`,{className:`space-y-2`,children:l.map((e,t)=>(0,Y.jsx)(Pb,{group:e,locale:n},`${e.key}-${t}`))})]})})})}function Pb({group:e,locale:t}){return(0,Y.jsxs)(`div`,{className:`rounded border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/20 px-3 py-2`,children:[(0,Y.jsx)(xr,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:e.label}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.key}),typeof e.order==`number`&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,title:G(`engine.bookPreview.orderTitle`,t),children:[`#`,e.order]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[e.package&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] text-muted-foreground`,title:G(`engine.bookPreview.packageTitle`,t),children:[(0,Y.jsx)(ii,{className:`h-3 w-3`}),e.package]}),(0,Y.jsx)(Fb,{include:e.include,hasOverride:!!e.pages?.length,locale:t})]})]}),(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:e.pages?.length?(0,Y.jsx)(`ol`,{className:`space-y-1`,children:e.pages.map((e,n)=>(0,Y.jsx)(Ib,{node:e,locale:t},n))}):e.include==null?(0,Y.jsx)(`div`,{className:`text-[11px] text-amber-700 italic`,children:Vp(G(`engine.bookPreview.noRule`,t),{include:(0,Y.jsx)(`code`,{children:`include`}),pages:(0,Y.jsx)(`code`,{children:`pages`}),group:(0,Y.jsx)(`code`,{children:`group: "${e.key}"`})})}):(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:G(`engine.bookPreview.derived`,t)})})]})}function Fb({include:e,hasOverride:t,locale:n}){return e==null?t?(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,title:G(`engine.bookPreview.curatedTitle`,n),children:G(`engine.bookPreview.curated`,n)}):null:typeof e==`string`?(0,Y.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/5 px-1.5 py-0.5 font-mono text-[10px] text-foreground`,title:G(`engine.bookPreview.globTitle`,n),children:e}):(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/5 px-1.5 py-0.5 text-[10px] text-foreground`,title:G(`engine.bookPreview.tagTitle`,n),children:[(0,Y.jsx)(Ui,{className:`h-3 w-3`}),e.tag]})}function Ib({node:e,locale:t}){if(e.literal===`---`)return(0,Y.jsxs)(`li`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:[(0,Y.jsx)($r,{className:`h-3 w-3`}),G(`engine.bookPreview.separator`,t)]});if(e.literal===`...`)return(0,Y.jsxs)(`li`,{className:`flex items-center gap-2 text-[11px] italic text-muted-foreground`,children:[(0,Y.jsx)(sr,{className:`h-3.5 w-3.5`}),G(`engine.bookPreview.rest`,t)]});let n=!!e.href,r=e.literal??e.doc,i=e.label??r??e.href??G(`engine.bookPreview.emptyPage`,t);return(0,Y.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[n?(0,Y.jsx)(cr,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Y.jsx)(gr,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:i}),!n&&r&&e.label&&(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r}),e.badge&&(0,Y.jsx)(`span`,{className:`rounded-full border border-primary/30 bg-primary/5 px-1.5 py-0.5 text-[9px] uppercase tracking-wider text-foreground`,children:e.badge}),n&&(0,Y.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`ml-auto font-mono text-[10px] text-muted-foreground hover:text-foreground truncate max-w-[40%]`,title:e.href,children:e.href})]})}var Lb=/^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$/;function Rb(e){let t=e.translations;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){if(!r||typeof r!=`object`||Array.isArray(r))continue;let t=r;n[e]={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{},content:typeof t.content==`string`?t.content:``}}return n}function zb(e,t){return t===``?typeof e.content==`string`?e.content:``:Rb(e)[t]?.content??``}function Bb(e,t,n){if(t===``)return{content:n};let r=Rb(e);return{translations:{...r,[t]:{...r[t],content:n}}}}function Vb(e,t,n,r){let i=Rb(e),a={...i[t]??{content:``}};return r?a[n]=r:delete a[n],{translations:{...i,[t]:a}}}function Hb(e,t){return{translations:{...Rb(e),[t]:{content:zb(e,``)}}}}function Ub(e,t){let{[t]:n,...r}=Rb(e);return{translations:Object.keys(r).length>0?r:void 0}}function Wb(e,t){return Lb.test(t)?Object.prototype.hasOwnProperty.call(Rb(e),t)?`duplicate`:null:`invalid`}function Gb(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`||!e.name||!Array.isArray(e.groups))continue;let r=[];for(let t of e.groups){if(!t||typeof t!=`object`)continue;let{key:e,label:n}=t;typeof e==`string`&&r.push({key:e,label:typeof n==`string`&&n?n:e})}t.push({name:e.name,label:typeof e.label==`string`&&e.label?e.label:e.name,audience:e.audience,groups:r,spine:e,packageId:typeof e._packageId==`string`?e._packageId:void 0})}return t.sort((e,t)=>e.label.localeCompare(t.label))}function Kb(e,t){let n=typeof e.name==`string`?e.name:``,r={name:n,label:typeof e.label==`string`?e.label:void 0,order:typeof e.order==`number`?e.order:void 0,group:typeof e.group==`string`&&e.group?e.group:void 0,tags:Array.isArray(e.tags)?e.tags.filter(e=>typeof e==`string`):void 0,packageId:typeof e._packageId==`string`?e._packageId:void 0},i=[];for(let e of t){let t;try{t=v(e.spine,[r],e.packageId)}catch{continue}let a=t.groups.slice(0,e.spine.groups.length);for(let t of a)t.entries.some(e=>e.doc===n)&&i.push({book:e.name,bookLabel:e.label,group:t.label,public:e.audience===`public`})}return i}function qb(){let e=sa(),[t,n]=J.useState({status:`loading`});return J.useEffect(()=>{let t=!1;return e.list(`book`).then(e=>{t||n({status:`loaded`,books:Gb(e??[])})}).catch(e=>{t||n({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e]),t}var Jb=`h-7 rounded-md border bg-background px-2 text-xs max-w-[280px] disabled:opacity-60`,Yb=`h-7 rounded-md border bg-background px-2 text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring`;function Xb({draft:e,onPatch:t,editing:n,locale:r,diagnostics:i}){let a=e??{},o=!!n&&!!t,s=Rb(a),c=Object.keys(s).sort(),[l,u]=J.useState(``),d=l===``||c.includes(l)?l:``,[f,p]=J.useState(``),m=f.trim()?Wb(a,f.trim()):null,h=zb(a,d),g=qb(),_=typeof a.group==`string`?a.group:``,v=g.status===`loaded`?Kb(a,g.books):[],y=g.status===`loaded`?new Set(g.books.flatMap(e=>e.groups.map(e=>e.key))):null,b=e=>t?.(e),x=()=>{let e=f.trim();e&&!Wb(a,e)&&(b(Hb(a,e)),u(e),p(``))},S=(i??[]).filter(e=>/^(content|translations|group)(\.|$)/.test(e.path??``)),C=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(gn,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`label`,{htmlFor:`doc-book-section`,className:`text-xs text-muted-foreground shrink-0`,children:G(`engine.docPreview.bookSection`,r)}),(0,Y.jsxs)(`select`,{id:`doc-book-section`,className:Jb,value:_,disabled:!o,onChange:e=>b({group:e.target.value||void 0}),children:[(0,Y.jsx)(`option`,{value:``,children:G(`engine.docPreview.noSection`,r)}),g.status===`loaded`&&g.books.map(e=>(0,Y.jsx)(`optgroup`,{label:e.label,children:e.groups.map(t=>(0,Y.jsx)(`option`,{value:t.key,children:t.label},`${e.name}:${t.key}`))},e.name)),_&&y&&!y.has(_)&&(0,Y.jsx)(`option`,{value:_,children:W(`engine.docPreview.unknownSection`,r,{key:_})})]})]}),w=g.status===`loading`?(0,Y.jsx)(`span`,{children:G(`engine.docPreview.booksLoading`,r)}):g.status===`error`?(0,Y.jsx)(`span`,{role:`alert`,className:`text-destructive`,children:W(`engine.docPreview.booksFailed`,r,{message:g.message})}):v.length>0?(0,Y.jsxs)(`span`,{"data-testid":`doc-placement`,children:[G(`engine.docPreview.appearsIn`,r),` `,v.map((e,t)=>(0,Y.jsxs)(J.Fragment,{children:[t>0&&`, `,(0,Y.jsxs)(`span`,{className:`font-medium text-foreground/80`,children:[e.bookLabel,` › `,e.group]}),e.public&&(0,Y.jsxs)(`span`,{className:`ml-1 inline-flex items-center gap-0.5 text-amber-700 dark:text-amber-300`,children:[(0,Y.jsx)(kr,{className:`h-3 w-3`,"aria-hidden":!0}),G(`engine.docPreview.publicBook`,r)]})]},`${e.book}:${e.group}`))]}):(0,Y.jsx)(`span`,{"data-testid":`doc-placement`,children:g.books.length===0?G(`engine.docPreview.noBooks`,r):G(`engine.docPreview.unplaced`,r)}),T=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsx)(Rr,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`div`,{role:`tablist`,"aria-label":G(`engine.docPreview.locales`,r),className:`flex flex-wrap items-center gap-1`,children:[``,...c].map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":d===e,onClick:()=>u(e),className:`rounded px-2 py-0.5 text-xs border transition-colors `+(d===e?`bg-background shadow-sm text-foreground border-border`:`text-muted-foreground border-transparent hover:text-foreground`),children:e===``?G(`engine.docPreview.baseLocale`,r):e}),o&&e!==``&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":W(`engine.docPreview.removeLocale`,r,{locale:e}),title:W(`engine.docPreview.removeLocale`,r,{locale:e}),onClick:()=>{b(Ub(a,e)),d===e&&u(``)},className:`ml-0.5 rounded p-0.5 text-muted-foreground hover:text-destructive`,children:(0,Y.jsx)(na,{className:`h-3 w-3`})})]},e||`(base)`))}),o&&(0,Y.jsxs)(`form`,{className:`flex items-center gap-1`,onSubmit:e=>{e.preventDefault(),x()},children:[(0,Y.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:G(`engine.docPreview.localePlaceholder`,r),"aria-label":G(`engine.docPreview.addLocaleInput`,r),"aria-invalid":m?!0:void 0,className:`${Yb} w-24`}),(0,Y.jsxs)(`button`,{type:`submit`,disabled:!f.trim()||!!m,className:`inline-flex h-7 items-center gap-1 rounded-md border px-2 text-xs disabled:opacity-50`,children:[(0,Y.jsx)(U,{className:`h-3 w-3`,"aria-hidden":!0}),G(`engine.docPreview.addLocale`,r)]}),m&&(0,Y.jsx)(`span`,{role:`alert`,className:`text-[11px] text-destructive`,children:m===`duplicate`?W(`engine.docPreview.localeDuplicate`,r,{locale:f.trim()}):G(`engine.docPreview.localeInvalid`,r)})]})]}),E=d===``?void 0:s[d],D=E&&o&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b px-3 py-1.5 bg-muted/10`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[G(`engine.docPreview.variantTitle`,r),(0,Y.jsx)(`input`,{value:E.label??``,onChange:e=>b(Vb(a,d,`label`,e.target.value)),placeholder:typeof a.label==`string`?a.label:``,className:`${Yb} w-48`})]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[G(`engine.docPreview.variantSummary`,r),(0,Y.jsx)(`input`,{value:E.description??``,onChange:e=>b(Vb(a,d,`description`,e.target.value)),placeholder:typeof a.description==`string`?a.description:``,className:`${Yb} w-64`})]})]}),O=(0,Y.jsx)(`section`,{"aria-label":G(`engine.docPreview.preview`,r),className:`h-full min-h-[260px] overflow-auto p-4`,onClickCapture:e=>{e.target.closest(`a`)&&e.preventDefault()},children:h.trim()?(0,Y.jsx)(Z,{fallbackHint:G(`engine.docPreview.renderFailed`,r),children:(0,Y.jsx)(Bt,{schema:{type:`markdown`,content:h}})}):(0,Y.jsxs)(`div`,{className:`flex h-full min-h-[200px] flex-col items-center justify-center gap-2 text-center text-xs text-muted-foreground`,children:[(0,Y.jsx)(gr,{className:`h-6 w-6 opacity-50`,"aria-hidden":!0}),G(o?`engine.docPreview.emptyEditing`:`engine.docPreview.empty`,r)]})});return(0,Y.jsx)(X,{hint:`doc · markdown`,children:(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5 border-b px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[C,T]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:w})]}),D,S.length>0&&(0,Y.jsx)(`ul`,{className:`border-b bg-destructive/5 px-3 py-1.5 text-xs text-destructive`,children:S.map((e,t)=>(0,Y.jsxs)(`li`,{children:[e.path?(0,Y.jsx)(`code`,{className:`font-mono mr-1`,children:e.path}):null,e.message]},t))}),o?(0,Y.jsxs)(`div`,{className:`grid flex-1 min-h-0 grid-cols-1 divide-y divide-border lg:grid-cols-2 lg:divide-x lg:divide-y-0`,children:[(0,Y.jsx)(`textarea`,{value:h,onChange:e=>b(Bb(a,d,e.target.value)),spellCheck:!1,"aria-label":d===``?G(`engine.docPreview.source`,r):W(`engine.docPreview.sourceLocale`,r,{locale:d}),placeholder:G(`engine.docPreview.sourcePlaceholder`,r),className:`h-full min-h-[260px] w-full resize-none bg-background p-3 font-mono text-xs leading-relaxed outline-none`}),O]}):(0,Y.jsx)(`div`,{className:`flex-1 min-h-0`,children:O})]})})}function Zb(){Ha(`page`,Bp),Ha(`view`,Yp),Ha(`dashboard`,nm),Ha(`report`,am),Ha(`app`,Om),Ha(`action`,ay),Ha(`object`,qm),Ha(`datasource`,mb),Ha(`validation`,bb),Ha(`dataset`,Ob),Ha(`email_template`,Zm),Ha(`translation`,Py),Ha(`book`,Nb),Ha(`doc`,Xb),Ha(`flow`,Sv),Ha(`job`,Oy),Ha(`agent`,Tv),Ha(`tool`,zv),Ha(`skill`,Ry),Ha(`permission`,Yv),Ha(`profile`,Yv),Ha(`position`,Ly),Ha(`role`,Ly)}var Qb=[{value:`metric`,labelKey:`engine.inspector.widget.type.metric`},{value:`bar`,labelKey:`engine.inspector.widget.type.bar`},{value:`horizontal-bar`,labelKey:`engine.inspector.widget.type.horizontalBar`},{value:`line`,labelKey:`engine.inspector.widget.type.line`},{value:`area`,labelKey:`engine.inspector.widget.type.area`},{value:`pie`,labelKey:`engine.inspector.widget.type.pie`},{value:`donut`,labelKey:`engine.inspector.widget.type.donut`},{value:`funnel`,labelKey:`engine.inspector.widget.type.funnel`},{value:`table`,labelKey:`engine.inspector.widget.type.table`},{value:`pivot`,labelKey:`engine.inspector.widget.type.pivot`}],$b=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function ex(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function tx({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],c=t.kind===`widget`?t.id:void 0,l=c?ex(e,c):null,u=l?.widget??{},d=typeof u.dataset==`string`?u.dataset:``,f=Array.isArray(u.dimensions)?u.dimensions.filter(e=>typeof e==`string`):[],p=Array.isArray(u.values)?u.values.filter(e=>typeof e==`string`):[],m=Ts(),h=ws(d||void 0,m),g=J.useMemo(()=>{let e=No(m.datasets);return d&&!e.some(e=>e.value===d)&&e.push({value:d,label:d}),e},[m.datasets,d]),_=J.useMemo(()=>ds(h.measures),[h.measures]),v=J.useMemo(()=>_s(h.dimensions),[h.dimensions]),y=J.useMemo(()=>h.dimensions.map(e=>({value:e.name,label:e.label??e.name,hint:e.type})),[h.dimensions]),b=J.useMemo(()=>Nt({globalFilters:e.globalFilters,dateRange:e.dateRange}),[e]);if(t.kind!==`widget`)return(0,Y.jsx)(ix,{message:W(`engine.inspector.widget.unsupportedSelection`,o,{kind:t.kind}),onClose:r,locale:o});if(!l)return(0,Y.jsx)(ix,{message:G(`engine.inspector.widget.removed`,o),onClose:r,locale:o});let{widget:x,index:S}=l,C=Mt(S),w=Tt(x.layout,{},C);function T(e){let t=[...s];t[S]={...t[S],...e},n({widgets:t})}function E(e){n({widgets:rs(s,S,e)}),x.id&&i?.({kind:`widget`,id:x.id,label:I(x.title,o)})}return(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:G(`engine.inspector.widget.kind`,o)}),(0,Y.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:I(x.title,o)||t.label||W(`engine.inspector.widget.untitledN`,o,{n:S+1})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,Y.jsx)(us,{index:S,total:s.length,onMove:E,upLabel:G(`engine.inspector.reorder.up`,o),downLabel:G(`engine.inspector.reorder.down`,o),disabled:a}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:G(`engine.inspector.widget.close`,o),"aria-label":G(`engine.inspector.widget.close`,o),children:(0,Y.jsx)(na,{className:`h-3.5 w-3.5`})})]})]}),(0,Y.jsx)(rx,{id:`widget-title`,label:G(`engine.inspector.widget.title`,o),children:(0,Y.jsx)(z,{id:`widget-title`,value:I(x.title,o)??``,onChange:e=>T({title:tn(x.title,o,e.target.value)}),disabled:a})}),(0,Y.jsx)(rx,{id:`widget-type`,label:G(`engine.inspector.widget.type`,o),children:(0,Y.jsxs)(Pe,{value:x.type??`metric`,onValueChange:e=>{let t=Qb.find(t=>t.value===e);t&&T({type:t.value})},disabled:a,children:[(0,Y.jsx)(he,{id:`widget-type`,children:(0,Y.jsx)(Ze,{})}),(0,Y.jsx)(Ke,{children:Qb.map(e=>(0,Y.jsx)(vt,{value:e.value,children:G(e.labelKey,o)},e.value))})]})}),(0,Y.jsxs)(`div`,{className:`space-y-3 rounded-md border p-3`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:G(`engine.inspector.widget.datasetSection`,o)}),(0,Y.jsxs)(rx,{id:`widget-dataset`,label:G(`engine.inspector.widget.dataset`,o),children:[(0,Y.jsx)(cl,{id:`widget-dataset`,value:d,onCommit:e=>T({dataset:e||void 0}),options:g,loading:m.loading,placeholder:G(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:G(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,Y.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:G(`engine.inspector.widget.datasetHint`,o)})]}),d&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ys,{label:G(`engine.inspector.widget.dimensions`,o),emptyText:G(`engine.inspector.widget.dimensionsHint`,o),names:f,options:v,loading:h.loading,error:h.error,readOnly:a,onCommit:e=>T({dimensions:e})}),(0,Y.jsx)(ys,{label:G(`engine.inspector.widget.values`,o),emptyText:G(`engine.inspector.widget.valuesHint`,o),names:p,options:_,loading:h.loading,error:h.error,readOnly:a,onCommit:e=>T({values:e})})]})]}),b.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-3 rounded-md border p-3`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:G(`engine.inspector.widget.filterBindingsSection`,o)}),(0,Y.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:G(`engine.inspector.widget.filterBindingsHint`,o)}),b.map(e=>{let t=x.filterBindings,n=t?.[e.name],r=n===!1,i=typeof n==`string`?n:``,s=n=>{let r={...t??{}};n===void 0?delete r[e.name]:r[e.name]=n,T({filterBindings:Object.keys(r).length>0?r:void 0})};return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`widget-filter-binding-${e.name}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(L,{className:`text-xs font-medium text-muted-foreground truncate`,children:I(e.label,o)||e.name}),(0,Y.jsx)(cs,{label:G(`engine.inspector.widget.filterBindingApply`,o),value:!r,onCommit:e=>s(e?void 0:!1),disabled:a})]}),!r&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(cl,{ariaLabel:W(`engine.inspector.widget.filterBindingField`,o,{filter:I(e.label,o)||e.name}),value:i,onCommit:e=>s(e||void 0),options:y,placeholder:W(`engine.inspector.widget.filterBindingDefault`,o,{field:e.field}),searchPlaceholder:G(`engine.form.searchFields`,o),disabled:a,mono:!0})}),i&&!a&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 px-2 text-[10px] text-muted-foreground`,onClick:()=>s(void 0),children:G(`engine.inspector.widget.filterBindingReset`,o)})]})]},e.name)})]}),(0,Y.jsx)(rx,{id:`widget-color`,labelling:`group`,label:G(`engine.inspector.widget.color`,o),children:(0,Y.jsx)(So,{ariaLabelledBy:nx(`widget-color`),value:x.colorVariant??`default`,onChange:e=>T({colorVariant:e}),disabled:a,options:$b.map(e=>({value:e}))})}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Y.jsx)(rx,{id:`widget-w`,label:G(`engine.inspector.widget.width`,o),children:(0,Y.jsx)(z,{id:`widget-w`,type:`number`,min:1,value:w.w,onChange:e=>T({layout:Tt(x.layout,{w:Number(e.target.value)||1},C)}),disabled:a})}),(0,Y.jsx)(rx,{id:`widget-h`,label:G(`engine.inspector.widget.height`,o),children:(0,Y.jsx)(z,{id:`widget-h`,type:`number`,min:1,value:w.h,onChange:e=>T({layout:Tt(x.layout,{h:Number(e.target.value)||1},C)}),disabled:a})})]}),!a&&(0,Y.jsx)(`div`,{className:`pt-2 border-t`,children:(0,Y.jsx)(B,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(S,1),n({widgets:t}),r()},children:G(`engine.inspector.widget.remove`,o)})})]})}var nx=e=>`${e}-label`;function rx({id:e,label:t,labelling:n=`control`,children:r}){return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(L,{...n===`group`?{id:nx(e)}:{htmlFor:e},className:`text-xs font-medium text-muted-foreground`,children:t}),r]})}function ix({message:e,onClose:t,locale:n}){return(0,Y.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,Y.jsx)(`p`,{children:e}),(0,Y.jsx)(B,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:G(`engine.inspector.widget.close`,n)})]})}var ax={"zh-CN":{metadataForms:{dashboard:{label:`仪表板`,sections:{basics:{label:`基本信息`,description:`仪表板的名称与描述。`},layout:{label:`布局`,description:`栅格尺寸与刷新频率。`},widgets:{label:`组件`,description:`放在栅格上的卡片与图表。`},filters:{label:`筛选`,description:`应用到全部组件的默认筛选与全局筛选。`},advanced:{label:`高级`,description:`无障碍与性能调优。`}},fields:{name:{label:`名称`,helpText:`snake_case 唯一标识`},label:{label:`显示名称`,helpText:`展示给使用者的名称`},description:{label:`描述`},columns:{label:`列数`,helpText:`栅格列数(默认 12)`},gap:{label:`间距`,helpText:`组件之间的间距,数值越大越松`},refreshIntervalSeconds:{label:`自动刷新`,helpText:`自动刷新间隔(秒),0 表示不自动刷新`},header:{label:`页眉`,helpText:`页眉设置:标题、描述与操作按钮`},"header.showTitle":{label:`显示标题`,helpText:`在页眉中显示仪表板名称`},"header.showDescription":{label:`显示描述`,helpText:`在页眉中显示仪表板描述`},"header.actions":{label:`操作按钮`,helpText:`显示在页眉里的操作按钮`},widgets:{label:`组件`,helpText:`仪表板组件,含位置与尺寸`},dateRange:{label:`日期范围`,helpText:`默认的日期范围选择器`},globalFilters:{label:`全局筛选`,helpText:`应用到全部组件的筛选条件`}}}}}};function ox(e){return es(e)?`zh-CN`:void 0}function sx(e,t,n){if(!e)return e;let r=ox(n);return!r||!ax[r]?.metadataForms?.[t]?e:ux(_(lx(e),t,ax,{locale:r}))}function cx(e){if(!e||typeof e!=`object`)return e;let t=e,n={...t};return Do(n,typeof t.label==`string`?t.label:void 0),Array.isArray(t.fields)&&(n.fields=t.fields.map(cx)),n}function lx(e){let t=e=>{if(!e||typeof e!=`object`)return e;let t=e;return Array.isArray(t.fields)?{...t,fields:t.fields.map(cx)}:t},n={...e};return Array.isArray(e.sections)&&(n.sections=e.sections.map(t)),Array.isArray(e.groups)&&(n.groups=e.groups.map(t)),n}function ux(e){let t=e=>{if(!e||typeof e!=`object`)return;let n=e;Po(n)||Do(n,void 0),Array.isArray(n.fields)&&n.fields.forEach(t)},n=e;for(let e of[`sections`,`groups`]){let r=n?.[e];if(Array.isArray(r))for(let e of r){let n=e?.fields;Array.isArray(n)&&n.forEach(t)}}return e}N();var dx={io:`input`,unrepresentable:`any`},fx=new Set([`widgets`,`label`,`description`,`name`]),px,mx=!1;function hx(){if(px||mx)return px;try{px=y(O,dx)}catch(e){mx=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return px}var gx=new Map;function _x(e){let t=String(e??``);if(gx.has(t))return gx.get(t);if(E&&typeof E==`object`)try{let n=JSON.parse(JSON.stringify(E));for(let e of n.sections??[])e.fields=(e.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!fx.has(t)});n.sections=(n.sections??[]).filter(e=>(e.fields??[]).length>0);let r=sx(n,`dashboard`,e);return gx.set(t,r),r}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}}var vx=new Set([`name`,`label`,`description`,`widgets`]);function yx({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=J.useCallback(e=>G(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=J.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=ol(`widget`,l.map(e=>e?.id).filter(Boolean)),r=Xp[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`,o={id:n,type:e,title:a,...r?.defaults??{}};t({widgets:os(l,o)}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:xs(l,e,null)})},f=(e,n)=>{e!==n&&t({widgets:rs(l,e,n)})},p=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:I(e.title,r)||e.id||W(`engine.inspector.widget.untitledN`,r,{n:t+1})})},[m,h]=J.useState(null),[g,_]=J.useState(null),{schema:v,form:y}=J.useMemo(()=>as({bundledSchema:hx(),bundledForm:_x(r),serverSchema:a,excludeFields:vx,sectionTitle:G(`engine.inspector.moreFields`,r)}),[a,r]);return(0,Y.jsxs)(is,{kindLabel:o(`engine.inspector.dashboard.kind`),title:String(s||e.name||o(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,Y.jsx)(q,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,Y.jsx)(q,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,Y.jsx)(V,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.widgetsEmpty`)}):(0,Y.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let i=Xp[e?.type]?.icon??$p;return(0,Y.jsxs)(`div`,{draggable:!n,onDragStart:()=>h(t),onDragEnd:()=>{h(null),_(null)},onDragOver:e=>{e.preventDefault(),_(t)},onDrop:()=>{m!=null&&m!==t&&f(m,t),h(null),_(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(g===t&&m!==null&&m!==t?` border-primary`:``),children:[!n&&(0,Y.jsx)(Ar,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,Y.jsx)(i,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>p(e,t),title:I(e?.title,r)||e?.id,children:I(e?.title,r)||e?.id||W(`engine.inspector.widget.untitledN`,r,{n:t+1})}),(0,Y.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>d(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,Y.jsx)(na,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,Y.jsx)(em,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,Y.jsx)(`div`,{className:`border-t pt-3`,children:v?(0,Y.jsx)(Bo,{schema:v,form:y,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var bx=e=>ao(e),xx=e=>typeof e.expression==`string`?e.expression.trim():``,Sx=e=>typeof e.label==`string`?e.label.trim():``,Cx=e=>typeof e.target==`string`?e.target.trim():``,wx=e=>{let t=xx(e);return t===``||t===`true`};function Tx(e){return Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&!Array.isArray(e)):[]}function Ex(e,t){if(wx(e))return t.isDefault===!0;let n=xx(e),r=bx(t.condition);if(n&&r===n)return!0;let i=Sx(e);return i!==``&&t.label===i}var Dx=e=>t=>t.source===e&&t.type!==`fault`&&t.type!==`back`;function Ox(e,t){let n=xx(t),r=Sx(t),i={...e};return r?i.label=r:delete i.label,n&&n!==`true`?(i.condition=n,delete i.isDefault):n===`true`?(i.isDefault=!0,delete i.condition):(delete i.condition,delete i.isDefault),i}function kx(e,t,n){let r=Tx(t),i=Dx(e),a=0;return n.map(e=>{if(!i(e))return e;let t=r[a++];return t?Ox(e,t):e})}function Ax(e,t,n){let r=Tx(t);if(r.length===0)return r;let i=n.map((e,t)=>t).filter(t=>Dx(e)(n[t])),a=new Set,o=new Map;return r.forEach((e,t)=>{let r=i.find(t=>!a.has(t)&&Ex(e,n[t]));r!==void 0&&(a.add(r),o.set(t,r))}),r.forEach((e,t)=>{if(o.has(t))return;let n=i.find(e=>!a.has(e));n!==void 0&&(a.add(n),o.set(t,n))}),r.map((e,t)=>{let{target:r,...i}=e,a=o.get(t);return a===void 0?i:{...i,target:n[a].target}})}function jx(e,t,n){let r=Tx(t),i=r.map(e=>{let{target:t,...n}=e;return n});if(!r.some(e=>Cx(e)!==``))return{conditions:i,edges:kx(e,i,n)};let a=n.map((e,t)=>t).filter(t=>Dx(e)(n[t])),o=new Set,s=new Map,c=[(e,t)=>t.target===Cx(e)&&Ex(e,t),(e,t)=>t.target===Cx(e),(e,t)=>Ex(e,t)];for(let e of c)r.forEach((t,r)=>{if(s.has(r)||Cx(t)===``)return;let i=a.find(r=>!o.has(r)&&e(t,n[r]));i!==void 0&&(o.add(i),s.set(r,i))});let l=new Map,u=[],d=new Set,f=n.map(e=>e.id);return r.forEach((t,r)=>{let i=Cx(t);if(i===``){let e=a.find(e=>!o.has(e)&&Ex(t,n[e]));e!==void 0&&(o.add(e),d.add(e));return}let c=s.get(r);if(c!==void 0){l.set(c,Ox({...n[c],target:i},t));return}let p=ol(`edge`,f);f.push(p),u.push(Ox({id:p,source:e,target:i},t))}),{conditions:i,edges:n.map((e,t)=>d.has(t)?null:l.get(t)??e).filter(e=>e!==null).concat(u)}}function Mx(e,t){return t===`template`?`{${e}}`:e}function Nx(e,t,n,r,i){let a=Mx(n,t),o=Math.min(Math.max(r,0),e.length),s=Math.min(Math.max(i,0),e.length),c=Math.min(o,s),l=Math.max(o,s);return{next:e.slice(0,c)+a+e.slice(l),caret:c+a.length}}function Px({value:e,onValueChange:t,onBlur:n,onKeyDown:r,mode:i,groups:a,placeholder:o,disabled:s,multiline:c,rows:l=4,mono:u,className:d,ariaRequired:f}){let p=J.useRef(null),m=J.useRef({start:0,end:0}),[h,g]=J.useState(!1),_=$o(),v=G(`engine.flowScope.picker.insert`,_),y=e=>{p.current=e},b=()=>{let t=p.current;t&&(m.current={start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},x=n=>{let{next:r,caret:a}=Nx(e,i,n,m.current.start,m.current.end);t(r),g(!1),requestAnimationFrame(()=>{let e=p.current;if(e){e.focus();try{e.setSelectionRange(a,a)}catch{}m.current={start:a,end:a}}})},S=a.some(e=>e.refs.length>0),C={value:e,onChange:e=>t(e.target.value),onBlur:n,onKeyDown:r,onSelect:b,onKeyUp:b,onClick:b,placeholder:o,disabled:s,"aria-required":f?!0:void 0};return(0,Y.jsxs)(`div`,{className:R(`relative`,d),children:[c?(0,Y.jsx)(`textarea`,{ref:y,...C,rows:l,className:`w-full rounded border bg-background px-2 py-1.5 pr-8 font-mono text-xs`}):(0,Y.jsx)(z,{ref:y,...C,className:R(`h-8 pr-8 text-sm`,u&&`font-mono`)}),S&&!s&&(0,Y.jsxs)(Me,{open:h,onOpenChange:g,children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":v,title:v,onMouseDown:b,className:`absolute right-1 top-1 inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,Y.jsx)(bn,{className:`h-3.5 w-3.5`})})}),(0,Y.jsx)(mt,{align:`end`,className:`w-72 p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:(0,Y.jsxs)(_e,{children:[(0,Y.jsx)(ve,{placeholder:G(`engine.flowScope.picker.search`,_),className:`h-9`}),(0,Y.jsxs)(dt,{children:[(0,Y.jsx)(Xe,{children:G(`engine.flowScope.picker.empty`,_)}),a.map(e=>(0,Y.jsx)(xe,{heading:e.label,children:e.refs.map(t=>(0,Y.jsxs)(Ve,{value:`${t.token} ${t.label} ${t.detail??``}`,onSelect:()=>x(t.token),className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-mono text-xs`,children:Mx(t.token,i)}),t.detail&&(0,Y.jsx)(`span`,{className:`shrink-0 truncate text-[10px] text-muted-foreground`,children:t.detail})]},`${e.id}:${t.token}`))},e.id))]})]})})]})]})}function Fx(e,t,n,r){let i=n&&n.length>0?gg(n.flatMap(e=>e.refs)):null,a=i?xg(e,t,i):[];return a.length>0?Sg(a,r):void 0}function Ix({value:e,role:t,scopeGroups:n,screenNode:r}){let i=$o(),a=t===`template`?null:Tg(t,e,i);if(a)return(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-destructive`,role:`alert`,children:a.message});let o=r?Pg(e,r,i):Fx(e,t,n,i);return o?(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-amber-600 dark:text-amber-400`,role:`note`,children:o}):null}function Lx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Rx(e){return e==null?``:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function zx(e){let t=e.trim();if(t===``)return``;if(t===`true`)return!0;if(t===`false`)return!1;if(/^-?\d+(\.\d+)?$/.test(t))return Number(t);if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.parse(t)}catch{return e}return e}function Bx(e){return Array.isArray(e)?e.filter(e=>Lx(e)).map(e=>{let t=e.variable??e.name??e.key;return[typeof t==`string`?t:``,e.value]}):Lx(e)?Object.entries(e):[]}function Vx(e,t,n=!1){let r=[...t],i=n&&!Array.isArray(e);return Bx(e).map(([e,t])=>{let n=ol(`kv`,r);return r.push(n),i&&Ch(t)?{id:n,key:e,raw:t.source,mode:`expression`,envelope:t}:{id:n,key:e,raw:Rx(t)}})}function Hx(e){return e.mode===`expression`?wh(e.envelope,e.raw):zx(e.raw)}function Ux(e,t){return t&&!e.some(e=>e.mode===`expression`)}function Wx(e,t){let n=new Set,r=[];for(let t of e){let e=t.key.trim();e&&!n.has(e)&&(n.add(e),r.push([e,t]))}if(Ux(r.map(([,e])=>e),t))return r.map(([e,t])=>({variable:e,value:Hx(t)}));let i={};for(let[e,t]of r)i[e]=Hx(t);return i}function Gx(e,t){if(t===`text`)return e.mode===`expression`?{id:e.id,key:e.key,raw:e.raw}:e;if(e.mode===`expression`)return e;let n=zx(e.raw);return Ch(n)?{id:e.id,key:e.key,raw:n.source,mode:`expression`,envelope:n}:{id:e.id,key:e.key,raw:e.raw,mode:`expression`}}function Kx(e){if(Array.isArray(e))return JSON.stringify(e);let t=e??{},n=Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{});return JSON.stringify(n)}function qx(e){let t=!1,n=e.map(e=>e.mode===`expression`||!Ch(zx(e.raw))?e:(t=!0,Gx(e,`expression`)));return t?n:e}function Jx({label:e,value:t,onCommit:n,disabled:r,help:i,addLabel:a,keyLabel:o,valueLabel:s,removeLabel:c,emptyLabel:l,scopeGroups:u,valueEnvelope:d,required:f}){let p=Array.isArray(t),m=d!==void 0,h=J.useMemo(()=>Kx(Wx(Vx(t,[],m),p)),[t,p,m]),[g,_]=J.useState(()=>Vx(t,[],m)),v=J.useRef(h);J.useEffect(()=>{h!==v.current&&(_(Vx(t,[],m)),v.current=h)},[h,t,m]);let y=e=>{let t=Wx(e,p);return v.current=Kx(t),n((Array.isArray(t)?t.length===0:Object.keys(t).length===0)?void 0:t),m&&!Array.isArray(t)?qx(e):e},b=()=>{let e=y(g);e!==g&&_(e)},x=(e,t)=>{_(n=>n.map(n=>n.id===e?{...n,...t}:n))},S=()=>{_(e=>[...e,{id:ol(`kv`,e.map(e=>e.id)),key:``,raw:``}])},C=e=>{_(t=>y(t.filter(t=>t.id!==e)))},w=(e,t)=>{_(n=>y(n.map(n=>n.id===e?Gx(n,t):n)))},T=!Ux(g,p);return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(L,{className:`text-xs text-muted-foreground`,children:[e,f&&(0,Y.jsx)(Cs,{})]}),m&&p&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-amber-700 dark:text-amber-400`,role:`note`,children:"`assignments` is a map of variable name → value (`{ assignments: { total: '{amount}' } }`). The array form `[{ variable, value }]` is a legacy shape the executor still reads but this contract does not describe — write the map, which is also the only shape that accepts a CEL value envelope."}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[g.length===0&&(0,Y.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground`,children:l}),g.map(e=>{let t=e.mode===`expression`,n=m&&T?Th(Hx(e)):null;return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(z,{value:e.key,onChange:t=>x(e.id,{key:t.target.value}),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},placeholder:o,disabled:r,className:`h-8 flex-1 font-mono text-xs`}),(0,Y.jsx)(Px,{mode:t?`expression`:`template`,mono:t,value:e.raw,onValueChange:t=>x(e.id,{raw:t}),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},groups:u??[],placeholder:t&&d?d.expressionPlaceholder:s,disabled:r,className:`flex-1`}),d&&(0,Y.jsx)(B,{type:`button`,variant:t?`secondary`:`ghost`,size:`sm`,className:R(`h-8 w-8 shrink-0 p-0`,t?`text-foreground`:`text-muted-foreground`),onClick:()=>w(e.id,t?`text`:`expression`),disabled:r,"aria-pressed":t,"aria-label":d.toggleLabel,title:d.toggleLabel,children:(0,Y.jsx)(Xn,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-8 shrink-0 p-0 text-muted-foreground`,onClick:()=>C(e.id),disabled:r,"aria-label":c,title:c,children:(0,Y.jsx)(na,{className:`h-3.5 w-3.5`})})]}),n?(0,Y.jsx)(`div`,{className:`space-y-0.5`,role:`alert`,children:n.map((e,t)=>(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-destructive`,children:e},t))}):t?(0,Y.jsx)(Ix,{value:Hx(e),role:`value`,scopeGroups:u}):(0,Y.jsx)(Ix,{value:e.raw,role:`template`,scopeGroups:u})]},e.id)})]}),(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 w-full text-xs`,onClick:S,disabled:r,children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),a]}),i&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:i})]})}function Yx(e,t){let n=[...t];return e.map(e=>{let t=ol(`sl`,n);return n.push(t),{id:t,value:e}})}function Xx(e){return e.map(e=>e.value.trim()).filter(e=>e!==``)}function Zx({label:e,value:t,onCommit:n,disabled:r,addLabel:i,itemLabel:a,removeLabel:o,emptyLabel:s,required:c}){let l=J.useMemo(()=>Array.isArray(t)?t.map(e=>String(e)):[],[t]),[u,d]=J.useState(()=>Yx(l,[])),f=J.useRef(JSON.stringify(l));J.useEffect(()=>{let e=JSON.stringify(l);e!==f.current&&(d(Yx(l,[])),f.current=e)},[l]);let p=e=>{let t=Xx(e);f.current=JSON.stringify(t),n(t.length?t:void 0)},m=(e,t)=>{d(n=>n.map(n=>n.id===e?{...n,value:t}:n))},h=()=>{d(e=>[...e,{id:ol(`sl`,e.map(e=>e.id)),value:``}])},g=e=>{d(t=>{let n=t.filter(t=>t.id!==e);return p(n),n})};return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(L,{className:`text-xs text-muted-foreground`,children:[e,c&&(0,Y.jsx)(Cs,{})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[u.length===0&&(0,Y.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground`,children:s}),u.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(z,{value:e.value,onChange:t=>m(e.id,t.target.value),onBlur:()=>p(u),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},placeholder:a,disabled:r,className:`h-8 flex-1 text-xs`}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-8 shrink-0 p-0 text-muted-foreground`,onClick:()=>g(e.id),disabled:r,"aria-label":o,title:o,children:(0,Y.jsx)(na,{className:`h-3.5 w-3.5`})})]},e.id))]}),(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 w-full text-xs`,onClick:h,disabled:r,children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),i]})]})}var Qx={object:`object`,flow:`flow`,connector:`connector`,"email-template":`email_template`},$x=Object.fromEntries(Object.entries({user:{displayField:`name`,picker:`search`,subtitle:[`email`]},team:{displayField:`name`},department:{displayField:`name`},position:{displayField:`label`}}).flatMap(([e,t])=>{let n=te[e];return!n||n.source!==`data`?[]:[[e,{object:n.object,valueField:n.valueField,...t}]]})),eS=oe.map(({value:e,label:t})=>({value:e,label:t}));function tS(e){let t=eS.find(t=>t.value===e);return t?t.label:e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function nS(e){return e?.source===`enum`&&e.values.length>0?e.values.map(e=>({value:e,label:tS(e)})):eS}function rS(e,t){if(e){if(e.kind)return{kind:e.kind,objectSource:e.objectSource,connectorSource:e.connectorSource,source:e.sources?.[e.kind]};if(e.kindFrom&&e.map){let n=t(e.kindFrom),r=typeof n==`string`?e.map[n]:void 0;if(r)return{kind:r,objectSource:e.objectSource,connectorSource:e.connectorSource,source:typeof n==`string`?e.sources?.[n]:void 0}}}}function iS(e){if(!e)return;let t=$x[e.kind],n=e.source;if(!(n&&n.source!==`data`))return n?{object:n.object,valueField:n.valueField,displayField:t?.displayField??n.valueField,...t?.picker?{picker:t.picker}:{},...t?.subtitle?{subtitle:t.subtitle}:{}}:t}function aS(e,t){let n=e?.config;if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n[t];return typeof r==`string`&&r?r:void 0}function oS(e,t,n){if(e!==`object-field`)return;let r=t||`$trigger`;return r===`$trigger`?aS((Array.isArray(n.draft.nodes)?n.draft.nodes:[]).find(e=>e?.type===`start`),`objectName`):aS(n.node,r)}function sS(e,t,n){if(e!==`connector-action`)return;let r=n.node?.connectorConfig;if(!r||typeof r!=`object`||Array.isArray(r))return;let i=r[t||`connectorId`];return typeof i==`string`&&i?i:void 0}function cS(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e.key==`string`&&!!e.key).map(e=>{let t=typeof e.description==`string`?e.description.trim():``;return{value:e.key,label:typeof e.label==`string`&&e.label&&e.label!==e.key?`${e.label} (${e.key})`:e.key,...t?{hint:t}:{}}}):[]}function lS(e,t){return Array.isArray(e)?e.filter(e=>!!e&&typeof e.name==`string`&&!!e.name).map(e=>{let n=typeof e.label==`string`&&e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name;return{value:e.name,label:e.origin===`declarative`?`${n} · ${G(`engine.inspector.reference.declarative`,t)}`:n}}):[]}function uS(e){let t=sa(),[n,r]=J.useState({options:[],loading:!!e});return J.useEffect(()=>{if(!e){r({options:[],loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),t.list(e).then(e=>{if(n)return;let t=(Array.isArray(e)?e:[]).filter(e=>e&&typeof e.name==`string`&&e.name).map(e=>({value:String(e.name),label:typeof e.label==`string`&&e.label&&e.label!==e.name?`${e.label} (${e.name})`:String(e.name)}));r({options:t,loading:!1})}).catch(()=>{n||r({options:[],loading:!1})}),()=>{n=!0}},[t,e]),n}function dS(e){let[t,n]=J.useState({options:[],loading:!!e});return J.useEffect(()=>{if(!e){n({options:[],loading:!1});return}let t=!1;return n(e=>({...e,loading:!0})),fetch(`/api/v1/automation/connectors`,{credentials:`include`,headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).then(r=>{if(t)return;let i=r?.data?.connectors??r?.connectors??[],a=Array.isArray(i)?i.find(t=>t?.name===e):void 0;n({options:cS(a?.actions),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function fS(e,t){let[n,r]=J.useState({options:[]});return J.useEffect(()=>{if(!e){r({options:[]});return}let n=!1;return fetch(`/api/v1/automation/connectors`,{credentials:`include`,headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).then(e=>{if(n)return;let i=e?.data?.connectors??e?.connectors??[];r({options:lS(i,t)})}).catch(()=>{n||r({options:[]})}),()=>{n=!0}},[e,t]),n}function pS({binding:e,value:t,onPick:n,onCommit:r,onBlur:i,disabled:a,placeholder:o,locale:s}){let c=Pt(),[l,u]=J.useState(!1),d=t==null?``:String(t);return!c||l?(0,Y.jsxs)(`div`,{className:`flex w-full items-center gap-1`,children:[(0,Y.jsx)(z,{value:d,onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},placeholder:o,disabled:a,className:`h-8 flex-1 text-sm`}),c&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-8 shrink-0 p-0 text-muted-foreground`,onClick:()=>u(!1),disabled:a,"aria-label":G(`engine.inspector.reference.pickFromRecords`,s),title:G(`engine.inspector.reference.pickFromRecords`,s),children:(0,Y.jsx)(Di,{className:`h-3.5 w-3.5`})})]}):(0,Y.jsxs)(`div`,{className:`flex w-full items-center gap-1`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(Ce,{value:d||null,onChange:e=>n(e==null?``:String(e)),readonly:a,dataSource:c,field:{type:`lookup`,name:`value`,reference:e.object,displayField:e.displayField,idField:e.valueField,multiple:!1,allow_create:!1,placeholder:o,...e.picker?{picker:e.picker}:{},...e.subtitle?{subtitle:e.subtitle}:{}}})}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-8 shrink-0 p-0 text-muted-foreground`,onClick:()=>u(!0),disabled:a,"aria-label":G(`engine.inspector.reference.enterManually`,s),title:G(`engine.inspector.reference.enterManually`,s),children:(0,Y.jsx)(di,{className:`h-3.5 w-3.5`})})]})}function mS({resolved:e,value:t,onCommit:n,onBlur:r,onSelect:i,disabled:a,placeholder:o,context:s,showHint:c=!0}){let l=J.useId(),u=$o(),d=s??{draft:{},node:null},f=e?.kind,p=i??(e=>{n(e),r?.()}),m=e?oS(e.kind,e.objectSource,d):void 0,{fields:h}=co(f===`object-field`?m:void 0),g=e?sS(e.kind,e.connectorSource,d):void 0,{options:_}=dS(f===`connector-action`?g:void 0),{options:v}=fS(f===`connector`,u),y=f&&f!==`object-field`&&f!==`node`&&f!==`connector-action`&&f!==`connector`?Qx[f]:void 0,{options:b}=uS(y),x=J.useMemo(()=>{if(f===`object-field`)return h.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));if(f===`connector-action`)return _;if(f===`connector`)return v;if(f===`node`){let e=Array.isArray(d.draft.nodes)?d.draft.nodes:[],t=typeof d.node?.id==`string`?d.node.id:void 0;return e.filter(e=>typeof e?.id==`string`&&e.id&&e.id!==t).map(e=>{let t=String(e.id);return{value:t,label:typeof e.label==`string`&&e.label?`${e.label} (${t})`:t}})}return y?b:[]},[f,y,h,_,v,b,d.draft,d.node]),S=f===`object-field`&&!m,C=f===`connector-action`&&!g,w=iS(e);if(w)return(0,Y.jsx)(pS,{binding:w,value:t,onPick:p,onCommit:n,onBlur:r,disabled:a,placeholder:o,locale:u});if(f===`org-membership-level`){let n=t==null?``:String(t),r=nS(e?.source),i=n&&!r.some(e=>e.value===n)?[...r,{value:n,label:Ss(n,G(`engine.form.invalid`,u),u)}]:r;return(0,Y.jsxs)(Pe,{value:n||void 0,onValueChange:p,disabled:a,children:[(0,Y.jsx)(he,{className:`h-8 w-full text-sm`,children:(0,Y.jsx)(Ze,{placeholder:o??`—`})}),(0,Y.jsx)(Ke,{children:i.map(e=>(0,Y.jsx)(vt,{value:e.value,children:e.label},e.value))})]})}return f===`manager`?(0,Y.jsxs)(`div`,{className:`w-full space-y-1`,children:[(0,Y.jsx)(z,{value:t==null?``:String(t),disabled:!0,placeholder:G(`engine.inspector.reference.managerPlaceholder`,u),className:`h-8 text-sm`}),(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:G(`engine.inspector.reference.managerHint`,u)})]}):f===`queue`?(0,Y.jsxs)(`div`,{className:`w-full space-y-1`,children:[(0,Y.jsx)(z,{value:t==null?``:String(t),onChange:e=>n(e.target.value),onBlur:r,placeholder:o,disabled:a,className:`h-8 text-sm`}),(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-amber-600 dark:text-amber-400`,children:G(`engine.inspector.reference.queueUnsupported`,u)})]}):(0,Y.jsxs)(`div`,{className:`w-full space-y-1`,children:[(0,Y.jsx)(z,{list:x.length?l:void 0,value:t==null?``:String(t),onChange:e=>n(e.target.value),onBlur:r,placeholder:o,disabled:a,className:`h-8 text-sm`}),x.length>0&&(0,Y.jsx)(`datalist`,{id:l,children:x.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.hint?`${e.label} — ${e.hint}`:e.label},e.value))}),c&&f===`object-field`&&m&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:W(`engine.inspector.reference.fieldsOf`,u,{object:m})}),c&&S&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:G(`engine.inspector.reference.setTriggerObject`,u)}),c&&f===`connector-action`&&g&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:W(`engine.inspector.reference.actionsOf`,u,{connector:g})}),c&&C&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:G(`engine.inspector.reference.chooseConnector`,u)})]})}function hS({field:e,value:t,onCommit:n,disabled:r,context:i,required:a}){let o=i?.node??null,s=rS(e.ref,e=>aS(o,e));return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(L,{className:`text-xs text-muted-foreground`,children:[e.label,a&&(0,Y.jsx)(Cs,{})]}),(0,Y.jsx)(mS,{resolved:s,value:t,onCommit:n,disabled:r,placeholder:e.placeholder,context:i})]})}function gS(e){return e===`stringList`||e===`numberList`||e===`objectList`}function _S(e,t,n){if(!e||typeof e.id!=`string`||typeof e.type!=`string`||!t||!Qg(e.type,t,n))return;let r=e.config&&typeof e.config==`object`&&!Array.isArray(e.config)?e.config:{};return{id:e.id,config:r}}function vS(e,t){let n=[...kg(e)].map(e=>({token:e,label:e,group:`screen_fields`}));return[{id:`screen_fields`,label:G(`engine.flowScope.group.screenFields`,t),refs:n}]}function yS(e,t){let n=[];return e.map(e=>{let r=ol(`ol`,n);n.push(r);let i={};for(let n of t){let t=e[n.key];n.kind===`boolean`?i[n.key]=t===!0:gS(n.kind)?i[n.key]=Array.isArray(t)?t:[]:t==null?i[n.key]=``:i[n.key]=String(t)}return{id:r,values:i}})}function bS(e,t){let n=[];for(let r of e){let e={},i=!1;for(let n of t){let t=r.values[n.key];n.kind===`boolean`?t===!0&&(e[n.key]=!0,i=!0):gS(n.kind)?Array.isArray(t)&&t.length>0&&(e[n.key]=t,i=!0):typeof t==`string`&&t.trim()!==``&&(e[n.key]=t.trim(),i=!0)}i&&n.push(e)}return n}function xS({label:e,columns:t,value:n,onCommit:r,disabled:i,addLabel:a,removeLabel:o,emptyLabel:s,itemLabel:c,context:l,scopeGroups:u,approvalScopeGroups:d,fieldId:f,required:p,requiredColumns:m}){let h=$o(),g=J.useMemo(()=>Array.isArray(n)?n.filter(e=>e&&typeof e==`object`):[],[n]),[_,v]=J.useState(()=>yS(g,t)),y=J.useRef(JSON.stringify(g));J.useEffect(()=>{let e=JSON.stringify(g);e!==y.current&&(v(yS(g,t)),y.current=e)},[g,t]);let b=e=>{let n=bS(e,t);y.current=JSON.stringify(n),r(n.length?n:void 0)},x=(e,t,n)=>{v(r=>r.map(r=>r.id===e?{...r,values:{...r.values,[t]:n}}:r))},[S,C]=J.useState(0);J.useEffect(()=>{S!==0&&b(_)},[S]);let w=(e,t,n)=>{v(r=>r.map(r=>r.id===e?{...r,values:{...r.values,[t]:n}}:r)),C(e=>e+1)},T=()=>{let e={};for(let n of t)e[n.key]=n.kind===`boolean`?!1:gS(n.kind)?[]:``;v(t=>[...t,{id:ol(`ol`,t.map(e=>e.id)),values:e}])},E=e=>{v(t=>t.filter(t=>t.id!==e)),C(e=>e+1)};return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(L,{className:`text-xs text-muted-foreground`,children:[e,p&&(0,Y.jsx)(Cs,{})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[_.length===0&&(0,Y.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground`,children:s}),_.map(e=>(0,Y.jsxs)(`div`,{className:`rounded border bg-muted/30 p-2`,children:[(0,Y.jsx)(`div`,{className:`mb-1 flex justify-end`,children:(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground`,onClick:()=>E(e.id),disabled:i,"aria-label":o,title:o,children:(0,Y.jsx)(na,{className:`h-3.5 w-3.5`})})}),(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:t.map(t=>{if(t.kind===`stringList`||t.kind===`numberList`){let n=e.values[t.key],r=Array.isArray(n)?n:[];return(0,Y.jsx)(`div`,{className:`border-l-2 border-muted/60 pl-2`,children:(0,Y.jsx)(Zx,{label:t.label,value:t.kind===`numberList`?r.map(e=>String(e)):r,onCommit:n=>{if(t.kind===`numberList`){let r=(n??[]).map(e=>Number(String(e).trim())).filter(e=>Number.isFinite(e));w(e.id,t.key,r)}else w(e.id,t.key,n??[])},disabled:i,addLabel:a,itemLabel:c??t.label,removeLabel:o,emptyLabel:s})},t.key)}if(t.kind===`objectList`){let n=e.values[t.key],r=Array.isArray(n)?n:[];return(0,Y.jsx)(`div`,{className:`border-l-2 border-muted/60 pl-2`,children:(0,Y.jsx)(xS,{label:t.label,columns:t.columns??[],value:r,onCommit:n=>w(e.id,t.key,n??[]),disabled:i,addLabel:a,removeLabel:o,emptyLabel:s,itemLabel:c,context:l,scopeGroups:u})},t.key)}let n=m?.has(t.key)===!0;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(L,{className:`w-24 shrink-0 text-[11px] text-muted-foreground`,children:[t.label,n&&(0,Y.jsx)(Cs,{})]}),t.kind===`boolean`?(0,Y.jsx)(ge,{checked:e.values[t.key]===!0,onCheckedChange:n=>w(e.id,t.key,n===!0),disabled:i}):t.kind===`reference`?(()=>{let r=rS(t.ref,t=>e.values[t]),a=t.ref?.kindFrom?String(e.values[t.ref.kindFrom]??``):``;if(r===void 0&&a===`expression`){let r=typeof e.values[t.key]==`string`?e.values[t.key]:``;return(0,Y.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,Y.jsx)(Px,{mode:`expression`,mono:!0,value:r,onValueChange:n=>x(e.id,t.key,n),onBlur:()=>b(_),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},groups:d??[],placeholder:t.placeholder??`current.<field> · trigger.<field> · vars.<node>.<key>`,disabled:i,ariaRequired:n}),(0,Y.jsx)(Ix,{value:r,role:`value`,scopeGroups:d})]})}return(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsx)(mS,{resolved:r,value:typeof e.values[t.key]==`string`?e.values[t.key]:``,onCommit:n=>x(e.id,t.key,typeof n==`string`?n:``),onBlur:()=>b(_),onSelect:n=>w(e.id,t.key,n),placeholder:t.placeholder,disabled:i,context:l,showHint:!1})})})():t.kind===`select`?(()=>{let r=typeof e.values[t.key]==`string`?e.values[t.key]:``,a=t.options??[],o=r&&!a.some(e=>e.value===r)?[...a,{value:r,label:Ss(r,G(`engine.form.deprecated`,h),h)}]:a;return(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsxs)(Pe,{value:r||void 0,onValueChange:n=>w(e.id,t.key,n),disabled:i,children:[(0,Y.jsx)(he,{className:`h-8 w-full text-xs`,"aria-required":n?!0:void 0,children:(0,Y.jsx)(Ze,{placeholder:t.placeholder??`—`})}),(0,Y.jsx)(Ke,{children:o.map(e=>(0,Y.jsx)(vt,{value:e.value,children:e.label},e.value))})]})})})():t.kind===`expression`?(()=>{let r=_S(l?.node,f,t.key),a=typeof e.values[t.key]==`string`?e.values[t.key]:``;return(0,Y.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,Y.jsx)(Px,{mode:`expression`,mono:!0,value:a,onValueChange:n=>x(e.id,t.key,n),onBlur:()=>b(_),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},groups:r?vS(r,h):u??[],placeholder:t.placeholder,disabled:i,ariaRequired:n}),(0,Y.jsx)(Ix,{value:a,role:`predicate`,scopeGroups:u,screenNode:r})]})})():(0,Y.jsx)(z,{value:typeof e.values[t.key]==`string`?e.values[t.key]:``,onChange:n=>x(e.id,t.key,n.target.value),onBlur:()=>b(_),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},placeholder:t.placeholder,disabled:i,"aria-required":n?!0:void 0,className:`h-8 flex-1 text-xs`})]},t.key)})})]},e.id))]}),(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 w-full text-xs`,onClick:T,disabled:i,children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),a]})]})}var SS=[],CS=Ao.secret;function wS({id:e,value:t,onCommit:n,disabled:r}){let[i,a]=J.useState(()=>typeof t==`string`&&t!==``?t:void 0),o=i!==void 0&&t===i?Ho:typeof t==`string`&&t!==``?t:void 0;return(0,Y.jsx)(CS,{id:e,value:o,onChange:e=>{if(e!==`••••••••`){if(e===null){a(void 0),n(void 0);return}if(typeof e==`string`&&e!==``){n(e);return}n(i)}},readOnly:r,schema:{type:`string`,writeOnly:!0}})}function TS({field:e,value:t,onCommit:n,disabled:r,locale:i,context:a,scopeGroups:o,approvalScopeGroups:s,triggerScope:c,inactiveRetained:l,onClearInactive:u,required:d,requiredColumns:f}){let p=e.refMode??(e.kind===`expression`?`expression`:`template`),m=e.kind===`expression`&&!!e.conditionBuilder&&!!c&&p!==`template`,h=J.useId(),g=(()=>{if(m&&c)return(0,Y.jsx)(po,{label:e.label,value:t==null?``:String(t),onCommit:e=>n(e),objectName:c.objectName,disabled:r,subjects:{fieldPrefix:c.fieldPrefix,includePrevious:c.includePrevious,context:SS}});switch(e.kind){case`reference`:return(0,Y.jsx)(hS,{field:e,value:t,onCommit:e=>n(e),disabled:r,context:a,required:d});case`keyValue`:return(0,Y.jsx)(Jx,{label:e.label,value:t,onCommit:e=>n(e),disabled:r,addLabel:G(`engine.inspector.flowNode.kv.add`,i),keyLabel:G(`engine.inspector.flowNode.kv.key`,i),valueLabel:G(`engine.inspector.flowNode.kv.value`,i),removeLabel:G(`engine.inspector.flowNode.kv.remove`,i),emptyLabel:G(`engine.inspector.flowNode.kv.empty`,i),scopeGroups:o,required:d,valueEnvelope:Sh(a?.node?.type,e.path)?{toggleLabel:G(`engine.inspector.flowNode.kv.asExpression`,i),expressionPlaceholder:G(`engine.inspector.flowNode.kv.expressionPlaceholder`,i)}:void 0});case`stringList`:return(0,Y.jsx)(Zx,{label:e.label,value:t,onCommit:e=>n(e),disabled:r,required:d,addLabel:G(`engine.inspector.flowNode.list.add`,i),itemLabel:G(`engine.inspector.flowNode.list.item`,i),removeLabel:G(`engine.inspector.flowNode.list.remove`,i),emptyLabel:G(`engine.inspector.flowNode.list.empty`,i)});case`numberList`:return(0,Y.jsx)(Zx,{label:e.label,value:Array.isArray(t)?t.map(e=>String(e)):t,onCommit:e=>{if(e==null)return n(void 0);let t=e.map(e=>Number(String(e).trim())).filter(e=>Number.isFinite(e));n(t.length?t:void 0)},disabled:r,required:d,addLabel:G(`engine.inspector.flowNode.list.add`,i),itemLabel:G(`engine.inspector.flowNode.list.item`,i),removeLabel:G(`engine.inspector.flowNode.list.remove`,i),emptyLabel:G(`engine.inspector.flowNode.list.empty`,i)});case`objectList`:return(0,Y.jsx)(xS,{label:e.label,columns:e.columns??[],value:t,onCommit:e=>n(e),disabled:r,addLabel:G(`engine.inspector.flowNode.list.add`,i),removeLabel:G(`engine.inspector.flowNode.list.remove`,i),emptyLabel:G(`engine.inspector.flowNode.list.empty`,i),itemLabel:G(`engine.inspector.flowNode.list.item`,i),context:a,scopeGroups:o,approvalScopeGroups:s,fieldId:e.id,required:d,requiredColumns:f});case`number`:return(0,Y.jsx)(gs,{label:e.label,value:typeof t==`number`?t:t!=null&&t!==``?Number(t):void 0,placeholder:e.placeholder,onCommit:e=>n(e),disabled:r,required:d});case`boolean`:{let i=Kh(t)?e.defaultValue===`true`:t===!0;return(0,Y.jsx)(cs,{label:e.label,value:i,onCommit:e=>n(e),disabled:r})}case`select`:return(()=>{let a=t==null?``:String(t),o=e.options??[],s=e.defaultValue,c=s!==void 0&&s!==``?o.find(e=>e.value===s)?.label??s:void 0;return(0,Y.jsx)(K,{label:e.label,value:a,options:o,placeholder:c,unknownValueLabel:e=>Ss(e,G(`engine.form.deprecated`,i),i),onCommit:e=>n(e),disabled:r,required:d})})();case`secret`:{let i=typeof a?.node?.id==`string`?a.node.id:``;return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(L,{htmlFor:h,className:`text-xs text-muted-foreground`,children:[e.label,d&&(0,Y.jsx)(Cs,{})]}),(0,Y.jsx)(wS,{id:h,value:t,onCommit:n,disabled:r},i)]})}case`textarea`:return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(L,{className:`text-xs text-muted-foreground`,children:[e.label,d&&(0,Y.jsx)(Cs,{})]}),(0,Y.jsx)(Px,{multiline:!0,rows:4,mode:p,value:t==null?``:String(t),onValueChange:e=>n(e),groups:o??[],placeholder:e.placeholder,disabled:r,ariaRequired:d})]});default:return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(L,{className:`text-xs text-muted-foreground`,children:[e.label,d&&(0,Y.jsx)(Cs,{})]}),(0,Y.jsx)(Px,{mode:p,mono:e.kind===`expression`,value:t==null?``:String(t),onValueChange:e=>n(e),groups:o??[],placeholder:e.placeholder,disabled:r,ariaRequired:d})]})}})(),_=p===`template`,v=e.kind===`expression`&&!_?Tg(`predicate`,t,i):null,y=e.kind===`expression`?_?`template`:`predicate`:p===`template`&&(e.kind===`text`||e.kind===`textarea`)?`template`:null,b=!v&&y&&o&&o.length>0?xg(t,y,gg(o.flatMap(e=>e.refs))):[];return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[g,l&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-1.5`,role:`note`,"data-testid":`inactive-retained`,"data-inactive-retained":l,children:[(0,Y.jsx)(`p`,{className:`flex-1 text-[11px] leading-snug text-amber-700 dark:text-amber-400`,children:G(l===`no-controller`?`engine.inspector.flowNode.inactiveRetainedOrphan`:`engine.inspector.flowNode.inactiveRetained`,i)}),u&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 shrink-0 px-2 text-[11px] text-amber-700 dark:text-amber-400`,onClick:u,disabled:r,children:G(`engine.inspector.flowNode.inactiveRetainedClear`,i)})]}),!l&&qh(e,t)&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-amber-700 dark:text-amber-400`,role:`note`,"data-testid":`unset-notice`,children:e.unsetNotice}),v&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-destructive`,role:`alert`,children:v.message}),!v&&b.length>0&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-amber-600 dark:text-amber-400`,role:`note`,children:Sg(b,i)}),e.help&&!v&&b.length===0&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:e.help})]})}function ES(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function DS(e){let t=``;for(let n of e)t+=typeof n==`number`?`[${n}]`:t?`.${n}`:n;return t}function OS(e,t){let[n,...r]=t,i={...e};return r.length===0?(delete i[n],i):(i[n]=OS(ES(e[n])?e[n]:{},r),i)}function kS(e,t,n){return ue(e,t).some(e=>e.path===n)?!0:x(e,t).some(e=>e.path===n&&e.entry.role===`predicate`&&e.entry.required===!0&&e.value==null&&m(e.value)!==void 0)}function AS(e,t){let n=M.safeParse(e);return!n.success&&n.error.issues.some(e=>e.path.length===t.length&&e.path.every((e,n)=>String(e)===t[n]))}function jS(e,t){if(!e||typeof e.type!=`string`||t.path.length===0)return!1;let n=OS(e,t.path);if(t.path[0]===`config`&&t.path.length>=2){let r=ES(n.config)?n.config:{};if(kS(e.type,r,DS(t.path.slice(1))))return!0}return AS(n,t.path)}function MS(e,t){let n=new Set;if(!e||typeof e.type!=`string`||t.path.length!==2||t.path[0]!==`config`)return n;let r=t.path[1],i={...ES(e.config)?e.config:{},[r]:[{}]};for(let a of t.columns??[])kS(e.type,i,DS([r,0,a.key]))&&n.add(a.key);return n}var NS=[`variables`,`outputs`,`loop`,`trigger`],PS={variables:`engine.flowScope.group.variables`,outputs:`engine.flowScope.group.outputs`,loop:`engine.flowScope.group.loop`,trigger:`engine.flowScope.group.trigger`};function FS(e,t,n,r){let i=$o(),a=J.useMemo(()=>ug(e??{},t,i,r),[e,t,i,r]),{fields:o,loading:s}=co(a.trigger?.objectName);return J.useMemo(()=>{let e=[...a.refs];n&&n.length&&e.push(...n),a.trigger&&e.push(...pg(a.trigger,o,i));let t=new Set,r=e.filter(e=>!t.has(e.token)&&(t.add(e.token),!0)),c=NS.map(e=>({id:e,label:G(PS[e],i),refs:r.filter(t=>t.group===e)})).filter(e=>e.refs.length>0),l=[],u=[];for(let e of o){if(!e?.name)continue;let t=e.label&&e.label!==e.name?e.label:e.type;l.push({token:`current.${e.name}`,label:`current.${e.name}`,detail:t,group:`approval_current`}),u.push({token:`trigger.${e.name}`,label:`trigger.${e.name}`,detail:t,group:`approval_trigger`})}let d=r.filter(e=>e.group===`variables`||e.group===`outputs`||e.group===`loop`).map(e=>({...e,token:`vars.${e.token}`,label:`vars.${e.token}`,group:`approval_vars`}));return d.push({token:`vars.previous`,label:`vars.previous`,detail:G(`engine.flowScope.detail.preUpdateRow`,i),group:`approval_vars`}),{groups:c,refs:r,approvalExpressionGroups:[{id:`approval_current`,label:G(`engine.flowScope.group.approvalCurrent`,i),refs:l},{id:`approval_trigger`,label:G(`engine.flowScope.group.approvalTrigger`,i),refs:u},{id:`approval_vars`,label:G(`engine.flowScope.group.variables`,i),refs:d}].filter(e=>e.refs.length>0),trigger:a.trigger,loading:!!a.trigger&&s,isEmpty:r.length===0}},[a,o,s,n,i])}function IS(e,t,n){let r=typeof t?.source==`string`&&t.source?t.source:void 0,i=t?.type;return FS(e,r,J.useMemo(()=>dg(e??{},{source:r,type:i},n),[e,r,i,n]),n)}var LS=[`description`];function RS(e){if(!LS.some(t=>t in e))return e;let t={...e};for(let e of LS)delete t[e];return t}function zS(e){return e.kind===`objectList`&&Wh(e)===`conditions`&&(e.columns??[]).some(e=>e.key===`target`)}function BS(e){let t=e?.config;return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}function VS(e,t,n){let[r,...i]=t,a={...e};if(i.length===0)n==null||n===``?delete a[r]:a[r]=n;else{let e=a[r],t=VS(e&&typeof e==`object`&&!Array.isArray(e)?e:{},i,n);Object.keys(t).length===0?delete a[r]:a[r]=t}return a}function HS({selection:e,draft:t,onPatch:n,onClearSelection:r,locale:i,readOnly:a}){let o=J.useMemo(()=>D_(t,e),[t,e]),s=o?.node??null,c=bh(),l=J.useMemo(()=>o?.nested&&o.container?cg(o.container).filter(e=>e.group===`loop`):[],[o]),{connectorId:u,actionId:d,storedInput:f}=J.useMemo(()=>{let e=s?.connectorConfig;if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e;return{connectorId:typeof t.connectorId==`string`&&t.connectorId?t.connectorId:void 0,actionId:typeof t.actionId==`string`&&t.actionId?t.actionId:void 0,storedInput:t.input}},[s]),m=xv(!!u&&!!d||ig(t)),{groups:h,approvalExpressionGroups:g,trigger:_}=FS(t,o?.scopeAnchorId,l,m),v=J.useMemo(()=>_v(hv(m,u,d)),[m,u,d]),y=s?.type,b=J.useMemo(()=>{let e=y?c[y]:void 0,t=zh(e===void 0?null:Go(e),y);return bv(Hh(y,t,i),v,f)},[c,y,i,v,f]),x=BS(s),S=p(t),C=b.filter(e=>Gh(e,s,b,S)),w=J.useMemo(()=>{let e=new Map;for(let t of b)e.set(t.id,{required:jS(s,t),columns:t.kind===`objectList`?MS(s,t):void 0});return e},[s,b]),T=J.useMemo(()=>{let e=Array.isArray(t.variables)?t.variables:[],n={};for(let t of e)t&&typeof t.name==`string`&&(n[t.name]=t.defaultValue);return n},[t]),E=J.useMemo(()=>{let e=new Set;for(let t of b){let n=Wh(t);n&&e.add(n),t.fallbackPath&&t.fallbackPath.length>=2&&t.fallbackPath[0]===`config`&&e.add(t.fallbackPath[1])}return e},[b]),D=J.useMemo(()=>{let e=Object.fromEntries(Object.entries(x).filter(([e])=>!E.has(e)));return Object.keys(e).length?JSON.stringify(e,null,2):``},[s,E]),[O,k]=J.useState(D),[A,j]=J.useState(null),[M,N]=J.useState(D.trim()!==``),[P,ee]=J.useState(!1);if(J.useEffect(()=>{k(D),j(null),N(D.trim()!==``),ee(!1)},[D]),!s){let t=(e.kind===`nested-node`?y_(e.id):null)?.nodeId??e.id;return(0,Y.jsx)(is,{kindLabel:G(`engine.inspector.flowNode.kind`,i),title:e.label??t,onClose:r,closeLabel:G(`engine.inspector.flowNode.close`,i),children:(0,Y.jsx)(ls,{message:t})})}let F=e=>{let t=o?.write(RS({...s,...e}));t&&n(t)},te=D.trim()!==``,ne=s.type===`screen`||s.type===`user_task`,re=(e,r)=>{if(!o)return;let i=e.path,a=r,c;if(e.omitKeys&&(a=yv(Uh(s,e),r&&typeof r==`object`&&!Array.isArray(r)?r:{},e.omitKeys)),!o.nested){let n=Array.isArray(t.edges)?t.edges:[];if(zS(e)){let e=jx(s.id,r,n);a=e.conditions.length?e.conditions:void 0,c=e.edges}else s.type===`decision`&&i.length===2&&i[0]===`config`&&i[1]===`conditions`&&(c=kx(s.id,r,n))}let l=VS(s,i,a);e.fallbackPath&&(l=VS(l,e.fallbackPath,void 0));let u=o.write(RS(l));u&&(c&&(u.edges=c),n(u))},ie=()=>{try{let e=O.trim()===``?{}:JSON.parse(O);if(!e||typeof e!=`object`||Array.isArray(e)){j(G(`engine.inspector.flowNode.advancedNotObject`,i));return}let t=Object.fromEntries(Object.entries(x).filter(([e])=>E.has(e))),r=Object.fromEntries(Object.entries(e).filter(([e])=>!E.has(e))),a={...t,...r};j(null);let c={...s};Object.keys(a).length===0?delete c.config:c.config=a;let l=o?.write(RS(c));l&&n(l)}catch(e){j(String(e.message))}},ae=()=>{let e=o?.write(null);e&&n(e),r()},oe=Zh.includes(s.type)?[...Zh]:[...Zh,s.type??``].filter(Boolean),I=!!o?.nested;return(0,Y.jsxs)(is,{kindLabel:G(`engine.inspector.flowNode.kind`,i),title:s.label||s.id,onClose:r,closeLabel:G(`engine.inspector.flowNode.close`,i),footer:I?void 0:(0,Y.jsx)(ps,{label:G(`engine.inspector.flowNode.remove`,i),onClick:ae,disabled:a}),children:[I&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,"aria-label":G(`engine.inspector.flowNode.nestedLocation`,i),children:[(0,Y.jsx)(`span`,{className:`max-w-[45%] truncate font-medium`,children:o?.container?.label||o?.container?.id}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`›`}),(0,Y.jsx)(`span`,{className:`truncate`,children:o?.regionKey?th({key:o.regionKey,label:o.regionLabel},i):o?.regionLabel}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`›`}),(0,Y.jsx)(`span`,{className:`max-w-[45%] truncate font-medium text-foreground`,children:s.label||s.id})]}),(0,Y.jsx)(q,{label:G(`engine.inspector.flowNode.id`,i),value:s.id,onCommit:e=>F({id:e}),disabled:a||I,mono:!0}),I&&(0,Y.jsx)(`p`,{className:`-mt-1 text-[11px] leading-snug text-muted-foreground`,children:G(`engine.inspector.flowNode.nestedIdHint`,i)}),(0,Y.jsx)(q,{label:G(`engine.inspector.flowNode.label`,i),value:s.label??``,onCommit:e=>F({label:e}),disabled:a}),(0,Y.jsx)(K,{label:G(`engine.inspector.flowNode.type`,i),value:s.type,options:oe.map(e=>({value:e,label:Qo(e,i,e)})),onCommit:e=>F({type:e}),disabled:a}),b.length===0?(0,Y.jsx)(`p`,{className:`pt-1 text-xs italic text-muted-foreground`,children:G(`engine.inspector.flowNode.noConfig`,i)}):C.length>0&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:G(`engine.inspector.flowNode.configuration`,i)}),(0,Y.jsx)(`span`,{className:`h-px flex-1 bg-border`,"aria-hidden":!0})]}),C.map(e=>{let n=zS(e),r=I&&n?{...e,columns:(e.columns??[]).filter(e=>e.key!==`target`)}:e,o=n&&!I?Ax(s.id,Uh(s,e),Array.isArray(t.edges)?t.edges:[]):r.omitKeys?vv(Uh(s,r),r.omitKeys):Uh(s,r);return(0,Y.jsx)(TS,{field:r,value:o,onCommit:t=>re(e,t),disabled:a,locale:i,context:{draft:t,node:s},scopeGroups:h,approvalScopeGroups:g,triggerScope:_,inactiveRetained:Xh(e,s,b,S),onClearInactive:a?void 0:()=>re(e,void 0),required:w.get(e.id)?.required,requiredColumns:w.get(e.id)?.columns},e.id)}),ne&&(0,Y.jsx)(B_,{node:s,variables:T,className:`mt-1`,locale:i}),te||P?(0,Y.jsxs)(`details`,{className:`group rounded border bg-muted/20`,open:M,onToggle:e=>N(e.target.open),children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer select-none px-2 py-1.5 text-xs font-medium text-muted-foreground`,children:G(`engine.inspector.flowNode.advanced`,i)}),(0,Y.jsxs)(`div`,{className:`space-y-1 border-t p-2`,children:[(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:G(`engine.inspector.flowNode.advancedHint`,i)}),(0,Y.jsx)(`textarea`,{value:O,onChange:e=>k(e.target.value),onBlur:ie,disabled:a,rows:6,placeholder:`{ }`,className:`w-full rounded border bg-background px-2 py-1.5 font-mono text-xs`}),A&&(0,Y.jsx)(`div`,{className:`text-xs text-destructive`,children:A})]})]}):!a&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{ee(!0),N(!0)},className:`inline-flex items-center gap-1 self-start text-[11px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),G(`engine.inspector.flowNode.advanced`,i)]})]})}function US({label:e,value:t}){return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsx)(`div`,{className:`flex h-8 items-center rounded border bg-muted/30 px-2 font-mono text-sm text-muted-foreground`,children:t})]})}function WS({selection:e,draft:t,onPatch:n,onClearSelection:r,locale:i,readOnly:a}){let o=Array.isArray(t.edges)?t.edges:[],s=o.findIndex((t,n)=>go(t,n)===e.id),c=s>=0?o[s]:null,{groups:l}=IS(t,c,xv(ig(t)));if(!c)return(0,Y.jsx)(is,{kindLabel:G(`engine.inspector.flowEdge.kind`,i),title:e.label??e.id,onClose:r,closeLabel:G(`engine.inspector.flowEdge.close`,i),children:(0,Y.jsx)(ls,{message:G(`engine.inspector.flowEdge.missing`,i)})});let u=e=>{let t={...c,...e};for(let e of[`label`,`condition`,`isDefault`]){let n=t[e];(n===void 0||n===``||n===!1)&&delete t[e]}(t.type==="default"||t.type===``||t.type===void 0)&&delete t.type,n({edges:xs(o,s,t)})},d=c.isDefault===!0,f=(Array.isArray(t.nodes)?t.nodes:[]).find(e=>e.id===c.source),p=f?.type===`decision`&&Array.isArray(f.config?.conditions)?f.config.conditions:[],m=e=>typeof e.expression==`string`?e.expression.trim():``,h=e=>typeof e.label==`string`?e.label.trim():``,g=(()=>{if(!p.length)return``;if(d){let e=p.findIndex(e=>{let t=m(e);return t===``||t===`true`});return e>=0?String(e):``}let e=ao(c.condition),t=e?p.findIndex(t=>m(t)===e):-1;return t<0&&c.label&&(t=p.findIndex(e=>h(e)===c.label)),t>=0?String(t):``})(),_=e=>{if(e===``)return;let t=p[Number(e)];if(!t)return;let n=m(t),r=h(t)||void 0;u(n===``||n===`true`?{isDefault:!0,condition:void 0,label:r}:{isDefault:!1,condition:n,label:r})},v=f?.type===`approval`,y=[`approve`,`reject`,`revise`],b=(()=>{let e=(c.label??``).trim().toLowerCase();return y.includes(e)?e:``})(),x=typeof c.type==`string`&&c.type||`default`;return(0,Y.jsxs)(is,{kindLabel:G(`engine.inspector.flowEdge.kind`,i),title:e.label??`${c.source} → ${c.target}`,onClose:r,closeLabel:G(`engine.inspector.flowEdge.close`,i),footer:(0,Y.jsx)(ps,{label:G(`engine.inspector.flowEdge.remove`,i),onClick:()=>{n({edges:xs(o,s,null)}),r()},disabled:a}),children:[(0,Y.jsx)(US,{label:G(`engine.inspector.flowEdge.source`,i),value:c.source}),(0,Y.jsx)(US,{label:G(`engine.inspector.flowEdge.target`,i),value:c.target}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:G(`engine.inspector.flowEdge.routing`,i)}),(0,Y.jsx)(`span`,{className:`h-px flex-1 bg-border`,"aria-hidden":!0})]}),p.length>0&&(0,Y.jsx)(K,{label:G(`engine.inspector.flowEdge.branch`,i),value:g,options:[...p.map((e,t)=>{let n=m(e),r=h(e)||W(`engine.flowRegion.branchN`,i,{n:t+1}),a=n===``||n===`true`?` \u00b7 ${G(`engine.inspector.flowEdge.branchDefault`,i)}`:` \u00b7 ${n}`;return{value:String(t),label:`${r}${a}`}}),{value:``,label:G(`engine.inspector.flowEdge.branchCustom`,i)}],onCommit:_,disabled:a}),v&&(0,Y.jsx)(K,{label:G(`engine.inspector.flowEdge.approvalBranch`,i),value:b,options:[{value:`approve`,label:G(`engine.inspector.flowEdge.branchApprove`,i)},{value:`reject`,label:G(`engine.inspector.flowEdge.branchReject`,i)},{value:`revise`,label:G(`engine.inspector.flowEdge.branchRevise`,i)},{value:``,label:G(`engine.inspector.flowEdge.branchCustom`,i)}],onCommit:e=>{e&&u({label:e})},disabled:a}),(0,Y.jsx)(q,{label:G(`engine.inspector.flowEdge.label`,i),value:c.label??``,onCommit:e=>u({label:e}),placeholder:G(`engine.inspector.flowEdge.labelHint`,i),disabled:a||d}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:G(`engine.inspector.flowEdge.condition`,i)}),(0,Y.jsx)(Px,{mode:`expression`,mono:!0,value:ao(c.condition)??``,onValueChange:e=>u({condition:ko(c.condition,e)}),groups:l,placeholder:G(`engine.inspector.flowEdge.conditionHint`,i),disabled:a||d})]}),(()=>{let e=d?null:Tg(`predicate`,c.condition,i);if(e)return(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-destructive`,role:`alert`,children:e.message});let t=d?[]:xg(ao(c.condition),`predicate`,gg(l.flatMap(e=>e.refs)));return t.length>0?(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-amber-600 dark:text-amber-400`,role:`note`,children:Sg(t,i)}):null})(),(0,Y.jsx)(cs,{label:G(`engine.inspector.flowEdge.isDefault`,i),value:d,onCommit:e=>u(e?{isDefault:!0,condition:void 0,label:void 0}:{isDefault:!1}),disabled:a}),(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:G(`engine.inspector.flowEdge.hint`,i)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:G(`engine.inspector.flowEdge.connection`,i)}),(0,Y.jsx)(`span`,{className:`h-px flex-1 bg-border`,"aria-hidden":!0})]}),(0,Y.jsx)(K,{label:G(`engine.inspector.flowEdge.type`,i),value:x,options:[{value:`default`,label:G(`engine.inspector.flowEdge.typeDefault`,i)},{value:`conditional`,label:G(`engine.inspector.flowEdge.typeConditional`,i)},{value:`fault`,label:G(`engine.inspector.flowEdge.typeFault`,i)},{value:`back`,label:G(`engine.inspector.flowEdge.typeBack`,i)}],onCommit:e=>u({type:e}),disabled:a}),c.type===`back`&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-amber-600 dark:text-amber-400`,role:`note`,children:G(`engine.inspector.flowEdge.backHint`,i)})]})}function GS(e){return e.selection.kind===`edge`?(0,Y.jsx)(WS,{...e}):(0,Y.jsx)(HS,{...e})}var KS=[`object`,`page`,`dashboard`,`report`,`url`,`group`],qS=[`default`,`view`,`record`,`filters`],JS={object:{targetKey:`objectName`,metaType:`object`},page:{targetKey:`pageName`,metaType:`page`},dashboard:{targetKey:`dashboardName`,metaType:`dashboard`},report:{targetKey:`reportName`,metaType:`report`},url:{targetKey:`url`},group:{}};function YS(e){return e.type!==`record`}var XS=[`objectName`,`viewName`,`recordId`,`recordMode`,`filters`,`pageName`,`dashboardName`,`reportName`,`url`,`target`,`params`],ZS=[`path`,`kind`,`href`,`route`,`object`,`page`,`dashboard`,`report`],QS={object:`object`,page:`page`,dashboard:`dashboard`,report:`report`,link:`url`,url:`url`,group:`group`};function $S(e){let t=e.type;if(typeof t==`string`&&KS.includes(t))return t;let n=e.kind;if(typeof n==`string`&&QS[n])return QS[n];if(e.objectName||e.object)return`object`;if(e.pageName||e.page)return`page`;if(e.dashboardName||e.dashboard)return`dashboard`;if(e.reportName||e.report)return`report`;if(e.url||e.href)return`url`;if(Array.isArray(e.children)&&e.children.length>0)return`group`;let r=e.path;return typeof r==`string`&&/^https?:/i.test(r)?`url`:null}function eC(e){if(e.recordId)return`record`;let t=e.filters;return t&&typeof t==`object`&&!Array.isArray(t)?`filters`:e.viewName?`view`:`default`}function tC(e=[]){let t={};for(let n of[...XS,...ZS])e.includes(n)||(t[n]=void 0);return t}var nC={default:[`objectName`],view:[`objectName`,`viewName`],record:[`objectName`,`recordId`,`recordMode`],filters:[`objectName`,`filters`]};function rC(e,t,n){let r=e.id;if(typeof r==`string`&&r)return r;let i=`nav_${(n??String(e.objectName??e.label??`item`)).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`item`}`,a=new Set(t.map(e=>typeof e.id==`string`?e.id:``).filter(Boolean));if(!a.has(i))return i;let o=2;for(;a.has(`${i}_${o}`);)o++;return`${i}_${o}`}function iC(e){let t=e.split(`.`),n=[];for(let e of t){let t=/^([a-zA-Z_]\w*)\[(\d+)\]$/.exec(e);if(!t)return null;n.push({key:t[1],index:Number(t[2])})}return n.length>0?n:null}function aC(e,t){let n=e[t[0].key];if(!Array.isArray(n))return{parent:[],node:null,index:-1};let r=n[t[0].index]??null;for(let e=1;e<t.length;e++){if(!r)return{parent:n,node:null,index:t[e].index};if(n=r[t[e].key],!Array.isArray(n))return{parent:[],node:null,index:-1};r=n[t[e].index]??null}return{parent:n,node:r,index:t[t.length-1].index}}function oC(e,t,n){let r=t[0].key,i=Array.isArray(e[r])?[...e[r]]:[];if(t.length===1)return{[r]:xs(i,t[0].index,n)};let a=i,o=[];for(let e=0;e<t.length-1;e++){let n={...a[t[e].index]??{}};o.push({arr:a,index:t[e].index,node:n});let r=t[e+1].key,i=Array.isArray(n[r])?[...n[r]]:[];n[r]=i,a[t[e].index]=n,a=i}let s=xs(a,t[t.length-1].index,n);return o[o.length-1].node[t[t.length-1].key]=s,{[r]:i}}function sC(e,t,n){let r=t[0].key;if(t.length===1)return{[r]:n};let i=Array.isArray(e[r])?[...e[r]]:[],a=i;for(let e=0;e<t.length-2;e++){let n={...a[t[e].index]??{}},r=t[e+1].key,i=Array.isArray(n[r])?[...n[r]]:[];n[r]=i,a[t[e].index]=n,a=i}let o=t[t.length-2],s=t[t.length-1].key,c={...a[o.index]??{}};return c[s]=n,a[o.index]=c,{[r]:i}}function cC(e,t){let n=sa(),[r,i]=J.useState({options:[],loading:!!e});return J.useEffect(()=>{if(!e){i({options:[],loading:!1});return}let r=!1;return i(e=>({...e,loading:!0})),n.list(e).then(e=>{if(r)return;let n=(Array.isArray(e)?e:[]).filter(e=>e&&typeof e.name==`string`&&e.name).filter(e=>!t||t(e)).map(e=>({value:String(e.name),label:typeof e.label==`string`&&e.label&&e.label!==e.name?`${e.label} (${e.name})`:String(e.name)}));i({options:n,loading:!1})}).catch(()=>{r||i({options:[],loading:!1})}),()=>{r=!0}},[n,e,t]),r}var lC={currentUserId:`{current_user_id}`,currentOrgId:`{current_org_id}`};function uC({objectName:e,filters:t,onCommit:n,disabled:r,locale:i}){let{fields:a}=co(e||void 0),o=J.useMemo(()=>a.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name})),[a]),s=Object.entries(t),c=(e,t,r)=>{let i=s.slice();i[e]=[t,r],n(Object.fromEntries(i.filter(([e])=>e!==``)))},l=e=>{let t=s.slice();t.splice(e,1),n(Object.fromEntries(t))};return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground`,children:G(`engine.inspector.appNav.filters`,i)}),s.map(([e,t],n)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(cl,{ariaLabel:G(`engine.inspector.appNav.filtersField`,i),value:e,onCommit:e=>c(n,e,t),options:o,placeholder:G(`engine.inspector.appNav.filtersField`,i),disabled:r,mono:!0})}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`=`}),(0,Y.jsx)(`input`,{value:t,onChange:t=>c(n,e,t.target.value),placeholder:G(`engine.inspector.appNav.filtersValue`,i),disabled:r,className:`h-7 w-0 min-w-0 flex-1 rounded border bg-background px-2 font-mono text-xs`,"data-testid":`nav-filter-value-${e||`new`}`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>l(n),disabled:r,className:`rounded p-1 text-muted-foreground hover:bg-muted`,"aria-label":G(`engine.inspector.appNav.filtersRemove`,i),"data-testid":`nav-filter-remove-${e||`new`}`,children:(0,Y.jsx)(na,{className:`h-3 w-3`})})]},`${e}-${n}`)),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n({...t,"":``}),disabled:r||Object.prototype.hasOwnProperty.call(t,``),className:`inline-flex items-center gap-1 rounded border px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted`,"data-testid":`nav-filter-add`,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),G(`engine.inspector.appNav.filtersAdd`,i)]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:G(`engine.inspector.appNav.filtersHint`,i)})]})}function dC({selection:e,draft:t,name:n,onPatch:r,onClearSelection:i,onSelectionChange:a,locale:o,readOnly:s}){let c=iC(e.id),{node:l,parent:u,index:d}=c?aC(t,c):{node:null,parent:[],index:-1},f=l?$S(l):null,p=l?eC(l):`default`,m=String(l?.objectName??l?.object??``),h=cC(f===`object`?`object`:void 0),g=f&&f!==`object`?JS[f].metaType:void 0,_=cC(g,g===`page`?YS:void 0),v=cC(f===`object`&&p===`view`?`view`:void 0),y=Na(),b=J.useMemo(()=>m?v.options.filter(e=>e.value.startsWith(`${m}.`)||!e.value.includes(`.`)):v.options,[v.options,m]);if(!c||!l)return(0,Y.jsx)(is,{kindLabel:G(`engine.inspector.appNav.kind`,o),title:e.label??e.id,onClose:i,closeLabel:G(`engine.inspector.appNav.close`,o),children:(0,Y.jsx)(ls,{message:e.id})});let x=cm(l,o,y).trim()||e.id,S=(e,n=[])=>{let i=e.type??l.type??f??void 0,a={...l,id:rC(l,u),...i?{type:i}:{},...e};for(let e of n)delete a[e];r(oC(t,c,a))},C=e=>{let t=e===``?um(l.label,o):lm(l.label,e,o);t===void 0?S({},[`label`]):S({label:t})},w=e=>{let t=JS[e].targetKey,n=e===`object`?nC.default:t?[t]:[];S({type:e,...tC(n)})},T=e=>{let t=tC(nC[e]);S(e===`filters`?{...t,objectName:m,filters:l.filters??{}}:{...t,objectName:m})},E=()=>{r(oC(t,c,null)),i()},D=e=>{let n=rs(u,d,e);r(sC(t,c,n));let i=c.slice(0,-1).map(e=>`${e.key}[${e.index}]`).join(`.`),o=c[c.length-1].key,s=i?`${i}.${o}[${e}]`:`${o}[${e}]`;a?.({kind:`nav`,id:s,label:x})},O=f&&f!==`group`?qa({...l,type:f},`/apps/${n||`app`}`,lC).href:null,k=JS[f??`group`];return(0,Y.jsxs)(is,{kindLabel:G(`engine.inspector.appNav.kind`,o),title:x,onClose:i,closeLabel:G(`engine.inspector.appNav.close`,o),headerActions:(0,Y.jsx)(us,{index:d,total:u.length,onMove:D,upLabel:G(`engine.inspector.reorder.up`,o),downLabel:G(`engine.inspector.reorder.down`,o),disabled:s}),footer:(0,Y.jsx)(ps,{label:G(`engine.inspector.appNav.remove`,o),onClick:E,disabled:s}),children:[(0,Y.jsx)(q,{label:G(`engine.inspector.appNav.label`,o),value:om(l.label,o),placeholder:sm(l,y),onCommit:C,disabled:s}),(0,Y.jsx)(q,{label:G(`engine.inspector.appNav.icon`,o),value:String(l.icon??``),onCommit:e=>S({icon:e}),disabled:s}),(0,Y.jsx)(K,{label:G(`engine.inspector.appNav.typeField`,o),value:f??``,options:KS.map(e=>({value:e,label:G(`engine.inspector.appNav.type.${e}`,o)})),onCommit:e=>w(e),disabled:s}),f===`object`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(cl,{label:G(`engine.inspector.appNav.object`,o),value:m,options:h.options,loading:h.loading,onCommit:e=>S({objectName:e,object:void 0}),disabled:s,mono:!0}),(0,Y.jsx)(K,{label:G(`engine.inspector.appNav.targetMode`,o),value:p,options:qS.map(e=>({value:e,label:G(`engine.inspector.appNav.mode.${e}`,o)})),onCommit:e=>T(e),disabled:s||!m}),p===`view`&&(0,Y.jsx)(cl,{label:G(`engine.inspector.appNav.view`,o),value:String(l.viewName??``),options:b,loading:v.loading,onCommit:e=>S({viewName:e}),disabled:s,mono:!0}),p===`record`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(q,{label:G(`engine.inspector.appNav.recordId`,o),value:String(l.recordId??``),onCommit:e=>S({recordId:e}),disabled:s,mono:!0}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:G(`engine.inspector.appNav.recordIdHint`,o)}),(0,Y.jsx)(K,{label:G(`engine.inspector.appNav.recordMode`,o),value:String(l.recordMode??`view`),options:[{value:`view`,label:G(`engine.inspector.appNav.recordModeView`,o)},{value:`edit`,label:G(`engine.inspector.appNav.recordModeEdit`,o)}],onCommit:e=>S({recordMode:e}),disabled:s})]}),p===`filters`&&(0,Y.jsx)(uC,{objectName:m,filters:l.filters??{},onCommit:e=>S({filters:e}),disabled:s,locale:o})]}),f&&f!==`object`&&f!==`group`&&k.targetKey&&(k.metaType?(0,Y.jsx)(cl,{label:G(`engine.inspector.appNav.type.${f}`,o),value:String(l[k.targetKey]??``),options:_.options,loading:_.loading,onCommit:e=>S({[k.targetKey]:e}),disabled:s,mono:!0}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(q,{label:G(`engine.inspector.appNav.url`,o),value:String(l.url??l.href??``),onCommit:e=>S({url:e,href:void 0}),disabled:s,mono:!0}),(0,Y.jsx)(K,{label:G(`engine.inspector.appNav.urlTarget`,o),value:String(l.target??`_self`),options:[{value:`_self`,label:G(`engine.inspector.appNav.urlTargetSelf`,o)},{value:`_blank`,label:G(`engine.inspector.appNav.urlTargetBlank`,o)}],onCommit:e=>S({target:e}),disabled:s})]})),O&&(0,Y.jsxs)(`div`,{className:`rounded border bg-muted/30 px-2 py-1.5`,"data-testid":`nav-target-preview`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:G(`engine.inspector.appNav.preview`,o)}),(0,Y.jsx)(`div`,{className:`break-all font-mono text-[11px]`,children:O})]})]})}var fC=[`field`,`label`,`accessorKey`,`header`];function pC(e){let t=/^([a-zA-Z_][\w]*)\.columns\[(\d+)\]$/.exec(e);return t?{variant:t[1],index:Number(t[2])}:null}function mC(e){return typeof e==`string`?{field:e}:e&&typeof e==`object`?e:{}}function hC(e){return e.field??``}function gC(e){return e.label??hC(e)}function _C(e){return Object.keys(e).some(e=>!fC.includes(e))}function vC(e){if(!e)return``;let t=e.data;return t&&typeof t.object==`string`?t.object:typeof e.object==`string`?e.object:``}function yC({selection:e,draft:t,onPatch:n,onClearSelection:r,onSelectionChange:i,locale:a,readOnly:o}){let s=pC(e.id),c=s?t[s.variant]:void 0,l=s&&Array.isArray(c?.columns)?c.columns:[],u=l.map(mC),d=s?u[s.index]??null:null,f=s?typeof l[s.index]==`string`:!1,p=J.useMemo(()=>Wl(),[]),m=vC(c),{fields:h,loading:g,error:_}=co(m||void 0),v=d?hC(d):``,y=J.useMemo(()=>h.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} · ${e.name}`:e.name})),[h]),b=y.length>0||v!==``;if(!s||!d)return(0,Y.jsx)(is,{kindLabel:G(`engine.inspector.viewColumn.kind`,a),title:e.label??e.id,onClose:r,closeLabel:G(`engine.inspector.viewColumn.close`,a),children:(0,Y.jsx)(ls,{message:e.id})});let x=e=>{let t=e.map((e,t)=>{let n=typeof l[t]==`string`,r=hC(e);return n&&!_C(e)&&!e.label&&!e.header&&r?r:e});n({[s.variant]:{...c,columns:t}})},S=e=>{let t=`field`in d||!(`accessorKey`in d)?`field`:`accessorKey`,n=`label`in d||!(`header`in d)?`label`:`header`,r={...e};`field`in e&&(r[t]=e.field,t!==`field`&&delete r.field),`label`in e&&(r[n]=e.label,n!==`label`&&delete r.label),x(xs(u,s.index,{...d,...r}))};return(0,Y.jsxs)(is,{kindLabel:G(`engine.inspector.viewColumn.kind`,a),title:gC(d)||e.id,onClose:r,closeLabel:G(`engine.inspector.viewColumn.close`,a),headerActions:(0,Y.jsx)(us,{index:s.index,total:u.length,onMove:e=>{x(rs(u,s.index,e)),i?.({kind:`column`,id:`${s.variant}.columns[${e}]`,label:gC(d)||`columns[${e}]`})},upLabel:G(`engine.inspector.reorder.up`,a),downLabel:G(`engine.inspector.reorder.down`,a),disabled:o}),footer:(0,Y.jsx)(ps,{label:G(`engine.inspector.viewColumn.remove`,a),onClick:()=>{x(xs(u,s.index,null)),r()},disabled:o}),children:[c&&(0,Y.jsx)(`div`,{className:`pb-1`,children:(0,Y.jsx)(Dl,{variantKey:s.variant,schema:c,columns:l,allStrings:l.length>0&&l.every(e=>typeof e==`string`),objectName:m||void 0,selectedIndex:s.index,readOnly:o,onPatch:n,onSelectionChange:i})}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-3`,children:[b?(0,Y.jsx)(K,{label:G(`engine.inspector.viewColumn.accessorKey`,a),value:hC(d),options:y,unknownValueLabel:e=>Ss(e,G(`engine.form.notInObject`,a),a),roster:ns({loading:g,error:_}),rosterFailureLabel:G(`engine.form.optionsLoadFailedTitle`,a),onCommit:e=>S({field:e}),disabled:o}):(0,Y.jsx)(q,{label:G(`engine.inspector.viewColumn.accessorKey`,a),value:hC(d),onCommit:e=>S({field:e}),disabled:o,mono:!0}),(0,Y.jsx)(q,{label:G(`engine.inspector.viewColumn.header`,a),value:gC(d)===hC(d)?``:gC(d),onCommit:e=>S({label:e}),disabled:o}),!f&&p?(0,Y.jsx)(`div`,{className:`border-t pt-3`,children:(0,Y.jsx)(Bo,{schema:p,value:d,hiddenFields:fC,readOnly:o,onChange:e=>{x(xs(u,s.index,e))}})}):null]})]})}function bC(e){let{selection:t}=e;if(t.kind===`column`)return(0,Y.jsx)(yC,{...e});let n=$l(e.draft,t.id||void 0)??Ql(e.draft);return(0,Y.jsx)(yu,{type:e.type,name:e.name,draft:e.draft,onPatch:e.onPatch,onSelectionChange:e.onSelectionChange,onClearSelection:e.onClearSelection,onBlockingIssuesChange:e.onBlockingIssuesChange,readOnly:e.readOnly,locale:e.locale,variantKey:n?.storeKey??`list`,familyKey:n?.familyKey??n?.storeKey??`list`,isHome:!1})}function xC(e){let t=Ql(e.draft);return(0,Y.jsx)(yu,{...e,variantKey:t?.storeKey??`list`,familyKey:t?.familyKey??t?.storeKey??`list`,isHome:!0})}N();var SC={io:`input`,unrepresentable:`any`},CC=new Set([`name`,`regions`,`children`]),wC,TC=!1;function EC(){if(wC||TC)return wC;try{wC=y(j,SC)}catch(e){TC=!0,typeof console<`u`&&console.warn(`[page-schema] failed to derive Page JSONSchema from spec`,e)}return wC}var DC;function OC(){if(DC)return DC;if(f&&typeof f==`object`){try{let e=JSON.parse(JSON.stringify(f));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!CC.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),DC=e}catch(e){typeof console<`u`&&console.warn(`[page-schema] failed to prune Page authoring form from spec`,e),DC=f}return DC}}function kC({draft:e,onPatch:t,readOnly:n,serverSchema:r,locale:i}){let{schema:a,form:o}=J.useMemo(()=>as({bundledSchema:EC(),bundledForm:OC(),serverSchema:r,excludeFields:CC,sectionTitle:G(`engine.inspector.moreFields`,i)}),[r,i]);return a?(0,Y.jsx)(Bo,{schema:a,form:o,value:e,hiddenFields:[...CC],readOnly:n,onChange:e=>t(e)}):(0,Y.jsx)(`p`,{className:`px-1 py-2 text-xs text-muted-foreground`,children:G(`engine.studio.inspector.noPageSchema`,i)})}de();function AC(e){if(!e||typeof e!=`object`||Array.isArray(e))return{kind:`malformed`,malformed:{raw:e,reason:`not-an-object`}};let t=e;if(typeof t.value!=`string`)return{kind:`malformed`,malformed:{raw:e,reason:`value-not-text`}};if(t.value.trim()===``)return{kind:`malformed`,malformed:{raw:e,reason:`value-empty`}};if(t.label!==void 0&&typeof t.label!=`string`)return{kind:`malformed`,malformed:{raw:e,reason:`label-not-text`}};if(t.color!==void 0&&typeof t.color!=`string`)return{kind:`malformed`,malformed:{raw:e,reason:`color-not-text`}};let n={...t};delete n.value,delete n.label,delete n.color;let r={value:t.value,label:typeof t.label==`string`?t.label:void 0,color:typeof t.color==`string`?t.color:void 0};return Object.keys(n).length>0&&(r.rest=n),{kind:`option`,option:r}}function jC(e){let t=e.options;return Array.isArray(t)?t.map(AC):[]}function MC(e){return e.flatMap(e=>e.kind===`option`?[e.option]:[])}function NC(e){return e===`select`||e===`multiselect`||e===`radio`||e===`checkboxes`}function PC(e){return e===`lookup`||e===`master_detail`||e===`tree`}function FC(e){return e===`formula`||e===`summary`}function IC(e){return e===`number`||e===`currency`||e===`percent`}function LC(e){return IC(e)&&e!==`currency`}function RC(e){return e===`text`||e===`textarea`||e===`email`||e===`url`||e===`phone`||e===`password`}function zC(e){return ie.has(e)}function BC(e,t){let n=`\`${e}\` (`,r=t.indexOf(n);if(r<0)return e;let i=r+n.length,a=1,o=i;for(;o<t.length;o++){let e=t[o];if(e===`(`)a++;else if(e===`)`&&--a===0)break}if(a!==0)return e;let s=t.slice(i,o).split(` — `)[0].replace(/`/g,``).trim();return s?`${e} (${s})`:e}var VC=(()=>{let e=T.shape.valueDomain.description??``;return h.options.map(t=>({value:t,label:BC(t,e)}))})();function HC(e){return e===`boolean`||e===`toggle`?`bool`:e===`number`||e===`currency`||e===`percent`?`number`:e===`select`||e===`radio`?`picklist`:[`formula`,`summary`,`autonumber`,`lookup`,`master_detail`,`tree`,`file`,`image`,`avatar`,`video`,`audio`,`signature`,`qrcode`,`composite`,`repeater`,`vector`,`multiselect`,`checkboxes`,`tags`].includes(e)?null:`text`}var UC=[`record`,`previous`,`parent`],WC=[`record`];function GC(e){return typeof e==`string`?e:e&&typeof e==`object`&&typeof e.source==`string`?e.source:``}function KC(e,t){if(t.trim()){if(e&&typeof e==`object`&&!Array.isArray(e)){let n=e;return{...n,dialect:typeof n.dialect==`string`?n.dialect:`cel`,source:t}}return t}}function qC(e){return bs.flatMap(t=>t.types.map(n=>({value:n,label:`${G(`engine.fieldCategory.${t.category}`,e)} · ${G(`engine.fieldType.${n}`,e)}`})))}function JC({selection:e,draft:t,onPatch:n,onClearSelection:r,onSelectionChange:i,onBlockingIssuesChange:a,readOnly:o,locale:s}){let c=J.useCallback(e=>G(e,s),[s]),l=J.useMemo(()=>qC(s),[s]),u=J.useMemo(()=>vo(t.fields),[t]),d=String(e.id),f=To(u,d),p=f>=0?u.entries[f]:null,m=Array.isArray(t.fieldGroups)?t.fieldGroups:[],h=_w(s),g=J.useRef(!1);J.useEffect(()=>{g.current=!1},[d]);let _=J.useRef(null),v=String(t.name??``),y=p?typeof p.def.type==`string`?p.def.type:`text`:null,[b,x]=J.useState({field:d,sites:{}}),S=J.useCallback((e,t)=>{let n=t.filter(e=>e.severity===`error`).length;x(t=>t.field===d?t.sites[e]===n?t:{field:d,sites:{...t.sites,[e]:n}}:{field:d,sites:{[e]:n}})},[d]),C=J.useMemo(()=>{if(b.field!==d)return 0;let e=0;for(let[t,n]of Object.entries(b.sites))(t!==`formula`||y===`formula`)&&(e+=n??0);return e},[b,d,y]),w=J.useRef(a);if(J.useEffect(()=>{w.current=a}),J.useEffect(()=>{w.current?.(C)},[C]),!p)return(0,Y.jsx)(is,{kindLabel:c(`designer.field.kind`),title:d||c(`designer.field.kind`),onClose:r,closeLabel:c(`designer.field.close`),children:(0,Y.jsx)(ls,{message:c(`designer.field.missing`)})});let T=p.def,E=y,D=fs[E],O=e=>{n({fields:Oo(e)})},k=e=>{let t=[...u.entries];t[f]={...p,def:{...T,...e}},O({shape:u.shape,entries:t})},A=e=>{let t={...T};delete t[e];let n=[...u.entries];n[f]={...p,def:t},O({shape:u.shape,entries:n})},j=e=>{let t=Vo(e),n=!t||t===p.name||u.entries.some((e,n)=>n!==f&&e.name===t);if(_.current={object:v,field:n?p.name:t,owner:`author`},n)return;let r=[...u.entries];r[f]={...p,name:t},O({shape:u.shape,entries:r}),i?.({kind:`field`,id:t,label:String(T.label??t)})},M=()=>{let e=_.current;return e&&e.object===v&&e.field===p.name?e.owner:null},N=e=>{if(o)return null;let t=M();if(t===`author`)return null;let n=E===`select`?`status`:E;if(!(t===`label`||p.name===n||p.name.startsWith(`${n}_`)&&/^\d+$/.test(p.name.slice(n.length+1))||/^field_\d+$/.test(p.name)))return null;let r=Vo(e);return!r||r===p.name||u.entries.some((e,t)=>t!==f&&e.name===r)?null:r},P=()=>{let e=u.entries.filter((e,t)=>t!==f);O({shape:u.shape,entries:e}),r()},ee=()=>{let e=new Set(u.entries.map(e=>e.name)),t=`${p.name}_copy`,n=t,r=1;for(;e.has(n);)r+=1,n=`${t}_${r}`;let a=typeof T.label==`string`&&T.label?T.label:``,o={name:n,def:{...T,label:a?a+c(`designer.field.copySuffix`):void 0}},s=[...u.entries];s.splice(f+1,0,o),O({shape:u.shape,entries:s}),i?.({kind:`field`,id:n,label:String(o.def.label??n)})},F=e=>{let t={shape:u.shape,entries:rs(u.entries,f,e)};O(t)},te=jC(T),ne=MC(te),re=e=>{let t=e.map(e=>{if(e.kind===`malformed`)return e.malformed.raw;let t=e.option,n={...t.rest,value:t.value,label:t.label??``};return t.color&&(n.color=t.color),n});k({options:t})},ie=(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!o&&(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:ee,title:c(`designer.field.duplicate`),"aria-label":c(`designer.field.duplicate`),children:(0,Y.jsx)(er,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(us,{index:f,total:u.entries.length,onMove:F,disabled:o})]}),ae=(0,Y.jsx)(ps,{label:W(`designer.field.remove`,s,{label:typeof T.label==`string`?T.label:p.name}),onClick:P,disabled:o}),oe=D?G(`engine.fieldType.${D.id}`,s):void 0;return(0,Y.jsxs)(is,{kindLabel:c(`designer.field.kind`),title:typeof T.label==`string`&&T.label?T.label:p.name,onClose:r,closeLabel:c(`designer.field.close`),headerActions:ie,footer:ae,children:[(0,Y.jsxs)(YC,{title:c(`designer.field.section.basic`),children:[(0,Y.jsx)(q,{label:c(`designer.field.apiName`),value:p.name,onCommit:j,disabled:o,mono:!0,testId:`field-apiname-input`}),(0,Y.jsx)(q,{label:c(`designer.field.label`),value:typeof T.label==`string`?T.label:``,onCommit:e=>{let t=N(e),n=[...u.entries];n[f]={...p,name:t??p.name,def:{...T,label:e}},O({shape:u.shape,entries:n}),t&&(_.current={object:v,field:t,owner:`label`},i?.({kind:`field`,id:t,label:e}))},disabled:o,testId:`field-label-input`}),(0,Y.jsx)(K,{label:c(`designer.field.type`),value:E,options:l,onCommit:e=>k({type:e}),disabled:o}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-4 pt-1`,children:[(0,Y.jsx)(cs,{label:c(`designer.field.required`),value:!!T.required,onCommit:e=>k({required:e||void 0}),disabled:o}),(0,Y.jsx)(cs,{label:c(`designer.field.unique`),value:!!T.unique,onCommit:e=>k({unique:e||void 0}),disabled:o})]}),(0,Y.jsx)(ZC,{label:c(`designer.field.description`),value:typeof T.description==`string`?T.description:``,onCommit:e=>k({description:e||void 0}),disabled:o,rows:2}),HC(E)&&(0,Y.jsx)(XC,{kind:HC(E),value:T.defaultValue,options:ne,onCommit:e=>k({defaultValue:e}),disabled:o,locale:s}),(0,Y.jsx)(ZC,{label:c(`designer.field.helpText`),value:typeof T.inlineHelpText==`string`?T.inlineHelpText:``,onCommit:e=>k({inlineHelpText:e||void 0}),disabled:o,rows:2,placeholder:c(`designer.field.helpTextPlaceholder`)})]}),(NC(E)||PC(E)||FC(E)||IC(E)||RC(E)||zC(E))&&(0,Y.jsxs)(YC,{title:W(`designer.field.section.options`,s,{type:oe??E}),children:[NC(E)&&(0,Y.jsx)(tw,{rows:te,onChange:re,disabled:o,locale:s},p.name),PC(E)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(QC,{label:c(`designer.field.relatedObject`),value:typeof T.reference==`string`?T.reference:``,options:h,onCommit:e=>k({reference:e||void 0}),disabled:o,placeholder:c(`designer.field.objectNamePlaceholder`)}),(0,Y.jsx)(q,{label:c(`designer.field.relationshipName`),value:typeof T.relationshipName==`string`?T.relationshipName:``,onCommit:e=>k({relationshipName:e||void 0}),disabled:o,placeholder:c(`designer.field.relationshipNameHint`)}),(0,Y.jsx)(ow,{def:T,patchDef:k,hostFieldNames:u.entries.map(e=>e.name).filter(e=>e!==p.name),readOnly:o,locale:s})]}),E===`formula`&&(0,Y.jsx)(Yo,{id:`field-formula-${p.name}`,label:c(`designer.field.formula`),value:GC(T.expression??T.formula),onChange:e=>{g.current=!0,k({expression:KC(T.expression??T.formula,e),formula:void 0,...e.trim()?{}:{returnType:void 0}})},onLintChange:e=>S(`formula`,e),onInferredTypeChange:e=>{if(!g.current)return;let t=e&&e!==`unknown`?e:void 0;T.returnType!==t&&k({returnType:t})},disabled:o,placeholder:`record.amount * 0.2`,objectName:typeof t.name==`string`?t.name:void 0,fieldNames:u.entries.map(e=>e.name).filter(e=>e!==p.name),scope:`record`,roots:WC,role:`value`,t:c}),E===`summary`&&(0,Y.jsx)(gw,{def:T,patchDef:k,objectOptions:h,readOnly:o,locale:s}),IC(E)&&(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Y.jsx)(gs,{label:c(`designer.field.precision`),value:typeof T.precision==`number`?T.precision:void 0,onCommit:e=>k({precision:e}),disabled:o}),LC(E)&&(0,Y.jsx)(gs,{label:c(`designer.field.scale`),value:typeof T.scale==`number`?T.scale:void 0,onCommit:e=>k({scale:e}),disabled:o}),(0,Y.jsx)(gs,{label:c(`designer.field.min`),value:typeof T.min==`number`?T.min:void 0,onCommit:e=>k({min:e}),disabled:o}),(0,Y.jsx)(gs,{label:c(`designer.field.max`),value:typeof T.max==`number`?T.max:void 0,onCommit:e=>k({max:e}),disabled:o})]}),RC(E)&&(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Y.jsx)(gs,{label:c(`designer.field.minLength`),value:typeof T.minLength==`number`?T.minLength:void 0,onCommit:e=>k({minLength:e}),disabled:o,placeholder:`0`}),(0,Y.jsx)(gs,{label:c(`designer.field.maxLength`),value:typeof T.maxLength==`number`?T.maxLength:void 0,onCommit:e=>k({maxLength:e}),disabled:o,placeholder:`255`})]}),zC(E)&&(0,Y.jsx)(K,{label:c(`designer.field.valueDomain`),value:typeof T.valueDomain==`string`?T.valueDomain:``,options:[{value:``,label:c(`designer.field.valueDomainNone`)},...VC],onCommit:e=>e?k({valueDomain:e}):A(`valueDomain`),disabled:o})]}),(0,Y.jsxs)(YC,{title:c(`designer.field.section.advanced`),children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Y.jsx)(cs,{label:c(`designer.field.readonly`),value:!!T.readonly,onCommit:e=>k({readonly:e||void 0}),disabled:o}),(0,Y.jsx)(cs,{label:c(`designer.field.hidden`),value:!!T.hidden,onCommit:e=>k({hidden:e||void 0}),disabled:o}),(0,Y.jsx)(cs,{label:c(`designer.field.externalId`),value:!!T.externalId,onCommit:e=>k({externalId:e||void 0}),disabled:o}),(0,Y.jsx)(cs,{label:c(`designer.field.trackHistory`),value:!!T.trackHistory,onCommit:e=>k({trackHistory:e||void 0}),disabled:o})]}),(0,Y.jsx)(q,{label:c(`designer.field.placeholder`),value:typeof T.placeholder==`string`?T.placeholder:``,onCommit:e=>k({placeholder:e||void 0}),disabled:o}),(0,Y.jsxs)(`div`,{className:`space-y-2 border-t pt-2.5`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground`,children:c(`designer.field.conditionalRules`)}),(0,Y.jsx)(Yo,{id:`field-rule-visible-${p.name}`,label:c(`designer.field.visibleWhen`),value:GC(T.visibleWhen),onChange:e=>k({visibleWhen:KC(T.visibleWhen,e)}),onLintChange:e=>S(`visibleWhen`,e),disabled:o,placeholder:`record.status != 'draft'`,objectName:typeof t.name==`string`?t.name:void 0,fieldNames:u.entries.map(e=>e.name),scope:`record`,roots:UC,slot:`visibleWhen`,t:c}),(0,Y.jsx)(Yo,{id:`field-rule-readonly-${p.name}`,label:c(`designer.field.readonlyWhen`),value:GC(T.readonlyWhen),onChange:e=>k({readonlyWhen:KC(T.readonlyWhen,e)}),onLintChange:e=>S(`readonlyWhen`,e),disabled:o,placeholder:`record.status == 'closed'`,objectName:typeof t.name==`string`?t.name:void 0,fieldNames:u.entries.map(e=>e.name),scope:`record`,roots:UC,slot:`readonlyWhen`,t:c}),(0,Y.jsx)(Yo,{id:`field-rule-required-${p.name}`,label:c(`designer.field.requiredWhen`),value:GC(T.requiredWhen),onChange:e=>k({requiredWhen:KC(T.requiredWhen,e)}),onLintChange:e=>S(`requiredWhen`,e),disabled:o,placeholder:`record.amount > 10000`,objectName:typeof t.name==`string`?t.name:void 0,fieldNames:u.entries.map(e=>e.name),scope:`record`,roots:UC,slot:`requiredWhen`,t:c}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80 px-0.5 leading-snug`,children:c(`designer.field.conditionalRulesHint`)})]}),m.length>0&&(0,Y.jsx)(K,{label:c(`designer.field.group`),value:typeof T.group==`string`?T.group:``,options:[{value:``,label:c(`designer.field.noGroup`)},...m.filter(e=>typeof e.key==`string`).map(e=>({value:e.key,label:String(e.label??e.key)}))],onCommit:e=>k({group:e||void 0}),disabled:o})]})]})}function YC({title:e,children:t}){return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground border-b pb-1`,children:e}),(0,Y.jsx)(`div`,{className:`space-y-2`,children:t})]})}function XC({kind:e,value:t,options:n,onCommit:r,disabled:i,locale:a}){let o=G(`designer.field.defaultValue`,a),s=G(`designer.field.defaultNone`,a);return e===`bool`?(0,Y.jsx)(K,{label:o,value:t===!0?`true`:t===!1?`false`:``,options:[{value:``,label:s},{value:`true`,label:G(`designer.field.true`,a)},{value:`false`,label:G(`designer.field.false`,a)}],onCommit:e=>r(e===``?void 0:e===`true`),disabled:i}):e===`number`?(0,Y.jsx)(gs,{label:o,value:typeof t==`number`?t:void 0,onCommit:e=>r(e),disabled:i}):e===`picklist`?(0,Y.jsx)(K,{label:o,value:typeof t==`string`?t:``,options:[{value:``,label:s},...n.filter(e=>e.value).map(e=>({value:e.value,label:e.label||e.value}))],onCommit:e=>r(e||void 0),disabled:i}):(0,Y.jsx)(q,{label:o,value:typeof t==`string`?t:t==null?``:String(t),onCommit:e=>r(e||void 0),disabled:i})}function ZC({label:e,value:t,onCommit:n,disabled:r,rows:i=2,mono:a,placeholder:o}){return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsx)(`textarea`,{value:t,disabled:r,rows:i,placeholder:o,onChange:e=>n(e.target.value),className:`w-full text-sm rounded-md border bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-primary `+(a?`font-mono text-xs `:``)})]})}function QC({label:e,value:t,options:n,onCommit:r,disabled:i,placeholder:a}){let o=J.useId();return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsx)(z,{list:o,value:t,onChange:e=>r(e.target.value),disabled:i,className:`h-8 text-sm font-mono`,placeholder:a??`object_name`}),(0,Y.jsx)(`datalist`,{id:o,children:n.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}var $C={"not-an-object":`designer.field.optMalformed.notAnObject`,"value-not-text":`designer.field.optMalformed.valueNotText`,"value-empty":`designer.field.optMalformed.valueEmpty`,"label-not-text":`designer.field.optMalformed.labelNotText`,"color-not-text":`designer.field.optMalformed.colorNotText`};function ew(e){let t;try{t=JSON.stringify(e)??String(e)}catch{t=String(e)}return t.length>120?`${t.slice(0,119)}…`:t}function tw({rows:e,onChange:t,disabled:n,locale:r}){let[i,a]=J.useState(()=>e.length>0?e:[{kind:`option`,option:{value:``,label:``}}]),o=e=>{a(e),t(e.filter(e=>e.kind===`malformed`||e.option.value.trim()!==``))},s=(e,t)=>{let n=[...i],r=n[e];r.kind===`option`&&(n[e]={kind:`option`,option:{...r.option,...t}},o(n))},c=e=>o(i.filter((t,n)=>n!==e)),l=(e,t)=>o(rs(i,e,t)),u=()=>o([...i,{kind:`option`,option:{value:``,label:``}}]),d=e=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>l(e,e-1),disabled:n||e===0,"aria-label":G(`designer.field.moveUp`,r),children:(0,Y.jsx)(fn,{className:`h-3 w-3`})}),(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>l(e,e+1),disabled:n||e===i.length-1,"aria-label":G(`designer.field.moveDown`,r),children:(0,Y.jsx)(un,{className:`h-3 w-3`})}),(0,Y.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive`,onClick:()=>c(e),disabled:n,"aria-label":G(`designer.field.removeValue`,r),children:(0,Y.jsx)(na,{className:`h-3 w-3`})})]});return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:G(`designer.field.picklistValues`,r)}),(0,Y.jsx)(V,{variant:`outline`,className:`text-[10px]`,children:i.length})]}),i.length===0?(0,Y.jsx)(`div`,{className:`text-[11px] italic text-muted-foreground px-1`,children:G(`designer.field.noValues`,r)}):(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:i.map((e,t)=>e.kind===`malformed`?(0,Y.jsxs)(`div`,{role:`alert`,"data-testid":`option-malformed`,className:`rounded-md border border-destructive/60 bg-destructive/5 p-1.5 space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,Y.jsx)(Ji,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-medium text-destructive`,children:G(`designer.field.optMalformed`,r)}),(0,Y.jsx)(`div`,{className:`text-[11px] text-destructive`,children:G($C[e.malformed.reason],r)}),(0,Y.jsx)(`code`,{className:`block truncate rounded bg-muted px-1 py-0.5 font-mono text-[10px]`,children:ew(e.malformed.raw)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:G(`designer.field.optMalformedHint`,r)})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`flex-1`}),d(t)]})]},t):(0,Y.jsxs)(`div`,{className:`rounded-md border border-border/60 p-1.5 space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(z,{value:e.option.value,onChange:e=>s(t,{value:e.target.value}),placeholder:G(`designer.field.optValue`,r),disabled:n,className:`h-7 min-w-0 flex-1 text-xs font-mono`}),(0,Y.jsx)(z,{value:e.option.label??``,onChange:e=>s(t,{label:e.target.value}),placeholder:G(`designer.field.optLabel`,r),disabled:n,className:`h-7 min-w-0 flex-1 text-xs`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`input`,{type:`color`,value:e.option.color??`#cccccc`,onChange:e=>s(t,{color:e.target.value}),disabled:n,className:`h-6 w-6 rounded border bg-background cursor-pointer p-0.5`,title:G(`designer.field.optColor`,r)}),(0,Y.jsx)(`span`,{className:`flex-1`}),d(t)]})]},t))}),!n&&(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,className:`h-7 gap-1 text-xs`,onClick:u,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),G(`designer.field.addValue`,r)]})]})}var nw=[{value:`eq`,symbol:`=`,labelKey:`engine.inspector.condition.op.equals`},{value:`ne`,symbol:`≠`,labelKey:`engine.inspector.condition.op.notEquals`},{value:`gt`,symbol:`>`,labelKey:`engine.inspector.condition.op.greaterThan`},{value:`lt`,symbol:`<`,labelKey:`engine.inspector.condition.op.lessThan`},{value:`gte`,symbol:`≥`,labelKey:`engine.inspector.condition.op.atLeast`},{value:`lte`,symbol:`≤`,labelKey:`engine.inspector.condition.op.atMost`},{value:`contains`,labelKey:`engine.inspector.condition.op.contains`},{value:`in`,labelKey:`engine.inspector.condition.op.inAnyOf`},{value:`notIn`,labelKey:`engine.inspector.condition.op.notIn`}];function rw(e){return nw.map(t=>{let n=G(t.labelKey,e);return{value:t.value,label:t.symbol?`${t.symbol} ${n}`:n}})}function iw(e){let t=e.lookupFilters??e.lookup_filters;return Array.isArray(t)?t:[]}function aw(e){let t=e.dependsOn??e.depends_on;return Array.isArray(t)?t.map(e=>typeof e==`string`?e:e&&typeof e==`object`?e.field:void 0).filter(e=>!!e):[]}function ow({def:e,patchDef:t,hostFieldNames:n,readOnly:r,locale:i}){let a=e=>G(e,i),o=typeof e.reference==`string`?e.reference:void 0,{fields:s,loading:c}=co(o),l=J.useMemo(()=>s.filter(e=>!e.hidden).map(e=>({value:e.name,label:e.label,hint:e.type})),[s]),u=J.useMemo(()=>n.map(e=>({value:e,label:e})),[n]),d=iw(e),f=aw(e),p=(e,n)=>t({lookupFilters:d.map((t,r)=>r===e?{...t,...n}:t)}),m=()=>t({lookupFilters:[...d,{field:``,operator:`eq`,value:``}]}),h=e=>{let n=d.filter((t,n)=>n!==e);t({lookupFilters:n.length?n:void 0})},g=e=>Array.isArray(e)?e.join(`, `):e==null?``:String(e),_=(e,t)=>e===`in`||e===`notIn`?t.split(`,`).map(e=>e.trim()).filter(Boolean):t,v=e=>{e&&!f.includes(e)&&t({dependsOn:[...f,e]})},y=e=>{let n=f.filter(t=>t!==e);t({dependsOn:n.length?n:void 0})},b=typeof e.displayField==`string`?e.displayField:``,x=typeof e.descriptionField==`string`?e.descriptionField:``,S=typeof e.lookupPageSize==`number`?e.lookupPageSize:void 0,C=e.allowCreate===!0,w=a(o?`designer.field.lookup.selectField`:`designer.field.lookup.setTargetFirst`);return(0,Y.jsxs)(`div`,{className:`space-y-2 border-t pt-2.5`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground`,children:a(`designer.field.lookup.pickerConfig`)}),(0,Y.jsx)(cl,{label:a(`designer.field.lookup.displayField`),value:b,onCommit:e=>t({displayField:e||void 0}),options:l,loading:c,placeholder:w,searchPlaceholder:a(`designer.field.lookup.searchFields`),disabled:r,mono:!0}),(0,Y.jsx)(cl,{label:a(`designer.field.lookup.descriptionField`),value:x,onCommit:e=>t({descriptionField:e||void 0}),options:l,loading:c,placeholder:w,searchPlaceholder:a(`designer.field.lookup.searchFields`),disabled:r,mono:!0}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 pt-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:a(`designer.field.lookup.selectableRecords`)}),(0,Y.jsx)(V,{variant:`outline`,className:`text-[10px]`,children:d.length})]}),!r&&(0,Y.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 gap-1 px-1.5 text-[11px]`,onClick:m,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),` `,a(`designer.field.lookup.addFilter`)]})]}),d.length===0?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-2 text-center text-[11px] text-muted-foreground`,children:W(`designer.field.lookup.noFilter`,i,{ref:o||`related`})}):d.map((e,t)=>(0,Y.jsxs)(`div`,{className:`rounded-md border p-2 space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:W(`designer.field.lookup.filterN`,i,{n:t+1})}),!r&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":a(`designer.field.lookup.removeFilter`),className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>h(t),children:(0,Y.jsx)(na,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsx)(cl,{label:a(`designer.field.lookup.filterField`),value:e.field??``,onCommit:e=>p(t,{field:e}),options:l,loading:c,placeholder:w,searchPlaceholder:a(`designer.field.lookup.searchFields`),disabled:r,mono:!0}),(0,Y.jsx)(K,{label:a(`designer.field.lookup.filterOperator`),value:e.operator??`eq`,options:rw(i),onCommit:e=>p(t,{operator:e}),disabled:r}),(0,Y.jsx)(q,{label:a(`designer.field.lookup.filterValue`),value:g(e.value),onCommit:n=>p(t,{value:_(e.operator,n)}),placeholder:e.operator===`in`||e.operator===`notIn`?`comma,separated,values`:a(`engine.inspector.condition.valuePlaceholder`),disabled:r,mono:!0})]},t))]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 pt-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:a(`designer.field.lookup.dependsOn`)}),f.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:f.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-secondary px-2 py-0.5 text-[11px] font-mono`,children:[e,!r&&(0,Y.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>y(e),"aria-label":W(`engine.form.removeNamed`,i,{name:e}),children:`×`})]},e))}),!r&&u.length>0&&(0,Y.jsx)(cl,{ariaLabel:a(`designer.field.lookup.addDependsOn`),value:``,onCommit:e=>v(e),options:u.filter(e=>!f.includes(e.value)),placeholder:a(`designer.field.lookup.addDependsOn`),searchPlaceholder:a(`designer.field.lookup.searchHostFields`),disabled:r,allowCustom:!1,mono:!0})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 pt-1`,children:[(0,Y.jsx)(gs,{label:a(`designer.field.lookup.pageSize`),value:S,onCommit:e=>t({lookupPageSize:e}),placeholder:`10`,disabled:r}),(0,Y.jsx)(`div`,{className:`flex items-end pb-1.5`,children:(0,Y.jsx)(cs,{label:a(`designer.field.lookup.allowCreate`),value:C,onCommit:e=>t({allowCreate:e||void 0}),disabled:r})})]})]})}var sw=[`count`,`sum`,`min`,`max`,`avg`];function cw(e){let t=e.summaryOperations;return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}var lw={ne:`$ne`,gt:`$gt`,lt:`$lt`,gte:`$gte`,lte:`$lte`,contains:`$contains`,in:`$in`,notIn:`$nin`},uw={$eq:`eq`,$ne:`ne`,$gt:`gt`,$lt:`lt`,$gte:`gte`,$lte:`lte`,$contains:`contains`,$in:`in`,$nin:`notIn`},dw=new Set([`number`,`currency`,`percent`,`rating`,`slider`,`autonumber`]);function fw(e,t,n){let r=e=>{if(typeof e!=`string`)return e;let n=e.trim();if(t===`boolean`||t===`toggle`)return n===`true`||n===`1`;if(t&&dw.has(t)){let t=Number(n);return n!==``&&Number.isFinite(t)?t:e}return e};return n?(Array.isArray(e)?e:String(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)).map(r):r(e)}function pw(e){if(!e||typeof e!=`object`||Array.isArray(e))return{rows:[],advanced:!1};let t=[],n=!1,r=e=>{for(let[i,a]of Object.entries(e)){if(i===`$and`&&Array.isArray(a)){for(let e of a)e&&typeof e==`object`&&!Array.isArray(e)?r(e):n=!0;continue}if(i.startsWith(`$`)){n=!0;continue}if(typeof a==`object`&&a&&!Array.isArray(a)){let e=Object.entries(a);if(e.length===0){n=!0;continue}for(let[r,a]of e){let e=uw[r];e?t.push({field:i,operator:e,value:a}):n=!0}}else t.push({field:i,operator:`eq`,value:a})}};return r(e),{rows:t,advanced:n}}function mw(e,t){let n=e.filter(e=>e.field);if(n.length===0)return;let r=n.map(e=>{let n=e.operator===`in`||e.operator===`notIn`,r=fw(e.value,t(e.field),n);return e.operator===`eq`?{[e.field]:r}:{[e.field]:{[lw[e.operator]??`$eq`]:r}}});if(r.length===1)return r[0];let i=r.map(e=>Object.keys(e)[0]);return new Set(i).size===i.length?Object.assign({},...r):{$and:r}}var hw=e=>Array.isArray(e)?e.join(`, `):e==null?``:String(e);function gw({def:e,patchDef:t,objectOptions:n,readOnly:r,locale:i}){let a=e=>G(e,i),o=cw(e),s=typeof o.object==`string`?o.object:``,c=typeof o.function==`string`?o.function:``,{fields:l,loading:u}=co(s||void 0),d=e=>{let n={...o,...e};for(let e of Object.keys(n))(n[e]===void 0||n[e]===``)&&delete n[e];t({summaryOperations:Object.keys(n).length>0?n:void 0})},f=J.useMemo(()=>l.filter(e=>!e.hidden).map(e=>({value:e.name,label:e.label,hint:e.type})),[l]),p=J.useMemo(()=>l.filter(e=>e.type===`lookup`||e.type===`master_detail`).map(e=>({value:e.name,label:e.label,hint:e.type})),[l]),m=a(s?`designer.field.lookup.selectField`:`designer.field.summary.setObjectFirst`),h=J.useCallback(e=>l.find(t=>t.name===e)?.type,[l]),{rows:g,advanced:_}=pw(o.filter),v=e=>d({filter:mw(e,h)}),y=(e,t)=>v(g.map((n,r)=>r===e?{...n,...t}:n)),b=()=>v([...g,{field:f[0]?.value??``,operator:`eq`,value:``}]),x=e=>v(g.filter((t,n)=>n!==e));return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(QC,{label:a(`designer.field.summary.object`),value:s,options:n,onCommit:e=>d({object:e||void 0}),disabled:r,placeholder:a(`designer.field.objectNamePlaceholder`)}),(0,Y.jsx)(K,{label:a(`designer.field.summary.function`),value:c,options:[{value:``,label:a(`designer.field.defaultNone`)},...sw.map(e=>({value:e,label:a(`designer.field.summary.fn.${e}`)}))],onCommit:e=>d({function:e||void 0}),disabled:r}),(0,Y.jsx)(cl,{label:a(`designer.field.summary.field`),value:typeof o.field==`string`?o.field:``,onCommit:e=>d({field:e||void 0}),options:f,loading:u,placeholder:m,searchPlaceholder:a(`designer.field.lookup.searchFields`),disabled:r,mono:!0}),c===`count`&&(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70 px-0.5 -mt-1`,children:a(`designer.field.summary.countFieldHint`)}),(0,Y.jsx)(cl,{label:a(`designer.field.summary.relationshipField`),value:typeof o.relationshipField==`string`?o.relationshipField:``,onCommit:e=>d({relationshipField:e||void 0}),options:p,loading:u,placeholder:m,searchPlaceholder:a(`designer.field.lookup.searchFields`),disabled:r,mono:!0}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 border-t pt-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:a(`designer.field.summary.filterSection`)}),!_&&(0,Y.jsx)(V,{variant:`outline`,className:`text-[10px]`,children:g.length})]}),!r&&!_&&(0,Y.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 gap-1 px-1.5 text-[11px]`,onClick:b,disabled:f.length===0,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),` `,a(`designer.field.summary.addFilter`)]})]}),_?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-2 text-[11px] text-muted-foreground`,children:a(`designer.field.summary.filterAdvanced`)}):g.length===0?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-2 text-center text-[11px] text-muted-foreground`,children:a(`designer.field.summary.noFilter`)}):g.map((e,t)=>(0,Y.jsxs)(`div`,{className:`rounded-md border p-2 space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:W(`designer.field.lookup.filterN`,i,{n:t+1})}),!r&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":a(`designer.field.lookup.removeFilter`),className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>x(t),children:(0,Y.jsx)(na,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsx)(cl,{label:a(`designer.field.lookup.filterField`),value:e.field??``,onCommit:e=>y(t,{field:e}),options:f,loading:u,placeholder:m,searchPlaceholder:a(`designer.field.lookup.searchFields`),disabled:r,mono:!0}),(0,Y.jsx)(K,{label:a(`designer.field.lookup.filterOperator`),value:e.operator??`eq`,options:rw(i),onCommit:e=>y(t,{operator:e}),disabled:r}),(0,Y.jsx)(q,{label:a(`designer.field.lookup.filterValue`),value:hw(e.value),onCommit:e=>y(t,{value:e}),placeholder:e.operator===`in`||e.operator===`notIn`?`comma,separated,values`:a(`engine.inspector.condition.valuePlaceholder`),disabled:r,mono:!0})]},t)),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80 px-0.5 leading-snug`,children:a(`designer.field.summary.filterHint`)})]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80 px-0.5 leading-snug`,children:a(`designer.field.summary.hint`)})]})}function _w(e){let t=sa(),[n,r]=J.useState([]);return J.useEffect(()=>{let n=!1;return Promise.all([t.list(`object`),t.listDrafts({type:`object`}).catch(()=>[])]).then(([t,i])=>{if(n)return;let a=new Map;for(let e of t??[])typeof e?.name==`string`&&e.name&&!a.has(e.name)&&a.set(e.name,{value:e.name,label:e.label?`${e.label} (${e.name})`:e.name});for(let t of i??[]){let n=t.name;typeof n==`string`&&n&&!a.has(n)&&a.set(n,{value:n,label:`${n} ${G(`engine.inspector.draftSuffix`,e)}`})}r([...a.values()].sort((e,t)=>e.value.localeCompare(t.value)))}).catch(()=>{}),()=>{n=!0}},[t,e]),n}function vw({name:e,draft:t,onPatch:n,readOnly:r,locale:i}){let a=J.useCallback(e=>G(e,i),[i]),o=!e,s=e=>typeof t[e]==`string`?t[e]:``,c=J.useRef(!1),l=e=>{let t={label:e||void 0};o&&!c.current&&(t.name=oa(e)),n(t)},u=e=>{c.current=!0,n({name:Vo(e)})},d=o?s(`name`):e||s(`name`),f=s(`label`)||e||a(`designer.object.kind`);return(0,Y.jsxs)(is,{kindLabel:a(`designer.object.kind`),title:f,onClose:()=>{},hideClose:!0,children:[(0,Y.jsxs)(ww,{title:a(`designer.object.section.basic`),hint:a(`designer.object.section.basicHint`),children:[(0,Y.jsx)(Tw,{hint:a(`designer.object.nameHint`),children:(0,Y.jsx)(q,{label:a(`designer.object.name`),value:d,onCommit:u,disabled:r||!o,mono:!0,testId:`object-name-input`,placeholder:a(`designer.object.namePlaceholder`)})}),(0,Y.jsx)(q,{label:a(`designer.object.label`),value:s(`label`),onCommit:l,disabled:r,placeholder:a(`designer.object.labelPlaceholder`)}),(0,Y.jsx)(q,{label:a(`designer.object.pluralLabel`),value:s(`pluralLabel`),onCommit:e=>n({pluralLabel:e||void 0}),disabled:r,placeholder:a(`designer.object.pluralPlaceholder`)}),(0,Y.jsx)(Tw,{hint:a(`designer.object.iconHint`),children:(0,Y.jsx)(q,{label:a(`designer.object.icon`),value:s(`icon`),onCommit:e=>n({icon:e||void 0}),disabled:r,mono:!0,placeholder:`building`})}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:a(`designer.object.description`)}),(0,Y.jsx)(`textarea`,{value:s(`description`),disabled:r,rows:2,placeholder:a(`designer.object.descriptionPlaceholder`),onChange:e=>n({description:e.target.value||void 0}),className:`w-full text-sm rounded-md border bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-primary`})]})]}),(0,Y.jsx)(Cw,{draft:t,onPatch:n,readOnly:r,tr:a})]})}var yw=[`read`,`create`,`update`,`delete`];function bw(e){return e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}function xw(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`, `):``}function Sw(){let[e,t]=J.useState(!1);return J.useEffect(()=>{let e=!1;return n(()=>import(`./vendor-objectstack-C4eD5dbT.js`).then(e=>(e.xn(),e.mn)).then(n=>{e||t(n?.ObjectRequiredPermissionsSchema!==void 0)}),[],import.meta.url).catch(()=>{}),()=>{e=!0}},[]),e}function Cw({draft:e,onPatch:t,readOnly:n,tr:r}){let i=Sw(),a=e.access?.default===`private`?`private`:`public`,o=e.requiredPermissions,s=!!o&&typeof o==`object`&&!Array.isArray(o),c=s?`perOp`:`all`,l=e=>{t({access:e===`private`?{default:`private`}:void 0})},u=e=>{let n=bw(e);t({requiredPermissions:n.length>0?n:void 0})},d=(e,n)=>{let r=s?{...o}:{},i=bw(n);i.length>0?r[e]=i:delete r[e],t({requiredPermissions:Object.keys(r).length>0?r:void 0})},f=e=>{if(e!==c){if(e===`perOp`){let e=Array.isArray(o)?o:[];t({requiredPermissions:e.length>0?{read:e,create:e,update:e,delete:e}:{}})}else{let e=s?o:{},n=[...new Set(yw.flatMap(t=>Array.isArray(e[t])?e[t]:[]))];t({requiredPermissions:n.length>0?n:void 0})}}};return(0,Y.jsxs)(ww,{title:r(`designer.object.section.access`),hint:r(`designer.object.section.accessHint`),children:[(0,Y.jsx)(Tw,{hint:r(a===`private`?`designer.object.posture.privateHint`:`designer.object.posture.publicHint`),children:(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:r(`designer.object.posture`)}),(0,Y.jsxs)(`select`,{value:a,disabled:n,onChange:e=>l(e.target.value),"data-testid":`object-access-posture`,className:`w-full rounded border bg-background px-2 py-1 text-[12px]`,children:[(0,Y.jsx)(`option`,{value:`public`,children:r(`designer.object.posture.public`)}),(0,Y.jsx)(`option`,{value:`private`,children:r(`designer.object.posture.private`)})]})]})}),(0,Y.jsx)(Tw,{hint:r(`designer.object.reqPerms.hint`),children:(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:r(`designer.object.reqPerms`)}),i&&(0,Y.jsxs)(`div`,{className:`inline-flex rounded border text-[11px]`,role:`group`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>f(`all`),className:`px-1.5 py-0.5 rounded-l ${c===`all`?`bg-primary/10 text-primary`:`text-muted-foreground`}`,children:r(`designer.object.reqPerms.mode.all`)}),(0,Y.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>f(`perOp`),"data-testid":`object-reqperms-perop`,className:`px-1.5 py-0.5 rounded-r border-l ${c===`perOp`?`bg-primary/10 text-primary`:`text-muted-foreground`}`,children:r(`designer.object.reqPerms.mode.perOp`)})]})]}),c===`all`?(0,Y.jsx)(q,{label:``,value:xw(o),onCommit:u,disabled:n,mono:!0,testId:`object-reqperms-all`,placeholder:r(`designer.object.reqPerms.placeholder`)}):(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:yw.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-14 shrink-0 text-[11px] text-muted-foreground capitalize`,children:r(`designer.object.reqPerms.op.${e}`)}),(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsx)(q,{label:``,value:xw(o?.[e]),onCommit:t=>d(e,t),disabled:n,mono:!0,testId:`object-reqperms-${e}`,placeholder:r(`designer.object.reqPerms.placeholder`)})})]},e))})]})})]})}function ww({title:e,hint:t,children:n}){return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`border-b pb-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),t&&(0,Y.jsx)(`div`,{className:`text-[10px] normal-case text-muted-foreground/70 mt-0.5`,children:t})]}),(0,Y.jsx)(`div`,{className:`space-y-2`,children:n})]})}function Tw({hint:e,children:t}){return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[t,e&&(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80 px-0.5 leading-snug`,children:e})]})}var Ew={equals:`$eq`,not_equals:`$ne`,greater_than:`$gt`,greater_than_or_equal:`$gte`,less_than:`$lt`,less_than_or_equal:`$lte`,after:`$gt`,before:`$lt`,contains:`$contains`,in:`$in`,not_in:`$nin`,not_contains:`$notContains`,starts_with:`$startsWith`,ends_with:`$endsWith`,icontains:`$icontains`,between:`$between`},Dw={$eq:`equals`,$ne:`not_equals`,$gt:`greater_than`,$gte:`greater_than_or_equal`,$lt:`less_than`,$lte:`less_than_or_equal`,$contains:`contains`,$in:`in`,$nin:`not_in`,$notContains:`not_contains`,$startsWith:`starts_with`,$endsWith:`ends_with`,$icontains:`icontains`,$between:`between`},Ow=(()=>{let e={};for(let[t,n]of Object.entries(Ew))(e[n]||=[]).push(t);return e})();function kw(e,t){let n=Ow[e];if(t&&n&&n.length>1){let e=new Set(Je(t).map(e=>e.value)),r=n.filter(t=>e.has(t));if(r.length===1)return r[0]}return Dw[e]}var Aw={is_empty:{$empty:!0},is_not_empty:{$empty:!1},is_null:{$null:!0},is_not_null:{$null:!1}};function jw(e){return(e?.conditions??[]).filter(e=>e&&e.field)}function Mw(e){return jw(e).length===0}function Nw(e){let t=jw(e),n=[];for(let e of t){let t=Aw[e.operator];if(t){n.push({[e.field]:{...t}});continue}let r=Ew[e.operator];if(!r)continue;let i=e.value;Ie(e.operator,i)&&n.push({[e.field]:{[r]:i}})}if(n.length!==0)return n.length===1?n[0]:{$and:n}}function Pw(e,t){if(Nw({logic:`and`,conditions:[e]})===void 0)return!1;if(!t)return!0;let n=t.find(t=>t.value===e.field)?.type;return Je(n).some(t=>t.value===e.operator)}function Fw(e,t){let n={id:`g`,logic:`and`,conditions:[]};if(e==null)return{group:n,representable:!0};if(typeof e!=`object`||Array.isArray(e)||`$or`in e)return{group:n,representable:!1};let r=Array.isArray(e.$and)?e.$and:[e],i=[];for(let e=0;e<r.length;e++){let a=r[e];if(!a||typeof a!=`object`||Array.isArray(a)||`$and`in a||`$or`in a)return{group:n,representable:!1};let o=Object.keys(a);if(o.length!==1)return{group:n,representable:!1};let s=o[0],c=a[s],l;if(c&&typeof c==`object`&&!Array.isArray(c)){let r=Object.keys(c);if(r.length!==1)return{group:n,representable:!1};let i=r[0];if(i===`$empty`){if(typeof c.$empty!=`boolean`)return{group:n,representable:!1};l={id:`c${e}`,field:s,operator:c.$empty?`is_empty`:`is_not_empty`,value:``}}else if(i===`$null`)l={id:`c${e}`,field:s,operator:c.$null?`is_null`:`is_not_null`,value:``};else{let r=kw(i,t?.find(e=>e.value===s)?.type);if(!r)return{group:n,representable:!1};l={id:`c${e}`,field:s,operator:r,value:c[i]}}}else l={id:`c${e}`,field:s,operator:`equals`,value:c};if(!Pw(l,t))return{group:n,representable:!1};i.push(l)}return{group:{id:`g`,logic:`and`,conditions:i},representable:!0}}function Iw(e,t){return e.map(e=>({value:e.value,label:G(e.labelKey,t)}))}function Lw(e,t){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==1?(0,Y.jsx)(J.Fragment,{children:e in t?t[e]:`{${e}}`},n):e)}var Rw=[{value:`count`,labelKey:`engine.inspector.dataset.aggregate.count`},{value:`sum`,labelKey:`engine.inspector.dataset.aggregate.sum`},{value:`avg`,labelKey:`engine.inspector.dataset.aggregate.avg`},{value:`min`,labelKey:`engine.inspector.dataset.aggregate.min`},{value:`max`,labelKey:`engine.inspector.dataset.aggregate.max`},{value:`count_distinct`,labelKey:`engine.inspector.dataset.aggregate.count_distinct`}],zw=[{value:`string`,labelKey:`engine.inspector.dataset.dimType.string`},{value:`number`,labelKey:`engine.inspector.dataset.dimType.number`},{value:`date`,labelKey:`engine.inspector.dataset.dimType.date`},{value:`boolean`,labelKey:`engine.inspector.dataset.dimType.boolean`},{value:`lookup`,labelKey:`engine.inspector.dataset.dimType.lookup`}],Bw=[{value:``,labelKey:`engine.inspector.dataset.granularity.none`},{value:`day`,labelKey:`engine.inspector.dataset.granularity.day`},{value:`week`,labelKey:`engine.inspector.dataset.granularity.week`},{value:`month`,labelKey:`engine.inspector.dataset.granularity.month`},{value:`quarter`,labelKey:`engine.inspector.dataset.granularity.quarter`},{value:`year`,labelKey:`engine.inspector.dataset.granularity.year`}],Vw=[{value:`ratio`,labelKey:`engine.inspector.dataset.derivedOp.ratio`},{value:`sum`,labelKey:`engine.inspector.dataset.derivedOp.sum`},{value:`difference`,labelKey:`engine.inspector.dataset.derivedOp.difference`},{value:`product`,labelKey:`engine.inspector.dataset.derivedOp.product`}],Hw=[{value:`raw`,labelKey:`engine.inspector.dataset.formatKind.raw`},{value:`number`,labelKey:`engine.inspector.dataset.formatKind.number`},{value:`currency`,labelKey:`engine.inspector.dataset.formatKind.currency`},{value:`percent`,labelKey:`engine.inspector.dataset.formatKind.percent`}],Uw=[{value:`0`,label:`0`},{value:`1`,label:`1`},{value:`2`,label:`2`}],Ww=[{value:`USD`,label:`USD ($)`},{value:`EUR`,label:`EUR (€)`},{value:`GBP`,label:`GBP (£)`},{value:`CNY`,label:`CNY (¥)`},{value:`JPY`,label:`JPY (¥)`},{value:`INR`,label:`INR (₹)`},{value:`CAD`,label:`CAD ($)`},{value:`AUD`,label:`AUD ($)`}];function Gw(e){return typeof e!=`string`||e.trim()===``}function Kw(e,t){let{field:n,...r}=e;return Gw(t)?r:{...r,field:t}}function qw({title:e,count:t,onAdd:n,addLabel:r}){return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:e}),(0,Y.jsx)(V,{variant:`outline`,className:`text-[10px]`,children:t})]}),n&&(0,Y.jsxs)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 gap-1 px-1.5 text-[11px]`,onClick:n,children:[(0,Y.jsx)(U,{className:`h-3 w-3`}),` `,r]})]})}function Jw({children:e,locale:t}){return(0,Y.jsxs)(`details`,{className:`group`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer select-none list-none text-[11px] text-muted-foreground hover:text-foreground`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(dn,{className:`h-3 w-3 transition-transform group-open:rotate-90`}),G(`engine.inspector.dataset.advanced`,t)]})}),(0,Y.jsx)(`div`,{className:`mt-1.5 space-y-1.5 border-l pl-2.5`,children:e})]})}function Yw(e,t){let n=(e??``).trim(),r=n.match(/\.(0+)/),i=r?Math.min(r[1].length,2):0;return t||/[$£€¥₹]/.test(n)?{kind:`currency`,decimals:i}:n.includes(`%`)?{kind:`percent`,decimals:i}:n?{kind:`number`,decimals:i}:{kind:`raw`,decimals:0}}function Xw(e,t,n){let r=t>0?`.`+`0`.repeat(t):``;switch(e){case`number`:return{format:`0,0${r}`,currency:void 0};case`currency`:return{format:`0,0${r}`,currency:n||`USD`};case`percent`:return{format:`0${r}%`,currency:void 0};default:return{format:void 0,currency:void 0}}}function Zw({measure:e,onPatch:t,disabled:n,locale:r}){let{kind:i,decimals:a}=Yw(e.format,e.currency),o=e.currency||`USD`,s=(e,n,r)=>t(Xw(e,n,r)),c=nn(),l=zt(i===`percent`?.1234:1234.5,e.format,e.currency,i===`percent`?`fraction`:void 0,c);return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,Y.jsx)(K,{label:G(`engine.inspector.dataset.displayFormat`,r),value:i,options:Iw(Hw,r),onCommit:e=>s(e,a,o),disabled:n}),i!==`raw`&&(0,Y.jsx)(K,{label:G(`engine.inspector.dataset.decimals`,r),value:String(a),options:Uw,onCommit:e=>s(i,parseInt(e,10)||0,o),disabled:n})]}),i===`currency`&&(0,Y.jsx)(K,{label:G(`engine.inspector.dataset.currency`,r),value:o,options:Ww,onCommit:e=>s(i,a,e),disabled:n}),i!==`raw`&&(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:Lw(G(`engine.inspector.dataset.sample`,r),{sample:(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:l})})})]})}function Qw(e,t){if(!e||!e.includes(`.`))return null;let n=e.slice(0,e.lastIndexOf(`.`));return n&&!t.includes(n)?n:null}function $w({rel:e,onAdd:t,disabled:n,locale:r}){return(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400`,children:[(0,Y.jsx)(Ji,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{children:Lw(G(`engine.inspector.dataset.relWarning`,r),{rel:(0,Y.jsx)(`code`,{className:`font-mono`,children:e})})}),!n&&t&&(0,Y.jsx)(`button`,{type:`button`,className:`underline hover:no-underline`,onClick:t,children:G(`engine.inspector.dataset.relWarningAdd`,r)})]})}function eT({label:e,help:t,value:n,onCommit:r,fields:i,disabled:a,locale:o}){let{group:s,representable:c}=Fw(n,i),l=s.conditions.length;return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:e}),c?(0,Y.jsxs)(Me,{children:[(0,Y.jsx)(Ae,{asChild:!0,children:(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,disabled:a,className:`h-8 w-full justify-between text-xs font-normal`,children:[(0,Y.jsx)(`span`,{className:`truncate text-left`,children:l?W(l===1?`engine.inspector.dataset.filterConditionsOne`:`engine.inspector.dataset.filterConditionsOther`,o,{count:l}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:G(`engine.inspector.dataset.addFilter`,o)})}),(0,Y.jsx)(Nn,{className:`h-3.5 w-3.5 opacity-60 shrink-0`})]})}),(0,Y.jsx)(mt,{align:`start`,className:`w-[440px] max-w-[90vw] p-3`,children:i.length===0?(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:G(`engine.inspector.dataset.filterNeedsObject`,o)}):(0,Y.jsx)(We,{fields:i,value:s,onChange:e=>{let t=Nw(e);(t!==void 0||Mw(e))&&r(t)}})})]}):(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-2.5 py-1.5 text-[11px] text-muted-foreground`,children:Lw(G(`engine.inspector.dataset.filterAdvanced`,o),{source:(0,Y.jsx)(`span`,{className:`font-medium`,children:G(`engine.inspector.dataset.sourceTab`,o)})})}),t&&(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:t})]})}function tT(e,t){return e===t?{object:e}:{object:e,include:[],dimensions:[],measures:[],filter:void 0}}function nT({draft:e,onPatch:t,readOnly:n,name:r,locale:i,onBlockingIssuesChange:a}){let o=e=>G(e,i),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=typeof e.object==`string`?e.object:``,u=Array.isArray(e.include)?e.include:[],d=Array.isArray(e.dimensions)?e.dimensions:[],f=Array.isArray(e.measures)?e.measures:[],p=typeof e.name==`string`?e.name:void 0,m=!r,h=J.useRef(!1),g=typeof e.name==`string`?e.name:``,{options:_,loading:v}=_l(),{relationships:y,fieldOptions:b,loading:x}=vl(l,u),S=yl(p),C=J.useMemo(()=>_.map(e=>({value:e.name,label:e.label})),[_]),w=J.useMemo(()=>y.map(e=>({value:e.name,label:e.label,hint:e.referenceTo?`→ ${e.referenceTo}`:void 0})),[y]),T=J.useMemo(()=>b.map(e=>({value:e.value,label:e.label,hint:e.type,group:e.group})),[b]),E=J.useMemo(()=>b.filter(e=>!e.value.includes(`.`)).map(e=>({value:e.value,label:e.label,type:e.type})),[b]),D=e.filter&&typeof e.filter==`object`?e.filter:void 0,O=C.find(e=>e.value===l)?.label??l,k=(e,n)=>t({dimensions:d.map((t,r)=>r===e?{...t,...n}:t)}),A=(e,n)=>t({measures:f.map((t,r)=>r===e?{...t,...n}:t)}),j=e=>e.includes(`.`)?e.split(`.`).pop()??e:e,M=(e,n)=>{let r=b.find(e=>e.value===n),i=r?.type?{type:fl(r.type)}:{};!Gw(n)&&!d[e]?.name&&(i.name=j(n)),t({dimensions:d.map((t,r)=>r===e?Kw({...t,...i},n):t)})},N=(e,n)=>{let r={};!Gw(n)&&!f[e]?.name&&(r.name=j(n)),t({measures:f.map((t,i)=>i===e?Kw({...t,...r},n):t)})},P=d.filter(e=>Gw(e.field)).length,ee=J.useRef(a);J.useEffect(()=>{ee.current=a}),J.useEffect(()=>{ee.current?.(P)},[P]);let F=J.useId();return(0,Y.jsxs)(is,{kindLabel:o(`engine.inspector.dataset.kind`),title:String(s||e.name||o(`engine.inspector.dataset.kind`)),onClose:()=>{},hideClose:!0,children:[p&&!S.loading&&(0,Y.jsx)(`p`,{className:S.reports+S.dashboards>0?`rounded-md border border-amber-500/30 bg-amber-500/5 px-2.5 py-1.5 text-[11px] text-amber-700 dark:text-amber-300`:`text-[11px] text-muted-foreground`,children:S.reports+S.dashboards>0?W(`engine.inspector.dataset.usage.bound`,i,{reports:W(S.reports===1?`engine.inspector.dataset.usage.reportsOne`:`engine.inspector.dataset.usage.reportsOther`,i,{count:S.reports}),dashboards:W(S.dashboards===1?`engine.inspector.dataset.usage.dashboardsOne`:`engine.inspector.dataset.usage.dashboardsOther`,i,{count:S.dashboards})}):o(`engine.inspector.dataset.usage.unbound`)}),m&&(0,Y.jsx)(q,{label:o(`engine.inspector.dataset.name`),value:g,onCommit:e=>{h.current=!0,t({name:Lo(e)})},placeholder:o(`engine.inspector.dataset.namePlaceholder`),disabled:n,mono:!0}),(0,Y.jsx)(q,{label:o(`engine.inspector.dataset.label`),value:s,onCommit:e=>{let n={label:e};m&&!h.current&&(n.name=Lo(e)),t(n)},disabled:n}),(0,Y.jsx)(q,{label:o(`engine.inspector.dataset.description`),value:c,onCommit:e=>t({description:e}),disabled:n}),(0,Y.jsx)(cl,{label:o(`engine.inspector.dataset.baseObject`),value:l,onCommit:e=>t(tT(e,l)),options:C,loading:v,placeholder:o(`engine.inspector.dataset.baseObjectPlaceholder`),searchPlaceholder:o(`engine.inspector.dataset.searchObjects`),disabled:n,mono:!0}),l&&(d.length>0||f.length>0||u.length>0||!!D)&&(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:o(`engine.inspector.dataset.baseObjectChangeHint`)}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,Y.jsx)(qw,{title:o(`engine.inspector.dataset.includedRelationships`),count:u.length,addLabel:o(`engine.form.add`),onAdd:n?void 0:()=>t({include:os(u,``)})}),u.length===0?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-2 text-center text-[11px] text-muted-foreground`,children:Lw(o(`engine.inspector.dataset.noJoins`),{object:(0,Y.jsx)(`code`,{children:O||o(`engine.inspector.dataset.baseObjectFallback`)}),path:(0,Y.jsx)(`code`,{children:`relationship.field`})})}):u.map((e,r)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(cl,{ariaLabel:o(`engine.inspector.dataset.includedRelationship`),value:e,onCommit:e=>t({include:u.map((t,n)=>n===r?e:t)}),options:w,loading:x,placeholder:o(`engine.inspector.dataset.relationshipPlaceholder`),searchPlaceholder:o(`engine.inspector.dataset.searchRelationships`),disabled:n,mono:!0}),!n&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 shrink-0 p-0`,onClick:()=>t({include:xs(u,r,null)}),"aria-label":o(`engine.inspector.dataset.removeRelationship`),children:(0,Y.jsx)(na,{className:`h-3.5 w-3.5`})})]},r)),l&&u.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1 gap-y-0.5 pt-0.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono font-medium`,children:O}),u.map((e,t)=>{let n=y.find(t=>t.name===e);return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(dn,{className:`h-3 w-3 opacity-60`}),(0,Y.jsxs)(`span`,{className:`font-mono`,children:[e,n?.referenceTo?` (${n.referenceTo})`:``]})]},t)})]})]}),(0,Y.jsx)(`div`,{className:`border-t pt-3`,children:(0,Y.jsx)(eT,{label:o(`engine.inspector.dataset.scopeFilter`),help:o(`engine.inspector.dataset.scopeFilterHelp`),value:D,onCommit:e=>t({filter:e}),fields:E,disabled:n,locale:i})}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-2`,children:[(0,Y.jsx)(qw,{title:o(`engine.inspector.dataset.dimensions`),count:d.length,addLabel:o(`engine.inspector.dataset.addDimension`),onAdd:n?void 0:()=>t({dimensions:os(d,{name:``,type:`string`})})}),d.map((e,r)=>(0,Y.jsxs)(`div`,{className:`rounded-md border p-2 space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:W(`engine.inspector.dataset.dimensionN`,i,{index:r+1})}),!n&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":o(`engine.inspector.dataset.removeDimension`),title:o(`engine.inspector.dataset.removeDimension`),className:`h-6 w-6 shrink-0 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>t({dimensions:xs(d,r,null)}),children:(0,Y.jsx)(Ki,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsx)(q,{label:o(`engine.inspector.dataset.name`),value:e.name??``,onCommit:e=>k(r,{name:e}),placeholder:o(`engine.inspector.dataset.dimensionNamePlaceholder`),disabled:n,mono:!0}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(L,{htmlFor:`${F}-${r}`,className:`text-xs text-muted-foreground`,children:[o(`engine.inspector.dataset.field`),Gw(e.field)&&(0,Y.jsx)(Cs,{})]}),(0,Y.jsx)(cl,{id:`${F}-${r}`,value:e.field??``,onCommit:e=>M(r,e),options:T,loading:x,placeholder:o(`engine.inspector.dataset.dimensionFieldPlaceholder`),searchPlaceholder:o(`engine.form.searchFields`),disabled:n,mono:!0})]}),(()=>{let r=Qw(e.field,u);return r?(0,Y.jsx)($w,{rel:r,disabled:n,locale:i,onAdd:()=>t({include:os(u,r)})}):null})(),(0,Y.jsx)(K,{label:o(`engine.inspector.dataset.type`),value:e.type,options:Iw(zw,i),onCommit:e=>k(r,{type:e}),disabled:n}),(0,Y.jsxs)(Jw,{locale:i,children:[(0,Y.jsx)(q,{label:o(`engine.inspector.dataset.labelOptional`),value:e.label??``,onCommit:e=>k(r,{label:e||void 0}),placeholder:e.name||o(`engine.inspector.dataset.displayLabel`),disabled:n}),e.type===`date`&&(0,Y.jsx)(K,{label:o(`engine.inspector.dataset.dateBucket`),value:e.dateGranularity??``,options:Iw(Bw,i),onCommit:e=>k(r,{dateGranularity:e||void 0}),disabled:n})]})]},r))]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-2`,children:[(0,Y.jsx)(qw,{title:o(`engine.inspector.dataset.measures`),count:f.length,addLabel:o(`engine.inspector.dataset.addMeasure`),onAdd:n?void 0:()=>t({measures:os(f,{name:``,aggregate:`sum`})})}),f.map((e,r)=>{let a=f.filter((e,t)=>t!==r).map(e=>e.name).filter(e=>!!e),s=e.derived;return(0,Y.jsxs)(`div`,{className:`rounded-md border p-2 space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:W(`engine.inspector.dataset.measureN`,i,{index:r+1})}),!n&&(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":o(`engine.inspector.dataset.removeMeasure`),title:o(`engine.inspector.dataset.removeMeasure`),className:`h-6 w-6 shrink-0 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>t({measures:xs(f,r,null)}),children:(0,Y.jsx)(Ki,{className:`h-3.5 w-3.5`})})]}),(0,Y.jsx)(q,{label:o(`engine.inspector.dataset.name`),value:e.name??``,onCommit:e=>A(r,{name:e}),placeholder:o(`engine.inspector.dataset.measureNamePlaceholder`),disabled:n,mono:!0}),(0,Y.jsx)(K,{label:o(`engine.inspector.dataset.aggregate`),value:e.aggregate,options:Iw(Rw,i),onCommit:e=>A(r,{aggregate:e}),disabled:n}),(0,Y.jsx)(cl,{label:o(`engine.inspector.dataset.field`),value:e.field??``,onCommit:e=>N(r,e),options:T,loading:x,placeholder:o(`engine.inspector.dataset.measureFieldPlaceholder`),searchPlaceholder:o(`engine.form.searchFields`),disabled:n,mono:!0}),(()=>{let r=Qw(e.field,u);return r?(0,Y.jsx)($w,{rel:r,disabled:n,locale:i,onAdd:()=>t({include:os(u,r)})}):null})(),(0,Y.jsxs)(Jw,{locale:i,children:[(0,Y.jsx)(q,{label:o(`engine.inspector.dataset.labelOptional`),value:e.label??``,onCommit:e=>A(r,{label:e||void 0}),placeholder:e.name||o(`engine.inspector.dataset.displayLabel`),disabled:n}),(0,Y.jsx)(Zw,{measure:e,onPatch:e=>A(r,e),disabled:n,locale:i}),(0,Y.jsx)(eT,{label:o(`engine.inspector.dataset.measureFilter`),help:o(`engine.inspector.dataset.measureFilterHelp`),value:e.filter,onCommit:e=>A(r,{filter:e}),fields:E,disabled:n,locale:i}),(0,Y.jsx)(cs,{label:o(`engine.inspector.dataset.derived`),value:!!s,onCommit:e=>A(r,{derived:e?{op:`ratio`,of:[]}:void 0}),disabled:n}),s&&(0,Y.jsxs)(`div`,{className:`space-y-1.5 rounded-md border border-dashed p-2`,children:[(0,Y.jsx)(K,{label:o(`engine.inspector.dataset.operation`),value:s.op,options:Iw(Vw,i),onCommit:e=>A(r,{derived:{...s,op:e}}),disabled:n}),(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dataset.operands`)}),(()=>{let e=s.op===`ratio`||s.op===`difference`?2:1;return(Array.isArray(s.of)?s.of.length:0)<e?(0,Y.jsx)(`p`,{className:`text-[10px] text-amber-600 dark:text-amber-400`,children:W(e===2?`engine.inspector.dataset.derivedNeedTwo`:`engine.inspector.dataset.derivedNeedOne`,i,{op:s.op??``})}):null})(),a.length===0?(0,Y.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground`,children:o(`engine.inspector.dataset.addOtherMeasuresFirst`)}):(0,Y.jsx)(`div`,{className:`space-y-1`,children:a.map(e=>{let t=Array.isArray(s.of)&&s.of.includes(e);return(0,Y.jsx)(cs,{label:e,value:t,disabled:n,onCommit:t=>{let n=Array.isArray(s.of)?s.of:[],i=t?[...n,e]:n.filter(t=>t!==e);A(r,{derived:{...s,of:i}})}},e)})})]})]})]},r)})]})]})}function rT(e){let t=sa(),[n,r]=J.useState([]),[i,a]=J.useState(!!e);return J.useEffect(()=>{if(!e){r([]),a(!1);return}let n=!1;return a(!0),t.list(e).then(e=>{if(n)return;let t=(e??[]).map(e=>e&&typeof e==`object`&&`item`in e?e.item:e).filter(e=>typeof e?.name==`string`&&e.name).map(e=>({value:e.name,label:e.label?`${e.label} (${e.name})`:e.name})).sort((e,t)=>e.value.localeCompare(t.value));r(t),a(!1)}).catch(()=>{n||(r([]),a(!1))}),()=>{n=!0}},[t,e]),{options:n,loading:i}}function iT(e,t){return e.map(e=>({value:e.value,label:G(e.labelKey,t)}))}function aT(e,t){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==1?(0,Y.jsx)(J.Fragment,{children:e in t?t[e]:`{${e}}`},n):e)}var oT=[{value:`script`,labelKey:`engine.inspector.action.type.script`},{value:`api`,labelKey:`engine.inspector.action.type.api`},{value:`flow`,labelKey:`engine.inspector.action.type.flow`},{value:`modal`,labelKey:`engine.inspector.action.type.modal`},{value:`form`,labelKey:`engine.inspector.action.type.form`},{value:`url`,labelKey:`engine.inspector.action.type.url`}],sT=[{value:`primary`,labelKey:`engine.inspector.action.variant.primary`},{value:`secondary`,labelKey:`engine.inspector.action.variant.secondary`},{value:`danger`,labelKey:`engine.inspector.action.variant.danger`},{value:`ghost`,labelKey:`engine.inspector.action.variant.ghost`},{value:`link`,labelKey:`engine.inspector.action.variant.link`}],cT=[{value:`action:button`,labelKey:`engine.inspector.action.component.button`},{value:`action:icon`,labelKey:`engine.inspector.action.component.icon`},{value:`action:menu`,labelKey:`engine.inspector.action.component.menu`},{value:`action:group`,labelKey:`engine.inspector.action.component.group`}],lT=[{value:`create`,labelKey:`engine.inspector.action.mode.create`},{value:`edit`,labelKey:`engine.inspector.action.mode.edit`},{value:`delete`,labelKey:`engine.inspector.action.mode.delete`},{value:`custom`,labelKey:`engine.inspector.action.mode.custom`}],uT=[{value:`POST`,label:`POST`},{value:`PATCH`,label:`PATCH`},{value:`PUT`,label:`PUT`},{value:`DELETE`,label:`DELETE`}],dT=[{value:`expression`,labelKey:`engine.inspector.action.bodyLang.expression`},{value:`js`,labelKey:`engine.inspector.action.bodyLang.js`}],fT=[{value:`text`,labelKey:`engine.inspector.action.paramType.text`},{value:`textarea`,labelKey:`engine.inspector.action.paramType.textarea`},{value:`number`,labelKey:`engine.inspector.action.paramType.number`},{value:`boolean`,labelKey:`engine.inspector.action.paramType.boolean`},{value:`select`,labelKey:`engine.inspector.action.paramType.select`},{value:`date`,labelKey:`engine.inspector.action.paramType.date`},{value:`datetime`,labelKey:`engine.inspector.action.paramType.datetime`},{value:`lookup`,labelKey:`engine.inspector.action.paramType.lookup`}],pT=new Set([...bt,...qt]);function mT(e){return pT.has(e)?e:void 0}var hT={record_header:`engine.inspector.action.location.record_header`,record_more:`engine.inspector.action.location.record_more`,record_section:`engine.inspector.action.location.record_section`,record_related:`engine.inspector.action.location.record_related`,list_toolbar:`engine.inspector.action.location.list_toolbar`,list_item:`engine.inspector.action.location.list_item`},gT=Object.keys(hT).map(e=>({value:e,labelKey:hT[e]})),_T={url:{labelKey:`engine.inspector.action.target.url.label`,placeholderKey:`engine.inspector.action.target.url.placeholder`,hintKey:`engine.inspector.action.target.url.hint`},flow:{labelKey:`engine.inspector.action.target.flow.label`,placeholderKey:`engine.inspector.action.target.flow.placeholder`,hintKey:`engine.inspector.action.target.flow.hint`},modal:{labelKey:`engine.inspector.action.target.modal.label`,placeholderKey:`engine.inspector.action.target.modal.placeholder`,hintKey:`engine.inspector.action.target.modal.hint`},form:{labelKey:`engine.inspector.action.target.form.label`,placeholder:`object.viewKey`,hintKey:`engine.inspector.action.target.form.hint`},api:{labelKey:`engine.inspector.action.target.api.label`,placeholder:`/api/v1/…`,hintKey:`engine.inspector.action.target.api.hint`}},vT={flow:`flow`,modal:`page`,form:`view`};function yT({type:e,value:t,onCommit:n,cfg:r,readOnly:i}){let a=vT[e]??null,{options:o}=rT(a),s=!!a&&o.length>0;return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[s?(0,Y.jsx)(K,{label:`${r.label} *`,value:t||void 0,options:o,onCommit:n,disabled:i}):(0,Y.jsx)(q,{label:`${r.label} *`,value:t,onCommit:n,placeholder:r.placeholder,disabled:i,mono:!0}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:r.hint})]})}var bT=[`target`,`body`,`method`,`bodyExtra`,`bodyShape`,`recordIdParam`,`recordIdField`,`onSuccess`,`opensInNewTab`,`newTabUrl`],xT=`list_toolbar`,ST=[{value:``,labelKey:`engine.inspector.action.scriptOp.run`},{value:`update`,labelKey:`engine.inspector.action.scriptOp.update`}],CT=[`name`,`label`,`objectName`,`icon`,`variant`,`component`,`type`,`target`,`execute`,`body`,`method`,`operation`,`patch`,`params`,`locations`,`confirmText`,`successMessage`,`errorMessage`,`refreshAfter`,`undoable`,`mode`,`visible`,`disabled`,`aiExposed`,`aiDescription`],wT=[`bulkEnabled`,`shortcut`];function TT({title:e,hint:t}){return(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e}),t&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:t})]})}function ET(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;return t.en??t[`en-US`]??Object.values(t)[0]??``}return String(e)}function DT({label:e,value:t,onCommit:n,disabled:r,hint:i,locale:a}){let{options:o}=$f();return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[o.length===0?(0,Y.jsx)(q,{label:e,value:t??``,placeholder:G(`engine.inspector.action.objectPlaceholder`,a),onCommit:n,disabled:r,mono:!0}):(0,Y.jsx)(K,{label:e,value:t||void 0,options:[{value:``,label:G(`engine.inspector.action.objectNone`,a)},...o],onCommit:n,disabled:r}),i&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:i})]})}function OT({label:e,objectName:t,value:n,onCommit:r,disabled:i}){let{fields:a}=co(t),o=J.useMemo(()=>a.filter(e=>!e.hidden).map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name})),[a]);return!t||o.length===0?(0,Y.jsx)(q,{label:e,value:n??``,onCommit:r,disabled:i,mono:!0}):(0,Y.jsx)(K,{label:e,value:n||void 0,options:[{value:``,label:`—`},...o],onCommit:r,disabled:i})}function kT({options:e,onCommit:t,disabled:n,locale:r}){let i=Array.isArray(e)?e:[];return(0,Y.jsxs)(`div`,{role:`group`,"aria-label":G(`engine.inspector.action.options`,r),className:`space-y-1.5 rounded-md border border-dashed border-border p-2`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:G(`engine.inspector.action.options`,r)}),i.length===0?(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground/80`,children:G(`engine.inspector.action.optionsEmpty`,r)}):i.map((e,a)=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,Y.jsxs)(`div`,{className:`grid flex-1 grid-cols-2 gap-2`,children:[(0,Y.jsx)(q,{label:G(`engine.inspector.action.optionLabel`,r),value:ET(e.label),onCommit:n=>t(xs(i,a,{...e,label:n})),disabled:n}),(0,Y.jsx)(q,{label:G(`engine.inspector.action.optionValue`,r),value:e.value??``,onCommit:n=>t(xs(i,a,{...e,value:n})),disabled:n,mono:!0})]}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`mt-[22px] h-6 w-6`,disabled:n,"aria-label":W(`engine.inspector.action.removeOption`,r,{index:a+1}),onClick:()=>t(xs(i,a,null)),children:(0,Y.jsx)(Ki,{className:`h-3.5 w-3.5`})})]},a)),!n&&(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>t(os(i,{label:``,value:``})),children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),` `,G(`engine.inspector.action.addOption`,r)]})]})}function AT({draft:e,onPatch:t,readOnly:n,locale:r,serverSchema:i,onBlockingIssuesChange:a}){let o=J.useCallback(e=>G(e,r),[r]),s=t=>typeof e[t]==`string`?e[t]:``,c=s(`type`)||`script`,l=s(`objectName`),u=e.body&&typeof e.body==`object`?e.body:{},d=Array.isArray(e.params)?e.params:[],f=Array.isArray(e.locations)?e.locations:[],p=s(`operation`),m=p===`update`,h=e.patch&&typeof e.patch==`object`&&!Array.isArray(e.patch)?e.patch:{},g=Object.entries(h),_=e=>{if(e===`update`){let e={operation:`update`,type:`script`};for(let t of bT)e[t]=void 0;f.includes(xT)&&(e.locations=f.filter(e=>e!==xT)),t(e);return}t({operation:void 0,patch:void 0})},v=e=>{let n={};for(let[t,r]of e)t.trim()!==``&&(n[t.trim()]=r);t({patch:n})},y=Array.isArray(e.requiredPermissions)?e.requiredPermissions.filter(e=>typeof e==`string`):[],{systemPermissions:b}=ot(),x=Array.isArray(b)?y.filter(e=>!b.includes(e)):[],S=e.aiExposed===!0,C=typeof e.aiDescription==`string`?e.aiDescription:``,w=s(`name`),[T,E]=J.useState({action:w,sites:{}}),D=J.useCallback((e,t)=>{E(n=>n.action===w?n.sites[e]===t?n:{action:w,sites:{...n.sites,[e]:t}}:{action:w,sites:{[e]:t}})},[w]),O=J.useMemo(()=>{if(T.action!==w)return 0;let e=0;for(let t of Object.values(T.sites))e+=t??0;return e},[T,w]),k=J.useRef(a);J.useEffect(()=>{k.current=a}),J.useEffect(()=>{k.current?.(O)},[O]);let A=e=>t({body:{...u,...e}}),j=(e,n)=>t({params:d.map((t,r)=>r===e?{...t,...n}:t)}),M=(e,n)=>{t({locations:n?[...new Set([...f,e])]:f.filter(t=>t!==e)})},N=_T[c],P=N&&{label:o(N.labelKey),placeholder:N.placeholderKey?o(N.placeholderKey):N.placeholder??``,hint:o(N.hintKey)},ee=i;return(0,Y.jsxs)(is,{kindLabel:o(`engine.inspector.action.kind`),title:String(ET(e.label)||e.name||o(`engine.inspector.action.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.action.close`),hideClose:!0,children:[(0,Y.jsx)(TT,{title:o(`engine.inspector.action.basics`)}),(0,Y.jsx)(q,{label:o(`engine.inspector.action.label`),value:ET(e.label),onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.action.labelPlaceholder`),disabled:n}),(0,Y.jsx)(q,{label:o(`engine.inspector.action.name`),value:s(`name`),onCommit:e=>t({name:e}),placeholder:o(`engine.inspector.action.namePlaceholder`),disabled:n,mono:!0}),(0,Y.jsx)(DT,{label:o(`engine.inspector.action.object`),value:l,onCommit:e=>t({objectName:e||void 0}),disabled:n,hint:o(l?`engine.inspector.action.objectBoundHint`:`engine.inspector.action.objectGlobalHint`),locale:r}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.action.icon`)}),(0,Y.jsx)(Ro,{schema:{type:`string`},value:s(`icon`),onChange:e=>t({icon:e||void 0}),readOnly:n})]}),(0,Y.jsx)(K,{label:o(`engine.inspector.action.variant`),value:s(`variant`)||void 0,options:iT(sT,r),onCommit:e=>t({variant:e}),disabled:n})]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-3`,children:[(0,Y.jsx)(TT,{title:o(`engine.inspector.action.behavior`),hint:o(`engine.inspector.action.behaviorHint`)}),(0,Y.jsx)(K,{label:o(`engine.inspector.action.type`),value:c,options:iT(oT,r),onCommit:e=>t({type:e}),disabled:n||m}),m&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:aT(o(`engine.inspector.action.pinnedScript`),{script:(0,Y.jsx)(`code`,{children:`script`})})}),c===`script`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{label:o(`engine.inspector.action.whatItDoes`),value:p,options:iT(ST,r),onCommit:_,disabled:n}),m?(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.action.fieldValues`)}),g.length===0?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-2.5 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.action.fieldValuesEmpty`)}):g.map(([e,t],r)=>(0,Y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsx)(q,{label:o(`engine.inspector.action.fieldValueField`),value:e,onCommit:e=>v(g.map((t,n)=>n===r?[e,t[1]]:t)),placeholder:`status`,disabled:n,mono:!0})}),(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsx)(q,{label:o(`engine.inspector.action.fieldValueValue`),value:typeof t==`string`?t:JSON.stringify(t??``),onCommit:e=>v(g.map((t,n)=>n===r?[t[0],e]:t)),placeholder:`done`,disabled:n,mono:!0})}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0`,disabled:n,"aria-label":o(`engine.inspector.action.removeFieldValue`),onClick:()=>v(g.filter((e,t)=>t!==r)),children:(0,Y.jsx)(Ki,{className:`h-3.5 w-3.5`})})]},r)),(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 text-xs`,disabled:n,onClick:()=>v([...g,[``,``]]),children:[(0,Y.jsx)(U,{className:`mr-1 h-3 w-3`}),` `,o(`engine.inspector.action.addFieldValue`)]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:o(`engine.inspector.action.updateHint`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{label:o(`engine.inspector.action.scriptLanguage`),value:(typeof u.language==`string`?u.language:void 0)||`expression`,options:iT(dT,r),onCommit:e=>A({language:e}),disabled:n}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.action.scriptBody`)}),(0,Y.jsx)(tt,{value:typeof u.source==`string`?u.source:``,onChange:e=>A({source:e.target.value}),disabled:n,spellCheck:!1,rows:5,placeholder:`// (input, ctx) => result
15
+ return { ok: true }`,className:`text-xs font-mono`}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:aT(o(`engine.inspector.action.scriptBodyHint`),{signature:(0,Y.jsx)(`code`,{children:`(input, ctx) => Promise<output>`})})})]})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[c===`api`&&(0,Y.jsx)(K,{label:o(`engine.inspector.action.method`),value:s(`method`)||`POST`,options:uT,onCommit:e=>t({method:e}),disabled:n}),P&&(0,Y.jsx)(yT,{type:c,value:s(`target`),onCommit:e=>t({target:e}),cfg:P,readOnly:n})]})]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-2`,children:[(0,Y.jsx)(TT,{title:o(`engine.inspector.action.inputs`),hint:o(`engine.inspector.action.inputsHint`)}),d.length===0?(0,Y.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-2.5 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.action.inputsEmpty`)}):d.map((e,i)=>(0,Y.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border p-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`#`,i+1]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`h-6 w-6`,disabled:n||i===0,"aria-label":o(`engine.inspector.reorder.up`),onClick:()=>t({params:rs(d,i,i-1)}),children:`↑`}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`h-6 w-6`,disabled:n||i===d.length-1,"aria-label":o(`engine.inspector.reorder.down`),onClick:()=>t({params:rs(d,i,i+1)}),children:`↓`}),(0,Y.jsx)(B,{type:`button`,variant:`ghost`,size:`icon`,className:`h-6 w-6`,disabled:n,"aria-label":o(`engine.inspector.action.removeInput`),onClick:()=>t({params:xs(d,i,null)}),children:(0,Y.jsx)(Ki,{className:`h-3.5 w-3.5`})})]})]}),l?(0,Y.jsx)(OT,{label:o(`engine.inspector.action.bindToField`),objectName:l,value:e.field,onCommit:e=>j(i,{field:e||void 0}),disabled:n}):null,!e.field&&(0,Y.jsx)(q,{label:o(`engine.inspector.action.paramName`),value:e.name??``,onCommit:e=>j(i,{name:e}),placeholder:o(`engine.inspector.action.paramNamePlaceholder`),disabled:n,mono:!0}),(0,Y.jsx)(q,{label:o(`engine.inspector.action.paramLabel`),value:ET(e.label),onCommit:e=>j(i,{label:e}),disabled:n}),!e.field&&(0,Y.jsx)(K,{label:o(`engine.inspector.action.paramTypeLabel`),value:e.type||void 0,options:iT(fT,r),onCommit:e=>j(i,{type:mT(e)}),disabled:n}),!e.field&&e.type===`select`&&(0,Y.jsx)(kT,{options:e.options,onCommit:e=>j(i,{options:e.length>0?e:void 0}),disabled:n,locale:r}),(0,Y.jsx)(q,{label:o(`engine.inspector.action.paramPlaceholder`),value:e.placeholder??``,onCommit:e=>j(i,{placeholder:e}),disabled:n}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:[(0,Y.jsx)(cs,{label:o(`engine.inspector.action.paramRequired`),value:!!e.required,onCommit:e=>j(i,{required:e}),disabled:n}),(0,Y.jsx)(cs,{label:o(`engine.inspector.action.paramPrefill`),value:!!e.defaultFromRow,onCommit:e=>j(i,{defaultFromRow:e}),disabled:n})]})]},i)),!n&&(0,Y.jsxs)(B,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>t({params:os(d,{})}),children:[(0,Y.jsx)(U,{className:`mr-1 h-3.5 w-3.5`}),` `,o(`engine.inspector.action.addInput`)]})]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-2`,children:[(0,Y.jsx)(TT,{title:o(`engine.inspector.action.placement`),hint:o(`engine.inspector.action.placementHint`)}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-1`,children:gT.filter(e=>!(m&&e.value===xT)).map(e=>(0,Y.jsx)(cs,{label:o(e.labelKey),value:f.includes(e.value),onCommit:t=>M(e.value,t),disabled:n},e.value))}),f.length===0&&(0,Y.jsx)(`div`,{className:`text-[11px] text-destructive`,children:o(`engine.inspector.action.noPlacement`)}),y.length>0&&(0,Y.jsxs)(`div`,{className:`text-[11px] text-amber-700`,"data-testid":`action-capability-gate-note`,children:[aT(o(`engine.inspector.action.capabilityGate`),{capabilities:(0,Y.jsx)(`span`,{className:`font-mono`,children:y.join(` + `)}),whom:o(y.length>1?`engine.inspector.action.capabilityGateAll`:`engine.inspector.action.capabilityGateOne`)}),x.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`span`,{"data-testid":`action-capability-gate-self`,children:aT(o(`engine.inspector.action.capabilityGateSelf`),{capabilities:(0,Y.jsx)(`span`,{className:`font-mono`,children:x.join(` + `)})})})]})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-2 pt-1`,children:(0,Y.jsx)(K,{label:o(`engine.inspector.action.component`),value:s(`component`)||void 0,options:iT(cT,r),onCommit:e=>t({component:e}),disabled:n})})]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-2`,children:[(0,Y.jsx)(TT,{title:o(`engine.inspector.action.feedback`),hint:o(`engine.inspector.action.feedbackHint`)}),(0,Y.jsx)(q,{label:o(`engine.inspector.action.confirmText`),value:ET(e.confirmText),onCommit:e=>t({confirmText:e}),placeholder:o(`engine.inspector.action.confirmTextPlaceholder`),disabled:n}),(0,Y.jsx)(q,{label:o(`engine.inspector.action.successMessage`),value:ET(e.successMessage),onCommit:e=>t({successMessage:e}),disabled:n}),(0,Y.jsx)(q,{label:o(`engine.inspector.action.errorMessage`),value:ET(e.errorMessage),onCommit:e=>t({errorMessage:e}),disabled:n}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(0,Y.jsx)(K,{label:o(`engine.inspector.action.mode`),value:s(`mode`)||void 0,options:iT(lT,r),onCommit:e=>t({mode:e}),disabled:n})}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:[(0,Y.jsx)(cs,{label:o(`engine.inspector.action.refreshAfter`),value:!!e.refreshAfter,onCommit:e=>t({refreshAfter:e}),disabled:n}),(0,Y.jsx)(cs,{label:o(`engine.inspector.action.undoable`),value:!!e.undoable,onCommit:e=>t({undoable:e}),disabled:n})]})]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-3`,children:[(0,Y.jsx)(TT,{title:o(`engine.inspector.action.conditions`),hint:o(`engine.inspector.action.conditionsHint`)}),(0,Y.jsx)(po,{label:o(`engine.inspector.action.visibleWhen`),value:Jo(e.visible),onCommit:n=>t({visible:ko(e.visible,n)}),objectName:l,disabled:n,scope:`record`,roots:lo,onBlockingIssuesChange:e=>D(`visible`,e)}),(0,Y.jsx)(po,{label:o(`engine.inspector.action.disabledWhen`),value:Jo(e.disabled),onCommit:n=>t({disabled:ko(e.disabled,n)}),objectName:l,disabled:n,scope:`record`,roots:lo,onBlockingIssuesChange:e=>D(`disabled`,e)})]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-2`,children:[(0,Y.jsx)(TT,{title:o(`engine.inspector.action.ai`),hint:o(`engine.inspector.action.aiHint`)}),(0,Y.jsx)(cs,{label:o(`engine.inspector.action.aiExposed`),value:S,onCommit:e=>t({aiExposed:e}),disabled:n}),S?(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.action.aiDescription`)}),(0,Y.jsx)(tt,{value:C,onChange:e=>t({aiDescription:e.target.value}),disabled:n,rows:3,placeholder:o(`engine.inspector.action.aiDescriptionPlaceholder`),className:`text-xs`}),C.length<40&&(0,Y.jsx)(`div`,{className:`text-[11px] text-destructive`,children:o(`engine.inspector.action.aiDescriptionTooShort`)})]}):null]}),ee&&(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,Y.jsx)(TT,{title:o(`engine.inspector.moreFields`),hint:o(`engine.inspector.action.moreFieldsHint`)}),(0,Y.jsx)(Bo,{schema:ee,value:e,hiddenFields:[...CT,...wT],readOnly:n,onChange:e=>t(e)})]})]})}var jT=[{value:`expression`,labelKey:`engine.inspector.hook.bodyLang.expression`},{value:`js`,labelKey:`engine.inspector.hook.bodyLang.js`}],MT=[`beforeInsert`,`afterInsert`,`beforeUpdate`,`afterUpdate`,`beforeDelete`,`afterDelete`,`beforeUpdateMany`,`afterUpdateMany`,`beforeDeleteMany`,`afterDeleteMany`],NT=[`beforeFind`,`afterFind`,`beforeFindOne`,`afterFindOne`,`beforeCount`,`afterCount`,`beforeAggregate`,`afterAggregate`],PT=`*`,FT=[`name`,`label`,`object`,`events`,`body`,`priority`,`async`,`condition`];function IT({title:e,hint:t}){return(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e}),t&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:t})]})}function LT(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;return t.en??t[`en-US`]??Object.values(t)[0]??``}return String(e)}function RT(e){if(e===PT)return{all:!0,names:[]};if(typeof e==`string`)return{all:!1,names:e?[e]:[]};if(Array.isArray(e)){let t=e.filter(e=>typeof e==`string`&&e!==PT);return{all:e.includes(PT),names:t}}return{all:!1,names:[]}}function zT(e,t){return e?PT:t.length===1?t[0]:t}function BT({draft:e,onPatch:t,readOnly:n,locale:r,serverSchema:i,onBlockingIssuesChange:a}){let o=J.useCallback(e=>G(e,r),[r]),s=t=>typeof e[t]==`string`?e[t]:``,c=e.body&&typeof e.body==`object`?e.body:{},l=Array.isArray(e.events)?e.events:[],{all:u,names:d}=RT(e.object),{options:f,loading:p,error:m}=$f(),h=ns({loading:p,error:m}),g=h.status===`loaded`,_=J.useMemo(()=>{let e=new Set(f.map(e=>e.value)),t=G(`engine.form.notPublished`,r);return[...d.filter(t=>!e.has(t)).map(e=>({value:e,label:g?Ss(e,t,r):e})),...f]},[f,d,r,g]),v=h.status===`error`?h.message:void 0,y=e=>t({body:{...c,...e}}),b=(e,n)=>{t({object:zT(!1,n?[...new Set([...d,e])]:d.filter(t=>t!==e))})},x=(e,n)=>{t({events:n?[...new Set([...l,e])]:l.filter(t=>t!==e)})},S=s(`name`),[C,w]=J.useState({hook:S,count:0}),T=J.useCallback(e=>{w(t=>t.hook===S&&t.count===e?t:{hook:S,count:e})},[S]),E=C.hook===S?C.count:0,D=J.useRef(a);J.useEffect(()=>{D.current=a}),J.useEffect(()=>{D.current?.(E)},[E]);let O=!u&&d.length===1?d[0]:void 0,k=typeof c.language==`string`?c.language:`expression`,A=i;return(0,Y.jsxs)(is,{kindLabel:o(`engine.inspector.hook.kind`),title:String(LT(e.label)||e.name||o(`engine.inspector.hook.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.action.close`),hideClose:!0,children:[(0,Y.jsx)(IT,{title:o(`engine.inspector.hook.basics`)}),(0,Y.jsx)(q,{label:o(`engine.inspector.hook.label`),value:LT(e.label),onCommit:e=>t({label:e||void 0}),placeholder:o(`engine.inspector.hook.labelPlaceholder`),disabled:n}),(0,Y.jsx)(q,{label:o(`engine.inspector.hook.name`),value:s(`name`),onCommit:e=>t({name:e}),placeholder:o(`engine.inspector.hook.namePlaceholder`),disabled:n,mono:!0,testId:`hook-name`}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`hook-object-picker`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.hook.objects`)}),(0,Y.jsx)(cs,{label:o(`engine.inspector.hook.allObjects`),value:u,onCommit:e=>t({object:e?PT:zT(!1,d)}),disabled:n}),!u&&(_.length>0||v===void 0)&&(0,Y.jsx)(`div`,{className:`max-h-40 space-y-1 overflow-auto rounded-md border p-2`,children:_.length===0?(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(g?`engine.inspector.hook.noObjects`:`engine.form.loadingOptions`)}):_.map(e=>(0,Y.jsx)(cs,{label:e.label,value:d.includes(e.value),onCommit:t=>b(e.value,t),disabled:n},e.value))}),!u&&v!==void 0&&(0,Y.jsxs)(`p`,{role:`status`,"data-testid":`hook-object-roster-failure`,className:`text-[11px] leading-snug text-amber-600 dark:text-amber-300`,children:[o(`engine.form.optionsLoadFailedTitle`),v?(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`span`,{className:`break-words font-mono text-[10px] opacity-80`,children:v})]}):null]}),!u&&d.length===0&&(0,Y.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:o(`engine.inspector.hook.pickObject`)})]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-2`,children:[(0,Y.jsx)(IT,{title:o(`engine.inspector.hook.events`),hint:o(`engine.inspector.hook.eventsHint`)}),(0,Y.jsx)(`div`,{className:`text-[11px] font-medium text-muted-foreground/80`,children:o(`engine.inspector.hook.eventsWrite`)}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:MT.map(e=>(0,Y.jsx)(cs,{label:e,value:l.includes(e),onCommit:t=>x(e,t),disabled:n},e))}),(0,Y.jsx)(`div`,{className:`pt-1 text-[11px] font-medium text-muted-foreground/80`,children:o(`engine.inspector.hook.eventsQuery`)}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:NT.map(e=>(0,Y.jsx)(cs,{label:e,value:l.includes(e),onCommit:t=>x(e,t),disabled:n},e))}),l.length===0&&(0,Y.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:o(`engine.inspector.hook.pickEvent`)})]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-3`,children:[(0,Y.jsx)(IT,{title:o(`engine.inspector.hook.function`),hint:o(`engine.inspector.hook.functionHint`)}),(0,Y.jsx)(K,{label:o(`engine.inspector.hook.language`),value:k,options:jT.map(e=>({value:e.value,label:o(e.labelKey)})),onCommit:e=>y({language:e}),disabled:n}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(L,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.hook.handlerBody`)}),(0,Y.jsx)(tt,{"data-testid":`hook-body-source`,value:typeof c.source==`string`?c.source:``,onChange:e=>y({source:e.target.value}),disabled:n,spellCheck:!1,rows:8,placeholder:k===`expression`?`record.amount >= 0`:`// (ctx) => { ... }
16
+ return;`,className:`text-xs font-mono`}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:o(k===`expression`?`engine.inspector.hook.bodyHint.expression`:`engine.inspector.hook.bodyHint.js`)})]})]}),(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-3`,children:[(0,Y.jsx)(IT,{title:o(`engine.inspector.hook.options`)}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Y.jsx)(gs,{label:o(`engine.inspector.hook.priority`),value:typeof e.priority==`number`?e.priority:void 0,onCommit:e=>t({priority:e}),placeholder:`100`,disabled:n}),(0,Y.jsx)(`div`,{className:`flex items-end pb-1.5`,children:(0,Y.jsx)(cs,{label:o(`engine.inspector.hook.async`),value:e.async===!0,onCommit:e=>t({async:e}),disabled:n})})]}),(0,Y.jsx)(po,{label:o(`engine.inspector.hook.condition`),value:Jo(e.condition),onCommit:n=>t({condition:ko(e.condition,n)}),objectName:O,disabled:n,scope:`record`,subjects:{context:yo},onBlockingIssuesChange:T})]}),A&&(0,Y.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,Y.jsx)(IT,{title:o(`engine.inspector.moreFields`),hint:o(`engine.inspector.hook.moreFieldsHint`)}),(0,Y.jsx)(Bo,{schema:A,value:e,hiddenFields:FT,readOnly:n,onChange:e=>t(e)})]})]})}function VT(){Ba(`dashboard`,tx),Ua(`dashboard`,yx),Ba(`flow`,GS),Ba(`app`,dC),Ba(`view`,bC),Ua(`view`,xC),Ba(`page`,vp),Ua(`page`,kC),Ua(`report`,ms),Ba(`object`,JC),Ua(`object`,vw),Ua(`dataset`,nT),Ua(`action`,AT),Ua(`hook`,BT)}xf(),Tf(),Nf(),Zb(),VT();var HT=new Map;function UT(e,t){HT.set(e,t)}function WT(e){return HT.get(e)}function GT({name:e}){return(0,Y.jsx)(Bt,{schema:{type:`object-view`,objectName:e}})}UT(`object`,GT);export{ks as A,lc as C,Us as D,oc as E,As as O,Mc as S,sc as T,tl as _,cm as a,zc as b,Bf as c,Du as d,Su as f,al as g,Jl as h,sm as i,js as k,cd as l,yu as m,ym as n,om as o,Cu as p,um as r,lm as s,WT as t,Mu as u,el as v,cc as w,Gc as x,Bc as y};