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