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