@object-ui/plugin-workflow 3.1.3 → 3.1.4

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.
package/dist/index.js CHANGED
@@ -1,1878 +1,2490 @@
1
- import { ComponentRegistry as we } from "@object-ui/core";
2
- import hs, { useState as $, useMemo as Se, useCallback as _, useRef as $e } from "react";
3
- import { Input as S, Badge as I, Button as T, Card as q, CardHeader as J, CardTitle as Z, CardContent as X, Label as h, Select as U, SelectTrigger as B, SelectValue as H, SelectContent as W, SelectItem as Y, Separator as ce, Switch as ps } from "@object-ui/components";
4
- import { Save as Qe, Play as Ve, GitBranch as Re, Trash2 as ye, ArrowRight as es, Plus as Ye, Settings as ze, Code as ss, Bell as Ue, Clock as me, Users as Fe, Circle as gs, CheckCircle as Be, MessageSquare as js, Check as fs, X as bs, RefreshCw as Ns, User as vs, Zap as Me, Globe as ts, FileEdit as ys, Mail as ws, Undo2 as ks, Redo2 as Cs, ZoomIn as Es, RotateCcw as _s, ZoomOut as Ts, History as Ss, Download as Rs, Upload as As, PanelRightClose as Ps, PanelRightOpen as Os, Link as Ds, AlertCircle as as, GitMerge as $s, Square as Is, SkipForward as Fs, Loader2 as Ms } from "lucide-react";
5
- import { clsx as Ls } from "clsx";
6
- import { twMerge as Vs } from "tailwind-merge";
7
- var Te = { exports: {} }, je = {};
8
- var We;
9
- function Ys() {
10
- if (We) return je;
11
- We = 1;
12
- var n = /* @__PURE__ */ Symbol.for("react.transitional.element"), c = /* @__PURE__ */ Symbol.for("react.fragment");
13
- function a(d, o, t) {
14
- var u = null;
15
- if (t !== void 0 && (u = "" + t), o.key !== void 0 && (u = "" + o.key), "key" in o) {
16
- t = {};
17
- for (var g in o)
18
- g !== "key" && (t[g] = o[g]);
19
- } else t = o;
20
- return o = t.ref, {
21
- $$typeof: n,
22
- type: d,
23
- key: u,
24
- ref: o !== void 0 ? o : null,
25
- props: t
26
- };
27
- }
28
- return je.Fragment = c, je.jsx = a, je.jsxs = a, je;
29
- }
30
- var fe = {};
31
- var qe;
32
- function zs() {
33
- return qe || (qe = 1, process.env.NODE_ENV !== "production" && (function() {
34
- function n(s) {
35
- if (s == null) return null;
36
- if (typeof s == "function")
37
- return s.$$typeof === G ? null : s.displayName || s.name || null;
38
- if (typeof s == "string") return s;
39
- switch (s) {
40
- case i:
41
- return "Fragment";
42
- case R:
43
- return "Profiler";
44
- case b:
45
- return "StrictMode";
46
- case P:
47
- return "Suspense";
48
- case M:
49
- return "SuspenseList";
50
- case E:
51
- return "Activity";
52
- }
53
- if (typeof s == "object")
54
- switch (typeof s.tag == "number" && console.error(
55
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
56
- ), s.$$typeof) {
57
- case de:
58
- return "Portal";
59
- case r:
60
- return s.displayName || "Context";
61
- case C:
62
- return (s._context.displayName || "Context") + ".Consumer";
63
- case j:
64
- var x = s.render;
65
- return s = s.displayName, s || (s = x.displayName || x.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
66
- case ue:
67
- return x = s.displayName || null, x !== null ? x : n(s.type) || "Memo";
68
- case N:
69
- x = s._payload, s = s._init;
70
- try {
71
- return n(s(x));
72
- } catch {
73
- }
74
- }
75
- return null;
76
- }
77
- function c(s) {
78
- return "" + s;
79
- }
80
- function a(s) {
81
- try {
82
- c(s);
83
- var x = !1;
84
- } catch {
85
- x = !0;
86
- }
87
- if (x) {
88
- x = console;
89
- var y = x.error, A = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
90
- return y.call(
91
- x,
92
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
93
- A
94
- ), c(s);
95
- }
96
- }
97
- function d(s) {
98
- if (s === i) return "<>";
99
- if (typeof s == "object" && s !== null && s.$$typeof === N)
100
- return "<...>";
101
- try {
102
- var x = n(s);
103
- return x ? "<" + x + ">" : "<...>";
104
- } catch {
105
- return "<...>";
106
- }
107
- }
108
- function o() {
109
- var s = K.A;
110
- return s === null ? null : s.getOwner();
111
- }
112
- function t() {
113
- return Error("react-stack-top-frame");
114
- }
115
- function u(s) {
116
- if (z.call(s, "key")) {
117
- var x = Object.getOwnPropertyDescriptor(s, "key").get;
118
- if (x && x.isReactWarning) return !1;
119
- }
120
- return s.key !== void 0;
121
- }
122
- function g(s, x) {
123
- function y() {
124
- re || (re = !0, console.error(
125
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
126
- x
127
- ));
128
- }
129
- y.isReactWarning = !0, Object.defineProperty(s, "key", {
130
- get: y,
131
- configurable: !0
132
- });
133
- }
134
- function F() {
135
- var s = n(this.type);
136
- return ee[s] || (ee[s] = !0, console.error(
137
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
138
- )), s = this.props.ref, s !== void 0 ? s : null;
139
- }
140
- function O(s, x, y, A, se, ne) {
141
- var w = y.ref;
142
- return s = {
143
- $$typeof: L,
144
- type: s,
145
- key: x,
146
- props: y,
147
- _owner: A
148
- }, (w !== void 0 ? w : null) !== null ? Object.defineProperty(s, "ref", {
149
- enumerable: !1,
150
- get: F
151
- }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
152
- configurable: !1,
153
- enumerable: !1,
154
- writable: !0,
155
- value: 0
156
- }), Object.defineProperty(s, "_debugInfo", {
157
- configurable: !1,
158
- enumerable: !1,
159
- writable: !0,
160
- value: null
161
- }), Object.defineProperty(s, "_debugStack", {
162
- configurable: !1,
163
- enumerable: !1,
164
- writable: !0,
165
- value: se
166
- }), Object.defineProperty(s, "_debugTask", {
167
- configurable: !1,
168
- enumerable: !1,
169
- writable: !0,
170
- value: ne
171
- }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
172
- }
173
- function p(s, x, y, A, se, ne) {
174
- var w = x.children;
175
- if (w !== void 0)
176
- if (A)
177
- if (ae(w)) {
178
- for (A = 0; A < w.length; A++)
179
- k(w[A]);
180
- Object.freeze && Object.freeze(w);
181
- } else
182
- console.error(
183
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
184
- );
185
- else k(w);
186
- if (z.call(x, "key")) {
187
- w = n(s);
188
- var te = Object.keys(x).filter(function(pe) {
189
- return pe !== "key";
190
- });
191
- A = 0 < te.length ? "{key: someKey, " + te.join(": ..., ") + ": ...}" : "{key: someKey}", ke[w + A] || (te = 0 < te.length ? "{" + te.join(": ..., ") + ": ...}" : "{}", console.error(
192
- `A props object containing a "key" prop is being spread into JSX:
193
- let props = %s;
194
- <%s {...props} />
195
- React keys must be passed directly to JSX without using spread:
196
- let props = %s;
197
- <%s key={someKey} {...props} />`,
198
- A,
199
- w,
200
- te,
201
- w
202
- ), ke[w + A] = !0);
203
- }
204
- if (w = null, y !== void 0 && (a(y), w = "" + y), u(x) && (a(x.key), w = "" + x.key), "key" in x) {
205
- y = {};
206
- for (var he in x)
207
- he !== "key" && (y[he] = x[he]);
208
- } else y = x;
209
- return w && g(
210
- y,
211
- typeof s == "function" ? s.displayName || s.name || "Unknown" : s
212
- ), O(
213
- s,
214
- w,
215
- y,
216
- o(),
217
- se,
218
- ne
219
- );
220
- }
221
- function k(s) {
222
- v(s) ? s._store && (s._store.validated = 1) : typeof s == "object" && s !== null && s.$$typeof === N && (s._payload.status === "fulfilled" ? v(s._payload.value) && s._payload.value._store && (s._payload.value._store.validated = 1) : s._store && (s._store.validated = 1));
223
- }
224
- function v(s) {
225
- return typeof s == "object" && s !== null && s.$$typeof === L;
226
- }
227
- var f = hs, L = /* @__PURE__ */ Symbol.for("react.transitional.element"), de = /* @__PURE__ */ Symbol.for("react.portal"), i = /* @__PURE__ */ Symbol.for("react.fragment"), b = /* @__PURE__ */ Symbol.for("react.strict_mode"), R = /* @__PURE__ */ Symbol.for("react.profiler"), C = /* @__PURE__ */ Symbol.for("react.consumer"), r = /* @__PURE__ */ Symbol.for("react.context"), j = /* @__PURE__ */ Symbol.for("react.forward_ref"), P = /* @__PURE__ */ Symbol.for("react.suspense"), M = /* @__PURE__ */ Symbol.for("react.suspense_list"), ue = /* @__PURE__ */ Symbol.for("react.memo"), N = /* @__PURE__ */ Symbol.for("react.lazy"), E = /* @__PURE__ */ Symbol.for("react.activity"), G = /* @__PURE__ */ Symbol.for("react.client.reference"), K = f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, ae = Array.isArray, Q = console.createTask ? console.createTask : function() {
228
- return null;
229
- };
230
- f = {
231
- react_stack_bottom_frame: function(s) {
232
- return s();
233
- }
234
- };
235
- var re, ee = {}, le = f.react_stack_bottom_frame.bind(
236
- f,
237
- t
238
- )(), xe = Q(d(t)), ke = {};
239
- fe.Fragment = i, fe.jsx = function(s, x, y) {
240
- var A = 1e4 > K.recentlyCreatedOwnerStacks++;
241
- return p(
242
- s,
243
- x,
244
- y,
245
- !1,
246
- A ? Error("react-stack-top-frame") : le,
247
- A ? Q(d(s)) : xe
248
- );
249
- }, fe.jsxs = function(s, x, y) {
250
- var A = 1e4 > K.recentlyCreatedOwnerStacks++;
251
- return p(
252
- s,
253
- x,
254
- y,
255
- !0,
256
- A ? Error("react-stack-top-frame") : le,
257
- A ? Q(d(s)) : xe
258
- );
259
- };
260
- })()), fe;
261
- }
262
- var Xe;
263
- function Us() {
264
- return Xe || (Xe = 1, process.env.NODE_ENV === "production" ? Te.exports = Ys() : Te.exports = zs()), Te.exports;
265
- }
266
- var e = Us();
267
- const Ie = {
268
- start: /* @__PURE__ */ e.jsx(Ve, { className: "h-4 w-4 text-green-500" }),
269
- end: /* @__PURE__ */ e.jsx(Be, { className: "h-4 w-4 text-red-500" }),
270
- task: /* @__PURE__ */ e.jsx(gs, { className: "h-4 w-4 text-blue-500" }),
271
- approval: /* @__PURE__ */ e.jsx(Fe, { className: "h-4 w-4 text-purple-500" }),
272
- condition: /* @__PURE__ */ e.jsx(Re, { className: "h-4 w-4 text-orange-500" }),
273
- parallel: /* @__PURE__ */ e.jsx(es, { className: "h-4 w-4 text-teal-500" }),
274
- delay: /* @__PURE__ */ e.jsx(me, { className: "h-4 w-4 text-gray-500" }),
275
- notification: /* @__PURE__ */ e.jsx(Ue, { className: "h-4 w-4 text-yellow-500" }),
276
- script: /* @__PURE__ */ e.jsx(ss, { className: "h-4 w-4 text-indigo-500" })
277
- }, Bs = {
278
- start: "border-green-300 bg-green-50",
279
- end: "border-red-300 bg-red-50",
280
- task: "border-blue-300 bg-blue-50",
281
- approval: "border-purple-300 bg-purple-50",
282
- condition: "border-orange-300 bg-orange-50",
283
- parallel: "border-teal-300 bg-teal-50",
284
- delay: "border-gray-300 bg-gray-50",
285
- notification: "border-yellow-300 bg-yellow-50",
286
- script: "border-indigo-300 bg-indigo-50"
287
- }, Hs = {
288
- draft: { variant: "secondary", label: "Draft" },
289
- active: { variant: "default", label: "Active" },
290
- paused: { variant: "outline", label: "Paused" },
291
- completed: { variant: "default", label: "Completed" },
292
- cancelled: { variant: "destructive", label: "Cancelled" }
293
- }, Ws = ({ schema: n }) => {
294
- const {
295
- workflow: c,
296
- readOnly: a = !1,
297
- showToolbar: d = !0
298
- } = n, [o, t] = $(c || {
299
- type: "workflow",
300
- title: "New Workflow",
301
- status: "draft",
302
- nodes: [
303
- { id: "start-1", type: "start", label: "Start", position: { x: 100, y: 100 } },
304
- { id: "end-1", type: "end", label: "End", position: { x: 100, y: 400 } }
305
- ],
306
- edges: [],
307
- variables: []
308
- }), [u, g] = $(null), [F, O] = $(null), p = Se(
309
- () => o.nodes.find((r) => r.id === u),
310
- [o.nodes, u]
311
- ), k = _((r) => {
312
- if (a) return;
313
- const j = `${r}-${Date.now()}`, P = {
314
- id: j,
315
- type: r,
316
- label: `New ${r.charAt(0).toUpperCase() + r.slice(1)}`,
317
- position: { x: 200, y: (o.nodes.length + 1) * 80 }
318
- };
319
- t((M) => ({
320
- ...M,
321
- nodes: [...M.nodes, P]
322
- })), g(j);
323
- }, [a, o.nodes.length]), v = _((r, j) => {
324
- a || t((P) => ({
325
- ...P,
326
- nodes: P.nodes.map((M) => M.id === r ? { ...M, ...j } : M)
327
- }));
328
- }, [a]), f = _((r) => {
329
- a || (t((j) => ({
330
- ...j,
331
- nodes: j.nodes.filter((P) => P.id !== r),
332
- edges: j.edges.filter((P) => P.source !== r && P.target !== r)
333
- })), u === r && g(null));
334
- }, [a, u]), L = _((r, j) => {
335
- if (a) return;
336
- const M = { id: `edge-${Date.now()}`, source: r, target: j };
337
- t((ue) => ({
338
- ...ue,
339
- edges: [...ue.edges, M]
340
- }));
341
- }, [a]), de = _((r) => {
342
- a || (t((j) => ({
343
- ...j,
344
- edges: j.edges.filter((P) => P.id !== r)
345
- })), F === r && O(null));
346
- }, [a, F]), i = () => {
347
- console.log("Saving workflow:", o), n.onSave;
348
- }, b = () => {
349
- t((r) => ({ ...r, status: "active" })), console.log("Publishing workflow"), n.onPublish;
350
- }, R = Hs[o.status || "draft"], C = ["task", "approval", "condition", "parallel", "delay", "notification", "script"];
351
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
352
- d && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border", children: [
353
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
354
- /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(
355
- S,
356
- {
357
- value: o.title || "",
358
- onChange: (r) => t((j) => ({ ...j, title: r.target.value })),
359
- className: "text-lg font-semibold border-none p-0 h-auto focus-visible:ring-0",
360
- readOnly: a,
361
- placeholder: "Workflow Title"
362
- }
363
- ) }),
364
- /* @__PURE__ */ e.jsx(I, { variant: R.variant, children: R.label })
365
- ] }),
366
- !a && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
367
- /* @__PURE__ */ e.jsxs(T, { variant: "outline", size: "sm", onClick: i, children: [
368
- /* @__PURE__ */ e.jsx(Qe, { className: "h-4 w-4 mr-2" }),
369
- "Save"
370
- ] }),
371
- /* @__PURE__ */ e.jsxs(T, { size: "sm", onClick: b, disabled: o.status === "active", children: [
372
- /* @__PURE__ */ e.jsx(Ve, { className: "h-4 w-4 mr-2" }),
373
- "Publish"
374
- ] })
375
- ] })
376
- ] }),
377
- /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-4 gap-4", children: [
378
- !a && /* @__PURE__ */ e.jsxs(q, { className: "lg:col-span-1", children: [
379
- /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsx(Z, { className: "text-sm", children: "Add Node" }) }),
380
- /* @__PURE__ */ e.jsx(X, { className: "space-y-2", children: C.map((r) => /* @__PURE__ */ e.jsxs(
381
- "button",
382
- {
383
- onClick: () => k(r),
384
- className: "w-full flex items-center gap-2 p-2 rounded-md border hover:bg-muted/50 transition-colors text-sm",
385
- children: [
386
- Ie[r],
387
- /* @__PURE__ */ e.jsx("span", { className: "capitalize", children: r })
388
- ]
389
- },
390
- r
391
- )) })
392
- ] }),
393
- /* @__PURE__ */ e.jsxs(q, { className: a ? "lg:col-span-3" : "lg:col-span-2", children: [
394
- /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsxs(Z, { className: "text-sm flex items-center gap-2", children: [
395
- /* @__PURE__ */ e.jsx(Re, { className: "h-4 w-4" }),
396
- "Workflow Flow"
397
- ] }) }),
398
- /* @__PURE__ */ e.jsx(X, { children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
399
- o.nodes.map((r) => /* @__PURE__ */ e.jsxs(
400
- "div",
401
- {
402
- onClick: () => {
403
- g(r.id), O(null);
404
- },
405
- className: `flex items-center justify-between p-3 rounded-lg border-2 cursor-pointer transition-all ${Bs[r.type]} ${u === r.id ? "ring-2 ring-primary shadow-md" : "hover:shadow-sm"}`,
406
- children: [
407
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
408
- Ie[r.type],
409
- /* @__PURE__ */ e.jsx("span", { className: "font-medium text-sm", children: r.label }),
410
- /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-muted-foreground capitalize", children: [
411
- "(",
412
- r.type,
413
- ")"
414
- ] })
415
- ] }),
416
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1", children: [
417
- o.edges.filter((j) => j.source === r.id).length > 0 && /* @__PURE__ */ e.jsxs(I, { variant: "outline", className: "text-xs", children: [
418
- o.edges.filter((j) => j.source === r.id).length,
419
- " out"
420
- ] }),
421
- !a && r.type !== "start" && r.type !== "end" && /* @__PURE__ */ e.jsx(
422
- T,
423
- {
424
- size: "sm",
425
- variant: "ghost",
426
- className: "h-6 w-6 p-0 text-red-500 hover:text-red-700",
427
- onClick: (j) => {
428
- j.stopPropagation(), f(r.id);
429
- },
430
- children: /* @__PURE__ */ e.jsx(ye, { className: "h-3 w-3" })
431
- }
432
- )
433
- ] })
434
- ]
435
- },
436
- r.id
437
- )),
438
- o.edges.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "mt-4 pt-4 border-t", children: [
439
- /* @__PURE__ */ e.jsx(h, { className: "text-xs text-muted-foreground mb-2 block", children: "Connections" }),
440
- o.edges.map((r) => {
441
- const j = o.nodes.find((M) => M.id === r.source), P = o.nodes.find((M) => M.id === r.target);
442
- return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-2 text-sm", children: [
443
- /* @__PURE__ */ e.jsx("span", { children: j?.label || r.source }),
444
- /* @__PURE__ */ e.jsx(es, { className: "h-3 w-3 text-muted-foreground" }),
445
- /* @__PURE__ */ e.jsx("span", { children: P?.label || r.target }),
446
- r.label && /* @__PURE__ */ e.jsx(I, { variant: "outline", className: "text-xs", children: r.label }),
447
- !a && /* @__PURE__ */ e.jsx(
448
- T,
449
- {
450
- size: "sm",
451
- variant: "ghost",
452
- className: "h-5 w-5 p-0 ml-auto text-red-500",
453
- onClick: () => de(r.id),
454
- children: /* @__PURE__ */ e.jsx(ye, { className: "h-3 w-3" })
455
- }
456
- )
457
- ] }, r.id);
458
- })
459
- ] }),
460
- !a && o.nodes.length >= 2 && /* @__PURE__ */ e.jsxs("div", { className: "mt-4 pt-4 border-t", children: [
461
- /* @__PURE__ */ e.jsx(h, { className: "text-xs text-muted-foreground mb-2 block", children: "Quick Connect" }),
462
- /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
463
- /* @__PURE__ */ e.jsxs(
464
- "select",
465
- {
466
- id: "edge-source",
467
- className: "border rounded-md p-1.5 text-sm bg-background",
468
- children: [
469
- /* @__PURE__ */ e.jsx("option", { value: "", children: "From..." }),
470
- o.nodes.filter((r) => r.type !== "end").map((r) => /* @__PURE__ */ e.jsx("option", { value: r.id, children: r.label }, r.id))
471
- ]
472
- }
473
- ),
474
- /* @__PURE__ */ e.jsxs(
475
- "select",
476
- {
477
- id: "edge-target",
478
- className: "border rounded-md p-1.5 text-sm bg-background",
479
- children: [
480
- /* @__PURE__ */ e.jsx("option", { value: "", children: "To..." }),
481
- o.nodes.filter((r) => r.type !== "start").map((r) => /* @__PURE__ */ e.jsx("option", { value: r.id, children: r.label }, r.id))
482
- ]
483
- }
484
- )
485
- ] }),
486
- /* @__PURE__ */ e.jsxs(
487
- T,
488
- {
489
- size: "sm",
490
- variant: "outline",
491
- className: "mt-2 w-full",
492
- onClick: () => {
493
- const r = document.getElementById("edge-source")?.value, j = document.getElementById("edge-target")?.value;
494
- r && j && r !== j && L(r, j);
495
- },
496
- children: [
497
- /* @__PURE__ */ e.jsx(Ye, { className: "h-3 w-3 mr-1" }),
498
- "Connect"
499
- ]
500
- }
501
- )
502
- ] })
503
- ] }) })
504
- ] }),
505
- /* @__PURE__ */ e.jsxs(q, { className: "lg:col-span-1", children: [
506
- /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsxs(Z, { className: "text-sm flex items-center gap-2", children: [
507
- /* @__PURE__ */ e.jsx(ze, { className: "h-4 w-4" }),
508
- "Properties"
509
- ] }) }),
510
- /* @__PURE__ */ e.jsx(X, { children: p ? /* @__PURE__ */ e.jsxs("div", { className: "space-y-3", children: [
511
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
512
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Label" }),
513
- /* @__PURE__ */ e.jsx(
514
- S,
515
- {
516
- value: p.label,
517
- onChange: (r) => v(p.id, { label: r.target.value }),
518
- className: "h-8 text-sm",
519
- readOnly: a
520
- }
521
- )
522
- ] }),
523
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
524
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Type" }),
525
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-2 rounded-md bg-muted text-sm", children: [
526
- Ie[p.type],
527
- /* @__PURE__ */ e.jsx("span", { className: "capitalize", children: p.type })
528
- ] })
529
- ] }),
530
- p.description !== void 0 && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
531
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Description" }),
532
- /* @__PURE__ */ e.jsx(
533
- S,
534
- {
535
- value: p.description || "",
536
- onChange: (r) => v(p.id, { description: r.target.value }),
537
- className: "h-8 text-sm",
538
- readOnly: a
539
- }
540
- )
541
- ] }),
542
- (p.type === "approval" || p.type === "task") && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
543
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
544
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Assignee" }),
545
- /* @__PURE__ */ e.jsx(
546
- S,
547
- {
548
- value: p.assignee || "",
549
- onChange: (r) => v(p.id, { assignee: r.target.value }),
550
- className: "h-8 text-sm",
551
- placeholder: "User, role, or expression",
552
- readOnly: a
553
- }
554
- )
555
- ] }),
556
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
557
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Assignee Type" }),
558
- /* @__PURE__ */ e.jsxs(
559
- "select",
560
- {
561
- className: "w-full border rounded-md h-8 text-sm px-2 bg-background",
562
- value: p.assigneeType || "user",
563
- onChange: (r) => v(p.id, { assigneeType: r.target.value }),
564
- disabled: a,
565
- children: [
566
- /* @__PURE__ */ e.jsx("option", { value: "user", children: "User" }),
567
- /* @__PURE__ */ e.jsx("option", { value: "role", children: "Role" }),
568
- /* @__PURE__ */ e.jsx("option", { value: "group", children: "Group" }),
569
- /* @__PURE__ */ e.jsx("option", { value: "expression", children: "Expression" })
570
- ]
571
- }
572
- )
573
- ] })
574
- ] }),
575
- p.type === "delay" && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
576
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Timeout (minutes)" }),
577
- /* @__PURE__ */ e.jsx(
578
- S,
579
- {
580
- type: "number",
581
- value: p.timeout || 60,
582
- onChange: (r) => v(p.id, { timeout: Number(r.target.value) }),
583
- className: "h-8 text-sm",
584
- readOnly: a
585
- }
586
- )
587
- ] }),
588
- /* @__PURE__ */ e.jsxs("div", { className: "text-xs text-muted-foreground mt-2", children: [
589
- "ID: ",
590
- p.id
591
- ] })
592
- ] }) : /* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground text-center py-8", children: "Select a node to edit its properties" }) })
593
- ] })
594
- ] })
595
- ] });
596
- }, qs = ({ schema: n }) => {
597
- const {
598
- currentNodeId: c,
599
- approvalRule: a,
600
- history: d = [],
601
- data: o,
602
- showHistory: t = !0,
603
- showComments: u = !0
604
- } = n, [g, F] = $(""), [O, p] = $(!1), k = (f) => {
605
- p(!0), console.log(`Approval action: ${f}`, {
606
- currentNodeId: c,
607
- comment: g,
608
- data: o
609
- }), setTimeout(() => {
610
- p(!1), F("");
611
- }, 500);
612
- }, v = (f) => {
613
- switch (f) {
614
- case "approve":
615
- case "approved":
616
- return /* @__PURE__ */ e.jsx(I, { variant: "default", className: "bg-green-500", children: "Approved" });
617
- case "reject":
618
- case "rejected":
619
- return /* @__PURE__ */ e.jsx(I, { variant: "destructive", children: "Rejected" });
620
- case "reassign":
621
- case "reassigned":
622
- return /* @__PURE__ */ e.jsx(I, { variant: "secondary", children: "Reassigned" });
623
- case "comment":
624
- return /* @__PURE__ */ e.jsx(I, { variant: "outline", children: "Comment" });
625
- case "escalate":
626
- case "escalated":
627
- return /* @__PURE__ */ e.jsx(I, { variant: "secondary", className: "bg-orange-500 text-white", children: "Escalated" });
628
- default:
629
- return /* @__PURE__ */ e.jsx(I, { variant: "outline", children: f });
630
- }
631
- };
632
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
633
- /* @__PURE__ */ e.jsxs(q, { children: [
634
- /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsxs(Z, { className: "flex items-center gap-2", children: [
635
- /* @__PURE__ */ e.jsx(me, { className: "h-5 w-5" }),
636
- "Pending Approval",
637
- a && /* @__PURE__ */ e.jsxs(I, { variant: "outline", className: "ml-2", children: [
638
- a.type === "any" && "Any approver",
639
- a.type === "all" && "All must approve",
640
- a.type === "majority" && "Majority approval",
641
- a.type === "sequential" && "Sequential"
642
- ] })
643
- ] }) }),
644
- /* @__PURE__ */ e.jsxs(X, { className: "space-y-4", children: [
645
- o && Object.keys(o).length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "p-3 bg-muted/50 rounded-lg", children: [
646
- /* @__PURE__ */ e.jsx(h, { className: "text-xs text-muted-foreground mb-2 block", children: "Request Details" }),
647
- /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-2 gap-2", children: Object.entries(o).slice(0, 6).map(([f, L]) => /* @__PURE__ */ e.jsxs("div", { className: "text-sm", children: [
648
- /* @__PURE__ */ e.jsxs("span", { className: "text-muted-foreground", children: [
649
- f,
650
- ": "
651
- ] }),
652
- /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: String(L) })
653
- ] }, f)) })
654
- ] }),
655
- u && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
656
- /* @__PURE__ */ e.jsxs(h, { className: "flex items-center gap-2 text-sm", children: [
657
- /* @__PURE__ */ e.jsx(js, { className: "h-4 w-4" }),
658
- "Comment"
659
- ] }),
660
- /* @__PURE__ */ e.jsx(
661
- S,
662
- {
663
- value: g,
664
- onChange: (f) => F(f.target.value),
665
- placeholder: "Add a comment (optional)"
666
- }
667
- )
668
- ] }),
669
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
670
- /* @__PURE__ */ e.jsxs(
671
- T,
672
- {
673
- onClick: () => k("approve"),
674
- disabled: O,
675
- className: "bg-green-600 hover:bg-green-700",
676
- children: [
677
- /* @__PURE__ */ e.jsx(fs, { className: "h-4 w-4 mr-2" }),
678
- "Approve"
679
- ]
680
- }
681
- ),
682
- /* @__PURE__ */ e.jsxs(
683
- T,
684
- {
685
- variant: "destructive",
686
- onClick: () => k("reject"),
687
- disabled: O,
688
- children: [
689
- /* @__PURE__ */ e.jsx(bs, { className: "h-4 w-4 mr-2" }),
690
- "Reject"
691
- ]
692
- }
693
- ),
694
- /* @__PURE__ */ e.jsxs(
695
- T,
696
- {
697
- variant: "outline",
698
- onClick: () => k("reassign"),
699
- disabled: O,
700
- children: [
701
- /* @__PURE__ */ e.jsx(Ns, { className: "h-4 w-4 mr-2" }),
702
- "Reassign"
703
- ]
704
- }
705
- )
706
- ] })
707
- ] })
708
- ] }),
709
- t && d.length > 0 && /* @__PURE__ */ e.jsxs(q, { children: [
710
- /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsx(Z, { className: "text-sm", children: "Approval History" }) }),
711
- /* @__PURE__ */ e.jsx(X, { children: /* @__PURE__ */ e.jsx("div", { className: "space-y-3", children: d.map((f, L) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-3 p-3 rounded-lg border", children: [
712
- /* @__PURE__ */ e.jsx("div", { className: "mt-0.5", children: /* @__PURE__ */ e.jsx(vs, { className: "h-4 w-4 text-muted-foreground" }) }),
713
- /* @__PURE__ */ e.jsxs("div", { className: "flex-1 min-w-0", children: [
714
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
715
- /* @__PURE__ */ e.jsx("span", { className: "font-medium text-sm", children: f.actorName || f.actor }),
716
- v(f.action),
717
- /* @__PURE__ */ e.jsx("span", { className: "text-xs text-muted-foreground", children: new Date(f.timestamp).toLocaleString() })
718
- ] }),
719
- f.comment && /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground mt-1", children: f.comment })
720
- ] })
721
- ] }, L)) }) })
722
- ] }),
723
- t && d.length === 0 && /* @__PURE__ */ e.jsx(q, { children: /* @__PURE__ */ e.jsx(X, { className: "p-6 text-center text-muted-foreground text-sm", children: "No approval history yet" }) })
724
- ] });
725
- }, Ge = {
726
- record_created: "Record Created",
727
- record_updated: "Record Updated",
728
- record_deleted: "Record Deleted",
729
- field_changed: "Field Changed",
730
- scheduled: "Scheduled"
731
- }, Je = {
732
- send_email: "Send Email",
733
- update_field: "Update Field",
734
- create_record: "Create Record",
735
- delete_record: "Delete Record",
736
- webhook: "Webhook",
737
- notification: "Notification"
738
- }, Xs = {
739
- send_email: /* @__PURE__ */ e.jsx(ws, { className: "h-4 w-4" }),
740
- update_field: /* @__PURE__ */ e.jsx(ys, { className: "h-4 w-4" }),
741
- create_record: /* @__PURE__ */ e.jsx(Ye, { className: "h-4 w-4" }),
742
- delete_record: /* @__PURE__ */ e.jsx(ye, { className: "h-4 w-4" }),
743
- webhook: /* @__PURE__ */ e.jsx(ts, { className: "h-4 w-4" }),
744
- notification: /* @__PURE__ */ e.jsx(Ue, { className: "h-4 w-4" })
745
- }, Ze = {
746
- equals: "Equals",
747
- not_equals: "Not Equals",
748
- contains: "Contains",
749
- greater_than: "Greater Than",
750
- less_than: "Less Than"
751
- }, Gs = () => ({
752
- id: `auto-${Date.now()}`,
753
- name: "",
754
- description: "",
755
- enabled: !0,
756
- trigger: { type: "record_created" },
757
- actions: [],
758
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
759
- }), be = ({ label: n, value: c, placeholder: a, onChange: d }) => /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
760
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: n }),
761
- /* @__PURE__ */ e.jsx(S, { value: c, onChange: (o) => d(o.target.value), placeholder: a })
762
- ] }), Js = ({
763
- automation: n,
764
- objects: c = [],
765
- onSave: a,
766
- onCancel: d,
767
- className: o
768
- }) => {
769
- const [t, u] = $(n ?? Gs()), g = _((i) => {
770
- u((b) => ({ ...b, trigger: { ...b.trigger, ...i } }));
771
- }, []), F = _(() => {
772
- u((i) => ({ ...i, actions: [...i.actions, { type: "send_email", params: {} }] }));
773
- }, []), O = _((i, b) => {
774
- u((R) => ({ ...R, actions: R.actions.map((C, r) => r === i ? { ...C, ...b } : C) }));
775
- }, []), p = _((i) => {
776
- u((b) => ({ ...b, actions: b.actions.filter((R, C) => C !== i) }));
777
- }, []), k = t.trigger.type !== "scheduled", v = t.trigger.type === "field_changed", f = t.trigger.type === "scheduled", L = c.find((i) => i.name === t.trigger.objectName)?.fields, de = (i, b) => {
778
- const R = (C, r) => O(b, { params: { ...i.params, [C]: r } });
779
- switch (i.type) {
780
- case "send_email":
781
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
782
- /* @__PURE__ */ e.jsx(be, { label: "To", value: i.params.to ?? "", placeholder: "Recipient email", onChange: (C) => R("to", C) }),
783
- /* @__PURE__ */ e.jsx(be, { label: "Subject", value: i.params.subject ?? "", placeholder: "Email subject", onChange: (C) => R("subject", C) })
784
- ] });
785
- case "webhook":
786
- return /* @__PURE__ */ e.jsx(be, { label: "URL", value: i.params.url ?? "", placeholder: "https://...", onChange: (C) => R("url", C) });
787
- case "notification":
788
- return /* @__PURE__ */ e.jsx(be, { label: "Message", value: i.params.message ?? "", placeholder: "Notification message", onChange: (C) => R("message", C) });
789
- case "update_field":
790
- case "create_record":
791
- case "delete_record":
792
- return /* @__PURE__ */ e.jsx(be, { label: "Target Object", value: i.params.objectName ?? "", placeholder: "Object name", onChange: (C) => R("objectName", C) });
793
- default:
794
- return null;
795
- }
796
- };
797
- return /* @__PURE__ */ e.jsxs("div", { className: o ?? "space-y-4", children: [
798
- /* @__PURE__ */ e.jsxs(q, { children: [
799
- /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsxs(Z, { className: "flex items-center gap-2 text-sm", children: [
800
- /* @__PURE__ */ e.jsx(Me, { className: "h-4 w-4 text-yellow-500" }),
801
- "Trigger"
802
- ] }) }),
803
- /* @__PURE__ */ e.jsxs(X, { className: "space-y-4", children: [
804
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
805
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Trigger Type" }),
806
- /* @__PURE__ */ e.jsxs(U, { value: t.trigger.type, onValueChange: (i) => g({ type: i }), children: [
807
- /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsx(H, { placeholder: "Select trigger type" }) }),
808
- /* @__PURE__ */ e.jsx(W, { children: Object.keys(Ge).map((i) => /* @__PURE__ */ e.jsx(Y, { value: i, children: Ge[i] }, i)) })
809
- ] })
810
- ] }),
811
- k && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
812
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Object" }),
813
- c.length > 0 ? /* @__PURE__ */ e.jsxs(U, { value: t.trigger.objectName ?? "", onValueChange: (i) => g({ objectName: i }), children: [
814
- /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsx(H, { placeholder: "Select object" }) }),
815
- /* @__PURE__ */ e.jsx(W, { children: c.map((i) => /* @__PURE__ */ e.jsx(Y, { value: i.name, children: i.label }, i.name)) })
816
- ] }) : /* @__PURE__ */ e.jsx(S, { value: t.trigger.objectName ?? "", onChange: (i) => g({ objectName: i.target.value }), placeholder: "Object name" })
817
- ] }),
818
- v && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
819
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Field" }),
820
- L ? /* @__PURE__ */ e.jsxs(U, { value: t.trigger.fieldName ?? "", onValueChange: (i) => g({ fieldName: i }), children: [
821
- /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsx(H, { placeholder: "Select field" }) }),
822
- /* @__PURE__ */ e.jsx(W, { children: Object.keys(L).map((i) => /* @__PURE__ */ e.jsx(Y, { value: i, children: i }, i)) })
823
- ] }) : /* @__PURE__ */ e.jsx(S, { value: t.trigger.fieldName ?? "", onChange: (i) => g({ fieldName: i.target.value }), placeholder: "Field name" })
824
- ] }),
825
- f && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
826
- /* @__PURE__ */ e.jsxs(h, { className: "text-xs flex items-center gap-1", children: [
827
- /* @__PURE__ */ e.jsx(me, { className: "h-3 w-3" }),
828
- " Cron Schedule"
829
- ] }),
830
- /* @__PURE__ */ e.jsx(S, { value: t.trigger.schedule ?? "", onChange: (i) => g({ schedule: i.target.value }), placeholder: "e.g. 0 9 * * 1-5" })
831
- ] }),
832
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
833
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Condition (optional)" }),
834
- /* @__PURE__ */ e.jsx(S, { value: t.trigger.condition ?? "", onChange: (i) => g({ condition: i.target.value }), placeholder: 'e.g. ${data.status === "active"}' })
835
- ] }),
836
- /* @__PURE__ */ e.jsx(ce, {}),
837
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-3", children: [
838
- /* @__PURE__ */ e.jsx(h, { className: "text-xs font-medium", children: "Conditional Trigger (optional)" }),
839
- /* @__PURE__ */ e.jsx("p", { className: "text-xs text-muted-foreground", children: "Run only when a field matches a specific value." }),
840
- /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 gap-2", children: [
841
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
842
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Field" }),
843
- L ? /* @__PURE__ */ e.jsxs(U, { value: t.trigger.conditionField ?? "", onValueChange: (i) => g({ conditionField: i }), children: [
844
- /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsx(H, { placeholder: "Field" }) }),
845
- /* @__PURE__ */ e.jsx(W, { children: Object.keys(L).map((i) => /* @__PURE__ */ e.jsx(Y, { value: i, children: i }, i)) })
846
- ] }) : /* @__PURE__ */ e.jsx(S, { value: t.trigger.conditionField ?? "", onChange: (i) => g({ conditionField: i.target.value }), placeholder: "e.g. status" })
847
- ] }),
848
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
849
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Operator" }),
850
- /* @__PURE__ */ e.jsxs(U, { value: t.trigger.conditionOperator ?? "equals", onValueChange: (i) => g({ conditionOperator: i }), children: [
851
- /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsx(H, { placeholder: "Operator" }) }),
852
- /* @__PURE__ */ e.jsx(W, { children: Object.keys(Ze).map((i) => /* @__PURE__ */ e.jsx(Y, { value: i, children: Ze[i] }, i)) })
853
- ] })
854
- ] }),
855
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
856
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Value" }),
857
- /* @__PURE__ */ e.jsx(S, { value: t.trigger.conditionValue ?? "", onChange: (i) => g({ conditionValue: i.target.value }), placeholder: "e.g. urgent" })
858
- ] })
859
- ] })
860
- ] })
861
- ] })
862
- ] }),
863
- /* @__PURE__ */ e.jsxs(q, { children: [
864
- /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsxs(Z, { className: "flex items-center gap-2 text-sm", children: [
865
- /* @__PURE__ */ e.jsx(ze, { className: "h-4 w-4" }),
866
- " Actions",
867
- /* @__PURE__ */ e.jsx(I, { variant: "secondary", className: "ml-auto", children: t.actions.length })
868
- ] }) }),
869
- /* @__PURE__ */ e.jsxs(X, { className: "space-y-3", children: [
870
- t.actions.length > 1 && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
871
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Execution" }),
872
- /* @__PURE__ */ e.jsxs(U, { value: t.executionMode ?? "sequential", onValueChange: (i) => u((b) => ({ ...b, executionMode: i })), children: [
873
- /* @__PURE__ */ e.jsx(B, { className: "h-7 w-36", children: /* @__PURE__ */ e.jsx(H, {}) }),
874
- /* @__PURE__ */ e.jsxs(W, { children: [
875
- /* @__PURE__ */ e.jsx(Y, { value: "sequential", children: "Sequential" }),
876
- /* @__PURE__ */ e.jsx(Y, { value: "parallel", children: "Parallel" })
877
- ] })
878
- ] })
879
- ] }),
880
- t.actions.map((i, b) => /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border p-3 space-y-3", children: [
881
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
882
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
883
- Xs[i.type],
884
- /* @__PURE__ */ e.jsx("span", { className: "text-sm font-medium", children: t.actions.length > 1 && (t.executionMode ?? "sequential") === "sequential" ? `Step ${b + 1}` : `Action ${b + 1}` }),
885
- b > 0 && t.actions.length > 1 && (t.executionMode ?? "sequential") === "sequential" && /* @__PURE__ */ e.jsx(I, { variant: "outline", className: "text-[10px] px-1", children: "then" })
886
- ] }),
887
- /* @__PURE__ */ e.jsx(T, { size: "sm", variant: "ghost", className: "h-7 w-7 p-0 text-red-500 hover:text-red-700", onClick: () => p(b), children: /* @__PURE__ */ e.jsx(ye, { className: "h-4 w-4" }) })
888
- ] }),
889
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
890
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Action Type" }),
891
- /* @__PURE__ */ e.jsxs(U, { value: i.type, onValueChange: (R) => O(b, { type: R, params: {} }), children: [
892
- /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsx(H, {}) }),
893
- /* @__PURE__ */ e.jsx(W, { children: Object.keys(Je).map((R) => /* @__PURE__ */ e.jsx(Y, { value: R, children: Je[R] }, R)) })
894
- ] })
895
- ] }),
896
- de(i, b)
897
- ] }, b)),
898
- /* @__PURE__ */ e.jsxs(T, { variant: "outline", size: "sm", className: "w-full", onClick: F, children: [
899
- /* @__PURE__ */ e.jsx(Ye, { className: "h-4 w-4 mr-2" }),
900
- " Add Action"
901
- ] })
902
- ] })
903
- ] }),
904
- /* @__PURE__ */ e.jsxs(q, { children: [
905
- /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsx(Z, { className: "text-sm", children: "Summary" }) }),
906
- /* @__PURE__ */ e.jsxs(X, { className: "space-y-4", children: [
907
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
908
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Name" }),
909
- /* @__PURE__ */ e.jsx(S, { value: t.name, onChange: (i) => u((b) => ({ ...b, name: i.target.value })), placeholder: "Automation name" })
910
- ] }),
911
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
912
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Description" }),
913
- /* @__PURE__ */ e.jsx(S, { value: t.description ?? "", onChange: (i) => u((b) => ({ ...b, description: i.target.value })), placeholder: "Optional description" })
914
- ] }),
915
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
916
- /* @__PURE__ */ e.jsx(h, { className: "text-sm", children: "Enabled" }),
917
- /* @__PURE__ */ e.jsx(ps, { checked: t.enabled, onCheckedChange: (i) => u((b) => ({ ...b, enabled: i })) })
918
- ] }),
919
- /* @__PURE__ */ e.jsx(ce, {}),
920
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 justify-end", children: [
921
- d && /* @__PURE__ */ e.jsx(T, { variant: "outline", size: "sm", onClick: d, children: "Cancel" }),
922
- /* @__PURE__ */ e.jsxs(T, { size: "sm", onClick: () => a?.(t), children: [
923
- /* @__PURE__ */ e.jsx(Me, { className: "h-4 w-4 mr-2" }),
924
- " Save Automation"
925
- ] })
926
- ] })
927
- ] })
928
- ] })
929
- ] });
930
- }, Zs = {
931
- success: "default",
932
- failure: "destructive",
933
- running: "secondary",
934
- pending: "outline"
935
- }, Ks = {
936
- success: "Success",
937
- failure: "Failed",
938
- running: "Running",
939
- pending: "Pending"
1
+ import { ComponentRegistry as e } from "@object-ui/core";
2
+ import { useCallback as t, useMemo as n, useRef as r, useState as i } from "react";
3
+ import { Badge as a, Button as o, Card as s, CardContent as c, CardHeader as l, CardTitle as u, Input as d, Label as f, Select as p, SelectContent as m, SelectItem as h, SelectTrigger as g, SelectValue as _, Separator as v, Switch as y } from "@object-ui/components";
4
+ import { AlertCircle as b, ArrowRight as x, Bell as S, Check as C, CheckCircle as w, Circle as T, Clock as E, Code as D, Download as ee, FileEdit as O, GitBranch as k, GitMerge as A, Globe as j, History as te, Link as ne, Loader2 as M, Mail as re, MessageSquare as ie, PanelRightClose as ae, PanelRightOpen as oe, Play as N, Plus as P, Redo2 as se, RefreshCw as F, RotateCcw as ce, Save as le, Settings as I, SkipForward as L, Square as R, Trash2 as z, Undo2 as ue, Upload as de, User as B, Users as V, X as H, Zap as fe, ZoomIn as pe, ZoomOut as me } from "lucide-react";
5
+ import { clsx as he } from "clsx";
6
+ import { twMerge as ge } from "tailwind-merge";
7
+ //#region \0rolldown/runtime.js
8
+ var U = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), _e = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
9
+ if (typeof require < "u") return require.apply(this, arguments);
10
+ throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
11
+ }), W = /* @__PURE__ */ U(((e) => {
12
+ var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
13
+ function r(e, n, r) {
14
+ var i = null;
15
+ if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
16
+ else r = n;
17
+ return n = r.ref, {
18
+ $$typeof: t,
19
+ type: e,
20
+ key: i,
21
+ ref: n === void 0 ? null : n,
22
+ props: r
23
+ };
24
+ }
25
+ e.Fragment = n, e.jsx = r, e.jsxs = r;
26
+ })), ve = /* @__PURE__ */ U(((e) => {
27
+ process.env.NODE_ENV !== "production" && (function() {
28
+ function t(e) {
29
+ if (e == null) return null;
30
+ if (typeof e == "function") return e.$$typeof === ee ? null : e.displayName || e.name || null;
31
+ if (typeof e == "string") return e;
32
+ switch (e) {
33
+ case _: return "Fragment";
34
+ case y: return "Profiler";
35
+ case v: return "StrictMode";
36
+ case C: return "Suspense";
37
+ case w: return "SuspenseList";
38
+ case D: return "Activity";
39
+ }
40
+ if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
41
+ case g: return "Portal";
42
+ case x: return e.displayName || "Context";
43
+ case b: return (e._context.displayName || "Context") + ".Consumer";
44
+ case S:
45
+ var n = e.render;
46
+ return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
47
+ case T: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
48
+ case E:
49
+ n = e._payload, e = e._init;
50
+ try {
51
+ return t(e(n));
52
+ } catch {}
53
+ }
54
+ return null;
55
+ }
56
+ function n(e) {
57
+ return "" + e;
58
+ }
59
+ function r(e) {
60
+ try {
61
+ n(e);
62
+ var t = !1;
63
+ } catch {
64
+ t = !0;
65
+ }
66
+ if (t) {
67
+ t = console;
68
+ var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
69
+ return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
70
+ }
71
+ }
72
+ function i(e) {
73
+ if (e === _) return "<>";
74
+ if (typeof e == "object" && e && e.$$typeof === E) return "<...>";
75
+ try {
76
+ var n = t(e);
77
+ return n ? "<" + n + ">" : "<...>";
78
+ } catch {
79
+ return "<...>";
80
+ }
81
+ }
82
+ function a() {
83
+ var e = O.A;
84
+ return e === null ? null : e.getOwner();
85
+ }
86
+ function o() {
87
+ return Error("react-stack-top-frame");
88
+ }
89
+ function s(e) {
90
+ if (k.call(e, "key")) {
91
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
92
+ if (t && t.isReactWarning) return !1;
93
+ }
94
+ return e.key !== void 0;
95
+ }
96
+ function c(e, t) {
97
+ function n() {
98
+ te || (te = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
99
+ }
100
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
101
+ get: n,
102
+ configurable: !0
103
+ });
104
+ }
105
+ function l() {
106
+ var e = t(this.type);
107
+ return ne[e] || (ne[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
108
+ }
109
+ function u(e, t, n, r, i, a) {
110
+ var o = n.ref;
111
+ return e = {
112
+ $$typeof: h,
113
+ type: e,
114
+ key: t,
115
+ props: n,
116
+ _owner: r
117
+ }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
118
+ enumerable: !1,
119
+ value: null
120
+ }) : Object.defineProperty(e, "ref", {
121
+ enumerable: !1,
122
+ get: l
123
+ }), e._store = {}, Object.defineProperty(e._store, "validated", {
124
+ configurable: !1,
125
+ enumerable: !1,
126
+ writable: !0,
127
+ value: 0
128
+ }), Object.defineProperty(e, "_debugInfo", {
129
+ configurable: !1,
130
+ enumerable: !1,
131
+ writable: !0,
132
+ value: null
133
+ }), Object.defineProperty(e, "_debugStack", {
134
+ configurable: !1,
135
+ enumerable: !1,
136
+ writable: !0,
137
+ value: i
138
+ }), Object.defineProperty(e, "_debugTask", {
139
+ configurable: !1,
140
+ enumerable: !1,
141
+ writable: !0,
142
+ value: a
143
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
144
+ }
145
+ function d(e, n, i, o, l, d) {
146
+ var p = n.children;
147
+ if (p !== void 0) if (o) if (A(p)) {
148
+ for (o = 0; o < p.length; o++) f(p[o]);
149
+ Object.freeze && Object.freeze(p);
150
+ } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
151
+ else f(p);
152
+ if (k.call(n, "key")) {
153
+ p = t(e);
154
+ var m = Object.keys(n).filter(function(e) {
155
+ return e !== "key";
156
+ });
157
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", ie[p + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, p, m, p), ie[p + o] = !0);
158
+ }
159
+ if (p = null, i !== void 0 && (r(i), p = "" + i), s(n) && (r(n.key), p = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
160
+ else i = n;
161
+ return p && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), u(e, p, i, a(), l, d);
162
+ }
163
+ function f(e) {
164
+ p(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === E && (e._payload.status === "fulfilled" ? p(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
165
+ }
166
+ function p(e) {
167
+ return typeof e == "object" && !!e && e.$$typeof === h;
168
+ }
169
+ var m = _e("react"), h = Symbol.for("react.transitional.element"), g = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), b = Symbol.for("react.consumer"), x = Symbol.for("react.context"), S = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), D = Symbol.for("react.activity"), ee = Symbol.for("react.client.reference"), O = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, k = Object.prototype.hasOwnProperty, A = Array.isArray, j = console.createTask ? console.createTask : function() {
170
+ return null;
171
+ };
172
+ m = { react_stack_bottom_frame: function(e) {
173
+ return e();
174
+ } };
175
+ var te, ne = {}, M = m.react_stack_bottom_frame.bind(m, o)(), re = j(i(o)), ie = {};
176
+ e.Fragment = _, e.jsx = function(e, t, n) {
177
+ var r = 1e4 > O.recentlyCreatedOwnerStacks++;
178
+ return d(e, t, n, !1, r ? Error("react-stack-top-frame") : M, r ? j(i(e)) : re);
179
+ }, e.jsxs = function(e, t, n) {
180
+ var r = 1e4 > O.recentlyCreatedOwnerStacks++;
181
+ return d(e, t, n, !0, r ? Error("react-stack-top-frame") : M, r ? j(i(e)) : re);
182
+ };
183
+ })();
184
+ })), G = (/* @__PURE__ */ U(((e, t) => {
185
+ process.env.NODE_ENV === "production" ? t.exports = W() : t.exports = ve();
186
+ })))(), K = {
187
+ start: /* @__PURE__ */ (0, G.jsx)(N, { className: "h-4 w-4 text-green-500" }),
188
+ end: /* @__PURE__ */ (0, G.jsx)(w, { className: "h-4 w-4 text-red-500" }),
189
+ task: /* @__PURE__ */ (0, G.jsx)(T, { className: "h-4 w-4 text-blue-500" }),
190
+ approval: /* @__PURE__ */ (0, G.jsx)(V, { className: "h-4 w-4 text-purple-500" }),
191
+ condition: /* @__PURE__ */ (0, G.jsx)(k, { className: "h-4 w-4 text-orange-500" }),
192
+ parallel: /* @__PURE__ */ (0, G.jsx)(x, { className: "h-4 w-4 text-teal-500" }),
193
+ delay: /* @__PURE__ */ (0, G.jsx)(E, { className: "h-4 w-4 text-gray-500" }),
194
+ notification: /* @__PURE__ */ (0, G.jsx)(S, { className: "h-4 w-4 text-yellow-500" }),
195
+ script: /* @__PURE__ */ (0, G.jsx)(D, { className: "h-4 w-4 text-indigo-500" })
196
+ }, ye = {
197
+ start: "border-green-300 bg-green-50",
198
+ end: "border-red-300 bg-red-50",
199
+ task: "border-blue-300 bg-blue-50",
200
+ approval: "border-purple-300 bg-purple-50",
201
+ condition: "border-orange-300 bg-orange-50",
202
+ parallel: "border-teal-300 bg-teal-50",
203
+ delay: "border-gray-300 bg-gray-50",
204
+ notification: "border-yellow-300 bg-yellow-50",
205
+ script: "border-indigo-300 bg-indigo-50"
206
+ }, q = {
207
+ draft: {
208
+ variant: "secondary",
209
+ label: "Draft"
210
+ },
211
+ active: {
212
+ variant: "default",
213
+ label: "Active"
214
+ },
215
+ paused: {
216
+ variant: "outline",
217
+ label: "Paused"
218
+ },
219
+ completed: {
220
+ variant: "default",
221
+ label: "Completed"
222
+ },
223
+ cancelled: {
224
+ variant: "destructive",
225
+ label: "Cancelled"
226
+ }
227
+ }, be = ({ schema: e }) => {
228
+ let { workflow: r, readOnly: p = !1, showToolbar: m = !0 } = e, [h, g] = i(r || {
229
+ type: "workflow",
230
+ title: "New Workflow",
231
+ status: "draft",
232
+ nodes: [{
233
+ id: "start-1",
234
+ type: "start",
235
+ label: "Start",
236
+ position: {
237
+ x: 100,
238
+ y: 100
239
+ }
240
+ }, {
241
+ id: "end-1",
242
+ type: "end",
243
+ label: "End",
244
+ position: {
245
+ x: 100,
246
+ y: 400
247
+ }
248
+ }],
249
+ edges: [],
250
+ variables: []
251
+ }), [_, v] = i(null), [y, b] = i(null), S = n(() => h.nodes.find((e) => e.id === _), [h.nodes, _]), C = t((e) => {
252
+ if (p) return;
253
+ let t = `${e}-${Date.now()}`, n = {
254
+ id: t,
255
+ type: e,
256
+ label: `New ${e.charAt(0).toUpperCase() + e.slice(1)}`,
257
+ position: {
258
+ x: 200,
259
+ y: (h.nodes.length + 1) * 80
260
+ }
261
+ };
262
+ g((e) => ({
263
+ ...e,
264
+ nodes: [...e.nodes, n]
265
+ })), v(t);
266
+ }, [p, h.nodes.length]), w = t((e, t) => {
267
+ p || g((n) => ({
268
+ ...n,
269
+ nodes: n.nodes.map((n) => n.id === e ? {
270
+ ...n,
271
+ ...t
272
+ } : n)
273
+ }));
274
+ }, [p]), T = t((e) => {
275
+ p || (g((t) => ({
276
+ ...t,
277
+ nodes: t.nodes.filter((t) => t.id !== e),
278
+ edges: t.edges.filter((t) => t.source !== e && t.target !== e)
279
+ })), _ === e && v(null));
280
+ }, [p, _]), E = t((e, t) => {
281
+ if (p) return;
282
+ let n = {
283
+ id: `edge-${Date.now()}`,
284
+ source: e,
285
+ target: t
286
+ };
287
+ g((e) => ({
288
+ ...e,
289
+ edges: [...e.edges, n]
290
+ }));
291
+ }, [p]), D = t((e) => {
292
+ p || (g((t) => ({
293
+ ...t,
294
+ edges: t.edges.filter((t) => t.id !== e)
295
+ })), y === e && b(null));
296
+ }, [p, y]), ee = () => {
297
+ console.log("Saving workflow:", h), e.onSave;
298
+ }, O = () => {
299
+ g((e) => ({
300
+ ...e,
301
+ status: "active"
302
+ })), console.log("Publishing workflow"), e.onPublish;
303
+ }, A = q[h.status || "draft"];
304
+ return /* @__PURE__ */ (0, G.jsxs)("div", {
305
+ className: "space-y-4",
306
+ children: [m && /* @__PURE__ */ (0, G.jsxs)("div", {
307
+ className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border",
308
+ children: [/* @__PURE__ */ (0, G.jsxs)("div", {
309
+ className: "flex items-center gap-3",
310
+ children: [/* @__PURE__ */ (0, G.jsx)("div", { children: /* @__PURE__ */ (0, G.jsx)(d, {
311
+ value: h.title || "",
312
+ onChange: (e) => g((t) => ({
313
+ ...t,
314
+ title: e.target.value
315
+ })),
316
+ className: "text-lg font-semibold border-none p-0 h-auto focus-visible:ring-0",
317
+ readOnly: p,
318
+ placeholder: "Workflow Title"
319
+ }) }), /* @__PURE__ */ (0, G.jsx)(a, {
320
+ variant: A.variant,
321
+ children: A.label
322
+ })]
323
+ }), !p && /* @__PURE__ */ (0, G.jsxs)("div", {
324
+ className: "flex items-center gap-2",
325
+ children: [/* @__PURE__ */ (0, G.jsxs)(o, {
326
+ variant: "outline",
327
+ size: "sm",
328
+ onClick: ee,
329
+ children: [/* @__PURE__ */ (0, G.jsx)(le, { className: "h-4 w-4 mr-2" }), "Save"]
330
+ }), /* @__PURE__ */ (0, G.jsxs)(o, {
331
+ size: "sm",
332
+ onClick: O,
333
+ disabled: h.status === "active",
334
+ children: [/* @__PURE__ */ (0, G.jsx)(N, { className: "h-4 w-4 mr-2" }), "Publish"]
335
+ })]
336
+ })]
337
+ }), /* @__PURE__ */ (0, G.jsxs)("div", {
338
+ className: "grid grid-cols-1 lg:grid-cols-4 gap-4",
339
+ children: [
340
+ !p && /* @__PURE__ */ (0, G.jsxs)(s, {
341
+ className: "lg:col-span-1",
342
+ children: [/* @__PURE__ */ (0, G.jsx)(l, { children: /* @__PURE__ */ (0, G.jsx)(u, {
343
+ className: "text-sm",
344
+ children: "Add Node"
345
+ }) }), /* @__PURE__ */ (0, G.jsx)(c, {
346
+ className: "space-y-2",
347
+ children: [
348
+ "task",
349
+ "approval",
350
+ "condition",
351
+ "parallel",
352
+ "delay",
353
+ "notification",
354
+ "script"
355
+ ].map((e) => /* @__PURE__ */ (0, G.jsxs)("button", {
356
+ onClick: () => C(e),
357
+ className: "w-full flex items-center gap-2 p-2 rounded-md border hover:bg-muted/50 transition-colors text-sm",
358
+ children: [K[e], /* @__PURE__ */ (0, G.jsx)("span", {
359
+ className: "capitalize",
360
+ children: e
361
+ })]
362
+ }, e))
363
+ })]
364
+ }),
365
+ /* @__PURE__ */ (0, G.jsxs)(s, {
366
+ className: p ? "lg:col-span-3" : "lg:col-span-2",
367
+ children: [/* @__PURE__ */ (0, G.jsx)(l, { children: /* @__PURE__ */ (0, G.jsxs)(u, {
368
+ className: "text-sm flex items-center gap-2",
369
+ children: [/* @__PURE__ */ (0, G.jsx)(k, { className: "h-4 w-4" }), "Workflow Flow"]
370
+ }) }), /* @__PURE__ */ (0, G.jsx)(c, { children: /* @__PURE__ */ (0, G.jsxs)("div", {
371
+ className: "space-y-2",
372
+ children: [
373
+ h.nodes.map((e) => /* @__PURE__ */ (0, G.jsxs)("div", {
374
+ onClick: () => {
375
+ v(e.id), b(null);
376
+ },
377
+ className: `flex items-center justify-between p-3 rounded-lg border-2 cursor-pointer transition-all ${ye[e.type]} ${_ === e.id ? "ring-2 ring-primary shadow-md" : "hover:shadow-sm"}`,
378
+ children: [/* @__PURE__ */ (0, G.jsxs)("div", {
379
+ className: "flex items-center gap-2",
380
+ children: [
381
+ K[e.type],
382
+ /* @__PURE__ */ (0, G.jsx)("span", {
383
+ className: "font-medium text-sm",
384
+ children: e.label
385
+ }),
386
+ /* @__PURE__ */ (0, G.jsxs)("span", {
387
+ className: "text-xs text-muted-foreground capitalize",
388
+ children: [
389
+ "(",
390
+ e.type,
391
+ ")"
392
+ ]
393
+ })
394
+ ]
395
+ }), /* @__PURE__ */ (0, G.jsxs)("div", {
396
+ className: "flex items-center gap-1",
397
+ children: [h.edges.filter((t) => t.source === e.id).length > 0 && /* @__PURE__ */ (0, G.jsxs)(a, {
398
+ variant: "outline",
399
+ className: "text-xs",
400
+ children: [h.edges.filter((t) => t.source === e.id).length, " out"]
401
+ }), !p && e.type !== "start" && e.type !== "end" && /* @__PURE__ */ (0, G.jsx)(o, {
402
+ size: "sm",
403
+ variant: "ghost",
404
+ className: "h-6 w-6 p-0 text-red-500 hover:text-red-700",
405
+ onClick: (t) => {
406
+ t.stopPropagation(), T(e.id);
407
+ },
408
+ children: /* @__PURE__ */ (0, G.jsx)(z, { className: "h-3 w-3" })
409
+ })]
410
+ })]
411
+ }, e.id)),
412
+ h.edges.length > 0 && /* @__PURE__ */ (0, G.jsxs)("div", {
413
+ className: "mt-4 pt-4 border-t",
414
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
415
+ className: "text-xs text-muted-foreground mb-2 block",
416
+ children: "Connections"
417
+ }), h.edges.map((e) => {
418
+ let t = h.nodes.find((t) => t.id === e.source), n = h.nodes.find((t) => t.id === e.target);
419
+ return /* @__PURE__ */ (0, G.jsxs)("div", {
420
+ className: "flex items-center gap-2 p-2 text-sm",
421
+ children: [
422
+ /* @__PURE__ */ (0, G.jsx)("span", { children: t?.label || e.source }),
423
+ /* @__PURE__ */ (0, G.jsx)(x, { className: "h-3 w-3 text-muted-foreground" }),
424
+ /* @__PURE__ */ (0, G.jsx)("span", { children: n?.label || e.target }),
425
+ e.label && /* @__PURE__ */ (0, G.jsx)(a, {
426
+ variant: "outline",
427
+ className: "text-xs",
428
+ children: e.label
429
+ }),
430
+ !p && /* @__PURE__ */ (0, G.jsx)(o, {
431
+ size: "sm",
432
+ variant: "ghost",
433
+ className: "h-5 w-5 p-0 ml-auto text-red-500",
434
+ onClick: () => D(e.id),
435
+ children: /* @__PURE__ */ (0, G.jsx)(z, { className: "h-3 w-3" })
436
+ })
437
+ ]
438
+ }, e.id);
439
+ })]
440
+ }),
441
+ !p && h.nodes.length >= 2 && /* @__PURE__ */ (0, G.jsxs)("div", {
442
+ className: "mt-4 pt-4 border-t",
443
+ children: [
444
+ /* @__PURE__ */ (0, G.jsx)(f, {
445
+ className: "text-xs text-muted-foreground mb-2 block",
446
+ children: "Quick Connect"
447
+ }),
448
+ /* @__PURE__ */ (0, G.jsxs)("div", {
449
+ className: "grid grid-cols-2 gap-2",
450
+ children: [/* @__PURE__ */ (0, G.jsxs)("select", {
451
+ id: "edge-source",
452
+ className: "border rounded-md p-1.5 text-sm bg-background",
453
+ children: [/* @__PURE__ */ (0, G.jsx)("option", {
454
+ value: "",
455
+ children: "From..."
456
+ }), h.nodes.filter((e) => e.type !== "end").map((e) => /* @__PURE__ */ (0, G.jsx)("option", {
457
+ value: e.id,
458
+ children: e.label
459
+ }, e.id))]
460
+ }), /* @__PURE__ */ (0, G.jsxs)("select", {
461
+ id: "edge-target",
462
+ className: "border rounded-md p-1.5 text-sm bg-background",
463
+ children: [/* @__PURE__ */ (0, G.jsx)("option", {
464
+ value: "",
465
+ children: "To..."
466
+ }), h.nodes.filter((e) => e.type !== "start").map((e) => /* @__PURE__ */ (0, G.jsx)("option", {
467
+ value: e.id,
468
+ children: e.label
469
+ }, e.id))]
470
+ })]
471
+ }),
472
+ /* @__PURE__ */ (0, G.jsxs)(o, {
473
+ size: "sm",
474
+ variant: "outline",
475
+ className: "mt-2 w-full",
476
+ onClick: () => {
477
+ let e = document.getElementById("edge-source")?.value, t = document.getElementById("edge-target")?.value;
478
+ e && t && e !== t && E(e, t);
479
+ },
480
+ children: [/* @__PURE__ */ (0, G.jsx)(P, { className: "h-3 w-3 mr-1" }), "Connect"]
481
+ })
482
+ ]
483
+ })
484
+ ]
485
+ }) })]
486
+ }),
487
+ /* @__PURE__ */ (0, G.jsxs)(s, {
488
+ className: "lg:col-span-1",
489
+ children: [/* @__PURE__ */ (0, G.jsx)(l, { children: /* @__PURE__ */ (0, G.jsxs)(u, {
490
+ className: "text-sm flex items-center gap-2",
491
+ children: [/* @__PURE__ */ (0, G.jsx)(I, { className: "h-4 w-4" }), "Properties"]
492
+ }) }), /* @__PURE__ */ (0, G.jsx)(c, { children: S ? /* @__PURE__ */ (0, G.jsxs)("div", {
493
+ className: "space-y-3",
494
+ children: [
495
+ /* @__PURE__ */ (0, G.jsxs)("div", {
496
+ className: "space-y-1",
497
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
498
+ className: "text-xs",
499
+ children: "Label"
500
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
501
+ value: S.label,
502
+ onChange: (e) => w(S.id, { label: e.target.value }),
503
+ className: "h-8 text-sm",
504
+ readOnly: p
505
+ })]
506
+ }),
507
+ /* @__PURE__ */ (0, G.jsxs)("div", {
508
+ className: "space-y-1",
509
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
510
+ className: "text-xs",
511
+ children: "Type"
512
+ }), /* @__PURE__ */ (0, G.jsxs)("div", {
513
+ className: "flex items-center gap-2 p-2 rounded-md bg-muted text-sm",
514
+ children: [K[S.type], /* @__PURE__ */ (0, G.jsx)("span", {
515
+ className: "capitalize",
516
+ children: S.type
517
+ })]
518
+ })]
519
+ }),
520
+ S.description !== void 0 && /* @__PURE__ */ (0, G.jsxs)("div", {
521
+ className: "space-y-1",
522
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
523
+ className: "text-xs",
524
+ children: "Description"
525
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
526
+ value: S.description || "",
527
+ onChange: (e) => w(S.id, { description: e.target.value }),
528
+ className: "h-8 text-sm",
529
+ readOnly: p
530
+ })]
531
+ }),
532
+ (S.type === "approval" || S.type === "task") && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsxs)("div", {
533
+ className: "space-y-1",
534
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
535
+ className: "text-xs",
536
+ children: "Assignee"
537
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
538
+ value: S.assignee || "",
539
+ onChange: (e) => w(S.id, { assignee: e.target.value }),
540
+ className: "h-8 text-sm",
541
+ placeholder: "User, role, or expression",
542
+ readOnly: p
543
+ })]
544
+ }), /* @__PURE__ */ (0, G.jsxs)("div", {
545
+ className: "space-y-1",
546
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
547
+ className: "text-xs",
548
+ children: "Assignee Type"
549
+ }), /* @__PURE__ */ (0, G.jsxs)("select", {
550
+ className: "w-full border rounded-md h-8 text-sm px-2 bg-background",
551
+ value: S.assigneeType || "user",
552
+ onChange: (e) => w(S.id, { assigneeType: e.target.value }),
553
+ disabled: p,
554
+ children: [
555
+ /* @__PURE__ */ (0, G.jsx)("option", {
556
+ value: "user",
557
+ children: "User"
558
+ }),
559
+ /* @__PURE__ */ (0, G.jsx)("option", {
560
+ value: "role",
561
+ children: "Role"
562
+ }),
563
+ /* @__PURE__ */ (0, G.jsx)("option", {
564
+ value: "group",
565
+ children: "Group"
566
+ }),
567
+ /* @__PURE__ */ (0, G.jsx)("option", {
568
+ value: "expression",
569
+ children: "Expression"
570
+ })
571
+ ]
572
+ })]
573
+ })] }),
574
+ S.type === "delay" && /* @__PURE__ */ (0, G.jsxs)("div", {
575
+ className: "space-y-1",
576
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
577
+ className: "text-xs",
578
+ children: "Timeout (minutes)"
579
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
580
+ type: "number",
581
+ value: S.timeout || 60,
582
+ onChange: (e) => w(S.id, { timeout: Number(e.target.value) }),
583
+ className: "h-8 text-sm",
584
+ readOnly: p
585
+ })]
586
+ }),
587
+ /* @__PURE__ */ (0, G.jsxs)("div", {
588
+ className: "text-xs text-muted-foreground mt-2",
589
+ children: ["ID: ", S.id]
590
+ })
591
+ ]
592
+ }) : /* @__PURE__ */ (0, G.jsx)("div", {
593
+ className: "text-sm text-muted-foreground text-center py-8",
594
+ children: "Select a node to edit its properties"
595
+ }) })]
596
+ })
597
+ ]
598
+ })]
599
+ });
600
+ }, xe = ({ schema: e }) => {
601
+ let { currentNodeId: t, approvalRule: n, history: r = [], data: p, showHistory: m = !0, showComments: h = !0 } = e, [g, _] = i(""), [v, y] = i(!1), b = (e) => {
602
+ y(!0), console.log(`Approval action: ${e}`, {
603
+ currentNodeId: t,
604
+ comment: g,
605
+ data: p
606
+ }), setTimeout(() => {
607
+ y(!1), _("");
608
+ }, 500);
609
+ }, x = (e) => {
610
+ switch (e) {
611
+ case "approve":
612
+ case "approved": return /* @__PURE__ */ (0, G.jsx)(a, {
613
+ variant: "default",
614
+ className: "bg-green-500",
615
+ children: "Approved"
616
+ });
617
+ case "reject":
618
+ case "rejected": return /* @__PURE__ */ (0, G.jsx)(a, {
619
+ variant: "destructive",
620
+ children: "Rejected"
621
+ });
622
+ case "reassign":
623
+ case "reassigned": return /* @__PURE__ */ (0, G.jsx)(a, {
624
+ variant: "secondary",
625
+ children: "Reassigned"
626
+ });
627
+ case "comment": return /* @__PURE__ */ (0, G.jsx)(a, {
628
+ variant: "outline",
629
+ children: "Comment"
630
+ });
631
+ case "escalate":
632
+ case "escalated": return /* @__PURE__ */ (0, G.jsx)(a, {
633
+ variant: "secondary",
634
+ className: "bg-orange-500 text-white",
635
+ children: "Escalated"
636
+ });
637
+ default: return /* @__PURE__ */ (0, G.jsx)(a, {
638
+ variant: "outline",
639
+ children: e
640
+ });
641
+ }
642
+ };
643
+ return /* @__PURE__ */ (0, G.jsxs)("div", {
644
+ className: "space-y-4",
645
+ children: [
646
+ /* @__PURE__ */ (0, G.jsxs)(s, { children: [/* @__PURE__ */ (0, G.jsx)(l, { children: /* @__PURE__ */ (0, G.jsxs)(u, {
647
+ className: "flex items-center gap-2",
648
+ children: [
649
+ /* @__PURE__ */ (0, G.jsx)(E, { className: "h-5 w-5" }),
650
+ "Pending Approval",
651
+ n && /* @__PURE__ */ (0, G.jsxs)(a, {
652
+ variant: "outline",
653
+ className: "ml-2",
654
+ children: [
655
+ n.type === "any" && "Any approver",
656
+ n.type === "all" && "All must approve",
657
+ n.type === "majority" && "Majority approval",
658
+ n.type === "sequential" && "Sequential"
659
+ ]
660
+ })
661
+ ]
662
+ }) }), /* @__PURE__ */ (0, G.jsxs)(c, {
663
+ className: "space-y-4",
664
+ children: [
665
+ p && Object.keys(p).length > 0 && /* @__PURE__ */ (0, G.jsxs)("div", {
666
+ className: "p-3 bg-muted/50 rounded-lg",
667
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
668
+ className: "text-xs text-muted-foreground mb-2 block",
669
+ children: "Request Details"
670
+ }), /* @__PURE__ */ (0, G.jsx)("div", {
671
+ className: "grid grid-cols-2 gap-2",
672
+ children: Object.entries(p).slice(0, 6).map(([e, t]) => /* @__PURE__ */ (0, G.jsxs)("div", {
673
+ className: "text-sm",
674
+ children: [/* @__PURE__ */ (0, G.jsxs)("span", {
675
+ className: "text-muted-foreground",
676
+ children: [e, ": "]
677
+ }), /* @__PURE__ */ (0, G.jsx)("span", {
678
+ className: "font-medium",
679
+ children: String(t)
680
+ })]
681
+ }, e))
682
+ })]
683
+ }),
684
+ h && /* @__PURE__ */ (0, G.jsxs)("div", {
685
+ className: "space-y-2",
686
+ children: [/* @__PURE__ */ (0, G.jsxs)(f, {
687
+ className: "flex items-center gap-2 text-sm",
688
+ children: [/* @__PURE__ */ (0, G.jsx)(ie, { className: "h-4 w-4" }), "Comment"]
689
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
690
+ value: g,
691
+ onChange: (e) => _(e.target.value),
692
+ placeholder: "Add a comment (optional)"
693
+ })]
694
+ }),
695
+ /* @__PURE__ */ (0, G.jsxs)("div", {
696
+ className: "flex items-center gap-2",
697
+ children: [
698
+ /* @__PURE__ */ (0, G.jsxs)(o, {
699
+ onClick: () => b("approve"),
700
+ disabled: v,
701
+ className: "bg-green-600 hover:bg-green-700",
702
+ children: [/* @__PURE__ */ (0, G.jsx)(C, { className: "h-4 w-4 mr-2" }), "Approve"]
703
+ }),
704
+ /* @__PURE__ */ (0, G.jsxs)(o, {
705
+ variant: "destructive",
706
+ onClick: () => b("reject"),
707
+ disabled: v,
708
+ children: [/* @__PURE__ */ (0, G.jsx)(H, { className: "h-4 w-4 mr-2" }), "Reject"]
709
+ }),
710
+ /* @__PURE__ */ (0, G.jsxs)(o, {
711
+ variant: "outline",
712
+ onClick: () => b("reassign"),
713
+ disabled: v,
714
+ children: [/* @__PURE__ */ (0, G.jsx)(F, { className: "h-4 w-4 mr-2" }), "Reassign"]
715
+ })
716
+ ]
717
+ })
718
+ ]
719
+ })] }),
720
+ m && r.length > 0 && /* @__PURE__ */ (0, G.jsxs)(s, { children: [/* @__PURE__ */ (0, G.jsx)(l, { children: /* @__PURE__ */ (0, G.jsx)(u, {
721
+ className: "text-sm",
722
+ children: "Approval History"
723
+ }) }), /* @__PURE__ */ (0, G.jsx)(c, { children: /* @__PURE__ */ (0, G.jsx)("div", {
724
+ className: "space-y-3",
725
+ children: r.map((e, t) => /* @__PURE__ */ (0, G.jsxs)("div", {
726
+ className: "flex items-start gap-3 p-3 rounded-lg border",
727
+ children: [/* @__PURE__ */ (0, G.jsx)("div", {
728
+ className: "mt-0.5",
729
+ children: /* @__PURE__ */ (0, G.jsx)(B, { className: "h-4 w-4 text-muted-foreground" })
730
+ }), /* @__PURE__ */ (0, G.jsxs)("div", {
731
+ className: "flex-1 min-w-0",
732
+ children: [/* @__PURE__ */ (0, G.jsxs)("div", {
733
+ className: "flex items-center gap-2 flex-wrap",
734
+ children: [
735
+ /* @__PURE__ */ (0, G.jsx)("span", {
736
+ className: "font-medium text-sm",
737
+ children: e.actorName || e.actor
738
+ }),
739
+ x(e.action),
740
+ /* @__PURE__ */ (0, G.jsx)("span", {
741
+ className: "text-xs text-muted-foreground",
742
+ children: new Date(e.timestamp).toLocaleString()
743
+ })
744
+ ]
745
+ }), e.comment && /* @__PURE__ */ (0, G.jsx)("p", {
746
+ className: "text-sm text-muted-foreground mt-1",
747
+ children: e.comment
748
+ })]
749
+ })]
750
+ }, t))
751
+ }) })] }),
752
+ m && r.length === 0 && /* @__PURE__ */ (0, G.jsx)(s, { children: /* @__PURE__ */ (0, G.jsx)(c, {
753
+ className: "p-6 text-center text-muted-foreground text-sm",
754
+ children: "No approval history yet"
755
+ }) })
756
+ ]
757
+ });
758
+ }, J = {
759
+ record_created: "Record Created",
760
+ record_updated: "Record Updated",
761
+ record_deleted: "Record Deleted",
762
+ field_changed: "Field Changed",
763
+ scheduled: "Scheduled"
764
+ }, Se = {
765
+ send_email: "Send Email",
766
+ update_field: "Update Field",
767
+ create_record: "Create Record",
768
+ delete_record: "Delete Record",
769
+ webhook: "Webhook",
770
+ notification: "Notification"
771
+ }, Ce = {
772
+ send_email: /* @__PURE__ */ (0, G.jsx)(re, { className: "h-4 w-4" }),
773
+ update_field: /* @__PURE__ */ (0, G.jsx)(O, { className: "h-4 w-4" }),
774
+ create_record: /* @__PURE__ */ (0, G.jsx)(P, { className: "h-4 w-4" }),
775
+ delete_record: /* @__PURE__ */ (0, G.jsx)(z, { className: "h-4 w-4" }),
776
+ webhook: /* @__PURE__ */ (0, G.jsx)(j, { className: "h-4 w-4" }),
777
+ notification: /* @__PURE__ */ (0, G.jsx)(S, { className: "h-4 w-4" })
778
+ }, we = {
779
+ equals: "Equals",
780
+ not_equals: "Not Equals",
781
+ contains: "Contains",
782
+ greater_than: "Greater Than",
783
+ less_than: "Less Than"
784
+ }, Te = () => ({
785
+ id: `auto-${Date.now()}`,
786
+ name: "",
787
+ description: "",
788
+ enabled: !0,
789
+ trigger: { type: "record_created" },
790
+ actions: [],
791
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
792
+ }), Y = ({ label: e, value: t, placeholder: n, onChange: r }) => /* @__PURE__ */ (0, G.jsxs)("div", {
793
+ className: "space-y-1",
794
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
795
+ className: "text-xs",
796
+ children: e
797
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
798
+ value: t,
799
+ onChange: (e) => r(e.target.value),
800
+ placeholder: n
801
+ })]
802
+ }), Ee = ({ automation: e, objects: n = [], onSave: r, onCancel: b, className: x }) => {
803
+ let [S, C] = i(e ?? Te()), w = t((e) => {
804
+ C((t) => ({
805
+ ...t,
806
+ trigger: {
807
+ ...t.trigger,
808
+ ...e
809
+ }
810
+ }));
811
+ }, []), T = t(() => {
812
+ C((e) => ({
813
+ ...e,
814
+ actions: [...e.actions, {
815
+ type: "send_email",
816
+ params: {}
817
+ }]
818
+ }));
819
+ }, []), D = t((e, t) => {
820
+ C((n) => ({
821
+ ...n,
822
+ actions: n.actions.map((n, r) => r === e ? {
823
+ ...n,
824
+ ...t
825
+ } : n)
826
+ }));
827
+ }, []), ee = t((e) => {
828
+ C((t) => ({
829
+ ...t,
830
+ actions: t.actions.filter((t, n) => n !== e)
831
+ }));
832
+ }, []), O = S.trigger.type !== "scheduled", k = S.trigger.type === "field_changed", A = S.trigger.type === "scheduled", j = n.find((e) => e.name === S.trigger.objectName)?.fields, te = (e, t) => {
833
+ let n = (n, r) => D(t, { params: {
834
+ ...e.params,
835
+ [n]: r
836
+ } });
837
+ switch (e.type) {
838
+ case "send_email": return /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsx)(Y, {
839
+ label: "To",
840
+ value: e.params.to ?? "",
841
+ placeholder: "Recipient email",
842
+ onChange: (e) => n("to", e)
843
+ }), /* @__PURE__ */ (0, G.jsx)(Y, {
844
+ label: "Subject",
845
+ value: e.params.subject ?? "",
846
+ placeholder: "Email subject",
847
+ onChange: (e) => n("subject", e)
848
+ })] });
849
+ case "webhook": return /* @__PURE__ */ (0, G.jsx)(Y, {
850
+ label: "URL",
851
+ value: e.params.url ?? "",
852
+ placeholder: "https://...",
853
+ onChange: (e) => n("url", e)
854
+ });
855
+ case "notification": return /* @__PURE__ */ (0, G.jsx)(Y, {
856
+ label: "Message",
857
+ value: e.params.message ?? "",
858
+ placeholder: "Notification message",
859
+ onChange: (e) => n("message", e)
860
+ });
861
+ case "update_field":
862
+ case "create_record":
863
+ case "delete_record": return /* @__PURE__ */ (0, G.jsx)(Y, {
864
+ label: "Target Object",
865
+ value: e.params.objectName ?? "",
866
+ placeholder: "Object name",
867
+ onChange: (e) => n("objectName", e)
868
+ });
869
+ default: return null;
870
+ }
871
+ };
872
+ return /* @__PURE__ */ (0, G.jsxs)("div", {
873
+ className: x ?? "space-y-4",
874
+ children: [
875
+ /* @__PURE__ */ (0, G.jsxs)(s, { children: [/* @__PURE__ */ (0, G.jsx)(l, { children: /* @__PURE__ */ (0, G.jsxs)(u, {
876
+ className: "flex items-center gap-2 text-sm",
877
+ children: [/* @__PURE__ */ (0, G.jsx)(fe, { className: "h-4 w-4 text-yellow-500" }), "Trigger"]
878
+ }) }), /* @__PURE__ */ (0, G.jsxs)(c, {
879
+ className: "space-y-4",
880
+ children: [
881
+ /* @__PURE__ */ (0, G.jsxs)("div", {
882
+ className: "space-y-1",
883
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
884
+ className: "text-xs",
885
+ children: "Trigger Type"
886
+ }), /* @__PURE__ */ (0, G.jsxs)(p, {
887
+ value: S.trigger.type,
888
+ onValueChange: (e) => w({ type: e }),
889
+ children: [/* @__PURE__ */ (0, G.jsx)(g, { children: /* @__PURE__ */ (0, G.jsx)(_, { placeholder: "Select trigger type" }) }), /* @__PURE__ */ (0, G.jsx)(m, { children: Object.keys(J).map((e) => /* @__PURE__ */ (0, G.jsx)(h, {
890
+ value: e,
891
+ children: J[e]
892
+ }, e)) })]
893
+ })]
894
+ }),
895
+ O && /* @__PURE__ */ (0, G.jsxs)("div", {
896
+ className: "space-y-1",
897
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
898
+ className: "text-xs",
899
+ children: "Object"
900
+ }), n.length > 0 ? /* @__PURE__ */ (0, G.jsxs)(p, {
901
+ value: S.trigger.objectName ?? "",
902
+ onValueChange: (e) => w({ objectName: e }),
903
+ children: [/* @__PURE__ */ (0, G.jsx)(g, { children: /* @__PURE__ */ (0, G.jsx)(_, { placeholder: "Select object" }) }), /* @__PURE__ */ (0, G.jsx)(m, { children: n.map((e) => /* @__PURE__ */ (0, G.jsx)(h, {
904
+ value: e.name,
905
+ children: e.label
906
+ }, e.name)) })]
907
+ }) : /* @__PURE__ */ (0, G.jsx)(d, {
908
+ value: S.trigger.objectName ?? "",
909
+ onChange: (e) => w({ objectName: e.target.value }),
910
+ placeholder: "Object name"
911
+ })]
912
+ }),
913
+ k && /* @__PURE__ */ (0, G.jsxs)("div", {
914
+ className: "space-y-1",
915
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
916
+ className: "text-xs",
917
+ children: "Field"
918
+ }), j ? /* @__PURE__ */ (0, G.jsxs)(p, {
919
+ value: S.trigger.fieldName ?? "",
920
+ onValueChange: (e) => w({ fieldName: e }),
921
+ children: [/* @__PURE__ */ (0, G.jsx)(g, { children: /* @__PURE__ */ (0, G.jsx)(_, { placeholder: "Select field" }) }), /* @__PURE__ */ (0, G.jsx)(m, { children: Object.keys(j).map((e) => /* @__PURE__ */ (0, G.jsx)(h, {
922
+ value: e,
923
+ children: e
924
+ }, e)) })]
925
+ }) : /* @__PURE__ */ (0, G.jsx)(d, {
926
+ value: S.trigger.fieldName ?? "",
927
+ onChange: (e) => w({ fieldName: e.target.value }),
928
+ placeholder: "Field name"
929
+ })]
930
+ }),
931
+ A && /* @__PURE__ */ (0, G.jsxs)("div", {
932
+ className: "space-y-1",
933
+ children: [/* @__PURE__ */ (0, G.jsxs)(f, {
934
+ className: "text-xs flex items-center gap-1",
935
+ children: [/* @__PURE__ */ (0, G.jsx)(E, { className: "h-3 w-3" }), " Cron Schedule"]
936
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
937
+ value: S.trigger.schedule ?? "",
938
+ onChange: (e) => w({ schedule: e.target.value }),
939
+ placeholder: "e.g. 0 9 * * 1-5"
940
+ })]
941
+ }),
942
+ /* @__PURE__ */ (0, G.jsxs)("div", {
943
+ className: "space-y-1",
944
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
945
+ className: "text-xs",
946
+ children: "Condition (optional)"
947
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
948
+ value: S.trigger.condition ?? "",
949
+ onChange: (e) => w({ condition: e.target.value }),
950
+ placeholder: "e.g. ${data.status === \"active\"}"
951
+ })]
952
+ }),
953
+ /* @__PURE__ */ (0, G.jsx)(v, {}),
954
+ /* @__PURE__ */ (0, G.jsxs)("div", {
955
+ className: "space-y-3",
956
+ children: [
957
+ /* @__PURE__ */ (0, G.jsx)(f, {
958
+ className: "text-xs font-medium",
959
+ children: "Conditional Trigger (optional)"
960
+ }),
961
+ /* @__PURE__ */ (0, G.jsx)("p", {
962
+ className: "text-xs text-muted-foreground",
963
+ children: "Run only when a field matches a specific value."
964
+ }),
965
+ /* @__PURE__ */ (0, G.jsxs)("div", {
966
+ className: "grid grid-cols-3 gap-2",
967
+ children: [
968
+ /* @__PURE__ */ (0, G.jsxs)("div", {
969
+ className: "space-y-1",
970
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
971
+ className: "text-xs",
972
+ children: "Field"
973
+ }), j ? /* @__PURE__ */ (0, G.jsxs)(p, {
974
+ value: S.trigger.conditionField ?? "",
975
+ onValueChange: (e) => w({ conditionField: e }),
976
+ children: [/* @__PURE__ */ (0, G.jsx)(g, { children: /* @__PURE__ */ (0, G.jsx)(_, { placeholder: "Field" }) }), /* @__PURE__ */ (0, G.jsx)(m, { children: Object.keys(j).map((e) => /* @__PURE__ */ (0, G.jsx)(h, {
977
+ value: e,
978
+ children: e
979
+ }, e)) })]
980
+ }) : /* @__PURE__ */ (0, G.jsx)(d, {
981
+ value: S.trigger.conditionField ?? "",
982
+ onChange: (e) => w({ conditionField: e.target.value }),
983
+ placeholder: "e.g. status"
984
+ })]
985
+ }),
986
+ /* @__PURE__ */ (0, G.jsxs)("div", {
987
+ className: "space-y-1",
988
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
989
+ className: "text-xs",
990
+ children: "Operator"
991
+ }), /* @__PURE__ */ (0, G.jsxs)(p, {
992
+ value: S.trigger.conditionOperator ?? "equals",
993
+ onValueChange: (e) => w({ conditionOperator: e }),
994
+ children: [/* @__PURE__ */ (0, G.jsx)(g, { children: /* @__PURE__ */ (0, G.jsx)(_, { placeholder: "Operator" }) }), /* @__PURE__ */ (0, G.jsx)(m, { children: Object.keys(we).map((e) => /* @__PURE__ */ (0, G.jsx)(h, {
995
+ value: e,
996
+ children: we[e]
997
+ }, e)) })]
998
+ })]
999
+ }),
1000
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1001
+ className: "space-y-1",
1002
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1003
+ className: "text-xs",
1004
+ children: "Value"
1005
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1006
+ value: S.trigger.conditionValue ?? "",
1007
+ onChange: (e) => w({ conditionValue: e.target.value }),
1008
+ placeholder: "e.g. urgent"
1009
+ })]
1010
+ })
1011
+ ]
1012
+ })
1013
+ ]
1014
+ })
1015
+ ]
1016
+ })] }),
1017
+ /* @__PURE__ */ (0, G.jsxs)(s, { children: [/* @__PURE__ */ (0, G.jsx)(l, { children: /* @__PURE__ */ (0, G.jsxs)(u, {
1018
+ className: "flex items-center gap-2 text-sm",
1019
+ children: [
1020
+ /* @__PURE__ */ (0, G.jsx)(I, { className: "h-4 w-4" }),
1021
+ " Actions",
1022
+ /* @__PURE__ */ (0, G.jsx)(a, {
1023
+ variant: "secondary",
1024
+ className: "ml-auto",
1025
+ children: S.actions.length
1026
+ })
1027
+ ]
1028
+ }) }), /* @__PURE__ */ (0, G.jsxs)(c, {
1029
+ className: "space-y-3",
1030
+ children: [
1031
+ S.actions.length > 1 && /* @__PURE__ */ (0, G.jsxs)("div", {
1032
+ className: "flex items-center gap-2 text-xs text-muted-foreground",
1033
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1034
+ className: "text-xs",
1035
+ children: "Execution"
1036
+ }), /* @__PURE__ */ (0, G.jsxs)(p, {
1037
+ value: S.executionMode ?? "sequential",
1038
+ onValueChange: (e) => C((t) => ({
1039
+ ...t,
1040
+ executionMode: e
1041
+ })),
1042
+ children: [/* @__PURE__ */ (0, G.jsx)(g, {
1043
+ className: "h-7 w-36",
1044
+ children: /* @__PURE__ */ (0, G.jsx)(_, {})
1045
+ }), /* @__PURE__ */ (0, G.jsxs)(m, { children: [/* @__PURE__ */ (0, G.jsx)(h, {
1046
+ value: "sequential",
1047
+ children: "Sequential"
1048
+ }), /* @__PURE__ */ (0, G.jsx)(h, {
1049
+ value: "parallel",
1050
+ children: "Parallel"
1051
+ })] })]
1052
+ })]
1053
+ }),
1054
+ S.actions.map((e, t) => /* @__PURE__ */ (0, G.jsxs)("div", {
1055
+ className: "rounded-lg border p-3 space-y-3",
1056
+ children: [
1057
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1058
+ className: "flex items-center justify-between",
1059
+ children: [/* @__PURE__ */ (0, G.jsxs)("div", {
1060
+ className: "flex items-center gap-2",
1061
+ children: [
1062
+ Ce[e.type],
1063
+ /* @__PURE__ */ (0, G.jsx)("span", {
1064
+ className: "text-sm font-medium",
1065
+ children: S.actions.length > 1 && (S.executionMode ?? "sequential") === "sequential" ? `Step ${t + 1}` : `Action ${t + 1}`
1066
+ }),
1067
+ t > 0 && S.actions.length > 1 && (S.executionMode ?? "sequential") === "sequential" && /* @__PURE__ */ (0, G.jsx)(a, {
1068
+ variant: "outline",
1069
+ className: "text-[10px] px-1",
1070
+ children: "then"
1071
+ })
1072
+ ]
1073
+ }), /* @__PURE__ */ (0, G.jsx)(o, {
1074
+ size: "sm",
1075
+ variant: "ghost",
1076
+ className: "h-7 w-7 p-0 text-red-500 hover:text-red-700",
1077
+ onClick: () => ee(t),
1078
+ children: /* @__PURE__ */ (0, G.jsx)(z, { className: "h-4 w-4" })
1079
+ })]
1080
+ }),
1081
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1082
+ className: "space-y-1",
1083
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1084
+ className: "text-xs",
1085
+ children: "Action Type"
1086
+ }), /* @__PURE__ */ (0, G.jsxs)(p, {
1087
+ value: e.type,
1088
+ onValueChange: (e) => D(t, {
1089
+ type: e,
1090
+ params: {}
1091
+ }),
1092
+ children: [/* @__PURE__ */ (0, G.jsx)(g, { children: /* @__PURE__ */ (0, G.jsx)(_, {}) }), /* @__PURE__ */ (0, G.jsx)(m, { children: Object.keys(Se).map((e) => /* @__PURE__ */ (0, G.jsx)(h, {
1093
+ value: e,
1094
+ children: Se[e]
1095
+ }, e)) })]
1096
+ })]
1097
+ }),
1098
+ te(e, t)
1099
+ ]
1100
+ }, t)),
1101
+ /* @__PURE__ */ (0, G.jsxs)(o, {
1102
+ variant: "outline",
1103
+ size: "sm",
1104
+ className: "w-full",
1105
+ onClick: T,
1106
+ children: [/* @__PURE__ */ (0, G.jsx)(P, { className: "h-4 w-4 mr-2" }), " Add Action"]
1107
+ })
1108
+ ]
1109
+ })] }),
1110
+ /* @__PURE__ */ (0, G.jsxs)(s, { children: [/* @__PURE__ */ (0, G.jsx)(l, { children: /* @__PURE__ */ (0, G.jsx)(u, {
1111
+ className: "text-sm",
1112
+ children: "Summary"
1113
+ }) }), /* @__PURE__ */ (0, G.jsxs)(c, {
1114
+ className: "space-y-4",
1115
+ children: [
1116
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1117
+ className: "space-y-1",
1118
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1119
+ className: "text-xs",
1120
+ children: "Name"
1121
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1122
+ value: S.name,
1123
+ onChange: (e) => C((t) => ({
1124
+ ...t,
1125
+ name: e.target.value
1126
+ })),
1127
+ placeholder: "Automation name"
1128
+ })]
1129
+ }),
1130
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1131
+ className: "space-y-1",
1132
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1133
+ className: "text-xs",
1134
+ children: "Description"
1135
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1136
+ value: S.description ?? "",
1137
+ onChange: (e) => C((t) => ({
1138
+ ...t,
1139
+ description: e.target.value
1140
+ })),
1141
+ placeholder: "Optional description"
1142
+ })]
1143
+ }),
1144
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1145
+ className: "flex items-center justify-between",
1146
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1147
+ className: "text-sm",
1148
+ children: "Enabled"
1149
+ }), /* @__PURE__ */ (0, G.jsx)(y, {
1150
+ checked: S.enabled,
1151
+ onCheckedChange: (e) => C((t) => ({
1152
+ ...t,
1153
+ enabled: e
1154
+ }))
1155
+ })]
1156
+ }),
1157
+ /* @__PURE__ */ (0, G.jsx)(v, {}),
1158
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1159
+ className: "flex items-center gap-2 justify-end",
1160
+ children: [b && /* @__PURE__ */ (0, G.jsx)(o, {
1161
+ variant: "outline",
1162
+ size: "sm",
1163
+ onClick: b,
1164
+ children: "Cancel"
1165
+ }), /* @__PURE__ */ (0, G.jsxs)(o, {
1166
+ size: "sm",
1167
+ onClick: () => r?.(S),
1168
+ children: [/* @__PURE__ */ (0, G.jsx)(fe, { className: "h-4 w-4 mr-2" }), " Save Automation"]
1169
+ })]
1170
+ })
1171
+ ]
1172
+ })] })
1173
+ ]
1174
+ });
1175
+ }, X = {
1176
+ success: "default",
1177
+ failure: "destructive",
1178
+ running: "secondary",
1179
+ pending: "outline"
1180
+ }, Z = {
1181
+ success: "Success",
1182
+ failure: "Failed",
1183
+ running: "Running",
1184
+ pending: "Pending"
940
1185
  };
