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