@picked/client 0.0.1-dev.1778120127377 → 0.0.1-dev.1778212587319
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-zfqEYPyX.js → api-Cwiixs03.js} +1 -1
- package/dist/{api-BM3zWj3k.cjs → api-Cz_3UuGL.cjs} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +366 -346
- package/dist/esm/plugins/dynamic-experiences/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +26 -10
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-DDZR8zjM.cjs +1 -0
- package/dist/{experience-instance-BrLWgVAN.js → experience-instance-dwfbKgOd.js} +178 -179
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts +28 -16
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/picked.d.ts +8 -14
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +19 -0
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/experience-instance-Ct3ogC7n.cjs +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -2,15 +2,15 @@ import { t as e } from "../object-DvUDOytC.js";
|
|
|
2
2
|
import { n as t, t as n } from "../rules-logic-D_CVBuv7.js";
|
|
3
3
|
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
|
-
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-
|
|
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-dwfbKgOd.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-
|
|
8
|
-
import { t as
|
|
9
|
-
import { attach as
|
|
10
|
-
import { createFactory as
|
|
7
|
+
import { n as D, r as te } from "../api-Cwiixs03.js";
|
|
8
|
+
import { t as O } from "../id-CRqy981z.js";
|
|
9
|
+
import { attach as k, combine as A, createApi as j, createDomain as M, createEffect as N, createEvent as P, createStore as F, sample as I } from "effector";
|
|
10
|
+
import { createFactory as L, invoke as R } from "@withease/factories";
|
|
11
11
|
//#region src/entities/experience/experience.ts
|
|
12
|
-
var
|
|
13
|
-
let i =
|
|
12
|
+
var ne = M("experience"), re = L(({ client: e, experience: r }) => {
|
|
13
|
+
let i = ne.store(r), a = j(i, { merge(e, t) {
|
|
14
14
|
return {
|
|
15
15
|
...e,
|
|
16
16
|
...t.experience
|
|
@@ -20,7 +20,7 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
|
|
|
20
20
|
decisionLogic: e.condition,
|
|
21
21
|
targetSelectors: e.targets,
|
|
22
22
|
initializeOpenLogic: e.initializeOpen
|
|
23
|
-
})), s =
|
|
23
|
+
})), s = A(i, e.components.listStore, (e, t) => (e.componentName ? t.find((t) => t.name === e.componentName) : void 0) || t.find((t) => t.name === `experience:${e.id}`) || t.find((e) => e.name === "experience"), { skipVoid: !1 }), c = A(i, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
|
|
24
24
|
let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(x).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
|
|
25
25
|
return {
|
|
26
26
|
steps: r,
|
|
@@ -28,7 +28,7 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
|
|
|
28
28
|
edges: e.edges,
|
|
29
29
|
conditions: i
|
|
30
30
|
};
|
|
31
|
-
}), l = r.actions ?? [], u, d =
|
|
31
|
+
}), l = r.actions ?? [], u, d = k({
|
|
32
32
|
source: o,
|
|
33
33
|
effect: (t, n) => {
|
|
34
34
|
let i = S(t.targetSelectors, r.id);
|
|
@@ -36,8 +36,8 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
|
|
|
36
36
|
n ? e.experienceInstances.spawn(u, t, n) : e.experienceInstances.spawn(u, t);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
}), f =
|
|
40
|
-
source:
|
|
39
|
+
}), f = k({
|
|
40
|
+
source: A({
|
|
41
41
|
preconditionPassed: e.preconditionPassedStore,
|
|
42
42
|
isUser: e.session.store.map((e) => e.isUser, { skipVoid: !1 }),
|
|
43
43
|
config: o
|
|
@@ -61,22 +61,22 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
|
|
|
61
61
|
shouldInitialiseFx: f
|
|
62
62
|
}, u;
|
|
63
63
|
});
|
|
64
|
-
function
|
|
65
|
-
return
|
|
64
|
+
function ie(e) {
|
|
65
|
+
return R(re, e);
|
|
66
66
|
}
|
|
67
|
-
var
|
|
68
|
-
let t =
|
|
67
|
+
var ae = L(({ client: e }) => {
|
|
68
|
+
let t = ne.store({}), n = j(t, { register(e, t) {
|
|
69
69
|
return {
|
|
70
70
|
...e,
|
|
71
71
|
[t.id]: t
|
|
72
72
|
};
|
|
73
|
-
} }), r =
|
|
74
|
-
n.register(
|
|
73
|
+
} }), r = P(), i = N((t) => {
|
|
74
|
+
n.register(ie({
|
|
75
75
|
client: e,
|
|
76
76
|
experience: t
|
|
77
77
|
}));
|
|
78
78
|
});
|
|
79
|
-
|
|
79
|
+
I({
|
|
80
80
|
clock: r,
|
|
81
81
|
source: t,
|
|
82
82
|
filter: (e, t) => e[t.id] !== void 0,
|
|
@@ -89,7 +89,7 @@ var oe = I(({ client: e }) => {
|
|
|
89
89
|
experience: t,
|
|
90
90
|
strategy: "override"
|
|
91
91
|
});
|
|
92
|
-
}),
|
|
92
|
+
}), I({
|
|
93
93
|
clock: r,
|
|
94
94
|
source: t,
|
|
95
95
|
filter: (e, t) => e[t.id] === void 0,
|
|
@@ -103,7 +103,7 @@ var oe = I(({ client: e }) => {
|
|
|
103
103
|
function s(e) {
|
|
104
104
|
return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
|
|
105
105
|
}
|
|
106
|
-
let c =
|
|
106
|
+
let c = k({
|
|
107
107
|
source: t,
|
|
108
108
|
effect: async (e, t) => {
|
|
109
109
|
let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
|
|
@@ -125,7 +125,7 @@ var oe = I(({ client: e }) => {
|
|
|
125
125
|
getById: o,
|
|
126
126
|
getByKey: s,
|
|
127
127
|
launch: c,
|
|
128
|
-
open:
|
|
128
|
+
open: k({
|
|
129
129
|
source: {
|
|
130
130
|
experiences: t,
|
|
131
131
|
instances: e.experienceInstances.listStore
|
|
@@ -152,7 +152,7 @@ var oe = I(({ client: e }) => {
|
|
|
152
152
|
}
|
|
153
153
|
}),
|
|
154
154
|
listStore: a,
|
|
155
|
-
initialiseExperiencesFx:
|
|
155
|
+
initialiseExperiencesFx: k({
|
|
156
156
|
source: a,
|
|
157
157
|
effect: async (e) => {
|
|
158
158
|
await Promise.all(e.map(async (e) => {
|
|
@@ -162,20 +162,20 @@ var oe = I(({ client: e }) => {
|
|
|
162
162
|
})
|
|
163
163
|
};
|
|
164
164
|
});
|
|
165
|
-
function
|
|
166
|
-
return
|
|
165
|
+
function oe(e) {
|
|
166
|
+
return R(ae, e);
|
|
167
167
|
}
|
|
168
|
-
var
|
|
168
|
+
var se = async (e) => {
|
|
169
169
|
await e.experiences.initialiseExperiencesFx();
|
|
170
170
|
};
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/entities/plugin/plugin.ts
|
|
173
|
-
function
|
|
174
|
-
return
|
|
173
|
+
function ce(e) {
|
|
174
|
+
return N(async () => {
|
|
175
175
|
await e();
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
-
var
|
|
178
|
+
var le = (e, t, n) => {
|
|
179
179
|
let r = t.name, i = t.setup(e);
|
|
180
180
|
if (i) {
|
|
181
181
|
let e = n[r] ?? {};
|
|
@@ -184,29 +184,29 @@ var ue = (e, t, n) => {
|
|
|
184
184
|
...i
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
},
|
|
187
|
+
}, ue = M("component"), de = L(({ client: e, component: t, name: n }) => ({
|
|
188
188
|
name: n,
|
|
189
189
|
component: t,
|
|
190
190
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
191
191
|
}));
|
|
192
|
-
function
|
|
193
|
-
return
|
|
192
|
+
function fe(e) {
|
|
193
|
+
return R(de, e);
|
|
194
194
|
}
|
|
195
|
-
var
|
|
196
|
-
let t =
|
|
195
|
+
var pe = L(({ client: e }) => {
|
|
196
|
+
let t = ue.store({}), n = j(t, { register(e, t) {
|
|
197
197
|
return {
|
|
198
198
|
...e,
|
|
199
199
|
[t.name]: t
|
|
200
200
|
};
|
|
201
|
-
} }), i =
|
|
202
|
-
|
|
201
|
+
} }), i = P();
|
|
202
|
+
I({
|
|
203
203
|
clock: i,
|
|
204
204
|
source: t,
|
|
205
205
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
206
206
|
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
207
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
207
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
208
208
|
clock: i,
|
|
209
|
-
fn: ({ name: t, component: n }) =>
|
|
209
|
+
fn: ({ name: t, component: n }) => fe({
|
|
210
210
|
client: e,
|
|
211
211
|
name: t,
|
|
212
212
|
component: n
|
|
@@ -223,27 +223,27 @@ var me = I(({ client: e }) => {
|
|
|
223
223
|
listStore: a
|
|
224
224
|
};
|
|
225
225
|
});
|
|
226
|
-
function
|
|
227
|
-
return
|
|
226
|
+
function me(e) {
|
|
227
|
+
return R(pe, e);
|
|
228
228
|
}
|
|
229
|
-
var
|
|
229
|
+
var he = (e, t, n) => {
|
|
230
230
|
n.register({
|
|
231
231
|
name: e,
|
|
232
232
|
component: t
|
|
233
233
|
});
|
|
234
|
-
},
|
|
235
|
-
let t =
|
|
234
|
+
}, ge = M("framework"), _e = L((e) => {
|
|
235
|
+
let t = ge.store({}), n = j(t, { register(e, t) {
|
|
236
236
|
return {
|
|
237
237
|
...e,
|
|
238
238
|
[t.name]: t.framework
|
|
239
239
|
};
|
|
240
|
-
} }), i =
|
|
241
|
-
|
|
240
|
+
} }), i = P();
|
|
241
|
+
I({
|
|
242
242
|
clock: i,
|
|
243
243
|
source: t,
|
|
244
244
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
245
245
|
fn: (e, { name: t }) => `Framework '${t}' already registered. Registering again will override the previous registration.`
|
|
246
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
246
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
247
247
|
clock: i,
|
|
248
248
|
target: n.register
|
|
249
249
|
});
|
|
@@ -257,106 +257,106 @@ var ge = (e, t, n) => {
|
|
|
257
257
|
listStore: a
|
|
258
258
|
};
|
|
259
259
|
});
|
|
260
|
-
function
|
|
261
|
-
return
|
|
260
|
+
function ve(e) {
|
|
261
|
+
return R(_e, e);
|
|
262
262
|
}
|
|
263
|
-
var
|
|
263
|
+
var ye = (e, t) => {
|
|
264
264
|
t.register({
|
|
265
265
|
name: e.name,
|
|
266
266
|
framework: e
|
|
267
267
|
});
|
|
268
|
-
},
|
|
268
|
+
}, be = L(({ client: e }) => {
|
|
269
269
|
let t = typeof window < "u", n = {
|
|
270
270
|
location: t ? window.location : void 0,
|
|
271
271
|
document: t ? window.document : void 0,
|
|
272
272
|
sessionStorage: t ? window.sessionStorage : void 0,
|
|
273
273
|
localStorage: t ? window.localStorage : void 0
|
|
274
274
|
};
|
|
275
|
-
return
|
|
275
|
+
return A(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
|
|
276
276
|
client: e,
|
|
277
277
|
responses: t,
|
|
278
278
|
fields: r,
|
|
279
279
|
...n
|
|
280
280
|
}));
|
|
281
281
|
});
|
|
282
|
-
function
|
|
283
|
-
return
|
|
282
|
+
function xe(e) {
|
|
283
|
+
return R(be, e);
|
|
284
284
|
}
|
|
285
285
|
//#endregion
|
|
286
286
|
//#region src/logic-engine.ts
|
|
287
|
-
function
|
|
287
|
+
function Se(e) {
|
|
288
288
|
return typeof e == "number" && !isNaN(e);
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function z(e) {
|
|
291
291
|
return typeof e == "string";
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function B(e) {
|
|
294
294
|
return Array.isArray(e);
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function V(e) {
|
|
297
297
|
return e instanceof Promise;
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function H(e) {
|
|
300
300
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
301
301
|
}
|
|
302
|
-
function
|
|
303
|
-
if (
|
|
302
|
+
function U(e) {
|
|
303
|
+
if (Se(e)) return e;
|
|
304
304
|
let t = parseFloat(`${e}`);
|
|
305
305
|
return isNaN(t) ? 0 : t;
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function W(e) {
|
|
308
308
|
return `${e}`;
|
|
309
309
|
}
|
|
310
|
-
var
|
|
310
|
+
var Ce = {
|
|
311
311
|
"==": (e, t) => e == t,
|
|
312
312
|
"===": (e, t) => e === t,
|
|
313
313
|
"!=": (e, t) => e != t,
|
|
314
314
|
"!==": (e, t) => e !== t,
|
|
315
|
-
">": (e, t) =>
|
|
316
|
-
">=": (e, t) =>
|
|
315
|
+
">": (e, t) => U(e) > U(t),
|
|
316
|
+
">=": (e, t) => U(e) >= U(t),
|
|
317
317
|
"<": (e, t, n) => {
|
|
318
|
-
let r =
|
|
318
|
+
let r = U(e), i = U(t);
|
|
319
319
|
if (n === void 0) return r < i;
|
|
320
|
-
let a =
|
|
320
|
+
let a = U(n);
|
|
321
321
|
return r < i && i < a;
|
|
322
322
|
},
|
|
323
323
|
"<=": (e, t, n) => {
|
|
324
|
-
let r =
|
|
324
|
+
let r = U(e), i = U(t);
|
|
325
325
|
if (n === void 0) return r <= i;
|
|
326
|
-
let a =
|
|
326
|
+
let a = U(n);
|
|
327
327
|
return r <= i && i <= a;
|
|
328
328
|
},
|
|
329
|
-
"!!": async (e) => await
|
|
330
|
-
"!": async (e) => !await
|
|
331
|
-
"%": (e, t) =>
|
|
329
|
+
"!!": async (e) => await K(e),
|
|
330
|
+
"!": async (e) => !await K(e),
|
|
331
|
+
"%": (e, t) => U(e) % U(t),
|
|
332
332
|
log: (e) => (console.log(e), e),
|
|
333
|
-
in: (e, t) => t ?
|
|
334
|
-
cat: (...e) => e.map(
|
|
333
|
+
in: (e, t) => t ? z(t) ? t.indexOf(W(e)) !== -1 : B(t) ? t.includes(e) : !1 : !1,
|
|
334
|
+
cat: (...e) => e.map(W).join(""),
|
|
335
335
|
substr: (e, t, n) => {
|
|
336
|
-
let r =
|
|
336
|
+
let r = W(e), i = U(t);
|
|
337
337
|
if (n === void 0) return r.substr(i);
|
|
338
|
-
let a =
|
|
338
|
+
let a = U(n);
|
|
339
339
|
if (a < 0) {
|
|
340
340
|
let e = r.substr(i);
|
|
341
341
|
return e.substr(0, e.length + a);
|
|
342
342
|
}
|
|
343
343
|
return r.substr(i, a);
|
|
344
344
|
},
|
|
345
|
-
"+": (...e) => e.reduce((e, t) =>
|
|
346
|
-
"*": (...e) => e.reduce((e, t) =>
|
|
345
|
+
"+": (...e) => e.reduce((e, t) => U(e) + U(t), 0),
|
|
346
|
+
"*": (...e) => e.reduce((e, t) => U(e) * U(t), 1),
|
|
347
347
|
"-": (e, t) => {
|
|
348
|
-
let n =
|
|
349
|
-
return t === void 0 ? -n : n -
|
|
348
|
+
let n = U(e);
|
|
349
|
+
return t === void 0 ? -n : n - U(t);
|
|
350
350
|
},
|
|
351
|
-
"/": (e, t) =>
|
|
352
|
-
min: (...e) => Math.min(...e.map(
|
|
353
|
-
max: (...e) => Math.max(...e.map(
|
|
354
|
-
merge: (...e) => e.reduce((e, t) =>
|
|
351
|
+
"/": (e, t) => U(e) / U(t),
|
|
352
|
+
min: (...e) => Math.min(...e.map(U)),
|
|
353
|
+
max: (...e) => Math.max(...e.map(U)),
|
|
354
|
+
merge: (...e) => e.reduce((e, t) => B(t) ? e.concat(t) : e.concat([t]), []),
|
|
355
355
|
var(e, t) {
|
|
356
356
|
let n = arguments.length > 1 ? t : null;
|
|
357
357
|
if (e === "" || e === "." || e == null) return this;
|
|
358
358
|
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
359
|
-
let r =
|
|
359
|
+
let r = W(e);
|
|
360
360
|
if (r === "" || r === ".") return this;
|
|
361
361
|
let i = r.split("."), a = this;
|
|
362
362
|
for (let e of i) {
|
|
@@ -369,116 +369,116 @@ var we = {
|
|
|
369
369
|
return a === void 0 ? n : a;
|
|
370
370
|
},
|
|
371
371
|
async missing(...e) {
|
|
372
|
-
let t =
|
|
372
|
+
let t = B(e[0]) ? e[0] : e, n = [];
|
|
373
373
|
for (let e of t) {
|
|
374
|
-
let t = await
|
|
374
|
+
let t = await G({ var: e }, this);
|
|
375
375
|
(t === null || t === "") && n.push(`${e}`);
|
|
376
376
|
}
|
|
377
377
|
return n;
|
|
378
378
|
},
|
|
379
379
|
async missing_some(e, t) {
|
|
380
|
-
let n = await
|
|
381
|
-
if (!
|
|
382
|
-
let r = n.filter(
|
|
383
|
-
return t.filter(
|
|
380
|
+
let n = await G({ missing: t }, this);
|
|
381
|
+
if (!B(n) || !B(t)) return [];
|
|
382
|
+
let r = n.filter(z);
|
|
383
|
+
return t.filter(z).length - r.length >= U(e) ? [] : r;
|
|
384
384
|
},
|
|
385
385
|
invoke(...e) {
|
|
386
386
|
let [t, ...n] = e;
|
|
387
387
|
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
388
388
|
},
|
|
389
|
-
startsWith: (e, t) =>
|
|
390
|
-
endsWith: (e, t) =>
|
|
389
|
+
startsWith: (e, t) => z(e) && z(t) && e.startsWith(t),
|
|
390
|
+
endsWith: (e, t) => z(e) && z(t) && e.endsWith(t),
|
|
391
391
|
regexp_matches(e, t) {
|
|
392
392
|
let n = e, r = "";
|
|
393
|
-
if (
|
|
393
|
+
if (B(e)) {
|
|
394
394
|
let [t, i] = e;
|
|
395
395
|
n = t, r = i;
|
|
396
396
|
}
|
|
397
|
-
return !
|
|
397
|
+
return !z(n) || !z(r) ? !1 : new RegExp(n, r).test(W(t));
|
|
398
398
|
},
|
|
399
399
|
throw(e) {
|
|
400
|
-
throw Error(
|
|
400
|
+
throw Error(W(e));
|
|
401
401
|
}
|
|
402
402
|
};
|
|
403
|
-
async function
|
|
403
|
+
async function G(e, t) {
|
|
404
404
|
if (!e) return e;
|
|
405
|
-
if (
|
|
406
|
-
if (
|
|
407
|
-
if (!
|
|
408
|
-
let n =
|
|
409
|
-
switch (
|
|
405
|
+
if (V(e)) return G(await e, t);
|
|
406
|
+
if (B(e)) return Promise.all(e.map((e) => G(e, t)));
|
|
407
|
+
if (!H(e)) return e;
|
|
408
|
+
let n = we(e), r = n ? e[n] ?? [] : [];
|
|
409
|
+
switch (B(r) || (r = [r]), n) {
|
|
410
410
|
case "if":
|
|
411
411
|
case "?:":
|
|
412
|
-
for (let e = 0; e < r.length - 1; e += 2) if (await
|
|
413
|
-
return r.length % 2 == 1 ?
|
|
412
|
+
for (let e = 0; e < r.length - 1; e += 2) if (await K(await G(r[e], t))) return G(r[e + 1], t);
|
|
413
|
+
return r.length % 2 == 1 ? G(r[r.length - 1], t) : null;
|
|
414
414
|
case "and": {
|
|
415
415
|
let e = null;
|
|
416
|
-
for (let n of r) if (e = await
|
|
416
|
+
for (let n of r) if (e = await G(n, t), !await K(e)) return e;
|
|
417
417
|
return e;
|
|
418
418
|
}
|
|
419
419
|
case "or": {
|
|
420
420
|
let e = null;
|
|
421
|
-
for (let n of r) if (e = await
|
|
421
|
+
for (let n of r) if (e = await G(n, t), await K(e)) return e;
|
|
422
422
|
return e;
|
|
423
423
|
}
|
|
424
424
|
case "map": {
|
|
425
|
-
let e = await
|
|
426
|
-
return
|
|
425
|
+
let e = await G(r[0], t);
|
|
426
|
+
return B(e) ? await Promise.all(e.map((e) => G(r[1], e))) : [];
|
|
427
427
|
}
|
|
428
428
|
case "filter": {
|
|
429
|
-
let e = await
|
|
430
|
-
return
|
|
429
|
+
let e = await G(r[0], t);
|
|
430
|
+
return B(e) ? (await Promise.all(e.map(async (e) => ({
|
|
431
431
|
item: e,
|
|
432
|
-
shouldInclude: await
|
|
432
|
+
shouldInclude: await K(await G(r[1], e))
|
|
433
433
|
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
434
434
|
}
|
|
435
435
|
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
|
|
436
|
+
let e = await G(r[0], t);
|
|
437
|
+
if (!B(e)) return r.length > 2 ? await G(r[2], t) : null;
|
|
438
|
+
let n = r[1], i = r.length > 2 ? await G(r[2], t) : null;
|
|
439
|
+
for (let t of e) i = await G(n, {
|
|
440
440
|
current: t,
|
|
441
441
|
accumulator: i
|
|
442
442
|
});
|
|
443
443
|
return i;
|
|
444
444
|
}
|
|
445
445
|
case "all": {
|
|
446
|
-
let e = await
|
|
447
|
-
if (!
|
|
448
|
-
for (let t of e) if (!await
|
|
446
|
+
let e = await G(r[0], t);
|
|
447
|
+
if (!B(e) || e.length === 0) return !1;
|
|
448
|
+
for (let t of e) if (!await K(await G(r[1], t))) return !1;
|
|
449
449
|
return !0;
|
|
450
450
|
}
|
|
451
451
|
case "some": {
|
|
452
|
-
let e = await
|
|
453
|
-
if (!
|
|
454
|
-
for (let t of e) if (await
|
|
452
|
+
let e = await G(r[0], t);
|
|
453
|
+
if (!B(e)) return !1;
|
|
454
|
+
for (let t of e) if (await K(await G(r[1], t))) return !0;
|
|
455
455
|
return !1;
|
|
456
456
|
}
|
|
457
457
|
case "none": {
|
|
458
|
-
let e = await
|
|
459
|
-
if (!
|
|
460
|
-
for (let t of e) if (await
|
|
458
|
+
let e = await G(r[0], t);
|
|
459
|
+
if (!B(e)) return !0;
|
|
460
|
+
for (let t of e) if (await K(await G(r[1], t))) return !1;
|
|
461
461
|
return !0;
|
|
462
462
|
}
|
|
463
463
|
case "catch": try {
|
|
464
|
-
return await
|
|
464
|
+
return await G(r[0], t);
|
|
465
465
|
} catch (e) {
|
|
466
|
-
return
|
|
466
|
+
return H(e) ? await G(e, t) : r[1] ? await G(r[1], e) : e instanceof Error ? e.message : e;
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
-
let i = await Promise.all(r.map((e) =>
|
|
469
|
+
let i = await Promise.all(r.map((e) => G(e, t))), a = n ? Ce[n] : void 0;
|
|
470
470
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
471
471
|
return a.apply(t, i);
|
|
472
472
|
}
|
|
473
|
-
async function
|
|
474
|
-
return
|
|
473
|
+
async function K(e) {
|
|
474
|
+
return V(e) ? K(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function we(e) {
|
|
477
477
|
return Object.keys(e)[0];
|
|
478
478
|
}
|
|
479
479
|
//#endregion
|
|
480
480
|
//#region src/lifecycle/rules-logic.ts
|
|
481
|
-
var
|
|
481
|
+
var Te = L(({ client: e }) => k({
|
|
482
482
|
source: {
|
|
483
483
|
stateSnapshot: e.stateSnapshotStore,
|
|
484
484
|
predicates: e.predicates.listStore,
|
|
@@ -497,7 +497,7 @@ var Ee = I(({ client: e }) => O({
|
|
|
497
497
|
let { bucket: e } = await t.getBucket();
|
|
498
498
|
return e;
|
|
499
499
|
}, e), {});
|
|
500
|
-
return await
|
|
500
|
+
return await G(a, {
|
|
501
501
|
responses: i,
|
|
502
502
|
location: typeof e.location == "object" ? {
|
|
503
503
|
hash: e.location.hash,
|
|
@@ -517,15 +517,15 @@ var Ee = I(({ client: e }) => O({
|
|
|
517
517
|
});
|
|
518
518
|
}
|
|
519
519
|
}));
|
|
520
|
-
function
|
|
521
|
-
return
|
|
520
|
+
function Ee(e) {
|
|
521
|
+
return R(Te, e);
|
|
522
522
|
}
|
|
523
523
|
//#endregion
|
|
524
524
|
//#region src/ping.ts
|
|
525
|
-
var
|
|
525
|
+
var De = 6e3, Oe = E("last_ping", "global"), ke = async (e) => {
|
|
526
526
|
try {
|
|
527
|
-
let t = Date.now(), n = w.get(
|
|
528
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
527
|
+
let t = Date.now(), n = w.get(Oe), r = 0;
|
|
528
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < De) return !0;
|
|
529
529
|
let i = {
|
|
530
530
|
projectId: e.projectId,
|
|
531
531
|
path: window.location.pathname
|
|
@@ -536,118 +536,118 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
|
|
|
536
536
|
} catch {
|
|
537
537
|
return !1;
|
|
538
538
|
}
|
|
539
|
-
},
|
|
540
|
-
let t =
|
|
539
|
+
}, q = M("lifecycle"), Ae = L(({ client: e }) => {
|
|
540
|
+
let t = q.store(!1), r = F(void 0, {
|
|
541
541
|
skipVoid: !1,
|
|
542
|
-
domain:
|
|
543
|
-
}), i =
|
|
542
|
+
domain: q
|
|
543
|
+
}), i = F(void 0, {
|
|
544
544
|
skipVoid: !1,
|
|
545
|
-
domain:
|
|
546
|
-
}), a =
|
|
545
|
+
domain: q
|
|
546
|
+
}), a = q.store("idle"), o = q.store([]), s = F(void 0, {
|
|
547
547
|
skipVoid: !1,
|
|
548
|
-
domain:
|
|
549
|
-
}), c =
|
|
548
|
+
domain: q
|
|
549
|
+
}), c = F(void 0, {
|
|
550
550
|
skipVoid: !1,
|
|
551
|
-
domain:
|
|
552
|
-
}), l =
|
|
551
|
+
domain: q
|
|
552
|
+
}), l = P(), u = P(), d = P(), p = P(), m = P(), h = P();
|
|
553
553
|
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
|
|
554
|
-
let g =
|
|
555
|
-
|
|
556
|
-
}), _ =
|
|
554
|
+
let g = N(() => {
|
|
555
|
+
ke(e);
|
|
556
|
+
}), _ = N(async () => {
|
|
557
557
|
await ee();
|
|
558
|
-
}), v =
|
|
559
|
-
await
|
|
560
|
-
}), y =
|
|
558
|
+
}), v = N(async () => {
|
|
559
|
+
await se(e);
|
|
560
|
+
}), y = k({ effect: v }), b = k({
|
|
561
561
|
source: o,
|
|
562
562
|
effect: async (e) => {
|
|
563
563
|
for (let t of e) await t();
|
|
564
564
|
}
|
|
565
|
-
}), x =
|
|
565
|
+
}), x = k({
|
|
566
566
|
source: s,
|
|
567
567
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
568
|
-
}), S =
|
|
568
|
+
}), S = k({
|
|
569
569
|
source: c,
|
|
570
570
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
571
|
-
}), C =
|
|
571
|
+
}), C = I({
|
|
572
572
|
clock: l,
|
|
573
573
|
filter: () => f()
|
|
574
574
|
});
|
|
575
|
-
|
|
575
|
+
I({
|
|
576
576
|
clock: C,
|
|
577
577
|
fn: () => "starting",
|
|
578
578
|
target: a
|
|
579
|
-
}),
|
|
579
|
+
}), I({
|
|
580
580
|
clock: C,
|
|
581
581
|
target: g
|
|
582
|
-
}),
|
|
582
|
+
}), I({
|
|
583
583
|
clock: C,
|
|
584
584
|
target: b
|
|
585
|
-
}),
|
|
585
|
+
}), I({
|
|
586
586
|
clock: C,
|
|
587
587
|
target: _
|
|
588
|
-
}),
|
|
588
|
+
}), I({
|
|
589
589
|
clock: b.done,
|
|
590
590
|
target: x
|
|
591
|
-
}),
|
|
591
|
+
}), I({
|
|
592
592
|
clock: x.doneData,
|
|
593
593
|
target: r
|
|
594
|
-
}),
|
|
594
|
+
}), I({
|
|
595
595
|
clock: S.doneData,
|
|
596
596
|
target: i
|
|
597
|
-
}),
|
|
597
|
+
}), I({
|
|
598
598
|
clock: x.doneData,
|
|
599
599
|
filter: (e) => e,
|
|
600
600
|
target: S
|
|
601
|
-
}),
|
|
601
|
+
}), I({
|
|
602
602
|
clock: S.doneData,
|
|
603
603
|
target: e.session.setIsUser
|
|
604
|
-
}),
|
|
604
|
+
}), I({
|
|
605
605
|
clock: S.doneData,
|
|
606
606
|
fn: (e) => ({
|
|
607
607
|
type: "user_decide",
|
|
608
608
|
value: e
|
|
609
609
|
}),
|
|
610
610
|
target: e.eventBus
|
|
611
|
-
}),
|
|
611
|
+
}), I({
|
|
612
612
|
clock: x.doneData,
|
|
613
613
|
filter: (e) => !e,
|
|
614
614
|
fn: () => void 0,
|
|
615
615
|
target: d
|
|
616
|
-
}),
|
|
616
|
+
}), I({
|
|
617
617
|
clock: S.doneData,
|
|
618
618
|
fn: () => void 0,
|
|
619
619
|
target: d
|
|
620
|
-
}),
|
|
620
|
+
}), I({
|
|
621
621
|
clock: d,
|
|
622
622
|
fn: () => ({ type: "initialize" }),
|
|
623
623
|
target: e.eventBus
|
|
624
624
|
});
|
|
625
|
-
let w =
|
|
626
|
-
return
|
|
625
|
+
let w = F(!1).on(_.done, () => !0), T = F(!1).on(d, () => !0), E = F(!1).on(y.done, () => !0), D = A(r, i, (e, t) => e === !0 && t === !0);
|
|
626
|
+
return I({
|
|
627
627
|
clock: d,
|
|
628
628
|
source: D,
|
|
629
629
|
filter: (e) => e,
|
|
630
630
|
fn: () => void 0,
|
|
631
631
|
target: v
|
|
632
|
-
}),
|
|
633
|
-
clock:
|
|
632
|
+
}), I({
|
|
633
|
+
clock: A(w, T, D, (e, t, n) => e && t && n),
|
|
634
634
|
filter: (e) => e,
|
|
635
635
|
fn: () => void 0,
|
|
636
636
|
target: y
|
|
637
|
-
}),
|
|
638
|
-
clock:
|
|
637
|
+
}), I({
|
|
638
|
+
clock: A(w, T, D, E, (e, t, n, r) => e && t && (!n || r)),
|
|
639
639
|
filter: (e) => e,
|
|
640
640
|
fn: () => void 0,
|
|
641
641
|
target: u
|
|
642
|
-
}),
|
|
642
|
+
}), I({
|
|
643
643
|
clock: u,
|
|
644
644
|
fn: () => "ready",
|
|
645
645
|
target: a
|
|
646
|
-
}),
|
|
646
|
+
}), I({
|
|
647
647
|
clock: u,
|
|
648
648
|
fn: () => ({ type: "ready" }),
|
|
649
649
|
target: e.eventBus
|
|
650
|
-
}),
|
|
650
|
+
}), I({
|
|
651
651
|
clock: u,
|
|
652
652
|
source: e.session.store,
|
|
653
653
|
fn: ({ id: e, isUser: t, identifiers: n }) => ({
|
|
@@ -657,7 +657,7 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
|
|
|
657
657
|
identifiers: n
|
|
658
658
|
}),
|
|
659
659
|
target: e.eventBus
|
|
660
|
-
}),
|
|
660
|
+
}), I({
|
|
661
661
|
clock: [
|
|
662
662
|
b.fail,
|
|
663
663
|
x.fail,
|
|
@@ -679,13 +679,13 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
|
|
|
679
679
|
setCondition: h
|
|
680
680
|
};
|
|
681
681
|
});
|
|
682
|
-
function
|
|
683
|
-
return
|
|
682
|
+
function je(e) {
|
|
683
|
+
return R(Ae, e);
|
|
684
684
|
}
|
|
685
685
|
//#endregion
|
|
686
686
|
//#region src/entities/predicate/predicate.ts
|
|
687
|
-
var
|
|
688
|
-
let t =
|
|
687
|
+
var Me = M("predicate"), Ne = L(({ client: e }) => {
|
|
688
|
+
let t = Me.store({}), n = j(t, { register(e, t) {
|
|
689
689
|
return {
|
|
690
690
|
...e,
|
|
691
691
|
[t.name]: {
|
|
@@ -693,13 +693,13 @@ var Ne = j("predicate"), Pe = I(({ client: e }) => {
|
|
|
693
693
|
predicate: t.predicate
|
|
694
694
|
}
|
|
695
695
|
};
|
|
696
|
-
} }), i =
|
|
697
|
-
|
|
696
|
+
} }), i = P();
|
|
697
|
+
I({
|
|
698
698
|
clock: i,
|
|
699
699
|
source: t,
|
|
700
700
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
701
701
|
fn: (e, { name: t }) => `Predicate '${t}' already registered. Registering again will override the previous registration.`
|
|
702
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
702
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
703
703
|
clock: i,
|
|
704
704
|
fn: ({ name: e, predicate: t }) => Object.freeze({
|
|
705
705
|
name: e,
|
|
@@ -712,7 +712,7 @@ var Ne = j("predicate"), Pe = I(({ client: e }) => {
|
|
|
712
712
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
713
713
|
}
|
|
714
714
|
function s(t) {
|
|
715
|
-
let n =
|
|
715
|
+
let n = F(() => void 0, { skipVoid: !1 }), r = k({
|
|
716
716
|
source: {
|
|
717
717
|
predicate: o(t),
|
|
718
718
|
snapshot: e.stateSnapshotStore
|
|
@@ -724,13 +724,13 @@ var Ne = j("predicate"), Pe = I(({ client: e }) => {
|
|
|
724
724
|
});
|
|
725
725
|
}
|
|
726
726
|
});
|
|
727
|
-
return
|
|
727
|
+
return I({
|
|
728
728
|
source: {
|
|
729
729
|
responses: e.responses.listStore,
|
|
730
730
|
fields: e.fields.listStore
|
|
731
731
|
},
|
|
732
732
|
target: r
|
|
733
|
-
}),
|
|
733
|
+
}), I({
|
|
734
734
|
clock: r.doneData,
|
|
735
735
|
filter: (e) => e !== void 0,
|
|
736
736
|
target: n
|
|
@@ -743,27 +743,27 @@ var Ne = j("predicate"), Pe = I(({ client: e }) => {
|
|
|
743
743
|
getEvokablePredicate: s
|
|
744
744
|
};
|
|
745
745
|
});
|
|
746
|
-
function
|
|
747
|
-
return
|
|
746
|
+
function Pe(e) {
|
|
747
|
+
return R(Ne, e);
|
|
748
748
|
}
|
|
749
|
-
var
|
|
749
|
+
var Fe = (e, t, n) => {
|
|
750
750
|
n.register({
|
|
751
751
|
name: e,
|
|
752
752
|
predicate: t
|
|
753
753
|
});
|
|
754
|
-
},
|
|
755
|
-
let t =
|
|
754
|
+
}, J = M("feature"), Ie = L(({ client: e }) => {
|
|
755
|
+
let t = J.store({}), n = J.store([]), i = j(t, { register(e, t) {
|
|
756
756
|
return {
|
|
757
757
|
...e,
|
|
758
758
|
[t.id]: t.feature
|
|
759
759
|
};
|
|
760
|
-
} }), a =
|
|
761
|
-
|
|
760
|
+
} }), a = P();
|
|
761
|
+
I({
|
|
762
762
|
clock: a,
|
|
763
763
|
source: t,
|
|
764
764
|
filter: (e, { id: t }) => e[t] !== void 0,
|
|
765
765
|
fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
|
|
766
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
766
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
767
767
|
clock: a,
|
|
768
768
|
fn: ({ id: e, feature: t }) => Object.freeze({
|
|
769
769
|
id: e,
|
|
@@ -777,7 +777,7 @@ var Ie = (e, t, n) => {
|
|
|
777
777
|
}),
|
|
778
778
|
target: i.register
|
|
779
779
|
});
|
|
780
|
-
let o =
|
|
780
|
+
let o = N(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
781
781
|
let r = E(`feature:${e}:${t}`, "global"), i = (n === "session" ? T : w).get(r).boolean();
|
|
782
782
|
return i === null ? null : {
|
|
783
783
|
id: e,
|
|
@@ -785,11 +785,11 @@ var Ie = (e, t, n) => {
|
|
|
785
785
|
bucket: i,
|
|
786
786
|
storage: n
|
|
787
787
|
};
|
|
788
|
-
}), s =
|
|
788
|
+
}), s = N((e) => {
|
|
789
789
|
if (!e) return null;
|
|
790
790
|
let t = E(`feature:${e.id}:${e.key}`, "global");
|
|
791
791
|
(e.storage === "session" ? T : w).set(t, e.bucket);
|
|
792
|
-
}), c = /* @__PURE__ */ new Map(), l =
|
|
792
|
+
}), c = /* @__PURE__ */ new Map(), l = k({
|
|
793
793
|
source: {
|
|
794
794
|
allFeaturesStore: t,
|
|
795
795
|
resolvedFeaturesStore: n
|
|
@@ -820,7 +820,7 @@ var Ie = (e, t, n) => {
|
|
|
820
820
|
};
|
|
821
821
|
}
|
|
822
822
|
});
|
|
823
|
-
|
|
823
|
+
I({
|
|
824
824
|
clock: i.register,
|
|
825
825
|
fn: (e) => {
|
|
826
826
|
let { id: t, feature: n } = e;
|
|
@@ -831,7 +831,7 @@ var Ie = (e, t, n) => {
|
|
|
831
831
|
};
|
|
832
832
|
},
|
|
833
833
|
target: o
|
|
834
|
-
}),
|
|
834
|
+
}), I({
|
|
835
835
|
source: t,
|
|
836
836
|
clock: l.doneData,
|
|
837
837
|
fn: (e, t) => {
|
|
@@ -845,7 +845,7 @@ var Ie = (e, t, n) => {
|
|
|
845
845
|
},
|
|
846
846
|
target: s
|
|
847
847
|
});
|
|
848
|
-
let u =
|
|
848
|
+
let u = A({
|
|
849
849
|
allFeaturesStore: t,
|
|
850
850
|
resolvedFeaturesStore: n
|
|
851
851
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -867,7 +867,7 @@ var Ie = (e, t, n) => {
|
|
|
867
867
|
isResolved: !1
|
|
868
868
|
};
|
|
869
869
|
}));
|
|
870
|
-
|
|
870
|
+
I({
|
|
871
871
|
clock: l.doneData,
|
|
872
872
|
source: { resolvedFeatures: n },
|
|
873
873
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
@@ -876,7 +876,7 @@ var Ie = (e, t, n) => {
|
|
|
876
876
|
type: "feature_decide",
|
|
877
877
|
feature: e
|
|
878
878
|
}))
|
|
879
|
-
}),
|
|
879
|
+
}), I({
|
|
880
880
|
clock: [o.doneData, l.doneData],
|
|
881
881
|
source: n,
|
|
882
882
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
@@ -889,17 +889,17 @@ var Ie = (e, t, n) => {
|
|
|
889
889
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
890
890
|
}
|
|
891
891
|
function p(e) {
|
|
892
|
-
let t =
|
|
892
|
+
let t = F(async () => void 0, { skipVoid: !1 }), r = k({
|
|
893
893
|
source: d(e),
|
|
894
894
|
effect: async (e) => {
|
|
895
895
|
if (e) return async () => (await e.getBucket()).bucket;
|
|
896
896
|
}
|
|
897
897
|
});
|
|
898
|
-
return
|
|
898
|
+
return I({
|
|
899
899
|
source: n,
|
|
900
900
|
filter: (t) => t.some((t) => t.id === e),
|
|
901
901
|
target: r
|
|
902
|
-
}),
|
|
902
|
+
}), I({
|
|
903
903
|
clock: r.doneData,
|
|
904
904
|
filter: (e) => e !== void 0,
|
|
905
905
|
target: t
|
|
@@ -913,69 +913,89 @@ var Ie = (e, t, n) => {
|
|
|
913
913
|
getEvokableFeature: p
|
|
914
914
|
};
|
|
915
915
|
});
|
|
916
|
-
function
|
|
917
|
-
return
|
|
916
|
+
function Le(e) {
|
|
917
|
+
return R(Ie, e);
|
|
918
918
|
}
|
|
919
|
-
var
|
|
919
|
+
var Re = (e, t, n) => {
|
|
920
920
|
n.register({
|
|
921
921
|
id: e,
|
|
922
922
|
feature: t
|
|
923
923
|
});
|
|
924
|
-
},
|
|
925
|
-
function
|
|
924
|
+
}, Y = M("history");
|
|
925
|
+
function X(e, t, n) {
|
|
926
926
|
return {
|
|
927
|
-
id:
|
|
928
|
-
node:
|
|
927
|
+
id: O("history-entry"),
|
|
928
|
+
node: n,
|
|
929
929
|
at: Date.now(),
|
|
930
|
-
|
|
930
|
+
instanceId: e,
|
|
931
|
+
experienceId: t
|
|
931
932
|
};
|
|
932
933
|
}
|
|
933
|
-
|
|
934
|
-
let
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
934
|
+
function ze(e) {
|
|
935
|
+
let t = e.findLastIndex((e) => v(e.node));
|
|
936
|
+
return t === -1 ? [] : e.slice(0, t + 1);
|
|
937
|
+
}
|
|
938
|
+
var Be = L(() => {
|
|
939
|
+
let e = Y.store([]), t = Y.event(), n = Y.event(), r = Y.event(), i = Y.event(), a = Y.event(), o = Y.event();
|
|
940
|
+
e.on(t, (e, t) => [...e, X(t.instanceId, t.experienceId, t.node)]), e.on(n, (e, t) => {
|
|
941
|
+
let n = X(t.instanceId, t.experienceId, t.node), r = e.findLastIndex((e) => e.instanceId === t.instanceId);
|
|
942
|
+
return r === -1 ? [...e, n] : e.with(r, n);
|
|
943
|
+
}), e.on(r, (e, { instanceId: t }) => {
|
|
944
|
+
let n = 0, r = -1;
|
|
945
|
+
for (let i = e.length - 1; i >= 0; i--) {
|
|
946
|
+
let a = e[i];
|
|
947
|
+
if (!(a?.instanceId !== t || !v(a.node)) && (n += 1, n === 2)) {
|
|
948
|
+
r = i;
|
|
946
949
|
break;
|
|
947
950
|
}
|
|
948
951
|
}
|
|
952
|
+
return r === -1 ? e : e.filter((e, n) => e.instanceId !== t || n <= r);
|
|
953
|
+
}), e.on(i, (e, { snapshots: t }) => Object.values(t).flat()), e.on(o, (e, t) => [...e, ...t]);
|
|
954
|
+
let s = e.map((e) => {
|
|
955
|
+
let t = /* @__PURE__ */ new Map();
|
|
956
|
+
for (let n of e) t.set(n.experienceId, n.instanceId);
|
|
957
|
+
let n = {};
|
|
958
|
+
for (let r of e) {
|
|
959
|
+
if (t.get(r.experienceId) !== r.instanceId) continue;
|
|
960
|
+
let e = n[r.experienceId] ?? [];
|
|
961
|
+
e.push(r), n[r.experienceId] = e;
|
|
962
|
+
}
|
|
949
963
|
return n;
|
|
950
|
-
}
|
|
951
|
-
return
|
|
952
|
-
|
|
953
|
-
|
|
964
|
+
});
|
|
965
|
+
return I({
|
|
966
|
+
clock: a,
|
|
967
|
+
source: s,
|
|
968
|
+
fn: (e, { instanceId: t, experienceId: n }) => ze(e[n] ?? []).map((e) => ({
|
|
954
969
|
...e,
|
|
955
|
-
|
|
956
|
-
|
|
970
|
+
id: O("history-entry"),
|
|
971
|
+
instanceId: t,
|
|
972
|
+
at: Date.now()
|
|
973
|
+
})),
|
|
974
|
+
target: o
|
|
957
975
|
}), {
|
|
958
976
|
push: t,
|
|
959
977
|
replace: n,
|
|
960
978
|
back: r,
|
|
961
|
-
|
|
962
|
-
|
|
979
|
+
restoreSnapshots: i,
|
|
980
|
+
seedInstanceFromSnapshot: a,
|
|
981
|
+
entriesStore: e,
|
|
982
|
+
snapshotStore: s
|
|
963
983
|
};
|
|
964
984
|
});
|
|
965
|
-
function
|
|
966
|
-
return
|
|
985
|
+
function Ve() {
|
|
986
|
+
return R(Be);
|
|
967
987
|
}
|
|
968
988
|
//#endregion
|
|
969
989
|
//#region src/utils/events.ts
|
|
970
|
-
var
|
|
971
|
-
let t =
|
|
990
|
+
var He = 0, Ue = (e) => {
|
|
991
|
+
let t = F([]);
|
|
972
992
|
return t.on(e, (e, t) => [...e, {
|
|
973
|
-
id:
|
|
993
|
+
id: He++,
|
|
974
994
|
at: /* @__PURE__ */ new Date(),
|
|
975
995
|
payload: t
|
|
976
996
|
}]), t;
|
|
977
|
-
},
|
|
978
|
-
let e =
|
|
997
|
+
}, We = M("field"), Ge = L(() => {
|
|
998
|
+
let e = We.store({}), t = j(e, {
|
|
979
999
|
register(e, t) {
|
|
980
1000
|
return {
|
|
981
1001
|
...e,
|
|
@@ -1023,13 +1043,13 @@ var Ue = 0, We = (e) => {
|
|
|
1023
1043
|
getByName: c
|
|
1024
1044
|
};
|
|
1025
1045
|
});
|
|
1026
|
-
function
|
|
1027
|
-
return
|
|
1046
|
+
function Ke() {
|
|
1047
|
+
return R(Ge);
|
|
1028
1048
|
}
|
|
1029
1049
|
//#endregion
|
|
1030
1050
|
//#region src/entities/step/step.ts
|
|
1031
|
-
var
|
|
1032
|
-
let e =
|
|
1051
|
+
var qe = M("step"), Je = L(() => {
|
|
1052
|
+
let e = qe.store({}), t = j(e, { register(e, t) {
|
|
1033
1053
|
return {
|
|
1034
1054
|
...e,
|
|
1035
1055
|
[t.step.id]: t.step
|
|
@@ -1053,16 +1073,16 @@ var Je = j("step"), Ye = I(() => {
|
|
|
1053
1073
|
indexStore: e
|
|
1054
1074
|
};
|
|
1055
1075
|
});
|
|
1056
|
-
function
|
|
1057
|
-
return
|
|
1076
|
+
function Ye() {
|
|
1077
|
+
return R(Je);
|
|
1058
1078
|
}
|
|
1059
|
-
function
|
|
1079
|
+
function Xe(e, t) {
|
|
1060
1080
|
t.register(e);
|
|
1061
1081
|
}
|
|
1062
1082
|
//#endregion
|
|
1063
1083
|
//#region src/entities/action/action.ts
|
|
1064
|
-
var
|
|
1065
|
-
let t =
|
|
1084
|
+
var Ze = M("action"), Qe = L(({ client: e }) => {
|
|
1085
|
+
let t = Ze.store({}), n = j(t, { register(e, t) {
|
|
1066
1086
|
return {
|
|
1067
1087
|
...e,
|
|
1068
1088
|
[t.key]: {
|
|
@@ -1070,13 +1090,13 @@ var Qe = j("action"), $e = I(({ client: e }) => {
|
|
|
1070
1090
|
action: t.action
|
|
1071
1091
|
}
|
|
1072
1092
|
};
|
|
1073
|
-
} }), i =
|
|
1074
|
-
|
|
1093
|
+
} }), i = P();
|
|
1094
|
+
I({
|
|
1075
1095
|
clock: i,
|
|
1076
1096
|
source: t,
|
|
1077
1097
|
filter: (e, { key: t }) => e[t] !== void 0,
|
|
1078
1098
|
fn: (e, { key: t }) => `Action '${t}' already registered. Registering again will override the previous registration.`
|
|
1079
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
1099
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
1080
1100
|
clock: i,
|
|
1081
1101
|
fn: ({ key: e, action: t }) => Object.freeze({
|
|
1082
1102
|
key: e,
|
|
@@ -1089,7 +1109,7 @@ var Qe = j("action"), $e = I(({ client: e }) => {
|
|
|
1089
1109
|
return t.map((t) => t[e]?.action, { skipVoid: !1 });
|
|
1090
1110
|
}
|
|
1091
1111
|
function s(t, n) {
|
|
1092
|
-
let r =
|
|
1112
|
+
let r = F(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, a = k({
|
|
1093
1113
|
source: {
|
|
1094
1114
|
action: o(t),
|
|
1095
1115
|
snapshot: e.stateSnapshotStore
|
|
@@ -1101,13 +1121,13 @@ var Qe = j("action"), $e = I(({ client: e }) => {
|
|
|
1101
1121
|
}, i);
|
|
1102
1122
|
}
|
|
1103
1123
|
});
|
|
1104
|
-
return
|
|
1124
|
+
return I({
|
|
1105
1125
|
source: {
|
|
1106
1126
|
responses: e.responses.listStore,
|
|
1107
1127
|
fields: e.fields.listStore
|
|
1108
1128
|
},
|
|
1109
1129
|
target: a
|
|
1110
|
-
}),
|
|
1130
|
+
}), I({
|
|
1111
1131
|
clock: a.doneData,
|
|
1112
1132
|
filter: (e) => e !== void 0,
|
|
1113
1133
|
target: r
|
|
@@ -1120,10 +1140,10 @@ var Qe = j("action"), $e = I(({ client: e }) => {
|
|
|
1120
1140
|
getEvokableAction: s
|
|
1121
1141
|
};
|
|
1122
1142
|
});
|
|
1123
|
-
function
|
|
1124
|
-
return
|
|
1143
|
+
function $e(e) {
|
|
1144
|
+
return R(Qe, e);
|
|
1125
1145
|
}
|
|
1126
|
-
var
|
|
1146
|
+
var et = (e, t, n) => {
|
|
1127
1147
|
n.register({
|
|
1128
1148
|
key: e,
|
|
1129
1149
|
action: t
|
|
@@ -1131,7 +1151,7 @@ var tt = (e, t, n) => {
|
|
|
1131
1151
|
};
|
|
1132
1152
|
//#endregion
|
|
1133
1153
|
//#region src/entities/response/response-validation.ts
|
|
1134
|
-
function
|
|
1154
|
+
function Z(e, t, n, r) {
|
|
1135
1155
|
return {
|
|
1136
1156
|
fieldKey: e.key,
|
|
1137
1157
|
userMessage: n,
|
|
@@ -1139,13 +1159,13 @@ function Y(e, t, n, r) {
|
|
|
1139
1159
|
value: t
|
|
1140
1160
|
};
|
|
1141
1161
|
}
|
|
1142
|
-
function
|
|
1162
|
+
function Q(e) {
|
|
1143
1163
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1144
1164
|
}
|
|
1145
|
-
function
|
|
1165
|
+
function tt(e) {
|
|
1146
1166
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1147
1167
|
}
|
|
1148
|
-
function
|
|
1168
|
+
function nt(e) {
|
|
1149
1169
|
try {
|
|
1150
1170
|
return JSON.stringify(e), !0;
|
|
1151
1171
|
} catch {
|
|
@@ -1159,42 +1179,42 @@ function it(e, t) {
|
|
|
1159
1179
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1160
1180
|
}
|
|
1161
1181
|
function at(e, t) {
|
|
1162
|
-
if (e.type !== "object" ||
|
|
1182
|
+
if (e.type !== "object" || Q(t)) return null;
|
|
1163
1183
|
if (e.multiple) {
|
|
1164
|
-
if (!Array.isArray(t)) return
|
|
1184
|
+
if (!Array.isArray(t)) return Z(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1165
1185
|
for (let n of t) {
|
|
1166
|
-
if (typeof n != "object" || !n) return
|
|
1167
|
-
if (!
|
|
1186
|
+
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.");
|
|
1187
|
+
if (!nt(n)) return Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1168
1188
|
}
|
|
1169
1189
|
return null;
|
|
1170
1190
|
}
|
|
1171
|
-
return Array.isArray(t) ?
|
|
1191
|
+
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.") : nt(t) ? null : Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1172
1192
|
}
|
|
1173
1193
|
function ot(e, t) {
|
|
1174
|
-
if (
|
|
1194
|
+
if (Q(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1175
1195
|
let n = Array.isArray(t) ? t : [t];
|
|
1176
1196
|
if (e.type === "object") {
|
|
1177
1197
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1178
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
1198
|
+
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
1199
|
}
|
|
1180
1200
|
let r = e.options.map((e) => e.value);
|
|
1181
|
-
return n.every((e) => !
|
|
1201
|
+
return n.every((e) => !tt(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
1202
|
}
|
|
1183
1203
|
async function st(t, n, r, i) {
|
|
1184
|
-
if (n.validation && !e(n.validation) && !
|
|
1204
|
+
if (n.validation && !e(n.validation) && !Q(r)) {
|
|
1185
1205
|
let e = i ? {
|
|
1186
1206
|
$input: r,
|
|
1187
1207
|
responses: i
|
|
1188
1208
|
} : { $input: r }, a = await t(n.validation, e);
|
|
1189
|
-
if (typeof a == "string") return
|
|
1190
|
-
if (a === !1) return
|
|
1209
|
+
if (typeof a == "string") return Z(n, r, a, `Field validation resulted in an error: ${a}.`);
|
|
1210
|
+
if (a === !1) return Z(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
1191
1211
|
}
|
|
1192
|
-
return n.required &&
|
|
1212
|
+
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
1213
|
}
|
|
1194
1214
|
//#endregion
|
|
1195
1215
|
//#region src/entities/response/response.ts
|
|
1196
|
-
var ct =
|
|
1197
|
-
let t = ct.store({}), r =
|
|
1216
|
+
var ct = M("response"), lt = L(({ client: e }) => {
|
|
1217
|
+
let t = ct.store({}), r = P(), i = P(), a = j(t, {
|
|
1198
1218
|
register(e, t) {
|
|
1199
1219
|
return {
|
|
1200
1220
|
...e,
|
|
@@ -1223,7 +1243,7 @@ var ct = j("response"), lt = I(({ client: e }) => {
|
|
|
1223
1243
|
});
|
|
1224
1244
|
} else a.registerBatch(e);
|
|
1225
1245
|
}
|
|
1226
|
-
let s = (t, r) => n(e, t, r), c =
|
|
1246
|
+
let s = (t, r) => n(e, t, r), c = k({
|
|
1227
1247
|
source: {
|
|
1228
1248
|
allFields: e.fields.listStore,
|
|
1229
1249
|
existingResponses: t
|
|
@@ -1281,7 +1301,7 @@ var ct = j("response"), lt = I(({ client: e }) => {
|
|
|
1281
1301
|
async function l(e) {
|
|
1282
1302
|
return c(e);
|
|
1283
1303
|
}
|
|
1284
|
-
let u =
|
|
1304
|
+
let u = k({
|
|
1285
1305
|
source: t,
|
|
1286
1306
|
effect: async (e, t) => {
|
|
1287
1307
|
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
@@ -1296,7 +1316,7 @@ var ct = j("response"), lt = I(({ client: e }) => {
|
|
|
1296
1316
|
value: t
|
|
1297
1317
|
})));
|
|
1298
1318
|
function m(e) {
|
|
1299
|
-
return
|
|
1319
|
+
return A({
|
|
1300
1320
|
f: e,
|
|
1301
1321
|
s: t
|
|
1302
1322
|
}, ({ f: e, s: t }) => {
|
|
@@ -1313,10 +1333,10 @@ var ct = j("response"), lt = I(({ client: e }) => {
|
|
|
1313
1333
|
function _(t) {
|
|
1314
1334
|
return m(e.fields.getByName(t));
|
|
1315
1335
|
}
|
|
1316
|
-
return
|
|
1336
|
+
return I({
|
|
1317
1337
|
clock: r,
|
|
1318
1338
|
target: a.clearAll
|
|
1319
|
-
}),
|
|
1339
|
+
}), I({
|
|
1320
1340
|
clock: i,
|
|
1321
1341
|
target: a.clear
|
|
1322
1342
|
}), {
|
|
@@ -1333,12 +1353,12 @@ var ct = j("response"), lt = I(({ client: e }) => {
|
|
|
1333
1353
|
};
|
|
1334
1354
|
});
|
|
1335
1355
|
function ut(e) {
|
|
1336
|
-
return
|
|
1356
|
+
return R(lt, e);
|
|
1337
1357
|
}
|
|
1338
1358
|
//#endregion
|
|
1339
1359
|
//#region src/entities/condition/condition.ts
|
|
1340
|
-
var dt =
|
|
1341
|
-
let e = dt.store({}), t =
|
|
1360
|
+
var dt = M("condition"), ft = L(() => {
|
|
1361
|
+
let e = dt.store({}), t = j(e, { register(e, t) {
|
|
1342
1362
|
return {
|
|
1343
1363
|
...e,
|
|
1344
1364
|
[t.condition.id]: t.condition
|
|
@@ -1363,7 +1383,7 @@ var dt = j("condition"), ft = I(() => {
|
|
|
1363
1383
|
};
|
|
1364
1384
|
});
|
|
1365
1385
|
function pt() {
|
|
1366
|
-
return
|
|
1386
|
+
return R(ft);
|
|
1367
1387
|
}
|
|
1368
1388
|
//#endregion
|
|
1369
1389
|
//#region src/utils/api-url.ts
|
|
@@ -1400,13 +1420,13 @@ function ht() {
|
|
|
1400
1420
|
}
|
|
1401
1421
|
//#endregion
|
|
1402
1422
|
//#region src/entities/session/session.ts
|
|
1403
|
-
var
|
|
1404
|
-
function
|
|
1423
|
+
var gt = E("session", "global");
|
|
1424
|
+
function _t() {
|
|
1405
1425
|
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
1426
|
}
|
|
1407
|
-
function
|
|
1427
|
+
function vt() {
|
|
1408
1428
|
if (!u()) return null;
|
|
1409
|
-
let e = w.get(
|
|
1429
|
+
let e = w.get(gt);
|
|
1410
1430
|
if (!e.isSet()) return null;
|
|
1411
1431
|
try {
|
|
1412
1432
|
return e.json();
|
|
@@ -1414,10 +1434,10 @@ function _t() {
|
|
|
1414
1434
|
return null;
|
|
1415
1435
|
}
|
|
1416
1436
|
}
|
|
1417
|
-
var
|
|
1418
|
-
let e =
|
|
1437
|
+
var yt = L(() => {
|
|
1438
|
+
let e = vt(), t = { id: e?.id ?? _t() };
|
|
1419
1439
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1420
|
-
let n =
|
|
1440
|
+
let n = F(t), r = j(n, {
|
|
1421
1441
|
setIsUser: (e, t) => ({
|
|
1422
1442
|
...e,
|
|
1423
1443
|
isUser: t
|
|
@@ -1438,13 +1458,13 @@ var vt = I(() => {
|
|
|
1438
1458
|
return e.isUser !== void 0 && (i.isUser = e.isUser), Object.keys(r).length > 0 && (i.identifiers = r), i;
|
|
1439
1459
|
}
|
|
1440
1460
|
});
|
|
1441
|
-
return
|
|
1461
|
+
return I({
|
|
1442
1462
|
source: n,
|
|
1443
|
-
target:
|
|
1463
|
+
target: k({
|
|
1444
1464
|
source: n,
|
|
1445
1465
|
effect: (e) => {
|
|
1446
1466
|
if (u()) try {
|
|
1447
|
-
w.get(
|
|
1467
|
+
w.get(gt).set(e);
|
|
1448
1468
|
} catch {}
|
|
1449
1469
|
}
|
|
1450
1470
|
})
|
|
@@ -1455,27 +1475,27 @@ var vt = I(() => {
|
|
|
1455
1475
|
removeIdentifier: r.removeIdentifier
|
|
1456
1476
|
};
|
|
1457
1477
|
});
|
|
1458
|
-
function
|
|
1459
|
-
return
|
|
1478
|
+
function bt() {
|
|
1479
|
+
return R(yt, void 0);
|
|
1460
1480
|
}
|
|
1461
1481
|
//#endregion
|
|
1462
1482
|
//#region src/utils/picked-config.ts
|
|
1463
|
-
function bt() {
|
|
1464
|
-
if (o()) return globalThis.window.pickedConfig;
|
|
1465
|
-
}
|
|
1466
1483
|
function xt() {
|
|
1467
|
-
if (o()) return
|
|
1484
|
+
if (o()) return globalThis.window.pickedConfig;
|
|
1468
1485
|
}
|
|
1469
1486
|
function St() {
|
|
1487
|
+
if (o()) return xt()?.projectId;
|
|
1488
|
+
}
|
|
1489
|
+
function Ct() {
|
|
1470
1490
|
if (!f()) return;
|
|
1471
1491
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1472
1492
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1473
1493
|
}
|
|
1474
|
-
function
|
|
1494
|
+
function wt(e) {
|
|
1475
1495
|
if (e.projectId) return e.projectId;
|
|
1476
|
-
let t =
|
|
1496
|
+
let t = St();
|
|
1477
1497
|
if (t) return t;
|
|
1478
|
-
let n =
|
|
1498
|
+
let n = Ct();
|
|
1479
1499
|
if (n) return n;
|
|
1480
1500
|
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
1501
|
}
|
|
@@ -1484,7 +1504,7 @@ function Ct(e) {
|
|
|
1484
1504
|
function $(e) {
|
|
1485
1505
|
return e == null || e === "" || Number.isNaN(e);
|
|
1486
1506
|
}
|
|
1487
|
-
var
|
|
1507
|
+
var Tt = {
|
|
1488
1508
|
default: (e, t) => $(e) ? String(t ?? "") : String(e),
|
|
1489
1509
|
append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
|
|
1490
1510
|
prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
|
|
@@ -1505,24 +1525,24 @@ var wt = {
|
|
|
1505
1525
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1506
1526
|
}
|
|
1507
1527
|
};
|
|
1508
|
-
function
|
|
1528
|
+
function Et(e) {
|
|
1509
1529
|
return typeof e == "object" && !!e;
|
|
1510
1530
|
}
|
|
1511
|
-
function
|
|
1531
|
+
function Dt(e, t) {
|
|
1512
1532
|
let n = t;
|
|
1513
|
-
for (let t of e.split(".")) if (
|
|
1533
|
+
for (let t of e.split(".")) if (Et(n) && t in n) n = n[t];
|
|
1514
1534
|
else return;
|
|
1515
1535
|
return typeof n == "function" ? n() : n;
|
|
1516
1536
|
}
|
|
1517
|
-
function
|
|
1518
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1537
|
+
function Ot(e, t) {
|
|
1538
|
+
let n = e.split("|").map((e) => e.trim()), r = Dt(n.shift() ?? "", t);
|
|
1519
1539
|
for (let e of n) {
|
|
1520
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1540
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Tt[i];
|
|
1521
1541
|
o && (r = o(r, a));
|
|
1522
1542
|
}
|
|
1523
1543
|
return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1524
1544
|
}
|
|
1525
|
-
function
|
|
1545
|
+
function kt(e, t) {
|
|
1526
1546
|
let n = "", r = 0;
|
|
1527
1547
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1528
1548
|
r += 2;
|
|
@@ -1534,77 +1554,77 @@ function Ot(e, t) {
|
|
|
1534
1554
|
}
|
|
1535
1555
|
i += e[r++];
|
|
1536
1556
|
}
|
|
1537
|
-
n +=
|
|
1557
|
+
n += Ot(i.trim(), t);
|
|
1538
1558
|
} else n += e[r++];
|
|
1539
1559
|
return n;
|
|
1540
1560
|
}
|
|
1541
1561
|
//#endregion
|
|
1542
1562
|
//#region src/picked.ts
|
|
1543
|
-
var
|
|
1563
|
+
var At = class {
|
|
1544
1564
|
static logger = r;
|
|
1545
1565
|
options;
|
|
1546
1566
|
plugins = {};
|
|
1547
|
-
eventBus =
|
|
1567
|
+
eventBus = P();
|
|
1548
1568
|
events;
|
|
1549
1569
|
projectId;
|
|
1550
1570
|
apiUrl;
|
|
1551
1571
|
dashboardUrl;
|
|
1552
1572
|
documentationSiteUrl;
|
|
1553
|
-
session =
|
|
1573
|
+
session = bt();
|
|
1554
1574
|
searchParams = ht();
|
|
1555
|
-
history =
|
|
1556
|
-
components =
|
|
1575
|
+
history = Ve();
|
|
1576
|
+
components = me({ client: this });
|
|
1557
1577
|
experienceInstances = b({ client: this });
|
|
1558
|
-
experiences =
|
|
1559
|
-
frameworks =
|
|
1560
|
-
predicates =
|
|
1561
|
-
features =
|
|
1578
|
+
experiences = oe({ client: this });
|
|
1579
|
+
frameworks = ve({ client: this });
|
|
1580
|
+
predicates = Pe({ client: this });
|
|
1581
|
+
features = Le({ client: this });
|
|
1562
1582
|
conditions = pt();
|
|
1563
|
-
fields =
|
|
1583
|
+
fields = Ke();
|
|
1564
1584
|
responses = ut({ client: this });
|
|
1565
|
-
steps =
|
|
1566
|
-
actions =
|
|
1567
|
-
stateSnapshotStore =
|
|
1568
|
-
evaluateRuleLogicFx =
|
|
1585
|
+
steps = Ye();
|
|
1586
|
+
actions = $e({ client: this });
|
|
1587
|
+
stateSnapshotStore = xe({ client: this });
|
|
1588
|
+
evaluateRuleLogicFx = Ee({ client: this });
|
|
1569
1589
|
start;
|
|
1570
1590
|
readyStore;
|
|
1571
1591
|
preconditionPassedStore;
|
|
1572
1592
|
conditionPassedStore;
|
|
1573
1593
|
lifecycleStageStore;
|
|
1574
|
-
lifecycle =
|
|
1575
|
-
renderStringFx =
|
|
1594
|
+
lifecycle = je({ client: this });
|
|
1595
|
+
renderStringFx = k({
|
|
1576
1596
|
source: this.responses.listStore,
|
|
1577
1597
|
effect: (e, { template: t, context: n }) => {
|
|
1578
1598
|
let r = {};
|
|
1579
1599
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1580
|
-
return
|
|
1600
|
+
return kt(t, {
|
|
1581
1601
|
...n,
|
|
1582
1602
|
responses: r
|
|
1583
1603
|
});
|
|
1584
1604
|
}
|
|
1585
1605
|
});
|
|
1586
1606
|
constructor(e) {
|
|
1587
|
-
this.events =
|
|
1607
|
+
this.events = Ue(this.eventBus), this.projectId = wt(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || mt(), 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
1608
|
type: "load",
|
|
1589
1609
|
version: te()
|
|
1590
1610
|
});
|
|
1591
1611
|
}
|
|
1592
1612
|
registerFramework = (e) => {
|
|
1593
|
-
|
|
1613
|
+
ye(e, this.frameworks);
|
|
1594
1614
|
};
|
|
1595
1615
|
registerComponent = (e, t) => {
|
|
1596
|
-
|
|
1616
|
+
he(e, t, this.components);
|
|
1597
1617
|
};
|
|
1598
1618
|
registerPlugin = (e) => {
|
|
1599
|
-
|
|
1619
|
+
le(this, e, this.plugins);
|
|
1600
1620
|
let t = this.plugins[e.name];
|
|
1601
1621
|
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1602
1622
|
};
|
|
1603
1623
|
registerFeature = (e, t) => {
|
|
1604
|
-
|
|
1624
|
+
Re(e, t, this.features);
|
|
1605
1625
|
};
|
|
1606
1626
|
registerPredicate = (e, t) => {
|
|
1607
|
-
|
|
1627
|
+
Fe(e, t, this.predicates);
|
|
1608
1628
|
};
|
|
1609
1629
|
registerCondition = (e) => {
|
|
1610
1630
|
this.conditions.register(e);
|
|
@@ -1613,13 +1633,13 @@ var kt = class {
|
|
|
1613
1633
|
this.fields.register(e);
|
|
1614
1634
|
};
|
|
1615
1635
|
registerStep = (e) => {
|
|
1616
|
-
|
|
1636
|
+
Xe(e, this.steps);
|
|
1617
1637
|
};
|
|
1618
1638
|
registerAction = (e, t) => {
|
|
1619
|
-
|
|
1639
|
+
et(e, t, this.actions);
|
|
1620
1640
|
};
|
|
1621
1641
|
registerExperience = (e) => {
|
|
1622
|
-
e.component &&
|
|
1642
|
+
e.component && he(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1623
1643
|
};
|
|
1624
1644
|
launchExperienceById = async (e, t) => {
|
|
1625
1645
|
this.experiences.launch({
|
|
@@ -1704,20 +1724,20 @@ var kt = class {
|
|
|
1704
1724
|
};
|
|
1705
1725
|
//#endregion
|
|
1706
1726
|
//#region src/entities/component/lazyComponent.ts
|
|
1707
|
-
function
|
|
1727
|
+
function jt(e) {
|
|
1708
1728
|
return {
|
|
1709
1729
|
$$type: "lazy-component",
|
|
1710
1730
|
load: e
|
|
1711
1731
|
};
|
|
1712
1732
|
}
|
|
1713
|
-
function
|
|
1733
|
+
function Mt(e) {
|
|
1714
1734
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1715
1735
|
}
|
|
1716
1736
|
//#endregion
|
|
1717
1737
|
//#region src/exports.ts
|
|
1718
|
-
var
|
|
1719
|
-
let t = new
|
|
1738
|
+
var Nt = (e) => {
|
|
1739
|
+
let t = new At(e);
|
|
1720
1740
|
return d(t), t;
|
|
1721
1741
|
};
|
|
1722
1742
|
//#endregion
|
|
1723
|
-
export {
|
|
1743
|
+
export { At as Picked, Nt as createClient, ce as createPluginEffect, E as createStorageKey, n as evaluateRuleLogic, xt as getPickedConfig, Mt as isLazyLoader, _ as isPickedRoot, jt 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 };
|