941
- function Qs(n, c) {
942
- if (!c) return "—";
943
- const a = new Date(c).getTime() - new Date(n).getTime();
944
- if (a < 1e3) return `${a}ms`;
945
- const d = Math.floor(a / 1e3);
946
- if (d < 60) return `${d}s`;
947
- const o = Math.floor(d / 60), t = d % 60;
948
- return `${o}m ${t}s`;
1186
+ function De(e, t) {
1187
+ if (!t) return "—";
1188
+ let n = new Date(t).getTime() - new Date(e).getTime();
1189
+ if (n < 1e3) return `${n}ms`;
1190
+ let r = Math.floor(n / 1e3);
1191
+ return r < 60 ? `${r}s` : `${Math.floor(r / 60)}m ${r % 60}s`;
949
1192
  }
950
- const et = ({
951
- runs: n = [],
952
- className: c
953
- }) => /* @__PURE__ */ e.jsxs(q, { className: c, children: [
954
- /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsxs(Z, { className: "flex items-center gap-2 text-sm", children: [
955
- /* @__PURE__ */ e.jsx(me, { className: "h-4 w-4" }),
956
- "Automation Run History",
957
- /* @__PURE__ */ e.jsx(I, { variant: "outline", className: "ml-auto", children: n.length })
958
- ] }) }),
959
- /* @__PURE__ */ e.jsx(X, { children: n.length === 0 ? /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground text-center py-6", children: "No automation runs yet" }) : /* @__PURE__ */ e.jsx("div", { className: "space-y-2", children: n.map((a) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-3 rounded-lg border p-3", children: [
960
- /* @__PURE__ */ e.jsx(I, { variant: Zs[a.status], children: Ks[a.status] }),
961
- /* @__PURE__ */ e.jsxs("div", { className: "flex-1 min-w-0 space-y-1", children: [
962
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
963
- /* @__PURE__ */ e.jsx("span", { className: "text-sm font-medium", children: a.automationName }),
964
- a.triggerEvent && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-muted-foreground", children: [
965
- " ",
966
- a.triggerEvent
967
- ] })
968
- ] }),
969
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3 text-xs text-muted-foreground", children: [
970
- /* @__PURE__ */ e.jsx("span", { children: new Date(a.startedAt).toLocaleString() }),
971
- /* @__PURE__ */ e.jsxs("span", { children: [
972
- "Duration: ",
973
- Qs(a.startedAt, a.completedAt)
974
- ] })
975
- ] }),
976
- a.status === "failure" && a.error && /* @__PURE__ */ e.jsx("p", { className: "text-xs text-red-600 mt-1", children: a.error })
977
- ] })
978
- ] }, a.id)) }) })
979
- ] });
980
- function Le(...n) {
981
- return Vs(Ls(n));
1193
+ var Oe = ({ runs: e = [], className: t }) => /* @__PURE__ */ (0, G.jsxs)(s, {
1194
+ className: t,
1195
+ children: [/* @__PURE__ */ (0, G.jsx)(l, { children: /* @__PURE__ */ (0, G.jsxs)(u, {
1196
+ className: "flex items-center gap-2 text-sm",
1197
+ children: [
1198
+ /* @__PURE__ */ (0, G.jsx)(E, { className: "h-4 w-4" }),
1199
+ "Automation Run History",
1200
+ /* @__PURE__ */ (0, G.jsx)(a, {
1201
+ variant: "outline",
1202
+ className: "ml-auto",
1203
+ children: e.length
1204
+ })
1205
+ ]
1206
+ }) }), /* @__PURE__ */ (0, G.jsx)(c, { children: e.length === 0 ? /* @__PURE__ */ (0, G.jsx)("p", {
1207
+ className: "text-sm text-muted-foreground text-center py-6",
1208
+ children: "No automation runs yet"
1209
+ }) : /* @__PURE__ */ (0, G.jsx)("div", {
1210
+ className: "space-y-2",
1211
+ children: e.map((e) => /* @__PURE__ */ (0, G.jsxs)("div", {
1212
+ className: "flex items-start gap-3 rounded-lg border p-3",
1213
+ children: [/* @__PURE__ */ (0, G.jsx)(a, {
1214
+ variant: X[e.status],
1215
+ children: Z[e.status]
1216
+ }), /* @__PURE__ */ (0, G.jsxs)("div", {
1217
+ className: "flex-1 min-w-0 space-y-1",
1218
+ children: [
1219
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1220
+ className: "flex items-center gap-2 flex-wrap",
1221
+ children: [/* @__PURE__ */ (0, G.jsx)("span", {
1222
+ className: "text-sm font-medium",
1223
+ children: e.automationName
1224
+ }), e.triggerEvent && /* @__PURE__ */ (0, G.jsxs)("span", {
1225
+ className: "text-xs text-muted-foreground",
1226
+ children: ["— ", e.triggerEvent]
1227
+ })]
1228
+ }),
1229
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1230
+ className: "flex items-center gap-3 text-xs text-muted-foreground",
1231
+ children: [/* @__PURE__ */ (0, G.jsx)("span", { children: new Date(e.startedAt).toLocaleString() }), /* @__PURE__ */ (0, G.jsxs)("span", { children: ["Duration: ", De(e.startedAt, e.completedAt)] })]
1232
+ }),
1233
+ e.status === "failure" && e.error && /* @__PURE__ */ (0, G.jsx)("p", {
1234
+ className: "text-xs text-red-600 mt-1",
1235
+ children: e.error
1236
+ })
1237
+ ]
1238
+ })]
1239
+ }, e.id))
1240
+ }) })]
1241
+ });
1242
+ //#endregion
1243
+ //#region src/FlowDesigner.tsx
1244
+ function ke(...e) {
1245
+ return ge(he(e));
982
1246
  }
