@picked/client 0.0.62 → 0.0.63
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-BZK_ICsc.cjs +1 -0
- package/dist/{api-CD_x70IA.js → api-CQuvieEa.js} +7 -4
- 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/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/plugins/window-object/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/{dom-DGePXPpM.js → dom-DjfSrkpp.js} +7 -7
- package/dist/{dom-C3C6Fmwz.cjs → dom-sqnnO-CT.cjs} +1 -1
- package/dist/esm/index.js +406 -400
- package/dist/esm/plugins/dom-observer/index.js +2 -2
- package/dist/esm/plugins/dynamic-experiences/index.js +3 -234
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-indexeddb/index.js +1 -1
- package/dist/esm/plugins/single-page-app/index.js +14 -14
- package/dist/esm/plugins/web-components/index.js +2 -2
- package/dist/esm/plugins/window-object/index.js +1 -1
- package/dist/esm/server/index.js +94 -57
- package/dist/experience-instance-CVKoGtYE.cjs +1 -0
- package/dist/{experience-instance-DImym3m_.js → experience-instance-DBzfLqnk.js} +161 -65
- package/dist/plugin-C0q0cRCy.js +241 -0
- package/dist/plugin-gwaOQFCe.cjs +1 -0
- package/dist/preview-bridge-CGyx7dEx.js +33 -0
- package/dist/preview-bridge-DIdDvNXQ.cjs +1 -0
- package/dist/supports-34OzZK5j.cjs +1 -0
- package/dist/{supports-0XIfd4-R.js → supports-BgjwyijI.js} +11 -4
- package/dist/types/entities/content/content.d.ts +5 -0
- package/dist/types/entities/content/content.d.ts.map +1 -1
- package/dist/types/lifecycle/condition-selection.d.ts +112 -0
- package/dist/types/lifecycle/condition-selection.d.ts.map +1 -0
- package/dist/types/lifecycle/lifecycle.d.ts.map +1 -1
- package/dist/types/picked.d.ts +19 -0
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +24 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +9 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/preview-bridge/index.d.ts +14 -0
- package/dist/types/preview-bridge/index.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +8 -0
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +84 -0
- package/dist/types/server/serialize.d.ts.map +1 -0
- package/dist/types/utils/api.d.ts +23 -1
- package/dist/types/utils/api.d.ts.map +1 -1
- package/dist/types/utils/supports.d.ts +85 -0
- package/dist/types/utils/supports.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/api-BB-f9JB_.cjs +0 -1
- package/dist/experience-instance-DygAdzbn.cjs +0 -1
- package/dist/supports-Dsjg-82e.cjs +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
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
|
-
import { a as i, c as a, d as o,
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
7
|
-
import { i as
|
|
8
|
-
import { n as
|
|
9
|
-
import { t as
|
|
10
|
-
import { attach as
|
|
11
|
-
import { createFactory as
|
|
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-BgjwyijI.js";
|
|
5
|
+
import { a as _, i as v, r as ee, s as y, t as b } from "../dom-DjfSrkpp.js";
|
|
6
|
+
import { c as x, l as S, n as C, r as w } from "../experience-instance-DBzfLqnk.js";
|
|
7
|
+
import { i as T, n as E, r as D, t as O } from "../storage-hOHCCXvP.js";
|
|
8
|
+
import { n as te, r as ne } from "../api-CQuvieEa.js";
|
|
9
|
+
import { t as re } from "../id-n2yrHvNo.js";
|
|
10
|
+
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";
|
|
11
|
+
import { createFactory as L, invoke as R } from "@withease/factories";
|
|
12
12
|
//#region src/entities/experience/experience.ts
|
|
13
|
-
var
|
|
14
|
-
let i =
|
|
13
|
+
var z = M("experience"), ie = L(({ client: e, experience: r }) => {
|
|
14
|
+
let i = z.store(r), a = j(i, { merge(e, t) {
|
|
15
15
|
return {
|
|
16
16
|
...e,
|
|
17
17
|
...t.experience
|
|
@@ -21,24 +21,24 @@ var R = j("experience"), re = I(({ client: e, experience: r }) => {
|
|
|
21
21
|
decisionLogic: e.condition,
|
|
22
22
|
targetSelectors: e.targets,
|
|
23
23
|
initializeOpenLogic: e.initializeOpen
|
|
24
|
-
})), s =
|
|
25
|
-
let r = e.nodes.filter(
|
|
24
|
+
})), 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) => {
|
|
25
|
+
let r = e.nodes.filter(S).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);
|
|
26
26
|
return {
|
|
27
27
|
steps: r,
|
|
28
28
|
nodes: e.nodes,
|
|
29
29
|
edges: e.edges,
|
|
30
30
|
conditions: i
|
|
31
31
|
};
|
|
32
|
-
}), l = r.actions ?? [], u, d =
|
|
32
|
+
}), l = r.actions ?? [], u, d = k({
|
|
33
33
|
source: o,
|
|
34
34
|
effect: (t, n) => {
|
|
35
|
-
let i =
|
|
36
|
-
i.forEach(({ elements: e }) => e.forEach((e) =>
|
|
35
|
+
let i = v(t.targetSelectors, r.id);
|
|
36
|
+
i.forEach(({ elements: e }) => e.forEach((e) => y(e, r.id))), b(i, r.id, r.key).forEach((t) => {
|
|
37
37
|
n ? e.experienceInstances.spawn(u, t, n) : e.experienceInstances.spawn(u, t);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
}), f =
|
|
41
|
-
source:
|
|
40
|
+
}), f = k({
|
|
41
|
+
source: A({
|
|
42
42
|
preconditionPassed: e.preconditionPassedStore,
|
|
43
43
|
isUser: e.session.store.map((e) => e.isUser, { skipVoid: !1 }),
|
|
44
44
|
config: o
|
|
@@ -46,9 +46,9 @@ var R = j("experience"), re = I(({ client: e, experience: r }) => {
|
|
|
46
46
|
effect: async ({ preconditionPassed: i, isUser: a, config: o }) => {
|
|
47
47
|
if (!i || !a) return !1;
|
|
48
48
|
let { decisionLogic: s, targetSelectors: c } = o;
|
|
49
|
-
return c.length === 0 ||
|
|
49
|
+
return c.length === 0 || v(c, r.id).length < 1 ? !1 : s === void 0 ? !0 : t(s) ? await n(e, s) === !0 : !0;
|
|
50
50
|
}
|
|
51
|
-
}), p =
|
|
51
|
+
}), p = N(async () => {
|
|
52
52
|
if (!e.contentLoader) return !0;
|
|
53
53
|
try {
|
|
54
54
|
await e.contentLoader({
|
|
@@ -59,26 +59,26 @@ var R = j("experience"), re = I(({ client: e, experience: r }) => {
|
|
|
59
59
|
`${r.id}`;
|
|
60
60
|
}
|
|
61
61
|
return !0;
|
|
62
|
-
}), m =
|
|
63
|
-
return
|
|
62
|
+
}), m = P(), h = P(), g = z.createStore(void 0, { skipVoid: !1 }).on(m, (e, t) => t).on(h, (e, t) => t);
|
|
63
|
+
return I({
|
|
64
64
|
clock: m,
|
|
65
65
|
target: f
|
|
66
|
-
}),
|
|
66
|
+
}), I({
|
|
67
67
|
clock: f.doneData,
|
|
68
68
|
source: g,
|
|
69
69
|
filter: (e, t) => t,
|
|
70
70
|
fn: (e) => e,
|
|
71
71
|
target: d
|
|
72
|
-
}),
|
|
72
|
+
}), I({
|
|
73
73
|
clock: f.doneData,
|
|
74
74
|
filter: Boolean,
|
|
75
75
|
target: p
|
|
76
|
-
}),
|
|
76
|
+
}), I({
|
|
77
77
|
clock: h,
|
|
78
78
|
source: g,
|
|
79
79
|
fn: (e) => e,
|
|
80
80
|
target: d
|
|
81
|
-
}),
|
|
81
|
+
}), I({
|
|
82
82
|
clock: h,
|
|
83
83
|
target: p
|
|
84
84
|
}), u = {
|
|
@@ -97,22 +97,22 @@ var R = j("experience"), re = I(({ client: e, experience: r }) => {
|
|
|
97
97
|
prepareExperienceContentFx: p
|
|
98
98
|
}, u;
|
|
99
99
|
});
|
|
100
|
-
function
|
|
101
|
-
return
|
|
100
|
+
function ae(e) {
|
|
101
|
+
return R(ie, e);
|
|
102
102
|
}
|
|
103
|
-
var
|
|
104
|
-
let t =
|
|
103
|
+
var oe = L(({ client: e }) => {
|
|
104
|
+
let t = z.store({}), n = j(t, { register(e, t) {
|
|
105
105
|
return {
|
|
106
106
|
...e,
|
|
107
107
|
[t.id]: t
|
|
108
108
|
};
|
|
109
|
-
} }), r =
|
|
110
|
-
n.register(
|
|
109
|
+
} }), r = P(), i = N((t) => {
|
|
110
|
+
n.register(ae({
|
|
111
111
|
client: e,
|
|
112
112
|
experience: t
|
|
113
113
|
}));
|
|
114
114
|
});
|
|
115
|
-
|
|
115
|
+
I({
|
|
116
116
|
clock: r,
|
|
117
117
|
source: t,
|
|
118
118
|
filter: (e, t) => e[t.id] !== void 0,
|
|
@@ -125,7 +125,7 @@ var ae = I(({ client: e }) => {
|
|
|
125
125
|
experience: t,
|
|
126
126
|
strategy: "override"
|
|
127
127
|
});
|
|
128
|
-
}),
|
|
128
|
+
}), I({
|
|
129
129
|
clock: r,
|
|
130
130
|
source: t,
|
|
131
131
|
filter: (e, t) => e[t.id] === void 0,
|
|
@@ -139,7 +139,7 @@ var ae = I(({ client: e }) => {
|
|
|
139
139
|
function s(e) {
|
|
140
140
|
return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
|
|
141
141
|
}
|
|
142
|
-
let c =
|
|
142
|
+
let c = k({
|
|
143
143
|
source: t,
|
|
144
144
|
effect: (e, t) => {
|
|
145
145
|
let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
|
|
@@ -157,7 +157,7 @@ var ae = I(({ client: e }) => {
|
|
|
157
157
|
getById: o,
|
|
158
158
|
getByKey: s,
|
|
159
159
|
launch: c,
|
|
160
|
-
open:
|
|
160
|
+
open: k({
|
|
161
161
|
source: {
|
|
162
162
|
experiences: t,
|
|
163
163
|
instances: e.experienceInstances.listStore
|
|
@@ -184,7 +184,7 @@ var ae = I(({ client: e }) => {
|
|
|
184
184
|
}
|
|
185
185
|
}),
|
|
186
186
|
listStore: a,
|
|
187
|
-
initialiseExperiencesFx:
|
|
187
|
+
initialiseExperiencesFx: k({
|
|
188
188
|
source: a,
|
|
189
189
|
effect: (e) => {
|
|
190
190
|
for (let t of e) t.initialiseRequested(void 0);
|
|
@@ -192,20 +192,20 @@ var ae = I(({ client: e }) => {
|
|
|
192
192
|
})
|
|
193
193
|
};
|
|
194
194
|
});
|
|
195
|
-
function
|
|
196
|
-
return
|
|
195
|
+
function se(e) {
|
|
196
|
+
return R(oe, e);
|
|
197
197
|
}
|
|
198
|
-
var
|
|
198
|
+
var ce = async (e) => {
|
|
199
199
|
await e.experiences.initialiseExperiencesFx();
|
|
200
200
|
};
|
|
201
201
|
//#endregion
|
|
202
202
|
//#region src/entities/plugin/plugin.ts
|
|
203
|
-
function
|
|
204
|
-
return
|
|
203
|
+
function le(e) {
|
|
204
|
+
return N(async () => {
|
|
205
205
|
await e();
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
|
-
var
|
|
208
|
+
var ue = (e, t, n) => {
|
|
209
209
|
let r = t.name, i = t.setup(e);
|
|
210
210
|
if (i) {
|
|
211
211
|
let e = n[r] ?? {};
|
|
@@ -214,29 +214,29 @@ var le = (e, t, n) => {
|
|
|
214
214
|
...i
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
|
-
},
|
|
217
|
+
}, de = M("component"), fe = L(({ client: e, component: t, name: n }) => ({
|
|
218
218
|
name: n,
|
|
219
219
|
component: t,
|
|
220
220
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
221
221
|
}));
|
|
222
|
-
function
|
|
223
|
-
return
|
|
222
|
+
function pe(e) {
|
|
223
|
+
return R(fe, e);
|
|
224
224
|
}
|
|
225
|
-
var
|
|
226
|
-
let t =
|
|
225
|
+
var me = L(({ client: e }) => {
|
|
226
|
+
let t = de.store({}), n = j(t, { register(e, t) {
|
|
227
227
|
return {
|
|
228
228
|
...e,
|
|
229
229
|
[t.name]: t
|
|
230
230
|
};
|
|
231
|
-
} }), i =
|
|
232
|
-
|
|
231
|
+
} }), i = P();
|
|
232
|
+
I({
|
|
233
233
|
clock: i,
|
|
234
234
|
source: t,
|
|
235
235
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
236
236
|
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
237
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
237
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
238
238
|
clock: i,
|
|
239
|
-
fn: ({ name: t, component: n }) =>
|
|
239
|
+
fn: ({ name: t, component: n }) => pe({
|
|
240
240
|
client: e,
|
|
241
241
|
name: t,
|
|
242
242
|
component: n
|
|
@@ -253,27 +253,27 @@ var pe = I(({ client: e }) => {
|
|
|
253
253
|
listStore: a
|
|
254
254
|
};
|
|
255
255
|
});
|
|
256
|
-
function
|
|
257
|
-
return
|
|
256
|
+
function he(e) {
|
|
257
|
+
return R(me, e);
|
|
258
258
|
}
|
|
259
|
-
var
|
|
259
|
+
var B = (e, t, n) => {
|
|
260
260
|
n.register({
|
|
261
261
|
name: e,
|
|
262
262
|
component: t
|
|
263
263
|
});
|
|
264
|
-
},
|
|
265
|
-
let t =
|
|
264
|
+
}, ge = M("framework"), _e = L((e) => {
|
|
265
|
+
let t = ge.store({}), n = j(t, { register(e, t) {
|
|
266
266
|
return {
|
|
267
267
|
...e,
|
|
268
268
|
[t.name]: t.framework
|
|
269
269
|
};
|
|
270
|
-
} }), i =
|
|
271
|
-
|
|
270
|
+
} }), i = P();
|
|
271
|
+
I({
|
|
272
272
|
clock: i,
|
|
273
273
|
source: t,
|
|
274
274
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
275
275
|
fn: (e, { name: t }) => `Framework '${t}' already registered. Registering again will override the previous registration.`
|
|
276
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
276
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
277
277
|
clock: i,
|
|
278
278
|
target: n.register
|
|
279
279
|
});
|
|
@@ -287,106 +287,106 @@ var z = (e, t, n) => {
|
|
|
287
287
|
listStore: a
|
|
288
288
|
};
|
|
289
289
|
});
|
|
290
|
-
function
|
|
291
|
-
return
|
|
290
|
+
function ve(e) {
|
|
291
|
+
return R(_e, e);
|
|
292
292
|
}
|
|
293
|
-
var
|
|
293
|
+
var ye = (e, t) => {
|
|
294
294
|
t.register({
|
|
295
295
|
name: e.name,
|
|
296
296
|
framework: e
|
|
297
297
|
});
|
|
298
|
-
},
|
|
298
|
+
}, be = L(({ client: e }) => {
|
|
299
299
|
let t = "window" in globalThis, n = {
|
|
300
300
|
location: t ? globalThis.location : void 0,
|
|
301
301
|
document: t ? globalThis.document : void 0,
|
|
302
302
|
sessionStorage: t ? globalThis.sessionStorage : void 0,
|
|
303
303
|
localStorage: t ? globalThis.localStorage : void 0
|
|
304
304
|
};
|
|
305
|
-
return
|
|
305
|
+
return A(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
|
|
306
306
|
client: e,
|
|
307
307
|
responses: t,
|
|
308
308
|
fields: r,
|
|
309
309
|
...n
|
|
310
310
|
}));
|
|
311
311
|
});
|
|
312
|
-
function
|
|
313
|
-
return
|
|
312
|
+
function xe(e) {
|
|
313
|
+
return R(be, e);
|
|
314
314
|
}
|
|
315
315
|
//#endregion
|
|
316
316
|
//#region src/logic-engine.ts
|
|
317
|
-
function
|
|
317
|
+
function Se(e) {
|
|
318
318
|
return typeof e == "number" && !isNaN(e);
|
|
319
319
|
}
|
|
320
|
-
function
|
|
320
|
+
function V(e) {
|
|
321
321
|
return typeof e == "string";
|
|
322
322
|
}
|
|
323
|
-
function
|
|
323
|
+
function H(e) {
|
|
324
324
|
return Array.isArray(e);
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function Ce(e) {
|
|
327
327
|
return e instanceof Promise;
|
|
328
328
|
}
|
|
329
|
-
function
|
|
329
|
+
function we(e) {
|
|
330
330
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
331
331
|
}
|
|
332
|
-
function
|
|
333
|
-
if (
|
|
332
|
+
function U(e) {
|
|
333
|
+
if (Se(e)) return e;
|
|
334
334
|
let t = parseFloat(`${e}`);
|
|
335
335
|
return isNaN(t) ? 0 : t;
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function W(e) {
|
|
338
338
|
return `${e}`;
|
|
339
339
|
}
|
|
340
|
-
var
|
|
340
|
+
var Te = {
|
|
341
341
|
"==": (e, t) => e == t,
|
|
342
342
|
"===": (e, t) => e === t,
|
|
343
343
|
"!=": (e, t) => e != t,
|
|
344
344
|
"!==": (e, t) => e !== t,
|
|
345
|
-
">": (e, t) =>
|
|
346
|
-
">=": (e, t) =>
|
|
345
|
+
">": (e, t) => U(e) > U(t),
|
|
346
|
+
">=": (e, t) => U(e) >= U(t),
|
|
347
347
|
"<": (e, t, n) => {
|
|
348
|
-
let r =
|
|
348
|
+
let r = U(e), i = U(t);
|
|
349
349
|
if (n === void 0) return r < i;
|
|
350
|
-
let a =
|
|
350
|
+
let a = U(n);
|
|
351
351
|
return r < i && i < a;
|
|
352
352
|
},
|
|
353
353
|
"<=": (e, t, n) => {
|
|
354
|
-
let r =
|
|
354
|
+
let r = U(e), i = U(t);
|
|
355
355
|
if (n === void 0) return r <= i;
|
|
356
|
-
let a =
|
|
356
|
+
let a = U(n);
|
|
357
357
|
return r <= i && i <= a;
|
|
358
358
|
},
|
|
359
|
-
"!!": async (e) => await
|
|
360
|
-
"!": async (e) => !await
|
|
361
|
-
"%": (e, t) =>
|
|
359
|
+
"!!": async (e) => await K(e),
|
|
360
|
+
"!": async (e) => !await K(e),
|
|
361
|
+
"%": (e, t) => U(e) % U(t),
|
|
362
362
|
log: (e) => (console.log(e), e),
|
|
363
|
-
in: (e, t) => t ?
|
|
364
|
-
cat: (...e) => e.map(
|
|
363
|
+
in: (e, t) => t ? V(t) ? t.indexOf(W(e)) !== -1 : H(t) ? t.includes(e) : !1 : !1,
|
|
364
|
+
cat: (...e) => e.map(W).join(""),
|
|
365
365
|
substr: (e, t, n) => {
|
|
366
|
-
let r =
|
|
366
|
+
let r = W(e), i = U(t);
|
|
367
367
|
if (n === void 0) return r.substr(i);
|
|
368
|
-
let a =
|
|
368
|
+
let a = U(n);
|
|
369
369
|
if (a < 0) {
|
|
370
370
|
let e = r.substr(i);
|
|
371
371
|
return e.substr(0, e.length + a);
|
|
372
372
|
}
|
|
373
373
|
return r.substr(i, a);
|
|
374
374
|
},
|
|
375
|
-
"+": (...e) => e.reduce((e, t) =>
|
|
376
|
-
"*": (...e) => e.reduce((e, t) =>
|
|
375
|
+
"+": (...e) => e.reduce((e, t) => U(e) + U(t), 0),
|
|
376
|
+
"*": (...e) => e.reduce((e, t) => U(e) * U(t), 1),
|
|
377
377
|
"-": (e, t) => {
|
|
378
|
-
let n =
|
|
379
|
-
return t === void 0 ? -n : n -
|
|
378
|
+
let n = U(e);
|
|
379
|
+
return t === void 0 ? -n : n - U(t);
|
|
380
380
|
},
|
|
381
|
-
"/": (e, t) =>
|
|
382
|
-
min: (...e) => Math.min(...e.map(
|
|
383
|
-
max: (...e) => Math.max(...e.map(
|
|
384
|
-
merge: (...e) => e.reduce((e, t) =>
|
|
381
|
+
"/": (e, t) => U(e) / U(t),
|
|
382
|
+
min: (...e) => Math.min(...e.map(U)),
|
|
383
|
+
max: (...e) => Math.max(...e.map(U)),
|
|
384
|
+
merge: (...e) => e.reduce((e, t) => H(t) ? e.concat(t) : e.concat([t]), []),
|
|
385
385
|
var(e, t) {
|
|
386
386
|
let n = arguments.length > 1 ? t : null;
|
|
387
387
|
if (e === "" || e === "." || e == null) return this;
|
|
388
388
|
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
389
|
-
let r =
|
|
389
|
+
let r = W(e);
|
|
390
390
|
if (r === "" || r === ".") return this;
|
|
391
391
|
let i = r.split("."), a = this;
|
|
392
392
|
for (let e of i) {
|
|
@@ -399,116 +399,116 @@ var Se = {
|
|
|
399
399
|
return a === void 0 ? n : a;
|
|
400
400
|
},
|
|
401
401
|
async missing(...e) {
|
|
402
|
-
let t =
|
|
402
|
+
let t = H(e[0]) ? e[0] : e, n = [];
|
|
403
403
|
for (let e of t) {
|
|
404
|
-
let t = await
|
|
404
|
+
let t = await G({ var: e }, this);
|
|
405
405
|
(t === null || t === "") && n.push(`${e}`);
|
|
406
406
|
}
|
|
407
407
|
return n;
|
|
408
408
|
},
|
|
409
409
|
async missing_some(e, t) {
|
|
410
|
-
let n = await
|
|
411
|
-
if (!
|
|
412
|
-
let r = n.filter(
|
|
413
|
-
return t.filter(
|
|
410
|
+
let n = await G({ missing: t }, this);
|
|
411
|
+
if (!H(n) || !H(t)) return [];
|
|
412
|
+
let r = n.filter(V);
|
|
413
|
+
return t.filter(V).length - r.length >= U(e) ? [] : r;
|
|
414
414
|
},
|
|
415
415
|
invoke(...e) {
|
|
416
416
|
let [t, ...n] = e;
|
|
417
417
|
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
418
418
|
},
|
|
419
|
-
startsWith: (e, t) =>
|
|
420
|
-
endsWith: (e, t) =>
|
|
419
|
+
startsWith: (e, t) => V(e) && V(t) && e.startsWith(t),
|
|
420
|
+
endsWith: (e, t) => V(e) && V(t) && e.endsWith(t),
|
|
421
421
|
regexp_matches(e, t) {
|
|
422
422
|
let n = e, r = "";
|
|
423
|
-
if (
|
|
423
|
+
if (H(e)) {
|
|
424
424
|
let [t, i] = e;
|
|
425
425
|
n = t, r = i;
|
|
426
426
|
}
|
|
427
|
-
return !
|
|
427
|
+
return !V(n) || !V(r) ? !1 : new RegExp(n, r).test(W(t));
|
|
428
428
|
},
|
|
429
429
|
throw(e) {
|
|
430
|
-
throw Error(
|
|
430
|
+
throw Error(W(e));
|
|
431
431
|
}
|
|
432
432
|
};
|
|
433
|
-
async function
|
|
433
|
+
async function G(e, t) {
|
|
434
434
|
if (!e) return e;
|
|
435
|
-
if (
|
|
436
|
-
if (
|
|
437
|
-
if (!
|
|
438
|
-
let n =
|
|
439
|
-
switch (
|
|
435
|
+
if (Ce(e)) return G(await e, t);
|
|
436
|
+
if (H(e)) return Promise.all(e.map((e) => G(e, t)));
|
|
437
|
+
if (!we(e)) return e;
|
|
438
|
+
let n = Ee(e), r = n ? e[n] ?? [] : [];
|
|
439
|
+
switch (H(r) || (r = [r]), n) {
|
|
440
440
|
case "if":
|
|
441
441
|
case "?:":
|
|
442
|
-
for (let e = 0; e < r.length - 1; e += 2) if (await
|
|
443
|
-
return r.length % 2 == 1 ?
|
|
442
|
+
for (let e = 0; e < r.length - 1; e += 2) if (await K(await G(r[e], t))) return G(r[e + 1], t);
|
|
443
|
+
return r.length % 2 == 1 ? G(r[r.length - 1], t) : null;
|
|
444
444
|
case "and": {
|
|
445
445
|
let e = null;
|
|
446
|
-
for (let n of r) if (e = await
|
|
446
|
+
for (let n of r) if (e = await G(n, t), !await K(e)) return e;
|
|
447
447
|
return e;
|
|
448
448
|
}
|
|
449
449
|
case "or": {
|
|
450
450
|
let e = null;
|
|
451
|
-
for (let n of r) if (e = await
|
|
451
|
+
for (let n of r) if (e = await G(n, t), await K(e)) return e;
|
|
452
452
|
return e;
|
|
453
453
|
}
|
|
454
454
|
case "map": {
|
|
455
|
-
let e = await
|
|
456
|
-
return
|
|
455
|
+
let e = await G(r[0], t);
|
|
456
|
+
return H(e) ? await Promise.all(e.map((e) => G(r[1], e))) : [];
|
|
457
457
|
}
|
|
458
458
|
case "filter": {
|
|
459
|
-
let e = await
|
|
460
|
-
return
|
|
459
|
+
let e = await G(r[0], t);
|
|
460
|
+
return H(e) ? (await Promise.all(e.map(async (e) => ({
|
|
461
461
|
item: e,
|
|
462
|
-
shouldInclude: await
|
|
462
|
+
shouldInclude: await K(await G(r[1], e))
|
|
463
463
|
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
464
464
|
}
|
|
465
465
|
case "reduce": {
|
|
466
|
-
let e = await
|
|
467
|
-
if (!
|
|
468
|
-
let n = r[1], i = r.length > 2 ? await
|
|
469
|
-
for (let t of e) i = await
|
|
466
|
+
let e = await G(r[0], t);
|
|
467
|
+
if (!H(e)) return r.length > 2 ? await G(r[2], t) : null;
|
|
468
|
+
let n = r[1], i = r.length > 2 ? await G(r[2], t) : null;
|
|
469
|
+
for (let t of e) i = await G(n, {
|
|
470
470
|
current: t,
|
|
471
471
|
accumulator: i
|
|
472
472
|
});
|
|
473
473
|
return i;
|
|
474
474
|
}
|
|
475
475
|
case "all": {
|
|
476
|
-
let e = await
|
|
477
|
-
if (!
|
|
478
|
-
for (let t of e) if (!await
|
|
476
|
+
let e = await G(r[0], t);
|
|
477
|
+
if (!H(e) || e.length === 0) return !1;
|
|
478
|
+
for (let t of e) if (!await K(await G(r[1], t))) return !1;
|
|
479
479
|
return !0;
|
|
480
480
|
}
|
|
481
481
|
case "some": {
|
|
482
|
-
let e = await
|
|
483
|
-
if (!
|
|
484
|
-
for (let t of e) if (await
|
|
482
|
+
let e = await G(r[0], t);
|
|
483
|
+
if (!H(e)) return !1;
|
|
484
|
+
for (let t of e) if (await K(await G(r[1], t))) return !0;
|
|
485
485
|
return !1;
|
|
486
486
|
}
|
|
487
487
|
case "none": {
|
|
488
|
-
let e = await
|
|
489
|
-
if (!
|
|
490
|
-
for (let t of e) if (await
|
|
488
|
+
let e = await G(r[0], t);
|
|
489
|
+
if (!H(e)) return !0;
|
|
490
|
+
for (let t of e) if (await K(await G(r[1], t))) return !1;
|
|
491
491
|
return !0;
|
|
492
492
|
}
|
|
493
493
|
case "catch": try {
|
|
494
|
-
return await
|
|
494
|
+
return await G(r[0], t);
|
|
495
495
|
} catch (e) {
|
|
496
|
-
return
|
|
496
|
+
return we(e) ? await G(e, t) : r[1] ? await G(r[1], e) : e instanceof Error ? e.message : e;
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
|
-
let i = await Promise.all(r.map((e) =>
|
|
499
|
+
let i = await Promise.all(r.map((e) => G(e, t))), a = n ? Te[n] : void 0;
|
|
500
500
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
501
501
|
return a.apply(t, i);
|
|
502
502
|
}
|
|
503
|
-
async function
|
|
504
|
-
return
|
|
503
|
+
async function K(e) {
|
|
504
|
+
return Ce(e) ? K(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
505
505
|
}
|
|
506
|
-
function
|
|
506
|
+
function Ee(e) {
|
|
507
507
|
return Object.keys(e)[0];
|
|
508
508
|
}
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/lifecycle/rules-logic.ts
|
|
511
|
-
var
|
|
511
|
+
var De = L(({ client: e }) => k({
|
|
512
512
|
source: {
|
|
513
513
|
stateSnapshot: e.stateSnapshotStore,
|
|
514
514
|
predicates: e.predicates.listStore,
|
|
@@ -527,7 +527,7 @@ var we = I(({ client: e }) => O({
|
|
|
527
527
|
let { bucket: e } = await t.getBucket();
|
|
528
528
|
return e;
|
|
529
529
|
}, e), {});
|
|
530
|
-
return await
|
|
530
|
+
return await G(a, {
|
|
531
531
|
responses: i,
|
|
532
532
|
location: typeof e.location == "object" ? {
|
|
533
533
|
hash: e.location.hash,
|
|
@@ -547,138 +547,140 @@ var we = I(({ client: e }) => O({
|
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
549
|
}));
|
|
550
|
-
function
|
|
551
|
-
return
|
|
550
|
+
function Oe(e) {
|
|
551
|
+
return R(De, e);
|
|
552
552
|
}
|
|
553
553
|
//#endregion
|
|
554
554
|
//#region src/ping.ts
|
|
555
|
-
var
|
|
555
|
+
var ke = 6e3, Ae = O("last_ping", "global"), je = async (e) => {
|
|
556
556
|
try {
|
|
557
|
-
let t = Date.now(), n =
|
|
558
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
557
|
+
let t = Date.now(), n = E.get(Ae), r = 0;
|
|
558
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < ke) return !0;
|
|
559
559
|
let i = {
|
|
560
560
|
projectId: e.projectId,
|
|
561
561
|
path: window.location.pathname
|
|
562
562
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
563
563
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
564
|
-
let s = (await
|
|
564
|
+
let s = (await te(e.apiUrl, "ping", i, a)).ok;
|
|
565
565
|
return s && n.set(t), s;
|
|
566
566
|
} catch {
|
|
567
567
|
return !1;
|
|
568
568
|
}
|
|
569
|
-
},
|
|
570
|
-
let t =
|
|
569
|
+
}, q = M("lifecycle"), Me = L(({ client: e }) => {
|
|
570
|
+
let t = q.store(!1), r = F(void 0, {
|
|
571
571
|
skipVoid: !1,
|
|
572
|
-
domain:
|
|
573
|
-
}), i =
|
|
572
|
+
domain: q
|
|
573
|
+
}), i = F(void 0, {
|
|
574
574
|
skipVoid: !1,
|
|
575
|
-
domain:
|
|
576
|
-
}), a =
|
|
575
|
+
domain: q
|
|
576
|
+
}), a = q.store("idle"), o = q.store([]), s = F(void 0, {
|
|
577
577
|
skipVoid: !1,
|
|
578
|
-
domain:
|
|
579
|
-
}),
|
|
578
|
+
domain: q
|
|
579
|
+
}), l = F(void 0, {
|
|
580
580
|
skipVoid: !1,
|
|
581
|
-
domain:
|
|
582
|
-
}),
|
|
583
|
-
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t),
|
|
584
|
-
let g =
|
|
585
|
-
|
|
586
|
-
}), _ =
|
|
581
|
+
domain: q
|
|
582
|
+
}), u = P(), d = P(), f = P(), p = P(), m = P(), h = P();
|
|
583
|
+
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), l.on(h, (e, t) => t), t.on(d, () => !0);
|
|
584
|
+
let g = N(() => {
|
|
585
|
+
je(e);
|
|
586
|
+
}), _ = N(async () => {
|
|
587
587
|
await ee();
|
|
588
|
-
}), v =
|
|
589
|
-
await
|
|
590
|
-
}), y =
|
|
588
|
+
}), v = N(async () => {
|
|
589
|
+
await ce(e);
|
|
590
|
+
}), y = k({ effect: v }), b = k({
|
|
591
591
|
source: o,
|
|
592
592
|
effect: async (e) => {
|
|
593
593
|
for (let t of e) await t();
|
|
594
594
|
}
|
|
595
|
-
}), x =
|
|
595
|
+
}), x = k({
|
|
596
596
|
source: s,
|
|
597
597
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
598
|
-
}), S =
|
|
599
|
-
source:
|
|
598
|
+
}), S = k({
|
|
599
|
+
source: l,
|
|
600
600
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
601
|
-
}), C =
|
|
602
|
-
clock:
|
|
603
|
-
|
|
601
|
+
}), C = I({
|
|
602
|
+
clock: u,
|
|
603
|
+
source: a,
|
|
604
|
+
filter: (e) => e === "idle" && c(),
|
|
605
|
+
fn: () => void 0
|
|
604
606
|
});
|
|
605
|
-
|
|
607
|
+
I({
|
|
606
608
|
clock: C,
|
|
607
609
|
fn: () => "starting",
|
|
608
610
|
target: a
|
|
609
|
-
}),
|
|
611
|
+
}), I({
|
|
610
612
|
clock: C,
|
|
611
613
|
target: g
|
|
612
|
-
}),
|
|
614
|
+
}), I({
|
|
613
615
|
clock: C,
|
|
614
616
|
target: b
|
|
615
|
-
}),
|
|
617
|
+
}), I({
|
|
616
618
|
clock: C,
|
|
617
619
|
target: _
|
|
618
|
-
}),
|
|
620
|
+
}), I({
|
|
619
621
|
clock: b.done,
|
|
620
622
|
target: x
|
|
621
|
-
}),
|
|
623
|
+
}), I({
|
|
622
624
|
clock: x.doneData,
|
|
623
625
|
target: r
|
|
624
|
-
}),
|
|
626
|
+
}), I({
|
|
625
627
|
clock: S.doneData,
|
|
626
628
|
target: i
|
|
627
|
-
}),
|
|
629
|
+
}), I({
|
|
628
630
|
clock: x.doneData,
|
|
629
631
|
filter: (e) => e,
|
|
630
632
|
target: S
|
|
631
|
-
}),
|
|
633
|
+
}), I({
|
|
632
634
|
clock: S.doneData,
|
|
633
635
|
target: e.session.setIsUser
|
|
634
|
-
}),
|
|
636
|
+
}), I({
|
|
635
637
|
clock: S.doneData,
|
|
636
638
|
fn: (e) => ({
|
|
637
639
|
type: "user_decide",
|
|
638
640
|
value: e
|
|
639
641
|
}),
|
|
640
642
|
target: e.eventBus
|
|
641
|
-
}),
|
|
643
|
+
}), I({
|
|
642
644
|
clock: x.doneData,
|
|
643
645
|
filter: (e) => !e,
|
|
644
646
|
fn: () => void 0,
|
|
645
|
-
target:
|
|
646
|
-
}),
|
|
647
|
+
target: f
|
|
648
|
+
}), I({
|
|
647
649
|
clock: S.doneData,
|
|
648
650
|
fn: () => void 0,
|
|
649
|
-
target:
|
|
650
|
-
}),
|
|
651
|
-
clock:
|
|
651
|
+
target: f
|
|
652
|
+
}), I({
|
|
653
|
+
clock: f,
|
|
652
654
|
fn: () => ({ type: "initialize" }),
|
|
653
655
|
target: e.eventBus
|
|
654
656
|
});
|
|
655
|
-
let w =
|
|
656
|
-
return
|
|
657
|
-
clock:
|
|
657
|
+
let w = F(!1).on(_.done, () => !0), T = F(!1).on(f, () => !0), E = F(!1).on(y.done, () => !0), D = A(r, i, (e, t) => e === !0 && t === !0);
|
|
658
|
+
return I({
|
|
659
|
+
clock: f,
|
|
658
660
|
source: D,
|
|
659
661
|
filter: (e) => e,
|
|
660
662
|
fn: () => void 0,
|
|
661
663
|
target: v
|
|
662
|
-
}),
|
|
663
|
-
clock:
|
|
664
|
+
}), I({
|
|
665
|
+
clock: A(w, T, D, (e, t, n) => e && t && n),
|
|
664
666
|
filter: (e) => e,
|
|
665
667
|
fn: () => void 0,
|
|
666
668
|
target: y
|
|
667
|
-
}),
|
|
668
|
-
clock:
|
|
669
|
+
}), I({
|
|
670
|
+
clock: A(w, T, D, E, (e, t, n, r) => e && t && (!n || r)),
|
|
669
671
|
filter: (e) => e,
|
|
670
672
|
fn: () => void 0,
|
|
671
|
-
target:
|
|
672
|
-
}),
|
|
673
|
-
clock:
|
|
673
|
+
target: d
|
|
674
|
+
}), I({
|
|
675
|
+
clock: d,
|
|
674
676
|
fn: () => "ready",
|
|
675
677
|
target: a
|
|
676
|
-
}),
|
|
677
|
-
clock:
|
|
678
|
+
}), I({
|
|
679
|
+
clock: d,
|
|
678
680
|
fn: () => ({ type: "ready" }),
|
|
679
681
|
target: e.eventBus
|
|
680
|
-
}),
|
|
681
|
-
clock:
|
|
682
|
+
}), I({
|
|
683
|
+
clock: d,
|
|
682
684
|
source: e.session.store,
|
|
683
685
|
fn: ({ id: e, isUser: t, identifiers: n }) => ({
|
|
684
686
|
type: "session",
|
|
@@ -687,7 +689,7 @@ var Ee = 6e3, De = E("last_ping", "global"), Oe = async (e) => {
|
|
|
687
689
|
identifiers: n
|
|
688
690
|
}),
|
|
689
691
|
target: e.eventBus
|
|
690
|
-
}),
|
|
692
|
+
}), I({
|
|
691
693
|
clock: [
|
|
692
694
|
b.fail,
|
|
693
695
|
x.fail,
|
|
@@ -699,7 +701,7 @@ var Ee = 6e3, De = E("last_ping", "global"), Oe = async (e) => {
|
|
|
699
701
|
fn: () => "failed",
|
|
700
702
|
target: a
|
|
701
703
|
}), {
|
|
702
|
-
start:
|
|
704
|
+
start: u,
|
|
703
705
|
readyStore: t,
|
|
704
706
|
preconditionPassedStore: r,
|
|
705
707
|
conditionPassedStore: i,
|
|
@@ -709,13 +711,13 @@ var Ee = 6e3, De = E("last_ping", "global"), Oe = async (e) => {
|
|
|
709
711
|
setCondition: h
|
|
710
712
|
};
|
|
711
713
|
});
|
|
712
|
-
function
|
|
713
|
-
return
|
|
714
|
+
function Ne(e) {
|
|
715
|
+
return R(Me, e);
|
|
714
716
|
}
|
|
715
717
|
//#endregion
|
|
716
718
|
//#region src/entities/predicate/predicate.ts
|
|
717
|
-
var
|
|
718
|
-
let t =
|
|
719
|
+
var Pe = M("predicate"), Fe = L(({ client: e }) => {
|
|
720
|
+
let t = Pe.store({}), n = j(t, { register(e, t) {
|
|
719
721
|
return {
|
|
720
722
|
...e,
|
|
721
723
|
[t.name]: {
|
|
@@ -723,13 +725,13 @@ var je = j("predicate"), Me = I(({ client: e }) => {
|
|
|
723
725
|
predicate: t.predicate
|
|
724
726
|
}
|
|
725
727
|
};
|
|
726
|
-
} }), i =
|
|
727
|
-
|
|
728
|
+
} }), i = P();
|
|
729
|
+
I({
|
|
728
730
|
clock: i,
|
|
729
731
|
source: t,
|
|
730
732
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
731
733
|
fn: (e, { name: t }) => `Predicate '${t}' already registered. Registering again will override the previous registration.`
|
|
732
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
734
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
733
735
|
clock: i,
|
|
734
736
|
fn: ({ name: e, predicate: t }) => Object.freeze({
|
|
735
737
|
name: e,
|
|
@@ -742,7 +744,7 @@ var je = j("predicate"), Me = I(({ client: e }) => {
|
|
|
742
744
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
743
745
|
}
|
|
744
746
|
function s(t) {
|
|
745
|
-
let n =
|
|
747
|
+
let n = F(() => void 0, { skipVoid: !1 }), r = k({
|
|
746
748
|
source: {
|
|
747
749
|
predicate: o(t),
|
|
748
750
|
snapshot: e.stateSnapshotStore
|
|
@@ -754,13 +756,13 @@ var je = j("predicate"), Me = I(({ client: e }) => {
|
|
|
754
756
|
});
|
|
755
757
|
}
|
|
756
758
|
});
|
|
757
|
-
return
|
|
759
|
+
return I({
|
|
758
760
|
source: {
|
|
759
761
|
responses: e.responses.listStore,
|
|
760
762
|
fields: e.fields.listStore
|
|
761
763
|
},
|
|
762
764
|
target: r
|
|
763
|
-
}),
|
|
765
|
+
}), I({
|
|
764
766
|
clock: r.doneData,
|
|
765
767
|
filter: (e) => e !== void 0,
|
|
766
768
|
target: n
|
|
@@ -773,27 +775,27 @@ var je = j("predicate"), Me = I(({ client: e }) => {
|
|
|
773
775
|
getEvokablePredicate: s
|
|
774
776
|
};
|
|
775
777
|
});
|
|
776
|
-
function
|
|
777
|
-
return
|
|
778
|
+
function Ie(e) {
|
|
779
|
+
return R(Fe, e);
|
|
778
780
|
}
|
|
779
|
-
var
|
|
781
|
+
var Le = (e, t, n) => {
|
|
780
782
|
n.register({
|
|
781
783
|
name: e,
|
|
782
784
|
predicate: t
|
|
783
785
|
});
|
|
784
|
-
},
|
|
785
|
-
let t =
|
|
786
|
+
}, J = M("feature"), Re = L(({ client: e }) => {
|
|
787
|
+
let t = J.store({}), n = J.store([]), i = j(t, { register(e, t) {
|
|
786
788
|
return {
|
|
787
789
|
...e,
|
|
788
790
|
[t.id]: t.feature
|
|
789
791
|
};
|
|
790
|
-
} }), a =
|
|
791
|
-
|
|
792
|
+
} }), a = P();
|
|
793
|
+
I({
|
|
792
794
|
clock: a,
|
|
793
795
|
source: t,
|
|
794
796
|
filter: (e, { id: t }) => e[t] !== void 0,
|
|
795
797
|
fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
|
|
796
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
798
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
797
799
|
clock: a,
|
|
798
800
|
fn: ({ id: e, feature: t }) => Object.freeze({
|
|
799
801
|
id: e,
|
|
@@ -807,19 +809,19 @@ var Pe = (e, t, n) => {
|
|
|
807
809
|
}),
|
|
808
810
|
target: i.register
|
|
809
811
|
});
|
|
810
|
-
let o =
|
|
811
|
-
let r =
|
|
812
|
+
let o = N(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
813
|
+
let r = O(`feature:${e}:${t}`, "global"), i = (n === "session" ? D : E).get(r).boolean();
|
|
812
814
|
return i === null ? null : {
|
|
813
815
|
id: e,
|
|
814
816
|
key: t,
|
|
815
817
|
bucket: i,
|
|
816
818
|
storage: n
|
|
817
819
|
};
|
|
818
|
-
}), s =
|
|
820
|
+
}), s = N((e) => {
|
|
819
821
|
if (!e) return null;
|
|
820
|
-
let t =
|
|
821
|
-
(e.storage === "session" ?
|
|
822
|
-
}), c = /* @__PURE__ */ new Map(), l =
|
|
822
|
+
let t = O(`feature:${e.id}:${e.key}`, "global");
|
|
823
|
+
(e.storage === "session" ? D : E).set(t, e.bucket);
|
|
824
|
+
}), c = /* @__PURE__ */ new Map(), l = k({
|
|
823
825
|
source: {
|
|
824
826
|
allFeaturesStore: t,
|
|
825
827
|
resolvedFeaturesStore: n
|
|
@@ -850,7 +852,7 @@ var Pe = (e, t, n) => {
|
|
|
850
852
|
};
|
|
851
853
|
}
|
|
852
854
|
});
|
|
853
|
-
|
|
855
|
+
I({
|
|
854
856
|
clock: i.register,
|
|
855
857
|
fn: (e) => {
|
|
856
858
|
let { id: t, feature: n } = e;
|
|
@@ -861,7 +863,7 @@ var Pe = (e, t, n) => {
|
|
|
861
863
|
};
|
|
862
864
|
},
|
|
863
865
|
target: o
|
|
864
|
-
}),
|
|
866
|
+
}), I({
|
|
865
867
|
source: t,
|
|
866
868
|
clock: l.doneData,
|
|
867
869
|
fn: (e, t) => {
|
|
@@ -875,7 +877,7 @@ var Pe = (e, t, n) => {
|
|
|
875
877
|
},
|
|
876
878
|
target: s
|
|
877
879
|
});
|
|
878
|
-
let u =
|
|
880
|
+
let u = A({
|
|
879
881
|
allFeaturesStore: t,
|
|
880
882
|
resolvedFeaturesStore: n
|
|
881
883
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -897,7 +899,7 @@ var Pe = (e, t, n) => {
|
|
|
897
899
|
isResolved: !1
|
|
898
900
|
};
|
|
899
901
|
}));
|
|
900
|
-
|
|
902
|
+
I({
|
|
901
903
|
clock: l.doneData,
|
|
902
904
|
source: { resolvedFeatures: n },
|
|
903
905
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
@@ -906,7 +908,7 @@ var Pe = (e, t, n) => {
|
|
|
906
908
|
type: "feature_decide",
|
|
907
909
|
feature: e
|
|
908
910
|
}))
|
|
909
|
-
}),
|
|
911
|
+
}), I({
|
|
910
912
|
clock: [o.doneData, l.doneData],
|
|
911
913
|
source: n,
|
|
912
914
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
@@ -919,17 +921,17 @@ var Pe = (e, t, n) => {
|
|
|
919
921
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
920
922
|
}
|
|
921
923
|
function p(e) {
|
|
922
|
-
let t =
|
|
924
|
+
let t = F(async () => void 0, { skipVoid: !1 }), r = k({
|
|
923
925
|
source: d(e),
|
|
924
926
|
effect: async (e) => {
|
|
925
927
|
if (e) return async () => (await e.getBucket()).bucket;
|
|
926
928
|
}
|
|
927
929
|
});
|
|
928
|
-
return
|
|
930
|
+
return I({
|
|
929
931
|
source: n,
|
|
930
932
|
filter: (t) => t.some((t) => t.id === e),
|
|
931
933
|
target: r
|
|
932
|
-
}),
|
|
934
|
+
}), I({
|
|
933
935
|
clock: r.doneData,
|
|
934
936
|
filter: (e) => e !== void 0,
|
|
935
937
|
target: t
|
|
@@ -943,26 +945,26 @@ var Pe = (e, t, n) => {
|
|
|
943
945
|
getEvokableFeature: p
|
|
944
946
|
};
|
|
945
947
|
});
|
|
946
|
-
function
|
|
947
|
-
return
|
|
948
|
+
function ze(e) {
|
|
949
|
+
return R(Re, e);
|
|
948
950
|
}
|
|
949
|
-
var
|
|
951
|
+
var Be = (e, t, n) => {
|
|
950
952
|
n.register({
|
|
951
953
|
id: e,
|
|
952
954
|
feature: t
|
|
953
955
|
});
|
|
954
|
-
},
|
|
955
|
-
function
|
|
956
|
+
}, Y = M("history");
|
|
957
|
+
function Ve(e, t) {
|
|
956
958
|
return {
|
|
957
|
-
id:
|
|
959
|
+
id: re(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
958
960
|
node: t,
|
|
959
961
|
at: Date.now(),
|
|
960
962
|
experienceId: e
|
|
961
963
|
};
|
|
962
964
|
}
|
|
963
|
-
var
|
|
964
|
-
let e =
|
|
965
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
965
|
+
var He = L(() => {
|
|
966
|
+
let e = Y.store({ entries: [] }), t = Y.event(), n = Y.event(), r = Y.event(), i = Y.event();
|
|
967
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, Ve(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), Ve(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
966
968
|
function a(e, t) {
|
|
967
969
|
let n = {
|
|
968
970
|
lastStepIndex: -1,
|
|
@@ -970,7 +972,7 @@ var ze = I(() => {
|
|
|
970
972
|
};
|
|
971
973
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
972
974
|
let i = e[r], a = i?.node;
|
|
973
|
-
if (!(!a || !
|
|
975
|
+
if (!(!a || !S(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
974
976
|
else {
|
|
975
977
|
n.secondLastStepIndex = r;
|
|
976
978
|
break;
|
|
@@ -992,20 +994,20 @@ var ze = I(() => {
|
|
|
992
994
|
entriesStore: e.map((e) => e.entries)
|
|
993
995
|
};
|
|
994
996
|
});
|
|
995
|
-
function
|
|
996
|
-
return
|
|
997
|
+
function Ue() {
|
|
998
|
+
return R(He);
|
|
997
999
|
}
|
|
998
1000
|
//#endregion
|
|
999
1001
|
//#region src/utils/events.ts
|
|
1000
|
-
var
|
|
1001
|
-
let t =
|
|
1002
|
+
var We = 0, Ge = (e) => {
|
|
1003
|
+
let t = F([]);
|
|
1002
1004
|
return t.on(e, (e, t) => [...e, {
|
|
1003
|
-
id:
|
|
1005
|
+
id: We++,
|
|
1004
1006
|
at: /* @__PURE__ */ new Date(),
|
|
1005
1007
|
payload: t
|
|
1006
1008
|
}]), t;
|
|
1007
|
-
},
|
|
1008
|
-
let e =
|
|
1009
|
+
}, Ke = M("field"), qe = L(() => {
|
|
1010
|
+
let e = Ke.store({}), t = j(e, {
|
|
1009
1011
|
register(e, t) {
|
|
1010
1012
|
return {
|
|
1011
1013
|
...e,
|
|
@@ -1053,13 +1055,13 @@ var Ve = 0, He = (e) => {
|
|
|
1053
1055
|
getByName: c
|
|
1054
1056
|
};
|
|
1055
1057
|
});
|
|
1056
|
-
function
|
|
1057
|
-
return
|
|
1058
|
+
function Je() {
|
|
1059
|
+
return R(qe);
|
|
1058
1060
|
}
|
|
1059
1061
|
//#endregion
|
|
1060
1062
|
//#region src/entities/step/step.ts
|
|
1061
|
-
var
|
|
1062
|
-
let e =
|
|
1063
|
+
var Ye = M("step"), Xe = L(() => {
|
|
1064
|
+
let e = Ye.store({}), t = j(e, { register(e, t) {
|
|
1063
1065
|
return {
|
|
1064
1066
|
...e,
|
|
1065
1067
|
[t.step.id]: t.step
|
|
@@ -1083,16 +1085,16 @@ var Ke = j("step"), qe = I(() => {
|
|
|
1083
1085
|
indexStore: e
|
|
1084
1086
|
};
|
|
1085
1087
|
});
|
|
1086
|
-
function
|
|
1087
|
-
return
|
|
1088
|
+
function Ze() {
|
|
1089
|
+
return R(Xe);
|
|
1088
1090
|
}
|
|
1089
|
-
function
|
|
1091
|
+
function Qe(e, t) {
|
|
1090
1092
|
t.register(e);
|
|
1091
1093
|
}
|
|
1092
1094
|
//#endregion
|
|
1093
1095
|
//#region src/entities/content/content.ts
|
|
1094
|
-
var
|
|
1095
|
-
let e =
|
|
1096
|
+
var $e = M("content"), et = L(() => {
|
|
1097
|
+
let e = $e.store({}), t = j(e, { register(e, t) {
|
|
1096
1098
|
return {
|
|
1097
1099
|
...e,
|
|
1098
1100
|
[t.content.id]: t.content
|
|
@@ -1112,16 +1114,16 @@ var Xe = j("content"), Ze = I(() => {
|
|
|
1112
1114
|
indexStore: e
|
|
1113
1115
|
};
|
|
1114
1116
|
});
|
|
1115
|
-
function
|
|
1116
|
-
return
|
|
1117
|
+
function tt() {
|
|
1118
|
+
return R(et);
|
|
1117
1119
|
}
|
|
1118
|
-
function
|
|
1120
|
+
function nt(e, t) {
|
|
1119
1121
|
t.register(e);
|
|
1120
1122
|
}
|
|
1121
1123
|
//#endregion
|
|
1122
1124
|
//#region src/entities/action/action.ts
|
|
1123
|
-
var
|
|
1124
|
-
let t =
|
|
1125
|
+
var rt = M("action"), it = L(({ client: e }) => {
|
|
1126
|
+
let t = rt.store({}), n = j(t, { register(e, t) {
|
|
1125
1127
|
return {
|
|
1126
1128
|
...e,
|
|
1127
1129
|
[t.key]: {
|
|
@@ -1129,13 +1131,13 @@ var et = j("action"), tt = I(({ client: e }) => {
|
|
|
1129
1131
|
action: t.action
|
|
1130
1132
|
}
|
|
1131
1133
|
};
|
|
1132
|
-
} }), i =
|
|
1133
|
-
|
|
1134
|
+
} }), i = P();
|
|
1135
|
+
I({
|
|
1134
1136
|
clock: i,
|
|
1135
1137
|
source: t,
|
|
1136
1138
|
filter: (e, { key: t }) => e[t] !== void 0,
|
|
1137
1139
|
fn: (e, { key: t }) => `Action '${t}' already registered. Registering again will override the previous registration.`
|
|
1138
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
1140
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
1139
1141
|
clock: i,
|
|
1140
1142
|
fn: ({ key: e, action: t }) => Object.freeze({
|
|
1141
1143
|
key: e,
|
|
@@ -1148,7 +1150,7 @@ var et = j("action"), tt = I(({ client: e }) => {
|
|
|
1148
1150
|
return t.map((t) => t[e]?.action, { skipVoid: !1 });
|
|
1149
1151
|
}
|
|
1150
1152
|
function s(t, n) {
|
|
1151
|
-
let r =
|
|
1153
|
+
let r = F(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, a = k({
|
|
1152
1154
|
source: {
|
|
1153
1155
|
action: o(t),
|
|
1154
1156
|
snapshot: e.stateSnapshotStore
|
|
@@ -1160,13 +1162,13 @@ var et = j("action"), tt = I(({ client: e }) => {
|
|
|
1160
1162
|
}, i);
|
|
1161
1163
|
}
|
|
1162
1164
|
});
|
|
1163
|
-
return
|
|
1165
|
+
return I({
|
|
1164
1166
|
source: {
|
|
1165
1167
|
responses: e.responses.listStore,
|
|
1166
1168
|
fields: e.fields.listStore
|
|
1167
1169
|
},
|
|
1168
1170
|
target: a
|
|
1169
|
-
}),
|
|
1171
|
+
}), I({
|
|
1170
1172
|
clock: a.doneData,
|
|
1171
1173
|
filter: (e) => e !== void 0,
|
|
1172
1174
|
target: r
|
|
@@ -1179,10 +1181,10 @@ var et = j("action"), tt = I(({ client: e }) => {
|
|
|
1179
1181
|
getEvokableAction: s
|
|
1180
1182
|
};
|
|
1181
1183
|
});
|
|
1182
|
-
function
|
|
1183
|
-
return
|
|
1184
|
+
function at(e) {
|
|
1185
|
+
return R(it, e);
|
|
1184
1186
|
}
|
|
1185
|
-
var
|
|
1187
|
+
var ot = (e, t, n) => {
|
|
1186
1188
|
n.register({
|
|
1187
1189
|
key: e,
|
|
1188
1190
|
action: t
|
|
@@ -1190,7 +1192,7 @@ var rt = (e, t, n) => {
|
|
|
1190
1192
|
};
|
|
1191
1193
|
//#endregion
|
|
1192
1194
|
//#region src/entities/response/response-validation.ts
|
|
1193
|
-
function
|
|
1195
|
+
function X(e, t, n, r) {
|
|
1194
1196
|
return {
|
|
1195
1197
|
fieldKey: e.key,
|
|
1196
1198
|
userMessage: n,
|
|
@@ -1198,62 +1200,62 @@ function Z(e, t, n, r) {
|
|
|
1198
1200
|
value: t
|
|
1199
1201
|
};
|
|
1200
1202
|
}
|
|
1201
|
-
function
|
|
1203
|
+
function Z(e) {
|
|
1202
1204
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1203
1205
|
}
|
|
1204
|
-
function
|
|
1206
|
+
function st(e) {
|
|
1205
1207
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1206
1208
|
}
|
|
1207
|
-
function
|
|
1209
|
+
function ct(e) {
|
|
1208
1210
|
try {
|
|
1209
1211
|
return JSON.stringify(e), !0;
|
|
1210
1212
|
} catch {
|
|
1211
1213
|
return !1;
|
|
1212
1214
|
}
|
|
1213
1215
|
}
|
|
1214
|
-
function
|
|
1216
|
+
function lt(e, t) {
|
|
1215
1217
|
return t.find((t) => t.key === e) ?? null;
|
|
1216
1218
|
}
|
|
1217
|
-
function
|
|
1219
|
+
function ut(e, t) {
|
|
1218
1220
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1219
1221
|
}
|
|
1220
|
-
function
|
|
1221
|
-
if (e.type !== "object" ||
|
|
1222
|
+
function dt(e, t) {
|
|
1223
|
+
if (e.type !== "object" || Z(t)) return null;
|
|
1222
1224
|
if (e.multiple) {
|
|
1223
|
-
if (!Array.isArray(t)) return
|
|
1225
|
+
if (!Array.isArray(t)) return X(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1224
1226
|
for (let n of t) {
|
|
1225
|
-
if (typeof n != "object" || !n) return
|
|
1226
|
-
if (!
|
|
1227
|
+
if (typeof n != "object" || !n) return X(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
1228
|
+
if (!ct(n)) return X(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1227
1229
|
}
|
|
1228
1230
|
return null;
|
|
1229
1231
|
}
|
|
1230
|
-
return Array.isArray(t) ?
|
|
1232
|
+
return Array.isArray(t) ? X(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? X(e, t, "This field expects an object value", "Field expects an object value.") : ct(t) ? null : X(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1231
1233
|
}
|
|
1232
|
-
function
|
|
1233
|
-
if (
|
|
1234
|
+
function ft(e, t) {
|
|
1235
|
+
if (Z(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1234
1236
|
let n = Array.isArray(t) ? t : [t];
|
|
1235
1237
|
if (e.type === "object") {
|
|
1236
1238
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1237
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
1239
|
+
return n.every((e) => r.has(JSON.stringify(e))) ? null : X(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
1238
1240
|
}
|
|
1239
1241
|
let r = e.options.map((e) => e.value);
|
|
1240
|
-
return n.every((e) => !
|
|
1242
|
+
return n.every((e) => !st(e) || e === null ? !1 : r.includes(e)) ? null : X(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
1241
1243
|
}
|
|
1242
|
-
async function
|
|
1243
|
-
if (n.validation && !e(n.validation) && !
|
|
1244
|
+
async function pt(t, n, r, i) {
|
|
1245
|
+
if (n.validation && !e(n.validation) && !Z(r)) {
|
|
1244
1246
|
let e = i ? {
|
|
1245
1247
|
$input: r,
|
|
1246
1248
|
responses: i
|
|
1247
1249
|
} : { $input: r }, a = await t(n.validation, e);
|
|
1248
|
-
if (typeof a == "string") return
|
|
1249
|
-
if (a === !1) return
|
|
1250
|
+
if (typeof a == "string") return X(n, r, a, `Field validation resulted in an error: ${a}.`);
|
|
1251
|
+
if (a === !1) return X(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
1250
1252
|
}
|
|
1251
|
-
return n.required &&
|
|
1253
|
+
return n.required && Z(r) ? X(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? X(n, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
1252
1254
|
}
|
|
1253
1255
|
//#endregion
|
|
1254
1256
|
//#region src/entities/response/response.ts
|
|
1255
|
-
var
|
|
1256
|
-
let t =
|
|
1257
|
+
var mt = M("response"), ht = L(({ client: e }) => {
|
|
1258
|
+
let t = mt.store({}), r = P(), i = P(), a = j(t, {
|
|
1257
1259
|
register(e, t) {
|
|
1258
1260
|
return {
|
|
1259
1261
|
...e,
|
|
@@ -1282,7 +1284,7 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1282
1284
|
});
|
|
1283
1285
|
} else a.registerBatch(e);
|
|
1284
1286
|
}
|
|
1285
|
-
let s = (t, r) => n(e, t, r), c =
|
|
1287
|
+
let s = (t, r) => n(e, t, r), c = k({
|
|
1286
1288
|
source: {
|
|
1287
1289
|
allFields: e.fields.listStore,
|
|
1288
1290
|
existingResponses: t
|
|
@@ -1292,7 +1294,7 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1292
1294
|
...t,
|
|
1293
1295
|
...n
|
|
1294
1296
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1295
|
-
let o =
|
|
1297
|
+
let o = lt(t, e);
|
|
1296
1298
|
if (!o) {
|
|
1297
1299
|
r.push({
|
|
1298
1300
|
fieldKey: t,
|
|
@@ -1302,17 +1304,17 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1302
1304
|
});
|
|
1303
1305
|
return;
|
|
1304
1306
|
}
|
|
1305
|
-
let c =
|
|
1307
|
+
let c = ut(o, n), l = await pt(s, o, c, a);
|
|
1306
1308
|
if (l) {
|
|
1307
1309
|
r.push(l);
|
|
1308
1310
|
return;
|
|
1309
1311
|
}
|
|
1310
|
-
let u =
|
|
1312
|
+
let u = dt(o, c);
|
|
1311
1313
|
if (u) {
|
|
1312
1314
|
r.push(u);
|
|
1313
1315
|
return;
|
|
1314
1316
|
}
|
|
1315
|
-
let d =
|
|
1317
|
+
let d = ft(o, c);
|
|
1316
1318
|
if (d) {
|
|
1317
1319
|
r.push(d);
|
|
1318
1320
|
return;
|
|
@@ -1340,7 +1342,7 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1340
1342
|
async function l(e) {
|
|
1341
1343
|
return c(e);
|
|
1342
1344
|
}
|
|
1343
|
-
let u =
|
|
1345
|
+
let u = k({
|
|
1344
1346
|
source: t,
|
|
1345
1347
|
effect: async (e, t) => {
|
|
1346
1348
|
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
@@ -1355,7 +1357,7 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1355
1357
|
value: t
|
|
1356
1358
|
})));
|
|
1357
1359
|
function m(e) {
|
|
1358
|
-
return
|
|
1360
|
+
return A({
|
|
1359
1361
|
f: e,
|
|
1360
1362
|
s: t
|
|
1361
1363
|
}, ({ f: e, s: t }) => {
|
|
@@ -1372,10 +1374,10 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1372
1374
|
function _(t) {
|
|
1373
1375
|
return m(e.fields.getByName(t));
|
|
1374
1376
|
}
|
|
1375
|
-
return
|
|
1377
|
+
return I({
|
|
1376
1378
|
clock: r,
|
|
1377
1379
|
target: a.clearAll
|
|
1378
|
-
}),
|
|
1380
|
+
}), I({
|
|
1379
1381
|
clock: i,
|
|
1380
1382
|
target: a.clear
|
|
1381
1383
|
}), {
|
|
@@ -1391,13 +1393,13 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1391
1393
|
getByFieldName: _
|
|
1392
1394
|
};
|
|
1393
1395
|
});
|
|
1394
|
-
function
|
|
1395
|
-
return
|
|
1396
|
+
function gt(e) {
|
|
1397
|
+
return R(ht, e);
|
|
1396
1398
|
}
|
|
1397
1399
|
//#endregion
|
|
1398
1400
|
//#region src/entities/condition/condition.ts
|
|
1399
|
-
var
|
|
1400
|
-
let e =
|
|
1401
|
+
var _t = M("condition"), vt = L(() => {
|
|
1402
|
+
let e = _t.store({}), t = j(e, { register(e, t) {
|
|
1401
1403
|
return {
|
|
1402
1404
|
...e,
|
|
1403
1405
|
[t.condition.id]: t.condition
|
|
@@ -1421,13 +1423,13 @@ var mt = j("condition"), ht = I(() => {
|
|
|
1421
1423
|
indexStore: e
|
|
1422
1424
|
};
|
|
1423
1425
|
});
|
|
1424
|
-
function
|
|
1425
|
-
return
|
|
1426
|
+
function yt() {
|
|
1427
|
+
return R(vt);
|
|
1426
1428
|
}
|
|
1427
1429
|
//#endregion
|
|
1428
1430
|
//#region src/utils/api-url.ts
|
|
1429
|
-
function
|
|
1430
|
-
if (
|
|
1431
|
+
function bt() {
|
|
1432
|
+
if (c()) {
|
|
1431
1433
|
let e = [
|
|
1432
1434
|
document.currentScript,
|
|
1433
1435
|
document.getElementById("picked_script"),
|
|
@@ -1441,31 +1443,31 @@ function _t() {
|
|
|
1441
1443
|
}
|
|
1442
1444
|
//#endregion
|
|
1443
1445
|
//#region src/utils/search-params.ts
|
|
1444
|
-
function
|
|
1445
|
-
if (!
|
|
1446
|
+
function xt() {
|
|
1447
|
+
if (!s()) return {};
|
|
1446
1448
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1447
1449
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
1448
1450
|
for (let r of n) {
|
|
1449
1451
|
let n = r.replace("picked-", "");
|
|
1450
1452
|
t[n] = e.getAll(r);
|
|
1451
1453
|
}
|
|
1452
|
-
let r =
|
|
1453
|
-
if (n.size > 0)
|
|
1454
|
+
let r = O("s");
|
|
1455
|
+
if (n.size > 0) D.set(r, t);
|
|
1454
1456
|
else {
|
|
1455
|
-
let e =
|
|
1457
|
+
let e = D.get(r);
|
|
1456
1458
|
if (e) return e.json() || {};
|
|
1457
1459
|
}
|
|
1458
1460
|
return t;
|
|
1459
1461
|
}
|
|
1460
1462
|
//#endregion
|
|
1461
1463
|
//#region src/entities/session/session.ts
|
|
1462
|
-
var
|
|
1463
|
-
function
|
|
1464
|
-
return
|
|
1464
|
+
var St = O("session", "global");
|
|
1465
|
+
function Ct() {
|
|
1466
|
+
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)}`;
|
|
1465
1467
|
}
|
|
1466
|
-
function
|
|
1467
|
-
if (!
|
|
1468
|
-
let e =
|
|
1468
|
+
function wt() {
|
|
1469
|
+
if (!m()) return null;
|
|
1470
|
+
let e = E.get(St);
|
|
1469
1471
|
if (!e.isSet()) return null;
|
|
1470
1472
|
try {
|
|
1471
1473
|
return e.json();
|
|
@@ -1473,10 +1475,10 @@ function xt() {
|
|
|
1473
1475
|
return null;
|
|
1474
1476
|
}
|
|
1475
1477
|
}
|
|
1476
|
-
var
|
|
1477
|
-
let e =
|
|
1478
|
+
var Tt = L(() => {
|
|
1479
|
+
let e = wt(), t = { id: e?.id ?? Ct() };
|
|
1478
1480
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1479
|
-
let n =
|
|
1481
|
+
let n = F(t), r = j(n, {
|
|
1480
1482
|
setIsUser: (e, t) => ({
|
|
1481
1483
|
...e,
|
|
1482
1484
|
isUser: t
|
|
@@ -1497,13 +1499,13 @@ var St = I(() => {
|
|
|
1497
1499
|
return e.isUser !== void 0 && (i.isUser = e.isUser), Object.keys(r).length > 0 && (i.identifiers = r), i;
|
|
1498
1500
|
}
|
|
1499
1501
|
});
|
|
1500
|
-
return
|
|
1502
|
+
return I({
|
|
1501
1503
|
source: n,
|
|
1502
|
-
target:
|
|
1504
|
+
target: k({
|
|
1503
1505
|
source: n,
|
|
1504
1506
|
effect: (e) => {
|
|
1505
|
-
if (
|
|
1506
|
-
|
|
1507
|
+
if (m()) try {
|
|
1508
|
+
E.get(St).set(e);
|
|
1507
1509
|
} catch {}
|
|
1508
1510
|
}
|
|
1509
1511
|
})
|
|
@@ -1514,39 +1516,39 @@ var St = I(() => {
|
|
|
1514
1516
|
removeIdentifier: r.removeIdentifier
|
|
1515
1517
|
};
|
|
1516
1518
|
});
|
|
1517
|
-
function
|
|
1518
|
-
return
|
|
1519
|
+
function Et() {
|
|
1520
|
+
return R(Tt, void 0);
|
|
1519
1521
|
}
|
|
1520
1522
|
//#endregion
|
|
1521
1523
|
//#region src/utils/picked-config.ts
|
|
1522
|
-
function
|
|
1523
|
-
if (
|
|
1524
|
+
function Dt() {
|
|
1525
|
+
if (s()) return globalThis.window.pickedConfig;
|
|
1524
1526
|
}
|
|
1525
|
-
function
|
|
1526
|
-
if (
|
|
1527
|
+
function Ot() {
|
|
1528
|
+
if (s()) return Dt()?.projectId;
|
|
1527
1529
|
}
|
|
1528
|
-
function
|
|
1529
|
-
if (!
|
|
1530
|
+
function kt() {
|
|
1531
|
+
if (!c()) return;
|
|
1530
1532
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1531
1533
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1532
1534
|
}
|
|
1533
|
-
function
|
|
1535
|
+
function At(e) {
|
|
1534
1536
|
if (e.projectId) return e.projectId;
|
|
1535
|
-
let t =
|
|
1537
|
+
let t = Ot();
|
|
1536
1538
|
if (t) return t;
|
|
1537
|
-
let n =
|
|
1539
|
+
let n = kt();
|
|
1538
1540
|
if (n) return n;
|
|
1539
1541
|
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.");
|
|
1540
1542
|
}
|
|
1541
1543
|
//#endregion
|
|
1542
1544
|
//#region src/utils/render-string.ts
|
|
1543
|
-
function
|
|
1545
|
+
function Q(e) {
|
|
1544
1546
|
return e == null || e === "" || Number.isNaN(e);
|
|
1545
1547
|
}
|
|
1546
|
-
var
|
|
1547
|
-
default: (e, t) =>
|
|
1548
|
-
append: (e, t) => t &&
|
|
1549
|
-
prepend: (e, t) => t &&
|
|
1548
|
+
var jt = {
|
|
1549
|
+
default: (e, t) => Q(e) ? String(t ?? "") : String(e),
|
|
1550
|
+
append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
|
|
1551
|
+
prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
|
|
1550
1552
|
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
1551
1553
|
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
1552
1554
|
capitalize: (e) => typeof e == "string" ? e.charAt(0).toUpperCase() + e.slice(1) : e,
|
|
@@ -1564,24 +1566,24 @@ var Ot = {
|
|
|
1564
1566
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1565
1567
|
}
|
|
1566
1568
|
};
|
|
1567
|
-
function
|
|
1569
|
+
function Mt(e) {
|
|
1568
1570
|
return typeof e == "object" && !!e;
|
|
1569
1571
|
}
|
|
1570
|
-
function
|
|
1572
|
+
function Nt(e, t) {
|
|
1571
1573
|
let n = t;
|
|
1572
|
-
for (let t of e.split(".")) if (
|
|
1574
|
+
for (let t of e.split(".")) if (Mt(n) && t in n) n = n[t];
|
|
1573
1575
|
else return;
|
|
1574
1576
|
return typeof n == "function" ? n() : n;
|
|
1575
1577
|
}
|
|
1576
|
-
function
|
|
1577
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1578
|
+
function Pt(e, t) {
|
|
1579
|
+
let n = e.split("|").map((e) => e.trim()), r = Nt(n.shift() ?? "", t);
|
|
1578
1580
|
for (let e of n) {
|
|
1579
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1581
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = jt[i];
|
|
1580
1582
|
o && (r = o(r, a));
|
|
1581
1583
|
}
|
|
1582
|
-
return
|
|
1584
|
+
return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1583
1585
|
}
|
|
1584
|
-
function
|
|
1586
|
+
function Ft(e, t) {
|
|
1585
1587
|
let n = "", r = 0;
|
|
1586
1588
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1587
1589
|
r += 2;
|
|
@@ -1593,80 +1595,84 @@ function Mt(e, t) {
|
|
|
1593
1595
|
}
|
|
1594
1596
|
i += e[r++];
|
|
1595
1597
|
}
|
|
1596
|
-
n +=
|
|
1598
|
+
n += Pt(i.trim(), t);
|
|
1597
1599
|
} else n += e[r++];
|
|
1598
1600
|
return n;
|
|
1599
1601
|
}
|
|
1600
1602
|
//#endregion
|
|
1601
1603
|
//#region src/picked.ts
|
|
1602
|
-
var
|
|
1604
|
+
var $ = class {
|
|
1603
1605
|
static logger = r;
|
|
1604
1606
|
options;
|
|
1605
1607
|
dataSource = null;
|
|
1606
1608
|
contentLoader;
|
|
1607
1609
|
plugins = {};
|
|
1608
|
-
eventBus =
|
|
1610
|
+
eventBus = P();
|
|
1609
1611
|
events;
|
|
1610
1612
|
projectId;
|
|
1611
1613
|
apiUrl;
|
|
1612
1614
|
dashboardUrl;
|
|
1613
1615
|
documentationSiteUrl;
|
|
1614
|
-
session =
|
|
1615
|
-
searchParams =
|
|
1616
|
-
history =
|
|
1617
|
-
components =
|
|
1618
|
-
experienceInstances =
|
|
1619
|
-
experiences =
|
|
1620
|
-
frameworks =
|
|
1621
|
-
predicates =
|
|
1622
|
-
features =
|
|
1623
|
-
conditions =
|
|
1624
|
-
fields =
|
|
1625
|
-
responses =
|
|
1626
|
-
steps =
|
|
1627
|
-
contents =
|
|
1628
|
-
actions =
|
|
1629
|
-
|
|
1630
|
-
|
|
1616
|
+
session = Et();
|
|
1617
|
+
searchParams = xt();
|
|
1618
|
+
history = Ue();
|
|
1619
|
+
components = he({ client: this });
|
|
1620
|
+
experienceInstances = C({ client: this });
|
|
1621
|
+
experiences = se({ client: this });
|
|
1622
|
+
frameworks = ve({ client: this });
|
|
1623
|
+
predicates = Ie({ client: this });
|
|
1624
|
+
features = ze({ client: this });
|
|
1625
|
+
conditions = yt();
|
|
1626
|
+
fields = Je();
|
|
1627
|
+
responses = gt({ client: this });
|
|
1628
|
+
steps = Ze();
|
|
1629
|
+
contents = tt();
|
|
1630
|
+
actions = at({ client: this });
|
|
1631
|
+
conditionResults = w();
|
|
1632
|
+
stateSnapshotStore = xe({ client: this });
|
|
1633
|
+
evaluateRuleLogicFx = Oe({ client: this });
|
|
1631
1634
|
start;
|
|
1632
1635
|
readyStore;
|
|
1633
1636
|
preconditionPassedStore;
|
|
1634
1637
|
conditionPassedStore;
|
|
1635
1638
|
lifecycleStageStore;
|
|
1636
|
-
lifecycle =
|
|
1637
|
-
renderStringFx =
|
|
1639
|
+
lifecycle = Ne({ client: this });
|
|
1640
|
+
renderStringFx = k({
|
|
1638
1641
|
source: this.responses.listStore,
|
|
1639
1642
|
effect: (e, { template: t, context: n }) => {
|
|
1640
1643
|
let r = {};
|
|
1641
1644
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1642
|
-
return
|
|
1645
|
+
return Ft(t, {
|
|
1643
1646
|
...n,
|
|
1644
1647
|
responses: r
|
|
1645
1648
|
});
|
|
1646
1649
|
}
|
|
1647
1650
|
});
|
|
1648
1651
|
constructor(e) {
|
|
1649
|
-
this.events =
|
|
1652
|
+
this.events = Ge(this.eventBus), this.projectId = At(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || bt(), 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({
|
|
1650
1653
|
type: "load",
|
|
1651
|
-
version:
|
|
1652
|
-
});
|
|
1654
|
+
version: ne()
|
|
1655
|
+
}), this.maybeStartPreviewBridge();
|
|
1656
|
+
}
|
|
1657
|
+
maybeStartPreviewBridge() {
|
|
1658
|
+
!s() || !h() || this.searchParams["preview-token"]?.[0] && import("../preview-bridge-CGyx7dEx.js").then((e) => e.initPreviewBridge()).catch(() => void 0);
|
|
1653
1659
|
}
|
|
1654
1660
|
registerFramework = (e) => {
|
|
1655
|
-
|
|
1661
|
+
ye(e, this.frameworks);
|
|
1656
1662
|
};
|
|
1657
1663
|
registerComponent = (e, t) => {
|
|
1658
|
-
|
|
1664
|
+
B(e, t, this.components);
|
|
1659
1665
|
};
|
|
1660
1666
|
registerPlugin = (e) => {
|
|
1661
|
-
|
|
1667
|
+
ue(this, e, this.plugins);
|
|
1662
1668
|
let t = this.plugins[e.name];
|
|
1663
1669
|
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1664
1670
|
};
|
|
1665
1671
|
registerFeature = (e, t) => {
|
|
1666
|
-
|
|
1672
|
+
Be(e, t, this.features);
|
|
1667
1673
|
};
|
|
1668
1674
|
registerPredicate = (e, t) => {
|
|
1669
|
-
|
|
1675
|
+
Le(e, t, this.predicates);
|
|
1670
1676
|
};
|
|
1671
1677
|
registerCondition = (e) => {
|
|
1672
1678
|
this.conditions.register(e);
|
|
@@ -1675,16 +1681,16 @@ var Nt = class {
|
|
|
1675
1681
|
this.fields.register(e);
|
|
1676
1682
|
};
|
|
1677
1683
|
registerStep = (e) => {
|
|
1678
|
-
|
|
1684
|
+
Qe(e, this.steps);
|
|
1679
1685
|
};
|
|
1680
1686
|
registerContent = (e) => {
|
|
1681
|
-
|
|
1687
|
+
nt(e, this.contents);
|
|
1682
1688
|
};
|
|
1683
1689
|
registerAction = (e, t) => {
|
|
1684
|
-
|
|
1690
|
+
ot(e, t, this.actions);
|
|
1685
1691
|
};
|
|
1686
1692
|
registerExperience = (e) => {
|
|
1687
|
-
e.component &&
|
|
1693
|
+
e.component && B(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1688
1694
|
};
|
|
1689
1695
|
launchExperienceById = async (e, t) => {
|
|
1690
1696
|
this.experiences.launch({
|
|
@@ -1769,20 +1775,20 @@ var Nt = class {
|
|
|
1769
1775
|
};
|
|
1770
1776
|
//#endregion
|
|
1771
1777
|
//#region src/entities/component/lazyComponent.ts
|
|
1772
|
-
function
|
|
1778
|
+
function It(e) {
|
|
1773
1779
|
return {
|
|
1774
1780
|
$$type: "lazy-component",
|
|
1775
1781
|
load: e
|
|
1776
1782
|
};
|
|
1777
1783
|
}
|
|
1778
|
-
function
|
|
1784
|
+
function Lt(e) {
|
|
1779
1785
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1780
1786
|
}
|
|
1781
1787
|
//#endregion
|
|
1782
1788
|
//#region src/exports.ts
|
|
1783
|
-
var
|
|
1784
|
-
let t = new
|
|
1785
|
-
return
|
|
1789
|
+
var Rt = (e) => {
|
|
1790
|
+
let t = new $(e);
|
|
1791
|
+
return u(t), t;
|
|
1786
1792
|
};
|
|
1787
1793
|
//#endregion
|
|
1788
|
-
export {
|
|
1794
|
+
export { $ as Picked, Rt as createClient, le as createPluginEffect, O as createStorageKey, n as evaluateRuleLogic, Dt as getPickedConfig, h as isInsideIframe, Lt as isLazyLoader, _ as isPickedRoot, It as lazyComponent, E as localStore, D as sessionStore, T 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 };
|