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