983
- const rs = 130, Ne = 52, ve = {
984
- start: "Start",
985
- end: "End",
986
- task: "Task",
987
- user_task: "User Task",
988
- service_task: "Service Task",
989
- script_task: "Script Task",
990
- approval: "Approval",
991
- condition: "Condition",
992
- parallel_gateway: "Parallel Gateway",
993
- join_gateway: "Join Gateway",
994
- boundary_event: "Boundary Event",
995
- delay: "Delay",
996
- notification: "Notification",
997
- webhook: "Webhook"
998
- }, ls = {
999
- start: /* @__PURE__ */ e.jsx(Ve, { className: "h-3.5 w-3.5 text-green-500" }),
1000
- end: /* @__PURE__ */ e.jsx(Is, { className: "h-3.5 w-3.5 text-red-500" }),
1001
- task: /* @__PURE__ */ e.jsx(Be, { className: "h-3.5 w-3.5 text-blue-500" }),
1002
- user_task: /* @__PURE__ */ e.jsx(Fe, { className: "h-3.5 w-3.5 text-blue-600" }),
1003
- service_task: /* @__PURE__ */ e.jsx(ze, { className: "h-3.5 w-3.5 text-blue-400" }),
1004
- script_task: /* @__PURE__ */ e.jsx(ss, { className: "h-3.5 w-3.5 text-indigo-500" }),
1005
- approval: /* @__PURE__ */ e.jsx(Fe, { className: "h-3.5 w-3.5 text-purple-500" }),
1006
- condition: /* @__PURE__ */ e.jsx(Re, { className: "h-3.5 w-3.5 text-orange-500" }),
1007
- parallel_gateway: /* @__PURE__ */ e.jsx(Re, { className: "h-3.5 w-3.5 text-teal-500" }),
1008
- join_gateway: /* @__PURE__ */ e.jsx($s, { className: "h-3.5 w-3.5 text-teal-600" }),
1009
- boundary_event: /* @__PURE__ */ e.jsx(as, { className: "h-3.5 w-3.5 text-amber-500" }),
1010
- delay: /* @__PURE__ */ e.jsx(me, { className: "h-3.5 w-3.5 text-gray-500" }),
1011
- notification: /* @__PURE__ */ e.jsx(Ue, { className: "h-3.5 w-3.5 text-yellow-500" }),
1012
- webhook: /* @__PURE__ */ e.jsx(ts, { className: "h-3.5 w-3.5 text-cyan-500" })
1013
- }, st = {
1014
- start: "border-green-400 bg-green-50 dark:bg-green-950",
1015
- end: "border-red-400 bg-red-50 dark:bg-red-950",
1016
- task: "border-blue-300 bg-blue-50 dark:bg-blue-950",
1017
- user_task: "border-blue-400 bg-blue-50 dark:bg-blue-950",
1018
- service_task: "border-blue-200 bg-slate-50 dark:bg-slate-900",
1019
- script_task: "border-indigo-300 bg-indigo-50 dark:bg-indigo-950",
1020
- approval: "border-purple-400 bg-purple-50 dark:bg-purple-950",
1021
- condition: "border-orange-400 bg-orange-50 dark:bg-orange-950",
1022
- parallel_gateway: "border-teal-400 bg-teal-50 dark:bg-teal-950",
1023
- join_gateway: "border-teal-500 bg-teal-50 dark:bg-teal-950",
1024
- boundary_event: "border-amber-400 bg-amber-50 dark:bg-amber-950 border-dashed",
1025
- delay: "border-gray-400 bg-gray-50 dark:bg-gray-900",
1026
- notification: "border-yellow-400 bg-yellow-50 dark:bg-yellow-950",
1027
- webhook: "border-cyan-400 bg-cyan-50 dark:bg-cyan-950"
1028
- }, tt = {
1029
- pending: { color: "text-muted-foreground", icon: /* @__PURE__ */ e.jsx(me, { className: "h-3 w-3" }) },
1030
- running: { color: "text-blue-500", icon: /* @__PURE__ */ e.jsx(Ms, { className: "h-3 w-3 animate-spin" }) },
1031
- completed: { color: "text-green-500", icon: /* @__PURE__ */ e.jsx(Be, { className: "h-3 w-3" }) },
1032
- failed: { color: "text-red-500", icon: /* @__PURE__ */ e.jsx(as, { className: "h-3 w-3" }) },
1033
- skipped: { color: "text-gray-400", icon: /* @__PURE__ */ e.jsx(Fs, { className: "h-3 w-3" }) }
1034
- }, at = [
1035
- "task",
1036
- "user_task",
1037
- "service_task",
1038
- "script_task",
1039
- "approval",
1040
- "condition",
1041
- "parallel_gateway",
1042
- "join_gateway",
1043
- "boundary_event",
1044
- "delay",
1045
- "notification",
1046
- "webhook"
1047
- ], rt = {
1048
- allow: "Allow (run concurrently)",
1049
- forbid: "Forbid (skip new)",
1050
- replace: "Replace (cancel existing)",
1051
- queue: "Queue (run after current)"
1052
- }, Ke = {
1053
- condition: "Condition",
1054
- manual: "Manual",
1055
- webhook: "Webhook",
1056
- timer: "Timer",
1057
- signal: "Signal"
1058
- }, lt = () => [
1059
- { id: "start-1", type: "start", label: "Start", position: { x: 80, y: 200 } },
1060
- { id: "end-1", type: "end", label: "End", position: { x: 500, y: 200 } }
1061
- ], nt = () => [];
1062
- function it(n) {
1063
- const [c, a] = $([n]), [d, o] = $(0), t = c[d], u = _((k) => {
1064
- a((v) => [...v.slice(0, d + 1), k]), o((v) => v + 1);
1065
- }, [d]), g = _(() => {
1066
- o((k) => Math.max(0, k - 1));
1067
- }, []), F = _(() => {
1068
- a((k) => (o((v) => Math.min(k.length - 1, v + 1)), k));
1069
- }, []), O = d > 0, p = d < c.length - 1;
1070
- return { current: t, push: u, undo: g, redo: F, canUndo: O, canRedo: p };
1247
+ var Q = 130, Ae = 52, $ = {
1248
+ start: "Start",
1249
+ end: "End",
1250
+ task: "Task",
1251
+ user_task: "User Task",
1252
+ service_task: "Service Task",
1253
+ script_task: "Script Task",
1254
+ approval: "Approval",
1255
+ condition: "Condition",
1256
+ parallel_gateway: "Parallel Gateway",
1257
+ join_gateway: "Join Gateway",
1258
+ boundary_event: "Boundary Event",
1259
+ delay: "Delay",
1260
+ notification: "Notification",
1261
+ webhook: "Webhook"
1262
+ }, je = {
1263
+ start: /* @__PURE__ */ (0, G.jsx)(N, { className: "h-3.5 w-3.5 text-green-500" }),
1264
+ end: /* @__PURE__ */ (0, G.jsx)(R, { className: "h-3.5 w-3.5 text-red-500" }),
1265
+ task: /* @__PURE__ */ (0, G.jsx)(w, { className: "h-3.5 w-3.5 text-blue-500" }),
1266
+ user_task: /* @__PURE__ */ (0, G.jsx)(V, { className: "h-3.5 w-3.5 text-blue-600" }),
1267
+ service_task: /* @__PURE__ */ (0, G.jsx)(I, { className: "h-3.5 w-3.5 text-blue-400" }),
1268
+ script_task: /* @__PURE__ */ (0, G.jsx)(D, { className: "h-3.5 w-3.5 text-indigo-500" }),
1269
+ approval: /* @__PURE__ */ (0, G.jsx)(V, { className: "h-3.5 w-3.5 text-purple-500" }),
1270
+ condition: /* @__PURE__ */ (0, G.jsx)(k, { className: "h-3.5 w-3.5 text-orange-500" }),
1271
+ parallel_gateway: /* @__PURE__ */ (0, G.jsx)(k, { className: "h-3.5 w-3.5 text-teal-500" }),
1272
+ join_gateway: /* @__PURE__ */ (0, G.jsx)(A, { className: "h-3.5 w-3.5 text-teal-600" }),
1273
+ boundary_event: /* @__PURE__ */ (0, G.jsx)(b, { className: "h-3.5 w-3.5 text-amber-500" }),
1274
+ delay: /* @__PURE__ */ (0, G.jsx)(E, { className: "h-3.5 w-3.5 text-gray-500" }),
1275
+ notification: /* @__PURE__ */ (0, G.jsx)(S, { className: "h-3.5 w-3.5 text-yellow-500" }),
1276
+ webhook: /* @__PURE__ */ (0, G.jsx)(j, { className: "h-3.5 w-3.5 text-cyan-500" })
1277
+ }, Me = {
1278
+ start: "border-green-400 bg-green-50 dark:bg-green-950",
1279
+ end: "border-red-400 bg-red-50 dark:bg-red-950",
1280
+ task: "border-blue-300 bg-blue-50 dark:bg-blue-950",
1281
+ user_task: "border-blue-400 bg-blue-50 dark:bg-blue-950",
1282
+ service_task: "border-blue-200 bg-slate-50 dark:bg-slate-900",
1283
+ script_task: "border-indigo-300 bg-indigo-50 dark:bg-indigo-950",
1284
+ approval: "border-purple-400 bg-purple-50 dark:bg-purple-950",
1285
+ condition: "border-orange-400 bg-orange-50 dark:bg-orange-950",
1286
+ parallel_gateway: "border-teal-400 bg-teal-50 dark:bg-teal-950",
1287
+ join_gateway: "border-teal-500 bg-teal-50 dark:bg-teal-950",
1288
+ boundary_event: "border-amber-400 bg-amber-50 dark:bg-amber-950 border-dashed",
1289
+ delay: "border-gray-400 bg-gray-50 dark:bg-gray-900",
1290
+ notification: "border-yellow-400 bg-yellow-50 dark:bg-yellow-950",
1291
+ webhook: "border-cyan-400 bg-cyan-50 dark:bg-cyan-950"
1292
+ }, Ne = {
1293
+ pending: {
1294
+ color: "text-muted-foreground",
1295
+ icon: /* @__PURE__ */ (0, G.jsx)(E, { className: "h-3 w-3" })
1296
+ },
1297
+ running: {
1298
+ color: "text-blue-500",
1299
+ icon: /* @__PURE__ */ (0, G.jsx)(M, { className: "h-3 w-3 animate-spin" })
1300
+ },
1301
+ completed: {
1302
+ color: "text-green-500",
1303
+ icon: /* @__PURE__ */ (0, G.jsx)(w, { className: "h-3 w-3" })
1304
+ },
1305
+ failed: {
1306
+ color: "text-red-500",
1307
+ icon: /* @__PURE__ */ (0, G.jsx)(b, { className: "h-3 w-3" })
1308
+ },
1309
+ skipped: {
1310
+ color: "text-gray-400",
1311
+ icon: /* @__PURE__ */ (0, G.jsx)(L, { className: "h-3 w-3" })
1312
+ }
1313
+ }, Pe = [
1314
+ "task",
1315
+ "user_task",
1316
+ "service_task",
1317
+ "script_task",
1318
+ "approval",
1319
+ "condition",
1320
+ "parallel_gateway",
1321
+ "join_gateway",
1322
+ "boundary_event",
1323
+ "delay",
1324
+ "notification",
1325
+ "webhook"
1326
+ ], Fe = {
1327
+ allow: "Allow (run concurrently)",
1328
+ forbid: "Forbid (skip new)",
1329
+ replace: "Replace (cancel existing)",
1330
+ queue: "Queue (run after current)"
1331
+ }, Ie = {
1332
+ condition: "Condition",
1333
+ manual: "Manual",
1334
+ webhook: "Webhook",
1335
+ timer: "Timer",
1336
+ signal: "Signal"
1337
+ }, Le = () => [{
1338
+ id: "start-1",
1339
+ type: "start",
1340
+ label: "Start",
1341
+ position: {
1342
+ x: 80,
1343
+ y: 200
1344
+ }
1345
+ }, {
1346
+ id: "end-1",
1347
+ type: "end",
1348
+ label: "End",
1349
+ position: {
1350
+ x: 500,
1351
+ y: 200
1352
+ }
1353
+ }], Re = () => [];
1354
+ function ze(e) {
1355
+ let [n, r] = i([e]), [a, o] = i(0);
1356
+ return {
1357
+ current: n[a],
1358
+ push: t((e) => {
1359
+ r((t) => [...t.slice(0, a + 1), e]), o((e) => e + 1);
1360
+ }, [a]),
1361
+ undo: t(() => {
1362
+ o((e) => Math.max(0, e - 1));
1363
+ }, []),
1364
+ redo: t(() => {
1365
+ r((e) => (o((t) => Math.min(e.length - 1, t + 1)), e));
1366
+ }, []),
1367
+ canUndo: a > 0,
1368
+ canRedo: a < n.length - 1
1369
+ };
1071
1370
  }
1072
- function ot(n, c, a) {
1073
- const d = [], o = ["boundary_event"];
1074
- n.forEach((u) => {
1075
- o.includes(u.type) && d.push(`Node "${u.label}" (${u.type}) has limited BPMN mapping.`);
1076
- });
1077
- const t = [
1078
- '<?xml version="1.0" encoding="UTF-8"?>',
1079
- '<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"',
1080
- ' xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"',
1081
- ' targetNamespace="http://objectui.org/bpmn">',
1082
- ` <process id="process-1" name="${a}" isExecutable="true">`,
1083
- ...n.map((u) => ` <${ct(u.type)} id="${u.id}" name="${u.label}" />`),
1084
- ...c.map((u) => ` <sequenceFlow ${[
1085
- `id="${u.id}"`,
1086
- `sourceRef="${u.source}"`,
1087
- `targetRef="${u.target}"`,
1088
- u.condition ? `conditionExpression="${u.condition}"` : ""
1089
- ].filter(Boolean).join(" ")} />`),
1090
- " </process>",
1091
- "</definitions>"
1092
- ].join(`
1093
- `);
1094
- return {
1095
- success: !0,
1096
- nodeCount: n.length,
1097
- edgeCount: c.length,
1098
- warnings: d.length ? d : void 0,
1099
- bpmnXml: t
1100
- };
1371
+ function Be(e, t, n) {
1372
+ let r = [], i = ["boundary_event"];
1373
+ e.forEach((e) => {
1374
+ i.includes(e.type) && r.push(`Node "${e.label}" (${e.type}) has limited BPMN mapping.`);
1375
+ });
1376
+ let a = [
1377
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
1378
+ "<definitions xmlns=\"http://www.omg.org/spec/BPMN/20100524/MODEL\"",
1379
+ " xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\"",
1380
+ " targetNamespace=\"http://objectui.org/bpmn\">",
1381
+ ` <process id="process-1" name="${n}" isExecutable="true">`,
1382
+ ...e.map((e) => ` <${Ve(e.type)} id="${e.id}" name="${e.label}" />`),
1383
+ ...t.map((e) => ` <sequenceFlow ${[
1384
+ `id="${e.id}"`,
1385
+ `sourceRef="${e.source}"`,
1386
+ `targetRef="${e.target}"`,
1387
+ e.condition ? `conditionExpression="${e.condition}"` : ""
1388
+ ].filter(Boolean).join(" ")} />`),
1389
+ " </process>",
1390
+ "</definitions>"
1391
+ ].join("\n");
1392
+ return {
1393
+ success: !0,
1394
+ nodeCount: e.length,
1395
+ edgeCount: t.length,
1396
+ warnings: r.length ? r : void 0,
1397
+ bpmnXml: a
1398
+ };
1101
1399
  }
1102
- function ct(n) {
1103
- return {
1104
- start: "startEvent",
1105
- end: "endEvent",
1106
- task: "task",
1107
- user_task: "userTask",
1108
- service_task: "serviceTask",
1109
- script_task: "scriptTask",
1110
- approval: "userTask",
1111
- condition: "exclusiveGateway",
1112
- parallel_gateway: "parallelGateway",
1113
- join_gateway: "parallelGateway",
1114
- boundary_event: "boundaryEvent",
1115
- delay: "intermediateCatchEvent",
1116
- notification: "sendTask",
1117
- webhook: "serviceTask"
1118
- }[n] ?? "task";
1400
+ function Ve(e) {
1401
+ return {
1402
+ start: "startEvent",
1403
+ end: "endEvent",
1404
+ task: "task",
1405
+ user_task: "userTask",
1406
+ service_task: "serviceTask",
1407
+ script_task: "scriptTask",
1408
+ approval: "userTask",
1409
+ condition: "exclusiveGateway",
1410
+ parallel_gateway: "parallelGateway",
1411
+ join_gateway: "parallelGateway",
1412
+ boundary_event: "boundaryEvent",
1413
+ delay: "intermediateCatchEvent",
1414
+ notification: "sendTask",
1415
+ webhook: "serviceTask"
1416
+ }[e] ?? "task";
1119
1417
  }
1120
- function dt(n, c) {
1121
- const a = n.position.x + rs, d = n.position.y + Ne / 2, o = c.position.x, t = c.position.y + Ne / 2, u = (a + o) / 2;
1122
- return { d: `M ${a} ${d} C ${u} ${d}, ${u} ${t}, ${o} ${t}`, labelX: u, labelY: (d + t) / 2 - 8 };
1418
+ function He(e, t) {
1419
+ let n = e.position.x + Q, r = e.position.y + Ae / 2, i = t.position.x, a = t.position.y + Ae / 2, o = (n + i) / 2;
1420
+ return {
1421
+ d: `M ${n} ${r} C ${o} ${r}, ${o} ${a}, ${i} ${a}`,
1422
+ labelX: o,
1423
+ labelY: (r + a) / 2 - 8
1424
+ };
1123
1425
  }
1124
- const ut = ({
1125
- node: n,
1126
- isSelected: c,
1127
- isConnectSource: a,
1128
- connectMode: d,
1129
- readOnly: o,
1130
- showExecutionOverlay: t,
1131
- onSelect: u,
1132
- onDelete: g,
1133
- onDragStart: F,
1134
- onPortClick: O
1135
- }) => {
1136
- const p = n.executionStatus, k = p ? tt[p] : null;
1137
- return /* @__PURE__ */ e.jsxs(
1138
- "div",
1139
- {
1140
- className: "absolute select-none",
1141
- style: { left: n.position.x, top: n.position.y },
1142
- draggable: !o && !d,
1143
- onDragStart: (v) => F(v, n.id),
1144
- onClick: (v) => u(n.id, v.shiftKey),
1145
- role: "group",
1146
- "aria-label": n.label,
1147
- children: [
1148
- /* @__PURE__ */ e.jsxs(
1149
- "div",
1150
- {
1151
- className: Le(
1152
- "flex items-center gap-2 border-2 rounded px-3 py-2 min-h-[52px] transition-shadow cursor-pointer",
1153
- st[n.type],
1154
- c && "ring-2 ring-primary shadow-md",
1155
- a && "ring-2 ring-blue-400 shadow-lg",
1156
- d && !a && "cursor-crosshair",
1157
- t && p === "running" && "ring-2 ring-blue-400",
1158
- t && p === "failed" && "ring-2 ring-red-400",
1159
- t && p === "completed" && "ring-2 ring-green-400"
1160
- ),
1161
- style: { width: rs, minHeight: Ne },
1162
- children: [
1163
- /* @__PURE__ */ e.jsx("span", { className: "shrink-0", children: ls[n.type] }),
1164
- /* @__PURE__ */ e.jsx("span", { className: "text-xs font-medium leading-tight flex-1 truncate", children: n.label }),
1165
- t && k && /* @__PURE__ */ e.jsx("span", { className: Le("shrink-0", k.color), children: k.icon })
1166
- ]
1167
- }
1168
- ),
1169
- !o && (c || d) && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1170
- /* @__PURE__ */ e.jsx(
1171
- "div",
1172
- {
1173
- className: "absolute w-3 h-3 rounded-full bg-primary border-2 border-background shadow cursor-crosshair",
1174
- style: { right: -6, top: Ne / 2 - 6 },
1175
- title: "Connect from this node",
1176
- onClick: (v) => {
1177
- v.stopPropagation(), O(n.id);
1178
- }
1179
- }
1180
- ),
1181
- /* @__PURE__ */ e.jsx(
1182
- "div",
1183
- {
1184
- className: "absolute w-3 h-3 rounded-full bg-muted-foreground border-2 border-background shadow cursor-crosshair",
1185
- style: { left: -6, top: Ne / 2 - 6 },
1186
- title: "Connect to this node",
1187
- onClick: (v) => {
1188
- v.stopPropagation(), O(n.id);
1189
- }
1190
- }
1191
- )
1192
- ] }),
1193
- !o && c && !d && /* @__PURE__ */ e.jsx(
1194
- "button",
1195
- {
1196
- className: "absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow",
1197
- onClick: (v) => {
1198
- v.stopPropagation(), g(n.id);
1199
- },
1200
- "aria-label": `Delete node ${n.label}`,
1201
- children: /* @__PURE__ */ e.jsx(ye, { className: "h-3 w-3" })
1202
- }
1203
- )
1204
- ]
1205
- }
1206
- );
1207
- }, xt = ({
1208
- node: n,
1209
- edge: c,
1210
- readOnly: a,
1211
- onNodeChange: d,
1212
- onEdgeChange: o
1213
- }) => !n && !c ? /* @__PURE__ */ e.jsx("div", { className: "p-4 text-sm text-muted-foreground", children: "Select a node or edge to edit its properties." }) : n ? /* @__PURE__ */ e.jsxs("div", { className: "p-3 space-y-3 overflow-y-auto", children: [
1214
- /* @__PURE__ */ e.jsx("p", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide", children: "Node Properties" }),
1215
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1216
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Label" }),
1217
- /* @__PURE__ */ e.jsx(
1218
- S,
1219
- {
1220
- value: n.label,
1221
- onChange: (t) => d({ ...n, label: t.target.value }),
1222
- disabled: a,
1223
- className: "h-7 text-xs"
1224
- }
1225
- )
1226
- ] }),
1227
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1228
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Type" }),
1229
- /* @__PURE__ */ e.jsxs(
1230
- U,
1231
- {
1232
- value: n.type,
1233
- onValueChange: (t) => d({ ...n, type: t }),
1234
- disabled: a,
1235
- children: [
1236
- /* @__PURE__ */ e.jsx(B, { className: "h-7 text-xs", children: /* @__PURE__ */ e.jsx(H, {}) }),
1237
- /* @__PURE__ */ e.jsx(W, { children: Object.keys(ve).map((t) => /* @__PURE__ */ e.jsx(Y, { value: t, className: "text-xs", children: ve[t] }, t)) })
1238
- ]
1239
- }
1240
- )
1241
- ] }),
1242
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1243
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Description" }),
1244
- /* @__PURE__ */ e.jsx(
1245
- S,
1246
- {
1247
- value: n.description ?? "",
1248
- onChange: (t) => d({ ...n, description: t.target.value }),
1249
- disabled: a,
1250
- className: "h-7 text-xs",
1251
- placeholder: "Optional description"
1252
- }
1253
- )
1254
- ] }),
1255
- ["task", "user_task", "service_task", "script_task", "delay", "webhook"].includes(n.type) && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1256
- /* @__PURE__ */ e.jsx(ce, {}),
1257
- /* @__PURE__ */ e.jsx("p", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide", children: "Executor" }),
1258
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1259
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Executor Type" }),
1260
- /* @__PURE__ */ e.jsx(
1261
- S,
1262
- {
1263
- value: n.executor?.type ?? "",
1264
- onChange: (t) => d({
1265
- ...n,
1266
- executor: { ...n.executor, type: t.target.value }
1267
- }),
1268
- disabled: a,
1269
- className: "h-7 text-xs",
1270
- placeholder: "e.g. http, script, email"
1271
- }
1272
- )
1273
- ] }),
1274
- n.type === "delay" && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1275
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Wait Event Type" }),
1276
- /* @__PURE__ */ e.jsxs(
1277
- U,
1278
- {
1279
- value: n.executor?.waitEventConfig?.eventType ?? "timer",
1280
- onValueChange: (t) => d({
1281
- ...n,
1282
- executor: {
1283
- ...n.executor,
1284
- type: n.executor?.type ?? "wait",
1285
- waitEventConfig: {
1286
- ...n.executor?.waitEventConfig,
1287
- eventType: t
1288
- }
1289
- }
1290
- }),
1291
- disabled: a,
1292
- children: [
1293
- /* @__PURE__ */ e.jsx(B, { className: "h-7 text-xs", children: /* @__PURE__ */ e.jsx(H, {}) }),
1294
- /* @__PURE__ */ e.jsx(W, { children: Object.keys(Ke).map((t) => /* @__PURE__ */ e.jsx(Y, { value: t, className: "text-xs", children: Ke[t] }, t)) })
1295
- ]
1296
- }
1297
- )
1298
- ] }),
1299
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1300
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Timeout (ms)" }),
1301
- /* @__PURE__ */ e.jsx(
1302
- S,
1303
- {
1304
- type: "number",
1305
- value: n.executor?.timeoutMs ?? "",
1306
- onChange: (t) => d({
1307
- ...n,
1308
- executor: {
1309
- ...n.executor,
1310
- type: n.executor?.type ?? "",
1311
- timeoutMs: t.target.value ? Number(t.target.value) : void 0
1312
- }
1313
- }),
1314
- disabled: a,
1315
- className: "h-7 text-xs",
1316
- placeholder: "e.g. 30000"
1317
- }
1318
- )
1319
- ] })
1320
- ] }),
1321
- n.type === "boundary_event" && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1322
- /* @__PURE__ */ e.jsx(ce, {}),
1323
- /* @__PURE__ */ e.jsx("p", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide", children: "Boundary Config" }),
1324
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1325
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Attached To Node ID" }),
1326
- /* @__PURE__ */ e.jsx(
1327
- S,
1328
- {
1329
- value: n.boundaryConfig?.attachedToNodeId ?? "",
1330
- onChange: (t) => d({
1331
- ...n,
1332
- boundaryConfig: {
1333
- ...n.boundaryConfig,
1334
- attachedToNodeId: t.target.value,
1335
- eventType: n.boundaryConfig?.eventType ?? "error"
1336
- }
1337
- }),
1338
- disabled: a,
1339
- className: "h-7 text-xs",
1340
- placeholder: "Host node id"
1341
- }
1342
- )
1343
- ] }),
1344
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1345
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Event Type" }),
1346
- /* @__PURE__ */ e.jsxs(
1347
- U,
1348
- {
1349
- value: n.boundaryConfig?.eventType ?? "error",
1350
- onValueChange: (t) => d({
1351
- ...n,
1352
- boundaryConfig: {
1353
- ...n.boundaryConfig,
1354
- attachedToNodeId: n.boundaryConfig?.attachedToNodeId ?? "",
1355
- eventType: t
1356
- }
1357
- }),
1358
- disabled: a,
1359
- children: [
1360
- /* @__PURE__ */ e.jsx(B, { className: "h-7 text-xs", children: /* @__PURE__ */ e.jsx(H, {}) }),
1361
- /* @__PURE__ */ e.jsx(W, { children: ["error", "timer", "message", "signal", "compensation"].map((t) => /* @__PURE__ */ e.jsx(Y, { value: t, className: "text-xs capitalize", children: t }, t)) })
1362
- ]
1363
- }
1364
- )
1365
- ] })
1366
- ] })
1367
- ] }) : c ? /* @__PURE__ */ e.jsxs("div", { className: "p-3 space-y-3 overflow-y-auto", children: [
1368
- /* @__PURE__ */ e.jsx("p", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide", children: "Edge Properties" }),
1369
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1370
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Label" }),
1371
- /* @__PURE__ */ e.jsx(
1372
- S,
1373
- {
1374
- value: c.label ?? "",
1375
- onChange: (t) => o({ ...c, label: t.target.value }),
1376
- disabled: a,
1377
- className: "h-7 text-xs"
1378
- }
1379
- )
1380
- ] }),
1381
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1382
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Type" }),
1383
- /* @__PURE__ */ e.jsxs(
1384
- U,
1385
- {
1386
- value: c.type ?? "default",
1387
- onValueChange: (t) => o({ ...c, type: t }),
1388
- disabled: a,
1389
- children: [
1390
- /* @__PURE__ */ e.jsx(B, { className: "h-7 text-xs", children: /* @__PURE__ */ e.jsx(H, {}) }),
1391
- /* @__PURE__ */ e.jsxs(W, { children: [
1392
- /* @__PURE__ */ e.jsx(Y, { value: "default", className: "text-xs", children: "Default" }),
1393
- /* @__PURE__ */ e.jsx(Y, { value: "conditional", className: "text-xs", children: "Conditional" }),
1394
- /* @__PURE__ */ e.jsx(Y, { value: "timeout", className: "text-xs", children: "Timeout" })
1395
- ] })
1396
- ]
1397
- }
1398
- )
1399
- ] }),
1400
- c.type === "conditional" && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1401
- /* @__PURE__ */ e.jsx(h, { className: "text-xs", children: "Condition Expression" }),
1402
- /* @__PURE__ */ e.jsx(
1403
- S,
1404
- {
1405
- value: c.condition ?? "",
1406
- onChange: (t) => o({ ...c, condition: t.target.value }),
1407
- disabled: a,
1408
- className: "h-7 text-xs font-mono",
1409
- placeholder: "e.g. status === 'approved'"
1410
- }
1411
- )
1412
- ] }),
1413
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1414
- /* @__PURE__ */ e.jsx(
1415
- "input",
1416
- {
1417
- type: "checkbox",
1418
- id: "edge-isDefault",
1419
- checked: c.isDefault ?? !1,
1420
- onChange: (t) => o({ ...c, isDefault: t.target.checked }),
1421
- disabled: a,
1422
- className: "h-3.5 w-3.5"
1423
- }
1424
- ),
1425
- /* @__PURE__ */ e.jsx(h, { htmlFor: "edge-isDefault", className: "text-xs", children: "Default edge (isDefault)" })
1426
- ] })
1427
- ] }) : null, mt = ({ versions: n }) => /* @__PURE__ */ e.jsxs("div", { className: "p-3 space-y-2", children: [
1428
- /* @__PURE__ */ e.jsx("p", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide", children: "Version History" }),
1429
- n.length === 0 && /* @__PURE__ */ e.jsx("p", { className: "text-xs text-muted-foreground", children: "No version history available." }),
1430
- /* @__PURE__ */ e.jsx("div", { className: "space-y-1.5", children: n.map((c) => /* @__PURE__ */ e.jsxs(
1431
- "div",
1432
- {
1433
- className: Le(
1434
- "rounded border p-2 text-xs",
1435
- c.isCurrent ? "border-primary bg-primary/5" : "border-border bg-muted/30"
1436
- ),
1437
- children: [
1438
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
1439
- /* @__PURE__ */ e.jsxs("span", { className: "font-medium", children: [
1440
- "v",
1441
- c.version
1442
- ] }),
1443
- c.isCurrent && /* @__PURE__ */ e.jsx(I, { variant: "default", className: "text-[10px] h-4", children: "Current" })
1444
- ] }),
1445
- c.changeNote && /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground mt-0.5", children: c.changeNote }),
1446
- /* @__PURE__ */ e.jsxs("p", { className: "text-muted-foreground mt-0.5", children: [
1447
- c.author && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1448
- c.author,
1449
- " · "
1450
- ] }),
1451
- new Date(c.createdAt).toLocaleDateString()
1452
- ] })
1453
- ]
1454
- },
1455
- c.version
1456
- )) })
1457
- ] }), ht = ({ schema: n, onSave: c }) => {
1458
- const {
1459
- readOnly: a = !1,
1460
- showToolbar: d = !0,
1461
- showMinimap: o = !1,
1462
- showVersionHistory: t = !1,
1463
- showExecutionOverlay: u = !1,
1464
- executionSteps: g = [],
1465
- versionHistory: F = [],
1466
- concurrencyPolicy: O,
1467
- title: p = "New Flow",
1468
- description: k = "",
1469
- status: v = "draft"
1470
- } = n, [f, L] = $(p), [de, i] = $(k), b = n.nodes ?? lt(), R = n.edges ?? nt(), { current: C, push: r, undo: j, redo: P, canUndo: M, canRedo: ue } = it({
1471
- nodes: b,
1472
- edges: R
1473
- }), N = C.nodes, E = C.edges, [G, K] = $(null), [z, ae] = $(null), [Q, re] = $(!1), [ee, le] = $(null), [xe, ke] = $(!0), [s, x] = $(t), [y, A] = $(null), [se, ne] = $(1), w = $e(null), te = Se(
1474
- () => N.find((l) => l.id === G) ?? null,
1475
- [N, G]
1476
- ), he = Se(
1477
- () => E.find((l) => l.id === z) ?? null,
1478
- [E, z]
1479
- ), pe = Se(() => {
1480
- if (!u || g.length === 0) return N;
1481
- const l = new Map(g.map((m) => [m.nodeId, m.status]));
1482
- return N.map(
1483
- (m) => l.has(m.id) ? { ...m, executionStatus: l.get(m.id) } : m
1484
- );
1485
- }, [N, u, g]), ns = _((l) => {
1486
- if (a) return;
1487
- const D = {
1488
- id: `${l}-${Date.now()}`,
1489
- type: l,
1490
- label: ve[l],
1491
- position: { x: 200, y: 80 + N.length * 70 }
1492
- };
1493
- r({ nodes: [...N, D], edges: E });
1494
- }, [a, N, E, r]), Ae = _((l) => {
1495
- if (a) return;
1496
- const m = N.filter((V) => V.id !== l), D = E.filter((V) => V.source !== l && V.target !== l);
1497
- r({ nodes: m, edges: D }), G === l && K(null);
1498
- }, [a, N, E, r, G]), is = _((l) => {
1499
- a || r({ nodes: N.map((m) => m.id === l.id ? l : m), edges: E });
1500
- }, [a, N, E, r]), He = _((l) => {
1501
- a || (r({ nodes: N, edges: E.filter((m) => m.id !== l) }), z === l && ae(null));
1502
- }, [a, N, E, r, z]), os = _((l) => {
1503
- a || r({ nodes: N, edges: E.map((m) => m.id === l.id ? l : m) });
1504
- }, [a, N, E, r]), cs = _((l) => {
1505
- if (!a) {
1506
- if (!Q) {
1507
- re(!0), le(l);
1508
- return;
1509
- }
1510
- if (ee && ee !== l) {
1511
- const D = { id: `edge-${Date.now()}`, source: ee, target: l };
1512
- r({ nodes: N, edges: [...E, D] });
1513
- }
1514
- re(!1), le(null);
1515
- }
1516
- }, [a, Q, ee, N, E, r]), Ce = $e(null), ie = $e(null), ds = _((l, m) => {
1517
- Ce.current = m;
1518
- const D = N.find((V) => V.id === m);
1519
- D && (ie.current = {
1520
- mouseX: l.clientX,
1521
- mouseY: l.clientY,
1522
- nodeX: D.position.x,
1523
- nodeY: D.position.y
1524
- }), l.dataTransfer.effectAllowed = "move";
1525
- }, [N]), us = _((l) => {
1526
- if (l.preventDefault(), !Ce.current || !ie.current || !w.current) return;
1527
- w.current.getBoundingClientRect();
1528
- const m = (l.clientX - ie.current.mouseX) / se, D = (l.clientY - ie.current.mouseY) / se, V = Math.max(0, ie.current.nodeX + m), Ee = Math.max(0, ie.current.nodeY + D), _e = Ce.current;
1529
- r({
1530
- nodes: N.map(
1531
- (oe) => oe.id === _e ? { ...oe, position: { x: V, y: Ee } } : oe
1532
- ),
1533
- edges: E
1534
- }), Ce.current = null, ie.current = null;
1535
- }, [N, E, r, se]), xs = _(() => {
1536
- const l = ot(N, E, f);
1537
- A(l);
1538
- const m = new Blob([l.bpmnXml ?? ""], { type: "application/xml" }), D = URL.createObjectURL(m), V = document.createElement("a");
1539
- V.href = D, V.download = `${f.replace(/\s+/g, "-").toLowerCase()}.bpmn`, V.click(), URL.revokeObjectURL(D);
1540
- }, [N, E, f]), Pe = _(() => {
1541
- c?.(N, E);
1542
- }, [N, E, c]), ms = _((l) => {
1543
- const m = l.ctrlKey || l.metaKey;
1544
- if (m && l.key === "z" && !l.shiftKey) {
1545
- l.preventDefault(), j();
1546
- return;
1547
- }
1548
- if (m && (l.key === "y" || l.key === "z" && l.shiftKey)) {
1549
- l.preventDefault(), P();
1550
- return;
1551
- }
1552
- if (m && l.key === "s") {
1553
- l.preventDefault(), Pe();
1554
- return;
1555
- }
1556
- l.key === "Escape" && (re(!1), le(null), K(null), ae(null)), (l.key === "Delete" || l.key === "Backspace") && (G ? Ae(G) : z && He(z));
1557
- }, [j, P, Pe, G, z, Ae, He]);
1558
- return /* @__PURE__ */ e.jsxs(q, { className: "flex flex-col h-full min-h-[600px] outline-none", tabIndex: 0, onKeyDown: ms, children: [
1559
- /* @__PURE__ */ e.jsx(J, { className: "py-2 px-4 border-b flex-shrink-0", children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [
1560
- /* @__PURE__ */ e.jsx(Me, { className: "h-4 w-4 text-primary shrink-0" }),
1561
- /* @__PURE__ */ e.jsx(Z, { className: "text-sm font-semibold", children: a ? /* @__PURE__ */ e.jsx("span", { children: f }) : /* @__PURE__ */ e.jsx(
1562
- S,
1563
- {
1564
- value: f,
1565
- onChange: (l) => L(l.target.value),
1566
- className: "h-6 text-sm font-semibold border-0 p-0 focus-visible:ring-0 bg-transparent",
1567
- "aria-label": "Flow title"
1568
- }
1569
- ) }),
1570
- /* @__PURE__ */ e.jsx(I, { variant: "outline", className: "text-xs capitalize", children: v }),
1571
- O && /* @__PURE__ */ e.jsx(I, { variant: "secondary", className: "text-xs", children: rt[O] }),
1572
- /* @__PURE__ */ e.jsxs("div", { className: "ml-auto flex items-center gap-1", children: [
1573
- !a && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1574
- /* @__PURE__ */ e.jsx(T, { size: "icon", variant: "ghost", className: "h-7 w-7", onClick: j, disabled: !M, title: "Undo (Ctrl+Z)", children: /* @__PURE__ */ e.jsx(ks, { className: "h-4 w-4" }) }),
1575
- /* @__PURE__ */ e.jsx(T, { size: "icon", variant: "ghost", className: "h-7 w-7", onClick: P, disabled: !ue, title: "Redo (Ctrl+Y)", children: /* @__PURE__ */ e.jsx(Cs, { className: "h-4 w-4" }) }),
1576
- /* @__PURE__ */ e.jsx(ce, { orientation: "vertical", className: "h-5 mx-1" })
1577
- ] }),
1578
- /* @__PURE__ */ e.jsx(T, { size: "icon", variant: "ghost", className: "h-7 w-7", onClick: () => ne((l) => Math.min(2, l + 0.1)), title: "Zoom in", children: /* @__PURE__ */ e.jsx(Es, { className: "h-4 w-4" }) }),
1579
- /* @__PURE__ */ e.jsx(T, { size: "icon", variant: "ghost", className: "h-7 w-7", onClick: () => ne(1), title: "Reset zoom", children: /* @__PURE__ */ e.jsx(_s, { className: "h-4 w-4" }) }),
1580
- /* @__PURE__ */ e.jsx(T, { size: "icon", variant: "ghost", className: "h-7 w-7", onClick: () => ne((l) => Math.max(0.3, l - 0.1)), title: "Zoom out", children: /* @__PURE__ */ e.jsx(Ts, { className: "h-4 w-4" }) }),
1581
- /* @__PURE__ */ e.jsx(ce, { orientation: "vertical", className: "h-5 mx-1" }),
1582
- F.length > 0 && /* @__PURE__ */ e.jsx(
1583
- T,
1584
- {
1585
- size: "icon",
1586
- variant: s ? "secondary" : "ghost",
1587
- className: "h-7 w-7",
1588
- onClick: () => x((l) => !l),
1589
- title: "Version history",
1590
- children: /* @__PURE__ */ e.jsx(Ss, { className: "h-4 w-4" })
1591
- }
1592
- ),
1593
- /* @__PURE__ */ e.jsx(T, { size: "icon", variant: "ghost", className: "h-7 w-7", onClick: xs, title: "Export BPMN", children: /* @__PURE__ */ e.jsx(Rs, { className: "h-4 w-4" }) }),
1594
- !a && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1595
- /* @__PURE__ */ e.jsx(T, { size: "icon", variant: "ghost", className: "h-7 w-7", title: "Import BPMN (drag & drop)", children: /* @__PURE__ */ e.jsx(As, { className: "h-4 w-4" }) }),
1596
- /* @__PURE__ */ e.jsxs(
1597
- T,
1598
- {
1599
- size: "sm",
1600
- variant: "default",
1601
- className: "h-7 text-xs gap-1",
1602
- onClick: Pe,
1603
- title: "Save (Ctrl+S)",
1604
- children: [
1605
- /* @__PURE__ */ e.jsx(Qe, { className: "h-3.5 w-3.5" }),
1606
- " Save"
1607
- ]
1608
- }
1609
- )
1610
- ] }),
1611
- /* @__PURE__ */ e.jsx(
1612
- T,
1613
- {
1614
- size: "icon",
1615
- variant: "ghost",
1616
- className: "h-7 w-7",
1617
- onClick: () => ke((l) => !l),
1618
- title: xe ? "Hide properties" : "Show properties",
1619
- children: xe ? /* @__PURE__ */ e.jsx(Ps, { className: "h-4 w-4" }) : /* @__PURE__ */ e.jsx(Os, { className: "h-4 w-4" })
1620
- }
1621
- )
1622
- ] })
1623
- ] }) }),
1624
- /* @__PURE__ */ e.jsxs(X, { className: "flex flex-1 p-0 overflow-hidden", children: [
1625
- d && !a && /* @__PURE__ */ e.jsxs("div", { className: "w-36 border-r bg-muted/30 flex-shrink-0 overflow-y-auto py-2 px-2", children: [
1626
- /* @__PURE__ */ e.jsx("p", { className: "text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-2 px-1", children: "Add Node" }),
1627
- /* @__PURE__ */ e.jsx("div", { className: "space-y-1", children: at.map((l) => /* @__PURE__ */ e.jsxs(
1628
- "button",
1629
- {
1630
- className: "w-full flex items-center gap-2 text-xs px-2 py-1.5 rounded hover:bg-muted transition-colors text-left",
1631
- onClick: () => ns(l),
1632
- title: `Add ${ve[l]}`,
1633
- children: [
1634
- ls[l],
1635
- /* @__PURE__ */ e.jsx("span", { className: "truncate", children: ve[l] })
1636
- ]
1637
- },
1638
- l
1639
- )) }),
1640
- Q && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1641
- /* @__PURE__ */ e.jsx(ce, { className: "my-2" }),
1642
- /* @__PURE__ */ e.jsxs("div", { className: "px-1", children: [
1643
- /* @__PURE__ */ e.jsx("p", { className: "text-[10px] text-blue-600 font-medium", children: "Connect mode" }),
1644
- /* @__PURE__ */ e.jsx("p", { className: "text-[10px] text-muted-foreground", children: "Click a target node port to connect." }),
1645
- /* @__PURE__ */ e.jsx(
1646
- T,
1647
- {
1648
- size: "sm",
1649
- variant: "outline",
1650
- className: "h-6 text-xs mt-1 w-full",
1651
- onClick: () => {
1652
- re(!1), le(null);
1653
- },
1654
- children: "Cancel"
1655
- }
1656
- )
1657
- ] })
1658
- ] })
1659
- ] }),
1660
- /* @__PURE__ */ e.jsx("div", { className: "flex-1 overflow-auto relative bg-dot-pattern", children: /* @__PURE__ */ e.jsxs(
1661
- "div",
1662
- {
1663
- ref: w,
1664
- className: "relative",
1665
- style: {
1666
- width: 1200,
1667
- height: 700,
1668
- transform: `scale(${se})`,
1669
- transformOrigin: "top left"
1670
- },
1671
- onDrop: us,
1672
- onDragOver: (l) => l.preventDefault(),
1673
- onClick: (l) => {
1674
- l.target === w.current && (K(null), ae(null));
1675
- },
1676
- children: [
1677
- /* @__PURE__ */ e.jsxs(
1678
- "svg",
1679
- {
1680
- className: "absolute inset-0 pointer-events-none",
1681
- width: 1200,
1682
- height: 700,
1683
- style: { overflow: "visible" },
1684
- children: [
1685
- /* @__PURE__ */ e.jsxs("defs", { children: [
1686
- /* @__PURE__ */ e.jsx("marker", { id: "fd-arrowhead", markerWidth: "10", markerHeight: "7", refX: "9", refY: "3.5", orient: "auto", children: /* @__PURE__ */ e.jsx("polygon", { points: "0 0, 10 3.5, 0 7", fill: "hsl(var(--foreground) / 0.5)" }) }),
1687
- /* @__PURE__ */ e.jsx("marker", { id: "fd-arrowhead-selected", markerWidth: "10", markerHeight: "7", refX: "9", refY: "3.5", orient: "auto", children: /* @__PURE__ */ e.jsx("polygon", { points: "0 0, 10 3.5, 0 7", fill: "hsl(var(--primary))" }) }),
1688
- /* @__PURE__ */ e.jsx("marker", { id: "fd-arrowhead-conditional", markerWidth: "10", markerHeight: "7", refX: "9", refY: "3.5", orient: "auto", children: /* @__PURE__ */ e.jsx("polygon", { points: "0 0, 10 3.5, 0 7", fill: "hsl(var(--foreground) / 0.6)" }) })
1689
- ] }),
1690
- E.map((l) => {
1691
- const m = pe.find((ge) => ge.id === l.source), D = pe.find((ge) => ge.id === l.target);
1692
- if (!m || !D) return null;
1693
- const { d: V, labelX: Ee, labelY: _e } = dt(m, D), oe = l.id === z, Oe = l.type === "conditional", De = l.isDefault;
1694
- return /* @__PURE__ */ e.jsxs(
1695
- "g",
1696
- {
1697
- className: "pointer-events-auto cursor-pointer",
1698
- onClick: (ge) => {
1699
- ge.stopPropagation(), ae(l.id), K(null);
1700
- },
1701
- children: [
1702
- /* @__PURE__ */ e.jsx(
1703
- "path",
1704
- {
1705
- d: V,
1706
- fill: "none",
1707
- stroke: oe ? "hsl(var(--primary))" : Oe ? "hsl(var(--foreground) / 0.6)" : "hsl(var(--foreground) / 0.4)",
1708
- strokeWidth: oe ? 2.5 : 2,
1709
- strokeDasharray: Oe ? "6 3" : De ? "3 3" : void 0,
1710
- markerEnd: `url(#fd-arrowhead${oe ? "-selected" : Oe ? "-conditional" : ""})`
1711
- }
1712
- ),
1713
- (l.label || De) && /* @__PURE__ */ e.jsx(
1714
- "text",
1715
- {
1716
- x: Ee,
1717
- y: _e,
1718
- textAnchor: "middle",
1719
- className: "text-[10px] fill-muted-foreground",
1720
- style: { fontSize: 10 },
1721
- children: l.label ?? (De ? "(default)" : "")
1722
- }
1723
- ),
1724
- l.condition && /* @__PURE__ */ e.jsx(
1725
- "text",
1726
- {
1727
- x: Ee,
1728
- y: _e + 12,
1729
- textAnchor: "middle",
1730
- className: "text-[9px] fill-orange-500",
1731
- style: { fontSize: 9 },
1732
- children: l.condition.length > 24 ? l.condition.slice(0, 24) + "…" : l.condition
1733
- }
1734
- ),
1735
- /* @__PURE__ */ e.jsx("path", { d: V, fill: "none", stroke: "transparent", strokeWidth: 12 })
1736
- ]
1737
- },
1738
- l.id
1739
- );
1740
- })
1741
- ]
1742
- }
1743
- ),
1744
- pe.map((l) => /* @__PURE__ */ e.jsx(
1745
- ut,
1746
- {
1747
- node: l,
1748
- isSelected: G === l.id,
1749
- isConnectSource: ee === l.id,
1750
- connectMode: Q,
1751
- readOnly: a,
1752
- showExecutionOverlay: u,
1753
- onSelect: (m, D) => {
1754
- D || ae(null), K(m);
1755
- },
1756
- onDelete: Ae,
1757
- onDragStart: ds,
1758
- onPortClick: cs
1759
- },
1760
- l.id
1761
- )),
1762
- Q && ee && /* @__PURE__ */ e.jsxs(
1763
- "div",
1764
- {
1765
- className: "absolute bottom-4 left-1/2 -translate-x-1/2 bg-blue-600 text-white text-xs px-3 py-1.5 rounded shadow-lg pointer-events-none",
1766
- children: [
1767
- /* @__PURE__ */ e.jsx(Ds, { className: "h-3 w-3 inline mr-1" }),
1768
- "Click a node port to complete the connection — Esc to cancel"
1769
- ]
1770
- }
1771
- ),
1772
- N.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "absolute inset-0 flex items-center justify-center text-muted-foreground text-sm", children: "No nodes yet. Use the toolbar to add nodes." })
1773
- ]
1774
- }
1775
- ) }),
1776
- s && F.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "w-48 border-l bg-background flex-shrink-0 overflow-y-auto", children: /* @__PURE__ */ e.jsx(mt, { versions: F }) }),
1777
- xe && /* @__PURE__ */ e.jsxs("div", { className: "w-52 border-l bg-background flex-shrink-0 overflow-y-auto", children: [
1778
- /* @__PURE__ */ e.jsx(
1779
- xt,
1780
- {
1781
- node: te,
1782
- edge: he,
1783
- readOnly: a,
1784
- onNodeChange: is,
1785
- onEdgeChange: os
1786
- }
1787
- ),
1788
- y && /* @__PURE__ */ e.jsxs("div", { className: "p-3 border-t", children: [
1789
- /* @__PURE__ */ e.jsx("p", { className: "text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-1", children: "BPMN Export" }),
1790
- /* @__PURE__ */ e.jsx(I, { variant: y.success ? "default" : "destructive", className: "text-[10px]", children: y.success ? `Exported ${y.nodeCount} nodes` : "Export failed" }),
1791
- y.warnings?.map((l, m) => /* @__PURE__ */ e.jsx("p", { className: "text-[10px] text-amber-600 mt-0.5", children: l }, m))
1792
- ] })
1793
- ] })
1794
- ] })
1795
- ] });
1796
- };
1797
- we.register(
1798
- "workflow-designer",
1799
- Ws,
1800
- {
1801
- label: "Workflow Designer",
1802
- category: "Enterprise",
1803
- inputs: [
1804
- { name: "workflow", type: "code", label: "Initial Workflow Definition" },
1805
- { name: "readOnly", type: "boolean", label: "Read Only", defaultValue: !1 },
1806
- { name: "showToolbar", type: "boolean", label: "Show Toolbar", defaultValue: !0 },
1807
- { name: "showMinimap", type: "boolean", label: "Show Minimap", defaultValue: !1 }
1808
- ]
1809
- }
1810
- );
1811
- we.register(
1812
- "approval-process",
1813
- qs,
1814
- {
1815
- label: "Approval Process",
1816
- category: "Enterprise",
1817
- inputs: [
1818
- { name: "workflowId", type: "string", label: "Workflow ID" },
1819
- { name: "instanceId", type: "string", label: "Instance ID" },
1820
- { name: "currentNodeId", type: "string", label: "Current Node ID" },
1821
- { name: "approvalRule", type: "code", label: "Approval Rule" },
1822
- { name: "history", type: "code", label: "History" },
1823
- { name: "showHistory", type: "boolean", label: "Show History", defaultValue: !0 },
1824
- { name: "showComments", type: "boolean", label: "Show Comments", defaultValue: !0 }
1825
- ]
1826
- }
1827
- );
1828
- we.register(
1829
- "automation-builder",
1830
- Js,
1831
- {
1832
- label: "Automation Builder",
1833
- category: "Enterprise",
1834
- inputs: [
1835
- { name: "automation", type: "code", label: "Automation Definition" },
1836
- { name: "objects", type: "code", label: "Available Objects" }
1837
- ]
1838
- }
1839
- );
1840
- we.register(
1841
- "automation-run-history",
1842
- et,
1843
- {
1844
- label: "Automation Run History",
1845
- category: "Enterprise",
1846
- inputs: [
1847
- { name: "runs", type: "code", label: "Run History" }
1848
- ]
1849
- }
1850
- );
1851
- we.register(
1852
- "flow-designer",
1853
- ht,
1854
- {
1855
- label: "Flow Designer",
1856
- category: "Enterprise",
1857
- inputs: [
1858
- { name: "nodes", type: "code", label: "Flow Nodes" },
1859
- { name: "edges", type: "code", label: "Flow Edges" },
1860
- { name: "title", type: "string", label: "Flow Title" },
1861
- { name: "readOnly", type: "boolean", label: "Read Only", defaultValue: !1 },
1862
- { name: "showToolbar", type: "boolean", label: "Show Toolbar", defaultValue: !0 },
1863
- { name: "showMinimap", type: "boolean", label: "Show Minimap", defaultValue: !1 },
1864
- { name: "showVersionHistory", type: "boolean", label: "Show Version History", defaultValue: !1 },
1865
- { name: "showExecutionOverlay", type: "boolean", label: "Show Execution Overlay", defaultValue: !1 },
1866
- { name: "concurrencyPolicy", type: "string", label: "Concurrency Policy" },
1867
- { name: "versionHistory", type: "code", label: "Version History" },
1868
- { name: "executionSteps", type: "code", label: "Execution Steps" }
1869
- ]
1870
- }
1871
- );
1872
- export {
1873
- qs as ApprovalProcess,
1874
- Js as AutomationBuilder,
1875
- et as AutomationRunHistory,
1876
- ht as FlowDesigner,
1877
- Ws as WorkflowDesigner
1426
+ var Ue = ({ node: e, isSelected: t, isConnectSource: n, connectMode: r, readOnly: i, showExecutionOverlay: a, onSelect: o, onDelete: s, onDragStart: c, onPortClick: l }) => {
1427
+ let u = e.executionStatus, d = u ? Ne[u] : null;
1428
+ return /* @__PURE__ */ (0, G.jsxs)("div", {
1429
+ className: "absolute select-none",
1430
+ style: {
1431
+ left: e.position.x,
1432
+ top: e.position.y
1433
+ },
1434
+ draggable: !i && !r,
1435
+ onDragStart: (t) => c(t, e.id),
1436
+ onClick: (t) => o(e.id, t.shiftKey),
1437
+ role: "group",
1438
+ "aria-label": e.label,
1439
+ children: [
1440
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1441
+ className: ke("flex items-center gap-2 border-2 rounded px-3 py-2 min-h-[52px] transition-shadow cursor-pointer", Me[e.type], t && "ring-2 ring-primary shadow-md", n && "ring-2 ring-blue-400 shadow-lg", r && !n && "cursor-crosshair", a && u === "running" && "ring-2 ring-blue-400", a && u === "failed" && "ring-2 ring-red-400", a && u === "completed" && "ring-2 ring-green-400"),
1442
+ style: {
1443
+ width: Q,
1444
+ minHeight: Ae
1445
+ },
1446
+ children: [
1447
+ /* @__PURE__ */ (0, G.jsx)("span", {
1448
+ className: "shrink-0",
1449
+ children: je[e.type]
1450
+ }),
1451
+ /* @__PURE__ */ (0, G.jsx)("span", {
1452
+ className: "text-xs font-medium leading-tight flex-1 truncate",
1453
+ children: e.label
1454
+ }),
1455
+ a && d && /* @__PURE__ */ (0, G.jsx)("span", {
1456
+ className: ke("shrink-0", d.color),
1457
+ children: d.icon
1458
+ })
1459
+ ]
1460
+ }),
1461
+ !i && (t || r) && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsx)("div", {
1462
+ className: "absolute w-3 h-3 rounded-full bg-primary border-2 border-background shadow cursor-crosshair",
1463
+ style: {
1464
+ right: -6,
1465
+ top: Ae / 2 - 6
1466
+ },
1467
+ title: "Connect from this node",
1468
+ onClick: (t) => {
1469
+ t.stopPropagation(), l(e.id);
1470
+ }
1471
+ }), /* @__PURE__ */ (0, G.jsx)("div", {
1472
+ className: "absolute w-3 h-3 rounded-full bg-muted-foreground border-2 border-background shadow cursor-crosshair",
1473
+ style: {
1474
+ left: -6,
1475
+ top: Ae / 2 - 6
1476
+ },
1477
+ title: "Connect to this node",
1478
+ onClick: (t) => {
1479
+ t.stopPropagation(), l(e.id);
1480
+ }
1481
+ })] }),
1482
+ !i && t && !r && /* @__PURE__ */ (0, G.jsx)("button", {
1483
+ className: "absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow",
1484
+ onClick: (t) => {
1485
+ t.stopPropagation(), s(e.id);
1486
+ },
1487
+ "aria-label": `Delete node ${e.label}`,
1488
+ children: /* @__PURE__ */ (0, G.jsx)(z, { className: "h-3 w-3" })
1489
+ })
1490
+ ]
1491
+ });
1492
+ }, We = ({ node: e, edge: t, readOnly: n, onNodeChange: r, onEdgeChange: i }) => !e && !t ? /* @__PURE__ */ (0, G.jsx)("div", {
1493
+ className: "p-4 text-sm text-muted-foreground",
1494
+ children: "Select a node or edge to edit its properties."
1495
+ }) : e ? /* @__PURE__ */ (0, G.jsxs)("div", {
1496
+ className: "p-3 space-y-3 overflow-y-auto",
1497
+ children: [
1498
+ /* @__PURE__ */ (0, G.jsx)("p", {
1499
+ className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide",
1500
+ children: "Node Properties"
1501
+ }),
1502
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1503
+ className: "space-y-1",
1504
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1505
+ className: "text-xs",
1506
+ children: "Label"
1507
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1508
+ value: e.label,
1509
+ onChange: (t) => r({
1510
+ ...e,
1511
+ label: t.target.value
1512
+ }),
1513
+ disabled: n,
1514
+ className: "h-7 text-xs"
1515
+ })]
1516
+ }),
1517
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1518
+ className: "space-y-1",
1519
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1520
+ className: "text-xs",
1521
+ children: "Type"
1522
+ }), /* @__PURE__ */ (0, G.jsxs)(p, {
1523
+ value: e.type,
1524
+ onValueChange: (t) => r({
1525
+ ...e,
1526
+ type: t
1527
+ }),
1528
+ disabled: n,
1529
+ children: [/* @__PURE__ */ (0, G.jsx)(g, {
1530
+ className: "h-7 text-xs",
1531
+ children: /* @__PURE__ */ (0, G.jsx)(_, {})
1532
+ }), /* @__PURE__ */ (0, G.jsx)(m, { children: Object.keys($).map((e) => /* @__PURE__ */ (0, G.jsx)(h, {
1533
+ value: e,
1534
+ className: "text-xs",
1535
+ children: $[e]
1536
+ }, e)) })]
1537
+ })]
1538
+ }),
1539
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1540
+ className: "space-y-1",
1541
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1542
+ className: "text-xs",
1543
+ children: "Description"
1544
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1545
+ value: e.description ?? "",
1546
+ onChange: (t) => r({
1547
+ ...e,
1548
+ description: t.target.value
1549
+ }),
1550
+ disabled: n,
1551
+ className: "h-7 text-xs",
1552
+ placeholder: "Optional description"
1553
+ })]
1554
+ }),
1555
+ [
1556
+ "task",
1557
+ "user_task",
1558
+ "service_task",
1559
+ "script_task",
1560
+ "delay",
1561
+ "webhook"
1562
+ ].includes(e.type) && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [
1563
+ /* @__PURE__ */ (0, G.jsx)(v, {}),
1564
+ /* @__PURE__ */ (0, G.jsx)("p", {
1565
+ className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide",
1566
+ children: "Executor"
1567
+ }),
1568
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1569
+ className: "space-y-1",
1570
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1571
+ className: "text-xs",
1572
+ children: "Executor Type"
1573
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1574
+ value: e.executor?.type ?? "",
1575
+ onChange: (t) => r({
1576
+ ...e,
1577
+ executor: {
1578
+ ...e.executor,
1579
+ type: t.target.value
1580
+ }
1581
+ }),
1582
+ disabled: n,
1583
+ className: "h-7 text-xs",
1584
+ placeholder: "e.g. http, script, email"
1585
+ })]
1586
+ }),
1587
+ e.type === "delay" && /* @__PURE__ */ (0, G.jsxs)("div", {
1588
+ className: "space-y-1",
1589
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1590
+ className: "text-xs",
1591
+ children: "Wait Event Type"
1592
+ }), /* @__PURE__ */ (0, G.jsxs)(p, {
1593
+ value: e.executor?.waitEventConfig?.eventType ?? "timer",
1594
+ onValueChange: (t) => r({
1595
+ ...e,
1596
+ executor: {
1597
+ ...e.executor,
1598
+ type: e.executor?.type ?? "wait",
1599
+ waitEventConfig: {
1600
+ ...e.executor?.waitEventConfig,
1601
+ eventType: t
1602
+ }
1603
+ }
1604
+ }),
1605
+ disabled: n,
1606
+ children: [/* @__PURE__ */ (0, G.jsx)(g, {
1607
+ className: "h-7 text-xs",
1608
+ children: /* @__PURE__ */ (0, G.jsx)(_, {})
1609
+ }), /* @__PURE__ */ (0, G.jsx)(m, { children: Object.keys(Ie).map((e) => /* @__PURE__ */ (0, G.jsx)(h, {
1610
+ value: e,
1611
+ className: "text-xs",
1612
+ children: Ie[e]
1613
+ }, e)) })]
1614
+ })]
1615
+ }),
1616
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1617
+ className: "space-y-1",
1618
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1619
+ className: "text-xs",
1620
+ children: "Timeout (ms)"
1621
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1622
+ type: "number",
1623
+ value: e.executor?.timeoutMs ?? "",
1624
+ onChange: (t) => r({
1625
+ ...e,
1626
+ executor: {
1627
+ ...e.executor,
1628
+ type: e.executor?.type ?? "",
1629
+ timeoutMs: t.target.value ? Number(t.target.value) : void 0
1630
+ }
1631
+ }),
1632
+ disabled: n,
1633
+ className: "h-7 text-xs",
1634
+ placeholder: "e.g. 30000"
1635
+ })]
1636
+ })
1637
+ ] }),
1638
+ e.type === "boundary_event" && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [
1639
+ /* @__PURE__ */ (0, G.jsx)(v, {}),
1640
+ /* @__PURE__ */ (0, G.jsx)("p", {
1641
+ className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide",
1642
+ children: "Boundary Config"
1643
+ }),
1644
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1645
+ className: "space-y-1",
1646
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1647
+ className: "text-xs",
1648
+ children: "Attached To Node ID"
1649
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1650
+ value: e.boundaryConfig?.attachedToNodeId ?? "",
1651
+ onChange: (t) => r({
1652
+ ...e,
1653
+ boundaryConfig: {
1654
+ ...e.boundaryConfig,
1655
+ attachedToNodeId: t.target.value,
1656
+ eventType: e.boundaryConfig?.eventType ?? "error"
1657
+ }
1658
+ }),
1659
+ disabled: n,
1660
+ className: "h-7 text-xs",
1661
+ placeholder: "Host node id"
1662
+ })]
1663
+ }),
1664
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1665
+ className: "space-y-1",
1666
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1667
+ className: "text-xs",
1668
+ children: "Event Type"
1669
+ }), /* @__PURE__ */ (0, G.jsxs)(p, {
1670
+ value: e.boundaryConfig?.eventType ?? "error",
1671
+ onValueChange: (t) => r({
1672
+ ...e,
1673
+ boundaryConfig: {
1674
+ ...e.boundaryConfig,
1675
+ attachedToNodeId: e.boundaryConfig?.attachedToNodeId ?? "",
1676
+ eventType: t
1677
+ }
1678
+ }),
1679
+ disabled: n,
1680
+ children: [/* @__PURE__ */ (0, G.jsx)(g, {
1681
+ className: "h-7 text-xs",
1682
+ children: /* @__PURE__ */ (0, G.jsx)(_, {})
1683
+ }), /* @__PURE__ */ (0, G.jsx)(m, { children: [
1684
+ "error",
1685
+ "timer",
1686
+ "message",
1687
+ "signal",
1688
+ "compensation"
1689
+ ].map((e) => /* @__PURE__ */ (0, G.jsx)(h, {
1690
+ value: e,
1691
+ className: "text-xs capitalize",
1692
+ children: e
1693
+ }, e)) })]
1694
+ })]
1695
+ })
1696
+ ] })
1697
+ ]
1698
+ }) : t ? /* @__PURE__ */ (0, G.jsxs)("div", {
1699
+ className: "p-3 space-y-3 overflow-y-auto",
1700
+ children: [
1701
+ /* @__PURE__ */ (0, G.jsx)("p", {
1702
+ className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide",
1703
+ children: "Edge Properties"
1704
+ }),
1705
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1706
+ className: "space-y-1",
1707
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1708
+ className: "text-xs",
1709
+ children: "Label"
1710
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1711
+ value: t.label ?? "",
1712
+ onChange: (e) => i({
1713
+ ...t,
1714
+ label: e.target.value
1715
+ }),
1716
+ disabled: n,
1717
+ className: "h-7 text-xs"
1718
+ })]
1719
+ }),
1720
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1721
+ className: "space-y-1",
1722
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1723
+ className: "text-xs",
1724
+ children: "Type"
1725
+ }), /* @__PURE__ */ (0, G.jsxs)(p, {
1726
+ value: t.type ?? "default",
1727
+ onValueChange: (e) => i({
1728
+ ...t,
1729
+ type: e
1730
+ }),
1731
+ disabled: n,
1732
+ children: [/* @__PURE__ */ (0, G.jsx)(g, {
1733
+ className: "h-7 text-xs",
1734
+ children: /* @__PURE__ */ (0, G.jsx)(_, {})
1735
+ }), /* @__PURE__ */ (0, G.jsxs)(m, { children: [
1736
+ /* @__PURE__ */ (0, G.jsx)(h, {
1737
+ value: "default",
1738
+ className: "text-xs",
1739
+ children: "Default"
1740
+ }),
1741
+ /* @__PURE__ */ (0, G.jsx)(h, {
1742
+ value: "conditional",
1743
+ className: "text-xs",
1744
+ children: "Conditional"
1745
+ }),
1746
+ /* @__PURE__ */ (0, G.jsx)(h, {
1747
+ value: "timeout",
1748
+ className: "text-xs",
1749
+ children: "Timeout"
1750
+ })
1751
+ ] })]
1752
+ })]
1753
+ }),
1754
+ t.type === "conditional" && /* @__PURE__ */ (0, G.jsxs)("div", {
1755
+ className: "space-y-1",
1756
+ children: [/* @__PURE__ */ (0, G.jsx)(f, {
1757
+ className: "text-xs",
1758
+ children: "Condition Expression"
1759
+ }), /* @__PURE__ */ (0, G.jsx)(d, {
1760
+ value: t.condition ?? "",
1761
+ onChange: (e) => i({
1762
+ ...t,
1763
+ condition: e.target.value
1764
+ }),
1765
+ disabled: n,
1766
+ className: "h-7 text-xs font-mono",
1767
+ placeholder: "e.g. status === 'approved'"
1768
+ })]
1769
+ }),
1770
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1771
+ className: "flex items-center gap-2",
1772
+ children: [/* @__PURE__ */ (0, G.jsx)("input", {
1773
+ type: "checkbox",
1774
+ id: "edge-isDefault",
1775
+ checked: t.isDefault ?? !1,
1776
+ onChange: (e) => i({
1777
+ ...t,
1778
+ isDefault: e.target.checked
1779
+ }),
1780
+ disabled: n,
1781
+ className: "h-3.5 w-3.5"
1782
+ }), /* @__PURE__ */ (0, G.jsx)(f, {
1783
+ htmlFor: "edge-isDefault",
1784
+ className: "text-xs",
1785
+ children: "Default edge (isDefault)"
1786
+ })]
1787
+ })
1788
+ ]
1789
+ }) : null, Ge = ({ versions: e }) => /* @__PURE__ */ (0, G.jsxs)("div", {
1790
+ className: "p-3 space-y-2",
1791
+ children: [
1792
+ /* @__PURE__ */ (0, G.jsx)("p", {
1793
+ className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide",
1794
+ children: "Version History"
1795
+ }),
1796
+ e.length === 0 && /* @__PURE__ */ (0, G.jsx)("p", {
1797
+ className: "text-xs text-muted-foreground",
1798
+ children: "No version history available."
1799
+ }),
1800
+ /* @__PURE__ */ (0, G.jsx)("div", {
1801
+ className: "space-y-1.5",
1802
+ children: e.map((e) => /* @__PURE__ */ (0, G.jsxs)("div", {
1803
+ className: ke("rounded border p-2 text-xs", e.isCurrent ? "border-primary bg-primary/5" : "border-border bg-muted/30"),
1804
+ children: [
1805
+ /* @__PURE__ */ (0, G.jsxs)("div", {
1806
+ className: "flex items-center justify-between",
1807
+ children: [/* @__PURE__ */ (0, G.jsxs)("span", {
1808
+ className: "font-medium",
1809
+ children: ["v", e.version]
1810
+ }), e.isCurrent && /* @__PURE__ */ (0, G.jsx)(a, {
1811
+ variant: "default",
1812
+ className: "text-[10px] h-4",
1813
+ children: "Current"
1814
+ })]
1815
+ }),
1816
+ e.changeNote && /* @__PURE__ */ (0, G.jsx)("p", {
1817
+ className: "text-muted-foreground mt-0.5",
1818
+ children: e.changeNote
1819
+ }),
1820
+ /* @__PURE__ */ (0, G.jsxs)("p", {
1821
+ className: "text-muted-foreground mt-0.5",
1822
+ children: [e.author && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [e.author, " · "] }), new Date(e.createdAt).toLocaleDateString()]
1823
+ })
1824
+ ]
1825
+ }, e.version))
1826
+ })
1827
+ ]
1828
+ }), Ke = ({ schema: e, onSave: f }) => {
1829
+ let { readOnly: p = !1, showToolbar: m = !0, showMinimap: h = !1, showVersionHistory: g = !1, showExecutionOverlay: _ = !1, executionSteps: y = [], versionHistory: b = [], concurrencyPolicy: x, title: S = "New Flow", description: C = "", status: w = "draft" } = e, [T, E] = i(S), [D, O] = i(C), { current: k, push: A, undo: j, redo: M, canUndo: re, canRedo: ie } = ze({
1830
+ nodes: e.nodes ?? Le(),
1831
+ edges: e.edges ?? Re()
1832
+ }), N = k.nodes, P = k.edges, [F, I] = i(null), [L, R] = i(null), [z, B] = i(!1), [V, H] = i(null), [he, ge] = i(!0), [U, _e] = i(g), [W, ve] = i(null), [K, ye] = i(1), q = r(null), be = n(() => N.find((e) => e.id === F) ?? null, [N, F]), xe = n(() => P.find((e) => e.id === L) ?? null, [P, L]), J = n(() => {
1833
+ if (!_ || y.length === 0) return N;
1834
+ let e = new Map(y.map((e) => [e.nodeId, e.status]));
1835
+ return N.map((t) => e.has(t.id) ? {
1836
+ ...t,
1837
+ executionStatus: e.get(t.id)
1838
+ } : t);
1839
+ }, [
1840
+ N,
1841
+ _,
1842
+ y
1843
+ ]), Se = t((e) => {
1844
+ if (p) return;
1845
+ let t = {
1846
+ id: `${e}-${Date.now()}`,
1847
+ type: e,
1848
+ label: $[e],
1849
+ position: {
1850
+ x: 200,
1851
+ y: 80 + N.length * 70
1852
+ }
1853
+ };
1854
+ A({
1855
+ nodes: [...N, t],
1856
+ edges: P
1857
+ });
1858
+ }, [
1859
+ p,
1860
+ N,
1861
+ P,
1862
+ A
1863
+ ]), Ce = t((e) => {
1864
+ p || (A({
1865
+ nodes: N.filter((t) => t.id !== e),
1866
+ edges: P.filter((t) => t.source !== e && t.target !== e)
1867
+ }), F === e && I(null));
1868
+ }, [
1869
+ p,
1870
+ N,
1871
+ P,
1872
+ A,
1873
+ F
1874
+ ]), we = t((e) => {
1875
+ p || A({
1876
+ nodes: N.map((t) => t.id === e.id ? e : t),
1877
+ edges: P
1878
+ });
1879
+ }, [
1880
+ p,
1881
+ N,
1882
+ P,
1883
+ A
1884
+ ]), Te = t((e) => {
1885
+ p || (A({
1886
+ nodes: N,
1887
+ edges: P.filter((t) => t.id !== e)
1888
+ }), L === e && R(null));
1889
+ }, [
1890
+ p,
1891
+ N,
1892
+ P,
1893
+ A,
1894
+ L
1895
+ ]), Y = t((e) => {
1896
+ p || A({
1897
+ nodes: N,
1898
+ edges: P.map((t) => t.id === e.id ? e : t)
1899
+ });
1900
+ }, [
1901
+ p,
1902
+ N,
1903
+ P,
1904
+ A
1905
+ ]), Ee = t((e) => {
1906
+ if (!p) {
1907
+ if (!z) {
1908
+ B(!0), H(e);
1909
+ return;
1910
+ }
1911
+ if (V && V !== e) {
1912
+ let t = {
1913
+ id: `edge-${Date.now()}`,
1914
+ source: V,
1915
+ target: e
1916
+ };
1917
+ A({
1918
+ nodes: N,
1919
+ edges: [...P, t]
1920
+ });
1921
+ }
1922
+ B(!1), H(null);
1923
+ }
1924
+ }, [
1925
+ p,
1926
+ z,
1927
+ V,
1928
+ N,
1929
+ P,
1930
+ A
1931
+ ]), X = r(null), Z = r(null), De = t((e, t) => {
1932
+ X.current = t;
1933
+ let n = N.find((e) => e.id === t);
1934
+ n && (Z.current = {
1935
+ mouseX: e.clientX,
1936
+ mouseY: e.clientY,
1937
+ nodeX: n.position.x,
1938
+ nodeY: n.position.y
1939
+ }), e.dataTransfer.effectAllowed = "move";
1940
+ }, [N]), Oe = t((e) => {
1941
+ if (e.preventDefault(), !X.current || !Z.current || !q.current) return;
1942
+ q.current.getBoundingClientRect();
1943
+ let t = (e.clientX - Z.current.mouseX) / K, n = (e.clientY - Z.current.mouseY) / K, r = Math.max(0, Z.current.nodeX + t), i = Math.max(0, Z.current.nodeY + n), a = X.current;
1944
+ A({
1945
+ nodes: N.map((e) => e.id === a ? {
1946
+ ...e,
1947
+ position: {
1948
+ x: r,
1949
+ y: i
1950
+ }
1951
+ } : e),
1952
+ edges: P
1953
+ }), X.current = null, Z.current = null;
1954
+ }, [
1955
+ N,
1956
+ P,
1957
+ A,
1958
+ K
1959
+ ]), ke = t(() => {
1960
+ let e = Be(N, P, T);
1961
+ ve(e);
1962
+ let t = new Blob([e.bpmnXml ?? ""], { type: "application/xml" }), n = URL.createObjectURL(t), r = document.createElement("a");
1963
+ r.href = n, r.download = `${T.replace(/\s+/g, "-").toLowerCase()}.bpmn`, r.click(), URL.revokeObjectURL(n);
1964
+ }, [
1965
+ N,
1966
+ P,
1967
+ T
1968
+ ]), Q = t(() => {
1969
+ f?.(N, P);
1970
+ }, [
1971
+ N,
1972
+ P,
1973
+ f
1974
+ ]);
1975
+ return /* @__PURE__ */ (0, G.jsxs)(s, {
1976
+ className: "flex flex-col h-full min-h-[600px] outline-none",
1977
+ tabIndex: 0,
1978
+ onKeyDown: t((e) => {
1979
+ let t = e.ctrlKey || e.metaKey;
1980
+ if (t && e.key === "z" && !e.shiftKey) {
1981
+ e.preventDefault(), j();
1982
+ return;
1983
+ }
1984
+ if (t && (e.key === "y" || e.key === "z" && e.shiftKey)) {
1985
+ e.preventDefault(), M();
1986
+ return;
1987
+ }
1988
+ if (t && e.key === "s") {
1989
+ e.preventDefault(), Q();
1990
+ return;
1991
+ }
1992
+ e.key === "Escape" && (B(!1), H(null), I(null), R(null)), (e.key === "Delete" || e.key === "Backspace") && (F ? Ce(F) : L && Te(L));
1993
+ }, [
1994
+ j,
1995
+ M,
1996
+ Q,
1997
+ F,
1998
+ L,
1999
+ Ce,
2000
+ Te
2001
+ ]),
2002
+ children: [/* @__PURE__ */ (0, G.jsx)(l, {
2003
+ className: "py-2 px-4 border-b flex-shrink-0",
2004
+ children: /* @__PURE__ */ (0, G.jsxs)("div", {
2005
+ className: "flex items-center gap-3 flex-wrap",
2006
+ children: [
2007
+ /* @__PURE__ */ (0, G.jsx)(fe, { className: "h-4 w-4 text-primary shrink-0" }),
2008
+ /* @__PURE__ */ (0, G.jsx)(u, {
2009
+ className: "text-sm font-semibold",
2010
+ children: p ? /* @__PURE__ */ (0, G.jsx)("span", { children: T }) : /* @__PURE__ */ (0, G.jsx)(d, {
2011
+ value: T,
2012
+ onChange: (e) => E(e.target.value),
2013
+ className: "h-6 text-sm font-semibold border-0 p-0 focus-visible:ring-0 bg-transparent",
2014
+ "aria-label": "Flow title"
2015
+ })
2016
+ }),
2017
+ /* @__PURE__ */ (0, G.jsx)(a, {
2018
+ variant: "outline",
2019
+ className: "text-xs capitalize",
2020
+ children: w
2021
+ }),
2022
+ x && /* @__PURE__ */ (0, G.jsx)(a, {
2023
+ variant: "secondary",
2024
+ className: "text-xs",
2025
+ children: Fe[x]
2026
+ }),
2027
+ /* @__PURE__ */ (0, G.jsxs)("div", {
2028
+ className: "ml-auto flex items-center gap-1",
2029
+ children: [
2030
+ !p && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [
2031
+ /* @__PURE__ */ (0, G.jsx)(o, {
2032
+ size: "icon",
2033
+ variant: "ghost",
2034
+ className: "h-7 w-7",
2035
+ onClick: j,
2036
+ disabled: !re,
2037
+ title: "Undo (Ctrl+Z)",
2038
+ children: /* @__PURE__ */ (0, G.jsx)(ue, { className: "h-4 w-4" })
2039
+ }),
2040
+ /* @__PURE__ */ (0, G.jsx)(o, {
2041
+ size: "icon",
2042
+ variant: "ghost",
2043
+ className: "h-7 w-7",
2044
+ onClick: M,
2045
+ disabled: !ie,
2046
+ title: "Redo (Ctrl+Y)",
2047
+ children: /* @__PURE__ */ (0, G.jsx)(se, { className: "h-4 w-4" })
2048
+ }),
2049
+ /* @__PURE__ */ (0, G.jsx)(v, {
2050
+ orientation: "vertical",
2051
+ className: "h-5 mx-1"
2052
+ })
2053
+ ] }),
2054
+ /* @__PURE__ */ (0, G.jsx)(o, {
2055
+ size: "icon",
2056
+ variant: "ghost",
2057
+ className: "h-7 w-7",
2058
+ onClick: () => ye((e) => Math.min(2, e + .1)),
2059
+ title: "Zoom in",
2060
+ children: /* @__PURE__ */ (0, G.jsx)(pe, { className: "h-4 w-4" })
2061
+ }),
2062
+ /* @__PURE__ */ (0, G.jsx)(o, {
2063
+ size: "icon",
2064
+ variant: "ghost",
2065
+ className: "h-7 w-7",
2066
+ onClick: () => ye(1),
2067
+ title: "Reset zoom",
2068
+ children: /* @__PURE__ */ (0, G.jsx)(ce, { className: "h-4 w-4" })
2069
+ }),
2070
+ /* @__PURE__ */ (0, G.jsx)(o, {
2071
+ size: "icon",
2072
+ variant: "ghost",
2073
+ className: "h-7 w-7",
2074
+ onClick: () => ye((e) => Math.max(.3, e - .1)),
2075
+ title: "Zoom out",
2076
+ children: /* @__PURE__ */ (0, G.jsx)(me, { className: "h-4 w-4" })
2077
+ }),
2078
+ /* @__PURE__ */ (0, G.jsx)(v, {
2079
+ orientation: "vertical",
2080
+ className: "h-5 mx-1"
2081
+ }),
2082
+ b.length > 0 && /* @__PURE__ */ (0, G.jsx)(o, {
2083
+ size: "icon",
2084
+ variant: U ? "secondary" : "ghost",
2085
+ className: "h-7 w-7",
2086
+ onClick: () => _e((e) => !e),
2087
+ title: "Version history",
2088
+ children: /* @__PURE__ */ (0, G.jsx)(te, { className: "h-4 w-4" })
2089
+ }),
2090
+ /* @__PURE__ */ (0, G.jsx)(o, {
2091
+ size: "icon",
2092
+ variant: "ghost",
2093
+ className: "h-7 w-7",
2094
+ onClick: ke,
2095
+ title: "Export BPMN",
2096
+ children: /* @__PURE__ */ (0, G.jsx)(ee, { className: "h-4 w-4" })
2097
+ }),
2098
+ !p && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsx)(o, {
2099
+ size: "icon",
2100
+ variant: "ghost",
2101
+ className: "h-7 w-7",
2102
+ title: "Import BPMN (drag & drop)",
2103
+ children: /* @__PURE__ */ (0, G.jsx)(de, { className: "h-4 w-4" })
2104
+ }), /* @__PURE__ */ (0, G.jsxs)(o, {
2105
+ size: "sm",
2106
+ variant: "default",
2107
+ className: "h-7 text-xs gap-1",
2108
+ onClick: Q,
2109
+ title: "Save (Ctrl+S)",
2110
+ children: [/* @__PURE__ */ (0, G.jsx)(le, { className: "h-3.5 w-3.5" }), " Save"]
2111
+ })] }),
2112
+ /* @__PURE__ */ (0, G.jsx)(o, {
2113
+ size: "icon",
2114
+ variant: "ghost",
2115
+ className: "h-7 w-7",
2116
+ onClick: () => ge((e) => !e),
2117
+ title: he ? "Hide properties" : "Show properties",
2118
+ children: he ? /* @__PURE__ */ (0, G.jsx)(ae, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, G.jsx)(oe, { className: "h-4 w-4" })
2119
+ })
2120
+ ]
2121
+ })
2122
+ ]
2123
+ })
2124
+ }), /* @__PURE__ */ (0, G.jsxs)(c, {
2125
+ className: "flex flex-1 p-0 overflow-hidden",
2126
+ children: [
2127
+ m && !p && /* @__PURE__ */ (0, G.jsxs)("div", {
2128
+ className: "w-36 border-r bg-muted/30 flex-shrink-0 overflow-y-auto py-2 px-2",
2129
+ children: [
2130
+ /* @__PURE__ */ (0, G.jsx)("p", {
2131
+ className: "text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-2 px-1",
2132
+ children: "Add Node"
2133
+ }),
2134
+ /* @__PURE__ */ (0, G.jsx)("div", {
2135
+ className: "space-y-1",
2136
+ children: Pe.map((e) => /* @__PURE__ */ (0, G.jsxs)("button", {
2137
+ className: "w-full flex items-center gap-2 text-xs px-2 py-1.5 rounded hover:bg-muted transition-colors text-left",
2138
+ onClick: () => Se(e),
2139
+ title: `Add ${$[e]}`,
2140
+ children: [je[e], /* @__PURE__ */ (0, G.jsx)("span", {
2141
+ className: "truncate",
2142
+ children: $[e]
2143
+ })]
2144
+ }, e))
2145
+ }),
2146
+ z && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsx)(v, { className: "my-2" }), /* @__PURE__ */ (0, G.jsxs)("div", {
2147
+ className: "px-1",
2148
+ children: [
2149
+ /* @__PURE__ */ (0, G.jsx)("p", {
2150
+ className: "text-[10px] text-blue-600 font-medium",
2151
+ children: "Connect mode"
2152
+ }),
2153
+ /* @__PURE__ */ (0, G.jsx)("p", {
2154
+ className: "text-[10px] text-muted-foreground",
2155
+ children: "Click a target node port to connect."
2156
+ }),
2157
+ /* @__PURE__ */ (0, G.jsx)(o, {
2158
+ size: "sm",
2159
+ variant: "outline",
2160
+ className: "h-6 text-xs mt-1 w-full",
2161
+ onClick: () => {
2162
+ B(!1), H(null);
2163
+ },
2164
+ children: "Cancel"
2165
+ })
2166
+ ]
2167
+ })] })
2168
+ ]
2169
+ }),
2170
+ /* @__PURE__ */ (0, G.jsx)("div", {
2171
+ className: "flex-1 overflow-auto relative bg-dot-pattern",
2172
+ children: /* @__PURE__ */ (0, G.jsxs)("div", {
2173
+ ref: q,
2174
+ className: "relative",
2175
+ style: {
2176
+ width: 1200,
2177
+ height: 700,
2178
+ transform: `scale(${K})`,
2179
+ transformOrigin: "top left"
2180
+ },
2181
+ onDrop: Oe,
2182
+ onDragOver: (e) => e.preventDefault(),
2183
+ onClick: (e) => {
2184
+ e.target === q.current && (I(null), R(null));
2185
+ },
2186
+ children: [
2187
+ /* @__PURE__ */ (0, G.jsxs)("svg", {
2188
+ className: "absolute inset-0 pointer-events-none",
2189
+ width: 1200,
2190
+ height: 700,
2191
+ style: { overflow: "visible" },
2192
+ children: [/* @__PURE__ */ (0, G.jsxs)("defs", { children: [
2193
+ /* @__PURE__ */ (0, G.jsx)("marker", {
2194
+ id: "fd-arrowhead",
2195
+ markerWidth: "10",
2196
+ markerHeight: "7",
2197
+ refX: "9",
2198
+ refY: "3.5",
2199
+ orient: "auto",
2200
+ children: /* @__PURE__ */ (0, G.jsx)("polygon", {
2201
+ points: "0 0, 10 3.5, 0 7",
2202
+ fill: "hsl(var(--foreground) / 0.5)"
2203
+ })
2204
+ }),
2205
+ /* @__PURE__ */ (0, G.jsx)("marker", {
2206
+ id: "fd-arrowhead-selected",
2207
+ markerWidth: "10",
2208
+ markerHeight: "7",
2209
+ refX: "9",
2210
+ refY: "3.5",
2211
+ orient: "auto",
2212
+ children: /* @__PURE__ */ (0, G.jsx)("polygon", {
2213
+ points: "0 0, 10 3.5, 0 7",
2214
+ fill: "hsl(var(--primary))"
2215
+ })
2216
+ }),
2217
+ /* @__PURE__ */ (0, G.jsx)("marker", {
2218
+ id: "fd-arrowhead-conditional",
2219
+ markerWidth: "10",
2220
+ markerHeight: "7",
2221
+ refX: "9",
2222
+ refY: "3.5",
2223
+ orient: "auto",
2224
+ children: /* @__PURE__ */ (0, G.jsx)("polygon", {
2225
+ points: "0 0, 10 3.5, 0 7",
2226
+ fill: "hsl(var(--foreground) / 0.6)"
2227
+ })
2228
+ })
2229
+ ] }), P.map((e) => {
2230
+ let t = J.find((t) => t.id === e.source), n = J.find((t) => t.id === e.target);
2231
+ if (!t || !n) return null;
2232
+ let { d: r, labelX: i, labelY: a } = He(t, n), o = e.id === L, s = e.type === "conditional", c = e.isDefault;
2233
+ return /* @__PURE__ */ (0, G.jsxs)("g", {
2234
+ className: "pointer-events-auto cursor-pointer",
2235
+ onClick: (t) => {
2236
+ t.stopPropagation(), R(e.id), I(null);
2237
+ },
2238
+ children: [
2239
+ /* @__PURE__ */ (0, G.jsx)("path", {
2240
+ d: r,
2241
+ fill: "none",
2242
+ stroke: o ? "hsl(var(--primary))" : s ? "hsl(var(--foreground) / 0.6)" : "hsl(var(--foreground) / 0.4)",
2243
+ strokeWidth: o ? 2.5 : 2,
2244
+ strokeDasharray: s ? "6 3" : c ? "3 3" : void 0,
2245
+ markerEnd: `url(#fd-arrowhead${o ? "-selected" : s ? "-conditional" : ""})`
2246
+ }),
2247
+ (e.label || c) && /* @__PURE__ */ (0, G.jsx)("text", {
2248
+ x: i,
2249
+ y: a,
2250
+ textAnchor: "middle",
2251
+ className: "text-[10px] fill-muted-foreground",
2252
+ style: { fontSize: 10 },
2253
+ children: e.label ?? (c ? "(default)" : "")
2254
+ }),
2255
+ e.condition && /* @__PURE__ */ (0, G.jsx)("text", {
2256
+ x: i,
2257
+ y: a + 12,
2258
+ textAnchor: "middle",
2259
+ className: "text-[9px] fill-orange-500",
2260
+ style: { fontSize: 9 },
2261
+ children: e.condition.length > 24 ? e.condition.slice(0, 24) + "…" : e.condition
2262
+ }),
2263
+ /* @__PURE__ */ (0, G.jsx)("path", {
2264
+ d: r,
2265
+ fill: "none",
2266
+ stroke: "transparent",
2267
+ strokeWidth: 12
2268
+ })
2269
+ ]
2270
+ }, e.id);
2271
+ })]
2272
+ }),
2273
+ J.map((e) => /* @__PURE__ */ (0, G.jsx)(Ue, {
2274
+ node: e,
2275
+ isSelected: F === e.id,
2276
+ isConnectSource: V === e.id,
2277
+ connectMode: z,
2278
+ readOnly: p,
2279
+ showExecutionOverlay: _,
2280
+ onSelect: (e, t) => {
2281
+ t || R(null), I(e);
2282
+ },
2283
+ onDelete: Ce,
2284
+ onDragStart: De,
2285
+ onPortClick: Ee
2286
+ }, e.id)),
2287
+ z && V && /* @__PURE__ */ (0, G.jsxs)("div", {
2288
+ className: "absolute bottom-4 left-1/2 -translate-x-1/2 bg-blue-600 text-white text-xs px-3 py-1.5 rounded shadow-lg pointer-events-none",
2289
+ children: [/* @__PURE__ */ (0, G.jsx)(ne, { className: "h-3 w-3 inline mr-1" }), "Click a node port to complete the connection — Esc to cancel"]
2290
+ }),
2291
+ N.length === 0 && /* @__PURE__ */ (0, G.jsx)("div", {
2292
+ className: "absolute inset-0 flex items-center justify-center text-muted-foreground text-sm",
2293
+ children: "No nodes yet. Use the toolbar to add nodes."
2294
+ })
2295
+ ]
2296
+ })
2297
+ }),
2298
+ U && b.length > 0 && /* @__PURE__ */ (0, G.jsx)("div", {
2299
+ className: "w-48 border-l bg-background flex-shrink-0 overflow-y-auto",
2300
+ children: /* @__PURE__ */ (0, G.jsx)(Ge, { versions: b })
2301
+ }),
2302
+ he && /* @__PURE__ */ (0, G.jsxs)("div", {
2303
+ className: "w-52 border-l bg-background flex-shrink-0 overflow-y-auto",
2304
+ children: [/* @__PURE__ */ (0, G.jsx)(We, {
2305
+ node: be,
2306
+ edge: xe,
2307
+ readOnly: p,
2308
+ onNodeChange: we,
2309
+ onEdgeChange: Y
2310
+ }), W && /* @__PURE__ */ (0, G.jsxs)("div", {
2311
+ className: "p-3 border-t",
2312
+ children: [
2313
+ /* @__PURE__ */ (0, G.jsx)("p", {
2314
+ className: "text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-1",
2315
+ children: "BPMN Export"
2316
+ }),
2317
+ /* @__PURE__ */ (0, G.jsx)(a, {
2318
+ variant: W.success ? "default" : "destructive",
2319
+ className: "text-[10px]",
2320
+ children: W.success ? `Exported ${W.nodeCount} nodes` : "Export failed"
2321
+ }),
2322
+ W.warnings?.map((e, t) => /* @__PURE__ */ (0, G.jsx)("p", {
2323
+ className: "text-[10px] text-amber-600 mt-0.5",
2324
+ children: e
2325
+ }, t))
2326
+ ]
2327
+ })]
2328
+ })
2329
+ ]
2330
+ })]
2331
+ });
1878
2332
  };
