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