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