@protobase/ui 0.119.1 → 0.119.3

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 (192) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/app/change-confirm/messages.d.ts +2 -2
  3. package/dist/app/charts/messages.d.ts +2 -2
  4. package/dist/app/create/messages.d.ts +2 -2
  5. package/dist/app/delete/messages.d.ts +2 -2
  6. package/dist/app/displays/messages.d.ts +2 -2
  7. package/dist/app/export/messages.d.ts +2 -2
  8. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  9. package/dist/app/field-types/workflow/definition.d.ts +1 -1
  10. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  11. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  12. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  13. package/dist/app/focus/messages.d.ts +2 -2
  14. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  15. package/dist/app/import/messages.d.ts +2 -2
  16. package/dist/app/list-messages.d.ts +2 -2
  17. package/dist/app/messages.d.ts +2 -2
  18. package/dist/app/meta-gate-messages.d.ts +2 -2
  19. package/dist/app/pages/messages.d.ts +2 -2
  20. package/dist/app/record-chart/messages.d.ts +2 -2
  21. package/dist/app/record-messages.d.ts +2 -2
  22. package/dist/app/related-cards/messages.d.ts +2 -2
  23. package/dist/app/saved/messages.d.ts +2 -2
  24. package/dist/app/saved/use-favorite.d.ts +1 -1
  25. package/dist/app/searches/messages.d.ts +2 -2
  26. package/dist/app/searches/use-save-search.d.ts +1 -1
  27. package/dist/app/start-target.d.ts +38 -0
  28. package/dist/app/start-target.js +38 -0
  29. package/dist/app/use-start-address.d.ts +6 -9
  30. package/dist/app/use-start-address.js +23 -21
  31. package/dist/app-shell/messages.d.ts +2 -2
  32. package/dist/assistant-dock/messages.d.ts +2 -2
  33. package/dist/auth/messages.d.ts +2 -2
  34. package/dist/calls/messages.d.ts +2 -2
  35. package/dist/filter-panel/messages.d.ts +2 -2
  36. package/dist/forms/messages.d.ts +2 -2
  37. package/dist/invitations/messages.d.ts +2 -2
  38. package/dist/mocks/customers.d.ts +1 -1
  39. package/dist/mocks/invoices.d.ts +1 -1
  40. package/dist/mocks/orders.d.ts +2 -2
  41. package/dist/notifications/bell/messages.d.ts +2 -2
  42. package/dist/organizations/messages.d.ts +2 -2
  43. package/dist/package.js +1 -1
  44. package/dist/plugins/messages.d.ts +2 -2
  45. package/dist/primitives/messages.d.ts +2 -2
  46. package/dist/shell/assets/{account-page-BXnceUQo.js → account-page-d4bA-Rnh.js} +2 -2
  47. package/dist/shell/assets/{app-D3BCcbgE.js → app-B94YfKGx.js} +11 -11
  48. package/dist/shell/assets/{assistant-shell-DKf9TfL2.js → assistant-shell-DTNOfaAZ.js} +2 -2
  49. package/dist/shell/assets/{board-display-DJkQwIfT.js → board-display-ClTe26F0.js} +2 -2
  50. package/dist/shell/assets/{calendar-display-BKyuHAAF.js → calendar-display-CwBcu_JO.js} +2 -2
  51. package/dist/shell/assets/{call-rings-D_kQbFd3.js → call-rings-D8cGALi4.js} +2 -2
  52. package/dist/shell/assets/{calls-D6jSGMCo.js → calls-DLSo4hNS.js} +2 -2
  53. package/dist/shell/assets/{circle-alert-ytReRN_c.js → circle-alert-C8YjGdRx.js} +2 -2
  54. package/dist/shell/assets/{composed-page-CbNBBioS.js → composed-page-DBHl-wl_.js} +2 -2
  55. package/dist/shell/assets/{composer-section-cg-cdFZx.js → composer-section-6TvE0L2w.js} +2 -2
  56. package/dist/shell/assets/{connect-route-hMUPiAft.js → connect-route-C8Km-e8S.js} +2 -2
  57. package/dist/shell/assets/{copy-field-BoXXafL7.js → copy-field-DXp0fGDR.js} +2 -2
  58. package/dist/shell/assets/{create-route-BePHRkTZ.js → create-route-s8RsjtyM.js} +2 -2
  59. package/dist/shell/assets/{custom-step-container-field-B3bsPeCV.js → custom-step-container-field-B8ut5WnP.js} +2 -2
  60. package/dist/shell/assets/{embedded-list-6lQyJozS.js → embedded-list-OJQKeuBN.js} +3 -3
  61. package/dist/shell/assets/{export-dialog-BUbdSkkU.js → export-dialog-gSUSlzOy.js} +2 -2
  62. package/dist/shell/assets/{first-organization-page-BhQOFT5P.js → first-organization-page-C7YZ32Kt.js} +2 -2
  63. package/dist/shell/assets/{graph-view-DZHMI-UQ.js → graph-view-_7poAZsr.js} +2 -2
  64. package/dist/shell/assets/{group-donut-Cu5Ny3gq.js → group-donut-XjNEBVUq.js} +2 -2
  65. package/dist/shell/assets/{guest-call-page-DlAkbaRH.js → guest-call-page-Cj6F3D3u.js} +3 -3
  66. package/dist/shell/assets/{html-viewer-DrSS-WnU.js → html-viewer-CmYTAzWa.js} +2 -2
  67. package/dist/shell/assets/{import-dialog-Dk_31-PT.js → import-dialog-bNG6qX6Q.js} +2 -2
  68. package/dist/shell/assets/{import-table-dialog-vL-juOMH.js → import-table-dialog-BbI7GJ8R.js} +2 -2
  69. package/dist/shell/assets/{index-CTmZ8-B4.js → index-CYraq2Hi.js} +1 -1
  70. package/dist/shell/assets/{invitations-page-CfTEdorg.js → invitations-page-XV6kL2Mk.js} +2 -2
  71. package/dist/shell/assets/{layout-grid-CTlIrnH5.js → layout-grid-dpoR6hFU.js} +2 -2
  72. package/dist/shell/assets/{legend-item-CqkLpsWb.js → legend-item-WwKh2W6n.js} +2 -2
  73. package/dist/shell/assets/{list-page-Czg2Jaxx.js → list-page-DImD2FRO.js} +4 -4
  74. package/dist/shell/assets/{maplibre-Bd79IbdT.js → maplibre-Bm0OQH9k.js} +2 -2
  75. package/dist/shell/assets/{markdown-content-BGl9PFVi.js → markdown-content-BZLiLira.js} +2 -2
  76. package/dist/shell/assets/{members-page-CEB-Wkl8.js → members-page-ZcqzlQu6.js} +2 -2
  77. package/dist/shell/assets/{messages-Ce8dRRRN.js → messages-vzi5T1Xo.js} +2 -2
  78. package/dist/shell/assets/{organization-page-CTxtblmm.js → organization-page-CjrQmpot.js} +2 -2
  79. package/dist/shell/assets/{organizations-page-DeNhUQDU.js → organizations-page-C7gJsoCx.js} +2 -2
  80. package/dist/shell/assets/{pending-invitation-row-BMp0ZxE8.js → pending-invitation-row-BZVOux9W.js} +2 -2
  81. package/dist/shell/assets/{period-chart-BDqtO8mc.js → period-chart-GDqLnl9l.js} +2 -2
  82. package/dist/shell/assets/{person-row-DRqtbPma.js → person-row-DgXLW9D8.js} +2 -2
  83. package/dist/shell/assets/{public-form-page-XgK3-Nzh.js → public-form-page-DjLnqHPx.js} +2 -2
  84. package/dist/shell/assets/{record-lines-DdN5hlI_.js → record-lines-CDTPiIdF.js} +2 -2
  85. package/dist/shell/assets/{record-map-sOmjX80D.js → record-map-Dcmuv9J8.js} +2 -2
  86. package/dist/shell/assets/{record-opens-DLfbC3xo.js → record-opens-D7SV04zf.js} +2 -2
  87. package/dist/shell/assets/{record-page-BntRofCL.js → record-page-DGWHTUdD.js} +3 -3
  88. package/dist/shell/assets/{record-preview-QMV2lW2j.js → record-preview-DsIrTWKZ.js} +2 -2
  89. package/dist/shell/assets/{records-map-DgTxGcbC.js → records-map-G0QXqaUR.js} +2 -2
  90. package/dist/shell/assets/{render-node-CkL5Sgl_.js → render-node-0_Pb8ixy.js} +3 -3
  91. package/dist/shell/assets/{reorder-button-8yWv8J72.js → reorder-button-BhhzhhTO.js} +2 -2
  92. package/dist/shell/assets/{run-trace-view-BPvPw3Ko.js → run-trace-view-DLY3Mt5m.js} +2 -2
  93. package/dist/shell/assets/{runner-install-field-CKP8E9ZO.js → runner-install-field-Iwp4UP6o.js} +2 -2
  94. package/dist/shell/assets/{runtime-update-DGbf2Nmm.js → runtime-update-DKcAQek2.js} +2 -2
  95. package/dist/shell/assets/{shared-protobase-ui-DN-uvpOy.js → shared-protobase-ui-XTZSVgEm.js} +1 -1
  96. package/dist/shell/assets/{sheet-source-cKJfUaud.js → sheet-source-DxVQhlKF.js} +2 -2
  97. package/dist/shell/assets/{sign-in-policy-page-Bty4Ih1x.js → sign-in-policy-page-E1eBhmUM.js} +2 -2
  98. package/dist/shell/assets/{start-block-queries-x-gNbPt1.js → start-block-queries-Bu7xMabd.js} +2 -2
  99. package/dist/shell/assets/{step-catalog-CCAXc8kn.js → step-catalog-BPk6WuYH.js} +2 -2
  100. package/dist/shell/assets/{step-panel-jmfh86YA.js → step-panel-BXHWAw8x.js} +2 -2
  101. package/dist/shell/assets/{timeline-display-CtxOHPoJ.js → timeline-display-CJHQiDm9.js} +2 -2
  102. package/dist/shell/assets/{trash-CFCBxAWq.js → trash-MHAT5Hf3.js} +2 -2
  103. package/dist/shell/assets/{update-set-BYNQUWVp.js → update-set-B0D_tNDz.js} +2 -2
  104. package/dist/shell/assets/{use-calendar-move-BytgRG51.js → use-calendar-move-O_48Gqvs.js} +2 -2
  105. package/dist/shell/assets/{use-display-rows-DGw9J73C.js → use-display-rows-vjthlkqo.js} +2 -2
  106. package/dist/shell/assets/{use-my-invitations-BcMFAcXl.js → use-my-invitations-DDPuugTE.js} +2 -2
  107. package/dist/shell/assets/{use-paged-search-CKcKKO6y.js → use-paged-search-DRj8498k.js} +2 -2
  108. package/dist/shell/assets/{use-run-trace-BRwbwZcf.js → use-run-trace-CWGAibgF.js} +2 -2
  109. package/dist/shell/assets/{use-workflow-page-DsD276W-.js → use-workflow-page-C9ZEXX5R.js} +2 -2
  110. package/dist/shell/assets/{use-workflow-types-Bn24Chp-.js → use-workflow-types-DDh28X2_.js} +2 -2
  111. package/dist/shell/assets/{workflow-canvas-BKd_Yd0v.js → workflow-canvas-n_YJtaOh.js} +2 -2
  112. package/dist/shell/assets/{workflow-field-DyBaV6m5.js → workflow-field-CpkY17Cc.js} +3 -3
  113. package/dist/shell/assets/{workflow-graph-editor-B8RJ52_E.js → workflow-graph-editor-V-ZGHSrC.js} +2 -2
  114. package/dist/shell/assets/{workflow-run-field-CzluYhjs.js → workflow-run-field-CoUJGVdX.js} +3 -3
  115. package/dist/shell/assets/{workflow-status-field-_umgNjK4.js → workflow-status-field-nmrhtSls.js} +2 -2
  116. package/dist/shell/assets/{workflow-workbench-CqOI36Oy.js → workflow-workbench-DvzNEdn3.js} +2 -2
  117. package/dist/shell/index.html +3 -3
  118. package/dist/shell/protobase.shell.json +2 -2
  119. package/dist/shell/protobase.sw.js +2 -2
  120. package/dist/shell-source-maps/assets/{account-page-BXnceUQo.js.map → account-page-d4bA-Rnh.js.map} +1 -1
  121. package/dist/shell-source-maps/assets/app-B94YfKGx.js.map +1 -0
  122. package/dist/shell-source-maps/assets/{assistant-shell-DKf9TfL2.js.map → assistant-shell-DTNOfaAZ.js.map} +1 -1
  123. package/dist/shell-source-maps/assets/{board-display-DJkQwIfT.js.map → board-display-ClTe26F0.js.map} +1 -1
  124. package/dist/shell-source-maps/assets/{calendar-display-BKyuHAAF.js.map → calendar-display-CwBcu_JO.js.map} +1 -1
  125. package/dist/shell-source-maps/assets/{call-rings-D_kQbFd3.js.map → call-rings-D8cGALi4.js.map} +1 -1
  126. package/dist/shell-source-maps/assets/{calls-D6jSGMCo.js.map → calls-DLSo4hNS.js.map} +1 -1
  127. package/dist/shell-source-maps/assets/{circle-alert-ytReRN_c.js.map → circle-alert-C8YjGdRx.js.map} +1 -1
  128. package/dist/shell-source-maps/assets/{composed-page-CbNBBioS.js.map → composed-page-DBHl-wl_.js.map} +1 -1
  129. package/dist/shell-source-maps/assets/{composer-section-cg-cdFZx.js.map → composer-section-6TvE0L2w.js.map} +1 -1
  130. package/dist/shell-source-maps/assets/{connect-route-hMUPiAft.js.map → connect-route-C8Km-e8S.js.map} +1 -1
  131. package/dist/shell-source-maps/assets/{copy-field-BoXXafL7.js.map → copy-field-DXp0fGDR.js.map} +1 -1
  132. package/dist/shell-source-maps/assets/{create-route-BePHRkTZ.js.map → create-route-s8RsjtyM.js.map} +1 -1
  133. package/dist/shell-source-maps/assets/{custom-step-container-field-B3bsPeCV.js.map → custom-step-container-field-B8ut5WnP.js.map} +1 -1
  134. package/dist/shell-source-maps/assets/{embedded-list-6lQyJozS.js.map → embedded-list-OJQKeuBN.js.map} +1 -1
  135. package/dist/shell-source-maps/assets/{export-dialog-BUbdSkkU.js.map → export-dialog-gSUSlzOy.js.map} +1 -1
  136. package/dist/shell-source-maps/assets/{first-organization-page-BhQOFT5P.js.map → first-organization-page-C7YZ32Kt.js.map} +1 -1
  137. package/dist/shell-source-maps/assets/{graph-view-DZHMI-UQ.js.map → graph-view-_7poAZsr.js.map} +1 -1
  138. package/dist/shell-source-maps/assets/{group-donut-Cu5Ny3gq.js.map → group-donut-XjNEBVUq.js.map} +1 -1
  139. package/dist/shell-source-maps/assets/{guest-call-page-DlAkbaRH.js.map → guest-call-page-Cj6F3D3u.js.map} +1 -1
  140. package/dist/shell-source-maps/assets/{html-viewer-DrSS-WnU.js.map → html-viewer-CmYTAzWa.js.map} +1 -1
  141. package/dist/shell-source-maps/assets/{import-dialog-Dk_31-PT.js.map → import-dialog-bNG6qX6Q.js.map} +1 -1
  142. package/dist/shell-source-maps/assets/{import-table-dialog-vL-juOMH.js.map → import-table-dialog-BbI7GJ8R.js.map} +1 -1
  143. package/dist/shell-source-maps/assets/{invitations-page-CfTEdorg.js.map → invitations-page-XV6kL2Mk.js.map} +1 -1
  144. package/dist/shell-source-maps/assets/{layout-grid-CTlIrnH5.js.map → layout-grid-dpoR6hFU.js.map} +1 -1
  145. package/dist/shell-source-maps/assets/{legend-item-CqkLpsWb.js.map → legend-item-WwKh2W6n.js.map} +1 -1
  146. package/dist/shell-source-maps/assets/{list-page-Czg2Jaxx.js.map → list-page-DImD2FRO.js.map} +1 -1
  147. package/dist/shell-source-maps/assets/{maplibre-Bd79IbdT.js.map → maplibre-Bm0OQH9k.js.map} +1 -1
  148. package/dist/shell-source-maps/assets/{markdown-content-BGl9PFVi.js.map → markdown-content-BZLiLira.js.map} +1 -1
  149. package/dist/shell-source-maps/assets/{members-page-CEB-Wkl8.js.map → members-page-ZcqzlQu6.js.map} +1 -1
  150. package/dist/shell-source-maps/assets/{messages-Ce8dRRRN.js.map → messages-vzi5T1Xo.js.map} +1 -1
  151. package/dist/shell-source-maps/assets/{organization-page-CTxtblmm.js.map → organization-page-CjrQmpot.js.map} +1 -1
  152. package/dist/shell-source-maps/assets/{organizations-page-DeNhUQDU.js.map → organizations-page-C7gJsoCx.js.map} +1 -1
  153. package/dist/shell-source-maps/assets/{pending-invitation-row-BMp0ZxE8.js.map → pending-invitation-row-BZVOux9W.js.map} +1 -1
  154. package/dist/shell-source-maps/assets/{period-chart-BDqtO8mc.js.map → period-chart-GDqLnl9l.js.map} +1 -1
  155. package/dist/shell-source-maps/assets/{person-row-DRqtbPma.js.map → person-row-DgXLW9D8.js.map} +1 -1
  156. package/dist/shell-source-maps/assets/{public-form-page-XgK3-Nzh.js.map → public-form-page-DjLnqHPx.js.map} +1 -1
  157. package/dist/shell-source-maps/assets/{record-lines-DdN5hlI_.js.map → record-lines-CDTPiIdF.js.map} +1 -1
  158. package/dist/shell-source-maps/assets/{record-map-sOmjX80D.js.map → record-map-Dcmuv9J8.js.map} +1 -1
  159. package/dist/shell-source-maps/assets/{record-opens-DLfbC3xo.js.map → record-opens-D7SV04zf.js.map} +1 -1
  160. package/dist/shell-source-maps/assets/{record-page-BntRofCL.js.map → record-page-DGWHTUdD.js.map} +1 -1
  161. package/dist/shell-source-maps/assets/{record-preview-QMV2lW2j.js.map → record-preview-DsIrTWKZ.js.map} +1 -1
  162. package/dist/shell-source-maps/assets/{records-map-DgTxGcbC.js.map → records-map-G0QXqaUR.js.map} +1 -1
  163. package/dist/shell-source-maps/assets/{render-node-CkL5Sgl_.js.map → render-node-0_Pb8ixy.js.map} +1 -1
  164. package/dist/shell-source-maps/assets/{reorder-button-8yWv8J72.js.map → reorder-button-BhhzhhTO.js.map} +1 -1
  165. package/dist/shell-source-maps/assets/{run-trace-view-BPvPw3Ko.js.map → run-trace-view-DLY3Mt5m.js.map} +1 -1
  166. package/dist/shell-source-maps/assets/{runner-install-field-CKP8E9ZO.js.map → runner-install-field-Iwp4UP6o.js.map} +1 -1
  167. package/dist/shell-source-maps/assets/{runtime-update-DGbf2Nmm.js.map → runtime-update-DKcAQek2.js.map} +1 -1
  168. package/dist/shell-source-maps/assets/{sheet-source-cKJfUaud.js.map → sheet-source-DxVQhlKF.js.map} +1 -1
  169. package/dist/shell-source-maps/assets/{sign-in-policy-page-Bty4Ih1x.js.map → sign-in-policy-page-E1eBhmUM.js.map} +1 -1
  170. package/dist/shell-source-maps/assets/{start-block-queries-x-gNbPt1.js.map → start-block-queries-Bu7xMabd.js.map} +1 -1
  171. package/dist/shell-source-maps/assets/{step-catalog-CCAXc8kn.js.map → step-catalog-BPk6WuYH.js.map} +1 -1
  172. package/dist/shell-source-maps/assets/{step-panel-jmfh86YA.js.map → step-panel-BXHWAw8x.js.map} +1 -1
  173. package/dist/shell-source-maps/assets/{timeline-display-CtxOHPoJ.js.map → timeline-display-CJHQiDm9.js.map} +1 -1
  174. package/dist/shell-source-maps/assets/{trash-CFCBxAWq.js.map → trash-MHAT5Hf3.js.map} +1 -1
  175. package/dist/shell-source-maps/assets/{update-set-BYNQUWVp.js.map → update-set-B0D_tNDz.js.map} +1 -1
  176. package/dist/shell-source-maps/assets/{use-calendar-move-BytgRG51.js.map → use-calendar-move-O_48Gqvs.js.map} +1 -1
  177. package/dist/shell-source-maps/assets/{use-display-rows-DGw9J73C.js.map → use-display-rows-vjthlkqo.js.map} +1 -1
  178. package/dist/shell-source-maps/assets/{use-my-invitations-BcMFAcXl.js.map → use-my-invitations-DDPuugTE.js.map} +1 -1
  179. package/dist/shell-source-maps/assets/{use-paged-search-CKcKKO6y.js.map → use-paged-search-DRj8498k.js.map} +1 -1
  180. package/dist/shell-source-maps/assets/{use-run-trace-BRwbwZcf.js.map → use-run-trace-CWGAibgF.js.map} +1 -1
  181. package/dist/shell-source-maps/assets/{use-workflow-page-DsD276W-.js.map → use-workflow-page-C9ZEXX5R.js.map} +1 -1
  182. package/dist/shell-source-maps/assets/{use-workflow-types-Bn24Chp-.js.map → use-workflow-types-DDh28X2_.js.map} +1 -1
  183. package/dist/shell-source-maps/assets/{workflow-canvas-BKd_Yd0v.js.map → workflow-canvas-n_YJtaOh.js.map} +1 -1
  184. package/dist/shell-source-maps/assets/{workflow-field-DyBaV6m5.js.map → workflow-field-CpkY17Cc.js.map} +1 -1
  185. package/dist/shell-source-maps/assets/{workflow-graph-editor-B8RJ52_E.js.map → workflow-graph-editor-V-ZGHSrC.js.map} +1 -1
  186. package/dist/shell-source-maps/assets/{workflow-run-field-CzluYhjs.js.map → workflow-run-field-CoUJGVdX.js.map} +1 -1
  187. package/dist/shell-source-maps/assets/{workflow-status-field-_umgNjK4.js.map → workflow-status-field-nmrhtSls.js.map} +1 -1
  188. package/dist/shell-source-maps/assets/{workflow-workbench-CqOI36Oy.js.map → workflow-workbench-DvzNEdn3.js.map} +1 -1
  189. package/dist/status/messages.d.ts +2 -2
  190. package/dist/users/messages.d.ts +2 -2
  191. package/package.json +5 -5
  192. package/dist/shell-source-maps/assets/app-D3BCcbgE.js.map +0 -1
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ga as r,Gs as i,Ic as a,Jn as o,Kl as s,Kr as c,Ks as l,Pa as u,Qr as d,Rr as f,Vc as p,Wl as m,Xc as h,Yc as g,Yn as _,ac as v,al as y,ba as b,cl as x,fl as S,gi as C,ic as w,ja as T,ls as E,mr as D,ns as O,on as k,sc as A,vn as j,xa as M}from"./app-D3BCcbgE.js";import{h as N,o as P}from"./vendor-t7Q7QbPu.js";import{Q as F}from"./embedded-list-6lQyJozS.js";import{n as I}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import{a as L,i as R,n as z,o as ee,r as B,s as V,t as H}from"./messages-Ce8dRRRN.js";var U={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};U.node;var W=p(U),G={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};G.node;var K=p(G),q=e(t(),1),J=h(`app/delete`),Y=m(),X=({blockingPlural:e,noun:t})=>J(`stillPointAt`,{plural:e,noun:t}),Z=({blockedBy:e,resources:t,views:n,noun:r,key:i})=>{let{resource:a,field:o}=e;if(!t[a])return;let c=n[a]?.names?.plural??x(a),l=X({blockingPlural:c,noun:r});if(!o||i===void 0)return{text:l};let u={kind:`list`,resource:a,filter:s(Y.eq(o,i))};return{text:l,link:{label:J(`show`,{plural:c}),to:u}}},Q=e(n(),1),te=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,Q.jsx)(v,{title:J(`confirmTitle`,{title:e}),description:J(`confirmDescription`,{noun:t,title:e}),onClose:i,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{onClick:i,children:J(`cancel`)}),(0,Q.jsx)(A,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:r,children:J(`delete`)})]})}),ne=({title:e,changes:t,busy:n,onReview:r,onDeleteAnyway:i,onCancel:a})=>(0,Q.jsx)(v,{title:J(`changedTitle`,{title:e}),description:J(`changedDescription`),onClose:a,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{onClick:r,children:J(`reviewChanges`)}),(0,Q.jsx)(A,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:J(`deleteAnyway`)})]}),children:t.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noVisibleChanges`)}):(0,Q.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),$=e=>{if(e.stage===`confirm`)return(0,Q.jsx)(v,{title:J(`bulkConfirmTitle`,{count:e.count,noun:e.noun,plural:e.plural}),description:J(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{onClick:e.onCancel,children:J(`cancel`)}),(0,Q.jsx)(A,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:J(`deleteCount`,{count:e.count})})]})});if(e.stage===`running`)return(0,Q.jsx)(v,{title:J(`deleting`),description:J(`progress`,{done:e.done,total:e.total}),onClose:()=>void 0,actions:(0,Q.jsx)(A,{loading:!0,disabled:!0,children:J(`working`)})});let t=e.total-e.failures.length;return(0,Q.jsx)(v,{title:e.failures.length===0?J(`deleted`,{count:t}):J(`deletedOf`,{count:t,total:e.total}),description:e.failures.length===0?void 0:J(`kept`,{count:e.failures.length}),onClose:e.onClose,actions:(0,Q.jsx)(A,{variant:`primary`,onClick:e.onClose,children:J(`done`)}),children:e.failures.length>0&&(0,Q.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,Q.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},re=new Set([`updated_at`,`updatedAt`]),ie=(e,t,n,r)=>Object.values(e.fields).flatMap(e=>{if(re.has(e.name)||JSON.stringify(n[e.name]??null)===JSON.stringify(r[e.name]??null))return[];let i=t?.fields[e.name];return[{field:e.name,label:i?.label??x(e.name),before:C(e,n[e.name],i),after:C(e,r[e.name],i)}]}),ae=4,oe=({model:e,view:t,onDeleted:n,onReview:r,restore:a})=>{let o=E(),s=N(),c=u(),[d,p]=(0,q.useState)(),[m,h]=(0,q.useState)(!1),g=t?.names?.singular??x(e.name),_=t?.names?.plural??x(e.name),{resources:v,views:y}=O(),{href:b,open:S}=f(),C=(t,n)=>t.blockedBy&&Z({blockedBy:t.blockedBy,resources:v,views:y,noun:g,...e.primaryKey.length===1&&{key:n.key}}),w=()=>{for(let t of[`page`,`list`,`first-page`,`map`])s.invalidateQueries({queryKey:[t,e.name]});for(let t of[`facets`,`series`,`aggregate`,`histogram`,`count`])s.invalidateQueries({queryKey:[t,e.name]})},T=async(t,n)=>{let r=n??(await o.get(e.name,t.key)).etag;try{await o.remove(e.name,t.key,{etag:r})}catch(e){if(!(e instanceof i))throw e;return e}},D=t=>{w(),p(void 0),n?.(t),c.show({state:`success`,title:J(`deletedToast`,{title:t.title}),...e.softDelete&&a&&{action:{label:J(`undo`),onClick:()=>{a(t).then(()=>{w(),c.show({state:`success`,title:J(`restored`,{title:t.title})})},e=>{if(!l(e))throw e;w(),c.show({state:e.status===409?`success`:`error`,title:e.status===409?J(`alreadyBack`,{title:t.title}):J(`couldNotRestore`,{title:t.title}),description:e.status===409?void 0:e.message})})}}}})},k=async(n,r)=>{h(!0);try{if(!await T(n,r))return D(n);let i=(await o.get(e.name,n.key)).record;p({kind:`conflict`,target:n,fresh:i,changes:ie(e,t,n.snapshot,i)})}catch(e){if(!l(e))throw e;p(void 0);let t=C(e,n);c.show({state:`error`,title:J(`couldNotDelete`,{title:n.title}),description:t?.text??e.message,...t?.link&&{action:{label:t.link.label,href:b(t.link.to),onNavigate:S}}})}finally{h(!1)}},A=async e=>{try{return await T(e,e.etag)?{title:e.title,message:J(`changedSinceLoaded`)}:void 0}catch(t){if(!l(t))throw t;return{title:e.title,message:C(t,e)?.text??t.message}}},j=async e=>{let t=[],n=[],r=0;p({kind:`bulk-running`,done:r,total:e.length});let i=[...e];return await Promise.all(Array.from({length:Math.min(ae,e.length)},async()=>{for(let a=i.shift();a;a=i.shift()){let i=await A(a);i&&(t.push(i),n.push(a)),r+=1,p({kind:`bulk-running`,done:r,total:e.length})}})),w(),p({kind:`bulk-done`,total:e.length,failures:t}),n},M=()=>p(void 0);return{dialogs:d&&(0,Q.jsxs)(Q.Fragment,{children:[d.kind===`confirm`&&(0,Q.jsx)(te,{title:d.target.title,noun:g,busy:m,onCancel:M,onConfirm:()=>void k(d.target,d.target.etag)}),d.kind===`conflict`&&(0,Q.jsx)(ne,{title:d.target.title,changes:d.changes,busy:m,onCancel:M,onReview:()=>{M(),r?.(d.target,d.fresh)},onDeleteAnyway:()=>void k(d.target,`*`)}),d.kind===`bulk-confirm`&&(0,Q.jsx)($,{stage:`confirm`,count:d.targets.length,noun:g,plural:_,onCancel:()=>{M(),d.settle(d.targets)},onConfirm:()=>d.settle(j(d.targets))}),d.kind===`bulk-running`&&(0,Q.jsx)($,{stage:`running`,done:d.done,total:d.total}),d.kind===`bulk-done`&&(0,Q.jsx)($,{stage:`done`,total:d.total,failures:d.failures,onClose:M})]}),start:t=>e.softDelete?k(t,t.etag):p({kind:`confirm`,target:t}),startBulk:e=>new Promise(t=>p({kind:`bulk-confirm`,targets:e,settle:t}))}},se=e=>{let t=E();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},ce=(e,t,n)=>({order:r,index:i})=>{let a=t=>r.findIndex(n=>S(M(e,n))===t),o=t.after.find(e=>a(e.key)>i);if(o)return H(`dependsOn`,{record:n,other:o.title});let s=t.before.find(e=>a(e.key)!==-1&&a(e.key)<i);return s?H(`dependsOn`,{record:s.title,other:n}):void 0},le=(e,t,n,r)=>{let i=e[t],a;for(let o=n;o<e.length;o++){let n=r({record:i,order:I(e,t,o),index:o});if(n===void 0)return{to:o,...a!==void 0&&{reason:a}};a??=n}return{to:t,reason:a}},ue=({model:e,view:t,field:n,filter:r,fields:i,rule:a})=>{let s=E(),l=u(),d=j(),{resources:f,views:p}=O(),m=`${n} asc`,h=P({queryKey:[...g.list(e.name,r,m,500,`hand-order`),i.join(`,`)],queryFn:async()=>{let t=o(f,p,e,i),n=[],a=``;do{let o=await s.search(e.name,{filter:r||void 0,orderBy:m,pageSize:500,labels:t,...a&&{pageToken:a}});n.push(..._(f,e,i,o.items,o.labels).map((t,n)=>({...t,id:b(e,o.items[n])}))),a=o.nextPageToken}while(a);return n}}),[v,x]=(0,q.useState)(),S=(0,q.useRef)(void 0),C=(0,q.useRef)([]),w=(0,q.useRef)(void 0),T=(0,q.useRef)(Promise.resolve()),D=(0,q.useRef)(0),k=(0,q.useRef)(void 0),A=async()=>{let t=S.current,r=C.current;if(C.current=[],!t||r.length===0)return;let i=await s.batchWrite(r),a=new Map(i.results.flatMap(e=>e.op===`move`?e.records:[]).map(t=>[b(e,t.record),t])),o=z(i.results,t=>b(e,t)),c=L(e,[...a].map(([e,t])=>({...t,before:{[n]:o.get(e)}})),[n]);k.current!==void 0&&l.dismiss(k.current),k.current=l.show({state:`success`,title:V(`orderChanged`),action:{label:V(`undo`),onClick:()=>W(c)}}),S.current&&=S.current.map(e=>{let t=a.get(e.id);return t?{...e,[n]:t.record[n],etag:t.etag}:e})},M=(e,t)=>n=>{S.current=void 0,C.current=[],x(void 0),l.show(ee(n,e,{place:`list`,title:t?w.current:void 0}))},N=async()=>{--D.current,!(D.current>0)&&(await d(e.name),!(D.current>0)&&(S.current=void 0,x(void 0)))},F=(n,r)=>{let i=S.current??h.data;if(!i||n===r)return;if(!e.position?.after)return H(i,n,r,a);let o=c(e,i[n]).record,l=i[n].id;R(s,e,t,o).then(n=>{let i=S.current??h.data,s=ce(e,n,y(e,t,o,l));H(i,i.findIndex(e=>e.id===l),r,e=>s(e)??a?.(e))},M(V(`couldNotChange`),!1))},H=(i,a,o,s)=>{if(a===-1||a===o)return;let l=s?U(i,a,o,s):o;a!==l&&(S.current=I(i,a,l),C.current=[...C.current,B(e,n,r,S.current,l)],x(S.current),D.current+=1,w.current=y(e,t,c(e,i[a]).record,i[a].id),T.current=T.current.then(A).catch(M(V(`couldNotChange`),!0)).then(N))},U=(t,n,r,i)=>{let a=le(t.map(t=>c(e,t).record),n,r,i);return a.reason!==void 0&&l.show({state:`warning`,title:a.to===n?V(`notMoved`):V(`movedToPlace`,{place:a.to+1}),description:a.reason}),a.to},W=e=>{k.current!==void 0&&l.dismiss(k.current),k.current=void 0,D.current+=1,T.current=T.current.then(async()=>{await s.batchWrite(e),S.current=void 0,C.current=[],x(void 0)}).catch(M(V(`couldNotUndo`),!1)).then(N)};return{rows:v??h.data,loading:h.isPending,error:h.error,move:F}},de=({model:e,view:t,field:n,filter:i,columns:a,sort:o})=>{let{resources:s,views:c}=O(),{fields:l,dropRules:u}=T(),{go:p,href:m}=f(),h=o!==void 0,g=(0,q.useMemo)(()=>k(e,t,a,{resources:s,views:c,fieldTypes:l}).map(e=>h?e:{...e,sortable:!1}),[e,t,a.join(`,`),s,c,l,h]),_=(0,q.useMemo)(()=>d(e,t,g.map(e=>e.id)),[e,t,g]),v=t?.list?.drag?.rule,b=v===void 0?void 0:u?.[v],x=ue({model:e,view:t,field:n,filter:i,fields:_,...b&&{rule:b}}),S=x.rows,C=(0,q.useMemo)(()=>S&&{total:S.length,rowAt:e=>S[e]},[S]);if(v!==void 0&&!b)return(0,Q.jsx)(r,{children:V.rich(`noRule`,{rule:v})});if(x.loading)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Q.jsx)(w,{className:`h-4 w-full`},t))});if(x.error)return(0,Q.jsx)(D,{title:V(`couldNotLoad`),error:x.error});if(!C||C.total===0)return(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:V(`nothingYet`)});let E=t=>p({kind:`record`,resource:e.name,key:M(e,t)});return(0,Q.jsx)(F,{fit:!0,scroll:`parent`,columns:g,source:C,latencyMs:0,onOpenRow:E,rowLink:t=>({href:m({kind:`record`,resource:e.name,key:M(e,t)}),onFollow:()=>E(t)}),...o&&{sort:o.value,onSortChange:o.onChange},rowNumbers:!1,reorder:{label:n=>y(e,t,n,n.id),onMove:x.move}})},fe=({sorting:e,onChange:t,size:n,iconOnly:r=!1})=>{let i=V(e?`done`:`reorder`);return(0,Q.jsxs)(A,{size:n,variant:e?`primary`:`secondary`,onClick:()=>t(!e),...r&&{"aria-label":i,title:i},children:[e?(0,Q.jsx)(a,{className:`size-3.5`}):(0,Q.jsx)(W,{className:`size-3.5`}),!r&&i]})};export{K as a,oe as i,de as n,se as r,fe as t};
2
- //# debugId=3cc96bfc-27bd-4ae0-8b3a-ec7790cc69e8
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ga as r,Gs as i,Ic as a,Jn as o,Kl as s,Kr as c,Ks as l,Pa as u,Qr as d,Rr as f,Vc as p,Wl as m,Xc as h,Yc as g,Yn as _,ac as v,al as y,ba as b,cl as x,fl as S,gi as C,ic as w,ja as T,ls as E,mr as D,ns as O,on as k,sc as A,vn as j,xa as M}from"./app-B94YfKGx.js";import{h as N,o as P}from"./vendor-t7Q7QbPu.js";import{Q as F}from"./embedded-list-OJQKeuBN.js";import{n as I}from"./lib-dnd-kit-sortable-CNDSKqCD.js";import{a as L,i as R,n as z,o as ee,r as B,s as V,t as H}from"./messages-vzi5T1Xo.js";var U={name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]};U.node;var W=p(U),G={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};G.node;var K=p(G),q=e(t(),1),J=h(`app/delete`),Y=m(),X=({blockingPlural:e,noun:t})=>J(`stillPointAt`,{plural:e,noun:t}),Z=({blockedBy:e,resources:t,views:n,noun:r,key:i})=>{let{resource:a,field:o}=e;if(!t[a])return;let c=n[a]?.names?.plural??x(a),l=X({blockingPlural:c,noun:r});if(!o||i===void 0)return{text:l};let u={kind:`list`,resource:a,filter:s(Y.eq(o,i))};return{text:l,link:{label:J(`show`,{plural:c}),to:u}}},Q=e(n(),1),te=({title:e,noun:t,busy:n,onConfirm:r,onCancel:i})=>(0,Q.jsx)(v,{title:J(`confirmTitle`,{title:e}),description:J(`confirmDescription`,{noun:t,title:e}),onClose:i,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{onClick:i,children:J(`cancel`)}),(0,Q.jsx)(A,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:r,children:J(`delete`)})]})}),ne=({title:e,changes:t,busy:n,onReview:r,onDeleteAnyway:i,onCancel:a})=>(0,Q.jsx)(v,{title:J(`changedTitle`,{title:e}),description:J(`changedDescription`),onClose:a,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{onClick:r,children:J(`reviewChanges`)}),(0,Q.jsx)(A,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,loading:n,onClick:i,children:J(`deleteAnyway`)})]}),children:t.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:J(`noVisibleChanges`)}):(0,Q.jsx)(`ul`,{className:`divide-y rounded-md border`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`grid grid-cols-[96px_1fr] gap-3 px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e.after})]})]},e.field))})}),$=e=>{if(e.stage===`confirm`)return(0,Q.jsx)(v,{title:J(`bulkConfirmTitle`,{count:e.count,noun:e.noun,plural:e.plural}),description:J(`bulkConfirmDescription`),onClose:e.onCancel,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{onClick:e.onCancel,children:J(`cancel`)}),(0,Q.jsx)(A,{variant:`primary`,className:`bg-danger hover:bg-danger/90`,onClick:e.onConfirm,children:J(`deleteCount`,{count:e.count})})]})});if(e.stage===`running`)return(0,Q.jsx)(v,{title:J(`deleting`),description:J(`progress`,{done:e.done,total:e.total}),onClose:()=>void 0,actions:(0,Q.jsx)(A,{loading:!0,disabled:!0,children:J(`working`)})});let t=e.total-e.failures.length;return(0,Q.jsx)(v,{title:e.failures.length===0?J(`deleted`,{count:t}):J(`deletedOf`,{count:t,total:e.total}),description:e.failures.length===0?void 0:J(`kept`,{count:e.failures.length}),onClose:e.onClose,actions:(0,Q.jsx)(A,{variant:`primary`,onClick:e.onClose,children:J(`done`)}),children:e.failures.length>0&&(0,Q.jsx)(`ul`,{className:`max-h-48 divide-y overflow-y-auto rounded-md border`,children:e.failures.map(e=>(0,Q.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-danger-text`,children:e.message})]},e.title))})})},re=new Set([`updated_at`,`updatedAt`]),ie=(e,t,n,r)=>Object.values(e.fields).flatMap(e=>{if(re.has(e.name)||JSON.stringify(n[e.name]??null)===JSON.stringify(r[e.name]??null))return[];let i=t?.fields[e.name];return[{field:e.name,label:i?.label??x(e.name),before:C(e,n[e.name],i),after:C(e,r[e.name],i)}]}),ae=4,oe=({model:e,view:t,onDeleted:n,onReview:r,restore:a})=>{let o=E(),s=N(),c=u(),[d,p]=(0,q.useState)(),[m,h]=(0,q.useState)(!1),g=t?.names?.singular??x(e.name),_=t?.names?.plural??x(e.name),{resources:v,views:y}=O(),{href:b,open:S}=f(),C=(t,n)=>t.blockedBy&&Z({blockedBy:t.blockedBy,resources:v,views:y,noun:g,...e.primaryKey.length===1&&{key:n.key}}),w=()=>{for(let t of[`page`,`list`,`first-page`,`map`])s.invalidateQueries({queryKey:[t,e.name]});for(let t of[`facets`,`series`,`aggregate`,`histogram`,`count`])s.invalidateQueries({queryKey:[t,e.name]})},T=async(t,n)=>{let r=n??(await o.get(e.name,t.key)).etag;try{await o.remove(e.name,t.key,{etag:r})}catch(e){if(!(e instanceof i))throw e;return e}},D=t=>{w(),p(void 0),n?.(t),c.show({state:`success`,title:J(`deletedToast`,{title:t.title}),...e.softDelete&&a&&{action:{label:J(`undo`),onClick:()=>{a(t).then(()=>{w(),c.show({state:`success`,title:J(`restored`,{title:t.title})})},e=>{if(!l(e))throw e;w(),c.show({state:e.status===409?`success`:`error`,title:e.status===409?J(`alreadyBack`,{title:t.title}):J(`couldNotRestore`,{title:t.title}),description:e.status===409?void 0:e.message})})}}}})},k=async(n,r)=>{h(!0);try{if(!await T(n,r))return D(n);let i=(await o.get(e.name,n.key)).record;p({kind:`conflict`,target:n,fresh:i,changes:ie(e,t,n.snapshot,i)})}catch(e){if(!l(e))throw e;p(void 0);let t=C(e,n);c.show({state:`error`,title:J(`couldNotDelete`,{title:n.title}),description:t?.text??e.message,...t?.link&&{action:{label:t.link.label,href:b(t.link.to),onNavigate:S}}})}finally{h(!1)}},A=async e=>{try{return await T(e,e.etag)?{title:e.title,message:J(`changedSinceLoaded`)}:void 0}catch(t){if(!l(t))throw t;return{title:e.title,message:C(t,e)?.text??t.message}}},j=async e=>{let t=[],n=[],r=0;p({kind:`bulk-running`,done:r,total:e.length});let i=[...e];return await Promise.all(Array.from({length:Math.min(ae,e.length)},async()=>{for(let a=i.shift();a;a=i.shift()){let i=await A(a);i&&(t.push(i),n.push(a)),r+=1,p({kind:`bulk-running`,done:r,total:e.length})}})),w(),p({kind:`bulk-done`,total:e.length,failures:t}),n},M=()=>p(void 0);return{dialogs:d&&(0,Q.jsxs)(Q.Fragment,{children:[d.kind===`confirm`&&(0,Q.jsx)(te,{title:d.target.title,noun:g,busy:m,onCancel:M,onConfirm:()=>void k(d.target,d.target.etag)}),d.kind===`conflict`&&(0,Q.jsx)(ne,{title:d.target.title,changes:d.changes,busy:m,onCancel:M,onReview:()=>{M(),r?.(d.target,d.fresh)},onDeleteAnyway:()=>void k(d.target,`*`)}),d.kind===`bulk-confirm`&&(0,Q.jsx)($,{stage:`confirm`,count:d.targets.length,noun:g,plural:_,onCancel:()=>{M(),d.settle(d.targets)},onConfirm:()=>d.settle(j(d.targets))}),d.kind===`bulk-running`&&(0,Q.jsx)($,{stage:`running`,done:d.done,total:d.total}),d.kind===`bulk-done`&&(0,Q.jsx)($,{stage:`done`,total:d.total,failures:d.failures,onClose:M})]}),start:t=>e.softDelete?k(t,t.etag):p({kind:`confirm`,target:t}),startBulk:e=>new Promise(t=>p({kind:`bulk-confirm`,targets:e,settle:t}))}},se=e=>{let t=E();return e.softDelete?async n=>void await t.undelete(e.name,n.key):void 0},ce=(e,t,n)=>({order:r,index:i})=>{let a=t=>r.findIndex(n=>S(M(e,n))===t),o=t.after.find(e=>a(e.key)>i);if(o)return H(`dependsOn`,{record:n,other:o.title});let s=t.before.find(e=>a(e.key)!==-1&&a(e.key)<i);return s?H(`dependsOn`,{record:s.title,other:n}):void 0},le=(e,t,n,r)=>{let i=e[t],a;for(let o=n;o<e.length;o++){let n=r({record:i,order:I(e,t,o),index:o});if(n===void 0)return{to:o,...a!==void 0&&{reason:a}};a??=n}return{to:t,reason:a}},ue=({model:e,view:t,field:n,filter:r,fields:i,rule:a})=>{let s=E(),l=u(),d=j(),{resources:f,views:p}=O(),m=`${n} asc`,h=P({queryKey:[...g.list(e.name,r,m,500,`hand-order`),i.join(`,`)],queryFn:async()=>{let t=o(f,p,e,i),n=[],a=``;do{let o=await s.search(e.name,{filter:r||void 0,orderBy:m,pageSize:500,labels:t,...a&&{pageToken:a}});n.push(..._(f,e,i,o.items,o.labels).map((t,n)=>({...t,id:b(e,o.items[n])}))),a=o.nextPageToken}while(a);return n}}),[v,x]=(0,q.useState)(),S=(0,q.useRef)(void 0),C=(0,q.useRef)([]),w=(0,q.useRef)(void 0),T=(0,q.useRef)(Promise.resolve()),D=(0,q.useRef)(0),k=(0,q.useRef)(void 0),A=async()=>{let t=S.current,r=C.current;if(C.current=[],!t||r.length===0)return;let i=await s.batchWrite(r),a=new Map(i.results.flatMap(e=>e.op===`move`?e.records:[]).map(t=>[b(e,t.record),t])),o=z(i.results,t=>b(e,t)),c=L(e,[...a].map(([e,t])=>({...t,before:{[n]:o.get(e)}})),[n]);k.current!==void 0&&l.dismiss(k.current),k.current=l.show({state:`success`,title:V(`orderChanged`),action:{label:V(`undo`),onClick:()=>W(c)}}),S.current&&=S.current.map(e=>{let t=a.get(e.id);return t?{...e,[n]:t.record[n],etag:t.etag}:e})},M=(e,t)=>n=>{S.current=void 0,C.current=[],x(void 0),l.show(ee(n,e,{place:`list`,title:t?w.current:void 0}))},N=async()=>{--D.current,!(D.current>0)&&(await d(e.name),!(D.current>0)&&(S.current=void 0,x(void 0)))},F=(n,r)=>{let i=S.current??h.data;if(!i||n===r)return;if(!e.position?.after)return H(i,n,r,a);let o=c(e,i[n]).record,l=i[n].id;R(s,e,t,o).then(n=>{let i=S.current??h.data,s=ce(e,n,y(e,t,o,l));H(i,i.findIndex(e=>e.id===l),r,e=>s(e)??a?.(e))},M(V(`couldNotChange`),!1))},H=(i,a,o,s)=>{if(a===-1||a===o)return;let l=s?U(i,a,o,s):o;a!==l&&(S.current=I(i,a,l),C.current=[...C.current,B(e,n,r,S.current,l)],x(S.current),D.current+=1,w.current=y(e,t,c(e,i[a]).record,i[a].id),T.current=T.current.then(A).catch(M(V(`couldNotChange`),!0)).then(N))},U=(t,n,r,i)=>{let a=le(t.map(t=>c(e,t).record),n,r,i);return a.reason!==void 0&&l.show({state:`warning`,title:a.to===n?V(`notMoved`):V(`movedToPlace`,{place:a.to+1}),description:a.reason}),a.to},W=e=>{k.current!==void 0&&l.dismiss(k.current),k.current=void 0,D.current+=1,T.current=T.current.then(async()=>{await s.batchWrite(e),S.current=void 0,C.current=[],x(void 0)}).catch(M(V(`couldNotUndo`),!1)).then(N)};return{rows:v??h.data,loading:h.isPending,error:h.error,move:F}},de=({model:e,view:t,field:n,filter:i,columns:a,sort:o})=>{let{resources:s,views:c}=O(),{fields:l,dropRules:u}=T(),{go:p,href:m}=f(),h=o!==void 0,g=(0,q.useMemo)(()=>k(e,t,a,{resources:s,views:c,fieldTypes:l}).map(e=>h?e:{...e,sortable:!1}),[e,t,a.join(`,`),s,c,l,h]),_=(0,q.useMemo)(()=>d(e,t,g.map(e=>e.id)),[e,t,g]),v=t?.list?.drag?.rule,b=v===void 0?void 0:u?.[v],x=ue({model:e,view:t,field:n,filter:i,fields:_,...b&&{rule:b}}),S=x.rows,C=(0,q.useMemo)(()=>S&&{total:S.length,rowAt:e=>S[e]},[S]);if(v!==void 0&&!b)return(0,Q.jsx)(r,{children:V.rich(`noRule`,{rule:v})});if(x.loading)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:3},(e,t)=>(0,Q.jsx)(w,{className:`h-4 w-full`},t))});if(x.error)return(0,Q.jsx)(D,{title:V(`couldNotLoad`),error:x.error});if(!C||C.total===0)return(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:V(`nothingYet`)});let E=t=>p({kind:`record`,resource:e.name,key:M(e,t)});return(0,Q.jsx)(F,{fit:!0,scroll:`parent`,columns:g,source:C,latencyMs:0,onOpenRow:E,rowLink:t=>({href:m({kind:`record`,resource:e.name,key:M(e,t)}),onFollow:()=>E(t)}),...o&&{sort:o.value,onSortChange:o.onChange},rowNumbers:!1,reorder:{label:n=>y(e,t,n,n.id),onMove:x.move}})},fe=({sorting:e,onChange:t,size:n,iconOnly:r=!1})=>{let i=V(e?`done`:`reorder`);return(0,Q.jsxs)(A,{size:n,variant:e?`primary`:`secondary`,onClick:()=>t(!e),...r&&{"aria-label":i,title:i},children:[e?(0,Q.jsx)(a,{className:`size-3.5`}):(0,Q.jsx)(W,{className:`size-3.5`}),!r&&i]})};export{K as a,oe as i,de as n,se as r,fe as t};
2
+ //# debugId=61873861-4ceb-49e4-a149-f0aac5bd4eb9
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{ic as r,mr as i}from"./app-D3BCcbgE.js";import{t as a}from"./workflow-canvas-BKd_Yd0v.js";import{a as o,i as s,n as c}from"./step-panel-jmfh86YA.js";import{t as l}from"./use-run-trace-BRwbwZcf.js";import{t as u}from"./use-workflow-types-Bn24Chp-.js";import{n as d,t as f}from"./graph-frame-PVfWqgbJ.js";var p=e(t(),1),m=e(n(),1),h=new Map,g=({trace:e,types:t,notice:n,idle:l})=>{let{definition:u,steps:g,going:_,place:v}=e,y=(0,p.useMemo)(()=>v&&o(g,{inProgress:_,...v}),[v,g,_]),[b,x]=(0,p.useState)();if(e.error)return(0,m.jsx)(i,{error:e.error,title:s(`loadFailed`)});if(!e.run||!e.id||!u||!y)return(0,m.jsx)(r,{className:`h-[28rem] w-full max-sm:h-[22rem]`});let S=[...y].filter(([,e])=>e.status===`failed`).map(([e])=>e).sort((e,t)=>t.split(`/`).length-e.split(`/`).length)[0],C=b===void 0?S:b??void 0,w={...e.run,id:e.id,created_at:String(e.run.created_at)};return(0,m.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!_&&g.length===0&&(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`noTrace`)}),(0,m.jsx)(f,{canvas:(0,m.jsx)(a,{definition:u,problems:h,selected:C,onSelect:e=>x(e??null),traces:y,...t&&{types:t}}),panel:(0,m.jsxs)(m.Fragment,{children:[n,C===void 0?l??(0,m.jsx)(d,{children:s(`pickNode`)}):(0,m.jsx)(c,{definition:u,run:w,selected:C,...t&&{types:t}})]})})]})},_=({runId:e})=>{let t=l(e),n=u().data;return(0,m.jsx)(g,{trace:t,...n&&{types:n}})};export{_ as RunTrace};
2
- //# debugId=4fbcfc37-2a89-47ba-bff0-8be09764ec1d
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{ic as r,mr as i}from"./app-B94YfKGx.js";import{t as a}from"./workflow-canvas-n_YJtaOh.js";import{a as o,i as s,n as c}from"./step-panel-BXHWAw8x.js";import{t as l}from"./use-run-trace-CWGAibgF.js";import{t as u}from"./use-workflow-types-DDh28X2_.js";import{n as d,t as f}from"./graph-frame-PVfWqgbJ.js";var p=e(t(),1),m=e(n(),1),h=new Map,g=({trace:e,types:t,notice:n,idle:l})=>{let{definition:u,steps:g,going:_,place:v}=e,y=(0,p.useMemo)(()=>v&&o(g,{inProgress:_,...v}),[v,g,_]),[b,x]=(0,p.useState)();if(e.error)return(0,m.jsx)(i,{error:e.error,title:s(`loadFailed`)});if(!e.run||!e.id||!u||!y)return(0,m.jsx)(r,{className:`h-[28rem] w-full max-sm:h-[22rem]`});let S=[...y].filter(([,e])=>e.status===`failed`).map(([e])=>e).sort((e,t)=>t.split(`/`).length-e.split(`/`).length)[0],C=b===void 0?S:b??void 0,w={...e.run,id:e.id,created_at:String(e.run.created_at)};return(0,m.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!_&&g.length===0&&(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`noTrace`)}),(0,m.jsx)(f,{canvas:(0,m.jsx)(a,{definition:u,problems:h,selected:C,onSelect:e=>x(e??null),traces:y,...t&&{types:t}}),panel:(0,m.jsxs)(m.Fragment,{children:[n,C===void 0?l??(0,m.jsx)(d,{children:s(`pickNode`)}):(0,m.jsx)(c,{definition:u,run:w,selected:C,...t&&{types:t}})]})})]})},_=({runId:e})=>{let t=l(e),n=u().data;return(0,m.jsx)(g,{trace:t,...n&&{types:n}})};export{_ as RunTrace};
2
+ //# debugId=cb63732d-e660-4666-8b09-bd90fdbc238a
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ws as r,Xc as i,Yi as a,ls as o,nl as s,sc as c}from"./app-D3BCcbgE.js";import{t as l}from"./copy-field-BoXXafL7.js";var u=e(t(),1),d=i(`app/field-types/runner-install`),f=e(n(),1),p=e=>e instanceof r?e.slug===`runner-registered`?d(`registered`):e.slug===`runner-revoked`?d(`revoked`):e.status===404?d(`notYours`):d(`failed`):d(`failed`),m=({value:e})=>{let t=o(),[n,r]=(0,u.useState)(),[i,s]=(0,u.useState)(!1),[m,h]=(0,u.useState)();if(e===null)return null;let g=async()=>{s(!0),h(void 0),await t.runnerRegistration(e).then(r,e=>h(p(e))),s(!1)};return(0,f.jsxs)(`div`,{className:`grid gap-2`,children:[n&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(l,{value:n.command,copyLabel:d(`copy`)}),(0,f.jsx)(`p`,{className:`text-body text-muted-foreground`,children:d(`shownOnce`,{until:a(Date.parse(n.expires_at))})})]}),m&&(0,f.jsx)(`p`,{role:`alert`,className:`text-body text-danger-text`,children:m}),(0,f.jsx)(c,{size:`sm`,variant:n?`secondary`:`primary`,className:`justify-self-start`,loading:i,onClick:()=>void g(),children:d(n?`again`:`issue`)})]})},h={of:[...s.runner_install],display:m,cell:()=>null};export{h as runnerInstallField};
2
- //# debugId=8a3fc13d-64ec-4714-b42a-adeaf4cd3549
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ws as r,Xc as i,Yi as a,ls as o,nl as s,sc as c}from"./app-B94YfKGx.js";import{t as l}from"./copy-field-DXp0fGDR.js";var u=e(t(),1),d=i(`app/field-types/runner-install`),f=e(n(),1),p=e=>e instanceof r?e.slug===`runner-registered`?d(`registered`):e.slug===`runner-revoked`?d(`revoked`):e.status===404?d(`notYours`):d(`failed`):d(`failed`),m=({value:e})=>{let t=o(),[n,r]=(0,u.useState)(),[i,s]=(0,u.useState)(!1),[m,h]=(0,u.useState)();if(e===null)return null;let g=async()=>{s(!0),h(void 0),await t.runnerRegistration(e).then(r,e=>h(p(e))),s(!1)};return(0,f.jsxs)(`div`,{className:`grid gap-2`,children:[n&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(l,{value:n.command,copyLabel:d(`copy`)}),(0,f.jsx)(`p`,{className:`text-body text-muted-foreground`,children:d(`shownOnce`,{until:a(Date.parse(n.expires_at))})})]}),m&&(0,f.jsx)(`p`,{role:`alert`,className:`text-body text-danger-text`,children:m}),(0,f.jsx)(c,{size:`sm`,variant:n?`secondary`:`primary`,className:`justify-self-start`,loading:i,onClick:()=>void g(),children:d(n?`again`:`issue`)})]})},h={of:[...s.runner_install],display:m,cell:()=>null};export{h as runnerInstallField};
2
+ //# debugId=08c29e14-3faa-4bf0-88b9-6c87b62ea814
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ks as r,Va as i,Vc as a,Ws as o,Xc as s,Yi as c,ac as l,ca as u,lc as d,qi as f,qs as p,sc as m}from"./app-D3BCcbgE.js";var h={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};h.node;var g=a(h),_=e=>typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null&&`code`in e.error&&`message`in e.error,v=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.clone().json():void 0;return _(t)?new o({type:`urn:protobase:problem:${t.error.code}`,title:e.statusText||`Request failed`,status:e.status,detail:t.error.message}):p(e)},y=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=async(r,i)=>{let a=await e.token(),o=await n(`${t}${r}`,{method:i,headers:{accept:`application/json`,...a&&{authorization:`Bearer ${a}`}}});if(!o.ok)throw await v(o);return await o.json()};return{status:()=>r(``,`GET`),update:()=>r(`/update`,`POST`)}},b=e(t(),1),x=s(`app/runtime`),S=e=>!!(e?.updateAvailable&&e.indicator),C=e=>e?5e3:18e5,w=(e,t)=>{if(!e.updateStage)return x(`updatingNow`);let n=x(e.updateStage);if(!e.updateStartedAt)return n;let r=Math.max(0,Math.floor((t-Date.parse(e.updateStartedAt))/1e3));return x(`started`,{stage:n,ago:f(r)})},T=(e,t=Date.now(),n=u())=>e.updating?w(e,t):e.nextUpdateAt?x(`nextOn`,{policy:x(e.policy),when:c(Date.parse(e.nextUpdateAt),n)}):x(e.policy),E=(e,t=u())=>{let n=c(Date.parse(e.finishedAt),t),r=x(e.outcome,{version:e.toVersion,when:n});return e.message?`${r}: ${e.message}`:`${r}.`},D=e=>r(e)&&e.status<500&&e.problem.detail?e.problem.detail:r(e)&&e.status===409?x(`alreadyLatest`):r(e)&&e.status===403?x(`onlyAdmin`):x(`couldNotStart`),O=e(n(),1),k=({label:e,value:t})=>(0,O.jsxs)(`div`,{className:`flex justify-between gap-4 py-1`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,O.jsx)(`span`,{className:`font-medium tabular-nums`,children:t})]}),A=({status:e,requesting:t,error:n,checkError:r,onUpdate:i,onClose:a})=>{let o=e.updating?void 0:e.lastUpdate;return(0,O.jsxs)(l,{title:x(`runtimeUpdate`),description:e.updating?(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,O.jsx)(d,{className:`size-3.5`}),T(e)]}):T(e),onClose:a,actions:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(m,{onClick:a,children:x(`close`)}),(0,O.jsx)(m,{variant:`primary`,loading:t,disabled:e.updating||!e.updateAvailable,onClick:i,children:e.updating?x(`updating`):x(`updateNow`)})]}),children:[(0,O.jsx)(k,{label:x(`currentVersion`),value:e.version}),(0,O.jsx)(k,{label:x(`latestVersion`),value:e.latest}),o&&(0,O.jsx)(`p`,{className:o.outcome===`failed`?`mt-3 text-danger-text`:`mt-3 text-muted-foreground`,children:E(o)}),n!==void 0&&(0,O.jsx)(`p`,{role:`alert`,className:`mt-3 text-danger-text`,children:D(n)}),r!==void 0&&(0,O.jsx)(`p`,{className:`mt-3 text-muted-foreground`,children:x(`checkFailed`)})]})},j=e=>{let t=i(),n=(0,b.useRef)(t);n.current=t;let r=t!==void 0;return(0,b.useMemo)(()=>r?y({url:e,token:()=>n.current}):void 0,[e,r])},M=e=>{let[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(),l=t?.updating??!1;return(0,b.useEffect)(()=>{if(!e)return;let t=!0,r=()=>e.status().then(e=>{t&&(n(e),c(void 0))},e=>t&&c(e));r();let i=setInterval(()=>void r(),C(l));return()=>{t=!1,clearInterval(i)}},[e,l]),{status:t,update:(0,b.useCallback)(async()=>{e&&(i(!0),o(void 0),await e.update().then(n,o),i(!1))},[e]),requesting:r,error:a,checkError:s}},N=({client:e})=>{let{status:t,update:n,requesting:r,error:i,checkError:a}=M(e),[o,s]=(0,b.useState)(!1);return!t||!o&&!S(t)?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(m,{size:`sm`,variant:`ghost`,"aria-label":x(`updateAvailable`),title:x(`updateAvailable`),onClick:()=>s(!0),className:`max-md:size-9 max-md:p-0`,children:[(0,O.jsx)(g,{className:`size-3.5 text-primary`}),(0,O.jsx)(`span`,{className:`max-md:sr-only`,children:x(`update`)})]}),o&&(0,O.jsx)(A,{status:t,requesting:r,error:i,checkError:a,onUpdate:()=>void n(),onClose:()=>s(!1)})]})},P=({url:e})=>(0,O.jsx)(N,{client:j(e)}),F=({url:e,client:t})=>t?(0,O.jsx)(N,{client:t}):(0,O.jsx)(P,{url:e});export{F as RuntimeUpdateButton};
2
- //# debugId=c66dfd8d-9a63-404a-8643-0af2b16f1378
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ks as r,Va as i,Vc as a,Ws as o,Xc as s,Yi as c,ac as l,ca as u,lc as d,qi as f,qs as p,sc as m}from"./app-B94YfKGx.js";var h={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};h.node;var g=a(h),_=e=>typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null&&`code`in e.error&&`message`in e.error,v=async e=>{let t=e.headers.get(`content-type`)?.includes(`json`)??!1?await e.clone().json():void 0;return _(t)?new o({type:`urn:protobase:problem:${t.error.code}`,title:e.statusText||`Request failed`,status:e.status,detail:t.error.message}):p(e)},y=e=>{let t=e.url.replace(/\/+$/,``),n=e.fetch??((e,t)=>fetch(e,t)),r=async(r,i)=>{let a=await e.token(),o=await n(`${t}${r}`,{method:i,headers:{accept:`application/json`,...a&&{authorization:`Bearer ${a}`}}});if(!o.ok)throw await v(o);return await o.json()};return{status:()=>r(``,`GET`),update:()=>r(`/update`,`POST`)}},b=e(t(),1),x=s(`app/runtime`),S=e=>!!(e?.updateAvailable&&e.indicator),C=e=>e?5e3:18e5,w=(e,t)=>{if(!e.updateStage)return x(`updatingNow`);let n=x(e.updateStage);if(!e.updateStartedAt)return n;let r=Math.max(0,Math.floor((t-Date.parse(e.updateStartedAt))/1e3));return x(`started`,{stage:n,ago:f(r)})},T=(e,t=Date.now(),n=u())=>e.updating?w(e,t):e.nextUpdateAt?x(`nextOn`,{policy:x(e.policy),when:c(Date.parse(e.nextUpdateAt),n)}):x(e.policy),E=(e,t=u())=>{let n=c(Date.parse(e.finishedAt),t),r=x(e.outcome,{version:e.toVersion,when:n});return e.message?`${r}: ${e.message}`:`${r}.`},D=e=>r(e)&&e.status<500&&e.problem.detail?e.problem.detail:r(e)&&e.status===409?x(`alreadyLatest`):r(e)&&e.status===403?x(`onlyAdmin`):x(`couldNotStart`),O=e(n(),1),k=({label:e,value:t})=>(0,O.jsxs)(`div`,{className:`flex justify-between gap-4 py-1`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,O.jsx)(`span`,{className:`font-medium tabular-nums`,children:t})]}),A=({status:e,requesting:t,error:n,checkError:r,onUpdate:i,onClose:a})=>{let o=e.updating?void 0:e.lastUpdate;return(0,O.jsxs)(l,{title:x(`runtimeUpdate`),description:e.updating?(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,O.jsx)(d,{className:`size-3.5`}),T(e)]}):T(e),onClose:a,actions:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(m,{onClick:a,children:x(`close`)}),(0,O.jsx)(m,{variant:`primary`,loading:t,disabled:e.updating||!e.updateAvailable,onClick:i,children:e.updating?x(`updating`):x(`updateNow`)})]}),children:[(0,O.jsx)(k,{label:x(`currentVersion`),value:e.version}),(0,O.jsx)(k,{label:x(`latestVersion`),value:e.latest}),o&&(0,O.jsx)(`p`,{className:o.outcome===`failed`?`mt-3 text-danger-text`:`mt-3 text-muted-foreground`,children:E(o)}),n!==void 0&&(0,O.jsx)(`p`,{role:`alert`,className:`mt-3 text-danger-text`,children:D(n)}),r!==void 0&&(0,O.jsx)(`p`,{className:`mt-3 text-muted-foreground`,children:x(`checkFailed`)})]})},j=e=>{let t=i(),n=(0,b.useRef)(t);n.current=t;let r=t!==void 0;return(0,b.useMemo)(()=>r?y({url:e,token:()=>n.current}):void 0,[e,r])},M=e=>{let[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(),l=t?.updating??!1;return(0,b.useEffect)(()=>{if(!e)return;let t=!0,r=()=>e.status().then(e=>{t&&(n(e),c(void 0))},e=>t&&c(e));r();let i=setInterval(()=>void r(),C(l));return()=>{t=!1,clearInterval(i)}},[e,l]),{status:t,update:(0,b.useCallback)(async()=>{e&&(i(!0),o(void 0),await e.update().then(n,o),i(!1))},[e]),requesting:r,error:a,checkError:s}},N=({client:e})=>{let{status:t,update:n,requesting:r,error:i,checkError:a}=M(e),[o,s]=(0,b.useState)(!1);return!t||!o&&!S(t)?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(m,{size:`sm`,variant:`ghost`,"aria-label":x(`updateAvailable`),title:x(`updateAvailable`),onClick:()=>s(!0),className:`max-md:size-9 max-md:p-0`,children:[(0,O.jsx)(g,{className:`size-3.5 text-primary`}),(0,O.jsx)(`span`,{className:`max-md:sr-only`,children:x(`update`)})]}),o&&(0,O.jsx)(A,{status:t,requesting:r,error:i,checkError:a,onUpdate:()=>void n(),onClose:()=>s(!1)})]})},P=({url:e})=>(0,O.jsx)(N,{client:j(e)}),F=({url:e,client:t})=>t?(0,O.jsx)(N,{client:t}):(0,O.jsx)(P,{url:e});export{F as RuntimeUpdateButton};
2
+ //# debugId=ca70041e-9361-4408-9d3d-b31cd1e17bcc
@@ -1 +1 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{$ as e,Aa as t,Ao as n,Ar as r,At as ee,B as te,Ba as i,Bi as a,Bt as o,Cn as s,Ct as c,Do as l,Dt as u,Et as d,Fr as f,Ft as p,G as m,Gc as h,Gi as g,Gt as _,H as v,Hi as y,Ht as b,Ir as x,Jc as S,Jt as C,K as w,Kc as T,Ki as E,Lr as D,Mo as O,Mt as k,N as A,Na as j,Nt as M,Ot as N,P,Pr as F,Pt as I,Q as L,Qt as R,R as z,Ra as B,Rn as V,Ro as H,Rr as U,Rt as W,Sr as G,St as K,Tr as q,Tt as J,U as Y,Uc as X,Ui as Z,V as Q,Va as ne,Vi as re,Vt as ie,W as ae,Wc as oe,Wi as se,X as ce,Yt as le,Zc as ue,Zt as $,_r as de,_t as fe,ac as pe,bo as me,br as he,bt as ge,cc as _e,co as ve,cs as ye,da as be,dt as xe,et as Se,fo as Ce,ft as we,go as Te,gr as Ee,gt as De,ho as Oe,hr as ke,ht as Ae,it as je,jo as Me,jr as Ne,jt as Pe,ka as Fe,ko as Ie,kr as Le,lc as Re,ls as ze,mt as Be,n as Ve,nc as He,nt as Ue,oo as We,or as Ge,ot as Ke,po as qe,pt as Je,qc as Ye,qt as Xe,r as Ze,rt as Qe,sc as $e,so as et,ss as tt,t as nt,tt as rt,us as it,ut as at,vo as ot,vt as st,wr as ct,wt as lt,xr as ut,xt as dt,yr as ft,yt as pt,z as mt,zi as ht,zt as gt}from"./app-D3BCcbgE.js";import{h as _t,o as vt}from"./vendor-t7Q7QbPu.js";export{K as ActionCard,G as ActionInputError,ye as ApiProvider,f as App,D as AppLink,Me as AppMark,we as AssistantDock,ve as AuthLayout,Oe as AvailabilityMark,$e as Button,W as CallMark,b as CallView,w as Carousel,k as ChatDivider,Pe as ChatMessage,ee as ChatThread,mt as Choices,We as CodeForm,ge as CompactTable,lt as Composer,pe as Dialog,fe as DiffView,z as Field,le as FieldBadge,dt as FieldList,Ee as FileReadError,e as FocusActions,Se as FocusNotice,je as FocusPage,rt as FocusPanel,Ue as FocusSlot,A as Form,he as HtmlFrame,Ve as InPlaceForm,l as Input,O as LogoMark,s as Markdown,d as MentionBox,J as MentionedText,te as MenuSelect,ot as MenuSurface,Ce as OtpInput,Be as PartView,o as RecordCall,_ as RecordLink,nt as RecordPicker,et as ResendCodeButton,Z as ResponsiveDialog,He as RouteLink,ce as SearchPicker,P as Section,me as Segmented,Q as Select,c as SidePanel,p as SignInPrompt,Re as Spinner,Te as StatusMark,Ae as StepList,V as Textarea,C as ToneEdge,v as allowDelayMs,_e as buttonClass,M as chatDayLabel,H as closeSidebarEvent,Fe as definePlugin,t as defineUi,st as diffStats,u as emptyDraft,ut as fileNamed,ct as isConflict,Y as isFramed,n as logoTapEvent,N as mentionedIds,h as mergeUi,pt as parseDiff,De as parsePatch,Ye as pluginApi,X as pluginsChangedEvent,S as protobaseVersion,I as sameChatDay,ue as showTextsIn,ft as siblingPage,qe as signedOutEvent,a as statusRefreshMs,T as uiFromModule,x as uiReadyEvent,ne as useApiToken,U as useAppAddress,ae as useArmedAfterFocus,xe as useAssistant,at as useAssistantClient,Je as useBackendData,ze as useClient,$ as useComponentReads,R as useComponentSelect,Ze as useCreateForm,Le as useFacets,Ie as useFieldControl,de as useFileText,Ke as useFocusPage,L as useFocusRecord,Qe as useFocusZoneFilled,m as useGuardedPress,r as useHistogram,se as useInbox,Ge as useLayoutRecord,F as useList,Xe as useListDisplay,g as useMarkNotificationsRead,ht as useMembers,tt as useMeta,re as useOwnStatus,oe as usePlugin,j as usePresence,be as usePushNotifications,vt as useQuery,_t as useQueryClient,B as useRecord,ie as useRecordCallAddress,gt as useRecordCalls,it as useResourceClient,Ne as useSeries,ke as useSiblingPage,i as useSignedInUser,y as useStatuses,E as useUnreadNotifications,q as useUpdateRecord};
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{$ as e,Aa as t,Ao as n,Ar as r,At as ee,B as te,Ba as i,Bi as a,Bt as o,Cn as s,Ct as c,Do as l,Dt as u,Et as d,Fr as f,Ft as p,G as m,Gc as h,Gi as g,Gt as _,H as v,Hi as y,Ht as b,Ir as x,Jc as S,Jt as C,K as w,Kc as T,Ki as E,Lr as D,Mo as O,Mt as k,N as A,Na as j,Nt as M,Ot as N,P,Pr as F,Pt as I,Q as L,Qt as R,R as z,Ra as B,Rn as V,Ro as H,Rr as U,Rt as W,Sr as G,St as K,Tr as q,Tt as J,U as Y,Uc as X,Ui as Z,V as Q,Va as ne,Vi as re,Vt as ie,W as ae,Wc as oe,Wi as se,X as ce,Yt as le,Zc as ue,Zt as $,_r as de,_t as fe,ac as pe,bo as me,br as he,bt as ge,cc as _e,co as ve,cs as ye,da as be,dt as xe,et as Se,fo as Ce,ft as we,go as Te,gr as Ee,gt as De,ho as Oe,hr as ke,ht as Ae,it as je,jo as Me,jr as Ne,jt as Pe,ka as Fe,ko as Ie,kr as Le,lc as Re,ls as ze,mt as Be,n as Ve,nc as He,nt as Ue,oo as We,or as Ge,ot as Ke,po as qe,pt as Je,qc as Ye,qt as Xe,r as Ze,rt as Qe,sc as $e,so as et,ss as tt,t as nt,tt as rt,us as it,ut as at,vo as ot,vt as st,wr as ct,wt as lt,xr as ut,xt as dt,yr as ft,yt as pt,z as mt,zi as ht,zt as gt}from"./app-B94YfKGx.js";import{h as _t,o as vt}from"./vendor-t7Q7QbPu.js";export{K as ActionCard,G as ActionInputError,ye as ApiProvider,f as App,D as AppLink,Me as AppMark,we as AssistantDock,ve as AuthLayout,Oe as AvailabilityMark,$e as Button,W as CallMark,b as CallView,w as Carousel,k as ChatDivider,Pe as ChatMessage,ee as ChatThread,mt as Choices,We as CodeForm,ge as CompactTable,lt as Composer,pe as Dialog,fe as DiffView,z as Field,le as FieldBadge,dt as FieldList,Ee as FileReadError,e as FocusActions,Se as FocusNotice,je as FocusPage,rt as FocusPanel,Ue as FocusSlot,A as Form,he as HtmlFrame,Ve as InPlaceForm,l as Input,O as LogoMark,s as Markdown,d as MentionBox,J as MentionedText,te as MenuSelect,ot as MenuSurface,Ce as OtpInput,Be as PartView,o as RecordCall,_ as RecordLink,nt as RecordPicker,et as ResendCodeButton,Z as ResponsiveDialog,He as RouteLink,ce as SearchPicker,P as Section,me as Segmented,Q as Select,c as SidePanel,p as SignInPrompt,Re as Spinner,Te as StatusMark,Ae as StepList,V as Textarea,C as ToneEdge,v as allowDelayMs,_e as buttonClass,M as chatDayLabel,H as closeSidebarEvent,Fe as definePlugin,t as defineUi,st as diffStats,u as emptyDraft,ut as fileNamed,ct as isConflict,Y as isFramed,n as logoTapEvent,N as mentionedIds,h as mergeUi,pt as parseDiff,De as parsePatch,Ye as pluginApi,X as pluginsChangedEvent,S as protobaseVersion,I as sameChatDay,ue as showTextsIn,ft as siblingPage,qe as signedOutEvent,a as statusRefreshMs,T as uiFromModule,x as uiReadyEvent,ne as useApiToken,U as useAppAddress,ae as useArmedAfterFocus,xe as useAssistant,at as useAssistantClient,Je as useBackendData,ze as useClient,$ as useComponentReads,R as useComponentSelect,Ze as useCreateForm,Le as useFacets,Ie as useFieldControl,de as useFileText,Ke as useFocusPage,L as useFocusRecord,Qe as useFocusZoneFilled,m as useGuardedPress,r as useHistogram,se as useInbox,Ge as useLayoutRecord,F as useList,Xe as useListDisplay,g as useMarkNotificationsRead,ht as useMembers,tt as useMeta,re as useOwnStatus,oe as usePlugin,j as usePresence,be as usePushNotifications,vt as useQuery,_t as useQueryClient,B as useRecord,ie as useRecordCallAddress,gt as useRecordCalls,it as useResourceClient,Ne as useSeries,ke as useSiblingPage,i as useSignedInUser,y as useStatuses,E as useUnreadNotifications,q as useUpdateRecord};
@@ -1,3 +1,3 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,Hc as i,Kl as a,Ks as o,Oc as s,Qc as c,Vc as l,Wl as u,cl as d,gi as f,io as p,j as m,lc as h,mr as g,sc as _,sl as v}from"./app-D3BCcbgE.js";import{c as y,d as b,l as ee,o as x,u as S}from"./list-page-Czg2Jaxx.js";var C={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};C.node;var te=l(C),w=e(t(),1),T=e(n(),1),ne=e=>/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,re=(e,t)=>{let n=[...t].sort((e,t)=>e.line-t.line).map(t=>[...e.map((e,n)=>x(t.cells[n]??null)),String(t.line),t.problems.join(`; `)]);return`${[[...e,b(`line`),b(`problems`)],...n].map(e=>e.map(ne).join(`,`)).join(`\r
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,Hc as i,Kl as a,Ks as o,Oc as s,Qc as c,Vc as l,Wl as u,cl as d,gi as f,io as p,j as m,lc as h,mr as g,sc as _,sl as v}from"./app-B94YfKGx.js";import{c as y,d as b,l as ee,o as x,u as S}from"./list-page-DImD2FRO.js";var C={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};C.node;var te=l(C),w=e(t(),1),T=e(n(),1),ne=e=>/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,re=(e,t)=>{let n=[...t].sort((e,t)=>e.line-t.line).map(t=>[...e.map((e,n)=>x(t.cells[n]??null)),String(t.line),t.problems.join(`; `)]);return`${[[...e,b(`line`),b(`problems`)],...n].map(e=>e.map(ne).join(`,`)).join(`\r
2
2
  `)}\r\n`},E=({label:e,counts:t})=>(0,T.jsx)(`dl`,{"aria-label":e,className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:t.map(([e,t])=>(0,T.jsxs)(`div`,{className:`rounded-lg border px-3 py-2`,children:[(0,T.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,T.jsx)(`dd`,{className:`text-lg font-semibold tabular-nums`,children:t.toLocaleString(r())})]},e))}),D=(e,t)=>e?.fields[t]?.label??d(t),ie=new Set([`text`,`integer`,`bigint`,`decimal`,`boolean`,`date`,`timestamp`,`uuid`,`enum`,`relation`,`currency`,`country`]),O=(e,t)=>{let n=e.relation?t[e.relation.resource]:void 0;return n?.primaryKey.length===1?n:void 0},ae=(e,t,{json:n=!1}={})=>Object.values(e.fields).filter(r=>r.readOnly||r.name===e.tenant?!1:r.type===`json`?n:ie.has(r.type)?r.type!==`relation`||O(r,t)!==void 0:!1),oe=new Set([`text`,`integer`,`bigint`,`uuid`,`date`,`currency`,`country`,`enum`]),se=e=>{let t=e.primaryKey.length===1?[e.fields[e.primaryKey[0]]]:[],n=Object.values(e.fields).filter(t=>t.filterable&&!t.sensitive&&oe.has(t.type)&&!e.primaryKey.includes(t.name));return[...t,...n]},k=(e,t)=>O(e,t),A=e=>!e.nullable&&!e.default,j=e=>e.toLowerCase().replace(/[\s_-]+/g,``),ce=(e,t,n)=>{let r=new Set;return e.flatMap((e,i)=>{let a=j(e);if(a===``)return[];let o=t.find(e=>!r.has(e.name)&&(j(D(n,e.name))===a||j(e.name)===a));return o?(r.add(o.name),[{column:i,field:o.name}]):[]})},le=(e,t,n)=>{if(e===`update`)return[];let r=new Set(n.map(e=>e.field));return t.filter(e=>A(e)&&!r.has(e.name))},M=e=>({ok:!0,value:e}),N=e=>({ok:!1,problem:e}),P=e=>`“${x(e)}”`,F=(e,t)=>{if(typeof e==`number`)return String(e);if(typeof e==`string`)return m(e,t.decimal)},ue=(e,t,n)=>{let r=F(t,n);if(r===void 0)return N(b(`notNumber`,{cell:P(t)}));let[i,a=``]=r.split(`.`);if(/[1-9]/.test(a)||/e/i.test(r))return N(b(`notWholeNumber`,{cell:P(t)}));if(e.type===`bigint`)return M(String(BigInt(i)));let o=Number(i);return Number.isSafeInteger(o)?M(o):N(b(`tooLarge`,{cell:P(t)}))},de=(e,t)=>{let n=F(e,t);return n===void 0?N(b(`notNumber`,{cell:P(e)})):M(n)},fe=new Set([`true`,`yes`,`1`]),pe=new Set([`false`,`no`,`0`]),me=e=>{if(typeof e==`boolean`)return M(e);let t=typeof e==`string`||typeof e==`number`?String(e).trim().toLowerCase():``;return fe.has(t)?M(!0):pe.has(t)?M(!1):N(b(`notBoolean`,{cell:P(e)}))},I=e=>String(e).padStart(2,`0`),he=(e,t,n)=>{let r=new Date(Date.UTC(e,t-1,n));if(r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n)return`${e}-${I(t)}-${I(n)}`},L=`(\\d{1,2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?`,ge=(e,t)=>{let n=RegExp(`^(\\d{4})[-/](\\d{1,2})[-/](\\d{1,2})(?:[T ]${L}(Z|[+-]\\d{2}:?\\d{2})?)?$`).exec(e.trim()),r=RegExp(`^(\\d{1,2})[./-](\\d{1,2})[./-](\\d{4})(?: ${L})?$`).exec(e.trim());if(!n&&!r)return;let[i,a,o]=n?[n[1],n[2],n[3]].map(Number):t===`dmy`?[r[3],r[2],r[1]].map(Number):[r[3],r[1],r[2]].map(Number),s=he(i,a,o);if(!s)return;let[c,l,u=`0`]=n?n.slice(4,7):r.slice(4,7);if(c===void 0)return{date:s};if(!(Number(c)>23||Number(l)>59||Number(u)>59))return{date:s,time:`${I(Number(c))}:${l}:${I(Number(u))}`,zone:n?.[7]}},R=(e,t)=>{if(ee(e)){let[t,n]=e.date.split(`T`);return{date:t,time:n}}return typeof e==`string`?ge(e,t.dateOrder):void 0},z=(e,t)=>N(b(`notDate`,{cell:P(e),dayFirst:t.dateOrder===`dmy`})),_e=(e,t)=>{let n=R(e,t);return n?n.time&&n.time!==`00:00:00`?N(b(`hasTime`,{cell:P(e)})):M(n.date):z(e,t)},ve=(e,t)=>{let n=R(e,t);if(!n)return z(e,t);if(n.zone)return M(new Date(`${n.date}T${n.time}${n.zone===`Z`?`Z`:n.zone.replace(/^([+-]\d{2})(\d{2})$/,`$1:$2`)}`).toISOString());let[r,i,a]=n.date.split(`-`).map(Number),[o,s,c]=(n.time??`00:00:00`).split(`:`).map(Number);return M(new Date(r,i-1,a,o,s,c).toISOString())},B=e=>e.trim().toLowerCase().replace(/\s+/g,` `),ye=(e,t,n)=>{let r=e.enumValues??[],i=B(x(n)),a=r.filter(e=>B(e)===i||B(v(e,t?.valueLabels))===i);return a.length===1?M(a[0]):a.length>1?N(b(`severalValues`,{cell:P(n),values:a.map(e=>v(e,t?.valueLabels)).join(`, `)})):N(b(`notOneOf`,{cell:P(n),values:r.map(e=>v(e,t?.valueLabels)).join(`, `)}))},be=(e,t)=>typeof e==`boolean`&&!t.booleanText?N(b(`notText`,{cell:P(e)})):M(x(e)),xe=e=>S(e)?M(e.json):M(e),V=(e,t,n,r)=>{if(y(n))return e.nullable?M(null):N(b(`emptyRequired`));if(e.type===`json`)return xe(n);if(S(n))return N(b(`nestedValue`,{cell:P(n)}));switch(e.type){case`integer`:case`bigint`:return ue(e,n,r);case`decimal`:return de(n,r);case`boolean`:return me(n);case`date`:return _e(n,r);case`timestamp`:return ve(n,r);case`enum`:return ye(e,t,n);case`text`:case`uuid`:case`currency`:case`country`:return be(n,r);default:throw Error(`Not implemented: importing ${e.type} fields, which importableFields leaves out`)}},Se=(e,t)=>e[t]?.names?.singular??d(t),Ce=(e,t)=>e[t]?.names?.plural??d(t),we=(e,t,n)=>{let{model:r,resources:i,views:a}=n,o=a[r.name],s={},c={},l=[],u=[];for(let{column:n,field:d,matchBy:f}of t.columns){let p=r.fields[d],m=e.cells[n]??null,h=D(o,d),g=k(p,i);if(g&&!y(m)){let e=f??g.primaryKey[0],n=V(g.fields[e],a[g.name]?.fields[e],m,t.options);n.ok?u.push({field:d,finding:{model:g,field:e,value:n.value}}):l.push(`${h}: ${n.problem}`),s[d]=x(m);continue}let _=V(p,o?.fields[d],m,t.options);_.ok?c[d]=s[d]=_.value:l.push(`${h}: ${_.problem}`)}let d;if(t.match&&t.mode!==`create`){let n=r.fields[t.match.field],i=V({...n,nullable:!1},o?.fields[n.name],e.cells[t.match.column]??null,t.options);i.ok?d={model:r,field:n.name,value:i.value}:l.push(`${D(o,n.name)}: ${i.problem}`)}return{values:s,data:c,problems:l,relations:u,match:d}},H=(e,t)=>{let n=e.lookups.keysOf(t.model.name,t.field,t.value),r=`${D(e.views[t.model.name],t.field).toLowerCase()} “${String(t.value)}”`;return n.length===1?{key:n[0]}:n.length===0?{none:b(`noneHas`,{singular:Se(e.views,t.model.name),named:r})}:{several:b(`severalHave`,{count:n.length,plural:Ce(e.views,t.model.name),named:r})}},Te=e=>e.cells.every(y),U=async(e,t,n)=>{let{model:r,views:i}=n,a=e.filter(e=>!Te(e)).map(e=>({row:e,...we(e,t,n)})),o=new Map;for(let e of a.flatMap(e=>[...e.relations.map(e=>e.finding),...e.match?[e.match]:[]])){let t=`${e.model.name}.${e.field}`;o.has(t)||o.set(t,{model:e.model,field:e.field,values:[]}),o.get(t).values.push(e.value)}for(let{model:e,field:t,values:r}of o.values())await n.lookups.load(e,t,r);return a.map(({row:e,values:a,data:o,problems:s,relations:c,match:l})=>{let u={...o};for(let{field:e,finding:t}of c){let a=H(n,t);`key`in a?u[e]=a.key:s.push(`${D(i[r.name],e)}: ${a.none??a.several}`)}let d=l&&H(n,l);d?.several&&s.push(b(`notOneRecord`,{found:d.several})),d?.none&&t.mode===`update`&&s.push(b(`nothingToUpdate`,{found:d.none}));let f={line:e.line,cells:e.cells,values:a,problems:s};return s.length>0?f:d&&`key`in d?{...f,op:{op:`update`,resource:r.name,key:d.key,etag:`*`,data:u}}:{...f,op:{op:`create`,resource:r.name,data:u}}})},Ee=5,De=5,Oe=async(e,t)=>{let n=e.rows(t),{value:r=[]}=await n.next();await n.return(void 0);let[i,...a]=r;return{headers:(i?.cells??[]).map(x),sample:a.slice(0,Ee)}};async function*W(e,t){let n=!0;for await(let r of e.rows(t))yield n?r.slice(1):r,n=!1}var ke=async(e,t,n,r,i,a)=>{let o={rows:0,creates:0,updates:0,problems:[],preview:[]};for await(let s of W(e,t)){a?.throwIfAborted();for(let e of await U(s,n,r))o.rows++,o.preview.length<De&&o.preview.push(e),e.op?.op===`create`?o.creates++:e.op?.op===`update`?o.updates++:o.problems.push({line:e.line,cells:e.cells,problems:e.problems});i(o.rows)}return o},Ae=(e,t)=>{if(!o(e))return[e.message];let n=e.errors.filter(e=>e.field);return n.length===0?[e.message]:n.map(e=>`${D(t.views[t.model.name],e.field)}: ${e.message}`)},je=async(e,t,n,r,{client:i,onProgress:a,cancelled:s})=>{let c={created:0,updated:0,skipped:0,failed:0,notWritten:[]},l=async e=>{let t=[...e];for(;t.length>0;){let e=t.map(e=>e.op);try{let{results:t}=await i.batchWrite(e);for(let e of t)e.op===`create`?c.created++:e.op===`update`&&c.updated++;return}catch(e){let n=o(e)?e.operation:void 0;if(n===void 0||!t[n])throw e;let[i]=t.splice(n,1);c.failed++,c.notWritten.push({line:i.line,cells:i.cells,problems:Ae(e,r)})}}},u=[],d=async e=>{for(;u.length>=100||e&&u.length>0;){if(s())return!1;await l(u.splice(0,100)),a({...c})}return!0};for await(let i of W(e,t)){for(let e of await U(i,n,r))e.op?u.push(e):(c.skipped++,c.notWritten.push({line:e.line,cells:e.cells,problems:e.problems}));if(!await d(!1))return{...c,cancelled:!0}}return await d(!0)?{...c,cancelled:!1}:{...c,cancelled:!0}},G=50,K=(e,t,n)=>p(re(t,n),b(`notImportedFile`,{name:(e??`import`).replace(/\.[^.]+$/,``)}),`text/csv`),q=({rows:e})=>(0,T.jsxs)(`ul`,{"aria-label":b(`rowsNotImported`),className:`flex flex-col gap-1 text-body`,children:[e.slice(0,G).map(e=>(0,T.jsxs)(`li`,{children:[(0,T.jsx)(`span`,{className:`font-medium`,children:b(`rowProblems`,{line:e.line})}),` `,e.problems.join(`; `)]},e.line)),e.length>G&&(0,T.jsx)(`li`,{className:`text-muted-foreground`,children:b(`andMore`,{count:(e.length-G).toLocaleString(r())})})]}),Me=({rows:e})=>(0,T.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,T.jsx)(h,{className:`size-3.5`}),b(`checkingRows`,{count:e.toLocaleString(r())})]}),Ne=({check:e,model:t,resources:n,views:r,columns:i,headers:a,fileName:o})=>{let c=r[t.name],l=i.map(e=>t.fields[e.field]);return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,T.jsx)(E,{label:b(`check`),counts:[[b(`rows`),e.rows],[b(`toCreate`),e.creates],[b(`toUpdate`),e.updates],[b(`withProblems`),e.problems.length]]}),e.preview.length>0&&(0,T.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,T.jsxs)(`table`,{"aria-label":b(`firstRows`),className:`w-full text-left text-body`,children:[(0,T.jsx)(`thead`,{className:`bg-muted text-muted-foreground`,children:(0,T.jsxs)(`tr`,{children:[(0,T.jsx)(`th`,{className:`px-2 py-1.5 font-medium`,children:b(`row`)}),l.map(e=>(0,T.jsx)(`th`,{className:`whitespace-nowrap px-2 py-1.5 font-medium`,children:D(c,e.name)},e.name))]})}),(0,T.jsx)(`tbody`,{className:`divide-y`,children:e.preview.map(e=>(0,T.jsxs)(`tr`,{className:e.problems.length>0?`bg-danger-soft`:void 0,children:[(0,T.jsx)(`td`,{className:`px-2 py-1.5 tabular-nums text-muted-foreground`,children:e.line}),l.map(t=>(0,T.jsx)(`td`,{className:`max-w-48 truncate px-2 py-1.5`,children:k(t,n)?String(e.values[t.name]??`—`):t.name in e.values?f(t,e.values[t.name],c?.fields[t.name]):``},t.name))]},e.line))})]})}),e.problems.length>0&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsx)(`h3`,{className:`font-medium`,children:b(`problemRows`)}),(0,T.jsxs)(_,{size:`sm`,onClick:()=>K(o,a,e.problems),children:[(0,T.jsx)(s,{className:`size-3.5`}),b(`download`)]})]}),(0,T.jsx)(q,{rows:e.problems})]}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`batches`,{size:100})})]})},Pe=[`.xlsx`,`.csv`,`.json`],Fe=[`text/csv`,`application/json`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],Ie=[`text/comma-separated-values`,`application/csv`,`text/x-csv`,`application/vnd.ms-excel`,`text/plain`,`application/octet-stream`],Le=e=>/\bAndroid\b/.test(e),Re=e=>[...Pe,...Fe,...Le(e)?Ie:[]].join(`,`),J=({label:e,name:t,value:n,options:r,onChange:a,help:o,className:s})=>{let c=(0,w.useId)();return(0,T.jsxs)(`div`,{className:i(`flex min-w-0 flex-col gap-1.5`,s),children:[(0,T.jsx)(`label`,{htmlFor:c,className:`font-medium`,children:e}),(0,T.jsx)(`select`,{id:c,"aria-label":t,value:n,onChange:e=>a(e.target.value),className:`h-8 w-full min-w-0 rounded-md border border-border-strong bg-background px-2 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 max-sm:min-h-11`,children:r.map(e=>(0,T.jsx)(`option`,{value:e.value,children:e.label},e.value))}),o&&(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o})]})},Y=({file:e,sheets:t,sheet:n,reading:r,onChoose:i,onSheet:a})=>{let o=(0,w.useId)();return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(`label`,{htmlFor:o,className:`font-medium`,children:b(`file`)}),(0,T.jsx)(`input`,{id:o,type:`file`,accept:Re(globalThis.navigator?.userAgent??``),disabled:r,onChange:e=>{let t=e.target.files?.[0];t&&i(t)},className:`file:mr-3 file:h-8 file:rounded-md file:border file:border-border-strong file:bg-background file:px-3 file:font-medium file:text-foreground max-sm:file:min-h-11`}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`fileHint`)})]}),r&&(0,T.jsxs)(`p`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,T.jsx)(h,{className:`size-3.5`}),b(`reading`,{name:e?.name??b(`theFile`)})]}),!r&&t.length>1&&(0,T.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,T.jsx)(te,{className:`mb-2 size-4 shrink-0 text-muted-foreground`}),(0,T.jsx)(J,{className:`flex-1`,label:b(`sheet`),value:n??``,options:t.map(e=>({value:e,label:e})),onChange:a})]})]})},X=e=>e.toLocaleString(r()),ze=({progress:e,total:t,cancelling:n})=>{let r=e.created+e.updated+e.failed;return(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:b(n?`stopping`:`saving`)}),(0,T.jsxs)(`span`,{className:`tabular-nums`,children:[X(r),` / `,X(t)]})]}),(0,T.jsx)(`div`,{role:`progressbar`,"aria-label":b(`rowsSaved`),"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":t,className:`h-2 overflow-hidden rounded-full bg-muted`,children:(0,T.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-[width]`,style:{width:`${t>0?Math.min(100,r/t*100):0}%`}})})]})},Be=({result:e,stopped:t,headers:n,fileName:r})=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t!==void 0&&(0,T.jsx)(g,{title:b(`stopped`),error:t}),e.cancelled&&(0,T.jsx)(`p`,{role:`status`,children:b(`cancelled`)}),(0,T.jsx)(E,{label:b(`summary`),counts:[[b(`created`),e.created],[b(`updated`),e.updated],[b(`skipped`),e.skipped],[b(`failed`),e.failed]]}),e.notWritten.length>0&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsx)(`h3`,{className:`font-medium`,children:b(`rowsNotImported`)}),(0,T.jsxs)(_,{size:`sm`,onClick:()=>K(r,n,e.notWritten),children:[(0,T.jsx)(s,{className:`size-3.5`}),b(`download`)]})]}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b(`notWrittenHint`)}),(0,T.jsx)(q,{rows:[...e.notWritten].sort((e,t)=>e.line-t.line)})]})]}),Ve=u(),Z=100,Q=e=>String(e),He=e=>{let t=new Map,n=(e,n)=>{let r=`${e}.${n}`;return t.has(r)||t.set(r,new Map),t.get(r)};return{load:async(t,r,i)=>{let o=n(t.name,r),s=[...new Map(i.filter(e=>!o.has(Q(e))).map(e=>[Q(e),e])).values()],c=t.primaryKey[0];for(let n=0;n<s.length;n+=Z){let i=s.slice(n,n+Z);for(let e of i)o.set(Q(e),[]);let l=a(Ve.in(r,i)),u;do{let n=await e(t.name).list(t.name,{filter:l,fields:[...new Set([c,r])],pageSize:1e3,pageToken:u});for(let e of n.items)o.get(Q(e[r]))?.push(e[c]);u=n.nextPageToken||void 0}while(u)}},keysOf:(e,t,r)=>n(e,t).get(Q(r))??[]}},Ue=500,$=()=>{let e=new Worker(new URL(`/assets/parse-worker-VaelBbE0.js`,``+import.meta.url),{type:`module`}),t=[],n;return e.onmessage=e=>{if(n){let t=n;n=void 0,t(e.data)}else t.push(e.data)},e.onerror=e=>{e.preventDefault();let r={type:`error`,message:b(`unreadable`)};n?n(r):t.push(r)},{send:t=>e.postMessage(t),receive:()=>t.length>0?Promise.resolve(t.shift()):new Promise(e=>n=e),stop:()=>e.terminate()}},We=e=>({sheets:async()=>{let t=$();try{t.send({type:`sheets`,file:e,locale:c()});let n=await t.receive();if(n.type===`error`)throw Error(n.message);if(n.type!==`sheets`)throw Error(`The parse worker answered ${n.type} to a request for sheets`);return n.sheets}finally{t.stop()}},rows:async function*(t){let n=$();try{for(n.send({type:`read`,file:e,sheet:t,chunk:Ue,locale:c()});;){let e=await n.receive();if(e.type===`error`)throw Error(e.message);if(e.type===`end`)return;if(e.type!==`rows`)throw Error(`The parse worker answered ${e.type} to a read`);yield e.rows,n.send({type:`next`})}}finally{n.stop()}}});export{A as _,Y as a,Me as c,je as d,ce as f,k as g,se as h,Be as i,ke as l,ae as m,He as n,J as o,D as p,ze as r,Ne as s,We as t,Oe as u,le as v};
