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