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