@picked/client 0.0.1-dev.1774231221701 → 0.0.1-dev.1774912386475
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-BEXzPJHZ.cjs → api-B-wGEgt8.cjs} +1 -1
- package/dist/{api-oudcFuUX.js → api-DwERBrAZ.js} +1 -1
- package/dist/cjs/form/index.js +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/form/index.js +128 -84
- package/dist/esm/index.js +393 -334
- package/dist/esm/plugins/create-experience/index.js +183 -151
- package/dist/esm/plugins/dynamic-experiences/index.js +52 -30
- package/dist/esm/plugins/responses-browser-storage/index.js +47 -20
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-DZiAwXph.js → experience-instance-CwwrKUI8.js} +50 -46
- package/dist/experience-instance-DdFUcVRd.cjs +1 -0
- package/dist/{rules-logic-B7vJrWyO.js → rules-logic-BIkBWZmf.js} +4 -2
- package/dist/rules-logic-DDxCiq4P.cjs +1 -0
- package/dist/types/entities/condition/condition.d.ts +17 -0
- package/dist/types/entities/condition/condition.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +40 -35
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +21 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +13 -2
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/response/response-validation.d.ts +76 -0
- package/dist/types/entities/response/response-validation.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +24 -17
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +36 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- package/dist/types/form/build-responses.d.ts +12 -9
- package/dist/types/form/build-responses.d.ts.map +1 -1
- package/dist/types/form/create-field-evaluator.d.ts +11 -3
- package/dist/types/form/create-field-evaluator.d.ts.map +1 -1
- package/dist/types/form/create-field-validation.d.ts +21 -6
- package/dist/types/form/create-field-validation.d.ts.map +1 -1
- package/dist/types/form/create-form.d.ts +42 -11
- package/dist/types/form/create-form.d.ts.map +1 -1
- package/dist/types/form/create-submit-pipeline.d.ts +21 -9
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
- package/dist/types/form/get-step-fields.d.ts +13 -0
- package/dist/types/form/get-step-fields.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +10 -2
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +68 -32
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +51 -29
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/index.d.ts +2 -2
- package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/serialization.d.ts +1 -0
- package/dist/types/plugins/create-experience/serialization.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +21 -4
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +41 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +3 -0
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -0
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +10 -6
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +74 -2
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts +31 -0
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/package.json +32 -6
- package/dist/experience-instance-Ddk4Jktn.cjs +0 -1
- package/dist/rules-logic-CXr4wXcG.cjs +0 -1
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +0 -3
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { n as e, t } from "../rules-logic-
|
|
1
|
+
import { n as e, t } from "../rules-logic-BIkBWZmf.js";
|
|
2
2
|
import { t as n } from "../object-C82v79xc.js";
|
|
3
3
|
import { t as r } from "../logger-6z_gb4rA.js";
|
|
4
4
|
import { a as i, c as a, d as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "../supports-0XIfd4-R.js";
|
|
5
|
-
import { a as g, c as
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as
|
|
8
|
-
import { t as
|
|
5
|
+
import { a as g, c as _, i as v, l as ee, n as te, o as ne, r as re, s as ie, u as ae } from "../experience-instance-CwwrKUI8.js";
|
|
6
|
+
import { i as y, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
|
|
7
|
+
import { n as oe, r as se } from "../api-DwERBrAZ.js";
|
|
8
|
+
import { t as ce } from "../id-CRqy981z.js";
|
|
9
9
|
import { attach as C, combine as w, createApi as T, createDomain as E, createEffect as D, createEvent as O, createStore as k, sample as A } from "effector";
|
|
10
10
|
import { createFactory as j, invoke as M } from "@withease/factories";
|
|
11
11
|
//#region src/entities/experience/experience.ts
|
|
12
|
-
var N = E("experience"),
|
|
12
|
+
var N = E("experience"), le = j(({ client: e, experience: t }) => {
|
|
13
13
|
let n = N.store(t), r = T(n, { merge(e, t) {
|
|
14
14
|
return {
|
|
15
15
|
...e,
|
|
@@ -19,34 +19,41 @@ var N = E("experience"), se = j(({ client: e, experience: t }) => {
|
|
|
19
19
|
name: e.name,
|
|
20
20
|
decisionLogic: e.condition,
|
|
21
21
|
targetSelectors: e.targets,
|
|
22
|
-
initializeOpenLogic:
|
|
23
|
-
})), a = e.components.listStore
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
initializeOpenLogic: e.initializeOpen
|
|
23
|
+
})), a = w(n, 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 }), o = w(n, e.steps.listStore, e.conditions.listStore, (e, t, n) => {
|
|
24
|
+
let r = e.nodes.filter(v).map((e) => {
|
|
25
|
+
let n = e.stepId;
|
|
26
|
+
return t.find((e) => e.id === n || e.key === n);
|
|
27
|
+
}).filter((e) => e !== void 0), i = e.nodes.filter(re).map((e) => n.find((t) => t.id === g(e))).filter((e) => e !== void 0);
|
|
28
|
+
return {
|
|
29
|
+
steps: r,
|
|
30
|
+
nodes: e.nodes,
|
|
31
|
+
edges: e.edges,
|
|
32
|
+
conditions: i
|
|
33
|
+
};
|
|
34
|
+
}), s = t.actions ?? [];
|
|
29
35
|
return {
|
|
30
36
|
id: t.id,
|
|
37
|
+
key: t.key,
|
|
38
|
+
name: t.name,
|
|
31
39
|
configStore: i,
|
|
32
40
|
treeStore: o,
|
|
33
|
-
fieldsStore: s,
|
|
34
41
|
componentStore: a,
|
|
35
|
-
actions:
|
|
42
|
+
actions: s,
|
|
36
43
|
merge: r.merge
|
|
37
44
|
};
|
|
38
45
|
});
|
|
39
|
-
function
|
|
40
|
-
return M(
|
|
46
|
+
function ue(e) {
|
|
47
|
+
return M(le, e);
|
|
41
48
|
}
|
|
42
|
-
var
|
|
49
|
+
var de = j(({ client: e }) => {
|
|
43
50
|
let t = N.store({}), n = T(t, { register(e, t) {
|
|
44
51
|
return {
|
|
45
52
|
...e,
|
|
46
53
|
[t.id]: t
|
|
47
54
|
};
|
|
48
|
-
} });
|
|
49
|
-
function
|
|
55
|
+
} }), r = t.map((e) => Object.fromEntries(Object.values(e).map((e) => [e.key, e.id])));
|
|
56
|
+
function i(r) {
|
|
50
57
|
let i = t.getState()[r.id];
|
|
51
58
|
if (i) {
|
|
52
59
|
i.merge({
|
|
@@ -55,61 +62,65 @@ var le = j(({ client: e }) => {
|
|
|
55
62
|
});
|
|
56
63
|
return;
|
|
57
64
|
}
|
|
58
|
-
let a =
|
|
65
|
+
let a = ue({
|
|
59
66
|
client: e,
|
|
60
67
|
experience: r
|
|
61
68
|
});
|
|
62
69
|
n.register(a);
|
|
63
70
|
}
|
|
64
|
-
let
|
|
65
|
-
function
|
|
66
|
-
return t
|
|
71
|
+
let a = t.map((e) => Object.values(e));
|
|
72
|
+
function o(e) {
|
|
73
|
+
return w(t, r, (t, n) => t[n[e] ?? ""] ?? t[e], { skipVoid: !1 });
|
|
67
74
|
}
|
|
68
|
-
let
|
|
69
|
-
source:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
let s = C({
|
|
76
|
+
source: {
|
|
77
|
+
experiences: t,
|
|
78
|
+
keys: r
|
|
79
|
+
},
|
|
80
|
+
effect: async ({ experiences: t, keys: n }, { key: r, id: i, options: a }) => {
|
|
81
|
+
let o = r ?? i ?? "", s = t[n[o] ?? ""] ?? t[o];
|
|
82
|
+
if (!s) {
|
|
83
|
+
`${o}`;
|
|
74
84
|
return;
|
|
75
85
|
}
|
|
76
|
-
if (
|
|
77
|
-
P(e,
|
|
86
|
+
if (a?.bypassCondition) {
|
|
87
|
+
P(e, s, a);
|
|
78
88
|
return;
|
|
79
89
|
}
|
|
80
|
-
await I(e,
|
|
90
|
+
await I(e, s) && P(e, s, a);
|
|
81
91
|
}
|
|
82
92
|
});
|
|
83
93
|
return {
|
|
84
|
-
register:
|
|
85
|
-
get:
|
|
86
|
-
getById:
|
|
87
|
-
launch:
|
|
94
|
+
register: i,
|
|
95
|
+
get: o,
|
|
96
|
+
getById: o,
|
|
97
|
+
launch: s,
|
|
88
98
|
open: C({
|
|
89
|
-
source:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
source: {
|
|
100
|
+
instances: e.experienceInstances.listStore,
|
|
101
|
+
keys: r
|
|
102
|
+
},
|
|
103
|
+
effect: ({ instances: e, keys: t }, { key: n, id: r, options: i }) => {
|
|
104
|
+
let a = n ?? r ?? "", o = t[a] ?? a, c = e.filter((e) => e.experienceId === o);
|
|
105
|
+
if (c.length > 0) for (let e of c) e.open();
|
|
106
|
+
else s({
|
|
107
|
+
key: o,
|
|
95
108
|
options: {
|
|
96
|
-
...
|
|
109
|
+
...i,
|
|
97
110
|
initialiseOpen: !0
|
|
98
111
|
}
|
|
99
112
|
});
|
|
100
113
|
}
|
|
101
114
|
}),
|
|
102
|
-
listStore:
|
|
115
|
+
listStore: a
|
|
103
116
|
};
|
|
104
117
|
});
|
|
105
|
-
function
|
|
106
|
-
return M(
|
|
118
|
+
function fe(e) {
|
|
119
|
+
return M(de, e);
|
|
107
120
|
}
|
|
108
|
-
var
|
|
109
|
-
t.
|
|
110
|
-
}
|
|
111
|
-
let { targetSelectors: r } = t.configStore.getState(), i = v(r, t.id);
|
|
112
|
-
i.forEach(({ elements: e }) => e.forEach((e) => ee(e, t.id))), te(i, t.id).forEach((r) => {
|
|
121
|
+
var P = (e, t, n) => {
|
|
122
|
+
let { targetSelectors: r } = t.configStore.getState(), i = _(r, t.id);
|
|
123
|
+
i.forEach(({ elements: e }) => e.forEach((e) => ae(e, t.id))), ne(i, t.id).forEach((r) => {
|
|
113
124
|
n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
|
|
114
125
|
});
|
|
115
126
|
}, F = async (e) => {
|
|
@@ -119,7 +130,7 @@ var de = (e, t) => {
|
|
|
119
130
|
}, I = async (n, r) => {
|
|
120
131
|
if (!n.preconditionPassed || !n.session?.isUser) return !1;
|
|
121
132
|
let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
|
|
122
|
-
return
|
|
133
|
+
return _(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
|
|
123
134
|
}, L = (e, t, n) => {
|
|
124
135
|
let r = t.name, i = t.setup(e);
|
|
125
136
|
if (i) {
|
|
@@ -163,13 +174,13 @@ var V = j(({ client: e }) => {
|
|
|
163
174
|
listStore: i
|
|
164
175
|
};
|
|
165
176
|
});
|
|
166
|
-
function
|
|
177
|
+
function pe(e) {
|
|
167
178
|
return M(V, e);
|
|
168
179
|
}
|
|
169
|
-
var
|
|
180
|
+
var H = (e, t, n) => {
|
|
170
181
|
n.register(e, t);
|
|
171
|
-
},
|
|
172
|
-
let t =
|
|
182
|
+
}, me = E("framework"), he = j(({ client: e }) => {
|
|
183
|
+
let t = me.store({}), n = T(t, { register(e, t) {
|
|
173
184
|
return {
|
|
174
185
|
...e,
|
|
175
186
|
[t.name]: t.framework
|
|
@@ -191,21 +202,21 @@ var U = (e, t, n) => {
|
|
|
191
202
|
listStore: i
|
|
192
203
|
};
|
|
193
204
|
});
|
|
194
|
-
function
|
|
195
|
-
return M(
|
|
205
|
+
function ge(e) {
|
|
206
|
+
return M(he, e);
|
|
196
207
|
}
|
|
197
|
-
var
|
|
208
|
+
var _e = (e, t) => {
|
|
198
209
|
t.register(e.name, e);
|
|
199
|
-
},
|
|
210
|
+
}, ve = 6e3, ye = S("last_ping", "global"), be = async (e) => {
|
|
200
211
|
try {
|
|
201
|
-
let t = Date.now(), n = b.get(
|
|
202
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
212
|
+
let t = Date.now(), n = b.get(ye), r = 0;
|
|
213
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < ve) return !0;
|
|
203
214
|
let i = {
|
|
204
215
|
projectId: e.projectId,
|
|
205
216
|
path: window.location.pathname
|
|
206
217
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
207
218
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
208
|
-
let s = (await
|
|
219
|
+
let s = (await oe(e.apiUrl, "ping", i, a)).ok;
|
|
209
220
|
return s && n.set(t), s;
|
|
210
221
|
} catch {
|
|
211
222
|
return !1;
|
|
@@ -213,7 +224,7 @@ var he = (e, t) => {
|
|
|
213
224
|
};
|
|
214
225
|
//#endregion
|
|
215
226
|
//#region src/utils/state-snaphot.ts
|
|
216
|
-
function
|
|
227
|
+
function U(e) {
|
|
217
228
|
let t = typeof window < "u", n = {
|
|
218
229
|
client: e,
|
|
219
230
|
responses: e.responses.listStore.getState(),
|
|
@@ -227,8 +238,8 @@ function W(e) {
|
|
|
227
238
|
}
|
|
228
239
|
//#endregion
|
|
229
240
|
//#region src/entities/predicate/predicate.ts
|
|
230
|
-
var
|
|
231
|
-
let t =
|
|
241
|
+
var xe = E("predicate"), Se = j(({ client: e }) => {
|
|
242
|
+
let t = xe.store({}), n = T(t, { register(e, t) {
|
|
232
243
|
return {
|
|
233
244
|
...e,
|
|
234
245
|
[t.name]: {
|
|
@@ -251,7 +262,7 @@ var ye = E("predicate"), be = j(({ client: e }) => {
|
|
|
251
262
|
let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
252
263
|
let n = a(t).getState();
|
|
253
264
|
if (!n) return;
|
|
254
|
-
let r =
|
|
265
|
+
let r = U(e);
|
|
255
266
|
return (...e) => n({
|
|
256
267
|
...r,
|
|
257
268
|
args: e
|
|
@@ -276,13 +287,13 @@ var ye = E("predicate"), be = j(({ client: e }) => {
|
|
|
276
287
|
getEvokablePredicate: o
|
|
277
288
|
};
|
|
278
289
|
});
|
|
279
|
-
function
|
|
280
|
-
return M(
|
|
290
|
+
function Ce(e) {
|
|
291
|
+
return M(Se, e);
|
|
281
292
|
}
|
|
282
|
-
var
|
|
293
|
+
var we = (e, t, n) => {
|
|
283
294
|
n.register(e, t);
|
|
284
|
-
},
|
|
285
|
-
let t =
|
|
295
|
+
}, W = E("feature"), Te = j(({ client: e }) => {
|
|
296
|
+
let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
|
|
286
297
|
return {
|
|
287
298
|
...e,
|
|
288
299
|
[t.id]: t.feature
|
|
@@ -436,23 +447,23 @@ var Se = (e, t, n) => {
|
|
|
436
447
|
getEvokableFeature: f
|
|
437
448
|
};
|
|
438
449
|
});
|
|
439
|
-
function
|
|
440
|
-
return M(
|
|
450
|
+
function Ee(e) {
|
|
451
|
+
return M(Te, e);
|
|
441
452
|
}
|
|
442
|
-
var
|
|
453
|
+
var De = (e, t, n) => {
|
|
443
454
|
n.register(e, t);
|
|
444
|
-
},
|
|
445
|
-
function
|
|
455
|
+
}, G = E("history");
|
|
456
|
+
function K(e, t) {
|
|
446
457
|
return {
|
|
447
|
-
id:
|
|
458
|
+
id: ce(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
448
459
|
node: t,
|
|
449
460
|
at: Date.now(),
|
|
450
461
|
experienceId: e
|
|
451
462
|
};
|
|
452
463
|
}
|
|
453
|
-
var
|
|
454
|
-
let e =
|
|
455
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
464
|
+
var Oe = j(() => {
|
|
465
|
+
let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
|
|
466
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, K(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), K(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
456
467
|
function a(e, t) {
|
|
457
468
|
let n = {
|
|
458
469
|
lastStepIndex: -1,
|
|
@@ -460,7 +471,7 @@ var Ee = j(() => {
|
|
|
460
471
|
};
|
|
461
472
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
462
473
|
let i = e[r], a = i?.node;
|
|
463
|
-
if (!(!a || !
|
|
474
|
+
if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
464
475
|
else {
|
|
465
476
|
n.secondLastStepIndex = r;
|
|
466
477
|
break;
|
|
@@ -482,25 +493,25 @@ var Ee = j(() => {
|
|
|
482
493
|
entriesStore: e.map((e) => e.entries)
|
|
483
494
|
};
|
|
484
495
|
});
|
|
485
|
-
function
|
|
486
|
-
return M(
|
|
496
|
+
function ke() {
|
|
497
|
+
return M(Oe);
|
|
487
498
|
}
|
|
488
499
|
//#endregion
|
|
489
500
|
//#region src/utils/events.ts
|
|
490
|
-
var
|
|
501
|
+
var Ae = 0, je = (e) => {
|
|
491
502
|
let t = k([]);
|
|
492
503
|
return A({
|
|
493
504
|
clock: e,
|
|
494
505
|
source: t,
|
|
495
506
|
fn: (e, t) => [...e, {
|
|
496
|
-
id:
|
|
507
|
+
id: Ae++,
|
|
497
508
|
at: /* @__PURE__ */ new Date(),
|
|
498
509
|
payload: t
|
|
499
510
|
}],
|
|
500
511
|
target: t
|
|
501
512
|
}), t;
|
|
502
|
-
},
|
|
503
|
-
let e =
|
|
513
|
+
}, Me = E("field"), Ne = j(() => {
|
|
514
|
+
let e = Me.store({}), t = T(e, {
|
|
504
515
|
register(e, t) {
|
|
505
516
|
return {
|
|
506
517
|
...e,
|
|
@@ -518,34 +529,67 @@ var De = 0, Oe = (e) => {
|
|
|
518
529
|
function n(e) {
|
|
519
530
|
t.register({ field: e });
|
|
520
531
|
}
|
|
521
|
-
function r(
|
|
532
|
+
function r(n, r) {
|
|
533
|
+
let i = e.getState(), a = Object.values(i).find((e) => e.key === n)?.id ?? n;
|
|
522
534
|
t.updateById({
|
|
523
|
-
fieldId:
|
|
524
|
-
updates:
|
|
535
|
+
fieldId: a,
|
|
536
|
+
updates: r
|
|
525
537
|
});
|
|
526
538
|
}
|
|
527
539
|
let i = e.map((e) => Object.values(e));
|
|
528
540
|
function a(t) {
|
|
529
|
-
return e.map((e) => e[t]
|
|
541
|
+
return e.map((e) => e[t] ?? null);
|
|
530
542
|
}
|
|
531
543
|
function o(t) {
|
|
532
|
-
return e.map((e) => Object.values(e).find((e) => e.
|
|
544
|
+
return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null);
|
|
545
|
+
}
|
|
546
|
+
function s(t) {
|
|
547
|
+
return e.map((e) => Object.values(e).find((e) => e.name === t) ?? null);
|
|
533
548
|
}
|
|
534
549
|
return {
|
|
535
550
|
register: n,
|
|
536
551
|
update: r,
|
|
537
552
|
getById: a,
|
|
553
|
+
getByKey: o,
|
|
538
554
|
listStore: i,
|
|
539
|
-
getByName:
|
|
555
|
+
getByName: s
|
|
540
556
|
};
|
|
541
557
|
});
|
|
542
|
-
function
|
|
543
|
-
return M(
|
|
558
|
+
function Pe() {
|
|
559
|
+
return M(Ne);
|
|
544
560
|
}
|
|
545
|
-
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/entities/step/step.ts
|
|
563
|
+
var Fe = E("step"), Ie = j(() => {
|
|
564
|
+
let e = Fe.store({}), t = T(e, { register(e, t) {
|
|
565
|
+
return {
|
|
566
|
+
...e,
|
|
567
|
+
[t.step.id]: t.step
|
|
568
|
+
};
|
|
569
|
+
} });
|
|
570
|
+
function n(e) {
|
|
571
|
+
t.register({ step: e });
|
|
572
|
+
}
|
|
573
|
+
let r = e.map((e) => Object.values(e));
|
|
574
|
+
function i(t) {
|
|
575
|
+
return e.map((e) => e[t] ?? null);
|
|
576
|
+
}
|
|
577
|
+
return {
|
|
578
|
+
register: n,
|
|
579
|
+
getById: i,
|
|
580
|
+
listStore: r
|
|
581
|
+
};
|
|
582
|
+
});
|
|
583
|
+
function Le() {
|
|
584
|
+
return M(Ie);
|
|
585
|
+
}
|
|
586
|
+
function Re(e, t) {
|
|
546
587
|
t.register(e);
|
|
547
|
-
}
|
|
548
|
-
|
|
588
|
+
}
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/entities/action/action.ts
|
|
591
|
+
var ze = E("action"), Be = j(() => {
|
|
592
|
+
let e = ze.store({}), t = T(e, { register(e, t) {
|
|
549
593
|
return {
|
|
550
594
|
...e,
|
|
551
595
|
[t.name]: {
|
|
@@ -577,33 +621,83 @@ var Me = (e, t) => {
|
|
|
577
621
|
getEvokableAction: a
|
|
578
622
|
};
|
|
579
623
|
});
|
|
580
|
-
function
|
|
581
|
-
return M(
|
|
624
|
+
function Ve() {
|
|
625
|
+
return M(Be);
|
|
582
626
|
}
|
|
583
|
-
var
|
|
627
|
+
var He = (e, t, n) => {
|
|
584
628
|
n.register(e, t);
|
|
585
629
|
};
|
|
586
630
|
//#endregion
|
|
587
|
-
//#region src/entities/response/response.ts
|
|
588
|
-
function
|
|
631
|
+
//#region src/entities/response/response-validation.ts
|
|
632
|
+
function q(e, t, n, r) {
|
|
633
|
+
return {
|
|
634
|
+
fieldKey: e.key,
|
|
635
|
+
fieldId: e.id,
|
|
636
|
+
userMessage: n,
|
|
637
|
+
systemMessage: r,
|
|
638
|
+
value: t
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function J(e) {
|
|
589
642
|
return e == null || e === "" || Array.isArray(e) && !e.length;
|
|
590
643
|
}
|
|
591
|
-
function
|
|
644
|
+
function Ue(e) {
|
|
592
645
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
593
646
|
}
|
|
594
|
-
function
|
|
647
|
+
function Y(e) {
|
|
595
648
|
try {
|
|
596
649
|
return JSON.stringify(e), !0;
|
|
597
650
|
} catch {
|
|
598
651
|
return !1;
|
|
599
652
|
}
|
|
600
653
|
}
|
|
601
|
-
|
|
602
|
-
|
|
654
|
+
function We(e, t) {
|
|
655
|
+
return t.find((t) => t.id === e) ?? t.find((t) => t.key === e) ?? null;
|
|
656
|
+
}
|
|
657
|
+
function Ge(e, t) {
|
|
658
|
+
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
659
|
+
}
|
|
660
|
+
function Ke(e, t) {
|
|
661
|
+
if (e.type !== "object" || J(t)) return null;
|
|
662
|
+
if (e.multiple) {
|
|
663
|
+
if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
664
|
+
for (let n of t) {
|
|
665
|
+
if (typeof n != "object" || !n) return q(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
666
|
+
if (!Y(n)) return q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
667
|
+
}
|
|
668
|
+
return null;
|
|
669
|
+
}
|
|
670
|
+
return Array.isArray(t) ? q(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? q(e, t, "This field expects an object value", "Field expects an object value.") : Y(t) ? null : q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
671
|
+
}
|
|
672
|
+
function qe(e, t) {
|
|
673
|
+
if (!Array.isArray(e.options) || e.options.length === 0) return null;
|
|
674
|
+
let n = Array.isArray(t) ? t : [t];
|
|
675
|
+
if (e.type === "object") {
|
|
676
|
+
let r = e.options.map((e) => JSON.stringify(e.value));
|
|
677
|
+
return n.every((e) => r.includes(JSON.stringify(e))) ? null : q(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
678
|
+
}
|
|
679
|
+
let r = e.options.map((e) => e.value);
|
|
680
|
+
return n.every((e) => !Ue(e) || e === null ? !1 : r.includes(e)) ? null : q(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
681
|
+
}
|
|
682
|
+
async function Je(e, t, r, i) {
|
|
683
|
+
if (t.validation && !n(t.validation) && !J(r)) {
|
|
684
|
+
let n = i ? {
|
|
685
|
+
$input: r,
|
|
686
|
+
responses: i
|
|
687
|
+
} : { $input: r }, a = await e(t.validation, n);
|
|
688
|
+
if (typeof a == "string") return q(t, r, a, `Field validation resulted in an error: ${a}.`);
|
|
689
|
+
if (a === !1) return q(t, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
690
|
+
}
|
|
691
|
+
return t.required && J(r) ? q(t, r, "This field is required", "Field is required.") : !t.multiple && Array.isArray(r) && r.length > 1 ? q(t, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
692
|
+
}
|
|
693
|
+
//#endregion
|
|
694
|
+
//#region src/entities/response/response.ts
|
|
695
|
+
var Ye = E("response"), Xe = j(({ client: e }) => {
|
|
696
|
+
let n = Ye.store({}), r = O(), i = O(), a = T(n, {
|
|
603
697
|
register(e, t) {
|
|
604
698
|
return {
|
|
605
699
|
...e,
|
|
606
|
-
[t.
|
|
700
|
+
[t.fieldKey]: t.response
|
|
607
701
|
};
|
|
608
702
|
},
|
|
609
703
|
registerBatch(e, t) {
|
|
@@ -613,221 +707,178 @@ var Re = E("response"), ze = j(({ client: e }) => {
|
|
|
613
707
|
};
|
|
614
708
|
},
|
|
615
709
|
clear(e, t) {
|
|
616
|
-
|
|
617
|
-
return r;
|
|
710
|
+
return Object.fromEntries(Object.entries(e).filter(([e]) => e !== t));
|
|
618
711
|
},
|
|
619
712
|
clearAll() {
|
|
620
713
|
return {};
|
|
621
714
|
}
|
|
622
715
|
});
|
|
623
|
-
function
|
|
716
|
+
function o(e, t) {
|
|
624
717
|
if (typeof e == "string") {
|
|
625
718
|
if (t === void 0) throw Error("Response is required when registering a single field");
|
|
626
|
-
|
|
627
|
-
|
|
719
|
+
a.register({
|
|
720
|
+
fieldKey: e,
|
|
628
721
|
response: t
|
|
629
722
|
});
|
|
630
|
-
} else
|
|
723
|
+
} else a.registerBatch(e);
|
|
631
724
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}, s = await t(e, l.validation, {
|
|
650
|
-
$input: c,
|
|
651
|
-
responses: n
|
|
652
|
-
});
|
|
653
|
-
if (typeof s == "string") {
|
|
654
|
-
a.push({
|
|
655
|
-
fieldId: o,
|
|
656
|
-
userMessage: s,
|
|
657
|
-
systemMessage: `Field validation resulted in an error: ${s}.`,
|
|
658
|
-
value: c
|
|
659
|
-
});
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
if (s === !1) {
|
|
663
|
-
a.push({
|
|
664
|
-
fieldId: o,
|
|
665
|
-
userMessage: "This field is invalid",
|
|
666
|
-
systemMessage: "Field validation resulted in an unspecified error.",
|
|
667
|
-
value: c
|
|
725
|
+
let s = (n, r) => t(e, n, r), c = C({
|
|
726
|
+
source: {
|
|
727
|
+
allFields: e.fields.listStore,
|
|
728
|
+
existingResponses: n
|
|
729
|
+
},
|
|
730
|
+
effect: async ({ allFields: e, existingResponses: t }, n) => {
|
|
731
|
+
let r = [], i = {}, a = {
|
|
732
|
+
...t,
|
|
733
|
+
...n
|
|
734
|
+
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
735
|
+
let o = We(t, e);
|
|
736
|
+
if (!o) {
|
|
737
|
+
r.push({
|
|
738
|
+
fieldKey: t,
|
|
739
|
+
userMessage: `Field '${t}' not found`,
|
|
740
|
+
systemMessage: `No field with key '${t}' exists. Available field keys are: ${e.map((e) => e.key).join(",")}.`,
|
|
741
|
+
value: n
|
|
668
742
|
});
|
|
669
743
|
return;
|
|
670
744
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
fieldId: o,
|
|
675
|
-
userMessage: "This field is required",
|
|
676
|
-
systemMessage: "Field is required.",
|
|
677
|
-
value: c
|
|
678
|
-
});
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
if (!l.multiple && Array.isArray(c) && c.length > 1) {
|
|
682
|
-
a.push({
|
|
683
|
-
fieldId: o,
|
|
684
|
-
userMessage: "This field expects a single response",
|
|
685
|
-
systemMessage: "Field expects a single response.",
|
|
686
|
-
value: c
|
|
687
|
-
});
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
if (l.type === "object" && !Y(c)) if (l.multiple) {
|
|
691
|
-
if (!Array.isArray(c)) {
|
|
692
|
-
a.push({
|
|
693
|
-
fieldId: o,
|
|
694
|
-
userMessage: "This field expects multiple values",
|
|
695
|
-
systemMessage: "Field expects an array of objects.",
|
|
696
|
-
value: c
|
|
697
|
-
});
|
|
745
|
+
let c = Ge(o, n), l = await Je(s, o, c, a);
|
|
746
|
+
if (l) {
|
|
747
|
+
r.push(l);
|
|
698
748
|
return;
|
|
699
749
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
fieldId: o,
|
|
704
|
-
userMessage: "This field expects object values",
|
|
705
|
-
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
706
|
-
value: c
|
|
707
|
-
});
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
if (!X(e)) {
|
|
711
|
-
a.push({
|
|
712
|
-
fieldId: o,
|
|
713
|
-
userMessage: "This field contains non-serializable data",
|
|
714
|
-
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
715
|
-
value: c
|
|
716
|
-
});
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
} else {
|
|
721
|
-
if (Array.isArray(c)) {
|
|
722
|
-
a.push({
|
|
723
|
-
fieldId: o,
|
|
724
|
-
userMessage: "This field expects a single value",
|
|
725
|
-
systemMessage: "Field expects a single object, not an array.",
|
|
726
|
-
value: c
|
|
727
|
-
});
|
|
750
|
+
let u = Ke(o, c);
|
|
751
|
+
if (u) {
|
|
752
|
+
r.push(u);
|
|
728
753
|
return;
|
|
729
754
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
userMessage: "This field expects an object value",
|
|
734
|
-
systemMessage: "Field expects an object value.",
|
|
735
|
-
value: c
|
|
736
|
-
});
|
|
737
|
-
return;
|
|
738
|
-
}
|
|
739
|
-
if (!X(c)) {
|
|
740
|
-
a.push({
|
|
741
|
-
fieldId: o,
|
|
742
|
-
userMessage: "This field contains non-serializable data",
|
|
743
|
-
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
744
|
-
value: c
|
|
745
|
-
});
|
|
755
|
+
let d = qe(o, c);
|
|
756
|
+
if (d) {
|
|
757
|
+
r.push(d);
|
|
746
758
|
return;
|
|
747
759
|
}
|
|
760
|
+
i[o.key] = n;
|
|
761
|
+
}));
|
|
762
|
+
for (let [e, t] of c.entries()) {
|
|
763
|
+
if (t.status !== "rejected") continue;
|
|
764
|
+
let n = o[e];
|
|
765
|
+
if (!n) continue;
|
|
766
|
+
let [i, a] = n, s = t.reason instanceof Error ? t.reason.message : String(t.reason);
|
|
767
|
+
r.push({
|
|
768
|
+
fieldKey: i,
|
|
769
|
+
userMessage: "An unexpected error occurred validating this field",
|
|
770
|
+
systemMessage: `Validation threw for field '${i}': ${s}`,
|
|
771
|
+
value: a
|
|
772
|
+
});
|
|
748
773
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
fieldId: o,
|
|
755
|
-
userMessage: "This field expects a valid option",
|
|
756
|
-
systemMessage: "Field expects a valid option from the defined choices.",
|
|
757
|
-
value: c
|
|
758
|
-
});
|
|
759
|
-
} else {
|
|
760
|
-
let t = l.options.map((e) => e.value);
|
|
761
|
-
e.every((e) => !Le(e) || e === null ? !1 : t.includes(e)) || a.push({
|
|
762
|
-
fieldId: o,
|
|
763
|
-
userMessage: "This field expects a valid option",
|
|
764
|
-
systemMessage: `Field expects a valid option. Valid options are: ${t.join(", ")}`,
|
|
765
|
-
value: c
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
})), {
|
|
770
|
-
responsesToCommit: i,
|
|
771
|
-
validationErrors: a
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
let l = C({
|
|
775
|
-
source: r,
|
|
776
|
-
effect: (e, t) => c(e, t)
|
|
774
|
+
return {
|
|
775
|
+
responsesToCommit: i,
|
|
776
|
+
validationErrors: r
|
|
777
|
+
};
|
|
778
|
+
}
|
|
777
779
|
});
|
|
778
|
-
async function
|
|
779
|
-
return
|
|
780
|
+
async function l(e) {
|
|
781
|
+
return c(e);
|
|
780
782
|
}
|
|
781
|
-
let
|
|
782
|
-
source:
|
|
783
|
+
let u = C({
|
|
784
|
+
source: n,
|
|
783
785
|
effect: async (e, t) => {
|
|
784
|
-
let { responsesToCommit: n, validationErrors: r } = await c(
|
|
785
|
-
return r.length ? { errors: r } : (
|
|
786
|
+
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
787
|
+
return r.length ? { errors: r } : (a.registerBatch(n), { errors: [] });
|
|
786
788
|
}
|
|
787
789
|
});
|
|
788
|
-
async function
|
|
789
|
-
return
|
|
790
|
+
async function d(e) {
|
|
791
|
+
return u(e);
|
|
790
792
|
}
|
|
791
|
-
let
|
|
792
|
-
|
|
793
|
-
|
|
793
|
+
let f = n.map((e) => e), p = w({
|
|
794
|
+
responses: n,
|
|
795
|
+
fields: e.fields.listStore
|
|
796
|
+
}, ({ responses: e, fields: t }) => Object.entries(e).map(([e, n]) => ({
|
|
797
|
+
fieldId: t.find((t) => t.key === e)?.id ?? e,
|
|
798
|
+
fieldKey: e,
|
|
799
|
+
value: n
|
|
794
800
|
})));
|
|
801
|
+
function m(t) {
|
|
802
|
+
return w({
|
|
803
|
+
f: e.fields.listStore.map((e) => e.find((e) => e.id === t || e.key === t) ?? null),
|
|
804
|
+
s: n
|
|
805
|
+
}, ({ f: e, s: t }) => {
|
|
806
|
+
let n = e ? t[e.key] ?? null : null;
|
|
807
|
+
return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
|
|
808
|
+
});
|
|
809
|
+
}
|
|
795
810
|
function h(t) {
|
|
796
811
|
return w({
|
|
797
|
-
f: e.fields.
|
|
798
|
-
|
|
799
|
-
}, ({ f: e,
|
|
812
|
+
f: e.fields.getByKey(t),
|
|
813
|
+
s: n
|
|
814
|
+
}, ({ f: e, s: t }) => {
|
|
815
|
+
let n = e ? t[e.key] ?? null : null;
|
|
816
|
+
return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
|
|
817
|
+
});
|
|
800
818
|
}
|
|
801
819
|
function g(t) {
|
|
802
820
|
return w({
|
|
803
821
|
f: e.fields.getByName(t),
|
|
804
|
-
s:
|
|
805
|
-
}, ({ f: e, s: t }) =>
|
|
822
|
+
s: n
|
|
823
|
+
}, ({ f: e, s: t }) => {
|
|
824
|
+
let n = e ? t[e.key] ?? null : null;
|
|
825
|
+
return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
|
|
826
|
+
});
|
|
806
827
|
}
|
|
807
828
|
return A({
|
|
808
|
-
clock:
|
|
809
|
-
target:
|
|
829
|
+
clock: r,
|
|
830
|
+
target: a.clearAll
|
|
810
831
|
}), A({
|
|
811
|
-
clock:
|
|
812
|
-
target:
|
|
832
|
+
clock: i,
|
|
833
|
+
target: a.clear
|
|
813
834
|
}), {
|
|
814
|
-
register:
|
|
815
|
-
clearAll:
|
|
816
|
-
clear:
|
|
817
|
-
commit:
|
|
818
|
-
getResponsesToCommit:
|
|
819
|
-
listStore:
|
|
820
|
-
getAllStore:
|
|
821
|
-
getByFieldId:
|
|
835
|
+
register: o,
|
|
836
|
+
clearAll: r,
|
|
837
|
+
clear: i,
|
|
838
|
+
commit: d,
|
|
839
|
+
getResponsesToCommit: l,
|
|
840
|
+
listStore: p,
|
|
841
|
+
getAllStore: f,
|
|
842
|
+
getByFieldId: m,
|
|
843
|
+
getByFieldKey: h,
|
|
822
844
|
getByFieldName: g
|
|
823
845
|
};
|
|
824
846
|
});
|
|
825
|
-
function
|
|
826
|
-
return M(
|
|
847
|
+
function Ze(e) {
|
|
848
|
+
return M(Xe, e);
|
|
849
|
+
}
|
|
850
|
+
//#endregion
|
|
851
|
+
//#region src/entities/condition/condition.ts
|
|
852
|
+
var Qe = E("condition"), $e = j(() => {
|
|
853
|
+
let e = Qe.store({}), t = T(e, { register(e, t) {
|
|
854
|
+
return {
|
|
855
|
+
...e,
|
|
856
|
+
[t.condition.id]: t.condition
|
|
857
|
+
};
|
|
858
|
+
} });
|
|
859
|
+
function n(e) {
|
|
860
|
+
t.register({ condition: e });
|
|
861
|
+
}
|
|
862
|
+
let r = e.map((e) => Object.values(e));
|
|
863
|
+
function i(t) {
|
|
864
|
+
return e.map((e) => e[t] ?? null);
|
|
865
|
+
}
|
|
866
|
+
function a(t) {
|
|
867
|
+
return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null);
|
|
868
|
+
}
|
|
869
|
+
return {
|
|
870
|
+
register: n,
|
|
871
|
+
getById: i,
|
|
872
|
+
getByKey: a,
|
|
873
|
+
listStore: r
|
|
874
|
+
};
|
|
875
|
+
});
|
|
876
|
+
function et() {
|
|
877
|
+
return M($e);
|
|
827
878
|
}
|
|
828
879
|
//#endregion
|
|
829
880
|
//#region src/utils/api-url.ts
|
|
830
|
-
function
|
|
881
|
+
function tt() {
|
|
831
882
|
if (f()) {
|
|
832
883
|
let e = [
|
|
833
884
|
document.currentScript,
|
|
@@ -842,7 +893,7 @@ function Ve() {
|
|
|
842
893
|
}
|
|
843
894
|
//#endregion
|
|
844
895
|
//#region src/utils/search-params.ts
|
|
845
|
-
function
|
|
896
|
+
function nt() {
|
|
846
897
|
if (!o()) return {};
|
|
847
898
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
848
899
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -860,18 +911,18 @@ function He() {
|
|
|
860
911
|
}
|
|
861
912
|
//#endregion
|
|
862
913
|
//#region src/utils/user-session.ts
|
|
863
|
-
function
|
|
914
|
+
function rt() {
|
|
864
915
|
return l() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
|
|
865
916
|
}
|
|
866
|
-
var
|
|
867
|
-
let e = b.get(
|
|
917
|
+
var it = S("session", "global"), X = () => {
|
|
918
|
+
let e = b.get(it), t;
|
|
868
919
|
e.isSet() && (t = e.json());
|
|
869
920
|
let n = (t) => e.set({
|
|
870
921
|
id: t.id,
|
|
871
922
|
isUser: t.isUser,
|
|
872
923
|
identifiers: t.identifiers
|
|
873
924
|
}), r = {
|
|
874
|
-
id: t?.id ??
|
|
925
|
+
id: t?.id ?? rt(),
|
|
875
926
|
isUser: t?.isUser ?? void 0,
|
|
876
927
|
identifiers: t?.identifiers ?? void 0,
|
|
877
928
|
setIsUser(e) {
|
|
@@ -888,13 +939,13 @@ var We = S("session", "global"), Ge = () => {
|
|
|
888
939
|
}
|
|
889
940
|
};
|
|
890
941
|
return n(r), r;
|
|
891
|
-
},
|
|
942
|
+
}, at = () => u() ? X() : null;
|
|
892
943
|
//#endregion
|
|
893
944
|
//#region src/utils/picked-config.ts
|
|
894
945
|
function Z() {
|
|
895
946
|
if (o()) return globalThis.window.pickedConfig;
|
|
896
947
|
}
|
|
897
|
-
function
|
|
948
|
+
function ot() {
|
|
898
949
|
if (!o()) return;
|
|
899
950
|
let e = Z(), t = e?.organizationId, n = e?.projectId;
|
|
900
951
|
return t && n ? {
|
|
@@ -902,7 +953,7 @@ function qe() {
|
|
|
902
953
|
projectId: n
|
|
903
954
|
} : void 0;
|
|
904
955
|
}
|
|
905
|
-
function
|
|
956
|
+
function st() {
|
|
906
957
|
if (!f()) return;
|
|
907
958
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
908
959
|
if (!e) return;
|
|
@@ -912,15 +963,15 @@ function Je() {
|
|
|
912
963
|
projectId: n
|
|
913
964
|
} : void 0;
|
|
914
965
|
}
|
|
915
|
-
function
|
|
966
|
+
function ct(e) {
|
|
916
967
|
let { organizationId: t, projectId: n } = e;
|
|
917
968
|
if (t && n) return {
|
|
918
969
|
organizationId: t,
|
|
919
970
|
projectId: n
|
|
920
971
|
};
|
|
921
|
-
let r =
|
|
972
|
+
let r = ot();
|
|
922
973
|
if (r) return r;
|
|
923
|
-
let i =
|
|
974
|
+
let i = st();
|
|
924
975
|
if (i) return i;
|
|
925
976
|
throw Error("organizationId and projectId are required. You can provide them via one of:\n (1) createClient({ organizationId, projectId }) options;\n (2) window.pickedConfig = { organizationId, projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.");
|
|
926
977
|
}
|
|
@@ -929,7 +980,7 @@ function Ye(e) {
|
|
|
929
980
|
function Q(e) {
|
|
930
981
|
return e == null || e === "" || Number.isNaN(e);
|
|
931
982
|
}
|
|
932
|
-
var
|
|
983
|
+
var lt = {
|
|
933
984
|
default: (e, t) => Q(e) ? String(t ?? "") : String(e),
|
|
934
985
|
append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
|
|
935
986
|
prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
|
|
@@ -950,24 +1001,24 @@ var Xe = {
|
|
|
950
1001
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
951
1002
|
}
|
|
952
1003
|
};
|
|
953
|
-
function
|
|
1004
|
+
function ut(e) {
|
|
954
1005
|
return typeof e == "object" && !!e;
|
|
955
1006
|
}
|
|
956
|
-
function
|
|
1007
|
+
function dt(e, t) {
|
|
957
1008
|
let n = t;
|
|
958
|
-
for (let t of e.split(".")) if (
|
|
1009
|
+
for (let t of e.split(".")) if (ut(n) && t in n) n = n[t];
|
|
959
1010
|
else return;
|
|
960
1011
|
return typeof n == "function" ? n() : n;
|
|
961
1012
|
}
|
|
962
|
-
function
|
|
963
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1013
|
+
function ft(e, t) {
|
|
1014
|
+
let n = e.split("|").map((e) => e.trim()), r = dt(n.shift() ?? "", t);
|
|
964
1015
|
for (let e of n) {
|
|
965
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1016
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = lt[i];
|
|
966
1017
|
o && (r = o(r, a));
|
|
967
1018
|
}
|
|
968
1019
|
return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
969
1020
|
}
|
|
970
|
-
function
|
|
1021
|
+
function pt(e, t) {
|
|
971
1022
|
let n = "", r = 0;
|
|
972
1023
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
973
1024
|
r += 2;
|
|
@@ -979,7 +1030,7 @@ function et(e, t) {
|
|
|
979
1030
|
}
|
|
980
1031
|
i += e[r++];
|
|
981
1032
|
}
|
|
982
|
-
n +=
|
|
1033
|
+
n += ft(i.trim(), t);
|
|
983
1034
|
} else n += e[r++];
|
|
984
1035
|
return n;
|
|
985
1036
|
}
|
|
@@ -1002,27 +1053,29 @@ var $ = class {
|
|
|
1002
1053
|
precondition;
|
|
1003
1054
|
condition;
|
|
1004
1055
|
preconditionPassed;
|
|
1005
|
-
searchParams =
|
|
1006
|
-
history =
|
|
1007
|
-
components =
|
|
1008
|
-
experienceInstances =
|
|
1009
|
-
experiences =
|
|
1010
|
-
frameworks =
|
|
1011
|
-
predicates =
|
|
1012
|
-
features =
|
|
1013
|
-
|
|
1014
|
-
fields =
|
|
1015
|
-
|
|
1056
|
+
searchParams = nt();
|
|
1057
|
+
history = ke();
|
|
1058
|
+
components = pe({ client: this });
|
|
1059
|
+
experienceInstances = te({ client: this });
|
|
1060
|
+
experiences = fe({ client: this });
|
|
1061
|
+
frameworks = ge({ client: this });
|
|
1062
|
+
predicates = Ce({ client: this });
|
|
1063
|
+
features = Ee({ client: this });
|
|
1064
|
+
conditions = et();
|
|
1065
|
+
fields = Pe();
|
|
1066
|
+
responses = Ze({ client: this });
|
|
1067
|
+
steps = Le();
|
|
1068
|
+
actions = Ve();
|
|
1016
1069
|
constructor(e) {
|
|
1017
|
-
this.events =
|
|
1018
|
-
let { organizationId: t, projectId: n } =
|
|
1019
|
-
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl ||
|
|
1070
|
+
this.events = je(this.eventBus);
|
|
1071
|
+
let { organizationId: t, projectId: n } = ct(e);
|
|
1072
|
+
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = at(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
|
|
1020
1073
|
type: "load",
|
|
1021
|
-
version:
|
|
1074
|
+
version: se()
|
|
1022
1075
|
});
|
|
1023
1076
|
}
|
|
1024
1077
|
start = () => {
|
|
1025
|
-
|
|
1078
|
+
be(this), (async () => {
|
|
1026
1079
|
if (!f()) return;
|
|
1027
1080
|
await this.runPluginStartHooks();
|
|
1028
1081
|
let e = await this.evaluateGate(this.precondition);
|
|
@@ -1037,7 +1090,7 @@ var $ = class {
|
|
|
1037
1090
|
value: e
|
|
1038
1091
|
});
|
|
1039
1092
|
}
|
|
1040
|
-
if (this.eventBus({ type: "initialize" }), n && F(this), await
|
|
1093
|
+
if (this.eventBus({ type: "initialize" }), n && F(this), await ie(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1041
1094
|
let { id: e, isUser: t, identifiers: n } = this.session;
|
|
1042
1095
|
this.eventBus({
|
|
1043
1096
|
type: "session",
|
|
@@ -1049,10 +1102,10 @@ var $ = class {
|
|
|
1049
1102
|
})();
|
|
1050
1103
|
};
|
|
1051
1104
|
registerFramework = (e) => {
|
|
1052
|
-
|
|
1105
|
+
_e(e, this.frameworks);
|
|
1053
1106
|
};
|
|
1054
1107
|
registerComponent = (e, t) => {
|
|
1055
|
-
|
|
1108
|
+
H(e, t, this.components);
|
|
1056
1109
|
};
|
|
1057
1110
|
registerPlugin = (e) => {
|
|
1058
1111
|
L(this, e, this.plugins);
|
|
@@ -1060,29 +1113,35 @@ var $ = class {
|
|
|
1060
1113
|
t?.onStart && this.pluginStartHooks.push(t.onStart);
|
|
1061
1114
|
};
|
|
1062
1115
|
registerFeature = (e, t) => {
|
|
1063
|
-
|
|
1116
|
+
De(e, t, this.features);
|
|
1064
1117
|
};
|
|
1065
1118
|
registerPredicate = (e, t) => {
|
|
1066
|
-
|
|
1119
|
+
we(e, t, this.predicates);
|
|
1120
|
+
};
|
|
1121
|
+
registerCondition = (e) => {
|
|
1122
|
+
this.conditions.register(e);
|
|
1067
1123
|
};
|
|
1068
1124
|
registerField = (e) => {
|
|
1069
|
-
|
|
1125
|
+
this.fields.register(e);
|
|
1126
|
+
};
|
|
1127
|
+
registerStep = (e) => {
|
|
1128
|
+
Re(e, this.steps);
|
|
1070
1129
|
};
|
|
1071
1130
|
registerAction = (e, t) => {
|
|
1072
|
-
|
|
1131
|
+
He(e, t, this.actions);
|
|
1073
1132
|
};
|
|
1074
1133
|
registerExperience = (e) => {
|
|
1075
|
-
e.component &&
|
|
1134
|
+
e.component && H(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1076
1135
|
};
|
|
1077
|
-
getStateSnapshot = () =>
|
|
1136
|
+
getStateSnapshot = () => U(this);
|
|
1078
1137
|
launchExperienceById = async (e, t) => {
|
|
1079
1138
|
this.experiences.launch({
|
|
1080
|
-
|
|
1139
|
+
key: e,
|
|
1081
1140
|
options: t
|
|
1082
1141
|
});
|
|
1083
1142
|
};
|
|
1084
1143
|
openExperienceById = async (e) => {
|
|
1085
|
-
this.experiences.open({
|
|
1144
|
+
this.experiences.open({ key: e });
|
|
1086
1145
|
};
|
|
1087
1146
|
async runPluginStartHooks() {
|
|
1088
1147
|
for (let e of this.pluginStartHooks) await e();
|
|
@@ -1154,7 +1213,7 @@ var $ = class {
|
|
|
1154
1213
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1155
1214
|
renderString = (e, t) => {
|
|
1156
1215
|
let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldId] = t.value, e), {});
|
|
1157
|
-
return
|
|
1216
|
+
return pt(e, {
|
|
1158
1217
|
...t,
|
|
1159
1218
|
responses: n
|
|
1160
1219
|
});
|
|
@@ -1162,20 +1221,20 @@ var $ = class {
|
|
|
1162
1221
|
};
|
|
1163
1222
|
//#endregion
|
|
1164
1223
|
//#region src/entities/component/lazyComponent.ts
|
|
1165
|
-
function
|
|
1224
|
+
function mt(e) {
|
|
1166
1225
|
return {
|
|
1167
1226
|
$$type: "lazy-component",
|
|
1168
1227
|
load: e
|
|
1169
1228
|
};
|
|
1170
1229
|
}
|
|
1171
|
-
function
|
|
1230
|
+
function ht(e) {
|
|
1172
1231
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1173
1232
|
}
|
|
1174
1233
|
//#endregion
|
|
1175
1234
|
//#region src/exports.ts
|
|
1176
|
-
var
|
|
1235
|
+
var gt = (e) => {
|
|
1177
1236
|
let t = new $(e);
|
|
1178
1237
|
return d(t), t;
|
|
1179
1238
|
};
|
|
1180
1239
|
//#endregion
|
|
1181
|
-
export { $ as Picked,
|
|
1240
|
+
export { $ as Picked, gt as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, ht as isLazyLoader, ee as isPickedRoot, mt as lazyComponent, b as localStore, x as sessionStore, y as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };
|