@objectstack/console 17.5.0 → 17.6.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 (271) hide show
  1. package/CHANGELOG.md +378 -0
  2. package/dist/.objectstack-injection.json +2 -2
  3. package/dist/.objectui-sha +1 -1
  4. package/dist/assets/{ActionResultDialog-CLdIyOW6.js → ActionResultDialog-4kHDGnT3.js} +3 -3
  5. package/dist/assets/{AiPendingActionsPage-OKYz66yR.js → AiPendingActionsPage-JjOddm0h.js} +1 -1
  6. package/dist/assets/{ApiConsolePage-CcrKovu8.js → ApiConsolePage-BgS26lbp.js} +1 -1
  7. package/dist/assets/AppDocsIndex-BDoH5ECM.js +1 -0
  8. package/dist/assets/{AppManagementPage-D_xz8cTZ.js → AppManagementPage-CCgKmNTj.js} +1 -1
  9. package/dist/assets/ApprovalsInboxPage-C6S1vk0X.js +1 -0
  10. package/dist/assets/AuditLogPage-v2dKXMuk.js +1 -0
  11. package/dist/assets/BookPage-DwFMcTSN.js +1 -0
  12. package/dist/assets/{ComponentNavView-BxsixSU9.js → ComponentNavView-B5g9c6fx.js} +1 -1
  13. package/dist/assets/{CreateViewDialog-xyKlpLEW.js → CreateViewDialog-D3l-tYHM.js} +1 -1
  14. package/dist/assets/DashboardView-BOcovpPd.js +1 -0
  15. package/dist/assets/DocPage-B6AkH5WI.js +1 -0
  16. package/dist/assets/{DocsIndex-B2zw_HAp.js → DocsIndex-DwW2QsYY.js} +1 -1
  17. package/dist/assets/{DocsLayout-DezZ8x7_.js → DocsLayout-D63StSgd.js} +1 -1
  18. package/dist/assets/DocsSlug-CP9fcabi.js +1 -0
  19. package/dist/assets/ExpressionProvider-CrL6jhVq.js +1 -0
  20. package/dist/assets/{FlowRunsPage-CvY3nJMF.js → FlowRunsPage-CxdaiUyk.js} +1 -1
  21. package/dist/assets/{IntegrationsPage-2leVkVDH.js → IntegrationsPage-DvG0x0Nb.js} +2 -2
  22. package/dist/assets/{InterfaceListPage-BdECC_i3.js → InterfaceListPage-C4wPYohR.js} +1 -1
  23. package/dist/assets/{MarketplaceInstalledPage-EPPHSitW.js → MarketplaceInstalledPage-B7KETQG2.js} +1 -1
  24. package/dist/assets/MarketplacePackagePage-CfgKDpNH.js +4 -0
  25. package/dist/assets/{MarketplacePage-BnQKykgv.js → MarketplacePage-DNEyU5AE.js} +1 -1
  26. package/dist/assets/{MetadataInspector-BWxLkr0O.js → MetadataInspector-EP0I3-Kq.js} +1 -1
  27. package/dist/assets/{ObjectDataPage-BIzp65Mo.js → ObjectDataPage-CykEm9MD.js} +1 -1
  28. package/dist/assets/PageView-C6u86tni.js +1 -0
  29. package/dist/assets/{ProfilePage-D2qGgxPK.js → ProfilePage-C3SjXMzi.js} +1 -1
  30. package/dist/assets/{PublicFormsPage-DlE6tck_.js → PublicFormsPage-D3uCTR-8.js} +1 -1
  31. package/dist/assets/RecordDetailView-DgR_zhP4.js +3 -0
  32. package/dist/assets/RecordFormPage-kiJI-ieF.js +1 -0
  33. package/dist/assets/ReportDefaultInspector-BIinF0EQ.js +1 -0
  34. package/dist/assets/{ReportView-GIdKJdOt.js → ReportView-BREO-ADE.js} +1 -1
  35. package/dist/assets/{RuntimeDraftBar-BbMdi3Kp.js → RuntimeDraftBar-BCWfd2yS.js} +1 -1
  36. package/dist/assets/SchemaForm-C4uMMZ13.js +3 -0
  37. package/dist/assets/SearchResultsPage-C6Hw_Lpn.js +1 -0
  38. package/dist/assets/{SettingsHub-BGKIj-Zq.js → SettingsHub-DP1mrzEN.js} +1 -1
  39. package/dist/assets/SettingsView-u7mc6pcc.js +1 -0
  40. package/dist/assets/{SkeletonDetail-C8fMI-Mu.js → SkeletonDetail-DIwlbHTr.js} +1 -1
  41. package/dist/assets/{af-BfSmLD34.js → af-DPUgkQl0.js} +1 -1
  42. package/dist/assets/ai-DPBykF2N.js +3 -0
  43. package/dist/assets/{app-shell-eager-leaves-CDVclng4.js → app-shell-eager-leaves-Cf2bM6uT.js} +1 -1
  44. package/dist/assets/{ar-B9ttrM75.js → ar-B-6GTIRU.js} +1 -1
  45. package/dist/assets/{ar-DZ-C1rn-cyl.js → ar-DZ-wEl298ti.js} +1 -1
  46. package/dist/assets/{ar-EG-BaDxKP_o.js → ar-EG-YBT90_S0.js} +1 -1
  47. package/dist/assets/{ar-MA-DbxNEcmd.js → ar-MA-3uT-EYh6.js} +1 -1
  48. package/dist/assets/{ar-SA-DeC5LXcX.js → ar-SA-SiQsjhhc.js} +1 -1
  49. package/dist/assets/{ar-TN-C9KpTFJz.js → ar-TN-CfzXjKzS.js} +1 -1
  50. package/dist/assets/{az-cMerDwRO.js → az-BqAfcNza.js} +1 -1
  51. package/dist/assets/{be-ZTSbszQh.js → be-CQgWXa9_.js} +1 -1
  52. package/dist/assets/{be-tarask-BXZEUrgX.js → be-tarask-BmNg0Sir.js} +1 -1
  53. package/dist/assets/{bg-BDogpmn5.js → bg-D3evgRuS.js} +1 -1
  54. package/dist/assets/{bn-Cz04uxmh.js → bn-uItkARwm.js} +1 -1
  55. package/dist/assets/{bs-CpFnCl-j.js → bs-DueReOpO.js} +1 -1
  56. package/dist/assets/{ca-CHC4M52Z.js → ca-Cr3AHktR.js} +1 -1
  57. package/dist/assets/{ckb-Dxw-RNm8.js → ckb-CTi5BET7.js} +1 -1
  58. package/dist/assets/contracts-DieHW666.js +1 -0
  59. package/dist/assets/{createDerive-DvA_JGNq.js → createDerive-CjN1i5vn.js} +1 -1
  60. package/dist/assets/{cs-DsFaJ5Z7.js → cs-43mFX9jr.js} +1 -1
  61. package/dist/assets/{cy-FH4JFDTs.js → cy-BBSkg3F8.js} +1 -1
  62. package/dist/assets/{da-D1pVjaAq.js → da-C5oA5qcs.js} +1 -1
  63. package/dist/assets/data-adapter-Cymvlczj.js +1 -0
  64. package/dist/assets/{de-AT-DUMQCisj.js → de-AT-CApxwJzu.js} +1 -1
  65. package/dist/assets/{de-DKrxSvnP.js → de-CPtbLlAf.js} +1 -1
  66. package/dist/assets/default-inspector-registry-Bs6GBn00.js +1 -0
  67. package/dist/assets/dist-BF-ssUpn.js +14 -0
  68. package/dist/assets/{el-l3-bHySV.js → el-Dto2xBQU.js} +1 -1
  69. package/dist/assets/en-AU-FVwCiDJO.js +1 -0
  70. package/dist/assets/{en-CA-DGH5NF0a.js → en-CA-DKuJPN1U.js} +1 -1
  71. package/dist/assets/en-GB-DQ_y5VbJ.js +1 -0
  72. package/dist/assets/en-IE-DaXOhsZW.js +1 -0
  73. package/dist/assets/en-IN-CnRZnAom.js +1 -0
  74. package/dist/assets/en-NZ-CBZLEToK.js +1 -0
  75. package/dist/assets/en-ZA-BE59v0wZ.js +1 -0
  76. package/dist/assets/{eo-CL6CXHZx.js → eo-BL8JXIWd.js} +1 -1
  77. package/dist/assets/{es-BIJ0rksI.js → es-BnoaNxsu.js} +1 -1
  78. package/dist/assets/{et-BGgMzjm1.js → et-tPYLNenO.js} +1 -1
  79. package/dist/assets/{eu-CqvAoRrX.js → eu-CUBG6bT0.js} +1 -1
  80. package/dist/assets/{fa-IR-DNz3oA1-.js → fa-IR-Rr2d9xSs.js} +1 -1
  81. package/dist/assets/{fi-DNSfKWuW.js → fi-B0NVIZsV.js} +1 -1
  82. package/dist/assets/{formatLong-CHb9WA3O.js → formatLong-1-gt9bpo.js} +1 -1
  83. package/dist/assets/{fr-DYRJCirJ.js → fr-BbhHek8e.js} +1 -1
  84. package/dist/assets/{fr-CA-CotiswPx.js → fr-CA-CBDvLXFg.js} +1 -1
  85. package/dist/assets/{fr-CH-CpiEYWpc.js → fr-CH-WPNmwPn7.js} +1 -1
  86. package/dist/assets/framework-DFR4HNtj.js +35 -0
  87. package/dist/assets/{fy-B69yM3FE.js → fy-DvOBbvEF.js} +1 -1
  88. package/dist/assets/{gd-BAy8AsX6.js → gd-BQPiTPX5.js} +1 -1
  89. package/dist/assets/getIcon-Cfwf-Egt.js +1 -0
  90. package/dist/assets/{gl-soLn_weL.js → gl-BJCXK8uO.js} +1 -1
  91. package/dist/assets/{gu-B19Yo9yC.js → gu-CctPRz3V.js} +1 -1
  92. package/dist/assets/{he-DYTPo33p.js → he-CVFMk6p2.js} +1 -1
  93. package/dist/assets/{hi-D2dIK7Oy.js → hi-Ba30-RwS.js} +1 -1
  94. package/dist/assets/{highlighted-body-OFNGDK62-CExufvVt.js → highlighted-body-OFNGDK62-BQ57IrBV.js} +1 -1
  95. package/dist/assets/{hr-BV-VOPMu.js → hr-BZUqTbZs.js} +1 -1
  96. package/dist/assets/{ht-C7MM4qkS.js → ht-BLe05tPx.js} +1 -1
  97. package/dist/assets/{hu-Rha1m2Ym.js → hu-2CQ_Mkww.js} +1 -1
  98. package/dist/assets/{hy-CiTNgbdV.js → hy-CclcPG4H.js} +1 -1
  99. package/dist/assets/i18n-BnUsCaSC.js +17 -0
  100. package/dist/assets/i18n-locale-ar-92O_xtDZ.js +4 -0
  101. package/dist/assets/i18n-locale-de-T5ic3yH9.js +4 -0
  102. package/dist/assets/i18n-locale-en-rxr7WJYl.js +4 -0
  103. package/dist/assets/i18n-locale-es-D_WOifJ_.js +4 -0
  104. package/dist/assets/i18n-locale-fr-3cvyjMkp.js +4 -0
  105. package/dist/assets/i18n-locale-ja-DXlIkB8I.js +4 -0
  106. package/dist/assets/i18n-locale-ko-DngRpS45.js +4 -0
  107. package/dist/assets/i18n-locale-pt-BkPaFCqZ.js +4 -0
  108. package/dist/assets/i18n-locale-ru-E5wLh-y6.js +4 -0
  109. package/dist/assets/i18n-locale-zh-BL4_Yand.js +4 -0
  110. package/dist/assets/{i18n-runtime-CTgAQF4N.js → i18n-runtime-97_bDVjP.js} +1 -1
  111. package/dist/assets/{id-Cijsfjt-.js → id-6JLB8s-f.js} +1 -1
  112. package/dist/assets/index-Cadlh4t_.css +2 -0
  113. package/dist/assets/index-D98sa5GF.js +20 -0
  114. package/dist/assets/{infrastructure-BHSync5f.js → infrastructure-Cc34lEqb.js} +2 -2
  115. package/dist/assets/integration-CeAF4JFT.js +1 -0
  116. package/dist/assets/{is-xS1WTyeC.js → is-to0CWzm1.js} +1 -1
  117. package/dist/assets/isSameWeek-DBXaA1Gd.js +1 -0
  118. package/dist/assets/{it-CH-l516ZNXj.js → it-CH-DhdfjP5Z.js} +1 -1
  119. package/dist/assets/{it-C2i_c9sd.js → it-ea0B8Ujp.js} +1 -1
  120. package/dist/assets/{ja-D9_ewLny.js → ja-B1bzkgDW.js} +1 -1
  121. package/dist/assets/{ja-Hira-D_6ExgHw.js → ja-Hira-CMrY5hXO.js} +1 -1
  122. package/dist/assets/{ka-BYHGyees.js → ka-DKSXLnXP.js} +1 -1
  123. package/dist/assets/{kk-CbTFtuqb.js → kk-DHwMv8Dn.js} +1 -1
  124. package/dist/assets/{km-Dr2gwhIn.js → km-tpLG1xNr.js} +1 -1
  125. package/dist/assets/{kn-CprH8JD7.js → kn-MLreVnHA.js} +1 -1
  126. package/dist/assets/{ko-CsFS2u5i.js → ko-CI0DBazn.js} +1 -1
  127. package/dist/assets/{lb-CbFKN7Ob.js → lb-CmL572Xe.js} +1 -1
  128. package/dist/assets/{lt-Bq0xkLp0.js → lt-DRtUOLdw.js} +1 -1
  129. package/dist/assets/{lv-Cj6vg6Qo.js → lv-COSHgkOP.js} +1 -1
  130. package/dist/assets/{match-C_jFGO9e.js → match-B-ergJQb.js} +1 -1
  131. package/dist/assets/{match-CiPp9BME.js → match-BQoOW8Cj.js} +1 -1
  132. package/dist/assets/{match-Co4ivumx.js → match-dfBS0YSQ.js} +1 -1
  133. package/dist/assets/mermaid-GHXKKRXX-Bb17TtNP.js +1 -0
  134. package/dist/assets/metadata-admin-CABUxbJl.js +9 -0
  135. package/dist/assets/{mk-MXFM99YL.js → mk-B0IH_YL_.js} +1 -1
  136. package/dist/assets/{mn-D5Q9B6Jt.js → mn-P-QdQ2n3.js} +1 -1
  137. package/dist/assets/{ms-CCzPRldx.js → ms-CtyEOINy.js} +1 -1
  138. package/dist/assets/{mt-mjJpN6xW.js → mt-DfuZ2HRm.js} +1 -1
  139. package/dist/assets/{nb-BIlNqdEb.js → nb-2Hp-5Tnt.js} +1 -1
  140. package/dist/assets/{nl-BE-FwXjQsmV.js → nl-BE-mmxbfNoR.js} +1 -1
  141. package/dist/assets/{nl-D2uBtIxG.js → nl-CZ_nLREz.js} +1 -1
  142. package/dist/assets/{nn-B0loJ7SV.js → nn-ccWhYsNa.js} +1 -1
  143. package/dist/assets/{oc-U7-yH1sO.js → oc-z504BFRV.js} +1 -1
  144. package/dist/assets/{pl-mTy0JYgi.js → pl-DeQ7ASt-.js} +1 -1
  145. package/dist/assets/plugin-calendar-Cn5HaZU8.js +1 -0
  146. package/dist/assets/plugin-charts-B6RcFWbo.js +7 -0
  147. package/dist/assets/plugin-chatbot-Ck47EhDX.js +122 -0
  148. package/dist/assets/plugin-dashboard-DjEx8e5Y.js +6 -0
  149. package/dist/assets/plugin-form-CLDvL0up.js +1 -0
  150. package/dist/assets/plugin-gantt-CrVrxVdi.js +63 -0
  151. package/dist/assets/plugin-grid-D2rmQEW_.js +11 -0
  152. package/dist/assets/plugin-kanban-BUNHFfIC.js +1 -0
  153. package/dist/assets/plugin-map-y-7RQQC5.js +1 -0
  154. package/dist/assets/{plugin-markdown-D1nTQc1T.js → plugin-markdown-BOkHcir_.js} +1 -1
  155. package/dist/assets/plugin-report-mT3jpna0.js +59 -0
  156. package/dist/assets/plugin-timeline-B1EF83D3.js +1 -0
  157. package/dist/assets/plugin-tree-MTHUt3_S.js +1 -0
  158. package/dist/assets/plugin-view-DHJI-ahf.js +1 -0
  159. package/dist/assets/plugins-views-CfkgqD30.js +3 -0
  160. package/dist/assets/{pt-BR-2KtO5Js1.js → pt-BR-D80_lPYF.js} +1 -1
  161. package/dist/assets/{pt-Bet5OOQf.js → pt-CJJ1RmXd.js} +1 -1
  162. package/dist/assets/{ro-37U6sgzi.js → ro-EuFb2TCj.js} +1 -1
  163. package/dist/assets/{ru-CyuAY-5E.js → ru-CMaVQScp.js} +1 -1
  164. package/dist/assets/{runtime-metadata-persistence-afAW-MeD.js → runtime-metadata-persistence-ClOTznqa.js} +1 -1
  165. package/dist/assets/{se-DeJabuC6.js → se-DsfdKLdF.js} +1 -1
  166. package/dist/assets/{sk-DWEpjfkR.js → sk-BNV9omI8.js} +1 -1
  167. package/dist/assets/{sl-4oSvNhIR.js → sl-DJS_nINU.js} +1 -1
  168. package/dist/assets/{sq-BjkBCaXW.js → sq-HEgjcbHe.js} +1 -1
  169. package/dist/assets/{sr-Dxm1DsRS.js → sr-CO0CFu4X.js} +1 -1
  170. package/dist/assets/{sr-Latn-Dawg6oP2.js → sr-Latn-eE1Idzey.js} +1 -1
  171. package/dist/assets/{src-C8NYjdVm.js → src-BU7L2v4J.js} +1 -1
  172. package/dist/assets/src-BUtIBFDA.js +1 -0
  173. package/dist/assets/src-C0eXlKtx.js +16 -0
  174. package/dist/assets/{studioEntry-nXQP3iL0.js → studioEntry-WeMfaSGn.js} +1 -1
  175. package/dist/assets/{submitRedirect-jK-cEIbP.js → submitRedirect-C2lfZSHt.js} +1 -1
  176. package/dist/assets/{sv-CROOGJGz.js → sv-5uTzgQT3.js} +1 -1
  177. package/dist/assets/{ta-BZnTmFI_.js → ta-BzgdkBZG.js} +1 -1
  178. package/dist/assets/{te-BN0v0x5t.js → te-Ct_pl7ZJ.js} +1 -1
  179. package/dist/assets/{th-CBjKhp_U.js → th-DouAlk0-.js} +1 -1
  180. package/dist/assets/{tr-x0Ne4N4H.js → tr-3XNBsI40.js} +1 -1
  181. package/dist/assets/types-zod-DXpXw10W.js +1 -0
  182. package/dist/assets/{ug-sgzNhsKo.js → ug-B9n24h9G.js} +1 -1
  183. package/dist/assets/ui-components-D6cEVg0T.js +37 -0
  184. package/dist/assets/ui-layout-DgVDuPEM.js +1 -0
  185. package/dist/assets/{uk-o_DQ5VHJ.js → uk-DCAenByf.js} +1 -1
  186. package/dist/assets/use-book-data-CwRldFxP.js +1 -0
  187. package/dist/assets/{useActionModal-CSvbHkQ7.js → useActionModal-Blp4rhOk.js} +1 -1
  188. package/dist/assets/useCanAuthorMetadata-BxCMgFRf.js +1 -0
  189. package/dist/assets/useNavSelDeepLink-67Y4qCNO.js +1 -0
  190. package/dist/assets/useNavTargetLabel-BOJncjIb.js +1 -0
  191. package/dist/assets/{useOpenRecordList-B5-qaFUx.js → useOpenRecordList-BrwJFojQ.js} +1 -1
  192. package/dist/assets/{usePackageL10n-CMx66am-.js → usePackageL10n-Ci9uVkRZ.js} +1 -1
  193. package/dist/assets/{useSettingsLabel-Kkr2q0Oo.js → useSettingsLabel-CeMnMWsh.js} +1 -1
  194. package/dist/assets/{uz-Cyrl-DbtkQtz_.js → uz-Cyrl-JSeHEqu-.js} +1 -1
  195. package/dist/assets/{uz-Be41d4jl.js → uz-DT3s9bZS.js} +1 -1
  196. package/dist/assets/vendor-objectstack-DFqu45yM.js +138 -0
  197. package/dist/assets/{vi-84mZmklk.js → vi-D2p-h6bY.js} +1 -1
  198. package/dist/assets/{zh-CN-DD1reegJ.js → zh-CN-DHOKqAit.js} +1 -1
  199. package/dist/assets/{zh-HK-B05u30WI.js → zh-HK-D4iIPY7I.js} +1 -1
  200. package/dist/assets/{zh-TW-Bb-WimPD.js → zh-TW-gORQ_tZh.js} +1 -1
  201. package/dist/chunk-membership.json +100 -90
  202. package/dist/eager-closure.json +110 -110
  203. package/dist/index.html +4 -4
  204. package/dist/sdui.manifest.json +520 -60
  205. package/package.json +1 -1
  206. package/dist/assets/AppDocsIndex-F4zDq2zz.js +0 -1
  207. package/dist/assets/ApprovalsInboxPage-DrEUmaDb.js +0 -1
  208. package/dist/assets/AuditLogPage-CoghqsZb.js +0 -1
  209. package/dist/assets/DashboardView-CGC-_Om8.js +0 -1
  210. package/dist/assets/DocPage-CIZE5kdj.js +0 -1
  211. package/dist/assets/DocsSlug-DXdFdwlS.js +0 -1
  212. package/dist/assets/ExpressionProvider-DZfMwyMs.js +0 -1
  213. package/dist/assets/MarketplacePackagePage-C7NOu2Ir.js +0 -4
  214. package/dist/assets/PageView-CVLgCRSF.js +0 -1
  215. package/dist/assets/RecordDetailView-DQKydU7X.js +0 -3
  216. package/dist/assets/RecordFormPage-BTjwxJIA.js +0 -1
  217. package/dist/assets/ReportDefaultInspector-DdsQAkd7.js +0 -1
  218. package/dist/assets/SchemaForm-C8X1ve4p.js +0 -3
  219. package/dist/assets/SearchResultsPage-Jwhqsdyo.js +0 -1
  220. package/dist/assets/SettingsView-D8SMKdrc.js +0 -1
  221. package/dist/assets/appRoute-DbnWDEa1.js +0 -1
  222. package/dist/assets/data-adapter-DMbe6Njk.js +0 -1
  223. package/dist/assets/default-inspector-registry-CpL3fFhl.js +0 -1
  224. package/dist/assets/dist-BXrEV1ag.js +0 -13
  225. package/dist/assets/en-AU-C6x7mDhH.js +0 -1
  226. package/dist/assets/en-GB-0-nho2eK.js +0 -1
  227. package/dist/assets/en-IE-2fC3BkfV.js +0 -1
  228. package/dist/assets/en-IN-C1QcFhxn.js +0 -1
  229. package/dist/assets/en-NZ-C80ptZT7.js +0 -1
  230. package/dist/assets/en-ZA-ByZDrjeb.js +0 -1
  231. package/dist/assets/framework-DcWkeiND.js +0 -35
  232. package/dist/assets/getIcon-BEVyC4y3.js +0 -1
  233. package/dist/assets/i18n-CEKxYdmD.js +0 -9
  234. package/dist/assets/i18n-locale-ar-DN7sl3GF.js +0 -4
  235. package/dist/assets/i18n-locale-de-C40JErvb.js +0 -4
  236. package/dist/assets/i18n-locale-en-CITPDIHy.js +0 -4
  237. package/dist/assets/i18n-locale-es-C8DdWN6c.js +0 -4
  238. package/dist/assets/i18n-locale-fr-COIdEZZl.js +0 -4
  239. package/dist/assets/i18n-locale-ja-DYF_rU_s.js +0 -4
  240. package/dist/assets/i18n-locale-ko-B-ODYAtX.js +0 -4
  241. package/dist/assets/i18n-locale-pt-CK1SyBIm.js +0 -4
  242. package/dist/assets/i18n-locale-ru-jLzvShMO.js +0 -4
  243. package/dist/assets/i18n-locale-zh-Bf9Gbbvl.js +0 -4
  244. package/dist/assets/index-CLyvpiGc.css +0 -2
  245. package/dist/assets/index-CfnfGw5W.js +0 -20
  246. package/dist/assets/isSameWeek-DWYeNyh8.js +0 -1
  247. package/dist/assets/mermaid-GHXKKRXX-DVLc_uym.js +0 -1
  248. package/dist/assets/metadata-admin-CybaOCdO.js +0 -9
  249. package/dist/assets/nav-selection-Dzm_mA3C.js +0 -1
  250. package/dist/assets/plugin-calendar-CKRBcML7.js +0 -1
  251. package/dist/assets/plugin-charts-DGTJxXCB.js +0 -7
  252. package/dist/assets/plugin-chatbot-DwtwNA-y.js +0 -122
  253. package/dist/assets/plugin-dashboard-C1AYKmGX.js +0 -6
  254. package/dist/assets/plugin-form-CV8ZY04-.js +0 -1
  255. package/dist/assets/plugin-gantt-BRIb2_8G.js +0 -63
  256. package/dist/assets/plugin-grid-C9h7mRVv.js +0 -11
  257. package/dist/assets/plugin-kanban-BcJ0Dhys.js +0 -1
  258. package/dist/assets/plugin-map-D24ZUOUj.js +0 -1
  259. package/dist/assets/plugin-report-BfGintAq.js +0 -59
  260. package/dist/assets/plugin-timeline-CbBRq_qt.js +0 -1
  261. package/dist/assets/plugin-tree-BNX2A5J5.js +0 -1
  262. package/dist/assets/plugin-view-DzWQWYyH.js +0 -1
  263. package/dist/assets/plugins-views-DraK4xz0.js +0 -3
  264. package/dist/assets/src-B8lv0plz.js +0 -18
  265. package/dist/assets/src-DoDvT77T.js +0 -1
  266. package/dist/assets/types-zod-Y2RwUUeJ.js +0 -1
  267. package/dist/assets/ui-components-BTB1NkUW.js +0 -37
  268. package/dist/assets/ui-layout-bZfafwJa.js +0 -1
  269. package/dist/assets/use-book-data-C3eyZJSG.js +0 -1
  270. package/dist/assets/vendor-objectstack-XuWC71M9.js +0 -266
  271. package/dist/assets/vendor-zod-CHLW1iCr.js +0 -64
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/console",
3
- "version": "17.5.0",
3
+ "version": "17.6.0",
4
4
  "description": "Prebuilt Console SPA pinned to this framework release, installed as a dependency of @objectstack/cli. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/objectstack-ai/objectstack/tree/main/packages/console",
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,p as n,r,t as i,v as a}from"./vendor-react-BggL7APJ.js";import{t as o}from"./vendor-icon-book-open-DKPXYwQK.js";import{t as s}from"./vendor-icon-loader-circle-D3PsuVaD.js";import{t as c}from"./DocShell-Bzl3QS30.js";import{a as l,c as u,n as d}from"./use-book-data-C3eyZJSG.js";var f=e(a(),1),p=i();function m(){let{appName:e}=n(),{books:i,docs:a,state:m}=d(),h=(0,f.useMemo)(()=>i.filter(t=>u(t)===e),[i,e]),g=(0,f.useMemo)(()=>l(h,a),[h,a]);return m===`loading`?(0,p.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,p.jsx)(s,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):g.length===1?(0,p.jsx)(t,{to:`/apps/${e}/docs/${g[0].slug}`,replace:!0}):(0,p.jsx)(c,{children:(0,p.jsx)(`div`,{className:`mx-auto max-w-3xl p-4 sm:p-6`,children:g.length===0?(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,p.jsx)(o,{className:`h-10 w-10`}),(0,p.jsx)(`p`,{className:`text-sm`,children:`This app does not ship any documentation yet.`}),(0,p.jsx)(r,{to:`/docs`,className:`text-sm font-medium text-primary hover:underline`,children:`Browse all documentation`})]}):(0,p.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:g.map(t=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(r,{to:`/apps/${e}/docs/${t.slug}`,className:`flex h-full items-start gap-3 rounded-md border border-border p-3 hover:bg-muted/50`,children:[(0,p.jsx)(o,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold`,children:t.label}),t.description?(0,p.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:t.description}):t.subtitle?(0,p.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground/70`,children:t.subtitle}):null,(0,p.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground/80`,children:[t.docCount,` `,t.docCount===1?`article`:`articles`]})]})]})},t.name))})})})}export{m as default};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{m as t,p as n,r,t as i,v as a}from"./vendor-react-BggL7APJ.js";import{a as o,p as s,v as c}from"./infrastructure-BHSync5f.js";import{a as l,o as ee}from"./vendor-objectstack-XuWC71M9.js";import{$ as te,$t as ne,An as re,Br as ie,Dn as u,Fn as ae,In as oe,Ln as d,Mn as se,Nn as ce,Ot as le,Pn as ue,Qt as de,Rn as fe,Rr as pe,Tt as me,Xt as he,Zt as ge,_i as _e,an as ve,bi as f,di as ye,en as be,fi as xe,gi as Se,hi as Ce,in as we,jn as Te,kn as Ee,li as De,mi as Oe,ni as p,nn as m,oi as ke,pi as Ae,qn as je,rn as h,si as Me,tn as Ne,ui as Pe,vi as g,wt as Fe,zn as Ie,zr as Le}from"./ui-components-BTB1NkUW.js";import{G as Re}from"./framework-DcWkeiND.js";import{p as _,t as ze,w as Be}from"./i18n-runtime-CTgAQF4N.js";import{r as v}from"./vendor-ui-utils-DIUdEYii.js";import{t as Ve}from"./vendor-icon-arrow-up-down-DdDqplfV.js";import{t as He}from"./vendor-icon-check-vpu9Zukp.js";import{t as Ue}from"./vendor-icon-chevron-left-KnDcuFH1.js";import{t as We}from"./vendor-icon-chevron-right-DbnKwHYQ.js";import{t as Ge}from"./vendor-icon-circle-alert-D1XTr_X9.js";import{t as Ke}from"./vendor-icon-circle-check-Bq3OcFQN.js";import{t as qe}from"./vendor-icon-circle-x-Nkh1Yr7N.js";import{t as Je}from"./vendor-icon-circle-5-gUQbxi.js";import{t as Ye}from"./vendor-icon-clock-CTLnah0r.js";import{t as Xe}from"./vendor-icon-copy-B5M-KdZo.js";import{t as Ze}from"./vendor-icon-external-link-SBKz5x6R.js";import{t as Qe}from"./vendor-icon-link-2-off-Donc5rrk.js";import{t as $e}from"./vendor-icon-paperclip-zxZDBuvr.js";import{t as et}from"./vendor-icon-refresh-cw-BGjSPEfJ.js";import{t as tt}from"./vendor-icon-search-B2Uqtp_W.js";import{t as nt}from"./vendor-icon-send-BlZYLCTK.js";import{t as rt}from"./vendor-icon-shield-alert-CJYtPI9w.js";import{t as it}from"./vendor-icon-square-check-big-B4UVzWzR.js";import{t as at}from"./vendor-icon-trash-BLsWkwB9.js";import{t as ot}from"./vendor-icon-user-IWwlLQut.js";import{t as st}from"./vendor-icon-workflow-B9ASq0nN.js";import{t as ct}from"./vendor-icon-x-CcLtgRNL.js";import"./src-B8lv0plz.js";import{r as lt,y as ut}from"./RecordDetailView-DQKydU7X.js";import{t as dt}from"./studioEntry-nXQP3iL0.js";var y=e(a(),1),b=`${``.replace(/\/$/,``)}/api/v1`;async function x(e,t){let n=c.get(),r=await fetch(`${b}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...n?{Authorization:`Bearer ${n}`}:{},...t?.headers||{}},...t}),i=null;try{i=await r.json()}catch{}if(!r.ok){let e=i?.code??`HTTP_${r.status}`,t=i?.message??i?.error??r.statusText,n=Error(`${e}: ${t}`);throw n.code=e,n.status=r.status,n.details=i,n}return i}var S={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return x(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId);let n=Array.isArray(e.approverId)?e.approverId.filter(Boolean).join(`,`):e.approverId;n&&t.set(`approverId`,n),e.submitterId&&t.set(`submitterId`,e.submitterId),e.q?.trim()&&t.set(`q`,e.q.trim()),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let r=t.toString();return x(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await x(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return x(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await x(`/approvals/requests/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async reject(e,t){let n=await x(`/approvals/requests/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async recall(e,t){return{data:(await x(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await x(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await x(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,notified:n.notified}},async requestInfo(e,t){return{data:(await x(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await x(`/approvals/requests/${encodeURIComponent(e)}/revise`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,autoRejected:n.autoRejected===!0}},async resubmit(e,t={}){let n=await x(`/approvals/requests/${encodeURIComponent(e)}/resubmit`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,resumed:n.resumed===!0}},async comment(e,t){return{data:(await x(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return x(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function ft(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);let n=[...e.positions||[],...typeof e.role==`string`?e.role.split(`,`):[]];for(let e of n){let n=String(e).trim();n&&t.add(`role:${n}`)}return Array.from(t)}function C(e,t){return`${e}::${t}`}function w(e){return typeof e.object_name==`string`&&e.object_name!==``&&typeof e.record_id==`string`&&e.record_id!==``}function T(e){let t=new Map,n=new Set;for(let r of e){if(!w(r))continue;let e=C(r.object_name,r.record_id);if(n.has(e))continue;n.add(e);let i=t.get(r.object_name);i?i.push(r.record_id):t.set(r.object_name,[r.record_id])}let r=[];for(let[e,n]of t)for(let t=0;t<n.length;t+=100)r.push({objectName:e,ids:n.slice(t,t+100)});return r}function E(e){if(Array.isArray(e))return e;let t=e?.data;return Array.isArray(t)?t:[]}async function pt(e,t){let n=new Map,r=T(t);return await Promise.all(r.map(async({objectName:t,ids:r})=>{let i;try{let n=await e.find(t,{$filter:{id:{$in:r}},$select:[`id`],$top:r.length});i=new Set(E(n).map(e=>e?.id).filter(e=>typeof e==`string`&&e!==``))}catch{return}for(let e of r)n.set(C(t,e),i.has(e))})),n}function mt(e){let t=Re(),[n,r]=(0,y.useState)(()=>new Map),i=(0,y.useRef)(new Set),a=(0,y.useRef)(e);a.current=e;let o=(0,y.useMemo)(()=>e.filter(w).map(e=>C(e.object_name,e.record_id)).join(`|`),[e]);return(0,y.useEffect)(()=>{if(!t)return;let e=a.current.filter(e=>w(e)&&!i.current.has(C(e.object_name,e.record_id)));if(e.length===0)return;for(let t of e)w(t)&&i.current.add(C(t.object_name,t.record_id));let n=!1;return pt(t,e).then(e=>{n||e.size===0||r(t=>{let n=new Map(t);for(let[t,r]of e)n.set(t,r);return n})}),()=>{n=!0}},[t,o]),(0,y.useMemo)(()=>({isUnreadable:e=>w(e)&&n.get(C(e.object_name,e.record_id))===!1}),[n])}var ht=`sys_approval_request`,gt=`cancel_reason`,D=`record_deleted`;function _t(e){return e?.status===`cancelled`&&e?.cancel_reason===`record_deleted`}function vt(){let{fieldOptionLabel:e}=_();return(0,y.useMemo)(()=>e(ht,gt,D,l.record_deleted),[e])}function yt(e,t){return!e||_t(e)||typeof e.record_title==`string`&&e.record_title.trim()!==``?!1:t}function bt(){let{t:e}=Be();return(0,y.useMemo)(()=>String(e(`approvalsInbox.recordUnresolvable`,{defaultValue:`This record cannot be opened`})),[e])}var O=new Set;function k(e){let t=e?.fields;if(!t||typeof t!=`object`)return O;let n=new Set;if(Array.isArray(t))for(let e of t){if(!e||typeof e!=`object`)continue;let t=e,r=t.name;typeof r==`string`&&r!==``&&t.hidden===!0&&n.add(r)}else for(let[e,r]of Object.entries(t))r&&typeof r==`object`&&r.hidden===!0&&n.add(e);return n.size>0?n:O}async function xt(e,t){if(typeof e?.getObjectSchema!=`function`)return O;try{return k(await e.getObjectSchema(t))}catch{return O}}function A(e){let t=[],n=new Set;for(let r of e)typeof r!=`string`||r===``||n.has(r)||(n.add(r),t.push(r));return t}function St(e){let t=Re(),[n,r]=(0,y.useState)(()=>new Map),i=(0,y.useRef)(new Set),a=(0,y.useRef)(e);a.current=e;let o=(0,y.useMemo)(()=>A(e).join(`|`),[e]);return(0,y.useEffect)(()=>{if(!t)return;let e=A(a.current).filter(e=>!i.current.has(e));if(e.length===0)return;for(let t of e)i.current.add(t);let n=!1;return Promise.all(e.map(async e=>[e,await xt(t,e)])).then(e=>{n||r(t=>{let n=new Map(t);for(let[t,r]of e)n.set(t,r);return n})}),()=>{n=!0}},[t,o]),(0,y.useMemo)(()=>({forObject:e=>typeof e==`string`&&e!==``?n.get(e)??O:O}),[n])}var j=i(),Ct=50,wt={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`,cancelled:`border-border bg-muted text-muted-foreground`};function Tt({status:e,label:t}){return(0,j.jsx)(p,{variant:`outline`,className:f(`font-medium`,wt[e]??``),children:t})}function Et({label:e,className:t}){return(0,j.jsxs)(`div`,{className:f(`flex items-center gap-1.5 text-muted-foreground min-w-0`,t),title:e,children:[(0,j.jsx)(at,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`truncate italic`,children:e})]})}function Dt({label:e,className:t}){return(0,j.jsxs)(`div`,{className:f(`flex items-center gap-1.5 text-muted-foreground min-w-0`,t),title:e,children:[(0,j.jsx)(Qe,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`truncate italic`,children:e})]})}function Ot(e,t){if(!e)return`—`;try{return new Date(e).toLocaleString(t)}catch{return e}}function M(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function N(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function kt(e){return e.process_label||N(e.process_name)}function At(e){return e.step_label?e.step_label:e.current_step?N(e.current_step):null}function jt(e){return e.submitter_name||M(e.submitter_id)}function Mt(e,t){return t.pending_approver_names?.[e]||M(e)}function Nt(e,t){let n=t.pending_approver_groups?.[e];return n&&n.length?n.join(` / `):void 0}function Pt(e){let t=[],n=new Map;for(let r of e.pending_approvers||[]){let i=Mt(r,e),a=Nt(r,e),o=a?`${i} ${a}`:i,s=n.get(o);s?(s.count+=1,r&&!s.title.split(`, `).includes(r)&&(s.title+=`, ${r}`)):(n.set(o,{label:i,group:a,count:1,title:r||i}),t.push(o))}return t.map(e=>n.get(e))}function Ft(e){if(e.submitter_name)return!1;let t=(e.submitter_id||``).trim();return!t||t.startsWith(`flow:`)||t.startsWith(`system:`)}function It(e){return e.object_label||e.object_name}function P(e){return e.submitted_at||e.created_at||void 0}function Lt(e,t){let n=P(e);if(!n)return null;let r=Date.parse(n);return Number.isNaN(r)?null:(t-r)/36e5}function Rt(e,t){if(e.status!==`pending`)return`text-muted-foreground`;let n=Lt(e,t);return n==null?`text-muted-foreground`:n>72?`text-red-600 dark:text-red-400 font-medium`:n>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function zt(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}function Bt(e,t){if(!e)return null;let n=Date.parse(e);return Number.isNaN(n)?null:{overdue:n<t,ms:Math.abs(t-n)}}var Vt=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function F(e){let t=e.split(`_`).filter(Boolean);return t.length>1&&t[t.length-1].toLowerCase()===`id`&&t.pop(),t.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function I(e,t,n){if(typeof t==`boolean`)return t?`✓`:`—`;if(typeof t==`number`){if(t>0xe8d4a51000&&/(_at$|_date$|^date_|_time$)/.test(e))try{return new Date(t).toLocaleDateString(n)}catch{}return t.toLocaleString(n)}let r=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(r))try{return new Date(r).toLocaleString(n)}catch{}return r}var Ht=/^[A-Za-z0-9_-]{15,}$/;function Ut(e,t,n,r,i=6,a,o){if(!e||typeof e!=`object`||Array.isArray(e))return[];let s=[];for(let[c,l]of Object.entries(e)){if(Vt.has(c)||o?.has(c)||a&&c===a||l==null||typeof l==`object`||String(l).trim()===``)continue;let e=n?.[c];if((e||typeof l!=`string`||!Ht.test(l.trim())||/^\d+$/.test(l.trim()))&&(s.push([r?.[c]??F(c),e??I(c,l,t)]),s.length>=i))break}return s}var Wt=/(amount|total|price|value|cost|sum|budget|salary|fee|revenue|balance|金额|总额|价格|费用|预算|金额)/i;function Gt(e,t,n){let r=e.payload;if(!r||typeof r!=`object`||Array.isArray(r))return null;for(let[i,a]of Object.entries(r)){if(Vt.has(i)||t.has(i)||!Wt.test(i))continue;let r=typeof a==`number`?a:typeof a==`string`&&a.trim()!==``&&Number.isFinite(Number(a))?Number(a):null;if(r!=null&&Number.isFinite(r))return{key:i,label:e.payload_labels?.[i]??F(i),value:r,display:e.payload_display?.[i]??r.toLocaleString(n)}}return null}function Kt({r:e,tr:t}){return(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`font-medium truncate`,children:kt(e)}),(0,j.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[At(e)||`—`,(e.round??1)>1&&(0,j.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:t(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function qt({r:e,href:t,hiddenKeys:n,deadLabel:i,unresolvableLabel:a}){let o=Gt(e,n,ze()),s=e.record_title||M(e.record_id);return(0,j.jsxs)(`div`,{className:`min-w-0`,children:[i===null?a===null?t===null?(0,j.jsx)(`div`,{className:`text-sm truncate max-w-full`,title:s,children:s}):(0,j.jsxs)(r,{to:t,onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:s,children:[(0,j.jsx)(`span`,{className:`truncate`,children:s}),(0,j.jsx)(Ze,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}):(0,j.jsx)(Dt,{label:a,className:`text-sm max-w-full`}):(0,j.jsx)(Et,{label:i,className:`text-sm max-w-full`}),(0,j.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[It(e),i!==null&&e.record_title&&(0,j.jsxs)(`span`,{className:`ml-1.5`,children:[`· `,e.record_title]}),o&&(0,j.jsxs)(`span`,{className:`ml-1.5 font-medium text-foreground`,title:`${o.label}: ${o.display}`,children:[`· `,o.display]})]})]})}function Jt({r:e,actionable:t,busy:n,needsInputs:r,tr:i,onApprove:a,onReject:o}){if(!t)return null;let s=i(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`);return(0,j.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),title:r?s:void 0,children:[(0,j.jsx)(g,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-emerald-700 hover:text-emerald-800 hover:bg-emerald-50 dark:text-emerald-400`,disabled:n||r,onClick:()=>a(e),"aria-label":r?s:i(`approve`,`Approve`),children:(0,j.jsx)(Ke,{className:`h-4 w-4`})}),(0,j.jsx)(g,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400`,disabled:n||r,onClick:()=>o(e),"aria-label":r?s:i(`reject`,`Reject`),children:(0,j.jsx)(qe,{className:`h-4 w-4`})})]})}function Yt(){let{t:e}=Be(),i=ze(),{user:a}=s(),{appName:c}=n(),[l,Re]=t(),_=(0,y.useMemo)(()=>ft(a),[a]),{systemPermissions:Qe}=te(),at=dt(Qe),b=(0,y.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),[x,C]=(0,y.useState)(()=>Date.now());(0,y.useEffect)(()=>{let e=setInterval(()=>C(Date.now()),6e4);return()=>clearInterval(e)},[]);let w=(0,y.useCallback)(e=>{if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Math.round((x-t)/1e3);if(n<45)return b(`justNow`,`just now`);let r=Math.round(n/60);if(r<60)return b(`minutesAgo`,`{{count}}m ago`,{count:r});let a=Math.round(r/60);if(a<24)return b(`hoursAgo`,`{{count}}h ago`,{count:a});let o=Math.round(a/24);if(o<30)return b(`daysAgo`,`{{count}}d ago`,{count:o});try{return new Date(e).toLocaleDateString(i)}catch{return e}},[b,i,x]),T=(0,y.useCallback)(e=>{switch(e){case`pending`:return b(`statusPending`,`Pending`);case`approved`:return b(`statusApproved`,`Approved`);case`rejected`:return b(`statusRejected`,`Rejected`);case`recalled`:return b(`statusRecalled`,`Recalled`);case`returned`:return b(`statusReturned`,`Returned for revision`);case`cancelled`:return b(`statusCancelled`,ee.cancelled);default:return e}},[b]),E=(0,y.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?b(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?b(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?b(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?b(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?b(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[b]),pt=(0,y.useCallback)(e=>e.overdue?b(`slaOverdue`,`SLA overdue {{dur}}`,{dur:zt(e.ms)}):b(`slaRemaining`,`SLA {{dur}} left`,{dur:zt(e.ms)}),[b]),ht=(0,y.useCallback)(e=>`/apps/${c||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[c]),gt=vt(),D=(0,y.useCallback)(e=>_t(e)?gt:null,[gt]),O=bt(),[k,xt]=(0,y.useState)(`pending`),[A,wt]=(0,y.useState)([]),[N,Nt]=(0,y.useState)(!1),[Lt,Vt]=(0,y.useState)(!1),[F,I]=(0,y.useState)(null),[Ht,Wt]=(0,y.useState)(null),[Yt,Xt]=(0,y.useState)(0),[L,Zt]=(0,y.useState)(null),[R,Qt]=(0,y.useState)(null),[$t,en]=(0,y.useState)([]),[tn,nn]=(0,y.useState)(!1),rn=(0,y.useMemo)(()=>R?[...A,R]:A,[A,R]),an=mt(rn),on=(0,y.useCallback)(e=>yt(e,!!e&&an.isUnreadable(e))?O:null,[an,O]),z=St((0,y.useMemo)(()=>rn.map(e=>e.object_name),[rn])),sn=z.forObject(R?.object_name),cn=(0,y.useMemo)(()=>o(),[]),ln=(0,y.useCallback)(async e=>{let t=window.open(``,`_blank`,`noopener`);try{let n=``.replace(/\/$/,``),r=await cn(`${n}/api/v1/storage/files/${encodeURIComponent(e.id)}/url`);if(!r.ok)throw Error(`HTTP_${r.status}`);let i=await r.json().catch(()=>null),a=i?.data?.url??i?.url;if(!a)throw Error(`NO_URL`);let o=/^https?:\/\//i.test(a)?a:`${n}${a}`;t?t.location.href=o:window.open(o,`_blank`,`noopener`)}catch{t?.close(),v.error(b(`attachmentOpenFailed`,`Could not open the attachment — please try again`))}},[cn,b]),[B,un]=(0,y.useState)(``),[dn,fn]=(0,y.useState)(``),[pn,mn]=(0,y.useState)(`all`),[hn,gn]=(0,y.useState)(`all`),[V,_n]=(0,y.useState)(`all`),[vn,yn]=(0,y.useState)(`recent`),[H,bn]=(0,y.useState)(new Set),[xn,Sn]=(0,y.useState)(!1),[U,Cn]=(0,y.useState)(null),[W,wn]=(0,y.useState)(null),[Tn,En]=(0,y.useState)(null),[G,Dn]=(0,y.useState)(``),[On,kn]=(0,y.useState)(!1),[An,jn]=(0,y.useState)(-1);(0,y.useEffect)(()=>{if(k===`pending`)return;let e=window.setTimeout(()=>fn(B),350);return()=>window.clearTimeout(e)},[B,k]);let K=(0,y.useCallback)(async()=>{Nt(!0),Wt(null);try{let e=[];if(k===`pending`)e=_.length?(await S.listRequests({status:`pending`,approverId:_})).data:[],Xt(e.length),I(null);else{let t={q:dn||void 0,status:V===`all`?void 0:V,limit:Ct,offset:0};if(k===`submitted`){let n=a?.id;if(n){let r=await S.listRequests({submitterId:n,...t});e=r.data,I(r.total??r.data.length)}else e=[],I(0)}else{let n=await S.listRequests(t);e=n.data,I(n.total??n.data.length)}_.length&&S.listRequests({status:`pending`,approverId:_}).then(e=>Xt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(P(t)||``).localeCompare(P(e)||``)),wt(e)}catch(e){Wt(e?.message||String(e)),wt([])}finally{Nt(!1)}},[k,_,a?.id,dn,V]);(0,y.useEffect)(()=>{K()},[K]);let Mn=(0,y.useCallback)(async()=>{if(!(k===`pending`||Lt)){Vt(!0);try{let e=await S.listRequests({submitterId:k===`submitted`?a?.id??void 0:void 0,q:dn||void 0,status:V===`all`?void 0:V,limit:Ct,offset:A.length});wt(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&I(e.total)}catch(e){v.error(E(e,b(`loadFailed`,`Failed to load request`)))}finally{Vt(!1)}}},[k,Lt,a?.id,dn,V,A.length,E,b]),q=(0,y.useCallback)(async e=>{Zt(e),nn(!0);try{let[t,n]=await Promise.all([S.getRequest(e),S.listActions(e)]);Qt(t.data),en(n.data)}catch(e){v.error(E(e,b(`loadFailed`,`Failed to load request`))),Qt(null),en([])}finally{nn(!1)}},[E,b]),Nn=()=>{Zt(null),Qt(null),en([])};(0,y.useEffect)(()=>{let e=l.get(`request`);e&&(Re(e=>{let t=new URLSearchParams(e);return t.delete(`request`),t},{replace:!0}),q(e))},[l]);let J=(0,y.useCallback)(()=>{_.length&&S.listRequests({status:`pending`,approverId:_}).then(e=>Xt(e.data.length)).catch(()=>{})},[_]),Pn=(0,y.useCallback)(async e=>{let[t,n]=await Promise.all([S.getRequest(e),S.listActions(e)]);Qt(t.data),en(n.data),K()},[K]),Fn=(0,y.useCallback)(async()=>{if(!R)return;let e=R.id;try{let[t,n]=await Promise.all([S.getRequest(e),S.listActions(e)]);Qt(t.data),en(n.data),K();let r=new Set(t.data.pending_approvers||[]),i=t.data.status===`pending`&&_.some(e=>r.has(e));if(k===`pending`&&!i){let t=Xn.current,n=t.findIndex(t=>t.id===e),r=t[n+1]??t[n-1];if(r&&r.id!==e){q(r.id);return}Nn()}}catch{Pn(e)}},[R,_,k,K,q,Nn,Pn]),In=(0,y.useCallback)(async()=>{if(R&&G.trim()){kn(!0);try{await S.comment(R.id,{actor_id:a?.id,comment:G.trim()}),Dn(``),await Pn(R.id)}catch(e){v.error(E(e,b(`actionFailed`,`Action failed`)))}finally{kn(!1)}}},[R,G,a?.id,Pn,E,b]),Ln=(0,y.useMemo)(()=>{if(!R||R.status!==`pending`)return!1;if(R.viewer)return R.viewer.can_act||!!R.viewer.can_override;let e=new Set(R.pending_approvers||[]);return _.some(t=>e.has(t))},[R,_]),Rn=(0,y.useMemo)(()=>!R||R.status!==`pending`?!1:R.viewer?R.viewer.is_submitter:R.submitter_id===a?.id,[R,a?.id]),zn=(0,y.useMemo)(()=>!R||R.status!==`returned`?!1:R.viewer?R.viewer.is_submitter:R.submitter_id===a?.id,[R,a?.id]),Bn=(0,y.useMemo)(()=>{let e=new Set;for(let t of A)e.add(kt(t));return Array.from(e).sort()},[A]),Vn=(0,y.useMemo)(()=>{let e=new Set;for(let t of A)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[A]),Y=(0,y.useMemo)(()=>{let e=B.trim().toLowerCase(),t=A.filter(t=>pn!==`all`&&kt(t)!==pn||hn!==`all`&&t.object_name!==hn||V!==`all`&&t.status!==V?!1:k!==`pending`||!e||[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e));if(vn===`recent`)return t;let n=[...t];return vn===`amount`?n.sort((e,t)=>{let n=Gt(e,z.forObject(e.object_name),i)?.value,r=Gt(t,z.forObject(t.object_name),i)?.value;return n==null&&r==null?0:n==null?1:r==null?-1:r-n}):n.sort((e,t)=>(P(e)||``).localeCompare(P(t)||``)),n},[A,B,pn,hn,V,k,vn,z,i]),X=(0,y.useMemo)(()=>L?Y.findIndex(e=>e.id===L):-1,[Y,L]);(0,y.useEffect)(()=>{if(H.size===0)return;let e=new Set(Y.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&bn(n)},[Y,H]),(0,y.useEffect)(()=>{An>=Y.length&&jn(Y.length-1)},[Y.length,An]);let Hn=(0,y.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(_);return(e.pending_approvers||[]).some(e=>t.has(e))},[_]),Z=(0,y.useCallback)(e=>Array.isArray(e.decision_outputs)&&e.decision_outputs.length>0,[]),Un=(0,y.useCallback)(e=>Hn(e)&&!Z(e),[Hn,Z]),Q=(0,y.useMemo)(()=>Y.filter(e=>H.has(e.id)&&Un(e)),[Y,H,Un]),$=Y.filter(e=>e.status===`pending`),Wn=$.length>0&&$.every(e=>H.has(e.id)),Gn=(0,y.useCallback)(()=>{bn(e=>{if(Wn)return new Set;let t=new Set(e);for(let e of $)t.add(e.id);return t})},[Wn,$]),Kn=(0,y.useCallback)(e=>{bn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),qn=(0,y.useCallback)(async e=>{let t=Q;if(t.length===0)return;Sn(!0);let n=0,r=[];for(let i of t){let t=new Set(i.pending_approvers||[]),o=_.find(e=>t.has(e))||a?.id||``;try{await(e===`approve`?S.approve:S.reject)(i.id,{actor_id:o}),n++}catch{r.push(i.record_title||M(i.record_id))}}if(Sn(!1),bn(new Set),r.length===0)v.success(e===`approve`?b(`bulkApproved`,`Approved {{count}} requests`,{count:n}):b(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);v.error(b(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),J()},[Q,_,a?.id,K,J,b]),Jn=(0,y.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=_.find(e=>t.has(e))||a?.id||``;En(e.id),Cn(null);try{let t=await S.approve(e.id,{actor_id:n});v.success(t.finalized?b(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||M(e.record_id)}):b(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),J()}catch(e){v.error(E(e,b(`actionFailed`,`Action failed`)))}finally{En(null)}},[U,_,a?.id,K,J,E,b]),Yn=(0,y.useCallback)(async()=>{let e=W;if(!e)return;let t=new Set(e.pending_approvers||[]),n=_.find(e=>t.has(e))||a?.id||``;En(e.id),wn(null);try{await S.reject(e.id,{actor_id:n}),v.success(b(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||M(e.record_id)})),K(),J()}catch(e){v.error(E(e,b(`actionFailed`,`Action failed`)))}finally{En(null)}},[W,_,a?.id,K,J,E,b]),Xn=(0,y.useRef)(Y);Xn.current=Y;let Zn=(0,y.useRef)(An);Zn.current=An,(0,y.useEffect)(()=>{let e=e=>{if(L||U||W)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Xn.current;if(!r.length)return;let i=Zn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),jn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),jn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),q(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&k===`pending`?(e.preventDefault(),Kn(r[i].id)):e.key===`a`&&i>=0&&r[i]&&Un(r[i])?(e.preventDefault(),Cn(r[i])):e.key===`r`&&i>=0&&r[i]&&Un(r[i])&&(e.preventDefault(),wn(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[L,U,W,k,q,Kn,Un]),(0,y.useEffect)(()=>{if(!L)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Xn.current,i=r.findIndex(e=>e.id===L);if(i<0)return;let a=e.key===`ArrowLeft`?r[i-1]:r[i+1];a&&(e.preventDefault(),q(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[L,q]);let Qn=!!B||pn!==`all`||hn!==`all`||V!==`all`,$n=e=>{xt(e),_n(`all`),mn(`all`),gn(`all`),un(``),yn(`recent`),jn(-1)};return(0,j.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,j.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,j.jsx)(it,{className:`h-6 w-6`}),b(`title`,`Approvals Inbox`)]}),(0,j.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:b(`subtitle`,`Review and act on approval requests.`)})]}),(0,j.jsxs)(g,{variant:`outline`,size:`sm`,onClick:K,disabled:N,className:`self-start sm:self-auto`,children:[(0,j.jsx)(et,{className:`h-4 w-4 mr-2 ${N?`animate-spin`:``}`}),b(`refresh`,`Refresh`)]})]}),Ht&&(0,j.jsxs)(ke,{variant:`destructive`,children:[(0,j.jsx)(Ge,{className:`h-4 w-4`}),(0,j.jsx)(Me,{children:Ht})]}),(0,j.jsxs)(he,{value:k,onValueChange:$n,children:[(0,j.jsxs)(de,{children:[(0,j.jsxs)(ne,{value:`pending`,children:[b(`tabMyPending`,`My Pending`),Yt>0&&(0,j.jsx)(p,{variant:`secondary`,className:`ml-2`,children:Yt})]}),(0,j.jsx)(ne,{value:`submitted`,children:b(`tabSubmitted`,`Submitted by me`)}),(0,j.jsx)(ne,{value:`all`,children:b(`tabAll`,`All`)})]}),(0,j.jsxs)(ge,{value:k,className:`mt-4 space-y-3`,children:[!N&&(A.length>0||k!==`pending`&&(dn||V!==`all`))&&(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,j.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,j.jsx)(tt,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,j.jsx)(je,{value:B,onChange:e=>un(e.target.value),placeholder:b(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),B&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>un(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":b(`clearSearch`,`Clear search`),children:(0,j.jsx)(ct,{className:`h-3.5 w-3.5`})})]}),k!==`pending`&&(0,j.jsxs)(ae,{value:V,onValueChange:_n,children:[(0,j.jsx)(fe,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,j.jsx)(Ie,{placeholder:b(`statusFilter`,`Status`)})}),(0,j.jsxs)(oe,{children:[(0,j.jsx)(d,{value:`all`,children:b(`allStatuses`,`All statuses`)}),(0,j.jsx)(d,{value:`pending`,children:T(`pending`)}),(0,j.jsx)(d,{value:`approved`,children:T(`approved`)}),(0,j.jsx)(d,{value:`rejected`,children:T(`rejected`)}),(0,j.jsx)(d,{value:`recalled`,children:T(`recalled`)}),(0,j.jsx)(d,{value:`returned`,children:T(`returned`)})]})]}),Bn.length>1&&(0,j.jsxs)(ae,{value:pn,onValueChange:mn,children:[(0,j.jsx)(fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,j.jsx)(Ie,{placeholder:b(`processFilter`,`Process`)})}),(0,j.jsxs)(oe,{children:[(0,j.jsx)(d,{value:`all`,children:b(`allProcesses`,`All processes`)}),Bn.map(e=>(0,j.jsx)(d,{value:e,children:e},e))]})]}),Vn.length>1&&(0,j.jsxs)(ae,{value:hn,onValueChange:gn,children:[(0,j.jsx)(fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,j.jsx)(Ie,{placeholder:b(`objectFilter`,`Object`)})}),(0,j.jsxs)(oe,{children:[(0,j.jsx)(d,{value:`all`,children:b(`allObjects`,`All objects`)}),Vn.map(e=>(0,j.jsx)(d,{value:e,children:e},e))]})]}),(0,j.jsxs)(ae,{value:vn,onValueChange:e=>yn(e),children:[(0,j.jsxs)(fe,{className:`h-8 w-auto min-w-[120px] text-sm`,children:[(0,j.jsx)(Ve,{className:`h-3.5 w-3.5 mr-1 text-muted-foreground`}),(0,j.jsx)(Ie,{placeholder:b(`sortBy`,`Sort`)})]}),(0,j.jsxs)(oe,{children:[(0,j.jsx)(d,{value:`recent`,children:b(`sortRecent`,`Newest first`)}),(0,j.jsx)(d,{value:`oldest`,children:b(`sortOldest`,`Oldest first`)}),(0,j.jsx)(d,{value:`amount`,children:b(`sortAmount`,`Amount (high→low)`)})]})]}),Qn&&(0,j.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:b(`filterCount`,`{{shown}} of {{total}}`,{shown:Y.length,total:A.length})})]}),k===`pending`&&H.size>0&&(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:H.size}),` `,b(`selected`,`selected`),Q.length!==H.size&&(0,j.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:b(`actionableCount`,`({{count}} actionable)`,{count:Q.length})})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(De,{children:[(0,j.jsx)(_e,{asChild:!0,children:(0,j.jsxs)(g,{size:`sm`,disabled:xn||Q.length===0,children:[(0,j.jsx)(Ke,{className:`h-3.5 w-3.5 mr-1`}),b(`approveN`,`Approve {{count}}`,{count:Q.length||``})]})}),(0,j.jsxs)(xe,{children:[(0,j.jsxs)(Ce,{children:[(0,j.jsx)(Se,{children:b(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:Q.length})}),(0,j.jsx)(Ae,{children:b(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,j.jsxs)(Oe,{children:[(0,j.jsx)(ye,{children:b(`cancel`,`Cancel`)}),(0,j.jsx)(Pe,{onClick:()=>qn(`approve`),children:b(`approveN`,`Approve {{count}}`,{count:Q.length})})]})]})]}),(0,j.jsxs)(De,{children:[(0,j.jsx)(_e,{asChild:!0,children:(0,j.jsxs)(g,{size:`sm`,variant:`outline`,disabled:xn||Q.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,j.jsx)(qe,{className:`h-3.5 w-3.5 mr-1`}),b(`rejectN`,`Reject {{count}}`,{count:Q.length||``})]})}),(0,j.jsxs)(xe,{children:[(0,j.jsxs)(Ce,{children:[(0,j.jsx)(Se,{children:b(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:Q.length})}),(0,j.jsx)(Ae,{children:b(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,j.jsxs)(Oe,{children:[(0,j.jsx)(ye,{children:b(`cancel`,`Cancel`)}),(0,j.jsx)(Pe,{onClick:()=>qn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:b(`rejectN`,`Reject {{count}}`,{count:Q.length})})]})]})]}),(0,j.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>bn(new Set),disabled:xn,children:b(`clear`,`Clear`)})]})]}),N?(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsx)(u,{className:`h-10 w-full`}),(0,j.jsx)(u,{className:`h-10 w-full`}),(0,j.jsx)(u,{className:`h-10 w-full`})]}):A.length===0?(0,j.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,j.jsxs)(Fe,{children:[(0,j.jsx)(le,{children:b(`emptyTitle`,`No requests`)}),(0,j.jsx)(me,{children:k===`pending`?b(`emptyPending`,`You're all caught up — nothing is waiting on you.`):b(`emptyOther`,`Nothing here yet.`)}),k===`pending`&&(0,j.jsx)(g,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>$n(`all`),children:b(`emptyViewAll`,`Browse all requests`)})]})}):Y.length===0?(0,j.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:b(`noMatches`,`No matches for current filters.`)}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(Le,{className:`hidden md:block`,children:(0,j.jsx)(ie,{className:`p-0`,children:(0,j.jsxs)(be,{children:[(0,j.jsx)(we,{children:(0,j.jsxs)(ve,{children:[k===`pending`&&(0,j.jsx)(h,{className:`w-10`,children:(0,j.jsx)(pe,{checked:Wn,onCheckedChange:Gn,"aria-label":b(`selectAll`,`Select all`),disabled:$.length===0})}),(0,j.jsx)(h,{className:`w-[22%]`,children:b(`colRequest`,`Request`)}),(0,j.jsx)(h,{className:`w-[30%]`,children:b(`colRecord`,`Record`)}),(0,j.jsx)(h,{className:`w-[16%]`,children:b(`colRequester`,`Requester`)}),(0,j.jsx)(h,{className:`w-[110px] min-w-[96px] whitespace-nowrap`,children:b(`colStatus`,`Status`)}),(0,j.jsx)(h,{className:`w-[132px]`,children:b(`colWaiting`,`Submitted`)}),(0,j.jsx)(h,{className:`w-20`,"aria-label":b(`colActions`,`Actions`)})]})}),(0,j.jsx)(Ne,{children:Y.map((e,t)=>(0,j.jsxs)(ve,{className:f(`group cursor-pointer hover:bg-accent/50`,An===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{jn(t),q(e.id)},children:[k===`pending`&&(0,j.jsx)(m,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,j.jsx)(pe,{checked:H.has(e.id),onCheckedChange:()=>Kn(e.id),disabled:e.status!==`pending`,"aria-label":b(`selectRow`,`Select request`)})}),(0,j.jsx)(m,{children:(0,j.jsx)(Kt,{r:e,tr:b})}),(0,j.jsx)(m,{children:(0,j.jsx)(qt,{r:e,href:D(e)!==null||an.isUnreadable(e)?null:ht(e),hiddenKeys:z.forObject(e.object_name),deadLabel:D(e),unresolvableLabel:on(e)})}),(0,j.jsx)(m,{children:Ft(e)?(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,j.jsx)(st,{className:`h-3.5 w-3.5 shrink-0`}),(0,j.jsx)(`span`,{className:`truncate italic`,children:b(`flowOrigin`,`Flow-initiated`)})]}):(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,j.jsx)(ot,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,j.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:jt(e)})]})}),(0,j.jsx)(m,{children:(0,j.jsx)(Tt,{status:e.status,label:T(e.status)})}),(0,j.jsxs)(m,{className:f(`text-xs whitespace-nowrap`,Rt(e,x)),title:Ot(P(e),i),children:[(0,j.jsx)(Ye,{className:`h-3 w-3 inline mr-1`}),w(P(e)),e.status===`pending`&&(()=>{let t=Bt(e.sla_due_at,x);return t?(0,j.jsx)(`div`,{className:f(`mt-0.5 text-[10px] font-medium`,t.overdue?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:pt(t)}):null})()]}),(0,j.jsx)(m,{className:`w-20`,children:(0,j.jsx)(Jt,{r:e,actionable:Hn(e),busy:Tn===e.id,needsInputs:Z(e),tr:b,onApprove:Cn,onReject:wn})})]},e.id))})]})})}),(0,j.jsx)(`div`,{className:`md:hidden space-y-2`,children:Y.map(e=>(0,j.jsx)(Le,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,j.jsxs)(ie,{className:`p-3 space-y-1.5`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsx)(`div`,{className:`font-medium text-sm truncate`,children:kt(e)}),(0,j.jsx)(Tt,{status:e.status,label:T(e.status)})]}),(()=>{let t=D(e),n=on(e);return(0,j.jsxs)(`div`,{className:`text-sm truncate`,children:[t===null?n===null?e.record_title||M(e.record_id):(0,j.jsx)(`span`,{className:`italic text-muted-foreground`,children:n}):(0,j.jsx)(`span`,{className:`italic text-muted-foreground`,children:t}),(0,j.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:It(e)}),t!==null&&e.record_title&&(0,j.jsxs)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:[`· `,e.record_title]}),(()=>{let t=Gt(e,z.forObject(e.object_name),i);return t?(0,j.jsxs)(`span`,{className:`text-xs ml-1.5 font-medium`,title:t.label,children:[`· `,t.display]}):null})()]})})(),(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[Ft(e)?(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate italic`,children:[(0,j.jsx)(st,{className:`h-3 w-3`}),b(`flowOrigin`,`Flow-initiated`)]}):(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,j.jsx)(ot,{className:`h-3 w-3`}),jt(e)]}),(0,j.jsxs)(`span`,{className:f(`inline-flex items-center gap-1 whitespace-nowrap`,Rt(e,x)),children:[(0,j.jsx)(Ye,{className:`h-3 w-3`}),w(P(e))]})]}),Hn(e)&&(0,j.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),title:Z(e)?b(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`):void 0,children:[(0,j.jsxs)(g,{size:`sm`,className:`h-7 flex-1`,disabled:Tn===e.id||Z(e),onClick:()=>Cn(e),children:[(0,j.jsx)(Ke,{className:`h-3.5 w-3.5 mr-1`}),b(`approve`,`Approve`)]}),(0,j.jsxs)(g,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:Tn===e.id||Z(e),onClick:()=>wn(e),children:[(0,j.jsx)(qe,{className:`h-3.5 w-3.5 mr-1`}),b(`reject`,`Reject`)]})]})]})},e.id))}),k!==`pending`&&F!=null&&(0,j.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,j.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:b(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:A.length,total:F})}),A.length<F&&(0,j.jsx)(g,{size:`sm`,variant:`outline`,disabled:Lt,onClick:()=>void Mn(),children:Lt?b(`loadingMore`,`Loading…`):b(`loadMore`,`Load more`)})]}),(0,j.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:b(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,j.jsx)(De,{open:!!U,onOpenChange:e=>!e&&Cn(null),children:(0,j.jsxs)(xe,{children:[(0,j.jsxs)(Ce,{children:[(0,j.jsx)(Se,{children:b(`approveOneTitle`,`Approve "{{title}}"?`,{title:U?U.record_title||M(U.record_id):``})}),(0,j.jsx)(Ae,{children:b(`approveOneBody`,`This approves the request with your identity. To add a comment or attachment, open the request instead.`)})]}),(0,j.jsxs)(Oe,{children:[(0,j.jsx)(ye,{children:b(`cancel`,`Cancel`)}),(0,j.jsx)(Pe,{onClick:()=>void Jn(),children:b(`approve`,`Approve`)})]})]})}),(0,j.jsx)(De,{open:!!W,onOpenChange:e=>!e&&wn(null),children:(0,j.jsxs)(xe,{children:[(0,j.jsxs)(Ce,{children:[(0,j.jsx)(Se,{children:b(`rejectOneTitle`,`Reject "{{title}}"?`,{title:W?W.record_title||M(W.record_id):``})}),(0,j.jsx)(Ae,{children:b(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,j.jsxs)(Oe,{children:[(0,j.jsx)(ye,{children:b(`cancel`,`Cancel`)}),(0,j.jsx)(Pe,{onClick:()=>void Yn(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:b(`reject`,`Reject`)})]})]})}),(0,j.jsx)(Ee,{open:!!L,onOpenChange:e=>!e&&Nn(),children:(0,j.jsxs)(re,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,j.jsxs)(se,{children:[(0,j.jsx)(ce,{children:R?kt(R):b(`drawerTitle`,`Approval Request`)}),(0,j.jsx)(Te,{children:R?At(R)||It(R):``})]}),R&&X>=0&&Y.length>1&&(0,j.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,j.jsxs)(g,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X<=0,onClick:()=>{let e=Y[X-1];e&&q(e.id)},children:[(0,j.jsx)(Ue,{className:`h-4 w-4 mr-0.5`}),b(`prevRequest`,`Previous`)]}),(0,j.jsx)(`span`,{children:b(`positionOf`,`Request {{index}} of {{total}}`,{index:X+1,total:Y.length})}),(0,j.jsxs)(g,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X>=Y.length-1,onClick:()=>{let e=Y[X+1];e&&q(e.id)},children:[b(`nextRequest`,`Next`),(0,j.jsx)(We,{className:`h-4 w-4 ml-0.5`})]})]}),tn?(0,j.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,j.jsx)(u,{className:`h-6 w-3/4`}),(0,j.jsx)(u,{className:`h-6 w-1/2`}),(0,j.jsx)(u,{className:`h-20 w-full`})]}):R?(0,j.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,j.jsx)(Tt,{status:R.status,label:T(R.status)}),(R.round??1)>1&&(0,j.jsx)(p,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:b(`roundChip`,`Round {{n}}`,{n:R.round})}),(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:Ot(P(R),i),children:[(0,j.jsx)(Ye,{className:`h-3 w-3`}),b(`submittedAgo`,`Submitted {{when}}`,{when:w(P(R))})]}),R.completed_at&&(0,j.jsxs)(`span`,{children:[`· `,b(`completedAt`,`Completed {{when}}`,{when:w(R.completed_at)})]}),R.status===`pending`&&(()=>{let e=Bt(R.sla_due_at,x);return e?(0,j.jsx)(p,{variant:`outline`,className:f(`text-[10px]`,e.overdue?`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`:`border-border text-muted-foreground`),children:pt(e)}):null})()]}),(()=>{let e=Gt(R,sn,i),t=Ut(R.payload,i,R.payload_display,R.payload_labels,6,e?.key,sn);return(0,j.jsx)(Le,{children:(0,j.jsxs)(ie,{className:`p-4 space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[D(R)===null?on(R)===null?an.isUnreadable(R)?(0,j.jsx)(`div`,{className:`text-base font-semibold truncate`,children:R.record_title||M(R.record_id)}):(0,j.jsxs)(r,{to:ht(R),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:R.record_title||M(R.record_id)}),(0,j.jsx)(Ze,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}):(0,j.jsx)(Dt,{label:on(R),className:`text-base font-semibold`}):(0,j.jsx)(Et,{label:D(R),className:`text-base font-semibold`}),(0,j.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[It(R),D(R)!==null&&R.record_title&&(0,j.jsxs)(`span`,{className:`ml-1.5`,children:[`· `,R.record_title]})]})]}),(0,j.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,j.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:Ft(R)?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(st,{className:`h-3 w-3`}),(0,j.jsx)(`span`,{className:`italic`,children:b(`flowOrigin`,`Flow-initiated`)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ot,{className:`h-3 w-3`}),(0,j.jsx)(`span`,{title:R.submitter_id||``,children:jt(R)})]})})})]}),e&&(0,j.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,j.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e.label}),(0,j.jsx)(`div`,{className:`text-xl font-semibold tabular-nums`,title:e.display,children:e.display})]}),t.length>0&&(0,j.jsx)(`div`,{className:f(`grid grid-cols-2 gap-x-4 gap-y-2 text-sm`,!e&&`border-t pt-3`),children:t.map(([e,t])=>(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,j.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),R.decision_progress&&(()=>{let e=R.decision_progress,t=(R.pending_approvers||[]).length;return(0,j.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 mb-1.5`,children:[(0,j.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.behavior===`per_group`?b(`progressGroups`,`Sign-off progress — {{got}} of {{need}} groups`,{got:e.got,need:e.need}):b(`progressApprovals`,`Approvals — {{got}} of {{need}}`,{got:e.got,need:e.need})}),e.behavior!==`per_group`&&R.status===`pending`&&t>0&&(0,j.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:b(`progressEligible`,`{{count}} eligible approver(s)`,{count:t})})]}),(0,j.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":e.need,"aria-valuenow":Math.min(e.got,e.need),"aria-label":b(`progressBar`,`Decision progress`),className:`flex gap-1`,children:e.need>0&&e.need<=12?Array.from({length:e.need}).map((t,n)=>(0,j.jsx)(`div`,{className:f(`h-1.5 flex-1 rounded-full`,n<e.got?`bg-emerald-500`:`bg-muted`)},n)):(0,j.jsx)(`div`,{className:`h-1.5 flex-1 rounded-full bg-muted overflow-hidden`,children:(0,j.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${e.need>0?Math.min(100,e.got/e.need*100):0}%`}})})}),e.groups&&(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.groups.map(e=>(0,j.jsxs)(p,{variant:`outline`,className:f(`text-[11px] gap-1`,e.satisfied?`border-emerald-300 text-emerald-700 dark:border-emerald-700 dark:text-emerald-400`:`text-muted-foreground`),title:`${e.got}/${e.need}`,children:[e.satisfied?(0,j.jsx)(He,{className:`h-3 w-3`}):(0,j.jsx)(Je,{className:`h-2.5 w-2.5`}),e.group,` `,e.got,`/`,e.need]},e.group))})]})})(),R.status===`pending`&&(R.pending_approvers||[]).length>0&&(0,j.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,j.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:b(`waitingOn`,`Waiting on`)}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Pt(R).map((e,t)=>(0,j.jsxs)(p,{variant:`outline`,className:`text-[11px]`,title:e.title,children:[e.label,e.group&&(0,j.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`· `,e.group]}),e.count>1&&(0,j.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.count]})]},`${e.label}-${e.group??``}-${t}`))})]})]})})})(),(R.flow_steps?.length??0)>1&&(0,j.jsx)(`ol`,{className:`flex flex-col px-1`,"aria-label":b(`stepProgress`,`Approval steps`),children:R.flow_steps.map((e,t,n)=>{let r=n[t+1];return(0,j.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col items-center self-stretch`,children:[(0,j.jsx)(`span`,{className:f(`flex items-center justify-center h-5 w-5 shrink-0 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,j.jsx)(He,{className:`h-3 w-3`}):t+1}),r&&(0,j.jsx)(`div`,{className:f(`w-px flex-1 min-h-3 my-1`,r.state===`done`||r.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)})]}),(0,j.jsx)(`span`,{className:f(`min-w-0 flex-1 pt-0.5 text-xs break-words`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]},e.id)})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:b(`history`,`Activity`)}),$t.length===0?(0,j.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:b(`noActions`,`No actions yet.`)}):(0,j.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:$t.map(e=>{let t=ut(e),n=t?`bg-amber-500`:e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:e.action===`reassign`?`bg-indigo-500`:e.action===`remind`||e.action===`request_info`?`bg-amber-500`:e.action===`comment`?`bg-slate-400`:e.action===`escalate`?`bg-red-500`:e.action===`revise`?`bg-violet-500`:e.action===`resubmit`?`bg-blue-500`:`bg-muted-foreground`,r=e.actor_id===`system:sla`?b(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===R.submitter_id?jt(R):M(e.actor_id)),a=e.action===`submit`?b(`actSubmit`,`Submitted`):e.action===`approve`?b(`actApprove`,`Approved`):e.action===`reject`?b(`actReject`,`Rejected`):e.action===`recall`?b(`actRecall`,`Recalled`):e.action===`reassign`?b(`actReassign`,`Reassigned`):e.action===`remind`?b(`actRemind`,`Reminder sent`):e.action===`request_info`?b(`actRequestInfo`,`Requested more info`):e.action===`comment`?b(`actComment`,`Commented`):e.action===`escalate`?b(`actEscalate`,`SLA escalated`):e.action===`revise`?b(`actRevise`,`Sent back for revision`):e.action===`resubmit`?b(`actResubmit`,`Resubmitted`):e.action;return(0,j.jsxs)(`li`,{className:`relative text-xs`,children:[(0,j.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${n}`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,j.jsx)(`span`,{className:`font-medium`,children:a}),(0,j.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,j.jsx)(`span`,{title:e.actor_id||``,children:r}),t&&(0,j.jsxs)(p,{variant:`outline`,className:`gap-1 border-amber-500/60 px-1.5 py-0 text-[10px] font-medium text-amber-700 dark:text-amber-400`,title:b(`viaOverrideHint`,`The actor held no approver slot on this step — admitted by the admin-override path.`),"data-testid":`via-override-chip`,children:[(0,j.jsx)(rt,{className:`h-3 w-3`,"aria-hidden":!0}),b(`viaOverrideChip`,`Admin override`)]}),(0,j.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:Ot(e.created_at,i),children:w(e.created_at)})]}),(()=>{let t=e;return e.action!==`reassign`||!t.reassign_from&&!t.reassign_to?null:(0,j.jsx)(`div`,{className:`text-muted-foreground mt-0.5`,children:b(`reassignFromTo`,`from {{from}} to {{to}}`,{from:t.reassign_from_name??M(t.reassign_from),to:t.reassign_to_name??M(t.reassign_to)})})})(),e.comment&&(0,j.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]}),Array.isArray(e.attachments)&&e.attachments.length>0&&(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((t,n)=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>void ln(t),className:`inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:t.name||t.id,children:[(0,j.jsx)($e,{className:`h-3 w-3`}),t.name||`${b(`attachmentChip`,`Attachment`)}${e.attachments.length>1?` ${n+1}`:``}`]},t.id||n))})]},e.id)})}),R.status===`pending`&&(Ln||Rn)&&(0,j.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,j.jsx)(je,{value:G,onChange:e=>Dn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&G.trim()&&(e.preventDefault(),In())},placeholder:b(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,j.jsx)(g,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!G.trim()||On,onClick:()=>void In(),children:(0,j.jsx)(nt,{className:`h-3.5 w-3.5`})})]})]}),at&&R.payload!=null&&(0,j.jsxs)(`details`,{className:`group`,children:[(0,j.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:b(`rawData`,`Raw data (JSON)`)}),(0,j.jsxs)(`div`,{className:`mt-2`,children:[(0,j.jsx)(`div`,{className:`flex justify-end`,children:(0,j.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(R.payload,null,2)),v.success(b(`copied`,`Copied`))}catch{v.error(b(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,j.jsx)(Xe,{className:`h-3 w-3`}),b(`copy`,`Copy`)]})}),(0,j.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(R.payload,null,2)})]})]}),R.status===`pending`&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ue,{}),(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsx)(lt,{objectName:`sys_approval_request`,record:R,location:`record_section`,label:b(`declaredActions`,`Actions`),onDone:()=>{Fn()}}),!Ln&&(0,j.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Rn?b(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):b(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(R.pending_approvers||[]).map(e=>Mt(e,R)).join(`, `)||`—`})})]})]}),zn&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ue,{}),(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:b(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,j.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,j.jsx)(g,{asChild:!0,size:`sm`,variant:`outline`,children:(0,j.jsxs)(r,{to:ht(R),children:[(0,j.jsx)(Ze,{className:`h-4 w-4 mr-1`}),b(`editRecordBtn`,`Edit record`)]})}),(0,j.jsx)(lt,{objectName:`sys_approval_request`,record:R,location:`record_section`,onDone:()=>{Pn(R.id),K()}})]})]})]})]}):null]})})]})}export{Yt as ApprovalsInboxPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t,v as n}from"./vendor-react-BggL7APJ.js";import{An as r,Br as i,Dn as a,Fn as o,In as ee,Ln as s,Mn as te,Nn as c,Ot as l,Pn as u,Rn as ne,Tt as re,Zn as d,an as f,en as p,in as ie,jn as ae,kn as oe,ni as m,nn as h,oi as se,qn as g,rn as _,si as ce,tn as v,vi as y,wt as le,zn as ue,zr as b}from"./ui-components-BTB1NkUW.js";import{t as de}from"./i18n-runtime-CTgAQF4N.js";import{t as fe}from"./vendor-icon-circle-alert-D1XTr_X9.js";import{t as x}from"./vendor-icon-refresh-cw-BGjSPEfJ.js";import{t as S}from"./vendor-icon-scroll-text-DENjQLzo.js";import{t as C}from"./vendor-icon-search-B2Uqtp_W.js";import{t as w}from"./vendor-icon-x-CcLtgRNL.js";var T=e(n(),1),pe=[`create`,`update`,`delete`,`login`,`logout`,`config_change`,`import`],E={create:`default`,update:`secondary`,delete:`destructive`,login:`outline`,logout:`outline`,config_change:`secondary`,import:`outline`},D=t(),me=`${``.replace(/\/$/,``)}/api/v1`,O=50;function k(e,t){if(!e)return`—`;try{return new Date(e).toLocaleString(t)}catch{return e}}function A(e,t=24){return e?e.length>t?`${e.slice(0,t-1)}…`:e:`—`}function j(e){if(!e)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function M(){let e=de(),[t,n]=(0,T.useState)([]),[M,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(`all`),[R,z]=(0,T.useState)(``),[B,V]=(0,T.useState)(``),[H,U]=(0,T.useState)(``),[W,G]=(0,T.useState)(``),[K,q]=(0,T.useState)(0),[J,Y]=(0,T.useState)(!1),[X,Z]=(0,T.useState)(null),Q=(0,T.useCallback)(async()=>{N(!0),F(null);try{let e={};I&&I!==`all`&&(e.action=I),R.trim()&&(e.object_name=R.trim()),B.trim()&&(e.user_id=B.trim()),H&&(e.created_at={...e.created_at||{},$gte:H}),W&&(e.created_at={...e.created_at||{},$lte:`${W}T23:59:59`});let t=new URLSearchParams;Object.keys(e).length>0&&t.set(`$filter`,JSON.stringify(e)),t.set(`$orderby`,`created_at desc`),t.set(`$top`,`51`),t.set(`$skip`,String(K*O));let r=await fetch(`${me}/data/sys_audit_log?${t.toString()}`,{credentials:`include`});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`HTTP ${r.status}: ${e.slice(0,200)||r.statusText}`)}let i=await r.json(),a=Array.isArray(i)?i:Array.isArray(i?.records)?i.records:Array.isArray(i?.data)?i.data:[];Y(a.length>O),n(a.slice(0,O))}catch(e){console.warn(`[AuditLogPage] load failed:`,e),F(e?.message||`Failed to load audit log`),n([]),Y(!1)}finally{N(!1)}},[I,R,B,H,W,K]);(0,T.useEffect)(()=>{Q()},[Q]);let he=(0,T.useCallback)(()=>{L(`all`),z(``),V(``),U(``),G(``),q(0)},[]),$=(0,T.useMemo)(()=>{let e=0;return I!==`all`&&(e+=1),R.trim()&&(e+=1),B.trim()&&(e+=1),H&&(e+=1),W&&(e+=1),e},[I,R,B,H,W]);return(0,D.jsxs)(`div`,{className:`p-6 space-y-4 max-w-screen-2xl mx-auto`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(S,{className:`h-6 w-6 text-muted-foreground`}),(0,D.jsxs)(`div`,{className:`flex-1`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Audit Log`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Read-only system activity and record changes. Newest first.`})]}),(0,D.jsxs)(y,{variant:`outline`,size:`sm`,onClick:Q,disabled:M,children:[(0,D.jsx)(x,{className:`h-4 w-4 mr-1 ${M?`animate-spin`:``}`}),`Refresh`]})]}),(0,D.jsx)(b,{children:(0,D.jsxs)(i,{className:`p-4 grid grid-cols-1 md:grid-cols-5 gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(d,{className:`text-xs`,children:`Action`}),(0,D.jsxs)(o,{value:I,onValueChange:e=>{L(e),q(0)},children:[(0,D.jsx)(ne,{className:`h-9`,children:(0,D.jsx)(ue,{})}),(0,D.jsxs)(ee,{children:[(0,D.jsx)(s,{value:`all`,children:`All actions`}),pe.map(e=>(0,D.jsx)(s,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(d,{className:`text-xs`,children:`Object`}),(0,D.jsx)(g,{placeholder:`e.g. account`,value:R,onChange:e=>{z(e.target.value),q(0)},className:`h-9`})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(d,{className:`text-xs`,children:`Actor (user id)`}),(0,D.jsx)(g,{placeholder:`user id`,value:B,onChange:e=>{V(e.target.value),q(0)},className:`h-9`})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(d,{className:`text-xs`,children:`From`}),(0,D.jsx)(g,{type:`date`,value:H,onChange:e=>{U(e.target.value),q(0)},className:`h-9`})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(d,{className:`text-xs`,children:`To`}),(0,D.jsx)(g,{type:`date`,value:W,onChange:e=>{G(e.target.value),q(0)},className:`h-9`})]}),$>0&&(0,D.jsx)(`div`,{className:`md:col-span-5 flex justify-end`,children:(0,D.jsxs)(y,{variant:`ghost`,size:`sm`,onClick:he,children:[(0,D.jsx)(w,{className:`h-4 w-4 mr-1`}),`Clear filters (`,$,`)`]})})]})}),P&&(0,D.jsxs)(se,{variant:`destructive`,children:[(0,D.jsx)(fe,{className:`h-4 w-4`}),(0,D.jsx)(ce,{children:P})]}),(0,D.jsx)(b,{children:(0,D.jsx)(i,{className:`p-0`,children:M&&t.length===0?(0,D.jsx)(`div`,{className:`p-6 space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,D.jsx)(a,{className:`h-9 w-full`},t))}):t.length===0?(0,D.jsx)(`div`,{className:`p-12`,children:(0,D.jsxs)(le,{children:[(0,D.jsx)(C,{className:`h-8 w-8 text-muted-foreground mb-3`}),(0,D.jsx)(l,{children:`No audit entries`}),(0,D.jsx)(re,{children:$>0?`Try clearing filters or widening the date range.`:`Events will appear here once tracked objects are modified.`})]})}):(0,D.jsxs)(p,{children:[(0,D.jsx)(ie,{children:(0,D.jsxs)(f,{children:[(0,D.jsx)(_,{className:`w-[180px]`,children:`Timestamp`}),(0,D.jsx)(_,{className:`w-[130px]`,children:`Action`}),(0,D.jsx)(_,{children:`Object`}),(0,D.jsx)(_,{children:`Record`}),(0,D.jsx)(_,{children:`Actor`}),(0,D.jsx)(_,{className:`w-[130px]`,children:`IP`})]})}),(0,D.jsx)(v,{children:t.map(t=>{let n=E[t.action||``]||`outline`;return(0,D.jsxs)(f,{className:`cursor-pointer`,onClick:()=>Z(t),children:[(0,D.jsx)(h,{className:`font-mono text-xs`,children:k(t.created_at,e)}),(0,D.jsx)(h,{children:(0,D.jsx)(m,{variant:n,children:t.action||`—`})}),(0,D.jsx)(h,{children:t.object_name||`—`}),(0,D.jsx)(h,{className:`font-mono text-xs`,children:A(t.record_id,18)}),(0,D.jsx)(h,{className:`font-mono text-xs`,children:A(t.user_id,18)}),(0,D.jsx)(h,{className:`font-mono text-xs`,children:t.ip_address||`—`})]},t.id)})})]})})}),(t.length>0||K>0)&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-sm text-muted-foreground`,children:[(0,D.jsxs)(`span`,{children:[`Page `,K+1,J?``:` · end`]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(y,{variant:`outline`,size:`sm`,disabled:K===0||M,onClick:()=>q(e=>Math.max(0,e-1)),children:`Previous`}),(0,D.jsx)(y,{variant:`outline`,size:`sm`,disabled:!J||M,onClick:()=>q(e=>e+1),children:`Next`})]})]}),(0,D.jsx)(oe,{open:!!X,onOpenChange:e=>!e&&Z(null),children:(0,D.jsxs)(r,{side:`right`,className:`sm:max-w-2xl w-full overflow-y-auto`,children:[(0,D.jsxs)(te,{children:[(0,D.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,D.jsx)(m,{variant:X&&E[X.action||``]||`outline`,children:X?.action||`—`}),X?.object_name||`Audit Event`]}),(0,D.jsx)(ae,{children:X?.id?(0,D.jsx)(`span`,{className:`font-mono text-xs`,children:X.id}):null})]}),X&&(0,D.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Timestamp`}),(0,D.jsx)(`div`,{className:`font-mono`,children:k(X.created_at,e)})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`IP Address`}),(0,D.jsx)(`div`,{className:`font-mono`,children:X.ip_address||`—`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Actor (user_id)`}),(0,D.jsx)(`div`,{className:`font-mono break-all`,children:X.user_id||`—`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Tenant`}),(0,D.jsx)(`div`,{className:`font-mono break-all`,children:X.tenant_id||`—`})]}),(0,D.jsxs)(`div`,{className:`col-span-2`,children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Target record`}),(0,D.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[X.object_name||`—`,` / `,X.record_id||`—`]})]}),X.user_agent&&(0,D.jsxs)(`div`,{className:`col-span-2`,children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`User Agent`}),(0,D.jsx)(`div`,{className:`font-mono text-xs break-all`,children:X.user_agent})]})]}),(X.old_value||X.new_value)&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(u,{}),(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(`div`,{className:`text-sm font-medium`,children:`Change payload`}),X.old_value&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Before`}),(0,D.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:j(X.old_value)})]}),X.new_value&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`After`}),(0,D.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:j(X.new_value)})]})]})]}),X.metadata&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(u,{}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,D.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-48 overflow-auto`,children:j(X.metadata)})]})]})]})]})})]})}export{M as AuditLogPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{p as t,t as n,v as r}from"./vendor-react-BggL7APJ.js";import{Dn as i,Ot as a,Tt as o,wt as s}from"./ui-components-BTB1NkUW.js";import{G as c,K as l,L as u}from"./framework-DcWkeiND.js";import{f as d,w as f}from"./i18n-runtime-CTgAQF4N.js";import{r as p}from"./vendor-ui-utils-DIUdEYii.js";import{t as m}from"./vendor-icon-layout-dashboard-wba2hvZp.js";import{a as h}from"./ExpressionProvider-DZfMwyMs.js";import{t as g}from"./useActionModal-CSvbHkQ7.js";import{t as _}from"./preferLocal-DEJV3KIq.js";import{n as v}from"./utils-MjUhYVsx.js";import{n as y,t as b}from"./MetadataInspector-BWxLkr0O.js";import{n as x}from"./plugin-dashboard-C1AYKmGX.js";import{t as S}from"./useOpenRecordList-B5-qaFUx.js";var C=n();function w({cards:e=6}){return(0,C.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(i,{className:`h-7 w-56`}),(0,C.jsx)(i,{className:`h-4 w-80`})]}),(0,C.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:Array.from({length:4}).map((e,t)=>(0,C.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-2`,children:[(0,C.jsx)(i,{className:`h-4 w-20`}),(0,C.jsx)(i,{className:`h-8 w-24`}),(0,C.jsx)(i,{className:`h-3 w-16`})]},`stat-${t}`))}),(0,C.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:e}).map((e,t)=>(0,C.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsx)(i,{className:`h-5 w-32`}),(0,C.jsx)(i,{className:`h-5 w-5 rounded-full`})]}),(0,C.jsx)(i,{className:`h-40 w-full`}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(i,{className:`h-3 w-16`}),(0,C.jsx)(i,{className:`h-3 w-12`})]})]},`widget-${t}`))})]})}var T=e(r(),1);function E({dataSource:e}){let n=S(),{dashboardName:r}=t(),{showDebug:i}=y(),E=c(),{t:D}=f(),{dashboardLabel:O,dashboardDescription:k}=d(),[A,j]=(0,T.useState)(!0),{modalHandler:M,modalElement:N}=g(E),P=(0,T.useMemo)(()=>({export_dashboard_pdf:async()=>{p.info(D(`dashboardActions.printDialogOpening`));try{return window.print(),{success:!0}}catch(e){return p.error(D(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(p.info(D(`dashboardActions.forecastSoon`)),{success:!0})}),[D]);(0,T.useEffect)(()=>{j(!0),queueMicrotask(()=>j(!1))},[r]);let{dashboards:F,objects:I}=l(),{app:L}=h(),R=_(F,r,L?._packageId),z=(0,T.useMemo)(()=>new Set((I||[]).map(e=>e?.name).filter(Boolean)),[I]),B=(0,T.useMemo)(()=>{if(!R||z.size===0)return R;let e=R.widgets;if(!Array.isArray(e)||e.length===0)return R;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return!t||z.has(t)});return t.length===e.length?R:{...R,widgets:t}},[R,z]);return A?(0,C.jsx)(w,{}):R?(0,C.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,C.jsx)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=v(R.label,D),t=O({name:R.name,label:e})||R.name;return(0,C.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:t})})(),(()=>{let e=(B||R).description??R.description,t=k({name:R.name,description:v(e,D)});return t?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]})}),(0,C.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,C.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,C.jsx)(u,{value:{openRecordList:n},children:(0,C.jsx)(x,{schema:B,dataSource:e,modalHandler:M,scriptHandlers:P,hideHeaderText:!0})})}),(0,C.jsx)(b,{open:i,sections:[{title:`Dashboard Configuration`,data:B}]})]}),N]}):(0,C.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,C.jsxs)(s,{children:[(0,C.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,C.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,C.jsx)(a,{children:D(`empty.dashboardNotFound`)}),(0,C.jsx)(o,{children:D(`empty.dashboardNotFoundDescription`,{name:r})})]})})}export{E as DashboardView};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{d as t,p as n,r,t as i,v as a}from"./vendor-react-BggL7APJ.js";import{G as o}from"./framework-DcWkeiND.js";import{w as s}from"./i18n-runtime-CTgAQF4N.js";import{t as c}from"./vendor-icon-chevron-down-BEf_jTEE.js";import{t as l}from"./vendor-icon-circle-alert-D1XTr_X9.js";import{t as u}from"./vendor-icon-external-link-SBKz5x6R.js";import{t as d}from"./vendor-icon-file-question-mark-CDRVvH3W.js";import{t as f}from"./vendor-icon-loader-circle-D3PsuVaD.js";import{t as p}from"./vendor-icon-menu-9YHQR0RT.js";import"./src-B8lv0plz.js";import{t as m}from"./DocShell-Bzl3QS30.js";import{i as h,l as g,n as _,u as v}from"./use-book-data-C3eyZJSG.js";import{r as y,t as b}from"./plugin-markdown-D1nTQc1T.js";var x=e(a(),1),S=/(^```[^\n]*\n[\s\S]*?\n```[ \t]*$|^~~~[^\n]*\n[\s\S]*?\n~~~[ \t]*$)/m,C=/(`[^`\n]+`)/,w=/\]\((?:\.\/)?([a-z][a-z0-9_]*)\.md(#[^)\s]*)?\)/g;function T(e){return e.split(C).map((e,t)=>t%2==1?e:e.replace(w,`](/docs/$1$2)`)).join(``)}function E(e){let t=[],n=e;for(;;){let e=S.exec(n);if(!e||e.index===void 0)return t.push(T(n)),t.join(``);t.push(T(n.slice(0,e.index)),e[0]),n=n.slice(e.index+e[0].length)}}var D=i();function O({book:e,activeDoc:t,docHref:n}){return(0,D.jsxs)(`nav`,{"aria-label":e.label??e.name,className:`text-sm`,children:[e.label?(0,D.jsx)(`div`,{className:`mb-3 px-2 text-sm font-semibold text-foreground`,children:e.label}):null,(0,D.jsx)(`div`,{className:`space-y-5`,children:e.groups.map(e=>(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`mb-1 px-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,D.jsx)(`ul`,{className:`space-y-0.5`,children:e.entries.map((e,i)=>{if(e.separator)return(0,D.jsx)(`li`,{className:`my-1.5 border-t border-border/60`,"aria-hidden":!0},`sep-${i}`);if(e.href)return(0,D.jsx)(`li`,{children:(0,D.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1.5 rounded px-2 py-1 text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,D.jsx)(`span`,{className:`truncate`,children:e.label??e.href}),(0,D.jsx)(u,{className:`h-3 w-3 shrink-0 opacity-60`})]})},`ext-${i}`);if(!e.doc)return null;let a=e.doc===t;return(0,D.jsx)(`li`,{children:(0,D.jsx)(r,{to:n(e.doc),"aria-current":a?`page`:void 0,className:`block truncate rounded px-2 py-1 transition ${a?`bg-primary/10 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:e.label??e.doc})},e.doc)})})]},e.key))})]})}function k(){let{slug:e,name:r,appName:i}=n(),a=t(),u=o(),{t:S}=s(),[C,w]=(0,x.useState)(null),[T,k]=(0,x.useState)(`loading`),[A,j]=(0,x.useState)(``);(0,x.useEffect)(()=>{let e=!1;async function t(){if(r&&u){k(`loading`);try{let t=await u.getClient().meta.getItem(`doc`,r,i?{packageId:i}:void 0),n=t?.item??t?.data??t;if(e)return;n&&typeof n.content==`string`?(w({name:r,label:n.label,content:n.content}),k(`ready`)):k(`missing`)}catch(t){if(e)return;(t?.status??t?.response?.status)===404||/not found/i.test(t?.message??``)?k(`missing`):(j(t?.message??`Failed to load documentation`),k(`error`))}}}return t(),()=>{e=!0}},[r,i,u]);let M=(0,x.useCallback)(e=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}#${e}`)},[]),N=(0,x.useCallback)(e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;let t=e.target.closest(`a`)?.getAttribute(`href`);t&&(t.startsWith(`/docs/`)?(e.preventDefault(),a(t)):t.startsWith(`#`)&&(e.preventDefault(),M(decodeURIComponent(t.slice(1)))))},[a,M]),P=(0,x.useCallback)((e,t)=>{e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||(e.preventDefault(),M(t))},[M]),F=(0,x.useMemo)(()=>y(C?.content??``),[C?.content]),I=S(`help.onThisPage`,{defaultValue:`On this page`}),{books:L,docs:R}=_(),z=i?`/apps/${i}/docs`:`/docs`,B=(0,x.useMemo)(()=>{let t=L.find(t=>h(t)===e);return t?g(t,v(t,R)):null},[L,R,e]),V=(0,x.useCallback)(t=>`${z}/${e}/${t}`,[z,e]);return T===`loading`?(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,D.jsx)(f,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):T===`missing`?(0,D.jsx)(m,{breadcrumb:r,children:(0,D.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,D.jsx)(d,{className:`h-10 w-10 text-muted-foreground`}),(0,D.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Documentation not found`}),(0,D.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No document named `,(0,D.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:r}),` is installed. It may belong to a package that is not installed, or it was removed in a newer version.`]})]})}):T===`error`?(0,D.jsx)(m,{breadcrumb:r,children:(0,D.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,D.jsx)(l,{className:`h-10 w-10 text-destructive`}),(0,D.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Failed to load documentation`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:A})]})}):(0,D.jsxs)(m,{breadcrumb:C?.label??r,children:[B?(0,D.jsxs)(`details`,{className:`group mx-auto max-w-6xl px-4 pt-4 sm:px-6 lg:hidden`,children:[(0,D.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm font-medium [&::-webkit-details-marker]:hidden`,children:[(0,D.jsx)(p,{className:`h-4 w-4 text-muted-foreground`}),(0,D.jsx)(`span`,{className:`truncate`,children:B.label??`Contents`}),(0,D.jsx)(c,{className:`ml-auto h-4 w-4 text-muted-foreground transition-transform group-open:rotate-180`})]}),(0,D.jsx)(`div`,{className:`mt-2 rounded-md border p-3`,children:(0,D.jsx)(O,{book:B,activeDoc:r,docHref:V})})]}):null,(0,D.jsxs)(`div`,{className:`mx-auto flex gap-8 p-4 sm:p-6 ${B?`max-w-6xl`:`max-w-5xl`}`,children:[B?(0,D.jsx)(`aside`,{className:`hidden w-56 shrink-0 lg:block`,children:(0,D.jsx)(`nav`,{className:`sticky top-20 max-h-[calc(100vh-6rem)] overflow-auto pr-1`,children:(0,D.jsx)(O,{book:B,activeDoc:r,docHref:V})})}):null,(0,D.jsx)(`article`,{className:`min-w-0 max-w-3xl flex-1 [&_h1]:scroll-mt-24 [&_h2]:scroll-mt-24 [&_h3]:scroll-mt-24`,onClick:N,children:(0,D.jsx)(b,{schema:{type:`markdown`,content:E(C?.content??``)}})}),F.length>=3?(0,D.jsx)(`aside`,{className:`hidden xl:block w-56 shrink-0`,children:(0,D.jsxs)(`nav`,{"aria-label":I,className:`sticky top-20 max-h-[calc(100vh-6rem)] overflow-auto`,children:[(0,D.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:I}),(0,D.jsx)(`ul`,{className:`border-l border-border text-sm`,children:F.map(e=>(0,D.jsx)(`li`,{style:{paddingLeft:(e.depth-2)*12},children:(0,D.jsx)(`a`,{href:`#${e.id}`,onClick:t=>P(t,e.id),className:`-ml-px block border-l border-transparent py-0.5 pl-3 text-muted-foreground hover:border-primary hover:text-foreground`,children:e.text})},e.id))})]})}):null]})]})}export{k as default};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,p as n,t as r,v as i}from"./vendor-react-BggL7APJ.js";import{t as a}from"./vendor-icon-book-open-DKPXYwQK.js";import{t as o}from"./vendor-icon-file-question-mark-CDRVvH3W.js";import{t as s}from"./vendor-icon-loader-circle-D3PsuVaD.js";import{t as c}from"./DocShell-Bzl3QS30.js";import{i as l,l as u,n as d,o as f,s as p,u as m}from"./use-book-data-C3eyZJSG.js";var h=e(i(),1),g=r();function _(){let{slug:e,appName:r}=n(),{books:i,docs:p,state:_}=d(),v=(0,h.useMemo)(()=>i.find(t=>l(t)===e),[i,e]),y=(0,h.useMemo)(()=>v?f(u(v,m(v,p))):void 0,[v,p]);if(_===`loading`)return(0,g.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,g.jsx)(s,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})});if(v&&y){let n=r?`/apps/${r}/docs`:`/docs`;return(0,g.jsx)(t,{to:`${n}/${e}/${y}`,replace:!0})}return(0,g.jsx)(c,{breadcrumb:v?v.label??e:e,children:(0,g.jsx)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:v?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(a,{className:`h-10 w-10 text-muted-foreground`}),(0,g.jsx)(`h1`,{className:`text-lg font-semibold`,children:v.label??e}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This book has no documents yet.`})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o,{className:`h-10 w-10 text-muted-foreground`}),(0,g.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Book not found`}),(0,g.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No book named `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:e}),` is installed.`]})]})})})}function v(){let{slug:e,appName:r}=n(),{books:i,docs:a,state:u}=d();if(u===`loading`)return(0,g.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,g.jsx)(s,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})});if(e&&i.some(t=>l(t)===e))return(0,g.jsx)(_,{});let f=r?`/apps/${r}/docs`:`/docs`,m=e?p(e,i,a):null;return m&&e?(0,g.jsx)(t,{to:`${f}/${l(m)}/${e}`,replace:!0}):(0,g.jsx)(c,{breadcrumb:e,children:(0,g.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,g.jsx)(o,{className:`h-10 w-10 text-muted-foreground`}),(0,g.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Documentation not found`}),(0,g.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No book or document named `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:e}),` is installed.`]})]})})}export{v as default};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t,v as n}from"./vendor-react-BggL7APJ.js";import{gt as r,jt as i,wr as a}from"./framework-DcWkeiND.js";var o=e(n(),1),s=t(),c=(0,o.createContext)(null);function l({user:e={},features:t={}}={}){return{current_user:e,user:e,ctx:{user:e},os:{user:e},features:t}}function u(e={}){return new a(l(e))}function d({children:e,user:t={},app:n={},data:r={},features:a={}}){let d=(0,o.useMemo)(()=>({user:t,app:n,data:r,features:a,evaluator:u({user:t,features:a})}),[t,n,r,a]),f=(0,o.useMemo)(()=>l({user:t,features:a}),[t,a]);return(0,s.jsx)(c.Provider,{value:d,children:(0,s.jsx)(i,{scope:f,children:e})})}function f(){let e=(0,o.useContext)(c);if(!e){let e={user:{},features:{}};return{...e,app:{},data:{},evaluator:u(e)}}return e}var p=`app-shell:visible`;function m(e,t,n=`visible`){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;let i=t=>r(p,void 0,n,e,t,`app-shell`);try{return t.evaluateCondition(e,{onFault:i})}catch(e){return i(e),!0}}function h(e,t){return e?.hidden!==!0&&m(e?.visibleWhen,t,`visibleWhen`)}export{f as a,h as i,u as n,m as r,d as t};
@@ -1,4 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{d as n,p as r,t as i,v as a}from"./vendor-react-BggL7APJ.js";import{f as ee}from"./infrastructure-BHSync5f.js";import{$n as te,Ar as ne,Br as re,Dn as o,Fn as ie,Hr as ae,In as oe,Ln as se,Mr as ce,Nr as le,Pr as ue,Qn as de,Rn as fe,Rr as s,Ur as pe,Zn as c,jr as me,kr as he,ni as l,sr as ge,tr as u,vi as d,zn as _e,zr as ve}from"./ui-components-BTB1NkUW.js";import{K as ye,Wr as f}from"./framework-DcWkeiND.js";import{t as be,w as xe}from"./i18n-runtime-CTgAQF4N.js";import{t as Se}from"./vendor-icon-arrow-left-DmGEbpkA.js";import{t as Ce}from"./vendor-icon-boxes-D-Ov3dJw.js";import{t as p}from"./vendor-icon-circle-alert-D1XTr_X9.js";import{t as we}from"./vendor-icon-circle-arrow-up-bx9jlxK3.js";import{t as m}from"./vendor-icon-circle-check-Bq3OcFQN.js";import{t as h}from"./vendor-icon-code-xml-C9EWHSC8.js";import{t as Te}from"./vendor-icon-database-C8JGjSkn.js";import{t as Ee}from"./vendor-icon-download-C3csYSaD.js";import{t as De}from"./vendor-icon-ellipsis-BjiiCS3N.js";import{t as Oe}from"./vendor-icon-external-link-SBKz5x6R.js";import{t as g}from"./vendor-icon-folder-tree-BQ1wv9bt.js";import{t as _}from"./vendor-icon-loader-circle-D3PsuVaD.js";import{t as ke}from"./vendor-icon-network-6ADGC5P5.js";import{t as Ae}from"./vendor-icon-package-B6zAlWd3.js";import{t as v}from"./vendor-icon-shield-alert-CJYtPI9w.js";import{t as y}from"./vendor-icon-shield-check-CdDzbial.js";import{t as b}from"./vendor-icon-trash-BLsWkwB9.js";import{t as x}from"./vendor-icon-webhook-B43SyK1w.js";import{t as je}from"./assistantBus-DoNtw1Tf.js";import{M as Me,_ as Ne,a as S,c as Pe,f as Fe,g as Ie,h as Le,i as Re,k as C,l as ze,n as Be,o as Ve,r as He,s as Ue,u as We,v as Ge,y as Ke}from"./app-shell-eager-leaves-CDVclng4.js";import{i as qe,n as Je,r as Ye,t as Xe}from"./usePackageL10n-CMx66am-.js";var w=e(a(),1),T=i();function E(e){let t=e.replace(/\r\n/g,`
2
- `).split(`
3
- `),n=[],r=0;for(;r<t.length;){let e=t[r];if(e.startsWith("```")){let i=e.slice(3).trim();r++;let a=[];for(;r<t.length&&!t[r].startsWith("```");)a.push(t[r]),r++;r++,n.push({type:`code`,text:a.join(`
4
- `),lang:i});continue}let i=/^(#{1,3})\s+(.*)$/.exec(e);if(i){let e=i[1].length;n.push({type:`h${e}`,text:i[2].trim()}),r++;continue}if(/^[-*]\s+/.test(e)){let e=[];for(;r<t.length&&/^[-*]\s+/.test(t[r]);)e.push(t[r].replace(/^[-*]\s+/,``)),r++;n.push({type:`ul`,items:e});continue}if(/^\d+\.\s+/.test(e)){let e=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r]);)e.push(t[r].replace(/^\d+\.\s+/,``)),r++;n.push({type:`ol`,items:e});continue}if(!e.trim()){r++;continue}let a=[];for(;r<t.length&&t[r].trim()&&!/^#{1,3}\s+/.test(t[r])&&!/^[-*]\s+/.test(t[r])&&!/^\d+\.\s+/.test(t[r])&&!t[r].startsWith("```");)a.push(t[r]),r++;n.push({type:`p`,text:a.join(` `)})}return n}function D(e){let t=[],n=e,r=0,i=[{re:/`([^`]+)`/,render:e=>(0,T.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[0.85em]`,children:e[1]},`k${r++}`)},{re:/\*\*([^*]+)\*\*/,render:e=>(0,T.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,T.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,T.jsx)(`a`,{href:e[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-violet-600 underline-offset-2 hover:underline dark:text-violet-400`,children:e[1]},`k${r++}`)}];for(;n;){let e=-1,r=null,a=null;for(let t of i){let i=t.re.exec(n);i&&(e===-1||i.index<e)&&(e=i.index,r=i,a=t)}if(!r||!a){t.push(n);break}e>0&&t.push(n.slice(0,e)),t.push(a.render(r)),n=n.slice(e+r[0].length)}return(0,T.jsx)(T.Fragment,{children:t.map((e,t)=>(0,T.jsx)(w.Fragment,{children:e},t))})}function Ze({source:e,className:t}){let n=E(e);return(0,T.jsx)(`div`,{className:`flex flex-col gap-4 text-sm leading-relaxed text-foreground/90 ${t??``}`,children:n.map((e,t)=>{switch(e.type){case`h1`:return(0,T.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:D(e.text??``)},t);case`h2`:return(0,T.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:D(e.text??``)},t);case`h3`:return(0,T.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:D(e.text??``)},t);case`p`:return(0,T.jsx)(`p`,{children:D(e.text??``)},t);case`ul`:return(0,T.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,T.jsxs)(`li`,{className:`flex gap-2`,children:[(0,T.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-violet-500/70`}),(0,T.jsx)(`span`,{children:D(e)})]},t))},t);case`ol`:return(0,T.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,T.jsx)(`li`,{className:`pl-1`,children:D(e)},t))},t);case`code`:return(0,T.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,T.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var Qe={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function O({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,T.jsx)(`code`,{className:`font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all`,children:e},e))})]})]})}function $e({version:e}){let{t}=xe();if(!e?.contains_code)return null;let n=e.permissions??{},r=(n.services?.length??0)+(n.hooks?.length??0)+(n.network?.length??0)+(n.fs?.length??0)>0;return(0,T.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,T.jsx)(h,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,T.jsx)(l,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:Qe[e.runtime]})}),e.platform_verified?(0,T.jsxs)(l,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,T.jsx)(y,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,T.jsxs)(l,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,T.jsx)(v,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,T.jsxs)(l,{variant:`outline`,className:`gap-1`,children:[(0,T.jsx)(m,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`This package requests:`})}),(0,T.jsx)(O,{icon:Ce,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,T.jsx)(O,{icon:x,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,T.jsx)(O,{icon:ke,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,T.jsx)(O,{icon:g,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0}),(0,T.jsx)(`div`,{className:`text-[11px] text-muted-foreground/80 leading-snug`,children:t(`marketplace.disclosure.notEnforced`,{defaultValue:`Recorded at install, and re-confirmed if a later version asks for more — but the runtime does not yet restrict the package to this list.`})})]}):(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var k=t({MarketplacePackagePage:()=>A});function A(){let e=n(),{packageId:t,appName:i}=r(),{isAdmin:a,isResolved:Ce}=ee(),{t:h,language:g}=xe(),ke=be(),v={describe:e=>h(e.anchor===`guest`?`marketplace.suggestedBindings.promptGuest`:`marketplace.suggestedBindings.promptEveryone`,{set:e.permission_set_name}),confirm:h(`marketplace.suggestedBindings.confirm`),confirming:h(`marketplace.suggestedBindings.confirming`),dismiss:h(`marketplace.suggestedBindings.dismiss`),confirmedToast:e=>h(`marketplace.suggestedBindings.confirmedToast`,{set:e.permission_set_name,anchor:e.anchor}),dismissedToast:e=>h(`marketplace.suggestedBindings.dismissedToast`,{set:e.permission_set_name})},y=i?`/apps/${i}`:``,{refresh:x}=ye(),E=Me(),[D,Qe]=(0,w.useState)(null),[O,k]=(0,w.useState)(E),[A,et]=(0,w.useState)(null),[tt,j]=(0,w.useState)(!1),[nt,rt]=(0,w.useState)([]),[it,M]=(0,w.useState)(!1),[N,P]=(0,w.useState)(null),[F,at]=(0,w.useState)(``),[ot,st]=(0,w.useState)({}),[ct,lt]=(0,w.useState)(!1),[ut,dt]=(0,w.useState)(!1),[I,ft]=(0,w.useState)(!1),[L,R]=(0,w.useState)(null),[z,pt]=(0,w.useState)(null),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(null),[W,G]=(0,w.useState)(null),[mt,ht]=(0,w.useState)(!1),[gt,_t]=(0,w.useState)([]),[vt,K]=(0,w.useState)(!1),[q,J]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!C().features.installLocal||!E||!a)return;let e=!1;return(async()=>{let t=await Fe();e||_t(t)})(),()=>{e=!0}},[t,q,E,a]),(0,w.useEffect)(()=>{if(!t||!E||!a)return;let e=C().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await S(t,e);!n&&r&&(V(r),pt(r.version))})(),()=>{n=!0}},[t,E,a]),(0,w.useEffect)(()=>{let e=!1;return(async()=>{if(t&&E&&a){k(!0),et(null);try{let n=await Ve(t);e||Qe(n)}catch(t){e||et(t?.message??String(t))}finally{e||k(!1)}}})(),()=>{e=!0}},[t,E,a]);let yt=async()=>{j(!0),R(null),P(null);let e=C().defaultEnvironmentId;if(e){M(!1),at(e),rt([]);return}M(!0);try{let[e,n]=await Promise.all([ze(),We()]),r=e.filter(e=>{let t=e.organization_id;return t?n.has(String(t)):!1});rt(r),st({});let i=t;i&&Promise.all(r.map(async e=>{try{let t=await S(i,e.id);return t?[e.id,t.version]:null}catch{return null}})).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);st(t)}),e.length>0&&r.length===0?P(h(`marketplace.install.noPermission`)):r.length===1&&at(r[0].id)}catch(e){let t=e?.status;P(t===401||t===403?h(`marketplace.install.signInFirst`):e?.message??String(e))}finally{M(!1)}},bt=async()=>{if(t&&F){ft(!0),R(null);try{let e=(await Pe({packageId:t,environmentId:F,seedSampleData:ct}))?.installation?.version??D?.package?.latest_version?.version??D?.versions?.[0]?.version??``;pt(e||`installed`);try{let e=C().defaultEnvironmentId||F;if(e){let n=await S(t,e);n&&V(n)}}catch{}let n=C().defaultEnvironmentId;if(!n||n===F)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await x()}catch{}R({ok:!0,message:h(`marketplace.install.success`)}),je()}catch(e){R({ok:!1,message:e?.message??String(e)})}finally{ft(!1)}}},xt=async()=>{if(t){K(!0),J(null);try{let e=await Ue({packageId:t});try{await x(`app`)}catch{}J({ok:!0,message:h(`marketplace.install.localSuccess`,{version:e.version,name:D?.package?Xe(D.package,g).displayName:e.manifestId})}),je()}catch(e){e?.code;let t=e?.message??String(e);f(e,`MANIFEST_CONFLICT`)?t=h(`marketplace.install.localManifestConflict`,{message:t}):f(e,`UNAUTHENTICATED`)?t=h(`marketplace.install.localUnauthorized`):f(e,`MARKETPLACE_UNAVAILABLE`)&&(t=h(`marketplace.install.localMarketplaceUnavailable`)),J({ok:!1,message:t})}finally{K(!1)}}},St=async()=>{if(Q&&confirm(h(`marketplace.uninstall.confirm`,{manifestId:Q.manifestId,version:Q.version}))){K(!0),J(null);try{await Ke(Q.manifestId);try{await x(`app`)}catch{}J({ok:!0,message:h(`marketplace.uninstall.successInDetail`,{manifestId:Q.manifestId})})}catch(e){J({ok:!1,message:e?.message??String(e)})}finally{K(!1)}}},Ct=async()=>{if(B){U(`reseed`),G(null);try{let e=await Ge(B.installationId);e.ok?(V({...B,withSampleData:!0}),G({ok:!0,text:h(`marketplace.detail.reseedQueued`)})):f(e,`ENVIRONMENT_KERNEL_UNAVAILABLE`)?(ht(!0),G({ok:!1,text:h(`marketplace.detail.sampleDataKernelUnavailable`)})):G({ok:!1,text:e.error||`Re-seed failed`})}finally{U(null)}}},wt=async()=>{if(B&&confirm(h(`marketplace.detail.purgeConfirm`))){U(`purge`),G(null);try{let e=await Ie(B.installationId);if(e.ok){V({...B,withSampleData:!1});let t=e.deleted??0;G({ok:!0,text:t>0?h(`marketplace.detail.purgeSuccess`,{count:t}):h(`marketplace.detail.purgeNoData`)})}else f(e,`ENVIRONMENT_KERNEL_UNAVAILABLE`)?(ht(!0),G({ok:!1,text:h(`marketplace.detail.sampleDataKernelUnavailable`)})):G({ok:!1,text:e.error||`Purge failed`})}finally{U(null)}}},Tt=async()=>{if(Q){U(`reseed`),G(null);try{let e=await Ne(Q.manifestId);_t(e=>e.map(e=>e.manifestId===Q.manifestId?{...e,withSampleData:!0}:e));let t=e.inserted??0,n=e.updated??0,r=e.errors??0,i=h(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n});G(r>0?{ok:!1,text:`${i} ${h(`marketplace.detail.reseedPartialErrors`,{count:r})}`}:{ok:!0,text:i})}catch(e){G({ok:!1,text:e?.message||`Re-seed failed`})}finally{U(null)}}},Et=async()=>{if(Q&&confirm(h(`marketplace.detail.purgeConfirm`))){U(`purge`),G(null);try{let e=await Le(Q.manifestId);_t(e=>e.map(e=>e.manifestId===Q.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;G({ok:!0,text:t>0?h(`marketplace.detail.purgeSuccess`,{count:t}):h(`marketplace.detail.purgeNoData`)})}catch(e){G({ok:!1,text:e?.message||`Purge failed`})}finally{U(null)}}};if(!E)return(0,T.jsx)(Je,{});if(!Ce)return(0,T.jsx)(Ye,{});if(!a)return(0,T.jsx)(He,{});if(O)return(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,T.jsx)(o,{className:`h-8 w-32`}),(0,T.jsx)(o,{className:`h-16 w-full`}),(0,T.jsx)(o,{className:`h-64 w-full`})]});if(A||!D)return(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,T.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>e(`${y}/system/marketplace`),children:[(0,T.jsx)(Se,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),h(`marketplace.back`)]}),(0,T.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`font-medium text-destructive`,children:h(`marketplace.load.packageFailed`)}),(0,T.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:A??h(`marketplace.load.notFound`)})]})]})]});let Y=D.package,X=Xe(Y,g),Z=Y.latest_version?.version??D.versions[0]?.version??null,Q=gt.find(e=>e.manifestId===Y.manifest_id)??null,Dt=!!Y.latest_version?.contains_code,$=!!z&&z!==`installed`&&!!Z&&z!==Z,Ot=C().features.installLocal,kt=!Z||vt||I||!Ot&&!!z&&!$,At=Ot?{label:h(vt?`marketplace.action.working`:Q?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:xt}:{label:I?h(`marketplace.action.installing`):z?$?h(`marketplace.action.updateTo`,{defaultValue:`Update`}):h(`marketplace.action.installed`,{defaultValue:`Installed`}):h(`marketplace.action.installToCloud`),onClick:yt},jt=Y.category?h(`marketplace.category.${Y.category}`,{defaultValue:Y.category}):null;return(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,T.jsxs)(d,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${y}/system/marketplace`),children:[(0,T.jsx)(Se,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),h(`marketplace.back`)]}),(0,T.jsxs)(`div`,{className:`flex items-start gap-5 flex-wrap sm:flex-nowrap rounded-2xl border bg-gradient-to-br from-primary/5 via-background to-background p-6 sm:p-8`,children:[(0,T.jsx)(qe,{iconUrl:Y.icon_url,displayName:X.displayName,manifestId:Y.manifest_id,className:`h-20 w-20 rounded-2xl shadow-sm ring-1 ring-border shrink-0`,initialClassName:`text-3xl font-bold`}),(0,T.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,T.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:X.displayName||Y.manifest_id}),Y.homepage_url&&(0,T.jsxs)(`a`,{href:Y.homepage_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:h(`marketplace.detail.homepage`),children:[(0,T.jsx)(Oe,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:h(`marketplace.detail.homepage`)})]})]}),(0,T.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,T.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:Y.manifest_id}),Z&&(0,T.jsx)(l,{variant:`outline`,children:h(`marketplace.versionBadge`,{version:Z})}),Y.publisher&&Y.publisher!==`private`&&(0,T.jsx)(l,{variant:Y.publisher===`objectstack`?`default`:`secondary`,children:Y.publisher}),jt&&(0,T.jsx)(l,{variant:`outline`,children:jt}),Y.license&&(0,T.jsx)(l,{variant:`outline`,className:`font-normal`,children:Y.license}),Q&&(0,T.jsxs)(l,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,T.jsx)(m,{className:`h-3 w-3`,"aria-hidden":`true`}),h(`marketplace.detail.installedV`,{version:Q.version})]}),!Q&&z&&(0,T.jsxs)(l,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,T.jsx)(m,{className:`h-3 w-3`,"aria-hidden":`true`}),h(`marketplace.detail.installedV`,{version:z})]}),$&&(0,T.jsxs)(l,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,T.jsx)(we,{className:`h-3 w-3`,"aria-hidden":`true`}),h(`marketplace.detail.updateAvailable`,{defaultValue:`Update available`}),` → v`,Z]})]}),X.description&&(0,T.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:X.description})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,T.jsxs)(d,{onClick:At.onClick,disabled:kt,size:`lg`,className:`min-w-[8rem]`,children:[(0,T.jsx)(Ee,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),At.label]}),Q&&(0,T.jsxs)(de,{children:[(0,T.jsx)(ge,{asChild:!0,children:(0,T.jsx)(d,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":h(`marketplace.detail.moreOptions`),children:(0,T.jsx)(De,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,T.jsxs)(te,{align:`end`,className:`w-56`,children:[(0,T.jsxs)(u,{onSelect:Tt,disabled:H!==null,children:[H===`reseed`?(0,T.jsx)(_,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(Te,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),Q.withSampleData?h(`marketplace.detail.reseedAgain`):h(`marketplace.detail.addSampleData`)]}),(0,T.jsxs)(u,{onSelect:Et,disabled:H!==null||!Q.withSampleData,className:`text-destructive focus:text-destructive`,children:[H===`purge`?(0,T.jsx)(_,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(b,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),h(`marketplace.detail.purgeSampleData`)]}),(0,T.jsxs)(u,{onSelect:St,disabled:vt,className:`text-destructive focus:text-destructive`,children:[(0,T.jsx)(b,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),h(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!Q&&B&&!C().cloudUrl&&(0,T.jsxs)(de,{children:[(0,T.jsx)(ge,{asChild:!0,children:(0,T.jsx)(d,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":h(`marketplace.detail.moreOptions`),children:(0,T.jsx)(De,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,T.jsxs)(te,{align:`end`,className:`w-56`,children:[(0,T.jsxs)(u,{onSelect:Ct,disabled:H!==null||mt,children:[H===`reseed`?(0,T.jsx)(_,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(Te,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),B.withSampleData?h(`marketplace.detail.reseedAgain`):h(`marketplace.detail.addSampleData`)]}),(0,T.jsxs)(u,{onSelect:wt,disabled:H!==null||mt||!B.withSampleData,className:`text-destructive focus:text-destructive`,children:[H===`purge`?(0,T.jsx)(_,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(b,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),h(`marketplace.detail.purgeSampleData`)]})]})]})]})]}),W&&(0,T.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm ${W.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[W.ok?(0,T.jsx)(m,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,T.jsx)(`div`,{className:`flex-1`,children:W.text}),(0,T.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>G(null),children:h(`marketplace.action.dismiss`)})]}),q&&(0,T.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm whitespace-pre-wrap ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[q.ok?(0,T.jsx)(m,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{className:`flex-1`,children:[q.message,q.ok&&(0,T.jsx)(Be,{packageId:Y.manifest_id,strings:v,className:`mt-2`})]}),(0,T.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>J(null),children:h(`marketplace.action.dismiss`)})]}),(0,T.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,T.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,T.jsxs)(ve,{children:[(0,T.jsx)(ae,{children:(0,T.jsx)(pe,{className:`text-base`,children:h(`marketplace.detail.about`)})}),(0,T.jsx)(re,{children:X.readme?(0,T.jsx)(Ze,{source:X.readme}):(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h(`marketplace.detail.noReadme`)})})]})}),(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsxs)(ve,{children:[(0,T.jsx)(ae,{children:(0,T.jsx)(pe,{className:`text-base`,children:h(`marketplace.detail.versions`)})}),(0,T.jsx)(re,{children:D.versions.length===0?(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h(`marketplace.detail.noApprovedVersions`)}):(0,T.jsx)(`ul`,{className:`space-y-3`,children:D.versions.map(e=>(0,T.jsxs)(`li`,{className:`space-y-1 text-sm`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,T.jsx)(Ae,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,T.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,T.jsx)(l,{variant:`outline`,className:`text-xs`,children:h(`marketplace.detail.prerelease`)})]}),(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.published_at?new Date(e.published_at).toLocaleDateString(ke):`—`})]}),e.release_notes&&e.release_notes.trim()&&(0,T.jsx)(`p`,{className:`whitespace-pre-line pl-5 text-xs text-muted-foreground`,children:e.release_notes.trim()})]},e.id))})})]})})]}),(0,T.jsx)(he,{open:tt,onOpenChange:e=>{j(e),e||(R(null),dt(!1))},children:(0,T.jsxs)(ne,{children:[(0,T.jsxs)(le,{children:[(0,T.jsx)(ue,{children:h(`marketplace.install.dialogTitle`,{name:X.displayName||Y.manifest_id})}),(0,T.jsx)(me,{children:C().defaultEnvironmentId?h(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):h(`marketplace.install.dialogDescPicker`)})]}),it?(0,T.jsx)(o,{className:`h-10 w-full`}):N?(0,T.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,T.jsx)(`div`,{className:`flex-1`,children:N})]}),Re()?(0,T.jsx)(`a`,{href:Re(),target:`_blank`,rel:`noopener noreferrer`,children:(0,T.jsxs)(d,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,T.jsx)(Oe,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),h(`marketplace.action.openOnCloud`)]})}):null]}):C().defaultEnvironmentId?(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(s,{id:`seed`,checked:ct,onCheckedChange:e=>lt(e===!0)}),(0,T.jsx)(c,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:h(`marketplace.install.includeSampleData`)})]}):nt.length===0?(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h(`marketplace.install.noEnvs`)}):(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(c,{htmlFor:`env-select`,children:h(`marketplace.install.environment`)}),(0,T.jsxs)(ie,{value:F,onValueChange:at,children:[(0,T.jsx)(fe,{id:`env-select`,children:(0,T.jsx)(_e,{placeholder:h(`marketplace.install.environmentPlaceholder`)})}),(0,T.jsx)(oe,{children:nt.map(e=>{let t=ot[e.id],n=!!t&&!!Z&&t!==`installed`&&t!==Z;return(0,T.jsxs)(se,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,T.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]}),t&&(n?(0,T.jsxs)(`span`,{className:`text-amber-600`,children:[` · `,h(`marketplace.install.updateTo`,{defaultValue:`Update → v{{version}}`,version:Z})]}):(0,T.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,h(`marketplace.install.installedVersion`,{defaultValue:`Installed v{{version}}`,version:t})]}))]},e.id)})})]})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(s,{id:`seed`,checked:ct,onCheckedChange:e=>lt(e===!0)}),(0,T.jsx)(c,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:h(`marketplace.install.includeSampleData`)})]})]}),Dt&&!N&&(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)($e,{version:Y.latest_version}),(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(s,{id:`ack-perms`,checked:ut,onCheckedChange:e=>dt(e===!0)}),(0,T.jsx)(c,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:h(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),L&&(0,T.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${L.ok?`border-green-500/30 bg-green-500/5 text-green-700`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:L.message}),L?.ok===!0&&C().defaultEnvironmentId&&C().defaultEnvironmentId===F&&(0,T.jsx)(Be,{packageId:Y.manifest_id,strings:v}),(0,T.jsxs)(ce,{children:[(0,T.jsx)(d,{variant:`outline`,onClick:()=>j(!1),children:h(`marketplace.action.close`)}),!N&&(0,T.jsx)(d,{onClick:bt,disabled:!F||I||L?.ok===!0||Dt&&!ut,children:h(I?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]})}export{k as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{d as t,m as n,p as r,t as i,u as a,v as o}from"./vendor-react-BggL7APJ.js";import{f as s}from"./infrastructure-BHSync5f.js";import{Ot as c,Tt as l,_t as u,wt as d}from"./ui-components-BTB1NkUW.js";import{G as f,K as p,ht as m}from"./framework-DcWkeiND.js";import{w as h}from"./i18n-runtime-CTgAQF4N.js";import{t as g}from"./vendor-icon-file-text-7BKAVNof.js";import{t as _}from"./vendor-icon-pencil-CMubUBjW.js";import{a as v}from"./ExpressionProvider-DZfMwyMs.js";import{w as y}from"./RecordDetailView-DQKydU7X.js";import{t as b}from"./preferLocal-DEJV3KIq.js";import{t as x}from"./InterfaceListPage-BdECC_i3.js";import{n as S,t as C}from"./MetadataInspector-BWxLkr0O.js";var w=e(o(),1),T=i();function E(){let{t:e}=h(),{pageName:i}=r(),[o]=n(),{showDebug:E}=S(),D=t(),O=a(),{isAdmin:k}=s(),{pages:A,objects:j,getTypeStatus:M}=p(),{app:N}=v(),P=f(),[F,I]=(0,w.useState)(0),L=b(A,i,N?._packageId);if(!L){let t=M?.(`page`);return t===`idle`||t===`loading`?(0,T.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,T.jsx)(u,{className:`h-5 w-5 text-muted-foreground`})}):(0,T.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,T.jsxs)(d,{children:[(0,T.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,T.jsx)(g,{className:`h-6 w-6 text-muted-foreground`})}),(0,T.jsx)(c,{children:e(`empty.pageNotFound`)}),(0,T.jsx)(l,{children:e(`empty.pageNotFoundDescription`,{name:i})})]})})}let R=Object.fromEntries(o.entries()),z=O.pathname.match(/\/apps\/([^/]+)/)?.[1],B=k&&!!z&&!!i;return(0,T.jsx)(y,{dataSource:P,objects:j,onRefresh:()=>I(e=>e+1),children:(0,T.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,T.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[B&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>{B&&D(`/apps/${z}/metadata/page/${encodeURIComponent(i)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,T.jsx)(_,{className:`h-3.5 w-3.5`})}),L.interfaceConfig?.source?(0,T.jsx)(x,{page:L,reserveEditAffordance:B},F):(0,T.jsx)(m,{schema:{...L,type:L.type||`page`,pageType:L.type,context:{params:R,refreshKey:F}}},F)]}),(0,T.jsx)(C,{open:E,sections:[{title:`Page Configuration`,data:L}]})]})})}export{E as PageView};
@@ -1,3 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{d as n,m 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-BHSync5f.js";import{J as f,Nr as p,Ot as m,V as h,f as g,rn as _}from"./vendor-objectstack-XuWC71M9.js";import{$ as v,Ar as y,Fn as b,In as x,Ln as S,Mr as C,Nr as w,Ot as T,Pn as E,Pr as ee,Rn as D,Rr as O,Tt as te,Yt as k,Zn as ne,bi as A,di as j,fi as re,gi as ie,hi as M,jr as ae,kr as oe,li as se,mi as ce,ni as N,oi as le,pi as P,qn as ue,si as de,ui as fe,vi as F,wi as pe,wt as me,z as he,zn as ge,zr as I}from"./ui-components-BTB1NkUW.js";import{$t as _e,Ci as ve,Ct as ye,D as be,Dr as xe,Ft as Se,G as Ce,K as we,Mt as Te,N as Ee,Ni as De,Nt as Oe,Pi as ke,Pr as Ae,Pt as L,Ri as je,St as Me,T as Ne,Tr as R,Tt as z,Ui as Pe,V as Fe,Wr as B,b as Ie,br as Le,cr as Re,dr as ze,g as Be,hr as V,ht as Ve,it as H,lr as He,m as Ue,mr as We,ni as Ge,pr as Ke,q as qe,r as Je,rt as Ye,s as Xe,ur as U,vn as Ze,w as Qe,wi as $e,z as et,zi as tt}from"./framework-DcWkeiND.js";import{f as nt,h as rt,t as it,w as W}from"./i18n-runtime-CTgAQF4N.js";import{r as G}from"./vendor-ui-utils-DIUdEYii.js";import{t as at}from"./vendor-icon-ban-BptIEC14.js";import{t as ot}from"./vendor-icon-check-vpu9Zukp.js";import{t as st}from"./vendor-icon-chevron-left-KnDcuFH1.js";import{t as ct}from"./vendor-icon-circle-alert-D1XTr_X9.js";import{t as lt}from"./vendor-icon-circle-5-gUQbxi.js";import{t as ut}from"./vendor-icon-database-C8JGjSkn.js";import{t as dt}from"./vendor-icon-download-C3csYSaD.js";import{t as K}from"./vendor-icon-loader-circle-D3PsuVaD.js";import{t as ft}from"./vendor-icon-lock-B_psRnly.js";import{t as pt}from"./vendor-icon-paperclip-zxZDBuvr.js";import{t as mt}from"./vendor-icon-plus-BlfcDDsa.js";import{t as ht}from"./vendor-icon-refresh-cw-BGjSPEfJ.js";import{t as gt}from"./vendor-icon-send-BlZYLCTK.js";import{t as _t}from"./vendor-icon-shield-alert-CJYtPI9w.js";import{t as vt}from"./vendor-icon-stamp-B4FwVzRL.js";import{t as q}from"./vendor-icon-trash-BLsWkwB9.js";import{t as yt}from"./vendor-icon-triangle-alert-D5n0T3q_.js";import{t as bt}from"./vendor-icon-upload-BZ3rElxe.js";import{t as xt}from"./vendor-icon-users-Db5uTXC8.js";import{t as St}from"./vendor-icon-x-CcLtgRNL.js";import{t as Ct}from"./plugin-form-CV8ZY04-.js";import{a as wt,f as Tt,l as Et,p as J,r as Dt,s as Ot,t as kt,u as At}from"./ActionResultDialog-CLdIyOW6.js";import{n as jt,t as Mt}from"./useActionModal-CSvbHkQ7.js";import"./ui-layout-bZfafwJa.js";import{a as Nt,d as Pt,f as Ft,l as It,m as Lt,p as Rt,u as zt}from"./plugin-grid-C9h7mRVv.js";import{t as Bt}from"./getIcon-BEVyC4y3.js";import{n as Vt,t as Ht}from"./MetadataInspector-BWxLkr0O.js";import{g as Ut}from"./i18n-CEKxYdmD.js";import{n as Wt,t as Gt}from"./SkeletonDetail-C8fMI-Mu.js";var Y=e(c(),1),X=o();function Kt({state:e,onOpenChange:t}){let{t:n}=W(),r=()=>{e.resolve?.(!0),t(!1)},i=()=>{e.resolve?.(!1),t(!1)};return(0,X.jsx)(se,{open:e.open,onOpenChange:e=>{e||i()},children:(0,X.jsxs)(re,{children:[(0,X.jsxs)(M,{children:[(0,X.jsx)(ie,{children:e.options?.title||n(`actionConfirm.title`)}),(0,X.jsx)(P,{children:e.message})]}),(0,X.jsxs)(ce,{children:[(0,X.jsx)(j,{onClick:i,children:e.options?.cancelText||n(`actionConfirm.cancel`)}),(0,X.jsx)(fe,{onClick:r,children:e.options?.confirmText||n(`actionConfirm.confirm`)})]})]})})}function qt(e){return e.kind===`object-form`&&!!e.objectName}function Jt(e){return Array.isArray(e.fields)?e.fields:[]}function Yt(e,t){let n=Xt(e,t);return Jt(e).filter(e=>!e.visibleWhen||R(e.visibleWhen,n,!0,void 0,n,{context:`visibleWhen of screen field '${e.name}'`}))}function Xt(e,t){let n={};for(let t of Jt(e)){let e=(t.type||`text`).toLowerCase();n[t.name]=e===`boolean`||e===`checkbox`?!1:null}for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function Zt(e){let t={};for(let n of Jt(e))n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function Qt({screen:e,values:t,onValueChange:n,dataSource:r,objects:i,objectForm:a,className:o}){if(qt(e)){let t=Array.isArray(i)?i.find(t=>t?.name===e.objectName):void 0,n=t?t.form?.subforms??t.formViews?.default?.subforms:void 0;return(0,X.jsx)(`div`,{className:A(`py-2`,o),children:r?(0,X.jsx)(Ct,{schema:{type:`object-form`,formType:`simple`,objectName:e.objectName,mode:e.mode===`edit`?`edit`:`create`,recordId:e.mode===`edit`?e.recordId:void 0,...e.defaults?{initialValues:e.defaults}:{},layout:`vertical`,subforms:n,onSuccess:a?.onSuccess,onCancel:a?.onCancel,showSubmit:a?.showSubmit??!0,showCancel:a?.showCancel??!0,submitText:a?.submitText??`Save & Continue`,cancelText:a?.cancelText??`Cancel`},dataSource:r},e.nodeId):(0,X.jsx)(`div`,{className:`text-sm text-destructive py-4`,children:a?.noDataSourceMessage??`This step renders an object form but no data source is available.`})})}return(0,X.jsx)(`div`,{className:A(`space-y-4 py-2`,o),children:Yt(e,t).map(e=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(ne,{htmlFor:`ff-${e.name}`,className:`text-sm`,children:[e.label||e.name,e.required&&(0,X.jsx)(`span`,{className:`text-destructive`,"aria-hidden":`true`,"data-required-marker":`true`,children:` *`})]}),(0,X.jsx)($t,{field:e,value:t[e.name],onChange:t=>n(e.name,t)})]},e.name))})}function $t({field:e,value:t,onChange:n}){let r=`ff-${e.name}`,i=(e.type||`text`).toLowerCase(),a=e.required?!0:void 0;if(Array.isArray(e.options)&&e.options.length>0)return(0,X.jsxs)(b,{value:t==null?void 0:String(t),onValueChange:e=>n(e),children:[(0,X.jsx)(D,{id:r,"aria-required":a,children:(0,X.jsx)(ge,{placeholder:e.placeholder||`Select…`})}),(0,X.jsx)(x,{children:e.options.map((e,t)=>(0,X.jsx)(S,{value:String(e.value),children:e.label},t))})]});if(i===`boolean`||i===`checkbox`)return(0,X.jsx)(O,{id:r,"aria-required":a,checked:t===!0,onCheckedChange:e=>n(e===!0)});if(i===`textarea`||i===`markdown`)return(0,X.jsx)(k,{id:r,"aria-required":a,value:t??``,placeholder:e.placeholder,onChange:e=>n(e.target.value)});let o=i===`number`||i===`currency`?`number`:i===`email`?`email`:i===`date`?`date`:`text`;return(0,X.jsx)(ue,{id:r,"aria-required":a,type:o,value:t??``,placeholder:e.placeholder,onChange:e=>n(o===`number`?e.target.value===``?void 0:Number(e.target.value):e.target.value)})}function en(e,t){let n=e.errorMessage;return typeof n==`string`&&n.length>0?n:V(e,t)}function tn(e){let t=e?.error?.details;return!t||typeof t!=`object`||Array.isArray(t)?{}:t}function nn(e,t,n){if(!e.ok)return e.status===400&&B(t?.error,`FLOW_FAILED`)?{kind:`failed`,error:en(tn(t),V(t,`${n} failed`)),retryable:!1}:e.status===404?{kind:`failed`,error:V(t,`${n} failed (HTTP ${e.status})`),retryable:!1}:{kind:`failed`,error:V(t,`${n} failed (HTTP ${e.status})`),retryable:!0};if(t&&t.success===!1)return{kind:`failed`,error:V(t,`${n} failed (HTTP ${e.status})`),retryable:!0};let r=t?.data??{};return r.success===!1||r.status===`failed`?{kind:`failed`,error:en(r,`${n} failed`),retryable:!1}:r.status===`paused`&&r.screen?{kind:`paused`,runId:r.runId,screen:r.screen,data:r}:r.status===`refused`?{kind:`refused`,message:typeof r.refusalMessage==`string`?r.refusalMessage:``,data:r}:{kind:`done`,data:t?.data,successMessage:typeof r.successMessage==`string`?r.successMessage:void 0}}function rn(e,t){switch(e.kind){case`failed`:return{result:{success:!1,error:e.error},refresh:!1};case`paused`:return{result:{success:!0,silent:!0},followUp:{kind:`screen`,runId:e.runId??``,screen:e.screen},refresh:!1};case`refused`:return{result:{success:!0,silent:!0},followUp:{kind:`refusal`,message:e.message},refresh:!1};case`done`:{let n=t!==!1;return{result:{success:!0,data:e.data,reload:n},refresh:n}}}}function an(e,t,n){if(!n||typeof e?.getResourceBundle!=`function`)return;let r=e.getResourceBundle(t,`translation`);if(r&&typeof r==`object`)for(let e of Object.values(r)){let r=e?.flows;if(r&&typeof r==`object`&&r[n])return{[t]:{flows:r}}}}function on(e,t){if(!t)return e;let n=e;for(let e of h){let r=t[e];typeof r==`string`&&r.length>0&&(n={...n,[e]:r})}return n}function sn(e,t,n,r){if(!n)return e;let i=f(n,t,e,{locale:r}),a=n[r]?.flows?.[t]?.screens?.[e.nodeId]?.fields,o=a&&Array.isArray(e.fields)?e.fields.map(e=>on(e,a[e.name])):e.fields;return{...e,title:i,fields:o}}function cn({state:e,authFetch:t,baseUrl:n,onClose:r,onComplete:i,dataSource:a,objects:o}){let{t:s,i18n:c,language:l}=W(),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)({}),[v,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(null);if((0,Y.useEffect)(()=>{e&&(d(e.screen),p(e.runId),h(e.flowName),_(Zt(e.screen)),S(null),E(null))},[e]),!e||!u)return null;let D=sn(u,m,an(c,l,m),l),O=(e,t)=>{_(n=>({...n,[e]:t})),S(e=>e&&e.retryable?null:e)},te=async e=>{let r=await t(`${n}/api/v1/automation/${encodeURIComponent(m)}/runs/${encodeURIComponent(f)}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({inputs:e})}),a=nn(r,await r.json().catch(()=>null),`Resume`);if(a.kind===`failed`){G.error(a.error),S({message:a.error,retryable:a.retryable});return}if(S(null),a.kind===`refused`){E({message:a.message});return}a.kind===`paused`?(d(a.screen),p(a.runId||f),_(Zt(a.screen)),G.success(s(`flowRunner.nextStep`,{defaultValue:`Saved — next step`}))):(G.success(a.successMessage||s(`flowRunner.completed`,{flow:m,defaultValue:`Flow "{{flow}}" completed`})),Ue({objectName:`*`}),i())},k=async()=>{let e=Yt(D,g).filter(e=>e.required&&(g[e.name]===void 0||g[e.name]===``||g[e.name]===null));if(e.length){G.error(s(`wizard.missingRequired`,{fields:e.map(e=>e.label||e.name).join(`, `),defaultValue:`Please complete the required fields: {{fields}}`}));return}b(!0);try{await te(g)}catch(e){let t=e.message;G.error(t),S({message:t,retryable:!0})}finally{b(!1)}},ne=async e=>{let t=e?.id??e?.data?.id??e?.record?.id,n=u.idVariable&&t!=null?{[u.idVariable]:t}:{};b(!0);try{await te(n)}catch(e){let t=e.message;G.error(t),S({message:t,retryable:!0})}finally{b(!1)}},A=qt(u),j=T!==null||x!==null&&!x.retryable;return(0,X.jsx)(oe,{open:!0,onOpenChange:e=>{!e&&!v&&r()},children:(0,X.jsxs)(y,{className:A?`sm:max-w-3xl max-h-[90vh] overflow-y-auto`:`sm:max-w-md`,children:[(0,X.jsxs)(w,{children:[(0,X.jsx)(ee,{children:D.title||s(`flowRunner.title`,{defaultValue:`Input`})}),D.description&&(0,X.jsx)(ae,{children:D.description})]}),T&&T.message&&(0,X.jsx)(le,{children:(0,X.jsx)(de,{children:T.message})}),x&&(0,X.jsx)(le,{variant:`destructive`,children:(0,X.jsx)(de,{children:x.message})}),(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(`div`,{className:`py-6 text-sm text-muted-foreground`,children:s(`common.loading`,{defaultValue:`Loading…`})}),children:(0,X.jsx)(Qt,{screen:D,values:g,onValueChange:O,dataSource:a,objects:o,objectForm:{onSuccess:ne,onCancel:r,showSubmit:!j,showCancel:!0,submitText:s(`flowRunner.saveAndContinue`,{defaultValue:`Save & Continue`}),cancelText:j?s(`common.close`,{defaultValue:`Close`}):s(`common.cancel`,{defaultValue:`Cancel`})}})}),!A&&(0,X.jsx)(C,{children:j?(0,X.jsx)(F,{variant:`outline`,onClick:r,children:s(`common.close`,{defaultValue:`Close`})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{variant:`outline`,onClick:r,disabled:v,children:s(`common.cancel`,{defaultValue:`Cancel`})}),(0,X.jsx)(F,{onClick:k,disabled:v,children:v?s(`flowRunner.submitting`,{defaultValue:`Submitting…`}):s(`common.submit`,{defaultValue:`Submit`})})]})})]})})}function ln({state:e,onClose:t}){let{t:n}=W();return(0,X.jsx)(oe,{open:e.open,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(y,{className:`sm:max-w-md`,children:[(0,X.jsx)(w,{children:(0,X.jsx)(ee,{children:e.title})}),e.message?(0,X.jsx)(le,{children:(0,X.jsx)(de,{children:e.message})}):null,(0,X.jsx)(C,{children:(0,X.jsx)(F,{variant:`outline`,onClick:t,children:n(`common.close`,{defaultValue:`Close`})})})]})})}function un(e){return e.name??e.field}function dn(e,t){if(e)return fn(e)?e:e.map(e=>typeof e.label==`string`?e:{...e,label:p(e.label,t)??e.value})}function fn(e){return e.every(e=>typeof e.label==`string`)}function pn(e){return e.field??e.name}function mn(e,t,n,r){if(Array.isArray(e)&&e.length!==0)return e.map(e=>{let i=typeof e==`string`?{label:e,value:e}:e,a=r?r(t,n,i.value,i.label):i.label;return{...i,label:a,value:i.value}})}function hn(e){if(typeof e==`string`)return e||void 0;if(e&&typeof e==`object`&&typeof e.source==`string`)return e.source||void 0}function gn(e,t){let n=pn(e),r=e.defaultFromRow&&t.row&&n!=null&&Object.prototype.hasOwnProperty.call(t.row,n)?t.row[n]:void 0,i=p(e.label,t.locale),a=dn(e.options,t.locale);if(!e.field)return{name:e.name??``,label:i??e.name??``,type:e.type??`text`,required:e.required??!1,options:a,placeholder:e.placeholder,helpText:e.helpText,defaultValue:r??e.defaultValue,visible:hn(e.visible),carryOver:e.carryOver,multiple:e.multiple,accept:e.accept,maxSize:e.maxSize,referenceTo:e.reference};let o=e.objectOverride??t.objectName,s=t.objects.find(e=>e?.name===o)?.fields?.[e.field];if(!s)return{unresolvedField:`${o}.${e.field}`,name:un(e)??e.field,label:i??t.fieldLabel(o,e.field,e.field),type:e.type??`text`,required:e.required??!1,options:a,placeholder:e.placeholder,helpText:e.helpText,defaultValue:r??e.defaultValue,visible:hn(e.visible),carryOver:e.carryOver,multiple:e.multiple,accept:e.accept,maxSize:e.maxSize,referenceTo:e.reference};let c=e.type??s.type??`text`,l=a??mn(s.options,o,e.field,t.fieldOptionLabel),u=i??t.fieldLabel(o,e.field,s.label??e.field),d=ve.has(wt(c))?{referenceTo:e.reference??s.reference,displayField:s.displayField??s.display_field??s.reference_field,idField:s.id_field,descriptionField:s.descriptionField??s.description_field,titleFormat:s.title_format,lookupColumns:s.lookupColumns??s.lookup_columns,lookupFilters:s.lookupFilters??s.lookup_filters,lookupPageSize:s.lookupPageSize??s.lookup_page_size,dependsOn:s.dependsOn}:{};return{name:un(e)??e.field,label:u,type:c,required:e.required??s.required??!1,options:l,placeholder:e.placeholder??s.placeholder,helpText:e.helpText??s.help??s.description,defaultValue:r??e.defaultValue??s.defaultValue,visible:hn(e.visible),carryOver:e.carryOver,multiple:e.multiple??s.multiple,accept:e.accept??s.accept,maxSize:e.maxSize??s.maxSize,...d}}function _n(e,t){let n=e=>{let t=e?.name;return typeof t==`string`&&t?t:void 0},r=Array.isArray(e)?[...e]:[],i=new Set;for(let e of r){let t=n(e);t&&i.add(t)}if(!Array.isArray(t))return r;for(let e of t){let t=n(e);t&&!i.has(t)&&(i.add(t),r.push(e))}return r}function vn(e,t){return Array.isArray(e)?e.map(e=>gn(e,t)):[]}_();function yn(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function bn({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=yn(e.url,t);return(0,X.jsx)(F,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,X.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function xn({state:e,apiBase:t,onOpenChange:n}){let r=e.spec,{t:i}=W();return(0,X.jsx)(se,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,X.jsxs)(re,{"data-testid":`environment-entitlement-dialog`,children:[(0,X.jsxs)(M,{children:[(0,X.jsx)(ie,{children:r?.title}),(0,X.jsx)(P,{children:r?.message})]}),(0,X.jsxs)(ce,{children:[(0,X.jsx)(j,{children:i(`common.close`,{defaultValue:`Close`})}),r?.secondaryCta&&(0,X.jsx)(bn,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,X.jsx)(bn,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var Sn=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function Cn(e){return typeof e==`string`&&Sn.has(e)}function wn(e,t){return(typeof t?.defaultValue==`string`?t.defaultValue:e).replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t?.[n]??``))}function Z(e,t){return typeof t==`string`&&t&&t!==`free`?e(`environment.entitlement.namedPlan`,{plan:t,defaultValue:`{{plan}} plan`}):e(`environment.entitlement.freePlan`,{defaultValue:`free plan`})}function Q(e,t=wn){let n=e?.error;if(!n||typeof n!=`object`)return null;let r=n.code;if(!Cn(r))return null;let i=n.details&&typeof n.details==`object`?n.details:void 0,a=typeof i?.upgrade_url==`string`&&i.upgrade_url?i.upgrade_url:``,o=typeof i?.contact_url==`string`&&i.contact_url?i.contact_url:``;if(r===`PRODUCTION_ENV_LIMIT`)return{code:r,title:t(`environment.entitlement.productionLimitTitle`,{defaultValue:`You already have your production environment`}),message:t(`environment.entitlement.productionLimitBody`,{defaultValue:`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`}),cta:o?{label:t(`environment.entitlement.contactSalesCta`,{defaultValue:`Contact sales`}),url:o}:void 0};let s=a?{label:t(`environment.entitlement.upgradeCta`,{defaultValue:`Upgrade plan`}),url:a}:void 0;if(r===`DEV_ENV_PLAN_LOCKED`)return{code:r,title:t(`environment.entitlement.planLockedTitle`,{defaultValue:`Development environments are a paid feature`}),message:t(`environment.entitlement.planLockedBody`,{plan:Z(t,i?.plan),defaultValue:`Your {{plan}} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`}),cta:s};let c=Number(i?.current),l=Number(i?.limit),u=Number.isFinite(c)&&Number.isFinite(l);return{code:r,title:t(`environment.entitlement.limitTitle`,{defaultValue:`Development environment limit reached`}),message:u?t(`environment.entitlement.limitBodyWithCount`,{used:c,limit:l,defaultValue:`You are using {{used}} of {{limit}} development environments. Capacity scales with AI seats — add an AI seat, or archive an unused development environment to free one up.`}):t(`environment.entitlement.limitBody`,{defaultValue:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`}),cta:s}}function Tn(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function En(e,t=wn){return{code:`DEV_ENV_PLAN_LOCKED`,title:t(`environment.entitlement.planLockedTitle`,{defaultValue:`Development environments are a paid feature`}),message:t(`environment.entitlement.planLockedBody`,{plan:Z(t,e.plan),defaultValue:`Your {{plan}} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`}),cta:e.upgradeUrl?{label:t(`environment.entitlement.upgradeCta`,{defaultValue:`Upgrade plan`}),url:e.upgradeUrl}:void 0}}var Dn=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function On(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function kn(e,t){if(!e.includes(`{{`))return e;let n=e.match(Dn);if(n){let e=On(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=On(n,t);return r==null?``:String(r)})}function An(e,t){if(typeof e==`string`)return kn(e,t);if(Array.isArray(e))return e.map(e=>An(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=An(i,t);return n}return e}function jn(e,t){return t?An(e,t):e}var Mn=(e,t)=>t;function $(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function Nn(e){try{let t=window.open(`about:blank`,`_blank`);if(t){let n=$(e(`console.serverAction.openingTitle`,`Opening…`)),r=$(e(`console.serverAction.openingBody`,`Opening… this may take a moment.`));t.document.write(`<!doctype html><meta charset="utf-8"><title>${n}</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>${r}</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),t.document.close()}return t}catch{return null}}function Pn(e){if(e)try{e.close()}catch{}}function Fn(e,t,n){if(e){try{e.location.href=t}catch{Pn(e),window.location.href=t}return}let r;try{r=window.open(t,`_blank`)}catch{r=null}r||G(n(`console.serverAction.popupBlockedTitle`,`Popup blocked`),{description:n(`console.serverAction.popupBlockedDescription`,`Your browser blocked the new tab from opening.`),action:{label:n(`console.serverAction.popupBlockedAction`,`Open in new tab`),onClick:()=>{try{window.open(t,`_blank`)}catch{window.location.href=t}}},duration:1e4})}function In(e){let t=He({fetch:e.fetch,baseUrl:e.baseUrl,resolveObject:e.resolveObject,resolveRecordId:e.resolveRecordId,onRefresh:e.onRefresh}),n=e.resolveRecordId??ze,r=e.t??Mn;return async(i,a)=>{let o=typeof i.newTabUrl==`string`?i.newTabUrl:``;if(i.opensInNewTab&&o){let t=n(i,a);if(t.error)return{success:!1,error:t.error};let s=t.recordId;return s==null?{success:!1,error:`This action runs on a single record — no record id available.`}:(Fn(Nn(r),`${e.baseUrl()||window.location.origin}${o.replace(`{recordId}`,encodeURIComponent(String(s)))}`,r),i.refreshAfter===!0&&e.onRefresh(),{success:!0})}let s=i.opensInNewTab?Nn(r):null;try{let n=await t(i,a);if(!n.success)return Pn(s),n;let o=We(n.data),c=o&&typeof o==`object`&&typeof o.redirectUrl==`string`?o.redirectUrl:null;return Ke(i.onSuccess)?(Pn(s),n):(c?o&&typeof o==`object`&&o.openIn===`self`?(Pn(s),e.navigate&&c.startsWith(`/`)?e.navigate(c):window.location.href=c):Fn(s,c,r):Pn(s),n)}catch(e){return Pn(s),{success:!1,error:e.message}}}}var Ln={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1},Rn=V;function zn(e){let{dataSource:t,objects:r,objectName:i,onRefresh:a}=e,o=n(),{user:s,activeOrganization:c}=u(),{systemPermissions:d}=v(),{fieldLabel:f,fieldOptionLabel:p,actionParamText:m,actionParamOptionLabel:h,actionDescription:g,actionResultDialog:_}=nt(),{t:y,language:b}=W(),x=we(),S=(0,Y.useMemo)(()=>i?r?.find(e=>e.name===i):void 0,[r,i]),C=i||S?.name,w=(0,Y.useCallback)(()=>{a?.()},[a]),T=be({dataSource:t,onUndo:()=>{w(),G.success(`Change undone`)}}),[E,ee]=(0,Y.useState)({open:!1,message:``}),[D,O]=(0,Y.useState)({open:!1,params:[]}),[te,k]=(0,Y.useState)({open:!1}),[ne,A]=(0,Y.useState)(null),[j,re]=(0,Y.useState)({open:!1}),[ie,M]=(0,Y.useState)({open:!1}),ae=(0,Y.useCallback)((e,t,n)=>new Promise(r=>{let a=typeof n?.objectName==`string`&&n.objectName?n.objectName:i||S?.name,o=_(a,n?.name,e)??e;k({open:!0,spec:o,data:t,resolve:r})}),[i,S,_]),oe=(0,Y.useCallback)((e,t)=>new Promise(n=>{ee({open:!0,message:e,options:t,resolve:n})}),[]),se=(0,Y.useCallback)((e,t)=>new Promise(n=>{(async()=>{await x.ensureType(`object`).catch(()=>[]);let a=_n(r,x.objects),o=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,s=typeof t?.objectName==`string`&&t.objectName?t.objectName:void 0,c=vn(e,{objectName:s||i||S?.name||``,objects:a,fieldLabel:f,fieldOptionLabel:p,row:o,locale:b}),l=s||i||S?.name,u=c.map(e=>({...e,label:m(l,t?.name,e.name,`label`,e.label)??e.label,placeholder:m(l,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:m(l,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:h(l,t?.name,e.name,n.value,n.label)})):e.options})),d=g(l,t?.name,t?.description),_=typeof t?.overrideNotice==`string`&&t.overrideNotice?t.overrideNotice:void 0;O({open:!0,params:u,title:t?.label,description:_?[_,d].filter(Boolean).join(`
2
-
3
- `):d,resolve:n})})()}),[i,S,r,x,f,p,m,h]),ce=s?{id:s.id,name:s.name,avatar:s.image,isPlatformAdmin:s?.isPlatformAdmin??!1,systemPermissions:d}:{...Ln,systemPermissions:d},N=(0,Y.useCallback)((e,t)=>{if(t?.type===`error`){G.error(e);return}if(t?.undo){G.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{T.undo()}}});return}G.success(e,{duration:t?.duration})},[T]),le=(0,Y.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):o(e)},[o]),P=(0,Y.useMemo)(()=>l({sameOriginOnly:!0}),[]),ue=(0,Y.useCallback)(e=>{M({open:!0,spec:e})},[]),de=(0,Y.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=jn(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};for(let e of Object.keys(f))if(e.startsWith(`outputs.`)&&e.length>8){let t=f[e];if(delete f[e],t===void 0||t===``)continue;(f.outputs??={})[e.slice(8)]=t}let p=Re(e,r);if(p.error)return{success:!1,error:p.error};p.value!==void 0&&(f[e.recordIdParam]=p.value),/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,jn(e.bodyExtra,o));let m=(e.method||`POST`).toUpperCase(),h={method:m,headers:{"Content-Type":`application/json`},credentials:`include`};m!==`GET`&&m!==`DELETE`&&(h.body=JSON.stringify(f));let g=await P(u,h);if(!g.ok){let e=null;try{e=await g.json()}catch{}let t=Q(e,y);return t?(ue(t),{success:!1}):{success:!1,error:Rn(e,`HTTP ${g.status}`)}}let _=await g.json().catch(()=>({}));return _&&typeof _==`object`&&_.success===!1?{success:!1,error:Rn(_,`Action "${e.name||a}" failed`)}:(e.refreshAfter!==!1&&w(),{success:!0,data:_&&typeof _==`object`&&!Array.isArray(_)&&`data`in _?_.data:_,reload:e.refreshAfter!==!1})}let o=e.objectName||C,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t=Object.keys(l),n=t.filter(e=>!Object.prototype.hasOwnProperty.call(s,e)||s[e]===void 0);n.length===0?d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:Object.fromEntries(t.map(e=>[e,s[e]])),redoData:{...l}}:console.warn("[useConsoleActionRuntime] `undoable` action succeeded but offers no Undo: the row it ran on does not carry every field it wrote, so their prior values are unknown and an Undo would overwrite stored data. A list row carries a written field when the object declares it and the principal may read it.",{action:e.name,missing:n})}let f=e.refreshAfter!==!1;return f&&w(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,C,P,c,w,ue,y]),fe=(0,Y.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(U(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await P(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||C,params:r})}),s=rn(nn(o,await o.json().catch(()=>null),`Flow "${n}"`),e.refreshAfter);return s.followUp?.kind===`screen`&&A({flowName:n,runId:s.followUp.runId,screen:s.followUp.screen}),s.followUp?.kind===`refusal`&&re({open:!0,title:e.label,message:s.followUp.message}),s.refresh&&w(),s.result}catch(e){return{success:!1,error:e.message}}},[P,C,w]),F=(0,Y.useRef)({objApiName:C,refresh:w,t:y,navigate:o});F.current={objApiName:C,refresh:w,t:y,navigate:o};let pe=(0,Y.useMemo)(()=>In({fetch:P,baseUrl:()=>``,resolveObject:()=>F.current.objApiName,onRefresh:()=>F.current.refresh(),navigate:e=>F.current.navigate(e),t:(e,t)=>String(F.current.t(e,t))}),[P]),{modalHandler:me,modalElement:he,resolveModalTarget:ge}=Mt(t),I=(0,Y.useCallback)(async(e,t)=>{let n=e.modal??e.target??e.params?.schema,r=n==null?null:await ge(n);return r?me(r):{success:!1,error:jt({actionName:e.name,target:n,serverHandlerHint:!0})}},[ge,me]);return{confirmHandler:oe,toastHandler:N,navigateHandler:le,paramCollectionHandler:se,resultDialogHandler:ae,apiHandler:de,flowHandler:fe,serverActionHandler:pe,modalActionHandler:I,authFetch:P,openEntitlementDialog:ue,actionProviderProps:(0,Y.useMemo)(()=>({context:{...i?{objectName:i}:{},user:ce,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:oe,onToast:N,onNavigate:le,onParamCollection:se,onResultDialog:ae,onModal:me,handlers:{api:de,flow:fe,script:pe,modal:I}}),[i,ce,c,oe,N,le,se,ae,de,fe,pe,me,I]),dialogs:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Kt,{state:E,onOpenChange:e=>{e||ee(e=>({...e,open:!1}))}}),(0,X.jsx)(Dt,{state:D,onOpenChange:e=>{e||O(e=>({...e,open:!1}))}}),(0,X.jsx)(kt,{state:te,onAcknowledge:()=>{te.resolve?.(),k({open:!1})}}),(0,X.jsx)(cn,{state:ne,authFetch:P,baseUrl:``,dataSource:t,objects:r,onClose:()=>A(null),onComplete:()=>{A(null),w()}}),(0,X.jsx)(ln,{state:j,onClose:()=>re(e=>({...e,open:!1}))}),(0,X.jsx)(xn,{state:ie,apiBase:``,onOpenChange:e=>{e||M({open:!1})}}),he]})}}function Bn({children:e,...t}){let n=zn(t);return(0,X.jsxs)(Ye,{...n.actionProviderProps,children:[e,n.dialogs]})}var Vn=(0,Y.createContext)(void 0);function Hn({children:e}){let[t,n]=(0,Y.useState)(`home`),[r,i]=(0,Y.useState)(),[a,o]=(0,Y.useState)(),s=(0,Y.useMemo)(()=>({context:t,setContext:n,currentAppName:r,setCurrentAppName:i,recordTitle:a,setRecordTitle:o}),[t,r,a]);return(0,X.jsx)(Vn.Provider,{value:s,children:e})}function Un(){return(0,Y.useContext)(Vn)||{context:`app`,setContext:()=>{},currentAppName:void 0,setCurrentAppName:()=>{},recordTitle:void 0,setRecordTitle:()=>{}}}function Wn(e){let{setRecordTitle:t}=Un();(0,Y.useEffect)(()=>(t(e),()=>t(void 0)),[e,t])}var Gn=`objectui-favorites`,Kn=`objectui-nav-pins`,qn=20,Jn=20;function Yn(e){let t=0,n=0,r=!1;for(let i of e)i.type===`nav`?(n++,n>Jn&&(r=!0)):(t++,t>qn&&(r=!0));if(!r)return e;let i=[],a=0,o=0;for(let t of e)t.type===`nav`?o<Jn&&(i.push(t),o++):a<qn&&(i.push(t),a++);return i}function Xn(e){try{let t=localStorage.getItem(At(Gn,e));return t?JSON.parse(t):[]}catch{return[]}}function Zn(e,t){try{localStorage.setItem(At(Gn,t),JSON.stringify(e))}catch{}}function Qn(e){let t;try{t=localStorage.getItem(Kn)}catch{return{migrated:e,didMigrate:!1}}if(!t)return{migrated:e,didMigrate:!1};let n=[];try{let e=JSON.parse(t);Array.isArray(e)&&(n=e.filter(e=>typeof e==`string`))}catch{}try{localStorage.removeItem(Kn)}catch{}if(n.length===0)return{migrated:e,didMigrate:!1};let r=new Set(e.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),i=new Date().toISOString(),a=[];for(let e of n)r.has(e)||a.push({id:`nav:${e}`,label:e,href:``,type:`nav`,navId:e,pinned:!0,favoritedAt:i});return a.length===0?{migrated:e,didMigrate:!0}:{migrated:[...e,...a],didMigrate:!0}}var $n=(0,Y.createContext)(null);function er({children:e}){let{user:t}=u(),n=t?.id??null,r=J(`favorites`),[i,a]=(0,Y.useState)(()=>Xn(n));(0,Y.useEffect)(()=>{a(Xn(n))},[n]),Tt(At(Gn,n),e=>{a(Array.isArray(e)?Yn(e.filter(e=>e&&typeof e.id==`string`)):[])});let o=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{if(!r)return;let e=++o.current,t=!1;return(async()=>{try{let i=await r.load();if(t||e!==o.current)return;let c=Yn((Array.isArray(i)?i:[]).filter(e=>e&&typeof e.id==`string`)),l=Xn(n),u=new Set(c.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),d=l.filter(e=>e.type===`nav`&&e.navId&&!u.has(e.navId)),f=c,p=!1;d.length>0&&(f=Yn([...c,...d]),p=!0);let{migrated:m,didMigrate:h}=Qn(f);h&&(f=Yn(m),p=!0),a(f),Zn(f,n),p&&s.schedule(f)}catch{}})(),()=>{t=!0}},[r,n]),(0,Y.useEffect)(()=>{r||a(e=>{let{migrated:t,didMigrate:r}=Qn(e);if(!r)return e;let i=Yn(t);return Zn(i,n),i})},[r,n]);let s=(0,Y.useMemo)(()=>Et(async e=>{r&&await r.save(e)},500),[r]);(0,Y.useEffect)(()=>()=>{s.flush()},[s]);let c=(0,Y.useCallback)(e=>{Zn(e,n),r&&s.schedule(e)},[n,r,s]),l=(0,Y.useCallback)(e=>{a(t=>{if(t.some(t=>t.id===e.id))return t;let n=Yn([{...e,favoritedAt:new Date().toISOString()},...t]);return c(n),n})},[c]),d=(0,Y.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return c(n),n})},[c]),f=(0,Y.useCallback)(e=>{a(t=>{let n=t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):Yn([{...e,favoritedAt:new Date().toISOString()},...t]);return c(n),n})},[c]),p=(0,Y.useCallback)(()=>{a([]),c([])},[c]),m=(0,Y.useCallback)((e,t)=>{e&&t&&a(n=>{let r=!1,i=n.map(n=>n.id===e&&n.label!==t?(r=!0,{...n,label:t}):n);return r?(c(i),i):n})},[c]),h=(0,Y.useCallback)((e,t)=>{a(n=>{let r=!1,i=n.map(n=>n.id!==e||!!n.pinned===t?n:(r=!0,{...n,pinned:t}));return r?(c(i),i):n})},[c]),g=(0,Y.useMemo)(()=>{let e=new Set;for(let t of i)t.pinned&&t.type===`nav`&&t.navId&&e.add(t.navId);return{favorites:i,addFavorite:l,removeFavorite:d,toggleFavorite:f,isFavorite:e=>i.some(t=>t.id===e),clearFavorites:p,refreshLabel:m,setPinned:h,isPinned:e=>i.some(t=>t.id===e&&!!t.pinned),pinnedNavIds:e}},[i,l,d,f,p,m,h]);return(0,X.jsx)($n.Provider,{value:g,children:e})}function tr(){return(0,Y.useContext)($n)||{favorites:[],addFavorite:()=>{},removeFavorite:()=>{},toggleFavorite:()=>{},isFavorite:()=>!1,clearFavorites:()=>{},refreshLabel:()=>{},setPinned:()=>{},isPinned:()=>!1,pinnedNavIds:new Set}}var nr=new Set([`created_by`,`updated_by`,`owner_id`]);function rr(e){let t=xe(e?.sort);if(!t)return;let n=Object.entries(t).map(([e,t])=>({field:e,order:t}));return n.length>0?n:void 0}function ir(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length>0}function ar(e){return e?Array.isArray(e)?e.filter(e=>e&&e.name!=null).map(e=>[String(e.name),e]):Object.entries(e):[]}function or(e,t,n){if(!e?.name||!Array.isArray(t)||t.length===0)return[];let r=e.name,i=[],a=[],o=n?.canRead;for(let e of t){if(!e?.name||o&&!o(e.name))continue;let t=rr(e.list);for(let[n,o]of ar(e.fields)){if(!o)continue;let s=o.type;if(s!==`lookup`&&s!==`master_detail`||o.reference!==r||nr.has(n)||o.relatedList===!1)continue;let c={childObject:e.name,childLabel:e.label||e.name,referenceField:n,isOwned:s===`master_detail`,isPrimary:o.relatedList===`primary`,...t?{sort:t}:{},_fkLabel:typeof o.label==`string`&&o.label||n,...typeof o.relatedListTitle==`string`&&o.relatedListTitle?{title:o.relatedListTitle}:{},...Array.isArray(o.relatedListColumns)&&o.relatedListColumns.length>0?{columns:o.relatedListColumns}:{},...ir(o.relatedListFilter)?{filter:o.relatedListFilter}:{}};(c.isOwned?i:a).push(c)}}let s=[...i,...a],c={};for(let e of s)c[e.childObject]=(c[e.childObject]||0)+1;return s.map(({_fkLabel:e,...t})=>!t.title&&c[t.childObject]>1?{...t,title:`${t.childLabel} · ${e}`}:t)}function sr(e){if(!e||typeof e!=`object`)return;let t=e.viewer;if(t&&typeof t==`object`)return t}function cr(e){let t=sr(e);return t?t.can_act===!1&&t.can_override===!0:!1}function lr(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e.source;if(typeof t==`string`)return t}return``}function ur(e){return!e||typeof e!=`object`?!1:lr(e.visible).includes(`can_override`)}function dr(e,t){return cr(t)&&ur(e)}function fr(e,t=e=>e){if(!e||typeof e!=`object`)return[];let n=e,r=Array.isArray(n.pending_approvers)?n.pending_approvers:[],i=n.pending_approver_names&&typeof n.pending_approver_names==`object`?n.pending_approver_names:{},a=[];for(let e of r){if(typeof e!=`string`||!e)continue;let n=i[e];a.push(typeof n==`string`&&n?n:t(e))}return a}function pr(e){return!e||typeof e!=`object`?!1:e.via_override===!0}function mr(e){let{url:t,channel:n,autoReconnect:r=!0,reconnectInterval:i=1e3,maxReconnectAttempts:a=10,authToken:o}=e,[s,c]=(0,Y.useState)(`disconnected`),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(0),_=(0,Y.useRef)(null),v=(0,Y.useRef)(new Map),y=(0,Y.useRef)([]),b=(0,Y.useRef)(!0),x=(0,Y.useRef)(!1),S=(0,Y.useCallback)(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),C=(0,Y.useCallback)(e=>{for(;y.current.length>0;){let t=y.current.shift(),r={type:t.type,channel:n,data:t.data,timestamp:new Date().toISOString()};e.send(JSON.stringify(r))}},[n]),w=(0,Y.useCallback)(()=>{if(typeof WebSocket>`u`){m(Error(`WebSocket is not available in this environment`)),c(`error`);return}if(!t){m(Error(`WebSocket URL is required`)),c(`error`);return}try{let e=new URL(t);if(e.protocol!==`ws:`&&e.protocol!==`wss:`){m(Error(`WebSocket URL must use ws: or wss: protocol`)),c(`error`);return}}catch{m(Error(`Invalid WebSocket URL`)),c(`error`);return}h.current&&=(x.current=!0,h.current.close(),null),x.current=!1,c(`connecting`),m(null);let e=o?`${t}?token=${encodeURIComponent(o)}&channel=${encodeURIComponent(n)}`:`${t}?channel=${encodeURIComponent(n)}`,s;try{s=new WebSocket(e)}catch(e){if(!b.current)return;let t=e instanceof Error?e:Error(`Failed to create WebSocket connection`);m(t),c(`error`);return}h.current=s,s.onopen=()=>{b.current&&(c(`connected`),m(null),g.current=0,C(s))},s.onmessage=e=>{if(b.current)try{let t=JSON.parse(String(e.data));if(t.channel!==n)return;u(t),f(e=>[...e,t]);let r=v.current.get(t.type);r&&r.forEach(e=>e(t.data))}catch{}},s.onerror=()=>{b.current&&(m(Error(`WebSocket connection error`)),c(`error`))},s.onclose=()=>{if(b.current){if(h.current=null,x.current){c(`disconnected`);return}if(r&&g.current<a){c(`reconnecting`);let e=Math.min(i*2**g.current,3e4);g.current+=1,_.current=setTimeout(()=>{b.current&&w()},e)}else c(`disconnected`)}}},[t,n,o,r,i,a,C]),T=(0,Y.useCallback)(()=>{S(),x.current=!0,g.current=0,h.current&&=(h.current.close(),null),c(`disconnected`)},[S]),E=(0,Y.useCallback)(()=>{S(),g.current=0,w()},[w,S]),ee=(0,Y.useCallback)((e,t)=>{let r=h.current;if(r&&r.readyState===WebSocket.OPEN){let i={type:e,channel:n,data:t,timestamp:new Date().toISOString()};r.send(JSON.stringify(i))}else y.current.push({type:e,data:t})},[n]),D=(0,Y.useCallback)((e,t)=>(v.current.has(e)||v.current.set(e,new Set),v.current.get(e).add(t),()=>{let n=v.current.get(e);n&&(n.delete(t),n.size===0&&v.current.delete(e))}),[]);return(0,Y.useEffect)(()=>(b.current=!0,t&&w(),()=>{b.current=!1,S(),x.current=!0,h.current&&=(h.current.close(),null)}),[t,n,o]),{connectionState:s,isConnected:s===`connected`,lastMessage:l,messages:d,send:ee,subscribe:D,disconnect:T,reconnect:E,error:p}}var hr=0;function gr(){return hr+=1,`conflict-${Date.now()}-${hr}`}var _r=0;function vr(){return _r+=1,`ver-${Date.now()}-${_r}`}function yr(e,t,n){let[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)([]);return{versions:r,currentVersion:(0,Y.useMemo)(()=>r.length===0?0:r[r.length-1].version,[r]),conflicts:a,hasConflicts:a.length>0,recordVersion:(0,Y.useCallback)((n,r)=>{i(i=>{let a=i.length===0?1:i[i.length-1].version+1,o={id:vr(),version:a,timestamp:new Date().toISOString(),userId:e,userName:t,changes:n,message:r};return[...i,o]})},[e,t]),resolveConflict:(0,Y.useCallback)((n,r,a)=>{o(o=>{let s=o.find(e=>e.id===n);if(!s)return o;let c;switch(r){case`local`:c=s.localValue;break;case`remote`:c=s.remoteValue;break;case`merge`:c=a??s.localValue}return i(n=>{let i=n.length===0?1:n[n.length-1].version+1,a={id:vr(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:{[s.field]:{before:s.baseValue,after:c}},message:`Resolved conflict on "${s.field}" using ${r} strategy`};return[...n,a]}),o.filter(e=>e.id!==n)})},[e,t]),resolveAllConflicts:(0,Y.useCallback)(n=>{o(r=>{if(r.length===0)return r;let a={};for(let e of r)a[e.field]={before:e.baseValue,after:n===`local`?e.localValue:e.remoteValue};return i(r=>{let i=r.length===0?1:r[r.length-1].version+1,o={id:vr(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:a,message:`Resolved all conflicts using ${n} strategy`};return[...r,o]}),[]})},[e,t]),revertToVersion:(0,Y.useCallback)(n=>{let a=r.findIndex(e=>e.id===n);if(a===-1)return null;let o={};for(let e=0;e<=a;e++){let t=r[e];for(let[e,n]of Object.entries(t.changes))o[e]=n.after}let s={},c={};for(let e of r)for(let[t,n]of Object.entries(e.changes))c[t]=n.after;for(let[e,t]of Object.entries(o))c[e]!==t&&(s[e]={before:c[e],after:t});return Object.keys(s).length>0&&i(n=>{let i=n.length===0?1:n[n.length-1].version+1,o={id:vr(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:s,message:`Reverted to version ${r[a].version}`};return[...n,o]}),o},[r,e,t]),compareVersions:(0,Y.useCallback)((e,t)=>{let n=r.findIndex(t=>t.id===e),i=r.findIndex(e=>e.id===t);if(n===-1||i===-1)return null;let[a,o]=n<i?[n,i]:[i,n],s=e=>{let t={};for(let n=0;n<=e;n++)for(let[e,i]of Object.entries(r[n].changes))t[e]=i.after;return t},c=s(a),l=s(o),u=new Set([...Object.keys(c),...Object.keys(l)]),d={};for(let e of u){let t=c[e],n=l[e];t!==n&&(d[e]={before:t,after:n})}return d},[r]),addConflict:(0,Y.useCallback)(e=>{let t={...e,id:gr()};o(e=>[...e,t])},[]),clearHistory:(0,Y.useCallback)(()=>{i([]),o([])},[])}}var br=rt({"collaboration.commentCount":`{{count}} comments`,"collaboration.commentCountOne":`{{count}} comment`,"collaboration.resolvedSuffix":` · Resolved`,"collaboration.sortComments":`Sort comments`,"collaboration.sortOldest":`Oldest`,"collaboration.sortNewest":`Newest`,"collaboration.resolve":`Resolve`,"collaboration.reopen":`Reopen`,"collaboration.justNow":`just now`,"collaboration.minutesAgo":`{{count}}m ago`,"collaboration.hoursAgo":`{{count}}h ago`,"collaboration.daysAgo":`{{count}}d ago`,"collaboration.edited":`(edited)`,"collaboration.reactionCount":`{{count}} reactions`,"collaboration.reactionCountOne":`{{count}} reaction`,"collaboration.addThumbsUp":`Add thumbs up`,"collaboration.reply":`Reply`,"collaboration.reactThumbsUp":`React with thumbs up`,"collaboration.reactHeart":`React with heart`,"collaboration.cancelReply":`Cancel reply`,"collaboration.replyingTo":`Replying to {{name}}…`,"collaboration.replyingToComment":`Replying to comment…`,"collaboration.commentPlaceholder":`Add a comment… (use @ to mention)`,"collaboration.send":`Send`,"collaboration.presentUserCount":`{{count}} users present`,"collaboration.presentUserCountOne":`{{count}} user present`,"collaboration.moreUserCount":`{{count}} more users`,"collaboration.moreUserCountOne":`{{count}} more user`,"collaboration.userStatusTitle":`{{name}} ({{status}})`,"collaboration.statusActive":`active`,"collaboration.statusIdle":`idle`,"collaboration.statusAway":`away`,"common.save":`Save`,"common.cancel":`Cancel`,"common.edit":`Edit`,"common.delete":`Delete`},`collaboration.commentPlaceholder`),xr={sm:24,md:32,lg:40},Sr={active:`#22c55e`,idle:`#f59e0b`,away:`#94a3b8`},Cr={active:`collaboration.statusActive`,idle:`collaboration.statusIdle`,away:`collaboration.statusAway`};function wr(e,t){let n=Cr[e];return n?t(n):e}function Tr(e){return e.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function Er({users:e,maxVisible:t=5,size:n=`md`,showStatus:r=!0,className:i}){let{t:a}=br(),o=xr[n],s=Math.round(o*.3),c=Math.round(o*.35),l=Math.max(8,Math.round(o*.28)),u=(0,Y.useMemo)(()=>e.slice(0,t),[e,t]),d=Math.max(0,e.length-t),f={display:`inline-flex`,alignItems:`center`,flexDirection:`row-reverse`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`},p={width:`${o}px`,height:`${o}px`,borderRadius:`50%`,border:`2px solid #fff`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`${c}px`,fontWeight:600,color:`#fff`,position:`relative`,flexShrink:0,overflow:`hidden`,boxSizing:`border-box`},m={...p,backgroundColor:`#e2e8f0`,color:`#475569`,marginLeft:`-${s}px`},h={position:`absolute`,bottom:`-1px`,right:`-1px`,width:`${l}px`,height:`${l}px`,borderRadius:`50%`,border:`2px solid #fff`,boxSizing:`border-box`},g=(0,Y.useMemo)(()=>[...u].reverse(),[u]);return Y.createElement(`div`,{style:f,className:i,role:`group`,"aria-label":a(e.length===1?`collaboration.presentUserCountOne`:`collaboration.presentUserCount`,{count:String(e.length)})},d>0&&Y.createElement(`div`,{key:`overflow`,style:m,title:a(d===1?`collaboration.moreUserCountOne`:`collaboration.moreUserCount`,{count:String(d)})},`+${d}`),g.map((e,t)=>Y.createElement(`div`,{key:e.userId,style:{...p,backgroundColor:e.color,marginLeft:t>0||d>0?`-${s}px`:`0`},title:a(`collaboration.userStatusTitle`,{name:e.userName,status:wr(e.status,a)})},e.avatar?Y.createElement(`img`,{src:e.avatar,alt:e.userName,style:{width:`100%`,height:`100%`,objectFit:`cover`}}):Tr(e.userName),r&&Y.createElement(`span`,{style:{...h,backgroundColor:Sr[e.status]}}))))}var Dr=Y.createContext({});function Or(){let e=Y.useContext(Dr),[t,n]=Y.useState([]);return Y.useEffect(()=>{if(!e.subscribeTenant){n([]);return}return e.subscribeTenant(e=>{n(Array.isArray(e)?e:[])})},[e]),t}function kr(e,t){let n=Y.useContext(Dr),[r,i]=Y.useState([]);return Y.useEffect(()=>{if(!n.subscribeRecord||!e||!t){i([]);return}return n.subscribeRecord({objectName:e,recordId:t},e=>{i(Array.isArray(e)?e:[])})},[n,e,t]),r}var Ar=`recordId`,jr=`form`,Mr=`formObject`,Nr=`formLink`,Pr=`palette`,Fr=`shortcuts`,Ir=`from`,Lr=48;function Rr(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>!!e&&typeof e.o==`string`&&e.o.length>0&&typeof e.i==`string`&&e.i.length>0).slice(-8).map(e=>({o:e.o,i:e.i,...typeof e.t==`string`&&e.t.trim()?{t:e.t.trim().slice(0,Lr)}:{}})):[]}catch{return[]}}function zr(e){return JSON.stringify(e.slice(-8))}function Br(e,t){let n=Rr(e),r=n[n.length-1];return(!r||r.o!==t.o||r.i!==t.i)&&n.push({o:t.o,i:t.i,...t.t&&t.t.trim()?{t:t.t.trim().slice(0,Lr)}:{}}),zr(n)}function Vr(e,t,n){let r=`${e}/${t.o}/record/${encodeURIComponent(t.i)}`;if(n.length===0)return r;let i=new URLSearchParams;return i.set(Ir,zr(n)),`${r}?${i.toString()}`}function Hr(){try{let e=d.get();return e?{Authorization:`Bearer ${e}`}:{}}catch{return{}}}function Ur(e){return e?e.lock_record!==!1:!1}function Wr(e,t){if(e)return e.viewer?.is_submitter??(!!t&&e.submitter_id===t)}function Gr(){return`${``.replace(/\/$/,``)}/api/v1`}async function Kr(e,t){let n=await fetch(`${Gr()}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...Hr(),...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=Error(r?.error||`HTTP ${n.status}`);throw e.code=r?.code??`HTTP_${n.status}`,e.status=n.status,e}return r}async function qr(e){try{let t=await Kr(`/approvals/requests/${encodeURIComponent(e.id)}`);return!t||t.id!==e.id?e:{...e,...t}}catch{return e}}async function Jr(e){let t=await Kr(`/approvals/requests/${encodeURIComponent(e)}/actions`);return Array.isArray(t?.data)?t.data:[]}async function Yr(e){return await Kr(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify({})})??{}}function Xr(e,t){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)([]),c=(0,Y.useRef)(!1),l=(0,Y.useCallback)(async()=>{if(e&&t&&!c.current){r(!0);try{let n=(await Kr(`/approvals/requests?object=${encodeURIComponent(e)}&recordId=${encodeURIComponent(t)}`))?.data??[],r=n.find(e=>e.status===`pending`),i=r?await qr(r):null;s(i?n.map(e=>e===r?i:e):n),a(!0)}catch(e){(e?.status===404||e?.status===501)&&(c.current=!0,a(!1))}finally{r(!1)}}},[e,t]);(0,Y.useEffect)(()=>{if(!e||!t){s([]);return}l()},[e,t,l]);let u=(0,Y.useMemo)(()=>o.find(e=>e.status===`pending`)??null,[o]),d=(0,Y.useMemo)(()=>[...o].sort((e,t)=>{let n=e.submitted_at||e.completed_at||``;return(t.submitted_at||t.completed_at||``).localeCompare(n)}),[o]);return{loading:n,available:i,requests:d,pendingRequest:u,latestRequest:d[0]??null,refresh:l}}var Zr=new Set([`record:discussion`,`record:chatter`]),Qr=[`children`,`items`,`body`,`components`,`regions`],$r=[`children`,`items`],ei=new Set([`record:attachments`]),ti=new Set([`record:approvals`]);function ni(e,t){let n=new WeakSet,r=e=>{if(!e||typeof e!=`object`||n.has(e))return!1;if(n.add(e),Array.isArray(e))return e.some(r);let i=e?.type;return typeof i==`string`&&t.has(i)?!0:[...Qr.map(t=>e[t]),...$r.map(t=>e.properties?.[t])].some(r)};return r(e)}function ri(e){let t=new WeakMap,n=new WeakSet,r=e=>!!e&&typeof e==`object`&&typeof e.type==`string`&&Zr.has(e.type),i=e=>{if(!e||typeof e!=`object`)return e;if(t.has(e))return t.get(e);if(n.has(e))return e;n.add(e);let a;if(Array.isArray(e)){let t=[],n=!1;for(let a of e){if(r(a)){n=!0;continue}let e=i(a);e!==a&&(n=!0),t.push(e)}a=n?t:e}else{let t={},n=!1;for(let r of Qr){let a=e[r];if(a==null)continue;let o=i(a);o!==a&&(t[r]=o,n=!0)}let r=e.properties;if(r&&typeof r==`object`&&!Array.isArray(r)){let e={},a=!1;for(let t of $r){let n=r[t];if(n==null)continue;let o=i(n);o!==n&&(e[t]=o,a=!0)}a&&(t.properties={...r,...e},n=!0)}a=n?{...e,...t}:e}return n.delete(e),t.set(e,a),a};return r(e)?null:i(e)}function ii(e){return ni(e,ei)}function ai(e){return ni(e,ti)}function oi(e){Ue({objectName:e})}function si(e,t,n,r,i){return typeof e==`boolean`?e:e==null||e===``?!1:Le(e,t??{},{fallback:!1,scope:n,warnOnError:!0,label:r,fields:i})}function ci(e,t,n){return(Array.isArray(e?.actions)?e.actions:[]).filter(e=>Array.isArray(e?.locations)&&e.locations.includes(n)).map(n=>t(e.name,n))}function li({appName:e,objects:t,dataSource:i,parentObjectName:a,parentRecordId:o,parentTitle:s,parentRecord:c,parentObjectFields:l,children:u}){let d=n(),{execute:f}=H(),[,p]=r(),{getObjectApiOperations:m,can:h}=v(),g=L(),_=Ne(),y=e?`/apps/${e}`:``,b=(0,Y.useMemo)(()=>new Set((t??[]).map(e=>e?.name).filter(Boolean)),[t]),x=(0,Y.useCallback)((e,t)=>{if(!y||!e||!b.has(e))return null;let n=`${y}/${e}/record/${encodeURIComponent(String(t))}`;if(a&&o){let e=Br(new URLSearchParams(window.location.search).get(Ir),{o:a,i:o,...s?{t:s}:{}}),t=new URLSearchParams;return t.set(Ir,e),`${n}?${t.toString()}`}return n},[y,b,a,o,s]),S=(0,Y.useCallback)((e,t)=>{let n=x(e,t);n&&d(n)},[x,d]),C=(0,Y.useCallback)(e=>{let t=new URLSearchParams(window.location.search);t.set(jr,e.recordId??`new`),t.set(Mr,e.objectName),e.link?t.set(Nr,`${e.link.field}:${e.link.parentId}`):t.delete(Nr),p(t)},[p]),w=(0,Y.useCallback)(async(e,t,n)=>{let r=t?.id??t?._id,{params:i,...a}=n,o={...a,objectName:e,...r==null?{}:{recordId:String(r)},params:{_rowRecord:t}};Array.isArray(i)&&i.length>0&&(o.actionParams=i),(await f(o))?.success&&oi(e)},[f]),T=(0,Y.useMemo)(()=>({resolve:({objectName:e,relationshipField:n,parentId:r})=>{let a=t.find(t=>t?.name===e);if(!a||!y)return{};let o=De(a,m(e)),s=o.create&&h(e,`create`),u=s?o.createPredicates:void 0,d=si(u?.visibleWhen??!0,c,g,`builtin:create:visibleWhen`,l),f=u?.disabledWhen!=null&&si(u.disabledWhen,c,g,`builtin:create:disabledWhen`,l),p={...o,create:s&&d,edit:o.edit&&h(e,`update`),delete:o.delete&&h(e,`delete`)},v={onView:t=>S(e,t)};p.create&&(f&&(v.createDisabled=!0),v.onCreate=()=>{C({objectName:e,link:n&&r!=null&&r!==``?{field:n,parentId:r}:void 0})}),p.edit&&(v.onEdit=t=>C({objectName:e,recordId:String(t)})),p.delete&&(v.onDelete=async t=>{await i?.delete?.(e,String(t))});let b=ci(a,_,`list_item`);b.length>0&&(v.rowActions=b,v.onRowAction=(t,n)=>w(e,n,t));let x=ci(a,_,`list_toolbar`);return x.length>0&&(v.toolbarActions=x,v.onToolbarAction=t=>w(e,void 0,t)),v},recordHref:x,openRecord:S}),[t,y,i,_,w,C,x,S,m,h,c,l,g]);return(0,X.jsx)(Ee,{value:T,children:u})}var ui=[`regions`,`components`,`children`];function di(e,t){if(Array.isArray(e)){let n=null;return e.forEach((r,i)=>{let a=di(r,t);a!==r&&(n??=e.slice(),n[i]=a)}),n??e}if(!e||typeof e!=`object`)return e;let n=e,r=null;n.type===`page:tabs`&&(r={...n},t.defaultTab!==void 0&&(r.defaultTab=t.defaultTab),t.onTabChange&&(r.onTabChange=t.onTabChange));for(let e of ui){let i=(r??n)[e];if(i==null)continue;let a=di(i,t);a!==i&&(r??={...n},r[e]=a)}return r??e}var fi=new Set([...m].filter(e=>!Ge.has(e)));function pi(e){return e==null||!Number.isFinite(e)?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var mi=({objectName:e,recordId:t,dataSource:n,currentUserId:r,className:i})=>{let{t:a}=W(),[o,s]=Y.useState([]),[c,u]=Y.useState(!1),[d,f]=Y.useState(null),[p,m]=Y.useState(`loading`),h=Y.useRef(0),g=Y.useRef(null),_=Y.useMemo(()=>l(),[]),v=Y.useMemo(()=>pe({baseUrl:``,scope:`attachments`,fetchImpl:_}),[``,_]),y=Y.useCallback(e=>{let t=e,n=String(t?.message??e??``),r=e=>t?.code===e||n.includes(e);return r(`ATTACHMENT_DELETE_DENIED`)?a(`detail.attachmentDeleteDenied`,{defaultValue:`Only the uploader or someone who can edit this record may delete this attachment.`}):r(`ATTACHMENT_PARENT_ACCESS`)?a(`detail.attachmentParentAccessDenied`,{defaultValue:`You don't have access to attach files to this record.`}):r(`ATTACHMENT_DOWNLOAD_DENIED`)?a(`detail.attachmentDownloadDenied`,{defaultValue:`You don't have access to download this attachment.`}):r(`AUTH_REQUIRED`)?a(`detail.attachmentAuthRequired`,{defaultValue:`Please sign in to download this attachment.`}):r(`PERMISSION_DENIED`)?a(`detail.attachmentPermissionDenied`,{defaultValue:`You don't have permission to do that.`}):n},[a]),b=Y.useCallback(async()=>{let r=++h.current,i=()=>h.current===r;if(n&&e&&t){m(`loading`);try{let r=await n.find(`sys_attachment`,{$filter:{parent_object:e,parent_id:t},$orderby:{created_at:`desc`},$top:100}),a=Array.isArray(r)?r:r?.data??[];if(!i())return;s(a),m(`loaded`)}catch(e){if(!i())return;s([]),m(Je(e)===`api-disabled`?`api-unavailable`:Xe(e)?`denied`:`unavailable`)}}},[n,e,t]);Y.useEffect(()=>{b()},[b]);let x=Y.useCallback(async i=>{if(i&&i.length!==0&&n){u(!0),f(null);try{for(let a of Array.from(i)){let i=await v.upload(a),o=i.meta?.fileId;if(!o)throw Error(`Upload did not return a fileId`);await n.create(`sys_attachment`,{parent_object:e,parent_id:t,file_id:o,file_name:i.name??a.name,mime_type:i.mimeType??a.type,size:i.size??a.size,...r?{uploaded_by:r}:{}})}await b()}catch(e){f(y(e))}finally{u(!1),g.current&&(g.current.value=``)}}},[v,n,e,t,r,b]),S=Y.useCallback(async e=>{if(n){f(null);try{await n.delete(`sys_attachment`,e.id),s(t=>t.filter(t=>t.id!==e.id))}catch(e){f(y(e))}}},[n,y]),C=Y.useCallback(async e=>{f(null);try{let t=await _(`/api/v1/storage/files/${encodeURIComponent(e.file_id)}/url`);if(!t.ok){let e;try{let n=await t.json();e=n?.error?.code??n?.code}catch{}throw Object.assign(Error(e??`Download failed (${t.status})`),{code:e})}let n=await t.json(),r=n?.url??n?.data?.url;if(!r)throw Error(`Download URL missing from response`);let i=/^https?:/i.test(r)?r:`${r}`;window.open(i,`_blank`,`noopener,noreferrer`)}catch(e){f(y(e))}},[_,``,y]);return(0,X.jsxs)(`div`,{className:A(`rounded-lg border bg-card`,i),"data-testid":`record-attachments-panel`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(pt,{className:`h-4 w-4 text-muted-foreground`}),(0,X.jsx)(`span`,{children:a(`detail.attachments`,{defaultValue:`Attachments`})}),o.length>0&&(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,o.length,`)`]})]}),p!==`denied`&&p!==`api-unavailable`&&p!==`unavailable`&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{ref:g,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void x(e.target.files)}),(0,X.jsxs)(F,{variant:`outline`,size:`sm`,disabled:c,onClick:()=>g.current?.click(),children:[c?(0,X.jsx)(K,{className:`h-4 w-4 mr-1 animate-spin`}):(0,X.jsx)(bt,{className:`h-4 w-4 mr-1`}),a(`detail.uploadAttachment`,{defaultValue:`Upload`})]})]})]}),d&&(0,X.jsx)(`div`,{className:`px-4 py-2 text-xs text-destructive border-b`,role:`alert`,children:d}),p===`loading`&&o.length===0?(0,X.jsxs)(`div`,{className:`px-4 py-6 text-sm text-muted-foreground flex items-center gap-2`,children:[(0,X.jsx)(K,{className:`h-4 w-4 animate-spin`}),a(`detail.loadingAttachments`,{defaultValue:`Loading attachments…`})]}):p===`denied`?(0,X.jsxs)(`div`,{className:`px-4 py-6 text-sm text-muted-foreground flex items-center gap-2`,"data-testid":`record-attachments-denied`,children:[(0,X.jsx)(ft,{className:`h-4 w-4 shrink-0`}),a(`detail.attachmentsAccessDenied`,{defaultValue:`You don't have access to these attachments.`})]}):p===`api-unavailable`?(0,X.jsxs)(`div`,{className:`px-4 py-6 text-sm text-muted-foreground flex items-center gap-2`,"data-testid":`record-attachments-api-unavailable`,children:[(0,X.jsx)(at,{className:`h-4 w-4 shrink-0`}),a(`detail.attachmentsApiUnavailable`,{defaultValue:`The attachments list is not available on this object.`})]}):p===`unavailable`?(0,X.jsxs)(`div`,{className:`px-4 py-6 text-sm text-muted-foreground flex flex-col items-start gap-3`,"data-testid":`record-attachments-unavailable`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(yt,{className:`h-4 w-4 shrink-0`}),a(`detail.attachmentsLoadFailed`,{defaultValue:`We couldn't load the attachments for this record.`})]}),(0,X.jsxs)(F,{variant:`outline`,size:`sm`,onClick:()=>void b(),children:[(0,X.jsx)(ht,{className:`h-4 w-4 mr-1`}),a(`detail.retryLoadAttachments`,{defaultValue:`Retry`})]})]}):o.length===0?(0,X.jsx)(`div`,{className:`px-4 py-6 text-sm text-muted-foreground`,children:a(`detail.noAttachments`,{defaultValue:`No attachments yet. Upload a file to get started.`})}):(0,X.jsx)(`ul`,{className:`divide-y`,children:o.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,X.jsx)(pt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm`,children:e.file_name||e.file_id}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:[pi(e.size),e.mime_type||void 0].filter(Boolean).join(` · `)})]}),(0,X.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":a(`detail.downloadAttachment`,{defaultValue:`Download`}),onClick:()=>void C(e),children:(0,X.jsx)(dt,{className:`h-4 w-4`})}),(0,X.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:text-destructive`,"aria-label":a(`detail.deleteAttachment`,{defaultValue:`Delete attachment`}),onClick:()=>void S(e),children:(0,X.jsx)(q,{className:`h-4 w-4`})})]},e.id))})]})},hi={sys_position:[`label`,`name`],sys_team:[`label`,`name`],sys_business_unit:[`label`,`name`],sys_user:[`full_name`,`name`,`display_name`,`email`]},gi=hi.sys_user,_i=Object.fromEntries(Object.entries(g).flatMap(([e,t])=>{if(!t||t.source!==`data`)return[];let n=String(t.object);return[[e,{object:n,valueField:String(t.valueField),displayFields:hi[n]??[`label`,`name`]}]]})),vi=new Set(Object.keys(g));function yi(e){if(!e||typeof e!=`string`)return null;let t=e.indexOf(`:`);if(t<=0||t===e.length-1)return null;let n=e.slice(0,t);return vi.has(n)?{raw:e,kind:n,value:e.slice(t+1)}:null}function bi(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function xi(e){if(!e)return`—`;if(e.includes(`@`))return e;if(e.startsWith(`role:`))return`Role: ${e.slice(5)}`;let t=yi(e);return t&&_i[t.kind]?.valueField===`name`?bi(t.value):e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e}function Si(e){if(!e||typeof e!=`object`)return[];let t=e,n=Array.isArray(t.pending_approvers)?t.pending_approvers:[],r=t.pending_approver_names&&typeof t.pending_approver_names==`object`?t.pending_approver_names:{},i=[];for(let e of n){if(typeof e!=`string`||!e)continue;let t=r[e];if(typeof t==`string`&&t)continue;let n=yi(e);n&&_i[n.kind]&&(i.includes(e)||i.push(e))}return i}function Ci(e,t){let{serverName:n,resolved:r,copy:i}=t,a=yi(e),o=a?_i[a.kind]:void 0,s=r?.label?.trim()||``,c=typeof n==`string`?n.trim():``,l=a&&o?.valueField===`name`?bi(a.value):``,u=c||s||l||i.fallback(e),d=r?.holders,f=``,p=!1;if(Array.isArray(d)){if(d.length===0)p=!0,u=i.unstaffed(u);else{let e=d.slice(0,3);f=i.joinNames(e),d.length>e.length&&(f+=` +${d.length-e.length}`)}}return{label:u,detail:f,raw:e,unstaffed:p}}function wi(e,t){if(!e||typeof e!=`object`)return``;let n=e;for(let e of t){let t=n[e];if(typeof t==`string`&&t.trim())return t.trim();if(typeof t==`number`)return String(t)}return``}var Ti={fallback:xi,joinNames:e=>e.join(`, `),unstaffed:e=>`${e} (no current holder)`};function Ei(e,t=xi){let n=(e,t)=>typeof e==`string`&&e?e:t,r=n(e(`approvalsInbox.approverNameSeparator`,{defaultValue:`, `}),`, `);return{fallback:t,joinNames:e=>e.join(r),unstaffed:t=>n(e(`approvalsInbox.approverUnstaffed`,{defaultValue:`{{seat}} (no current holder)`,seat:t}),Ti.unstaffed(t))}}var Di=`sys_user_position`,Oi=`position`,ki=`user_id`,Ai=`sys_user`,ji=new Map,Mi=new Map,Ni=e=>Array.isArray(e)?e:e?.data??[];async function Pi(e,t,n,r){let i=_i[t];if(!i)return;let a=Ni(await e.find(i.object,{$filter:{[i.valueField]:{$in:n}},$top:200}));for(let e of a){let n=e?.[i.valueField];if(n==null)continue;let a=wi(e,i.displayFields);if(!a)continue;let o=`${t}:${String(n)}`;r.set(o,{...r.get(o),label:a})}}async function Fi(e,t,n){let r=Ni(await e.find(Di,{$filter:{[Oi]:{$in:t}},$top:500})),i=new Map;for(let e of t)i.set(e,[]);for(let e of r){let t=e?.[Oi],n=e?.[ki];if(t==null||n==null)continue;let r=i.get(String(t));r&&!r.includes(String(n))&&r.push(String(n))}let a=[...new Set([...i.values()].flat())],o=new Map;if(a.length>0){let t=Ni(await e.find(Ai,{$filter:{id:{$in:a}},$top:500}));for(let e of t)e?.id!=null&&o.set(String(e.id),wi(e,gi)||String(e.id))}for(let[e,t]of i){let r=`position:${e}`;n.set(r,{...n.get(r),holders:t.map(e=>o.get(e)??e)})}}async function Ii(e,t){let n=new Map,r=new Map;for(let e of t){let t=yi(e);if(!t||!_i[t.kind])continue;let n=r.get(t.kind)??[];n.includes(t.value)||n.push(t.value),r.set(t.kind,n)}await Promise.all([...r].map(([t,r])=>Pi(e,t,r,n).catch(()=>{})));let i=r.get(`position`);i&&i.length>0&&await Fi(e,i,n).catch(()=>{});for(let e of t)ji.set(e,n.get(e)??{})}function Li(e){let t=Ce(),n=(0,Y.useMemo)(()=>[...new Set(e)].filter(Boolean).sort(),[e]),r=n.join(`|`),[i,a]=(0,Y.useState)(0),o=(0,Y.useRef)(!0);return(0,Y.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]),(0,Y.useEffect)(()=>{if(!t||n.length===0)return;let e=n.filter(e=>!ji.has(e));if(e.length===0)return;let r=e.join(`|`),i=Mi.get(r);i||(i=Ii(t,e).finally(()=>Mi.delete(r)),Mi.set(r,i)),i.then(()=>{o.current&&a(e=>e+1)})},[t,r]),(0,Y.useMemo)(()=>{let e={};for(let t of n){let n=ji.get(t);n&&(e[t]=n)}return e},[r,i])}var Ri={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`},zi={approve:`bg-emerald-500`,reject:`bg-destructive`,submit:`bg-blue-500`,reassign:`bg-indigo-500`,remind:`bg-amber-500`,request_info:`bg-amber-500`,comment:`bg-slate-400`,escalate:`bg-red-500`,revise:`bg-violet-500`,resubmit:`bg-blue-500`};function Bi(e,t){let n=t?.copy??Ti,r=t?.directory??{},i=[],a=new Map;for(let t of e.pending_approvers||[]){let o=Ci(t,{serverName:e.pending_approver_names?.[t],resolved:r[t],copy:n}),s=o.label,c=e.pending_approver_groups?.[t],l=c&&c.length?c.join(` / `):void 0,u=[s,o.detail,l].filter(Boolean).join(` `),d=a.get(u);d?(d.count+=1,t&&!d.title.split(`, `).includes(t)&&(d.title+=`, ${t}`)):(a.set(u,{label:s,group:l,count:1,title:t||s,...o.detail?{detail:o.detail}:{},...o.unstaffed?{unstaffed:!0}:{}}),i.push(u))}return i.map(e=>a.get(e))}function Vi(e,t){if(!e)return`—`;try{return new Date(e).toLocaleString(t)}catch{return e}}function Hi(e){return e.flat().sort((e,t)=>String(e.created_at||``).localeCompare(String(t.created_at||``)))}var Ui=({approvals:e,currentUserId:t,className:n})=>{let{t:r}=W(),i=it(),a=Y.useCallback((e,t,n)=>String(r(`approvalsInbox.${e}`,{defaultValue:t,...n})),[r]),{available:o,requests:s,pendingRequest:c}=e,u=c??s[0]??null,[d,f]=Y.useState([]),[p,m]=Y.useState(!1),[h,g]=Y.useState(!1),_=Li(Y.useMemo(()=>Si(c),[c])),v=Y.useMemo(()=>Ei(r),[r]),y=s.map(e=>`${e.id} ${e.status} ${e.decision_progress?.got??``}`).join(`,`),b=Y.useCallback(async()=>{let e=y?y.split(`,`).map(e=>e.split(` `)[0]):[];if(e.length===0){f([]);return}m(!0);try{let t=await Promise.all(e.map(e=>Jr(e).catch(()=>[])));f(Hi(t))}finally{m(!1)}},[y]);Y.useEffect(()=>{b()},[b]);let x=Wr(c,t)??!1,S=Y.useCallback(async()=>{if(c){g(!0);try{let e=await Yr(c.id);G.success(a(`remindSuccess`,`Reminder sent to {{count}} approver(s)`,{count:e?.notified??0})),await b()}catch(e){G.error(e?.code===`THROTTLED`||e?.status===429?a(`remindThrottled`,`A reminder was sent recently — try again later.`):e?.message||a(`loadFailed`,`Failed to load request`))}finally{g(!1)}}},[c,b,a]),C=Y.useMemo(()=>l(),[]),w=Y.useCallback(async e=>{let t=window.open(``,`_blank`,`noopener`);try{let n=``.replace(/\/$/,``),r=await C(`${n}/api/v1/storage/files/${encodeURIComponent(e.id)}/url`);if(!r.ok)throw Error(`HTTP_${r.status}`);let i=await r.json().catch(()=>null),a=i?.data?.url??i?.url;if(!a)throw Error(`NO_URL`);let o=/^https?:\/\//i.test(a)?a:`${n}${a}`;t?t.location.href=o:window.open(o,`_blank`,`noopener`)}catch{t?.close(),G.error(a(`attachmentOpenFailed`,`Could not open the attachment — please try again`))}},[C,a]);if(!o||s.length===0||!u)return null;let T=e=>{switch(e){case`pending`:return a(`statusPending`,`Pending`);case`approved`:return a(`statusApproved`,`Approved`);case`rejected`:return a(`statusRejected`,`Rejected`);case`recalled`:return a(`statusRecalled`,`Recalled`);case`returned`:return a(`statusReturned`,`Returned for revision`);default:return e}},E=e=>e.action===`submit`?a(`actSubmit`,`Submitted`):e.action===`approve`?a(`actApprove`,`Approved`):e.action===`reject`?a(`actReject`,`Rejected`):e.action===`recall`?a(`actRecall`,`Recalled`):e.action===`reassign`?a(`actReassign`,`Reassigned`):e.action===`remind`?a(`actRemind`,`Reminder sent`):e.action===`request_info`?a(`actRequestInfo`,`Requested more info`):e.action===`comment`?a(`actComment`,`Commented`):e.action===`escalate`?a(`actEscalate`,`SLA escalated`):e.action===`revise`?a(`actRevise`,`Sent back for revision`):e.action===`resubmit`?a(`actResubmit`,`Resubmitted`):e.action,ee=e=>e.actor_id===`system:sla`?a(`systemSlaActor`,`System (SLA)`):e.actor_name??xi(e.actor_id),D=c?.decision_progress,O=(c?.pending_approvers||[]).length,te=u.status===`pending`?u.step_label||(u.current_step?bi(u.current_step):null):null;return(0,X.jsxs)(`div`,{className:A(`rounded-lg border bg-card`,n),"data-testid":`record-approvals-panel`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-3 border-b`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 text-sm font-medium`,children:[(0,X.jsx)(vt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{children:r(`detail.approvalsPanelTitle`,{defaultValue:`Approvals`})}),(0,X.jsxs)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:[u.process_label||bi(u.process_name),te?` · ${te}`:``]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(u.round??1)>1&&(0,X.jsx)(N,{variant:`outline`,className:`text-[11px] text-muted-foreground`,children:a(`roundChip`,`Round {{n}}`,{n:u.round})}),(0,X.jsx)(N,{variant:`outline`,className:A(`font-medium`,Ri[u.status]??``),children:T(u.status)})]})]}),(0,X.jsxs)(`div`,{className:`px-4 py-3 space-y-3`,children:[(c?.flow_steps?.length??0)>1&&(0,X.jsx)(`ol`,{className:`flex flex-col`,"aria-label":a(`stepProgress`,`Approval steps`),children:c.flow_steps.map((e,t,n)=>{let r=n[t+1];return(0,X.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center self-stretch`,children:[(0,X.jsx)(`span`,{className:A(`flex items-center justify-center h-5 w-5 shrink-0 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,X.jsx)(ot,{className:`h-3 w-3`}):t+1}),r&&(0,X.jsx)(`div`,{className:A(`w-px flex-1 min-h-3 my-1`,r.state===`done`||r.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)})]}),(0,X.jsx)(`span`,{className:A(`min-w-0 flex-1 pt-0.5 text-xs break-words`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]},e.id)})}),D&&(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 mb-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:D.behavior===`per_group`?a(`progressGroups`,`Sign-off progress — {{got}} of {{need}} groups`,{got:D.got,need:D.need}):a(`progressApprovals`,`Approvals — {{got}} of {{need}}`,{got:D.got,need:D.need})}),D.behavior!==`per_group`&&O>0&&(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:a(`progressEligible`,`{{count}} eligible approver(s)`,{count:O})})]}),(0,X.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":D.need,"aria-valuenow":Math.min(D.got,D.need),"aria-label":a(`progressBar`,`Decision progress`),className:`flex gap-1`,children:D.need>0&&D.need<=12?Array.from({length:D.need}).map((e,t)=>(0,X.jsx)(`div`,{className:A(`h-1.5 flex-1 rounded-full`,t<D.got?`bg-emerald-500`:`bg-muted`)},t)):(0,X.jsx)(`div`,{className:`h-1.5 flex-1 rounded-full bg-muted overflow-hidden`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${D.need>0?Math.min(100,D.got/D.need*100):0}%`}})})}),D.groups&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:D.groups.map(e=>(0,X.jsxs)(N,{variant:`outline`,className:A(`text-[11px] gap-1`,e.satisfied?`border-emerald-300 text-emerald-700 dark:border-emerald-700 dark:text-emerald-400`:`text-muted-foreground`),title:`${e.got}/${e.need}`,children:[e.satisfied?(0,X.jsx)(ot,{className:`h-3 w-3`}):(0,X.jsx)(lt,{className:`h-2.5 w-2.5`}),e.group,` `,e.got,`/`,e.need]},e.group))})]}),c&&(c.pending_approvers||[]).length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:a(`waitingOn`,`Waiting on`)}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[Bi(c,{directory:_,copy:v}).map((e,t)=>(0,X.jsxs)(N,{variant:`outline`,className:`text-[11px]`,title:e.title,"data-testid":`approver-chip`,"data-unstaffed":e.unstaffed?`true`:void 0,children:[e.label,e.detail&&(0,X.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`· `,e.detail]}),e.group&&(0,X.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`· `,e.group]}),e.count>1&&(0,X.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.count]})]},`${e.label}-${e.group??``}-${t}`)),x&&(0,X.jsxs)(F,{variant:`outline`,size:`sm`,className:`h-6 gap-1 px-2 text-[11px]`,disabled:h,onClick:()=>void S(),children:[h?(0,X.jsx)(K,{className:`h-3 w-3 animate-spin`}):(0,X.jsx)(gt,{className:`h-3 w-3`}),a(`remindBtn`,`Send reminder`)]})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-2`,children:a(`history`,`Activity`)}),p&&d.length===0?(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[(0,X.jsx)(K,{className:`h-3.5 w-3.5 animate-spin`}),a(`loadingMore`,`Loading…`)]}):d.length===0?(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:a(`noActions`,`No actions yet.`)}):(0,X.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:d.map(e=>(0,X.jsxs)(`li`,{className:`relative text-xs`,children:[(0,X.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${pr(e)?`bg-amber-500`:zi[e.action]??`bg-muted-foreground`}`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:E(e)}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,X.jsx)(`span`,{title:e.actor_id||``,children:ee(e)}),pr(e)&&(0,X.jsxs)(N,{variant:`outline`,className:`gap-1 border-amber-500/60 px-1.5 py-0 text-[10px] font-medium text-amber-700 dark:text-amber-400`,title:a(`viaOverrideHint`,`The actor held no approver slot on this step — admitted by the admin-override path.`),"data-testid":`via-override-chip`,children:[(0,X.jsx)(_t,{className:`h-3 w-3`,"aria-hidden":!0}),a(`viaOverrideChip`,`Admin override`)]}),e.step_name&&(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,bi(e.step_name)]}),(0,X.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,children:Vi(e.created_at,i)})]}),e.action===`reassign`&&(e.reassign_from||e.reassign_to)&&(0,X.jsx)(`div`,{className:`text-muted-foreground mt-0.5`,children:a(`reassignFromTo`,`from {{from}} to {{to}}`,{from:e.reassign_from_name??xi(e.reassign_from),to:e.reassign_to_name??xi(e.reassign_to)})}),e.comment&&(0,X.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]}),Array.isArray(e.attachments)&&e.attachments.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((t,n)=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void w(t),className:`inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:t.name||t.id,children:[(0,X.jsx)(pt,{className:`h-3 w-3`}),t.name||`${a(`attachmentChip`,`Attachment`)}${e.attachments.length>1?` ${n+1}`:``}`]},t.id||n))})]},e.id))})]})]})]})},Wi=`outputs.`,Gi={department:`sys_business_unit`,position:`sys_position`,team:`sys_team`};function Ki(e){let t=typeof e==`object`&&e?e:{},n=t.decision_output_defs;if(Array.isArray(n)&&n.length>0)return n.filter(e=>e&&e.key);let r=t.decision_outputs;return Array.isArray(r)&&r.length>0?r.map(e=>({key:String(e)})).filter(e=>e.key):[]}function qi(e){return e.split(/[_-]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Ji(e,t,n={}){return e.filter(e=>e&&e.key).map(e=>{let r={name:`${Wi}${e.key}`,label:e.label??qi(e.key),required:n.decision===`approve`&&e.required===!0};if(e.type===`user`)return{...r,type:`user`,multiple:e.multiple===!0,helpText:t(`actions.decisionOutput.help`)};let i=e.type?Gi[e.type]:void 0;return i?{...r,type:`lookup`,reference:i,multiple:e.multiple===!0,helpText:t(`actions.decisionOutput.help`)}:{...r,type:`text`,helpText:t(`actions.decisionOutput.helpMultiValue`)}})}var Yi=({action:e,objectName:t,record:n})=>{let{execute:r}=H(),[i,a]=(0,Y.useState)(!1),o=Ne(),{t:s}=W(),c=typeof n==`object`&&n?n:{},l=Oe(n),u=Te(tt(e.visible),l,{throwOnError:!0,label:`declared action "${e.name??e.label??`action`}" (visible)`}),d=Te(tt(e.disabled),l),f=(0,Y.useMemo)(()=>dr(e,n),[e,n]),p=Li((0,Y.useMemo)(()=>f?Si(n):[],[f,n])),m=(0,Y.useMemo)(()=>{let e=Ei(s);return fr(n,t=>{let n=Ci(t,{resolved:p[t],copy:e});return n.detail?`${n.label} · ${n.detail}`:n.label})},[n,p,s]),h=o(t,e).label||``,g=String(s(`approvalsInbox.overrideActionLabel`,{defaultValue:`Override {{action}}`,action:h})),_=f?m.length>0?String(s(`approvalsInbox.overrideNoticeWho`,{defaultValue:`You hold no approver slot on this step. Continuing uses your admin override: it finalises the step immediately and bypasses the approvers who have not acted — {{who}}. The decision is recorded as an admin override.`,who:m.join(`, `)})):String(s(`approvalsInbox.overrideNotice`,{defaultValue:`You hold no approver slot on this step. Continuing uses your admin override: it finalises the step immediately, bypassing any approver who has not acted. The decision is recorded as an admin override.`})):void 0,v=(0,Y.useCallback)(async()=>{if(!i){a(!0);try{let{params:i,...a}=e,l=/\/approve$/.test(String(e.target??``))?`approve`:/\/reject$/.test(String(e.target??``))?`reject`:void 0,u=l?Ji(Ki(c),s,{decision:l}):[],d={...o(t,a),objectName:t,params:{_rowRecord:n}};_&&(d.overrideNotice=_,d.label=g);let f=Array.isArray(i)?i:[];(f.length>0||u.length>0)&&(d.actionParams=[...f,...u]),await r(d)}finally{a(!1)}}},[e,r,i,t,n,o,s,_,g]);if(je(e.visible)&&!u)return null;let y=typeof e.icon==`string`?e.icon:void 0,b=e.variant,x=f?`outline`:b===`primary`?`default`:b===`danger`?`destructive`:b||`outline`,S=f?g:h;return(0,X.jsxs)(F,{type:`button`,size:`sm`,variant:x,disabled:(je(e.disabled)?d:!1)||i,onClick:v,className:A(f&&`border-amber-500/60 text-amber-700 hover:bg-amber-50 hover:text-amber-800 dark:text-amber-400 dark:hover:bg-amber-500/10 dark:hover:text-amber-300`),"data-testid":`declared-action-${e.name}`,"data-override-decision":f?`true`:void 0,children:[i&&(0,X.jsx)(K,{className:`mr-2 h-4 w-4 animate-spin`}),!i&&f?(0,X.jsx)(_t,{className:A(`h-4 w-4`,S&&`mr-2`)}):null,!i&&!f&&y?Y.createElement(Bt(y),{className:A(`h-4 w-4`,S&&`mr-2`)}):null,S]})},Xi=({actions:e,objectName:t,record:n,className:r,label:i})=>{let{t:a}=W(),o=Qe(),s=(0,Y.useMemo)(()=>e.filter(e=>o(e.requiredPermissions)),[e,o]);return s.length===0?null:(0,X.jsxs)(`div`,{className:A(`space-y-2`,r),children:[i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{}),(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:i})]}),(0,X.jsx)(`div`,{role:`toolbar`,"aria-label":i||a(`common.actions`),className:`flex flex-row flex-wrap items-center gap-2`,children:s.map(e=>(0,X.jsx)(Yi,{action:e,objectName:t,record:n},e.name))})]})};function Zi({objectName:e,record:t,location:n,onDone:r,actions:i,exclude:a,className:o,label:s}){let c=Ce(),{item:l}=qe(`object`,i?void 0:e),u=(0,Y.useMemo)(()=>i??l?.actions??[],[i,l]),d=(0,Y.useMemo)(()=>{let e=a&&a.length?new Set(a):null;return u.filter(t=>Array.isArray(t?.locations)&&t.locations.includes(n)&&!(e&&e.has(t?.name)))},[u,n,a]),f=zn({dataSource:c,objects:l?[l]:[],objectName:e,onRefresh:r});return d.length===0?null:(0,X.jsxs)(Ye,{...f.actionProviderProps,children:[(0,X.jsx)(Xi,{actions:d,objectName:e,record:t,className:o,label:s}),f.dialogs]})}var Qi=[`approval_remind`],$i=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}};Pe.register(`approvals`,({schema:e,className:t,...n})=>{let r=z(),{user:i}=u(),{designer:a}=$i(n),o=e?.approvals,s=Xr(o?void 0:r?.objectName,o||r?.recordId==null?void 0:String(r.recordId)),c=o??s,l=e?.currentUserId??i?.id;return(0,X.jsx)(`div`,{className:t,...a,children:(0,X.jsx)(Ui,{approvals:c,currentUserId:l})})},{namespace:`record`,skipFallback:!0,category:`record`,label:`Approvals`,icon:`Stamp`,inputs:[{name:`className`,type:`string`}]});function ea(){let e=Ut()===`zh-CN`;return Y.useMemo(()=>e?{title:`已分配用户`,add:`添加用户`,remove:`移除`,empty:`还没有分配任何用户。点击「添加用户」来分配。`,loading:`加载中…`,pickTitle:`选择要分配的用户`,seatFull:e=>`AI 席位已用完(`+e+`/`+e+`)。请先移除一个用户,或在许可证中提升席位上限,再分配新用户。`,addFailed:`分配失败,请重试。`,countOf:e=>e+` 人`,direct:`直授`,viaPosition:e=>`经岗位 `+e,everyoneNote:`已绑定到 everyone 锚点 — 所有登录成员都持有此权限集。`,positionHeldHint:`经岗位持有 — 在岗位的指派中移除。`}:{title:`Assigned Users`,add:`Add user`,remove:`Remove`,empty:`No users assigned yet. Click "Add user" to assign.`,loading:`Loading…`,pickTitle:`Select users to assign`,seatFull:e=>`All `+e+` AI seat(s) are in use. Remove a user or raise the license cap before assigning another.`,addFailed:`Failed to assign. Please try again.`,countOf:e=>String(e),direct:`direct`,viaPosition:e=>`via position `+e,everyoneNote:`Bound to the everyone anchor — every signed-in member holds this set.`,positionHeldHint:`Held via a position — remove it on the position’s assignments.`},[e])}var ta=e=>Array.isArray(e)?e:e?.data??[],na=e=>e?.full_name||e?.name||e?.display_name||e?.email||String(e?.id??``);function ra({permissionSetName:e}){let t=Ce(),n=ea(),[r,i]=Y.useState(null),[a,o]=Y.useState([]),[s,c]=Y.useState(!1),[l,u]=Y.useState(!0),[d,f]=Y.useState(!1),[p,m]=Y.useState(!1),[h,g]=Y.useState(null),_=Y.useCallback(async()=>{u(!0);try{let n=ta(await t.find(`sys_permission_set`,{$filter:{name:e},$top:1})),r=n[0]?.id?String(n[0].id):null;if(i(r),!r){o([]),c(!1);return}let a=ta(await t.find(`sys_user_permission_set`,{$filter:{permission_set_id:r},$top:500})),s=[],l=!1;try{let e=ta(await t.find(`sys_position_permission_set`,{$filter:{permission_set_id:r},$top:200})),n=[...new Set(e.map(e=>e.position_id).filter(Boolean).map(String))];if(n.length){let e=ta(await t.find(`sys_position`,{$filter:{id:{$in:n}},$top:200})).map(e=>String(e.name??``)).filter(Boolean);l=e.includes(`everyone`),s=e.filter(e=>e!==`everyone`&&e!==`guest`)}}catch{}let u=s.length?ta(await t.find(`sys_user_position`,{$filter:{position:{$in:s}},$top:1e3})):[],d=new Map,f=new Map;for(let e of a){if(!e?.user_id)continue;let t=String(e.user_id);f.set(t,String(e.id)),d.set(t,[...d.get(t)??[],{kind:`direct`}])}for(let e of u){if(!e?.user_id||!e?.position)continue;let t=String(e.user_id);d.set(t,[...d.get(t)??[],{kind:`position`,position:String(e.position)}])}let p=[...d.keys()],m=p.length?ta(await t.find(`sys_user`,{$filter:{id:{$in:p}},$top:1e3})):[],h=new Map(m.map(e=>[String(e.id),e]));o(p.map(e=>{let t=h.get(e);return{grantId:f.get(e)??null,userId:e,name:t?na(t):e,email:t?.email??``,via:d.get(e)??[]}})),c(l)}catch{o([]),c(!1)}finally{u(!1)}},[t,e]);Y.useEffect(()=>{_()},[_]);let v=Y.useMemo(()=>new Set(a.map(e=>e.userId)),[a]),y=Y.useCallback(async e=>{if(r){m(!0),g(null);try{for(let n of e||[]){let e=n?.id==null?null:String(n.id);e&&!v.has(e)&&await t.create(`sys_user_permission_set`,{permission_set_id:r,user_id:e})}await _()}catch(e){let t=String(e?.body?.error??e?.error??e?.message??``),r=t.match(/(\d+)\s*of\s*(\d+)\s*seat/i);if(/cap reached|seat cap|ai[-_ ]?seat/i.test(t))g(n.seatFull(r?Number(r[2]):a.length));else{let e=t.replace(/^\s*\[[^\]]*\]\s*/,``).trim();g(e||n.addFailed)}}finally{m(!1),f(!1)}}},[t,r,v,_,a.length,n]),b=Y.useCallback(async e=>{g(null);try{await t.delete(`sys_user_permission_set`,e),await _()}catch{}},[t,_]);return(0,X.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(xt,{className:`h-4 w-4 text-muted-foreground`}),(0,X.jsx)(`span`,{children:n.title}),!l&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground font-normal`,children:n.countOf(a.length)})]}),(0,X.jsxs)(F,{variant:`outline`,size:`sm`,disabled:p||!r,onClick:()=>{g(null),f(!0)},className:`gap-1 h-8 text-xs`,children:[p?(0,X.jsx)(K,{className:`h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(mt,{className:`h-3.5 w-3.5`}),n.add]})]}),h&&(0,X.jsxs)(`div`,{className:`mb-3 flex items-start gap-2 rounded-md border border-amber-300/60 bg-amber-50 dark:bg-amber-950/30 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,role:`alert`,children:[(0,X.jsx)(ct,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,X.jsx)(`span`,{children:h})]}),s&&(0,X.jsxs)(`div`,{className:`mb-3 flex items-start gap-2 rounded-md border bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(xt,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,X.jsx)(`span`,{children:n.everyoneNote})]}),l?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground py-3`,children:[(0,X.jsx)(K,{className:`h-3.5 w-3.5 animate-spin`}),n.loading]}):a.length===0?!s&&(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground italic py-3`,children:n.empty}):(0,X.jsx)(`ul`,{className:`divide-y rounded-md border`,children:a.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-primary/10 text-primary text-xs font-medium shrink-0`,children:(e.name||`?`).slice(0,1).toUpperCase()}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-sm truncate`,children:e.name}),e.via.map((e,t)=>(0,X.jsx)(`span`,{className:`shrink-0 rounded border bg-muted/40 px-1.5 py-0.5 text-[10px] leading-none text-muted-foreground`,children:e.kind===`direct`?n.direct:n.viaPosition(e.position)},t))]}),e.email&&e.email!==e.name&&(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.email})]}),e.grantId?(0,X.jsx)(F,{variant:`ghost`,size:`sm`,onClick:()=>void b(e.grantId),"aria-label":n.remove,title:n.remove,className:`h-7 w-7 p-0 text-muted-foreground hover:text-destructive shrink-0`,children:(0,X.jsx)(St,{className:`h-4 w-4`})}):(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,title:n.positionHeldHint,children:`—`})]},e.userId))}),r&&(0,X.jsx)(he,{open:d,onOpenChange:e=>f(e),multiple:!0,dataSource:t,objectName:`sys_user`,title:n.pickTitle,onSelect:()=>{},onSelectRecords:e=>void y(e)})]})}function ia(){let e=z()?.data?.name;return!e||typeof e!=`string`?null:(0,X.jsx)(I,{className:`overflow-hidden`,children:(0,X.jsx)(ra,{permissionSetName:e})})}var aa=new Set([`id`,`_id`,`created_at`,`created_by`,`updated_at`,`updated_by`]),oa=new Set([`organization_id`,`tenant_id`,`is_deleted`,`deleted_at`,`space`]),sa=new Set([`formula`,`summary`,`rollup`,`autonumber`,`auto_number`]),ca=e=>e==null||e===``||Array.isArray(e)&&e.length===0,la=e=>{try{return JSON.stringify(e)??`undefined`}catch{return String(e)}};function ua(e){if(!e)return null;if(typeof e==`object`)return e;if(typeof e==`string`)try{let t=JSON.parse(e);return t&&typeof t==`object`?t:null}catch{return null}return null}function da(e,t,n){let r=new Set([...Object.keys(e??{}),...Object.keys(t??{})]),i=[];for(let a of r){if(aa.has(a)||oa.has(a))continue;let r=n?.[a];if(r&&(r.hidden===!0||typeof r.type==`string`&&sa.has(r.type)))continue;let o=e?.[a],s=t?.[a];ca(o)&&ca(s)||la(o)!==la(s)&&i.push({field:a,from:o,to:s})}return i}function fa(e){let t=e?.reference;return typeof t==`string`&&t.length>0?t:null}var pa=e=>e==null||e===``?[]:(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`||typeof e==`number`?String(e):typeof e==`object`&&e&&`id`in e?String(e.id):null).filter(e=>!!e);function ma(e,t){let n=new Map;for(let r of e){let e=fa(t?.[r.field]);if(!e)continue;let i=[...pa(r.from),...pa(r.to)];if(i.length===0)continue;let a=n.get(e);a||n.set(e,a=new Set);for(let e of i)a.add(e)}return n}function ha(e,t,n){let r=e?.type;if(r===`boolean`||typeof t==`boolean`){let e=t===!0||t===`true`||t===1,r=e?`common.yes`:`common.no`,i=e?`Yes`:`No`;return n.t?n.t(r,{defaultValue:i}):i}if(r===`date`||r===`datetime`){let e=Ze(t);if(!Number.isNaN(e.getTime()))try{return r===`date`?e.toLocaleDateString(n.locale):e.toLocaleString(n.locale,{dateStyle:`medium`,timeStyle:`short`})}catch{return String(t)}return String(t)}if(Array.isArray(e?.options))for(let n of e.options){let e=n&&typeof n==`object`?n.value??n.name:n;if(e===t||String(e)===String(t)){let t=n&&typeof n==`object`?n.label??n.name??e:n;return String(t)}}let i=fa(e);if(i){let e=n.lookupLabels?.get(i)?.get(String(t));if(e)return e}return typeof t==`object`&&t?la(t):String(t)}function ga(e,t,n={}){return ca(t)?``:Array.isArray(t)?t.map(t=>ha(e,t,n)).join(`, `):ha(e,t,n)}var _a=t({RecordDetailView:()=>Oa,isSecondaryField:()=>Sa,resolveActionUser:()=>ya,resolveRecordHeaderActionGates:()=>Ta}),va={id:`current-user`,name:`Demo User`};function ya(e,t,n){let r=e?{id:e.id,name:e.name,avatar:e.image}:va;return t?{...r,systemPermissions:n}:r}var ba=[`description`,`notes`,`note`,`remark`,`remarks`,`comments`],xa=new Set([`textarea`,`markdown`,`html`,`richtext`,`json`,`code`]);function Sa(e,t){if(xa.has(t?.type))return!0;let n=e.toLowerCase();return ba.some(e=>n===e||n.endsWith(`_${e}`))}var Ca=[];function wa(e,t){let n=new Map;for(let r of[...e,...t])n.set(String(r.id),r);return Array.from(n.values()).sort((e,t)=>(e.createdAt?Date.parse(e.createdAt):0)-(t.createdAt?Date.parse(t.createdAt):0))}function Ta(e,t){let n=De(e,t);return{edit:n.edit,delete:n.delete}}var Ea=new WeakMap;function Da(e,t,n){let r=_e(e,t,n);if(r===e||!e||typeof e!=`object`)return r;let i=JSON.stringify(Object.keys(r)),a=Ea.get(e);return a&&a.kept===i?a.row:(Ea.set(e,{kept:i,row:r}),r)}function Oa({dataSource:e,objects:t,onEdit:o,objectNameOverride:c,recordIdOverride:d,embedded:f}){let p=i(),m=p.appName,h=c??p.objectName,g=d??p.recordId,{showDebug:_}=Vt(),{user:y,activeOrganization:b}=u(),x=n(),[S,C]=r(),w=S.get(`tab`)??void 0,E=s(),ee=(0,Y.useCallback)(e=>{let t=new URLSearchParams(window.location.search);t.get(`tab`)!==e&&(t.set(`tab`,e),C(t,{replace:!0,state:E.state}))},[C,E.state]),D=E.state?.from,O=(0,Y.useMemo)(()=>{if(D?.pathname&&D?.label)return D;let e=Rr(new URLSearchParams(E.search).get(Ir)),t=e[e.length-1];if(!t)return;let n=m?`/apps/${m}`:``,r=t.i.length>12?`${t.i.slice(0,8)}…`:t.i;return{pathname:Vr(n,t,e.slice(0,-1)),label:t.t||`#${r}`}},[D,E.search,m]),{t:k,language:ne}=W(),A=it(),{objectLabel:j,viewLabel:re,sectionLabel:ie,actionParamText:M,actionParamOptionLabel:ae,actionDescription:oe,actionResultDialog:se,fieldLabel:ce,fieldOptionLabel:N}=nt(),le=Ne(),{isFavorite:P,toggleFavorite:ue,refreshLabel:de}=tr(),{addRecentItem:fe}=Ot(),[F,pe]=(0,Y.useState)(!0),[he,ge]=(0,Y.useState)({}),[I,_e]=(0,Y.useState)([]),[ve,xe]=(0,Y.useState)(null),[Ce,we]=(0,Y.useState)({open:!1}),[Te,Ee]=(0,Y.useState)(null),[De,Oe]=(0,Y.useState)(!1),[L,je]=(0,Y.useState)(),R=t.find(e=>e.name===h);Wn(f?void 0:L);let z=g,Pe=Be(h||void 0,z||void 0),B=(0,Y.useCallback)(()=>{h&&Ue({objectName:h,recordId:z||void 0})},[h,z]),Le=(0,Y.useCallback)(()=>{Ue({objectName:`*`})},[]),ze=f?void 0:Le,V=kr(h,z),H=(0,Y.useMemo)(()=>!h||!z?null:{id:`record:${h}:${z}`,label:L||z||``,href:`/apps/${m}/${h}/record/${z}`,type:`record`},[m,h,z,L]),He=H?P(H.id):!1,We=(0,Y.useCallback)(()=>{H&&ue(H)},[H,ue]),{page:Ke,slots:qe}=Ie(h),Je=(0,Y.useMemo)(()=>Ke||!R?null:Pt(R,qe?{slots:qe}:void 0),[Ke,qe,R]),Xe=Ke||Je,[U,Ze]=(0,Y.useState)(null),[Qe,tt]=(0,Y.useState)(`idle`),rt=v();(0,Y.useEffect)(()=>{let t=!1;if(!Xe||!z||!h||!e?.findOne){Ze(null),tt(`idle`);return}let n=$e(R?.fields),r=rt?.isLoaded?n.filter(e=>rt.checkField(h,e,`read`)):n,i=r.length>0?{$expand:r}:void 0,a=()=>{tt(`loading`),(i?e.findOne(h,z,i):e.findOne(h,z)).then(e=>{t||(e&&typeof e==`object`?(Ze(e),tt(`loaded`)):(Ze(null),tt(`missing`)))}).catch(()=>{t||(Ze(null),tt(`missing`))})};a();let o=e=>{let t=e.detail||{};t.objectName===h&&String(t.recordId)===String(z)&&a()};return window.addEventListener(`objectui:record-changed`,o),()=>{t=!0,window.removeEventListener(`objectui:record-changed`,o)}},[Xe,h,z,e,R,Pe,rt]);let at=Da(U,rt,h);(0,Y.useEffect)(()=>{if(!at||typeof at!=`object`||!R)return;let e=Ae(R,at);e&&e!==`Untitled`&&e!==L&&je(e)},[at,R,L]),(0,Y.useEffect)(()=>{if(!h||!z||!m||!L)return;let e=`record:${h}:${z}`,t=`/apps/${m}/${h}/record/${z}`;fe({id:e,label:L,href:t,type:`record`}),de(e,L)},[m,h,z,L,fe,de]);let[ot,ct]=(0,Y.useState)({open:!1,message:``}),[lt,dt]=(0,Y.useState)({open:!1,params:[]}),[K,ft]=(0,Y.useState)({open:!1}),pt=(0,Y.useCallback)((e,t,n)=>new Promise(r=>{let i=typeof n?.objectName==`string`&&n.objectName?n.objectName:h||R?.name,a=se(i,n?.name,e)??e;ft({open:!0,spec:a,data:t,resolve:r})}),[h,R,se]),mt=(0,Y.useCallback)((e,t)=>new Promise(n=>{ct({open:!0,message:e,options:t,resolve:n})}),[]),ht=(0,Y.useCallback)((e,n)=>new Promise(r=>{let i=typeof n?.objectName==`string`&&n.objectName?n.objectName:void 0,a=n?.params&&!Array.isArray(n.params)?n.params._rowRecord:void 0,o=vn(e,{objectName:i||h||R?.name||``,objects:t||[],fieldLabel:ce,fieldOptionLabel:N,row:a,locale:ne}),s=i||h||R?.name,c=o.map(e=>({...e,label:M(s,n?.name,e.name,`label`,e.label)??e.label,placeholder:M(s,n?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:M(s,n?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(t=>({...t,label:ae(s,n?.name,e.name,t.value,t.label)})):e.options}));dt({open:!0,params:c,title:n?.label,description:oe(s,n?.name,n?.description),resolve:r})}),[h,R,t,ce,N,M,ae]),gt=be({dataSource:e,onUndo:e=>{e?.objectName?Ue({objectName:e.objectName,recordId:e.recordId}):B(),G.success(`Change undone`)}}),_t=(0,Y.useCallback)((e,t)=>{if(t?.type===`error`){G.error(e);return}if(t?.undo){G.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{gt.undo()}}});return}G.success(e,{duration:t?.duration})},[gt]),vt=(0,Y.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):x(e)},[x]),q=(0,Y.useMemo)(()=>l(),[]),yt=(0,Y.useCallback)(async t=>{try{let n=t.target||t.name,r=t.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,i={...t.params||{}};delete i._rowRecord;let a=typeof n==`string`?n:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let e=r??(!t.objectName||t.objectName===h?U??void 0:void 0),n=a;e&&/\{[a-z_][a-z0-9_]*\}/i.test(n)&&(n=n.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(t,n)=>{let r=e[n];return r==null?``:encodeURIComponent(String(r))}));let o=n.startsWith(`http`)?n:`${n}`,s=t.bodyShape&&typeof t.bodyShape==`object`&&t.bodyShape.wrap?t.bodyShape.wrap:void 0,c=s?{[s]:i}:{...i};if(t.recordIdParam){let e=t.recordIdField||`id`,n=t.recordId,i=!!r&&r[e]!=null;if(!i&&n!=null)c[t.recordIdParam]=n;else{let e=!t.objectName||t.objectName===h?U??(z==null?void 0:{id:z}):void 0,n=Re(t,i?r:e??r);if(n.error)return{success:!1,error:n.error};n.value!==void 0&&(c[t.recordIdParam]=n.value)}}/\/api\/v1\/auth\//.test(n)&&!c.organizationId&&b?.id&&(c.organizationId=b.id),t.bodyExtra&&typeof t.bodyExtra==`object`&&Object.assign(c,t.bodyExtra);let l=(t.method||`POST`).toUpperCase(),u={method:l,headers:{"Content-Type":`application/json`},credentials:`include`};l!==`GET`&&l!==`DELETE`&&(u.body=JSON.stringify(c));let d=await q(o,u);if(!d.ok){let e=null;try{e=await d.json()}catch{}let t=e?.error?.message||e?.error||e?.message||`HTTP ${d.status}`;return{success:!1,error:typeof t==`string`?t:`HTTP ${d.status}`}}let f=await d.json().catch(()=>({}));return t.refreshAfter===!0&&B(),{success:!0,data:f,reload:t.refreshAfter===!0}}t.bodyExtra&&typeof t.bodyExtra==`object`&&Object.assign(i,t.bodyExtra);let o;switch(n){case`opportunity_change_stage`:await e.update(h,z,{stage:i.new_stage});break;case`opportunity_mark_won`:await e.update(h,z,{stage:`closed_won`});break;case`opportunity_mark_lost`:await e.update(h,z,{stage:`closed_lost`,loss_reason:i.loss_reason});break;default:{let n=t.objectName??h,r=t.recordId??z,a=n===h&&String(r)===String(z);if(Object.keys(i).length>0&&n&&r!=null){if(t.undoable&&a&&U){let e={};for(let t of Object.keys(i))e[t]=U[t]??null;o={id:`undo-${n}-${r}-${Date.now()}`,type:`update`,objectName:n,recordId:String(r),timestamp:Date.now(),description:t.label||`Undo ${n}`,undoData:e,redoData:{...i}}}await e.update(n,String(r),i)}break}}let s=t.refreshAfter===!0;return(s||o)&&B(),{success:!0,reload:s,undo:o}}catch(e){return{success:!1,error:e.message}}},[e,h,z,U,q,b]),{modalHandler:bt,modalElement:xt,resolveModalTarget:St}=Mt(e),Ct=(0,Y.useCallback)(async e=>{let t=e.target||e.name;if(!t)return{success:!1,error:`No flow target provided for flow action`};try{let n={...e.params&&!Array.isArray(e.params)?e.params:{}};delete n._rowRecord;let r=await q(`/api/v1/automation/${encodeURIComponent(t)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:e.recordId??z,objectName:e.objectName??h,params:n})}),i=rn(nn(r,await r.json().catch(()=>null),`Flow "${t}"`),e.refreshAfter);return i.followUp?.kind===`screen`&&xe({flowName:t,runId:i.followUp.runId,screen:i.followUp.screen}),i.followUp?.kind===`refusal`&&we({open:!0,title:e.label,message:i.followUp.message}),i.refresh&&B(),i.result}catch(e){return{success:!1,error:e.message}}},[q,z,h]),wt=(0,Y.useRef)({objectName:h,pureRecordId:z,notifyRecordChanged:B,t:k,navigate:x});wt.current={objectName:h,pureRecordId:z,notifyRecordChanged:B,t:k,navigate:x};let Tt=(0,Y.useMemo)(()=>In({fetch:q,baseUrl:()=>``,resolveObject:()=>wt.current.objectName,resolveRecordId:e=>({recordId:e.recordId??wt.current.pureRecordId??void 0}),onRefresh:()=>wt.current.notifyRecordChanged(),navigate:e=>wt.current.navigate(e),t:(e,t)=>String(wt.current.t(e,t))}),[q]),Et=(0,Y.useCallback)(async e=>{let t=e.modal??e.target??e.params?.schema,n=t==null?null:await St(t);return n?bt(n):{success:!1,error:jt({actionName:e.name,target:t,serverHandlerHint:!0})}},[St,bt]),J=Xr(h,z),At=(0,Y.useRef)(J);At.current=J;let Bt=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{if(!Bt.current){Bt.current=!0;return}At.current.refresh()},[Pe]);let Ut=U?.approval_status===`pending`||U?.approval_status===`in_approval`,qt=Ut||!!J.pendingRequest,Jt=J.pendingRequest?Ur(J.pendingRequest):Ut,Yt=J.pendingRequest?.decision_progress,Xt=Wr(J.pendingRequest,y?.id),Zt=(0,Y.useCallback)(()=>{At.current.refresh(),B()},[B]),{can:Qt,isLoaded:$t,getObjectApiOperations:en,systemPermissions:tn}=rt,an=(0,Y.useMemo)(()=>R?en(R.name):void 0,[R,en]),on=(0,Y.useMemo)(()=>or(R,t,{canRead:$t?e=>Qt(e,`read`):void 0}),[R,t,Qt,$t]),sn=Lt(R?.name,z,`update`,!!R?.name&&!!z),un=Lt(R?.name,z,`delete`,!!R?.name&&!!z),dn=(0,Y.useMemo)(()=>ke(R?.userActions?.edit),[R]),fn=(0,Y.useMemo)(()=>ke(R?.userActions?.delete),[R]),pn=R?.fields,mn=Se(dn?.visibleWhen??!0,U,{fallback:!1,warnOnError:!0,label:`builtin:edit:visibleWhen`,fields:pn}),hn=Se(fn?.visibleWhen??!0,U,{fallback:!1,warnOnError:!0,label:`builtin:delete:visibleWhen`,fields:pn}),gn=Se(dn?.disabledWhen,U,{fallback:!1,warnOnError:!0,label:`builtin:edit:disabledWhen`,fields:pn}),_n=Se(fn?.disabledWhen,U,{fallback:!1,warnOnError:!0,label:`builtin:delete:disabledWhen`,fields:pn}),yn=dn?.disabledWhen!=null&&gn,bn=fn?.disabledWhen!=null&&_n,xn=(0,Y.useMemo)(()=>!R||R.name===`sys_audit_log`||R.enable?.trackHistory!==!0?!1:t.some(e=>e.name===`sys_audit_log`),[R,t]),Sn=R?.enable?.feeds!==!1,Cn=R?.enable?.activities!==!1,wn=R?.enable?.files===!0;(0,Y.useEffect)(()=>{if(!e||!z||!R||!xn){Ee(null);return}let n=!1;Oe(!0);let r=!!t.find(e=>e.name===`sys_audit_log`)?.fields?.actor;return e.find(`sys_audit_log`,{$filter:{record_id:z,object_name:R.name},$orderby:{created_at:`desc`},$top:50,$select:[`id`,`created_at`,`action`,`user_id`,...r?[`actor`]:[],`old_value`,`new_value`]}).then(async r=>{if(n)return;let i=Array.isArray(r)?r:r?.data||[],a=Array.from(new Set(i.map(e=>e?.user_id).filter(e=>typeof e==`string`&&e.length>0))),o=new Map;if(a.length>0)try{let t=await e.find(`sys_user`,{$filter:{id:{$in:a}},$top:a.length,$select:[`id`,`name`,`email`,`image`]}),n=Array.isArray(t)?t:t?.data||[];o=new Map(n.map(e=>[e.id,{name:e.name||e.email||null,image:e.image||null}]))}catch(e){console.warn(`[RecordDetailView] Failed to resolve audit user names:`,e)}let s={};for(let[e,t]of Object.entries(R.fields||{}))t?.label&&(s[e]=t.label);let c=i.map(e=>da(ua(e?.old_value),ua(e?.new_value),R.fields)),l=ma(c.flat(),R.fields),u=new Map;if(await Promise.all(Array.from(l.entries()).map(async([n,r])=>{let i=t.find(e=>e.name===n),a=Rt(i)??`name`;try{let t=await e.find(n,{$filter:{id:{$in:Array.from(r)}},$top:r.size,$select:[`id`,a]}),i=Array.isArray(t)?t:t?.data||[];u.set(n,new Map(i.filter(e=>e?.id!=null&&typeof e?.[a]==`string`&&e[a]).map(e=>[String(e.id),e[a]])))}catch(e){console.warn(`[RecordDetailView] Failed to resolve audit lookup labels for ${n}:`,e)}})),n)return;let d={t:k,locale:A,lookupLabels:u},f=i.map((e,t)=>{let n=e?.user_id?o.get(e.user_id):void 0,r=typeof e?.actor==`string`&&e.actor.trim()&&e.actor!==e?.user_id?e.actor.trim():null,i=r?.startsWith(`svc:`)?k(`detail.systemActor`,{defaultValue:`System`}):r,a=c[t].map(e=>({field:e.field,label:s[e.field]||e.field,from:ga(R.fields?.[e.field],e.from,d),to:ga(R.fields?.[e.field],e.to,d)}));return{...e,user_name:n?.name??i,user_avatar:n?.image??null,changes:a.length>0?a:void 0}});Ee(f)}).catch(e=>{n||(console.warn(`[RecordDetailView] Failed to fetch sys_audit_log:`,e),Ee([]))}).finally(()=>{n||Oe(!1)}),()=>{n=!0}},[e,z,R,xn,t,ne,A]),(0,Y.useEffect)(()=>{if(!e)return;let t=!1,n=y?[{id:String(y.id),label:y.name||y.email||String(y.id),avatarUrl:y.image||void 0}]:[];return(async()=>{try{let r=await e.find(`sys_user`,{$top:50,$select:[`id`,`name`,`email`,`image`]});if(t)return;let i=(Array.isArray(r)?r:r?.data||[]).map(e=>({id:String(e.id),label:e.name||e.email||String(e.id),avatarUrl:e.image||void 0})).filter(e=>e.label),a=new Set(n.map(e=>e.id)),o=[...n,...i.filter(e=>!a.has(e.id))];_e(o.length>0?o:n)}catch{if(t)return;_e(n)}})(),()=>{t=!0}},[e,y?.id,y?.name,y?.email]);let Z=(0,Y.useMemo)(()=>ya(y,$t,tn),[y?.id,y?.name,y?.image,$t,tn]),Q=h&&z?`${h}:${z}`:null,Tn=(Q?he[Q]:void 0)??Ca,En=e&&Q&&(Sn||Cn)?Q:null,[Dn,On]=(0,Y.useState)(null),kn=En!==null&&Dn!==En;(0,Y.useEffect)(()=>{if(!e||!h||!z)return;let t=!1,n=`${h}:${z}`,r=[],i=e=>{if(!e)return;let t;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return}else typeof e==`object`&&(t=e);if(t)return Object.entries(t).map(([e,t])=>({emoji:e,count:Array.isArray(t)?t.length:0,reacted:Array.isArray(t)&&t.includes(Z.id)}))};return Sn&&r.push(e.find(`sys_comment`,{$filter:{thread_id:n},$orderby:{created_at:`asc`}}).then(e=>{if(!e?.data?.length)return;let t=e.data.map(e=>({id:e.id,type:`comment`,actor:e.author_name??k(`detail.unknownUser`,{defaultValue:`Unknown`}),actorAvatarUrl:e.author_avatar_url??void 0,body:e.body??``,createdAt:e.created_at,updatedAt:e.updated_at,parentId:e.parent_id??void 0,reactions:i(e.reactions)}));ge(e=>({...e,[n]:wa(e[n]??Ca,t)}))}).catch(()=>{})),Cn&&r.push(e.find(`sys_activity`,{$filter:{object_name:h,record_id:z},$orderby:{timestamp:`asc`},$top:200}).then(e=>{if(!e?.data?.length)return;let t=k(`detail.systemActor`,{defaultValue:`System`}),r=[];for(let n of e.data){let e=zt(n,t);e&&r.push(e)}r.length&&ge(e=>({...e,[n]:wa(e[n]??Ca,r)}))}).catch(()=>{})),Promise.allSettled(r).then(()=>{t||On(En)}),()=>{t=!0}},[e,h,z,Z,Sn,Cn,En]);let An=(0,Y.useCallback)(async t=>{let n={id:crypto.randomUUID(),type:`comment`,actor:Z.name,actorAvatarUrl:`avatar`in Z?Z.avatar:void 0,body:t,createdAt:new Date().toISOString()};if(Q&&ge(e=>({...e,[Q]:[...e[Q]??Ca,n]})),e){let r=`${h}:${z}`,i=Nt(t,I);e.create(`sys_comment`,{id:n.id,thread_id:r,author_id:Z.id,author_name:Z.name,author_avatar_url:`avatar`in Z?Z.avatar:void 0,body:t,mentions:JSON.stringify(i),created_at:n.createdAt}).catch(()=>{})}},[Z,e,h,z,Q,I]),jn=(0,Y.useCallback)(async(t,n)=>{let r={id:crypto.randomUUID(),type:`comment`,actor:Z.name,actorAvatarUrl:`avatar`in Z?Z.avatar:void 0,body:n,createdAt:new Date().toISOString(),parentId:t};if(Q&&ge(e=>{let n=[...e[Q]??Ca,r];return{...e,[Q]:n.map(e=>e.id===t?{...e,replyCount:(e.replyCount??0)+1}:e)}}),e){let i=`${h}:${z}`,a=Nt(n,I);e.create(`sys_comment`,{id:r.id,thread_id:i,author_id:Z.id,author_name:Z.name,author_avatar_url:`avatar`in Z?Z.avatar:void 0,body:n,mentions:JSON.stringify(a),created_at:r.createdAt,parent_id:t}).catch(()=>{})}},[Z,e,h,z,Q,I]),Mn=(0,Y.useCallback)((t,n)=>{Q&&ge(r=>({...r,[Q]:(r[Q]??Ca).map(r=>{if(r.id!==t)return r;let i=[...r.reactions??[]],a=i.findIndex(e=>e.emoji===n);if(a>=0){let e=i[a];e.reacted?e.count<=1?i.splice(a,1):i[a]={...e,count:e.count-1,reacted:!1}:i[a]={...e,count:e.count+1,reacted:!0}}else i.push({emoji:n,count:1,reacted:!0});let o={...r,reactions:i};if(e){let n=Z.id,r={};for(let e of i){let t=[];for(e.reacted&&t.push(n);t.length<e.count;)t.push(`__other__`);r[e.emoji]=t}e.update(`sys_comment`,String(t),{reactions:JSON.stringify(r)}).catch(()=>{})}return o})}))},[Z.id,e,Q]);(0,Y.useEffect)(()=>{pe(!0),queueMicrotask(()=>pe(!1))},[h,g]);let $=(0,Y.useMemo)(()=>{if(!R)return{};let e=(()=>{let e=e=>{let t=R.fields[e],n=t.reference;return{name:e,label:t.label||e,type:t.type||`text`,...t.options&&{options:t.options},...n&&{reference_to:n},...t.reference_field&&{reference_field:t.reference_field},...t.currency&&{currency:t.currency}}},t=t=>{let n=t.filter(e=>!Sa(e,R.fields[e])),r=t.filter(e=>Sa(e,R.fields[e]));return r.length===0||n.length===0?[{showBorder:!1,fields:t.map(e)}]:[{showBorder:!1,fields:n.map(e)},{name:`details`,label:ie(R.name,`details`,k(`detail.sectionMoreDetails`,`More details`)),collapsible:!0,defaultCollapsed:!1,showBorder:!0,fields:r.map(e)}]},n=Ft(R);return n?n.flatMap(e=>e.name?[{...e,label:ie(R.name,e.name,e.label),showBorder:!0}]:t(e.fields.map(e=>e.name))):t(Object.keys(R.fields||{}).filter(e=>!Ge.has(e)&&!fi.has(e)&&!R.fields[e]?.hidden))})(),n=(()=>{let e=new Set;return(R.actions||[]).filter(t=>!t.locations?.includes(`record_header`)&&!t.locations?.includes(`record_more`)?!1:!t.name||!e.has(t.name)&&(e.add(t.name),!0)).map(e=>le(R.name,e))})(),r=R.highlightFields??[],i=Rt(R),a=(Array.isArray(r)?r:[]).map(e=>typeof e==`string`?e:e?.name).filter(e=>typeof e==`string`&&e.length>0&&e!==i),o=on.map(({childObject:e,childLabel:n,referenceField:r,title:i,columns:a,isPrimary:o,sort:s,filter:c})=>{let l=t.find(t=>t.name===e);return{title:i||(l?j({name:l.name,label:l.label||n}):n),objectName:e,relationshipField:r,...Array.isArray(a)&&a.length>0?{columns:a}:{},...s&&s.length>0?{sort:s}:{},...c?{filter:c}:{},...l?.icon?{icon:l.icon}:{},...o?{isPrimary:!0}:{}}});return{sections:e,highlightFields:a.length>0?a:void 0,headerActions:n.length>0?n:void 0,related:o.length>0?o:void 0,...xn&&{history:{entries:Te??[],loading:De&&Te===null,unknownUserText:k(`detail.unknownUser`,{defaultValue:`Unknown`})}},...J.available&&J.requests.length>0&&{approvals:{count:J.requests.length,node:{approvals:{available:J.available,requests:J.requests,pendingRequest:J.pendingRequest},currentUserId:y?.id}}}}},[R?.name,on,k,j,t,xn,Te,De,J.available,J.pendingRequest,J.requests,y?.id]);if(F)return(0,X.jsx)(Gt,{});if(!R)return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,X.jsxs)(me,{children:[(0,X.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,X.jsx)(ut,{className:`h-6 w-6 text-muted-foreground`})}),(0,X.jsx)(T,{children:k(`empty.objectNotFound`)}),(0,X.jsx)(te,{children:k(`empty.objectNotFoundDescription`,{name:h})})]})});if(Qe===`missing`)return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,X.jsxs)(me,{children:[(0,X.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,X.jsx)(ut,{className:`h-6 w-6 text-muted-foreground`})}),(0,X.jsx)(T,{children:k(`empty.recordNotFound`,{defaultValue:`Record not found`})}),(0,X.jsx)(te,{children:k(`empty.recordNotFoundDescription`,{defaultValue:`The record you are looking for does not exist or may have been deleted.`})})]})});let Nn=ii(Xe),Pn=(()=>{let t=Ta(R,an),n={edit:t.edit&&sn&&mn,delete:t.delete&&un&&hn},r=[];return n.edit&&r.push({name:`sys_edit`,label:k(`detail.edit`,{defaultValue:`Edit`}),type:`script`,locations:[`record_header`],variant:`default`,order:100,disableDuringInlineEdit:!0,disabled:Jt||yn,onClick:()=>o({id:z})}),r.push({name:`sys_share`,label:k(`detail.share`,{defaultValue:`Share`}),type:`script`,locations:[`record_header`],variant:`outline`,order:110,component:`action:menu`,onClick:async()=>{try{if(navigator.share){await navigator.share({title:document.title,url:window.location.href});return}}catch{return}try{await navigator.clipboard.writeText(window.location.href),G.success(k(`detail.linkCopied`,{defaultValue:`Link copied to clipboard`}))}catch(e){G.error(k(`detail.linkCopyFailed`,{defaultValue:`Failed to copy link`})+(e?.message?`: ${e.message}`:``))}}}),n.delete&&r.push({name:`sys_delete`,label:k(`detail.delete`,{defaultValue:`Delete`}),type:`script`,locations:[`record_header`],variant:`destructive`,order:120,component:`action:menu`,...bn?{disabled:!0}:null,onClick:async()=>{let t=k(`detail.deleteConfirmation`,{defaultValue:`Are you sure you want to delete this record?`});if(window.confirm(t))try{await e.delete(h,z),G.success(k(`detail.deleted`,{defaultValue:`Record deleted`}));let t=m?`/apps/${m}`:``;x(`${t}/${h}`,{replace:!0})}catch(e){G.error(e?.message||`Delete failed`)}}}),r})(),Fn=Ke?Xe:Pt(R,{sections:$.sections,highlightFields:$.highlightFields,headerActions:$.headerActions,related:$.related,history:$.history,approvals:$.approvals,...qe?{slots:qe}:{}}),Ln=Sn?Fn:ri(Fn),Rn=ai(Ln);return(0,X.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,X.jsxs)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:[V.length>0&&(0,X.jsx)(Er,{users:V,size:`sm`,maxVisible:3,showStatus:!0}),(0,X.jsx)(Wt,{managedBy:R?.managedBy})]}),(0,X.jsx)(ye,{objectName:h,recordId:z,data:at,objectSchema:R,dataSource:e,embedded:f,refresh:ze,headerSystemActions:Pn,isFavorite:He,onToggleFavorite:H?We:void 0,children:(0,X.jsx)(Fe,{canEdit:Ta(R,an).edit&&sn&&!Jt&&mn&&!yn,locked:Jt,approvalPending:qt,approvalProgress:Yt,approvalIsSubmitter:Xt,lockedReason:k(`detail.lockedTooltip`,{defaultValue:`This record has a pending approval request; editing is locked`}),children:(0,X.jsx)(Me,{children:(0,X.jsx)(et,{items:Tn,loading:kn,onAddComment:An,onAddReply:jn,onToggleReaction:Mn,mentionSuggestions:I,children:(0,X.jsxs)(Ye,{context:{record:U||{},objectName:h,user:Z},onConfirm:mt,onToast:_t,onNavigate:vt,onParamCollection:ht,onResultDialog:pt,onModal:bt,handlers:{api:yt,flow:Ct,script:Tt,modal:Et},children:[(0,X.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,X.jsxs)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:[O?.pathname&&O?.label&&(0,X.jsxs)(a,{to:O.pathname,className:`inline-flex items-center gap-1 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,X.jsx)(st,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{children:O.label})]}),J.available&&J.pendingRequest&&(0,X.jsx)(Zi,{className:`mb-4`,objectName:`sys_approval_request`,record:J.pendingRequest,location:`record_section`,exclude:[...Qi],onDone:Zt}),(0,X.jsx)(li,{appName:m,objects:t,dataSource:e,parentObjectName:h,parentRecordId:z??void 0,parentTitle:L,parentRecord:U,parentObjectFields:pn,children:(0,X.jsx)(Ve,{schema:di(Ln,{defaultTab:w,onTabChange:ee})})}),z&&!Rn&&(0,X.jsx)(Ui,{className:`mt-6`,approvals:J,currentUserId:y?.id}),h===`sys_permission_set`&&z&&(0,X.jsx)(`div`,{className:`mt-6`,children:(0,X.jsx)(ia,{})}),wn&&!Nn&&z&&(0,X.jsx)(`div`,{className:`mt-6`,children:(0,X.jsx)(mi,{objectName:h,recordId:z,dataSource:e,currentUserId:Z?.id})}),(0,X.jsx)(It,{dataSource:e,objectName:h,recordId:z,data:U,refresh:B,fieldLabelFor:e=>R?.fields?.[e]?.label||ce(h||``,e,e),locked:Jt,lockedHint:k(`detail.lockedTooltip`,{defaultValue:`This record has a pending approval request; editing is locked`})})]}),(0,X.jsx)(Ht,{open:_,sections:[{title:`Page Schema`,data:Ln}]})]}),xt]})})})})}),(0,X.jsx)(Kt,{state:ot,onOpenChange:e=>{e||ct(e=>({...e,open:!1}))}}),(0,X.jsx)(Dt,{state:lt,onOpenChange:e=>{e||dt(e=>({...e,open:!1}))}}),(0,X.jsx)(kt,{state:K,onAcknowledge:()=>{K.resolve?.(),ft({open:!1})}}),(0,X.jsx)(cn,{state:ve,authFetch:q,baseUrl:``,dataSource:e,objects:t,onClose:()=>xe(null),onComplete:()=>{xe(null),B()}}),(0,X.jsx)(ln,{state:Ce,onClose:()=>we(e=>({...e,open:!1}))})]})}export{Zt as A,Un as C,En as D,Tn as E,Jt as M,Xt as N,cn as O,Yt as P,Hn as S,zn as T,yr as _,Hr as a,er as b,Ar as c,jr as d,Ir as f,Er as g,Or as h,mi as i,qt as j,Qt as k,Nr as l,Rr as m,_a as n,Pr as o,Vr as p,Zi as r,Fr as s,Oa as t,Mr as u,mr as v,Bn as w,tr as x,pr as y};