@picked/client 0.0.1-dev.1773365725739 → 0.0.1-dev.1773371977114
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/{api-B3JRgxph.js → api-CLwLE-DW.js} +1 -1
- package/dist/{api-F0IOGUor.cjs → api-Cn-rv5A5.cjs} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/esm/index.js +558 -554
- package/dist/esm/plugins/create-experience/index.js +173 -174
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/types/entities/field/field.d.ts +18 -3
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +6 -2
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/picked.d.ts +6 -2
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +5 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,145 +1,144 @@
|
|
|
1
|
-
import { createDomain as x, createApi as j, attach as
|
|
1
|
+
import { createDomain as x, createApi as j, attach as D, createStore as L, createEffect as z, sample as k, combine as V, createEvent as N } from "effector";
|
|
2
2
|
import { createFactory as b, invoke as I } from "@withease/factories";
|
|
3
|
-
import { g as
|
|
4
|
-
import { f as
|
|
3
|
+
import { g as Y, t as te, c as re, i as se, e as A, a as ne, b as ie, d as oe } from "../experience-instance-fvSEb72i.js";
|
|
4
|
+
import { f as zt } from "../experience-instance-fvSEb72i.js";
|
|
5
5
|
import { l as w } from "../logger-C9a75KZn.js";
|
|
6
|
-
import { c as
|
|
7
|
-
import { a as
|
|
8
|
-
import { p as ae, g as ce } from "../api-
|
|
6
|
+
import { c as $, l as O, s as M } from "../storage-Co_LbKr_.js";
|
|
7
|
+
import { a as Ot } from "../storage-Co_LbKr_.js";
|
|
8
|
+
import { p as ae, g as ce } from "../api-CLwLE-DW.js";
|
|
9
9
|
import { g as ue } from "../id-BW-g3y32.js";
|
|
10
10
|
import { i as de } from "../object-JwZ58NOH.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
const Y = x("experience"), me = b(
|
|
11
|
+
import { s as _, a as H, b as le, c as pe, d as fe } from "../supports-8YT4QKI7.js";
|
|
12
|
+
import { e as Ut, f as Dt, g as Vt, h as Nt, i as Tt, j as Lt, k as _t } from "../supports-8YT4QKI7.js";
|
|
13
|
+
const Q = x("experience"), ge = b(
|
|
15
14
|
({ client: t, experience: e }) => {
|
|
16
|
-
const r =
|
|
17
|
-
merge(
|
|
15
|
+
const r = Q.store(e), s = j(r, {
|
|
16
|
+
merge(c, g) {
|
|
18
17
|
return {
|
|
19
|
-
...
|
|
18
|
+
...c,
|
|
20
19
|
...g.experience
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
|
-
}), n = r.map((
|
|
24
|
-
name:
|
|
25
|
-
decisionLogic:
|
|
26
|
-
targetSelectors:
|
|
22
|
+
}), n = r.map((c) => ({
|
|
23
|
+
name: c.name,
|
|
24
|
+
decisionLogic: c.condition,
|
|
25
|
+
targetSelectors: c.targets,
|
|
27
26
|
initializeOpenLogic: e.initializeOpen
|
|
28
|
-
})),
|
|
29
|
-
(
|
|
27
|
+
})), f = t.components.listStore.map(
|
|
28
|
+
(c) => (e.componentName ? c.find((g) => g.name === e.componentName) : void 0) || c.find((g) => g.name === `experience:${e.id}`) || c.find((g) => g.name === "experience"),
|
|
30
29
|
{ skipVoid: !1 }
|
|
31
|
-
),
|
|
32
|
-
steps:
|
|
33
|
-
nodes:
|
|
34
|
-
edges:
|
|
35
|
-
conditionals:
|
|
36
|
-
})),
|
|
30
|
+
), i = r.map((c) => ({
|
|
31
|
+
steps: c.steps,
|
|
32
|
+
nodes: c.nodes,
|
|
33
|
+
edges: c.edges,
|
|
34
|
+
conditionals: c.conditionals
|
|
35
|
+
})), a = r.map((c) => c.fields), o = e.actions ?? [];
|
|
37
36
|
return {
|
|
38
37
|
id: e.id,
|
|
39
38
|
configStore: n,
|
|
40
|
-
treeStore:
|
|
41
|
-
fieldsStore:
|
|
42
|
-
componentStore:
|
|
43
|
-
actions:
|
|
39
|
+
treeStore: i,
|
|
40
|
+
fieldsStore: a,
|
|
41
|
+
componentStore: f,
|
|
42
|
+
actions: o,
|
|
44
43
|
merge: s.merge
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
46
|
);
|
|
48
|
-
function
|
|
49
|
-
return I(
|
|
47
|
+
function me(t) {
|
|
48
|
+
return I(ge, t);
|
|
50
49
|
}
|
|
51
|
-
const
|
|
52
|
-
const e =
|
|
53
|
-
register(
|
|
50
|
+
const he = b(({ client: t }) => {
|
|
51
|
+
const e = Q.store({}), r = j(e, {
|
|
52
|
+
register(o, c) {
|
|
54
53
|
return {
|
|
55
|
-
...
|
|
56
|
-
[
|
|
54
|
+
...o,
|
|
55
|
+
[c.id]: c
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
58
|
});
|
|
60
|
-
function s(
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
59
|
+
function s(o) {
|
|
60
|
+
const c = e.getState()[o.id];
|
|
61
|
+
if (c) {
|
|
62
|
+
c.merge({ experience: o, strategy: "override" });
|
|
64
63
|
return;
|
|
65
64
|
}
|
|
66
|
-
const g =
|
|
65
|
+
const g = me({ client: t, experience: o });
|
|
67
66
|
r.register(g);
|
|
68
67
|
}
|
|
69
|
-
const n = e.map((
|
|
70
|
-
function
|
|
71
|
-
return e.map((
|
|
68
|
+
const n = e.map((o) => Object.values(o));
|
|
69
|
+
function f(o) {
|
|
70
|
+
return e.map((c) => c[o], { skipVoid: !1 });
|
|
72
71
|
}
|
|
73
|
-
const
|
|
72
|
+
const i = D({
|
|
74
73
|
source: e,
|
|
75
|
-
effect: async (
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
78
|
-
w("warn", `Experience with id '${
|
|
74
|
+
effect: async (o, { id: c, options: g }) => {
|
|
75
|
+
const y = o[c];
|
|
76
|
+
if (!y) {
|
|
77
|
+
w("warn", `Experience with id '${c}' not found.`);
|
|
79
78
|
return;
|
|
80
79
|
}
|
|
81
80
|
if (g?.bypassCondition) {
|
|
82
|
-
|
|
81
|
+
T(t, y, g);
|
|
83
82
|
return;
|
|
84
83
|
}
|
|
85
|
-
await
|
|
84
|
+
await X(t, y) && T(t, y, g);
|
|
86
85
|
}
|
|
87
|
-
}),
|
|
86
|
+
}), a = D({
|
|
88
87
|
source: t.experienceInstances.listStore,
|
|
89
|
-
effect: (
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
for (const
|
|
93
|
-
|
|
88
|
+
effect: (o, { id: c, options: g }) => {
|
|
89
|
+
const y = o.filter((F) => F.experienceId === c);
|
|
90
|
+
if (y.length > 0)
|
|
91
|
+
for (const F of y)
|
|
92
|
+
F.open();
|
|
94
93
|
else
|
|
95
|
-
|
|
94
|
+
i({ id: c, options: { ...g, initialiseOpen: !0 } });
|
|
96
95
|
}
|
|
97
96
|
});
|
|
98
97
|
return {
|
|
99
98
|
/** Registers an experience in the index. If an experience with the same ID already exists, it is merged. */
|
|
100
99
|
register: s,
|
|
101
100
|
/** Returns a derived store for an experience by its ID. The store value is `undefined` when no match exists. */
|
|
102
|
-
get:
|
|
101
|
+
get: f,
|
|
103
102
|
/** @deprecated Use `experiences.get(id)` instead. */
|
|
104
|
-
getById:
|
|
103
|
+
getById: f,
|
|
105
104
|
/** Effector effect that launches an experience by ID, creating instances for each DOM target. */
|
|
106
|
-
launch:
|
|
105
|
+
launch: i,
|
|
107
106
|
/** Effector effect that opens an experience's existing instances, or launches it with `initialiseOpen` if none exist. */
|
|
108
|
-
open:
|
|
107
|
+
open: a,
|
|
109
108
|
/** Derived store containing all registered experiences as an array. */
|
|
110
109
|
listStore: n
|
|
111
110
|
};
|
|
112
111
|
});
|
|
113
|
-
function
|
|
114
|
-
return I(
|
|
112
|
+
function ye(t) {
|
|
113
|
+
return I(he, t);
|
|
115
114
|
}
|
|
116
|
-
const
|
|
115
|
+
const Se = (t, e) => {
|
|
117
116
|
e.register(t);
|
|
118
|
-
},
|
|
119
|
-
const { targetSelectors: s } = e.configStore.getState(), n =
|
|
117
|
+
}, T = (t, e, r) => {
|
|
118
|
+
const { targetSelectors: s } = e.configStore.getState(), n = Y(s, e.id);
|
|
120
119
|
n.forEach(
|
|
121
|
-
({ elements:
|
|
122
|
-
), re(n, e.id).forEach((
|
|
123
|
-
r ? t.experienceInstances.spawn(e,
|
|
120
|
+
({ elements: i }) => i.forEach((a) => te(a, e.id))
|
|
121
|
+
), re(n, e.id).forEach((i) => {
|
|
122
|
+
r ? t.experienceInstances.spawn(e, i, r) : t.experienceInstances.spawn(e, i);
|
|
124
123
|
});
|
|
125
|
-
},
|
|
124
|
+
}, K = async (t) => {
|
|
126
125
|
await Promise.all(
|
|
127
126
|
t.experiences.listStore.getState().map(async (e) => {
|
|
128
|
-
await
|
|
127
|
+
await X(t, e) && T(t, e);
|
|
129
128
|
})
|
|
130
129
|
);
|
|
131
|
-
},
|
|
130
|
+
}, X = async (t, e) => {
|
|
132
131
|
if (!t.preconditionPassed || !t.session?.isUser)
|
|
133
132
|
return !1;
|
|
134
133
|
const { decisionLogic: r, targetSelectors: s } = e.configStore.getState();
|
|
135
|
-
return
|
|
136
|
-
},
|
|
134
|
+
return Y(s, e.id).length < 1 || s.length === 0 ? !1 : r === void 0 ? !0 : se(r) ? await A(t, r) === !0 : !0;
|
|
135
|
+
}, ve = (t, e, r) => {
|
|
137
136
|
const s = e.name, n = e.setup(t);
|
|
138
137
|
if (n) {
|
|
139
|
-
const
|
|
140
|
-
r[s] = Object.freeze({ ...
|
|
138
|
+
const f = r[s] ?? {};
|
|
139
|
+
r[s] = Object.freeze({ ...f, ...n });
|
|
141
140
|
}
|
|
142
|
-
},
|
|
141
|
+
}, ke = x("component"), we = b(
|
|
143
142
|
({ client: t, component: e, name: r }) => {
|
|
144
143
|
const s = t.frameworks.getByName(e.frameworkName);
|
|
145
144
|
return {
|
|
@@ -149,89 +148,89 @@ const ve = (t, e) => {
|
|
|
149
148
|
};
|
|
150
149
|
}
|
|
151
150
|
);
|
|
152
|
-
function
|
|
153
|
-
return I(
|
|
151
|
+
function be(t) {
|
|
152
|
+
return I(we, t);
|
|
154
153
|
}
|
|
155
|
-
const
|
|
156
|
-
const e =
|
|
157
|
-
register(
|
|
154
|
+
const Ie = b(({ client: t }) => {
|
|
155
|
+
const e = ke.store({}), r = j(e, {
|
|
156
|
+
register(i, a) {
|
|
158
157
|
return {
|
|
159
|
-
...
|
|
160
|
-
[
|
|
158
|
+
...i,
|
|
159
|
+
[a.name]: a
|
|
161
160
|
};
|
|
162
161
|
}
|
|
163
162
|
});
|
|
164
|
-
function s(
|
|
165
|
-
e.getState()[
|
|
163
|
+
function s(i, a) {
|
|
164
|
+
e.getState()[i] && w(
|
|
166
165
|
"warn",
|
|
167
|
-
`Component '${
|
|
166
|
+
`Component '${i}' already registered. Registering again will override the previous registration.`
|
|
168
167
|
);
|
|
169
|
-
const
|
|
170
|
-
r.register(
|
|
168
|
+
const c = be({ client: t, name: i, component: a });
|
|
169
|
+
r.register(c);
|
|
171
170
|
}
|
|
172
|
-
const n = e.map((
|
|
173
|
-
function
|
|
174
|
-
return e.map((
|
|
171
|
+
const n = e.map((i) => Object.values(i));
|
|
172
|
+
function f(i) {
|
|
173
|
+
return e.map((a) => a[i], { skipVoid: !1 });
|
|
175
174
|
}
|
|
176
175
|
return {
|
|
177
176
|
register: s,
|
|
178
|
-
getByName:
|
|
177
|
+
getByName: f,
|
|
179
178
|
listStore: n
|
|
180
179
|
};
|
|
181
180
|
});
|
|
182
|
-
function
|
|
183
|
-
return I(
|
|
181
|
+
function Fe(t) {
|
|
182
|
+
return I(Ie, t);
|
|
184
183
|
}
|
|
185
|
-
const
|
|
184
|
+
const G = (t, e, r) => {
|
|
186
185
|
r.register(t, e);
|
|
187
|
-
},
|
|
188
|
-
const e =
|
|
189
|
-
register(
|
|
186
|
+
}, xe = x("framework"), je = b(({ client: t }) => {
|
|
187
|
+
const e = xe.store({}), r = j(e, {
|
|
188
|
+
register(i, a) {
|
|
190
189
|
return {
|
|
191
|
-
...
|
|
192
|
-
[
|
|
190
|
+
...i,
|
|
191
|
+
[a.name]: a.framework
|
|
193
192
|
};
|
|
194
193
|
}
|
|
195
194
|
});
|
|
196
|
-
function s(
|
|
197
|
-
e.getState()[
|
|
195
|
+
function s(i, a) {
|
|
196
|
+
e.getState()[i] && w(
|
|
198
197
|
"warn",
|
|
199
|
-
`Framework '${
|
|
200
|
-
), r.register({ name:
|
|
198
|
+
`Framework '${i}' already registered. Registering again will override the previous registration.`
|
|
199
|
+
), r.register({ name: i, framework: a });
|
|
201
200
|
}
|
|
202
|
-
const n = e.map((
|
|
203
|
-
function
|
|
204
|
-
return e.map((
|
|
201
|
+
const n = e.map((i) => Object.values(i));
|
|
202
|
+
function f(i) {
|
|
203
|
+
return e.map((a) => a[i], { skipVoid: !1 });
|
|
205
204
|
}
|
|
206
205
|
return {
|
|
207
206
|
register: s,
|
|
208
|
-
getByName:
|
|
207
|
+
getByName: f,
|
|
209
208
|
listStore: n
|
|
210
209
|
};
|
|
211
210
|
});
|
|
212
|
-
function
|
|
213
|
-
return I(
|
|
211
|
+
function Ee(t) {
|
|
212
|
+
return I(je, t);
|
|
214
213
|
}
|
|
215
|
-
const
|
|
214
|
+
const Pe = (t, e) => {
|
|
216
215
|
e.register(t.name, t);
|
|
217
|
-
},
|
|
216
|
+
}, Ae = 6e3, $e = $("last_ping", "global"), Be = async (t) => {
|
|
218
217
|
try {
|
|
219
|
-
const e = Date.now(), r =
|
|
218
|
+
const e = Date.now(), r = O.get($e);
|
|
220
219
|
let s = 0;
|
|
221
|
-
if (r.isSet() && (s = r.json() ?? 0), s && e - s <
|
|
220
|
+
if (r.isSet() && (s = r.json() ?? 0), s && e - s < Ae)
|
|
222
221
|
return !0;
|
|
223
222
|
const n = {
|
|
224
223
|
projectId: t.projectId,
|
|
225
224
|
path: window.location.pathname
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
return
|
|
225
|
+
}, f = {}, a = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
226
|
+
a && (f["x-vercel-protection-bypass"] = a);
|
|
227
|
+
const c = (await ae(t.apiUrl, "ping", n, f)).ok;
|
|
228
|
+
return c && r.set(e), c;
|
|
230
229
|
} catch (e) {
|
|
231
230
|
return w("error", e), !1;
|
|
232
231
|
}
|
|
233
232
|
};
|
|
234
|
-
function
|
|
233
|
+
function Z(t) {
|
|
235
234
|
const e = typeof window < "u", r = {
|
|
236
235
|
client: t,
|
|
237
236
|
responses: t.responses.listStore.getState(),
|
|
@@ -243,223 +242,223 @@ function X(t) {
|
|
|
243
242
|
};
|
|
244
243
|
return Object.freeze(r);
|
|
245
244
|
}
|
|
246
|
-
const
|
|
247
|
-
const e =
|
|
248
|
-
register(
|
|
245
|
+
const Re = x("predicate"), ze = b(({ client: t }) => {
|
|
246
|
+
const e = Re.store({}), r = j(e, {
|
|
247
|
+
register(a, o) {
|
|
249
248
|
return {
|
|
250
|
-
...
|
|
251
|
-
[
|
|
252
|
-
name:
|
|
253
|
-
predicate:
|
|
249
|
+
...a,
|
|
250
|
+
[o.name]: {
|
|
251
|
+
name: o.name,
|
|
252
|
+
predicate: o.predicate
|
|
254
253
|
}
|
|
255
254
|
};
|
|
256
255
|
}
|
|
257
256
|
});
|
|
258
|
-
function s(
|
|
259
|
-
e.getState()[
|
|
257
|
+
function s(a, o) {
|
|
258
|
+
e.getState()[a] && w(
|
|
260
259
|
"warn",
|
|
261
|
-
`Predicate '${
|
|
262
|
-
), r.register(Object.freeze({ name:
|
|
260
|
+
`Predicate '${a}' already registered. Registering again will override the previous registration.`
|
|
261
|
+
), r.register(Object.freeze({ name: a, predicate: o }));
|
|
263
262
|
}
|
|
264
|
-
const n = e.map((
|
|
265
|
-
function
|
|
266
|
-
return e.map((
|
|
263
|
+
const n = e.map((a) => Object.values(a));
|
|
264
|
+
function f(a) {
|
|
265
|
+
return e.map((o) => o[a]?.predicate, { skipVoid: !1 });
|
|
267
266
|
}
|
|
268
|
-
function
|
|
269
|
-
const
|
|
267
|
+
function i(a) {
|
|
268
|
+
const o = L(() => {
|
|
270
269
|
}, {
|
|
271
270
|
skipVoid: !1
|
|
272
|
-
}),
|
|
273
|
-
const g =
|
|
271
|
+
}), c = z(async () => {
|
|
272
|
+
const g = f(a).getState();
|
|
274
273
|
if (!g)
|
|
275
274
|
return;
|
|
276
|
-
const
|
|
277
|
-
return (...
|
|
275
|
+
const y = Z(t);
|
|
276
|
+
return (...F) => g({ ...y, args: F });
|
|
278
277
|
});
|
|
279
278
|
return k({
|
|
280
279
|
source: { responses: t.responses.listStore, fields: t.fields.listStore },
|
|
281
|
-
target:
|
|
280
|
+
target: c
|
|
282
281
|
}), k({
|
|
283
|
-
clock:
|
|
282
|
+
clock: c.doneData,
|
|
284
283
|
filter: (g) => g !== void 0,
|
|
285
|
-
target:
|
|
286
|
-
}),
|
|
284
|
+
target: o
|
|
285
|
+
}), c(), o;
|
|
287
286
|
}
|
|
288
287
|
return {
|
|
289
288
|
register: s,
|
|
290
|
-
getByName:
|
|
289
|
+
getByName: f,
|
|
291
290
|
listStore: n,
|
|
292
|
-
getEvokablePredicate:
|
|
291
|
+
getEvokablePredicate: i
|
|
293
292
|
};
|
|
294
293
|
});
|
|
295
|
-
function
|
|
296
|
-
return I(
|
|
294
|
+
function Ce(t) {
|
|
295
|
+
return I(ze, t);
|
|
297
296
|
}
|
|
298
|
-
const
|
|
297
|
+
const Oe = (t, e, r) => {
|
|
299
298
|
r.register(t, e);
|
|
300
|
-
},
|
|
301
|
-
const e =
|
|
302
|
-
register(
|
|
299
|
+
}, J = x("feature"), Me = b(({ client: t }) => {
|
|
300
|
+
const e = J.store({}), r = J.store([]), s = j(e, {
|
|
301
|
+
register(d, l) {
|
|
303
302
|
return {
|
|
304
|
-
...
|
|
305
|
-
[
|
|
303
|
+
...d,
|
|
304
|
+
[l.id]: l.feature
|
|
306
305
|
};
|
|
307
306
|
}
|
|
308
307
|
});
|
|
309
|
-
function n(
|
|
310
|
-
e.getState()[
|
|
308
|
+
function n(d, l) {
|
|
309
|
+
e.getState()[d] && w(
|
|
311
310
|
"warn",
|
|
312
|
-
`Feature '${
|
|
311
|
+
`Feature '${d}' already registered. Registering again will override the previous registration.`
|
|
313
312
|
);
|
|
314
|
-
const
|
|
315
|
-
id:
|
|
313
|
+
const m = {
|
|
314
|
+
id: d,
|
|
316
315
|
feature: {
|
|
317
|
-
...
|
|
318
|
-
id:
|
|
316
|
+
...l,
|
|
317
|
+
id: d
|
|
319
318
|
}
|
|
320
319
|
};
|
|
321
320
|
s.register(
|
|
322
321
|
Object.freeze({
|
|
323
|
-
id:
|
|
324
|
-
feature:
|
|
322
|
+
id: d,
|
|
323
|
+
feature: m
|
|
325
324
|
})
|
|
326
325
|
);
|
|
327
326
|
}
|
|
328
|
-
const
|
|
327
|
+
const f = z(
|
|
329
328
|
async ({
|
|
330
|
-
id:
|
|
331
|
-
key:
|
|
332
|
-
storage:
|
|
329
|
+
id: d,
|
|
330
|
+
key: l,
|
|
331
|
+
storage: u = "local"
|
|
333
332
|
}) => {
|
|
334
|
-
const
|
|
335
|
-
return
|
|
333
|
+
const m = $(`feature:${d}:${l}`, "global"), h = (u === "session" ? M : O).get(m).boolean();
|
|
334
|
+
return h === null ? null : { id: d, key: l, bucket: h, storage: u };
|
|
336
335
|
}
|
|
337
|
-
),
|
|
338
|
-
if (!
|
|
336
|
+
), i = z((d) => {
|
|
337
|
+
if (!d)
|
|
339
338
|
return null;
|
|
340
|
-
const
|
|
341
|
-
(
|
|
342
|
-
}),
|
|
339
|
+
const l = $(`feature:${d.id}:${d.key}`, "global");
|
|
340
|
+
(d.storage === "session" ? M : O).set(l, d.bucket);
|
|
341
|
+
}), a = /* @__PURE__ */ new Map(), o = D({
|
|
343
342
|
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
344
|
-
effect: async ({ allFeaturesStore:
|
|
345
|
-
const
|
|
346
|
-
(
|
|
343
|
+
effect: async ({ allFeaturesStore: d, resolvedFeaturesStore: l }, { id: u, decide: m, key: p }) => {
|
|
344
|
+
const h = l.find(
|
|
345
|
+
(R) => R.id === u && R.key === p
|
|
347
346
|
);
|
|
348
|
-
if (
|
|
349
|
-
return
|
|
350
|
-
const
|
|
351
|
-
if (!
|
|
352
|
-
throw new Error(`Feature with id '${
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
355
|
-
const
|
|
356
|
-
return { id:
|
|
347
|
+
if (h)
|
|
348
|
+
return h;
|
|
349
|
+
const S = d[u];
|
|
350
|
+
if (!S)
|
|
351
|
+
throw new Error(`Feature with id '${u}' not found`);
|
|
352
|
+
const E = a.get(`${u}:${p}`);
|
|
353
|
+
if (E !== void 0) {
|
|
354
|
+
const R = await E;
|
|
355
|
+
return { id: S.id, bucket: R, key: p, storage: S.feature.storage };
|
|
357
356
|
}
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
return { id:
|
|
357
|
+
const B = m();
|
|
358
|
+
a.set(`${u}:${p}`, B);
|
|
359
|
+
const v = await B;
|
|
360
|
+
return { id: S.id, bucket: v, key: p, storage: S.feature.storage };
|
|
362
361
|
}
|
|
363
362
|
});
|
|
364
363
|
k({
|
|
365
364
|
clock: s.register,
|
|
366
|
-
fn: (
|
|
367
|
-
const { id:
|
|
368
|
-
return { id:
|
|
365
|
+
fn: (d) => {
|
|
366
|
+
const { id: l, feature: u } = d;
|
|
367
|
+
return { id: l, key: u.feature.key, storage: u.feature.storage };
|
|
369
368
|
},
|
|
370
|
-
target:
|
|
369
|
+
target: f
|
|
371
370
|
}), k({
|
|
372
371
|
source: e,
|
|
373
|
-
clock:
|
|
374
|
-
fn: (
|
|
375
|
-
const { id:
|
|
376
|
-
return
|
|
372
|
+
clock: o.doneData,
|
|
373
|
+
fn: (d, l) => {
|
|
374
|
+
const { id: u, bucket: m, storage: p } = l, h = d[u]?.feature.key;
|
|
375
|
+
return h ? { key: h, id: u, bucket: m, storage: p } : null;
|
|
377
376
|
},
|
|
378
|
-
target:
|
|
377
|
+
target: i
|
|
379
378
|
});
|
|
380
|
-
const
|
|
379
|
+
const c = V({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
381
380
|
({
|
|
382
|
-
allFeaturesStore:
|
|
383
|
-
resolvedFeaturesStore:
|
|
384
|
-
}) => Object.values(
|
|
385
|
-
const
|
|
386
|
-
(
|
|
381
|
+
allFeaturesStore: d,
|
|
382
|
+
resolvedFeaturesStore: l
|
|
383
|
+
}) => Object.values(d).map((u) => {
|
|
384
|
+
const m = l.find(
|
|
385
|
+
(p) => p.id === u.id && p.key === u.feature.key
|
|
387
386
|
);
|
|
388
|
-
return
|
|
389
|
-
id:
|
|
390
|
-
name:
|
|
391
|
-
key:
|
|
392
|
-
getBucket: () => ({ id:
|
|
387
|
+
return m ? {
|
|
388
|
+
id: u.id,
|
|
389
|
+
name: u.feature.name,
|
|
390
|
+
key: u.feature.key,
|
|
391
|
+
getBucket: () => ({ id: u.id, bucket: m.bucket }),
|
|
393
392
|
isResolved: !0
|
|
394
393
|
} : {
|
|
395
|
-
id:
|
|
396
|
-
name:
|
|
397
|
-
key:
|
|
398
|
-
getBucket: async () => await
|
|
394
|
+
id: u.id,
|
|
395
|
+
name: u.feature.name,
|
|
396
|
+
key: u.feature.key,
|
|
397
|
+
getBucket: async () => await o(u.feature),
|
|
399
398
|
isResolved: !1
|
|
400
399
|
};
|
|
401
400
|
})
|
|
402
401
|
);
|
|
403
402
|
k({
|
|
404
|
-
clock:
|
|
403
|
+
clock: o.doneData,
|
|
405
404
|
source: { resolvedFeatures: r },
|
|
406
|
-
filter: ({ resolvedFeatures:
|
|
407
|
-
(
|
|
405
|
+
filter: ({ resolvedFeatures: d }, { id: l, key: u }) => !d.some(
|
|
406
|
+
(p) => p.id === l && p.key === u
|
|
408
407
|
),
|
|
409
|
-
fn: (
|
|
410
|
-
target: t.eventBus.prepend((
|
|
408
|
+
fn: (d, l) => l,
|
|
409
|
+
target: t.eventBus.prepend((d) => ({
|
|
411
410
|
type: "feature_decide",
|
|
412
|
-
feature:
|
|
411
|
+
feature: d
|
|
413
412
|
}))
|
|
414
413
|
}), k({
|
|
415
|
-
clock: [
|
|
414
|
+
clock: [f.doneData, o.doneData],
|
|
416
415
|
source: r,
|
|
417
|
-
fn: (
|
|
418
|
-
(
|
|
419
|
-
) ?
|
|
416
|
+
fn: (d, l) => !l || d.some(
|
|
417
|
+
(m) => m.id === l.id && m.key === l.key
|
|
418
|
+
) ? d : [...d, l],
|
|
420
419
|
target: r
|
|
421
420
|
});
|
|
422
|
-
function g(
|
|
423
|
-
return
|
|
421
|
+
function g(d) {
|
|
422
|
+
return c.map((l) => l.find((u) => u.id === d));
|
|
424
423
|
}
|
|
425
|
-
function
|
|
426
|
-
return e.map((
|
|
424
|
+
function y(d) {
|
|
425
|
+
return e.map((l) => l[d], { skipVoid: !1 });
|
|
427
426
|
}
|
|
428
|
-
function
|
|
429
|
-
const
|
|
427
|
+
function F(d) {
|
|
428
|
+
const l = L(
|
|
430
429
|
async () => {
|
|
431
430
|
},
|
|
432
431
|
{ skipVoid: !1 }
|
|
433
|
-
),
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
436
|
-
return async () => (await
|
|
432
|
+
), u = z(async () => {
|
|
433
|
+
const m = g(d).getState();
|
|
434
|
+
if (m)
|
|
435
|
+
return async () => (await m.getBucket()).bucket;
|
|
437
436
|
});
|
|
438
437
|
return k({
|
|
439
438
|
source: r,
|
|
440
|
-
filter: (
|
|
441
|
-
target:
|
|
439
|
+
filter: (m) => m.some((p) => p.id === d),
|
|
440
|
+
target: u
|
|
442
441
|
}), k({
|
|
443
|
-
clock:
|
|
444
|
-
filter: (
|
|
445
|
-
target:
|
|
446
|
-
}),
|
|
442
|
+
clock: u.doneData,
|
|
443
|
+
filter: (m) => m !== void 0,
|
|
444
|
+
target: l
|
|
445
|
+
}), u(), l;
|
|
447
446
|
}
|
|
448
447
|
return {
|
|
449
448
|
register: n,
|
|
450
449
|
getById: g,
|
|
451
|
-
getByName:
|
|
452
|
-
listStore:
|
|
453
|
-
getEvokableFeature:
|
|
450
|
+
getByName: y,
|
|
451
|
+
listStore: c,
|
|
452
|
+
getEvokableFeature: F
|
|
454
453
|
};
|
|
455
454
|
});
|
|
456
|
-
function
|
|
457
|
-
return I(
|
|
455
|
+
function Ue(t) {
|
|
456
|
+
return I(Me, t);
|
|
458
457
|
}
|
|
459
|
-
const
|
|
458
|
+
const De = (t, e, r) => {
|
|
460
459
|
r.register(t, e);
|
|
461
|
-
},
|
|
462
|
-
function
|
|
460
|
+
}, P = x("history");
|
|
461
|
+
function q(t, e) {
|
|
463
462
|
return {
|
|
464
463
|
// eslint-disable-next-line sonarjs/pseudo-random
|
|
465
464
|
id: ue(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
@@ -468,132 +467,134 @@ function J(t, e) {
|
|
|
468
467
|
experienceId: t
|
|
469
468
|
};
|
|
470
469
|
}
|
|
471
|
-
const
|
|
472
|
-
const t =
|
|
473
|
-
t.on(e, (
|
|
474
|
-
entries: [...
|
|
475
|
-
})), t.on(r, (
|
|
470
|
+
const Ve = b(() => {
|
|
471
|
+
const t = P.store({ entries: [] }), e = P.event(), r = P.event(), s = P.event(), n = P.event();
|
|
472
|
+
t.on(e, (i, a) => ({
|
|
473
|
+
entries: [...i.entries, q(a.experienceId, a.node)]
|
|
474
|
+
})), t.on(r, (i, a) => ({
|
|
476
475
|
entries: [
|
|
477
|
-
...
|
|
478
|
-
|
|
476
|
+
...i.entries.slice(0, -1),
|
|
477
|
+
q(a.experienceId, a.node)
|
|
479
478
|
]
|
|
480
|
-
})), t.on(n, (
|
|
481
|
-
function
|
|
482
|
-
const
|
|
483
|
-
for (let
|
|
484
|
-
const g =
|
|
485
|
-
if (!(!
|
|
486
|
-
if (
|
|
487
|
-
|
|
479
|
+
})), t.on(n, (i, a) => a);
|
|
480
|
+
function f(i, a) {
|
|
481
|
+
const o = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
482
|
+
for (let c = i.length - 1; c >= 0; c--) {
|
|
483
|
+
const g = i[c], y = g?.node;
|
|
484
|
+
if (!(!y || !ne(y)) && !(a && g?.experienceId !== a))
|
|
485
|
+
if (o.lastStepIndex === -1)
|
|
486
|
+
o.lastStepIndex = c;
|
|
488
487
|
else {
|
|
489
|
-
|
|
488
|
+
o.secondLastStepIndex = c;
|
|
490
489
|
break;
|
|
491
490
|
}
|
|
492
491
|
}
|
|
493
|
-
return
|
|
492
|
+
return o;
|
|
494
493
|
}
|
|
495
|
-
return t.on(s, (
|
|
496
|
-
const { secondLastStepIndex:
|
|
494
|
+
return t.on(s, (i, a) => {
|
|
495
|
+
const { secondLastStepIndex: o } = f(i.entries, a.experienceId), c = o !== -1 ? i.entries.slice(0, o + 1) : i.entries;
|
|
497
496
|
return {
|
|
498
|
-
...
|
|
499
|
-
entries:
|
|
497
|
+
...i,
|
|
498
|
+
entries: c
|
|
500
499
|
};
|
|
501
500
|
}), {
|
|
502
501
|
push: e,
|
|
503
502
|
replace: r,
|
|
504
503
|
back: s,
|
|
505
504
|
restore: n,
|
|
506
|
-
entriesStore: t.map((
|
|
505
|
+
entriesStore: t.map((i) => i.entries)
|
|
507
506
|
};
|
|
508
507
|
});
|
|
509
|
-
function
|
|
510
|
-
return I(
|
|
508
|
+
function Ne() {
|
|
509
|
+
return I(Ve);
|
|
511
510
|
}
|
|
512
|
-
let
|
|
513
|
-
const
|
|
514
|
-
const e =
|
|
511
|
+
let Te = 0;
|
|
512
|
+
const Le = (t) => {
|
|
513
|
+
const e = L([]);
|
|
515
514
|
return k({
|
|
516
515
|
clock: t,
|
|
517
516
|
source: e,
|
|
518
517
|
fn: (r, s) => [
|
|
519
518
|
...r,
|
|
520
519
|
{
|
|
521
|
-
id:
|
|
520
|
+
id: Te++,
|
|
522
521
|
at: /* @__PURE__ */ new Date(),
|
|
523
522
|
payload: s
|
|
524
523
|
}
|
|
525
524
|
],
|
|
526
525
|
target: e
|
|
527
526
|
}), e;
|
|
528
|
-
},
|
|
529
|
-
const t =
|
|
530
|
-
register(
|
|
527
|
+
}, _e = x("field"), He = b(() => {
|
|
528
|
+
const t = _e.store({}), e = j(t, {
|
|
529
|
+
register(o, c) {
|
|
531
530
|
return {
|
|
532
|
-
...
|
|
533
|
-
[
|
|
531
|
+
...o,
|
|
532
|
+
[c.resolvedKey]: { ...c.field, key: c.resolvedKey }
|
|
534
533
|
};
|
|
535
534
|
}
|
|
536
535
|
});
|
|
537
|
-
function r(
|
|
538
|
-
e.register({ field:
|
|
536
|
+
function r(o) {
|
|
537
|
+
e.register({ field: o, resolvedKey: o.key });
|
|
539
538
|
}
|
|
540
|
-
function s(
|
|
541
|
-
const g =
|
|
539
|
+
function s(o, c) {
|
|
540
|
+
const g = f(o).getState();
|
|
542
541
|
if (!g)
|
|
543
542
|
return;
|
|
544
|
-
const
|
|
545
|
-
...
|
|
543
|
+
const y = Object.assign({}, g, {
|
|
544
|
+
...c
|
|
546
545
|
});
|
|
547
|
-
e.register({ field: { ...
|
|
546
|
+
e.register({ field: { ...y }, resolvedKey: o });
|
|
548
547
|
}
|
|
549
|
-
const n = t.map((
|
|
550
|
-
function
|
|
551
|
-
return t.map((
|
|
548
|
+
const n = t.map((o) => Object.values(o));
|
|
549
|
+
function f(o) {
|
|
550
|
+
return t.map((c) => c[o] || null);
|
|
552
551
|
}
|
|
553
|
-
function o
|
|
554
|
-
return t.map((
|
|
552
|
+
function i(o) {
|
|
553
|
+
return t.map((c) => Object.values(c).find((g) => g.id === o) || null);
|
|
555
554
|
}
|
|
556
|
-
function
|
|
557
|
-
return t.map((
|
|
555
|
+
function a(o) {
|
|
556
|
+
return t.map((c) => Object.values(c).find((g) => g.name === o) || null);
|
|
558
557
|
}
|
|
559
558
|
return {
|
|
560
559
|
register: r,
|
|
561
560
|
update: s,
|
|
562
|
-
getByKey:
|
|
563
|
-
|
|
561
|
+
getByKey: f,
|
|
562
|
+
// eslint-disable-next-line sonarjs/deprecation -- exposing deprecated alias for backwards compatibility
|
|
563
|
+
getById: i,
|
|
564
564
|
listStore: n,
|
|
565
|
-
|
|
565
|
+
// eslint-disable-next-line sonarjs/deprecation -- exposing deprecated alias for backwards compatibility
|
|
566
|
+
getByName: a
|
|
566
567
|
};
|
|
567
568
|
});
|
|
568
|
-
function
|
|
569
|
-
return I(
|
|
569
|
+
function Ke() {
|
|
570
|
+
return I(He);
|
|
570
571
|
}
|
|
571
|
-
const
|
|
572
|
+
const Ge = (t, e) => {
|
|
572
573
|
e.register(t);
|
|
573
|
-
},
|
|
574
|
-
const t =
|
|
575
|
-
register(
|
|
574
|
+
}, Je = x("action"), qe = b(() => {
|
|
575
|
+
const t = Je.store({}), e = j(t, {
|
|
576
|
+
register(i, a) {
|
|
576
577
|
return {
|
|
577
|
-
...
|
|
578
|
-
[
|
|
579
|
-
name:
|
|
580
|
-
action:
|
|
578
|
+
...i,
|
|
579
|
+
[a.name]: {
|
|
580
|
+
name: a.name,
|
|
581
|
+
action: a.action
|
|
581
582
|
}
|
|
582
583
|
};
|
|
583
584
|
}
|
|
584
585
|
});
|
|
585
|
-
function r(
|
|
586
|
-
e.register({ name:
|
|
586
|
+
function r(i, a) {
|
|
587
|
+
e.register({ name: i, action: a });
|
|
587
588
|
}
|
|
588
|
-
const s = t.map((
|
|
589
|
-
function n(
|
|
590
|
-
return t.map((
|
|
589
|
+
const s = t.map((i) => Object.values(i));
|
|
590
|
+
function n(i) {
|
|
591
|
+
return t.map((a) => a[i], { skipVoid: !1 });
|
|
591
592
|
}
|
|
592
|
-
function
|
|
593
|
+
function f(i) {
|
|
593
594
|
return t.map(
|
|
594
|
-
(
|
|
595
|
-
const
|
|
596
|
-
return
|
|
595
|
+
(a) => {
|
|
596
|
+
const o = a[i];
|
|
597
|
+
return o ? o.action : void 0;
|
|
597
598
|
},
|
|
598
599
|
{ skipVoid: !1 }
|
|
599
600
|
);
|
|
@@ -602,215 +603,216 @@ const Je = (t, e) => {
|
|
|
602
603
|
register: r,
|
|
603
604
|
getByName: n,
|
|
604
605
|
listStore: s,
|
|
605
|
-
getEvokableAction:
|
|
606
|
+
getEvokableAction: f
|
|
606
607
|
};
|
|
607
608
|
});
|
|
608
|
-
function
|
|
609
|
-
return I(
|
|
609
|
+
function We() {
|
|
610
|
+
return I(qe);
|
|
610
611
|
}
|
|
611
|
-
const
|
|
612
|
+
const Ye = (t, e, r) => {
|
|
612
613
|
r.register(t, e);
|
|
613
614
|
};
|
|
614
|
-
function
|
|
615
|
+
function U(t) {
|
|
615
616
|
return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
|
|
616
617
|
}
|
|
617
|
-
function
|
|
618
|
+
function Qe(t) {
|
|
618
619
|
return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null;
|
|
619
620
|
}
|
|
620
|
-
function
|
|
621
|
+
function W(t) {
|
|
621
622
|
try {
|
|
622
623
|
return JSON.stringify(t), !0;
|
|
623
624
|
} catch {
|
|
624
625
|
return !1;
|
|
625
626
|
}
|
|
626
627
|
}
|
|
627
|
-
const
|
|
628
|
-
const e =
|
|
629
|
-
register(
|
|
628
|
+
const Xe = x("response"), Ze = b(({ client: t }) => {
|
|
629
|
+
const e = Xe.store({}), r = N(), s = N(), n = j(e, {
|
|
630
|
+
register(d, l) {
|
|
630
631
|
return {
|
|
631
|
-
...
|
|
632
|
-
[
|
|
632
|
+
...d,
|
|
633
|
+
[l.fieldKey]: l.response
|
|
633
634
|
};
|
|
634
635
|
},
|
|
635
|
-
registerBatch(
|
|
636
|
+
registerBatch(d, l) {
|
|
636
637
|
return {
|
|
637
|
-
...
|
|
638
|
-
...
|
|
638
|
+
...d,
|
|
639
|
+
...l
|
|
639
640
|
};
|
|
640
641
|
},
|
|
641
|
-
clear(
|
|
642
|
-
const { [
|
|
643
|
-
return
|
|
642
|
+
clear(d, l) {
|
|
643
|
+
const { [l]: u, ...m } = d;
|
|
644
|
+
return m;
|
|
644
645
|
},
|
|
645
646
|
clearAll() {
|
|
646
647
|
return {};
|
|
647
648
|
}
|
|
648
649
|
});
|
|
649
|
-
function
|
|
650
|
-
if (typeof
|
|
651
|
-
if (
|
|
650
|
+
function f(d, l) {
|
|
651
|
+
if (typeof d == "string") {
|
|
652
|
+
if (l === void 0)
|
|
652
653
|
throw new Error("Response is required when registering a single field");
|
|
653
|
-
n.register({
|
|
654
|
+
n.register({ fieldKey: d, response: l });
|
|
654
655
|
} else
|
|
655
|
-
n.registerBatch(
|
|
656
|
+
n.registerBatch(d);
|
|
656
657
|
}
|
|
657
|
-
async function
|
|
658
|
-
const
|
|
658
|
+
async function i(d) {
|
|
659
|
+
const l = [];
|
|
659
660
|
return await Promise.allSettled(
|
|
660
661
|
// eslint-disable-next-line sonarjs/cognitive-complexity -- validation covers all field types, options, and JSON-serializability; splitting would obscure intent
|
|
661
|
-
Object.entries(
|
|
662
|
-
let
|
|
663
|
-
const h = t.fields.getByKey(
|
|
662
|
+
Object.entries(d).map(async ([u, m]) => {
|
|
663
|
+
let p = m;
|
|
664
|
+
const h = t.fields.getByKey(u).getState();
|
|
664
665
|
if (!h) {
|
|
665
|
-
|
|
666
|
-
fieldId:
|
|
667
|
-
userMessage: `Field '${
|
|
668
|
-
systemMessage: `No field with ID '${
|
|
669
|
-
value:
|
|
666
|
+
l.push({
|
|
667
|
+
fieldId: u,
|
|
668
|
+
userMessage: `Field '${u}' not found`,
|
|
669
|
+
systemMessage: `No field with ID '${u}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
670
|
+
value: p
|
|
670
671
|
});
|
|
671
672
|
return;
|
|
672
673
|
}
|
|
673
|
-
if (h.multiple && (typeof
|
|
674
|
-
const
|
|
675
|
-
$input:
|
|
674
|
+
if (h.multiple && (typeof p == "string" || typeof p == "number" || typeof p == "boolean") && (p = [p]), h.validation && !de(h.validation) && !U(p)) {
|
|
675
|
+
const S = await A(t, h.validation, {
|
|
676
|
+
$input: p
|
|
676
677
|
});
|
|
677
|
-
if (typeof
|
|
678
|
-
|
|
679
|
-
fieldId:
|
|
680
|
-
userMessage:
|
|
681
|
-
systemMessage: `Field validation resulted in an error: ${
|
|
682
|
-
value:
|
|
678
|
+
if (typeof S == "string") {
|
|
679
|
+
l.push({
|
|
680
|
+
fieldId: u,
|
|
681
|
+
userMessage: S,
|
|
682
|
+
systemMessage: `Field validation resulted in an error: ${S}.`,
|
|
683
|
+
value: p
|
|
683
684
|
});
|
|
684
685
|
return;
|
|
685
686
|
}
|
|
686
|
-
if (
|
|
687
|
-
|
|
688
|
-
fieldId:
|
|
687
|
+
if (S === !1) {
|
|
688
|
+
l.push({
|
|
689
|
+
fieldId: u,
|
|
689
690
|
userMessage: "This field is invalid",
|
|
690
691
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
691
|
-
value:
|
|
692
|
+
value: p
|
|
692
693
|
});
|
|
693
694
|
return;
|
|
694
695
|
}
|
|
695
696
|
}
|
|
696
|
-
if (h.required &&
|
|
697
|
-
|
|
698
|
-
fieldId:
|
|
697
|
+
if (h.required && U(p)) {
|
|
698
|
+
l.push({
|
|
699
|
+
fieldId: u,
|
|
699
700
|
userMessage: "This field is required",
|
|
700
701
|
systemMessage: "Field is required.",
|
|
701
|
-
value:
|
|
702
|
+
value: p
|
|
702
703
|
});
|
|
703
704
|
return;
|
|
704
705
|
}
|
|
705
|
-
if (!h.multiple && Array.isArray(
|
|
706
|
-
|
|
707
|
-
fieldId:
|
|
706
|
+
if (!h.multiple && Array.isArray(p) && p.length > 1) {
|
|
707
|
+
l.push({
|
|
708
|
+
fieldId: u,
|
|
708
709
|
userMessage: "This field expects a single response",
|
|
709
710
|
systemMessage: "Field expects a single response.",
|
|
710
|
-
value:
|
|
711
|
+
value: p
|
|
711
712
|
});
|
|
712
713
|
return;
|
|
713
714
|
}
|
|
714
|
-
if (h.type === "object" && !
|
|
715
|
+
if (h.type === "object" && !U(p))
|
|
715
716
|
if (h.multiple) {
|
|
716
|
-
if (!Array.isArray(
|
|
717
|
-
|
|
718
|
-
fieldId:
|
|
717
|
+
if (!Array.isArray(p)) {
|
|
718
|
+
l.push({
|
|
719
|
+
fieldId: u,
|
|
719
720
|
userMessage: "This field expects multiple values",
|
|
720
721
|
systemMessage: "Field expects an array of objects.",
|
|
721
|
-
value:
|
|
722
|
+
value: p
|
|
722
723
|
});
|
|
723
724
|
return;
|
|
724
725
|
}
|
|
725
|
-
for (const
|
|
726
|
-
if (typeof
|
|
727
|
-
|
|
728
|
-
fieldId:
|
|
726
|
+
for (const S of p) {
|
|
727
|
+
if (typeof S != "object" || S === null) {
|
|
728
|
+
l.push({
|
|
729
|
+
fieldId: u,
|
|
729
730
|
userMessage: "This field expects object values",
|
|
730
731
|
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
731
|
-
value:
|
|
732
|
+
value: p
|
|
732
733
|
});
|
|
733
734
|
return;
|
|
734
735
|
}
|
|
735
|
-
if (!
|
|
736
|
-
|
|
737
|
-
fieldId:
|
|
736
|
+
if (!W(S)) {
|
|
737
|
+
l.push({
|
|
738
|
+
fieldId: u,
|
|
738
739
|
userMessage: "This field contains non-serializable data",
|
|
739
740
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
740
|
-
value:
|
|
741
|
+
value: p
|
|
741
742
|
});
|
|
742
743
|
return;
|
|
743
744
|
}
|
|
744
745
|
}
|
|
745
746
|
} else {
|
|
746
|
-
if (Array.isArray(
|
|
747
|
-
|
|
748
|
-
fieldId:
|
|
747
|
+
if (Array.isArray(p)) {
|
|
748
|
+
l.push({
|
|
749
|
+
fieldId: u,
|
|
749
750
|
userMessage: "This field expects a single value",
|
|
750
751
|
systemMessage: "Field expects a single object, not an array.",
|
|
751
|
-
value:
|
|
752
|
+
value: p
|
|
752
753
|
});
|
|
753
754
|
return;
|
|
754
755
|
}
|
|
755
|
-
if (typeof
|
|
756
|
-
|
|
757
|
-
fieldId:
|
|
756
|
+
if (typeof p != "object" || p === null) {
|
|
757
|
+
l.push({
|
|
758
|
+
fieldId: u,
|
|
758
759
|
userMessage: "This field expects an object value",
|
|
759
760
|
systemMessage: "Field expects an object value.",
|
|
760
|
-
value:
|
|
761
|
+
value: p
|
|
761
762
|
});
|
|
762
763
|
return;
|
|
763
764
|
}
|
|
764
|
-
if (!
|
|
765
|
-
|
|
766
|
-
fieldId:
|
|
765
|
+
if (!W(p)) {
|
|
766
|
+
l.push({
|
|
767
|
+
fieldId: u,
|
|
767
768
|
userMessage: "This field contains non-serializable data",
|
|
768
769
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
769
|
-
value:
|
|
770
|
+
value: p
|
|
770
771
|
});
|
|
771
772
|
return;
|
|
772
773
|
}
|
|
773
774
|
}
|
|
774
775
|
if (Array.isArray(h.options) && h.options.length > 0) {
|
|
775
|
-
const
|
|
776
|
+
const S = Array.isArray(p) ? p : [p];
|
|
776
777
|
if (h.type === "object") {
|
|
777
|
-
const
|
|
778
|
-
|
|
779
|
-
fieldId:
|
|
778
|
+
const E = h.options.map((v) => JSON.stringify(v.value));
|
|
779
|
+
S.every((v) => E.includes(JSON.stringify(v))) || l.push({
|
|
780
|
+
fieldId: u,
|
|
780
781
|
userMessage: "This field expects a valid option",
|
|
781
782
|
systemMessage: "Field expects a valid option from the defined choices.",
|
|
782
|
-
value:
|
|
783
|
+
value: p
|
|
783
784
|
});
|
|
784
785
|
} else {
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
fieldId:
|
|
786
|
+
const E = h.options.map((v) => v.value);
|
|
787
|
+
S.every((v) => !Qe(v) || v === null ? !1 : E.includes(v)) || l.push({
|
|
788
|
+
fieldId: u,
|
|
788
789
|
userMessage: "This field expects a valid option",
|
|
789
|
-
systemMessage: `Field expects a valid option. Valid options are: ${
|
|
790
|
-
value:
|
|
790
|
+
systemMessage: `Field expects a valid option. Valid options are: ${E.join(", ")}`,
|
|
791
|
+
value: p
|
|
791
792
|
});
|
|
792
793
|
}
|
|
793
794
|
}
|
|
794
795
|
})
|
|
795
|
-
), { responsesToCommit:
|
|
796
|
+
), { responsesToCommit: d, validationErrors: l };
|
|
796
797
|
}
|
|
797
|
-
async function
|
|
798
|
-
const { responsesToCommit:
|
|
799
|
-
return
|
|
798
|
+
async function a(d) {
|
|
799
|
+
const { responsesToCommit: l, validationErrors: u } = await i(d);
|
|
800
|
+
return u.length ? { errors: u } : (n.registerBatch(l), { errors: [] });
|
|
800
801
|
}
|
|
801
|
-
const
|
|
802
|
-
fieldId:
|
|
803
|
-
value:
|
|
802
|
+
const o = e.map((d) => d), c = e.map((d) => Object.keys(d).map((u) => ({
|
|
803
|
+
fieldId: u,
|
|
804
|
+
value: d[u]
|
|
804
805
|
})));
|
|
805
|
-
function g(
|
|
806
|
-
const
|
|
807
|
-
return
|
|
806
|
+
function g(d) {
|
|
807
|
+
const l = t.fields.getByKey(d), u = e.map((m) => m[d] || null);
|
|
808
|
+
return V({ f: l, r: u }, ({ f: m, r: p }) => p || (m?.defaultValue ? m.defaultValue : null));
|
|
808
809
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
810
|
+
const y = g;
|
|
811
|
+
function F(d) {
|
|
812
|
+
const l = t.fields.getByName(d);
|
|
813
|
+
return V({ f: l, s: e }, ({ f: u, s: m }) => {
|
|
814
|
+
const p = u && m[u.key] || null;
|
|
815
|
+
return p || (u?.defaultValue ? u.defaultValue : null);
|
|
814
816
|
});
|
|
815
817
|
}
|
|
816
818
|
return k({
|
|
@@ -820,22 +822,24 @@ const Ze = x("response"), et = b(({ client: t }) => {
|
|
|
820
822
|
clock: s,
|
|
821
823
|
target: n.clear
|
|
822
824
|
}), {
|
|
823
|
-
register:
|
|
825
|
+
register: f,
|
|
824
826
|
clearAll: r,
|
|
825
827
|
clear: s,
|
|
826
|
-
commit:
|
|
827
|
-
getResponsesToCommit:
|
|
828
|
-
listStore:
|
|
829
|
-
getAllStore:
|
|
830
|
-
|
|
831
|
-
|
|
828
|
+
commit: a,
|
|
829
|
+
getResponsesToCommit: i,
|
|
830
|
+
listStore: c,
|
|
831
|
+
getAllStore: o,
|
|
832
|
+
getByFieldKey: g,
|
|
833
|
+
// eslint-disable-next-line sonarjs/deprecation -- exposing deprecated alias for backwards compatibility
|
|
834
|
+
getByFieldId: y,
|
|
835
|
+
getByFieldName: F
|
|
832
836
|
};
|
|
833
837
|
});
|
|
834
|
-
function
|
|
835
|
-
return I(
|
|
838
|
+
function et(t) {
|
|
839
|
+
return I(Ze, t);
|
|
836
840
|
}
|
|
837
|
-
function
|
|
838
|
-
if (
|
|
841
|
+
function tt() {
|
|
842
|
+
if (_()) {
|
|
839
843
|
const t = [
|
|
840
844
|
document.currentScript,
|
|
841
845
|
document.getElementById("picked_script"),
|
|
@@ -849,34 +853,34 @@ function rt() {
|
|
|
849
853
|
}
|
|
850
854
|
return "https://api.picked.app";
|
|
851
855
|
}
|
|
852
|
-
function
|
|
853
|
-
if (!
|
|
856
|
+
function rt() {
|
|
857
|
+
if (!H())
|
|
854
858
|
return {};
|
|
855
859
|
const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
|
|
856
860
|
for (const [n] of t.entries())
|
|
857
861
|
n.startsWith("picked-") && r.add(n);
|
|
858
862
|
for (const n of r) {
|
|
859
|
-
const
|
|
860
|
-
e[
|
|
863
|
+
const f = n.replace("picked-", "");
|
|
864
|
+
e[f] = t.getAll(n);
|
|
861
865
|
}
|
|
862
|
-
const s =
|
|
866
|
+
const s = $("s");
|
|
863
867
|
if (r.size > 0)
|
|
864
|
-
|
|
868
|
+
M.set(s, e);
|
|
865
869
|
else {
|
|
866
|
-
const n =
|
|
870
|
+
const n = M.get(s);
|
|
867
871
|
if (n)
|
|
868
872
|
return n.json() || {};
|
|
869
873
|
}
|
|
870
874
|
return e;
|
|
871
875
|
}
|
|
872
|
-
function
|
|
873
|
-
if (
|
|
876
|
+
function st() {
|
|
877
|
+
if (pe())
|
|
874
878
|
return crypto.randomUUID();
|
|
875
879
|
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);
|
|
876
880
|
return `${t}-${e}-${r}-${s}`;
|
|
877
881
|
}
|
|
878
|
-
const
|
|
879
|
-
const t =
|
|
882
|
+
const nt = $("session", "global"), it = () => {
|
|
883
|
+
const t = O.get(nt);
|
|
880
884
|
let e;
|
|
881
885
|
t.isSet() && (e = t.json());
|
|
882
886
|
const r = (n) => t.set({
|
|
@@ -884,35 +888,35 @@ const it = A("session", "global"), ot = () => {
|
|
|
884
888
|
isUser: n.isUser,
|
|
885
889
|
identifiers: n.identifiers
|
|
886
890
|
}), s = {
|
|
887
|
-
id: e?.id ??
|
|
891
|
+
id: e?.id ?? st(),
|
|
888
892
|
isUser: e?.isUser ?? void 0,
|
|
889
893
|
identifiers: e?.identifiers ?? void 0,
|
|
890
894
|
setIsUser(n) {
|
|
891
895
|
this.isUser = n, r(this);
|
|
892
896
|
},
|
|
893
|
-
setIdentifier(n,
|
|
894
|
-
this.identifiers = { ...this.identifiers, [n]:
|
|
897
|
+
setIdentifier(n, f) {
|
|
898
|
+
this.identifiers = { ...this.identifiers, [n]: f }, r(this);
|
|
895
899
|
},
|
|
896
900
|
removeIdentifier(n) {
|
|
897
901
|
this.identifiers && (this.identifiers = Object.fromEntries(
|
|
898
|
-
Object.entries(this.identifiers).filter(([
|
|
902
|
+
Object.entries(this.identifiers).filter(([f]) => f !== n)
|
|
899
903
|
), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
|
|
900
904
|
}
|
|
901
905
|
};
|
|
902
906
|
return r(s), s;
|
|
903
|
-
},
|
|
904
|
-
function
|
|
905
|
-
if (
|
|
907
|
+
}, ot = () => le() ? it() : null;
|
|
908
|
+
function at() {
|
|
909
|
+
if (H())
|
|
906
910
|
return globalThis.window.pickedConfig;
|
|
907
911
|
}
|
|
908
|
-
function
|
|
909
|
-
if (!
|
|
912
|
+
function ct() {
|
|
913
|
+
if (!H())
|
|
910
914
|
return;
|
|
911
|
-
const t =
|
|
915
|
+
const t = at(), e = t?.organizationId, r = t?.projectId;
|
|
912
916
|
return e && r ? { organizationId: e, projectId: r } : void 0;
|
|
913
917
|
}
|
|
914
|
-
function
|
|
915
|
-
if (!
|
|
918
|
+
function ut() {
|
|
919
|
+
if (!_())
|
|
916
920
|
return;
|
|
917
921
|
const t = document.getElementById("picked_script") || document.querySelector("script#picked") || // legacy support for 'cvly' script tag
|
|
918
922
|
document.getElementById("cvly");
|
|
@@ -921,14 +925,14 @@ function dt() {
|
|
|
921
925
|
const e = t.dataset.organizationid || t.getAttribute("organization-id"), r = t.dataset.projectid || t.getAttribute("project-id");
|
|
922
926
|
return e && r ? { organizationId: e, projectId: r } : void 0;
|
|
923
927
|
}
|
|
924
|
-
function
|
|
928
|
+
function dt(t) {
|
|
925
929
|
const { organizationId: e, projectId: r } = t;
|
|
926
930
|
if (e && r)
|
|
927
931
|
return { organizationId: e, projectId: r };
|
|
928
|
-
const s =
|
|
932
|
+
const s = ct();
|
|
929
933
|
if (s)
|
|
930
934
|
return s;
|
|
931
|
-
const n =
|
|
935
|
+
const n = ut();
|
|
932
936
|
if (n)
|
|
933
937
|
return n;
|
|
934
938
|
throw new Error(
|
|
@@ -938,13 +942,13 @@ function lt(t) {
|
|
|
938
942
|
(3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
|
|
939
943
|
);
|
|
940
944
|
}
|
|
941
|
-
function
|
|
945
|
+
function C(t) {
|
|
942
946
|
return t == null || t === "" || Number.isNaN(t);
|
|
943
947
|
}
|
|
944
|
-
const
|
|
945
|
-
default: (t, e) =>
|
|
946
|
-
append: (t, e) => e && !
|
|
947
|
-
prepend: (t, e) => e && !
|
|
948
|
+
const lt = {
|
|
949
|
+
default: (t, e) => C(t) ? String(e ?? "") : String(t),
|
|
950
|
+
append: (t, e) => e && !C(t) ? `${t} ${e}` : t,
|
|
951
|
+
prepend: (t, e) => e && !C(t) ? `${e} ${t}` : t,
|
|
948
952
|
upper: (t) => typeof t == "string" ? t.toUpperCase() : t,
|
|
949
953
|
lower: (t) => typeof t == "string" ? t.toLowerCase() : t,
|
|
950
954
|
capitalize: (t) => typeof t == "string" ? t.charAt(0).toUpperCase() + t.slice(1) : t,
|
|
@@ -961,28 +965,28 @@ const pt = {
|
|
|
961
965
|
return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
|
|
962
966
|
}
|
|
963
967
|
};
|
|
964
|
-
function
|
|
968
|
+
function pt(t) {
|
|
965
969
|
return typeof t == "object" && t !== null;
|
|
966
970
|
}
|
|
967
|
-
function
|
|
971
|
+
function ft(t, e) {
|
|
968
972
|
let r = e;
|
|
969
973
|
for (const s of t.split("."))
|
|
970
|
-
if (
|
|
974
|
+
if (pt(r) && s in r)
|
|
971
975
|
r = r[s];
|
|
972
976
|
else
|
|
973
977
|
return;
|
|
974
978
|
return typeof r == "function" ? r() : r;
|
|
975
979
|
}
|
|
976
|
-
function
|
|
977
|
-
const r = t.split("|").map((
|
|
978
|
-
let n =
|
|
979
|
-
for (const
|
|
980
|
-
const [
|
|
981
|
-
g && (n = g(n,
|
|
980
|
+
function gt(t, e) {
|
|
981
|
+
const r = t.split("|").map((f) => f.trim()), s = r.shift() ?? "";
|
|
982
|
+
let n = ft(s, e);
|
|
983
|
+
for (const f of r) {
|
|
984
|
+
const [i, ...a] = f.split(":"), o = i?.trim() ?? "", c = a.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), g = lt[o];
|
|
985
|
+
g && (n = g(n, c));
|
|
982
986
|
}
|
|
983
|
-
return
|
|
987
|
+
return C(n) ? "" : typeof n == "object" ? JSON.stringify(n) : String(n);
|
|
984
988
|
}
|
|
985
|
-
function
|
|
989
|
+
function mt(t, e) {
|
|
986
990
|
let r = "", s = 0;
|
|
987
991
|
for (; s < t.length; )
|
|
988
992
|
if (t[s] === "{" && t[s + 1] === "{") {
|
|
@@ -995,19 +999,19 @@ function ht(t, e) {
|
|
|
995
999
|
}
|
|
996
1000
|
n += t[s++];
|
|
997
1001
|
}
|
|
998
|
-
r +=
|
|
1002
|
+
r += gt(n.trim(), e);
|
|
999
1003
|
} else
|
|
1000
1004
|
r += t[s++];
|
|
1001
1005
|
return r;
|
|
1002
1006
|
}
|
|
1003
|
-
class
|
|
1007
|
+
class ht {
|
|
1004
1008
|
static logger = w;
|
|
1005
1009
|
options;
|
|
1006
1010
|
isReady = !1;
|
|
1007
1011
|
project;
|
|
1008
1012
|
plugins = {};
|
|
1009
1013
|
pluginStartHooks = [];
|
|
1010
|
-
eventBus =
|
|
1014
|
+
eventBus = N();
|
|
1011
1015
|
events;
|
|
1012
1016
|
organizationId;
|
|
1013
1017
|
projectId;
|
|
@@ -1018,25 +1022,25 @@ class yt {
|
|
|
1018
1022
|
precondition;
|
|
1019
1023
|
condition;
|
|
1020
1024
|
preconditionPassed;
|
|
1021
|
-
searchParams =
|
|
1022
|
-
history =
|
|
1023
|
-
components =
|
|
1025
|
+
searchParams = rt();
|
|
1026
|
+
history = Ne();
|
|
1027
|
+
components = Fe({ client: this });
|
|
1024
1028
|
experienceInstances = ie({ client: this });
|
|
1025
|
-
experiences =
|
|
1026
|
-
frameworks =
|
|
1027
|
-
predicates =
|
|
1028
|
-
features =
|
|
1029
|
-
responses =
|
|
1030
|
-
fields =
|
|
1031
|
-
actions =
|
|
1029
|
+
experiences = ye({ client: this });
|
|
1030
|
+
frameworks = Ee({ client: this });
|
|
1031
|
+
predicates = Ce({ client: this });
|
|
1032
|
+
features = Ue({ client: this });
|
|
1033
|
+
responses = et({ client: this });
|
|
1034
|
+
fields = Ke();
|
|
1035
|
+
actions = We();
|
|
1032
1036
|
constructor(e) {
|
|
1033
|
-
w("info", "Picked client initializing."), this.events =
|
|
1034
|
-
const { organizationId: r, projectId: s } =
|
|
1035
|
-
this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl ||
|
|
1037
|
+
w("info", "Picked client initializing."), this.events = Le(this.eventBus);
|
|
1038
|
+
const { organizationId: r, projectId: s } = dt(e);
|
|
1039
|
+
this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: ce() }), w("info", "Picked client initialized.");
|
|
1036
1040
|
}
|
|
1037
1041
|
start = () => {
|
|
1038
|
-
|
|
1039
|
-
if (!
|
|
1042
|
+
Be(this), (async () => {
|
|
1043
|
+
if (!_())
|
|
1040
1044
|
return;
|
|
1041
1045
|
await this.runPluginStartHooks();
|
|
1042
1046
|
const r = await this.evaluateGate(this.precondition);
|
|
@@ -1045,42 +1049,42 @@ class yt {
|
|
|
1045
1049
|
r && (s = await this.evaluateGate(this.condition));
|
|
1046
1050
|
const n = r && s === !0;
|
|
1047
1051
|
if (typeof s == "boolean" && this.session) {
|
|
1048
|
-
const
|
|
1049
|
-
this.session.setIsUser(
|
|
1052
|
+
const f = s;
|
|
1053
|
+
this.session.setIsUser(f), this.eventBus({ type: "user_decide", value: f });
|
|
1050
1054
|
}
|
|
1051
|
-
if (this.eventBus({ type: "initialize" }), n &&
|
|
1052
|
-
const { id:
|
|
1053
|
-
this.eventBus({ type: "session", id:
|
|
1055
|
+
if (this.eventBus({ type: "initialize" }), n && K(this), await oe(), n && K(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1056
|
+
const { id: f, isUser: i, identifiers: a } = this.session;
|
|
1057
|
+
this.eventBus({ type: "session", id: f, isUser: i, identifiers: a });
|
|
1054
1058
|
}
|
|
1055
1059
|
})();
|
|
1056
1060
|
};
|
|
1057
1061
|
registerFramework = (e) => {
|
|
1058
|
-
|
|
1062
|
+
Pe(e, this.frameworks);
|
|
1059
1063
|
};
|
|
1060
1064
|
registerComponent = (e, r) => {
|
|
1061
|
-
|
|
1065
|
+
G(e, r, this.components);
|
|
1062
1066
|
};
|
|
1063
1067
|
registerPlugin = (e) => {
|
|
1064
|
-
|
|
1068
|
+
ve(this, e, this.plugins);
|
|
1065
1069
|
const r = this.plugins[e.name];
|
|
1066
1070
|
r?.onStart && this.pluginStartHooks.push(r.onStart);
|
|
1067
1071
|
};
|
|
1068
1072
|
registerFeature = (e, r) => {
|
|
1069
|
-
|
|
1073
|
+
De(e, r, this.features);
|
|
1070
1074
|
};
|
|
1071
1075
|
registerPredicate = (e, r) => {
|
|
1072
|
-
|
|
1076
|
+
Oe(e, r, this.predicates);
|
|
1073
1077
|
};
|
|
1074
1078
|
registerField = (e) => {
|
|
1075
|
-
|
|
1079
|
+
Ge(e, this.fields);
|
|
1076
1080
|
};
|
|
1077
1081
|
registerAction = (e, r) => {
|
|
1078
|
-
|
|
1082
|
+
Ye(e, r, this.actions);
|
|
1079
1083
|
};
|
|
1080
1084
|
registerExperience = (e) => {
|
|
1081
|
-
e.component &&
|
|
1085
|
+
e.component && G(`experience:${e.id}`, e.component, this.components), Se(e, this.experiences);
|
|
1082
1086
|
};
|
|
1083
|
-
getStateSnapshot = () =>
|
|
1087
|
+
getStateSnapshot = () => Z(this);
|
|
1084
1088
|
/** @deprecated Use `client.experiences.launch({ id: experienceId })` instead. */
|
|
1085
1089
|
launchExperienceById = async (e, r) => {
|
|
1086
1090
|
this.experiences.launch({ id: e, options: r });
|
|
@@ -1094,7 +1098,7 @@ class yt {
|
|
|
1094
1098
|
await e();
|
|
1095
1099
|
}
|
|
1096
1100
|
async evaluateGate(e) {
|
|
1097
|
-
return e === void 0 ? !0 : typeof e == "boolean" ? e : await
|
|
1101
|
+
return e === void 0 ? !0 : typeof e == "boolean" ? e : await A(this, e) === !0;
|
|
1098
1102
|
}
|
|
1099
1103
|
setupPlugins() {
|
|
1100
1104
|
this.options.plugins?.forEach((e) => {
|
|
@@ -1122,13 +1126,13 @@ class yt {
|
|
|
1122
1126
|
const [s, n] = r.split(":");
|
|
1123
1127
|
if (!s || !n)
|
|
1124
1128
|
return;
|
|
1125
|
-
let
|
|
1126
|
-
|
|
1127
|
-
key: `${
|
|
1129
|
+
let f = n;
|
|
1130
|
+
f === "true" && (f = !0), f === "false" && (f = !1), this.registerFeature(s, {
|
|
1131
|
+
key: `${f}`,
|
|
1128
1132
|
// use the assigned bucket value as the key
|
|
1129
1133
|
name: s,
|
|
1130
1134
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
1131
|
-
decide: () =>
|
|
1135
|
+
decide: () => f,
|
|
1132
1136
|
storage: "session"
|
|
1133
1137
|
});
|
|
1134
1138
|
} catch {
|
|
@@ -1205,68 +1209,68 @@ class yt {
|
|
|
1205
1209
|
* // => "Fruits: apple, banana, and cherry"
|
|
1206
1210
|
*/
|
|
1207
1211
|
renderString = (e, r) => {
|
|
1208
|
-
const s = this.responses.listStore.getState().reduce((n,
|
|
1209
|
-
return
|
|
1212
|
+
const s = this.responses.listStore.getState().reduce((n, f) => (n[f.fieldId] = f.value, n), {});
|
|
1213
|
+
return mt(e, {
|
|
1210
1214
|
...r,
|
|
1211
1215
|
responses: s
|
|
1212
1216
|
});
|
|
1213
1217
|
};
|
|
1214
1218
|
}
|
|
1215
|
-
function
|
|
1219
|
+
function ee(t) {
|
|
1216
1220
|
return t.options?.some((e) => "condition" in e) ?? !1;
|
|
1217
1221
|
}
|
|
1218
|
-
function
|
|
1219
|
-
return t.some((e) => e.condition ||
|
|
1222
|
+
function yt(t) {
|
|
1223
|
+
return t.some((e) => e.condition || ee(e));
|
|
1220
1224
|
}
|
|
1221
|
-
async function
|
|
1222
|
-
return e.length === 0 || !
|
|
1225
|
+
async function Et(t, e) {
|
|
1226
|
+
return e.length === 0 || !yt(e) ? e : (await Promise.all(
|
|
1223
1227
|
e.map(async (s) => {
|
|
1224
|
-
if (!(s.condition ? await
|
|
1228
|
+
if (!(s.condition ? await A(t, s.condition) : !0))
|
|
1225
1229
|
return null;
|
|
1226
|
-
if (!s.options || !
|
|
1230
|
+
if (!s.options || !ee(s))
|
|
1227
1231
|
return s;
|
|
1228
|
-
const
|
|
1229
|
-
s.options.map(async (
|
|
1230
|
-
)).filter((
|
|
1231
|
-
return
|
|
1232
|
+
const i = (await Promise.all(
|
|
1233
|
+
s.options.map(async (o) => o.condition ? await A(t, o.condition) ? o : null : o)
|
|
1234
|
+
)).filter((o) => o !== null);
|
|
1235
|
+
return i.length === s.options.length ? s : i.length === 0 ? null : { ...s, options: i };
|
|
1232
1236
|
})
|
|
1233
1237
|
)).filter((s) => s !== null);
|
|
1234
1238
|
}
|
|
1235
|
-
function
|
|
1239
|
+
function Pt(t) {
|
|
1236
1240
|
return {
|
|
1237
1241
|
$$type: "lazy-component",
|
|
1238
1242
|
load: t
|
|
1239
1243
|
};
|
|
1240
1244
|
}
|
|
1241
|
-
function
|
|
1245
|
+
function At(t) {
|
|
1242
1246
|
return typeof t == "object" && t !== null && "$$type" in t && t.$$type === "lazy-component";
|
|
1243
1247
|
}
|
|
1244
|
-
const
|
|
1245
|
-
const e = new
|
|
1246
|
-
return
|
|
1248
|
+
const $t = (t) => {
|
|
1249
|
+
const e = new ht(t);
|
|
1250
|
+
return fe(e), e;
|
|
1247
1251
|
};
|
|
1248
1252
|
export {
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1253
|
+
ht as Picked,
|
|
1254
|
+
$t as createClient,
|
|
1255
|
+
$ as createStorageKey,
|
|
1256
|
+
A as evaluateRuleLogic,
|
|
1257
|
+
at as getPickedConfig,
|
|
1258
|
+
Et as getStepFields,
|
|
1259
|
+
At as isLazyLoader,
|
|
1260
|
+
zt as isPickedRoot,
|
|
1261
|
+
Pt as lazyComponent,
|
|
1262
|
+
O as localStore,
|
|
1263
|
+
M as sessionStore,
|
|
1264
|
+
Ot as subscribe,
|
|
1265
|
+
Ut as supportsCookies,
|
|
1266
|
+
pe as supportsCryptoRandomUUID,
|
|
1267
|
+
_ as supportsDocument,
|
|
1268
|
+
Dt as supportsHistory,
|
|
1269
|
+
Vt as supportsIntersectionObserver,
|
|
1270
|
+
le as supportsLocalStorage,
|
|
1271
|
+
Nt as supportsLocation,
|
|
1272
|
+
Tt as supportsSessionStorage,
|
|
1273
|
+
Lt as supportsShadowRoot,
|
|
1274
|
+
_t as supportsWebComponents,
|
|
1275
|
+
H as supportsWindow
|
|
1272
1276
|
};
|