@picked/client 0.0.1-dev.1769998938557 → 0.0.1-dev.1770178792114

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.
@@ -1,32 +1,32 @@
1
- import { createDomain as xt, createEvent as k, combine as C, createApi as ct, createEffect as $, attach as F, sample as m, split as It } from "effector";
2
- import { createFactory as ut, invoke as ft } from "@withease/factories";
3
- import { i as Et, s as lt, a as kt } from "./supports-COb-sl36.js";
1
+ import { createDomain as It, createEvent as k, combine as H, createApi as ut, createEffect as $, attach as F, sample as m, split as Et } from "effector";
2
+ import { createFactory as ft, invoke as lt } from "@withease/factories";
3
+ import { i as kt, s as dt, a as At } from "./supports-COb-sl36.js";
4
4
  import { l as x } from "./logger-C9a75KZn.js";
5
- import { i as At } from "./object-JwZ58NOH.js";
6
- function bt(t) {
5
+ import { i as bt } from "./object-JwZ58NOH.js";
6
+ function vt(t) {
7
7
  return typeof t == "number" && !isNaN(t);
8
8
  }
9
- function H(t) {
9
+ function j(t) {
10
10
  return typeof t == "string";
11
11
  }
12
12
  function N(t) {
13
13
  return Array.isArray(t);
14
14
  }
15
- function dt(t) {
15
+ function pt(t) {
16
16
  return t instanceof Promise;
17
17
  }
18
- function rt(t) {
18
+ function ot(t) {
19
19
  return typeof t == "object" && t !== null && !Array.isArray(t) && Object.keys(t).length === 1;
20
20
  }
21
21
  function g(t) {
22
- if (bt(t)) return t;
22
+ if (vt(t)) return t;
23
23
  const e = parseFloat(`${t}`);
24
24
  return isNaN(e) ? 0 : e;
25
25
  }
26
- function D(t) {
26
+ function R(t) {
27
27
  return `${t}`;
28
28
  }
29
- const vt = {
29
+ const Ot = {
30
30
  // eslint-disable-next-line eqeqeq
31
31
  "==": (t, e) => t == e,
32
32
  "===": (t, e) => t === e,
@@ -52,11 +52,11 @@ const vt = {
52
52
  "%": (t, e) => g(t) % g(e),
53
53
  // eslint-disable-next-line sonarjs/function-return-type
54
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(""),
55
+ in: (t, e) => e ? j(e) ? e.indexOf(R(t)) !== -1 : N(e) ? e.includes(t) : !1 : !1,
56
+ cat: (...t) => t.map(R).join(""),
57
57
  /* eslint-disable sonarjs/deprecation */
58
58
  substr: (t, e, r) => {
59
- const n = D(t), s = g(e);
59
+ const n = R(t), s = g(e);
60
60
  if (r === void 0) return n.substr(s);
61
61
  const a = g(r);
62
62
  if (a < 0) {
@@ -82,7 +82,7 @@ const vt = {
82
82
  return this;
83
83
  if (typeof t == "number" && Array.isArray(this))
84
84
  return t >= 0 && t < this.length ? this[t] : r;
85
- const n = D(t);
85
+ const n = R(t);
86
86
  if (n === "" || n === ".")
87
87
  return this;
88
88
  const s = n.split(".");
@@ -109,8 +109,8 @@ const vt = {
109
109
  async missing_some(t, e) {
110
110
  const r = await p({ missing: e }, this);
111
111
  if (!N(r) || !N(e)) return [];
112
- const n = r.filter(H);
113
- return e.filter(H).length - n.length >= g(t) ? [] : n;
112
+ const n = r.filter(j);
113
+ return e.filter(j).length - n.length >= g(t) ? [] : n;
114
114
  },
115
115
  /**
116
116
  * Invoke operator - executes a function with optional arguments
@@ -134,20 +134,20 @@ const vt = {
134
134
  const [a, o] = t;
135
135
  r = a, n = o;
136
136
  }
137
- return !H(r) || !H(n) ? !1 : new RegExp(r, n).test(D(e));
137
+ return !j(r) || !j(n) ? !1 : new RegExp(r, n).test(R(e));
138
138
  },
139
139
  throw(t) {
140
- throw new Error(D(t));
140
+ throw new Error(R(t));
141
141
  }
142
142
  };
143
143
  async function p(t, e) {
144
144
  if (!t) return t;
145
- if (dt(t))
145
+ if (pt(t))
146
146
  return p(await t, e);
147
147
  if (N(t))
148
148
  return Promise.all(t.map((o) => p(o, e)));
149
- if (!rt(t)) return t;
150
- const r = Ot(t);
149
+ if (!ot(t)) return t;
150
+ const r = Bt(t);
151
151
  let n = r ? t[r] ?? [] : [];
152
152
  switch (N(n) || (n = [n]), r) {
153
153
  case "if":
@@ -217,23 +217,23 @@ async function p(t, e) {
217
217
  try {
218
218
  return await p(n[0], e);
219
219
  } catch (o) {
220
- return rt(o) ? await p(o, e) : n[1] ? await p(n[1], o) : o instanceof Error ? o.message : o;
220
+ return ot(o) ? await p(o, e) : n[1] ? await p(n[1], o) : o instanceof Error ? o.message : o;
221
221
  }
222
222
  }
223
- const s = await Promise.all(n.map((o) => p(o, e))), a = r ? vt[r] : void 0;
223
+ const s = await Promise.all(n.map((o) => p(o, e))), a = r ? Ot[r] : void 0;
224
224
  if (!a) throw new Error(`Unrecognized operation ${r}`);
225
225
  return a.apply(e, s);
226
226
  }
227
227
  async function O(t) {
228
- return dt(t) ? O(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
228
+ return pt(t) ? O(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
229
229
  }
230
- function Ot(t) {
230
+ function Bt(t) {
231
231
  return Object.keys(t)[0];
232
232
  }
233
- function Bt(t) {
234
- return !At(t);
233
+ function Ft(t) {
234
+ return !bt(t);
235
235
  }
236
- async function ot(t, e, r) {
236
+ async function it(t, e, r) {
237
237
  const n = t.getStateSnapshot(), s = t.predicates.listStore.getState().reduce((c, d) => ({
238
238
  ...c,
239
239
  [d.name]: (...S) => d.predicate({ ...n, args: S })
@@ -262,44 +262,44 @@ async function ot(t, e, r) {
262
262
  };
263
263
  return await p(e, o);
264
264
  }
265
- function Ft(t) {
266
- return !kt() || !lt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
265
+ function _t(t) {
266
+ return !At() || !dt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
267
267
  (e) => e instanceof HTMLElement
268
268
  );
269
269
  }
270
- const _t = "open";
271
- function $t(t) {
272
- if (!Et())
270
+ const $t = "open";
271
+ function Mt(t) {
272
+ if (!kt())
273
273
  throw new Error("Shadow DOM is not supported in this environment");
274
- return t.attachShadow({ mode: _t });
274
+ return t.attachShadow({ mode: $t });
275
275
  }
276
- function Qt() {
276
+ function Yt() {
277
277
  return new Promise((t, e) => {
278
- if (!lt()) {
278
+ if (!dt()) {
279
279
  e();
280
280
  return;
281
281
  }
282
282
  document.readyState !== "loading" ? t() : document.addEventListener("readystatechange", () => t(), { once: !0 });
283
283
  });
284
284
  }
285
- function Mt(t, e) {
285
+ function Tt(t, e) {
286
286
  const r = new MutationObserver((n) => {
287
287
  document.contains(t) || (r.disconnect(), e());
288
288
  });
289
289
  r.observe(document.body, { childList: !0, subtree: !0 });
290
290
  }
291
- const W = "picked-root", G = "picked-target", Tt = "picked-root";
292
- function Yt(t, e) {
291
+ const G = "picked-root", K = "picked-target", Lt = "picked-root";
292
+ function Zt(t, e) {
293
293
  return [
294
294
  ...t,
295
295
  // Target and replace picked-root web components
296
296
  {
297
- selector: `${Tt}[experience-id="${e}"]`,
297
+ selector: `${Lt}[experience-id="${e}"]`,
298
298
  placement: "replace"
299
299
  }
300
300
  ].flatMap((n) => {
301
- const s = Ft(n.selector).filter(
302
- (a) => !Lt(a, e) && !Dt(a, e)
301
+ const s = _t(n.selector).filter(
302
+ (a) => !Dt(a, e) && !Rt(a, e)
303
303
  );
304
304
  return {
305
305
  ...n,
@@ -307,25 +307,25 @@ function Yt(t, e) {
307
307
  };
308
308
  });
309
309
  }
310
- function Zt(t, e) {
311
- return t.flatMap((r) => r.elements.map((n) => Pt(n, r.placement, e)));
312
- }
313
310
  function te(t, e) {
314
- t.classList.add(G), t.classList.add(`${G}-${e}`);
311
+ return t.flatMap((r) => r.elements.map((n) => Ct(n, r.placement, e)));
315
312
  }
316
- function Lt(t, e) {
317
- return e ? t.classList.contains(`${G}-${e}`) : t.classList.contains(`${G}`);
313
+ function ee(t, e) {
314
+ t.classList.add(K), t.classList.add(`${K}-${e}`);
318
315
  }
319
316
  function Dt(t, e) {
320
- return e ? t.classList.contains(`${W}-${e}`) : t.classList.contains(W);
317
+ return e ? t.classList.contains(`${K}-${e}`) : t.classList.contains(`${K}`);
321
318
  }
322
- function Rt(t) {
319
+ function Rt(t, e) {
320
+ return e ? t.classList.contains(`${G}-${e}`) : t.classList.contains(G);
321
+ }
322
+ function Pt(t) {
323
323
  const e = document.createElement("div");
324
- return e.style.display = "block", e.classList.add(W), e.classList.add(`${W}-${t}`), e;
324
+ return e.style.display = "block", e.classList.add(G), e.classList.add(`${G}-${t}`), e;
325
325
  }
326
- function Pt(t, e, r) {
326
+ function Ct(t, e, r) {
327
327
  let n;
328
- const s = Rt(r);
328
+ const s = Pt(r);
329
329
  if (t instanceof Document)
330
330
  n = t.body.appendChild(s);
331
331
  else {
@@ -350,34 +350,34 @@ function Pt(t, e, r) {
350
350
  }
351
351
  return n;
352
352
  }
353
- function it(t) {
353
+ function st(t) {
354
354
  return t.type === "conditional";
355
355
  }
356
- function j(t) {
356
+ function U(t) {
357
357
  return t.type === "step";
358
358
  }
359
- function st(t) {
359
+ function at(t) {
360
360
  return t.type === "experience";
361
361
  }
362
- function z(t) {
362
+ function J(t) {
363
363
  return t.type === "origin";
364
364
  }
365
- function at(t) {
365
+ function ct(t) {
366
366
  return t.type === "action";
367
367
  }
368
- const pt = (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) => {
368
+ const gt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), U(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
369
369
  const c = t.find((d) => d.id === o.destinationNodeId);
370
- return c ? pt(t, e, c, !1, s) : [];
371
- })), Ct = (t, e, r) => pt(t, e, r, !0, /* @__PURE__ */ new Set()), gt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
370
+ return c ? gt(t, e, c, !1, s) : [];
371
+ })), Ht = (t, e, r) => gt(t, e, r, !0, /* @__PURE__ */ new Set()), mt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
372
372
  if (s.has(r.id)) return [-1, -1];
373
373
  s.add(r.id);
374
374
  const a = e.filter((d) => d.sourceNodeId === r.id);
375
375
  if (a.length === 0) return [0, 0];
376
376
  let o = 1 / 0, c = -1 / 0;
377
377
  for (const d of a) {
378
- const S = t.find((R) => R.id === d.destinationNodeId);
378
+ const S = t.find((P) => P.id === d.destinationNodeId);
379
379
  if (!S) continue;
380
- const [A, _] = gt(
380
+ const [A, _] = mt(
381
381
  t,
382
382
  e,
383
383
  S,
@@ -387,7 +387,7 @@ const pt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
387
387
  A !== -1 && (o = Math.min(o, A + 1), c = Math.max(c, _ + 1));
388
388
  }
389
389
  return o === 1 / 0 ? [-1, -1] : [o, c];
390
- }, Ht = (t, e, r) => gt(t, e, r, !0, /* @__PURE__ */ new Set()), mt = (t, e, r, n = /* @__PURE__ */ new Set()) => {
390
+ }, jt = (t, e, r) => mt(t, e, r, !0, /* @__PURE__ */ new Set()), St = (t, e, r, n = /* @__PURE__ */ new Set()) => {
391
391
  if (n.has(r.id)) return [-1, -1];
392
392
  if (n.add(r.id), r.type === "origin") return [0, 0];
393
393
  const s = e.filter((c) => c.destinationNodeId === r.id);
@@ -396,7 +396,7 @@ const pt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
396
396
  for (const c of s) {
397
397
  const d = t.find((_) => _.id === c.sourceNodeId);
398
398
  if (!d) continue;
399
- const [S, A] = mt(
399
+ const [S, A] = St(
400
400
  t,
401
401
  e,
402
402
  d,
@@ -405,99 +405,99 @@ const pt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
405
405
  S !== -1 && (a = Math.min(a, S + 1), o = Math.max(o, A + 1));
406
406
  }
407
407
  return a === 1 / 0 ? [-1, -1] : [a, o];
408
- }, jt = (t, e, r) => mt(t, e, r, /* @__PURE__ */ new Set()), St = (t) => t.find((r) => r.type === "origin") || null, J = (t, e, r) => {
408
+ }, Ut = (t, e, r) => St(t, e, r, /* @__PURE__ */ new Set()), ht = (t) => t.find((r) => r.type === "origin") || null, Q = (t, e, r) => {
409
409
  if (!t)
410
- return St(e);
410
+ return ht(e);
411
411
  const n = r.find((a) => a.sourceNodeId === t.id);
412
412
  if (!n)
413
413
  return null;
414
414
  const s = e.find((a) => a.id === n.destinationNodeId);
415
415
  return s || null;
416
416
  };
417
- async function Ut(t, e, r, n) {
417
+ async function Wt(t, e, r, n) {
418
418
  const s = t ? "true" : "false", a = n.find(
419
419
  (o) => o.sourceNodeHandle === s && o.sourceNodeId === e
420
420
  );
421
421
  return r.find((o) => o.id === a?.destinationNodeId);
422
422
  }
423
- const Q = xt("experience-instance"), Wt = ut(
423
+ const Y = It("experience-instance"), Gt = ft(
424
424
  ({
425
425
  client: t,
426
426
  experience: e,
427
427
  target: r
428
428
  }) => {
429
- const n = k(), s = k(), a = k(), o = k(), c = k(), d = k(), S = e.componentStore, A = Q.store("transitioning"), _ = t.history.entriesStore.map((i) => i.filter((l) => l.experienceId === e.id)), R = _.map((i) => i.filter((l) => j(l.node))), I = _.map((i) => i[i.length - 1]?.node || null), u = C(
429
+ const n = k(), s = k(), a = k(), o = k(), c = k(), d = k(), S = e.componentStore, A = Y.store("transitioning"), _ = t.history.entriesStore.map((i) => i.filter((l) => l.experienceId === e.id)), P = _.map((i) => i.filter((l) => U(l.node))), I = _.map((i) => i[i.length - 1]?.node || null), u = H(
430
430
  e.treeStore,
431
431
  I,
432
- ({ steps: i }, l) => i.find((f) => l && j(l) && f.id === l.stepId) || null
433
- ), h = C(
432
+ ({ steps: i }, l) => i.find((f) => l && U(l) && f.id === l.stepId) || null
433
+ ), h = H(
434
434
  e.treeStore,
435
435
  I,
436
- ({ nodes: i, edges: l }, f) => f ? Ct(i, l, f) : []
437
- ), b = C(
436
+ ({ nodes: i, edges: l }, f) => f ? Ht(i, l, f) : []
437
+ ), b = H(
438
438
  e.treeStore,
439
439
  I,
440
- ({ nodes: i, edges: l }, f) => f ? jt(i, l, f) : [-1, -1]
441
- ), M = C(
440
+ ({ nodes: i, edges: l }, f) => f ? Ut(i, l, f) : [-1, -1]
441
+ ), T = H(
442
442
  e.treeStore,
443
443
  I,
444
- ({ nodes: i, edges: l }, f) => f ? Ht(i, l, f) : [-1, -1]
445
- ), v = Q.store(!1), T = ct(v, {
444
+ ({ nodes: i, edges: l }, f) => f ? jt(i, l, f) : [-1, -1]
445
+ ), v = Y.store(!1), L = ut(v, {
446
446
  open: () => !0,
447
447
  close: () => !1,
448
448
  toggle: (i) => !i,
449
449
  set: (i, l) => l
450
- }), ht = $(async () => {
450
+ }), yt = $(async () => {
451
451
  t.history.back({ experienceId: e.id });
452
- }), yt = F({
452
+ }), wt = F({
453
453
  source: e.treeStore,
454
454
  effect: async (i, l) => {
455
- const f = i.nodes.find((w) => j(w) && w.stepId === l);
455
+ const f = i.nodes.find((w) => U(w) && w.stepId === l);
456
456
  f && t.history.push({ experienceId: e.id, node: f });
457
457
  }
458
- }), Y = F({
458
+ }), Z = F({
459
459
  source: I,
460
460
  effect: (i) => {
461
461
  }
462
- }), K = F({
463
- source: e.treeStore,
464
- effect: async ({ nodes: i }) => St(i)
465
462
  }), V = F({
463
+ source: e.treeStore,
464
+ effect: async ({ nodes: i }) => ht(i)
465
+ }), q = F({
466
466
  source: e.treeStore,
467
467
  effect: async ({ nodes: i, edges: l }, f) => {
468
- if (z(f))
469
- return J(f, i, l);
468
+ if (J(f))
469
+ return Q(f, i, l);
470
470
  }
471
- }), q = F({
471
+ }), X = F({
472
472
  source: e.treeStore,
473
473
  effect: async ({ nodes: i, edges: l, conditionals: f }, w) => {
474
- if (!it(w))
474
+ if (!st(w))
475
475
  return;
476
- const L = f.find((B) => B.id === w.conditionalId);
477
- if (!L)
476
+ const D = f.find((B) => B.id === w.conditionalId);
477
+ if (!D)
478
478
  return;
479
- const E = w.id, y = await ot(t, L.condition);
480
- return Ut(!!y, E, i, l);
479
+ const E = w.id, y = await it(t, D.condition);
480
+ return Wt(!!y, E, i, l);
481
481
  }
482
- }), Z = F({
482
+ }), tt = F({
483
483
  source: e.treeStore,
484
484
  effect: async ({ nodes: i, edges: l }, f) => {
485
- if (!at(f))
485
+ if (!ct(f))
486
486
  return;
487
487
  const w = f.action;
488
488
  if (!w) {
489
489
  x("warn", `Action node ${f.id} has no action name`);
490
490
  return;
491
491
  }
492
- const L = t.actions.getByName(w).getState();
493
- if (!L) {
492
+ const D = t.actions.getByName(w).getState();
493
+ if (!D) {
494
494
  x("warn", `Action '${w}' not registered on client`);
495
495
  const E = l.find(
496
496
  (y) => y.sourceNodeId === f.id && y.sourceNodeHandle === "false"
497
497
  );
498
498
  return E ? i.find((y) => y.id === E.destinationNodeId) : null;
499
499
  }
500
- if (typeof L.action != "function") {
500
+ if (typeof D.action != "function") {
501
501
  x("warn", `Action '${w}' is not a function`);
502
502
  const E = l.find(
503
503
  (y) => y.sourceNodeId === f.id && y.sourceNodeHandle === "false"
@@ -505,7 +505,7 @@ const Q = xt("experience-instance"), Wt = ut(
505
505
  return E ? i.find((y) => y.id === E.destinationNodeId) : null;
506
506
  }
507
507
  try {
508
- x("info", `Executing action: ${w}`), await L.action(w);
508
+ x("info", `Executing action: ${w}`), await D.action(w);
509
509
  const E = l.find(
510
510
  (B) => B.sourceNodeId === f.id && B.sourceNodeHandle === "true"
511
511
  );
@@ -516,65 +516,93 @@ const Q = xt("experience-instance"), Wt = ut(
516
516
  } catch (E) {
517
517
  x("warn", `Action '${w}' failed:`, E);
518
518
  const y = l.find(
519
- (U) => U.sourceNodeId === f.id && U.sourceNodeHandle === "false"
519
+ (W) => W.sourceNodeId === f.id && W.sourceNodeHandle === "false"
520
520
  );
521
521
  if (!y)
522
522
  return x("warn", `No 'false' edge found for action node ${f.id}`), null;
523
- const B = i.find((U) => U.id === y.destinationNodeId);
523
+ const B = i.find((W) => W.id === y.destinationNodeId);
524
524
  return x("info", `Action '${w}' failed, moving to node ${B?.id}`), B || null;
525
525
  }
526
526
  }
527
- }), wt = $((i) => {
528
- if (st(i))
527
+ }), Nt = $((i) => {
528
+ if (at(i))
529
529
  return t.launchExperienceById(i.experienceId);
530
- }), tt = F({
530
+ }), et = F({
531
531
  source: [I, e.treeStore],
532
- effect: async ([i, { nodes: l, edges: f }]) => J(i, l, f)
533
- }), P = F({
532
+ effect: async ([i, { nodes: l, edges: f }]) => Q(i, l, f)
533
+ }), C = F({
534
534
  source: [I, e.treeStore],
535
- effect: async ([i, { nodes: l, edges: f }]) => J(i, l, f)
536
- }), Nt = $((i) => {
535
+ effect: async ([i, { nodes: l, edges: f }]) => Q(i, l, f)
536
+ }), xt = $((i) => {
537
537
  t.history.push({ experienceId: e.id, node: i });
538
- }), et = F({
538
+ }), nt = F({
539
539
  source: e.configStore,
540
- effect: async ({ initializeOpenLogic: i }) => Bt(i) ? !!await ot(t, i) : i ?? !1
541
- }), X = k(), nt = k();
540
+ effect: async ({ initializeOpenLogic: i }) => Ft(i) ? !!await it(t, i) : i ?? !1
541
+ }), M = {
542
+ id: Math.random().toString(36).substring(7),
543
+ // config
544
+ experienceId: e.id,
545
+ configStore: e.configStore,
546
+ target: r,
547
+ componentStore: S,
548
+ // state
549
+ stateStore: A,
550
+ // open close
551
+ isOpenStore: v,
552
+ open: L.open,
553
+ close: L.close,
554
+ toggleOpen: L.toggle,
555
+ setOpen: L.set,
556
+ // nodes
557
+ treeStore: e.treeStore,
558
+ fieldsStore: e.fieldsStore,
559
+ currentNodeStore: I,
560
+ currentStepStore: u,
561
+ nextReachableStepNodesStore: h,
562
+ stepsToOriginStore: b,
563
+ stepsToLeafStore: T,
564
+ // history
565
+ goToNextStep: s,
566
+ goToPreviousStep: a,
567
+ goToStepById: o,
568
+ stepsHistoryStore: P
569
+ }, z = k(), rt = k();
542
570
  return m({
543
571
  source: I,
544
- target: X
572
+ target: z
545
573
  }), m({
546
- clock: X,
574
+ clock: z,
547
575
  filter: (i) => i === null,
548
- target: K
576
+ target: V
549
577
  }), m({
550
- clock: X,
578
+ clock: z,
551
579
  filter: (i) => i !== null,
552
- target: nt
553
- }), It({
554
- source: nt,
555
- match: (i) => it(i) ? "condition" : j(i) ? "step" : st(i) ? "launchExperience" : z(i) ? "origin" : at(i) ? "action" : "other",
580
+ target: rt
581
+ }), Et({
582
+ source: rt,
583
+ match: (i) => st(i) ? "condition" : U(i) ? "step" : at(i) ? "launchExperience" : J(i) ? "origin" : ct(i) ? "action" : "other",
556
584
  cases: {
557
- origin: V,
558
- condition: q,
559
- step: Y,
560
- launchExperience: wt,
561
- action: Z,
585
+ origin: q,
586
+ condition: X,
587
+ step: Z,
588
+ launchExperience: Nt,
589
+ action: tt,
562
590
  __: k()
563
591
  }
564
592
  }), m({
565
593
  clock: [
594
+ X.doneData,
566
595
  q.doneData,
567
596
  V.doneData,
568
- K.doneData,
569
- P.doneData,
570
- tt.doneData,
571
- Z.doneData
597
+ C.doneData,
598
+ et.doneData,
599
+ tt.doneData
572
600
  ],
573
601
  filter: Boolean,
574
- target: Nt
602
+ target: xt
575
603
  }), m({
576
604
  clock: s,
577
- target: P
605
+ target: C
578
606
  }), m({
579
607
  clock: s,
580
608
  source: u,
@@ -582,59 +610,63 @@ const Q = xt("experience-instance"), Wt = ut(
582
610
  target: t.eventBus.prepend((i) => ({
583
611
  type: "step_submit",
584
612
  step: i,
585
- experience: e
613
+ experience: e,
614
+ experienceInstance: M
586
615
  }))
587
616
  }), m({
588
- clock: P.done,
617
+ clock: C.done,
589
618
  source: u,
590
619
  filter: Boolean,
591
620
  target: t.eventBus.prepend((i) => ({
592
621
  type: "step_submit_success",
593
622
  step: i,
594
- experience: e
623
+ experience: e,
624
+ experienceInstance: M
595
625
  }))
596
626
  }), m({
597
- clock: P.fail,
627
+ clock: C.fail,
598
628
  source: u,
599
629
  filter: Boolean,
600
630
  target: t.eventBus.prepend((i) => ({
601
631
  type: "step_submit_error",
602
632
  step: i,
603
- experience: e
633
+ experience: e,
634
+ experienceInstance: M
604
635
  }))
605
636
  }), m({
606
637
  clock: a,
607
- target: ht
608
- }), m({ clock: o, target: yt }), m({
609
- source: C([
638
+ target: yt
639
+ }), m({ clock: o, target: wt }), m({
640
+ source: H([
641
+ X.pending,
610
642
  q.pending,
611
643
  V.pending,
612
- K.pending,
613
- P.pending
644
+ C.pending
614
645
  ]),
615
646
  fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
616
647
  target: A
617
648
  }), m({
618
- clock: Y.doneData,
649
+ clock: Z.doneData,
619
650
  source: u,
620
651
  filter: Boolean,
621
652
  target: t.eventBus.prepend((i) => ({
622
653
  type: "step_enter",
623
654
  step: i,
624
- experience: e
655
+ experience: e,
656
+ experienceInstance: M
625
657
  }))
626
658
  }), m({
627
659
  clock: d,
628
- target: et
660
+ target: nt
629
661
  }), m({
630
- source: et.doneData,
662
+ source: nt.doneData,
631
663
  fn: Boolean,
632
664
  target: v
633
665
  }), m({
634
666
  source: I,
635
667
  clock: n,
636
- filter: (i) => i ? z(i) : !0,
637
- target: tt
668
+ filter: (i) => i ? J(i) : !0,
669
+ target: et
638
670
  }), m({
639
671
  source: v,
640
672
  filter: Boolean,
@@ -644,53 +676,28 @@ const Q = xt("experience-instance"), Wt = ut(
644
676
  filter: Boolean,
645
677
  target: t.eventBus.prepend(() => ({
646
678
  type: "experience_open",
647
- experience: e
679
+ experience: e,
680
+ experienceInstance: M
648
681
  }))
649
682
  }), m({
650
683
  source: v,
651
684
  filter: (i) => !i,
652
685
  target: t.eventBus.prepend(() => ({
653
686
  type: "experience_close",
654
- experience: e
687
+ experience: e,
688
+ experienceInstance: M
655
689
  }))
656
690
  }), m({
657
691
  clock: c,
658
692
  target: [d]
659
- }), c(), {
660
- id: Math.random().toString(36).substring(7),
661
- // config
662
- experienceId: e.id,
663
- configStore: e.configStore,
664
- target: r,
665
- componentStore: S,
666
- // state
667
- stateStore: A,
668
- // open close
669
- isOpenStore: v,
670
- open: T.open,
671
- close: T.close,
672
- toggleOpen: T.toggle,
673
- setOpen: T.set,
674
- // nodes
675
- treeStore: e.treeStore,
676
- currentNodeStore: I,
677
- currentStepStore: u,
678
- nextReachableStepNodesStore: h,
679
- stepsToOriginStore: b,
680
- stepsToLeafStore: M,
681
- // history
682
- goToNextStep: s,
683
- goToPreviousStep: a,
684
- goToStepById: o,
685
- stepsHistoryStore: R
686
- };
693
+ }), c(), M;
687
694
  }
688
695
  );
689
- function Gt(t) {
690
- return ft(Wt, t);
696
+ function Kt(t) {
697
+ return lt(Gt, t);
691
698
  }
692
- const Kt = ut(({ client: t }) => {
693
- const e = Q.store({}), r = k(), n = k(), s = k(), a = ct(e, {
699
+ const Vt = ft(({ client: t }) => {
700
+ const e = Y.store({}), r = k(), n = k(), s = k(), a = ut(e, {
694
701
  register(u, h) {
695
702
  const b = [
696
703
  ...u[h.experienceId] ?? []
@@ -701,21 +708,21 @@ const Kt = ut(({ client: t }) => {
701
708
  };
702
709
  },
703
710
  unregister(u, h) {
704
- const b = h.experienceId, M = u[b]?.filter(
711
+ const b = h.experienceId, T = u[b]?.filter(
705
712
  (v) => v !== h
706
713
  );
707
714
  return {
708
715
  ...u,
709
- [b]: M ?? []
716
+ [b]: T ?? []
710
717
  };
711
718
  }
712
719
  }), o = $(
713
- ({ experience: u, target: h }) => Gt({ client: t, experience: u, target: h })
720
+ ({ experience: u, target: h }) => Kt({ client: t, experience: u, target: h })
714
721
  ), c = $((u) => {
715
722
  a.register(u);
716
723
  }), d = $(
717
724
  (u) => {
718
- u.target && Mt(u.target, () => {
725
+ u.target && Tt(u.target, () => {
719
726
  s(u);
720
727
  });
721
728
  }
@@ -735,19 +742,19 @@ const Kt = ut(({ client: t }) => {
735
742
  );
736
743
  return;
737
744
  }
738
- const M = u.target;
739
- if (!M) {
745
+ const T = u.target;
746
+ if (!T) {
740
747
  x(
741
748
  "error",
742
749
  `No target element registered for experience '${u.experienceId}'. Skipping rendering.`
743
750
  );
744
751
  return;
745
752
  }
746
- const v = $t(M);
753
+ const v = Mt(T);
747
754
  try {
748
755
  b.render(v, h.component, t, u);
749
- } catch (T) {
750
- x("error", T);
756
+ } catch (L) {
757
+ x("error", L);
751
758
  }
752
759
  });
753
760
  m({
@@ -776,28 +783,28 @@ const Kt = ut(({ client: t }) => {
776
783
  function _(u, h) {
777
784
  r({ experience: u, target: h });
778
785
  }
779
- const R = e.map((u) => Object.values(u).flat());
786
+ const P = e.map((u) => Object.values(u).flat());
780
787
  function I(u) {
781
788
  return e.map((h) => h[u] || [], { skipVoid: !1 });
782
789
  }
783
790
  return {
784
791
  spawn: _,
785
792
  getByExperienceId: I,
786
- listStore: R
793
+ listStore: P
787
794
  };
788
795
  });
789
- function ee(t) {
790
- return ft(Kt, t);
796
+ function ne(t) {
797
+ return lt(Vt, t);
791
798
  }
792
799
  export {
793
- j as a,
794
- ee as b,
795
- Zt as c,
796
- Qt as d,
797
- ot as e,
798
- Dt as f,
799
- Yt as g,
800
- Gt as h,
801
- Bt as i,
802
- te as t
800
+ U as a,
801
+ ne as b,
802
+ te as c,
803
+ Yt as d,
804
+ it as e,
805
+ Rt as f,
806
+ Zt as g,
807
+ Kt as h,
808
+ Ft as i,
809
+ ee as t
803
810
  };