@objectstack/console 17.3.0 → 17.4.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 (188) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/dist/.objectui-sha +1 -1
  3. package/dist/assets/{ActionResultDialog-CQwenjVA.js → ActionResultDialog-Bsr2GS71.js} +1 -1
  4. package/dist/assets/{AiPendingActionsPage-7gZ8zlOy.js → AiPendingActionsPage-DB-UVcdM.js} +1 -1
  5. package/dist/assets/{ApiConsolePage-DUF0ysH7.js → ApiConsolePage-Bzqo2owc.js} +1 -1
  6. package/dist/assets/{AppDocsIndex-CP_AVG4X.js → AppDocsIndex-KhVqdZ-P.js} +1 -1
  7. package/dist/assets/{AppManagementPage-BJktnoa5.js → AppManagementPage-CsZ0LMQn.js} +1 -1
  8. package/dist/assets/{ApprovalsInboxPage-DlnxY-uy.js → ApprovalsInboxPage-D_LOnhJ7.js} +1 -1
  9. package/dist/assets/{AuditLogPage-DIJPRjji.js → AuditLogPage-B9eqwuzl.js} +1 -1
  10. package/dist/assets/{ComponentNavView-C84QByT7.js → ComponentNavView-DeokLfkW.js} +1 -1
  11. package/dist/assets/{CreateViewDialog-Zbd9Cagm.js → CreateViewDialog-BMdQ4ZYy.js} +1 -1
  12. package/dist/assets/{DashboardView-UyKHklBx.js → DashboardView-DHZboRi8.js} +1 -1
  13. package/dist/assets/{DeveloperHubPage-BRyNdrCJ.js → DeveloperHubPage-C_VYirN0.js} +1 -1
  14. package/dist/assets/{DocPage-Bx8ZXCYt.js → DocPage-_9x-3Dbi.js} +1 -1
  15. package/dist/assets/{DocShell-Ipy_IDvh.js → DocShell-D4dSPfBz.js} +1 -1
  16. package/dist/assets/{DocsIndex-CmY-7OQR.js → DocsIndex-CJVRa_hE.js} +1 -1
  17. package/dist/assets/{DocsLayout-BNsSvaz2.js → DocsLayout-C-tYgUZv.js} +1 -1
  18. package/dist/assets/{DocsSlug-Cb_NMM1k.js → DocsSlug-DmyGpfEy.js} +1 -1
  19. package/dist/assets/{ExpressionProvider-DqGWVuxV.js → ExpressionProvider-B6z09kM6.js} +1 -1
  20. package/dist/assets/{FlowRunsPage-B6ustUgi.js → FlowRunsPage-OjGJi-JU.js} +1 -1
  21. package/dist/assets/{IntegrationsPage-chOxmiyU.js → IntegrationsPage-CrDMDe62.js} +1 -1
  22. package/dist/assets/{InterfaceListPage-DVETnQm5.js → InterfaceListPage-P3y6hqTX.js} +1 -1
  23. package/dist/assets/{MarketplaceInstalledPage-DA5pjhAz.js → MarketplaceInstalledPage-CQek7WnV.js} +1 -1
  24. package/dist/assets/{MarketplacePackagePage-dCIVHBFi.js → MarketplacePackagePage-DL2ivKSc.js} +1 -1
  25. package/dist/assets/{MarketplacePage-wJb6g1p7.js → MarketplacePage-B-6EokyB.js} +1 -1
  26. package/dist/assets/{MetadataInspector-Cu-n1FYz.js → MetadataInspector-IQGUoLyp.js} +1 -1
  27. package/dist/assets/{ObjectDataPage-CP-YSZYQ.js → ObjectDataPage-Bmc3RQhM.js} +1 -1
  28. package/dist/assets/{PageView-B1_ibRuM.js → PageView-DzUZqB_h.js} +1 -1
  29. package/dist/assets/{ProfilePage-DEr5iZVB.js → ProfilePage-NklCqPxc.js} +1 -1
  30. package/dist/assets/{PublicFormsPage-CBcKQbNl.js → PublicFormsPage-CItIvcLQ.js} +1 -1
  31. package/dist/assets/RecordDetailView-XWxuegfV.js +3 -0
  32. package/dist/assets/{RecordFormPage-CGQlYWDk.js → RecordFormPage-B-yrhs7J.js} +1 -1
  33. package/dist/assets/{ReportDefaultInspector-R_p6YStL.js → ReportDefaultInspector-D5Kro5_t.js} +1 -1
  34. package/dist/assets/{ReportView-BTMrtcGH.js → ReportView-COpZ8PQT.js} +1 -1
  35. package/dist/assets/{RuntimeDraftBar-agGU39FL.js → RuntimeDraftBar-CSVtuByp.js} +1 -1
  36. package/dist/assets/{SchemaForm-DJbupOno.js → SchemaForm-DIsxxOZF.js} +1 -1
  37. package/dist/assets/{SearchResultsPage-CHhZUc6L.js → SearchResultsPage-B2r6kgni.js} +1 -1
  38. package/dist/assets/{SettingsHub-BGLR_gS7.js → SettingsHub-DQz2HDtZ.js} +1 -1
  39. package/dist/assets/{SettingsView-Bq-7Zkzs.js → SettingsView-BfOEalDW.js} +1 -1
  40. package/dist/assets/{SkeletonDetail-B4-UKxai.js → SkeletonDetail-DMOa5zcl.js} +1 -1
  41. package/dist/assets/{SystemHubPage-CVZVag1e.js → SystemHubPage-DM2VRSIP.js} +1 -1
  42. package/dist/assets/{abnfDiagram-VCTEODGH-DUS5D5dU.js → abnfDiagram-VCTEODGH-DaPlU6Hz.js} +1 -1
  43. package/dist/assets/{app-shell-eager-leaves-BB0oaPx6.js → app-shell-eager-leaves-wjbiJgVZ.js} +1 -1
  44. package/dist/assets/architectureDiagram-5GKGNRK7-Cq014PwG.js +36 -0
  45. package/dist/assets/{blockDiagram-OSKFZWR5-Bz2hnVmp.js → blockDiagram-OSKFZWR5-vtlcoeZc.js} +1 -1
  46. package/dist/assets/{c4Diagram-7LVT6UL2-DU3u1Y6c.js → c4Diagram-7LVT6UL2-BrdwRG2M.js} +1 -1
  47. package/dist/assets/channel-D2IgUFnY.js +1 -0
  48. package/dist/assets/{chunk-3NF5O7KM-B8Q7HUio.js → chunk-3NF5O7KM-CjWAf_Jo.js} +1 -1
  49. package/dist/assets/{chunk-4HAMMTFA-BPKwX4iB.js → chunk-4HAMMTFA-BtV_msXT.js} +1 -1
  50. package/dist/assets/chunk-75Z2AOVW-DdRL9yNr.js +2 -0
  51. package/dist/assets/chunk-CLGD4ZFX-De9kMAXh.js +1 -0
  52. package/dist/assets/{chunk-DU6HZSFF-BkY4hAzc.js → chunk-DU6HZSFF-DqjylQO-.js} +1 -1
  53. package/dist/assets/chunk-F27PBJKO-tEB_K-iD.js +1 -0
  54. package/dist/assets/{chunk-GMAD6QVW-DZo_NykZ.js → chunk-GMAD6QVW-BMzd_HHM.js} +1 -1
  55. package/dist/assets/{chunk-GVQU2GXP-9ELY9S6X.js → chunk-GVQU2GXP-B1p1nHC0.js} +1 -1
  56. package/dist/assets/{chunk-H2I77ZZE-vCr_buP7.js → chunk-H2I77ZZE-ioXC4dHO.js} +1 -1
  57. package/dist/assets/{chunk-HLEWEB6X-iPkY2ESt.js → chunk-HLEWEB6X-zZ3ZMup3.js} +1 -1
  58. package/dist/assets/chunk-L3NEJ4N5-DePXufTQ.js +1 -0
  59. package/dist/assets/{chunk-LQGUR6SS-iVI0GACK.js → chunk-LQGUR6SS-BUWUp_dz.js} +1 -1
  60. package/dist/assets/{chunk-OSK3NFVY-DcRwXCQD.js → chunk-OSK3NFVY-L7nTUJKT.js} +2 -2
  61. package/dist/assets/{chunk-P2QGCYS3-nx2-dM5t.js → chunk-P2QGCYS3-BG-i3rdI.js} +1 -1
  62. package/dist/assets/{chunk-POPQ4Y6H-BxLOacOG.js → chunk-POPQ4Y6H-DLEB8EqK.js} +1 -1
  63. package/dist/assets/{chunk-PWAF6VOD-2mst9kZu.js → chunk-PWAF6VOD-Be_prJjm.js} +1 -1
  64. package/dist/assets/{chunk-SVP7TREG-C3BMpr4x.js → chunk-SVP7TREG-BdJpxJji.js} +1 -1
  65. package/dist/assets/chunk-XXDRQBXY-CEXsCcSu.js +1 -0
  66. package/dist/assets/{chunk-ZLD2IHE6-ZFqtFJbj.js → chunk-ZLD2IHE6-BLIPZykR.js} +1 -1
  67. package/dist/assets/classDiagram-CYGNFDIV-BielDdJQ.js +1 -0
  68. package/dist/assets/classDiagram-v2-TLXNO2FR-BielDdJQ.js +1 -0
  69. package/dist/assets/cose-bilkent-JH36ORCC-CnLWv9XE.js +1 -0
  70. package/dist/assets/{createDerive-Best2JCj.js → createDerive-DtfnFzGm.js} +1 -1
  71. package/dist/assets/{cynefinDiagram-5FMLGOSQ-Lnly8IJd.js → cynefinDiagram-5FMLGOSQ-Do1SZz4I.js} +1 -1
  72. package/dist/assets/{dagre-OS7QT2EB-CdXLxmTK.js → dagre-OS7QT2EB-CqmZ9Y9O.js} +1 -1
  73. package/dist/assets/data-adapter-1YRpH3h_.js +5 -0
  74. package/dist/assets/{default-inspector-registry-DeEG98bO.js → default-inspector-registry-CmSpNwTr.js} +1 -1
  75. package/dist/assets/{diagram-S7CK7UJ4-DE8I3gxQ.js → diagram-S7CK7UJ4-CMpcDWop.js} +1 -1
  76. package/dist/assets/{diagram-UQ7AKVKN-D2xQpbEq.js → diagram-UQ7AKVKN-DLK_4yej.js} +1 -1
  77. package/dist/assets/{diagram-VSXAHHWV-DnttDSlO.js → diagram-VSXAHHWV-MAILxw0S.js} +1 -1
  78. package/dist/assets/diagram-VX7I27RA-DGiXGVX7.js +24 -0
  79. package/dist/assets/{diagram-Z3DM3KII-BgB9f0Nv.js → diagram-Z3DM3KII-BywboeGI.js} +1 -1
  80. package/dist/assets/dist-B88JFSFg.js +5 -0
  81. package/dist/assets/{ebnfDiagram-PWID7BFC-32WvKbS2.js → ebnfDiagram-PWID7BFC-DdMLbnuP.js} +1 -1
  82. package/dist/assets/{erDiagram-2YWLMYGG-Dwf8uAdl.js → erDiagram-2YWLMYGG-O6raGx2P.js} +1 -1
  83. package/dist/assets/flowDiagram-T62WH6J4-CkAxOnqU.js +1 -0
  84. package/dist/assets/framework-DFE_Mws9.js +36 -0
  85. package/dist/assets/{ganttDiagram-EL5Y4UJY-DqYIE0Cu.js → ganttDiagram-EL5Y4UJY-Dijdjc50.js} +2 -2
  86. package/dist/assets/{getIcon-CgyYxSEC.js → getIcon-B4Pp7Q-0.js} +1 -1
  87. package/dist/assets/gitGraphDiagram-WWUBYQGX-Cfl4OIGG.js +106 -0
  88. package/dist/assets/{highlighted-body-OFNGDK62-BxO9mjPI.js → highlighted-body-OFNGDK62-BlqGRgbU.js} +1 -1
  89. package/dist/assets/{i18n-Cfqor-xb.js → i18n-DGcOKnTh.js} +1 -1
  90. package/dist/assets/{i18n-locales-Bz4c8KXc.js → i18n-locales-BBA090ve.js} +10 -10
  91. package/dist/assets/index-C5Fu9Kda.css +2 -0
  92. package/dist/assets/index-ClPLLRzK.js +20 -0
  93. package/dist/assets/{infoDiagram-FKFFQAWI-Cr1-5_Am.js → infoDiagram-FKFFQAWI-oOVNWlVA.js} +1 -1
  94. package/dist/assets/{infrastructure-CIpDEFyQ.js → infrastructure-B4zG1jNa.js} +2 -2
  95. package/dist/assets/{ishikawaDiagram-5VMMS53U-Bsjx7BsE.js → ishikawaDiagram-5VMMS53U-BUfTfup1.js} +1 -1
  96. package/dist/assets/{journeyDiagram-EYS64GPL-1scn5Z5c.js → journeyDiagram-EYS64GPL-4fyU8Ui9.js} +2 -2
  97. package/dist/assets/{kanban-definition-UXKFOSKX-DjLQAv5U.js → kanban-definition-UXKFOSKX-qwquHo2y.js} +1 -1
  98. package/dist/assets/mermaid-GHXKKRXX-_UhQGe8N.js +1 -0
  99. package/dist/assets/{mermaid.core-pW40dd4u.js → mermaid.core-RfBGJVq5.js} +2 -2
  100. package/dist/assets/{metadata-admin-pawEBYI9.js → metadata-admin-Bo-vWW2Z.js} +3 -3
  101. package/dist/assets/{mindmap-definition-THT77NOG-CUcYMB9H.js → mindmap-definition-THT77NOG-cOVHgGB_.js} +1 -1
  102. package/dist/assets/{pegDiagram-XKGWAZYB-CT1r3sRa.js → pegDiagram-XKGWAZYB-DQikOuPL.js} +1 -1
  103. package/dist/assets/{pieDiagram-E7YTZNPT-CSi-V1LQ.js → pieDiagram-E7YTZNPT-Cu9wPXiv.js} +2 -2
  104. package/dist/assets/plugin-calendar-DqlnPeWE.js +1 -0
  105. package/dist/assets/plugin-charts-hJ5C1pY-.js +7 -0
  106. package/dist/assets/{plugin-chatbot-BGnkLzFS.js → plugin-chatbot-BeSLDg4N.js} +5 -5
  107. package/dist/assets/plugin-dashboard-d1o52lHr.js +6 -0
  108. package/dist/assets/{plugin-form-_fjHxKTV.js → plugin-form-D8x_rH5w.js} +1 -1
  109. package/dist/assets/plugin-gantt-B2GTMGPH.js +63 -0
  110. package/dist/assets/plugin-grid-DGXy_yQF.js +9 -0
  111. package/dist/assets/{plugin-kanban-DA0eW6yj.js → plugin-kanban-CVf6Nj3e.js} +1 -1
  112. package/dist/assets/plugin-map-hkbw1bGS.js +1 -0
  113. package/dist/assets/{plugin-markdown-B7zwZHmn.js → plugin-markdown-Bdb2UThR.js} +4 -4
  114. package/dist/assets/plugin-report-CelulaB7.js +59 -0
  115. package/dist/assets/{plugin-timeline-B6rsNNAK.js → plugin-timeline-DTcJ-hts.js} +1 -1
  116. package/dist/assets/plugin-tree-Bk5vG9la.js +1 -0
  117. package/dist/assets/{plugin-view-5qxxRyZZ.js → plugin-view-CKs41t7o.js} +1 -1
  118. package/dist/assets/plugins-views-DZmsFOak.js +4 -0
  119. package/dist/assets/{quadrantDiagram-AXDQQJYC-DUJ_94hm.js → quadrantDiagram-AXDQQJYC-DqTU6p89.js} +3 -3
  120. package/dist/assets/{railroadDiagram-O6MQD6OU-CEyfAhzM.js → railroadDiagram-O6MQD6OU-CHGgIBKb.js} +1 -1
  121. package/dist/assets/{requirementDiagram-IS5BZ75X-CAK7hvBg.js → requirementDiagram-IS5BZ75X-B20mHS5h.js} +1 -1
  122. package/dist/assets/{runtime-metadata-persistence-DYPxFzHI.js → runtime-metadata-persistence-DzS2YaNb.js} +1 -1
  123. package/dist/assets/{sankeyDiagram-P5KCCOFB-DgYJh7uz.js → sankeyDiagram-P5KCCOFB-oqGY91Cw.js} +3 -3
  124. package/dist/assets/{sequenceDiagram-WJ2MYXX4-DsQerPtC.js → sequenceDiagram-WJ2MYXX4-CVMm7Aid.js} +1 -1
  125. package/dist/assets/{src-CVJP2nIc.js → src-D7tZqf12.js} +1 -1
  126. package/dist/assets/{src-_DxAIBqo.js → src-DCXZnd2l.js} +1 -1
  127. package/dist/assets/{src-S6pzKItc.js → src-DEMdKbQy.js} +1 -1
  128. package/dist/assets/src-hcMLuWxG.js +17 -0
  129. package/dist/assets/stateDiagram-XQSTLZYL-3oM7IdVe.js +1 -0
  130. package/dist/assets/stateDiagram-v2-IH3M54BS-BznjPAgb.js +1 -0
  131. package/dist/assets/studioEntry-BUFsLXCL.js +1 -0
  132. package/dist/assets/{submitRedirect-UXd9NsjL.js → submitRedirect-7ExeC4kw.js} +1 -1
  133. package/dist/assets/{swimlanes-V6O3JKXN-BiKyiEJr.js → swimlanes-V6O3JKXN-Djgbrkmh.js} +1 -1
  134. package/dist/assets/swimlanesDiagram-JKAHXJPX-DHJJ3qZq.js +8 -0
  135. package/dist/assets/{timeline-definition-24CTP7MA-CW5rY3PX.js → timeline-definition-24CTP7MA-k2lbfDvL.js} +2 -2
  136. package/dist/assets/ui-components-CMHDBJEm.js +37 -0
  137. package/dist/assets/{ui-layout-UUTFXV6S.js → ui-layout-Jk_qY9Ni.js} +1 -1
  138. package/dist/assets/{use-book-data-qUZAxIs0.js → use-book-data-CM73PGvc.js} +1 -1
  139. package/dist/assets/{useActionModal-CkM-zGdy.js → useActionModal-D_iilsul.js} +1 -1
  140. package/dist/assets/{usePackageL10n-F9isJ9pn.js → usePackageL10n-BfPqgsRL.js} +1 -1
  141. package/dist/assets/{useSettingsLabel-CSZBfUiw.js → useSettingsLabel-CW2sBbmj.js} +1 -1
  142. package/dist/assets/vendor-charts-BBlPrtHS.js +67 -0
  143. package/dist/assets/{vendor-i18n-C1AQDWux.js → vendor-i18n-CzBLXLJU.js} +1 -1
  144. package/dist/assets/vendor-objectstack-BU0HrnMy.js +270 -0
  145. package/dist/assets/{vendor-zod-r9lyeyrU.js → vendor-zod-Bwe8XZZa.js} +3 -3
  146. package/dist/assets/{vennDiagram-4TSXK5OY-C79cMc25.js → vennDiagram-4TSXK5OY-zweM554s.js} +1 -1
  147. package/dist/assets/{wardleyDiagram-VM6X3IG4-BAO0_jUk.js → wardleyDiagram-VM6X3IG4-Dg9r6Ajz.js} +1 -1
  148. package/dist/assets/{xychartDiagram-S5SC5T6Z-BIRd7YRo.js → xychartDiagram-S5SC5T6Z-CraplxeN.js} +2 -2
  149. package/dist/eager-closure.json +87 -87
  150. package/dist/index.html +4 -4
  151. package/package.json +1 -1
  152. package/dist/assets/RecordDetailView-A8bbPnkK.js +0 -3
  153. package/dist/assets/architectureDiagram-5GKGNRK7-mGW8P1lC.js +0 -36
  154. package/dist/assets/channel-FD4s9EIH.js +0 -1
  155. package/dist/assets/chunk-75Z2AOVW-CkSdnmiC.js +0 -2
  156. package/dist/assets/chunk-CLGD4ZFX-BTkDISwp.js +0 -1
  157. package/dist/assets/chunk-F27PBJKO-DUKg0YWV.js +0 -1
  158. package/dist/assets/chunk-L3NEJ4N5-Bzz35TZJ.js +0 -1
  159. package/dist/assets/chunk-XXDRQBXY-iNC8aYmk.js +0 -1
  160. package/dist/assets/classDiagram-CYGNFDIV-D5Pd2TCl.js +0 -1
  161. package/dist/assets/classDiagram-v2-TLXNO2FR-D5Pd2TCl.js +0 -1
  162. package/dist/assets/cose-bilkent-JH36ORCC-CPQv9aQH.js +0 -1
  163. package/dist/assets/data-adapter-DL25qpAe.js +0 -5
  164. package/dist/assets/diagram-VX7I27RA-BSEwkn7K.js +0 -24
  165. package/dist/assets/dist-BpPy7hlB.js +0 -5
  166. package/dist/assets/flowDiagram-T62WH6J4-CqVSNJ8T.js +0 -1
  167. package/dist/assets/framework-BfSv4Kb0.js +0 -36
  168. package/dist/assets/gitGraphDiagram-WWUBYQGX-D1dYmoGu.js +0 -106
  169. package/dist/assets/index-BU-FzlQ6.js +0 -20
  170. package/dist/assets/index-_VyGO4ms.css +0 -2
  171. package/dist/assets/mermaid-GHXKKRXX-NzEcDxBh.js +0 -1
  172. package/dist/assets/plugin-calendar-BwiiCIjv.js +0 -1
  173. package/dist/assets/plugin-charts-CDGkx7z5.js +0 -7
  174. package/dist/assets/plugin-dashboard-Bj4ldCX6.js +0 -6
  175. package/dist/assets/plugin-gantt-zR8DkpEg.js +0 -63
  176. package/dist/assets/plugin-grid-kkbz4uec.js +0 -9
  177. package/dist/assets/plugin-map-DukneTNg.js +0 -1
  178. package/dist/assets/plugin-report-DaPtlsJr.js +0 -59
  179. package/dist/assets/plugin-tree-DauauLFc.js +0 -1
  180. package/dist/assets/plugins-views-iYcMmImr.js +0 -4
  181. package/dist/assets/src-JX1BkhmR.js +0 -17
  182. package/dist/assets/stateDiagram-XQSTLZYL-BJndPKik.js +0 -1
  183. package/dist/assets/stateDiagram-v2-IH3M54BS-Bi94bTLl.js +0 -1
  184. package/dist/assets/studioEntry-C6G8U-LG.js +0 -1
  185. package/dist/assets/swimlanesDiagram-JKAHXJPX-DKIR852g.js +0 -8
  186. package/dist/assets/ui-components-D2lrjG-t.js +0 -43
  187. package/dist/assets/vendor-charts-CY9WhhzX.js +0 -67
  188. package/dist/assets/vendor-objectstack-BeKUVjuj.js +0 -270
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,b as n,g as r,h as i,r as a}from"./vendor-react-CsWFRkED.js";import{c as o,g as s,n as c,y as ee}from"./infrastructure-CIpDEFyQ.js";import{q as te}from"./framework-BfSv4Kb0.js";import{y as ne}from"./i18n-locales-Bz4c8KXc.js";import{Bt as re,Cn as ie,Dn as ae,Dr as oe,En as l,Fs as se,Gr as ce,Gt as u,Hr as le,Ht as ue,Ia as de,In as fe,Jr as pe,Js as me,Jt as he,Kr as ge,Kt as d,On as _e,Or as ve,Pr as f,Rr as ye,Sn as be,Tn as xe,Ur as Se,Us as Ce,Ut as we,Vr as Te,Vt as Ee,Wi as De,Wr as Oe,Wt as ke,Xr as p,Yc as Ae,Yr as je,Ys as Me,aa as Ne,bn as Pe,di as Fe,ea as Ie,gc as Le,gn as m,ht as Re,ia as ze,ic as Be,ii as Ve,il as h,kr as He,mc as Ue,mt as We,ni as Ge,pc as Ke,qr as qe,qt as Je,sc as Ye,va as Xe,vn as Ze,vt as Qe,wn as $e,ws as et,xn as tt,yn as nt,zr as rt,zt as it}from"./ui-components-D2lrjG-t.js";import{r as g}from"./vendor-ui-utils-BFw4cGI6.js";import{r as at,y as ot}from"./RecordDetailView-A8bbPnkK.js";import"./src-JX1BkhmR.js";import{t as st}from"./studioEntry-C6G8U-LG.js";var _=e(n(),1),ct=`${``.replace(/\/$/,``)}/api/v1`;async function v(e,t){let n=ee.get(),r=await fetch(`${ct}${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 y={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return v(`/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 v(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await v(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return v(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await v(`/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 v(`/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 v(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await v(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await v(`/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 v(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await v(`/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 v(`/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 v(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return v(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function lt(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 b(e,t){return`${e}::${t}`}function x(e){return typeof e.object_name==`string`&&e.object_name!==``&&typeof e.record_id==`string`&&e.record_id!==``}function S(e){let t=new Map,n=new Set;for(let r of e){if(!x(r))continue;let e=b(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 C(e){if(Array.isArray(e))return e;let t=e?.data;return Array.isArray(t)?t:[]}async function ut(e,t){let n=new Map,r=S(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(C(n).map(e=>e?.id).filter(e=>typeof e==`string`&&e!==``))}catch{return}for(let e of r)n.set(b(t,e),i.has(e))})),n}function dt(e){let t=te(),[n,r]=(0,_.useState)(()=>new Map),i=(0,_.useRef)(new Set),a=(0,_.useRef)(e);a.current=e;let o=(0,_.useMemo)(()=>e.filter(x).map(e=>b(e.object_name,e.record_id)).join(`|`),[e]);return(0,_.useEffect)(()=>{if(!t)return;let e=a.current.filter(e=>x(e)&&!i.current.has(b(e.object_name,e.record_id)));if(e.length===0)return;for(let t of e)x(t)&&i.current.add(b(t.object_name,t.record_id));let n=!1;return ut(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,_.useMemo)(()=>({isUnreadable:e=>x(e)&&n.get(b(e.object_name,e.record_id))===!1}),[n])}var w=new Set;function T(e){let t=e?.fields;if(!t||typeof t!=`object`)return w;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:w}async function E(e,t){if(typeof e?.getObjectSchema!=`function`)return w;try{return T(await e.getObjectSchema(t))}catch{return w}}function ft(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 pt(e){let t=te(),[n,r]=(0,_.useState)(()=>new Map),i=(0,_.useRef)(new Set),a=(0,_.useRef)(e);a.current=e;let o=(0,_.useMemo)(()=>ft(e).join(`|`),[e]);return(0,_.useEffect)(()=>{if(!t)return;let e=ft(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 E(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,_.useMemo)(()=>({forObject:e=>typeof e==`string`&&e!==``?n.get(e)??w:w}),[n])}var D=a(),mt=50,ht={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`};function gt({status:e,label:t}){return(0,D.jsx)(f,{variant:`outline`,className:h(`font-medium`,ht[e]??``),children:t})}function _t(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function O(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 k(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function A(e){return e.process_label||k(e.process_name)}function vt(e){return e.step_label?e.step_label:e.current_step?k(e.current_step):null}function yt(e){return e.submitter_name||O(e.submitter_id)}function bt(e,t){return t.pending_approver_names?.[e]||O(e)}function xt(e,t){let n=t.pending_approver_groups?.[e];return n&&n.length?n.join(` / `):void 0}function St(e){let t=[],n=new Map;for(let r of e.pending_approvers||[]){let i=bt(r,e),a=xt(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 Ct(e){if(e.submitter_name)return!1;let t=(e.submitter_id||``).trim();return!t||t.startsWith(`flow:`)||t.startsWith(`system:`)}function wt(e){return e.object_label||e.object_name}function j(e){return e.submitted_at||e.created_at||void 0}function M(e,t){let n=j(e);if(!n)return null;let r=Date.parse(n);return Number.isNaN(r)?null:(t-r)/36e5}function Tt(e,t){if(e.status!==`pending`)return`text-muted-foreground`;let n=M(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 Et(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}function Dt(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 N=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function P(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 Ot(e,t){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()}catch{}return t.toLocaleString()}let n=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(n))try{return new Date(n).toLocaleString()}catch{}return n}var F=/^[A-Za-z0-9_-]{15,}$/;function kt(e,t,n,r=6,i,a){if(!e||typeof e!=`object`||Array.isArray(e))return[];let o=[];for(let[s,c]of Object.entries(e)){if(N.has(s)||a?.has(s)||i&&s===i||c==null||typeof c==`object`||String(c).trim()===``)continue;let e=t?.[s];if(!(!e&&typeof c==`string`&&F.test(c.trim())&&!/^\d+$/.test(c.trim()))&&(o.push([n?.[s]??P(s),e??Ot(s,c)]),o.length>=r))break}return o}var At=/(amount|total|price|value|cost|sum|budget|salary|fee|revenue|balance|金额|总额|价格|费用|预算|金额)/i;function I(e,t){let n=e.payload;if(!n||typeof n!=`object`||Array.isArray(n))return null;for(let[r,i]of Object.entries(n)){if(N.has(r)||t.has(r)||!At.test(r))continue;let n=typeof i==`number`?i:typeof i==`string`&&i.trim()!==``&&Number.isFinite(Number(i))?Number(i):null;if(!(n==null||!Number.isFinite(n)))return{key:r,label:e.payload_labels?.[r]??P(r),value:n,display:e.payload_display?.[r]??n.toLocaleString()}}return null}function jt({r:e,tr:t}){return(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`div`,{className:`font-medium truncate`,children:A(e)}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[vt(e)||`—`,(e.round??1)>1&&(0,D.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:t(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Mt({r:e,href:n,hiddenKeys:r}){let i=I(e,r),a=e.record_title||O(e.record_id);return(0,D.jsxs)(`div`,{className:`min-w-0`,children:[n===null?(0,D.jsx)(`div`,{className:`text-sm truncate max-w-full`,title:e.record_id,children:a}):(0,D.jsxs)(t,{to:n,onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:e.record_id,children:[(0,D.jsx)(`span`,{className:`truncate`,children:a}),(0,D.jsx)(et,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[wt(e),i&&(0,D.jsxs)(`span`,{className:`ml-1.5 font-medium text-foreground`,title:`${i.label}: ${i.display}`,children:[`· `,i.display]})]})]})}function Nt({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,D.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,D.jsx)(p,{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,D.jsx)(Be,{className:`h-4 w-4`})}),(0,D.jsx)(p,{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,D.jsx)(Me,{className:`h-4 w-4`})})]})}function Pt(){let{t:e,language:n}=ne(),{user:a}=s(),{appName:ee}=i(),[te,ct]=r(),v=(0,_.useMemo)(()=>lt(a),[a]),{systemPermissions:b}=c(),x=st(b),S=(0,_.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),[C,ut]=(0,_.useState)(()=>Date.now());(0,_.useEffect)(()=>{let e=setInterval(()=>ut(Date.now()),6e4);return()=>clearInterval(e)},[]);let w=(0,_.useCallback)(e=>{if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let r=Math.round((C-t)/1e3);if(r<45)return S(`justNow`,`just now`);let i=Math.round(r/60);if(i<60)return S(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return S(`hoursAgo`,`{{count}}h ago`,{count:a});let o=Math.round(a/24);if(o<30)return S(`daysAgo`,`{{count}}d ago`,{count:o});try{return new Date(e).toLocaleDateString(n)}catch{return e}},[S,n,C]),T=(0,_.useCallback)(e=>{switch(e){case`pending`:return S(`statusPending`,`Pending`);case`approved`:return S(`statusApproved`,`Approved`);case`rejected`:return S(`statusRejected`,`Rejected`);case`recalled`:return S(`statusRecalled`,`Recalled`);case`returned`:return S(`statusReturned`,`Returned for revision`);default:return e}},[S]),E=(0,_.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?S(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?S(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?S(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?S(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?S(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[S]),ft=(0,_.useCallback)(e=>e.overdue?S(`slaOverdue`,`SLA overdue {{dur}}`,{dur:Et(e.ms)}):S(`slaRemaining`,`SLA {{dur}} left`,{dur:Et(e.ms)}),[S]),ht=(0,_.useCallback)(e=>`/apps/${ee||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[ee]),[k,xt]=(0,_.useState)(`pending`),[M,N]=(0,_.useState)([]),[P,Ot]=(0,_.useState)(!1),[F,At]=(0,_.useState)(!1),[Pt,Ft]=(0,_.useState)(null),[It,Lt]=(0,_.useState)(null),[Rt,zt]=(0,_.useState)(0),[L,Bt]=(0,_.useState)(null),[R,Vt]=(0,_.useState)(null),[Ht,Ut]=(0,_.useState)([]),[Wt,Gt]=(0,_.useState)(!1),Kt=(0,_.useMemo)(()=>R?[...M,R]:M,[M,R]),qt=dt(Kt),z=pt((0,_.useMemo)(()=>Kt.map(e=>e.object_name),[Kt])),Jt=z.forObject(R?.object_name),Yt=(0,_.useMemo)(()=>o(),[]),Xt=(0,_.useCallback)(async e=>{let t=window.open(``,`_blank`,`noopener`);try{let n=``.replace(/\/$/,``),r=await Yt(`${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(S(`attachmentOpenFailed`,`Could not open the attachment — please try again`))}},[Yt,S]),[B,Zt]=(0,_.useState)(``),[Qt,$t]=(0,_.useState)(``),[en,tn]=(0,_.useState)(`all`),[nn,rn]=(0,_.useState)(`all`),[V,an]=(0,_.useState)(`all`),[on,sn]=(0,_.useState)(`recent`),[H,cn]=(0,_.useState)(new Set),[ln,un]=(0,_.useState)(!1),[U,dn]=(0,_.useState)(null),[W,fn]=(0,_.useState)(null),[pn,mn]=(0,_.useState)(null),[G,hn]=(0,_.useState)(``),[gn,_n]=(0,_.useState)(!1),[vn,yn]=(0,_.useState)(-1);(0,_.useEffect)(()=>{if(k===`pending`)return;let e=window.setTimeout(()=>$t(B),350);return()=>window.clearTimeout(e)},[B,k]);let K=(0,_.useCallback)(async()=>{Ot(!0),Lt(null);try{let e=[];if(k===`pending`)e=v.length?(await y.listRequests({status:`pending`,approverId:v})).data:[],zt(e.length),Ft(null);else{let t={q:Qt||void 0,status:V===`all`?void 0:V,limit:mt,offset:0};if(k===`submitted`){let n=a?.id;if(n){let r=await y.listRequests({submitterId:n,...t});e=r.data,Ft(r.total??r.data.length)}else e=[],Ft(0)}else{let n=await y.listRequests(t);e=n.data,Ft(n.total??n.data.length)}v.length&&y.listRequests({status:`pending`,approverId:v}).then(e=>zt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(j(t)||``).localeCompare(j(e)||``)),N(e)}catch(e){Lt(e?.message||String(e)),N([])}finally{Ot(!1)}},[k,v,a?.id,Qt,V]);(0,_.useEffect)(()=>{K()},[K]);let bn=(0,_.useCallback)(async()=>{if(!(k===`pending`||F)){At(!0);try{let e=await y.listRequests({submitterId:k===`submitted`?a?.id??void 0:void 0,q:Qt||void 0,status:V===`all`?void 0:V,limit:mt,offset:M.length});N(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&Ft(e.total)}catch(e){g.error(E(e,S(`loadFailed`,`Failed to load request`)))}finally{At(!1)}}},[k,F,a?.id,Qt,V,M.length,E,S]),q=(0,_.useCallback)(async e=>{Bt(e),Gt(!0);try{let[t,n]=await Promise.all([y.getRequest(e),y.listActions(e)]);Vt(t.data),Ut(n.data)}catch(e){g.error(E(e,S(`loadFailed`,`Failed to load request`))),Vt(null),Ut([])}finally{Gt(!1)}},[E,S]),xn=()=>{Bt(null),Vt(null),Ut([])};(0,_.useEffect)(()=>{let e=te.get(`request`);e&&(ct(e=>{let t=new URLSearchParams(e);return t.delete(`request`),t},{replace:!0}),q(e))},[te]);let J=(0,_.useCallback)(()=>{v.length&&y.listRequests({status:`pending`,approverId:v}).then(e=>zt(e.data.length)).catch(()=>{})},[v]),Sn=(0,_.useCallback)(async e=>{let[t,n]=await Promise.all([y.getRequest(e),y.listActions(e)]);Vt(t.data),Ut(n.data),K()},[K]),Cn=(0,_.useCallback)(async()=>{if(!R)return;let e=R.id;try{let[t,n]=await Promise.all([y.getRequest(e),y.listActions(e)]);Vt(t.data),Ut(n.data),K();let r=new Set(t.data.pending_approvers||[]),i=t.data.status===`pending`&&v.some(e=>r.has(e));if(k===`pending`&&!i){let t=Rn.current,n=t.findIndex(t=>t.id===e),r=t[n+1]??t[n-1];if(r&&r.id!==e){q(r.id);return}xn()}}catch{Sn(e)}},[R,v,k,K,q,xn,Sn]),wn=(0,_.useCallback)(async()=>{if(!(!R||!G.trim())){_n(!0);try{await y.comment(R.id,{actor_id:a?.id,comment:G.trim()}),hn(``),await Sn(R.id)}catch(e){g.error(E(e,S(`actionFailed`,`Action failed`)))}finally{_n(!1)}}},[R,G,a?.id,Sn,E,S]),Tn=(0,_.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 v.some(t=>e.has(t))},[R,v]),En=(0,_.useMemo)(()=>!R||R.status!==`pending`?!1:R.viewer?R.viewer.is_submitter:R.submitter_id===a?.id,[R,a?.id]),Dn=(0,_.useMemo)(()=>!R||R.status!==`returned`?!1:R.viewer?R.viewer.is_submitter:R.submitter_id===a?.id,[R,a?.id]),On=(0,_.useMemo)(()=>{let e=new Set;for(let t of M)e.add(A(t));return Array.from(e).sort()},[M]),kn=(0,_.useMemo)(()=>{let e=new Set;for(let t of M)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[M]),Y=(0,_.useMemo)(()=>{let e=B.trim().toLowerCase(),t=M.filter(t=>en!==`all`&&A(t)!==en||nn!==`all`&&t.object_name!==nn||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(on===`recent`)return t;let n=[...t];return on===`amount`?n.sort((e,t)=>{let n=I(e,z.forObject(e.object_name))?.value,r=I(t,z.forObject(t.object_name))?.value;return n==null&&r==null?0:n==null?1:r==null?-1:r-n}):n.sort((e,t)=>(j(e)||``).localeCompare(j(t)||``)),n},[M,B,en,nn,V,k,on,z]),X=(0,_.useMemo)(()=>L?Y.findIndex(e=>e.id===L):-1,[Y,L]);(0,_.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&&cn(n)},[Y,H]),(0,_.useEffect)(()=>{vn>=Y.length&&yn(Y.length-1)},[Y.length,vn]);let An=(0,_.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(v);return(e.pending_approvers||[]).some(e=>t.has(e))},[v]),Z=(0,_.useCallback)(e=>Array.isArray(e.decision_outputs)&&e.decision_outputs.length>0,[]),jn=(0,_.useCallback)(e=>An(e)&&!Z(e),[An,Z]),Q=(0,_.useMemo)(()=>Y.filter(e=>H.has(e.id)&&jn(e)),[Y,H,jn]),$=Y.filter(e=>e.status===`pending`),Mn=$.length>0&&$.every(e=>H.has(e.id)),Nn=(0,_.useCallback)(()=>{cn(e=>{if(Mn)return new Set;let t=new Set(e);for(let e of $)t.add(e.id);return t})},[Mn,$]),Pn=(0,_.useCallback)(e=>{cn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Fn=(0,_.useCallback)(async e=>{let t=Q;if(t.length===0)return;un(!0);let n=0,r=[];for(let i of t){let t=new Set(i.pending_approvers||[]),o=v.find(e=>t.has(e))||a?.id||``;try{await(e===`approve`?y.approve:y.reject)(i.id,{actor_id:o}),n++}catch{r.push(i.record_title||O(i.record_id))}}if(un(!1),cn(new Set),r.length===0)g.success(e===`approve`?S(`bulkApproved`,`Approved {{count}} requests`,{count:n}):S(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);g.error(S(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),J()},[Q,v,a?.id,K,J,S]),In=(0,_.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=v.find(e=>t.has(e))||a?.id||``;mn(e.id),dn(null);try{let t=await y.approve(e.id,{actor_id:n});g.success(t.finalized?S(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||O(e.record_id)}):S(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),J()}catch(e){g.error(E(e,S(`actionFailed`,`Action failed`)))}finally{mn(null)}},[U,v,a?.id,K,J,E,S]),Ln=(0,_.useCallback)(async()=>{let e=W;if(!e)return;let t=new Set(e.pending_approvers||[]),n=v.find(e=>t.has(e))||a?.id||``;mn(e.id),fn(null);try{await y.reject(e.id,{actor_id:n}),g.success(S(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||O(e.record_id)})),K(),J()}catch(e){g.error(E(e,S(`actionFailed`,`Action failed`)))}finally{mn(null)}},[W,v,a?.id,K,J,E,S]),Rn=(0,_.useRef)(Y);Rn.current=Y;let zn=(0,_.useRef)(vn);zn.current=vn,(0,_.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=Rn.current;if(!r.length)return;let i=zn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),yn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),yn(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(),Pn(r[i].id)):e.key===`a`&&i>=0&&r[i]&&jn(r[i])?(e.preventDefault(),dn(r[i])):e.key===`r`&&i>=0&&r[i]&&jn(r[i])&&(e.preventDefault(),fn(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[L,U,W,k,q,Pn,jn]),(0,_.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=Rn.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 Bn=!!B||en!==`all`||nn!==`all`||V!==`all`,Vn=e=>{xt(e),an(`all`),tn(`all`),rn(`all`),Zt(``),sn(`recent`),yn(-1)};return(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,D.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,D.jsx)(De,{className:`h-6 w-6`}),S(`title`,`Approvals Inbox`)]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:S(`subtitle`,`Review and act on approval requests.`)})]}),(0,D.jsxs)(p,{variant:`outline`,size:`sm`,onClick:K,disabled:P,className:`self-start sm:self-auto`,children:[(0,D.jsx)(Xe,{className:`h-4 w-4 mr-2 ${P?`animate-spin`:``}`}),S(`refresh`,`Refresh`)]})]}),It&&(0,D.jsxs)(ye,{variant:`destructive`,children:[(0,D.jsx)(Ye,{className:`h-4 w-4`}),(0,D.jsx)(rt,{children:It})]}),(0,D.jsxs)(it,{value:k,onValueChange:Vn,children:[(0,D.jsxs)(Ee,{children:[(0,D.jsxs)(ue,{value:`pending`,children:[S(`tabMyPending`,`My Pending`),Rt>0&&(0,D.jsx)(f,{variant:`secondary`,className:`ml-2`,children:Rt})]}),(0,D.jsx)(ue,{value:`submitted`,children:S(`tabSubmitted`,`Submitted by me`)}),(0,D.jsx)(ue,{value:`all`,children:S(`tabAll`,`All`)})]}),(0,D.jsxs)(re,{value:k,className:`mt-4 space-y-3`,children:[!P&&(M.length>0||k!==`pending`&&(Qt||V!==`all`))&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,D.jsx)(Ne,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,D.jsx)(fe,{value:B,onChange:e=>Zt(e.target.value),placeholder:S(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),B&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>Zt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":S(`clearSearch`,`Clear search`),children:(0,D.jsx)(Ge,{className:`h-3.5 w-3.5`})})]}),k!==`pending`&&(0,D.jsxs)($e,{value:V,onValueChange:an,children:[(0,D.jsx)(ae,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,D.jsx)(_e,{placeholder:S(`statusFilter`,`Status`)})}),(0,D.jsxs)(xe,{children:[(0,D.jsx)(l,{value:`all`,children:S(`allStatuses`,`All statuses`)}),(0,D.jsx)(l,{value:`pending`,children:T(`pending`)}),(0,D.jsx)(l,{value:`approved`,children:T(`approved`)}),(0,D.jsx)(l,{value:`rejected`,children:T(`rejected`)}),(0,D.jsx)(l,{value:`recalled`,children:T(`recalled`)}),(0,D.jsx)(l,{value:`returned`,children:T(`returned`)})]})]}),On.length>1&&(0,D.jsxs)($e,{value:en,onValueChange:tn,children:[(0,D.jsx)(ae,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,D.jsx)(_e,{placeholder:S(`processFilter`,`Process`)})}),(0,D.jsxs)(xe,{children:[(0,D.jsx)(l,{value:`all`,children:S(`allProcesses`,`All processes`)}),On.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),kn.length>1&&(0,D.jsxs)($e,{value:nn,onValueChange:rn,children:[(0,D.jsx)(ae,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,D.jsx)(_e,{placeholder:S(`objectFilter`,`Object`)})}),(0,D.jsxs)(xe,{children:[(0,D.jsx)(l,{value:`all`,children:S(`allObjects`,`All objects`)}),kn.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),(0,D.jsxs)($e,{value:on,onValueChange:e=>sn(e),children:[(0,D.jsxs)(ae,{className:`h-8 w-auto min-w-[120px] text-sm`,children:[(0,D.jsx)(Ae,{className:`h-3.5 w-3.5 mr-1 text-muted-foreground`}),(0,D.jsx)(_e,{placeholder:S(`sortBy`,`Sort`)})]}),(0,D.jsxs)(xe,{children:[(0,D.jsx)(l,{value:`recent`,children:S(`sortRecent`,`Newest first`)}),(0,D.jsx)(l,{value:`oldest`,children:S(`sortOldest`,`Oldest first`)}),(0,D.jsx)(l,{value:`amount`,children:S(`sortAmount`,`Amount (high→low)`)})]})]}),Bn&&(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`filterCount`,`{{shown}} of {{total}}`,{shown:Y.length,total:M.length})})]}),k===`pending`&&H.size>0&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:H.size}),` `,S(`selected`,`selected`),Q.length!==H.size&&(0,D.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:S(`actionableCount`,`({{count}} actionable)`,{count:Q.length})})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsxs)(Te,{children:[(0,D.jsx)(je,{asChild:!0,children:(0,D.jsxs)(p,{size:`sm`,disabled:ln||Q.length===0,children:[(0,D.jsx)(Be,{className:`h-3.5 w-3.5 mr-1`}),S(`approveN`,`Approve {{count}}`,{count:Q.length||``})]})}),(0,D.jsxs)(Oe,{children:[(0,D.jsxs)(qe,{children:[(0,D.jsx)(pe,{children:S(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:Q.length})}),(0,D.jsx)(ce,{children:S(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,D.jsxs)(ge,{children:[(0,D.jsx)(Se,{children:S(`cancel`,`Cancel`)}),(0,D.jsx)(le,{onClick:()=>Fn(`approve`),children:S(`approveN`,`Approve {{count}}`,{count:Q.length})})]})]})]}),(0,D.jsxs)(Te,{children:[(0,D.jsx)(je,{asChild:!0,children:(0,D.jsxs)(p,{size:`sm`,variant:`outline`,disabled:ln||Q.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,D.jsx)(Me,{className:`h-3.5 w-3.5 mr-1`}),S(`rejectN`,`Reject {{count}}`,{count:Q.length||``})]})}),(0,D.jsxs)(Oe,{children:[(0,D.jsxs)(qe,{children:[(0,D.jsx)(pe,{children:S(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:Q.length})}),(0,D.jsx)(ce,{children:S(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,D.jsxs)(ge,{children:[(0,D.jsx)(Se,{children:S(`cancel`,`Cancel`)}),(0,D.jsx)(le,{onClick:()=>Fn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`rejectN`,`Reject {{count}}`,{count:Q.length})})]})]})]}),(0,D.jsx)(p,{size:`sm`,variant:`ghost`,onClick:()=>cn(new Set),disabled:ln,children:S(`clear`,`Clear`)})]})]}),P?(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(m,{className:`h-10 w-full`}),(0,D.jsx)(m,{className:`h-10 w-full`}),(0,D.jsx)(m,{className:`h-10 w-full`})]}):M.length===0?(0,D.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,D.jsxs)(We,{children:[(0,D.jsx)(Qe,{children:S(`emptyTitle`,`No requests`)}),(0,D.jsx)(Re,{children:k===`pending`?S(`emptyPending`,`You're all caught up — nothing is waiting on you.`):S(`emptyOther`,`Nothing here yet.`)}),k===`pending`&&(0,D.jsx)(p,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Vn(`all`),children:S(`emptyViewAll`,`Browse all requests`)})]})}):Y.length===0?(0,D.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:S(`noMatches`,`No matches for current filters.`)}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ve,{className:`hidden md:block`,children:(0,D.jsx)(He,{className:`p-0`,children:(0,D.jsxs)(we,{children:[(0,D.jsx)(Je,{children:(0,D.jsxs)(he,{children:[k===`pending`&&(0,D.jsx)(d,{className:`w-10`,children:(0,D.jsx)(oe,{checked:Mn,onCheckedChange:Nn,"aria-label":S(`selectAll`,`Select all`),disabled:$.length===0})}),(0,D.jsx)(d,{className:`w-[22%]`,children:S(`colRequest`,`Request`)}),(0,D.jsx)(d,{className:`w-[30%]`,children:S(`colRecord`,`Record`)}),(0,D.jsx)(d,{className:`w-[16%]`,children:S(`colRequester`,`Requester`)}),(0,D.jsx)(d,{className:`w-[110px] min-w-[96px] whitespace-nowrap`,children:S(`colStatus`,`Status`)}),(0,D.jsx)(d,{className:`w-[132px]`,children:S(`colWaiting`,`Submitted`)}),(0,D.jsx)(d,{className:`w-20`,"aria-label":S(`colActions`,`Actions`)})]})}),(0,D.jsx)(ke,{children:Y.map((e,t)=>(0,D.jsxs)(he,{className:h(`group cursor-pointer hover:bg-accent/50`,vn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{yn(t),q(e.id)},children:[k===`pending`&&(0,D.jsx)(u,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,D.jsx)(oe,{checked:H.has(e.id),onCheckedChange:()=>Pn(e.id),disabled:e.status!==`pending`,"aria-label":S(`selectRow`,`Select request`)})}),(0,D.jsx)(u,{children:(0,D.jsx)(jt,{r:e,tr:S})}),(0,D.jsx)(u,{children:(0,D.jsx)(Mt,{r:e,href:qt.isUnreadable(e)?null:ht(e),hiddenKeys:z.forObject(e.object_name)})}),(0,D.jsx)(u,{children:Ct(e)?(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,D.jsx)(Ve,{className:`h-3.5 w-3.5 shrink-0`}),(0,D.jsx)(`span`,{className:`truncate italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,D.jsx)(Fe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,D.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:yt(e)})]})}),(0,D.jsx)(u,{children:(0,D.jsx)(gt,{status:e.status,label:T(e.status)})}),(0,D.jsxs)(u,{className:h(`text-xs whitespace-nowrap`,Tt(e,C)),title:_t(j(e)),children:[(0,D.jsx)(Ce,{className:`h-3 w-3 inline mr-1`}),w(j(e)),e.status===`pending`&&(()=>{let t=Dt(e.sla_due_at,C);return t?(0,D.jsx)(`div`,{className:h(`mt-0.5 text-[10px] font-medium`,t.overdue?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:ft(t)}):null})()]}),(0,D.jsx)(u,{className:`w-20`,children:(0,D.jsx)(Nt,{r:e,actionable:An(e),busy:pn===e.id,needsInputs:Z(e),tr:S,onApprove:dn,onReject:fn})})]},e.id))})]})})}),(0,D.jsx)(`div`,{className:`md:hidden space-y-2`,children:Y.map(e=>(0,D.jsx)(ve,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,D.jsxs)(He,{className:`p-3 space-y-1.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,D.jsx)(`div`,{className:`font-medium text-sm truncate`,children:A(e)}),(0,D.jsx)(gt,{status:e.status,label:T(e.status)})]}),(0,D.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||O(e.record_id),(0,D.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:wt(e)}),(()=>{let t=I(e,z.forObject(e.object_name));return t?(0,D.jsxs)(`span`,{className:`text-xs ml-1.5 font-medium`,title:t.label,children:[`· `,t.display]}):null})()]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[Ct(e)?(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate italic`,children:[(0,D.jsx)(Ve,{className:`h-3 w-3`}),S(`flowOrigin`,`Flow-initiated`)]}):(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,D.jsx)(Fe,{className:`h-3 w-3`}),yt(e)]}),(0,D.jsxs)(`span`,{className:h(`inline-flex items-center gap-1 whitespace-nowrap`,Tt(e,C)),children:[(0,D.jsx)(Ce,{className:`h-3 w-3`}),w(j(e))]})]}),An(e)&&(0,D.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),title:Z(e)?S(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`):void 0,children:[(0,D.jsxs)(p,{size:`sm`,className:`h-7 flex-1`,disabled:pn===e.id||Z(e),onClick:()=>dn(e),children:[(0,D.jsx)(Be,{className:`h-3.5 w-3.5 mr-1`}),S(`approve`,`Approve`)]}),(0,D.jsxs)(p,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:pn===e.id||Z(e),onClick:()=>fn(e),children:[(0,D.jsx)(Me,{className:`h-3.5 w-3.5 mr-1`}),S(`reject`,`Reject`)]})]})]})},e.id))}),k!==`pending`&&Pt!=null&&(0,D.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:M.length,total:Pt})}),M.length<Pt&&(0,D.jsx)(p,{size:`sm`,variant:`outline`,disabled:F,onClick:()=>void bn(),children:F?S(`loadingMore`,`Loading…`):S(`loadMore`,`Load more`)})]}),(0,D.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:S(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,D.jsx)(Te,{open:!!U,onOpenChange:e=>!e&&dn(null),children:(0,D.jsxs)(Oe,{children:[(0,D.jsxs)(qe,{children:[(0,D.jsx)(pe,{children:S(`approveOneTitle`,`Approve "{{title}}"?`,{title:U?U.record_title||O(U.record_id):``})}),(0,D.jsx)(ce,{children:S(`approveOneBody`,`This approves the request with your identity. To add a comment or attachment, open the request instead.`)})]}),(0,D.jsxs)(ge,{children:[(0,D.jsx)(Se,{children:S(`cancel`,`Cancel`)}),(0,D.jsx)(le,{onClick:()=>void In(),children:S(`approve`,`Approve`)})]})]})}),(0,D.jsx)(Te,{open:!!W,onOpenChange:e=>!e&&fn(null),children:(0,D.jsxs)(Oe,{children:[(0,D.jsxs)(qe,{children:[(0,D.jsx)(pe,{children:S(`rejectOneTitle`,`Reject "{{title}}"?`,{title:W?W.record_title||O(W.record_id):``})}),(0,D.jsx)(ce,{children:S(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,D.jsxs)(ge,{children:[(0,D.jsx)(Se,{children:S(`cancel`,`Cancel`)}),(0,D.jsx)(le,{onClick:()=>void Ln(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`reject`,`Reject`)})]})]})}),(0,D.jsx)(Ze,{open:!!L,onOpenChange:e=>!e&&xn(),children:(0,D.jsxs)(nt,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,D.jsxs)(tt,{children:[(0,D.jsx)(be,{children:R?A(R):S(`drawerTitle`,`Approval Request`)}),(0,D.jsx)(Pe,{children:R?vt(R)||wt(R):``})]}),R&&X>=0&&Y.length>1&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,D.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X<=0,onClick:()=>{let e=Y[X-1];e&&q(e.id)},children:[(0,D.jsx)(Ue,{className:`h-4 w-4 mr-0.5`}),S(`prevRequest`,`Previous`)]}),(0,D.jsx)(`span`,{children:S(`positionOf`,`Request {{index}} of {{total}}`,{index:X+1,total:Y.length})}),(0,D.jsxs)(p,{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:[S(`nextRequest`,`Next`),(0,D.jsx)(Ke,{className:`h-4 w-4 ml-0.5`})]})]}),Wt?(0,D.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,D.jsx)(m,{className:`h-6 w-3/4`}),(0,D.jsx)(m,{className:`h-6 w-1/2`}),(0,D.jsx)(m,{className:`h-20 w-full`})]}):R?(0,D.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,D.jsx)(gt,{status:R.status,label:T(R.status)}),(R.round??1)>1&&(0,D.jsx)(f,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:R.round})}),(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:_t(j(R)),children:[(0,D.jsx)(Ce,{className:`h-3 w-3`}),S(`submittedAgo`,`Submitted {{when}}`,{when:w(j(R))})]}),R.completed_at&&(0,D.jsxs)(`span`,{children:[`· `,S(`completedAt`,`Completed {{when}}`,{when:w(R.completed_at)})]}),R.status===`pending`&&(()=>{let e=Dt(R.sla_due_at,C);return e?(0,D.jsx)(f,{variant:`outline`,className:h(`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:ft(e)}):null})()]}),(()=>{let e=I(R,Jt),n=kt(R.payload,R.payload_display,R.payload_labels,6,e?.key,Jt);return(0,D.jsx)(ve,{children:(0,D.jsxs)(He,{className:`p-4 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[qt.isUnreadable(R)?(0,D.jsx)(`div`,{className:`text-base font-semibold truncate`,children:R.record_title||O(R.record_id)}):(0,D.jsxs)(t,{to:ht(R),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`truncate`,children:R.record_title||O(R.record_id)}),(0,D.jsx)(et,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:wt(R)})]}),(0,D.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,D.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:Ct(R)?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Ve,{className:`h-3 w-3`}),(0,D.jsx)(`span`,{className:`italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Fe,{className:`h-3 w-3`}),(0,D.jsx)(`span`,{title:R.submitter_id||``,children:yt(R)})]})})})]}),e&&(0,D.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,D.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e.label}),(0,D.jsx)(`div`,{className:`text-xl font-semibold tabular-nums`,title:e.display,children:e.display})]}),n.length>0&&(0,D.jsx)(`div`,{className:h(`grid grid-cols-2 gap-x-4 gap-y-2 text-sm`,!e&&`border-t pt-3`),children:n.map(([e,t])=>(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,D.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),R.decision_progress&&(()=>{let e=R.decision_progress,t=(R.pending_approvers||[]).length;return(0,D.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 mb-1.5`,children:[(0,D.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.behavior===`per_group`?S(`progressGroups`,`Sign-off progress — {{got}} of {{need}} groups`,{got:e.got,need:e.need}):S(`progressApprovals`,`Approvals — {{got}} of {{need}}`,{got:e.got,need:e.need})}),e.behavior!==`per_group`&&R.status===`pending`&&t>0&&(0,D.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:S(`progressEligible`,`{{count}} eligible approver(s)`,{count:t})})]}),(0,D.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":e.need,"aria-valuenow":Math.min(e.got,e.need),"aria-label":S(`progressBar`,`Decision progress`),className:`flex gap-1`,children:e.need>0&&e.need<=12?Array.from({length:e.need}).map((t,n)=>(0,D.jsx)(`div`,{className:h(`h-1.5 flex-1 rounded-full`,n<e.got?`bg-emerald-500`:`bg-muted`)},n)):(0,D.jsx)(`div`,{className:`h-1.5 flex-1 rounded-full bg-muted overflow-hidden`,children:(0,D.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,D.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.groups.map(e=>(0,D.jsxs)(f,{variant:`outline`,className:h(`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,D.jsx)(Le,{className:`h-3 w-3`}):(0,D.jsx)(me,{className:`h-2.5 w-2.5`}),e.group,` `,e.got,`/`,e.need]},e.group))})]})})(),R.status===`pending`&&(R.pending_approvers||[]).length>0&&(0,D.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,D.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:S(`waitingOn`,`Waiting on`)}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:St(R).map((e,t)=>(0,D.jsxs)(f,{variant:`outline`,className:`text-[11px]`,title:e.title,children:[e.label,e.group&&(0,D.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`· `,e.group]}),e.count>1&&(0,D.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.count]})]},`${e.label}-${e.group??``}-${t}`))})]})]})})})(),(R.flow_steps?.length??0)>1&&(0,D.jsx)(`ol`,{className:`flex flex-col px-1`,"aria-label":S(`stepProgress`,`Approval steps`),children:R.flow_steps.map((e,t,n)=>{let r=n[t+1];return(0,D.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col items-center self-stretch`,children:[(0,D.jsx)(`span`,{className:h(`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,D.jsx)(Le,{className:`h-3 w-3`}):t+1}),r&&(0,D.jsx)(`div`,{className:h(`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,D.jsx)(`span`,{className:h(`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,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:S(`history`,`Activity`)}),Ht.length===0?(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`noActions`,`No actions yet.`)}):(0,D.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:Ht.map(e=>{let t=ot(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`?S(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===R.submitter_id?yt(R):O(e.actor_id)),i=e.action===`submit`?S(`actSubmit`,`Submitted`):e.action===`approve`?S(`actApprove`,`Approved`):e.action===`reject`?S(`actReject`,`Rejected`):e.action===`recall`?S(`actRecall`,`Recalled`):e.action===`reassign`?S(`actReassign`,`Reassigned`):e.action===`remind`?S(`actRemind`,`Reminder sent`):e.action===`request_info`?S(`actRequestInfo`,`Requested more info`):e.action===`comment`?S(`actComment`,`Commented`):e.action===`escalate`?S(`actEscalate`,`SLA escalated`):e.action===`revise`?S(`actRevise`,`Sent back for revision`):e.action===`resubmit`?S(`actResubmit`,`Resubmitted`):e.action;return(0,D.jsxs)(`li`,{className:`relative text-xs`,children:[(0,D.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${n}`,"aria-hidden":!0}),(0,D.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,D.jsx)(`span`,{className:`font-medium`,children:i}),(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,D.jsx)(`span`,{title:e.actor_id||``,children:r}),t&&(0,D.jsxs)(f,{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:S(`viaOverrideHint`,`The actor held no approver slot on this step — admitted by the admin-override path.`),"data-testid":`via-override-chip`,children:[(0,D.jsx)(Ie,{className:`h-3 w-3`,"aria-hidden":!0}),S(`viaOverrideChip`,`Admin override`)]}),(0,D.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:_t(e.created_at),children:w(e.created_at)})]}),(()=>{let t=e;return e.action!==`reassign`||!t.reassign_from&&!t.reassign_to?null:(0,D.jsx)(`div`,{className:`text-muted-foreground mt-0.5`,children:S(`reassignFromTo`,`from {{from}} to {{to}}`,{from:t.reassign_from_name??O(t.reassign_from),to:t.reassign_to_name??O(t.reassign_to)})})})(),e.comment&&(0,D.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]}),Array.isArray(e.attachments)&&e.attachments.length>0&&(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((t,n)=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void Xt(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,D.jsx)(de,{className:`h-3 w-3`}),t.name||`${S(`attachmentChip`,`Attachment`)}${e.attachments.length>1?` ${n+1}`:``}`]},t.id||n))})]},e.id)})}),R.status===`pending`&&(Tn||En)&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,D.jsx)(fe,{value:G,onChange:e=>hn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&G.trim()&&(e.preventDefault(),wn())},placeholder:S(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,D.jsx)(p,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!G.trim()||gn,onClick:()=>void wn(),children:(0,D.jsx)(ze,{className:`h-3.5 w-3.5`})})]})]}),x&&R.payload!=null&&(0,D.jsxs)(`details`,{className:`group`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:S(`rawData`,`Raw data (JSON)`)}),(0,D.jsxs)(`div`,{className:`mt-2`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(R.payload,null,2)),g.success(S(`copied`,`Copied`))}catch{g.error(S(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,D.jsx)(se,{className:`h-3 w-3`}),S(`copy`,`Copy`)]})}),(0,D.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,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ie,{}),(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(at,{objectName:`sys_approval_request`,record:R,location:`record_section`,label:S(`declaredActions`,`Actions`),onDone:()=>{Cn()}}),!Tn&&(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:En?S(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):S(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(R.pending_approvers||[]).map(e=>bt(e,R)).join(`, `)||`—`})})]})]}),Dn&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ie,{}),(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,D.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,D.jsx)(p,{asChild:!0,size:`sm`,variant:`outline`,children:(0,D.jsxs)(t,{to:ht(R),children:[(0,D.jsx)(et,{className:`h-4 w-4 mr-1`}),S(`editRecordBtn`,`Edit record`)]})}),(0,D.jsx)(at,{objectName:`sys_approval_request`,record:R,location:`record_section`,onDone:()=>{Sn(R.id),K()}})]})]})]})]}):null]})})]})}export{Pt as ApprovalsInboxPage};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,b as n,g as r,h as i,r as a}from"./vendor-react-CsWFRkED.js";import{c as o,g as s,n as c,y as ee}from"./infrastructure-B4zG1jNa.js";import{q as te}from"./framework-DFE_Mws9.js";import{y as ne}from"./i18n-locales-BBA090ve.js";import{Bt as re,Cn as ie,Dn as ae,Dr as oe,En as l,Fs as se,Gr as ce,Gt as u,Hr as le,Ht as ue,Ia as de,In as fe,Jr as pe,Js as me,Jt as he,Kr as ge,Kt as d,On as _e,Or as ve,Pr as f,Rr as ye,Sn as be,Tn as xe,Ur as Se,Us as Ce,Ut as we,Vr as Te,Vt as Ee,Wi as De,Wr as Oe,Wt as ke,Xr as p,Yc as Ae,Yr as je,Ys as Me,aa as Ne,bn as Pe,di as Fe,ea as Ie,gc as Le,gn as m,ht as Re,ia as ze,ic as Be,ii as Ve,il as h,kr as He,mc as Ue,mt as We,ni as Ge,pc as Ke,qr as qe,qt as Je,sc as Ye,va as Xe,vn as Ze,vt as Qe,wn as $e,ws as et,xn as tt,yn as nt,zr as rt,zt as it}from"./ui-components-CMHDBJEm.js";import{r as g}from"./vendor-ui-utils-BFw4cGI6.js";import{r as at,y as ot}from"./RecordDetailView-XWxuegfV.js";import"./src-hcMLuWxG.js";import{t as st}from"./studioEntry-BUFsLXCL.js";var _=e(n(),1),ct=`${``.replace(/\/$/,``)}/api/v1`;async function v(e,t){let n=ee.get(),r=await fetch(`${ct}${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 y={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return v(`/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 v(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await v(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return v(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await v(`/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 v(`/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 v(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await v(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await v(`/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 v(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await v(`/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 v(`/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 v(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return v(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function lt(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 b(e,t){return`${e}::${t}`}function x(e){return typeof e.object_name==`string`&&e.object_name!==``&&typeof e.record_id==`string`&&e.record_id!==``}function S(e){let t=new Map,n=new Set;for(let r of e){if(!x(r))continue;let e=b(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 C(e){if(Array.isArray(e))return e;let t=e?.data;return Array.isArray(t)?t:[]}async function ut(e,t){let n=new Map,r=S(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(C(n).map(e=>e?.id).filter(e=>typeof e==`string`&&e!==``))}catch{return}for(let e of r)n.set(b(t,e),i.has(e))})),n}function dt(e){let t=te(),[n,r]=(0,_.useState)(()=>new Map),i=(0,_.useRef)(new Set),a=(0,_.useRef)(e);a.current=e;let o=(0,_.useMemo)(()=>e.filter(x).map(e=>b(e.object_name,e.record_id)).join(`|`),[e]);return(0,_.useEffect)(()=>{if(!t)return;let e=a.current.filter(e=>x(e)&&!i.current.has(b(e.object_name,e.record_id)));if(e.length===0)return;for(let t of e)x(t)&&i.current.add(b(t.object_name,t.record_id));let n=!1;return ut(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,_.useMemo)(()=>({isUnreadable:e=>x(e)&&n.get(b(e.object_name,e.record_id))===!1}),[n])}var w=new Set;function T(e){let t=e?.fields;if(!t||typeof t!=`object`)return w;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:w}async function E(e,t){if(typeof e?.getObjectSchema!=`function`)return w;try{return T(await e.getObjectSchema(t))}catch{return w}}function ft(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 pt(e){let t=te(),[n,r]=(0,_.useState)(()=>new Map),i=(0,_.useRef)(new Set),a=(0,_.useRef)(e);a.current=e;let o=(0,_.useMemo)(()=>ft(e).join(`|`),[e]);return(0,_.useEffect)(()=>{if(!t)return;let e=ft(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 E(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,_.useMemo)(()=>({forObject:e=>typeof e==`string`&&e!==``?n.get(e)??w:w}),[n])}var D=a(),mt=50,ht={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`};function gt({status:e,label:t}){return(0,D.jsx)(f,{variant:`outline`,className:h(`font-medium`,ht[e]??``),children:t})}function _t(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function O(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 k(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function A(e){return e.process_label||k(e.process_name)}function vt(e){return e.step_label?e.step_label:e.current_step?k(e.current_step):null}function yt(e){return e.submitter_name||O(e.submitter_id)}function bt(e,t){return t.pending_approver_names?.[e]||O(e)}function xt(e,t){let n=t.pending_approver_groups?.[e];return n&&n.length?n.join(` / `):void 0}function St(e){let t=[],n=new Map;for(let r of e.pending_approvers||[]){let i=bt(r,e),a=xt(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 Ct(e){if(e.submitter_name)return!1;let t=(e.submitter_id||``).trim();return!t||t.startsWith(`flow:`)||t.startsWith(`system:`)}function wt(e){return e.object_label||e.object_name}function j(e){return e.submitted_at||e.created_at||void 0}function M(e,t){let n=j(e);if(!n)return null;let r=Date.parse(n);return Number.isNaN(r)?null:(t-r)/36e5}function Tt(e,t){if(e.status!==`pending`)return`text-muted-foreground`;let n=M(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 Et(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}function Dt(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 N=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function P(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 Ot(e,t){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()}catch{}return t.toLocaleString()}let n=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(n))try{return new Date(n).toLocaleString()}catch{}return n}var F=/^[A-Za-z0-9_-]{15,}$/;function kt(e,t,n,r=6,i,a){if(!e||typeof e!=`object`||Array.isArray(e))return[];let o=[];for(let[s,c]of Object.entries(e)){if(N.has(s)||a?.has(s)||i&&s===i||c==null||typeof c==`object`||String(c).trim()===``)continue;let e=t?.[s];if(!(!e&&typeof c==`string`&&F.test(c.trim())&&!/^\d+$/.test(c.trim()))&&(o.push([n?.[s]??P(s),e??Ot(s,c)]),o.length>=r))break}return o}var At=/(amount|total|price|value|cost|sum|budget|salary|fee|revenue|balance|金额|总额|价格|费用|预算|金额)/i;function I(e,t){let n=e.payload;if(!n||typeof n!=`object`||Array.isArray(n))return null;for(let[r,i]of Object.entries(n)){if(N.has(r)||t.has(r)||!At.test(r))continue;let n=typeof i==`number`?i:typeof i==`string`&&i.trim()!==``&&Number.isFinite(Number(i))?Number(i):null;if(!(n==null||!Number.isFinite(n)))return{key:r,label:e.payload_labels?.[r]??P(r),value:n,display:e.payload_display?.[r]??n.toLocaleString()}}return null}function jt({r:e,tr:t}){return(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`div`,{className:`font-medium truncate`,children:A(e)}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[vt(e)||`—`,(e.round??1)>1&&(0,D.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:t(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Mt({r:e,href:n,hiddenKeys:r}){let i=I(e,r),a=e.record_title||O(e.record_id);return(0,D.jsxs)(`div`,{className:`min-w-0`,children:[n===null?(0,D.jsx)(`div`,{className:`text-sm truncate max-w-full`,title:e.record_id,children:a}):(0,D.jsxs)(t,{to:n,onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:e.record_id,children:[(0,D.jsx)(`span`,{className:`truncate`,children:a}),(0,D.jsx)(et,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[wt(e),i&&(0,D.jsxs)(`span`,{className:`ml-1.5 font-medium text-foreground`,title:`${i.label}: ${i.display}`,children:[`· `,i.display]})]})]})}function Nt({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,D.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,D.jsx)(p,{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,D.jsx)(Be,{className:`h-4 w-4`})}),(0,D.jsx)(p,{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,D.jsx)(Me,{className:`h-4 w-4`})})]})}function Pt(){let{t:e,language:n}=ne(),{user:a}=s(),{appName:ee}=i(),[te,ct]=r(),v=(0,_.useMemo)(()=>lt(a),[a]),{systemPermissions:b}=c(),x=st(b),S=(0,_.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),[C,ut]=(0,_.useState)(()=>Date.now());(0,_.useEffect)(()=>{let e=setInterval(()=>ut(Date.now()),6e4);return()=>clearInterval(e)},[]);let w=(0,_.useCallback)(e=>{if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let r=Math.round((C-t)/1e3);if(r<45)return S(`justNow`,`just now`);let i=Math.round(r/60);if(i<60)return S(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return S(`hoursAgo`,`{{count}}h ago`,{count:a});let o=Math.round(a/24);if(o<30)return S(`daysAgo`,`{{count}}d ago`,{count:o});try{return new Date(e).toLocaleDateString(n)}catch{return e}},[S,n,C]),T=(0,_.useCallback)(e=>{switch(e){case`pending`:return S(`statusPending`,`Pending`);case`approved`:return S(`statusApproved`,`Approved`);case`rejected`:return S(`statusRejected`,`Rejected`);case`recalled`:return S(`statusRecalled`,`Recalled`);case`returned`:return S(`statusReturned`,`Returned for revision`);default:return e}},[S]),E=(0,_.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?S(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?S(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?S(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?S(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?S(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[S]),ft=(0,_.useCallback)(e=>e.overdue?S(`slaOverdue`,`SLA overdue {{dur}}`,{dur:Et(e.ms)}):S(`slaRemaining`,`SLA {{dur}} left`,{dur:Et(e.ms)}),[S]),ht=(0,_.useCallback)(e=>`/apps/${ee||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[ee]),[k,xt]=(0,_.useState)(`pending`),[M,N]=(0,_.useState)([]),[P,Ot]=(0,_.useState)(!1),[F,At]=(0,_.useState)(!1),[Pt,Ft]=(0,_.useState)(null),[It,Lt]=(0,_.useState)(null),[Rt,zt]=(0,_.useState)(0),[L,Bt]=(0,_.useState)(null),[R,Vt]=(0,_.useState)(null),[Ht,Ut]=(0,_.useState)([]),[Wt,Gt]=(0,_.useState)(!1),Kt=(0,_.useMemo)(()=>R?[...M,R]:M,[M,R]),qt=dt(Kt),z=pt((0,_.useMemo)(()=>Kt.map(e=>e.object_name),[Kt])),Jt=z.forObject(R?.object_name),Yt=(0,_.useMemo)(()=>o(),[]),Xt=(0,_.useCallback)(async e=>{let t=window.open(``,`_blank`,`noopener`);try{let n=``.replace(/\/$/,``),r=await Yt(`${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(S(`attachmentOpenFailed`,`Could not open the attachment — please try again`))}},[Yt,S]),[B,Zt]=(0,_.useState)(``),[Qt,$t]=(0,_.useState)(``),[en,tn]=(0,_.useState)(`all`),[nn,rn]=(0,_.useState)(`all`),[V,an]=(0,_.useState)(`all`),[on,sn]=(0,_.useState)(`recent`),[H,cn]=(0,_.useState)(new Set),[ln,un]=(0,_.useState)(!1),[U,dn]=(0,_.useState)(null),[W,fn]=(0,_.useState)(null),[pn,mn]=(0,_.useState)(null),[G,hn]=(0,_.useState)(``),[gn,_n]=(0,_.useState)(!1),[vn,yn]=(0,_.useState)(-1);(0,_.useEffect)(()=>{if(k===`pending`)return;let e=window.setTimeout(()=>$t(B),350);return()=>window.clearTimeout(e)},[B,k]);let K=(0,_.useCallback)(async()=>{Ot(!0),Lt(null);try{let e=[];if(k===`pending`)e=v.length?(await y.listRequests({status:`pending`,approverId:v})).data:[],zt(e.length),Ft(null);else{let t={q:Qt||void 0,status:V===`all`?void 0:V,limit:mt,offset:0};if(k===`submitted`){let n=a?.id;if(n){let r=await y.listRequests({submitterId:n,...t});e=r.data,Ft(r.total??r.data.length)}else e=[],Ft(0)}else{let n=await y.listRequests(t);e=n.data,Ft(n.total??n.data.length)}v.length&&y.listRequests({status:`pending`,approverId:v}).then(e=>zt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(j(t)||``).localeCompare(j(e)||``)),N(e)}catch(e){Lt(e?.message||String(e)),N([])}finally{Ot(!1)}},[k,v,a?.id,Qt,V]);(0,_.useEffect)(()=>{K()},[K]);let bn=(0,_.useCallback)(async()=>{if(!(k===`pending`||F)){At(!0);try{let e=await y.listRequests({submitterId:k===`submitted`?a?.id??void 0:void 0,q:Qt||void 0,status:V===`all`?void 0:V,limit:mt,offset:M.length});N(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&Ft(e.total)}catch(e){g.error(E(e,S(`loadFailed`,`Failed to load request`)))}finally{At(!1)}}},[k,F,a?.id,Qt,V,M.length,E,S]),q=(0,_.useCallback)(async e=>{Bt(e),Gt(!0);try{let[t,n]=await Promise.all([y.getRequest(e),y.listActions(e)]);Vt(t.data),Ut(n.data)}catch(e){g.error(E(e,S(`loadFailed`,`Failed to load request`))),Vt(null),Ut([])}finally{Gt(!1)}},[E,S]),xn=()=>{Bt(null),Vt(null),Ut([])};(0,_.useEffect)(()=>{let e=te.get(`request`);e&&(ct(e=>{let t=new URLSearchParams(e);return t.delete(`request`),t},{replace:!0}),q(e))},[te]);let J=(0,_.useCallback)(()=>{v.length&&y.listRequests({status:`pending`,approverId:v}).then(e=>zt(e.data.length)).catch(()=>{})},[v]),Sn=(0,_.useCallback)(async e=>{let[t,n]=await Promise.all([y.getRequest(e),y.listActions(e)]);Vt(t.data),Ut(n.data),K()},[K]),Cn=(0,_.useCallback)(async()=>{if(!R)return;let e=R.id;try{let[t,n]=await Promise.all([y.getRequest(e),y.listActions(e)]);Vt(t.data),Ut(n.data),K();let r=new Set(t.data.pending_approvers||[]),i=t.data.status===`pending`&&v.some(e=>r.has(e));if(k===`pending`&&!i){let t=Rn.current,n=t.findIndex(t=>t.id===e),r=t[n+1]??t[n-1];if(r&&r.id!==e){q(r.id);return}xn()}}catch{Sn(e)}},[R,v,k,K,q,xn,Sn]),wn=(0,_.useCallback)(async()=>{if(!(!R||!G.trim())){_n(!0);try{await y.comment(R.id,{actor_id:a?.id,comment:G.trim()}),hn(``),await Sn(R.id)}catch(e){g.error(E(e,S(`actionFailed`,`Action failed`)))}finally{_n(!1)}}},[R,G,a?.id,Sn,E,S]),Tn=(0,_.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 v.some(t=>e.has(t))},[R,v]),En=(0,_.useMemo)(()=>!R||R.status!==`pending`?!1:R.viewer?R.viewer.is_submitter:R.submitter_id===a?.id,[R,a?.id]),Dn=(0,_.useMemo)(()=>!R||R.status!==`returned`?!1:R.viewer?R.viewer.is_submitter:R.submitter_id===a?.id,[R,a?.id]),On=(0,_.useMemo)(()=>{let e=new Set;for(let t of M)e.add(A(t));return Array.from(e).sort()},[M]),kn=(0,_.useMemo)(()=>{let e=new Set;for(let t of M)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[M]),Y=(0,_.useMemo)(()=>{let e=B.trim().toLowerCase(),t=M.filter(t=>en!==`all`&&A(t)!==en||nn!==`all`&&t.object_name!==nn||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(on===`recent`)return t;let n=[...t];return on===`amount`?n.sort((e,t)=>{let n=I(e,z.forObject(e.object_name))?.value,r=I(t,z.forObject(t.object_name))?.value;return n==null&&r==null?0:n==null?1:r==null?-1:r-n}):n.sort((e,t)=>(j(e)||``).localeCompare(j(t)||``)),n},[M,B,en,nn,V,k,on,z]),X=(0,_.useMemo)(()=>L?Y.findIndex(e=>e.id===L):-1,[Y,L]);(0,_.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&&cn(n)},[Y,H]),(0,_.useEffect)(()=>{vn>=Y.length&&yn(Y.length-1)},[Y.length,vn]);let An=(0,_.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(v);return(e.pending_approvers||[]).some(e=>t.has(e))},[v]),Z=(0,_.useCallback)(e=>Array.isArray(e.decision_outputs)&&e.decision_outputs.length>0,[]),jn=(0,_.useCallback)(e=>An(e)&&!Z(e),[An,Z]),Q=(0,_.useMemo)(()=>Y.filter(e=>H.has(e.id)&&jn(e)),[Y,H,jn]),$=Y.filter(e=>e.status===`pending`),Mn=$.length>0&&$.every(e=>H.has(e.id)),Nn=(0,_.useCallback)(()=>{cn(e=>{if(Mn)return new Set;let t=new Set(e);for(let e of $)t.add(e.id);return t})},[Mn,$]),Pn=(0,_.useCallback)(e=>{cn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Fn=(0,_.useCallback)(async e=>{let t=Q;if(t.length===0)return;un(!0);let n=0,r=[];for(let i of t){let t=new Set(i.pending_approvers||[]),o=v.find(e=>t.has(e))||a?.id||``;try{await(e===`approve`?y.approve:y.reject)(i.id,{actor_id:o}),n++}catch{r.push(i.record_title||O(i.record_id))}}if(un(!1),cn(new Set),r.length===0)g.success(e===`approve`?S(`bulkApproved`,`Approved {{count}} requests`,{count:n}):S(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);g.error(S(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),J()},[Q,v,a?.id,K,J,S]),In=(0,_.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=v.find(e=>t.has(e))||a?.id||``;mn(e.id),dn(null);try{let t=await y.approve(e.id,{actor_id:n});g.success(t.finalized?S(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||O(e.record_id)}):S(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),J()}catch(e){g.error(E(e,S(`actionFailed`,`Action failed`)))}finally{mn(null)}},[U,v,a?.id,K,J,E,S]),Ln=(0,_.useCallback)(async()=>{let e=W;if(!e)return;let t=new Set(e.pending_approvers||[]),n=v.find(e=>t.has(e))||a?.id||``;mn(e.id),fn(null);try{await y.reject(e.id,{actor_id:n}),g.success(S(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||O(e.record_id)})),K(),J()}catch(e){g.error(E(e,S(`actionFailed`,`Action failed`)))}finally{mn(null)}},[W,v,a?.id,K,J,E,S]),Rn=(0,_.useRef)(Y);Rn.current=Y;let zn=(0,_.useRef)(vn);zn.current=vn,(0,_.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=Rn.current;if(!r.length)return;let i=zn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),yn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),yn(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(),Pn(r[i].id)):e.key===`a`&&i>=0&&r[i]&&jn(r[i])?(e.preventDefault(),dn(r[i])):e.key===`r`&&i>=0&&r[i]&&jn(r[i])&&(e.preventDefault(),fn(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[L,U,W,k,q,Pn,jn]),(0,_.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=Rn.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 Bn=!!B||en!==`all`||nn!==`all`||V!==`all`,Vn=e=>{xt(e),an(`all`),tn(`all`),rn(`all`),Zt(``),sn(`recent`),yn(-1)};return(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,D.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,D.jsx)(De,{className:`h-6 w-6`}),S(`title`,`Approvals Inbox`)]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:S(`subtitle`,`Review and act on approval requests.`)})]}),(0,D.jsxs)(p,{variant:`outline`,size:`sm`,onClick:K,disabled:P,className:`self-start sm:self-auto`,children:[(0,D.jsx)(Xe,{className:`h-4 w-4 mr-2 ${P?`animate-spin`:``}`}),S(`refresh`,`Refresh`)]})]}),It&&(0,D.jsxs)(ye,{variant:`destructive`,children:[(0,D.jsx)(Ye,{className:`h-4 w-4`}),(0,D.jsx)(rt,{children:It})]}),(0,D.jsxs)(it,{value:k,onValueChange:Vn,children:[(0,D.jsxs)(Ee,{children:[(0,D.jsxs)(ue,{value:`pending`,children:[S(`tabMyPending`,`My Pending`),Rt>0&&(0,D.jsx)(f,{variant:`secondary`,className:`ml-2`,children:Rt})]}),(0,D.jsx)(ue,{value:`submitted`,children:S(`tabSubmitted`,`Submitted by me`)}),(0,D.jsx)(ue,{value:`all`,children:S(`tabAll`,`All`)})]}),(0,D.jsxs)(re,{value:k,className:`mt-4 space-y-3`,children:[!P&&(M.length>0||k!==`pending`&&(Qt||V!==`all`))&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,D.jsx)(Ne,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,D.jsx)(fe,{value:B,onChange:e=>Zt(e.target.value),placeholder:S(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),B&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>Zt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":S(`clearSearch`,`Clear search`),children:(0,D.jsx)(Ge,{className:`h-3.5 w-3.5`})})]}),k!==`pending`&&(0,D.jsxs)($e,{value:V,onValueChange:an,children:[(0,D.jsx)(ae,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,D.jsx)(_e,{placeholder:S(`statusFilter`,`Status`)})}),(0,D.jsxs)(xe,{children:[(0,D.jsx)(l,{value:`all`,children:S(`allStatuses`,`All statuses`)}),(0,D.jsx)(l,{value:`pending`,children:T(`pending`)}),(0,D.jsx)(l,{value:`approved`,children:T(`approved`)}),(0,D.jsx)(l,{value:`rejected`,children:T(`rejected`)}),(0,D.jsx)(l,{value:`recalled`,children:T(`recalled`)}),(0,D.jsx)(l,{value:`returned`,children:T(`returned`)})]})]}),On.length>1&&(0,D.jsxs)($e,{value:en,onValueChange:tn,children:[(0,D.jsx)(ae,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,D.jsx)(_e,{placeholder:S(`processFilter`,`Process`)})}),(0,D.jsxs)(xe,{children:[(0,D.jsx)(l,{value:`all`,children:S(`allProcesses`,`All processes`)}),On.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),kn.length>1&&(0,D.jsxs)($e,{value:nn,onValueChange:rn,children:[(0,D.jsx)(ae,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,D.jsx)(_e,{placeholder:S(`objectFilter`,`Object`)})}),(0,D.jsxs)(xe,{children:[(0,D.jsx)(l,{value:`all`,children:S(`allObjects`,`All objects`)}),kn.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),(0,D.jsxs)($e,{value:on,onValueChange:e=>sn(e),children:[(0,D.jsxs)(ae,{className:`h-8 w-auto min-w-[120px] text-sm`,children:[(0,D.jsx)(Ae,{className:`h-3.5 w-3.5 mr-1 text-muted-foreground`}),(0,D.jsx)(_e,{placeholder:S(`sortBy`,`Sort`)})]}),(0,D.jsxs)(xe,{children:[(0,D.jsx)(l,{value:`recent`,children:S(`sortRecent`,`Newest first`)}),(0,D.jsx)(l,{value:`oldest`,children:S(`sortOldest`,`Oldest first`)}),(0,D.jsx)(l,{value:`amount`,children:S(`sortAmount`,`Amount (high→low)`)})]})]}),Bn&&(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`filterCount`,`{{shown}} of {{total}}`,{shown:Y.length,total:M.length})})]}),k===`pending`&&H.size>0&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:H.size}),` `,S(`selected`,`selected`),Q.length!==H.size&&(0,D.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:S(`actionableCount`,`({{count}} actionable)`,{count:Q.length})})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsxs)(Te,{children:[(0,D.jsx)(je,{asChild:!0,children:(0,D.jsxs)(p,{size:`sm`,disabled:ln||Q.length===0,children:[(0,D.jsx)(Be,{className:`h-3.5 w-3.5 mr-1`}),S(`approveN`,`Approve {{count}}`,{count:Q.length||``})]})}),(0,D.jsxs)(Oe,{children:[(0,D.jsxs)(qe,{children:[(0,D.jsx)(pe,{children:S(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:Q.length})}),(0,D.jsx)(ce,{children:S(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,D.jsxs)(ge,{children:[(0,D.jsx)(Se,{children:S(`cancel`,`Cancel`)}),(0,D.jsx)(le,{onClick:()=>Fn(`approve`),children:S(`approveN`,`Approve {{count}}`,{count:Q.length})})]})]})]}),(0,D.jsxs)(Te,{children:[(0,D.jsx)(je,{asChild:!0,children:(0,D.jsxs)(p,{size:`sm`,variant:`outline`,disabled:ln||Q.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,D.jsx)(Me,{className:`h-3.5 w-3.5 mr-1`}),S(`rejectN`,`Reject {{count}}`,{count:Q.length||``})]})}),(0,D.jsxs)(Oe,{children:[(0,D.jsxs)(qe,{children:[(0,D.jsx)(pe,{children:S(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:Q.length})}),(0,D.jsx)(ce,{children:S(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,D.jsxs)(ge,{children:[(0,D.jsx)(Se,{children:S(`cancel`,`Cancel`)}),(0,D.jsx)(le,{onClick:()=>Fn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`rejectN`,`Reject {{count}}`,{count:Q.length})})]})]})]}),(0,D.jsx)(p,{size:`sm`,variant:`ghost`,onClick:()=>cn(new Set),disabled:ln,children:S(`clear`,`Clear`)})]})]}),P?(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(m,{className:`h-10 w-full`}),(0,D.jsx)(m,{className:`h-10 w-full`}),(0,D.jsx)(m,{className:`h-10 w-full`})]}):M.length===0?(0,D.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,D.jsxs)(We,{children:[(0,D.jsx)(Qe,{children:S(`emptyTitle`,`No requests`)}),(0,D.jsx)(Re,{children:k===`pending`?S(`emptyPending`,`You're all caught up — nothing is waiting on you.`):S(`emptyOther`,`Nothing here yet.`)}),k===`pending`&&(0,D.jsx)(p,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Vn(`all`),children:S(`emptyViewAll`,`Browse all requests`)})]})}):Y.length===0?(0,D.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:S(`noMatches`,`No matches for current filters.`)}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ve,{className:`hidden md:block`,children:(0,D.jsx)(He,{className:`p-0`,children:(0,D.jsxs)(we,{children:[(0,D.jsx)(Je,{children:(0,D.jsxs)(he,{children:[k===`pending`&&(0,D.jsx)(d,{className:`w-10`,children:(0,D.jsx)(oe,{checked:Mn,onCheckedChange:Nn,"aria-label":S(`selectAll`,`Select all`),disabled:$.length===0})}),(0,D.jsx)(d,{className:`w-[22%]`,children:S(`colRequest`,`Request`)}),(0,D.jsx)(d,{className:`w-[30%]`,children:S(`colRecord`,`Record`)}),(0,D.jsx)(d,{className:`w-[16%]`,children:S(`colRequester`,`Requester`)}),(0,D.jsx)(d,{className:`w-[110px] min-w-[96px] whitespace-nowrap`,children:S(`colStatus`,`Status`)}),(0,D.jsx)(d,{className:`w-[132px]`,children:S(`colWaiting`,`Submitted`)}),(0,D.jsx)(d,{className:`w-20`,"aria-label":S(`colActions`,`Actions`)})]})}),(0,D.jsx)(ke,{children:Y.map((e,t)=>(0,D.jsxs)(he,{className:h(`group cursor-pointer hover:bg-accent/50`,vn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{yn(t),q(e.id)},children:[k===`pending`&&(0,D.jsx)(u,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,D.jsx)(oe,{checked:H.has(e.id),onCheckedChange:()=>Pn(e.id),disabled:e.status!==`pending`,"aria-label":S(`selectRow`,`Select request`)})}),(0,D.jsx)(u,{children:(0,D.jsx)(jt,{r:e,tr:S})}),(0,D.jsx)(u,{children:(0,D.jsx)(Mt,{r:e,href:qt.isUnreadable(e)?null:ht(e),hiddenKeys:z.forObject(e.object_name)})}),(0,D.jsx)(u,{children:Ct(e)?(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,D.jsx)(Ve,{className:`h-3.5 w-3.5 shrink-0`}),(0,D.jsx)(`span`,{className:`truncate italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,D.jsx)(Fe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,D.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:yt(e)})]})}),(0,D.jsx)(u,{children:(0,D.jsx)(gt,{status:e.status,label:T(e.status)})}),(0,D.jsxs)(u,{className:h(`text-xs whitespace-nowrap`,Tt(e,C)),title:_t(j(e)),children:[(0,D.jsx)(Ce,{className:`h-3 w-3 inline mr-1`}),w(j(e)),e.status===`pending`&&(()=>{let t=Dt(e.sla_due_at,C);return t?(0,D.jsx)(`div`,{className:h(`mt-0.5 text-[10px] font-medium`,t.overdue?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:ft(t)}):null})()]}),(0,D.jsx)(u,{className:`w-20`,children:(0,D.jsx)(Nt,{r:e,actionable:An(e),busy:pn===e.id,needsInputs:Z(e),tr:S,onApprove:dn,onReject:fn})})]},e.id))})]})})}),(0,D.jsx)(`div`,{className:`md:hidden space-y-2`,children:Y.map(e=>(0,D.jsx)(ve,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,D.jsxs)(He,{className:`p-3 space-y-1.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,D.jsx)(`div`,{className:`font-medium text-sm truncate`,children:A(e)}),(0,D.jsx)(gt,{status:e.status,label:T(e.status)})]}),(0,D.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||O(e.record_id),(0,D.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:wt(e)}),(()=>{let t=I(e,z.forObject(e.object_name));return t?(0,D.jsxs)(`span`,{className:`text-xs ml-1.5 font-medium`,title:t.label,children:[`· `,t.display]}):null})()]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[Ct(e)?(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate italic`,children:[(0,D.jsx)(Ve,{className:`h-3 w-3`}),S(`flowOrigin`,`Flow-initiated`)]}):(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,D.jsx)(Fe,{className:`h-3 w-3`}),yt(e)]}),(0,D.jsxs)(`span`,{className:h(`inline-flex items-center gap-1 whitespace-nowrap`,Tt(e,C)),children:[(0,D.jsx)(Ce,{className:`h-3 w-3`}),w(j(e))]})]}),An(e)&&(0,D.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),title:Z(e)?S(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`):void 0,children:[(0,D.jsxs)(p,{size:`sm`,className:`h-7 flex-1`,disabled:pn===e.id||Z(e),onClick:()=>dn(e),children:[(0,D.jsx)(Be,{className:`h-3.5 w-3.5 mr-1`}),S(`approve`,`Approve`)]}),(0,D.jsxs)(p,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:pn===e.id||Z(e),onClick:()=>fn(e),children:[(0,D.jsx)(Me,{className:`h-3.5 w-3.5 mr-1`}),S(`reject`,`Reject`)]})]})]})},e.id))}),k!==`pending`&&Pt!=null&&(0,D.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:M.length,total:Pt})}),M.length<Pt&&(0,D.jsx)(p,{size:`sm`,variant:`outline`,disabled:F,onClick:()=>void bn(),children:F?S(`loadingMore`,`Loading…`):S(`loadMore`,`Load more`)})]}),(0,D.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:S(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,D.jsx)(Te,{open:!!U,onOpenChange:e=>!e&&dn(null),children:(0,D.jsxs)(Oe,{children:[(0,D.jsxs)(qe,{children:[(0,D.jsx)(pe,{children:S(`approveOneTitle`,`Approve "{{title}}"?`,{title:U?U.record_title||O(U.record_id):``})}),(0,D.jsx)(ce,{children:S(`approveOneBody`,`This approves the request with your identity. To add a comment or attachment, open the request instead.`)})]}),(0,D.jsxs)(ge,{children:[(0,D.jsx)(Se,{children:S(`cancel`,`Cancel`)}),(0,D.jsx)(le,{onClick:()=>void In(),children:S(`approve`,`Approve`)})]})]})}),(0,D.jsx)(Te,{open:!!W,onOpenChange:e=>!e&&fn(null),children:(0,D.jsxs)(Oe,{children:[(0,D.jsxs)(qe,{children:[(0,D.jsx)(pe,{children:S(`rejectOneTitle`,`Reject "{{title}}"?`,{title:W?W.record_title||O(W.record_id):``})}),(0,D.jsx)(ce,{children:S(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,D.jsxs)(ge,{children:[(0,D.jsx)(Se,{children:S(`cancel`,`Cancel`)}),(0,D.jsx)(le,{onClick:()=>void Ln(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`reject`,`Reject`)})]})]})}),(0,D.jsx)(Ze,{open:!!L,onOpenChange:e=>!e&&xn(),children:(0,D.jsxs)(nt,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,D.jsxs)(tt,{children:[(0,D.jsx)(be,{children:R?A(R):S(`drawerTitle`,`Approval Request`)}),(0,D.jsx)(Pe,{children:R?vt(R)||wt(R):``})]}),R&&X>=0&&Y.length>1&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,D.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X<=0,onClick:()=>{let e=Y[X-1];e&&q(e.id)},children:[(0,D.jsx)(Ue,{className:`h-4 w-4 mr-0.5`}),S(`prevRequest`,`Previous`)]}),(0,D.jsx)(`span`,{children:S(`positionOf`,`Request {{index}} of {{total}}`,{index:X+1,total:Y.length})}),(0,D.jsxs)(p,{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:[S(`nextRequest`,`Next`),(0,D.jsx)(Ke,{className:`h-4 w-4 ml-0.5`})]})]}),Wt?(0,D.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,D.jsx)(m,{className:`h-6 w-3/4`}),(0,D.jsx)(m,{className:`h-6 w-1/2`}),(0,D.jsx)(m,{className:`h-20 w-full`})]}):R?(0,D.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,D.jsx)(gt,{status:R.status,label:T(R.status)}),(R.round??1)>1&&(0,D.jsx)(f,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:R.round})}),(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:_t(j(R)),children:[(0,D.jsx)(Ce,{className:`h-3 w-3`}),S(`submittedAgo`,`Submitted {{when}}`,{when:w(j(R))})]}),R.completed_at&&(0,D.jsxs)(`span`,{children:[`· `,S(`completedAt`,`Completed {{when}}`,{when:w(R.completed_at)})]}),R.status===`pending`&&(()=>{let e=Dt(R.sla_due_at,C);return e?(0,D.jsx)(f,{variant:`outline`,className:h(`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:ft(e)}):null})()]}),(()=>{let e=I(R,Jt),n=kt(R.payload,R.payload_display,R.payload_labels,6,e?.key,Jt);return(0,D.jsx)(ve,{children:(0,D.jsxs)(He,{className:`p-4 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[qt.isUnreadable(R)?(0,D.jsx)(`div`,{className:`text-base font-semibold truncate`,children:R.record_title||O(R.record_id)}):(0,D.jsxs)(t,{to:ht(R),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:`truncate`,children:R.record_title||O(R.record_id)}),(0,D.jsx)(et,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:wt(R)})]}),(0,D.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,D.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:Ct(R)?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Ve,{className:`h-3 w-3`}),(0,D.jsx)(`span`,{className:`italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Fe,{className:`h-3 w-3`}),(0,D.jsx)(`span`,{title:R.submitter_id||``,children:yt(R)})]})})})]}),e&&(0,D.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,D.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e.label}),(0,D.jsx)(`div`,{className:`text-xl font-semibold tabular-nums`,title:e.display,children:e.display})]}),n.length>0&&(0,D.jsx)(`div`,{className:h(`grid grid-cols-2 gap-x-4 gap-y-2 text-sm`,!e&&`border-t pt-3`),children:n.map(([e,t])=>(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,D.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),R.decision_progress&&(()=>{let e=R.decision_progress,t=(R.pending_approvers||[]).length;return(0,D.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 mb-1.5`,children:[(0,D.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.behavior===`per_group`?S(`progressGroups`,`Sign-off progress — {{got}} of {{need}} groups`,{got:e.got,need:e.need}):S(`progressApprovals`,`Approvals — {{got}} of {{need}}`,{got:e.got,need:e.need})}),e.behavior!==`per_group`&&R.status===`pending`&&t>0&&(0,D.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:S(`progressEligible`,`{{count}} eligible approver(s)`,{count:t})})]}),(0,D.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":e.need,"aria-valuenow":Math.min(e.got,e.need),"aria-label":S(`progressBar`,`Decision progress`),className:`flex gap-1`,children:e.need>0&&e.need<=12?Array.from({length:e.need}).map((t,n)=>(0,D.jsx)(`div`,{className:h(`h-1.5 flex-1 rounded-full`,n<e.got?`bg-emerald-500`:`bg-muted`)},n)):(0,D.jsx)(`div`,{className:`h-1.5 flex-1 rounded-full bg-muted overflow-hidden`,children:(0,D.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,D.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.groups.map(e=>(0,D.jsxs)(f,{variant:`outline`,className:h(`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,D.jsx)(Le,{className:`h-3 w-3`}):(0,D.jsx)(me,{className:`h-2.5 w-2.5`}),e.group,` `,e.got,`/`,e.need]},e.group))})]})})(),R.status===`pending`&&(R.pending_approvers||[]).length>0&&(0,D.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,D.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:S(`waitingOn`,`Waiting on`)}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:St(R).map((e,t)=>(0,D.jsxs)(f,{variant:`outline`,className:`text-[11px]`,title:e.title,children:[e.label,e.group&&(0,D.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`· `,e.group]}),e.count>1&&(0,D.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.count]})]},`${e.label}-${e.group??``}-${t}`))})]})]})})})(),(R.flow_steps?.length??0)>1&&(0,D.jsx)(`ol`,{className:`flex flex-col px-1`,"aria-label":S(`stepProgress`,`Approval steps`),children:R.flow_steps.map((e,t,n)=>{let r=n[t+1];return(0,D.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col items-center self-stretch`,children:[(0,D.jsx)(`span`,{className:h(`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,D.jsx)(Le,{className:`h-3 w-3`}):t+1}),r&&(0,D.jsx)(`div`,{className:h(`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,D.jsx)(`span`,{className:h(`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,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:S(`history`,`Activity`)}),Ht.length===0?(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`noActions`,`No actions yet.`)}):(0,D.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:Ht.map(e=>{let t=ot(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`?S(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===R.submitter_id?yt(R):O(e.actor_id)),i=e.action===`submit`?S(`actSubmit`,`Submitted`):e.action===`approve`?S(`actApprove`,`Approved`):e.action===`reject`?S(`actReject`,`Rejected`):e.action===`recall`?S(`actRecall`,`Recalled`):e.action===`reassign`?S(`actReassign`,`Reassigned`):e.action===`remind`?S(`actRemind`,`Reminder sent`):e.action===`request_info`?S(`actRequestInfo`,`Requested more info`):e.action===`comment`?S(`actComment`,`Commented`):e.action===`escalate`?S(`actEscalate`,`SLA escalated`):e.action===`revise`?S(`actRevise`,`Sent back for revision`):e.action===`resubmit`?S(`actResubmit`,`Resubmitted`):e.action;return(0,D.jsxs)(`li`,{className:`relative text-xs`,children:[(0,D.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${n}`,"aria-hidden":!0}),(0,D.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,D.jsx)(`span`,{className:`font-medium`,children:i}),(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,D.jsx)(`span`,{title:e.actor_id||``,children:r}),t&&(0,D.jsxs)(f,{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:S(`viaOverrideHint`,`The actor held no approver slot on this step — admitted by the admin-override path.`),"data-testid":`via-override-chip`,children:[(0,D.jsx)(Ie,{className:`h-3 w-3`,"aria-hidden":!0}),S(`viaOverrideChip`,`Admin override`)]}),(0,D.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:_t(e.created_at),children:w(e.created_at)})]}),(()=>{let t=e;return e.action!==`reassign`||!t.reassign_from&&!t.reassign_to?null:(0,D.jsx)(`div`,{className:`text-muted-foreground mt-0.5`,children:S(`reassignFromTo`,`from {{from}} to {{to}}`,{from:t.reassign_from_name??O(t.reassign_from),to:t.reassign_to_name??O(t.reassign_to)})})})(),e.comment&&(0,D.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]}),Array.isArray(e.attachments)&&e.attachments.length>0&&(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((t,n)=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void Xt(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,D.jsx)(de,{className:`h-3 w-3`}),t.name||`${S(`attachmentChip`,`Attachment`)}${e.attachments.length>1?` ${n+1}`:``}`]},t.id||n))})]},e.id)})}),R.status===`pending`&&(Tn||En)&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,D.jsx)(fe,{value:G,onChange:e=>hn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&G.trim()&&(e.preventDefault(),wn())},placeholder:S(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,D.jsx)(p,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!G.trim()||gn,onClick:()=>void wn(),children:(0,D.jsx)(ze,{className:`h-3.5 w-3.5`})})]})]}),x&&R.payload!=null&&(0,D.jsxs)(`details`,{className:`group`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:S(`rawData`,`Raw data (JSON)`)}),(0,D.jsxs)(`div`,{className:`mt-2`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(R.payload,null,2)),g.success(S(`copied`,`Copied`))}catch{g.error(S(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,D.jsx)(se,{className:`h-3 w-3`}),S(`copy`,`Copy`)]})}),(0,D.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,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ie,{}),(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(at,{objectName:`sys_approval_request`,record:R,location:`record_section`,label:S(`declaredActions`,`Actions`),onDone:()=>{Cn()}}),!Tn&&(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:En?S(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):S(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(R.pending_approvers||[]).map(e=>bt(e,R)).join(`, `)||`—`})})]})]}),Dn&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ie,{}),(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,D.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,D.jsx)(p,{asChild:!0,size:`sm`,variant:`outline`,children:(0,D.jsxs)(t,{to:ht(R),children:[(0,D.jsx)(et,{className:`h-4 w-4 mr-1`}),S(`editRecordBtn`,`Edit record`)]})}),(0,D.jsx)(at,{objectName:`sys_approval_request`,record:R,location:`record_section`,onDone:()=>{Sn(R.id),K()}})]})]})]})]}):null]})})]})}export{Pt as ApprovalsInboxPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,r as n}from"./vendor-react-CsWFRkED.js";import{Bn as r,Cn as i,Dn as a,En as o,Gt as s,In as c,Jt as l,Kt as u,On as d,Or as f,Pr as p,Rr as m,Sn as h,Tn as g,Ut as _,Wt as ee,Xr as v,aa as te,bn as ne,gn as re,ht as ie,kr as y,mt as ae,ni as b,oa as x,qt as oe,sc as se,va as ce,vn as le,vt as ue,wn as S,xn as C,yn as w,zr as T}from"./ui-components-D2lrjG-t.js";var E=e(t(),1),de=[`create`,`update`,`delete`,`login`,`logout`,`config_change`,`import`],D={create:`default`,update:`secondary`,delete:`destructive`,login:`outline`,logout:`outline`,config_change:`secondary`,import:`outline`},O=n(),fe=`${``.replace(/\/$/,``)}/api/v1`,k=50;function A(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function j(e,t=24){return e?e.length>t?`${e.slice(0,t-1)}…`:e:`—`}function M(e){if(!e)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function N(){let[e,t]=(0,E.useState)([]),[n,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(null),[I,L]=(0,E.useState)(`all`),[R,z]=(0,E.useState)(``),[B,V]=(0,E.useState)(``),[H,U]=(0,E.useState)(``),[W,G]=(0,E.useState)(``),[K,q]=(0,E.useState)(0),[J,Y]=(0,E.useState)(!1),[X,Z]=(0,E.useState)(null),Q=(0,E.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 n=new URLSearchParams;Object.keys(e).length>0&&n.set(`$filter`,JSON.stringify(e)),n.set(`$orderby`,`created_at desc`),n.set(`$top`,`51`),n.set(`$skip`,String(K*k));let r=await fetch(`${fe}/data/sys_audit_log?${n.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>k),t(a.slice(0,k))}catch(e){console.warn(`[AuditLogPage] load failed:`,e),F(e?.message||`Failed to load audit log`),t([]),Y(!1)}finally{N(!1)}},[I,R,B,H,W,K]);(0,E.useEffect)(()=>{Q()},[Q]);let pe=(0,E.useCallback)(()=>{L(`all`),z(``),V(``),U(``),G(``),q(0)},[]),$=(0,E.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,O.jsxs)(`div`,{className:`p-6 space-y-4 max-w-screen-2xl mx-auto`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(x,{className:`h-6 w-6 text-muted-foreground`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Audit Log`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Read-only system activity and record changes. Newest first.`})]}),(0,O.jsxs)(v,{variant:`outline`,size:`sm`,onClick:Q,disabled:n,children:[(0,O.jsx)(ce,{className:`h-4 w-4 mr-1 ${n?`animate-spin`:``}`}),`Refresh`]})]}),(0,O.jsx)(f,{children:(0,O.jsxs)(y,{className:`p-4 grid grid-cols-1 md:grid-cols-5 gap-3`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`Action`}),(0,O.jsxs)(S,{value:I,onValueChange:e=>{L(e),q(0)},children:[(0,O.jsx)(a,{className:`h-9`,children:(0,O.jsx)(d,{})}),(0,O.jsxs)(g,{children:[(0,O.jsx)(o,{value:`all`,children:`All actions`}),de.map(e=>(0,O.jsx)(o,{value:e,children:e},e))]})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`Object`}),(0,O.jsx)(c,{placeholder:`e.g. account`,value:R,onChange:e=>{z(e.target.value),q(0)},className:`h-9`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`Actor (user id)`}),(0,O.jsx)(c,{placeholder:`user id`,value:B,onChange:e=>{V(e.target.value),q(0)},className:`h-9`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`From`}),(0,O.jsx)(c,{type:`date`,value:H,onChange:e=>{U(e.target.value),q(0)},className:`h-9`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`To`}),(0,O.jsx)(c,{type:`date`,value:W,onChange:e=>{G(e.target.value),q(0)},className:`h-9`})]}),$>0&&(0,O.jsx)(`div`,{className:`md:col-span-5 flex justify-end`,children:(0,O.jsxs)(v,{variant:`ghost`,size:`sm`,onClick:pe,children:[(0,O.jsx)(b,{className:`h-4 w-4 mr-1`}),`Clear filters (`,$,`)`]})})]})}),P&&(0,O.jsxs)(m,{variant:`destructive`,children:[(0,O.jsx)(se,{className:`h-4 w-4`}),(0,O.jsx)(T,{children:P})]}),(0,O.jsx)(f,{children:(0,O.jsx)(y,{className:`p-0`,children:n&&e.length===0?(0,O.jsx)(`div`,{className:`p-6 space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,O.jsx)(re,{className:`h-9 w-full`},t))}):e.length===0?(0,O.jsx)(`div`,{className:`p-12`,children:(0,O.jsxs)(ae,{children:[(0,O.jsx)(te,{className:`h-8 w-8 text-muted-foreground mb-3`}),(0,O.jsx)(ue,{children:`No audit entries`}),(0,O.jsx)(ie,{children:$>0?`Try clearing filters or widening the date range.`:`Events will appear here once tracked objects are modified.`})]})}):(0,O.jsxs)(_,{children:[(0,O.jsx)(oe,{children:(0,O.jsxs)(l,{children:[(0,O.jsx)(u,{className:`w-[180px]`,children:`Timestamp`}),(0,O.jsx)(u,{className:`w-[130px]`,children:`Action`}),(0,O.jsx)(u,{children:`Object`}),(0,O.jsx)(u,{children:`Record`}),(0,O.jsx)(u,{children:`Actor`}),(0,O.jsx)(u,{className:`w-[130px]`,children:`IP`})]})}),(0,O.jsx)(ee,{children:e.map(e=>{let t=D[e.action||``]||`outline`;return(0,O.jsxs)(l,{className:`cursor-pointer`,onClick:()=>Z(e),children:[(0,O.jsx)(s,{className:`font-mono text-xs`,children:A(e.created_at)}),(0,O.jsx)(s,{children:(0,O.jsx)(p,{variant:t,children:e.action||`—`})}),(0,O.jsx)(s,{children:e.object_name||`—`}),(0,O.jsx)(s,{className:`font-mono text-xs`,children:j(e.record_id,18)}),(0,O.jsx)(s,{className:`font-mono text-xs`,children:j(e.user_id,18)}),(0,O.jsx)(s,{className:`font-mono text-xs`,children:e.ip_address||`—`})]},e.id)})})]})})}),(e.length>0||K>0)&&(0,O.jsxs)(`div`,{className:`flex items-center justify-between text-sm text-muted-foreground`,children:[(0,O.jsxs)(`span`,{children:[`Page `,K+1,J?``:` · end`]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(v,{variant:`outline`,size:`sm`,disabled:K===0||n,onClick:()=>q(e=>Math.max(0,e-1)),children:`Previous`}),(0,O.jsx)(v,{variant:`outline`,size:`sm`,disabled:!J||n,onClick:()=>q(e=>e+1),children:`Next`})]})]}),(0,O.jsx)(le,{open:!!X,onOpenChange:e=>!e&&Z(null),children:(0,O.jsxs)(w,{side:`right`,className:`sm:max-w-2xl w-full overflow-y-auto`,children:[(0,O.jsxs)(C,{children:[(0,O.jsxs)(h,{className:`flex items-center gap-2`,children:[(0,O.jsx)(p,{variant:X&&D[X.action||``]||`outline`,children:X?.action||`—`}),X?.object_name||`Audit Event`]}),(0,O.jsx)(ne,{children:X?.id?(0,O.jsx)(`span`,{className:`font-mono text-xs`,children:X.id}):null})]}),X&&(0,O.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Timestamp`}),(0,O.jsx)(`div`,{className:`font-mono`,children:A(X.created_at)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`IP Address`}),(0,O.jsx)(`div`,{className:`font-mono`,children:X.ip_address||`—`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Actor (user_id)`}),(0,O.jsx)(`div`,{className:`font-mono break-all`,children:X.user_id||`—`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Tenant`}),(0,O.jsx)(`div`,{className:`font-mono break-all`,children:X.tenant_id||`—`})]}),(0,O.jsxs)(`div`,{className:`col-span-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Target record`}),(0,O.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[X.object_name||`—`,` / `,X.record_id||`—`]})]}),X.user_agent&&(0,O.jsxs)(`div`,{className:`col-span-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`User Agent`}),(0,O.jsx)(`div`,{className:`font-mono text-xs break-all`,children:X.user_agent})]})]}),(X.old_value||X.new_value)&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i,{}),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:`Change payload`}),X.old_value&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Before`}),(0,O.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.old_value)})]}),X.new_value&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`After`}),(0,O.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.new_value)})]})]})]}),X.metadata&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i,{}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,O.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-48 overflow-auto`,children:M(X.metadata)})]})]})]})]})})]})}export{N as AuditLogPage};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,r as n}from"./vendor-react-CsWFRkED.js";import{Bn as r,Cn as i,Dn as a,En as o,Gt as s,In as c,Jt as l,Kt as u,On as d,Or as f,Pr as p,Rr as m,Sn as h,Tn as g,Ut as _,Wt as ee,Xr as v,aa as te,bn as ne,gn as re,ht as ie,kr as y,mt as ae,ni as b,oa as x,qt as oe,sc as se,va as ce,vn as le,vt as ue,wn as S,xn as C,yn as w,zr as T}from"./ui-components-CMHDBJEm.js";var E=e(t(),1),de=[`create`,`update`,`delete`,`login`,`logout`,`config_change`,`import`],D={create:`default`,update:`secondary`,delete:`destructive`,login:`outline`,logout:`outline`,config_change:`secondary`,import:`outline`},O=n(),fe=`${``.replace(/\/$/,``)}/api/v1`,k=50;function A(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function j(e,t=24){return e?e.length>t?`${e.slice(0,t-1)}…`:e:`—`}function M(e){if(!e)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function N(){let[e,t]=(0,E.useState)([]),[n,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(null),[I,L]=(0,E.useState)(`all`),[R,z]=(0,E.useState)(``),[B,V]=(0,E.useState)(``),[H,U]=(0,E.useState)(``),[W,G]=(0,E.useState)(``),[K,q]=(0,E.useState)(0),[J,Y]=(0,E.useState)(!1),[X,Z]=(0,E.useState)(null),Q=(0,E.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 n=new URLSearchParams;Object.keys(e).length>0&&n.set(`$filter`,JSON.stringify(e)),n.set(`$orderby`,`created_at desc`),n.set(`$top`,`51`),n.set(`$skip`,String(K*k));let r=await fetch(`${fe}/data/sys_audit_log?${n.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>k),t(a.slice(0,k))}catch(e){console.warn(`[AuditLogPage] load failed:`,e),F(e?.message||`Failed to load audit log`),t([]),Y(!1)}finally{N(!1)}},[I,R,B,H,W,K]);(0,E.useEffect)(()=>{Q()},[Q]);let pe=(0,E.useCallback)(()=>{L(`all`),z(``),V(``),U(``),G(``),q(0)},[]),$=(0,E.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,O.jsxs)(`div`,{className:`p-6 space-y-4 max-w-screen-2xl mx-auto`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(x,{className:`h-6 w-6 text-muted-foreground`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Audit Log`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Read-only system activity and record changes. Newest first.`})]}),(0,O.jsxs)(v,{variant:`outline`,size:`sm`,onClick:Q,disabled:n,children:[(0,O.jsx)(ce,{className:`h-4 w-4 mr-1 ${n?`animate-spin`:``}`}),`Refresh`]})]}),(0,O.jsx)(f,{children:(0,O.jsxs)(y,{className:`p-4 grid grid-cols-1 md:grid-cols-5 gap-3`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`Action`}),(0,O.jsxs)(S,{value:I,onValueChange:e=>{L(e),q(0)},children:[(0,O.jsx)(a,{className:`h-9`,children:(0,O.jsx)(d,{})}),(0,O.jsxs)(g,{children:[(0,O.jsx)(o,{value:`all`,children:`All actions`}),de.map(e=>(0,O.jsx)(o,{value:e,children:e},e))]})]})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`Object`}),(0,O.jsx)(c,{placeholder:`e.g. account`,value:R,onChange:e=>{z(e.target.value),q(0)},className:`h-9`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`Actor (user id)`}),(0,O.jsx)(c,{placeholder:`user id`,value:B,onChange:e=>{V(e.target.value),q(0)},className:`h-9`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`From`}),(0,O.jsx)(c,{type:`date`,value:H,onChange:e=>{U(e.target.value),q(0)},className:`h-9`})]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(r,{className:`text-xs`,children:`To`}),(0,O.jsx)(c,{type:`date`,value:W,onChange:e=>{G(e.target.value),q(0)},className:`h-9`})]}),$>0&&(0,O.jsx)(`div`,{className:`md:col-span-5 flex justify-end`,children:(0,O.jsxs)(v,{variant:`ghost`,size:`sm`,onClick:pe,children:[(0,O.jsx)(b,{className:`h-4 w-4 mr-1`}),`Clear filters (`,$,`)`]})})]})}),P&&(0,O.jsxs)(m,{variant:`destructive`,children:[(0,O.jsx)(se,{className:`h-4 w-4`}),(0,O.jsx)(T,{children:P})]}),(0,O.jsx)(f,{children:(0,O.jsx)(y,{className:`p-0`,children:n&&e.length===0?(0,O.jsx)(`div`,{className:`p-6 space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,O.jsx)(re,{className:`h-9 w-full`},t))}):e.length===0?(0,O.jsx)(`div`,{className:`p-12`,children:(0,O.jsxs)(ae,{children:[(0,O.jsx)(te,{className:`h-8 w-8 text-muted-foreground mb-3`}),(0,O.jsx)(ue,{children:`No audit entries`}),(0,O.jsx)(ie,{children:$>0?`Try clearing filters or widening the date range.`:`Events will appear here once tracked objects are modified.`})]})}):(0,O.jsxs)(_,{children:[(0,O.jsx)(oe,{children:(0,O.jsxs)(l,{children:[(0,O.jsx)(u,{className:`w-[180px]`,children:`Timestamp`}),(0,O.jsx)(u,{className:`w-[130px]`,children:`Action`}),(0,O.jsx)(u,{children:`Object`}),(0,O.jsx)(u,{children:`Record`}),(0,O.jsx)(u,{children:`Actor`}),(0,O.jsx)(u,{className:`w-[130px]`,children:`IP`})]})}),(0,O.jsx)(ee,{children:e.map(e=>{let t=D[e.action||``]||`outline`;return(0,O.jsxs)(l,{className:`cursor-pointer`,onClick:()=>Z(e),children:[(0,O.jsx)(s,{className:`font-mono text-xs`,children:A(e.created_at)}),(0,O.jsx)(s,{children:(0,O.jsx)(p,{variant:t,children:e.action||`—`})}),(0,O.jsx)(s,{children:e.object_name||`—`}),(0,O.jsx)(s,{className:`font-mono text-xs`,children:j(e.record_id,18)}),(0,O.jsx)(s,{className:`font-mono text-xs`,children:j(e.user_id,18)}),(0,O.jsx)(s,{className:`font-mono text-xs`,children:e.ip_address||`—`})]},e.id)})})]})})}),(e.length>0||K>0)&&(0,O.jsxs)(`div`,{className:`flex items-center justify-between text-sm text-muted-foreground`,children:[(0,O.jsxs)(`span`,{children:[`Page `,K+1,J?``:` · end`]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(v,{variant:`outline`,size:`sm`,disabled:K===0||n,onClick:()=>q(e=>Math.max(0,e-1)),children:`Previous`}),(0,O.jsx)(v,{variant:`outline`,size:`sm`,disabled:!J||n,onClick:()=>q(e=>e+1),children:`Next`})]})]}),(0,O.jsx)(le,{open:!!X,onOpenChange:e=>!e&&Z(null),children:(0,O.jsxs)(w,{side:`right`,className:`sm:max-w-2xl w-full overflow-y-auto`,children:[(0,O.jsxs)(C,{children:[(0,O.jsxs)(h,{className:`flex items-center gap-2`,children:[(0,O.jsx)(p,{variant:X&&D[X.action||``]||`outline`,children:X?.action||`—`}),X?.object_name||`Audit Event`]}),(0,O.jsx)(ne,{children:X?.id?(0,O.jsx)(`span`,{className:`font-mono text-xs`,children:X.id}):null})]}),X&&(0,O.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Timestamp`}),(0,O.jsx)(`div`,{className:`font-mono`,children:A(X.created_at)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`IP Address`}),(0,O.jsx)(`div`,{className:`font-mono`,children:X.ip_address||`—`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Actor (user_id)`}),(0,O.jsx)(`div`,{className:`font-mono break-all`,children:X.user_id||`—`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Tenant`}),(0,O.jsx)(`div`,{className:`font-mono break-all`,children:X.tenant_id||`—`})]}),(0,O.jsxs)(`div`,{className:`col-span-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Target record`}),(0,O.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[X.object_name||`—`,` / `,X.record_id||`—`]})]}),X.user_agent&&(0,O.jsxs)(`div`,{className:`col-span-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`User Agent`}),(0,O.jsx)(`div`,{className:`font-mono text-xs break-all`,children:X.user_agent})]})]}),(X.old_value||X.new_value)&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i,{}),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:`Change payload`}),X.old_value&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Before`}),(0,O.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.old_value)})]}),X.new_value&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`After`}),(0,O.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.new_value)})]})]})]}),X.metadata&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i,{}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,O.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-48 overflow-auto`,children:M(X.metadata)})]})]})]})]})})]})}export{N as AuditLogPage};
@@ -1 +1 @@
1
- import"./rolldown-runtime-C0FnF6B9.js";import{b as e,g as t,h as n,r}from"./vendor-react-CsWFRkED.js";import{ht as i,mt as a,vt as o}from"./ui-components-D2lrjG-t.js";import{t as s}from"./componentRegistry-ByxoJqMW.js";e();var c=r();function l({extraProps:e}={}){let r=n(),[l]=t(),u=r.ns,d=r.name,f=u&&d?`${u}:${d}`:u??``,p=s(f);if(!p)return(0,c.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,c.jsxs)(a,{children:[(0,c.jsx)(o,{children:`Component not registered`}),(0,c.jsxs)(i,{children:[`No component is registered for `,(0,c.jsx)(`code`,{className:`font-mono`,children:f||`(empty)`}),`. Ensure the plugin that provides this surface is installed and has called`,(0,c.jsx)(`code`,{className:`font-mono`,children:` registerAppComponent()`}),`.`]})]})});let m={};for(let[e,t]of l.entries())m[e]=t;let h=p.component;return(0,c.jsx)(h,{...m,...e??{}})}export{l as ComponentNavView,l as default};
1
+ import"./rolldown-runtime-C0FnF6B9.js";import{b as e,g as t,h as n,r}from"./vendor-react-CsWFRkED.js";import{ht as i,mt as a,vt as o}from"./ui-components-CMHDBJEm.js";import{t as s}from"./componentRegistry-ByxoJqMW.js";e();var c=r();function l({extraProps:e}={}){let r=n(),[l]=t(),u=r.ns,d=r.name,f=u&&d?`${u}:${d}`:u??``,p=s(f);if(!p)return(0,c.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,c.jsxs)(a,{children:[(0,c.jsx)(o,{children:`Component not registered`}),(0,c.jsxs)(i,{children:[`No component is registered for `,(0,c.jsx)(`code`,{className:`font-mono`,children:f||`(empty)`}),`. Ensure the plugin that provides this surface is installed and has called`,(0,c.jsx)(`code`,{className:`font-mono`,children:` registerAppComponent()`}),`.`]})]})});let m={};for(let[e,t]of l.entries())m[e]=t;let h=p.component;return(0,c.jsx)(h,{...m,...e??{}})}export{l as ComponentNavView,l as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,r as n}from"./vendor-react-CsWFRkED.js";import{y as r}from"./i18n-locales-Bz4c8KXc.js";import{Cr as i,Dc as a,Do as o,Gi as s,In as c,Sr as ee,Tc as l,Ui as u,Us as d,Xr as f,bo as p,br as m,fo as h,il as g,sc as _,vr as v,xr as y,yr as te,zo as b}from"./ui-components-D2lrjG-t.js";import{n as x}from"./createDerive-Best2JCj.js";import{a as S,i as C,n as w,o as T,r as E,s as ne,t as D}from"./plugin-view-5qxxRyZZ.js";var O=e(t(),1),k=n();function A({title:e,subtitle:t,icon:n,actions:r,accentColor:i,sticky:a=!1,className:o,"data-testid":s}){return(0,k.jsxs)(`div`,{style:{"--page-header-accent":i||`hsl(var(--primary))`},className:g(`relative shrink-0 border-b bg-background z-10`,a&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,o),"data-testid":s??`page-header`,children:[(0,k.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,k.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,k.jsx)(`div`,{className:g(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,k.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),r&&(0,k.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:r})]})]})}function j(e){return[{type:`grid`,icon:o,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:u,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:a,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:b,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:d,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:s,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:h,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:l,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)},{type:`tree`,icon:p,label:e(`console.objectView.viewTypeTree`),description:e(`console.objectView.viewTypeTreeDesc`)}]}function M(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var N={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:w}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>T(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:w},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}],tree:[{key:`parentField`,i18nKey:`console.objectView.parentField`,helpI18nKey:`console.objectView.parentFieldHelp`,filter:e=>e.rawType===`tree`||e.rawType===`lookup`||e.rawType===`master_detail`}]};function P({open:e,onOpenChange:t,onCreate:n,existingLabels:a,availableTypes:o,objectDef:s}){let{t:l}=r(),u=(0,O.useMemo)(()=>j(l),[l]),d=(0,O.useMemo)(()=>o&&o.length>0?u.filter(e=>o.includes(e.type)):u,[u,o]),p=(a??[]).join(`\0`),h=(0,O.useMemo)(()=>new Set(a??[]),[p]),b=(0,O.useMemo)(()=>s?C(s):[],[s]),[S,w]=(0,O.useState)(d[0]?.type??`grid`),[T,E]=(0,O.useState)(``),[D,A]=(0,O.useState)(!1),[P,F]=(0,O.useState)(``),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)({});(0,O.useEffect)(()=>{e&&(w(d[0]?.type??`grid`),A(!1),L(!1),z({}))},[e,d]),(0,O.useEffect)(()=>{if(!D){let e=d.find(e=>e.type===S);E(M(e?.label??`View`,h))}},[S,D,d,h]),(0,O.useEffect)(()=>{I||F(x(T))},[T,I]);let B=N[S]??[],V=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:!s||(e.filter?b.filter(e.filter):b).length>0,H=(0,O.useMemo)(()=>{let e={};return d.forEach(t=>{let n=(N[t.type]??[]).find(e=>!V(e));e[t.type]=n??null}),e},[d,b,s]),U=e=>R[`${S}.${e}`]??``,W=(e,t)=>z(n=>({...n,[`${S}.${e}`]:t})),G=T.trim(),K=G.length>0&&h.has(G),q=B.every(e=>U(e.key).length>0),J=/^[a-z_][a-z0-9_]*$/,Y=P.trim(),X=Y.length===0,Z=Y.length>0&&!J.test(Y),Q=G.length>0&&!K&&q&&!X&&!Z;(0,O.useEffect)(()=>{B.length!==0&&B.forEach(e=>{if(U(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&W(e.key,e.defaultValue);return}let t=e.filter?b.filter(e.filter):b;if(t.length===0)return;if(t.length===1){W(e.key,t[0].value);return}let n=ne(t,e.preferred??[]);n&&W(e.key,n)})},[S,b]);let $=()=>{if(!Q)return;let e={};B.forEach(t=>{let n=U(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:S,label:G,name:Y};Object.keys(e).length>0&&(r[S]=e),n(r),t(!1)};return(0,k.jsx)(v,{open:e,onOpenChange:t,children:(0,k.jsxs)(te,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,k.jsxs)(ee,{children:[(0,k.jsx)(i,{children:l(`console.objectView.createView`)}),(0,k.jsx)(m,{children:l(`console.objectView.createViewDesc`)})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:d.map(({type:e,label:t,description:n,icon:r})=>{let i=e===S,a=H[e],o=!!a,s=o?l(`console.objectView.viewTypeUnavailable`,{field:l(a.i18nKey)}):void 0;return(0,k.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":i,"aria-disabled":o,disabled:o,title:s,onClick:()=>{o||w(e)},className:g(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!o&&`hover:border-primary/60 hover:bg-accent/40`,i&&!o?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,o&&`opacity-50 cursor-not-allowed`),children:[(0,k.jsx)(r,{className:g(`h-5 w-5`,i&&!o?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,k.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,k.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:o?l(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),B.length>0&&(0,k.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:B.map(e=>{let t=U(e.key),n=e.kind===`enum`,r=n?[]:e.filter?b.filter(e.filter):b,i=!n&&b.length>0&&r.length===0;return(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[l(e.i18nKey),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,"aria-hidden":`true`,children:`*`})]}),(0,k.jsxs)(`select`,{id:`create-view-required-${e.key}`,"aria-required":`true`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>W(e.key,t.target.value),disabled:i,className:g(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,k.jsx)(`option`,{value:``,children:l(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,k.jsx)(`option`,{value:e.value,children:l(e.i18nKey)},e.value)):r.map(e=>(0,k.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!i&&(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:l(e.helpI18nKey)}),i&&(0,k.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,k.jsx)(_,{className:`h-3 w-3`}),l(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.title`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,"aria-hidden":`true`,children:`*`})]}),(0,k.jsx)(c,{id:`create-view-name-input`,"aria-required":`true`,"data-testid":`create-view-name-input`,autoFocus:!0,value:T,onChange:e=>{E(e.target.value),A(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:l(`console.objectView.newView`),className:`h-9`}),K&&(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:l(`console.objectView.duplicateViewName`)})]}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-machine-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.viewName`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,"aria-hidden":`true`,children:`*`})]}),(0,k.jsx)(c,{id:`create-view-machine-name-input`,"aria-required":`true`,"data-testid":`create-view-machine-name-input`,value:P,onChange:e=>{F(e.target.value),L(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:`grid_1`,className:`h-9 font-mono`}),X?(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameRequired`)}):Z?(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-machine-name`,children:l(`console.objectView.viewNameInvalid`)}):(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameHelp`)})]}),(0,k.jsxs)(y,{className:`mt-2`,children:[(0,k.jsx)(f,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:l(`console.objectView.cancel`)}),(0,k.jsx)(f,{type:`button`,disabled:!Q,onClick:$,"data-testid":`create-view-submit`,children:l(`console.objectView.create`)})]})]})})}export{A as n,P as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,r as n}from"./vendor-react-CsWFRkED.js";import{y as r}from"./i18n-locales-BBA090ve.js";import{Cr as i,Dc as a,Do as o,Gi as s,In as c,Sr as ee,Tc as l,Ui as u,Us as d,Xr as f,bo as p,br as m,fo as h,il as g,sc as _,vr as v,xr as y,yr as te,zo as b}from"./ui-components-CMHDBJEm.js";import{n as x}from"./createDerive-DtfnFzGm.js";import{a as S,i as C,n as w,o as T,r as E,s as ne,t as D}from"./plugin-view-CKs41t7o.js";var O=e(t(),1),k=n();function A({title:e,subtitle:t,icon:n,actions:r,accentColor:i,sticky:a=!1,className:o,"data-testid":s}){return(0,k.jsxs)(`div`,{style:{"--page-header-accent":i||`hsl(var(--primary))`},className:g(`relative shrink-0 border-b bg-background z-10`,a&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,o),"data-testid":s??`page-header`,children:[(0,k.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,k.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,k.jsx)(`div`,{className:g(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,k.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),r&&(0,k.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:r})]})]})}function j(e){return[{type:`grid`,icon:o,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:u,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:a,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:b,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:d,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:s,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:h,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:l,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)},{type:`tree`,icon:p,label:e(`console.objectView.viewTypeTree`),description:e(`console.objectView.viewTypeTreeDesc`)}]}function M(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var N={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:w}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>T(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:w},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}],tree:[{key:`parentField`,i18nKey:`console.objectView.parentField`,helpI18nKey:`console.objectView.parentFieldHelp`,filter:e=>e.rawType===`tree`||e.rawType===`lookup`||e.rawType===`master_detail`}]};function P({open:e,onOpenChange:t,onCreate:n,existingLabels:a,availableTypes:o,objectDef:s}){let{t:l}=r(),u=(0,O.useMemo)(()=>j(l),[l]),d=(0,O.useMemo)(()=>o&&o.length>0?u.filter(e=>o.includes(e.type)):u,[u,o]),p=(a??[]).join(`\0`),h=(0,O.useMemo)(()=>new Set(a??[]),[p]),b=(0,O.useMemo)(()=>s?C(s):[],[s]),[S,w]=(0,O.useState)(d[0]?.type??`grid`),[T,E]=(0,O.useState)(``),[D,A]=(0,O.useState)(!1),[P,F]=(0,O.useState)(``),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)({});(0,O.useEffect)(()=>{e&&(w(d[0]?.type??`grid`),A(!1),L(!1),z({}))},[e,d]),(0,O.useEffect)(()=>{if(!D){let e=d.find(e=>e.type===S);E(M(e?.label??`View`,h))}},[S,D,d,h]),(0,O.useEffect)(()=>{I||F(x(T))},[T,I]);let B=N[S]??[],V=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:!s||(e.filter?b.filter(e.filter):b).length>0,H=(0,O.useMemo)(()=>{let e={};return d.forEach(t=>{let n=(N[t.type]??[]).find(e=>!V(e));e[t.type]=n??null}),e},[d,b,s]),U=e=>R[`${S}.${e}`]??``,W=(e,t)=>z(n=>({...n,[`${S}.${e}`]:t})),G=T.trim(),K=G.length>0&&h.has(G),q=B.every(e=>U(e.key).length>0),J=/^[a-z_][a-z0-9_]*$/,Y=P.trim(),X=Y.length===0,Z=Y.length>0&&!J.test(Y),Q=G.length>0&&!K&&q&&!X&&!Z;(0,O.useEffect)(()=>{B.length!==0&&B.forEach(e=>{if(U(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&W(e.key,e.defaultValue);return}let t=e.filter?b.filter(e.filter):b;if(t.length===0)return;if(t.length===1){W(e.key,t[0].value);return}let n=ne(t,e.preferred??[]);n&&W(e.key,n)})},[S,b]);let $=()=>{if(!Q)return;let e={};B.forEach(t=>{let n=U(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:S,label:G,name:Y};Object.keys(e).length>0&&(r[S]=e),n(r),t(!1)};return(0,k.jsx)(v,{open:e,onOpenChange:t,children:(0,k.jsxs)(te,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,k.jsxs)(ee,{children:[(0,k.jsx)(i,{children:l(`console.objectView.createView`)}),(0,k.jsx)(m,{children:l(`console.objectView.createViewDesc`)})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:d.map(({type:e,label:t,description:n,icon:r})=>{let i=e===S,a=H[e],o=!!a,s=o?l(`console.objectView.viewTypeUnavailable`,{field:l(a.i18nKey)}):void 0;return(0,k.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":i,"aria-disabled":o,disabled:o,title:s,onClick:()=>{o||w(e)},className:g(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!o&&`hover:border-primary/60 hover:bg-accent/40`,i&&!o?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,o&&`opacity-50 cursor-not-allowed`),children:[(0,k.jsx)(r,{className:g(`h-5 w-5`,i&&!o?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,k.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,k.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:o?l(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),B.length>0&&(0,k.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:B.map(e=>{let t=U(e.key),n=e.kind===`enum`,r=n?[]:e.filter?b.filter(e.filter):b,i=!n&&b.length>0&&r.length===0;return(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[l(e.i18nKey),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,"aria-hidden":`true`,children:`*`})]}),(0,k.jsxs)(`select`,{id:`create-view-required-${e.key}`,"aria-required":`true`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>W(e.key,t.target.value),disabled:i,className:g(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,k.jsx)(`option`,{value:``,children:l(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,k.jsx)(`option`,{value:e.value,children:l(e.i18nKey)},e.value)):r.map(e=>(0,k.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!i&&(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:l(e.helpI18nKey)}),i&&(0,k.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,k.jsx)(_,{className:`h-3 w-3`}),l(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.title`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,"aria-hidden":`true`,children:`*`})]}),(0,k.jsx)(c,{id:`create-view-name-input`,"aria-required":`true`,"data-testid":`create-view-name-input`,autoFocus:!0,value:T,onChange:e=>{E(e.target.value),A(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:l(`console.objectView.newView`),className:`h-9`}),K&&(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:l(`console.objectView.duplicateViewName`)})]}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-machine-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.viewName`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,"aria-hidden":`true`,children:`*`})]}),(0,k.jsx)(c,{id:`create-view-machine-name-input`,"aria-required":`true`,"data-testid":`create-view-machine-name-input`,value:P,onChange:e=>{F(e.target.value),L(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:`grid_1`,className:`h-9 font-mono`}),X?(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameRequired`)}):Z?(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-machine-name`,children:l(`console.objectView.viewNameInvalid`)}):(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameHelp`)})]}),(0,k.jsxs)(y,{className:`mt-2`,children:[(0,k.jsx)(f,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:l(`console.objectView.cancel`)}),(0,k.jsx)(f,{type:`button`,disabled:!Q,onClick:$,"data-testid":`create-view-submit`,children:l(`console.objectView.create`)})]})]})})}export{A as n,P as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,h as n,r}from"./vendor-react-CsWFRkED.js";import{J as i,q as a,z as o}from"./framework-BfSv4Kb0.js";import{u as s,y as c}from"./i18n-locales-Bz4c8KXc.js";import{Oo as l,gn as u,ht as d,mt as f,vt as p}from"./ui-components-D2lrjG-t.js";import{r as m}from"./vendor-ui-utils-BFw4cGI6.js";import{a as h}from"./ExpressionProvider-DqGWVuxV.js";import{t as g}from"./useActionModal-CkM-zGdy.js";import{t as _}from"./preferLocal-CKqyhTP9.js";import{n as v}from"./utils-MjUhYVsx.js";import{n as y,t as b}from"./MetadataInspector-Cu-n1FYz.js";import{n as x}from"./plugin-dashboard-Bj4ldCX6.js";import{t as S}from"./useOpenRecordList-DOZu_JZX.js";var C=r();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)(u,{className:`h-7 w-56`}),(0,C.jsx)(u,{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)(u,{className:`h-4 w-20`}),(0,C.jsx)(u,{className:`h-8 w-24`}),(0,C.jsx)(u,{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)(u,{className:`h-5 w-32`}),(0,C.jsx)(u,{className:`h-5 w-5 rounded-full`})]}),(0,C.jsx)(u,{className:`h-40 w-full`}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(u,{className:`h-3 w-16`}),(0,C.jsx)(u,{className:`h-3 w-12`})]})]},`widget-${t}`))})]})}var T=e(t(),1);function E({dataSource:e}){let t=S(),{dashboardName:r}=n(),{showDebug:u}=y(),E=a(),{t:D}=c(),{dashboardLabel:O,dashboardDescription:k}=s(),[A,j]=(0,T.useState)(!0),{modalHandler:M,modalElement:N}=g(E),P=(0,T.useMemo)(()=>({export_dashboard_pdf:async()=>{m.info(D(`dashboardActions.printDialogOpening`));try{return window.print(),{success:!0}}catch(e){return m.error(D(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(m.info(D(`dashboardActions.forecastSoon`)),{success:!0})}),[D]);(0,T.useEffect)(()=>{j(!0),queueMicrotask(()=>j(!1))},[r]);let{dashboards:F,objects:I}=i(),{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((B||R).title,D),t=v(R.label,D),n=O({name:R.name,label:t}),r=e||n||R.name;return(0,C.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:r})})(),(()=>{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)(o,{value:{openRecordList:t},children:(0,C.jsx)(x,{schema:B,dataSource:e,modalHandler:M,scriptHandlers:P,hideHeaderText:!0})})}),(0,C.jsx)(b,{open:u,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)(f,{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)(l,{className:`h-6 w-6 text-muted-foreground`})}),(0,C.jsx)(p,{children:D(`empty.dashboardNotFound`)}),(0,C.jsx)(d,{children:D(`empty.dashboardNotFoundDescription`,{name:r})})]})})}export{E as DashboardView};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,h as n,r}from"./vendor-react-CsWFRkED.js";import{J as i,q as a,z as o}from"./framework-DFE_Mws9.js";import{u as s,y as c}from"./i18n-locales-BBA090ve.js";import{Oo as l,gn as u,ht as d,mt as f,vt as p}from"./ui-components-CMHDBJEm.js";import{r as m}from"./vendor-ui-utils-BFw4cGI6.js";import{a as h}from"./ExpressionProvider-B6z09kM6.js";import{t as g}from"./useActionModal-D_iilsul.js";import{t as _}from"./preferLocal-CKqyhTP9.js";import{n as v}from"./utils-MjUhYVsx.js";import{n as y,t as b}from"./MetadataInspector-IQGUoLyp.js";import{n as x}from"./plugin-dashboard-d1o52lHr.js";import{t as S}from"./useOpenRecordList-DOZu_JZX.js";var C=r();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)(u,{className:`h-7 w-56`}),(0,C.jsx)(u,{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)(u,{className:`h-4 w-20`}),(0,C.jsx)(u,{className:`h-8 w-24`}),(0,C.jsx)(u,{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)(u,{className:`h-5 w-32`}),(0,C.jsx)(u,{className:`h-5 w-5 rounded-full`})]}),(0,C.jsx)(u,{className:`h-40 w-full`}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(u,{className:`h-3 w-16`}),(0,C.jsx)(u,{className:`h-3 w-12`})]})]},`widget-${t}`))})]})}var T=e(t(),1);function E({dataSource:e}){let t=S(),{dashboardName:r}=n(),{showDebug:u}=y(),E=a(),{t:D}=c(),{dashboardLabel:O,dashboardDescription:k}=s(),[A,j]=(0,T.useState)(!0),{modalHandler:M,modalElement:N}=g(E),P=(0,T.useMemo)(()=>({export_dashboard_pdf:async()=>{m.info(D(`dashboardActions.printDialogOpening`));try{return window.print(),{success:!0}}catch(e){return m.error(D(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(m.info(D(`dashboardActions.forecastSoon`)),{success:!0})}),[D]);(0,T.useEffect)(()=>{j(!0),queueMicrotask(()=>j(!1))},[r]);let{dashboards:F,objects:I}=i(),{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)(o,{value:{openRecordList:t},children:(0,C.jsx)(x,{schema:B,dataSource:e,modalHandler:M,scriptHandlers:P,hideHeaderText:!0})})}),(0,C.jsx)(b,{open:u,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)(f,{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)(l,{className:`h-6 w-6 text-muted-foreground`})}),(0,C.jsx)(p,{children:D(`empty.dashboardNotFound`)}),(0,C.jsx)(d,{children:D(`empty.dashboardNotFoundDescription`,{name:r})})]})})}export{E as DashboardView};
@@ -1 +1 @@
1
- import{h as e,p as t,r as n}from"./vendor-react-CsWFRkED.js";import{Ar as r,Mr as i,Oa as a,Or as o,ii as s,jr as c,ki as l,kr as u,us as d}from"./ui-components-D2lrjG-t.js";var f=n();function p(){let n=t(),{appName:p}=e(),m=p?`/apps/${p}`:``,h=[{title:`Integrations & APIs`,description:`Your app as a REST API — base URL, endpoints, and connect samples`,icon:a,href:`${m}/developer/integrations`},{title:`API Console`,description:`Inspect and exercise REST endpoints with auto-discovered services`,icon:l,href:`${m}/developer/api-console`},{title:`Flow Runs`,description:`Trigger flows with sample inputs and inspect recent run history`,icon:s,href:`${m}/developer/flow-runs`},{title:`Public Forms`,description:`Publish, share, and embed FormViews available to anonymous users`,icon:d,href:`${m}/developer/public-forms`}];return(0,f.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,f.jsxs)(`div`,{className:`min-w-0`,children:[(0,f.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Developer`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Tools for building, debugging, and sharing ObjectStack apps`})]}),(0,f.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:h.map(e=>{let t=e.icon;return(0,f.jsxs)(o,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>n(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${e.title}: ${e.description}`,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.href))},children:[(0,f.jsxs)(c,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,f.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,f.jsx)(t,{className:`h-5 w-5`})}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(i,{className:`text-base`,children:e.title}),(0,f.jsx)(r,{className:`text-xs`,children:e.description})]})]}),(0,f.jsx)(u,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
1
+ import{h as e,p as t,r as n}from"./vendor-react-CsWFRkED.js";import{Ar as r,Mr as i,Oa as a,Or as o,ii as s,jr as c,ki as l,kr as u,us as d}from"./ui-components-CMHDBJEm.js";var f=n();function p(){let n=t(),{appName:p}=e(),m=p?`/apps/${p}`:``,h=[{title:`Integrations & APIs`,description:`Your app as a REST API — base URL, endpoints, and connect samples`,icon:a,href:`${m}/developer/integrations`},{title:`API Console`,description:`Inspect and exercise REST endpoints with auto-discovered services`,icon:l,href:`${m}/developer/api-console`},{title:`Flow Runs`,description:`Trigger flows with sample inputs and inspect recent run history`,icon:s,href:`${m}/developer/flow-runs`},{title:`Public Forms`,description:`Publish, share, and embed FormViews available to anonymous users`,icon:d,href:`${m}/developer/public-forms`}];return(0,f.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,f.jsxs)(`div`,{className:`min-w-0`,children:[(0,f.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Developer`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Tools for building, debugging, and sharing ObjectStack apps`})]}),(0,f.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:h.map(e=>{let t=e.icon;return(0,f.jsxs)(o,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>n(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${e.title}: ${e.description}`,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.href))},children:[(0,f.jsxs)(c,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,f.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,f.jsx)(t,{className:`h-5 w-5`})}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(i,{className:`text-base`,children:e.title}),(0,f.jsx)(r,{className:`text-xs`,children:e.description})]})]}),(0,f.jsx)(u,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,b as n,h as r,p as i,r as a}from"./vendor-react-CsWFRkED.js";import{q as o}from"./framework-BfSv4Kb0.js";import{y as s}from"./i18n-locales-Bz4c8KXc.js";import{hc as c,ps as l,sc as u,uo as d,vo as f,ws as p}from"./ui-components-D2lrjG-t.js";import"./src-JX1BkhmR.js";import{t as m}from"./DocShell-Ipy_IDvh.js";import{i as h,l as g,n as _,u as v}from"./use-book-data-qUZAxIs0.js";import{r as y,t as b}from"./plugin-markdown-B7zwZHmn.js";var x=e(n(),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=a();function O({book:e,activeDoc:n,docHref:r}){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)(p,{className:`h-3 w-3 shrink-0 opacity-60`})]})},`ext-${i}`);if(!e.doc)return null;let a=e.doc===n;return(0,D.jsx)(`li`,{children:(0,D.jsx)(t,{to:r(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:t,appName:n}=r(),a=i(),p=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 r(){if(!(!t||!p)){k(`loading`);try{let r=await p.getClient().meta.getItem(`doc`,t,n?{packageId:n}:void 0),i=r?.item??r?.data??r;if(e)return;i&&typeof i.content==`string`?(w({name:t,label:i.label,content:i.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 r(),()=>{e=!0}},[t,n,p]);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=n?`/apps/${n}/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:t,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-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:t}),` 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:t,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)(u,{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??t,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)(d,{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:t,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:t,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
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,b as n,h as r,p as i,r as a}from"./vendor-react-CsWFRkED.js";import{q as o}from"./framework-DFE_Mws9.js";import{y as s}from"./i18n-locales-BBA090ve.js";import{hc as c,ps as l,sc as u,uo as d,vo as f,ws as p}from"./ui-components-CMHDBJEm.js";import"./src-hcMLuWxG.js";import{t as m}from"./DocShell-D4dSPfBz.js";import{i as h,l as g,n as _,u as v}from"./use-book-data-CM73PGvc.js";import{r as y,t as b}from"./plugin-markdown-Bdb2UThR.js";var x=e(n(),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=a();function O({book:e,activeDoc:n,docHref:r}){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)(p,{className:`h-3 w-3 shrink-0 opacity-60`})]})},`ext-${i}`);if(!e.doc)return null;let a=e.doc===n;return(0,D.jsx)(`li`,{children:(0,D.jsx)(t,{to:r(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:t,appName:n}=r(),a=i(),p=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 r(){if(!(!t||!p)){k(`loading`);try{let r=await p.getClient().meta.getItem(`doc`,t,n?{packageId:n}:void 0),i=r?.item??r?.data??r;if(e)return;i&&typeof i.content==`string`?(w({name:t,label:i.label,content:i.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 r(),()=>{e=!0}},[t,n,p]);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=n?`/apps/${n}/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:t,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-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:t}),` 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:t,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)(u,{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??t,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)(d,{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:t,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:t,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 +1 @@
1
- import{a as e,r as t}from"./vendor-react-CsWFRkED.js";import{Rc as n}from"./ui-components-D2lrjG-t.js";var r=t();function i({breadcrumb:t,children:i}){return(0,r.jsxs)(`div`,{className:`min-h-full`,children:[(0,r.jsx)(`header`,{className:`sticky top-0 z-10 border-b border-border bg-background/80 backdrop-blur supports-[backdrop-filter]:bg-background/60`,children:(0,r.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-center gap-2 px-4 py-3 sm:px-6`,children:[(0,r.jsxs)(e,{to:`/docs`,className:`flex items-center gap-2 text-sm font-semibold hover:opacity-80`,children:[(0,r.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),(0,r.jsx)(`span`,{children:`Documentation`})]}),t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`span`,{className:`text-muted-foreground/60`,"aria-hidden":!0,children:`/`}),(0,r.jsx)(`span`,{className:`truncate text-sm text-muted-foreground`,children:t})]}):null]})}),i]})}export{i as t};
1
+ import{a as e,r as t}from"./vendor-react-CsWFRkED.js";import{Rc as n}from"./ui-components-CMHDBJEm.js";var r=t();function i({breadcrumb:t,children:i}){return(0,r.jsxs)(`div`,{className:`min-h-full`,children:[(0,r.jsx)(`header`,{className:`sticky top-0 z-10 border-b border-border bg-background/80 backdrop-blur supports-[backdrop-filter]:bg-background/60`,children:(0,r.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-center gap-2 px-4 py-3 sm:px-6`,children:[(0,r.jsxs)(e,{to:`/docs`,className:`flex items-center gap-2 text-sm font-semibold hover:opacity-80`,children:[(0,r.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),(0,r.jsx)(`span`,{children:`Documentation`})]}),t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`span`,{className:`text-muted-foreground/60`,"aria-hidden":!0,children:`/`}),(0,r.jsx)(`span`,{className:`truncate text-sm text-muted-foreground`,children:t})]}):null]})}),i]})}export{i as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,b as n,r}from"./vendor-react-CsWFRkED.js";import{Rc as i,sc as a,vo as o}from"./ui-components-D2lrjG-t.js";import{t as s}from"./DocShell-Ipy_IDvh.js";import{a as c,n as l}from"./use-book-data-qUZAxIs0.js";var u=e(n(),1),d=r();function f(){let{books:e,docs:n,state:r,error:f}=l(),p=(0,u.useMemo)(()=>c(e,n),[e,n]);return r===`loading`?(0,d.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,d.jsx)(o,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):r===`error`?(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)(a,{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:f})]}):(0,d.jsx)(s,{children:(0,d.jsxs)(`div`,{className:`mx-auto max-w-4xl p-4 sm:p-6`,children:[(0,d.jsxs)(`header`,{className:`mb-6`,children:[(0,d.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Documentation`}),(0,d.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Books and guides from your installed packages.`})]}),p.length===0?(0,d.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,d.jsx)(i,{className:`h-10 w-10`}),(0,d.jsxs)(`p`,{className:`text-sm`,children:[`No documentation is installed. Packages ship docs as flat`,(0,d.jsx)(`code`,{className:`mx-1 rounded bg-muted px-1 py-0.5`,children:`src/docs/*.md`}),`files, organised by a `,(0,d.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`book`}),` (ADR-0046).`]})]}):(0,d.jsx)(`ul`,{className:`grid items-stretch gap-3 sm:grid-cols-2`,children:p.map(e=>(0,d.jsx)(`li`,{className:`h-full`,children:(0,d.jsxs)(t,{to:`/docs/${e.slug}`,className:`flex h-full items-start gap-3 rounded-md border border-border p-3 hover:bg-muted/50`,children:[(0,d.jsx)(i,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,d.jsxs)(`div`,{className:`min-w-0`,children:[(0,d.jsx)(`div`,{className:`text-sm font-semibold`,children:e.label}),e.description?(0,d.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}):e.subtitle?(0,d.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground/70`,children:e.subtitle}):null,(0,d.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground/80`,children:[e.docCount,` `,e.docCount===1?`article`:`articles`]})]})]})},e.name))})]})})}export{f as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,b as n,r}from"./vendor-react-CsWFRkED.js";import{Rc as i,sc as a,vo as o}from"./ui-components-CMHDBJEm.js";import{t as s}from"./DocShell-D4dSPfBz.js";import{a as c,n as l}from"./use-book-data-CM73PGvc.js";var u=e(n(),1),d=r();function f(){let{books:e,docs:n,state:r,error:f}=l(),p=(0,u.useMemo)(()=>c(e,n),[e,n]);return r===`loading`?(0,d.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,d.jsx)(o,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):r===`error`?(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)(a,{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:f})]}):(0,d.jsx)(s,{children:(0,d.jsxs)(`div`,{className:`mx-auto max-w-4xl p-4 sm:p-6`,children:[(0,d.jsxs)(`header`,{className:`mb-6`,children:[(0,d.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Documentation`}),(0,d.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Books and guides from your installed packages.`})]}),p.length===0?(0,d.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,d.jsx)(i,{className:`h-10 w-10`}),(0,d.jsxs)(`p`,{className:`text-sm`,children:[`No documentation is installed. Packages ship docs as flat`,(0,d.jsx)(`code`,{className:`mx-1 rounded bg-muted px-1 py-0.5`,children:`src/docs/*.md`}),`files, organised by a `,(0,d.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`book`}),` (ADR-0046).`]})]}):(0,d.jsx)(`ul`,{className:`grid items-stretch gap-3 sm:grid-cols-2`,children:p.map(e=>(0,d.jsx)(`li`,{className:`h-full`,children:(0,d.jsxs)(t,{to:`/docs/${e.slug}`,className:`flex h-full items-start gap-3 rounded-md border border-border p-3 hover:bg-muted/50`,children:[(0,d.jsx)(i,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,d.jsxs)(`div`,{className:`min-w-0`,children:[(0,d.jsx)(`div`,{className:`text-sm font-semibold`,children:e.label}),e.description?(0,d.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}):e.subtitle?(0,d.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground/70`,children:e.subtitle}):null,(0,d.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground/80`,children:[e.docCount,` `,e.docCount===1?`article`:`articles`]})]})]})},e.name))})]})})}export{f as default};
@@ -1 +1 @@
1
- import{c as e,r as t}from"./vendor-react-CsWFRkED.js";import{r as n,t as r}from"./use-book-data-qUZAxIs0.js";var i=t();function a(){let t=n();return(0,i.jsx)(r.Provider,{value:t,children:(0,i.jsx)(e,{})})}export{a as default};
1
+ import{c as e,r as t}from"./vendor-react-CsWFRkED.js";import{r as n,t as r}from"./use-book-data-CM73PGvc.js";var i=t();function a(){let t=n();return(0,i.jsx)(r.Provider,{value:t,children:(0,i.jsx)(e,{})})}export{a as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,h as n,r,s as i}from"./vendor-react-CsWFRkED.js";import{Rc as a,ps as o,vo as s}from"./ui-components-D2lrjG-t.js";import{t as c}from"./DocShell-Ipy_IDvh.js";import{i as l,l as u,n as d,o as f,s as p,u as m}from"./use-book-data-qUZAxIs0.js";var h=e(t(),1),g=r();function _(){let{slug:e,appName:t}=n(),{books:r,docs:p,state:_}=d(),v=(0,h.useMemo)(()=>r.find(t=>l(t)===e),[r,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=t?`/apps/${t}/docs`:`/docs`;return(0,g.jsx)(i,{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:t}=n(),{books:r,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&&r.some(t=>l(t)===e))return(0,g.jsx)(_,{});let f=t?`/apps/${t}/docs`:`/docs`,m=e?p(e,r,a):null;return m&&e?(0,g.jsx)(i,{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
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,h as n,r,s as i}from"./vendor-react-CsWFRkED.js";import{Rc as a,ps as o,vo as s}from"./ui-components-CMHDBJEm.js";import{t as c}from"./DocShell-D4dSPfBz.js";import{i as l,l as u,n as d,o as f,s as p,u as m}from"./use-book-data-CM73PGvc.js";var h=e(t(),1),g=r();function _(){let{slug:e,appName:t}=n(),{books:r,docs:p,state:_}=d(),v=(0,h.useMemo)(()=>r.find(t=>l(t)===e),[r,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=t?`/apps/${t}/docs`:`/docs`;return(0,g.jsx)(i,{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:t}=n(),{books:r,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&&r.some(t=>l(t)===e))return(0,g.jsx)(_,{});let f=t?`/apps/${t}/docs`:`/docs`,m=e?p(e,r,a):null;return m&&e?(0,g.jsx)(i,{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 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,r as n}from"./vendor-react-CsWFRkED.js";import{St as r,Zn as i,gt as a}from"./framework-BfSv4Kb0.js";var o=e(t(),1),s=n(),c=(0,o.createContext)(null);function l({user:e={},app:t={},data:n={},features:r={}}={}){return{current_user:e,user:e,ctx:{user:e},os:{user:e},app:t,data:n,features:r}}function u(e={}){return new i(l(e))}function d({children:e,user:t={},app:n={},data:i={},features:a={}}){let d=(0,o.useMemo)(()=>({user:t,app:n,data:i,features:a,evaluator:u({user:t,app:n,data:i,features:a})}),[t,n,i,a]),f=(0,o.useMemo)(()=>l({user:t,app:n,data:i,features:a}),[t,n,i,a]);return(0,s.jsx)(c.Provider,{value:d,children:(0,s.jsx)(r,{scope:f,children:e})})}function f(){let e=(0,o.useContext)(c);if(!e){let e={user:{},app:{},data:{},features:{}};return{...e,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 r=t=>a(p,void 0,n,e,t,`app-shell`);try{return t.evaluateCondition(e,{onFault:r})}catch(e){return r(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
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,r as n}from"./vendor-react-CsWFRkED.js";import{St as r,er as i,gt as a}from"./framework-DFE_Mws9.js";var o=e(t(),1),s=n(),c=(0,o.createContext)(null);function l({user:e={},app:t={},data:n={},features:r={}}={}){return{current_user:e,user:e,ctx:{user:e},os:{user:e},app:t,data:n,features:r}}function u(e={}){return new i(l(e))}function d({children:e,user:t={},app:n={},data:i={},features:a={}}){let d=(0,o.useMemo)(()=>({user:t,app:n,data:i,features:a,evaluator:u({user:t,app:n,data:i,features:a})}),[t,n,i,a]),f=(0,o.useMemo)(()=>l({user:t,app:n,data:i,features:a}),[t,n,i,a]);return(0,s.jsx)(c.Provider,{value:d,children:(0,s.jsx)(r,{scope:f,children:e})})}function f(){let e=(0,o.useContext)(c);if(!e){let e={user:{},app:{},data:{},features:{}};return{...e,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 r=t=>a(p,void 0,n,e,t,`app-shell`);try{return t.evaluateCondition(e,{onFault:r})}catch(e){return r(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 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,r as n}from"./vendor-react-CsWFRkED.js";import{c as r}from"./infrastructure-CIpDEFyQ.js";import{J as i,q as a}from"./framework-BfSv4Kb0.js";import{Ar as o,Bn as s,Gt as c,In as l,Jt as u,Kt as d,Mr as f,Or as p,Pr as m,Rt as h,Sn as g,Us as _,Ut as v,Wt as y,Xr as b,Ys as x,Yt as S,bn as C,gn as w,ic as T,ii as E,jr as D,ka as O,kn as k,kr as A,qt as j,sc as M,va as N,vn as P,vo as F,xn as I,yn as L}from"./ui-components-D2lrjG-t.js";import{k as R}from"./RecordDetailView-A8bbPnkK.js";import"./src-JX1BkhmR.js";var z=e(t(),1),B=n();function V({status:e}){let t={success:{icon:T,cls:`text-emerald-600 border-emerald-300`},completed:{icon:T,cls:`text-emerald-600 border-emerald-300`},failed:{icon:x,cls:`text-red-600 border-red-300`},error:{icon:x,cls:`text-red-600 border-red-300`},running:{icon:F,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:_,cls:`text-amber-600 border-amber-300`},paused:{icon:_,cls:`text-amber-600 border-amber-300`},skipped:{icon:M,cls:`text-muted-foreground`}}[e]??{icon:M,cls:`text-muted-foreground`},n=t.icon;return(0,B.jsxs)(m,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,B.jsx)(n,{className:`h-3 w-3`}),e]})}function H(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function U(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function W({data:e}){return(0,B.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function G(){let e=a()?.getClient?.(),[t,n]=(0,z.useState)([]),[r,i]=(0,z.useState)(!0),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(``),[d,m]=(0,z.useState)(0),h=(0,z.useCallback)(async()=>{if(!e?.meta?.getItems){c(`meta.getItems is not available on this client`),i(!1);return}i(!0),c(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!l&&r.length>0&&u(r[0].name)}catch(e){c(e?.message??String(e))}finally{i(!1)}},[e,l]);(0,z.useEffect)(()=>{h()},[h]);let g=(0,z.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,B.jsx)(E,{className:`h-5 w-5`}),`Flow Runs`]}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,B.jsxs)(p,{children:[(0,B.jsx)(D,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(f,{className:`text-base`,children:`Flow`}),(0,B.jsx)(o,{children:`Select a flow definition to test`})]}),(0,B.jsxs)(b,{variant:`outline`,size:`sm`,onClick:h,disabled:r,children:[(0,B.jsx)(N,{className:`h-3.5 w-3.5 mr-2 ${r?`animate-spin`:``}`}),`Refresh`]})]})}),(0,B.jsxs)(A,{children:[r&&(0,B.jsx)(w,{className:`h-9 w-72`}),s&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!r&&!s&&t.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!r&&!s&&t.length>0&&(0,B.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),g&&(0,B.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,B.jsx)(K,{client:e,flow:g.spec,onExecuted:()=>m(e=>e+1)}),(0,B.jsx)(q,{client:e,flowName:g.name,refreshKey:d})]})]})}function K({client:e,flow:t,onExecuted:n}){let c=(0,z.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),u=a(),{objects:d}=i(),g=(0,z.useMemo)(()=>r(),[]),[v,y]=(0,z.useState)({}),[C,w]=(0,z.useState)(!1),[E,k]=(0,z.useState)(null),[j,M]=(0,z.useState)(null),[N,P]=(0,z.useState)(null);(0,z.useEffect)(()=>{y({}),k(null),M(null),P(null)},[t?.name]);let I=(e,t)=>y(n=>({...n,[e]:t}));return(0,B.jsxs)(p,{children:[(0,B.jsxs)(D,{className:`pb-3`,children:[(0,B.jsx)(f,{className:`text-base`,children:`Test Run`}),(0,B.jsx)(o,{children:`Provide input values and invoke the flow`})]}),(0,B.jsxs)(A,{className:`space-y-3`,children:[c.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),c.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsxs)(s,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,B.jsx)(m,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(S,{id:`var-${e.name}`,checked:v[e.name]===`true`,onCheckedChange:t=>I(e.name,t?`true`:`false`)}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,B.jsx)(h,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:v[e.name]??``,onChange:t=>I(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,B.jsx)(l,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:v[e.name]??``,onChange:t=>I(e.name,t.target.value)})]},e.name)),(0,B.jsx)(`div`,{className:`pt-1`,children:(0,B.jsxs)(b,{onClick:async()=>{if(!e?.automation?.execute){M(`automation.execute is not available on this client`);return}w(!0),M(null),k(null),P(null);try{let r={};for(let e of c){let t=v[e.name];t!==void 0&&(r[e.name]=U(t,e.type))}let i=await e.automation.execute(t.name,{params:r});k(i),i?.status===`paused`&&i?.screen&&i?.runId&&P({flowName:t.name,runId:i.runId,screen:i.screen}),n?.()}catch(e){M(e?.message??String(e))}finally{w(!1)}},disabled:C,size:`sm`,children:[C?(0,B.jsx)(F,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(O,{className:`h-3.5 w-3.5 mr-2`}),C?`Running…`:`Run Flow`]})}),(E||j)&&(0,B.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[j||E?.success===!1?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(x,{className:`h-4 w-4 text-red-500`}),` Failed`]}):E?.status===`paused`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(_,{className:`h-4 w-4 text-amber-500`}),` Waiting for input`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(T,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof E?.durationMs==`number`&&(0,B.jsxs)(m,{variant:`secondary`,className:`text-[10px] font-mono`,children:[E.durationMs,` ms`]})]}),j&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:j}),E?.status===`paused`&&E?.screen&&E?.runId&&!N&&(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This run is paused at screen `,(0,B.jsx)(`span`,{className:`font-mono`,children:E.screen.nodeId}),`.`]}),(0,B.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>P({flowName:t.name,runId:E.runId,screen:E.screen}),children:`Continue run`})]}),E&&(0,B.jsx)(W,{data:E})]})]}),(0,B.jsx)(R,{state:N,authFetch:g,baseUrl:``,dataSource:u,objects:d,onClose:()=>{P(null),n?.()},onComplete:()=>{P(null),n?.()}})]})}function q({client:e,flowName:t,refreshKey:n}){let[r,i]=(0,z.useState)([]),[a,s]=(0,z.useState)(!0),[l,h]=(0,z.useState)(null),[_,x]=(0,z.useState)(null),[S,T]=(0,z.useState)(null),[E,O]=(0,z.useState)(!1),[M,R]=(0,z.useState)(null),U=(0,z.useCallback)(async()=>{if(!e?.automation?.listRuns){h(`automation.listRuns is not available on this client`),s(!1);return}s(!0),h(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];i(r)}catch(e){h(e?.message??String(e))}finally{s(!1)}},[e,t]);(0,z.useEffect)(()=>{U()},[U,n]);let G=async n=>{x(n),T(null),R(null),O(!0);try{let r=await e.automation.getRun(t,n);T(r?.run??r)}catch(e){R(e?.message??String(e))}finally{O(!1)}};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(p,{children:[(0,B.jsx)(D,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(f,{className:`text-base`,children:`Recent Runs`}),(0,B.jsx)(o,{className:`font-mono text-xs`,children:t})]}),(0,B.jsxs)(b,{variant:`outline`,size:`sm`,onClick:U,disabled:a,children:[a?(0,B.jsx)(F,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(N,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,B.jsxs)(A,{children:[a&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(w,{className:`h-8 w-full`}),(0,B.jsx)(w,{className:`h-8 w-full`}),(0,B.jsx)(w,{className:`h-8 w-full`})]}),!a&&l&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:l}),!a&&!l&&r.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!a&&!l&&r.length>0&&(0,B.jsxs)(v,{children:[(0,B.jsx)(j,{children:(0,B.jsxs)(u,{children:[(0,B.jsx)(d,{children:`Run`}),(0,B.jsx)(d,{children:`Status`}),(0,B.jsx)(d,{children:`Started`}),(0,B.jsx)(d,{className:`text-right`,children:`Duration`})]})}),(0,B.jsx)(y,{children:r.map(e=>(0,B.jsxs)(u,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,B.jsxs)(c,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,B.jsx)(c,{children:(0,B.jsx)(V,{status:e.status})}),(0,B.jsx)(c,{className:`text-xs text-muted-foreground`,children:H(e.startedAt)}),(0,B.jsx)(c,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,B.jsx)(P,{open:!!_,onOpenChange:e=>{e||(x(null),T(null))},children:(0,B.jsxs)(L,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,B.jsxs)(I,{className:`p-4 border-b`,children:[(0,B.jsxs)(g,{className:`font-mono text-sm break-all`,children:[`Run `,_]}),(0,B.jsx)(C,{children:S&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,B.jsx)(V,{status:S.status}),typeof S.durationMs==`number`&&(0,B.jsxs)(m,{variant:`secondary`,className:`text-[10px] font-mono`,children:[S.durationMs,` ms`]}),(0,B.jsx)(`span`,{className:`text-xs`,children:H(S.startedAt)})]})})]}),(0,B.jsxs)(k,{className:`flex-1 p-4`,children:[E&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(w,{className:`h-16 w-full`}),(0,B.jsx)(w,{className:`h-16 w-full`}),(0,B.jsx)(w,{className:`h-16 w-full`})]}),M&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:M}),!E&&S&&(0,B.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(S.steps)&&S.steps.length>0?S.steps.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,B.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,B.jsx)(m,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,B.jsx)(V,{status:e.status}),typeof e.durationMs==`number`&&(0,B.jsxs)(m,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,B.jsx)(W,{data:e.input})]}),e.output!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,B.jsx)(W,{data:e.output})]}),e.error&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,B.jsx)(W,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,B.jsx)(W,{data:S})]})})]})]})})]})}export{G as FlowRunsPage};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,r as n}from"./vendor-react-CsWFRkED.js";import{c as r}from"./infrastructure-B4zG1jNa.js";import{J as i,q as a}from"./framework-DFE_Mws9.js";import{Ar as o,Bn as s,Gt as c,In as l,Jt as u,Kt as d,Mr as f,Or as p,Pr as m,Rt as h,Sn as g,Us as _,Ut as v,Wt as y,Xr as b,Ys as x,Yt as S,bn as C,gn as w,ic as T,ii as E,jr as D,ka as O,kn as k,kr as A,qt as j,sc as M,va as N,vn as P,vo as F,xn as I,yn as L}from"./ui-components-CMHDBJEm.js";import{k as R}from"./RecordDetailView-XWxuegfV.js";import"./src-hcMLuWxG.js";var z=e(t(),1),B=n();function V({status:e}){let t={success:{icon:T,cls:`text-emerald-600 border-emerald-300`},completed:{icon:T,cls:`text-emerald-600 border-emerald-300`},failed:{icon:x,cls:`text-red-600 border-red-300`},error:{icon:x,cls:`text-red-600 border-red-300`},running:{icon:F,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:_,cls:`text-amber-600 border-amber-300`},paused:{icon:_,cls:`text-amber-600 border-amber-300`},skipped:{icon:M,cls:`text-muted-foreground`}}[e]??{icon:M,cls:`text-muted-foreground`},n=t.icon;return(0,B.jsxs)(m,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,B.jsx)(n,{className:`h-3 w-3`}),e]})}function H(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function U(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function W({data:e}){return(0,B.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function G(){let e=a()?.getClient?.(),[t,n]=(0,z.useState)([]),[r,i]=(0,z.useState)(!0),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(``),[d,m]=(0,z.useState)(0),h=(0,z.useCallback)(async()=>{if(!e?.meta?.getItems){c(`meta.getItems is not available on this client`),i(!1);return}i(!0),c(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!l&&r.length>0&&u(r[0].name)}catch(e){c(e?.message??String(e))}finally{i(!1)}},[e,l]);(0,z.useEffect)(()=>{h()},[h]);let g=(0,z.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,B.jsx)(E,{className:`h-5 w-5`}),`Flow Runs`]}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,B.jsxs)(p,{children:[(0,B.jsx)(D,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(f,{className:`text-base`,children:`Flow`}),(0,B.jsx)(o,{children:`Select a flow definition to test`})]}),(0,B.jsxs)(b,{variant:`outline`,size:`sm`,onClick:h,disabled:r,children:[(0,B.jsx)(N,{className:`h-3.5 w-3.5 mr-2 ${r?`animate-spin`:``}`}),`Refresh`]})]})}),(0,B.jsxs)(A,{children:[r&&(0,B.jsx)(w,{className:`h-9 w-72`}),s&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!r&&!s&&t.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!r&&!s&&t.length>0&&(0,B.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),g&&(0,B.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,B.jsx)(K,{client:e,flow:g.spec,onExecuted:()=>m(e=>e+1)}),(0,B.jsx)(q,{client:e,flowName:g.name,refreshKey:d})]})]})}function K({client:e,flow:t,onExecuted:n}){let c=(0,z.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),u=a(),{objects:d}=i(),g=(0,z.useMemo)(()=>r(),[]),[v,y]=(0,z.useState)({}),[C,w]=(0,z.useState)(!1),[E,k]=(0,z.useState)(null),[j,M]=(0,z.useState)(null),[N,P]=(0,z.useState)(null);(0,z.useEffect)(()=>{y({}),k(null),M(null),P(null)},[t?.name]);let I=(e,t)=>y(n=>({...n,[e]:t}));return(0,B.jsxs)(p,{children:[(0,B.jsxs)(D,{className:`pb-3`,children:[(0,B.jsx)(f,{className:`text-base`,children:`Test Run`}),(0,B.jsx)(o,{children:`Provide input values and invoke the flow`})]}),(0,B.jsxs)(A,{className:`space-y-3`,children:[c.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),c.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsxs)(s,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,B.jsx)(m,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(S,{id:`var-${e.name}`,checked:v[e.name]===`true`,onCheckedChange:t=>I(e.name,t?`true`:`false`)}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,B.jsx)(h,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:v[e.name]??``,onChange:t=>I(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,B.jsx)(l,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:v[e.name]??``,onChange:t=>I(e.name,t.target.value)})]},e.name)),(0,B.jsx)(`div`,{className:`pt-1`,children:(0,B.jsxs)(b,{onClick:async()=>{if(!e?.automation?.execute){M(`automation.execute is not available on this client`);return}w(!0),M(null),k(null),P(null);try{let r={};for(let e of c){let t=v[e.name];t!==void 0&&(r[e.name]=U(t,e.type))}let i=await e.automation.execute(t.name,{params:r});k(i),i?.status===`paused`&&i?.screen&&i?.runId&&P({flowName:t.name,runId:i.runId,screen:i.screen}),n?.()}catch(e){M(e?.message??String(e))}finally{w(!1)}},disabled:C,size:`sm`,children:[C?(0,B.jsx)(F,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(O,{className:`h-3.5 w-3.5 mr-2`}),C?`Running…`:`Run Flow`]})}),(E||j)&&(0,B.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[j||E?.success===!1?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(x,{className:`h-4 w-4 text-red-500`}),` Failed`]}):E?.status===`paused`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(_,{className:`h-4 w-4 text-amber-500`}),` Waiting for input`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(T,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof E?.durationMs==`number`&&(0,B.jsxs)(m,{variant:`secondary`,className:`text-[10px] font-mono`,children:[E.durationMs,` ms`]})]}),j&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:j}),E?.status===`paused`&&E?.screen&&E?.runId&&!N&&(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This run is paused at screen `,(0,B.jsx)(`span`,{className:`font-mono`,children:E.screen.nodeId}),`.`]}),(0,B.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>P({flowName:t.name,runId:E.runId,screen:E.screen}),children:`Continue run`})]}),E&&(0,B.jsx)(W,{data:E})]})]}),(0,B.jsx)(R,{state:N,authFetch:g,baseUrl:``,dataSource:u,objects:d,onClose:()=>{P(null),n?.()},onComplete:()=>{P(null),n?.()}})]})}function q({client:e,flowName:t,refreshKey:n}){let[r,i]=(0,z.useState)([]),[a,s]=(0,z.useState)(!0),[l,h]=(0,z.useState)(null),[_,x]=(0,z.useState)(null),[S,T]=(0,z.useState)(null),[E,O]=(0,z.useState)(!1),[M,R]=(0,z.useState)(null),U=(0,z.useCallback)(async()=>{if(!e?.automation?.listRuns){h(`automation.listRuns is not available on this client`),s(!1);return}s(!0),h(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];i(r)}catch(e){h(e?.message??String(e))}finally{s(!1)}},[e,t]);(0,z.useEffect)(()=>{U()},[U,n]);let G=async n=>{x(n),T(null),R(null),O(!0);try{let r=await e.automation.getRun(t,n);T(r?.run??r)}catch(e){R(e?.message??String(e))}finally{O(!1)}};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(p,{children:[(0,B.jsx)(D,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(f,{className:`text-base`,children:`Recent Runs`}),(0,B.jsx)(o,{className:`font-mono text-xs`,children:t})]}),(0,B.jsxs)(b,{variant:`outline`,size:`sm`,onClick:U,disabled:a,children:[a?(0,B.jsx)(F,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(N,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,B.jsxs)(A,{children:[a&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(w,{className:`h-8 w-full`}),(0,B.jsx)(w,{className:`h-8 w-full`}),(0,B.jsx)(w,{className:`h-8 w-full`})]}),!a&&l&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:l}),!a&&!l&&r.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!a&&!l&&r.length>0&&(0,B.jsxs)(v,{children:[(0,B.jsx)(j,{children:(0,B.jsxs)(u,{children:[(0,B.jsx)(d,{children:`Run`}),(0,B.jsx)(d,{children:`Status`}),(0,B.jsx)(d,{children:`Started`}),(0,B.jsx)(d,{className:`text-right`,children:`Duration`})]})}),(0,B.jsx)(y,{children:r.map(e=>(0,B.jsxs)(u,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,B.jsxs)(c,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,B.jsx)(c,{children:(0,B.jsx)(V,{status:e.status})}),(0,B.jsx)(c,{className:`text-xs text-muted-foreground`,children:H(e.startedAt)}),(0,B.jsx)(c,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,B.jsx)(P,{open:!!_,onOpenChange:e=>{e||(x(null),T(null))},children:(0,B.jsxs)(L,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,B.jsxs)(I,{className:`p-4 border-b`,children:[(0,B.jsxs)(g,{className:`font-mono text-sm break-all`,children:[`Run `,_]}),(0,B.jsx)(C,{children:S&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,B.jsx)(V,{status:S.status}),typeof S.durationMs==`number`&&(0,B.jsxs)(m,{variant:`secondary`,className:`text-[10px] font-mono`,children:[S.durationMs,` ms`]}),(0,B.jsx)(`span`,{className:`text-xs`,children:H(S.startedAt)})]})})]}),(0,B.jsxs)(k,{className:`flex-1 p-4`,children:[E&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(w,{className:`h-16 w-full`}),(0,B.jsx)(w,{className:`h-16 w-full`}),(0,B.jsx)(w,{className:`h-16 w-full`})]}),M&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:M}),!E&&S&&(0,B.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(S.steps)&&S.steps.length>0?S.steps.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,B.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,B.jsx)(m,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,B.jsx)(V,{status:e.status}),typeof e.durationMs==`number`&&(0,B.jsxs)(m,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,B.jsx)(W,{data:e.input})]}),e.output!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,B.jsx)(W,{data:e.output})]}),e.error&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,B.jsx)(W,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,B.jsx)(W,{data:S})]})})]})]})})]})}export{G as FlowRunsPage};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,h as n,p as r,r as i}from"./vendor-react-CsWFRkED.js";import{Ar as a,Br as o,Cr as s,Fs as c,Ic as l,In as u,Mr as d,Ms as f,No as p,Oa as m,Or as h,Os as g,Pr as _,Rr as v,Sr as y,Xr as b,br as x,ea as S,gc as C,jr as w,ki as T,kr as E,vr as D,xr as O,yr as k,zr as A}from"./ui-components-D2lrjG-t.js";var j=e(t(),1),M=`objectstack`,N=`Query and modify data in an ObjectStack app over MCP — discover objects, read and filter records, and create/update/delete under your own permissions and row-level security. Use when the user wants to inspect or change data in their ObjectStack environment.`,P=`<YOUR_ENV_MCP_URL>`;function F(e={}){let t=e.mcpUrl?.trim()||P,n=e.envName?.trim();return`---
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{b as t,h as n,p as r,r as i}from"./vendor-react-CsWFRkED.js";import{Ar as a,Br as o,Cr as s,Fs as c,Ic as l,In as u,Mr as d,Ms as f,No as p,Oa as m,Or as h,Os as g,Pr as _,Rr as v,Sr as y,Xr as b,br as x,ea as S,gc as C,jr as w,ki as T,kr as E,vr as D,xr as O,yr as k,zr as A}from"./ui-components-CMHDBJEm.js";var j=e(t(),1),M=`objectstack`,N=`Query and modify data in an ObjectStack app over MCP — discover objects, read and filter records, and create/update/delete under your own permissions and row-level security. Use when the user wants to inspect or change data in their ObjectStack environment.`,P=`<YOUR_ENV_MCP_URL>`;function F(e={}){let t=e.mcpUrl?.trim()||P,n=e.envName?.trim();return`---
2
2
  name: ${M}
3
3
  description: ${N}
4
4
  ---