@sonata-innovations/fiber-fbre 2.0.0 → 2.0.3
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/README.md +37 -6
- package/dist/fiber-fbre.cjs +1 -1
- package/dist/fiber-fbre.css +1 -1
- package/dist/fiber-fbre.js +1387 -1238
- package/dist/index.d.ts +4 -0
- package/package.json +2 -2
package/dist/fiber-fbre.js
CHANGED
|
@@ -1,240 +1,240 @@
|
|
|
1
|
-
import { jsx as m, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useStore as
|
|
4
|
-
import { normalizeOptions as
|
|
5
|
-
import { validateValue as
|
|
6
|
-
const
|
|
1
|
+
import { jsx as m, jsxs as B, Fragment as fn } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Ke, useContext as Ie, useMemo as ke, useState as J, useRef as Z, useEffect as H, useCallback as z } from "react";
|
|
3
|
+
import { useStore as Q, createStore as Qe } from "zustand";
|
|
4
|
+
import { normalizeOptions as mn } from "@sonata-innovations/fiber-types";
|
|
5
|
+
import { validateValue as vn, isHiddenByCondition as te, extractFormulaReferences as Be, evaluateFormula as ie, evaluateConditionConfig as hn, formatCalculationResult as yn } from "@sonata-innovations/fiber-shared";
|
|
6
|
+
const gn = /* @__PURE__ */ new Map(), bn = (n) => gn.get(n), Cn = /* @__PURE__ */ new Set([
|
|
7
7
|
"header",
|
|
8
8
|
"text",
|
|
9
9
|
"divider",
|
|
10
10
|
"callout",
|
|
11
11
|
"table"
|
|
12
|
-
]),
|
|
13
|
-
var o, t,
|
|
12
|
+
]), ve = (n) => Cn.has(n), Sn = (n, r) => {
|
|
13
|
+
var o, t, e, s;
|
|
14
14
|
if (r.includes(":")) {
|
|
15
|
-
const
|
|
16
|
-
return (
|
|
15
|
+
const c = r.split(":"), i = n.components[c[0]];
|
|
16
|
+
return (e = (t = (o = i == null ? void 0 : i.addedComponents) == null ? void 0 : o[parseInt(c[1])]) == null ? void 0 : t[parseInt(c[2])]) == null ? void 0 : e.value;
|
|
17
17
|
}
|
|
18
|
-
return (s =
|
|
19
|
-
},
|
|
18
|
+
return (s = n.components[r]) == null ? void 0 : s.value;
|
|
19
|
+
}, M = (n, r) => {
|
|
20
20
|
var t;
|
|
21
|
-
const o = (t =
|
|
22
|
-
return !o || !o.rules || o.rules.length === 0 ? [] :
|
|
23
|
-
|
|
21
|
+
const o = (t = n.properties) == null ? void 0 : t.validation;
|
|
22
|
+
return !o || !o.rules || o.rules.length === 0 ? [] : vn(
|
|
23
|
+
n.value,
|
|
24
24
|
o,
|
|
25
|
-
r ? (
|
|
25
|
+
r ? (e) => Sn(r, e) : void 0
|
|
26
26
|
);
|
|
27
|
-
},
|
|
27
|
+
}, wn = (n) => {
|
|
28
28
|
var o;
|
|
29
|
-
const r = (o =
|
|
29
|
+
const r = (o = n.properties) == null ? void 0 : o.validation;
|
|
30
30
|
return !r || !r.rules ? !1 : r.rules.some((t) => t.type === "required");
|
|
31
|
-
},
|
|
31
|
+
}, X = (n) => {
|
|
32
32
|
var o, t;
|
|
33
|
-
const r = { ...
|
|
33
|
+
const r = { ...n };
|
|
34
34
|
return Array.isArray((o = r.properties) == null ? void 0 : o.options) && (r.properties = {
|
|
35
35
|
...r.properties,
|
|
36
|
-
options:
|
|
37
|
-
}),
|
|
38
|
-
},
|
|
36
|
+
options: mn(r.properties.options)
|
|
37
|
+
}), n.type === "computed" ? (r.value = null, r.valid = !0) : !ve(n.type) && n.type !== "group" && n.type !== "repeater" && (r.value = null, r.valid = !wn(n)), (n.type === "checkbox" || n.type === "dropDownMulti") && (r.value = []), n.type === "radio" && "options" in n.properties && n.properties.options.length > 0 && (r.value = n.properties.options[0].value), n.type === "toggleSwitch" && (r.value = !1), n.type === "colorPicker" && ((t = n.properties) != null && t.defaultValue) && (r.value = n.properties.defaultValue), n.type === "slider" && (r.value = "initValue" in n.properties ? n.properties.initValue : "min" in n.properties ? n.properties.min : 0), r;
|
|
38
|
+
}, le = (n, r, o) => {
|
|
39
39
|
var t;
|
|
40
|
-
for (const
|
|
41
|
-
if (
|
|
42
|
-
const s =
|
|
43
|
-
|
|
40
|
+
for (const e of o.rules)
|
|
41
|
+
if (e.type === "matchesField" && ((t = e.params) != null && t.field)) {
|
|
42
|
+
const s = e.params.field;
|
|
43
|
+
n[s] || (n[s] = []), n[s].push({
|
|
44
44
|
target: r,
|
|
45
45
|
config: o
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
},
|
|
49
|
-
const o =
|
|
50
|
-
return o ? !o.components.some((
|
|
51
|
-
var
|
|
52
|
-
const s =
|
|
48
|
+
}, oe = (n, r) => {
|
|
49
|
+
const o = n.screens[r];
|
|
50
|
+
return o ? !o.components.some((e) => {
|
|
51
|
+
var i;
|
|
52
|
+
const s = n.components[e.uuid];
|
|
53
53
|
if (!s) return !1;
|
|
54
54
|
if (s.type === "group" || s.type === "repeater")
|
|
55
|
-
return (
|
|
56
|
-
(
|
|
57
|
-
const
|
|
58
|
-
return
|
|
55
|
+
return (i = s.addedComponents) == null ? void 0 : i.some(
|
|
56
|
+
(l) => l.some((a) => {
|
|
57
|
+
const u = a.conditions && "when" in a.conditions ? a.conditions : void 0;
|
|
58
|
+
return u && te(u, n.conditionResults[a.uuid]) ? !1 : !a.valid;
|
|
59
59
|
})
|
|
60
60
|
);
|
|
61
|
-
const
|
|
62
|
-
return
|
|
61
|
+
const c = s.conditions && "when" in s.conditions ? s.conditions : void 0;
|
|
62
|
+
return te(c, n.conditionResults[s.uuid]) ? !1 : s && "valid" in s && !s.valid;
|
|
63
63
|
}) : !0;
|
|
64
64
|
};
|
|
65
|
-
function
|
|
65
|
+
function Nn(n) {
|
|
66
66
|
const r = {};
|
|
67
|
-
for (const o of
|
|
68
|
-
const t =
|
|
69
|
-
for (const
|
|
70
|
-
r[
|
|
67
|
+
for (const o of n) {
|
|
68
|
+
const t = Be(o.formula);
|
|
69
|
+
for (const e of t)
|
|
70
|
+
r[e] || (r[e] = []), r[e].includes(o.uuid) || r[e].push(o.uuid);
|
|
71
71
|
}
|
|
72
72
|
return r;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
const r = new Map(
|
|
76
|
-
function s(
|
|
77
|
-
if (t.has(
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const
|
|
82
|
-
for (const
|
|
83
|
-
o.has(
|
|
84
|
-
|
|
74
|
+
function Ze(n) {
|
|
75
|
+
const r = new Map(n.map((c) => [c.uuid, c])), o = new Set(n.map((c) => c.uuid)), t = /* @__PURE__ */ new Set(), e = [];
|
|
76
|
+
function s(c, i) {
|
|
77
|
+
if (t.has(c) || i.has(c)) return;
|
|
78
|
+
i.add(c);
|
|
79
|
+
const l = r.get(c);
|
|
80
|
+
if (!l) return;
|
|
81
|
+
const a = Be(l.formula);
|
|
82
|
+
for (const u of a)
|
|
83
|
+
o.has(u) && s(u, i);
|
|
84
|
+
i.delete(c), t.add(c), e.push(l);
|
|
85
85
|
}
|
|
86
|
-
for (const
|
|
87
|
-
s(
|
|
88
|
-
return
|
|
86
|
+
for (const c of n)
|
|
87
|
+
s(c.uuid, /* @__PURE__ */ new Set());
|
|
88
|
+
return e;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function en(n, r) {
|
|
91
91
|
return {
|
|
92
92
|
resolveValue: (o) => {
|
|
93
93
|
if (o in r)
|
|
94
94
|
return r[o];
|
|
95
|
-
const t =
|
|
95
|
+
const t = ee(n, o);
|
|
96
96
|
if (!t) return null;
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
const s = Number(
|
|
97
|
+
const e = t.value;
|
|
98
|
+
if (e == null || e === "") return null;
|
|
99
|
+
const s = Number(e);
|
|
100
100
|
return isNaN(s) ? null : s;
|
|
101
101
|
},
|
|
102
102
|
resolveOptionMetadata: (o, t) => {
|
|
103
|
-
var
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
106
|
-
const s =
|
|
103
|
+
var u;
|
|
104
|
+
const e = ee(n, o);
|
|
105
|
+
if (!e) return null;
|
|
106
|
+
const s = e.value;
|
|
107
107
|
if (!s) return null;
|
|
108
|
-
const
|
|
109
|
-
if (!Array.isArray(
|
|
110
|
-
const
|
|
111
|
-
(
|
|
108
|
+
const c = (u = e.properties) == null ? void 0 : u.options;
|
|
109
|
+
if (!Array.isArray(c)) return null;
|
|
110
|
+
const i = c.find(
|
|
111
|
+
(d) => d.value === s || d.label === s
|
|
112
112
|
);
|
|
113
|
-
if (!(
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
117
|
-
return isNaN(
|
|
113
|
+
if (!(i != null && i.metadata)) return null;
|
|
114
|
+
const l = i.metadata[t];
|
|
115
|
+
if (l == null) return null;
|
|
116
|
+
const a = Number(l);
|
|
117
|
+
return isNaN(a) ? null : a;
|
|
118
118
|
},
|
|
119
119
|
resolveRepeaterValues: (o) => {
|
|
120
|
-
for (const t of Object.keys(
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
const s =
|
|
120
|
+
for (const t of Object.keys(n.components)) {
|
|
121
|
+
const e = n.components[t];
|
|
122
|
+
if (e.type !== "repeater" || !e.addedComponents || !e.components) continue;
|
|
123
|
+
const s = e.components.findIndex((i) => i.uuid === o);
|
|
124
124
|
if (s === -1) continue;
|
|
125
|
-
const
|
|
126
|
-
for (const
|
|
127
|
-
const
|
|
128
|
-
if (!
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
const
|
|
132
|
-
isNaN(
|
|
125
|
+
const c = [];
|
|
126
|
+
for (const i of e.addedComponents) {
|
|
127
|
+
const l = i[s];
|
|
128
|
+
if (!l) continue;
|
|
129
|
+
const a = l.value;
|
|
130
|
+
if (a == null || a === "") continue;
|
|
131
|
+
const u = Number(a);
|
|
132
|
+
isNaN(u) || c.push(u);
|
|
133
133
|
}
|
|
134
|
-
return
|
|
134
|
+
return c.length > 0 ? c : null;
|
|
135
135
|
}
|
|
136
136
|
return null;
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
const r =
|
|
140
|
+
function Ee(n) {
|
|
141
|
+
const r = n.calculations ?? [];
|
|
142
142
|
if (r.length === 0) return {};
|
|
143
|
-
const o =
|
|
143
|
+
const o = Ze(r), t = {}, e = en(n, t);
|
|
144
144
|
for (const s of o)
|
|
145
|
-
t[s.uuid] =
|
|
145
|
+
t[s.uuid] = ie(s.formula, e);
|
|
146
146
|
return t;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
const o =
|
|
148
|
+
function we(n, r) {
|
|
149
|
+
const o = n.calculationsByDependency, t = n.calculations ?? [];
|
|
150
150
|
if (t.length === 0 || !o) return null;
|
|
151
|
-
const
|
|
151
|
+
const e = /* @__PURE__ */ new Set(), s = [r];
|
|
152
152
|
for (; s.length > 0; ) {
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
for (const
|
|
156
|
-
|
|
153
|
+
const u = s.shift(), d = o[u];
|
|
154
|
+
if (d)
|
|
155
|
+
for (const f of d)
|
|
156
|
+
e.has(f) || (e.add(f), s.push(f));
|
|
157
157
|
}
|
|
158
|
-
if (
|
|
159
|
-
const
|
|
160
|
-
let
|
|
161
|
-
for (const
|
|
162
|
-
if (
|
|
163
|
-
const
|
|
164
|
-
|
|
158
|
+
if (e.size === 0) return null;
|
|
159
|
+
const c = Ze(t), i = { ...n.calculationResults }, l = en(n, i);
|
|
160
|
+
let a = !1;
|
|
161
|
+
for (const u of c)
|
|
162
|
+
if (e.has(u.uuid)) {
|
|
163
|
+
const d = ie(u.formula, l);
|
|
164
|
+
i[u.uuid] !== d && (i[u.uuid] = d, a = !0);
|
|
165
165
|
}
|
|
166
|
-
return
|
|
166
|
+
return a ? i : null;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function Rn(n) {
|
|
169
169
|
const r = {}, o = (t) => {
|
|
170
170
|
var s;
|
|
171
171
|
if (t.type !== "computed" || !((s = t.properties) != null && s.formula)) return;
|
|
172
|
-
const
|
|
173
|
-
for (const
|
|
174
|
-
r[
|
|
172
|
+
const e = Be(t.properties.formula);
|
|
173
|
+
for (const c of e)
|
|
174
|
+
r[c] || (r[c] = []), r[c].includes(t.uuid) || r[c].push(t.uuid);
|
|
175
175
|
};
|
|
176
|
-
for (const t of Object.values(
|
|
176
|
+
for (const t of Object.values(n))
|
|
177
177
|
if (o(t), (t.type === "repeater" || t.type === "group") && t.components)
|
|
178
|
-
for (const
|
|
179
|
-
o(
|
|
178
|
+
for (const e of t.components)
|
|
179
|
+
o(e);
|
|
180
180
|
return r;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
var
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
for (let
|
|
187
|
-
const
|
|
188
|
-
|
|
182
|
+
function nn(n, r, o, t) {
|
|
183
|
+
var l, a;
|
|
184
|
+
const e = n.components[o], s = ((l = e == null ? void 0 : e.components) == null ? void 0 : l.map((u) => u.uuid)) ?? [], c = (a = e == null ? void 0 : e.addedComponents) == null ? void 0 : a[t], i = /* @__PURE__ */ new Map();
|
|
185
|
+
if (c)
|
|
186
|
+
for (let u = 0; u < c.length; u++) {
|
|
187
|
+
const d = s[u];
|
|
188
|
+
d && i.set(d, c[u]);
|
|
189
189
|
}
|
|
190
190
|
return {
|
|
191
|
-
resolveValue: (
|
|
192
|
-
if (
|
|
193
|
-
return r[
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
const g =
|
|
191
|
+
resolveValue: (u) => {
|
|
192
|
+
if (u in r)
|
|
193
|
+
return r[u];
|
|
194
|
+
const d = i.get(u);
|
|
195
|
+
if (d) {
|
|
196
|
+
const g = d.value;
|
|
197
197
|
if (g == null || g === "") return null;
|
|
198
|
-
const
|
|
199
|
-
return isNaN(
|
|
198
|
+
const v = Number(g);
|
|
199
|
+
return isNaN(v) ? null : v;
|
|
200
200
|
}
|
|
201
|
-
const
|
|
202
|
-
if (!
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
const y = Number(
|
|
201
|
+
const f = ee(n, u);
|
|
202
|
+
if (!f) return null;
|
|
203
|
+
const p = f.value;
|
|
204
|
+
if (p == null || p === "") return null;
|
|
205
|
+
const y = Number(p);
|
|
206
206
|
return isNaN(y) ? null : y;
|
|
207
207
|
},
|
|
208
|
-
resolveOptionMetadata: (
|
|
209
|
-
var
|
|
210
|
-
const
|
|
211
|
-
if (!
|
|
212
|
-
const y =
|
|
208
|
+
resolveOptionMetadata: (u, d) => {
|
|
209
|
+
var C;
|
|
210
|
+
const p = i.get(u) ?? ee(n, u);
|
|
211
|
+
if (!p) return null;
|
|
212
|
+
const y = p.value;
|
|
213
213
|
if (!y) return null;
|
|
214
|
-
const g = (
|
|
214
|
+
const g = (C = p.properties) == null ? void 0 : C.options;
|
|
215
215
|
if (!Array.isArray(g)) return null;
|
|
216
|
-
const
|
|
217
|
-
(
|
|
216
|
+
const v = g.find(
|
|
217
|
+
(S) => S.value === y || S.label === y
|
|
218
218
|
);
|
|
219
|
-
if (!(
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
const b = Number(
|
|
219
|
+
if (!(v != null && v.metadata)) return null;
|
|
220
|
+
const h = v.metadata[d];
|
|
221
|
+
if (h == null) return null;
|
|
222
|
+
const b = Number(h);
|
|
223
223
|
return isNaN(b) ? null : b;
|
|
224
224
|
},
|
|
225
|
-
resolveRepeaterValues: (
|
|
226
|
-
for (const
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
225
|
+
resolveRepeaterValues: (u) => {
|
|
226
|
+
for (const d of Object.keys(n.components)) {
|
|
227
|
+
const f = n.components[d];
|
|
228
|
+
if (f.type !== "repeater" || !f.addedComponents || !f.components) continue;
|
|
229
|
+
const p = f.components.findIndex((g) => g.uuid === u);
|
|
230
|
+
if (p === -1) continue;
|
|
231
231
|
const y = [];
|
|
232
|
-
for (const g of
|
|
233
|
-
const
|
|
234
|
-
if (!
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
const b = Number(
|
|
232
|
+
for (const g of f.addedComponents) {
|
|
233
|
+
const v = g[p];
|
|
234
|
+
if (!v) continue;
|
|
235
|
+
const h = v.value;
|
|
236
|
+
if (h == null || h === "") continue;
|
|
237
|
+
const b = Number(h);
|
|
238
238
|
isNaN(b) || y.push(b);
|
|
239
239
|
}
|
|
240
240
|
return y.length > 0 ? y : null;
|
|
@@ -243,423 +243,427 @@ function We(e, r, o, t) {
|
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function he(n, r) {
|
|
247
247
|
return {
|
|
248
248
|
resolveValue: (o) => {
|
|
249
249
|
if (o in r)
|
|
250
250
|
return r[o];
|
|
251
|
-
const t =
|
|
251
|
+
const t = ee(n, o);
|
|
252
252
|
if (!t) return null;
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
255
|
-
const s = Number(
|
|
253
|
+
const e = t.value;
|
|
254
|
+
if (e == null || e === "") return null;
|
|
255
|
+
const s = Number(e);
|
|
256
256
|
return isNaN(s) ? null : s;
|
|
257
257
|
},
|
|
258
258
|
resolveOptionMetadata: (o, t) => {
|
|
259
|
-
var
|
|
260
|
-
const
|
|
261
|
-
if (!
|
|
262
|
-
const s =
|
|
259
|
+
var u;
|
|
260
|
+
const e = ee(n, o);
|
|
261
|
+
if (!e) return null;
|
|
262
|
+
const s = e.value;
|
|
263
263
|
if (!s) return null;
|
|
264
|
-
const
|
|
265
|
-
if (!Array.isArray(
|
|
266
|
-
const
|
|
267
|
-
(
|
|
264
|
+
const c = (u = e.properties) == null ? void 0 : u.options;
|
|
265
|
+
if (!Array.isArray(c)) return null;
|
|
266
|
+
const i = c.find(
|
|
267
|
+
(d) => d.value === s || d.label === s
|
|
268
268
|
);
|
|
269
|
-
if (!(
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
const
|
|
273
|
-
return isNaN(
|
|
269
|
+
if (!(i != null && i.metadata)) return null;
|
|
270
|
+
const l = i.metadata[t];
|
|
271
|
+
if (l == null) return null;
|
|
272
|
+
const a = Number(l);
|
|
273
|
+
return isNaN(a) ? null : a;
|
|
274
274
|
},
|
|
275
275
|
resolveRepeaterValues: (o) => {
|
|
276
|
-
for (const t of Object.keys(
|
|
277
|
-
const
|
|
278
|
-
if (
|
|
279
|
-
const s =
|
|
276
|
+
for (const t of Object.keys(n.components)) {
|
|
277
|
+
const e = n.components[t];
|
|
278
|
+
if (e.type !== "repeater" || !e.addedComponents || !e.components) continue;
|
|
279
|
+
const s = e.components.findIndex((i) => i.uuid === o);
|
|
280
280
|
if (s === -1) continue;
|
|
281
|
-
const
|
|
282
|
-
for (const
|
|
283
|
-
const
|
|
284
|
-
if (!
|
|
285
|
-
const
|
|
286
|
-
if (
|
|
287
|
-
const
|
|
288
|
-
isNaN(
|
|
281
|
+
const c = [];
|
|
282
|
+
for (const i of e.addedComponents) {
|
|
283
|
+
const l = i[s];
|
|
284
|
+
if (!l) continue;
|
|
285
|
+
const a = l.value;
|
|
286
|
+
if (a == null || a === "") continue;
|
|
287
|
+
const u = Number(a);
|
|
288
|
+
isNaN(u) || c.push(u);
|
|
289
289
|
}
|
|
290
|
-
return
|
|
290
|
+
return c.length > 0 ? c : null;
|
|
291
291
|
}
|
|
292
292
|
return null;
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function xe(n) {
|
|
297
297
|
var o, t;
|
|
298
|
-
const r =
|
|
299
|
-
for (const
|
|
300
|
-
if (
|
|
301
|
-
const s =
|
|
302
|
-
|
|
298
|
+
const r = n.calculationResults ?? {};
|
|
299
|
+
for (const e of Object.values(n.components))
|
|
300
|
+
if (e.type === "computed" && ((o = e.properties) != null && o.formula)) {
|
|
301
|
+
const s = he(n, r), c = ie(e.properties.formula, s);
|
|
302
|
+
e.value = c;
|
|
303
303
|
}
|
|
304
|
-
for (const
|
|
305
|
-
if ((
|
|
306
|
-
for (let s = 0; s <
|
|
307
|
-
const
|
|
308
|
-
for (let
|
|
309
|
-
const
|
|
310
|
-
if ((
|
|
311
|
-
const
|
|
312
|
-
|
|
304
|
+
for (const e of Object.values(n.components))
|
|
305
|
+
if ((e.type === "repeater" || e.type === "group") && e.addedComponents && e.components)
|
|
306
|
+
for (let s = 0; s < e.addedComponents.length; s++) {
|
|
307
|
+
const c = e.addedComponents[s];
|
|
308
|
+
for (let i = 0; i < c.length; i++) {
|
|
309
|
+
const l = c[i], a = e.components[i];
|
|
310
|
+
if ((a == null ? void 0 : a.type) === "computed" && ((t = a.properties) != null && t.formula)) {
|
|
311
|
+
const u = e.type === "repeater" ? nn(n, r, e.uuid, s) : he(n, r), d = ie(a.properties.formula, u);
|
|
312
|
+
l.value = d;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
|
-
function
|
|
318
|
-
var
|
|
319
|
-
const o =
|
|
317
|
+
function En(n, r) {
|
|
318
|
+
var c, i;
|
|
319
|
+
const o = n.computedByDependency;
|
|
320
320
|
if (!o) return !1;
|
|
321
321
|
const t = o[r];
|
|
322
322
|
if (!t || t.length === 0) return !1;
|
|
323
|
-
const
|
|
323
|
+
const e = n.calculationResults ?? {};
|
|
324
324
|
let s = !1;
|
|
325
|
-
for (const
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
328
|
-
const
|
|
329
|
-
|
|
325
|
+
for (const l of t) {
|
|
326
|
+
const a = n.components[l];
|
|
327
|
+
if (a && a.type === "computed" && ((c = a.properties) != null && c.formula)) {
|
|
328
|
+
const u = he(n, e), d = ie(a.properties.formula, u);
|
|
329
|
+
a.value !== d && (n.components[l] = { ...a, value: d }, s = !0);
|
|
330
330
|
continue;
|
|
331
331
|
}
|
|
332
|
-
for (const
|
|
333
|
-
if ((
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
336
|
-
const
|
|
337
|
-
if ((
|
|
338
|
-
for (let
|
|
339
|
-
const y =
|
|
332
|
+
for (const u of Object.values(n.components))
|
|
333
|
+
if ((u.type === "repeater" || u.type === "group") && u.components && u.addedComponents) {
|
|
334
|
+
const d = u.components.findIndex((p) => p.uuid === l);
|
|
335
|
+
if (d === -1) continue;
|
|
336
|
+
const f = u.components[d];
|
|
337
|
+
if ((f == null ? void 0 : f.type) !== "computed" || !((i = f.properties) != null && i.formula)) continue;
|
|
338
|
+
for (let p = 0; p < u.addedComponents.length; p++) {
|
|
339
|
+
const y = u.addedComponents[p][d];
|
|
340
340
|
if (!y) continue;
|
|
341
|
-
const g =
|
|
342
|
-
y.value !==
|
|
341
|
+
const g = u.type === "repeater" ? nn(n, e, u.uuid, p) : he(n, e), v = ie(f.properties.formula, g);
|
|
342
|
+
y.value !== v && (u.addedComponents[p][d] = { ...y, value: v }, s = !0);
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
return s;
|
|
347
347
|
}
|
|
348
|
-
const
|
|
348
|
+
const tn = (n, r) => {
|
|
349
349
|
var o, t;
|
|
350
350
|
if (r.includes(":")) {
|
|
351
|
-
const
|
|
352
|
-
return (t = (o = s == null ? void 0 : s.addedComponents) == null ? void 0 : o[parseInt(
|
|
351
|
+
const e = r.split(":"), s = n[e[0]];
|
|
352
|
+
return (t = (o = s == null ? void 0 : s.addedComponents) == null ? void 0 : o[parseInt(e[1])]) == null ? void 0 : t[parseInt(e[2])];
|
|
353
353
|
}
|
|
354
|
-
return
|
|
355
|
-
},
|
|
356
|
-
for (const o of
|
|
357
|
-
if (
|
|
354
|
+
return n[r];
|
|
355
|
+
}, fe = (n, r) => {
|
|
356
|
+
for (const o of n.screenOrder)
|
|
357
|
+
if (n.screens[o].components.some((e) => e.uuid === r))
|
|
358
358
|
return o;
|
|
359
359
|
return null;
|
|
360
|
-
},
|
|
360
|
+
}, xn = (n, r) => {
|
|
361
361
|
if (!r.includes(":")) return null;
|
|
362
362
|
const o = r.split(":");
|
|
363
363
|
if (o.length !== 3) return null;
|
|
364
|
-
const t = o[0],
|
|
364
|
+
const t = o[0], e = parseInt(o[2]), s = n.components[t];
|
|
365
365
|
if (!s || s.type !== "repeater" || !s.components) return null;
|
|
366
|
-
const
|
|
367
|
-
return (
|
|
368
|
-
},
|
|
369
|
-
const s = r(),
|
|
366
|
+
const c = s.components[e];
|
|
367
|
+
return (c == null ? void 0 : c.uuid) ?? null;
|
|
368
|
+
}, Ye = (n, r, o, t, e) => {
|
|
369
|
+
const s = r(), c = s.groupComponentMap[o] ?? o, i = kn(n, r, c), l = {
|
|
370
370
|
components: s.components,
|
|
371
371
|
groupComponentMap: s.groupComponentMap
|
|
372
|
-
},
|
|
373
|
-
t.valid =
|
|
374
|
-
const
|
|
372
|
+
}, a = M(t, l);
|
|
373
|
+
t.valid = a.length === 0;
|
|
374
|
+
const u = {
|
|
375
375
|
...s.validationErrors,
|
|
376
|
-
[o]:
|
|
377
|
-
},
|
|
378
|
-
if (
|
|
379
|
-
for (const
|
|
380
|
-
const
|
|
381
|
-
if (
|
|
382
|
-
const
|
|
383
|
-
|
|
376
|
+
[o]: a
|
|
377
|
+
}, d = s.validationsByDependency[o];
|
|
378
|
+
if (d)
|
|
379
|
+
for (const C of d) {
|
|
380
|
+
const S = ee(s, C.target);
|
|
381
|
+
if (S) {
|
|
382
|
+
const w = M(S, l);
|
|
383
|
+
S.valid = w.length === 0, u[C.target] = w;
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
const
|
|
386
|
+
const f = fe(s, e), p = {
|
|
387
387
|
components: { ...s.components },
|
|
388
|
-
validationErrors:
|
|
388
|
+
validationErrors: u
|
|
389
389
|
};
|
|
390
|
-
if (
|
|
391
|
-
const
|
|
392
|
-
|
|
390
|
+
if (i && (p.conditionResults = i), f) {
|
|
391
|
+
const C = { ...s, ...p };
|
|
392
|
+
p.screenValidity = {
|
|
393
393
|
...s.screenValidity,
|
|
394
|
-
[
|
|
394
|
+
[f]: oe(C, f)
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
|
-
const y = { ...s, ...
|
|
398
|
-
if (
|
|
399
|
-
const
|
|
400
|
-
for (const
|
|
401
|
-
|
|
397
|
+
const y = { ...s, ...p }, g = o.includes(":") ? xn(y, o) : null, v = [], h = (C) => {
|
|
398
|
+
if (En(y, C)) {
|
|
399
|
+
const S = y.computedByDependency[C] ?? [];
|
|
400
|
+
for (const w of S)
|
|
401
|
+
v.includes(w) || (v.push(w), h(w));
|
|
402
402
|
}
|
|
403
403
|
};
|
|
404
|
-
|
|
405
|
-
let b =
|
|
406
|
-
if (g && g !==
|
|
407
|
-
const
|
|
408
|
-
|
|
404
|
+
h(c), g && g !== c && h(g);
|
|
405
|
+
let b = we(y, c);
|
|
406
|
+
if (g && g !== c) {
|
|
407
|
+
const C = b ? { ...y, calculationResults: b } : y, S = we(C, g);
|
|
408
|
+
S && (b = S);
|
|
409
409
|
}
|
|
410
|
-
for (const
|
|
411
|
-
const
|
|
412
|
-
|
|
410
|
+
for (const C of v) {
|
|
411
|
+
const S = b ? { ...y, calculationResults: b } : y, w = we(S, C);
|
|
412
|
+
w && (b = w);
|
|
413
413
|
}
|
|
414
|
-
b && (
|
|
415
|
-
},
|
|
414
|
+
b && (p.calculationResults = b), n(p);
|
|
415
|
+
}, Dn = (n, r) => ({
|
|
416
416
|
updateComponentValue: (o, t) => {
|
|
417
|
-
var
|
|
418
|
-
const
|
|
417
|
+
var c, i;
|
|
418
|
+
const e = r();
|
|
419
419
|
if (o.includes(":")) {
|
|
420
|
-
const
|
|
421
|
-
if (!((
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
|
|
425
|
-
|
|
420
|
+
const l = o.split(":"), a = l[0], u = parseInt(l[1]), d = parseInt(l[2]), f = e.components[a];
|
|
421
|
+
if (!((i = (c = f == null ? void 0 : f.addedComponents) == null ? void 0 : c[u]) != null && i[d])) return;
|
|
422
|
+
const p = f.addedComponents[u][d].value !== t;
|
|
423
|
+
if (f.addedComponents[u][d] = { ...f.addedComponents[u][d], value: t }, p) {
|
|
424
|
+
Ye(
|
|
425
|
+
n,
|
|
426
426
|
r,
|
|
427
427
|
o,
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
f.addedComponents[u][d],
|
|
429
|
+
a
|
|
430
430
|
);
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
|
-
|
|
433
|
+
n({ components: { ...e.components } });
|
|
434
434
|
return;
|
|
435
435
|
}
|
|
436
|
-
const s =
|
|
436
|
+
const s = e.components[o];
|
|
437
437
|
if (s) {
|
|
438
438
|
if (s.type === "group" || s.type === "repeater") {
|
|
439
|
-
|
|
439
|
+
n({ components: { ...e.components } });
|
|
440
440
|
return;
|
|
441
441
|
}
|
|
442
|
-
t
|
|
442
|
+
if (t === s.value) {
|
|
443
|
+
n({ selectionTick: r().selectionTick + 1 });
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
s.value = t, Ye(n, r, o, s, o);
|
|
443
447
|
}
|
|
444
448
|
},
|
|
445
449
|
addGroupIteration: (o) => {
|
|
446
|
-
const t = r(),
|
|
447
|
-
if (!
|
|
450
|
+
const t = r(), e = t.components[o];
|
|
451
|
+
if (!e || e.type !== "group" || !e.components)
|
|
448
452
|
return;
|
|
449
|
-
|
|
450
|
-
const s = { ...t.conditionsByDependency },
|
|
451
|
-
const
|
|
452
|
-
if (
|
|
453
|
+
e.addedComponents || (e.addedComponents = []);
|
|
454
|
+
const s = { ...t.conditionsByDependency }, c = e.components.map((a, u) => {
|
|
455
|
+
const d = X(a);
|
|
456
|
+
if (d.uuid = [o, e.addedComponents.length, u].join(
|
|
453
457
|
":"
|
|
454
|
-
), t.groupComponentMap[
|
|
455
|
-
const
|
|
456
|
-
|
|
458
|
+
), t.groupComponentMap[d.uuid] = a.uuid, d.conditions && Object.keys(d.conditions).length > 0) {
|
|
459
|
+
const p = "when" in d.conditions ? d.conditions : null;
|
|
460
|
+
p && (d.conditions = p, ne(
|
|
457
461
|
s,
|
|
458
|
-
|
|
459
|
-
|
|
462
|
+
d.uuid,
|
|
463
|
+
p,
|
|
460
464
|
"component"
|
|
461
465
|
));
|
|
462
466
|
}
|
|
463
|
-
const
|
|
464
|
-
return
|
|
467
|
+
const f = M(d);
|
|
468
|
+
return d.valid = f.length === 0, d;
|
|
465
469
|
});
|
|
466
|
-
|
|
467
|
-
const
|
|
468
|
-
return
|
|
470
|
+
e.addedComponents.push(c);
|
|
471
|
+
const i = fe(t, o), l = { ...t.screenValidity };
|
|
472
|
+
return i && (l[i] = oe(
|
|
469
473
|
{
|
|
470
474
|
...t
|
|
471
475
|
},
|
|
472
|
-
|
|
473
|
-
)),
|
|
476
|
+
i
|
|
477
|
+
)), n({
|
|
474
478
|
components: { ...t.components },
|
|
475
479
|
groupComponentMap: { ...t.groupComponentMap },
|
|
476
480
|
conditionsByDependency: s,
|
|
477
|
-
screenValidity:
|
|
478
|
-
}),
|
|
481
|
+
screenValidity: l
|
|
482
|
+
}), e.addedComponents;
|
|
479
483
|
},
|
|
480
484
|
addRepeaterIteration: (o) => {
|
|
481
|
-
const t = r(),
|
|
482
|
-
if (!
|
|
485
|
+
const t = r(), e = t.components[o];
|
|
486
|
+
if (!e || e.type !== "repeater" || !e.components)
|
|
483
487
|
return;
|
|
484
|
-
|
|
485
|
-
const s = { ...t.conditionsByDependency },
|
|
486
|
-
const
|
|
487
|
-
if (
|
|
488
|
+
e.addedComponents || (e.addedComponents = []);
|
|
489
|
+
const s = { ...t.conditionsByDependency }, c = e.components.map((d, f) => {
|
|
490
|
+
const p = X(d);
|
|
491
|
+
if (p.uuid = [
|
|
488
492
|
o,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
].join(":"),
|
|
492
|
-
const g = "when" in
|
|
493
|
-
g && (
|
|
493
|
+
e.addedComponents.length,
|
|
494
|
+
f
|
|
495
|
+
].join(":"), p.conditions && Object.keys(p.conditions).length > 0) {
|
|
496
|
+
const g = "when" in p.conditions ? p.conditions : null;
|
|
497
|
+
g && (p.conditions = g, ne(
|
|
494
498
|
s,
|
|
495
|
-
|
|
499
|
+
p.uuid,
|
|
496
500
|
g,
|
|
497
501
|
"component"
|
|
498
502
|
));
|
|
499
503
|
}
|
|
500
|
-
const y =
|
|
501
|
-
return
|
|
504
|
+
const y = M(p);
|
|
505
|
+
return p.valid = y.length === 0, p;
|
|
502
506
|
});
|
|
503
|
-
|
|
504
|
-
const
|
|
505
|
-
|
|
507
|
+
e.addedComponents.push(c);
|
|
508
|
+
const i = fe(t, o), l = { ...t.screenValidity };
|
|
509
|
+
i && (l[i] = oe(
|
|
506
510
|
{
|
|
507
511
|
...t
|
|
508
512
|
},
|
|
509
|
-
|
|
513
|
+
i
|
|
510
514
|
));
|
|
511
|
-
const
|
|
515
|
+
const a = {
|
|
512
516
|
...t,
|
|
513
517
|
components: { ...t.components }
|
|
514
518
|
};
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
return
|
|
519
|
+
xe(a);
|
|
520
|
+
const u = Ee(a);
|
|
521
|
+
return n({
|
|
518
522
|
components: { ...t.components },
|
|
519
523
|
conditionsByDependency: s,
|
|
520
|
-
screenValidity:
|
|
521
|
-
calculationResults:
|
|
522
|
-
}),
|
|
524
|
+
screenValidity: l,
|
|
525
|
+
calculationResults: u
|
|
526
|
+
}), e.addedComponents;
|
|
523
527
|
},
|
|
524
528
|
removeRepeaterIteration: (o, t) => {
|
|
525
529
|
var g;
|
|
526
|
-
const
|
|
530
|
+
const e = r(), s = e.components[o];
|
|
527
531
|
if (!s || s.type !== "repeater" || !s.addedComponents)
|
|
528
532
|
return;
|
|
529
|
-
const
|
|
530
|
-
if (s.addedComponents.length <=
|
|
531
|
-
const
|
|
533
|
+
const c = ((g = s.properties) == null ? void 0 : g.minIterations) ?? 1;
|
|
534
|
+
if (s.addedComponents.length <= c) return;
|
|
535
|
+
const i = s.addedComponents[t], l = new Set(i.map((v) => v.uuid));
|
|
532
536
|
s.addedComponents.splice(t, 1);
|
|
533
|
-
const
|
|
534
|
-
for (const
|
|
535
|
-
delete
|
|
536
|
-
for (const
|
|
537
|
-
const
|
|
538
|
-
b.length === 0 ? delete
|
|
537
|
+
const a = { ...e.conditionsByDependency }, u = { ...e.validationErrors };
|
|
538
|
+
for (const v of l)
|
|
539
|
+
delete u[v], delete a[v];
|
|
540
|
+
for (const v of Object.keys(a)) {
|
|
541
|
+
const h = a[v], b = h.filter((C) => !l.has(C.target));
|
|
542
|
+
b.length === 0 ? delete a[v] : b.length !== h.length && (a[v] = b);
|
|
539
543
|
}
|
|
540
|
-
for (let
|
|
541
|
-
s.addedComponents[
|
|
542
|
-
const
|
|
543
|
-
if (
|
|
544
|
-
|
|
545
|
-
for (const
|
|
546
|
-
for (const
|
|
547
|
-
|
|
544
|
+
for (let v = t; v < s.addedComponents.length; v++)
|
|
545
|
+
s.addedComponents[v].forEach((h, b) => {
|
|
546
|
+
const C = h.uuid, S = [o, v, b].join(":");
|
|
547
|
+
if (C !== S) {
|
|
548
|
+
h.uuid = S, C in u && (u[S] = u[C], delete u[C]), C in a && (a[S] = a[C], delete a[C]);
|
|
549
|
+
for (const w of Object.values(a))
|
|
550
|
+
for (const V of w)
|
|
551
|
+
V.target === C && (V.target = S);
|
|
548
552
|
}
|
|
549
553
|
});
|
|
550
|
-
const
|
|
551
|
-
|
|
554
|
+
const d = fe(e, o), f = { ...e.screenValidity };
|
|
555
|
+
d && (f[d] = oe(
|
|
552
556
|
{
|
|
553
|
-
...
|
|
557
|
+
...e
|
|
554
558
|
},
|
|
555
|
-
|
|
559
|
+
d
|
|
556
560
|
));
|
|
557
|
-
const
|
|
558
|
-
...
|
|
559
|
-
components: { ...
|
|
561
|
+
const p = {
|
|
562
|
+
...e,
|
|
563
|
+
components: { ...e.components }
|
|
560
564
|
};
|
|
561
|
-
|
|
562
|
-
const y =
|
|
563
|
-
|
|
564
|
-
components: { ...
|
|
565
|
-
conditionsByDependency:
|
|
566
|
-
validationErrors:
|
|
567
|
-
screenValidity:
|
|
565
|
+
xe(p);
|
|
566
|
+
const y = Ee(p);
|
|
567
|
+
n({
|
|
568
|
+
components: { ...e.components },
|
|
569
|
+
conditionsByDependency: a,
|
|
570
|
+
validationErrors: u,
|
|
571
|
+
screenValidity: f,
|
|
568
572
|
calculationResults: y
|
|
569
573
|
});
|
|
570
574
|
}
|
|
571
|
-
}),
|
|
572
|
-
const
|
|
573
|
-
for (const
|
|
574
|
-
|
|
575
|
+
}), ee = (n, r) => tn(n.components, r), ne = (n, r, o, t) => {
|
|
576
|
+
const e = /* @__PURE__ */ new Set();
|
|
577
|
+
for (const c of o.when.rules)
|
|
578
|
+
e.add(c.source);
|
|
575
579
|
const s = { target: r, type: t, config: o };
|
|
576
|
-
for (const
|
|
577
|
-
|
|
578
|
-
},
|
|
580
|
+
for (const c of e)
|
|
581
|
+
n[c] || (n[c] = []), n[c].push(s);
|
|
582
|
+
}, In = (n, r) => {
|
|
579
583
|
var o, t;
|
|
580
|
-
return r.includes(":") ? (o =
|
|
581
|
-
},
|
|
582
|
-
const t = r(),
|
|
583
|
-
if (!
|
|
584
|
+
return r.includes(":") ? (o = ee(n, r)) == null ? void 0 : o.value : (t = n.components[r]) == null ? void 0 : t.value;
|
|
585
|
+
}, ce = (n, r) => hn(r, (o, t) => (t == null ? void 0 : t.sourceType) === "context" ? n.externalContext[t.source] : In(n, o)), kn = (n, r, o) => {
|
|
586
|
+
const t = r(), e = t.conditionsByDependency[o];
|
|
587
|
+
if (!e || e.length === 0) return null;
|
|
584
588
|
let s = !1;
|
|
585
|
-
const
|
|
586
|
-
for (const
|
|
587
|
-
const
|
|
588
|
-
i
|
|
589
|
+
const c = { ...t.conditionResults };
|
|
590
|
+
for (const i of e) {
|
|
591
|
+
const l = ce(t, i.config);
|
|
592
|
+
c[i.target] !== l && (c[i.target] = l, s = !0);
|
|
589
593
|
}
|
|
590
|
-
return s ?
|
|
591
|
-
},
|
|
594
|
+
return s ? c : null;
|
|
595
|
+
}, Bn = (n) => {
|
|
592
596
|
const r = {}, o = /* @__PURE__ */ new Set();
|
|
593
|
-
for (const t of Object.values(
|
|
594
|
-
for (const
|
|
595
|
-
o.has(
|
|
597
|
+
for (const t of Object.values(n.conditionsByDependency))
|
|
598
|
+
for (const e of t)
|
|
599
|
+
o.has(e.target) || (o.add(e.target), r[e.target] = ce(n, e.config));
|
|
596
600
|
return r;
|
|
597
|
-
},
|
|
598
|
-
if (!
|
|
599
|
-
const r = "label" in
|
|
600
|
-
uuid:
|
|
601
|
-
type:
|
|
602
|
-
value:
|
|
601
|
+
}, Ne = (n) => {
|
|
602
|
+
if (!n || ve(n.type)) return null;
|
|
603
|
+
const r = "label" in n.properties ? n.properties.label : "", o = {
|
|
604
|
+
uuid: n.uuid,
|
|
605
|
+
type: n.type,
|
|
606
|
+
value: n.value
|
|
603
607
|
};
|
|
604
608
|
return r && (o.label = r), o;
|
|
605
|
-
},
|
|
606
|
-
if (
|
|
607
|
-
return
|
|
608
|
-
},
|
|
609
|
+
}, Ge = (n) => {
|
|
610
|
+
if (n.conditions && "when" in n.conditions)
|
|
611
|
+
return n.conditions;
|
|
612
|
+
}, On = (n) => {
|
|
609
613
|
const r = {
|
|
610
|
-
uuid:
|
|
611
|
-
metadata:
|
|
614
|
+
uuid: n.flowUUID,
|
|
615
|
+
metadata: n.metadata,
|
|
612
616
|
screens: []
|
|
613
617
|
}, o = (t) => {
|
|
614
|
-
const
|
|
615
|
-
if (!
|
|
616
|
-
const s =
|
|
617
|
-
return
|
|
618
|
+
const e = n.screens[t];
|
|
619
|
+
if (!e) return !1;
|
|
620
|
+
const s = e.conditions && "when" in e.conditions ? e.conditions : void 0;
|
|
621
|
+
return te(s, n.conditionResults[t]);
|
|
618
622
|
};
|
|
619
|
-
return r.screens =
|
|
620
|
-
const
|
|
623
|
+
return r.screens = n.screenOrder.filter((t) => !o(t)).map((t) => {
|
|
624
|
+
const e = n.screens[t], s = {
|
|
621
625
|
uuid: t,
|
|
622
|
-
components:
|
|
623
|
-
const
|
|
624
|
-
if (!
|
|
625
|
-
const
|
|
626
|
-
if (
|
|
626
|
+
components: e.components.map((c) => {
|
|
627
|
+
const i = n.components[c.uuid];
|
|
628
|
+
if (!i) return null;
|
|
629
|
+
const l = Ge(i);
|
|
630
|
+
if (te(l, n.conditionResults[c.uuid]))
|
|
627
631
|
return null;
|
|
628
|
-
if ((
|
|
629
|
-
const
|
|
630
|
-
return
|
|
631
|
-
...
|
|
632
|
-
components:
|
|
633
|
-
(
|
|
634
|
-
const
|
|
635
|
-
return !
|
|
636
|
-
|
|
637
|
-
|
|
632
|
+
if ((i.type === "group" || i.type === "repeater") && i.addedComponents) {
|
|
633
|
+
const a = Ne(i);
|
|
634
|
+
return a ? {
|
|
635
|
+
...a,
|
|
636
|
+
components: i.addedComponents.map(
|
|
637
|
+
(u) => u.filter((d) => {
|
|
638
|
+
const f = Ge(d);
|
|
639
|
+
return !te(
|
|
640
|
+
f,
|
|
641
|
+
n.conditionResults[d.uuid]
|
|
638
642
|
);
|
|
639
|
-
}).map((
|
|
643
|
+
}).map((d) => Ne(d)).filter((d) => d !== null)
|
|
640
644
|
)
|
|
641
645
|
} : null;
|
|
642
646
|
}
|
|
643
|
-
return
|
|
644
|
-
}).filter((
|
|
647
|
+
return Ne(i);
|
|
648
|
+
}).filter((c) => c !== null)
|
|
645
649
|
};
|
|
646
|
-
return
|
|
650
|
+
return e.label && (s.label = e.label), s;
|
|
647
651
|
}), r;
|
|
648
|
-
},
|
|
652
|
+
}, be = Ke(
|
|
649
653
|
null
|
|
650
654
|
);
|
|
651
|
-
function
|
|
652
|
-
const r =
|
|
655
|
+
function P(n) {
|
|
656
|
+
const r = Ie(be);
|
|
653
657
|
if (!r)
|
|
654
658
|
throw new Error("useFBREStore must be used within an FBRE provider");
|
|
655
|
-
return
|
|
659
|
+
return Q(r, n);
|
|
656
660
|
}
|
|
657
|
-
const
|
|
658
|
-
const
|
|
659
|
-
if (!
|
|
661
|
+
const Ce = () => {
|
|
662
|
+
const n = Ie(be);
|
|
663
|
+
if (!n)
|
|
660
664
|
throw new Error("useFBREStoreApi must be used within an FBRE provider");
|
|
661
|
-
return
|
|
662
|
-
},
|
|
665
|
+
return n;
|
|
666
|
+
}, ue = (n) => !n || Object.keys(n).length === 0 ? null : "when" in n ? n : null, Vn = [], Tn = () => Qe((n, r) => ({
|
|
663
667
|
// Identity
|
|
664
668
|
flowUUID: "",
|
|
665
669
|
metadata: {},
|
|
@@ -685,206 +689,208 @@ const Ke = () => {
|
|
|
685
689
|
calculationsByDependency: {},
|
|
686
690
|
// Computed components
|
|
687
691
|
computedByDependency: {},
|
|
692
|
+
// Selection re-click tracking
|
|
693
|
+
selectionTick: 0,
|
|
688
694
|
// Actions
|
|
689
|
-
loadFlow: (o, t,
|
|
690
|
-
var
|
|
691
|
-
const s = {},
|
|
692
|
-
o.screens.forEach((
|
|
693
|
-
const
|
|
694
|
-
s[
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
695
|
+
loadFlow: (o, t, e) => {
|
|
696
|
+
var V;
|
|
697
|
+
const s = {}, c = [], i = {}, l = {}, a = {}, u = {}, d = {}, f = {}, p = {};
|
|
698
|
+
o.screens.forEach((E) => {
|
|
699
|
+
const T = ue(E.conditions), _ = T ? { ...E, conditions: T } : { ...E };
|
|
700
|
+
s[E.uuid] = _, c.push(E.uuid), T && ne(
|
|
701
|
+
u,
|
|
702
|
+
E.uuid,
|
|
703
|
+
T,
|
|
698
704
|
"screen"
|
|
699
|
-
),
|
|
700
|
-
var
|
|
701
|
-
const
|
|
702
|
-
if (
|
|
703
|
-
l,
|
|
704
|
-
S.uuid,
|
|
705
|
-
D,
|
|
706
|
-
"component"
|
|
707
|
-
), (V = B.properties) != null && V.validation && ae(
|
|
705
|
+
), E.components.forEach((N) => {
|
|
706
|
+
var U;
|
|
707
|
+
const I = ue(N.conditions), k = X(N);
|
|
708
|
+
if (I && (k.conditions = I), i[N.uuid] = k, I && ne(
|
|
708
709
|
u,
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
710
|
+
N.uuid,
|
|
711
|
+
I,
|
|
712
|
+
"component"
|
|
713
|
+
), (U = k.properties) != null && U.validation && le(
|
|
714
|
+
d,
|
|
715
|
+
N.uuid,
|
|
716
|
+
k.properties.validation
|
|
717
|
+
), (N.type === "group" || N.type === "repeater") && N.components) {
|
|
718
|
+
const A = i[N.uuid];
|
|
719
|
+
A.addedComponents || (A.addedComponents = []);
|
|
720
|
+
const q = N.properties ?? {}, j = N.type === "repeater" ? q.initialData : void 0, O = N.type === "repeater" ? q.minIterations : void 0, $ = j ? j.length : N.type === "repeater" && O && O > 1 ? O : 1;
|
|
721
|
+
for (let Y = 0; Y < $; Y++) {
|
|
722
|
+
const K = N.components.map((R, G) => {
|
|
723
|
+
var se;
|
|
724
|
+
const x = X(R);
|
|
725
|
+
x.uuid = [
|
|
726
|
+
N.uuid,
|
|
727
|
+
A.addedComponents.length,
|
|
728
|
+
G
|
|
729
|
+
].join(":"), j && j[Y] && R.uuid in j[Y] && (x.value = j[Y][R.uuid]), N.type === "group" && (l[x.uuid] = R.uuid), Y === 0 && (a[R.uuid] = x.uuid);
|
|
730
|
+
const L = ue(x.conditions);
|
|
731
|
+
L && (x.conditions = L, ne(
|
|
731
732
|
u,
|
|
732
|
-
|
|
733
|
-
|
|
733
|
+
x.uuid,
|
|
734
|
+
L,
|
|
735
|
+
"component"
|
|
736
|
+
)), (se = x.properties) != null && se.validation && le(
|
|
737
|
+
d,
|
|
738
|
+
x.uuid,
|
|
739
|
+
x.properties.validation
|
|
734
740
|
);
|
|
735
|
-
const
|
|
736
|
-
return
|
|
741
|
+
const re = M(x);
|
|
742
|
+
return x.valid = re.length === 0, re.length > 0 && (f[x.uuid] = re), x;
|
|
737
743
|
});
|
|
738
|
-
|
|
744
|
+
A.addedComponents.push(K);
|
|
739
745
|
}
|
|
740
746
|
}
|
|
741
747
|
});
|
|
742
|
-
}), t && t.screens.forEach((
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
const
|
|
746
|
-
if (
|
|
747
|
-
if ((
|
|
748
|
-
if (
|
|
749
|
-
const
|
|
750
|
-
(
|
|
748
|
+
}), t && t.screens.forEach((E) => {
|
|
749
|
+
const T = c.indexOf(E.uuid);
|
|
750
|
+
T < 0 || E.components.forEach((_) => {
|
|
751
|
+
const N = i[_.uuid];
|
|
752
|
+
if (N)
|
|
753
|
+
if ((N.type === "group" || N.type === "repeater") && _.components && N.addedComponents) {
|
|
754
|
+
if (_.components.length > 1) {
|
|
755
|
+
const I = N.addedComponents.length, k = _.components.length - I, W = o.screens[T].components.find(
|
|
756
|
+
(U) => U.uuid === N.uuid
|
|
751
757
|
);
|
|
752
|
-
for (let
|
|
753
|
-
if (
|
|
754
|
-
const
|
|
755
|
-
(
|
|
756
|
-
var
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
].join(":"),
|
|
763
|
-
const
|
|
764
|
-
|
|
758
|
+
for (let U = 0; U < k; U++)
|
|
759
|
+
if (W != null && W.components) {
|
|
760
|
+
const A = W.components.map(
|
|
761
|
+
(q, j) => {
|
|
762
|
+
var K;
|
|
763
|
+
const O = X(q);
|
|
764
|
+
O.uuid = [
|
|
765
|
+
N.uuid,
|
|
766
|
+
N.addedComponents.length,
|
|
767
|
+
j
|
|
768
|
+
].join(":"), N.type === "group" && (l[O.uuid] = q.uuid), a[q.uuid] || (a[q.uuid] = O.uuid);
|
|
769
|
+
const $ = ue(
|
|
770
|
+
O.conditions
|
|
765
771
|
);
|
|
766
|
-
|
|
767
|
-
l,
|
|
768
|
-
E.uuid,
|
|
769
|
-
_,
|
|
770
|
-
"component"
|
|
771
|
-
)), (ee = E.properties) != null && ee.validation && ae(
|
|
772
|
+
$ && (O.conditions = $, ne(
|
|
772
773
|
u,
|
|
773
|
-
|
|
774
|
-
|
|
774
|
+
O.uuid,
|
|
775
|
+
$,
|
|
776
|
+
"component"
|
|
777
|
+
)), (K = O.properties) != null && K.validation && le(
|
|
778
|
+
d,
|
|
779
|
+
O.uuid,
|
|
780
|
+
O.properties.validation
|
|
775
781
|
);
|
|
776
|
-
const
|
|
777
|
-
return
|
|
782
|
+
const Y = M(O);
|
|
783
|
+
return O.valid = Y.length === 0, Y.length > 0 && (f[O.uuid] = Y), O;
|
|
778
784
|
}
|
|
779
785
|
);
|
|
780
|
-
|
|
786
|
+
N.addedComponents.push(A);
|
|
781
787
|
}
|
|
782
788
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
for (const
|
|
786
|
-
const
|
|
787
|
-
if (
|
|
788
|
-
|
|
789
|
-
const
|
|
790
|
-
|
|
789
|
+
_.components.forEach((I) => {
|
|
790
|
+
I.forEach((k) => {
|
|
791
|
+
for (const W of N.addedComponents) {
|
|
792
|
+
const U = W.find((A) => A.uuid === k.uuid);
|
|
793
|
+
if (U) {
|
|
794
|
+
U.value = k.value;
|
|
795
|
+
const A = M(U);
|
|
796
|
+
U.valid = A.length === 0, f[U.uuid] = A;
|
|
791
797
|
break;
|
|
792
798
|
}
|
|
793
799
|
}
|
|
794
800
|
});
|
|
795
801
|
});
|
|
796
802
|
} else {
|
|
797
|
-
|
|
798
|
-
const
|
|
799
|
-
|
|
803
|
+
N.value = _.value;
|
|
804
|
+
const I = M(N);
|
|
805
|
+
N.valid = I.length === 0, f[N.uuid] = I;
|
|
800
806
|
}
|
|
801
807
|
});
|
|
802
808
|
});
|
|
803
|
-
for (const
|
|
804
|
-
const
|
|
805
|
-
if (!(
|
|
806
|
-
const
|
|
807
|
-
|
|
809
|
+
for (const E of Object.keys(i)) {
|
|
810
|
+
const T = i[E];
|
|
811
|
+
if (!(T.type === "group" || T.type === "repeater" || !((V = T.properties) != null && V.validation)) && !(E in f)) {
|
|
812
|
+
const _ = M(T);
|
|
813
|
+
T.valid = _.length === 0, _.length > 0 && (f[E] = _);
|
|
808
814
|
}
|
|
809
815
|
}
|
|
810
816
|
const y = {
|
|
811
817
|
...r(),
|
|
812
|
-
externalContext:
|
|
818
|
+
externalContext: e ?? {},
|
|
813
819
|
screens: s,
|
|
814
|
-
screenOrder:
|
|
815
|
-
components:
|
|
816
|
-
groupComponentMap:
|
|
817
|
-
templateComponentMap:
|
|
818
|
-
conditionsByDependency:
|
|
820
|
+
screenOrder: c,
|
|
821
|
+
components: i,
|
|
822
|
+
groupComponentMap: l,
|
|
823
|
+
templateComponentMap: a,
|
|
824
|
+
conditionsByDependency: u,
|
|
819
825
|
conditionResults: {},
|
|
820
|
-
validationErrors:
|
|
821
|
-
validationsByDependency:
|
|
822
|
-
}, g =
|
|
823
|
-
y.conditionResults = g,
|
|
824
|
-
|
|
826
|
+
validationErrors: f,
|
|
827
|
+
validationsByDependency: d
|
|
828
|
+
}, g = Bn(y);
|
|
829
|
+
y.conditionResults = g, c.forEach((E) => {
|
|
830
|
+
p[E] = oe(y, E);
|
|
825
831
|
});
|
|
826
|
-
const
|
|
832
|
+
const v = Rn(i), h = {
|
|
827
833
|
...y,
|
|
828
|
-
computedByDependency:
|
|
834
|
+
computedByDependency: v,
|
|
829
835
|
calculationResults: {},
|
|
830
|
-
screenValidity:
|
|
836
|
+
screenValidity: p
|
|
831
837
|
};
|
|
832
|
-
|
|
833
|
-
const b = o.calculations ?? [],
|
|
834
|
-
...
|
|
838
|
+
xe(h);
|
|
839
|
+
const b = o.calculations ?? [], C = Nn(b), S = {
|
|
840
|
+
...h,
|
|
835
841
|
calculations: b
|
|
836
|
-
},
|
|
837
|
-
|
|
842
|
+
}, w = Ee(S);
|
|
843
|
+
n({
|
|
838
844
|
flowUUID: o.uuid,
|
|
839
845
|
metadata: o.metadata,
|
|
840
846
|
config: o.config ?? {},
|
|
841
|
-
externalContext:
|
|
847
|
+
externalContext: e ?? {},
|
|
842
848
|
screens: s,
|
|
843
|
-
screenOrder:
|
|
844
|
-
components:
|
|
845
|
-
groupComponentMap:
|
|
846
|
-
templateComponentMap:
|
|
847
|
-
conditionsByDependency:
|
|
849
|
+
screenOrder: c,
|
|
850
|
+
components: i,
|
|
851
|
+
groupComponentMap: l,
|
|
852
|
+
templateComponentMap: a,
|
|
853
|
+
conditionsByDependency: u,
|
|
848
854
|
conditionResults: g,
|
|
849
|
-
screenValidity:
|
|
850
|
-
validationErrors:
|
|
851
|
-
validationsByDependency:
|
|
855
|
+
screenValidity: p,
|
|
856
|
+
validationErrors: f,
|
|
857
|
+
validationsByDependency: d,
|
|
852
858
|
calculations: b,
|
|
853
|
-
calculationResults:
|
|
854
|
-
calculationsByDependency:
|
|
855
|
-
computedByDependency:
|
|
859
|
+
calculationResults: w,
|
|
860
|
+
calculationsByDependency: C,
|
|
861
|
+
computedByDependency: v
|
|
856
862
|
});
|
|
857
863
|
},
|
|
858
864
|
updateContext: (o) => {
|
|
859
|
-
const t = r(),
|
|
860
|
-
for (const
|
|
861
|
-
|
|
862
|
-
for (const
|
|
863
|
-
!(
|
|
865
|
+
const t = r(), e = t.externalContext, s = [];
|
|
866
|
+
for (const a of Object.keys(o))
|
|
867
|
+
e[a] !== o[a] && s.push(a);
|
|
868
|
+
for (const a of Object.keys(e))
|
|
869
|
+
!(a in o) && !s.includes(a) && s.push(a);
|
|
864
870
|
if (s.length === 0) return;
|
|
865
|
-
const
|
|
866
|
-
let
|
|
867
|
-
const
|
|
868
|
-
for (const
|
|
869
|
-
const
|
|
870
|
-
if (!(!
|
|
871
|
-
for (const
|
|
872
|
-
if (
|
|
873
|
-
|
|
874
|
-
const
|
|
875
|
-
|
|
871
|
+
const c = { ...t.conditionResults };
|
|
872
|
+
let i = !1;
|
|
873
|
+
const l = /* @__PURE__ */ new Set();
|
|
874
|
+
for (const a of s) {
|
|
875
|
+
const u = t.conditionsByDependency[a];
|
|
876
|
+
if (!(!u || u.length === 0))
|
|
877
|
+
for (const d of u) {
|
|
878
|
+
if (l.has(d.target)) continue;
|
|
879
|
+
l.add(d.target);
|
|
880
|
+
const f = { ...t, externalContext: o }, p = ce(f, d.config);
|
|
881
|
+
c[d.target] !== p && (c[d.target] = p, i = !0);
|
|
876
882
|
}
|
|
877
883
|
}
|
|
878
|
-
if (
|
|
879
|
-
const
|
|
880
|
-
for (const
|
|
881
|
-
|
|
882
|
-
|
|
884
|
+
if (i) {
|
|
885
|
+
const a = { ...t, conditionResults: c }, u = {};
|
|
886
|
+
for (const d of t.screenOrder)
|
|
887
|
+
u[d] = oe(a, d);
|
|
888
|
+
n({ externalContext: o, conditionResults: c, screenValidity: u });
|
|
883
889
|
} else
|
|
884
|
-
|
|
890
|
+
n({ externalContext: o });
|
|
885
891
|
},
|
|
886
|
-
...
|
|
887
|
-
getFlowData: () =>
|
|
892
|
+
...Dn(n, r),
|
|
893
|
+
getFlowData: () => On(r()),
|
|
888
894
|
getScreenByIndex: (o) => {
|
|
889
895
|
const t = r();
|
|
890
896
|
return o < 0 || o >= t.screenOrder.length ? null : t.screens[t.screenOrder[o]];
|
|
@@ -893,39 +899,39 @@ const Ke = () => {
|
|
|
893
899
|
const t = r();
|
|
894
900
|
return o < 0 || o >= t.screenOrder.length ? !0 : t.screenValidity[t.screenOrder[o]] ?? !0;
|
|
895
901
|
},
|
|
896
|
-
getValidationErrors: (o) => r().validationErrors[o] ??
|
|
902
|
+
getValidationErrors: (o) => r().validationErrors[o] ?? Vn,
|
|
897
903
|
evaluateFlowValidation: () => {
|
|
898
904
|
const o = r(), t = {};
|
|
899
|
-
let
|
|
905
|
+
let e = !0;
|
|
900
906
|
return o.screenOrder.forEach((s) => {
|
|
901
|
-
const
|
|
902
|
-
t[s] =
|
|
903
|
-
}),
|
|
907
|
+
const c = oe(o, s);
|
|
908
|
+
t[s] = c, c || (e = !1);
|
|
909
|
+
}), n({ screenValidity: t }), e;
|
|
904
910
|
},
|
|
905
911
|
getMaxScreenCount: () => r().screenOrder.length - 1,
|
|
906
912
|
getCalculationResult: (o) => r().calculationResults[o] ?? null
|
|
907
|
-
})),
|
|
908
|
-
var
|
|
909
|
-
const r =
|
|
913
|
+
})), _n = ({ uuid: n }) => {
|
|
914
|
+
var i;
|
|
915
|
+
const r = P((l) => l.components[n]), o = P((l) => l.conditionResults[n]);
|
|
910
916
|
if (!r) return null;
|
|
911
917
|
const t = r.conditions && "when" in r.conditions ? r.conditions : void 0;
|
|
912
|
-
if (
|
|
913
|
-
const
|
|
914
|
-
if (!
|
|
918
|
+
if (te(t, o)) return null;
|
|
919
|
+
const e = bn(r.type);
|
|
920
|
+
if (!e)
|
|
915
921
|
return console.warn(`FBRE: No renderer for component type "${r.type}"`), null;
|
|
916
|
-
const s = (
|
|
917
|
-
return /* @__PURE__ */ m("div", { className:
|
|
918
|
-
},
|
|
919
|
-
const r =
|
|
920
|
-
const t = o.screenOrder[
|
|
922
|
+
const s = (i = r.properties) == null ? void 0 : i.width, c = s && s !== "full" ? `fbre-component fbre-width-${s}` : "fbre-component";
|
|
923
|
+
return /* @__PURE__ */ m("div", { className: c, "data-uuid": n, children: /* @__PURE__ */ m(e, { uuid: n }) });
|
|
924
|
+
}, De = ({ screenIndex: n }) => {
|
|
925
|
+
const r = P((o) => {
|
|
926
|
+
const t = o.screenOrder[n];
|
|
921
927
|
return t ? o.screens[t] : null;
|
|
922
928
|
});
|
|
923
|
-
return r ? /* @__PURE__ */ m("div", { className: "fbre-screen", children: r.components.map((o) => /* @__PURE__ */ m(
|
|
924
|
-
},
|
|
929
|
+
return r ? /* @__PURE__ */ m("div", { className: "fbre-screen", children: r.components.map((o) => /* @__PURE__ */ m(_n, { uuid: o.uuid }, o.uuid)) }) : null;
|
|
930
|
+
}, Je = ({ size: n = 14 }) => /* @__PURE__ */ m(
|
|
925
931
|
"svg",
|
|
926
932
|
{
|
|
927
|
-
width:
|
|
928
|
-
height:
|
|
933
|
+
width: n,
|
|
934
|
+
height: n,
|
|
929
935
|
viewBox: "0 0 24 24",
|
|
930
936
|
fill: "none",
|
|
931
937
|
stroke: "currentColor",
|
|
@@ -934,109 +940,126 @@ const Ke = () => {
|
|
|
934
940
|
strokeLinejoin: "round",
|
|
935
941
|
children: /* @__PURE__ */ m("polyline", { points: "4,12 9.5,17.5 20,7" })
|
|
936
942
|
}
|
|
937
|
-
),
|
|
938
|
-
position:
|
|
943
|
+
), Mn = ({ size: n = 12 }) => /* @__PURE__ */ m("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ m("path", { d: "M7 10l5 5 5-5z" }) }), Un = ({ size: n = 16 }) => /* @__PURE__ */ m("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ m("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) }), An = ({ size: n = 16 }) => /* @__PURE__ */ m("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ m("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }) }), ze = ({
|
|
944
|
+
position: n,
|
|
939
945
|
screenIndex: r,
|
|
940
946
|
maxScreenIndex: o,
|
|
941
947
|
allowInvalidTransition: t,
|
|
942
|
-
screenValidity:
|
|
948
|
+
screenValidity: e,
|
|
943
949
|
summaryEnabled: s,
|
|
944
|
-
summaryActive:
|
|
945
|
-
atMaxScreen:
|
|
946
|
-
nextButtonLabel:
|
|
947
|
-
backButtonLabel:
|
|
948
|
-
completionLoading:
|
|
949
|
-
nextScreen:
|
|
950
|
-
prevScreen:
|
|
951
|
-
onFlowComplete:
|
|
950
|
+
summaryActive: c,
|
|
951
|
+
atMaxScreen: i,
|
|
952
|
+
nextButtonLabel: l,
|
|
953
|
+
backButtonLabel: a,
|
|
954
|
+
completionLoading: u,
|
|
955
|
+
nextScreen: d,
|
|
956
|
+
prevScreen: f,
|
|
957
|
+
onFlowComplete: p
|
|
952
958
|
}) => {
|
|
953
|
-
const y =
|
|
954
|
-
if (
|
|
955
|
-
return /* @__PURE__ */
|
|
959
|
+
const y = u ?? !1;
|
|
960
|
+
if (n === "back")
|
|
961
|
+
return /* @__PURE__ */ B(
|
|
956
962
|
"button",
|
|
957
963
|
{
|
|
958
964
|
type: "button",
|
|
959
965
|
className: "fbre-btn fbre-btn--secondary",
|
|
960
|
-
disabled: r === 0 && !
|
|
961
|
-
onClick:
|
|
966
|
+
disabled: r === 0 && !c || y,
|
|
967
|
+
onClick: f,
|
|
962
968
|
children: [
|
|
963
|
-
/* @__PURE__ */ m(
|
|
964
|
-
|
|
969
|
+
/* @__PURE__ */ m(Un, {}),
|
|
970
|
+
a || "Back"
|
|
965
971
|
]
|
|
966
972
|
}
|
|
967
973
|
);
|
|
968
|
-
const g = s ?
|
|
969
|
-
return o === 0 ? /* @__PURE__ */
|
|
974
|
+
const g = s ? i && c : i, v = s ? i ? c ? "Done" : "Review" : "Next" : i ? "Done" : "Next";
|
|
975
|
+
return o === 0 ? /* @__PURE__ */ B(
|
|
970
976
|
"button",
|
|
971
977
|
{
|
|
972
978
|
type: "button",
|
|
973
979
|
className: "fbre-btn fbre-btn--primary",
|
|
974
|
-
disabled: y || !
|
|
980
|
+
disabled: y || !e,
|
|
975
981
|
onClick: () => {
|
|
976
|
-
s && !
|
|
982
|
+
s && !c ? d() : p();
|
|
977
983
|
},
|
|
978
984
|
children: [
|
|
979
|
-
|
|
980
|
-
y ? /* @__PURE__ */ m("span", { className: "fbre-btn__spinner" }) : /* @__PURE__ */ m(
|
|
985
|
+
l || (s ? c ? "Complete" : "Review" : "Complete"),
|
|
986
|
+
y ? /* @__PURE__ */ m("span", { className: "fbre-btn__spinner" }) : /* @__PURE__ */ m(Je, { size: 16 })
|
|
981
987
|
]
|
|
982
988
|
}
|
|
983
|
-
) : /* @__PURE__ */
|
|
989
|
+
) : /* @__PURE__ */ B(
|
|
984
990
|
"button",
|
|
985
991
|
{
|
|
986
992
|
type: "button",
|
|
987
993
|
className: "fbre-btn fbre-btn--primary",
|
|
988
|
-
disabled: y || !t && !
|
|
994
|
+
disabled: y || !t && !e || v === "Done" && !e,
|
|
989
995
|
onClick: () => {
|
|
990
|
-
g ?
|
|
996
|
+
g ? p() : d();
|
|
991
997
|
},
|
|
992
998
|
children: [
|
|
993
|
-
|
|
994
|
-
y ? /* @__PURE__ */ m("span", { className: "fbre-btn__spinner" }) : g ? /* @__PURE__ */ m(
|
|
999
|
+
l || v,
|
|
1000
|
+
y ? /* @__PURE__ */ m("span", { className: "fbre-btn__spinner" }) : g ? /* @__PURE__ */ m(Je, { size: 16 }) : /* @__PURE__ */ m(An, {})
|
|
995
1001
|
]
|
|
996
1002
|
}
|
|
997
1003
|
);
|
|
998
|
-
},
|
|
1004
|
+
}, Fn = ({ current: n, total: r, stepperStyle: o }) => {
|
|
999
1005
|
if (r <= 1) return null;
|
|
1000
|
-
const
|
|
1001
|
-
return
|
|
1002
|
-
"div",
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
{
|
|
1010
|
-
className: "fbre-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1006
|
+
const t = r > 1 ? n / (r - 1) * 100 : 100, s = !!o && o !== "default" || r <= 6;
|
|
1007
|
+
return /* @__PURE__ */ B(fn, { children: [
|
|
1008
|
+
s && /* @__PURE__ */ m("div", { className: "fbre-stepper fbre-stepper--dots", children: Array.from({ length: r }, (c, i) => /* @__PURE__ */ m(
|
|
1009
|
+
"div",
|
|
1010
|
+
{
|
|
1011
|
+
className: `fbre-stepper__dot${i === n ? " active" : i < n ? " completed" : ""}`
|
|
1012
|
+
},
|
|
1013
|
+
i
|
|
1014
|
+
)) }),
|
|
1015
|
+
s && /* @__PURE__ */ B("div", { className: "fbre-stepper fbre-stepper--bar-alt", children: [
|
|
1016
|
+
/* @__PURE__ */ m("div", { className: "fbre-stepper__track", children: /* @__PURE__ */ m(
|
|
1017
|
+
"div",
|
|
1018
|
+
{
|
|
1019
|
+
className: "fbre-stepper__fill",
|
|
1020
|
+
style: { width: `${t}%` }
|
|
1021
|
+
}
|
|
1022
|
+
) }),
|
|
1023
|
+
/* @__PURE__ */ B("span", { className: "fbre-stepper__counter", children: [
|
|
1024
|
+
n + 1,
|
|
1025
|
+
" of ",
|
|
1026
|
+
r
|
|
1027
|
+
] })
|
|
1028
|
+
] }),
|
|
1029
|
+
!s && /* @__PURE__ */ m("div", { className: "fbre-stepper fbre-stepper--bar", children: /* @__PURE__ */ m(
|
|
1030
|
+
"div",
|
|
1031
|
+
{
|
|
1032
|
+
className: "fbre-stepper__fill",
|
|
1033
|
+
style: { width: `${t}%` }
|
|
1034
|
+
}
|
|
1035
|
+
) })
|
|
1036
|
+
] });
|
|
1037
|
+
}, jn = ({ current: n, total: r }) => r <= 1 ? null : /* @__PURE__ */ B("div", { className: "fbre-stepper-text", children: [
|
|
1015
1038
|
"Step ",
|
|
1016
|
-
|
|
1039
|
+
n + 1,
|
|
1017
1040
|
" of ",
|
|
1018
1041
|
r
|
|
1019
|
-
] }),
|
|
1020
|
-
const r =
|
|
1021
|
-
return /* @__PURE__ */
|
|
1042
|
+
] }), Ln = (n) => {
|
|
1043
|
+
const r = n.controlsLayout === "stacked", o = n.showStepper !== !1 && (n.stepperStyle ?? "default") !== "text";
|
|
1044
|
+
return /* @__PURE__ */ B(
|
|
1022
1045
|
"div",
|
|
1023
1046
|
{
|
|
1024
1047
|
className: r ? "fbre-controls fbre-controls--stacked" : "fbre-controls",
|
|
1025
1048
|
children: [
|
|
1026
|
-
|
|
1027
|
-
o &&
|
|
1028
|
-
/* @__PURE__ */ m(
|
|
1049
|
+
n.screenIndex > 0 || n.summaryActive ? /* @__PURE__ */ m(ze, { position: "back", ...n }) : /* @__PURE__ */ m("div", {}),
|
|
1050
|
+
o && n.maxScreenIndex > 0 ? /* @__PURE__ */ m(Fn, { current: n.screenIndex, total: n.maxScreenIndex + 1, stepperStyle: n.stepperStyle }) : /* @__PURE__ */ m("div", {}),
|
|
1051
|
+
/* @__PURE__ */ m(ze, { position: "next", ...n })
|
|
1029
1052
|
]
|
|
1030
1053
|
}
|
|
1031
1054
|
);
|
|
1032
|
-
},
|
|
1033
|
-
component:
|
|
1055
|
+
}, on = ({
|
|
1056
|
+
component: n
|
|
1034
1057
|
}) => {
|
|
1035
|
-
const { uuid: r, label: o, type: t, value:
|
|
1036
|
-
if (
|
|
1058
|
+
const { uuid: r, label: o, type: t, value: e, components: s } = n, c = () => {
|
|
1059
|
+
if (e != null)
|
|
1037
1060
|
switch (t) {
|
|
1038
1061
|
case "fileUpload":
|
|
1039
|
-
return
|
|
1062
|
+
return e.name;
|
|
1040
1063
|
case "inputText":
|
|
1041
1064
|
case "inputTextArea":
|
|
1042
1065
|
case "inputNumber":
|
|
@@ -1044,33 +1067,33 @@ const Ke = () => {
|
|
|
1044
1067
|
case "radio":
|
|
1045
1068
|
case "rating":
|
|
1046
1069
|
case "slider":
|
|
1047
|
-
return
|
|
1070
|
+
return e.toString();
|
|
1048
1071
|
case "computed":
|
|
1049
|
-
return typeof
|
|
1072
|
+
return typeof e == "number" ? e.toString() : "—";
|
|
1050
1073
|
case "toggleSwitch":
|
|
1051
|
-
return
|
|
1074
|
+
return e ? "Yes" : "No";
|
|
1052
1075
|
case "checkbox":
|
|
1053
1076
|
case "dropDownMulti":
|
|
1054
|
-
return
|
|
1077
|
+
return e.length === 0 ? "No options selected" : e.join(", ");
|
|
1055
1078
|
}
|
|
1056
1079
|
return "No response given";
|
|
1057
1080
|
};
|
|
1058
|
-
if (t === "signature" &&
|
|
1059
|
-
const
|
|
1060
|
-
return /* @__PURE__ */
|
|
1081
|
+
if (t === "signature" && e) {
|
|
1082
|
+
const a = typeof e == "string" && e.startsWith("data:");
|
|
1083
|
+
return /* @__PURE__ */ B("div", { className: "fbre-summary__item", children: [
|
|
1061
1084
|
/* @__PURE__ */ m("div", { className: "fbre-summary__item-label", children: o }),
|
|
1062
|
-
/* @__PURE__ */ m("div", { className: "fbre-summary__item-value", children:
|
|
1085
|
+
/* @__PURE__ */ m("div", { className: "fbre-summary__item-value", children: a ? /* @__PURE__ */ m(
|
|
1063
1086
|
"img",
|
|
1064
1087
|
{
|
|
1065
|
-
src:
|
|
1088
|
+
src: e,
|
|
1066
1089
|
alt: "Signature",
|
|
1067
1090
|
style: { maxWidth: "100%", maxHeight: 80 }
|
|
1068
1091
|
}
|
|
1069
|
-
) : /* @__PURE__ */ m("span", { style: { fontFamily: '"Brush Script MT", "Segoe Script", "Dancing Script", cursive', fontSize: 24 }, children:
|
|
1092
|
+
) : /* @__PURE__ */ m("span", { style: { fontFamily: '"Brush Script MT", "Segoe Script", "Dancing Script", cursive', fontSize: 24 }, children: e }) })
|
|
1070
1093
|
] });
|
|
1071
1094
|
}
|
|
1072
|
-
const
|
|
1073
|
-
return /* @__PURE__ */
|
|
1095
|
+
const i = () => s ? s.map((a, u) => /* @__PURE__ */ m("div", { children: a.map((d) => /* @__PURE__ */ m(on, { component: d }, d.uuid)) }, `${r}-${u}`)) : null, l = e == null || typeof e == "string" && e.length === 0 || Array.isArray(e) && e.length === 0;
|
|
1096
|
+
return /* @__PURE__ */ B(
|
|
1074
1097
|
"div",
|
|
1075
1098
|
{
|
|
1076
1099
|
className: `fbre-summary__item${t === "group" || t === "repeater" ? " fbre-summary__item--group" : ""}`,
|
|
@@ -1079,68 +1102,68 @@ const Ke = () => {
|
|
|
1079
1102
|
t !== "group" && t !== "repeater" && /* @__PURE__ */ m(
|
|
1080
1103
|
"div",
|
|
1081
1104
|
{
|
|
1082
|
-
className: `fbre-summary__item-value${
|
|
1083
|
-
children:
|
|
1105
|
+
className: `fbre-summary__item-value${l ? " fbre-summary__item-value--empty" : ""}`,
|
|
1106
|
+
children: c()
|
|
1084
1107
|
}
|
|
1085
1108
|
),
|
|
1086
|
-
(t === "group" || t === "repeater") &&
|
|
1109
|
+
(t === "group" || t === "repeater") && i()
|
|
1087
1110
|
]
|
|
1088
1111
|
}
|
|
1089
1112
|
);
|
|
1090
|
-
},
|
|
1091
|
-
const
|
|
1092
|
-
if (
|
|
1113
|
+
}, Pn = /\$\{([^}]+)\}/g, $n = (n, r) => n.replace(Pn, (o, t) => {
|
|
1114
|
+
const e = r.resolveCalculation(t);
|
|
1115
|
+
if (e !== null) return e;
|
|
1093
1116
|
const s = r.resolveComponentValue(t);
|
|
1094
1117
|
return s !== null ? s : "";
|
|
1095
1118
|
});
|
|
1096
|
-
function
|
|
1097
|
-
const
|
|
1098
|
-
return
|
|
1099
|
-
const
|
|
1100
|
-
var
|
|
1101
|
-
const
|
|
1102
|
-
if (
|
|
1103
|
-
const
|
|
1104
|
-
if (!
|
|
1105
|
-
const
|
|
1106
|
-
return (
|
|
1119
|
+
function Yn() {
|
|
1120
|
+
const n = P((e) => e.components), r = P((e) => e.templateComponentMap), o = P((e) => e.calculations), t = P((e) => e.calculationResults);
|
|
1121
|
+
return ke(() => {
|
|
1122
|
+
const e = new Map(o.map((c) => [c.uuid, c])), s = (c) => {
|
|
1123
|
+
var d, f;
|
|
1124
|
+
const i = n[c];
|
|
1125
|
+
if (i) return i;
|
|
1126
|
+
const l = r[c];
|
|
1127
|
+
if (!l) return;
|
|
1128
|
+
const a = l.split(":"), u = n[a[0]];
|
|
1129
|
+
return (f = (d = u == null ? void 0 : u.addedComponents) == null ? void 0 : d[parseInt(a[1])]) == null ? void 0 : f[parseInt(a[2])];
|
|
1107
1130
|
};
|
|
1108
1131
|
return {
|
|
1109
|
-
resolveComponentValue: (
|
|
1110
|
-
const
|
|
1111
|
-
if (!
|
|
1112
|
-
const
|
|
1113
|
-
return
|
|
1132
|
+
resolveComponentValue: (c) => {
|
|
1133
|
+
const i = s(c);
|
|
1134
|
+
if (!i) return null;
|
|
1135
|
+
const l = i.value;
|
|
1136
|
+
return l == null || l === "" ? null : Array.isArray(l) ? l.join(", ") : String(l);
|
|
1114
1137
|
},
|
|
1115
|
-
resolveCalculation: (
|
|
1116
|
-
const
|
|
1117
|
-
if (!
|
|
1118
|
-
const
|
|
1119
|
-
return
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1138
|
+
resolveCalculation: (c) => {
|
|
1139
|
+
const i = e.get(c);
|
|
1140
|
+
if (!i) return null;
|
|
1141
|
+
const l = t[c] ?? null;
|
|
1142
|
+
return yn(
|
|
1143
|
+
l,
|
|
1144
|
+
i.format,
|
|
1145
|
+
i.decimalPlaces,
|
|
1146
|
+
i.currencySymbol
|
|
1124
1147
|
);
|
|
1125
1148
|
}
|
|
1126
1149
|
};
|
|
1127
|
-
}, [
|
|
1150
|
+
}, [n, r, o, t]);
|
|
1128
1151
|
}
|
|
1129
|
-
const
|
|
1130
|
-
const o =
|
|
1131
|
-
return /* @__PURE__ */
|
|
1132
|
-
/* @__PURE__ */
|
|
1152
|
+
const Gn = ({ screen: n, showToggle: r }) => {
|
|
1153
|
+
const o = Yn(), [t, e] = J(!0);
|
|
1154
|
+
return /* @__PURE__ */ B("div", { children: [
|
|
1155
|
+
/* @__PURE__ */ B(
|
|
1133
1156
|
"div",
|
|
1134
1157
|
{
|
|
1135
1158
|
className: "fbre-summary__screen-header",
|
|
1136
|
-
onClick: () => r &&
|
|
1159
|
+
onClick: () => r && e(!t),
|
|
1137
1160
|
children: [
|
|
1138
|
-
|
|
1161
|
+
n.label && /* @__PURE__ */ m("span", { className: "fbre-summary__screen-label", children: $n(n.label, o) }),
|
|
1139
1162
|
r && /* @__PURE__ */ m(
|
|
1140
1163
|
"span",
|
|
1141
1164
|
{
|
|
1142
1165
|
className: `fbre-summary__screen-toggle${t ? "" : " collapsed"}`,
|
|
1143
|
-
children: /* @__PURE__ */ m(
|
|
1166
|
+
children: /* @__PURE__ */ m(Mn, { size: 20 })
|
|
1144
1167
|
}
|
|
1145
1168
|
)
|
|
1146
1169
|
]
|
|
@@ -1150,134 +1173,221 @@ const Mn = ({ screen: e, showToggle: r }) => {
|
|
|
1150
1173
|
"div",
|
|
1151
1174
|
{
|
|
1152
1175
|
className: `fbre-summary__screen-body${t ? "" : " collapsed"}`,
|
|
1153
|
-
children:
|
|
1176
|
+
children: n.components.map((s) => /* @__PURE__ */ m(on, { component: s }, s.uuid))
|
|
1154
1177
|
}
|
|
1155
1178
|
)
|
|
1156
1179
|
] });
|
|
1157
|
-
},
|
|
1158
|
-
const
|
|
1159
|
-
() =>
|
|
1160
|
-
[
|
|
1180
|
+
}, qe = () => {
|
|
1181
|
+
const n = Ce(), r = P((e) => e.components), o = ke(
|
|
1182
|
+
() => n.getState().getFlowData(),
|
|
1183
|
+
[n, r]
|
|
1161
1184
|
), t = o.screens.length;
|
|
1162
|
-
return /* @__PURE__ */
|
|
1185
|
+
return /* @__PURE__ */ B("div", { className: "fbre-summary", children: [
|
|
1163
1186
|
/* @__PURE__ */ m("h2", { className: "fbre-summary__title", children: "Review" }),
|
|
1164
|
-
/* @__PURE__ */ m("div", { className: "fbre-summary__body", children: o.screens.map((
|
|
1165
|
-
|
|
1187
|
+
/* @__PURE__ */ m("div", { className: "fbre-summary__body", children: o.screens.map((e) => /* @__PURE__ */ m(
|
|
1188
|
+
Gn,
|
|
1166
1189
|
{
|
|
1167
|
-
screen:
|
|
1190
|
+
screen: e,
|
|
1168
1191
|
showToggle: t > 1
|
|
1169
1192
|
},
|
|
1170
|
-
|
|
1193
|
+
e.uuid
|
|
1171
1194
|
)) })
|
|
1172
1195
|
] });
|
|
1173
|
-
},
|
|
1174
|
-
const o =
|
|
1196
|
+
}, rn = (n, r, o) => r ? !te(r, o[n]) : !0, ye = (n, r) => {
|
|
1197
|
+
const o = n.screenOrder.length - 1;
|
|
1175
1198
|
let t = r + 1;
|
|
1176
1199
|
for (; t <= o; ) {
|
|
1177
|
-
const
|
|
1178
|
-
if (
|
|
1200
|
+
const e = n.screenOrder[t], s = n.screens[e], c = s != null && s.conditions && "when" in s.conditions ? s.conditions : void 0;
|
|
1201
|
+
if (rn(e, c, n.conditionResults)) return t;
|
|
1179
1202
|
t++;
|
|
1180
1203
|
}
|
|
1181
1204
|
return null;
|
|
1182
|
-
},
|
|
1205
|
+
}, Jn = (n, r) => {
|
|
1183
1206
|
let o = r - 1;
|
|
1184
1207
|
for (; o >= 0; ) {
|
|
1185
|
-
const t =
|
|
1186
|
-
if (
|
|
1208
|
+
const t = n.screenOrder[o], e = n.screens[t], s = e != null && e.conditions && "when" in e.conditions ? e.conditions : void 0;
|
|
1209
|
+
if (rn(t, s, n.conditionResults)) return o;
|
|
1187
1210
|
o--;
|
|
1188
1211
|
}
|
|
1189
1212
|
return 0;
|
|
1190
|
-
},
|
|
1191
|
-
|
|
1192
|
-
|
|
1213
|
+
}, Oe = /* @__PURE__ */ new Set([
|
|
1214
|
+
"radio",
|
|
1215
|
+
"yesNo",
|
|
1216
|
+
"cardSelect",
|
|
1217
|
+
"dropDown"
|
|
1218
|
+
]), zn = 500;
|
|
1219
|
+
function sn(n, r, o) {
|
|
1220
|
+
const t = Ce(), e = Z(null), s = Z(""), c = Z(0);
|
|
1221
|
+
H(() => {
|
|
1222
|
+
if (!n) return;
|
|
1223
|
+
const i = t.getState(), l = He(i, r);
|
|
1224
|
+
l && (s.current = We(i.components, l)), c.current = i.selectionTick;
|
|
1225
|
+
}, [n, r, t]), H(() => {
|
|
1226
|
+
if (!n) return;
|
|
1227
|
+
const i = t.subscribe((l) => {
|
|
1228
|
+
const a = He(l, r);
|
|
1229
|
+
if (!a) return;
|
|
1230
|
+
const u = l.selectionTick, d = u !== c.current;
|
|
1231
|
+
d && (c.current = u);
|
|
1232
|
+
const f = We(l.components, a);
|
|
1233
|
+
if (f === s.current && !d) return;
|
|
1234
|
+
const p = s.current;
|
|
1235
|
+
if (s.current = f, !(f !== p ? qn(l.components, a, p) : d && Hn(l.components, a)) || ye(l, r) === null) return;
|
|
1236
|
+
const v = l.screenOrder[r];
|
|
1237
|
+
v && l.screenValidity[v] === !1 || (e.current && clearTimeout(e.current), e.current = setTimeout(() => {
|
|
1238
|
+
e.current = null, o();
|
|
1239
|
+
}, zn));
|
|
1240
|
+
});
|
|
1241
|
+
return () => {
|
|
1242
|
+
i(), e.current && (clearTimeout(e.current), e.current = null);
|
|
1243
|
+
};
|
|
1244
|
+
}, [n, r, t, o]), H(() => () => {
|
|
1245
|
+
e.current && (clearTimeout(e.current), e.current = null);
|
|
1246
|
+
}, [r]);
|
|
1247
|
+
}
|
|
1248
|
+
function He(n, r) {
|
|
1249
|
+
const o = n.screenOrder[r];
|
|
1250
|
+
if (!o) return null;
|
|
1251
|
+
const t = n.screens[o];
|
|
1252
|
+
return t ? t.components.map((e) => e.uuid) : null;
|
|
1253
|
+
}
|
|
1254
|
+
function We(n, r) {
|
|
1255
|
+
const o = [];
|
|
1256
|
+
for (const t of r) {
|
|
1257
|
+
const e = n[t];
|
|
1258
|
+
!e || !Oe.has(e.type) || o.push(`${t}=${JSON.stringify(e.value ?? null)}`);
|
|
1259
|
+
}
|
|
1260
|
+
return o.join("|");
|
|
1261
|
+
}
|
|
1262
|
+
function qn(n, r, o) {
|
|
1263
|
+
const t = /* @__PURE__ */ new Map();
|
|
1264
|
+
for (const e of o.split("|")) {
|
|
1265
|
+
const s = e.indexOf("=");
|
|
1266
|
+
s > 0 && t.set(e.slice(0, s), e.slice(s + 1));
|
|
1267
|
+
}
|
|
1268
|
+
for (const e of r) {
|
|
1269
|
+
const s = n[e];
|
|
1270
|
+
if (!s || !Oe.has(s.type)) continue;
|
|
1271
|
+
const c = JSON.stringify(s.value ?? null), i = t.get(e) ?? "null";
|
|
1272
|
+
if (c !== i && c !== "null") return !0;
|
|
1273
|
+
}
|
|
1274
|
+
return !1;
|
|
1275
|
+
}
|
|
1276
|
+
function Hn(n, r) {
|
|
1277
|
+
for (const o of r) {
|
|
1278
|
+
const t = n[o];
|
|
1279
|
+
if (!(!t || !Oe.has(t.type)) && t.value !== null && t.value !== void 0)
|
|
1280
|
+
return !0;
|
|
1281
|
+
}
|
|
1282
|
+
return !1;
|
|
1283
|
+
}
|
|
1284
|
+
function cn(n, r, o) {
|
|
1285
|
+
const t = Ce();
|
|
1286
|
+
H(() => {
|
|
1287
|
+
if (!n) return;
|
|
1288
|
+
const e = (s) => {
|
|
1289
|
+
if (s.key !== "Enter") return;
|
|
1290
|
+
const c = s.target;
|
|
1291
|
+
if (c.tagName !== "INPUT" || !c.closest(".fbre-container")) return;
|
|
1292
|
+
const i = t.getState();
|
|
1293
|
+
if (ye(i, r) === null) return;
|
|
1294
|
+
const a = i.screenOrder[r];
|
|
1295
|
+
a && i.screenValidity[a] === !1 || (s.preventDefault(), o());
|
|
1296
|
+
};
|
|
1297
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
1298
|
+
}, [n, r, o, t]);
|
|
1299
|
+
}
|
|
1300
|
+
const me = /* @__PURE__ */ new Map(), bt = (n, r) => {
|
|
1301
|
+
me.has(n) || me.set(n, /* @__PURE__ */ new Set()), me.get(n).add(r);
|
|
1302
|
+
}, Ct = (n, r) => {
|
|
1193
1303
|
var o;
|
|
1194
|
-
(o =
|
|
1195
|
-
},
|
|
1196
|
-
function
|
|
1197
|
-
return
|
|
1304
|
+
(o = me.get(n)) == null || o.delete(r);
|
|
1305
|
+
}, an = Ke(null);
|
|
1306
|
+
function St() {
|
|
1307
|
+
return Ie(an);
|
|
1198
1308
|
}
|
|
1199
|
-
class
|
|
1200
|
-
constructor(r, o, t,
|
|
1201
|
-
super(r), this.name = "ApiError", this.status = o, this.code = t, this.validationErrors =
|
|
1309
|
+
class ge extends Error {
|
|
1310
|
+
constructor(r, o, t, e) {
|
|
1311
|
+
super(r), this.name = "ApiError", this.status = o, this.code = t, this.validationErrors = e;
|
|
1202
1312
|
}
|
|
1203
1313
|
}
|
|
1204
|
-
class
|
|
1314
|
+
class Wn extends ge {
|
|
1205
1315
|
constructor(r, o) {
|
|
1206
1316
|
super(`Request timed out after ${o}ms: ${r}`, 0, "TIMEOUT"), this.name = "TimeoutError";
|
|
1207
1317
|
}
|
|
1208
1318
|
}
|
|
1209
|
-
const
|
|
1210
|
-
function
|
|
1211
|
-
return new Promise((r) => setTimeout(r,
|
|
1319
|
+
const Xn = /* @__PURE__ */ new Set([502, 503, 504]), de = 2, Kn = [500, 1500];
|
|
1320
|
+
function Qn(n) {
|
|
1321
|
+
return new Promise((r) => setTimeout(r, n));
|
|
1212
1322
|
}
|
|
1213
|
-
async function
|
|
1214
|
-
const
|
|
1323
|
+
async function ae(n, r, o = {}) {
|
|
1324
|
+
const e = `${n.apiEndpoint || ""}${r}`, s = n.timeout ?? 3e4, c = {
|
|
1215
1325
|
...o.body ? { "Content-Type": "application/json" } : {},
|
|
1216
1326
|
...o.headers
|
|
1217
1327
|
};
|
|
1218
|
-
|
|
1219
|
-
let
|
|
1220
|
-
for (let
|
|
1221
|
-
|
|
1328
|
+
n.apiKey && (c.Authorization = `Bearer ${n.apiKey}`);
|
|
1329
|
+
let i;
|
|
1330
|
+
for (let l = 0; l <= de; l++) {
|
|
1331
|
+
l > 0 && await Qn(Kn[l - 1]);
|
|
1222
1332
|
try {
|
|
1223
|
-
const
|
|
1224
|
-
let
|
|
1333
|
+
const a = new AbortController(), u = setTimeout(() => a.abort(), s);
|
|
1334
|
+
let d;
|
|
1225
1335
|
try {
|
|
1226
|
-
|
|
1336
|
+
d = await fetch(e, {
|
|
1227
1337
|
...o,
|
|
1228
|
-
headers:
|
|
1229
|
-
signal:
|
|
1338
|
+
headers: c,
|
|
1339
|
+
signal: a.signal
|
|
1230
1340
|
});
|
|
1231
1341
|
} finally {
|
|
1232
|
-
clearTimeout(
|
|
1342
|
+
clearTimeout(u);
|
|
1233
1343
|
}
|
|
1234
|
-
if (!
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1344
|
+
if (!d.ok) {
|
|
1345
|
+
const f = await d.json().catch(() => ({})), p = new ge(
|
|
1346
|
+
f.error || `HTTP ${d.status}`,
|
|
1347
|
+
d.status,
|
|
1348
|
+
f.code,
|
|
1349
|
+
f.validationErrors
|
|
1240
1350
|
);
|
|
1241
|
-
if (
|
|
1242
|
-
|
|
1351
|
+
if (l < de && Xn.has(d.status)) {
|
|
1352
|
+
i = p;
|
|
1243
1353
|
continue;
|
|
1244
1354
|
}
|
|
1245
|
-
throw
|
|
1355
|
+
throw p;
|
|
1246
1356
|
}
|
|
1247
|
-
return
|
|
1248
|
-
} catch (
|
|
1249
|
-
if (
|
|
1250
|
-
throw
|
|
1251
|
-
if (
|
|
1252
|
-
const
|
|
1253
|
-
if (
|
|
1254
|
-
|
|
1357
|
+
return d.json();
|
|
1358
|
+
} catch (a) {
|
|
1359
|
+
if (a instanceof ge)
|
|
1360
|
+
throw a;
|
|
1361
|
+
if (a instanceof DOMException && a.name === "AbortError") {
|
|
1362
|
+
const u = new Wn(e, s);
|
|
1363
|
+
if (l < de) {
|
|
1364
|
+
i = u;
|
|
1255
1365
|
continue;
|
|
1256
1366
|
}
|
|
1257
|
-
throw
|
|
1367
|
+
throw u;
|
|
1258
1368
|
}
|
|
1259
|
-
if (
|
|
1260
|
-
|
|
1369
|
+
if (a instanceof TypeError && l < de) {
|
|
1370
|
+
i = a;
|
|
1261
1371
|
continue;
|
|
1262
1372
|
}
|
|
1263
|
-
throw
|
|
1373
|
+
throw a;
|
|
1264
1374
|
}
|
|
1265
1375
|
}
|
|
1266
|
-
throw
|
|
1376
|
+
throw i;
|
|
1267
1377
|
}
|
|
1268
|
-
async function
|
|
1269
|
-
return
|
|
1378
|
+
async function Zn(n, r) {
|
|
1379
|
+
return ae(n, `/api/v1/public/flows/${r}`);
|
|
1270
1380
|
}
|
|
1271
|
-
async function
|
|
1381
|
+
async function et(n, r, o) {
|
|
1272
1382
|
const t = { flowId: r };
|
|
1273
|
-
return o && Object.keys(o).length > 0 && (t.context = o),
|
|
1383
|
+
return o && Object.keys(o).length > 0 && (t.context = o), ae(n, "/api/v1/public/sessions", {
|
|
1274
1384
|
method: "POST",
|
|
1275
1385
|
body: JSON.stringify(t)
|
|
1276
1386
|
});
|
|
1277
1387
|
}
|
|
1278
|
-
async function
|
|
1279
|
-
return
|
|
1280
|
-
|
|
1388
|
+
async function nt(n, r, o) {
|
|
1389
|
+
return ae(
|
|
1390
|
+
n,
|
|
1281
1391
|
`/api/v1/public/sessions/${r}/next`,
|
|
1282
1392
|
{
|
|
1283
1393
|
method: "POST",
|
|
@@ -1285,9 +1395,9 @@ async function $n(e, r, o) {
|
|
|
1285
1395
|
}
|
|
1286
1396
|
);
|
|
1287
1397
|
}
|
|
1288
|
-
async function
|
|
1289
|
-
return
|
|
1290
|
-
|
|
1398
|
+
async function tt(n, r, o) {
|
|
1399
|
+
return ae(
|
|
1400
|
+
n,
|
|
1291
1401
|
`/api/v1/public/sessions/${r}/prev`,
|
|
1292
1402
|
{
|
|
1293
1403
|
method: "POST",
|
|
@@ -1295,9 +1405,9 @@ async function Pn(e, r, o) {
|
|
|
1295
1405
|
}
|
|
1296
1406
|
);
|
|
1297
1407
|
}
|
|
1298
|
-
async function
|
|
1299
|
-
return
|
|
1300
|
-
|
|
1408
|
+
async function ot(n, r, o) {
|
|
1409
|
+
return ae(
|
|
1410
|
+
n,
|
|
1301
1411
|
`/api/v1/public/sessions/${r}/complete`,
|
|
1302
1412
|
{
|
|
1303
1413
|
method: "POST",
|
|
@@ -1305,149 +1415,172 @@ async function Gn(e, r, o) {
|
|
|
1305
1415
|
}
|
|
1306
1416
|
);
|
|
1307
1417
|
}
|
|
1308
|
-
async function
|
|
1309
|
-
return
|
|
1310
|
-
|
|
1418
|
+
async function rt(n, r) {
|
|
1419
|
+
return ae(
|
|
1420
|
+
n,
|
|
1311
1421
|
`/api/v1/public/sessions/${r}`
|
|
1312
1422
|
);
|
|
1313
1423
|
}
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1424
|
+
const st = {
|
|
1425
|
+
clean: "dots",
|
|
1426
|
+
outlined: "dots",
|
|
1427
|
+
"refined-clean": "pill",
|
|
1428
|
+
"airy-clean": "glow",
|
|
1429
|
+
"soft-outlined": "glow",
|
|
1430
|
+
"defined-outlined": "bar",
|
|
1431
|
+
"centered-minimal": "dots",
|
|
1432
|
+
"stacked-cards": "dots",
|
|
1433
|
+
"soft-float": "glow",
|
|
1434
|
+
"bold-statement": "bar"
|
|
1435
|
+
}, it = ({
|
|
1436
|
+
screenIndex: n,
|
|
1316
1437
|
onFlowComplete: r,
|
|
1317
1438
|
onScreenChange: o
|
|
1318
1439
|
}) => {
|
|
1319
|
-
var
|
|
1320
|
-
const t =
|
|
1440
|
+
var Ve, Te, _e, Me, Ue, Ae, Fe, je, Le, Pe, $e;
|
|
1441
|
+
const t = P((D) => D.config), e = P((D) => D.screenOrder.length), s = P((D) => Object.keys(D.components).length > 0), c = Ce(), i = Math.max(
|
|
1321
1442
|
0,
|
|
1322
|
-
Math.min(
|
|
1323
|
-
), [
|
|
1324
|
-
!!(t != null && t.summary &&
|
|
1325
|
-
),
|
|
1326
|
-
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1329
|
-
}, [
|
|
1330
|
-
const
|
|
1331
|
-
(
|
|
1332
|
-
),
|
|
1333
|
-
(
|
|
1334
|
-
var
|
|
1335
|
-
return
|
|
1443
|
+
Math.min(n, e - 1)
|
|
1444
|
+
), [l, a] = J(i), [u, d] = J(
|
|
1445
|
+
!!(t != null && t.summary && n >= e)
|
|
1446
|
+
), f = ((Ve = t == null ? void 0 : t.navigation) == null ? void 0 : Ve.transition) ?? "none", p = f !== "none", [y, g] = J(null), [v, h] = J(!1), [b, C] = J("forward"), [S, w] = J(!1), V = Z(null);
|
|
1447
|
+
H(() => {
|
|
1448
|
+
const D = Math.max(0, Math.min(n, e - 1));
|
|
1449
|
+
a(D);
|
|
1450
|
+
}, [n]);
|
|
1451
|
+
const E = P((D) => D.screenOrder[l]), T = P(
|
|
1452
|
+
(D) => E ? D.screenValidity[E] ?? !0 : !0
|
|
1453
|
+
), _ = P(
|
|
1454
|
+
(D) => {
|
|
1455
|
+
var F;
|
|
1456
|
+
return E ? (F = D.screens[E]) == null ? void 0 : F.nextButtonLabel : void 0;
|
|
1336
1457
|
}
|
|
1337
|
-
),
|
|
1338
|
-
(
|
|
1339
|
-
var
|
|
1340
|
-
return
|
|
1458
|
+
), N = P(
|
|
1459
|
+
(D) => {
|
|
1460
|
+
var F;
|
|
1461
|
+
return E ? (F = D.screens[E]) == null ? void 0 : F.backButtonLabel : void 0;
|
|
1341
1462
|
}
|
|
1342
|
-
),
|
|
1343
|
-
(
|
|
1344
|
-
o && o(
|
|
1463
|
+
), I = z(
|
|
1464
|
+
(D) => {
|
|
1465
|
+
o && o(D, c.getState().getFlowData());
|
|
1345
1466
|
},
|
|
1346
|
-
[o,
|
|
1347
|
-
),
|
|
1348
|
-
(
|
|
1349
|
-
g(
|
|
1467
|
+
[o, c]
|
|
1468
|
+
), k = z(
|
|
1469
|
+
(D) => {
|
|
1470
|
+
g(l), h(u), C(D), w(!0), V.current && (V.current.scrollTop = 0);
|
|
1350
1471
|
},
|
|
1351
|
-
[
|
|
1352
|
-
),
|
|
1353
|
-
|
|
1354
|
-
}, []),
|
|
1355
|
-
if (!
|
|
1356
|
-
if (
|
|
1357
|
-
|
|
1472
|
+
[l, u]
|
|
1473
|
+
), W = z(() => {
|
|
1474
|
+
w(!1), g(null);
|
|
1475
|
+
}, []), U = z(() => {
|
|
1476
|
+
if (!S)
|
|
1477
|
+
if (u)
|
|
1478
|
+
p && k("back"), d(!1), I(l);
|
|
1358
1479
|
else {
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1480
|
+
const D = c.getState(), F = Jn(D, l);
|
|
1481
|
+
F !== l && (p && k("back"), a(F), I(F));
|
|
1361
1482
|
}
|
|
1362
1483
|
}, [
|
|
1363
|
-
|
|
1484
|
+
S,
|
|
1485
|
+
u,
|
|
1364
1486
|
l,
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
j !== null ? (f && B("forward"), d(j), D(j)) : t != null && t.summary && (f && B("forward"), u(!0), D(c + 1));
|
|
1487
|
+
p,
|
|
1488
|
+
k,
|
|
1489
|
+
I,
|
|
1490
|
+
c
|
|
1491
|
+
]), A = z(() => {
|
|
1492
|
+
if (S) return;
|
|
1493
|
+
const D = c.getState(), F = ye(D, l);
|
|
1494
|
+
F !== null ? (p && k("forward"), a(F), I(F)) : t != null && t.summary && (p && k("forward"), d(!0), I(l + 1));
|
|
1374
1495
|
}, [
|
|
1375
|
-
|
|
1376
|
-
|
|
1496
|
+
S,
|
|
1497
|
+
l,
|
|
1377
1498
|
t,
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
]), [
|
|
1383
|
-
|
|
1384
|
-
const
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
}).catch((
|
|
1388
|
-
|
|
1499
|
+
p,
|
|
1500
|
+
k,
|
|
1501
|
+
I,
|
|
1502
|
+
c
|
|
1503
|
+
]), [q, j] = J(!1), [O, $] = J(null), Y = z(() => {
|
|
1504
|
+
$(null);
|
|
1505
|
+
const D = r(c.getState().getFlowData());
|
|
1506
|
+
D && typeof D.then == "function" && (j(!0), D.then(() => {
|
|
1507
|
+
j(!1);
|
|
1508
|
+
}).catch((F) => {
|
|
1509
|
+
j(!1), $(F instanceof Error ? F.message : String(F));
|
|
1389
1510
|
}));
|
|
1390
|
-
}, [r,
|
|
1391
|
-
(
|
|
1392
|
-
|
|
1393
|
-
|
|
1511
|
+
}, [r, c]), K = P((D) => ye(D, l) === null), R = ((Te = t == null ? void 0 : t.theme) == null ? void 0 : Te.darkMode) ?? !1, x = ((t == null ? void 0 : t.mode) ?? "standard") === "conversational";
|
|
1512
|
+
sn(
|
|
1513
|
+
x && !u,
|
|
1514
|
+
l,
|
|
1515
|
+
A
|
|
1516
|
+
), cn(
|
|
1517
|
+
x && !u,
|
|
1518
|
+
l,
|
|
1519
|
+
A
|
|
1520
|
+
);
|
|
1521
|
+
const L = ((_e = t == null ? void 0 : t.theme) == null ? void 0 : _e.style) ?? "clean", re = ((Me = t == null ? void 0 : t.controls) == null ? void 0 : Me.stepperStyle) ?? "default", se = re === "default" ? st[L] ?? "dots" : re, un = ((Ue = t == null ? void 0 : t.controls) == null ? void 0 : Ue.showStepper) !== !1 && se === "text", Se = {};
|
|
1522
|
+
(Ae = t == null ? void 0 : t.theme) != null && Ae.color && (Se["--fbre-theme-color"] = t.theme.color);
|
|
1523
|
+
const dn = () => v ? /* @__PURE__ */ m(qe, {}) : y !== null ? /* @__PURE__ */ m(De, { screenIndex: y }) : null, pn = S ? "fbre-screen-wrapper fbre-screen-wrapper--transitioning" : "fbre-screen-wrapper";
|
|
1524
|
+
return /* @__PURE__ */ B(
|
|
1394
1525
|
"div",
|
|
1395
1526
|
{
|
|
1396
1527
|
className: "fbre-container",
|
|
1397
|
-
"data-style":
|
|
1398
|
-
"data-mode":
|
|
1399
|
-
"data-
|
|
1400
|
-
|
|
1528
|
+
"data-style": L,
|
|
1529
|
+
"data-mode": R ? "dark" : "light",
|
|
1530
|
+
"data-form-mode": x ? "conversational" : void 0,
|
|
1531
|
+
"data-stepper": se !== "text" ? se : void 0,
|
|
1532
|
+
"data-transition": p ? f : void 0,
|
|
1533
|
+
style: Object.keys(Se).length > 0 ? Se : void 0,
|
|
1401
1534
|
children: [
|
|
1402
|
-
|
|
1403
|
-
/* @__PURE__ */
|
|
1404
|
-
|
|
1535
|
+
un && /* @__PURE__ */ m(jn, { current: l, total: e }),
|
|
1536
|
+
/* @__PURE__ */ B("div", { className: pn, ref: V, children: [
|
|
1537
|
+
S && /* @__PURE__ */ m(
|
|
1405
1538
|
"div",
|
|
1406
1539
|
{
|
|
1407
1540
|
className: "fbre-screen--exiting",
|
|
1408
1541
|
"data-direction": b,
|
|
1409
|
-
onAnimationEnd:
|
|
1410
|
-
children:
|
|
1542
|
+
onAnimationEnd: W,
|
|
1543
|
+
children: dn()
|
|
1411
1544
|
}
|
|
1412
1545
|
),
|
|
1413
|
-
/* @__PURE__ */
|
|
1546
|
+
/* @__PURE__ */ B(
|
|
1414
1547
|
"div",
|
|
1415
1548
|
{
|
|
1416
|
-
className:
|
|
1417
|
-
"data-direction":
|
|
1549
|
+
className: S ? "fbre-screen--entering" : void 0,
|
|
1550
|
+
"data-direction": S ? b : void 0,
|
|
1418
1551
|
children: [
|
|
1419
|
-
!
|
|
1420
|
-
|
|
1552
|
+
!u && /* @__PURE__ */ m(De, { screenIndex: l }),
|
|
1553
|
+
u && /* @__PURE__ */ m(qe, {})
|
|
1421
1554
|
]
|
|
1422
1555
|
}
|
|
1423
1556
|
)
|
|
1424
1557
|
] }),
|
|
1425
|
-
|
|
1426
|
-
((
|
|
1427
|
-
|
|
1558
|
+
O && /* @__PURE__ */ m("div", { className: "fbre-completion-error", children: O }),
|
|
1559
|
+
((Fe = t == null ? void 0 : t.controls) == null ? void 0 : Fe.show) !== !1 && s && /* @__PURE__ */ m(
|
|
1560
|
+
Ln,
|
|
1428
1561
|
{
|
|
1429
|
-
screenIndex:
|
|
1430
|
-
maxScreenIndex:
|
|
1431
|
-
allowInvalidTransition: (
|
|
1432
|
-
screenValidity:
|
|
1562
|
+
screenIndex: l,
|
|
1563
|
+
maxScreenIndex: e - 1,
|
|
1564
|
+
allowInvalidTransition: (je = t == null ? void 0 : t.navigation) == null ? void 0 : je.allowInvalidTransition,
|
|
1565
|
+
screenValidity: T,
|
|
1433
1566
|
summaryEnabled: (t == null ? void 0 : t.summary) ?? !1,
|
|
1434
|
-
summaryActive:
|
|
1435
|
-
atMaxScreen:
|
|
1436
|
-
nextButtonLabel:
|
|
1437
|
-
backButtonLabel:
|
|
1438
|
-
completionLoading:
|
|
1439
|
-
showStepper: (
|
|
1440
|
-
stepperStyle: (
|
|
1441
|
-
controlsLayout: (
|
|
1442
|
-
nextScreen:
|
|
1443
|
-
prevScreen:
|
|
1444
|
-
onFlowComplete:
|
|
1567
|
+
summaryActive: u,
|
|
1568
|
+
atMaxScreen: K,
|
|
1569
|
+
nextButtonLabel: _,
|
|
1570
|
+
backButtonLabel: N,
|
|
1571
|
+
completionLoading: q,
|
|
1572
|
+
showStepper: (Le = t == null ? void 0 : t.controls) == null ? void 0 : Le.showStepper,
|
|
1573
|
+
stepperStyle: (Pe = t == null ? void 0 : t.controls) == null ? void 0 : Pe.stepperStyle,
|
|
1574
|
+
controlsLayout: ($e = t == null ? void 0 : t.controls) == null ? void 0 : $e.layout,
|
|
1575
|
+
nextScreen: A,
|
|
1576
|
+
prevScreen: U,
|
|
1577
|
+
onFlowComplete: Y
|
|
1445
1578
|
}
|
|
1446
1579
|
)
|
|
1447
1580
|
]
|
|
1448
1581
|
}
|
|
1449
1582
|
);
|
|
1450
|
-
},
|
|
1583
|
+
}, ct = [], at = () => Qe((n, r) => ({
|
|
1451
1584
|
// Identity (minimal — server drives the flow)
|
|
1452
1585
|
flowUUID: "",
|
|
1453
1586
|
metadata: {},
|
|
@@ -1473,6 +1606,8 @@ const Jn = ({
|
|
|
1473
1606
|
calculationsByDependency: {},
|
|
1474
1607
|
// Computed components
|
|
1475
1608
|
computedByDependency: {},
|
|
1609
|
+
// Selection re-click tracking
|
|
1610
|
+
selectionTick: 0,
|
|
1476
1611
|
// Server-driven specific
|
|
1477
1612
|
sessionId: "",
|
|
1478
1613
|
navigation: {
|
|
@@ -1487,7 +1622,7 @@ const Jn = ({
|
|
|
1487
1622
|
error: "",
|
|
1488
1623
|
// Actions
|
|
1489
1624
|
clearError: () => {
|
|
1490
|
-
|
|
1625
|
+
n({ error: "" });
|
|
1491
1626
|
},
|
|
1492
1627
|
/**
|
|
1493
1628
|
* loadFlow is repurposed to load a server screen payload.
|
|
@@ -1496,288 +1631,291 @@ const Jn = ({
|
|
|
1496
1631
|
loadFlow: () => {
|
|
1497
1632
|
},
|
|
1498
1633
|
updateContext: (o) => {
|
|
1499
|
-
|
|
1634
|
+
n({ externalContext: o });
|
|
1500
1635
|
},
|
|
1501
1636
|
updateComponentValue: (o, t) => {
|
|
1502
|
-
var
|
|
1503
|
-
const
|
|
1637
|
+
var f, p;
|
|
1638
|
+
const e = r();
|
|
1504
1639
|
if (o.includes(":")) {
|
|
1505
|
-
const y = o.split(":"), g = y[0],
|
|
1506
|
-
if (!((
|
|
1507
|
-
b.addedComponents[
|
|
1508
|
-
const
|
|
1509
|
-
let
|
|
1510
|
-
if (
|
|
1511
|
-
|
|
1512
|
-
for (const
|
|
1513
|
-
N
|
|
1514
|
-
{ ...
|
|
1515
|
-
|
|
1640
|
+
const y = o.split(":"), g = y[0], v = parseInt(y[1]), h = parseInt(y[2]), b = e.components[g];
|
|
1641
|
+
if (!((p = (f = b == null ? void 0 : b.addedComponents) == null ? void 0 : f[v]) != null && p[h])) return;
|
|
1642
|
+
b.addedComponents[v][h] = { ...b.addedComponents[v][h], value: t };
|
|
1643
|
+
const C = e.groupComponentMap[o] ?? o, S = e.conditionsByDependency[C];
|
|
1644
|
+
let w = e.conditionResults;
|
|
1645
|
+
if (S && S.length > 0) {
|
|
1646
|
+
w = { ...e.conditionResults };
|
|
1647
|
+
for (const N of S)
|
|
1648
|
+
w[N.target] = ce(
|
|
1649
|
+
{ ...e },
|
|
1650
|
+
N.config
|
|
1516
1651
|
);
|
|
1517
1652
|
}
|
|
1518
|
-
const
|
|
1519
|
-
components:
|
|
1520
|
-
groupComponentMap:
|
|
1521
|
-
},
|
|
1522
|
-
b.addedComponents[
|
|
1523
|
-
|
|
1653
|
+
const V = {
|
|
1654
|
+
components: e.components,
|
|
1655
|
+
groupComponentMap: e.groupComponentMap
|
|
1656
|
+
}, E = M(
|
|
1657
|
+
b.addedComponents[v][h],
|
|
1658
|
+
V
|
|
1524
1659
|
);
|
|
1525
|
-
b.addedComponents[
|
|
1526
|
-
const
|
|
1527
|
-
...
|
|
1528
|
-
[o]:
|
|
1529
|
-
},
|
|
1530
|
-
if (
|
|
1531
|
-
for (const
|
|
1532
|
-
const
|
|
1533
|
-
if (
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1660
|
+
b.addedComponents[v][h].valid = E.length === 0;
|
|
1661
|
+
const T = {
|
|
1662
|
+
...e.validationErrors,
|
|
1663
|
+
[o]: E
|
|
1664
|
+
}, _ = e.validationsByDependency[o];
|
|
1665
|
+
if (_)
|
|
1666
|
+
for (const N of _) {
|
|
1667
|
+
const I = Xe(e, N.target);
|
|
1668
|
+
if (I) {
|
|
1669
|
+
const k = M(I, V);
|
|
1670
|
+
I.valid = k.length === 0, T[N.target] = k;
|
|
1536
1671
|
}
|
|
1537
1672
|
}
|
|
1538
|
-
|
|
1539
|
-
components: { ...
|
|
1540
|
-
conditionResults:
|
|
1541
|
-
validationErrors:
|
|
1673
|
+
n({
|
|
1674
|
+
components: { ...e.components },
|
|
1675
|
+
conditionResults: w,
|
|
1676
|
+
validationErrors: T
|
|
1542
1677
|
});
|
|
1543
1678
|
return;
|
|
1544
1679
|
}
|
|
1545
|
-
const s =
|
|
1680
|
+
const s = e.components[o];
|
|
1546
1681
|
if (!s) return;
|
|
1547
1682
|
if (s.type === "group" || s.type === "repeater") {
|
|
1548
|
-
|
|
1683
|
+
n({ components: { ...e.components } });
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
if (t === s.value) {
|
|
1687
|
+
n({ selectionTick: (r().selectionTick ?? 0) + 1 });
|
|
1549
1688
|
return;
|
|
1550
1689
|
}
|
|
1551
|
-
if (t === s.value) return;
|
|
1552
1690
|
s.value = t;
|
|
1553
|
-
const
|
|
1554
|
-
let
|
|
1555
|
-
if (
|
|
1556
|
-
|
|
1557
|
-
for (const y of
|
|
1558
|
-
|
|
1559
|
-
{ ...
|
|
1691
|
+
const c = e.conditionsByDependency[o];
|
|
1692
|
+
let i = e.conditionResults;
|
|
1693
|
+
if (c && c.length > 0) {
|
|
1694
|
+
i = { ...e.conditionResults };
|
|
1695
|
+
for (const y of c)
|
|
1696
|
+
i[y.target] = ce(
|
|
1697
|
+
{ ...e },
|
|
1560
1698
|
y.config
|
|
1561
1699
|
);
|
|
1562
1700
|
}
|
|
1563
|
-
const
|
|
1564
|
-
components:
|
|
1565
|
-
groupComponentMap:
|
|
1566
|
-
},
|
|
1567
|
-
s.valid =
|
|
1568
|
-
const
|
|
1569
|
-
if (
|
|
1570
|
-
for (const y of
|
|
1571
|
-
const g =
|
|
1701
|
+
const l = {
|
|
1702
|
+
components: e.components,
|
|
1703
|
+
groupComponentMap: e.groupComponentMap
|
|
1704
|
+
}, a = M(s, l);
|
|
1705
|
+
s.valid = a.length === 0;
|
|
1706
|
+
const u = { ...e.validationErrors, [o]: a }, d = e.validationsByDependency[o];
|
|
1707
|
+
if (d)
|
|
1708
|
+
for (const y of d) {
|
|
1709
|
+
const g = Xe(e, y.target);
|
|
1572
1710
|
if (g) {
|
|
1573
|
-
const
|
|
1574
|
-
g.valid =
|
|
1711
|
+
const v = M(g, l);
|
|
1712
|
+
g.valid = v.length === 0, u[y.target] = v;
|
|
1575
1713
|
}
|
|
1576
1714
|
}
|
|
1577
|
-
|
|
1578
|
-
components: { ...
|
|
1579
|
-
conditionResults:
|
|
1580
|
-
validationErrors:
|
|
1715
|
+
n({
|
|
1716
|
+
components: { ...e.components },
|
|
1717
|
+
conditionResults: i,
|
|
1718
|
+
validationErrors: u
|
|
1581
1719
|
});
|
|
1582
1720
|
},
|
|
1583
1721
|
addGroupIteration: (o) => {
|
|
1584
|
-
const t = r(),
|
|
1585
|
-
if (!
|
|
1722
|
+
const t = r(), e = t.components[o];
|
|
1723
|
+
if (!e || e.type !== "group" || !e.components)
|
|
1586
1724
|
return;
|
|
1587
|
-
|
|
1588
|
-
const s =
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1725
|
+
e.addedComponents || (e.addedComponents = []);
|
|
1726
|
+
const s = e.components.map((c, i) => {
|
|
1727
|
+
const l = X(c);
|
|
1728
|
+
l.uuid = [o, e.addedComponents.length, i].join(
|
|
1591
1729
|
":"
|
|
1592
|
-
), t.groupComponentMap[
|
|
1593
|
-
const
|
|
1594
|
-
return
|
|
1730
|
+
), t.groupComponentMap[l.uuid] = c.uuid;
|
|
1731
|
+
const a = M(l);
|
|
1732
|
+
return l.valid = a.length === 0, l;
|
|
1595
1733
|
});
|
|
1596
|
-
return
|
|
1734
|
+
return e.addedComponents.push(s), n({
|
|
1597
1735
|
components: { ...t.components },
|
|
1598
1736
|
groupComponentMap: { ...t.groupComponentMap }
|
|
1599
|
-
}),
|
|
1737
|
+
}), e.addedComponents;
|
|
1600
1738
|
},
|
|
1601
1739
|
addRepeaterIteration: (o) => {
|
|
1602
|
-
const t = r(),
|
|
1603
|
-
if (!
|
|
1740
|
+
const t = r(), e = t.components[o];
|
|
1741
|
+
if (!e || e.type !== "repeater" || !e.components)
|
|
1604
1742
|
return;
|
|
1605
|
-
|
|
1606
|
-
const s =
|
|
1607
|
-
const
|
|
1608
|
-
|
|
1743
|
+
e.addedComponents || (e.addedComponents = []);
|
|
1744
|
+
const s = e.components.map((c, i) => {
|
|
1745
|
+
const l = X(c);
|
|
1746
|
+
l.uuid = [
|
|
1609
1747
|
o,
|
|
1610
|
-
|
|
1611
|
-
|
|
1748
|
+
e.addedComponents.length,
|
|
1749
|
+
i
|
|
1612
1750
|
].join(":");
|
|
1613
|
-
const
|
|
1614
|
-
return
|
|
1751
|
+
const a = M(l);
|
|
1752
|
+
return l.valid = a.length === 0, l;
|
|
1615
1753
|
});
|
|
1616
|
-
return
|
|
1754
|
+
return e.addedComponents.push(s), n({ components: { ...t.components } }), e.addedComponents;
|
|
1617
1755
|
},
|
|
1618
1756
|
removeRepeaterIteration: (o, t) => {
|
|
1619
|
-
const
|
|
1757
|
+
const e = r(), s = e.components[o];
|
|
1620
1758
|
if (!(!s || s.type !== "repeater" || !s.addedComponents || s.addedComponents.length <= 1)) {
|
|
1621
1759
|
s.addedComponents.splice(t, 1);
|
|
1622
|
-
for (let
|
|
1623
|
-
s.addedComponents[
|
|
1624
|
-
|
|
1760
|
+
for (let c = t; c < s.addedComponents.length; c++)
|
|
1761
|
+
s.addedComponents[c].forEach((i, l) => {
|
|
1762
|
+
i.uuid = [o, c, l].join(":");
|
|
1625
1763
|
});
|
|
1626
|
-
|
|
1764
|
+
n({ components: { ...e.components } });
|
|
1627
1765
|
}
|
|
1628
1766
|
},
|
|
1629
1767
|
getFlowData: () => ({ uuid: "", metadata: {}, screens: [] }),
|
|
1630
1768
|
getScreenByIndex: (o) => {
|
|
1631
1769
|
const t = r();
|
|
1632
1770
|
if (o !== 0) return null;
|
|
1633
|
-
const
|
|
1634
|
-
return
|
|
1771
|
+
const e = t.screenOrder[0];
|
|
1772
|
+
return e ? t.screens[e] : null;
|
|
1635
1773
|
},
|
|
1636
1774
|
getScreenValidity: (o) => {
|
|
1637
1775
|
const t = r();
|
|
1638
1776
|
if (o !== 0) return !0;
|
|
1639
|
-
const
|
|
1640
|
-
return
|
|
1777
|
+
const e = t.screenOrder[0];
|
|
1778
|
+
return e ? t.screenValidity[e] ?? !0 : !0;
|
|
1641
1779
|
},
|
|
1642
|
-
getValidationErrors: (o) => r().validationErrors[o] ??
|
|
1780
|
+
getValidationErrors: (o) => r().validationErrors[o] ?? ct,
|
|
1643
1781
|
evaluateFlowValidation: () => {
|
|
1644
1782
|
const o = r(), t = o.screenOrder[0];
|
|
1645
1783
|
if (!t) return !0;
|
|
1646
|
-
const
|
|
1647
|
-
if (!
|
|
1784
|
+
const e = o.screens[t];
|
|
1785
|
+
if (!e) return !0;
|
|
1648
1786
|
let s = !0;
|
|
1649
|
-
const
|
|
1787
|
+
const c = {
|
|
1650
1788
|
components: o.components,
|
|
1651
1789
|
groupComponentMap: o.groupComponentMap
|
|
1652
|
-
},
|
|
1653
|
-
for (const
|
|
1654
|
-
const
|
|
1655
|
-
if (!
|
|
1656
|
-
if ((
|
|
1657
|
-
for (const
|
|
1658
|
-
for (const y of
|
|
1790
|
+
}, i = { ...o.validationErrors };
|
|
1791
|
+
for (const a of e.components) {
|
|
1792
|
+
const u = o.components[a.uuid];
|
|
1793
|
+
if (!u) continue;
|
|
1794
|
+
if ((u.type === "group" || u.type === "repeater") && u.addedComponents) {
|
|
1795
|
+
for (const p of u.addedComponents)
|
|
1796
|
+
for (const y of p) {
|
|
1659
1797
|
const g = y.conditions && "when" in y.conditions ? y.conditions : void 0;
|
|
1660
1798
|
if (g) {
|
|
1661
|
-
const
|
|
1662
|
-
if (g.action === "show" && !
|
|
1799
|
+
const h = o.conditionResults[y.uuid] ?? !1;
|
|
1800
|
+
if (g.action === "show" && !h || g.action === "hide" && h)
|
|
1663
1801
|
continue;
|
|
1664
1802
|
}
|
|
1665
|
-
const
|
|
1666
|
-
y.valid =
|
|
1803
|
+
const v = M(y, c);
|
|
1804
|
+
y.valid = v.length === 0, i[y.uuid] = v, v.length > 0 && (s = !1);
|
|
1667
1805
|
}
|
|
1668
1806
|
continue;
|
|
1669
1807
|
}
|
|
1670
|
-
const
|
|
1671
|
-
if (
|
|
1672
|
-
const
|
|
1673
|
-
if (
|
|
1808
|
+
const d = u.conditions && "when" in u.conditions ? u.conditions : void 0;
|
|
1809
|
+
if (d) {
|
|
1810
|
+
const p = o.conditionResults[u.uuid] ?? !1;
|
|
1811
|
+
if (d.action === "show" && !p || d.action === "hide" && p)
|
|
1674
1812
|
continue;
|
|
1675
1813
|
}
|
|
1676
|
-
const
|
|
1677
|
-
|
|
1814
|
+
const f = M(u, c);
|
|
1815
|
+
u.valid = f.length === 0, i[u.uuid] = f, f.length > 0 && (s = !1);
|
|
1678
1816
|
}
|
|
1679
|
-
const
|
|
1680
|
-
return
|
|
1817
|
+
const l = { ...o.screenValidity, [t]: s };
|
|
1818
|
+
return n({
|
|
1681
1819
|
components: { ...o.components },
|
|
1682
|
-
validationErrors:
|
|
1683
|
-
screenValidity:
|
|
1820
|
+
validationErrors: i,
|
|
1821
|
+
screenValidity: l
|
|
1684
1822
|
}), s;
|
|
1685
1823
|
},
|
|
1686
1824
|
getMaxScreenCount: () => 0,
|
|
1687
1825
|
getCalculationResult: (o) => r().calculationResults[o] ?? null
|
|
1688
|
-
})),
|
|
1826
|
+
})), pe = (n, r) => {
|
|
1689
1827
|
var y, g;
|
|
1690
|
-
const o = {}, t = {},
|
|
1691
|
-
for (const
|
|
1692
|
-
const
|
|
1693
|
-
if (o[
|
|
1694
|
-
|
|
1695
|
-
const b =
|
|
1696
|
-
var
|
|
1697
|
-
const
|
|
1698
|
-
if (
|
|
1699
|
-
const
|
|
1700
|
-
|
|
1828
|
+
const o = {}, t = {}, e = {}, s = {}, c = {}, i = {}, l = r.screen.uuid;
|
|
1829
|
+
for (const v of r.screen.components) {
|
|
1830
|
+
const h = X(v);
|
|
1831
|
+
if (o[h.uuid] = h, (h.type === "group" || h.type === "repeater") && v.components) {
|
|
1832
|
+
h.addedComponents || (h.addedComponents = []);
|
|
1833
|
+
const b = v.components.map((C, S) => {
|
|
1834
|
+
var V;
|
|
1835
|
+
const w = X(C);
|
|
1836
|
+
if (w.uuid = [h.uuid, 0, S].join(":"), h.type === "group" && (t[w.uuid] = C.uuid), e[C.uuid] = w.uuid, (V = w.properties) != null && V.validation) {
|
|
1837
|
+
const E = w.properties.validation;
|
|
1838
|
+
E.rules && E.rules.length > 0 && le(c, w.uuid, E);
|
|
1701
1839
|
}
|
|
1702
|
-
return
|
|
1840
|
+
return w;
|
|
1703
1841
|
});
|
|
1704
|
-
|
|
1842
|
+
h.addedComponents.push(b);
|
|
1705
1843
|
}
|
|
1706
|
-
if ((y =
|
|
1707
|
-
const b =
|
|
1708
|
-
b.rules && b.rules.length > 0 &&
|
|
1844
|
+
if ((y = h.properties) != null && y.validation) {
|
|
1845
|
+
const b = h.properties.validation;
|
|
1846
|
+
b.rules && b.rules.length > 0 && le(c, h.uuid, b);
|
|
1709
1847
|
}
|
|
1710
1848
|
}
|
|
1711
|
-
for (const { targetUUID:
|
|
1712
|
-
|
|
1849
|
+
for (const { targetUUID: v, config: h } of r.conditions)
|
|
1850
|
+
ne(s, v, h, v === l ? "screen" : "component");
|
|
1713
1851
|
if (r.previousData)
|
|
1714
|
-
for (const
|
|
1715
|
-
const
|
|
1716
|
-
|
|
1852
|
+
for (const v of r.previousData) {
|
|
1853
|
+
const h = o[v.uuid];
|
|
1854
|
+
h && (h.value = v.value);
|
|
1717
1855
|
}
|
|
1718
|
-
const
|
|
1719
|
-
for (const
|
|
1720
|
-
const
|
|
1721
|
-
if (
|
|
1722
|
-
if (
|
|
1723
|
-
for (const
|
|
1724
|
-
for (const
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1856
|
+
const a = { components: o };
|
|
1857
|
+
for (const v of Object.keys(o)) {
|
|
1858
|
+
const h = o[v];
|
|
1859
|
+
if (h.type === "group" || h.type === "repeater") {
|
|
1860
|
+
if (h.addedComponents)
|
|
1861
|
+
for (const C of h.addedComponents)
|
|
1862
|
+
for (const S of C) {
|
|
1863
|
+
const w = M(S, a);
|
|
1864
|
+
S.valid = w.length === 0, w.length > 0 && (i[S.uuid] = w);
|
|
1727
1865
|
}
|
|
1728
1866
|
continue;
|
|
1729
1867
|
}
|
|
1730
|
-
if (!((g =
|
|
1731
|
-
const b =
|
|
1732
|
-
|
|
1868
|
+
if (!((g = h.properties) != null && g.validation)) continue;
|
|
1869
|
+
const b = M(h, a);
|
|
1870
|
+
h.valid = b.length === 0, b.length > 0 && (i[v] = b);
|
|
1733
1871
|
}
|
|
1734
|
-
const
|
|
1872
|
+
const u = {}, d = {
|
|
1735
1873
|
components: o
|
|
1736
|
-
},
|
|
1737
|
-
for (const
|
|
1738
|
-
for (const
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1874
|
+
}, f = /* @__PURE__ */ new Set();
|
|
1875
|
+
for (const v of Object.values(s))
|
|
1876
|
+
for (const h of v)
|
|
1877
|
+
f.has(h.target) || (f.add(h.target), u[h.target] = ce(
|
|
1878
|
+
d,
|
|
1879
|
+
h.config
|
|
1742
1880
|
));
|
|
1743
|
-
let
|
|
1744
|
-
for (const
|
|
1745
|
-
const
|
|
1746
|
-
if (
|
|
1747
|
-
if ((
|
|
1748
|
-
for (const b of
|
|
1749
|
-
for (const
|
|
1750
|
-
if (!
|
|
1751
|
-
|
|
1881
|
+
let p = !0;
|
|
1882
|
+
for (const v of r.screen.components) {
|
|
1883
|
+
const h = o[v.uuid];
|
|
1884
|
+
if (h)
|
|
1885
|
+
if ((h.type === "group" || h.type === "repeater") && h.addedComponents)
|
|
1886
|
+
for (const b of h.addedComponents) {
|
|
1887
|
+
for (const C of b)
|
|
1888
|
+
if (!C.valid) {
|
|
1889
|
+
p = !1;
|
|
1752
1890
|
break;
|
|
1753
1891
|
}
|
|
1754
|
-
if (!
|
|
1892
|
+
if (!p) break;
|
|
1755
1893
|
}
|
|
1756
|
-
else
|
|
1894
|
+
else h.valid === !1 && (p = !1);
|
|
1757
1895
|
}
|
|
1758
|
-
|
|
1896
|
+
n.setState({
|
|
1759
1897
|
// Screen (single screen)
|
|
1760
|
-
screenOrder: [
|
|
1898
|
+
screenOrder: [l],
|
|
1761
1899
|
screens: {
|
|
1762
|
-
[
|
|
1763
|
-
uuid:
|
|
1900
|
+
[l]: {
|
|
1901
|
+
uuid: l,
|
|
1764
1902
|
label: r.screen.label,
|
|
1765
1903
|
components: r.screen.components,
|
|
1766
1904
|
nextButtonLabel: r.screen.nextButtonLabel,
|
|
1767
1905
|
backButtonLabel: r.screen.backButtonLabel
|
|
1768
1906
|
}
|
|
1769
1907
|
},
|
|
1770
|
-
screenValidity: { [
|
|
1908
|
+
screenValidity: { [l]: p },
|
|
1771
1909
|
// Components
|
|
1772
1910
|
components: o,
|
|
1773
1911
|
groupComponentMap: t,
|
|
1774
|
-
templateComponentMap:
|
|
1912
|
+
templateComponentMap: e,
|
|
1775
1913
|
// Conditions
|
|
1776
1914
|
conditionsByDependency: s,
|
|
1777
|
-
conditionResults:
|
|
1915
|
+
conditionResults: u,
|
|
1778
1916
|
// Validation
|
|
1779
|
-
validationErrors:
|
|
1780
|
-
validationsByDependency:
|
|
1917
|
+
validationErrors: i,
|
|
1918
|
+
validationsByDependency: c,
|
|
1781
1919
|
// Calculations (not used in server-driven mode yet)
|
|
1782
1920
|
calculations: [],
|
|
1783
1921
|
calculationResults: {},
|
|
@@ -1794,69 +1932,73 @@ const Jn = ({
|
|
|
1794
1932
|
// Config
|
|
1795
1933
|
config: r.config ?? {}
|
|
1796
1934
|
});
|
|
1797
|
-
},
|
|
1935
|
+
}, Re = (n) => {
|
|
1798
1936
|
var s;
|
|
1799
|
-
const r =
|
|
1937
|
+
const r = n.getState(), o = r.screenOrder[0];
|
|
1800
1938
|
if (!o) return [];
|
|
1801
1939
|
const t = r.screens[o];
|
|
1802
1940
|
if (!t) return [];
|
|
1803
|
-
const
|
|
1804
|
-
for (const
|
|
1805
|
-
const
|
|
1806
|
-
if (!
|
|
1807
|
-
const
|
|
1808
|
-
uuid:
|
|
1809
|
-
type:
|
|
1810
|
-
value:
|
|
1941
|
+
const e = [];
|
|
1942
|
+
for (const c of t.components) {
|
|
1943
|
+
const i = r.components[c.uuid];
|
|
1944
|
+
if (!i || ve(i.type)) continue;
|
|
1945
|
+
const l = {
|
|
1946
|
+
uuid: i.uuid,
|
|
1947
|
+
type: i.type,
|
|
1948
|
+
value: i.value
|
|
1811
1949
|
};
|
|
1812
|
-
(s =
|
|
1813
|
-
(
|
|
1814
|
-
uuid:
|
|
1815
|
-
type:
|
|
1816
|
-
value:
|
|
1950
|
+
(s = i.properties) != null && s.label && (l.label = i.properties.label), (i.type === "group" || i.type === "repeater") && i.addedComponents && (l.components = i.addedComponents.map(
|
|
1951
|
+
(a) => a.filter((u) => !ve(u.type)).map((u) => ({
|
|
1952
|
+
uuid: u.uuid,
|
|
1953
|
+
type: u.type,
|
|
1954
|
+
value: u.value
|
|
1817
1955
|
}))
|
|
1818
|
-
)),
|
|
1956
|
+
)), e.push(l);
|
|
1819
1957
|
}
|
|
1820
|
-
return
|
|
1821
|
-
},
|
|
1822
|
-
sessionEndpoint:
|
|
1958
|
+
return e;
|
|
1959
|
+
}, Xe = (n, r) => tn(n.components, r), lt = 6e4, ut = ({
|
|
1960
|
+
sessionEndpoint: n,
|
|
1823
1961
|
flowId: r,
|
|
1824
1962
|
apiKey: o,
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1963
|
+
mode: t,
|
|
1964
|
+
theme: e,
|
|
1965
|
+
context: s,
|
|
1966
|
+
onFlowComplete: c,
|
|
1828
1967
|
onScreenChange: i
|
|
1829
1968
|
}) => {
|
|
1830
|
-
const
|
|
1831
|
-
|
|
1832
|
-
const
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
),
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1969
|
+
const l = Z(null);
|
|
1970
|
+
l.current || (l.current = at());
|
|
1971
|
+
const a = l.current, u = Q(a, (R) => R.loading), d = Q(a, (R) => R.error), f = Q(a, (R) => R.navigation), p = Q(a, (R) => R.config), y = Q(a, (R) => {
|
|
1972
|
+
var G;
|
|
1973
|
+
return (G = R.config) == null ? void 0 : G.mode;
|
|
1974
|
+
}), g = Q(a, (R) => R.screenOrder), v = Q(a, (R) => R.screens), [h, b] = J(""), C = Z(null), S = Z(Date.now()), w = ke(
|
|
1975
|
+
() => ({ apiEndpoint: n, apiKey: o }),
|
|
1976
|
+
[n, o]
|
|
1977
|
+
), V = z((R) => {
|
|
1978
|
+
b(R), C.current && clearTimeout(C.current), C.current = setTimeout(() => b(""), 8e3);
|
|
1979
|
+
}, []), E = z(() => {
|
|
1980
|
+
b(""), C.current && (clearTimeout(C.current), C.current = null);
|
|
1839
1981
|
}, []), T = z(async () => {
|
|
1840
|
-
|
|
1982
|
+
a.setState({ loading: !0, error: "" });
|
|
1841
1983
|
try {
|
|
1842
|
-
const R = await
|
|
1843
|
-
|
|
1984
|
+
const R = await et(w, r, s);
|
|
1985
|
+
pe(a, R);
|
|
1844
1986
|
} catch (R) {
|
|
1845
|
-
|
|
1987
|
+
a.setState({ loading: !1, error: R.message });
|
|
1846
1988
|
}
|
|
1847
|
-
}, [r,
|
|
1848
|
-
|
|
1989
|
+
}, [r, n, o, s]);
|
|
1990
|
+
H(() => {
|
|
1849
1991
|
T();
|
|
1850
|
-
}, [T]),
|
|
1992
|
+
}, [T]), H(() => {
|
|
1851
1993
|
const R = async () => {
|
|
1852
1994
|
if (document.visibilityState !== "visible") return;
|
|
1853
|
-
const
|
|
1854
|
-
if (!(!
|
|
1995
|
+
const G = a.getState();
|
|
1996
|
+
if (!(!G.sessionId || Date.now() - S.current < lt))
|
|
1855
1997
|
try {
|
|
1856
|
-
const
|
|
1857
|
-
|
|
1858
|
-
} catch (
|
|
1859
|
-
|
|
1998
|
+
const L = await rt(w, G.sessionId);
|
|
1999
|
+
pe(a, L);
|
|
2000
|
+
} catch (L) {
|
|
2001
|
+
L instanceof ge && L.status === 404 && a.setState({
|
|
1860
2002
|
loading: !1,
|
|
1861
2003
|
error: "Session expired. Please start over.",
|
|
1862
2004
|
screenOrder: [],
|
|
@@ -1865,49 +2007,51 @@ const Jn = ({
|
|
|
1865
2007
|
}
|
|
1866
2008
|
};
|
|
1867
2009
|
return document.addEventListener("visibilitychange", R), () => document.removeEventListener("visibilitychange", R);
|
|
1868
|
-
}, [
|
|
1869
|
-
const
|
|
1870
|
-
const R =
|
|
2010
|
+
}, [n, o]);
|
|
2011
|
+
const _ = z(async () => {
|
|
2012
|
+
const R = a.getState();
|
|
1871
2013
|
if (!(R.loading || !R.evaluateFlowValidation())) {
|
|
1872
|
-
|
|
2014
|
+
a.setState({ loading: !0 }), a.getState().clearError(), E();
|
|
1873
2015
|
try {
|
|
1874
|
-
const
|
|
1875
|
-
|
|
1876
|
-
} catch (
|
|
1877
|
-
|
|
2016
|
+
const x = Re(a), L = await nt(w, R.sessionId, x);
|
|
2017
|
+
pe(a, L), S.current = Date.now(), i == null || i(L.navigation.screenNumber);
|
|
2018
|
+
} catch (x) {
|
|
2019
|
+
a.setState({ loading: !1 }), V(x.message);
|
|
1878
2020
|
}
|
|
1879
2021
|
}
|
|
1880
|
-
}, [w,
|
|
1881
|
-
const R =
|
|
2022
|
+
}, [w, a, i, V, E]), N = z(async () => {
|
|
2023
|
+
const R = a.getState();
|
|
1882
2024
|
if (!R.loading) {
|
|
1883
|
-
|
|
2025
|
+
a.setState({ loading: !0 }), a.getState().clearError(), E();
|
|
1884
2026
|
try {
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
} catch (
|
|
1888
|
-
|
|
2027
|
+
const G = Re(a), x = await tt(w, R.sessionId, G);
|
|
2028
|
+
pe(a, x), S.current = Date.now(), i == null || i(x.navigation.screenNumber);
|
|
2029
|
+
} catch (G) {
|
|
2030
|
+
a.setState({ loading: !1 }), V(G.message);
|
|
1889
2031
|
}
|
|
1890
2032
|
}
|
|
1891
|
-
}, [w,
|
|
1892
|
-
const R =
|
|
2033
|
+
}, [w, a, i, V, E]), I = z(async () => {
|
|
2034
|
+
const R = a.getState();
|
|
1893
2035
|
if (!(R.loading || !R.evaluateFlowValidation())) {
|
|
1894
|
-
|
|
2036
|
+
a.setState({ loading: !0 }), a.getState().clearError(), E();
|
|
1895
2037
|
try {
|
|
1896
|
-
const
|
|
1897
|
-
|
|
1898
|
-
} catch (
|
|
1899
|
-
|
|
2038
|
+
const x = Re(a), L = await ot(w, R.sessionId, x);
|
|
2039
|
+
S.current = Date.now(), c(L);
|
|
2040
|
+
} catch (x) {
|
|
2041
|
+
a.setState({ loading: !1 }), V(x.message);
|
|
1900
2042
|
}
|
|
1901
2043
|
}
|
|
1902
|
-
}, [w,
|
|
1903
|
-
|
|
1904
|
-
const
|
|
1905
|
-
|
|
2044
|
+
}, [w, a, c, V, E]), k = { ...p == null ? void 0 : p.theme, ...e }, U = (t ?? y ?? "standard") === "conversational", A = U && !f.isLastScreen;
|
|
2045
|
+
sn(A, 0, _), cn(A, 0, _);
|
|
2046
|
+
const q = k.darkMode ?? !1, j = {};
|
|
2047
|
+
k.color && (j["--fbre-theme-color"] = k.color);
|
|
2048
|
+
const O = g[0], $ = O ? v[O] : void 0, Y = $ == null ? void 0 : $.nextButtonLabel, K = $ == null ? void 0 : $.backButtonLabel;
|
|
2049
|
+
return u && g.length === 0 ? /* @__PURE__ */ m("div", { className: "fbre-container", children: /* @__PURE__ */ B("div", { className: "fbre-remote-loading", children: [
|
|
1906
2050
|
/* @__PURE__ */ m("div", { className: "fbre-spinner" }),
|
|
1907
2051
|
/* @__PURE__ */ m("p", { children: "Loading form..." })
|
|
1908
|
-
] }) }) :
|
|
2052
|
+
] }) }) : d && g.length === 0 ? /* @__PURE__ */ m("div", { className: "fbre-container", children: /* @__PURE__ */ B("div", { className: "fbre-remote-error", children: [
|
|
1909
2053
|
/* @__PURE__ */ m("p", { children: "Failed to load form" }),
|
|
1910
|
-
/* @__PURE__ */ m("p", { className: "fbre-remote-error__detail", children:
|
|
2054
|
+
/* @__PURE__ */ m("p", { className: "fbre-remote-error__detail", children: d }),
|
|
1911
2055
|
/* @__PURE__ */ m(
|
|
1912
2056
|
"button",
|
|
1913
2057
|
{
|
|
@@ -1918,39 +2062,40 @@ const Jn = ({
|
|
|
1918
2062
|
children: "Retry"
|
|
1919
2063
|
}
|
|
1920
2064
|
)
|
|
1921
|
-
] }) }) :
|
|
1922
|
-
|
|
2065
|
+
] }) }) : g.length === 0 ? null : /* @__PURE__ */ m(
|
|
2066
|
+
be.Provider,
|
|
1923
2067
|
{
|
|
1924
|
-
value:
|
|
1925
|
-
children: /* @__PURE__ */
|
|
2068
|
+
value: a,
|
|
2069
|
+
children: /* @__PURE__ */ B(
|
|
1926
2070
|
"div",
|
|
1927
2071
|
{
|
|
1928
2072
|
className: "fbre-container",
|
|
1929
|
-
"data-style":
|
|
1930
|
-
"data-mode":
|
|
1931
|
-
|
|
2073
|
+
"data-style": k.style ?? "clean",
|
|
2074
|
+
"data-mode": q ? "dark" : "light",
|
|
2075
|
+
"data-form-mode": U ? "conversational" : void 0,
|
|
2076
|
+
style: Object.keys(j).length > 0 ? j : void 0,
|
|
1932
2077
|
children: [
|
|
1933
|
-
/* @__PURE__ */ m("div", { className: "fbre-screen-wrapper", children: /* @__PURE__ */ m(
|
|
2078
|
+
/* @__PURE__ */ m("div", { className: "fbre-screen-wrapper", children: /* @__PURE__ */ m(De, { screenIndex: 0 }) }),
|
|
1934
2079
|
/* @__PURE__ */ m(
|
|
1935
|
-
|
|
2080
|
+
dt,
|
|
1936
2081
|
{
|
|
1937
|
-
navigation:
|
|
1938
|
-
loading:
|
|
1939
|
-
onPrev:
|
|
1940
|
-
onNext:
|
|
1941
|
-
onComplete:
|
|
1942
|
-
nextButtonLabel:
|
|
1943
|
-
backButtonLabel:
|
|
2082
|
+
navigation: f,
|
|
2083
|
+
loading: u,
|
|
2084
|
+
onPrev: N,
|
|
2085
|
+
onNext: _,
|
|
2086
|
+
onComplete: I,
|
|
2087
|
+
nextButtonLabel: Y,
|
|
2088
|
+
backButtonLabel: K
|
|
1944
2089
|
}
|
|
1945
2090
|
),
|
|
1946
|
-
/* @__PURE__ */
|
|
1947
|
-
/* @__PURE__ */ m("span", { children:
|
|
2091
|
+
/* @__PURE__ */ B("div", { className: `fbre-toast${h ? " visible" : ""}`, children: [
|
|
2092
|
+
/* @__PURE__ */ m("span", { children: h }),
|
|
1948
2093
|
/* @__PURE__ */ m(
|
|
1949
2094
|
"button",
|
|
1950
2095
|
{
|
|
1951
2096
|
type: "button",
|
|
1952
2097
|
className: "fbre-toast__close",
|
|
1953
|
-
onClick:
|
|
2098
|
+
onClick: E,
|
|
1954
2099
|
"aria-label": "Dismiss",
|
|
1955
2100
|
children: "×"
|
|
1956
2101
|
}
|
|
@@ -1961,36 +2106,36 @@ const Jn = ({
|
|
|
1961
2106
|
)
|
|
1962
2107
|
}
|
|
1963
2108
|
);
|
|
1964
|
-
},
|
|
1965
|
-
navigation:
|
|
2109
|
+
}, dt = ({
|
|
2110
|
+
navigation: n,
|
|
1966
2111
|
loading: r,
|
|
1967
2112
|
onPrev: o,
|
|
1968
2113
|
onNext: t,
|
|
1969
|
-
onComplete:
|
|
2114
|
+
onComplete: e,
|
|
1970
2115
|
nextButtonLabel: s,
|
|
1971
|
-
backButtonLabel:
|
|
1972
|
-
}) => /* @__PURE__ */
|
|
1973
|
-
/* @__PURE__ */ m("div", { className: "fbre-controls__left", children:
|
|
2116
|
+
backButtonLabel: c
|
|
2117
|
+
}) => /* @__PURE__ */ B("div", { className: "fbre-controls", children: [
|
|
2118
|
+
/* @__PURE__ */ m("div", { className: "fbre-controls__left", children: n.canGoBack && /* @__PURE__ */ m(
|
|
1974
2119
|
"button",
|
|
1975
2120
|
{
|
|
1976
2121
|
type: "button",
|
|
1977
2122
|
className: "fbre-btn fbre-btn--back",
|
|
1978
2123
|
onClick: o,
|
|
1979
2124
|
disabled: r,
|
|
1980
|
-
children:
|
|
2125
|
+
children: c || "Back"
|
|
1981
2126
|
}
|
|
1982
2127
|
) }),
|
|
1983
|
-
/* @__PURE__ */ m("div", { className: "fbre-controls__center", children: /* @__PURE__ */
|
|
1984
|
-
|
|
2128
|
+
/* @__PURE__ */ m("div", { className: "fbre-controls__center", children: /* @__PURE__ */ B("span", { className: "fbre-controls__progress", children: [
|
|
2129
|
+
n.screenNumber,
|
|
1985
2130
|
" / ",
|
|
1986
|
-
|
|
2131
|
+
n.totalScreens
|
|
1987
2132
|
] }) }),
|
|
1988
|
-
/* @__PURE__ */ m("div", { className: "fbre-controls__right", children:
|
|
2133
|
+
/* @__PURE__ */ m("div", { className: "fbre-controls__right", children: n.isLastScreen ? /* @__PURE__ */ m(
|
|
1989
2134
|
"button",
|
|
1990
2135
|
{
|
|
1991
2136
|
type: "button",
|
|
1992
2137
|
className: "fbre-btn fbre-btn--complete",
|
|
1993
|
-
onClick:
|
|
2138
|
+
onClick: e,
|
|
1994
2139
|
disabled: r,
|
|
1995
2140
|
children: r ? "Submitting..." : s || "Complete"
|
|
1996
2141
|
}
|
|
@@ -2005,109 +2150,113 @@ const Jn = ({
|
|
|
2005
2150
|
}
|
|
2006
2151
|
) })
|
|
2007
2152
|
] });
|
|
2008
|
-
function
|
|
2009
|
-
return !r && !o && !t
|
|
2010
|
-
...
|
|
2011
|
-
...
|
|
2012
|
-
...
|
|
2013
|
-
...
|
|
2153
|
+
function pt(n, r, o, t, e) {
|
|
2154
|
+
return !r && !o && !t && !e ? n : {
|
|
2155
|
+
...n,
|
|
2156
|
+
...e && { mode: e },
|
|
2157
|
+
...r && { theme: { ...n.theme, ...r } },
|
|
2158
|
+
...o && { navigation: { ...n.navigation, ...o } },
|
|
2159
|
+
...t && { controls: { ...n.controls, ...t } }
|
|
2014
2160
|
};
|
|
2015
2161
|
}
|
|
2016
|
-
const
|
|
2017
|
-
flow:
|
|
2162
|
+
const ln = ({
|
|
2163
|
+
flow: n,
|
|
2018
2164
|
data: r,
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2165
|
+
mode: o,
|
|
2166
|
+
theme: t,
|
|
2167
|
+
navigation: e,
|
|
2168
|
+
controls: s,
|
|
2169
|
+
screenIndex: c,
|
|
2023
2170
|
context: i,
|
|
2024
|
-
storeRef:
|
|
2025
|
-
onFlowComplete:
|
|
2026
|
-
onScreenChange:
|
|
2027
|
-
onScreenValidationChange:
|
|
2028
|
-
apiCtx:
|
|
2171
|
+
storeRef: l,
|
|
2172
|
+
onFlowComplete: a,
|
|
2173
|
+
onScreenChange: u,
|
|
2174
|
+
onScreenValidationChange: d,
|
|
2175
|
+
apiCtx: f
|
|
2029
2176
|
}) => {
|
|
2030
|
-
const p =
|
|
2031
|
-
p.current || (p.current =
|
|
2032
|
-
p.current && p.current.getState().loadFlow(
|
|
2033
|
-
}, [
|
|
2177
|
+
const p = Z(null);
|
|
2178
|
+
p.current || (p.current = Tn(), p.current.getState().loadFlow(n, r, i)), l && (l.current = p.current), H(() => {
|
|
2179
|
+
p.current && p.current.getState().loadFlow(n, r, i);
|
|
2180
|
+
}, [n.uuid]), H(() => {
|
|
2034
2181
|
if (p.current) {
|
|
2035
|
-
const
|
|
2036
|
-
h !==
|
|
2182
|
+
const v = p.current.getState(), h = pt(v.config, t, e, s, o);
|
|
2183
|
+
h !== v.config && p.current.setState({ config: h });
|
|
2037
2184
|
}
|
|
2038
|
-
}, [o, t,
|
|
2039
|
-
const
|
|
2040
|
-
|
|
2185
|
+
}, [o, t, e, s]);
|
|
2186
|
+
const y = i ? JSON.stringify(i) : "";
|
|
2187
|
+
H(() => {
|
|
2041
2188
|
p.current && i && p.current.getState().updateContext(i);
|
|
2042
|
-
}, [
|
|
2043
|
-
const
|
|
2044
|
-
|
|
2189
|
+
}, [y]);
|
|
2190
|
+
const g = /* @__PURE__ */ m(be.Provider, { value: p.current, children: /* @__PURE__ */ m(
|
|
2191
|
+
it,
|
|
2045
2192
|
{
|
|
2046
|
-
screenIndex:
|
|
2047
|
-
onFlowComplete:
|
|
2048
|
-
onScreenChange:
|
|
2049
|
-
onScreenValidationChange:
|
|
2193
|
+
screenIndex: c ?? 0,
|
|
2194
|
+
onFlowComplete: a,
|
|
2195
|
+
onScreenChange: u,
|
|
2196
|
+
onScreenValidationChange: d
|
|
2050
2197
|
}
|
|
2051
2198
|
) });
|
|
2052
|
-
return
|
|
2053
|
-
},
|
|
2054
|
-
flowId:
|
|
2199
|
+
return f ? /* @__PURE__ */ m(an.Provider, { value: f, children: g }) : g;
|
|
2200
|
+
}, ft = ({
|
|
2201
|
+
flowId: n,
|
|
2055
2202
|
apiEndpoint: r,
|
|
2056
2203
|
apiKey: o,
|
|
2057
2204
|
data: t,
|
|
2058
|
-
|
|
2059
|
-
|
|
2205
|
+
mode: e,
|
|
2206
|
+
theme: s,
|
|
2207
|
+
navigation: c,
|
|
2060
2208
|
controls: i,
|
|
2061
|
-
screenIndex:
|
|
2062
|
-
context:
|
|
2063
|
-
storeRef:
|
|
2064
|
-
onFlowComplete:
|
|
2065
|
-
onScreenChange:
|
|
2209
|
+
screenIndex: l,
|
|
2210
|
+
context: a,
|
|
2211
|
+
storeRef: u,
|
|
2212
|
+
onFlowComplete: d,
|
|
2213
|
+
onScreenChange: f,
|
|
2066
2214
|
onScreenValidationChange: p
|
|
2067
2215
|
}) => {
|
|
2068
|
-
const [
|
|
2069
|
-
return
|
|
2070
|
-
|
|
2071
|
-
const
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
config:
|
|
2075
|
-
flowId:
|
|
2076
|
-
flowVersionId:
|
|
2077
|
-
tenantId:
|
|
2216
|
+
const [y, g] = J(null), [v, h] = J(""), [b, C] = J(null);
|
|
2217
|
+
return H(() => {
|
|
2218
|
+
g(null), h("");
|
|
2219
|
+
const S = { apiEndpoint: r, apiKey: o };
|
|
2220
|
+
Zn(S, n).then((w) => {
|
|
2221
|
+
g(w.data), C({
|
|
2222
|
+
config: S,
|
|
2223
|
+
flowId: w.id,
|
|
2224
|
+
flowVersionId: w.versionId,
|
|
2225
|
+
tenantId: w.tenantId
|
|
2078
2226
|
});
|
|
2079
|
-
}).catch((
|
|
2080
|
-
}, [
|
|
2227
|
+
}).catch((w) => h(w.message));
|
|
2228
|
+
}, [n, r, o]), v ? /* @__PURE__ */ m("div", { className: "fbre-container", children: /* @__PURE__ */ B("div", { className: "fbre-remote-error", children: [
|
|
2081
2229
|
/* @__PURE__ */ m("p", { children: "Failed to load form" }),
|
|
2082
|
-
/* @__PURE__ */ m("p", { className: "fbre-remote-error__detail", children:
|
|
2083
|
-
] }) }) : !
|
|
2230
|
+
/* @__PURE__ */ m("p", { className: "fbre-remote-error__detail", children: v })
|
|
2231
|
+
] }) }) : !y || !b ? /* @__PURE__ */ m("div", { className: "fbre-container", children: /* @__PURE__ */ B("div", { className: "fbre-remote-loading", children: [
|
|
2084
2232
|
/* @__PURE__ */ m("div", { className: "fbre-spinner" }),
|
|
2085
2233
|
/* @__PURE__ */ m("p", { children: "Loading form..." })
|
|
2086
2234
|
] }) }) : /* @__PURE__ */ m(
|
|
2087
|
-
|
|
2235
|
+
ln,
|
|
2088
2236
|
{
|
|
2089
|
-
flow:
|
|
2237
|
+
flow: y,
|
|
2090
2238
|
data: t,
|
|
2091
|
-
|
|
2092
|
-
|
|
2239
|
+
mode: e,
|
|
2240
|
+
theme: s,
|
|
2241
|
+
navigation: c,
|
|
2093
2242
|
controls: i,
|
|
2094
|
-
screenIndex:
|
|
2095
|
-
context:
|
|
2096
|
-
storeRef:
|
|
2097
|
-
onFlowComplete:
|
|
2098
|
-
onScreenChange:
|
|
2243
|
+
screenIndex: l,
|
|
2244
|
+
context: a,
|
|
2245
|
+
storeRef: u,
|
|
2246
|
+
onFlowComplete: d,
|
|
2247
|
+
onScreenChange: f,
|
|
2099
2248
|
onScreenValidationChange: p,
|
|
2100
|
-
apiCtx:
|
|
2249
|
+
apiCtx: b
|
|
2101
2250
|
}
|
|
2102
2251
|
);
|
|
2103
|
-
},
|
|
2252
|
+
}, wt = (n) => "sessionEndpoint" in n ? /* @__PURE__ */ m(ut, { ...n }) : "flowId" in n && n.flowId ? /* @__PURE__ */ m(ft, { ...n }) : /* @__PURE__ */ m(ln, { ...n });
|
|
2104
2253
|
export {
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2254
|
+
ge as ApiError,
|
|
2255
|
+
wt as FBRE,
|
|
2256
|
+
Wn as TimeoutError,
|
|
2257
|
+
bt as addFBREEventListener,
|
|
2258
|
+
Ct as removeFBREEventListener,
|
|
2259
|
+
St as useFBREApi,
|
|
2260
|
+
P as useFBREStore,
|
|
2261
|
+
Ce as useFBREStoreApi
|
|
2113
2262
|
};
|