@picked/client 0.0.1-dev.1777601813342 → 0.0.1-dev.1777602638912
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-CiR56vZg.js → api-5yb5p-eh.js} +1 -1
- package/dist/{api-BAOO2VZv.cjs → api-AgvW9_WG.cjs} +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/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/plugins/window-object/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/form/index.js +32 -17
- package/dist/esm/index.js +307 -181
- package/dist/esm/plugins/create-experience/index.js +1 -1
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/plugins/experience-browser-storage/index.js +2 -2
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-indexeddb/index.js +1 -1
- package/dist/esm/plugins/single-page-app/index.js +25 -93
- package/dist/esm/plugins/web-components/index.js +2 -2
- package/dist/esm/plugins/window-object/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-DC2gKwA6.cjs +1 -0
- package/dist/experience-instance-DJaNc5Ob.js +486 -0
- package/dist/object-C82v79xc.js +25 -0
- package/dist/object-CUJOjanb.cjs +1 -0
- package/dist/rules-logic-BTIxfrJJ.js +240 -0
- package/dist/rules-logic-DNLOv90w.cjs +1 -0
- package/dist/{supports-DUJbucFW.js → supports-0XIfd4-R.js} +9 -18
- package/dist/supports-Dsjg-82e.cjs +1 -0
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/framework/framework.d.ts +0 -12
- package/dist/types/entities/framework/framework.d.ts.map +1 -1
- package/dist/types/form/create-form.d.ts +32 -0
- package/dist/types/form/create-form.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/index.d.ts +1 -2
- package/dist/types/plugins/single-page-app/index.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +9 -92
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/global-obj.d.ts +0 -5
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/supports.d.ts +0 -113
- package/dist/types/utils/supports.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/experience-CR19HpPg.js +0 -136
- package/dist/experience-DOWnsvA1.cjs +0 -1
- package/dist/experience-instance-C2jZU8ho.cjs +0 -1
- package/dist/experience-instance-CGLdwg--.js +0 -400
- package/dist/nodes-Bmzx3TP_.js +0 -101
- package/dist/nodes-Dx9bxj35.cjs +0 -1
- package/dist/rules-logic-CvILqbhz.js +0 -266
- package/dist/rules-logic-DV5SUr5M.cjs +0 -1
- package/dist/supports-DFDQ6eJO.cjs +0 -1
- /package/dist/{id-Cg7fVl1O.cjs → id-Bv44ilEo.cjs} +0 -0
- /package/dist/{id-n2yrHvNo.js → id-CRqy981z.js} +0 -0
- /package/dist/{logger-C44jSdYl.js → logger-6z_gb4rA.js} +0 -0
- /package/dist/{logger-CJUj90QX.cjs → logger-fbvQC40v.cjs} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,16 +1,142 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as n } from "../
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { n as e, t } from "../rules-logic-BTIxfrJJ.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 _, i as v, l as ee, n as te, o as ne, r as re, s as y } from "../experience-instance-DJaNc5Ob.js";
|
|
6
|
+
import { i as ie, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
|
|
7
|
+
import { n as ae, r as oe } from "../api-5yb5p-eh.js";
|
|
8
|
+
import { t as se } 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";
|
|
11
|
+
//#region src/entities/experience/experience.ts
|
|
12
|
+
var N = E("experience"), ce = j(({ client: e, experience: t }) => {
|
|
13
|
+
let n = N.store(t), r = T(n, { merge(e, t) {
|
|
14
|
+
return {
|
|
15
|
+
...e,
|
|
16
|
+
...t.experience
|
|
17
|
+
};
|
|
18
|
+
} }), i = n.map((e) => ({
|
|
19
|
+
name: e.name,
|
|
20
|
+
decisionLogic: e.condition,
|
|
21
|
+
targetSelectors: e.targets,
|
|
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.indexStore, e.conditions.indexStore, (e, t, n) => {
|
|
24
|
+
let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(re).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
|
|
25
|
+
return {
|
|
26
|
+
steps: r,
|
|
27
|
+
nodes: e.nodes,
|
|
28
|
+
edges: e.edges,
|
|
29
|
+
conditions: i
|
|
30
|
+
};
|
|
31
|
+
}), s = t.actions ?? [];
|
|
32
|
+
return {
|
|
33
|
+
id: t.id,
|
|
34
|
+
key: t.key,
|
|
35
|
+
name: t.name,
|
|
36
|
+
configStore: i,
|
|
37
|
+
treeStore: o,
|
|
38
|
+
componentStore: a,
|
|
39
|
+
actions: s,
|
|
40
|
+
merge: r.merge
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
function le(e) {
|
|
44
|
+
return M(ce, e);
|
|
45
|
+
}
|
|
46
|
+
var ue = j(({ client: e }) => {
|
|
47
|
+
let t = N.store({}), n = T(t, { register(e, t) {
|
|
48
|
+
return {
|
|
49
|
+
...e,
|
|
50
|
+
[t.id]: t
|
|
51
|
+
};
|
|
52
|
+
} });
|
|
53
|
+
function r(r) {
|
|
54
|
+
let i = t.getState()[r.id];
|
|
55
|
+
if (i) {
|
|
56
|
+
i.merge({
|
|
57
|
+
experience: r,
|
|
58
|
+
strategy: "override"
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let a = le({
|
|
63
|
+
client: e,
|
|
64
|
+
experience: r
|
|
65
|
+
});
|
|
66
|
+
n.register(a);
|
|
67
|
+
}
|
|
68
|
+
let i = t.map((e) => Object.values(e));
|
|
69
|
+
function a(e) {
|
|
70
|
+
return t.map((t) => t[e], { skipVoid: !1 });
|
|
71
|
+
}
|
|
72
|
+
function o(e) {
|
|
73
|
+
return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
|
|
74
|
+
}
|
|
75
|
+
let s = C({
|
|
76
|
+
source: t,
|
|
77
|
+
effect: async (t, n) => {
|
|
78
|
+
let r = "key" in n ? Object.values(t).find((e) => e.key === n.key) : t[n.id];
|
|
79
|
+
if (!r) {
|
|
80
|
+
"key" in n ? `${n.key}` : `${n.id}`;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
let { options: i } = n;
|
|
84
|
+
if (i?.bypassCondition) {
|
|
85
|
+
P(e, r, i);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
await I(e, r) && P(e, r, i);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
register: r,
|
|
93
|
+
get: a,
|
|
94
|
+
getById: a,
|
|
95
|
+
getByKey: o,
|
|
96
|
+
launch: s,
|
|
97
|
+
open: C({
|
|
98
|
+
source: {
|
|
99
|
+
experiences: t,
|
|
100
|
+
instances: e.experienceInstances.listStore
|
|
101
|
+
},
|
|
102
|
+
effect: ({ experiences: e, instances: t }, n) => {
|
|
103
|
+
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => r && e.experienceId === r.id);
|
|
104
|
+
if (i.length > 0) for (let e of i) e.open();
|
|
105
|
+
else s("key" in n ? {
|
|
106
|
+
key: n.key,
|
|
107
|
+
options: {
|
|
108
|
+
...n.options,
|
|
109
|
+
initialiseOpen: !0
|
|
110
|
+
}
|
|
111
|
+
} : {
|
|
112
|
+
id: n.id,
|
|
113
|
+
options: {
|
|
114
|
+
...n.options,
|
|
115
|
+
initialiseOpen: !0
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
listStore: i
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
function de(e) {
|
|
124
|
+
return M(ue, e);
|
|
125
|
+
}
|
|
126
|
+
var P = (e, t, n) => {
|
|
127
|
+
let { targetSelectors: r } = t.configStore.getState(), i = y(r, t.id);
|
|
128
|
+
i.forEach(({ elements: e }) => e.forEach((e) => ee(e, t.id))), g(i, t.id, t.key).forEach((r) => {
|
|
129
|
+
n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
|
|
130
|
+
});
|
|
131
|
+
}, F = async (e) => {
|
|
132
|
+
await Promise.all(e.experiences.listStore.getState().map(async (t) => {
|
|
133
|
+
await I(e, t) && P(e, t);
|
|
134
|
+
}));
|
|
135
|
+
}, I = async (n, r) => {
|
|
136
|
+
if (!n.preconditionPassed || !n.session?.isUser) return !1;
|
|
137
|
+
let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
|
|
138
|
+
return y(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
|
|
139
|
+
}, fe = (e, t, n) => {
|
|
14
140
|
let r = t.name, i = t.setup(e);
|
|
15
141
|
if (i) {
|
|
16
142
|
let e = n[r] ?? {};
|
|
@@ -19,16 +145,16 @@ var ae = (e, t, n) => {
|
|
|
19
145
|
...i
|
|
20
146
|
});
|
|
21
147
|
}
|
|
22
|
-
},
|
|
148
|
+
}, L = E("component"), R = j(({ client: e, component: t, name: n }) => ({
|
|
23
149
|
name: n,
|
|
24
150
|
component: t,
|
|
25
151
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
26
152
|
}));
|
|
27
|
-
function
|
|
28
|
-
return
|
|
153
|
+
function z(e) {
|
|
154
|
+
return M(R, e);
|
|
29
155
|
}
|
|
30
|
-
var
|
|
31
|
-
let t =
|
|
156
|
+
var B = j(({ client: e }) => {
|
|
157
|
+
let t = L.store({}), n = T(t, { register(e, t) {
|
|
32
158
|
return {
|
|
33
159
|
...e,
|
|
34
160
|
[t.name]: t
|
|
@@ -36,7 +162,7 @@ var le = M(({ client: e }) => {
|
|
|
36
162
|
} });
|
|
37
163
|
function r(r, i) {
|
|
38
164
|
t.getState()[r] && `${r}`;
|
|
39
|
-
let a =
|
|
165
|
+
let a = z({
|
|
40
166
|
client: e,
|
|
41
167
|
name: r,
|
|
42
168
|
component: i
|
|
@@ -53,13 +179,13 @@ var le = M(({ client: e }) => {
|
|
|
53
179
|
listStore: i
|
|
54
180
|
};
|
|
55
181
|
});
|
|
56
|
-
function
|
|
57
|
-
return
|
|
182
|
+
function V(e) {
|
|
183
|
+
return M(B, e);
|
|
58
184
|
}
|
|
59
|
-
var
|
|
185
|
+
var H = (e, t, n) => {
|
|
60
186
|
n.register(e, t);
|
|
61
|
-
},
|
|
62
|
-
let t =
|
|
187
|
+
}, pe = E("framework"), me = j(({ client: e }) => {
|
|
188
|
+
let t = pe.store({}), n = T(t, { register(e, t) {
|
|
63
189
|
return {
|
|
64
190
|
...e,
|
|
65
191
|
[t.name]: t.framework
|
|
@@ -81,21 +207,21 @@ var P = (e, t, n) => {
|
|
|
81
207
|
listStore: i
|
|
82
208
|
};
|
|
83
209
|
});
|
|
84
|
-
function
|
|
85
|
-
return
|
|
210
|
+
function he(e) {
|
|
211
|
+
return M(me, e);
|
|
86
212
|
}
|
|
87
|
-
var
|
|
213
|
+
var ge = (e, t) => {
|
|
88
214
|
t.register(e.name, e);
|
|
89
|
-
},
|
|
215
|
+
}, _e = 6e3, ve = S("last_ping", "global"), ye = async (e) => {
|
|
90
216
|
try {
|
|
91
|
-
let t = Date.now(), n =
|
|
92
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
217
|
+
let t = Date.now(), n = b.get(ve), r = 0;
|
|
218
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < _e) return !0;
|
|
93
219
|
let i = {
|
|
94
220
|
projectId: e.projectId,
|
|
95
221
|
path: window.location.pathname
|
|
96
222
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
97
223
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
98
|
-
let s = (await
|
|
224
|
+
let s = (await ae(e.apiUrl, "ping", i, a)).ok;
|
|
99
225
|
return s && n.set(t), s;
|
|
100
226
|
} catch {
|
|
101
227
|
return !1;
|
|
@@ -103,7 +229,7 @@ var R = (e, t) => {
|
|
|
103
229
|
};
|
|
104
230
|
//#endregion
|
|
105
231
|
//#region src/utils/state-snaphot.ts
|
|
106
|
-
function
|
|
232
|
+
function U(e) {
|
|
107
233
|
let t = typeof window < "u", n = {
|
|
108
234
|
client: e,
|
|
109
235
|
responses: e.responses.listStore.getState(),
|
|
@@ -117,8 +243,8 @@ function H(e) {
|
|
|
117
243
|
}
|
|
118
244
|
//#endregion
|
|
119
245
|
//#region src/entities/predicate/predicate.ts
|
|
120
|
-
var
|
|
121
|
-
let t =
|
|
246
|
+
var be = E("predicate"), xe = j(({ client: e }) => {
|
|
247
|
+
let t = be.store({}), n = T(t, { register(e, t) {
|
|
122
248
|
return {
|
|
123
249
|
...e,
|
|
124
250
|
[t.name]: {
|
|
@@ -138,22 +264,22 @@ var U = D("predicate"), de = M(({ client: e }) => {
|
|
|
138
264
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
139
265
|
}
|
|
140
266
|
function o(t) {
|
|
141
|
-
let n =
|
|
267
|
+
let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
142
268
|
let n = a(t).getState();
|
|
143
269
|
if (!n) return;
|
|
144
|
-
let r =
|
|
270
|
+
let r = U(e);
|
|
145
271
|
return (...e) => n({
|
|
146
272
|
...r,
|
|
147
273
|
args: e
|
|
148
274
|
});
|
|
149
275
|
});
|
|
150
|
-
return
|
|
276
|
+
return A({
|
|
151
277
|
source: {
|
|
152
278
|
responses: e.responses.listStore,
|
|
153
279
|
fields: e.fields.listStore
|
|
154
280
|
},
|
|
155
281
|
target: r
|
|
156
|
-
}),
|
|
282
|
+
}), A({
|
|
157
283
|
clock: r.doneData,
|
|
158
284
|
filter: (e) => e !== void 0,
|
|
159
285
|
target: n
|
|
@@ -166,13 +292,13 @@ var U = D("predicate"), de = M(({ client: e }) => {
|
|
|
166
292
|
getEvokablePredicate: o
|
|
167
293
|
};
|
|
168
294
|
});
|
|
169
|
-
function
|
|
170
|
-
return
|
|
295
|
+
function Se(e) {
|
|
296
|
+
return M(xe, e);
|
|
171
297
|
}
|
|
172
|
-
var
|
|
298
|
+
var Ce = (e, t, n) => {
|
|
173
299
|
n.register(e, t);
|
|
174
|
-
}, W =
|
|
175
|
-
let t = W.store({}), n = W.store([]), r =
|
|
300
|
+
}, W = E("feature"), we = j(({ client: e }) => {
|
|
301
|
+
let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
|
|
176
302
|
return {
|
|
177
303
|
...e,
|
|
178
304
|
[t.id]: t.feature
|
|
@@ -192,19 +318,19 @@ var pe = (e, t, n) => {
|
|
|
192
318
|
feature: i
|
|
193
319
|
}));
|
|
194
320
|
}
|
|
195
|
-
let a =
|
|
196
|
-
let r =
|
|
321
|
+
let a = D(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
322
|
+
let r = S(`feature:${e}:${t}`, "global"), i = (n === "session" ? x : b).get(r).boolean();
|
|
197
323
|
return i === null ? null : {
|
|
198
324
|
id: e,
|
|
199
325
|
key: t,
|
|
200
326
|
bucket: i,
|
|
201
327
|
storage: n
|
|
202
328
|
};
|
|
203
|
-
}), o =
|
|
329
|
+
}), o = D((e) => {
|
|
204
330
|
if (!e) return null;
|
|
205
|
-
let t =
|
|
206
|
-
(e.storage === "session" ?
|
|
207
|
-
}), s = /* @__PURE__ */ new Map(), c =
|
|
331
|
+
let t = S(`feature:${e.id}:${e.key}`, "global");
|
|
332
|
+
(e.storage === "session" ? x : b).set(t, e.bucket);
|
|
333
|
+
}), s = /* @__PURE__ */ new Map(), c = C({
|
|
208
334
|
source: {
|
|
209
335
|
allFeaturesStore: t,
|
|
210
336
|
resolvedFeaturesStore: n
|
|
@@ -235,7 +361,7 @@ var pe = (e, t, n) => {
|
|
|
235
361
|
};
|
|
236
362
|
}
|
|
237
363
|
});
|
|
238
|
-
|
|
364
|
+
A({
|
|
239
365
|
clock: r.register,
|
|
240
366
|
fn: (e) => {
|
|
241
367
|
let { id: t, feature: n } = e;
|
|
@@ -246,7 +372,7 @@ var pe = (e, t, n) => {
|
|
|
246
372
|
};
|
|
247
373
|
},
|
|
248
374
|
target: a
|
|
249
|
-
}),
|
|
375
|
+
}), A({
|
|
250
376
|
source: t,
|
|
251
377
|
clock: c.doneData,
|
|
252
378
|
fn: (e, t) => {
|
|
@@ -260,7 +386,7 @@ var pe = (e, t, n) => {
|
|
|
260
386
|
},
|
|
261
387
|
target: o
|
|
262
388
|
});
|
|
263
|
-
let l =
|
|
389
|
+
let l = w({
|
|
264
390
|
allFeaturesStore: t,
|
|
265
391
|
resolvedFeaturesStore: n
|
|
266
392
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -282,7 +408,7 @@ var pe = (e, t, n) => {
|
|
|
282
408
|
isResolved: !1
|
|
283
409
|
};
|
|
284
410
|
}));
|
|
285
|
-
|
|
411
|
+
A({
|
|
286
412
|
clock: c.doneData,
|
|
287
413
|
source: { resolvedFeatures: n },
|
|
288
414
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
@@ -291,7 +417,7 @@ var pe = (e, t, n) => {
|
|
|
291
417
|
type: "feature_decide",
|
|
292
418
|
feature: e
|
|
293
419
|
}))
|
|
294
|
-
}),
|
|
420
|
+
}), A({
|
|
295
421
|
clock: [a.doneData, c.doneData],
|
|
296
422
|
source: n,
|
|
297
423
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
@@ -304,15 +430,15 @@ var pe = (e, t, n) => {
|
|
|
304
430
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
305
431
|
}
|
|
306
432
|
function f(e) {
|
|
307
|
-
let t =
|
|
433
|
+
let t = k(async () => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
308
434
|
let t = u(e).getState();
|
|
309
435
|
if (t) return async () => (await t.getBucket()).bucket;
|
|
310
436
|
});
|
|
311
|
-
return
|
|
437
|
+
return A({
|
|
312
438
|
source: n,
|
|
313
439
|
filter: (t) => t.some((t) => t.id === e),
|
|
314
440
|
target: r
|
|
315
|
-
}),
|
|
441
|
+
}), A({
|
|
316
442
|
clock: r.doneData,
|
|
317
443
|
filter: (e) => e !== void 0,
|
|
318
444
|
target: t
|
|
@@ -326,21 +452,21 @@ var pe = (e, t, n) => {
|
|
|
326
452
|
getEvokableFeature: f
|
|
327
453
|
};
|
|
328
454
|
});
|
|
329
|
-
function
|
|
330
|
-
return
|
|
455
|
+
function Te(e) {
|
|
456
|
+
return M(we, e);
|
|
331
457
|
}
|
|
332
|
-
var
|
|
458
|
+
var Ee = (e, t, n) => {
|
|
333
459
|
n.register(e, t);
|
|
334
|
-
}, G =
|
|
460
|
+
}, G = E("history");
|
|
335
461
|
function K(e, t) {
|
|
336
462
|
return {
|
|
337
|
-
id:
|
|
463
|
+
id: se(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
338
464
|
node: t,
|
|
339
465
|
at: Date.now(),
|
|
340
466
|
experienceId: e
|
|
341
467
|
};
|
|
342
468
|
}
|
|
343
|
-
var
|
|
469
|
+
var De = j(() => {
|
|
344
470
|
let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
|
|
345
471
|
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);
|
|
346
472
|
function a(e, t) {
|
|
@@ -350,7 +476,7 @@ var _e = M(() => {
|
|
|
350
476
|
};
|
|
351
477
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
352
478
|
let i = e[r], a = i?.node;
|
|
353
|
-
if (!(!a || !
|
|
479
|
+
if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
354
480
|
else {
|
|
355
481
|
n.secondLastStepIndex = r;
|
|
356
482
|
break;
|
|
@@ -372,25 +498,25 @@ var _e = M(() => {
|
|
|
372
498
|
entriesStore: e.map((e) => e.entries)
|
|
373
499
|
};
|
|
374
500
|
});
|
|
375
|
-
function
|
|
376
|
-
return
|
|
501
|
+
function Oe() {
|
|
502
|
+
return M(De);
|
|
377
503
|
}
|
|
378
504
|
//#endregion
|
|
379
505
|
//#region src/utils/events.ts
|
|
380
|
-
var
|
|
381
|
-
let t =
|
|
382
|
-
return
|
|
506
|
+
var ke = 0, Ae = (e) => {
|
|
507
|
+
let t = k([]);
|
|
508
|
+
return A({
|
|
383
509
|
clock: e,
|
|
384
510
|
source: t,
|
|
385
511
|
fn: (e, t) => [...e, {
|
|
386
|
-
id:
|
|
512
|
+
id: ke++,
|
|
387
513
|
at: /* @__PURE__ */ new Date(),
|
|
388
514
|
payload: t
|
|
389
515
|
}],
|
|
390
516
|
target: t
|
|
391
517
|
}), t;
|
|
392
|
-
},
|
|
393
|
-
let e =
|
|
518
|
+
}, je = E("field"), Me = j(() => {
|
|
519
|
+
let e = je.store({}), t = T(e, {
|
|
394
520
|
register(e, t) {
|
|
395
521
|
return {
|
|
396
522
|
...e,
|
|
@@ -434,13 +560,13 @@ var ye = 0, be = (e) => {
|
|
|
434
560
|
getByName: s
|
|
435
561
|
};
|
|
436
562
|
});
|
|
437
|
-
function
|
|
438
|
-
return
|
|
563
|
+
function Ne() {
|
|
564
|
+
return M(Me);
|
|
439
565
|
}
|
|
440
566
|
//#endregion
|
|
441
567
|
//#region src/entities/step/step.ts
|
|
442
|
-
var
|
|
443
|
-
let e =
|
|
568
|
+
var Pe = E("step"), Fe = j(() => {
|
|
569
|
+
let e = Pe.store({}), t = T(e, { register(e, t) {
|
|
444
570
|
return {
|
|
445
571
|
...e,
|
|
446
572
|
[t.step.id]: t.step
|
|
@@ -464,16 +590,16 @@ var we = D("step"), Te = M(() => {
|
|
|
464
590
|
indexStore: e
|
|
465
591
|
};
|
|
466
592
|
});
|
|
467
|
-
function
|
|
468
|
-
return
|
|
593
|
+
function Ie() {
|
|
594
|
+
return M(Fe);
|
|
469
595
|
}
|
|
470
|
-
function
|
|
596
|
+
function Le(e, t) {
|
|
471
597
|
t.register(e);
|
|
472
598
|
}
|
|
473
599
|
//#endregion
|
|
474
600
|
//#region src/entities/action/action.ts
|
|
475
|
-
var
|
|
476
|
-
let t =
|
|
601
|
+
var Re = E("action"), ze = j(({ client: e }) => {
|
|
602
|
+
let t = Re.store({}), n = T(t, { register(e, t) {
|
|
477
603
|
return {
|
|
478
604
|
...e,
|
|
479
605
|
[t.key]: {
|
|
@@ -493,22 +619,22 @@ var Oe = D("action"), ke = M(({ client: e }) => {
|
|
|
493
619
|
return t.map((t) => t[e]?.action, { skipVoid: !1 });
|
|
494
620
|
}
|
|
495
621
|
function o(t, n) {
|
|
496
|
-
let r =
|
|
622
|
+
let r = k(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, o = D(async () => {
|
|
497
623
|
let n = a(t).getState();
|
|
498
624
|
if (!n) return;
|
|
499
|
-
let r =
|
|
625
|
+
let r = U(e);
|
|
500
626
|
return (...e) => n({
|
|
501
627
|
...r,
|
|
502
628
|
args: e
|
|
503
629
|
}, i);
|
|
504
630
|
});
|
|
505
|
-
return
|
|
631
|
+
return A({
|
|
506
632
|
source: {
|
|
507
633
|
responses: e.responses.listStore,
|
|
508
634
|
fields: e.fields.listStore
|
|
509
635
|
},
|
|
510
636
|
target: o
|
|
511
|
-
}),
|
|
637
|
+
}), A({
|
|
512
638
|
clock: o.doneData,
|
|
513
639
|
filter: (e) => e !== void 0,
|
|
514
640
|
target: r
|
|
@@ -521,10 +647,10 @@ var Oe = D("action"), ke = M(({ client: e }) => {
|
|
|
521
647
|
getEvokableAction: o
|
|
522
648
|
};
|
|
523
649
|
});
|
|
524
|
-
function
|
|
525
|
-
return
|
|
650
|
+
function Be(e) {
|
|
651
|
+
return M(ze, e);
|
|
526
652
|
}
|
|
527
|
-
var
|
|
653
|
+
var Ve = (e, t, n) => {
|
|
528
654
|
n.register(e, t);
|
|
529
655
|
};
|
|
530
656
|
//#endregion
|
|
@@ -540,7 +666,7 @@ function q(e, t, n, r) {
|
|
|
540
666
|
function J(e) {
|
|
541
667
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
542
668
|
}
|
|
543
|
-
function
|
|
669
|
+
function He(e) {
|
|
544
670
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
545
671
|
}
|
|
546
672
|
function Y(e) {
|
|
@@ -550,13 +676,13 @@ function Y(e) {
|
|
|
550
676
|
return !1;
|
|
551
677
|
}
|
|
552
678
|
}
|
|
553
|
-
function
|
|
679
|
+
function Ue(e, t) {
|
|
554
680
|
return t.find((t) => t.key === e) ?? null;
|
|
555
681
|
}
|
|
556
|
-
function
|
|
682
|
+
function We(e, t) {
|
|
557
683
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
558
684
|
}
|
|
559
|
-
function
|
|
685
|
+
function Ge(e, t) {
|
|
560
686
|
if (e.type !== "object" || J(t)) return null;
|
|
561
687
|
if (e.multiple) {
|
|
562
688
|
if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
@@ -568,7 +694,7 @@ function Fe(e, t) {
|
|
|
568
694
|
}
|
|
569
695
|
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.).");
|
|
570
696
|
}
|
|
571
|
-
function
|
|
697
|
+
function Ke(e, t) {
|
|
572
698
|
if (J(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
573
699
|
let n = Array.isArray(t) ? t : [t];
|
|
574
700
|
if (e.type === "object") {
|
|
@@ -576,23 +702,23 @@ function Ie(e, t) {
|
|
|
576
702
|
return n.every((e) => r.has(JSON.stringify(e))) ? null : q(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
577
703
|
}
|
|
578
704
|
let r = e.options.map((e) => e.value);
|
|
579
|
-
return n.every((e) => !
|
|
705
|
+
return n.every((e) => !He(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(", ")}`);
|
|
580
706
|
}
|
|
581
|
-
async function
|
|
582
|
-
if (
|
|
583
|
-
let
|
|
707
|
+
async function qe(e, t, r, i) {
|
|
708
|
+
if (t.validation && !n(t.validation) && !J(r)) {
|
|
709
|
+
let n = i ? {
|
|
584
710
|
$input: r,
|
|
585
711
|
responses: i
|
|
586
|
-
} : { $input: r }, a = await t
|
|
587
|
-
if (typeof a == "string") return q(
|
|
588
|
-
if (a === !1) return q(
|
|
712
|
+
} : { $input: r }, a = await e(t.validation, n);
|
|
713
|
+
if (typeof a == "string") return q(t, r, a, `Field validation resulted in an error: ${a}.`);
|
|
714
|
+
if (a === !1) return q(t, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
589
715
|
}
|
|
590
|
-
return
|
|
716
|
+
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;
|
|
591
717
|
}
|
|
592
718
|
//#endregion
|
|
593
719
|
//#region src/entities/response/response.ts
|
|
594
|
-
var
|
|
595
|
-
let n =
|
|
720
|
+
var Je = E("response"), Ye = j(({ client: e }) => {
|
|
721
|
+
let n = Je.store({}), r = O(), i = O(), a = T(n, {
|
|
596
722
|
register(e, t) {
|
|
597
723
|
return {
|
|
598
724
|
...e,
|
|
@@ -621,7 +747,7 @@ var Re = D("response"), ze = M(({ client: e }) => {
|
|
|
621
747
|
});
|
|
622
748
|
} else a.registerBatch(e);
|
|
623
749
|
}
|
|
624
|
-
let s = (n, r) => t(e, n, r), c =
|
|
750
|
+
let s = (n, r) => t(e, n, r), c = C({
|
|
625
751
|
source: {
|
|
626
752
|
allFields: e.fields.listStore,
|
|
627
753
|
existingResponses: n
|
|
@@ -631,7 +757,7 @@ var Re = D("response"), ze = M(({ client: e }) => {
|
|
|
631
757
|
...t,
|
|
632
758
|
...n
|
|
633
759
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
634
|
-
let o =
|
|
760
|
+
let o = Ue(t, e);
|
|
635
761
|
if (!o) {
|
|
636
762
|
r.push({
|
|
637
763
|
fieldKey: t,
|
|
@@ -641,17 +767,17 @@ var Re = D("response"), ze = M(({ client: e }) => {
|
|
|
641
767
|
});
|
|
642
768
|
return;
|
|
643
769
|
}
|
|
644
|
-
let c =
|
|
770
|
+
let c = We(o, n), l = await qe(s, o, c, a);
|
|
645
771
|
if (l) {
|
|
646
772
|
r.push(l);
|
|
647
773
|
return;
|
|
648
774
|
}
|
|
649
|
-
let u =
|
|
775
|
+
let u = Ge(o, c);
|
|
650
776
|
if (u) {
|
|
651
777
|
r.push(u);
|
|
652
778
|
return;
|
|
653
779
|
}
|
|
654
|
-
let d =
|
|
780
|
+
let d = Ke(o, c);
|
|
655
781
|
if (d) {
|
|
656
782
|
r.push(d);
|
|
657
783
|
return;
|
|
@@ -679,7 +805,7 @@ var Re = D("response"), ze = M(({ client: e }) => {
|
|
|
679
805
|
async function l(e) {
|
|
680
806
|
return c(e);
|
|
681
807
|
}
|
|
682
|
-
let u =
|
|
808
|
+
let u = C({
|
|
683
809
|
source: n,
|
|
684
810
|
effect: async (e, t) => {
|
|
685
811
|
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
@@ -694,7 +820,7 @@ var Re = D("response"), ze = M(({ client: e }) => {
|
|
|
694
820
|
value: t
|
|
695
821
|
})));
|
|
696
822
|
function m(e) {
|
|
697
|
-
return
|
|
823
|
+
return w({
|
|
698
824
|
f: e,
|
|
699
825
|
s: n
|
|
700
826
|
}, ({ f: e, s: t }) => {
|
|
@@ -711,10 +837,10 @@ var Re = D("response"), ze = M(({ client: e }) => {
|
|
|
711
837
|
function _(t) {
|
|
712
838
|
return m(e.fields.getByName(t));
|
|
713
839
|
}
|
|
714
|
-
return
|
|
840
|
+
return A({
|
|
715
841
|
clock: r,
|
|
716
842
|
target: a.clearAll
|
|
717
|
-
}),
|
|
843
|
+
}), A({
|
|
718
844
|
clock: i,
|
|
719
845
|
target: a.clear
|
|
720
846
|
}), {
|
|
@@ -730,13 +856,13 @@ var Re = D("response"), ze = M(({ client: e }) => {
|
|
|
730
856
|
getByFieldName: _
|
|
731
857
|
};
|
|
732
858
|
});
|
|
733
|
-
function
|
|
734
|
-
return
|
|
859
|
+
function Xe(e) {
|
|
860
|
+
return M(Ye, e);
|
|
735
861
|
}
|
|
736
862
|
//#endregion
|
|
737
863
|
//#region src/entities/condition/condition.ts
|
|
738
|
-
var
|
|
739
|
-
let e =
|
|
864
|
+
var Ze = E("condition"), Qe = j(() => {
|
|
865
|
+
let e = Ze.store({}), t = T(e, { register(e, t) {
|
|
740
866
|
return {
|
|
741
867
|
...e,
|
|
742
868
|
[t.condition.id]: t.condition
|
|
@@ -760,12 +886,12 @@ var Ve = D("condition"), He = M(() => {
|
|
|
760
886
|
indexStore: e
|
|
761
887
|
};
|
|
762
888
|
});
|
|
763
|
-
function
|
|
764
|
-
return
|
|
889
|
+
function $e() {
|
|
890
|
+
return M(Qe);
|
|
765
891
|
}
|
|
766
892
|
//#endregion
|
|
767
893
|
//#region src/utils/api-url.ts
|
|
768
|
-
function
|
|
894
|
+
function et() {
|
|
769
895
|
if (f()) {
|
|
770
896
|
let e = [
|
|
771
897
|
document.currentScript,
|
|
@@ -780,7 +906,7 @@ function We() {
|
|
|
780
906
|
}
|
|
781
907
|
//#endregion
|
|
782
908
|
//#region src/utils/search-params.ts
|
|
783
|
-
function
|
|
909
|
+
function tt() {
|
|
784
910
|
if (!o()) return {};
|
|
785
911
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
786
912
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -788,28 +914,28 @@ function Ge() {
|
|
|
788
914
|
let n = r.replace("picked-", "");
|
|
789
915
|
t[n] = e.getAll(r);
|
|
790
916
|
}
|
|
791
|
-
let r =
|
|
792
|
-
if (n.size > 0)
|
|
917
|
+
let r = S("s");
|
|
918
|
+
if (n.size > 0) x.set(r, t);
|
|
793
919
|
else {
|
|
794
|
-
let e =
|
|
920
|
+
let e = x.get(r);
|
|
795
921
|
if (e) return e.json() || {};
|
|
796
922
|
}
|
|
797
923
|
return t;
|
|
798
924
|
}
|
|
799
925
|
//#endregion
|
|
800
926
|
//#region src/utils/user-session.ts
|
|
801
|
-
function
|
|
802
|
-
return
|
|
927
|
+
function nt() {
|
|
928
|
+
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)}`;
|
|
803
929
|
}
|
|
804
|
-
var
|
|
805
|
-
let e =
|
|
930
|
+
var rt = S("session", "global"), it = () => {
|
|
931
|
+
let e = b.get(rt), t;
|
|
806
932
|
e.isSet() && (t = e.json());
|
|
807
933
|
let n = (t) => e.set({
|
|
808
934
|
id: t.id,
|
|
809
935
|
isUser: t.isUser,
|
|
810
936
|
identifiers: t.identifiers
|
|
811
937
|
}), r = {
|
|
812
|
-
id: t?.id ??
|
|
938
|
+
id: t?.id ?? nt(),
|
|
813
939
|
isUser: t?.isUser ?? void 0,
|
|
814
940
|
identifiers: t?.identifiers ?? void 0,
|
|
815
941
|
setIsUser(e) {
|
|
@@ -826,21 +952,21 @@ var qe = x("session", "global"), Je = () => {
|
|
|
826
952
|
}
|
|
827
953
|
};
|
|
828
954
|
return n(r), r;
|
|
829
|
-
},
|
|
955
|
+
}, X = () => u() ? it() : null;
|
|
830
956
|
//#endregion
|
|
831
957
|
//#region src/utils/picked-config.ts
|
|
832
|
-
function
|
|
958
|
+
function Z() {
|
|
833
959
|
if (o()) return globalThis.window.pickedConfig;
|
|
834
960
|
}
|
|
835
|
-
function
|
|
961
|
+
function at() {
|
|
836
962
|
if (!o()) return;
|
|
837
|
-
let e =
|
|
963
|
+
let e = Z(), t = e?.organizationId, n = e?.projectId;
|
|
838
964
|
return t && n ? {
|
|
839
965
|
organizationId: t,
|
|
840
966
|
projectId: n
|
|
841
967
|
} : void 0;
|
|
842
968
|
}
|
|
843
|
-
function
|
|
969
|
+
function ot() {
|
|
844
970
|
if (!f()) return;
|
|
845
971
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
846
972
|
if (!e) return;
|
|
@@ -850,15 +976,15 @@ function Z() {
|
|
|
850
976
|
projectId: n
|
|
851
977
|
} : void 0;
|
|
852
978
|
}
|
|
853
|
-
function
|
|
979
|
+
function st(e) {
|
|
854
980
|
let { organizationId: t, projectId: n } = e;
|
|
855
981
|
if (t && n) return {
|
|
856
982
|
organizationId: t,
|
|
857
983
|
projectId: n
|
|
858
984
|
};
|
|
859
|
-
let r =
|
|
985
|
+
let r = at();
|
|
860
986
|
if (r) return r;
|
|
861
|
-
let i =
|
|
987
|
+
let i = ot();
|
|
862
988
|
if (i) return i;
|
|
863
989
|
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.");
|
|
864
990
|
}
|
|
@@ -867,7 +993,7 @@ function Ze(e) {
|
|
|
867
993
|
function Q(e) {
|
|
868
994
|
return e == null || e === "" || Number.isNaN(e);
|
|
869
995
|
}
|
|
870
|
-
var
|
|
996
|
+
var ct = {
|
|
871
997
|
default: (e, t) => Q(e) ? String(t ?? "") : String(e),
|
|
872
998
|
append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
|
|
873
999
|
prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
|
|
@@ -888,24 +1014,24 @@ var Qe = {
|
|
|
888
1014
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
889
1015
|
}
|
|
890
1016
|
};
|
|
891
|
-
function
|
|
1017
|
+
function lt(e) {
|
|
892
1018
|
return typeof e == "object" && !!e;
|
|
893
1019
|
}
|
|
894
|
-
function
|
|
1020
|
+
function ut(e, t) {
|
|
895
1021
|
let n = t;
|
|
896
|
-
for (let t of e.split(".")) if (
|
|
1022
|
+
for (let t of e.split(".")) if (lt(n) && t in n) n = n[t];
|
|
897
1023
|
else return;
|
|
898
1024
|
return typeof n == "function" ? n() : n;
|
|
899
1025
|
}
|
|
900
|
-
function
|
|
901
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1026
|
+
function dt(e, t) {
|
|
1027
|
+
let n = e.split("|").map((e) => e.trim()), r = ut(n.shift() ?? "", t);
|
|
902
1028
|
for (let e of n) {
|
|
903
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1029
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = ct[i];
|
|
904
1030
|
o && (r = o(r, a));
|
|
905
1031
|
}
|
|
906
1032
|
return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
907
1033
|
}
|
|
908
|
-
function
|
|
1034
|
+
function ft(e, t) {
|
|
909
1035
|
let n = "", r = 0;
|
|
910
1036
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
911
1037
|
r += 2;
|
|
@@ -917,19 +1043,19 @@ function nt(e, t) {
|
|
|
917
1043
|
}
|
|
918
1044
|
i += e[r++];
|
|
919
1045
|
}
|
|
920
|
-
n +=
|
|
1046
|
+
n += dt(i.trim(), t);
|
|
921
1047
|
} else n += e[r++];
|
|
922
1048
|
return n;
|
|
923
1049
|
}
|
|
924
1050
|
//#endregion
|
|
925
1051
|
//#region src/picked.ts
|
|
926
1052
|
var $ = class {
|
|
927
|
-
static logger =
|
|
1053
|
+
static logger = r;
|
|
928
1054
|
options;
|
|
929
1055
|
isReady = !1;
|
|
930
1056
|
plugins = {};
|
|
931
1057
|
pluginStartHooks = [];
|
|
932
|
-
eventBus =
|
|
1058
|
+
eventBus = O();
|
|
933
1059
|
events;
|
|
934
1060
|
organizationId;
|
|
935
1061
|
projectId;
|
|
@@ -940,29 +1066,29 @@ var $ = class {
|
|
|
940
1066
|
precondition;
|
|
941
1067
|
condition;
|
|
942
1068
|
preconditionPassed;
|
|
943
|
-
searchParams =
|
|
944
|
-
history =
|
|
945
|
-
components =
|
|
946
|
-
experienceInstances =
|
|
947
|
-
experiences =
|
|
948
|
-
frameworks =
|
|
949
|
-
predicates =
|
|
950
|
-
features =
|
|
951
|
-
conditions =
|
|
952
|
-
fields =
|
|
953
|
-
responses =
|
|
954
|
-
steps =
|
|
955
|
-
actions =
|
|
1069
|
+
searchParams = tt();
|
|
1070
|
+
history = Oe();
|
|
1071
|
+
components = V({ client: this });
|
|
1072
|
+
experienceInstances = te({ client: this });
|
|
1073
|
+
experiences = de({ client: this });
|
|
1074
|
+
frameworks = he({ client: this });
|
|
1075
|
+
predicates = Se({ client: this });
|
|
1076
|
+
features = Te({ client: this });
|
|
1077
|
+
conditions = $e();
|
|
1078
|
+
fields = Ne();
|
|
1079
|
+
responses = Xe({ client: this });
|
|
1080
|
+
steps = Ie();
|
|
1081
|
+
actions = Be({ client: this });
|
|
956
1082
|
constructor(e) {
|
|
957
|
-
this.events =
|
|
958
|
-
let { organizationId: t, projectId: n } =
|
|
959
|
-
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl ||
|
|
1083
|
+
this.events = Ae(this.eventBus);
|
|
1084
|
+
let { organizationId: t, projectId: n } = st(e);
|
|
1085
|
+
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || et(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = X(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
|
|
960
1086
|
type: "load",
|
|
961
|
-
version:
|
|
1087
|
+
version: oe()
|
|
962
1088
|
});
|
|
963
1089
|
}
|
|
964
1090
|
start = () => {
|
|
965
|
-
|
|
1091
|
+
ye(this), (async () => {
|
|
966
1092
|
if (!f()) return;
|
|
967
1093
|
await this.runPluginStartHooks();
|
|
968
1094
|
let e = await this.evaluateGate(this.precondition);
|
|
@@ -977,7 +1103,7 @@ var $ = class {
|
|
|
977
1103
|
value: e
|
|
978
1104
|
});
|
|
979
1105
|
}
|
|
980
|
-
if (this.eventBus({ type: "initialize" }), n &&
|
|
1106
|
+
if (this.eventBus({ type: "initialize" }), n && F(this), await ne(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
981
1107
|
let { id: e, isUser: t, identifiers: n } = this.session;
|
|
982
1108
|
this.eventBus({
|
|
983
1109
|
type: "session",
|
|
@@ -989,21 +1115,21 @@ var $ = class {
|
|
|
989
1115
|
})();
|
|
990
1116
|
};
|
|
991
1117
|
registerFramework = (e) => {
|
|
992
|
-
|
|
1118
|
+
ge(e, this.frameworks);
|
|
993
1119
|
};
|
|
994
1120
|
registerComponent = (e, t) => {
|
|
995
|
-
|
|
1121
|
+
H(e, t, this.components);
|
|
996
1122
|
};
|
|
997
1123
|
registerPlugin = (e) => {
|
|
998
|
-
|
|
1124
|
+
fe(this, e, this.plugins);
|
|
999
1125
|
let t = this.plugins[e.name];
|
|
1000
1126
|
t?.onStart && this.pluginStartHooks.push(t.onStart);
|
|
1001
1127
|
};
|
|
1002
1128
|
registerFeature = (e, t) => {
|
|
1003
|
-
|
|
1129
|
+
Ee(e, t, this.features);
|
|
1004
1130
|
};
|
|
1005
1131
|
registerPredicate = (e, t) => {
|
|
1006
|
-
|
|
1132
|
+
Ce(e, t, this.predicates);
|
|
1007
1133
|
};
|
|
1008
1134
|
registerCondition = (e) => {
|
|
1009
1135
|
this.conditions.register(e);
|
|
@@ -1012,15 +1138,15 @@ var $ = class {
|
|
|
1012
1138
|
this.fields.register(e);
|
|
1013
1139
|
};
|
|
1014
1140
|
registerStep = (e) => {
|
|
1015
|
-
|
|
1141
|
+
Le(e, this.steps);
|
|
1016
1142
|
};
|
|
1017
1143
|
registerAction = (e, t) => {
|
|
1018
|
-
|
|
1144
|
+
Ve(e, t, this.actions);
|
|
1019
1145
|
};
|
|
1020
1146
|
registerExperience = (e) => {
|
|
1021
|
-
e.component &&
|
|
1147
|
+
e.component && H(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1022
1148
|
};
|
|
1023
|
-
getStateSnapshot = () =>
|
|
1149
|
+
getStateSnapshot = () => U(this);
|
|
1024
1150
|
launchExperienceById = async (e, t) => {
|
|
1025
1151
|
this.experiences.launch({
|
|
1026
1152
|
id: e,
|
|
@@ -1109,7 +1235,7 @@ var $ = class {
|
|
|
1109
1235
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1110
1236
|
renderString = (e, t) => {
|
|
1111
1237
|
let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldKey] = t.value, e), {});
|
|
1112
|
-
return
|
|
1238
|
+
return ft(e, {
|
|
1113
1239
|
...t,
|
|
1114
1240
|
responses: n
|
|
1115
1241
|
});
|
|
@@ -1117,20 +1243,20 @@ var $ = class {
|
|
|
1117
1243
|
};
|
|
1118
1244
|
//#endregion
|
|
1119
1245
|
//#region src/entities/component/lazyComponent.ts
|
|
1120
|
-
function
|
|
1246
|
+
function pt(e) {
|
|
1121
1247
|
return {
|
|
1122
1248
|
$$type: "lazy-component",
|
|
1123
1249
|
load: e
|
|
1124
1250
|
};
|
|
1125
1251
|
}
|
|
1126
|
-
function
|
|
1252
|
+
function mt(e) {
|
|
1127
1253
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1128
1254
|
}
|
|
1129
1255
|
//#endregion
|
|
1130
1256
|
//#region src/exports.ts
|
|
1131
|
-
var
|
|
1257
|
+
var ht = (e) => {
|
|
1132
1258
|
let t = new $(e);
|
|
1133
|
-
return
|
|
1259
|
+
return d(t), t;
|
|
1134
1260
|
};
|
|
1135
1261
|
//#endregion
|
|
1136
|
-
export { $ as Picked,
|
|
1262
|
+
export { $ as Picked, ht as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, mt as isLazyLoader, _ as isPickedRoot, pt as lazyComponent, b as localStore, x as sessionStore, ie 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 };
|