@oomol-lab/open-flow 0.1.0-beta.10 → 0.1.0-beta.12

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 (65) hide show
  1. package/dist/browser/DesignerIcon-ckcKnxxJ.js +2267 -0
  2. package/dist/browser/createResourceDialog-2pESP2wA.js +111 -0
  3. package/dist/browser/{dist-meg_oHVR.js → dist-BZ5PTFAs.js} +335 -335
  4. package/dist/browser/dist-Bmb2mZvW.js +795 -0
  5. package/dist/browser/{dist-Cc0y2Pli.js → dist-Ce71Szg7.js} +622 -622
  6. package/dist/browser/dist-DSe6KRsr.js +1224 -0
  7. package/dist/browser/{dist-Dg_VXC8f.js → dist-DY4qlXTK.js} +134 -134
  8. package/dist/browser/{esm-yhVU_KbQ.js → esm-BPZ0P6x4.js} +59 -59
  9. package/dist/browser/flow-authoring-node.d.ts +11 -4
  10. package/dist/browser/flow-authoring.d.ts +1 -1
  11. package/dist/browser/flow-authoring.js +5032 -275
  12. package/dist/browser/flow-change-schema.d.ts +6 -0
  13. package/dist/browser/flow-change.d.ts +21 -8
  14. package/dist/browser/flow-change.js +5048 -155
  15. package/dist/browser/{flowChanges-B2ttnaj9.js → flowChanges-CHPdBmZb.js} +4433 -3786
  16. package/dist/browser/{flowRunInputEditorStore-DDidwd8h.js → flowRunInputEditorStore-NPGePkvP.js} +679 -689
  17. package/dist/browser/flowWorkspace-BLGcgnHj.js +158418 -0
  18. package/dist/browser/{getPseudoElementBounds-5LArT6Xc.js → getPseudoElementBounds-Dfqo78k7.js} +691 -687
  19. package/dist/browser/host-conformance.d.ts +7 -0
  20. package/dist/browser/host-conformance.js +33 -0
  21. package/dist/browser/{languages-DgJehE1g.js → languages-i3Xmpt6S.js} +6 -15
  22. package/dist/browser/licenses.md +82 -0
  23. package/dist/browser/{markdownContent-DUfLdnUt.js → markdownContent-BawLYUjh.js} +23 -23
  24. package/dist/browser/select-Dn3vpjGC.js +6872 -0
  25. package/dist/browser/theme.css +34 -34
  26. package/dist/browser/{typeScriptSession-_TgJ_7Oq.js → typeScriptSession-BoV-FDl3.js} +257 -257
  27. package/dist/browser/waitNotificationInputs-BFbQUOyp.js +29 -0
  28. package/dist/browser/workbench-contract.d.ts +8 -2
  29. package/dist/browser/workbench.css +1 -1
  30. package/dist/browser/workbench.js +1277 -1021
  31. package/dist/browser/workbenchSelect-DzF8oik9.js +435 -0
  32. package/dist/common/control-api-conformance.d.ts +6 -0
  33. package/dist/common/control-api-conformance.js +300 -85
  34. package/dist/common/control-api.d.ts +37 -10
  35. package/dist/common/control-api.js +5199 -437
  36. package/dist/common/control-requests.d.ts +68 -0
  37. package/dist/common/control-requests.js +4913 -0
  38. package/dist/common/engine-contract.d.ts +1 -1
  39. package/dist/common/flow-encoding.d.ts +3 -1
  40. package/dist/common/flow-encoding.js +4761 -63
  41. package/dist/common/flow-graph.d.ts +6 -0
  42. package/dist/common/flow-json.d.ts +2 -0
  43. package/dist/common/flow-modules.d.ts +20 -0
  44. package/dist/common/flow-schema.d.ts +8 -0
  45. package/dist/common/flow-semantics.d.ts +6 -5
  46. package/dist/common/flow-semantics.js +14641 -9800
  47. package/dist/common/integration-trigger.d.ts +1 -0
  48. package/dist/common/mcp-conformance.d.ts +2 -0
  49. package/dist/common/mcp.d.ts +545 -0
  50. package/dist/common/mcp.js +4964 -0
  51. package/dist/common/run-events.d.ts +2 -2
  52. package/dist/common/run-events.js +8 -15
  53. package/dist/common/runtime-contract.d.ts +9 -1
  54. package/dist/common/runtime-contract.js +137 -27
  55. package/dist/common/scheduler.d.ts +11 -33
  56. package/dist/common/scheduler.js +7241 -428
  57. package/dist/index.d.ts +5 -5
  58. package/package.json +13 -1
  59. package/dist/browser/DesignerIcon-DjgOMYI5.js +0 -2065
  60. package/dist/browser/createResourceDialog-DNBueSYZ.js +0 -505
  61. package/dist/browser/dist-BMRLCebL.js +0 -1893
  62. package/dist/browser/flowWorkspace-Dr8-Hut9.js +0 -45541
  63. package/dist/browser/icons-KIOgjHpD.js +0 -730
  64. package/dist/browser/waitNotificationInputs-BPulOxYt.js +0 -26
  65. package/dist/browser/workbenchSelect-CbXrdwxW.js +0 -1375
@@ -1,14 +1,19 @@
1
1
  import { a as e, f as t, i as n } from "./dist-C46JByB-.js";
2
2
  import { a as r, i, s as a, t as o } from "./main-DmjVyuWr.js";
3
- import { Un as s, Vn as c, jt as l } from "./getPseudoElementBounds-5LArT6Xc.js";
4
- import { a as u, c as d, d as f, f as p, i as m, n as h, o as g, p as _, t as v, u as y } from "./icons-KIOgjHpD.js";
5
- import { t as b } from "./workbenchSelect-CbXrdwxW.js";
6
- import { $ as x, A as S, C as ee, D as C, E as w, F as T, G as E, H as D, I as O, J as te, M as k, N as A, O as j, P as M, Q as N, S as P, U as F, V as I, W as ne, X as re, Y as ie, Z as ae, _ as oe, a as se, at as ce, b as le, c as ue, ct as de, d as fe, dt as pe, et as me, f as he, ft as L, g as ge, h as _e, ht as ve, i as ye, it as be, j as R, l as xe, lt as Se, m as Ce, mt as z, n as B, nt as we, o as Te, ot as Ee, p as De, pt as Oe, q as ke, rt as Ae, s as je, st as Me, t as Ne, tt as V, u as Pe, ut as Fe, v as Ie, w as Le, x as Re, y as ze, z as Be } from "./flowChanges-B2ttnaj9.js";
7
- import { a as Ve, i as He, n as Ue, r as We } from "./languages-DgJehE1g.js";
8
- import { Suspense as Ge, lazy as H, useEffect as U, useRef as Ke, useState as W } from "react";
9
- import { Fragment as qe, jsx as G, jsxs as K } from "react/jsx-runtime";
3
+ import { $ as s, A as c, B as l, C as u, D as d, E as f, F as p, H as m, I as h, J as g, K as _, M as v, N as y, O as b, P as x, Q as S, R as C, S as w, U as T, V as E, W as D, X as O, Y as ee, Z as k, _ as A, a as j, at as te, b as M, c as N, ct as ne, d as re, dt as ie, et as ae, f as oe, ft as P, g as se, gt as F, h as ce, ht as le, i as ue, it as de, j as I, l as fe, lt as pe, m as me, mt as L, n as R, nt as he, o as ge, ot as _e, p as ve, pt as ye, q as be, rt as xe, s as Se, st as Ce, t as we, tt as z, u as Te, ut as Ee, v as De, w as Oe, x as ke, y as Ae, z as je } from "./flowChanges-CHPdBmZb.js";
4
+ import { Ot as Me, Un as Ne, Vn as B, jt as V } from "./getPseudoElementBounds-Dfqo78k7.js";
5
+ import { C as Pe, S as Fe, T as Ie, _ as Le, b as Re, c as H, h as U, l as ze, m as Be, w as Ve } from "./select-Dn3vpjGC.js";
6
+ import { _ as He, c as Ue, f as We, s as Ge, u as Ke } from "./DesignerIcon-ckcKnxxJ.js";
7
+ import { i as qe, n as Je, r as Ye, t as Xe } from "./languages-i3Xmpt6S.js";
8
+ import { a as Ze, c as Qe, i as $e, n as et, o as tt, r as nt, s as rt, t as it } from "./workbenchSelect-DzF8oik9.js";
9
+ import { Suspense as at, lazy as ot, useEffect as W, useRef as G, useState as K } from "react";
10
+ import { Fragment as st, jsx as q, jsxs as J } from "react/jsx-runtime";
11
+ import * as ct from "effect/Cause";
12
+ import * as Y from "effect/Effect";
13
+ import * as lt from "effect/Exit";
14
+ import * as ut from "effect/Fiber";
10
15
  //#region src/workbench/browser/runtime/navigation.ts
