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