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