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