@notmrabhi/flowforge 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/GatewayBranchEdge-9YF32wwN.js +1 -0
  2. package/dist/GatewayBranchEdge-Dxoy5B1A.js +1264 -0
  3. package/dist/SchemaBuilderDrawer-157p-2Vj.js +1136 -0
  4. package/dist/SchemaBuilderDrawer-Wje7pVrn.js +1 -0
  5. package/dist/bpmn-CcuE2X_Q.js +2 -0
  6. package/dist/bpmn-CtfWDaOY.js +33 -0
  7. package/dist/canvas.cjs +1 -0
  8. package/dist/canvas.d.ts +809 -0
  9. package/dist/canvas.js +28 -0
  10. package/dist/canvasTokens-CAD6G24b.js +32 -0
  11. package/dist/canvasTokens-gKNYrPl4.js +1 -0
  12. package/dist/core.cjs +1 -0
  13. package/dist/core.d.ts +374 -0
  14. package/dist/core.js +24 -0
  15. package/dist/defaultUi.cjs +1 -0
  16. package/dist/defaultUi.d.ts +83 -0
  17. package/dist/defaultUi.js +18 -0
  18. package/dist/form.cjs +1 -0
  19. package/dist/form.d.ts +857 -0
  20. package/dist/form.js +44 -0
  21. package/dist/index-B31-Y5uO.js +11 -0
  22. package/dist/index-B3aHpb84.js +13 -0
  23. package/dist/index-BU09HbVh.js +10176 -0
  24. package/dist/index-BnzttJ4w.js +13758 -0
  25. package/dist/index-BysKSEtZ.js +1 -0
  26. package/dist/index-CQ0cVcHp.js +2 -0
  27. package/dist/index-CkjEllpd.js +1 -0
  28. package/dist/index-Codx5QwP.js +41 -0
  29. package/dist/index-Cw9DC-tf.js +76 -0
  30. package/dist/index-CzPi8KQC.js +1310 -0
  31. package/dist/index-D14V8rKX.js +1 -0
  32. package/dist/index-Da5NHCS2.js +8132 -0
  33. package/dist/index-a1IOaYsW.js +9 -0
  34. package/dist/index-a3QMaedZ.js +2553 -0
  35. package/dist/index-gtgq_241.js +3 -0
  36. package/dist/index-l6kvDx-m.js +1360 -0
  37. package/dist/index-lcviy90e.js +613 -0
  38. package/dist/index-wOnYb3DO.js +567 -0
  39. package/dist/index.cjs +1 -0
  40. package/dist/index.d.ts +1409 -0
  41. package/dist/index.js +107 -0
  42. package/dist/messages-CO299wPN.js +22 -0
  43. package/dist/messages-O9Tw_XXR.js +1 -0
  44. package/dist/nodeRegistry.cjs +1 -0
  45. package/dist/nodeRegistry.d.ts +334 -0
  46. package/dist/nodeRegistry.js +555 -0
  47. package/dist/style.css +6 -0
  48. package/dist/templateRegistry.cjs +1 -0
  49. package/dist/templateRegistry.d.ts +83 -0
  50. package/dist/templateRegistry.js +43 -0
  51. package/dist/templateSkeletons-D2ecxpVH.js +2954 -0
  52. package/dist/templateSkeletons-D5dYuslG.js +1 -0
  53. package/package.json +1 -1
