@picked/client 0.0.1-dev.1783642866820 → 0.0.1-dev.1784001148032
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-BXhgvSc-.cjs → api-B1wdTDNv.cjs} +1 -1
- package/dist/{api-4pMvd_kR.js → api-BJ8EHkg5.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dom-observer/index.js +1 -1
- 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/docs/actions.mdx +2 -16
- package/dist/docs/sdk/actions.md +3 -21
- package/dist/{dom-BwmTHeT7.js → dom-CZyRgp2P.js} +17 -12
- package/dist/dom-CdxDV3e-.cjs +1 -0
- package/dist/esm/index.js +488 -384
- package/dist/esm/plugins/dom-observer/index.js +1 -1
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/plugins/history-browser-storage/index.js +33 -11
- package/dist/esm/server/index.js +2 -2
- package/dist/experience-instance-BbSXoRrr.cjs +1 -0
- package/dist/{experience-instance-pTMwxW1R.js → experience-instance-M2kR3nTp.js} +200 -207
- package/dist/{plugin-DfzEBtiA.js → plugin-B04iPuj_.js} +1 -1
- package/dist/{plugin-DDe5zJhy.cjs → plugin-D3z3IXOb.cjs} +1 -1
- package/dist/types/entities/action/action.d.ts +2 -7
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +2 -2
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +23 -10
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts +30 -16
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +1 -0
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/picked.d.ts +10 -14
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +17 -0
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +94 -0
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/dom-CDrHc_j9.cjs +0 -1
- package/dist/experience-instance-DunhI3b8.cjs +0 -1
- package/dist/types/utils/node-tree/get-next-node-from-action.d.ts +0 -24
- package/dist/types/utils/node-tree/get-next-node-from-action.d.ts.map +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -2,16 +2,25 @@ import { t as e } from "../object-BUDGxEqy.js";
|
|
|
2
2
|
import { n as t, t as n } from "../rules-logic-HesIUCu6.js";
|
|
3
3
|
import { t as r } from "../logger-DMN6TxJJ.js";
|
|
4
4
|
import { a as i, c as a, d as o, f as s, i as c, l, m as u, n as d, o as f, r as p, s as m, t as h, u as g } from "../supports-CO9bJGNl.js";
|
|
5
|
-
import { a as _,
|
|
6
|
-
import { l as
|
|
7
|
-
import { i as
|
|
8
|
-
import { n as te, r as ne } from "../api-
|
|
5
|
+
import { a as _, c as v, i as y, o as b, r as ee, t as x } from "../dom-CZyRgp2P.js";
|
|
6
|
+
import { l as S, n as C, r as w, u as T } from "../experience-instance-M2kR3nTp.js";
|
|
7
|
+
import { i as E, n as D, r as O, t as k } from "../storage-1MW3-_As.js";
|
|
8
|
+
import { n as te, r as ne } from "../api-BJ8EHkg5.js";
|
|
9
9
|
import { t as re } from "../id-Bo4RBeOs.js";
|
|
10
|
-
import { attach as
|
|
11
|
-
import { createFactory as
|
|
10
|
+
import { attach as A, combine as j, createApi as M, createDomain as N, createEffect as P, createEvent as F, createStore as I, sample as L } from "effector";
|
|
11
|
+
import { createFactory as R, invoke as z } from "@withease/factories";
|
|
12
12
|
//#region src/entities/experience/experience.ts
|
|
13
|
-
var
|
|
14
|
-
|
|
13
|
+
var B = N("experience");
|
|
14
|
+
function ie(e, t, n) {
|
|
15
|
+
let r = new Set(t.filter((e) => e.elements.length > 0).map((e) => e.selector));
|
|
16
|
+
for (let t of e) {
|
|
17
|
+
if (t.placement !== "replace" || r.has(t.selector)) continue;
|
|
18
|
+
let e = y(t.selector);
|
|
19
|
+
!e || e === n || `${t.selector}${e}${n}`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
var ae = R(({ client: e, experience: r }) => {
|
|
23
|
+
let i = B.store(r), a = M(i, { merge(e, t) {
|
|
15
24
|
return {
|
|
16
25
|
...e,
|
|
17
26
|
...t.experience
|
|
@@ -21,24 +30,24 @@ var z = M("experience"), ie = L(({ client: e, experience: r }) => {
|
|
|
21
30
|
decisionLogic: e.condition,
|
|
22
31
|
targetSelectors: e.targets,
|
|
23
32
|
initializeOpenLogic: e.initializeOpen
|
|
24
|
-
})), s =
|
|
25
|
-
let r = e.nodes.filter(
|
|
33
|
+
})), s = j(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 = j(i, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
|
|
34
|
+
let r = e.nodes.filter(T).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(S).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
|
|
26
35
|
return {
|
|
27
36
|
steps: r,
|
|
28
37
|
nodes: e.nodes,
|
|
29
38
|
edges: e.edges,
|
|
30
39
|
conditions: i
|
|
31
40
|
};
|
|
32
|
-
}), l = r.actions ?? [], u, d =
|
|
41
|
+
}), l = r.actions ?? [], u, d = A({
|
|
33
42
|
source: o,
|
|
34
43
|
effect: (t, n) => {
|
|
35
|
-
let i =
|
|
36
|
-
i.forEach(({ elements: e }) => e.forEach((e) =>
|
|
44
|
+
let i = _(t.targetSelectors, r.id);
|
|
45
|
+
i.forEach(({ elements: e }) => e.forEach((e) => v(e, r.id))), x(i, r.id, r.key).forEach((t) => {
|
|
37
46
|
n ? e.experienceInstances.spawn(u, t, n) : e.experienceInstances.spawn(u, t);
|
|
38
|
-
});
|
|
47
|
+
}), ie(t.targetSelectors, i, r.id);
|
|
39
48
|
}
|
|
40
|
-
}), f =
|
|
41
|
-
source:
|
|
49
|
+
}), f = A({
|
|
50
|
+
source: j({
|
|
42
51
|
preconditionPassed: e.preconditionPassedStore,
|
|
43
52
|
isUser: e.session.store.map((e) => e.isUser, { skipVoid: !1 }),
|
|
44
53
|
config: o
|
|
@@ -46,9 +55,9 @@ var z = M("experience"), ie = L(({ client: e, experience: r }) => {
|
|
|
46
55
|
effect: async ({ preconditionPassed: i, isUser: a, config: o }) => {
|
|
47
56
|
if (!i || !a) return !1;
|
|
48
57
|
let { decisionLogic: s, targetSelectors: c } = o;
|
|
49
|
-
return c.length === 0 ||
|
|
58
|
+
return c.length === 0 || _(c, r.id).length < 1 ? !1 : s === void 0 ? !0 : t(s) ? await n(e, s) === !0 : !0;
|
|
50
59
|
}
|
|
51
|
-
}), p =
|
|
60
|
+
}), p = P(async () => {
|
|
52
61
|
if (!e.contentLoader) return !0;
|
|
53
62
|
try {
|
|
54
63
|
await e.contentLoader({
|
|
@@ -59,26 +68,26 @@ var z = M("experience"), ie = L(({ client: e, experience: r }) => {
|
|
|
59
68
|
`${r.id}`;
|
|
60
69
|
}
|
|
61
70
|
return !0;
|
|
62
|
-
}), m =
|
|
63
|
-
return
|
|
71
|
+
}), m = F(), h = F(), g = B.createStore(void 0, { skipVoid: !1 }).on(m, (e, t) => t).on(h, (e, t) => t);
|
|
72
|
+
return L({
|
|
64
73
|
clock: m,
|
|
65
74
|
target: f
|
|
66
|
-
}),
|
|
75
|
+
}), L({
|
|
67
76
|
clock: f.doneData,
|
|
68
77
|
source: g,
|
|
69
78
|
filter: (e, t) => t,
|
|
70
79
|
fn: (e) => e,
|
|
71
80
|
target: d
|
|
72
|
-
}),
|
|
81
|
+
}), L({
|
|
73
82
|
clock: f.doneData,
|
|
74
83
|
filter: Boolean,
|
|
75
84
|
target: p
|
|
76
|
-
}),
|
|
85
|
+
}), L({
|
|
77
86
|
clock: h,
|
|
78
87
|
source: g,
|
|
79
88
|
fn: (e) => e,
|
|
80
89
|
target: d
|
|
81
|
-
}),
|
|
90
|
+
}), L({
|
|
82
91
|
clock: h,
|
|
83
92
|
target: p
|
|
84
93
|
}), u = {
|
|
@@ -97,22 +106,60 @@ var z = M("experience"), ie = L(({ client: e, experience: r }) => {
|
|
|
97
106
|
prepareExperienceContentFx: p
|
|
98
107
|
}, u;
|
|
99
108
|
});
|
|
100
|
-
function
|
|
101
|
-
return
|
|
109
|
+
function oe(e) {
|
|
110
|
+
return z(ae, e);
|
|
111
|
+
}
|
|
112
|
+
var se = 5e3;
|
|
113
|
+
function ce(e, t) {
|
|
114
|
+
return new Promise((n) => {
|
|
115
|
+
let r = setTimeout(n, t);
|
|
116
|
+
e.then(() => {
|
|
117
|
+
clearTimeout(r), n();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function le(e) {
|
|
122
|
+
return e.configStore.getState().targetSelectors.filter((e) => e.placement === "replace").map((e) => e.selector);
|
|
123
|
+
}
|
|
124
|
+
function ue(e) {
|
|
125
|
+
let t = /* @__PURE__ */ new Map();
|
|
126
|
+
for (let n of e) for (let e of le(n)) t.set(e, (t.get(e) ?? 0) + 1);
|
|
127
|
+
let n = [], r = [];
|
|
128
|
+
for (let i of e) le(i).some((e) => (t.get(e) ?? 0) > 1) ? n.push(i) : r.push(i);
|
|
129
|
+
return {
|
|
130
|
+
serialised: n,
|
|
131
|
+
parallel: r
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
async function de(e) {
|
|
135
|
+
let t;
|
|
136
|
+
try {
|
|
137
|
+
let n = new Promise((n) => {
|
|
138
|
+
t = e.initialiseFx.finally.watch(() => n());
|
|
139
|
+
});
|
|
140
|
+
await e.shouldInitialiseFx() && await ce(n, se);
|
|
141
|
+
} catch {
|
|
142
|
+
`${e.id}`;
|
|
143
|
+
} finally {
|
|
144
|
+
t?.();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async function fe(e) {
|
|
148
|
+
for (let t of e) await de(t);
|
|
102
149
|
}
|
|
103
|
-
var
|
|
104
|
-
let t =
|
|
150
|
+
var pe = R(({ client: e }) => {
|
|
151
|
+
let t = B.store({}), n = M(t, { register(e, t) {
|
|
105
152
|
return {
|
|
106
153
|
...e,
|
|
107
154
|
[t.id]: t
|
|
108
155
|
};
|
|
109
|
-
} }), r =
|
|
110
|
-
n.register(
|
|
156
|
+
} }), r = F(), i = P((t) => {
|
|
157
|
+
n.register(oe({
|
|
111
158
|
client: e,
|
|
112
159
|
experience: t
|
|
113
160
|
}));
|
|
114
161
|
});
|
|
115
|
-
|
|
162
|
+
L({
|
|
116
163
|
clock: r,
|
|
117
164
|
source: t,
|
|
118
165
|
filter: (e, t) => e[t.id] !== void 0,
|
|
@@ -125,7 +172,7 @@ var oe = L(({ client: e }) => {
|
|
|
125
172
|
experience: t,
|
|
126
173
|
strategy: "override"
|
|
127
174
|
});
|
|
128
|
-
}),
|
|
175
|
+
}), L({
|
|
129
176
|
clock: r,
|
|
130
177
|
source: t,
|
|
131
178
|
filter: (e, t) => e[t.id] === void 0,
|
|
@@ -139,7 +186,7 @@ var oe = L(({ client: e }) => {
|
|
|
139
186
|
function s(e) {
|
|
140
187
|
return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
|
|
141
188
|
}
|
|
142
|
-
let c =
|
|
189
|
+
let c = A({
|
|
143
190
|
source: t,
|
|
144
191
|
effect: (e, t) => {
|
|
145
192
|
let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
|
|
@@ -157,7 +204,7 @@ var oe = L(({ client: e }) => {
|
|
|
157
204
|
getById: o,
|
|
158
205
|
getByKey: s,
|
|
159
206
|
launch: c,
|
|
160
|
-
open:
|
|
207
|
+
open: A({
|
|
161
208
|
source: {
|
|
162
209
|
experiences: t,
|
|
163
210
|
instances: e.experienceInstances.listStore
|
|
@@ -184,28 +231,29 @@ var oe = L(({ client: e }) => {
|
|
|
184
231
|
}
|
|
185
232
|
}),
|
|
186
233
|
listStore: a,
|
|
187
|
-
initialiseExperiencesFx:
|
|
234
|
+
initialiseExperiencesFx: A({
|
|
188
235
|
source: a,
|
|
189
|
-
effect: (e) => {
|
|
190
|
-
|
|
236
|
+
effect: async (e) => {
|
|
237
|
+
let { serialised: t, parallel: n } = ue(e);
|
|
238
|
+
await Promise.all([fe(t), ...n.map((e) => de(e))]);
|
|
191
239
|
}
|
|
192
240
|
})
|
|
193
241
|
};
|
|
194
242
|
});
|
|
195
|
-
function
|
|
196
|
-
return
|
|
243
|
+
function me(e) {
|
|
244
|
+
return z(pe, e);
|
|
197
245
|
}
|
|
198
|
-
var
|
|
246
|
+
var he = async (e) => {
|
|
199
247
|
await e.experiences.initialiseExperiencesFx();
|
|
200
248
|
};
|
|
201
249
|
//#endregion
|
|
202
250
|
//#region src/entities/plugin/plugin.ts
|
|
203
|
-
function
|
|
204
|
-
return
|
|
251
|
+
function ge(e) {
|
|
252
|
+
return P(async () => {
|
|
205
253
|
await e();
|
|
206
254
|
});
|
|
207
255
|
}
|
|
208
|
-
var
|
|
256
|
+
var _e = (e, t, n) => {
|
|
209
257
|
let r = t.name, i = t.setup(e);
|
|
210
258
|
if (i) {
|
|
211
259
|
let e = n[r] ?? {};
|
|
@@ -214,29 +262,29 @@ var ue = (e, t, n) => {
|
|
|
214
262
|
...i
|
|
215
263
|
});
|
|
216
264
|
}
|
|
217
|
-
},
|
|
265
|
+
}, ve = N("component"), ye = R(({ client: e, component: t, name: n }) => ({
|
|
218
266
|
name: n,
|
|
219
267
|
component: t,
|
|
220
268
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
221
269
|
}));
|
|
222
|
-
function
|
|
223
|
-
return
|
|
270
|
+
function be(e) {
|
|
271
|
+
return z(ye, e);
|
|
224
272
|
}
|
|
225
|
-
var
|
|
226
|
-
let t =
|
|
273
|
+
var xe = R(({ client: e }) => {
|
|
274
|
+
let t = ve.store({}), n = M(t, { register(e, t) {
|
|
227
275
|
return {
|
|
228
276
|
...e,
|
|
229
277
|
[t.name]: t
|
|
230
278
|
};
|
|
231
|
-
} }), i =
|
|
232
|
-
|
|
279
|
+
} }), i = F();
|
|
280
|
+
L({
|
|
233
281
|
clock: i,
|
|
234
282
|
source: t,
|
|
235
283
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
236
284
|
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
237
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
285
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), L({
|
|
238
286
|
clock: i,
|
|
239
|
-
fn: ({ name: t, component: n }) =>
|
|
287
|
+
fn: ({ name: t, component: n }) => be({
|
|
240
288
|
client: e,
|
|
241
289
|
name: t,
|
|
242
290
|
component: n
|
|
@@ -253,27 +301,27 @@ var me = L(({ client: e }) => {
|
|
|
253
301
|
listStore: a
|
|
254
302
|
};
|
|
255
303
|
});
|
|
256
|
-
function
|
|
257
|
-
return
|
|
304
|
+
function Se(e) {
|
|
305
|
+
return z(xe, e);
|
|
258
306
|
}
|
|
259
|
-
var
|
|
307
|
+
var Ce = (e, t, n) => {
|
|
260
308
|
n.register({
|
|
261
309
|
name: e,
|
|
262
310
|
component: t
|
|
263
311
|
});
|
|
264
|
-
},
|
|
265
|
-
let t =
|
|
312
|
+
}, we = N("framework"), Te = R((e) => {
|
|
313
|
+
let t = we.store({}), n = M(t, { register(e, t) {
|
|
266
314
|
return {
|
|
267
315
|
...e,
|
|
268
316
|
[t.name]: t.framework
|
|
269
317
|
};
|
|
270
|
-
} }), i =
|
|
271
|
-
|
|
318
|
+
} }), i = F();
|
|
319
|
+
L({
|
|
272
320
|
clock: i,
|
|
273
321
|
source: t,
|
|
274
322
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
275
323
|
fn: (e, { name: t }) => `Framework '${t}' already registered. Registering again will override the previous registration.`
|
|
276
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
324
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), L({
|
|
277
325
|
clock: i,
|
|
278
326
|
target: n.register
|
|
279
327
|
});
|
|
@@ -287,34 +335,34 @@ var B = (e, t, n) => {
|
|
|
287
335
|
listStore: a
|
|
288
336
|
};
|
|
289
337
|
});
|
|
290
|
-
function
|
|
291
|
-
return
|
|
338
|
+
function Ee(e) {
|
|
339
|
+
return z(Te, e);
|
|
292
340
|
}
|
|
293
|
-
var
|
|
341
|
+
var De = (e, t) => {
|
|
294
342
|
t.register({
|
|
295
343
|
name: e.name,
|
|
296
344
|
framework: e
|
|
297
345
|
});
|
|
298
|
-
},
|
|
346
|
+
}, Oe = R(({ client: e }) => {
|
|
299
347
|
let t = "window" in globalThis, n = {
|
|
300
348
|
location: t ? globalThis.location : void 0,
|
|
301
349
|
document: t ? globalThis.document : void 0,
|
|
302
350
|
sessionStorage: t ? globalThis.sessionStorage : void 0,
|
|
303
351
|
localStorage: t ? globalThis.localStorage : void 0
|
|
304
352
|
};
|
|
305
|
-
return
|
|
353
|
+
return j(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
|
|
306
354
|
client: e,
|
|
307
355
|
responses: t,
|
|
308
356
|
fields: r,
|
|
309
357
|
...n
|
|
310
358
|
}));
|
|
311
359
|
});
|
|
312
|
-
function
|
|
313
|
-
return
|
|
360
|
+
function ke(e) {
|
|
361
|
+
return z(Oe, e);
|
|
314
362
|
}
|
|
315
363
|
//#endregion
|
|
316
364
|
//#region src/logic-engine.ts
|
|
317
|
-
function
|
|
365
|
+
function Ae(e) {
|
|
318
366
|
return typeof e == "number" && !isNaN(e);
|
|
319
367
|
}
|
|
320
368
|
function V(e) {
|
|
@@ -323,70 +371,70 @@ function V(e) {
|
|
|
323
371
|
function H(e) {
|
|
324
372
|
return Array.isArray(e);
|
|
325
373
|
}
|
|
326
|
-
function
|
|
374
|
+
function je(e) {
|
|
327
375
|
return e instanceof Promise;
|
|
328
376
|
}
|
|
329
|
-
function
|
|
377
|
+
function Me(e) {
|
|
330
378
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
331
379
|
}
|
|
332
|
-
function
|
|
333
|
-
if (
|
|
380
|
+
function U(e) {
|
|
381
|
+
if (Ae(e)) return e;
|
|
334
382
|
let t = parseFloat(`${e}`);
|
|
335
383
|
return isNaN(t) ? 0 : t;
|
|
336
384
|
}
|
|
337
|
-
function
|
|
385
|
+
function W(e) {
|
|
338
386
|
return `${e}`;
|
|
339
387
|
}
|
|
340
|
-
var
|
|
388
|
+
var Ne = {
|
|
341
389
|
"==": (e, t) => e == t,
|
|
342
390
|
"===": (e, t) => e === t,
|
|
343
391
|
"!=": (e, t) => e != t,
|
|
344
392
|
"!==": (e, t) => e !== t,
|
|
345
|
-
">": (e, t) =>
|
|
346
|
-
">=": (e, t) =>
|
|
393
|
+
">": (e, t) => U(e) > U(t),
|
|
394
|
+
">=": (e, t) => U(e) >= U(t),
|
|
347
395
|
"<": (e, t, n) => {
|
|
348
|
-
let r =
|
|
396
|
+
let r = U(e), i = U(t);
|
|
349
397
|
if (n === void 0) return r < i;
|
|
350
|
-
let a =
|
|
398
|
+
let a = U(n);
|
|
351
399
|
return r < i && i < a;
|
|
352
400
|
},
|
|
353
401
|
"<=": (e, t, n) => {
|
|
354
|
-
let r =
|
|
402
|
+
let r = U(e), i = U(t);
|
|
355
403
|
if (n === void 0) return r <= i;
|
|
356
|
-
let a =
|
|
404
|
+
let a = U(n);
|
|
357
405
|
return r <= i && i <= a;
|
|
358
406
|
},
|
|
359
|
-
"!!": async (e) => await
|
|
360
|
-
"!": async (e) => !await
|
|
361
|
-
"%": (e, t) =>
|
|
407
|
+
"!!": async (e) => await K(e),
|
|
408
|
+
"!": async (e) => !await K(e),
|
|
409
|
+
"%": (e, t) => U(e) % U(t),
|
|
362
410
|
log: (e) => (console.log(e), e),
|
|
363
|
-
in: (e, t) => t ? V(t) ? t.indexOf(
|
|
364
|
-
cat: (...e) => e.map(
|
|
411
|
+
in: (e, t) => t ? V(t) ? t.indexOf(W(e)) !== -1 : H(t) ? t.includes(e) : !1 : !1,
|
|
412
|
+
cat: (...e) => e.map(W).join(""),
|
|
365
413
|
substr: (e, t, n) => {
|
|
366
|
-
let r =
|
|
414
|
+
let r = W(e), i = U(t);
|
|
367
415
|
if (n === void 0) return r.substr(i);
|
|
368
|
-
let a =
|
|
416
|
+
let a = U(n);
|
|
369
417
|
if (a < 0) {
|
|
370
418
|
let e = r.substr(i);
|
|
371
419
|
return e.substr(0, e.length + a);
|
|
372
420
|
}
|
|
373
421
|
return r.substr(i, a);
|
|
374
422
|
},
|
|
375
|
-
"+": (...e) => e.reduce((e, t) =>
|
|
376
|
-
"*": (...e) => e.reduce((e, t) =>
|
|
423
|
+
"+": (...e) => e.reduce((e, t) => U(e) + U(t), 0),
|
|
424
|
+
"*": (...e) => e.reduce((e, t) => U(e) * U(t), 1),
|
|
377
425
|
"-": (e, t) => {
|
|
378
|
-
let n =
|
|
379
|
-
return t === void 0 ? -n : n -
|
|
426
|
+
let n = U(e);
|
|
427
|
+
return t === void 0 ? -n : n - U(t);
|
|
380
428
|
},
|
|
381
|
-
"/": (e, t) =>
|
|
382
|
-
min: (...e) => Math.min(...e.map(
|
|
383
|
-
max: (...e) => Math.max(...e.map(
|
|
429
|
+
"/": (e, t) => U(e) / U(t),
|
|
430
|
+
min: (...e) => Math.min(...e.map(U)),
|
|
431
|
+
max: (...e) => Math.max(...e.map(U)),
|
|
384
432
|
merge: (...e) => e.reduce((e, t) => H(t) ? e.concat(t) : e.concat([t]), []),
|
|
385
433
|
var(e, t) {
|
|
386
434
|
let n = arguments.length > 1 ? t : null;
|
|
387
435
|
if (e === "" || e === "." || e == null) return this;
|
|
388
436
|
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
389
|
-
let r =
|
|
437
|
+
let r = W(e);
|
|
390
438
|
if (r === "" || r === ".") return this;
|
|
391
439
|
let i = r.split("."), a = this;
|
|
392
440
|
for (let e of i) {
|
|
@@ -401,16 +449,16 @@ var we = {
|
|
|
401
449
|
async missing(...e) {
|
|
402
450
|
let t = H(e[0]) ? e[0] : e, n = [];
|
|
403
451
|
for (let e of t) {
|
|
404
|
-
let t = await
|
|
452
|
+
let t = await G({ var: e }, this);
|
|
405
453
|
(t === null || t === "") && n.push(`${e}`);
|
|
406
454
|
}
|
|
407
455
|
return n;
|
|
408
456
|
},
|
|
409
457
|
async missing_some(e, t) {
|
|
410
|
-
let n = await
|
|
458
|
+
let n = await G({ missing: t }, this);
|
|
411
459
|
if (!H(n) || !H(t)) return [];
|
|
412
460
|
let r = n.filter(V);
|
|
413
|
-
return t.filter(V).length - r.length >=
|
|
461
|
+
return t.filter(V).length - r.length >= U(e) ? [] : r;
|
|
414
462
|
},
|
|
415
463
|
invoke(...e) {
|
|
416
464
|
let [t, ...n] = e;
|
|
@@ -424,101 +472,101 @@ var we = {
|
|
|
424
472
|
let [t, i] = e;
|
|
425
473
|
n = t, r = i;
|
|
426
474
|
}
|
|
427
|
-
return !V(n) || !V(r) ? !1 : new RegExp(n, r).test(
|
|
475
|
+
return !V(n) || !V(r) ? !1 : new RegExp(n, r).test(W(t));
|
|
428
476
|
},
|
|
429
477
|
throw(e) {
|
|
430
|
-
throw Error(
|
|
478
|
+
throw Error(W(e));
|
|
431
479
|
}
|
|
432
480
|
};
|
|
433
|
-
async function
|
|
481
|
+
async function G(e, t) {
|
|
434
482
|
if (!e) return e;
|
|
435
|
-
if (
|
|
436
|
-
if (H(e)) return Promise.all(e.map((e) =>
|
|
437
|
-
if (!
|
|
438
|
-
let n =
|
|
483
|
+
if (je(e)) return G(await e, t);
|
|
484
|
+
if (H(e)) return Promise.all(e.map((e) => G(e, t)));
|
|
485
|
+
if (!Me(e)) return e;
|
|
486
|
+
let n = Pe(e), r = n ? e[n] ?? [] : [];
|
|
439
487
|
switch (H(r) || (r = [r]), n) {
|
|
440
488
|
case "if":
|
|
441
489
|
case "?:":
|
|
442
|
-
for (let e = 0; e < r.length - 1; e += 2) if (await
|
|
443
|
-
return r.length % 2 == 1 ?
|
|
490
|
+
for (let e = 0; e < r.length - 1; e += 2) if (await K(await G(r[e], t))) return G(r[e + 1], t);
|
|
491
|
+
return r.length % 2 == 1 ? G(r[r.length - 1], t) : null;
|
|
444
492
|
case "and": {
|
|
445
493
|
let e = null;
|
|
446
|
-
for (let n of r) if (e = await
|
|
494
|
+
for (let n of r) if (e = await G(n, t), !await K(e)) return e;
|
|
447
495
|
return e;
|
|
448
496
|
}
|
|
449
497
|
case "or": {
|
|
450
498
|
let e = null;
|
|
451
|
-
for (let n of r) if (e = await
|
|
499
|
+
for (let n of r) if (e = await G(n, t), await K(e)) return e;
|
|
452
500
|
return e;
|
|
453
501
|
}
|
|
454
502
|
case "map": {
|
|
455
|
-
let e = await
|
|
456
|
-
return H(e) ? await Promise.all(e.map((e) =>
|
|
503
|
+
let e = await G(r[0], t);
|
|
504
|
+
return H(e) ? await Promise.all(e.map((e) => G(r[1], e))) : [];
|
|
457
505
|
}
|
|
458
506
|
case "filter": {
|
|
459
|
-
let e = await
|
|
507
|
+
let e = await G(r[0], t);
|
|
460
508
|
return H(e) ? (await Promise.all(e.map(async (e) => ({
|
|
461
509
|
item: e,
|
|
462
|
-
shouldInclude: await
|
|
510
|
+
shouldInclude: await K(await G(r[1], e))
|
|
463
511
|
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
464
512
|
}
|
|
465
513
|
case "reduce": {
|
|
466
|
-
let e = await
|
|
467
|
-
if (!H(e)) return r.length > 2 ? await
|
|
468
|
-
let n = r[1], i = r.length > 2 ? await
|
|
469
|
-
for (let t of e) i = await
|
|
514
|
+
let e = await G(r[0], t);
|
|
515
|
+
if (!H(e)) return r.length > 2 ? await G(r[2], t) : null;
|
|
516
|
+
let n = r[1], i = r.length > 2 ? await G(r[2], t) : null;
|
|
517
|
+
for (let t of e) i = await G(n, {
|
|
470
518
|
current: t,
|
|
471
519
|
accumulator: i
|
|
472
520
|
});
|
|
473
521
|
return i;
|
|
474
522
|
}
|
|
475
523
|
case "all": {
|
|
476
|
-
let e = await
|
|
524
|
+
let e = await G(r[0], t);
|
|
477
525
|
if (!H(e) || e.length === 0) return !1;
|
|
478
|
-
for (let t of e) if (!await
|
|
526
|
+
for (let t of e) if (!await K(await G(r[1], t))) return !1;
|
|
479
527
|
return !0;
|
|
480
528
|
}
|
|
481
529
|
case "some": {
|
|
482
|
-
let e = await
|
|
530
|
+
let e = await G(r[0], t);
|
|
483
531
|
if (!H(e)) return !1;
|
|
484
|
-
for (let t of e) if (await
|
|
532
|
+
for (let t of e) if (await K(await G(r[1], t))) return !0;
|
|
485
533
|
return !1;
|
|
486
534
|
}
|
|
487
535
|
case "none": {
|
|
488
|
-
let e = await
|
|
536
|
+
let e = await G(r[0], t);
|
|
489
537
|
if (!H(e)) return !0;
|
|
490
|
-
for (let t of e) if (await
|
|
538
|
+
for (let t of e) if (await K(await G(r[1], t))) return !1;
|
|
491
539
|
return !0;
|
|
492
540
|
}
|
|
493
541
|
case "catch": try {
|
|
494
|
-
return await
|
|
542
|
+
return await G(r[0], t);
|
|
495
543
|
} catch (e) {
|
|
496
|
-
return
|
|
544
|
+
return Me(e) ? await G(e, t) : r[1] ? await G(r[1], e) : e instanceof Error ? e.message : e;
|
|
497
545
|
}
|
|
498
546
|
}
|
|
499
|
-
let i = await Promise.all(r.map((e) =>
|
|
547
|
+
let i = await Promise.all(r.map((e) => G(e, t))), a = n ? Ne[n] : void 0;
|
|
500
548
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
501
549
|
return a.apply(t, i);
|
|
502
550
|
}
|
|
503
|
-
async function
|
|
504
|
-
return
|
|
551
|
+
async function K(e) {
|
|
552
|
+
return je(e) ? K(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
505
553
|
}
|
|
506
|
-
function
|
|
554
|
+
function Pe(e) {
|
|
507
555
|
return Object.keys(e)[0];
|
|
508
556
|
}
|
|
509
557
|
//#endregion
|
|
510
558
|
//#region src/lifecycle/rules-logic.ts
|
|
511
|
-
function
|
|
559
|
+
function q(e, t, n) {
|
|
512
560
|
return new Proxy(Object.create(null), { get(r, i) {
|
|
513
561
|
if (typeof i != "string") return;
|
|
514
562
|
let a = e.find((e) => e.key === i);
|
|
515
|
-
if (a !== void 0) return async () => n.has(i) ? !1 : await
|
|
563
|
+
if (a !== void 0) return async () => n.has(i) ? !1 : await G(a.logic, {
|
|
516
564
|
...t,
|
|
517
|
-
conditions:
|
|
565
|
+
conditions: q(e, t, new Set(n).add(i))
|
|
518
566
|
}) === !0;
|
|
519
567
|
} });
|
|
520
568
|
}
|
|
521
|
-
var
|
|
569
|
+
var Fe = R(({ client: e }) => A({
|
|
522
570
|
source: {
|
|
523
571
|
stateSnapshot: e.stateSnapshotStore,
|
|
524
572
|
predicates: e.predicates.listStore,
|
|
@@ -555,21 +603,21 @@ var De = L(({ client: e }) => k({
|
|
|
555
603
|
features: u,
|
|
556
604
|
...s
|
|
557
605
|
};
|
|
558
|
-
return await
|
|
606
|
+
return await G(o, {
|
|
559
607
|
...d,
|
|
560
|
-
conditions:
|
|
608
|
+
conditions: q(a, d, /* @__PURE__ */ new Set())
|
|
561
609
|
});
|
|
562
610
|
}
|
|
563
611
|
}));
|
|
564
|
-
function
|
|
565
|
-
return
|
|
612
|
+
function Ie(e) {
|
|
613
|
+
return z(Fe, e);
|
|
566
614
|
}
|
|
567
615
|
//#endregion
|
|
568
616
|
//#region src/ping.ts
|
|
569
|
-
var
|
|
617
|
+
var Le = 6e3, Re = k("last_ping", "global"), ze = async (e) => {
|
|
570
618
|
try {
|
|
571
|
-
let t = Date.now(), n =
|
|
572
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
619
|
+
let t = Date.now(), n = D.get(Re), r = 0;
|
|
620
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < Le) return !0;
|
|
573
621
|
let i = {
|
|
574
622
|
projectId: e.projectId,
|
|
575
623
|
path: window.location.pathname
|
|
@@ -580,120 +628,120 @@ var ke = 6e3, Ae = O("last_ping", "global"), je = async (e) => {
|
|
|
580
628
|
} catch {
|
|
581
629
|
return !1;
|
|
582
630
|
}
|
|
583
|
-
}, J =
|
|
584
|
-
let t = J.store(!1), r =
|
|
631
|
+
}, J = N("lifecycle"), Be = R(({ client: e }) => {
|
|
632
|
+
let t = J.store(!1), r = I(void 0, {
|
|
585
633
|
skipVoid: !1,
|
|
586
634
|
domain: J
|
|
587
|
-
}), i =
|
|
635
|
+
}), i = I(void 0, {
|
|
588
636
|
skipVoid: !1,
|
|
589
637
|
domain: J
|
|
590
|
-
}), a = J.store("idle"), o = J.store([]), s =
|
|
638
|
+
}), a = J.store("idle"), o = J.store([]), s = I(void 0, {
|
|
591
639
|
skipVoid: !1,
|
|
592
640
|
domain: J
|
|
593
|
-
}), l =
|
|
641
|
+
}), l = I(void 0, {
|
|
594
642
|
skipVoid: !1,
|
|
595
643
|
domain: J
|
|
596
|
-
}), u =
|
|
644
|
+
}), u = F(), d = F(), f = F(), p = F(), m = F(), h = F();
|
|
597
645
|
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), l.on(h, (e, t) => t), t.on(d, () => !0);
|
|
598
|
-
let g =
|
|
599
|
-
|
|
600
|
-
}), _ =
|
|
646
|
+
let g = P(() => {
|
|
647
|
+
ze(e);
|
|
648
|
+
}), _ = P(async () => {
|
|
601
649
|
await ee();
|
|
602
|
-
}), v =
|
|
603
|
-
await
|
|
604
|
-
}), y =
|
|
650
|
+
}), v = P(async () => {
|
|
651
|
+
await he(e);
|
|
652
|
+
}), y = A({ effect: v }), b = A({
|
|
605
653
|
source: o,
|
|
606
654
|
effect: async (e) => {
|
|
607
655
|
for (let t of e) await t();
|
|
608
656
|
}
|
|
609
|
-
}), x =
|
|
657
|
+
}), x = A({
|
|
610
658
|
source: s,
|
|
611
659
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
612
|
-
}), S =
|
|
660
|
+
}), S = A({
|
|
613
661
|
source: l,
|
|
614
662
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
615
|
-
}), C =
|
|
663
|
+
}), C = L({
|
|
616
664
|
clock: u,
|
|
617
665
|
source: a,
|
|
618
666
|
filter: (e) => e === "idle" && c(),
|
|
619
667
|
fn: () => void 0
|
|
620
668
|
});
|
|
621
|
-
|
|
669
|
+
L({
|
|
622
670
|
clock: C,
|
|
623
671
|
fn: () => "starting",
|
|
624
672
|
target: a
|
|
625
|
-
}),
|
|
673
|
+
}), L({
|
|
626
674
|
clock: C,
|
|
627
675
|
target: g
|
|
628
|
-
}),
|
|
676
|
+
}), L({
|
|
629
677
|
clock: C,
|
|
630
678
|
target: b
|
|
631
|
-
}),
|
|
679
|
+
}), L({
|
|
632
680
|
clock: C,
|
|
633
681
|
target: _
|
|
634
|
-
}),
|
|
682
|
+
}), L({
|
|
635
683
|
clock: b.done,
|
|
636
684
|
target: x
|
|
637
|
-
}),
|
|
685
|
+
}), L({
|
|
638
686
|
clock: x.doneData,
|
|
639
687
|
target: r
|
|
640
|
-
}),
|
|
688
|
+
}), L({
|
|
641
689
|
clock: S.doneData,
|
|
642
690
|
target: i
|
|
643
|
-
}),
|
|
691
|
+
}), L({
|
|
644
692
|
clock: x.doneData,
|
|
645
693
|
filter: (e) => e,
|
|
646
694
|
target: S
|
|
647
|
-
}),
|
|
695
|
+
}), L({
|
|
648
696
|
clock: S.doneData,
|
|
649
697
|
target: e.session.setIsUser
|
|
650
|
-
}),
|
|
698
|
+
}), L({
|
|
651
699
|
clock: S.doneData,
|
|
652
700
|
fn: (e) => ({
|
|
653
701
|
type: "user_decide",
|
|
654
702
|
value: e
|
|
655
703
|
}),
|
|
656
704
|
target: e.eventBus
|
|
657
|
-
}),
|
|
705
|
+
}), L({
|
|
658
706
|
clock: x.doneData,
|
|
659
707
|
filter: (e) => !e,
|
|
660
708
|
fn: () => void 0,
|
|
661
709
|
target: f
|
|
662
|
-
}),
|
|
710
|
+
}), L({
|
|
663
711
|
clock: S.doneData,
|
|
664
712
|
fn: () => void 0,
|
|
665
713
|
target: f
|
|
666
|
-
}),
|
|
714
|
+
}), L({
|
|
667
715
|
clock: f,
|
|
668
716
|
fn: () => ({ type: "initialize" }),
|
|
669
717
|
target: e.eventBus
|
|
670
718
|
});
|
|
671
|
-
let w =
|
|
672
|
-
return
|
|
719
|
+
let w = I(!1).on(_.done, () => !0), T = I(!1).on(f, () => !0), E = I(!1).on(y.done, () => !0), D = j(r, i, (e, t) => e === !0 && t === !0);
|
|
720
|
+
return L({
|
|
673
721
|
clock: f,
|
|
674
722
|
source: D,
|
|
675
723
|
filter: (e) => e,
|
|
676
724
|
fn: () => void 0,
|
|
677
725
|
target: v
|
|
678
|
-
}),
|
|
679
|
-
clock:
|
|
726
|
+
}), L({
|
|
727
|
+
clock: j(w, T, D, (e, t, n) => e && t && n),
|
|
680
728
|
filter: (e) => e,
|
|
681
729
|
fn: () => void 0,
|
|
682
730
|
target: y
|
|
683
|
-
}),
|
|
684
|
-
clock:
|
|
731
|
+
}), L({
|
|
732
|
+
clock: j(w, T, D, E, (e, t, n, r) => e && t && (!n || r)),
|
|
685
733
|
filter: (e) => e,
|
|
686
734
|
fn: () => void 0,
|
|
687
735
|
target: d
|
|
688
|
-
}),
|
|
736
|
+
}), L({
|
|
689
737
|
clock: d,
|
|
690
738
|
fn: () => "ready",
|
|
691
739
|
target: a
|
|
692
|
-
}),
|
|
740
|
+
}), L({
|
|
693
741
|
clock: d,
|
|
694
742
|
fn: () => ({ type: "ready" }),
|
|
695
743
|
target: e.eventBus
|
|
696
|
-
}),
|
|
744
|
+
}), L({
|
|
697
745
|
clock: d,
|
|
698
746
|
source: e.session.store,
|
|
699
747
|
fn: ({ id: e, isUser: t, identifiers: n }) => ({
|
|
@@ -703,7 +751,7 @@ var ke = 6e3, Ae = O("last_ping", "global"), je = async (e) => {
|
|
|
703
751
|
identifiers: n
|
|
704
752
|
}),
|
|
705
753
|
target: e.eventBus
|
|
706
|
-
}),
|
|
754
|
+
}), L({
|
|
707
755
|
clock: [
|
|
708
756
|
b.fail,
|
|
709
757
|
x.fail,
|
|
@@ -725,13 +773,13 @@ var ke = 6e3, Ae = O("last_ping", "global"), je = async (e) => {
|
|
|
725
773
|
setCondition: h
|
|
726
774
|
};
|
|
727
775
|
});
|
|
728
|
-
function
|
|
729
|
-
return
|
|
776
|
+
function Ve(e) {
|
|
777
|
+
return z(Be, e);
|
|
730
778
|
}
|
|
731
779
|
//#endregion
|
|
732
780
|
//#region src/entities/predicate/predicate.ts
|
|
733
|
-
var
|
|
734
|
-
let t =
|
|
781
|
+
var He = N("predicate"), Ue = R(({ client: e }) => {
|
|
782
|
+
let t = He.store({}), n = M(t, { register(e, t) {
|
|
735
783
|
return {
|
|
736
784
|
...e,
|
|
737
785
|
[t.name]: {
|
|
@@ -739,13 +787,13 @@ var Pe = M("predicate"), Fe = L(({ client: e }) => {
|
|
|
739
787
|
predicate: t.predicate
|
|
740
788
|
}
|
|
741
789
|
};
|
|
742
|
-
} }), i =
|
|
743
|
-
|
|
790
|
+
} }), i = F();
|
|
791
|
+
L({
|
|
744
792
|
clock: i,
|
|
745
793
|
source: t,
|
|
746
794
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
747
795
|
fn: (e, { name: t }) => `Predicate '${t}' already registered. Registering again will override the previous registration.`
|
|
748
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
796
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), L({
|
|
749
797
|
clock: i,
|
|
750
798
|
fn: ({ name: e, predicate: t }) => Object.freeze({
|
|
751
799
|
name: e,
|
|
@@ -758,7 +806,7 @@ var Pe = M("predicate"), Fe = L(({ client: e }) => {
|
|
|
758
806
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
759
807
|
}
|
|
760
808
|
function s(t) {
|
|
761
|
-
let n =
|
|
809
|
+
let n = I(() => void 0, { skipVoid: !1 }), r = A({
|
|
762
810
|
source: {
|
|
763
811
|
predicate: o(t),
|
|
764
812
|
snapshot: e.stateSnapshotStore
|
|
@@ -770,13 +818,13 @@ var Pe = M("predicate"), Fe = L(({ client: e }) => {
|
|
|
770
818
|
});
|
|
771
819
|
}
|
|
772
820
|
});
|
|
773
|
-
return
|
|
821
|
+
return L({
|
|
774
822
|
source: {
|
|
775
823
|
responses: e.responses.listStore,
|
|
776
824
|
fields: e.fields.listStore
|
|
777
825
|
},
|
|
778
826
|
target: r
|
|
779
|
-
}),
|
|
827
|
+
}), L({
|
|
780
828
|
clock: r.doneData,
|
|
781
829
|
filter: (e) => e !== void 0,
|
|
782
830
|
target: n
|
|
@@ -789,27 +837,27 @@ var Pe = M("predicate"), Fe = L(({ client: e }) => {
|
|
|
789
837
|
getEvokablePredicate: s
|
|
790
838
|
};
|
|
791
839
|
});
|
|
792
|
-
function
|
|
793
|
-
return
|
|
840
|
+
function We(e) {
|
|
841
|
+
return z(Ue, e);
|
|
794
842
|
}
|
|
795
|
-
var
|
|
843
|
+
var Ge = (e, t, n) => {
|
|
796
844
|
n.register({
|
|
797
845
|
name: e,
|
|
798
846
|
predicate: t
|
|
799
847
|
});
|
|
800
|
-
},
|
|
801
|
-
let t =
|
|
848
|
+
}, Ke = N("feature"), qe = R(({ client: e }) => {
|
|
849
|
+
let t = Ke.store({}), n = Ke.store([]), i = M(t, { register(e, t) {
|
|
802
850
|
return {
|
|
803
851
|
...e,
|
|
804
852
|
[t.id]: t.feature
|
|
805
853
|
};
|
|
806
|
-
} }), a =
|
|
807
|
-
|
|
854
|
+
} }), a = F();
|
|
855
|
+
L({
|
|
808
856
|
clock: a,
|
|
809
857
|
source: t,
|
|
810
858
|
filter: (e, { id: t }) => e[t] !== void 0,
|
|
811
859
|
fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
|
|
812
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
860
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), L({
|
|
813
861
|
clock: a,
|
|
814
862
|
fn: ({ id: e, feature: t }) => Object.freeze({
|
|
815
863
|
id: e,
|
|
@@ -823,19 +871,19 @@ var Le = (e, t, n) => {
|
|
|
823
871
|
}),
|
|
824
872
|
target: i.register
|
|
825
873
|
});
|
|
826
|
-
let o =
|
|
827
|
-
let r =
|
|
874
|
+
let o = P(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
875
|
+
let r = k(`feature:${e}:${t}`, "global"), i = (n === "session" ? O : D).get(r).boolean();
|
|
828
876
|
return i === null ? null : {
|
|
829
877
|
id: e,
|
|
830
878
|
key: t,
|
|
831
879
|
bucket: i,
|
|
832
880
|
storage: n
|
|
833
881
|
};
|
|
834
|
-
}), s =
|
|
882
|
+
}), s = P((e) => {
|
|
835
883
|
if (!e) return null;
|
|
836
|
-
let t =
|
|
837
|
-
(e.storage === "session" ?
|
|
838
|
-
}), c = /* @__PURE__ */ new Map(), l =
|
|
884
|
+
let t = k(`feature:${e.id}:${e.key}`, "global");
|
|
885
|
+
(e.storage === "session" ? O : D).set(t, e.bucket);
|
|
886
|
+
}), c = /* @__PURE__ */ new Map(), l = A({
|
|
839
887
|
source: {
|
|
840
888
|
allFeaturesStore: t,
|
|
841
889
|
resolvedFeaturesStore: n
|
|
@@ -866,7 +914,7 @@ var Le = (e, t, n) => {
|
|
|
866
914
|
};
|
|
867
915
|
}
|
|
868
916
|
});
|
|
869
|
-
|
|
917
|
+
L({
|
|
870
918
|
clock: i.register,
|
|
871
919
|
fn: (e) => {
|
|
872
920
|
let { id: t, feature: n } = e;
|
|
@@ -877,7 +925,7 @@ var Le = (e, t, n) => {
|
|
|
877
925
|
};
|
|
878
926
|
},
|
|
879
927
|
target: o
|
|
880
|
-
}),
|
|
928
|
+
}), L({
|
|
881
929
|
source: t,
|
|
882
930
|
clock: l.doneData,
|
|
883
931
|
fn: (e, t) => {
|
|
@@ -891,7 +939,7 @@ var Le = (e, t, n) => {
|
|
|
891
939
|
},
|
|
892
940
|
target: s
|
|
893
941
|
});
|
|
894
|
-
let u =
|
|
942
|
+
let u = j({
|
|
895
943
|
allFeaturesStore: t,
|
|
896
944
|
resolvedFeaturesStore: n
|
|
897
945
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -913,7 +961,7 @@ var Le = (e, t, n) => {
|
|
|
913
961
|
isResolved: !1
|
|
914
962
|
};
|
|
915
963
|
}));
|
|
916
|
-
|
|
964
|
+
L({
|
|
917
965
|
clock: l.doneData,
|
|
918
966
|
source: { resolvedFeatures: n },
|
|
919
967
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
@@ -922,7 +970,7 @@ var Le = (e, t, n) => {
|
|
|
922
970
|
type: "feature_decide",
|
|
923
971
|
feature: e
|
|
924
972
|
}))
|
|
925
|
-
}),
|
|
973
|
+
}), L({
|
|
926
974
|
clock: [o.doneData, l.doneData],
|
|
927
975
|
source: n,
|
|
928
976
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
@@ -935,17 +983,17 @@ var Le = (e, t, n) => {
|
|
|
935
983
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
936
984
|
}
|
|
937
985
|
function p(e) {
|
|
938
|
-
let t =
|
|
986
|
+
let t = I(async () => void 0, { skipVoid: !1 }), r = A({
|
|
939
987
|
source: d(e),
|
|
940
988
|
effect: async (e) => {
|
|
941
989
|
if (e) return async () => (await e.getBucket()).bucket;
|
|
942
990
|
}
|
|
943
991
|
});
|
|
944
|
-
return
|
|
992
|
+
return L({
|
|
945
993
|
source: n,
|
|
946
994
|
filter: (t) => t.some((t) => t.id === e),
|
|
947
995
|
target: r
|
|
948
|
-
}),
|
|
996
|
+
}), L({
|
|
949
997
|
clock: r.doneData,
|
|
950
998
|
filter: (e) => e !== void 0,
|
|
951
999
|
target: t
|
|
@@ -959,69 +1007,111 @@ var Le = (e, t, n) => {
|
|
|
959
1007
|
getEvokableFeature: p
|
|
960
1008
|
};
|
|
961
1009
|
});
|
|
962
|
-
function
|
|
963
|
-
return
|
|
1010
|
+
function Je(e) {
|
|
1011
|
+
return z(qe, e);
|
|
964
1012
|
}
|
|
965
|
-
var
|
|
1013
|
+
var Ye = (e, t, n) => {
|
|
966
1014
|
n.register({
|
|
967
1015
|
id: e,
|
|
968
1016
|
feature: t
|
|
969
1017
|
});
|
|
970
|
-
}, Y =
|
|
971
|
-
function
|
|
1018
|
+
}, Y = N("history");
|
|
1019
|
+
function X(e, t, n) {
|
|
972
1020
|
return {
|
|
973
|
-
id: re(
|
|
974
|
-
node:
|
|
1021
|
+
id: re("history-entry"),
|
|
1022
|
+
node: n,
|
|
975
1023
|
at: Date.now(),
|
|
976
|
-
|
|
1024
|
+
instanceId: e,
|
|
1025
|
+
experienceId: t
|
|
977
1026
|
};
|
|
978
1027
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1028
|
+
function Xe(e) {
|
|
1029
|
+
for (let t = e.length - 1; t >= 0; t--) {
|
|
1030
|
+
let n = e[t];
|
|
1031
|
+
if (n && T(n.node)) return e.slice(0, t + 1);
|
|
1032
|
+
}
|
|
1033
|
+
return [];
|
|
1034
|
+
}
|
|
1035
|
+
var Ze = R(() => {
|
|
1036
|
+
let e = Y.store([]), t = Y.event(), n = Y.event(), r = Y.event(), i = Y.event(), a = Y.event(), o = Y.event(), s = Y.event();
|
|
1037
|
+
e.on(t, (e, t) => [...e, X(t.instanceId, t.experienceId, t.node)]), e.on(n, (e, t) => {
|
|
1038
|
+
let n = X(t.instanceId, t.experienceId, t.node), r = -1;
|
|
1039
|
+
for (let n = e.length - 1; n >= 0; n--) if (e[n]?.instanceId === t.instanceId) {
|
|
1040
|
+
r = n;
|
|
1041
|
+
break;
|
|
1042
|
+
}
|
|
1043
|
+
return r === -1 ? [...e, n] : [
|
|
1044
|
+
...e.slice(0, r),
|
|
1045
|
+
n,
|
|
1046
|
+
...e.slice(r + 1)
|
|
1047
|
+
];
|
|
1048
|
+
}), e.on(r, (e, { instanceId: t }) => {
|
|
1049
|
+
let n = 0, r = -1;
|
|
1050
|
+
for (let i = e.length - 1; i >= 0; i--) {
|
|
1051
|
+
let a = e[i];
|
|
1052
|
+
if (!(a?.instanceId !== t || !T(a.node)) && ++n === 2) {
|
|
1053
|
+
r = i;
|
|
992
1054
|
break;
|
|
993
1055
|
}
|
|
994
1056
|
}
|
|
1057
|
+
return r === -1 ? e : e.filter((e, n) => e.instanceId !== t || n <= r);
|
|
1058
|
+
}), e.on(i, (e, { snapshots: t }) => {
|
|
1059
|
+
let n = new Set(e.map((e) => e.experienceId)), r = [];
|
|
1060
|
+
for (let e of Object.keys(t)) {
|
|
1061
|
+
if (n.has(e)) continue;
|
|
1062
|
+
let i = t[e];
|
|
1063
|
+
i && r.push(...i);
|
|
1064
|
+
}
|
|
1065
|
+
return r.length === 0 ? e : [...e, ...r];
|
|
1066
|
+
}), e.on(s, (e, t) => [...e, ...t]), e.on(o, (e, { instanceId: t }) => {
|
|
1067
|
+
let n = e.filter((e) => e.instanceId !== t);
|
|
1068
|
+
return n.length === e.length ? e : n;
|
|
1069
|
+
});
|
|
1070
|
+
let c = e.map((e) => {
|
|
1071
|
+
let t = /* @__PURE__ */ new Map();
|
|
1072
|
+
for (let n of e) t.set(n.experienceId, n.instanceId);
|
|
1073
|
+
let n = {};
|
|
1074
|
+
for (let r of e) {
|
|
1075
|
+
if (t.get(r.experienceId) !== r.instanceId) continue;
|
|
1076
|
+
let e = n[r.experienceId] ?? [];
|
|
1077
|
+
e.push(r), n[r.experienceId] = e;
|
|
1078
|
+
}
|
|
995
1079
|
return n;
|
|
996
|
-
}
|
|
997
|
-
return
|
|
998
|
-
|
|
999
|
-
|
|
1080
|
+
});
|
|
1081
|
+
return L({
|
|
1082
|
+
clock: a,
|
|
1083
|
+
source: c,
|
|
1084
|
+
fn: (e, { instanceId: t, experienceId: n }) => Xe(e[n] ?? []).map((e) => ({
|
|
1000
1085
|
...e,
|
|
1001
|
-
|
|
1002
|
-
|
|
1086
|
+
id: re("history-entry"),
|
|
1087
|
+
instanceId: t
|
|
1088
|
+
})),
|
|
1089
|
+
target: s
|
|
1003
1090
|
}), {
|
|
1004
1091
|
push: t,
|
|
1005
1092
|
replace: n,
|
|
1006
1093
|
back: r,
|
|
1007
|
-
|
|
1008
|
-
|
|
1094
|
+
restoreSnapshots: i,
|
|
1095
|
+
seedInstanceFromSnapshot: a,
|
|
1096
|
+
clearForInstance: o,
|
|
1097
|
+
entriesStore: e,
|
|
1098
|
+
snapshotStore: c
|
|
1009
1099
|
};
|
|
1010
1100
|
});
|
|
1011
|
-
function
|
|
1012
|
-
return
|
|
1101
|
+
function Qe() {
|
|
1102
|
+
return z(Ze);
|
|
1013
1103
|
}
|
|
1014
1104
|
//#endregion
|
|
1015
1105
|
//#region src/utils/events.ts
|
|
1016
|
-
var
|
|
1017
|
-
let t =
|
|
1106
|
+
var $e = 0, et = (e) => {
|
|
1107
|
+
let t = I([]);
|
|
1018
1108
|
return t.on(e, (e, t) => [...e, {
|
|
1019
|
-
id:
|
|
1109
|
+
id: $e++,
|
|
1020
1110
|
at: /* @__PURE__ */ new Date(),
|
|
1021
1111
|
payload: t
|
|
1022
1112
|
}]), t;
|
|
1023
|
-
},
|
|
1024
|
-
let e =
|
|
1113
|
+
}, tt = N("field"), nt = R(() => {
|
|
1114
|
+
let e = tt.store({}), t = M(e, {
|
|
1025
1115
|
register(e, t) {
|
|
1026
1116
|
return {
|
|
1027
1117
|
...e,
|
|
@@ -1069,13 +1159,13 @@ var Ge = 0, Ke = (e) => {
|
|
|
1069
1159
|
getByName: c
|
|
1070
1160
|
};
|
|
1071
1161
|
});
|
|
1072
|
-
function
|
|
1073
|
-
return
|
|
1162
|
+
function rt() {
|
|
1163
|
+
return z(nt);
|
|
1074
1164
|
}
|
|
1075
1165
|
//#endregion
|
|
1076
1166
|
//#region src/entities/step/step.ts
|
|
1077
|
-
var
|
|
1078
|
-
let e =
|
|
1167
|
+
var it = N("step"), at = R(() => {
|
|
1168
|
+
let e = it.store({}), t = M(e, { register(e, t) {
|
|
1079
1169
|
return {
|
|
1080
1170
|
...e,
|
|
1081
1171
|
[t.step.id]: t.step
|
|
@@ -1099,16 +1189,16 @@ var Xe = M("step"), Ze = L(() => {
|
|
|
1099
1189
|
indexStore: e
|
|
1100
1190
|
};
|
|
1101
1191
|
});
|
|
1102
|
-
function
|
|
1103
|
-
return
|
|
1192
|
+
function ot() {
|
|
1193
|
+
return z(at);
|
|
1104
1194
|
}
|
|
1105
|
-
function
|
|
1195
|
+
function st(e, t) {
|
|
1106
1196
|
t.register(e);
|
|
1107
1197
|
}
|
|
1108
1198
|
//#endregion
|
|
1109
1199
|
//#region src/entities/content/content.ts
|
|
1110
|
-
var
|
|
1111
|
-
let e =
|
|
1200
|
+
var ct = N("content"), lt = R(() => {
|
|
1201
|
+
let e = ct.store({}), t = M(e, { register(e, t) {
|
|
1112
1202
|
return {
|
|
1113
1203
|
...e,
|
|
1114
1204
|
[t.content.id]: t.content
|
|
@@ -1128,16 +1218,16 @@ var et = M("content"), tt = L(() => {
|
|
|
1128
1218
|
indexStore: e
|
|
1129
1219
|
};
|
|
1130
1220
|
});
|
|
1131
|
-
function
|
|
1132
|
-
return
|
|
1221
|
+
function ut() {
|
|
1222
|
+
return z(lt);
|
|
1133
1223
|
}
|
|
1134
|
-
function
|
|
1224
|
+
function dt(e, t) {
|
|
1135
1225
|
t.register(e);
|
|
1136
1226
|
}
|
|
1137
1227
|
//#endregion
|
|
1138
1228
|
//#region src/entities/action/action.ts
|
|
1139
|
-
var
|
|
1140
|
-
let t =
|
|
1229
|
+
var ft = N("action"), pt = R(({ client: e }) => {
|
|
1230
|
+
let t = ft.store({}), n = M(t, { register(e, t) {
|
|
1141
1231
|
return {
|
|
1142
1232
|
...e,
|
|
1143
1233
|
[t.key]: {
|
|
@@ -1145,13 +1235,13 @@ var it = M("action"), at = L(({ client: e }) => {
|
|
|
1145
1235
|
action: t.action
|
|
1146
1236
|
}
|
|
1147
1237
|
};
|
|
1148
|
-
} }), i =
|
|
1149
|
-
|
|
1238
|
+
} }), i = F();
|
|
1239
|
+
L({
|
|
1150
1240
|
clock: i,
|
|
1151
1241
|
source: t,
|
|
1152
1242
|
filter: (e, { key: t }) => e[t] !== void 0,
|
|
1153
1243
|
fn: (e, { key: t }) => `Action '${t}' already registered. Registering again will override the previous registration.`
|
|
1154
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
1244
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), L({
|
|
1155
1245
|
clock: i,
|
|
1156
1246
|
fn: ({ key: e, action: t }) => Object.freeze({
|
|
1157
1247
|
key: e,
|
|
@@ -1164,7 +1254,7 @@ var it = M("action"), at = L(({ client: e }) => {
|
|
|
1164
1254
|
return t.map((t) => t[e]?.action, { skipVoid: !1 });
|
|
1165
1255
|
}
|
|
1166
1256
|
function s(t, n) {
|
|
1167
|
-
let r =
|
|
1257
|
+
let r = I(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, a = A({
|
|
1168
1258
|
source: {
|
|
1169
1259
|
action: o(t),
|
|
1170
1260
|
snapshot: e.stateSnapshotStore
|
|
@@ -1176,13 +1266,13 @@ var it = M("action"), at = L(({ client: e }) => {
|
|
|
1176
1266
|
}, i);
|
|
1177
1267
|
}
|
|
1178
1268
|
});
|
|
1179
|
-
return
|
|
1269
|
+
return L({
|
|
1180
1270
|
source: {
|
|
1181
1271
|
responses: e.responses.listStore,
|
|
1182
1272
|
fields: e.fields.listStore
|
|
1183
1273
|
},
|
|
1184
1274
|
target: a
|
|
1185
|
-
}),
|
|
1275
|
+
}), L({
|
|
1186
1276
|
clock: a.doneData,
|
|
1187
1277
|
filter: (e) => e !== void 0,
|
|
1188
1278
|
target: r
|
|
@@ -1195,10 +1285,10 @@ var it = M("action"), at = L(({ client: e }) => {
|
|
|
1195
1285
|
getEvokableAction: s
|
|
1196
1286
|
};
|
|
1197
1287
|
});
|
|
1198
|
-
function
|
|
1199
|
-
return
|
|
1288
|
+
function mt(e) {
|
|
1289
|
+
return z(pt, e);
|
|
1200
1290
|
}
|
|
1201
|
-
var
|
|
1291
|
+
var ht = (e, t, n) => {
|
|
1202
1292
|
n.register({
|
|
1203
1293
|
key: e,
|
|
1204
1294
|
action: t
|
|
@@ -1206,7 +1296,7 @@ var st = (e, t, n) => {
|
|
|
1206
1296
|
};
|
|
1207
1297
|
//#endregion
|
|
1208
1298
|
//#region src/entities/response/response-validation.ts
|
|
1209
|
-
function
|
|
1299
|
+
function Z(e, t, n, r) {
|
|
1210
1300
|
return {
|
|
1211
1301
|
fieldKey: e.key,
|
|
1212
1302
|
userMessage: n,
|
|
@@ -1214,62 +1304,62 @@ function X(e, t, n, r) {
|
|
|
1214
1304
|
value: t
|
|
1215
1305
|
};
|
|
1216
1306
|
}
|
|
1217
|
-
function
|
|
1307
|
+
function Q(e) {
|
|
1218
1308
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1219
1309
|
}
|
|
1220
|
-
function
|
|
1310
|
+
function gt(e) {
|
|
1221
1311
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1222
1312
|
}
|
|
1223
|
-
function
|
|
1313
|
+
function _t(e) {
|
|
1224
1314
|
try {
|
|
1225
1315
|
return JSON.stringify(e), !0;
|
|
1226
1316
|
} catch {
|
|
1227
1317
|
return !1;
|
|
1228
1318
|
}
|
|
1229
1319
|
}
|
|
1230
|
-
function
|
|
1320
|
+
function vt(e, t) {
|
|
1231
1321
|
return t.find((t) => t.key === e) ?? null;
|
|
1232
1322
|
}
|
|
1233
|
-
function
|
|
1323
|
+
function yt(e, t) {
|
|
1234
1324
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1235
1325
|
}
|
|
1236
|
-
function
|
|
1237
|
-
if (e.type !== "object" ||
|
|
1326
|
+
function bt(e, t) {
|
|
1327
|
+
if (e.type !== "object" || Q(t)) return null;
|
|
1238
1328
|
if (e.multiple) {
|
|
1239
|
-
if (!Array.isArray(t)) return
|
|
1329
|
+
if (!Array.isArray(t)) return Z(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1240
1330
|
for (let n of t) {
|
|
1241
|
-
if (typeof n != "object" || !n) return
|
|
1242
|
-
if (!
|
|
1331
|
+
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.");
|
|
1332
|
+
if (!_t(n)) return Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1243
1333
|
}
|
|
1244
1334
|
return null;
|
|
1245
1335
|
}
|
|
1246
|
-
return Array.isArray(t) ?
|
|
1336
|
+
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.") : _t(t) ? null : Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1247
1337
|
}
|
|
1248
|
-
function
|
|
1249
|
-
if (
|
|
1338
|
+
function xt(e, t) {
|
|
1339
|
+
if (Q(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1250
1340
|
let n = Array.isArray(t) ? t : [t];
|
|
1251
1341
|
if (e.type === "object") {
|
|
1252
1342
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1253
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
1343
|
+
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.");
|
|
1254
1344
|
}
|
|
1255
1345
|
let r = e.options.map((e) => e.value);
|
|
1256
|
-
return n.every((e) => !
|
|
1346
|
+
return n.every((e) => !gt(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(", ")}`);
|
|
1257
1347
|
}
|
|
1258
|
-
async function
|
|
1259
|
-
if (n.validation && !e(n.validation) && !
|
|
1348
|
+
async function St(t, n, r, i) {
|
|
1349
|
+
if (n.validation && !e(n.validation) && !Q(r)) {
|
|
1260
1350
|
let e = i ? {
|
|
1261
1351
|
$input: r,
|
|
1262
1352
|
responses: i
|
|
1263
1353
|
} : { $input: r }, a = await t(n.validation, e);
|
|
1264
|
-
if (typeof a == "string") return
|
|
1265
|
-
if (a === !1) return
|
|
1354
|
+
if (typeof a == "string") return Z(n, r, a, `Field validation resulted in an error: ${a}.`);
|
|
1355
|
+
if (a === !1) return Z(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
1266
1356
|
}
|
|
1267
|
-
return n.required &&
|
|
1357
|
+
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;
|
|
1268
1358
|
}
|
|
1269
1359
|
//#endregion
|
|
1270
1360
|
//#region src/entities/response/response.ts
|
|
1271
|
-
var
|
|
1272
|
-
let t =
|
|
1361
|
+
var Ct = N("response"), wt = R(({ client: e }) => {
|
|
1362
|
+
let t = Ct.store({}), r = F(), i = F(), a = M(t, {
|
|
1273
1363
|
register(e, t) {
|
|
1274
1364
|
return {
|
|
1275
1365
|
...e,
|
|
@@ -1298,7 +1388,7 @@ var ht = M("response"), gt = L(({ client: e }) => {
|
|
|
1298
1388
|
});
|
|
1299
1389
|
} else a.registerBatch(e);
|
|
1300
1390
|
}
|
|
1301
|
-
let s = (t, r) => n(e, t, r), c =
|
|
1391
|
+
let s = (t, r) => n(e, t, r), c = A({
|
|
1302
1392
|
source: {
|
|
1303
1393
|
allFields: e.fields.listStore,
|
|
1304
1394
|
existingResponses: t
|
|
@@ -1308,7 +1398,7 @@ var ht = M("response"), gt = L(({ client: e }) => {
|
|
|
1308
1398
|
...t,
|
|
1309
1399
|
...n
|
|
1310
1400
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1311
|
-
let o =
|
|
1401
|
+
let o = vt(t, e);
|
|
1312
1402
|
if (!o) {
|
|
1313
1403
|
r.push({
|
|
1314
1404
|
fieldKey: t,
|
|
@@ -1318,17 +1408,17 @@ var ht = M("response"), gt = L(({ client: e }) => {
|
|
|
1318
1408
|
});
|
|
1319
1409
|
return;
|
|
1320
1410
|
}
|
|
1321
|
-
let c =
|
|
1411
|
+
let c = yt(o, n), l = await St(s, o, c, a);
|
|
1322
1412
|
if (l) {
|
|
1323
1413
|
r.push(l);
|
|
1324
1414
|
return;
|
|
1325
1415
|
}
|
|
1326
|
-
let u =
|
|
1416
|
+
let u = bt(o, c);
|
|
1327
1417
|
if (u) {
|
|
1328
1418
|
r.push(u);
|
|
1329
1419
|
return;
|
|
1330
1420
|
}
|
|
1331
|
-
let d =
|
|
1421
|
+
let d = xt(o, c);
|
|
1332
1422
|
if (d) {
|
|
1333
1423
|
r.push(d);
|
|
1334
1424
|
return;
|
|
@@ -1356,7 +1446,7 @@ var ht = M("response"), gt = L(({ client: e }) => {
|
|
|
1356
1446
|
async function l(e) {
|
|
1357
1447
|
return c(e);
|
|
1358
1448
|
}
|
|
1359
|
-
let u =
|
|
1449
|
+
let u = A({
|
|
1360
1450
|
source: t,
|
|
1361
1451
|
effect: async (e, t) => {
|
|
1362
1452
|
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
@@ -1371,7 +1461,7 @@ var ht = M("response"), gt = L(({ client: e }) => {
|
|
|
1371
1461
|
value: t
|
|
1372
1462
|
})));
|
|
1373
1463
|
function m(e) {
|
|
1374
|
-
return
|
|
1464
|
+
return j({
|
|
1375
1465
|
f: e,
|
|
1376
1466
|
s: t
|
|
1377
1467
|
}, ({ f: e, s: t }) => {
|
|
@@ -1388,16 +1478,30 @@ var ht = M("response"), gt = L(({ client: e }) => {
|
|
|
1388
1478
|
function _(t) {
|
|
1389
1479
|
return m(e.fields.getByName(t));
|
|
1390
1480
|
}
|
|
1391
|
-
|
|
1481
|
+
L({
|
|
1392
1482
|
clock: r,
|
|
1393
1483
|
target: a.clearAll
|
|
1394
|
-
}),
|
|
1484
|
+
}), L({
|
|
1395
1485
|
clock: i,
|
|
1396
1486
|
target: a.clear
|
|
1397
|
-
})
|
|
1487
|
+
});
|
|
1488
|
+
let v = A({
|
|
1489
|
+
source: e.experiences.listStore,
|
|
1490
|
+
effect: (e, t) => {
|
|
1491
|
+
let n = e.find((e) => e.id === t);
|
|
1492
|
+
if (!n) return;
|
|
1493
|
+
let { steps: r } = n.treeStore.getState(), a = r.flatMap((e) => e.fieldKeys);
|
|
1494
|
+
for (let e of a) i(e);
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
function y(e) {
|
|
1498
|
+
v(e);
|
|
1499
|
+
}
|
|
1500
|
+
return {
|
|
1398
1501
|
register: o,
|
|
1399
1502
|
clearAll: r,
|
|
1400
1503
|
clear: i,
|
|
1504
|
+
clearByExperience: y,
|
|
1401
1505
|
commit: d,
|
|
1402
1506
|
getResponsesToCommit: l,
|
|
1403
1507
|
listStore: p,
|
|
@@ -1407,13 +1511,13 @@ var ht = M("response"), gt = L(({ client: e }) => {
|
|
|
1407
1511
|
getByFieldName: _
|
|
1408
1512
|
};
|
|
1409
1513
|
});
|
|
1410
|
-
function
|
|
1411
|
-
return
|
|
1514
|
+
function Tt(e) {
|
|
1515
|
+
return z(wt, e);
|
|
1412
1516
|
}
|
|
1413
1517
|
//#endregion
|
|
1414
1518
|
//#region src/entities/condition/condition.ts
|
|
1415
|
-
var
|
|
1416
|
-
let e =
|
|
1519
|
+
var Et = N("condition"), Dt = R(() => {
|
|
1520
|
+
let e = Et.store({}), t = M(e, { register(e, t) {
|
|
1417
1521
|
return {
|
|
1418
1522
|
...e,
|
|
1419
1523
|
[t.condition.id]: t.condition
|
|
@@ -1437,12 +1541,12 @@ var vt = M("condition"), yt = L(() => {
|
|
|
1437
1541
|
indexStore: e
|
|
1438
1542
|
};
|
|
1439
1543
|
});
|
|
1440
|
-
function
|
|
1441
|
-
return
|
|
1544
|
+
function Ot() {
|
|
1545
|
+
return z(Dt);
|
|
1442
1546
|
}
|
|
1443
1547
|
//#endregion
|
|
1444
1548
|
//#region src/utils/api-url.ts
|
|
1445
|
-
function
|
|
1549
|
+
function kt() {
|
|
1446
1550
|
if (c()) {
|
|
1447
1551
|
let e = [
|
|
1448
1552
|
document.currentScript,
|
|
@@ -1457,7 +1561,7 @@ function xt() {
|
|
|
1457
1561
|
}
|
|
1458
1562
|
//#endregion
|
|
1459
1563
|
//#region src/utils/search-params.ts
|
|
1460
|
-
function
|
|
1564
|
+
function At() {
|
|
1461
1565
|
if (!s()) return {};
|
|
1462
1566
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1463
1567
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -1465,23 +1569,23 @@ function St() {
|
|
|
1465
1569
|
let n = r.replace("picked-", "");
|
|
1466
1570
|
t[n] = e.getAll(r);
|
|
1467
1571
|
}
|
|
1468
|
-
let r =
|
|
1469
|
-
if (n.size > 0)
|
|
1572
|
+
let r = k("s");
|
|
1573
|
+
if (n.size > 0) O.set(r, t);
|
|
1470
1574
|
else {
|
|
1471
|
-
let e =
|
|
1575
|
+
let e = O.get(r);
|
|
1472
1576
|
if (e) return e.json() || {};
|
|
1473
1577
|
}
|
|
1474
1578
|
return t;
|
|
1475
1579
|
}
|
|
1476
1580
|
//#endregion
|
|
1477
1581
|
//#region src/entities/session/session.ts
|
|
1478
|
-
var
|
|
1479
|
-
function
|
|
1582
|
+
var jt = k("session", "global");
|
|
1583
|
+
function Mt() {
|
|
1480
1584
|
return p() ? 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)}`;
|
|
1481
1585
|
}
|
|
1482
|
-
function
|
|
1586
|
+
function Nt() {
|
|
1483
1587
|
if (!m()) return null;
|
|
1484
|
-
let e =
|
|
1588
|
+
let e = D.get(jt);
|
|
1485
1589
|
if (!e.isSet()) return null;
|
|
1486
1590
|
try {
|
|
1487
1591
|
return e.json();
|
|
@@ -1489,10 +1593,10 @@ function Tt() {
|
|
|
1489
1593
|
return null;
|
|
1490
1594
|
}
|
|
1491
1595
|
}
|
|
1492
|
-
var
|
|
1493
|
-
let e =
|
|
1596
|
+
var Pt = R(() => {
|
|
1597
|
+
let e = Nt(), t = { id: e?.id ?? Mt() };
|
|
1494
1598
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1495
|
-
let n =
|
|
1599
|
+
let n = I(t), r = M(n, {
|
|
1496
1600
|
setIsUser: (e, t) => ({
|
|
1497
1601
|
...e,
|
|
1498
1602
|
isUser: t
|
|
@@ -1513,13 +1617,13 @@ var Et = L(() => {
|
|
|
1513
1617
|
return e.isUser !== void 0 && (i.isUser = e.isUser), Object.keys(r).length > 0 && (i.identifiers = r), i;
|
|
1514
1618
|
}
|
|
1515
1619
|
});
|
|
1516
|
-
return
|
|
1620
|
+
return L({
|
|
1517
1621
|
source: n,
|
|
1518
|
-
target:
|
|
1622
|
+
target: A({
|
|
1519
1623
|
source: n,
|
|
1520
1624
|
effect: (e) => {
|
|
1521
1625
|
if (m()) try {
|
|
1522
|
-
|
|
1626
|
+
D.get(jt).set(e);
|
|
1523
1627
|
} catch {}
|
|
1524
1628
|
}
|
|
1525
1629
|
})
|
|
@@ -1530,39 +1634,39 @@ var Et = L(() => {
|
|
|
1530
1634
|
removeIdentifier: r.removeIdentifier
|
|
1531
1635
|
};
|
|
1532
1636
|
});
|
|
1533
|
-
function
|
|
1534
|
-
return
|
|
1637
|
+
function Ft() {
|
|
1638
|
+
return z(Pt, void 0);
|
|
1535
1639
|
}
|
|
1536
1640
|
//#endregion
|
|
1537
1641
|
//#region src/utils/picked-config.ts
|
|
1538
|
-
function
|
|
1642
|
+
function It() {
|
|
1539
1643
|
if (s()) return globalThis.window.pickedConfig;
|
|
1540
1644
|
}
|
|
1541
|
-
function
|
|
1542
|
-
if (s()) return
|
|
1645
|
+
function Lt() {
|
|
1646
|
+
if (s()) return It()?.projectId;
|
|
1543
1647
|
}
|
|
1544
|
-
function
|
|
1648
|
+
function Rt() {
|
|
1545
1649
|
if (!c()) return;
|
|
1546
1650
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1547
1651
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1548
1652
|
}
|
|
1549
|
-
function
|
|
1653
|
+
function zt(e) {
|
|
1550
1654
|
if (e.projectId) return e.projectId;
|
|
1551
|
-
let t =
|
|
1655
|
+
let t = Lt();
|
|
1552
1656
|
if (t) return t;
|
|
1553
|
-
let n =
|
|
1657
|
+
let n = Rt();
|
|
1554
1658
|
if (n) return n;
|
|
1555
1659
|
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.");
|
|
1556
1660
|
}
|
|
1557
1661
|
//#endregion
|
|
1558
1662
|
//#region src/utils/render-string.ts
|
|
1559
|
-
function
|
|
1663
|
+
function $(e) {
|
|
1560
1664
|
return e == null || e === "" || Number.isNaN(e);
|
|
1561
1665
|
}
|
|
1562
|
-
var
|
|
1563
|
-
default: (e, t) =>
|
|
1564
|
-
append: (e, t) => t &&
|
|
1565
|
-
prepend: (e, t) => t &&
|
|
1666
|
+
var Bt = {
|
|
1667
|
+
default: (e, t) => $(e) ? String(t ?? "") : String(e),
|
|
1668
|
+
append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
|
|
1669
|
+
prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
|
|
1566
1670
|
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
1567
1671
|
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
1568
1672
|
capitalize: (e) => typeof e == "string" ? e.charAt(0).toUpperCase() + e.slice(1) : e,
|
|
@@ -1580,24 +1684,24 @@ var Mt = {
|
|
|
1580
1684
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1581
1685
|
}
|
|
1582
1686
|
};
|
|
1583
|
-
function
|
|
1687
|
+
function Vt(e) {
|
|
1584
1688
|
return typeof e == "object" && !!e;
|
|
1585
1689
|
}
|
|
1586
|
-
function
|
|
1690
|
+
function Ht(e, t) {
|
|
1587
1691
|
let n = t;
|
|
1588
|
-
for (let t of e.split(".")) if (
|
|
1692
|
+
for (let t of e.split(".")) if (Vt(n) && t in n) n = n[t];
|
|
1589
1693
|
else return;
|
|
1590
1694
|
return typeof n == "function" ? n() : n;
|
|
1591
1695
|
}
|
|
1592
|
-
function
|
|
1593
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1696
|
+
function Ut(e, t) {
|
|
1697
|
+
let n = e.split("|").map((e) => e.trim()), r = Ht(n.shift() ?? "", t);
|
|
1594
1698
|
for (let e of n) {
|
|
1595
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1699
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Bt[i];
|
|
1596
1700
|
o && (r = o(r, a));
|
|
1597
1701
|
}
|
|
1598
|
-
return
|
|
1702
|
+
return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1599
1703
|
}
|
|
1600
|
-
function
|
|
1704
|
+
function Wt(e, t) {
|
|
1601
1705
|
let n = "", r = 0;
|
|
1602
1706
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1603
1707
|
r += 2;
|
|
@@ -1609,61 +1713,61 @@ function It(e, t) {
|
|
|
1609
1713
|
}
|
|
1610
1714
|
i += e[r++];
|
|
1611
1715
|
}
|
|
1612
|
-
n +=
|
|
1716
|
+
n += Ut(i.trim(), t);
|
|
1613
1717
|
} else n += e[r++];
|
|
1614
1718
|
return n;
|
|
1615
1719
|
}
|
|
1616
1720
|
//#endregion
|
|
1617
1721
|
//#region src/picked.ts
|
|
1618
|
-
var
|
|
1722
|
+
var Gt = class {
|
|
1619
1723
|
static logger = r;
|
|
1620
1724
|
options;
|
|
1621
1725
|
dataSource = null;
|
|
1622
1726
|
contentLoader;
|
|
1623
1727
|
plugins = {};
|
|
1624
|
-
eventBus =
|
|
1728
|
+
eventBus = F();
|
|
1625
1729
|
events;
|
|
1626
1730
|
projectId;
|
|
1627
1731
|
apiUrl;
|
|
1628
1732
|
dashboardUrl;
|
|
1629
1733
|
documentationSiteUrl;
|
|
1630
|
-
session =
|
|
1631
|
-
searchParams =
|
|
1632
|
-
history =
|
|
1633
|
-
components =
|
|
1634
|
-
experienceInstances =
|
|
1635
|
-
experiences =
|
|
1636
|
-
frameworks =
|
|
1637
|
-
predicates =
|
|
1638
|
-
features =
|
|
1639
|
-
conditions =
|
|
1640
|
-
fields =
|
|
1641
|
-
responses =
|
|
1642
|
-
steps =
|
|
1643
|
-
contents =
|
|
1644
|
-
actions =
|
|
1645
|
-
conditionResults =
|
|
1646
|
-
stateSnapshotStore =
|
|
1647
|
-
evaluateRuleLogicFx =
|
|
1734
|
+
session = Ft();
|
|
1735
|
+
searchParams = At();
|
|
1736
|
+
history = Qe();
|
|
1737
|
+
components = Se({ client: this });
|
|
1738
|
+
experienceInstances = C({ client: this });
|
|
1739
|
+
experiences = me({ client: this });
|
|
1740
|
+
frameworks = Ee({ client: this });
|
|
1741
|
+
predicates = We({ client: this });
|
|
1742
|
+
features = Je({ client: this });
|
|
1743
|
+
conditions = Ot();
|
|
1744
|
+
fields = rt();
|
|
1745
|
+
responses = Tt({ client: this });
|
|
1746
|
+
steps = ot();
|
|
1747
|
+
contents = ut();
|
|
1748
|
+
actions = mt({ client: this });
|
|
1749
|
+
conditionResults = w();
|
|
1750
|
+
stateSnapshotStore = ke({ client: this });
|
|
1751
|
+
evaluateRuleLogicFx = Ie({ client: this });
|
|
1648
1752
|
start;
|
|
1649
1753
|
readyStore;
|
|
1650
1754
|
preconditionPassedStore;
|
|
1651
1755
|
conditionPassedStore;
|
|
1652
1756
|
lifecycleStageStore;
|
|
1653
|
-
lifecycle =
|
|
1654
|
-
renderStringFx =
|
|
1757
|
+
lifecycle = Ve({ client: this });
|
|
1758
|
+
renderStringFx = A({
|
|
1655
1759
|
source: this.responses.listStore,
|
|
1656
1760
|
effect: (e, { template: t, context: n }) => {
|
|
1657
1761
|
let r = {};
|
|
1658
1762
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1659
|
-
return
|
|
1763
|
+
return Wt(t, {
|
|
1660
1764
|
...n,
|
|
1661
1765
|
responses: r
|
|
1662
1766
|
});
|
|
1663
1767
|
}
|
|
1664
1768
|
});
|
|
1665
1769
|
constructor(e) {
|
|
1666
|
-
this.events =
|
|
1770
|
+
this.events = et(this.eventBus), this.projectId = zt(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || kt(), 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({
|
|
1667
1771
|
type: "load",
|
|
1668
1772
|
version: ne()
|
|
1669
1773
|
}), this.maybeStartPreviewBridge();
|
|
@@ -1672,21 +1776,21 @@ var $ = class {
|
|
|
1672
1776
|
!s() || !h() || this.searchParams["preview-token"]?.[0] && import("../preview-bridge-D76l-dPy.js").then((e) => e.initPreviewBridge()).catch(() => void 0);
|
|
1673
1777
|
}
|
|
1674
1778
|
registerFramework = (e) => {
|
|
1675
|
-
|
|
1779
|
+
De(e, this.frameworks);
|
|
1676
1780
|
};
|
|
1677
1781
|
registerComponent = (e, t) => {
|
|
1678
|
-
|
|
1782
|
+
Ce(e, t, this.components);
|
|
1679
1783
|
};
|
|
1680
1784
|
registerPlugin = (e) => {
|
|
1681
|
-
|
|
1785
|
+
_e(this, e, this.plugins);
|
|
1682
1786
|
let t = this.plugins[e.name];
|
|
1683
1787
|
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1684
1788
|
};
|
|
1685
1789
|
registerFeature = (e, t) => {
|
|
1686
|
-
|
|
1790
|
+
Ye(e, t, this.features);
|
|
1687
1791
|
};
|
|
1688
1792
|
registerPredicate = (e, t) => {
|
|
1689
|
-
|
|
1793
|
+
Ge(e, t, this.predicates);
|
|
1690
1794
|
};
|
|
1691
1795
|
registerCondition = (e) => {
|
|
1692
1796
|
this.conditions.register(e);
|
|
@@ -1695,16 +1799,16 @@ var $ = class {
|
|
|
1695
1799
|
this.fields.register(e);
|
|
1696
1800
|
};
|
|
1697
1801
|
registerStep = (e) => {
|
|
1698
|
-
|
|
1802
|
+
st(e, this.steps);
|
|
1699
1803
|
};
|
|
1700
1804
|
registerContent = (e) => {
|
|
1701
|
-
|
|
1805
|
+
dt(e, this.contents);
|
|
1702
1806
|
};
|
|
1703
1807
|
registerAction = (e, t) => {
|
|
1704
|
-
|
|
1808
|
+
ht(e, t, this.actions);
|
|
1705
1809
|
};
|
|
1706
1810
|
registerExperience = (e) => {
|
|
1707
|
-
e.component &&
|
|
1811
|
+
e.component && Ce(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1708
1812
|
};
|
|
1709
1813
|
launchExperienceById = async (e, t) => {
|
|
1710
1814
|
this.experiences.launch({
|
|
@@ -1789,20 +1893,20 @@ var $ = class {
|
|
|
1789
1893
|
};
|
|
1790
1894
|
//#endregion
|
|
1791
1895
|
//#region src/entities/component/lazyComponent.ts
|
|
1792
|
-
function
|
|
1896
|
+
function Kt(e) {
|
|
1793
1897
|
return {
|
|
1794
1898
|
$$type: "lazy-component",
|
|
1795
1899
|
load: e
|
|
1796
1900
|
};
|
|
1797
1901
|
}
|
|
1798
|
-
function
|
|
1902
|
+
function qt(e) {
|
|
1799
1903
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1800
1904
|
}
|
|
1801
1905
|
//#endregion
|
|
1802
1906
|
//#region src/exports.ts
|
|
1803
|
-
var
|
|
1804
|
-
let t = new
|
|
1907
|
+
var Jt = (e) => {
|
|
1908
|
+
let t = new Gt(e);
|
|
1805
1909
|
return u(t), t;
|
|
1806
1910
|
};
|
|
1807
1911
|
//#endregion
|
|
1808
|
-
export {
|
|
1912
|
+
export { Gt as Picked, Jt as createClient, ge as createPluginEffect, k as createStorageKey, n as evaluateRuleLogic, It as getPickedConfig, h as isInsideIframe, qt as isLazyLoader, b as isPickedRoot, Kt as lazyComponent, D as localStore, O as sessionStore, E as subscribe, d as supportsCookies, p as supportsCryptoRandomUUID, c as supportsDocument, i as supportsHistory, f as supportsIntersectionObserver, m as supportsLocalStorage, a as supportsLocation, l as supportsSessionStorage, g as supportsShadowRoot, o as supportsWebComponents, s as supportsWindow };
|