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