2333
+ e.register("workflow-designer", be, {
2334
+ label: "Workflow Designer",
2335
+ category: "Enterprise",
2336
+ inputs: [
2337
+ {
2338
+ name: "workflow",
2339
+ type: "code",
2340
+ label: "Initial Workflow Definition"
2341
+ },
2342
+ {
2343
+ name: "readOnly",
2344
+ type: "boolean",
2345
+ label: "Read Only",
2346
+ defaultValue: !1
2347
+ },
2348
+ {
2349
+ name: "showToolbar",
2350
+ type: "boolean",
2351
+ label: "Show Toolbar",
2352
+ defaultValue: !0
2353
+ },
2354
+ {
2355
+ name: "showMinimap",
2356
+ type: "boolean",
2357
+ label: "Show Minimap",
2358
+ defaultValue: !1
2359
+ }
2360
+ ]
2361
+ }), e.register("approval-process", xe, {
2362
+ label: "Approval Process",
2363
+ category: "Enterprise",
2364
+ inputs: [
2365
+ {
2366
+ name: "workflowId",
2367
+ type: "string",
2368
+ label: "Workflow ID"
2369
+ },
2370
+ {
2371
+ name: "instanceId",
2372
+ type: "string",
2373
+ label: "Instance ID"
2374
+ },
2375
+ {
2376
+ name: "currentNodeId",
2377
+ type: "string",
2378
+ label: "Current Node ID"
2379
+ },
2380
+ {
2381
+ name: "approvalRule",
2382
+ type: "code",
2383
+ label: "Approval Rule"
2384
+ },
2385
+ {
2386
+ name: "history",
2387
+ type: "code",
2388
+ label: "History"
2389
+ },
2390
+ {
2391
+ name: "showHistory",
2392
+ type: "boolean",
2393
+ label: "Show History",
2394
+ defaultValue: !0
2395
+ },
2396
+ {
2397
+ name: "showComments",
2398
+ type: "boolean",
2399
+ label: "Show Comments",
2400
+ defaultValue: !0
2401
+ }
2402
+ ]
2403
+ }), e.register("automation-builder", Ee, {
2404
+ label: "Automation Builder",
2405
+ category: "Enterprise",
2406
+ inputs: [{
2407
+ name: "automation",
2408
+ type: "code",
2409
+ label: "Automation Definition"
2410
+ }, {
2411
+ name: "objects",
2412
+ type: "code",
2413
+ label: "Available Objects"
2414
+ }]
2415
+ }), e.register("automation-run-history", Oe, {
2416
+ label: "Automation Run History",
2417
+ category: "Enterprise",
2418
+ inputs: [{
2419
+ name: "runs",
2420
+ type: "code",
2421
+ label: "Run History"
2422
+ }]
2423
+ }), e.register("flow-designer", Ke, {
2424
+ label: "Flow Designer",
2425
+ category: "Enterprise",
2426
+ inputs: [
2427
+ {
2428
+ name: "nodes",
2429
+ type: "code",
2430
+ label: "Flow Nodes"
2431
+ },
2432
+ {
2433
+ name: "edges",
2434
+ type: "code",
2435
+ label: "Flow Edges"
2436
+ },
2437
+ {
2438
+ name: "title",
2439
+ type: "string",
2440
+ label: "Flow Title"
2441
+ },
2442
+ {
2443
+ name: "readOnly",
2444
+ type: "boolean",
2445
+ label: "Read Only",
2446
+ defaultValue: !1
2447
+ },
2448
+ {
2449
+ name: "showToolbar",
2450
+ type: "boolean",
2451
+ label: "Show Toolbar",
2452
+ defaultValue: !0
2453
+ },
2454
+ {
2455
+ name: "showMinimap",
2456
+ type: "boolean",
2457
+ label: "Show Minimap",
2458
+ defaultValue: !1
2459
+ },
2460
+ {
2461
+ name: "showVersionHistory",
2462
+ type: "boolean",
2463
+ label: "Show Version History",
2464
+ defaultValue: !1
2465
+ },
2466
+ {
2467
+ name: "showExecutionOverlay",
2468
+ type: "boolean",
2469
+ label: "Show Execution Overlay",
2470
+ defaultValue: !1
2471
+ },
2472
+ {
2473
+ name: "concurrencyPolicy",
2474
+ type: "string",
2475
+ label: "Concurrency Policy"
2476
+ },
2477
+ {
2478
+ name: "versionHistory",
2479
+ type: "code",
2480
+ label: "Version History"
2481
+ },
2482
+ {
2483
+ name: "executionSteps",
2484
+ type: "code",
2485
+ label: "Execution Steps"
2486
+ }
2487
+ ]
2488
+ });
2489
+ //#endregion
2490
+ export { xe as ApprovalProcess, Ee as AutomationBuilder, Oe as AutomationRunHistory, Ke as FlowDesigner, be as WorkflowDesigner };