@picked/client 0.0.50 → 0.0.51-next.10
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-CHy9HcU7.cjs +1 -0
- package/dist/{api-DWBcrf98.js → api-mlYS-lDj.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 +472 -0
- package/dist/esm/index.js +473 -383
- package/dist/esm/plugins/create-experience/index.js +198 -165
- package/dist/esm/plugins/dynamic-experiences/index.js +52 -30
- 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 +7 -9
- package/dist/esm/plugins/responses-indexeddb/index.js +11 -11
- package/dist/esm/plugins/single-page-app/index.js +4 -4
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-DOcd8XI1.cjs +1 -0
- package/dist/experience-instance-NHU1moID.js +486 -0
- package/dist/{object-Clj5zVr1.js → object-C82v79xc.js} +2 -1
- package/dist/object-CUJOjanb.cjs +1 -0
- package/dist/rules-logic-CnVktz2l.js +240 -0
- package/dist/rules-logic-nMHNVLn7.cjs +1 -0
- package/dist/{storage-DyxpJ0pg.js → storage-6Xk0uAxB.js} +3 -1
- package/dist/storage-B6lQtc4-.cjs +1 -0
- package/dist/types/client.d.ts +47 -43
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/entities/action/action.d.ts +37 -5
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/condition/condition.d.ts +20 -0
- package/dist/types/entities/condition/condition.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +67 -51
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +22 -2
- 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 +24 -10
- 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-validation.d.ts +74 -0
- package/dist/types/entities/response/response-validation.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +24 -20
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +42 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- 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 +17 -0
- package/dist/types/form/build-responses.d.ts.map +1 -0
- package/dist/types/form/create-field-evaluator.d.ts +27 -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 +97 -0
- package/dist/types/form/create-form.d.ts.map +1 -0
- package/dist/types/form/create-submit-pipeline.d.ts +70 -0
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -0
- package/dist/types/form/get-step-fields.d.ts +18 -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 +3 -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 +99 -33
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +53 -31
- 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/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 +45 -0
- package/dist/types/plugins/dynamic-experiences/types.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 +2 -2
- 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 +16 -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/state-snaphot.d.ts +11 -1
- package/dist/types/utils/state-snaphot.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
|
@@ -1,710 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./object-Clj5zVr1.js";
|
|
2
|
-
import "./logger-6z_gb4rA.js";
|
|
3
|
-
import { d as t, l as n, r } from "./supports-0XIfd4-R.js";
|
|
4
|
-
import { attach as i, combine as a, createApi as o, createDomain as s, createEffect as c, createEvent as l, sample as u, split as d } from "effector";
|
|
5
|
-
import { createFactory as f, invoke as p } from "@withease/factories";
|
|
6
|
-
//#region src/logic-engine.ts
|
|
7
|
-
function m(e) {
|
|
8
|
-
return typeof e == "number" && !isNaN(e);
|
|
9
|
-
}
|
|
10
|
-
function h(e) {
|
|
11
|
-
return typeof e == "string";
|
|
12
|
-
}
|
|
13
|
-
function g(e) {
|
|
14
|
-
return Array.isArray(e);
|
|
15
|
-
}
|
|
16
|
-
function _(e) {
|
|
17
|
-
return e instanceof Promise;
|
|
18
|
-
}
|
|
19
|
-
function v(e) {
|
|
20
|
-
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
21
|
-
}
|
|
22
|
-
function y(e) {
|
|
23
|
-
if (m(e)) return e;
|
|
24
|
-
let t = parseFloat(`${e}`);
|
|
25
|
-
return isNaN(t) ? 0 : t;
|
|
26
|
-
}
|
|
27
|
-
function b(e) {
|
|
28
|
-
return `${e}`;
|
|
29
|
-
}
|
|
30
|
-
var x = {
|
|
31
|
-
"==": (e, t) => e == t,
|
|
32
|
-
"===": (e, t) => e === t,
|
|
33
|
-
"!=": (e, t) => e != t,
|
|
34
|
-
"!==": (e, t) => e !== t,
|
|
35
|
-
">": (e, t) => y(e) > y(t),
|
|
36
|
-
">=": (e, t) => y(e) >= y(t),
|
|
37
|
-
"<": (e, t, n) => {
|
|
38
|
-
let r = y(e), i = y(t);
|
|
39
|
-
if (n === void 0) return r < i;
|
|
40
|
-
let a = y(n);
|
|
41
|
-
return r < i && i < a;
|
|
42
|
-
},
|
|
43
|
-
"<=": (e, t, n) => {
|
|
44
|
-
let r = y(e), i = y(t);
|
|
45
|
-
if (n === void 0) return r <= i;
|
|
46
|
-
let a = y(n);
|
|
47
|
-
return r <= i && i <= a;
|
|
48
|
-
},
|
|
49
|
-
"!!": async (e) => await C(e),
|
|
50
|
-
"!": async (e) => !await C(e),
|
|
51
|
-
"%": (e, t) => y(e) % y(t),
|
|
52
|
-
log: (e) => (console.log(e), e),
|
|
53
|
-
in: (e, t) => t ? h(t) ? t.indexOf(b(e)) !== -1 : g(t) ? t.includes(e) : !1 : !1,
|
|
54
|
-
cat: (...e) => e.map(b).join(""),
|
|
55
|
-
substr: (e, t, n) => {
|
|
56
|
-
let r = b(e), i = y(t);
|
|
57
|
-
if (n === void 0) return r.substr(i);
|
|
58
|
-
let a = y(n);
|
|
59
|
-
if (a < 0) {
|
|
60
|
-
let e = r.substr(i);
|
|
61
|
-
return e.substr(0, e.length + a);
|
|
62
|
-
}
|
|
63
|
-
return r.substr(i, a);
|
|
64
|
-
},
|
|
65
|
-
"+": (...e) => e.reduce((e, t) => y(e) + y(t), 0),
|
|
66
|
-
"*": (...e) => e.reduce((e, t) => y(e) * y(t), 1),
|
|
67
|
-
"-": (e, t) => {
|
|
68
|
-
let n = y(e);
|
|
69
|
-
return t === void 0 ? -n : n - y(t);
|
|
70
|
-
},
|
|
71
|
-
"/": (e, t) => y(e) / y(t),
|
|
72
|
-
min: (...e) => Math.min(...e.map(y)),
|
|
73
|
-
max: (...e) => Math.max(...e.map(y)),
|
|
74
|
-
merge: (...e) => e.reduce((e, t) => g(t) ? e.concat(t) : e.concat([t]), []),
|
|
75
|
-
var(e, t) {
|
|
76
|
-
let n = arguments.length > 1 ? t : null;
|
|
77
|
-
if (e === "" || e === "." || e == null) return this;
|
|
78
|
-
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
79
|
-
let r = b(e);
|
|
80
|
-
if (r === "" || r === ".") return this;
|
|
81
|
-
let i = r.split("."), a = this;
|
|
82
|
-
for (let e of i) {
|
|
83
|
-
if (a == null) return n;
|
|
84
|
-
if (Array.isArray(a)) {
|
|
85
|
-
let t = parseInt(e, 10);
|
|
86
|
-
a = isNaN(t) ? a[e] : a[t];
|
|
87
|
-
} else a = a[e];
|
|
88
|
-
}
|
|
89
|
-
return a === void 0 ? n : a;
|
|
90
|
-
},
|
|
91
|
-
async missing(...e) {
|
|
92
|
-
let t = g(e[0]) ? e[0] : e, n = [];
|
|
93
|
-
for (let e of t) {
|
|
94
|
-
let t = await S({ var: e }, this);
|
|
95
|
-
(t === null || t === "") && n.push(`${e}`);
|
|
96
|
-
}
|
|
97
|
-
return n;
|
|
98
|
-
},
|
|
99
|
-
async missing_some(e, t) {
|
|
100
|
-
let n = await S({ missing: t }, this);
|
|
101
|
-
if (!g(n) || !g(t)) return [];
|
|
102
|
-
let r = n.filter(h);
|
|
103
|
-
return t.filter(h).length - r.length >= y(e) ? [] : r;
|
|
104
|
-
},
|
|
105
|
-
invoke(...e) {
|
|
106
|
-
let [t, ...n] = e;
|
|
107
|
-
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
108
|
-
},
|
|
109
|
-
regexp_matches(e, t) {
|
|
110
|
-
let n = e, r = "";
|
|
111
|
-
if (g(e)) {
|
|
112
|
-
let [t, i] = e;
|
|
113
|
-
n = t, r = i;
|
|
114
|
-
}
|
|
115
|
-
return !h(n) || !h(r) ? !1 : new RegExp(n, r).test(b(t));
|
|
116
|
-
},
|
|
117
|
-
throw(e) {
|
|
118
|
-
throw Error(b(e));
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
async function S(e, t) {
|
|
122
|
-
if (!e) return e;
|
|
123
|
-
if (_(e)) return S(await e, t);
|
|
124
|
-
if (g(e)) return Promise.all(e.map((e) => S(e, t)));
|
|
125
|
-
if (!v(e)) return e;
|
|
126
|
-
let n = w(e), r = n ? e[n] ?? [] : [];
|
|
127
|
-
switch (g(r) || (r = [r]), n) {
|
|
128
|
-
case "if":
|
|
129
|
-
case "?:":
|
|
130
|
-
for (let e = 0; e < r.length - 1; e += 2) if (await C(await S(r[e], t))) return S(r[e + 1], t);
|
|
131
|
-
return r.length % 2 == 1 ? S(r[r.length - 1], t) : null;
|
|
132
|
-
case "and": {
|
|
133
|
-
let e = null;
|
|
134
|
-
for (let n of r) if (e = await S(n, t), !await C(e)) return e;
|
|
135
|
-
return e;
|
|
136
|
-
}
|
|
137
|
-
case "or": {
|
|
138
|
-
let e = null;
|
|
139
|
-
for (let n of r) if (e = await S(n, t), await C(e)) return e;
|
|
140
|
-
return e;
|
|
141
|
-
}
|
|
142
|
-
case "map": {
|
|
143
|
-
let e = await S(r[0], t);
|
|
144
|
-
return g(e) ? await Promise.all(e.map((e) => S(r[1], e))) : [];
|
|
145
|
-
}
|
|
146
|
-
case "filter": {
|
|
147
|
-
let e = await S(r[0], t);
|
|
148
|
-
return g(e) ? (await Promise.all(e.map(async (e) => ({
|
|
149
|
-
item: e,
|
|
150
|
-
shouldInclude: await C(await S(r[1], e))
|
|
151
|
-
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
152
|
-
}
|
|
153
|
-
case "reduce": {
|
|
154
|
-
let e = await S(r[0], t);
|
|
155
|
-
if (!g(e)) return r.length > 2 ? await S(r[2], t) : null;
|
|
156
|
-
let n = r[1], i = r.length > 2 ? await S(r[2], t) : null;
|
|
157
|
-
for (let t of e) i = await S(n, {
|
|
158
|
-
current: t,
|
|
159
|
-
accumulator: i
|
|
160
|
-
});
|
|
161
|
-
return i;
|
|
162
|
-
}
|
|
163
|
-
case "all": {
|
|
164
|
-
let e = await S(r[0], t);
|
|
165
|
-
if (!g(e) || e.length === 0) return !1;
|
|
166
|
-
for (let t of e) if (!await C(await S(r[1], t))) return !1;
|
|
167
|
-
return !0;
|
|
168
|
-
}
|
|
169
|
-
case "some": {
|
|
170
|
-
let e = await S(r[0], t);
|
|
171
|
-
if (!g(e)) return !1;
|
|
172
|
-
for (let t of e) if (await C(await S(r[1], t))) return !0;
|
|
173
|
-
return !1;
|
|
174
|
-
}
|
|
175
|
-
case "none": {
|
|
176
|
-
let e = await S(r[0], t);
|
|
177
|
-
if (!g(e)) return !0;
|
|
178
|
-
for (let t of e) if (await C(await S(r[1], t))) return !1;
|
|
179
|
-
return !0;
|
|
180
|
-
}
|
|
181
|
-
case "catch": try {
|
|
182
|
-
return await S(r[0], t);
|
|
183
|
-
} catch (e) {
|
|
184
|
-
return v(e) ? await S(e, t) : r[1] ? await S(r[1], e) : e instanceof Error ? e.message : e;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
let i = await Promise.all(r.map((e) => S(e, t))), a = n ? x[n] : void 0;
|
|
188
|
-
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
189
|
-
return a.apply(t, i);
|
|
190
|
-
}
|
|
191
|
-
async function C(e) {
|
|
192
|
-
return _(e) ? C(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
193
|
-
}
|
|
194
|
-
function w(e) {
|
|
195
|
-
return Object.keys(e)[0];
|
|
196
|
-
}
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region src/utils/rules-logic.ts
|
|
199
|
-
function T(t) {
|
|
200
|
-
return !e(t);
|
|
201
|
-
}
|
|
202
|
-
async function E(e, t, n) {
|
|
203
|
-
let r = e.getStateSnapshot(), i = e.predicates.listStore.getState().reduce((e, t) => ({
|
|
204
|
-
...e,
|
|
205
|
-
[t.name]: (...e) => t.predicate({
|
|
206
|
-
...r,
|
|
207
|
-
args: e
|
|
208
|
-
})
|
|
209
|
-
}), {}), a = e.features.listStore.getState().reduce((e, t) => ({
|
|
210
|
-
...e,
|
|
211
|
-
[t.id]: async () => {
|
|
212
|
-
let { bucket: e } = await t.getBucket();
|
|
213
|
-
return e;
|
|
214
|
-
}
|
|
215
|
-
}), {});
|
|
216
|
-
return await S(t, {
|
|
217
|
-
...n,
|
|
218
|
-
responses: e.responses.getAllStore.getState(),
|
|
219
|
-
location: typeof r.location == "object" ? {
|
|
220
|
-
hash: r.location.hash,
|
|
221
|
-
host: r.location.host,
|
|
222
|
-
hostname: r.location.hostname,
|
|
223
|
-
href: r.location.href,
|
|
224
|
-
origin: r.location.origin,
|
|
225
|
-
pathname: r.location.pathname,
|
|
226
|
-
port: r.location.port,
|
|
227
|
-
protocol: r.location.protocol,
|
|
228
|
-
search: r.location.search
|
|
229
|
-
} : void 0,
|
|
230
|
-
predicates: i,
|
|
231
|
-
features: a
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/utils/dom.ts
|
|
236
|
-
function D(e) {
|
|
237
|
-
return !t() || !r() ? [] : Array.from(window.document.querySelectorAll(e)).filter((e) => e instanceof HTMLElement);
|
|
238
|
-
}
|
|
239
|
-
var O = "open";
|
|
240
|
-
function k(e) {
|
|
241
|
-
if (!n()) throw Error("Shadow DOM is not supported in this environment");
|
|
242
|
-
return e.attachShadow({ mode: O });
|
|
243
|
-
}
|
|
244
|
-
function A() {
|
|
245
|
-
return new Promise((e, t) => {
|
|
246
|
-
if (!r()) {
|
|
247
|
-
t();
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
document.readyState === "loading" ? document.addEventListener("readystatechange", () => e(), { once: !0 }) : e();
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
function j(e, t) {
|
|
254
|
-
let n = new MutationObserver((r) => {
|
|
255
|
-
document.contains(e) || (n.disconnect(), t());
|
|
256
|
-
});
|
|
257
|
-
n.observe(document.body, {
|
|
258
|
-
childList: !0,
|
|
259
|
-
subtree: !0
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
var M = "picked-root", N = "picked-target", P = "picked-root";
|
|
263
|
-
function F(e, t) {
|
|
264
|
-
return [...e, {
|
|
265
|
-
selector: `${P}[experience-id="${t}"]`,
|
|
266
|
-
placement: "replace"
|
|
267
|
-
}].flatMap((e) => {
|
|
268
|
-
let n = D(e.selector).filter((e) => !R(e, t) && !z(e, t));
|
|
269
|
-
return {
|
|
270
|
-
...e,
|
|
271
|
-
elements: n
|
|
272
|
-
};
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
function I(e, t) {
|
|
276
|
-
return e.flatMap((e) => e.elements.map((n) => V(n, e.placement, t)));
|
|
277
|
-
}
|
|
278
|
-
function L(e, t) {
|
|
279
|
-
e.classList.add(N), e.classList.add(`${N}-${t}`);
|
|
280
|
-
}
|
|
281
|
-
function R(e, t) {
|
|
282
|
-
return t ? e.classList.contains(`${N}-${t}`) : e.classList.contains(`${N}`);
|
|
283
|
-
}
|
|
284
|
-
function z(e, t) {
|
|
285
|
-
return t ? e.classList.contains(`${M}-${t}`) : e.classList.contains(M);
|
|
286
|
-
}
|
|
287
|
-
function B(e) {
|
|
288
|
-
let t = document.createElement("div");
|
|
289
|
-
return t.style.display = "block", t.classList.add(M), t.classList.add(`${M}-${e}`), t;
|
|
290
|
-
}
|
|
291
|
-
function V(e, t, n) {
|
|
292
|
-
let r, i = B(n);
|
|
293
|
-
if (e instanceof Document) r = e.body.appendChild(i);
|
|
294
|
-
else {
|
|
295
|
-
switch (t) {
|
|
296
|
-
case "replace":
|
|
297
|
-
e.replaceWith(i);
|
|
298
|
-
break;
|
|
299
|
-
case "before":
|
|
300
|
-
e.before(i);
|
|
301
|
-
break;
|
|
302
|
-
case "after":
|
|
303
|
-
e.after(i);
|
|
304
|
-
break;
|
|
305
|
-
case "prepend":
|
|
306
|
-
e.prepend(i);
|
|
307
|
-
break;
|
|
308
|
-
default:
|
|
309
|
-
e.append(i);
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
r = i;
|
|
313
|
-
}
|
|
314
|
-
return r;
|
|
315
|
-
}
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region src/utils/nodes.ts
|
|
318
|
-
function H(e) {
|
|
319
|
-
return e.type === "conditional";
|
|
320
|
-
}
|
|
321
|
-
function U(e) {
|
|
322
|
-
return e.type === "step";
|
|
323
|
-
}
|
|
324
|
-
function W(e) {
|
|
325
|
-
return e.type === "experience";
|
|
326
|
-
}
|
|
327
|
-
function G(e) {
|
|
328
|
-
return e.type === "origin";
|
|
329
|
-
}
|
|
330
|
-
function K(e) {
|
|
331
|
-
return e.type === "action";
|
|
332
|
-
}
|
|
333
|
-
//#endregion
|
|
334
|
-
//#region src/utils/node-tree/next-reachable-step-nodes.ts
|
|
335
|
-
var q = (e, t, n, r, i = /* @__PURE__ */ new Set()) => i.has(n.id) ? [] : (i.add(n.id), U(n) && !r ? [n] : t.filter((e) => e.sourceNodeId === n.id).flatMap((n) => {
|
|
336
|
-
let r = e.find((e) => e.id === n.destinationNodeId);
|
|
337
|
-
return r ? q(e, t, r, !1, i) : [];
|
|
338
|
-
})), ee = (e, t, n) => q(e, t, n, !0, /* @__PURE__ */ new Set()), J = (e, t, n, r, i = /* @__PURE__ */ new Set()) => {
|
|
339
|
-
if (i.has(n.id)) return [-1, -1];
|
|
340
|
-
i.add(n.id);
|
|
341
|
-
let a = t.filter((e) => e.sourceNodeId === n.id);
|
|
342
|
-
if (a.length === 0) return [0, 0];
|
|
343
|
-
let o = Infinity, s = -Infinity;
|
|
344
|
-
for (let n of a) {
|
|
345
|
-
let r = e.find((e) => e.id === n.destinationNodeId);
|
|
346
|
-
if (!r) continue;
|
|
347
|
-
let [a, c] = J(e, t, r, !1, new Set(i));
|
|
348
|
-
a !== -1 && (o = Math.min(o, a + 1), s = Math.max(s, c + 1));
|
|
349
|
-
}
|
|
350
|
-
return o === Infinity ? [-1, -1] : [o, s];
|
|
351
|
-
}, te = (e, t, n) => J(e, t, n, !0, /* @__PURE__ */ new Set()), Y = (e, t, n, r = /* @__PURE__ */ new Set()) => {
|
|
352
|
-
if (r.has(n.id)) return [-1, -1];
|
|
353
|
-
if (r.add(n.id), n.type === "origin") return [0, 0];
|
|
354
|
-
let i = t.filter((e) => e.destinationNodeId === n.id);
|
|
355
|
-
if (i.length === 0) return [-1, -1];
|
|
356
|
-
let a = Infinity, o = -Infinity;
|
|
357
|
-
for (let n of i) {
|
|
358
|
-
let i = e.find((e) => e.id === n.sourceNodeId);
|
|
359
|
-
if (!i) continue;
|
|
360
|
-
let [s, c] = Y(e, t, i, new Set(r));
|
|
361
|
-
s !== -1 && (a = Math.min(a, s + 1), o = Math.max(o, c + 1));
|
|
362
|
-
}
|
|
363
|
-
return a === Infinity ? [-1, -1] : [a, o];
|
|
364
|
-
}, ne = (e, t, n) => Y(e, t, n, /* @__PURE__ */ new Set()), X = (e) => e.find((e) => e.type === "origin") || null, Z = (e, t, n) => {
|
|
365
|
-
if (!e) return X(t);
|
|
366
|
-
let r = n.find((t) => t.sourceNodeId === e.id);
|
|
367
|
-
return r && t.find((e) => e.id === r.destinationNodeId) || null;
|
|
368
|
-
};
|
|
369
|
-
//#endregion
|
|
370
|
-
//#region src/utils/node-tree/get-next-node-from-conditional.ts
|
|
371
|
-
async function re(e, t, n, r) {
|
|
372
|
-
let i = e ? "true" : "false", a = r.find((e) => e.sourceNodeHandle === i && e.sourceNodeId === t);
|
|
373
|
-
return n.find((e) => e.id === a?.destinationNodeId);
|
|
374
|
-
}
|
|
375
|
-
//#endregion
|
|
376
|
-
//#region src/entities/experience-instance/experience-instance.ts
|
|
377
|
-
var Q = s("experience-instance"), $ = f(({ client: e, experience: t, target: n, options: r }) => {
|
|
378
|
-
let s = l(), f = l(), p = l(), m = l(), h = l(), g = l(), _ = t.componentStore, v = Q.store("transitioning"), y = e.history.entriesStore.map((e) => e.filter((e) => e.experienceId === t.id)), b = y.map((e) => e.filter((e) => U(e.node))), x = y.map((e) => e.at(-1)?.node || null), S = a(t.treeStore, x, ({ steps: e }, t) => e.find((e) => t && U(t) && e.id === t.stepId) || null), C = a(t.treeStore, b, ({ steps: e }, t) => {
|
|
379
|
-
let n = t.at(-2);
|
|
380
|
-
if (!n || !U(n.node)) return null;
|
|
381
|
-
let r = n.node;
|
|
382
|
-
return e.find((e) => e.id === r.stepId) || null;
|
|
383
|
-
}), w = a(t.treeStore, x, ({ nodes: e, edges: t }, n) => n ? ee(e, t, n) : []), D = a(t.treeStore, x, ({ nodes: e, edges: t }, n) => n ? ne(e, t, n) : [-1, -1]), O = a(t.treeStore, x, ({ nodes: e, edges: t }, n) => n ? te(e, t, n) : [-1, -1]), k = Q.store(!1), A = o(k, {
|
|
384
|
-
open: () => !0,
|
|
385
|
-
close: () => !1,
|
|
386
|
-
toggle: (e) => !e,
|
|
387
|
-
set: (e, t) => t
|
|
388
|
-
}), j = c(async () => {
|
|
389
|
-
e.history.back({ experienceId: t.id });
|
|
390
|
-
}), M = i({
|
|
391
|
-
source: t.treeStore,
|
|
392
|
-
effect: async (n, r) => {
|
|
393
|
-
let i = n.nodes.find((e) => U(e) && e.stepId === r);
|
|
394
|
-
i && e.history.push({
|
|
395
|
-
experienceId: t.id,
|
|
396
|
-
node: i
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
}), N = i({
|
|
400
|
-
source: x,
|
|
401
|
-
effect: (e) => {}
|
|
402
|
-
}), P = i({
|
|
403
|
-
source: t.treeStore,
|
|
404
|
-
effect: async ({ nodes: e }) => X(e)
|
|
405
|
-
}), F = i({
|
|
406
|
-
source: t.treeStore,
|
|
407
|
-
effect: async ({ nodes: e, edges: t }, n) => {
|
|
408
|
-
if (G(n)) return Z(n, e, t);
|
|
409
|
-
}
|
|
410
|
-
}), I = i({
|
|
411
|
-
source: t.treeStore,
|
|
412
|
-
effect: async ({ nodes: t, edges: n, conditionals: r }, i) => {
|
|
413
|
-
if (!H(i)) return;
|
|
414
|
-
let a = r.find((e) => e.id === i.conditionalId);
|
|
415
|
-
if (!a) return;
|
|
416
|
-
let o = i.id;
|
|
417
|
-
return re(!!await E(e, a.condition), o, t, n);
|
|
418
|
-
}
|
|
419
|
-
}), L = i({
|
|
420
|
-
source: t.treeStore,
|
|
421
|
-
effect: async ({ nodes: t, edges: n }, r) => {
|
|
422
|
-
if (!K(r)) return;
|
|
423
|
-
let i = r.action;
|
|
424
|
-
if (!i) {
|
|
425
|
-
`${r.id}`;
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
let a = e.actions.getByName(i).getState();
|
|
429
|
-
if (!a) {
|
|
430
|
-
`${i}`;
|
|
431
|
-
let e = n.find((e) => e.sourceNodeId === r.id && e.sourceNodeHandle === "false");
|
|
432
|
-
return e ? t.find((t) => t.id === e.destinationNodeId) : null;
|
|
433
|
-
}
|
|
434
|
-
if (typeof a.action != "function") {
|
|
435
|
-
`${i}`;
|
|
436
|
-
let e = n.find((e) => e.sourceNodeId === r.id && e.sourceNodeHandle === "false");
|
|
437
|
-
return e ? t.find((t) => t.id === e.destinationNodeId) : null;
|
|
438
|
-
}
|
|
439
|
-
try {
|
|
440
|
-
`${i}`, await a.action(i);
|
|
441
|
-
let e = n.find((e) => e.sourceNodeId === r.id && e.sourceNodeHandle === "true");
|
|
442
|
-
if (!e) return `${r.id}`, null;
|
|
443
|
-
let o = t.find((t) => t.id === e.destinationNodeId);
|
|
444
|
-
return `${i}${o?.id}`, o || null;
|
|
445
|
-
} catch {
|
|
446
|
-
`${i}`;
|
|
447
|
-
let e = n.find((e) => e.sourceNodeId === r.id && e.sourceNodeHandle === "false");
|
|
448
|
-
if (!e) return `${r.id}`, null;
|
|
449
|
-
let a = t.find((t) => t.id === e.destinationNodeId);
|
|
450
|
-
return `${i}${a?.id}`, a || null;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}), R = c((t) => {
|
|
454
|
-
W(t) && e.experiences.launch({ id: t.experienceId });
|
|
455
|
-
}), z = i({
|
|
456
|
-
source: [x, t.treeStore],
|
|
457
|
-
effect: async ([e, { nodes: t, edges: n }]) => Z(e, t, n)
|
|
458
|
-
}), B = i({
|
|
459
|
-
source: [x, t.treeStore],
|
|
460
|
-
effect: async ([e, { nodes: t, edges: n }]) => Z(e, t, n)
|
|
461
|
-
}), V = c((n) => {
|
|
462
|
-
e.history.push({
|
|
463
|
-
experienceId: t.id,
|
|
464
|
-
node: n
|
|
465
|
-
});
|
|
466
|
-
}), q = i({
|
|
467
|
-
source: t.configStore,
|
|
468
|
-
effect: async ({ initializeOpenLogic: t }) => r?.initialiseOpen === void 0 ? T(t) ? !!await E(e, t) : t ?? !1 : r.initialiseOpen
|
|
469
|
-
}), J = Object.freeze({
|
|
470
|
-
id: Math.random().toString(36).substring(7),
|
|
471
|
-
experienceId: t.id,
|
|
472
|
-
configStore: t.configStore,
|
|
473
|
-
target: n,
|
|
474
|
-
componentStore: _,
|
|
475
|
-
stateStore: v,
|
|
476
|
-
isOpenStore: k,
|
|
477
|
-
open: A.open,
|
|
478
|
-
close: A.close,
|
|
479
|
-
toggleOpen: A.toggle,
|
|
480
|
-
setOpen: A.set,
|
|
481
|
-
treeStore: t.treeStore,
|
|
482
|
-
fieldsStore: t.fieldsStore,
|
|
483
|
-
currentNodeStore: x,
|
|
484
|
-
currentStepStore: S,
|
|
485
|
-
previousStepStore: C,
|
|
486
|
-
nextReachableStepNodesStore: w,
|
|
487
|
-
stepsToOriginStore: D,
|
|
488
|
-
stepsToLeafStore: O,
|
|
489
|
-
goToNextStep: f,
|
|
490
|
-
goToPreviousStep: p,
|
|
491
|
-
goToStepById: m,
|
|
492
|
-
stepsHistoryStore: b
|
|
493
|
-
}), Y = l(), $ = l();
|
|
494
|
-
return u({
|
|
495
|
-
source: x,
|
|
496
|
-
target: Y
|
|
497
|
-
}), u({
|
|
498
|
-
clock: Y,
|
|
499
|
-
filter: (e) => e === null,
|
|
500
|
-
target: P
|
|
501
|
-
}), u({
|
|
502
|
-
clock: Y,
|
|
503
|
-
filter: (e) => e !== null,
|
|
504
|
-
target: $
|
|
505
|
-
}), d({
|
|
506
|
-
source: $,
|
|
507
|
-
match: (e) => H(e) ? "condition" : U(e) ? "step" : W(e) ? "launchExperience" : G(e) ? "origin" : K(e) ? "action" : "other",
|
|
508
|
-
cases: {
|
|
509
|
-
origin: F,
|
|
510
|
-
condition: I,
|
|
511
|
-
step: N,
|
|
512
|
-
launchExperience: R,
|
|
513
|
-
action: L,
|
|
514
|
-
__: l()
|
|
515
|
-
}
|
|
516
|
-
}), u({
|
|
517
|
-
clock: [
|
|
518
|
-
I.doneData,
|
|
519
|
-
F.doneData,
|
|
520
|
-
P.doneData,
|
|
521
|
-
B.doneData,
|
|
522
|
-
z.doneData,
|
|
523
|
-
L.doneData
|
|
524
|
-
],
|
|
525
|
-
filter: Boolean,
|
|
526
|
-
target: V
|
|
527
|
-
}), u({
|
|
528
|
-
clock: f,
|
|
529
|
-
target: B
|
|
530
|
-
}), u({
|
|
531
|
-
clock: f,
|
|
532
|
-
source: S,
|
|
533
|
-
filter: Boolean,
|
|
534
|
-
target: e.eventBus.prepend((e) => ({
|
|
535
|
-
type: "step_submit",
|
|
536
|
-
step: e,
|
|
537
|
-
experience: J
|
|
538
|
-
}))
|
|
539
|
-
}), u({
|
|
540
|
-
clock: B.done,
|
|
541
|
-
source: S,
|
|
542
|
-
filter: Boolean,
|
|
543
|
-
target: e.eventBus.prepend((e) => ({
|
|
544
|
-
type: "step_submit_success",
|
|
545
|
-
step: e,
|
|
546
|
-
experience: J
|
|
547
|
-
}))
|
|
548
|
-
}), u({
|
|
549
|
-
clock: B.fail,
|
|
550
|
-
source: S,
|
|
551
|
-
filter: Boolean,
|
|
552
|
-
target: e.eventBus.prepend((e) => ({
|
|
553
|
-
type: "step_submit_error",
|
|
554
|
-
step: e,
|
|
555
|
-
experience: J
|
|
556
|
-
}))
|
|
557
|
-
}), u({
|
|
558
|
-
clock: p,
|
|
559
|
-
target: j
|
|
560
|
-
}), u({
|
|
561
|
-
clock: m,
|
|
562
|
-
target: M
|
|
563
|
-
}), u({
|
|
564
|
-
source: a([
|
|
565
|
-
I.pending,
|
|
566
|
-
F.pending,
|
|
567
|
-
P.pending,
|
|
568
|
-
B.pending
|
|
569
|
-
]),
|
|
570
|
-
fn: (e) => e.some(Boolean) ? "transitioning" : "ready",
|
|
571
|
-
target: v
|
|
572
|
-
}), u({
|
|
573
|
-
clock: N.doneData,
|
|
574
|
-
source: S,
|
|
575
|
-
filter: Boolean,
|
|
576
|
-
target: e.eventBus.prepend((e) => ({
|
|
577
|
-
type: "step_enter",
|
|
578
|
-
step: e,
|
|
579
|
-
experience: J
|
|
580
|
-
}))
|
|
581
|
-
}), u({
|
|
582
|
-
clock: g,
|
|
583
|
-
target: q
|
|
584
|
-
}), u({
|
|
585
|
-
source: q.doneData,
|
|
586
|
-
fn: Boolean,
|
|
587
|
-
target: k
|
|
588
|
-
}), u({
|
|
589
|
-
source: x,
|
|
590
|
-
clock: s,
|
|
591
|
-
filter: (e) => e ? G(e) : !0,
|
|
592
|
-
target: z
|
|
593
|
-
}), u({
|
|
594
|
-
source: k,
|
|
595
|
-
filter: Boolean,
|
|
596
|
-
target: s
|
|
597
|
-
}), u({
|
|
598
|
-
source: k,
|
|
599
|
-
filter: Boolean,
|
|
600
|
-
target: e.eventBus.prepend(() => ({
|
|
601
|
-
type: "experience_open",
|
|
602
|
-
experience: J
|
|
603
|
-
}))
|
|
604
|
-
}), u({
|
|
605
|
-
source: k,
|
|
606
|
-
filter: (e) => !e,
|
|
607
|
-
target: e.eventBus.prepend(() => ({
|
|
608
|
-
type: "experience_close",
|
|
609
|
-
experience: J
|
|
610
|
-
}))
|
|
611
|
-
}), u({
|
|
612
|
-
clock: h,
|
|
613
|
-
target: [g]
|
|
614
|
-
}), h(), J;
|
|
615
|
-
});
|
|
616
|
-
function ie(e) {
|
|
617
|
-
return p($, e);
|
|
618
|
-
}
|
|
619
|
-
var ae = f(({ client: e }) => {
|
|
620
|
-
let t = Q.store({}), n = l(), r = l(), i = l(), a = o(t, {
|
|
621
|
-
register(e, t) {
|
|
622
|
-
let n = [...e[t.experienceId] ?? []];
|
|
623
|
-
return n.push(t), {
|
|
624
|
-
...e,
|
|
625
|
-
[t.experienceId]: n
|
|
626
|
-
};
|
|
627
|
-
},
|
|
628
|
-
unregister(e, t) {
|
|
629
|
-
let n = t.experienceId, r = e[n]?.filter((e) => e !== t);
|
|
630
|
-
return {
|
|
631
|
-
...e,
|
|
632
|
-
[n]: r ?? []
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
}), s = c(({ experience: t, target: n, options: r }) => ie({
|
|
636
|
-
client: e,
|
|
637
|
-
experience: t,
|
|
638
|
-
target: n,
|
|
639
|
-
options: r
|
|
640
|
-
})), d = c((e) => {
|
|
641
|
-
a.register(e);
|
|
642
|
-
}), f = c((e) => {
|
|
643
|
-
e.target && j(e.target, () => {
|
|
644
|
-
i(e);
|
|
645
|
-
});
|
|
646
|
-
}), p = c((e) => {
|
|
647
|
-
a.unregister(e);
|
|
648
|
-
}), m = c((t) => {
|
|
649
|
-
let n = t.componentStore.getState();
|
|
650
|
-
if (!n) return;
|
|
651
|
-
let r = n.frameworkStore.getState();
|
|
652
|
-
if (!r) {
|
|
653
|
-
`${n.name}`;
|
|
654
|
-
return;
|
|
655
|
-
}
|
|
656
|
-
let i = t.target;
|
|
657
|
-
if (!i) {
|
|
658
|
-
`${t.experienceId}`;
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
let a = k(i);
|
|
662
|
-
try {
|
|
663
|
-
r.render(a, n.component, e, t);
|
|
664
|
-
} catch {}
|
|
665
|
-
});
|
|
666
|
-
u({
|
|
667
|
-
clock: n,
|
|
668
|
-
target: s
|
|
669
|
-
}), u({
|
|
670
|
-
clock: i,
|
|
671
|
-
target: p
|
|
672
|
-
}), u({
|
|
673
|
-
clock: s.doneData,
|
|
674
|
-
target: [
|
|
675
|
-
d,
|
|
676
|
-
f,
|
|
677
|
-
r
|
|
678
|
-
]
|
|
679
|
-
}), u({
|
|
680
|
-
clock: s.doneData,
|
|
681
|
-
target: e.eventBus.prepend((e) => ({
|
|
682
|
-
type: "experience_initialize",
|
|
683
|
-
experience: e
|
|
684
|
-
}))
|
|
685
|
-
}), u({
|
|
686
|
-
clock: r,
|
|
687
|
-
target: m
|
|
688
|
-
});
|
|
689
|
-
function h(e, t, r) {
|
|
690
|
-
n({
|
|
691
|
-
experience: e,
|
|
692
|
-
target: t,
|
|
693
|
-
options: r
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
let g = t.map((e) => Object.values(e).flat());
|
|
697
|
-
function _(e) {
|
|
698
|
-
return t.map((t) => t[e] || [], { skipVoid: !1 });
|
|
699
|
-
}
|
|
700
|
-
return {
|
|
701
|
-
spawn: h,
|
|
702
|
-
getByExperienceId: _,
|
|
703
|
-
listStore: g
|
|
704
|
-
};
|
|
705
|
-
});
|
|
706
|
-
function oe(e) {
|
|
707
|
-
return p(ae, e);
|
|
708
|
-
}
|
|
709
|
-
//#endregion
|
|
710
|
-
export { A as a, L as c, I as i, E as l, oe as n, F as o, U as r, z as s, ie as t, T as u };
|