@w6w/embed 0.2.1 → 0.2.19

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 (185) hide show
  1. package/README.md +22 -5
  2. package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
  3. package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
  4. package/dist/{CreateFunctionModal-DRsFx-FB.js → CreateFunctionModal-DScxp_LN.js} +25 -25
  5. package/dist/{CreateFunctionModal-DRsFx-FB.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
  6. package/dist/{DocumentFormModal-BExK1V-B.js → DocumentFormModal-Br4s8wmi.js} +5 -5
  7. package/dist/{DocumentFormModal-BExK1V-B.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
  8. package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
  9. package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
  10. package/dist/ModelRoutesManager-1Ac5wcas.js +345 -0
  11. package/dist/ModelRoutesManager-1Ac5wcas.js.map +1 -0
  12. package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
  13. package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
  14. package/dist/apps-ItBvnWX3.js +92 -0
  15. package/dist/apps-ItBvnWX3.js.map +1 -0
  16. package/dist/{callables-3mFrMVG_.js → callables-tOlflvbl.js} +11 -11
  17. package/dist/{callables-3mFrMVG_.js.map → callables-tOlflvbl.js.map} +1 -1
  18. package/dist/chrome/ConfirmModal.d.ts +4 -1
  19. package/dist/chrome/DangerZone.d.ts +4 -3
  20. package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
  21. package/dist/chrome/JsonToggle.d.ts +29 -20
  22. package/dist/chrome/Modal.d.ts +3 -1
  23. package/dist/chrome/RightRail.d.ts +6 -1
  24. package/dist/chrome/VersionHistoryModal.d.ts +2 -0
  25. package/dist/chrome/index.d.ts +1 -0
  26. package/dist/chrome/workspace.d.ts +36 -1
  27. package/dist/coerce-input-DFJ4n_wc.js +150 -0
  28. package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
  29. package/dist/connections-CzsCyIxY.js +119 -0
  30. package/dist/connections-CzsCyIxY.js.map +1 -0
  31. package/dist/credentials-Cn92LGhJ.js +171 -0
  32. package/dist/credentials-Cn92LGhJ.js.map +1 -0
  33. package/dist/data-stores-UeQvwVCa.js +170 -0
  34. package/dist/data-stores-UeQvwVCa.js.map +1 -0
  35. package/dist/document-sources-DNmBojx6.js +169 -0
  36. package/dist/document-sources-DNmBojx6.js.map +1 -0
  37. package/dist/draft/use-workflow-draft.d.ts +2 -0
  38. package/dist/draft.mjs +2 -2
  39. package/dist/editor/BindingBanner.d.ts +13 -0
  40. package/dist/editor/CallableEditorFrame.d.ts +7 -0
  41. package/dist/editor/EndpointCards.d.ts +4 -1
  42. package/dist/editor/PublishControl.d.ts +19 -0
  43. package/dist/editor/PublishTooltip.d.ts +7 -0
  44. package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
  45. package/dist/editor/StartingStateModal.d.ts +14 -0
  46. package/dist/editor/TargetSelector.d.ts +15 -0
  47. package/dist/editor/TargetSelector.types.d.ts +2 -0
  48. package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
  49. package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
  50. package/dist/editor/definition.d.ts +6 -0
  51. package/dist/editor/json-apply.d.ts +29 -0
  52. package/dist/editor/step-problems-feed.d.ts +5 -0
  53. package/dist/editor/types.d.ts +2 -2
  54. package/dist/editor-apps-DkkC7wOQ.js +152 -0
  55. package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
  56. package/dist/editor-tools-BR27RGto.js +1683 -0
  57. package/dist/editor-tools-BR27RGto.js.map +1 -0
  58. package/dist/editor.mjs +1 -1
  59. package/dist/editors.mjs +855 -650
  60. package/dist/editors.mjs.map +1 -1
  61. package/dist/{endpoints-B2ynbZo-.js → endpoints-DSRo1Lc5.js} +113 -107
  62. package/dist/endpoints-DSRo1Lc5.js.map +1 -0
  63. package/dist/fields-DvS8XZFc.js +21 -0
  64. package/dist/fields-DvS8XZFc.js.map +1 -0
  65. package/dist/forms/ModelBudgetsManager.d.ts +9 -0
  66. package/dist/forms/ModelRoutesManager.d.ts +14 -0
  67. package/dist/forms.d.ts +4 -0
  68. package/dist/forms.mjs +611 -212
  69. package/dist/forms.mjs.map +1 -1
  70. package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
  71. package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
  72. package/dist/index.mjs +154 -117
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/lib/binding-problems.d.ts +42 -0
  75. package/dist/lib/code-rail.d.ts +4 -2
  76. package/dist/lib/history-query.d.ts +45 -0
  77. package/dist/lib/import-bindings.d.ts +89 -0
  78. package/dist/lib/index.d.ts +4 -0
  79. package/dist/lib/invoke-error.d.ts +1 -0
  80. package/dist/lib/rail-settings.d.ts +1 -1
  81. package/dist/lib/sdk-snippets.d.ts +1 -1
  82. package/dist/lib/setup-incomplete.d.ts +22 -0
  83. package/dist/lib/starting-data.d.ts +31 -0
  84. package/dist/lib/state-panel.d.ts +29 -0
  85. package/dist/lib/target-fields.d.ts +11 -15
  86. package/dist/lib/trigger-preview.d.ts +1 -0
  87. package/dist/lib/workflow-live-run.d.ts +93 -8
  88. package/dist/lib/workflow-nodes.d.ts +5 -0
  89. package/dist/lib/workflow-validity.d.ts +65 -16
  90. package/dist/lib/workflow-variables.d.ts +1 -1
  91. package/dist/lib/workflow-version.d.ts +2 -0
  92. package/dist/lib.mjs +86 -69
  93. package/dist/lists/ConnectionDependents.d.ts +31 -0
  94. package/dist/lists/ConnectionDetail.d.ts +4 -1
  95. package/dist/lists/ConnectionList.d.ts +4 -1
  96. package/dist/lists/CredentialDetail.d.ts +15 -0
  97. package/dist/lists/CredentialList.d.ts +14 -0
  98. package/dist/lists/DataStoreList.d.ts +17 -0
  99. package/dist/lists/DataStoreView.d.ts +19 -0
  100. package/dist/lists/Logs.d.ts +19 -0
  101. package/dist/lists/ModelCatalog.d.ts +12 -0
  102. package/dist/lists/ModelUsage.d.ts +12 -0
  103. package/dist/lists.d.ts +14 -0
  104. package/dist/lists.mjs +1766 -609
  105. package/dist/lists.mjs.map +1 -1
  106. package/dist/models-bAayQPJ_.js +270 -0
  107. package/dist/models-bAayQPJ_.js.map +1 -0
  108. package/dist/{project-context-BiCjv_E3.js → project-context-Tvp-La7A.js} +3 -3
  109. package/dist/{project-context-BiCjv_E3.js.map → project-context-Tvp-La7A.js.map} +1 -1
  110. package/dist/rail/ConnectionsTool.d.ts +2 -0
  111. package/dist/rail/HistoryTool.d.ts +2 -0
  112. package/dist/rail/StartingStateTool.d.ts +2 -0
  113. package/dist/rail/settings-sections.d.ts +4 -1
  114. package/dist/rail.mjs +4 -4
  115. package/dist/repos/agents-studio-agents.d.ts +52 -0
  116. package/dist/repos/agents-studio-assets.d.ts +68 -0
  117. package/dist/repos/connections.d.ts +30 -12
  118. package/dist/repos/constants.d.ts +12 -0
  119. package/dist/repos/credentials.d.ts +83 -0
  120. package/dist/repos/data-stores.d.ts +84 -0
  121. package/dist/repos/endpoints.d.ts +9 -3
  122. package/dist/repos/fields.d.ts +34 -0
  123. package/dist/repos/functions.d.ts +7 -5
  124. package/dist/repos/history.d.ts +9 -0
  125. package/dist/repos/index.d.ts +7 -0
  126. package/dist/repos/models.d.ts +289 -0
  127. package/dist/repos/spec-export.d.ts +3 -3
  128. package/dist/repos/spec-import.d.ts +30 -1
  129. package/dist/repos/step-tests.d.ts +2 -0
  130. package/dist/repos/webhook-listen.d.ts +35 -0
  131. package/dist/repos/workflows.d.ts +105 -2
  132. package/dist/repos.mjs +655 -176
  133. package/dist/repos.mjs.map +1 -1
  134. package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
  135. package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
  136. package/dist/{slug-C4ktDPdy.js → slug-BVdgiP_L.js} +64 -60
  137. package/dist/slug-BVdgiP_L.js.map +1 -0
  138. package/dist/{spec-export-Cf3VQSQS.js → spec-export-DGy5ijps.js} +73 -60
  139. package/dist/spec-export-DGy5ijps.js.map +1 -0
  140. package/dist/spec-import-SWOonsNr.js +116 -0
  141. package/dist/spec-import-SWOonsNr.js.map +1 -0
  142. package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
  143. package/dist/step-tests-B4E4W3ly.js.map +1 -0
  144. package/dist/theme-context-E2ZhlXDX.js +6 -0
  145. package/dist/theme-context-E2ZhlXDX.js.map +1 -0
  146. package/dist/theme-context.d.ts +2 -0
  147. package/dist/{use-callable-draft-zHLpcr-b.js → use-callable-draft-DCauHt5o.js} +23 -23
  148. package/dist/{use-callable-draft-zHLpcr-b.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
  149. package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
  150. package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
  151. package/dist/{workflow-blank-DyL3_RUA.js → workflow-blank-DFpGObrn.js} +6 -6
  152. package/dist/{workflow-blank-DyL3_RUA.js.map → workflow-blank-DFpGObrn.js.map} +1 -1
  153. package/dist/workflows-BZN4Hyz1.js +623 -0
  154. package/dist/workflows-BZN4Hyz1.js.map +1 -0
  155. package/package.json +3 -2
  156. package/src/styles.css +155 -7
  157. package/dist/ConfirmModal-RLbZT5_k.js +0 -181
  158. package/dist/ConfirmModal-RLbZT5_k.js.map +0 -1
  159. package/dist/ImportSpecModal-BDQIf6rg.js +0 -136
  160. package/dist/ImportSpecModal-BDQIf6rg.js.map +0 -1
  161. package/dist/WorkflowEditor-DlbVv6Fs.js +0 -854
  162. package/dist/WorkflowEditor-DlbVv6Fs.js.map +0 -1
  163. package/dist/apps-1FNUwbGv.js +0 -77
  164. package/dist/apps-1FNUwbGv.js.map +0 -1
  165. package/dist/coerce-input-BicYr7nc.js +0 -139
  166. package/dist/coerce-input-BicYr7nc.js.map +0 -1
  167. package/dist/connections-CjjYeRqb.js +0 -78
  168. package/dist/connections-CjjYeRqb.js.map +0 -1
  169. package/dist/document-sources-C0grrtdq.js +0 -86
  170. package/dist/document-sources-C0grrtdq.js.map +0 -1
  171. package/dist/editor-apps-BdenSV1o.js +0 -95
  172. package/dist/editor-apps-BdenSV1o.js.map +0 -1
  173. package/dist/editor-tools-RxmY5iyi.js +0 -1279
  174. package/dist/editor-tools-RxmY5iyi.js.map +0 -1
  175. package/dist/endpoints-B2ynbZo-.js.map +0 -1
  176. package/dist/rail-settings-XYGToh00.js.map +0 -1
  177. package/dist/slug-C4ktDPdy.js.map +0 -1
  178. package/dist/spec-export-Cf3VQSQS.js.map +0 -1
  179. package/dist/spec-import-CjmxyZDR.js +0 -465
  180. package/dist/spec-import-CjmxyZDR.js.map +0 -1
  181. package/dist/step-tests-CivICmTq.js.map +0 -1
  182. package/dist/trigger-preview-VPkrryDl.js +0 -120
  183. package/dist/trigger-preview-VPkrryDl.js.map +0 -1
  184. package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
  185. package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
@@ -0,0 +1,1109 @@
1
+ import { jsxs as g, jsx as a, Fragment as le } from "react/jsx-runtime";
2
+ import { useQueryClient as Ot, useQueries as Re } from "@tanstack/react-query";
3
+ import { ApiError as Ce } from "@w6w/sdk";
4
+ import { Modal as fn, IconButton as ce, JsonEditor as pn, useExpressionOptions as hn, ExpressionEditorModal as mn, useW6WApi as It, W6WUIProvider as bn, isTestRequired as Ct, requiredParamsFilled as gn, ExecutionLogPanel as yn, testInputSavesSettled as vn } from "@w6w/ui";
5
+ import { useState as y, useMemo as v, createElement as J, useId as wn, useCallback as E, useContext as Sn, useRef as w, useEffect as T, Suspense as kn, lazy as Nn } from "react";
6
+ import { E as En, $ as Rn, W as Cn, Q as Pn, V as An, q as Tn, X as jn, v as On, B as In, A as Fn, N as Ln, a as Mn, z as Jn, n as Dn, y as Bn, t as Wn, b as $n } from "./workflows-BZN4Hyz1.js";
7
+ import { H as xn, a as Kn } from "./editor-apps-DkkC7wOQ.js";
8
+ import { M as ue } from "./ConfirmModal-Pv2-A_3U.js";
9
+ import { d as Qn, W as _n, e as qn, R as Vn, P as Hn, b as zn, c as Gn } from "./editor-tools-BR27RGto.js";
10
+ import { u as Yn } from "./client-context-CX61Bgw-.js";
11
+ import { u as Un } from "./use-workflow-draft-l3P5KZzw.js";
12
+ import { r as Xn, h as Zn, e as es, f as ts, a as ns, d as ss, b as os, p as is, i as rs, g as as } from "./setup-incomplete-BHs3Lpfy.js";
13
+ import { g as Pt, r as ls, c as cs, v as us } from "./document-sources-DNmBojx6.js";
14
+ import { n as At } from "./import-bindings-EUtxZ9Ti.js";
15
+ import { p as ds, d as fs } from "./settings-rail--GdRMusb.js";
16
+ import { u as ps, b as hs } from "./project-context-Tvp-La7A.js";
17
+ import { i as ms, d as Tt } from "./connections-CzsCyIxY.js";
18
+ import { h as bs, b as gs, g as ys, d as vs, u as ws, e as Ss } from "./spec-export-DGy5ijps.js";
19
+ import { l as jt, a as Pe, w as ks } from "./step-tests-B4E4W3ly.js";
20
+ import { i as Ns, f as Es } from "./vault-BSEWhMYC.js";
21
+ import { i as Rs } from "./data-stores-UeQvwVCa.js";
22
+ import { e as Cs } from "./apps-ItBvnWX3.js";
23
+ import { E as Ps } from "./theme-context-E2ZhlXDX.js";
24
+ import { validateInitialState as As } from "@w6w/expr";
25
+ function Ts({ title: s }) {
26
+ const { value: e, placeholder: r, maxLength: i, ariaLabel: n, onChange: l, onBlur: u } = s;
27
+ return /* @__PURE__ */ a(
28
+ "input",
29
+ {
30
+ className: "wf-title-input",
31
+ value: e,
32
+ placeholder: r,
33
+ maxLength: i,
34
+ size: Math.min(Math.max(e.length, r.length), 80),
35
+ "aria-label": n,
36
+ onChange: (d) => l(d.target.value),
37
+ onBlur: u
38
+ }
39
+ );
40
+ }
41
+ function js({
42
+ onBack: s,
43
+ backLabel: e,
44
+ title: r,
45
+ titleAdornment: i,
46
+ actions: n
47
+ }) {
48
+ return /* @__PURE__ */ g("div", { className: "wf-fullbleed-head", children: [
49
+ e !== null && /* @__PURE__ */ a(
50
+ "button",
51
+ {
52
+ type: "button",
53
+ className: "muted wf-back-btn",
54
+ "data-testid": "wf-editor-back",
55
+ onClick: s,
56
+ children: e
57
+ }
58
+ ),
59
+ r.editable ? /* @__PURE__ */ a(Ts, { title: r }) : /* @__PURE__ */ g("h2", { className: "exec-profile-title", children: [
60
+ r.value,
61
+ " ",
62
+ i
63
+ ] }),
64
+ /* @__PURE__ */ g("div", { className: "wf-head-actions", style: { marginLeft: "auto" }, children: [
65
+ r.editable && i,
66
+ n
67
+ ] })
68
+ ] });
69
+ }
70
+ function Os(s, e, r) {
71
+ if (!(s !== "workflow" || e === void 0))
72
+ return (i) => {
73
+ r(), e(i.id);
74
+ };
75
+ }
76
+ function Is(s) {
77
+ const { kind: e, id: r, onClose: i, onOpenRun: n } = s, [l, u] = y(En), d = Os(e, n, i);
78
+ return /* @__PURE__ */ a(
79
+ fn,
80
+ {
81
+ size: "full",
82
+ title: "History",
83
+ subtitle: r,
84
+ onClose: i,
85
+ headerRight: /* @__PURE__ */ a(ce, { icon: "close", label: "Close", onClick: i }),
86
+ children: /* @__PURE__ */ a("div", { className: "w6w-modal-body", children: /* @__PURE__ */ a(
87
+ xn,
88
+ {
89
+ scope: { callable: r },
90
+ showKind: !1,
91
+ filters: l,
92
+ onFiltersChange: u,
93
+ onOpenInEditor: d
94
+ }
95
+ ) })
96
+ }
97
+ );
98
+ }
99
+ function Fs(s) {
100
+ return /* @__PURE__ */ a(ce, { icon: "json", onClick: s.onClick, label: "Edit raw JSON definition" });
101
+ }
102
+ function Ls(s) {
103
+ return s.open ? s.mode === "apply" ? /* @__PURE__ */ a(Ms, { ...s }) : /* @__PURE__ */ a(Js, { ...s }) : null;
104
+ }
105
+ function Ft(s) {
106
+ return /* @__PURE__ */ a("div", { className: "json-toggle-editor", children: /* @__PURE__ */ a(
107
+ pn,
108
+ {
109
+ value: s.value,
110
+ onChange: s.onChange,
111
+ minHeight: "120px",
112
+ "aria-label": s.label
113
+ }
114
+ ) });
115
+ }
116
+ function Ms(s) {
117
+ const { onClose: e, title: r, value: i, prepareApply: n, onApply: l, editorLabel: u } = s, [d, S] = y(i), [h, m] = y(i), [j, z] = y([]), [de, I] = y(!1), C = v(
118
+ () => (n == null ? void 0 : n(d)) ?? { ok: !0, text: d, restored: [] },
119
+ [n, d]
120
+ ), D = d !== h, G = () => D ? I(!0) : e(), Y = () => {
121
+ !C.ok || !D || (l == null || l(C.text), S(C.text), m(C.text), z(C.restored), I(!1));
122
+ };
123
+ return /* @__PURE__ */ g(ue, { title: r, onClose: G, wide: !0, className: "modal-json", children: [
124
+ /* @__PURE__ */ g("div", { className: "modal-body", children: [
125
+ /* @__PURE__ */ g("p", { className: "muted small", children: [
126
+ "Edit the raw definition (",
127
+ /* @__PURE__ */ a("code", { children: 'manifestVersion: "2"' }),
128
+ "). Apply updates the visual editor; Save stores it."
129
+ ] }),
130
+ /* @__PURE__ */ a(
131
+ Ft,
132
+ {
133
+ value: d,
134
+ onChange: (U) => {
135
+ S(U), I(!1);
136
+ },
137
+ label: u
138
+ }
139
+ ),
140
+ !C.ok && /* @__PURE__ */ a("p", { className: "error small", role: "alert", "data-testid": "json-toggle-error", children: C.error }),
141
+ j.length > 0 && /* @__PURE__ */ g("p", { className: "muted small", "data-testid": "json-toggle-restored", children: [
142
+ "Restored ",
143
+ j.join(", "),
144
+ ": ",
145
+ j.length > 1 ? "these fields" : "this field",
146
+ " ",
147
+ "can't be changed in JSON."
148
+ ] })
149
+ ] }),
150
+ /* @__PURE__ */ a("div", { className: "modal-actions", children: de ? /* @__PURE__ */ g(le, { children: [
151
+ /* @__PURE__ */ a("span", { className: "muted small json-toggle-confirm", children: "Discard unapplied changes?" }),
152
+ /* @__PURE__ */ a("button", { type: "button", className: "btn ghost", onClick: () => I(!1), children: "Keep editing" }),
153
+ /* @__PURE__ */ a(
154
+ "button",
155
+ {
156
+ type: "button",
157
+ className: "btn danger",
158
+ "data-testid": "json-toggle-discard",
159
+ onClick: e,
160
+ children: "Discard"
161
+ }
162
+ )
163
+ ] }) : /* @__PURE__ */ g(le, { children: [
164
+ /* @__PURE__ */ a(
165
+ "button",
166
+ {
167
+ type: "button",
168
+ className: "btn ghost",
169
+ "data-testid": "json-toggle-close",
170
+ onClick: G,
171
+ children: "Close"
172
+ }
173
+ ),
174
+ /* @__PURE__ */ a(
175
+ "button",
176
+ {
177
+ type: "button",
178
+ className: "btn",
179
+ "data-testid": "json-toggle-apply",
180
+ disabled: !C.ok || !D,
181
+ onClick: Y,
182
+ children: "Apply"
183
+ }
184
+ )
185
+ ] }) })
186
+ ] });
187
+ }
188
+ function Js(s) {
189
+ const { onClose: e, title: r, value: i, onChange: n, guard: l, onSave: u, saving: d, error: S, editorLabel: h } = s, m = (l == null ? void 0 : l(i)) ?? null;
190
+ return /* @__PURE__ */ g(ue, { title: r, onClose: e, wide: !0, className: "modal-json", children: [
191
+ /* @__PURE__ */ g("div", { className: "modal-body", children: [
192
+ /* @__PURE__ */ a("p", { className: "muted small", children: "Save replaces the stored definition." }),
193
+ /* @__PURE__ */ a(Ft, { value: i, onChange: (j) => n == null ? void 0 : n(j), label: h }),
194
+ m && /* @__PURE__ */ a("p", { className: "muted small", "data-testid": "json-toggle-reason", children: m }),
195
+ S && /* @__PURE__ */ a("div", { className: "error", children: S })
196
+ ] }),
197
+ /* @__PURE__ */ g("div", { className: "modal-actions", children: [
198
+ /* @__PURE__ */ a("button", { type: "button", className: "btn ghost", onClick: e, children: "Cancel" }),
199
+ /* @__PURE__ */ a(
200
+ "button",
201
+ {
202
+ type: "button",
203
+ className: "btn",
204
+ "data-testid": "json-toggle-save",
205
+ disabled: m != null || !!d,
206
+ onClick: u,
207
+ children: d ? "Saving…" : "Save"
208
+ }
209
+ )
210
+ ] })
211
+ ] });
212
+ }
213
+ function Ds(s, e) {
214
+ const r = (n) => Array.isArray(n) ? n.map(r) : n !== null && typeof n == "object" ? Object.fromEntries(
215
+ Object.entries(n).sort(([l], [u]) => l.localeCompare(u)).map(([l, u]) => [l, r(u)])
216
+ ) : n, i = (n) => {
217
+ if (n === null || typeof n != "object" || Array.isArray(n)) return n;
218
+ const { status: l, ...u } = n;
219
+ return { ...u, key: u.key ?? null, tags: u.tags ?? [] };
220
+ };
221
+ return JSON.stringify(r(i(s))) === JSON.stringify(r(i(e)));
222
+ }
223
+ function Bs(s) {
224
+ const { kind: e, problemCount: r, canEnable: i, onEnable: n, pending: l } = s, u = r > 0 ? `This ${e} is disabled and ${r} ${r === 1 ? "step uses" : "steps use"} a connection that no longer exists. Choose another connection, save, then Enable.` : "Connections fixed. Enable to run again.";
225
+ return J(
226
+ "div",
227
+ { role: "alert", className: "error", "data-testid": "binding-disabled-banner" },
228
+ J("span", null, u),
229
+ " ",
230
+ J(
231
+ "button",
232
+ {
233
+ type: "button",
234
+ "data-testid": "binding-enable",
235
+ disabled: !i || l === !0,
236
+ onClick: n
237
+ },
238
+ "Enable"
239
+ )
240
+ );
241
+ }
242
+ function Ws({
243
+ project: s,
244
+ onNavigate: e,
245
+ rail: r = !0,
246
+ storageKey: i,
247
+ tools: n = qn,
248
+ children: l
249
+ }) {
250
+ const u = Qn(), d = /* @__PURE__ */ a(Vn, { project: s, onNavigate: e, children: /* @__PURE__ */ g(Hn, { project: s, children: [
251
+ l,
252
+ r && /* @__PURE__ */ a(zn, { tools: n, storageKey: i })
253
+ ] }) });
254
+ return r || !u ? /* @__PURE__ */ a(_n, { children: d }) : d;
255
+ }
256
+ function $s({
257
+ message: s,
258
+ disabled: e = !1,
259
+ children: r
260
+ }) {
261
+ const i = wn(), [n, l] = y(!1);
262
+ return /* @__PURE__ */ g(
263
+ "fieldset",
264
+ {
265
+ className: "wf-publish-tooltip",
266
+ "aria-label": "Publish workflow",
267
+ "aria-describedby": i,
268
+ tabIndex: e ? 0 : void 0,
269
+ onMouseEnter: () => l(!0),
270
+ onMouseLeave: () => l(!1),
271
+ onFocus: () => l(!0),
272
+ onBlur: (u) => {
273
+ u.currentTarget.contains(u.relatedTarget) || l(!1);
274
+ },
275
+ onKeyDown: (u) => {
276
+ u.key === "Escape" && l(!1);
277
+ },
278
+ children: [
279
+ r(i),
280
+ n && /* @__PURE__ */ a("span", { id: i, role: "tooltip", className: "wf-publish-hint", children: s })
281
+ ]
282
+ }
283
+ );
284
+ }
285
+ function xs(s) {
286
+ const { problems: e, nodeLabel: r } = s, i = Object.entries(e).filter(([, l]) => l.length > 0);
287
+ if (i.length === 0) return null;
288
+ const n = i.length;
289
+ return J(
290
+ "div",
291
+ { role: "status", className: "error", "data-testid": "setup-incomplete-banner" },
292
+ J(
293
+ "span",
294
+ null,
295
+ `Setup incomplete: ${n} ${n === 1 ? "step needs" : "steps need"} attention. The workflow can still run.`
296
+ ),
297
+ J(
298
+ "ul",
299
+ { "data-testid": "setup-incomplete-list" },
300
+ ...i.map(
301
+ ([l, u]) => J("li", { key: l }, `${r ? r(l) : l}: ${u.join(", ")}`)
302
+ )
303
+ )
304
+ );
305
+ }
306
+ const Ks = {
307
+ invalid_json: "This isn't valid JSON yet, so it isn't saved. Fix it to save.",
308
+ not_object: 'Starting state must be a JSON object, like {"region": "us"}. Not saved.',
309
+ too_large: "Starting state is over the 64 KiB limit. Not saved."
310
+ };
311
+ function Qs(s) {
312
+ const e = hn();
313
+ return /* @__PURE__ */ a(
314
+ mn,
315
+ {
316
+ mode: "json-binding",
317
+ startingState: !0,
318
+ title: "Starting state",
319
+ fieldLabel: "initialState",
320
+ value: void 0,
321
+ options: e,
322
+ jsonValue: s.initialState,
323
+ jsonProblem: (r) => {
324
+ const i = Pt(r);
325
+ if (!i.ok) return Ks[i.reason];
326
+ const n = i.value === void 0 ? void 0 : As(i.value)[0];
327
+ return n ? `${n.message} Not saved.` : null;
328
+ },
329
+ onSaveJson: (r) => {
330
+ const i = Pt(r === void 0 ? "" : JSON.stringify(r));
331
+ i.ok && s.onChange(i.value);
332
+ },
333
+ onClose: s.onClose
334
+ }
335
+ );
336
+ }
337
+ const Lt = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/, _s = "Untitled workflow", qs = ["id", "key", "manifestVersion"];
338
+ function Vs(s) {
339
+ let e = 0;
340
+ const r = () => {
341
+ for (; e < s.length && `
342
+ \r`.includes(s[e]); ) e++;
343
+ }, i = () => {
344
+ throw e;
345
+ }, n = (h) => {
346
+ for (const m of h)
347
+ s[e] !== m && i(), e++;
348
+ }, l = () => {
349
+ for (e++; s[e] !== '"'; ) {
350
+ const h = s[e];
351
+ if ((h === void 0 || h < " ") && i(), h === "\\")
352
+ if (e++, s[e] === "u")
353
+ for (let m = 0; m < 4; m++)
354
+ e++, /[0-9a-fA-F]/.test(s[e] ?? "") || i();
355
+ else '"\\/bfnrt'.includes(s[e] ?? "x") || i();
356
+ e++;
357
+ }
358
+ e++;
359
+ }, u = /-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?/y, d = () => {
360
+ u.lastIndex = e, u.test(s) || i(), e = u.lastIndex;
361
+ }, S = () => {
362
+ r();
363
+ const h = s[e];
364
+ if (h === "{" || h === "[") {
365
+ const m = h === "{" ? "}" : "]";
366
+ if (e++, r(), s[e] === m) {
367
+ e++;
368
+ return;
369
+ }
370
+ for (; ; )
371
+ if (m === "}" && (r(), s[e] !== '"' && i(), l(), r(), s[e] !== ":" && i(), e++), S(), r(), s[e] === ",") e++;
372
+ else if (s[e] === m) {
373
+ e++;
374
+ return;
375
+ } else i();
376
+ }
377
+ h === '"' ? l() : h === "t" ? n("true") : h === "f" ? n("false") : h === "n" ? n("null") : d();
378
+ };
379
+ try {
380
+ return S(), r(), e < s.length ? e : null;
381
+ } catch (h) {
382
+ return typeof h == "number" ? Math.min(h, s.length) : 0;
383
+ }
384
+ }
385
+ function Hs(s, e) {
386
+ const r = e instanceof Error ? e.message : String(e), i = Vs(s);
387
+ if (i === null) return r;
388
+ const n = s.slice(0, i), l = n.split(`
389
+ `).length, u = i - n.lastIndexOf(`
390
+ `);
391
+ return `Line ${l}, column ${u}: ${r}`;
392
+ }
393
+ const ae = (s) => typeof s == "object" && s !== null && !Array.isArray(s);
394
+ function zs(s) {
395
+ if (typeof s.name != "string" || s.name.length === 0) return "`name` is required.";
396
+ const e = s.nodes ?? s.steps;
397
+ if (!Array.isArray(e)) return "`nodes` must be an array.";
398
+ const r = /* @__PURE__ */ new Set();
399
+ for (let i = 0; i < e.length; i++) {
400
+ const n = e[i];
401
+ if (!ae(n)) return `\`nodes[${i}]\` must be an object.`;
402
+ if (typeof n.id != "string" || n.id.length === 0)
403
+ return `\`nodes[${i}].id\` must be a non-empty string.`;
404
+ if (n.id.includes(".")) return `Node id "${n.id}" may not contain ".".`;
405
+ if (r.has(n.id)) return `Node id "${n.id}" is used twice.`;
406
+ r.add(n.id);
407
+ const l = n.position;
408
+ if (l !== void 0 && (!ae(l) || !Number.isFinite(l.x) || !Number.isFinite(l.y)))
409
+ return `\`nodes[${i}].position\` must be { "x": number, "y": number }.`;
410
+ }
411
+ if (s.edges !== void 0) {
412
+ if (!Array.isArray(s.edges)) return "`edges` must be an array.";
413
+ for (let i = 0; i < s.edges.length; i++) {
414
+ const n = s.edges[i];
415
+ if (!ae(n)) return `\`edges[${i}]\` must be an object.`;
416
+ for (const l of ["from", "to"])
417
+ if (typeof n[l] != "string" || !r.has(n[l]))
418
+ return `\`edges[${i}].${l}\` does not name an existing node.`;
419
+ }
420
+ }
421
+ return null;
422
+ }
423
+ function Gs(s, e) {
424
+ let r;
425
+ try {
426
+ r = JSON.parse(s);
427
+ } catch (d) {
428
+ return { ok: !1, error: Hs(s, d) };
429
+ }
430
+ if (!ae(r)) return { ok: !1, error: "The definition must be a JSON object." };
431
+ const i = [];
432
+ let n = r;
433
+ const l = {};
434
+ if (e) {
435
+ for (const d of qs) {
436
+ const S = Object.hasOwn(e, d), h = Object.hasOwn(n, d);
437
+ if (!(S === h && JSON.stringify(e[d]) === JSON.stringify(n[d])))
438
+ if (i.push(d), S)
439
+ h ? n = { ...n, [d]: e[d] } : l[d] = e[d];
440
+ else {
441
+ const { [d]: m, ...j } = n;
442
+ n = j;
443
+ }
444
+ }
445
+ n = { ...l, ...n };
446
+ }
447
+ if (typeof n.id == "string" && !Lt.test(n.id))
448
+ return { ok: !1, error: "Invalid workflow id." };
449
+ const u = zs(n);
450
+ return u !== null ? { ok: !1, error: u } : { ok: !0, text: i.length > 0 ? JSON.stringify(n, null, 2) : s, restored: i };
451
+ }
452
+ function Ys(s, e, r, i) {
453
+ const n = {};
454
+ for (const l of s) {
455
+ const u = { code: l.code, connection: l.connection };
456
+ n[l.siteId] = [...Object.hasOwn(n, l.siteId) ? n[l.siteId] : [], u];
457
+ }
458
+ for (const l of [e, r, i])
459
+ for (const [u, d] of Object.entries(l ?? {}))
460
+ d.length > 0 && (n[u] = [...Object.hasOwn(n, u) ? n[u] : [], ...d]);
461
+ return n;
462
+ }
463
+ const Us = Nn(
464
+ () => import("@w6w/ui/flow").then((s) => ({ default: s.WorkflowFlowEditor }))
465
+ );
466
+ function Xs(s) {
467
+ var wt, St, kt, Nt, Et;
468
+ const { workflowId: e, project: r, projectPending: i, initialRunId: n, onNavigate: l, slots: u } = s, d = Yn(), S = It(), [h, m] = y(null), [j, z] = y(!1), [de, I] = y(0), [C, D] = y(!1), [G, Y] = y(!1), [U, Ae] = y(!1), [X, Te] = y(void 0), je = w(!0), Oe = w(() => null), Mt = E(
469
+ (t) => {
470
+ const o = t;
471
+ return Lt.test(typeof o.id == "string" ? o.id : "") ? At(X, o.key).reason : "Invalid workflow id.";
472
+ },
473
+ [X]
474
+ ), f = Un({
475
+ workflowId: e,
476
+ project: r,
477
+ autoSave: je.current,
478
+ // The expression editor holds uncommitted parts in its own local state until its Save
479
+ // button, so saving from under it would persist a workflow without the expression the user
480
+ // is looking at. Read at fire time (opening it changes neither the buffer nor `canSave`).
481
+ canAutoSave: () => !document.querySelector(".w6w-exprmodal"),
482
+ saveGuard: Mt,
483
+ publishBlockedReason: (t) => Oe.current(t)
484
+ }), Ie = f.json, c = f.parsed, B = f.canSave, Jt = f.dirty;
485
+ T(() => {
486
+ if (f.loading || f.loadError !== null) {
487
+ Te(void 0);
488
+ return;
489
+ }
490
+ !f.dirty && c && Te(c.key ?? null);
491
+ }, [f.loading, f.loadError, f.dirty, c]);
492
+ const [Dt, fe] = y(!1);
493
+ T(() => {
494
+ f.stale || fe(!1);
495
+ }, [f.stale]);
496
+ const [Bt, Fe] = y(!1), Le = w(!1);
497
+ T(() => {
498
+ f.saving ? Fe(!1) : Le.current && f.error === null && Fe(!0), Le.current = f.saving;
499
+ }, [f.saving, f.error]);
500
+ const [O, N] = y(null), Me = Rn(), Je = Cn(), De = Pn(), P = An(O), K = (wt = P.data) == null ? void 0 : wt.status, Be = P.isError, Z = Tn(K, Be), Wt = jn(O, K), We = On(
501
+ In(P.data),
502
+ (St = Wt.data) == null ? void 0 : St.writes
503
+ ), $e = Fn(P.data, We), pe = w(!1), [$t, xe] = y(!1);
504
+ T(() => {
505
+ N(null);
506
+ }, [e]), T(() => {
507
+ n && N(n);
508
+ }, [e, n]), T(() => {
509
+ P.data && P.data.workflowId !== e && N(null);
510
+ }, [P.data, e]);
511
+ async function Ke(t) {
512
+ try {
513
+ const o = await f.flushThen(t);
514
+ !o.ok && o.outcome.status === "blocked" && m(o.outcome.reason);
515
+ } catch (o) {
516
+ m(o instanceof Ce ? o.message : String(o));
517
+ }
518
+ }
519
+ async function xt() {
520
+ if (!(!e || Z || pe.current)) {
521
+ m(null), pe.current = !0, xe(!0);
522
+ try {
523
+ const t = b ? Dn(R, b.isManualTrigger, b.isEntryTrigger) : (Q == null ? void 0 : Q[0]) && { id: Q[0].id, manual: !0 };
524
+ await vn();
525
+ const o = await Bn(
526
+ t == null ? void 0 : t.id,
527
+ (p) => jt(d, e, p),
528
+ () => Wn(d, e)
529
+ );
530
+ await Ke(
531
+ () => t && !t.manual ? (
532
+ // A webhook / schedule / app trigger entry runs FROM that trigger: the server takes
533
+ // the payload as the event that fired it (its output and `trigger.event`), which a
534
+ // plain run's `input` — the Manual trigger's slot — never reaches.
535
+ Je.mutateAsync({
536
+ id: e,
537
+ nodeId: t.id,
538
+ body: { stopAt: [], ...o ? { input: o } : {} }
539
+ }).then((p) => N(p.runId))
540
+ ) : Me.mutateAsync({
541
+ id: e,
542
+ variables: {},
543
+ ...o ? { input: o } : {}
544
+ }).then((p) => N(p.runId))
545
+ );
546
+ } finally {
547
+ pe.current = !1, xe(!1);
548
+ }
549
+ }
550
+ }
551
+ async function Kt(t, o) {
552
+ if (!e) return;
553
+ m(null);
554
+ const p = await f.flushThen(
555
+ () => {
556
+ var k;
557
+ return Je.mutateAsync({
558
+ id: e,
559
+ nodeId: t,
560
+ body: {
561
+ stopAt: o.stopAt,
562
+ ...(k = o.state) != null && k.steps ? { nodes: o.state.steps } : {},
563
+ ...o.input ? { input: o.input } : {}
564
+ }
565
+ });
566
+ }
567
+ );
568
+ if (!p.ok)
569
+ throw new Error(
570
+ p.outcome.status === "blocked" ? p.outcome.reason : "The workflow could not be saved, so it was not run."
571
+ );
572
+ N(p.value.runId);
573
+ }
574
+ function Qt() {
575
+ O && (De.mutate(O, {
576
+ onError: (t) => {
577
+ const o = t instanceof Ce ? t.code : "";
578
+ $n(o) === "surface" && m(t instanceof Ce ? t.message : String(t));
579
+ }
580
+ }), N(null));
581
+ }
582
+ async function _t() {
583
+ Ae(!0);
584
+ try {
585
+ await f.reload(), I((t) => t + 1), m(null);
586
+ } finally {
587
+ Ae(!1);
588
+ }
589
+ }
590
+ const ee = f.stale ? null : f.error ?? f.loadError, Qe = h ?? (ee === null ? null : ee instanceof Error ? ee.message : String(ee)), qt = c !== null && (Array.isArray(c.nodes) || Array.isArray(c.steps)), _e = (c == null ? void 0 : c.displayName) ?? "", he = Xn(c == null ? void 0 : c.settings), te = ls(c == null ? void 0 : c.initialState), Vt = v(() => cs(c == null ? void 0 : c.variables), [c == null ? void 0 : c.variables]), qe = At(X, c == null ? void 0 : c.key), Ve = c !== null && X !== void 0 && !qe.allowed ? qe.reason : null, R = v(
591
+ () => Zn(c),
592
+ [c]
593
+ ), [b, Ht] = y(null);
594
+ T(() => {
595
+ let t = !1;
596
+ return import("@w6w/ui/flow").then((o) => {
597
+ t || Ht({
598
+ internalNodes: o.INTERNAL_NODES,
599
+ isInternalApp: o.isInternalApp,
600
+ internalNodeParams: o.internalNodeParams,
601
+ isManualTrigger: (p) => p === o.TRIGGER_APP,
602
+ isEntryTrigger: o.isTriggerStep,
603
+ asFieldDefs: o.asFieldDefs,
604
+ findLoopProblems: o.findLoopProblems,
605
+ findStateWriteProblems: o.findStateWriteProblems
606
+ });
607
+ }), () => {
608
+ t = !0;
609
+ };
610
+ }, []);
611
+ const Q = v(() => {
612
+ if (b)
613
+ return es(
614
+ { steps: R },
615
+ {
616
+ isManualTrigger: b.isManualTrigger,
617
+ asFieldDefs: b.asFieldDefs
618
+ }
619
+ );
620
+ }, [b, R]), F = v(() => {
621
+ if (!b) return [];
622
+ const t = /* @__PURE__ */ new Set();
623
+ for (const o of R) {
624
+ const { app: p, action: k } = o.uses ?? {};
625
+ p && k && !b.isInternalApp(p) && t.add(p);
626
+ }
627
+ return [...t];
628
+ }, [b, R]), { byId: ne } = Kn(F), zt = v(() => [...ne.values()], [ne]), He = Re({
629
+ queries: F.map((t) => ({
630
+ queryKey: Cs(t),
631
+ queryFn: () => S.getAppActions(t)
632
+ }))
633
+ }), ze = v(() => {
634
+ var o, p;
635
+ const t = {};
636
+ if (!b) return t;
637
+ for (const k of R) {
638
+ const { app: A, action: x } = k.uses ?? {};
639
+ if (!A || !x) continue;
640
+ const Ne = `${A}::${x}`;
641
+ if (!(Ne in t))
642
+ if (b.isInternalApp(A))
643
+ t[Ne] = b.internalNodeParams(A, x);
644
+ else {
645
+ const Rt = F.indexOf(A), Ee = Rt >= 0 ? (o = He[Rt]) == null ? void 0 : o.data : void 0;
646
+ t[Ne] = ((p = Ee == null ? void 0 : Ee.find((dn) => dn.key === x)) == null ? void 0 : p.params) ?? [];
647
+ }
648
+ }
649
+ return t;
650
+ }, [b, R, F, He]), _ = v(() => {
651
+ const t = {};
652
+ for (const [o, p] of ne) t[o] = p;
653
+ return t;
654
+ }, [ne]), me = v(
655
+ () => R.filter((t) => {
656
+ var p;
657
+ const o = (p = t.uses) == null ? void 0 : p.app;
658
+ return !!o && o in _ && Ct(_[o]);
659
+ }),
660
+ [R, _]
661
+ ), Ge = Re({
662
+ queries: me.map((t) => ({
663
+ queryKey: Pe(e, t.id),
664
+ queryFn: () => jt(d, e, t.id),
665
+ enabled: !!e
666
+ }))
667
+ }), Ye = v(() => {
668
+ const t = {};
669
+ return me.forEach((o, p) => {
670
+ var k, A;
671
+ t[o.id] = !!((A = (k = Ge[p]) == null ? void 0 : k.data) != null && A.some((x) => x.lastRunStatus === "succeeded"));
672
+ }), t;
673
+ }, [me, Ge]), q = bs("workflow", e, !!e), be = gs("workflow"), L = ((kt = q.data) == null ? void 0 : kt.currentPublishedVersion) ?? null, V = ys("workflow", e, L, !!e), Ue = V.data !== void 0 && c !== null && Ds(c, V.data.definition), M = q.data === void 0 ? void 0 : L === null ? "unpublished" : V.data === void 0 || f.loading ? void 0 : Ue ? "published" : "draft", [Gt, Xe] = y(!1), Yt = vs("workflow");
674
+ async function Ze(t) {
675
+ Xe(!0), m(null);
676
+ try {
677
+ await f.discardThen(() => Yt.mutateAsync({ id: e, versionNumber: t })), I((o) => o + 1), N(null);
678
+ } finally {
679
+ Xe(!1);
680
+ }
681
+ }
682
+ const se = Ot(), et = w(null);
683
+ T(() => {
684
+ var t;
685
+ if (!(!e || !O || et.current === O) && Ln(K, (t = P.data) == null ? void 0 : t.workflowId, e)) {
686
+ et.current = O;
687
+ for (const o of Mn)
688
+ setTimeout(
689
+ () => void se.invalidateQueries({ queryKey: ks(e) }),
690
+ o
691
+ );
692
+ }
693
+ }, [e, O, K, (Nt = P.data) == null ? void 0 : Nt.workflowId, se]);
694
+ const tt = Re({
695
+ queries: F.map((t) => ({
696
+ queryKey: Tt(t),
697
+ queryFn: () => ms(d, t)
698
+ }))
699
+ }), nt = v(() => {
700
+ const t = /* @__PURE__ */ new Map();
701
+ return F.forEach((o, p) => {
702
+ const k = tt[p];
703
+ k && (k.isError ? t.set(o, { state: "error" }) : k.isSuccess && !k.isFetching ? t.set(o, { state: "ready", ids: new Set((k.data ?? []).map((A) => A.id)) }) : t.set(o, { state: "loading" }));
704
+ }), t;
705
+ }, [F, tt]), W = v(
706
+ () => ts(R, (t) => nt.get(t), c == null ? void 0 : c.connections),
707
+ [R, nt, c == null ? void 0 : c.connections]
708
+ ), st = Ns(r ?? void 0, r !== null), ot = Es(), it = ws(), rt = Rs(r ?? void 0), ge = v(() => {
709
+ if (!c) return {};
710
+ const t = (o) => ({
711
+ names: (o.data ?? []).map((p) => p.name),
712
+ ready: o.isSuccess
713
+ });
714
+ return ns({
715
+ workflow: c,
716
+ lists: {
717
+ vars: t(st),
718
+ secrets: t(ot),
719
+ constants: t(it),
720
+ stores: t(rt)
721
+ }
722
+ });
723
+ }, [c, st, ot, it, rt]), at = v(() => {
724
+ const t = {};
725
+ for (const [o, p] of Object.entries(ge))
726
+ t[o] = [{ code: "setup_incomplete", items: p }];
727
+ return t;
728
+ }, [ge]), Ut = v(
729
+ () => Ys(
730
+ W,
731
+ b == null ? void 0 : b.findLoopProblems(c),
732
+ c ? b == null ? void 0 : b.findStateWriteProblems(c) : void 0,
733
+ at
734
+ ),
735
+ [W, b, c, at]
736
+ ), lt = w(/* @__PURE__ */ new Set());
737
+ T(() => {
738
+ for (const t of W) {
739
+ const o = `${t.app}|${t.connection}`;
740
+ lt.current.has(o) || (lt.current.add(o), se.invalidateQueries({ queryKey: Tt(t.app) }));
741
+ }
742
+ }, [W, se]);
743
+ const oe = w({ id: e, had: !1 });
744
+ oe.current.id !== e && (oe.current = { id: e, had: !1 }), W.length > 0 && (oe.current.had = !0);
745
+ const ct = Ss("workflow"), ye = ss({
746
+ enabled: (Et = q.data) == null ? void 0 : Et.enabled,
747
+ problemCount: W.length,
748
+ dirty: f.dirty,
749
+ hadProblems: oe.current.had
750
+ }), ve = v(
751
+ () => ({
752
+ actionParamsByKey: ze,
753
+ appsById: _,
754
+ testStatus: Ye,
755
+ requiredParamsFilled: gn,
756
+ isTestRequired: Ct
757
+ }),
758
+ [ze, _, Ye]
759
+ ), Xt = v(
760
+ () => c !== null && b !== null ? os(c, ve) : [],
761
+ [c, b, ve]
762
+ ), [ut, dt] = y(!1), we = w(!1), H = is({
763
+ projectMissing: r === null,
764
+ loading: !B,
765
+ saveBlockedReason: f.saveBlockedReason ?? (B && c === null ? "the workflow JSON does not parse." : null),
766
+ catalogLoading: c !== null && b === null,
767
+ problems: Xt,
768
+ publishing: ut || be.isPending
769
+ }) ?? (q.isPending || L !== null && V.isPending ? "Checking the published version…" : q.isError || L !== null && V.isError ? "Can't check the published version. Reload to try again." : Ue ? "Already published. Make a change before publishing again." : null);
770
+ async function Se() {
771
+ if (!(!e || H !== null || we.current)) {
772
+ we.current = !0, dt(!0), m(null);
773
+ try {
774
+ await Ke(() => be.mutateAsync(e));
775
+ } finally {
776
+ we.current = !1, dt(!1);
777
+ }
778
+ }
779
+ }
780
+ Oe.current = (t) => t !== null && typeof t == "object" ? rs(t, ve) : null, je.current = he.autoSave;
781
+ const Zt = E(
782
+ (t) => Gs(t, re.current),
783
+ []
784
+ );
785
+ function ie(t) {
786
+ if (!c) return;
787
+ const o = { ...c, ...t };
788
+ f.setJson(JSON.stringify(o, null, 2));
789
+ }
790
+ function ft(t) {
791
+ if (!c) return;
792
+ const o = { ...c, ...t };
793
+ m(null), f.commit(JSON.stringify(o, null, 2));
794
+ }
795
+ const re = w(c);
796
+ re.current = c;
797
+ const pt = w(f.commit);
798
+ pt.current = f.commit;
799
+ const ht = w(f.saveNow);
800
+ ht.current = f.saveNow, T(() => {
801
+ const t = (o) => {
802
+ o.altKey || !(o.metaKey || o.ctrlKey) || o.key.toLowerCase() !== "s" || (o.preventDefault(), !document.querySelector(".w6w-exprmodal") && B && ht.current());
803
+ };
804
+ return document.addEventListener("keydown", t), () => {
805
+ document.removeEventListener("keydown", t);
806
+ };
807
+ }, [B]);
808
+ const en = v(
809
+ () => c ? ds(c) : {},
810
+ [c]
811
+ ), tn = E((t) => {
812
+ const o = re.current;
813
+ if (!o) return;
814
+ const p = fs(o, t);
815
+ m(null), pt.current(JSON.stringify(p, null, 2));
816
+ }, []), nn = E(() => Y(!0), []), mt = w(() => {
817
+ });
818
+ mt.current = (t) => {
819
+ N(t), l({ type: "run", id: e, runId: t });
820
+ };
821
+ const bt = E((t) => mt.current(t), []), gt = w(Ze);
822
+ gt.current = Ze;
823
+ const sn = E((t) => gt.current(t), []), yt = w(Se);
824
+ yt.current = Se;
825
+ const on = E(() => yt.current(), []), ke = w({ saveMeta: ft, patchMeta: ie });
826
+ ke.current = { saveMeta: ft, patchMeta: ie };
827
+ const rn = E(
828
+ (t, o) => {
829
+ var p;
830
+ ke.current.saveMeta({
831
+ settings: as((p = re.current) == null ? void 0 : p.settings, t, o)
832
+ });
833
+ },
834
+ []
835
+ ), an = E((t) => {
836
+ ke.current.patchMeta({ variables: us(t) });
837
+ }, []), [$, ln] = y(null), vt = w($);
838
+ vt.current = $;
839
+ const cn = E(
840
+ (t) => {
841
+ var o;
842
+ (o = vt.current) == null || o.edit(t);
843
+ },
844
+ []
845
+ ), un = E(() => D(!0), []);
846
+ return Gn({
847
+ kind: "workflow",
848
+ id: e,
849
+ connectionResources: ($ == null ? void 0 : $.workflowId) === e ? { ...$, edit: cn } : void 0,
850
+ label: _e,
851
+ key: (c == null ? void 0 : c.key) ?? void 0,
852
+ triggers: Q,
853
+ onRestoreVersion: sn,
854
+ definitionStatus: M,
855
+ onPublish: on,
856
+ publishDisabled: H !== null,
857
+ policy: en,
858
+ onPolicyChange: tn,
859
+ hasStartingState: te !== void 0 && Object.keys(te).length > 0,
860
+ startingState: te,
861
+ onOpenStartingState: nn,
862
+ onOpenRun: bt,
863
+ authoringSettings: { autoSave: he.autoSave, savePosition: he.savePosition },
864
+ onAuthoringSettingChange: rn,
865
+ variables: Vt,
866
+ onVariablesChange: an,
867
+ onOpenHistory: un
868
+ }), /* @__PURE__ */ g("div", { className: "wf-fullbleed", style: { height: "100%", minWidth: 0, flex: 1 }, children: [
869
+ (u == null ? void 0 : u.header) ?? /* @__PURE__ */ a(
870
+ js,
871
+ {
872
+ onBack: () => l({ type: "list" }),
873
+ backLabel: (u == null ? void 0 : u.backLabel) === null ? null : (u == null ? void 0 : u.backLabel) ?? "← Workflows",
874
+ title: {
875
+ editable: !0,
876
+ value: _e,
877
+ placeholder: _s,
878
+ maxLength: 80,
879
+ ariaLabel: "Workflow name",
880
+ onChange: (t) => ie({ displayName: t }),
881
+ onBlur: () => {
882
+ B && f.saveNow();
883
+ }
884
+ },
885
+ titleAdornment: M && /* @__PURE__ */ a(
886
+ "span",
887
+ {
888
+ className: `badge wf-definition-status ${M}`,
889
+ "data-testid": "wf-definition-status",
890
+ "aria-live": "polite",
891
+ title: M === "published" ? "This workflow matches the published version. Edits create a separate draft." : M === "draft" ? "You are editing a draft. The published version stays unchanged until you publish." : "You are editing a draft. This workflow has not been published.",
892
+ children: M === "published" ? "Live" : "Draft"
893
+ }
894
+ ),
895
+ actions: /* @__PURE__ */ g(le, { children: [
896
+ /* @__PURE__ */ a(
897
+ ce,
898
+ {
899
+ icon: "play",
900
+ label: Jn(K, Be),
901
+ "data-testid": "wf-run-start",
902
+ onClick: xt,
903
+ disabled: !e || Z || $t || Me.isPending
904
+ }
905
+ ),
906
+ Z && /* @__PURE__ */ a(
907
+ ce,
908
+ {
909
+ icon: "stop",
910
+ label: "Stop this run",
911
+ "data-testid": "wf-run-stop",
912
+ onClick: Qt,
913
+ disabled: De.isPending
914
+ }
915
+ ),
916
+ /* @__PURE__ */ a(
917
+ $s,
918
+ {
919
+ disabled: H !== null,
920
+ message: H ?? (L !== null ? "Republish this draft as a new live version" : "Publish this draft as a new live version"),
921
+ children: (t) => /* @__PURE__ */ a(le, { children: /* @__PURE__ */ a(
922
+ "button",
923
+ {
924
+ type: "button",
925
+ className: "btn ghost wf-publish",
926
+ "data-testid": "wf-publish",
927
+ onClick: () => void Se(),
928
+ disabled: H !== null,
929
+ "aria-describedby": t,
930
+ children: ut || be.isPending ? L !== null ? "Republishing…" : "Publishing…" : L !== null ? M === "draft" ? "Republish" : "Published" : "Publish"
931
+ }
932
+ ) })
933
+ }
934
+ ),
935
+ /* @__PURE__ */ a(Fs, { onClick: () => z(!0) }),
936
+ u == null ? void 0 : u.headerActions
937
+ ] })
938
+ }
939
+ ),
940
+ /* @__PURE__ */ a(xs, { problems: ge }),
941
+ ye.show && /* @__PURE__ */ a(
942
+ Bs,
943
+ {
944
+ kind: "workflow",
945
+ problemCount: ye.problemCount,
946
+ canEnable: ye.canEnable,
947
+ pending: ct.isPending,
948
+ onEnable: () => ct.mutate({ id: e, enabled: !0 })
949
+ }
950
+ ),
951
+ /* @__PURE__ */ a("div", { className: "wf-fullbleed-canvas", children: /* @__PURE__ */ g("div", { className: "wf-run-area", children: [
952
+ /* @__PURE__ */ a("div", { className: "wf-run-canvas", children: /* @__PURE__ */ a(kn, { fallback: /* @__PURE__ */ a("p", { className: "muted", children: "Loading visual editor…" }), children: qt && c ? /* @__PURE__ */ a(
953
+ Us,
954
+ {
955
+ onConnectionResourcesChange: ln,
956
+ value: c,
957
+ onChange: (t, o) => {
958
+ f.setJson(JSON.stringify(t, null, 2)), o != null && o.viewportOnly || N(null);
959
+ },
960
+ apps: zt,
961
+ project: r ?? void 0,
962
+ height: "100%",
963
+ readOnly: Z,
964
+ stepProblems: Ut,
965
+ runState: P.data,
966
+ onTestRun: () => N(null),
967
+ onRunFromNode: Kt
968
+ },
969
+ de
970
+ ) : Ie === "" ? /* @__PURE__ */ a("p", { className: "muted", children: "Loading…" }) : /* @__PURE__ */ a("p", { className: "muted", children: "Fix the JSON to render the visual editor." }) }) }),
971
+ O && /* @__PURE__ */ a("div", { className: "wf-run-log", "data-testid": "wf-run-log", children: /* @__PURE__ */ a(
972
+ yn,
973
+ {
974
+ steps: We,
975
+ runError: $e.runError,
976
+ stepErrors: $e.stepErrors,
977
+ onDismiss: () => N(null)
978
+ }
979
+ ) })
980
+ ] }) }),
981
+ r === null && !i && /* @__PURE__ */ g("div", { role: "alert", className: "error", "data-testid": "wf-project-required", children: [
982
+ "No project selected — pass a ",
983
+ /* @__PURE__ */ a("code", { children: "project" }),
984
+ " prop (or set the provider's project) to edit and save this workflow."
985
+ ] }),
986
+ /* @__PURE__ */ g("div", { className: "wf-fullbleed-foot", children: [
987
+ /* @__PURE__ */ g("div", { className: "row", style: { flexWrap: "wrap", alignItems: "center" }, children: [
988
+ /* @__PURE__ */ a(
989
+ "button",
990
+ {
991
+ type: "button",
992
+ className: "btn",
993
+ disabled: r === null || !B || !Jt,
994
+ onClick: f.saveNow,
995
+ children: f.saving ? "Saving…" : "Save"
996
+ }
997
+ ),
998
+ Bt && /* @__PURE__ */ a("span", { className: "ok", children: "Saved." })
999
+ ] }),
1000
+ Qe && /* @__PURE__ */ a("div", { className: "error", children: Qe }),
1001
+ Ve && /* @__PURE__ */ a("div", { className: "error", "data-testid": "wf-key-guard", children: Ve })
1002
+ ] }),
1003
+ Gt && /* @__PURE__ */ a(ue, { title: "Restoring version…", onClose: () => {
1004
+ }, children: /* @__PURE__ */ a("div", { className: "modal-body", children: "Replacing the draft…" }) }),
1005
+ /* @__PURE__ */ a(
1006
+ Ls,
1007
+ {
1008
+ open: j,
1009
+ onClose: () => z(!1),
1010
+ title: `JSON — ${(c == null ? void 0 : c.displayName) || "workflow"}`,
1011
+ mode: "apply",
1012
+ value: Ie,
1013
+ prepareApply: Zt,
1014
+ onApply: (t) => {
1015
+ f.setJson(t), I((o) => o + 1), N(null);
1016
+ },
1017
+ editorLabel: "Workflow definition JSON"
1018
+ }
1019
+ ),
1020
+ f.stale && !Dt && /* @__PURE__ */ g(ue, { title: "This workflow changed on the server", onClose: () => fe(!0), children: [
1021
+ /* @__PURE__ */ g("div", { className: "modal-body", children: [
1022
+ /* @__PURE__ */ a("p", { className: "muted small", children: "Someone else — another tab, another session — saved this workflow after you opened it. Your save was refused rather than applied, so their work is still intact." }),
1023
+ /* @__PURE__ */ g("p", { className: "muted small", children: [
1024
+ /* @__PURE__ */ a("strong", { children: "Reload from server" }),
1025
+ " replaces what is on this canvas with the saved copy; anything you changed here and have not saved is lost.",
1026
+ " ",
1027
+ /* @__PURE__ */ a("strong", { children: "Keep editing" }),
1028
+ " leaves your version exactly as it is — but every save will be refused the same way until you reload, so copy out anything you need first."
1029
+ ] })
1030
+ ] }),
1031
+ /* @__PURE__ */ g("div", { className: "modal-actions", children: [
1032
+ /* @__PURE__ */ a("button", { type: "button", className: "btn ghost", onClick: () => fe(!0), children: "Keep editing" }),
1033
+ /* @__PURE__ */ a("button", { type: "button", className: "btn", disabled: U, onClick: _t, children: U ? "Reloading…" : "Reload from server" })
1034
+ ] })
1035
+ ] }),
1036
+ C && /* @__PURE__ */ a(
1037
+ Is,
1038
+ {
1039
+ kind: "workflow",
1040
+ id: e,
1041
+ onClose: () => D(!1),
1042
+ onOpenRun: bt
1043
+ }
1044
+ ),
1045
+ G && /* @__PURE__ */ a(
1046
+ Qs,
1047
+ {
1048
+ initialState: te,
1049
+ onChange: (t) => ie({ initialState: t }),
1050
+ onClose: () => Y(!1)
1051
+ }
1052
+ )
1053
+ ] });
1054
+ }
1055
+ function Zs({ children: s }) {
1056
+ const e = It(), r = Ot(), i = Sn(Ps), n = v(() => ({ ...e, saveStepTest: (...d) => e.saveStepTest(...d).finally(() => {
1057
+ r.invalidateQueries({ queryKey: Pe(d[0], d[1]) });
1058
+ }), recordStepTestRun: (...d) => e.recordStepTestRun(...d).finally(() => {
1059
+ r.invalidateQueries({ queryKey: Pe(d[0], d[1]) });
1060
+ }) }), [e, r]);
1061
+ return /* @__PURE__ */ a(bn, { api: n, theme: i, children: s });
1062
+ }
1063
+ const eo = () => {
1064
+ };
1065
+ function Po(s) {
1066
+ const { workflowId: e, initialRunId: r, onNavigate: i = eo, slots: n } = s, l = ps(s.project), u = hs().status, d = s.project === void 0 && u === "resolving", S = E(
1067
+ (h) => {
1068
+ h.type === "list" ? i({ type: "list" }) : h.kind === "workflow" && i({ type: "workflow", id: h.id });
1069
+ },
1070
+ [i]
1071
+ );
1072
+ return /* @__PURE__ */ a(
1073
+ "div",
1074
+ {
1075
+ className: "w6w-embed-root",
1076
+ style: { display: "flex", width: "100%", height: "100%", minHeight: 0 },
1077
+ children: /* @__PURE__ */ a(
1078
+ Ws,
1079
+ {
1080
+ project: l,
1081
+ onNavigate: S,
1082
+ rail: s.rail,
1083
+ storageKey: l === null ? null : `w6w.rail.embed.${l}`,
1084
+ children: /* @__PURE__ */ a(Zs, { children: /* @__PURE__ */ a(
1085
+ Xs,
1086
+ {
1087
+ workflowId: e,
1088
+ project: l,
1089
+ projectPending: d,
1090
+ initialRunId: r,
1091
+ onNavigate: i,
1092
+ slots: n
1093
+ }
1094
+ ) })
1095
+ }
1096
+ )
1097
+ }
1098
+ );
1099
+ }
1100
+ export {
1101
+ Bs as B,
1102
+ js as E,
1103
+ Is as H,
1104
+ Ls as J,
1105
+ Po as W,
1106
+ Ws as a,
1107
+ Fs as b
1108
+ };
1109
+ //# sourceMappingURL=WorkflowEditor-CmhXHRxi.js.map