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