3
- //# debugId=1c2897d4-6ae7-45f6-b1d7-62d1a15bf37f
3
+ //# debugId=f1550865-2851-495a-a761-146d1e3f7264
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,$o as i,Hc as a,Jo as o,Ss as s,Yi as c,Yo as l,Zo as u,lc as d,sc as f,vs as p,ys as m}from"./app-D3BCcbgE.js";import{t as h}from"./page-header-Ddz2r5ic.js";var g=e(t(),1),_=()=>[{value:`allowed`,label:p(`on`)},{value:`forbidden`,label:p(`off`)}],v=()=>[{value:`allowed`,label:p(`optional`)},{value:`required`,label:p(`required`)},{value:`forbidden`,label:p(`off`)}],y=()=>[{method:`password`,label:p(`password`),description:p(`passwordDescription`),rules:_()},{method:`emailCode`,label:p(`emailedSignInCode`),description:p(`emailedSignInCodeDescription`),rules:_()},{method:`passkey`,label:p(`passkeys`),description:p(`passkeysPolicyDescription`),rules:v()},{method:`twoFactor`,label:p(`twoFactor`),description:p(`twoFactorPolicyDescription`),rules:v()},{method:`staffAccess`,label:p(`staffAccess`),description:p(`staffAccessDescription`),rules:[{value:`allowed`,label:p(`on`)},{value:`notify`,label:p(`emailThePerson`)},{value:`forbidden`,label:p(`off`)}]},{method:`platformSignIn`,label:p(`platformSignIn`),description:p(`platformSignInDescription`),rules:_()}],b=(e,t)=>{let n=y().find(t=>t.method===e)?.rules.find(e=>e.value===t)?.label;if(n===void 0)throw Error(`No label for the ${t} rule of ${e}`);return n},x=e(n(),1),S=({row:e,value:t,onChange:n})=>(0,x.jsx)(`span`,{role:`radiogroup`,"aria-label":e.label,className:`inline-flex h-8 shrink-0 rounded-md bg-muted p-0.5`,children:e.rules.map(e=>(0,x.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>n(e.value),className:a(`rounded px-3 text-body font-medium transition-colors`,e.value===t?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value))}),C=({method:e},t,{mail:n,effective:r,policy:i})=>{if(e===`emailCode`&&!n)return p(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return p(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return p(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&t.passkey===`required`)return p(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return p(`appliesAs`,{rule:b(e,r[e])})},w=({operator:e,platformProviders:t=[]})=>y().flatMap(n=>n.method===`staffAccess`&&!e?[]:n.method===`platformSignIn`?t.length>0?[{...n,label:p(`platformSignInWith`,{provider:new Intl.ListFormat(r(),{type:`conjunction`}).format(t)})}]:[]:[n]),T=({state:e,onSave:t,busy:n,error:r,notice:i})=>{let[a,o]=(0,g.useState)(e.policy),s=w(e),l=s.some(({method:t})=>a[t]!==e.policy[t]);return(0,x.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t(a)},children:[(0,x.jsx)(`ul`,{className:`divide-y rounded-lg border bg-background`,children:s.map(t=>{let n=C(t,a,e);return(0,x.jsxs)(`li`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h2`,{className:`font-semibold`,children:t.label}),(0,x.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t.description}),n&&(0,x.jsx)(`p`,{className:`mt-1.5 text-xs font-medium text-warning-text`,children:n})]}),(0,x.jsx)(S,{row:t,value:a[t.method],onChange:e=>o({...a,[t.method]:e})})]},t.method)})}),r&&(0,x.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-body font-medium text-danger-text`,children:r}),i&&!l&&(0,x.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.savedAt?e.savedBy?p(`lastSavedBy`,{name:e.savedBy,time:c(Date.parse(e.savedAt))}):p(`lastSaved`,{time:c(Date.parse(e.savedAt))}):p(`neverChanged`)}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[l&&(0,x.jsx)(f,{onClick:()=>o(e.policy),children:p(`reset`)}),(0,x.jsx)(f,{variant:`primary`,type:`submit`,loading:n,disabled:!l,children:p(`save`)})]})]})]})},E=(e,t)=>e.endedAt?(0,x.jsx)(u,{tone:`neutral`,children:p(`stopped`,{time:c(Date.parse(e.endedAt))})}):Date.parse(e.expiresAt)<=t?(0,x.jsx)(u,{tone:`neutral`,children:p(`ended`,{time:c(Date.parse(e.expiresAt))})}):(0,x.jsx)(u,{tone:`amber`,children:p(`signedInUntil`,{time:c(Date.parse(e.expiresAt))})}),D=({signIns:e,operator:t,error:n,now:r=Date.now()})=>(0,x.jsxs)(o,{title:p(`staffSignIns`),description:p(`staffSignInsDescription`,{operator:t}),children:[(0,x.jsx)(l,{message:n}),e&&e.length===0&&(0,x.jsx)(`p`,{className:`text-muted-foreground`,children:p(`noStaffSignIns`)}),e&&e.length>0&&(0,x.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.staffName?`${e.staffName} (${e.staff})`:e.staff}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:p(`as`)}),(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.user})]}),(0,x.jsx)(`p`,{className:`break-words`,children:e.reason}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{children:c(Date.parse(e.startedAt))}),E(e,r)]})]},e.id))})]}),O=({operator:e})=>{let{session:t}=m(),[n,r]=(0,g.useState)(),[a,o]=(0,g.useState)();return(0,g.useEffect)(()=>{t.staff.log().then(r,e=>o(e instanceof s?i(e):p(`couldNotReadStaffSignIns`)))},[t]),(0,x.jsx)(D,{operator:e,signIns:n,error:a})},k=()=>{let{session:e}=m(),[t,n]=(0,g.useState)(),[r,a]=(0,g.useState)(!1),[o,c]=(0,g.useState)(),[l,u]=(0,g.useState)();(0,g.useEffect)(()=>{e.signInPolicy.read().then(n,e=>c(e instanceof s?i(e):p(`couldNotReadPolicy`)))},[e]);let f=async t=>{a(!0),c(void 0),u(void 0);try{n(await e.signInPolicy.save(t)),u(p(`policySaved`))}catch(e){if(!(e instanceof s))throw e;c(i(e))}a(!1)};return(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,x.jsx)(h,{title:p(`signInPolicy`),subtitle:p(`policySubtitle`)}),t?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{state:t,busy:r,error:o,notice:l,onSave:e=>void f(e)},t.savedAt??`default`),t.operator&&(0,x.jsx)(O,{operator:t.operator})]}):o?(0,x.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:o}):(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(d,{}),` `,p(`loading`)]})]})};export{k as SignInPolicyPage};
2
- //# debugId=6dcb8221-d718-4f25-954a-f25ce907f0e1
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,$o as i,Hc as a,Jo as o,Ss as s,Yi as c,Yo as l,Zo as u,lc as d,sc as f,vs as p,ys as m}from"./app-B94YfKGx.js";import{t as h}from"./page-header-Ddz2r5ic.js";var g=e(t(),1),_=()=>[{value:`allowed`,label:p(`on`)},{value:`forbidden`,label:p(`off`)}],v=()=>[{value:`allowed`,label:p(`optional`)},{value:`required`,label:p(`required`)},{value:`forbidden`,label:p(`off`)}],y=()=>[{method:`password`,label:p(`password`),description:p(`passwordDescription`),rules:_()},{method:`emailCode`,label:p(`emailedSignInCode`),description:p(`emailedSignInCodeDescription`),rules:_()},{method:`passkey`,label:p(`passkeys`),description:p(`passkeysPolicyDescription`),rules:v()},{method:`twoFactor`,label:p(`twoFactor`),description:p(`twoFactorPolicyDescription`),rules:v()},{method:`staffAccess`,label:p(`staffAccess`),description:p(`staffAccessDescription`),rules:[{value:`allowed`,label:p(`on`)},{value:`notify`,label:p(`emailThePerson`)},{value:`forbidden`,label:p(`off`)}]},{method:`platformSignIn`,label:p(`platformSignIn`),description:p(`platformSignInDescription`),rules:_()}],b=(e,t)=>{let n=y().find(t=>t.method===e)?.rules.find(e=>e.value===t)?.label;if(n===void 0)throw Error(`No label for the ${t} rule of ${e}`);return n},x=e(n(),1),S=({row:e,value:t,onChange:n})=>(0,x.jsx)(`span`,{role:`radiogroup`,"aria-label":e.label,className:`inline-flex h-8 shrink-0 rounded-md bg-muted p-0.5`,children:e.rules.map(e=>(0,x.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>n(e.value),className:a(`rounded px-3 text-body font-medium transition-colors`,e.value===t?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value))}),C=({method:e},t,{mail:n,effective:r,policy:i})=>{if(e===`emailCode`&&!n)return p(`codeNeedsMail`);if(e===`password`&&!n&&t.password===`forbidden`)return p(`passwordStaysOn`);if(e===`staffAccess`&&!n&&t.staffAccess===`notify`)return p(`staffNeedsMail`);if(e===`platformSignIn`&&t.platformSignIn===`allowed`&&t.passkey===`required`)return p(`platformOff`);if(t[e]===i[e]&&r[e]!==i[e])return p(`appliesAs`,{rule:b(e,r[e])})},w=({operator:e,platformProviders:t=[]})=>y().flatMap(n=>n.method===`staffAccess`&&!e?[]:n.method===`platformSignIn`?t.length>0?[{...n,label:p(`platformSignInWith`,{provider:new Intl.ListFormat(r(),{type:`conjunction`}).format(t)})}]:[]:[n]),T=({state:e,onSave:t,busy:n,error:r,notice:i})=>{let[a,o]=(0,g.useState)(e.policy),s=w(e),l=s.some(({method:t})=>a[t]!==e.policy[t]);return(0,x.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),t(a)},children:[(0,x.jsx)(`ul`,{className:`divide-y rounded-lg border bg-background`,children:s.map(t=>{let n=C(t,a,e);return(0,x.jsxs)(`li`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h2`,{className:`font-semibold`,children:t.label}),(0,x.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:t.description}),n&&(0,x.jsx)(`p`,{className:`mt-1.5 text-xs font-medium text-warning-text`,children:n})]}),(0,x.jsx)(S,{row:t,value:a[t.method],onChange:e=>o({...a,[t.method]:e})})]},t.method)})}),r&&(0,x.jsx)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-body font-medium text-danger-text`,children:r}),i&&!l&&(0,x.jsx)(`p`,{role:`status`,className:`rounded-md bg-success-soft px-3 py-2 text-body font-medium text-success-text`,children:i}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.savedAt?e.savedBy?p(`lastSavedBy`,{name:e.savedBy,time:c(Date.parse(e.savedAt))}):p(`lastSaved`,{time:c(Date.parse(e.savedAt))}):p(`neverChanged`)}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[l&&(0,x.jsx)(f,{onClick:()=>o(e.policy),children:p(`reset`)}),(0,x.jsx)(f,{variant:`primary`,type:`submit`,loading:n,disabled:!l,children:p(`save`)})]})]})]})},E=(e,t)=>e.endedAt?(0,x.jsx)(u,{tone:`neutral`,children:p(`stopped`,{time:c(Date.parse(e.endedAt))})}):Date.parse(e.expiresAt)<=t?(0,x.jsx)(u,{tone:`neutral`,children:p(`ended`,{time:c(Date.parse(e.expiresAt))})}):(0,x.jsx)(u,{tone:`amber`,children:p(`signedInUntil`,{time:c(Date.parse(e.expiresAt))})}),D=({signIns:e,operator:t,error:n,now:r=Date.now()})=>(0,x.jsxs)(o,{title:p(`staffSignIns`),description:p(`staffSignInsDescription`,{operator:t}),children:[(0,x.jsx)(l,{message:n}),e&&e.length===0&&(0,x.jsx)(`p`,{className:`text-muted-foreground`,children:p(`noStaffSignIns`)}),e&&e.length>0&&(0,x.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`flex flex-col gap-1.5 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.staffName?`${e.staffName} (${e.staff})`:e.staff}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:p(`as`)}),(0,x.jsx)(`span`,{className:`font-medium break-all`,children:e.user})]}),(0,x.jsx)(`p`,{className:`break-words`,children:e.reason}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{children:c(Date.parse(e.startedAt))}),E(e,r)]})]},e.id))})]}),O=({operator:e})=>{let{session:t}=m(),[n,r]=(0,g.useState)(),[a,o]=(0,g.useState)();return(0,g.useEffect)(()=>{t.staff.log().then(r,e=>o(e instanceof s?i(e):p(`couldNotReadStaffSignIns`)))},[t]),(0,x.jsx)(D,{operator:e,signIns:n,error:a})},k=()=>{let{session:e}=m(),[t,n]=(0,g.useState)(),[r,a]=(0,g.useState)(!1),[o,c]=(0,g.useState)(),[l,u]=(0,g.useState)();(0,g.useEffect)(()=>{e.signInPolicy.read().then(n,e=>c(e instanceof s?i(e):p(`couldNotReadPolicy`)))},[e]);let f=async t=>{a(!0),c(void 0),u(void 0);try{n(await e.signInPolicy.save(t)),u(p(`policySaved`))}catch(e){if(!(e instanceof s))throw e;c(i(e))}a(!1)};return(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 px-4 py-6 md:px-6`,children:[(0,x.jsx)(h,{title:p(`signInPolicy`),subtitle:p(`policySubtitle`)}),t?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{state:t,busy:r,error:o,notice:l,onSave:e=>void f(e)},t.savedAt??`default`),t.operator&&(0,x.jsx)(O,{operator:t.operator})]}):o?(0,x.jsx)(`p`,{role:`alert`,className:`text-danger-text`,children:o}):(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(d,{}),` `,p(`loading`)]})]})};export{k as SignInPolicyPage};
2
+ //# debugId=04d5e061-9943-4506-9a7e-6f20bbbf092a
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t}from"./react-CuiNlnus.js";import{Bo as n,Bs as r,Ds as i,Er as a,Jn as o,Nr as s,Qn as c,_a as l,an as u,ar as d,dn as f,er as p,fn as m,in as h,ja as g,ks as _,ls as v,ns as y,rn as b,sr as x,un as S,ws as C}from"./app-D3BCcbgE.js";import{h as w}from"./vendor-t7Q7QbPu.js";import{S as T,ht as E,r as D}from"./embedded-list-6lQyJozS.js";import{n as O}from"./record-preview-QMV2lW2j.js";var k=e(t(),1),A=e=>({queryKey:e.queryKey,start:t=>t.prefetchQuery(e)}),j=e=>({queryKey:e.queryKey,start:t=>t.prefetchInfiniteQuery(e)}),M={Table:(e,t,n)=>{let{resource:r,filter:i=``,sort:a=``,columns:o,button:s,bulk:c=!1,limit:d=10,select:p}=h(e),m=r===void 0?void 0:n.resources[r];if(!m)return[];if(t.part===`chosen`){let e=p===void 0?void 0:n.given[p];return e?[A(f(n.client,m,{key:e}))]:[]}let g=n.views[m.name],{fields:v,read:y}=u({...n,model:m,view:g,columns:o?.map(_),button:s,bulk:c,phoneColumns:b(o)});return[A(D(n,{model:m,filter:i,orderBy:a||l(m,g),limit:d,fields:v,read:y}))]},Chart:(e,t,{client:n,resources:r,views:i})=>{let{resource:o,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m}=h(e),g=r[o],_=g&&E({model:g,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m},r,i);return g&&_?[A(a(n,g.name,_))]:[]},RecordCards:(e,t,{client:n,resources:r,views:i})=>{let{resource:a,filter:o=``,sort:s=``,limit:c=10}=h(e),u=r[a];if(!u)return[];let d=s||l(u,i[u.name]);return[A(m(n,u,{filter:o,sort:d,pageSize:c})),A(S(n,u,o))]},RecordRow:(e,t,{client:n,queryClient:r,resources:i,views:a})=>{let{resource:o,filter:s=``,sort:c=``}=h(e),l=i[o];if(!l)return[];let u=a[l.name];return u?.searchesOf||u?.listOf!==void 0?[]:[A(O({queryClient:r,client:n,resources:i,views:a,model:l,...T(l,u,{filter:s,sort:c})}))]},Thread:(e,t,{client:n,resources:i,views:a})=>{let{resource:c,filter:l,sender:u,time:d,calls:f,limit:p=50}=h(e);if(t.part===`calls`){let e=f&&i[f.resource];return e?[j(s(n,e.name,{filter:f.filter,orderBy:r(f.time),pageSize:p}))]:[]}let m=i[c];if(!m)return[];let g=o(i,a,m,u===void 0?[]:[u]);return[j(s(n,m.name,{filter:l,orderBy:r(d),pageSize:p,labels:g}))]}},N=(e,t,{client:n,resources:r})=>{let i=r[t.resource];return i?[A(S(n,i))]:[]},P=(e,t,n)=>(n?.reads??[]).flatMap(n=>{let r=i(t,n.block);if(!r||r.custom)return[];if(n.part===`condition`)return N(r,n,e);if(n.split)return[];let a=M[r.type];return a?a(C(r,{stack:[],params:e.params,...e.root&&{root:e.root}}),n,e):[]}),F=({tree:e,plan:t})=>{let r=v(),i=w(),{resources:a,views:o}=y(),s=g().fields,l=n(),u=c(),f=p(),m=d(x()),h=(0,k.useMemo)(()=>P({client:r,queryClient:i,resources:a,views:o,fieldTypes:s,xs:l,params:u,given:f,...m&&{root:m}},e,t),[r,i,a,o,s,l,u,f,m,e,t]);return(0,k.useEffect)(()=>{for(let e of h)e.start(i)},[h,i]),null};export{F as t};
2
- //# debugId=31fa035b-3edd-4500-9073-5870baf7a3d5
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t}from"./react-CuiNlnus.js";import{Bo as n,Bs as r,Ds as i,Er as a,Jn as o,Nr as s,Qn as c,_a as l,an as u,ar as d,dn as f,er as p,fn as m,in as h,ja as g,ks as _,ls as v,ns as y,rn as b,sr as x,un as S,ws as C}from"./app-B94YfKGx.js";import{h as w}from"./vendor-t7Q7QbPu.js";import{S as T,ht as E,r as D}from"./embedded-list-OJQKeuBN.js";import{n as O}from"./record-preview-DsIrTWKZ.js";var k=e(t(),1),A=e=>({queryKey:e.queryKey,start:t=>t.prefetchQuery(e)}),j=e=>({queryKey:e.queryKey,start:t=>t.prefetchInfiniteQuery(e)}),M={Table:(e,t,n)=>{let{resource:r,filter:i=``,sort:a=``,columns:o,button:s,bulk:c=!1,limit:d=10,select:p}=h(e),m=r===void 0?void 0:n.resources[r];if(!m)return[];if(t.part===`chosen`){let e=p===void 0?void 0:n.given[p];return e?[A(f(n.client,m,{key:e}))]:[]}let g=n.views[m.name],{fields:v,read:y}=u({...n,model:m,view:g,columns:o?.map(_),button:s,bulk:c,phoneColumns:b(o)});return[A(D(n,{model:m,filter:i,orderBy:a||l(m,g),limit:d,fields:v,read:y}))]},Chart:(e,t,{client:n,resources:r,views:i})=>{let{resource:o,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m}=h(e),g=r[o],_=g&&E({model:g,groupBy:s,splitBy:c,sum:l,average:u,filter:d,granularity:f,range:p,limit:m},r,i);return g&&_?[A(a(n,g.name,_))]:[]},RecordCards:(e,t,{client:n,resources:r,views:i})=>{let{resource:a,filter:o=``,sort:s=``,limit:c=10}=h(e),u=r[a];if(!u)return[];let d=s||l(u,i[u.name]);return[A(m(n,u,{filter:o,sort:d,pageSize:c})),A(S(n,u,o))]},RecordRow:(e,t,{client:n,queryClient:r,resources:i,views:a})=>{let{resource:o,filter:s=``,sort:c=``}=h(e),l=i[o];if(!l)return[];let u=a[l.name];return u?.searchesOf||u?.listOf!==void 0?[]:[A(O({queryClient:r,client:n,resources:i,views:a,model:l,...T(l,u,{filter:s,sort:c})}))]},Thread:(e,t,{client:n,resources:i,views:a})=>{let{resource:c,filter:l,sender:u,time:d,calls:f,limit:p=50}=h(e);if(t.part===`calls`){let e=f&&i[f.resource];return e?[j(s(n,e.name,{filter:f.filter,orderBy:r(f.time),pageSize:p}))]:[]}let m=i[c];if(!m)return[];let g=o(i,a,m,u===void 0?[]:[u]);return[j(s(n,m.name,{filter:l,orderBy:r(d),pageSize:p,labels:g}))]}},N=(e,t,{client:n,resources:r})=>{let i=r[t.resource];return i?[A(S(n,i))]:[]},P=(e,t,n)=>(n?.reads??[]).flatMap(n=>{let r=i(t,n.block);if(!r||r.custom)return[];if(n.part===`condition`)return N(r,n,e);if(n.split)return[];let a=M[r.type];return a?a(C(r,{stack:[],params:e.params,...e.root&&{root:e.root}}),n,e):[]}),F=({tree:e,plan:t})=>{let r=v(),i=w(),{resources:a,views:o}=y(),s=g().fields,l=n(),u=c(),f=p(),m=d(x()),h=(0,k.useMemo)(()=>P({client:r,queryClient:i,resources:a,views:o,fieldTypes:s,xs:l,params:u,given:f,...m&&{root:m}},e,t),[r,i,a,o,s,l,u,f,m,e,t]);return(0,k.useEffect)(()=>{for(let e of h)e.start(i)},[h,i]),null};export{F as t};
2
+ //# debugId=6eef131a-6dd5-4d0a-8cd0-d6a03793bb93
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ac as r,Do as i,M as a,R as o,Rn as s,Sc as c,V as l,Vc as u,Xc as d,_c as f,ac as p,cl as ee,jc as m,pc as te,sc as h,ss as ne,xc as g,yc as _,zc as re}from"./app-D3BCcbgE.js";import{t as ie}from"./circle-alert-ytReRN_c.js";import{a as ae,c as oe,d as se,f as ce,g as le,h as ue,i as de,m as fe,o as pe,p as me,r as he,s as ge,u as _e}from"./workflow-canvas-BKd_Yd0v.js";import{t as ve}from"./trash-CFCBxAWq.js";import{A as ye,D as be,F as xe,M as v,_ as Se,a as Ce,c as y,f as we,g as Te,h as b,i as Ee,k as x,m as De,n as Oe,o as S,s as C,u as ke,x as Ae}from"./workflows-Bey4jszG.js";import{E as w,S as je,T,_ as Me,s as E,x as D}from"./use-run-trace-BRwbwZcf.js";import{n as O}from"./use-workflow-types-Bn24Chp-.js";var Ne={type:`object`,title:`File`,properties:{uri:{type:`string`},name:{type:`string`},type:{type:`string`},size:{type:`integer`}}},Pe=(e,t)=>e.relation&&t?.(e.relation.resource)===`integer`?{type:`integer`}:{type:`string`},Fe=(e,t,n)=>{if(e.file)return t===`read`?Ne:{type:`string`};switch(e.type){case`integer`:return{type:`integer`};case`boolean`:return{type:`boolean`};case`json`:return{};case`enum`:return{type:`string`,...e.enumValues&&{enum:e.enumValues}};case`relation`:return t===`read`?Pe(e,n):{type:[`string`,`integer`]};case`bigint`:return t===`read`?{type:`string`}:{type:[`string`,`integer`]};case`decimal`:return t===`read`?{type:`string`}:{type:[`string`,`number`]};default:return{type:`string`}}},Ie=(e,t,n)=>{let r=Fe(e,t,n);if(t===`read`||!e.nullable||r.type===void 0)return r;let i=Array.isArray(r.type)?r.type:[r.type];return{...r,type:[...i,`null`],...Array.isArray(r.enum)&&{enum:[...r.enum,null]}}},Le=(e,t,n=e.name,r)=>({type:`object`,title:n,properties:Object.fromEntries(Object.values(e.fields).filter(e=>t===`read`||!e.readOnly).map(e=>[e.name,Ie(e,t,r)]))}),Re=e=>t=>{let n=e(t);return n?.primaryKey.length===1?n.fields[n.primaryKey[0]]?.type:void 0},ze={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};ze.node;var k=u(ze),Be={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};Be.node;var Ve=u(Be),He={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};He.node;var Ue=u(He),We={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};We.node;var Ge=u(We),Ke={name:`pen-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]],aliases:[`edit-3`]};Ke.node;var qe=u(Ke),Je={name:`repeat`,size:24,node:[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]};Je.node;var Ye=u(Je),Xe={name:`timer`,size:24,node:[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]};Xe.node;var Ze=u(Xe),A=(e,t)=>{let n=structuredClone(e);return t(n),n},j=new Set([`Task`,`Pass`,`Wait`,`Map`,`Block`]),M=(e,t)=>{if(!j.has(e.Type))return;let n=e;delete n.End,n.Next=t},N=(e,t)=>{let n=D(e,t);if(!n)throw Error(`No Map or Block at ${t.join(`/`)}`);return n},Qe=(e,t)=>{let n=new Set(Me(e.stateMachine)),r=1;for(;n.has(`${t} ${r}`);)r++;return`${t} ${r}`},$e=e=>`task`in e?{Type:`Task`,Resource:e.task,Arguments:{},End:!0}:e.type===`Choice`?{Type:`Choice`,Choices:[]}:e.type===`Wait`?{Type:`Wait`,Seconds:60,End:!0}:e.type===`Succeed`?{Type:`Succeed`}:e.type===`Fail`?{Type:`Fail`}:e.type===`Pass`?{Type:`Pass`,End:!0}:e.type===`Block`?{Type:`Block`,Processor:{StartAt:``,States:{}},Cache:{Ttl:`1 hour`},End:!0}:{Type:`Map`,Items:`{% [] %}`,ItemProcessor:{StartAt:``,States:{}},End:!0},P=(e,t,n,r,i)=>A(e,e=>{let a=N(e,t),o=b(e)===`data`,s=$e(n);if(o&&delete s.End,a.States[r]=s,!o&&(a.StartAt===void 0||!Object.hasOwn(a.States,a.StartAt))&&(a.StartAt=r),s.Type!==`Map`&&s.Type!==`Block`)return;let c=Qe(e,i),l=o?{States:{[c]:{Type:`Pass`}}}:{StartAt:c,States:{[c]:{Type:`Pass`,End:!0}}};s.Type===`Map`?s.ItemProcessor=l:s.Processor=l}),F=e=>e.Type===`Choice`||j.has(e.Type),et=(e,t,n)=>{let r=e.States[t],i=e.States[n];if(!r||!j.has(r.Type))return;let a=r.Next;(a===void 0||F(i))&&(M(r,n),a!==void 0&&(i.Type===`Choice`?i.Default=a:j.has(i.Type)&&M(i,a)))},tt=(e,t,n)=>{let r=N(e,t);if(n!==void 0&&n!==t.join(`/`)){let{name:e}=T(n);return j.has(r.States[e]?.Type)?e:void 0}return Object.keys(r.States).reverse().find(e=>r.States[e].End===!0)},nt=e=>e.kind===`start`?[]:T(e.source).scope,rt=e=>e.ErrorEquals.length===1&&e.ErrorEquals[0]===`States.ALL`,it=(e,t)=>{if(t.kind===`start`)return e.stateMachine.StartAt||void 0;let{scope:n,name:r}=T(t.source),i=D(e,n)?.States[r];if(i){if(t.kind===`next`)return i.Next;if(t.kind==="default")return i.Type===`Choice`?i.Default:void 0;if(t.kind===`catch`)return`Catch`in i?i.Catch?.find(rt)?.Next:void 0}},at=(e,t,n,r,i)=>{if(i.kind===`start`)return st(e,t,n,r);let{scope:a,name:o}=T(i.source);if(i.kind===`next`)return ot(e,a,t,n,r,o);let s=it(e,i);return A(P(e,a,t,n,r),e=>{let t=N(e,a),r=t.States[o],c=t.States[n];if(r&&(s===void 0||F(c))){if(i.kind===`rule`&&r.Type===`Choice`&&(r.Choices=[...r.Choices??[],{Condition:``,Next:n}]),i.kind==="default"&&r.Type===`Choice`&&(r.Default=n),i.kind===`catch`&&(r.Type===`Task`||r.Type===`Map`||r.Type===`Block`)){let e=r.Catch?.find(rt);e?e.Next=n:r.Catch=[...r.Catch??[],{ErrorEquals:[`States.ALL`],Next:n}]}s!==void 0&&(c.Type===`Choice`?c.Default=s:j.has(c.Type)&&M(c,s))}})},ot=(e,t,n,r,i,a)=>{let o=P(e,t,n,r,i);return a===void 0||b(e)===`data`?o:A(o,e=>et(N(e,t),a,r))},st=(e,t,n,r)=>{let i=e.stateMachine.StartAt??``,a=P(e,[],t,n,r);return b(e)===`data`?a:A(a,e=>{let t=e.stateMachine.States[n];(i===``||F(t))&&(e.stateMachine.StartAt=n,i!==``&&j.has(t.Type)&&M(t,i),i!==``&&t.Type===`Choice`&&(t.Default=i))})},ct=(e,t)=>{`Next`in e&&e.Next===t&&(delete e.Next,e.End=!0),e.Type===`Choice`&&(e.Choices=(e.Choices??[]).filter(e=>e.Next!==t),e.Default===t&&delete e.Default),`Catch`in e&&e.Catch&&(e.Catch=e.Catch.filter(e=>e.Next!==t),e.Catch.length===0&&delete e.Catch)},lt=(e,t)=>A(e,e=>{let{scope:n,name:r}=T(t),i=N(e,n);delete i.States[r];for(let e of Object.values(i.States))ct(e,r);i.StartAt===r&&(i.StartAt=Object.keys(i.States)[0]??``)}),ut=(e,t,n,r)=>A(e,e=>{let{scope:i,name:a}=T(r);if(t===`start`){e.stateMachine.StartAt=a;return}let o=T(n);if(o.scope.join(`/`)!==i.join(`/`))throw Error(`A state leads only to states of its own machine`);let s=N(e,i).States[o.name];s&&(t===`next`&&M(s,a),t===`rule`&&s.Type===`Choice`&&(s.Choices=[...s.Choices??[],{Condition:``,Next:a}]),t==="default"&&s.Type===`Choice`&&(s.Default=a),t===`catch`&&(s.Type===`Task`||s.Type===`Map`||s.Type===`Block`)&&(s.Catch=[...s.Catch??[],{ErrorEquals:[`States.ALL`],Next:a}]))}),dt=(e,t)=>A(e,e=>{if(t.kind===`start`)return;let{scope:n,name:r}=T(t.source),i=N(e,n).States[r];if(!i)return;let a=Number(/\[(\d+)\]/.exec(t.field)?.[1]);t.kind===`next`&&`Next`in i&&(delete i.Next,i.End=!0),t.kind===`rule`&&i.Type===`Choice`&&(i.Choices=i.Choices.filter((e,t)=>t!==a)),t.kind==="default"&&i.Type===`Choice`&&delete i.Default,t.kind===`catch`&&`Catch`in i&&i.Catch&&(i.Catch=i.Catch.filter((e,t)=>t!==a),i.Catch.length===0&&delete i.Catch)}),ft=(e,t,n)=>A(e,e=>{let{scope:r,name:i}=T(t);N(e,r).States[i]=n}),pt=(e,t,n)=>{e.States=Object.fromEntries(Object.entries(e.States).map(([e,r])=>[e===t?n:e,r])),e.StartAt===t&&(e.StartAt=n);for(let r of Object.values(e.States)){if(`Next`in r&&r.Next===t&&(r.Next=n),r.Type===`Choice`){for(let e of r.Choices??[])e.Next===t&&(e.Next=n);r.Default===t&&(r.Default=n)}if(`Catch`in r)for(let e of r.Catch??[])e.Next===t&&(e.Next=n)}},mt=e=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)&&![`true`,`false`,`null`].includes(e)?e:`\`${e}\``,ht=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),I=(e,t,n)=>{if(typeof e==`string`){if(!e.trimStart().startsWith(`{%`))return e;let r=RegExp(`\\$states\\.context\\.Steps\\.(?:${ht(t)}(?![A-Za-z0-9_])|\`${ht(t)}\`)`,`g`);return e.split(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\*[\s\S]*?\*\/)/).map((e,t)=>t%2==1?e:e.replace(r,()=>`$states.context.Steps.${mt(n)}`)).join(``)}return Array.isArray(e)?e.map(e=>I(e,t,n)):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,r])=>[e,I(r,t,n)])):e},gt=(e,t,n)=>A(e,e=>{let{scope:r,name:i}=T(t);pt(N(e,r),i,n),e.stateMachine=I(e.stateMachine,i,n)}),_t=(e,t)=>A(e,e=>{let{scope:n,name:r}=T(t);N(e,n).StartAt=r}),vt=(e,t)=>A(e,e=>{e.trigger=t}),L=e=>typeof e==`object`&&!!e&&!Array.isArray(e),yt=e=>Array.isArray(e.enum)&&e.enum.every(e=>typeof e==`string`)?{kind:`choice`,options:e.enum}:e.type===`string`?{kind:`text`}:e.type===`number`||e.type===`integer`||e.type===`boolean`?{kind:`value`}:e.type===`array`&&L(e.items)&&e.items.type===`string`?{kind:`names`}:{kind:`json`},R=e=>{let t=L(e.properties)?e.properties:{},n=Array.isArray(e.required)?e.required:[];return Object.entries(t).map(([e,t])=>{let r=L(t)?t:{},i=typeof r.title==`string`?r.title:void 0;return{name:e,...yt(r),required:n.includes(e),...i&&{title:i}}})},z=e=>e.message.startsWith(`is missing`),bt=e=>new Map([...e].map(([e,t])=>[e,t.filter(e=>!z(e))])),xt=e=>{let t=new Map,n=[],r=(e,n)=>t.set(e,[...t.get(e)??[],n]);for(let{state:t,field:i,message:a}of e){let e={...i!==void 0&&{field:i},message:a};t===void 0?i?.startsWith(`trigger`)||i===`StartAt`||i===`stateMachine.StartAt`?r(``,e):n.push(e):r(t,e)}return{byNode:t,whole:n}},St=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),Ct=e=>t=>e.flatMap(e=>{let n=t[e.name];return n===void 0||n===``?e.required?[{field:e.name,message:`is missing`}]:[]:e.kind===`names`&&!St(n)?[{field:e.name,message:`is a list of names, separated by commas`}]:[]}),wt=(e,t,n)=>{let r=t.step_types.filter(e=>e.available),i=t.triggers.filter(e=>e.available&&e.id!==`manual`),a=[...t.step_types,...t.triggers].filter(e=>!e.available);return we(e,{resources:r.map(e=>e.id),required:Object.fromEntries(r.map(e=>[e.id,R(e.input).filter(e=>e.required).map(e=>e.name)])),triggers:Object.fromEntries(i.map(e=>[e.id,Ct(R(e.input))])),unavailable:Object.fromEntries(a.map(e=>[e.id,e.reason??``])),versioned:Oe(r.map(e=>e.id)),...n&&{pins:n}})},Tt=e=>{let t=new Map;for(let{state:n,field:r,message:i}of Ce(e))n!==void 0&&t.set(n,[...t.get(n)??[],{...r!==void 0&&{field:r},message:i}]);return t},B=e(n(),1),Et=({problems:e})=>e.length>0&&(0,B.jsxs)(`div`,{className:`rounded-md border border-danger/30 bg-danger-soft px-3 py-2 text-body text-danger-text`,children:[(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,B.jsx)(ie,{className:`size-4`,"aria-hidden":`true`}),e.every(z)?O(`fillInToSave`,{count:e.length}):O(`cannotSave`,{count:e.length})]}),(0,B.jsx)(`ul`,{className:`mt-1 list-disc pl-6`,children:e.map((e,t)=>(0,B.jsx)(`li`,{children:e.field?O(`fieldProblem`,{field:e.field,message:e.message}):e.message},t))})]}),Dt=({warnings:e})=>e.length>0&&(0,B.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning-soft px-3 py-2 text-body text-warning-text`,children:[(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,B.jsx)(te,{className:`size-4`,"aria-hidden":`true`}),O(`warningsSaveAnyway`,{count:e.length})]}),(0,B.jsx)(`ul`,{className:`mt-1 list-disc pl-6`,children:e.map((e,t)=>(0,B.jsx)(`li`,{children:e.field?O(`fieldProblem`,{field:e.field,message:e.message}):e.message},t))})]}),V=e(t(),1),Ot=({name:e,taken:t,disabled:n,onRename:r})=>{let[a,s]=(0,V.useState)(e),c=a.trim(),l=c===``?O(`nameNeeded`):c!==e&&t.includes(c)?O(`nameTaken`):void 0,u=()=>{!l&&c!==e&&r(c)};return(0,B.jsx)(o,{label:O(`name`),error:l,children:(0,B.jsx)(i,{value:a,invalid:!!l,disabled:n,onChange:e=>s(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&u()}})})},H=(e,t)=>{let n=e.filter(e=>e.field===t||e.field?.startsWith(`${t}.`)||e.field?.startsWith(`${t}[`));return n.length>0?n.map(e=>e.message).join(`; `):void 0},U=({label:e,value:t,names:n,none:r,error:i,disabled:a,onChange:s})=>(0,B.jsx)(o,{label:e,error:i,children:(0,B.jsxs)(l,{invalid:!!i,value:t??``,disabled:a,onChange:e=>s(e.target.value===``?void 0:e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:r}),t!==void 0&&!n.includes(t)&&(0,B.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})}),kt=e=>e===void 0?``:typeof e==`string`?e:JSON.stringify(e,null,2),At=e=>{if(e.trim()!==``)try{return JSON.parse(e)}catch(t){if(!(t instanceof SyntaxError))throw t;return e}},jt=e=>{let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length>0?t:void 0},Mt=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):kt(e),Nt=(0,V.createContext)(void 0),Pt=()=>(0,V.useContext)(Nt),Ft=e=>e===``?void 0:e,It={text:Ft,value:At,choice:Ft,json:At,names:jt},W=({label:e,kind:t,options:n=[],required:r,help:a,value:c,error:u,onChange:d,disabled:f,read:p=It[t],write:ee=t===`names`?Mt:kt})=>{let[m,te]=(0,V.useState)(),h=m!==void 0&&JSON.stringify(p(m))===JSON.stringify(c)?m:ee(c),ne=Pt(),g=e=>{te(e),d(p(e))},_=ne!==void 0&&!f&&(c==null||typeof c==`string`)&&(t===`text`||t===`json`||t===`value`);return(0,B.jsxs)(o,{label:e,required:r,help:a,error:u,wide:t===`json`,children:[t===`choice`?(0,B.jsxs)(l,{invalid:!!u,value:h,disabled:f,onChange:e=>d(e.target.value===``?void 0:e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:O(`defaultChoice`)}),n.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]}):t===`json`?(0,B.jsx)(s,{invalid:!!u,rows:2,className:`font-mono text-xs`,value:h,disabled:f,onChange:e=>g(e.target.value)}):(0,B.jsx)(i,{invalid:!!u,value:h,disabled:f,onChange:e=>g(e.target.value)}),_&&(0,B.jsx)(`button`,{type:`button`,"aria-label":O(`insertValueInto`,{field:e}),className:`mt-1 text-xs font-medium text-primary-text hover:underline max-md:min-h-11`,onClick:()=>ne({label:e,value:c,set:d}),children:O(`insertValue`)})]})},Lt=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),Rt=e=>Array.isArray(e)?e.join(`, `):``,G=({state:e,names:t,problems:n,disabled:r,onChange:i})=>{let a=e.Catch??[],o=t=>{let{Catch:n,...r}=e;i(t.length>0?{...r,Catch:t}:r)},s=(e,t)=>o(a.map((n,r)=>r===e?t:n));return(0,B.jsxs)(B.Fragment,{children:[a.map((e,i)=>(0,B.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border border-danger/40 p-3`,children:[(0,B.jsx)(`legend`,{className:`px-1 text-xs font-medium text-danger-text`,children:O(`errorPathNumber`,{number:i+1})}),(0,B.jsx)(W,{label:O(`errors`),kind:`text`,help:O(`errorsHelp`),value:e.ErrorEquals??[],read:Lt,write:Rt,error:H(n,`Catch[${i}].ErrorEquals`),disabled:r,onChange:t=>s(i,{...e,ErrorEquals:t})}),(0,B.jsx)(U,{label:O(`thenGoesTo`),value:e.Next||void 0,names:t,none:O(`chooseStep`),error:H(n,`Catch[${i}].Next`),disabled:r,onChange:t=>s(i,{...e,Next:t??``})}),!r&&(0,B.jsxs)(h,{size:`sm`,variant:`ghost`,className:`self-start`,onClick:()=>o(a.filter((e,t)=>t!==i)),children:[(0,B.jsx)(ve,{className:`size-3.5`}),O(`removeErrorPath`)]})]},i)),!r&&(0,B.jsx)(`div`,{children:(0,B.jsxs)(h,{size:`sm`,onClick:()=>o([...a,{ErrorEquals:[`States.ALL`],Next:``}]),children:[(0,B.jsx)(_,{className:`size-3.5`}),O(`addErrorPath`)]})})]})},zt=({state:e,names:t,problems:n,disabled:r,onChange:i})=>{let a=e.Choices??[],o=(t,n)=>i({...e,Choices:a.map((e,r)=>r===t?n:e)});return(0,B.jsxs)(B.Fragment,{children:[a.map((s,c)=>(0,B.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border p-3`,children:[(0,B.jsx)(`legend`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:O(`ruleNumber`,{number:c+1})}),(0,B.jsx)(W,{label:O(`condition`),kind:`text`,help:O(`conditionHelp`),value:s.Condition,error:H(n,`Choices[${c}].Condition`),disabled:r,onChange:e=>o(c,{...s,Condition:typeof e==`string`?e:``})}),(0,B.jsx)(U,{label:O(`thenGoesTo`),value:s.Next||void 0,names:t,none:O(`chooseStep`),error:H(n,`Choices[${c}].Next`),disabled:r,onChange:e=>o(c,{...s,Next:e??``})}),!r&&(0,B.jsxs)(h,{size:`sm`,variant:`ghost`,className:`self-start`,onClick:()=>i({...e,Choices:a.filter((e,t)=>t!==c)}),children:[(0,B.jsx)(ve,{className:`size-3.5`}),O(`removeRule`)]})]},c)),!r&&(0,B.jsx)(`div`,{children:(0,B.jsxs)(h,{size:`sm`,onClick:()=>i({...e,Choices:[...a,{Condition:``,Next:``}]}),children:[(0,B.jsx)(_,{className:`size-3.5`}),O(`addRule`)]})}),(0,B.jsx)(U,{label:O(`otherwiseGoesTo`),value:e.Default,names:t,none:O(`noDefault`),error:H(n,`Default`),disabled:r,onChange:t=>{let{Default:n,...r}=e;i(t===void 0?r:{...r,Default:t})}})]})},K=(e,t)=>{let{Cache:n,...r}=e;return t===void 0?r:{...r,Cache:t}},Bt=({state:e,types:t,disabled:n,onChange:r})=>{let[i,s]=(0,V.useState)(!1),c=ge(e,t);return c?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(o,{label:O(`cacheResults`),help:O(c.forces?`cacheForceHelp`:`cacheHelp`),children:(0,B.jsx)(a,{checked:c.on,onChange:t=>{if(!n){if(!t)return r(K(e,c.offValue));if(c.disclaimer)return s(!0);r(K(e,!0))}}})}),i&&(0,B.jsx)(p,{title:O(`cacheConfirmTitle`),description:c.disclaimer,onClose:()=>s(!1),actions:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(h,{onClick:()=>s(!1),children:O(`cacheCancel`)}),(0,B.jsx)(h,{variant:`primary`,onClick:()=>(s(!1),r(K(e,!0))),children:O(`cacheConfirm`)})]})})]}):null},Vt=(e,t,n)=>{let{[t]:r,...i}=e;return n==null||n===``?i:{...i,[t]:n}},Ht=(e,t)=>{let{type:n}=x(e.Resource);if(t){let{Cache:t,...r}=e;return{...r,Resource:`${n}${ye}`}}let{HeartbeatSeconds:r,TimeoutSeconds:i,...a}=e;return{...a,Resource:n,...i!==void 0&&i<=xe.taskTimeoutSeconds&&{TimeoutSeconds:i}}},Ut=e=>De(e)===void 0,Wt=(e,t)=>({...e,Resource:`${t}${x(e.Resource).waits&&Ut(t)?ye:``}`}),Gt=(e,t,n)=>{let{[t]:r,...i}=typeof e.Arguments==`object`&&e.Arguments!==null?e.Arguments:{};return{...e,Arguments:n===void 0?i:{...i,[t]:n}}},Kt=({state:e,types:t,problems:n,disabled:r,onChange:i})=>{let s=t.step_types.filter(e=>e.available),{type:c,waits:u}=x(e.Resource),d=Ut(c),f=t.step_types.find(e=>e.id===c),p=typeof e.Arguments==`string`||!f;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(o,{label:O(`stepType`),error:H(n,`Resource`),children:(0,B.jsxs)(l,{value:c,disabled:r,onChange:t=>i(Wt(e,t.target.value)),children:[!s.some(e=>e.id===c)&&(0,B.jsx)(`option`,{value:c,children:me(c,f?.label)}),s.map(e=>(0,B.jsx)(`option`,{value:e.id,children:me(e.id,e.label)},e.id))]})}),p?(0,B.jsx)(W,{label:O(`arguments`),kind:`json`,value:e.Arguments,error:H(n,`Arguments`),disabled:r,onChange:t=>i({...e,Arguments:t??{}})}):R(f.input).map(t=>(0,B.jsx)(W,{label:oe(t.name,t.title),kind:t.kind,options:t.options,required:t.required,...t.kind===`names`&&{help:O(`namesHelp`)},value:e.Arguments?.[t.name],error:H(n,`Arguments.${t.name}`),disabled:r,onChange:n=>i(Gt(e,t.name,n))},`${c}:${t.name}`)),d&&(0,B.jsx)(o,{label:O(`waitsForResult`),help:O(`waitsForResultHelp`),children:(0,B.jsx)(a,{checked:u,onChange:t=>!r&&i(Ht(e,t))})}),u||!d?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(W,{label:O(`waitTimeout`),help:O(`waitTimeoutHelp`),kind:`json`,value:e.TimeoutSeconds,error:H(n,`TimeoutSeconds`),disabled:r,onChange:t=>i(Vt(e,`TimeoutSeconds`,t))}),(0,B.jsx)(W,{label:O(`heartbeatSeconds`),help:O(`heartbeatHelp`),kind:`json`,value:e.HeartbeatSeconds,error:H(n,`HeartbeatSeconds`),disabled:r,onChange:t=>i(Vt(e,`HeartbeatSeconds`,t))})]}):(0,B.jsx)(Bt,{state:e,types:t,disabled:r,onChange:i})]})},q=(e,t,n)=>{let{[t]:r,...i}=e;return n===void 0?i:{...i,[t]:n}},qt=({state:e,problems:t,disabled:n,onChange:r})=>(0,B.jsx)(W,{label:O(`onlyWhen`),kind:`text`,help:O(`onlyWhenHelp`),value:e.Condition,error:H(t,`Condition`),disabled:n,onChange:t=>r(q(e,`Condition`,t))}),J=e=>{let{state:t,names:n,problems:r,disabled:i,onChange:a}=e;if(e.data)return(0,B.jsx)(qt,{...e});let o=t;return(0,B.jsx)(U,{label:O(`goesOnTo`),value:o.Next,names:n,none:O(`endsHere`),error:H(r,`Next`)??H(r,`End`),disabled:i,onChange:e=>{let{Next:t,End:n,...r}=o;a(e===void 0?{...r,End:!0}:{...r,Next:e})}})},Jt=e=>{let{state:t,types:n,problems:r,disabled:i,onChange:a}=e,o=(e,n,o,s)=>(0,B.jsx)(W,{label:n,kind:o,help:s,value:t[e],error:H(r,e),disabled:i,onChange:n=>a(q(t,e,n))});if(t.Type===`Task`)return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Kt,{state:t,types:n,problems:r,disabled:i,onChange:a}),(0,B.jsx)(J,{...e}),!e.data&&(0,B.jsx)(G,{...e,state:t})]});if(t.Type===`Choice`)return(0,B.jsx)(zt,{...e,state:t});if(t.Type===`Map`)return(0,B.jsxs)(B.Fragment,{children:[o(`Items`,O(`items`),`json`,O(`itemsHelp`)),o(`MaxConcurrency`,O(`maxConcurrency`),`json`),(0,B.jsx)(J,{...e}),!e.data&&(0,B.jsx)(G,{...e,state:t})]});if(t.Type===`Block`){let n=(e,n,o,s)=>(0,B.jsx)(W,{label:n,kind:o,help:s,value:t.Cache?.[e],error:H(r,`Cache.${e}`)??(e===`Ttl`?H(r,`Cache`):void 0),disabled:i,onChange:n=>a({...t,Cache:q(t.Cache??{Ttl:``},e,n)})});return(0,B.jsxs)(B.Fragment,{children:[o(`Arguments`,O(`blockArguments`),`json`,O(`blockArgumentsHelp`)),n(`Ttl`,O(`blockTtl`),`text`,O(`blockTtlHelp`)),n(`Key`,O(`blockKey`),`json`,O(`blockKeyHelp`)),(0,B.jsx)(J,{...e}),!e.data&&(0,B.jsx)(G,{...e,state:t})]})}return t.Type===`Wait`?(0,B.jsxs)(B.Fragment,{children:[o(`Seconds`,O(`seconds`),`json`),(0,B.jsx)(J,{...e})]}):t.Type===`Pass`?(0,B.jsxs)(B.Fragment,{children:[o(`Output`,O(`output`),`json`,O(`outputHelp`)),(0,B.jsx)(J,{...e})]}):t.Type===`Succeed`?o(`Output`,O(`output`),`json`,O(`outputHelp`)):t.Type===`Fail`?(0,B.jsxs)(B.Fragment,{children:[e.data&&(0,B.jsx)(qt,{...e}),o(`Error`,O(`error`),`text`),o(`Cause`,O(`cause`),`text`)]}):null},Yt=(e,t,n,r)=>{let{[n]:i,...a}=t;return{[e]:r===void 0?a:{...a,[n]:r}}},Xt=({trigger:e,types:t,problems:n,disabled:r,onChange:i})=>{let a=ue(e),s=t.triggers.filter(e=>e.available),c=s.find(e=>e.id===a),u=a!==void 0&&!c?a:void 0,d=a===void 0?{}:e[a]??{};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(o,{label:O(`startsWhen`),error:H(n,`trigger`),help:u&&O(`triggerOtherHelp`),children:(0,B.jsxs)(l,{value:a??``,disabled:r,onChange:e=>i({[e.target.value]:{}}),children:[u!==void 0&&(0,B.jsx)(`option`,{value:u,children:le(u,t.triggers.find(e=>e.id===u)?.label)}),a===void 0&&(0,B.jsx)(`option`,{value:``,children:O(`triggerUnknown`)}),s.map(e=>(0,B.jsx)(`option`,{value:e.id,children:le(e.id,e.label)},e.id))]})}),c&&R(c.input).map(e=>(0,B.jsx)(W,{label:oe(e.name,e.title),kind:e.kind,options:e.options,required:e.required,...e.kind===`names`&&{help:O(`namesHelp`)},value:d[e.name],error:H(n,`trigger.${c.id}.${e.name}`),disabled:r,onChange:t=>i(Yt(c.id,d,e.name,t))},`${c.id}:${e.name}`)),u!==void 0&&(0,B.jsx)(W,{label:O(`triggerInput`),kind:`json`,value:d,error:H(n,`trigger.${u}`),disabled:!0,onChange:()=>void 0})]})},Zt=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.Type==`string`,Qt=({kind:e,name:t})=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsx)(`h3`,{className:`truncate font-semibold text-foreground`,children:t})]}),$t=({definition:e,types:t,selected:n,problems:r,warnings:i=[],onChange:a,onSelect:o})=>{let s=w(e,n);if(!s)return null;let{scope:c,name:l}=T(n),u=D(e,c),d=!a,f=e=>a?.(e);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Qt,{kind:_e(s,t),name:l}),(0,B.jsx)(Et,{problems:r}),(0,B.jsx)(Dt,{warnings:i}),(0,B.jsx)(Ot,{name:l,taken:Me(e.stateMachine),disabled:d,onRename:t=>{f(gt(e,n,t)),o(je(c,t))}},n),(0,B.jsx)(Jt,{state:s,types:t,names:Object.keys(u.States),problems:r,disabled:d,data:b(e)===`data`,onChange:t=>f(ft(e,n,t))}),(0,B.jsxs)(`details`,{children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-body font-medium text-muted-foreground`,children:O(`asJson`)}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(W,{label:O(`stepJson`),kind:`json`,help:O(`stepJsonHelp`),value:s,disabled:d,onChange:t=>{Zt(t)&&f(ft(e,n,t))}},n)})]}),a&&(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b(e)===`sequence`&&u.StartAt!==l&&(0,B.jsxs)(h,{size:`sm`,onClick:()=>f(_t(e,n)),children:[(0,B.jsx)(Ve,{className:`size-3.5`}),O(`startHere`)]}),(0,B.jsxs)(h,{size:`sm`,variant:`danger`,onClick:()=>{f(lt(e,n)),o(void 0)},children:[(0,B.jsx)(ve,{className:`size-3.5`}),O(`removeStep`)]})]})]})},en=e=>{let{definition:t,types:n,selected:r,problems:i,onChange:a}=e;return(0,B.jsx)(`section`,{"aria-label":O(`chosenStep`),className:`flex flex-col gap-4 rounded-lg border bg-background p-4`,children:r===``?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Qt,{kind:O(`trigger`),name:fe(t.trigger,n)}),(0,B.jsx)(Et,{problems:i}),(0,B.jsx)(Xt,{trigger:t.trigger,types:n,problems:i,disabled:!a,onChange:e=>a?.(vt(t,e))})]}):(0,B.jsx)($t,{...e,selected:r})})},tn=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Y=(e,t,n,r)=>{let i=structuredClone(e),{scope:a,name:o}=T(t),s=D(i,a)?.States[o];if(s&&n[0]===`#condition`)return r===void 0?delete s.Condition:s.Condition=r,i;if(!s||s.Type!==`Task`)return e;tn(s.Arguments)||(s.Arguments={});let c=s.Arguments;for(let e of n.slice(0,-1))tn(c[e])||(c[e]={}),c=c[e];let l=n.at(-1);return r===void 0?delete c[l]:c[l]=r,i},nn=e=>[`=`,`!=`,`>`,`<`,`matches`,`and`,`or`,`not`,...e?[`expression`]:[]],rn=e=>e.kind===`compare`||e.kind===`matches`?{value:``}:{value:e.kind===`logic`&&e.op===`and`},an=e=>e===`not`?{kind:`not`,sides:[{value:!1}]}:e===`and`||e===`or`?{kind:`logic`,op:e,sides:[{value:e===`and`},{value:e===`and`}]}:e===`matches`?{kind:`matches`,sides:[{value:``},{pattern:`.*`,flags:``}]}:{kind:`compare`,op:e,sides:[{value:``},{value:``}]},on=`{% true %}`,sn=(e,t)=>{if(t.length===0)return e;let n=e.sides[t[0]];return n&&y(n)?sn(n,t.slice(1)):void 0},X=(e,t,n)=>({...e,sides:e.sides.map((e,r)=>r===t?n:e)}),Z=(e,t,n)=>{if(t.length===0)return n(e);let r=e.sides[t[0]],i=r&&y(r)?Z(r,t.slice(1),n):void 0;return i&&X(e,t[0],i)},cn=(e,t,n)=>{if(e.kind===`logic`&&t===e.sides.length)return{...e,sides:[...e.sides,n]};if(!(t>=e.sides.length)){if(e.kind===`matches`&&t===1)return!y(n)&&`value`in n&&typeof n.value==`string`?X(e,1,{pattern:n.value||`.*`,flags:e.sides[1].flags}):void 0;if(e.kind!==`compare`&&e.kind!==`matches`||!y(n))return X(e,t,n)}},ln=(e,t,n,r)=>{let i=S(w(e,t)?.Condition),a=i&&n.length>0&&Z(i,n.slice(0,-1),e=>cn(e,n.at(-1),r));return a&&S(C(a))?Y(e,t,[E],C(a)):e},un=(e,t,n,r)=>{let i=w(e,t)?.Condition;if(n.length===0)return i!==void 0&&i!==``?e:Y(e,t,[E],r===`expression`?on:C(an(r)));let a=S(i),o=a&&sn(a,n.slice(0,-1)),s=n.at(-1),c=o?.sides[s],l=o?.kind===`logic`&&s===o.sides.length;return r===`expression`||!o||o.kind===`compare`||o.kind===`matches`||!l&&(!c||y(c)||!(`value`in c))?e:ln(e,t,n,an(r))},dn=(e,t,n)=>{if(n.length===0)return Y(e,t,[E],void 0);let r=S(w(e,t)?.Condition),i=n.at(-1),a=r&&Z(r,n.slice(0,-1),e=>{if(!(i>=e.sides.length))return e.kind===`logic`&&e.sides.length>2?{...e,sides:e.sides.filter((e,t)=>t!==i)}:cn(e,i,rn(e))});return a?Y(e,t,[E],C(a)):e},fn=e=>{let t=[];if(`Next`in e&&e.Next!==void 0&&t.push(e.Next),e.Type===`Choice`){for(let n of e.Choices??[])t.push(n.Next);e.Default!==void 0&&t.push(e.Default)}if(`Catch`in e)for(let n of e.Catch??[])n.Next!==void 0&&t.push(n.Next);return t},pn=(e,t)=>{let n=new Set,r=[t];for(;r.length>0;){let t=r.shift(),i=e.States[t];!n.has(t)&&i&&(n.add(t),r.push(...fn(i)))}return[...n]},mn=e=>e.StartAt===void 0?Object.keys(e.States):pn(e,e.StartAt),hn=e=>{if(e.Resource!==`app:http`||typeof e.Arguments!=`object`||e.Arguments===null)return!1;let t=e.Arguments.method;return t===void 0||typeof t==`string`&&t.toUpperCase()===`GET`},gn=(e,t,n)=>t.flatMap(t=>{let r=e.States[t];if(!r)return[];let i=v(r),a=i?gn(i,mn(i),n):[];return r.Type===`Task`?(n?.step_types.find(e=>e.id===r.Resource)?.writes??!0)===!1||hn(r)?[]:[{name:t,kind:_e(r,n)}]:a}),_n=(e,t)=>{if(!e||t||!(`Assign`in e)||!e.Assign)return e;let n=Object.fromEntries(Object.entries(e.Assign).filter(([,e])=>e!==Ee)),{Assign:r,...i}=e;return Object.keys(n).length===0?i:{...i,Assign:n}},vn=(e,t,n)=>{let r=e?.stateMachine.States[n],i=r!==void 0&&`Output`in r;return JSON.stringify(_n(r,i))!==JSON.stringify(_n(t.stateMachine.States[n],i))},yn=(e,t)=>{let n=Se(e),r=new Set([t]);for(let e=!0;e;){e=!1;for(let[t,i]of n)!r.has(t)&&[...Te(i)].some(e=>r.has(e))&&(r.add(t),e=!0)}return Object.keys(e.States).filter(e=>r.has(e))},bn=(e,t,n=e.stateMachine.StartAt)=>{let r=e.stateMachine;return gn(r,b(e)===`data`?n===void 0?mn(r):yn(r,n):n===void 0?mn(r):pn(r,n),t)},xn=/^[A-Za-z_][A-Za-z0-9_]*$/,Sn=e=>xn.test(e)?e:`\`${e.replaceAll("`",``)}\``,Cn=e=>{let t=JSON.stringify(e)??``;return t.length>60?`${t.slice(0,59)}…`:t},wn=100,Tn=4,En=e=>{let t=[{path:``,sample:Cn(e)}],n=(e,r,i)=>{if(!(i===Tn||typeof r!=`object`||!r||t.length>=wn)){if(Array.isArray(r)){if(r.length===0)return;let a=`${e}[0]`;t.push({path:a,sample:Cn(r[0])}),n(a,r[0],i+1);return}for(let[a,o]of Object.entries(r)){let r=e===``?Sn(a):`${e}.${Sn(a)}`;t.push({path:r,sample:Cn(o)}),n(r,o,i+1)}}};return n(``,e,0),t.slice(0,wn)},Dn=(e,t)=>t===``?e:`${e}${t.startsWith(`[`)?``:`.`}${t}`,On=(e,t)=>{if(e==null||e===``)return`{% ${t} %}`;if(typeof e!=`string`)throw Error(`A value is inserted only into a field that holds text`);let n=/^\{%([\s\S]*)%\}$/.exec(e.trim());return n?`{% (${n[1].trim()}) & ${t} %}`:`{% ${JSON.stringify(e)} & ${t} %}`},kn=(e,t)=>{let{scope:n,name:r}=T(t),i=(e,t,n)=>Object.keys(e.States).filter(n=>n!==t&&pn(e,n).includes(t)).filter(t=>[`Task`,`Map`,`Block`].includes(e.States[t].Type)).map(e=>[...n,e].join(`/`)),a=i(D(e,n),r,n),o=n.findLastIndex((t,r)=>D(e,n.slice(0,r))?.States[n[r]]?.Type===`Block`);return[...n.flatMap((t,r)=>r<=o?[]:i(D(e,n.slice(0,r)),t,n.slice(0,r))),...a]},An=`{% $states.result %}`,jn=(e,t)=>{let{scope:n,name:r}=T(t),i=D(e,n)?.States[r];return i!==void 0&&`Output`in i},Mn=e=>`Assign`in e&&e.Assign?e.Assign:{},Nn=e=>Object.values(e.States).flatMap(e=>[...Object.keys(Mn(e)),...v(e)?Nn(v(e)):[]]),Pn=(e,t)=>{let n=t.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^(\d)/,`step_$1`)||`value`,r=new Set(Nn(e.stateMachine));if(!r.has(n))return n;let i=2;for(;r.has(`${n}_${i}`);)i++;return`${n}_${i}`},Fn=(e,t)=>{let{scope:n,name:r}=T(t),i=D(e,n).States[r],a=Object.entries(Mn(i)).find(([,e])=>e===An);if(a)return{definition:e,variable:a[0],added:!1};let o=Pn(e,r),s=structuredClone(e),c=D(s,n).States[r];return c.Assign={...c.Assign,[o]:An},{definition:s,variable:o,added:!0}},Q=(e,t)=>e.pure.find(e=>e.id===t),In=(e,t)=>{let n=pe(t.handle);if(!n)return;let r=Q(e,t.node);return r?r.kind===`break`?{node:r.source,path:[...r.path,...n]}:void 0:{node:t.node,path:n}},Ln=(e,t)=>{let n=ae(t.handle);if(n===void 0)return;let r=Q(e,t.node);if(!r)return e.inputs.has(t.node)?{step:t.node,keys:[n]}:void 0;if(r.kind===`make`)return{step:r.target,keys:[r.key,n]};if(r.kind===`select`)return{step:r.target,keys:[r.key],select:r};if((r.kind!==`condition`||r.part.kind!==`matches`||n!==`1`)&&r.kind===`condition`&&r.part.kind!==`expression`)return{step:r.target,keys:[E],side:{node:r,at:[...r.at,Number(n)]}}},Rn=(e,t)=>e.path.length===1&&e.path[0]===`#status`&&t.keys.length===1&&t.keys[0]===`#condition`&&!t.side,zn=(e,t,n)=>{let r=Q(e,t.node);if(n===`out`){let n=pe(t.handle);return(r?.kind===`break`?r.outputs:e.outputs.get(t.node)??[]).find(e=>JSON.stringify(e.path)===JSON.stringify(n))?.type}let i=ae(t.handle);if(!(r?.kind===`condition`&&r.part.kind===`compare`||r?.kind===`select`))return(r?.kind===`make`||r?.kind===`condition`?r.inputs:e.inputs.get(t.node)??[]).find(e=>e.key===i)?.type},Bn=(e,t)=>T(t).scope.some((t,n,r)=>w(e,r.slice(0,n+1).join(`/`))?.Type===`Block`),Vn=(e,t)=>{let{scope:n}=T(t);for(let t=n.length;t>0;t--)if(w(e,n.slice(0,t).join(`/`))?.Type===`Block`)return n.slice(0,t).join(`/`)},Hn=(e,t,n)=>{let{scope:r,name:i}=T(t);if(T(n).scope.join(`/`)!==r.join(`/`))return!1;let a=Se(D(e,r)),o=new Set,s=[i];for(;s.length>0;){let e=s.pop();if(e===T(n).name)return!0;o.has(e)||(o.add(e),s.push(...Te(a.get(e)??{data:new Set,status:new Set,handled:new Set})))}return!1},Un=(e,t,n,r)=>{let i=In(t,n),a=Ln(t,r);if(!i||!a)return{reason:`notPins`};let o=Vn(e,a.step);if(o!==void 0&&i.node!==``&&!i.node.startsWith(`${o}/`))return{reason:`otherScope`,step:T(i.node).name};if(b(e)===`data`&&i.node!==``){let[t,n]=[T(i.node).scope.join(`/`),T(a.step).scope.join(`/`)];if(t!==``&&t!==n&&!n.startsWith(`${t}/`))return{reason:`otherScope`,step:T(i.node).name};if(Hn(e,i.node,a.step))return{reason:`notBefore`,step:T(i.node).name};if(i.path[0]!==`#status`&&jn(e,i.node))return{reason:`shapesOutput`,step:T(i.node).name}}else if(i.node===``){if(Bn(e,a.step))return{reason:`notBefore`,step:T(a.step).name}}else{if(!kn(e,a.step).includes(i.node))return{reason:`notBefore`,step:T(i.node).name};if(jn(e,i.node))return{reason:`shapesOutput`,step:T(i.node).name}}if(Rn(i,a))return;let s=zn(t,n,`out`),c=zn(t,r,`in`);if(s&&c&&!be(s,c))return{reason:`type`,source:s,target:c}},Wn=(e,t,n,r)=>{if(Un(e,t,n,r))return e;let i=In(t,n),a=Ln(t,r),o=e,s;if(i.node===``)s={base:{input:!0},path:i.path};else if(i.path[0]===`#status`)s={base:{step:T(i.node).name},path:i.path.slice(1)};else{let t=Fn(e,i.node);o=t.definition,s={base:{variable:t.variable},path:i.path}}let c=`step`in s.base&&s.path.length===0?{...s,path:[`Status`]}:s;return a.side?ln(o,a.step,a.side.at,{read:c}):a.select?Y(o,a.step,a.keys,ke({...a.select.part,operand:{read:c}})):Rn(i,a)?Y(o,a.step,a.keys,C({kind:`compare`,op:`=`,sides:[{read:c},{value:`SUCCEEDED`}]})):Y(o,a.step,a.keys,Ae(s))},Gn=(e,t,n)=>{let r=Ln(t,{node:n.target,handle:n.targetHandle});if(r?.side)return dn(e,r.step,r.side.at);if(r?.select)return Y(e,r.step,r.keys,ke({...r.select.part,operand:{value:``}}));if(r)return Y(e,r.step,r.keys,void 0);let i=Q(t,n.target)??Q(t,n.source);return i?Kn(e,t,i):e},Kn=(e,t,n)=>{if(n.kind===`make`||n.kind===`select`)return Y(e,n.target,[n.key],void 0);if(n.kind===`condition`)return dn(e,n.target,n.at);let r=e=>t.edges.filter(t=>t.source===e.id&&!t.expression).flatMap(e=>{let n=Q(t,e.target);return n?.kind===`break`?r(n):[e]});return he(t,r(n),e=>de(t,e)).reduce((e,n)=>Gn(e,t,n),e)},qn=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,Jn={connect:ut,disconnect:dt,removeState:lt,setArgument:Y,connectData:Wn,disconnectData:Gn,removePure:Kn,wireRefusal:Un,addCondition:un,conditionChoices:nn,setConditionSide:ln,addSelect:(e,t,n)=>{let r=w(e,t)?.Arguments?.[n];if(r!==void 0&&!qn(r)||typeof r==`string`&&r.startsWith(`{%`))return e;let i=r??``;return Y(e,t,[n],ke({operand:{value:``},cases:[{when:``,then:i}],otherwise:i}))}},Yn=(e,t,n={})=>({inputs:Object.fromEntries(e.step_types.map(e=>[e.id,e.input])),outputs:Object.fromEntries([...e.step_types,...e.triggers].flatMap(e=>e.output?[[e.id,e.output]]:[])),records:(e,r)=>{let i=t[e];return i&&Le(i,r,n[e]?.names?.singular??ee(e),Re(e=>t[e]))},emails:t=>{let n=e.templates?.find(e=>e.name===t);return n&&{schema:n.schema,languages:n.languages}}}),Xn=e=>{let{data:t}=ne();return(0,V.useMemo)(()=>Yn(e,t?.resources??{},t?.views),[e,t?.resources,t?.views])},$=d(`app/field-types/workflow-page`),Zn={"app:http":{icon:Ge,keywords:[`api`,`fetch`,`url`,`webhook`,`get`,`post`]},"app:mail.send":{icon:c,keywords:[`email`,`send`,`message`]},"app:records.create":{icon:k,keywords:[`insert`,`add`,`new`,`row`]},"app:records.update":{icon:k,keywords:[`change`,`edit`,`row`]},"app:records.get":{icon:k,keywords:[`read`,`find`,`row`]},"app:records.list":{icon:k,keywords:[`read`,`find`,`query`,`rows`]}},Qn=[{type:`Choice`,icon:Ue,description:()=>$(`flowChoice`),keywords:[`if`,`branch`,`switch`,`condition`]},{type:`Map`,icon:Ye,description:()=>$(`flowMap`),keywords:[`loop`,`each`,`list`,`repeat`]},{type:`Block`,icon:g,description:()=>$(`flowBlock`),keywords:[`cache`,`once`,`group`,`reuse`,`wrap`]},{type:`Wait`,icon:Ze,description:()=>$(`flowWait`),keywords:[`delay`,`sleep`,`pause`,`later`]},{type:`Pass`,icon:qe,description:()=>$(`flowPass`),keywords:[`variable`,`assign`,`transform`]},{type:`Succeed`,icon:m,description:()=>$(`flowSucceed`),keywords:[`end`,`stop`,`done`]},{type:`Fail`,icon:r,description:()=>$(`flowFail`),keywords:[`end`,`stop`,`error`]}],$n=e=>({id:`task:${e.id}`,title:ce(e.id,e.label),description:e.description,keywords:[e.id,...Zn[e.id]?.keywords??[]],icon:Zn[e.id]?.icon??(e.id.startsWith(`app:`)?re:f)}),er=e=>e.slice(0,Math.max(e.indexOf(`:`),0)),tr=e=>e===`custom`?$(`customSteps`):e,nr=e=>{let t=new Set(Object.values(Oe(e.step_types.map(e=>e.id)))),n=e.step_types.filter(e=>e.available&&(!De(e.id)||t.has(e.id))),r=[...new Set(n.map(e=>er(e.id)).filter(e=>e!==`app`))];return[{title:$(`builtIn`),items:n.filter(e=>er(e.id)===`app`).map($n)},...r.map(e=>({title:tr(e),items:n.filter(t=>er(t.id)===e).map($n)})),{title:$(`flow`),items:Qn.map(e=>({id:`type:${e.type}`,title:se(e.type),description:e.description(),keywords:e.keywords,icon:e.icon}))}].filter(e=>e.items.length>0)},rr=e=>e.startsWith(`task:`)?{task:e.slice(5)}:{type:e.slice(5)};export{mt as A,ot as C,it as D,Qe as E,tt as O,P as S,st as T,wt as _,Jn as a,Tt as b,En as c,On as d,vn as f,Et as g,Nt as h,Xn as i,nt as k,jn as l,en as m,nr as n,kn as o,bn as p,$ as r,Dn as s,rr as t,Fn as u,z as v,at as w,bt as x,xt as y};
2
- //# debugId=8201773c-9272-4787-9eaf-fc42c2665d7a
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{Ac as r,Do as i,M as a,R as o,Rn as s,Sc as c,V as l,Vc as u,Xc as d,_c as f,ac as p,cl as ee,jc as m,pc as te,sc as h,ss as ne,xc as g,yc as _,zc as re}from"./app-B94YfKGx.js";import{t as ie}from"./circle-alert-C8YjGdRx.js";import{a as ae,c as oe,d as se,f as ce,g as le,h as ue,i as de,m as fe,o as pe,p as me,r as he,s as ge,u as _e}from"./workflow-canvas-n_YJtaOh.js";import{t as ve}from"./trash-MHAT5Hf3.js";import{A as ye,D as be,F as xe,M as v,_ as Se,a as Ce,c as y,f as we,g as Te,h as b,i as Ee,k as x,m as De,n as Oe,o as S,s as C,u as ke,x as Ae}from"./workflows-Bey4jszG.js";import{E as w,S as je,T,_ as Me,s as E,x as D}from"./use-run-trace-CWGAibgF.js";import{n as O}from"./use-workflow-types-DDh28X2_.js";var Ne={type:`object`,title:`File`,properties:{uri:{type:`string`},name:{type:`string`},type:{type:`string`},size:{type:`integer`}}},Pe=(e,t)=>e.relation&&t?.(e.relation.resource)===`integer`?{type:`integer`}:{type:`string`},Fe=(e,t,n)=>{if(e.file)return t===`read`?Ne:{type:`string`};switch(e.type){case`integer`:return{type:`integer`};case`boolean`:return{type:`boolean`};case`json`:return{};case`enum`:return{type:`string`,...e.enumValues&&{enum:e.enumValues}};case`relation`:return t===`read`?Pe(e,n):{type:[`string`,`integer`]};case`bigint`:return t===`read`?{type:`string`}:{type:[`string`,`integer`]};case`decimal`:return t===`read`?{type:`string`}:{type:[`string`,`number`]};default:return{type:`string`}}},Ie=(e,t,n)=>{let r=Fe(e,t,n);if(t===`read`||!e.nullable||r.type===void 0)return r;let i=Array.isArray(r.type)?r.type:[r.type];return{...r,type:[...i,`null`],...Array.isArray(r.enum)&&{enum:[...r.enum,null]}}},Le=(e,t,n=e.name,r)=>({type:`object`,title:n,properties:Object.fromEntries(Object.values(e.fields).filter(e=>t===`read`||!e.readOnly).map(e=>[e.name,Ie(e,t,r)]))}),Re=e=>t=>{let n=e(t);return n?.primaryKey.length===1?n.fields[n.primaryKey[0]]?.type:void 0},ze={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};ze.node;var k=u(ze),Be={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};Be.node;var Ve=u(Be),He={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};He.node;var Ue=u(He),We={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};We.node;var Ge=u(We),Ke={name:`pen-line`,size:24,node:[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]],aliases:[`edit-3`]};Ke.node;var qe=u(Ke),Je={name:`repeat`,size:24,node:[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]};Je.node;var Ye=u(Je),Xe={name:`timer`,size:24,node:[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]};Xe.node;var Ze=u(Xe),A=(e,t)=>{let n=structuredClone(e);return t(n),n},j=new Set([`Task`,`Pass`,`Wait`,`Map`,`Block`]),M=(e,t)=>{if(!j.has(e.Type))return;let n=e;delete n.End,n.Next=t},N=(e,t)=>{let n=D(e,t);if(!n)throw Error(`No Map or Block at ${t.join(`/`)}`);return n},Qe=(e,t)=>{let n=new Set(Me(e.stateMachine)),r=1;for(;n.has(`${t} ${r}`);)r++;return`${t} ${r}`},$e=e=>`task`in e?{Type:`Task`,Resource:e.task,Arguments:{},End:!0}:e.type===`Choice`?{Type:`Choice`,Choices:[]}:e.type===`Wait`?{Type:`Wait`,Seconds:60,End:!0}:e.type===`Succeed`?{Type:`Succeed`}:e.type===`Fail`?{Type:`Fail`}:e.type===`Pass`?{Type:`Pass`,End:!0}:e.type===`Block`?{Type:`Block`,Processor:{StartAt:``,States:{}},Cache:{Ttl:`1 hour`},End:!0}:{Type:`Map`,Items:`{% [] %}`,ItemProcessor:{StartAt:``,States:{}},End:!0},P=(e,t,n,r,i)=>A(e,e=>{let a=N(e,t),o=b(e)===`data`,s=$e(n);if(o&&delete s.End,a.States[r]=s,!o&&(a.StartAt===void 0||!Object.hasOwn(a.States,a.StartAt))&&(a.StartAt=r),s.Type!==`Map`&&s.Type!==`Block`)return;let c=Qe(e,i),l=o?{States:{[c]:{Type:`Pass`}}}:{StartAt:c,States:{[c]:{Type:`Pass`,End:!0}}};s.Type===`Map`?s.ItemProcessor=l:s.Processor=l}),F=e=>e.Type===`Choice`||j.has(e.Type),et=(e,t,n)=>{let r=e.States[t],i=e.States[n];if(!r||!j.has(r.Type))return;let a=r.Next;(a===void 0||F(i))&&(M(r,n),a!==void 0&&(i.Type===`Choice`?i.Default=a:j.has(i.Type)&&M(i,a)))},tt=(e,t,n)=>{let r=N(e,t);if(n!==void 0&&n!==t.join(`/`)){let{name:e}=T(n);return j.has(r.States[e]?.Type)?e:void 0}return Object.keys(r.States).reverse().find(e=>r.States[e].End===!0)},nt=e=>e.kind===`start`?[]:T(e.source).scope,rt=e=>e.ErrorEquals.length===1&&e.ErrorEquals[0]===`States.ALL`,it=(e,t)=>{if(t.kind===`start`)return e.stateMachine.StartAt||void 0;let{scope:n,name:r}=T(t.source),i=D(e,n)?.States[r];if(i){if(t.kind===`next`)return i.Next;if(t.kind==="default")return i.Type===`Choice`?i.Default:void 0;if(t.kind===`catch`)return`Catch`in i?i.Catch?.find(rt)?.Next:void 0}},at=(e,t,n,r,i)=>{if(i.kind===`start`)return st(e,t,n,r);let{scope:a,name:o}=T(i.source);if(i.kind===`next`)return ot(e,a,t,n,r,o);let s=it(e,i);return A(P(e,a,t,n,r),e=>{let t=N(e,a),r=t.States[o],c=t.States[n];if(r&&(s===void 0||F(c))){if(i.kind===`rule`&&r.Type===`Choice`&&(r.Choices=[...r.Choices??[],{Condition:``,Next:n}]),i.kind==="default"&&r.Type===`Choice`&&(r.Default=n),i.kind===`catch`&&(r.Type===`Task`||r.Type===`Map`||r.Type===`Block`)){let e=r.Catch?.find(rt);e?e.Next=n:r.Catch=[...r.Catch??[],{ErrorEquals:[`States.ALL`],Next:n}]}s!==void 0&&(c.Type===`Choice`?c.Default=s:j.has(c.Type)&&M(c,s))}})},ot=(e,t,n,r,i,a)=>{let o=P(e,t,n,r,i);return a===void 0||b(e)===`data`?o:A(o,e=>et(N(e,t),a,r))},st=(e,t,n,r)=>{let i=e.stateMachine.StartAt??``,a=P(e,[],t,n,r);return b(e)===`data`?a:A(a,e=>{let t=e.stateMachine.States[n];(i===``||F(t))&&(e.stateMachine.StartAt=n,i!==``&&j.has(t.Type)&&M(t,i),i!==``&&t.Type===`Choice`&&(t.Default=i))})},ct=(e,t)=>{`Next`in e&&e.Next===t&&(delete e.Next,e.End=!0),e.Type===`Choice`&&(e.Choices=(e.Choices??[]).filter(e=>e.Next!==t),e.Default===t&&delete e.Default),`Catch`in e&&e.Catch&&(e.Catch=e.Catch.filter(e=>e.Next!==t),e.Catch.length===0&&delete e.Catch)},lt=(e,t)=>A(e,e=>{let{scope:n,name:r}=T(t),i=N(e,n);delete i.States[r];for(let e of Object.values(i.States))ct(e,r);i.StartAt===r&&(i.StartAt=Object.keys(i.States)[0]??``)}),ut=(e,t,n,r)=>A(e,e=>{let{scope:i,name:a}=T(r);if(t===`start`){e.stateMachine.StartAt=a;return}let o=T(n);if(o.scope.join(`/`)!==i.join(`/`))throw Error(`A state leads only to states of its own machine`);let s=N(e,i).States[o.name];s&&(t===`next`&&M(s,a),t===`rule`&&s.Type===`Choice`&&(s.Choices=[...s.Choices??[],{Condition:``,Next:a}]),t==="default"&&s.Type===`Choice`&&(s.Default=a),t===`catch`&&(s.Type===`Task`||s.Type===`Map`||s.Type===`Block`)&&(s.Catch=[...s.Catch??[],{ErrorEquals:[`States.ALL`],Next:a}]))}),dt=(e,t)=>A(e,e=>{if(t.kind===`start`)return;let{scope:n,name:r}=T(t.source),i=N(e,n).States[r];if(!i)return;let a=Number(/\[(\d+)\]/.exec(t.field)?.[1]);t.kind===`next`&&`Next`in i&&(delete i.Next,i.End=!0),t.kind===`rule`&&i.Type===`Choice`&&(i.Choices=i.Choices.filter((e,t)=>t!==a)),t.kind==="default"&&i.Type===`Choice`&&delete i.Default,t.kind===`catch`&&`Catch`in i&&i.Catch&&(i.Catch=i.Catch.filter((e,t)=>t!==a),i.Catch.length===0&&delete i.Catch)}),ft=(e,t,n)=>A(e,e=>{let{scope:r,name:i}=T(t);N(e,r).States[i]=n}),pt=(e,t,n)=>{e.States=Object.fromEntries(Object.entries(e.States).map(([e,r])=>[e===t?n:e,r])),e.StartAt===t&&(e.StartAt=n);for(let r of Object.values(e.States)){if(`Next`in r&&r.Next===t&&(r.Next=n),r.Type===`Choice`){for(let e of r.Choices??[])e.Next===t&&(e.Next=n);r.Default===t&&(r.Default=n)}if(`Catch`in r)for(let e of r.Catch??[])e.Next===t&&(e.Next=n)}},mt=e=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)&&![`true`,`false`,`null`].includes(e)?e:`\`${e}\``,ht=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),I=(e,t,n)=>{if(typeof e==`string`){if(!e.trimStart().startsWith(`{%`))return e;let r=RegExp(`\\$states\\.context\\.Steps\\.(?:${ht(t)}(?![A-Za-z0-9_])|\`${ht(t)}\`)`,`g`);return e.split(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\*[\s\S]*?\*\/)/).map((e,t)=>t%2==1?e:e.replace(r,()=>`$states.context.Steps.${mt(n)}`)).join(``)}return Array.isArray(e)?e.map(e=>I(e,t,n)):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,r])=>[e,I(r,t,n)])):e},gt=(e,t,n)=>A(e,e=>{let{scope:r,name:i}=T(t);pt(N(e,r),i,n),e.stateMachine=I(e.stateMachine,i,n)}),_t=(e,t)=>A(e,e=>{let{scope:n,name:r}=T(t);N(e,n).StartAt=r}),vt=(e,t)=>A(e,e=>{e.trigger=t}),L=e=>typeof e==`object`&&!!e&&!Array.isArray(e),yt=e=>Array.isArray(e.enum)&&e.enum.every(e=>typeof e==`string`)?{kind:`choice`,options:e.enum}:e.type===`string`?{kind:`text`}:e.type===`number`||e.type===`integer`||e.type===`boolean`?{kind:`value`}:e.type===`array`&&L(e.items)&&e.items.type===`string`?{kind:`names`}:{kind:`json`},R=e=>{let t=L(e.properties)?e.properties:{},n=Array.isArray(e.required)?e.required:[];return Object.entries(t).map(([e,t])=>{let r=L(t)?t:{},i=typeof r.title==`string`?r.title:void 0;return{name:e,...yt(r),required:n.includes(e),...i&&{title:i}}})},z=e=>e.message.startsWith(`is missing`),bt=e=>new Map([...e].map(([e,t])=>[e,t.filter(e=>!z(e))])),xt=e=>{let t=new Map,n=[],r=(e,n)=>t.set(e,[...t.get(e)??[],n]);for(let{state:t,field:i,message:a}of e){let e={...i!==void 0&&{field:i},message:a};t===void 0?i?.startsWith(`trigger`)||i===`StartAt`||i===`stateMachine.StartAt`?r(``,e):n.push(e):r(t,e)}return{byNode:t,whole:n}},St=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),Ct=e=>t=>e.flatMap(e=>{let n=t[e.name];return n===void 0||n===``?e.required?[{field:e.name,message:`is missing`}]:[]:e.kind===`names`&&!St(n)?[{field:e.name,message:`is a list of names, separated by commas`}]:[]}),wt=(e,t,n)=>{let r=t.step_types.filter(e=>e.available),i=t.triggers.filter(e=>e.available&&e.id!==`manual`),a=[...t.step_types,...t.triggers].filter(e=>!e.available);return we(e,{resources:r.map(e=>e.id),required:Object.fromEntries(r.map(e=>[e.id,R(e.input).filter(e=>e.required).map(e=>e.name)])),triggers:Object.fromEntries(i.map(e=>[e.id,Ct(R(e.input))])),unavailable:Object.fromEntries(a.map(e=>[e.id,e.reason??``])),versioned:Oe(r.map(e=>e.id)),...n&&{pins:n}})},Tt=e=>{let t=new Map;for(let{state:n,field:r,message:i}of Ce(e))n!==void 0&&t.set(n,[...t.get(n)??[],{...r!==void 0&&{field:r},message:i}]);return t},B=e(n(),1),Et=({problems:e})=>e.length>0&&(0,B.jsxs)(`div`,{className:`rounded-md border border-danger/30 bg-danger-soft px-3 py-2 text-body text-danger-text`,children:[(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,B.jsx)(ie,{className:`size-4`,"aria-hidden":`true`}),e.every(z)?O(`fillInToSave`,{count:e.length}):O(`cannotSave`,{count:e.length})]}),(0,B.jsx)(`ul`,{className:`mt-1 list-disc pl-6`,children:e.map((e,t)=>(0,B.jsx)(`li`,{children:e.field?O(`fieldProblem`,{field:e.field,message:e.message}):e.message},t))})]}),Dt=({warnings:e})=>e.length>0&&(0,B.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning-soft px-3 py-2 text-body text-warning-text`,children:[(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,B.jsx)(te,{className:`size-4`,"aria-hidden":`true`}),O(`warningsSaveAnyway`,{count:e.length})]}),(0,B.jsx)(`ul`,{className:`mt-1 list-disc pl-6`,children:e.map((e,t)=>(0,B.jsx)(`li`,{children:e.field?O(`fieldProblem`,{field:e.field,message:e.message}):e.message},t))})]}),V=e(t(),1),Ot=({name:e,taken:t,disabled:n,onRename:r})=>{let[a,s]=(0,V.useState)(e),c=a.trim(),l=c===``?O(`nameNeeded`):c!==e&&t.includes(c)?O(`nameTaken`):void 0,u=()=>{!l&&c!==e&&r(c)};return(0,B.jsx)(o,{label:O(`name`),error:l,children:(0,B.jsx)(i,{value:a,invalid:!!l,disabled:n,onChange:e=>s(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&u()}})})},H=(e,t)=>{let n=e.filter(e=>e.field===t||e.field?.startsWith(`${t}.`)||e.field?.startsWith(`${t}[`));return n.length>0?n.map(e=>e.message).join(`; `):void 0},U=({label:e,value:t,names:n,none:r,error:i,disabled:a,onChange:s})=>(0,B.jsx)(o,{label:e,error:i,children:(0,B.jsxs)(l,{invalid:!!i,value:t??``,disabled:a,onChange:e=>s(e.target.value===``?void 0:e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:r}),t!==void 0&&!n.includes(t)&&(0,B.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})}),kt=e=>e===void 0?``:typeof e==`string`?e:JSON.stringify(e,null,2),At=e=>{if(e.trim()!==``)try{return JSON.parse(e)}catch(t){if(!(t instanceof SyntaxError))throw t;return e}},jt=e=>{let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length>0?t:void 0},Mt=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)?e.join(`, `):kt(e),Nt=(0,V.createContext)(void 0),Pt=()=>(0,V.useContext)(Nt),Ft=e=>e===``?void 0:e,It={text:Ft,value:At,choice:Ft,json:At,names:jt},W=({label:e,kind:t,options:n=[],required:r,help:a,value:c,error:u,onChange:d,disabled:f,read:p=It[t],write:ee=t===`names`?Mt:kt})=>{let[m,te]=(0,V.useState)(),h=m!==void 0&&JSON.stringify(p(m))===JSON.stringify(c)?m:ee(c),ne=Pt(),g=e=>{te(e),d(p(e))},_=ne!==void 0&&!f&&(c==null||typeof c==`string`)&&(t===`text`||t===`json`||t===`value`);return(0,B.jsxs)(o,{label:e,required:r,help:a,error:u,wide:t===`json`,children:[t===`choice`?(0,B.jsxs)(l,{invalid:!!u,value:h,disabled:f,onChange:e=>d(e.target.value===``?void 0:e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:O(`defaultChoice`)}),n.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]}):t===`json`?(0,B.jsx)(s,{invalid:!!u,rows:2,className:`font-mono text-xs`,value:h,disabled:f,onChange:e=>g(e.target.value)}):(0,B.jsx)(i,{invalid:!!u,value:h,disabled:f,onChange:e=>g(e.target.value)}),_&&(0,B.jsx)(`button`,{type:`button`,"aria-label":O(`insertValueInto`,{field:e}),className:`mt-1 text-xs font-medium text-primary-text hover:underline max-md:min-h-11`,onClick:()=>ne({label:e,value:c,set:d}),children:O(`insertValue`)})]})},Lt=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),Rt=e=>Array.isArray(e)?e.join(`, `):``,G=({state:e,names:t,problems:n,disabled:r,onChange:i})=>{let a=e.Catch??[],o=t=>{let{Catch:n,...r}=e;i(t.length>0?{...r,Catch:t}:r)},s=(e,t)=>o(a.map((n,r)=>r===e?t:n));return(0,B.jsxs)(B.Fragment,{children:[a.map((e,i)=>(0,B.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border border-danger/40 p-3`,children:[(0,B.jsx)(`legend`,{className:`px-1 text-xs font-medium text-danger-text`,children:O(`errorPathNumber`,{number:i+1})}),(0,B.jsx)(W,{label:O(`errors`),kind:`text`,help:O(`errorsHelp`),value:e.ErrorEquals??[],read:Lt,write:Rt,error:H(n,`Catch[${i}].ErrorEquals`),disabled:r,onChange:t=>s(i,{...e,ErrorEquals:t})}),(0,B.jsx)(U,{label:O(`thenGoesTo`),value:e.Next||void 0,names:t,none:O(`chooseStep`),error:H(n,`Catch[${i}].Next`),disabled:r,onChange:t=>s(i,{...e,Next:t??``})}),!r&&(0,B.jsxs)(h,{size:`sm`,variant:`ghost`,className:`self-start`,onClick:()=>o(a.filter((e,t)=>t!==i)),children:[(0,B.jsx)(ve,{className:`size-3.5`}),O(`removeErrorPath`)]})]},i)),!r&&(0,B.jsx)(`div`,{children:(0,B.jsxs)(h,{size:`sm`,onClick:()=>o([...a,{ErrorEquals:[`States.ALL`],Next:``}]),children:[(0,B.jsx)(_,{className:`size-3.5`}),O(`addErrorPath`)]})})]})},zt=({state:e,names:t,problems:n,disabled:r,onChange:i})=>{let a=e.Choices??[],o=(t,n)=>i({...e,Choices:a.map((e,r)=>r===t?n:e)});return(0,B.jsxs)(B.Fragment,{children:[a.map((s,c)=>(0,B.jsxs)(`fieldset`,{className:`flex flex-col gap-3 rounded-md border p-3`,children:[(0,B.jsx)(`legend`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:O(`ruleNumber`,{number:c+1})}),(0,B.jsx)(W,{label:O(`condition`),kind:`text`,help:O(`conditionHelp`),value:s.Condition,error:H(n,`Choices[${c}].Condition`),disabled:r,onChange:e=>o(c,{...s,Condition:typeof e==`string`?e:``})}),(0,B.jsx)(U,{label:O(`thenGoesTo`),value:s.Next||void 0,names:t,none:O(`chooseStep`),error:H(n,`Choices[${c}].Next`),disabled:r,onChange:e=>o(c,{...s,Next:e??``})}),!r&&(0,B.jsxs)(h,{size:`sm`,variant:`ghost`,className:`self-start`,onClick:()=>i({...e,Choices:a.filter((e,t)=>t!==c)}),children:[(0,B.jsx)(ve,{className:`size-3.5`}),O(`removeRule`)]})]},c)),!r&&(0,B.jsx)(`div`,{children:(0,B.jsxs)(h,{size:`sm`,onClick:()=>i({...e,Choices:[...a,{Condition:``,Next:``}]}),children:[(0,B.jsx)(_,{className:`size-3.5`}),O(`addRule`)]})}),(0,B.jsx)(U,{label:O(`otherwiseGoesTo`),value:e.Default,names:t,none:O(`noDefault`),error:H(n,`Default`),disabled:r,onChange:t=>{let{Default:n,...r}=e;i(t===void 0?r:{...r,Default:t})}})]})},K=(e,t)=>{let{Cache:n,...r}=e;return t===void 0?r:{...r,Cache:t}},Bt=({state:e,types:t,disabled:n,onChange:r})=>{let[i,s]=(0,V.useState)(!1),c=ge(e,t);return c?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(o,{label:O(`cacheResults`),help:O(c.forces?`cacheForceHelp`:`cacheHelp`),children:(0,B.jsx)(a,{checked:c.on,onChange:t=>{if(!n){if(!t)return r(K(e,c.offValue));if(c.disclaimer)return s(!0);r(K(e,!0))}}})}),i&&(0,B.jsx)(p,{title:O(`cacheConfirmTitle`),description:c.disclaimer,onClose:()=>s(!1),actions:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(h,{onClick:()=>s(!1),children:O(`cacheCancel`)}),(0,B.jsx)(h,{variant:`primary`,onClick:()=>(s(!1),r(K(e,!0))),children:O(`cacheConfirm`)})]})})]}):null},Vt=(e,t,n)=>{let{[t]:r,...i}=e;return n==null||n===``?i:{...i,[t]:n}},Ht=(e,t)=>{let{type:n}=x(e.Resource);if(t){let{Cache:t,...r}=e;return{...r,Resource:`${n}${ye}`}}let{HeartbeatSeconds:r,TimeoutSeconds:i,...a}=e;return{...a,Resource:n,...i!==void 0&&i<=xe.taskTimeoutSeconds&&{TimeoutSeconds:i}}},Ut=e=>De(e)===void 0,Wt=(e,t)=>({...e,Resource:`${t}${x(e.Resource).waits&&Ut(t)?ye:``}`}),Gt=(e,t,n)=>{let{[t]:r,...i}=typeof e.Arguments==`object`&&e.Arguments!==null?e.Arguments:{};return{...e,Arguments:n===void 0?i:{...i,[t]:n}}},Kt=({state:e,types:t,problems:n,disabled:r,onChange:i})=>{let s=t.step_types.filter(e=>e.available),{type:c,waits:u}=x(e.Resource),d=Ut(c),f=t.step_types.find(e=>e.id===c),p=typeof e.Arguments==`string`||!f;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(o,{label:O(`stepType`),error:H(n,`Resource`),children:(0,B.jsxs)(l,{value:c,disabled:r,onChange:t=>i(Wt(e,t.target.value)),children:[!s.some(e=>e.id===c)&&(0,B.jsx)(`option`,{value:c,children:me(c,f?.label)}),s.map(e=>(0,B.jsx)(`option`,{value:e.id,children:me(e.id,e.label)},e.id))]})}),p?(0,B.jsx)(W,{label:O(`arguments`),kind:`json`,value:e.Arguments,error:H(n,`Arguments`),disabled:r,onChange:t=>i({...e,Arguments:t??{}})}):R(f.input).map(t=>(0,B.jsx)(W,{label:oe(t.name,t.title),kind:t.kind,options:t.options,required:t.required,...t.kind===`names`&&{help:O(`namesHelp`)},value:e.Arguments?.[t.name],error:H(n,`Arguments.${t.name}`),disabled:r,onChange:n=>i(Gt(e,t.name,n))},`${c}:${t.name}`)),d&&(0,B.jsx)(o,{label:O(`waitsForResult`),help:O(`waitsForResultHelp`),children:(0,B.jsx)(a,{checked:u,onChange:t=>!r&&i(Ht(e,t))})}),u||!d?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(W,{label:O(`waitTimeout`),help:O(`waitTimeoutHelp`),kind:`json`,value:e.TimeoutSeconds,error:H(n,`TimeoutSeconds`),disabled:r,onChange:t=>i(Vt(e,`TimeoutSeconds`,t))}),(0,B.jsx)(W,{label:O(`heartbeatSeconds`),help:O(`heartbeatHelp`),kind:`json`,value:e.HeartbeatSeconds,error:H(n,`HeartbeatSeconds`),disabled:r,onChange:t=>i(Vt(e,`HeartbeatSeconds`,t))})]}):(0,B.jsx)(Bt,{state:e,types:t,disabled:r,onChange:i})]})},q=(e,t,n)=>{let{[t]:r,...i}=e;return n===void 0?i:{...i,[t]:n}},qt=({state:e,problems:t,disabled:n,onChange:r})=>(0,B.jsx)(W,{label:O(`onlyWhen`),kind:`text`,help:O(`onlyWhenHelp`),value:e.Condition,error:H(t,`Condition`),disabled:n,onChange:t=>r(q(e,`Condition`,t))}),J=e=>{let{state:t,names:n,problems:r,disabled:i,onChange:a}=e;if(e.data)return(0,B.jsx)(qt,{...e});let o=t;return(0,B.jsx)(U,{label:O(`goesOnTo`),value:o.Next,names:n,none:O(`endsHere`),error:H(r,`Next`)??H(r,`End`),disabled:i,onChange:e=>{let{Next:t,End:n,...r}=o;a(e===void 0?{...r,End:!0}:{...r,Next:e})}})},Jt=e=>{let{state:t,types:n,problems:r,disabled:i,onChange:a}=e,o=(e,n,o,s)=>(0,B.jsx)(W,{label:n,kind:o,help:s,value:t[e],error:H(r,e),disabled:i,onChange:n=>a(q(t,e,n))});if(t.Type===`Task`)return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Kt,{state:t,types:n,problems:r,disabled:i,onChange:a}),(0,B.jsx)(J,{...e}),!e.data&&(0,B.jsx)(G,{...e,state:t})]});if(t.Type===`Choice`)return(0,B.jsx)(zt,{...e,state:t});if(t.Type===`Map`)return(0,B.jsxs)(B.Fragment,{children:[o(`Items`,O(`items`),`json`,O(`itemsHelp`)),o(`MaxConcurrency`,O(`maxConcurrency`),`json`),(0,B.jsx)(J,{...e}),!e.data&&(0,B.jsx)(G,{...e,state:t})]});if(t.Type===`Block`){let n=(e,n,o,s)=>(0,B.jsx)(W,{label:n,kind:o,help:s,value:t.Cache?.[e],error:H(r,`Cache.${e}`)??(e===`Ttl`?H(r,`Cache`):void 0),disabled:i,onChange:n=>a({...t,Cache:q(t.Cache??{Ttl:``},e,n)})});return(0,B.jsxs)(B.Fragment,{children:[o(`Arguments`,O(`blockArguments`),`json`,O(`blockArgumentsHelp`)),n(`Ttl`,O(`blockTtl`),`text`,O(`blockTtlHelp`)),n(`Key`,O(`blockKey`),`json`,O(`blockKeyHelp`)),(0,B.jsx)(J,{...e}),!e.data&&(0,B.jsx)(G,{...e,state:t})]})}return t.Type===`Wait`?(0,B.jsxs)(B.Fragment,{children:[o(`Seconds`,O(`seconds`),`json`),(0,B.jsx)(J,{...e})]}):t.Type===`Pass`?(0,B.jsxs)(B.Fragment,{children:[o(`Output`,O(`output`),`json`,O(`outputHelp`)),(0,B.jsx)(J,{...e})]}):t.Type===`Succeed`?o(`Output`,O(`output`),`json`,O(`outputHelp`)):t.Type===`Fail`?(0,B.jsxs)(B.Fragment,{children:[e.data&&(0,B.jsx)(qt,{...e}),o(`Error`,O(`error`),`text`),o(`Cause`,O(`cause`),`text`)]}):null},Yt=(e,t,n,r)=>{let{[n]:i,...a}=t;return{[e]:r===void 0?a:{...a,[n]:r}}},Xt=({trigger:e,types:t,problems:n,disabled:r,onChange:i})=>{let a=ue(e),s=t.triggers.filter(e=>e.available),c=s.find(e=>e.id===a),u=a!==void 0&&!c?a:void 0,d=a===void 0?{}:e[a]??{};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(o,{label:O(`startsWhen`),error:H(n,`trigger`),help:u&&O(`triggerOtherHelp`),children:(0,B.jsxs)(l,{value:a??``,disabled:r,onChange:e=>i({[e.target.value]:{}}),children:[u!==void 0&&(0,B.jsx)(`option`,{value:u,children:le(u,t.triggers.find(e=>e.id===u)?.label)}),a===void 0&&(0,B.jsx)(`option`,{value:``,children:O(`triggerUnknown`)}),s.map(e=>(0,B.jsx)(`option`,{value:e.id,children:le(e.id,e.label)},e.id))]})}),c&&R(c.input).map(e=>(0,B.jsx)(W,{label:oe(e.name,e.title),kind:e.kind,options:e.options,required:e.required,...e.kind===`names`&&{help:O(`namesHelp`)},value:d[e.name],error:H(n,`trigger.${c.id}.${e.name}`),disabled:r,onChange:t=>i(Yt(c.id,d,e.name,t))},`${c.id}:${e.name}`)),u!==void 0&&(0,B.jsx)(W,{label:O(`triggerInput`),kind:`json`,value:d,error:H(n,`trigger.${u}`),disabled:!0,onChange:()=>void 0})]})},Zt=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.Type==`string`,Qt=({kind:e,name:t})=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsx)(`h3`,{className:`truncate font-semibold text-foreground`,children:t})]}),$t=({definition:e,types:t,selected:n,problems:r,warnings:i=[],onChange:a,onSelect:o})=>{let s=w(e,n);if(!s)return null;let{scope:c,name:l}=T(n),u=D(e,c),d=!a,f=e=>a?.(e);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Qt,{kind:_e(s,t),name:l}),(0,B.jsx)(Et,{problems:r}),(0,B.jsx)(Dt,{warnings:i}),(0,B.jsx)(Ot,{name:l,taken:Me(e.stateMachine),disabled:d,onRename:t=>{f(gt(e,n,t)),o(je(c,t))}},n),(0,B.jsx)(Jt,{state:s,types:t,names:Object.keys(u.States),problems:r,disabled:d,data:b(e)===`data`,onChange:t=>f(ft(e,n,t))}),(0,B.jsxs)(`details`,{children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-body font-medium text-muted-foreground`,children:O(`asJson`)}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(W,{label:O(`stepJson`),kind:`json`,help:O(`stepJsonHelp`),value:s,disabled:d,onChange:t=>{Zt(t)&&f(ft(e,n,t))}},n)})]}),a&&(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b(e)===`sequence`&&u.StartAt!==l&&(0,B.jsxs)(h,{size:`sm`,onClick:()=>f(_t(e,n)),children:[(0,B.jsx)(Ve,{className:`size-3.5`}),O(`startHere`)]}),(0,B.jsxs)(h,{size:`sm`,variant:`danger`,onClick:()=>{f(lt(e,n)),o(void 0)},children:[(0,B.jsx)(ve,{className:`size-3.5`}),O(`removeStep`)]})]})]})},en=e=>{let{definition:t,types:n,selected:r,problems:i,onChange:a}=e;return(0,B.jsx)(`section`,{"aria-label":O(`chosenStep`),className:`flex flex-col gap-4 rounded-lg border bg-background p-4`,children:r===``?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Qt,{kind:O(`trigger`),name:fe(t.trigger,n)}),(0,B.jsx)(Et,{problems:i}),(0,B.jsx)(Xt,{trigger:t.trigger,types:n,problems:i,disabled:!a,onChange:e=>a?.(vt(t,e))})]}):(0,B.jsx)($t,{...e,selected:r})})},tn=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Y=(e,t,n,r)=>{let i=structuredClone(e),{scope:a,name:o}=T(t),s=D(i,a)?.States[o];if(s&&n[0]===`#condition`)return r===void 0?delete s.Condition:s.Condition=r,i;if(!s||s.Type!==`Task`)return e;tn(s.Arguments)||(s.Arguments={});let c=s.Arguments;for(let e of n.slice(0,-1))tn(c[e])||(c[e]={}),c=c[e];let l=n.at(-1);return r===void 0?delete c[l]:c[l]=r,i},nn=e=>[`=`,`!=`,`>`,`<`,`matches`,`and`,`or`,`not`,...e?[`expression`]:[]],rn=e=>e.kind===`compare`||e.kind===`matches`?{value:``}:{value:e.kind===`logic`&&e.op===`and`},an=e=>e===`not`?{kind:`not`,sides:[{value:!1}]}:e===`and`||e===`or`?{kind:`logic`,op:e,sides:[{value:e===`and`},{value:e===`and`}]}:e===`matches`?{kind:`matches`,sides:[{value:``},{pattern:`.*`,flags:``}]}:{kind:`compare`,op:e,sides:[{value:``},{value:``}]},on=`{% true %}`,sn=(e,t)=>{if(t.length===0)return e;let n=e.sides[t[0]];return n&&y(n)?sn(n,t.slice(1)):void 0},X=(e,t,n)=>({...e,sides:e.sides.map((e,r)=>r===t?n:e)}),Z=(e,t,n)=>{if(t.length===0)return n(e);let r=e.sides[t[0]],i=r&&y(r)?Z(r,t.slice(1),n):void 0;return i&&X(e,t[0],i)},cn=(e,t,n)=>{if(e.kind===`logic`&&t===e.sides.length)return{...e,sides:[...e.sides,n]};if(!(t>=e.sides.length)){if(e.kind===`matches`&&t===1)return!y(n)&&`value`in n&&typeof n.value==`string`?X(e,1,{pattern:n.value||`.*`,flags:e.sides[1].flags}):void 0;if(e.kind!==`compare`&&e.kind!==`matches`||!y(n))return X(e,t,n)}},ln=(e,t,n,r)=>{let i=S(w(e,t)?.Condition),a=i&&n.length>0&&Z(i,n.slice(0,-1),e=>cn(e,n.at(-1),r));return a&&S(C(a))?Y(e,t,[E],C(a)):e},un=(e,t,n,r)=>{let i=w(e,t)?.Condition;if(n.length===0)return i!==void 0&&i!==``?e:Y(e,t,[E],r===`expression`?on:C(an(r)));let a=S(i),o=a&&sn(a,n.slice(0,-1)),s=n.at(-1),c=o?.sides[s],l=o?.kind===`logic`&&s===o.sides.length;return r===`expression`||!o||o.kind===`compare`||o.kind===`matches`||!l&&(!c||y(c)||!(`value`in c))?e:ln(e,t,n,an(r))},dn=(e,t,n)=>{if(n.length===0)return Y(e,t,[E],void 0);let r=S(w(e,t)?.Condition),i=n.at(-1),a=r&&Z(r,n.slice(0,-1),e=>{if(!(i>=e.sides.length))return e.kind===`logic`&&e.sides.length>2?{...e,sides:e.sides.filter((e,t)=>t!==i)}:cn(e,i,rn(e))});return a?Y(e,t,[E],C(a)):e},fn=e=>{let t=[];if(`Next`in e&&e.Next!==void 0&&t.push(e.Next),e.Type===`Choice`){for(let n of e.Choices??[])t.push(n.Next);e.Default!==void 0&&t.push(e.Default)}if(`Catch`in e)for(let n of e.Catch??[])n.Next!==void 0&&t.push(n.Next);return t},pn=(e,t)=>{let n=new Set,r=[t];for(;r.length>0;){let t=r.shift(),i=e.States[t];!n.has(t)&&i&&(n.add(t),r.push(...fn(i)))}return[...n]},mn=e=>e.StartAt===void 0?Object.keys(e.States):pn(e,e.StartAt),hn=e=>{if(e.Resource!==`app:http`||typeof e.Arguments!=`object`||e.Arguments===null)return!1;let t=e.Arguments.method;return t===void 0||typeof t==`string`&&t.toUpperCase()===`GET`},gn=(e,t,n)=>t.flatMap(t=>{let r=e.States[t];if(!r)return[];let i=v(r),a=i?gn(i,mn(i),n):[];return r.Type===`Task`?(n?.step_types.find(e=>e.id===r.Resource)?.writes??!0)===!1||hn(r)?[]:[{name:t,kind:_e(r,n)}]:a}),_n=(e,t)=>{if(!e||t||!(`Assign`in e)||!e.Assign)return e;let n=Object.fromEntries(Object.entries(e.Assign).filter(([,e])=>e!==Ee)),{Assign:r,...i}=e;return Object.keys(n).length===0?i:{...i,Assign:n}},vn=(e,t,n)=>{let r=e?.stateMachine.States[n],i=r!==void 0&&`Output`in r;return JSON.stringify(_n(r,i))!==JSON.stringify(_n(t.stateMachine.States[n],i))},yn=(e,t)=>{let n=Se(e),r=new Set([t]);for(let e=!0;e;){e=!1;for(let[t,i]of n)!r.has(t)&&[...Te(i)].some(e=>r.has(e))&&(r.add(t),e=!0)}return Object.keys(e.States).filter(e=>r.has(e))},bn=(e,t,n=e.stateMachine.StartAt)=>{let r=e.stateMachine;return gn(r,b(e)===`data`?n===void 0?mn(r):yn(r,n):n===void 0?mn(r):pn(r,n),t)},xn=/^[A-Za-z_][A-Za-z0-9_]*$/,Sn=e=>xn.test(e)?e:`\`${e.replaceAll("`",``)}\``,Cn=e=>{let t=JSON.stringify(e)??``;return t.length>60?`${t.slice(0,59)}…`:t},wn=100,Tn=4,En=e=>{let t=[{path:``,sample:Cn(e)}],n=(e,r,i)=>{if(!(i===Tn||typeof r!=`object`||!r||t.length>=wn)){if(Array.isArray(r)){if(r.length===0)return;let a=`${e}[0]`;t.push({path:a,sample:Cn(r[0])}),n(a,r[0],i+1);return}for(let[a,o]of Object.entries(r)){let r=e===``?Sn(a):`${e}.${Sn(a)}`;t.push({path:r,sample:Cn(o)}),n(r,o,i+1)}}};return n(``,e,0),t.slice(0,wn)},Dn=(e,t)=>t===``?e:`${e}${t.startsWith(`[`)?``:`.`}${t}`,On=(e,t)=>{if(e==null||e===``)return`{% ${t} %}`;if(typeof e!=`string`)throw Error(`A value is inserted only into a field that holds text`);let n=/^\{%([\s\S]*)%\}$/.exec(e.trim());return n?`{% (${n[1].trim()}) & ${t} %}`:`{% ${JSON.stringify(e)} & ${t} %}`},kn=(e,t)=>{let{scope:n,name:r}=T(t),i=(e,t,n)=>Object.keys(e.States).filter(n=>n!==t&&pn(e,n).includes(t)).filter(t=>[`Task`,`Map`,`Block`].includes(e.States[t].Type)).map(e=>[...n,e].join(`/`)),a=i(D(e,n),r,n),o=n.findLastIndex((t,r)=>D(e,n.slice(0,r))?.States[n[r]]?.Type===`Block`);return[...n.flatMap((t,r)=>r<=o?[]:i(D(e,n.slice(0,r)),t,n.slice(0,r))),...a]},An=`{% $states.result %}`,jn=(e,t)=>{let{scope:n,name:r}=T(t),i=D(e,n)?.States[r];return i!==void 0&&`Output`in i},Mn=e=>`Assign`in e&&e.Assign?e.Assign:{},Nn=e=>Object.values(e.States).flatMap(e=>[...Object.keys(Mn(e)),...v(e)?Nn(v(e)):[]]),Pn=(e,t)=>{let n=t.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^(\d)/,`step_$1`)||`value`,r=new Set(Nn(e.stateMachine));if(!r.has(n))return n;let i=2;for(;r.has(`${n}_${i}`);)i++;return`${n}_${i}`},Fn=(e,t)=>{let{scope:n,name:r}=T(t),i=D(e,n).States[r],a=Object.entries(Mn(i)).find(([,e])=>e===An);if(a)return{definition:e,variable:a[0],added:!1};let o=Pn(e,r),s=structuredClone(e),c=D(s,n).States[r];return c.Assign={...c.Assign,[o]:An},{definition:s,variable:o,added:!0}},Q=(e,t)=>e.pure.find(e=>e.id===t),In=(e,t)=>{let n=pe(t.handle);if(!n)return;let r=Q(e,t.node);return r?r.kind===`break`?{node:r.source,path:[...r.path,...n]}:void 0:{node:t.node,path:n}},Ln=(e,t)=>{let n=ae(t.handle);if(n===void 0)return;let r=Q(e,t.node);if(!r)return e.inputs.has(t.node)?{step:t.node,keys:[n]}:void 0;if(r.kind===`make`)return{step:r.target,keys:[r.key,n]};if(r.kind===`select`)return{step:r.target,keys:[r.key],select:r};if((r.kind!==`condition`||r.part.kind!==`matches`||n!==`1`)&&r.kind===`condition`&&r.part.kind!==`expression`)return{step:r.target,keys:[E],side:{node:r,at:[...r.at,Number(n)]}}},Rn=(e,t)=>e.path.length===1&&e.path[0]===`#status`&&t.keys.length===1&&t.keys[0]===`#condition`&&!t.side,zn=(e,t,n)=>{let r=Q(e,t.node);if(n===`out`){let n=pe(t.handle);return(r?.kind===`break`?r.outputs:e.outputs.get(t.node)??[]).find(e=>JSON.stringify(e.path)===JSON.stringify(n))?.type}let i=ae(t.handle);if(!(r?.kind===`condition`&&r.part.kind===`compare`||r?.kind===`select`))return(r?.kind===`make`||r?.kind===`condition`?r.inputs:e.inputs.get(t.node)??[]).find(e=>e.key===i)?.type},Bn=(e,t)=>T(t).scope.some((t,n,r)=>w(e,r.slice(0,n+1).join(`/`))?.Type===`Block`),Vn=(e,t)=>{let{scope:n}=T(t);for(let t=n.length;t>0;t--)if(w(e,n.slice(0,t).join(`/`))?.Type===`Block`)return n.slice(0,t).join(`/`)},Hn=(e,t,n)=>{let{scope:r,name:i}=T(t);if(T(n).scope.join(`/`)!==r.join(`/`))return!1;let a=Se(D(e,r)),o=new Set,s=[i];for(;s.length>0;){let e=s.pop();if(e===T(n).name)return!0;o.has(e)||(o.add(e),s.push(...Te(a.get(e)??{data:new Set,status:new Set,handled:new Set})))}return!1},Un=(e,t,n,r)=>{let i=In(t,n),a=Ln(t,r);if(!i||!a)return{reason:`notPins`};let o=Vn(e,a.step);if(o!==void 0&&i.node!==``&&!i.node.startsWith(`${o}/`))return{reason:`otherScope`,step:T(i.node).name};if(b(e)===`data`&&i.node!==``){let[t,n]=[T(i.node).scope.join(`/`),T(a.step).scope.join(`/`)];if(t!==``&&t!==n&&!n.startsWith(`${t}/`))return{reason:`otherScope`,step:T(i.node).name};if(Hn(e,i.node,a.step))return{reason:`notBefore`,step:T(i.node).name};if(i.path[0]!==`#status`&&jn(e,i.node))return{reason:`shapesOutput`,step:T(i.node).name}}else if(i.node===``){if(Bn(e,a.step))return{reason:`notBefore`,step:T(a.step).name}}else{if(!kn(e,a.step).includes(i.node))return{reason:`notBefore`,step:T(i.node).name};if(jn(e,i.node))return{reason:`shapesOutput`,step:T(i.node).name}}if(Rn(i,a))return;let s=zn(t,n,`out`),c=zn(t,r,`in`);if(s&&c&&!be(s,c))return{reason:`type`,source:s,target:c}},Wn=(e,t,n,r)=>{if(Un(e,t,n,r))return e;let i=In(t,n),a=Ln(t,r),o=e,s;if(i.node===``)s={base:{input:!0},path:i.path};else if(i.path[0]===`#status`)s={base:{step:T(i.node).name},path:i.path.slice(1)};else{let t=Fn(e,i.node);o=t.definition,s={base:{variable:t.variable},path:i.path}}let c=`step`in s.base&&s.path.length===0?{...s,path:[`Status`]}:s;return a.side?ln(o,a.step,a.side.at,{read:c}):a.select?Y(o,a.step,a.keys,ke({...a.select.part,operand:{read:c}})):Rn(i,a)?Y(o,a.step,a.keys,C({kind:`compare`,op:`=`,sides:[{read:c},{value:`SUCCEEDED`}]})):Y(o,a.step,a.keys,Ae(s))},Gn=(e,t,n)=>{let r=Ln(t,{node:n.target,handle:n.targetHandle});if(r?.side)return dn(e,r.step,r.side.at);if(r?.select)return Y(e,r.step,r.keys,ke({...r.select.part,operand:{value:``}}));if(r)return Y(e,r.step,r.keys,void 0);let i=Q(t,n.target)??Q(t,n.source);return i?Kn(e,t,i):e},Kn=(e,t,n)=>{if(n.kind===`make`||n.kind===`select`)return Y(e,n.target,[n.key],void 0);if(n.kind===`condition`)return dn(e,n.target,n.at);let r=e=>t.edges.filter(t=>t.source===e.id&&!t.expression).flatMap(e=>{let n=Q(t,e.target);return n?.kind===`break`?r(n):[e]});return he(t,r(n),e=>de(t,e)).reduce((e,n)=>Gn(e,t,n),e)},qn=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,Jn={connect:ut,disconnect:dt,removeState:lt,setArgument:Y,connectData:Wn,disconnectData:Gn,removePure:Kn,wireRefusal:Un,addCondition:un,conditionChoices:nn,setConditionSide:ln,addSelect:(e,t,n)=>{let r=w(e,t)?.Arguments?.[n];if(r!==void 0&&!qn(r)||typeof r==`string`&&r.startsWith(`{%`))return e;let i=r??``;return Y(e,t,[n],ke({operand:{value:``},cases:[{when:``,then:i}],otherwise:i}))}},Yn=(e,t,n={})=>({inputs:Object.fromEntries(e.step_types.map(e=>[e.id,e.input])),outputs:Object.fromEntries([...e.step_types,...e.triggers].flatMap(e=>e.output?[[e.id,e.output]]:[])),records:(e,r)=>{let i=t[e];return i&&Le(i,r,n[e]?.names?.singular??ee(e),Re(e=>t[e]))},emails:t=>{let n=e.templates?.find(e=>e.name===t);return n&&{schema:n.schema,languages:n.languages}}}),Xn=e=>{let{data:t}=ne();return(0,V.useMemo)(()=>Yn(e,t?.resources??{},t?.views),[e,t?.resources,t?.views])},$=d(`app/field-types/workflow-page`),Zn={"app:http":{icon:Ge,keywords:[`api`,`fetch`,`url`,`webhook`,`get`,`post`]},"app:mail.send":{icon:c,keywords:[`email`,`send`,`message`]},"app:records.create":{icon:k,keywords:[`insert`,`add`,`new`,`row`]},"app:records.update":{icon:k,keywords:[`change`,`edit`,`row`]},"app:records.get":{icon:k,keywords:[`read`,`find`,`row`]},"app:records.list":{icon:k,keywords:[`read`,`find`,`query`,`rows`]}},Qn=[{type:`Choice`,icon:Ue,description:()=>$(`flowChoice`),keywords:[`if`,`branch`,`switch`,`condition`]},{type:`Map`,icon:Ye,description:()=>$(`flowMap`),keywords:[`loop`,`each`,`list`,`repeat`]},{type:`Block`,icon:g,description:()=>$(`flowBlock`),keywords:[`cache`,`once`,`group`,`reuse`,`wrap`]},{type:`Wait`,icon:Ze,description:()=>$(`flowWait`),keywords:[`delay`,`sleep`,`pause`,`later`]},{type:`Pass`,icon:qe,description:()=>$(`flowPass`),keywords:[`variable`,`assign`,`transform`]},{type:`Succeed`,icon:m,description:()=>$(`flowSucceed`),keywords:[`end`,`stop`,`done`]},{type:`Fail`,icon:r,description:()=>$(`flowFail`),keywords:[`end`,`stop`,`error`]}],$n=e=>({id:`task:${e.id}`,title:ce(e.id,e.label),description:e.description,keywords:[e.id,...Zn[e.id]?.keywords??[]],icon:Zn[e.id]?.icon??(e.id.startsWith(`app:`)?re:f)}),er=e=>e.slice(0,Math.max(e.indexOf(`:`),0)),tr=e=>e===`custom`?$(`customSteps`):e,nr=e=>{let t=new Set(Object.values(Oe(e.step_types.map(e=>e.id)))),n=e.step_types.filter(e=>e.available&&(!De(e.id)||t.has(e.id))),r=[...new Set(n.map(e=>er(e.id)).filter(e=>e!==`app`))];return[{title:$(`builtIn`),items:n.filter(e=>er(e.id)===`app`).map($n)},...r.map(e=>({title:tr(e),items:n.filter(t=>er(t.id)===e).map($n)})),{title:$(`flow`),items:Qn.map(e=>({id:`type:${e.type}`,title:se(e.type),description:e.description(),keywords:e.keywords,icon:e.icon}))}].filter(e=>e.items.length>0)},rr=e=>e.startsWith(`task:`)?{task:e.slice(5)}:{type:e.slice(5)};export{mt as A,ot as C,it as D,Qe as E,tt as O,P as S,st as T,wt as _,Jn as a,Tt as b,En as c,On as d,vn as f,Et as g,Nt as h,Xn as i,nt as k,jn as l,en as m,nr as n,kn as o,bn as p,$ as r,Dn as s,rr as t,Fn as u,z as v,at as w,bt as x,xt as y};
2
+ //# debugId=4f93a5ae-607b-465b-998a-924b02caebe8
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,Hc as i,In as a,Lr as o,Xc as s,Yi as c,Zo as l,cc as u,ns as d,sc as f}from"./app-D3BCcbgE.js";import{l as p,m,n as h,u as g}from"./workflow-canvas-BKd_Yd0v.js";import{m as _}from"./workflows-Bey4jszG.js";import{E as v,T as y,n as b}from"./use-run-trace-BRwbwZcf.js";var x=e(t(),1),S=e=>e===``?[]:e.split(`/`).map(t=>{let n=/^(.*)\.\d+\[(\d+)\]$/.exec(t);if(!n)throw Error(`"${e}" is not a step's scope`);return{map:decodeURIComponent(n[1]),index:Number(n[2])}}),C=(e,t)=>[...S(e).map(e=>e.map),t].join(`/`),w={succeeded:0,caught:1,retrying:2,failed:3,current:4},T=(e,{inProgress:t,startAt:n,within:r=[]})=>{let i=(e,t)=>[...r,C(e,t)].join(`/`),a=new Map,o=new Map,s=new Map;for(let t of e){let e=i(t.scope,t.state);a.set(e,(a.get(e)??0)+1),o.set(`${t.scope}\n${t.state}`,t),s.set(t.scope,t)}let c=new Map,l=(e,t)=>{let n=c.get(e);(n===void 0||w[t]>w[n])&&c.set(e,t)};for(let e of o.values())l(i(e.scope,e.state),e.status);if(t){!s.has(``)&&n&&l([...r,n].join(`/`),`current`);for(let e of s.values())e.status!==`retrying`&&e.next!==null&&l(i(e.scope,e.next),`current`)}return new Map([...c].map(([e,t])=>[e,{status:t,steps:a.get(e)??0}]))},E=s(`app/field-types/workflow-run`),D=e(n(),1),O=({title:e,children:t})=>(0,D.jsxs)(`div`,{className:`grid gap-1`,children:[(0,D.jsx)(`h5`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),k=e=>new Intl.DateTimeFormat(r(),{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(Date.parse(e)),A=({logs:e})=>(0,D.jsx)(`ol`,{className:`grid gap-0.5 rounded-md bg-muted/60 px-3 py-2 font-mono text-xs`,children:e.map((e,t)=>(0,D.jsxs)(`li`,{className:`whitespace-pre-wrap break-words`,children:[(0,D.jsx)(`time`,{dateTime:e.at,className:`text-muted-foreground`,children:k(e.at)}),` `,e.message]},t))}),j=({step:e,runId:t,valueActions:n})=>{let r=d(),s=typeof e.type==`string`&&_(e.type)!==void 0&&r.resources.workflow_custom_step_jobs!==void 0&&r.permissions.workflow_custom_step_jobs?.read!==!1,f=e.logs?.some(e=>e.message===`Not sent: replay`)??!1,m=S(e.scope),g=e.output!==void 0&&e.output!==null&&(0,D.jsxs)(O,{title:E(`output`),children:[(0,D.jsx)(a,{value:e.output}),n?.(e.output,`output`)]});return(0,D.jsxs)(`article`,{"aria-label":E(`stepTry`,{attempt:e.attempt}),className:`grid gap-3 rounded-lg border bg-background p-3`,children:[(0,D.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-body`,children:[(0,D.jsx)(`span`,{className:`font-medium text-foreground`,children:E(`stepTry`,{attempt:e.attempt})}),m.map((e,t)=>(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:E(`itemOf`,{index:e.index+1,map:e.map})},t)),(0,D.jsx)(l,{tone:h[e.status],children:p(e.status)}),f&&(0,D.jsx)(l,{tone:`violet`,children:E(`notSent`)}),e.reused===!0&&(0,D.jsx)(l,{tone:`blue`,children:E(`reused`)}),e.joined===!0&&(0,D.jsx)(l,{tone:`blue`,children:E(`joined`)}),(0,D.jsx)(`time`,{dateTime:e.started_at,className:`text-muted-foreground`,children:c(Date.parse(e.started_at))}),(0,D.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:E(`duration`,{ms:Number(e.duration_ms??0)})})]}),e.error!=null&&(0,D.jsx)(O,{title:E(`error`),children:(0,D.jsxs)(`p`,{className:`text-body text-danger-text`,children:[(0,D.jsx)(`span`,{className:`font-mono`,children:String(e.error)}),e.cause!=null&&(0,D.jsxs)(`span`,{children:[`: `,String(e.cause)]})]})}),typeof e.run==`string`&&(0,D.jsxs)(`div`,{className:`grid gap-1`,children:[e.reused===!0&&(0,D.jsx)(`p`,{className:`text-body text-muted-foreground`,children:E(`reusedResult`)}),e.joined===!0&&(0,D.jsx)(`p`,{className:`text-body text-muted-foreground`,children:E(`joinedResult`)}),(0,D.jsx)(o,{to:{kind:`record`,resource:`workflow_runs`,key:e.run},className:i(u({size:`sm`}),`justify-self-start`),children:e.reused===!0?E(`openEarlierBlockRun`):E(`openBlockRun`)})]}),s&&(0,D.jsx)(o,{to:{kind:`list`,resource:`workflow_custom_step_jobs`,filter:`run_id = "${t}"`},className:i(u({size:`sm`}),`justify-self-start`),children:E(`openJobs`)}),e.status!==`failed`&&g,e.input!==void 0&&e.input!==null&&(0,D.jsxs)(O,{title:E(`input`),children:[(0,D.jsx)(a,{value:e.input}),n?.(e.input,`input`)]}),e.status===`failed`&&g,e.assigned!=null&&(0,D.jsx)(O,{title:E(`variables`),children:(0,D.jsx)(a,{value:e.assigned})}),e.logs&&e.logs.length>0&&(0,D.jsx)(O,{title:E(`logs`),children:(0,D.jsx)(A,{logs:e.logs})})]})},M=({kind:e,name:t})=>(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),(0,D.jsx)(`h4`,{className:`truncate font-semibold text-foreground`,children:t})]}),N=({run:e,name:t,block:n,valueActions:r})=>{let i=b(e.id,!1),[a,s]=(0,x.useState)(20);if(i.isPending)return null;let c=(i.data??[]).filter(e=>e.state===t),l=n===void 0?void 0:(i.data??[]).filter(e=>e.state===n&&typeof e.run==`string`).at(-1)?.run;return c.length===0&&typeof l==`string`?(0,D.jsxs)(`div`,{className:`grid gap-2 text-body text-muted-foreground`,children:[(0,D.jsx)(`p`,{children:E(`ranInBlockRun`,{block:n})}),(0,D.jsx)(o,{to:{kind:`record`,resource:`workflow_runs`,key:l},className:u({size:`sm`})+` justify-self-start`,children:E(`openBlockRun`)})]}):c.length===0?(0,D.jsx)(`p`,{className:`text-body text-muted-foreground`,children:E(`notRun`)}):(0,D.jsxs)(`div`,{className:`grid gap-3`,children:[c.slice(0,a).map(t=>(0,D.jsx)(j,{step:t,runId:e.id,...r&&{valueActions:r}},String(t.id))),c.length>a&&(0,D.jsx)(f,{size:`sm`,className:`justify-self-start`,onClick:()=>s(a+20),children:E(`showMore`)})]})},P=({definition:e,run:t,selected:n,types:r})=>{let i=n===``?void 0:v(e,n);return(0,D.jsx)(`section`,{"aria-label":E(`chosenStep`),className:`grid gap-3 rounded-lg border bg-surface p-4`,children:i?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(M,{kind:g(i,r),name:y(n).name}),(0,D.jsx)(N,{run:t,name:y(n).name})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(M,{kind:E(`trigger`),name:m(e.trigger,r)}),(0,D.jsx)(O,{title:E(`runInput`),children:(0,D.jsx)(a,{value:t.input??null})})]})})};export{T as a,E as i,P as n,C as o,O as r,N as t};
2
- //# debugId=2399f87c-e980-477b-9661-e93a4d71fed6
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$c as r,Hc as i,In as a,Lr as o,Xc as s,Yi as c,Zo as l,cc as u,ns as d,sc as f}from"./app-B94YfKGx.js";import{l as p,m,n as h,u as g}from"./workflow-canvas-n_YJtaOh.js";import{m as _}from"./workflows-Bey4jszG.js";import{E as v,T as y,n as b}from"./use-run-trace-CWGAibgF.js";var x=e(t(),1),S=e=>e===``?[]:e.split(`/`).map(t=>{let n=/^(.*)\.\d+\[(\d+)\]$/.exec(t);if(!n)throw Error(`"${e}" is not a step's scope`);return{map:decodeURIComponent(n[1]),index:Number(n[2])}}),C=(e,t)=>[...S(e).map(e=>e.map),t].join(`/`),w={succeeded:0,caught:1,retrying:2,failed:3,current:4},T=(e,{inProgress:t,startAt:n,within:r=[]})=>{let i=(e,t)=>[...r,C(e,t)].join(`/`),a=new Map,o=new Map,s=new Map;for(let t of e){let e=i(t.scope,t.state);a.set(e,(a.get(e)??0)+1),o.set(`${t.scope}\n${t.state}`,t),s.set(t.scope,t)}let c=new Map,l=(e,t)=>{let n=c.get(e);(n===void 0||w[t]>w[n])&&c.set(e,t)};for(let e of o.values())l(i(e.scope,e.state),e.status);if(t){!s.has(``)&&n&&l([...r,n].join(`/`),`current`);for(let e of s.values())e.status!==`retrying`&&e.next!==null&&l(i(e.scope,e.next),`current`)}return new Map([...c].map(([e,t])=>[e,{status:t,steps:a.get(e)??0}]))},E=s(`app/field-types/workflow-run`),D=e(n(),1),O=({title:e,children:t})=>(0,D.jsxs)(`div`,{className:`grid gap-1`,children:[(0,D.jsx)(`h5`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]}),k=e=>new Intl.DateTimeFormat(r(),{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(Date.parse(e)),A=({logs:e})=>(0,D.jsx)(`ol`,{className:`grid gap-0.5 rounded-md bg-muted/60 px-3 py-2 font-mono text-xs`,children:e.map((e,t)=>(0,D.jsxs)(`li`,{className:`whitespace-pre-wrap break-words`,children:[(0,D.jsx)(`time`,{dateTime:e.at,className:`text-muted-foreground`,children:k(e.at)}),` `,e.message]},t))}),j=({step:e,runId:t,valueActions:n})=>{let r=d(),s=typeof e.type==`string`&&_(e.type)!==void 0&&r.resources.workflow_custom_step_jobs!==void 0&&r.permissions.workflow_custom_step_jobs?.read!==!1,f=e.logs?.some(e=>e.message===`Not sent: replay`)??!1,m=S(e.scope),g=e.output!==void 0&&e.output!==null&&(0,D.jsxs)(O,{title:E(`output`),children:[(0,D.jsx)(a,{value:e.output}),n?.(e.output,`output`)]});return(0,D.jsxs)(`article`,{"aria-label":E(`stepTry`,{attempt:e.attempt}),className:`grid gap-3 rounded-lg border bg-background p-3`,children:[(0,D.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-body`,children:[(0,D.jsx)(`span`,{className:`font-medium text-foreground`,children:E(`stepTry`,{attempt:e.attempt})}),m.map((e,t)=>(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:E(`itemOf`,{index:e.index+1,map:e.map})},t)),(0,D.jsx)(l,{tone:h[e.status],children:p(e.status)}),f&&(0,D.jsx)(l,{tone:`violet`,children:E(`notSent`)}),e.reused===!0&&(0,D.jsx)(l,{tone:`blue`,children:E(`reused`)}),e.joined===!0&&(0,D.jsx)(l,{tone:`blue`,children:E(`joined`)}),(0,D.jsx)(`time`,{dateTime:e.started_at,className:`text-muted-foreground`,children:c(Date.parse(e.started_at))}),(0,D.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:E(`duration`,{ms:Number(e.duration_ms??0)})})]}),e.error!=null&&(0,D.jsx)(O,{title:E(`error`),children:(0,D.jsxs)(`p`,{className:`text-body text-danger-text`,children:[(0,D.jsx)(`span`,{className:`font-mono`,children:String(e.error)}),e.cause!=null&&(0,D.jsxs)(`span`,{children:[`: `,String(e.cause)]})]})}),typeof e.run==`string`&&(0,D.jsxs)(`div`,{className:`grid gap-1`,children:[e.reused===!0&&(0,D.jsx)(`p`,{className:`text-body text-muted-foreground`,children:E(`reusedResult`)}),e.joined===!0&&(0,D.jsx)(`p`,{className:`text-body text-muted-foreground`,children:E(`joinedResult`)}),(0,D.jsx)(o,{to:{kind:`record`,resource:`workflow_runs`,key:e.run},className:i(u({size:`sm`}),`justify-self-start`),children:e.reused===!0?E(`openEarlierBlockRun`):E(`openBlockRun`)})]}),s&&(0,D.jsx)(o,{to:{kind:`list`,resource:`workflow_custom_step_jobs`,filter:`run_id = "${t}"`},className:i(u({size:`sm`}),`justify-self-start`),children:E(`openJobs`)}),e.status!==`failed`&&g,e.input!==void 0&&e.input!==null&&(0,D.jsxs)(O,{title:E(`input`),children:[(0,D.jsx)(a,{value:e.input}),n?.(e.input,`input`)]}),e.status===`failed`&&g,e.assigned!=null&&(0,D.jsx)(O,{title:E(`variables`),children:(0,D.jsx)(a,{value:e.assigned})}),e.logs&&e.logs.length>0&&(0,D.jsx)(O,{title:E(`logs`),children:(0,D.jsx)(A,{logs:e.logs})})]})},M=({kind:e,name:t})=>(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),(0,D.jsx)(`h4`,{className:`truncate font-semibold text-foreground`,children:t})]}),N=({run:e,name:t,block:n,valueActions:r})=>{let i=b(e.id,!1),[a,s]=(0,x.useState)(20);if(i.isPending)return null;let c=(i.data??[]).filter(e=>e.state===t),l=n===void 0?void 0:(i.data??[]).filter(e=>e.state===n&&typeof e.run==`string`).at(-1)?.run;return c.length===0&&typeof l==`string`?(0,D.jsxs)(`div`,{className:`grid gap-2 text-body text-muted-foreground`,children:[(0,D.jsx)(`p`,{children:E(`ranInBlockRun`,{block:n})}),(0,D.jsx)(o,{to:{kind:`record`,resource:`workflow_runs`,key:l},className:u({size:`sm`})+` justify-self-start`,children:E(`openBlockRun`)})]}):c.length===0?(0,D.jsx)(`p`,{className:`text-body text-muted-foreground`,children:E(`notRun`)}):(0,D.jsxs)(`div`,{className:`grid gap-3`,children:[c.slice(0,a).map(t=>(0,D.jsx)(j,{step:t,runId:e.id,...r&&{valueActions:r}},String(t.id))),c.length>a&&(0,D.jsx)(f,{size:`sm`,className:`justify-self-start`,onClick:()=>s(a+20),children:E(`showMore`)})]})},P=({definition:e,run:t,selected:n,types:r})=>{let i=n===``?void 0:v(e,n);return(0,D.jsx)(`section`,{"aria-label":E(`chosenStep`),className:`grid gap-3 rounded-lg border bg-surface p-4`,children:i?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(M,{kind:g(i,r),name:y(n).name}),(0,D.jsx)(N,{run:t,name:y(n).name})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(M,{kind:E(`trigger`),name:m(e.trigger,r)}),(0,D.jsx)(O,{title:E(`runInput`),children:(0,D.jsx)(a,{value:t.input??null})})]})})};export{T as a,E as i,P as n,C as o,O as r,N as t};
2
+ //# debugId=571d6030-f31a-41fe-94a9-c2810fa33e3e
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$i as r,Ea as i,Hc as a,Ji as o,Qi as s,Xi as c,aa as l,ca as u,cl as d,ea as f,gi as p,ic as m,mr as ee,ra as h,rs as te,ui as g,wa as ne}from"./app-D3BCcbgE.js";import{_,a as re,i as ie,n as v,o as ae,t as oe,v as se}from"./lib-dnd-kit-core-xi-7xL_N.js";import{a as ce,g as y,h as b,i as x,l as le,m as ue,n as de,o as S,r as C,t as fe,u as w,v as T}from"./use-calendar-move-BytgRG51.js";var E=e(t(),1),D=864e5,O=e=>Date.parse(`${e}T00:00:00Z`),k=(e,t=0)=>{let n=new Date(O(e));return new Date(Date.UTC(n.getUTCFullYear(),Math.floor(n.getUTCMonth()/3)*3+3*t,1)).toISOString().slice(0,10)},A=({scale:e,day:t})=>({scale:e,day:e===`week`?b(t):e===`month`?y(t):k(t)}),j=(e,t,n=u())=>A(e??{scale:`month`,day:l(t,n)}),M=(e,t)=>{let{scale:n,day:r}=A(e);return{scale:n,day:n===`week`?w(r,7*t):n===`month`?y(r,t):k(r,t)}},N=e=>{let t=A(e).day,n=(O(M(e,1).day)-O(t))/D;return Array.from({length:n},(e,n)=>w(t,n))},P=e=>({from:A(e).day,to:M(e,1).day}),F=(e,t,n,r=u())=>{let i=l(n,r),a=N(e);return A({scale:t,day:i>=a[0]&&i<=a.at(-1)?i:a[0]})},I=e=>{let t=N(e);return e.scale===`week`?c(O(t[0]),O(t.at(-1))):e.scale===`month`?s(O(t[0])):f(O(t[0]),O(y(t.at(-1))))},L=e=>{let t=N(e);if(e.scale===`week`)return t.map((e,t)=>({index:t,span:1,label:`${h(O(e))} ${Number(e.slice(8))}`}));if(e.scale===`month`)return t.map((e,t)=>({index:t,span:1,label:String(Number(e.slice(8))),...t%7!=0&&{minor:!0}}));let n=t.flatMap((e,t)=>e.endsWith(`-01`)?[t]:[]);return n.map((e,i)=>({index:e,span:(n[i+1]??t.length)-e,label:r(O(t[e]))}))},R=(e,t,n,r,i=u())=>{let a=T(e,t,n,i),o=r[0],s=r.at(-1);if(!(!a||o===void 0||s===void 0||a.last<o||a.first>s))return{first:a.first<o?0:r.indexOf(a.first),last:a.last>s?r.length-1:r.indexOf(a.last),before:a.first<o,after:a.last>s,start:a.first}},z=`none`,B=(e,t,n,r)=>{let i=r.group,a=i===void 0?void 0:t.fields[i];if(i===void 0||!a)return[{key:``,rows:e}];let o=n?.fields[i],s=new Map;for(let t of e){let e=t.record[i],n=e==null||e===``,r=n?z:`value:${String(e)}`,c=n?g(`noValue`,{label:o?.label??d(i)}):t.labels[i]??p(a,e,o),l=s.get(r)??{value:n?void 0:e,lane:{key:r,label:c,rows:[]}};l.lane.rows.push(t),s.set(r,l)}let c=a.enumValues??[],l=(e,t)=>e.value===void 0||t.value===void 0?Number(e.value===void 0)-Number(t.value===void 0):a.type===`enum`?c.indexOf(String(e.value))-c.indexOf(String(t.value)):a.type===`relation`?e.lane.label.localeCompare(t.lane.label):typeof e.value==`number`&&typeof t.value==`number`?e.value-t.value:String(e.value).localeCompare(String(t.value),void 0,{numeric:!0});return[...s.values()].toSorted(l).map(({lane:e})=>e)},V=e(n(),1),H=`grid grid-cols-1 sm:grid-cols-[12rem_minmax(0,1fr)]`,U=(e,t)=>`${e/t*100}%`,pe=({ticks:e,days:t,today:n,label:r,trackRef:i})=>(0,V.jsxs)(`div`,{className:a(H,`border-b border-border bg-surface`),children:[(0,V.jsx)(`span`,{className:`hidden truncate px-2 py-1 text-xs font-medium text-muted-foreground sm:block`,children:r}),(0,V.jsx)(`div`,{ref:i,"aria-hidden":!0,className:`relative h-6`,children:e.map(e=>(0,V.jsx)(`span`,{className:a(`absolute inset-y-0 items-center truncate px-1 text-xs tabular-nums text-muted-foreground`,e.index>0?`border-l border-border`:`border-border sm:border-l`,e.minor?`hidden sm:flex`:`flex`,e.span===1&&t[e.index]===n&&`font-medium text-primary`),style:{left:U(e.index,t.length),width:U(e.span,t.length)},children:e.label},e.index))})]}),me=({ticks:e,days:t,today:n})=>{let r=t.indexOf(n);return(0,V.jsxs)(`div`,{"aria-hidden":!0,className:a(H,`pointer-events-none absolute inset-0`),children:[(0,V.jsx)(`span`,{className:`hidden sm:block`}),(0,V.jsxs)(`div`,{className:`relative`,children:[r>=0&&(0,V.jsx)(`span`,{className:`absolute inset-y-0 bg-primary/10`,style:{left:U(r,t.length),width:U(1,t.length)}}),e.map(e=>(0,V.jsx)(`span`,{className:a(`absolute inset-y-0 w-px bg-border`,(e.minor||e.index===0)&&`hidden sm:block`),style:{left:U(e.index,t.length)}},e.index))]})]})},he=({model:e,view:t,display:n,row:r,days:i,movable:o,dragged:s})=>{let c=R(r.record,n,e,i);return(0,V.jsxs)(`div`,{className:a(H,`relative border-b border-border last:border-b-0`),children:[(0,V.jsx)(`span`,{"aria-hidden":!0,className:`truncate px-2 pt-1 text-body sm:py-1.5`,children:S(e,t,n,r)}),(0,V.jsx)(`div`,{className:`relative h-7`,children:c&&(0,V.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2`,style:{left:U(c.first,i.length),width:U(c.last-c.first+1,i.length)},children:(0,V.jsx)(x,{model:e,view:t,display:n,row:r,day:c.start,movable:o,dragged:s,className:a(c.before&&`rounded-l-none border-l-0`,c.after&&`rounded-r-none border-r-0`)})})})]})},ge=()=>[{scale:`week`,label:g(`week`)},{scale:`month`,label:g(`month`)},{scale:`quarter`,label:g(`quarter`)}],W=({model:e,view:t,display:n,fields:r,filter:a,at:s,linkTo:c,now:f=Date.now()})=>{let[p,h]=(0,E.useState)(),y=j(c?s:p,f),b=N(y),x=L(y),D=C({model:e,display:n,range:P(y),fields:r,filter:a}),{moves:O,move:k}=de(e,n),A=B(ue(fe(D.rows,O),n),e,t,n),R=te(e.name),z=ne(R,`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[H,U]=(0,E.useState)(),W=(0,E.useRef)(!1),G=(0,E.useRef)(0),K=(0,E.useRef)(null),q=()=>(K.current?.getBoundingClientRect().width??0)/b.length,J=e=>{let t=q();return t>0?Math.round(e/t):0},Y=({transform:e})=>({...e,x:J(e.x)*q(),y:0}),_e=se(_(re,{activationConstraint:{distance:4}}),_(ae,{activationConstraint:{delay:250,tolerance:5}}),_(ie,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:(e,{currentCoordinates:t})=>{let n=e.code===`ArrowLeft`?-1:+(e.code===`ArrowRight`);if(n!==0)return e.preventDefault(),{x:t.x+n*q(),y:t.y}}})),X=l(f,u()),Z=r=>S(e,t,n,r.row),Q=e=>o(Date.parse(`${w(e.day,G.current)}T00:00:00Z`)),ve={onDragStart:({active:e})=>g(`pickedUp`,{title:Z(e.data.current)}),onDragMove:({active:e})=>g(`startsOn`,{title:Z(e.data.current),day:Q(e.data.current)}),onDragOver:()=>void 0,onDragEnd:({active:e})=>G.current===0?g(`putBack`,{title:Z(e.data.current)}):g(`wasMovedTo`,{title:Z(e.data.current),to:Q(e.data.current)}),onDragCancel:({active:e})=>g(`cancelled`,{title:Z(e.data.current)})},$=()=>{U(void 0),setTimeout(()=>W.current=!1)},ye=({active:e})=>{W.current=!0,G.current=0,U(e.data.current)},be=({delta:e})=>G.current=J(e.x),xe=({active:t,delta:r})=>{$(),G.current=J(r.x);let{row:i}=t.data.current,a=T(i.record,n,e);a&&G.current!==0&&k(i,a.first,w(a.first,G.current))},Se=n.group===void 0?t?.names?.plural??d(e.name):t?.fields[n.group]?.label??d(n.group),Ce=!D.loading&&!D.error&&D.rows.length===0;return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,V.jsx)(le,{heading:I(y),unit:y.scale,previous:M(y,-1),today:j({scale:y.scale,day:X},f),next:M(y,1),scales:ge().map(({scale:e,label:t})=>({view:F(y,e,f),label:t,current:y.scale===e})),scalesLabel:g(`timelineScale`),linkTo:c,onView:h}),D.error&&(0,V.jsx)(ee,{title:g(`couldNotLoadRows`),error:D.error}),D.capped&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`capped`,{limit:500,unit:y.scale})}),(0,V.jsxs)(oe,{sensors:_e,modifiers:[Y],onDragStart:ye,onDragMove:be,onDragEnd:xe,onDragCancel:$,accessibility:{announcements:ve,screenReaderInstructions:{draggable:g(`timelineInstructions`)}},children:[(0,V.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[(0,V.jsx)(pe,{ticks:x,days:b,today:X,label:Se,trackRef:K}),(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(me,{ticks:x,days:b,today:X}),D.loading&&(0,V.jsxs)(`div`,{className:`relative flex flex-col gap-2 p-2`,children:[(0,V.jsx)(m,{className:`h-4`}),(0,V.jsx)(m,{className:`h-4`})]}),Ce&&(0,V.jsx)(`p`,{className:`relative px-2 py-3 text-xs text-muted-foreground`,children:g(`nothingIn`,{unit:y.scale})}),!D.loading&&A.map(r=>(0,V.jsxs)(`section`,{"aria-label":r.label,className:`relative border-b border-border last:border-b-0`,children:[r.label!==void 0&&(0,V.jsxs)(`h3`,{className:`flex items-center gap-1.5 border-b border-border bg-surface px-2 py-1 text-xs font-medium`,children:[r.label,(0,V.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:r.rows.length})]}),r.rows.map(r=>(0,V.jsx)(he,{model:e,view:t,display:n,row:r,days:b,movable:z&&i(r.record,`update`),dragged:()=>W.current},r.key))]},r.key))]})]}),(0,V.jsx)(v,{children:H&&(0,V.jsx)(ce,{model:e,view:t,display:n,row:H.row,day:H.day})})]})]})};export{W as TimelineDisplay};
2
- //# debugId=adc4e1cf-a09f-499d-adea-4c60e38ba382
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{o as e}from"./rolldown-runtime-DFwUHQ4A.js";import{i as t,t as n}from"./react-CuiNlnus.js";import{$i as r,Ea as i,Hc as a,Ji as o,Qi as s,Xi as c,aa as l,ca as u,cl as d,ea as f,gi as p,ic as m,mr as ee,ra as h,rs as te,ui as g,wa as ne}from"./app-B94YfKGx.js";import{_,a as re,i as ie,n as v,o as ae,t as oe,v as se}from"./lib-dnd-kit-core-xi-7xL_N.js";import{a as ce,g as y,h as b,i as x,l as le,m as ue,n as de,o as S,r as C,t as fe,u as w,v as T}from"./use-calendar-move-O_48Gqvs.js";var E=e(t(),1),D=864e5,O=e=>Date.parse(`${e}T00:00:00Z`),k=(e,t=0)=>{let n=new Date(O(e));return new Date(Date.UTC(n.getUTCFullYear(),Math.floor(n.getUTCMonth()/3)*3+3*t,1)).toISOString().slice(0,10)},A=({scale:e,day:t})=>({scale:e,day:e===`week`?b(t):e===`month`?y(t):k(t)}),j=(e,t,n=u())=>A(e??{scale:`month`,day:l(t,n)}),M=(e,t)=>{let{scale:n,day:r}=A(e);return{scale:n,day:n===`week`?w(r,7*t):n===`month`?y(r,t):k(r,t)}},N=e=>{let t=A(e).day,n=(O(M(e,1).day)-O(t))/D;return Array.from({length:n},(e,n)=>w(t,n))},P=e=>({from:A(e).day,to:M(e,1).day}),F=(e,t,n,r=u())=>{let i=l(n,r),a=N(e);return A({scale:t,day:i>=a[0]&&i<=a.at(-1)?i:a[0]})},I=e=>{let t=N(e);return e.scale===`week`?c(O(t[0]),O(t.at(-1))):e.scale===`month`?s(O(t[0])):f(O(t[0]),O(y(t.at(-1))))},L=e=>{let t=N(e);if(e.scale===`week`)return t.map((e,t)=>({index:t,span:1,label:`${h(O(e))} ${Number(e.slice(8))}`}));if(e.scale===`month`)return t.map((e,t)=>({index:t,span:1,label:String(Number(e.slice(8))),...t%7!=0&&{minor:!0}}));let n=t.flatMap((e,t)=>e.endsWith(`-01`)?[t]:[]);return n.map((e,i)=>({index:e,span:(n[i+1]??t.length)-e,label:r(O(t[e]))}))},R=(e,t,n,r,i=u())=>{let a=T(e,t,n,i),o=r[0],s=r.at(-1);if(!(!a||o===void 0||s===void 0||a.last<o||a.first>s))return{first:a.first<o?0:r.indexOf(a.first),last:a.last>s?r.length-1:r.indexOf(a.last),before:a.first<o,after:a.last>s,start:a.first}},z=`none`,B=(e,t,n,r)=>{let i=r.group,a=i===void 0?void 0:t.fields[i];if(i===void 0||!a)return[{key:``,rows:e}];let o=n?.fields[i],s=new Map;for(let t of e){let e=t.record[i],n=e==null||e===``,r=n?z:`value:${String(e)}`,c=n?g(`noValue`,{label:o?.label??d(i)}):t.labels[i]??p(a,e,o),l=s.get(r)??{value:n?void 0:e,lane:{key:r,label:c,rows:[]}};l.lane.rows.push(t),s.set(r,l)}let c=a.enumValues??[],l=(e,t)=>e.value===void 0||t.value===void 0?Number(e.value===void 0)-Number(t.value===void 0):a.type===`enum`?c.indexOf(String(e.value))-c.indexOf(String(t.value)):a.type===`relation`?e.lane.label.localeCompare(t.lane.label):typeof e.value==`number`&&typeof t.value==`number`?e.value-t.value:String(e.value).localeCompare(String(t.value),void 0,{numeric:!0});return[...s.values()].toSorted(l).map(({lane:e})=>e)},V=e(n(),1),H=`grid grid-cols-1 sm:grid-cols-[12rem_minmax(0,1fr)]`,U=(e,t)=>`${e/t*100}%`,pe=({ticks:e,days:t,today:n,label:r,trackRef:i})=>(0,V.jsxs)(`div`,{className:a(H,`border-b border-border bg-surface`),children:[(0,V.jsx)(`span`,{className:`hidden truncate px-2 py-1 text-xs font-medium text-muted-foreground sm:block`,children:r}),(0,V.jsx)(`div`,{ref:i,"aria-hidden":!0,className:`relative h-6`,children:e.map(e=>(0,V.jsx)(`span`,{className:a(`absolute inset-y-0 items-center truncate px-1 text-xs tabular-nums text-muted-foreground`,e.index>0?`border-l border-border`:`border-border sm:border-l`,e.minor?`hidden sm:flex`:`flex`,e.span===1&&t[e.index]===n&&`font-medium text-primary`),style:{left:U(e.index,t.length),width:U(e.span,t.length)},children:e.label},e.index))})]}),me=({ticks:e,days:t,today:n})=>{let r=t.indexOf(n);return(0,V.jsxs)(`div`,{"aria-hidden":!0,className:a(H,`pointer-events-none absolute inset-0`),children:[(0,V.jsx)(`span`,{className:`hidden sm:block`}),(0,V.jsxs)(`div`,{className:`relative`,children:[r>=0&&(0,V.jsx)(`span`,{className:`absolute inset-y-0 bg-primary/10`,style:{left:U(r,t.length),width:U(1,t.length)}}),e.map(e=>(0,V.jsx)(`span`,{className:a(`absolute inset-y-0 w-px bg-border`,(e.minor||e.index===0)&&`hidden sm:block`),style:{left:U(e.index,t.length)}},e.index))]})]})},he=({model:e,view:t,display:n,row:r,days:i,movable:o,dragged:s})=>{let c=R(r.record,n,e,i);return(0,V.jsxs)(`div`,{className:a(H,`relative border-b border-border last:border-b-0`),children:[(0,V.jsx)(`span`,{"aria-hidden":!0,className:`truncate px-2 pt-1 text-body sm:py-1.5`,children:S(e,t,n,r)}),(0,V.jsx)(`div`,{className:`relative h-7`,children:c&&(0,V.jsx)(`div`,{className:`absolute top-1/2 -translate-y-1/2`,style:{left:U(c.first,i.length),width:U(c.last-c.first+1,i.length)},children:(0,V.jsx)(x,{model:e,view:t,display:n,row:r,day:c.start,movable:o,dragged:s,className:a(c.before&&`rounded-l-none border-l-0`,c.after&&`rounded-r-none border-r-0`)})})})]})},ge=()=>[{scale:`week`,label:g(`week`)},{scale:`month`,label:g(`month`)},{scale:`quarter`,label:g(`quarter`)}],W=({model:e,view:t,display:n,fields:r,filter:a,at:s,linkTo:c,now:f=Date.now()})=>{let[p,h]=(0,E.useState)(),y=j(c?s:p,f),b=N(y),x=L(y),D=C({model:e,display:n,range:P(y),fields:r,filter:a}),{moves:O,move:k}=de(e,n),A=B(ue(fe(D.rows,O),n),e,t,n),R=te(e.name),z=ne(R,`update`)&&[n.start,n.end].every(t=>t===void 0||!e.fields[t]?.readOnly),[H,U]=(0,E.useState)(),W=(0,E.useRef)(!1),G=(0,E.useRef)(0),K=(0,E.useRef)(null),q=()=>(K.current?.getBoundingClientRect().width??0)/b.length,J=e=>{let t=q();return t>0?Math.round(e/t):0},Y=({transform:e})=>({...e,x:J(e.x)*q(),y:0}),_e=se(_(re,{activationConstraint:{distance:4}}),_(ae,{activationConstraint:{delay:250,tolerance:5}}),_(ie,{keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]},coordinateGetter:(e,{currentCoordinates:t})=>{let n=e.code===`ArrowLeft`?-1:+(e.code===`ArrowRight`);if(n!==0)return e.preventDefault(),{x:t.x+n*q(),y:t.y}}})),X=l(f,u()),Z=r=>S(e,t,n,r.row),Q=e=>o(Date.parse(`${w(e.day,G.current)}T00:00:00Z`)),ve={onDragStart:({active:e})=>g(`pickedUp`,{title:Z(e.data.current)}),onDragMove:({active:e})=>g(`startsOn`,{title:Z(e.data.current),day:Q(e.data.current)}),onDragOver:()=>void 0,onDragEnd:({active:e})=>G.current===0?g(`putBack`,{title:Z(e.data.current)}):g(`wasMovedTo`,{title:Z(e.data.current),to:Q(e.data.current)}),onDragCancel:({active:e})=>g(`cancelled`,{title:Z(e.data.current)})},$=()=>{U(void 0),setTimeout(()=>W.current=!1)},ye=({active:e})=>{W.current=!0,G.current=0,U(e.data.current)},be=({delta:e})=>G.current=J(e.x),xe=({active:t,delta:r})=>{$(),G.current=J(r.x);let{row:i}=t.data.current,a=T(i.record,n,e);a&&G.current!==0&&k(i,a.first,w(a.first,G.current))},Se=n.group===void 0?t?.names?.plural??d(e.name):t?.fields[n.group]?.label??d(n.group),Ce=!D.loading&&!D.error&&D.rows.length===0;return(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,V.jsx)(le,{heading:I(y),unit:y.scale,previous:M(y,-1),today:j({scale:y.scale,day:X},f),next:M(y,1),scales:ge().map(({scale:e,label:t})=>({view:F(y,e,f),label:t,current:y.scale===e})),scalesLabel:g(`timelineScale`),linkTo:c,onView:h}),D.error&&(0,V.jsx)(ee,{title:g(`couldNotLoadRows`),error:D.error}),D.capped&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`capped`,{limit:500,unit:y.scale})}),(0,V.jsxs)(oe,{sensors:_e,modifiers:[Y],onDragStart:ye,onDragMove:be,onDragEnd:xe,onDragCancel:$,accessibility:{announcements:ve,screenReaderInstructions:{draggable:g(`timelineInstructions`)}},children:[(0,V.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:[(0,V.jsx)(pe,{ticks:x,days:b,today:X,label:Se,trackRef:K}),(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(me,{ticks:x,days:b,today:X}),D.loading&&(0,V.jsxs)(`div`,{className:`relative flex flex-col gap-2 p-2`,children:[(0,V.jsx)(m,{className:`h-4`}),(0,V.jsx)(m,{className:`h-4`})]}),Ce&&(0,V.jsx)(`p`,{className:`relative px-2 py-3 text-xs text-muted-foreground`,children:g(`nothingIn`,{unit:y.scale})}),!D.loading&&A.map(r=>(0,V.jsxs)(`section`,{"aria-label":r.label,className:`relative border-b border-border last:border-b-0`,children:[r.label!==void 0&&(0,V.jsxs)(`h3`,{className:`flex items-center gap-1.5 border-b border-border bg-surface px-2 py-1 text-xs font-medium`,children:[r.label,(0,V.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:r.rows.length})]}),r.rows.map(r=>(0,V.jsx)(he,{model:e,view:t,display:n,row:r,days:b,movable:z&&i(r.record,`update`),dragged:()=>W.current},r.key))]},r.key))]})]}),(0,V.jsx)(v,{children:H&&(0,V.jsx)(ce,{model:e,view:t,display:n,row:H.row,day:H.day})})]})]})};export{W as TimelineDisplay};
2
+ //# debugId=891d0883-9bd5-47e3-b478-4454c42c5d70
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{Vc as e}from"./app-D3BCcbgE.js";var t={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};t.node;var n=e(t);export{n as t};
2
- //# debugId=85081c40-5aac-413c-8c6c-8d527bd0e513
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{Vc as e}from"./app-B94YfKGx.js";var t={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};t.node;var n=e(t);export{n as t};
2
+ //# debugId=0c1c04f9-1dfd-44cd-abcd-c867da73c041
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{Jl as e,Rl as t,Xl as n,Yl as r,Zl as i,ql as a}from"./app-D3BCcbgE.js";import{A as o}from"./vendor-t7Q7QbPu.js";var s=e=>()=>{throw Error(`Not implemented: ${e}() needs the database (the resource's search fields, trigram matching), so it cannot be evaluated against a record`)},c=(e,t,n)=>({...i,search:{...i.search,evaluate:n?e=>a(n,t,e):s(`search`)},similar:{...i.similar,evaluate:s(`similar`)},regex:{...i.regex,evaluate:(e,t)=>e.some(e=>typeof e==`string`&&new RegExp(t).test(e))},now:{...i.now,evaluate:e}}),l=(e,t,n={})=>o(r(e,{expand:!0}),t,{functions:c(n.now??(()=>new Date),t,n.search)}),u=(e,t,n,r={})=>({name:e,kind:t,label:n.label,required:t!==`boolean`&&!n.optional,...n.help!==void 0&&{help:n.help},...n.when!==void 0&&{when:n.when},...n.default!==void 0&&{default:n.default},...r}),d={text:(e,t)=>u(e,`text`,t,{...t.multiline&&{multiline:!0},...t.max!==void 0&&{max:t.max}}),integer:(e,t)=>u(e,`integer`,t),decimal:(e,t)=>u(e,`decimal`,t),boolean:(e,t)=>u(e,`boolean`,t),secret:(e,t)=>u(e,`secret`,t),date:(e,t)=>u(e,`date`,t),choice:(e,t)=>u(e,`choice`,t,`options`in t?{options:t.options.map(({value:e,label:t})=>({value:e,label:t}))}:{resource:t.resource}),checklist:(e,t)=>u(e,`checklist`,t,{...`items`in t&&{items:[...t.items]},...`from`in t&&{from:t.from}}),custom:(e,t)=>u(e,`custom`,t,{component:t.component,...t.props!==void 0&&{props:t.props}})},f={text:`text`,integer:`integer`,decimal:`decimal`,boolean:`boolean`,date:`date`,choice:`text`,secret:`text`,checklist:`json`,custom:`json`},p=e=>({name:e.name,column:e.name,type:e.options?`enum`:f[e.kind],nullable:!0,readOnly:!1,filterable:e.kind!==`custom`&&e.kind!==`checklist`&&e.kind!==`secret`,sortable:!1,aliases:[],...e.options&&{enumValues:e.options.map(e=>e.value)}}),m=e=>({name:`inputs`,table:{name:`inputs`},fields:Object.fromEntries(e.map(e=>[e.name,p(e)])),primaryKey:[]}),h=(t,r)=>{let i=t[r].when;if(i===void 0)return;let a=n(i);if(!a.ok)return a.errors.map(e=>e.message).join(`; `);if(!a.ast)return`it is empty`;let o=e(m(t.slice(0,r)),a.ast);return o.ok?o.filter:o.errors.map(e=>e.message).join(`; `)},g=e=>e.kind===`checklist`?e.items===void 0==(e.from===void 0)?[`input "${e.name}": a checklist takes either "items" or "from"`]:e.items&&e.items.length===0?[`input "${e.name}": a checklist needs at least one item`]:[]:[],_=e=>e.flatMap((t,n)=>{let r=[];e.findIndex(e=>e.name===t.name)!==n&&r.push(`input "${t.name}" is declared twice`),t.kind===`secret`&&t.default!==void 0&&r.push(`input "${t.name}": a secret takes no default`),t.kind!==`secret`&&t.options&&t.default!==void 0&&!t.options.some(e=>e.value===t.default)&&r.push(`input "${t.name}": default "${String(t.default)}" is not one of its options`);let i=h(e,n);return typeof i==`string`&&r.push(`input "${t.name}": "when" is not a valid condition over the inputs before it: ${i}`),[...r,...g(t)]}),v=(e,t)=>{let n=new Set,r={};return e.forEach((i,a)=>{let o=h(e,a);if(typeof o==`string`)throw Error(`Input "${i.name}": ${o}`);let s=o===void 0||l(o,r)===!0;s&&n.add(i.name),r[i.name]=s?t[i.name]??null:null}),n},y=(e,n=[])=>Object.entries(e).flatMap(([e,r])=>{let i=typeof r==`string`?t(r):void 0;if(i===void 0)return[];let a=n.find(e=>e.name===i);return a?a.kind===`secret`?[`set "${e}" names secret input "${i}", which an update never writes; take it in an action's handler`]:[]:[`set "${e}" names input "${i}", which it does not ask for`]}),b=(e,n)=>Object.fromEntries(Object.entries(e).flatMap(([e,r])=>{let i=typeof r==`string`?t(r):void 0;return i===void 0?[[e,r]]:Object.hasOwn(n,i)?[[e,n[i]]]:[]}));export{v as a,d as i,b as n,_ as r,y as t};
2
- //# debugId=58350516-569f-4a31-8d43-431492dab249
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:protobase-app":!0})}catch{}})();import{Jl as e,Rl as t,Xl as n,Yl as r,Zl as i,ql as a}from"./app-B94YfKGx.js";import{A as o}from"./vendor-t7Q7QbPu.js";var s=e=>()=>{throw Error(`Not implemented: ${e}() needs the database (the resource's search fields, trigram matching), so it cannot be evaluated against a record`)},c=(e,t,n)=>({...i,search:{...i.search,evaluate:n?e=>a(n,t,e):s(`search`)},similar:{...i.similar,evaluate:s(`similar`)},regex:{...i.regex,evaluate:(e,t)=>e.some(e=>typeof e==`string`&&new RegExp(t).test(e))},now:{...i.now,evaluate:e}}),l=(e,t,n={})=>o(r(e,{expand:!0}),t,{functions:c(n.now??(()=>new Date),t,n.search)}),u=(e,t,n,r={})=>({name:e,kind:t,label:n.label,required:t!==`boolean`&&!n.optional,...n.help!==void 0&&{help:n.help},...n.when!==void 0&&{when:n.when},...n.default!==void 0&&{default:n.default},...r}),d={text:(e,t)=>u(e,`text`,t,{...t.multiline&&{multiline:!0},...t.max!==void 0&&{max:t.max}}),integer:(e,t)=>u(e,`integer`,t),decimal:(e,t)=>u(e,`decimal`,t),boolean:(e,t)=>u(e,`boolean`,t),secret:(e,t)=>u(e,`secret`,t),date:(e,t)=>u(e,`date`,t),choice:(e,t)=>u(e,`choice`,t,`options`in t?{options:t.options.map(({value:e,label:t})=>({value:e,label:t}))}:{resource:t.resource}),checklist:(e,t)=>u(e,`checklist`,t,{...`items`in t&&{items:[...t.items]},...`from`in t&&{from:t.from}}),custom:(e,t)=>u(e,`custom`,t,{component:t.component,...t.props!==void 0&&{props:t.props}})},f={text:`text`,integer:`integer`,decimal:`decimal`,boolean:`boolean`,date:`date`,choice:`text`,secret:`text`,checklist:`json`,custom:`json`},p=e=>({name:e.name,column:e.name,type:e.options?`enum`:f[e.kind],nullable:!0,readOnly:!1,filterable:e.kind!==`custom`&&e.kind!==`checklist`&&e.kind!==`secret`,sortable:!1,aliases:[],...e.options&&{enumValues:e.options.map(e=>e.value)}}),m=e=>({name:`inputs`,table:{name:`inputs`},fields:Object.fromEntries(e.map(e=>[e.name,p(e)])),primaryKey:[]}),h=(t,r)=>{let i=t[r].when;if(i===void 0)return;let a=n(i);if(!a.ok)return a.errors.map(e=>e.message).join(`; `);if(!a.ast)return`it is empty`;let o=e(m(t.slice(0,r)),a.ast);return o.ok?o.filter:o.errors.map(e=>e.message).join(`; `)},g=e=>e.kind===`checklist`?e.items===void 0==(e.from===void 0)?[`input "${e.name}": a checklist takes either "items" or "from"`]:e.items&&e.items.length===0?[`input "${e.name}": a checklist needs at least one item`]:[]:[],_=e=>e.flatMap((t,n)=>{let r=[];e.findIndex(e=>e.name===t.name)!==n&&r.push(`input "${t.name}" is declared twice`),t.kind===`secret`&&t.default!==void 0&&r.push(`input "${t.name}": a secret takes no default`),t.kind!==`secret`&&t.options&&t.default!==void 0&&!t.options.some(e=>e.value===t.default)&&r.push(`input "${t.name}": default "${String(t.default)}" is not one of its options`);let i=h(e,n);return typeof i==`string`&&r.push(`input "${t.name}": "when" is not a valid condition over the inputs before it: ${i}`),[...r,...g(t)]}),v=(e,t)=>{let n=new Set,r={};return e.forEach((i,a)=>{let o=h(e,a);if(typeof o==`string`)throw Error(`Input "${i.name}": ${o}`);let s=o===void 0||l(o,r)===!0;s&&n.add(i.name),r[i.name]=s?t[i.name]??null:null}),n},y=(e,n=[])=>Object.entries(e).flatMap(([e,r])=>{let i=typeof r==`string`?t(r):void 0;if(i===void 0)return[];let a=n.find(e=>e.name===i);return a?a.kind===`secret`?[`set "${e}" names secret input "${i}", which an update never writes; take it in an action's handler`]:[]:[`set "${e}" names input "${i}", which it does not ask for`]}),b=(e,n)=>Object.fromEntries(Object.entries(e).flatMap(([e,r])=>{let i=typeof r==`string`?t(r):void 0;return i===void 0?[[e,r]]:Object.hasOwn(n,i)?[[e,n[i]]]:[]}));export{v as a,d as i,b as n,_ as r,y as t};
2
+ //# debugId=740ffb4d-0f31-4bf2-870a-569d62f8f9cc