@protobase/ui 0.123.0 → 0.123.1

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 (262) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/activity-chart/messages.d.ts +2 -2
  3. package/dist/app/charts/messages.d.ts +2 -2
  4. package/dist/app/confirm-sign-in-messages.d.ts +2 -2
  5. package/dist/app/conversation-page/conversation-page.d.ts +5 -4
  6. package/dist/app/conversation-page/conversation-page.js +14 -11
  7. package/dist/app/conversation-page/messages.d.ts +2 -2
  8. package/dist/app/conversation-page/thread-panel.d.ts +6 -2
  9. package/dist/app/conversation-page/thread-panel.js +12 -6
  10. package/dist/app/conversation-page/use-conversation-typing.d.ts +8 -0
  11. package/dist/app/conversation-page/use-conversation-typing.js +20 -0
  12. package/dist/app/create/messages.d.ts +2 -2
  13. package/dist/app/delete/messages.d.ts +2 -2
  14. package/dist/app/displays/messages.d.ts +2 -2
  15. package/dist/app/embedded-list/messages.d.ts +2 -2
  16. package/dist/app/export/messages.d.ts +2 -2
  17. package/dist/app/field-messages.d.ts +2 -2
  18. package/dist/app/field-types/custom-step-container/messages.d.ts +2 -2
  19. package/dist/app/field-types/runner-install/messages.d.ts +2 -2
  20. package/dist/app/field-types/workflow/definition.d.ts +1 -1
  21. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  22. package/dist/app/field-types/workflow/pins/pin-text.d.ts +1 -1
  23. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  24. package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
  25. package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
  26. package/dist/app/file-viewers/messages.d.ts +2 -2
  27. package/dist/app/focus/messages.d.ts +2 -2
  28. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  29. package/dist/app/gallery/messages.d.ts +2 -2
  30. package/dist/app/hand-order/messages.d.ts +2 -2
  31. package/dist/app/history/messages.d.ts +2 -2
  32. package/dist/app/import/messages.d.ts +2 -2
  33. package/dist/app/list-edit/messages.d.ts +2 -2
  34. package/dist/app/list-messages.d.ts +2 -2
  35. package/dist/app/messages.d.ts +2 -2
  36. package/dist/app/new-version/messages.d.ts +2 -2
  37. package/dist/app/pages/messages.d.ts +2 -2
  38. package/dist/app/record-chart/messages.d.ts +2 -2
  39. package/dist/app/record-messages.d.ts +2 -2
  40. package/dist/app/record-mode/shown-layout.d.ts +1 -1
  41. package/dist/app/record-row/messages.d.ts +2 -2
  42. package/dist/app/related-cards/messages.d.ts +2 -2
  43. package/dist/app/runtime/messages.d.ts +2 -2
  44. package/dist/app/saved/messages.d.ts +2 -2
  45. package/dist/app/search/messages.d.ts +2 -2
  46. package/dist/app/searches/messages.d.ts +2 -2
  47. package/dist/app-shell/messages.d.ts +2 -2
  48. package/dist/assistant-dock/messages.d.ts +2 -2
  49. package/dist/auth/messages.d.ts +2 -2
  50. package/dist/calls/messages.d.ts +2 -2
  51. package/dist/data-grid/column-spec.d.ts +1 -1
  52. package/dist/data-grid/messages.d.ts +2 -2
  53. package/dist/filter-panel/messages.d.ts +2 -2
  54. package/dist/inline-child-table/messages.d.ts +2 -2
  55. package/dist/invitations/messages.d.ts +2 -2
  56. package/dist/mailbox/messages.d.ts +2 -2
  57. package/dist/mentions/messages.d.ts +2 -2
  58. package/dist/mocks/customers.d.ts +1 -1
  59. package/dist/mocks/invoices.d.ts +2 -2
  60. package/dist/mocks/orders.d.ts +2 -2
  61. package/dist/notifications/bell/messages.d.ts +2 -2
  62. package/dist/organizations/messages.d.ts +2 -2
  63. package/dist/package.js +1 -1
  64. package/dist/primitives/messages.d.ts +2 -2
  65. package/dist/record-view/messages.d.ts +2 -2
  66. package/dist/record-view/use-autosave.d.ts +1 -1
  67. package/dist/relay/relay-context.js +1 -1
  68. package/dist/relay/relay-store.d.ts +1 -1
  69. package/dist/relay/relay-store.js +11 -18
  70. package/dist/relay/typing-line.d.ts +1 -6
  71. package/dist/relay/typing-line.js +4 -26
  72. package/dist/relay/use-relay-typing.d.ts +8 -0
  73. package/dist/relay/use-relay-typing.js +38 -0
  74. package/dist/relay/use-typing-sender.d.ts +5 -2
  75. package/dist/relay/use-typing-sender.js +5 -27
  76. package/dist/shell/assets/{account-page-D15oXHUN.js → account-page-DS2lZVD1.js} +2 -2
  77. package/dist/shell/assets/{app-CG26wvV-.js → app-1IZYQXW2.js} +13 -13
  78. package/dist/shell/assets/{assistant-shell-vuaTWe1u.js → assistant-shell-BIpWuqnT.js} +2 -2
  79. package/dist/shell/assets/board-display-Buo0YyZ5.js +2 -0
  80. package/dist/shell/assets/calendar-display-10AgoW3N.js +2 -0
  81. package/dist/shell/assets/{call-rings-CN1O37Vm.js → call-rings-BUUwC1QU.js} +2 -2
  82. package/dist/shell/assets/{calls-BgpYzNDg.js → calls-eQ3_Fp6k.js} +2 -2
  83. package/dist/shell/assets/{circle-alert-CYtCwklT.js → circle-alert-D7B_KeB7.js} +2 -2
  84. package/dist/shell/assets/{composed-page-CfvP7zgM.js → composed-page-Btkd6u0m.js} +2 -2
  85. package/dist/shell/assets/{composer-section-D8Iupdnl.js → composer-section-DUmPQLgo.js} +2 -2
  86. package/dist/shell/assets/{connect-route-2GF04qVw.js → connect-route-DQIlzdmb.js} +2 -2
  87. package/dist/shell/assets/{copy-field-Od-pW31E.js → copy-field-BfYo47Io.js} +2 -2
  88. package/dist/shell/assets/{create-route-BOGcWPvp.js → create-route-CSTAtNAw.js} +2 -2
  89. package/dist/shell/assets/{custom-step-container-field-B0JbqL0W.js → custom-step-container-field-Dxltzn8J.js} +4 -4
  90. package/dist/shell/assets/embedded-list-7l7TUHug.js +3 -0
  91. package/dist/shell/assets/{export-dialog-Cj0urwkZ.js → export-dialog-DWcXdfEj.js} +2 -2
  92. package/dist/shell/assets/{first-organization-page-Cr_eunjI.js → first-organization-page-77PHesxY.js} +2 -2
  93. package/dist/shell/assets/{graph-view-Ck8qrE0y.js → graph-view-DQOQDrmJ.js} +2 -2
  94. package/dist/shell/assets/{group-donut-_2BqPybE.js → group-donut-BGfuQ6iU.js} +2 -2
  95. package/dist/shell/assets/{guest-call-page-BKpxRWu7.js → guest-call-page-BdV2Hwhv.js} +3 -3
  96. package/dist/shell/assets/{html-viewer-PjyNPHSq.js → html-viewer-CXABej3u.js} +2 -2
  97. package/dist/shell/assets/{import-dialog-K0rhUDim.js → import-dialog-Cqu_xO6L.js} +2 -2
  98. package/dist/shell/assets/import-table-dialog-MwfAiAmM.js +2 -0
  99. package/dist/shell/assets/{index-xBA_aU0w.js → index-DJQ4glyU.js} +1 -1
  100. package/dist/shell/assets/invitations-page-C6LjToJR.js +2 -0
  101. package/dist/shell/assets/{layout-grid-Cr-RvgOt.js → layout-grid-C_uTX3Tb.js} +2 -2
  102. package/dist/shell/assets/{legend-item-BOIlaOng.js → legend-item-DzqFlC4D.js} +2 -2
  103. package/dist/shell/assets/list-page-CTGtveKF.js +4 -0
  104. package/dist/shell/assets/{maplibre-BOy1wGSA.js → maplibre-aCJmOb1H.js} +2 -2
  105. package/dist/shell/assets/{markdown-content-BrnTSgUW.js → markdown-content-CDmFTB6r.js} +2 -2
  106. package/dist/shell/assets/members-page-Defqhu24.js +2 -0
  107. package/dist/shell/assets/{message-content-BLdexhtW.js → message-content-CeLDUud8.js} +3 -3
  108. package/dist/shell/assets/messages-XnV72On0.js +2 -0
  109. package/dist/shell/assets/organization-page-Cdfaqvsh.js +2 -0
  110. package/dist/shell/assets/organizations-page-C37kxzUq.js +2 -0
  111. package/dist/shell/assets/{pending-invitation-row-2aTEUX6U.js → pending-invitation-row-Cyu7Ucej.js} +2 -2
  112. package/dist/shell/assets/{period-chart-Bf1e1Rfd.js → period-chart-T4rBI9Y2.js} +2 -2
  113. package/dist/shell/assets/{person-row-DM8AgaGL.js → person-row-DjxZAaa3.js} +2 -2
  114. package/dist/shell/assets/public-form-page-DaPFaXOT.js +2 -0
  115. package/dist/shell/assets/{record-lines-DO-JkjJw.js → record-lines-CSeqYQnm.js} +2 -2
  116. package/dist/shell/assets/{record-map-BM3T3O3d.js → record-map-l-E3DvxV.js} +2 -2
  117. package/dist/shell/assets/{record-opens-1_hpMdpy.js → record-opens-DPMtZw1p.js} +2 -2
  118. package/dist/shell/assets/record-page-DK2-zwXx.js +3 -0
  119. package/dist/shell/assets/{record-preview-WMGeft1g.js → record-preview-0BdCZkO9.js} +2 -2
  120. package/dist/shell/assets/{records-map-DA4QJ5o1.js → records-map-DSg2fbqb.js} +2 -2
  121. package/dist/shell/assets/render-node-qPc-4XAK.js +3 -0
  122. package/dist/shell/assets/reorder-button-Z_evPIxl.js +2 -0
  123. package/dist/shell/assets/{run-trace-view-DZqLuDCs.js → run-trace-view-ChuThRe4.js} +2 -2
  124. package/dist/shell/assets/{runner-install-field-CZFX7YDn.js → runner-install-field-8Ap9WvhK.js} +2 -2
  125. package/dist/shell/assets/{runtime-update-BSvbTfZB.js → runtime-update-B4DPgHIL.js} +2 -2
  126. package/dist/shell/assets/shared-protobase-ui-ClTsd7Ce.js +1 -0
  127. package/dist/shell/assets/{sheet-source-8s0DvsVl.js → sheet-source-D0v07JHr.js} +3 -3
  128. package/dist/shell/assets/sign-in-policy-page-CV3iE_o8.js +2 -0
  129. package/dist/shell/assets/start-block-queries-DJX-JI2P.js +2 -0
  130. package/dist/shell/assets/step-catalog-DSHlXxWA.js +2 -0
  131. package/dist/shell/assets/{step-panel-k-OfcV1o.js → step-panel-CF6x9K8Y.js} +2 -2
  132. package/dist/shell/assets/timeline-display-DpVKeXjG.js +2 -0
  133. package/dist/shell/assets/{trash-C576xGNJ.js → trash-Ccs0JhuD.js} +2 -2
  134. package/dist/shell/assets/{update-set-OSkktpzc.js → update-set-L1kw--38.js} +2 -2
  135. package/dist/shell/assets/use-calendar-move-DHCS22jF.js +2 -0
  136. package/dist/shell/assets/{use-display-rows-xrXX3vo7.js → use-display-rows-DcY7w9cN.js} +2 -2
  137. package/dist/shell/assets/{use-my-invitations-BzmabmV5.js → use-my-invitations-Dodu_ib9.js} +2 -2
  138. package/dist/shell/assets/{use-paged-search-1j6rT5dX.js → use-paged-search-Crpqw2e-.js} +2 -2
  139. package/dist/shell/assets/{use-run-trace-DhxoDhjX.js → use-run-trace-Cozaxsfl.js} +2 -2
  140. package/dist/shell/assets/{use-workflow-page-Dof4TXvO.js → use-workflow-page-eP9jGrad.js} +2 -2
  141. package/dist/shell/assets/{use-workflow-types-DlnnSIon.js → use-workflow-types-DjJ87TLL.js} +2 -2
  142. package/dist/shell/assets/{workflow-canvas-04KWcras.js → workflow-canvas-NJSHRDav.js} +4 -4
  143. package/dist/shell/assets/{workflow-field-DnRl3Zn3.js → workflow-field-D_pqVGeK.js} +3 -3
  144. package/dist/shell/assets/{workflow-graph-editor-CW-k7iPq.js → workflow-graph-editor-D4zxMPy4.js} +2 -2
  145. package/dist/shell/assets/{workflow-run-field-Cb04vQvU.js → workflow-run-field-DcL-8XS_.js} +3 -3
  146. package/dist/shell/assets/workflow-status-field-15bq7T5K.js +2 -0
  147. package/dist/shell/assets/workflow-workbench-CC_mXUfW.js +4 -0
  148. package/dist/shell/index.html +3 -3
  149. package/dist/shell/protobase.shell.json +2 -2
  150. package/dist/shell/protobase.sw.js +2 -2
  151. package/dist/shell-source-maps/assets/{account-page-D15oXHUN.js.map → account-page-DS2lZVD1.js.map} +1 -1
  152. package/dist/shell-source-maps/assets/{app-CG26wvV-.js.map → app-1IZYQXW2.js.map} +1 -1
  153. package/dist/shell-source-maps/assets/{assistant-shell-vuaTWe1u.js.map → assistant-shell-BIpWuqnT.js.map} +1 -1
  154. package/dist/shell-source-maps/assets/{board-display-DPYwY014.js.map → board-display-Buo0YyZ5.js.map} +1 -1
  155. package/dist/shell-source-maps/assets/{calendar-display-CPqQ_x_H.js.map → calendar-display-10AgoW3N.js.map} +1 -1
  156. package/dist/shell-source-maps/assets/{call-rings-CN1O37Vm.js.map → call-rings-BUUwC1QU.js.map} +1 -1
  157. package/dist/shell-source-maps/assets/{calls-BgpYzNDg.js.map → calls-eQ3_Fp6k.js.map} +1 -1
  158. package/dist/shell-source-maps/assets/{circle-alert-CYtCwklT.js.map → circle-alert-D7B_KeB7.js.map} +1 -1
  159. package/dist/shell-source-maps/assets/{composed-page-CfvP7zgM.js.map → composed-page-Btkd6u0m.js.map} +1 -1
  160. package/dist/shell-source-maps/assets/{composer-section-D8Iupdnl.js.map → composer-section-DUmPQLgo.js.map} +1 -1
  161. package/dist/shell-source-maps/assets/{connect-route-2GF04qVw.js.map → connect-route-DQIlzdmb.js.map} +1 -1
  162. package/dist/shell-source-maps/assets/{copy-field-Od-pW31E.js.map → copy-field-BfYo47Io.js.map} +1 -1
  163. package/dist/shell-source-maps/assets/{create-route-BOGcWPvp.js.map → create-route-CSTAtNAw.js.map} +1 -1
  164. package/dist/shell-source-maps/assets/{custom-step-container-field-B0JbqL0W.js.map → custom-step-container-field-Dxltzn8J.js.map} +1 -1
  165. package/dist/shell-source-maps/assets/{embedded-list-BiErfCKc.js.map → embedded-list-7l7TUHug.js.map} +1 -1
  166. package/dist/shell-source-maps/assets/{export-dialog-Cj0urwkZ.js.map → export-dialog-DWcXdfEj.js.map} +1 -1
  167. package/dist/shell-source-maps/assets/{first-organization-page-Cr_eunjI.js.map → first-organization-page-77PHesxY.js.map} +1 -1
  168. package/dist/shell-source-maps/assets/{graph-view-Ck8qrE0y.js.map → graph-view-DQOQDrmJ.js.map} +1 -1
  169. package/dist/shell-source-maps/assets/{group-donut-_2BqPybE.js.map → group-donut-BGfuQ6iU.js.map} +1 -1
  170. package/dist/shell-source-maps/assets/{guest-call-page-BKpxRWu7.js.map → guest-call-page-BdV2Hwhv.js.map} +1 -1
  171. package/dist/shell-source-maps/assets/{html-viewer-PjyNPHSq.js.map → html-viewer-CXABej3u.js.map} +1 -1
  172. package/dist/shell-source-maps/assets/{import-dialog-K0rhUDim.js.map → import-dialog-Cqu_xO6L.js.map} +1 -1
  173. package/dist/shell-source-maps/assets/{import-table-dialog-QNdJfEUq.js.map → import-table-dialog-MwfAiAmM.js.map} +1 -1
  174. package/dist/shell-source-maps/assets/{invitations-page-BA90Dbkk.js.map → invitations-page-C6LjToJR.js.map} +1 -1
  175. package/dist/shell-source-maps/assets/{layout-grid-Cr-RvgOt.js.map → layout-grid-C_uTX3Tb.js.map} +1 -1
  176. package/dist/shell-source-maps/assets/{legend-item-BOIlaOng.js.map → legend-item-DzqFlC4D.js.map} +1 -1
  177. package/dist/shell-source-maps/assets/{list-page-lR1G4P0j.js.map → list-page-CTGtveKF.js.map} +1 -1
  178. package/dist/shell-source-maps/assets/{maplibre-BOy1wGSA.js.map → maplibre-aCJmOb1H.js.map} +1 -1
  179. package/dist/shell-source-maps/assets/{markdown-content-BrnTSgUW.js.map → markdown-content-CDmFTB6r.js.map} +1 -1
  180. package/dist/shell-source-maps/assets/{members-page-VcGQ0wXn.js.map → members-page-Defqhu24.js.map} +1 -1
  181. package/dist/shell-source-maps/assets/{message-content-BLdexhtW.js.map → message-content-CeLDUud8.js.map} +1 -1
  182. package/dist/shell-source-maps/assets/{messages-DPRjc1DX.js.map → messages-XnV72On0.js.map} +1 -1
  183. package/dist/shell-source-maps/assets/{organization-page-DprBMbrZ.js.map → organization-page-Cdfaqvsh.js.map} +1 -1
  184. package/dist/shell-source-maps/assets/{organizations-page--4KynkcH.js.map → organizations-page-C37kxzUq.js.map} +1 -1
  185. package/dist/shell-source-maps/assets/{pending-invitation-row-2aTEUX6U.js.map → pending-invitation-row-Cyu7Ucej.js.map} +1 -1
  186. package/dist/shell-source-maps/assets/{period-chart-Bf1e1Rfd.js.map → period-chart-T4rBI9Y2.js.map} +1 -1
  187. package/dist/shell-source-maps/assets/{person-row-DM8AgaGL.js.map → person-row-DjxZAaa3.js.map} +1 -1
  188. package/dist/shell-source-maps/assets/{public-form-page-Dk47d12N.js.map → public-form-page-DaPFaXOT.js.map} +1 -1
  189. package/dist/shell-source-maps/assets/{record-lines-DO-JkjJw.js.map → record-lines-CSeqYQnm.js.map} +1 -1
  190. package/dist/shell-source-maps/assets/{record-map-BM3T3O3d.js.map → record-map-l-E3DvxV.js.map} +1 -1
  191. package/dist/shell-source-maps/assets/{record-opens-1_hpMdpy.js.map → record-opens-DPMtZw1p.js.map} +1 -1
  192. package/dist/shell-source-maps/assets/record-page-DK2-zwXx.js.map +1 -0
  193. package/dist/shell-source-maps/assets/{record-preview-WMGeft1g.js.map → record-preview-0BdCZkO9.js.map} +1 -1
  194. package/dist/shell-source-maps/assets/{records-map-DA4QJ5o1.js.map → records-map-DSg2fbqb.js.map} +1 -1
  195. package/dist/shell-source-maps/assets/{render-node-BYXtHiwx.js.map → render-node-qPc-4XAK.js.map} +1 -1
  196. package/dist/shell-source-maps/assets/{reorder-button-DlbkRsr1.js.map → reorder-button-Z_evPIxl.js.map} +1 -1
  197. package/dist/shell-source-maps/assets/{run-trace-view-DZqLuDCs.js.map → run-trace-view-ChuThRe4.js.map} +1 -1
  198. package/dist/shell-source-maps/assets/{runner-install-field-CZFX7YDn.js.map → runner-install-field-8Ap9WvhK.js.map} +1 -1
  199. package/dist/shell-source-maps/assets/{runtime-update-BSvbTfZB.js.map → runtime-update-B4DPgHIL.js.map} +1 -1
  200. package/dist/shell-source-maps/assets/{sheet-source-8s0DvsVl.js.map → sheet-source-D0v07JHr.js.map} +1 -1
  201. package/dist/shell-source-maps/assets/{sign-in-policy-page-BJN_TfWv.js.map → sign-in-policy-page-CV3iE_o8.js.map} +1 -1
  202. package/dist/shell-source-maps/assets/{start-block-queries-nfDrEnQD.js.map → start-block-queries-DJX-JI2P.js.map} +1 -1
  203. package/dist/shell-source-maps/assets/{step-catalog-QhL8OPW4.js.map → step-catalog-DSHlXxWA.js.map} +1 -1
  204. package/dist/shell-source-maps/assets/{step-panel-k-OfcV1o.js.map → step-panel-CF6x9K8Y.js.map} +1 -1
  205. package/dist/shell-source-maps/assets/{timeline-display-CbqpZrs6.js.map → timeline-display-DpVKeXjG.js.map} +1 -1
  206. package/dist/shell-source-maps/assets/{trash-C576xGNJ.js.map → trash-Ccs0JhuD.js.map} +1 -1
  207. package/dist/shell-source-maps/assets/{update-set-OSkktpzc.js.map → update-set-L1kw--38.js.map} +1 -1
  208. package/dist/shell-source-maps/assets/{use-calendar-move-DJbTVBiR.js.map → use-calendar-move-DHCS22jF.js.map} +1 -1
  209. package/dist/shell-source-maps/assets/{use-display-rows-xrXX3vo7.js.map → use-display-rows-DcY7w9cN.js.map} +1 -1
  210. package/dist/shell-source-maps/assets/{use-my-invitations-BzmabmV5.js.map → use-my-invitations-Dodu_ib9.js.map} +1 -1
  211. package/dist/shell-source-maps/assets/{use-paged-search-1j6rT5dX.js.map → use-paged-search-Crpqw2e-.js.map} +1 -1
  212. package/dist/shell-source-maps/assets/{use-run-trace-DhxoDhjX.js.map → use-run-trace-Cozaxsfl.js.map} +1 -1
  213. package/dist/shell-source-maps/assets/{use-workflow-page-Dof4TXvO.js.map → use-workflow-page-eP9jGrad.js.map} +1 -1
  214. package/dist/shell-source-maps/assets/{use-workflow-types-DlnnSIon.js.map → use-workflow-types-DjJ87TLL.js.map} +1 -1
  215. package/dist/shell-source-maps/assets/{workflow-canvas-04KWcras.js.map → workflow-canvas-NJSHRDav.js.map} +1 -1
  216. package/dist/shell-source-maps/assets/{workflow-field-DnRl3Zn3.js.map → workflow-field-D_pqVGeK.js.map} +1 -1
  217. package/dist/shell-source-maps/assets/{workflow-graph-editor-CW-k7iPq.js.map → workflow-graph-editor-D4zxMPy4.js.map} +1 -1
  218. package/dist/shell-source-maps/assets/{workflow-run-field-Cb04vQvU.js.map → workflow-run-field-DcL-8XS_.js.map} +1 -1
  219. package/dist/shell-source-maps/assets/{workflow-status-field-D4-yEdIA.js.map → workflow-status-field-15bq7T5K.js.map} +1 -1
  220. package/dist/shell-source-maps/assets/{workflow-workbench-BBRBLI2p.js.map → workflow-workbench-CC_mXUfW.js.map} +1 -1
  221. package/dist/status/messages.d.ts +2 -2
  222. package/dist/typing/conversation-typing.d.ts +15 -0
  223. package/dist/typing/conversation-typing.js +11 -0
  224. package/dist/typing/record-channel-typing.d.ts +14 -0
  225. package/dist/typing/record-channel-typing.js +33 -0
  226. package/dist/typing/typers-store.d.ts +15 -0
  227. package/dist/typing/typers-store.js +31 -0
  228. package/dist/typing/typing-names.d.ts +11 -0
  229. package/dist/typing/typing-names.js +29 -0
  230. package/dist/typing/typing.d.ts +49 -0
  231. package/dist/typing/typing.js +102 -0
  232. package/dist/typing/use-record-typing.d.ts +11 -0
  233. package/dist/typing/use-record-typing.js +51 -0
  234. package/dist/typing/use-typing-box.d.ts +16 -0
  235. package/dist/typing/use-typing-box.js +30 -0
  236. package/dist/users/messages.d.ts +2 -2
  237. package/package.json +5 -5
  238. package/dist/relay/typing.d.ts +0 -37
  239. package/dist/relay/typing.js +0 -78
  240. package/dist/shell/assets/board-display-DPYwY014.js +0 -2
  241. package/dist/shell/assets/calendar-display-CPqQ_x_H.js +0 -2
  242. package/dist/shell/assets/embedded-list-BiErfCKc.js +0 -3
  243. package/dist/shell/assets/import-table-dialog-QNdJfEUq.js +0 -2
  244. package/dist/shell/assets/invitations-page-BA90Dbkk.js +0 -2
  245. package/dist/shell/assets/list-page-lR1G4P0j.js +0 -4
  246. package/dist/shell/assets/members-page-VcGQ0wXn.js +0 -2
  247. package/dist/shell/assets/messages-DPRjc1DX.js +0 -2
  248. package/dist/shell/assets/organization-page-DprBMbrZ.js +0 -2
  249. package/dist/shell/assets/organizations-page--4KynkcH.js +0 -2
  250. package/dist/shell/assets/public-form-page-Dk47d12N.js +0 -2
  251. package/dist/shell/assets/record-page-C7tfbihg.js +0 -3
  252. package/dist/shell/assets/render-node-BYXtHiwx.js +0 -3
  253. package/dist/shell/assets/reorder-button-DlbkRsr1.js +0 -2
  254. package/dist/shell/assets/shared-protobase-ui-CDYOdP3n.js +0 -1
  255. package/dist/shell/assets/sign-in-policy-page-BJN_TfWv.js +0 -2
  256. package/dist/shell/assets/start-block-queries-nfDrEnQD.js +0 -2
  257. package/dist/shell/assets/step-catalog-QhL8OPW4.js +0 -2
  258. package/dist/shell/assets/timeline-display-CbqpZrs6.js +0 -2
  259. package/dist/shell/assets/use-calendar-move-DJbTVBiR.js +0 -2
  260. package/dist/shell/assets/workflow-status-field-D4-yEdIA.js +0 -2
  261. package/dist/shell/assets/workflow-workbench-BBRBLI2p.js +0 -4
  262. package/dist/shell-source-maps/assets/record-page-C7tfbihg.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-canvas-04KWcras.js","names":["createContext","createContext","useContext","useState","_Fragment","createContext","useContext","useContext","Title","_Fragment","useState","useState","useState","useRef","useMemo","createContext","useContext","useState","useMemo","useRef","useMemo","useState","ReactFlow","n","a","t","__toESM","require_react","require_jsx_runtime","Segmented","Select","Button","Input","Checkbox","guarded","X","createLucideIcon","Badge","cn","CircleAlert","LayoutGrid","schemaAt","innerMachine","pinType","expressionSource","inputSchema","machineDependencies","readText","isConditionPart","stepStatuses","dependsOn","orderOf","allStates","taskResource","selectParts","customStepOf","conditionParts","selectValue","expressionReferences","referenceValue","parseReference","pathOfName","pathOf","withoutKey","holdsSteps","conditionPin","inputPin","inputPins","triggerOutputs","stepOutputs","placedBoxes","fieldsOf","statusPin","workflowLayoutOf","statusKey","layoutKey","conditionKey","givenSchema","text","getBezierPath","Position","ReactFlowProvider","useReactFlow","Panel","useStore","Controls","index","Handle","useKeyPress","Background","useUpdateNodeInternals","useElk","__iconData","Pin","import_react","stepTypeLabels","stepTypeLabel","resource","listed","stepTypeOption","label","custom","stateTypeLabels","stateTypeLabel","type","stateLabel","state","types","entry","waits","inputLabels","inputLabel","name","title","triggerLabels","triggerTypeLabel","triggerType","trigger","triggerLabel","nodeStatusLabels","nodeStatusLabel","status","cacheAdvice","cacheForcedAgainst","cacheSwitch","advice","part","pathPart","path","pathFrom","breakId","source","makeId","target","key","conditionId","at","selectId","inHandle","outHandle","breakIn","makeOut","conditionOut","selectOut","selectInput","inKey","handle","outPath","import_jsx_runtime","wirePlace","pure","graph","node","edge","nodePlace","later","b","lastPlaceFirst","groups","order","removal","removals","place","placeOf","each","rulesOf","catchersOf","stateEdges","scope","machine","field","rule","catcher","machineGraph","parent","parts","steps","inner","dataEdges","own","edges","kind","from","nested","fromTrigger","definitionGraph","definition","states","start","nodeSize","portId","rootOptions","dataOrderOptions","mapPadding","isGroup","elkGraph","sized","size","extras","id","ports","port","end","pureIn","elk","inside","child","edgesIn","parentOf","candidate","wire","top","laidOutBoxes","boxes","visit","laidOut","layoutElk","engine","foldHeight","padding","shownInputs","shown","open","inputs","pin","pinnedHeight","header","outputs","foldable","kindLabels","typeLabel","pinColour","outputLabels","outputLabel","inputPinLabel","conditionTitles","conditionTitle","choice","conditionNodeTitle","statusLabels","statusLabel","pureHeader","selectWidth","makeFieldsShown","pureInputs","breakOutputs","read","reads","expressionHeight","nodeSizes","sizes","data","folded","fields","rowMiddle","titleHandle","pureTop","pinPorts","pins","pureParent","near","triggerFlowId","flowId","isPureFlowId","graphId","nodePins","flowNodes","box","cacheWarning","warned","warnings","marks","warning","problems","traces","dataOrder","selected","labelLength","shortened","edgeLabel","dataOrderEdge","flowEdges","pureFlowNodes","unwiredOrderEdges","step","wired","dataFlowEdges","AddAtContext","nodeTones","PinActionsContext","usePinActions","inlineKind","others","other","numberOf","typed","NumberInput","setTyped","className","value","event","onChange","PinValue","editor","checked","option","pinClass","InputRow","actions","connectable","bare","onValue","keys","OutputRow","GroupPins","count","FoldRow","PinColumns","editable","UnpinContext","MovedMark","unpin","execTops","sourcesOf","next","caught","useAddAt","addAt","SourceHandle","Sources","ProblemCount","WarningMark","TraceMark","trace","boxClass","Title$1","first","DataSides","OnlyWhen","condition","StateNode","moved","isConnectable","TriggerNode","graphViewStorageKey","readGraphView","storage","writeGraphView","view","browserStorage","useGraphView","setView","sideName","ExpressionText","readName","PatternRow","pattern","ConditionPins","out","before","ValueInput","SelectRows","disabled","write","setCase","position","change","titleOf","Title","PureNodeView","pureData","shownOutputs","PureOfferMenu","offer","onClose","isObject","samePath","booleanType","partReads","side","readsStatus","literalType","kinds","resultVariables","found","assign","variable","dataGraph","schemas","pathOfState","breaks","makes","conditions","selects","variables","targetHandle","expression","pinOf","fielded","broken","breakOf","known","schema","made","wireValue","one","sourceOf","reference","sourceOfReference","sourceOfSide","partOf","sides","sources","into","conditionOf","selectOf","operand","makeOf","required","declared","fieldSchema","extra","local","refusalText","refusal","isPinHandle","isObjectType","conditionOffer","choices","put","localsLeft","under","gone","usePins","edits","editing","setLocal","setOpen","setOffer","now","layout","current","check","to","finish","isValid","connection","connect","remove","after","bound","nodes","cut","removed","addSelect","latest","addCondition","point","frame","WireCheckContext","WireLine","fromX","fromY","fromPosition","toX","toY","toPosition","refused","connectionStatus","toNode","toHandle","fromHandle","fromNode","useLayout","setBoxes","shape","nodeTypes","scopeOf","FitOnLayout","flow","tidied","KeepCentre","width","previous","x","MeasureOnLayout","updateNodeInternals","ids","notDragged","Canvas","changed","byId","layoutJson","whole","manual","changeView","onLayoutChange","movable","dragged","setDragged","setTidied","chosen","setChosen","pinned","chosenEdge","setChosenEdge","isValidConnection","drop","placed","positions","tidy","onNodesChange","dropped","changes","only","shiftHeld","boxing","onSelect","onAddAt","fills","WorkflowCanvas","props"],"sources":["../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/pin.mjs","../../../src/app/field-types/workflow/labels.ts","../../../src/app/field-types/workflow/cache-advice.ts","../../../src/app/field-types/workflow/pins/pure-ids.ts","../../../src/app/field-types/workflow/pins/removal-order.ts","../../../src/app/field-types/workflow/definition-graph.ts","../../../src/app/field-types/workflow/graph-layout.ts","../../../src/app/field-types/workflow/pins/pin-layout.ts","../../../src/app/field-types/workflow/pins/pin-text.ts","../../../src/app/field-types/workflow/pins/node-sizes.ts","../../../src/app/field-types/workflow/pins/pure-parents.ts","../../../src/app/field-types/workflow/flow-elements.ts","../../../src/app/field-types/workflow/add-at-context.ts","../../../src/app/field-types/workflow/node-trace.ts","../../../src/app/field-types/workflow/pins/pin-actions.ts","../../../src/app/field-types/workflow/pins/pin-value.tsx","../../../src/app/field-types/workflow/pins/pin-rows.tsx","../../../src/app/field-types/workflow/unpin-context.ts","../../../src/app/field-types/workflow/moved-mark.tsx","../../../src/app/field-types/workflow/flow-nodes.tsx","../../../src/app/field-types/workflow/pins/graph-view.ts","../../../src/app/field-types/workflow/pins/condition-nodes.tsx","../../../src/app/field-types/workflow/pins/select-node.tsx","../../../src/app/field-types/workflow/pins/pure-nodes.tsx","../../../src/app/field-types/workflow/pins/pure-offer.tsx","../../../src/app/field-types/workflow/pins/data-graph.ts","../../../src/app/field-types/workflow/pins/refusal-text.ts","../../../src/app/field-types/workflow/pins/use-pins.ts","../../../src/app/field-types/workflow/pins/wire-line.tsx","../../../src/app/field-types/workflow/use-layout.ts","../../../src/app/field-types/workflow/workflow-canvas.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"pin\",\n size: 24,\n node: [\n [\"path\", { d: \"M12 17v5\", key: \"bb1du9\" }],\n [\n \"path\",\n {\n d: \"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z\",\n key: \"1nkz8b\"\n }\n ]\n ]\n};\n__iconData.node;\nconst Pin = createLucideIcon(__iconData);\n\nexport { __iconData, Pin as default };\n//# sourceMappingURL=pin.mjs.map\n","import type { WorkflowTypeList } from '@protobase/client'\nimport { customStepOf, taskResource, type State, type Trigger } from '@protobase/workflows'\nimport type { NodeStatus } from './node-trace'\nimport { text } from './messages'\n\n/**\n * The built-in step types' names, by the `Resource` a Task names; another shows the label the type list gives it,\n * `listed`, or, without one, as it is written.\n */\nconst stepTypeLabels: Record<string, () => string> = {\n 'app:http': () => text('stepHttp'),\n 'app:records.create': () => text('stepRecordsCreate'),\n 'app:records.update': () => text('stepRecordsUpdate'),\n 'app:records.get': () => text('stepRecordsGet'),\n 'app:records.list': () => text('stepRecordsList'),\n 'app:mail.send': () => text('stepMailSend'),\n 'app:mail.template': () => text('stepMailTemplate'),\n 'app:piece': () => text('stepPiece'),\n}\n\nexport const stepTypeLabel = (resource: string, listed?: string) => stepTypeLabels[resource]?.() ?? listed ?? resource\n\n/** A step type as a list to choose from names it: a custom step's version beside its label, as each version is a type of its own. */\nexport const stepTypeOption = (resource: string, listed?: string) => {\n const label = stepTypeLabel(resource, listed)\n const custom = customStepOf(resource)\n return custom ? text('stepTypeVersion', { type: label, version: custom.version }) : label\n}\n\n/** The states' types other than Task, which shows its step type's name. */\nconst stateTypeLabels: Record<Exclude<State['Type'], 'Task'>, () => string> = {\n Pass: () => text('typePass'),\n Choice: () => text('typeChoice'),\n Wait: () => text('typeWait'),\n Map: () => text('typeMap'),\n Block: () => text('typeBlock'),\n Succeed: () => text('typeSucceed'),\n Fail: () => text('typeFail'),\n}\n\nexport const stateTypeLabel = (type: Exclude<State['Type'], 'Task'>) => stateTypeLabels[type]?.() ?? type\n\n/**\n * What a state is, as its node and panel name it: its step type for a Task, by the label `types` lists, saying so when\n * it then waits for an outside result; else its type.\n */\nexport const stateLabel = (state: State, types?: WorkflowTypeList) => {\n if (state.Type !== 'Task') return stateTypeLabel(state.Type)\n const { type, waits } = taskResource(String(state.Resource))\n const label = stepTypeLabel(type, types?.step_types.find((entry) => entry.id === type)?.label)\n return waits ? text('stepTypeWaits', { type: label }) : label\n}\n\n/**\n * The arguments' and fields' names in the forms, by their name in the definition; another shows the title its schema\n * gives it, or, without one, as it is written.\n */\nconst inputLabels: Record<string, () => string> = {\n url: () => text('inputUrl'),\n method: () => text('inputMethod'),\n headers: () => text('inputHeaders'),\n query: () => text('inputQuery'),\n body: () => text('inputBody'),\n response: () => text('inputResponse'),\n resource: () => text('inputResource'),\n data: () => text('inputData'),\n key: () => text('inputKey'),\n filter: () => text('inputFilter'),\n order_by: () => text('inputOrderBy'),\n limit: () => text('inputLimit'),\n to: () => text('inputTo'),\n subject: () => text('inputSubject'),\n text: () => text('inputText'),\n html: () => text('inputHtml'),\n attachments: () => text('inputAttachments'),\n piece: () => text('inputPiece'),\n action: () => text('inputAction'),\n connection: () => text('inputConnection'),\n props: () => text('inputProps'),\n when: () => text('inputWhen'),\n body_schema: () => text('inputBodySchema'),\n}\n\nexport const inputLabel = (name: string, title?: string) => inputLabels[name]?.() ?? title ?? name\n\n/** The built-in triggers' names; another shows the label the type list gives it, `listed`, or as it is written. */\nconst triggerLabels: Record<string, () => string> = {\n manual: () => text('triggerManual'),\n 'app:record': () => text('triggerRecord'),\n}\n\nexport const triggerTypeLabel = (type: string, listed?: string) => triggerLabels[type]?.() ?? listed ?? type\n\n/** The type a trigger names: the one key it holds. */\nexport const triggerType = (trigger: Trigger | undefined): string | undefined => Object.keys(trigger ?? {})[0]\n\n/** The trigger's label: its type's, by the label `types` lists, or a prompt to choose one when it has none. */\nexport const triggerLabel = (trigger: Trigger | undefined, types?: WorkflowTypeList) => {\n const type = triggerType(trigger)\n return type === undefined ? text('triggerUnknown') : triggerTypeLabel(type, types?.triggers.find((entry) => entry.id === type)?.label)\n}\n\nconst nodeStatusLabels: Record<NodeStatus, () => string> = {\n succeeded: () => text('traceSucceeded'),\n caught: () => text('traceCaught'),\n retrying: () => text('traceRetrying'),\n failed: () => text('traceFailed'),\n current: () => text('traceCurrent'),\n}\n\n/** How a state did in a run, as its node's mark says it. */\nexport const nodeStatusLabel = (status: NodeStatus) => nodeStatusLabels[status]()\n","import type { WorkflowTypeList } from '@protobase/client'\nimport { taskResource, type State, type TaskState } from '@protobase/workflows'\n\n/** The cache advice the type list gives a Task's step type; none for a type that offers no cache. */\nexport const cacheAdvice = (state: TaskState, types: WorkflowTypeList | undefined) => types?.step_types.find((type) => type.id === taskResource(state.Resource).type)?.cache\n\n/** Whether a workflow forced the cache on for a step whose type advises against it, which its node marks. */\nexport const cacheForcedAgainst = (state: State, types: WorkflowTypeList | undefined) => state.Type === 'Task' && state.Cache === true && cacheAdvice(state, types)?.choice === 'discouraged'\n\n/**\n * The Task form's cache switch, for every type but one whose cache is `hidden`, a type without a cache included, which\n * a workflow may still force on. A `switch` type's is on as the Task says, else as its default, and off sets `Cache`\n * false; any other's is on only while the Task forces it, and off leaves the type to decide (`Cache` unset).\n */\nexport const cacheSwitch = (state: TaskState, types: WorkflowTypeList | undefined) => {\n const advice = cacheAdvice(state, types)\n if (advice?.choice === 'hidden') return\n if (advice?.choice === 'switch') return { on: state.Cache ?? advice.default === true, forces: false, offValue: false as const, disclaimer: undefined }\n return { on: state.Cache === true, forces: true, offValue: undefined, disclaimer: advice?.choice === 'discouraged' ? advice.disclaimer : undefined }\n}\n","// React Flow finds nodes and handles by CSS selectors it builds from their ids unescaped, so ids hold no quotes:\n// each name in them is URI-encoded, and a path is its names each after a `/`.\nconst part = (name: string) => encodeURIComponent(name)\nconst pathPart = (path: readonly string[]) => path.map((name) => `/${part(name)}`).join('')\nconst pathFrom = (text: string) => (text === '' ? [] : text.split('/').slice(1).map(decodeURIComponent))\n\n/** A Break node's id: the node whose value it takes apart, and where that value is in what the node gives. */\nexport const breakId = (source: string, path: readonly string[]) => `break:${part(source)}|${pathPart(path)}`\n\n/** A Make node's id: the step whose argument it builds, and the argument. */\nexport const makeId = (target: string, key: string) => `make:${part(target)}|${part(key)}`\n\n/** A condition node's id: the step whose Condition it is part of, and where it is among the Condition's nodes. */\nexport const conditionId = (target: string, at: readonly number[]) => `when:${part(target)}|${at.join('/')}`\n\n/** A Select node's id: the step whose argument it chooses, and the argument. */\nexport const selectId = (target: string, key: string) => `select:${part(target)}|${part(key)}`\n\n/** Whether a node id is a Break's, a Make's, a condition node's or a Select's, which the editor draws and the document holds no state for. */\nexport const isPureId = (id: string) => id.startsWith('break:') || id.startsWith('make:') || id.startsWith('when:') || id.startsWith('select:')\n\n/** The handle of an input pin, by its argument or field. */\nexport const inHandle = (key: string) => `in:${part(key)}`\n\n/** The handle of an output pin, by where its value is in what the node gives. */\nexport const outHandle = (path: readonly string[]) => `out:${pathPart(path)}`\n\n/** The handle a Break takes its object at, and the one a Make gives its object from. */\nexport const breakIn = 'break-in'\nexport const makeOut = 'make-out'\n\n/** The handle a condition node gives its yes or no from. */\nexport const conditionOut = 'condition-out'\n\n/** The handle a Select gives the value it chose from, and the key of the input it looks at. */\nexport const selectOut = 'select-out'\nexport const selectInput = 'value'\n\n/** An input handle's argument or field; undefined for any other handle. */\nexport const inKey = (handle: string | null | undefined) => (handle?.startsWith('in:') ? decodeURIComponent(handle.slice(3)) : undefined)\n\n/** An output handle's path; undefined for any other handle. */\nexport const outPath = (handle: string | null | undefined): string[] | undefined => (handle?.startsWith('out:') ? pathFrom(handle.slice(4)) : undefined)\n","import type { DataEdge, DataGraph, PureNode } from './data-graph'\nimport { inKey } from './pure-ids'\n\n/**\n * Where among a step's Condition's nodes a removal takes an input away: a wire into a condition node's input, by the\n * node's place and the input; undefined for any other wire.\n */\nexport const wirePlace = (graph: DataGraph, edge: Pick<DataEdge, 'target' | 'targetHandle'>) => {\n const pure = graph.pure.find((node) => node.id === edge.target)\n const key = inKey(edge.targetHandle)\n return pure?.kind === 'condition' && key !== undefined ? { step: pure.target, at: [...pure.at, Number(key)] } : undefined\n}\n\n/** Where a condition node's removal takes its input away among its step's Condition's nodes; undefined for any other node. */\nexport const nodePlace = (node: PureNode) => (node.kind === 'condition' ? { step: node.target, at: node.at } : undefined)\n\n// Whether `a` comes after `b` among a Condition's nodes, by the inputs on the way to it\nconst later = (a: readonly number[], b: readonly number[]): number => {\n for (let index = 0; index < Math.min(a.length, b.length); index++) if (a[index] !== b[index]) return a[index]! - b[index]!\n return a.length - b.length\n}\n\n/**\n * Removals in the order that keeps each one's place: an All of or an Any of that loses an input moves the inputs after\n * it up, so the removals in one step's Condition go together, the last place first, each place as the graph drawn\n * before them all names it. The steps keep the order their first removal came in, and every other removal its own.\n */\nexport const lastPlaceFirst = <T>(_graph: DataGraph, removals: readonly T[], placeOf: (removal: T) => { step: string; at: number[] } | undefined): T[] => {\n const groups = new Map<string, { removal: T; at: number[] }[]>()\n const order: (T | string)[] = []\n for (const removal of removals) {\n const place = placeOf(removal)\n if (!place) {\n order.push(removal)\n continue\n }\n const key = `step:${place.step}`\n if (!groups.has(key)) {\n groups.set(key, [])\n order.push(key)\n }\n groups.get(key)!.push({ removal, at: place.at })\n }\n return order.flatMap((each) => (typeof each === 'string' && groups.has(each) ? groups.get(each)!.toSorted((a, b) => later(b.at, a.at)).map(({ removal }) => removal) : [each as T]))\n}\n","import { dependsOn, innerMachine, machineDependencies, orderOf, type Definition, type Machine, type State, type Trigger } from '@protobase/workflows'\nimport { pathOf, triggerId, type StatePath } from './definition'\n\n/**\n * Where an edge leaves its node, and so what it sets when drawn: `next` a state's Next, `rule` a Choice rule's Next,\n * `default` a Choice's Default, `catch` a catcher's Next, `start` the StartAt of the machine the trigger starts. In data\n * order an edge is drawn from what a state reads instead: `reads`, some of its variables, or `status`, its status\n * alone; and `start` from the trigger to each state that reads from no other.\n */\nexport type EdgeKind = 'next' | 'rule' | 'default' | 'catch' | 'start' | 'reads' | 'status'\n\nexport type GraphNode =\n | { kind: 'trigger'; id: typeof triggerId; trigger: Trigger }\n /** `parent` is the path of the Map or Block whose steps it is one of, `first` whether its machine starts at it. */\n | { kind: 'state'; id: StatePath; name: string; state: State; scope: string[]; parent?: StatePath; first: boolean }\n\n/** An edge, by the field of its source state that names its target (`Next`, `Choices[0].Next`, `Catch[1].Next`). */\nexport type GraphEdge = { id: string; kind: EdgeKind; source: string; target: StatePath; field: string; label?: string }\n\nexport type Graph = { nodes: GraphNode[]; edges: GraphEdge[] }\n\nconst rulesOf = (state: State) => (state.Type === 'Choice' && Array.isArray(state.Choices) ? state.Choices : [])\nconst catchersOf = (state: State) => ('Catch' in state && Array.isArray(state.Catch) ? state.Catch : [])\n\n// The edges a state names, each to a state of its own machine; one naming no state there is left out, and the\n// definition check names it on the state.\nconst stateEdges = (machine: Machine, scope: string[], name: string, state: State): GraphEdge[] => {\n const source = pathOf(scope, name)\n const edge = (kind: EdgeKind, field: string, target: string, label?: string): GraphEdge[] =>\n Object.hasOwn(machine.States, target) ? [{ id: `${source}\\n${field}`, kind, source, target: pathOf(scope, target), field, ...(label !== undefined && { label }) }] : []\n return [\n ...('Next' in state && typeof state.Next === 'string' ? edge('next', 'Next', state.Next) : []),\n ...rulesOf(state).flatMap((rule, index) => edge('rule', `Choices[${index}].Next`, rule.Next, rule.Condition)),\n ...(state.Type === 'Choice' && typeof state.Default === 'string' ? edge('default', 'Default', state.Default) : []),\n ...catchersOf(state).flatMap((catcher, index) => (catcher.Next === undefined ? [] : edge('catch', `Catch[${index}].Next`, catcher.Next, Array.isArray(catcher.ErrorEquals) ? catcher.ErrorEquals.join(', ') : undefined))),\n ]\n}\n\nconst machineGraph = (machine: Machine, scope: string[]): Graph => {\n const parent = scope.length > 0 ? scope.join('/') : undefined\n const parts = Object.entries(machine.States).map(([name, state]): Graph => {\n const node: GraphNode = { kind: 'state', id: pathOf(scope, name), name, state, scope, ...(parent !== undefined && { parent }), first: machine.StartAt === name }\n const steps = innerMachine(state)\n const inner = steps?.States ? machineGraph(steps, [...scope, name]) : { nodes: [], edges: [] }\n return { nodes: [node, ...inner.nodes], edges: [...stateEdges(machine, scope, name, state), ...inner.edges] }\n })\n return { nodes: parts.flatMap((part) => part.nodes), edges: parts.flatMap((part) => part.edges) }\n}\n\n// In data order, an edge from each state to each one that reads from it: its variables, or only its status, which runs\n// after it all the same; and from the trigger to each state that reads from none.\nconst dataEdges = (machine: Machine, scope: string[], fromTrigger: boolean): GraphEdge[] => {\n const dependencies = machineDependencies(machine)\n return [...dependencies].flatMap(([name, own]): GraphEdge[] => {\n const target = pathOf(scope, name)\n const edges = [...dependsOn(own)].map((from): GraphEdge => {\n const kind = own.data.has(from) ? 'reads' : 'status'\n return { id: `${pathOf(scope, from)}\\n${kind}\\n${target}`, kind, source: pathOf(scope, from), target, field: kind }\n })\n const inner = innerMachine(machine.States[name])\n const nested = inner?.States ? dataEdges(inner, [...scope, name], false) : []\n const root: GraphEdge[] = fromTrigger && edges.length === 0 ? [{ id: `\\nStart\\n${target}`, kind: 'start', source: triggerId, target, field: 'StartAt' }] : []\n return [...root, ...edges, ...nested]\n })\n}\n\n/**\n * The definition as a graph: the trigger, each state a node in the order the definition lists them, a Map's or a\n * Block's states inside it, and an edge for each state a state names. A Map or Block comes before the states inside it. The definition holds\n * no positions; the layout places the nodes.\n */\nexport const definitionGraph = (definition: Definition): Graph => {\n const machine = definition.stateMachine\n const states = machineGraph(machine, [])\n if (orderOf(definition) === 'data') return { nodes: [{ kind: 'trigger', id: triggerId, trigger: definition.trigger }, ...states.nodes.map((node) => (node.kind === 'state' ? { ...node, first: false } : node))], edges: dataEdges(machine, [], true) }\n const start: GraphEdge[] = machine.StartAt !== undefined && Object.hasOwn(machine.States, machine.StartAt) ? [{ id: '\\nStartAt', kind: 'start', source: triggerId, target: machine.StartAt, field: 'StartAt' }] : []\n return { nodes: [{ kind: 'trigger', id: triggerId, trigger: definition.trigger }, ...states.nodes], edges: [...start, ...states.edges] }\n}\n","import type { ElkNode } from 'elkjs/lib/elk-api'\nimport type { Graph, GraphNode } from './definition-graph'\nimport { holdsSteps } from './definition'\n\n/** A node's box: where its top left corner is, within the Map or Block it is inside or else the canvas, and its size. */\nexport type Box = { x: number; y: number; width: number; height: number }\n\n/** What lays a graph out: ELK's `layout`, in a worker in the browser. */\nexport type LayoutEngine = { layout: (graph: ElkNode) => Promise<ElkNode> }\n\n/** The size of a node the layout is given no size for: the layout places nodes, it does not size them. */\nexport const nodeSize = { width: 224, height: 64 }\n\n/**\n * What the layout places besides the graph: each node's size by its id, the Break, Make, condition and Select nodes\n * with the Map or Block each is inside, the wires between pins, which pull the nodes they join into order as edges do,\n * and where each node's pins are, so the wires meet their nodes where they are drawn and cross as little as they can.\n */\nexport type LayoutExtras = {\n sizes?: ReadonlyMap<string, { width: number; height: number }>\n pure?: readonly { id: string; parent?: string }[]\n wires?: readonly { id: string; source: string; target: string; sourceHandle?: string; targetHandle?: string }[]\n ports?: ReadonlyMap<string, readonly { handle: string; side: 'in' | 'out'; y: number }[]>\n /** The workflow runs in data order, where nodes go beside what reads them. */\n dataOrder?: boolean\n}\n\n// A pin's port on its node, as ELK names it\nconst portId = (node: string, handle: string) => `${node}\\u0000${handle}`\n\n// ELK's layered algorithm from left to right, as execution runs in Blueprints, laying out each Map's or Block's states\n// inside it, with room for its title on top.\nconst rootOptions = {\n 'elk.algorithm': 'layered',\n 'elk.direction': 'RIGHT',\n 'elk.hierarchyHandling': 'INCLUDE_CHILDREN',\n 'elk.layered.spacing.nodeNodeBetweenLayers': '72',\n 'elk.spacing.nodeNode': '32',\n 'elk.edgeLabels.inline': 'false',\n}\n\n// In data order, each node in the layer just before what reads it, so a Break, a condition node or a Select stands\n// beside its reader and a step beside the steps that read it. In sequence order, where states that end the run would\n// all go to the last layer, ELK balances the layers instead.\nconst dataOrderOptions = { 'elk.layered.layering.strategy': 'LONGEST_PATH' }\nconst mapPadding = { 'elk.padding': '[top=48,left=24,bottom=24,right=24]' }\n\nconst isGroup = (node: GraphNode) => node.kind === 'state' && holdsSteps(node.state)\n\n/**\n * The graph as ELK's: each node a box of `nodeSize`, a Map or Block a box around the nodes inside it, which ELK sizes,\n * and each edge inside the Map or Block its two ends are in. Edge labels are left out: the canvas draws them on the edge's middle.\n */\nexport const elkGraph = (graph: Graph, extras: LayoutExtras = {}): ElkNode => {\n // A node with its pins as ports where they are drawn, which ELK keeps in place as it orders the nodes of each layer\n const sized = (id: string): ElkNode => {\n const size = extras.sizes?.get(id) ?? nodeSize\n const ports = extras.ports?.get(id)\n if (!ports?.length) return { id, ...size }\n return {\n id,\n ...size,\n layoutOptions: { 'elk.portConstraints': 'FIXED_POS' },\n ports: ports.map((port) => ({ id: portId(id, port.handle), x: port.side === 'in' ? 0 : size.width, y: port.y, width: 0, height: 0, layoutOptions: { 'elk.port.side': port.side === 'in' ? 'WEST' : 'EAST' } })),\n }\n }\n // A wire's end: its pin's port where the node has one, else the node\n const end = (node: string, handle: string | undefined) => (handle !== undefined && extras.ports?.get(node)?.some((port) => port.handle === handle) ? portId(node, handle) : node)\n const pureIn = (parent: string | undefined) => (extras.pure ?? []).filter((pure) => pure.parent === parent).map((pure) => sized(pure.id))\n const elk = (node: GraphNode): ElkNode => {\n if (!isGroup(node)) return sized(node.id)\n const inside = graph.nodes.filter((child) => child.kind === 'state' && child.parent === node.id)\n return { id: node.id, layoutOptions: mapPadding, children: [...inside.map(elk), ...pureIn(node.id)], edges: edgesIn(node.id) }\n }\n const parentOf = (id: string) => {\n const pure = extras.pure?.find((candidate) => candidate.id === id)\n if (pure) return pure.parent\n const node = graph.nodes.find((candidate) => candidate.id === id)\n return node?.kind === 'state' ? node.parent : undefined\n }\n // A wire joins two nodes of one machine; one into or out of a Map is drawn but not laid out by\n const edgesIn = (parent: string | undefined) => [\n ...graph.edges.filter((edge) => parentOf(edge.target) === parent).map((edge) => ({ id: edge.id, sources: [edge.source], targets: [edge.target] })),\n ...(extras.wires ?? [])\n .filter((wire) => parentOf(wire.target) === parent && parentOf(wire.source) === parent)\n .map((wire) => ({ id: wire.id, sources: [end(wire.source, wire.sourceHandle)], targets: [end(wire.target, wire.targetHandle)] })),\n ]\n const top = graph.nodes.filter((node) => node.kind === 'trigger' || node.parent === undefined)\n return { id: 'root', layoutOptions: extras.dataOrder ? { ...rootOptions, ...dataOrderOptions } : rootOptions, children: [...top.map(elk), ...pureIn(undefined)], edges: edgesIn(undefined) }\n}\n\n/** Each node's box from ELK's laid out graph, by node id; a node inside a Map or Block is placed within it. */\nexport const laidOutBoxes = (laidOut: ElkNode): Map<string, Box> => {\n const boxes = new Map<string, Box>()\n const visit = (node: ElkNode) => {\n for (const child of node.children ?? []) {\n boxes.set(child.id, { x: child.x ?? 0, y: child.y ?? 0, width: child.width ?? nodeSize.width, height: child.height ?? nodeSize.height })\n visit(child)\n }\n }\n visit(laidOut)\n return boxes\n}\n\n/** The graph `elk` describes laid out by `engine`: each node's box. */\nexport const layoutElk = async (engine: LayoutEngine, elk: ElkNode) => laidOutBoxes(await engine.layout(elk))\n\n/** The graph laid out by `engine`: each node's box. */\nexport const layoutGraph = (engine: LayoutEngine, graph: Graph, extras?: LayoutExtras) => layoutElk(engine, elkGraph(graph, extras))\n","import type { InputPin, OutputPin } from './node-pins'\n\n/** A node's header, holding its type and name with the execution handles beside it, and each pin's row. */\nexport const headerHeight = 52\nexport const rowHeight = 26\nconst foldHeight = 24\nconst padding = 8\n\n/** The width of a step's or the trigger's node, and of a Break's or a Make's. */\nexport const stepWidth = 296\nexport const pureWidth = 216\n\n/** The height of an Expression's text, which scrolls inside past it. */\nexport const expressionTextHeight = 64\n\n/**\n * The inputs a node shows: the ones its type needs and the ones that hold something, all of them once it is opened,\n * so a node stays small; with how many it folds away.\n */\nexport const shownInputs = (inputs: readonly InputPin[], open: boolean): { shown: InputPin[]; folded: number } => {\n const shown = open ? [...inputs] : inputs.filter((pin) => pin.required || pin.state !== 'empty')\n return { shown, folded: inputs.length - shown.length }\n}\n\n/** A node's height: its header, then a row per pin on the side with more, and the row that folds its optional inputs. */\nexport const pinnedHeight = (inputs: number, outputs: readonly OutputPin[] | number, foldable: boolean, header = headerHeight) => {\n const rows = Math.max(inputs, typeof outputs === 'number' ? outputs : outputs.length)\n return header + rows * rowHeight + (foldable ? foldHeight : 0) + padding\n}\n","import type { PinKind, PinType } from '@protobase/workflows'\nimport { inputLabel } from '../labels'\nimport { text } from '../messages'\nimport type { ConditionChoice } from './condition-edits'\nimport type { ConditionNode } from './data-graph'\nimport { conditionKey, statusKey } from './node-pins'\n\nconst kindLabels: Record<PinKind | 'any', () => string> = {\n string: () => text('typeString'),\n integer: () => text('typeInteger'),\n number: () => text('typeNumber'),\n boolean: () => text('typeBoolean'),\n object: () => text('typeObject'),\n array: () => text('typeArray'),\n null: () => text('typeNull'),\n any: () => text('typeAny'),\n}\n\n/** A pin's type in words: its title, such as Contact, or what it can be, such as Text or Whole number. */\nexport const typeLabel = (type: PinType) => {\n if (type.title !== undefined) return type.title\n if (type.kinds === 'any') return kindLabels.any()\n return type.kinds.map((kind) => kindLabels[kind]()).reduce((first, second) => text('typeOr', { first, second }))\n}\n\n/** The kind a pin is coloured by: its first, or any. */\nexport const pinColour = (type: PinType) => (type.kinds === 'any' ? 'any' : type.kinds[0]!)\n\nconst outputLabels: Record<string, () => string> = {\n status: () => text('outputStatus'),\n headers: () => text('outputHeaders'),\n body: () => text('outputBody'),\n record: () => text('outputRecord'),\n resource: () => text('outputResource'),\n key: () => text('outputKey'),\n records: () => text('outputRecords'),\n message_id: () => text('outputMessageId'),\n}\n\n/**\n * An output pin's name: the whole of what a node gives, a value a built-in type returns by its label, else the\n * field's name, as a Break names each field of an object, such as a record's.\n */\nexport const outputLabel = (path: readonly string[], trigger = false, field = false) => {\n if (path.length === 0) return trigger ? text('pinRunInput') : text('pinResult')\n if (path.length === 1 && path[0] === statusKey) return text('stepStatusType')\n const name = path.at(-1)!\n // Only a label of its own: a field named as an object's member, such as __proto__, is shown by its name\n return field || !Object.hasOwn(outputLabels, name) ? name : outputLabels[name]!()\n}\n\n/** An input pin's name: a built-in argument by its label, else its name. */\nexport const inputPinLabel = (key: string) => (key === conditionKey ? text('onlyWhen') : inputLabel(key))\n\nconst conditionTitles: Record<ConditionChoice, () => string> = {\n '=': () => text('conditionEquals'),\n '!=': () => text('conditionNotEquals'),\n '>': () => text('conditionGreater'),\n '<': () => text('conditionLess'),\n matches: () => text('conditionMatches'),\n and: () => text('conditionAnd'),\n or: () => text('conditionOr'),\n not: () => text('conditionNot'),\n expression: () => text('conditionExpression'),\n}\n\n/** A condition node's name, as the canvas offers it and titles it: Equals, Not equals, Greater, Less, Matches, All of, Any of, Not or Expression. */\nexport const conditionTitle = (choice: ConditionChoice) => conditionTitles[choice]()\n\n/** The title of a condition node on the canvas. */\nexport const conditionNodeTitle = ({ part }: ConditionNode) => conditionTitle(part.kind === 'compare' || part.kind === 'logic' ? part.op : part.kind)\n\nconst statusLabels: Record<string, () => string> = {\n SUCCEEDED: () => text('statusSucceeded'),\n FAILED: () => text('statusFailed'),\n TIMED_OUT: () => text('statusTimedOut'),\n ABORTED: () => text('statusAborted'),\n SKIPPED: () => text('statusSkipped'),\n}\n\n/** What a step's status is, in words: Succeeded for `SUCCEEDED`; any other as it is. */\nexport const statusLabel = (status: string) => (Object.hasOwn(statusLabels, status) ? statusLabels[status]!() : status)\n","import type { Graph } from '../definition-graph'\nimport { holdsSteps } from '../definition'\nimport type { BreakNode, DataEdge, DataGraph, PureNode } from './data-graph'\nimport type { InputPin, OutputPin } from './node-pins'\nimport { breakIn, conditionOut, inHandle, makeOut, outHandle, selectOut } from './pure-ids'\nimport { expressionTextHeight, headerHeight, pinnedHeight, pureWidth, rowHeight, shownInputs, stepWidth } from './pin-layout'\n\n/** A node's size, as the layout places it. */\nexport type Size = { width: number; height: number }\n\n// A Break's or a Make's title is one line\nconst pureHeader = 34\n\n// A Select's cases each hold two values side by side\nconst selectWidth = 280\n\n// A Make shows every field it builds, as Blueprints draw one, unless it has more than this\nconst makeFieldsShown = 8\n\n/** The inputs a Make shows and how many it folds away, a condition node all of its own; a Break takes no inputs of its own. */\nexport const pureInputs = (pure: PureNode, open: boolean): { shown: InputPin[]; folded: number } => {\n if (pure.kind === 'condition') return { shown: pure.inputs, folded: 0 }\n return pure.kind === 'make' ? shownInputs(pure.inputs, open || pure.inputs.length <= makeFieldsShown) : { shown: [], folded: 0 }\n}\n\n/**\n * The fields a Break shows: those something reads, through a wire or an expression, all of them once it is opened or\n * while nothing reads any; with how many it folds away, and whether it has a row to fold or open them.\n */\nexport const breakOutputs = (pure: BreakNode, edges: readonly DataEdge[], open: boolean): { shown: OutputPin[]; folded: number; foldable: boolean } => {\n const read = new Set(edges.filter((edge) => edge.source === pure.id).map((edge) => edge.sourceHandle))\n const reads = pure.outputs.filter((pin) => read.has(outHandle(pin.path)))\n const foldable = reads.length > 0 && reads.length < pure.outputs.length\n if (open || !foldable) return { shown: pure.outputs, folded: 0, foldable }\n return { shown: reads, folded: pure.outputs.length - reads.length, foldable }\n}\n\n// An Expression's text above the values it reads, and the space between them\nconst expressionHeight = (reads: number) => pureHeader + 4 + expressionTextHeight + 4 + reads * rowHeight + 8\n\n/**\n * Every node's size by its id: a step's or the trigger's by the pins it shows, a Break's or a Make's too; a Map or a\n * Block is left out, as the layout sizes it around the states inside it.\n */\nexport const nodeSizes = (graph: Graph, data: DataGraph, open: ReadonlySet<string>): Map<string, Size> => {\n const sizes = new Map<string, Size>()\n for (const node of graph.nodes) {\n if (node.kind === 'state' && holdsSteps(node.state)) continue\n const { shown, folded } = shownInputs(data.inputs.get(node.id) ?? [], open.has(node.id))\n sizes.set(node.id, { width: stepWidth, height: pinnedHeight(shown.length, data.outputs.get(node.id) ?? [], folded > 0 || open.has(node.id)) })\n }\n for (const pure of data.pure) {\n if (pure.kind === 'condition' && pure.part.kind === 'expression') {\n sizes.set(pure.id, { width: pureWidth, height: expressionHeight(pure.inputs.length) })\n continue\n }\n // A Select: the value it looks at, a row per case, what it gives otherwise, and the row that adds a case\n if (pure.kind === 'select') {\n sizes.set(pure.id, { width: selectWidth, height: pinnedHeight(pure.part.cases.length + 3, 1, false, pureHeader) })\n continue\n }\n if (pure.kind === 'break') {\n const fields = breakOutputs(pure, data.edges, open.has(pure.id))\n sizes.set(pure.id, { width: pureWidth, height: pinnedHeight(0, fields.shown.length, fields.foldable, pureHeader) })\n continue\n }\n const { shown, folded } = pureInputs(pure, open.has(pure.id))\n sizes.set(pure.id, { width: pureWidth, height: pinnedHeight(shown.length, 1, pure.kind === 'make' && (folded > 0 || open.has(pure.id)), pureHeader) })\n }\n return sizes\n}\n\n/** Where a pin's dot is on its node, for the layout: its handle, the side it is on, and how far down it is. */\nexport type PinPort = { handle: string; side: 'in' | 'out'; y: number }\n\n// A row's middle, below a header and the rows before it\nconst rowMiddle = (top: number, index: number) => top + index * rowHeight + rowHeight / 2\n\n// The handle a pure node gives its value from, or takes its object at, beside its title\nconst titleHandle = 13\n\n// The rows of a pure node start below its title, after the room its first row leaves above it\nconst pureTop = pureHeader + 4\n\n/**\n * Where each node's pins are, by its id, as the canvas draws them, so the layout orders nodes by where their wires\n * meet them: a step's and the trigger's inputs and outputs in their rows below the header, a Break's object beside its\n * title and its fields shown below, and a Make's, a condition node's or a Select's value beside its title and its\n * inputs below. A Map's or a Block's pins sit on its header's edge, which the layout lets it place.\n */\nexport const pinPorts = (graph: Graph, data: DataGraph, open: ReadonlySet<string>): Map<string, PinPort[]> => {\n const ports = new Map<string, PinPort[]>()\n for (const node of graph.nodes) {\n if (node.kind === 'state' && holdsSteps(node.state)) continue\n const { shown } = shownInputs(data.inputs.get(node.id) ?? [], open.has(node.id))\n ports.set(node.id, [\n ...shown.map((pin, index): PinPort => ({ handle: inHandle(pin.key), side: 'in', y: rowMiddle(headerHeight, index) })),\n ...(data.outputs.get(node.id) ?? []).map((pin, index): PinPort => ({ handle: outHandle(pin.path), side: 'out', y: rowMiddle(headerHeight, index) })),\n ])\n }\n for (const pure of data.pure) {\n const inputs = (pins: readonly InputPin[], top = pureTop) => pins.map((pin, index): PinPort => ({ handle: inHandle(pin.key), side: 'in', y: rowMiddle(top, index) }))\n if (pure.kind === 'break') {\n const { shown } = breakOutputs(pure, data.edges, open.has(pure.id))\n ports.set(pure.id, [{ handle: breakIn, side: 'in', y: titleHandle }, ...shown.map((pin, index): PinPort => ({ handle: outHandle(pin.path), side: 'out', y: rowMiddle(pureTop, index) }))])\n } else if (pure.kind === 'make') {\n ports.set(pure.id, [{ handle: makeOut, side: 'out', y: titleHandle }, ...inputs(pureInputs(pure, open.has(pure.id)).shown)])\n } else if (pure.kind === 'select') {\n ports.set(pure.id, [{ handle: selectOut, side: 'out', y: titleHandle }, ...inputs(pure.inputs)])\n } else {\n const top = pure.part.kind === 'expression' ? pureTop + expressionTextHeight + 4 : pureTop\n ports.set(pure.id, [{ handle: conditionOut, side: 'out', y: titleHandle }, ...inputs(pure.inputs, top)])\n }\n }\n return ports\n}\n","import type { Graph } from '../definition-graph'\nimport type { PureNode } from './data-graph'\n\n/**\n * The Map or Block a Break, a Make or a condition node is inside: the one around the node whose value it breaks, or the\n * step it makes an argument or a Condition of.\n */\nexport const pureParent = (graph: Graph, pure: PureNode) => {\n const near = graph.nodes.find((node) => node.id === (pure.kind === 'break' ? pure.source : pure.target))\n return near?.kind === 'state' ? near.parent : undefined\n}\n","import type { Edge, Node } from '@xyflow/react'\nimport type { WorkflowTypeList } from '@protobase/client'\nimport { cacheForcedAgainst } from './cache-advice'\nimport { triggerId } from './definition'\nimport type { Graph, GraphNode } from './definition-graph'\nimport { nodeSize, type Box } from './graph-layout'\nimport type { NodeTrace } from './node-trace'\nimport type { NodeProblem } from './problems'\nimport { stateLabel, triggerLabel } from './labels'\nimport { text } from './messages'\nimport type { DataGraph, PureNode } from './pins/data-graph'\nimport type { InputPin, OutputPin } from './pins/node-pins'\nimport { shownInputs } from './pins/pin-layout'\nimport { pinColour } from './pins/pin-text'\nimport { breakOutputs, pureInputs } from './pins/node-sizes'\nimport { pureParent } from './pins/pure-parents'\n\n/**\n * What a node of the canvas draws from: its node of the graph, what it is (`kind`, its type's label), the problems the\n * check found with it and what it warns of, how it did in a run, and whether its cache was forced on against its type's\n * advice.\n */\n/** `dataOrder`: the workflow runs in data order, so the node has no execution handles to draw edges from by hand. */\n/**\n * What a Break's, a Make's or a condition node draws from: the node, which of its inputs and a Break's fields it shows,\n * how many it folds away, whether it is open, and whether it has a row to fold or open them.\n */\nexport type PureData = { pure: PureNode; shownInputs: InputPin[]; shownOutputs: OutputPin[]; folded: number; open: boolean; foldable: boolean }\n\n/** `moved`: the node was moved by hand, so the layout leaves it where it was put. */\nexport type NodeData = { node: GraphNode; kind: string; problems: NodeProblem[]; warnings?: NodeProblem[]; trace?: NodeTrace; cacheWarning?: boolean; pins?: NodePins; pureData?: PureData; dataOrder?: boolean; moved?: boolean }\n\n/** The pins a node shows: the inputs it shows, its outputs, how many inputs it folds away and whether it is open. */\nexport type NodePins = { inputs: InputPin[]; outputs: OutputPin[]; folded: number; open: boolean }\n\nexport type FlowNode = Node<NodeData, 'trigger' | 'state' | 'pure'>\n\n// React Flow's ids: no state is named by an empty path, but React Flow wants every id to say something.\nconst triggerFlowId = 'trigger'\n// A Break's or a Make's id is its own, as no state has it.\n/** A trigger's or a state's node id on the canvas: a state's always prefixed, whatever it is named, such as make:Report. */\nexport const flowId = (id: string) => (id === triggerId ? triggerFlowId : `state:${id}`)\n\n/** Whether a canvas node is a Break or a Make: neither the trigger nor a state, whose ids flowId gives. */\nexport const isPureFlowId = (id: string) => id !== triggerFlowId && !id.startsWith('state:')\n\n/** The graph's id of a canvas node: a state's name, the trigger's, or a Break's or a Make's id as it is. */\nexport const graphId = (id: string) => (id === triggerFlowId ? triggerId : id.startsWith('state:') ? id.slice('state:'.length) : id)\n\n/** The pins of a node, as the data graph gives them and its optional inputs are open or folded. */\nexport const nodePins = (data: DataGraph, id: string, open: boolean): NodePins => {\n const { shown, folded } = shownInputs(data.inputs.get(id) ?? [], open)\n return { inputs: shown, outputs: data.outputs.get(id) ?? [], folded, open }\n}\n\n\n/**\n * The canvas's nodes, at the boxes the layout gave them: a Map holds the nodes inside it, which come after it, and a\n * node not laid out yet waits at the top left. Nodes are not dragged here: the canvas lets them be where it takes changes.\n */\nexport const flowNodes = (graph: Graph, boxes: ReadonlyMap<string, Box> | undefined, problems: ReadonlyMap<string, NodeProblem[]>, selected: string | undefined, traces?: ReadonlyMap<string, NodeTrace>, types?: WorkflowTypeList, warnings?: ReadonlyMap<string, NodeProblem[]>, pins?: { data: DataGraph; open: ReadonlySet<string> }, dataOrder = false): FlowNode[] =>\n graph.nodes.map((node) => {\n const box = boxes?.get(node.id) ?? { x: 0, y: 0, ...nodeSize }\n const parent = node.kind === 'state' ? node.parent : undefined\n const kind = node.kind === 'trigger' ? triggerLabel(node.trigger, types) : stateLabel(node.state, types)\n const cacheWarning = node.kind === 'state' && cacheForcedAgainst(node.state, types)\n const name = node.kind === 'state' ? text('stateNode', { name: node.name, type: kind }) : text('triggerNode', { trigger: kind })\n const warned = warnings?.get(node.id) ?? []\n const marks = [...(cacheWarning ? [text('cacheForcedAgainst')] : []), ...warned.map((warning) => warning.message)]\n return {\n id: flowId(node.id),\n type: node.kind,\n ariaLabel: [name, ...marks].join(', '),\n position: { x: box.x, y: box.y },\n width: box.width,\n height: box.height,\n // The node is drawn at its box's size, so React Flow knows it from the first render: a node handed over without\n // one loses its handles' places, and its edges vanish until its size changes\n measured: { width: box.width, height: box.height },\n data: { node, kind, problems: problems.get(node.id) ?? [], ...(traces?.has(node.id) && { trace: traces.get(node.id) }), ...(cacheWarning && { cacheWarning }), ...(warned.length > 0 && { warnings: warned }), ...(pins && { pins: nodePins(pins.data, node.id, pins.open.has(node.id)) }), ...(dataOrder && { dataOrder }) },\n draggable: false,\n deletable: node.kind === 'state',\n selected: node.id === selected,\n ...(parent !== undefined && { parentId: flowId(parent), extent: 'parent' as const }),\n }\n })\n\n// A condition longer than this is cut on its edge; the step's form shows it whole.\nconst labelLength = 40\n\nconst shortened = (label: string) => (label.length > labelLength ? `${label.slice(0, labelLength - 1)}…` : label)\n\nconst edgeLabel = (edge: Graph['edges'][number]) => {\n if (edge.kind === 'default') return text('otherwise')\n if (edge.kind === 'catch') return text('onError', { errors: edge.label ?? '' })\n if (edge.kind === 'rule') return edge.label ? shortened(edge.label) : text('conditionToWrite')\n return\n}\n\n// In data order an edge is what a state reads, drawn between each node's sides, which only changing what it reads changes\nconst dataOrderEdge = (edge: Graph['edges'][number]): Edge => ({\n id: edge.id,\n source: flowId(edge.source),\n sourceHandle: 'out',\n target: flowId(edge.target),\n targetHandle: 'in',\n deletable: false,\n data: { kind: edge.kind, field: edge.field, source: edge.source },\n ...(edge.kind === 'status' && { className: 'pb-workflow-status' }),\n})\n\n/** The canvas's edges, each from the handle of its kind; the trigger's cannot be deleted, only drawn elsewhere. */\nexport const flowEdges = (graph: Graph, dataOrder = false): Edge[] =>\n graph.edges.map((edge) => {\n if (dataOrder) return dataOrderEdge(edge)\n const label = edgeLabel(edge)\n return {\n id: edge.id,\n source: flowId(edge.source),\n sourceHandle: edge.kind,\n target: flowId(edge.target),\n targetHandle: 'in',\n deletable: edge.kind !== 'start',\n data: { kind: edge.kind, field: edge.field, source: edge.source },\n ...(label !== undefined && { label }),\n ...(edge.kind === 'catch' && { className: 'pb-workflow-catch' }),\n }\n })\n\n/** The Break, Make and condition nodes, at their boxes, inside the Map or Block of what they break or make. */\nexport const pureFlowNodes = (graph: Graph, data: DataGraph, boxes: ReadonlyMap<string, Box> | undefined, open: ReadonlySet<string>): FlowNode[] =>\n data.pure.map((pure) => {\n const box = boxes?.get(pure.id) ?? { x: 0, y: 0, ...nodeSize }\n const parent = pureParent(graph, pure)\n const { shown, folded } = pureInputs(pure, open.has(pure.id))\n const fields = pure.kind === 'break' ? breakOutputs(pure, data.edges, open.has(pure.id)) : undefined\n // The graph node it stands beside, which names nothing a panel opens\n const near = graph.nodes.find((node) => node.id === (pure.kind === 'break' ? pure.source : pure.target))!\n return {\n id: pure.id,\n type: 'pure' as const,\n position: { x: box.x, y: box.y },\n width: box.width,\n height: box.height,\n measured: { width: box.width, height: box.height },\n data: { node: near, kind: pure.kind, problems: [], pureData: { pure, shownInputs: shown, shownOutputs: fields?.shown ?? [], folded: fields?.folded ?? folded, open: open.has(pure.id), foldable: fields ? fields.foldable : folded > 0 || open.has(pure.id) } },\n draggable: false,\n deletable: true,\n ...(parent !== undefined && { parentId: flowId(parent), extent: 'parent' as const }),\n }\n })\n\n/** The wires between pins, each coloured by the type of what it carries. */\n/**\n * In data order with pins, the lines between steps that no wire stands for: a step that reads another only in a way no\n * pin shows, such as a variable assigned part of its result, still shows that it runs after it.\n */\nexport const unwiredOrderEdges = (graph: Graph, data: DataGraph): Edge[] => {\n // The step a wire's end belongs to, through the Break, Make or condition node it passes\n const step = (node: string) => {\n const pure = data.pure.find((each) => each.id === node)\n return pure ? (pure.kind === 'break' ? pure.source : pure.target) : node\n }\n const wired = new Set(data.edges.map((edge) => `${step(edge.source)}\\n${step(edge.target)}`))\n // The trigger's lines start the states that read nothing, which the run's input pins show\n return flowEdges({ ...graph, edges: graph.edges.filter((edge) => edge.source !== triggerId && !wired.has(`${edge.source}\\n${edge.target}`)) }, true)\n}\n\nexport const dataFlowEdges = (data: DataGraph): Edge[] => {\n // A wire's end is a Break's or a Make's, as the graph lists them, else a step's or the trigger's\n const pure = new Set(data.pure.map((node) => node.id))\n const end = (id: string) => (pure.has(id) ? id : flowId(id))\n return data.edges.map((edge) => ({\n id: edge.id,\n source: end(edge.source),\n sourceHandle: edge.sourceHandle,\n target: end(edge.target),\n targetHandle: edge.targetHandle,\n // A read inside an expression goes only as the expression changes\n deletable: !edge.expression,\n data: { kind: 'data', wire: edge },\n className: `pb-wire pb-wire-${pinColour(edge.type)}${edge.expression ? ' pb-wire-expression' : ''}`,\n }))\n}\n","import { createContext } from 'react'\nimport type { AddAt } from './definition-edits'\n\n/** What a click on an editable source handle of the canvas does: opens the step picker for a step added there. */\nexport const AddAtContext = createContext<((at: AddAt) => void) | undefined>(undefined)\n","import type { BadgeTone } from '../../../primitives/badge'\n\n/**\n * How a state did in a run, as its node shows it: how its last step ended, `retrying` while it waits to be tried again,\n * or `current` while the run is on it.\n */\nexport type NodeStatus = 'succeeded' | 'caught' | 'retrying' | 'failed' | 'current'\n\n/** A node's mark in a run: its status, how many steps it took, every try and item counted, and whether the step changed since. */\nexport type NodeTrace = { status: NodeStatus; steps: number; changed?: boolean }\n\nexport const nodeTones: Record<NodeStatus, BadgeTone> = { succeeded: 'green', caught: 'amber', retrying: 'amber', failed: 'red', current: 'blue' }\n","import { createContext, useContext } from 'react'\n\n/**\n * What the pins on the canvas can do: change a step's argument in place, a value of a condition node's side at `at`\n * among the step's Condition's nodes, or the whole Condition as an Expression writes it, and open or fold a node's\n * optional inputs.\n */\nexport type PinActions = {\n setArgument: (step: string, keys: readonly string[], value: unknown) => void\n setConditionSide: (step: string, at: readonly number[], value: string | number | boolean) => void\n setCondition: (step: string, value: string | undefined) => void\n toggleOpen: (node: string) => void\n}\n\nexport const PinActionsContext = createContext<PinActions | undefined>(undefined)\n\n/** The pins' actions where the canvas is editable; undefined where it is only shown. */\nexport const usePinActions = () => useContext(PinActionsContext)\n","import { useState } from 'react'\nimport { Checkbox } from '../../../../primitives/checkbox'\nimport { Input } from '../../../../primitives/input'\nimport { Select } from '../../../../primitives/select'\nimport { text } from '../messages'\nimport { conditionKey, type InputPin } from './node-pins'\nimport { statusLabel } from './pin-text'\n\n// The one kind an inline editor writes, for a pin that takes text, a number or true and false\nconst inlineKind = (pin: InputPin) => {\n if (pin.options) return 'choice'\n if (pin.type.kinds === 'any') return\n const [kind, ...others] = pin.type.kinds.filter((each) => each !== 'null')\n if (kind === 'string' && others.every((other) => other === 'integer' || other === 'number')) return 'string'\n if (others.length > 0) return\n return kind === 'integer' || kind === 'number' ? 'number' : kind === 'boolean' ? 'boolean' : undefined\n}\n\nconst numberOf = (typed: string) => (typed.trim() === '' ? undefined : Number.isNaN(Number(typed)) ? typed : Number(typed))\n\n// A number's editor shows what was typed while it has the focus, such as \"1.\" on the way to 1.5, which the value it\n// gives, 1, would not; once the focus leaves, it shows the value again.\nconst NumberInput = ({ name, className, value, onChange }: { name: string; className: string; value: unknown; onChange: (value: unknown) => void }) => {\n const [typed, setTyped] = useState<string>()\n return (\n <Input\n aria-label={name}\n wrapperClassName={`${className} h-6 w-[55%] px-1.5`}\n className=\"text-xs\"\n inputMode=\"decimal\"\n value={typed ?? (value === undefined ? '' : String(value))}\n onChange={(event) => {\n setTyped(event.target.value)\n onChange(numberOf(event.target.value))\n }}\n onBlur={() => setTyped(undefined)}\n />\n )\n}\n\n/**\n * What an input pin holds, on its row: an editor of its own value where it is text, a number, true or false or a\n * choice and no wire reads into it, a mark for an expression or an object, which the step's form edits, else nothing.\n */\nexport const PinValue = ({ pin, label, onChange }: { pin: InputPin; label: string; onChange?: (value: unknown) => void }) => {\n if (pin.state === 'wired' || pin.state === 'made') return null\n // A Condition is an expression, which the step's form edits; wired, it reads a yes or no\n if (pin.key === conditionKey && pin.state !== 'expression') return null\n if (pin.state === 'expression') {\n return (\n <span className=\"ml-auto shrink-0 rounded bg-muted px-1 font-mono text-xs text-muted-foreground\" title={text('pinExpression', { expression: String(pin.value) })}>\n ƒ\n </span>\n )\n }\n const kind = inlineKind(pin)\n if (pin.state === 'literal' && typeof pin.value === 'object') return <span className=\"ml-auto shrink-0 text-xs text-muted-foreground\" title={text('pinObjectValue')}>{'{…}'}</span>\n // A value of a type no editor here takes, such as a key that is text or a number, shows as it is\n if (!kind) return pin.state === 'literal' ? <span className=\"ml-auto min-w-0 truncate text-xs text-muted-foreground\">{String(pin.value)}</span> : null\n const name = text('inputValue', { label })\n if (!onChange) return <span className=\"ml-auto min-w-0 truncate text-xs text-muted-foreground\">{pin.value === undefined ? '' : String(pin.value)}</span>\n const editor = 'nodrag nopan nowheel ml-auto min-w-0'\n if (kind === 'boolean') return <Checkbox className={editor} checked={pin.value === true} label={name} onChange={(checked) => onChange(checked)} />\n if (kind === 'choice') {\n return (\n <Select aria-label={name} className={`${editor} h-6 max-w-[55%] px-1 py-0 text-xs`} value={typeof pin.value === 'string' ? pin.value : ''} onChange={(event) => onChange(event.target.value === '' ? undefined : event.target.value)}>\n <option value=\"\" />\n {pin.options!.map((option) => (\n <option key={option} value={option}>\n {pin.statuses ? statusLabel(option) : option}\n </option>\n ))}\n </Select>\n )\n }\n if (kind === 'number') return <NumberInput name={name} className={editor} value={pin.value} onChange={onChange} />\n return (\n <Input\n aria-label={name}\n wrapperClassName={`${editor} h-6 w-[55%] px-1.5`}\n className=\"text-xs\"\n value={pin.value === undefined ? '' : String(pin.value)}\n onChange={(event) => onChange(event.target.value === '' ? undefined : event.target.value)}\n />\n )\n}\n","import { Handle, Position } from '@xyflow/react'\nimport { text } from '../messages'\nimport type { InputPin, OutputPin } from './node-pins'\nimport { usePinActions } from './pin-actions'\nimport { inputPinLabel, outputLabel, pinColour, typeLabel } from './pin-text'\nimport { PinValue } from './pin-value'\nimport { inHandle, outHandle } from './pure-ids'\n\nconst pinClass = (pin: { type: InputPin['type'] }) => `pb-pin pb-pin-${pinColour(pin.type)}`\n\n/**\n * An input pin's row: its dot on the left edge, which a wire ends at, its name with its type on hover, and what it\n * holds. `step` and `keys` say which argument it sets, such as a Make's field of `data`; `onValue`, what its value\n * changes instead, such as a condition node's side, named `name`; `bare`, it takes a wire only and shows no value.\n */\nexport const InputRow = ({ pin, step, keys, connectable, name, onValue, bare = false }: { pin: InputPin; step: string; keys: readonly string[]; connectable: boolean; name?: string; onValue?: (value: unknown) => void; bare?: boolean }) => {\n const actions = usePinActions()\n const label = name ?? inputPinLabel(pin.key)\n return (\n <div className=\"relative flex h-[26px] items-center gap-1.5 pr-2 pl-3\">\n <Handle id={inHandle(pin.key)} type=\"target\" position={Position.Left} isConnectable={connectable} className={pinClass(pin)} />\n <span className=\"min-w-0 shrink truncate text-xs text-body\" title={text('pinTypeTitle', { label, type: typeLabel(pin.type) })}>\n {label}\n {pin.required && <span aria-hidden=\"true\" className=\"text-danger-text\">*</span>}\n </span>\n {!bare && <PinValue pin={pin} label={label} {...(actions && connectable && { onChange: onValue ?? ((value: unknown) => actions.setArgument(step, keys, value)) })} />}\n </div>\n )\n}\n\n/** An output pin's row: its name with its type on hover, and its dot on the right edge, which wires start from. */\nexport const OutputRow = ({ pin, connectable, trigger = false, field = false }: { pin: OutputPin; connectable: boolean; trigger?: boolean; field?: boolean }) => {\n const label = outputLabel(pin.path, trigger, field)\n return (\n <div className=\"relative flex h-[26px] items-center justify-end pr-3 pl-2\">\n <span className=\"min-w-0 truncate text-xs text-body\" title={text('pinTypeTitle', { label, type: typeLabel(pin.type) })}>\n {label}\n </span>\n <Handle id={outHandle(pin.path)} type=\"source\" position={Position.Right} isConnectable={connectable} className={pinClass(pin)} />\n </div>\n )\n}\n\n/**\n * The pins of a Map or a Block, whose box holds its own steps: a dot on its header's edge for each, its name and type on\n * hover, so the wires to and from the step have their ends, as its steps fill the rest.\n */\nexport const GroupPins = ({ inputs, outputs, connectable }: { inputs: readonly InputPin[]; outputs: readonly OutputPin[]; connectable: boolean }) => {\n const top = (index: number, count: number) => ({ top: `${((index + 1) * 100) / (count + 1)}%` })\n return (\n <>\n {inputs.map((pin, index) => (\n <Handle key={pin.key} id={inHandle(pin.key)} type=\"target\" position={Position.Left} isConnectable={connectable} className={pinClass(pin)} style={top(index, inputs.length)} title={text('pinTypeTitle', { label: inputPinLabel(pin.key), type: typeLabel(pin.type) })} />\n ))}\n {outputs.map((pin, index) => (\n <Handle key={pin.path.join('/')} id={outHandle(pin.path)} type=\"source\" position={Position.Right} isConnectable={connectable} className={pinClass(pin)} style={top(index, outputs.length)} title={text('pinTypeTitle', { label: outputLabel(pin.path), type: typeLabel(pin.type) })} />\n ))}\n </>\n )\n}\n\n/** The button that opens a node's optional inputs, or a Break's fields nothing reads, or folds them again. */\nexport const FoldRow = ({ node, folded, open, fields = false }: { node: string; folded: number; open: boolean; fields?: boolean }) => {\n const actions = usePinActions()\n if (folded === 0 && !open) return null\n return (\n <button type=\"button\" className=\"nodrag h-6 w-full px-3 text-left text-xs text-muted-foreground hover:text-foreground\" onClick={() => actions?.toggleOpen(node)} disabled={!actions}>\n {fields ? (open ? text('foldLessFields') : text('foldMoreFields', { count: folded })) : open ? text('foldLess') : text('foldMore', { count: folded })}\n </button>\n )\n}\n\n/** A node's pins: its inputs on the left and its outputs on the right, side by side, then the row that folds its optional inputs. */\nexport const PinColumns = ({ node, inputs, outputs, folded, open, editable, trigger = false }: { node: string; inputs: readonly InputPin[]; outputs: readonly OutputPin[]; folded: number; open: boolean; editable: boolean; trigger?: boolean }) => (\n <>\n <div className=\"grid grid-cols-[3fr_2fr]\">\n <div className=\"min-w-0\">\n {inputs.map((pin) => (\n <InputRow key={pin.key} pin={pin} step={node} keys={[pin.key]} connectable={editable} />\n ))}\n </div>\n <div className=\"min-w-0\">\n {outputs.map((pin) => (\n <OutputRow key={JSON.stringify(pin.path)} pin={pin} connectable={editable} trigger={trigger} />\n ))}\n </div>\n </div>\n <FoldRow node={node} folded={folded} open={open} />\n </>\n)\n","import { createContext } from 'react'\n\n/** What a moved node's mark does where the canvas takes changes: hands the node, by its canvas id, back to the layout. */\nexport const UnpinContext = createContext<((node: string) => void) | undefined>(undefined)\n","import { Pin } from 'lucide-react'\nimport { useContext } from 'react'\nimport { cn } from '../../../lib/cn'\nimport { Button } from '../../../primitives/button'\nimport { text } from './messages'\nimport { UnpinContext } from './unpin-context'\n\n// On the box's top right corner, outside what the box shows and clear of the handles down its right side\nconst place = 'nodrag absolute -top-4 -right-4 z-10'\n\n/**\n * The mark of a node moved by hand, which the layout leaves where it was put: where the canvas takes changes, a button\n * that unpins it, handing it back to the layout.\n */\nexport const MovedMark = ({ node, name }: { node: string; name: string }) => {\n const unpin = useContext(UnpinContext)\n if (!unpin) {\n return (\n <span className={cn(place, 'inline-flex size-7 items-center justify-center rounded-md border border-border-strong bg-background text-muted-foreground shadow-sm')} title={text('movedByHand')}>\n <Pin className=\"size-3.5\" aria-hidden />\n <span className=\"sr-only\">{text('movedByHand')}</span>\n </span>\n )\n }\n return (\n <Button\n size=\"icon\"\n className={place}\n aria-label={text('unpin', { name })}\n title={text('unpinHelp')}\n onClick={(event) => {\n // The node itself is not chosen by it\n event.stopPropagation()\n unpin(node)\n }}\n >\n <Pin className=\"size-3.5\" aria-hidden />\n </Button>\n )\n}\n","import { Handle, Position, type NodeProps } from '@xyflow/react'\nimport { CircleAlert } from 'lucide-react'\nimport { useContext, type KeyboardEvent, type MouseEvent } from 'react'\nimport type { State } from '@protobase/workflows'\nimport { cn } from '../../../lib/cn'\nimport { Badge } from '../../../primitives/badge'\nimport { AddAtContext } from './add-at-context'\nimport type { AddAt } from './definition-edits'\nimport type { EdgeKind } from './definition-graph'\nimport type { FlowNode } from './flow-elements'\nimport { nodeStatusLabel } from './labels'\nimport { nodeTones, type NodeTrace } from './node-trace'\nimport { holdsSteps } from './definition'\nimport { text } from './messages'\nimport { GroupPins, PinColumns } from './pins/pin-rows'\nimport { MovedMark } from './moved-mark'\n\ntype Source = { kind: EdgeKind; top: number; label?: string }\n\n// Where the execution handles sit on a node's right edge, in its header, as Blueprints draw them\nconst execTops = [18, 38]\n\n// The handles an edge leaves a state from, by its type, down the header's right edge: on to the next state, or a\n// Choice's rules and then its Default, and below it the error path of a Task, Map or Block.\nconst sourcesOf = (state: State): Source[] => {\n if (state.Type === 'Choice') {\n return [\n { kind: 'rule', top: execTops[0]!, label: text('when') },\n { kind: 'default', top: execTops[1]!, label: text('otherwise') },\n ]\n }\n const next: Source[] = ['Task', 'Pass', 'Wait', 'Map', 'Block'].includes(state.Type) ? [{ kind: 'next', top: execTops[0]! }] : []\n const caught: Source[] = state.Type === 'Task' || state.Type === 'Map' || state.Type === 'Block' ? [{ kind: 'catch', top: execTops[next.length]!, label: text('onErrorHandle') }] : []\n return [...next, ...caught]\n}\n\n// A click on a handle, rather than a drag from it, adds a step there; the node itself is not chosen by it\nconst useAddAt = (at: AddAt, editable: boolean, handle?: string) => {\n const addAt = useContext(AddAtContext)\n if (!addAt || !editable) return {}\n const open = (event: MouseEvent | KeyboardEvent) => {\n event.stopPropagation()\n addAt(at)\n }\n const label = handle ? text('addStepAtNamedHandle', { handle }) : text('addStepAtHandle')\n return {\n role: 'button',\n tabIndex: 0,\n 'aria-label': label,\n title: label,\n onClick: open,\n onKeyDown: (event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n open(event)\n }\n },\n }\n}\n\nconst SourceHandle = ({ source, path, editable }: { source: Source; path: string; editable: boolean }) => (\n <Handle id={source.kind} type=\"source\" position={Position.Right} isConnectable={editable} style={{ top: source.top }} className={cn('pb-workflow-exec', `pb-workflow-handle-${source.kind}`)} {...useAddAt({ kind: source.kind, source: path }, editable, source.label)}>\n {source.label && <span className=\"pb-workflow-handle-label\">{source.label}</span>}\n </Handle>\n)\n\nconst Sources = ({ state, path, editable }: { state: State; path: string; editable: boolean }) => sourcesOf(state).map((source) => <SourceHandle key={source.kind} source={source} path={path} editable={editable} />)\n\nconst ProblemCount = ({ count }: { count: number }) =>\n count > 0 && (\n <span className=\"inline-flex shrink-0 items-center gap-1 text-xs font-medium text-danger-text\" title={text('problemCount', { count })}>\n <CircleAlert className=\"size-3.5\" aria-hidden=\"true\" />\n <span className=\"sr-only\">{text('problemCount', { count })}</span>\n <span aria-hidden=\"true\">{count}</span>\n </span>\n )\n\n// What a step should be looked at for though it saves, plain to see on a screenshot: its cache forced on against its\n// type's advice, or what the check warns of\nconst WarningMark = ({ label }: { label: string }) => (\n <span className=\"inline-flex shrink-0 items-center text-warning-text\" title={label}>\n <CircleAlert className=\"size-3.5\" aria-hidden=\"true\" />\n <span className=\"sr-only\">{label}</span>\n </span>\n)\n\n// How the state did in a run, and how many steps it took when more than one\nconst TraceMark = ({ trace }: { trace: NodeTrace }) => (\n <span className=\"flex shrink-0 flex-col items-end gap-0.5\">\n {trace.changed ? <span title={text('changedSinceRun')} className=\"rounded-full border border-dashed px-1.5 text-xs text-muted-foreground\">{text('changedShort')}</span> : <Badge tone={nodeTones[trace.status]}>{nodeStatusLabel(trace.status)}</Badge>}\n {trace.steps > 1 && <span className=\"text-xs tabular-nums text-muted-foreground\">{text('traceSteps', { count: trace.steps })}</span>}\n </span>\n)\n\nconst boxClass = (selected: boolean, problems: number, trace?: NodeTrace) =>\n cn('rounded-lg border bg-background text-body shadow-sm', problems > 0 || trace?.status === 'failed' ? 'border-danger' : 'border-border-strong', selected && 'ring-2 ring-primary/40')\n\n// What the state is, with the count of its problems or its mark in a run, over its name, which keeps the whole width\nconst Title = ({ name, kind, problems, first, trace, warnings = [] }: { name: string; kind: string; problems: number; first?: boolean; trace?: NodeTrace; warnings?: readonly string[] }) => (\n <div className=\"min-w-0\">\n <div className=\"flex min-w-0 items-start justify-between gap-2\">\n <div className=\"min-w-0 truncate text-xs text-muted-foreground\">\n {kind}\n {first && <span className=\"text-primary-text\"> · {text('startsHere')}</span>}\n </div>\n {warnings.length > 0 && <WarningMark label={warnings.join('\\n')} />}\n <ProblemCount count={problems} />\n {trace && <TraceMark trace={trace} />}\n </div>\n <div className=\"truncate font-medium text-foreground\">{name}</div>\n </div>\n)\n\n/** A state: a box with its name, what it is and the handles its edges leave from; a Map's or Block's holds the states inside it. */\n// In data order a node has no execution handles: the edges drawn between nodes, in the simple view, are what they read,\n// from one's side to the other's\nconst DataSides = () => (\n <>\n <Handle id=\"in\" type=\"target\" position={Position.Left} isConnectable={false} className=\"pb-workflow-side\" style={{ top: execTops[0] }} />\n <Handle id=\"out\" type=\"source\" position={Position.Right} isConnectable={false} className=\"pb-workflow-side\" style={{ top: execTops[0] }} />\n </>\n)\n\n// The Condition a state runs under in data order, shortly, whole on hover\nconst OnlyWhen = ({ condition }: { condition: string | undefined }) =>\n condition !== undefined && (\n <span className=\"absolute top-1 right-6 max-w-[45%] truncate rounded bg-muted px-1 text-[0.625rem] text-muted-foreground\" title={condition}>\n {text('onlyWhenBadge')}\n </span>\n )\n\nexport const StateNode = ({ id, data, selected, isConnectable }: NodeProps<FlowNode>) => {\n const { node, kind, problems, trace, cacheWarning, warnings = [], pins, dataOrder, moved } = data\n if (node.kind !== 'state') return null\n return (\n <div className={cn(boxClass(selected, problems.length, trace), 'h-full', holdsSteps(node.state) && 'bg-muted/40')}>\n {moved && <MovedMark node={id} name={node.name} />}\n <div className=\"relative h-[52px] py-2 pr-6 pl-4\">\n {dataOrder ? <DataSides /> : <Handle id=\"in\" type=\"target\" position={Position.Left} isConnectable={isConnectable} className=\"pb-workflow-exec\" style={{ top: execTops[0] }} />}\n {dataOrder && <OnlyWhen condition={node.state.Condition} />}\n <Title name={node.name} kind={kind} problems={problems.length} first={node.first && node.parent !== undefined} trace={trace} warnings={[...(cacheWarning ? [text('cacheForcedAgainst')] : []), ...warnings.map((warning) => warning.message)]} />\n {!dataOrder && <Sources state={node.state} path={node.id} editable={isConnectable} />}\n {pins && holdsSteps(node.state) && <GroupPins inputs={pins.inputs} outputs={pins.outputs} connectable={isConnectable} />}\n </div>\n {pins && !holdsSteps(node.state) && <PinColumns node={node.id} inputs={pins.inputs} outputs={pins.outputs} folded={pins.folded} open={pins.open} editable={isConnectable} />}\n </div>\n )\n}\n\n/** The trigger: what starts a run, leading to the first state. */\nexport const TriggerNode = ({ id, data, selected, isConnectable }: NodeProps<FlowNode>) => {\n const { node, kind, problems, pins, dataOrder, moved } = data\n // In data order no state is first, so the trigger's handle adds no step\n const addAt = useAddAt({ kind: 'start', source: node.id }, isConnectable && !dataOrder)\n if (node.kind !== 'trigger') return null\n return (\n <div className={cn(boxClass(selected, problems.length), 'h-full border-dashed')}>\n {moved && <MovedMark node={id} name={text('trigger')} />}\n <div className=\"relative h-[52px] py-2 pr-6 pl-4\">\n <Title name={kind} kind={text('trigger')} problems={problems.length} />\n {dataOrder ? (\n <Handle id=\"out\" type=\"source\" position={Position.Right} isConnectable={false} className=\"pb-workflow-side\" style={{ top: execTops[0] }} />\n ) : (\n <Handle id=\"start\" type=\"source\" position={Position.Right} isConnectable={isConnectable} className=\"pb-workflow-exec\" style={{ top: execTops[0] }} {...addAt} />\n )}\n </div>\n {pins && <PinColumns node={node.id} inputs={[]} outputs={pins.outputs} folded={0} open={false} editable={isConnectable} trigger />}\n </div>\n )\n}\n","import { useState } from 'react'\nimport { guarded } from '../../../../lib/guarded'\n\n/**\n * How the editor draws a workflow: `pins`, every step's inputs and outputs as typed pins with the wires between them;\n * or `simple`, the steps and the lines between them alone, their inputs edited in the step's form. Both are views of the same document: switching changes nothing in it.\n */\nexport type GraphView = 'pins' | 'simple'\n\nexport const graphViewStorageKey = 'protobase:workflow-graph-view'\n\n/**\n * The view chosen in this browser; pins, the default, when none was or storage is unavailable. `storage` gives the\n * storage when asked, since a browser that blocks it throws as soon as it is reached.\n */\nexport const readGraphView = (storage: () => Pick<Storage, 'getItem'>): GraphView => (guarded(() => storage().getItem(graphViewStorageKey), null) === 'simple' ? 'simple' : 'pins')\n\n/** Remembers a view, and the default by forgetting the choice, so the default costs no storage. */\nexport const writeGraphView = (storage: () => Pick<Storage, 'setItem' | 'removeItem'>, view: GraphView) =>\n guarded(() => (view === 'pins' ? storage().removeItem(graphViewStorageKey) : storage().setItem(graphViewStorageKey, view)), undefined)\n\nconst browserStorage = () => localStorage\n\n/** The view the person chose last in this browser, and the way to choose another, which this browser remembers. */\nexport const useGraphView = () => {\n const [view, setView] = useState<GraphView>(() => readGraphView(browserStorage))\n const choose = (next: GraphView) => {\n setView(next)\n writeGraphView(browserStorage, next)\n }\n return [view, choose] as const\n}\n","import { Handle, Position } from '@xyflow/react'\nimport { useState } from 'react'\nimport { text } from '../messages'\nimport type { ConditionNode } from './data-graph'\nimport { usePinActions } from './pin-actions'\nimport { Input } from '../../../../primitives/input'\nimport { InputRow } from './pin-rows'\nimport { pinColour, typeLabel } from './pin-text'\nimport { expressionTextHeight } from './pin-layout'\nimport { conditionOut, inHandle } from './pure-ids'\n\n// An input's name: a Comparison's two are A and B, an All of's and an Any of's A, B, C and on, a Matches node's the text\n// and the pattern, a Not's what it turns round\nconst sideName = (node: ConditionNode, key: string) => {\n if (node.part.kind === 'not') return text('conditionNotSide')\n if (node.part.kind === 'matches') return key === '0' ? text('conditionMatchesText') : text('conditionMatchesPattern')\n if (node.part.kind === 'logic') return String.fromCharCode(65 + (Number(key) % 26))\n return key === '0' ? text('conditionSideA') : text('conditionSideB')\n}\n\n// The text of an Expression, kept as typed while it has the focus and written once the focus leaves, so a Condition\n// typed into a form the nodes stand for turns into them only then\nconst ExpressionText = ({ node, source }: { node: ConditionNode; source: string }) => {\n const actions = usePinActions()\n const [typed, setTyped] = useState<string>()\n const shown = source.trim()\n return (\n <textarea\n aria-label={text('conditionExpressionText')}\n className=\"nodrag nopan nowheel block w-full resize-none rounded border border-border bg-background px-1.5 py-1 font-mono text-xs text-foreground\"\n style={{ height: expressionTextHeight }}\n spellCheck={false}\n readOnly={!actions}\n value={typed ?? shown}\n onChange={(event) => setTyped(event.target.value)}\n onBlur={() => {\n setTyped(undefined)\n const next = typed?.trim()\n if (next === undefined || next === shown) return\n actions?.setCondition(node.target, next === '' ? undefined : `{% ${next} %}`)\n }}\n />\n )\n}\n\n// A value an Expression reads, by where it comes from: Save.Status, input.record.id or $fetch.body.ip\nconst readName = (key: string) => key.replace(/^\\$states\\.context\\.Steps\\./, '').replace(/^\\$states\\.context\\.Execution\\.Input/, 'input')\n\n// A Matches node's pattern, typed on the node and never wired: what is typed shows while the box has the focus, and only\n// a pattern that is not empty is written, as an empty one is no regular expression\nconst PatternRow = ({ node, editable }: { node: ConditionNode; editable: boolean }) => {\n const actions = usePinActions()\n const [typed, setTyped] = useState<string>()\n const label = text('conditionMatchesPattern')\n const pattern = String(node.inputs[1]?.value ?? '')\n return (\n <div className=\"relative flex h-[26px] items-center gap-1.5 pr-2 pl-3\">\n <span className=\"min-w-0 shrink truncate text-xs text-body\">{label}</span>\n <Input\n aria-label={text('inputValue', { label })}\n wrapperClassName=\"nodrag nopan nowheel ml-auto h-6 w-[60%] min-w-0 px-1.5\"\n className=\"font-mono text-xs\"\n value={typed ?? pattern}\n disabled={!actions || !editable}\n onChange={(event) => {\n setTyped(event.target.value)\n if (event.target.value !== '') actions?.setConditionSide(node.target, [...node.at, 1], event.target.value)\n }}\n onBlur={() => setTyped(undefined)}\n />\n </div>\n )\n}\n\n/**\n * A condition node's pins and inputs: a Comparison's, an And's or an Or's two sides, a Not's one, each wired or\n * holding a value of its own, or an Expression's text with a pin per value it reads, which only the text changes. Its\n * yes or no goes out on the right, to the Only when pin or the side it is part of.\n */\nexport const ConditionPins = ({ node, editable }: { node: ConditionNode; editable: boolean }) => {\n const actions = usePinActions()\n const out = <Handle id={conditionOut} type=\"source\" position={Position.Right} isConnectable={false} className=\"pb-pin pb-pin-boolean\" style={{ top: 13 }} />\n if (node.part.kind === 'expression') {\n return (\n <div className=\"relative grid gap-1 px-2 pt-1\">\n {out}\n <ExpressionText node={node} source={node.part.source} />\n <div className=\"-mx-2\">\n {node.inputs.map((pin) => (\n <div key={pin.key} className=\"relative flex h-[26px] items-center pr-2 pl-3\">\n <Handle id={inHandle(pin.key)} type=\"target\" position={Position.Left} isConnectable={false} className={`pb-pin pb-pin-${pinColour(pin.type)}`} />\n <span className=\"min-w-0 truncate font-mono text-xs text-body\" title={text('pinTypeTitle', { label: pin.key, type: typeLabel(pin.type) })}>\n {readName(pin.key)}\n </span>\n </div>\n ))}\n </div>\n </div>\n )\n }\n return (\n <div className=\"relative pt-1\">\n {out}\n {node.inputs.map((pin) =>\n node.part.kind === 'matches' && pin.key === '1' ? (\n <PatternRow key={pin.key} node={node} editable={editable} />\n ) : (\n <InputRow\n key={pin.key}\n pin={pin}\n step={node.target}\n keys={[]}\n name={sideName(node, pin.key)}\n // The empty input after an All of's or an Any of's last takes a wire or a node, which adds its next condition\n bare={node.part.kind === 'logic' && Number(pin.key) === node.part.sides.length}\n connectable={editable}\n // A value cleared is an empty one: a check box gives true or false, so only text or a number is cleared\n onValue={(value) => actions?.setConditionSide(node.target, [...node.at, Number(pin.key)], (value ?? '') as string | number | boolean)}\n />\n ),\n )}\n </div>\n )\n}\n","import { Handle, Position } from '@xyflow/react'\nimport { X } from 'lucide-react'\nimport { selectValue, type SelectPart, type SelectValue } from '@protobase/workflows'\nimport { Input } from '../../../../primitives/input'\nimport { text } from '../messages'\nimport type { SelectNode } from './data-graph'\nimport { usePinActions } from './pin-actions'\nimport { InputRow } from './pin-rows'\nimport { pinColour } from './pin-text'\nimport { selectOut } from './pure-ids'\n\n// What was typed, as the kind of value it replaces: a number stays one while it reads as one, true and false stay\n// true and false, and anything else is text\nconst typed = (next: string, before: SelectValue): SelectValue => {\n if (typeof before === 'number' && next.trim() !== '' && Number.isFinite(Number(next))) return Number(next)\n if (typeof before === 'boolean' && (next === 'true' || next === 'false')) return next === 'true'\n return next\n}\n\nconst editor = 'nodrag nopan nowheel h-6 min-w-0 px-1.5'\n\n// A value of the node's own, typed on its row\nconst ValueInput = ({ label, value, onChange, disabled }: { label: string; value: SelectValue; onChange: (value: SelectValue) => void; disabled: boolean }) => (\n <Input aria-label={label} wrapperClassName={`${editor} flex-1`} className=\"text-xs\" value={String(value)} disabled={disabled} onChange={(event) => onChange(typed(event.target.value, value))} />\n)\n\n/**\n * A Select's rows: the value it looks at, a pin a wire reads into or a value of its own; then a row per case, the\n * value it can be and what the node gives then; what it gives for any other; and a button that adds a case. Its value\n * goes out on the right, to the argument it chooses.\n */\nexport const SelectRows = ({ node, editable }: { node: SelectNode; editable: boolean }) => {\n const actions = usePinActions()\n const disabled = !actions || !editable\n const write = (part: SelectPart) => actions?.setArgument(node.target, [node.key], selectValue(part))\n const { part } = node\n const setCase = (index: number, change: Partial<SelectPart['cases'][number]>) => write({ ...part, cases: part.cases.map((each, position) => (position === index ? { ...each, ...change } : each)) })\n return (\n <div className=\"relative pt-1\">\n <Handle id={selectOut} type=\"source\" position={Position.Right} isConnectable={false} className={`pb-pin pb-pin-${pinColour(node.type)}`} style={{ top: 13 }} />\n {node.inputs.map((pin) => (\n <InputRow key={pin.key} pin={pin} step={node.target} keys={[]} name={text('selectInput')} connectable={editable} onValue={(value) => write({ ...part, operand: { value: typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' ? value : '' } })} />\n ))}\n {part.cases.map((each, index) => (\n <div key={index} className=\"flex h-[26px] items-center gap-1 pr-2 pl-3\">\n <ValueInput label={text('selectWhen', { case: index + 1 })} value={each.when} disabled={disabled} onChange={(when) => setCase(index, { when })} />\n <span aria-hidden=\"true\" className=\"text-xs text-muted-foreground\">\n →\n </span>\n <ValueInput label={text('selectThen', { case: index + 1 })} value={each.then} disabled={disabled} onChange={(then) => setCase(index, { then })} />\n <button\n type=\"button\"\n className=\"nodrag shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-40\"\n aria-label={text('selectRemoveCase', { case: index + 1 })}\n disabled={disabled || part.cases.length === 1}\n onClick={() => write({ ...part, cases: part.cases.filter((_, position) => position !== index) })}\n >\n <X className=\"size-3\" aria-hidden />\n </button>\n </div>\n ))}\n <div className=\"flex h-[26px] items-center gap-1 pr-2 pl-3\">\n <span className=\"shrink-0 text-xs text-body\">{text('selectOtherwise')}</span>\n <ValueInput label={text('selectOtherwise')} value={part.otherwise} disabled={disabled} onChange={(otherwise) => write({ ...part, otherwise })} />\n </div>\n <button type=\"button\" className=\"nodrag h-6 w-full px-3 text-left text-xs text-muted-foreground hover:text-foreground\" disabled={disabled} onClick={() => write({ ...part, cases: [...part.cases, { when: '', then: '' }] })}>\n {text('selectAddCase')}\n </button>\n </div>\n )\n}\n","import { Handle, Position, type NodeProps } from '@xyflow/react'\nimport { cn } from '../../../../lib/cn'\nimport type { FlowNode, PureData } from '../flow-elements'\nimport { text } from '../messages'\nimport type { PureNode } from './data-graph'\nimport { ConditionPins } from './condition-nodes'\nimport { SelectRows } from './select-node'\nimport { FoldRow, InputRow, OutputRow } from './pin-rows'\nimport { conditionNodeTitle, pinColour, typeLabel } from './pin-text'\nimport { breakIn, makeOut } from './pure-ids'\nimport { MovedMark } from '../moved-mark'\n\nconst titleOf = (pure: PureNode) => {\n if (pure.kind === 'condition') return conditionNodeTitle(pure)\n if (pure.kind === 'select') return text('selectTitle')\n return pure.kind === 'break' ? text('breakTitle', { type: typeLabel(pure.type) }) : text('makeTitle', { type: typeLabel(pure.type) })\n}\n\nconst Title = ({ pure }: { pure: PureNode }) => <div className=\"truncate border-b px-3 py-1.5 text-xs font-medium text-foreground\">{titleOf(pure)}</div>\n\n/**\n * A Break, a Make or a condition node: a node of the editor's own, with no step at run time, that takes an object apart\n * into a pin per field, builds one from a pin per field, or is part of a step's Condition. Its object's own pin is bound\n * to the value it breaks or the argument it makes, a condition node's to the Only when pin or side it is part of.\n */\nexport const PureNodeView = ({ id, data, selected, isConnectable: editable }: NodeProps<FlowNode>) => {\n const { pureData, moved } = data\n if (!pureData) return null\n const { pure, shownInputs, shownOutputs, folded, open, foldable } = pureData\n return (\n <div className={cn('h-full rounded-lg border border-dashed border-border-strong bg-background text-body shadow-sm', selected && 'ring-2 ring-primary/40')}>\n {moved && <MovedMark node={id} name={titleOf(pure)} />}\n <Title pure={pure} />\n {pure.kind === 'condition' ? (\n <ConditionPins node={pure} editable={editable} />\n ) : pure.kind === 'select' ? (\n <SelectRows node={pure} editable={editable} />\n ) : pure.kind === 'break' ? (\n <div className=\"relative pt-1\">\n <Handle id={breakIn} type=\"target\" position={Position.Left} isConnectable={false} className={`pb-pin pb-pin-${pinColour(pure.type)}`} style={{ top: 13 }} />\n {shownOutputs.map((pin) => (\n <OutputRow key={JSON.stringify(pin.path)} pin={pin} connectable={editable} field />\n ))}\n {foldable && <FoldRow node={pure.id} folded={folded} open={open} fields />}\n </div>\n ) : (\n <div className=\"relative pt-1\">\n <Handle id={makeOut} type=\"source\" position={Position.Right} isConnectable={false} className={`pb-pin pb-pin-${pinColour(pure.type)}`} style={{ top: 13 }} />\n {shownInputs.map((pin) => (\n <InputRow key={pin.key} pin={pin} step={pure.target} keys={[pure.key, pin.key]} connectable={editable} />\n ))}\n <FoldRow node={pure.id} folded={folded} open={open} />\n </div>\n )}\n </div>\n )\n}\n","import { Button } from '../../../../primitives/button'\nimport { text } from '../messages'\n\n/**\n * Where a wire was let go on the empty canvas, and the nodes the pin it came from can have: a Break or a Make for an\n * object pin, the condition nodes for an Only when pin or a side of an And, an Or or a Not.\n */\nexport type PureOffer = { x: number; y: number; choices: { label: string; add: () => void }[] }\n\n/** The offer of the nodes the pin a wire was dragged from can have, at the point it was let go. */\nexport const PureOfferMenu = ({ offer, onClose }: { offer: PureOffer; onClose: () => void }) => (\n <div role=\"dialog\" aria-label={text('pureOfferTitle')} className=\"absolute z-10 grid gap-1 rounded-md border bg-background p-1 shadow-md\" style={{ left: offer.x, top: offer.y }}>\n {offer.choices.map((choice, index) => (\n <Button\n key={choice.label}\n size=\"sm\"\n variant=\"ghost\"\n className=\"justify-start\"\n autoFocus={index === 0}\n onClick={() => {\n choice.add()\n onClose()\n }}\n >\n {choice.label}\n </Button>\n ))}\n <Button size=\"sm\" variant=\"ghost\" onClick={onClose}>\n {text('pureOfferClose')}\n </Button>\n </div>\n)\n","import {\n allStates,\n conditionParts,\n expressionReferences,\n expressionSource,\n inputSchema,\n isConditionPart,\n orderOf,\n parseReference,\n pinType,\n readText,\n referenceValue,\n resultRead,\n schemaAt,\n selectParts,\n stepStatuses,\n type SelectPart,\n type ConditionInput,\n type ConditionPart,\n type Definition,\n type PinSchemas,\n type PinType,\n type Reference,\n type State,\n} from '@protobase/workflows'\nimport { pathOfName, triggerId } from '../definition'\nimport { conditionKey, conditionPin, fieldsOf, givenSchema, inputPin, inputPins, statusKey, statusPin, stepOutputs, triggerOutputs, type InputPin, type OutputPin } from './node-pins'\nimport { breakId, breakIn, conditionId, conditionOut, inHandle, makeId, makeOut, outHandle, selectId, selectInput, selectOut } from './pure-ids'\n\n/** A Break node: the fields of the object a node gives at `path`, each a pin of its own. */\nexport type BreakNode = { kind: 'break'; id: string; source: string; path: string[]; type: PinType; outputs: OutputPin[] }\n\n/** A Make node: the object a step's argument `key` holds, built from a pin per field. */\nexport type MakeNode = { kind: 'make'; id: string; target: string; key: string; type: PinType; inputs: InputPin[] }\n\n/** A Condition no condition nodes stand for, whole: its JSONata, between `{%` and `%}`. */\nexport type ConditionExpression = { kind: 'expression'; source: string }\n\n/**\n * A node of a step's Condition, on the way to its Only when pin in data order: a Comparison, an And, an Or or a Not at\n * `at` among the Condition's nodes, with an input per side, or the whole Condition as an Expression, with a pin per\n * value it reads.\n */\nexport type ConditionNode = { kind: 'condition'; id: string; target: string; at: number[]; part: ConditionPart | ConditionExpression; inputs: InputPin[] }\n\n/**\n * A Select node: the value a step's argument `key` holds, chosen by another, which its one input reads; with a case per\n * value that one can be and what it gives then, and what it gives for any other.\n */\nexport type SelectNode = { kind: 'select'; id: string; target: string; key: string; part: SelectPart; type: PinType; inputs: InputPin[] }\n\nexport type PureNode = BreakNode | MakeNode | ConditionNode | SelectNode\n\n/**\n * A wire from an output pin to an input pin, of the type of the value it carries. `expression`: the input is an\n * expression that reads the value among others, so the wire shows the read, and only changing the expression removes it.\n */\nexport type DataEdge = { id: string; source: string; sourceHandle: string; target: string; targetHandle: string; type: PinType; expression?: true }\n\n/** A Break or Make made on the canvas, which the document holds nothing for until a wire runs through it. */\nexport type LocalPure = { kind: 'break'; source: string; path: string[] } | { kind: 'make'; target: string; key: string }\n\n/** The data side of the graph: every node's pins, the Break, Make and condition nodes, and the wires. */\nexport type DataGraph = { inputs: Map<string, InputPin[]>; outputs: Map<string, OutputPin[]>; pure: PureNode[]; edges: DataEdge[] }\n\nconst isObject = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst samePath = (a: readonly string[], b: readonly string[]) => a.length === b.length && a.every((key, index) => key === b[index])\n\nconst booleanType: PinType = { kinds: ['boolean'] }\n\n// The reads a Condition's nodes make, each once for each side that makes it\nconst partReads = (part: ConditionPart): Reference[] => (part.sides as ConditionInput[]).flatMap((side) => (isConditionPart(side) ? partReads(side) : 'read' in side ? [side.read] : []))\n\n// A read of a step's Status, which the step's status pin gives\nconst readsStatus = (side: ConditionInput) => !isConditionPart(side) && 'read' in side && 'step' in side.read.base && samePath(side.read.path, ['Status'])\n\n// The type of a value of a Comparison's own, by the type of what it is compared with, else by its own\nconst literalType = (value: unknown, other: PinType | undefined): PinType => {\n if (other && other.kinds !== 'any') {\n const kinds = other.kinds.filter((kind) => kind !== 'null')\n if (kinds.length === 1 && ['string', 'integer', 'number', 'boolean'].includes(kinds[0]!)) return { kinds }\n }\n return { kinds: [typeof value === 'number' ? 'number' : typeof value === 'boolean' ? 'boolean' : 'string'] }\n}\n\n// The path of every state that keeps its whole result in a variable, by the variable, when exactly one does.\nconst resultVariables = (definition: Definition) => {\n const found = new Map<string, string | null>()\n for (const [name, state] of allStates(definition.stateMachine)) {\n const assign = 'Assign' in state && isObject(state.Assign) ? state.Assign : {}\n for (const [variable, value] of Object.entries(assign)) {\n const path = value === resultRead ? pathOfName(definition.stateMachine, name)?.join('/') : undefined\n found.set(variable, found.has(variable) || path === undefined ? null : path)\n }\n }\n return found\n}\n\n/**\n * The data side of a definition: each step's input pins and each node's output pins by their types, a wire for each\n * argument that is one read by name, through a Break node for each object a read goes into, a Make node for each\n * argument written as an object whose fields read values, and in data order each Condition as the condition nodes it\n * is made of, or else as an Expression node, with the Breaks and Makes of `local` besides.\n */\nexport const dataGraph = (definition: Definition, schemas: PinSchemas, local: readonly LocalPure[] = []): DataGraph => {\n const states = new Map<string, State>(allStates(definition.stateMachine).map(([name, state]) => [pathOfName(definition.stateMachine, name)!.join('/'), state]))\n // In data order every state has an Only when pin first and a status pin last\n const data = orderOf(definition) === 'data'\n const outputs = new Map<string, OutputPin[]>([[triggerId, triggerOutputs(definition, schemas)], ...[...states].map(([path, state]): [string, OutputPin[]] => [path, [...stepOutputs(state, schemas), ...(data ? [statusPin] : [])]])])\n const inputs = new Map([...states].filter(([, state]) => data || state.Type === 'Task').map(([path, state]) => [path, [...(data ? [conditionPin(state)] : []), ...inputPins(state, schemas)]]))\n const pathOfState = (name: string) => [...states.keys()].find((path) => path.split('/').at(-1) === name)\n const breaks = new Map<string, BreakNode>()\n const makes = new Map<string, MakeNode>()\n const conditions: ConditionNode[] = []\n const selects: SelectNode[] = []\n const edges = new Map<string, DataEdge>()\n const variables = resultVariables(definition)\n\n const wire = (from: { node: string; handle: string; type: PinType }, target: string, targetHandle: string, expression = false) => {\n const id = `data:${from.node}|${from.handle}->${target}|${targetHandle}`\n if (expression && edges.has(id)) return\n edges.set(id, { id, source: from.node, sourceHandle: from.handle, target, targetHandle, type: from.type, ...(expression && { expression: true as const }) })\n }\n const pinOf = (pins: OutputPin[], path: string[]) => {\n let pin = pins.find((each) => samePath(each.path, path))\n if (!pin) {\n pin = { path, type: pinType(undefined) }\n pins.push(pin)\n }\n return pin\n }\n // The pin that gives the value at `path` of what `source` gives: its own, or a field of a Break of the object around it\n const from = (source: string, path: string[]): { node: string; handle: string; type: PinType } => {\n const pins = outputs.get(source)!\n const own = pins.find((pin) => samePath(pin.path, path))\n // A step's status pin in data order is no field of what it gives: a step giving one whole value stays unfielded\n const fielded = pins.some((pin) => pin.path.length > 0 && pin.path[0] !== statusKey)\n if (own || path.length === 0 || (fielded && path.length === 1)) {\n const pin = own ?? pinOf(pins, path)\n return { node: source, handle: outHandle(pin.path), type: pin.type }\n }\n const broken = breakOf(source, path.slice(0, -1))\n const pin = pinOf(broken.outputs, path.slice(-1))\n return { node: broken.id, handle: outHandle(pin.path), type: pin.type }\n }\n const breakOf = (source: string, path: string[]) => {\n const id = breakId(source, path)\n const known = breaks.get(id)\n if (known) return known\n const schema = givenSchema(definition, states.get(source), schemas, path)\n const made: BreakNode = { kind: 'break', id, source, path, type: pinType(schema), outputs: fieldsOf(schema).map(([key, field]) => ({ path: [key], type: pinType(field) })) }\n breaks.set(id, made)\n wire(from(source, path), id, breakIn)\n return made\n }\n // The wires of a value: one for a read by name alone, else one for each read of its expression\n const wireValue = (value: unknown, target: string, targetHandle: string) => {\n const one = sourceOf(value)\n if (one) return wire(one, target, targetHandle)\n for (const reference of expressionReferences(value)) {\n const source = sourceOfReference(reference)\n if (source) wire(source, target, targetHandle, true)\n }\n }\n const sourceOf = (value: unknown) => {\n const reference = parseReference(value)\n return reference && sourceOfReference(reference)\n }\n const sourceOfReference = (reference: Reference) => {\n if ('step' in reference.base) {\n const node = pathOfState(reference.base.step)\n return node === undefined || !outputs.has(node) ? undefined : from(node, [statusKey, ...reference.path])\n }\n const node = 'input' in reference.base ? triggerId : variables.get(reference.base.variable)\n return node === undefined || node === null || !outputs.has(node) ? undefined : from(node, reference.path)\n }\n // A read a condition node takes: a step's Status from its status pin, any other as a step's input takes it\n const sourceOfSide = (side: ConditionInput) => {\n if (isConditionPart(side) || !('read' in side)) return\n if (!readsStatus(side)) return sourceOfReference(side.read)\n const node = pathOfState((side.read.base as { step: string }).step)\n return node === undefined || !outputs.has(node) ? undefined : from(node, [statusKey])\n }\n // Each node of a Condition, its output wired to where it goes, and each side wired from its node or what it reads\n const partOf = (target: string, part: ConditionPart, at: number[], into: { node: string; handle: string }) => {\n const id = conditionId(target, at)\n const sides: ConditionInput[] = part.sides\n const sources = sides.map(sourceOfSide)\n const inputs = sides.map((side, index): InputPin => {\n const key = String(index)\n if (isConditionPart(side)) return { key, type: booleanType, required: false, value: undefined, state: 'made' }\n if ('read' in side) return { key, type: sources[index]?.type ?? pinType(undefined), required: false, value: referenceValue(side.read), state: 'wired' }\n // A Matches node's pattern is its own, written on the node; the text it tests is any text\n if ('pattern' in side) return { key, type: { kinds: ['string'] }, required: false, value: side.pattern, state: 'literal' }\n if (part.kind === 'matches') return { key, type: { kinds: ['string'] }, required: false, value: side.value, state: 'literal' }\n if (part.kind !== 'compare') return { key, type: booleanType, required: false, value: side.value, state: 'literal' }\n // A value compared with a step's Status is one of the statuses it can be\n const other = sides[1 - index]!\n if (readsStatus(other)) return { key, type: { kinds: ['string'] }, required: false, value: side.value, state: 'literal', options: stepStatuses, statuses: true }\n return { key, type: literalType(side.value, sources[1 - index]?.type), required: false, value: side.value, state: 'literal' }\n })\n // An All of or an Any of has one input more, empty, which a wire or a node adds as its next condition\n if (part.kind === 'logic') inputs.push({ key: String(sides.length), type: booleanType, required: false, value: undefined, state: 'empty' })\n conditions.push({ kind: 'condition', id, target, at, part, inputs })\n wire({ node: id, handle: conditionOut, type: booleanType }, into.node, into.handle)\n sides.forEach((side, index) => {\n if (isConditionPart(side)) partOf(target, side, [...at, index], { node: id, handle: inHandle(String(index)) })\n else if (sources[index]) wire(sources[index], id, inHandle(String(index)))\n })\n }\n // A step's Condition as its condition nodes when it is made of them and each read has a pin to come from, else as an\n // Expression node with a pin per value it reads\n const conditionOf = (target: string, value: unknown) => {\n const part = conditionParts(value)\n const into = { node: target, handle: inHandle(conditionKey) }\n if (part && partReads(part).every((read) => sourceOfSide({ read }))) return partOf(target, part, [], into)\n const id = conditionId(target, [])\n const reads = expressionReferences(value).flatMap((read) => {\n const source = sourceOfSide({ read })\n return source ? [{ read, source }] : []\n })\n conditions.push({ kind: 'condition', id, target, at: [], part: { kind: 'expression', source: expressionSource(value)! }, inputs: reads.map(({ read, source }) => ({ key: readText(read), type: source.type, required: false, value: referenceValue(read), state: 'wired' })) })\n wire({ node: id, handle: conditionOut, type: booleanType }, into.node, into.handle)\n for (const { read, source } of reads) wire(source, id, inHandle(readText(read)), true)\n }\n // A step's argument chosen by another value, as a Select node, when what it looks at has a pin to come from\n const selectOf = (target: string, pin: InputPin) => {\n const part = selectParts(pin.value)\n const source = part && sourceOfSide(part.operand)\n if (!part || ('read' in part.operand && !source)) return false\n const id = selectId(target, pin.key)\n const operand: InputPin = 'read' in part.operand\n ? { key: selectInput, type: source!.type, required: false, value: referenceValue(part.operand.read), state: 'wired' }\n : { key: selectInput, type: { kinds: ['string'] }, required: false, value: part.operand.value, state: 'literal' }\n selects.push({ kind: 'select', id, target, key: pin.key, part, type: pin.type, inputs: [operand] })\n wire({ node: id, handle: selectOut, type: pin.type }, target, inHandle(pin.key))\n if (source) wire(source, id, inHandle(selectInput))\n return true\n }\n const makeOf = (target: string, key: string) => {\n const id = makeId(target, key)\n const known = makes.get(id)\n if (known) return known\n const pin = inputs.get(target)?.find((each) => each.key === key)\n const state = states.get(target)!\n const schema = schemaAt(inputSchema(state, schemas), [key])\n const value = isObject(pin?.value) ? pin.value : {}\n const required = new Set(Array.isArray(schema?.required) ? (schema.required as string[]) : [])\n const declared = fieldsOf(schema).map(([field, fieldSchema]) => inputPin(field, fieldSchema, value[field], required.has(field)))\n const extra = Object.keys(value).filter((field) => !declared.some((each) => each.key === field)).map((field) => inputPin(field, schemaAt(schema, [field]) ?? {}, value[field], false))\n const made: MakeNode = { kind: 'make', id, target, key, type: pin?.type ?? pinType(schema), inputs: [...declared, ...extra] }\n makes.set(id, made)\n wire({ node: id, handle: makeOut, type: made.type }, target, inHandle(key))\n for (const field of made.inputs) wireValue(field.value, id, inHandle(field.key))\n return made\n }\n\n for (const [target, pins] of inputs) {\n for (const [index, pin] of pins.entries()) {\n // A Condition that computes is drawn by its nodes, which build it as a Make builds an object\n if (pin.key === conditionKey && pin.state === 'expression') {\n pins[index] = { ...pin, state: 'made' }\n conditionOf(target, pin.value)\n continue\n }\n // A value chosen by another is drawn as a Select node, which builds it as a Make builds an object\n if (pin.state === 'expression' && selectOf(target, pin)) {\n pins[index] = { ...pin, state: 'made' }\n continue\n }\n if (pin.state === 'made') makeOf(target, pin.key)\n if (pin.state === 'wired' || pin.state === 'expression') wireValue(pin.value, target, inHandle(pin.key))\n }\n }\n for (const each of local) {\n if (each.kind === 'break' && outputs.has(each.source)) breakOf(each.source, each.path)\n // A Make made on the canvas stays only while its input holds no read or expression, which a wire would have put there\n if (each.kind === 'make' && inputs.get(each.target)?.some((pin) => pin.key === each.key && pin.state !== 'wired' && pin.state !== 'expression')) makeOf(each.target, each.key)\n }\n return { inputs, outputs, pure: [...breaks.values(), ...makes.values(), ...conditions, ...selects], edges: [...edges.values()] }\n}\n","import { text } from '../messages'\nimport type { WireRefusal } from './data-edits'\nimport { typeLabel } from './pin-text'\n\n/** Why a wire is refused, in words, as the line being drawn says it over the pin it would end at. */\nexport const refusalText = (refusal: WireRefusal) => {\n if (refusal.reason === 'notBefore') return text('refuseNotBefore', { step: refusal.step })\n if (refusal.reason === 'otherScope') return text('refuseOtherScope', { step: refusal.step })\n if (refusal.reason === 'shapesOutput') return text('refuseShaped', { step: refusal.step })\n if (refusal.reason === 'type') return text('refuseType', { source: typeLabel(refusal.source), target: typeLabel(refusal.target) })\n return text('refuseNotPins')\n}\n","import type { Connection, Edge, FinalConnectionState } from '@xyflow/react'\nimport { useEffect, useMemo, useRef, useState, type RefObject } from 'react'\nimport { orderOf, type Definition, type PinSchemas } from '@protobase/workflows'\nimport type { Graph } from '../definition-graph'\nimport type { CanvasEdits } from '../canvas-edits'\nimport { graphId, isPureFlowId } from '../flow-elements'\nimport { text } from '../messages'\nimport type { ConditionChoice } from './condition-edits'\nimport type { PinEnd } from './data-edits'\nimport { lastPlaceFirst, nodePlace, wirePlace } from './removal-order'\nimport { dataGraph, type DataEdge, type LocalPure, type PureNode } from './data-graph'\nimport { conditionKey } from './node-pins'\nimport { nodeSizes, pinPorts } from './node-sizes'\nimport type { PinActions } from './pin-actions'\nimport { conditionTitle, typeLabel } from './pin-text'\nimport type { PureOffer } from './pure-offer'\nimport { breakId, inKey, makeId, outPath } from './pure-ids'\nimport { pureParent } from './pure-parents'\nimport { refusalText } from './refusal-text'\nimport type { WireCheck } from './wire-line'\n\n/** Whether a handle is a pin's, rather than one execution runs along. */\nexport const isPinHandle = (handle: string | null | undefined) => inKey(handle) !== undefined || outPath(handle) !== undefined\n\nconst end = (node: string, handle: string | null | undefined): PinEnd => ({ node: graphId(node), handle: handle ?? '' })\n\nconst isObjectType = (kinds: readonly string[] | 'any') => kinds !== 'any' && kinds.includes('object')\n\n// The offer of each condition node of `choices`, each written where `put` puts it\nconst conditionOffer = (choices: readonly ConditionChoice[], put: (choice: ConditionChoice) => void) => choices.map((choice) => ({ label: conditionTitle(choice), add: () => put(choice) }))\n\n/**\n * The Breaks and Makes made on the canvas that stay once `gone` are removed: those, and each Break made from a field of\n * a removed Break, which takes its object from it.\n */\nexport const localsLeft = (local: readonly LocalPure[], gone: readonly PureNode[]): LocalPure[] => {\n const id = (each: LocalPure) => (each.kind === 'break' ? breakId(each.source, each.path) : makeId(each.target, each.key))\n const under = (each: LocalPure) => each.kind === 'break' && gone.some((parent) => parent.kind === 'break' && parent.source === each.source && parent.path.every((step, index) => each.path[index] === step))\n return local.filter((each) => !under(each) && !gone.some((node) => node.id === id(each)))\n}\n\n/** What an editable canvas's pins change: the definition, through `onChange`, by `edits`. */\nexport type PinEditing = { onChange: (definition: Definition) => void; edits: CanvasEdits }\n\n/**\n * The pins of a canvas, given the schemas their types come from: the data graph with the Break and Make nodes made on\n * the canvas, which inputs are open, what the layout places, and with `editing`, what wiring, unwiring, removing a\n * Break, a Make or a condition node and letting go of a wire on the empty canvas do. Without schemas, no pins.\n */\nexport const usePins = (definition: Definition, graph: Graph, schemas: PinSchemas | undefined, editing: PinEditing | undefined, frame: RefObject<HTMLElement | null>) => {\n const edits = editing?.edits\n const [local, setLocal] = useState<LocalPure[]>([])\n const [open, setOpen] = useState<ReadonlySet<string>>(new Set())\n const [offer, setOffer] = useState<PureOffer>()\n // The definition and editing as they are now, which a choice made in an offer opened before an edit applies to\n const now = useRef({ definition, editing })\n useEffect(() => {\n now.current = { definition, editing }\n })\n const data = useMemo(() => schemas && dataGraph(definition, schemas, local), [definition, schemas, local])\n const dataOrder = orderOf(definition) === 'data'\n const layout = useMemo(() => {\n if (!data) return\n return {\n sizes: nodeSizes(graph, data, open),\n pure: data.pure.map((pure) => ({ id: pure.id, parent: pureParent(graph, pure) })),\n wires: data.edges.map((edge) => ({ id: edge.id, source: edge.source, target: edge.target, sourceHandle: edge.sourceHandle, targetHandle: edge.targetHandle })),\n ports: pinPorts(graph, data, open),\n dataOrder,\n }\n }, [graph, data, open, dataOrder])\n\n const actions: PinActions | undefined = editing && {\n setArgument: (step, keys, value) => editing.onChange(editing.edits.setArgument(definition, step, keys, value)),\n setConditionSide: (step, at, value) => editing.onChange(editing.edits.setConditionSide(definition, step, at, { value })),\n setCondition: (step, value) => editing.onChange(editing.edits.setArgument(definition, step, [conditionKey], value)),\n toggleOpen: (node) => setOpen((current) => (current.has(node) ? new Set([...current].filter((id) => id !== node)) : new Set([...current, node]))),\n }\n const check: WireCheck = (from, to) => {\n if (!data || !edits || !isPinHandle(from.handle) || !isPinHandle(to.handle)) return\n // A wire may be dragged from its input end\n const [start, finish] = outPath(from.handle) ? [from, to] : [to, from]\n const refusal = edits.wireRefusal(definition, data, end(start.node, start.handle), end(finish.node, finish.handle))\n return refusal && refusalText(refusal)\n }\n const isValid = (connection: Connection | Edge) => Boolean(data && edits) && edits!.wireRefusal(definition, data!, end(connection.source, connection.sourceHandle), end(connection.target, connection.targetHandle)) === undefined\n const connect = (connection: Connection) => {\n if (!editing || !data) return\n editing.onChange(editing.edits.connectData(definition, data, end(connection.source, connection.sourceHandle), end(connection.target, connection.targetHandle)))\n }\n // Wires cut and Breaks and Makes removed, from what the other removals left. Cutting the wire a Break takes its object\n // by, or a Make gives its object by, removes that node, which has no place without it.\n const remove = (next: Definition, nodes: readonly { id: string }[], edges: readonly Edge[]) => {\n if (!data || !edits) return next\n let after = next\n const bound = edges.flatMap((edge) => {\n const wire = (edge.data as { wire?: DataEdge } | undefined)?.wire\n const pure = wire && data.pure.find((each) => (each.kind === 'break' && each.id === wire.target) || (each.kind === 'make' && each.id === wire.source))\n return pure ? [{ id: pure.id }] : []\n })\n const gone = [...nodes.filter((node) => isPureFlowId(node.id)), ...bound.filter((node) => !nodes.some((other) => other.id === node.id))]\n // Wires cut and nodes removed, the last inputs of a Condition's nodes first, so none moves another's place\n const cut = edges.flatMap((edge) => {\n const wire = (edge.data as { kind?: string; wire?: DataEdge } | undefined)?.wire\n return wire && !gone.some((node) => node.id === wire.source || node.id === wire.target) ? [{ wire }] : []\n })\n const removed = gone.flatMap((node) => data.pure.filter((each) => each.id === node.id).map((pure) => ({ pure })))\n const removals: ({ wire: DataEdge } | { pure: PureNode })[] = [...cut, ...removed]\n for (const removal of lastPlaceFirst(data, removals, (each) => ('wire' in each ? wirePlace(data, each.wire) : nodePlace(each.pure)))) {\n after = 'wire' in removal ? edits.disconnectData(after, data, removal.wire) : edits.removePure(after, data, removal.pure)\n }\n if (gone.length > 0) setLocal((current) => localsLeft(current, gone.flatMap((node) => data.pure.filter((each) => each.id === node.id))))\n return after\n }\n // A Select chosen in an offer, added to the definition as it is when it is chosen\n const addSelect = (step: string, key: string) => {\n const { definition: current, editing: latest } = now.current\n latest?.onChange(latest.edits.addSelect(current, step, key))\n }\n // A condition node chosen in an offer, added to the definition as it is when it is chosen\n const addCondition = (step: string, at: readonly number[], choice: ConditionChoice) => {\n const { definition: current, editing: latest } = now.current\n latest?.onChange(latest.edits.addCondition(current, step, at, choice))\n }\n // A wire from an object pin let go on the empty canvas offers to take that object apart, or to build it, there; one\n // from an empty Only when pin, or an input of an All of, an Any of or a Not that holds a value or none, the condition nodes\n const connectEnd = (event: MouseEvent | TouchEvent, state: FinalConnectionState) => {\n if (!data || !editing || state.isValid || state.toHandle || !state.fromHandle?.id || !state.fromNode) return\n const node = graphId(state.fromNode.id)\n const handle = state.fromHandle.id\n const point = 'changedTouches' in event ? event.changedTouches[0]! : event\n const box = frame.current?.getBoundingClientRect()\n const at = { x: point.clientX - (box?.left ?? 0), y: point.clientY - (box?.top ?? 0) }\n const path = outPath(handle)\n if (path) {\n const pure = data.pure.find((each) => each.id === node)\n const pins = pure?.kind === 'break' ? pure.outputs : data.outputs.get(node) ?? []\n const type = pins.find((pin) => JSON.stringify(pin.path) === JSON.stringify(path))?.type\n if (!type || !isObjectType(type.kinds)) return\n const source = pure?.kind === 'break' ? { source: pure.source, path: [...pure.path, ...path] } : { source: node, path }\n setOffer({ ...at, choices: [{ label: text('breakTitle', { type: typeLabel(type) }), add: () => setLocal((current) => [...current, { kind: 'break', ...source }]) }] })\n return\n }\n const key = inKey(handle)\n const condition = data.pure.find((each) => each.id === node)\n if (condition?.kind === 'condition') {\n const side = condition.inputs.find((each) => each.key === key)\n // An input of an All of, an Any of or a Not that holds a value, or the empty one after an All of's or Any of's last\n if (!side || (side.state !== 'literal' && side.state !== 'empty') || (condition.part.kind !== 'logic' && condition.part.kind !== 'not')) return\n setOffer({ ...at, choices: conditionOffer(editing.edits.conditionChoices(false), (choice) => addCondition(condition.target, [...condition.at, Number(key)], choice)) })\n return\n }\n const pin = key === undefined ? undefined : data.inputs.get(node)?.find((each) => each.key === key)\n if (pin?.key === conditionKey && pin.state === 'empty') {\n setOffer({ ...at, choices: conditionOffer(editing.edits.conditionChoices(true), (choice) => addCondition(node, [], choice)) })\n return\n }\n // An input of a value, empty or holding one of its own, can have a Select choose it from another value\n if (pin && pin.key !== conditionKey && !isObjectType(pin.type.kinds) && (pin.state === 'empty' || pin.state === 'literal')) {\n setOffer({ ...at, choices: [{ label: text('selectOffer'), add: () => addSelect(node, pin.key) }] })\n return\n }\n if (!pin || !isObjectType(pin.type.kinds) || pin.state === 'wired' || pin.state === 'expression') return\n setOffer({ ...at, choices: [{ label: text('makeTitle', { type: typeLabel(pin.type) }), add: () => setLocal((current) => [...current, { kind: 'make', target: node, key: pin.key }]) }] })\n }\n return { data, open, layout, actions, check, isValid, connect, remove, connectEnd, offer, closeOffer: () => setOffer(undefined) }\n}\n","import { getBezierPath, type ConnectionLineComponentProps } from '@xyflow/react'\nimport { createContext, useContext } from 'react'\nimport type { FlowNode } from '../flow-elements'\n\n/** Why a wire from one handle to another would be refused, in words; undefined when it would not be, or is no wire. */\nexport type WireCheck = (from: { node: string; handle: string }, to: { node: string; handle: string }) => string | undefined\n\nexport const WireCheckContext = createContext<WireCheck | undefined>(undefined)\n\n/**\n * The line drawn while a wire is dragged: over a pin that refuses it, it turns red and says why, such as that text\n * does not fit a whole number, as Blueprints do.\n */\nexport const WireLine = ({ fromX, fromY, toX, toY, fromPosition, toPosition, connectionStatus, fromNode, fromHandle, toNode, toHandle }: ConnectionLineComponentProps<FlowNode>) => {\n const check = useContext(WireCheckContext)\n const [path] = getBezierPath({ sourceX: fromX, sourceY: fromY, sourcePosition: fromPosition, targetX: toX, targetY: toY, targetPosition: toPosition })\n const refused = connectionStatus === 'invalid' && toNode && toHandle?.id && fromHandle.id ? check?.({ node: fromNode.id, handle: fromHandle.id }, { node: toNode.id, handle: toHandle.id }) : undefined\n return (\n <g className={refused ? 'pb-wire-refused' : undefined}>\n <path d={path} fill=\"none\" className=\"react-flow__connection-path\" />\n {refused && (\n <foreignObject x={toX + 12} y={toY - 30} width={260} height={28} className=\"overflow-visible\">\n <div className=\"inline-block rounded border border-danger bg-danger-soft px-1.5 py-0.5 text-xs whitespace-nowrap text-danger-text shadow\">{refused}</div>\n </foreignObject>\n )}\n </g>\n )\n}\n","/*! @license elkjs (https://github.com/kieler/elkjs), Copyright (c) 2019 TypeFox and others, EPL-2.0 OR GPL-3.0-or-later; its source is at that address. */\nimport { useEffect, useMemo, useState } from 'react'\nimport { useElk } from '../../../lib/elk/use-elk'\nimport type { Graph } from './definition-graph'\nimport { elkGraph, layoutElk, type Box, type LayoutExtras } from './graph-layout'\n\n/**\n * The boxes of the graph's nodes, laid out again each time its nodes, edges, sizes or wires change, not when only what\n * a state does changes; until the first layout is done, undefined. A layout that a newer one overtook is dropped.\n */\nexport const useLayout = (graph: Graph, extras?: LayoutExtras) => {\n const engine = useElk()\n const [boxes, setBoxes] = useState<Map<string, Box>>()\n const shape = useMemo(() => JSON.stringify(elkGraph(graph, extras)), [graph, extras])\n useEffect(() => {\n if (!engine) return\n let current = true\n void layoutElk(engine, JSON.parse(shape)).then((laidOut) => {\n if (current) setBoxes(laidOut)\n })\n return () => {\n current = false\n }\n }, [engine, shape])\n return boxes\n}\n","import { Background, Controls, Panel, ReactFlow, ReactFlowProvider, useKeyPress, useReactFlow, useStore, useUpdateNodeInternals, type Connection, type Edge, type EdgeChange, type IsValidConnection, type NodeChange, type XYPosition } from '@xyflow/react'\nimport '@xyflow/react/dist/style.css'\nimport './workflow-canvas.css'\nimport { LayoutGrid } from 'lucide-react'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport type { WorkflowTypeList } from '@protobase/client'\nimport { orderOf, type Definition, type PinSchemas } from '@protobase/workflows'\nimport { triggerId } from './definition'\nimport type { CanvasEdits } from './canvas-edits'\nimport type { AddAt } from './definition-edits'\nimport { definitionGraph, type EdgeKind, type GraphNode } from './definition-graph'\nimport { dataFlowEdges, flowEdges, flowId, flowNodes, graphId, isPureFlowId, pureFlowNodes, unwiredOrderEdges, type FlowNode } from './flow-elements'\nimport { AddAtContext } from './add-at-context'\nimport { StateNode, TriggerNode } from './flow-nodes'\nimport { Button } from '../../../primitives/button'\nimport { Segmented } from '../../../primitives/segmented'\nimport { useGraphView, type GraphView } from './pins/graph-view'\nimport { PinActionsContext } from './pins/pin-actions'\nimport { PureNodeView } from './pins/pure-nodes'\nimport { PureOfferMenu } from './pins/pure-offer'\nimport { pureParent } from './pins/pure-parents'\nimport { isPinHandle, usePins } from './pins/use-pins'\nimport { WireCheckContext, WireLine } from './pins/wire-line'\nimport type { NodeTrace } from './node-trace'\nimport type { NodeProblem } from './problems'\nimport { useLayout } from './use-layout'\nimport { layoutKey, placedBoxes, withoutKey, workflowLayoutOf, type ManualLayout, type WorkflowLayout } from './manual-layout'\nimport { UnpinContext } from './unpin-context'\nimport { text } from './messages'\n\nconst nodeTypes = { state: StateNode, trigger: TriggerNode, pure: PureNodeView }\n\nexport type WorkflowCanvasProps = {\n definition: Definition\n problems: ReadonlyMap<string, NodeProblem[]>\n /** The node chosen, by its graph id: the trigger's, or a state's path. */\n selected: string | undefined\n onSelect: (id: string | undefined) => void\n /** Without it and `edits`, the graph is only shown. */\n onChange?: (definition: Definition) => void\n /** What the canvas edits the definition with, `canvasEdits`, handed over with `onChange` so a canvas that only shows loads none of it. */\n edits?: CanvasEdits\n /** A click on a source handle, rather than a drag from it: a step is to be added there. */\n onAddAt?: (at: AddAt) => void\n /** How each state did in a run, by its path, marked on its node. */\n traces?: ReadonlyMap<string, NodeTrace>\n /** What the check warns of, by node, which a save goes through with. */\n warnings?: ReadonlyMap<string, NodeProblem[]>\n /** The app's types, whose labels name the nodes and whose cache advice marks them. */\n types?: WorkflowTypeList\n /** The schemas pins are typed by: with them, every step shows its inputs and outputs as pins, wired by the reads its arguments make. */\n schemas?: PinSchemas\n /** The canvas is the window, on a page that does not scroll: as a panel opens beside it, what was in its middle stays there. */\n fills?: boolean\n /** Where nodes were moved by hand in each view, by their layout keys, which the layout leaves where they were put. */\n layout?: WorkflowLayout\n /**\n * Without it, no node is moved by hand: with it, a node dragged stays where it is let go in the view shown, and Unpin\n * and Tidy up hand that view's nodes back to the layout.\n */\n onLayoutChange?: (layout: WorkflowLayout) => void\n}\n\n// The machine a node's states lead within: the Maps it is inside, or the trigger's, the whole workflow's.\nconst scopeOf = (node: GraphNode | undefined) => (node?.kind === 'state' ? node.scope.join('/') : '')\n\n// Each new layout is fitted to the canvas, so a change is in sight without zooming by hand, as is the graph tidied up;\n// a node moved by hand moves nothing else in sight.\nconst FitOnLayout = ({ laidOut, tidied }: { laidOut: unknown; tidied: number }) => {\n const flow = useReactFlow()\n useEffect(() => {\n if (laidOut) void flow.fitView({ maxZoom: 1, padding: 0.1 })\n }, [laidOut, tidied])\n return null\n}\n\n// A canvas that fills its page narrows as a panel opens: what was in its middle stays there.\nconst KeepCentre = () => {\n const flow = useReactFlow()\n const width = useStore((state) => state.width)\n const before = useRef(width)\n useEffect(() => {\n const previous = before.current\n before.current = width\n // Only between two measured widths: the first measurement, and one back from a hidden pane, move nothing\n if (previous === 0 || width === 0 || width === previous) return\n const { x, y, zoom } = flow.getViewport()\n void flow.setViewport({ x: x + (width - previous) / 2, y, zoom })\n }, [width, flow])\n return null\n}\n\n// Each new layout measures every node's handles again: a Map's box grows with the states inside it, and its edges\n// leave from where its handles are now.\nconst MeasureOnLayout = ({ laidOut, ids }: { laidOut: unknown; ids: string[] }) => {\n const updateNodeInternals = useUpdateNodeInternals()\n useEffect(() => {\n if (laidOut) updateNodeInternals(ids)\n }, [laidOut])\n return null\n}\n\n// Where nodes dragged are until they are let go, by their canvas ids\nconst notDragged: ReadonlyMap<string, XYPosition> = new Map()\n\nconst Canvas = ({ definition, problems, warnings, selected, onSelect, onChange: changed, edits, onAddAt, traces, types, schemas, fills = false, layout, onLayoutChange }: WorkflowCanvasProps) => {\n const editing = changed && edits && { onChange: changed, edits }\n const graph = useMemo(() => definitionGraph(definition), [definition])\n const frame = useRef<HTMLDivElement>(null)\n // The simple view is the same document drawn without pins: its lines are the execution edges, which stay the lines\n // between steps when the order of steps comes from what they read\n const [view, setView] = useGraphView()\n const pins = usePins(definition, graph, view === 'pins' ? schemas : undefined, editing, frame)\n const laidOut = useLayout(graph, pins.layout)\n const byId = useMemo(() => new Map(graph.nodes.map((node) => [node.id, node])), [graph])\n // The record hands the layout over anew on each render: it changes only when its JSON does. Each view keeps its own.\n const layoutJson = JSON.stringify(layout ?? {})\n const whole = useMemo(() => workflowLayoutOf(layoutJson), [layoutJson])\n const manual = whole[view]\n const changeView = (next: ManualLayout) => onLayoutChange?.({ ...whole, [view]: next })\n // Each node's layout key, by its id on the graph, a Break's or a Make's its own\n const keys = useMemo(() => new Map([...graph.nodes.map((node): [string, string] => [node.id, layoutKey(node.id)]), ...(pins.data?.pure ?? []).map((pure): [string, string] => [pure.id, layoutKey(pure.id, pure)])]), [graph, pins.data])\n const moved = useMemo(() => new Map([...keys].flatMap(([id, key]) => (Object.hasOwn(manual, key) ? [[id, manual[key]!] as const] : []))), [keys, manual])\n // The nodes ELK laid out, with the moved ones where they were put and the others clear of them\n const boxes = useMemo(() => {\n if (!laidOut) return undefined\n const pure = new Map((pins.data?.pure ?? []).map((node) => [node.id, node]))\n const parentOf = (id: string) => {\n const node = byId.get(id)\n return pure.has(id) ? pureParent(graph, pure.get(id)!) : node?.kind === 'state' ? node.parent : undefined\n }\n return placedBoxes(laidOut, moved, parentOf)\n }, [laidOut, moved, byId, graph, pins.data])\n const movable = Boolean(onLayoutChange)\n const [dragged, setDragged] = useState(notDragged)\n const [tidied, setTidied] = useState(0)\n const dataOrder = orderOf(definition) === 'data'\n // The nodes chosen, by their canvas ids, which move together and which Delete removes: Shift-click adds or takes one\n // out, and a Shift-drag box chooses every node it covers. A step's form opens only while it is the one node chosen.\n const [chosen, setChosen] = useState<ReadonlySet<string>>(() => new Set(selected === undefined ? [] : [flowId(selected)]))\n // A step chosen from outside, such as one just added, is the one node chosen; its form closed from outside, it no longer is\n useEffect(() => {\n setChosen((current) => {\n if (selected !== undefined) return current.has(flowId(selected)) ? current : new Set([flowId(selected)])\n return current.size === 1 && !isPureFlowId([...current][0]!) ? new Set() : current\n })\n }, [selected])\n const nodes = useMemo(\n () =>\n [\n ...flowNodes(graph, boxes, problems, selected, traces, types, warnings, pins.data && { data: pins.data, open: pins.open }, dataOrder),\n ...(pins.data ? pureFlowNodes(graph, pins.data, boxes, pins.open) : []),\n ].map((node) => {\n const at = dragged.get(node.id)\n const pinned = moved.has(graphId(node.id))\n return {\n ...node,\n selected: chosen.has(node.id),\n draggable: movable,\n ...(at && { position: at }),\n ...(pinned && { data: { ...node.data, moved: true }, ...(node.ariaLabel && { ariaLabel: `${node.ariaLabel}, ${text('movedByHand')}` }) }),\n }\n }),\n [graph, boxes, problems, selected, traces, types, warnings, pins.data, pins.open, dataOrder, chosen, dragged, moved, movable],\n )\n // The edge chosen, which Delete removes\n const [chosenEdge, setChosenEdge] = useState<string>()\n // In data order with pins, the wires are what the states read, which order them: another line between two states is\n // drawn only where no wire stands for it\n const edges = useMemo(\n () => [...(dataOrder && pins.data ? unwiredOrderEdges(graph, pins.data) : flowEdges(graph, dataOrder)), ...(pins.data ? dataFlowEdges(pins.data) : [])].map((edge) => ({ ...edge, selected: edge.id === chosenEdge })),\n [graph, pins.data, chosenEdge, dataOrder],\n )\n const editable = Boolean(editing)\n\n // A state leads only to a state of its own machine: the trigger to one of the workflow's, a Map's to its own.\n const isValidConnection: IsValidConnection = (connection) => {\n // A wire joins pins, as their types allow; execution runs along the other handles\n if (isPinHandle(connection.sourceHandle) || isPinHandle(connection.targetHandle)) return isPinHandle(connection.sourceHandle) && isPinHandle(connection.targetHandle) && pins.isValid(connection)\n if (connection.targetHandle !== 'in') return false\n const target = byId.get(graphId(connection.target))\n const source = byId.get(graphId(connection.source))\n return target?.kind === 'state' && scopeOf(source) === scopeOf(target)\n }\n // Nodes let go stay where they are, each under its key; one let go where the layout has it stays the layout's\n const drop = (positions: ReadonlyMap<string, XYPosition>) => {\n setDragged(notDragged)\n const placed = [...positions].flatMap(([node, at]): [string, XYPosition][] => {\n const id = graphId(node)\n const key = keys.get(id)\n const box = boxes?.get(id)\n const point = { x: Math.round(at.x), y: Math.round(at.y) }\n if (key === undefined || (!moved.has(id) && box && Math.round(box.x) === point.x && Math.round(box.y) === point.y)) return []\n return [[key, point]]\n })\n if (placed.length > 0) changeView({ ...manual, ...Object.fromEntries(placed) })\n }\n const unpin = onLayoutChange && ((node: string) => {\n const key = keys.get(graphId(node))\n if (key !== undefined) changeView(withoutKey(manual, key))\n })\n const tidy = () => {\n changeView({})\n setTidied((count) => count + 1)\n }\n const onNodesChange = (changes: NodeChange<FlowNode>[]) => {\n // A node follows the pointer while dragged, and the arrow keys move the chosen one, each move let go at once\n const dropped = new Map<string, XYPosition>()\n for (const change of changes) {\n if (change.type !== 'position' || !change.position || !movable) continue\n const at = change.position\n if (change.dragging) setDragged((current) => new Map(current).set(change.id, at))\n else dropped.set(change.id, at)\n }\n if (dropped.size > 0) drop(dropped)\n const choices = changes.filter((change) => change.type === 'select')\n if (choices.length === 0) return\n const next = new Set(chosen)\n for (const change of choices) {\n if (change.selected) next.add(change.id)\n else next.delete(change.id)\n }\n setChosen(next)\n // A step's form opens when it is chosen alone, by a plain click or the keyboard; a Break, a Make or several nodes\n // chosen open none. A choice made with Shift or a box never opens one, not even while it holds one step on the way.\n const [only] = next.size === 1 ? [...next] : []\n const step = only === undefined || isPureFlowId(only) ? undefined : graphId(only)\n if (step !== undefined && (shiftHeld || boxing.current)) return selected === undefined ? undefined : onSelect(undefined)\n if (step !== selected) onSelect(step)\n }\n // Whether a choice is being made with Shift or a box, which opens no step's form\n const shiftHeld = useKeyPress('Shift')\n const boxing = useRef(false)\n const onEdgesChange = (changes: EdgeChange[]) => {\n for (const change of changes) {\n if (change.type !== 'select') continue\n if (change.selected) setChosenEdge(change.id)\n else setChosenEdge((current) => (current === change.id ? undefined : current))\n }\n }\n const onConnect = (connection: Connection) => {\n if (!editing || !connection.sourceHandle) return\n if (isPinHandle(connection.sourceHandle)) return pins.connect(connection)\n editing.onChange(editing.edits.connect(definition, connection.sourceHandle as EdgeKind, graphId(connection.source), graphId(connection.target)))\n }\n // Deleting a state takes the edges to it along: its own removal does that, so they are left alone here.\n const onDelete = ({ nodes: gone, edges: cut }: { nodes: { id: string }[]; edges: Edge[] }) => {\n if (!editing) return\n const removed = gone.filter((node) => !isPureFlowId(node.id)).map((node) => graphId(node.id)).filter((id) => id !== triggerId)\n let next = pins.remove(definition, gone, cut)\n for (const edge of cut) {\n const data = edge.data as { kind: EdgeKind; field: string; source: string }\n if ((data.kind as string) === 'data') continue\n if (!removed.includes(data.source) && !removed.includes(graphId(edge.target))) next = editing.edits.disconnect(next, data)\n }\n // A Map's states go with it\n for (const path of removed) if (!removed.some((other) => path.startsWith(`${other}/`))) next = editing.edits.removeState(next, path)\n editing.onChange(next)\n }\n\n return (\n <AddAtContext.Provider value={editing ? onAddAt : undefined}>\n <UnpinContext.Provider value={unpin}>\n <PinActionsContext.Provider value={pins.actions}>\n <WireCheckContext.Provider value={pins.check}>\n <div ref={frame} className=\"relative h-full w-full\">\n <ReactFlow\n className=\"pb-workflow\"\n nodes={nodes}\n edges={edges}\n nodeTypes={nodeTypes}\n nodesDraggable={movable}\n // A click that slips a pixel or two moves nothing, and a node moved is not chosen: its form would narrow the\n // canvas under the pointer\n nodeDragThreshold={4}\n selectNodesOnDrag={false}\n nodesConnectable={editable}\n // A click on a handle adds a step there; a connection is drawn by dragging, from a few pixels on\n connectOnClick={false}\n connectionDragThreshold={4}\n edgesFocusable={editable}\n elementsSelectable\n deleteKeyCode={editable ? ['Backspace', 'Delete'] : null}\n onNodesChange={onNodesChange}\n onEdgesChange={onEdgesChange}\n isValidConnection={isValidConnection}\n onConnect={onConnect}\n onConnectEnd={pins.connectEnd}\n connectionLineComponent={WireLine}\n onDelete={onDelete}\n // Shift adds a node to the choice or takes it out, as a Shift-drag box adds every node it covers\n multiSelectionKeyCode=\"Shift\"\n onSelectionStart={() => void (boxing.current = true)}\n onSelectionEnd={() => void (boxing.current = false)}\n // A click on a step chooses it alone, opening its form; with Shift it only adds to the choice, in onNodesChange\n onNodeClick={(event, node) => !event.shiftKey && !isPureFlowId(node.id) && onSelect(graphId(node.id))}\n onPaneClick={() => onSelect(undefined)}\n // As in Blueprints: the wheel zooms towards the pointer, as does a pinch, and dragging the empty canvas with\n // the left, middle or right button pans it; Shift-drag selects a box. A trackpad's two-finger scroll is a\n // wheel too, so it zooms: telling it from a mouse's wheel would be a guess. Over the canvas the page does\n // not scroll; elsewhere it does.\n zoomOnScroll\n panOnScroll={false}\n panOnDrag={[0, 1, 2]}\n selectionOnDrag={false}\n selectionKeyCode=\"Shift\"\n preventScrolling\n onPaneContextMenu={(event) => event.preventDefault()}\n minZoom={0.2}\n maxZoom={1.5}\n aria-label={text('canvas')}\n >\n <Background gap={16} />\n {schemas && (\n <Panel position=\"top-left\">\n <Segmented<GraphView> label={text('graphView')} value={view} onChange={setView} options={[{ value: 'pins', label: text('viewPins') }, { value: 'simple', label: text('viewSimple') }]} />\n </Panel>\n )}\n {movable && Object.keys(manual).length > 0 && (\n <Panel position=\"top-right\">\n <Button title={text('tidyUpHelp')} onClick={tidy}>\n <LayoutGrid className=\"size-3.5\" aria-hidden />\n {text('tidyUp')}\n </Button>\n </Panel>\n )}\n <Controls showInteractive={false} />\n <FitOnLayout laidOut={laidOut} tidied={tidied} />\n {fills && <KeepCentre />}\n <MeasureOnLayout laidOut={boxes} ids={nodes.map((node) => node.id)} />\n </ReactFlow>\n {pins.offer && <PureOfferMenu offer={pins.offer} onClose={pins.closeOffer} />}\n </div>\n </WireCheckContext.Provider>\n </PinActionsContext.Provider>\n </UnpinContext.Provider>\n </AddAtContext.Provider>\n )\n}\n\n/**\n * The workflow's graph on a canvas, laid out by ELK each time it changes: the trigger, a node per state, a Map's states\n * inside it, and an edge per state it leads to. With `onChange` and `edits`, dragging from a handle connects states, a click on\n * one asks `onAddAt` for a step there, Delete removes the chosen state or edge, and each change is the definition edited.\n * With `onLayoutChange`, a node dragged stays where it is let go in the view shown, Pins or Simple, each keeping its own\n * places, marked, until Unpin on it or Tidy up hands it back to ELK, which lays the others out around it.\n */\nexport const WorkflowCanvas = (props: WorkflowCanvasProps) => (\n <ReactFlowProvider>\n <Canvas {...props} />\n </ReactFlowProvider>\n)\n"],"ignoreList":[0],"mappings":"83CASA,IAAM4F,GAAa,CACjB,KAAM,MACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CACE,OACA,CACE,EAAG,6MACH,IAAK,QACP,CACF,CACF,CACF,EACAA,GAAW,KACX,IAAMC,GAAMzD,EAAiBwD,EAAU,aCfjCG,GAA+C,CACnD,eAAkBjB,EAAK,UAAU,EACjC,yBAA4BA,EAAK,mBAAmB,EACpD,yBAA4BA,EAAK,mBAAmB,EACpD,sBAAyBA,EAAK,gBAAgB,EAC9C,uBAA0BA,EAAK,iBAAiB,EAChD,oBAAuBA,EAAK,cAAc,EAC1C,wBAA2BA,EAAK,kBAAkB,EAClD,gBAAmBA,EAAK,WAAW,CACrC,EAEakB,IAAiB,EAAkB,IAAoBD,GAAeE,EAAS,GAAG,GAAKC,GAAUD,EAGjGE,IAAkB,EAAkB,IAAoB,CACnE,IAAMC,EAAQJ,GAAcC,EAAUC,CAAM,EACtCG,EAAS9C,EAAa0C,CAAQ,EACpC,OAAOI,EAASvB,EAAK,kBAAmB,CAAE,KAAMsB,EAAO,QAASC,EAAO,OAAQ,CAAC,EAAID,CACtF,EAGME,GAAwE,CAC5E,SAAYxB,EAAK,UAAU,EAC3B,WAAcA,EAAK,YAAY,EAC/B,SAAYA,EAAK,UAAU,EAC3B,QAAWA,EAAK,SAAS,EACzB,UAAaA,EAAK,WAAW,EAC7B,YAAeA,EAAK,aAAa,EACjC,SAAYA,EAAK,UAAU,CAC7B,EAEayB,GAAkB,GAAyCD,GAAgBE,EAAK,GAAG,GAAKA,EAMxFC,IAAc,EA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WAAW,cAAA,EAAa,CAAA,EAC7CsC,EAAK,QAAQ,CACR,GACH,CAAA,GAET,EAAAsE,EAAA,IAAA,CAAC/D,GAAD,CAAU,gBAAiB,EAAQ,CAAA,GACnC,EAAA+D,EAAA,IAAA,CAAC0U,GAAD,CAAsB,UAAiB,QAAS,CAAA,EAC/CyC,IAAS,EAAAnX,EAAA,IAAA,CAAC6U,GAAD,CAAa,CAAA,GACvB,EAAA7U,EAAA,IAAA,CAACiV,GAAD,CAAiB,QAAShR,EAAO,IAAK8O,GAAM,IAAK,GAAS3S,EAAK,EAAE,CAAI,CAAA,CAC5D,CACV,CAAA,EAAA0G,EAAK,QAAS,EAAA9G,EAAA,IAAA,CAACgO,GAAD,CAAe,MAAOlH,EAAK,MAAO,QAASA,EAAK,UAAa,CAAA,CACzE,GACoB,CAAA,CACD,CAAA,CACP,CAAA,CACF,CAAA,CAE3B,EASasQ,GAAkB,IAC7B,EAAApX,EAAA,IAAA,CAACnE,GAAD,CAAA,UACE,EAAAmE,EAAA,IAAA,CAACqV,GAAD,CAAQ,GAAIgC,CAAQ,CAAA,CACH,CAAA","debugId":"34e0a59c-adab-4e73-9764-93a1d8c9e5bc"}