@@ -0,0 +1,2954 @@
1
+ import { jsxs as v, jsx as f, Fragment as ye } from "react/jsx-runtime";
2
+ import G, { useRef as vt, useEffect as re, useState as M, useCallback as $, useMemo as Y } from "react";
3
+ import In, { useStore as On, useReactFlow as Mn, Background as jn, Controls as Fn, MiniMap as zn } from "reactflow";
4
+ import "reactflow/dist/style.css";
5
+ import { e as Ln, G as An, E as Dn, P as Rn, L as Pn, d as Bn, f as Wn } from "./GatewayBranchEdge-Dxoy5B1A.js";
6
+ import { Dialog as Gn, Box as Q, Drawer as $n, IconButton as Et, Button as Ne, CircularProgress as Yn } from "@mui/material";
7
+ import Kn from "react-select";
8
+ import { MdClose as Un, MdCalendarToday as Vn, MdBolt as Hn, MdArrowBack as Wt, MdChevronRight as Gt, MdAddCircleOutline as qn, MdApps as Xn, MdErrorOutline as Jn, MdAccountTree as Zn, MdAdd as Qn, MdSearch as er, MdCategory as tr, MdCancel as $t, MdError as Yt, MdCheckCircle as Kt, MdPlayArrow as Ut, MdHourglassEmpty as nr, MdSchedule as kt, MdPerson as rr, MdExpandLess as or, MdExpandMore as ir } from "react-icons/md";
9
+ import { GrTrigger as sr } from "react-icons/gr";
10
+ import { BiCollapse as lr, BiExpand as ar } from "react-icons/bi";
11
+ import { j as dr, b as cr } from "./index-BU09HbVh.js";
12
+ import { m as ur } from "./messages-CO299wPN.js";
13
+ import { T as fr, E as ee } from "./canvasTokens-CAD6G24b.js";
14
+ var Vt = Object.defineProperty, hr = (e, t, n) => t in e ? Vt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, gr = (e, t) => {
15
+ for (var n in t) Vt(e, n, { get: t[n], enumerable: !0 });
16
+ }, pr = (e, t, n) => hr(e, t + "", n), Ht = {};
17
+ gr(Ht, { Graph: () => K, alg: () => Xe, json: () => Xt, version: () => mr });
18
+ var br = Object.defineProperty, qt = (e, t) => {
19
+ for (var n in t) br(e, n, { get: t[n], enumerable: !0 });
20
+ }, K = class {
21
+ constructor(e) {
22
+ this._isDirected = !0, this._isMultigraph = !1, this._isCompound = !1, this._nodes = {}, this._in = {}, this._preds = {}, this._out = {}, this._sucs = {}, this._edgeObjs = {}, this._edgeLabels = {}, this._nodeCount = 0, this._edgeCount = 0, this._defaultNodeLabelFn = () => {
23
+ }, this._defaultEdgeLabelFn = () => {
24
+ }, e && (this._isDirected = "directed" in e ? e.directed : !0, this._isMultigraph = "multigraph" in e ? e.multigraph : !1, this._isCompound = "compound" in e ? e.compound : !1), this._isCompound && (this._parent = {}, this._children = {}, this._children["\0"] = {});
25
+ }
26
+ isDirected() {
27
+ return this._isDirected;
28
+ }
29
+ isMultigraph() {
30
+ return this._isMultigraph;
31
+ }
32
+ isCompound() {
33
+ return this._isCompound;
34
+ }
35
+ setGraph(e) {
36
+ return this._label = e, this;
37
+ }
38
+ graph() {
39
+ return this._label;
40
+ }
41
+ setDefaultNodeLabel(e) {
42
+ return typeof e != "function" ? this._defaultNodeLabelFn = () => e : this._defaultNodeLabelFn = e, this;
43
+ }
44
+ nodeCount() {
45
+ return this._nodeCount;
46
+ }
47
+ nodes() {
48
+ return Object.keys(this._nodes);
49
+ }
50
+ sources() {
51
+ return this.nodes().filter((e) => Object.keys(this._in[e]).length === 0);
52
+ }
53
+ sinks() {
54
+ return this.nodes().filter((e) => Object.keys(this._out[e]).length === 0);
55
+ }
56
+ setNodes(e, t) {
57
+ return e.forEach((n) => {
58
+ t !== void 0 ? this.setNode(n, t) : this.setNode(n);
59
+ }), this;
60
+ }
61
+ setNode(e, t) {
62
+ return e in this._nodes ? (arguments.length > 1 && (this._nodes[e] = t), this) : (this._nodes[e] = arguments.length > 1 ? t : this._defaultNodeLabelFn(e), this._isCompound && (this._parent[e] = "\0", this._children[e] = {}, this._children["\0"][e] = !0), this._in[e] = {}, this._preds[e] = {}, this._out[e] = {}, this._sucs[e] = {}, ++this._nodeCount, this);
63
+ }
64
+ node(e) {
65
+ return this._nodes[e];
66
+ }
67
+ hasNode(e) {
68
+ return e in this._nodes;
69
+ }
70
+ removeNode(e) {
71
+ if (e in this._nodes) {
72
+ let t = (n) => this.removeEdge(this._edgeObjs[n]);
73
+ delete this._nodes[e], this._isCompound && (this._removeFromParentsChildList(e), delete this._parent[e], this.children(e).forEach((n) => {
74
+ this.setParent(n);
75
+ }), delete this._children[e]), Object.keys(this._in[e]).forEach(t), delete this._in[e], delete this._preds[e], Object.keys(this._out[e]).forEach(t), delete this._out[e], delete this._sucs[e], --this._nodeCount;
76
+ }
77
+ return this;
78
+ }
79
+ setParent(e, t) {
80
+ if (!this._isCompound) throw new Error("Cannot set parent in a non-compound graph");
81
+ if (t === void 0) t = "\0";
82
+ else {
83
+ t += "";
84
+ for (let n = t; n !== void 0; n = this.parent(n)) if (n === e) throw new Error("Setting " + t + " as parent of " + e + " would create a cycle");
85
+ this.setNode(t);
86
+ }
87
+ return this.setNode(e), this._removeFromParentsChildList(e), this._parent[e] = t, this._children[t][e] = !0, this;
88
+ }
89
+ parent(e) {
90
+ if (this._isCompound) {
91
+ let t = this._parent[e];
92
+ if (t !== "\0") return t;
93
+ }
94
+ }
95
+ children(e = "\0") {
96
+ if (this._isCompound) {
97
+ let t = this._children[e];
98
+ if (t) return Object.keys(t);
99
+ } else {
100
+ if (e === "\0") return this.nodes();
101
+ if (this.hasNode(e)) return [];
102
+ }
103
+ return [];
104
+ }
105
+ predecessors(e) {
106
+ let t = this._preds[e];
107
+ if (t) return Object.keys(t);
108
+ }
109
+ successors(e) {
110
+ let t = this._sucs[e];
111
+ if (t) return Object.keys(t);
112
+ }
113
+ neighbors(e) {
114
+ let t = this.predecessors(e);
115
+ if (t) {
116
+ let n = new Set(t);
117
+ for (let r of this.successors(e)) n.add(r);
118
+ return Array.from(n.values());
119
+ }
120
+ }
121
+ isLeaf(e) {
122
+ let t;
123
+ return this.isDirected() ? t = this.successors(e) : t = this.neighbors(e), t.length === 0;
124
+ }
125
+ filterNodes(e) {
126
+ let t = new this.constructor({ directed: this._isDirected, multigraph: this._isMultigraph, compound: this._isCompound });
127
+ t.setGraph(this.graph()), Object.entries(this._nodes).forEach(([o, i]) => {
128
+ e(o) && t.setNode(o, i);
129
+ }), Object.values(this._edgeObjs).forEach((o) => {
130
+ t.hasNode(o.v) && t.hasNode(o.w) && t.setEdge(o, this.edge(o));
131
+ });
132
+ let n = {}, r = (o) => {
133
+ let i = this.parent(o);
134
+ return !i || t.hasNode(i) ? (n[o] = i ?? void 0, i ?? void 0) : i in n ? n[i] : r(i);
135
+ };
136
+ return this._isCompound && t.nodes().forEach((o) => t.setParent(o, r(o))), t;
137
+ }
138
+ setDefaultEdgeLabel(e) {
139
+ return typeof e != "function" ? this._defaultEdgeLabelFn = () => e : this._defaultEdgeLabelFn = e, this;
140
+ }
141
+ edgeCount() {
142
+ return this._edgeCount;
143
+ }
144
+ edges() {
145
+ return Object.values(this._edgeObjs);
146
+ }
147
+ setPath(e, t) {
148
+ return e.reduce((n, r) => (t !== void 0 ? this.setEdge(n, r, t) : this.setEdge(n, r), r)), this;
149
+ }
150
+ setEdge(e, t, n, r) {
151
+ let o, i, s, l, d = !1;
152
+ typeof e == "object" && e !== null && "v" in e ? (o = e.v, i = e.w, s = e.name, arguments.length === 2 && (l = t, d = !0)) : (o = e, i = t, s = r, arguments.length > 2 && (l = n, d = !0)), o = "" + o, i = "" + i, s !== void 0 && (s = "" + s);
153
+ let a = be(this._isDirected, o, i, s);
154
+ if (a in this._edgeLabels) return d && (this._edgeLabels[a] = l), this;
155
+ if (s !== void 0 && !this._isMultigraph) throw new Error("Cannot set a named edge when isMultigraph = false");
156
+ this.setNode(o), this.setNode(i), this._edgeLabels[a] = d ? l : this._defaultEdgeLabelFn(o, i, s);
157
+ let c = yr(this._isDirected, o, i, s);
158
+ return o = c.v, i = c.w, Object.freeze(c), this._edgeObjs[a] = c, xt(this._preds[i], o), xt(this._sucs[o], i), this._in[i][a] = c, this._out[o][a] = c, this._edgeCount++, this;
159
+ }
160
+ edge(e, t, n) {
161
+ let r = arguments.length === 1 ? Ae(this._isDirected, e) : be(this._isDirected, e, t, n);
162
+ return this._edgeLabels[r];
163
+ }
164
+ edgeAsObj(e, t, n) {
165
+ let r = arguments.length === 1 ? this.edge(e) : this.edge(e, t, n);
166
+ return typeof r != "object" ? { label: r } : r;
167
+ }
168
+ hasEdge(e, t, n) {
169
+ return (arguments.length === 1 ? Ae(this._isDirected, e) : be(this._isDirected, e, t, n)) in this._edgeLabels;
170
+ }
171
+ removeEdge(e, t, n) {
172
+ let r = arguments.length === 1 ? Ae(this._isDirected, e) : be(this._isDirected, e, t, n), o = this._edgeObjs[r];
173
+ if (o) {
174
+ let i = o.v, s = o.w;
175
+ delete this._edgeLabels[r], delete this._edgeObjs[r], Tt(this._preds[s], i), Tt(this._sucs[i], s), delete this._in[s][r], delete this._out[i][r], this._edgeCount--;
176
+ }
177
+ return this;
178
+ }
179
+ inEdges(e, t) {
180
+ return this.isDirected() ? this.filterEdges(this._in[e], e, t) : this.nodeEdges(e, t);
181
+ }
182
+ outEdges(e, t) {
183
+ return this.isDirected() ? this.filterEdges(this._out[e], e, t) : this.nodeEdges(e, t);
184
+ }
185
+ nodeEdges(e, t) {
186
+ if (e in this._nodes) return this.filterEdges({ ...this._in[e], ...this._out[e] }, e, t);
187
+ }
188
+ _removeFromParentsChildList(e) {
189
+ delete this._children[this._parent[e]][e];
190
+ }
191
+ filterEdges(e, t, n) {
192
+ if (!e) return;
193
+ let r = Object.values(e);
194
+ return n ? r.filter((o) => o.v === t && o.w === n || o.v === n && o.w === t) : r;
195
+ }
196
+ };
197
+ function xt(e, t) {
198
+ e[t] ? e[t]++ : e[t] = 1;
199
+ }
200
+ function Tt(e, t) {
201
+ e[t] !== void 0 && !--e[t] && delete e[t];
202
+ }
203
+ function be(e, t, n, r) {
204
+ let o = "" + t, i = "" + n;
205
+ if (!e && o > i) {
206
+ let s = o;
207
+ o = i, i = s;
208
+ }
209
+ return o + "" + i + "" + (r === void 0 ? "\0" : r);
210
+ }
211
+ function yr(e, t, n, r) {
212
+ let o = "" + t, i = "" + n;
213
+ if (!e && o > i) {
214
+ let l = o;
215
+ o = i, i = l;
216
+ }
217
+ let s = { v: o, w: i };
218
+ return r && (s.name = r), s;
219
+ }
220
+ function Ae(e, t) {
221
+ return be(e, t.v, t.w, t.name);
222
+ }
223
+ var mr = "4.0.1", Xt = {};
224
+ qt(Xt, { read: () => kr, write: () => wr });
225
+ function wr(e) {
226
+ let t = { options: { directed: e.isDirected(), multigraph: e.isMultigraph(), compound: e.isCompound() }, nodes: vr(e), edges: Er(e) }, n = e.graph();
227
+ return n !== void 0 && (t.value = structuredClone(n)), t;
228
+ }
229
+ function vr(e) {
230
+ return e.nodes().map((t) => {
231
+ let n = e.node(t), r = e.parent(t), o = { v: t };
232
+ return n !== void 0 && (o.value = n), r !== void 0 && (o.parent = r), o;
233
+ });
234
+ }
235
+ function Er(e) {
236
+ return e.edges().map((t) => {
237
+ let n = e.edge(t), r = { v: t.v, w: t.w };
238
+ return t.name !== void 0 && (r.name = t.name), n !== void 0 && (r.value = n), r;
239
+ });
240
+ }
241
+ function kr(e) {
242
+ let t = new K(e.options);
243
+ return e.value !== void 0 && t.setGraph(e.value), e.nodes.forEach((n) => {
244
+ t.setNode(n.v, n.value), n.parent && t.setParent(n.v, n.parent);
245
+ }), e.edges.forEach((n) => {
246
+ t.setEdge({ v: n.v, w: n.w, name: n.name }, n.value);
247
+ }), t;
248
+ }
249
+ var Xe = {};
250
+ qt(Xe, { CycleException: () => Ce, bellmanFord: () => Jt, components: () => _r, dijkstra: () => Se, dijkstraAll: () => Cr, findCycles: () => Ir, floydWarshall: () => Mr, isAcyclic: () => Fr, postorder: () => Lr, preorder: () => Ar, prim: () => Dr, shortestPaths: () => Rr, tarjan: () => Qt, topsort: () => en });
251
+ var xr = () => 1;
252
+ function Jt(e, t, n, r) {
253
+ return Tr(e, String(t), n || xr, r || function(o) {
254
+ return e.outEdges(o);
255
+ });
256
+ }
257
+ function Tr(e, t, n, r) {
258
+ let o = {}, i, s = 0, l = e.nodes(), d = function(u) {
259
+ let h = n(u);
260
+ o[u.v].distance + h < o[u.w].distance && (o[u.w] = { distance: o[u.v].distance + h, predecessor: u.v }, i = !0);
261
+ }, a = function() {
262
+ l.forEach(function(u) {
263
+ r(u).forEach(function(h) {
264
+ let g = h.v === u ? h.v : h.w, b = g === h.v ? h.w : h.v;
265
+ d({ v: g, w: b });
266
+ });
267
+ });
268
+ };
269
+ l.forEach(function(u) {
270
+ let h = u === t ? 0 : Number.POSITIVE_INFINITY;
271
+ o[u] = { distance: h, predecessor: "" };
272
+ });
273
+ let c = l.length;
274
+ for (let u = 1; u < c && (i = !1, s++, a(), !!i); u++) ;
275
+ if (s === c - 1 && (i = !1, a(), i)) throw new Error("The graph contains a negative weight cycle");
276
+ return o;
277
+ }
278
+ function _r(e) {
279
+ let t = {}, n = [], r;
280
+ function o(i) {
281
+ i in t || (t[i] = !0, r.push(i), e.successors(i).forEach(o), e.predecessors(i).forEach(o));
282
+ }
283
+ return e.nodes().forEach(function(i) {
284
+ r = [], o(i), r.length && n.push(r);
285
+ }), n;
286
+ }
287
+ var Zt = class {
288
+ constructor() {
289
+ this._arr = [], this._keyIndices = {};
290
+ }
291
+ size() {
292
+ return this._arr.length;
293
+ }
294
+ keys() {
295
+ return this._arr.map((e) => e.key);
296
+ }
297
+ has(e) {
298
+ return e in this._keyIndices;
299
+ }
300
+ priority(e) {
301
+ let t = this._keyIndices[e];
302
+ if (t !== void 0) return this._arr[t].priority;
303
+ }
304
+ min() {
305
+ if (this.size() === 0) throw new Error("Queue underflow");
306
+ return this._arr[0].key;
307
+ }
308
+ add(e, t) {
309
+ let n = this._keyIndices, r = String(e);
310
+ if (!(r in n)) {
311
+ let o = this._arr, i = o.length;
312
+ return n[r] = i, o.push({ key: r, priority: t }), this._decrease(i), !0;
313
+ }
314
+ return !1;
315
+ }
316
+ removeMin() {
317
+ this._swap(0, this._arr.length - 1);
318
+ let e = this._arr.pop();
319
+ return delete this._keyIndices[e.key], this._heapify(0), e.key;
320
+ }
321
+ decrease(e, t) {
322
+ let n = this._keyIndices[e];
323
+ if (n === void 0) throw new Error(`Key not found: ${e}`);
324
+ let r = this._arr[n].priority;
325
+ if (t > r) throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);
326
+ this._arr[n].priority = t, this._decrease(n);
327
+ }
328
+ _heapify(e) {
329
+ let t = this._arr, n = 2 * e, r = n + 1, o = e;
330
+ n < t.length && (o = t[n].priority < t[o].priority ? n : o, r < t.length && (o = t[r].priority < t[o].priority ? r : o), o !== e && (this._swap(e, o), this._heapify(o)));
331
+ }
332
+ _decrease(e) {
333
+ let t = this._arr, n = t[e].priority, r;
334
+ for (; e !== 0 && (r = e >> 1, !(t[r].priority < n)); ) this._swap(e, r), e = r;
335
+ }
336
+ _swap(e, t) {
337
+ let n = this._arr, r = this._keyIndices, o = n[e], i = n[t];
338
+ n[e] = i, n[t] = o, r[i.key] = e, r[o.key] = t;
339
+ }
340
+ }, Nr = () => 1;
341
+ function Se(e, t, n, r) {
342
+ let o = function(i) {
343
+ return e.outEdges(i);
344
+ };
345
+ return Sr(e, String(t), n || Nr, r || o);
346
+ }
347
+ function Sr(e, t, n, r) {
348
+ let o = {}, i = new Zt(), s, l, d = function(a) {
349
+ let c = a.v !== s ? a.v : a.w, u = o[c], h = n(a), g = l.distance + h;
350
+ if (h < 0) throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + a + " Weight: " + h);
351
+ g < u.distance && (u.distance = g, u.predecessor = s, i.decrease(c, g));
352
+ };
353
+ for (e.nodes().forEach(function(a) {
354
+ let c = a === t ? 0 : Number.POSITIVE_INFINITY;
355
+ o[a] = { distance: c, predecessor: "" }, i.add(a, c);
356
+ }); i.size() > 0 && (s = i.removeMin(), l = o[s], l.distance !== Number.POSITIVE_INFINITY); ) r(s).forEach(d);
357
+ return o;
358
+ }
359
+ function Cr(e, t, n) {
360
+ return e.nodes().reduce(function(r, o) {
361
+ return r[o] = Se(e, o, t, n), r;
362
+ }, {});
363
+ }
364
+ function Qt(e) {
365
+ let t = 0, n = [], r = {}, o = [];
366
+ function i(s) {
367
+ let l = r[s] = { onStack: !0, lowlink: t, index: t++ };
368
+ if (n.push(s), e.successors(s).forEach(function(d) {
369
+ d in r ? r[d].onStack && (l.lowlink = Math.min(l.lowlink, r[d].index)) : (i(d), l.lowlink = Math.min(l.lowlink, r[d].lowlink));
370
+ }), l.lowlink === l.index) {
371
+ let d = [], a;
372
+ do
373
+ a = n.pop(), r[a].onStack = !1, d.push(a);
374
+ while (s !== a);
375
+ o.push(d);
376
+ }
377
+ }
378
+ return e.nodes().forEach(function(s) {
379
+ s in r || i(s);
380
+ }), o;
381
+ }
382
+ function Ir(e) {
383
+ return Qt(e).filter(function(t) {
384
+ return t.length > 1 || t.length === 1 && e.hasEdge(t[0], t[0]);
385
+ });
386
+ }
387
+ var Or = () => 1;
388
+ function Mr(e, t, n) {
389
+ return jr(e, t || Or, n || function(r) {
390
+ return e.outEdges(r);
391
+ });
392
+ }
393
+ function jr(e, t, n) {
394
+ let r = {}, o = e.nodes();
395
+ return o.forEach(function(i) {
396
+ r[i] = {}, r[i][i] = { distance: 0, predecessor: "" }, o.forEach(function(s) {
397
+ i !== s && (r[i][s] = { distance: Number.POSITIVE_INFINITY, predecessor: "" });
398
+ }), n(i).forEach(function(s) {
399
+ let l = s.v === i ? s.w : s.v, d = t(s);
400
+ r[i][l] = { distance: d, predecessor: i };
401
+ });
402
+ }), o.forEach(function(i) {
403
+ let s = r[i];
404
+ o.forEach(function(l) {
405
+ let d = r[l];
406
+ o.forEach(function(a) {
407
+ let c = d[i], u = s[a], h = d[a], g = c.distance + u.distance;
408
+ g < h.distance && (h.distance = g, h.predecessor = u.predecessor);
409
+ });
410
+ });
411
+ }), r;
412
+ }
413
+ var Ce = class extends Error {
414
+ constructor(...e) {
415
+ super(...e);
416
+ }
417
+ };
418
+ function en(e) {
419
+ let t = {}, n = {}, r = [];
420
+ function o(i) {
421
+ if (i in n) throw new Ce();
422
+ i in t || (n[i] = !0, t[i] = !0, e.predecessors(i).forEach(o), delete n[i], r.push(i));
423
+ }
424
+ if (e.sinks().forEach(o), Object.keys(t).length !== e.nodeCount()) throw new Ce();
425
+ return r;
426
+ }
427
+ function Fr(e) {
428
+ try {
429
+ en(e);
430
+ } catch (t) {
431
+ if (t instanceof Ce) return !1;
432
+ throw t;
433
+ }
434
+ return !0;
435
+ }
436
+ function zr(e, t, n, r, o) {
437
+ Array.isArray(t) || (t = [t]);
438
+ let i = (l) => {
439
+ var d;
440
+ return (d = e.isDirected() ? e.successors(l) : e.neighbors(l)) != null ? d : [];
441
+ }, s = {};
442
+ return t.forEach(function(l) {
443
+ if (!e.hasNode(l)) throw new Error("Graph does not have node: " + l);
444
+ o = tn(e, l, n === "post", s, i, r, o);
445
+ }), o;
446
+ }
447
+ function tn(e, t, n, r, o, i, s) {
448
+ return t in r || (r[t] = !0, n || (s = i(s, t)), o(t).forEach(function(l) {
449
+ s = tn(e, l, n, r, o, i, s);
450
+ }), n && (s = i(s, t))), s;
451
+ }
452
+ function nn(e, t, n) {
453
+ return zr(e, t, n, function(r, o) {
454
+ return r.push(o), r;
455
+ }, []);
456
+ }
457
+ function Lr(e, t) {
458
+ return nn(e, t, "post");
459
+ }
460
+ function Ar(e, t) {
461
+ return nn(e, t, "pre");
462
+ }
463
+ function Dr(e, t) {
464
+ let n = new K(), r = {}, o = new Zt(), i;
465
+ function s(d) {
466
+ let a = d.v === i ? d.w : d.v, c = o.priority(a);
467
+ if (c !== void 0) {
468
+ let u = t(d);
469
+ u < c && (r[a] = i, o.decrease(a, u));
470
+ }
471
+ }
472
+ if (e.nodeCount() === 0) return n;
473
+ e.nodes().forEach(function(d) {
474
+ o.add(d, Number.POSITIVE_INFINITY), n.setNode(d);
475
+ }), o.decrease(e.nodes()[0], 0);
476
+ let l = !1;
477
+ for (; o.size() > 0; ) {
478
+ if (i = o.removeMin(), i in r) n.setEdge(i, r[i]);
479
+ else {
480
+ if (l) throw new Error("Input graph is not connected: " + e);
481
+ l = !0;
482
+ }
483
+ e.nodeEdges(i).forEach(s);
484
+ }
485
+ return n;
486
+ }
487
+ function Rr(e, t, n, r) {
488
+ return Pr(e, t, n, r ?? ((o) => {
489
+ let i = e.outEdges(o);
490
+ return i ?? [];
491
+ }));
492
+ }
493
+ function Pr(e, t, n, r) {
494
+ if (n === void 0) return Se(e, t, n, r);
495
+ let o = !1, i = e.nodes();
496
+ for (let s = 0; s < i.length; s++) {
497
+ let l = r(i[s]);
498
+ for (let d = 0; d < l.length; d++) {
499
+ let a = l[d], c = a.v === i[s] ? a.v : a.w, u = c === a.v ? a.w : a.v;
500
+ n({ v: c, w: u }) < 0 && (o = !0);
501
+ }
502
+ if (o) return Jt(e, t, n, r);
503
+ }
504
+ return Se(e, t, n, r);
505
+ }
506
+ function ge(e, t, n, r) {
507
+ let o = r;
508
+ for (; e.hasNode(o); ) o = Je(r);
509
+ return n.dummy = t, e.setNode(o, n), o;
510
+ }
511
+ function Br(e) {
512
+ let t = new K().setGraph(e.graph());
513
+ return e.nodes().forEach((n) => t.setNode(n, e.node(n))), e.edges().forEach((n) => {
514
+ let r = t.edge(n.v, n.w) || { weight: 0, minlen: 1 }, o = e.edge(n);
515
+ t.setEdge(n.v, n.w, { weight: r.weight + o.weight, minlen: Math.max(r.minlen, o.minlen) });
516
+ }), t;
517
+ }
518
+ function rn(e) {
519
+ let t = new K({ multigraph: e.isMultigraph() }).setGraph(e.graph());
520
+ return e.nodes().forEach((n) => {
521
+ e.children(n).length || t.setNode(n, e.node(n));
522
+ }), e.edges().forEach((n) => {
523
+ t.setEdge(n, e.edge(n));
524
+ }), t;
525
+ }
526
+ function _t(e, t) {
527
+ let n = e.x, r = e.y, o = t.x - n, i = t.y - r, s = e.width / 2, l = e.height / 2;
528
+ if (!o && !i) throw new Error("Not possible to find intersection inside of the rectangle");
529
+ let d, a;
530
+ return Math.abs(i) * s > Math.abs(o) * l ? (i < 0 && (l = -l), d = l * o / i, a = l) : (o < 0 && (s = -s), d = s, a = s * i / o), { x: n + d, y: r + a };
531
+ }
532
+ function ve(e) {
533
+ let t = me(sn(e) + 1).map(() => []);
534
+ return e.nodes().forEach((n) => {
535
+ let r = e.node(n), o = r.rank;
536
+ o !== void 0 && (t[o] || (t[o] = []), t[o][r.order] = n);
537
+ }), t;
538
+ }
539
+ function Wr(e) {
540
+ let t = e.nodes().map((r) => {
541
+ let o = e.node(r).rank;
542
+ return o === void 0 ? Number.MAX_VALUE : o;
543
+ }), n = X(Math.min, t);
544
+ e.nodes().forEach((r) => {
545
+ let o = e.node(r);
546
+ Object.hasOwn(o, "rank") && (o.rank -= n);
547
+ });
548
+ }
549
+ function Gr(e) {
550
+ let t = e.nodes().map((s) => e.node(s).rank).filter((s) => s !== void 0), n = X(Math.min, t), r = [];
551
+ e.nodes().forEach((s) => {
552
+ let l = e.node(s).rank - n;
553
+ r[l] || (r[l] = []), r[l].push(s);
554
+ });
555
+ let o = 0, i = e.graph().nodeRankFactor;
556
+ Array.from(r).forEach((s, l) => {
557
+ s === void 0 && l % i !== 0 ? --o : s !== void 0 && o && s.forEach((d) => e.node(d).rank += o);
558
+ });
559
+ }
560
+ function Nt(e, t, n, r) {
561
+ let o = { width: 0, height: 0 };
562
+ return arguments.length >= 4 && (o.rank = n, o.order = r), ge(e, "border", o, t);
563
+ }
564
+ function $r(e, t = on) {
565
+ let n = [];
566
+ for (let r = 0; r < e.length; r += t) {
567
+ let o = e.slice(r, r + t);
568
+ n.push(o);
569
+ }
570
+ return n;
571
+ }
572
+ var on = 65535;
573
+ function X(e, t) {
574
+ if (t.length > on) {
575
+ let n = $r(t);
576
+ return e(...n.map((r) => e(...r)));
577
+ } else return e(...t);
578
+ }
579
+ function sn(e) {
580
+ let t = e.nodes().map((n) => {
581
+ let r = e.node(n).rank;
582
+ return r === void 0 ? Number.MIN_VALUE : r;
583
+ });
584
+ return X(Math.max, t);
585
+ }
586
+ function Yr(e, t) {
587
+ let n = { lhs: [], rhs: [] };
588
+ return e.forEach((r) => {
589
+ t(r) ? n.lhs.push(r) : n.rhs.push(r);
590
+ }), n;
591
+ }
592
+ function ln(e, t) {
593
+ let n = Date.now();
594
+ try {
595
+ return t();
596
+ } finally {
597
+ console.log(e + " time: " + (Date.now() - n) + "ms");
598
+ }
599
+ }
600
+ function an(e, t) {
601
+ return t();
602
+ }
603
+ var Kr = 0;
604
+ function Je(e) {
605
+ let t = ++Kr;
606
+ return e + ("" + t);
607
+ }
608
+ function me(e, t, n = 1) {
609
+ t == null && (t = e, e = 0);
610
+ let r = (i) => i < t;
611
+ n < 0 && (r = (i) => t < i);
612
+ let o = [];
613
+ for (let i = e; r(i); i += n) o.push(i);
614
+ return o;
615
+ }
616
+ function Ie(e, t) {
617
+ let n = {};
618
+ for (let r of t) e[r] !== void 0 && (n[r] = e[r]);
619
+ return n;
620
+ }
621
+ function Oe(e, t) {
622
+ let n;
623
+ return typeof t == "string" ? n = (r) => r[t] : n = t, Object.entries(e).reduce((r, [o, i]) => (r[o] = n(i, o), r), {});
624
+ }
625
+ function Ur(e, t) {
626
+ return e.reduce((n, r, o) => (n[r] = t[o], n), {});
627
+ }
628
+ var Me = "\0", Vr = "3.0.0", Hr = class {
629
+ constructor() {
630
+ pr(this, "_sentinel");
631
+ let e = {};
632
+ e._next = e._prev = e, this._sentinel = e;
633
+ }
634
+ dequeue() {
635
+ let e = this._sentinel, t = e._prev;
636
+ if (t !== e) return St(t), t;
637
+ }
638
+ enqueue(e) {
639
+ let t = this._sentinel;
640
+ e._prev && e._next && St(e), e._next = t._next, t._next._prev = e, t._next = e, e._prev = t;
641
+ }
642
+ toString() {
643
+ let e = [], t = this._sentinel, n = t._prev;
644
+ for (; n !== t; ) e.push(JSON.stringify(n, qr)), n = n._prev;
645
+ return "[" + e.join(", ") + "]";
646
+ }
647
+ };
648
+ function St(e) {
649
+ e._prev._next = e._next, e._next._prev = e._prev, delete e._next, delete e._prev;
650
+ }
651
+ function qr(e, t) {
652
+ if (e !== "_next" && e !== "_prev") return t;
653
+ }
654
+ var Xr = Hr, Jr = () => 1;
655
+ function Zr(e, t) {
656
+ if (e.nodeCount() <= 1) return [];
657
+ let n = eo(e, t || Jr);
658
+ return Qr(n.graph, n.buckets, n.zeroIdx).flatMap((r) => e.outEdges(r.v, r.w) || []);
659
+ }
660
+ function Qr(e, t, n) {
661
+ var r;
662
+ let o = [], i = t[t.length - 1], s = t[0], l;
663
+ for (; e.nodeCount(); ) {
664
+ for (; l = s.dequeue(); ) De(e, t, n, l);
665
+ for (; l = i.dequeue(); ) De(e, t, n, l);
666
+ if (e.nodeCount()) {
667
+ for (let d = t.length - 2; d > 0; --d) if (l = (r = t[d]) == null ? void 0 : r.dequeue(), l) {
668
+ o = o.concat(De(e, t, n, l, !0) || []);
669
+ break;
670
+ }
671
+ }
672
+ }
673
+ return o;
674
+ }
675
+ function De(e, t, n, r, o) {
676
+ let i = [], s = o ? i : void 0;
677
+ return (e.inEdges(r.v) || []).forEach((l) => {
678
+ let d = e.edge(l), a = e.node(l.v);
679
+ o && i.push({ v: l.v, w: l.w }), a.out -= d, Ke(t, n, a);
680
+ }), (e.outEdges(r.v) || []).forEach((l) => {
681
+ let d = e.edge(l), a = l.w, c = e.node(a);
682
+ c.in -= d, Ke(t, n, c);
683
+ }), e.removeNode(r.v), s;
684
+ }
685
+ function eo(e, t) {
686
+ let n = new K(), r = 0, o = 0;
687
+ e.nodes().forEach((l) => {
688
+ n.setNode(l, { v: l, in: 0, out: 0 });
689
+ }), e.edges().forEach((l) => {
690
+ let d = n.edge(l.v, l.w) || 0, a = t(l), c = d + a;
691
+ n.setEdge(l.v, l.w, c);
692
+ let u = n.node(l.v), h = n.node(l.w);
693
+ o = Math.max(o, u.out += a), r = Math.max(r, h.in += a);
694
+ });
695
+ let i = to(o + r + 3).map(() => new Xr()), s = r + 1;
696
+ return n.nodes().forEach((l) => {
697
+ Ke(i, s, n.node(l));
698
+ }), { graph: n, buckets: i, zeroIdx: s };
699
+ }
700
+ function Ke(e, t, n) {
701
+ var r, o, i;
702
+ n.out ? n.in ? (i = e[n.out - n.in + t]) == null || i.enqueue(n) : (o = e[e.length - 1]) == null || o.enqueue(n) : (r = e[0]) == null || r.enqueue(n);
703
+ }
704
+ function to(e) {
705
+ let t = [];
706
+ for (let n = 0; n < e; n++) t.push(n);
707
+ return t;
708
+ }
709
+ function no(e) {
710
+ (e.graph().acyclicer === "greedy" ? Zr(e, t(e)) : ro(e)).forEach((n) => {
711
+ let r = e.edge(n);
712
+ e.removeEdge(n), r.forwardName = n.name, r.reversed = !0, e.setEdge(n.w, n.v, r, Je("rev"));
713
+ });
714
+ function t(n) {
715
+ return (r) => n.edge(r).weight;
716
+ }
717
+ }
718
+ function ro(e) {
719
+ let t = [], n = {}, r = {};
720
+ function o(i) {
721
+ Object.hasOwn(r, i) || (r[i] = !0, n[i] = !0, e.outEdges(i).forEach((s) => {
722
+ Object.hasOwn(n, s.w) ? t.push(s) : o(s.w);
723
+ }), delete n[i]);
724
+ }
725
+ return e.nodes().forEach(o), t;
726
+ }
727
+ function oo(e) {
728
+ e.edges().forEach((t) => {
729
+ let n = e.edge(t);
730
+ if (n.reversed) {
731
+ e.removeEdge(t);
732
+ let r = n.forwardName;
733
+ delete n.reversed, delete n.forwardName, e.setEdge(t.w, t.v, n, r);
734
+ }
735
+ });
736
+ }
737
+ function io(e) {
738
+ e.graph().dummyChains = [], e.edges().forEach((t) => so(e, t));
739
+ }
740
+ function so(e, t) {
741
+ let n = t.v, r = e.node(n).rank, o = t.w, i = e.node(o).rank, s = t.name, l = e.edge(t), d = l.labelRank;
742
+ if (i === r + 1) return;
743
+ e.removeEdge(t);
744
+ let a, c, u;
745
+ for (u = 0, ++r; r < i; ++u, ++r) l.points = [], c = { width: 0, height: 0, edgeLabel: l, edgeObj: t, rank: r }, a = ge(e, "edge", c, "_d"), r === d && (c.width = l.width, c.height = l.height, c.dummy = "edge-label", c.labelpos = l.labelpos), e.setEdge(n, a, { weight: l.weight }, s), u === 0 && e.graph().dummyChains.push(a), n = a;
746
+ e.setEdge(n, o, { weight: l.weight }, s);
747
+ }
748
+ function lo(e) {
749
+ e.graph().dummyChains.forEach((t) => {
750
+ let n = e.node(t), r = n.edgeLabel, o;
751
+ for (e.setEdge(n.edgeObj, r); n.dummy; ) o = e.successors(t)[0], e.removeNode(t), r.points.push({ x: n.x, y: n.y }), n.dummy === "edge-label" && (r.x = n.x, r.y = n.y, r.width = n.width, r.height = n.height), t = o, n = e.node(t);
752
+ });
753
+ }
754
+ function Ze(e) {
755
+ let t = {};
756
+ function n(r) {
757
+ let o = e.node(r);
758
+ if (Object.hasOwn(t, r)) return o.rank;
759
+ t[r] = !0;
760
+ let i = e.outEdges(r), s = i ? i.map((d) => d == null ? Number.POSITIVE_INFINITY : n(d.w) - e.edge(d).minlen) : [], l = X(Math.min, s);
761
+ return l === Number.POSITIVE_INFINITY && (l = 0), o.rank = l;
762
+ }
763
+ e.sources().forEach(n);
764
+ }
765
+ function he(e, t) {
766
+ return e.node(t.w).rank - e.node(t.v).rank - e.edge(t).minlen;
767
+ }
768
+ var dn = ao;
769
+ function ao(e) {
770
+ let t = new K({ directed: !1 }), n = e.nodes();
771
+ if (n.length === 0) throw new Error("Graph must have at least one node");
772
+ let r = n[0], o = e.nodeCount();
773
+ t.setNode(r, {});
774
+ let i, s;
775
+ for (; co(t, e) < o && (i = uo(t, e), !!i); ) s = t.hasNode(i.v) ? he(e, i) : -he(e, i), fo(t, e, s);
776
+ return t;
777
+ }
778
+ function co(e, t) {
779
+ function n(r) {
780
+ let o = t.nodeEdges(r);
781
+ o && o.forEach((i) => {
782
+ let s = i.v, l = r === s ? i.w : s;
783
+ !e.hasNode(l) && !he(t, i) && (e.setNode(l, {}), e.setEdge(r, l, {}), n(l));
784
+ });
785
+ }
786
+ return e.nodes().forEach(n), e.nodeCount();
787
+ }
788
+ function uo(e, t) {
789
+ return t.edges().reduce((n, r) => {
790
+ let o = Number.POSITIVE_INFINITY;
791
+ return e.hasNode(r.v) !== e.hasNode(r.w) && (o = he(t, r)), o < n[0] ? [o, r] : n;
792
+ }, [Number.POSITIVE_INFINITY, null])[1];
793
+ }
794
+ function fo(e, t, n) {
795
+ e.nodes().forEach((r) => t.node(r).rank += n);
796
+ }
797
+ var { preorder: ho, postorder: go } = Xe, po = de;
798
+ de.initLowLimValues = et;
799
+ de.initCutValues = Qe;
800
+ de.calcCutValue = cn;
801
+ de.leaveEdge = fn;
802
+ de.enterEdge = hn;
803
+ de.exchangeEdges = gn;
804
+ function de(e) {
805
+ e = Br(e), Ze(e);
806
+ let t = dn(e);
807
+ et(t), Qe(t, e);
808
+ let n, r;
809
+ for (; n = fn(t); ) r = hn(t, e, n), gn(t, e, n, r);
810
+ }
811
+ function Qe(e, t) {
812
+ let n = go(e, e.nodes());
813
+ n = n.slice(0, n.length - 1), n.forEach((r) => bo(e, t, r));
814
+ }
815
+ function bo(e, t, n) {
816
+ let r = e.node(n).parent, o = e.edge(n, r);
817
+ o.cutvalue = cn(e, t, n);
818
+ }
819
+ function cn(e, t, n) {
820
+ let r = e.node(n).parent, o = !0, i = t.edge(n, r), s = 0;
821
+ i || (o = !1, i = t.edge(r, n)), s = i.weight;
822
+ let l = t.nodeEdges(n);
823
+ return l && l.forEach((d) => {
824
+ let a = d.v === n, c = a ? d.w : d.v;
825
+ if (c !== r) {
826
+ let u = a === o, h = t.edge(d).weight;
827
+ if (s += u ? h : -h, mo(e, n, c)) {
828
+ let g = e.edge(n, c).cutvalue;
829
+ s += u ? -g : g;
830
+ }
831
+ }
832
+ }), s;
833
+ }
834
+ function et(e, t) {
835
+ arguments.length < 2 && (t = e.nodes()[0]), un(e, {}, 1, t);
836
+ }
837
+ function un(e, t, n, r, o) {
838
+ let i = n, s = e.node(r);
839
+ t[r] = !0;
840
+ let l = e.neighbors(r);
841
+ return l && l.forEach((d) => {
842
+ Object.hasOwn(t, d) || (n = un(e, t, n, d, r));
843
+ }), s.low = i, s.lim = n++, o ? s.parent = o : delete s.parent, n;
844
+ }
845
+ function fn(e) {
846
+ return e.edges().find((t) => e.edge(t).cutvalue < 0);
847
+ }
848
+ function hn(e, t, n) {
849
+ let r = n.v, o = n.w;
850
+ t.hasEdge(r, o) || (r = n.w, o = n.v);
851
+ let i = e.node(r), s = e.node(o), l = i, d = !1;
852
+ return i.lim > s.lim && (l = s, d = !0), t.edges().filter((a) => d === Ct(e, e.node(a.v), l) && d !== Ct(e, e.node(a.w), l)).reduce((a, c) => he(t, c) < he(t, a) ? c : a);
853
+ }
854
+ function gn(e, t, n, r) {
855
+ let o = n.v, i = n.w;
856
+ e.removeEdge(o, i), e.setEdge(r.v, r.w, {}), et(e), Qe(e, t), yo(e, t);
857
+ }
858
+ function yo(e, t) {
859
+ let n = e.nodes().find((o) => !e.node(o).parent);
860
+ if (!n) return;
861
+ let r = ho(e, [n]);
862
+ r = r.slice(1), r.forEach((o) => {
863
+ let i = e.node(o).parent, s = t.edge(o, i), l = !1;
864
+ s || (s = t.edge(i, o), l = !0), t.node(o).rank = t.node(i).rank + (l ? s.minlen : -s.minlen);
865
+ });
866
+ }
867
+ function mo(e, t, n) {
868
+ return e.hasEdge(t, n);
869
+ }
870
+ function Ct(e, t, n) {
871
+ return n.low <= t.lim && t.lim <= n.lim;
872
+ }
873
+ var wo = vo;
874
+ function vo(e) {
875
+ let t = e.graph().ranker;
876
+ if (typeof t == "function") return t(e);
877
+ switch (t) {
878
+ case "network-simplex":
879
+ It(e);
880
+ break;
881
+ case "tight-tree":
882
+ ko(e);
883
+ break;
884
+ case "longest-path":
885
+ Eo(e);
886
+ break;
887
+ case "none":
888
+ break;
889
+ default:
890
+ It(e);
891
+ }
892
+ }
893
+ var Eo = Ze;
894
+ function ko(e) {
895
+ Ze(e), dn(e);
896
+ }
897
+ function It(e) {
898
+ po(e);
899
+ }
900
+ var xo = To;
901
+ function To(e) {
902
+ let t = No(e);
903
+ e.graph().dummyChains.forEach((n) => {
904
+ let r = e.node(n), o = r.edgeObj, i = _o(e, t, o.v, o.w), s = i.path, l = i.lca, d = 0, a = s[d], c = !0;
905
+ for (; n !== o.w; ) {
906
+ if (r = e.node(n), c) {
907
+ for (; (a = s[d]) !== l && e.node(a).maxRank < r.rank; ) d++;
908
+ a === l && (c = !1);
909
+ }
910
+ if (!c) {
911
+ for (; d < s.length - 1 && e.node(s[d + 1]).minRank <= r.rank; ) d++;
912
+ a = s[d];
913
+ }
914
+ a !== void 0 && e.setParent(n, a), n = e.successors(n)[0];
915
+ }
916
+ });
917
+ }
918
+ function _o(e, t, n, r) {
919
+ let o = [], i = [], s = Math.min(t[n].low, t[r].low), l = Math.max(t[n].lim, t[r].lim), d;
920
+ d = n;
921
+ do
922
+ d = e.parent(d), o.push(d);
923
+ while (d && (t[d].low > s || l > t[d].lim));
924
+ let a = d, c = r;
925
+ for (; (c = e.parent(c)) !== a; ) i.push(c);
926
+ return { path: o.concat(i.reverse()), lca: a };
927
+ }
928
+ function No(e) {
929
+ let t = {}, n = 0;
930
+ function r(o) {
931
+ let i = n;
932
+ e.children(o).forEach(r), t[o] = { low: i, lim: n++ };
933
+ }
934
+ return e.children(Me).forEach(r), t;
935
+ }
936
+ function So(e) {
937
+ let t = ge(e, "root", {}, "_root"), n = Co(e), r = Object.values(n), o = X(Math.max, r) - 1, i = 2 * o + 1;
938
+ e.graph().nestingRoot = t, e.edges().forEach((l) => e.edge(l).minlen *= i);
939
+ let s = Io(e) + 1;
940
+ e.children(Me).forEach((l) => pn(e, t, i, s, o, n, l)), e.graph().nodeRankFactor = i;
941
+ }
942
+ function pn(e, t, n, r, o, i, s) {
943
+ var l;
944
+ let d = e.children(s);
945
+ if (!d.length) {
946
+ s !== t && e.setEdge(t, s, { weight: 0, minlen: n });
947
+ return;
948
+ }
949
+ let a = Nt(e, "_bt"), c = Nt(e, "_bb"), u = e.node(s);
950
+ e.setParent(a, s), u.borderTop = a, e.setParent(c, s), u.borderBottom = c, d.forEach((h) => {
951
+ var g;
952
+ pn(e, t, n, r, o, i, h);
953
+ let b = e.node(h), E = b.borderTop ? b.borderTop : h, y = b.borderBottom ? b.borderBottom : h, x = b.borderTop ? r : 2 * r, N = E !== y ? 1 : o - ((g = i[s]) != null ? g : 0) + 1;
954
+ e.setEdge(a, E, { weight: x, minlen: N, nestingEdge: !0 }), e.setEdge(y, c, { weight: x, minlen: N, nestingEdge: !0 });
955
+ }), e.parent(s) || e.setEdge(t, a, { weight: 0, minlen: o + ((l = i[s]) != null ? l : 0) });
956
+ }
957
+ function Co(e) {
958
+ let t = {};
959
+ function n(r, o) {
960
+ let i = e.children(r);
961
+ i && i.length && i.forEach((s) => n(s, o + 1)), t[r] = o;
962
+ }
963
+ return e.children(Me).forEach((r) => n(r, 1)), t;
964
+ }
965
+ function Io(e) {
966
+ return e.edges().reduce((t, n) => t + e.edge(n).weight, 0);
967
+ }
968
+ function Oo(e) {
969
+ let t = e.graph();
970
+ e.removeNode(t.nestingRoot), delete t.nestingRoot, e.edges().forEach((n) => {
971
+ e.edge(n).nestingEdge && e.removeEdge(n);
972
+ });
973
+ }
974
+ var Mo = jo;
975
+ function jo(e) {
976
+ function t(n) {
977
+ let r = e.children(n), o = e.node(n);
978
+ if (r.length && r.forEach(t), Object.hasOwn(o, "minRank")) {
979
+ o.borderLeft = [], o.borderRight = [];
980
+ for (let i = o.minRank, s = o.maxRank + 1; i < s; ++i) Ot(e, "borderLeft", "_bl", n, o, i), Ot(e, "borderRight", "_br", n, o, i);
981
+ }
982
+ }
983
+ e.children(Me).forEach(t);
984
+ }
985
+ function Ot(e, t, n, r, o, i) {
986
+ let s = { width: 0, height: 0, rank: i, borderType: t }, l = o[t][i - 1], d = ge(e, "border", s, n);
987
+ o[t][i] = d, e.setParent(d, r), l && e.setEdge(l, d, { weight: 1 });
988
+ }
989
+ function Fo(e) {
990
+ var t;
991
+ let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
992
+ (n === "lr" || n === "rl") && bn(e);
993
+ }
994
+ function zo(e) {
995
+ var t;
996
+ let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
997
+ (n === "bt" || n === "rl") && Lo(e), (n === "lr" || n === "rl") && (Ao(e), bn(e));
998
+ }
999
+ function bn(e) {
1000
+ e.nodes().forEach((t) => Mt(e.node(t))), e.edges().forEach((t) => Mt(e.edge(t)));
1001
+ }
1002
+ function Mt(e) {
1003
+ let t = e.width;
1004
+ e.width = e.height, e.height = t;
1005
+ }
1006
+ function Lo(e) {
1007
+ e.nodes().forEach((t) => Re(e.node(t))), e.edges().forEach((t) => {
1008
+ var n;
1009
+ let r = e.edge(t);
1010
+ (n = r.points) == null || n.forEach(Re), Object.hasOwn(r, "y") && Re(r);
1011
+ });
1012
+ }
1013
+ function Re(e) {
1014
+ e.y = -e.y;
1015
+ }
1016
+ function Ao(e) {
1017
+ e.nodes().forEach((t) => Pe(e.node(t))), e.edges().forEach((t) => {
1018
+ var n;
1019
+ let r = e.edge(t);
1020
+ (n = r.points) == null || n.forEach(Pe), Object.hasOwn(r, "x") && Pe(r);
1021
+ });
1022
+ }
1023
+ function Pe(e) {
1024
+ let t = e.x;
1025
+ e.x = e.y, e.y = t;
1026
+ }
1027
+ function Do(e) {
1028
+ let t = {}, n = e.nodes().filter((l) => !e.children(l).length), r = n.map((l) => e.node(l).rank), o = X(Math.max, r), i = me(o + 1).map(() => []);
1029
+ function s(l) {
1030
+ if (t[l]) return;
1031
+ t[l] = !0;
1032
+ let d = e.node(l);
1033
+ i[d.rank].push(l);
1034
+ let a = e.successors(l);
1035
+ a && a.forEach(s);
1036
+ }
1037
+ return n.sort((l, d) => e.node(l).rank - e.node(d).rank).forEach(s), i;
1038
+ }
1039
+ function Ro(e, t) {
1040
+ let n = 0;
1041
+ for (let r = 1; r < t.length; ++r) n += Po(e, t[r - 1], t[r]);
1042
+ return n;
1043
+ }
1044
+ function Po(e, t, n) {
1045
+ let r = Ur(n, n.map((a, c) => c)), o = t.flatMap((a) => {
1046
+ let c = e.outEdges(a);
1047
+ return c ? c.map((u) => ({ pos: r[u.w], weight: e.edge(u).weight })).sort((u, h) => u.pos - h.pos) : [];
1048
+ }), i = 1;
1049
+ for (; i < n.length; ) i <<= 1;
1050
+ let s = 2 * i - 1;
1051
+ i -= 1;
1052
+ let l = new Array(s).fill(0), d = 0;
1053
+ return o.forEach((a) => {
1054
+ let c = a.pos + i;
1055
+ l[c] += a.weight;
1056
+ let u = 0;
1057
+ for (; c > 0; ) c % 2 && (u += l[c + 1]), c = c - 1 >> 1, l[c] += a.weight;
1058
+ d += a.weight * u;
1059
+ }), d;
1060
+ }
1061
+ function Bo(e, t = []) {
1062
+ return t.map((n) => {
1063
+ let r = e.inEdges(n);
1064
+ if (!r || !r.length) return { v: n };
1065
+ {
1066
+ let o = r.reduce((i, s) => {
1067
+ let l = e.edge(s), d = e.node(s.v);
1068
+ return { sum: i.sum + l.weight * d.order, weight: i.weight + l.weight };
1069
+ }, { sum: 0, weight: 0 });
1070
+ return { v: n, barycenter: o.sum / o.weight, weight: o.weight };
1071
+ }
1072
+ });
1073
+ }
1074
+ function Wo(e, t) {
1075
+ let n = {};
1076
+ e.forEach((o, i) => {
1077
+ let s = { indegree: 0, in: [], out: [], vs: [o.v], i };
1078
+ o.barycenter !== void 0 && (s.barycenter = o.barycenter, s.weight = o.weight), n[o.v] = s;
1079
+ }), t.edges().forEach((o) => {
1080
+ let i = n[o.v], s = n[o.w];
1081
+ i !== void 0 && s !== void 0 && (s.indegree++, i.out.push(s));
1082
+ });
1083
+ let r = Object.values(n).filter((o) => !o.indegree);
1084
+ return Go(r);
1085
+ }
1086
+ function Go(e) {
1087
+ let t = [];
1088
+ function n(o) {
1089
+ return (i) => {
1090
+ i.merged || (i.barycenter === void 0 || o.barycenter === void 0 || i.barycenter >= o.barycenter) && $o(o, i);
1091
+ };
1092
+ }
1093
+ function r(o) {
1094
+ return (i) => {
1095
+ i.in.push(o), --i.indegree === 0 && e.push(i);
1096
+ };
1097
+ }
1098
+ for (; e.length; ) {
1099
+ let o = e.pop();
1100
+ t.push(o), o.in.reverse().forEach(n(o)), o.out.forEach(r(o));
1101
+ }
1102
+ return t.filter((o) => !o.merged).map((o) => Ie(o, ["vs", "i", "barycenter", "weight"]));
1103
+ }
1104
+ function $o(e, t) {
1105
+ let n = 0, r = 0;
1106
+ e.weight && (n += e.barycenter * e.weight, r += e.weight), t.weight && (n += t.barycenter * t.weight, r += t.weight), e.vs = t.vs.concat(e.vs), e.barycenter = n / r, e.weight = r, e.i = Math.min(t.i, e.i), t.merged = !0;
1107
+ }
1108
+ function Yo(e, t) {
1109
+ let n = Yr(e, (c) => Object.hasOwn(c, "barycenter")), r = n.lhs, o = n.rhs.sort((c, u) => u.i - c.i), i = [], s = 0, l = 0, d = 0;
1110
+ r.sort(Ko(!!t)), d = jt(i, o, d), r.forEach((c) => {
1111
+ d += c.vs.length, i.push(c.vs), s += c.barycenter * c.weight, l += c.weight, d = jt(i, o, d);
1112
+ });
1113
+ let a = { vs: i.flat(1) };
1114
+ return l && (a.barycenter = s / l, a.weight = l), a;
1115
+ }
1116
+ function jt(e, t, n) {
1117
+ let r;
1118
+ for (; t.length && (r = t[t.length - 1]).i <= n; ) t.pop(), e.push(r.vs), n++;
1119
+ return n;
1120
+ }
1121
+ function Ko(e) {
1122
+ return (t, n) => t.barycenter < n.barycenter ? -1 : t.barycenter > n.barycenter ? 1 : e ? n.i - t.i : t.i - n.i;
1123
+ }
1124
+ function yn(e, t, n, r) {
1125
+ let o = e.children(t), i = e.node(t), s = i ? i.borderLeft : void 0, l = i ? i.borderRight : void 0, d = {};
1126
+ s && (o = o.filter((h) => h !== s && h !== l));
1127
+ let a = Bo(e, o);
1128
+ a.forEach((h) => {
1129
+ if (e.children(h.v).length) {
1130
+ let g = yn(e, h.v, n, r);
1131
+ d[h.v] = g, Object.hasOwn(g, "barycenter") && Vo(h, g);
1132
+ }
1133
+ });
1134
+ let c = Wo(a, n);
1135
+ Uo(c, d);
1136
+ let u = Yo(c, r);
1137
+ if (s && l) {
1138
+ u.vs = [s, u.vs, l].flat(1);
1139
+ let h = e.predecessors(s);
1140
+ if (h && h.length) {
1141
+ let g = e.node(h[0]), b = e.predecessors(l), E = e.node(b[0]);
1142
+ Object.hasOwn(u, "barycenter") || (u.barycenter = 0, u.weight = 0), u.barycenter = (u.barycenter * u.weight + g.order + E.order) / (u.weight + 2), u.weight += 2;
1143
+ }
1144
+ }
1145
+ return u;
1146
+ }
1147
+ function Uo(e, t) {
1148
+ e.forEach((n) => {
1149
+ n.vs = n.vs.flatMap((r) => t[r] ? t[r].vs : r);
1150
+ });
1151
+ }
1152
+ function Vo(e, t) {
1153
+ e.barycenter !== void 0 ? (e.barycenter = (e.barycenter * e.weight + t.barycenter * t.weight) / (e.weight + t.weight), e.weight += t.weight) : (e.barycenter = t.barycenter, e.weight = t.weight);
1154
+ }
1155
+ function Ho(e, t, n, r) {
1156
+ r || (r = e.nodes());
1157
+ let o = qo(e), i = new K({ compound: !0 }).setGraph({ root: o }).setDefaultNodeLabel((s) => e.node(s));
1158
+ return r.forEach((s) => {
1159
+ let l = e.node(s), d = e.parent(s);
1160
+ if (l.rank === t || l.minRank <= t && t <= l.maxRank) {
1161
+ i.setNode(s), i.setParent(s, d || o);
1162
+ let a = e[n](s);
1163
+ a && a.forEach((c) => {
1164
+ let u = c.v === s ? c.w : c.v, h = i.edge(u, s), g = h !== void 0 ? h.weight : 0;
1165
+ i.setEdge(u, s, { weight: e.edge(c).weight + g });
1166
+ }), Object.hasOwn(l, "minRank") && i.setNode(s, { borderLeft: l.borderLeft[t], borderRight: l.borderRight[t] });
1167
+ }
1168
+ }), i;
1169
+ }
1170
+ function qo(e) {
1171
+ let t;
1172
+ for (; e.hasNode(t = Je("_root")); ) ;
1173
+ return t;
1174
+ }
1175
+ function Xo(e, t, n) {
1176
+ let r = {}, o;
1177
+ n.forEach((i) => {
1178
+ let s = e.parent(i), l, d;
1179
+ for (; s; ) {
1180
+ if (l = e.parent(s), l ? (d = r[l], r[l] = s) : (d = o, o = s), d && d !== s) {
1181
+ t.setEdge(d, s);
1182
+ return;
1183
+ }
1184
+ s = l;
1185
+ }
1186
+ });
1187
+ }
1188
+ function mn(e, t = {}) {
1189
+ if (typeof t.customOrder == "function") {
1190
+ t.customOrder(e, mn);
1191
+ return;
1192
+ }
1193
+ let n = sn(e), r = Ft(e, me(1, n + 1), "inEdges"), o = Ft(e, me(n - 1, -1, -1), "outEdges"), i = Do(e);
1194
+ if (zt(e, i), t.disableOptimalOrderHeuristic) return;
1195
+ let s = Number.POSITIVE_INFINITY, l, d = t.constraints || [];
1196
+ for (let a = 0, c = 0; c < 4; ++a, ++c) {
1197
+ Jo(a % 2 ? r : o, a % 4 >= 2, d), i = ve(e);
1198
+ let u = Ro(e, i);
1199
+ u < s ? (c = 0, l = Object.assign({}, i), s = u) : u === s && (l = structuredClone(i));
1200
+ }
1201
+ zt(e, l);
1202
+ }
1203
+ function Ft(e, t, n) {
1204
+ let r = /* @__PURE__ */ new Map(), o = (i, s) => {
1205
+ r.has(i) || r.set(i, []), r.get(i).push(s);
1206
+ };
1207
+ for (let i of e.nodes()) {
1208
+ let s = e.node(i);
1209
+ if (typeof s.rank == "number" && o(s.rank, i), typeof s.minRank == "number" && typeof s.maxRank == "number") for (let l = s.minRank; l <= s.maxRank; l++) l !== s.rank && o(l, i);
1210
+ }
1211
+ return t.map(function(i) {
1212
+ return Ho(e, i, n, r.get(i) || []);
1213
+ });
1214
+ }
1215
+ function Jo(e, t, n) {
1216
+ let r = new K();
1217
+ e.forEach(function(o) {
1218
+ n.forEach((l) => r.setEdge(l.left, l.right));
1219
+ let i = o.graph().root, s = yn(o, i, r, t);
1220
+ s.vs.forEach((l, d) => o.node(l).order = d), Xo(o, r, s.vs);
1221
+ });
1222
+ }
1223
+ function zt(e, t) {
1224
+ Object.values(t).forEach((n) => n.forEach((r, o) => e.node(r).order = o));
1225
+ }
1226
+ function Zo(e, t) {
1227
+ let n = {};
1228
+ function r(o, i) {
1229
+ let s = 0, l = 0, d = o.length, a = i[i.length - 1];
1230
+ return i.forEach((c, u) => {
1231
+ let h = ei(e, c), g = h ? e.node(h).order : d;
1232
+ (h || c === a) && (i.slice(l, u + 1).forEach((b) => {
1233
+ let E = e.predecessors(b);
1234
+ E && E.forEach((y) => {
1235
+ let x = e.node(y), N = x.order;
1236
+ (N < s || g < N) && !(x.dummy && e.node(b).dummy) && wn(n, y, b);
1237
+ });
1238
+ }), l = u + 1, s = g);
1239
+ }), i;
1240
+ }
1241
+ return t.length && t.reduce(r), n;
1242
+ }
1243
+ function Qo(e, t) {
1244
+ let n = {};
1245
+ function r(i, s, l, d, a) {
1246
+ me(s, l).forEach((c) => {
1247
+ let u = i[c];
1248
+ if (u !== void 0 && e.node(u).dummy) {
1249
+ let h = e.predecessors(u);
1250
+ h && h.forEach((g) => {
1251
+ if (g === void 0) return;
1252
+ let b = e.node(g);
1253
+ b.dummy && (b.order < d || b.order > a) && wn(n, g, u);
1254
+ });
1255
+ }
1256
+ });
1257
+ }
1258
+ function o(i, s) {
1259
+ let l = -1, d = -1, a = 0;
1260
+ return s.forEach((c, u) => {
1261
+ if (e.node(c).dummy === "border") {
1262
+ let h = e.predecessors(c);
1263
+ if (h && h.length) {
1264
+ let g = h[0];
1265
+ if (g === void 0) return;
1266
+ d = e.node(g).order, r(s, a, u, l, d), a = u, l = d;
1267
+ }
1268
+ }
1269
+ r(s, a, s.length, d, i.length);
1270
+ }), s;
1271
+ }
1272
+ return t.length && t.reduce(o), n;
1273
+ }
1274
+ function ei(e, t) {
1275
+ if (e.node(t).dummy) {
1276
+ let n = e.predecessors(t);
1277
+ if (n) return n.find((r) => e.node(r).dummy);
1278
+ }
1279
+ }
1280
+ function wn(e, t, n) {
1281
+ if (t > n) {
1282
+ let o = t;
1283
+ t = n, n = o;
1284
+ }
1285
+ let r = e[t];
1286
+ r || (e[t] = r = {}), r[n] = !0;
1287
+ }
1288
+ function ti(e, t, n) {
1289
+ if (t > n) {
1290
+ let o = t;
1291
+ t = n, n = o;
1292
+ }
1293
+ let r = e[t];
1294
+ return r !== void 0 && Object.hasOwn(r, n);
1295
+ }
1296
+ function ni(e, t, n, r) {
1297
+ let o = {}, i = {}, s = {};
1298
+ return t.forEach((l) => {
1299
+ l.forEach((d, a) => {
1300
+ o[d] = d, i[d] = d, s[d] = a;
1301
+ });
1302
+ }), t.forEach((l) => {
1303
+ let d = -1;
1304
+ l.forEach((a) => {
1305
+ let c = r(a);
1306
+ if (c && c.length) {
1307
+ let u = c.sort((g, b) => {
1308
+ let E = s[g], y = s[b];
1309
+ return (E !== void 0 ? E : 0) - (y !== void 0 ? y : 0);
1310
+ }), h = (u.length - 1) / 2;
1311
+ for (let g = Math.floor(h), b = Math.ceil(h); g <= b; ++g) {
1312
+ let E = u[g];
1313
+ if (E === void 0) continue;
1314
+ let y = s[E];
1315
+ if (y !== void 0 && i[a] === a && d < y && !ti(n, a, E)) {
1316
+ let x = o[E];
1317
+ x !== void 0 && (i[E] = a, i[a] = o[a] = x, d = y);
1318
+ }
1319
+ }
1320
+ }
1321
+ });
1322
+ }), { root: o, align: i };
1323
+ }
1324
+ function ri(e, t, n, r, o = !1) {
1325
+ let i = {}, s = oi(e, t, n, o), l = o ? "borderLeft" : "borderRight";
1326
+ function d(g, b) {
1327
+ let E = s.nodes().slice(), y = {}, x = E.pop();
1328
+ for (; x; ) {
1329
+ if (y[x]) g(x);
1330
+ else {
1331
+ y[x] = !0, E.push(x);
1332
+ for (let N of b(x)) E.push(N);
1333
+ }
1334
+ x = E.pop();
1335
+ }
1336
+ }
1337
+ function a(g) {
1338
+ let b = s.inEdges(g);
1339
+ b ? i[g] = b.reduce((E, y) => {
1340
+ var x;
1341
+ let N = (x = i[y.v]) != null ? x : 0, O = s.edge(y);
1342
+ return Math.max(E, N + (O !== void 0 ? O : 0));
1343
+ }, 0) : i[g] = 0;
1344
+ }
1345
+ function c(g) {
1346
+ let b = s.outEdges(g), E = Number.POSITIVE_INFINITY;
1347
+ b && (E = b.reduce((x, N) => {
1348
+ let O = i[N.w], F = s.edge(N);
1349
+ return Math.min(x, (O !== void 0 ? O : 0) - (F !== void 0 ? F : 0));
1350
+ }, Number.POSITIVE_INFINITY));
1351
+ let y = e.node(g);
1352
+ E !== Number.POSITIVE_INFINITY && y.borderType !== l && (i[g] = Math.max(i[g] !== void 0 ? i[g] : 0, E));
1353
+ }
1354
+ function u(g) {
1355
+ return s.predecessors(g) || [];
1356
+ }
1357
+ function h(g) {
1358
+ return s.successors(g) || [];
1359
+ }
1360
+ return d(a, u), d(c, h), Object.keys(r).forEach((g) => {
1361
+ var b;
1362
+ let E = n[g];
1363
+ E !== void 0 && (i[g] = (b = i[E]) != null ? b : 0);
1364
+ }), i;
1365
+ }
1366
+ function oi(e, t, n, r) {
1367
+ let o = new K(), i = e.graph(), s = di(i.nodesep, i.edgesep, r);
1368
+ return t.forEach((l) => {
1369
+ let d;
1370
+ l.forEach((a) => {
1371
+ let c = n[a];
1372
+ if (c !== void 0) {
1373
+ if (o.setNode(c), d !== void 0) {
1374
+ let u = n[d];
1375
+ if (u !== void 0) {
1376
+ let h = o.edge(u, c);
1377
+ o.setEdge(u, c, Math.max(s(e, a, d), h || 0));
1378
+ }
1379
+ }
1380
+ d = a;
1381
+ }
1382
+ });
1383
+ }), o;
1384
+ }
1385
+ function ii(e, t) {
1386
+ return Object.values(t).reduce((n, r) => {
1387
+ let o = Number.NEGATIVE_INFINITY, i = Number.POSITIVE_INFINITY;
1388
+ Object.entries(r).forEach(([l, d]) => {
1389
+ let a = ci(e, l) / 2;
1390
+ o = Math.max(d + a, o), i = Math.min(d - a, i);
1391
+ });
1392
+ let s = o - i;
1393
+ return s < n[0] && (n = [s, r]), n;
1394
+ }, [Number.POSITIVE_INFINITY, null])[1];
1395
+ }
1396
+ function si(e, t) {
1397
+ let n = Object.values(t), r = X(Math.min, n), o = X(Math.max, n);
1398
+ ["u", "d"].forEach((i) => {
1399
+ ["l", "r"].forEach((s) => {
1400
+ let l = i + s, d = e[l];
1401
+ if (!d || d === t) return;
1402
+ let a = Object.values(d), c = r - X(Math.min, a);
1403
+ s !== "l" && (c = o - X(Math.max, a)), c && (e[l] = Oe(d, (u) => u + c));
1404
+ });
1405
+ });
1406
+ }
1407
+ function li(e, t = void 0) {
1408
+ let n = e.ul;
1409
+ return n ? Oe(n, (r, o) => {
1410
+ var i, s;
1411
+ if (t) {
1412
+ let d = t.toLowerCase(), a = e[d];
1413
+ if (a && a[o] !== void 0) return a[o];
1414
+ }
1415
+ let l = Object.values(e).map((d) => {
1416
+ let a = d[o];
1417
+ return a !== void 0 ? a : 0;
1418
+ }).sort((d, a) => d - a);
1419
+ return (((i = l[1]) != null ? i : 0) + ((s = l[2]) != null ? s : 0)) / 2;
1420
+ }) : {};
1421
+ }
1422
+ function ai(e) {
1423
+ let t = ve(e), n = Object.assign(Zo(e, t), Qo(e, t)), r = {}, o;
1424
+ ["u", "d"].forEach((s) => {
1425
+ o = s === "u" ? t : Object.values(t).reverse(), ["l", "r"].forEach((l) => {
1426
+ l === "r" && (o = o.map((c) => Object.values(c).reverse()));
1427
+ let d = ni(e, o, n, (c) => (s === "u" ? e.predecessors(c) : e.successors(c)) || []), a = ri(e, o, d.root, d.align, l === "r");
1428
+ l === "r" && (a = Oe(a, (c) => -c)), r[s + l] = a;
1429
+ });
1430
+ });
1431
+ let i = ii(e, r);
1432
+ return si(r, i), li(r, e.graph().align);
1433
+ }
1434
+ function di(e, t, n) {
1435
+ return (r, o, i) => {
1436
+ let s = r.node(o), l = r.node(i), d = 0, a;
1437
+ if (d += s.width / 2, Object.hasOwn(s, "labelpos")) switch (s.labelpos.toLowerCase()) {
1438
+ case "l":
1439
+ a = -s.width / 2;
1440
+ break;
1441
+ case "r":
1442
+ a = s.width / 2;
1443
+ break;
1444
+ }
1445
+ if (a && (d += n ? a : -a), a = void 0, d += (s.dummy ? t : e) / 2, d += (l.dummy ? t : e) / 2, d += l.width / 2, Object.hasOwn(l, "labelpos")) switch (l.labelpos.toLowerCase()) {
1446
+ case "l":
1447
+ a = l.width / 2;
1448
+ break;
1449
+ case "r":
1450
+ a = -l.width / 2;
1451
+ break;
1452
+ }
1453
+ return a && (d += n ? a : -a), d;
1454
+ };
1455
+ }
1456
+ function ci(e, t) {
1457
+ return e.node(t).width;
1458
+ }
1459
+ function ui(e) {
1460
+ e = rn(e), fi(e), Object.entries(ai(e)).forEach(([t, n]) => e.node(t).x = n);
1461
+ }
1462
+ function fi(e) {
1463
+ let t = ve(e), n = e.graph(), r = n.ranksep, o = n.rankalign, i = 0;
1464
+ t.forEach((s) => {
1465
+ let l = s.reduce((d, a) => {
1466
+ var c;
1467
+ let u = (c = e.node(a).height) != null ? c : 0;
1468
+ return d > u ? d : u;
1469
+ }, 0);
1470
+ s.forEach((d) => {
1471
+ let a = e.node(d);
1472
+ o === "top" ? a.y = i + a.height / 2 : o === "bottom" ? a.y = i + l - a.height / 2 : a.y = i + l / 2;
1473
+ }), i += l + r;
1474
+ });
1475
+ }
1476
+ function hi(e, t = {}) {
1477
+ let n = t.debugTiming ? ln : an;
1478
+ return n("layout", () => {
1479
+ let r = n(" buildLayoutGraph", () => xi(e));
1480
+ return n(" runLayout", () => gi(r, n, t)), n(" updateInputGraph", () => pi(e, r)), r;
1481
+ });
1482
+ }
1483
+ function gi(e, t, n) {
1484
+ t(" makeSpaceForEdgeLabels", () => Ti(e)), t(" removeSelfEdges", () => Fi(e)), t(" acyclic", () => no(e)), t(" nestingGraph.run", () => So(e)), t(" rank", () => wo(rn(e))), t(" injectEdgeLabelProxies", () => _i(e)), t(" removeEmptyRanks", () => Gr(e)), t(" nestingGraph.cleanup", () => Oo(e)), t(" normalizeRanks", () => Wr(e)), t(" assignRankMinMax", () => Ni(e)), t(" removeEdgeLabelProxies", () => Si(e)), t(" normalize.run", () => io(e)), t(" parentDummyChains", () => xo(e)), t(" addBorderSegments", () => Mo(e)), t(" order", () => mn(e, n)), t(" insertSelfEdges", () => zi(e)), t(" adjustCoordinateSystem", () => Fo(e)), t(" position", () => ui(e)), t(" positionSelfEdges", () => Li(e)), t(" removeBorderNodes", () => ji(e)), t(" normalize.undo", () => lo(e)), t(" fixupEdgeLabelCoords", () => Oi(e)), t(" undoCoordinateSystem", () => zo(e)), t(" translateGraph", () => Ci(e)), t(" assignNodeIntersects", () => Ii(e)), t(" reversePoints", () => Mi(e)), t(" acyclic.undo", () => oo(e));
1485
+ }
1486
+ function pi(e, t) {
1487
+ e.nodes().forEach((n) => {
1488
+ let r = e.node(n), o = t.node(n);
1489
+ r && (r.x = o.x, r.y = o.y, r.order = o.order, r.rank = o.rank, t.children(n).length && (r.width = o.width, r.height = o.height));
1490
+ }), e.edges().forEach((n) => {
1491
+ let r = e.edge(n), o = t.edge(n);
1492
+ r.points = o.points, Object.hasOwn(o, "x") && (r.x = o.x, r.y = o.y);
1493
+ }), e.graph().width = t.graph().width, e.graph().height = t.graph().height;
1494
+ }
1495
+ var bi = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"], yi = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "TB", rankalign: "center" }, mi = ["acyclicer", "ranker", "rankdir", "align", "rankalign"], wi = ["width", "height", "rank"], Lt = { width: 0, height: 0 }, vi = ["minlen", "weight", "width", "height", "labeloffset"], Ei = { minlen: 1, weight: 1, width: 0, height: 0, labeloffset: 10, labelpos: "r" }, ki = ["labelpos"];
1496
+ function xi(e) {
1497
+ let t = new K({ multigraph: !0, compound: !0 }), n = We(e.graph());
1498
+ return t.setGraph(Object.assign({}, yi, Be(n, bi), Ie(n, mi))), e.nodes().forEach((r) => {
1499
+ let o = We(e.node(r)), i = Be(o, wi);
1500
+ Object.keys(Lt).forEach((l) => {
1501
+ i[l] === void 0 && (i[l] = Lt[l]);
1502
+ }), t.setNode(r, i);
1503
+ let s = e.parent(r);
1504
+ s !== void 0 && t.setParent(r, s);
1505
+ }), e.edges().forEach((r) => {
1506
+ let o = We(e.edge(r));
1507
+ t.setEdge(r, Object.assign({}, Ei, Be(o, vi), Ie(o, ki)));
1508
+ }), t;
1509
+ }
1510
+ function Ti(e) {
1511
+ let t = e.graph();
1512
+ t.ranksep /= 2, e.edges().forEach((n) => {
1513
+ let r = e.edge(n);
1514
+ r.minlen *= 2, r.labelpos.toLowerCase() !== "c" && (t.rankdir === "TB" || t.rankdir === "BT" ? r.width += r.labeloffset : r.height += r.labeloffset);
1515
+ });
1516
+ }
1517
+ function _i(e) {
1518
+ e.edges().forEach((t) => {
1519
+ let n = e.edge(t);
1520
+ if (n.width && n.height) {
1521
+ let r = e.node(t.v), o = { rank: (e.node(t.w).rank - r.rank) / 2 + r.rank, e: t };
1522
+ ge(e, "edge-proxy", o, "_ep");
1523
+ }
1524
+ });
1525
+ }
1526
+ function Ni(e) {
1527
+ let t = 0;
1528
+ e.nodes().forEach((n) => {
1529
+ let r = e.node(n);
1530
+ r.borderTop && (r.minRank = e.node(r.borderTop).rank, r.maxRank = e.node(r.borderBottom).rank, t = Math.max(t, r.maxRank));
1531
+ }), e.graph().maxRank = t;
1532
+ }
1533
+ function Si(e) {
1534
+ e.nodes().forEach((t) => {
1535
+ let n = e.node(t);
1536
+ if (n.dummy === "edge-proxy") {
1537
+ let r = n;
1538
+ e.edge(r.e).labelRank = n.rank, e.removeNode(t);
1539
+ }
1540
+ });
1541
+ }
1542
+ function Ci(e) {
1543
+ let t = Number.POSITIVE_INFINITY, n = 0, r = Number.POSITIVE_INFINITY, o = 0, i = e.graph(), s = i.marginx || 0, l = i.marginy || 0;
1544
+ function d(a) {
1545
+ let c = a.x, u = a.y, h = a.width, g = a.height;
1546
+ t = Math.min(t, c - h / 2), n = Math.max(n, c + h / 2), r = Math.min(r, u - g / 2), o = Math.max(o, u + g / 2);
1547
+ }
1548
+ e.nodes().forEach((a) => d(e.node(a))), e.edges().forEach((a) => {
1549
+ let c = e.edge(a);
1550
+ Object.hasOwn(c, "x") && d(c);
1551
+ }), t -= s, r -= l, e.nodes().forEach((a) => {
1552
+ let c = e.node(a);
1553
+ c.x -= t, c.y -= r;
1554
+ }), e.edges().forEach((a) => {
1555
+ let c = e.edge(a);
1556
+ c.points.forEach((u) => {
1557
+ u.x -= t, u.y -= r;
1558
+ }), Object.hasOwn(c, "x") && (c.x -= t), Object.hasOwn(c, "y") && (c.y -= r);
1559
+ }), i.width = n - t + s, i.height = o - r + l;
1560
+ }
1561
+ function Ii(e) {
1562
+ e.edges().forEach((t) => {
1563
+ let n = e.edge(t), r = e.node(t.v), o = e.node(t.w), i, s;
1564
+ n.points ? (i = n.points[0], s = n.points[n.points.length - 1]) : (n.points = [], i = o, s = r), n.points.unshift(_t(r, i)), n.points.push(_t(o, s));
1565
+ });
1566
+ }
1567
+ function Oi(e) {
1568
+ e.edges().forEach((t) => {
1569
+ let n = e.edge(t);
1570
+ if (Object.hasOwn(n, "x")) switch ((n.labelpos === "l" || n.labelpos === "r") && (n.width -= n.labeloffset), n.labelpos) {
1571
+ case "l":
1572
+ n.x -= n.width / 2 + n.labeloffset;
1573
+ break;
1574
+ case "r":
1575
+ n.x += n.width / 2 + n.labeloffset;
1576
+ break;
1577
+ }
1578
+ });
1579
+ }
1580
+ function Mi(e) {
1581
+ e.edges().forEach((t) => {
1582
+ let n = e.edge(t);
1583
+ n.reversed && n.points.reverse();
1584
+ });
1585
+ }
1586
+ function ji(e) {
1587
+ e.nodes().forEach((t) => {
1588
+ if (e.children(t).length) {
1589
+ let n = e.node(t), r = e.node(n.borderTop), o = e.node(n.borderBottom), i = e.node(n.borderLeft[n.borderLeft.length - 1]), s = e.node(n.borderRight[n.borderRight.length - 1]);
1590
+ n.width = Math.abs(s.x - i.x), n.height = Math.abs(o.y - r.y), n.x = i.x + n.width / 2, n.y = r.y + n.height / 2;
1591
+ }
1592
+ }), e.nodes().forEach((t) => {
1593
+ e.node(t).dummy === "border" && e.removeNode(t);
1594
+ });
1595
+ }
1596
+ function Fi(e) {
1597
+ e.edges().forEach((t) => {
1598
+ if (t.v === t.w) {
1599
+ let n = e.node(t.v);
1600
+ n.selfEdges || (n.selfEdges = []), n.selfEdges.push({ e: t, label: e.edge(t) }), e.removeEdge(t);
1601
+ }
1602
+ });
1603
+ }
1604
+ function zi(e) {
1605
+ ve(e).forEach((t) => {
1606
+ let n = 0;
1607
+ t.forEach((r, o) => {
1608
+ let i = e.node(r);
1609
+ i.order = o + n, (i.selfEdges || []).forEach((s) => {
1610
+ ge(e, "selfedge", { width: s.label.width, height: s.label.height, rank: i.rank, order: o + ++n, e: s.e, label: s.label }, "_se");
1611
+ }), delete i.selfEdges;
1612
+ });
1613
+ });
1614
+ }
1615
+ function Li(e) {
1616
+ e.nodes().forEach((t) => {
1617
+ let n = e.node(t);
1618
+ if (n.dummy === "selfedge") {
1619
+ let r = n, o = e.node(r.e.v), i = o.x + o.width / 2, s = o.y, l = n.x - i, d = o.height / 2;
1620
+ e.setEdge(r.e, r.label), e.removeNode(t), r.label.points = [{ x: i + 2 * l / 3, y: s - d }, { x: i + 5 * l / 6, y: s - d }, { x: i + l, y: s }, { x: i + 5 * l / 6, y: s + d }, { x: i + 2 * l / 3, y: s + d }], r.label.x = n.x, r.label.y = n.y;
1621
+ }
1622
+ });
1623
+ }
1624
+ function Be(e, t) {
1625
+ return Oe(Ie(e, t), Number);
1626
+ }
1627
+ function We(e) {
1628
+ let t = {};
1629
+ return e && Object.entries(e).forEach(([n, r]) => {
1630
+ typeof n == "string" && (n = n.toLowerCase()), t[n] = r;
1631
+ }), t;
1632
+ }
1633
+ function Ai(e) {
1634
+ let t = ve(e), n = new K({ compound: !0, multigraph: !0 }).setGraph({});
1635
+ return e.nodes().forEach((r) => {
1636
+ n.setNode(r, { label: r }), n.setParent(r, "layer" + e.node(r).rank);
1637
+ }), e.edges().forEach((r) => n.setEdge(r.v, r.w, {}, r.name)), t.forEach((r, o) => {
1638
+ let i = "layer" + o;
1639
+ n.setNode(i, { rank: "same" }), r.reduce((s, l) => (n.setEdge(s, l, { style: "invis" }), l));
1640
+ }), n;
1641
+ }
1642
+ var Di = { graphlib: Ht, version: Vr, layout: hi, debug: Ai, util: { time: ln, notime: an } }, At = Di;
1643
+ /*! For license information please see dagre.esm.js.LEGAL.txt */
1644
+ const Ri = (e) => {
1645
+ const t = [];
1646
+ return e.nodeInternals.forEach((n, r) => t.push(`${r}:${n.height ?? 0}`)), t.join(",");
1647
+ }, Pi = ({ onHeightsReady: e, nodeCount: t }) => {
1648
+ const n = On(Ri), r = vt("");
1649
+ vt(0);
1650
+ const { fitView: o } = Mn();
1651
+ return re(() => {
1652
+ if (!n || n === r.current) return;
1653
+ const i = {};
1654
+ for (const s of n.split(",")) {
1655
+ const [l, d] = s.split(":"), a = Number(d);
1656
+ l && a > 0 && (i[l] = a);
1657
+ }
1658
+ Object.keys(i).length !== 0 && (r.current = n, e(i));
1659
+ }, [n]), null;
1660
+ }, je = ({ isOpen: e, onClose: t, title: n, icon: r, children: o, footer: i, width: s = 600 }) => {
1661
+ const [l, d] = M(!1), a = () => d((h) => !h), c = () => /* @__PURE__ */ v(Q, { sx: { display: "flex", alignItems: "center", p: 2, pt: 3, borderBottom: "1px solid #e0e0e0", mb: 0, flexShrink: 0 }, children: [
1662
+ r && /* @__PURE__ */ f(Q, { sx: { mr: 1.5, display: "flex", alignItems: "center", fontSize: "1.25rem", color: "#1DBF60" }, children: r }),
1663
+ /* @__PURE__ */ f("span", { style: { flexGrow: 1, fontSize: 14, fontWeight: 500, color: "#212121" }, children: n }),
1664
+ /* @__PURE__ */ f(Et, { onClick: a, size: "small", sx: { mr: 1 }, title: l ? "Collapse" : "Expand", "data-testid": "expand-collapse-base-drawer-btn", children: l ? /* @__PURE__ */ f(lr, {}) : /* @__PURE__ */ f(ar, {}) }),
1665
+ /* @__PURE__ */ f(Et, { onClick: t, size: "small", "data-testid": "close-drawer-button", children: /* @__PURE__ */ f(Un, {}) })
1666
+ ] }), u = () => i ? /* @__PURE__ */ f(Q, { sx: { flexShrink: 0, p: 2, borderTop: "1px solid #e0e0e0", display: "flex", justifyContent: "flex-end", gap: 2 }, children: i }) : null;
1667
+ return l ? /* @__PURE__ */ v(Gn, { open: e, onClose: t, maxWidth: !1, fullWidth: !0, PaperProps: { sx: { display: "flex", flexDirection: "column", height: "80vh", boxShadow: 24, width: "750px", maxWidth: "100%" } }, children: [
1668
+ /* @__PURE__ */ f(c, {}),
1669
+ /* @__PURE__ */ f(Q, { sx: { flexGrow: 1, overflowY: "auto", p: 0 }, children: o }),
1670
+ /* @__PURE__ */ f(u, {})
1671
+ ] }) : /* @__PURE__ */ v(
1672
+ $n,
1673
+ {
1674
+ anchor: "right",
1675
+ open: e,
1676
+ onClose: t,
1677
+ variant: "persistent",
1678
+ sx: { zIndex: 900 },
1679
+ ModalProps: { keepMounted: !1 },
1680
+ PaperProps: {
1681
+ sx: {
1682
+ width: s,
1683
+ position: "fixed",
1684
+ top: "64px",
1685
+ height: "calc(100% - 74px)",
1686
+ right: "10px",
1687
+ borderRadius: "8px",
1688
+ border: "1px solid #bdbdbd",
1689
+ boxShadow: "none",
1690
+ zIndex: 900,
1691
+ display: "flex",
1692
+ flexDirection: "column"
1693
+ }
1694
+ },
1695
+ children: [
1696
+ /* @__PURE__ */ f(c, {}),
1697
+ /* @__PURE__ */ f(Q, { sx: { flexGrow: 1, overflowY: "auto", p: 0 }, children: o }),
1698
+ /* @__PURE__ */ f(u, {})
1699
+ ]
1700
+ }
1701
+ );
1702
+ }, Bi = ({
1703
+ open: e,
1704
+ templates: t,
1705
+ messages: n,
1706
+ onSelect: r,
1707
+ onClose: o,
1708
+ loadTriggerSources: i
1709
+ }) => {
1710
+ const [s, l] = M("trigger"), [d, a] = M(null), [c, u] = M([]), [h, g] = M([]), [b, E] = M(!1), [y, x] = M(null);
1711
+ re(() => {
1712
+ e || (l("trigger"), a(null), u([]), g([]), E(!1), x(null));
1713
+ }, [e]);
1714
+ const N = $(async (z) => {
1715
+ if (!i) {
1716
+ r(z);
1717
+ return;
1718
+ }
1719
+ a(z), E(!0), x(null);
1720
+ try {
1721
+ const R = await i(z.triggerKey);
1722
+ if (!R || R.length === 0) {
1723
+ r(z);
1724
+ return;
1725
+ }
1726
+ u(R), l("sources");
1727
+ } catch (R) {
1728
+ x(R instanceof Error ? R.message : "Failed to load sources.");
1729
+ } finally {
1730
+ E(!1);
1731
+ }
1732
+ }, [i, r]), O = () => {
1733
+ l("trigger"), a(null), u([]), g([]), x(null);
1734
+ }, F = () => {
1735
+ d && r(d, h);
1736
+ }, j = s === "sources" && d, W = j ? /* @__PURE__ */ v(ye, { children: [
1737
+ /* @__PURE__ */ f(Ne, { type: "button", variant: "outlined", size: "small", onClick: O, children: n.cancel ?? "Back" }),
1738
+ /* @__PURE__ */ f(
1739
+ Ne,
1740
+ {
1741
+ type: "button",
1742
+ variant: "contained",
1743
+ size: "small",
1744
+ onClick: F,
1745
+ disabled: h.length === 0,
1746
+ children: n.save ?? "Continue"
1747
+ }
1748
+ )
1749
+ ] }) : null;
1750
+ return /* @__PURE__ */ f(
1751
+ je,
1752
+ {
1753
+ isOpen: e,
1754
+ onClose: o,
1755
+ title: j ? d.label : n.addTriggerTitle,
1756
+ icon: /* @__PURE__ */ f(sr, {}),
1757
+ width: 500,
1758
+ footer: W,
1759
+ children: /* @__PURE__ */ v(Q, { sx: { p: 2 }, children: [
1760
+ !j && /* @__PURE__ */ v(ye, { children: [
1761
+ /* @__PURE__ */ f("p", { className: "ff-text-muted ff-mb-3", style: { fontSize: 13 }, children: n.chooseTrigger }),
1762
+ /* @__PURE__ */ v("div", { className: "ff-d-flex ff-flex-column ff-gap-2", children: [
1763
+ t.map((z) => /* @__PURE__ */ v(
1764
+ "div",
1765
+ {
1766
+ className: "ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-start ff-gap-3",
1767
+ style: { cursor: b ? "wait" : "pointer", transition: "background 0.15s", opacity: b ? 0.6 : 1 },
1768
+ onClick: () => !b && N(z),
1769
+ role: "button",
1770
+ tabIndex: 0,
1771
+ onKeyDown: (R) => {
1772
+ R.key === "Enter" && !b && N(z);
1773
+ },
1774
+ onMouseEnter: (R) => {
1775
+ b || (R.currentTarget.style.background = "#f5f5f5");
1776
+ },
1777
+ onMouseLeave: (R) => {
1778
+ R.currentTarget.style.background = "";
1779
+ },
1780
+ children: [
1781
+ /* @__PURE__ */ f("div", { style: { color: z.triggerCategory === "scheduler" ? "#1976d2" : "#f57c00", marginTop: 2, flexShrink: 0 }, children: z.triggerCategory === "scheduler" ? /* @__PURE__ */ f(Vn, { size: 18 }) : /* @__PURE__ */ f(Hn, { size: 18 }) }),
1782
+ /* @__PURE__ */ v("div", { children: [
1783
+ /* @__PURE__ */ f("div", { style: { fontSize: 14, fontWeight: 500, color: "#212121" }, children: z.label }),
1784
+ z.description && /* @__PURE__ */ f("div", { style: { fontSize: 12, color: "#757575", marginTop: 2 }, children: z.description })
1785
+ ] })
1786
+ ]
1787
+ },
1788
+ z.triggerKey
1789
+ )),
1790
+ t.length === 0 && /* @__PURE__ */ f("p", { className: "ff-text-muted ff-text-center", style: { fontSize: 13 }, children: n.noTriggers })
1791
+ ] }),
1792
+ b && /* @__PURE__ */ v(Q, { sx: { display: "flex", alignItems: "center", gap: 1, mt: 2, fontSize: 12, color: "#64748b" }, children: [
1793
+ /* @__PURE__ */ f(Yn, { size: 14 }),
1794
+ /* @__PURE__ */ f("span", { children: "Loading sources for the selected trigger…" })
1795
+ ] }),
1796
+ y && /* @__PURE__ */ f("p", { style: { fontSize: 12, color: "#d32f2f", marginTop: 12 }, children: y })
1797
+ ] }),
1798
+ j && /* @__PURE__ */ v(ye, { children: [
1799
+ /* @__PURE__ */ v(
1800
+ "div",
1801
+ {
1802
+ role: "button",
1803
+ tabIndex: 0,
1804
+ onClick: O,
1805
+ onKeyDown: (z) => {
1806
+ z.key === "Enter" && O();
1807
+ },
1808
+ className: "ff-d-flex ff-align-items-center ff-gap-1 ff-mb-3",
1809
+ style: { cursor: "pointer", color: "#0066cc", fontSize: 13, fontWeight: 500, width: "fit-content" },
1810
+ children: [
1811
+ /* @__PURE__ */ f(Wt, { size: 16 }),
1812
+ /* @__PURE__ */ f("span", { children: n.addTriggerTitle })
1813
+ ]
1814
+ }
1815
+ ),
1816
+ /* @__PURE__ */ v("p", { className: "ff-text-muted ff-mb-2", style: { fontSize: 13 }, children: [
1817
+ "Pick one or more sources for ",
1818
+ /* @__PURE__ */ f("strong", { children: d.label }),
1819
+ ":"
1820
+ ] }),
1821
+ /* @__PURE__ */ f(
1822
+ Kn,
1823
+ {
1824
+ isMulti: !0,
1825
+ options: c,
1826
+ value: h,
1827
+ onChange: (z) => g(z ?? []),
1828
+ placeholder: "Select sources…",
1829
+ menuPosition: "fixed",
1830
+ menuPortalTarget: typeof document < "u" ? document.body : void 0,
1831
+ styles: dr(!1, !0)
1832
+ }
1833
+ )
1834
+ ] })
1835
+ ] })
1836
+ }
1837
+ );
1838
+ }, Ge = {
1839
+ cursor: "pointer",
1840
+ transition: "background 0.15s"
1841
+ }, $e = "ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-center ff-gap-3", Wi = ({ open: e, availableDescriptors: t, messages: n, onSelect: r, onClose: o }) => {
1842
+ const { apps: i, ungrouped: s } = Y(() => {
1843
+ const u = /* @__PURE__ */ new Map(), h = [];
1844
+ for (const g of t)
1845
+ if (g.app) {
1846
+ const b = u.get(g.app.key);
1847
+ b ? b.descriptors.push(g) : u.set(g.app.key, {
1848
+ key: g.app.key,
1849
+ label: g.app.label,
1850
+ icon: g.app.icon,
1851
+ description: g.app.description,
1852
+ descriptors: [g]
1853
+ });
1854
+ } else
1855
+ h.push(g);
1856
+ return { apps: [...u.values()], ungrouped: h };
1857
+ }, [t]), [l, d] = M(null), a = l ? i.find((u) => u.key === l) ?? null : null;
1858
+ re(() => {
1859
+ e || d(null);
1860
+ }, [e]), re(() => {
1861
+ d(null);
1862
+ }, [t]);
1863
+ const c = !a;
1864
+ return /* @__PURE__ */ f(
1865
+ je,
1866
+ {
1867
+ isOpen: e,
1868
+ onClose: o,
1869
+ title: c ? n.addStepTitle : a.label,
1870
+ icon: c ? /* @__PURE__ */ f(qn, {}) : a.icon ?? /* @__PURE__ */ f(Xn, {}),
1871
+ width: 500,
1872
+ children: /* @__PURE__ */ v(Q, { sx: { p: 2 }, children: [
1873
+ !c && /* @__PURE__ */ v(
1874
+ "div",
1875
+ {
1876
+ role: "button",
1877
+ tabIndex: 0,
1878
+ onClick: () => d(null),
1879
+ onKeyDown: (u) => {
1880
+ u.key === "Enter" && d(null);
1881
+ },
1882
+ className: "ff-d-flex ff-align-items-center ff-gap-1 ff-mb-3",
1883
+ style: { cursor: "pointer", color: "#0066cc", fontSize: 13, fontWeight: 500, width: "fit-content" },
1884
+ children: [
1885
+ /* @__PURE__ */ f(Wt, { size: 16 }),
1886
+ /* @__PURE__ */ f("span", { children: n.addStepTitle })
1887
+ ]
1888
+ }
1889
+ ),
1890
+ /* @__PURE__ */ f("p", { className: "ff-text-muted ff-mb-3", style: { fontSize: 13 }, children: c ? n.chooseAction : `Pick an action from ${a.label}` }),
1891
+ /* @__PURE__ */ f("div", { className: "ff-d-flex ff-flex-column ff-gap-2", children: c ? /* @__PURE__ */ v(ye, { children: [
1892
+ i.map((u) => /* @__PURE__ */ v(
1893
+ "div",
1894
+ {
1895
+ className: $e,
1896
+ style: Ge,
1897
+ onClick: () => d(u.key),
1898
+ role: "button",
1899
+ tabIndex: 0,
1900
+ onKeyDown: (h) => {
1901
+ h.key === "Enter" && d(u.key);
1902
+ },
1903
+ onMouseEnter: (h) => {
1904
+ h.currentTarget.style.background = "#f5f5f5";
1905
+ },
1906
+ onMouseLeave: (h) => {
1907
+ h.currentTarget.style.background = "";
1908
+ },
1909
+ children: [
1910
+ u.icon && /* @__PURE__ */ f("div", { style: { flexShrink: 0 }, children: u.icon }),
1911
+ /* @__PURE__ */ v("div", { style: { flex: 1, minWidth: 0 }, children: [
1912
+ /* @__PURE__ */ f("div", { style: { fontSize: 14, fontWeight: 500, color: "#212121" }, children: u.label }),
1913
+ /* @__PURE__ */ f("div", { style: { fontSize: 12, color: "#757575", marginTop: 2 }, children: u.description ?? `${u.descriptors.length} action${u.descriptors.length === 1 ? "" : "s"}` })
1914
+ ] }),
1915
+ /* @__PURE__ */ f(Gt, { size: 18, color: "#9e9e9e" })
1916
+ ]
1917
+ },
1918
+ `app-${u.key}`
1919
+ )),
1920
+ s.map((u) => /* @__PURE__ */ v(
1921
+ "div",
1922
+ {
1923
+ className: $e,
1924
+ style: Ge,
1925
+ onClick: () => r(u),
1926
+ role: "button",
1927
+ tabIndex: 0,
1928
+ onKeyDown: (h) => {
1929
+ h.key === "Enter" && r(u);
1930
+ },
1931
+ onMouseEnter: (h) => {
1932
+ h.currentTarget.style.background = "#f5f5f5";
1933
+ },
1934
+ onMouseLeave: (h) => {
1935
+ h.currentTarget.style.background = "";
1936
+ },
1937
+ children: [
1938
+ u.icon && /* @__PURE__ */ f("div", { style: { flexShrink: 0 }, children: u.icon }),
1939
+ /* @__PURE__ */ f("span", { style: { fontSize: 14, fontWeight: 500, color: "#212121" }, children: u.label })
1940
+ ]
1941
+ },
1942
+ u.type
1943
+ )),
1944
+ i.length === 0 && s.length === 0 && /* @__PURE__ */ f("p", { className: "ff-text-muted ff-text-center", style: { fontSize: 13 }, children: n.noActions })
1945
+ ] }) : (
1946
+ /* Stage 2 — actions for the selected app */
1947
+ a.descriptors.map((u) => /* @__PURE__ */ v(
1948
+ "div",
1949
+ {
1950
+ className: $e,
1951
+ style: Ge,
1952
+ onClick: () => r(u),
1953
+ role: "button",
1954
+ tabIndex: 0,
1955
+ onKeyDown: (h) => {
1956
+ h.key === "Enter" && r(u);
1957
+ },
1958
+ onMouseEnter: (h) => {
1959
+ h.currentTarget.style.background = "#f5f5f5";
1960
+ },
1961
+ onMouseLeave: (h) => {
1962
+ h.currentTarget.style.background = "";
1963
+ },
1964
+ children: [
1965
+ u.icon && /* @__PURE__ */ f("div", { style: { flexShrink: 0 }, children: u.icon }),
1966
+ /* @__PURE__ */ f("span", { style: { fontSize: 14, fontWeight: 500, color: "#212121" }, children: u.label })
1967
+ ]
1968
+ },
1969
+ u.type
1970
+ ))
1971
+ ) })
1972
+ ] })
1973
+ }
1974
+ );
1975
+ }, Dt = "_conditionConfig", Gi = ({ open: e, nodeId: t, descriptor: n, initialValues: r, messages: o, onSave: i, onClose: s }) => {
1976
+ const [l, d] = M([]), [a, c] = M(!1), [u, h] = M(null), [g, b] = M({});
1977
+ re(() => {
1978
+ b((r == null ? void 0 : r[Dt]) ?? {});
1979
+ }, [r, t]), re(() => {
1980
+ let N = !1;
1981
+ if (h(null), !n || !t) {
1982
+ d([]), c(!1);
1983
+ return;
1984
+ }
1985
+ const O = n.formSchema;
1986
+ return typeof O == "function" ? (c(!0), O(t).then((F) => {
1987
+ N || (d(F), c(!1));
1988
+ }).catch((F) => {
1989
+ N || (d([]), h(F instanceof Error ? F.message : "Unable to load configuration."), c(!1));
1990
+ })) : (d(O), c(!1)), () => {
1991
+ N = !0;
1992
+ };
1993
+ }, [n, t]);
1994
+ const E = t ? `node-config-form-${t}` : "node-config-form", y = !a && !u && l.length > 0, x = y ? /* @__PURE__ */ v(ye, { children: [
1995
+ /* @__PURE__ */ f(Ne, { type: "button", variant: "outlined", size: "small", onClick: s, children: o.cancel }),
1996
+ /* @__PURE__ */ f(Ne, { type: "submit", form: E, variant: "contained", size: "small", children: o.save })
1997
+ ] }) : null;
1998
+ return /* @__PURE__ */ f(
1999
+ je,
2000
+ {
2001
+ isOpen: e,
2002
+ onClose: s,
2003
+ title: (n == null ? void 0 : n.label) ?? o.configureStep,
2004
+ icon: n == null ? void 0 : n.icon,
2005
+ width: 500,
2006
+ footer: x,
2007
+ children: /* @__PURE__ */ v(Q, { sx: { p: 2 }, children: [
2008
+ a && /* @__PURE__ */ f("p", { className: "ff-text-muted", style: { fontSize: 13 }, children: o.loadingConfiguration }),
2009
+ !a && u && /* @__PURE__ */ f("p", { style: { fontSize: 13, color: "#d32f2f" }, children: u }),
2010
+ !a && !u && l.length === 0 && /* @__PURE__ */ f("p", { className: "ff-text-muted", style: { fontSize: 13 }, children: o.noConfigurationNeeded }),
2011
+ y && /* @__PURE__ */ f(
2012
+ cr,
2013
+ {
2014
+ schema: { layout: "flat", fields: l },
2015
+ initialValues: r ?? {},
2016
+ formId: E,
2017
+ conditionConfig: g,
2018
+ onConditionConfigChange: b,
2019
+ onSubmit: (N) => {
2020
+ if (!t) return;
2021
+ const O = Object.keys(g).length > 0;
2022
+ i(t, { ...N, [Dt]: O ? g : void 0 }), s();
2023
+ }
2024
+ }
2025
+ )
2026
+ ] })
2027
+ }
2028
+ );
2029
+ }, $i = ({
2030
+ isOpen: e,
2031
+ onClose: t,
2032
+ workflowId: n,
2033
+ workflowLabel: r,
2034
+ onFetchWorkflow: o
2035
+ }) => {
2036
+ const [i, s] = M({ status: "idle" });
2037
+ return re(() => {
2038
+ if (!e || !n) {
2039
+ s({ status: "idle" });
2040
+ return;
2041
+ }
2042
+ s({ status: "loading" }), o(n).then((l) => s({ status: "loaded", state: l })).catch((l) => s({ status: "error", message: (l == null ? void 0 : l.message) ?? "Failed to load workflow" }));
2043
+ }, [e, n, o]), /* @__PURE__ */ f(
2044
+ je,
2045
+ {
2046
+ isOpen: e,
2047
+ onClose: t,
2048
+ title: r ? `Preview: ${r}` : "Sub-Workflow Preview",
2049
+ icon: /* @__PURE__ */ f(Zn, { size: 18, color: "#00695c" }),
2050
+ width: 700,
2051
+ children: /* @__PURE__ */ v("div", { style: { height: "100%", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", padding: 24 }, children: [
2052
+ i.status === "idle" && /* @__PURE__ */ f("span", { style: { color: "#9e9e9e", fontSize: 14 }, children: "Select a workflow to preview" }),
2053
+ i.status === "loading" && /* @__PURE__ */ v("div", { style: { textAlign: "center", color: "#9e9e9e" }, children: [
2054
+ /* @__PURE__ */ f("div", { style: { width: 32, height: 32, borderRadius: "50%", border: "3px solid #e0e0e0", borderTopColor: "#00897b", animation: "spin 0.8s linear infinite", margin: "0 auto 12px" } }),
2055
+ /* @__PURE__ */ f("span", { style: { fontSize: 14 }, children: "Loading workflow…" }),
2056
+ /* @__PURE__ */ f("style", { children: "@keyframes spin { to { transform: rotate(360deg); } }" })
2057
+ ] }),
2058
+ i.status === "error" && /* @__PURE__ */ v("div", { style: { textAlign: "center", color: "#c62828" }, children: [
2059
+ /* @__PURE__ */ f(Jn, { size: 32, style: { marginBottom: 8 } }),
2060
+ /* @__PURE__ */ f("p", { style: { margin: 0, fontSize: 14 }, children: i.message })
2061
+ ] }),
2062
+ i.status === "loaded" && /* @__PURE__ */ f("div", { style: { width: "100%", flex: 1 }, children: /* @__PURE__ */ f(Yi, { state: i.state }) })
2063
+ ] })
2064
+ }
2065
+ );
2066
+ }, Yi = ({ state: e }) => {
2067
+ const [t, n] = M(null), [r, o] = M(null);
2068
+ return re(() => {
2069
+ Promise.all([
2070
+ Promise.resolve().then(() => Xi).then((i) => i.default),
2071
+ import("./nodeRegistry.js").then((i) => i.nodeTypeRegistry),
2072
+ import("./templateRegistry.js").then((i) => i.templateRegistry)
2073
+ ]).then(([i, s, l]) => {
2074
+ n(() => i), o({ nodeTypeRegistry: s, templateRegistry: l });
2075
+ });
2076
+ }, []), !t || !r ? /* @__PURE__ */ f("div", { style: { color: "#9e9e9e", fontSize: 13, textAlign: "center" }, children: "Loading canvas…" }) : /* @__PURE__ */ f("div", { style: { width: "100%", height: 480, border: "1px solid #e0e0e0", borderRadius: 8, overflow: "hidden" }, children: /* @__PURE__ */ f(
2077
+ t,
2078
+ {
2079
+ nodeRegistry: r.nodeTypeRegistry,
2080
+ templateRegistry: r.templateRegistry,
2081
+ initialValue: e,
2082
+ readOnly: !0
2083
+ }
2084
+ ) });
2085
+ }, we = 350, Ue = 70, Ve = 60, He = {
2086
+ startNode: 40,
2087
+ endNode: 40,
2088
+ addTriggerNode: 56,
2089
+ triggerNode: 110,
2090
+ actionNode: 90,
2091
+ filterNode: 90,
2092
+ approvalNode: 90,
2093
+ delayNode: 80,
2094
+ notificationNode: 80
2095
+ }, Ki = {
2096
+ plusEdge: Bn,
2097
+ labelPlusEdge: Pn,
2098
+ plainEdge: Rn,
2099
+ edgeWithPlusLabel: Dn,
2100
+ gatewayBranchEdge: An
2101
+ };
2102
+ function Rt() {
2103
+ return [
2104
+ { id: "start", kind: "start", reactFlowType: "startNode" },
2105
+ { id: "addTrigger", kind: "addTrigger", reactFlowType: "addTriggerNode" },
2106
+ { id: "end", kind: "end", reactFlowType: "endNode" }
2107
+ ];
2108
+ }
2109
+ function Ui(e, t, n, r = "TB") {
2110
+ const o = new At.graphlib.Graph();
2111
+ return o.setGraph({ rankdir: r, ranksep: 70, nodesep: 50 }), o.setDefaultEdgeLabel(() => ({})), e.forEach((i) => {
2112
+ const s = n[i.id] ?? { width: we, height: He[i.type ?? ""] ?? 80 };
2113
+ o.setNode(i.id, { width: s.width, height: s.height });
2114
+ }), t.forEach((i) => o.setEdge(i.source, i.target)), At.layout(o), e.map((i) => {
2115
+ var a, c;
2116
+ const s = o.node(i.id), l = ((a = n[i.id]) == null ? void 0 : a.width) ?? we, d = ((c = n[i.id]) == null ? void 0 : c.height) ?? He[i.type ?? ""] ?? 80;
2117
+ return { ...i, position: { x: s.x - l / 2, y: s.y - d / 2 } };
2118
+ });
2119
+ }
2120
+ const ae = (e) => e === "filter" || e === "approval";
2121
+ function Vi(e, t, n, r) {
2122
+ const s = Ue, l = 30, d = 30, a = {}, c = {}, u = /* @__PURE__ */ new Map();
2123
+ for (const y of e) u.set(y.id, y);
2124
+ for (const y of Object.values(t))
2125
+ for (const x of Object.values(y))
2126
+ for (const N of x) u.set(N.id, N);
2127
+ const h = (y, x, N) => {
2128
+ const O = r[y] ?? { width: we, height: 80 };
2129
+ return a[y] = { x: x - O.width / 2, y: N }, N + O.height;
2130
+ }, g = (y, x, N) => {
2131
+ let O = N;
2132
+ for (const F of y)
2133
+ O = h(F.id, x, O) + s, ae(F.kind) && t[F.id] && (O = b(F.id, x, O));
2134
+ return O;
2135
+ }, b = (y, x, N) => {
2136
+ const O = x + 180, F = t[y], j = Object.keys(F), W = u.get(y), z = (W == null ? void 0 : W.branchLabels) ?? { pass: "Pass", fail: "Fail" }, R = a[y], B = r[y] ?? { height: 80 }, Ee = R.y + B.height, ke = [];
2137
+ let te = N;
2138
+ return j.forEach((ce, pe) => {
2139
+ const oe = F[ce], A = te;
2140
+ ke.push({
2141
+ y: A - Ee,
2142
+ label: z[ce] ?? ce,
2143
+ isPass: pe === 0
2144
+ }), te = g(oe, O, te + d), pe < j.length - 1 && (te += l);
2145
+ }), c[y] = {
2146
+ branches: ke,
2147
+ height: te - Ee,
2148
+ indent: 180
2149
+ }, te;
2150
+ };
2151
+ let E = Ve;
2152
+ for (const y of e)
2153
+ E = h(y.id, 400, E) + s, ae(y.kind) && t[y.id] && (E = b(y.id, 400, E));
2154
+ return {
2155
+ nodes: n.map((y) => a[y.id] ? { ...y, position: a[y.id] } : y),
2156
+ railSpecs: c
2157
+ };
2158
+ }
2159
+ function Pt(e) {
2160
+ return {
2161
+ id: e.id,
2162
+ type: e.reactFlowType,
2163
+ position: { x: 0, y: 0 },
2164
+ data: { ...e.nodeData, ...e.formData, descriptorType: e.descriptorType },
2165
+ draggable: !1,
2166
+ selectable: !1
2167
+ };
2168
+ }
2169
+ function Hi(e, t, n, r, o) {
2170
+ return {
2171
+ id: `e-${e.id}-${t.id}`,
2172
+ source: e.id,
2173
+ target: t.id,
2174
+ type: "plusEdge",
2175
+ style: { stroke: n },
2176
+ data: {
2177
+ onAddStepClick: r,
2178
+ referenceNodeType: e.reactFlowType,
2179
+ ...o ?? {}
2180
+ }
2181
+ };
2182
+ }
2183
+ function qi(e, t, n, r, o = {}, i = "TB", s = "horizontal") {
2184
+ const l = o.edgeColor ?? "#b0bec5", d = [], a = [], c = (b, E) => {
2185
+ const y = t[b];
2186
+ if (!y) return;
2187
+ const N = E ?? { pass: "Pass", fail: "Fail" }, O = Object.keys(y), F = (j, W, z, R) => {
2188
+ if (j.length !== 0) {
2189
+ j.forEach((B) => d.push(Pt(B))), a.push({
2190
+ id: `e-${b}-${W}-start`,
2191
+ source: b,
2192
+ target: j[0].id,
2193
+ type: "gatewayBranchEdge",
2194
+ style: { stroke: l },
2195
+ data: { branch: W, filterId: b, label: z, isFirst: R === 0, onAddStepClick: n, verticalRouting: s === "vertical" }
2196
+ });
2197
+ for (let B = 1; B < j.length; B++)
2198
+ ae(j[B - 1].kind) || a.push(Hi(j[B - 1], j[B], l, n, { filterId: b, branch: W }));
2199
+ for (const B of j)
2200
+ ae(B.kind) && t[B.id] && c(B.id, B.branchLabels);
2201
+ }
2202
+ };
2203
+ O.forEach((j, W) => {
2204
+ F(y[j], j, N[j] ?? j, W);
2205
+ });
2206
+ };
2207
+ for (let b = 0; b < e.length; b++) {
2208
+ const E = e[b];
2209
+ if (d.push(Pt(E)), b > 0) {
2210
+ const y = e[b - 1], x = y.kind === "start" || y.kind === "addTrigger";
2211
+ if (y.kind === "filter" || y.kind === "approval") continue;
2212
+ a.push({
2213
+ id: `e-${y.id}-${E.id}`,
2214
+ source: y.id,
2215
+ target: E.id,
2216
+ type: x ? "plainEdge" : "plusEdge",
2217
+ style: { stroke: l },
2218
+ data: x ? {} : {
2219
+ onAddStepClick: n,
2220
+ referenceNodeType: y.reactFlowType
2221
+ }
2222
+ });
2223
+ }
2224
+ (E.kind === "filter" || E.kind === "approval") && t[E.id] && c(E.id, E.branchLabels);
2225
+ }
2226
+ const u = {};
2227
+ if (d.forEach((b) => {
2228
+ u[b.id] = {
2229
+ width: we,
2230
+ height: r[b.id] ?? He[b.type ?? ""] ?? 80
2231
+ };
2232
+ }), !(Object.keys(t).length > 0)) {
2233
+ if (i === "LR") {
2234
+ let N = Ve;
2235
+ return { nodes: d.map((F) => {
2236
+ const j = u[F.id].width, W = u[F.id].height, z = { ...F, position: { x: N, y: 300 - W / 2 } };
2237
+ return N += j + Ue, z;
2238
+ }), edges: a };
2239
+ }
2240
+ const b = 400;
2241
+ let E = Ve;
2242
+ return { nodes: d.map((x) => {
2243
+ const N = u[x.id].height, O = { ...x, position: { x: b - we / 2, y: E } };
2244
+ return E += N + Ue, O;
2245
+ }), edges: a };
2246
+ }
2247
+ if (s === "vertical") {
2248
+ const { nodes: b, railSpecs: E } = Vi(e, t, d, u);
2249
+ return { nodes: b.map(
2250
+ (x) => E[x.id] ? { ...x, data: { ...x.data, _branchRail: E[x.id] } } : x
2251
+ ), edges: a };
2252
+ }
2253
+ return { nodes: Ui(d, a, u, i), edges: a };
2254
+ }
2255
+ const Bt = ({
2256
+ nodeRegistry: e,
2257
+ templateRegistry: t,
2258
+ initialValue: n,
2259
+ nodeTypes: r,
2260
+ edgeTypes: o,
2261
+ onSave: i,
2262
+ readOnly: s = !1,
2263
+ theme: l = {},
2264
+ messages: d,
2265
+ canvasOptions: a = {},
2266
+ renderTriggerSelector: c,
2267
+ loadTriggerSources: u,
2268
+ renderNodePicker: h,
2269
+ renderNodeConfig: g,
2270
+ onNodeClick: b,
2271
+ maxNodes: E,
2272
+ layoutDirection: y = "TB",
2273
+ executionRecord: x,
2274
+ onFetchWorkflow: N
2275
+ }) => {
2276
+ const {
2277
+ fitView: O = !0,
2278
+ fitViewPadding: F = 0.3,
2279
+ showControls: j = !0,
2280
+ showMiniMap: W = !1,
2281
+ panOnScroll: z = !0,
2282
+ zoomOnScroll: R = !1,
2283
+ minZoom: B = 0.25,
2284
+ maxZoom: Ee = 2,
2285
+ snapToGrid: ke = !1,
2286
+ snapGrid: te = [15, 15],
2287
+ branchLayout: ce = "horizontal",
2288
+ nodeBody: pe = "full"
2289
+ } = a, oe = Y(() => ur(d), [d]), [A, ie] = M(() => (n == null ? void 0 : n.slots) ?? Rt()), [U, J] = M(() => (n == null ? void 0 : n.branches) ?? {}), [ue, V] = M(null), [Fe, tt] = M(null), [H, xe] = M(null), [se, nt] = M(null), [Te, rt] = M(null), [q, ot] = M(() => {
2290
+ const p = n == null ? void 0 : n.slots.find((_) => _.kind === "triggerFixed"), w = p != null && p.id.startsWith("trigger-") ? p.id.slice(8) : void 0;
2291
+ return w ? t.lookup(w) ?? null : null;
2292
+ }), [it, En] = M({}), kn = $((p) => {
2293
+ En(p);
2294
+ }, []), xn = Y(() => ({ ...Ln, ...r }), [r]), Tn = Y(() => ({ ...Ki, ...o }), [o]), _n = Y(() => {
2295
+ const p = A.filter((_) => _.kind === "userTask").length, w = Object.values(U).flatMap((_) => Object.values(_).flat()).filter((_) => _.kind === "userTask").length;
2296
+ return p + w;
2297
+ }, [A, U]), st = E ?? (q == null ? void 0 : q.maxTasks), lt = st !== void 0 && _n >= st, le = $((p) => {
2298
+ const w = A.find((_) => _.id === p);
2299
+ if (w) return w;
2300
+ for (const _ of Object.values(U)) {
2301
+ const k = Object.values(_).flat().find((I) => I.id === p);
2302
+ if (k) return k;
2303
+ }
2304
+ return null;
2305
+ }, [A, U]), ze = $((p) => {
2306
+ s || (tt(p), V("nodeConfig"));
2307
+ }, [s]), at = $((p) => {
2308
+ if (!s) {
2309
+ if (A.some((w) => w.id === p)) {
2310
+ const w = A.find((_) => _.id === p);
2311
+ if ((w == null ? void 0 : w.kind) === "triggerFixed") {
2312
+ ie(Rt()), J({}), ot(null);
2313
+ return;
2314
+ }
2315
+ ie((_) => {
2316
+ const k = _.filter((I) => I.id !== p);
2317
+ return ae((w == null ? void 0 : w.kind) ?? "") && !k.some((I) => I.kind === "end") ? [...k, { id: "end", kind: "end", reactFlowType: "endNode" }] : k;
2318
+ }), J((_) => {
2319
+ const k = { ..._ }, I = (m) => {
2320
+ k[m] && (Object.values(k[m]).flat().filter((T) => ae(T.kind)).forEach((T) => I(T.id)), delete k[m]);
2321
+ };
2322
+ return I(p), k;
2323
+ });
2324
+ return;
2325
+ }
2326
+ J((w) => {
2327
+ const _ = (I, m) => {
2328
+ const T = [];
2329
+ for (const S of I)
2330
+ ae(S.kind) && m[S.id] && (T.push(S.id), Object.values(m[S.id]).forEach((C) => T.push(..._(C, m))));
2331
+ return T;
2332
+ }, k = { ...w };
2333
+ for (const I of Object.keys(k))
2334
+ for (const m of Object.keys(k[I])) {
2335
+ const T = k[I][m], S = T.findIndex((D) => D.id === p);
2336
+ if (S === -1 || T[S].kind === "end") continue;
2337
+ const C = T[S];
2338
+ let L = T.filter((D) => D.id !== p);
2339
+ return C.kind === "filter" && ((C.id in k ? _([C], k) : []).forEach((P) => delete k[P]), delete k[C.id], L.some((P) => P.kind === "end") || (L = [...L, { id: `end-${I}-${m}`, kind: "end", reactFlowType: "endNode" }])), k[I] = { ...k[I], [m]: L }, k;
2340
+ }
2341
+ return k;
2342
+ });
2343
+ }
2344
+ }, [s, A]), Le = $(() => {
2345
+ s || V("triggerSelect");
2346
+ }, [s]), dt = $((p, w) => {
2347
+ s || lt || (xe(p), nt(w.filterId && w.branch ? { filterId: w.filterId, branch: w.branch } : null), V("nodePicker"));
2348
+ }, [s, lt]), ct = $((p, w) => {
2349
+ if (ot(p), V(null), p.skeletonState) {
2350
+ const k = Array.isArray(w) && w.length > 0, I = (p.skeletonState.slots ?? []).map((m) => m.kind !== "triggerFixed" ? m : {
2351
+ ...m,
2352
+ nodeData: {
2353
+ label: p.label,
2354
+ ...m.nodeData ?? {},
2355
+ ...k && { sources: w }
2356
+ }
2357
+ });
2358
+ J(p.skeletonState.branches ?? {}), ie(I);
2359
+ return;
2360
+ }
2361
+ J({});
2362
+ const _ = Array.isArray(w) && w.length > 0;
2363
+ ie([
2364
+ { id: "start", kind: "start", reactFlowType: "startNode" },
2365
+ {
2366
+ id: `trigger-${p.triggerKey}`,
2367
+ kind: "triggerFixed",
2368
+ reactFlowType: "triggerNode",
2369
+ nodeData: {
2370
+ label: p.label,
2371
+ source: p.source,
2372
+ eventType: p.triggerKey,
2373
+ type: p.triggerCategory === "scheduler" ? "scheduler" : "event",
2374
+ ..._ && { sources: w }
2375
+ },
2376
+ deletable: !1
2377
+ },
2378
+ { id: "end", kind: "end", reactFlowType: "endNode" }
2379
+ ]);
2380
+ }, []), ut = $(() => {
2381
+ var _;
2382
+ const p = {
2383
+ insertAfterSlot: null,
2384
+ upstreamSlots: [],
2385
+ downstreamSlots: [],
2386
+ branch: se,
2387
+ template: q
2388
+ };
2389
+ if (!H) return p;
2390
+ if (se) {
2391
+ const { filterId: k, branch: I } = se, m = A.findIndex((D) => D.id === k), T = m >= 0 ? A.slice(0, m + 1) : [], S = ((_ = U[k]) == null ? void 0 : _[I]) ?? [], C = S.findIndex((D) => D.id === H), L = C >= 0 ? S.slice(0, C + 1) : [];
2392
+ return p.upstreamSlots = [...T, ...L], p.downstreamSlots = C >= 0 ? S.slice(C + 1) : S, p.insertAfterSlot = L[L.length - 1] ?? null, p;
2393
+ }
2394
+ const w = A.findIndex((k) => k.id === H);
2395
+ return p.upstreamSlots = w >= 0 ? A.slice(0, w + 1) : [], p.downstreamSlots = w >= 0 ? A.slice(w + 1) : [], p.insertAfterSlot = p.upstreamSlots[p.upstreamSlots.length - 1] ?? null, p;
2396
+ }, [A, U, H, se, q]), ft = (p, w) => p.descriptorType === w || p.id === w || p.kind === w, ht = $(() => {
2397
+ const p = e.list(), w = q != null && q.availableTasks ? p.filter((k) => q.availableTasks.includes(k.type)) : p, _ = ut();
2398
+ return w.filter((k) => k.maxPerWorkflow !== void 0 && A.filter((m) => m.descriptorType === k.type).length + Object.values(U).flatMap((m) => Object.values(m).flat()).filter((m) => m.descriptorType === k.type).length >= k.maxPerWorkflow ? !1 : k.canInsert ? k.canInsert(_) : !(k.insertAfter && k.insertAfter.length > 0 && !_.upstreamSlots.some(
2399
+ (m) => k.insertAfter.some((T) => ft(m, T))
2400
+ ) || k.insertBefore && k.insertBefore.length > 0 && !_.downstreamSlots.some(
2401
+ (m) => k.insertBefore.some((T) => ft(m, T))
2402
+ )));
2403
+ }, [e, q, A, U, ut]), gt = $((p) => {
2404
+ if (!H) return;
2405
+ const w = `${p.type}-${Date.now()}`, _ = p.reactFlowType === "filterNode" || p.reactFlowType === "approvalNode" || p.reactFlowType === "conditionBranchNode", k = p.branchLabels ?? { pass: "Pass", fail: "Fail" }, I = {
2406
+ id: w,
2407
+ kind: _ ? p.reactFlowType === "approvalNode" ? "approval" : "filter" : "userTask",
2408
+ reactFlowType: p.reactFlowType,
2409
+ descriptorType: p.type,
2410
+ formData: {},
2411
+ nodeData: { title: p.label },
2412
+ deletable: !0,
2413
+ branchLabels: k
2414
+ };
2415
+ if (se) {
2416
+ const { filterId: m, branch: T } = se;
2417
+ J((S) => {
2418
+ const C = [...S[m][T]];
2419
+ if (_) {
2420
+ const ne = C.filter((fe) => fe.kind !== "end"), wt = ne.findIndex((fe) => fe.id === H), Cn = wt === -1 ? ne.length : wt + 1;
2421
+ return ne.splice(Cn, 0, I), {
2422
+ ...S,
2423
+ [m]: { ...S[m], [T]: ne },
2424
+ [w]: Object.fromEntries(
2425
+ Object.keys(k).map((fe) => [fe, [{ id: `end-${w}-${fe}`, kind: "end", reactFlowType: "endNode" }]])
2426
+ )
2427
+ };
2428
+ }
2429
+ const L = C.findIndex((ne) => ne.id === H), D = C.findIndex((ne) => ne.kind === "end"), P = L === -1 ? D === -1 ? C.length : D : L + 1;
2430
+ return C.splice(P, 0, I), { ...S, [m]: { ...S[m], [T]: C } };
2431
+ });
2432
+ } else
2433
+ _ ? (ie((m) => {
2434
+ const T = m.findIndex((C) => C.id === H);
2435
+ return [...m.filter((C) => C.kind !== "end").slice(0, T + 1), I];
2436
+ }), J((m) => ({
2437
+ ...m,
2438
+ [w]: Object.fromEntries(
2439
+ Object.keys(k).map((T) => [T, [{ id: `end-${w}-${T}`, kind: "end", reactFlowType: "endNode" }]])
2440
+ )
2441
+ }))) : ie((m) => {
2442
+ const T = m.findIndex((S) => S.id === H);
2443
+ return T === -1 ? m : [...m.slice(0, T + 1), I, ...m.slice(T + 1)];
2444
+ });
2445
+ xe(null), nt(null), tt(w), V("nodeConfig");
2446
+ }, [H, se]), pt = $((p, w) => {
2447
+ const _ = (m) => {
2448
+ const T = m.label || m.key;
2449
+ switch (m.kind) {
2450
+ case "if":
2451
+ return `IF · ${T}`;
2452
+ case "elseif":
2453
+ return `ELSE IF · ${T}`;
2454
+ case "else":
2455
+ return T.toUpperCase() === "ELSE" ? T : `ELSE · ${T}`;
2456
+ default:
2457
+ return T;
2458
+ }
2459
+ }, k = (m) => {
2460
+ const T = le(p);
2461
+ if ((T == null ? void 0 : T.descriptorType) !== "conditionBranch") return m;
2462
+ const C = (w.branchConfigs ?? []).map((P) => P.key).filter(Boolean);
2463
+ if (C.length === 0) return m;
2464
+ const L = m[p] ?? {}, D = {};
2465
+ return C.forEach((P) => {
2466
+ D[P] = L[P] ?? [{ id: `end-${p}-${P}`, kind: "end", reactFlowType: "endNode" }];
2467
+ }), { ...m, [p]: D };
2468
+ }, I = (m, T) => {
2469
+ if (m.descriptorType !== "conditionBranch") return { ...m, formData: T };
2470
+ const S = T.branchConfigs ?? [], C = {};
2471
+ return S.forEach((L) => {
2472
+ L.key && (C[L.key] = _(L));
2473
+ }), { ...m, formData: T, branchLabels: C };
2474
+ };
2475
+ if (A.some((m) => m.id === p)) {
2476
+ J((m) => {
2477
+ const T = k(m);
2478
+ return ie((S) => {
2479
+ const C = S.map((L) => L.id === p ? I(L, w) : L);
2480
+ return i == null || i({ slots: C, branches: T }), C;
2481
+ }), T;
2482
+ });
2483
+ return;
2484
+ }
2485
+ J((m) => {
2486
+ const S = { ...k(m) };
2487
+ for (const C of Object.keys(S)) {
2488
+ const L = (D) => D.map((P) => P.id === p ? I(P, w) : P);
2489
+ for (const D of Object.keys(S[C]))
2490
+ if (S[C][D].some((P) => P.id === p))
2491
+ return S[C] = { ...S[C], [D]: L(S[C][D]) }, i == null || i({ slots: A, branches: S }), S;
2492
+ }
2493
+ return S;
2494
+ });
2495
+ }, [A, U, le, i]), Z = Y(() => le(Fe ?? ""), [le, Fe]), bt = Y(() => Z != null && Z.descriptorType ? e.forType(Z.descriptorType) ?? null : null, [Z, e]), { nodes: yt, edges: Nn } = Y(
2496
+ () => qi(A, U, s ? null : dt, it, l, y, ce),
2497
+ [A, U, s, dt, it, l, y, ce]
2498
+ ), mt = Y(() => {
2499
+ const p = x ? new Map(x.steps.map((w) => [w.nodeId, w])) : null;
2500
+ return yt.map((w) => {
2501
+ let _ = {};
2502
+ if (p) {
2503
+ const k = p.get(w.id);
2504
+ k && (_ = { _executionStatus: k.status, _executionError: k.error });
2505
+ }
2506
+ return w.type === "subWorkflowNode" && N && (_.onPreview = (k) => {
2507
+ var m;
2508
+ const I = le(w.id);
2509
+ rt({ workflowId: k, workflowLabel: ((m = I == null ? void 0 : I.formData) == null ? void 0 : m.workflowLabel) ?? void 0 });
2510
+ }), Object.keys(_).length > 0 ? { ...w, data: { ...w.data, ..._ } } : w;
2511
+ });
2512
+ }, [yt, x, N, le]), Sn = Y(() => ({ onEditNode: ze, onDeleteNode: at, onAddStep: () => {
2513
+ }, onClickAddTrigger: Le, messages: oe, nodeRegistry: e, nodeBody: pe }), [ze, at, Le, oe, e, pe]);
2514
+ return /* @__PURE__ */ f(Wn.Provider, { value: Sn, children: /* @__PURE__ */ v(
2515
+ "div",
2516
+ {
2517
+ className: "flowforge-canvas",
2518
+ style: {
2519
+ width: "100%",
2520
+ height: "100%",
2521
+ position: "relative",
2522
+ // CSS variable consumed by edge SCSS for primary/hover color
2523
+ "--ff-primary": l.primaryColor ?? "#1dbf60",
2524
+ "--ff-edge-color": l.edgeColor ?? "#b0bec5",
2525
+ "--ff-text": l.textColor ?? "#212121",
2526
+ "--ff-muted": l.mutedTextColor ?? "#9ca3af",
2527
+ "--ff-surface": l.surfaceColor ?? "#fff",
2528
+ "--ff-border": l.borderColor ?? "#dee2e6",
2529
+ "--ff-danger": l.dangerColor ?? "#d32f2f",
2530
+ "--ff-radius": `${l.borderRadius ?? 6}px`,
2531
+ "--ff-font-family": l.fontFamily
2532
+ },
2533
+ children: [
2534
+ /* @__PURE__ */ v(
2535
+ In,
2536
+ {
2537
+ nodes: mt,
2538
+ edges: Nn,
2539
+ nodeTypes: xn,
2540
+ edgeTypes: Tn,
2541
+ fitView: O,
2542
+ fitViewOptions: { padding: F },
2543
+ nodesDraggable: !1,
2544
+ nodesConnectable: !1,
2545
+ panOnScroll: z,
2546
+ zoomOnScroll: R,
2547
+ minZoom: B,
2548
+ maxZoom: Ee,
2549
+ snapToGrid: ke,
2550
+ snapGrid: te,
2551
+ proOptions: { hideAttribution: !0 },
2552
+ onNodeClick: (p, w) => {
2553
+ const _ = le(w.id);
2554
+ _ && (b != null && b(_) || (_.kind === "addTrigger" || _.kind === "triggerFixed" ? Le() : (_.kind === "userTask" || _.kind === "filter" || _.kind === "approval") && ze(w.id)));
2555
+ },
2556
+ children: [
2557
+ l.background !== "none" && /* @__PURE__ */ f(
2558
+ jn,
2559
+ {
2560
+ variant: l.background,
2561
+ color: l.backgroundColor ?? "#e0e0e0",
2562
+ gap: 20
2563
+ }
2564
+ ),
2565
+ j && /* @__PURE__ */ f(Fn, { showInteractive: !1 }),
2566
+ W && /* @__PURE__ */ f(zn, { zoomable: !0, pannable: !0 }),
2567
+ /* @__PURE__ */ f(Pi, { onHeightsReady: kn, nodeCount: mt.length })
2568
+ ]
2569
+ }
2570
+ ),
2571
+ c ? ue === "triggerSelect" && c(t.list(), ct, () => V(null)) : /* @__PURE__ */ f(Bi, { open: ue === "triggerSelect", templates: t.list(), messages: oe, onSelect: ct, onClose: () => V(null), loadTriggerSources: u }),
2572
+ h ? ue === "nodePicker" && h(ht(), gt, () => {
2573
+ V(null), xe(null);
2574
+ }) : /* @__PURE__ */ f(Wi, { open: ue === "nodePicker", availableDescriptors: ht(), messages: oe, onSelect: gt, onClose: () => {
2575
+ V(null), xe(null);
2576
+ } }),
2577
+ g ? ue === "nodeConfig" && g(bt ?? void 0, Z, pt, () => V(null)) : /* @__PURE__ */ f(Gi, { open: ue === "nodeConfig", nodeId: Fe, descriptor: bt, initialValues: Z == null ? void 0 : Z.formData, messages: oe, onSave: pt, onClose: () => V(null) }),
2578
+ N && Te && /* @__PURE__ */ f(
2579
+ $i,
2580
+ {
2581
+ isOpen: !!Te,
2582
+ onClose: () => rt(null),
2583
+ workflowId: Te.workflowId,
2584
+ workflowLabel: Te.workflowLabel,
2585
+ onFetchWorkflow: N
2586
+ }
2587
+ )
2588
+ ]
2589
+ }
2590
+ ) });
2591
+ }, Xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2592
+ __proto__: null,
2593
+ WorkflowCanvas: Bt,
2594
+ default: Bt
2595
+ }, Symbol.toStringTag, { value: "Module" })), Ye = "All";
2596
+ function Ji({ template: e, onSelect: t }) {
2597
+ var o, i;
2598
+ const n = e.triggerCategory ? fr[e.triggerCategory] : null, r = ((o = e.skeletonState) == null ? void 0 : o.slots.filter((s) => s.kind === "userTask").length) ?? 0;
2599
+ return /* @__PURE__ */ v(
2600
+ "div",
2601
+ {
2602
+ role: "button",
2603
+ tabIndex: 0,
2604
+ onClick: t,
2605
+ onKeyDown: (s) => {
2606
+ (s.key === "Enter" || s.key === " ") && t();
2607
+ },
2608
+ style: {
2609
+ border: "1.5px solid #e0e0e0",
2610
+ borderRadius: 10,
2611
+ padding: "16px",
2612
+ background: "#fff",
2613
+ cursor: "pointer",
2614
+ transition: "border-color 0.15s, box-shadow 0.15s",
2615
+ display: "flex",
2616
+ flexDirection: "column",
2617
+ gap: 8,
2618
+ outline: "none"
2619
+ },
2620
+ onMouseEnter: (s) => {
2621
+ s.currentTarget.style.borderColor = "#1976d2", s.currentTarget.style.boxShadow = "0 2px 8px rgba(25,118,210,0.12)";
2622
+ },
2623
+ onMouseLeave: (s) => {
2624
+ s.currentTarget.style.borderColor = "#e0e0e0", s.currentTarget.style.boxShadow = "none";
2625
+ },
2626
+ children: [
2627
+ /* @__PURE__ */ v("div", { style: { display: "flex", alignItems: "flex-start", gap: 10 }, children: [
2628
+ e.icon && /* @__PURE__ */ f("div", { style: { flexShrink: 0, width: 36, height: 36, borderRadius: 8, background: "#f5f5f5", display: "flex", alignItems: "center", justifyContent: "center" }, children: e.icon }),
2629
+ /* @__PURE__ */ v("div", { style: { flex: 1, minWidth: 0 }, children: [
2630
+ /* @__PURE__ */ f("div", { style: { fontWeight: 600, fontSize: 14, color: "#212121", marginBottom: 2 }, children: e.label }),
2631
+ e.description && /* @__PURE__ */ f("div", { style: { fontSize: 12, color: "#757575", lineHeight: 1.4, display: "-webkit-box", WebkitLineClamp: 2, WebkitBoxOrient: "vertical", overflow: "hidden" }, children: e.description })
2632
+ ] })
2633
+ ] }),
2634
+ /* @__PURE__ */ v("div", { style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 4 }, children: [
2635
+ n && /* @__PURE__ */ f("span", { style: { fontSize: 10, fontWeight: 600, padding: "2px 7px", borderRadius: 10, background: n.bg, color: n.color }, children: n.label }),
2636
+ (i = e.tags) == null ? void 0 : i.map((s) => /* @__PURE__ */ f("span", { style: { fontSize: 10, padding: "2px 7px", borderRadius: 10, background: "#f5f5f5", color: "#616161" }, children: s }, s)),
2637
+ r > 0 && /* @__PURE__ */ v("span", { style: { fontSize: 10, color: "#9e9e9e", marginLeft: "auto" }, children: [
2638
+ r,
2639
+ " step",
2640
+ r !== 1 ? "s" : ""
2641
+ ] })
2642
+ ] }),
2643
+ e.author && /* @__PURE__ */ v("div", { style: { fontSize: 11, color: "#bdbdbd" }, children: [
2644
+ "by ",
2645
+ e.author
2646
+ ] })
2647
+ ]
2648
+ }
2649
+ );
2650
+ }
2651
+ const gs = ({
2652
+ templates: e,
2653
+ onSelectTemplate: t,
2654
+ onStartFromScratch: n
2655
+ }) => {
2656
+ const [r, o] = M(""), [i, s] = M(Ye), l = Y(() => {
2657
+ const a = /* @__PURE__ */ new Set();
2658
+ return e.forEach((c) => {
2659
+ c.category && a.add(c.category);
2660
+ }), [Ye, ...Array.from(a)];
2661
+ }, [e]), d = Y(() => {
2662
+ let a = e;
2663
+ if (i !== Ye && (a = a.filter((c) => c.category === i)), r.trim()) {
2664
+ const c = r.toLowerCase();
2665
+ a = a.filter(
2666
+ (u) => {
2667
+ var h, g;
2668
+ return u.label.toLowerCase().includes(c) || ((h = u.description) == null ? void 0 : h.toLowerCase().includes(c)) || ((g = u.tags) == null ? void 0 : g.some((b) => b.toLowerCase().includes(c)));
2669
+ }
2670
+ );
2671
+ }
2672
+ return [...a].sort((c, u) => (u.popularity ?? 0) - (c.popularity ?? 0));
2673
+ }, [e, i, r]);
2674
+ return /* @__PURE__ */ v("div", { style: { display: "flex", flexDirection: "column", height: "100%", fontFamily: "inherit" }, children: [
2675
+ /* @__PURE__ */ v("div", { style: { padding: "24px 24px 0", borderBottom: "1px solid #f0f0f0", paddingBottom: 16 }, children: [
2676
+ /* @__PURE__ */ v("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: 16 }, children: [
2677
+ /* @__PURE__ */ v("div", { children: [
2678
+ /* @__PURE__ */ f("h2", { style: { margin: 0, fontSize: 20, fontWeight: 700, color: "#212121" }, children: "Workflow Templates" }),
2679
+ /* @__PURE__ */ f("p", { style: { margin: "4px 0 0", fontSize: 13, color: "#757575" }, children: "Choose a pre-built template or start from scratch" })
2680
+ ] }),
2681
+ n && /* @__PURE__ */ v(
2682
+ "button",
2683
+ {
2684
+ onClick: n,
2685
+ style: { display: "flex", alignItems: "center", gap: 6, padding: "8px 16px", border: "1.5px solid #1976d2", borderRadius: 6, background: "#fff", color: "#1976d2", fontSize: 13, fontWeight: 600, cursor: "pointer" },
2686
+ children: [
2687
+ /* @__PURE__ */ f(Qn, { size: 16 }),
2688
+ "Start from Scratch"
2689
+ ]
2690
+ }
2691
+ )
2692
+ ] }),
2693
+ /* @__PURE__ */ v("div", { style: { display: "flex", alignItems: "center", gap: 8, background: "#f5f5f5", borderRadius: 8, padding: "8px 12px", marginBottom: 12 }, children: [
2694
+ /* @__PURE__ */ f(er, { size: 18, color: "#9e9e9e" }),
2695
+ /* @__PURE__ */ f(
2696
+ "input",
2697
+ {
2698
+ value: r,
2699
+ onChange: (a) => o(a.target.value),
2700
+ placeholder: "Search templates...",
2701
+ style: { border: "none", background: "transparent", outline: "none", fontSize: 14, color: "#212121", flex: 1 }
2702
+ }
2703
+ )
2704
+ ] }),
2705
+ l.length > 1 && /* @__PURE__ */ f("div", { style: { display: "flex", gap: 4, flexWrap: "wrap" }, children: l.map((a) => /* @__PURE__ */ f(
2706
+ "button",
2707
+ {
2708
+ onClick: () => s(a),
2709
+ style: {
2710
+ padding: "4px 12px",
2711
+ borderRadius: 20,
2712
+ border: "1.5px solid",
2713
+ borderColor: i === a ? "#1976d2" : "#e0e0e0",
2714
+ background: i === a ? "#e3f2fd" : "#fff",
2715
+ color: i === a ? "#1565c0" : "#616161",
2716
+ fontSize: 12,
2717
+ fontWeight: i === a ? 600 : 400,
2718
+ cursor: "pointer"
2719
+ },
2720
+ children: a
2721
+ },
2722
+ a
2723
+ )) })
2724
+ ] }),
2725
+ /* @__PURE__ */ f("div", { style: { flex: 1, overflowY: "auto", padding: 24 }, children: d.length === 0 ? /* @__PURE__ */ v("div", { style: { textAlign: "center", padding: "40px 0", color: "#9e9e9e" }, children: [
2726
+ /* @__PURE__ */ f(tr, { size: 36, style: { marginBottom: 8 } }),
2727
+ /* @__PURE__ */ f("p", { style: { margin: 0, fontSize: 14 }, children: "No templates found" })
2728
+ ] }) : /* @__PURE__ */ f("div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(280px, 1fr))", gap: 16 }, children: d.map((a) => /* @__PURE__ */ f(Ji, { template: a, onSelect: () => t(a) }, a.triggerKey)) }) })
2729
+ ] });
2730
+ }, _e = {
2731
+ running: { label: "Running", color: ee.running, icon: G.createElement(Ut, { size: 14 }) },
2732
+ success: { label: "Success", color: ee.success, icon: G.createElement(Kt, { size: 14 }) },
2733
+ failed: { label: "Failed", color: ee.failed, icon: G.createElement(Yt, { size: 14 }) },
2734
+ cancelled: { label: "Cancelled", color: ee.cancelled, icon: G.createElement($t, { size: 14 }) }
2735
+ }, Zi = {
2736
+ pending: { color: ee.pending, icon: G.createElement(nr, { size: 14 }) },
2737
+ running: { color: ee.running, icon: G.createElement(Ut, { size: 14 }) },
2738
+ success: { color: ee.success, icon: G.createElement(Kt, { size: 14 }) },
2739
+ failed: { color: ee.failed, icon: G.createElement(Yt, { size: 14 }) },
2740
+ skipped: { color: ee.skipped, icon: G.createElement($t, { size: 14 }) }
2741
+ };
2742
+ function qe(e) {
2743
+ try {
2744
+ return new Date(e).toLocaleString();
2745
+ } catch {
2746
+ return e;
2747
+ }
2748
+ }
2749
+ function vn(e, t) {
2750
+ try {
2751
+ const n = new Date(t ?? (/* @__PURE__ */ new Date()).toISOString()).getTime() - new Date(e).getTime();
2752
+ return n < 1e3 ? `${n}ms` : n < 6e4 ? `${(n / 1e3).toFixed(1)}s` : `${Math.floor(n / 6e4)}m ${Math.floor(n % 6e4 / 1e3)}s`;
2753
+ } catch {
2754
+ return "—";
2755
+ }
2756
+ }
2757
+ function Qi({ step: e }) {
2758
+ const [t, n] = M(!1), r = Zi[e.status], o = !!(e.inputs || e.outputs || e.error);
2759
+ return /* @__PURE__ */ v("div", { style: { borderBottom: "1px solid #f5f5f5" }, children: [
2760
+ /* @__PURE__ */ v(
2761
+ "div",
2762
+ {
2763
+ style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", cursor: o ? "pointer" : "default" },
2764
+ onClick: () => {
2765
+ o && n((i) => !i);
2766
+ },
2767
+ role: o ? "button" : void 0,
2768
+ tabIndex: o ? 0 : void 0,
2769
+ onKeyDown: (i) => {
2770
+ o && (i.key === "Enter" || i.key === " ") && n((s) => !s);
2771
+ },
2772
+ children: [
2773
+ /* @__PURE__ */ f("span", { style: { color: r.color, flexShrink: 0 }, children: G.cloneElement(r.icon, { color: r.color }) }),
2774
+ /* @__PURE__ */ f("span", { style: { flex: 1, fontSize: 13, color: "#212121" }, children: e.label || e.nodeId }),
2775
+ e.branchTaken && /* @__PURE__ */ f("span", { style: { fontSize: 10, padding: "1px 6px", borderRadius: 10, background: "#e3f2fd", color: "#1565c0", fontWeight: 600 }, children: e.branchTaken }),
2776
+ /* @__PURE__ */ f("span", { style: { fontSize: 11, color: "#9e9e9e", flexShrink: 0 }, children: e.startedAt ? vn(e.startedAt, e.completedAt) : "—" }),
2777
+ o && /* @__PURE__ */ f("span", { style: { color: "#9e9e9e", flexShrink: 0 }, children: t ? G.createElement(or, { size: 16 }) : G.createElement(ir, { size: 16 }) })
2778
+ ]
2779
+ }
2780
+ ),
2781
+ t && o && /* @__PURE__ */ v("div", { style: { padding: "0 12px 10px 32px", fontSize: 12 }, children: [
2782
+ e.error && /* @__PURE__ */ f("div", { style: { padding: "6px 10px", borderRadius: 6, background: "#ffebee", color: "#c62828", marginBottom: 6 }, children: e.error }),
2783
+ e.inputs && Object.keys(e.inputs).length > 0 && /* @__PURE__ */ v("details", { style: { marginBottom: 4 }, children: [
2784
+ /* @__PURE__ */ f("summary", { style: { cursor: "pointer", color: "#616161", marginBottom: 4 }, children: "Inputs" }),
2785
+ /* @__PURE__ */ f("pre", { style: { margin: 0, fontSize: 11, background: "#f5f5f5", padding: 8, borderRadius: 4, overflowX: "auto" }, children: JSON.stringify(e.inputs, null, 2) })
2786
+ ] }),
2787
+ e.outputs && Object.keys(e.outputs).length > 0 && /* @__PURE__ */ v("details", { children: [
2788
+ /* @__PURE__ */ f("summary", { style: { cursor: "pointer", color: "#616161", marginBottom: 4 }, children: "Outputs" }),
2789
+ /* @__PURE__ */ f("pre", { style: { margin: 0, fontSize: 11, background: "#f5f5f5", padding: 8, borderRadius: 4, overflowX: "auto" }, children: JSON.stringify(e.outputs, null, 2) })
2790
+ ] })
2791
+ ] })
2792
+ ] });
2793
+ }
2794
+ function es({ record: e, selected: t, onSelect: n }) {
2795
+ const r = _e[e.status];
2796
+ return /* @__PURE__ */ v(
2797
+ "div",
2798
+ {
2799
+ role: "button",
2800
+ tabIndex: 0,
2801
+ onClick: n,
2802
+ onKeyDown: (o) => {
2803
+ (o.key === "Enter" || o.key === " ") && n();
2804
+ },
2805
+ style: {
2806
+ padding: "10px 14px",
2807
+ borderBottom: "1px solid #f0f0f0",
2808
+ cursor: "pointer",
2809
+ background: t ? "#e3f2fd" : "#fff",
2810
+ display: "flex",
2811
+ alignItems: "center",
2812
+ gap: 10,
2813
+ outline: "none"
2814
+ },
2815
+ children: [
2816
+ /* @__PURE__ */ f("span", { style: { color: r.color, flexShrink: 0 }, children: G.cloneElement(r.icon, { color: r.color, size: 16 }) }),
2817
+ /* @__PURE__ */ v("div", { style: { flex: 1, minWidth: 0 }, children: [
2818
+ /* @__PURE__ */ f("div", { style: { fontSize: 12, color: "#212121", fontWeight: t ? 600 : 400, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: qe(e.triggeredAt) }),
2819
+ /* @__PURE__ */ v("div", { style: { fontSize: 11, color: "#9e9e9e" }, children: [
2820
+ e.triggeredBy ? `by ${e.triggeredBy}` : "System",
2821
+ " · ",
2822
+ e.steps.length,
2823
+ " step",
2824
+ e.steps.length !== 1 ? "s" : ""
2825
+ ] })
2826
+ ] }),
2827
+ /* @__PURE__ */ f("span", { style: { fontSize: 11, fontWeight: 600, color: r.color, flexShrink: 0 }, children: r.label }),
2828
+ /* @__PURE__ */ f(Gt, { size: 14, color: "#bdbdbd" })
2829
+ ]
2830
+ }
2831
+ );
2832
+ }
2833
+ const ps = ({ records: e, onViewOnCanvas: t }) => {
2834
+ var s;
2835
+ const [n, r] = M(((s = e[0]) == null ? void 0 : s.id) ?? null), o = e.find((l) => l.id === n) ?? null, i = [...e].sort((l, d) => new Date(d.triggeredAt).getTime() - new Date(l.triggeredAt).getTime());
2836
+ return e.length === 0 ? /* @__PURE__ */ v("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", height: 300, color: "#9e9e9e", gap: 8 }, children: [
2837
+ /* @__PURE__ */ f(kt, { size: 36 }),
2838
+ /* @__PURE__ */ f("p", { style: { margin: 0, fontSize: 14 }, children: "No executions yet" }),
2839
+ /* @__PURE__ */ f("p", { style: { margin: 0, fontSize: 12 }, children: "Run history will appear here" })
2840
+ ] }) : /* @__PURE__ */ v("div", { style: { display: "flex", height: "100%", fontFamily: "inherit", border: "1px solid #e0e0e0", borderRadius: 8, overflow: "hidden" }, children: [
2841
+ /* @__PURE__ */ v("div", { style: { width: 260, flexShrink: 0, borderRight: "1px solid #e0e0e0", overflowY: "auto", background: "#fafafa" }, children: [
2842
+ /* @__PURE__ */ v("div", { style: { padding: "12px 14px", borderBottom: "1px solid #e0e0e0", fontWeight: 600, fontSize: 13, color: "#212121" }, children: [
2843
+ "Run History (",
2844
+ e.length,
2845
+ ")"
2846
+ ] }),
2847
+ i.map((l) => /* @__PURE__ */ f(es, { record: l, selected: l.id === n, onSelect: () => r(l.id) }, l.id))
2848
+ ] }),
2849
+ /* @__PURE__ */ f("div", { style: { flex: 1, overflowY: "auto" }, children: o ? /* @__PURE__ */ v("div", { children: [
2850
+ /* @__PURE__ */ v("div", { style: { padding: "16px 20px", borderBottom: "1px solid #f0f0f0", display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 12 }, children: [
2851
+ /* @__PURE__ */ v("div", { children: [
2852
+ /* @__PURE__ */ v("div", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 4 }, children: [
2853
+ G.cloneElement(_e[o.status].icon, { color: _e[o.status].color, size: 18 }),
2854
+ /* @__PURE__ */ f("span", { style: { fontWeight: 700, fontSize: 15, color: "#212121" }, children: _e[o.status].label })
2855
+ ] }),
2856
+ /* @__PURE__ */ v("div", { style: { fontSize: 12, color: "#757575", display: "flex", flexDirection: "column", gap: 2 }, children: [
2857
+ /* @__PURE__ */ v("span", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
2858
+ /* @__PURE__ */ f(kt, { size: 13 }),
2859
+ " ",
2860
+ qe(o.triggeredAt),
2861
+ o.completedAt && ` → ${qe(o.completedAt)} (${vn(o.triggeredAt, o.completedAt)})`
2862
+ ] }),
2863
+ o.triggeredBy && /* @__PURE__ */ v("span", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
2864
+ /* @__PURE__ */ f(rr, { size: 13 }),
2865
+ " ",
2866
+ o.triggeredBy
2867
+ ] })
2868
+ ] })
2869
+ ] }),
2870
+ t && /* @__PURE__ */ f(
2871
+ "button",
2872
+ {
2873
+ onClick: () => t(o),
2874
+ style: { padding: "6px 12px", border: "1.5px solid #1976d2", borderRadius: 6, background: "#fff", color: "#1976d2", fontSize: 12, fontWeight: 600, cursor: "pointer", flexShrink: 0 },
2875
+ children: "View on Canvas"
2876
+ }
2877
+ )
2878
+ ] }),
2879
+ o.error && /* @__PURE__ */ f("div", { style: { margin: "12px 16px", padding: "10px 14px", borderRadius: 6, background: "#ffebee", color: "#c62828", fontSize: 13 }, children: o.error }),
2880
+ /* @__PURE__ */ v("div", { children: [
2881
+ /* @__PURE__ */ v("div", { style: { padding: "10px 12px", fontSize: 12, fontWeight: 600, color: "#757575", borderBottom: "1px solid #f0f0f0" }, children: [
2882
+ "STEPS (",
2883
+ o.steps.length,
2884
+ ")"
2885
+ ] }),
2886
+ o.steps.map((l, d) => /* @__PURE__ */ f(Qi, { step: l }, `${l.nodeId}-${d}`))
2887
+ ] }),
2888
+ o.inputs && Object.keys(o.inputs).length > 0 && /* @__PURE__ */ f("div", { style: { padding: "10px 16px" }, children: /* @__PURE__ */ v("details", { children: [
2889
+ /* @__PURE__ */ f("summary", { style: { cursor: "pointer", fontSize: 12, fontWeight: 600, color: "#757575", marginBottom: 6 }, children: "TRIGGER INPUTS" }),
2890
+ /* @__PURE__ */ f("pre", { style: { margin: 0, fontSize: 11, background: "#f5f5f5", padding: 10, borderRadius: 4, overflowX: "auto" }, children: JSON.stringify(o.inputs, null, 2) })
2891
+ ] }) })
2892
+ ] }) : /* @__PURE__ */ f("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "100%", color: "#9e9e9e", fontSize: 14 }, children: "Select a run to see details" }) })
2893
+ ] });
2894
+ }, bs = {
2895
+ slots: [
2896
+ { id: "start", kind: "start", reactFlowType: "startNode", deletable: !1 },
2897
+ { id: "trigger-END_USER_CREATION", kind: "triggerFixed", reactFlowType: "triggerNode", deletable: !0, label: "New User Registration", nodeData: { label: "New User Registration" } },
2898
+ { id: "notification-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Welcome Email", nodeData: { title: "Welcome Email" } },
2899
+ { id: "approval-1", kind: "approval", reactFlowType: "approvalNode", descriptorType: "approval", deletable: !0, label: "Manager Approval", branchLabels: { pass: "Approved", fail: "Rejected" } },
2900
+ { id: "end", kind: "end", reactFlowType: "endNode", deletable: !1 }
2901
+ ],
2902
+ branches: {
2903
+ "approval-1": {
2904
+ pass: [{ id: "notification-pass-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Approval Confirmed", nodeData: { title: "Approval Confirmed" } }],
2905
+ fail: [{ id: "notification-fail-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Rejection Notice", nodeData: { title: "Rejection Notice" } }]
2906
+ }
2907
+ }
2908
+ }, ys = {
2909
+ slots: [
2910
+ { id: "start", kind: "start", reactFlowType: "startNode", deletable: !1 },
2911
+ { id: "trigger-ACCESS_REQUEST", kind: "triggerFixed", reactFlowType: "triggerNode", deletable: !0, label: "Access Request Submitted", nodeData: { label: "Access Request Submitted" } },
2912
+ { id: "approval-1", kind: "approval", reactFlowType: "approvalNode", descriptorType: "approval", deletable: !0, label: "Access Approval", branchLabels: { pass: "Approved", fail: "Denied" } },
2913
+ { id: "end", kind: "end", reactFlowType: "endNode", deletable: !1 }
2914
+ ],
2915
+ branches: {
2916
+ "approval-1": {
2917
+ pass: [
2918
+ { id: "restApi-1", kind: "userTask", reactFlowType: "restApiNode", descriptorType: "restApi", deletable: !0, label: "Provision Access", nodeData: { title: "Provision Access" } },
2919
+ { id: "notification-pass-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Access Granted Email", nodeData: { title: "Access Granted Email" } }
2920
+ ],
2921
+ fail: [
2922
+ { id: "notification-fail-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Access Denied Email", nodeData: { title: "Access Denied Email" } }
2923
+ ]
2924
+ }
2925
+ }
2926
+ }, ms = {
2927
+ slots: [
2928
+ { id: "start", kind: "start", reactFlowType: "startNode", deletable: !1 },
2929
+ { id: "trigger-USER_DEACTIVATION", kind: "triggerFixed", reactFlowType: "triggerNode", deletable: !0, label: "User Deactivation", nodeData: { label: "User Deactivation" } },
2930
+ { id: "delay-1", kind: "userTask", reactFlowType: "delayNode", descriptorType: "delay", deletable: !0, label: "Grace Period", nodeData: { title: "Grace Period", duration: 7, unit: "days" }, formData: { duration: 7, unit: "days" } },
2931
+ { id: "notification-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Notify IT Team", nodeData: { title: "Notify IT Team" } },
2932
+ { id: "end", kind: "end", reactFlowType: "endNode", deletable: !1 }
2933
+ ],
2934
+ branches: {}
2935
+ }, ws = {
2936
+ slots: [
2937
+ { id: "start", kind: "start", reactFlowType: "startNode", deletable: !1 },
2938
+ { id: "trigger-WEBHOOK_TRIGGER", kind: "triggerFixed", reactFlowType: "webhookTriggerNode", deletable: !0, label: "Incoming Webhook", nodeData: { label: "Incoming Webhook" } },
2939
+ { id: "restApi-1", kind: "userTask", reactFlowType: "restApiNode", descriptorType: "restApi", deletable: !0, label: "Call External API", nodeData: { title: "Call External API" } },
2940
+ { id: "notification-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Notify on Completion", nodeData: { title: "Notify on Completion" } },
2941
+ { id: "end", kind: "end", reactFlowType: "endNode", deletable: !1 }
2942
+ ],
2943
+ branches: {}
2944
+ };
2945
+ export {
2946
+ Bt as F,
2947
+ $i as S,
2948
+ ps as W,
2949
+ gs as a,
2950
+ ys as b,
2951
+ ms as o,
2952
+ bs as u,
2953
+ ws as w
2954
+ };