@notmrabhi/flowforge 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{GatewayBranchEdge-4XMPBHne.js → GatewayBranchEdge-BdUVHQJc.js} +57 -49
- package/dist/GatewayBranchEdge-DK6kuCK2.js +1 -0
- package/dist/{SchemaBuilderDrawer-D14R1O1M.js → SchemaBuilderDrawer-157p-2Vj.js} +1 -1
- package/dist/{SchemaBuilderDrawer-jbSe-O-O.js → SchemaBuilderDrawer-Wje7pVrn.js} +1 -1
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.js +2 -2
- package/dist/defaultUi.cjs +1 -1
- package/dist/defaultUi.js +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.js +2 -2
- package/dist/{index-CxVqPygT.js → index-BU09HbVh.js} +11 -5
- package/dist/{index-BWAxupnf.js → index-CQ0cVcHp.js} +1 -1
- package/dist/{index-C0Eu9PxA.js → index-Codx5QwP.js} +1 -1
- package/dist/{index-DZOcYc5S.js → index-Da5NHCS2.js} +1 -1
- package/dist/{index-DNZlQp9z.js → index-a1IOaYsW.js} +1 -1
- package/dist/{index-DLSkW4rA.js → index-a3QMaedZ.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/{templateSkeletons-BRBQmvvx.js → templateSkeletons--Ol7Sg7H.js} +1 -1
- package/dist/{templateSkeletons-uBCB72rO.js → templateSkeletons-DcvDac7_.js} +191 -190
- package/package.json +1 -1
- package/dist/GatewayBranchEdge-mRo5aZ3f.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as n, jsx as e, Fragment as L } from "react/jsx-runtime";
|
|
2
2
|
import { Handle as b, Position as x, getStraightPath as M, BaseEdge as K } from "reactflow";
|
|
3
|
-
import { Tooltip as
|
|
3
|
+
import { Tooltip as D, Chip as U } from "@mui/material";
|
|
4
4
|
import { GrTrigger as ce } from "react-icons/gr";
|
|
5
5
|
import { createContext as de, useContext as ae } from "react";
|
|
6
6
|
import { d as pe } from "./messages-CO299wPN.js";
|
|
@@ -30,7 +30,7 @@ const Ee = de({
|
|
|
30
30
|
const { onClickAddTrigger: t, messages: i } = E();
|
|
31
31
|
return /* @__PURE__ */ n("div", { style: { width: 350, display: "flex", justifyContent: "center" }, children: [
|
|
32
32
|
/* @__PURE__ */ e(b, { type: "target", position: x.Top, style: { opacity: 0, left: "50%" } }),
|
|
33
|
-
/* @__PURE__ */ e(
|
|
33
|
+
/* @__PURE__ */ e(D, { title: i.addTriggerTooltip, placement: "top", arrow: !0, children: /* @__PURE__ */ n(
|
|
34
34
|
"div",
|
|
35
35
|
{
|
|
36
36
|
onClick: t,
|
|
@@ -69,13 +69,13 @@ const Ee = de({
|
|
|
69
69
|
);
|
|
70
70
|
};
|
|
71
71
|
function Pe(t) {
|
|
72
|
-
return t ? t === "END_USER_CREATION" ? "New User Registration" : t === "END_USER_UPDATION" ? "On User Update" : t.replace(/[_-]+/g, " ").replace(/\b\w/g, (i) => i.toUpperCase()) : "";
|
|
72
|
+
return t ? t === "END_USER_CREATION" ? "New User Registration" : t === "END_USER_UPDATION" ? "On User Update" : t.replace(/[_-]+/g, " ").toLowerCase().replace(/\b\w/g, (i) => i.toUpperCase()) : "";
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function De(t) {
|
|
75
75
|
const i = typeof t == "string" ? t : t.value ?? "";
|
|
76
76
|
return i === "SIGNUP_FLOW" ? "User Self-Registration" : i === "ADMIN_CREATION_FLOW" ? "Create User via Admin Portal" : i === "SHEDULAR" ? "Scheduler" : typeof t != "string" && t.label ? t.label : i.replace(/[_-]+/g, " ").replace(/\b\w/g, (f) => f.toUpperCase());
|
|
77
77
|
}
|
|
78
|
-
const
|
|
78
|
+
const Ae = ({ data: t }) => {
|
|
79
79
|
const { onClickAddTrigger: i } = E(), {
|
|
80
80
|
type: f,
|
|
81
81
|
eventType: a,
|
|
@@ -87,37 +87,45 @@ const De = ({ data: t }) => {
|
|
|
87
87
|
infoText: d = "This node decides the flow trigger type and configuration."
|
|
88
88
|
} = t ?? {}, y = (m) => {
|
|
89
89
|
m == null || m.stopPropagation(), i();
|
|
90
|
-
}, h = Array.isArray(s) && s.length > 0, N = !!(r || g), p = f === "scheduler" ? "Scheduler Trigger" : f === "event" || h || N ? "Event Trigger Source" : "Select Trigger", c =
|
|
91
|
-
|
|
92
|
-
/* @__PURE__ */ e("span", {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
role: "button",
|
|
112
|
-
tabIndex: 0,
|
|
113
|
-
onClick: y,
|
|
114
|
-
onKeyDown: (m) => {
|
|
115
|
-
(m.key === "Enter" || m.key === " ") && y(m);
|
|
116
|
-
},
|
|
117
|
-
style: { cursor: "pointer", color: "#1e88e5" },
|
|
118
|
-
children: "Click to select a trigger to start your workflow"
|
|
90
|
+
}, h = Array.isArray(s) && s.length > 0, N = !!(r || g), p = f === "scheduler" ? "Scheduler Trigger" : f === "event" || h || N ? "Event Trigger Source" : "Select Trigger", c = (() => {
|
|
91
|
+
if (f === "scheduler")
|
|
92
|
+
return /* @__PURE__ */ e("span", { children: "Scheduler to be configured" });
|
|
93
|
+
if (f === "event" || h) {
|
|
94
|
+
const m = r || Pe(a);
|
|
95
|
+
return /* @__PURE__ */ n("div", { children: [
|
|
96
|
+
/* @__PURE__ */ n("div", { className: "ff-d-flex ff-align-items-center", children: [
|
|
97
|
+
/* @__PURE__ */ e("span", { style: { fontWeight: 600 }, children: m }),
|
|
98
|
+
/* @__PURE__ */ e("span", { className: "ff-ms-2 ff-text-muted", style: { fontSize: 12 }, children: "via" })
|
|
99
|
+
] }),
|
|
100
|
+
/* @__PURE__ */ e("div", { className: "ff-d-flex ff-flex-wrap ff-mt-2", style: { gap: 4 }, children: h ? s.map((w, k) => /* @__PURE__ */ e(
|
|
101
|
+
U,
|
|
102
|
+
{
|
|
103
|
+
label: De(w),
|
|
104
|
+
variant: "outlined",
|
|
105
|
+
size: "small",
|
|
106
|
+
className: "ff-text-dark"
|
|
107
|
+
},
|
|
108
|
+
k
|
|
109
|
+
)) : /* @__PURE__ */ e("span", { className: "ff-text-muted", style: { fontSize: 12 }, children: "No source selected" }) })
|
|
110
|
+
] });
|
|
119
111
|
}
|
|
120
|
-
|
|
112
|
+
return N ? /* @__PURE__ */ n("div", { className: "ff-d-flex ff-flex-wrap ff-align-items-center", style: { gap: 6 }, children: [
|
|
113
|
+
r && /* @__PURE__ */ e("span", { style: { fontWeight: 600 }, children: r }),
|
|
114
|
+
g && /* @__PURE__ */ e(U, { label: g, variant: "outlined", size: "small" })
|
|
115
|
+
] }) : /* @__PURE__ */ e(
|
|
116
|
+
"span",
|
|
117
|
+
{
|
|
118
|
+
role: "button",
|
|
119
|
+
tabIndex: 0,
|
|
120
|
+
onClick: y,
|
|
121
|
+
onKeyDown: (m) => {
|
|
122
|
+
(m.key === "Enter" || m.key === " ") && y(m);
|
|
123
|
+
},
|
|
124
|
+
style: { cursor: "pointer", color: "#1e88e5" },
|
|
125
|
+
children: "Click to select a trigger to start your workflow"
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
})(), v = l ? /* @__PURE__ */ n(L, { children: [
|
|
121
129
|
l.status === "success" && /* @__PURE__ */ e(le, { size: 16, color: "#1DBF60", style: { marginRight: 8 } }),
|
|
122
130
|
l.status === "failed" && /* @__PURE__ */ e(re, { size: 16, color: "#f44336", style: { marginRight: 8 } })
|
|
123
131
|
] }) : /* @__PURE__ */ n("div", { className: "ff-d-flex ff-align-items-center", children: [
|
|
@@ -136,7 +144,7 @@ const De = ({ data: t }) => {
|
|
|
136
144
|
children: /* @__PURE__ */ e(T, { size: 16 })
|
|
137
145
|
}
|
|
138
146
|
),
|
|
139
|
-
/* @__PURE__ */ e(
|
|
147
|
+
/* @__PURE__ */ e(D, { title: /* @__PURE__ */ e("div", { children: d }), placement: "right", arrow: !0, children: /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(W, { color: "gray", size: 16 }) }) })
|
|
140
148
|
] });
|
|
141
149
|
return /* @__PURE__ */ n("div", { style: { width: 350 }, children: [
|
|
142
150
|
/* @__PURE__ */ e(b, { type: "target", position: x.Top, style: { opacity: 0 } }),
|
|
@@ -223,7 +231,7 @@ const We = ({ data: t }) => {
|
|
|
223
231
|
/* @__PURE__ */ n("div", { className: "ff-d-flex ff-align-items-center", children: [
|
|
224
232
|
(r == null ? void 0 : r.status) === "success" && /* @__PURE__ */ e(le, { size: 16, color: "#1DBF60", style: { marginRight: 8 } }),
|
|
225
233
|
(r == null ? void 0 : r.status) === "failed" && /* @__PURE__ */ e(re, { size: 16, color: "#f44336", style: { marginRight: 8 } }),
|
|
226
|
-
!r && /* @__PURE__ */ e(
|
|
234
|
+
!r && /* @__PURE__ */ e(D, { title: /* @__PURE__ */ e("div", { children: g }), placement: "right", arrow: !0, children: /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(W, { color: "gray", size: 16 }) }) })
|
|
227
235
|
] })
|
|
228
236
|
] }),
|
|
229
237
|
/* @__PURE__ */ n(
|
|
@@ -343,7 +351,7 @@ const We = ({ data: t }) => {
|
|
|
343
351
|
children: /* @__PURE__ */ e(P, { color: "red", size: 16 })
|
|
344
352
|
}
|
|
345
353
|
),
|
|
346
|
-
/* @__PURE__ */ e(
|
|
354
|
+
/* @__PURE__ */ e(D, { title: r, placement: "right", arrow: !0, children: /* @__PURE__ */ e("div", { className: "ff-ms-2", children: /* @__PURE__ */ e(W, { color: "gray", size: 16 }) }) })
|
|
347
355
|
] })
|
|
348
356
|
] }),
|
|
349
357
|
/* @__PURE__ */ e("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: "#fafafa", fontSize: 12 }, children: s.length === 0 ? /* @__PURE__ */ e("span", { className: "ff-text-muted", children: "No conditions configured" }) : s.map((o, l) => /* @__PURE__ */ n("div", { className: "ff-d-flex ff-align-items-center ff-mb-1", children: [
|
|
@@ -396,7 +404,7 @@ const We = ({ data: t }) => {
|
|
|
396
404
|
children: /* @__PURE__ */ e(P, { color: "red", size: 16 })
|
|
397
405
|
}
|
|
398
406
|
),
|
|
399
|
-
p && /* @__PURE__ */ e(
|
|
407
|
+
p && /* @__PURE__ */ e(D, { title: p, placement: "right", arrow: !0, children: /* @__PURE__ */ e("div", { className: "ff-ms-2", children: /* @__PURE__ */ e(W, { color: "gray", size: 16 }) }) })
|
|
400
408
|
] })
|
|
401
409
|
] }),
|
|
402
410
|
r !== "title-only" && /* @__PURE__ */ e("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: "#fafafa", fontSize: 12 }, children: c != null && c.renderNode ? c.renderNode(i) : I ? /* @__PURE__ */ e("div", { className: "ff-d-flex ff-flex-wrap ff-gap-1", children: k.map((u, z) => /* @__PURE__ */ e("span", { className: "ff-badge ff-bg-dark ff-text-white ff-py-1 ff-px-2 ff-rounded", style: { fontSize: 11 }, title: u, children: u }, z)) }) : /* @__PURE__ */ e("span", { className: "ff-text-muted", children: "Not configured" }) })
|
|
@@ -445,7 +453,7 @@ const We = ({ data: t }) => {
|
|
|
445
453
|
children: /* @__PURE__ */ e(P, { color: "red", size: 16 })
|
|
446
454
|
}
|
|
447
455
|
),
|
|
448
|
-
/* @__PURE__ */ e(
|
|
456
|
+
/* @__PURE__ */ e(D, { title: "This approval policy determines who must approve a request before the workflow continues.", arrow: !0, placement: "right", children: /* @__PURE__ */ e("span", { className: "ff-ms-2 ff-d-inline-flex", children: /* @__PURE__ */ e(W, { color: "gray", size: 16 }) }) })
|
|
449
457
|
] })
|
|
450
458
|
] }),
|
|
451
459
|
/* @__PURE__ */ n("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: "#FCFCFC" }, children: [
|
|
@@ -459,8 +467,8 @@ const We = ({ data: t }) => {
|
|
|
459
467
|
] }),
|
|
460
468
|
l.length > 0 ? /* @__PURE__ */ n("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
461
469
|
y.map((p, c) => {
|
|
462
|
-
var z,
|
|
463
|
-
const v = ((z = p.stageName) == null ? void 0 : z.trim()) || `Stage ${c + 1}`, m = Array.isArray(p.userIds) ? p.userIds.length : 0, w = ((
|
|
470
|
+
var z, A, C;
|
|
471
|
+
const v = ((z = p.stageName) == null ? void 0 : z.trim()) || `Stage ${c + 1}`, m = Array.isArray(p.userIds) ? p.userIds.length : 0, w = ((A = p.groupName) == null ? void 0 : A.trim()) ?? "", k = ((C = p.roleName) == null ? void 0 : C.trim()) ?? "", I = m > 0 || w || k;
|
|
464
472
|
let u = "Not configured";
|
|
465
473
|
return w ? u = `Group: ${w}` : k ? u = `Role: ${k}` : m > 0 && (u = `${m} approver${m !== 1 ? "s" : ""}`), /* @__PURE__ */ n("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
|
|
466
474
|
/* @__PURE__ */ e("div", { className: "ff-rounded-circle ff-d-flex ff-align-items-center ff-justify-content-center ff-flex-shrink-0", style: { width: 28, height: 28, background: "#FFF9C4", color: "#5D4037", fontSize: 12, fontWeight: 700 }, children: c + 1 }),
|
|
@@ -685,7 +693,7 @@ const Ue = ({ id: t, data: i }) => {
|
|
|
685
693
|
] }),
|
|
686
694
|
a && /* @__PURE__ */ n("div", { className: "ff-d-flex ff-align-items-center ff-gap-1", style: { marginTop: 4 }, children: [
|
|
687
695
|
/* @__PURE__ */ e("span", { style: { fontSize: 10, color: "#1565c0", fontFamily: "monospace", flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: a }),
|
|
688
|
-
/* @__PURE__ */ e(
|
|
696
|
+
/* @__PURE__ */ e(D, { title: "Copy URL", placement: "top", arrow: !0, children: /* @__PURE__ */ e(
|
|
689
697
|
"div",
|
|
690
698
|
{
|
|
691
699
|
role: "button",
|
|
@@ -908,7 +916,7 @@ const Ue = ({ id: t, data: i }) => {
|
|
|
908
916
|
endNode: Te,
|
|
909
917
|
addTriggerNode: ze,
|
|
910
918
|
addStepNode: Ie,
|
|
911
|
-
triggerNode:
|
|
919
|
+
triggerNode: Ae,
|
|
912
920
|
eventNode: We,
|
|
913
921
|
filterNode: Fe,
|
|
914
922
|
actionNode: $e,
|
|
@@ -949,7 +957,7 @@ const Ue = ({ id: t, data: i }) => {
|
|
|
949
957
|
stepVisibility: d == null ? void 0 : d.stepVisibility
|
|
950
958
|
};
|
|
951
959
|
u(o, fe);
|
|
952
|
-
},
|
|
960
|
+
}, A = (R) => {
|
|
953
961
|
(R.key === "Enter" || R.key === " ") && (R.preventDefault(), z(R));
|
|
954
962
|
}, C = () => /* @__PURE__ */ n(L, { children: [
|
|
955
963
|
/* @__PURE__ */ n("g", { className: "plus-icon-container", children: [
|
|
@@ -964,7 +972,7 @@ const Ue = ({ id: t, data: i }) => {
|
|
|
964
972
|
] })
|
|
965
973
|
] }), S = u ? {
|
|
966
974
|
onClick: z,
|
|
967
|
-
onKeyDown:
|
|
975
|
+
onKeyDown: A,
|
|
968
976
|
role: "button",
|
|
969
977
|
tabIndex: 0,
|
|
970
978
|
style: { cursor: "pointer", pointerEvents: "all" }
|
|
@@ -1183,7 +1191,7 @@ const Ue = ({ id: t, data: i }) => {
|
|
|
1183
1191
|
filterId: d == null ? void 0 : d.filterId,
|
|
1184
1192
|
branch: d == null ? void 0 : d.branch
|
|
1185
1193
|
});
|
|
1186
|
-
},
|
|
1194
|
+
}, A = 11.5, C = 6;
|
|
1187
1195
|
return /* @__PURE__ */ n("g", { children: [
|
|
1188
1196
|
/* @__PURE__ */ e("path", { id: t, d: N, fill: "none", stroke: p, strokeWidth: 1.5, markerEnd: l }),
|
|
1189
1197
|
c && !y && /* @__PURE__ */ e("g", { transform: `translate(${k}, ${u})`, children: (() => {
|
|
@@ -1225,7 +1233,7 @@ const Ue = ({ id: t, data: i }) => {
|
|
|
1225
1233
|
style: { cursor: "pointer", pointerEvents: "all" },
|
|
1226
1234
|
className: "nodrag nopan edge-plus-svg",
|
|
1227
1235
|
children: [
|
|
1228
|
-
/* @__PURE__ */ e("circle", { r:
|
|
1236
|
+
/* @__PURE__ */ e("circle", { r: A, className: "edge-plus-circle" }),
|
|
1229
1237
|
/* @__PURE__ */ e("line", { x1: 0, y1: -C, x2: 0, y2: C, strokeWidth: 2, strokeLinecap: "round", className: "plus-line" }),
|
|
1230
1238
|
/* @__PURE__ */ e("line", { x1: -C, y1: 0, x2: C, y2: 0, strokeWidth: 2, strokeLinecap: "round", className: "plus-line" })
|
|
1231
1239
|
]
|
|
@@ -1244,7 +1252,7 @@ export {
|
|
|
1244
1252
|
pt as P,
|
|
1245
1253
|
He as R,
|
|
1246
1254
|
Ce as S,
|
|
1247
|
-
|
|
1255
|
+
Ae as T,
|
|
1248
1256
|
Oe as W,
|
|
1249
1257
|
ze as a,
|
|
1250
1258
|
Be as b,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),l=require("reactflow"),E=require("@mui/material"),ce=require("react-icons/gr"),V=require("react"),fe=require("./messages-O9Tw_XXR.js"),h=require("react-icons/md"),L=require("react-icons/fa"),ae=require("react-icons/fi"),C=require("./canvasTokens-gKNYrPl4.js"),Z=V.createContext({onEditNode:()=>{},onDeleteNode:()=>{},onAddStep:()=>{},onClickAddTrigger:()=>{},messages:fe.defaultFlowForgeMessages,nodeRegistry:null,nodeBody:"full"}),w=()=>V.useContext(Z),Y=()=>e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0,left:"50%"}}),e.jsx("div",{style:{padding:"8px 28px",borderRadius:999,background:"#f5f5f5",border:"1.5px solid #bdbdbd",fontSize:13,fontWeight:500,color:"#424242",userSelect:"none"},children:"Start"})]}),J=()=>e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0,left:"50%"}}),e.jsx("div",{style:{padding:"8px 28px",borderRadius:999,background:"#f5f5f5",border:"1.5px solid #bdbdbd",fontSize:13,fontWeight:500,color:"#424242",userSelect:"none"},children:"End"})]}),Q=()=>{const{onClickAddTrigger:t,messages:s}=w();return e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0,left:"50%"}}),e.jsx(E.Tooltip,{title:s.addTriggerTooltip,placement:"top",arrow:!0,children:e.jsxs("div",{onClick:t,role:"button",tabIndex:0,onKeyDown:d=>{d.key==="Enter"&&t()},style:{padding:"10px 24px",borderRadius:8,border:"1.5px dashed #d0d0d0",background:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx(ce.GrTrigger,{size:16}),e.jsx("span",{className:"ff-text-black",style:{fontSize:13},"data-testid":"add-trigger-btn-text",children:s.addTriggerButton})]})}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0,left:"50%"}})]})},pe=({id:t})=>{const{onAddStep:s}=w();return e.jsxs("div",{onClick:()=>s(t),role:"button",tabIndex:0,onKeyDown:d=>{d.key==="Enter"&&s(t)},style:{width:28,height:28,borderRadius:"50%",border:"1.5px solid #9e9e9e",background:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:18,color:"#757575",lineHeight:1,userSelect:"none"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),"+",e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})};function xe(t){return t?t==="END_USER_CREATION"?"New User Registration":t==="END_USER_UPDATION"?"On User Update":t.replace(/[_-]+/g," ").toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):""}function ge(t){const s=typeof t=="string"?t:t.value??"";return s==="SIGNUP_FLOW"?"User Self-Registration":s==="ADMIN_CREATION_FLOW"?"Create User via Admin Portal":s==="SHEDULAR"?"Scheduler":typeof t!="string"&&t.label?t.label:s.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase())}const X=({data:t})=>{const{onClickAddTrigger:s}=w(),{type:d,eventType:a,sources:r,label:o,source:x,previewWorkflow:n,executionStatus:i,infoText:f="This node decides the flow trigger type and configuration."}=t??{},y=m=>{m==null||m.stopPropagation(),s()},g=Array.isArray(r)&&r.length>0,j=!!(o||x),p=d==="scheduler"?"Scheduler Trigger":d==="event"||g||j?"Event Trigger Source":"Select Trigger",c=(()=>{if(d==="scheduler")return e.jsx("span",{children:"Scheduler to be configured"});if(d==="event"||g){const m=o||xe(a);return e.jsxs("div",{children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[e.jsx("span",{style:{fontWeight:600},children:m}),e.jsx("span",{className:"ff-ms-2 ff-text-muted",style:{fontSize:12},children:"via"})]}),e.jsx("div",{className:"ff-d-flex ff-flex-wrap ff-mt-2",style:{gap:4},children:g?r.map((k,b)=>e.jsx(E.Chip,{label:ge(k),variant:"outlined",size:"small",className:"ff-text-dark"},b)):e.jsx("span",{className:"ff-text-muted",style:{fontSize:12},children:"No source selected"})})]})}return j?e.jsxs("div",{className:"ff-d-flex ff-flex-wrap ff-align-items-center",style:{gap:6},children:[o&&e.jsx("span",{style:{fontWeight:600},children:o}),x&&e.jsx(E.Chip,{label:x,variant:"outlined",size:"small"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:y,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&y(m)},style:{cursor:"pointer",color:"#1e88e5"},children:"Click to select a trigger to start your workflow"})})(),N=i?e.jsxs(e.Fragment,{children:[i.status==="success"&&e.jsx(L.FaCheckCircle,{size:16,color:"#1DBF60",style:{marginRight:8}}),i.status==="failed"&&e.jsx(L.FaTimesCircle,{size:16,color:"#f44336",style:{marginRight:8}})]}):e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[!n&&e.jsx("div",{role:"button",tabIndex:0,onClick:y,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&y(m)},className:"ff-me-2",style:{cursor:"pointer",color:"#212121"},"aria-label":"Edit trigger",children:e.jsx(h.MdOutlineModeEdit,{size:16})}),e.jsx(E.Tooltip,{title:e.jsx("div",{children:f}),placement:"right",arrow:!0,children:e.jsx("span",{children:e.jsx(h.MdInfoOutline,{color:"gray",size:16})})})]});return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #a5d6a7",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(76,175,80,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(h.MdInput,{size:16,color:"#388e3c"})}),e.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:p})]}),e.jsx("div",{className:"ff-d-flex ff-align-items-center",children:N})]}),e.jsx("div",{style:{background:"#f5f5f5",fontSize:12,color:"#212121",padding:"10px 6px",margin:"0 6px 10px",borderRadius:6},children:c})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0},id:"1"})]})};function he(t){return t?t==="END_USER_CREATION"?"New User Registration":t==="END_USER_UPDATION"?"On User Update":t.replace(/[_-]+/g," ").replace(/\b\w/g,s=>s.toUpperCase()):""}function ye(t){const s=typeof t=="string"?t:t.value??"";return s==="SIGNUP_FLOW"?"User Self-Registration":s==="ADMIN_CREATION_FLOW"?"Create User via Admin Portal":s==="SHEDULAR"||s==="SCHEDULER"?"Scheduler":typeof t!="string"&&t.label?t.label:s.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase())}const ue=({data:t})=>{const{header:s="Event",title:d,eventType:a,sources:r,executionStatus:o,infoText:x="This event is raised by the system. It cannot be configured."}=t??{},n=d??he(a)??"—";return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #a5d6a7",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(76,175,80,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(h.MdInput,{size:16,color:"#388e3c"})}),e.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:s})]}),e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[(o==null?void 0:o.status)==="success"&&e.jsx(L.FaCheckCircle,{size:16,color:"#1DBF60",style:{marginRight:8}}),(o==null?void 0:o.status)==="failed"&&e.jsx(L.FaTimesCircle,{size:16,color:"#f44336",style:{marginRight:8}}),!o&&e.jsx(E.Tooltip,{title:e.jsx("div",{children:x}),placement:"right",arrow:!0,children:e.jsx("span",{children:e.jsx(h.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsxs("div",{style:{background:"#f5f5f5",fontSize:13,color:"#212121",padding:"10px 12px",margin:"0 6px 10px",borderRadius:6},children:[e.jsx("div",{style:{fontWeight:600},children:n}),Array.isArray(r)&&r.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ff-text-muted",style:{fontSize:12,marginTop:4},children:"via"}),e.jsx("div",{className:"ff-d-flex ff-flex-wrap ff-mt-1",style:{gap:4},children:r.map((i,f)=>e.jsx(E.Chip,{label:ye(i),variant:"outlined",size:"small",className:"ff-text-dark"},f))})]})]})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0},id:"1"})]})},ee=({rail:t,cardWidth:s})=>{const d=s/2;s/2+t.indent;const a="var(--ff-edge-color, #b0bec5)";return e.jsxs("svg",{width:s+t.indent+200,height:t.height,style:{position:"absolute",left:0,top:"100%",pointerEvents:"none",overflow:"visible"},children:[e.jsx("line",{x1:d,y1:0,x2:d,y2:t.height,stroke:a,strokeWidth:1.5}),t.branches.map((r,o)=>{const x=r.y;return e.jsxs("g",{transform:`translate(0, ${x})`,children:[e.jsx("rect",{x:d-5,y:-5,width:10,height:10,fill:"#fff",stroke:a,strokeWidth:1.5,transform:`rotate(45, ${d}, 0)`}),e.jsx("text",{x:d+14,y:4,fontSize:12,fontWeight:500,fill:"var(--ff-text, #212121)",style:{fontFamily:"sans-serif"},children:r.label})]},o)})]})},te=({id:t,data:s})=>{const{onEditNode:d,onDeleteNode:a}=w(),{conditions:r=[],infoText:o="Filter conditions applied to workflow data",_branchRail:x}=s;return e.jsxs("div",{style:{width:350,position:"relative"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #ffe082",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(255,160,0,0.1)"},children:e.jsx(ae.FiFilter,{className:"ff-text-warning",size:16})}),e.jsx("span",{className:"ff-ms-2 ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Filter"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),d(t)},onKeyDown:n=>{n.key==="Enter"&&(n.stopPropagation(),d(t))},children:e.jsx(h.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),a(t)},onKeyDown:n=>{n.key==="Enter"&&(n.stopPropagation(),a(t))},children:e.jsx(h.MdDeleteOutline,{color:"red",size:16})}),e.jsx(E.Tooltip,{title:o,placement:"right",arrow:!0,children:e.jsx("div",{className:"ff-ms-2",children:e.jsx(h.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#fafafa",fontSize:12},children:r.length===0?e.jsx("span",{className:"ff-text-muted",children:"No conditions configured"}):r.map((n,i)=>e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-mb-1",children:[e.jsx("p",{className:"ff-m-0 ff-fw-bold ff-me-1 ff-text-truncate",style:{maxWidth:100},title:n.field,children:n.field}),e.jsx("span",{className:"ff-text-muted",children:n.operator}),e.jsx("p",{className:"ff-text-dark ff-text-truncate ff-mx-1 ff-m-0",title:n.value,children:n.value}),i<r.length-1&&e.jsx("p",{className:"ff-bg-primary ff-text-white ff-fw-bold ff-ms-1 ff-px-1 ff-rounded-1 ff-m-0",children:n.logicalOperator})]},i))})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}}),x&&e.jsx(ee,{rail:x,cardWidth:350})]})},ne=({id:t,data:s})=>{const{onEditNode:d,onDeleteNode:a,nodeRegistry:r,nodeBody:o="full"}=w(),{title:x="Task",descriptorType:n,groupBlocks:i,groups:f,roles:y,groupId:g,roleId:j,infoText:p=""}=s,c=n?r==null?void 0:r.forType(n):void 0,N=c==null?void 0:c.icon,m=u=>u==null?"":typeof u=="string"?u:typeof u=="object"&&"label"in u?String(u.label):String(u),k=u=>Array.isArray(u)?u.map(m).filter(Boolean):u!=null&&u!==""?[m(u)]:[],b=(i==null?void 0:i.flatMap(u=>u.groups??[]))??[...k(f),...k(y),...k(g),...k(j)],P=b.length>0;return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[N&&e.jsx("div",{style:{display:"flex",alignItems:"center"},children:N}),e.jsx("span",{className:"ff-text-dark",style:{fontSize:14,fontWeight:500},children:x})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),d(t)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),d(t))},children:e.jsx(h.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),a(t)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),a(t))},children:e.jsx(h.MdDeleteOutline,{color:"red",size:16})}),p&&e.jsx(E.Tooltip,{title:p,placement:"right",arrow:!0,children:e.jsx("div",{className:"ff-ms-2",children:e.jsx(h.MdInfoOutline,{color:"gray",size:16})})})]})]}),o!=="title-only"&&e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#fafafa",fontSize:12},children:c!=null&&c.renderNode?c.renderNode(s):P?e.jsx("div",{className:"ff-d-flex ff-flex-wrap ff-gap-1",children:b.map((u,T)=>e.jsx("span",{className:"ff-badge ff-bg-dark ff-text-white ff-py-1 ff-px-2 ff-rounded",style:{fontSize:11},title:u,children:u},T))}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},M=5,se=({id:t,data:s})=>{const{onEditNode:d,onDeleteNode:a}=w(),{approvalData:r,isPreview:o=!1,_branchRail:x}=s,n=(r==null?void 0:r.policy)??{},i=n.stages??[],f=i.length,y=i.slice(0,M),g=f-M,j=n.name??n.policyName??"Untitled Policy";return e.jsxs("div",{style:{width:350,position:"relative"},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #ffe082",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(251,192,45,0.2)"},children:e.jsx(h.MdCheckCircle,{style:{color:"#FBC02D"},size:16})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Approval Policy"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[!o&&e.jsx("div",{role:"button",tabIndex:0,style:{cursor:"pointer"},onClick:p=>{p.stopPropagation(),d(t)},onKeyDown:p=>{p.key==="Enter"&&(p.stopPropagation(),d(t))},children:e.jsx(h.MdOutlineModeEdit,{size:16,className:"ff-text-secondary"})}),!o&&e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,style:{cursor:"pointer"},onClick:p=>{p.stopPropagation(),a(t)},onKeyDown:p=>{p.key==="Enter"&&(p.stopPropagation(),a(t))},children:e.jsx(h.MdDeleteOutline,{color:"red",size:16})}),e.jsx(E.Tooltip,{title:"This approval policy determines who must approve a request before the workflow continues.",arrow:!0,placement:"right",children:e.jsx("span",{className:"ff-ms-2 ff-d-inline-flex",children:e.jsx(h.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsxs("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#FCFCFC"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-start ff-align-items-center ff-mb-2",children:[e.jsx("h6",{className:"ff-text-dark ff-mb-0 ff-text-truncate ff-flex-grow-1 ff-me-2",style:{fontSize:13,fontWeight:700},title:j,children:j}),e.jsxs("span",{className:"ff-badge ff-rounded-pill ff-px-2 ff-py-1 ff-flex-shrink-0",style:{background:"#FFF9C4",color:"#616161",fontSize:11,fontWeight:600},children:[f," Stage",f!==1?"s":""]})]}),i.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[y.map((p,c)=>{var T,I,S;const N=((T=p.stageName)==null?void 0:T.trim())||`Stage ${c+1}`,m=Array.isArray(p.userIds)?p.userIds.length:0,k=((I=p.groupName)==null?void 0:I.trim())??"",b=((S=p.roleName)==null?void 0:S.trim())??"",P=m>0||k||b;let u="Not configured";return k?u=`Group: ${k}`:b?u=`Role: ${b}`:m>0&&(u=`${m} approver${m!==1?"s":""}`),e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-rounded-circle ff-d-flex ff-align-items-center ff-justify-content-center ff-flex-shrink-0",style:{width:28,height:28,background:"#FFF9C4",color:"#5D4037",fontSize:12,fontWeight:700},children:c+1}),e.jsxs("div",{className:"ff-flex-grow-1 ff-rounded ff-p-2 ff-d-flex ff-justify-content-between ff-align-items-center ff-border",style:{background:"#FFFDE7",borderColor:"#FEE79A"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#212121"},children:N}),e.jsxs("span",{className:`ff-d-flex ff-align-items-center ff-gap-1 ${P?"ff-text-dark":"ff-text-muted"}`,style:{fontSize:12},children:[e.jsx(h.MdPeople,{size:16,className:"ff-flex-shrink-0",style:{color:P?"#5D4037":"#9E9E9E"}}),u]})]})]},c)}),g>0&&e.jsxs("div",{className:"ff-text-center ff-fw-bold ff-py-2 ff-border ff-rounded",style:{fontSize:11,color:"#1976d2",borderColor:"#FEE79A",background:"#FFFDE7",borderStyle:"dashed",cursor:o?"default":"pointer"},role:o?void 0:"button",tabIndex:o?void 0:0,onClick:p=>{o||(p.stopPropagation(),d(t))},onKeyDown:p=>{o||p.key!=="Enter"||(p.stopPropagation(),d(t))},children:["+ ",g," More Stage",g>1?"s":""]})]}):e.jsx("div",{className:"ff-text-center ff-py-3 ff-rounded ff-border",style:{fontSize:12,color:"#9e9e9e",background:"#FFFDE7",borderColor:"#FEE79A",borderStyle:"dashed"},children:"No stages configured"})]})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}}),x&&e.jsx(ee,{rail:x,cardWidth:350})]})},ie=({id:t,data:s})=>{const{onEditNode:d,onDeleteNode:a}=w(),{duration:r,unit:o}=s,x=r!=null&&o,n=x?`Wait ${r} ${o}`:"Not configured";return e.jsxs("div",{style:{width:350},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(33,150,243,0.1)"},children:e.jsx(h.MdSchedule,{size:16,color:"#1976d2"})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Delay"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:i=>{i.stopPropagation(),d(t)},onKeyDown:i=>{i.key==="Enter"&&(i.stopPropagation(),d(t))},children:e.jsx(h.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:i=>{i.stopPropagation(),a(t)},onKeyDown:i=>{i.key==="Enter"&&(i.stopPropagation(),a(t))},children:e.jsx(h.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:e.jsx("span",{className:x?"ff-text-dark ff-fw-medium":"ff-text-muted",children:n})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},W={email:{label:"Email",bg:"#e3f2fd",color:"#1565c0",iconType:h.MdEmail},slack:{label:"Slack",bg:"#e8f5e9",color:"#2e7d32",iconType:h.MdNotifications},teams:{label:"MS Teams",bg:"#ede7f6",color:"#4527a0",iconType:h.MdNotifications},sms:{label:"SMS",bg:"#fce4ec",color:"#880e4f",iconType:h.MdSms},"in-app":{label:"In-App",bg:"#fff3e0",color:"#e65100",iconType:h.MdNotifications},webhook:{label:"Webhook",bg:"#f3e5f5",color:"#6a1b9a",iconType:h.MdWebhook}},me={label:"Notification",bg:"rgba(156,39,176,0.1)",color:"#7b1fa2",iconType:h.MdNotifications};function je(t){var s;switch(t.channel){case"email":return((s=t.emailTo)==null?void 0:s.join(", "))??t.recipient??null;case"slack":return t.slackChannel??null;case"teams":return t.teamsMessage?"Message configured":null;case"sms":return t.smsTo??null;case"in-app":return t.inAppRecipient??null;case"webhook":return t.webhookUrl??null;default:return t.recipient??null}}function be(t){switch(t.channel){case"email":return t.emailSubject??t.subject??null;case"slack":{const s=t.slackMessage;return s?s.length>60?`${s.slice(0,60)}…`:s:null}case"in-app":return t.inAppTitle??null;default:return t.subject??null}}const oe=({id:t,data:s})=>{const{onEditNode:d,onDeleteNode:a}=w(),r=s,o=r.channel&&W[r.channel]?W[r.channel]:me,x=je(r),n=be(r),i=!!(r.channel&&x),f=o.iconType;return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:o.bg},children:e.jsx(f,{size:16,color:o.color})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:r.channel?`${o.label} Notification`:"Notification"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:y=>{y.stopPropagation(),d(t)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.stopPropagation(),d(t))},children:e.jsx(h.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:y=>{y.stopPropagation(),a(t)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.stopPropagation(),a(t))},children:e.jsx(h.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#fafafa",fontSize:12},children:i?e.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:10,background:o.bg,color:o.color,fontWeight:600,flexShrink:0},children:o.label}),e.jsx("span",{className:"ff-text-dark ff-text-truncate",style:{maxWidth:220},children:x})]}),n&&e.jsx("span",{className:"ff-text-muted ff-text-truncate",style:{maxWidth:280},children:n})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},F={"api-key":"API Key",hmac:"HMAC"},le=({data:t})=>{const{onClickAddTrigger:s}=w(),{label:d="Webhook Trigger",endpointUrl:a,authMethod:r,source:o}=t,x=i=>{i.stopPropagation(),s()},n=i=>{i.stopPropagation(),a&&navigator.clipboard.writeText(a).catch(()=>{})};return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #90caf9",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(33,150,243,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(h.MdWebhook,{size:16,color:"#1565c0"})}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#212121"},children:"Webhook Trigger"})]}),e.jsx("div",{role:"button",tabIndex:0,onClick:x,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&x(i)},className:"ff-d-flex ff-align-items-center",style:{paddingRight:4,cursor:"pointer"},children:e.jsx(h.MdOutlineModeEdit,{size:16,color:"#555"})})]}),e.jsxs("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#e3f2fd",border:"1px solid #90caf9"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-flex-wrap ff-gap-2 ff-mb-1",children:[e.jsx("span",{style:{fontSize:12,color:"#1565c0",fontWeight:600},children:d}),o&&e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:11,background:"#fff",border:"1px solid #90caf9",color:"#1565c0"},children:o}),r&&r!=="none"&&F[r]&&e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:10,background:"#1565c0",color:"#fff",fontWeight:600},children:F[r]})]}),a&&e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-1",style:{marginTop:4},children:[e.jsx("span",{style:{fontSize:10,color:"#1565c0",fontFamily:"monospace",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),e.jsx(E.Tooltip,{title:"Copy URL",placement:"top",arrow:!0,children:e.jsx("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&n(i)},style:{cursor:"pointer",flexShrink:0},children:e.jsx(h.MdContentCopy,{size:12,color:"#1565c0"})})})]})]})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},re=({id:t,data:s})=>{var j;const{onEditNode:d,onDeleteNode:a,nodeRegistry:r}=w(),{method:o,url:x,descriptorType:n}=s,i=n?(j=r==null?void 0:r.forType(n))==null?void 0:j.icon:e.jsx(h.MdHttp,{size:16,color:"#546e7a"}),f=!!(o&&x),y=(o==null?void 0:o.toUpperCase())??"",g=C.HTTP_METHOD_STYLE[y]??null;return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,display:"flex",alignItems:"center",justifyContent:"center"},children:i}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"REST API Call"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:p=>{p.stopPropagation(),d(t)},onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.stopPropagation(),d(t))},children:e.jsx(h.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:p=>{p.stopPropagation(),a(t)},onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.stopPropagation(),a(t))},children:e.jsx(h.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#fafafa",fontSize:12},children:f?e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[g&&e.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:4,background:g.bg,color:g.color,flexShrink:0},children:y}),e.jsx("span",{className:"ff-text-dark ff-text-truncate",style:{fontFamily:"monospace",fontSize:11},title:x,children:x})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},Ne={eq:"=",neq:"≠",gt:">",gte:"≥",lt:"<",lte:"≤",contains:"contains",startsWith:"starts with",endsWith:"ends with",isEmpty:"is empty",isNotEmpty:"is not empty"},ke=({id:t,data:s})=>{const{onEditNode:d,onDeleteNode:a}=w(),{title:r="Condition Branch",branchConfigs:o=[],defaultBranch:x}=s,n=o.length>0;return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b39ddb",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,borderRadius:6,background:"rgba(103,58,183,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(h.MdCallSplit,{size:16,color:"#512da8"})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:r})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:i=>{i.stopPropagation(),d(t)},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.stopPropagation(),d(t))},children:e.jsx(h.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:i=>{i.stopPropagation(),a(t)},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.stopPropagation(),a(t))},children:e.jsx(h.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#fafafa",fontSize:12},children:n?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.map((i,f)=>{var p,c;const y=C.BRANCH_PALETTE[f%C.BRANCH_PALETTE.length],g=(p=i.conditions)==null?void 0:p[0],j=(((c=i.conditions)==null?void 0:c.length)??0)-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:y.bg,color:y.color,flexShrink:0},children:i.label||i.key}),g?e.jsxs("span",{style:{fontSize:11,color:"#616161",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[g.field," ",Ne[g.operator]??g.operator,g.value?` ${g.value}`:"",j>0?` +${j} more`:""]}):e.jsx("span",{style:{fontSize:11,color:"#9e9e9e"},children:"No conditions yet"})]},i.key)}),x&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:"#f5f5f5",color:"#757575",flexShrink:0},children:"Default"}),e.jsx("span",{style:{fontSize:11,color:"#9e9e9e"},children:"fallback path"})]})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured — click edit to add branches"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},ve=({id:t,data:s})=>{var p;const{onEditNode:d,onDeleteNode:a,nodeRegistry:r}=w(),{title:o="Sub-Workflow",workflowId:x,workflowLabel:n,descriptorType:i,onPreview:f}=s,y=i?(p=r==null?void 0:r.forType(i))==null?void 0:p.icon:e.jsx(h.MdAccountTree,{size:16,color:"#00695c"}),g=!!x,j=c=>{c.stopPropagation(),x&&f&&f(x)};return e.jsxs("div",{style:{width:C.NODE_WIDTH},children:[e.jsx(l.Handle,{type:"target",position:l.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #80cbc4",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,borderRadius:6,background:"rgba(0,137,123,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:y}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:o})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),d(t)},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.stopPropagation(),d(t))},children:e.jsx(h.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),a(t)},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.stopPropagation(),a(t))},children:e.jsx(h.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:g?"#e0f2f1":"#fafafa",fontSize:12,border:g?"1px solid #b2dfdb":"none"},children:g?e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-between",children:[e.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-1",children:[e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#00695c"},children:n||x}),e.jsxs("span",{style:{fontSize:10,color:"#80cbc4",fontFamily:"monospace"},children:["ID: ",x]})]}),f&&e.jsxs("div",{role:"button",tabIndex:0,onClick:j,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&j(c)},style:{cursor:"pointer",display:"flex",alignItems:"center",gap:3,fontSize:11,color:"#00897b"},children:[e.jsx(h.MdOpenInNew,{size:13}),"Preview"]})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured — select a workflow"})})]}),e.jsx(l.Handle,{type:"source",position:l.Position.Bottom,style:{opacity:0}})]})},we={startNode:Y,endNode:J,addTriggerNode:Q,addStepNode:pe,triggerNode:X,eventNode:ue,filterNode:te,actionNode:ne,approvalNode:se,delayNode:ie,notificationNode:oe,webhookTriggerNode:le,restApiNode:re,conditionBranchNode:ke,subWorkflowNode:ve},Se=11.5,H=2,D=6,$=40,O=20,B=4,Ee=({id:t,sourceX:s,sourceY:d,targetX:a,targetY:r,sourcePosition:o,targetPosition:x,source:n,target:i,data:f})=>{const[y,g,j]=l.getStraightPath({sourceX:s,sourceY:d,targetX:a,targetY:r}),p=f==null?void 0:f.label,c=p==="Pass",N=c||p==="Fail",m=s+(a-s)/3,k=d+(r-d)/3,b=s+2*(a-s)/3,P=d+2*(r-d)/3,u=f==null?void 0:f.onAddStepClick,T=z=>{if(z.stopPropagation(),typeof u!="function")return;const de={edgeId:t,nodeId:n,sourceNodeId:n,targetNodeId:i,position:"between",referenceNodeId:n,referenceNodeType:f==null?void 0:f.referenceNodeType,stepVisibility:f==null?void 0:f.stepVisibility};u(n,de)},I=z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),T(z))},S=()=>e.jsxs(e.Fragment,{children:[e.jsxs("g",{className:"plus-icon-container",children:[e.jsx("circle",{r:Se,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-D,x2:0,y2:D,strokeWidth:H,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-D,y1:0,x2:D,y2:0,strokeWidth:H,strokeLinecap:"round",className:"plus-line"})]}),e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(18, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]}),v=u?{onClick:T,onKeyDown:I,role:"button",tabIndex:0,style:{cursor:"pointer",pointerEvents:"all"}}:{style:{cursor:"default",pointerEvents:"all"}};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(l.BaseEdge,{id:t,path:y}),N?e.jsxs(e.Fragment,{children:[e.jsxs("g",{transform:`translate(${m}, ${k})`,children:[e.jsx("rect",{x:-$/2,y:-O/2,width:$,height:O,rx:B,ry:B,fill:c?"#ADE6C5":"#FDBFBF"}),e.jsx("text",{textAnchor:"middle",dominantBaseline:"central",fill:c?"#1DBF60":"#C50000",style:{fontSize:12,fontWeight:500},children:p})]}),e.jsx("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${b}, ${P})`,"data-testid":"plus-node-icon",...v,children:e.jsx(S,{})})]}):e.jsx("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${g}, ${j})`,"data-testid":"plus-node-icon",...v,children:e.jsx(S,{})})]})},Te=11.5,_=2,A=6,Pe=({id:t,sourceX:s,sourceY:d,targetX:a,targetY:r,source:o,target:x,data:n})=>{const[i,f,y]=l.getStraightPath({sourceX:s,sourceY:d,targetX:a,targetY:r}),g=n==null?void 0:n.onAddStepClick,j=c=>{c.stopPropagation(),typeof g=="function"&&g(o,{edgeId:t,nodeId:o,sourceNodeId:o,targetNodeId:x,position:"between",referenceNodeId:o,referenceNodeType:n==null?void 0:n.referenceNodeType,stepVisibility:n==null?void 0:n.stepVisibility,filterId:n==null?void 0:n.filterId,branch:n==null?void 0:n.branch})},p=c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),j(c))};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(l.BaseEdge,{id:t,path:i,style:{stroke:"#b0bec5"}}),e.jsxs("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${f}, ${y})`,style:{cursor:g?"pointer":"default",pointerEvents:"all",outline:"none"},onClick:g?j:void 0,onKeyDown:g?p:void 0,role:g?"button":void 0,tabIndex:g?0:void 0,"data-testid":"plus-node-icon",children:[e.jsx("circle",{r:Te,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-A,x2:0,y2:A,strokeWidth:_,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-A,y1:0,x2:A,y2:0,strokeWidth:_,strokeLinecap:"round",className:"plus-line"}),e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(18, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]})]})},Ce=({id:t,sourceX:s,sourceY:d,targetX:a,targetY:r})=>{const[o]=l.getStraightPath({sourceX:s,sourceY:d,targetX:a,targetY:r});return e.jsx(l.BaseEdge,{id:t,path:o,style:{stroke:"#b0bec5"}})},Ie=11.5,K=2,R=6,ze=-24,U=40,q=20,G=4,De=({id:t,sourceX:s,sourceY:d,targetX:a,targetY:r,source:o,target:x,data:n})=>{const[i,f,y]=l.getStraightPath({sourceX:s,sourceY:d,targetX:a,targetY:r}),g=n==null?void 0:n.label,j=g==="Pass",p=j||g==="Fail",c=n==null?void 0:n.onAddStepClick,N=(n==null?void 0:n.showPlus)!==!1&&!!c,m=b=>{b.stopPropagation(),typeof c=="function"&&c(o,{edgeId:t,nodeId:o,sourceNodeId:o,targetNodeId:x,position:"between",referenceNodeId:o,referenceNodeType:n==null?void 0:n.referenceNodeType,stepVisibility:n==null?void 0:n.stepVisibility})},k=b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),m(b))};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(l.BaseEdge,{id:t,path:i,style:{stroke:"#b0bec5"}}),e.jsxs("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${f}, ${y})`,style:{cursor:c?"pointer":"default",pointerEvents:"all",outline:"none"},onClick:c?m:void 0,onKeyDown:c?k:void 0,role:c?"button":void 0,tabIndex:c?0:void 0,children:[p&&e.jsxs("g",{transform:`translate(0, ${N?ze:0})`,children:[e.jsx("rect",{x:-U/2,y:-q/2,width:U,height:q,rx:G,ry:G,fill:j?"#ADE6C5":"#FDBFBF"}),e.jsx("text",{textAnchor:"middle",dominantBaseline:"central",fill:j?"#1DBF60":"#C50000",style:{fontSize:12,fontWeight:500},children:g})]}),N&&e.jsxs("g",{className:"plus-icon-container",children:[e.jsx("circle",{r:Ie,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-R,x2:0,y2:R,strokeWidth:K,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-R,y1:0,x2:R,y2:0,strokeWidth:K,strokeLinecap:"round",className:"plus-line"})]}),N&&e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(22, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]})]})},Ae=({id:t,source:s,target:d,sourceX:a,sourceY:r,targetX:o,targetY:x,style:n={},markerEnd:i,data:f})=>{const y=(f==null?void 0:f.verticalRouting)??!1,g=30,j=y?(()=>{const v=x-g;return`M ${a},${v} L ${o},${v} L ${o},${x}`})():(()=>{const v=r+30;return`M ${a},${r} L ${a},${v} L ${o},${v} L ${o},${x}`})(),p=n.stroke||"#d1d5db",c=f==null?void 0:f.label,N=(f==null?void 0:f.isFirst)??!1,m=f==null?void 0:f.onAddStepClick,k=y?x-g:r+30,b=a+(o-a)*(y?.25:.35),P=a+(o-a)*(y?.65:.7),u=k,T=v=>{v.stopPropagation(),m&&m(s,{edgeId:t,nodeId:s,sourceNodeId:s,targetNodeId:d,position:"between",referenceNodeId:s,filterId:f==null?void 0:f.filterId,branch:f==null?void 0:f.branch})},I=11.5,S=6;return e.jsxs("g",{children:[e.jsx("path",{id:t,d:j,fill:"none",stroke:p,strokeWidth:1.5,markerEnd:i}),c&&!y&&e.jsx("g",{transform:`translate(${b}, ${u})`,children:(()=>{const v=Math.max(44,c.length*7+20);return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:-v/2,y:-11,width:v,height:22,rx:11,fill:N?"#e8f5e9":"#ffebee",stroke:N?"#81c784":"#e57373",strokeWidth:1}),e.jsx("text",{x:0,y:4,textAnchor:"middle",fontSize:10,fontWeight:600,fill:N?"#2e7d32":"#c62828",style:{fontFamily:"sans-serif",pointerEvents:"none"},children:c})]})})()}),m&&e.jsxs("g",{transform:`translate(${P}, ${u})`,onClick:T,style:{cursor:"pointer",pointerEvents:"all"},className:"nodrag nopan edge-plus-svg",children:[e.jsx("circle",{r:I,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-S,x2:0,y2:S,strokeWidth:2,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-S,y1:0,x2:S,y2:0,strokeWidth:2,strokeLinecap:"round",className:"plus-line"})]})]})};exports.ActionNode=ne;exports.AddTriggerNode=Q;exports.ApprovalNode=se;exports.DelayNode=ie;exports.EdgeWithPlusLabel=Ee;exports.EndNode=J;exports.FilterNode=te;exports.GatewayBranchEdge=Ae;exports.LabelPlusEdge=De;exports.NotificationNode=oe;exports.PlainEdge=Ce;exports.PlusEdge=Pe;exports.RestApiNode=re;exports.StartNode=Y;exports.TriggerNode=X;exports.WebhookTriggerNode=le;exports.WorkflowCanvasContext=Z;exports.builtInNodeTypes=we;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo as P, useState as T, useRef as M, useEffect as de, useCallback as te } from "react";
|
|
2
2
|
import { useFormik as ke } from "formik";
|
|
3
|
-
import { k as pe, C as Ne, g as oe, a as ue, b as ie, v as se, E as ze, d as Te, V as we } from "./index-
|
|
3
|
+
import { k as pe, C as Ne, g as oe, a as ue, b as ie, v as se, E as ze, d as Te, V as we } from "./index-BU09HbVh.js";
|
|
4
4
|
import { jsxs as t, Fragment as q, jsx as e } from "react/jsx-runtime";
|
|
5
5
|
import { Box as n, Collapse as Ie, Tooltip as A, Dialog as he, Typography as S, IconButton as Y, Stepper as Fe, Step as Oe, StepLabel as Re, Drawer as Ee, Chip as We, Divider as Ae } from "@mui/material";
|
|
6
6
|
import { MdCheck as G, MdClose as _, MdAdd as J, MdArrowBack as fe, MdEdit as De, MdDeleteOutline as Pe, MdSettings as be, MdArrowForward as Me } from "react-icons/md";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const h=require("react"),re=require("formik"),N=require("./index-DNZlQp9z.js"),e=require("react/jsx-runtime"),o=require("@mui/material"),S=require("react-icons/md"),ie=require("react-icons/fa6");function ae({schema:l,initialValues:s,onSubmit:d,showErrorsImmediately:a=!1}){const r=l.fields??[],t=h.useMemo(()=>N.buildValidationSchema(r),[r]),p=h.useMemo(()=>{if(a)return r.reduce((u,v)=>{const g=N.resolveFieldKey(v);return g&&(u[g]=!0),u},{})},[r,a]),[i,c]=h.useState({}),[m,y]=h.useState({}),B=h.useRef(s);h.useEffect(()=>{B.current!==s&&(B.current=s,c({}),y({}))},[s]);const x=re.useFormik({initialValues:s,validationSchema:t,initialTouched:p,validateOnMount:a,validateOnChange:!0,validateOnBlur:!0,enableReinitialize:!0,onSubmit:async u=>{const v=N.buildEvaluationPayload({values:u,conditionConfig:m});await d(u,v)}}),n=h.useCallback(()=>{x.submitForm()},[x]),f=h.useCallback(u=>{x.resetForm(u?{values:u}:void 0),c({}),y({})},[x]);return{values:x.values,errors:x.errors,isValid:x.isValid,isDirty:x.dirty,isSubmitting:x.isSubmitting,formulaConfig:i,conditionConfig:m,submit:n,reset:f,setFieldValue:x.setFieldValue,_schema:l,_formik:x,_formulaConfig:i,_onFormulaConfigChange:c,_conditionConfig:m,_onConditionConfigChange:y}}const Z=N.FlowForgeRegistry.getTypeOptions(),j="form-control font-14",b="text-14 text-dark fw-medium mb-1 align-items-center d-flex gap-1",F={fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:.6,marginBottom:8,display:"block"},ce=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"url",label:"URL"},{value:"password",label:"Password"},{value:"select",label:"Select"},{value:"object",label:"Object (sub-fields)"},{value:"array",label:"Array (nested)"}],de=[{value:3,label:"1/4"},{value:4,label:"1/3"},{value:6,label:"1/2"},{value:8,label:"2/3"},{value:12,label:"Full"}];function xe({value:l,onChange:s}){const d=l??12;return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:"Column width"}),e.jsx(o.Box,{sx:{display:"flex",gap:.5},children:de.map(a=>e.jsx(o.Tooltip,{title:`colSpan: ${a.value}`,placement:"top",children:e.jsx(o.Box,{component:"button",onClick:()=>s(a.value),sx:{flex:1,border:"1px solid",borderColor:d===a.value?"#6366f1":"#dee2e6",borderRadius:"6px",cursor:"pointer",bgcolor:d===a.value?"#eef2ff":"#fff",color:d===a.value?"#6366f1":"#6c757d",fontSize:11,fontWeight:600,py:.6,px:0,"&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:a.label})},a.value))}),e.jsx(o.Box,{sx:{display:"flex",gap:"3px",mt:.75},children:Array.from({length:12}).map((a,r)=>e.jsx(o.Box,{sx:{flex:1,height:4,borderRadius:"2px",bgcolor:r<d?"#6366f1":"#e2e8f0",transition:"background 0.12s"}},r))})]})}function Q({options:l=[],onChange:s}){function d(a,r,t){s(l.map((p,i)=>i===a?{...p,[r]:t}:p))}return e.jsxs(o.Box,{children:[e.jsxs("span",{className:b,children:["Options ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:l.map((a,r)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{className:j,style:{flex:1},placeholder:"Label",value:a.label,onChange:t=>d(r,"label",t.target.value)}),e.jsx("input",{className:j,style:{flex:1},placeholder:"Value",value:a.value,onChange:t=>d(r,"value",t.target.value)}),e.jsx(o.Box,{component:"button",onClick:()=>s(l.filter((t,p)=>p!==r)),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]},r))}),e.jsxs(o.Box,{component:"button",onClick:()=>s([...l,{label:"",value:""}]),sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:[e.jsx(S.MdAdd,{size:13})," Add option"]})]})}const ee=[{value:"operator",label:"Operator (predefined)"},{value:"select",label:"Select"},{value:"text",label:"Text"}];function pe({col:l,onChange:s,onDelete:d}){const a=l.type==="select",r=l.type==="operator";return e.jsxs(o.Box,{sx:{border:"1px solid #e2e8f0",borderRadius:"7px",p:1.25,bgcolor:"#fff",display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(o.Box,{sx:{fontSize:10,fontWeight:700,px:.75,py:.2,borderRadius:"4px",bgcolor:r?"#fef9c3":"#eef2ff",color:r?"#92400e":"#6366f1",flexShrink:0},children:r?"OPERATOR":l.type.toUpperCase()}),e.jsx(o.Box,{sx:{fontSize:12,fontWeight:600,color:"#0f172a",flex:1},children:l.label||l.id||"Unnamed"}),e.jsx(o.Box,{component:"button",onClick:d,sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Column type"}),e.jsx("select",{value:l.type,onChange:t=>s({...l,type:t.target.value,options:void 0}),className:j,style:{cursor:"pointer"},children:ee.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Column key ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:`${j} ${l.id?"":"border-danger"}`,value:l.id,onChange:t=>s({...l,id:t.target.value}),placeholder:"e.g. field, operator, value"}),!l.id&&e.jsx("span",{style:{fontSize:10,color:"#dc3545"},children:"Required — used as data key"})]})]}),!r&&e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Label"}),e.jsx("input",{className:j,value:l.label??"",onChange:t=>s({...l,label:t.target.value||void 0}),placeholder:"Column label"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Placeholder"}),e.jsx("input",{className:j,value:l.placeholder??"",onChange:t=>s({...l,placeholder:t.target.value||void 0}),placeholder:"Hint…"})]})]}),a&&e.jsx(Q,{options:l.options??[],onChange:t=>s({...l,options:t})}),r&&e.jsx(o.Box,{sx:{bgcolor:"#fefce8",border:"1px solid #fef08a",borderRadius:"6px",px:1.25,py:.75},children:e.jsx(o.Box,{sx:{fontSize:11,color:"#78350f"},children:"Predefined: equals, not equals, contains, starts with, ends with, is present, is not present, greater than, less than…"})}),!r&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:`formula-${l.id}`,checked:!!l.formula,onChange:t=>s({...l,formula:t.target.checked||void 0}),style:{cursor:"pointer",width:14,height:14}}),e.jsx("label",{htmlFor:`formula-${l.id}`,className:b,style:{margin:0,cursor:"pointer"},children:"Formula input (chip editor)"})]})]})}function ue({condition:l,onChange:s}){const d=!!l;function a(){s(d?void 0:{fields:[]})}function r(i){if(!l)return;const c=i==="operator"?"operator":l.fields.filter(m=>m.type!=="operator").length===0?"field":"value";s({...l,fields:[...l.fields,{id:c,type:i}]})}function t(i,c){if(!l)return;const m=[...l.fields];m[i]=c,s({...l,fields:m})}function p(i){l&&s({...l,fields:l.fields.filter((c,m)=>m!==i)})}return e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:d?1.25:0},children:[e.jsx("input",{type:"checkbox",id:"enable-condition",checked:d,onChange:a,style:{cursor:"pointer",width:14,height:14}}),e.jsx("span",{style:{...F,margin:0,color:d?"#6366f1":"#94a3b8"},children:"Condition row"})]}),d&&l&&e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[l.fields.map((i,c)=>e.jsx(pe,{col:i,onChange:m=>t(c,m),onDelete:()=>p(c)},c)),e.jsx(o.Box,{sx:{display:"flex",gap:.5},children:ee.map(i=>e.jsxs(o.Box,{component:"button",onClick:()=>r(i.value),sx:{flex:1,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,py:.5,borderRadius:"6px",color:i.value==="operator"?"#92400e":"#6366f1","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:["+ ",i.value==="operator"?"Operator":i.label.split(" ")[0]]},i.value))}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,flexWrap:"wrap"},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:"allow-groups",checked:!!l.allowGroups,onChange:i=>s({...l,allowGroups:i.target.checked||void 0}),style:{cursor:"pointer",width:14,height:14}}),e.jsx("label",{htmlFor:"allow-groups",className:b,style:{margin:0,cursor:"pointer"},children:"Allow nested groups"})]}),l.allowGroups&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("label",{className:b,style:{margin:0},children:"Max depth"}),e.jsx("input",{type:"number",min:1,max:5,className:j,style:{width:60,textAlign:"center"},value:l.maxGroupDepth??"",onChange:i=>s({...l,maxGroupDepth:i.target.value?Number(i.target.value):void 0}),placeholder:"∞"})]})]})]})]})}function E({id:l,label:s,checked:d,onChange:a}){return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:l,checked:d,onChange:r=>a(r.target.checked),style:{cursor:"pointer",width:14,height:14,flexShrink:0}}),e.jsx("label",{htmlFor:l,className:b,style:{margin:0,cursor:"pointer"},children:s})]})}function he({views:l=[],onChange:s}){function d(r,t,p){s(l.map((i,c)=>c===r?{...i,[t]:p}:i))}function a(){const r=`tab${l.length+1}`;s([...l,{id:r,label:`Tab ${l.length+1}`}])}return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:"Views"}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:l.map((r,t)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{className:j,style:{flex:1},placeholder:"Label",value:r.label,onChange:p=>d(t,"label",p.target.value)}),e.jsx("input",{className:j,style:{flex:1},placeholder:"ID (no spaces)",value:r.id,onChange:p=>d(t,"id",p.target.value.replace(/\s/g,"_"))}),e.jsx(o.Box,{component:"button",onClick:()=>s(l.filter((p,i)=>i!==t)),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]},t))}),e.jsxs(o.Box,{component:"button",onClick:a,sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:[e.jsx(S.MdAdd,{size:13})," Add view"]})]})}function _({label:l,value:s,options:d,onChange:a}){return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:l}),e.jsx(o.Box,{sx:{display:"flex",border:"1px solid #dee2e6",borderRadius:"7px",overflow:"hidden"},children:d.map(r=>e.jsx(o.Box,{component:"button",onClick:()=>a(r.value),sx:{flex:1,border:"none",borderRight:"1px solid #dee2e6",cursor:"pointer",fontSize:12,fontWeight:600,py:.6,bgcolor:s===r.value?"#eef2ff":"#fff",color:s===r.value?"#6366f1":"#6c757d","&:last-child":{borderRight:"none"},"&:hover":{bgcolor:"#f5f3ff"}},children:r.label},r.value))})]})}function le({field:l,onChange:s,onSave:d,onCancel:a,noFooter:r}){const[t,p]=h.useState(!1),i=l.id??l.name??"",c=l,m=l.type==="select"||l.type==="descriptive-select"||l.type==="radio-group",y=N.FlowForgeRegistry.get(l.type),B=y==null?void 0:y.configSchema;function x(n,f){s({...l,[n]:f})}return e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{sx:{flex:1,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(o.Box,{children:[e.jsx("span",{style:F,children:"Required"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Type"}),e.jsx("select",{value:l.type,onChange:n=>x("type",n.target.value),className:j,style:{cursor:"pointer"},children:Z.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:l.type==="tabs"?"1fr":"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Field ID ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:j,value:l.id??l.name??"",onChange:n=>x("id",n.target.value),placeholder:"e.g. email"})]}),l.type!=="tabs"&&e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Label ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:j,value:l.label??"",onChange:n=>x("label",n.target.value),placeholder:"Display label"})]})]}),l.type!=="tabs"&&e.jsx(xe,{value:l.colSpan,onChange:n=>x("colSpan",n===12?void 0:n)})]})]}),B&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx("span",{style:F,children:"Specific Settings"}),e.jsx(N.FlowForm,{schema:{layout:"flat",compact:!0,fields:B.fields},initialValues:l,onValuesChange:n=>s({...l,...n}),onSubmit:()=>{}})]}),l.type==="tabs"&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5,display:"flex",flexDirection:"column",gap:1.5},children:[e.jsx("span",{style:F,children:"Content"}),e.jsx(he,{views:(c.tabs??[]).map(n=>({id:n.id,label:n.label})),onChange:n=>{const f=c.tabs??[],u=n.map(v=>{const g=f.find(w=>w.id===v.id);return g?{...g,...v}:{...v,fields:[]}});s({...l,tabs:u})}}),e.jsx("span",{style:{...F,marginTop:4},children:"Interaction"}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Disabled"}),e.jsx("input",{className:j,value:c.disabledExpr??"",onChange:n=>s({...l,disabledExpr:n.target.value||void 0}),placeholder:"false"})]}),e.jsx("span",{style:{...F,marginTop:4},children:"Appearance"}),e.jsx(_,{label:"Alignment",value:c.alignment??"left",options:[{value:"left",label:"|←"},{value:"center-left",label:"←|"},{value:"center",label:"|·|"},{value:"center-right",label:"|→"},{value:"right",label:"→|"}],onChange:n=>s({...l,alignment:n})}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Hidden"}),e.jsx("input",{className:j,value:c.hiddenExpr??"",onChange:n=>s({...l,hiddenExpr:n.target.value||void 0}),placeholder:"false"})]}),e.jsx(_,{label:"Variant",value:c.variant??"line",options:[{value:"pill",label:"Pill"},{value:"line",label:"Line"}],onChange:n=>s({...l,variant:n})}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Active color"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.activeColor??"#6366f1",onChange:n=>s({...l,activeColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.activeColor??"",onChange:n=>s({...l,activeColor:n.target.value||void 0}),placeholder:"#6366f1",style:{flex:1}})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Active text"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.activeTextColor??"#ffffff",onChange:n=>s({...l,activeTextColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.activeTextColor??"",onChange:n=>s({...l,activeTextColor:n.target.value||void 0}),placeholder:"auto",style:{flex:1}})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Inactive text"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.inactiveTextColor??"#64748b",onChange:n=>s({...l,inactiveTextColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.inactiveTextColor??"",onChange:n=>s({...l,inactiveTextColor:n.target.value||void 0}),placeholder:"#64748b",style:{flex:1}})]})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Styles"}),e.jsx("input",{className:j,value:c.styles??"",onChange:n=>s({...l,styles:n.target.value||void 0}),placeholder:"None"})]}),e.jsx("span",{style:{...F,marginTop:4},children:"Spacing"}),e.jsx(_,{label:"Height",value:c.height??"auto",options:[{value:"auto",label:"Auto"},{value:"fixed",label:"Fixed"}],onChange:n=>s({...l,height:n})}),e.jsx(_,{label:"Margin",value:c.margin??"normal",options:[{value:"normal",label:"Normal"},{value:"none",label:"None"}],onChange:n=>s({...l,margin:n})})]}),m&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx("span",{style:F,children:"Options"}),e.jsx(Q,{options:c.options??[],onChange:n=>s({...l,options:n})})]}),l.type==="array"&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5,display:"flex",flexDirection:"column",gap:1},children:[e.jsx("span",{style:F,children:"Array settings"}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item type"}),e.jsx("select",{className:j,style:{cursor:"pointer"},value:c.itemType??"text",onChange:n=>s({...l,itemType:n.target.value}),children:ce.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item label"}),e.jsx("input",{className:j,value:c.itemLabel??"",onChange:n=>s({...l,itemLabel:n.target.value||void 0}),placeholder:'e.g. "Member"'})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Add button label"}),e.jsx("input",{className:j,value:c.addLabel??"",onChange:n=>s({...l,addLabel:n.target.value||void 0}),placeholder:"Add item"})]})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Min items"}),e.jsx("input",{type:"number",min:0,className:j,value:c.minItems??"",onChange:n=>s({...l,minItems:n.target.value?Number(n.target.value):void 0}),placeholder:"0"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Max items"}),e.jsx("input",{type:"number",min:1,className:j,value:c.maxItems??"",onChange:n=>s({...l,maxItems:n.target.value?Number(n.target.value):void 0}),placeholder:"∞"})]})]}),!["object","array","select"].includes(c.itemType??"text")&&e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item placeholder"}),e.jsx("input",{className:j,value:c.itemPlaceholder??"",onChange:n=>s({...l,itemPlaceholder:n.target.value||void 0}),placeholder:"Enter value…"})]})]}),e.jsx(ue,{condition:l.condition,onChange:n=>s({...l,condition:n})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx(o.Box,{component:"button",onClick:()=>p(n=>!n),sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:.5,p:0,mb:t?1.25:0},children:e.jsxs("span",{style:{...F,margin:0,color:t?"#6366f1":"#94a3b8"},children:[t?"▾":"▸"," Optional settings"]})}),e.jsx(o.Collapse,{in:t,children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Placeholder"}),e.jsx("input",{className:j,value:l.placeholder??"",onChange:n=>x("placeholder",n.target.value||void 0),placeholder:"Hint text…"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Helper text"}),e.jsx("input",{className:j,value:l.helperText??"",onChange:n=>x("helperText",n.target.value||void 0),placeholder:"Description…"})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Info tooltip"}),e.jsx("input",{className:j,value:l.info??"",onChange:n=>x("info",n.target.value||void 0),placeholder:"Shown in ℹ tooltip"})]}),e.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5},children:[e.jsx(E,{id:`${i}-req`,label:"Required",checked:!!l.required,onChange:n=>x("required",n||void 0)}),e.jsx(E,{id:`${i}-dis`,label:"Disabled",checked:!!l.disabled,onChange:n=>x("disabled",n||void 0)}),e.jsx(E,{id:`${i}-hid`,label:"Hidden",checked:!!l.hidden,onChange:n=>x("hidden",n||void 0)}),e.jsx(E,{id:`${i}-opt`,label:"Show optional",checked:!!l.showOptional,onChange:n=>x("showOptional",n||void 0)}),e.jsx(E,{id:`${i}-div`,label:"Divider after",checked:!!l.dividerAfter,onChange:n=>x("dividerAfter",n||void 0)}),e.jsx(E,{id:`${i}-frm`,label:"Formula input",checked:!!l.formula,onChange:n=>x("formula",n||void 0)})]})]})})]})]}),!r&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",gap:1,justifyContent:"flex-end",bgcolor:"#f8fafc",flexShrink:0},children:[e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:d,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Save"]})]})]})}const L={text:"#0f172a",textMuted:"#64748b",borderInput:"rgba(0,0,0,0.23)",bg:"#ffffff"},fe={md:"6px"},oe={sm:11,md:13},G={width:"100%",fontSize:oe.md,fontFamily:"inherit",padding:"8px 12px",border:`1px solid ${L.borderInput}`,borderRadius:fe.md,outline:"none",background:L.bg,color:L.text,boxSizing:"border-box",transition:"border-color 0.15s, box-shadow 0.15s"};function X(){return{type:"text",id:"",label:"",colSpan:12}}function be(l){return l.type==="object"||l.type==="array"||l.type==="schema"}function me(l){if(l.type==="object")return"Child Fields";if(l.type==="schema")return"Schema Fields";const s=l.itemType??"text";return s==="object"?"Item Fields":s==="select"?"Item Options":"Item Config"}function ge({field:l,onChange:s}){var r;const d=l,a=d.itemType??"text";if(l.type==="object")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields nested inside this object. Each child field can itself be an object or array."}),e.jsx(W,{value:l.children??[],onChange:t=>s({...l,children:t}),label:"Child fields"})]});if(l.type==="schema")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields inside this schema. When the form is filled, their values are collected into a single object as this field's value."}),e.jsx(W,{value:l.children??[],onChange:t=>s({...l,children:t}),label:"Schema fields"})]});if(l.type==="array"){if(a==="object")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields for each item in the array. Each item will be an object with these fields."}),e.jsx(W,{value:d.itemFields??[],onChange:t=>s({...l,itemFields:t}),label:"Item fields"})]});if(a==="select"){const t=d.itemOptions??[];return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Options available in each select item."}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:t.map((p,i)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{style:{...G,flex:1,padding:"6px 10px"},placeholder:"Label",value:p.label,onChange:c=>{const m=t.map((y,B)=>B===i?{...y,label:c.target.value}:y);s({...l,itemOptions:m})}}),e.jsx("input",{style:{...G,flex:1,padding:"6px 10px"},placeholder:"Value",value:p.value,onChange:c=>{const m=t.map((y,B)=>B===i?{...y,value:c.target.value}:y);s({...l,itemOptions:m})}}),e.jsx(o.Box,{component:"button",onClick:()=>s({...l,itemOptions:t.filter((c,m)=>m!==i)}),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:"✕"})]},i))}),e.jsx(o.Box,{component:"button",onClick:()=>s({...l,itemOptions:[...t,{label:"",value:""}]}),sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%",justifyContent:"center","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:"+ Add option"})]})}if(a==="array"){const t=((r=d.itemSchema)==null?void 0:r.itemType)??"text",p=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"url",label:"URL"},{value:"password",label:"Password"},{value:"select",label:"Select"},{value:"object",label:"Object"}];return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Each item is itself an array. Configure the type of items inside the nested array."}),e.jsx("label",{style:{fontSize:oe.sm,fontWeight:600,color:L.textMuted,display:"block",marginBottom:3},children:"Nested item type"}),e.jsx("select",{style:{...G,padding:"6px 10px",cursor:"pointer"},value:t,onChange:i=>s({...l,itemSchema:{...d.itemSchema??{},itemType:i.target.value}}),children:p.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]})}return e.jsx(o.Box,{sx:{p:2.5},children:e.jsxs(o.Box,{sx:{border:"1.5px dashed #e2e8f0",borderRadius:"8px",py:3,textAlign:"center"},children:[e.jsxs(o.Typography,{sx:{fontSize:13,color:"#94a3b8"},children:["No extra configuration needed for ",e.jsx("strong",{children:a})," items."]}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#cbd5e1",mt:.5},children:"Item placeholder and labels are set in the previous step."})]})})}return null}function je({field:l}){var p;const[s,d]=h.useState({}),a=l.id??l.name??"preview",r=[{value:3,label:"1/4"},{value:4,label:"1/3"},{value:6,label:"1/2"},{value:8,label:"2/3"},{value:12,label:"Full"}],t=l.colSpan&&l.colSpan<12?((p=r.find(i=>i.value===l.colSpan))==null?void 0:p.label)??l.colSpan:"Full";return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mb:2,px:1.25,py:.75,bgcolor:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"7px"},children:[e.jsx(o.Typography,{sx:{fontSize:11,color:"#15803d",fontWeight:500,flex:1},children:"Live preview — interact to test the field"}),e.jsxs(o.Typography,{sx:{fontSize:11,color:"#64748b"},children:["Width: ",t]})]}),e.jsx(N.FlowForm,{schema:{layout:"flat",fields:[l]},initialValues:{[a]:l.type==="array"?[]:l.type==="object"||l.type==="schema"?{}:""},onSubmit:()=>{},conditionConfig:s,onConditionConfigChange:d})]})}function J({open:l,initial:s,onSave:d,onClose:a,editMode:r=!1}){const[t,p]=h.useState(1),[i,c]=h.useState(()=>s??X());function m(){c(s??X()),p(1)}const y=be(i),B=y?3:2,x=y?["Configure",me(i),"Preview"]:["Configure","Preview"],n=!!(i.id||i.name)&&!!i.type;function f(){p(k=>Math.min(k+1,B))}function u(){p(k=>Math.max(k-1,1))}function v(){d(i),a()}const g=t-1,w=t===B,T=y&&t===3||!y&&t===2;return e.jsxs(o.Dialog,{open:l,onClose:a,TransitionProps:{onEnter:m},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",maxHeight:"90vh"}},children:[e.jsxs(o.Box,{sx:{px:2.5,pt:1.75,pb:0,borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mb:1.5},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a",flex:1},children:r?"Edit Field":"Add Field"}),e.jsx(o.IconButton,{size:"small",onClick:a,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})]}),e.jsx(o.Stepper,{activeStep:g,sx:{pb:1.5},children:x.map((k,R)=>e.jsx(o.Step,{completed:g>R,children:e.jsx(o.StepLabel,{children:k})},k))})]}),e.jsxs(o.Box,{sx:{flex:1,overflowY:"auto"},children:[t===1&&e.jsx(le,{field:i,onChange:c,onSave:f,onCancel:a,noFooter:!0}),t===2&&y&&e.jsx(ge,{field:i,onChange:c}),T&&e.jsx(je,{field:i})]}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[t>1&&e.jsxs(o.Box,{component:"button",onClick:u,sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:500,color:"#6c757d",px:0,"&:hover":{color:"#0f172a"}},children:[e.jsx(S.MdArrowBack,{size:14})," Back"]}),e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),w?e.jsxs(o.Box,{component:"button",onClick:v,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," ",r?"Save changes":"Add field"]}):e.jsx(o.Box,{component:"button",onClick:f,disabled:!n,sx:{border:"none",cursor:n?"pointer":"not-allowed",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:n?"#6366f1":"#c7d2fe",color:"#fff","&:hover":{bgcolor:n?"#4f46e5":"#c7d2fe"}},children:"Next →"})]})]})}function ye({field:l,index:s,total:d,onEdit:a,onDelete:r,onMoveUp:t,onMoveDown:p}){const i=l.label||l.id||l.name||"Untitled",c=l.id??l.name??"";return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:1.5,py:1,border:"1px solid #e2e8f0",borderRadius:"8px",bgcolor:"#fff"},children:[e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.25,color:"#cbd5e1"},children:[e.jsx(o.Box,{component:"button",onClick:t,disabled:s===0,sx:{background:"none",border:"none",p:0,cursor:s===0?"default":"pointer",color:s===0?"#e2e8f0":"#94a3b8",lineHeight:1,fontSize:10,"&:hover":{color:s===0?"#e2e8f0":"#475569"}},children:"▲"}),e.jsx(o.Box,{component:"button",onClick:p,disabled:s===d-1,sx:{background:"none",border:"none",p:0,cursor:s===d-1?"default":"pointer",color:s===d-1?"#e2e8f0":"#94a3b8",lineHeight:1,fontSize:10,"&:hover":{color:s===d-1?"#e2e8f0":"#475569"}},children:"▼"})]}),e.jsx(o.Box,{sx:{fontSize:10,fontWeight:700,px:.75,py:.2,borderRadius:"4px",bgcolor:"#eef2ff",color:"#6366f1",flexShrink:0},children:l.type}),e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsxs(o.Typography,{sx:{fontSize:13,fontWeight:600,color:"#0f172a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[i,l.required&&e.jsx(o.Box,{component:"span",sx:{color:"#dc3545",ml:.25},children:"*"})]}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#94a3b8",fontFamily:"monospace"},children:c})]}),e.jsx(o.Tooltip,{title:"Edit field",placement:"top",children:e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"6px",p:0,color:"#94a3b8","&:hover":{bgcolor:"#f1f5f9",color:"#475569"}},children:e.jsx(S.MdEdit,{size:14})})}),e.jsx(o.Tooltip,{title:"Remove field",placement:"top",children:e.jsx(o.Box,{component:"button",onClick:r,sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"6px",p:0,color:"#94a3b8","&:hover":{bgcolor:"#fee2e2",color:"#dc2626"}},children:e.jsx(S.MdDeleteOutline,{size:16})})})]})}function ve({open:l,value:s,onSave:d,onClose:a}){const[r,t]=h.useState(s),[p,i]=h.useState(null);function c(){t(s),i(null)}function m(f){t(u=>u.filter((v,g)=>g!==f))}function y(f,u){t(v=>{const g=[...v],w=f+u;return w<0||w>=g.length?v:([g[f],g[w]]=[g[w],g[f]],g)})}function B(f){p!==null&&(t(u=>{const v=[...u];return v[p]=f,v}),i(null))}function x(){d(r),a()}const n=JSON.stringify(r)!==JSON.stringify(s);return e.jsxs(e.Fragment,{children:[e.jsxs(o.Dialog,{open:l,onClose:a,TransitionProps:{onEnter:c},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",maxHeight:"85vh"}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:2.5,py:1.75,borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a"},children:"Edit Schema"}),e.jsxs(o.Typography,{sx:{fontSize:11,color:"#94a3b8"},children:[r.length," field",r.length!==1?"s":""," defined"]})]}),e.jsx(o.IconButton,{size:"small",onClick:a,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})]}),e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",p:2.5},children:r.length===0?e.jsx(o.Box,{sx:{border:"1.5px dashed rgba(0,0,0,0.12)",borderRadius:"8px",py:4,textAlign:"center"},children:e.jsx(o.Typography,{sx:{fontSize:13,color:"#94a3b8"},children:"No fields defined yet"})}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:r.map((f,u)=>e.jsx(ye,{field:f,index:u,total:r.length,onEdit:()=>i(u),onDelete:()=>m(u),onMoveUp:()=>y(u,-1),onMoveDown:()=>y(u,1)},`${f.id??f.name}-${u}`))})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[n?e.jsx(o.Typography,{sx:{fontSize:11,color:"#f59e0b",fontWeight:500,flex:1},children:"Unsaved changes"}):e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:x,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Done"]})]})]}),p!==null&&e.jsx(J,{open:p!==null,initial:r[p],onSave:B,onClose:()=>i(null),editMode:!0})]})}function se(l){const s={};for(const d of l){const a=d.id??d.name??"";a&&(d.type==="array"?s[a]=[]:d.type==="object"||d.type==="schema"?s[a]=se(d.children??[]):s[a]="")}return s}function W({value:l,onChange:s,suggestions:d,label:a="Fields",onPayload:r,validate:t=!0,onValidityChange:p,variableGroups:i,initialValues:c,initialFormulaConfig:m,initialConditionConfig:y}){const[B,x]=h.useState(!1),[n,f]=h.useState(!1),[u,v]=h.useState(null),[g,w]=h.useState(m??{}),[T,k]=h.useState(y??{}),R=h.useRef(c??{}),A=h.useMemo(()=>se(l),[l]),$=h.useMemo(()=>c&&Object.keys(c).length>0?{...A,...c}:A,[A,c]),M=h.useMemo(()=>t?N.buildValidationSchema(l):void 0,[t,l]);h.useEffect(()=>{r&&r({schema:l,formulaConfig:g,conditionConfig:T,conditionExpressions:N.serializeConditionExpressions(T),values:R.current,evaluationPayload:N.buildEvaluationPayload({values:R.current,conditionConfig:T})})},[T,g,l]);const V=h.useCallback(z=>{R.current=z,r&&r({schema:l,formulaConfig:g,conditionConfig:T,conditionExpressions:N.serializeConditionExpressions(T),values:z,evaluationPayload:N.buildEvaluationPayload({values:z,conditionConfig:T})})},[l,g,T,r]);function P(z){s([...l,z])}function q(z){if(!u)return;const{containerFieldId:D,tabId:H}=u,U=l.map(I=>{if((I.id??I.name)!==D)return I;const Y=I.tabs??[];return{...I,tabs:Y.map(O=>O.id===H?{...O,fields:[...O.fields??[],z]}:O)}});s(U),v(null)}function C(z,D,H){const U=l.map(I=>{if((I.id??I.name)!==z)return I;const Y=I.tabs??[];return{...I,tabs:Y.map(O=>O.id===D?{...O,fields:(O.fields??[]).filter((Be,te)=>te!==H)}:O)}});s(U)}const ne=h.useMemo(()=>({openAddFieldDialog:(z,D)=>v({containerFieldId:z,tabId:D}),removeFieldFromTab:C}),[l,s]),K=e.jsxs("div",{className:"schema-builder-root",children:[l.length>0&&e.jsx("div",{className:"schema-builder-header",children:e.jsxs("div",{className:"schema-builder-actions",children:[e.jsx(o.Tooltip,{title:"Edit schema",placement:"top",children:e.jsxs("button",{className:"sb-btn sb-btn-outline",onClick:()=>f(!0),children:[e.jsx(S.MdSettings,{size:13})," Edit Schema"]})}),e.jsx(o.Tooltip,{title:"Add a new field",placement:"top",children:e.jsxs("button",{className:"sb-btn sb-btn-primary",onClick:()=>x(!0),children:[e.jsx(S.MdAdd,{size:14})," Add Field"]})})]})}),l.length>0?e.jsx(N.TabsEditContext.Provider,{value:ne,children:e.jsx(N.FlowForm,{schema:{layout:"flat",fields:l},initialValues:$,onSubmit:()=>{},validationSchema:M,onValidityChange:p,onValuesChange:r?V:void 0,formulaConfig:g,onFormulaConfigChange:w,conditionConfig:T,onConditionConfigChange:k})}):e.jsxs("div",{className:"schema-builder-empty-state",children:[e.jsx(ie.FaWpforms,{size:40,className:"schema-builder-empty-icon"}),e.jsx("p",{className:"schema-builder-empty-title",children:"Tell us what fields should be in the list, and assign values to them."}),e.jsx("div",{className:"schema-builder-empty-actions",children:e.jsx("button",{className:"btn",onClick:()=>x(!0),children:"Add field"})})]}),e.jsx(J,{open:B,onSave:P,onClose:()=>x(!1)}),e.jsx(ve,{open:n,value:l,onSave:s,onClose:()=>f(!1)}),e.jsx(J,{open:!!u,onSave:q,onClose:()=>v(null)})]});return i?e.jsxs(N.VariablePickerProvider,{groups:i,children:[e.jsx(N.VariablePicker,{width:260,mode:"popover"}),K]}):K}function Ce({fields:l,onOpen:s}){return e.jsxs(o.Box,{sx:{border:"1px solid #e2e8f0",borderRadius:"8px",bgcolor:"#fff",overflow:"hidden"},children:[l.length>0?e.jsx(o.Box,{sx:{px:1.5,py:1.25,display:"flex",flexWrap:"wrap",gap:.5},children:l.map((d,a)=>{const r=d.id??d.name??"";return e.jsx(o.Tooltip,{title:`${d.type} · ${r}`,placement:"top",children:e.jsx(o.Chip,{label:d.label||r,size:"small",sx:{fontSize:11,fontWeight:500,height:22,bgcolor:"#f1f5f9",color:"#334155",border:"1px solid #e2e8f0","& .MuiChip-label":{px:1}}})},a)})}):e.jsx(o.Box,{sx:{px:1.5,py:1.5},children:e.jsx(o.Typography,{sx:{fontSize:12,color:"#94a3b8"},children:"No fields defined yet"})}),e.jsx(o.Divider,{sx:{borderColor:"#f1f5f9"}}),e.jsxs(o.Box,{onClick:s,sx:{display:"flex",alignItems:"center",gap:.75,px:1.5,py:1,cursor:"pointer","&:hover":{bgcolor:"#f8fafc"},transition:"background 0.12s"},children:[l.length===0?e.jsx(S.MdAdd,{size:14,color:"#6366f1"}):e.jsx(S.MdSettings,{size:13,color:"#6366f1"}),e.jsx(o.Typography,{sx:{fontSize:12,fontWeight:600,color:"#6366f1",flex:1},children:l.length===0?"Add fields":"Configure fields"}),e.jsx(S.MdArrowForward,{size:13,color:"#94a3b8"})]})]})}function Se({value:l,onChange:s,suggestions:d,onPayload:a,onDone:r,validate:t,onValidityChange:p,label:i="Fields",drawerTitle:c="Configure Fields",drawerWidth:m=580}){const[y,B]=h.useState(!1),[x,n]=h.useState({type:"list"}),[f,u]=h.useState(l),v=h.useRef(null),g=h.useRef(void 0),w=h.useRef(void 0),T=h.useRef(void 0),[k,R]=h.useState(null);function A(){u(l),n({type:"list"}),B(!0)}function $(){const C=v.current;C&&(g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig),s(f),B(!1),r==null||r(f,C)}function M(){const C=v.current;C&&(g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig),u(l),B(!1)}function V(){if(x.type!=="edit"||!k)return;const C=[...f];C[x.index]=k,u(C),n({type:"list"}),R(null)}function P(){n({type:"list"}),R(null)}const q=JSON.stringify(f)!==JSON.stringify(l);return x.type==="edit"&&f[x.index],e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{sx:{fontSize:12,fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:.5,mb:.75},children:i}),e.jsx(Ce,{fields:l,onOpen:A})]}),e.jsxs(o.Drawer,{anchor:"right",open:y,onClose:M,PaperProps:{sx:{width:m,display:"flex",flexDirection:"column",boxShadow:"-4px 0 24px rgba(0,0,0,0.12)",overflow:"hidden"}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:2,py:1.5,borderBottom:"1px solid #e2e8f0",flexShrink:0,gap:1},children:[x.type==="edit"&&e.jsx(o.Tooltip,{title:"Back to fields",placement:"bottom",children:e.jsx(o.IconButton,{size:"small",onClick:P,sx:{color:"#64748b"},children:e.jsx(S.MdArrowBack,{size:17})})}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a"},children:x.type==="edit"?(k==null?void 0:k.label)||(k==null?void 0:k.id)||"Edit field":c}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#94a3b8"},children:x.type==="edit"?"Configure field properties":`${f.length} field${f.length!==1?"s":""} defined`})]}),x.type==="list"&&e.jsx(o.Tooltip,{title:"Close",placement:"bottom",children:e.jsx(o.IconButton,{size:"small",onClick:M,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})})]}),x.type==="list"&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",p:2.5},children:e.jsx(W,{value:f,onChange:u,suggestions:d,onPayload:C=>{v.current=C,g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig,a==null||a(C)},validate:t,onValidityChange:p,label:i,initialValues:g.current,initialFormulaConfig:w.current,initialConditionConfig:T.current})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[q?e.jsx(o.Typography,{sx:{fontSize:11,color:"#f59e0b",fontWeight:500,flex:1},children:"Unsaved changes"}):e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:M,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:$,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Done"]})]})]}),x.type==="edit"&&k&&e.jsx(le,{field:k,onChange:R,onSave:V,onCancel:P})]})]})}exports.FIELD_TYPE_OPTIONS=Z;exports.SchemaBuilder=W;exports.SchemaBuilderDrawer=Se;exports.useFlowForm=ae;
|
|
1
|
+
"use strict";const h=require("react"),re=require("formik"),N=require("./index-a1IOaYsW.js"),e=require("react/jsx-runtime"),o=require("@mui/material"),S=require("react-icons/md"),ie=require("react-icons/fa6");function ae({schema:l,initialValues:s,onSubmit:d,showErrorsImmediately:a=!1}){const r=l.fields??[],t=h.useMemo(()=>N.buildValidationSchema(r),[r]),p=h.useMemo(()=>{if(a)return r.reduce((u,v)=>{const g=N.resolveFieldKey(v);return g&&(u[g]=!0),u},{})},[r,a]),[i,c]=h.useState({}),[m,y]=h.useState({}),B=h.useRef(s);h.useEffect(()=>{B.current!==s&&(B.current=s,c({}),y({}))},[s]);const x=re.useFormik({initialValues:s,validationSchema:t,initialTouched:p,validateOnMount:a,validateOnChange:!0,validateOnBlur:!0,enableReinitialize:!0,onSubmit:async u=>{const v=N.buildEvaluationPayload({values:u,conditionConfig:m});await d(u,v)}}),n=h.useCallback(()=>{x.submitForm()},[x]),f=h.useCallback(u=>{x.resetForm(u?{values:u}:void 0),c({}),y({})},[x]);return{values:x.values,errors:x.errors,isValid:x.isValid,isDirty:x.dirty,isSubmitting:x.isSubmitting,formulaConfig:i,conditionConfig:m,submit:n,reset:f,setFieldValue:x.setFieldValue,_schema:l,_formik:x,_formulaConfig:i,_onFormulaConfigChange:c,_conditionConfig:m,_onConditionConfigChange:y}}const Z=N.FlowForgeRegistry.getTypeOptions(),j="form-control font-14",b="text-14 text-dark fw-medium mb-1 align-items-center d-flex gap-1",F={fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:.6,marginBottom:8,display:"block"},ce=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"url",label:"URL"},{value:"password",label:"Password"},{value:"select",label:"Select"},{value:"object",label:"Object (sub-fields)"},{value:"array",label:"Array (nested)"}],de=[{value:3,label:"1/4"},{value:4,label:"1/3"},{value:6,label:"1/2"},{value:8,label:"2/3"},{value:12,label:"Full"}];function xe({value:l,onChange:s}){const d=l??12;return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:"Column width"}),e.jsx(o.Box,{sx:{display:"flex",gap:.5},children:de.map(a=>e.jsx(o.Tooltip,{title:`colSpan: ${a.value}`,placement:"top",children:e.jsx(o.Box,{component:"button",onClick:()=>s(a.value),sx:{flex:1,border:"1px solid",borderColor:d===a.value?"#6366f1":"#dee2e6",borderRadius:"6px",cursor:"pointer",bgcolor:d===a.value?"#eef2ff":"#fff",color:d===a.value?"#6366f1":"#6c757d",fontSize:11,fontWeight:600,py:.6,px:0,"&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:a.label})},a.value))}),e.jsx(o.Box,{sx:{display:"flex",gap:"3px",mt:.75},children:Array.from({length:12}).map((a,r)=>e.jsx(o.Box,{sx:{flex:1,height:4,borderRadius:"2px",bgcolor:r<d?"#6366f1":"#e2e8f0",transition:"background 0.12s"}},r))})]})}function Q({options:l=[],onChange:s}){function d(a,r,t){s(l.map((p,i)=>i===a?{...p,[r]:t}:p))}return e.jsxs(o.Box,{children:[e.jsxs("span",{className:b,children:["Options ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:l.map((a,r)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{className:j,style:{flex:1},placeholder:"Label",value:a.label,onChange:t=>d(r,"label",t.target.value)}),e.jsx("input",{className:j,style:{flex:1},placeholder:"Value",value:a.value,onChange:t=>d(r,"value",t.target.value)}),e.jsx(o.Box,{component:"button",onClick:()=>s(l.filter((t,p)=>p!==r)),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]},r))}),e.jsxs(o.Box,{component:"button",onClick:()=>s([...l,{label:"",value:""}]),sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:[e.jsx(S.MdAdd,{size:13})," Add option"]})]})}const ee=[{value:"operator",label:"Operator (predefined)"},{value:"select",label:"Select"},{value:"text",label:"Text"}];function pe({col:l,onChange:s,onDelete:d}){const a=l.type==="select",r=l.type==="operator";return e.jsxs(o.Box,{sx:{border:"1px solid #e2e8f0",borderRadius:"7px",p:1.25,bgcolor:"#fff",display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(o.Box,{sx:{fontSize:10,fontWeight:700,px:.75,py:.2,borderRadius:"4px",bgcolor:r?"#fef9c3":"#eef2ff",color:r?"#92400e":"#6366f1",flexShrink:0},children:r?"OPERATOR":l.type.toUpperCase()}),e.jsx(o.Box,{sx:{fontSize:12,fontWeight:600,color:"#0f172a",flex:1},children:l.label||l.id||"Unnamed"}),e.jsx(o.Box,{component:"button",onClick:d,sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Column type"}),e.jsx("select",{value:l.type,onChange:t=>s({...l,type:t.target.value,options:void 0}),className:j,style:{cursor:"pointer"},children:ee.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Column key ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:`${j} ${l.id?"":"border-danger"}`,value:l.id,onChange:t=>s({...l,id:t.target.value}),placeholder:"e.g. field, operator, value"}),!l.id&&e.jsx("span",{style:{fontSize:10,color:"#dc3545"},children:"Required — used as data key"})]})]}),!r&&e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Label"}),e.jsx("input",{className:j,value:l.label??"",onChange:t=>s({...l,label:t.target.value||void 0}),placeholder:"Column label"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Placeholder"}),e.jsx("input",{className:j,value:l.placeholder??"",onChange:t=>s({...l,placeholder:t.target.value||void 0}),placeholder:"Hint…"})]})]}),a&&e.jsx(Q,{options:l.options??[],onChange:t=>s({...l,options:t})}),r&&e.jsx(o.Box,{sx:{bgcolor:"#fefce8",border:"1px solid #fef08a",borderRadius:"6px",px:1.25,py:.75},children:e.jsx(o.Box,{sx:{fontSize:11,color:"#78350f"},children:"Predefined: equals, not equals, contains, starts with, ends with, is present, is not present, greater than, less than…"})}),!r&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:`formula-${l.id}`,checked:!!l.formula,onChange:t=>s({...l,formula:t.target.checked||void 0}),style:{cursor:"pointer",width:14,height:14}}),e.jsx("label",{htmlFor:`formula-${l.id}`,className:b,style:{margin:0,cursor:"pointer"},children:"Formula input (chip editor)"})]})]})}function ue({condition:l,onChange:s}){const d=!!l;function a(){s(d?void 0:{fields:[]})}function r(i){if(!l)return;const c=i==="operator"?"operator":l.fields.filter(m=>m.type!=="operator").length===0?"field":"value";s({...l,fields:[...l.fields,{id:c,type:i}]})}function t(i,c){if(!l)return;const m=[...l.fields];m[i]=c,s({...l,fields:m})}function p(i){l&&s({...l,fields:l.fields.filter((c,m)=>m!==i)})}return e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:d?1.25:0},children:[e.jsx("input",{type:"checkbox",id:"enable-condition",checked:d,onChange:a,style:{cursor:"pointer",width:14,height:14}}),e.jsx("span",{style:{...F,margin:0,color:d?"#6366f1":"#94a3b8"},children:"Condition row"})]}),d&&l&&e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[l.fields.map((i,c)=>e.jsx(pe,{col:i,onChange:m=>t(c,m),onDelete:()=>p(c)},c)),e.jsx(o.Box,{sx:{display:"flex",gap:.5},children:ee.map(i=>e.jsxs(o.Box,{component:"button",onClick:()=>r(i.value),sx:{flex:1,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,py:.5,borderRadius:"6px",color:i.value==="operator"?"#92400e":"#6366f1","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:["+ ",i.value==="operator"?"Operator":i.label.split(" ")[0]]},i.value))}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,flexWrap:"wrap"},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:"allow-groups",checked:!!l.allowGroups,onChange:i=>s({...l,allowGroups:i.target.checked||void 0}),style:{cursor:"pointer",width:14,height:14}}),e.jsx("label",{htmlFor:"allow-groups",className:b,style:{margin:0,cursor:"pointer"},children:"Allow nested groups"})]}),l.allowGroups&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("label",{className:b,style:{margin:0},children:"Max depth"}),e.jsx("input",{type:"number",min:1,max:5,className:j,style:{width:60,textAlign:"center"},value:l.maxGroupDepth??"",onChange:i=>s({...l,maxGroupDepth:i.target.value?Number(i.target.value):void 0}),placeholder:"∞"})]})]})]})]})}function E({id:l,label:s,checked:d,onChange:a}){return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:l,checked:d,onChange:r=>a(r.target.checked),style:{cursor:"pointer",width:14,height:14,flexShrink:0}}),e.jsx("label",{htmlFor:l,className:b,style:{margin:0,cursor:"pointer"},children:s})]})}function he({views:l=[],onChange:s}){function d(r,t,p){s(l.map((i,c)=>c===r?{...i,[t]:p}:i))}function a(){const r=`tab${l.length+1}`;s([...l,{id:r,label:`Tab ${l.length+1}`}])}return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:"Views"}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:l.map((r,t)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{className:j,style:{flex:1},placeholder:"Label",value:r.label,onChange:p=>d(t,"label",p.target.value)}),e.jsx("input",{className:j,style:{flex:1},placeholder:"ID (no spaces)",value:r.id,onChange:p=>d(t,"id",p.target.value.replace(/\s/g,"_"))}),e.jsx(o.Box,{component:"button",onClick:()=>s(l.filter((p,i)=>i!==t)),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]},t))}),e.jsxs(o.Box,{component:"button",onClick:a,sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:[e.jsx(S.MdAdd,{size:13})," Add view"]})]})}function _({label:l,value:s,options:d,onChange:a}){return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:l}),e.jsx(o.Box,{sx:{display:"flex",border:"1px solid #dee2e6",borderRadius:"7px",overflow:"hidden"},children:d.map(r=>e.jsx(o.Box,{component:"button",onClick:()=>a(r.value),sx:{flex:1,border:"none",borderRight:"1px solid #dee2e6",cursor:"pointer",fontSize:12,fontWeight:600,py:.6,bgcolor:s===r.value?"#eef2ff":"#fff",color:s===r.value?"#6366f1":"#6c757d","&:last-child":{borderRight:"none"},"&:hover":{bgcolor:"#f5f3ff"}},children:r.label},r.value))})]})}function le({field:l,onChange:s,onSave:d,onCancel:a,noFooter:r}){const[t,p]=h.useState(!1),i=l.id??l.name??"",c=l,m=l.type==="select"||l.type==="descriptive-select"||l.type==="radio-group",y=N.FlowForgeRegistry.get(l.type),B=y==null?void 0:y.configSchema;function x(n,f){s({...l,[n]:f})}return e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{sx:{flex:1,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(o.Box,{children:[e.jsx("span",{style:F,children:"Required"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Type"}),e.jsx("select",{value:l.type,onChange:n=>x("type",n.target.value),className:j,style:{cursor:"pointer"},children:Z.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:l.type==="tabs"?"1fr":"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Field ID ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:j,value:l.id??l.name??"",onChange:n=>x("id",n.target.value),placeholder:"e.g. email"})]}),l.type!=="tabs"&&e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Label ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:j,value:l.label??"",onChange:n=>x("label",n.target.value),placeholder:"Display label"})]})]}),l.type!=="tabs"&&e.jsx(xe,{value:l.colSpan,onChange:n=>x("colSpan",n===12?void 0:n)})]})]}),B&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx("span",{style:F,children:"Specific Settings"}),e.jsx(N.FlowForm,{schema:{layout:"flat",compact:!0,fields:B.fields},initialValues:l,onValuesChange:n=>s({...l,...n}),onSubmit:()=>{}})]}),l.type==="tabs"&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5,display:"flex",flexDirection:"column",gap:1.5},children:[e.jsx("span",{style:F,children:"Content"}),e.jsx(he,{views:(c.tabs??[]).map(n=>({id:n.id,label:n.label})),onChange:n=>{const f=c.tabs??[],u=n.map(v=>{const g=f.find(w=>w.id===v.id);return g?{...g,...v}:{...v,fields:[]}});s({...l,tabs:u})}}),e.jsx("span",{style:{...F,marginTop:4},children:"Interaction"}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Disabled"}),e.jsx("input",{className:j,value:c.disabledExpr??"",onChange:n=>s({...l,disabledExpr:n.target.value||void 0}),placeholder:"false"})]}),e.jsx("span",{style:{...F,marginTop:4},children:"Appearance"}),e.jsx(_,{label:"Alignment",value:c.alignment??"left",options:[{value:"left",label:"|←"},{value:"center-left",label:"←|"},{value:"center",label:"|·|"},{value:"center-right",label:"|→"},{value:"right",label:"→|"}],onChange:n=>s({...l,alignment:n})}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Hidden"}),e.jsx("input",{className:j,value:c.hiddenExpr??"",onChange:n=>s({...l,hiddenExpr:n.target.value||void 0}),placeholder:"false"})]}),e.jsx(_,{label:"Variant",value:c.variant??"line",options:[{value:"pill",label:"Pill"},{value:"line",label:"Line"}],onChange:n=>s({...l,variant:n})}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Active color"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.activeColor??"#6366f1",onChange:n=>s({...l,activeColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.activeColor??"",onChange:n=>s({...l,activeColor:n.target.value||void 0}),placeholder:"#6366f1",style:{flex:1}})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Active text"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.activeTextColor??"#ffffff",onChange:n=>s({...l,activeTextColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.activeTextColor??"",onChange:n=>s({...l,activeTextColor:n.target.value||void 0}),placeholder:"auto",style:{flex:1}})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Inactive text"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.inactiveTextColor??"#64748b",onChange:n=>s({...l,inactiveTextColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.inactiveTextColor??"",onChange:n=>s({...l,inactiveTextColor:n.target.value||void 0}),placeholder:"#64748b",style:{flex:1}})]})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Styles"}),e.jsx("input",{className:j,value:c.styles??"",onChange:n=>s({...l,styles:n.target.value||void 0}),placeholder:"None"})]}),e.jsx("span",{style:{...F,marginTop:4},children:"Spacing"}),e.jsx(_,{label:"Height",value:c.height??"auto",options:[{value:"auto",label:"Auto"},{value:"fixed",label:"Fixed"}],onChange:n=>s({...l,height:n})}),e.jsx(_,{label:"Margin",value:c.margin??"normal",options:[{value:"normal",label:"Normal"},{value:"none",label:"None"}],onChange:n=>s({...l,margin:n})})]}),m&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx("span",{style:F,children:"Options"}),e.jsx(Q,{options:c.options??[],onChange:n=>s({...l,options:n})})]}),l.type==="array"&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5,display:"flex",flexDirection:"column",gap:1},children:[e.jsx("span",{style:F,children:"Array settings"}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item type"}),e.jsx("select",{className:j,style:{cursor:"pointer"},value:c.itemType??"text",onChange:n=>s({...l,itemType:n.target.value}),children:ce.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item label"}),e.jsx("input",{className:j,value:c.itemLabel??"",onChange:n=>s({...l,itemLabel:n.target.value||void 0}),placeholder:'e.g. "Member"'})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Add button label"}),e.jsx("input",{className:j,value:c.addLabel??"",onChange:n=>s({...l,addLabel:n.target.value||void 0}),placeholder:"Add item"})]})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Min items"}),e.jsx("input",{type:"number",min:0,className:j,value:c.minItems??"",onChange:n=>s({...l,minItems:n.target.value?Number(n.target.value):void 0}),placeholder:"0"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Max items"}),e.jsx("input",{type:"number",min:1,className:j,value:c.maxItems??"",onChange:n=>s({...l,maxItems:n.target.value?Number(n.target.value):void 0}),placeholder:"∞"})]})]}),!["object","array","select"].includes(c.itemType??"text")&&e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item placeholder"}),e.jsx("input",{className:j,value:c.itemPlaceholder??"",onChange:n=>s({...l,itemPlaceholder:n.target.value||void 0}),placeholder:"Enter value…"})]})]}),e.jsx(ue,{condition:l.condition,onChange:n=>s({...l,condition:n})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx(o.Box,{component:"button",onClick:()=>p(n=>!n),sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:.5,p:0,mb:t?1.25:0},children:e.jsxs("span",{style:{...F,margin:0,color:t?"#6366f1":"#94a3b8"},children:[t?"▾":"▸"," Optional settings"]})}),e.jsx(o.Collapse,{in:t,children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Placeholder"}),e.jsx("input",{className:j,value:l.placeholder??"",onChange:n=>x("placeholder",n.target.value||void 0),placeholder:"Hint text…"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Helper text"}),e.jsx("input",{className:j,value:l.helperText??"",onChange:n=>x("helperText",n.target.value||void 0),placeholder:"Description…"})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Info tooltip"}),e.jsx("input",{className:j,value:l.info??"",onChange:n=>x("info",n.target.value||void 0),placeholder:"Shown in ℹ tooltip"})]}),e.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5},children:[e.jsx(E,{id:`${i}-req`,label:"Required",checked:!!l.required,onChange:n=>x("required",n||void 0)}),e.jsx(E,{id:`${i}-dis`,label:"Disabled",checked:!!l.disabled,onChange:n=>x("disabled",n||void 0)}),e.jsx(E,{id:`${i}-hid`,label:"Hidden",checked:!!l.hidden,onChange:n=>x("hidden",n||void 0)}),e.jsx(E,{id:`${i}-opt`,label:"Show optional",checked:!!l.showOptional,onChange:n=>x("showOptional",n||void 0)}),e.jsx(E,{id:`${i}-div`,label:"Divider after",checked:!!l.dividerAfter,onChange:n=>x("dividerAfter",n||void 0)}),e.jsx(E,{id:`${i}-frm`,label:"Formula input",checked:!!l.formula,onChange:n=>x("formula",n||void 0)})]})]})})]})]}),!r&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",gap:1,justifyContent:"flex-end",bgcolor:"#f8fafc",flexShrink:0},children:[e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:d,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Save"]})]})]})}const L={text:"#0f172a",textMuted:"#64748b",borderInput:"rgba(0,0,0,0.23)",bg:"#ffffff"},fe={md:"6px"},oe={sm:11,md:13},G={width:"100%",fontSize:oe.md,fontFamily:"inherit",padding:"8px 12px",border:`1px solid ${L.borderInput}`,borderRadius:fe.md,outline:"none",background:L.bg,color:L.text,boxSizing:"border-box",transition:"border-color 0.15s, box-shadow 0.15s"};function X(){return{type:"text",id:"",label:"",colSpan:12}}function be(l){return l.type==="object"||l.type==="array"||l.type==="schema"}function me(l){if(l.type==="object")return"Child Fields";if(l.type==="schema")return"Schema Fields";const s=l.itemType??"text";return s==="object"?"Item Fields":s==="select"?"Item Options":"Item Config"}function ge({field:l,onChange:s}){var r;const d=l,a=d.itemType??"text";if(l.type==="object")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields nested inside this object. Each child field can itself be an object or array."}),e.jsx(W,{value:l.children??[],onChange:t=>s({...l,children:t}),label:"Child fields"})]});if(l.type==="schema")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields inside this schema. When the form is filled, their values are collected into a single object as this field's value."}),e.jsx(W,{value:l.children??[],onChange:t=>s({...l,children:t}),label:"Schema fields"})]});if(l.type==="array"){if(a==="object")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields for each item in the array. Each item will be an object with these fields."}),e.jsx(W,{value:d.itemFields??[],onChange:t=>s({...l,itemFields:t}),label:"Item fields"})]});if(a==="select"){const t=d.itemOptions??[];return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Options available in each select item."}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:t.map((p,i)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{style:{...G,flex:1,padding:"6px 10px"},placeholder:"Label",value:p.label,onChange:c=>{const m=t.map((y,B)=>B===i?{...y,label:c.target.value}:y);s({...l,itemOptions:m})}}),e.jsx("input",{style:{...G,flex:1,padding:"6px 10px"},placeholder:"Value",value:p.value,onChange:c=>{const m=t.map((y,B)=>B===i?{...y,value:c.target.value}:y);s({...l,itemOptions:m})}}),e.jsx(o.Box,{component:"button",onClick:()=>s({...l,itemOptions:t.filter((c,m)=>m!==i)}),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:"✕"})]},i))}),e.jsx(o.Box,{component:"button",onClick:()=>s({...l,itemOptions:[...t,{label:"",value:""}]}),sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%",justifyContent:"center","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:"+ Add option"})]})}if(a==="array"){const t=((r=d.itemSchema)==null?void 0:r.itemType)??"text",p=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"url",label:"URL"},{value:"password",label:"Password"},{value:"select",label:"Select"},{value:"object",label:"Object"}];return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Each item is itself an array. Configure the type of items inside the nested array."}),e.jsx("label",{style:{fontSize:oe.sm,fontWeight:600,color:L.textMuted,display:"block",marginBottom:3},children:"Nested item type"}),e.jsx("select",{style:{...G,padding:"6px 10px",cursor:"pointer"},value:t,onChange:i=>s({...l,itemSchema:{...d.itemSchema??{},itemType:i.target.value}}),children:p.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]})}return e.jsx(o.Box,{sx:{p:2.5},children:e.jsxs(o.Box,{sx:{border:"1.5px dashed #e2e8f0",borderRadius:"8px",py:3,textAlign:"center"},children:[e.jsxs(o.Typography,{sx:{fontSize:13,color:"#94a3b8"},children:["No extra configuration needed for ",e.jsx("strong",{children:a})," items."]}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#cbd5e1",mt:.5},children:"Item placeholder and labels are set in the previous step."})]})})}return null}function je({field:l}){var p;const[s,d]=h.useState({}),a=l.id??l.name??"preview",r=[{value:3,label:"1/4"},{value:4,label:"1/3"},{value:6,label:"1/2"},{value:8,label:"2/3"},{value:12,label:"Full"}],t=l.colSpan&&l.colSpan<12?((p=r.find(i=>i.value===l.colSpan))==null?void 0:p.label)??l.colSpan:"Full";return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mb:2,px:1.25,py:.75,bgcolor:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"7px"},children:[e.jsx(o.Typography,{sx:{fontSize:11,color:"#15803d",fontWeight:500,flex:1},children:"Live preview — interact to test the field"}),e.jsxs(o.Typography,{sx:{fontSize:11,color:"#64748b"},children:["Width: ",t]})]}),e.jsx(N.FlowForm,{schema:{layout:"flat",fields:[l]},initialValues:{[a]:l.type==="array"?[]:l.type==="object"||l.type==="schema"?{}:""},onSubmit:()=>{},conditionConfig:s,onConditionConfigChange:d})]})}function J({open:l,initial:s,onSave:d,onClose:a,editMode:r=!1}){const[t,p]=h.useState(1),[i,c]=h.useState(()=>s??X());function m(){c(s??X()),p(1)}const y=be(i),B=y?3:2,x=y?["Configure",me(i),"Preview"]:["Configure","Preview"],n=!!(i.id||i.name)&&!!i.type;function f(){p(k=>Math.min(k+1,B))}function u(){p(k=>Math.max(k-1,1))}function v(){d(i),a()}const g=t-1,w=t===B,T=y&&t===3||!y&&t===2;return e.jsxs(o.Dialog,{open:l,onClose:a,TransitionProps:{onEnter:m},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",maxHeight:"90vh"}},children:[e.jsxs(o.Box,{sx:{px:2.5,pt:1.75,pb:0,borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mb:1.5},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a",flex:1},children:r?"Edit Field":"Add Field"}),e.jsx(o.IconButton,{size:"small",onClick:a,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})]}),e.jsx(o.Stepper,{activeStep:g,sx:{pb:1.5},children:x.map((k,R)=>e.jsx(o.Step,{completed:g>R,children:e.jsx(o.StepLabel,{children:k})},k))})]}),e.jsxs(o.Box,{sx:{flex:1,overflowY:"auto"},children:[t===1&&e.jsx(le,{field:i,onChange:c,onSave:f,onCancel:a,noFooter:!0}),t===2&&y&&e.jsx(ge,{field:i,onChange:c}),T&&e.jsx(je,{field:i})]}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[t>1&&e.jsxs(o.Box,{component:"button",onClick:u,sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:500,color:"#6c757d",px:0,"&:hover":{color:"#0f172a"}},children:[e.jsx(S.MdArrowBack,{size:14})," Back"]}),e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),w?e.jsxs(o.Box,{component:"button",onClick:v,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," ",r?"Save changes":"Add field"]}):e.jsx(o.Box,{component:"button",onClick:f,disabled:!n,sx:{border:"none",cursor:n?"pointer":"not-allowed",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:n?"#6366f1":"#c7d2fe",color:"#fff","&:hover":{bgcolor:n?"#4f46e5":"#c7d2fe"}},children:"Next →"})]})]})}function ye({field:l,index:s,total:d,onEdit:a,onDelete:r,onMoveUp:t,onMoveDown:p}){const i=l.label||l.id||l.name||"Untitled",c=l.id??l.name??"";return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:1.5,py:1,border:"1px solid #e2e8f0",borderRadius:"8px",bgcolor:"#fff"},children:[e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.25,color:"#cbd5e1"},children:[e.jsx(o.Box,{component:"button",onClick:t,disabled:s===0,sx:{background:"none",border:"none",p:0,cursor:s===0?"default":"pointer",color:s===0?"#e2e8f0":"#94a3b8",lineHeight:1,fontSize:10,"&:hover":{color:s===0?"#e2e8f0":"#475569"}},children:"▲"}),e.jsx(o.Box,{component:"button",onClick:p,disabled:s===d-1,sx:{background:"none",border:"none",p:0,cursor:s===d-1?"default":"pointer",color:s===d-1?"#e2e8f0":"#94a3b8",lineHeight:1,fontSize:10,"&:hover":{color:s===d-1?"#e2e8f0":"#475569"}},children:"▼"})]}),e.jsx(o.Box,{sx:{fontSize:10,fontWeight:700,px:.75,py:.2,borderRadius:"4px",bgcolor:"#eef2ff",color:"#6366f1",flexShrink:0},children:l.type}),e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsxs(o.Typography,{sx:{fontSize:13,fontWeight:600,color:"#0f172a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[i,l.required&&e.jsx(o.Box,{component:"span",sx:{color:"#dc3545",ml:.25},children:"*"})]}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#94a3b8",fontFamily:"monospace"},children:c})]}),e.jsx(o.Tooltip,{title:"Edit field",placement:"top",children:e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"6px",p:0,color:"#94a3b8","&:hover":{bgcolor:"#f1f5f9",color:"#475569"}},children:e.jsx(S.MdEdit,{size:14})})}),e.jsx(o.Tooltip,{title:"Remove field",placement:"top",children:e.jsx(o.Box,{component:"button",onClick:r,sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"6px",p:0,color:"#94a3b8","&:hover":{bgcolor:"#fee2e2",color:"#dc2626"}},children:e.jsx(S.MdDeleteOutline,{size:16})})})]})}function ve({open:l,value:s,onSave:d,onClose:a}){const[r,t]=h.useState(s),[p,i]=h.useState(null);function c(){t(s),i(null)}function m(f){t(u=>u.filter((v,g)=>g!==f))}function y(f,u){t(v=>{const g=[...v],w=f+u;return w<0||w>=g.length?v:([g[f],g[w]]=[g[w],g[f]],g)})}function B(f){p!==null&&(t(u=>{const v=[...u];return v[p]=f,v}),i(null))}function x(){d(r),a()}const n=JSON.stringify(r)!==JSON.stringify(s);return e.jsxs(e.Fragment,{children:[e.jsxs(o.Dialog,{open:l,onClose:a,TransitionProps:{onEnter:c},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",maxHeight:"85vh"}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:2.5,py:1.75,borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a"},children:"Edit Schema"}),e.jsxs(o.Typography,{sx:{fontSize:11,color:"#94a3b8"},children:[r.length," field",r.length!==1?"s":""," defined"]})]}),e.jsx(o.IconButton,{size:"small",onClick:a,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})]}),e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",p:2.5},children:r.length===0?e.jsx(o.Box,{sx:{border:"1.5px dashed rgba(0,0,0,0.12)",borderRadius:"8px",py:4,textAlign:"center"},children:e.jsx(o.Typography,{sx:{fontSize:13,color:"#94a3b8"},children:"No fields defined yet"})}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:r.map((f,u)=>e.jsx(ye,{field:f,index:u,total:r.length,onEdit:()=>i(u),onDelete:()=>m(u),onMoveUp:()=>y(u,-1),onMoveDown:()=>y(u,1)},`${f.id??f.name}-${u}`))})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[n?e.jsx(o.Typography,{sx:{fontSize:11,color:"#f59e0b",fontWeight:500,flex:1},children:"Unsaved changes"}):e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:x,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Done"]})]})]}),p!==null&&e.jsx(J,{open:p!==null,initial:r[p],onSave:B,onClose:()=>i(null),editMode:!0})]})}function se(l){const s={};for(const d of l){const a=d.id??d.name??"";a&&(d.type==="array"?s[a]=[]:d.type==="object"||d.type==="schema"?s[a]=se(d.children??[]):s[a]="")}return s}function W({value:l,onChange:s,suggestions:d,label:a="Fields",onPayload:r,validate:t=!0,onValidityChange:p,variableGroups:i,initialValues:c,initialFormulaConfig:m,initialConditionConfig:y}){const[B,x]=h.useState(!1),[n,f]=h.useState(!1),[u,v]=h.useState(null),[g,w]=h.useState(m??{}),[T,k]=h.useState(y??{}),R=h.useRef(c??{}),A=h.useMemo(()=>se(l),[l]),$=h.useMemo(()=>c&&Object.keys(c).length>0?{...A,...c}:A,[A,c]),M=h.useMemo(()=>t?N.buildValidationSchema(l):void 0,[t,l]);h.useEffect(()=>{r&&r({schema:l,formulaConfig:g,conditionConfig:T,conditionExpressions:N.serializeConditionExpressions(T),values:R.current,evaluationPayload:N.buildEvaluationPayload({values:R.current,conditionConfig:T})})},[T,g,l]);const V=h.useCallback(z=>{R.current=z,r&&r({schema:l,formulaConfig:g,conditionConfig:T,conditionExpressions:N.serializeConditionExpressions(T),values:z,evaluationPayload:N.buildEvaluationPayload({values:z,conditionConfig:T})})},[l,g,T,r]);function P(z){s([...l,z])}function q(z){if(!u)return;const{containerFieldId:D,tabId:H}=u,U=l.map(I=>{if((I.id??I.name)!==D)return I;const Y=I.tabs??[];return{...I,tabs:Y.map(O=>O.id===H?{...O,fields:[...O.fields??[],z]}:O)}});s(U),v(null)}function C(z,D,H){const U=l.map(I=>{if((I.id??I.name)!==z)return I;const Y=I.tabs??[];return{...I,tabs:Y.map(O=>O.id===D?{...O,fields:(O.fields??[]).filter((Be,te)=>te!==H)}:O)}});s(U)}const ne=h.useMemo(()=>({openAddFieldDialog:(z,D)=>v({containerFieldId:z,tabId:D}),removeFieldFromTab:C}),[l,s]),K=e.jsxs("div",{className:"schema-builder-root",children:[l.length>0&&e.jsx("div",{className:"schema-builder-header",children:e.jsxs("div",{className:"schema-builder-actions",children:[e.jsx(o.Tooltip,{title:"Edit schema",placement:"top",children:e.jsxs("button",{className:"sb-btn sb-btn-outline",onClick:()=>f(!0),children:[e.jsx(S.MdSettings,{size:13})," Edit Schema"]})}),e.jsx(o.Tooltip,{title:"Add a new field",placement:"top",children:e.jsxs("button",{className:"sb-btn sb-btn-primary",onClick:()=>x(!0),children:[e.jsx(S.MdAdd,{size:14})," Add Field"]})})]})}),l.length>0?e.jsx(N.TabsEditContext.Provider,{value:ne,children:e.jsx(N.FlowForm,{schema:{layout:"flat",fields:l},initialValues:$,onSubmit:()=>{},validationSchema:M,onValidityChange:p,onValuesChange:r?V:void 0,formulaConfig:g,onFormulaConfigChange:w,conditionConfig:T,onConditionConfigChange:k})}):e.jsxs("div",{className:"schema-builder-empty-state",children:[e.jsx(ie.FaWpforms,{size:40,className:"schema-builder-empty-icon"}),e.jsx("p",{className:"schema-builder-empty-title",children:"Tell us what fields should be in the list, and assign values to them."}),e.jsx("div",{className:"schema-builder-empty-actions",children:e.jsx("button",{className:"btn",onClick:()=>x(!0),children:"Add field"})})]}),e.jsx(J,{open:B,onSave:P,onClose:()=>x(!1)}),e.jsx(ve,{open:n,value:l,onSave:s,onClose:()=>f(!1)}),e.jsx(J,{open:!!u,onSave:q,onClose:()=>v(null)})]});return i?e.jsxs(N.VariablePickerProvider,{groups:i,children:[e.jsx(N.VariablePicker,{width:260,mode:"popover"}),K]}):K}function Ce({fields:l,onOpen:s}){return e.jsxs(o.Box,{sx:{border:"1px solid #e2e8f0",borderRadius:"8px",bgcolor:"#fff",overflow:"hidden"},children:[l.length>0?e.jsx(o.Box,{sx:{px:1.5,py:1.25,display:"flex",flexWrap:"wrap",gap:.5},children:l.map((d,a)=>{const r=d.id??d.name??"";return e.jsx(o.Tooltip,{title:`${d.type} · ${r}`,placement:"top",children:e.jsx(o.Chip,{label:d.label||r,size:"small",sx:{fontSize:11,fontWeight:500,height:22,bgcolor:"#f1f5f9",color:"#334155",border:"1px solid #e2e8f0","& .MuiChip-label":{px:1}}})},a)})}):e.jsx(o.Box,{sx:{px:1.5,py:1.5},children:e.jsx(o.Typography,{sx:{fontSize:12,color:"#94a3b8"},children:"No fields defined yet"})}),e.jsx(o.Divider,{sx:{borderColor:"#f1f5f9"}}),e.jsxs(o.Box,{onClick:s,sx:{display:"flex",alignItems:"center",gap:.75,px:1.5,py:1,cursor:"pointer","&:hover":{bgcolor:"#f8fafc"},transition:"background 0.12s"},children:[l.length===0?e.jsx(S.MdAdd,{size:14,color:"#6366f1"}):e.jsx(S.MdSettings,{size:13,color:"#6366f1"}),e.jsx(o.Typography,{sx:{fontSize:12,fontWeight:600,color:"#6366f1",flex:1},children:l.length===0?"Add fields":"Configure fields"}),e.jsx(S.MdArrowForward,{size:13,color:"#94a3b8"})]})]})}function Se({value:l,onChange:s,suggestions:d,onPayload:a,onDone:r,validate:t,onValidityChange:p,label:i="Fields",drawerTitle:c="Configure Fields",drawerWidth:m=580}){const[y,B]=h.useState(!1),[x,n]=h.useState({type:"list"}),[f,u]=h.useState(l),v=h.useRef(null),g=h.useRef(void 0),w=h.useRef(void 0),T=h.useRef(void 0),[k,R]=h.useState(null);function A(){u(l),n({type:"list"}),B(!0)}function $(){const C=v.current;C&&(g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig),s(f),B(!1),r==null||r(f,C)}function M(){const C=v.current;C&&(g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig),u(l),B(!1)}function V(){if(x.type!=="edit"||!k)return;const C=[...f];C[x.index]=k,u(C),n({type:"list"}),R(null)}function P(){n({type:"list"}),R(null)}const q=JSON.stringify(f)!==JSON.stringify(l);return x.type==="edit"&&f[x.index],e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{sx:{fontSize:12,fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:.5,mb:.75},children:i}),e.jsx(Ce,{fields:l,onOpen:A})]}),e.jsxs(o.Drawer,{anchor:"right",open:y,onClose:M,PaperProps:{sx:{width:m,display:"flex",flexDirection:"column",boxShadow:"-4px 0 24px rgba(0,0,0,0.12)",overflow:"hidden"}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:2,py:1.5,borderBottom:"1px solid #e2e8f0",flexShrink:0,gap:1},children:[x.type==="edit"&&e.jsx(o.Tooltip,{title:"Back to fields",placement:"bottom",children:e.jsx(o.IconButton,{size:"small",onClick:P,sx:{color:"#64748b"},children:e.jsx(S.MdArrowBack,{size:17})})}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a"},children:x.type==="edit"?(k==null?void 0:k.label)||(k==null?void 0:k.id)||"Edit field":c}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#94a3b8"},children:x.type==="edit"?"Configure field properties":`${f.length} field${f.length!==1?"s":""} defined`})]}),x.type==="list"&&e.jsx(o.Tooltip,{title:"Close",placement:"bottom",children:e.jsx(o.IconButton,{size:"small",onClick:M,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})})]}),x.type==="list"&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",p:2.5},children:e.jsx(W,{value:f,onChange:u,suggestions:d,onPayload:C=>{v.current=C,g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig,a==null||a(C)},validate:t,onValidityChange:p,label:i,initialValues:g.current,initialFormulaConfig:w.current,initialConditionConfig:T.current})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[q?e.jsx(o.Typography,{sx:{fontSize:11,color:"#f59e0b",fontWeight:500,flex:1},children:"Unsaved changes"}):e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:M,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:$,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Done"]})]})]}),x.type==="edit"&&k&&e.jsx(le,{field:k,onChange:R,onSave:V,onCancel:P})]})]})}exports.FIELD_TYPE_OPTIONS=Z;exports.SchemaBuilder=W;exports.SchemaBuilderDrawer=Se;exports.useFlowForm=ae;
|