1
+ {"version":3,"file":"workflow-canvas-NJSHRDav.js","names":["createContext","createContext","useContext","useState","_Fragment","createContext","useContext","useContext","Title","_Fragment","useState","useState","useState","useRef","useMemo","createContext","useContext","useState","useMemo","useRef","useMemo","useState","ReactFlow","n","a","t","__toESM","require_react","require_jsx_runtime","X","Button","guarded","Segmented","Input","Badge","cn","Select","createLucideIcon","Checkbox","CircleAlert","LayoutGrid","schemaAt","innerMachine","pinType","expressionSource","inputSchema","machineDependencies","readText","isConditionPart","stepStatuses","dependsOn","orderOf","allStates","taskResource","selectParts","customStepOf","conditionParts","selectValue","expressionReferences","referenceValue","parseReference","pathOfName","pathOf","withoutKey","holdsSteps","conditionPin","inputPin","inputPins","triggerOutputs","stepOutputs","placedBoxes","fieldsOf","statusPin","workflowLayoutOf","statusKey","layoutKey","conditionKey","givenSchema","text","getBezierPath","Position","ReactFlowProvider","useReactFlow","Panel","useStore","Controls","index","Handle","useKeyPress","Background","useUpdateNodeInternals","useElk","__iconData","Pin","import_react","stepTypeLabels","stepTypeLabel","resource","listed","stepTypeOption","label","custom","stateTypeLabels","stateTypeLabel","type","stateLabel","state","types","entry","waits","inputLabels","inputLabel","name","title","triggerLabels","triggerTypeLabel","triggerType","trigger","triggerLabel","nodeStatusLabels","nodeStatusLabel","status","cacheAdvice","cacheForcedAgainst","cacheSwitch","advice","part","pathPart","path","pathFrom","breakId","source","makeId","target","key","conditionId","at","selectId","inHandle","outHandle","breakIn","makeOut","conditionOut","selectOut","selectInput","inKey","handle","outPath","import_jsx_runtime","wirePlace","pure","graph","node","edge","nodePlace","later","b","lastPlaceFirst","groups","order","removal","removals","place","placeOf","each","rulesOf","catchersOf","stateEdges","scope","machine","field","rule","catcher","machineGraph","parent","parts","steps","inner","dataEdges","own","edges","kind","from","nested","fromTrigger","definitionGraph","definition","states","start","nodeSize","portId","rootOptions","dataOrderOptions","mapPadding","isGroup","elkGraph","sized","size","extras","id","ports","port","end","pureIn","elk","inside","child","edgesIn","parentOf","candidate","wire","top","laidOutBoxes","boxes","visit","laidOut","layoutElk","engine","foldHeight","padding","shownInputs","shown","open","inputs","pin","pinnedHeight","header","outputs","foldable","kindLabels","typeLabel","pinColour","outputLabels","outputLabel","inputPinLabel","conditionTitles","conditionTitle","choice","conditionNodeTitle","statusLabels","statusLabel","pureHeader","selectWidth","makeFieldsShown","pureInputs","breakOutputs","read","reads","expressionHeight","nodeSizes","sizes","data","folded","fields","rowMiddle","titleHandle","pureTop","pinPorts","pins","pureParent","near","triggerFlowId","flowId","isPureFlowId","graphId","nodePins","flowNodes","box","cacheWarning","warned","warnings","marks","warning","problems","traces","dataOrder","selected","labelLength","shortened","edgeLabel","dataOrderEdge","flowEdges","pureFlowNodes","unwiredOrderEdges","step","wired","dataFlowEdges","AddAtContext","nodeTones","PinActionsContext","usePinActions","inlineKind","others","other","numberOf","typed","NumberInput","setTyped","className","value","event","onChange","PinValue","editor","checked","option","pinClass","InputRow","actions","connectable","bare","onValue","keys","OutputRow","GroupPins","count","FoldRow","PinColumns","editable","UnpinContext","MovedMark","unpin","execTops","sourcesOf","next","caught","useAddAt","addAt","SourceHandle","Sources","ProblemCount","WarningMark","TraceMark","trace","boxClass","Title$1","first","DataSides","OnlyWhen","condition","StateNode","moved","isConnectable","TriggerNode","graphViewStorageKey","readGraphView","storage","writeGraphView","view","browserStorage","useGraphView","setView","sideName","ExpressionText","readName","PatternRow","pattern","ConditionPins","out","before","ValueInput","SelectRows","disabled","write","setCase","position","change","titleOf","Title","PureNodeView","pureData","shownOutputs","PureOfferMenu","offer","onClose","isObject","samePath","booleanType","partReads","side","readsStatus","literalType","kinds","resultVariables","found","assign","variable","dataGraph","schemas","pathOfState","breaks","makes","conditions","selects","variables","targetHandle","expression","pinOf","fielded","broken","breakOf","known","schema","made","wireValue","one","sourceOf","reference","sourceOfReference","sourceOfSide","partOf","sides","sources","into","conditionOf","selectOf","operand","makeOf","required","declared","fieldSchema","extra","local","refusalText","refusal","isPinHandle","isObjectType","conditionOffer","choices","put","localsLeft","under","gone","usePins","edits","editing","setLocal","setOpen","setOffer","now","layout","current","check","to","finish","isValid","connection","connect","remove","after","bound","nodes","cut","removed","addSelect","latest","addCondition","point","frame","WireCheckContext","WireLine","fromX","fromY","fromPosition","toX","toY","toPosition","refused","connectionStatus","toNode","toHandle","fromHandle","fromNode","useLayout","setBoxes","shape","nodeTypes","scopeOf","FitOnLayout","flow","tidied","KeepCentre","width","previous","x","MeasureOnLayout","updateNodeInternals","ids","notDragged","Canvas","changed","byId","layoutJson","whole","manual","changeView","onLayoutChange","movable","dragged","setDragged","setTidied","chosen","setChosen","pinned","chosenEdge","setChosenEdge","isValidConnection","drop","placed","positions","tidy","onNodesChange","dropped","changes","only","shiftHeld","boxing","onSelect","onAddAt","fills","WorkflowCanvas","props"],"sources":["../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/pin.mjs","../../../src/app/field-types/workflow/labels.ts","../../../src/app/field-types/workflow/cache-advice.ts","../../../src/app/field-types/workflow/pins/pure-ids.ts","../../../src/app/field-types/workflow/pins/removal-order.ts","../../../src/app/field-types/workflow/definition-graph.ts","../../../src/app/field-types/workflow/graph-layout.ts","../../../src/app/field-types/workflow/pins/pin-layout.ts","../../../src/app/field-types/workflow/pins/pin-text.ts","../../../src/app/field-types/workflow/pins/node-sizes.ts","../../../src/app/field-types/workflow/pins/pure-parents.ts","../../../src/app/field-types/workflow/flow-elements.ts","../../../src/app/field-types/workflow/add-at-context.ts","../../../src/app/field-types/workflow/node-trace.ts","../../../src/app/field-types/workflow/pins/pin-actions.ts","../../../src/app/field-types/workflow/pins/pin-value.tsx","../../../src/app/field-types/workflow/pins/pin-rows.tsx","../../../src/app/field-types/workflow/unpin-context.ts","../../../src/app/field-types/workflow/moved-mark.tsx","../../../src/app/field-types/workflow/flow-nodes.tsx","../../../src/app/field-types/workflow/pins/graph-view.ts","../../../src/app/field-types/workflow/pins/condition-nodes.tsx","../../../src/app/field-types/workflow/pins/select-node.tsx","../../../src/app/field-types/workflow/pins/pure-nodes.tsx","../../../src/app/field-types/workflow/pins/pure-offer.tsx","../../../src/app/field-types/workflow/pins/data-graph.ts","../../../src/app/field-types/workflow/pins/refusal-text.ts","../../../src/app/field-types/workflow/pins/use-pins.ts","../../../src/app/field-types/workflow/pins/wire-line.tsx","../../../src/app/field-types/workflow/use-layout.ts","../../../src/app/field-types/workflow/workflow-canvas.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"pin\",\n size: 24,\n node: [\n [\"path\", { d: \"M12 17v5\", key: \"bb1du9\" }],\n [\n \"path\",\n {\n d: \"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z\",\n key: \"1nkz8b\"\n }\n ]\n ]\n};\n__iconData.node;\nconst Pin = createLucideIcon(__iconData);\n\nexport { __iconData, Pin as default };\n//# sourceMappingURL=pin.mjs.map\n","import type { WorkflowTypeList } from '@protobase/client'\nimport { customStepOf, taskResource, type State, type Trigger } from '@protobase/workflows'\nimport type { NodeStatus } from './node-trace'\nimport { text } from './messages'\n\n/**\n * The built-in step types' names, by the `Resource` a Task names; another shows the label the type list gives it,\n * `listed`, or, without one, as it is written.\n */\nconst stepTypeLabels: Record<string, () => string> = {\n 'app:http': () => text('stepHttp'),\n 'app:records.create': () => text('stepRecordsCreate'),\n 'app:records.update': () => text('stepRecordsUpdate'),\n 'app:records.get': () => text('stepRecordsGet'),\n 'app:records.list': () => text('stepRecordsList'),\n 'app:mail.send': () => text('stepMailSend'),\n 'app:mail.template': () => text('stepMailTemplate'),\n 'app:piece': () => text('stepPiece'),\n}\n\nexport const stepTypeLabel = (resource: string, listed?: string) => stepTypeLabels[resource]?.() ?? listed ?? resource\n\n/** A step type as a list to choose from names it: a custom step's version beside its label, as each version is a type of its own. */\nexport const stepTypeOption = (resource: string, listed?: string) => {\n const label = stepTypeLabel(resource, listed)\n const custom = customStepOf(resource)\n return custom ? text('stepTypeVersion', { type: label, version: custom.version }) : label\n}\n\n/** The states' types other than Task, which shows its step type's name. */\nconst stateTypeLabels: Record<Exclude<State['Type'], 'Task'>, () => string> = {\n Pass: () => text('typePass'),\n Choice: () => text('typeChoice'),\n Wait: () => text('typeWait'),\n Map: () => text('typeMap'),\n Block: () => text('typeBlock'),\n Succeed: () => text('typeSucceed'),\n Fail: () => text('typeFail'),\n}\n\nexport const stateTypeLabel = (type: Exclude<State['Type'], 'Task'>) => stateTypeLabels[type]?.() ?? type\n\n/**\n * What a state is, as its node and panel name it: its step type for a Task, by the label `types` lists, saying so when\n * it then waits for an outside result; else its type.\n */\nexport const stateLabel = (state: State, types?: WorkflowTypeList) => {\n if (state.Type !== 'Task') return stateTypeLabel(state.Type)\n const { type, waits } = taskResource(String(state.Resource))\n const label = stepTypeLabel(type, types?.step_types.find((entry) => entry.id === type)?.label)\n return waits ? text('stepTypeWaits', { type: label }) : label\n}\n\n/**\n * The arguments' and fields' names in the forms, by their name in the definition; another shows the title its schema\n * gives it, or, without one, as it is written.\n */\nconst inputLabels: Record<string, () => string> = {\n url: () => text('inputUrl'),\n method: () => text('inputMethod'),\n headers: () => text('inputHeaders'),\n query: () => text('inputQuery'),\n body: () => text('inputBody'),\n response: () => text('inputResponse'),\n resource: () => text('inputResource'),\n data: () => text('inputData'),\n key: () => text('inputKey'),\n filter: () => text('inputFilter'),\n order_by: () => text('inputOrderBy'),\n limit: () => text('inputLimit'),\n to: () => text('inputTo'),\n subject: () => text('inputSubject'),\n text: () => text('inputText'),\n html: () => text('inputHtml'),\n attachments: () => text('inputAttachments'),\n piece: () => text('inputPiece'),\n action: () => text('inputAction'),\n connection: () => text('inputConnection'),\n props: () => text('inputProps'),\n when: () => text('inputWhen'),\n body_schema: () => text('inputBodySchema'),\n}\n\nexport const inputLabel = (name: string, title?: string) => inputLabels[name]?.() ?? title ?? name\n\n/** The built-in triggers' names; another shows the label the type list gives it, `listed`, or as it is written. */\nconst triggerLabels: Record<string, () => string> = {\n manual: () => text('triggerManual'),\n 'app:record': () => text('triggerRecord'),\n}\n\nexport const triggerTypeLabel = (type: string, listed?: string) => triggerLabels[type]?.() ?? listed ?? type\n\n/** The type a trigger names: the one key it holds. */\nexport const triggerType = (trigger: Trigger | undefined): string | undefined => Object.keys(trigger ?? {})[0]\n\n/** The trigger's label: its type's, by the label `types` lists, or a prompt to choose one when it has none. */\nexport const triggerLabel = (trigger: Trigger | undefined, types?: WorkflowTypeList) => {\n const type = triggerType(trigger)\n return type === undefined ? text('triggerUnknown') : triggerTypeLabel(type, types?.triggers.find((entry) => entry.id === type)?.label)\n}\n\nconst nodeStatusLabels: Record<NodeStatus, () => string> = {\n succeeded: () => text('traceSucceeded'),\n caught: () => text('traceCaught'),\n retrying: () => text('traceRetrying'),\n failed: () => text('traceFailed'),\n current: () => text('traceCurrent'),\n}\n\n/** How a state did in a run, as its node's mark says it. */\nexport const nodeStatusLabel = (status: NodeStatus) => nodeStatusLabels[status]()\n","import type { WorkflowTypeList } from '@protobase/client'\nimport { taskResource, type State, type TaskState } from '@protobase/workflows'\n\n/** The cache advice the type list gives a Task's step type; none for a type that offers no cache. */\nexport const cacheAdvice = (state: TaskState, types: WorkflowTypeList | undefined) => types?.step_types.find((type) => type.id === taskResource(state.Resource).type)?.cache\n\n/** Whether a workflow forced the cache on for a step whose type advises against it, which its node marks. */\nexport const cacheForcedAgainst = (state: State, types: WorkflowTypeList | undefined) => state.Type === 'Task' && state.Cache === true && cacheAdvice(state, types)?.choice === 'discouraged'\n\n/**\n * The Task form's cache switch, for every type but one whose cache is `hidden`, a type without a cache included, which\n * a workflow may still force on. A `switch` type's is on as the Task says, else as its default, and off sets `Cache`\n * false; any other's is on only while the Task forces it, and off leaves the type to decide (`Cache` unset).\n */\nexport const cacheSwitch = (state: TaskState, types: WorkflowTypeList | undefined) => {\n const advice = cacheAdvice(state, types)\n if (advice?.choice === 'hidden') return\n if (advice?.choice === 'switch') return { on: state.Cache ?? advice.default === true, forces: false, offValue: false as const, disclaimer: undefined }\n return { on: state.Cache === true, forces: true, offValue: undefined, disclaimer: advice?.choice === 'discouraged' ? advice.disclaimer : undefined }\n}\n","// React Flow finds nodes and handles by CSS selectors it builds from their ids unescaped, so ids hold no quotes:\n// each name in them is URI-encoded, and a path is its names each after a `/`.\nconst part = (name: string) => encodeURIComponent(name)\nconst pathPart = (path: readonly string[]) => path.map((name) => `/${part(name)}`).join('')\nconst pathFrom = (text: string) => (text === '' ? [] : text.split('/').slice(1).map(decodeURIComponent))\n\n/** A Break node's id: the node whose value it takes apart, and where that value is in what the node gives. */\nexport const breakId = (source: string, path: readonly string[]) => `break:${part(source)}|${pathPart(path)}`\n\n/** A Make node's id: the step whose argument it builds, and the argument. */\nexport const makeId = (target: string, key: string) => `make:${part(target)}|${part(key)}`\n\n/** A condition node's id: the step whose Condition it is part of, and where it is among the Condition's nodes. */\nexport const conditionId = (target: string, at: readonly number[]) => `when:${part(target)}|${at.join('/')}`\n\n/** A Select node's id: the step whose argument it chooses, and the argument. */\nexport const selectId = (target: string, key: string) => `select:${part(target)}|${part(key)}`\n\n/** Whether a node id is a Break's, a Make's, a condition node's or a Select's, which the editor draws and the document holds no state for. */\nexport const isPureId = (id: string) => id.startsWith('break:') || id.startsWith('make:') || id.startsWith('when:') || id.startsWith('select:')\n\n/** The handle of an input pin, by its argument or field. */\nexport const inHandle = (key: string) => `in:${part(key)}`\n\n/** The handle of an output pin, by where its value is in what the node gives. */\nexport const outHandle = (path: readonly string[]) => `out:${pathPart(path)}`\n\n/** The handle a Break takes its object at, and the one a Make gives its object from. */\nexport const breakIn = 'break-in'\nexport const makeOut = 'make-out'\n\n/** The handle a condition node gives its yes or no from. */\nexport const conditionOut = 'condition-out'\n\n/** The handle a Select gives the value it chose from, and the key of the input it looks at. */\nexport const selectOut = 'select-out'\nexport const selectInput = 'value'\n\n/** An input handle's argument or field; undefined for any other handle. */\nexport const inKey = (handle: string | null | undefined) => (handle?.startsWith('in:') ? decodeURIComponent(handle.slice(3)) : undefined)\n\n/** An output handle's path; undefined for any other handle. */\nexport const outPath = (handle: string | null | undefined): string[] | undefined => (handle?.startsWith('out:') ? pathFrom(handle.slice(4)) : undefined)\n","import type { DataEdge, DataGraph, PureNode } from './data-graph'\nimport { inKey } from './pure-ids'\n\n/**\n * Where among a step's Condition's nodes a removal takes an input away: a wire into a condition node's input, by the\n * node's place and the input; undefined for any other wire.\n */\nexport const wirePlace = (graph: DataGraph, edge: Pick<DataEdge, 'target' | 'targetHandle'>) => {\n const pure = graph.pure.find((node) => node.id === edge.target)\n const key = inKey(edge.targetHandle)\n return pure?.kind === 'condition' && key !== undefined ? { step: pure.target, at: [...pure.at, Number(key)] } : undefined\n}\n\n/** Where a condition node's removal takes its input away among its step's Condition's nodes; undefined for any other node. */\nexport const nodePlace = (node: PureNode) => (node.kind === 'condition' ? { step: node.target, at: node.at } : undefined)\n\n// Whether `a` comes after `b` among a Condition's nodes, by the inputs on the way to it\nconst later = (a: readonly number[], b: readonly number[]): number => {\n for (let index = 0; index < Math.min(a.length, b.length); index++) if (a[index] !== b[index]) return a[index]! - b[index]!\n return a.length - b.length\n}\n\n/**\n * Removals in the order that keeps each one's place: an All of or an Any of that loses an input moves the inputs after\n * it up, so the removals in one step's Condition go together, the last place first, each place as the graph drawn\n * before them all names it. The steps keep the order their first removal came in, and every other removal its own.\n */\nexport const lastPlaceFirst = <T>(_graph: DataGraph, removals: readonly T[], placeOf: (removal: T) => { step: string; at: number[] } | undefined): T[] => {\n const groups = new Map<string, { removal: T; at: number[] }[]>()\n const order: (T | string)[] = []\n for (const removal of removals) {\n const place = placeOf(removal)\n if (!place) {\n order.push(removal)\n continue\n }\n const key = `step:${place.step}`\n if (!groups.has(key)) {\n groups.set(key, [])\n order.push(key)\n }\n groups.get(key)!.push({ removal, at: place.at })\n }\n return order.flatMap((each) => (typeof each === 'string' && groups.has(each) ? groups.get(each)!.toSorted((a, b) => later(b.at, a.at)).map(({ removal }) => removal) : [each as T]))\n}\n","import { dependsOn, innerMachine, machineDependencies, orderOf, type Definition, type Machine, type State, type Trigger } from '@protobase/workflows'\nimport { pathOf, triggerId, type StatePath } from './definition'\n\n/**\n * Where an edge leaves its node, and so what it sets when drawn: `next` a state's Next, `rule` a Choice rule's Next,\n * `default` a Choice's Default, `catch` a catcher's Next, `start` the StartAt of the machine the trigger starts. In data\n * order an edge is drawn from what a state reads instead: `reads`, some of its variables, or `status`, its status\n * alone; and `start` from the trigger to each state that reads from no other.\n */\nexport type EdgeKind = 'next' | 'rule' | 'default' | 'catch' | 'start' | 'reads' | 'status'\n\nexport type GraphNode =\n | { kind: 'trigger'; id: typeof triggerId; trigger: Trigger }\n /** `parent` is the path of the Map or Block whose steps it is one of, `first` whether its machine starts at it. */\n | { kind: 'state'; id: StatePath; name: string; state: State; scope: string[]; parent?: StatePath; first: boolean }\n\n/** An edge, by the field of its source state that names its target (`Next`, `Choices[0].Next`, `Catch[1].Next`). */\nexport type GraphEdge = { id: string; kind: EdgeKind; source: string; target: StatePath; field: string; label?: string }\n\nexport type Graph = { nodes: GraphNode[]; edges: GraphEdge[] }\n\nconst rulesOf = (state: State) => (state.Type === 'Choice' && Array.isArray(state.Choices) ? state.Choices : [])\nconst catchersOf = (state: State) => ('Catch' in state && Array.isArray(state.Catch) ? state.Catch : [])\n\n// The edges a state names, each to a state of its own machine; one naming no state there is left out, and the\n// definition check names it on the state.\nconst stateEdges = (machine: Machine, scope: string[], name: string, state: State): GraphEdge[] => {\n const source = pathOf(scope, name)\n const edge = (kind: EdgeKind, field: string, target: string, label?: string): GraphEdge[] =>\n Object.hasOwn(machine.States, target) ? [{ id: `${source}\\n${field}`, kind, source, target: pathOf(scope, target), field, ...(label !== undefined && { label }) }] : []\n return [\n ...('Next' in state && typeof state.Next === 'string' ? edge('next', 'Next', state.Next) : []),\n ...rulesOf(state).flatMap((rule, index) => edge('rule', `Choices[${index}].Next`, rule.Next, rule.Condition)),\n ...(state.Type === 'Choice' && typeof state.Default === 'string' ? edge('default', 'Default', state.Default) : []),\n ...catchersOf(state).flatMap((catcher, index) => (catcher.Next === undefined ? [] : edge('catch', `Catch[${index}].Next`, catcher.Next, Array.isArray(catcher.ErrorEquals) ? catcher.ErrorEquals.join(', ') : undefined))),\n ]\n}\n\nconst machineGraph = (machine: Machine, scope: string[]): Graph => {\n const parent = scope.length > 0 ? scope.join('/') : undefined\n const parts = Object.entries(machine.States).map(([name, state]): Graph => {\n const node: GraphNode = { kind: 'state', id: pathOf(scope, name), name, state, scope, ...(parent !== undefined && { parent }), first: machine.StartAt === name }\n const steps = innerMachine(state)\n const inner = steps?.States ? machineGraph(steps, [...scope, name]) : { nodes: [], edges: [] }\n return { nodes: [node, ...inner.nodes], edges: [...stateEdges(machine, scope, name, state), ...inner.edges] }\n })\n return { nodes: parts.flatMap((part) => part.nodes), edges: parts.flatMap((part) => part.edges) }\n}\n\n// In data order, an edge from each state to each one that reads from it: its variables, or only its status, which runs\n// after it all the same; and from the trigger to each state that reads from none.\nconst dataEdges = (machine: Machine, scope: string[], fromTrigger: boolean): GraphEdge[] => {\n const dependencies = machineDependencies(machine)\n return [...dependencies].flatMap(([name, own]): GraphEdge[] => {\n const target = pathOf(scope, name)\n const edges = [...dependsOn(own)].map((from): GraphEdge => {\n const kind = own.data.has(from) ? 'reads' : 'status'\n return { id: `${pathOf(scope, from)}\\n${kind}\\n${target}`, kind, source: pathOf(scope, from), target, field: kind }\n })\n const inner = innerMachine(machine.States[name])\n const nested = inner?.States ? dataEdges(inner, [...scope, name], false) : []\n const root: GraphEdge[] = fromTrigger && edges.length === 0 ? [{ id: `\\nStart\\n${target}`, kind: 'start', source: triggerId, target, field: 'StartAt' }] : []\n return [...root, ...edges, ...nested]\n })\n}\n\n/**\n * The definition as a graph: the trigger, each state a node in the order the definition lists them, a Map's or a\n * Block's states inside it, and an edge for each state a state names. A Map or Block comes before the states inside it. The definition holds\n * no positions; the layout places the nodes.\n */\nexport const definitionGraph = (definition: Definition): Graph => {\n const machine = definition.stateMachine\n const states = machineGraph(machine, [])\n if (orderOf(definition) === 'data') return { nodes: [{ kind: 'trigger', id: triggerId, trigger: definition.trigger }, ...states.nodes.map((node) => (node.kind === 'state' ? { ...node, first: false } : node))], edges: dataEdges(machine, [], true) }\n const start: GraphEdge[] = machine.StartAt !== undefined && Object.hasOwn(machine.States, machine.StartAt) ? [{ id: '\\nStartAt', kind: 'start', source: triggerId, target: machine.StartAt, field: 'StartAt' }] : []\n return { nodes: [{ kind: 'trigger', id: triggerId, trigger: definition.trigger }, ...states.nodes], edges: [...start, ...states.edges] }\n}\n","import type { ElkNode } from 'elkjs/lib/elk-api'\nimport type { Graph, GraphNode } from './definition-graph'\nimport { holdsSteps } from './definition'\n\n/** A node's box: where its top left corner is, within the Map or Block it is inside or else the canvas, and its size. */\nexport type Box = { x: number; y: number; width: number; height: number }\n\n/** What lays a graph out: ELK's `layout`, in a worker in the browser. */\nexport type LayoutEngine = { layout: (graph: ElkNode) => Promise<ElkNode> }\n\n/** The size of a node the layout is given no size for: the layout places nodes, it does not size them. */\nexport const nodeSize = { width: 224, height: 64 }\n\n/**\n * What the layout places besides the graph: each node's size by its id, the Break, Make, condition and Select nodes\n * with the Map or Block each is inside, the wires between pins, which pull the nodes they join into order as edges do,\n * and where each node's pins are, so the wires meet their nodes where they are drawn and cross as little as they can.\n */\nexport type LayoutExtras = {\n sizes?: ReadonlyMap<string, { width: number; height: number }>\n pure?: readonly { id: string; parent?: string }[]\n wires?: readonly { id: string; source: string; target: string; sourceHandle?: string; targetHandle?: string }[]\n ports?: ReadonlyMap<string, readonly { handle: string; side: 'in' | 'out'; y: number }[]>\n /** The workflow runs in data order, where nodes go beside what reads them. */\n dataOrder?: boolean\n}\n\n// A pin's port on its node, as ELK names it\nconst portId = (node: string, handle: string) => `${node}\\u0000${handle}`\n\n// ELK's layered algorithm from left to right, as execution runs in Blueprints, laying out each Map's or Block's states\n// inside it, with room for its title on top.\nconst rootOptions = {\n 'elk.algorithm': 'layered',\n 'elk.direction': 'RIGHT',\n 'elk.hierarchyHandling': 'INCLUDE_CHILDREN',\n 'elk.layered.spacing.nodeNodeBetweenLayers': '72',\n 'elk.spacing.nodeNode': '32',\n 'elk.edgeLabels.inline': 'false',\n}\n\n// In data order, each node in the layer just before what reads it, so a Break, a condition node or a Select stands\n// beside its reader and a step beside the steps that read it. In sequence order, where states that end the run would\n// all go to the last layer, ELK balances the layers instead.\nconst dataOrderOptions = { 'elk.layered.layering.strategy': 'LONGEST_PATH' }\nconst mapPadding = { 'elk.padding': '[top=48,left=24,bottom=24,right=24]' }\n\nconst isGroup = (node: GraphNode) => node.kind === 'state' && holdsSteps(node.state)\n\n/**\n * The graph as ELK's: each node a box of `nodeSize`, a Map or Block a box around the nodes inside it, which ELK sizes,\n * and each edge inside the Map or Block its two ends are in. Edge labels are left out: the canvas draws them on the edge's middle.\n */\nexport const elkGraph = (graph: Graph, extras: LayoutExtras = {}): ElkNode => {\n // A node with its pins as ports where they are drawn, which ELK keeps in place as it orders the nodes of each layer\n const sized = (id: string): ElkNode => {\n const size = extras.sizes?.get(id) ?? nodeSize\n const ports = extras.ports?.get(id)\n if (!ports?.length) return { id, ...size }\n return {\n id,\n ...size,\n layoutOptions: { 'elk.portConstraints': 'FIXED_POS' },\n ports: ports.map((port) => ({ id: portId(id, port.handle), x: port.side === 'in' ? 0 : size.width, y: port.y, width: 0, height: 0, layoutOptions: { 'elk.port.side': port.side === 'in' ? 'WEST' : 'EAST' } })),\n }\n }\n // A wire's end: its pin's port where the node has one, else the node\n const end = (node: string, handle: string | undefined) => (handle !== undefined && extras.ports?.get(node)?.some((port) => port.handle === handle) ? portId(node, handle) : node)\n const pureIn = (parent: string | undefined) => (extras.pure ?? []).filter((pure) => pure.parent === parent).map((pure) => sized(pure.id))\n const elk = (node: GraphNode): ElkNode => {\n if (!isGroup(node)) return sized(node.id)\n const inside = graph.nodes.filter((child) => child.kind === 'state' && child.parent === node.id)\n return { id: node.id, layoutOptions: mapPadding, children: [...inside.map(elk), ...pureIn(node.id)], edges: edgesIn(node.id) }\n }\n const parentOf = (id: string) => {\n const pure = extras.pure?.find((candidate) => candidate.id === id)\n if (pure) return pure.parent\n const node = graph.nodes.find((candidate) => candidate.id === id)\n return node?.kind === 'state' ? node.parent : undefined\n }\n // A wire joins two nodes of one machine; one into or out of a Map is drawn but not laid out by\n const edgesIn = (parent: string | undefined) => [\n ...graph.edges.filter((edge) => parentOf(edge.target) === parent).map((edge) => ({ id: edge.id, sources: [edge.source], targets: [edge.target] })),\n ...(extras.wires ?? [])\n .filter((wire) => parentOf(wire.target) === parent && parentOf(wire.source) === parent)\n .map((wire) => ({ id: wire.id, sources: [end(wire.source, wire.sourceHandle)], targets: [end(wire.target, wire.targetHandle)] })),\n ]\n const top = graph.nodes.filter((node) => node.kind === 'trigger' || node.parent === undefined)\n return { id: 'root', layoutOptions: extras.dataOrder ? { ...rootOptions, ...dataOrderOptions } : rootOptions, children: [...top.map(elk), ...pureIn(undefined)], edges: edgesIn(undefined) }\n}\n\n/** Each node's box from ELK's laid out graph, by node id; a node inside a Map or Block is placed within it. */\nexport const laidOutBoxes = (laidOut: ElkNode): Map<string, Box> => {\n const boxes = new Map<string, Box>()\n const visit = (node: ElkNode) => {\n for (const child of node.children ?? []) {\n boxes.set(child.id, { x: child.x ?? 0, y: child.y ?? 0, width: child.width ?? nodeSize.width, height: child.height ?? nodeSize.height })\n visit(child)\n }\n }\n visit(laidOut)\n return boxes\n}\n\n/** The graph `elk` describes laid out by `engine`: each node's box. */\nexport const layoutElk = async (engine: LayoutEngine, elk: ElkNode) => laidOutBoxes(await engine.layout(elk))\n\n/** The graph laid out by `engine`: each node's box. */\nexport const layoutGraph = (engine: LayoutEngine, graph: Graph, extras?: LayoutExtras) => layoutElk(engine, elkGraph(graph, extras))\n","import type { InputPin, OutputPin } from './node-pins'\n\n/** A node's header, holding its type and name with the execution handles beside it, and each pin's row. */\nexport const headerHeight = 52\nexport const rowHeight = 26\nconst foldHeight = 24\nconst padding = 8\n\n/** The width of a step's or the trigger's node, and of a Break's or a Make's. */\nexport const stepWidth = 296\nexport const pureWidth = 216\n\n/** The height of an Expression's text, which scrolls inside past it. */\nexport const expressionTextHeight = 64\n\n/**\n * The inputs a node shows: the ones its type needs and the ones that hold something, all of them once it is opened,\n * so a node stays small; with how many it folds away.\n */\nexport const shownInputs = (inputs: readonly InputPin[], open: boolean): { shown: InputPin[]; folded: number } => {\n const shown = open ? [...inputs] : inputs.filter((pin) => pin.required || pin.state !== 'empty')\n return { shown, folded: inputs.length - shown.length }\n}\n\n/** A node's height: its header, then a row per pin on the side with more, and the row that folds its optional inputs. */\nexport const pinnedHeight = (inputs: number, outputs: readonly OutputPin[] | number, foldable: boolean, header = headerHeight) => {\n const rows = Math.max(inputs, typeof outputs === 'number' ? outputs : outputs.length)\n return header + rows * rowHeight + (foldable ? foldHeight : 0) + padding\n}\n","import type { PinKind, PinType } from '@protobase/workflows'\nimport { inputLabel } from '../labels'\nimport { text } from '../messages'\nimport type { ConditionChoice } from './condition-edits'\nimport type { ConditionNode } from './data-graph'\nimport { conditionKey, statusKey } from './node-pins'\n\nconst kindLabels: Record<PinKind | 'any', () => string> = {\n string: () => text('typeString'),\n integer: () => text('typeInteger'),\n number: () => text('typeNumber'),\n boolean: () => text('typeBoolean'),\n object: () => text('typeObject'),\n array: () => text('typeArray'),\n null: () => text('typeNull'),\n any: () => text('typeAny'),\n}\n\n/** A pin's type in words: its title, such as Contact, or what it can be, such as Text or Whole number. */\nexport const typeLabel = (type: PinType) => {\n if (type.title !== undefined) return type.title\n if (type.kinds === 'any') return kindLabels.any()\n return type.kinds.map((kind) => kindLabels[kind]()).reduce((first, second) => text('typeOr', { first, second }))\n}\n\n/** The kind a pin is coloured by: its first, or any. */\nexport const pinColour = (type: PinType) => (type.kinds === 'any' ? 'any' : type.kinds[0]!)\n\nconst outputLabels: Record<string, () => string> = {\n status: () => text('outputStatus'),\n headers: () => text('outputHeaders'),\n body: () => text('outputBody'),\n record: () => text('outputRecord'),\n resource: () => text('outputResource'),\n key: () => text('outputKey'),\n records: () => text('outputRecords'),\n message_id: () => text('outputMessageId'),\n}\n\n/**\n * An output pin's name: the whole of what a node gives, a value a built-in type returns by its label, else the\n * field's name, as a Break names each field of an object, such as a record's.\n */\nexport const outputLabel = (path: readonly string[], trigger = false, field = false) => {\n if (path.length === 0) return trigger ? text('pinRunInput') : text('pinResult')\n if (path.length === 1 && path[0] === statusKey) return text('stepStatusType')\n const name = path.at(-1)!\n // Only a label of its own: a field named as an object's member, such as __proto__, is shown by its name\n return field || !Object.hasOwn(outputLabels, name) ? name : outputLabels[name]!()\n}\n\n/** An input pin's name: a built-in argument by its label, else its name. */\nexport const inputPinLabel = (key: string) => (key === conditionKey ? text('onlyWhen') : inputLabel(key))\n\nconst conditionTitles: Record<ConditionChoice, () => string> = {\n '=': () => text('conditionEquals'),\n '!=': () => text('conditionNotEquals'),\n '>': () => text('conditionGreater'),\n '<': () => text('conditionLess'),\n matches: () => text('conditionMatches'),\n and: () => text('conditionAnd'),\n or: () => text('conditionOr'),\n not: () => text('conditionNot'),\n expression: () => text('conditionExpression'),\n}\n\n/** A condition node's name, as the canvas offers it and titles it: Equals, Not equals, Greater, Less, Matches, All of, Any of, Not or Expression. */\nexport const conditionTitle = (choice: ConditionChoice) => conditionTitles[choice]()\n\n/** The title of a condition node on the canvas. */\nexport const conditionNodeTitle = ({ part }: ConditionNode) => conditionTitle(part.kind === 'compare' || part.kind === 'logic' ? part.op : part.kind)\n\nconst statusLabels: Record<string, () => string> = {\n SUCCEEDED: () => text('statusSucceeded'),\n FAILED: () => text('statusFailed'),\n TIMED_OUT: () => text('statusTimedOut'),\n ABORTED: () => text('statusAborted'),\n SKIPPED: () => text('statusSkipped'),\n}\n\n/** What a step's status is, in words: Succeeded for `SUCCEEDED`; any other as it is. */\nexport const statusLabel = (status: string) => (Object.hasOwn(statusLabels, status) ? statusLabels[status]!() : status)\n","import type { Graph } from '../definition-graph'\nimport { holdsSteps } from '../definition'\nimport type { BreakNode, DataEdge, DataGraph, PureNode } from './data-graph'\nimport type { InputPin, OutputPin } from './node-pins'\nimport { breakIn, conditionOut, inHandle, makeOut, outHandle, selectOut } from './pure-ids'\nimport { expressionTextHeight, headerHeight, pinnedHeight, pureWidth, rowHeight, shownInputs, stepWidth } from './pin-layout'\n\n/** A node's size, as the layout places it. */\nexport type Size = { width: number; height: number }\n\n// A Break's or a Make's title is one line\nconst pureHeader = 34\n\n// A Select's cases each hold two values side by side\nconst selectWidth = 280\n\n// A Make shows every field it builds, as Blueprints draw one, unless it has more than this\nconst makeFieldsShown = 8\n\n/** The inputs a Make shows and how many it folds away, a condition node all of its own; a Break takes no inputs of its own. */\nexport const pureInputs = (pure: PureNode, open: boolean): { shown: InputPin[]; folded: number } => {\n if (pure.kind === 'condition') return { shown: pure.inputs, folded: 0 }\n return pure.kind === 'make' ? shownInputs(pure.inputs, open || pure.inputs.length <= makeFieldsShown) : { shown: [], folded: 0 }\n}\n\n/**\n * The fields a Break shows: those something reads, through a wire or an expression, all of them once it is opened or\n * while nothing reads any; with how many it folds away, and whether it has a row to fold or open them.\n */\nexport const breakOutputs = (pure: BreakNode, edges: readonly DataEdge[], open: boolean): { shown: OutputPin[]; folded: number; foldable: boolean } => {\n const read = new Set(edges.filter((edge) => edge.source === pure.id).map((edge) => edge.sourceHandle))\n const reads = pure.outputs.filter((pin) => read.has(outHandle(pin.path)))\n const foldable = reads.length > 0 && reads.length < pure.outputs.length\n if (open || !foldable) return { shown: pure.outputs, folded: 0, foldable }\n return { shown: reads, folded: pure.outputs.length - reads.length, foldable }\n}\n\n// An Expression's text above the values it reads, and the space between them\nconst expressionHeight = (reads: number) => pureHeader + 4 + expressionTextHeight + 4 + reads * rowHeight + 8\n\n/**\n * Every node's size by its id: a step's or the trigger's by the pins it shows, a Break's or a Make's too; a Map or a\n * Block is left out, as the layout sizes it around the states inside it.\n */\nexport const nodeSizes = (graph: Graph, data: DataGraph, open: ReadonlySet<string>): Map<string, Size> => {\n const sizes = new Map<string, Size>()\n for (const node of graph.nodes) {\n if (node.kind === 'state' && holdsSteps(node.state)) continue\n const { shown, folded } = shownInputs(data.inputs.get(node.id) ?? [], open.has(node.id))\n sizes.set(node.id, { width: stepWidth, height: pinnedHeight(shown.length, data.outputs.get(node.id) ?? [], folded > 0 || open.has(node.id)) })\n }\n for (const pure of data.pure) {\n if (pure.kind === 'condition' && pure.part.kind === 'expression') {\n sizes.set(pure.id, { width: pureWidth, height: expressionHeight(pure.inputs.length) })\n continue\n }\n // A Select: the value it looks at, a row per case, what it gives otherwise, and the row that adds a case\n if (pure.kind === 'select') {\n sizes.set(pure.id, { width: selectWidth, height: pinnedHeight(pure.part.cases.length + 3, 1, false, pureHeader) })\n continue\n }\n if (pure.kind === 'break') {\n const fields = breakOutputs(pure, data.edges, open.has(pure.id))\n sizes.set(pure.id, { width: pureWidth, height: pinnedHeight(0, fields.shown.length, fields.foldable, pureHeader) })\n continue\n }\n const { shown, folded } = pureInputs(pure, open.has(pure.id))\n sizes.set(pure.id, { width: pureWidth, height: pinnedHeight(shown.length, 1, pure.kind === 'make' && (folded > 0 || open.has(pure.id)), pureHeader) })\n }\n return sizes\n}\n\n/** Where a pin's dot is on its node, for the layout: its handle, the side it is on, and how far down it is. */\nexport type PinPort = { handle: string; side: 'in' | 'out'; y: number }\n\n// A row's middle, below a header and the rows before it\nconst rowMiddle = (top: number, index: number) => top + index * rowHeight + rowHeight / 2\n\n// The handle a pure node gives its value from, or takes its object at, beside its title\nconst titleHandle = 13\n\n// The rows of a pure node start below its title, after the room its first row leaves above it\nconst pureTop = pureHeader + 4\n\n/**\n * Where each node's pins are, by its id, as the canvas draws them, so the layout orders nodes by where their wires\n * meet them: a step's and the trigger's inputs and outputs in their rows below the header, a Break's object beside its\n * title and its fields shown below, and a Make's, a condition node's or a Select's value beside its title and its\n * inputs below. A Map's or a Block's pins sit on its header's edge, which the layout lets it place.\n */\nexport const pinPorts = (graph: Graph, data: DataGraph, open: ReadonlySet<string>): Map<string, PinPort[]> => {\n const ports = new Map<string, PinPort[]>()\n for (const node of graph.nodes) {\n if (node.kind === 'state' && holdsSteps(node.state)) continue\n const { shown } = shownInputs(data.inputs.get(node.id) ?? [], open.has(node.id))\n ports.set(node.id, [\n ...shown.map((pin, index): PinPort => ({ handle: inHandle(pin.key), side: 'in', y: rowMiddle(headerHeight, index) })),\n ...(data.outputs.get(node.id) ?? []).map((pin, index): PinPort => ({ handle: outHandle(pin.path), side: 'out', y: rowMiddle(headerHeight, index) })),\n ])\n }\n for (const pure of data.pure) {\n const inputs = (pins: readonly InputPin[], top = pureTop) => pins.map((pin, index): PinPort => ({ handle: inHandle(pin.key), side: 'in', y: rowMiddle(top, index) }))\n if (pure.kind === 'break') {\n const { shown } = breakOutputs(pure, data.edges, open.has(pure.id))\n ports.set(pure.id, [{ handle: breakIn, side: 'in', y: titleHandle }, ...shown.map((pin, index): PinPort => ({ handle: outHandle(pin.path), side: 'out', y: rowMiddle(pureTop, index) }))])\n } else if (pure.kind === 'make') {\n ports.set(pure.id, [{ handle: makeOut, side: 'out', y: titleHandle }, ...inputs(pureInputs(pure, open.has(pure.id)).shown)])\n } else if (pure.kind === 'select') {\n ports.set(pure.id, [{ handle: selectOut, side: 'out', y: titleHandle }, ...inputs(pure.inputs)])\n } else {\n const top = pure.part.kind === 'expression' ? pureTop + expressionTextHeight + 4 : pureTop\n ports.set(pure.id, [{ handle: conditionOut, side: 'out', y: titleHandle }, ...inputs(pure.inputs, top)])\n }\n }\n return ports\n}\n","import type { Graph } from '../definition-graph'\nimport type { PureNode } from './data-graph'\n\n/**\n * The Map or Block a Break, a Make or a condition node is inside: the one around the node whose value it breaks, or the\n * step it makes an argument or a Condition of.\n */\nexport const pureParent = (graph: Graph, pure: PureNode) => {\n const near = graph.nodes.find((node) => node.id === (pure.kind === 'break' ? pure.source : pure.target))\n return near?.kind === 'state' ? near.parent : undefined\n}\n","import type { Edge, Node } from '@xyflow/react'\nimport type { WorkflowTypeList } from '@protobase/client'\nimport { cacheForcedAgainst } from './cache-advice'\nimport { triggerId } from './definition'\nimport type { Graph, GraphNode } from './definition-graph'\nimport { nodeSize, type Box } from './graph-layout'\nimport type { NodeTrace } from './node-trace'\nimport type { NodeProblem } from './problems'\nimport { stateLabel, triggerLabel } from './labels'\nimport { text } from './messages'\nimport type { DataGraph, PureNode } from './pins/data-graph'\nimport type { InputPin, OutputPin } from './pins/node-pins'\nimport { shownInputs } from './pins/pin-layout'\nimport { pinColour } from './pins/pin-text'\nimport { breakOutputs, pureInputs } from './pins/node-sizes'\nimport { pureParent } from './pins/pure-parents'\n\n/**\n * What a node of the canvas draws from: its node of the graph, what it is (`kind`, its type's label), the problems the\n * check found with it and what it warns of, how it did in a run, and whether its cache was forced on against its type's\n * advice.\n */\n/** `dataOrder`: the workflow runs in data order, so the node has no execution handles to draw edges from by hand. */\n/**\n * What a Break's, a Make's or a condition node draws from: the node, which of its inputs and a Break's fields it shows,\n * how many it folds away, whether it is open, and whether it has a row to fold or open them.\n */\nexport type PureData = { pure: PureNode; shownInputs: InputPin[]; shownOutputs: OutputPin[]; folded: number; open: boolean; foldable: boolean }\n\n/** `moved`: the node was moved by hand, so the layout leaves it where it was put. */\nexport type NodeData = { node: GraphNode; kind: string; problems: NodeProblem[]; warnings?: NodeProblem[]; trace?: NodeTrace; cacheWarning?: boolean; pins?: NodePins; pureData?: PureData; dataOrder?: boolean; moved?: boolean }\n\n/** The pins a node shows: the inputs it shows, its outputs, how many inputs it folds away and whether it is open. */\nexport type NodePins = { inputs: InputPin[]; outputs: OutputPin[]; folded: number; open: boolean }\n\nexport type FlowNode = Node<NodeData, 'trigger' | 'state' | 'pure'>\n\n// React Flow's ids: no state is named by an empty path, but React Flow wants every id to say something.\nconst triggerFlowId = 'trigger'\n// A Break's or a Make's id is its own, as no state has it.\n/** A trigger's or a state's node id on the canvas: a state's always prefixed, whatever it is named, such as make:Report. */\nexport const flowId = (id: string) => (id === triggerId ? triggerFlowId : `state:${id}`)\n\n/** Whether a canvas node is a Break or a Make: neither the trigger nor a state, whose ids flowId gives. */\nexport const isPureFlowId = (id: string) => id !== triggerFlowId && !id.startsWith('state:')\n\n/** The graph's id of a canvas node: a state's name, the trigger's, or a Break's or a Make's id as it is. */\nexport const graphId = (id: string) => (id === triggerFlowId ? triggerId : id.startsWith('state:') ? id.slice('state:'.length) : id)\n\n/** The pins of a node, as the data graph gives them and its optional inputs are open or folded. */\nexport const nodePins = (data: DataGraph, id: string, open: boolean): NodePins => {\n const { shown, folded } = shownInputs(data.inputs.get(id) ?? [], open)\n return { inputs: shown, outputs: data.outputs.get(id) ?? [], folded, open }\n}\n\n\n/**\n * The canvas's nodes, at the boxes the layout gave them: a Map holds the nodes inside it, which come after it, and a\n * node not laid out yet waits at the top left. Nodes are not dragged here: the canvas lets them be where it takes changes.\n */\nexport const flowNodes = (graph: Graph, boxes: ReadonlyMap<string, Box> | undefined, problems: ReadonlyMap<string, NodeProblem[]>, selected: string | undefined, traces?: ReadonlyMap<string, NodeTrace>, types?: WorkflowTypeList, warnings?: ReadonlyMap<string, NodeProblem[]>, pins?: { data: DataGraph; open: ReadonlySet<string> }, dataOrder = false): FlowNode[] =>\n graph.nodes.map((node) => {\n const box = boxes?.get(node.id) ?? { x: 0, y: 0, ...nodeSize }\n const parent = node.kind === 'state' ? node.parent : undefined\n const kind = node.kind === 'trigger' ? triggerLabel(node.trigger, types) : stateLabel(node.state, types)\n const cacheWarning = node.kind === 'state' && cacheForcedAgainst(node.state, types)\n const name = node.kind === 'state' ? text('stateNode', { name: node.name, type: kind }) : text('triggerNode', { trigger: kind })\n const warned = warnings?.get(node.id) ?? []\n const marks = [...(cacheWarning ? [text('cacheForcedAgainst')] : []), ...warned.map((warning) => warning.message)]\n return {\n id: flowId(node.id),\n type: node.kind,\n ariaLabel: [name, ...marks].join(', '),\n position: { x: box.x, y: box.y },\n width: box.width,\n height: box.height,\n // The node is drawn at its box's size, so React Flow knows it from the first render: a node handed over without\n // one loses its handles' places, and its edges vanish until its size changes\n measured: { width: box.width, height: box.height },\n data: { node, kind, problems: problems.get(node.id) ?? [], ...(traces?.has(node.id) && { trace: traces.get(node.id) }), ...(cacheWarning && { cacheWarning }), ...(warned.length > 0 && { warnings: warned }), ...(pins && { pins: nodePins(pins.data, node.id, pins.open.has(node.id)) }), ...(dataOrder && { dataOrder }) },\n draggable: false,\n deletable: node.kind === 'state',\n selected: node.id === selected,\n ...(parent !== undefined && { parentId: flowId(parent), extent: 'parent' as const }),\n }\n })\n\n// A condition longer than this is cut on its edge; the step's form shows it whole.\nconst labelLength = 40\n\nconst shortened = (label: string) => (label.length > labelLength ? `${label.slice(0, labelLength - 1)}…` : label)\n\nconst edgeLabel = (edge: Graph['edges'][number]) => {\n if (edge.kind === 'default') return text('otherwise')\n if (edge.kind === 'catch') return text('onError', { errors: edge.label ?? '' })\n if (edge.kind === 'rule') return edge.label ? shortened(edge.label) : text('conditionToWrite')\n return\n}\n\n// In data order an edge is what a state reads, drawn between each node's sides, which only changing what it reads changes\nconst dataOrderEdge = (edge: Graph['edges'][number]): Edge => ({\n id: edge.id,\n source: flowId(edge.source),\n sourceHandle: 'out',\n target: flowId(edge.target),\n targetHandle: 'in',\n deletable: false,\n data: { kind: edge.kind, field: edge.field, source: edge.source },\n ...(edge.kind === 'status' && { className: 'pb-workflow-status' }),\n})\n\n/** The canvas's edges, each from the handle of its kind; the trigger's cannot be deleted, only drawn elsewhere. */\nexport const flowEdges = (graph: Graph, dataOrder = false): Edge[] =>\n graph.edges.map((edge) => {\n if (dataOrder) return dataOrderEdge(edge)\n const label = edgeLabel(edge)\n return {\n id: edge.id,\n source: flowId(edge.source),\n sourceHandle: edge.kind,\n target: flowId(edge.target),\n targetHandle: 'in',\n deletable: edge.kind !== 'start',\n data: { kind: edge.kind, field: edge.field, source: edge.source },\n ...(label !== undefined && { label }),\n ...(edge.kind === 'catch' && { className: 'pb-workflow-catch' }),\n }\n })\n\n/** The Break, Make and condition nodes, at their boxes, inside the Map or Block of what they break or make. */\nexport const pureFlowNodes = (graph: Graph, data: DataGraph, boxes: ReadonlyMap<string, Box> | undefined, open: ReadonlySet<string>): FlowNode[] =>\n data.pure.map((pure) => {\n const box = boxes?.get(pure.id) ?? { x: 0, y: 0, ...nodeSize }\n const parent = pureParent(graph, pure)\n const { shown, folded } = pureInputs(pure, open.has(pure.id))\n const fields = pure.kind === 'break' ? breakOutputs(pure, data.edges, open.has(pure.id)) : undefined\n // The graph node it stands beside, which names nothing a panel opens\n const near = graph.nodes.find((node) => node.id === (pure.kind === 'break' ? pure.source : pure.target))!\n return {\n id: pure.id,\n type: 'pure' as const,\n position: { x: box.x, y: box.y },\n width: box.width,\n height: box.height,\n measured: { width: box.width, height: box.height },\n data: { node: near, kind: pure.kind, problems: [], pureData: { pure, shownInputs: shown, shownOutputs: fields?.shown ?? [], folded: fields?.folded ?? folded, open: open.has(pure.id), foldable: fields ? fields.foldable : folded > 0 || open.has(pure.id) } },\n draggable: false,\n deletable: true,\n ...(parent !== undefined && { parentId: flowId(parent), extent: 'parent' as const }),\n }\n })\n\n/** The wires between pins, each coloured by the type of what it carries. */\n/**\n * In data order with pins, the lines between steps that no wire stands for: a step that reads another only in a way no\n * pin shows, such as a variable assigned part of its result, still shows that it runs after it.\n */\nexport const unwiredOrderEdges = (graph: Graph, data: DataGraph): Edge[] => {\n // The step a wire's end belongs to, through the Break, Make or condition node it passes\n const step = (node: string) => {\n const pure = data.pure.find((each) => each.id === node)\n return pure ? (pure.kind === 'break' ? pure.source : pure.target) : node\n }\n const wired = new Set(data.edges.map((edge) => `${step(edge.source)}\\n${step(edge.target)}`))\n // The trigger's lines start the states that read nothing, which the run's input pins show\n return flowEdges({ ...graph, edges: graph.edges.filter((edge) => edge.source !== triggerId && !wired.has(`${edge.source}\\n${edge.target}`)) }, true)\n}\n\nexport const dataFlowEdges = (data: DataGraph): Edge[] => {\n // A wire's end is a Break's or a Make's, as the graph lists them, else a step's or the trigger's\n const pure = new Set(data.pure.map((node) => node.id))\n const end = (id: string) => (pure.has(id) ? id : flowId(id))\n return data.edges.map((edge) => ({\n id: edge.id,\n source: end(edge.source),\n sourceHandle: edge.sourceHandle,\n target: end(edge.target),\n targetHandle: edge.targetHandle,\n // A read inside an expression goes only as the expression changes\n deletable: !edge.expression,\n data: { kind: 'data', wire: edge },\n className: `pb-wire pb-wire-${pinColour(edge.type)}${edge.expression ? ' pb-wire-expression' : ''}`,\n }))\n}\n","import { createContext } from 'react'\nimport type { AddAt } from './definition-edits'\n\n/** What a click on an editable source handle of the canvas does: opens the step picker for a step added there. */\nexport const AddAtContext = createContext<((at: AddAt) => void) | undefined>(undefined)\n","import type { BadgeTone } from '../../../primitives/badge'\n\n/**\n * How a state did in a run, as its node shows it: how its last step ended, `retrying` while it waits to be tried again,\n * or `current` while the run is on it.\n */\nexport type NodeStatus = 'succeeded' | 'caught' | 'retrying' | 'failed' | 'current'\n\n/** A node's mark in a run: its status, how many steps it took, every try and item counted, and whether the step changed since. */\nexport type NodeTrace = { status: NodeStatus; steps: number; changed?: boolean }\n\nexport const nodeTones: Record<NodeStatus, BadgeTone> = { succeeded: 'green', caught: 'amber', retrying: 'amber', failed: 'red', current: 'blue' }\n","import { createContext, useContext } from 'react'\n\n/**\n * What the pins on the canvas can do: change a step's argument in place, a value of a condition node's side at `at`\n * among the step's Condition's nodes, or the whole Condition as an Expression writes it, and open or fold a node's\n * optional inputs.\n */\nexport type PinActions = {\n setArgument: (step: string, keys: readonly string[], value: unknown) => void\n setConditionSide: (step: string, at: readonly number[], value: string | number | boolean) => void\n setCondition: (step: string, value: string | undefined) => void\n toggleOpen: (node: string) => void\n}\n\nexport const PinActionsContext = createContext<PinActions | undefined>(undefined)\n\n/** The pins' actions where the canvas is editable; undefined where it is only shown. */\nexport const usePinActions = () => useContext(PinActionsContext)\n","import { useState } from 'react'\nimport { Checkbox } from '../../../../primitives/checkbox'\nimport { Input } from '../../../../primitives/input'\nimport { Select } from '../../../../primitives/select'\nimport { text } from '../messages'\nimport { conditionKey, type InputPin } from './node-pins'\nimport { statusLabel } from './pin-text'\n\n// The one kind an inline editor writes, for a pin that takes text, a number or true and false\nconst inlineKind = (pin: InputPin) => {\n if (pin.options) return 'choice'\n if (pin.type.kinds === 'any') return\n const [kind, ...others] = pin.type.kinds.filter((each) => each !== 'null')\n if (kind === 'string' && others.every((other) => other === 'integer' || other === 'number')) return 'string'\n if (others.length > 0) return\n return kind === 'integer' || kind === 'number' ? 'number' : kind === 'boolean' ? 'boolean' : undefined\n}\n\nconst numberOf = (typed: string) => (typed.trim() === '' ? undefined : Number.isNaN(Number(typed)) ? typed : Number(typed))\n\n// A number's editor shows what was typed while it has the focus, such as \"1.\" on the way to 1.5, which the value it\n// gives, 1, would not; once the focus leaves, it shows the value again.\nconst NumberInput = ({ name, className, value, onChange }: { name: string; className: string; value: unknown; onChange: (value: unknown) => void }) => {\n const [typed, setTyped] = useState<string>()\n return (\n <Input\n aria-label={name}\n wrapperClassName={`${className} h-6 w-[55%] px-1.5`}\n className=\"text-xs\"\n inputMode=\"decimal\"\n value={typed ?? (value === undefined ? '' : String(value))}\n onChange={(event) => {\n setTyped(event.target.value)\n onChange(numberOf(event.target.value))\n }}\n onBlur={() => setTyped(undefined)}\n />\n )\n}\n\n/**\n * What an input pin holds, on its row: an editor of its own value where it is text, a number, true or false or a\n * choice and no wire reads into it, a mark for an expression or an object, which the step's form edits, else nothing.\n */\nexport const PinValue = ({ pin, label, onChange }: { pin: InputPin; label: string; onChange?: (value: unknown) => void }) => {\n if (pin.state === 'wired' || pin.state === 'made') return null\n // A Condition is an expression, which the step's form edits; wired, it reads a yes or no\n if (pin.key === conditionKey && pin.state !== 'expression') return null\n if (pin.state === 'expression') {\n return (\n <span className=\"ml-auto shrink-0 rounded bg-muted px-1 font-mono text-xs text-muted-foreground\" title={text('pinExpression', { expression: String(pin.value) })}>\n ƒ\n </span>\n )\n }\n const kind = inlineKind(pin)\n if (pin.state === 'literal' && typeof pin.value === 'object') return <span className=\"ml-auto shrink-0 text-xs text-muted-foreground\" title={text('pinObjectValue')}>{'{…}'}</span>\n // A value of a type no editor here takes, such as a key that is text or a number, shows as it is\n if (!kind) return pin.state === 'literal' ? <span className=\"ml-auto min-w-0 truncate text-xs text-muted-foreground\">{String(pin.value)}</span> : null\n const name = text('inputValue', { label })\n if (!onChange) return <span className=\"ml-auto min-w-0 truncate text-xs text-muted-foreground\">{pin.value === undefined ? '' : String(pin.value)}</span>\n const editor = 'nodrag nopan nowheel ml-auto min-w-0'\n if (kind === 'boolean') return <Checkbox className={editor} checked={pin.value === true} label={name} onChange={(checked) => onChange(checked)} />\n if (kind === 'choice') {\n return (\n <Select aria-label={name} className={`${editor} h-6 max-w-[55%] px-1 py-0 text-xs`} value={typeof pin.value === 'string' ? pin.value : ''} onChange={(event) => onChange(event.target.value === '' ? undefined : event.target.value)}>\n <option value=\"\" />\n {pin.options!.map((option) => (\n <option key={option} value={option}>\n {pin.statuses ? statusLabel(option) : option}\n </option>\n ))}\n </Select>\n )\n }\n if (kind === 'number') return <NumberInput name={name} className={editor} value={pin.value} onChange={onChange} />\n return (\n <Input\n aria-label={name}\n wrapperClassName={`${editor} h-6 w-[55%] px-1.5`}\n className=\"text-xs\"\n value={pin.value === undefined ? '' : String(pin.value)}\n onChange={(event) => onChange(event.target.value === '' ? undefined : event.target.value)}\n />\n )\n}\n","import { Handle, Position } from '@xyflow/react'\nimport { text } from '../messages'\nimport type { InputPin, OutputPin } from './node-pins'\nimport { usePinActions } from './pin-actions'\nimport { inputPinLabel, outputLabel, pinColour, typeLabel } from './pin-text'\nimport { PinValue } from './pin-value'\nimport { inHandle, outHandle } from './pure-ids'\n\nconst pinClass = (pin: { type: InputPin['type'] }) => `pb-pin pb-pin-${pinColour(pin.type)}`\n\n/**\n * An input pin's row: its dot on the left edge, which a wire ends at, its name with its type on hover, and what it\n * holds. `step` and `keys` say which argument it sets, such as a Make's field of `data`; `onValue`, what its value\n * changes instead, such as a condition node's side, named `name`; `bare`, it takes a wire only and shows no value.\n */\nexport const InputRow = ({ pin, step, keys, connectable, name, onValue, bare = false }: { pin: InputPin; step: string; keys: readonly string[]; connectable: boolean; name?: string; onValue?: (value: unknown) => void; bare?: boolean }) => {\n const actions = usePinActions()\n const label = name ?? inputPinLabel(pin.key)\n return (\n <div className=\"relative flex h-[26px] items-center gap-1.5 pr-2 pl-3\">\n <Handle id={inHandle(pin.key)} type=\"target\" position={Position.Left} isConnectable={connectable} className={pinClass(pin)} />\n <span className=\"min-w-0 shrink truncate text-xs text-body\" title={text('pinTypeTitle', { label, type: typeLabel(pin.type) })}>\n {label}\n {pin.required && <span aria-hidden=\"true\" className=\"text-danger-text\">*</span>}\n </span>\n {!bare && <PinValue pin={pin} label={label} {...(actions && connectable && { onChange: onValue ?? ((value: unknown) => actions.setArgument(step, keys, value)) })} />}\n </div>\n )\n}\n\n/** An output pin's row: its name with its type on hover, and its dot on the right edge, which wires start from. */\nexport const OutputRow = ({ pin, connectable, trigger = false, field = false }: { pin: OutputPin; connectable: boolean; trigger?: boolean; field?: boolean }) => {\n const label = outputLabel(pin.path, trigger, field)\n return (\n <div className=\"relative flex h-[26px] items-center justify-end pr-3 pl-2\">\n <span className=\"min-w-0 truncate text-xs text-body\" title={text('pinTypeTitle', { label, type: typeLabel(pin.type) })}>\n {label}\n </span>\n <Handle id={outHandle(pin.path)} type=\"source\" position={Position.Right} isConnectable={connectable} className={pinClass(pin)} />\n </div>\n )\n}\n\n/**\n * The pins of a Map or a Block, whose box holds its own steps: a dot on its header's edge for each, its name and type on\n * hover, so the wires to and from the step have their ends, as its steps fill the rest.\n */\nexport const GroupPins = ({ inputs, outputs, connectable }: { inputs: readonly InputPin[]; outputs: readonly OutputPin[]; connectable: boolean }) => {\n const top = (index: number, count: number) => ({ top: `${((index + 1) * 100) / (count + 1)}%` })\n return (\n <>\n {inputs.map((pin, index) => (\n <Handle key={pin.key} id={inHandle(pin.key)} type=\"target\" position={Position.Left} isConnectable={connectable} className={pinClass(pin)} style={top(index, inputs.length)} title={text('pinTypeTitle', { label: inputPinLabel(pin.key), type: typeLabel(pin.type) })} />\n ))}\n {outputs.map((pin, index) => (\n <Handle key={pin.path.join('/')} id={outHandle(pin.path)} type=\"source\" position={Position.Right} isConnectable={connectable} className={pinClass(pin)} style={top(index, outputs.length)} title={text('pinTypeTitle', { label: outputLabel(pin.path), type: typeLabel(pin.type) })} />\n ))}\n </>\n )\n}\n\n/** The button that opens a node's optional inputs, or a Break's fields nothing reads, or folds them again. */\nexport const FoldRow = ({ node, folded, open, fields = false }: { node: string; folded: number; open: boolean; fields?: boolean }) => {\n const actions = usePinActions()\n if (folded === 0 && !open) return null\n return (\n <button type=\"button\" className=\"nodrag h-6 w-full px-3 text-left text-xs text-muted-foreground hover:text-foreground\" onClick={() => actions?.toggleOpen(node)} disabled={!actions}>\n {fields ? (open ? text('foldLessFields') : text('foldMoreFields', { count: folded })) : open ? text('foldLess') : text('foldMore', { count: folded })}\n </button>\n )\n}\n\n/** A node's pins: its inputs on the left and its outputs on the right, side by side, then the row that folds its optional inputs. */\nexport const PinColumns = ({ node, inputs, outputs, folded, open, editable, trigger = false }: { node: string; inputs: readonly InputPin[]; outputs: readonly OutputPin[]; folded: number; open: boolean; editable: boolean; trigger?: boolean }) => (\n <>\n <div className=\"grid grid-cols-[3fr_2fr]\">\n <div className=\"min-w-0\">\n {inputs.map((pin) => (\n <InputRow key={pin.key} pin={pin} step={node} keys={[pin.key]} connectable={editable} />\n ))}\n </div>\n <div className=\"min-w-0\">\n {outputs.map((pin) => (\n <OutputRow key={JSON.stringify(pin.path)} pin={pin} connectable={editable} trigger={trigger} />\n ))}\n </div>\n </div>\n <FoldRow node={node} folded={folded} open={open} />\n </>\n)\n","import { createContext } from 'react'\n\n/** What a moved node's mark does where the canvas takes changes: hands the node, by its canvas id, back to the layout. */\nexport const UnpinContext = createContext<((node: string) => void) | undefined>(undefined)\n","import { Pin } from 'lucide-react'\nimport { useContext } from 'react'\nimport { cn } from '../../../lib/cn'\nimport { Button } from '../../../primitives/button'\nimport { text } from './messages'\nimport { UnpinContext } from './unpin-context'\n\n// On the box's top right corner, outside what the box shows and clear of the handles down its right side\nconst place = 'nodrag absolute -top-4 -right-4 z-10'\n\n/**\n * The mark of a node moved by hand, which the layout leaves where it was put: where the canvas takes changes, a button\n * that unpins it, handing it back to the layout.\n */\nexport const MovedMark = ({ node, name }: { node: string; name: string }) => {\n const unpin = useContext(UnpinContext)\n if (!unpin) {\n return (\n <span className={cn(place, 'inline-flex size-7 items-center justify-center rounded-md border border-border-strong bg-background text-muted-foreground shadow-sm')} title={text('movedByHand')}>\n <Pin className=\"size-3.5\" aria-hidden />\n <span className=\"sr-only\">{text('movedByHand')}</span>\n </span>\n )\n }\n return (\n <Button\n size=\"icon\"\n className={place}\n aria-label={text('unpin', { name })}\n title={text('unpinHelp')}\n onClick={(event) => {\n // The node itself is not chosen by it\n event.stopPropagation()\n unpin(node)\n }}\n >\n <Pin className=\"size-3.5\" aria-hidden />\n </Button>\n )\n}\n","import { Handle, Position, type NodeProps } from '@xyflow/react'\nimport { CircleAlert } from 'lucide-react'\nimport { useContext, type KeyboardEvent, type MouseEvent } from 'react'\nimport type { State } from '@protobase/workflows'\nimport { cn } from '../../../lib/cn'\nimport { Badge } from '../../../primitives/badge'\nimport { AddAtContext } from './add-at-context'\nimport type { AddAt } from './definition-edits'\nimport type { EdgeKind } from './definition-graph'\nimport type { FlowNode } from './flow-elements'\nimport { nodeStatusLabel } from './labels'\nimport { nodeTones, type NodeTrace } from './node-trace'\nimport { holdsSteps } from './definition'\nimport { text } from './messages'\nimport { GroupPins, PinColumns } from './pins/pin-rows'\nimport { MovedMark } from './moved-mark'\n\ntype Source = { kind: EdgeKind; top: number; label?: string }\n\n// Where the execution handles sit on a node's right edge, in its header, as Blueprints draw them\nconst execTops = [18, 38]\n\n// The handles an edge leaves a state from, by its type, down the header's right edge: on to the next state, or a\n// Choice's rules and then its Default, and below it the error path of a Task, Map or Block.\nconst sourcesOf = (state: State): Source[] => {\n if (state.Type === 'Choice') {\n return [\n { kind: 'rule', top: execTops[0]!, label: text('when') },\n { kind: 'default', top: execTops[1]!, label: text('otherwise') },\n ]\n }\n const next: Source[] = ['Task', 'Pass', 'Wait', 'Map', 'Block'].includes(state.Type) ? [{ kind: 'next', top: execTops[0]! }] : []\n const caught: Source[] = state.Type === 'Task' || state.Type === 'Map' || state.Type === 'Block' ? [{ kind: 'catch', top: execTops[next.length]!, label: text('onErrorHandle') }] : []\n return [...next, ...caught]\n}\n\n// A click on a handle, rather than a drag from it, adds a step there; the node itself is not chosen by it\nconst useAddAt = (at: AddAt, editable: boolean, handle?: string) => {\n const addAt = useContext(AddAtContext)\n if (!addAt || !editable) return {}\n const open = (event: MouseEvent | KeyboardEvent) => {\n event.stopPropagation()\n addAt(at)\n }\n const label = handle ? text('addStepAtNamedHandle', { handle }) : text('addStepAtHandle')\n return {\n role: 'button',\n tabIndex: 0,\n 'aria-label': label,\n title: label,\n onClick: open,\n onKeyDown: (event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n open(event)\n }\n },\n }\n}\n\nconst SourceHandle = ({ source, path, editable }: { source: Source; path: string; editable: boolean }) => (\n <Handle id={source.kind} type=\"source\" position={Position.Right} isConnectable={editable} style={{ top: source.top }} className={cn('pb-workflow-exec', `pb-workflow-handle-${source.kind}`)} {...useAddAt({ kind: source.kind, source: path }, editable, source.label)}>\n {source.label && <span className=\"pb-workflow-handle-label\">{source.label}</span>}\n </Handle>\n)\n\nconst Sources = ({ state, path, editable }: { state: State; path: string; editable: boolean }) => sourcesOf(state).map((source) => <SourceHandle key={source.kind} source={source} path={path} editable={editable} />)\n\nconst ProblemCount = ({ count }: { count: number }) =>\n count > 0 && (\n <span className=\"inline-flex shrink-0 items-center gap-1 text-xs font-medium text-danger-text\" title={text('problemCount', { count })}>\n <CircleAlert className=\"size-3.5\" aria-hidden=\"true\" />\n <span className=\"sr-only\">{text('problemCount', { count })}</span>\n <span aria-hidden=\"true\">{count}</span>\n </span>\n )\n\n// What a step should be looked at for though it saves, plain to see on a screenshot: its cache forced on against its\n// type's advice, or what the check warns of\nconst WarningMark = ({ label }: { label: string }) => (\n <span className=\"inline-flex shrink-0 items-center text-warning-text\" title={label}>\n <CircleAlert className=\"size-3.5\" aria-hidden=\"true\" />\n <span className=\"sr-only\">{label}</span>\n </span>\n)\n\n// How the state did in a run, and how many steps it took when more than one\nconst TraceMark = ({ trace }: { trace: NodeTrace }) => (\n <span className=\"flex shrink-0 flex-col items-end gap-0.5\">\n {trace.changed ? <span title={text('changedSinceRun')} className=\"rounded-full border border-dashed px-1.5 text-xs text-muted-foreground\">{text('changedShort')}</span> : <Badge tone={nodeTones[trace.status]}>{nodeStatusLabel(trace.status)}</Badge>}\n {trace.steps > 1 && <span className=\"text-xs tabular-nums text-muted-foreground\">{text('traceSteps', { count: trace.steps })}</span>}\n </span>\n)\n\nconst boxClass = (selected: boolean, problems: number, trace?: NodeTrace) =>\n cn('rounded-lg border bg-background text-body shadow-sm', problems > 0 || trace?.status === 'failed' ? 'border-danger' : 'border-border-strong', selected && 'ring-2 ring-primary/40')\n\n// What the state is, with the count of its problems or its mark in a run, over its name, which keeps the whole width\nconst Title = ({ name, kind, problems, first, trace, warnings = [] }: { name: string; kind: string; problems: number; first?: boolean; trace?: NodeTrace; warnings?: readonly string[] }) => (\n <div className=\"min-w-0\">\n <div className=\"flex min-w-0 items-start justify-between gap-2\">\n <div className=\"min-w-0 truncate text-xs text-muted-foreground\">\n {kind}\n {first && <span className=\"text-primary-text\"> · {text('startsHere')}</span>}\n </div>\n {warnings.length > 0 && <WarningMark label={warnings.join('\\n')} />}\n <ProblemCount count={problems} />\n {trace && <TraceMark trace={trace} />}\n </div>\n <div className=\"truncate font-medium text-foreground\">{name}</div>\n </div>\n)\n\n/** A state: a box with its name, what it is and the handles its edges leave from; a Map's or Block's holds the states inside it. */\n// In data order a node has no execution handles: the edges drawn between nodes, in the simple view, are what they read,\n// from one's side to the other's\nconst DataSides = () => (\n <>\n <Handle id=\"in\" type=\"target\" position={Position.Left} isConnectable={false} className=\"pb-workflow-side\" style={{ top: execTops[0] }} />\n <Handle id=\"out\" type=\"source\" position={Position.Right} isConnectable={false} className=\"pb-workflow-side\" style={{ top: execTops[0] }} />\n </>\n)\n\n// The Condition a state runs under in data order, shortly, whole on hover\nconst OnlyWhen = ({ condition }: { condition: string | undefined }) =>\n condition !== undefined && (\n <span className=\"absolute top-1 right-6 max-w-[45%] truncate rounded bg-muted px-1 text-[0.625rem] text-muted-foreground\" title={condition}>\n {text('onlyWhenBadge')}\n </span>\n )\n\nexport const StateNode = ({ id, data, selected, isConnectable }: NodeProps<FlowNode>) => {\n const { node, kind, problems, trace, cacheWarning, warnings = [], pins, dataOrder, moved } = data\n if (node.kind !== 'state') return null\n return (\n <div className={cn(boxClass(selected, problems.length, trace), 'h-full', holdsSteps(node.state) && 'bg-muted/40')}>\n {moved && <MovedMark node={id} name={node.name} />}\n <div className=\"relative h-[52px] py-2 pr-6 pl-4\">\n {dataOrder ? <DataSides /> : <Handle id=\"in\" type=\"target\" position={Position.Left} isConnectable={isConnectable} className=\"pb-workflow-exec\" style={{ top: execTops[0] }} />}\n {dataOrder && <OnlyWhen condition={node.state.Condition} />}\n <Title name={node.name} kind={kind} problems={problems.length} first={node.first && node.parent !== undefined} trace={trace} warnings={[...(cacheWarning ? [text('cacheForcedAgainst')] : []), ...warnings.map((warning) => warning.message)]} />\n {!dataOrder && <Sources state={node.state} path={node.id} editable={isConnectable} />}\n {pins && holdsSteps(node.state) && <GroupPins inputs={pins.inputs} outputs={pins.outputs} connectable={isConnectable} />}\n </div>\n {pins && !holdsSteps(node.state) && <PinColumns node={node.id} inputs={pins.inputs} outputs={pins.outputs} folded={pins.folded} open={pins.open} editable={isConnectable} />}\n </div>\n )\n}\n\n/** The trigger: what starts a run, leading to the first state. */\nexport const TriggerNode = ({ id, data, selected, isConnectable }: NodeProps<FlowNode>) => {\n const { node, kind, problems, pins, dataOrder, moved } = data\n // In data order no state is first, so the trigger's handle adds no step\n const addAt = useAddAt({ kind: 'start', source: node.id }, isConnectable && !dataOrder)\n if (node.kind !== 'trigger') return null\n return (\n <div className={cn(boxClass(selected, problems.length), 'h-full border-dashed')}>\n {moved && <MovedMark node={id} name={text('trigger')} />}\n <div className=\"relative h-[52px] py-2 pr-6 pl-4\">\n <Title name={kind} kind={text('trigger')} problems={problems.length} />\n {dataOrder ? (\n <Handle id=\"out\" type=\"source\" position={Position.Right} isConnectable={false} className=\"pb-workflow-side\" style={{ top: execTops[0] }} />\n ) : (\n <Handle id=\"start\" type=\"source\" position={Position.Right} isConnectable={isConnectable} className=\"pb-workflow-exec\" style={{ top: execTops[0] }} {...addAt} />\n )}\n </div>\n {pins && <PinColumns node={node.id} inputs={[]} outputs={pins.outputs} folded={0} open={false} editable={isConnectable} trigger />}\n </div>\n )\n}\n","import { useState } from 'react'\nimport { guarded } from '../../../../lib/guarded'\n\n/**\n * How the editor draws a workflow: `pins`, every step's inputs and outputs as typed pins with the wires between them;\n * or `simple`, the steps and the lines between them alone, their inputs edited in the step's form. Both are views of the same document: switching changes nothing in it.\n */\nexport type GraphView = 'pins' | 'simple'\n\nexport const graphViewStorageKey = 'protobase:workflow-graph-view'\n\n/**\n * The view chosen in this browser; pins, the default, when none was or storage is unavailable. `storage` gives the\n * storage when asked, since a browser that blocks it throws as soon as it is reached.\n */\nexport const readGraphView = (storage: () => Pick<Storage, 'getItem'>): GraphView => (guarded(() => storage().getItem(graphViewStorageKey), null) === 'simple' ? 'simple' : 'pins')\n\n/** Remembers a view, and the default by forgetting the choice, so the default costs no storage. */\nexport const writeGraphView = (storage: () => Pick<Storage, 'setItem' | 'removeItem'>, view: GraphView) =>\n guarded(() => (view === 'pins' ? storage().removeItem(graphViewStorageKey) : storage().setItem(graphViewStorageKey, view)), undefined)\n\nconst browserStorage = () => localStorage\n\n/** The view the person chose last in this browser, and the way to choose another, which this browser remembers. */\nexport const useGraphView = () => {\n const [view, setView] = useState<GraphView>(() => readGraphView(browserStorage))\n const choose = (next: GraphView) => {\n setView(next)\n writeGraphView(browserStorage, next)\n }\n return [view, choose] as const\n}\n","import { Handle, Position } from '@xyflow/react'\nimport { useState } from 'react'\nimport { text } from '../messages'\nimport type { ConditionNode } from './data-graph'\nimport { usePinActions } from './pin-actions'\nimport { Input } from '../../../../primitives/input'\nimport { InputRow } from './pin-rows'\nimport { pinColour, typeLabel } from './pin-text'\nimport { expressionTextHeight } from './pin-layout'\nimport { conditionOut, inHandle } from './pure-ids'\n\n// An input's name: a Comparison's two are A and B, an All of's and an Any of's A, B, C and on, a Matches node's the text\n// and the pattern, a Not's what it turns round\nconst sideName = (node: ConditionNode, key: string) => {\n if (node.part.kind === 'not') return text('conditionNotSide')\n if (node.part.kind === 'matches') return key === '0' ? text('conditionMatchesText') : text('conditionMatchesPattern')\n if (node.part.kind === 'logic') return String.fromCharCode(65 + (Number(key) % 26))\n return key === '0' ? text('conditionSideA') : text('conditionSideB')\n}\n\n// The text of an Expression, kept as typed while it has the focus and written once the focus leaves, so a Condition\n// typed into a form the nodes stand for turns into them only then\nconst ExpressionText = ({ node, source }: { node: ConditionNode; source: string }) => {\n const actions = usePinActions()\n const [typed, setTyped] = useState<string>()\n const shown = source.trim()\n return (\n <textarea\n aria-label={text('conditionExpressionText')}\n className=\"nodrag nopan nowheel block w-full resize-none rounded border border-border bg-background px-1.5 py-1 font-mono text-xs text-foreground\"\n style={{ height: expressionTextHeight }}\n spellCheck={false}\n readOnly={!actions}\n value={typed ?? shown}\n onChange={(event) => setTyped(event.target.value)}\n onBlur={() => {\n setTyped(undefined)\n const next = typed?.trim()\n if (next === undefined || next === shown) return\n actions?.setCondition(node.target, next === '' ? undefined : `{% ${next} %}`)\n }}\n />\n )\n}\n\n// A value an Expression reads, by where it comes from: Save.Status, input.record.id or $fetch.body.ip\nconst readName = (key: string) => key.replace(/^\\$states\\.context\\.Steps\\./, '').replace(/^\\$states\\.context\\.Execution\\.Input/, 'input')\n\n// A Matches node's pattern, typed on the node and never wired: what is typed shows while the box has the focus, and only\n// a pattern that is not empty is written, as an empty one is no regular expression\nconst PatternRow = ({ node, editable }: { node: ConditionNode; editable: boolean }) => {\n const actions = usePinActions()\n const [typed, setTyped] = useState<string>()\n const label = text('conditionMatchesPattern')\n const pattern = String(node.inputs[1]?.value ?? '')\n return (\n <div className=\"relative flex h-[26px] items-center gap-1.5 pr-2 pl-3\">\n <span className=\"min-w-0 shrink truncate text-xs text-body\">{label}</span>\n <Input\n aria-label={text('inputValue', { label })}\n wrapperClassName=\"nodrag nopan nowheel ml-auto h-6 w-[60%] min-w-0 px-1.5\"\n className=\"font-mono text-xs\"\n value={typed ?? pattern}\n disabled={!actions || !editable}\n onChange={(event) => {\n setTyped(event.target.value)\n if (event.target.value !== '') actions?.setConditionSide(node.target, [...node.at, 1], event.target.value)\n }}\n onBlur={() => setTyped(undefined)}\n />\n </div>\n )\n}\n\n/**\n * A condition node's pins and inputs: a Comparison's, an And's or an Or's two sides, a Not's one, each wired or\n * holding a value of its own, or an Expression's text with a pin per value it reads, which only the text changes. Its\n * yes or no goes out on the right, to the Only when pin or the side it is part of.\n */\nexport const ConditionPins = ({ node, editable }: { node: ConditionNode; editable: boolean }) => {\n const actions = usePinActions()\n const out = <Handle id={conditionOut} type=\"source\" position={Position.Right} isConnectable={false} className=\"pb-pin pb-pin-boolean\" style={{ top: 13 }} />\n if (node.part.kind === 'expression') {\n return (\n <div className=\"relative grid gap-1 px-2 pt-1\">\n {out}\n <ExpressionText node={node} source={node.part.source} />\n <div className=\"-mx-2\">\n {node.inputs.map((pin) => (\n <div key={pin.key} className=\"relative flex h-[26px] items-center pr-2 pl-3\">\n <Handle id={inHandle(pin.key)} type=\"target\" position={Position.Left} isConnectable={false} className={`pb-pin pb-pin-${pinColour(pin.type)}`} />\n <span className=\"min-w-0 truncate font-mono text-xs text-body\" title={text('pinTypeTitle', { label: pin.key, type: typeLabel(pin.type) })}>\n {readName(pin.key)}\n </span>\n </div>\n ))}\n </div>\n </div>\n )\n }\n return (\n <div className=\"relative pt-1\">\n {out}\n {node.inputs.map((pin) =>\n node.part.kind === 'matches' && pin.key === '1' ? (\n <PatternRow key={pin.key} node={node} editable={editable} />\n ) : (\n <InputRow\n key={pin.key}\n pin={pin}\n step={node.target}\n keys={[]}\n name={sideName(node, pin.key)}\n // The empty input after an All of's or an Any of's last takes a wire or a node, which adds its next condition\n bare={node.part.kind === 'logic' && Number(pin.key) === node.part.sides.length}\n connectable={editable}\n // A value cleared is an empty one: a check box gives true or false, so only text or a number is cleared\n onValue={(value) => actions?.setConditionSide(node.target, [...node.at, Number(pin.key)], (value ?? '') as string | number | boolean)}\n />\n ),\n )}\n </div>\n )\n}\n","import { Handle, Position } from '@xyflow/react'\nimport { X } from 'lucide-react'\nimport { selectValue, type SelectPart, type SelectValue } from '@protobase/workflows'\nimport { Input } from '../../../../primitives/input'\nimport { text } from '../messages'\nimport type { SelectNode } from './data-graph'\nimport { usePinActions } from './pin-actions'\nimport { InputRow } from './pin-rows'\nimport { pinColour } from './pin-text'\nimport { selectOut } from './pure-ids'\n\n// What was typed, as the kind of value it replaces: a number stays one while it reads as one, true and false stay\n// true and false, and anything else is text\nconst typed = (next: string, before: SelectValue): SelectValue => {\n if (typeof before === 'number' && next.trim() !== '' && Number.isFinite(Number(next))) return Number(next)\n if (typeof before === 'boolean' && (next === 'true' || next === 'false')) return next === 'true'\n return next\n}\n\nconst editor = 'nodrag nopan nowheel h-6 min-w-0 px-1.5'\n\n// A value of the node's own, typed on its row\nconst ValueInput = ({ label, value, onChange, disabled }: { label: string; value: SelectValue; onChange: (value: SelectValue) => void; disabled: boolean }) => (\n <Input aria-label={label} wrapperClassName={`${editor} flex-1`} className=\"text-xs\" value={String(value)} disabled={disabled} onChange={(event) => onChange(typed(event.target.value, value))} />\n)\n\n/**\n * A Select's rows: the value it looks at, a pin a wire reads into or a value of its own; then a row per case, the\n * value it can be and what the node gives then; what it gives for any other; and a button that adds a case. Its value\n * goes out on the right, to the argument it chooses.\n */\nexport const SelectRows = ({ node, editable }: { node: SelectNode; editable: boolean }) => {\n const actions = usePinActions()\n const disabled = !actions || !editable\n const write = (part: SelectPart) => actions?.setArgument(node.target, [node.key], selectValue(part))\n const { part } = node\n const setCase = (index: number, change: Partial<SelectPart['cases'][number]>) => write({ ...part, cases: part.cases.map((each, position) => (position === index ? { ...each, ...change } : each)) })\n return (\n <div className=\"relative pt-1\">\n <Handle id={selectOut} type=\"source\" position={Position.Right} isConnectable={false} className={`pb-pin pb-pin-${pinColour(node.type)}`} style={{ top: 13 }} />\n {node.inputs.map((pin) => (\n <InputRow key={pin.key} pin={pin} step={node.target} keys={[]} name={text('selectInput')} connectable={editable} onValue={(value) => write({ ...part, operand: { value: typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' ? value : '' } })} />\n ))}\n {part.cases.map((each, index) => (\n <div key={index} className=\"flex h-[26px] items-center gap-1 pr-2 pl-3\">\n <ValueInput label={text('selectWhen', { case: index + 1 })} value={each.when} disabled={disabled} onChange={(when) => setCase(index, { when })} />\n <span aria-hidden=\"true\" className=\"text-xs text-muted-foreground\">\n →\n </span>\n <ValueInput label={text('selectThen', { case: index + 1 })} value={each.then} disabled={disabled} onChange={(then) => setCase(index, { then })} />\n <button\n type=\"button\"\n className=\"nodrag shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-40\"\n aria-label={text('selectRemoveCase', { case: index + 1 })}\n disabled={disabled || part.cases.length === 1}\n onClick={() => write({ ...part, cases: part.cases.filter((_, position) => position !== index) })}\n >\n <X className=\"size-3\" aria-hidden />\n </button>\n </div>\n ))}\n <div className=\"flex h-[26px] items-center gap-1 pr-2 pl-3\">\n <span className=\"shrink-0 text-xs text-body\">{text('selectOtherwise')}</span>\n <ValueInput label={text('selectOtherwise')} value={part.otherwise} disabled={disabled} onChange={(otherwise) => write({ ...part, otherwise })} />\n </div>\n <button type=\"button\" className=\"nodrag h-6 w-full px-3 text-left text-xs text-muted-foreground hover:text-foreground\" disabled={disabled} onClick={() => write({ ...part, cases: [...part.cases, { when: '', then: '' }] })}>\n {text('selectAddCase')}\n </button>\n </div>\n )\n}\n","import { Handle, Position, type NodeProps } from '@xyflow/react'\nimport { cn } from '../../../../lib/cn'\nimport type { FlowNode, PureData } from '../flow-elements'\nimport { text } from '../messages'\nimport type { PureNode } from './data-graph'\nimport { ConditionPins } from './condition-nodes'\nimport { SelectRows } from './select-node'\nimport { FoldRow, InputRow, OutputRow } from './pin-rows'\nimport { conditionNodeTitle, pinColour, typeLabel } from './pin-text'\nimport { breakIn, makeOut } from './pure-ids'\nimport { MovedMark } from '../moved-mark'\n\nconst titleOf = (pure: PureNode) => {\n if (pure.kind === 'condition') return conditionNodeTitle(pure)\n if (pure.kind === 'select') return text('selectTitle')\n return pure.kind === 'break' ? text('breakTitle', { type: typeLabel(pure.type) }) : text('makeTitle', { type: typeLabel(pure.type) })\n}\n\nconst Title = ({ pure }: { pure: PureNode }) => <div className=\"truncate border-b px-3 py-1.5 text-xs font-medium text-foreground\">{titleOf(pure)}</div>\n\n/**\n * A Break, a Make or a condition node: a node of the editor's own, with no step at run time, that takes an object apart\n * into a pin per field, builds one from a pin per field, or is part of a step's Condition. Its object's own pin is bound\n * to the value it breaks or the argument it makes, a condition node's to the Only when pin or side it is part of.\n */\nexport const PureNodeView = ({ id, data, selected, isConnectable: editable }: NodeProps<FlowNode>) => {\n const { pureData, moved } = data\n if (!pureData) return null\n const { pure, shownInputs, shownOutputs, folded, open, foldable } = pureData\n return (\n <div className={cn('h-full rounded-lg border border-dashed border-border-strong bg-background text-body shadow-sm', selected && 'ring-2 ring-primary/40')}>\n {moved && <MovedMark node={id} name={titleOf(pure)} />}\n <Title pure={pure} />\n {pure.kind === 'condition' ? (\n <ConditionPins node={pure} editable={editable} />\n ) : pure.kind === 'select' ? (\n <SelectRows node={pure} editable={editable} />\n ) : pure.kind === 'break' ? (\n <div className=\"relative pt-1\">\n <Handle id={breakIn} type=\"target\" position={Position.Left} isConnectable={false} className={`pb-pin pb-pin-${pinColour(pure.type)}`} style={{ top: 13 }} />\n {shownOutputs.map((pin) => (\n <OutputRow key={JSON.stringify(pin.path)} pin={pin} connectable={editable} field />\n ))}\n {foldable && <FoldRow node={pure.id} folded={folded} open={open} fields />}\n </div>\n ) : (\n <div className=\"relative pt-1\">\n <Handle id={makeOut} type=\"source\" position={Position.Right} isConnectable={false} className={`pb-pin pb-pin-${pinColour(pure.type)}`} style={{ top: 13 }} />\n {shownInputs.map((pin) => (\n <InputRow key={pin.key} pin={pin} step={pure.target} keys={[pure.key, pin.key]} connectable={editable} />\n ))}\n <FoldRow node={pure.id} folded={folded} open={open} />\n </div>\n )}\n </div>\n )\n}\n","import { Button } from '../../../../primitives/button'\nimport { text } from '../messages'\n\n/**\n * Where a wire was let go on the empty canvas, and the nodes the pin it came from can have: a Break or a Make for an\n * object pin, the condition nodes for an Only when pin or a side of an And, an Or or a Not.\n */\nexport type PureOffer = { x: number; y: number; choices: { label: string; add: () => void }[] }\n\n/** The offer of the nodes the pin a wire was dragged from can have, at the point it was let go. */\nexport const PureOfferMenu = ({ offer, onClose }: { offer: PureOffer; onClose: () => void }) => (\n <div role=\"dialog\" aria-label={text('pureOfferTitle')} className=\"absolute z-10 grid gap-1 rounded-md border bg-background p-1 shadow-md\" style={{ left: offer.x, top: offer.y }}>\n {offer.choices.map((choice, index) => (\n <Button\n key={choice.label}\n size=\"sm\"\n variant=\"ghost\"\n className=\"justify-start\"\n autoFocus={index === 0}\n onClick={() => {\n choice.add()\n onClose()\n }}\n >\n {choice.label}\n </Button>\n ))}\n <Button size=\"sm\" variant=\"ghost\" onClick={onClose}>\n {text('pureOfferClose')}\n </Button>\n </div>\n)\n","import {\n allStates,\n conditionParts,\n expressionReferences,\n expressionSource,\n inputSchema,\n isConditionPart,\n orderOf,\n parseReference,\n pinType,\n readText,\n referenceValue,\n resultRead,\n schemaAt,\n selectParts,\n stepStatuses,\n type SelectPart,\n type ConditionInput,\n type ConditionPart,\n type Definition,\n type PinSchemas,\n type PinType,\n type Reference,\n type State,\n} from '@protobase/workflows'\nimport { pathOfName, triggerId } from '../definition'\nimport { conditionKey, conditionPin, fieldsOf, givenSchema, inputPin, inputPins, statusKey, statusPin, stepOutputs, triggerOutputs, type InputPin, type OutputPin } from './node-pins'\nimport { breakId, breakIn, conditionId, conditionOut, inHandle, makeId, makeOut, outHandle, selectId, selectInput, selectOut } from './pure-ids'\n\n/** A Break node: the fields of the object a node gives at `path`, each a pin of its own. */\nexport type BreakNode = { kind: 'break'; id: string; source: string; path: string[]; type: PinType; outputs: OutputPin[] }\n\n/** A Make node: the object a step's argument `key` holds, built from a pin per field. */\nexport type MakeNode = { kind: 'make'; id: string; target: string; key: string; type: PinType; inputs: InputPin[] }\n\n/** A Condition no condition nodes stand for, whole: its JSONata, between `{%` and `%}`. */\nexport type ConditionExpression = { kind: 'expression'; source: string }\n\n/**\n * A node of a step's Condition, on the way to its Only when pin in data order: a Comparison, an And, an Or or a Not at\n * `at` among the Condition's nodes, with an input per side, or the whole Condition as an Expression, with a pin per\n * value it reads.\n */\nexport type ConditionNode = { kind: 'condition'; id: string; target: string; at: number[]; part: ConditionPart | ConditionExpression; inputs: InputPin[] }\n\n/**\n * A Select node: the value a step's argument `key` holds, chosen by another, which its one input reads; with a case per\n * value that one can be and what it gives then, and what it gives for any other.\n */\nexport type SelectNode = { kind: 'select'; id: string; target: string; key: string; part: SelectPart; type: PinType; inputs: InputPin[] }\n\nexport type PureNode = BreakNode | MakeNode | ConditionNode | SelectNode\n\n/**\n * A wire from an output pin to an input pin, of the type of the value it carries. `expression`: the input is an\n * expression that reads the value among others, so the wire shows the read, and only changing the expression removes it.\n */\nexport type DataEdge = { id: string; source: string; sourceHandle: string; target: string; targetHandle: string; type: PinType; expression?: true }\n\n/** A Break or Make made on the canvas, which the document holds nothing for until a wire runs through it. */\nexport type LocalPure = { kind: 'break'; source: string; path: string[] } | { kind: 'make'; target: string; key: string }\n\n/** The data side of the graph: every node's pins, the Break, Make and condition nodes, and the wires. */\nexport type DataGraph = { inputs: Map<string, InputPin[]>; outputs: Map<string, OutputPin[]>; pure: PureNode[]; edges: DataEdge[] }\n\nconst isObject = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst samePath = (a: readonly string[], b: readonly string[]) => a.length === b.length && a.every((key, index) => key === b[index])\n\nconst booleanType: PinType = { kinds: ['boolean'] }\n\n// The reads a Condition's nodes make, each once for each side that makes it\nconst partReads = (part: ConditionPart): Reference[] => (part.sides as ConditionInput[]).flatMap((side) => (isConditionPart(side) ? partReads(side) : 'read' in side ? [side.read] : []))\n\n// A read of a step's Status, which the step's status pin gives\nconst readsStatus = (side: ConditionInput) => !isConditionPart(side) && 'read' in side && 'step' in side.read.base && samePath(side.read.path, ['Status'])\n\n// The type of a value of a Comparison's own, by the type of what it is compared with, else by its own\nconst literalType = (value: unknown, other: PinType | undefined): PinType => {\n if (other && other.kinds !== 'any') {\n const kinds = other.kinds.filter((kind) => kind !== 'null')\n if (kinds.length === 1 && ['string', 'integer', 'number', 'boolean'].includes(kinds[0]!)) return { kinds }\n }\n return { kinds: [typeof value === 'number' ? 'number' : typeof value === 'boolean' ? 'boolean' : 'string'] }\n}\n\n// The path of every state that keeps its whole result in a variable, by the variable, when exactly one does.\nconst resultVariables = (definition: Definition) => {\n const found = new Map<string, string | null>()\n for (const [name, state] of allStates(definition.stateMachine)) {\n const assign = 'Assign' in state && isObject(state.Assign) ? state.Assign : {}\n for (const [variable, value] of Object.entries(assign)) {\n const path = value === resultRead ? pathOfName(definition.stateMachine, name)?.join('/') : undefined\n found.set(variable, found.has(variable) || path === undefined ? null : path)\n }\n }\n return found\n}\n\n/**\n * The data side of a definition: each step's input pins and each node's output pins by their types, a wire for each\n * argument that is one read by name, through a Break node for each object a read goes into, a Make node for each\n * argument written as an object whose fields read values, and in data order each Condition as the condition nodes it\n * is made of, or else as an Expression node, with the Breaks and Makes of `local` besides.\n */\nexport const dataGraph = (definition: Definition, schemas: PinSchemas, local: readonly LocalPure[] = []): DataGraph => {\n const states = new Map<string, State>(allStates(definition.stateMachine).map(([name, state]) => [pathOfName(definition.stateMachine, name)!.join('/'), state]))\n // In data order every state has an Only when pin first and a status pin last\n const data = orderOf(definition) === 'data'\n const outputs = new Map<string, OutputPin[]>([[triggerId, triggerOutputs(definition, schemas)], ...[...states].map(([path, state]): [string, OutputPin[]] => [path, [...stepOutputs(state, schemas), ...(data ? [statusPin] : [])]])])\n const inputs = new Map([...states].filter(([, state]) => data || state.Type === 'Task').map(([path, state]) => [path, [...(data ? [conditionPin(state)] : []), ...inputPins(state, schemas)]]))\n const pathOfState = (name: string) => [...states.keys()].find((path) => path.split('/').at(-1) === name)\n const breaks = new Map<string, BreakNode>()\n const makes = new Map<string, MakeNode>()\n const conditions: ConditionNode[] = []\n const selects: SelectNode[] = []\n const edges = new Map<string, DataEdge>()\n const variables = resultVariables(definition)\n\n const wire = (from: { node: string; handle: string; type: PinType }, target: string, targetHandle: string, expression = false) => {\n const id = `data:${from.node}|${from.handle}->${target}|${targetHandle}`\n if (expression && edges.has(id)) return\n edges.set(id, { id, source: from.node, sourceHandle: from.handle, target, targetHandle, type: from.type, ...(expression && { expression: true as const }) })\n }\n const pinOf = (pins: OutputPin[], path: string[]) => {\n let pin = pins.find((each) => samePath(each.path, path))\n if (!pin) {\n pin = { path, type: pinType(undefined) }\n pins.push(pin)\n }\n return pin\n }\n // The pin that gives the value at `path` of what `source` gives: its own, or a field of a Break of the object around it\n const from = (source: string, path: string[]): { node: string; handle: string; type: PinType } => {\n const pins = outputs.get(source)!\n const own = pins.find((pin) => samePath(pin.path, path))\n // A step's status pin in data order is no field of what it gives: a step giving one whole value stays unfielded\n const fielded = pins.some((pin) => pin.path.length > 0 && pin.path[0] !== statusKey)\n if (own || path.length === 0 || (fielded && path.length === 1)) {\n const pin = own ?? pinOf(pins, path)\n return { node: source, handle: outHandle(pin.path), type: pin.type }\n }\n const broken = breakOf(source, path.slice(0, -1))\n const pin = pinOf(broken.outputs, path.slice(-1))\n return { node: broken.id, handle: outHandle(pin.path), type: pin.type }\n }\n const breakOf = (source: string, path: string[]) => {\n const id = breakId(source, path)\n const known = breaks.get(id)\n if (known) return known\n const schema = givenSchema(definition, states.get(source), schemas, path)\n const made: BreakNode = { kind: 'break', id, source, path, type: pinType(schema), outputs: fieldsOf(schema).map(([key, field]) => ({ path: [key], type: pinType(field) })) }\n breaks.set(id, made)\n wire(from(source, path), id, breakIn)\n return made\n }\n // The wires of a value: one for a read by name alone, else one for each read of its expression\n const wireValue = (value: unknown, target: string, targetHandle: string) => {\n const one = sourceOf(value)\n if (one) return wire(one, target, targetHandle)\n for (const reference of expressionReferences(value)) {\n const source = sourceOfReference(reference)\n if (source) wire(source, target, targetHandle, true)\n }\n }\n const sourceOf = (value: unknown) => {\n const reference = parseReference(value)\n return reference && sourceOfReference(reference)\n }\n const sourceOfReference = (reference: Reference) => {\n if ('step' in reference.base) {\n const node = pathOfState(reference.base.step)\n return node === undefined || !outputs.has(node) ? undefined : from(node, [statusKey, ...reference.path])\n }\n const node = 'input' in reference.base ? triggerId : variables.get(reference.base.variable)\n return node === undefined || node === null || !outputs.has(node) ? undefined : from(node, reference.path)\n }\n // A read a condition node takes: a step's Status from its status pin, any other as a step's input takes it\n const sourceOfSide = (side: ConditionInput) => {\n if (isConditionPart(side) || !('read' in side)) return\n if (!readsStatus(side)) return sourceOfReference(side.read)\n const node = pathOfState((side.read.base as { step: string }).step)\n return node === undefined || !outputs.has(node) ? undefined : from(node, [statusKey])\n }\n // Each node of a Condition, its output wired to where it goes, and each side wired from its node or what it reads\n const partOf = (target: string, part: ConditionPart, at: number[], into: { node: string; handle: string }) => {\n const id = conditionId(target, at)\n const sides: ConditionInput[] = part.sides\n const sources = sides.map(sourceOfSide)\n const inputs = sides.map((side, index): InputPin => {\n const key = String(index)\n if (isConditionPart(side)) return { key, type: booleanType, required: false, value: undefined, state: 'made' }\n if ('read' in side) return { key, type: sources[index]?.type ?? pinType(undefined), required: false, value: referenceValue(side.read), state: 'wired' }\n // A Matches node's pattern is its own, written on the node; the text it tests is any text\n if ('pattern' in side) return { key, type: { kinds: ['string'] }, required: false, value: side.pattern, state: 'literal' }\n if (part.kind === 'matches') return { key, type: { kinds: ['string'] }, required: false, value: side.value, state: 'literal' }\n if (part.kind !== 'compare') return { key, type: booleanType, required: false, value: side.value, state: 'literal' }\n // A value compared with a step's Status is one of the statuses it can be\n const other = sides[1 - index]!\n if (readsStatus(other)) return { key, type: { kinds: ['string'] }, required: false, value: side.value, state: 'literal', options: stepStatuses, statuses: true }\n return { key, type: literalType(side.value, sources[1 - index]?.type), required: false, value: side.value, state: 'literal' }\n })\n // An All of or an Any of has one input more, empty, which a wire or a node adds as its next condition\n if (part.kind === 'logic') inputs.push({ key: String(sides.length), type: booleanType, required: false, value: undefined, state: 'empty' })\n conditions.push({ kind: 'condition', id, target, at, part, inputs })\n wire({ node: id, handle: conditionOut, type: booleanType }, into.node, into.handle)\n sides.forEach((side, index) => {\n if (isConditionPart(side)) partOf(target, side, [...at, index], { node: id, handle: inHandle(String(index)) })\n else if (sources[index]) wire(sources[index], id, inHandle(String(index)))\n })\n }\n // A step's Condition as its condition nodes when it is made of them and each read has a pin to come from, else as an\n // Expression node with a pin per value it reads\n const conditionOf = (target: string, value: unknown) => {\n const part = conditionParts(value)\n const into = { node: target, handle: inHandle(conditionKey) }\n if (part && partReads(part).every((read) => sourceOfSide({ read }))) return partOf(target, part, [], into)\n const id = conditionId(target, [])\n const reads = expressionReferences(value).flatMap((read) => {\n const source = sourceOfSide({ read })\n return source ? [{ read, source }] : []\n })\n conditions.push({ kind: 'condition', id, target, at: [], part: { kind: 'expression', source: expressionSource(value)! }, inputs: reads.map(({ read, source }) => ({ key: readText(read), type: source.type, required: false, value: referenceValue(read), state: 'wired' })) })\n wire({ node: id, handle: conditionOut, type: booleanType }, into.node, into.handle)\n for (const { read, source } of reads) wire(source, id, inHandle(readText(read)), true)\n }\n // A step's argument chosen by another value, as a Select node, when what it looks at has a pin to come from\n const selectOf = (target: string, pin: InputPin) => {\n const part = selectParts(pin.value)\n const source = part && sourceOfSide(part.operand)\n if (!part || ('read' in part.operand && !source)) return false\n const id = selectId(target, pin.key)\n const operand: InputPin = 'read' in part.operand\n ? { key: selectInput, type: source!.type, required: false, value: referenceValue(part.operand.read), state: 'wired' }\n : { key: selectInput, type: { kinds: ['string'] }, required: false, value: part.operand.value, state: 'literal' }\n selects.push({ kind: 'select', id, target, key: pin.key, part, type: pin.type, inputs: [operand] })\n wire({ node: id, handle: selectOut, type: pin.type }, target, inHandle(pin.key))\n if (source) wire(source, id, inHandle(selectInput))\n return true\n }\n const makeOf = (target: string, key: string) => {\n const id = makeId(target, key)\n const known = makes.get(id)\n if (known) return known\n const pin = inputs.get(target)?.find((each) => each.key === key)\n const state = states.get(target)!\n const schema = schemaAt(inputSchema(state, schemas), [key])\n const value = isObject(pin?.value) ? pin.value : {}\n const required = new Set(Array.isArray(schema?.required) ? (schema.required as string[]) : [])\n const declared = fieldsOf(schema).map(([field, fieldSchema]) => inputPin(field, fieldSchema, value[field], required.has(field)))\n const extra = Object.keys(value).filter((field) => !declared.some((each) => each.key === field)).map((field) => inputPin(field, schemaAt(schema, [field]) ?? {}, value[field], false))\n const made: MakeNode = { kind: 'make', id, target, key, type: pin?.type ?? pinType(schema), inputs: [...declared, ...extra] }\n makes.set(id, made)\n wire({ node: id, handle: makeOut, type: made.type }, target, inHandle(key))\n for (const field of made.inputs) wireValue(field.value, id, inHandle(field.key))\n return made\n }\n\n for (const [target, pins] of inputs) {\n for (const [index, pin] of pins.entries()) {\n // A Condition that computes is drawn by its nodes, which build it as a Make builds an object\n if (pin.key === conditionKey && pin.state === 'expression') {\n pins[index] = { ...pin, state: 'made' }\n conditionOf(target, pin.value)\n continue\n }\n // A value chosen by another is drawn as a Select node, which builds it as a Make builds an object\n if (pin.state === 'expression' && selectOf(target, pin)) {\n pins[index] = { ...pin, state: 'made' }\n continue\n }\n if (pin.state === 'made') makeOf(target, pin.key)\n if (pin.state === 'wired' || pin.state === 'expression') wireValue(pin.value, target, inHandle(pin.key))\n }\n }\n for (const each of local) {\n if (each.kind === 'break' && outputs.has(each.source)) breakOf(each.source, each.path)\n // A Make made on the canvas stays only while its input holds no read or expression, which a wire would have put there\n if (each.kind === 'make' && inputs.get(each.target)?.some((pin) => pin.key === each.key && pin.state !== 'wired' && pin.state !== 'expression')) makeOf(each.target, each.key)\n }\n return { inputs, outputs, pure: [...breaks.values(), ...makes.values(), ...conditions, ...selects], edges: [...edges.values()] }\n}\n","import { text } from '../messages'\nimport type { WireRefusal } from './data-edits'\nimport { typeLabel } from './pin-text'\n\n/** Why a wire is refused, in words, as the line being drawn says it over the pin it would end at. */\nexport const refusalText = (refusal: WireRefusal) => {\n if (refusal.reason === 'notBefore') return text('refuseNotBefore', { step: refusal.step })\n if (refusal.reason === 'otherScope') return text('refuseOtherScope', { step: refusal.step })\n if (refusal.reason === 'shapesOutput') return text('refuseShaped', { step: refusal.step })\n if (refusal.reason === 'type') return text('refuseType', { source: typeLabel(refusal.source), target: typeLabel(refusal.target) })\n return text('refuseNotPins')\n}\n","import type { Connection, Edge, FinalConnectionState } from '@xyflow/react'\nimport { useEffect, useMemo, useRef, useState, type RefObject } from 'react'\nimport { orderOf, type Definition, type PinSchemas } from '@protobase/workflows'\nimport type { Graph } from '../definition-graph'\nimport type { CanvasEdits } from '../canvas-edits'\nimport { graphId, isPureFlowId } from '../flow-elements'\nimport { text } from '../messages'\nimport type { ConditionChoice } from './condition-edits'\nimport type { PinEnd } from './data-edits'\nimport { lastPlaceFirst, nodePlace, wirePlace } from './removal-order'\nimport { dataGraph, type DataEdge, type LocalPure, type PureNode } from './data-graph'\nimport { conditionKey } from './node-pins'\nimport { nodeSizes, pinPorts } from './node-sizes'\nimport type { PinActions } from './pin-actions'\nimport { conditionTitle, typeLabel } from './pin-text'\nimport type { PureOffer } from './pure-offer'\nimport { breakId, inKey, makeId, outPath } from './pure-ids'\nimport { pureParent } from './pure-parents'\nimport { refusalText } from './refusal-text'\nimport type { WireCheck } from './wire-line'\n\n/** Whether a handle is a pin's, rather than one execution runs along. */\nexport const isPinHandle = (handle: string | null | undefined) => inKey(handle) !== undefined || outPath(handle) !== undefined\n\nconst end = (node: string, handle: string | null | undefined): PinEnd => ({ node: graphId(node), handle: handle ?? '' })\n\nconst isObjectType = (kinds: readonly string[] | 'any') => kinds !== 'any' && kinds.includes('object')\n\n// The offer of each condition node of `choices`, each written where `put` puts it\nconst conditionOffer = (choices: readonly ConditionChoice[], put: (choice: ConditionChoice) => void) => choices.map((choice) => ({ label: conditionTitle(choice), add: () => put(choice) }))\n\n/**\n * The Breaks and Makes made on the canvas that stay once `gone` are removed: those, and each Break made from a field of\n * a removed Break, which takes its object from it.\n */\nexport const localsLeft = (local: readonly LocalPure[], gone: readonly PureNode[]): LocalPure[] => {\n const id = (each: LocalPure) => (each.kind === 'break' ? breakId(each.source, each.path) : makeId(each.target, each.key))\n const under = (each: LocalPure) => each.kind === 'break' && gone.some((parent) => parent.kind === 'break' && parent.source === each.source && parent.path.every((step, index) => each.path[index] === step))\n return local.filter((each) => !under(each) && !gone.some((node) => node.id === id(each)))\n}\n\n/** What an editable canvas's pins change: the definition, through `onChange`, by `edits`. */\nexport type PinEditing = { onChange: (definition: Definition) => void; edits: CanvasEdits }\n\n/**\n * The pins of a canvas, given the schemas their types come from: the data graph with the Break and Make nodes made on\n * the canvas, which inputs are open, what the layout places, and with `editing`, what wiring, unwiring, removing a\n * Break, a Make or a condition node and letting go of a wire on the empty canvas do. Without schemas, no pins.\n */\nexport const usePins = (definition: Definition, graph: Graph, schemas: PinSchemas | undefined, editing: PinEditing | undefined, frame: RefObject<HTMLElement | null>) => {\n const edits = editing?.edits\n const [local, setLocal] = useState<LocalPure[]>([])\n const [open, setOpen] = useState<ReadonlySet<string>>(new Set())\n const [offer, setOffer] = useState<PureOffer>()\n // The definition and editing as they are now, which a choice made in an offer opened before an edit applies to\n const now = useRef({ definition, editing })\n useEffect(() => {\n now.current = { definition, editing }\n })\n const data = useMemo(() => schemas && dataGraph(definition, schemas, local), [definition, schemas, local])\n const dataOrder = orderOf(definition) === 'data'\n const layout = useMemo(() => {\n if (!data) return\n return {\n sizes: nodeSizes(graph, data, open),\n pure: data.pure.map((pure) => ({ id: pure.id, parent: pureParent(graph, pure) })),\n wires: data.edges.map((edge) => ({ id: edge.id, source: edge.source, target: edge.target, sourceHandle: edge.sourceHandle, targetHandle: edge.targetHandle })),\n ports: pinPorts(graph, data, open),\n dataOrder,\n }\n }, [graph, data, open, dataOrder])\n\n const actions: PinActions | undefined = editing && {\n setArgument: (step, keys, value) => editing.onChange(editing.edits.setArgument(definition, step, keys, value)),\n setConditionSide: (step, at, value) => editing.onChange(editing.edits.setConditionSide(definition, step, at, { value })),\n setCondition: (step, value) => editing.onChange(editing.edits.setArgument(definition, step, [conditionKey], value)),\n toggleOpen: (node) => setOpen((current) => (current.has(node) ? new Set([...current].filter((id) => id !== node)) : new Set([...current, node]))),\n }\n const check: WireCheck = (from, to) => {\n if (!data || !edits || !isPinHandle(from.handle) || !isPinHandle(to.handle)) return\n // A wire may be dragged from its input end\n const [start, finish] = outPath(from.handle) ? [from, to] : [to, from]\n const refusal = edits.wireRefusal(definition, data, end(start.node, start.handle), end(finish.node, finish.handle))\n return refusal && refusalText(refusal)\n }\n const isValid = (connection: Connection | Edge) => Boolean(data && edits) && edits!.wireRefusal(definition, data!, end(connection.source, connection.sourceHandle), end(connection.target, connection.targetHandle)) === undefined\n const connect = (connection: Connection) => {\n if (!editing || !data) return\n editing.onChange(editing.edits.connectData(definition, data, end(connection.source, connection.sourceHandle), end(connection.target, connection.targetHandle)))\n }\n // Wires cut and Breaks and Makes removed, from what the other removals left. Cutting the wire a Break takes its object\n // by, or a Make gives its object by, removes that node, which has no place without it.\n const remove = (next: Definition, nodes: readonly { id: string }[], edges: readonly Edge[]) => {\n if (!data || !edits) return next\n let after = next\n const bound = edges.flatMap((edge) => {\n const wire = (edge.data as { wire?: DataEdge } | undefined)?.wire\n const pure = wire && data.pure.find((each) => (each.kind === 'break' && each.id === wire.target) || (each.kind === 'make' && each.id === wire.source))\n return pure ? [{ id: pure.id }] : []\n })\n const gone = [...nodes.filter((node) => isPureFlowId(node.id)), ...bound.filter((node) => !nodes.some((other) => other.id === node.id))]\n // Wires cut and nodes removed, the last inputs of a Condition's nodes first, so none moves another's place\n const cut = edges.flatMap((edge) => {\n const wire = (edge.data as { kind?: string; wire?: DataEdge } | undefined)?.wire\n return wire && !gone.some((node) => node.id === wire.source || node.id === wire.target) ? [{ wire }] : []\n })\n const removed = gone.flatMap((node) => data.pure.filter((each) => each.id === node.id).map((pure) => ({ pure })))\n const removals: ({ wire: DataEdge } | { pure: PureNode })[] = [...cut, ...removed]\n for (const removal of lastPlaceFirst(data, removals, (each) => ('wire' in each ? wirePlace(data, each.wire) : nodePlace(each.pure)))) {\n after = 'wire' in removal ? edits.disconnectData(after, data, removal.wire) : edits.removePure(after, data, removal.pure)\n }\n if (gone.length > 0) setLocal((current) => localsLeft(current, gone.flatMap((node) => data.pure.filter((each) => each.id === node.id))))\n return after\n }\n // A Select chosen in an offer, added to the definition as it is when it is chosen\n const addSelect = (step: string, key: string) => {\n const { definition: current, editing: latest } = now.current\n latest?.onChange(latest.edits.addSelect(current, step, key))\n }\n // A condition node chosen in an offer, added to the definition as it is when it is chosen\n const addCondition = (step: string, at: readonly number[], choice: ConditionChoice) => {\n const { definition: current, editing: latest } = now.current\n latest?.onChange(latest.edits.addCondition(current, step, at, choice))\n }\n // A wire from an object pin let go on the empty canvas offers to take that object apart, or to build it, there; one\n // from an empty Only when pin, or an input of an All of, an Any of or a Not that holds a value or none, the condition nodes\n const connectEnd = (event: MouseEvent | TouchEvent, state: FinalConnectionState) => {\n if (!data || !editing || state.isValid || state.toHandle || !state.fromHandle?.id || !state.fromNode) return\n const node = graphId(state.fromNode.id)\n const handle = state.fromHandle.id\n const point = 'changedTouches' in event ? event.changedTouches[0]! : event\n const box = frame.current?.getBoundingClientRect()\n const at = { x: point.clientX - (box?.left ?? 0), y: point.clientY - (box?.top ?? 0) }\n const path = outPath(handle)\n if (path) {\n const pure = data.pure.find((each) => each.id === node)\n const pins = pure?.kind === 'break' ? pure.outputs : data.outputs.get(node) ?? []\n const type = pins.find((pin) => JSON.stringify(pin.path) === JSON.stringify(path))?.type\n if (!type || !isObjectType(type.kinds)) return\n const source = pure?.kind === 'break' ? { source: pure.source, path: [...pure.path, ...path] } : { source: node, path }\n setOffer({ ...at, choices: [{ label: text('breakTitle', { type: typeLabel(type) }), add: () => setLocal((current) => [...current, { kind: 'break', ...source }]) }] })\n return\n }\n const key = inKey(handle)\n const condition = data.pure.find((each) => each.id === node)\n if (condition?.kind === 'condition') {\n const side = condition.inputs.find((each) => each.key === key)\n // An input of an All of, an Any of or a Not that holds a value, or the empty one after an All of's or Any of's last\n if (!side || (side.state !== 'literal' && side.state !== 'empty') || (condition.part.kind !== 'logic' && condition.part.kind !== 'not')) return\n setOffer({ ...at, choices: conditionOffer(editing.edits.conditionChoices(false), (choice) => addCondition(condition.target, [...condition.at, Number(key)], choice)) })\n return\n }\n const pin = key === undefined ? undefined : data.inputs.get(node)?.find((each) => each.key === key)\n if (pin?.key === conditionKey && pin.state === 'empty') {\n setOffer({ ...at, choices: conditionOffer(editing.edits.conditionChoices(true), (choice) => addCondition(node, [], choice)) })\n return\n }\n // An input of a value, empty or holding one of its own, can have a Select choose it from another value\n if (pin && pin.key !== conditionKey && !isObjectType(pin.type.kinds) && (pin.state === 'empty' || pin.state === 'literal')) {\n setOffer({ ...at, choices: [{ label: text('selectOffer'), add: () => addSelect(node, pin.key) }] })\n return\n }\n if (!pin || !isObjectType(pin.type.kinds) || pin.state === 'wired' || pin.state === 'expression') return\n setOffer({ ...at, choices: [{ label: text('makeTitle', { type: typeLabel(pin.type) }), add: () => setLocal((current) => [...current, { kind: 'make', target: node, key: pin.key }]) }] })\n }\n return { data, open, layout, actions, check, isValid, connect, remove, connectEnd, offer, closeOffer: () => setOffer(undefined) }\n}\n","import { getBezierPath, type ConnectionLineComponentProps } from '@xyflow/react'\nimport { createContext, useContext } from 'react'\nimport type { FlowNode } from '../flow-elements'\n\n/** Why a wire from one handle to another would be refused, in words; undefined when it would not be, or is no wire. */\nexport type WireCheck = (from: { node: string; handle: string }, to: { node: string; handle: string }) => string | undefined\n\nexport const WireCheckContext = createContext<WireCheck | undefined>(undefined)\n\n/**\n * The line drawn while a wire is dragged: over a pin that refuses it, it turns red and says why, such as that text\n * does not fit a whole number, as Blueprints do.\n */\nexport const WireLine = ({ fromX, fromY, toX, toY, fromPosition, toPosition, connectionStatus, fromNode, fromHandle, toNode, toHandle }: ConnectionLineComponentProps<FlowNode>) => {\n const check = useContext(WireCheckContext)\n const [path] = getBezierPath({ sourceX: fromX, sourceY: fromY, sourcePosition: fromPosition, targetX: toX, targetY: toY, targetPosition: toPosition })\n const refused = connectionStatus === 'invalid' && toNode && toHandle?.id && fromHandle.id ? check?.({ node: fromNode.id, handle: fromHandle.id }, { node: toNode.id, handle: toHandle.id }) : undefined\n return (\n <g className={refused ? 'pb-wire-refused' : undefined}>\n <path d={path} fill=\"none\" className=\"react-flow__connection-path\" />\n {refused && (\n <foreignObject x={toX + 12} y={toY - 30} width={260} height={28} className=\"overflow-visible\">\n <div className=\"inline-block rounded border border-danger bg-danger-soft px-1.5 py-0.5 text-xs whitespace-nowrap text-danger-text shadow\">{refused}</div>\n </foreignObject>\n )}\n </g>\n )\n}\n","/*! @license elkjs (https://github.com/kieler/elkjs), Copyright (c) 2019 TypeFox and others, EPL-2.0 OR GPL-3.0-or-later; its source is at that address. */\nimport { useEffect, useMemo, useState } from 'react'\nimport { useElk } from '../../../lib/elk/use-elk'\nimport type { Graph } from './definition-graph'\nimport { elkGraph, layoutElk, type Box, type LayoutExtras } from './graph-layout'\n\n/**\n * The boxes of the graph's nodes, laid out again each time its nodes, edges, sizes or wires change, not when only what\n * a state does changes; until the first layout is done, undefined. A layout that a newer one overtook is dropped.\n */\nexport const useLayout = (graph: Graph, extras?: LayoutExtras) => {\n const engine = useElk()\n const [boxes, setBoxes] = useState<Map<string, Box>>()\n const shape = useMemo(() => JSON.stringify(elkGraph(graph, extras)), [graph, extras])\n useEffect(() => {\n if (!engine) return\n let current = true\n void layoutElk(engine, JSON.parse(shape)).then((laidOut) => {\n if (current) setBoxes(laidOut)\n })\n return () => {\n current = false\n }\n }, [engine, shape])\n return boxes\n}\n","import { Background, Controls, Panel, ReactFlow, ReactFlowProvider, useKeyPress, useReactFlow, useStore, useUpdateNodeInternals, type Connection, type Edge, type EdgeChange, type IsValidConnection, type NodeChange, type XYPosition } from '@xyflow/react'\nimport '@xyflow/react/dist/style.css'\nimport './workflow-canvas.css'\nimport { LayoutGrid } from 'lucide-react'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport type { WorkflowTypeList } from '@protobase/client'\nimport { orderOf, type Definition, type PinSchemas } from '@protobase/workflows'\nimport { triggerId } from './definition'\nimport type { CanvasEdits } from './canvas-edits'\nimport type { AddAt } from './definition-edits'\nimport { definitionGraph, type EdgeKind, type GraphNode } from './definition-graph'\nimport { dataFlowEdges, flowEdges, flowId, flowNodes, graphId, isPureFlowId, pureFlowNodes, unwiredOrderEdges, type FlowNode } from './flow-elements'\nimport { AddAtContext } from './add-at-context'\nimport { StateNode, TriggerNode } from './flow-nodes'\nimport { Button } from '../../../primitives/button'\nimport { Segmented } from '../../../primitives/segmented'\nimport { useGraphView, type GraphView } from './pins/graph-view'\nimport { PinActionsContext } from './pins/pin-actions'\nimport { PureNodeView } from './pins/pure-nodes'\nimport { PureOfferMenu } from './pins/pure-offer'\nimport { pureParent } from './pins/pure-parents'\nimport { isPinHandle, usePins } from './pins/use-pins'\nimport { WireCheckContext, WireLine } from './pins/wire-line'\nimport type { NodeTrace } from './node-trace'\nimport type { NodeProblem } from './problems'\nimport { useLayout } from './use-layout'\nimport { layoutKey, placedBoxes, withoutKey, workflowLayoutOf, type ManualLayout, type WorkflowLayout } from './manual-layout'\nimport { UnpinContext } from './unpin-context'\nimport { text } from './messages'\n\nconst nodeTypes = { state: StateNode, trigger: TriggerNode, pure: PureNodeView }\n\nexport type WorkflowCanvasProps = {\n definition: Definition\n problems: ReadonlyMap<string, NodeProblem[]>\n /** The node chosen, by its graph id: the trigger's, or a state's path. */\n selected: string | undefined\n onSelect: (id: string | undefined) => void\n /** Without it and `edits`, the graph is only shown. */\n onChange?: (definition: Definition) => void\n /** What the canvas edits the definition with, `canvasEdits`, handed over with `onChange` so a canvas that only shows loads none of it. */\n edits?: CanvasEdits\n /** A click on a source handle, rather than a drag from it: a step is to be added there. */\n onAddAt?: (at: AddAt) => void\n /** How each state did in a run, by its path, marked on its node. */\n traces?: ReadonlyMap<string, NodeTrace>\n /** What the check warns of, by node, which a save goes through with. */\n warnings?: ReadonlyMap<string, NodeProblem[]>\n /** The app's types, whose labels name the nodes and whose cache advice marks them. */\n types?: WorkflowTypeList\n /** The schemas pins are typed by: with them, every step shows its inputs and outputs as pins, wired by the reads its arguments make. */\n schemas?: PinSchemas\n /** The canvas is the window, on a page that does not scroll: as a panel opens beside it, what was in its middle stays there. */\n fills?: boolean\n /** Where nodes were moved by hand in each view, by their layout keys, which the layout leaves where they were put. */\n layout?: WorkflowLayout\n /**\n * Without it, no node is moved by hand: with it, a node dragged stays where it is let go in the view shown, and Unpin\n * and Tidy up hand that view's nodes back to the layout.\n */\n onLayoutChange?: (layout: WorkflowLayout) => void\n}\n\n// The machine a node's states lead within: the Maps it is inside, or the trigger's, the whole workflow's.\nconst scopeOf = (node: GraphNode | undefined) => (node?.kind === 'state' ? node.scope.join('/') : '')\n\n// Each new layout is fitted to the canvas, so a change is in sight without zooming by hand, as is the graph tidied up;\n// a node moved by hand moves nothing else in sight.\nconst FitOnLayout = ({ laidOut, tidied }: { laidOut: unknown; tidied: number }) => {\n const flow = useReactFlow()\n useEffect(() => {\n if (laidOut) void flow.fitView({ maxZoom: 1, padding: 0.1 })\n }, [laidOut, tidied])\n return null\n}\n\n// A canvas that fills its page narrows as a panel opens: what was in its middle stays there.\nconst KeepCentre = () => {\n const flow = useReactFlow()\n const width = useStore((state) => state.width)\n const before = useRef(width)\n useEffect(() => {\n const previous = before.current\n before.current = width\n // Only between two measured widths: the first measurement, and one back from a hidden pane, move nothing\n if (previous === 0 || width === 0 || width === previous) return\n const { x, y, zoom } = flow.getViewport()\n void flow.setViewport({ x: x + (width - previous) / 2, y, zoom })\n }, [width, flow])\n return null\n}\n\n// Each new layout measures every node's handles again: a Map's box grows with the states inside it, and its edges\n// leave from where its handles are now.\nconst MeasureOnLayout = ({ laidOut, ids }: { laidOut: unknown; ids: string[] }) => {\n const updateNodeInternals = useUpdateNodeInternals()\n useEffect(() => {\n if (laidOut) updateNodeInternals(ids)\n }, [laidOut])\n return null\n}\n\n// Where nodes dragged are until they are let go, by their canvas ids\nconst notDragged: ReadonlyMap<string, XYPosition> = new Map()\n\nconst Canvas = ({ definition, problems, warnings, selected, onSelect, onChange: changed, edits, onAddAt, traces, types, schemas, fills = false, layout, onLayoutChange }: WorkflowCanvasProps) => {\n const editing = changed && edits && { onChange: changed, edits }\n const graph = useMemo(() => definitionGraph(definition), [definition])\n const frame = useRef<HTMLDivElement>(null)\n // The simple view is the same document drawn without pins: its lines are the execution edges, which stay the lines\n // between steps when the order of steps comes from what they read\n const [view, setView] = useGraphView()\n const pins = usePins(definition, graph, view === 'pins' ? schemas : undefined, editing, frame)\n const laidOut = useLayout(graph, pins.layout)\n const byId = useMemo(() => new Map(graph.nodes.map((node) => [node.id, node])), [graph])\n // The record hands the layout over anew on each render: it changes only when its JSON does. Each view keeps its own.\n const layoutJson = JSON.stringify(layout ?? {})\n const whole = useMemo(() => workflowLayoutOf(layoutJson), [layoutJson])\n const manual = whole[view]\n const changeView = (next: ManualLayout) => onLayoutChange?.({ ...whole, [view]: next })\n // Each node's layout key, by its id on the graph, a Break's or a Make's its own\n const keys = useMemo(() => new Map([...graph.nodes.map((node): [string, string] => [node.id, layoutKey(node.id)]), ...(pins.data?.pure ?? []).map((pure): [string, string] => [pure.id, layoutKey(pure.id, pure)])]), [graph, pins.data])\n const moved = useMemo(() => new Map([...keys].flatMap(([id, key]) => (Object.hasOwn(manual, key) ? [[id, manual[key]!] as const] : []))), [keys, manual])\n // The nodes ELK laid out, with the moved ones where they were put and the others clear of them\n const boxes = useMemo(() => {\n if (!laidOut) return undefined\n const pure = new Map((pins.data?.pure ?? []).map((node) => [node.id, node]))\n const parentOf = (id: string) => {\n const node = byId.get(id)\n return pure.has(id) ? pureParent(graph, pure.get(id)!) : node?.kind === 'state' ? node.parent : undefined\n }\n return placedBoxes(laidOut, moved, parentOf)\n }, [laidOut, moved, byId, graph, pins.data])\n const movable = Boolean(onLayoutChange)\n const [dragged, setDragged] = useState(notDragged)\n const [tidied, setTidied] = useState(0)\n const dataOrder = orderOf(definition) === 'data'\n // The nodes chosen, by their canvas ids, which move together and which Delete removes: Shift-click adds or takes one\n // out, and a Shift-drag box chooses every node it covers. A step's form opens only while it is the one node chosen.\n const [chosen, setChosen] = useState<ReadonlySet<string>>(() => new Set(selected === undefined ? [] : [flowId(selected)]))\n // A step chosen from outside, such as one just added, is the one node chosen; its form closed from outside, it no longer is\n useEffect(() => {\n setChosen((current) => {\n if (selected !== undefined) return current.has(flowId(selected)) ? current : new Set([flowId(selected)])\n return current.size === 1 && !isPureFlowId([...current][0]!) ? new Set() : current\n })\n }, [selected])\n const nodes = useMemo(\n () =>\n [\n ...flowNodes(graph, boxes, problems, selected, traces, types, warnings, pins.data && { data: pins.data, open: pins.open }, dataOrder),\n ...(pins.data ? pureFlowNodes(graph, pins.data, boxes, pins.open) : []),\n ].map((node) => {\n const at = dragged.get(node.id)\n const pinned = moved.has(graphId(node.id))\n return {\n ...node,\n selected: chosen.has(node.id),\n draggable: movable,\n ...(at && { position: at }),\n ...(pinned && { data: { ...node.data, moved: true }, ...(node.ariaLabel && { ariaLabel: `${node.ariaLabel}, ${text('movedByHand')}` }) }),\n }\n }),\n [graph, boxes, problems, selected, traces, types, warnings, pins.data, pins.open, dataOrder, chosen, dragged, moved, movable],\n )\n // The edge chosen, which Delete removes\n const [chosenEdge, setChosenEdge] = useState<string>()\n // In data order with pins, the wires are what the states read, which order them: another line between two states is\n // drawn only where no wire stands for it\n const edges = useMemo(\n () => [...(dataOrder && pins.data ? unwiredOrderEdges(graph, pins.data) : flowEdges(graph, dataOrder)), ...(pins.data ? dataFlowEdges(pins.data) : [])].map((edge) => ({ ...edge, selected: edge.id === chosenEdge })),\n [graph, pins.data, chosenEdge, dataOrder],\n )\n const editable = Boolean(editing)\n\n // A state leads only to a state of its own machine: the trigger to one of the workflow's, a Map's to its own.\n const isValidConnection: IsValidConnection = (connection) => {\n // A wire joins pins, as their types allow; execution runs along the other handles\n if (isPinHandle(connection.sourceHandle) || isPinHandle(connection.targetHandle)) return isPinHandle(connection.sourceHandle) && isPinHandle(connection.targetHandle) && pins.isValid(connection)\n if (connection.targetHandle !== 'in') return false\n const target = byId.get(graphId(connection.target))\n const source = byId.get(graphId(connection.source))\n return target?.kind === 'state' && scopeOf(source) === scopeOf(target)\n }\n // Nodes let go stay where they are, each under its key; one let go where the layout has it stays the layout's\n const drop = (positions: ReadonlyMap<string, XYPosition>) => {\n setDragged(notDragged)\n const placed = [...positions].flatMap(([node, at]): [string, XYPosition][] => {\n const id = graphId(node)\n const key = keys.get(id)\n const box = boxes?.get(id)\n const point = { x: Math.round(at.x), y: Math.round(at.y) }\n if (key === undefined || (!moved.has(id) && box && Math.round(box.x) === point.x && Math.round(box.y) === point.y)) return []\n return [[key, point]]\n })\n if (placed.length > 0) changeView({ ...manual, ...Object.fromEntries(placed) })\n }\n const unpin = onLayoutChange && ((node: string) => {\n const key = keys.get(graphId(node))\n if (key !== undefined) changeView(withoutKey(manual, key))\n })\n const tidy = () => {\n changeView({})\n setTidied((count) => count + 1)\n }\n const onNodesChange = (changes: NodeChange<FlowNode>[]) => {\n // A node follows the pointer while dragged, and the arrow keys move the chosen one, each move let go at once\n const dropped = new Map<string, XYPosition>()\n for (const change of changes) {\n if (change.type !== 'position' || !change.position || !movable) continue\n const at = change.position\n if (change.dragging) setDragged((current) => new Map(current).set(change.id, at))\n else dropped.set(change.id, at)\n }\n if (dropped.size > 0) drop(dropped)\n const choices = changes.filter((change) => change.type === 'select')\n if (choices.length === 0) return\n const next = new Set(chosen)\n for (const change of choices) {\n if (change.selected) next.add(change.id)\n else next.delete(change.id)\n }\n setChosen(next)\n // A step's form opens when it is chosen alone, by a plain click or the keyboard; a Break, a Make or several nodes\n // chosen open none. A choice made with Shift or a box never opens one, not even while it holds one step on the way.\n const [only] = next.size === 1 ? [...next] : []\n const step = only === undefined || isPureFlowId(only) ? undefined : graphId(only)\n if (step !== undefined && (shiftHeld || boxing.current)) return selected === undefined ? undefined : onSelect(undefined)\n if (step !== selected) onSelect(step)\n }\n // Whether a choice is being made with Shift or a box, which opens no step's form\n const shiftHeld = useKeyPress('Shift')\n const boxing = useRef(false)\n const onEdgesChange = (changes: EdgeChange[]) => {\n for (const change of changes) {\n if (change.type !== 'select') continue\n if (change.selected) setChosenEdge(change.id)\n else setChosenEdge((current) => (current === change.id ? undefined : current))\n }\n }\n const onConnect = (connection: Connection) => {\n if (!editing || !connection.sourceHandle) return\n if (isPinHandle(connection.sourceHandle)) return pins.connect(connection)\n editing.onChange(editing.edits.connect(definition, connection.sourceHandle as EdgeKind, graphId(connection.source), graphId(connection.target)))\n }\n // Deleting a state takes the edges to it along: its own removal does that, so they are left alone here.\n const onDelete = ({ nodes: gone, edges: cut }: { nodes: { id: string }[]; edges: Edge[] }) => {\n if (!editing) return\n const removed = gone.filter((node) => !isPureFlowId(node.id)).map((node) => graphId(node.id)).filter((id) => id !== triggerId)\n let next = pins.remove(definition, gone, cut)\n for (const edge of cut) {\n const data = edge.data as { kind: EdgeKind; field: string; source: string }\n if ((data.kind as string) === 'data') continue\n if (!removed.includes(data.source) && !removed.includes(graphId(edge.target))) next = editing.edits.disconnect(next, data)\n }\n // A Map's states go with it\n for (const path of removed) if (!removed.some((other) => path.startsWith(`${other}/`))) next = editing.edits.removeState(next, path)\n editing.onChange(next)\n }\n\n return (\n <AddAtContext.Provider value={editing ? onAddAt : undefined}>\n <UnpinContext.Provider value={unpin}>\n <PinActionsContext.Provider value={pins.actions}>\n <WireCheckContext.Provider value={pins.check}>\n <div ref={frame} className=\"relative h-full w-full\">\n <ReactFlow\n className=\"pb-workflow\"\n nodes={nodes}\n edges={edges}\n nodeTypes={nodeTypes}\n nodesDraggable={movable}\n // A click that slips a pixel or two moves nothing, and a node moved is not chosen: its form would narrow the\n // canvas under the pointer\n nodeDragThreshold={4}\n selectNodesOnDrag={false}\n nodesConnectable={editable}\n // A click on a handle adds a step there; a connection is drawn by dragging, from a few pixels on\n connectOnClick={false}\n connectionDragThreshold={4}\n edgesFocusable={editable}\n elementsSelectable\n deleteKeyCode={editable ? ['Backspace', 'Delete'] : null}\n onNodesChange={onNodesChange}\n onEdgesChange={onEdgesChange}\n isValidConnection={isValidConnection}\n onConnect={onConnect}\n onConnectEnd={pins.connectEnd}\n connectionLineComponent={WireLine}\n onDelete={onDelete}\n // Shift adds a node to the choice or takes it out, as a Shift-drag box adds every node it covers\n multiSelectionKeyCode=\"Shift\"\n onSelectionStart={() => void (boxing.current = true)}\n onSelectionEnd={() => void (boxing.current = false)}\n // A click on a step chooses it alone, opening its form; with Shift it only adds to the choice, in onNodesChange\n onNodeClick={(event, node) => !event.shiftKey && !isPureFlowId(node.id) && onSelect(graphId(node.id))}\n onPaneClick={() => onSelect(undefined)}\n // As in Blueprints: the wheel zooms towards the pointer, as does a pinch, and dragging the empty canvas with\n // the left, middle or right button pans it; Shift-drag selects a box. A trackpad's two-finger scroll is a\n // wheel too, so it zooms: telling it from a mouse's wheel would be a guess. Over the canvas the page does\n // not scroll; elsewhere it does.\n zoomOnScroll\n panOnScroll={false}\n panOnDrag={[0, 1, 2]}\n selectionOnDrag={false}\n selectionKeyCode=\"Shift\"\n preventScrolling\n onPaneContextMenu={(event) => event.preventDefault()}\n minZoom={0.2}\n maxZoom={1.5}\n aria-label={text('canvas')}\n >\n <Background gap={16} />\n {schemas && (\n <Panel position=\"top-left\">\n <Segmented<GraphView> label={text('graphView')} value={view} onChange={setView} options={[{ value: 'pins', label: text('viewPins') }, { value: 'simple', label: text('viewSimple') }]} />\n </Panel>\n )}\n {movable && Object.keys(manual).length > 0 && (\n <Panel position=\"top-right\">\n <Button title={text('tidyUpHelp')} onClick={tidy}>\n <LayoutGrid className=\"size-3.5\" aria-hidden />\n {text('tidyUp')}\n </Button>\n </Panel>\n )}\n <Controls showInteractive={false} />\n <FitOnLayout laidOut={laidOut} tidied={tidied} />\n {fills && <KeepCentre />}\n <MeasureOnLayout laidOut={boxes} ids={nodes.map((node) => node.id)} />\n </ReactFlow>\n {pins.offer && <PureOfferMenu offer={pins.offer} onClose={pins.closeOffer} />}\n </div>\n </WireCheckContext.Provider>\n </PinActionsContext.Provider>\n </UnpinContext.Provider>\n </AddAtContext.Provider>\n )\n}\n\n/**\n * The workflow's graph on a canvas, laid out by ELK each time it changes: the trigger, a node per state, a Map's states\n * inside it, and an edge per state it leads to. With `onChange` and `edits`, dragging from a handle connects states, a click on\n * one asks `onAddAt` for a step there, Delete removes the chosen state or edge, and each change is the definition edited.\n * With `onLayoutChange`, a node dragged stays where it is let go in the view shown, Pins or Simple, each keeping its own\n * places, marked, until Unpin on it or Tidy up hands it back to ELK, which lays the others out around it.\n */\nexport const WorkflowCanvas = (props: WorkflowCanvasProps) => (\n <ReactFlowProvider>\n <Canvas {...props} />\n </ReactFlowProvider>\n)\n"],"ignoreList":[0],"mappings":"83CASA,IAAM4F,GAAa,CACjB,KAAM,MACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CACE,OACA,CACE,EAAG,6MACH,IAAK,QACP,CACF,CACF,CACF,EACAA,GAAW,KACX,IAAMC,GAAMxD,EAAiBuD,EAAU,aCfjCG,GAA+C,CACnD,eAAkBjB,EAAK,UAAU,EACjC,yBAA4BA,EAAK,mBAAmB,EACpD,yBAA4BA,EAAK,mBAAmB,EACpD,sBAAyBA,EAAK,gBAAgB,EAC9C,uBAA0BA,EAAK,iBAAiB,EAChD,oBAAuBA,EAAK,cAAc,EAC1C,wBAA2BA,EAAK,kBAAkB,EAClD,gBAAmBA,EAAK,WAAW,CACrC,EAEakB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