@picked/client 0.0.1-dev.1770256874555 → 0.0.1-dev.1770787109735
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/esm/index.js +420 -379
- package/dist/esm/plugins/create-experience/index.js +298 -294
- package/dist/types/entities/field/field.d.ts +41 -77
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +9 -5
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/picked.d.ts +18 -13
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +32 -14
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/dist/types/utils/get-step-fields.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { createDomain as x, createApi as j, createStore as q, createEffect as $, sample as
|
|
1
|
+
import { createDomain as x, createApi as j, createStore as q, createEffect as $, sample as I, attach as ee, combine as V, createEvent as N } from "effector";
|
|
2
2
|
import { createFactory as w, invoke as b } from "@withease/factories";
|
|
3
|
-
import { g as K, t as
|
|
3
|
+
import { g as K, t as te, c as re, i as se, e as E, a as ne, b as ie, d as oe } from "../experience-instance-D0bQ9DzM.js";
|
|
4
4
|
import { f as At } from "../experience-instance-D0bQ9DzM.js";
|
|
5
5
|
import { l as k } from "../logger-C9a75KZn.js";
|
|
6
|
-
import { c as A, l as
|
|
6
|
+
import { c as A, l as z, s as C } from "../storage-Co_LbKr_.js";
|
|
7
7
|
import { a as Rt } from "../storage-Co_LbKr_.js";
|
|
8
|
-
import { g as
|
|
9
|
-
import { i as
|
|
10
|
-
import { s as T, a as U, b as
|
|
11
|
-
import { e as
|
|
12
|
-
const W = x("experience"),
|
|
8
|
+
import { g as ae } from "../id-BW-g3y32.js";
|
|
9
|
+
import { i as ce } from "../object-JwZ58NOH.js";
|
|
10
|
+
import { s as T, a as U, b as ue, c as de, d as le } from "../supports-8YT4QKI7.js";
|
|
11
|
+
import { e as Ot, f as zt, g as Ct, h as Mt, i as Dt, j as Vt, k as Nt } from "../supports-8YT4QKI7.js";
|
|
12
|
+
const W = x("experience"), pe = w(
|
|
13
13
|
({ client: t, experience: e }) => {
|
|
14
14
|
const r = W.store(e), s = j(r, {
|
|
15
|
-
merge(p,
|
|
15
|
+
merge(p, y) {
|
|
16
16
|
return {
|
|
17
17
|
...p,
|
|
18
|
-
...
|
|
18
|
+
...y.experience
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
}), i = r.map((p) => ({
|
|
@@ -23,70 +23,70 @@ const W = x("experience"), le = w(
|
|
|
23
23
|
decisionLogic: p.condition ?? p.decide,
|
|
24
24
|
targetSelectors: p.targets,
|
|
25
25
|
initializeOpenLogic: e.initializeOpen
|
|
26
|
-
})),
|
|
27
|
-
(p) => p.find((
|
|
26
|
+
})), l = t.components.listStore.map(
|
|
27
|
+
(p) => p.find((y) => y.name === `experience:${e.id}`) || p.find((y) => y.name === "experience"),
|
|
28
28
|
{ skipVoid: !1 }
|
|
29
29
|
), o = r.map((p) => ({
|
|
30
30
|
steps: p.steps,
|
|
31
31
|
nodes: p.nodes,
|
|
32
32
|
edges: p.edges,
|
|
33
33
|
conditionals: p.conditionals
|
|
34
|
-
})),
|
|
34
|
+
})), a = r.map((p) => p.fields), g = e.actions ?? [];
|
|
35
35
|
return {
|
|
36
36
|
id: e.id,
|
|
37
37
|
configStore: i,
|
|
38
38
|
treeStore: o,
|
|
39
|
-
fieldsStore:
|
|
40
|
-
componentStore:
|
|
41
|
-
actions:
|
|
39
|
+
fieldsStore: a,
|
|
40
|
+
componentStore: l,
|
|
41
|
+
actions: g,
|
|
42
42
|
merge: s.merge
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
|
-
function
|
|
47
|
-
return b(
|
|
46
|
+
function fe(t) {
|
|
47
|
+
return b(pe, t);
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const ge = w(({ client: t }) => {
|
|
50
50
|
const e = W.store({}), r = j(e, {
|
|
51
|
-
register(o,
|
|
51
|
+
register(o, a) {
|
|
52
52
|
return {
|
|
53
53
|
...o,
|
|
54
|
-
[
|
|
54
|
+
[a.id]: a
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
function s(o) {
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
|
|
59
|
+
const a = e.getState()[o.id];
|
|
60
|
+
if (a) {
|
|
61
|
+
a.merge({ experience: o, strategy: "override" });
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
r.register(
|
|
64
|
+
const g = fe({ client: t, experience: o });
|
|
65
|
+
r.register(g);
|
|
66
66
|
}
|
|
67
67
|
const i = e.map((o) => Object.values(o));
|
|
68
|
-
function
|
|
69
|
-
return e.map((
|
|
68
|
+
function l(o) {
|
|
69
|
+
return e.map((a) => a[o], { skipVoid: !1 });
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
72
|
register: s,
|
|
73
|
-
getById:
|
|
73
|
+
getById: l,
|
|
74
74
|
listStore: i
|
|
75
75
|
};
|
|
76
76
|
});
|
|
77
|
-
function
|
|
78
|
-
return b(
|
|
77
|
+
function me(t) {
|
|
78
|
+
return b(ge, t);
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const ye = (t, e) => {
|
|
81
81
|
e.register(t);
|
|
82
82
|
}, Y = (t, e) => {
|
|
83
83
|
const { targetSelectors: r } = e.configStore.getState(), s = K(r, e.id);
|
|
84
84
|
s.forEach(
|
|
85
|
-
({ elements:
|
|
86
|
-
),
|
|
87
|
-
t.experienceInstances.spawn(e,
|
|
85
|
+
({ elements: l }) => l.forEach((o) => te(o, e.id))
|
|
86
|
+
), re(s, e.id).forEach((l) => {
|
|
87
|
+
t.experienceInstances.spawn(e, l);
|
|
88
88
|
});
|
|
89
|
-
},
|
|
89
|
+
}, L = async (t) => {
|
|
90
90
|
await Promise.all(
|
|
91
91
|
t.experiences.listStore.getState().map(async (e) => {
|
|
92
92
|
await he(t, e) && Y(t, e);
|
|
@@ -94,14 +94,14 @@ const me = (t, e) => {
|
|
|
94
94
|
);
|
|
95
95
|
}, he = async (t, e) => {
|
|
96
96
|
const { decisionLogic: r, targetSelectors: s } = e.configStore.getState();
|
|
97
|
-
return K(s, e.id).length < 1 || s.length === 0 ? !1 : r &&
|
|
98
|
-
},
|
|
97
|
+
return K(s, e.id).length < 1 || s.length === 0 ? !1 : r && se(r) ? await E(t, r) === !0 : !0;
|
|
98
|
+
}, Se = (t, e, r) => {
|
|
99
99
|
const s = e.name, i = e.setup(t);
|
|
100
100
|
if (i) {
|
|
101
|
-
const
|
|
102
|
-
r[s] = Object.freeze({ ...
|
|
101
|
+
const l = r[s] ?? {};
|
|
102
|
+
r[s] = Object.freeze({ ...l, ...i });
|
|
103
103
|
}
|
|
104
|
-
},
|
|
104
|
+
}, ve = x("component"), ke = w(
|
|
105
105
|
({ client: t, component: e, name: r }) => {
|
|
106
106
|
const s = t.frameworks.getByName(e.frameworkName);
|
|
107
107
|
return {
|
|
@@ -111,87 +111,87 @@ const me = (t, e) => {
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
);
|
|
114
|
-
function
|
|
115
|
-
return b(
|
|
114
|
+
function we(t) {
|
|
115
|
+
return b(ke, t);
|
|
116
116
|
}
|
|
117
|
-
const
|
|
118
|
-
const e =
|
|
119
|
-
register(o,
|
|
117
|
+
const be = w(({ client: t }) => {
|
|
118
|
+
const e = ve.store({}), r = j(e, {
|
|
119
|
+
register(o, a) {
|
|
120
120
|
return {
|
|
121
121
|
...o,
|
|
122
|
-
[
|
|
122
|
+
[a.name]: a
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
function s(o,
|
|
126
|
+
function s(o, a) {
|
|
127
127
|
e.getState()[o] && k(
|
|
128
128
|
"warn",
|
|
129
129
|
`Component '${o}' already registered. Registering again will override the previous registration.`
|
|
130
130
|
);
|
|
131
|
-
const p =
|
|
131
|
+
const p = we({ client: t, name: o, component: a });
|
|
132
132
|
r.register(p);
|
|
133
133
|
}
|
|
134
134
|
const i = e.map((o) => Object.values(o));
|
|
135
|
-
function
|
|
136
|
-
return e.map((
|
|
135
|
+
function l(o) {
|
|
136
|
+
return e.map((a) => a[o], { skipVoid: !1 });
|
|
137
137
|
}
|
|
138
138
|
return {
|
|
139
139
|
register: s,
|
|
140
|
-
getByName:
|
|
140
|
+
getByName: l,
|
|
141
141
|
listStore: i
|
|
142
142
|
};
|
|
143
143
|
});
|
|
144
|
-
function
|
|
145
|
-
return b(
|
|
144
|
+
function Fe(t) {
|
|
145
|
+
return b(be, t);
|
|
146
146
|
}
|
|
147
|
-
const
|
|
147
|
+
const _ = (t, e, r) => {
|
|
148
148
|
r.register(t, e);
|
|
149
|
-
}, Ie = x("framework"),
|
|
149
|
+
}, Ie = x("framework"), xe = w(({ client: t }) => {
|
|
150
150
|
const e = Ie.store({}), r = j(e, {
|
|
151
|
-
register(o,
|
|
151
|
+
register(o, a) {
|
|
152
152
|
return {
|
|
153
153
|
...o,
|
|
154
|
-
[
|
|
154
|
+
[a.name]: a.framework
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
-
function s(o,
|
|
158
|
+
function s(o, a) {
|
|
159
159
|
e.getState()[o] && k(
|
|
160
160
|
"warn",
|
|
161
161
|
`Framework '${o}' already registered. Registering again will override the previous registration.`
|
|
162
|
-
), r.register({ name: o, framework:
|
|
162
|
+
), r.register({ name: o, framework: a });
|
|
163
163
|
}
|
|
164
164
|
const i = e.map((o) => Object.values(o));
|
|
165
|
-
function
|
|
166
|
-
return e.map((
|
|
165
|
+
function l(o) {
|
|
166
|
+
return e.map((a) => a[o], { skipVoid: !1 });
|
|
167
167
|
}
|
|
168
168
|
return {
|
|
169
169
|
register: s,
|
|
170
|
-
getByName:
|
|
170
|
+
getByName: l,
|
|
171
171
|
listStore: i
|
|
172
172
|
};
|
|
173
173
|
});
|
|
174
|
-
function
|
|
175
|
-
return b(
|
|
174
|
+
function je(t) {
|
|
175
|
+
return b(xe, t);
|
|
176
176
|
}
|
|
177
|
-
const
|
|
177
|
+
const Ee = (t, e) => {
|
|
178
178
|
e.register(t.name, t);
|
|
179
|
-
},
|
|
179
|
+
}, Pe = 6e3, Ae = A("last_ping", "global"), Be = (t) => `${t}/api/v1/ping`, Re = async (t) => {
|
|
180
180
|
try {
|
|
181
|
-
const e = Date.now(), r =
|
|
181
|
+
const e = Date.now(), r = z.get(Ae);
|
|
182
182
|
let s = 0;
|
|
183
|
-
if (r.isSet() && (s = r.json() ?? 0), s && e - s <
|
|
183
|
+
if (r.isSet() && (s = r.json() ?? 0), s && e - s < Pe)
|
|
184
184
|
return !0;
|
|
185
|
-
const i =
|
|
185
|
+
const i = Be(t.apiUrl), l = {
|
|
186
186
|
projectId: t.projectId,
|
|
187
187
|
path: window.location.pathname
|
|
188
|
-
}, o = JSON.stringify(
|
|
188
|
+
}, o = JSON.stringify(l), a = {
|
|
189
189
|
"Content-Type": "application/json"
|
|
190
190
|
}, p = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
191
|
-
p && (
|
|
191
|
+
p && (a["x-vercel-protection-bypass"] = p);
|
|
192
192
|
const S = (await fetch(i, {
|
|
193
193
|
method: "POST",
|
|
194
|
-
headers:
|
|
194
|
+
headers: a,
|
|
195
195
|
body: o
|
|
196
196
|
})).ok;
|
|
197
197
|
return S && r.set(e), S;
|
|
@@ -211,147 +211,147 @@ function Q(t) {
|
|
|
211
211
|
};
|
|
212
212
|
return Object.freeze(r);
|
|
213
213
|
}
|
|
214
|
-
const
|
|
215
|
-
const e =
|
|
216
|
-
register(
|
|
214
|
+
const $e = x("predicate"), Oe = w(({ client: t }) => {
|
|
215
|
+
const e = $e.store({}), r = j(e, {
|
|
216
|
+
register(a, g) {
|
|
217
217
|
return {
|
|
218
|
-
...
|
|
219
|
-
[
|
|
220
|
-
name:
|
|
221
|
-
predicate:
|
|
218
|
+
...a,
|
|
219
|
+
[g.name]: {
|
|
220
|
+
name: g.name,
|
|
221
|
+
predicate: g.predicate
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
225
|
});
|
|
226
|
-
function s(
|
|
227
|
-
e.getState()[
|
|
226
|
+
function s(a, g) {
|
|
227
|
+
e.getState()[a] && k(
|
|
228
228
|
"warn",
|
|
229
|
-
`Predicate '${
|
|
230
|
-
), r.register(Object.freeze({ name:
|
|
229
|
+
`Predicate '${a}' already registered. Registering again will override the previous registration.`
|
|
230
|
+
), r.register(Object.freeze({ name: a, predicate: g }));
|
|
231
231
|
}
|
|
232
|
-
const i = e.map((
|
|
233
|
-
function
|
|
234
|
-
return e.map((
|
|
232
|
+
const i = e.map((a) => Object.values(a));
|
|
233
|
+
function l(a) {
|
|
234
|
+
return e.map((g) => g[a]?.predicate, { skipVoid: !1 });
|
|
235
235
|
}
|
|
236
|
-
function o(
|
|
237
|
-
const
|
|
236
|
+
function o(a) {
|
|
237
|
+
const g = q(() => {
|
|
238
238
|
}, {
|
|
239
239
|
skipVoid: !1
|
|
240
240
|
}), p = $(async () => {
|
|
241
|
-
const
|
|
242
|
-
if (!
|
|
241
|
+
const y = l(a).getState();
|
|
242
|
+
if (!y)
|
|
243
243
|
return;
|
|
244
244
|
const S = Q(t);
|
|
245
|
-
return (...
|
|
245
|
+
return (...d) => y({ ...S, args: d });
|
|
246
246
|
});
|
|
247
|
-
return
|
|
247
|
+
return I({
|
|
248
248
|
source: { responses: t.responses.listStore, fields: t.fields.listStore },
|
|
249
249
|
target: p
|
|
250
|
-
}),
|
|
250
|
+
}), I({
|
|
251
251
|
clock: p.doneData,
|
|
252
|
-
filter: (
|
|
253
|
-
target:
|
|
254
|
-
}), p(),
|
|
252
|
+
filter: (y) => y !== void 0,
|
|
253
|
+
target: g
|
|
254
|
+
}), p(), g;
|
|
255
255
|
}
|
|
256
256
|
return {
|
|
257
257
|
register: s,
|
|
258
|
-
getByName:
|
|
258
|
+
getByName: l,
|
|
259
259
|
listStore: i,
|
|
260
260
|
getEvokablePredicate: o
|
|
261
261
|
};
|
|
262
262
|
});
|
|
263
263
|
function ze(t) {
|
|
264
|
-
return b(
|
|
264
|
+
return b(Oe, t);
|
|
265
265
|
}
|
|
266
266
|
const Ce = (t, e, r) => {
|
|
267
267
|
r.register(t, e);
|
|
268
|
-
}, J = x("feature"),
|
|
268
|
+
}, J = x("feature"), Me = w(({ client: t }) => {
|
|
269
269
|
const e = J.store({}), r = J.store([]), s = j(e, {
|
|
270
|
-
register(
|
|
270
|
+
register(n, c) {
|
|
271
271
|
return {
|
|
272
|
-
...
|
|
272
|
+
...n,
|
|
273
273
|
[c.id]: c.feature
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
});
|
|
277
|
-
function i(
|
|
278
|
-
e.getState()[
|
|
277
|
+
function i(n, c) {
|
|
278
|
+
e.getState()[n] && k(
|
|
279
279
|
"warn",
|
|
280
|
-
`Feature '${
|
|
280
|
+
`Feature '${n}' already registered. Registering again will override the previous registration.`
|
|
281
281
|
);
|
|
282
282
|
const u = {
|
|
283
|
-
id:
|
|
283
|
+
id: n,
|
|
284
284
|
feature: {
|
|
285
285
|
...c,
|
|
286
|
-
id:
|
|
286
|
+
id: n
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
289
|
s.register(
|
|
290
290
|
Object.freeze({
|
|
291
|
-
id:
|
|
291
|
+
id: n,
|
|
292
292
|
feature: u
|
|
293
293
|
})
|
|
294
294
|
);
|
|
295
295
|
}
|
|
296
|
-
const
|
|
296
|
+
const l = $(
|
|
297
297
|
async ({
|
|
298
|
-
id:
|
|
298
|
+
id: n,
|
|
299
299
|
key: c,
|
|
300
300
|
storage: f = "local"
|
|
301
301
|
}) => {
|
|
302
|
-
const u = A(`feature:${
|
|
303
|
-
return
|
|
302
|
+
const u = A(`feature:${n}:${c}`, "global"), h = (f === "session" ? C : z).get(u).boolean();
|
|
303
|
+
return h === null ? null : { id: n, key: c, bucket: h, storage: f };
|
|
304
304
|
}
|
|
305
|
-
), o = $((
|
|
306
|
-
if (!
|
|
305
|
+
), o = $((n) => {
|
|
306
|
+
if (!n)
|
|
307
307
|
return null;
|
|
308
|
-
const c = A(`feature:${
|
|
309
|
-
(
|
|
310
|
-
}),
|
|
308
|
+
const c = A(`feature:${n.id}:${n.key}`, "global");
|
|
309
|
+
(n.storage === "session" ? C : z).set(c, n.bucket);
|
|
310
|
+
}), a = /* @__PURE__ */ new Map(), g = ee({
|
|
311
311
|
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
312
|
-
effect: async ({ allFeaturesStore:
|
|
313
|
-
const
|
|
314
|
-
(R) => R.id === f && R.key ===
|
|
312
|
+
effect: async ({ allFeaturesStore: n, resolvedFeaturesStore: c }, { id: f, decide: u, key: m }) => {
|
|
313
|
+
const h = c.find(
|
|
314
|
+
(R) => R.id === f && R.key === m
|
|
315
315
|
);
|
|
316
|
-
if (
|
|
317
|
-
return
|
|
318
|
-
const
|
|
319
|
-
if (!
|
|
316
|
+
if (h)
|
|
317
|
+
return h;
|
|
318
|
+
const F = n[f];
|
|
319
|
+
if (!F)
|
|
320
320
|
throw new Error(`Feature with id '${f}' not found`);
|
|
321
|
-
const B =
|
|
321
|
+
const B = a.get(`${f}:${m}`);
|
|
322
322
|
if (B !== void 0) {
|
|
323
323
|
const R = await B;
|
|
324
|
-
return { id:
|
|
324
|
+
return { id: F.id, bucket: R, key: m, storage: F.feature.storage };
|
|
325
325
|
}
|
|
326
326
|
const v = u();
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
return { id:
|
|
327
|
+
a.set(`${f}:${m}`, v);
|
|
328
|
+
const Z = await v;
|
|
329
|
+
return { id: F.id, bucket: Z, key: m, storage: F.feature.storage };
|
|
330
330
|
}
|
|
331
331
|
});
|
|
332
|
-
|
|
332
|
+
I({
|
|
333
333
|
clock: s.register,
|
|
334
|
-
fn: (
|
|
335
|
-
const { id: c, feature: f } =
|
|
334
|
+
fn: (n) => {
|
|
335
|
+
const { id: c, feature: f } = n;
|
|
336
336
|
return { id: c, key: f.feature.key, storage: f.feature.storage };
|
|
337
337
|
},
|
|
338
|
-
target:
|
|
339
|
-
}),
|
|
338
|
+
target: l
|
|
339
|
+
}), I({
|
|
340
340
|
source: e,
|
|
341
|
-
clock:
|
|
342
|
-
fn: (
|
|
343
|
-
const { id: f, bucket: u, storage:
|
|
344
|
-
return
|
|
341
|
+
clock: g.doneData,
|
|
342
|
+
fn: (n, c) => {
|
|
343
|
+
const { id: f, bucket: u, storage: m } = c, h = n[f]?.feature.key;
|
|
344
|
+
return h ? { key: h, id: f, bucket: u, storage: m } : null;
|
|
345
345
|
},
|
|
346
346
|
target: o
|
|
347
347
|
});
|
|
348
|
-
const p =
|
|
348
|
+
const p = V({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
349
349
|
({
|
|
350
|
-
allFeaturesStore:
|
|
350
|
+
allFeaturesStore: n,
|
|
351
351
|
resolvedFeaturesStore: c
|
|
352
|
-
}) => Object.values(
|
|
352
|
+
}) => Object.values(n).map((f) => {
|
|
353
353
|
const u = c.find(
|
|
354
|
-
(
|
|
354
|
+
(m) => m.id === f.id && m.key === f.feature.key
|
|
355
355
|
);
|
|
356
356
|
return u ? {
|
|
357
357
|
id: f.id,
|
|
@@ -363,51 +363,51 @@ const Ce = (t, e, r) => {
|
|
|
363
363
|
id: f.id,
|
|
364
364
|
name: f.feature.name,
|
|
365
365
|
key: f.feature.key,
|
|
366
|
-
getBucket: async () => await
|
|
366
|
+
getBucket: async () => await g(f.feature),
|
|
367
367
|
isResolved: !1
|
|
368
368
|
};
|
|
369
369
|
})
|
|
370
370
|
);
|
|
371
|
-
|
|
372
|
-
clock:
|
|
371
|
+
I({
|
|
372
|
+
clock: g.doneData,
|
|
373
373
|
source: { resolvedFeatures: r },
|
|
374
|
-
filter: ({ resolvedFeatures:
|
|
375
|
-
(
|
|
374
|
+
filter: ({ resolvedFeatures: n }, { id: c, key: f }) => !n.some(
|
|
375
|
+
(m) => m.id === c && m.key === f
|
|
376
376
|
),
|
|
377
|
-
fn: (
|
|
378
|
-
target: t.eventBus.prepend((
|
|
377
|
+
fn: (n, c) => c,
|
|
378
|
+
target: t.eventBus.prepend((n) => ({
|
|
379
379
|
type: "feature_decide",
|
|
380
|
-
feature:
|
|
380
|
+
feature: n
|
|
381
381
|
}))
|
|
382
|
-
}),
|
|
383
|
-
clock: [
|
|
382
|
+
}), I({
|
|
383
|
+
clock: [l.doneData, g.doneData],
|
|
384
384
|
source: r,
|
|
385
|
-
fn: (
|
|
385
|
+
fn: (n, c) => !c || n.some(
|
|
386
386
|
(u) => u.id === c.id && u.key === c.key
|
|
387
|
-
) ?
|
|
387
|
+
) ? n : [...n, c],
|
|
388
388
|
target: r
|
|
389
389
|
});
|
|
390
|
-
function
|
|
391
|
-
return p.map((c) => c.find((f) => f.id ===
|
|
390
|
+
function y(n) {
|
|
391
|
+
return p.map((c) => c.find((f) => f.id === n));
|
|
392
392
|
}
|
|
393
|
-
function S(
|
|
394
|
-
return e.map((c) => c[
|
|
393
|
+
function S(n) {
|
|
394
|
+
return e.map((c) => c[n], { skipVoid: !1 });
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function d(n) {
|
|
397
397
|
const c = q(
|
|
398
398
|
async () => {
|
|
399
399
|
},
|
|
400
400
|
{ skipVoid: !1 }
|
|
401
401
|
), f = $(async () => {
|
|
402
|
-
const u =
|
|
402
|
+
const u = y(n).getState();
|
|
403
403
|
if (u)
|
|
404
404
|
return async () => (await u.getBucket()).bucket;
|
|
405
405
|
});
|
|
406
|
-
return
|
|
406
|
+
return I({
|
|
407
407
|
source: r,
|
|
408
|
-
filter: (u) => u.some((
|
|
408
|
+
filter: (u) => u.some((m) => m.id === n),
|
|
409
409
|
target: f
|
|
410
|
-
}),
|
|
410
|
+
}), I({
|
|
411
411
|
clock: f.doneData,
|
|
412
412
|
filter: (u) => u !== void 0,
|
|
413
413
|
target: c
|
|
@@ -415,14 +415,14 @@ const Ce = (t, e, r) => {
|
|
|
415
415
|
}
|
|
416
416
|
return {
|
|
417
417
|
register: i,
|
|
418
|
-
getById:
|
|
418
|
+
getById: y,
|
|
419
419
|
getByName: S,
|
|
420
420
|
listStore: p,
|
|
421
|
-
getEvokableFeature:
|
|
421
|
+
getEvokableFeature: d
|
|
422
422
|
};
|
|
423
423
|
});
|
|
424
|
-
function
|
|
425
|
-
return b(
|
|
424
|
+
function De(t) {
|
|
425
|
+
return b(Me, t);
|
|
426
426
|
}
|
|
427
427
|
const Ve = (t, e, r) => {
|
|
428
428
|
r.register(t, e);
|
|
@@ -430,38 +430,38 @@ const Ve = (t, e, r) => {
|
|
|
430
430
|
function G(t, e) {
|
|
431
431
|
return {
|
|
432
432
|
// eslint-disable-next-line sonarjs/pseudo-random
|
|
433
|
-
id:
|
|
433
|
+
id: ae(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
434
434
|
node: e,
|
|
435
435
|
at: Date.now(),
|
|
436
436
|
experienceId: t
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
|
-
const
|
|
439
|
+
const Ne = w(() => {
|
|
440
440
|
const t = P.store({ entries: [] }), e = P.event(), r = P.event(), s = P.event(), i = P.event();
|
|
441
|
-
t.on(e, (o,
|
|
442
|
-
entries: [...o.entries, G(
|
|
443
|
-
})), t.on(r, (o,
|
|
441
|
+
t.on(e, (o, a) => ({
|
|
442
|
+
entries: [...o.entries, G(a.experienceId, a.node)]
|
|
443
|
+
})), t.on(r, (o, a) => ({
|
|
444
444
|
entries: [
|
|
445
445
|
...o.entries.slice(0, -1),
|
|
446
|
-
G(
|
|
446
|
+
G(a.experienceId, a.node)
|
|
447
447
|
]
|
|
448
|
-
})), t.on(i, (o,
|
|
449
|
-
function
|
|
450
|
-
const
|
|
448
|
+
})), t.on(i, (o, a) => a);
|
|
449
|
+
function l(o, a) {
|
|
450
|
+
const g = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
451
451
|
for (let p = o.length - 1; p >= 0; p--) {
|
|
452
|
-
const
|
|
453
|
-
if (!(!S || !
|
|
454
|
-
if (
|
|
455
|
-
|
|
452
|
+
const y = o[p], S = y?.node;
|
|
453
|
+
if (!(!S || !ne(S)) && !(a && y?.experienceId !== a))
|
|
454
|
+
if (g.lastStepIndex === -1)
|
|
455
|
+
g.lastStepIndex = p;
|
|
456
456
|
else {
|
|
457
|
-
|
|
457
|
+
g.secondLastStepIndex = p;
|
|
458
458
|
break;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
return
|
|
461
|
+
return g;
|
|
462
462
|
}
|
|
463
|
-
return t.on(s, (o,
|
|
464
|
-
const { secondLastStepIndex:
|
|
463
|
+
return t.on(s, (o, a) => {
|
|
464
|
+
const { secondLastStepIndex: g } = l(o.entries, a.experienceId), p = g !== -1 ? o.entries.slice(0, g + 1) : o.entries;
|
|
465
465
|
return {
|
|
466
466
|
...o,
|
|
467
467
|
entries: p
|
|
@@ -474,74 +474,109 @@ const De = w(() => {
|
|
|
474
474
|
entriesStore: t.map((o) => o.entries)
|
|
475
475
|
};
|
|
476
476
|
});
|
|
477
|
-
function
|
|
478
|
-
return b(
|
|
477
|
+
function Te() {
|
|
478
|
+
return b(Ne);
|
|
479
479
|
}
|
|
480
|
-
const
|
|
481
|
-
const
|
|
482
|
-
register(
|
|
480
|
+
const Ue = () => N(), M = x("field"), Le = w(({ client: t }) => {
|
|
481
|
+
const e = M.store({}), r = j(e, {
|
|
482
|
+
register(d, n) {
|
|
483
483
|
return {
|
|
484
|
-
...
|
|
485
|
-
[
|
|
484
|
+
...d,
|
|
485
|
+
[n.field.id]: n.field
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
488
|
});
|
|
489
|
-
function
|
|
490
|
-
|
|
489
|
+
function s(d) {
|
|
490
|
+
r.register({ field: d });
|
|
491
491
|
}
|
|
492
|
-
function
|
|
493
|
-
const
|
|
494
|
-
if (!
|
|
492
|
+
function i(d, n) {
|
|
493
|
+
const c = o(d).getState();
|
|
494
|
+
if (!c)
|
|
495
495
|
return;
|
|
496
|
-
const
|
|
497
|
-
...
|
|
496
|
+
const f = Object.assign({}, c, {
|
|
497
|
+
...n
|
|
498
498
|
});
|
|
499
|
-
|
|
499
|
+
r.register({ field: { ...f } });
|
|
500
500
|
}
|
|
501
|
-
const
|
|
502
|
-
function d
|
|
503
|
-
return
|
|
501
|
+
const l = e.map((d) => Object.values(d));
|
|
502
|
+
function o(d) {
|
|
503
|
+
return e.map((n) => n[d] || null);
|
|
504
504
|
}
|
|
505
|
-
function
|
|
506
|
-
return
|
|
505
|
+
function a(d) {
|
|
506
|
+
return e.map((n) => Object.values(n).find((c) => c.name === d) || null);
|
|
507
|
+
}
|
|
508
|
+
const g = M.store({}), p = M.effect(
|
|
509
|
+
async (d) => {
|
|
510
|
+
const n = o(d).getState();
|
|
511
|
+
if (!n || n.options == null)
|
|
512
|
+
return { fieldId: d, options: null };
|
|
513
|
+
if (typeof n.options != "function")
|
|
514
|
+
return { fieldId: d, options: n.options };
|
|
515
|
+
if (!t)
|
|
516
|
+
return { fieldId: d, options: null };
|
|
517
|
+
const c = t.responses.listStore.getState(), f = {};
|
|
518
|
+
for (const m of c)
|
|
519
|
+
m.value !== void 0 && (f[m.fieldId] = m.value);
|
|
520
|
+
const u = await Promise.resolve(n.options({ responses: f }));
|
|
521
|
+
return { fieldId: d, options: u };
|
|
522
|
+
}
|
|
523
|
+
);
|
|
524
|
+
g.on(p, (d, n) => ({
|
|
525
|
+
...d,
|
|
526
|
+
[n]: { status: "loading", options: null }
|
|
527
|
+
})), g.on(p.doneData, (d, { fieldId: n, options: c }) => ({
|
|
528
|
+
...d,
|
|
529
|
+
[n]: { status: "resolved", options: c }
|
|
530
|
+
})), g.on(p.fail, (d, { params: n }) => ({
|
|
531
|
+
...d,
|
|
532
|
+
[n]: { status: "error", options: null, error: "Failed to resolve field options" }
|
|
533
|
+
}));
|
|
534
|
+
function y(d) {
|
|
535
|
+
const n = g.getState()[d];
|
|
536
|
+
n && n.status !== "idle" || p(d);
|
|
537
|
+
}
|
|
538
|
+
function S(d) {
|
|
539
|
+
return g.map((n) => n[d] ?? { status: "idle", options: null });
|
|
507
540
|
}
|
|
508
541
|
return {
|
|
509
|
-
register:
|
|
510
|
-
update:
|
|
511
|
-
getById:
|
|
512
|
-
listStore:
|
|
513
|
-
getByName:
|
|
542
|
+
register: s,
|
|
543
|
+
update: i,
|
|
544
|
+
getById: o,
|
|
545
|
+
listStore: l,
|
|
546
|
+
getByName: a,
|
|
547
|
+
resolve: y,
|
|
548
|
+
getByFieldId: S
|
|
514
549
|
};
|
|
515
550
|
});
|
|
516
|
-
function
|
|
517
|
-
return b(
|
|
551
|
+
function _e(t) {
|
|
552
|
+
return b(Le, t);
|
|
518
553
|
}
|
|
519
554
|
const Je = (t, e) => {
|
|
520
555
|
e.register(t);
|
|
521
556
|
}, Ge = x("action"), He = w(() => {
|
|
522
557
|
const t = Ge.store({}), e = j(t, {
|
|
523
|
-
register(o,
|
|
558
|
+
register(o, a) {
|
|
524
559
|
return {
|
|
525
560
|
...o,
|
|
526
|
-
[
|
|
527
|
-
name:
|
|
528
|
-
action:
|
|
561
|
+
[a.name]: {
|
|
562
|
+
name: a.name,
|
|
563
|
+
action: a.action
|
|
529
564
|
}
|
|
530
565
|
};
|
|
531
566
|
}
|
|
532
567
|
});
|
|
533
|
-
function r(o,
|
|
534
|
-
e.register({ name: o, action:
|
|
568
|
+
function r(o, a) {
|
|
569
|
+
e.register({ name: o, action: a });
|
|
535
570
|
}
|
|
536
571
|
const s = t.map((o) => Object.values(o));
|
|
537
572
|
function i(o) {
|
|
538
|
-
return t.map((
|
|
573
|
+
return t.map((a) => a[o], { skipVoid: !1 });
|
|
539
574
|
}
|
|
540
|
-
function
|
|
575
|
+
function l(o) {
|
|
541
576
|
return t.map(
|
|
542
|
-
(
|
|
543
|
-
const
|
|
544
|
-
return
|
|
577
|
+
(a) => {
|
|
578
|
+
const g = a[o];
|
|
579
|
+
return g ? g.action : void 0;
|
|
545
580
|
},
|
|
546
581
|
{ skipVoid: !1 }
|
|
547
582
|
);
|
|
@@ -550,7 +585,7 @@ const Je = (t, e) => {
|
|
|
550
585
|
register: r,
|
|
551
586
|
getByName: i,
|
|
552
587
|
listStore: s,
|
|
553
|
-
getEvokableAction:
|
|
588
|
+
getEvokableAction: l
|
|
554
589
|
};
|
|
555
590
|
});
|
|
556
591
|
function qe() {
|
|
@@ -559,7 +594,7 @@ function qe() {
|
|
|
559
594
|
const Ke = (t, e, r) => {
|
|
560
595
|
r.register(t, e);
|
|
561
596
|
};
|
|
562
|
-
function
|
|
597
|
+
function D(t) {
|
|
563
598
|
return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
|
|
564
599
|
}
|
|
565
600
|
function We(t) {
|
|
@@ -574,42 +609,42 @@ function H(t) {
|
|
|
574
609
|
}
|
|
575
610
|
const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
576
611
|
const e = Ye.store({}), r = N(), s = N(), i = j(e, {
|
|
577
|
-
register(
|
|
612
|
+
register(d, n) {
|
|
578
613
|
return {
|
|
579
|
-
...
|
|
580
|
-
[
|
|
614
|
+
...d,
|
|
615
|
+
[n.fieldId]: n.response
|
|
581
616
|
};
|
|
582
617
|
},
|
|
583
|
-
registerBatch(
|
|
618
|
+
registerBatch(d, n) {
|
|
584
619
|
return {
|
|
585
|
-
...
|
|
586
|
-
...
|
|
620
|
+
...d,
|
|
621
|
+
...n
|
|
587
622
|
};
|
|
588
623
|
},
|
|
589
|
-
clear(
|
|
590
|
-
const { [
|
|
624
|
+
clear(d, n) {
|
|
625
|
+
const { [n]: c, ...f } = d;
|
|
591
626
|
return f;
|
|
592
627
|
},
|
|
593
628
|
clearAll() {
|
|
594
629
|
return {};
|
|
595
630
|
}
|
|
596
631
|
});
|
|
597
|
-
function d
|
|
598
|
-
if (typeof
|
|
599
|
-
if (
|
|
632
|
+
function l(d, n) {
|
|
633
|
+
if (typeof d == "string") {
|
|
634
|
+
if (n === void 0)
|
|
600
635
|
throw new Error("Response is required when registering a single field");
|
|
601
|
-
i.register({ fieldId:
|
|
636
|
+
i.register({ fieldId: d, response: n });
|
|
602
637
|
} else
|
|
603
|
-
i.registerBatch(
|
|
638
|
+
i.registerBatch(d);
|
|
604
639
|
}
|
|
605
|
-
async function o(
|
|
606
|
-
const
|
|
640
|
+
async function o(d) {
|
|
641
|
+
const n = [];
|
|
607
642
|
return await Promise.allSettled(
|
|
608
|
-
Object.entries(
|
|
643
|
+
Object.entries(d).map(async ([c, f]) => {
|
|
609
644
|
let u = f;
|
|
610
|
-
const
|
|
611
|
-
if (!
|
|
612
|
-
|
|
645
|
+
const m = t.fields.getById(c).getState();
|
|
646
|
+
if (!m) {
|
|
647
|
+
n.push({
|
|
613
648
|
fieldId: c,
|
|
614
649
|
userMessage: `Field '${c}' not found`,
|
|
615
650
|
systemMessage: `No field with ID '${c}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
@@ -617,21 +652,21 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
617
652
|
});
|
|
618
653
|
return;
|
|
619
654
|
}
|
|
620
|
-
if (
|
|
621
|
-
const
|
|
655
|
+
if (m.multiple && (typeof u == "string" || typeof u == "number" || typeof u == "boolean") && (u = [u]), m.validation && !ce(m.validation) && !D(u)) {
|
|
656
|
+
const h = await E(t, m.validation, {
|
|
622
657
|
$input: u
|
|
623
658
|
});
|
|
624
|
-
if (typeof
|
|
625
|
-
|
|
659
|
+
if (typeof h == "string") {
|
|
660
|
+
n.push({
|
|
626
661
|
fieldId: c,
|
|
627
|
-
userMessage:
|
|
628
|
-
systemMessage: `Field validation resulted in an error: ${
|
|
662
|
+
userMessage: h,
|
|
663
|
+
systemMessage: `Field validation resulted in an error: ${h}.`,
|
|
629
664
|
value: u
|
|
630
665
|
});
|
|
631
666
|
return;
|
|
632
667
|
}
|
|
633
|
-
if (
|
|
634
|
-
|
|
668
|
+
if (h === !1) {
|
|
669
|
+
n.push({
|
|
635
670
|
fieldId: c,
|
|
636
671
|
userMessage: "This field is invalid",
|
|
637
672
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
@@ -640,8 +675,8 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
640
675
|
return;
|
|
641
676
|
}
|
|
642
677
|
}
|
|
643
|
-
if (
|
|
644
|
-
|
|
678
|
+
if (m.required && D(u)) {
|
|
679
|
+
n.push({
|
|
645
680
|
fieldId: c,
|
|
646
681
|
userMessage: "This field is required",
|
|
647
682
|
systemMessage: "Field is required.",
|
|
@@ -649,8 +684,8 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
649
684
|
});
|
|
650
685
|
return;
|
|
651
686
|
}
|
|
652
|
-
if (!
|
|
653
|
-
|
|
687
|
+
if (!m.multiple && Array.isArray(u) && u.length > 1) {
|
|
688
|
+
n.push({
|
|
654
689
|
fieldId: c,
|
|
655
690
|
userMessage: "This field expects a single response",
|
|
656
691
|
systemMessage: "Field expects a single response.",
|
|
@@ -658,10 +693,10 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
658
693
|
});
|
|
659
694
|
return;
|
|
660
695
|
}
|
|
661
|
-
if (
|
|
662
|
-
if (
|
|
696
|
+
if (m.type === "object" && !D(u))
|
|
697
|
+
if (m.multiple) {
|
|
663
698
|
if (!Array.isArray(u)) {
|
|
664
|
-
|
|
699
|
+
n.push({
|
|
665
700
|
fieldId: c,
|
|
666
701
|
userMessage: "This field expects multiple values",
|
|
667
702
|
systemMessage: "Field expects an array of objects.",
|
|
@@ -669,9 +704,9 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
669
704
|
});
|
|
670
705
|
return;
|
|
671
706
|
}
|
|
672
|
-
for (const
|
|
673
|
-
if (typeof
|
|
674
|
-
|
|
707
|
+
for (const h of u) {
|
|
708
|
+
if (typeof h != "object" || h === null) {
|
|
709
|
+
n.push({
|
|
675
710
|
fieldId: c,
|
|
676
711
|
userMessage: "This field expects object values",
|
|
677
712
|
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
@@ -679,8 +714,8 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
679
714
|
});
|
|
680
715
|
return;
|
|
681
716
|
}
|
|
682
|
-
if (!H(
|
|
683
|
-
|
|
717
|
+
if (!H(h)) {
|
|
718
|
+
n.push({
|
|
684
719
|
fieldId: c,
|
|
685
720
|
userMessage: "This field contains non-serializable data",
|
|
686
721
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
@@ -691,7 +726,7 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
691
726
|
}
|
|
692
727
|
} else {
|
|
693
728
|
if (Array.isArray(u)) {
|
|
694
|
-
|
|
729
|
+
n.push({
|
|
695
730
|
fieldId: c,
|
|
696
731
|
userMessage: "This field expects a single value",
|
|
697
732
|
systemMessage: "Field expects a single object, not an array.",
|
|
@@ -700,7 +735,7 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
700
735
|
return;
|
|
701
736
|
}
|
|
702
737
|
if (typeof u != "object" || u === null) {
|
|
703
|
-
|
|
738
|
+
n.push({
|
|
704
739
|
fieldId: c,
|
|
705
740
|
userMessage: "This field expects an object value",
|
|
706
741
|
systemMessage: "Field expects an object value.",
|
|
@@ -709,7 +744,7 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
709
744
|
return;
|
|
710
745
|
}
|
|
711
746
|
if (!H(u)) {
|
|
712
|
-
|
|
747
|
+
n.push({
|
|
713
748
|
fieldId: c,
|
|
714
749
|
userMessage: "This field contains non-serializable data",
|
|
715
750
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
@@ -718,70 +753,70 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
718
753
|
return;
|
|
719
754
|
}
|
|
720
755
|
}
|
|
721
|
-
if (
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
724
|
-
const
|
|
725
|
-
|
|
756
|
+
if (m.options && typeof m.options != "function") {
|
|
757
|
+
const h = Array.isArray(u) ? u : [u];
|
|
758
|
+
if (m.type === "object") {
|
|
759
|
+
const F = m.options.map((v) => JSON.stringify(v.value));
|
|
760
|
+
h.every((v) => F.includes(JSON.stringify(v))) || n.push({
|
|
726
761
|
fieldId: c,
|
|
727
762
|
userMessage: "This field expects a valid option",
|
|
728
763
|
systemMessage: "Field expects a valid option from the defined choices.",
|
|
729
764
|
value: u
|
|
730
765
|
});
|
|
731
766
|
} else {
|
|
732
|
-
const
|
|
733
|
-
|
|
767
|
+
const F = m.options.map((v) => v.value);
|
|
768
|
+
h.every((v) => !We(v) || v === null ? !1 : F.includes(v)) || n.push({
|
|
734
769
|
fieldId: c,
|
|
735
770
|
userMessage: "This field expects a valid option",
|
|
736
|
-
systemMessage: `Field expects a valid option. Valid options are: ${
|
|
771
|
+
systemMessage: `Field expects a valid option. Valid options are: ${F.join(", ")}`,
|
|
737
772
|
value: u
|
|
738
773
|
});
|
|
739
774
|
}
|
|
740
775
|
}
|
|
741
776
|
})
|
|
742
|
-
), { responsesToCommit:
|
|
777
|
+
), { responsesToCommit: d, validationErrors: n };
|
|
743
778
|
}
|
|
744
|
-
async function
|
|
745
|
-
const { responsesToCommit:
|
|
746
|
-
return c.length ? { errors: c } : (i.registerBatch(
|
|
779
|
+
async function a(d) {
|
|
780
|
+
const { responsesToCommit: n, validationErrors: c } = await o(d);
|
|
781
|
+
return c.length ? { errors: c } : (i.registerBatch(n), { errors: [] });
|
|
747
782
|
}
|
|
748
|
-
const
|
|
783
|
+
const g = e.map((d) => d), p = e.map((d) => Object.keys(d).map((c) => ({
|
|
749
784
|
fieldId: c,
|
|
750
|
-
value:
|
|
785
|
+
value: d[c]
|
|
751
786
|
})));
|
|
752
|
-
function
|
|
753
|
-
const
|
|
754
|
-
return
|
|
787
|
+
function y(d) {
|
|
788
|
+
const n = t.fields.getById(d), c = e.map((f) => f[d] || null);
|
|
789
|
+
return V({ f: n, r: c }, ({ f, r: u }) => u || (f?.defaultValue ? f.defaultValue : null));
|
|
755
790
|
}
|
|
756
|
-
function S(
|
|
757
|
-
const
|
|
758
|
-
return
|
|
791
|
+
function S(d) {
|
|
792
|
+
const n = t.fields.getByName(d);
|
|
793
|
+
return V({ f: n, s: e }, ({ f: c, s: f }) => {
|
|
759
794
|
const u = c && f[c.id] || null;
|
|
760
795
|
return u || (c?.defaultValue ? c.defaultValue : null);
|
|
761
796
|
});
|
|
762
797
|
}
|
|
763
|
-
return
|
|
798
|
+
return I({
|
|
764
799
|
clock: r,
|
|
765
800
|
target: i.clearAll
|
|
766
|
-
}),
|
|
801
|
+
}), I({
|
|
767
802
|
clock: s,
|
|
768
803
|
target: i.clear
|
|
769
804
|
}), {
|
|
770
|
-
register:
|
|
805
|
+
register: l,
|
|
771
806
|
clearAll: r,
|
|
772
807
|
clear: s,
|
|
773
|
-
commit:
|
|
808
|
+
commit: a,
|
|
774
809
|
getResponsesToCommit: o,
|
|
775
810
|
listStore: p,
|
|
776
|
-
getAllStore:
|
|
777
|
-
getByFieldId:
|
|
811
|
+
getAllStore: g,
|
|
812
|
+
getByFieldId: y,
|
|
778
813
|
getByFieldName: S
|
|
779
814
|
};
|
|
780
815
|
});
|
|
781
816
|
function Xe(t) {
|
|
782
817
|
return b(Qe, t);
|
|
783
818
|
}
|
|
784
|
-
const Ze = () => "0.0.1-dev.
|
|
819
|
+
const Ze = () => "0.0.1-dev.1770787109735";
|
|
785
820
|
function et() {
|
|
786
821
|
if (T()) {
|
|
787
822
|
const t = [
|
|
@@ -804,27 +839,27 @@ function tt() {
|
|
|
804
839
|
for (const [i] of t.entries())
|
|
805
840
|
i.startsWith("picked-") && r.add(i);
|
|
806
841
|
for (const i of r) {
|
|
807
|
-
const
|
|
808
|
-
e[
|
|
842
|
+
const l = i.replace("picked-", "");
|
|
843
|
+
e[l] = t.getAll(i);
|
|
809
844
|
}
|
|
810
845
|
const s = A("s");
|
|
811
846
|
if (r.size > 0)
|
|
812
|
-
|
|
847
|
+
C.set(s, e);
|
|
813
848
|
else {
|
|
814
|
-
const i =
|
|
849
|
+
const i = C.get(s);
|
|
815
850
|
if (i)
|
|
816
851
|
return i.json() || {};
|
|
817
852
|
}
|
|
818
853
|
return e;
|
|
819
854
|
}
|
|
820
855
|
function rt() {
|
|
821
|
-
if (
|
|
856
|
+
if (de())
|
|
822
857
|
return crypto.randomUUID();
|
|
823
858
|
const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15);
|
|
824
859
|
return `${t}-${e}-${r}-${s}`;
|
|
825
860
|
}
|
|
826
861
|
const st = A("session", "global"), nt = () => {
|
|
827
|
-
const t =
|
|
862
|
+
const t = z.get(st);
|
|
828
863
|
let e;
|
|
829
864
|
t.isSet() && (e = t.json());
|
|
830
865
|
const r = (i) => t.set({
|
|
@@ -838,17 +873,17 @@ const st = A("session", "global"), nt = () => {
|
|
|
838
873
|
setIsUser(i) {
|
|
839
874
|
this.isUser = i, r(this);
|
|
840
875
|
},
|
|
841
|
-
setIdentifier(i,
|
|
842
|
-
this.identifiers = { ...this.identifiers, [i]:
|
|
876
|
+
setIdentifier(i, l) {
|
|
877
|
+
this.identifiers = { ...this.identifiers, [i]: l }, r(this);
|
|
843
878
|
},
|
|
844
879
|
removeIdentifier(i) {
|
|
845
880
|
this.identifiers && (this.identifiers = Object.fromEntries(
|
|
846
|
-
Object.entries(this.identifiers).filter(([
|
|
881
|
+
Object.entries(this.identifiers).filter(([l]) => l !== i)
|
|
847
882
|
), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
|
|
848
883
|
}
|
|
849
884
|
};
|
|
850
885
|
return r(s), s;
|
|
851
|
-
}, it = () =>
|
|
886
|
+
}, it = () => ue() ? nt() : null;
|
|
852
887
|
function ot() {
|
|
853
888
|
if (U())
|
|
854
889
|
return globalThis.window.pickedConfig;
|
|
@@ -886,13 +921,13 @@ function ut(t) {
|
|
|
886
921
|
(3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
|
|
887
922
|
);
|
|
888
923
|
}
|
|
889
|
-
function
|
|
924
|
+
function O(t) {
|
|
890
925
|
return t == null || t === "" || Number.isNaN(t);
|
|
891
926
|
}
|
|
892
927
|
const dt = {
|
|
893
|
-
default: (t, e) =>
|
|
894
|
-
append: (t, e) => e && !
|
|
895
|
-
prepend: (t, e) => e && !
|
|
928
|
+
default: (t, e) => O(t) ? String(e ?? "") : String(t),
|
|
929
|
+
append: (t, e) => e && !O(t) ? `${t} ${e}` : t,
|
|
930
|
+
prepend: (t, e) => e && !O(t) ? `${e} ${t}` : t,
|
|
896
931
|
upper: (t) => typeof t == "string" ? t.toUpperCase() : t,
|
|
897
932
|
lower: (t) => typeof t == "string" ? t.toLowerCase() : t,
|
|
898
933
|
capitalize: (t) => typeof t == "string" ? t.charAt(0).toUpperCase() + t.slice(1) : t,
|
|
@@ -922,13 +957,13 @@ function pt(t, e) {
|
|
|
922
957
|
return typeof r == "function" ? r() : r;
|
|
923
958
|
}
|
|
924
959
|
function ft(t, e) {
|
|
925
|
-
const r = t.split("|").map((
|
|
960
|
+
const r = t.split("|").map((l) => l.trim()), s = r.shift() ?? "";
|
|
926
961
|
let i = pt(s, e);
|
|
927
|
-
for (const
|
|
928
|
-
const [o, ...
|
|
929
|
-
|
|
962
|
+
for (const l of r) {
|
|
963
|
+
const [o, ...a] = l.split(":"), g = o?.trim() ?? "", p = a.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), y = dt[g];
|
|
964
|
+
y && (i = y(i, p));
|
|
930
965
|
}
|
|
931
|
-
return
|
|
966
|
+
return O(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
|
|
932
967
|
}
|
|
933
968
|
function gt(t, e) {
|
|
934
969
|
let r = "", s = 0;
|
|
@@ -954,7 +989,7 @@ class mt {
|
|
|
954
989
|
isReady = !1;
|
|
955
990
|
project;
|
|
956
991
|
plugins = {};
|
|
957
|
-
eventBus =
|
|
992
|
+
eventBus = Ue();
|
|
958
993
|
organizationId;
|
|
959
994
|
projectId;
|
|
960
995
|
apiUrl;
|
|
@@ -962,23 +997,23 @@ class mt {
|
|
|
962
997
|
precondition;
|
|
963
998
|
condition;
|
|
964
999
|
searchParams = tt();
|
|
965
|
-
history =
|
|
966
|
-
components =
|
|
967
|
-
experienceInstances =
|
|
968
|
-
experiences =
|
|
969
|
-
frameworks =
|
|
1000
|
+
history = Te();
|
|
1001
|
+
components = Fe({ client: this });
|
|
1002
|
+
experienceInstances = ie({ client: this });
|
|
1003
|
+
experiences = me({ client: this });
|
|
1004
|
+
frameworks = je({ client: this });
|
|
970
1005
|
predicates = ze({ client: this });
|
|
971
|
-
features =
|
|
1006
|
+
features = De({ client: this });
|
|
972
1007
|
responses = Xe({ client: this });
|
|
973
|
-
fields =
|
|
1008
|
+
fields = _e({ client: this });
|
|
974
1009
|
actions = qe();
|
|
975
1010
|
constructor(e) {
|
|
976
1011
|
k("info", "Picked client initializing.");
|
|
977
1012
|
const { organizationId: r, projectId: s } = ut(e);
|
|
978
1013
|
this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || et(), this.session = it(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: Ze() }), k("info", "Picked client initialized.");
|
|
979
1014
|
}
|
|
980
|
-
start() {
|
|
981
|
-
|
|
1015
|
+
start = () => {
|
|
1016
|
+
Re(this), (async () => {
|
|
982
1017
|
if (!T())
|
|
983
1018
|
return;
|
|
984
1019
|
let r;
|
|
@@ -987,47 +1022,45 @@ class mt {
|
|
|
987
1022
|
r && (this.condition === void 0 ? s = !0 : typeof this.condition == "boolean" ? s = this.condition : s = await E(this, this.condition) === !0);
|
|
988
1023
|
const i = r && s === !0;
|
|
989
1024
|
if (typeof s == "boolean" && this.session) {
|
|
990
|
-
const
|
|
991
|
-
this.session.setIsUser(
|
|
1025
|
+
const l = s;
|
|
1026
|
+
this.session.setIsUser(l), this.eventBus({ type: "user_decide", value: l });
|
|
992
1027
|
}
|
|
993
|
-
this.eventBus({ type: "initialize" }), document.body && i &&
|
|
1028
|
+
this.eventBus({ type: "initialize" }), document.body && i && L(this), await oe(), i && L(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
|
|
994
1029
|
})();
|
|
995
|
-
}
|
|
996
|
-
registerFramework(e) {
|
|
997
|
-
|
|
998
|
-
}
|
|
999
|
-
registerComponent(e, r) {
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
registerPlugin(e) {
|
|
1003
|
-
|
|
1004
|
-
}
|
|
1005
|
-
registerFeature(e, r) {
|
|
1030
|
+
};
|
|
1031
|
+
registerFramework = (e) => {
|
|
1032
|
+
Ee(e, this.frameworks);
|
|
1033
|
+
};
|
|
1034
|
+
registerComponent = (e, r) => {
|
|
1035
|
+
_(e, r, this.components);
|
|
1036
|
+
};
|
|
1037
|
+
registerPlugin = (e) => {
|
|
1038
|
+
Se(this, e, this.plugins);
|
|
1039
|
+
};
|
|
1040
|
+
registerFeature = (e, r) => {
|
|
1006
1041
|
Ve(e, r, this.features);
|
|
1007
|
-
}
|
|
1008
|
-
registerPredicate(e, r) {
|
|
1042
|
+
};
|
|
1043
|
+
registerPredicate = (e, r) => {
|
|
1009
1044
|
Ce(e, r, this.predicates);
|
|
1010
|
-
}
|
|
1011
|
-
registerField(e) {
|
|
1045
|
+
};
|
|
1046
|
+
registerField = (e) => {
|
|
1012
1047
|
Je(e, this.fields);
|
|
1013
|
-
}
|
|
1014
|
-
registerAction(e, r) {
|
|
1048
|
+
};
|
|
1049
|
+
registerAction = (e, r) => {
|
|
1015
1050
|
Ke(e, r, this.actions);
|
|
1016
|
-
}
|
|
1017
|
-
registerExperience(e) {
|
|
1018
|
-
e.component &&
|
|
1019
|
-
}
|
|
1020
|
-
getStateSnapshot()
|
|
1021
|
-
|
|
1022
|
-
}
|
|
1023
|
-
async launchExperienceById(e) {
|
|
1051
|
+
};
|
|
1052
|
+
registerExperience = (e) => {
|
|
1053
|
+
e.component && _(`experience:${e.id}`, e.component, this.components), ye(e, this.experiences);
|
|
1054
|
+
};
|
|
1055
|
+
getStateSnapshot = () => Q(this);
|
|
1056
|
+
launchExperienceById = async (e) => {
|
|
1024
1057
|
const r = this.experiences.getById(e).getState();
|
|
1025
1058
|
if (!r) {
|
|
1026
1059
|
k("warn", `Experience with id '${e}' not found.`);
|
|
1027
1060
|
return;
|
|
1028
1061
|
}
|
|
1029
1062
|
Y(this, r);
|
|
1030
|
-
}
|
|
1063
|
+
};
|
|
1031
1064
|
// private async fetchProject() {
|
|
1032
1065
|
// if (this.project) {
|
|
1033
1066
|
// return
|
|
@@ -1063,13 +1096,13 @@ class mt {
|
|
|
1063
1096
|
const [s, i] = r.split(":");
|
|
1064
1097
|
if (!s || !i)
|
|
1065
1098
|
return;
|
|
1066
|
-
let
|
|
1067
|
-
|
|
1068
|
-
key: `${
|
|
1099
|
+
let l = i;
|
|
1100
|
+
l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(s, {
|
|
1101
|
+
key: `${l}`,
|
|
1069
1102
|
// use the assigned bucket value as the key
|
|
1070
1103
|
name: s,
|
|
1071
1104
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
1072
|
-
decide: () =>
|
|
1105
|
+
decide: () => l,
|
|
1073
1106
|
storage: "session"
|
|
1074
1107
|
});
|
|
1075
1108
|
} catch {
|
|
@@ -1096,9 +1129,7 @@ class mt {
|
|
|
1096
1129
|
this.registerAction(r, s);
|
|
1097
1130
|
});
|
|
1098
1131
|
}
|
|
1099
|
-
getPluginConfig(e) {
|
|
1100
|
-
return this.plugins[e] ?? {};
|
|
1101
|
-
}
|
|
1132
|
+
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1102
1133
|
/**
|
|
1103
1134
|
* Interpolates a template string using values from the client's response store and/or a provided context.
|
|
1104
1135
|
* Supports dot-notation, modifiers, and executing functions found in the context.
|
|
@@ -1142,7 +1173,7 @@ class mt {
|
|
|
1142
1173
|
* // => "Fruits: apple, banana, and cherry"
|
|
1143
1174
|
*/
|
|
1144
1175
|
renderString = (e, r) => {
|
|
1145
|
-
const s = this.responses.listStore.getState().reduce((i,
|
|
1176
|
+
const s = this.responses.listStore.getState().reduce((i, l) => (i[l.fieldId] = l.value, i), {});
|
|
1146
1177
|
return gt(e, {
|
|
1147
1178
|
...r,
|
|
1148
1179
|
responses: s
|
|
@@ -1150,28 +1181,38 @@ class mt {
|
|
|
1150
1181
|
};
|
|
1151
1182
|
}
|
|
1152
1183
|
function X(t) {
|
|
1153
|
-
return t.options
|
|
1184
|
+
return Array.isArray(t.options) && t.options.some((e) => "condition" in e);
|
|
1154
1185
|
}
|
|
1155
|
-
function
|
|
1186
|
+
function yt(t) {
|
|
1156
1187
|
return t.some((e) => e.condition || X(e));
|
|
1157
1188
|
}
|
|
1158
1189
|
async function xt(t, e) {
|
|
1159
|
-
return e.length === 0
|
|
1190
|
+
return e.length === 0 ? e : (await Promise.all(
|
|
1160
1191
|
e.map(async (s) => {
|
|
1161
|
-
|
|
1192
|
+
let i = s;
|
|
1193
|
+
if (s.options && typeof s.options == "function")
|
|
1194
|
+
try {
|
|
1195
|
+
const p = s.options, y = await Promise.resolve(p());
|
|
1196
|
+
i = { ...s, options: y };
|
|
1197
|
+
} catch {
|
|
1198
|
+
i = { ...s, options: null };
|
|
1199
|
+
}
|
|
1200
|
+
if (!yt([i]))
|
|
1201
|
+
return i;
|
|
1202
|
+
if (!(i.condition ? await E(t, i.condition) : !0))
|
|
1162
1203
|
return null;
|
|
1163
|
-
if (!
|
|
1164
|
-
return
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1167
|
-
)).filter((
|
|
1168
|
-
return
|
|
1204
|
+
if (!i.options || !X(i) || !Array.isArray(i.options))
|
|
1205
|
+
return i;
|
|
1206
|
+
const a = (await Promise.all(
|
|
1207
|
+
i.options.map(async (p) => p.condition ? await E(t, p.condition) ? p : null : p)
|
|
1208
|
+
)).filter((p) => p !== null);
|
|
1209
|
+
return a.length === i.options.length ? i : a.length === 0 ? null : { ...i, options: a };
|
|
1169
1210
|
})
|
|
1170
1211
|
)).filter((s) => s !== null);
|
|
1171
1212
|
}
|
|
1172
1213
|
const jt = (t) => {
|
|
1173
1214
|
const e = new mt(t);
|
|
1174
|
-
return
|
|
1215
|
+
return le(e), e;
|
|
1175
1216
|
};
|
|
1176
1217
|
export {
|
|
1177
1218
|
mt as Picked,
|
|
@@ -1181,18 +1222,18 @@ export {
|
|
|
1181
1222
|
ot as getPickedConfig,
|
|
1182
1223
|
xt as getStepFields,
|
|
1183
1224
|
At as isPickedRoot,
|
|
1184
|
-
|
|
1185
|
-
|
|
1225
|
+
z as localStore,
|
|
1226
|
+
C as sessionStore,
|
|
1186
1227
|
Rt as subscribe,
|
|
1187
|
-
|
|
1188
|
-
|
|
1228
|
+
Ot as supportsCookies,
|
|
1229
|
+
de as supportsCryptoRandomUUID,
|
|
1189
1230
|
T as supportsDocument,
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1231
|
+
zt as supportsHistory,
|
|
1232
|
+
Ct as supportsIntersectionObserver,
|
|
1233
|
+
ue as supportsLocalStorage,
|
|
1193
1234
|
Mt as supportsLocation,
|
|
1194
|
-
|
|
1195
|
-
|
|
1235
|
+
Dt as supportsSessionStorage,
|
|
1236
|
+
Vt as supportsShadowRoot,
|
|
1196
1237
|
Nt as supportsWebComponents,
|
|
1197
1238
|
U as supportsWindow
|
|
1198
1239
|
};
|