@burdenoff/microfe-subscriberbot 2026.1102.5 → 2026.1103.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/stories/pages/InboxPage.stories.d.ts.map +1 -1
  2. package/dist/stories/pages/InboxReadState.stories.d.ts +11 -0
  3. package/dist/stories/pages/InboxReadState.stories.d.ts.map +1 -0
  4. package/dist/stories/pages/WorkflowBuilderPage.stories.d.ts +14 -0
  5. package/dist/stories/pages/WorkflowBuilderPage.stories.d.ts.map +1 -0
  6. package/dist/stories/pages/WorkflowsPage.stories.d.ts +1 -0
  7. package/dist/stories/pages/WorkflowsPage.stories.d.ts.map +1 -1
  8. package/dist/stories/support/fixtures.d.ts +6 -1
  9. package/dist/stories/support/fixtures.d.ts.map +1 -1
  10. package/dist/stories/support/handlers.d.ts.map +1 -1
  11. package/dist/subscriberbot/SubscriberBotRoutes.d.ts.map +1 -1
  12. package/dist/subscriberbot/SubscriberBotRoutes.js +27 -23
  13. package/dist/subscriberbot/SubscriberBotRoutes.js.map +1 -1
  14. package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts +11 -1
  15. package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts.map +1 -1
  16. package/dist/subscriberbot/hooks/useSubscriberBotApi.js +122 -82
  17. package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
  18. package/dist/subscriberbot/pages/InboxPage.d.ts +2 -2
  19. package/dist/subscriberbot/pages/InboxPage.d.ts.map +1 -1
  20. package/dist/subscriberbot/pages/InboxPage.js +272 -234
  21. package/dist/subscriberbot/pages/InboxPage.js.map +1 -1
  22. package/dist/subscriberbot/pages/WorkflowsPage.d.ts +4 -4
  23. package/dist/subscriberbot/pages/WorkflowsPage.d.ts.map +1 -1
  24. package/dist/subscriberbot/pages/WorkflowsPage.js +201 -190
  25. package/dist/subscriberbot/pages/WorkflowsPage.js.map +1 -1
  26. package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.d.ts +3 -0
  27. package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.d.ts.map +1 -0
  28. package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.js +648 -0
  29. package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.js.map +1 -0
  30. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.d.ts +60 -0
  31. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.d.ts.map +1 -0
  32. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.js +122 -0
  33. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.js.map +1 -0
  34. package/dist/subscriberbot/types/index.d.ts +65 -0
  35. package/dist/subscriberbot/types/index.d.ts.map +1 -1
  36. package/dist/subscriberbot/utils/pageContext.d.ts.map +1 -1
  37. package/dist/subscriberbot/utils/pageContext.js +21 -13
  38. package/dist/subscriberbot/utils/pageContext.js.map +1 -1
  39. package/package.json +3 -1
