treege 3.0.0-beta.39 → 3.0.0-beta.40
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/DefaultInputs-8yJMEyMh.js +1557 -0
- package/dist/ThemeContext-Ejgu9Mwr.js +1603 -0
- package/dist/editor/constants/nodeTypes.d.ts +3 -3
- package/dist/editor/context/TreegeEditorContext.d.ts +18 -1
- package/dist/editor/features/TreegeEditor/dialogs/ChangeNodeTypeDialog.d.ts +2 -0
- package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/components/NodeInputPreview.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +7 -0
- package/dist/editor/hooks/useFlowActions.d.ts +2 -2
- package/dist/editor/utils/edge.d.ts +14 -0
- package/dist/{editor-CAj1BX2r.js → editor-DWJ95r4g.js} +1340 -1114
- package/dist/editor.js +2 -2
- package/dist/main.js +4 -5
- package/dist/renderer/utils/node.d.ts +9 -0
- package/dist/renderer-native.js +680 -681
- package/dist/renderer.js +3 -4
- package/dist/shared/locales/ar.json.d.ts +7 -0
- package/dist/shared/locales/de.json.d.ts +7 -0
- package/dist/shared/locales/en.json.d.ts +7 -0
- package/dist/shared/locales/es.json.d.ts +7 -0
- package/dist/shared/locales/fr.json.d.ts +7 -0
- package/dist/shared/locales/it.json.d.ts +7 -0
- package/dist/shared/locales/pt.json.d.ts +7 -0
- package/package.json +1 -1
- package/dist/ThemeContext-PGG6Ht__.js +0 -813
- package/dist/editor/features/TreegeEditor/inputs/SelectInputType.d.ts +0 -7
- package/dist/editor/features/TreegeEditor/nodes/components/InputTypeBadge.d.ts +0 -7
- package/dist/renderer-BOjgk8F8.js +0 -1199
- package/dist/separator-Cdfv5nIR.js +0 -351
- package/dist/useRenderNode-OgRe_mb5.js +0 -775
|
@@ -1,775 +0,0 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, i as r, l as i, r as a, s as o, u as s } from "./ThemeContext-PGG6Ht__.js";
|
|
2
|
-
import { jsx as c } from "react/jsx-runtime";
|
|
3
|
-
import { Fragment as l, createContext as u, useCallback as d, useContext as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
4
|
-
import _ from "dompurify";
|
|
5
|
-
//#region src/renderer/context/TreegeConfigContext.tsx
|
|
6
|
-
var v = u(void 0), y = () => f(v), b = ({ children: e, components: t, googleApiKey: n, language: r, theme: i, validationMode: a }) => {
|
|
7
|
-
let o = {
|
|
8
|
-
components: t,
|
|
9
|
-
googleApiKey: n,
|
|
10
|
-
language: r,
|
|
11
|
-
theme: i,
|
|
12
|
-
validationMode: a
|
|
13
|
-
};
|
|
14
|
-
return /* @__PURE__ */ c(v.Provider, {
|
|
15
|
-
value: o,
|
|
16
|
-
children: e
|
|
17
|
-
});
|
|
18
|
-
}, x = (e) => e.filter(s), S = (e) => {
|
|
19
|
-
if (e.data.name) return e.data.name;
|
|
20
|
-
if (e.data.label) {
|
|
21
|
-
if (e.data.label.en) return e.data.label.en;
|
|
22
|
-
let t = Object.values(e.data.label).find(Boolean);
|
|
23
|
-
if (t) return t;
|
|
24
|
-
}
|
|
25
|
-
return e.id;
|
|
26
|
-
}, C = (e, t) => {
|
|
27
|
-
let n = t.find((t) => t.id === e);
|
|
28
|
-
return n ? S(n) : void 0;
|
|
29
|
-
}, w = (e) => e == null || typeof e == "string" && e.trim() === "" ? !0 : Array.isArray(e) && e.length === 0, T = (e, t) => e ? t[e] != null : !1, E = (e, t) => {
|
|
30
|
-
let n = {};
|
|
31
|
-
return t.forEach((t) => {
|
|
32
|
-
let r = t.id, i = S(t);
|
|
33
|
-
e[r] !== void 0 && (n[i] = e[r]);
|
|
34
|
-
}), n;
|
|
35
|
-
}, D = (e, t, n) => {
|
|
36
|
-
if (!t) return e;
|
|
37
|
-
switch (t) {
|
|
38
|
-
case "toString": return String(e);
|
|
39
|
-
case "toNumber": return Number(e);
|
|
40
|
-
case "toBoolean":
|
|
41
|
-
if (typeof e == "string") {
|
|
42
|
-
let t = e.trim().toLowerCase();
|
|
43
|
-
if ([
|
|
44
|
-
"true",
|
|
45
|
-
"1",
|
|
46
|
-
"yes",
|
|
47
|
-
"on"
|
|
48
|
-
].includes(t)) return !0;
|
|
49
|
-
if ([
|
|
50
|
-
"false",
|
|
51
|
-
"0",
|
|
52
|
-
"no",
|
|
53
|
-
"off",
|
|
54
|
-
""
|
|
55
|
-
].includes(t)) return !1;
|
|
56
|
-
}
|
|
57
|
-
return typeof e == "number" ? e !== 0 : typeof e == "boolean" ? e : !!e;
|
|
58
|
-
case "toArray": return Array.isArray(e) ? e : [e];
|
|
59
|
-
case "toObject":
|
|
60
|
-
if (n && Array.isArray(n)) {
|
|
61
|
-
if (typeof e != "object" || !e) return e;
|
|
62
|
-
let t = {};
|
|
63
|
-
return n.forEach((n) => {
|
|
64
|
-
n.sourceKey && n.targetKey && (t[n.targetKey] = e[n.sourceKey]);
|
|
65
|
-
}), t;
|
|
66
|
-
}
|
|
67
|
-
return e;
|
|
68
|
-
default: return e;
|
|
69
|
-
}
|
|
70
|
-
}, O = (e, t) => {
|
|
71
|
-
if (Object.is(e, t)) return !0;
|
|
72
|
-
if (!(e && t) || typeof e != "object" || typeof t != "object") return !1;
|
|
73
|
-
try {
|
|
74
|
-
return JSON.stringify(e) === JSON.stringify(t);
|
|
75
|
-
} catch {
|
|
76
|
-
return !1;
|
|
77
|
-
}
|
|
78
|
-
}, k = (e, t, n) => {
|
|
79
|
-
let r = {};
|
|
80
|
-
return e.forEach((e) => {
|
|
81
|
-
let { defaultValue: i } = e.data;
|
|
82
|
-
if (!i || i.type !== "reference" || !i.referenceField) return;
|
|
83
|
-
let a = e.id, { referenceField: o, transformFunction: s, objectMapping: c } = i, l = t[o], u = n[o];
|
|
84
|
-
if (l === u || l == null) return;
|
|
85
|
-
let d = D(l, s, c), f = D(u, s, c), p = t[a], m = O(p, f), h = O(p, d);
|
|
86
|
-
!m || h || (r[a] = d);
|
|
87
|
-
}), r;
|
|
88
|
-
}, A = [
|
|
89
|
-
"b",
|
|
90
|
-
"i",
|
|
91
|
-
"em",
|
|
92
|
-
"strong",
|
|
93
|
-
"u",
|
|
94
|
-
"br",
|
|
95
|
-
"p",
|
|
96
|
-
"span"
|
|
97
|
-
], j = ["class"], M = (e, t = {}) => {
|
|
98
|
-
if (e == null || e === "") return "";
|
|
99
|
-
let n = String(e), { plainTextOnly: r = !0, allowedTags: i, allowedAttributes: a } = t;
|
|
100
|
-
if (r) return _.sanitize(n, {
|
|
101
|
-
ALLOWED_ATTR: [],
|
|
102
|
-
ALLOWED_TAGS: []
|
|
103
|
-
});
|
|
104
|
-
let o = i ?? A, s = a ?? j;
|
|
105
|
-
return _.sanitize(n, {
|
|
106
|
-
ALLOW_DATA_ATTR: !1,
|
|
107
|
-
ALLOW_UNKNOWN_PROTOCOLS: !1,
|
|
108
|
-
ALLOWED_ATTR: s,
|
|
109
|
-
ALLOWED_TAGS: o,
|
|
110
|
-
FORBID_ATTR: ["style"],
|
|
111
|
-
FORBID_TAGS: ["style", "script"],
|
|
112
|
-
KEEP_CONTENT: !0,
|
|
113
|
-
RETURN_DOM: !1,
|
|
114
|
-
RETURN_DOM_FRAGMENT: !1
|
|
115
|
-
});
|
|
116
|
-
}, N = 100, P = (e, t = {}, n = 0, r = /* @__PURE__ */ new WeakSet()) => {
|
|
117
|
-
if (n > N) return console.warn(`sanitizeHttpResponse: Maximum depth (${N}) exceeded.`), typeof e == "string" ? M(e, t) : "[Max Depth Exceeded]";
|
|
118
|
-
if (e == null) return e;
|
|
119
|
-
if (typeof e == "string") return M(e, t);
|
|
120
|
-
if (Array.isArray(e)) return e.map((e) => P(e, t, n + 1, r));
|
|
121
|
-
if (typeof e == "object") {
|
|
122
|
-
if (r.has(e)) return console.warn("sanitizeHttpResponse: Circular reference detected. Breaking cycle to prevent infinite recursion."), "[Circular Reference]";
|
|
123
|
-
r.add(e);
|
|
124
|
-
let i = {};
|
|
125
|
-
for (let [a, o] of Object.entries(e)) i[a] = P(o, t, n + 1, r);
|
|
126
|
-
return r.delete(e), i;
|
|
127
|
-
}
|
|
128
|
-
return e;
|
|
129
|
-
}, F = async (e) => {
|
|
130
|
-
try {
|
|
131
|
-
let { url: t, method: n = "GET", headers: r = [], body: i } = e;
|
|
132
|
-
if (!t || t.trim() === "") return {
|
|
133
|
-
error: "No URL provided",
|
|
134
|
-
success: !1
|
|
135
|
-
};
|
|
136
|
-
let a = { "Content-Type": "application/json" };
|
|
137
|
-
r.forEach((e) => {
|
|
138
|
-
e.key && e.value && (a[e.key] = e.value);
|
|
139
|
-
});
|
|
140
|
-
let o = {
|
|
141
|
-
headers: a,
|
|
142
|
-
method: n
|
|
143
|
-
};
|
|
144
|
-
i && n && [
|
|
145
|
-
"POST",
|
|
146
|
-
"PUT",
|
|
147
|
-
"PATCH"
|
|
148
|
-
].includes(n) && (o.body = i);
|
|
149
|
-
let s = await fetch(t, o), c;
|
|
150
|
-
return c = s.headers.get("content-type")?.includes("application/json") ? await s.json() : await s.text(), s.ok ? {
|
|
151
|
-
data: c,
|
|
152
|
-
status: s.status,
|
|
153
|
-
statusText: s.statusText,
|
|
154
|
-
success: !0
|
|
155
|
-
} : {
|
|
156
|
-
data: c,
|
|
157
|
-
error: `HTTP ${s.status}: ${s.statusText}`,
|
|
158
|
-
status: s.status,
|
|
159
|
-
statusText: s.statusText,
|
|
160
|
-
success: !1
|
|
161
|
-
};
|
|
162
|
-
} catch (e) {
|
|
163
|
-
return {
|
|
164
|
-
error: e instanceof Error ? e.message : "An unknown error occurred",
|
|
165
|
-
success: !1
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}, I = (e, t, n = {}) => {
|
|
169
|
-
if (!e) return "";
|
|
170
|
-
let { encode: r = !1, json: i = !1 } = n;
|
|
171
|
-
return e.replace(/\{\{([\w-]+)}}/g, (e, n) => {
|
|
172
|
-
let a = t[n.trim()];
|
|
173
|
-
if (a == null) return i ? "null" : "";
|
|
174
|
-
let o = typeof a == "string" ? M(a) : a;
|
|
175
|
-
if (r) return encodeURIComponent(String(o));
|
|
176
|
-
if (i) {
|
|
177
|
-
if (typeof o == "string") return `"${o.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
178
|
-
if (typeof o == "number" || typeof o == "boolean") return String(o);
|
|
179
|
-
if (typeof o == "object") return JSON.stringify(o);
|
|
180
|
-
}
|
|
181
|
-
return String(o);
|
|
182
|
-
});
|
|
183
|
-
}, L = (e, t) => e ? e.replace(/\{\{response\.([\w.-]+)}}/g, (e, n) => {
|
|
184
|
-
let r = R(t, n.trim());
|
|
185
|
-
return r == null ? "" : String(r);
|
|
186
|
-
}) : "", R = (e, t) => {
|
|
187
|
-
if (!(!e || typeof e != "object")) return t.split(".").reduce((e, t) => {
|
|
188
|
-
if (!(typeof e != "object" || !e)) return e[t];
|
|
189
|
-
}, e);
|
|
190
|
-
}, z = async (e, t, n) => {
|
|
191
|
-
if (!e.url || e.url.trim() === "") return {
|
|
192
|
-
error: "No URL configured for submission",
|
|
193
|
-
success: !1
|
|
194
|
-
};
|
|
195
|
-
let r = I(e.url, t, { encode: !0 });
|
|
196
|
-
if (!r || r.trim() === "") return {
|
|
197
|
-
error: "Invalid URL after template replacement",
|
|
198
|
-
success: !1
|
|
199
|
-
};
|
|
200
|
-
let i = e.headers?.map((e) => ({
|
|
201
|
-
key: e.key,
|
|
202
|
-
value: I(e.value, t)
|
|
203
|
-
})), a = await F({
|
|
204
|
-
body: e.sendAllFormValues ? JSON.stringify(E(t, n)) : e.body ? I(e.body, t, { json: !0 }) : void 0,
|
|
205
|
-
headers: i,
|
|
206
|
-
method: e.method || "POST",
|
|
207
|
-
url: r
|
|
208
|
-
});
|
|
209
|
-
if (!a.success) return {
|
|
210
|
-
data: a.data,
|
|
211
|
-
error: a.error,
|
|
212
|
-
success: !1
|
|
213
|
-
};
|
|
214
|
-
let o = e.redirectUrl ? (() => {
|
|
215
|
-
let t = L(e.redirectUrl, a.data);
|
|
216
|
-
return t && t.trim() !== "" ? t : void 0;
|
|
217
|
-
})() : void 0;
|
|
218
|
-
return {
|
|
219
|
-
data: a.data,
|
|
220
|
-
redirectUrl: o,
|
|
221
|
-
success: !0
|
|
222
|
-
};
|
|
223
|
-
}, B = (e) => {
|
|
224
|
-
e && (e.startsWith("http://") || e.startsWith("https://") ? window.location.href = e : window.history?.pushState ? (window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"))) : window.location.href = e);
|
|
225
|
-
}, ee = (e, t, n, r) => {
|
|
226
|
-
let [i, a] = g(!1), [c, l] = g(null), u = m(() => {
|
|
227
|
-
let t = e.find((e) => s(e) && e.data?.type === "submit");
|
|
228
|
-
return t && s(t) ? t : null;
|
|
229
|
-
}, [e]), f = d(async (e) => {
|
|
230
|
-
if (!u?.data?.submitConfig) return null;
|
|
231
|
-
let i = u.data.submitConfig;
|
|
232
|
-
if (!i.url || i.url.trim() === "") return null;
|
|
233
|
-
l(null), i.showLoading !== !1 && a(!0);
|
|
234
|
-
try {
|
|
235
|
-
let a = await z(i, t, r);
|
|
236
|
-
if (a.success) {
|
|
237
|
-
let t = o(i.successMessage, n);
|
|
238
|
-
if (t && l({
|
|
239
|
-
message: t,
|
|
240
|
-
type: "success"
|
|
241
|
-
}), e && e(a.data), a.redirectUrl) {
|
|
242
|
-
let e = a.redirectUrl;
|
|
243
|
-
setTimeout(() => B(e), 1e3);
|
|
244
|
-
}
|
|
245
|
-
} else l({
|
|
246
|
-
message: o(i.errorMessage, n) || a.error || "An error occurred during submission",
|
|
247
|
-
type: "error"
|
|
248
|
-
});
|
|
249
|
-
return a;
|
|
250
|
-
} catch (e) {
|
|
251
|
-
let t = o(i.errorMessage, n) || (e instanceof Error ? e.message : "An unexpected error occurred");
|
|
252
|
-
return l({
|
|
253
|
-
message: t,
|
|
254
|
-
type: "error"
|
|
255
|
-
}), {
|
|
256
|
-
error: t,
|
|
257
|
-
success: !1
|
|
258
|
-
};
|
|
259
|
-
} finally {
|
|
260
|
-
a(!1);
|
|
261
|
-
}
|
|
262
|
-
}, [
|
|
263
|
-
u,
|
|
264
|
-
t,
|
|
265
|
-
n,
|
|
266
|
-
r
|
|
267
|
-
]);
|
|
268
|
-
return {
|
|
269
|
-
clearSubmitMessage: d(() => {
|
|
270
|
-
l(null);
|
|
271
|
-
}, []),
|
|
272
|
-
handleSubmitWithConfig: f,
|
|
273
|
-
hasSubmitConfig: !!u?.data?.submitConfig,
|
|
274
|
-
isSubmitting: i,
|
|
275
|
-
submitButtonNode: u,
|
|
276
|
-
submitMessage: c
|
|
277
|
-
};
|
|
278
|
-
}, V = (e) => e == null ? null : typeof e == "boolean" || typeof e == "number" ? e : typeof e == "string" ? e === "" ? null : e : typeof e == "object" ? JSON.stringify(e) : String(e), H = (e, t, n) => {
|
|
279
|
-
let r = V(e), i = V(t);
|
|
280
|
-
if (r === null || i === null) switch (n) {
|
|
281
|
-
case "===": return r === i;
|
|
282
|
-
case "!==": return r !== i;
|
|
283
|
-
default: return !1;
|
|
284
|
-
}
|
|
285
|
-
if ([
|
|
286
|
-
">",
|
|
287
|
-
"<",
|
|
288
|
-
">=",
|
|
289
|
-
"<="
|
|
290
|
-
].includes(n)) {
|
|
291
|
-
let e = Number(r), t = Number(i);
|
|
292
|
-
if (!(Number.isNaN(e) || Number.isNaN(t))) switch (n) {
|
|
293
|
-
case ">": return e > t;
|
|
294
|
-
case "<": return e < t;
|
|
295
|
-
case ">=": return e >= t;
|
|
296
|
-
case "<=": return e <= t;
|
|
297
|
-
default: return !1;
|
|
298
|
-
}
|
|
299
|
-
return !1;
|
|
300
|
-
}
|
|
301
|
-
switch (n) {
|
|
302
|
-
case "===": {
|
|
303
|
-
let e = Number(r), t = Number(i);
|
|
304
|
-
return Number.isNaN(e) || Number.isNaN(t) ? String(r) === String(i) : e === t;
|
|
305
|
-
}
|
|
306
|
-
case "!==": {
|
|
307
|
-
let e = Number(r), t = Number(i);
|
|
308
|
-
return Number.isNaN(e) || Number.isNaN(t) ? String(r) !== String(i) : e !== t;
|
|
309
|
-
}
|
|
310
|
-
default: return !1;
|
|
311
|
-
}
|
|
312
|
-
}, U = (e, t, n) => {
|
|
313
|
-
let { field: r, operator: i, value: a } = e;
|
|
314
|
-
if (!(r && i) || a === void 0) return !0;
|
|
315
|
-
let o = t[r];
|
|
316
|
-
if (o === void 0 && n) {
|
|
317
|
-
let e = n.get(r);
|
|
318
|
-
e && s(e) && (o = t[e.id]);
|
|
319
|
-
}
|
|
320
|
-
return H(o, a, i);
|
|
321
|
-
}, W = (e, t, n) => {
|
|
322
|
-
if (!e || e.length === 0) return !0;
|
|
323
|
-
if (e.length === 1) return U(e[0], t, n);
|
|
324
|
-
let i = U(e[0], t, n);
|
|
325
|
-
for (let a = 1; a < e.length; a += 1) {
|
|
326
|
-
let o = e[a], s = U(o, t, n), c = e[a - 1].logicalOperator || r.AND;
|
|
327
|
-
if (c === r.AND) {
|
|
328
|
-
if (i &&= s, !i) return !1;
|
|
329
|
-
} else if (c === r.OR && (i ||= s, i)) return !0;
|
|
330
|
-
}
|
|
331
|
-
return i;
|
|
332
|
-
}, G = (e) => {
|
|
333
|
-
let t = /* @__PURE__ */ new Map();
|
|
334
|
-
return e.forEach((e) => {
|
|
335
|
-
let n = t.get(e.source);
|
|
336
|
-
n ? n.push(e) : t.set(e.source, [e]);
|
|
337
|
-
}), t;
|
|
338
|
-
}, K = (e, t, n) => {
|
|
339
|
-
let r = [], i = [], a = [];
|
|
340
|
-
e.forEach((e) => {
|
|
341
|
-
let t = e.data?.isFallback, n = e.data?.conditions?.length;
|
|
342
|
-
t ? a.push(e) : n ? i.push(e) : r.push(e);
|
|
343
|
-
});
|
|
344
|
-
let o = [...r];
|
|
345
|
-
if (i.length === 0) return a.length > 0 && o.length === 0 && o.push(...a), {
|
|
346
|
-
edgesToFollow: o,
|
|
347
|
-
waitingForInput: !1
|
|
348
|
-
};
|
|
349
|
-
if (!i.every((e) => {
|
|
350
|
-
let r = e.data?.conditions;
|
|
351
|
-
return r ? r.every((e) => {
|
|
352
|
-
if (!e.field) return !0;
|
|
353
|
-
let r = n.get(e.field);
|
|
354
|
-
return T(s(r) ? r.id : e.field, t);
|
|
355
|
-
}) : !1;
|
|
356
|
-
})) return a.length > 0 && o.push(...a), {
|
|
357
|
-
edgesToFollow: o,
|
|
358
|
-
waitingForInput: o.length === 0
|
|
359
|
-
};
|
|
360
|
-
let c = i.filter((e) => W(e.data?.conditions, t, n));
|
|
361
|
-
return c.length > 0 ? (o.push(...c), {
|
|
362
|
-
edgesToFollow: o,
|
|
363
|
-
waitingForInput: !1
|
|
364
|
-
}) : (o.push(...a), {
|
|
365
|
-
edgesToFollow: o,
|
|
366
|
-
waitingForInput: !1
|
|
367
|
-
});
|
|
368
|
-
}, q = (e, t) => !t.some((t) => t.target === e), J = (e, t) => {
|
|
369
|
-
let n = e.filter((e) => q(e.id, t));
|
|
370
|
-
return n.find(s) || n[0];
|
|
371
|
-
}, Y = (e, t, n, r) => {
|
|
372
|
-
e.forEach((e) => {
|
|
373
|
-
let i = r.get(e);
|
|
374
|
-
if (!i) return;
|
|
375
|
-
let { parentId: a } = i, o = /* @__PURE__ */ new Set();
|
|
376
|
-
for (; a && !o.has(a);) {
|
|
377
|
-
if (o.add(a), t.add(a), !n.has(a)) {
|
|
378
|
-
let t = n.get(e);
|
|
379
|
-
t !== void 0 && n.set(a, t);
|
|
380
|
-
}
|
|
381
|
-
a = r.get(a)?.parentId;
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
}, X = (e, t, n) => {
|
|
385
|
-
let r = J(e, t);
|
|
386
|
-
if (!r) return {
|
|
387
|
-
endOfPathReached: !0,
|
|
388
|
-
visibleNodeIds: /* @__PURE__ */ new Set(),
|
|
389
|
-
visibleNodes: [],
|
|
390
|
-
visibleRootNodes: []
|
|
391
|
-
};
|
|
392
|
-
let i = new Map(e.map((e) => [e.id, e])), a = G(t), o = [], s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = !1, u = (e) => {
|
|
393
|
-
if (c.has(e)) return;
|
|
394
|
-
c.add(e);
|
|
395
|
-
let t = i.get(e);
|
|
396
|
-
if (!t) return;
|
|
397
|
-
s.add(e), o.push(t);
|
|
398
|
-
let { edgesToFollow: r, waitingForInput: d } = K(a.get(e) || [], n, i);
|
|
399
|
-
if (d) {
|
|
400
|
-
l = !0;
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
r.forEach((e) => {
|
|
404
|
-
u(e.target);
|
|
405
|
-
});
|
|
406
|
-
};
|
|
407
|
-
u(r.id);
|
|
408
|
-
let d = new Map(o.map((e, t) => [e.id, t])), f = new Set(s);
|
|
409
|
-
Y(s, f, d, i);
|
|
410
|
-
let p = e.filter((e) => f.has(e.id)).sort((e, t) => (d.get(e.id) ?? 2 ** 53 - 1) - (d.get(t.id) ?? 2 ** 53 - 1)), m = p.filter((e) => !(e.parentId && f.has(e.parentId)));
|
|
411
|
-
return {
|
|
412
|
-
endOfPathReached: !l,
|
|
413
|
-
visibleNodeIds: f,
|
|
414
|
-
visibleNodes: p,
|
|
415
|
-
visibleRootNodes: m
|
|
416
|
-
};
|
|
417
|
-
}, Z = (e) => {
|
|
418
|
-
if (e.length === 1) return e[0];
|
|
419
|
-
let n = new Set(e.map((e) => e.id)), r = /* @__PURE__ */ new Set();
|
|
420
|
-
return e.forEach((e) => {
|
|
421
|
-
e.nodes.forEach((e) => {
|
|
422
|
-
if (t(e)) {
|
|
423
|
-
let t = e.data.targetId;
|
|
424
|
-
t && n.has(t) && r.add(t);
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
}), e.find((e) => !r.has(e.id)) || e[0];
|
|
428
|
-
}, Q = (e, t, n, r, i = /* @__PURE__ */ new Set()) => {
|
|
429
|
-
let a = /* @__PURE__ */ new Set();
|
|
430
|
-
for (let o of e) if (n.has(o)) {
|
|
431
|
-
let e = r.get(o), s = e ? t.get(e) : void 0;
|
|
432
|
-
if (s) {
|
|
433
|
-
if (e && i.has(e)) continue;
|
|
434
|
-
e && i.add(e);
|
|
435
|
-
let o = Q(new Set(s.nodes.map((e) => e.id)), t, n, r, i);
|
|
436
|
-
for (let e of o) a.add(e);
|
|
437
|
-
}
|
|
438
|
-
} else a.add(o);
|
|
439
|
-
return a;
|
|
440
|
-
}, te = (e, t) => {
|
|
441
|
-
let n = /* @__PURE__ */ new Set();
|
|
442
|
-
return t.forEach((t) => {
|
|
443
|
-
e.has(t.source) && e.has(t.target) && n.add(t.source);
|
|
444
|
-
}), Array.from(e).filter((e) => !n.has(e));
|
|
445
|
-
}, $ = (e) => {
|
|
446
|
-
if (!e) return {
|
|
447
|
-
edges: [],
|
|
448
|
-
id: "empty",
|
|
449
|
-
nodes: []
|
|
450
|
-
};
|
|
451
|
-
let n = Array.isArray(e) ? e : [e];
|
|
452
|
-
if (n.length === 0) return {
|
|
453
|
-
edges: [],
|
|
454
|
-
id: "empty",
|
|
455
|
-
nodes: []
|
|
456
|
-
};
|
|
457
|
-
let r = Z(n);
|
|
458
|
-
if (n.length === 1) return r;
|
|
459
|
-
let i = new Map(n.map((e) => [e.id, e])), a = [], o = [...r.edges], s = new Set([r.id]), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), d = (e) => {
|
|
460
|
-
let n = [];
|
|
461
|
-
return e.forEach((e) => {
|
|
462
|
-
if (!t(e)) {
|
|
463
|
-
n.push(e);
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
let r = e.data.targetId;
|
|
467
|
-
if (!r) return;
|
|
468
|
-
let a = i.get(r);
|
|
469
|
-
if (!a) {
|
|
470
|
-
console.warn(`Flow with id "${r}" not found`);
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
let u = a.nodes.find((e) => !e.parentId);
|
|
474
|
-
if (!u) {
|
|
475
|
-
console.warn(`Flow "${r}" has no root node; preserving FlowNode "${e.id}"`), n.push(e);
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
c.set(e.id, u.id), l.set(e.id, r), s.has(r) || (s.add(r), o.push(...a.edges), n.push(...d(a.nodes)));
|
|
479
|
-
}), n;
|
|
480
|
-
};
|
|
481
|
-
a.push(...d(r.nodes)), o.forEach((e) => {
|
|
482
|
-
if (c.has(e.source)) {
|
|
483
|
-
let t = u.get(e.source);
|
|
484
|
-
t ? t.push(e) : u.set(e.source, [e]);
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
let f = o.map((e) => {
|
|
488
|
-
if (c.has(e.source)) return null;
|
|
489
|
-
let t = c.get(e.target);
|
|
490
|
-
return t ? {
|
|
491
|
-
...e,
|
|
492
|
-
target: t
|
|
493
|
-
} : e;
|
|
494
|
-
}).filter((e) => e !== null);
|
|
495
|
-
return c.forEach((e, t) => {
|
|
496
|
-
let n = u.get(t);
|
|
497
|
-
if (!n?.length) return;
|
|
498
|
-
let r = l.get(t), a = r ? i.get(r) : void 0;
|
|
499
|
-
a && te(Q(new Set(a.nodes.map((e) => e.id)), i, c, l, new Set(r ? [r] : [])), f).forEach((e) => {
|
|
500
|
-
n.forEach((n) => {
|
|
501
|
-
let r = c.get(n.target) ?? n.target, i = n.id ?? `${t}__${n.target}`;
|
|
502
|
-
f.push({
|
|
503
|
-
...n,
|
|
504
|
-
id: `${e}__${i}`,
|
|
505
|
-
source: e,
|
|
506
|
-
target: r
|
|
507
|
-
});
|
|
508
|
-
});
|
|
509
|
-
});
|
|
510
|
-
}), {
|
|
511
|
-
edges: f,
|
|
512
|
-
id: r.id,
|
|
513
|
-
nodes: a
|
|
514
|
-
};
|
|
515
|
-
}, ne = u(null), re = ({ children: e, value: t }) => /* @__PURE__ */ c(ne.Provider, {
|
|
516
|
-
value: t,
|
|
517
|
-
children: e
|
|
518
|
-
}), ie = () => {
|
|
519
|
-
let e = f(ne) ?? {
|
|
520
|
-
flows: null,
|
|
521
|
-
formErrors: {},
|
|
522
|
-
formValues: {},
|
|
523
|
-
googleApiKey: void 0,
|
|
524
|
-
inputNodes: [],
|
|
525
|
-
language: "",
|
|
526
|
-
setFieldValue: () => {}
|
|
527
|
-
}, t = m(() => e.flows ? $(e.flows).edges : [], [e.flows]);
|
|
528
|
-
return {
|
|
529
|
-
...e,
|
|
530
|
-
edges: t
|
|
531
|
-
};
|
|
532
|
-
}, ae = (t) => {
|
|
533
|
-
let n = ie(), r = e(t ?? n.language);
|
|
534
|
-
return m(() => (e) => {
|
|
535
|
-
let t = r(e);
|
|
536
|
-
return typeof e == "object" && e ? M(t) : t;
|
|
537
|
-
}, [r]);
|
|
538
|
-
}, oe = ({ components: e, flows: t, googleApiKey: n, initialValues: r = {}, language: i, onChange: a, onSubmit: o, theme: c, validate: l, validationMode: u }) => {
|
|
539
|
-
let f = y(), _ = m(() => ({
|
|
540
|
-
components: {
|
|
541
|
-
form: e?.form ?? f?.components?.form,
|
|
542
|
-
group: e?.group ?? f?.components?.group,
|
|
543
|
-
inputs: {
|
|
544
|
-
...f?.components?.inputs,
|
|
545
|
-
...e?.inputs
|
|
546
|
-
},
|
|
547
|
-
submitButton: e?.submitButton ?? f?.components?.submitButton,
|
|
548
|
-
submitButtonWrapper: e?.submitButtonWrapper ?? f?.components?.submitButtonWrapper,
|
|
549
|
-
ui: {
|
|
550
|
-
...f?.components?.ui,
|
|
551
|
-
...e?.ui
|
|
552
|
-
}
|
|
553
|
-
},
|
|
554
|
-
googleApiKey: n ?? f?.googleApiKey,
|
|
555
|
-
language: i ?? f?.language ?? "en",
|
|
556
|
-
theme: c ?? f?.theme ?? "dark",
|
|
557
|
-
validationMode: u ?? f?.validationMode ?? "onSubmit"
|
|
558
|
-
}), [
|
|
559
|
-
e,
|
|
560
|
-
f,
|
|
561
|
-
n,
|
|
562
|
-
i,
|
|
563
|
-
c,
|
|
564
|
-
u
|
|
565
|
-
]), v = m(() => $(t), [t]), { nodes: b, edges: S } = v, C = m(() => x(b), [b]), T = ae(_.language), D = h({}), [O, A] = g({}), [j, M] = g(() => {
|
|
566
|
-
let e = { ...r };
|
|
567
|
-
return b.forEach((t) => {
|
|
568
|
-
if (s(t)) {
|
|
569
|
-
let n = t.id;
|
|
570
|
-
if (e[n] !== void 0) return;
|
|
571
|
-
let { defaultValue: r } = t.data;
|
|
572
|
-
if (!r) return;
|
|
573
|
-
if (r.type === "static" && r.staticValue !== void 0 && (e[n] = r.staticValue), r.type === "reference" && r.referenceField) {
|
|
574
|
-
let { referenceField: t } = r, i = e[t];
|
|
575
|
-
i !== void 0 && (e[n] = i);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}), e;
|
|
579
|
-
}), { endOfPathReached: N, visibleNodes: P, visibleRootNodes: F } = m(() => X(b, S, j), [
|
|
580
|
-
b,
|
|
581
|
-
S,
|
|
582
|
-
j
|
|
583
|
-
]), { clearSubmitMessage: I, handleSubmitWithConfig: L, hasSubmitConfig: R, isSubmitting: z, submitMessage: B } = ee(P, j, _.language, C), V = h(a), H = h(l), U = m(() => E(j, C), [j, C]), W = d((e, t) => {
|
|
584
|
-
M((n) => ({
|
|
585
|
-
...n,
|
|
586
|
-
[e]: t
|
|
587
|
-
})), A((t) => {
|
|
588
|
-
let n = { ...t };
|
|
589
|
-
return delete n[e], n;
|
|
590
|
-
});
|
|
591
|
-
}, []), G = d((e) => {
|
|
592
|
-
Object.keys(e).length !== 0 && (M((t) => ({
|
|
593
|
-
...t,
|
|
594
|
-
...e
|
|
595
|
-
})), A((t) => {
|
|
596
|
-
let n = { ...t };
|
|
597
|
-
return Object.keys(e).forEach((e) => {
|
|
598
|
-
delete n[e];
|
|
599
|
-
}), n;
|
|
600
|
-
}));
|
|
601
|
-
}, []), K = d((e) => {
|
|
602
|
-
let t = {};
|
|
603
|
-
P.forEach((e) => {
|
|
604
|
-
if (s(e)) {
|
|
605
|
-
let n = e.id, r = j[n];
|
|
606
|
-
if (e.data.required && w(r)) {
|
|
607
|
-
t[n] = T(e.data.errorMessage) || T("validation.required");
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
if (!w(r) && e.data.pattern) try {
|
|
611
|
-
new RegExp(e.data.pattern).test(String(r)) || (t[n] = T(e.data.errorMessage) || T("validation.invalidFormat"));
|
|
612
|
-
} catch (e) {
|
|
613
|
-
console.error(`Invalid pattern for field ${n}:`, e);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
});
|
|
617
|
-
let n = e ? e(j, P) : {}, r = {
|
|
618
|
-
...t,
|
|
619
|
-
...n
|
|
620
|
-
};
|
|
621
|
-
return A(r), {
|
|
622
|
-
errors: r,
|
|
623
|
-
hasCustomErrors: Object.keys(n).length > 0,
|
|
624
|
-
isValid: Object.keys(r).length === 0
|
|
625
|
-
};
|
|
626
|
-
}, [
|
|
627
|
-
P,
|
|
628
|
-
j,
|
|
629
|
-
T
|
|
630
|
-
]), q = d(async () => {
|
|
631
|
-
let { isValid: e } = K(H.current);
|
|
632
|
-
if (!e) return !1;
|
|
633
|
-
if (R) {
|
|
634
|
-
let e = await L((e) => {
|
|
635
|
-
o && o(U, { httpResponse: e });
|
|
636
|
-
});
|
|
637
|
-
if (e === null) return o?.(U), !0;
|
|
638
|
-
if (!e.success) return !0;
|
|
639
|
-
} else o && o(U);
|
|
640
|
-
return !0;
|
|
641
|
-
}, [
|
|
642
|
-
K,
|
|
643
|
-
R,
|
|
644
|
-
L,
|
|
645
|
-
o,
|
|
646
|
-
U
|
|
647
|
-
]), J = m(() => {
|
|
648
|
-
let e = [];
|
|
649
|
-
return P.forEach((t) => {
|
|
650
|
-
if (!s(t)) return;
|
|
651
|
-
let n = t.id, r = j[n];
|
|
652
|
-
if (t.data.required && w(r)) {
|
|
653
|
-
let r = T(t.data.label) || n;
|
|
654
|
-
e.push(r);
|
|
655
|
-
}
|
|
656
|
-
}), e;
|
|
657
|
-
}, [
|
|
658
|
-
P,
|
|
659
|
-
j,
|
|
660
|
-
T
|
|
661
|
-
]), Y = m(() => P.some((e) => s(e) && e.data.type === "submit"), [P]), Z = m(() => {
|
|
662
|
-
let e = Object.keys(O);
|
|
663
|
-
return e.length > 0 ? e[0] : void 0;
|
|
664
|
-
}, [O]);
|
|
665
|
-
return p(() => {
|
|
666
|
-
V.current = a;
|
|
667
|
-
}, [a]), p(() => {
|
|
668
|
-
H.current = l;
|
|
669
|
-
}, [l]), p(() => {
|
|
670
|
-
V.current?.(U);
|
|
671
|
-
}, [U]), p(() => {
|
|
672
|
-
_.validationMode === "onChange" && K(H.current);
|
|
673
|
-
}, [_.validationMode, K]), p(() => {
|
|
674
|
-
let e = k(C, j, D.current);
|
|
675
|
-
Object.keys(e).length > 0 && G(e), D.current = j;
|
|
676
|
-
}, [
|
|
677
|
-
j,
|
|
678
|
-
C,
|
|
679
|
-
G
|
|
680
|
-
]), {
|
|
681
|
-
canSubmit: !Y && N && b.length > 0,
|
|
682
|
-
clearSubmitMessage: I,
|
|
683
|
-
config: _,
|
|
684
|
-
firstErrorFieldId: Z,
|
|
685
|
-
formErrors: O,
|
|
686
|
-
formValues: j,
|
|
687
|
-
handleSubmit: q,
|
|
688
|
-
inputNodes: C,
|
|
689
|
-
isSubmitting: z,
|
|
690
|
-
mergedFlow: v,
|
|
691
|
-
missingRequiredFields: J,
|
|
692
|
-
prevFormValuesRef: D,
|
|
693
|
-
setFieldErrors: A,
|
|
694
|
-
setFieldValue: W,
|
|
695
|
-
setMultipleFieldValues: G,
|
|
696
|
-
submitMessage: B,
|
|
697
|
-
t: T,
|
|
698
|
-
validateForm: K,
|
|
699
|
-
visibleNodes: P,
|
|
700
|
-
visibleRootNodes: F
|
|
701
|
-
};
|
|
702
|
-
}, se = (e) => new Promise((t, n) => {
|
|
703
|
-
let r = new FileReader();
|
|
704
|
-
r.onload = () => {
|
|
705
|
-
let n = r.result;
|
|
706
|
-
t({
|
|
707
|
-
data: n,
|
|
708
|
-
lastModified: e.lastModified,
|
|
709
|
-
name: e.name,
|
|
710
|
-
size: e.size,
|
|
711
|
-
type: e.type
|
|
712
|
-
});
|
|
713
|
-
}, r.onerror = () => {
|
|
714
|
-
n(/* @__PURE__ */ Error(`Failed to read file: ${e.name}`));
|
|
715
|
-
}, r.readAsDataURL(e);
|
|
716
|
-
}), ce = (e) => {
|
|
717
|
-
let t = e.data.split(",")[1], n = atob(t), r = new ArrayBuffer(n.length), i = new Uint8Array(r);
|
|
718
|
-
for (let e = 0; e < n.length; e++) i[e] = n.charCodeAt(e);
|
|
719
|
-
let a = new Blob([r], { type: e.type });
|
|
720
|
-
return new File([a], e.name, {
|
|
721
|
-
lastModified: e.lastModified,
|
|
722
|
-
type: e.type
|
|
723
|
-
});
|
|
724
|
-
}, le = (e) => Promise.all(e.map((e) => se(e))), ue = ({ DefaultFormWrapper: e, DefaultGroup: t, DefaultSubmitButton: r, DefaultSubmitButtonWrapper: u, config: f, defaultInputRenderers: p, defaultUI: h, formErrors: g, formValues: _, missingRequiredFields: v, setFieldValue: y, visibleNodes: b }) => {
|
|
725
|
-
let x = m(() => f.components.form || e, [f.components.form, e]), C = m(() => f.components.submitButton || r, [f.components.submitButton, r]), w = m(() => f.components.submitButtonWrapper || u || l, [f.components.submitButtonWrapper, u]);
|
|
726
|
-
return {
|
|
727
|
-
FormWrapper: x,
|
|
728
|
-
renderNode: d(function e(r) {
|
|
729
|
-
let { type: l } = r;
|
|
730
|
-
switch (l) {
|
|
731
|
-
case a.input: {
|
|
732
|
-
if (!s(r)) return null;
|
|
733
|
-
let e = r.data, t = e.type || "text", n = f.components.inputs?.[t], i = p[t], a = n || i, l = r.id, u = (e) => y(l, e), d = _[l], m = g[l], h = o(e.label, f.language), b = o(e.placeholder, f.language), x = o(e.helperText, f.language), C = S(r), w = M(h), T = M(b), E = M(x);
|
|
734
|
-
return a ? /* @__PURE__ */ c(a, {
|
|
735
|
-
id: r.id,
|
|
736
|
-
node: r,
|
|
737
|
-
value: d,
|
|
738
|
-
error: m,
|
|
739
|
-
label: w,
|
|
740
|
-
placeholder: T,
|
|
741
|
-
helperText: E,
|
|
742
|
-
name: C,
|
|
743
|
-
setValue: u,
|
|
744
|
-
missingRequiredFields: v
|
|
745
|
-
}, r.id) : (console.warn("No renderer found for input type:", t), null);
|
|
746
|
-
}
|
|
747
|
-
case a.group: return i(r) ? /* @__PURE__ */ c(f.components.group || t, {
|
|
748
|
-
node: r,
|
|
749
|
-
children: b.filter((e) => e.parentId === r.id).map((t) => e(t))
|
|
750
|
-
}, r.id) : null;
|
|
751
|
-
case a.ui: {
|
|
752
|
-
if (!n(r)) return null;
|
|
753
|
-
let e = r.data.type || "title", t = f.components.ui?.[e], i = h[e], a = t || i;
|
|
754
|
-
return a ? /* @__PURE__ */ c(a, { node: r }, r.id) : null;
|
|
755
|
-
}
|
|
756
|
-
case a.flow: return null;
|
|
757
|
-
default: return console.warn("Unknown node type:", l), null;
|
|
758
|
-
}
|
|
759
|
-
}, [
|
|
760
|
-
f,
|
|
761
|
-
b,
|
|
762
|
-
_,
|
|
763
|
-
g,
|
|
764
|
-
y,
|
|
765
|
-
v,
|
|
766
|
-
p,
|
|
767
|
-
h,
|
|
768
|
-
t
|
|
769
|
-
]),
|
|
770
|
-
SubmitButton: C,
|
|
771
|
-
SubmitButtonWrapper: w
|
|
772
|
-
};
|
|
773
|
-
};
|
|
774
|
-
//#endregion
|
|
775
|
-
export { b as C, C as S, D as _, oe as a, E as b, ie as c, q as d, $ as f, P as g, M as h, ce as i, J as l, W as m, se as n, ae as o, U as p, le as r, re as s, ue as t, X as u, k as v, y as w, w as x, T as y };
|