@picked/client 0.0.1-dev.1764637043885 → 0.0.1-dev.1764694362099
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 +1 -1
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +322 -332
- package/dist/esm/plugins/create-experience/index.js +121 -123
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +8 -8
- package/dist/esm/plugins/responses-browser-storage/index.js +6 -6
- package/dist/esm/plugins/responses-indexeddb/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-DjjpHk0t.cjs → experience-instance-BpQMqclI.cjs} +1 -1
- package/dist/{experience-instance-C4INDX6a.js → experience-instance-CMrX6QA2.js} +1 -1
- package/dist/types/client.d.ts +0 -31
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +1 -3
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/picked.d.ts +10 -13
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +1 -5
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +7 -8
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/user-session.d.ts +1 -5
- package/dist/types/utils/user-session.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
var Y = Object.defineProperty;
|
|
2
2
|
var J = (t, e, r) => e in t ? Y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var m = (t, e, r) => J(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { createDomain as
|
|
5
|
-
import { createFactory as
|
|
6
|
-
import { g as
|
|
7
|
-
import { f as
|
|
8
|
-
import { l as
|
|
9
|
-
import { c as
|
|
10
|
-
import { a as
|
|
4
|
+
import { createDomain as b, createApi as I, createEffect as M, attach as Q, sample as x, combine as O, createEvent as C } from "effector";
|
|
5
|
+
import { createFactory as v, invoke as w } from "@withease/factories";
|
|
6
|
+
import { g as _, t as X, c as Z, i as ee, e as $, a as te, b as re, d as se } from "../experience-instance-CMrX6QA2.js";
|
|
7
|
+
import { f as kt } from "../experience-instance-CMrX6QA2.js";
|
|
8
|
+
import { l as k } from "../logger-C9a75KZn.js";
|
|
9
|
+
import { c as R, s as j, l as D } from "../storage-Cb_71y48.js";
|
|
10
|
+
import { a as wt } from "../storage-Cb_71y48.js";
|
|
11
11
|
import { g as ne } from "../id-BW-g3y32.js";
|
|
12
|
-
import { i as
|
|
13
|
-
import { s as H, a as
|
|
14
|
-
import { h as
|
|
15
|
-
const K =
|
|
12
|
+
import { i as oe } from "../object-JwZ58NOH.js";
|
|
13
|
+
import { s as H, a as ie, b as ae, c as ce, d as ue } from "../supports-BjhuLJ8z.js";
|
|
14
|
+
import { h as bt, f as It, j as xt, e as Et, g as Pt, i as Rt, k as Bt } from "../supports-BjhuLJ8z.js";
|
|
15
|
+
const K = b("experience"), le = v(
|
|
16
16
|
({ client: t, experience: e }) => {
|
|
17
|
-
const r = K.store(e), n =
|
|
18
|
-
merge(
|
|
17
|
+
const r = K.store(e), n = I(r, {
|
|
18
|
+
merge(l, h) {
|
|
19
19
|
return {
|
|
20
|
-
...
|
|
20
|
+
...l,
|
|
21
21
|
...h.experience
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
}),
|
|
25
|
-
name:
|
|
26
|
-
decisionLogic:
|
|
27
|
-
targetSelectors:
|
|
24
|
+
}), c = r.map((l) => ({
|
|
25
|
+
name: l.name,
|
|
26
|
+
decisionLogic: l.decide,
|
|
27
|
+
targetSelectors: l.targets,
|
|
28
28
|
initializeOpenLogic: e.initializeOpen
|
|
29
|
-
})),
|
|
30
|
-
(
|
|
29
|
+
})), u = t.components.listStore.map(
|
|
30
|
+
(l) => l.find((h) => h.name === `experience:${e.id}`) || l.find((h) => h.name === "experience"),
|
|
31
31
|
{ skipVoid: !1 }
|
|
32
|
-
), s = r.map((
|
|
33
|
-
steps:
|
|
34
|
-
nodes:
|
|
35
|
-
edges:
|
|
36
|
-
conditionals:
|
|
37
|
-
})),
|
|
32
|
+
), s = r.map((l) => ({
|
|
33
|
+
steps: l.steps,
|
|
34
|
+
nodes: l.nodes,
|
|
35
|
+
edges: l.edges,
|
|
36
|
+
conditionals: l.conditionals
|
|
37
|
+
})), o = e.actions ?? [];
|
|
38
38
|
return {
|
|
39
39
|
id: e.id,
|
|
40
|
-
configStore:
|
|
40
|
+
configStore: c,
|
|
41
41
|
treeStore: s,
|
|
42
|
-
componentStore:
|
|
43
|
-
actions:
|
|
42
|
+
componentStore: u,
|
|
43
|
+
actions: o,
|
|
44
44
|
merge: n.merge
|
|
45
45
|
};
|
|
46
46
|
}
|
|
@@ -48,32 +48,32 @@ const K = F("experience"), le = k(
|
|
|
48
48
|
function de(t) {
|
|
49
49
|
return w(le, t);
|
|
50
50
|
}
|
|
51
|
-
const pe =
|
|
52
|
-
const e = K.store({}), r =
|
|
53
|
-
register(s,
|
|
51
|
+
const pe = v(({ client: t }) => {
|
|
52
|
+
const e = K.store({}), r = I(e, {
|
|
53
|
+
register(s, o) {
|
|
54
54
|
return {
|
|
55
55
|
...s,
|
|
56
|
-
[
|
|
56
|
+
[o.id]: o
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
function n(s) {
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
61
|
+
const o = e.getState()[s.id];
|
|
62
|
+
if (o) {
|
|
63
|
+
o.merge({ experience: s, strategy: "override" });
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
r.register(
|
|
66
|
+
const l = de({ client: t, experience: s });
|
|
67
|
+
r.register(l);
|
|
68
68
|
}
|
|
69
|
-
const
|
|
70
|
-
function
|
|
71
|
-
return e.map((
|
|
69
|
+
const c = e.map((s) => Object.values(s));
|
|
70
|
+
function u(s) {
|
|
71
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
72
72
|
}
|
|
73
73
|
return {
|
|
74
74
|
register: n,
|
|
75
|
-
getById:
|
|
76
|
-
listStore:
|
|
75
|
+
getById: u,
|
|
76
|
+
listStore: c
|
|
77
77
|
};
|
|
78
78
|
});
|
|
79
79
|
function ge(t) {
|
|
@@ -82,13 +82,13 @@ function ge(t) {
|
|
|
82
82
|
const fe = (t, e) => {
|
|
83
83
|
e.register(t);
|
|
84
84
|
}, q = (t, e) => {
|
|
85
|
-
const { targetSelectors: r } = e.configStore.getState(), n =
|
|
85
|
+
const { targetSelectors: r } = e.configStore.getState(), n = _(r, e.id);
|
|
86
86
|
n.forEach(
|
|
87
|
-
({ elements:
|
|
88
|
-
), Z(n, e.id).forEach((
|
|
89
|
-
t.experienceInstances.spawn(e,
|
|
87
|
+
({ elements: u }) => u.forEach((s) => X(s, e.id))
|
|
88
|
+
), Z(n, e.id).forEach((u) => {
|
|
89
|
+
t.experienceInstances.spawn(e, u);
|
|
90
90
|
});
|
|
91
|
-
},
|
|
91
|
+
}, V = async (t) => {
|
|
92
92
|
await Promise.all(
|
|
93
93
|
t.experiences.listStore.getState().map(async (e) => {
|
|
94
94
|
await me(t, e) && q(t, e);
|
|
@@ -96,14 +96,14 @@ const fe = (t, e) => {
|
|
|
96
96
|
);
|
|
97
97
|
}, me = async (t, e) => {
|
|
98
98
|
const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
|
|
99
|
-
return
|
|
99
|
+
return _(n, e.id).length < 1 || n.length === 0 ? !1 : r && ee(r) ? await $(t, r) === !0 : !0;
|
|
100
100
|
}, he = (t, e, r) => {
|
|
101
|
-
const n = e.name,
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
r[n] = Object.freeze({ ...
|
|
101
|
+
const n = e.name, c = e.setup(t);
|
|
102
|
+
if (c) {
|
|
103
|
+
const u = r[n] ?? {};
|
|
104
|
+
r[n] = Object.freeze({ ...u, ...c });
|
|
105
105
|
}
|
|
106
|
-
}, ye =
|
|
106
|
+
}, ye = b("component"), Se = v(
|
|
107
107
|
({ client: t, component: e, name: r }) => {
|
|
108
108
|
const n = t.frameworks.getByName(e.frameworkName);
|
|
109
109
|
return {
|
|
@@ -113,91 +113,91 @@ const fe = (t, e) => {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
);
|
|
116
|
-
function
|
|
116
|
+
function ke(t) {
|
|
117
117
|
return w(Se, t);
|
|
118
118
|
}
|
|
119
|
-
const
|
|
120
|
-
const e = ye.store({}), r =
|
|
121
|
-
register(s,
|
|
119
|
+
const ve = v(({ client: t }) => {
|
|
120
|
+
const e = ye.store({}), r = I(e, {
|
|
121
|
+
register(s, o) {
|
|
122
122
|
return {
|
|
123
123
|
...s,
|
|
124
|
-
[
|
|
124
|
+
[o.name]: o
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
|
-
function n(s,
|
|
129
|
-
e.getState()[s] &&
|
|
128
|
+
function n(s, o) {
|
|
129
|
+
e.getState()[s] && k(
|
|
130
130
|
"warn",
|
|
131
131
|
`Component '${s}' already registered. Registering again will override the previous registration.`
|
|
132
132
|
);
|
|
133
|
-
const h =
|
|
133
|
+
const h = ke({ client: t, name: s, component: o });
|
|
134
134
|
r.register(h);
|
|
135
135
|
}
|
|
136
|
-
const
|
|
137
|
-
function
|
|
138
|
-
return e.map((
|
|
136
|
+
const c = e.map((s) => Object.values(s));
|
|
137
|
+
function u(s) {
|
|
138
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
139
139
|
}
|
|
140
140
|
return {
|
|
141
141
|
register: n,
|
|
142
|
-
getByName:
|
|
143
|
-
listStore:
|
|
142
|
+
getByName: u,
|
|
143
|
+
listStore: c
|
|
144
144
|
};
|
|
145
145
|
});
|
|
146
146
|
function we(t) {
|
|
147
|
-
return w(
|
|
147
|
+
return w(ve, t);
|
|
148
148
|
}
|
|
149
|
-
const
|
|
149
|
+
const T = (t, e, r) => {
|
|
150
150
|
r.register(t, e);
|
|
151
|
-
},
|
|
152
|
-
const e =
|
|
153
|
-
register(s,
|
|
151
|
+
}, Fe = b("framework"), be = v(({ client: t }) => {
|
|
152
|
+
const e = Fe.store({}), r = I(e, {
|
|
153
|
+
register(s, o) {
|
|
154
154
|
return {
|
|
155
155
|
...s,
|
|
156
|
-
[
|
|
156
|
+
[o.name]: o.framework
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
|
-
function n(s,
|
|
161
|
-
e.getState()[s] &&
|
|
160
|
+
function n(s, o) {
|
|
161
|
+
e.getState()[s] && k(
|
|
162
162
|
"warn",
|
|
163
163
|
`Framework '${s}' already registered. Registering again will override the previous registration.`
|
|
164
|
-
), r.register({ name: s, framework:
|
|
164
|
+
), r.register({ name: s, framework: o });
|
|
165
165
|
}
|
|
166
|
-
const
|
|
167
|
-
function
|
|
168
|
-
return e.map((
|
|
166
|
+
const c = e.map((s) => Object.values(s));
|
|
167
|
+
function u(s) {
|
|
168
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
169
169
|
}
|
|
170
170
|
return {
|
|
171
171
|
register: n,
|
|
172
|
-
getByName:
|
|
173
|
-
listStore:
|
|
172
|
+
getByName: u,
|
|
173
|
+
listStore: c
|
|
174
174
|
};
|
|
175
175
|
});
|
|
176
|
-
function
|
|
177
|
-
return w(
|
|
176
|
+
function Ie(t) {
|
|
177
|
+
return w(be, t);
|
|
178
178
|
}
|
|
179
179
|
const xe = (t, e) => {
|
|
180
180
|
e.register(t.name, t);
|
|
181
|
-
}, Ee = 6e3,
|
|
181
|
+
}, Ee = 6e3, N = R("last_ping", "global"), Pe = (t) => `${t}/api/v1/ping`, Re = async (t) => {
|
|
182
182
|
try {
|
|
183
|
-
const e = Date.now(), r = localStorage.getItem(
|
|
183
|
+
const e = Date.now(), r = localStorage.getItem(N);
|
|
184
184
|
if (r && e - parseInt(r) < Ee)
|
|
185
185
|
return !0;
|
|
186
|
-
const n = Pe(t.apiUrl),
|
|
186
|
+
const n = Pe(t.apiUrl), c = {
|
|
187
187
|
projectId: t.projectId,
|
|
188
188
|
path: window.location.pathname
|
|
189
|
-
},
|
|
189
|
+
}, u = JSON.stringify(c), s = {
|
|
190
190
|
"Content-Type": "application/json"
|
|
191
|
-
},
|
|
192
|
-
|
|
191
|
+
}, o = document.getElementById("picked_script"), l = o == null ? void 0 : o.dataset.verceltoken;
|
|
192
|
+
l && (s["x-vercel-protection-bypass"] = l);
|
|
193
193
|
const S = (await fetch(n, {
|
|
194
194
|
method: "POST",
|
|
195
195
|
headers: s,
|
|
196
|
-
body:
|
|
196
|
+
body: u
|
|
197
197
|
})).ok;
|
|
198
|
-
return S && localStorage.setItem(
|
|
198
|
+
return S && localStorage.setItem(N, e.toString()), S;
|
|
199
199
|
} catch (e) {
|
|
200
|
-
return
|
|
200
|
+
return k("error", e), !1;
|
|
201
201
|
}
|
|
202
202
|
};
|
|
203
203
|
function Be(t) {
|
|
@@ -212,32 +212,32 @@ function Be(t) {
|
|
|
212
212
|
};
|
|
213
213
|
return Object.freeze(r);
|
|
214
214
|
}
|
|
215
|
-
const Ae =
|
|
216
|
-
const e = Ae.store({}), r =
|
|
217
|
-
register(s,
|
|
215
|
+
const Ae = b("predicate"), $e = v(({ client: t }) => {
|
|
216
|
+
const e = Ae.store({}), r = I(e, {
|
|
217
|
+
register(s, o) {
|
|
218
218
|
return {
|
|
219
219
|
...s,
|
|
220
|
-
[
|
|
221
|
-
name:
|
|
222
|
-
predicate:
|
|
220
|
+
[o.name]: {
|
|
221
|
+
name: o.name,
|
|
222
|
+
predicate: o.predicate
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
|
-
function n(s,
|
|
228
|
-
e.getState()[s] &&
|
|
227
|
+
function n(s, o) {
|
|
228
|
+
e.getState()[s] && k(
|
|
229
229
|
"warn",
|
|
230
230
|
`Predicate '${s}' already registered. Registering again will override the previous registration.`
|
|
231
|
-
), r.register(Object.freeze({ name: s, predicate:
|
|
231
|
+
), r.register(Object.freeze({ name: s, predicate: o }));
|
|
232
232
|
}
|
|
233
|
-
const
|
|
234
|
-
function
|
|
235
|
-
return e.map((
|
|
233
|
+
const c = e.map((s) => Object.values(s));
|
|
234
|
+
function u(s) {
|
|
235
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
236
236
|
}
|
|
237
237
|
return {
|
|
238
238
|
register: n,
|
|
239
|
-
getByName:
|
|
240
|
-
listStore:
|
|
239
|
+
getByName: u,
|
|
240
|
+
listStore: c
|
|
241
241
|
};
|
|
242
242
|
});
|
|
243
243
|
function je(t) {
|
|
@@ -245,24 +245,24 @@ function je(t) {
|
|
|
245
245
|
}
|
|
246
246
|
const Oe = (t, e, r) => {
|
|
247
247
|
r.register(t, e);
|
|
248
|
-
},
|
|
249
|
-
const e =
|
|
250
|
-
register(d,
|
|
248
|
+
}, z = b("feature"), Ce = v(({ client: t }) => {
|
|
249
|
+
const e = z.store({}), r = z.store([]), n = I(e, {
|
|
250
|
+
register(d, a) {
|
|
251
251
|
return {
|
|
252
252
|
...d,
|
|
253
|
-
[
|
|
253
|
+
[a.id]: a.feature
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
|
-
function
|
|
258
|
-
e.getState()[d] &&
|
|
257
|
+
function c(d, a) {
|
|
258
|
+
e.getState()[d] && k(
|
|
259
259
|
"warn",
|
|
260
260
|
`Feature '${d}' already registered. Registering again will override the previous registration.`
|
|
261
261
|
);
|
|
262
262
|
const p = {
|
|
263
263
|
id: d,
|
|
264
264
|
feature: {
|
|
265
|
-
...
|
|
265
|
+
...a,
|
|
266
266
|
id: d
|
|
267
267
|
}
|
|
268
268
|
};
|
|
@@ -273,106 +273,106 @@ const Oe = (t, e, r) => {
|
|
|
273
273
|
})
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
|
-
const
|
|
276
|
+
const u = M(
|
|
277
277
|
async ({
|
|
278
278
|
id: d,
|
|
279
|
-
key:
|
|
280
|
-
storage:
|
|
279
|
+
key: a,
|
|
280
|
+
storage: i = "local"
|
|
281
281
|
}) => {
|
|
282
|
-
const p =
|
|
283
|
-
return g === null ? null : { id: d, key:
|
|
282
|
+
const p = R(`feature:${d}:${a}`, "global"), g = (i === "session" ? j : D).get(p).boolean();
|
|
283
|
+
return g === null ? null : { id: d, key: a, bucket: g, storage: i };
|
|
284
284
|
}
|
|
285
|
-
), s =
|
|
285
|
+
), s = M((d) => {
|
|
286
286
|
if (!d)
|
|
287
287
|
return null;
|
|
288
|
-
const
|
|
289
|
-
(d.storage === "session" ? j : D).set(
|
|
290
|
-
}),
|
|
288
|
+
const a = R(`feature:${d.id}:${d.key}`, "global");
|
|
289
|
+
(d.storage === "session" ? j : D).set(a, d.bucket);
|
|
290
|
+
}), o = /* @__PURE__ */ new Map(), l = Q({
|
|
291
291
|
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
292
|
-
effect: async ({ allFeaturesStore: d, resolvedFeaturesStore:
|
|
293
|
-
const g =
|
|
294
|
-
(
|
|
292
|
+
effect: async ({ allFeaturesStore: d, resolvedFeaturesStore: a }, { id: i, decide: p, key: f }) => {
|
|
293
|
+
const g = a.find(
|
|
294
|
+
(A) => A.id === i && A.key === f
|
|
295
295
|
);
|
|
296
296
|
if (g)
|
|
297
297
|
return g;
|
|
298
|
-
const y = d[
|
|
298
|
+
const y = d[i];
|
|
299
299
|
if (!y)
|
|
300
|
-
throw new Error(`Feature with id '${
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
303
|
-
const
|
|
304
|
-
return { id: y.id, bucket:
|
|
300
|
+
throw new Error(`Feature with id '${i}' not found`);
|
|
301
|
+
const F = o.get(`${i}:${f}`);
|
|
302
|
+
if (F !== void 0) {
|
|
303
|
+
const A = await F;
|
|
304
|
+
return { id: y.id, bucket: A, key: f, storage: y.feature.storage };
|
|
305
305
|
}
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
return { id: y.id, bucket:
|
|
306
|
+
const B = p();
|
|
307
|
+
o.set(`${i}:${f}`, B);
|
|
308
|
+
const E = await B;
|
|
309
|
+
return { id: y.id, bucket: E, key: f, storage: y.feature.storage };
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
312
|
x({
|
|
313
313
|
clock: n.register,
|
|
314
314
|
fn: (d) => {
|
|
315
|
-
const { id:
|
|
316
|
-
return { id:
|
|
315
|
+
const { id: a, feature: i } = d;
|
|
316
|
+
return { id: a, key: i.feature.key, storage: i.feature.storage };
|
|
317
317
|
},
|
|
318
|
-
target:
|
|
318
|
+
target: u
|
|
319
319
|
}), x({
|
|
320
320
|
source: e,
|
|
321
|
-
clock:
|
|
322
|
-
fn: (d,
|
|
321
|
+
clock: l.doneData,
|
|
322
|
+
fn: (d, a) => {
|
|
323
323
|
var y;
|
|
324
|
-
const { id:
|
|
325
|
-
return g ? { key: g, id:
|
|
324
|
+
const { id: i, bucket: p, storage: f } = a, g = (y = d[i]) == null ? void 0 : y.feature.key;
|
|
325
|
+
return g ? { key: g, id: i, bucket: p, storage: f } : null;
|
|
326
326
|
},
|
|
327
327
|
target: s
|
|
328
328
|
});
|
|
329
329
|
const h = O({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
330
330
|
({
|
|
331
331
|
allFeaturesStore: d,
|
|
332
|
-
resolvedFeaturesStore:
|
|
333
|
-
}) => Object.values(d).map((
|
|
334
|
-
const p =
|
|
335
|
-
(f) => f.id ===
|
|
332
|
+
resolvedFeaturesStore: a
|
|
333
|
+
}) => Object.values(d).map((i) => {
|
|
334
|
+
const p = a.find(
|
|
335
|
+
(f) => f.id === i.id && f.key === i.feature.key
|
|
336
336
|
);
|
|
337
337
|
return p ? {
|
|
338
|
-
id:
|
|
339
|
-
name:
|
|
340
|
-
key:
|
|
341
|
-
getBucket: () => ({ id:
|
|
338
|
+
id: i.id,
|
|
339
|
+
name: i.feature.name,
|
|
340
|
+
key: i.feature.key,
|
|
341
|
+
getBucket: () => ({ id: i.id, bucket: p.bucket }),
|
|
342
342
|
isResolved: !0
|
|
343
343
|
} : {
|
|
344
|
-
id:
|
|
345
|
-
name:
|
|
346
|
-
key:
|
|
347
|
-
getBucket: async () => await
|
|
344
|
+
id: i.id,
|
|
345
|
+
name: i.feature.name,
|
|
346
|
+
key: i.feature.key,
|
|
347
|
+
getBucket: async () => await l(i.feature),
|
|
348
348
|
isResolved: !1
|
|
349
349
|
};
|
|
350
350
|
})
|
|
351
351
|
);
|
|
352
352
|
x({
|
|
353
|
-
clock:
|
|
353
|
+
clock: l.doneData,
|
|
354
354
|
source: { resolvedFeatures: r },
|
|
355
|
-
filter: ({ resolvedFeatures: d }, { id:
|
|
356
|
-
(f) => f.id ===
|
|
355
|
+
filter: ({ resolvedFeatures: d }, { id: a, key: i }) => !d.some(
|
|
356
|
+
(f) => f.id === a && f.key === i
|
|
357
357
|
),
|
|
358
|
-
fn: (d,
|
|
358
|
+
fn: (d, a) => a,
|
|
359
359
|
target: t.eventBus.prepend((d) => ({
|
|
360
360
|
type: "feature_decide",
|
|
361
361
|
feature: d
|
|
362
362
|
}))
|
|
363
363
|
}), x({
|
|
364
|
-
clock: [
|
|
364
|
+
clock: [u.doneData, l.doneData],
|
|
365
365
|
source: r,
|
|
366
|
-
fn: (d,
|
|
367
|
-
(p) => p.id ===
|
|
368
|
-
) ? d : [...d,
|
|
366
|
+
fn: (d, a) => !a || d.some(
|
|
367
|
+
(p) => p.id === a.id && p.key === a.key
|
|
368
|
+
) ? d : [...d, a],
|
|
369
369
|
target: r
|
|
370
370
|
});
|
|
371
371
|
function S(d) {
|
|
372
|
-
return e.map((
|
|
372
|
+
return e.map((a) => a[d], { skipVoid: !1 });
|
|
373
373
|
}
|
|
374
374
|
return {
|
|
375
|
-
register:
|
|
375
|
+
register: c,
|
|
376
376
|
getByName: S,
|
|
377
377
|
listStore: h
|
|
378
378
|
};
|
|
@@ -380,10 +380,10 @@ const Oe = (t, e, r) => {
|
|
|
380
380
|
function De(t) {
|
|
381
381
|
return w(Ce, t);
|
|
382
382
|
}
|
|
383
|
-
const
|
|
383
|
+
const Me = (t, e, r) => {
|
|
384
384
|
r.register(t, e);
|
|
385
|
-
},
|
|
386
|
-
function
|
|
385
|
+
}, P = b("history");
|
|
386
|
+
function L(t, e) {
|
|
387
387
|
return {
|
|
388
388
|
// eslint-disable-next-line sonarjs/pseudo-random
|
|
389
389
|
id: ne(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
@@ -392,32 +392,32 @@ function z(t, e) {
|
|
|
392
392
|
experienceId: t
|
|
393
393
|
};
|
|
394
394
|
}
|
|
395
|
-
const
|
|
396
|
-
const t =
|
|
397
|
-
t.on(e, (s,
|
|
398
|
-
entries: [...s.entries,
|
|
399
|
-
})), t.on(r, (s,
|
|
395
|
+
const Ve = v(() => {
|
|
396
|
+
const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), c = P.event();
|
|
397
|
+
t.on(e, (s, o) => ({
|
|
398
|
+
entries: [...s.entries, L(o.experienceId, o.node)]
|
|
399
|
+
})), t.on(r, (s, o) => ({
|
|
400
400
|
entries: [
|
|
401
401
|
...s.entries.slice(0, -1),
|
|
402
|
-
|
|
402
|
+
L(o.experienceId, o.node)
|
|
403
403
|
]
|
|
404
|
-
})), t.on(
|
|
405
|
-
function
|
|
406
|
-
const
|
|
404
|
+
})), t.on(c, (s, o) => o);
|
|
405
|
+
function u(s, o) {
|
|
406
|
+
const l = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
407
407
|
for (let h = s.length - 1; h >= 0; h--) {
|
|
408
408
|
const S = s[h], d = S == null ? void 0 : S.node;
|
|
409
|
-
if (!(!d || !te(d)) && !(
|
|
410
|
-
if (
|
|
411
|
-
|
|
409
|
+
if (!(!d || !te(d)) && !(o && (S == null ? void 0 : S.experienceId) !== o))
|
|
410
|
+
if (l.lastStepIndex === -1)
|
|
411
|
+
l.lastStepIndex = h;
|
|
412
412
|
else {
|
|
413
|
-
|
|
413
|
+
l.secondLastStepIndex = h;
|
|
414
414
|
break;
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
return
|
|
417
|
+
return l;
|
|
418
418
|
}
|
|
419
|
-
return t.on(n, (s,
|
|
420
|
-
const { secondLastStepIndex:
|
|
419
|
+
return t.on(n, (s, o) => {
|
|
420
|
+
const { secondLastStepIndex: l } = u(s.entries, o.experienceId), h = l !== -1 ? s.entries.slice(0, l + 1) : s.entries;
|
|
421
421
|
return {
|
|
422
422
|
...s,
|
|
423
423
|
entries: h
|
|
@@ -426,19 +426,19 @@ const Me = k(() => {
|
|
|
426
426
|
push: e,
|
|
427
427
|
replace: r,
|
|
428
428
|
back: n,
|
|
429
|
-
restore:
|
|
429
|
+
restore: c,
|
|
430
430
|
entriesStore: t.map((s) => s.entries)
|
|
431
431
|
};
|
|
432
432
|
});
|
|
433
|
-
function
|
|
434
|
-
return w(
|
|
433
|
+
function Te() {
|
|
434
|
+
return w(Ve);
|
|
435
435
|
}
|
|
436
|
-
const
|
|
437
|
-
const t =
|
|
438
|
-
register(s,
|
|
436
|
+
const Ne = () => C(), ze = b("field"), Le = v(() => {
|
|
437
|
+
const t = ze.store({}), e = I(t, {
|
|
438
|
+
register(s, o) {
|
|
439
439
|
return {
|
|
440
440
|
...s,
|
|
441
|
-
[
|
|
441
|
+
[o.field.id]: o.field
|
|
442
442
|
};
|
|
443
443
|
}
|
|
444
444
|
});
|
|
@@ -446,29 +446,29 @@ const Te = () => C(), Ne = F("field"), ze = k(() => {
|
|
|
446
446
|
e.register({ field: s });
|
|
447
447
|
}
|
|
448
448
|
const n = t.map((s) => Object.values(s));
|
|
449
|
-
function
|
|
450
|
-
return t.map((
|
|
449
|
+
function c(s) {
|
|
450
|
+
return t.map((o) => o[s] || null);
|
|
451
451
|
}
|
|
452
|
-
function
|
|
453
|
-
return t.map((
|
|
452
|
+
function u(s) {
|
|
453
|
+
return t.map((o) => Object.values(o).find((l) => l.name === s) || null);
|
|
454
454
|
}
|
|
455
455
|
return {
|
|
456
456
|
register: r,
|
|
457
|
-
getById:
|
|
457
|
+
getById: c,
|
|
458
458
|
listStore: n,
|
|
459
|
-
getByName:
|
|
459
|
+
getByName: u
|
|
460
460
|
};
|
|
461
461
|
});
|
|
462
|
-
function
|
|
463
|
-
return w(
|
|
462
|
+
function Ue() {
|
|
463
|
+
return w(Le);
|
|
464
464
|
}
|
|
465
|
-
const
|
|
465
|
+
const _e = (t, e) => {
|
|
466
466
|
e.register(t);
|
|
467
|
-
}, He =
|
|
468
|
-
const t = He.store({}), e =
|
|
469
|
-
register(
|
|
467
|
+
}, He = b("action"), Ke = v(() => {
|
|
468
|
+
const t = He.store({}), e = I(t, {
|
|
469
|
+
register(u, s) {
|
|
470
470
|
return {
|
|
471
|
-
...
|
|
471
|
+
...u,
|
|
472
472
|
[s.name]: {
|
|
473
473
|
name: s.name,
|
|
474
474
|
action: s.action
|
|
@@ -476,16 +476,16 @@ const Le = (t, e) => {
|
|
|
476
476
|
};
|
|
477
477
|
}
|
|
478
478
|
});
|
|
479
|
-
function r(
|
|
480
|
-
e.register({ name:
|
|
479
|
+
function r(u, s) {
|
|
480
|
+
e.register({ name: u, action: s });
|
|
481
481
|
}
|
|
482
|
-
const n = t.map((
|
|
483
|
-
function
|
|
484
|
-
return t.map((s) => s[
|
|
482
|
+
const n = t.map((u) => Object.values(u));
|
|
483
|
+
function c(u) {
|
|
484
|
+
return t.map((s) => s[u], { skipVoid: !1 });
|
|
485
485
|
}
|
|
486
486
|
return {
|
|
487
487
|
register: r,
|
|
488
|
-
getByName:
|
|
488
|
+
getByName: c,
|
|
489
489
|
listStore: n
|
|
490
490
|
};
|
|
491
491
|
});
|
|
@@ -495,42 +495,42 @@ function qe() {
|
|
|
495
495
|
const Ge = (t, e, r) => {
|
|
496
496
|
r.register(t, e);
|
|
497
497
|
};
|
|
498
|
-
function
|
|
498
|
+
function U(t) {
|
|
499
499
|
return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
|
|
500
500
|
}
|
|
501
|
-
const We =
|
|
502
|
-
const e = We.store({}), r = C(), n = C(),
|
|
503
|
-
register(
|
|
501
|
+
const We = b("response"), Ye = v(({ client: t }) => {
|
|
502
|
+
const e = We.store({}), r = C(), n = C(), c = I(e, {
|
|
503
|
+
register(a, i) {
|
|
504
504
|
return {
|
|
505
|
-
...
|
|
506
|
-
[
|
|
505
|
+
...a,
|
|
506
|
+
[i.fieldId]: i.response
|
|
507
507
|
};
|
|
508
508
|
},
|
|
509
|
-
registerBatch(
|
|
509
|
+
registerBatch(a, i) {
|
|
510
510
|
return {
|
|
511
|
-
...
|
|
512
|
-
...
|
|
511
|
+
...a,
|
|
512
|
+
...i
|
|
513
513
|
};
|
|
514
514
|
},
|
|
515
|
-
clear(
|
|
516
|
-
const { [
|
|
515
|
+
clear(a, i) {
|
|
516
|
+
const { [i]: p, ...f } = a;
|
|
517
517
|
return f;
|
|
518
518
|
},
|
|
519
519
|
clearAll() {
|
|
520
520
|
return {};
|
|
521
521
|
}
|
|
522
522
|
});
|
|
523
|
-
function
|
|
524
|
-
|
|
523
|
+
function u(a, i) {
|
|
524
|
+
c.register({ fieldId: a, response: i });
|
|
525
525
|
}
|
|
526
|
-
async function s(
|
|
527
|
-
const
|
|
526
|
+
async function s(a) {
|
|
527
|
+
const i = [];
|
|
528
528
|
return await Promise.allSettled(
|
|
529
|
-
Object.entries(
|
|
529
|
+
Object.entries(a).map(async ([p, f]) => {
|
|
530
530
|
let g = f;
|
|
531
531
|
const y = t.fields.getById(p).getState();
|
|
532
532
|
if (!y) {
|
|
533
|
-
|
|
533
|
+
i.push({
|
|
534
534
|
fieldId: p,
|
|
535
535
|
userMessage: `Field '${p}' not found`,
|
|
536
536
|
systemMessage: `No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
@@ -538,21 +538,21 @@ const We = F("response"), Ye = k(({ client: t }) => {
|
|
|
538
538
|
});
|
|
539
539
|
return;
|
|
540
540
|
}
|
|
541
|
-
if (y.multiple && (typeof g == "string" || typeof g == "number" || typeof g == "boolean") && (g = [g]), y.validation && !
|
|
542
|
-
const
|
|
541
|
+
if (y.multiple && (typeof g == "string" || typeof g == "number" || typeof g == "boolean") && (g = [g]), y.validation && !oe(y.validation) && !U(g)) {
|
|
542
|
+
const F = await $(t, y.validation, {
|
|
543
543
|
$input: g
|
|
544
544
|
});
|
|
545
|
-
if (typeof
|
|
546
|
-
|
|
545
|
+
if (typeof F == "string") {
|
|
546
|
+
i.push({
|
|
547
547
|
fieldId: p,
|
|
548
|
-
userMessage:
|
|
549
|
-
systemMessage: `Field validation resulted in an error: ${
|
|
548
|
+
userMessage: F,
|
|
549
|
+
systemMessage: `Field validation resulted in an error: ${F}.`,
|
|
550
550
|
value: g
|
|
551
551
|
});
|
|
552
552
|
return;
|
|
553
553
|
}
|
|
554
|
-
if (
|
|
555
|
-
|
|
554
|
+
if (F === !1) {
|
|
555
|
+
i.push({
|
|
556
556
|
fieldId: p,
|
|
557
557
|
userMessage: "This field is invalid",
|
|
558
558
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
@@ -561,8 +561,8 @@ const We = F("response"), Ye = k(({ client: t }) => {
|
|
|
561
561
|
return;
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
-
if (y.required &&
|
|
565
|
-
|
|
564
|
+
if (y.required && U(g)) {
|
|
565
|
+
i.push({
|
|
566
566
|
fieldId: p,
|
|
567
567
|
userMessage: "This field is required",
|
|
568
568
|
systemMessage: "Field is required.",
|
|
@@ -571,7 +571,7 @@ const We = F("response"), Ye = k(({ client: t }) => {
|
|
|
571
571
|
return;
|
|
572
572
|
}
|
|
573
573
|
if (!y.multiple && Array.isArray(g) && g.length > 1) {
|
|
574
|
-
|
|
574
|
+
i.push({
|
|
575
575
|
fieldId: p,
|
|
576
576
|
userMessage: "This field expects a single response",
|
|
577
577
|
systemMessage: "Field expects a single response.",
|
|
@@ -580,50 +580,50 @@ const We = F("response"), Ye = k(({ client: t }) => {
|
|
|
580
580
|
return;
|
|
581
581
|
}
|
|
582
582
|
if (y.options) {
|
|
583
|
-
const
|
|
584
|
-
Array.isArray(g) && (
|
|
583
|
+
const F = y.options.map((E) => E.value), B = Array.isArray(g) ? g : [g];
|
|
584
|
+
Array.isArray(g) && (B.every((E) => F.includes(E)) || i.push({
|
|
585
585
|
fieldId: p,
|
|
586
586
|
userMessage: "This field expects a valid option",
|
|
587
|
-
systemMessage: `Field expects a valid option. Valid options are: ${
|
|
587
|
+
systemMessage: `Field expects a valid option. Valid options are: ${F.join(", ")}`,
|
|
588
588
|
value: g
|
|
589
589
|
}));
|
|
590
590
|
}
|
|
591
591
|
})
|
|
592
|
-
), { responsesToCommit:
|
|
592
|
+
), { responsesToCommit: a, validationErrors: i };
|
|
593
593
|
}
|
|
594
|
-
async function
|
|
595
|
-
const { responsesToCommit:
|
|
596
|
-
return p.length ? { errors: p } : (
|
|
594
|
+
async function o(a) {
|
|
595
|
+
const { responsesToCommit: i, validationErrors: p } = await s(a);
|
|
596
|
+
return p.length ? { errors: p } : (c.registerBatch(i), { errors: [] });
|
|
597
597
|
}
|
|
598
|
-
const
|
|
598
|
+
const l = e.map((a) => a), h = e.map((a) => Object.keys(a).map((p) => ({
|
|
599
599
|
fieldId: p,
|
|
600
|
-
value:
|
|
600
|
+
value: a[p]
|
|
601
601
|
})));
|
|
602
|
-
function S(
|
|
603
|
-
const
|
|
604
|
-
return O({ f:
|
|
602
|
+
function S(a) {
|
|
603
|
+
const i = t.fields.getById(a), p = e.map((f) => f[a] || null);
|
|
604
|
+
return O({ f: i, r: p }, ({ f, r: g }) => g || (f != null && f.defaultValue ? f.defaultValue : null));
|
|
605
605
|
}
|
|
606
|
-
function d(
|
|
607
|
-
const
|
|
608
|
-
return O({ f:
|
|
606
|
+
function d(a) {
|
|
607
|
+
const i = t.fields.getByName(a);
|
|
608
|
+
return O({ f: i, s: e }, ({ f: p, s: f }) => {
|
|
609
609
|
const g = p && f[p.id] || null;
|
|
610
610
|
return g || (p != null && p.defaultValue ? p.defaultValue : null);
|
|
611
611
|
});
|
|
612
612
|
}
|
|
613
613
|
return x({
|
|
614
614
|
clock: r,
|
|
615
|
-
target:
|
|
615
|
+
target: c.clearAll
|
|
616
616
|
}), x({
|
|
617
617
|
clock: n,
|
|
618
|
-
target:
|
|
618
|
+
target: c.clear
|
|
619
619
|
}), {
|
|
620
|
-
register:
|
|
620
|
+
register: u,
|
|
621
621
|
clearAll: r,
|
|
622
622
|
clear: n,
|
|
623
|
-
commit:
|
|
623
|
+
commit: o,
|
|
624
624
|
getResponsesToCommit: s,
|
|
625
625
|
listStore: h,
|
|
626
|
-
getAllStore:
|
|
626
|
+
getAllStore: l,
|
|
627
627
|
getByFieldId: S,
|
|
628
628
|
getByFieldName: d
|
|
629
629
|
};
|
|
@@ -631,7 +631,7 @@ const We = F("response"), Ye = k(({ client: t }) => {
|
|
|
631
631
|
function Je(t) {
|
|
632
632
|
return w(Ye, t);
|
|
633
633
|
}
|
|
634
|
-
const Qe = () => "0.0.1-dev.
|
|
634
|
+
const Qe = () => "0.0.1-dev.1764694362099";
|
|
635
635
|
function Xe() {
|
|
636
636
|
if (H()) {
|
|
637
637
|
const t = [
|
|
@@ -648,22 +648,22 @@ function Xe() {
|
|
|
648
648
|
return "https://api.picked.app";
|
|
649
649
|
}
|
|
650
650
|
function Ze() {
|
|
651
|
-
if (!
|
|
651
|
+
if (!ie())
|
|
652
652
|
return {};
|
|
653
653
|
const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
|
|
654
|
-
for (const [
|
|
655
|
-
|
|
656
|
-
for (const
|
|
657
|
-
const
|
|
658
|
-
e[
|
|
654
|
+
for (const [c] of t.entries())
|
|
655
|
+
c.startsWith("picked-") && r.add(c);
|
|
656
|
+
for (const c of r) {
|
|
657
|
+
const u = c.replace("picked-", "");
|
|
658
|
+
e[u] = t.getAll(c);
|
|
659
659
|
}
|
|
660
|
-
const n =
|
|
660
|
+
const n = R("s");
|
|
661
661
|
if (r.size > 0)
|
|
662
662
|
j.set(n, e);
|
|
663
663
|
else {
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
666
|
-
return
|
|
664
|
+
const c = j.get(n);
|
|
665
|
+
if (c)
|
|
666
|
+
return c.json() || {};
|
|
667
667
|
}
|
|
668
668
|
return e;
|
|
669
669
|
}
|
|
@@ -673,76 +673,66 @@ function et() {
|
|
|
673
673
|
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);
|
|
674
674
|
return `${t}-${e}-${r}-${n}`;
|
|
675
675
|
}
|
|
676
|
-
const tt =
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
this.isUser = o, r(this);
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
return r(n), n;
|
|
688
|
-
}, st = () => ae() ? rt() : null;
|
|
676
|
+
const tt = () => ({
|
|
677
|
+
id: et()
|
|
678
|
+
}), rt = R("session", "global"), st = () => {
|
|
679
|
+
if (!ae()) return null;
|
|
680
|
+
const t = D.get(rt);
|
|
681
|
+
let e = t.isSet() ? t.json() : null;
|
|
682
|
+
return e || (e = tt(), t.set(e)), e;
|
|
683
|
+
}, nt = () => st();
|
|
689
684
|
class G {
|
|
690
685
|
constructor(e) {
|
|
691
686
|
m(this, "options");
|
|
692
687
|
m(this, "isReady", !1);
|
|
693
688
|
m(this, "project");
|
|
694
689
|
m(this, "plugins", {});
|
|
695
|
-
m(this, "eventBus",
|
|
690
|
+
m(this, "eventBus", Ne());
|
|
696
691
|
m(this, "organizationId");
|
|
697
692
|
m(this, "projectId");
|
|
698
693
|
m(this, "apiUrl");
|
|
699
694
|
m(this, "session");
|
|
700
|
-
m(this, "precondition");
|
|
701
|
-
m(this, "condition");
|
|
702
695
|
m(this, "searchParams", Ze());
|
|
703
|
-
m(this, "history",
|
|
696
|
+
m(this, "history", Te());
|
|
704
697
|
m(this, "components", we({ client: this }));
|
|
705
698
|
m(this, "experienceInstances", re({ client: this }));
|
|
706
699
|
m(this, "experiences", ge({ client: this }));
|
|
707
|
-
m(this, "frameworks",
|
|
700
|
+
m(this, "frameworks", Ie({ client: this }));
|
|
708
701
|
m(this, "predicates", je({ client: this }));
|
|
709
702
|
m(this, "features", De({ client: this }));
|
|
710
703
|
m(this, "responses", Je({ client: this }));
|
|
711
|
-
m(this, "fields",
|
|
704
|
+
m(this, "fields", Ue());
|
|
712
705
|
m(this, "actions", qe());
|
|
713
|
-
|
|
706
|
+
k("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Xe(), this.session = nt(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.eventBus({ type: "initialized", version: Qe() }), k("info", "Picked client initialized.");
|
|
714
707
|
}
|
|
715
708
|
start() {
|
|
716
709
|
Re(this), (async () => {
|
|
717
|
-
|
|
718
|
-
return;
|
|
719
|
-
let r = !0, n;
|
|
720
|
-
this.precondition !== void 0 && await E(this, this.precondition) === !1 && (n = !1, r = !1), this.condition !== void 0 && n !== !1 && await E(this, this.condition) === !1 && (r = !1), this.session && this.session.setIsUser(r), this.eventBus({ type: "initialize" }), this.eventBus({ type: "user_decide", value: r }), document.body && r && M(this), await se(), r && M(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
|
|
710
|
+
H() && (document.body && V(this), await se(), V(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session }));
|
|
721
711
|
})();
|
|
722
712
|
}
|
|
723
713
|
registerFramework(e) {
|
|
724
714
|
xe(e, this.frameworks);
|
|
725
715
|
}
|
|
726
716
|
registerComponent(e, r) {
|
|
727
|
-
|
|
717
|
+
T(e, r, this.components);
|
|
728
718
|
}
|
|
729
719
|
registerPlugin(e) {
|
|
730
720
|
he(this, e, this.plugins);
|
|
731
721
|
}
|
|
732
722
|
registerFeature(e, r) {
|
|
733
|
-
|
|
723
|
+
Me(e, r, this.features);
|
|
734
724
|
}
|
|
735
725
|
registerPredicate(e, r) {
|
|
736
726
|
Oe(e, r, this.predicates);
|
|
737
727
|
}
|
|
738
728
|
registerField(e) {
|
|
739
|
-
|
|
729
|
+
_e(e, this.fields);
|
|
740
730
|
}
|
|
741
731
|
registerAction(e, r) {
|
|
742
732
|
Ge(e, r, this.actions);
|
|
743
733
|
}
|
|
744
734
|
registerExperience(e) {
|
|
745
|
-
e.component &&
|
|
735
|
+
e.component && T(`experience:${e.id}`, e.component, this.components), fe(e, this.experiences);
|
|
746
736
|
}
|
|
747
737
|
getStateSnapshot() {
|
|
748
738
|
return Be(this);
|
|
@@ -750,7 +740,7 @@ class G {
|
|
|
750
740
|
async launchExperienceById(e) {
|
|
751
741
|
const r = this.experiences.getById(e).getState();
|
|
752
742
|
if (!r) {
|
|
753
|
-
|
|
743
|
+
k("warn", `Experience with id '${e}' not found.`);
|
|
754
744
|
return;
|
|
755
745
|
}
|
|
756
746
|
q(this, r);
|
|
@@ -768,14 +758,14 @@ class G {
|
|
|
768
758
|
var e;
|
|
769
759
|
(e = this.options.plugins) == null || e.forEach((r) => {
|
|
770
760
|
if (Array.isArray(r)) {
|
|
771
|
-
r.forEach((
|
|
772
|
-
this.registerPlugin(
|
|
761
|
+
r.forEach((c) => {
|
|
762
|
+
this.registerPlugin(c);
|
|
773
763
|
});
|
|
774
764
|
return;
|
|
775
765
|
}
|
|
776
766
|
const n = typeof r == "function" ? r() : r;
|
|
777
767
|
if (Array.isArray(n)) {
|
|
778
|
-
n.forEach((
|
|
768
|
+
n.forEach((c) => this.registerPlugin(c));
|
|
779
769
|
return;
|
|
780
770
|
}
|
|
781
771
|
this.registerPlugin(n);
|
|
@@ -784,20 +774,20 @@ class G {
|
|
|
784
774
|
setupFeatures() {
|
|
785
775
|
const e = this.options.features;
|
|
786
776
|
e && (Object.entries(e).forEach(([r, n]) => {
|
|
787
|
-
const
|
|
788
|
-
this.registerFeature(r,
|
|
777
|
+
const c = typeof n == "function" ? n() : n;
|
|
778
|
+
this.registerFeature(r, c);
|
|
789
779
|
}), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
|
|
790
780
|
try {
|
|
791
|
-
const [n,
|
|
792
|
-
if (!n || !
|
|
781
|
+
const [n, c] = r.split(":");
|
|
782
|
+
if (!n || !c)
|
|
793
783
|
return;
|
|
794
|
-
let
|
|
795
|
-
|
|
796
|
-
key: `${
|
|
784
|
+
let u = c;
|
|
785
|
+
u === "true" && (u = !0), u === "false" && (u = !1), this.registerFeature(n, {
|
|
786
|
+
key: `${u}`,
|
|
797
787
|
// use the assigned bucket value as the key
|
|
798
788
|
name: n,
|
|
799
789
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
800
|
-
decide: () =>
|
|
790
|
+
decide: () => u,
|
|
801
791
|
storage: "session"
|
|
802
792
|
});
|
|
803
793
|
} catch {
|
|
@@ -808,7 +798,7 @@ class G {
|
|
|
808
798
|
const e = this.options.predicates;
|
|
809
799
|
e && Object.entries(e).forEach(([r, n]) => {
|
|
810
800
|
if (typeof n != "function") {
|
|
811
|
-
|
|
801
|
+
k("warn", `Predicate "${r}" is not a function.`);
|
|
812
802
|
return;
|
|
813
803
|
}
|
|
814
804
|
this.registerPredicate(r, n);
|
|
@@ -818,7 +808,7 @@ class G {
|
|
|
818
808
|
const e = this.options.actions;
|
|
819
809
|
e && Object.entries(e).forEach(([r, n]) => {
|
|
820
810
|
if (typeof n != "function") {
|
|
821
|
-
|
|
811
|
+
k("warn", `Action "${r}" is not a function.`);
|
|
822
812
|
return;
|
|
823
813
|
}
|
|
824
814
|
this.registerAction(r, n);
|
|
@@ -828,51 +818,51 @@ class G {
|
|
|
828
818
|
return this.plugins[e] ?? {};
|
|
829
819
|
}
|
|
830
820
|
}
|
|
831
|
-
m(G, "logger",
|
|
821
|
+
m(G, "logger", k);
|
|
832
822
|
function W(t) {
|
|
833
823
|
var e;
|
|
834
824
|
return ((e = t.options) == null ? void 0 : e.some((r) => "condition" in r)) ?? !1;
|
|
835
825
|
}
|
|
836
|
-
function
|
|
826
|
+
function ot(t) {
|
|
837
827
|
return t.some((e) => e.condition || W(e));
|
|
838
828
|
}
|
|
839
|
-
async function
|
|
840
|
-
return e.length === 0 || !
|
|
829
|
+
async function mt(t, e) {
|
|
830
|
+
return e.length === 0 || !ot(e) ? e : (await Promise.all(
|
|
841
831
|
e.map(async (n) => {
|
|
842
|
-
if (!(n.condition ? await
|
|
832
|
+
if (!(n.condition ? await $(t, n.condition) : !0))
|
|
843
833
|
return null;
|
|
844
834
|
if (!n.options || !W(n))
|
|
845
835
|
return n;
|
|
846
836
|
const s = (await Promise.all(
|
|
847
|
-
n.options.map(async (
|
|
848
|
-
)).filter((
|
|
837
|
+
n.options.map(async (l) => l.condition ? await $(t, l.condition) ? l : null : l)
|
|
838
|
+
)).filter((l) => l !== null);
|
|
849
839
|
return s.length === n.options.length ? n : s.length === 0 ? null : { ...n, options: s };
|
|
850
840
|
})
|
|
851
841
|
)).filter((n) => n !== null);
|
|
852
842
|
}
|
|
853
|
-
const
|
|
843
|
+
const ht = (t) => {
|
|
854
844
|
const e = new G(t);
|
|
855
845
|
return ue(e), e;
|
|
856
846
|
};
|
|
857
847
|
export {
|
|
858
848
|
G as Picked,
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
849
|
+
ht as createClient,
|
|
850
|
+
R as createStorageKey,
|
|
851
|
+
$ as evaluateRuleLogic,
|
|
852
|
+
mt as getStepFields,
|
|
853
|
+
kt as isPickedRoot,
|
|
864
854
|
D as localStore,
|
|
865
855
|
j as sessionStore,
|
|
866
|
-
|
|
867
|
-
|
|
856
|
+
wt as subscribe,
|
|
857
|
+
bt as supportsCookies,
|
|
868
858
|
ce as supportsCryptoRandomUUID,
|
|
869
859
|
H as supportsDocument,
|
|
870
|
-
|
|
871
|
-
|
|
860
|
+
It as supportsHistory,
|
|
861
|
+
xt as supportsIntersectionObserver,
|
|
872
862
|
ae as supportsLocalStorage,
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
863
|
+
Et as supportsLocation,
|
|
864
|
+
Pt as supportsSessionStorage,
|
|
865
|
+
Rt as supportsShadowRoot,
|
|
866
|
+
Bt as supportsWebComponents,
|
|
867
|
+
ie as supportsWindow
|
|
878
868
|
};
|