@picked/client 0.0.1-dev.1778467244607 → 0.0.1-dev.1778468342672
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/{api-DWGhvwuG.js → api-BFD1TEJW.js} +1 -1
- package/dist/{api-CF5VqlzY.cjs → api-D_w_sQ8k.cjs} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/esm/index.js +332 -268
- package/dist/esm/plugins/dynamic-experiences/index.js +109 -38
- package/dist/types/entities/content/content.d.ts +37 -0
- package/dist/types/entities/content/content.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +22 -2
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +17 -2
- package/dist/types/entities/step/step.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -1
- package/dist/types/picked.d.ts +39 -0
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +18 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +63 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -4,13 +4,13 @@ import { t as r } from "../logger-6z_gb4rA.js";
|
|
|
4
4
|
import { a as i, c as a, d as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "../supports-0XIfd4-R.js";
|
|
5
5
|
import { a as g, c as _, i as v, l as y, n as b, o as ee, r as x, s as S } from "../experience-instance-BrLWgVAN.js";
|
|
6
6
|
import { i as C, n as w, r as T, t as E } from "../storage-6Xk0uAxB.js";
|
|
7
|
-
import { n as D, r as te } from "../api-
|
|
7
|
+
import { n as D, r as te } from "../api-BFD1TEJW.js";
|
|
8
8
|
import { t as ne } from "../id-CRqy981z.js";
|
|
9
9
|
import { attach as O, combine as k, createApi as A, createDomain as j, createEffect as M, createEvent as N, createStore as P, sample as F } from "effector";
|
|
10
10
|
import { createFactory as I, invoke as L } from "@withease/factories";
|
|
11
11
|
//#region src/entities/experience/experience.ts
|
|
12
|
-
var
|
|
13
|
-
let i =
|
|
12
|
+
var R = j("experience"), re = I(({ client: e, experience: r }) => {
|
|
13
|
+
let i = R.store(r), a = A(i, { merge(e, t) {
|
|
14
14
|
return {
|
|
15
15
|
...e,
|
|
16
16
|
...t.experience
|
|
@@ -47,8 +47,40 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
|
|
|
47
47
|
let { decisionLogic: s, targetSelectors: c } = o;
|
|
48
48
|
return c.length === 0 || S(c, r.id).length < 1 ? !1 : s === void 0 ? !0 : t(s) ? await n(e, s) === !0 : !0;
|
|
49
49
|
}
|
|
50
|
-
})
|
|
51
|
-
|
|
50
|
+
}), p = M(async () => {
|
|
51
|
+
if (!e.contentLoader) return !0;
|
|
52
|
+
try {
|
|
53
|
+
await e.contentLoader({
|
|
54
|
+
id: r.id,
|
|
55
|
+
key: r.key
|
|
56
|
+
});
|
|
57
|
+
} catch {
|
|
58
|
+
`${r.id}`;
|
|
59
|
+
}
|
|
60
|
+
return !0;
|
|
61
|
+
}), m = N(), h = N(), _ = R.createStore(void 0, { skipVoid: !1 }).on(m, (e, t) => t).on(h, (e, t) => t);
|
|
62
|
+
return F({
|
|
63
|
+
clock: m,
|
|
64
|
+
target: f
|
|
65
|
+
}), F({
|
|
66
|
+
clock: f.doneData,
|
|
67
|
+
source: _,
|
|
68
|
+
filter: (e, t) => t,
|
|
69
|
+
fn: (e) => e,
|
|
70
|
+
target: d
|
|
71
|
+
}), F({
|
|
72
|
+
clock: f.doneData,
|
|
73
|
+
filter: Boolean,
|
|
74
|
+
target: p
|
|
75
|
+
}), F({
|
|
76
|
+
clock: h,
|
|
77
|
+
source: _,
|
|
78
|
+
fn: (e) => e,
|
|
79
|
+
target: d
|
|
80
|
+
}), F({
|
|
81
|
+
clock: h,
|
|
82
|
+
target: p
|
|
83
|
+
}), u = {
|
|
52
84
|
id: r.id,
|
|
53
85
|
key: r.key,
|
|
54
86
|
name: r.name,
|
|
@@ -58,20 +90,23 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
|
|
|
58
90
|
actions: l,
|
|
59
91
|
merge: a.merge,
|
|
60
92
|
initialiseFx: d,
|
|
61
|
-
shouldInitialiseFx: f
|
|
93
|
+
shouldInitialiseFx: f,
|
|
94
|
+
initialiseRequested: m,
|
|
95
|
+
initialiseDirectly: h,
|
|
96
|
+
prepareExperienceContentFx: p
|
|
62
97
|
}, u;
|
|
63
98
|
});
|
|
64
|
-
function
|
|
65
|
-
return L(
|
|
99
|
+
function ie(e) {
|
|
100
|
+
return L(re, e);
|
|
66
101
|
}
|
|
67
|
-
var
|
|
68
|
-
let t =
|
|
102
|
+
var ae = I(({ client: e }) => {
|
|
103
|
+
let t = R.store({}), n = A(t, { register(e, t) {
|
|
69
104
|
return {
|
|
70
105
|
...e,
|
|
71
106
|
[t.id]: t
|
|
72
107
|
};
|
|
73
108
|
} }), r = N(), i = M((t) => {
|
|
74
|
-
n.register(
|
|
109
|
+
n.register(ie({
|
|
75
110
|
client: e,
|
|
76
111
|
experience: t
|
|
77
112
|
}));
|
|
@@ -105,18 +140,14 @@ var oe = I(({ client: e }) => {
|
|
|
105
140
|
}
|
|
106
141
|
let c = O({
|
|
107
142
|
source: t,
|
|
108
|
-
effect:
|
|
143
|
+
effect: (e, t) => {
|
|
109
144
|
let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
|
|
110
145
|
if (!n) {
|
|
111
146
|
"key" in t ? `${t.key}` : `${t.id}`;
|
|
112
147
|
return;
|
|
113
148
|
}
|
|
114
149
|
let { options: r } = t;
|
|
115
|
-
|
|
116
|
-
await n.initialiseFx(r);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
await n.shouldInitialiseFx() && await n.initialiseFx(r);
|
|
150
|
+
r?.bypassCondition ? n.initialiseDirectly(r) : n.initialiseRequested(r);
|
|
120
151
|
}
|
|
121
152
|
});
|
|
122
153
|
return {
|
|
@@ -131,7 +162,7 @@ var oe = I(({ client: e }) => {
|
|
|
131
162
|
instances: e.experienceInstances.listStore
|
|
132
163
|
},
|
|
133
164
|
effect: async ({ experiences: e, instances: t }, n) => {
|
|
134
|
-
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) =>
|
|
165
|
+
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => e.experienceId === r?.id);
|
|
135
166
|
if (i.length > 0) {
|
|
136
167
|
for (let e of i) e.open();
|
|
137
168
|
return;
|
|
@@ -154,28 +185,26 @@ var oe = I(({ client: e }) => {
|
|
|
154
185
|
listStore: a,
|
|
155
186
|
initialiseExperiencesFx: O({
|
|
156
187
|
source: a,
|
|
157
|
-
effect:
|
|
158
|
-
|
|
159
|
-
await e.shouldInitialiseFx() && await e.initialiseFx(void 0);
|
|
160
|
-
}));
|
|
188
|
+
effect: (e) => {
|
|
189
|
+
for (let t of e) t.initialiseRequested(void 0);
|
|
161
190
|
}
|
|
162
191
|
})
|
|
163
192
|
};
|
|
164
193
|
});
|
|
165
|
-
function
|
|
166
|
-
return L(
|
|
194
|
+
function oe(e) {
|
|
195
|
+
return L(ae, e);
|
|
167
196
|
}
|
|
168
|
-
var
|
|
197
|
+
var se = async (e) => {
|
|
169
198
|
await e.experiences.initialiseExperiencesFx();
|
|
170
199
|
};
|
|
171
200
|
//#endregion
|
|
172
201
|
//#region src/entities/plugin/plugin.ts
|
|
173
|
-
function
|
|
202
|
+
function ce(e) {
|
|
174
203
|
return M(async () => {
|
|
175
204
|
await e();
|
|
176
205
|
});
|
|
177
206
|
}
|
|
178
|
-
var
|
|
207
|
+
var le = (e, t, n) => {
|
|
179
208
|
let r = t.name, i = t.setup(e);
|
|
180
209
|
if (i) {
|
|
181
210
|
let e = n[r] ?? {};
|
|
@@ -184,16 +213,16 @@ var ue = (e, t, n) => {
|
|
|
184
213
|
...i
|
|
185
214
|
});
|
|
186
215
|
}
|
|
187
|
-
},
|
|
216
|
+
}, ue = j("component"), de = I(({ client: e, component: t, name: n }) => ({
|
|
188
217
|
name: n,
|
|
189
218
|
component: t,
|
|
190
219
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
191
220
|
}));
|
|
192
|
-
function
|
|
193
|
-
return L(
|
|
221
|
+
function fe(e) {
|
|
222
|
+
return L(de, e);
|
|
194
223
|
}
|
|
195
|
-
var
|
|
196
|
-
let t =
|
|
224
|
+
var pe = I(({ client: e }) => {
|
|
225
|
+
let t = ue.store({}), n = A(t, { register(e, t) {
|
|
197
226
|
return {
|
|
198
227
|
...e,
|
|
199
228
|
[t.name]: t
|
|
@@ -206,7 +235,7 @@ var me = I(({ client: e }) => {
|
|
|
206
235
|
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
207
236
|
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
208
237
|
clock: i,
|
|
209
|
-
fn: ({ name: t, component: n }) =>
|
|
238
|
+
fn: ({ name: t, component: n }) => fe({
|
|
210
239
|
client: e,
|
|
211
240
|
name: t,
|
|
212
241
|
component: n
|
|
@@ -223,16 +252,16 @@ var me = I(({ client: e }) => {
|
|
|
223
252
|
listStore: a
|
|
224
253
|
};
|
|
225
254
|
});
|
|
226
|
-
function
|
|
227
|
-
return L(
|
|
255
|
+
function me(e) {
|
|
256
|
+
return L(pe, e);
|
|
228
257
|
}
|
|
229
|
-
var
|
|
258
|
+
var z = (e, t, n) => {
|
|
230
259
|
n.register({
|
|
231
260
|
name: e,
|
|
232
261
|
component: t
|
|
233
262
|
});
|
|
234
|
-
},
|
|
235
|
-
let t =
|
|
263
|
+
}, he = j("framework"), ge = I((e) => {
|
|
264
|
+
let t = he.store({}), n = A(t, { register(e, t) {
|
|
236
265
|
return {
|
|
237
266
|
...e,
|
|
238
267
|
[t.name]: t.framework
|
|
@@ -257,20 +286,20 @@ var ge = (e, t, n) => {
|
|
|
257
286
|
listStore: a
|
|
258
287
|
};
|
|
259
288
|
});
|
|
260
|
-
function
|
|
261
|
-
return L(
|
|
289
|
+
function _e(e) {
|
|
290
|
+
return L(ge, e);
|
|
262
291
|
}
|
|
263
|
-
var
|
|
292
|
+
var ve = (e, t) => {
|
|
264
293
|
t.register({
|
|
265
294
|
name: e.name,
|
|
266
295
|
framework: e
|
|
267
296
|
});
|
|
268
|
-
},
|
|
269
|
-
let t =
|
|
270
|
-
location: t ?
|
|
271
|
-
document: t ?
|
|
272
|
-
sessionStorage: t ?
|
|
273
|
-
localStorage: t ?
|
|
297
|
+
}, ye = I(({ client: e }) => {
|
|
298
|
+
let t = "window" in globalThis, n = {
|
|
299
|
+
location: t ? globalThis.location : void 0,
|
|
300
|
+
document: t ? globalThis.document : void 0,
|
|
301
|
+
sessionStorage: t ? globalThis.sessionStorage : void 0,
|
|
302
|
+
localStorage: t ? globalThis.localStorage : void 0
|
|
274
303
|
};
|
|
275
304
|
return k(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
|
|
276
305
|
client: e,
|
|
@@ -279,84 +308,84 @@ var be = (e, t) => {
|
|
|
279
308
|
...n
|
|
280
309
|
}));
|
|
281
310
|
});
|
|
282
|
-
function
|
|
283
|
-
return L(
|
|
311
|
+
function be(e) {
|
|
312
|
+
return L(ye, e);
|
|
284
313
|
}
|
|
285
314
|
//#endregion
|
|
286
315
|
//#region src/logic-engine.ts
|
|
287
|
-
function
|
|
316
|
+
function xe(e) {
|
|
288
317
|
return typeof e == "number" && !isNaN(e);
|
|
289
318
|
}
|
|
290
|
-
function
|
|
319
|
+
function B(e) {
|
|
291
320
|
return typeof e == "string";
|
|
292
321
|
}
|
|
293
|
-
function
|
|
322
|
+
function V(e) {
|
|
294
323
|
return Array.isArray(e);
|
|
295
324
|
}
|
|
296
|
-
function
|
|
325
|
+
function H(e) {
|
|
297
326
|
return e instanceof Promise;
|
|
298
327
|
}
|
|
299
|
-
function
|
|
328
|
+
function U(e) {
|
|
300
329
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
301
330
|
}
|
|
302
|
-
function
|
|
303
|
-
if (
|
|
331
|
+
function W(e) {
|
|
332
|
+
if (xe(e)) return e;
|
|
304
333
|
let t = parseFloat(`${e}`);
|
|
305
334
|
return isNaN(t) ? 0 : t;
|
|
306
335
|
}
|
|
307
|
-
function
|
|
336
|
+
function G(e) {
|
|
308
337
|
return `${e}`;
|
|
309
338
|
}
|
|
310
|
-
var
|
|
339
|
+
var Se = {
|
|
311
340
|
"==": (e, t) => e == t,
|
|
312
341
|
"===": (e, t) => e === t,
|
|
313
342
|
"!=": (e, t) => e != t,
|
|
314
343
|
"!==": (e, t) => e !== t,
|
|
315
|
-
">": (e, t) =>
|
|
316
|
-
">=": (e, t) =>
|
|
344
|
+
">": (e, t) => W(e) > W(t),
|
|
345
|
+
">=": (e, t) => W(e) >= W(t),
|
|
317
346
|
"<": (e, t, n) => {
|
|
318
|
-
let r =
|
|
347
|
+
let r = W(e), i = W(t);
|
|
319
348
|
if (n === void 0) return r < i;
|
|
320
|
-
let a =
|
|
349
|
+
let a = W(n);
|
|
321
350
|
return r < i && i < a;
|
|
322
351
|
},
|
|
323
352
|
"<=": (e, t, n) => {
|
|
324
|
-
let r =
|
|
353
|
+
let r = W(e), i = W(t);
|
|
325
354
|
if (n === void 0) return r <= i;
|
|
326
|
-
let a =
|
|
355
|
+
let a = W(n);
|
|
327
356
|
return r <= i && i <= a;
|
|
328
357
|
},
|
|
329
|
-
"!!": async (e) => await
|
|
330
|
-
"!": async (e) => !await
|
|
331
|
-
"%": (e, t) =>
|
|
358
|
+
"!!": async (e) => await q(e),
|
|
359
|
+
"!": async (e) => !await q(e),
|
|
360
|
+
"%": (e, t) => W(e) % W(t),
|
|
332
361
|
log: (e) => (console.log(e), e),
|
|
333
|
-
in: (e, t) => t ?
|
|
334
|
-
cat: (...e) => e.map(
|
|
362
|
+
in: (e, t) => t ? B(t) ? t.indexOf(G(e)) !== -1 : V(t) ? t.includes(e) : !1 : !1,
|
|
363
|
+
cat: (...e) => e.map(G).join(""),
|
|
335
364
|
substr: (e, t, n) => {
|
|
336
|
-
let r =
|
|
365
|
+
let r = G(e), i = W(t);
|
|
337
366
|
if (n === void 0) return r.substr(i);
|
|
338
|
-
let a =
|
|
367
|
+
let a = W(n);
|
|
339
368
|
if (a < 0) {
|
|
340
369
|
let e = r.substr(i);
|
|
341
370
|
return e.substr(0, e.length + a);
|
|
342
371
|
}
|
|
343
372
|
return r.substr(i, a);
|
|
344
373
|
},
|
|
345
|
-
"+": (...e) => e.reduce((e, t) =>
|
|
346
|
-
"*": (...e) => e.reduce((e, t) =>
|
|
374
|
+
"+": (...e) => e.reduce((e, t) => W(e) + W(t), 0),
|
|
375
|
+
"*": (...e) => e.reduce((e, t) => W(e) * W(t), 1),
|
|
347
376
|
"-": (e, t) => {
|
|
348
|
-
let n =
|
|
349
|
-
return t === void 0 ? -n : n -
|
|
377
|
+
let n = W(e);
|
|
378
|
+
return t === void 0 ? -n : n - W(t);
|
|
350
379
|
},
|
|
351
|
-
"/": (e, t) =>
|
|
352
|
-
min: (...e) => Math.min(...e.map(
|
|
353
|
-
max: (...e) => Math.max(...e.map(
|
|
354
|
-
merge: (...e) => e.reduce((e, t) =>
|
|
380
|
+
"/": (e, t) => W(e) / W(t),
|
|
381
|
+
min: (...e) => Math.min(...e.map(W)),
|
|
382
|
+
max: (...e) => Math.max(...e.map(W)),
|
|
383
|
+
merge: (...e) => e.reduce((e, t) => V(t) ? e.concat(t) : e.concat([t]), []),
|
|
355
384
|
var(e, t) {
|
|
356
385
|
let n = arguments.length > 1 ? t : null;
|
|
357
386
|
if (e === "" || e === "." || e == null) return this;
|
|
358
387
|
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
359
|
-
let r =
|
|
388
|
+
let r = G(e);
|
|
360
389
|
if (r === "" || r === ".") return this;
|
|
361
390
|
let i = r.split("."), a = this;
|
|
362
391
|
for (let e of i) {
|
|
@@ -369,116 +398,116 @@ var we = {
|
|
|
369
398
|
return a === void 0 ? n : a;
|
|
370
399
|
},
|
|
371
400
|
async missing(...e) {
|
|
372
|
-
let t =
|
|
401
|
+
let t = V(e[0]) ? e[0] : e, n = [];
|
|
373
402
|
for (let e of t) {
|
|
374
|
-
let t = await
|
|
403
|
+
let t = await K({ var: e }, this);
|
|
375
404
|
(t === null || t === "") && n.push(`${e}`);
|
|
376
405
|
}
|
|
377
406
|
return n;
|
|
378
407
|
},
|
|
379
408
|
async missing_some(e, t) {
|
|
380
|
-
let n = await
|
|
381
|
-
if (!
|
|
382
|
-
let r = n.filter(
|
|
383
|
-
return t.filter(
|
|
409
|
+
let n = await K({ missing: t }, this);
|
|
410
|
+
if (!V(n) || !V(t)) return [];
|
|
411
|
+
let r = n.filter(B);
|
|
412
|
+
return t.filter(B).length - r.length >= W(e) ? [] : r;
|
|
384
413
|
},
|
|
385
414
|
invoke(...e) {
|
|
386
415
|
let [t, ...n] = e;
|
|
387
416
|
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
388
417
|
},
|
|
389
|
-
startsWith: (e, t) =>
|
|
390
|
-
endsWith: (e, t) =>
|
|
418
|
+
startsWith: (e, t) => B(e) && B(t) && e.startsWith(t),
|
|
419
|
+
endsWith: (e, t) => B(e) && B(t) && e.endsWith(t),
|
|
391
420
|
regexp_matches(e, t) {
|
|
392
421
|
let n = e, r = "";
|
|
393
|
-
if (
|
|
422
|
+
if (V(e)) {
|
|
394
423
|
let [t, i] = e;
|
|
395
424
|
n = t, r = i;
|
|
396
425
|
}
|
|
397
|
-
return !
|
|
426
|
+
return !B(n) || !B(r) ? !1 : new RegExp(n, r).test(G(t));
|
|
398
427
|
},
|
|
399
428
|
throw(e) {
|
|
400
|
-
throw Error(
|
|
429
|
+
throw Error(G(e));
|
|
401
430
|
}
|
|
402
431
|
};
|
|
403
|
-
async function
|
|
432
|
+
async function K(e, t) {
|
|
404
433
|
if (!e) return e;
|
|
405
|
-
if (
|
|
406
|
-
if (
|
|
407
|
-
if (!
|
|
408
|
-
let n =
|
|
409
|
-
switch (
|
|
434
|
+
if (H(e)) return K(await e, t);
|
|
435
|
+
if (V(e)) return Promise.all(e.map((e) => K(e, t)));
|
|
436
|
+
if (!U(e)) return e;
|
|
437
|
+
let n = Ce(e), r = n ? e[n] ?? [] : [];
|
|
438
|
+
switch (V(r) || (r = [r]), n) {
|
|
410
439
|
case "if":
|
|
411
440
|
case "?:":
|
|
412
|
-
for (let e = 0; e < r.length - 1; e += 2) if (await
|
|
413
|
-
return r.length % 2 == 1 ?
|
|
441
|
+
for (let e = 0; e < r.length - 1; e += 2) if (await q(await K(r[e], t))) return K(r[e + 1], t);
|
|
442
|
+
return r.length % 2 == 1 ? K(r[r.length - 1], t) : null;
|
|
414
443
|
case "and": {
|
|
415
444
|
let e = null;
|
|
416
|
-
for (let n of r) if (e = await
|
|
445
|
+
for (let n of r) if (e = await K(n, t), !await q(e)) return e;
|
|
417
446
|
return e;
|
|
418
447
|
}
|
|
419
448
|
case "or": {
|
|
420
449
|
let e = null;
|
|
421
|
-
for (let n of r) if (e = await
|
|
450
|
+
for (let n of r) if (e = await K(n, t), await q(e)) return e;
|
|
422
451
|
return e;
|
|
423
452
|
}
|
|
424
453
|
case "map": {
|
|
425
|
-
let e = await
|
|
426
|
-
return
|
|
454
|
+
let e = await K(r[0], t);
|
|
455
|
+
return V(e) ? await Promise.all(e.map((e) => K(r[1], e))) : [];
|
|
427
456
|
}
|
|
428
457
|
case "filter": {
|
|
429
|
-
let e = await
|
|
430
|
-
return
|
|
458
|
+
let e = await K(r[0], t);
|
|
459
|
+
return V(e) ? (await Promise.all(e.map(async (e) => ({
|
|
431
460
|
item: e,
|
|
432
|
-
shouldInclude: await
|
|
461
|
+
shouldInclude: await q(await K(r[1], e))
|
|
433
462
|
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
434
463
|
}
|
|
435
464
|
case "reduce": {
|
|
436
|
-
let e = await
|
|
437
|
-
if (!
|
|
438
|
-
let n = r[1], i = r.length > 2 ? await
|
|
439
|
-
for (let t of e) i = await
|
|
465
|
+
let e = await K(r[0], t);
|
|
466
|
+
if (!V(e)) return r.length > 2 ? await K(r[2], t) : null;
|
|
467
|
+
let n = r[1], i = r.length > 2 ? await K(r[2], t) : null;
|
|
468
|
+
for (let t of e) i = await K(n, {
|
|
440
469
|
current: t,
|
|
441
470
|
accumulator: i
|
|
442
471
|
});
|
|
443
472
|
return i;
|
|
444
473
|
}
|
|
445
474
|
case "all": {
|
|
446
|
-
let e = await
|
|
447
|
-
if (!
|
|
448
|
-
for (let t of e) if (!await
|
|
475
|
+
let e = await K(r[0], t);
|
|
476
|
+
if (!V(e) || e.length === 0) return !1;
|
|
477
|
+
for (let t of e) if (!await q(await K(r[1], t))) return !1;
|
|
449
478
|
return !0;
|
|
450
479
|
}
|
|
451
480
|
case "some": {
|
|
452
|
-
let e = await
|
|
453
|
-
if (!
|
|
454
|
-
for (let t of e) if (await
|
|
481
|
+
let e = await K(r[0], t);
|
|
482
|
+
if (!V(e)) return !1;
|
|
483
|
+
for (let t of e) if (await q(await K(r[1], t))) return !0;
|
|
455
484
|
return !1;
|
|
456
485
|
}
|
|
457
486
|
case "none": {
|
|
458
|
-
let e = await
|
|
459
|
-
if (!
|
|
460
|
-
for (let t of e) if (await
|
|
487
|
+
let e = await K(r[0], t);
|
|
488
|
+
if (!V(e)) return !0;
|
|
489
|
+
for (let t of e) if (await q(await K(r[1], t))) return !1;
|
|
461
490
|
return !0;
|
|
462
491
|
}
|
|
463
492
|
case "catch": try {
|
|
464
|
-
return await
|
|
493
|
+
return await K(r[0], t);
|
|
465
494
|
} catch (e) {
|
|
466
|
-
return
|
|
495
|
+
return U(e) ? await K(e, t) : r[1] ? await K(r[1], e) : e instanceof Error ? e.message : e;
|
|
467
496
|
}
|
|
468
497
|
}
|
|
469
|
-
let i = await Promise.all(r.map((e) =>
|
|
498
|
+
let i = await Promise.all(r.map((e) => K(e, t))), a = n ? Se[n] : void 0;
|
|
470
499
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
471
500
|
return a.apply(t, i);
|
|
472
501
|
}
|
|
473
|
-
async function
|
|
474
|
-
return
|
|
502
|
+
async function q(e) {
|
|
503
|
+
return H(e) ? q(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
475
504
|
}
|
|
476
|
-
function
|
|
505
|
+
function Ce(e) {
|
|
477
506
|
return Object.keys(e)[0];
|
|
478
507
|
}
|
|
479
508
|
//#endregion
|
|
480
509
|
//#region src/lifecycle/rules-logic.ts
|
|
481
|
-
var
|
|
510
|
+
var we = I(({ client: e }) => O({
|
|
482
511
|
source: {
|
|
483
512
|
stateSnapshot: e.stateSnapshotStore,
|
|
484
513
|
predicates: e.predicates.listStore,
|
|
@@ -497,7 +526,7 @@ var Ee = I(({ client: e }) => O({
|
|
|
497
526
|
let { bucket: e } = await t.getBucket();
|
|
498
527
|
return e;
|
|
499
528
|
}, e), {});
|
|
500
|
-
return await
|
|
529
|
+
return await K(a, {
|
|
501
530
|
responses: i,
|
|
502
531
|
location: typeof e.location == "object" ? {
|
|
503
532
|
hash: e.location.hash,
|
|
@@ -517,15 +546,15 @@ var Ee = I(({ client: e }) => O({
|
|
|
517
546
|
});
|
|
518
547
|
}
|
|
519
548
|
}));
|
|
520
|
-
function
|
|
521
|
-
return L(
|
|
549
|
+
function Te(e) {
|
|
550
|
+
return L(we, e);
|
|
522
551
|
}
|
|
523
552
|
//#endregion
|
|
524
553
|
//#region src/ping.ts
|
|
525
|
-
var
|
|
554
|
+
var Ee = 6e3, De = E("last_ping", "global"), Oe = async (e) => {
|
|
526
555
|
try {
|
|
527
|
-
let t = Date.now(), n = w.get(
|
|
528
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
556
|
+
let t = Date.now(), n = w.get(De), r = 0;
|
|
557
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < Ee) return !0;
|
|
529
558
|
let i = {
|
|
530
559
|
projectId: e.projectId,
|
|
531
560
|
path: window.location.pathname
|
|
@@ -536,27 +565,27 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
|
|
|
536
565
|
} catch {
|
|
537
566
|
return !1;
|
|
538
567
|
}
|
|
539
|
-
},
|
|
540
|
-
let t =
|
|
568
|
+
}, J = j("lifecycle"), ke = I(({ client: e }) => {
|
|
569
|
+
let t = J.store(!1), r = P(void 0, {
|
|
541
570
|
skipVoid: !1,
|
|
542
|
-
domain:
|
|
571
|
+
domain: J
|
|
543
572
|
}), i = P(void 0, {
|
|
544
573
|
skipVoid: !1,
|
|
545
|
-
domain:
|
|
546
|
-
}), a =
|
|
574
|
+
domain: J
|
|
575
|
+
}), a = J.store("idle"), o = J.store([]), s = P(void 0, {
|
|
547
576
|
skipVoid: !1,
|
|
548
|
-
domain:
|
|
577
|
+
domain: J
|
|
549
578
|
}), c = P(void 0, {
|
|
550
579
|
skipVoid: !1,
|
|
551
|
-
domain:
|
|
580
|
+
domain: J
|
|
552
581
|
}), l = N(), u = N(), d = N(), p = N(), m = N(), h = N();
|
|
553
582
|
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
|
|
554
583
|
let g = M(() => {
|
|
555
|
-
|
|
584
|
+
Oe(e);
|
|
556
585
|
}), _ = M(async () => {
|
|
557
586
|
await ee();
|
|
558
587
|
}), v = M(async () => {
|
|
559
|
-
await
|
|
588
|
+
await se(e);
|
|
560
589
|
}), y = O({ effect: v }), b = O({
|
|
561
590
|
source: o,
|
|
562
591
|
effect: async (e) => {
|
|
@@ -679,13 +708,13 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
|
|
|
679
708
|
setCondition: h
|
|
680
709
|
};
|
|
681
710
|
});
|
|
682
|
-
function
|
|
683
|
-
return L(
|
|
711
|
+
function Ae(e) {
|
|
712
|
+
return L(ke, e);
|
|
684
713
|
}
|
|
685
714
|
//#endregion
|
|
686
715
|
//#region src/entities/predicate/predicate.ts
|
|
687
|
-
var
|
|
688
|
-
let t =
|
|
716
|
+
var je = j("predicate"), Me = I(({ client: e }) => {
|
|
717
|
+
let t = je.store({}), n = A(t, { register(e, t) {
|
|
689
718
|
return {
|
|
690
719
|
...e,
|
|
691
720
|
[t.name]: {
|
|
@@ -743,16 +772,16 @@ var Ne = j("predicate"), Pe = I(({ client: e }) => {
|
|
|
743
772
|
getEvokablePredicate: s
|
|
744
773
|
};
|
|
745
774
|
});
|
|
746
|
-
function
|
|
747
|
-
return L(
|
|
775
|
+
function Ne(e) {
|
|
776
|
+
return L(Me, e);
|
|
748
777
|
}
|
|
749
|
-
var
|
|
778
|
+
var Pe = (e, t, n) => {
|
|
750
779
|
n.register({
|
|
751
780
|
name: e,
|
|
752
781
|
predicate: t
|
|
753
782
|
});
|
|
754
|
-
},
|
|
755
|
-
let t =
|
|
783
|
+
}, Y = j("feature"), Fe = I(({ client: e }) => {
|
|
784
|
+
let t = Y.store({}), n = Y.store([]), i = A(t, { register(e, t) {
|
|
756
785
|
return {
|
|
757
786
|
...e,
|
|
758
787
|
[t.id]: t.feature
|
|
@@ -913,16 +942,16 @@ var Ie = (e, t, n) => {
|
|
|
913
942
|
getEvokableFeature: p
|
|
914
943
|
};
|
|
915
944
|
});
|
|
916
|
-
function
|
|
917
|
-
return L(
|
|
945
|
+
function Ie(e) {
|
|
946
|
+
return L(Fe, e);
|
|
918
947
|
}
|
|
919
|
-
var
|
|
948
|
+
var Le = (e, t, n) => {
|
|
920
949
|
n.register({
|
|
921
950
|
id: e,
|
|
922
951
|
feature: t
|
|
923
952
|
});
|
|
924
|
-
},
|
|
925
|
-
function
|
|
953
|
+
}, X = j("history");
|
|
954
|
+
function Re(e, t) {
|
|
926
955
|
return {
|
|
927
956
|
id: ne(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
928
957
|
node: t,
|
|
@@ -930,9 +959,9 @@ function J(e, t) {
|
|
|
930
959
|
experienceId: e
|
|
931
960
|
};
|
|
932
961
|
}
|
|
933
|
-
var
|
|
934
|
-
let e =
|
|
935
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
962
|
+
var ze = I(() => {
|
|
963
|
+
let e = X.store({ entries: [] }), t = X.event(), n = X.event(), r = X.event(), i = X.event();
|
|
964
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, Re(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), Re(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
936
965
|
function a(e, t) {
|
|
937
966
|
let n = {
|
|
938
967
|
lastStepIndex: -1,
|
|
@@ -962,20 +991,20 @@ var Ve = I(() => {
|
|
|
962
991
|
entriesStore: e.map((e) => e.entries)
|
|
963
992
|
};
|
|
964
993
|
});
|
|
965
|
-
function
|
|
966
|
-
return L(
|
|
994
|
+
function Be() {
|
|
995
|
+
return L(ze);
|
|
967
996
|
}
|
|
968
997
|
//#endregion
|
|
969
998
|
//#region src/utils/events.ts
|
|
970
|
-
var
|
|
999
|
+
var Ve = 0, He = (e) => {
|
|
971
1000
|
let t = P([]);
|
|
972
1001
|
return t.on(e, (e, t) => [...e, {
|
|
973
|
-
id:
|
|
1002
|
+
id: Ve++,
|
|
974
1003
|
at: /* @__PURE__ */ new Date(),
|
|
975
1004
|
payload: t
|
|
976
1005
|
}]), t;
|
|
977
|
-
},
|
|
978
|
-
let e =
|
|
1006
|
+
}, Ue = j("field"), We = I(() => {
|
|
1007
|
+
let e = Ue.store({}), t = A(e, {
|
|
979
1008
|
register(e, t) {
|
|
980
1009
|
return {
|
|
981
1010
|
...e,
|
|
@@ -1023,13 +1052,13 @@ var Ue = 0, We = (e) => {
|
|
|
1023
1052
|
getByName: c
|
|
1024
1053
|
};
|
|
1025
1054
|
});
|
|
1026
|
-
function
|
|
1027
|
-
return L(
|
|
1055
|
+
function Ge() {
|
|
1056
|
+
return L(We);
|
|
1028
1057
|
}
|
|
1029
1058
|
//#endregion
|
|
1030
1059
|
//#region src/entities/step/step.ts
|
|
1031
|
-
var
|
|
1032
|
-
let e =
|
|
1060
|
+
var Ke = j("step"), qe = I(() => {
|
|
1061
|
+
let e = Ke.store({}), t = A(e, { register(e, t) {
|
|
1033
1062
|
return {
|
|
1034
1063
|
...e,
|
|
1035
1064
|
[t.step.id]: t.step
|
|
@@ -1053,16 +1082,45 @@ var Je = j("step"), Ye = I(() => {
|
|
|
1053
1082
|
indexStore: e
|
|
1054
1083
|
};
|
|
1055
1084
|
});
|
|
1056
|
-
function
|
|
1057
|
-
return L(
|
|
1085
|
+
function Je() {
|
|
1086
|
+
return L(qe);
|
|
1058
1087
|
}
|
|
1059
|
-
function
|
|
1088
|
+
function Ye(e, t) {
|
|
1089
|
+
t.register(e);
|
|
1090
|
+
}
|
|
1091
|
+
//#endregion
|
|
1092
|
+
//#region src/entities/content/content.ts
|
|
1093
|
+
var Xe = j("content"), Ze = I(() => {
|
|
1094
|
+
let e = Xe.store({}), t = A(e, { register(e, t) {
|
|
1095
|
+
return {
|
|
1096
|
+
...e,
|
|
1097
|
+
[t.content.id]: t.content
|
|
1098
|
+
};
|
|
1099
|
+
} });
|
|
1100
|
+
function n(e) {
|
|
1101
|
+
t.register({ content: e });
|
|
1102
|
+
}
|
|
1103
|
+
let r = e.map((e) => Object.values(e));
|
|
1104
|
+
function i(t) {
|
|
1105
|
+
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
1106
|
+
}
|
|
1107
|
+
return {
|
|
1108
|
+
register: n,
|
|
1109
|
+
getById: i,
|
|
1110
|
+
listStore: r,
|
|
1111
|
+
indexStore: e
|
|
1112
|
+
};
|
|
1113
|
+
});
|
|
1114
|
+
function Qe() {
|
|
1115
|
+
return L(Ze);
|
|
1116
|
+
}
|
|
1117
|
+
function $e(e, t) {
|
|
1060
1118
|
t.register(e);
|
|
1061
1119
|
}
|
|
1062
1120
|
//#endregion
|
|
1063
1121
|
//#region src/entities/action/action.ts
|
|
1064
|
-
var
|
|
1065
|
-
let t =
|
|
1122
|
+
var et = j("action"), tt = I(({ client: e }) => {
|
|
1123
|
+
let t = et.store({}), n = A(t, { register(e, t) {
|
|
1066
1124
|
return {
|
|
1067
1125
|
...e,
|
|
1068
1126
|
[t.key]: {
|
|
@@ -1120,10 +1178,10 @@ var Qe = j("action"), $e = I(({ client: e }) => {
|
|
|
1120
1178
|
getEvokableAction: s
|
|
1121
1179
|
};
|
|
1122
1180
|
});
|
|
1123
|
-
function
|
|
1124
|
-
return L(
|
|
1181
|
+
function nt(e) {
|
|
1182
|
+
return L(tt, e);
|
|
1125
1183
|
}
|
|
1126
|
-
var
|
|
1184
|
+
var rt = (e, t, n) => {
|
|
1127
1185
|
n.register({
|
|
1128
1186
|
key: e,
|
|
1129
1187
|
action: t
|
|
@@ -1131,7 +1189,7 @@ var tt = (e, t, n) => {
|
|
|
1131
1189
|
};
|
|
1132
1190
|
//#endregion
|
|
1133
1191
|
//#region src/entities/response/response-validation.ts
|
|
1134
|
-
function
|
|
1192
|
+
function Z(e, t, n, r) {
|
|
1135
1193
|
return {
|
|
1136
1194
|
fieldKey: e.key,
|
|
1137
1195
|
userMessage: n,
|
|
@@ -1139,62 +1197,62 @@ function Y(e, t, n, r) {
|
|
|
1139
1197
|
value: t
|
|
1140
1198
|
};
|
|
1141
1199
|
}
|
|
1142
|
-
function
|
|
1200
|
+
function Q(e) {
|
|
1143
1201
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1144
1202
|
}
|
|
1145
|
-
function
|
|
1203
|
+
function it(e) {
|
|
1146
1204
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1147
1205
|
}
|
|
1148
|
-
function
|
|
1206
|
+
function at(e) {
|
|
1149
1207
|
try {
|
|
1150
1208
|
return JSON.stringify(e), !0;
|
|
1151
1209
|
} catch {
|
|
1152
1210
|
return !1;
|
|
1153
1211
|
}
|
|
1154
1212
|
}
|
|
1155
|
-
function
|
|
1213
|
+
function ot(e, t) {
|
|
1156
1214
|
return t.find((t) => t.key === e) ?? null;
|
|
1157
1215
|
}
|
|
1158
|
-
function
|
|
1216
|
+
function st(e, t) {
|
|
1159
1217
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1160
1218
|
}
|
|
1161
|
-
function
|
|
1162
|
-
if (e.type !== "object" ||
|
|
1219
|
+
function ct(e, t) {
|
|
1220
|
+
if (e.type !== "object" || Q(t)) return null;
|
|
1163
1221
|
if (e.multiple) {
|
|
1164
|
-
if (!Array.isArray(t)) return
|
|
1222
|
+
if (!Array.isArray(t)) return Z(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1165
1223
|
for (let n of t) {
|
|
1166
|
-
if (typeof n != "object" || !n) return
|
|
1167
|
-
if (!
|
|
1224
|
+
if (typeof n != "object" || !n) return Z(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
1225
|
+
if (!at(n)) return Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1168
1226
|
}
|
|
1169
1227
|
return null;
|
|
1170
1228
|
}
|
|
1171
|
-
return Array.isArray(t) ?
|
|
1229
|
+
return Array.isArray(t) ? Z(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? Z(e, t, "This field expects an object value", "Field expects an object value.") : at(t) ? null : Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1172
1230
|
}
|
|
1173
|
-
function
|
|
1174
|
-
if (
|
|
1231
|
+
function lt(e, t) {
|
|
1232
|
+
if (Q(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1175
1233
|
let n = Array.isArray(t) ? t : [t];
|
|
1176
1234
|
if (e.type === "object") {
|
|
1177
1235
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1178
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
1236
|
+
return n.every((e) => r.has(JSON.stringify(e))) ? null : Z(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
1179
1237
|
}
|
|
1180
1238
|
let r = e.options.map((e) => e.value);
|
|
1181
|
-
return n.every((e) => !
|
|
1239
|
+
return n.every((e) => !it(e) || e === null ? !1 : r.includes(e)) ? null : Z(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
1182
1240
|
}
|
|
1183
|
-
async function
|
|
1184
|
-
if (n.validation && !e(n.validation) && !
|
|
1241
|
+
async function ut(t, n, r, i) {
|
|
1242
|
+
if (n.validation && !e(n.validation) && !Q(r)) {
|
|
1185
1243
|
let e = i ? {
|
|
1186
1244
|
$input: r,
|
|
1187
1245
|
responses: i
|
|
1188
1246
|
} : { $input: r }, a = await t(n.validation, e);
|
|
1189
|
-
if (typeof a == "string") return
|
|
1190
|
-
if (a === !1) return
|
|
1247
|
+
if (typeof a == "string") return Z(n, r, a, `Field validation resulted in an error: ${a}.`);
|
|
1248
|
+
if (a === !1) return Z(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
1191
1249
|
}
|
|
1192
|
-
return n.required &&
|
|
1250
|
+
return n.required && Q(r) ? Z(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? Z(n, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
1193
1251
|
}
|
|
1194
1252
|
//#endregion
|
|
1195
1253
|
//#region src/entities/response/response.ts
|
|
1196
|
-
var
|
|
1197
|
-
let t =
|
|
1254
|
+
var dt = j("response"), ft = I(({ client: e }) => {
|
|
1255
|
+
let t = dt.store({}), r = N(), i = N(), a = A(t, {
|
|
1198
1256
|
register(e, t) {
|
|
1199
1257
|
return {
|
|
1200
1258
|
...e,
|
|
@@ -1233,7 +1291,7 @@ var ct = j("response"), lt = I(({ client: e }) => {
|
|
|
1233
1291
|
...t,
|
|
1234
1292
|
...n
|
|
1235
1293
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1236
|
-
let o =
|
|
1294
|
+
let o = ot(t, e);
|
|
1237
1295
|
if (!o) {
|
|
1238
1296
|
r.push({
|
|
1239
1297
|
fieldKey: t,
|
|
@@ -1243,17 +1301,17 @@ var ct = j("response"), lt = I(({ client: e }) => {
|
|
|
1243
1301
|
});
|
|
1244
1302
|
return;
|
|
1245
1303
|
}
|
|
1246
|
-
let c =
|
|
1304
|
+
let c = st(o, n), l = await ut(s, o, c, a);
|
|
1247
1305
|
if (l) {
|
|
1248
1306
|
r.push(l);
|
|
1249
1307
|
return;
|
|
1250
1308
|
}
|
|
1251
|
-
let u =
|
|
1309
|
+
let u = ct(o, c);
|
|
1252
1310
|
if (u) {
|
|
1253
1311
|
r.push(u);
|
|
1254
1312
|
return;
|
|
1255
1313
|
}
|
|
1256
|
-
let d =
|
|
1314
|
+
let d = lt(o, c);
|
|
1257
1315
|
if (d) {
|
|
1258
1316
|
r.push(d);
|
|
1259
1317
|
return;
|
|
@@ -1332,13 +1390,13 @@ var ct = j("response"), lt = I(({ client: e }) => {
|
|
|
1332
1390
|
getByFieldName: _
|
|
1333
1391
|
};
|
|
1334
1392
|
});
|
|
1335
|
-
function
|
|
1336
|
-
return L(
|
|
1393
|
+
function pt(e) {
|
|
1394
|
+
return L(ft, e);
|
|
1337
1395
|
}
|
|
1338
1396
|
//#endregion
|
|
1339
1397
|
//#region src/entities/condition/condition.ts
|
|
1340
|
-
var
|
|
1341
|
-
let e =
|
|
1398
|
+
var mt = j("condition"), ht = I(() => {
|
|
1399
|
+
let e = mt.store({}), t = A(e, { register(e, t) {
|
|
1342
1400
|
return {
|
|
1343
1401
|
...e,
|
|
1344
1402
|
[t.condition.id]: t.condition
|
|
@@ -1362,12 +1420,12 @@ var dt = j("condition"), ft = I(() => {
|
|
|
1362
1420
|
indexStore: e
|
|
1363
1421
|
};
|
|
1364
1422
|
});
|
|
1365
|
-
function
|
|
1366
|
-
return L(
|
|
1423
|
+
function gt() {
|
|
1424
|
+
return L(ht);
|
|
1367
1425
|
}
|
|
1368
1426
|
//#endregion
|
|
1369
1427
|
//#region src/utils/api-url.ts
|
|
1370
|
-
function
|
|
1428
|
+
function _t() {
|
|
1371
1429
|
if (f()) {
|
|
1372
1430
|
let e = [
|
|
1373
1431
|
document.currentScript,
|
|
@@ -1382,7 +1440,7 @@ function mt() {
|
|
|
1382
1440
|
}
|
|
1383
1441
|
//#endregion
|
|
1384
1442
|
//#region src/utils/search-params.ts
|
|
1385
|
-
function
|
|
1443
|
+
function vt() {
|
|
1386
1444
|
if (!o()) return {};
|
|
1387
1445
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1388
1446
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -1400,13 +1458,13 @@ function ht() {
|
|
|
1400
1458
|
}
|
|
1401
1459
|
//#endregion
|
|
1402
1460
|
//#region src/entities/session/session.ts
|
|
1403
|
-
var
|
|
1404
|
-
function
|
|
1461
|
+
var yt = E("session", "global");
|
|
1462
|
+
function bt() {
|
|
1405
1463
|
return l() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1406
1464
|
}
|
|
1407
|
-
function
|
|
1465
|
+
function xt() {
|
|
1408
1466
|
if (!u()) return null;
|
|
1409
|
-
let e = w.get(
|
|
1467
|
+
let e = w.get(yt);
|
|
1410
1468
|
if (!e.isSet()) return null;
|
|
1411
1469
|
try {
|
|
1412
1470
|
return e.json();
|
|
@@ -1414,8 +1472,8 @@ function _t() {
|
|
|
1414
1472
|
return null;
|
|
1415
1473
|
}
|
|
1416
1474
|
}
|
|
1417
|
-
var
|
|
1418
|
-
let e =
|
|
1475
|
+
var St = I(() => {
|
|
1476
|
+
let e = xt(), t = { id: e?.id ?? bt() };
|
|
1419
1477
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1420
1478
|
let n = P(t), r = A(n, {
|
|
1421
1479
|
setIsUser: (e, t) => ({
|
|
@@ -1444,7 +1502,7 @@ var vt = I(() => {
|
|
|
1444
1502
|
source: n,
|
|
1445
1503
|
effect: (e) => {
|
|
1446
1504
|
if (u()) try {
|
|
1447
|
-
w.get(
|
|
1505
|
+
w.get(yt).set(e);
|
|
1448
1506
|
} catch {}
|
|
1449
1507
|
}
|
|
1450
1508
|
})
|
|
@@ -1455,27 +1513,27 @@ var vt = I(() => {
|
|
|
1455
1513
|
removeIdentifier: r.removeIdentifier
|
|
1456
1514
|
};
|
|
1457
1515
|
});
|
|
1458
|
-
function
|
|
1459
|
-
return L(
|
|
1516
|
+
function Ct() {
|
|
1517
|
+
return L(St, void 0);
|
|
1460
1518
|
}
|
|
1461
1519
|
//#endregion
|
|
1462
1520
|
//#region src/utils/picked-config.ts
|
|
1463
|
-
function
|
|
1521
|
+
function wt() {
|
|
1464
1522
|
if (o()) return globalThis.window.pickedConfig;
|
|
1465
1523
|
}
|
|
1466
|
-
function
|
|
1467
|
-
if (o()) return
|
|
1524
|
+
function Tt() {
|
|
1525
|
+
if (o()) return wt()?.projectId;
|
|
1468
1526
|
}
|
|
1469
|
-
function
|
|
1527
|
+
function Et() {
|
|
1470
1528
|
if (!f()) return;
|
|
1471
1529
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1472
1530
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1473
1531
|
}
|
|
1474
|
-
function
|
|
1532
|
+
function Dt(e) {
|
|
1475
1533
|
if (e.projectId) return e.projectId;
|
|
1476
|
-
let t =
|
|
1534
|
+
let t = Tt();
|
|
1477
1535
|
if (t) return t;
|
|
1478
|
-
let n =
|
|
1536
|
+
let n = Et();
|
|
1479
1537
|
if (n) return n;
|
|
1480
1538
|
throw Error("projectId is required. You can provide it via one of:\n (1) createClient({ projectId }) options;\n (2) window.pickedConfig = { projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes a data-projectid (or project-id) attribute.");
|
|
1481
1539
|
}
|
|
@@ -1484,7 +1542,7 @@ function Ct(e) {
|
|
|
1484
1542
|
function $(e) {
|
|
1485
1543
|
return e == null || e === "" || Number.isNaN(e);
|
|
1486
1544
|
}
|
|
1487
|
-
var
|
|
1545
|
+
var Ot = {
|
|
1488
1546
|
default: (e, t) => $(e) ? String(t ?? "") : String(e),
|
|
1489
1547
|
append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
|
|
1490
1548
|
prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
|
|
@@ -1505,24 +1563,24 @@ var wt = {
|
|
|
1505
1563
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1506
1564
|
}
|
|
1507
1565
|
};
|
|
1508
|
-
function
|
|
1566
|
+
function kt(e) {
|
|
1509
1567
|
return typeof e == "object" && !!e;
|
|
1510
1568
|
}
|
|
1511
|
-
function
|
|
1569
|
+
function At(e, t) {
|
|
1512
1570
|
let n = t;
|
|
1513
|
-
for (let t of e.split(".")) if (
|
|
1571
|
+
for (let t of e.split(".")) if (kt(n) && t in n) n = n[t];
|
|
1514
1572
|
else return;
|
|
1515
1573
|
return typeof n == "function" ? n() : n;
|
|
1516
1574
|
}
|
|
1517
|
-
function
|
|
1518
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1575
|
+
function jt(e, t) {
|
|
1576
|
+
let n = e.split("|").map((e) => e.trim()), r = At(n.shift() ?? "", t);
|
|
1519
1577
|
for (let e of n) {
|
|
1520
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1578
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Ot[i];
|
|
1521
1579
|
o && (r = o(r, a));
|
|
1522
1580
|
}
|
|
1523
1581
|
return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1524
1582
|
}
|
|
1525
|
-
function
|
|
1583
|
+
function Mt(e, t) {
|
|
1526
1584
|
let n = "", r = 0;
|
|
1527
1585
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1528
1586
|
r += 2;
|
|
@@ -1534,15 +1592,17 @@ function Ot(e, t) {
|
|
|
1534
1592
|
}
|
|
1535
1593
|
i += e[r++];
|
|
1536
1594
|
}
|
|
1537
|
-
n +=
|
|
1595
|
+
n += jt(i.trim(), t);
|
|
1538
1596
|
} else n += e[r++];
|
|
1539
1597
|
return n;
|
|
1540
1598
|
}
|
|
1541
1599
|
//#endregion
|
|
1542
1600
|
//#region src/picked.ts
|
|
1543
|
-
var
|
|
1601
|
+
var Nt = class {
|
|
1544
1602
|
static logger = r;
|
|
1545
1603
|
options;
|
|
1604
|
+
dataSource = null;
|
|
1605
|
+
contentLoader;
|
|
1546
1606
|
plugins = {};
|
|
1547
1607
|
eventBus = N();
|
|
1548
1608
|
events;
|
|
@@ -1550,61 +1610,62 @@ var kt = class {
|
|
|
1550
1610
|
apiUrl;
|
|
1551
1611
|
dashboardUrl;
|
|
1552
1612
|
documentationSiteUrl;
|
|
1553
|
-
session =
|
|
1554
|
-
searchParams =
|
|
1555
|
-
history =
|
|
1556
|
-
components =
|
|
1613
|
+
session = Ct();
|
|
1614
|
+
searchParams = vt();
|
|
1615
|
+
history = Be();
|
|
1616
|
+
components = me({ client: this });
|
|
1557
1617
|
experienceInstances = b({ client: this });
|
|
1558
|
-
experiences =
|
|
1559
|
-
frameworks =
|
|
1560
|
-
predicates =
|
|
1561
|
-
features =
|
|
1562
|
-
conditions =
|
|
1563
|
-
fields =
|
|
1564
|
-
responses =
|
|
1565
|
-
steps =
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1618
|
+
experiences = oe({ client: this });
|
|
1619
|
+
frameworks = _e({ client: this });
|
|
1620
|
+
predicates = Ne({ client: this });
|
|
1621
|
+
features = Ie({ client: this });
|
|
1622
|
+
conditions = gt();
|
|
1623
|
+
fields = Ge();
|
|
1624
|
+
responses = pt({ client: this });
|
|
1625
|
+
steps = Je();
|
|
1626
|
+
contents = Qe();
|
|
1627
|
+
actions = nt({ client: this });
|
|
1628
|
+
stateSnapshotStore = be({ client: this });
|
|
1629
|
+
evaluateRuleLogicFx = Te({ client: this });
|
|
1569
1630
|
start;
|
|
1570
1631
|
readyStore;
|
|
1571
1632
|
preconditionPassedStore;
|
|
1572
1633
|
conditionPassedStore;
|
|
1573
1634
|
lifecycleStageStore;
|
|
1574
|
-
lifecycle =
|
|
1635
|
+
lifecycle = Ae({ client: this });
|
|
1575
1636
|
renderStringFx = O({
|
|
1576
1637
|
source: this.responses.listStore,
|
|
1577
1638
|
effect: (e, { template: t, context: n }) => {
|
|
1578
1639
|
let r = {};
|
|
1579
1640
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1580
|
-
return
|
|
1641
|
+
return Mt(t, {
|
|
1581
1642
|
...n,
|
|
1582
1643
|
responses: r
|
|
1583
1644
|
});
|
|
1584
1645
|
}
|
|
1585
1646
|
});
|
|
1586
1647
|
constructor(e) {
|
|
1587
|
-
this.events =
|
|
1648
|
+
this.events = He(this.eventBus), this.projectId = Dt(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || _t(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
|
|
1588
1649
|
type: "load",
|
|
1589
1650
|
version: te()
|
|
1590
1651
|
});
|
|
1591
1652
|
}
|
|
1592
1653
|
registerFramework = (e) => {
|
|
1593
|
-
|
|
1654
|
+
ve(e, this.frameworks);
|
|
1594
1655
|
};
|
|
1595
1656
|
registerComponent = (e, t) => {
|
|
1596
|
-
|
|
1657
|
+
z(e, t, this.components);
|
|
1597
1658
|
};
|
|
1598
1659
|
registerPlugin = (e) => {
|
|
1599
|
-
|
|
1660
|
+
le(this, e, this.plugins);
|
|
1600
1661
|
let t = this.plugins[e.name];
|
|
1601
1662
|
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1602
1663
|
};
|
|
1603
1664
|
registerFeature = (e, t) => {
|
|
1604
|
-
|
|
1665
|
+
Le(e, t, this.features);
|
|
1605
1666
|
};
|
|
1606
1667
|
registerPredicate = (e, t) => {
|
|
1607
|
-
|
|
1668
|
+
Pe(e, t, this.predicates);
|
|
1608
1669
|
};
|
|
1609
1670
|
registerCondition = (e) => {
|
|
1610
1671
|
this.conditions.register(e);
|
|
@@ -1613,13 +1674,16 @@ var kt = class {
|
|
|
1613
1674
|
this.fields.register(e);
|
|
1614
1675
|
};
|
|
1615
1676
|
registerStep = (e) => {
|
|
1616
|
-
|
|
1677
|
+
Ye(e, this.steps);
|
|
1678
|
+
};
|
|
1679
|
+
registerContent = (e) => {
|
|
1680
|
+
$e(e, this.contents);
|
|
1617
1681
|
};
|
|
1618
1682
|
registerAction = (e, t) => {
|
|
1619
|
-
|
|
1683
|
+
rt(e, t, this.actions);
|
|
1620
1684
|
};
|
|
1621
1685
|
registerExperience = (e) => {
|
|
1622
|
-
e.component &&
|
|
1686
|
+
e.component && z(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1623
1687
|
};
|
|
1624
1688
|
launchExperienceById = async (e, t) => {
|
|
1625
1689
|
this.experiences.launch({
|
|
@@ -1704,20 +1768,20 @@ var kt = class {
|
|
|
1704
1768
|
};
|
|
1705
1769
|
//#endregion
|
|
1706
1770
|
//#region src/entities/component/lazyComponent.ts
|
|
1707
|
-
function
|
|
1771
|
+
function Pt(e) {
|
|
1708
1772
|
return {
|
|
1709
1773
|
$$type: "lazy-component",
|
|
1710
1774
|
load: e
|
|
1711
1775
|
};
|
|
1712
1776
|
}
|
|
1713
|
-
function
|
|
1777
|
+
function Ft(e) {
|
|
1714
1778
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1715
1779
|
}
|
|
1716
1780
|
//#endregion
|
|
1717
1781
|
//#region src/exports.ts
|
|
1718
|
-
var
|
|
1719
|
-
let t = new
|
|
1782
|
+
var It = (e) => {
|
|
1783
|
+
let t = new Nt(e);
|
|
1720
1784
|
return d(t), t;
|
|
1721
1785
|
};
|
|
1722
1786
|
//#endregion
|
|
1723
|
-
export {
|
|
1787
|
+
export { Nt as Picked, It as createClient, ce as createPluginEffect, E as createStorageKey, n as evaluateRuleLogic, wt as getPickedConfig, Ft as isLazyLoader, _ as isPickedRoot, Pt as lazyComponent, w as localStore, T as sessionStore, C as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };
|