@picked/client 0.0.50 → 0.0.51-next.1
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-A3gUhQJc.cjs +1 -0
- package/dist/{api-DWBcrf98.js → api-Brluf3C1.js} +1 -1
- package/dist/cjs/form/index.js +1 -0
- 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/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/server/index.js +1 -1
- package/dist/esm/form/index.js +466 -0
- package/dist/esm/index.js +330 -321
- package/dist/esm/plugins/create-experience/index.js +25 -19
- package/dist/esm/plugins/dynamic-experiences/index.js +1 -1
- 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 +5 -9
- package/dist/esm/plugins/single-page-app/index.js +4 -4
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-CIbQp9D7.js +481 -0
- package/dist/experience-instance-Dri5yAp1.cjs +1 -0
- package/dist/{object-Clj5zVr1.js → object-C82v79xc.js} +2 -1
- package/dist/object-CUJOjanb.cjs +1 -0
- package/dist/rules-logic-BIkBWZmf.js +233 -0
- package/dist/rules-logic-DDxCiq4P.cjs +1 -0
- package/dist/{storage-DyxpJ0pg.js → storage-6Xk0uAxB.js} +3 -1
- package/dist/storage-B6lQtc4-.cjs +1 -0
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +10 -10
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +11 -8
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/exports.d.ts +0 -1
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/form/build-responses.d.ts +14 -0
- package/dist/types/form/build-responses.d.ts.map +1 -0
- package/dist/types/form/create-field-evaluator.d.ts +19 -0
- package/dist/types/form/create-field-evaluator.d.ts.map +1 -0
- package/dist/types/form/create-field-validation.d.ts +59 -0
- package/dist/types/form/create-field-validation.d.ts.map +1 -0
- package/dist/types/form/create-form.d.ts +96 -0
- package/dist/types/form/create-form.d.ts.map +1 -0
- package/dist/types/form/create-submit-pipeline.d.ts +58 -0
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -0
- package/dist/types/form/get-step-fields.d.ts +5 -0
- package/dist/types/form/get-step-fields.d.ts.map +1 -0
- package/dist/types/form/index.d.ts +10 -0
- package/dist/types/form/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +12 -10
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +4 -5
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +24 -22
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/index.d.ts +1 -1
- package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -0
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +0 -3
- package/dist/types/utils/dom.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/global-obj.d.ts +0 -1
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/indexed-db.d.ts +2 -1
- package/dist/types/utils/indexed-db.d.ts.map +1 -1
- package/dist/types/utils/logger.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/min-max-steps-to-leaf.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +2 -2
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/object.d.ts +0 -8
- package/dist/types/utils/object.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +1 -1
- package/dist/types/utils/picked-config.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/dist/types/utils/search-params.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +43 -7
- package/dist/api-BwTaomem.cjs +0 -1
- package/dist/experience-instance-BRpI9I4s.js +0 -710
- package/dist/experience-instance-BUTnwbSJ.cjs +0 -1
- package/dist/object-BReQiaSS.cjs +0 -1
- package/dist/storage-BFjb8azI.cjs +0 -1
- package/dist/types/entities/project/project.d.ts +0 -9
- package/dist/types/entities/project/project.d.ts.map +0 -1
- package/dist/types/utils/get-step-fields.d.ts +0 -4
- package/dist/types/utils/get-step-fields.d.ts.map +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/{id-CIbS4P60.cjs → id-Bv44ilEo.cjs} +0 -0
- /package/dist/{id-BniPxOdF.js → id-CRqy981z.js} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import { a as
|
|
5
|
-
import { i as
|
|
6
|
-
import { n as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { n as e, t } from "../rules-logic-BIkBWZmf.js";
|
|
2
|
+
import { t as n } from "../object-C82v79xc.js";
|
|
3
|
+
import { t as r } from "../logger-6z_gb4rA.js";
|
|
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 ee, i as te, n as _, o as v, r as y, s as ne } from "../experience-instance-CIbQp9D7.js";
|
|
6
|
+
import { i as re, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
|
|
7
|
+
import { n as ie, r as ae } from "../api-Brluf3C1.js";
|
|
8
|
+
import { t as oe } from "../id-CRqy981z.js";
|
|
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
|
+
import { createFactory as j, invoke as M } from "@withease/factories";
|
|
10
11
|
//#region src/entities/experience/experience.ts
|
|
11
|
-
var
|
|
12
|
-
let n =
|
|
12
|
+
var N = E("experience"), se = j(({ client: e, experience: t }) => {
|
|
13
|
+
let n = N.store(t), r = T(n, { merge(e, t) {
|
|
13
14
|
return {
|
|
14
15
|
...e,
|
|
15
16
|
...t.experience
|
|
@@ -23,7 +24,7 @@ var M = T("experience"), ce = A(({ client: e, experience: t }) => {
|
|
|
23
24
|
steps: e.steps,
|
|
24
25
|
nodes: e.nodes,
|
|
25
26
|
edges: e.edges,
|
|
26
|
-
|
|
27
|
+
conditions: e.conditions
|
|
27
28
|
})), s = n.map((e) => e.fields), c = t.actions ?? [];
|
|
28
29
|
return {
|
|
29
30
|
id: t.id,
|
|
@@ -35,11 +36,11 @@ var M = T("experience"), ce = A(({ client: e, experience: t }) => {
|
|
|
35
36
|
merge: r.merge
|
|
36
37
|
};
|
|
37
38
|
});
|
|
38
|
-
function
|
|
39
|
-
return
|
|
39
|
+
function ce(e) {
|
|
40
|
+
return M(se, e);
|
|
40
41
|
}
|
|
41
|
-
var
|
|
42
|
-
let t =
|
|
42
|
+
var le = j(({ client: e }) => {
|
|
43
|
+
let t = N.store({}), n = T(t, { register(e, t) {
|
|
43
44
|
return {
|
|
44
45
|
...e,
|
|
45
46
|
[t.id]: t
|
|
@@ -54,7 +55,7 @@ var ue = A(({ client: e }) => {
|
|
|
54
55
|
});
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
|
-
let a =
|
|
58
|
+
let a = ce({
|
|
58
59
|
client: e,
|
|
59
60
|
experience: r
|
|
60
61
|
});
|
|
@@ -64,7 +65,7 @@ var ue = A(({ client: e }) => {
|
|
|
64
65
|
function a(e) {
|
|
65
66
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
66
67
|
}
|
|
67
|
-
let o =
|
|
68
|
+
let o = C({
|
|
68
69
|
source: t,
|
|
69
70
|
effect: async (t, { id: n, options: r }) => {
|
|
70
71
|
let i = t[n];
|
|
@@ -73,10 +74,10 @@ var ue = A(({ client: e }) => {
|
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
76
|
if (r?.bypassCondition) {
|
|
76
|
-
|
|
77
|
+
P(e, i, r);
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
|
-
await
|
|
80
|
+
await I(e, i) && P(e, i, r);
|
|
80
81
|
}
|
|
81
82
|
});
|
|
82
83
|
return {
|
|
@@ -84,7 +85,7 @@ var ue = A(({ client: e }) => {
|
|
|
84
85
|
get: a,
|
|
85
86
|
getById: a,
|
|
86
87
|
launch: o,
|
|
87
|
-
open:
|
|
88
|
+
open: C({
|
|
88
89
|
source: e.experienceInstances.listStore,
|
|
89
90
|
effect: (e, { id: t, options: n }) => {
|
|
90
91
|
let r = e.filter((e) => e.experienceId === t);
|
|
@@ -101,25 +102,25 @@ var ue = A(({ client: e }) => {
|
|
|
101
102
|
listStore: i
|
|
102
103
|
};
|
|
103
104
|
});
|
|
104
|
-
function
|
|
105
|
-
return
|
|
105
|
+
function ue(e) {
|
|
106
|
+
return M(le, e);
|
|
106
107
|
}
|
|
107
|
-
var
|
|
108
|
+
var de = (e, t) => {
|
|
108
109
|
t.register(e);
|
|
109
|
-
},
|
|
110
|
-
let { targetSelectors:
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
}, P = (e, t, n) => {
|
|
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) => {
|
|
113
|
+
n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
|
|
113
114
|
});
|
|
114
|
-
},
|
|
115
|
+
}, F = async (e) => {
|
|
115
116
|
await Promise.all(e.experiences.listStore.getState().map(async (t) => {
|
|
116
|
-
await
|
|
117
|
+
await I(e, t) && P(e, t);
|
|
117
118
|
}));
|
|
118
|
-
},
|
|
119
|
-
if (!
|
|
120
|
-
let { decisionLogic:
|
|
121
|
-
return a
|
|
122
|
-
},
|
|
119
|
+
}, I = async (n, r) => {
|
|
120
|
+
if (!n.preconditionPassed || !n.session?.isUser) return !1;
|
|
121
|
+
let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
|
|
122
|
+
return v(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
|
|
123
|
+
}, L = (e, t, n) => {
|
|
123
124
|
let r = t.name, i = t.setup(e);
|
|
124
125
|
if (i) {
|
|
125
126
|
let e = n[r] ?? {};
|
|
@@ -128,16 +129,16 @@ var fe = (e, t) => {
|
|
|
128
129
|
...i
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
|
-
},
|
|
132
|
+
}, R = E("component"), z = j(({ client: e, component: t, name: n }) => ({
|
|
132
133
|
name: n,
|
|
133
134
|
component: t,
|
|
134
135
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
135
136
|
}));
|
|
136
|
-
function
|
|
137
|
-
return
|
|
137
|
+
function B(e) {
|
|
138
|
+
return M(z, e);
|
|
138
139
|
}
|
|
139
|
-
var
|
|
140
|
-
let t =
|
|
140
|
+
var V = j(({ client: e }) => {
|
|
141
|
+
let t = R.store({}), n = T(t, { register(e, t) {
|
|
141
142
|
return {
|
|
142
143
|
...e,
|
|
143
144
|
[t.name]: t
|
|
@@ -145,7 +146,7 @@ var B = A(({ client: e }) => {
|
|
|
145
146
|
} });
|
|
146
147
|
function r(r, i) {
|
|
147
148
|
t.getState()[r] && `${r}`;
|
|
148
|
-
let a =
|
|
149
|
+
let a = B({
|
|
149
150
|
client: e,
|
|
150
151
|
name: r,
|
|
151
152
|
component: i
|
|
@@ -162,13 +163,13 @@ var B = A(({ client: e }) => {
|
|
|
162
163
|
listStore: i
|
|
163
164
|
};
|
|
164
165
|
});
|
|
165
|
-
function
|
|
166
|
-
return
|
|
166
|
+
function H(e) {
|
|
167
|
+
return M(V, e);
|
|
167
168
|
}
|
|
168
|
-
var
|
|
169
|
+
var U = (e, t, n) => {
|
|
169
170
|
n.register(e, t);
|
|
170
|
-
},
|
|
171
|
-
let t =
|
|
171
|
+
}, fe = E("framework"), pe = j(({ client: e }) => {
|
|
172
|
+
let t = fe.store({}), n = T(t, { register(e, t) {
|
|
172
173
|
return {
|
|
173
174
|
...e,
|
|
174
175
|
[t.name]: t.framework
|
|
@@ -190,21 +191,21 @@ var H = (e, t, n) => {
|
|
|
190
191
|
listStore: i
|
|
191
192
|
};
|
|
192
193
|
});
|
|
193
|
-
function
|
|
194
|
-
return
|
|
194
|
+
function me(e) {
|
|
195
|
+
return M(pe, e);
|
|
195
196
|
}
|
|
196
|
-
var
|
|
197
|
+
var he = (e, t) => {
|
|
197
198
|
t.register(e.name, e);
|
|
198
|
-
},
|
|
199
|
+
}, ge = 6e3, _e = S("last_ping", "global"), ve = async (e) => {
|
|
199
200
|
try {
|
|
200
|
-
let t = Date.now(), n =
|
|
201
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
201
|
+
let t = Date.now(), n = b.get(_e), r = 0;
|
|
202
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < ge) return !0;
|
|
202
203
|
let i = {
|
|
203
204
|
projectId: e.projectId,
|
|
204
205
|
path: window.location.pathname
|
|
205
206
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
206
207
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
207
|
-
let s = (await
|
|
208
|
+
let s = (await ie(e.apiUrl, "ping", i, a)).ok;
|
|
208
209
|
return s && n.set(t), s;
|
|
209
210
|
} catch {
|
|
210
211
|
return !1;
|
|
@@ -212,7 +213,7 @@ var ge = (e, t) => {
|
|
|
212
213
|
};
|
|
213
214
|
//#endregion
|
|
214
215
|
//#region src/utils/state-snaphot.ts
|
|
215
|
-
function
|
|
216
|
+
function W(e) {
|
|
216
217
|
let t = typeof window < "u", n = {
|
|
217
218
|
client: e,
|
|
218
219
|
responses: e.responses.listStore.getState(),
|
|
@@ -226,8 +227,8 @@ function U(e) {
|
|
|
226
227
|
}
|
|
227
228
|
//#endregion
|
|
228
229
|
//#region src/entities/predicate/predicate.ts
|
|
229
|
-
var
|
|
230
|
-
let t =
|
|
230
|
+
var ye = E("predicate"), be = j(({ client: e }) => {
|
|
231
|
+
let t = ye.store({}), n = T(t, { register(e, t) {
|
|
231
232
|
return {
|
|
232
233
|
...e,
|
|
233
234
|
[t.name]: {
|
|
@@ -247,22 +248,22 @@ var be = T("predicate"), xe = A(({ client: e }) => {
|
|
|
247
248
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
248
249
|
}
|
|
249
250
|
function o(t) {
|
|
250
|
-
let n =
|
|
251
|
+
let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
251
252
|
let n = a(t).getState();
|
|
252
253
|
if (!n) return;
|
|
253
|
-
let r =
|
|
254
|
+
let r = W(e);
|
|
254
255
|
return (...e) => n({
|
|
255
256
|
...r,
|
|
256
257
|
args: e
|
|
257
258
|
});
|
|
258
259
|
});
|
|
259
|
-
return
|
|
260
|
+
return A({
|
|
260
261
|
source: {
|
|
261
262
|
responses: e.responses.listStore,
|
|
262
263
|
fields: e.fields.listStore
|
|
263
264
|
},
|
|
264
265
|
target: r
|
|
265
|
-
}),
|
|
266
|
+
}), A({
|
|
266
267
|
clock: r.doneData,
|
|
267
268
|
filter: (e) => e !== void 0,
|
|
268
269
|
target: n
|
|
@@ -275,13 +276,13 @@ var be = T("predicate"), xe = A(({ client: e }) => {
|
|
|
275
276
|
getEvokablePredicate: o
|
|
276
277
|
};
|
|
277
278
|
});
|
|
278
|
-
function
|
|
279
|
-
return
|
|
279
|
+
function xe(e) {
|
|
280
|
+
return M(be, e);
|
|
280
281
|
}
|
|
281
|
-
var
|
|
282
|
+
var Se = (e, t, n) => {
|
|
282
283
|
n.register(e, t);
|
|
283
|
-
},
|
|
284
|
-
let t =
|
|
284
|
+
}, G = E("feature"), Ce = j(({ client: e }) => {
|
|
285
|
+
let t = G.store({}), n = G.store([]), r = T(t, { register(e, t) {
|
|
285
286
|
return {
|
|
286
287
|
...e,
|
|
287
288
|
[t.id]: t.feature
|
|
@@ -301,19 +302,19 @@ var Ce = (e, t, n) => {
|
|
|
301
302
|
feature: i
|
|
302
303
|
}));
|
|
303
304
|
}
|
|
304
|
-
let a =
|
|
305
|
-
let r =
|
|
305
|
+
let a = D(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
306
|
+
let r = S(`feature:${e}:${t}`, "global"), i = (n === "session" ? x : b).get(r).boolean();
|
|
306
307
|
return i === null ? null : {
|
|
307
308
|
id: e,
|
|
308
309
|
key: t,
|
|
309
310
|
bucket: i,
|
|
310
311
|
storage: n
|
|
311
312
|
};
|
|
312
|
-
}), o =
|
|
313
|
+
}), o = D((e) => {
|
|
313
314
|
if (!e) return null;
|
|
314
|
-
let t =
|
|
315
|
-
(e.storage === "session" ?
|
|
316
|
-
}), s = /* @__PURE__ */ new Map(), c =
|
|
315
|
+
let t = S(`feature:${e.id}:${e.key}`, "global");
|
|
316
|
+
(e.storage === "session" ? x : b).set(t, e.bucket);
|
|
317
|
+
}), s = /* @__PURE__ */ new Map(), c = C({
|
|
317
318
|
source: {
|
|
318
319
|
allFeaturesStore: t,
|
|
319
320
|
resolvedFeaturesStore: n
|
|
@@ -344,7 +345,7 @@ var Ce = (e, t, n) => {
|
|
|
344
345
|
};
|
|
345
346
|
}
|
|
346
347
|
});
|
|
347
|
-
|
|
348
|
+
A({
|
|
348
349
|
clock: r.register,
|
|
349
350
|
fn: (e) => {
|
|
350
351
|
let { id: t, feature: n } = e;
|
|
@@ -355,7 +356,7 @@ var Ce = (e, t, n) => {
|
|
|
355
356
|
};
|
|
356
357
|
},
|
|
357
358
|
target: a
|
|
358
|
-
}),
|
|
359
|
+
}), A({
|
|
359
360
|
source: t,
|
|
360
361
|
clock: c.doneData,
|
|
361
362
|
fn: (e, t) => {
|
|
@@ -369,7 +370,7 @@ var Ce = (e, t, n) => {
|
|
|
369
370
|
},
|
|
370
371
|
target: o
|
|
371
372
|
});
|
|
372
|
-
let l =
|
|
373
|
+
let l = w({
|
|
373
374
|
allFeaturesStore: t,
|
|
374
375
|
resolvedFeaturesStore: n
|
|
375
376
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -391,7 +392,7 @@ var Ce = (e, t, n) => {
|
|
|
391
392
|
isResolved: !1
|
|
392
393
|
};
|
|
393
394
|
}));
|
|
394
|
-
|
|
395
|
+
A({
|
|
395
396
|
clock: c.doneData,
|
|
396
397
|
source: { resolvedFeatures: n },
|
|
397
398
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
@@ -400,7 +401,7 @@ var Ce = (e, t, n) => {
|
|
|
400
401
|
type: "feature_decide",
|
|
401
402
|
feature: e
|
|
402
403
|
}))
|
|
403
|
-
}),
|
|
404
|
+
}), A({
|
|
404
405
|
clock: [a.doneData, c.doneData],
|
|
405
406
|
source: n,
|
|
406
407
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
@@ -413,15 +414,15 @@ var Ce = (e, t, n) => {
|
|
|
413
414
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
414
415
|
}
|
|
415
416
|
function f(e) {
|
|
416
|
-
let t =
|
|
417
|
+
let t = k(async () => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
417
418
|
let t = u(e).getState();
|
|
418
419
|
if (t) return async () => (await t.getBucket()).bucket;
|
|
419
420
|
});
|
|
420
|
-
return
|
|
421
|
+
return A({
|
|
421
422
|
source: n,
|
|
422
423
|
filter: (t) => t.some((t) => t.id === e),
|
|
423
424
|
target: r
|
|
424
|
-
}),
|
|
425
|
+
}), A({
|
|
425
426
|
clock: r.doneData,
|
|
426
427
|
filter: (e) => e !== void 0,
|
|
427
428
|
target: t
|
|
@@ -435,23 +436,23 @@ var Ce = (e, t, n) => {
|
|
|
435
436
|
getEvokableFeature: f
|
|
436
437
|
};
|
|
437
438
|
});
|
|
438
|
-
function
|
|
439
|
-
return
|
|
439
|
+
function we(e) {
|
|
440
|
+
return M(Ce, e);
|
|
440
441
|
}
|
|
441
|
-
var
|
|
442
|
+
var Te = (e, t, n) => {
|
|
442
443
|
n.register(e, t);
|
|
443
|
-
},
|
|
444
|
-
function
|
|
444
|
+
}, K = E("history");
|
|
445
|
+
function q(e, t) {
|
|
445
446
|
return {
|
|
446
|
-
id:
|
|
447
|
+
id: oe(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
447
448
|
node: t,
|
|
448
449
|
at: Date.now(),
|
|
449
450
|
experienceId: e
|
|
450
451
|
};
|
|
451
452
|
}
|
|
452
|
-
var
|
|
453
|
-
let e =
|
|
454
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
453
|
+
var Ee = j(() => {
|
|
454
|
+
let e = K.store({ entries: [] }), t = K.event(), n = K.event(), r = K.event(), i = K.event();
|
|
455
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, q(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), q(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
455
456
|
function a(e, t) {
|
|
456
457
|
let n = {
|
|
457
458
|
lastStepIndex: -1,
|
|
@@ -459,7 +460,7 @@ var De = A(() => {
|
|
|
459
460
|
};
|
|
460
461
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
461
462
|
let i = e[r], a = i?.node;
|
|
462
|
-
if (!(!a || !
|
|
463
|
+
if (!(!a || !y(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
463
464
|
else {
|
|
464
465
|
n.secondLastStepIndex = r;
|
|
465
466
|
break;
|
|
@@ -481,38 +482,47 @@ var De = A(() => {
|
|
|
481
482
|
entriesStore: e.map((e) => e.entries)
|
|
482
483
|
};
|
|
483
484
|
});
|
|
484
|
-
function
|
|
485
|
-
return
|
|
485
|
+
function J() {
|
|
486
|
+
return M(Ee);
|
|
486
487
|
}
|
|
487
488
|
//#endregion
|
|
488
489
|
//#region src/utils/events.ts
|
|
489
|
-
var
|
|
490
|
-
let t =
|
|
491
|
-
return
|
|
490
|
+
var De = 0, Oe = (e) => {
|
|
491
|
+
let t = k([]);
|
|
492
|
+
return A({
|
|
492
493
|
clock: e,
|
|
493
494
|
source: t,
|
|
494
495
|
fn: (e, t) => [...e, {
|
|
495
|
-
id:
|
|
496
|
+
id: De++,
|
|
496
497
|
at: /* @__PURE__ */ new Date(),
|
|
497
498
|
payload: t
|
|
498
499
|
}],
|
|
499
500
|
target: t
|
|
500
501
|
}), t;
|
|
501
|
-
},
|
|
502
|
-
let e =
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
502
|
+
}, ke = E("field"), Ae = j(() => {
|
|
503
|
+
let e = ke.store({}), t = T(e, {
|
|
504
|
+
register(e, t) {
|
|
505
|
+
return {
|
|
506
|
+
...e,
|
|
507
|
+
[t.field.id]: t.field
|
|
508
|
+
};
|
|
509
|
+
},
|
|
510
|
+
updateById(e, t) {
|
|
511
|
+
let n = e[t.fieldId];
|
|
512
|
+
return n ? {
|
|
513
|
+
...e,
|
|
514
|
+
[t.fieldId]: Object.assign({}, n, t.updates)
|
|
515
|
+
} : e;
|
|
516
|
+
}
|
|
517
|
+
});
|
|
508
518
|
function n(e) {
|
|
509
519
|
t.register({ field: e });
|
|
510
520
|
}
|
|
511
521
|
function r(e, n) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
522
|
+
t.updateById({
|
|
523
|
+
fieldId: e,
|
|
524
|
+
updates: n
|
|
525
|
+
});
|
|
516
526
|
}
|
|
517
527
|
let i = e.map((e) => Object.values(e));
|
|
518
528
|
function a(t) {
|
|
@@ -529,13 +539,13 @@ var ke = 0, Ae = (e) => {
|
|
|
529
539
|
getByName: o
|
|
530
540
|
};
|
|
531
541
|
});
|
|
532
|
-
function
|
|
533
|
-
return
|
|
542
|
+
function je() {
|
|
543
|
+
return M(Ae);
|
|
534
544
|
}
|
|
535
|
-
var
|
|
545
|
+
var Me = (e, t) => {
|
|
536
546
|
t.register(e);
|
|
537
|
-
},
|
|
538
|
-
let e =
|
|
547
|
+
}, Ne = E("action"), Pe = j(() => {
|
|
548
|
+
let e = Ne.store({}), t = T(e, { register(e, t) {
|
|
539
549
|
return {
|
|
540
550
|
...e,
|
|
541
551
|
[t.name]: {
|
|
@@ -567,29 +577,29 @@ var Pe = (e, t) => {
|
|
|
567
577
|
getEvokableAction: a
|
|
568
578
|
};
|
|
569
579
|
});
|
|
570
|
-
function
|
|
571
|
-
return
|
|
580
|
+
function Fe() {
|
|
581
|
+
return M(Pe);
|
|
572
582
|
}
|
|
573
|
-
var
|
|
583
|
+
var Ie = (e, t, n) => {
|
|
574
584
|
n.register(e, t);
|
|
575
585
|
};
|
|
576
586
|
//#endregion
|
|
577
587
|
//#region src/entities/response/response.ts
|
|
578
|
-
function
|
|
588
|
+
function Y(e) {
|
|
579
589
|
return e == null || e === "" || Array.isArray(e) && !e.length;
|
|
580
590
|
}
|
|
581
|
-
function
|
|
591
|
+
function Le(e) {
|
|
582
592
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
583
593
|
}
|
|
584
|
-
function
|
|
594
|
+
function X(e) {
|
|
585
595
|
try {
|
|
586
596
|
return JSON.stringify(e), !0;
|
|
587
597
|
} catch {
|
|
588
598
|
return !1;
|
|
589
599
|
}
|
|
590
600
|
}
|
|
591
|
-
var
|
|
592
|
-
let
|
|
601
|
+
var Re = E("response"), ze = j(({ client: e }) => {
|
|
602
|
+
let r = Re.store({}), i = O(), a = O(), o = T(r, {
|
|
593
603
|
register(e, t) {
|
|
594
604
|
return {
|
|
595
605
|
...e,
|
|
@@ -610,196 +620,215 @@ var Be = T("response"), Ve = A(({ client: e }) => {
|
|
|
610
620
|
return {};
|
|
611
621
|
}
|
|
612
622
|
});
|
|
613
|
-
function
|
|
623
|
+
function s(e, t) {
|
|
614
624
|
if (typeof e == "string") {
|
|
615
625
|
if (t === void 0) throw Error("Response is required when registering a single field");
|
|
616
|
-
|
|
626
|
+
o.register({
|
|
617
627
|
fieldId: e,
|
|
618
628
|
response: t
|
|
619
629
|
});
|
|
620
|
-
} else
|
|
630
|
+
} else o.registerBatch(e);
|
|
621
631
|
}
|
|
622
|
-
async function
|
|
623
|
-
let
|
|
624
|
-
return await Promise.allSettled(Object.entries(
|
|
625
|
-
let
|
|
626
|
-
if (!
|
|
627
|
-
|
|
628
|
-
fieldId:
|
|
629
|
-
userMessage: `Field '${
|
|
630
|
-
systemMessage: `No field with ID '${
|
|
631
|
-
value:
|
|
632
|
+
async function c(r, i) {
|
|
633
|
+
let a = [];
|
|
634
|
+
return await Promise.allSettled(Object.entries(i).map(async ([o, s]) => {
|
|
635
|
+
let c = s, l = e.fields.getById(o).getState();
|
|
636
|
+
if (!l) {
|
|
637
|
+
a.push({
|
|
638
|
+
fieldId: o,
|
|
639
|
+
userMessage: `Field '${o}' not found`,
|
|
640
|
+
systemMessage: `No field with ID '${o}' exists. Available field IDs are: ${Object.keys(e.fields.listStore.getState()).join(",")}.`,
|
|
641
|
+
value: c
|
|
632
642
|
});
|
|
633
643
|
return;
|
|
634
644
|
}
|
|
635
|
-
if (
|
|
636
|
-
let
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
645
|
+
if (l.multiple && (typeof c == "string" || typeof c == "number" || typeof c == "boolean") && (c = [c]), l.validation && !n(l.validation) && !Y(c)) {
|
|
646
|
+
let n = {
|
|
647
|
+
...r,
|
|
648
|
+
...i
|
|
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
|
|
643
659
|
});
|
|
644
660
|
return;
|
|
645
661
|
}
|
|
646
|
-
if (
|
|
647
|
-
|
|
648
|
-
fieldId:
|
|
662
|
+
if (s === !1) {
|
|
663
|
+
a.push({
|
|
664
|
+
fieldId: o,
|
|
649
665
|
userMessage: "This field is invalid",
|
|
650
666
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
651
|
-
value:
|
|
667
|
+
value: c
|
|
652
668
|
});
|
|
653
669
|
return;
|
|
654
670
|
}
|
|
655
671
|
}
|
|
656
|
-
if (
|
|
657
|
-
|
|
658
|
-
fieldId:
|
|
672
|
+
if (l.required && Y(c)) {
|
|
673
|
+
a.push({
|
|
674
|
+
fieldId: o,
|
|
659
675
|
userMessage: "This field is required",
|
|
660
676
|
systemMessage: "Field is required.",
|
|
661
|
-
value:
|
|
677
|
+
value: c
|
|
662
678
|
});
|
|
663
679
|
return;
|
|
664
680
|
}
|
|
665
|
-
if (!
|
|
666
|
-
|
|
667
|
-
fieldId:
|
|
681
|
+
if (!l.multiple && Array.isArray(c) && c.length > 1) {
|
|
682
|
+
a.push({
|
|
683
|
+
fieldId: o,
|
|
668
684
|
userMessage: "This field expects a single response",
|
|
669
685
|
systemMessage: "Field expects a single response.",
|
|
670
|
-
value:
|
|
686
|
+
value: c
|
|
671
687
|
});
|
|
672
688
|
return;
|
|
673
689
|
}
|
|
674
|
-
if (
|
|
675
|
-
if (!Array.isArray(
|
|
676
|
-
|
|
677
|
-
fieldId:
|
|
690
|
+
if (l.type === "object" && !Y(c)) if (l.multiple) {
|
|
691
|
+
if (!Array.isArray(c)) {
|
|
692
|
+
a.push({
|
|
693
|
+
fieldId: o,
|
|
678
694
|
userMessage: "This field expects multiple values",
|
|
679
695
|
systemMessage: "Field expects an array of objects.",
|
|
680
|
-
value:
|
|
696
|
+
value: c
|
|
681
697
|
});
|
|
682
698
|
return;
|
|
683
699
|
}
|
|
684
|
-
for (let e of
|
|
700
|
+
for (let e of c) {
|
|
685
701
|
if (typeof e != "object" || !e) {
|
|
686
|
-
|
|
687
|
-
fieldId:
|
|
702
|
+
a.push({
|
|
703
|
+
fieldId: o,
|
|
688
704
|
userMessage: "This field expects object values",
|
|
689
705
|
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
690
|
-
value:
|
|
706
|
+
value: c
|
|
691
707
|
});
|
|
692
708
|
return;
|
|
693
709
|
}
|
|
694
|
-
if (!
|
|
695
|
-
|
|
696
|
-
fieldId:
|
|
710
|
+
if (!X(e)) {
|
|
711
|
+
a.push({
|
|
712
|
+
fieldId: o,
|
|
697
713
|
userMessage: "This field contains non-serializable data",
|
|
698
714
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
699
|
-
value:
|
|
715
|
+
value: c
|
|
700
716
|
});
|
|
701
717
|
return;
|
|
702
718
|
}
|
|
703
719
|
}
|
|
704
720
|
} else {
|
|
705
|
-
if (Array.isArray(
|
|
706
|
-
|
|
707
|
-
fieldId:
|
|
721
|
+
if (Array.isArray(c)) {
|
|
722
|
+
a.push({
|
|
723
|
+
fieldId: o,
|
|
708
724
|
userMessage: "This field expects a single value",
|
|
709
725
|
systemMessage: "Field expects a single object, not an array.",
|
|
710
|
-
value:
|
|
726
|
+
value: c
|
|
711
727
|
});
|
|
712
728
|
return;
|
|
713
729
|
}
|
|
714
|
-
if (typeof
|
|
715
|
-
|
|
716
|
-
fieldId:
|
|
730
|
+
if (typeof c != "object" || !c) {
|
|
731
|
+
a.push({
|
|
732
|
+
fieldId: o,
|
|
717
733
|
userMessage: "This field expects an object value",
|
|
718
734
|
systemMessage: "Field expects an object value.",
|
|
719
|
-
value:
|
|
735
|
+
value: c
|
|
720
736
|
});
|
|
721
737
|
return;
|
|
722
738
|
}
|
|
723
|
-
if (!
|
|
724
|
-
|
|
725
|
-
fieldId:
|
|
739
|
+
if (!X(c)) {
|
|
740
|
+
a.push({
|
|
741
|
+
fieldId: o,
|
|
726
742
|
userMessage: "This field contains non-serializable data",
|
|
727
743
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
728
|
-
value:
|
|
744
|
+
value: c
|
|
729
745
|
});
|
|
730
746
|
return;
|
|
731
747
|
}
|
|
732
748
|
}
|
|
733
|
-
if (Array.isArray(
|
|
734
|
-
let e = Array.isArray(
|
|
735
|
-
if (
|
|
736
|
-
let
|
|
737
|
-
e.every((e) =>
|
|
738
|
-
fieldId:
|
|
749
|
+
if (Array.isArray(l.options) && l.options.length > 0) {
|
|
750
|
+
let e = Array.isArray(c) ? c : [c];
|
|
751
|
+
if (l.type === "object") {
|
|
752
|
+
let t = l.options.map((e) => JSON.stringify(e.value));
|
|
753
|
+
e.every((e) => t.includes(JSON.stringify(e))) || a.push({
|
|
754
|
+
fieldId: o,
|
|
739
755
|
userMessage: "This field expects a valid option",
|
|
740
756
|
systemMessage: "Field expects a valid option from the defined choices.",
|
|
741
|
-
value:
|
|
757
|
+
value: c
|
|
742
758
|
});
|
|
743
759
|
} else {
|
|
744
|
-
let
|
|
745
|
-
e.every((e) => !
|
|
746
|
-
fieldId:
|
|
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,
|
|
747
763
|
userMessage: "This field expects a valid option",
|
|
748
|
-
systemMessage: `Field expects a valid option. Valid options are: ${
|
|
749
|
-
value:
|
|
764
|
+
systemMessage: `Field expects a valid option. Valid options are: ${t.join(", ")}`,
|
|
765
|
+
value: c
|
|
750
766
|
});
|
|
751
767
|
}
|
|
752
768
|
}
|
|
753
769
|
})), {
|
|
754
|
-
responsesToCommit:
|
|
755
|
-
validationErrors:
|
|
770
|
+
responsesToCommit: i,
|
|
771
|
+
validationErrors: a
|
|
756
772
|
};
|
|
757
773
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
774
|
+
let l = C({
|
|
775
|
+
source: r,
|
|
776
|
+
effect: (e, t) => c(e, t)
|
|
777
|
+
});
|
|
778
|
+
async function u(e) {
|
|
779
|
+
return l(e);
|
|
780
|
+
}
|
|
781
|
+
let d = C({
|
|
782
|
+
source: r,
|
|
783
|
+
effect: async (e, t) => {
|
|
784
|
+
let { responsesToCommit: n, validationErrors: r } = await c(e, t);
|
|
785
|
+
return r.length ? { errors: r } : (o.registerBatch(n), { errors: [] });
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
async function f(e) {
|
|
789
|
+
return d(e);
|
|
761
790
|
}
|
|
762
|
-
let
|
|
791
|
+
let p = r.map((e) => e), m = r.map((e) => Object.keys(e).map((t) => ({
|
|
763
792
|
fieldId: t,
|
|
764
793
|
value: e[t]
|
|
765
794
|
})));
|
|
766
|
-
function
|
|
767
|
-
return
|
|
768
|
-
f: e.fields.getById(
|
|
769
|
-
r:
|
|
795
|
+
function h(t) {
|
|
796
|
+
return w({
|
|
797
|
+
f: e.fields.getById(t),
|
|
798
|
+
r: r.map((e) => e[t] || null)
|
|
770
799
|
}, ({ f: e, r: t }) => t || (e?.defaultValue ? e.defaultValue : null));
|
|
771
800
|
}
|
|
772
|
-
function
|
|
773
|
-
return
|
|
774
|
-
f: e.fields.getByName(
|
|
775
|
-
s:
|
|
801
|
+
function g(t) {
|
|
802
|
+
return w({
|
|
803
|
+
f: e.fields.getByName(t),
|
|
804
|
+
s: r
|
|
776
805
|
}, ({ f: e, s: t }) => e && t[e.id] || (e?.defaultValue ? e.defaultValue : null));
|
|
777
806
|
}
|
|
778
|
-
return
|
|
779
|
-
clock: n,
|
|
780
|
-
target: a.clearAll
|
|
781
|
-
}), k({
|
|
807
|
+
return A({
|
|
782
808
|
clock: i,
|
|
783
|
-
target:
|
|
809
|
+
target: o.clearAll
|
|
810
|
+
}), A({
|
|
811
|
+
clock: a,
|
|
812
|
+
target: o.clear
|
|
784
813
|
}), {
|
|
785
|
-
register:
|
|
786
|
-
clearAll:
|
|
787
|
-
clear:
|
|
788
|
-
commit:
|
|
789
|
-
getResponsesToCommit:
|
|
790
|
-
listStore:
|
|
791
|
-
getAllStore:
|
|
792
|
-
getByFieldId:
|
|
793
|
-
getByFieldName:
|
|
814
|
+
register: s,
|
|
815
|
+
clearAll: i,
|
|
816
|
+
clear: a,
|
|
817
|
+
commit: f,
|
|
818
|
+
getResponsesToCommit: u,
|
|
819
|
+
listStore: m,
|
|
820
|
+
getAllStore: p,
|
|
821
|
+
getByFieldId: h,
|
|
822
|
+
getByFieldName: g
|
|
794
823
|
};
|
|
795
824
|
});
|
|
796
|
-
function
|
|
797
|
-
return
|
|
825
|
+
function Be(e) {
|
|
826
|
+
return M(ze, e);
|
|
798
827
|
}
|
|
799
828
|
//#endregion
|
|
800
829
|
//#region src/utils/api-url.ts
|
|
801
|
-
function
|
|
802
|
-
if (
|
|
830
|
+
function Ve() {
|
|
831
|
+
if (f()) {
|
|
803
832
|
let e = [
|
|
804
833
|
document.currentScript,
|
|
805
834
|
document.getElementById("picked_script"),
|
|
@@ -813,36 +842,36 @@ function Ue() {
|
|
|
813
842
|
}
|
|
814
843
|
//#endregion
|
|
815
844
|
//#region src/utils/search-params.ts
|
|
816
|
-
function
|
|
817
|
-
if (!
|
|
845
|
+
function He() {
|
|
846
|
+
if (!o()) return {};
|
|
818
847
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
819
848
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
820
849
|
for (let r of n) {
|
|
821
850
|
let n = r.replace("picked-", "");
|
|
822
851
|
t[n] = e.getAll(r);
|
|
823
852
|
}
|
|
824
|
-
let r =
|
|
825
|
-
if (n.size > 0)
|
|
853
|
+
let r = S("s");
|
|
854
|
+
if (n.size > 0) x.set(r, t);
|
|
826
855
|
else {
|
|
827
|
-
let e =
|
|
856
|
+
let e = x.get(r);
|
|
828
857
|
if (e) return e.json() || {};
|
|
829
858
|
}
|
|
830
859
|
return t;
|
|
831
860
|
}
|
|
832
861
|
//#endregion
|
|
833
862
|
//#region src/utils/user-session.ts
|
|
834
|
-
function
|
|
835
|
-
return
|
|
863
|
+
function Ue() {
|
|
864
|
+
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)}`;
|
|
836
865
|
}
|
|
837
|
-
var
|
|
838
|
-
let e =
|
|
866
|
+
var We = S("session", "global"), Ge = () => {
|
|
867
|
+
let e = b.get(We), t;
|
|
839
868
|
e.isSet() && (t = e.json());
|
|
840
869
|
let n = (t) => e.set({
|
|
841
870
|
id: t.id,
|
|
842
871
|
isUser: t.isUser,
|
|
843
872
|
identifiers: t.identifiers
|
|
844
873
|
}), r = {
|
|
845
|
-
id: t?.id ??
|
|
874
|
+
id: t?.id ?? Ue(),
|
|
846
875
|
isUser: t?.isUser ?? void 0,
|
|
847
876
|
identifiers: t?.identifiers ?? void 0,
|
|
848
877
|
setIsUser(e) {
|
|
@@ -859,22 +888,22 @@ var Ke = b("session", "global"), qe = () => {
|
|
|
859
888
|
}
|
|
860
889
|
};
|
|
861
890
|
return n(r), r;
|
|
862
|
-
},
|
|
891
|
+
}, Ke = () => u() ? Ge() : null;
|
|
863
892
|
//#endregion
|
|
864
893
|
//#region src/utils/picked-config.ts
|
|
865
|
-
function
|
|
866
|
-
if (
|
|
894
|
+
function Z() {
|
|
895
|
+
if (o()) return globalThis.window.pickedConfig;
|
|
867
896
|
}
|
|
868
|
-
function
|
|
869
|
-
if (!
|
|
870
|
-
let e =
|
|
897
|
+
function qe() {
|
|
898
|
+
if (!o()) return;
|
|
899
|
+
let e = Z(), t = e?.organizationId, n = e?.projectId;
|
|
871
900
|
return t && n ? {
|
|
872
901
|
organizationId: t,
|
|
873
902
|
projectId: n
|
|
874
903
|
} : void 0;
|
|
875
904
|
}
|
|
876
|
-
function
|
|
877
|
-
if (!
|
|
905
|
+
function Je() {
|
|
906
|
+
if (!f()) return;
|
|
878
907
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
879
908
|
if (!e) return;
|
|
880
909
|
let t = e.dataset.organizationid || e.getAttribute("organization-id"), n = e.dataset.projectid || e.getAttribute("project-id");
|
|
@@ -883,27 +912,27 @@ function Xe() {
|
|
|
883
912
|
projectId: n
|
|
884
913
|
} : void 0;
|
|
885
914
|
}
|
|
886
|
-
function
|
|
915
|
+
function Ye(e) {
|
|
887
916
|
let { organizationId: t, projectId: n } = e;
|
|
888
917
|
if (t && n) return {
|
|
889
918
|
organizationId: t,
|
|
890
919
|
projectId: n
|
|
891
920
|
};
|
|
892
|
-
let r =
|
|
921
|
+
let r = qe();
|
|
893
922
|
if (r) return r;
|
|
894
|
-
let i =
|
|
923
|
+
let i = Je();
|
|
895
924
|
if (i) return i;
|
|
896
925
|
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.");
|
|
897
926
|
}
|
|
898
927
|
//#endregion
|
|
899
928
|
//#region src/utils/render-string.ts
|
|
900
|
-
function
|
|
929
|
+
function Q(e) {
|
|
901
930
|
return e == null || e === "" || Number.isNaN(e);
|
|
902
931
|
}
|
|
903
|
-
var
|
|
904
|
-
default: (e, t) =>
|
|
905
|
-
append: (e, t) => t && !
|
|
906
|
-
prepend: (e, t) => t && !
|
|
932
|
+
var Xe = {
|
|
933
|
+
default: (e, t) => Q(e) ? String(t ?? "") : String(e),
|
|
934
|
+
append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
|
|
935
|
+
prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
|
|
907
936
|
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
908
937
|
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
909
938
|
capitalize: (e) => typeof e == "string" ? e.charAt(0).toUpperCase() + e.slice(1) : e,
|
|
@@ -921,24 +950,24 @@ var Qe = {
|
|
|
921
950
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
922
951
|
}
|
|
923
952
|
};
|
|
924
|
-
function
|
|
953
|
+
function Ze(e) {
|
|
925
954
|
return typeof e == "object" && !!e;
|
|
926
955
|
}
|
|
927
|
-
function
|
|
956
|
+
function Qe(e, t) {
|
|
928
957
|
let n = t;
|
|
929
|
-
for (let t of e.split(".")) if (
|
|
958
|
+
for (let t of e.split(".")) if (Ze(n) && t in n) n = n[t];
|
|
930
959
|
else return;
|
|
931
960
|
return typeof n == "function" ? n() : n;
|
|
932
961
|
}
|
|
933
|
-
function
|
|
934
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
962
|
+
function $e(e, t) {
|
|
963
|
+
let n = e.split("|").map((e) => e.trim()), r = Qe(n.shift() ?? "", t);
|
|
935
964
|
for (let e of n) {
|
|
936
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
965
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Xe[i];
|
|
937
966
|
o && (r = o(r, a));
|
|
938
967
|
}
|
|
939
|
-
return
|
|
968
|
+
return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
940
969
|
}
|
|
941
|
-
function
|
|
970
|
+
function et(e, t) {
|
|
942
971
|
let n = "", r = 0;
|
|
943
972
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
944
973
|
r += 2;
|
|
@@ -950,20 +979,19 @@ function Z(e, t) {
|
|
|
950
979
|
}
|
|
951
980
|
i += e[r++];
|
|
952
981
|
}
|
|
953
|
-
n +=
|
|
982
|
+
n += $e(i.trim(), t);
|
|
954
983
|
} else n += e[r++];
|
|
955
984
|
return n;
|
|
956
985
|
}
|
|
957
986
|
//#endregion
|
|
958
987
|
//#region src/picked.ts
|
|
959
|
-
var
|
|
960
|
-
static logger =
|
|
988
|
+
var $ = class {
|
|
989
|
+
static logger = r;
|
|
961
990
|
options;
|
|
962
991
|
isReady = !1;
|
|
963
|
-
project;
|
|
964
992
|
plugins = {};
|
|
965
993
|
pluginStartHooks = [];
|
|
966
|
-
eventBus =
|
|
994
|
+
eventBus = O();
|
|
967
995
|
events;
|
|
968
996
|
organizationId;
|
|
969
997
|
projectId;
|
|
@@ -974,42 +1002,42 @@ var Q = class {
|
|
|
974
1002
|
precondition;
|
|
975
1003
|
condition;
|
|
976
1004
|
preconditionPassed;
|
|
977
|
-
searchParams =
|
|
978
|
-
history =
|
|
979
|
-
components =
|
|
980
|
-
experienceInstances =
|
|
981
|
-
experiences =
|
|
982
|
-
frameworks =
|
|
983
|
-
predicates =
|
|
984
|
-
features =
|
|
985
|
-
responses =
|
|
986
|
-
fields =
|
|
987
|
-
actions =
|
|
1005
|
+
searchParams = He();
|
|
1006
|
+
history = J();
|
|
1007
|
+
components = H({ client: this });
|
|
1008
|
+
experienceInstances = _({ client: this });
|
|
1009
|
+
experiences = ue({ client: this });
|
|
1010
|
+
frameworks = me({ client: this });
|
|
1011
|
+
predicates = xe({ client: this });
|
|
1012
|
+
features = we({ client: this });
|
|
1013
|
+
responses = Be({ client: this });
|
|
1014
|
+
fields = je();
|
|
1015
|
+
actions = Fe();
|
|
988
1016
|
constructor(e) {
|
|
989
|
-
this.events =
|
|
990
|
-
let { organizationId: t, projectId: n } =
|
|
991
|
-
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl ||
|
|
1017
|
+
this.events = Oe(this.eventBus);
|
|
1018
|
+
let { organizationId: t, projectId: n } = Ye(e);
|
|
1019
|
+
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Ve(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = Ke(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
|
|
992
1020
|
type: "load",
|
|
993
|
-
version:
|
|
1021
|
+
version: ae()
|
|
994
1022
|
});
|
|
995
1023
|
}
|
|
996
1024
|
start = () => {
|
|
997
|
-
|
|
998
|
-
if (!
|
|
1025
|
+
ve(this), (async () => {
|
|
1026
|
+
if (!f()) return;
|
|
999
1027
|
await this.runPluginStartHooks();
|
|
1000
|
-
let
|
|
1001
|
-
this.preconditionPassed =
|
|
1002
|
-
let
|
|
1003
|
-
|
|
1004
|
-
let
|
|
1005
|
-
if (typeof
|
|
1006
|
-
let e =
|
|
1028
|
+
let e = await this.evaluateGate(this.precondition);
|
|
1029
|
+
this.preconditionPassed = e;
|
|
1030
|
+
let t;
|
|
1031
|
+
e && (t = await this.evaluateGate(this.condition));
|
|
1032
|
+
let n = e && t === !0;
|
|
1033
|
+
if (typeof t == "boolean" && this.session) {
|
|
1034
|
+
let e = t;
|
|
1007
1035
|
this.session.setIsUser(e), this.eventBus({
|
|
1008
1036
|
type: "user_decide",
|
|
1009
1037
|
value: e
|
|
1010
1038
|
});
|
|
1011
1039
|
}
|
|
1012
|
-
if (this.eventBus({ type: "initialize" }),
|
|
1040
|
+
if (this.eventBus({ type: "initialize" }), n && F(this), await g(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1013
1041
|
let { id: e, isUser: t, identifiers: n } = this.session;
|
|
1014
1042
|
this.eventBus({
|
|
1015
1043
|
type: "session",
|
|
@@ -1021,32 +1049,32 @@ var Q = class {
|
|
|
1021
1049
|
})();
|
|
1022
1050
|
};
|
|
1023
1051
|
registerFramework = (e) => {
|
|
1024
|
-
|
|
1052
|
+
he(e, this.frameworks);
|
|
1025
1053
|
};
|
|
1026
1054
|
registerComponent = (e, t) => {
|
|
1027
|
-
|
|
1055
|
+
U(e, t, this.components);
|
|
1028
1056
|
};
|
|
1029
1057
|
registerPlugin = (e) => {
|
|
1030
|
-
|
|
1058
|
+
L(this, e, this.plugins);
|
|
1031
1059
|
let t = this.plugins[e.name];
|
|
1032
1060
|
t?.onStart && this.pluginStartHooks.push(t.onStart);
|
|
1033
1061
|
};
|
|
1034
1062
|
registerFeature = (e, t) => {
|
|
1035
|
-
|
|
1063
|
+
Te(e, t, this.features);
|
|
1036
1064
|
};
|
|
1037
1065
|
registerPredicate = (e, t) => {
|
|
1038
|
-
|
|
1066
|
+
Se(e, t, this.predicates);
|
|
1039
1067
|
};
|
|
1040
1068
|
registerField = (e) => {
|
|
1041
|
-
|
|
1069
|
+
Me(e, this.fields);
|
|
1042
1070
|
};
|
|
1043
1071
|
registerAction = (e, t) => {
|
|
1044
|
-
|
|
1072
|
+
Ie(e, t, this.actions);
|
|
1045
1073
|
};
|
|
1046
1074
|
registerExperience = (e) => {
|
|
1047
|
-
e.component &&
|
|
1075
|
+
e.component && U(`experience:${e.id}`, e.component, this.components), de(e, this.experiences);
|
|
1048
1076
|
};
|
|
1049
|
-
getStateSnapshot = () =>
|
|
1077
|
+
getStateSnapshot = () => W(this);
|
|
1050
1078
|
launchExperienceById = async (e, t) => {
|
|
1051
1079
|
this.experiences.launch({
|
|
1052
1080
|
id: e,
|
|
@@ -1060,7 +1088,7 @@ var Q = class {
|
|
|
1060
1088
|
for (let e of this.pluginStartHooks) await e();
|
|
1061
1089
|
}
|
|
1062
1090
|
async evaluateGate(e) {
|
|
1063
|
-
return e === void 0 ? !0 : typeof e == "boolean" ? e : await
|
|
1091
|
+
return e === void 0 ? !0 : typeof e == "boolean" ? e : await t(this, e) === !0;
|
|
1064
1092
|
}
|
|
1065
1093
|
setupPlugins() {
|
|
1066
1094
|
this.options.plugins?.forEach((e) => {
|
|
@@ -1126,47 +1154,28 @@ var Q = class {
|
|
|
1126
1154
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1127
1155
|
renderString = (e, t) => {
|
|
1128
1156
|
let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldId] = t.value, e), {});
|
|
1129
|
-
return
|
|
1157
|
+
return et(e, {
|
|
1130
1158
|
...t,
|
|
1131
1159
|
responses: n
|
|
1132
1160
|
});
|
|
1133
1161
|
};
|
|
1134
1162
|
};
|
|
1135
1163
|
//#endregion
|
|
1136
|
-
//#region src/utils/get-step-fields.ts
|
|
1137
|
-
function $(e) {
|
|
1138
|
-
return e.options?.some((e) => "condition" in e) ?? !1;
|
|
1139
|
-
}
|
|
1140
|
-
function nt(e) {
|
|
1141
|
-
return e.some((e) => e.condition || $(e));
|
|
1142
|
-
}
|
|
1143
|
-
async function rt(e, t) {
|
|
1144
|
-
return t.length === 0 || !nt(t) ? t : (await Promise.all(t.map(async (t) => {
|
|
1145
|
-
if (!(!t.condition || await r(e, t.condition))) return null;
|
|
1146
|
-
if (!t.options || !$(t)) return t;
|
|
1147
|
-
let n = (await Promise.all(t.options.map(async (t) => t.condition ? await r(e, t.condition) ? t : null : t))).filter((e) => e !== null);
|
|
1148
|
-
return n.length === t.options.length ? t : n.length === 0 ? null : {
|
|
1149
|
-
...t,
|
|
1150
|
-
options: n
|
|
1151
|
-
};
|
|
1152
|
-
}))).filter((e) => e !== null);
|
|
1153
|
-
}
|
|
1154
|
-
//#endregion
|
|
1155
1164
|
//#region src/entities/component/lazyComponent.ts
|
|
1156
|
-
function
|
|
1165
|
+
function tt(e) {
|
|
1157
1166
|
return {
|
|
1158
1167
|
$$type: "lazy-component",
|
|
1159
1168
|
load: e
|
|
1160
1169
|
};
|
|
1161
1170
|
}
|
|
1162
|
-
function
|
|
1171
|
+
function nt(e) {
|
|
1163
1172
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1164
1173
|
}
|
|
1165
1174
|
//#endregion
|
|
1166
1175
|
//#region src/exports.ts
|
|
1167
|
-
var
|
|
1168
|
-
let t = new
|
|
1169
|
-
return
|
|
1176
|
+
var rt = (e) => {
|
|
1177
|
+
let t = new $(e);
|
|
1178
|
+
return d(t), t;
|
|
1170
1179
|
};
|
|
1171
1180
|
//#endregion
|
|
1172
|
-
export {
|
|
1181
|
+
export { $ as Picked, rt as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, nt as isLazyLoader, ne as isPickedRoot, tt as lazyComponent, b as localStore, x as sessionStore, re 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 };
|