@@ -0,0 +1,648 @@
1
+ import { useSubscriberBot as e } from "../../context/SubscriberBotContext.js";
2
+ import { PageLayout as t } from "../../components/PageLayout.js";
3
+ import { StatusBadge as n } from "../../components/StatusBadge.js";
4
+ import { EmptyState as r } from "../../components/EmptyState.js";
5
+ import { useTr as i } from "../../hooks/useTr.js";
6
+ import { ErrorView as a, LoadingView as o } from "../../components/StateViews.js";
7
+ import "../../components/index.js";
8
+ import { useActivateWorkflow as s, usePauseWorkflow as c, useSaveWorkflowGraph as l, useWorkflow as u } from "../../hooks/useSubscriberBotApi.js";
9
+ import { ACTION_KINDS as d, NODE_KINDS as f, canAddKind as p, configSummary as ee, connectionError as te, defaultLabel as m, fromServerGraph as h, initialConfig as g, nextNodePosition as ne, removeNode as _, toSaveInput as re } from "./workflowBuilderGraph.js";
10
+ import { useCallback as v, useMemo as y, useState as b } from "react";
11
+ import { AlertTriangle as x, ArrowLeft as S, CheckCircle2 as C, Clock as w, GitBranch as T, GitFork as E, Pause as D, Play as ie, Save as ae, Sparkles as O, Trash2 as k, Zap as A } from "lucide-react";
12
+ import { useParams as j } from "react-router";
13
+ import { Fragment as M, jsx as N, jsxs as P } from "react/jsx-runtime";
14
+ import { GlassCard as F } from "@burdenoff/fe-libs/ui";
15
+ import { Background as I, Controls as L, Handle as R, MarkerType as oe, Position as z, ReactFlow as se, applyNodeChanges as B } from "@xyflow/react";
16
+ import "@xyflow/react/dist/style.css";
17
+ //#region src/subscriberbot/pages/workflows/WorkflowBuilderPage.tsx
18
+ var V = "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] disabled:opacity-60", H = "mb-1 block text-xs font-medium text-text-secondary", U = "inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50", W = "inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50", G = {
19
+ TRIGGER: {
20
+ icon: A,
21
+ bar: "bg-[var(--color-accent-indigo)]",
22
+ labelKey: "workflows.builder.kind.trigger",
23
+ fallback: "Trigger",
24
+ hint: "The event that starts the workflow"
25
+ },
26
+ ACTION: {
27
+ icon: O,
28
+ bar: "bg-status-success-text",
29
+ labelKey: "workflows.builder.kind.action",
30
+ fallback: "Action",
31
+ hint: "Notify, alert, create a task, update, classify or call an adapter"
32
+ },
33
+ CONDITION: {
34
+ icon: E,
35
+ bar: "bg-status-warning-text",
36
+ labelKey: "workflows.builder.kind.condition",
37
+ fallback: "Condition",
38
+ hint: "Route through a true or false outlet"
39
+ },
40
+ DELAY: {
41
+ icon: w,
42
+ bar: "bg-text-secondary",
43
+ labelKey: "workflows.builder.kind.delay",
44
+ fallback: "Delay",
45
+ hint: "Wait before the next step"
46
+ },
47
+ BRANCH: {
48
+ icon: T,
49
+ bar: "bg-[var(--color-accent-indigo)]",
50
+ labelKey: "workflows.builder.kind.branch",
51
+ fallback: "Branch",
52
+ hint: "Run two or more paths in parallel"
53
+ }
54
+ }, K = {
55
+ NOTIFY: "Notify",
56
+ ALERT: "Raise an alert",
57
+ CREATE_TASK: "Create a task",
58
+ UPDATE_RELATIONSHIP: "Update the relationship",
59
+ CLASSIFY: "Classify with AI",
60
+ EVALUATE_POLICIES: "Evaluate agent policies",
61
+ CALL_ADAPTER: "Call the provider adapter"
62
+ }, q = {
63
+ background: "var(--color-text-secondary)",
64
+ width: 10,
65
+ height: 10
66
+ };
67
+ function J({ data: e, selected: t }) {
68
+ let n = i(), r = G[e.kind], a = r.icon;
69
+ return /* @__PURE__ */ P("div", {
70
+ "data-testid": `workflow-node-${e.kind.toLowerCase()}`,
71
+ className: `w-52 overflow-hidden rounded-xl border bg-bg-surface shadow-sm ${t ? "border-[var(--color-focus-ring)] ring-2 ring-[var(--color-focus-ring)]" : e.hasIssue ? "border-status-warning-text" : "border-border-subtle"}`,
72
+ children: [
73
+ e.kind !== "TRIGGER" && /* @__PURE__ */ N(R, {
74
+ type: "target",
75
+ position: z.Left,
76
+ style: q
77
+ }),
78
+ /* @__PURE__ */ N("div", {
79
+ className: `h-1 w-full ${r.bar}`,
80
+ "aria-hidden": !0
81
+ }),
82
+ /* @__PURE__ */ P("div", {
83
+ className: "p-3",
84
+ children: [
85
+ /* @__PURE__ */ P("div", {
86
+ className: "flex items-center gap-2",
87
+ children: [
88
+ /* @__PURE__ */ N("span", {
89
+ className: "flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary",
90
+ children: /* @__PURE__ */ N(a, { className: "h-4 w-4" })
91
+ }),
92
+ /* @__PURE__ */ N("p", {
93
+ className: "text-[10px] font-medium uppercase tracking-wide text-text-secondary",
94
+ children: n(r.labelKey, r.fallback)
95
+ }),
96
+ e.hasIssue && /* @__PURE__ */ N(x, {
97
+ className: "ml-auto h-3.5 w-3.5 text-status-warning-text",
98
+ "aria-label": n("workflows.builder.nodeHasIssue", "Needs attention")
99
+ })
100
+ ]
101
+ }),
102
+ /* @__PURE__ */ N("p", {
103
+ className: "mt-2 truncate text-sm font-semibold text-text-primary",
104
+ title: e.label,
105
+ children: e.label
106
+ }),
107
+ /* @__PURE__ */ N("p", {
108
+ className: "mt-0.5 truncate text-xs text-text-secondary",
109
+ title: e.summary,
110
+ children: e.summary
111
+ })
112
+ ]
113
+ }),
114
+ e.kind === "CONDITION" ? /* @__PURE__ */ P(M, { children: [/* @__PURE__ */ N(R, {
115
+ id: "true",
116
+ type: "source",
117
+ position: z.Right,
118
+ style: {
119
+ ...q,
120
+ top: "35%",
121
+ background: "var(--color-status-success-text)"
122
+ }
123
+ }), /* @__PURE__ */ N(R, {
124
+ id: "false",
125
+ type: "source",
126
+ position: z.Right,
127
+ style: {
128
+ ...q,
129
+ top: "70%",
130
+ background: "var(--color-status-error-text)"
131
+ }
132
+ })] }) : /* @__PURE__ */ N(R, {
133
+ type: "source",
134
+ position: z.Right,
135
+ style: q
136
+ })
137
+ ]
138
+ });
139
+ }
140
+ var ce = { workflow: J };
141
+ function le({ node: e, readOnly: t, onChange: n, onDelete: r }) {
142
+ let a = i(), o = G[e.kind], s = (t) => n({ config: {
143
+ ...e.config,
144
+ ...t
145
+ } });
146
+ return /* @__PURE__ */ P("div", {
147
+ className: "space-y-4",
148
+ "data-testid": "workflow-node-inspector",
149
+ children: [
150
+ /* @__PURE__ */ N("p", {
151
+ className: "text-xs font-medium uppercase tracking-wide text-text-secondary",
152
+ children: a(o.labelKey, o.fallback)
153
+ }),
154
+ /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
155
+ htmlFor: "wfb-label",
156
+ className: H,
157
+ children: a("workflows.builder.inspector.label", "Label")
158
+ }), /* @__PURE__ */ N("input", {
159
+ id: "wfb-label",
160
+ className: V,
161
+ value: e.label,
162
+ maxLength: 120,
163
+ disabled: t,
164
+ onChange: (e) => n({ label: e.target.value })
165
+ })] }),
166
+ e.kind === "TRIGGER" && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
167
+ htmlFor: "wfb-event",
168
+ className: H,
169
+ children: a("workflows.builder.inspector.event", "Trigger event")
170
+ }), /* @__PURE__ */ N("input", {
171
+ id: "wfb-event",
172
+ className: V,
173
+ value: typeof e.config.event == "string" ? e.config.event : "",
174
+ maxLength: 120,
175
+ placeholder: a("workflows.form.triggerPlaceholder", "e.g. InvoiceReceived, RenewalDetected"),
176
+ disabled: t,
177
+ onChange: (e) => s({ event: e.target.value })
178
+ })] }),
179
+ e.kind === "ACTION" && /* @__PURE__ */ P(M, { children: [/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
180
+ htmlFor: "wfb-action",
181
+ className: H,
182
+ children: a("workflows.builder.inspector.action", "Action")
183
+ }), /* @__PURE__ */ P("select", {
184
+ id: "wfb-action",
185
+ className: V,
186
+ value: typeof e.config.action == "string" ? e.config.action : "",
187
+ disabled: t,
188
+ onChange: (e) => s({ action: e.target.value || void 0 }),
189
+ children: [/* @__PURE__ */ N("option", {
190
+ value: "",
191
+ children: a("workflows.builder.inspector.chooseAction", "Choose an action…")
192
+ }), d.map((e) => /* @__PURE__ */ N("option", {
193
+ value: e,
194
+ children: a(`workflows.builder.action.${e.toLowerCase()}`, K[e])
195
+ }, e))]
196
+ })] }), /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
197
+ htmlFor: "wfb-message",
198
+ className: H,
199
+ children: a("workflows.builder.inspector.message", "Message (optional)")
200
+ }), /* @__PURE__ */ N("textarea", {
201
+ id: "wfb-message",
202
+ rows: 3,
203
+ className: V,
204
+ maxLength: 1e3,
205
+ value: typeof e.config.message == "string" ? e.config.message : "",
206
+ disabled: t,
207
+ onChange: (e) => s({ message: e.target.value })
208
+ })] })] }),
209
+ e.kind === "CONDITION" && /* @__PURE__ */ P("div", { children: [
210
+ /* @__PURE__ */ N("label", {
211
+ htmlFor: "wfb-expression",
212
+ className: H,
213
+ children: a("workflows.builder.inspector.expression", "Condition")
214
+ }),
215
+ /* @__PURE__ */ N("input", {
216
+ id: "wfb-expression",
217
+ className: V,
218
+ maxLength: 500,
219
+ placeholder: a("workflows.builder.inspector.expressionPlaceholder", "e.g. monthlySpend > 100"),
220
+ value: typeof e.config.expression == "string" ? e.config.expression : "",
221
+ disabled: t,
222
+ onChange: (e) => s({ expression: e.target.value })
223
+ }),
224
+ /* @__PURE__ */ N("p", {
225
+ className: "mt-1 text-xs text-text-secondary",
226
+ children: a("workflows.builder.inspector.expressionHint", "Connect the green outlet for when it holds and the red outlet for when it does not.")
227
+ })
228
+ ] }),
229
+ e.kind === "DELAY" && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
230
+ htmlFor: "wfb-delay",
231
+ className: H,
232
+ children: a("workflows.builder.inspector.delay", "Wait (minutes)")
233
+ }), /* @__PURE__ */ N("input", {
234
+ id: "wfb-delay",
235
+ type: "number",
236
+ min: 1,
237
+ max: 525600,
238
+ step: 1,
239
+ className: V,
240
+ value: typeof e.config.durationMinutes == "number" ? e.config.durationMinutes : "",
241
+ disabled: t,
242
+ onChange: (e) => {
243
+ let t = Number.parseInt(e.target.value, 10);
244
+ s({ durationMinutes: Number.isFinite(t) ? t : void 0 });
245
+ }
246
+ })] }),
247
+ e.kind === "BRANCH" && /* @__PURE__ */ N("p", {
248
+ className: "text-xs text-text-secondary",
249
+ children: a("workflows.builder.inspector.branchHint", "Connect two or more steps; they run in parallel.")
250
+ }),
251
+ !t && /* @__PURE__ */ P("button", {
252
+ type: "button",
253
+ onClick: r,
254
+ className: "inline-flex items-center gap-1.5 rounded-lg border border-status-error-text/40 px-3 py-1.5 text-xs font-medium text-status-error-text hover:bg-status-error-bg-subtle",
255
+ children: [
256
+ /* @__PURE__ */ N(k, { className: "h-3.5 w-3.5" }),
257
+ " ",
258
+ a("workflows.builder.inspector.deleteNode", "Delete node")
259
+ ]
260
+ })
261
+ ]
262
+ });
263
+ }
264
+ function Y({ workflow: e }) {
265
+ let t = i(), a = l(), o = s(), u = c(), [d, S] = b(() => h(e.graph)), [w, T] = b(e.graph.issues), [E, O] = b(!1), [j, R] = b(null), [z, V] = b(null), [H, K] = b(null), [q, J] = b(1), Y = e.status === "ACTIVE", X = Y || a.isPending, [ue, de] = b(e.graph);
266
+ ue !== e.graph && (de(e.graph), E || (S(h(e.graph)), T(e.graph.issues)));
267
+ let Z = y(() => new Set(w.map((e) => e.nodeId).filter((e) => !!e)), [w]), fe = y(() => d.nodes.map((e) => ({
268
+ id: e.id,
269
+ type: "workflow",
270
+ position: {
271
+ x: e.x,
272
+ y: e.y
273
+ },
274
+ selected: e.id === j,
275
+ data: {
276
+ kind: e.kind,
277
+ label: e.label || m(e.kind),
278
+ summary: ee(e),
279
+ hasIssue: !E && Z.has(e.id)
280
+ }
281
+ })), [
282
+ d.nodes,
283
+ j,
284
+ E,
285
+ Z
286
+ ]), pe = y(() => d.edges.map((e) => ({
287
+ id: e.id,
288
+ source: e.source,
289
+ target: e.target,
290
+ sourceHandle: e.handle,
291
+ selected: e.id === z,
292
+ label: e.handle === "true" ? t("workflows.builder.yes", "Yes") : e.handle === "false" ? t("workflows.builder.no", "No") : void 0,
293
+ markerEnd: {
294
+ type: oe.ArrowClosed,
295
+ color: "var(--color-text-secondary)"
296
+ },
297
+ style: {
298
+ stroke: e.id === z ? "var(--color-focus-ring)" : "var(--color-text-secondary)",
299
+ strokeWidth: 2
300
+ }
301
+ })), [
302
+ d.edges,
303
+ z,
304
+ t
305
+ ]), Q = v((e) => {
306
+ S((t) => e(t)), O(!0), K(null);
307
+ }, []), me = v((e) => {
308
+ let t = e.filter((e) => e.type === "position" && e.position), n = e.filter((e) => e.type === "remove");
309
+ X || t.length === 0 && n.length === 0 || Q((e) => {
310
+ let r = B(t, e.nodes.map((e) => ({
311
+ id: e.id,
312
+ position: {
313
+ x: e.x,
314
+ y: e.y
315
+ },
316
+ data: {}
317
+ }))), i = {
318
+ nodes: e.nodes.map((e) => {
319
+ let t = r.find((t) => t.id === e.id);
320
+ return t ? {
321
+ ...e,
322
+ x: t.position.x,
323
+ y: t.position.y
324
+ } : e;
325
+ }),
326
+ edges: e.edges
327
+ };
328
+ for (let e of n) e.type === "remove" && (i = _(i, e.id));
329
+ return i;
330
+ });
331
+ }, [Q, X]), he = v((e) => {
332
+ let t = new Set(e.filter((e) => e.type === "remove").map((e) => e.id));
333
+ X || t.size === 0 || Q((e) => ({
334
+ nodes: e.nodes,
335
+ edges: e.edges.filter((e) => !t.has(e.id))
336
+ }));
337
+ }, [Q, X]), ge = v((e) => {
338
+ if (X) return;
339
+ let t = e.sourceHandle ?? null, n = te(d, e.source, e.target, t);
340
+ if (n) {
341
+ K({
342
+ tone: "error",
343
+ text: n
344
+ });
345
+ return;
346
+ }
347
+ Q((n) => ({
348
+ nodes: n.nodes,
349
+ edges: [...n.edges, {
350
+ id: `edge-${e.source}-${t ?? "out"}-${e.target}`,
351
+ source: e.source,
352
+ target: e.target,
353
+ handle: t,
354
+ label: null
355
+ }]
356
+ }));
357
+ }, [
358
+ Q,
359
+ d,
360
+ X
361
+ ]), _e = (e) => {
362
+ let t = `new-${q}`;
363
+ J((e) => e + 1);
364
+ let n = ne(d.nodes);
365
+ Q((r) => ({
366
+ nodes: [...r.nodes, {
367
+ id: t,
368
+ kind: e,
369
+ label: m(e),
370
+ config: g(e),
371
+ x: n.x,
372
+ y: n.y
373
+ }],
374
+ edges: r.edges
375
+ })), R(t), V(null);
376
+ }, $ = d.nodes.find((e) => e.id === j) ?? null, ve = () => {
377
+ a.mutate({
378
+ workflowId: e.id,
379
+ input: re(d)
380
+ }, {
381
+ onSuccess: (e) => {
382
+ S(h(e)), T(e.issues), O(!1), R(null), V(null), K({
383
+ tone: "success",
384
+ text: e.valid ? t("workflows.builder.savedValid", "Saved. This workflow is ready to activate.") : t("workflows.builder.savedWithIssues", "Saved as a draft. Fix the issues below before activating.")
385
+ });
386
+ },
387
+ onError: (e) => K({
388
+ tone: "error",
389
+ text: e instanceof Error ? e.message : t("common.error", "An error occurred")
390
+ })
391
+ });
392
+ }, ye = () => o.mutate(e.id, {
393
+ onSuccess: () => K({
394
+ tone: "success",
395
+ text: t("workflows.builder.activated", "Workflow activated.")
396
+ }),
397
+ onError: (e) => K({
398
+ tone: "error",
399
+ text: e instanceof Error ? e.message : t("common.error", "An error occurred")
400
+ })
401
+ }), be = () => u.mutate(e.id, {
402
+ onSuccess: () => K({
403
+ tone: "success",
404
+ text: t("workflows.builder.paused", "Workflow paused. You can edit it now.")
405
+ }),
406
+ onError: (e) => K({
407
+ tone: "error",
408
+ text: e instanceof Error ? e.message : t("common.error", "An error occurred")
409
+ })
410
+ }), xe = !Y && !E && w.length === 0 && d.nodes.length > 0;
411
+ return /* @__PURE__ */ P(M, { children: [
412
+ /* @__PURE__ */ P("div", {
413
+ className: "flex flex-wrap items-center justify-between gap-3",
414
+ children: [/* @__PURE__ */ P("div", {
415
+ className: "flex flex-wrap items-center gap-2",
416
+ children: [
417
+ /* @__PURE__ */ N(n, { status: e.status }),
418
+ E && /* @__PURE__ */ N("span", {
419
+ className: "rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text",
420
+ children: t("workflows.builder.unsaved", "Unsaved changes")
421
+ }),
422
+ !E && w.length === 0 && d.nodes.length > 0 && /* @__PURE__ */ P("span", {
423
+ className: "inline-flex items-center gap-1 text-xs text-status-success-text",
424
+ children: [
425
+ /* @__PURE__ */ N(C, { className: "h-3.5 w-3.5" }),
426
+ " ",
427
+ t("workflows.builder.valid", "Ready to run")
428
+ ]
429
+ })
430
+ ]
431
+ }), /* @__PURE__ */ N("div", {
432
+ className: "flex flex-wrap items-center gap-2",
433
+ children: Y ? /* @__PURE__ */ P("button", {
434
+ type: "button",
435
+ className: U,
436
+ onClick: be,
437
+ disabled: u.isPending,
438
+ children: [
439
+ /* @__PURE__ */ N(D, { className: "h-4 w-4" }),
440
+ " ",
441
+ t("workflows.builder.pauseToEdit", "Pause to edit")
442
+ ]
443
+ }) : /* @__PURE__ */ P(M, { children: [/* @__PURE__ */ P("button", {
444
+ type: "button",
445
+ className: U,
446
+ onClick: ve,
447
+ disabled: !E || a.isPending,
448
+ children: [
449
+ /* @__PURE__ */ N(ae, { className: "h-4 w-4" }),
450
+ " ",
451
+ a.isPending ? t("workflows.builder.saving", "Saving…") : t("workflows.builder.save", "Save")
452
+ ]
453
+ }), /* @__PURE__ */ P("button", {
454
+ type: "button",
455
+ className: W,
456
+ onClick: ye,
457
+ disabled: !xe || o.isPending,
458
+ title: E ? t("workflows.builder.saveFirst", "Save your changes first") : w.length > 0 ? t("workflows.builder.fixIssuesFirst", "Fix the issues first") : void 0,
459
+ children: [
460
+ /* @__PURE__ */ N(ie, { className: "h-4 w-4" }),
461
+ " ",
462
+ o.isPending ? t("common.activating", "Activating…") : t("workflows.flow.activate", "Activate workflow")
463
+ ]
464
+ })] })
465
+ })]
466
+ }),
467
+ H && /* @__PURE__ */ N("div", {
468
+ role: H.tone === "error" ? "alert" : "status",
469
+ className: `mt-3 rounded-lg border px-4 py-2 text-sm ${H.tone === "error" ? "border-status-error-text/30 bg-status-error-bg-subtle text-status-error-text" : "border-status-success-text/30 bg-status-success-bg-subtle text-status-success-text"}`,
470
+ children: H.text
471
+ }),
472
+ Y && /* @__PURE__ */ N("p", {
473
+ className: "mt-3 text-sm text-text-secondary",
474
+ children: t("workflows.builder.readOnlyActive", "This workflow is active, so it is shown read-only. Pause it to change its steps.")
475
+ }),
476
+ /* @__PURE__ */ P("div", {
477
+ className: "mt-4 grid grid-cols-1 gap-4 lg:grid-cols-[13rem_minmax(0,1fr)_18rem]",
478
+ children: [
479
+ /* @__PURE__ */ P(F, {
480
+ treatment: "metric",
481
+ className: "p-3",
482
+ children: [/* @__PURE__ */ N("p", {
483
+ className: "mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary",
484
+ children: t("workflows.builder.palette", "Add a step")
485
+ }), /* @__PURE__ */ N("div", {
486
+ className: "grid grid-cols-2 gap-2 lg:grid-cols-1",
487
+ role: "group",
488
+ "aria-label": t("workflows.builder.palette", "Add a step"),
489
+ children: f.map((e) => {
490
+ let n = G[e], r = n.icon;
491
+ return /* @__PURE__ */ P("button", {
492
+ type: "button",
493
+ disabled: X || !p(e, d.nodes),
494
+ onClick: () => _e(e),
495
+ title: t(`${n.labelKey}Hint`, n.hint),
496
+ className: "flex items-center gap-2 rounded-lg border border-border-subtle bg-bg-surface px-2.5 py-2 text-left text-sm text-text-primary hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-50",
497
+ children: [/* @__PURE__ */ N(r, { className: "h-4 w-4 shrink-0 text-text-secondary" }), /* @__PURE__ */ N("span", {
498
+ className: "truncate",
499
+ children: t(n.labelKey, n.fallback)
500
+ })]
501
+ }, e);
502
+ })
503
+ })]
504
+ }),
505
+ /* @__PURE__ */ N("div", {
506
+ className: "h-[60vh] min-h-[420px] overflow-hidden rounded-xl border border-border-subtle bg-bg-sunken",
507
+ "data-testid": "workflow-canvas",
508
+ children: d.nodes.length === 0 ? /* @__PURE__ */ N("div", {
509
+ className: "flex h-full items-center justify-center p-6",
510
+ children: /* @__PURE__ */ N(r, {
511
+ icon: /* @__PURE__ */ N(A, { className: "h-10 w-10" }),
512
+ title: t("workflows.builder.emptyTitle", "Start with a trigger"),
513
+ description: t("workflows.builder.emptyDescription", "Add a trigger from the palette, then connect the steps that should follow it.")
514
+ })
515
+ }) : /* @__PURE__ */ P(se, {
516
+ nodes: fe,
517
+ edges: pe,
518
+ nodeTypes: ce,
519
+ onNodesChange: me,
520
+ onEdgesChange: he,
521
+ onConnect: ge,
522
+ onNodeClick: (e, t) => {
523
+ R(t.id), V(null);
524
+ },
525
+ onEdgeClick: (e, t) => {
526
+ V(t.id), R(null);
527
+ },
528
+ onPaneClick: () => {
529
+ R(null), V(null);
530
+ },
531
+ nodesDraggable: !X,
532
+ nodesConnectable: !X,
533
+ deleteKeyCode: X ? null : ["Backspace", "Delete"],
534
+ fitView: !0,
535
+ fitViewOptions: {
536
+ padding: .2,
537
+ maxZoom: 1.1
538
+ },
539
+ proOptions: { hideAttribution: !0 },
540
+ children: [/* @__PURE__ */ N(I, {
541
+ color: "var(--color-border-subtle)",
542
+ gap: 20
543
+ }), /* @__PURE__ */ N(L, { showInteractive: !1 })]
544
+ })
545
+ }),
546
+ /* @__PURE__ */ P("div", {
547
+ className: "space-y-4",
548
+ children: [/* @__PURE__ */ N(F, {
549
+ treatment: "metric",
550
+ className: "p-4",
551
+ children: $ ? /* @__PURE__ */ N(le, {
552
+ node: $,
553
+ readOnly: X,
554
+ onChange: (e) => Q((t) => ({
555
+ nodes: t.nodes.map((t) => t.id === $.id ? {
556
+ ...t,
557
+ ...e
558
+ } : t),
559
+ edges: t.edges
560
+ })),
561
+ onDelete: () => {
562
+ Q((e) => _(e, $.id)), R(null);
563
+ }
564
+ }) : z && !X ? /* @__PURE__ */ P("div", {
565
+ className: "space-y-3",
566
+ children: [/* @__PURE__ */ N("p", {
567
+ className: "text-sm text-text-primary",
568
+ children: t("workflows.builder.edgeSelected", "Connection selected")
569
+ }), /* @__PURE__ */ P("button", {
570
+ type: "button",
571
+ onClick: () => {
572
+ Q((e) => ({
573
+ nodes: e.nodes,
574
+ edges: e.edges.filter((e) => e.id !== z)
575
+ })), V(null);
576
+ },
577
+ className: "inline-flex items-center gap-1.5 rounded-lg border border-status-error-text/40 px-3 py-1.5 text-xs font-medium text-status-error-text hover:bg-status-error-bg-subtle",
578
+ children: [
579
+ /* @__PURE__ */ N(k, { className: "h-3.5 w-3.5" }),
580
+ " ",
581
+ t("workflows.builder.deleteEdge", "Delete connection")
582
+ ]
583
+ })]
584
+ }) : /* @__PURE__ */ N("p", {
585
+ className: "text-sm text-text-secondary",
586
+ children: t("workflows.builder.inspectorEmpty", "Select a node to edit it. Drag from a node’s right edge to another node to connect them.")
587
+ })
588
+ }), /* @__PURE__ */ P(F, {
589
+ treatment: "metric",
590
+ className: "p-4",
591
+ "data-testid": "workflow-issues",
592
+ children: [/* @__PURE__ */ N("p", {
593
+ className: "mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary",
594
+ children: t("workflows.builder.issues", "Validation")
595
+ }), E ? /* @__PURE__ */ N("p", {
596
+ className: "text-sm text-text-secondary",
597
+ children: t("workflows.builder.issuesAfterSave", "Save to check the workflow.")
598
+ }) : w.length === 0 ? /* @__PURE__ */ P("p", {
599
+ className: "inline-flex items-center gap-1.5 text-sm text-status-success-text",
600
+ children: [
601
+ /* @__PURE__ */ N(C, { className: "h-4 w-4" }),
602
+ " ",
603
+ t("workflows.builder.noIssues", "No issues found")
604
+ ]
605
+ }) : /* @__PURE__ */ N("ul", {
606
+ className: "space-y-2",
607
+ children: w.map((e, t) => /* @__PURE__ */ N("li", { children: /* @__PURE__ */ P("button", {
608
+ type: "button",
609
+ className: "flex w-full items-start gap-2 text-left text-sm text-text-primary hover:underline disabled:no-underline",
610
+ disabled: !e.nodeId,
611
+ onClick: () => e.nodeId && R(e.nodeId),
612
+ children: [/* @__PURE__ */ N(x, { className: "mt-0.5 h-4 w-4 shrink-0 text-status-warning-text" }), /* @__PURE__ */ N("span", { children: e.message })]
613
+ }) }, `${e.code}-${e.nodeId ?? e.edgeId ?? t}`))
614
+ })]
615
+ })]
616
+ })
617
+ ]
618
+ })
619
+ ] });
620
+ }
621
+ function X() {
622
+ let { id: n } = j(), s = i(), { navigateTo: c } = e(), { data: l, isLoading: d, isError: f, refetch: p } = u(n);
623
+ return /* @__PURE__ */ N(t, {
624
+ title: l?.name ?? s("workflows.builder.title", "Workflow builder"),
625
+ description: l ? s("workflows.builder.subtitle", "Visual builder · starts on {{trigger}}", { trigger: l.triggerEvent || "—" }) : void 0,
626
+ actions: /* @__PURE__ */ P("button", {
627
+ type: "button",
628
+ className: U,
629
+ onClick: () => c(n ? `/workflows/${n}` : "/workflows"),
630
+ children: [
631
+ /* @__PURE__ */ N(S, { className: "h-4 w-4" }),
632
+ " ",
633
+ s("workflows.builder.back", "Workflows")
634
+ ]
635
+ }),
636
+ children: d ? /* @__PURE__ */ N(o, { label: s("workflows.builder.loading", "Loading workflow…") }) : f ? /* @__PURE__ */ N(a, {
637
+ message: s("workflows.builder.error", "Could not load this workflow."),
638
+ onRetry: () => void p()
639
+ }) : l ? /* @__PURE__ */ N(Y, { workflow: l }, l.id) : /* @__PURE__ */ N(r, {
640
+ title: s("workflows.builder.notFound", "Workflow not found"),
641
+ description: s("workflows.builder.notFoundDescription", "It may have been deleted, or it belongs to another workspace.")
642
+ })
643
+ });
644
+ }
645
+ //#endregion
646
+ export { X as WorkflowBuilderPage };
647
+
648
+ //# sourceMappingURL=WorkflowBuilderPage.js.map