11
- var Je = class {
16
+ var dt = class {
12
17
  #e;
13
18
  #t;
14
19
  #n;
@@ -67,7 +72,7 @@ var Je = class {
67
72
  this.#s = !0, await this.#n.selectFlow(void 0), e == this.#i && (this.#u("design", !1), this.#s = !1);
68
73
  }
69
74
  async apply(e) {
70
- if (Ye(e, this.#t)) return;
75
+ if (ft(e, this.#t)) return;
71
76
  this.#t = e;
72
77
  let t = ++this.#i;
73
78
  this.#s = !0;
@@ -83,49 +88,59 @@ var Je = class {
83
88
  flowId: n,
84
89
  view: n == null ? "design" : e
85
90
  };
86
- Ye(r, this.#t) || (this.#t = r, this.#e(r, { replace: t })), this.#r.set(r.view);
91
+ ft(r, this.#t) || (this.#t = r, this.#e(r, { replace: t })), this.#r.set(r.view);
87
92
  }
88
93
  };
89
- function Ye(e, t) {
94
+ function ft(e, t) {
90
95
  return e.flowId == t.flowId && e.view == t.view;
91
96
  }
92
97
  //#endregion
93
98
  //#region src/workbench/browser/runtime/shell/resourceBrowser.tsx
94
- var Xe = H(() => import("./createResourceDialog-DNBueSYZ.js")), Ze = Ve.map((e) => ({
95
- label: He[e],
99
+ var pt = ot(() => import("./createResourceDialog-2pESP2wA.js")), mt = qe.map((e) => ({
100
+ label: Ye[e],
96
101
  value: e
97
102
  }));
98
- function Qe({ language: e, onLanguageChange: t }) {
99
- let n = r(), [i, a] = W(null);
100
- return t == null ? null : /* @__PURE__ */ K("div", {
103
+ function ht({ language: e, onLanguageChange: t }) {
104
+ let n = r(), [i, a] = K(null);
105
+ return t == null ? null : /* @__PURE__ */ J("div", {
101
106
  className: "resource-language",
102
107
  ref: a,
103
- children: [/* @__PURE__ */ G("span", {
108
+ children: [/* @__PURE__ */ q("span", {
104
109
  className: "sr-only",
105
110
  children: n("language.label")
106
- }), /* @__PURE__ */ G(b, {
111
+ }), /* @__PURE__ */ q(it, {
107
112
  ariaLabel: n("language.label"),
108
113
  onValueChange: (e) => t(e),
109
- options: Ze,
114
+ options: mt,
110
115
  portalRoot: i,
111
116
  value: e
112
117
  })]
113
118
  });
114
119
  }
115
- function $e({ badge: e, busy: t, flow: n, href: a, onSelect: o, store: d }) {
116
- let f = i(), p = r(), [m, h] = W("idle"), [g, y] = W(n.name), b = u(g);
117
- async function x(e) {
120
+ function gt({ badge: e, busy: t, flow: n, href: a, onSelect: o, store: s }) {
121
+ let [c, l] = K(null), u = G(null), d = G(null), f = G(null), p = i(), m = r(), [h, g] = K("idle"), [_, v] = K(n.name), [y, b] = K(), x = n.live != null && n.live.revisionId != n.draftRevisionId;
122
+ async function S(e) {
123
+ b(e == "publish" ? "publish" : "enabled");
124
+ try {
125
+ e == "publish" ? await s.workspace.publishFlow(n) : await s.workspace.setFlowEnabled(n, e);
126
+ } finally {
127
+ b(void 0);
128
+ }
129
+ }
130
+ let C = U(_);
131
+ async function w(e) {
118
132
  e.preventDefault();
119
- let t = g.trim();
120
- u(t) == null && await d.workspace.renameFlow(n.flowId, t) && h("idle");
133
+ let t = _.trim();
134
+ U(t) == null && await s.workspace.renameFlow(n.flowId, t) && g("idle");
121
135
  }
122
- async function S() {
123
- await d.workspace.deleteFlow(n.flowId) && h("idle");
136
+ async function T() {
137
+ await s.workspace.deleteFlow(n.flowId) && g("idle");
124
138
  }
125
- return /* @__PURE__ */ K("div", {
139
+ return /* @__PURE__ */ J("div", {
126
140
  className: "resource-item-row",
141
+ ref: l,
127
142
  children: [
128
- /* @__PURE__ */ K(c, {
143
+ /* @__PURE__ */ J(B, {
129
144
  "aria-disabled": n.status == "retiring",
130
145
  className: "resource-list-row flow-columns",
131
146
  nativeButton: !1,
@@ -134,310 +149,355 @@ function $e({ badge: e, busy: t, flow: n, href: a, onSelect: o, store: d }) {
134
149
  e.preventDefault();
135
150
  return;
136
151
  }
137
- me(e, () => o(n));
152
+ ae(e, () => o(n));
138
153
  },
139
- render: /* @__PURE__ */ G("a", { href: n.status == "retiring" ? void 0 : a }),
154
+ render: /* @__PURE__ */ q("a", { href: n.status == "retiring" ? void 0 : a }),
140
155
  tabIndex: n.status == "retiring" ? -1 : void 0,
141
156
  variant: "ghost",
142
157
  children: [
143
- /* @__PURE__ */ K("span", {
158
+ /* @__PURE__ */ J("span", {
144
159
  className: "resource-primary-cell",
145
- children: [/* @__PURE__ */ G("span", {
160
+ children: [/* @__PURE__ */ q("span", {
146
161
  className: "resource-icon",
147
- children: /* @__PURE__ */ G(v, { name: "flow" })
148
- }), /* @__PURE__ */ K("span", { children: [/* @__PURE__ */ K("span", {
162
+ children: /* @__PURE__ */ q(H, { name: "flow" })
163
+ }), /* @__PURE__ */ J("span", { children: [/* @__PURE__ */ J("span", {
149
164
  className: "flex min-w-0 items-center gap-2",
150
- children: [/* @__PURE__ */ G("strong", {
165
+ children: [/* @__PURE__ */ q("strong", {
151
166
  className: "min-w-0 truncate",
152
167
  children: n.name
153
- }), e != null && /* @__PURE__ */ G(pe, {
168
+ }), e != null && /* @__PURE__ */ q(ie, {
154
169
  className: "min-w-0 shrink",
155
170
  title: e,
156
171
  variant: "secondary",
157
- children: /* @__PURE__ */ G("span", {
172
+ children: /* @__PURE__ */ q("span", {
158
173
  className: "truncate",
159
174
  children: e
160
175
  })
161
176
  })]
162
- }), /* @__PURE__ */ G("code", {
177
+ }), /* @__PURE__ */ q("code", {
163
178
  translate: "no",
164
179
  children: n.flowId
165
180
  })] })]
166
181
  }),
167
- /* @__PURE__ */ G("time", {
182
+ /* @__PURE__ */ q("time", {
168
183
  dateTime: n.updatedAt,
169
- children: new Date(n.updatedAt).toLocaleString(f)
184
+ children: new Date(n.updatedAt).toLocaleString(p)
170
185
  }),
171
- /* @__PURE__ */ K("span", {
172
- className: `resource-status ${n.status == "active" ? "active" : "warning"}`,
173
- children: [/* @__PURE__ */ G("span", {
174
- "aria-hidden": "true",
175
- className: `status-dot ${n.status == "active" ? "success" : "running"}`
176
- }), p(n.status == "active" ? "resource.active" : "resource.retiring")]
186
+ /* @__PURE__ */ q("span", {
187
+ className: "resource-status",
188
+ children: m(n.status == "retiring" ? "resource.retiring" : n.live == null ? "resource.notPublished" : x ? "resource.unpublishedChanges" : "resource.isPublished")
177
189
  })
178
190
  ]
179
191
  }),
180
- n.status == "active" && /* @__PURE__ */ G(c, {
181
- "aria-expanded": m != "idle",
182
- "aria-label": p("sidebar.flowActions", { name: n.name }),
183
- className: s("resource-row-more", m != "idle" && "active"),
184
- disabled: t != null,
185
- onClick: () => h(m == "idle" ? "actions" : "idle"),
186
- size: "icon-sm",
187
- variant: "ghost",
188
- children: /* @__PURE__ */ G(v, { name: "more" })
192
+ /* @__PURE__ */ J("div", {
193
+ className: "resource-live-controls",
194
+ "aria-busy": y != null,
195
+ children: [n.live == null ? /* @__PURE__ */ q("span", {
196
+ className: "resource-status",
197
+ title: m("resource.publishFirst"),
198
+ children: ""
199
+ }) : /* @__PURE__ */ J(Ie, {
200
+ className: "resource-enable",
201
+ title: m("resource.enabledHint"),
202
+ children: [/* @__PURE__ */ q(Ge, {
203
+ "aria-label": m("resource.enableFlow", { name: n.name }),
204
+ checked: n.live?.enabled ?? !1,
205
+ disabled: n.status != "active" || n.live == null || t != null || y != null,
206
+ onCheckedChange: (e) => void S(e),
207
+ size: "sm"
208
+ }), /* @__PURE__ */ q("span", { children: m(n.live?.enabled ? "resource.enabled" : "resource.disabled") })]
209
+ }), /* @__PURE__ */ q(B, {
210
+ disabled: n.status != "active" || t != null || y != null || n.live != null && !x,
211
+ onClick: () => void S("publish"),
212
+ size: "sm",
213
+ variant: "outline",
214
+ children: m(y == "publish" ? "workspace.publishing" : n.live == null ? "resource.publish" : "resource.publishUpdate")
215
+ })]
189
216
  }),
190
- m == "actions" && /* @__PURE__ */ K("div", {
191
- className: "resource-row-actions",
192
- children: [/* @__PURE__ */ G(c, {
217
+ n.status == "active" && /* @__PURE__ */ J(Ue, { children: [/* @__PURE__ */ q(He, {
218
+ "aria-label": m("sidebar.flowActions", { name: n.name }),
219
+ disabled: t != null || y != null,
220
+ render: /* @__PURE__ */ q(B, {
221
+ className: "resource-row-more",
222
+ ref: u,
223
+ size: "icon-sm",
224
+ variant: "ghost",
225
+ children: /* @__PURE__ */ q(H, { name: "more" })
226
+ })
227
+ }), /* @__PURE__ */ J(Ke, {
228
+ align: "end",
229
+ className: "min-w-36",
230
+ container: c,
231
+ finalFocus: h == "idle",
232
+ children: [/* @__PURE__ */ q(We, {
193
233
  onClick: () => {
194
- y(n.name), h("rename");
234
+ v(n.name), g("rename");
195
235
  },
196
- size: "sm",
197
- variant: "outline",
198
- children: p("common.rename")
199
- }), /* @__PURE__ */ G(c, {
200
- onClick: () => h("delete"),
201
- size: "sm",
236
+ children: m("common.rename")
237
+ }), /* @__PURE__ */ q(We, {
238
+ onClick: () => g("delete"),
202
239
  variant: "destructive",
203
- children: p("common.delete")
240
+ children: m("common.delete")
204
241
  })]
242
+ })] }),
243
+ /* @__PURE__ */ q(et, {
244
+ open: h == "rename",
245
+ onOpenChange: (e) => {
246
+ e || g("idle");
247
+ },
248
+ children: /* @__PURE__ */ q($e, {
249
+ container: c,
250
+ initialFocus: d,
251
+ finalFocus: u,
252
+ closeLabel: m("common.cancel"),
253
+ children: /* @__PURE__ */ J("form", {
254
+ className: "flex flex-col gap-4",
255
+ onSubmit: (e) => void w(e),
256
+ children: [
257
+ /* @__PURE__ */ q(rt, { children: /* @__PURE__ */ q(Qe, { children: m("sidebar.renameFlow", { name: n.name }) }) }),
258
+ /* @__PURE__ */ J(Re, {
259
+ "data-invalid": _.length > 0 && C != null,
260
+ children: [
261
+ /* @__PURE__ */ q(Ve, {
262
+ htmlFor: `rename-flow-${n.flowId}`,
263
+ children: m("resource.flowName")
264
+ }),
265
+ /* @__PURE__ */ q(V, {
266
+ autoComplete: "off",
267
+ "aria-invalid": _.length > 0 && C != null,
268
+ "aria-describedby": _.length > 0 && C != null ? `rename-error-${n.flowId}` : void 0,
269
+ id: `rename-flow-${n.flowId}`,
270
+ name: "flow-name",
271
+ onChange: (e) => v(e.target.value),
272
+ ref: d,
273
+ required: !0,
274
+ value: _
275
+ }),
276
+ _.length > 0 && C != null && /* @__PURE__ */ q(Fe, {
277
+ id: `rename-error-${n.flowId}`,
278
+ children: m(`resource.nameIssue.${C}`, { max: 80 })
279
+ })
280
+ ]
281
+ }),
282
+ /* @__PURE__ */ J(tt, { children: [/* @__PURE__ */ q(nt, {
283
+ render: /* @__PURE__ */ q(B, { variant: "outline" }),
284
+ type: "button",
285
+ children: m("common.cancel")
286
+ }), /* @__PURE__ */ q(B, {
287
+ disabled: t != null || C != null,
288
+ type: "submit",
289
+ children: m("common.save")
290
+ })] })
291
+ ]
292
+ })
293
+ })
205
294
  }),
206
- m == "rename" && /* @__PURE__ */ K("form", {
207
- className: "resource-row-form",
208
- onSubmit: (e) => void x(e),
209
- children: [
210
- /* @__PURE__ */ G(_, {
211
- htmlFor: `rename-flow-${n.flowId}`,
212
- children: p("sidebar.renameFlow", { name: n.name })
213
- }),
214
- /* @__PURE__ */ K("span", {
215
- className: "resource-row-field",
216
- children: [/* @__PURE__ */ G(l, {
217
- autoComplete: "off",
218
- "aria-invalid": g.length > 0 && b != null,
219
- autoFocus: !0,
220
- id: `rename-flow-${n.flowId}`,
221
- name: "flow-name",
222
- onChange: (e) => y(e.target.value),
223
- required: !0,
224
- value: g
225
- }), g.length > 0 && b != null && /* @__PURE__ */ G("small", {
226
- className: "resource-name-message error",
227
- children: p(`resource.nameIssue.${b}`, { max: 80 })
228
- })]
229
- }),
230
- /* @__PURE__ */ K("div", { children: [/* @__PURE__ */ G(c, {
231
- onClick: () => h("idle"),
232
- size: "sm",
233
- variant: "outline",
234
- children: p("common.cancel")
235
- }), /* @__PURE__ */ G(c, {
236
- disabled: t != null || b != null,
237
- size: "sm",
238
- type: "submit",
239
- children: p("common.save")
240
- })] })
241
- ]
242
- }),
243
- m == "delete" && /* @__PURE__ */ K("div", {
244
- className: "resource-row-confirm",
245
- role: "group",
246
- "aria-label": p("sidebar.deleteFlow", { name: n.name }),
247
- children: [/* @__PURE__ */ G("span", { children: /* @__PURE__ */ G("strong", { children: p("sidebar.deleteFlowConfirm", { name: n.name }) }) }), /* @__PURE__ */ K("div", { children: [/* @__PURE__ */ G(c, {
248
- onClick: () => h("idle"),
249
- size: "sm",
250
- variant: "outline",
251
- children: p("common.cancel")
252
- }), /* @__PURE__ */ G(c, {
253
- disabled: t != null,
254
- onClick: () => void S(),
255
- size: "sm",
256
- variant: "destructive",
257
- children: p(t == "flow" ? "common.deleting" : "common.delete")
258
- })] })]
295
+ /* @__PURE__ */ q(et, {
296
+ open: h == "delete",
297
+ onOpenChange: (e) => {
298
+ e || g("idle");
299
+ },
300
+ children: /* @__PURE__ */ J($e, {
301
+ container: c,
302
+ initialFocus: f,
303
+ finalFocus: u,
304
+ showCloseButton: !1,
305
+ children: [/* @__PURE__ */ J(rt, { children: [/* @__PURE__ */ q(Qe, { children: m("sidebar.deleteFlowConfirm", { name: n.name }) }), /* @__PURE__ */ q(Ze, { children: m("resource.deleteDescription") })] }), /* @__PURE__ */ J(tt, { children: [/* @__PURE__ */ q(nt, {
306
+ render: /* @__PURE__ */ q(B, {
307
+ ref: f,
308
+ variant: "outline"
309
+ }),
310
+ children: m("common.cancel")
311
+ }), /* @__PURE__ */ q(B, {
312
+ disabled: t != null,
313
+ onClick: () => void T(),
314
+ variant: "destructive",
315
+ children: m(t == "flow" ? "common.deleting" : "common.delete")
316
+ })] })]
317
+ })
259
318
  })
260
319
  ]
261
320
  });
262
321
  }
263
- function et() {
264
- return /* @__PURE__ */ K("div", {
322
+ function _t() {
323
+ return /* @__PURE__ */ J("div", {
265
324
  "aria-hidden": "true",
266
325
  className: "resource-list-row resource-skeleton-row flow-columns",
267
326
  children: [
268
- /* @__PURE__ */ K("span", {
327
+ /* @__PURE__ */ J("span", {
269
328
  className: "resource-primary-cell",
270
- children: [/* @__PURE__ */ G(V, { className: "size-8 shrink-0" }), /* @__PURE__ */ K("span", {
329
+ children: [/* @__PURE__ */ q(z, { className: "size-8 shrink-0" }), /* @__PURE__ */ J("span", {
271
330
  className: "resource-skeleton-copy",
272
- children: [/* @__PURE__ */ G(V, { className: "h-3.5 w-36" }), /* @__PURE__ */ G(V, { className: "h-2.5 w-48 max-w-full" })]
331
+ children: [/* @__PURE__ */ q(z, { className: "h-3.5 w-36" }), /* @__PURE__ */ q(z, { className: "h-2.5 w-48 max-w-full" })]
273
332
  })]
274
333
  }),
275
- /* @__PURE__ */ G(V, { className: "h-3 w-28" }),
276
- /* @__PURE__ */ G(V, { className: "h-3 w-16" })
334
+ /* @__PURE__ */ q(z, { className: "h-3 w-28" }),
335
+ /* @__PURE__ */ q(z, { className: "h-3 w-16" })
277
336
  ]
278
337
  });
279
338
  }
280
- function tt({ catalogWidth: e, createFlowDisabled: t, createFlowField: n, flowBadges: i, hrefForFlow: o, hostAction: l, hostTitle: d, language: f, onCreateFlow: p, onHostAction: m, onLanguageChange: h, onSelectFlow: g, store: _ }) {
281
- let y = r(), b = a(_.workspace.$.busy), S = a(_.workspace.$.flowLoadFailed), ee = a(_.workspace.$.flowLoadMoreFailed), C = a(_.workspace.$.flowLoading), w = a(_.workspace.$.flowLoadingMore), T = a(_.workspace.$.flowNextCursor), E = a(_.workspace.$.flowRefreshing), D = a(_.workspace.$.flows), O = a(_.workspace.$.flowTotal), [te, k] = W(!1), [A, j] = W(""), [M, N] = W(""), P = A.trim().toLocaleLowerCase(), F = D.filter((e) => e.name.toLocaleLowerCase().includes(P));
282
- async function I(e) {
339
+ function vt({ catalogWidth: e, createFlowDisabled: t, createFlowField: n, flowBadges: i, hrefForFlow: o, hostAction: c, hostTitle: l, language: u, onCreateFlow: d, onHostAction: f, onLanguageChange: p, onSelectFlow: m, store: h }) {
340
+ let g = r(), _ = a(h.workspace.$.busy), v = a(h.workspace.$.flowLoadFailed), y = a(h.workspace.$.flowLoadMoreFailed), b = a(h.workspace.$.flowLoading), x = a(h.workspace.$.flowLoadingMore), S = a(h.workspace.$.flowNextCursor), C = a(h.workspace.$.flowRefreshing), w = a(h.workspace.$.flows), T = a(h.workspace.$.flowTotal), [E, D] = K(!1), [O, ee] = K(""), [k, A] = K(""), j = O.trim().toLocaleLowerCase(), M = w.filter((e) => e.name.toLocaleLowerCase().includes(j));
341
+ async function N(e) {
283
342
  e.preventDefault();
284
- let t = M.trim();
285
- u(t) != null || !await p(t) || (k(!1), N(""));
343
+ let t = k.trim();
344
+ U(t) != null || !await d(t) || (D(!1), A(""));
286
345
  }
287
- return /* @__PURE__ */ G("main", {
346
+ return /* @__PURE__ */ q("main", {
288
347
  className: "resource-browser",
289
- children: /* @__PURE__ */ K("div", {
290
- className: s("resource-page", e != "default" && "resource-page-full"),
348
+ children: /* @__PURE__ */ J("div", {
349
+ className: Ne("resource-page", e != "default" && "resource-page-full"),
291
350
  children: [
292
- /* @__PURE__ */ G("h1", {
351
+ /* @__PURE__ */ q("h1", {
293
352
  className: "sr-only",
294
- children: y("resource.flows")
353
+ children: g("resource.flows")
295
354
  }),
296
- /* @__PURE__ */ K("section", {
355
+ /* @__PURE__ */ J("section", {
297
356
  "aria-labelledby": "flow-list-title",
298
357
  className: "resource-list-section",
299
358
  children: [
300
- /* @__PURE__ */ K("div", {
359
+ /* @__PURE__ */ J("div", {
301
360
  className: "resource-list-title",
302
- children: [/* @__PURE__ */ K("div", {
361
+ children: [/* @__PURE__ */ J("div", {
303
362
  className: "resource-list-heading",
304
- children: [/* @__PURE__ */ G("h2", {
363
+ children: [/* @__PURE__ */ q("h2", {
305
364
  id: "flow-list-title",
306
- children: y("resource.allFlows")
307
- }), !C && /* @__PURE__ */ G("span", { children: y("resource.flowCount", { count: O ?? D.length }) })]
308
- }), /* @__PURE__ */ K("div", {
365
+ children: g("resource.allFlows")
366
+ }), !b && /* @__PURE__ */ q("span", { children: g("resource.flowCount", { count: T ?? w.length }) })]
367
+ }), /* @__PURE__ */ J("div", {
309
368
  className: "resource-list-actions",
310
369
  children: [
311
- /* @__PURE__ */ G(Qe, {
312
- language: f,
313
- onLanguageChange: h
370
+ /* @__PURE__ */ q(ht, {
371
+ language: u,
372
+ onLanguageChange: p
314
373
  }),
315
- /* @__PURE__ */ K(we, {
374
+ /* @__PURE__ */ J(he, {
316
375
  className: "w-full sm:w-56",
317
- children: [/* @__PURE__ */ G(Ae, { children: /* @__PURE__ */ G(v, {
376
+ children: [/* @__PURE__ */ q(xe, { children: /* @__PURE__ */ q(H, {
318
377
  name: "search",
319
378
  size: 17
320
- }) }), /* @__PURE__ */ G(be, {
379
+ }) }), /* @__PURE__ */ q(de, {
321
380
  autoComplete: "off",
322
- "aria-label": y("resource.searchFlows"),
381
+ "aria-label": g("resource.searchFlows"),
323
382
  name: "flow-search",
324
- onChange: (e) => j(e.target.value),
325
- placeholder: y("resource.searchFlows"),
326
- value: A
383
+ onChange: (e) => ee(e.target.value),
384
+ placeholder: g("resource.searchFlows"),
385
+ value: O
327
386
  })]
328
387
  }),
329
- /* @__PURE__ */ G(c, {
330
- "aria-label": y("common.refresh"),
331
- disabled: C || E || b != null,
332
- onClick: () => void _.workspace.reloadFlows(),
388
+ /* @__PURE__ */ q(B, {
389
+ "aria-label": g("common.refresh"),
390
+ disabled: b || C || _ != null,
391
+ onClick: () => void h.workspace.reloadFlows(),
333
392
  size: "icon",
334
- title: y("common.refresh"),
393
+ title: g("common.refresh"),
335
394
  variant: "outline",
336
- children: /* @__PURE__ */ G(v, {
337
- className: E ? "animate-spin" : void 0,
395
+ children: /* @__PURE__ */ q(H, {
396
+ className: C ? "animate-spin" : void 0,
338
397
  name: "refresh"
339
398
  })
340
399
  }),
341
- /* @__PURE__ */ K(c, {
400
+ /* @__PURE__ */ J(B, {
342
401
  className: "resource-page-primary-action",
343
- disabled: b != null,
344
- onClick: () => k(!0),
345
- children: [/* @__PURE__ */ G(v, {
402
+ disabled: _ != null,
403
+ onClick: () => D(!0),
404
+ children: [/* @__PURE__ */ q(H, {
346
405
  "data-icon": "inline-start",
347
406
  name: "plus"
348
- }), y("resource.newFlow")]
407
+ }), g("resource.newFlow")]
349
408
  }),
350
- l != null && d != null && m != null && /* @__PURE__ */ G(x, {
351
- action: l,
352
- onAction: m,
353
- title: d
409
+ c != null && l != null && f != null && /* @__PURE__ */ q(s, {
410
+ action: c,
411
+ onAction: f,
412
+ title: l
354
413
  })
355
414
  ]
356
415
  })]
357
416
  }),
358
- /* @__PURE__ */ K("div", {
417
+ /* @__PURE__ */ J("div", {
359
418
  "aria-hidden": "true",
360
419
  className: "resource-list-columns flow-columns",
361
420
  children: [
362
- /* @__PURE__ */ G("span", { children: y("resource.name") }),
363
- /* @__PURE__ */ G("span", { children: y("resource.updated") }),
364
- /* @__PURE__ */ G("span", { children: y("resource.status") })
421
+ /* @__PURE__ */ q("span", { children: g("resource.name") }),
422
+ /* @__PURE__ */ q("span", { children: g("resource.updated") }),
423
+ /* @__PURE__ */ q("span", { children: g("resource.publication") }),
424
+ /* @__PURE__ */ q("span", { children: g("resource.enabledColumn") })
365
425
  ]
366
426
  }),
367
- /* @__PURE__ */ G("div", {
427
+ /* @__PURE__ */ q("div", {
368
428
  className: "resource-list",
369
- children: C ? Array.from({ length: 5 }, (e, t) => /* @__PURE__ */ G(et, {}, t)) : S ? /* @__PURE__ */ K(ce, {
429
+ children: b ? Array.from({ length: 5 }, (e, t) => /* @__PURE__ */ q(_t, {}, t)) : v ? /* @__PURE__ */ J(te, {
370
430
  className: "min-h-64",
371
431
  role: "alert",
372
- children: [/* @__PURE__ */ K(de, { children: [
373
- /* @__PURE__ */ G(Se, {
432
+ children: [/* @__PURE__ */ J(ne, { children: [
433
+ /* @__PURE__ */ q(pe, {
374
434
  variant: "icon",
375
- children: /* @__PURE__ */ G(v, {
435
+ children: /* @__PURE__ */ q(H, {
376
436
  name: "alert",
377
437
  size: 20
378
438
  })
379
439
  }),
380
- /* @__PURE__ */ G(Fe, { children: y("resource.flowsLoadFailed") }),
381
- /* @__PURE__ */ G(Me, { children: y("resource.flowsLoadFailedDescription") })
382
- ] }), /* @__PURE__ */ G(Ee, { children: /* @__PURE__ */ G(c, {
383
- onClick: () => void _.retryFlows(),
440
+ /* @__PURE__ */ q(Ee, { children: g("resource.flowsLoadFailed") }),
441
+ /* @__PURE__ */ q(Ce, { children: g("resource.flowsLoadFailedDescription") })
442
+ ] }), /* @__PURE__ */ q(_e, { children: /* @__PURE__ */ q(B, {
443
+ onClick: () => void h.retryFlows(),
384
444
  variant: "outline",
385
- children: y("empty.retry")
445
+ children: g("empty.retry")
386
446
  }) })]
387
- }) : F.length == 0 ? /* @__PURE__ */ K(ce, {
447
+ }) : M.length == 0 ? /* @__PURE__ */ J(te, {
388
448
  className: "min-h-64",
389
- children: [/* @__PURE__ */ K(de, { children: [
390
- /* @__PURE__ */ G(Se, {
449
+ children: [/* @__PURE__ */ J(ne, { children: [
450
+ /* @__PURE__ */ q(pe, {
391
451
  variant: "icon",
392
- children: /* @__PURE__ */ G(v, {
452
+ children: /* @__PURE__ */ q(H, {
393
453
  name: "flow",
394
454
  size: 20
395
455
  })
396
456
  }),
397
- /* @__PURE__ */ G(Fe, { children: y(P.length == 0 ? "resource.noFlows" : "resource.noMatchingFlows") }),
398
- /* @__PURE__ */ G(Me, { children: y(P.length == 0 ? "resource.noFlowsDescription" : "resource.noMatchingDescription") })
399
- ] }), P.length == 0 && /* @__PURE__ */ G(Ee, { children: /* @__PURE__ */ K(c, {
400
- onClick: () => k(!0),
457
+ /* @__PURE__ */ q(Ee, { children: g(j.length == 0 ? "resource.noFlows" : "resource.noMatchingFlows") }),
458
+ /* @__PURE__ */ q(Ce, { children: g(j.length == 0 ? "resource.noFlowsDescription" : "resource.noMatchingDescription") })
459
+ ] }), j.length == 0 && /* @__PURE__ */ q(_e, { children: /* @__PURE__ */ J(B, {
460
+ onClick: () => D(!0),
401
461
  variant: "outline",
402
- children: [/* @__PURE__ */ G(v, {
462
+ children: [/* @__PURE__ */ q(H, {
403
463
  "data-icon": "inline-start",
404
464
  name: "plus"
405
- }), y("resource.newFlow")]
465
+ }), g("resource.newFlow")]
406
466
  }) })]
407
- }) : F.map((e) => /* @__PURE__ */ G($e, {
467
+ }) : M.map((e) => /* @__PURE__ */ q(gt, {
408
468
  badge: i?.[e.flowId],
409
- busy: b,
469
+ busy: _,
410
470
  flow: e,
411
471
  href: o(e),
412
- onSelect: g,
413
- store: _
472
+ onSelect: m,
473
+ store: h
414
474
  }, e.flowId))
415
475
  }),
416
- T != null && /* @__PURE__ */ G("div", {
476
+ S != null && /* @__PURE__ */ q("div", {
417
477
  className: "resource-list-footer",
418
- children: /* @__PURE__ */ G(c, {
419
- disabled: w || E,
420
- onClick: () => void _.workspace.loadMoreFlows(),
478
+ children: /* @__PURE__ */ q(B, {
479
+ disabled: x || C,
480
+ onClick: () => void h.workspace.loadMoreFlows(),
421
481
  variant: "outline",
422
- children: y(w ? "resource.loadingMore" : ee ? "resource.retryLoadMore" : "resource.loadMore")
482
+ children: g(x ? "resource.loadingMore" : y ? "resource.retryLoadMore" : "resource.loadMore")
423
483
  })
424
484
  })
425
485
  ]
426
486
  }),
427
- te && /* @__PURE__ */ G(Ge, {
487
+ E && /* @__PURE__ */ q(at, {
428
488
  fallback: null,
429
- children: /* @__PURE__ */ G(Xe, {
489
+ children: /* @__PURE__ */ q(pt, {
430
490
  disabled: t,
431
491
  field: n,
432
492
  id: "flow-name",
433
- issue: u(M),
434
- label: y("resource.flowName"),
435
- name: M,
436
- onNameChange: N,
437
- onOpenChange: k,
438
- onSubmit: (e) => void I(e),
439
- pending: b == "flow",
440
- title: y("resource.newFlow")
493
+ issue: U(k),
494
+ label: g("resource.flowName"),
495
+ name: k,
496
+ onNameChange: A,
497
+ onOpenChange: D,
498
+ onSubmit: (e) => void N(e),
499
+ pending: _ == "flow",
500
+ title: g("resource.newFlow")
441
501
  })
442
502
  })
443
503
  ]
@@ -446,7 +506,7 @@ function tt({ catalogWidth: e, createFlowDisabled: t, createFlowField: n, flowBa
446
506
  }
447
507
  //#endregion
448
508
  //#region ../../node_modules/.bun/nanoid@6.0.1/node_modules/nanoid/index.browser.js
449
- var nt = (e) => crypto.getRandomValues(new Uint8Array(e)), rt = (e, t, n) => {
509
+ var yt = (e) => crypto.getRandomValues(new Uint8Array(e)), bt = (e, t, n) => {
450
510
  let r = 256 - 256 % e.length;
451
511
  if (r === 256) {
452
512
  let r = e.length - 1;
@@ -468,43 +528,29 @@ var nt = (e) => crypto.getRandomValues(new Uint8Array(e)), rt = (e, t, n) => {
468
528
  for (; s--;) if (t[s] < r && (o += e[t[s] % e.length], o.length >= a)) return o;
469
529
  }
470
530
  };
471
- }, it = (e, t = 21) => rt(e, t | 0, nt);
531
+ }, xt = (e, t = 21) => bt(e, t | 0, yt);
472
532
  //#endregion
473
533
  //#region src/flow/common/edgeChanges.ts
474
- function at(e, t, n) {
475
- let r = {
476
- source: n.source,
477
- sourceHandle: n.sourceHandle,
478
- target: n.target,
479
- targetHandle: n.targetHandle
480
- }, i = st(e, t)?.nodes[n.target], a = i != null && "inputs" in i ? i.inputs[n.targetHandle] : void 0;
481
- return a?.kind == "sources" && a.sources.some((e) => e.kind == "node" && e.nodeId == n.source && e.output == n.sourceHandle) ? [] : ke(e, [{
482
- before: a,
483
- edge: r,
534
+ function St(e, t, n) {
535
+ return wt(e, t)?.edges.some((e) => Me(e, n)) ? [] : [{
536
+ edge: n,
484
537
  kind: "graph.edge.connect",
485
538
  target: t
486
- }]);
539
+ }];
487
540
  }
488
- function ot(e, t, n) {
489
- let r = {
490
- source: n.source,
491
- sourceHandle: n.sourceHandle,
492
- target: n.target,
493
- targetHandle: n.targetHandle
494
- }, i = st(e, t)?.nodes[n.target], a = i != null && "inputs" in i ? i.inputs[n.targetHandle] : void 0;
495
- return a?.kind != "sources" || !a.sources.some((e) => e.kind == "node" && e.nodeId == n.source && e.output == n.sourceHandle) ? [] : [{
496
- before: a,
497
- edge: r,
541
+ function Ct(e, t, n) {
542
+ return wt(e, t)?.edges.some((e) => Me(e, n)) ? [{
543
+ edge: n,
498
544
  kind: "graph.edge.disconnect",
499
545
  target: t
500
- }];
546
+ }] : [];
501
547
  }
502
- function st(e, t) {
548
+ function wt(e, t) {
503
549
  return t.kind == "flow" ? e.document.graph : e.document.subflows[t.id]?.graph;
504
550
  }
505
551
  //#endregion
506
552
  //#region src/flow/common/moduleChanges.ts
507
- async function ct(e) {
553
+ async function Tt(e) {
508
554
  try {
509
555
  let { parse: t } = await import("./lib-C5Ipyfps.js").then((e) => e.t), n = t(e, {
510
556
  errorRecovery: !0,
@@ -520,7 +566,7 @@ async function ct(e) {
520
566
  return [];
521
567
  }
522
568
  }
523
- function lt(e, t, n, r, i) {
569
+ function Et(e, t, n, r, i) {
524
570
  return [{
525
571
  beforeImports: n,
526
572
  beforeSource: t,
@@ -530,7 +576,7 @@ function lt(e, t, n, r, i) {
530
576
  source: r
531
577
  }];
532
578
  }
533
- var ut = it("23456789abcdefghjkmnpqrstuvwxyz", 10), q = {
579
+ var Dt = xt("23456789abcdefghjkmnpqrstuvwxyz", 10), X = {
534
580
  activities: [],
535
581
  activitiesLoadFailed: !1,
536
582
  activitiesLoading: !1,
@@ -545,24 +591,25 @@ var ut = it("23456789abcdefghjkmnpqrstuvwxyz", 10), q = {
545
591
  publications: [],
546
592
  publishing: !1,
547
593
  refreshing: !1
548
- }, dt = 20, ft = 50, pt = 750;
549
- function J(e, t) {
594
+ }, Ot = 20, kt = 50, At = 750;
595
+ function Z(e, t) {
550
596
  return e?.flowId == t.flowId;
551
597
  }
552
- var mt = class {
598
+ var jt = class {
553
599
  #e;
554
600
  #t;
555
601
  #n;
556
- #r = new F();
557
- #i = new F();
602
+ #r = new m();
603
+ #i = new m();
558
604
  #a;
559
- #o = new F();
560
- #s = new F();
605
+ #o = new m();
606
+ #s = new m();
561
607
  #c;
562
- #l = t(q);
608
+ #l = t(X);
563
609
  #u;
564
610
  #d;
565
- constructor(t, n, r, i, a = () => crypto.randomUUID(), o = L()) {
611
+ #f;
612
+ constructor(t, n, r, i, a = F, o = P()) {
566
613
  this.#e = t, this.#t = a, this.#n = o, this.#a = i, this.#c = r, this.#u = n, this.$ = {
567
614
  activities: e(this.#l, (e) => e.activities),
568
615
  activitiesLoadFailed: e(this.#l, (e) => e.activitiesLoadFailed),
@@ -591,29 +638,29 @@ var mt = class {
591
638
  };
592
639
  }
593
640
  dispose() {
594
- this.#r.invalidate(), this.#i.invalidate(), this.#o.invalidate(), this.#s.invalidate();
641
+ this.#r.invalidate(), this.#i.invalidate(), this.#v(), this.#o.invalidate(), this.#s.invalidate();
595
642
  for (let e of Object.values(this.$)) e.dispose();
596
643
  this.#l.dispose();
597
644
  }
598
645
  reset() {
599
- this.#r.invalidate(), this.#i.invalidate(), this.#o.invalidate(), this.#s.invalidate(), this.#d = void 0, this.#l.set(q);
646
+ this.#r.invalidate(), this.#i.invalidate(), this.#v(), this.#o.invalidate(), this.#s.invalidate(), this.#f = void 0, this.#l.set(X);
600
647
  }
601
648
  async load(e) {
602
- let t = { flowId: e }, n = this.#l.value, r = n.loaded && J(n.target, t), i = this.#r.begin();
603
- J(n.target, t) || (this.#i.invalidate(), this.#d = void 0), r ? this.#y({
649
+ let t = { flowId: e }, n = this.#l.value, r = n.loaded && Z(n.target, t), i = this.#r.begin();
650
+ Z(n.target, t) || (this.#i.invalidate(), this.#v(), this.#f = void 0), r ? this.#x({
604
651
  loadFailed: !1,
605
652
  loadingMore: !1,
606
653
  loadMoreFailed: !1,
607
654
  refreshing: !0
608
655
  }) : (this.#c(void 0), this.#l.set({
609
- ...q,
656
+ ...X,
610
657
  loading: !0,
611
658
  target: t
612
659
  }));
613
660
  try {
614
- let e = r ? n.operation : await this.#h(t), [a, o, s] = await this.#m(t);
661
+ let e = r ? n.operation : await this.#g(t), [a, o, s] = await this.#h(t);
615
662
  if (!i()) return;
616
- if (this.#u.updateLive(a), this.#y({
663
+ if (this.#u.updateLive(a), this.#x({
617
664
  bindings: s,
618
665
  live: a,
619
666
  loaded: !0,
@@ -628,33 +675,33 @@ var mt = class {
628
675
  }
629
676
  }), !r && e?.status == "pending") {
630
677
  let n = this.#u.$.targetFlow.value;
631
- this.#g(t, e, this.#i.begin(), n?.flowId == t.flowId ? n.name : t.flowId);
678
+ this.#_(t, e, this.#i.begin(), n?.flowId == t.flowId ? n.name : t.flowId);
632
679
  }
633
680
  } catch (e) {
634
681
  if (!i()) return;
635
- this.#y({
682
+ this.#x({
636
683
  loadFailed: !r,
637
684
  loading: !1,
638
685
  refreshing: !1
639
- }), this.#c(D(e, this.#n.t));
686
+ }), this.#c(E(e, this.#n.t));
640
687
  }
641
688
  }
642
689
  async loadMore() {
643
690
  let { loadingMore: e, nextCursor: t, target: n } = this.#l.value;
644
691
  if (e || t == null || n == null) return;
645
692
  let r = this.#r.capture();
646
- this.#y({
693
+ this.#x({
647
694
  loadMoreFailed: !1,
648
695
  loadingMore: !0
649
696
  });
650
697
  try {
651
698
  let e = await this.#e.listPublications(n.flowId, {
652
699
  cursor: t,
653
- limit: ft
700
+ limit: kt
654
701
  });
655
702
  if (!r()) return;
656
703
  let i = new Set(this.#l.value.publications.map((e) => e.publicationId));
657
- this.#y({
704
+ this.#x({
658
705
  loadingMore: !1,
659
706
  loadMoreFailed: !1,
660
707
  nextCursor: e.nextCursor,
@@ -662,35 +709,39 @@ var mt = class {
662
709
  });
663
710
  } catch (e) {
664
711
  if (!r()) return;
665
- this.#y({
712
+ this.#x({
666
713
  loadMoreFailed: !0,
667
714
  loadingMore: !1
668
- }), this.#c(D(e, this.#n.t));
715
+ }), this.#c(E(e, this.#n.t));
669
716
  }
670
717
  }
671
718
  async publish() {
672
- let e = this.#u.$.targetFlow.value, t = this.#u.$.draft.value;
673
- if (e == null || t == null || this.#l.value.changingTriggerId != null || this.#l.value.publishing || this.#l.value.rollingBackPublicationId != null) return !1;
674
- let n = { flowId: e.flowId }, r = this.#u.$.live.value?.publication?.publicationId ?? null, i = JSON.stringify({
675
- expectedLivePublicationId: r,
676
- flowId: e.flowId,
719
+ let e = this.#u.$.flowId.value;
720
+ if (!await this.#u.saveModuleEditor() || e != this.#u.$.flowId.value) return !1;
721
+ let t = this.#u.$.targetFlow.value, n = this.#u.$.draft.value;
722
+ if (t == null || n == null || this.#l.value.changingTriggerId != null || this.#l.value.publishing || this.#l.value.rollingBackPublicationId != null) return !1;
723
+ let r = { flowId: t.flowId }, i = this.#u.$.live.value?.publication?.publicationId ?? null, a = JSON.stringify({
724
+ expectedLivePublicationId: i,
725
+ flowId: t.flowId,
677
726
  kind: "publish",
678
- revisionId: t.revisionId
679
- }), a = this.#d?.signature == i ? this.#d : {
727
+ revisionId: n.revisionId
728
+ }), o = this.#f?.signature == a ? this.#f : {
680
729
  key: this.#t(),
681
- signature: i
682
- }, o = this.#i.begin();
683
- this.#d = a, this.#c(void 0), this.#v(n, { publishing: !0 });
730
+ signature: a
731
+ };
732
+ this.#v();
733
+ let s = this.#i.begin();
734
+ this.#f = o, this.#c(void 0), this.#b(r, { publishing: !0 });
684
735
  try {
685
- let i = await this.#e.publishFlow(e.flowId, t.revisionId, r, { idempotencyKey: a.key });
686
- return o() ? (this.#a.setItem(this.#_(n.flowId), i.operationId), this.#y({
687
- operation: i,
688
- publishing: i.status == "pending"
689
- }), await this.#g(n, i, o, e.name)) : !1;
736
+ let e = await this.#e.publishFlow(t.flowId, n.revisionId, i, { idempotencyKey: o.key });
737
+ return s() ? (this.#a.setItem(this.#y(r.flowId), e.operationId), this.#x({
738
+ operation: e,
739
+ publishing: e.status == "pending"
740
+ }), await this.#_(r, e, s, t.name)) : !1;
690
741
  } catch (e) {
691
- return o() ? (e instanceof z && e.code == "live.conflict" && await this.#p(n), this.#c(D(e, this.#n.t)), !1) : !1;
742
+ return s() ? (e instanceof L && e.code == "live.conflict" && await this.#m(r), this.#c(E(e, this.#n.t)), !1) : !1;
692
743
  } finally {
693
- o() && this.#y({ publishing: !1 });
744
+ s() && this.#x({ publishing: !1 });
694
745
  }
695
746
  }
696
747
  async rollback(e) {
@@ -701,24 +752,26 @@ var mt = class {
701
752
  flowId: r.flowId,
702
753
  kind: "rollback",
703
754
  targetPublicationId: e.publicationId
704
- }), o = this.#d?.signature == a ? this.#d : {
755
+ }), o = this.#f?.signature == a ? this.#f : {
705
756
  key: this.#t(),
706
757
  signature: a
707
- }, s = this.#i.begin();
708
- this.#d = o, this.#c(void 0), this.#y({ rollingBackPublicationId: e.publicationId });
758
+ };
759
+ this.#v();
760
+ let s = this.#i.begin();
761
+ this.#f = o, this.#c(void 0), this.#x({ rollingBackPublicationId: e.publicationId });
709
762
  try {
710
- return await this.#e.rollbackFlow(r.flowId, e.publicationId, i, { idempotencyKey: o.key }), !s() || (await this.#f(r), !s()) ? !1 : (this.#d = void 0, this.#c({
763
+ return await this.#e.rollbackFlow(r.flowId, e.publicationId, i, { idempotencyKey: o.key }), !s() || (await this.#p(r), !s()) ? !1 : (this.#f = void 0, this.#c({
711
764
  kind: "success",
712
765
  message: this.#n.t("notice.rolledBack", { revision: e.revisionId })
713
766
  }), !0);
714
767
  } catch (e) {
715
- return s() ? (e instanceof z && e.code == "live.conflict" && await this.#p(r), this.#c(D(e, this.#n.t)), !1) : !1;
768
+ return s() ? (e instanceof L && e.code == "live.conflict" && await this.#m(r), this.#c(E(e, this.#n.t)), !1) : !1;
716
769
  } finally {
717
- s() && this.#y({ rollingBackPublicationId: void 0 });
770
+ s() && this.#x({ rollingBackPublicationId: void 0 });
718
771
  }
719
772
  }
720
773
  closeTrigger() {
721
- this.#o.invalidate(), this.#s.invalidate(), this.#y({
774
+ this.#o.invalidate(), this.#s.invalidate(), this.#x({
722
775
  activities: [],
723
776
  activitiesLoadFailed: !1,
724
777
  activitiesLoading: !1,
@@ -735,7 +788,7 @@ var mt = class {
735
788
  let t = this.#l.value.target;
736
789
  if (t == null) return;
737
790
  let n = this.#o.begin();
738
- this.#s.invalidate(), this.#y({
791
+ this.#s.invalidate(), this.#x({
739
792
  activities: [],
740
793
  activitiesLoadFailed: !1,
741
794
  activitiesLoading: !0,
@@ -747,45 +800,45 @@ var mt = class {
747
800
  testingTriggerId: void 0,
748
801
  testResult: void 0
749
802
  });
750
- let [r, i] = await Promise.allSettled([this.#e.getFlowTriggerBinding(t.flowId, e), this.#e.listFlowTriggerActivities(t.flowId, e, { limit: dt })]);
803
+ let [r, i] = await Promise.allSettled([this.#e.getFlowTriggerBinding(t.flowId, e), this.#e.listFlowTriggerActivities(t.flowId, e, { limit: Ot })]);
751
804
  if (n()) {
752
805
  if (r.status == "rejected") {
753
- this.#y({
806
+ this.#x({
754
807
  activitiesLoading: !1,
755
808
  detailLoading: !1
756
- }), this.#c(D(r.reason, this.#n.t));
809
+ }), this.#c(E(r.reason, this.#n.t));
757
810
  return;
758
811
  }
759
- this.#y({
812
+ this.#x({
760
813
  detail: r.value,
761
814
  detailLoading: !1
762
- }), i.status == "fulfilled" ? this.#y({
815
+ }), i.status == "fulfilled" ? this.#x({
763
816
  activities: i.value.activities,
764
817
  activitiesLoadFailed: !1,
765
818
  activitiesLoading: !1,
766
819
  activitiesNextCursor: i.value.nextCursor
767
- }) : (this.#y({
820
+ }) : (this.#x({
768
821
  activitiesLoadFailed: !0,
769
822
  activitiesLoading: !1
770
- }), this.#c(D(i.reason, this.#n.t)));
823
+ }), this.#c(E(i.reason, this.#n.t)));
771
824
  }
772
825
  }
773
826
  async loadMoreTriggerActivities() {
774
827
  let { activitiesLoadingMore: e, activitiesNextCursor: t, selectedTriggerId: n, target: r } = this.#l.value;
775
828
  if (e || t == null || n == null || r == null) return;
776
829
  let i = this.#o.capture();
777
- this.#y({
830
+ this.#x({
778
831
  activitiesLoadFailed: !1,
779
832
  activitiesLoadingMore: !0
780
833
  });
781
834
  try {
782
835
  let e = await this.#e.listFlowTriggerActivities(r.flowId, n, {
783
836
  cursor: t,
784
- limit: dt
837
+ limit: Ot
785
838
  });
786
839
  if (!i() || this.#l.value.selectedTriggerId != n) return;
787
840
  let a = new Set(this.#l.value.activities.map((e) => e.activityId));
788
- this.#y({
841
+ this.#x({
789
842
  activities: [...this.#l.value.activities, ...e.activities.filter((e) => !a.has(e.activityId))],
790
843
  activitiesLoadFailed: !1,
791
844
  activitiesLoadingMore: !1,
@@ -793,329 +846,421 @@ var mt = class {
793
846
  });
794
847
  } catch (e) {
795
848
  if (!i() || this.#l.value.selectedTriggerId != n) return;
796
- this.#y({
849
+ this.#x({
797
850
  activitiesLoadFailed: !0,
798
851
  activitiesLoadingMore: !1
799
- }), this.#c(D(e, this.#n.t));
852
+ }), this.#c(E(e, this.#n.t));
800
853
  }
801
854
  }
802
855
  async testTrigger() {
803
856
  let { detail: e, selectedTriggerId: t, target: n, testingTriggerId: r } = this.#l.value;
804
857
  if (e?.binding.kind != "poll" || e.binding.currentPublicationId == null || t == null || n == null || r != null) return !1;
805
858
  let i = this.#s.begin();
806
- this.#y({
859
+ this.#x({
807
860
  testingTriggerId: t,
808
861
  testResult: void 0
809
862
  });
810
863
  try {
811
864
  let e = await this.#e.testFlowPollTrigger(n.flowId, t);
812
- return !i() || this.#l.value.selectedTriggerId != t ? !1 : (this.#y({ testResult: e }), !0);
865
+ return !i() || this.#l.value.selectedTriggerId != t ? !1 : (this.#x({ testResult: e }), !0);
813
866
  } catch (e) {
814
- return i() && this.#l.value.selectedTriggerId == t && this.#c(D(e, this.#n.t)), !1;
867
+ return i() && this.#l.value.selectedTriggerId == t && this.#c(E(e, this.#n.t)), !1;
815
868
  } finally {
816
- i() && this.#l.value.selectedTriggerId == t && this.#y({ testingTriggerId: void 0 });
869
+ i() && this.#l.value.selectedTriggerId == t && this.#x({ testingTriggerId: void 0 });
817
870
  }
818
871
  }
819
872
  async toggleTrigger(e) {
820
873
  let t = this.#l.value.target;
821
874
  if (t == null || this.#l.value.changingTriggerId != null || this.#l.value.publishing || this.#l.value.rollingBackPublicationId != null) return !1;
875
+ this.#v();
822
876
  let n = this.#i.begin();
823
- this.#y({ changingTriggerId: e.triggerNodeId });
877
+ this.#x({ changingTriggerId: e.triggerNodeId });
824
878
  try {
825
879
  if (e.operatorState == "active" ? await this.#e.pauseFlowTrigger(t.flowId, e.triggerNodeId) : await this.#e.resumeFlowTrigger(t.flowId, e.triggerNodeId), !n()) return !1;
826
880
  let r = await this.#e.listFlowTriggerBindings(t.flowId);
827
- return n() ? (this.#y({ bindings: r }), this.#l.value.selectedTriggerId == e.triggerNodeId && this.openTrigger(e.triggerNodeId), this.#c({
881
+ return n() ? (this.#x({ bindings: r }), this.#l.value.selectedTriggerId == e.triggerNodeId && this.openTrigger(e.triggerNodeId), this.#c({
828
882
  kind: "success",
829
883
  message: this.#n.t(e.operatorState == "active" ? "notice.triggerPaused" : "notice.triggerResumed")
830
884
  }), !0) : !1;
831
885
  } catch (e) {
832
- return n() && this.#c(D(e, this.#n.t)), !1;
886
+ return n() && this.#c(E(e, this.#n.t)), !1;
833
887
  } finally {
834
- n() && this.#y({ changingTriggerId: void 0 });
888
+ n() && this.#x({ changingTriggerId: void 0 });
835
889
  }
836
890
  }
837
- async #f(e) {
838
- let t = this.#r.begin(), [n, r, i] = await this.#m(e).catch((n) => {
839
- throw t() && J(this.#l.value.target, e) && this.#y({ refreshing: !1 }), n;
891
+ async #p(e, t) {
892
+ let n = this.#r.begin(), [r, i, a] = await this.#h(e, t).catch((t) => {
893
+ throw n() && Z(this.#l.value.target, e) && this.#x({ refreshing: !1 }), t;
840
894
  });
841
- t() && this.#u.updateLive(n), t() && J(this.#l.value.target, e) && this.#y({
842
- bindings: i,
843
- live: n,
895
+ t?.throwIfAborted(), n() && this.#u.updateLive(r), n() && Z(this.#l.value.target, e) && this.#x({
896
+ bindings: a,
897
+ live: r,
844
898
  loaded: !0,
845
899
  loadFailed: !1,
846
900
  loadingMore: !1,
847
- nextCursor: r.nextCursor,
848
- publications: r.publications,
901
+ nextCursor: i.nextCursor,
902
+ publications: i.publications,
849
903
  refreshing: !1,
850
- total: r.total
904
+ total: i.total
851
905
  }), await this.#u.refreshFlows();
852
906
  }
853
- async #p(e) {
907
+ async #m(e) {
854
908
  try {
855
- await this.#f(e), this.#d = void 0;
909
+ await this.#p(e), this.#f = void 0;
856
910
  } catch {
857
911
  return;
858
912
  }
859
913
  }
860
- async #m(e) {
914
+ async #h(e, t) {
861
915
  return await Promise.all([
862
- this.#e.getLive(e.flowId),
916
+ this.#e.getLive(e.flowId, t),
863
917
  this.#e.listPublications(e.flowId, {
864
918
  includeTotal: !0,
865
- limit: ft
866
- }),
867
- this.#e.listFlowTriggerBindings(e.flowId)
919
+ limit: kt
920
+ }, t),
921
+ this.#e.listFlowTriggerBindings(e.flowId, t)
868
922
  ]);
869
923
  }
870
- async #h(e) {
871
- let t = this.#a.getItem(this.#_(e.flowId));
924
+ async #g(e) {
925
+ let t = this.#a.getItem(this.#y(e.flowId));
872
926
  if (t != null && t != "") try {
873
927
  return await this.#e.getPublishOperation(e.flowId, t);
874
928
  } catch (t) {
875
- if (t instanceof z && t.code == "publication.operation-not-found") {
876
- this.#a.setItem(this.#_(e.flowId), "");
929
+ if (t instanceof L && t.code == "publication.operation-not-found") {
930
+ this.#a.setItem(this.#y(e.flowId), "");
877
931
  return;
878
932
  }
879
933
  throw t;
880
934
  }
881
935
  }
882
- async #g(e, t, n, r) {
883
- let i = t;
884
- for (; i.status == "pending";) {
885
- if (await new Promise((e) => setTimeout(e, pt)), !n()) return !1;
886
- try {
887
- i = await this.#e.getPublishOperation(e.flowId, i.operationId);
888
- } catch (t) {
936
+ async #_(e, t, n, r) {
937
+ this.#v();
938
+ let i = Y.runFork(Y.gen({ self: this }, function* () {
939
+ let i = t;
940
+ for (; i.status == "pending";) {
941
+ if (yield* Y.sleep(At), !n()) return !1;
942
+ let t = yield* Y.tryPromise({
943
+ try: (t) => this.#e.getPublishOperation(e.flowId, i.operationId, t),
944
+ catch: (e) => e
945
+ }).pipe(Y.match({
946
+ onFailure: (e) => ({ error: e }),
947
+ onSuccess: (e) => ({ value: e })
948
+ }));
889
949
  if (!n()) return !1;
890
- if (t instanceof z && t.code == "publication.operation-not-found") return this.#a.setItem(this.#_(e.flowId), ""), this.#v(e, {
891
- operation: void 0,
892
- publishing: !1
893
- }), this.#c(D(t, this.#n.t)), !1;
894
- this.#c(D(t, this.#n.t));
895
- continue;
950
+ if ("error" in t) {
951
+ let n = t.error;
952
+ if (n instanceof L && n.code == "publication.operation-not-found") return this.#a.setItem(this.#y(e.flowId), ""), this.#b(e, {
953
+ operation: void 0,
954
+ publishing: !1
955
+ }), this.#c(E(n, this.#n.t)), !1;
956
+ this.#c(E(n, this.#n.t));
957
+ continue;
958
+ }
959
+ i = t.value, this.#b(e, { operation: i });
896
960
  }
897
961
  if (!n()) return !1;
898
- this.#v(e, { operation: i });
899
- }
900
- if (this.#d = void 0, this.#v(e, {
901
- operation: i,
902
- publishing: !1
903
- }), i.status == "failed") return this.#c({
904
- kind: "error",
905
- message: i.issue.message
906
- }), !1;
907
- try {
908
- await this.#f(e);
909
- } catch (e) {
910
- return n() && this.#c(D(e, this.#n.t)), !0;
911
- }
912
- return n() ? (this.#c({
913
- kind: "success",
914
- message: this.#n.t("notice.published", { name: r })
915
- }), !0) : !1;
962
+ if (this.#f = void 0, this.#b(e, {
963
+ operation: i,
964
+ publishing: !1
965
+ }), i.status == "failed") return this.#c({
966
+ kind: "error",
967
+ message: i.issue.message
968
+ }), !1;
969
+ let a = yield* Y.tryPromise({
970
+ try: (t) => this.#p(e, t),
971
+ catch: (e) => e
972
+ }).pipe(Y.match({
973
+ onFailure: (e) => (n() && this.#c(E(e, this.#n.t)), !1),
974
+ onSuccess: () => !0
975
+ }));
976
+ return n() ? (a && this.#c({
977
+ kind: "success",
978
+ message: this.#n.t("notice.published", { name: r })
979
+ }), !0) : !1;
980
+ }));
981
+ this.#d = i;
982
+ let a = await Y.runPromiseExit(ut.join(i));
983
+ if (lt.isSuccess(a)) return a.value;
984
+ if (ct.hasInterruptsOnly(a.cause)) return !1;
985
+ throw ct.squash(a.cause);
986
+ }
987
+ #v() {
988
+ this.#d?.interruptUnsafe(), this.#d = void 0;
916
989
  }
917
- #_(e) {
990
+ #y(e) {
918
991
  return `publish-operation:${e}`;
919
992
  }
920
- #v(e, t) {
921
- J(this.#l.value.target, e) ? this.#y(t) : this.#l.set({
922
- ...q,
993
+ #b(e, t) {
994
+ Z(this.#l.value.target, e) ? this.#x(t) : this.#l.set({
995
+ ...X,
923
996
  ...t,
924
997
  target: e
925
998
  });
926
999
  }
927
- #y(e) {
1000
+ #x(e) {
928
1001
  this.#l.set({
929
1002
  ...this.#l.value,
930
1003
  ...e
931
1004
  });
932
1005
  }
933
- }, ht = { starting: !1 };
934
- function gt(e) {
1006
+ }, Mt = { starting: !1 };
1007
+ function Nt(e) {
935
1008
  switch (e.kind) {
936
1009
  case "condition": return { [e.node.input.handle]: e.node.input };
937
- case "subflow": return m(e.definition?.inputs ?? []);
938
- case "task": return m(e.definition?.inputs ?? []);
1010
+ case "subflow": return Be(e.definition?.inputs ?? []);
1011
+ case "task": return Be(e.definition?.inputs ?? []);
939
1012
  case "value": return {};
940
1013
  case "wait": return { [e.node.input.handle]: e.node.input };
941
1014
  }
942
1015
  }
943
- function _t(e) {
1016
+ function Pt(e) {
944
1017
  return e.node.name == null ? e.kind == "task" || e.kind == "subflow" ? e.definition?.name ?? e.id : e.id : e.node.name;
945
1018
  }
946
- async function vt(e, t) {
947
- let { FlowRunInputEditorStore: n } = await import("./flowRunInputEditorStore-DDidwd8h.js").then((e) => e.r), r = I(e), i = r.graph({ kind: "flow" });
948
- return i == null ? [] : Object.entries(i.nodes).toSorted(([e], [t]) => e.localeCompare(t)).flatMap(([e, i]) => {
949
- let a = r.resolveNode(e, i);
950
- if (a.kind == "trigger") return [];
951
- let o = Object.entries(gt(a)).filter(([e, t]) => a.node.inputs[e] == null && !Object.hasOwn(t, "value")).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, t]) => Object.assign({
1019
+ async function Ft(e, t, n) {
1020
+ let { FlowRunInputEditorStore: r } = await import("./flowRunInputEditorStore-NPGePkvP.js").then((e) => e.r), i = C(e), a = i.graph({ kind: "flow" });
1021
+ if (a == null) return [];
1022
+ let o = /* @__PURE__ */ new Set([n]), s = [n];
1023
+ for (; s.length > 0;) {
1024
+ let e = s.pop();
1025
+ for (let t of a.edges) t.source != e || o.has(t.target) || (o.add(t.target), s.push(t.target));
1026
+ }
1027
+ return Object.entries(a.nodes).filter(([e]) => o.has(e)).toSorted(([e], [t]) => e.localeCompare(t)).flatMap(([e, n]) => {
1028
+ let a = i.resolveNode(e, n);
1029
+ if (a.kind == "trigger") {
1030
+ if (a.trigger.kind == "manual" || a.trigger.kind == "cron") return [];
1031
+ let n = new r([{
1032
+ handle: "payload",
1033
+ jsonSchema: l(a.trigger),
1034
+ nullable: !1
1035
+ }], t);
1036
+ return n.replaceValues({ payload: {} }), [{
1037
+ editor: n,
1038
+ nodeId: e,
1039
+ title: a.trigger.name
1040
+ }];
1041
+ }
1042
+ let o = Object.entries(Nt(a)).filter(([e, t]) => a.node.inputs[e] == null && !Object.hasOwn(t, "value")).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, t]) => Object.assign({
952
1043
  handle: e,
953
1044
  jsonSchema: t.jsonSchema,
954
1045
  nullable: t.nullable
955
1046
  }, t.description == null ? {} : { description: t.description }));
956
1047
  return o.length == 0 ? [] : [{
957
- editor: new n(o, t),
1048
+ editor: new r(o, t),
958
1049
  nodeId: e,
959
- title: _t(a)
1050
+ title: Pt(a)
960
1051
  }];
961
1052
  });
962
1053
  }
963
- var yt = class {
1054
+ var It = class {
964
1055
  #e;
965
1056
  #t;
966
1057
  #n;
967
- #r = new F();
968
- #i = new F();
969
- #a;
1058
+ #r;
1059
+ #i = new m();
1060
+ #a = new m();
970
1061
  #o;
971
- #s = t(ht);
972
- #c;
973
- constructor(t, n, r, i = L(), a = () => crypto.randomUUID()) {
974
- this.#e = t, this.#a = n, this.#o = r, this.#n = i, this.#t = a, this.$ = {
975
- inputRequest: e(this.#s, (e) => e.inputRequest),
976
- starting: e(this.#s, (e) => e.starting),
977
- submitting: e(this.#s, (e) => e.submitting)
1062
+ #s;
1063
+ #c = t(Mt);
1064
+ #l;
1065
+ constructor(t, n, r, i, a = P(), o = F) {
1066
+ this.#e = i, this.#t = t, this.#o = n, this.#s = r, this.#r = a, this.#n = o, this.$ = {
1067
+ inputRequest: e(this.#c, (e) => e.inputRequest),
1068
+ starting: e(this.#c, (e) => e.starting),
1069
+ submitting: e(this.#c, (e) => e.submitting)
978
1070
  };
979
1071
  }
980
1072
  dispose() {
981
- this.#r.invalidate(), this.#i.invalidate(), this.#d();
1073
+ this.#i.invalidate(), this.#a.invalidate(), this.#f();
982
1074
  for (let e of Object.values(this.$)) e.dispose();
983
- this.#s.dispose();
1075
+ this.#c.dispose();
984
1076
  }
985
1077
  reset() {
986
- this.#r.invalidate(), this.#i.invalidate(), this.#c = void 0;
987
- let e = this.#s.value.inputRequest;
988
- this.#s.set(ht), this.#d(e);
1078
+ this.#i.invalidate(), this.#a.invalidate(), this.#l = void 0;
1079
+ let e = this.#c.value.inputRequest;
1080
+ this.#c.set(Mt), this.#f(e);
989
1081
  }
990
- async requestDraft(e, t) {
991
- let n = this.#i.begin();
992
- return await this.#l("draft", e, t, t.revisionId, n);
1082
+ async requestDraft(e, t, n) {
1083
+ let r = this.#a.begin();
1084
+ try {
1085
+ return await this.#u("draft", e, t, t.revisionId, r, void 0, n);
1086
+ } catch (e) {
1087
+ return r() && this.#s(E(e, this.#r.t)), "unavailable";
1088
+ } finally {
1089
+ r() && this.#p({ starting: !1 });
1090
+ }
993
1091
  }
994
1092
  async requestLive(e) {
995
- let t = this.#i.begin();
996
- this.#o(void 0), this.#f({ starting: !0 });
1093
+ let t = this.#a.begin();
1094
+ this.#s(void 0), this.#p({ starting: !0 });
997
1095
  try {
998
- let n = (await this.#e.getLive(e.flowId)).publication;
1096
+ let n = (await this.#t.getLive(e.flowId)).publication;
999
1097
  if (n == null) return "unavailable";
1000
- let r = await this.#e.getRevision(e.flowId, n.revisionId);
1001
- return t() ? await this.#l("live", e, r, n.revisionId, t, n.publicationId) : "unavailable";
1098
+ let r = await this.#t.getRevision(e.flowId, n.revisionId);
1099
+ return t() ? await this.#u("live", e, r, n.revisionId, t, n.publicationId) : "unavailable";
1002
1100
  } catch (e) {
1003
- return t() && this.#o(D(e, this.#n.t)), "unavailable";
1101
+ return t() && this.#s(E(e, this.#r.t)), "unavailable";
1004
1102
  } finally {
1005
- t() && this.#f({ starting: !1 });
1103
+ t() && this.#p({ starting: !1 });
1006
1104
  }
1007
1105
  }
1008
1106
  dismissInputs() {
1009
- let e = this.#s.value.inputRequest;
1010
- this.#f({ inputRequest: void 0 }), this.#d(e);
1107
+ let e = this.#c.value.inputRequest;
1108
+ this.#p({ inputRequest: void 0 }), this.#f(e);
1011
1109
  }
1012
1110
  async confirmInputs() {
1013
- let e = this.#s.value.inputRequest;
1014
- if (e == null) return !1;
1015
- if (!e.valid.value) return this.#f({ inputRequest: {
1111
+ let e = this.#c.value.inputRequest;
1112
+ if (e == null || e.triggerId == null) return !1;
1113
+ if (!e.valid.value) return this.#p({ inputRequest: {
1016
1114
  ...e,
1017
1115
  attempted: !0
1018
1116
  } }), !1;
1019
- let t = Object.fromEntries(e.groups.map((e) => [e.nodeId, e.editor.values()])), n = await this.#u(e.source, e.flow, e.revisionId, t, e.publicationId);
1020
- return n && this.#s.value.inputRequest === e && this.dismissInputs(), n;
1117
+ let t = Object.fromEntries(e.groups.filter((t) => t.nodeId != e.triggerId).map((e) => [e.nodeId, e.editor.values()])), n = e.groups.find((t) => t.nodeId == e.triggerId)?.editor.values().payload ?? {}, r = await this.#d(e.source, e.flow, e.revisionId, {
1118
+ nodeId: e.triggerId,
1119
+ payload: n
1120
+ }, t, e.publicationId);
1121
+ return r && this.#c.value.inputRequest === e && this.dismissInputs(), r;
1122
+ }
1123
+ async selectTrigger(e) {
1124
+ let t = this.#c.value.inputRequest;
1125
+ if (t == null || !t.triggers.some((t) => t.nodeId == e)) return;
1126
+ let r = this.#a.begin();
1127
+ this.#p({ starting: !0 });
1128
+ try {
1129
+ let i = await Ft(t.revision, this.#r.lang$, e);
1130
+ if (!r() || this.#c.value.inputRequest !== t) {
1131
+ for (let e of i) e.editor.dispose();
1132
+ return;
1133
+ }
1134
+ let a = n((e) => i.every((t) => e(t.editor.valid$)));
1135
+ this.#p({ inputRequest: {
1136
+ ...t,
1137
+ attempted: !1,
1138
+ groups: i,
1139
+ triggerId: e,
1140
+ valid: a
1141
+ } }), this.#f(t);
1142
+ } catch (e) {
1143
+ r() && this.#s(E(e, this.#r.t));
1144
+ } finally {
1145
+ r() && this.#p({ starting: !1 });
1146
+ }
1021
1147
  }
1022
- async #l(e, t, r, i, a, o) {
1023
- let s = this.#s.value.inputRequest;
1024
- this.#f({
1148
+ async #u(e, t, r, i, a, o, s) {
1149
+ let c = this.#c.value.inputRequest;
1150
+ this.#p({
1025
1151
  inputRequest: void 0,
1026
1152
  starting: !0,
1027
1153
  submitting: void 0
1028
- }), this.#d(s);
1029
- let c;
1030
- try {
1031
- c = await vt(r, this.#n.lang$);
1032
- } catch (e) {
1033
- throw a() && this.#f({
1034
- starting: !1,
1035
- submitting: void 0
1036
- }), e;
1037
- }
1154
+ }), this.#f(c);
1155
+ let l = C(r).graph({ kind: "flow" }), u = Object.entries(l?.nodes ?? {}).flatMap(([e, t]) => "inputs" in t ? [] : [{
1156
+ nodeId: e,
1157
+ title: t.name
1158
+ }]);
1159
+ if (u.length == 0) return this.#p({ starting: !1 }), this.#s({
1160
+ kind: "error",
1161
+ message: this.#r.t("runInput.noTrigger")
1162
+ }), "unavailable";
1163
+ let d = s == null ? u.length == 1 ? u[0] : void 0 : u.find((e) => e.nodeId == s);
1164
+ if (s != null && d == null) return this.#p({ starting: !1 }), this.#s({
1165
+ kind: "error",
1166
+ message: this.#r.t("runInput.selectTrigger")
1167
+ }), "unavailable";
1168
+ let f = d == null ? [] : await Ft(r, this.#r.lang$, d.nodeId);
1038
1169
  if (!a()) {
1039
- for (let e of c) e.editor.dispose();
1170
+ for (let e of f) e.editor.dispose();
1040
1171
  return "unavailable";
1041
1172
  }
1042
- if (c.length == 0) return await this.#u(e, t, i, {}, o) ? "started" : "unavailable";
1043
- let l = n((e) => c.every((t) => e(t.editor.valid$)));
1044
- return this.#f({
1173
+ if (d != null && f.length == 0) return await this.#d(e, t, i, {
1174
+ nodeId: d.nodeId,
1175
+ payload: {}
1176
+ }, {}, o) ? "started" : "unavailable";
1177
+ let p = n((e) => d != null && f.every((t) => e(t.editor.valid$)));
1178
+ return this.#p({
1045
1179
  inputRequest: {
1046
1180
  attempted: !1,
1047
1181
  flow: t,
1048
- groups: c,
1182
+ groups: f,
1183
+ revision: r,
1184
+ triggers: u,
1185
+ triggerId: d?.nodeId,
1049
1186
  ...o == null ? {} : { publicationId: o },
1050
1187
  revisionId: i,
1051
1188
  source: e,
1052
- valid: l
1189
+ valid: p
1053
1190
  },
1054
1191
  starting: !1,
1055
1192
  submitting: void 0
1056
1193
  }), "input";
1057
1194
  }
1058
- async #u(e, t, n, r = {}, i) {
1059
- if (e == "live" && i == null) return !1;
1060
- let a = this.#r.capture(), o = this.#a.prepareStart();
1061
- this.#o(void 0), this.#f({
1195
+ async #d(e, t, n, r, i = {}, a) {
1196
+ if (e == "live" && a == null) return !1;
1197
+ let o = this.#i.capture(), s = this.#o.prepareStart();
1198
+ this.#s(void 0), this.#p({
1062
1199
  starting: !0,
1063
1200
  submitting: e
1064
1201
  });
1065
- let s = e == "draft" ? {
1066
- flowId: t.flowId,
1067
- revisionId: n
1068
- } : { publicationId: i }, c = JSON.stringify({
1069
- inputs: r,
1070
- source: e,
1071
- ...s
1072
- }), l = this.#c?.signature == c ? this.#c : {
1073
- key: this.#t(),
1074
- signature: c
1075
- };
1076
- this.#c = l;
1077
1202
  try {
1078
- let s = e == "draft" ? await this.#e.createDraftRun(t.flowId, n, {
1079
- idempotencyKey: l.key,
1080
- inputs: r
1081
- }) : await this.#e.createLiveRun(i, {
1082
- idempotencyKey: l.key,
1083
- inputs: r
1203
+ if (e == "draft") {
1204
+ let e = await this.#e(t.flowId);
1205
+ if (e == null || !o() || !s()) return !1;
1206
+ n = e;
1207
+ }
1208
+ let c = e == "draft" ? {
1209
+ flowId: t.flowId,
1210
+ revisionId: n
1211
+ } : { publicationId: a }, l = JSON.stringify({
1212
+ inputs: i,
1213
+ trigger: r,
1214
+ source: e,
1215
+ ...c
1216
+ }), u = this.#l?.signature == l ? this.#l : {
1217
+ key: this.#n(),
1218
+ signature: l
1219
+ };
1220
+ this.#l = u;
1221
+ let d = e == "draft" ? await this.#t.createDraftRun(t.flowId, n, {
1222
+ idempotencyKey: u.key,
1223
+ inputs: i,
1224
+ trigger: r
1225
+ }) : await this.#t.createLiveRun(a, {
1226
+ idempotencyKey: u.key,
1227
+ inputs: i,
1228
+ trigger: r
1084
1229
  });
1085
- return !a() || !o() ? !1 : (this.#c = void 0, this.#a.follow(s, o));
1230
+ return !o() || !s() ? !1 : (this.#l = void 0, this.#o.follow(d, s));
1086
1231
  } catch (e) {
1087
- return a() && o() && this.#o(D(e, this.#n.t)), !1;
1232
+ return o() && s() && this.#s(E(e, this.#r.t)), !1;
1088
1233
  } finally {
1089
- a() && this.#f({
1234
+ o() && this.#p({
1090
1235
  starting: !1,
1091
1236
  submitting: void 0
1092
1237
  });
1093
1238
  }
1094
1239
  }
1095
- #d(e = this.#s.value.inputRequest) {
1240
+ #f(e = this.#c.value.inputRequest) {
1096
1241
  if (e != null) {
1097
1242
  e.valid.dispose();
1098
1243
  for (let t of e.groups) t.editor.dispose();
1099
1244
  }
1100
1245
  }
1101
- #f(e) {
1102
- this.#s.set({
1103
- ...this.#s.value,
1246
+ #p(e) {
1247
+ this.#c.set({
1248
+ ...this.#c.value,
1104
1249
  ...e
1105
1250
  });
1106
1251
  }
1107
- }, bt = {
1252
+ }, Lt = {
1108
1253
  actions: {},
1109
1254
  catalogs: {}
1110
1255
  };
1111
- function xt(e) {
1256
+ function Rt(e) {
1112
1257
  return Object.entries(e).map(([e, t]) => ({
1113
1258
  description: t.description,
1114
1259
  handle: e,
1115
1260
  jsonSchema: t.jsonSchema
1116
1261
  }));
1117
1262
  }
1118
- function Y(e, t) {
1263
+ function Q(e, t) {
1119
1264
  return {
1120
1265
  connector: e,
1121
1266
  description: e.authenticated && e.defaultConnection == null ? t("addNode.connectorNeedsConnection", {
@@ -1123,15 +1268,15 @@ function Y(e, t) {
1123
1268
  service: e.serviceName
1124
1269
  }) : e.description,
1125
1270
  group: t("addNode.connectorActions"),
1126
- icon: T(e),
1271
+ icon: p(e),
1127
1272
  id: `connector:${e.actionId}`,
1128
- inputs: xt(e.inputs),
1273
+ inputs: Rt(e.inputs),
1129
1274
  kind: "connector",
1130
1275
  label: e.name,
1131
- outputs: xt(e.outputs)
1276
+ outputs: Rt(e.outputs)
1132
1277
  };
1133
1278
  }
1134
- function St(e, t) {
1279
+ function zt(e, t) {
1135
1280
  let n = /* @__PURE__ */ new Map();
1136
1281
  for (let t of e) {
1137
1282
  let e = n.get(t.serviceId) ?? [];
@@ -1139,7 +1284,7 @@ function St(e, t) {
1139
1284
  }
1140
1285
  return [...n.values()].toSorted((e, t) => e[0].serviceName.localeCompare(t[0].serviceName)).map((e) => {
1141
1286
  let n = e[0], r = e.map((e) => {
1142
- let n = Y(e, t);
1287
+ let n = Q(e, t);
1143
1288
  return {
1144
1289
  description: n.description,
1145
1290
  label: n.label,
@@ -1150,7 +1295,7 @@ function St(e, t) {
1150
1295
  choices: r,
1151
1296
  description: t(r.length == 1 ? "addNode.connectorActionCountOne" : "addNode.connectorActionCount", { count: r.length }),
1152
1297
  group: t("addNode.connectorActions"),
1153
- icon: T(n),
1298
+ icon: p(n),
1154
1299
  id: `connector-provider:${n.serviceId}`,
1155
1300
  inputs: [],
1156
1301
  kind: "connector-group",
@@ -1160,12 +1305,12 @@ function St(e, t) {
1160
1305
  };
1161
1306
  });
1162
1307
  }
1163
- function Ct(e, t) {
1308
+ function Bt(e, t) {
1164
1309
  return {
1165
1310
  choices: [],
1166
1311
  description: t("addNode.connectorBrowseActions"),
1167
1312
  group: t("addNode.connectorActions"),
1168
- icon: T(e),
1313
+ icon: p(e),
1169
1314
  id: `connector-provider:${e.serviceId}`,
1170
1315
  inputs: [],
1171
1316
  kind: "connector-group",
@@ -1174,7 +1319,7 @@ function Ct(e, t) {
1174
1319
  serviceId: e.serviceId
1175
1320
  };
1176
1321
  }
1177
- function wt(e, t) {
1322
+ function Vt(e, t) {
1178
1323
  if (e == null) return;
1179
1324
  let n = e.kind == "wait" ? e.node.notification?.taskId : e.kind == "task" && e.node.task == null ? e.node.taskId : void 0;
1180
1325
  if (n == null) return;
@@ -1186,10 +1331,10 @@ function wt(e, t) {
1186
1331
  taskId: n
1187
1332
  };
1188
1333
  }
1189
- function Tt(e, t, n) {
1334
+ function Ht(e, t, n) {
1190
1335
  if (e == null) return [];
1191
1336
  let r = [];
1192
- for (let i of [...O(e.revision.content).tasks].toSorted()) {
1337
+ for (let i of [...je(e.revision.content).tasks].toSorted()) {
1193
1338
  let a = e.task(i);
1194
1339
  if (a?.executor.kind != "connector") continue;
1195
1340
  let o = t[a.executor.action];
@@ -1206,7 +1351,7 @@ function Tt(e, t, n) {
1206
1351
  }
1207
1352
  return r;
1208
1353
  }
1209
- var Et = class {
1354
+ var Ut = class {
1210
1355
  #e;
1211
1356
  #t;
1212
1357
  #n;
@@ -1223,13 +1368,13 @@ var Et = class {
1223
1368
  #p;
1224
1369
  #m;
1225
1370
  #h;
1226
- constructor(r, i, a, o, s = L()) {
1227
- this.#r = /* @__PURE__ */ new Map(), this.#i = /* @__PURE__ */ new Set(), this.#a = new F(), this.#o = new F(), this.#d = t(bt), this.#h = !1, this.browseAddNodeOptions = async (e) => {
1371
+ constructor(r, i, a, o, s = P()) {
1372
+ this.#r = /* @__PURE__ */ new Map(), this.#i = /* @__PURE__ */ new Set(), this.#a = new m(), this.#o = new m(), this.#d = t(Lt), this.#h = !1, this.browseAddNodeOptions = async (e) => {
1228
1373
  if (this.#h) return;
1229
1374
  let t = this.#f.$.flowId.value;
1230
1375
  if (t == null) return;
1231
1376
  let n = this.#m ?? await this.#e.listConnectorProviders(e, t);
1232
- if (!(e.aborted || this.#h || t != this.#f.$.flowId.value)) return this.#m = n, n.toSorted((e, t) => e.serviceName.localeCompare(t.serviceName)).map((e) => Ct(e, this.#t.t));
1377
+ if (!(e.aborted || this.#h || t != this.#f.$.flowId.value)) return this.#m = n, n.toSorted((e, t) => e.serviceName.localeCompare(t.serviceName)).map((e) => Bt(e, this.#t.t));
1233
1378
  }, this.provideAddNodeOptionChoices = async (e, t) => {
1234
1379
  if (this.#h) return;
1235
1380
  let n = this.#f.$.flowId.value, r = this.#m?.find((t) => `connector-provider:${t.serviceId}` == e);
@@ -1240,7 +1385,7 @@ var Et = class {
1240
1385
  return this.#r.set(r.serviceId, a), this.#b({ actions: {
1241
1386
  ...this.#d.value.actions,
1242
1387
  ...Object.fromEntries(a.map((e) => [e.actionId, e]))
1243
- } }), a.map((e) => Y(e, this.#t.t));
1388
+ } }), a.map((e) => Q(e, this.#t.t));
1244
1389
  }, this.provideAddNodeOptions = async (e, t) => {
1245
1390
  if (this.#h) return;
1246
1391
  let n = this.#f.$.flowId.value;
@@ -1249,17 +1394,17 @@ var Et = class {
1249
1394
  if (t.aborted || this.#h || n != this.#f.$.flowId.value) return;
1250
1395
  let a = { ...this.#d.value.actions };
1251
1396
  for (let e of i) a[e.actionId] = e;
1252
- if (this.#b({ actions: a }), r.length != 0) return i.map((e) => Y(e, this.#t.t));
1397
+ if (this.#b({ actions: a }), r.length != 0) return i.map((e) => Q(e, this.#t.t));
1253
1398
  let o = new Map(i.map((e) => [e.actionId, e]));
1254
1399
  for (let e of this.#f.$.revision.value?.connectorActionIds ?? []) {
1255
1400
  let t = a[e];
1256
1401
  t != null && o.set(e, t);
1257
1402
  }
1258
- return St([...o.values()], this.#t.t);
1403
+ return zt([...o.values()], this.#t.t);
1259
1404
  }, this.#e = r, this.#n = o, this.#f = i, this.#u = a, this.#t = s;
1260
1405
  let c = e(this.#d, (e) => e.actions), l = e(this.#d, (e) => e.catalogs);
1261
1406
  this.#l = n((e) => {
1262
- let t = wt(e(i.$.selection), e(i.$.revision)), n = e(this.#d);
1407
+ let t = Vt(e(i.$.selection), e(i.$.revision)), n = e(this.#d);
1263
1408
  if (t == null) return { authorizationPending: !1 };
1264
1409
  let r = n.actions[t.actionId], a = r == null ? void 0 : n.catalogs[r.serviceId], o = t.connectionId == null ? void 0 : a?.byId.get(t.connectionId);
1265
1410
  return o == null && r?.defaultConnection?.connectionId == t.connectionId && (o = r.defaultConnection), {
@@ -1275,7 +1420,7 @@ var Et = class {
1275
1420
  actions: c,
1276
1421
  catalogs: l,
1277
1422
  connectionLoading: e(this.#d, (e) => e.connectionLoading),
1278
- diagnostics: n((e) => Tt(e(i.$.revision), e(c), e(l))),
1423
+ diagnostics: n((e) => Ht(e(i.$.revision), e(c), e(l))),
1279
1424
  selectedAction: e(this.#l, (e) => e.action),
1280
1425
  selectedActionError: e(this.#l, (e) => e.actionError),
1281
1426
  selectedActiveConnections: e(this.#l, (e) => e.activeConnections),
@@ -1290,11 +1435,11 @@ var Et = class {
1290
1435
  this.#l.dispose(), this.#d.dispose();
1291
1436
  }
1292
1437
  reset() {
1293
- this.#h || (this.#a.invalidate(), this.#o.invalidate(), this.#p = void 0, this.#r.clear(), this.#m = void 0, this.#i.clear(), this.#d.set(bt));
1438
+ this.#h || (this.#a.invalidate(), this.#o.invalidate(), this.#p = void 0, this.#r.clear(), this.#m = void 0, this.#i.clear(), this.#d.set(Lt));
1294
1439
  }
1295
1440
  async refresh(e = !1) {
1296
1441
  if (this.#h) return;
1297
- let t = this.#o.begin(), n = this.#f.$.flowId.value, r = wt(this.#f.$.selection.value, this.#f.$.revision.value);
1442
+ let t = this.#o.begin(), n = this.#f.$.flowId.value, r = Vt(this.#f.$.selection.value, this.#f.$.revision.value);
1298
1443
  if (n == null || r == null) {
1299
1444
  (this.#d.value.actionLoading != null || this.#d.value.connectionLoading != null) && this.#b({
1300
1445
  actionLoading: void 0,
@@ -1318,12 +1463,30 @@ var Et = class {
1318
1463
  } catch (e) {
1319
1464
  this.#x(t, n) && this.#b({ actionError: {
1320
1465
  actionId: r.actionId,
1321
- message: D(e, this.#t.t).message
1466
+ message: E(e, this.#t.t).message
1322
1467
  } });
1323
1468
  } finally {
1324
1469
  this.#x(t, n) && this.#d.value.actionLoading == r.actionId && this.#b({ actionLoading: void 0 });
1325
1470
  }
1326
1471
  }
1472
+ async loadCodeConnections(e, t) {
1473
+ let n = this.#f.$.flowId.value;
1474
+ if (n == null || this.#h) return;
1475
+ let r = await this.#e.listConnectorConnections(e, t, n);
1476
+ t.aborted || this.#h || n != this.#f.$.flowId.value || this.#b({ catalogs: {
1477
+ ...this.#d.value.catalogs,
1478
+ [e]: d(r)
1479
+ } });
1480
+ }
1481
+ async loadCodeAction(e, t) {
1482
+ let n = this.#f.$.flowId.value;
1483
+ if (n == null || this.#h) return;
1484
+ let r = await this.#e.getConnectorAction(e, t, n);
1485
+ t.aborted || this.#h || n != this.#f.$.flowId.value || this.#b({ actions: {
1486
+ ...this.#d.value.actions,
1487
+ [e]: r
1488
+ } });
1489
+ }
1327
1490
  async connect(e) {
1328
1491
  if (this.#h) return;
1329
1492
  let t = this.#f.$.flowId.value;
@@ -1343,7 +1506,7 @@ var Et = class {
1343
1506
  serviceId: e
1344
1507
  }, this.#b({ authorizationServiceId: e });
1345
1508
  } catch (e) {
1346
- this.#h || this.#u(D(e, this.#t.t));
1509
+ this.#h || this.#u(E(e, this.#t.t));
1347
1510
  }
1348
1511
  }
1349
1512
  async setConnection(e, t) {
@@ -1376,13 +1539,13 @@ var Et = class {
1376
1539
  a = await this.#e.listConnectorConnections(t, void 0, e);
1377
1540
  } catch (n) {
1378
1541
  this.#x(r, e) && this.#b({ connectionError: {
1379
- message: D(n, this.#t.t).message,
1542
+ message: E(n, this.#t.t).message,
1380
1543
  serviceId: t
1381
1544
  } });
1382
1545
  return;
1383
1546
  }
1384
1547
  if (!this.#x(r, e)) return;
1385
- let o = C(a);
1548
+ let o = d(a);
1386
1549
  return this.#b({ catalogs: {
1387
1550
  ...this.#d.value.catalogs,
1388
1551
  [t]: o
@@ -1422,7 +1585,7 @@ var Et = class {
1422
1585
  }
1423
1586
  if (!this.#x(e, t)) return;
1424
1587
  let i = /* @__PURE__ */ new Set();
1425
- for (let e of O(n.revision.content).tasks) {
1588
+ for (let e of je(n.revision.content).tasks) {
1426
1589
  let t = n.task(e);
1427
1590
  if (t?.executor.kind != "connector") continue;
1428
1591
  let r = this.#d.value.actions[t.executor.action];
@@ -1430,8 +1593,8 @@ var Et = class {
1430
1593
  }
1431
1594
  await Promise.all([...i].map((n) => this.#v(t, n, !1, e)));
1432
1595
  }
1433
- }, Dt = { catalogs: {} }, Ot = "trigger:";
1434
- function X(e, t) {
1596
+ }, Wt = { catalogs: {} }, Gt = "trigger:";
1597
+ function Kt(e, t) {
1435
1598
  if (e?.kind != "trigger") return;
1436
1599
  let n = e.trigger;
1437
1600
  if (n.kind != "poll" && n.kind != "integration") return;
@@ -1442,15 +1605,15 @@ function X(e, t) {
1442
1605
  triggerId: e.id
1443
1606
  };
1444
1607
  }
1445
- function kt(e, t) {
1608
+ function qt(e, t) {
1446
1609
  return {
1447
1610
  description: t.t("addNode.triggerNeedsConnection", { provider: e.provider }),
1448
- group: t.t("addNode.triggers"),
1449
- icon: T({
1611
+ group: t.t("addNode.integrationTriggers"),
1612
+ icon: p({
1450
1613
  serviceId: e.provider,
1451
1614
  serviceName: e.provider
1452
1615
  }),
1453
- id: `${Ot}${e.key}`,
1616
+ id: `${Gt}${e.key}`,
1454
1617
  inputs: [],
1455
1618
  kind: "trigger",
1456
1619
  label: e.displayName,
@@ -1464,7 +1627,7 @@ function kt(e, t) {
1464
1627
  }
1465
1628
  };
1466
1629
  }
1467
- var At = class {
1630
+ var Jt = class {
1468
1631
  #e;
1469
1632
  #t;
1470
1633
  #n;
@@ -1476,28 +1639,29 @@ var At = class {
1476
1639
  #c;
1477
1640
  #l;
1478
1641
  #u;
1479
- constructor(r, i, a, o, s = L()) {
1480
- this.#t = new AbortController(), this.#a = new F(), this.#c = t(Dt), this.#u = !1, this.browseAddNodeOptions = async (e) => {
1481
- let t = this.#l.$.flowId.value;
1482
- if (e.aborted || this.#u || t == null || this.#l.$.target.value?.kind != "flow") return [];
1483
- let n = await this.#d();
1484
- if (!(e.aborted || this.#u || t != this.#l.$.flowId.value)) return [...n.values()].map((e) => kt(e, this.#i));
1642
+ #d;
1643
+ constructor(r, i, a, o, s = P()) {
1644
+ this.#t = new AbortController(), this.#a = new m(), this.#o = /* @__PURE__ */ new Set(), this.#l = t(Wt), this.#d = !1, this.browseAddNodeOptions = async (e) => {
1645
+ let t = this.#u.$.flowId.value;
1646
+ if (e.aborted || this.#d || t == null || this.#u.$.target.value?.kind != "flow") return [];
1647
+ let n = await this.#f();
1648
+ if (!(e.aborted || this.#d || t != this.#u.$.flowId.value)) return [...n.values()].map((e) => qt(e, this.#i));
1485
1649
  }, this.provideAddNodeOptions = async (e, t) => {
1486
- let n = this.#l.$.flowId.value;
1487
- if (t.aborted || this.#u || n == null || this.#l.$.target.value?.kind != "flow") return [];
1650
+ let n = this.#u.$.flowId.value;
1651
+ if (t.aborted || this.#d || n == null || this.#u.$.target.value?.kind != "flow") return [];
1488
1652
  let r = e.trim().toLowerCase();
1489
1653
  if (r.length == 0) return [];
1490
- let i = await this.#d();
1491
- if (!(t.aborted || this.#u || n != this.#l.$.flowId.value)) return [...i.values()].filter((e) => [
1654
+ let i = await this.#f();
1655
+ if (!(t.aborted || this.#d || n != this.#u.$.flowId.value)) return [...i.values()].filter((e) => [
1492
1656
  e.description,
1493
1657
  e.displayName,
1494
1658
  e.key,
1495
1659
  e.name,
1496
1660
  e.provider,
1497
1661
  e.type
1498
- ].some((e) => e.toLowerCase().includes(r))).map((e) => kt(e, this.#i));
1499
- }, this.#n = r, this.#r = o, this.#i = s, this.#s = a, this.#l = i, this.#o = n((e) => {
1500
- let t = e(i.$.selection), n = X(t, i), r = e(this.#c);
1662
+ ].some((e) => e.toLowerCase().includes(r))).map((e) => qt(e, this.#i));
1663
+ }, this.#n = r, this.#r = o, this.#i = s, this.#c = a, this.#u = i, this.#s = n((e) => {
1664
+ let t = e(i.$.selection), n = Kt(t, i), r = e(this.#l);
1501
1665
  if (t?.kind != "trigger") return { authorizationPending: !1 };
1502
1666
  let a = t.trigger;
1503
1667
  if (a.kind != "poll" && a.kind != "integration") return { authorizationPending: !1 };
@@ -1510,102 +1674,96 @@ var At = class {
1510
1674
  definition: a.definition
1511
1675
  };
1512
1676
  }), this.$ = {
1513
- connectionLoading: e(this.#c, (e) => e.connectionLoading),
1514
- selectedActiveConnections: e(this.#o, (e) => e.activeConnections),
1515
- selectedAuthorizationPending: e(this.#o, (e) => e.authorizationPending),
1516
- selectedConnection: e(this.#o, (e) => e.connection),
1517
- selectedConnectionError: e(this.#o, (e) => e.connectionError),
1518
- selectedDefinition: e(this.#o, (e) => e.definition)
1677
+ connectionLoading: e(this.#l, (e) => e.connectionLoading),
1678
+ selectedActiveConnections: e(this.#s, (e) => e.activeConnections),
1679
+ selectedAuthorizationPending: e(this.#s, (e) => e.authorizationPending),
1680
+ selectedConnection: e(this.#s, (e) => e.connection),
1681
+ selectedConnectionError: e(this.#s, (e) => e.connectionError),
1682
+ selectedDefinition: e(this.#s, (e) => e.definition)
1519
1683
  };
1520
1684
  }
1521
1685
  dispose() {
1522
- this.#u = !0, this.#t.abort(), this.#a.invalidate();
1686
+ this.#d = !0, this.#t.abort(), this.#a.invalidate();
1523
1687
  for (let e of Object.values(this.$)) e.dispose();
1524
- this.#o.dispose(), this.#c.dispose();
1688
+ this.#s.dispose(), this.#l.dispose();
1525
1689
  }
1526
1690
  reset() {
1527
- this.#u || (this.#t.abort(), this.#t = new AbortController(), this.#e = void 0, this.#a.invalidate(), this.#c.set(Dt));
1691
+ this.#d || (this.#t.abort(), this.#t = new AbortController(), this.#e = void 0, this.#o.clear(), this.#a.invalidate(), this.#l.set(Wt));
1528
1692
  }
1529
1693
  async refresh(e = !1) {
1530
- let t = this.#a.begin(), n = this.#l.$.flowId.value, r = X(this.#l.$.selection.value, this.#l);
1531
- if (!this.#u) {
1532
- if (n == null || r == null) {
1533
- this.#c.value.connectionLoading != null && this.#f({ connectionLoading: void 0 });
1534
- return;
1535
- }
1536
- if (!(!e && this.#c.value.catalogs[r.provider] != null)) {
1537
- this.#f({
1538
- connectionError: void 0,
1539
- connectionLoading: r.provider
1540
- });
1541
- try {
1542
- let e = C(await this.#n.listConnectorConnections(r.provider, void 0, n));
1543
- if (!this.#p(t, n)) return;
1544
- this.#f({ catalogs: {
1545
- ...this.#c.value.catalogs,
1546
- [r.provider]: e
1547
- } });
1548
- } catch (e) {
1549
- this.#p(t, n) && this.#f({ connectionError: {
1550
- message: D(e, this.#i.t).message,
1551
- provider: r.provider
1552
- } });
1553
- } finally {
1554
- this.#p(t, n) && this.#c.value.connectionLoading == r.provider && this.#f({ connectionLoading: void 0 });
1555
- }
1556
- }
1694
+ if (this.#d) return;
1695
+ let t = this.#a.begin(), n = this.#u.$.flowId.value, r = Kt(this.#u.$.selection.value, this.#u);
1696
+ if (n == null || r == null) {
1697
+ this.#l.value.connectionLoading != null && this.#p({ connectionLoading: void 0 });
1698
+ return;
1699
+ }
1700
+ if (!e && !this.#o.has(r.provider) && this.#l.value.catalogs[r.provider] != null) {
1701
+ this.#l.value.connectionLoading != null && this.#p({ connectionLoading: void 0 });
1702
+ return;
1703
+ }
1704
+ this.#p({
1705
+ connectionError: void 0,
1706
+ connectionLoading: r.provider
1707
+ });
1708
+ try {
1709
+ let e = d(await this.#n.listConnectorConnections(r.provider, void 0, n));
1710
+ if (!this.#m(t, n)) return;
1711
+ this.#o.delete(r.provider), this.#p({ catalogs: {
1712
+ ...this.#l.value.catalogs,
1713
+ [r.provider]: e
1714
+ } });
1715
+ } catch (e) {
1716
+ this.#m(t, n) && this.#p({ connectionError: {
1717
+ message: E(e, this.#i.t).message,
1718
+ provider: r.provider
1719
+ } });
1720
+ } finally {
1721
+ this.#m(t, n) && this.#l.value.connectionLoading == r.provider && this.#p({ connectionLoading: void 0 });
1557
1722
  }
1558
1723
  }
1559
1724
  async connect(e) {
1560
- let t = this.#l.$.flowId.value;
1561
- if (!(this.#u || t == null)) try {
1725
+ let t = this.#u.$.flowId.value;
1726
+ if (!(this.#d || t == null)) try {
1562
1727
  if (!await this.#r.openExternalPage(() => this.#n.createConnectorConnectionPage(e, t))) {
1563
- this.#s({
1728
+ this.#c({
1564
1729
  kind: "error",
1565
1730
  message: this.#i.t("notice.connectionPopupBlocked")
1566
1731
  });
1567
1732
  return;
1568
1733
  }
1569
- !this.#u && t == this.#l.$.flowId.value && this.#f({ authorizationProvider: e });
1734
+ !this.#d && t == this.#u.$.flowId.value && this.#p({ authorizationProvider: e });
1570
1735
  } catch (e) {
1571
- this.#u || this.#s(D(e, this.#i.t));
1736
+ this.#d || this.#c(E(e, this.#i.t));
1572
1737
  }
1573
1738
  }
1574
1739
  async setConnection(e, t) {
1575
- return await this.#l.setTriggerConnection(e, t);
1576
- }
1577
- async saveSettings(e, t) {
1578
- return await this.#l.saveTriggerSettings(e, t);
1740
+ return await this.#u.setTriggerConnection(e, t);
1579
1741
  }
1580
1742
  async refreshAfterAuthorization() {
1581
- let e = this.#c.value.authorizationProvider;
1582
- if (this.#u || e == null) return;
1583
- let t = { ...this.#c.value.catalogs };
1584
- delete t[e], this.#f({
1585
- authorizationProvider: void 0,
1586
- catalogs: t
1587
- }), X(this.#l.$.selection.value, this.#l)?.provider == e && await this.refresh(!0);
1588
- }
1589
- #d() {
1743
+ if (this.#d) return;
1744
+ let e = this.#l.value.authorizationProvider;
1745
+ e != null && (this.#o.add(e), this.#p({ authorizationProvider: void 0 }), Kt(this.#u.$.selection.value, this.#u)?.provider == e && await this.refresh(!0));
1746
+ }
1747
+ #f() {
1590
1748
  if (this.#e != null) return this.#e;
1591
1749
  let e = this.#n.listTriggerDefinitions(this.#t.signal).then((e) => new Map(e.map((e) => [e.key, e])));
1592
1750
  return this.#e = e, e.catch(() => {
1593
1751
  this.#e == e && (this.#e = void 0);
1594
1752
  }), e;
1595
1753
  }
1596
- #f(e) {
1597
- this.#u || this.#c.set({
1598
- ...this.#c.value,
1754
+ #p(e) {
1755
+ this.#d || this.#l.set({
1756
+ ...this.#l.value,
1599
1757
  ...e
1600
1758
  });
1601
1759
  }
1602
- #p(e, t) {
1603
- return !this.#u && e() && t == this.#l.$.flowId.value;
1760
+ #m(e, t) {
1761
+ return !this.#d && e() && t == this.#u.$.flowId.value;
1604
1762
  }
1605
1763
  };
1606
1764
  //#endregion
1607
1765
  //#region src/workbench/browser/runtime/stores/draftChanges.ts
1608
- function jt(e, t) {
1766
+ function Yt(e, t) {
1609
1767
  if (e.length != 1 || t.length != 1) return;
1610
1768
  let n = e[0], r = t[0];
1611
1769
  if (n?.kind == "graph.node.field.set" && r?.kind == "graph.node.field.set") return n.nodeId != r.nodeId || n.field != r.field || n.target.kind != r.target.kind || n.target.kind == "subflow" && (r.target.kind != "subflow" || n.target.id != r.target.id) ? void 0 : [{
@@ -1625,7 +1783,7 @@ function jt(e, t) {
1625
1783
  value: r.value
1626
1784
  }];
1627
1785
  }
1628
- var Mt = class {
1786
+ var Xt = class {
1629
1787
  #e;
1630
1788
  #t;
1631
1789
  #n;
@@ -1653,28 +1811,28 @@ var Mt = class {
1653
1811
  this.#a = e;
1654
1812
  let t = e, n = [];
1655
1813
  for (let e of this.#o) try {
1656
- t = B(t, e.changes), n.push(e);
1814
+ t = R(t, e.changes), n.push(e);
1657
1815
  } catch (t) {
1658
- if (!(t instanceof h)) throw t;
1816
+ if (!(t instanceof ze)) throw t;
1659
1817
  e.active = !1;
1660
1818
  }
1661
1819
  return this.#o = n, t;
1662
1820
  }
1663
1821
  project(e) {
1664
- return this.#o.reduce((e, t) => B(e, t.changes), e);
1822
+ return this.#o.reduce((e, t) => R(e, t.changes), e);
1665
1823
  }
1666
1824
  enqueue(e) {
1667
1825
  let t = this.#s.then(e);
1668
1826
  return this.#s = t, t;
1669
1827
  }
1670
1828
  async change(e, t, n, r = !0) {
1671
- let i = this.#o.at(-1), a = i == null || i.started || !i.active ? void 0 : jt(i.changes, n);
1829
+ let i = this.#o.at(-1), a = i == null || i.started || !i.active ? void 0 : Yt(i.changes, n);
1672
1830
  if (i != null && a != null) return i.changes = a, this.#a != null && this.#t.apply(this.project(this.#a)), i.result;
1673
1831
  this.#t.beforeChange(r);
1674
1832
  let o = {
1675
1833
  ...e,
1676
1834
  active: !0,
1677
- changeId: crypto.randomUUID(),
1835
+ changeId: F(),
1678
1836
  changes: n,
1679
1837
  started: !1
1680
1838
  };
@@ -1699,21 +1857,21 @@ var Mt = class {
1699
1857
  let r = this.#l(e, n, t);
1700
1858
  return this.#o.length == 0 && this.#t.check(), r;
1701
1859
  } catch (n) {
1702
- if (n instanceof z && n.code == "flow.revision-conflict") {
1860
+ if (n instanceof L && n.code == "flow.revision-conflict") {
1703
1861
  if (!t && await this.#t.recover(e)) {
1704
- t = !0, e.changeId = crypto.randomUUID();
1862
+ t = !0, e.changeId = F();
1705
1863
  continue;
1706
1864
  }
1707
1865
  t && await this.#t.recover(e), this.#u(e);
1708
1866
  } else {
1709
- if (!(n instanceof z) && !t) {
1867
+ if (!(n instanceof L) && !t) {
1710
1868
  let n = this.#a?.revisionId;
1711
1869
  if (await this.#t.recover(e)) {
1712
- t = !0, e.active && this.#a?.revisionId != n && (e.changeId = crypto.randomUUID());
1870
+ t = !0, e.active && this.#a?.revisionId != n && (e.changeId = F());
1713
1871
  continue;
1714
1872
  }
1715
1873
  }
1716
- this.#u(e), this.#t.current(e) && this.#r(D(n, this.#n.t));
1874
+ this.#u(e), this.#t.current(e) && this.#r(E(n, this.#n.t));
1717
1875
  }
1718
1876
  return;
1719
1877
  }
@@ -1722,7 +1880,7 @@ var Mt = class {
1722
1880
  #l(e, t, n) {
1723
1881
  let r = {
1724
1882
  ...n.revision,
1725
- content: B(t, e.changes).content
1883
+ content: R(t, e.changes).content
1726
1884
  };
1727
1885
  this.#o = this.#o.filter((t) => t !== e), this.#a = r;
1728
1886
  let i = this.#t.diagnostics(), a = this.#o.length == 0 && i?.revisionId == r.revisionId;
@@ -1731,7 +1889,7 @@ var Mt = class {
1731
1889
  #u(e) {
1732
1890
  e.active = !1, this.#o = this.#o.filter((t) => t !== e), !(!this.#t.current(e) || this.#a == null) && this.#t.apply(this.project(this.#a));
1733
1891
  }
1734
- }, Z = 50, Nt = {
1892
+ }, Zt = 50, Qt = {
1735
1893
  failed: !1,
1736
1894
  loaded: !1,
1737
1895
  loading: !0,
@@ -1739,13 +1897,15 @@ var Mt = class {
1739
1897
  loadMoreFailed: !1,
1740
1898
  refreshing: !1,
1741
1899
  flows: []
1742
- }, Pt = class {
1900
+ }, $t = class {
1743
1901
  #e;
1744
1902
  #t;
1745
- #n = new F();
1903
+ #n = new m();
1746
1904
  #r;
1747
- #i = t(Nt);
1748
- #a = !1;
1905
+ #i = t(Qt);
1906
+ #a = new AbortController();
1907
+ #o = /* @__PURE__ */ new Set();
1908
+ #s = !1;
1749
1909
  constructor(t, n, r) {
1750
1910
  this.#e = t, this.#t = r, this.#r = n, this.$ = {
1751
1911
  failed: e(this.#i, (e) => e.failed),
@@ -1762,24 +1922,21 @@ var Mt = class {
1762
1922
  return this.#i.value.loaded;
1763
1923
  }
1764
1924
  dispose() {
1765
- this.#a = !0, this.#n.invalidate();
1925
+ this.#s = !0, this.#a.abort(), this.#n.invalidate();
1766
1926
  for (let e of Object.values(this.$)) e.dispose();
1767
1927
  this.#i.dispose();
1768
1928
  }
1769
- capture() {
1770
- return this.#n.capture();
1771
- }
1772
1929
  flow(e) {
1773
1930
  return this.#i.value.flows.find((t) => t.flowId == e);
1774
1931
  }
1775
1932
  async reload() {
1776
1933
  let e = this.#n.begin(), t = this.#i.value.loaded;
1777
- t ? this.#o({
1934
+ t ? this.#c({
1778
1935
  failed: !1,
1779
1936
  loadingMore: !1,
1780
1937
  loadMoreFailed: !1,
1781
1938
  refreshing: !0
1782
- }) : this.#o({
1939
+ }) : this.#c({
1783
1940
  failed: !1,
1784
1941
  loading: !0,
1785
1942
  loadingMore: !1,
@@ -1792,10 +1949,10 @@ var Mt = class {
1792
1949
  try {
1793
1950
  let t = await this.#e.listFlows({
1794
1951
  includeTotal: !0,
1795
- limit: Z
1952
+ limit: Zt
1796
1953
  });
1797
1954
  if (!e()) return;
1798
- this.#o({
1955
+ this.#c({
1799
1956
  loaded: !0,
1800
1957
  loading: !1,
1801
1958
  refreshing: !1,
@@ -1805,81 +1962,117 @@ var Mt = class {
1805
1962
  });
1806
1963
  } catch (n) {
1807
1964
  if (!e()) return;
1808
- this.#o({
1965
+ this.#c({
1809
1966
  failed: !t,
1810
1967
  loading: !1,
1811
1968
  refreshing: !1
1812
- }), this.#r(D(n, this.#t.t));
1969
+ }), this.#r(E(n, this.#t.t));
1813
1970
  }
1814
1971
  }
1815
1972
  async loadMore() {
1816
1973
  let { loadingMore: e, nextCursor: t, refreshing: n } = this.#i.value;
1817
1974
  if (e || n || t == null) return;
1818
1975
  let r = this.#n.capture();
1819
- this.#o({
1976
+ this.#c({
1820
1977
  loadingMore: !0,
1821
1978
  loadMoreFailed: !1
1822
1979
  });
1823
1980
  try {
1824
1981
  let e = await this.#e.listFlows({
1825
1982
  cursor: t,
1826
- limit: Z
1983
+ limit: Zt
1827
1984
  });
1828
1985
  if (!r()) return;
1829
1986
  let n = new Set(this.#i.value.flows.map((e) => e.flowId));
1830
- this.#o({
1987
+ this.#c({
1831
1988
  loadingMore: !1,
1832
1989
  nextCursor: e.nextCursor,
1833
1990
  flows: [...this.#i.value.flows, ...e.flows.filter((e) => !n.has(e.flowId))]
1834
1991
  });
1835
1992
  } catch (e) {
1836
1993
  if (!r()) return;
1837
- this.#o({
1994
+ this.#c({
1838
1995
  loadingMore: !1,
1839
1996
  loadMoreFailed: !0
1840
- }), this.#r(D(e, this.#t.t));
1997
+ }), this.#r(E(e, this.#t.t));
1998
+ }
1999
+ }
2000
+ async setEnabled(e, t) {
2001
+ if (!(e.live == null || this.#o.has(e.flowId))) {
2002
+ this.#o.add(e.flowId);
2003
+ try {
2004
+ let n = await this.#e.setFlowEnabled(e.flowId, e.live.publicationId, t);
2005
+ this.#s || this.include(n);
2006
+ } catch (e) {
2007
+ this.#s || (this.#r(E(e, this.#t.t)), await this.reload());
2008
+ } finally {
2009
+ this.#o.delete(e.flowId);
2010
+ }
2011
+ }
2012
+ }
2013
+ async publish(e) {
2014
+ if (!this.#o.has(e.flowId)) {
2015
+ this.#o.add(e.flowId);
2016
+ try {
2017
+ let t = await this.#e.publishFlow(e.flowId, e.draftRevisionId, e.live?.publicationId ?? null);
2018
+ if (this.#s) return;
2019
+ let n = await Y.runPromise(Y.gen({ self: this }, function* () {
2020
+ let n = t;
2021
+ for (; n.status == "pending";) yield* Y.sleep(1e3), n = yield* Y.tryPromise((t) => this.#e.getPublishOperation(e.flowId, n.operationId, t));
2022
+ return n;
2023
+ }), { signal: this.#a.signal });
2024
+ if (this.#s) return;
2025
+ n.status == "failed" ? this.#r({
2026
+ kind: "error",
2027
+ message: n.issue.message
2028
+ }) : this.#r({
2029
+ kind: "success",
2030
+ message: this.#t.t("notice.published", { name: e.name })
2031
+ }), this.include(await this.#e.getFlow(e.flowId));
2032
+ } catch (e) {
2033
+ this.#s || this.#r(E(e, this.#t.t));
2034
+ } finally {
2035
+ this.#o.delete(e.flowId);
2036
+ }
1841
2037
  }
1842
2038
  }
1843
2039
  async create(e) {
1844
2040
  let t = await this.#e.createFlow(e);
1845
- if (!this.#a) return this.#o({
1846
- flows: [...this.#i.value.flows, t],
1847
- total: this.#i.value.total == null ? void 0 : this.#i.value.total + 1
1848
- }), t;
2041
+ if (!this.#s) return this.insert(t), t;
1849
2042
  }
1850
2043
  include(e) {
1851
2044
  let t = this.#i.value.flows.findIndex((t) => t.flowId == e.flowId);
1852
2045
  if (t < 0) {
1853
- this.#o({ flows: [...this.#i.value.flows, e] });
2046
+ this.#c({ flows: [...this.#i.value.flows, e] });
1854
2047
  return;
1855
2048
  }
1856
- this.#o({ flows: this.#i.value.flows.with(t, e) });
2049
+ this.#c({ flows: this.#i.value.flows.with(t, e) });
1857
2050
  }
1858
2051
  insert(e) {
1859
- this.#i.value.flows.some((t) => t.flowId == e.flowId) || this.#o({
2052
+ this.#i.value.flows.some((t) => t.flowId == e.flowId) || this.#c({
1860
2053
  flows: [...this.#i.value.flows, e],
1861
2054
  total: this.#i.value.total == null ? void 0 : this.#i.value.total + 1
1862
2055
  });
1863
2056
  }
1864
2057
  remove(e) {
1865
- this.#o({
2058
+ this.#c({
1866
2059
  flows: this.#i.value.flows.filter((t) => t.flowId != e),
1867
2060
  total: this.#i.value.total == null ? void 0 : this.#i.value.total - 1
1868
2061
  });
1869
2062
  }
1870
2063
  advanceHead(e, t) {
1871
- this.#o({ flows: this.#i.value.flows.map((n) => n.flowId == e ? {
2064
+ this.#c({ flows: this.#i.value.flows.map((n) => n.flowId == e ? {
1872
2065
  ...n,
1873
2066
  draftRevisionId: t
1874
2067
  } : n) });
1875
2068
  }
1876
- #o(e) {
1877
- this.#a || this.#i.set({
2069
+ #c(e) {
2070
+ this.#s || this.#i.set({
1878
2071
  ...this.#i.value,
1879
2072
  ...e
1880
2073
  });
1881
2074
  }
1882
- }, Ft = class {
2075
+ }, en = class {
1883
2076
  #e;
1884
2077
  #t;
1885
2078
  #n;
@@ -1922,7 +2115,7 @@ var Mt = class {
1922
2115
  this.#c(a, r);
1923
2116
  } catch (r) {
1924
2117
  if (this.#o || !n()) return;
1925
- if (r instanceof z && r.code == "flow.presentation-conflict") try {
2118
+ if (r instanceof L && r.code == "flow.presentation-conflict") try {
1926
2119
  let t = await this.#e.getPresentation(e);
1927
2120
  if (this.#o || !n()) return;
1928
2121
  this.#c(a, t), this.#n({
@@ -1930,9 +2123,9 @@ var Mt = class {
1930
2123
  message: this.#t.t("notice.layoutConflict")
1931
2124
  });
1932
2125
  } catch (e) {
1933
- !this.#o && n() && this.#n(D(e, this.#t.t));
2126
+ !this.#o && n() && this.#n(E(e, this.#t.t));
1934
2127
  }
1935
- else this.#c(a, t), this.#n(D(r, this.#t.t));
2128
+ else this.#c(a, t), this.#n(E(r, this.#t.t));
1936
2129
  }
1937
2130
  }), await this.#i;
1938
2131
  }
@@ -1944,21 +2137,21 @@ var Mt = class {
1944
2137
  value: n
1945
2138
  });
1946
2139
  }
1947
- }, It = {
2140
+ }, tn = {
1948
2141
  checkLoading: !1,
1949
2142
  selectedNodeIds: [],
1950
2143
  workspaceLoadFailed: !1,
1951
2144
  workspaceLoading: !1
1952
2145
  };
1953
- function Lt(e) {
1954
- return e.workspaceLoading ? "loading" : e.busy == "designer" ? "saving" : e.draft == null ? "noDraft" : "saved";
2146
+ function nn(e) {
2147
+ return e.workspaceLoading ? "loading" : e.moduleSaveStatus == null ? e.busy == "designer" ? "saving" : e.draft == null ? "noDraft" : "saved" : e.moduleSaveStatus;
1955
2148
  }
1956
- function Q(e, t) {
2149
+ function $(e, t) {
1957
2150
  if (t.phase != null) return t.phase;
1958
2151
  let n = e?.content.modules[t.moduleId];
1959
2152
  return n == null ? "failed" : t.source == n.source ? "saved" : "dirty";
1960
2153
  }
1961
- function $(e, t, n) {
2154
+ function rn(e, t, n) {
1962
2155
  if (e == null || t == null || n.length != 1) return;
1963
2156
  let r = e.node(t, n[0]);
1964
2157
  if (!(r?.kind != "task" || r.definition == null || !("moduleId" in r.definition) || r.module == null)) return {
@@ -1966,9 +2159,9 @@ function $(e, t, n) {
1966
2159
  source: r.module.source
1967
2160
  };
1968
2161
  }
1969
- var Rt = class {
2162
+ var an = class {
1970
2163
  #e;
1971
- #t = t(It);
2164
+ #t = t(tn);
1972
2165
  #n;
1973
2166
  constructor(t, r) {
1974
2167
  let i = e(this.#t, (e) => e.busy), a = e(this.#t, (e) => e.checkLoading), o = e(this.#t, (e) => e.diagnosticFocus), s = e(this.#t, (e) => e.diagnostics), c = e(this.#t, (e) => e.draft), l = e(this.#t, (e) => {
@@ -1976,25 +2169,25 @@ var Rt = class {
1976
2169
  let { phase: t, ...n } = e.moduleEditor;
1977
2170
  return {
1978
2171
  ...n,
1979
- status: Q(e.draft, e.moduleEditor)
2172
+ status: $(e.draft, e.moduleEditor)
1980
2173
  };
1981
- }), u = e(this.#t, (e) => e.nodeFocus), d = e(this.#t, (e) => e.presentation), f = e(this.#t, (e) => e.flowId), p = e(this.#t, (e) => e.live), m = e(this.#t, (e) => e.draft == null ? void 0 : I(e.draft)), h = e(this.#t, (e) => e.selectedNodeIds), g = e(this.#t, (e) => e.target), _ = e(this.#t, (e) => e.workspaceLoadFailed), v = e(this.#t, (e) => e.workspaceLoading);
2174
+ }), u = e(this.#t, (e) => e.nodeFocus), d = e(this.#t, (e) => e.presentation), f = e(this.#t, (e) => e.flowId), p = e(this.#t, (e) => e.live), m = e(this.#t, (e) => e.draft == null ? void 0 : C(e.draft)), h = e(this.#t, (e) => e.selectedNodeIds), g = e(this.#t, (e) => e.target), _ = e(this.#t, (e) => e.workspaceLoadFailed), v = e(this.#t, (e) => e.workspaceLoading);
1982
2175
  this.#e = e(this.#t, (e) => ({
1983
- revision: e.draft == null ? void 0 : I(e.draft),
2176
+ revision: e.draft == null ? void 0 : C(e.draft),
1984
2177
  target: e.target
1985
2178
  }), { equal: (e, t) => e.revision === t.revision && e.target === t.target });
1986
2179
  let y = e(this.#t, (e) => {
1987
- if (e.draft != null && e.target != null && e.selectedNodeIds.length == 1) return I(e.draft).selection(e.target, e.selectedNodeIds[0]);
2180
+ if (e.draft != null && e.target != null && e.selectedNodeIds.length == 1) return C(e.draft).selection(e.target, e.selectedNodeIds[0]);
1988
2181
  });
1989
2182
  this.$ = {
1990
2183
  addNodeOptions: n((e) => {
1991
2184
  let { revision: n, target: r } = e(this.#e);
1992
- return Le(n?.revision, r, e(t.t$));
2185
+ return Oe(n?.revision, r, e(t.t$));
1993
2186
  }),
1994
2187
  busy: i,
1995
2188
  checkLoading: a,
1996
2189
  diagnosticFocus: o,
1997
- diagnosticItems: e(this.#t, (e) => E(e.draft == null ? void 0 : I(e.draft), e.target, e.diagnostics)),
2190
+ diagnosticItems: e(this.#t, (e) => D(e.draft == null ? void 0 : C(e.draft), e.target, e.diagnostics)),
1998
2191
  diagnostics: s,
1999
2192
  draft: c,
2000
2193
  flow: n((e) => {
@@ -2010,7 +2203,7 @@ var Rt = class {
2010
2203
  flowRefreshing: r.$.refreshing,
2011
2204
  flowTotal: r.$.total,
2012
2205
  flows: r.$.flows,
2013
- inspectorDiagnostics: e(this.#t, (e) => ne(e.draft == null ? void 0 : I(e.draft), e.target, e.diagnostics, y.value)),
2206
+ inspectorDiagnostics: e(this.#t, (e) => T(e.draft == null ? void 0 : C(e.draft), e.target, e.diagnostics, y.value)),
2014
2207
  live: p,
2015
2208
  moduleDiagnostics: e(this.#t, (e) => {
2016
2209
  let t = e.moduleEditor?.moduleId;
@@ -2022,11 +2215,11 @@ var Rt = class {
2022
2215
  revision: m,
2023
2216
  selection: y,
2024
2217
  selectedNodeIds: h,
2025
- status: e(this.#t, Lt),
2218
+ status: e(this.#t, nn),
2026
2219
  target: g,
2027
2220
  targetFlow: n((e) => e(g)?.kind == "flow" ? e(r.$.flows).find((t) => t.flowId == e(f)) : void 0),
2028
2221
  targetName: e(this.#t, (e) => {
2029
- if (e.target != null) return e.target.kind == "flow" ? r.flow(e.flowId ?? "")?.name : e.draft == null ? e.target.id : I(e.draft).subflow(e.target.id)?.name ?? e.target.id;
2222
+ if (e.target != null) return e.target.kind == "flow" ? r.flow(e.flowId ?? "")?.name : e.draft == null ? e.target.id : C(e.draft).subflow(e.target.id)?.name ?? e.target.id;
2030
2223
  }),
2031
2224
  workspaceLoadFailed: _,
2032
2225
  workspaceLoading: v
@@ -2045,57 +2238,17 @@ var Rt = class {
2045
2238
  for (let e of Object.values(this.$)) this.#n.has(e) || e.dispose();
2046
2239
  this.#e.dispose(), this.#t.dispose();
2047
2240
  }
2241
+ }, on = {
2242
+ x: 40,
2243
+ y: 40
2048
2244
  };
2049
- //#endregion
2050
- //#region src/workbench/browser/runtime/stores/workspaceStore.ts
2051
- function zt(e, t) {
2245
+ function sn(e, t) {
2052
2246
  if (t != null) return t.kind == "flow" || e.subflow(t.id) != null ? t : { kind: "flow" };
2053
2247
  }
2054
- function Bt(e, t, n, r) {
2055
- let i = j(e, t).nodes;
2056
- if (r.target == n) {
2057
- let e = i.find((e) => e.id == r.source);
2058
- if (e == null || e.kind == "comment") return;
2059
- let t = e.outputs.find((e) => "handle" in e && e.handle == r.sourceHandle);
2060
- return t == null || !("handle" in t) ? void 0 : {
2061
- inputs: [{
2062
- description: t.description,
2063
- handle: r.targetHandle,
2064
- jsonSchema: t.jsonSchema ?? {},
2065
- nullable: t.nullable ?? !1,
2066
- value: null
2067
- }],
2068
- outputs: [{
2069
- handle: "result",
2070
- jsonSchema: {},
2071
- nullable: !0
2072
- }]
2073
- };
2074
- }
2075
- if (r.source == n) {
2076
- let e = i.find((e) => e.id == r.target);
2077
- if (e == null || e.kind == "comment") return;
2078
- let t = e.inputs.find((e) => "handle" in e && e.handle == r.targetHandle);
2079
- return t == null || !("handle" in t) ? void 0 : {
2080
- inputs: [{
2081
- handle: "value",
2082
- jsonSchema: {},
2083
- nullable: !0,
2084
- value: null
2085
- }],
2086
- outputs: [{
2087
- description: t.description,
2088
- handle: r.sourceHandle,
2089
- jsonSchema: t.jsonSchema ?? {},
2090
- nullable: t.nullable ?? !1
2091
- }]
2092
- };
2093
- }
2094
- }
2095
- var Vt = class {
2248
+ var cn = class {
2096
2249
  #e;
2097
2250
  #t;
2098
- #n = new F();
2251
+ #n = new m();
2099
2252
  #r;
2100
2253
  #i;
2101
2254
  #a;
@@ -2103,47 +2256,60 @@ var Vt = class {
2103
2256
  #s;
2104
2257
  #c;
2105
2258
  #l;
2106
- #u;
2107
- #d = 0;
2108
- #f = 0;
2109
- #p = !1;
2110
- #m = !1;
2111
- #h = !1;
2112
- #g = 0;
2113
- #_;
2114
- #v;
2115
- constructor(e, t, n = ut, r = L(), i = () => {}) {
2116
- this.#e = e, this.#c = t, this.#i = n, this.#r = r, this.#s = i, this.#o = new Pt(e, t, r), this.#l = new Rt(r, this.#o), this.#t = new Mt(e, t, r, {
2117
- apply: (e, t) => this.#x(e, t),
2259
+ #u = /* @__PURE__ */ new Map();
2260
+ #d;
2261
+ #f;
2262
+ #p;
2263
+ #m = 0;
2264
+ #h = 0;
2265
+ #g = !1;
2266
+ #_ = !1;
2267
+ #v = !1;
2268
+ #y = 0;
2269
+ #b;
2270
+ #x;
2271
+ constructor(e, t, n = Dt, r = P(), i = () => {}) {
2272
+ this.#e = e, this.#c = t, this.#i = n, this.#r = r, this.#s = i, this.#o = new $t(e, t, r), this.#l = new an(r, this.#o), this.#t = new Xt(e, t, r, {
2273
+ apply: (e, t) => this.#D(e, t),
2118
2274
  beforeChange: (e) => {
2119
- e && (this.#N({ busy: "designer" }), this.#c(void 0));
2275
+ e && (this.#R({ busy: "designer" }), this.#c(void 0));
2120
2276
  },
2121
- check: () => void this.#C(),
2122
- current: (e) => this.#M(e),
2277
+ check: () => void this.#k(),
2278
+ current: (e) => this.#L(e),
2123
2279
  diagnostics: () => this.#l.value.diagnostics,
2124
2280
  finishChanges: () => {
2125
- !this.#m && this.#l.value.busy == "designer" && this.#N({ busy: void 0 });
2281
+ !this.#_ && this.#l.value.busy == "designer" && this.#R({ busy: void 0 });
2126
2282
  },
2127
- headChanged: (e, t) => this.#E(e, t),
2128
- recover: (e) => this.#T(e, !0)
2129
- }), this.#a = new Ft(e, t, (e) => this.#N({ presentation: e }), r), this.$ = this.#l.$;
2283
+ headChanged: (e, t) => this.#M(e, t),
2284
+ recover: (e) => this.#j(e, !0)
2285
+ }), this.#a = new en(e, t, (e) => this.#R({ presentation: e }), r), this.$ = this.#l.$;
2130
2286
  }
2131
2287
  dispose() {
2132
- this.#m = !0, this.#n.invalidate(), this.#a.dispose(), this.#_?.(), this.#v?.(), this.#l.dispose(), this.#o.dispose();
2288
+ this.#_ = !0, clearTimeout(this.#d), this.#n.invalidate(), this.#a.dispose(), this.#b?.(), this.#x?.(), this.#l.dispose(), this.#o.dispose();
2133
2289
  }
2134
2290
  async start(e) {
2135
- this.#_ ??= this.#e.watchFlowCatalog(() => void this.reloadFlows()), await this.reloadFlows(), await this.selectFlow(e);
2291
+ if (this.#b == null) {
2292
+ let e = this.#e.watchFlowCatalog(() => void this.reloadFlows());
2293
+ this.#b = e.stop, await e.ready;
2294
+ }
2295
+ this.#_ || (await this.reloadFlows(), this.#_ || await this.selectFlow(e));
2136
2296
  }
2137
2297
  async reloadFlows() {
2138
2298
  await this.#o.reload();
2139
2299
  }
2300
+ async setFlowEnabled(e, t) {
2301
+ await this.#o.setEnabled(e, t);
2302
+ }
2303
+ async publishFlow(e) {
2304
+ await this.#o.publish(e);
2305
+ }
2140
2306
  async loadMoreFlows() {
2141
2307
  await this.#o.loadMore();
2142
2308
  }
2143
2309
  async selectFlow(e) {
2144
- if (!this.#O()) return !1;
2310
+ if (!await this.saveModuleEditor()) return !1;
2145
2311
  let t = this.#n.begin();
2146
- if (this.#t.reset(), this.#a.reset(), this.#f = 0, this.#p = !1, this.#h = !1, this.#v?.(), this.#v = void 0, this.#N({
2312
+ if (this.#t.reset(), this.#a.reset(), this.#h = 0, this.#g = !1, this.#v = !1, this.#x?.(), this.#x = void 0, this.#R({
2147
2313
  checkLoading: !1,
2148
2314
  diagnosticFocus: void 0,
2149
2315
  diagnostics: void 0,
@@ -2159,27 +2325,27 @@ var Vt = class {
2159
2325
  workspaceLoading: e != null
2160
2326
  }), e == null) return !0;
2161
2327
  try {
2162
- let n = this.#o.flow(e), [r, i, a, o] = await Promise.all([
2163
- n ?? this.#e.getFlow(e),
2164
- this.#e.getDraft(e),
2165
- this.#e.getLive(e),
2166
- this.#e.getPresentation(e)
2167
- ]);
2328
+ let n = !1, r, i = this.#e.watchFlow(e, (e) => {
2329
+ t() && (this.#t.committed == null ? (n = !0, r = e) : e != this.#t.committed.revisionId && this.#A(e));
2330
+ }, (e) => {
2331
+ t() && this.#s(e);
2332
+ });
2333
+ if (this.#x = i.stop, await i.ready, !t()) return !1;
2334
+ let { flow: a, draft: o, live: s, presentation: c } = await this.#e.getEditor(e);
2168
2335
  if (!t()) return !1;
2169
- this.#t.reset(i), this.#a.reset(o), this.#o.include(r), this.#N({
2170
- draft: i,
2171
- live: a,
2172
- presentation: o,
2336
+ this.#t.reset(o), this.#a.reset(c), this.#o.include(a), this.#R({
2337
+ draft: o,
2338
+ live: s,
2339
+ presentation: c,
2173
2340
  target: { kind: "flow" },
2174
2341
  workspaceLoadFailed: !1,
2175
2342
  workspaceLoading: !1
2176
- }), this.#C(), this.#v = this.#e.watchFlow(e, (e) => {
2177
- !this.#m && e != this.#t.committed?.revisionId && this.#w(e);
2178
- }, this.#s);
2343
+ }), await this.#E(t), n && r != o.revisionId && this.#A(r);
2179
2344
  } catch (e) {
2180
2345
  if (!t()) return !1;
2181
- let n = e instanceof z && e.code == ve.flowNotFound;
2182
- return this.#N(n ? {
2346
+ this.#x?.(), this.#x = void 0;
2347
+ let n = e instanceof L && e.code == le.flowNotFound;
2348
+ return this.#R(n ? {
2183
2349
  flowId: void 0,
2184
2350
  target: void 0,
2185
2351
  workspaceLoadFailed: !1,
@@ -2190,64 +2356,64 @@ var Vt = class {
2190
2356
  }), this.#c(n ? {
2191
2357
  kind: "error",
2192
2358
  message: this.#r.t("notice.flowMissing")
2193
- } : D(e, this.#r.t)), !1;
2359
+ } : E(e, this.#r.t)), !1;
2194
2360
  }
2195
2361
  return !0;
2196
2362
  }
2197
2363
  selectTarget(e) {
2198
- return this.#O() ? (this.#N({
2364
+ return this.#S(), this.#R({
2199
2365
  diagnosticFocus: void 0,
2200
2366
  diagnostics: void 0,
2201
2367
  moduleEditor: void 0,
2202
2368
  nodeFocus: void 0,
2203
2369
  selectedNodeIds: [],
2204
2370
  target: e
2205
- }), this.#C(), !0) : !1;
2371
+ }), this.#k(), !0;
2206
2372
  }
2207
2373
  selectNodes(e) {
2208
- return e.length == this.#l.value.selectedNodeIds.length && e.every((e, t) => e == this.#l.value.selectedNodeIds[t]) ? !0 : this.#O() ? (this.#N({
2374
+ return e.length == this.#l.value.selectedNodeIds.length && e.every((e, t) => e == this.#l.value.selectedNodeIds[t]) ? !0 : (this.#S(), this.#R({
2209
2375
  diagnosticFocus: void 0,
2210
- moduleEditor: $(this.#l.value.draft == null ? void 0 : I(this.#l.value.draft), this.#l.value.target, e),
2376
+ moduleEditor: rn(this.#l.value.draft == null ? void 0 : C(this.#l.value.draft), this.#l.value.target, e),
2211
2377
  nodeFocus: void 0,
2212
2378
  selectedNodeIds: e
2213
- }), !0) : !1;
2379
+ }), !0);
2214
2380
  }
2215
2381
  async createFlow(e, t) {
2216
- if (this.#O()) {
2217
- this.#N({ busy: "flow" }), this.#c(void 0);
2382
+ if (await this.saveModuleEditor()) {
2383
+ this.#R({ busy: "flow" }), this.#c(void 0);
2218
2384
  try {
2219
2385
  if (t == null) return await this.#o.create(e);
2220
2386
  let n = await this.#e.getFlow(await t(e));
2221
2387
  return this.#o.insert(n), n;
2222
2388
  } catch (e) {
2223
- this.#m || this.#c(D(e, this.#r.t));
2389
+ this.#_ || this.#c(E(e, this.#r.t));
2224
2390
  } finally {
2225
- this.#N({ busy: void 0 });
2391
+ this.#R({ busy: void 0 });
2226
2392
  }
2227
2393
  }
2228
2394
  }
2229
2395
  async deleteFlow(e) {
2230
- if (!this.#O()) return !1;
2396
+ if (!await this.saveModuleEditor()) return !1;
2231
2397
  let t = this.#o.flow(e);
2232
2398
  if (t == null || t.status == "retiring") return !1;
2233
- this.#N({ busy: "flow" }), this.#c(void 0);
2399
+ this.#R({ busy: "flow" }), this.#c(void 0);
2234
2400
  try {
2235
- return await this.#e.deleteFlow(e), !this.#m && (this.#o.remove(e), this.#c({
2401
+ return await this.#e.deleteFlow(e), !this.#_ && (this.#o.remove(e), this.#c({
2236
2402
  kind: "success",
2237
2403
  message: this.#r.t("notice.flowDeleteAccepted", { name: t.name })
2238
2404
  }), !0);
2239
2405
  } catch (e) {
2240
- return this.#m || this.#c(D(e, this.#r.t)), !1;
2406
+ return this.#_ || this.#c(E(e, this.#r.t)), !1;
2241
2407
  } finally {
2242
- this.#N({ busy: void 0 });
2408
+ this.#R({ busy: void 0 });
2243
2409
  }
2244
2410
  }
2245
2411
  async createResource(e) {
2246
- if (!this.#O() || this.#l.value.draft == null) return !1;
2412
+ if (!await this.saveModuleEditor() || this.#l.value.draft == null) return !1;
2247
2413
  let t = this.#i();
2248
- this.#N({ busy: "resource" }), this.#c(void 0);
2249
- let n = await this.#b(se(t, e), !1);
2250
- return this.#N({ busy: void 0 }), n != null && (this.selectTarget({
2414
+ this.#R({ busy: "resource" }), this.#c(void 0);
2415
+ let n = await this.#T(j(t, e), !1);
2416
+ return this.#R({ busy: void 0 }), n != null && (this.selectTarget({
2251
2417
  id: t,
2252
2418
  kind: "subflow"
2253
2419
  }), this.#c({
@@ -2259,173 +2425,188 @@ var Vt = class {
2259
2425
  let n = this.#o.flow(e), r = t.trim();
2260
2426
  if (n == null || r.length == 0) return !1;
2261
2427
  if (n.name == r) return !0;
2262
- this.#N({ busy: "flow" }), this.#c(void 0);
2428
+ this.#R({ busy: "flow" }), this.#c(void 0);
2263
2429
  let i;
2264
2430
  try {
2265
2431
  i = await this.#e.renameFlow(e, r), i != null && this.#o.include(i);
2266
2432
  } catch (e) {
2267
- this.#m || this.#c(D(e, this.#r.t));
2433
+ this.#_ || this.#c(E(e, this.#r.t));
2268
2434
  }
2269
- return this.#N({ busy: void 0 }), i != null && (this.#c({
2435
+ return this.#R({ busy: void 0 }), i != null && (this.#c({
2270
2436
  kind: "success",
2271
2437
  message: this.#r.t("notice.flowRenamed", { name: r })
2272
2438
  }), !0);
2273
2439
  }
2274
2440
  async addNode(e, t, n) {
2275
- if (!this.#O()) return;
2441
+ if (!await this.saveModuleEditor()) return;
2276
2442
  let r = this.#l.value.draft, i = this.#l.value.target;
2277
2443
  if (r == null || i == null) return;
2278
2444
  let a = this.#i();
2279
- if (e.kind == "comment") return await this.#y(i, a, t);
2280
- let o = I(r), s = ee(e, o, i, this.#r.t);
2445
+ if (e.kind == "comment") return await this.#w(i, a, t);
2446
+ let o = C(r), s = u(e, o, i, this.#r.t);
2281
2447
  if (s == null) return;
2282
- let c = n?.(a);
2283
- if (s.kind == "code" && c != null) {
2284
- let e = Bt(r, i, a, c);
2285
- if (e == null) return;
2286
- s = {
2287
- ...s,
2288
- ports: e
2289
- };
2290
- }
2291
- let l = Ne(o, i, a, s, this.#i);
2448
+ let c = n?.(a), l = we(o, i, a, s, this.#i);
2292
2449
  if (l == null) return;
2293
- let u = c == null ? l : [...l, ...at(B(r, l).content, i, c)], d = this.#b(u);
2450
+ let d = c == null ? l : [...l, ...St(R(r, l).content, i, {
2451
+ source: c.source,
2452
+ target: c.target,
2453
+ ...c.sourceHandle.startsWith("$branch:") ? { sourceHandle: c.sourceHandle.slice(8) } : {}
2454
+ })], f = this.#T(d);
2294
2455
  this.selectNodes([a]);
2295
- let f = this.moveNodes({ [a]: t });
2296
- if (await d != null && (await f, !this.#m)) return this.#N({ nodeFocus: {
2456
+ let p = this.moveNodes({ [a]: t });
2457
+ if (await f != null && (await p, !this.#_)) return this.#R({ nodeFocus: {
2297
2458
  nodeId: a,
2298
- requestId: ++this.#g
2459
+ requestId: ++this.#y
2299
2460
  } }), a;
2300
2461
  }
2301
2462
  async connect(e) {
2302
2463
  let t = this.$.revision.value, n = this.#l.value.target;
2303
2464
  if (t == null || n == null) return;
2304
- let r = at(t.revision.content, n, e);
2305
- r.length > 0 && await this.#b(r);
2465
+ let r = St(t.revision.content, n, {
2466
+ source: e.source,
2467
+ target: e.target,
2468
+ ...e.sourceHandle.startsWith("$branch:") ? { sourceHandle: e.sourceHandle.slice(8) } : {}
2469
+ });
2470
+ r.length > 0 && await this.#T(r);
2306
2471
  }
2307
2472
  async disconnect(e) {
2308
2473
  let t = this.$.revision.value, n = this.#l.value.target;
2309
2474
  if (t == null || n == null) return;
2310
- let r = ot(t.revision.content, n, e);
2311
- r.length > 0 && await this.#b(r);
2475
+ let r = Ct(t.revision.content, n, {
2476
+ source: e.source,
2477
+ target: e.target,
2478
+ ...e.sourceHandle.startsWith("$branch:") ? { sourceHandle: e.sourceHandle.slice(8) } : {}
2479
+ });
2480
+ r.length > 0 && await this.#T(r);
2312
2481
  }
2313
2482
  async deleteSelectedNodes() {
2314
- if (!this.#O()) return;
2483
+ if (!await this.saveModuleEditor()) return;
2315
2484
  let e = this.$.revision.value, t = this.#l.value.target;
2316
2485
  if (e == null || t == null || this.#l.value.selectedNodeIds.length == 0) return;
2317
- let n = w(this.#l.value.presentation?.value ?? {}, t), r = new Set(this.#l.value.selectedNodeIds.filter((e) => n.has(e))), i = Te(e, t, this.#l.value.selectedNodeIds), a = i.length == 0 ? void 0 : this.#b(i), o = r.size == 0 ? void 0 : this.#S((e) => S(e, t, r));
2486
+ let n = f(this.#l.value.presentation?.value ?? {}, t), r = new Set(this.#l.value.selectedNodeIds.filter((e) => n.has(e))), i = ge(e, t, this.#l.value.selectedNodeIds), a = i.length == 0 ? void 0 : this.#T(i), o = r.size == 0 ? void 0 : this.#O((e) => c(e, t, r));
2318
2487
  this.selectNodes([]), (a == null || await a != null) && await o;
2319
2488
  }
2320
2489
  copySelectedNodes() {
2321
2490
  let e = this.$.revision.value, t = this.#l.value.target;
2322
2491
  if (e == null || t == null || this.#l.value.selectedNodeIds.length == 0) return;
2323
2492
  let n = new Set(this.#l.value.selectedNodeIds);
2324
- this.#u = {
2325
- comments: this.#D().nodes.flatMap((e) => e.kind == "comment" && n.has(e.id) ? [{
2493
+ this.#p = {
2494
+ comments: this.#N().nodes.flatMap((e) => e.kind == "comment" && n.has(e.id) ? [{
2326
2495
  content: e.content,
2327
2496
  position: e.position,
2328
2497
  sourceId: e.id,
2329
2498
  title: e.title
2330
2499
  }] : []),
2331
- nodes: ye(e, t, this.#l.value.selectedNodeIds)
2500
+ nodes: ue(e, t, this.#l.value.selectedNodeIds)
2332
2501
  };
2333
2502
  }
2334
- async pasteNodes(e) {
2335
- if (!this.#O()) return;
2336
- let t = this.$.revision.value, n = this.#l.value.target;
2337
- if (t == null || n == null || this.#u == null) return;
2338
- let r = je(t, n, this.#u.nodes, this.#i), i = r.changes.length == 0 ? void 0 : this.#b(r.changes), a = this.#u.comments.map((e) => ({
2503
+ async pasteNodes(e, t = on) {
2504
+ if (!await this.saveModuleEditor()) return;
2505
+ let n = this.$.revision.value, r = this.#l.value.target;
2506
+ if (n == null || r == null || this.#p == null) return;
2507
+ let i = Se(n, r, this.#p.nodes, this.#i), a = i.changes.length == 0 ? void 0 : this.#T(i.changes), o = this.#p.comments.map((e) => ({
2339
2508
  ...e,
2340
2509
  nodeId: this.#i()
2341
2510
  }));
2342
- if (r.nodeIds.length == 0 && a.length == 0) return;
2343
- let o = new Map(this.#D().nodes.map((e) => [e.id, e])), s = Object.fromEntries(r.sourceIds.map((t, n) => {
2344
- let i = e?.[t] ?? o.get(t)?.position;
2345
- return [r.nodeIds[n], {
2346
- x: (i?.x ?? 80) + 40,
2347
- y: (i?.y ?? 80) + 40
2511
+ if (i.nodeIds.length == 0 && o.length == 0) return;
2512
+ let s = new Map(this.#N().nodes.map((e) => [e.id, e])), c = /* @__PURE__ */ new Set([...i.nodeIds, ...o.map((e) => e.nodeId)]), l = new Set([...s].filter(([e]) => !c.has(e)).map(([, e]) => `${e.position.x}\0${e.position.y}`)), u = [...i.sourceIds.map((t) => e?.[t] ?? s.get(t)?.position ?? {
2513
+ x: 80,
2514
+ y: 80
2515
+ }), ...o.map((e) => e.position)], d = 1;
2516
+ if (t.x != 0 || t.y != 0) for (; u.some((e) => l.has(`${e.x + t.x * d}\0${e.y + t.y * d}`));) d += 1;
2517
+ let f = Object.fromEntries(i.sourceIds.map((n, r) => {
2518
+ let a = e?.[n] ?? s.get(n)?.position;
2519
+ return [i.nodeIds[r], {
2520
+ x: (a?.x ?? 80) + t.x * d,
2521
+ y: (a?.y ?? 80) + t.y * d
2348
2522
  }];
2349
- })), c = this.#S((e) => {
2350
- let t = A(e, n, s);
2351
- for (let e of a) t = R(t, n, e.nodeId, {
2523
+ })), p = this.#O((e) => {
2524
+ let n = y(e, r, f);
2525
+ for (let e of o) n = I(n, r, e.nodeId, {
2352
2526
  content: e.content,
2353
2527
  position: {
2354
- x: e.position.x + 40,
2355
- y: e.position.y + 40
2528
+ x: e.position.x + t.x * d,
2529
+ y: e.position.y + t.y * d
2356
2530
  },
2357
2531
  title: this.#r.t("addNode.commentCopy", { title: e.title })
2358
2532
  });
2359
- return t;
2533
+ return n;
2360
2534
  });
2361
- this.selectNodes([...r.nodeIds, ...a.map((e) => e.nodeId)]), (i == null || await i != null) && await c;
2535
+ this.selectNodes([...i.nodeIds, ...o.map((e) => e.nodeId)]), (a == null || await a != null) && await p;
2362
2536
  }
2363
- async duplicateSelectedNodes(e) {
2364
- this.copySelectedNodes(), await this.pasteNodes(e);
2537
+ async duplicateSelectedNodes(e, t) {
2538
+ this.copySelectedNodes(), await this.pasteNodes(e, t);
2365
2539
  }
2366
2540
  async saveNodeSettings(e, t) {
2367
2541
  let n = this.$.revision.value, r = this.#l.value.target;
2368
2542
  if (n == null || r == null) return !1;
2369
- let i = ge(n, r, e, t);
2370
- return i != null && await this.#b(i) != null;
2543
+ let i = se(n, r, e, t);
2544
+ return i != null && await this.#T(i) != null;
2371
2545
  }
2372
2546
  async saveNodeDescription(e, t) {
2373
2547
  let n = this.$.revision.value, r = this.#l.value.target;
2374
2548
  if (n == null || r == null) return !1;
2375
- let i = De(n, r, e, t);
2376
- return i != null && await this.#b(i) != null;
2549
+ let i = ve(n, r, e, t);
2550
+ return i != null && await this.#T(i) != null;
2377
2551
  }
2378
2552
  async saveNodeIcon(e, t) {
2379
2553
  let n = this.$.revision.value, r = this.#l.value.target;
2380
2554
  if (n == null || r == null) return !1;
2381
- let i = Ce(n, r, e, t);
2382
- return i != null && await this.#b(i) != null;
2555
+ let i = me(n, r, e, t);
2556
+ return i != null && await this.#T(i) != null;
2383
2557
  }
2384
2558
  async saveNodeTitle(e, t) {
2385
2559
  let n = this.$.revision.value, r = this.#l.value.target;
2386
2560
  if (n == null || r == null) return !1;
2387
- let i = _e(n, r, e, t);
2388
- return i != null && await this.#b(i) != null;
2561
+ let i = ce(n, r, e, t);
2562
+ return i != null && await this.#T(i) != null;
2389
2563
  }
2390
2564
  async setInputValue(e, t, n) {
2391
2565
  let r = this.$.revision.value, i = this.#l.value.target;
2392
2566
  if (r == null || i == null) return !1;
2393
- let a = ue(r, i, e, t, n);
2394
- return a != null && await this.#b(a) != null;
2567
+ let a = N(r, i, e, t, n);
2568
+ return a != null && await this.#T(a) != null;
2569
+ }
2570
+ async setInputSource(e, t, n) {
2571
+ let r = this.$.revision.value, i = this.#l.value.target;
2572
+ return r == null || i == null ? !1 : await this.#T(ee(r.revision.content, i, e, t, [{
2573
+ kind: "node",
2574
+ ...n
2575
+ }])) != null;
2395
2576
  }
2396
2577
  async setInputVariable(e, t, n) {
2397
2578
  let r = this.$.revision.value, i = this.#l.value.target;
2398
2579
  if (r == null || i == null) return !1;
2399
- let a = n == null ? ue(r, i, e, t, void 0) : xe(r, i, e, t, n, this.#i());
2400
- return a != null && await this.#b(a) != null;
2580
+ let a = n == null ? N(r, i, e, t, void 0) : fe(r, i, e, t, n, this.#i());
2581
+ return a != null && await this.#T(a) != null;
2401
2582
  }
2402
2583
  async saveCondition(e, t) {
2403
2584
  let n = this.$.revision.value, r = this.#l.value.target;
2404
2585
  if (n == null || r == null) return !1;
2405
- let i = he(n, r, e, t);
2406
- return i != null && await this.#b(i) != null;
2586
+ let i = oe(n, r, e, t);
2587
+ return i != null && await this.#T(i) != null;
2407
2588
  }
2408
2589
  async saveValue(e, t) {
2409
2590
  let n = this.$.revision.value, r = this.#l.value.target;
2410
2591
  if (n == null || r == null) return !1;
2411
- let i = le(n, r, e, t);
2412
- return i != null && await this.#b(i) != null;
2592
+ let i = M(n, r, e, t);
2593
+ return i != null && await this.#T(i) != null;
2413
2594
  }
2414
2595
  async saveWait(e, t) {
2415
2596
  let n = this.$.revision.value, r = this.#l.value.target;
2416
2597
  if (n == null || r?.kind != "flow") return !1;
2417
- let i = Re(n, r, e, t);
2418
- return i != null && await this.#b(i) != null;
2598
+ let i = ke(n, r, e, t);
2599
+ return i != null && await this.#T(i) != null;
2419
2600
  }
2420
2601
  async setWaitNotification(e, t) {
2421
- let n = this.$.revision.value, r = n == null ? void 0 : Pe(n, e, t, this.#i());
2422
- return r != null && await this.#b(r) != null;
2602
+ let n = this.$.revision.value, r = n == null ? void 0 : Te(n, e, t, this.#i());
2603
+ return r != null && await this.#T(r) != null;
2423
2604
  }
2424
2605
  async saveComment(e, t) {
2425
2606
  let n = this.#l.value.target;
2426
2607
  if (n == null) return;
2427
- let r = this.#D().nodes.find((t) => t.id == e)?.position;
2428
- r != null && await this.#S((i) => R(i, n, e, {
2608
+ let r = this.#N().nodes.find((t) => t.id == e)?.position;
2609
+ r != null && await this.#O((i) => I(i, n, e, {
2429
2610
  ...t,
2430
2611
  position: r
2431
2612
  }));
@@ -2433,185 +2614,248 @@ var Vt = class {
2433
2614
  async saveTaskSettings(e, t) {
2434
2615
  let n = this.$.revision.value, r = this.#l.value.target;
2435
2616
  if (n == null || r == null) return !1;
2436
- let i = Ie(n, r, e, t);
2437
- return i != null && await this.#b(i) != null;
2617
+ let i = De(n, r, e, t);
2618
+ return i != null && await this.#T(i) != null;
2619
+ }
2620
+ async saveCodeActions(e, t) {
2621
+ let n = this.$.revision.value, r = this.#l.value.target;
2622
+ if (n == null || r == null) return !1;
2623
+ let i = be(n.revision.content, r, e, t);
2624
+ return i == null || await this.#T(i) != null;
2438
2625
  }
2439
2626
  async saveCodeTaskPorts(e, t) {
2440
2627
  let n = this.$.revision.value, r = this.#l.value.target;
2441
2628
  if (n == null || r == null) return !1;
2442
- let i = fe(n, r, e, t);
2443
- return i != null && await this.#b(i) != null;
2629
+ let i = re(n, r, e, t);
2630
+ return i != null && await this.#T(i) != null;
2444
2631
  }
2445
2632
  async saveTaskAdditionalInputs(e, t) {
2446
2633
  let n = this.$.revision.value, r = this.#l.value.target;
2447
2634
  if (n == null || r == null) return !1;
2448
- let i = ze(n, r, e, t);
2449
- return i != null && await this.#b(i) != null;
2635
+ let i = Ae(n, r, e, t);
2636
+ return i != null && await this.#T(i) != null;
2450
2637
  }
2451
2638
  async setConnectorConnection(e, t) {
2452
2639
  let n = this.$.revision.value;
2453
2640
  if (n == null) return !1;
2454
- let r = te(n.revision.content, e, t);
2455
- return r != null && await this.#b(r) != null;
2456
- }
2457
- async saveTriggerSettings(e, t) {
2458
- let n = this.$.revision.value, r = this.#l.value.target;
2459
- if (n == null || r?.kind != "flow") return !1;
2460
- let i = re(n.revision.content, r, e, t);
2461
- return i != null && await this.#b(i) != null;
2641
+ let r = g(n.revision.content, e, t);
2642
+ return r != null && await this.#T(r) != null;
2462
2643
  }
2463
2644
  async saveTriggerConfig(e, t, n) {
2464
2645
  let r = this.$.revision.value, i = this.#l.value.target;
2465
2646
  if (r == null || i?.kind != "flow") return !1;
2466
- let a = ae(r.revision.content, i, e, t, n);
2467
- return a != null && await this.#b(a) != null;
2647
+ let a = k(r.revision.content, i, e, t, n);
2648
+ return a != null && await this.#T(a) != null;
2468
2649
  }
2469
2650
  async saveTriggerSchedule(e, t) {
2470
2651
  let n = this.$.revision.value, r = this.#l.value.target;
2471
2652
  if (n == null || r?.kind != "flow") return !1;
2472
- let i = N(n.revision.content, r, e, t);
2473
- return i != null && await this.#b(i) != null;
2653
+ let i = S(n.revision.content, r, e, t);
2654
+ return i != null && await this.#T(i) != null;
2474
2655
  }
2475
2656
  async saveWebhook(e, t) {
2476
2657
  let n = this.$.revision.value, r = this.#l.value.target;
2477
2658
  if (n == null || r?.kind != "flow") return !1;
2478
- let i = P(n, r, e, t);
2479
- return i != null && await this.#b(i) != null;
2659
+ let i = w(n, r, e, t);
2660
+ return i != null && await this.#T(i) != null;
2480
2661
  }
2481
2662
  async setTriggerConnection(e, t) {
2482
2663
  let n = this.$.revision.value, r = this.#l.value.target;
2483
2664
  if (n == null || r?.kind != "flow") return !1;
2484
- let i = ie(n.revision.content, r, e, t);
2485
- return i != null && await this.#b(i) != null;
2665
+ let i = O(n.revision.content, r, e, t);
2666
+ return i != null && await this.#T(i) != null;
2486
2667
  }
2487
2668
  async saveSubflowSettings(e, t) {
2488
2669
  let n = this.$.revision.value;
2489
2670
  if (n == null) return !1;
2490
- let r = oe(n, e, t);
2491
- return r != null && await this.#b(r) != null;
2671
+ let r = A(n, e, t);
2672
+ return r != null && await this.#T(r) != null;
2492
2673
  }
2493
2674
  updateModuleSource(e) {
2494
2675
  let t = this.#l.value.moduleEditor;
2495
- t != null && t.source != e && this.#N({ moduleEditor: {
2496
- ...t,
2497
- phase: void 0,
2498
- source: e
2499
- } });
2676
+ if (t == null || t.source == e) return;
2677
+ let n = this.#u.get(t.moduleId)?.base ?? this.#l.value.draft?.content.modules[t.moduleId];
2678
+ n != null && (this.#u.set(t.moduleId, {
2679
+ base: n,
2680
+ editor: {
2681
+ ...t,
2682
+ phase: void 0,
2683
+ source: e
2684
+ }
2685
+ }), this.#R({}), clearTimeout(this.#d), this.#d = setTimeout(() => void this.#S(), 800));
2500
2686
  }
2501
2687
  discardModuleChanges() {
2502
2688
  let e = this.#l.value.moduleEditor;
2503
- if (e == null) return;
2689
+ if (e == null || this.#f != null) return;
2690
+ this.#u.delete(e.moduleId);
2504
2691
  let t = this.#l.value.draft?.content.modules[e.moduleId];
2505
- if (t == null) {
2506
- this.#N({ moduleEditor: void 0 });
2507
- return;
2508
- }
2509
- this.#N({ moduleEditor: {
2692
+ this.#R({ moduleEditor: t == null ? void 0 : {
2510
2693
  moduleId: e.moduleId,
2511
2694
  source: t.source
2512
2695
  } });
2513
2696
  }
2697
+ get hasUnsavedCode() {
2698
+ return this.#u.size > 0;
2699
+ }
2514
2700
  async saveModuleEditor() {
2515
- let e = this.#l.value.moduleEditor;
2516
- if (e == null || e.phase == "saving") return !1;
2517
- this.#N({ moduleEditor: {
2518
- ...e,
2519
- phase: "saving"
2520
- } });
2521
- let t = await ct(e.source);
2522
- if (this.#m) return !1;
2523
- let n = this.#l.value.draft?.content.modules[e.moduleId];
2524
- if (n == null) return !1;
2525
- let r = await this.#b(lt(e.moduleId, n.source, n.imports, e.source, t));
2526
- return !this.#m && this.#l.value.moduleEditor?.moduleId == e.moduleId && this.#N({ moduleEditor: {
2527
- ...this.#l.value.moduleEditor,
2528
- phase: r == null ? "failed" : void 0
2529
- } }), r != null;
2701
+ if (this.#_) return !1;
2702
+ for (let e of this.#u.values()) e.editor.phase == "failed" && (e.editor = {
2703
+ ...e.editor,
2704
+ phase: void 0
2705
+ });
2706
+ return this.#R({}), await this.#S();
2707
+ }
2708
+ #S() {
2709
+ if (clearTimeout(this.#d), this.#f != null) return this.#f;
2710
+ if (this.#_) return Promise.resolve(!1);
2711
+ if (![...this.#u.values()].some((e) => e.editor.phase != "failed")) return Promise.resolve(this.#u.size == 0);
2712
+ let e = this.#n.capture();
2713
+ return this.#f = this.#C(e).finally(() => {
2714
+ this.#f = void 0;
2715
+ }), this.#f;
2716
+ }
2717
+ async #C(e) {
2718
+ for (; !this.#_ && e();) {
2719
+ let t = [...this.#u.entries()].find(([, e]) => e.editor.phase != "failed");
2720
+ if (t == null) return this.#u.size == 0;
2721
+ let [n, r] = t, i = r.editor.source;
2722
+ r.editor = {
2723
+ ...r.editor,
2724
+ phase: "saving"
2725
+ }, this.#R({});
2726
+ try {
2727
+ let t = await Tt(i);
2728
+ if (this.#_ || !e()) return !1;
2729
+ let a = this.#l.value.draft?.content.modules[n];
2730
+ if (a == null || a.source != r.base.source || JSON.stringify(a.imports) != JSON.stringify(r.base.imports)) throw Error(this.#r.t("notice.moduleUpdated"));
2731
+ let o = i == a.source && JSON.stringify(t) == JSON.stringify(a.imports) ? this.#l.value.draft : await this.#T(Et(n, r.base.source, r.base.imports, i, t), !1);
2732
+ if (this.#_ || !e()) return !1;
2733
+ let s = this.#u.get(n);
2734
+ if (s == null) continue;
2735
+ o == null ? s.editor = {
2736
+ ...s.editor,
2737
+ phase: "failed"
2738
+ } : s.editor.source == i ? (this.#u.delete(n), this.#l.value.moduleEditor?.moduleId == n && this.#R({ moduleEditor: {
2739
+ moduleId: n,
2740
+ source: i
2741
+ } })) : (s.base = {
2742
+ ...r.base,
2743
+ source: i,
2744
+ imports: t
2745
+ }, s.editor = {
2746
+ ...s.editor,
2747
+ phase: void 0
2748
+ });
2749
+ } catch (t) {
2750
+ if (this.#_ || !e()) return !1;
2751
+ let r = this.#u.get(n);
2752
+ r != null && (r.editor = {
2753
+ ...r.editor,
2754
+ phase: "failed"
2755
+ }), this.#c(E(t, this.#r.t));
2756
+ }
2757
+ this.#R({});
2758
+ }
2759
+ return !1;
2530
2760
  }
2531
2761
  async moveNodes(e) {
2532
2762
  let t = this.#l.value.target;
2533
- t != null && await this.#S((n) => A(n, t, e));
2763
+ t != null && await this.#O((n) => y(n, t, e));
2534
2764
  }
2535
- async moveViewport(e, t = "detail") {
2536
- let n = this.#l.value.target;
2537
- n != null && await this.#S((r) => k(r, n, e, t));
2765
+ async moveViewport(e) {
2766
+ let t = this.#l.value.target;
2767
+ t != null && await this.#O((n) => v(n, t, e));
2538
2768
  }
2539
2769
  async check() {
2540
- await this.#C();
2770
+ await this.#k();
2541
2771
  }
2542
2772
  async refreshFlows() {
2543
2773
  await this.reloadFlows();
2544
2774
  }
2545
2775
  updateLive(e) {
2546
- e.flowId == this.#l.value.flowId && this.#N({ live: e });
2776
+ e.flowId == this.#l.value.flowId && this.#R({ live: e });
2547
2777
  }
2548
2778
  locateNode(e) {
2549
2779
  let t = this.$.revision.value, n = this.#l.value.target;
2550
- return t == null || n == null || t.node(n, e) == null || !this.selectNodes([e]) ? !1 : (this.#N({ nodeFocus: {
2780
+ return t == null || n == null || t.node(n, e) == null || !this.selectNodes([e]) ? !1 : (this.#R({ nodeFocus: {
2551
2781
  nodeId: e,
2552
- requestId: ++this.#g
2782
+ requestId: ++this.#y
2553
2783
  } }), !0);
2554
2784
  }
2555
2785
  locateDiagnostic(e) {
2556
- return e.location == null || !this.selectNodes([e.location.nodeId]) ? !1 : (this.#N({ diagnosticFocus: {
2786
+ return e.location == null || !this.selectNodes([e.location.nodeId]) ? !1 : (this.#R({ diagnosticFocus: {
2557
2787
  ...e.location,
2558
2788
  diagnostic: e.diagnostic,
2559
- requestId: ++this.#d
2789
+ requestId: ++this.#m
2560
2790
  } }), !0);
2561
2791
  }
2562
- async #y(e, t, n) {
2563
- let r = Math.max(0, ...this.#D().nodes.flatMap((e) => {
2792
+ async #w(e, t, n) {
2793
+ let r = Math.max(0, ...this.#N().nodes.flatMap((e) => {
2564
2794
  if (e.kind != "comment") return [];
2565
2795
  let t = /#(\d+)$/.exec(e.title);
2566
2796
  return t == null ? [] : [Number(t[1])];
2567
- })), i = this.#S((i) => R(i, e, t, {
2797
+ })), i = this.#O((i) => I(i, e, t, {
2568
2798
  content: "",
2569
2799
  position: n,
2570
2800
  title: this.#r.t("addNode.commentName", { number: r + 1 })
2571
2801
  }));
2572
- if (this.selectNodes([t]), await i, !this.#m) return t;
2802
+ if (this.selectNodes([t]), await i, !this.#_) return t;
2573
2803
  }
2574
- async #b(e, t = !0) {
2804
+ async #T(e, t = !0) {
2575
2805
  let n = this.#l.value.flowId, r = this.#l.value.draft;
2576
2806
  if (n != null && r != null) return e.length == 0 ? r : await this.#t.change({
2577
2807
  current: this.#n.capture(),
2578
2808
  flowId: n
2579
2809
  }, r, e, t);
2580
2810
  }
2581
- #x(e, t = !1) {
2582
- let n = this.#l.value.draft, { revision: r, selectedNodeIds: i, target: a } = this.#k(e), o = this.#l.value.moduleEditor;
2583
- return this.#N({
2811
+ async #E(e) {
2812
+ for (let t = 0; t < 2 && e(); t += 1) {
2813
+ let t = this.#l.value.draft;
2814
+ if (t == null) return;
2815
+ let n = _(t.content);
2816
+ if (n.length == 0) {
2817
+ this.#k();
2818
+ return;
2819
+ }
2820
+ if (await this.#T(n, !1) != null || !e()) return;
2821
+ if (this.#l.value.draft?.revisionId == t.revisionId) break;
2822
+ }
2823
+ e() && this.#k();
2824
+ }
2825
+ #D(e, t = !1) {
2826
+ let n = this.#l.value.draft, { revision: r, selectedNodeIds: i, target: a } = this.#P(e), o = this.#l.value.moduleEditor;
2827
+ return this.#R({
2584
2828
  diagnostics: t ? this.#l.value.diagnostics : void 0,
2585
2829
  draft: e,
2586
- moduleEditor: o != null && n != null && Q(n, o) != "saved" ? o : $(r, a, i),
2830
+ moduleEditor: o != null && n != null && $(n, o) != "saved" ? o : rn(r, a, i),
2587
2831
  selectedNodeIds: i,
2588
2832
  target: a
2589
2833
  }), r;
2590
2834
  }
2591
- async #S(e) {
2592
- if (this.#m) return;
2835
+ async #O(e) {
2836
+ if (this.#_) return;
2593
2837
  let t = this.#l.value.flowId, n = this.#l.value.presentation;
2594
- t != null && n != null && await this.#a.change(t, n, this.#o.capture(), e);
2838
+ t != null && n != null && await this.#a.change(t, n, this.#n.capture(), e);
2595
2839
  }
2596
- async #C() {
2597
- if (this.#m) return;
2840
+ async #k() {
2841
+ if (this.#_) return;
2598
2842
  let e = this.#l.value.flowId, t = this.#l.value.draft, n = this.#l.value.target;
2599
2843
  if (e == null || t == null || n == null) {
2600
- n ?? this.#N({
2844
+ n ?? this.#R({
2601
2845
  checkLoading: !1,
2602
2846
  diagnostics: void 0
2603
2847
  });
2604
2848
  return;
2605
2849
  }
2606
- this.#N({
2850
+ this.#R({
2607
2851
  checkLoading: !0,
2608
2852
  diagnosticFocus: void 0
2609
2853
  });
2610
2854
  try {
2611
2855
  let n = await this.#e.checkFlow(e, t.revisionId);
2612
- if (!this.#m && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId) {
2856
+ if (!this.#_ && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId) {
2613
2857
  let e = this.#l.value.live;
2614
- this.#N({
2858
+ this.#R({
2615
2859
  diagnostics: n,
2616
2860
  live: e == null ? void 0 : {
2617
2861
  ...e,
@@ -2620,16 +2864,16 @@ var Vt = class {
2620
2864
  });
2621
2865
  }
2622
2866
  } catch (n) {
2623
- !this.#m && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId && this.#c(D(n, this.#r.t));
2867
+ !this.#_ && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId && this.#c(E(n, this.#r.t));
2624
2868
  } finally {
2625
- !this.#m && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId && this.#N({ checkLoading: !1 });
2869
+ !this.#_ && e == this.#l.value.flowId && t.revisionId == this.#l.value.draft?.revisionId && this.#R({ checkLoading: !1 });
2626
2870
  }
2627
2871
  }
2628
- async #w(e) {
2629
- if (this.#m) return;
2872
+ async #A(e) {
2873
+ if (this.#_) return;
2630
2874
  let t = this.#l.value.flowId;
2631
- if (t == null || (this.#f += 1, e != null && (this.#p = !0), this.#h)) return;
2632
- this.#h = !0;
2875
+ if (t == null || (this.#h += 1, e != null && (this.#g = !0), this.#v)) return;
2876
+ this.#v = !0;
2633
2877
  let n = {
2634
2878
  current: this.#n.capture(),
2635
2879
  flowId: t
@@ -2637,84 +2881,83 @@ var Vt = class {
2637
2881
  await this.#t.enqueue(async () => {
2638
2882
  let e;
2639
2883
  do {
2640
- e = this.#f;
2641
- let t = this.#p;
2642
- this.#p = !1, await this.#T(n, !1, t);
2643
- } while (this.#M(n) && e != this.#f);
2644
- }), this.#M(n) && (this.#h = !1);
2884
+ e = this.#h;
2885
+ let t = this.#g;
2886
+ this.#g = !1, await this.#j(n, !1, t);
2887
+ } while (this.#L(n) && e != this.#h);
2888
+ }), this.#L(n) && (this.#v = !1);
2645
2889
  }
2646
- async #T(e, t, n = !1) {
2890
+ async #j(e, t, n = !1) {
2647
2891
  try {
2648
2892
  let t = this.#t.committed;
2649
2893
  if (t == null) return !1;
2650
2894
  let r = await this.#e.syncDraft(e.flowId);
2651
- if (!this.#M(e)) return !1;
2895
+ if (!this.#L(e)) return !1;
2652
2896
  let i = r.draft;
2653
2897
  if (i.revisionId == t.revisionId) return !0;
2654
- let a = this.#A(i, !1);
2655
- return this.#E(e.flowId, i.revisionId), n && (this.#c({
2898
+ let a = this.#F(i, !1);
2899
+ return this.#M(e.flowId, i.revisionId), n && this.#c({
2656
2900
  kind: a ? "error" : "success",
2657
2901
  message: this.#r.t(a ? "notice.moduleUpdated" : "notice.draftUpdated")
2658
- }), this.#C()), !0;
2902
+ }), this.#k(), !0;
2659
2903
  } catch (n) {
2660
- return t && this.#M(e) && this.#c(D(n, this.#r.t)), !1;
2904
+ return t && this.#L(e) && this.#c(E(n, this.#r.t)), !1;
2661
2905
  }
2662
2906
  }
2663
- #E(e, t) {
2907
+ #M(e, t) {
2664
2908
  this.#o.advanceHead(e, t);
2665
2909
  }
2666
- #D() {
2910
+ #N() {
2667
2911
  let e = this.#l.value;
2668
- return j(e.draft, e.target, e.presentation?.value, e.diagnostics?.diagnostics, {}, {}, this.#r.t);
2912
+ return b(e.draft, e.target, e.presentation?.value, e.diagnostics?.diagnostics, {}, {}, this.#r.t);
2669
2913
  }
2670
- #O() {
2671
- let e = this.#l.value.moduleEditor;
2672
- return e == null || Q(this.#l.value.draft, e) == "saved" || (this.#c({
2673
- kind: "error",
2674
- message: this.#r.t("notice.unsavedCode")
2675
- }), !1);
2676
- }
2677
- #k(e) {
2678
- let t = I(e), n = zt(t, this.#l.value.target);
2914
+ #P(e) {
2915
+ let t = C(e), n = sn(t, this.#l.value.target);
2679
2916
  return {
2680
2917
  revision: t,
2681
2918
  selectedNodeIds: this.#l.value.selectedNodeIds.filter((e) => n != null && t.selection(n, e) != null),
2682
2919
  target: n
2683
2920
  };
2684
2921
  }
2685
- #A(e, t) {
2686
- let n = this.#t.replaceCommitted(e), r = this.#l.value.moduleEditor, i = r != null && Q(this.#l.value.draft, r) != "saved", a = this.#k(n), o = a.target;
2687
- return this.#N({
2922
+ #F(e, t) {
2923
+ let n = this.#t.replaceCommitted(e), r = this.#l.value.moduleEditor, i = r != null && $(this.#l.value.draft, r) != "saved", a = this.#P(n), o = a.target;
2924
+ return this.#R({
2688
2925
  diagnostics: t ? this.#l.value.diagnostics : void 0,
2689
2926
  draft: n,
2690
- moduleEditor: this.#j(a.revision, o, a.selectedNodeIds),
2927
+ moduleEditor: this.#I(a.revision, o, a.selectedNodeIds),
2691
2928
  selectedNodeIds: a.selectedNodeIds,
2692
2929
  target: o
2693
2930
  }), i;
2694
2931
  }
2695
- #j(e, t, n) {
2932
+ #I(e, t, n) {
2696
2933
  let r = this.#l.value.moduleEditor;
2697
- return r == null || Q(this.#l.value.draft, r) == "saved" ? $(e, t, n) : {
2934
+ return r == null || $(this.#l.value.draft, r) == "saved" ? rn(e, t, n) : {
2698
2935
  ...r,
2699
2936
  phase: "failed"
2700
2937
  };
2701
2938
  }
2702
- #M(e) {
2703
- return !this.#m && e.flowId == this.#l.value.flowId && e.current();
2939
+ #L(e) {
2940
+ return !this.#_ && e.flowId == this.#l.value.flowId && e.current();
2704
2941
  }
2705
- #N(e) {
2706
- this.#m || this.#l.set(e);
2942
+ #R(e) {
2943
+ if (this.#_) return;
2944
+ let t = Object.hasOwn(e, "moduleEditor") ? e.moduleEditor : this.#l.value.moduleEditor, n = t == null ? void 0 : this.#u.get(t.moduleId)?.editor ?? t, r = [...this.#u.values()].some((e) => e.editor.phase == "failed") ? "failed" : this.#u.size > 0 ? "saving" : void 0;
2945
+ this.#l.set({
2946
+ ...e,
2947
+ moduleEditor: n,
2948
+ moduleSaveStatus: r
2949
+ });
2707
2950
  }
2708
2951
  };
2709
2952
  //#endregion
2710
2953
  //#region src/workbench/browser/runtime/stores/workbenchStore.ts
2711
- function Ht(e) {
2954
+ function ln(e) {
2712
2955
  return new Map(e.nodes.map((e) => [e.id, e]));
2713
2956
  }
2714
- function Ut(e, t) {
2715
- return e == null || t == null ? [] : I(e).designerInputs(t);
2957
+ function un(e, t) {
2958
+ return e == null || t == null ? [] : C(e).designerInputs(t);
2716
2959
  }
2717
- function Wt(e, t, n, r, i) {
2960
+ function dn(e, t, n, r, i) {
2718
2961
  if (e == null || t?.kind != "flow" || n?.revisionId != e.revisionId || n.flowId != e.flowId) return /* @__PURE__ */ new Map();
2719
2962
  let a = r.find((t) => t.kind == "run.started" && t.payload.flowId == e.flowId)?.payload.scopeId;
2720
2963
  return typeof a == "string" ? new Map(r.flatMap((t) => {
@@ -2722,7 +2965,7 @@ function Wt(e, t, n, r, i) {
2722
2965
  return t.payload.scopeId == a && t.payload.flowId == e.flowId && typeof n == "string" && i.has(n) ? [[t.sequence, n]] : [];
2723
2966
  })) : /* @__PURE__ */ new Map();
2724
2967
  }
2725
- var Gt = { openExternalPage: async () => !1 }, Kt = class {
2968
+ var fn = { openExternalPage: async () => !1 }, pn = class {
2726
2969
  #e;
2727
2970
  #t;
2728
2971
  #n;
@@ -2733,16 +2976,22 @@ var Gt = { openExternalPage: async () => !1 }, Kt = class {
2733
2976
  #s;
2734
2977
  #c;
2735
2978
  #l;
2736
- constructor(r, i, a = () => crypto.randomUUID(), o = L(), s = Gt, c = !0) {
2737
- this.#t = new F(), this.#r = t(), this.#a = t([]), this.#o = t(!1), this.#s = t(!1), this.#c = new F(), this.#l = !1, this.provideAddNodeOptions = async (e, t) => await this.#u([this.triggers.provideAddNodeOptions(e, t), this.connectors.provideAddNodeOptions(e, t)], t), this.browseAddNodeOptions = async (e) => await this.#u([this.triggers.browseAddNodeOptions(e), this.connectors.browseAddNodeOptions(e)], e), this.provideAddNodeOptionChoices = async (e, t) => {
2979
+ #u;
2980
+ constructor(r, i, a = F, o = P(), s = fn, c = !0) {
2981
+ this.#t = new m(), this.#r = t(), this.#a = t([]), this.#o = t(!1), this.#s = t(!1), this.#c = !0, this.#u = !1, this.provideAddNodeOptions = async (e, t) => await this.#d([this.triggers.provideAddNodeOptions(e, t), this.connectors.provideAddNodeOptions(e, t)], t), this.browseAddNodeOptions = async (e) => {
2982
+ let t = await Promise.all([this.triggers.browseAddNodeOptions(e), this.connectors.browseAddNodeOptions(e)]);
2983
+ if (!(e.aborted || this.#u)) return t.flatMap((e) => e ?? []);
2984
+ }, this.provideAddNodeOptionChoices = async (e, t) => {
2738
2985
  if (!e.startsWith("trigger:")) return await this.connectors.provideAddNodeOptionChoices(e, t);
2739
2986
  }, this.#e = r, this.#n = o, this.#i = c;
2740
2987
  let l = (e) => {
2741
- this.#l || this.#r.set(e);
2988
+ this.#u || this.#r.set(e);
2742
2989
  };
2743
- this.runs = new Be(r, l, o), this.workspace = new Vt(r, l, ut, o, (e) => {
2744
- e.kind == "run.created" ? this.#d(r, e) : this.runs.changed(e.runId);
2745
- }), this.connectors = new Et(r, this.workspace, l, s, o), this.triggers = new At(r, this.workspace, l, s, o), this.publications = new mt(r, this.workspace, l, i, a, o), this.runRequests = new yt(r, this.runs, l, o, a);
2990
+ this.runs = new h(r, l, o), this.workspace = new cn(r, l, Dt, o, (e) => {
2991
+ e.kind == "run.created" ? this.#f(r, e) : this.runs.changed(e.runId);
2992
+ }), this.connectors = new Ut(r, this.workspace, l, s, o), this.triggers = new Jt(r, this.workspace, l, s, o), this.publications = new jt(r, this.workspace, l, i, a, o), this.runRequests = new It(r, this.runs, l, async (e) => {
2993
+ if (!(e != this.workspace.$.flowId.value || !await this.workspace.saveModuleEditor() || this.#u || e != this.workspace.$.flowId.value)) return this.workspace.$.draft.value?.revisionId;
2994
+ }, o, a);
2746
2995
  let u = n((e) => {
2747
2996
  let t = e(this.workspace.$.diagnostics);
2748
2997
  if (t == null) return;
@@ -2756,8 +3005,8 @@ var Gt = { openExternalPage: async () => !1 }, Kt = class {
2756
3005
  let t = e(this.workspace.$.draft);
2757
3006
  f != t?.flowId && (d.clear(), f = t?.flowId);
2758
3007
  let n = e(this.workspace.$.target), r = e(this.workspace.$.presentation)?.value, i = e(u)?.diagnostics ?? e(this.connectors.$.diagnostics), a = e(this.connectors.$.actions), s = e(this.connectors.$.catalogs), c = e(o.t$), l = e(this.runs.$.run), p = e(this.runs.$.events), m = e(this.#a), h = e(this.#o), g = e(this.#s), _ = n == null ? "" : n.kind == "flow" ? "flow" : `subflow:${n.id}`, v = [
2759
- ...Ut(t, n),
2760
- r == null || n == null ? void 0 : M(r, n),
3008
+ ...un(t, n),
3009
+ r == null || n == null ? void 0 : x(r, n),
2761
3010
  i,
2762
3011
  a,
2763
3012
  s,
@@ -2770,12 +3019,12 @@ var Gt = { openExternalPage: async () => !1 }, Kt = class {
2770
3019
  ...l == null ? [] : [t?.revisionId]
2771
3020
  ], y = d.get(_);
2772
3021
  if (y != null && y.inputs.length == v.length && y.inputs.every((e, t) => e === v[t])) return y.graph;
2773
- let b = j(t, n, r, i, a, s, c, l, p, m, h, g, this.#i);
3022
+ let S = b(t, n, r, i, a, s, c, l, p, m, h, g, this.#i);
2774
3023
  return d.set(_, {
2775
- graph: b,
3024
+ graph: S,
2776
3025
  inputs: v
2777
- }), b;
2778
- }), m = e(p, Ht);
3026
+ }), S;
3027
+ }), g = e(p, ln);
2779
3028
  this.$ = {
2780
3029
  busy: n((e) => {
2781
3030
  let t = e(this.workspace.$.busy);
@@ -2786,15 +3035,15 @@ var Gt = { openExternalPage: async () => !1 }, Kt = class {
2786
3035
  if (e(this.publications.$.rollingBackPublicationId) != null) return "rollback";
2787
3036
  if (e(this.publications.$.changingTriggerId) != null) return "trigger";
2788
3037
  }),
2789
- diagnosticItems: n((e) => E(e(this.workspace.$.revision), e(this.workspace.$.target), e(u))),
3038
+ diagnosticItems: n((e) => D(e(this.workspace.$.revision), e(this.workspace.$.target), e(u))),
2790
3039
  diagnostics: u,
2791
3040
  designer: p,
2792
- designerNodeById: m,
3041
+ designerNodeById: g,
2793
3042
  notice: this.#r,
2794
- runEventNodes: n((e) => Wt(e(this.workspace.$.draft), e(this.workspace.$.target), e(this.runs.$.run), e(this.runs.$.events), e(m))),
3043
+ runEventNodes: n((e) => dn(e(this.workspace.$.draft), e(this.workspace.$.target), e(this.runs.$.run), e(this.runs.$.events), e(g))),
2795
3044
  selectedDesignerNode: n((e) => {
2796
3045
  let t = e(this.workspace.$.selectedNodeIds);
2797
- return t.length == 1 ? e(m).get(t[0]) : void 0;
3046
+ return t.length == 1 ? e(g).get(t[0]) : void 0;
2798
3047
  }),
2799
3048
  variableNames: this.#a,
2800
3049
  variableNamesLoaded: this.#o,
@@ -2802,7 +3051,7 @@ var Gt = { openExternalPage: async () => !1 }, Kt = class {
2802
3051
  };
2803
3052
  }
2804
3053
  dispose() {
2805
- this.#l = !0, this.#t.invalidate(), this.#c.invalidate();
3054
+ this.#u = !0, this.#t.invalidate();
2806
3055
  for (let e of Object.values(this.$)) e.dispose();
2807
3056
  this.connectors.dispose(), this.publications.dispose(), this.runRequests.dispose(), this.runs.dispose(), this.triggers.dispose(), this.workspace.dispose(), this.#a.dispose(), this.#o.dispose(), this.#s.dispose();
2808
3057
  }
@@ -2813,28 +3062,33 @@ var Gt = { openExternalPage: async () => !1 }, Kt = class {
2813
3062
  await this.workspace.reloadFlows();
2814
3063
  }
2815
3064
  dismissNotice() {
2816
- this.#l || this.#r.set(void 0);
3065
+ this.#u || this.#r.set(void 0);
3066
+ }
3067
+ invalidateVariableNames() {
3068
+ this.#c = !0;
2817
3069
  }
2818
3070
  async refreshVariableNames() {
2819
- if (this.#l || !this.#i) return;
2820
- let e = this.#c.begin();
2821
- this.#s.set(!0);
2822
- try {
2823
- let { variables: t } = await this.#e.listVariables();
2824
- if (!e() || this.#l) return;
2825
- this.#a.set(t.map((e) => e.name)), this.#o.set(!0);
2826
- } catch (t) {
2827
- e() && !this.#l && this.#r.set(D(t, this.#n.t));
2828
- } finally {
2829
- e() && !this.#l && this.#s.set(!1);
3071
+ if (!(this.#u || !this.#i)) {
3072
+ if (this.#l != null) return this.#l;
3073
+ if (this.#c) return this.#c = !1, this.#s.set(!0), this.#l = (async () => {
3074
+ try {
3075
+ let { variables: e } = await this.#e.listVariables();
3076
+ if (this.#u) return;
3077
+ this.#a.set(e.map((e) => e.name)), this.#o.set(!0);
3078
+ } catch (e) {
3079
+ this.#c = !0, this.#u || this.#r.set(E(e, this.#n.t));
3080
+ } finally {
3081
+ this.#l = void 0, this.#u || this.#s.set(!1);
3082
+ }
3083
+ })(), this.#l;
2830
3084
  }
2831
3085
  }
2832
3086
  async selectFlow(e) {
2833
- return this.#l || (this.#t.invalidate(), this.#r.set(void 0), !await this.workspace.selectFlow(e)) ? !1 : (this.connectors.reset(), this.triggers.reset(), this.publications.reset(), this.runRequests.reset(), this.runs.reset(), !0);
3087
+ return this.#u || (this.#t.invalidate(), this.#r.set(void 0), !await this.workspace.selectFlow(e)) ? !1 : (this.connectors.reset(), this.triggers.reset(), this.publications.reset(), this.runRequests.reset(), this.runs.reset(), !0);
2834
3088
  }
2835
3089
  async createFlow(e, t) {
2836
3090
  let n = await this.workspace.createFlow(e, t);
2837
- return this.#l || n == null ? !1 : (await this.selectFlow(n.flowId), this.#l || this.#r.set({
3091
+ return this.#u || n == null ? !1 : (await this.selectFlow(n.flowId), this.#u || this.#r.set({
2838
3092
  kind: "success",
2839
3093
  message: this.#n.t("notice.created", { name: n.name })
2840
3094
  }), !0);
@@ -2862,43 +3116,45 @@ var Gt = { openExternalPage: async () => !1 }, Kt = class {
2862
3116
  let r = await this.workspace.addNode(e, t, n);
2863
3117
  return r != null && e.kind == "connector" && this.connectors.refresh(), r != null && e.kind == "trigger" && this.triggers.refresh(), r;
2864
3118
  }
2865
- async #u(e, t) {
3119
+ async #d(e, t) {
2866
3120
  let n = await Promise.allSettled(e);
2867
- if (t.aborted || this.#l) return;
3121
+ if (t.aborted || this.#u) return;
2868
3122
  let r = n.filter((e) => e.status == "rejected");
2869
3123
  if (r.length > 0 && r.length == n.length) throw r[0].reason;
2870
- return r.length > 0 && this.#r.set(D(r[0].reason, this.#n.t)), n.flatMap((e) => e.status == "fulfilled" ? e.value ?? [] : []);
3124
+ return r.length > 0 && this.#r.set(E(r[0].reason, this.#n.t)), n.flatMap((e) => e.status == "fulfilled" ? e.value ?? [] : []);
2871
3125
  }
2872
3126
  async refreshSelectedConnector(e = !1) {
2873
3127
  await this.connectors.refresh(e);
2874
3128
  }
2875
- async requestDraftRun() {
2876
- let e = this.workspace.$.targetFlow.value, t = this.workspace.$.draft.value;
2877
- return e == null || t == null ? "unavailable" : await this.runRequests.requestDraft(e, t);
3129
+ async requestDraftRun(e) {
3130
+ let t = this.workspace.$.flowId.value;
3131
+ if (!await this.workspace.saveModuleEditor() || this.#u || t != this.workspace.$.flowId.value) return "unavailable";
3132
+ let n = this.workspace.$.targetFlow.value, r = this.workspace.$.draft.value;
3133
+ return n == null || r == null ? "unavailable" : await this.runRequests.requestDraft(n, r, e);
2878
3134
  }
2879
3135
  async requestLiveRun() {
2880
3136
  let e = this.workspace.$.targetFlow.value;
2881
3137
  return e == null ? "unavailable" : await this.runRequests.requestLive(e);
2882
3138
  }
2883
- async #d(e, t) {
3139
+ async #f(e, t) {
2884
3140
  let n = this.workspace.$.target.value;
2885
- if (this.#l || this.runRequests.$.submitting.value != null || n?.kind != "flow" || this.workspace.$.flowId.value != t.flowId) return;
3141
+ if (this.#u || this.runRequests.$.submitting.value != null || n?.kind != "flow" || this.workspace.$.flowId.value != t.flowId) return;
2886
3142
  let r = this.#t.begin();
2887
3143
  try {
2888
3144
  let n = await e.getRun(t.runId), i = this.workspace.$.target.value;
2889
- if (!r() || this.#l || i?.kind != "flow" || this.workspace.$.flowId.value != t.flowId || n.flowId != t.flowId || n.runId != t.runId) return;
3145
+ if (!r() || this.#u || i?.kind != "flow" || this.workspace.$.flowId.value != t.flowId || n.flowId != t.flowId || n.runId != t.runId) return;
2890
3146
  this.runs.followExternal(n);
2891
3147
  } catch {
2892
3148
  return;
2893
3149
  }
2894
3150
  }
2895
- }, qt = H(() => import("./flowWorkspace-Dr8-Hut9.js").then((e) => e.t));
2896
- function Jt({ action: e, description: t, error: n, onSubmit: r, onTokenChange: i, pending: a = !1, title: o, token: s, tokenLabel: u }) {
2897
- let m = s != null && u != null && i != null, h = s ?? "", _ = /* @__PURE__ */ K(qe, { children: [
2898
- /* @__PURE__ */ G("div", {
3151
+ }, mn = ot(() => import("./flowWorkspace-BLGcgnHj.js").then((e) => e.t));
3152
+ function hn({ action: e, description: t, error: n, onSubmit: r, onTokenChange: i, pending: a = !1, title: o, token: s, tokenLabel: c }) {
3153
+ let l = s != null && c != null && i != null, u = s ?? "", d = /* @__PURE__ */ J(st, { children: [
3154
+ /* @__PURE__ */ q("div", {
2899
3155
  "aria-hidden": "true",
2900
3156
  className: "flex size-10 items-center justify-center rounded-lg bg-muted text-muted-foreground",
2901
- children: /* @__PURE__ */ K("svg", {
3157
+ children: /* @__PURE__ */ J("svg", {
2902
3158
  className: "size-5",
2903
3159
  fill: "none",
2904
3160
  stroke: "currentColor",
@@ -2906,40 +3162,40 @@ function Jt({ action: e, description: t, error: n, onSubmit: r, onTokenChange: i
2906
3162
  strokeLinejoin: "round",
2907
3163
  strokeWidth: "1.8",
2908
3164
  viewBox: "0 0 24 24",
2909
- children: [/* @__PURE__ */ G("rect", {
3165
+ children: [/* @__PURE__ */ q("rect", {
2910
3166
  height: "9",
2911
3167
  rx: "2",
2912
3168
  width: "14",
2913
3169
  x: "5",
2914
3170
  y: "11"
2915
- }), /* @__PURE__ */ G("path", { d: "M8 11V8a4 4 0 0 1 8 0v3" })]
3171
+ }), /* @__PURE__ */ q("path", { d: "M8 11V8a4 4 0 0 1 8 0v3" })]
2916
3172
  })
2917
3173
  }),
2918
- /* @__PURE__ */ K("header", {
3174
+ /* @__PURE__ */ J("header", {
2919
3175
  className: "flex flex-col gap-2",
2920
- children: [/* @__PURE__ */ G("h1", {
3176
+ children: [/* @__PURE__ */ q("h1", {
2921
3177
  className: "text-xl font-semibold tracking-tight text-balance",
2922
3178
  children: o
2923
- }), /* @__PURE__ */ G("p", {
3179
+ }), /* @__PURE__ */ q("p", {
2924
3180
  className: "text-sm/relaxed text-muted-foreground text-pretty",
2925
3181
  children: t
2926
3182
  })]
2927
3183
  }),
2928
- m && /* @__PURE__ */ G(f, { children: /* @__PURE__ */ K(d, {
3184
+ l && /* @__PURE__ */ q(Pe, { children: /* @__PURE__ */ J(Re, {
2929
3185
  "data-invalid": n != null,
2930
3186
  children: [
2931
- /* @__PURE__ */ G(p, {
3187
+ /* @__PURE__ */ q(Ve, {
2932
3188
  htmlFor: "session-token",
2933
- children: u
3189
+ children: c
2934
3190
  }),
2935
- /* @__PURE__ */ G(l, {
3191
+ /* @__PURE__ */ q(V, {
2936
3192
  autoComplete: "username",
2937
3193
  name: "username",
2938
3194
  type: "hidden",
2939
3195
  value: "open-flow",
2940
3196
  readOnly: !0
2941
3197
  }),
2942
- /* @__PURE__ */ G(l, {
3198
+ /* @__PURE__ */ q(V, {
2943
3199
  autoComplete: "current-password",
2944
3200
  "aria-invalid": n != null,
2945
3201
  autoFocus: !0,
@@ -2949,48 +3205,48 @@ function Jt({ action: e, description: t, error: n, onSubmit: r, onTokenChange: i
2949
3205
  onChange: (e) => i?.(e.target.value),
2950
3206
  spellCheck: !1,
2951
3207
  type: "password",
2952
- value: h
3208
+ value: u
2953
3209
  }),
2954
- n != null && /* @__PURE__ */ G(y, { children: n })
3210
+ n != null && /* @__PURE__ */ q(Fe, { children: n })
2955
3211
  ]
2956
3212
  }) }),
2957
- e != null && r != null && /* @__PURE__ */ K(c, {
2958
- disabled: a || m && h.length == 0,
3213
+ e != null && r != null && /* @__PURE__ */ J(B, {
3214
+ disabled: a || l && u.length == 0,
2959
3215
  size: "lg",
2960
3216
  type: "submit",
2961
- children: [a && /* @__PURE__ */ G(g, {
3217
+ children: [a && /* @__PURE__ */ q(Le, {
2962
3218
  "aria-label": e,
2963
3219
  "data-icon": "inline-start"
2964
3220
  }), e]
2965
3221
  }),
2966
- a && e == null && /* @__PURE__ */ G(g, { "aria-label": t })
2967
- ] }), v = "m-auto flex w-full max-w-[420px] flex-col gap-5 rounded-xl bg-card p-6 shadow-lg shadow-black/10";
2968
- return /* @__PURE__ */ G("main", {
3222
+ a && e == null && /* @__PURE__ */ q(Le, { "aria-label": t })
3223
+ ] }), f = "m-auto flex w-full max-w-[420px] flex-col gap-5 rounded-xl bg-card p-6 shadow-lg shadow-black/10";
3224
+ return /* @__PURE__ */ q("main", {
2969
3225
  className: "open-flow-workbench",
2970
- children: /* @__PURE__ */ G("div", {
3226
+ children: /* @__PURE__ */ q("div", {
2971
3227
  className: "grid h-full overflow-auto bg-muted/20 p-4",
2972
- children: r == null ? /* @__PURE__ */ G("section", {
3228
+ children: r == null ? /* @__PURE__ */ q("section", {
2973
3229
  "aria-busy": a,
2974
- className: v,
2975
- children: _
2976
- }) : /* @__PURE__ */ G("form", {
3230
+ className: f,
3231
+ children: d
3232
+ }) : /* @__PURE__ */ q("form", {
2977
3233
  "aria-busy": a,
2978
- className: v,
3234
+ className: f,
2979
3235
  onSubmit: r,
2980
- children: _
3236
+ children: d
2981
3237
  })
2982
3238
  })
2983
3239
  });
2984
3240
  }
2985
- function Yt({ host: e, store: t }) {
3241
+ function gn({ host: e, store: t }) {
2986
3242
  let n = a(t.$.notice);
2987
- return U(() => e.notify(n), [e, n]), U(() => () => e.notify(void 0), [e]), null;
3243
+ return W(() => e.notify(n), [e, n]), W(() => () => e.notify(void 0), [e]), null;
2988
3244
  }
2989
- function Xt({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowField: r, flowBadges: i, hrefFor: o, hostAction: s, hostTitle: c, language: l, navigation: u, onConfigureConnector: d, onHostAction: f, onLanguageChange: p, store: m, theme: h }) {
3245
+ function _n({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowField: r, flowBadges: i, hrefFor: o, hostAction: s, hostTitle: c, language: l, navigation: u, onConfigureConnector: d, onHostAction: f, onLanguageChange: p, store: m, theme: h }) {
2990
3246
  let g = a(m.workspace.$.flowId);
2991
- return /* @__PURE__ */ G("div", {
3247
+ return /* @__PURE__ */ q("div", {
2992
3248
  className: "app-shell",
2993
- children: g == null ? /* @__PURE__ */ G(tt, {
3249
+ children: g == null ? /* @__PURE__ */ q(vt, {
2994
3250
  catalogWidth: e,
2995
3251
  createFlowDisabled: n,
2996
3252
  createFlowField: r,
@@ -3007,12 +3263,12 @@ function Xt({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowF
3007
3263
  onLanguageChange: p,
3008
3264
  onSelectFlow: (e) => void u.selectFlow(e),
3009
3265
  store: m
3010
- }) : /* @__PURE__ */ G(Ge, {
3011
- fallback: /* @__PURE__ */ G("main", {
3266
+ }) : /* @__PURE__ */ q(at, {
3267
+ fallback: /* @__PURE__ */ q("main", {
3012
3268
  "aria-busy": "true",
3013
3269
  className: "workspace"
3014
3270
  }),
3015
- children: /* @__PURE__ */ G(qt, {
3271
+ children: /* @__PURE__ */ q(mn, {
3016
3272
  hostAction: s,
3017
3273
  hostTitle: c,
3018
3274
  hrefFor: o,
@@ -3025,21 +3281,21 @@ function Xt({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowF
3025
3281
  })
3026
3282
  });
3027
3283
  }
3028
- function Zt({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowField: r, flowBadges: i, host: a, hostAction: s, hostTitle: c, hrefFor: l, language: u, location: d, onConfigureConnector: f, onHostAction: p, onLanguageChange: m, onNavigate: h, preferences: g, theme: _, variables: v = !0 }) {
3029
- let y = Ke(h);
3284
+ function vn({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowField: r, flowBadges: i, host: a, hostAction: s, hostTitle: c, hrefFor: l, language: u, location: d, onConfigureConnector: f, onHostAction: p, onLanguageChange: m, onNavigate: h, preferences: g, theme: _, variables: v = !0 }) {
3285
+ let y = G(h);
3030
3286
  y.current = h;
3031
- let [{ i18n: b, navigation: x, store: S }] = W(() => {
3032
- let e = L(u), t = new Kt(new Oe((e, t) => a.request(e, t), (e, t) => a.subscribeFlow(e, t), (e) => a.subscribeFlowCatalog(e)), g, () => crypto.randomUUID(), e, a, v);
3287
+ let [{ i18n: b, navigation: x, store: S }] = K(() => {
3288
+ let e = P(u), t = new pn(new ye((e, t) => a.request(e, t), (e, t) => a.subscribeFlow(e, t), (e) => a.subscribeFlowCatalog(e)), g, F, e, a, v);
3033
3289
  return {
3034
3290
  i18n: e,
3035
- navigation: new Je(t, d, (e, t) => y.current(e, t)),
3291
+ navigation: new dt(t, d, (e, t) => y.current(e, t)),
3036
3292
  store: t
3037
3293
  };
3038
3294
  });
3039
- return U(() => {
3295
+ return W(() => {
3040
3296
  x.start();
3041
3297
  let e = () => {
3042
- S.connectors.refreshAfterAuthorization(), S.triggers.refreshAfterAuthorization(), S.refreshVariableNames();
3298
+ S.connectors.refreshAfterAuthorization(), S.triggers.refreshAfterAuthorization(), S.invalidateVariableNames();
3043
3299
  };
3044
3300
  return globalThis.addEventListener("focus", e), () => {
3045
3301
  globalThis.removeEventListener("focus", e), x.dispose(), S.dispose(), b.dispose();
@@ -3048,17 +3304,17 @@ function Zt({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowF
3048
3304
  b,
3049
3305
  x,
3050
3306
  S
3051
- ]), U(() => void x.apply(d), [d, x]), U(() => {
3307
+ ]), W(() => void x.apply(d), [d, x]), W(() => {
3052
3308
  b.lang != u && b.switchLang(u);
3053
- }, [b, u]), /* @__PURE__ */ G(o, {
3309
+ }, [b, u]), /* @__PURE__ */ q(o, {
3054
3310
  i18n: b,
3055
- children: /* @__PURE__ */ K("div", {
3311
+ children: /* @__PURE__ */ J("div", {
3056
3312
  className: "open-flow-theme open-flow-workbench",
3057
3313
  "data-theme": _,
3058
- children: [/* @__PURE__ */ G(Yt, {
3314
+ children: [/* @__PURE__ */ q(gn, {
3059
3315
  host: a,
3060
3316
  store: S
3061
- }), /* @__PURE__ */ G(Xt, {
3317
+ }), /* @__PURE__ */ q(_n, {
3062
3318
  catalogWidth: e,
3063
3319
  createFlow: t,
3064
3320
  createFlowDisabled: n,
@@ -3078,8 +3334,8 @@ function Zt({ catalogWidth: e, createFlow: t, createFlowDisabled: n, createFlowF
3078
3334
  })
3079
3335
  });
3080
3336
  }
3081
- function Qt({ sessionKey: e, ...t }) {
3082
- return /* @__PURE__ */ G(Zt, { ...t }, e);
3337
+ function yn({ sessionKey: e, ...t }) {
3338
+ return /* @__PURE__ */ q(vn, { ...t }, e);
3083
3339
  }
3084
3340
  //#endregion
3085
- export { Jt as OpenFlowSessionGate, Qt as OpenFlowWorkbench, Ue as isWorkbenchLanguage, We as resolveWorkbenchLanguage, He as workbenchLanguageNames, Ve as workbenchLanguages };
3341
+ export { hn as OpenFlowSessionGate, yn as OpenFlowWorkbench, Xe as isWorkbenchLanguage, Je as resolveWorkbenchLanguage, Ye as workbenchLanguageNames, qe as workbenchLanguages };