@picked/client 0.0.1-dev.1778136207545 → 0.0.1-dev.1778212587319

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 (35) hide show
  1. package/dist/{api-Crj5wFbR.js → api-Cwiixs03.js} +1 -1
  2. package/dist/{api-NcKXNrkY.cjs → api-Cz_3UuGL.cjs} +1 -1
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  5. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  6. package/dist/cjs/server/index.js +1 -1
  7. package/dist/esm/index.js +318 -344
  8. package/dist/esm/plugins/dynamic-experiences/index.js +38 -103
  9. package/dist/esm/plugins/history-browser-storage/index.js +26 -10
  10. package/dist/esm/server/index.js +1 -1
  11. package/dist/experience-instance-DDZR8zjM.cjs +1 -0
  12. package/dist/{experience-instance-BrLWgVAN.js → experience-instance-dwfbKgOd.js} +178 -179
  13. package/dist/types/entities/experience/experience.d.ts +2 -23
  14. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  15. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  16. package/dist/types/entities/history/history.d.ts +28 -16
  17. package/dist/types/entities/history/history.d.ts.map +1 -1
  18. package/dist/types/entities/step/step.d.ts +0 -14
  19. package/dist/types/entities/step/step.d.ts.map +1 -1
  20. package/dist/types/index.d.ts +0 -2
  21. package/dist/types/index.d.ts.map +1 -1
  22. package/dist/types/picked.d.ts +8 -52
  23. package/dist/types/picked.d.ts.map +1 -1
  24. package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -2
  25. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  26. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +1 -18
  27. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  28. package/dist/types/plugins/dynamic-experiences/types.d.ts +1 -62
  29. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  30. package/dist/types/plugins/history-browser-storage/plugin.d.ts +19 -0
  31. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  32. package/package.json +1 -1
  33. package/dist/experience-instance-Ct3ogC7n.cjs +0 -1
  34. package/dist/types/entities/content/content.d.ts +0 -37
  35. package/dist/types/entities/content/content.d.ts.map +0 -1
package/dist/esm/index.js CHANGED
@@ -2,15 +2,15 @@ import { t as e } from "../object-DvUDOytC.js";
2
2
  import { n as t, t as n } from "../rules-logic-D_CVBuv7.js";
3
3
  import { t as r } from "../logger-6z_gb4rA.js";
4
4
  import { a as i, c as a, d as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "../supports-0XIfd4-R.js";
5
- import { a as g, c as _, i as v, l as y, n as b, o as ee, r as x, s as S } from "../experience-instance-BrLWgVAN.js";
5
+ import { a as g, c as _, i as v, l as y, n as b, o as ee, r as x, s as S } from "../experience-instance-dwfbKgOd.js";
6
6
  import { i as C, n as w, r as T, t as E } from "../storage-6Xk0uAxB.js";
7
- import { n as D, r as te } from "../api-Crj5wFbR.js";
8
- import { t as ne } from "../id-CRqy981z.js";
9
- import { attach as O, combine as k, createApi as A, createDomain as j, createEffect as M, createEvent as N, createStore as P, sample as F } from "effector";
10
- import { createFactory as I, invoke as L } from "@withease/factories";
7
+ import { n as D, r as te } from "../api-Cwiixs03.js";
8
+ import { t as O } from "../id-CRqy981z.js";
9
+ import { attach as k, combine as A, createApi as j, createDomain as M, createEffect as N, createEvent as P, createStore as F, sample as I } from "effector";
10
+ import { createFactory as L, invoke as R } from "@withease/factories";
11
11
  //#region src/entities/experience/experience.ts
12
- var re = j("experience"), ie = I(({ client: e, experience: r }) => {
13
- let i = re.store(r), a = A(i, { merge(e, t) {
12
+ var ne = M("experience"), re = L(({ client: e, experience: r }) => {
13
+ let i = ne.store(r), a = j(i, { merge(e, t) {
14
14
  return {
15
15
  ...e,
16
16
  ...t.experience
@@ -20,7 +20,7 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
20
20
  decisionLogic: e.condition,
21
21
  targetSelectors: e.targets,
22
22
  initializeOpenLogic: e.initializeOpen
23
- })), s = k(i, e.components.listStore, (e, t) => (e.componentName ? t.find((t) => t.name === e.componentName) : void 0) || t.find((t) => t.name === `experience:${e.id}`) || t.find((e) => e.name === "experience"), { skipVoid: !1 }), c = k(i, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
23
+ })), s = A(i, e.components.listStore, (e, t) => (e.componentName ? t.find((t) => t.name === e.componentName) : void 0) || t.find((t) => t.name === `experience:${e.id}`) || t.find((e) => e.name === "experience"), { skipVoid: !1 }), c = A(i, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
24
24
  let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(x).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
25
25
  return {
26
26
  steps: r,
@@ -28,7 +28,7 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
28
28
  edges: e.edges,
29
29
  conditions: i
30
30
  };
31
- }), l = r.actions ?? [], u, d = O({
31
+ }), l = r.actions ?? [], u, d = k({
32
32
  source: o,
33
33
  effect: (t, n) => {
34
34
  let i = S(t.targetSelectors, r.id);
@@ -36,8 +36,8 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
36
36
  n ? e.experienceInstances.spawn(u, t, n) : e.experienceInstances.spawn(u, t);
37
37
  });
38
38
  }
39
- }), f = O({
40
- source: k({
39
+ }), f = k({
40
+ source: A({
41
41
  preconditionPassed: e.preconditionPassedStore,
42
42
  isUser: e.session.store.map((e) => e.isUser, { skipVoid: !1 }),
43
43
  config: o
@@ -61,22 +61,22 @@ var re = j("experience"), ie = I(({ client: e, experience: r }) => {
61
61
  shouldInitialiseFx: f
62
62
  }, u;
63
63
  });
64
- function ae(e) {
65
- return L(ie, e);
64
+ function ie(e) {
65
+ return R(re, e);
66
66
  }
67
- var oe = I(({ client: e }) => {
68
- let t = re.store({}), n = A(t, { register(e, t) {
67
+ var ae = L(({ client: e }) => {
68
+ let t = ne.store({}), n = j(t, { register(e, t) {
69
69
  return {
70
70
  ...e,
71
71
  [t.id]: t
72
72
  };
73
- } }), r = N(), i = M((t) => {
74
- n.register(ae({
73
+ } }), r = P(), i = N((t) => {
74
+ n.register(ie({
75
75
  client: e,
76
76
  experience: t
77
77
  }));
78
78
  });
79
- F({
79
+ I({
80
80
  clock: r,
81
81
  source: t,
82
82
  filter: (e, t) => e[t.id] !== void 0,
@@ -89,7 +89,7 @@ var oe = I(({ client: e }) => {
89
89
  experience: t,
90
90
  strategy: "override"
91
91
  });
92
- }), F({
92
+ }), I({
93
93
  clock: r,
94
94
  source: t,
95
95
  filter: (e, t) => e[t.id] === void 0,
@@ -103,20 +103,20 @@ var oe = I(({ client: e }) => {
103
103
  function s(e) {
104
104
  return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
105
105
  }
106
- let c = O({
106
+ let c = k({
107
107
  source: t,
108
- effect: async (t, n) => {
109
- let r = "key" in n ? Object.values(t).find((e) => e.key === n.key) : t[n.id];
110
- if (!r) {
111
- "key" in n ? `${n.key}` : `${n.id}`;
108
+ effect: async (e, t) => {
109
+ let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
110
+ if (!n) {
111
+ "key" in t ? `${t.key}` : `${t.id}`;
112
112
  return;
113
113
  }
114
- let { options: i } = n;
115
- if (i?.bypassCondition) {
116
- await R(e, r), await r.initialiseFx(i);
114
+ let { options: r } = t;
115
+ if (r?.bypassCondition) {
116
+ await n.initialiseFx(r);
117
117
  return;
118
118
  }
119
- await r.shouldInitialiseFx() && (await R(e, r), await r.initialiseFx(i));
119
+ await n.shouldInitialiseFx() && await n.initialiseFx(r);
120
120
  }
121
121
  });
122
122
  return {
@@ -125,7 +125,7 @@ var oe = I(({ client: e }) => {
125
125
  getById: o,
126
126
  getByKey: s,
127
127
  launch: c,
128
- open: O({
128
+ open: k({
129
129
  source: {
130
130
  experiences: t,
131
131
  instances: e.experienceInstances.listStore
@@ -152,41 +152,30 @@ var oe = I(({ client: e }) => {
152
152
  }
153
153
  }),
154
154
  listStore: a,
155
- initialiseExperiencesFx: O({
155
+ initialiseExperiencesFx: k({
156
156
  source: a,
157
- effect: async (t) => {
158
- await Promise.all(t.map(async (t) => {
159
- await t.shouldInitialiseFx() && (await R(e, t), await t.initialiseFx(void 0));
157
+ effect: async (e) => {
158
+ await Promise.all(e.map(async (e) => {
159
+ await e.shouldInitialiseFx() && await e.initialiseFx(void 0);
160
160
  }));
161
161
  }
162
162
  })
163
163
  };
164
164
  });
165
- function se(e) {
166
- return L(oe, e);
165
+ function oe(e) {
166
+ return R(ae, e);
167
167
  }
168
- var ce = async (e) => {
168
+ var se = async (e) => {
169
169
  await e.experiences.initialiseExperiencesFx();
170
- }, R = async (e, t) => {
171
- if (!e.contentLoader) return !0;
172
- try {
173
- await e.contentLoader({
174
- id: t.id,
175
- key: t.key
176
- });
177
- } catch {
178
- `${t.id}`;
179
- }
180
- return !0;
181
170
  };
182
171
  //#endregion
183
172
  //#region src/entities/plugin/plugin.ts
184
- function le(e) {
185
- return M(async () => {
173
+ function ce(e) {
174
+ return N(async () => {
186
175
  await e();
187
176
  });
188
177
  }
189
- var ue = (e, t, n) => {
178
+ var le = (e, t, n) => {
190
179
  let r = t.name, i = t.setup(e);
191
180
  if (i) {
192
181
  let e = n[r] ?? {};
@@ -195,29 +184,29 @@ var ue = (e, t, n) => {
195
184
  ...i
196
185
  });
197
186
  }
198
- }, de = j("component"), fe = I(({ client: e, component: t, name: n }) => ({
187
+ }, ue = M("component"), de = L(({ client: e, component: t, name: n }) => ({
199
188
  name: n,
200
189
  component: t,
201
190
  frameworkStore: e.frameworks.getByName(t.frameworkName)
202
191
  }));
203
- function pe(e) {
204
- return L(fe, e);
192
+ function fe(e) {
193
+ return R(de, e);
205
194
  }
206
- var me = I(({ client: e }) => {
207
- let t = de.store({}), n = A(t, { register(e, t) {
195
+ var pe = L(({ client: e }) => {
196
+ let t = ue.store({}), n = j(t, { register(e, t) {
208
197
  return {
209
198
  ...e,
210
199
  [t.name]: t
211
200
  };
212
- } }), i = N();
213
- F({
201
+ } }), i = P();
202
+ I({
214
203
  clock: i,
215
204
  source: t,
216
205
  filter: (e, { name: t }) => e[t] !== void 0,
217
206
  fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
218
- }).watch((e) => /* @__PURE__ */ r("warn", e)), F({
207
+ }).watch((e) => /* @__PURE__ */ r("warn", e)), I({
219
208
  clock: i,
220
- fn: ({ name: t, component: n }) => pe({
209
+ fn: ({ name: t, component: n }) => fe({
221
210
  client: e,
222
211
  name: t,
223
212
  component: n
@@ -234,27 +223,27 @@ var me = I(({ client: e }) => {
234
223
  listStore: a
235
224
  };
236
225
  });
237
- function he(e) {
238
- return L(me, e);
226
+ function me(e) {
227
+ return R(pe, e);
239
228
  }
240
- var ge = (e, t, n) => {
229
+ var he = (e, t, n) => {
241
230
  n.register({
242
231
  name: e,
243
232
  component: t
244
233
  });
245
- }, _e = j("framework"), ve = I((e) => {
246
- let t = _e.store({}), n = A(t, { register(e, t) {
234
+ }, ge = M("framework"), _e = L((e) => {
235
+ let t = ge.store({}), n = j(t, { register(e, t) {
247
236
  return {
248
237
  ...e,
249
238
  [t.name]: t.framework
250
239
  };
251
- } }), i = N();
252
- F({
240
+ } }), i = P();
241
+ I({
253
242
  clock: i,
254
243
  source: t,
255
244
  filter: (e, { name: t }) => e[t] !== void 0,
256
245
  fn: (e, { name: t }) => `Framework '${t}' already registered. Registering again will override the previous registration.`
257
- }).watch((e) => /* @__PURE__ */ r("warn", e)), F({
246
+ }).watch((e) => /* @__PURE__ */ r("warn", e)), I({
258
247
  clock: i,
259
248
  target: n.register
260
249
  });
@@ -268,34 +257,34 @@ var ge = (e, t, n) => {
268
257
  listStore: a
269
258
  };
270
259
  });
271
- function ye(e) {
272
- return L(ve, e);
260
+ function ve(e) {
261
+ return R(_e, e);
273
262
  }
274
- var be = (e, t) => {
263
+ var ye = (e, t) => {
275
264
  t.register({
276
265
  name: e.name,
277
266
  framework: e
278
267
  });
279
- }, xe = I(({ client: e }) => {
268
+ }, be = L(({ client: e }) => {
280
269
  let t = typeof window < "u", n = {
281
270
  location: t ? window.location : void 0,
282
271
  document: t ? window.document : void 0,
283
272
  sessionStorage: t ? window.sessionStorage : void 0,
284
273
  localStorage: t ? window.localStorage : void 0
285
274
  };
286
- return k(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
275
+ return A(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
287
276
  client: e,
288
277
  responses: t,
289
278
  fields: r,
290
279
  ...n
291
280
  }));
292
281
  });
293
- function Se(e) {
294
- return L(xe, e);
282
+ function xe(e) {
283
+ return R(be, e);
295
284
  }
296
285
  //#endregion
297
286
  //#region src/logic-engine.ts
298
- function Ce(e) {
287
+ function Se(e) {
299
288
  return typeof e == "number" && !isNaN(e);
300
289
  }
301
290
  function z(e) {
@@ -311,14 +300,14 @@ function H(e) {
311
300
  return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
312
301
  }
313
302
  function U(e) {
314
- if (Ce(e)) return e;
303
+ if (Se(e)) return e;
315
304
  let t = parseFloat(`${e}`);
316
305
  return isNaN(t) ? 0 : t;
317
306
  }
318
307
  function W(e) {
319
308
  return `${e}`;
320
309
  }
321
- var we = {
310
+ var Ce = {
322
311
  "==": (e, t) => e == t,
323
312
  "===": (e, t) => e === t,
324
313
  "!=": (e, t) => e != t,
@@ -416,7 +405,7 @@ async function G(e, t) {
416
405
  if (V(e)) return G(await e, t);
417
406
  if (B(e)) return Promise.all(e.map((e) => G(e, t)));
418
407
  if (!H(e)) return e;
419
- let n = Te(e), r = n ? e[n] ?? [] : [];
408
+ let n = we(e), r = n ? e[n] ?? [] : [];
420
409
  switch (B(r) || (r = [r]), n) {
421
410
  case "if":
422
411
  case "?:":
@@ -477,19 +466,19 @@ async function G(e, t) {
477
466
  return H(e) ? await G(e, t) : r[1] ? await G(r[1], e) : e instanceof Error ? e.message : e;
478
467
  }
479
468
  }
480
- let i = await Promise.all(r.map((e) => G(e, t))), a = n ? we[n] : void 0;
469
+ let i = await Promise.all(r.map((e) => G(e, t))), a = n ? Ce[n] : void 0;
481
470
  if (!a) throw Error(`Unrecognized operation ${n}`);
482
471
  return a.apply(t, i);
483
472
  }
484
473
  async function K(e) {
485
474
  return V(e) ? K(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
486
475
  }
487
- function Te(e) {
476
+ function we(e) {
488
477
  return Object.keys(e)[0];
489
478
  }
490
479
  //#endregion
491
480
  //#region src/lifecycle/rules-logic.ts
492
- var Ee = I(({ client: e }) => O({
481
+ var Te = L(({ client: e }) => k({
493
482
  source: {
494
483
  stateSnapshot: e.stateSnapshotStore,
495
484
  predicates: e.predicates.listStore,
@@ -528,15 +517,15 @@ var Ee = I(({ client: e }) => O({
528
517
  });
529
518
  }
530
519
  }));
531
- function De(e) {
532
- return L(Ee, e);
520
+ function Ee(e) {
521
+ return R(Te, e);
533
522
  }
534
523
  //#endregion
535
524
  //#region src/ping.ts
536
- var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
525
+ var De = 6e3, Oe = E("last_ping", "global"), ke = async (e) => {
537
526
  try {
538
- let t = Date.now(), n = w.get(ke), r = 0;
539
- if (n.isSet() && (r = n.json() ?? 0), r && t - r < Oe) return !0;
527
+ let t = Date.now(), n = w.get(Oe), r = 0;
528
+ if (n.isSet() && (r = n.json() ?? 0), r && t - r < De) return !0;
540
529
  let i = {
541
530
  projectId: e.projectId,
542
531
  path: window.location.pathname
@@ -547,118 +536,118 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
547
536
  } catch {
548
537
  return !1;
549
538
  }
550
- }, q = j("lifecycle"), je = I(({ client: e }) => {
551
- let t = q.store(!1), r = P(void 0, {
539
+ }, q = M("lifecycle"), Ae = L(({ client: e }) => {
540
+ let t = q.store(!1), r = F(void 0, {
552
541
  skipVoid: !1,
553
542
  domain: q
554
- }), i = P(void 0, {
543
+ }), i = F(void 0, {
555
544
  skipVoid: !1,
556
545
  domain: q
557
- }), a = q.store("idle"), o = q.store([]), s = P(void 0, {
546
+ }), a = q.store("idle"), o = q.store([]), s = F(void 0, {
558
547
  skipVoid: !1,
559
548
  domain: q
560
- }), c = P(void 0, {
549
+ }), c = F(void 0, {
561
550
  skipVoid: !1,
562
551
  domain: q
563
- }), l = N(), u = N(), d = N(), p = N(), m = N(), h = N();
552
+ }), l = P(), u = P(), d = P(), p = P(), m = P(), h = P();
564
553
  o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
565
- let g = M(() => {
566
- Ae(e);
567
- }), _ = M(async () => {
554
+ let g = N(() => {
555
+ ke(e);
556
+ }), _ = N(async () => {
568
557
  await ee();
569
- }), v = M(async () => {
570
- await ce(e);
571
- }), y = O({ effect: v }), b = O({
558
+ }), v = N(async () => {
559
+ await se(e);
560
+ }), y = k({ effect: v }), b = k({
572
561
  source: o,
573
562
  effect: async (e) => {
574
563
  for (let t of e) await t();
575
564
  }
576
- }), x = O({
565
+ }), x = k({
577
566
  source: s,
578
567
  effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
579
- }), S = O({
568
+ }), S = k({
580
569
  source: c,
581
570
  effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
582
- }), C = F({
571
+ }), C = I({
583
572
  clock: l,
584
573
  filter: () => f()
585
574
  });
586
- F({
575
+ I({
587
576
  clock: C,
588
577
  fn: () => "starting",
589
578
  target: a
590
- }), F({
579
+ }), I({
591
580
  clock: C,
592
581
  target: g
593
- }), F({
582
+ }), I({
594
583
  clock: C,
595
584
  target: b
596
- }), F({
585
+ }), I({
597
586
  clock: C,
598
587
  target: _
599
- }), F({
588
+ }), I({
600
589
  clock: b.done,
601
590
  target: x
602
- }), F({
591
+ }), I({
603
592
  clock: x.doneData,
604
593
  target: r
605
- }), F({
594
+ }), I({
606
595
  clock: S.doneData,
607
596
  target: i
608
- }), F({
597
+ }), I({
609
598
  clock: x.doneData,
610
599
  filter: (e) => e,
611
600
  target: S
612
- }), F({
601
+ }), I({
613
602
  clock: S.doneData,
614
603
  target: e.session.setIsUser
615
- }), F({
604
+ }), I({
616
605
  clock: S.doneData,
617
606
  fn: (e) => ({
618
607
  type: "user_decide",
619
608
  value: e
620
609
  }),
621
610
  target: e.eventBus
622
- }), F({
611
+ }), I({
623
612
  clock: x.doneData,
624
613
  filter: (e) => !e,
625
614
  fn: () => void 0,
626
615
  target: d
627
- }), F({
616
+ }), I({
628
617
  clock: S.doneData,
629
618
  fn: () => void 0,
630
619
  target: d
631
- }), F({
620
+ }), I({
632
621
  clock: d,
633
622
  fn: () => ({ type: "initialize" }),
634
623
  target: e.eventBus
635
624
  });
636
- let w = P(!1).on(_.done, () => !0), T = P(!1).on(d, () => !0), E = P(!1).on(y.done, () => !0), D = k(r, i, (e, t) => e === !0 && t === !0);
637
- return F({
625
+ let w = F(!1).on(_.done, () => !0), T = F(!1).on(d, () => !0), E = F(!1).on(y.done, () => !0), D = A(r, i, (e, t) => e === !0 && t === !0);
626
+ return I({
638
627
  clock: d,
639
628
  source: D,
640
629
  filter: (e) => e,
641
630
  fn: () => void 0,
642
631
  target: v
643
- }), F({
644
- clock: k(w, T, D, (e, t, n) => e && t && n),
632
+ }), I({
633
+ clock: A(w, T, D, (e, t, n) => e && t && n),
645
634
  filter: (e) => e,
646
635
  fn: () => void 0,
647
636
  target: y
648
- }), F({
649
- clock: k(w, T, D, E, (e, t, n, r) => e && t && (!n || r)),
637
+ }), I({
638
+ clock: A(w, T, D, E, (e, t, n, r) => e && t && (!n || r)),
650
639
  filter: (e) => e,
651
640
  fn: () => void 0,
652
641
  target: u
653
- }), F({
642
+ }), I({
654
643
  clock: u,
655
644
  fn: () => "ready",
656
645
  target: a
657
- }), F({
646
+ }), I({
658
647
  clock: u,
659
648
  fn: () => ({ type: "ready" }),
660
649
  target: e.eventBus
661
- }), F({
650
+ }), I({
662
651
  clock: u,
663
652
  source: e.session.store,
664
653
  fn: ({ id: e, isUser: t, identifiers: n }) => ({
@@ -668,7 +657,7 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
668
657
  identifiers: n
669
658
  }),
670
659
  target: e.eventBus
671
- }), F({
660
+ }), I({
672
661
  clock: [
673
662
  b.fail,
674
663
  x.fail,
@@ -690,13 +679,13 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
690
679
  setCondition: h
691
680
  };
692
681
  });
693
- function Me(e) {
694
- return L(je, e);
682
+ function je(e) {
683
+ return R(Ae, e);
695
684
  }
696
685
  //#endregion
697
686
  //#region src/entities/predicate/predicate.ts
698
- var Ne = j("predicate"), Pe = I(({ client: e }) => {
699
- let t = Ne.store({}), n = A(t, { register(e, t) {
687
+ var Me = M("predicate"), Ne = L(({ client: e }) => {
688
+ let t = Me.store({}), n = j(t, { register(e, t) {
700
689
  return {
701
690
  ...e,
702
691
  [t.name]: {
@@ -704,13 +693,13 @@ var Ne = j("predicate"), Pe = I(({ client: e }) => {
704
693
  predicate: t.predicate
705
694
  }
706
695
  };
707
- } }), i = N();
708
- F({
696
+ } }), i = P();
697
+ I({
709
698
  clock: i,
710
699
  source: t,
711
700
  filter: (e, { name: t }) => e[t] !== void 0,
712
701
  fn: (e, { name: t }) => `Predicate '${t}' already registered. Registering again will override the previous registration.`
713
- }).watch((e) => /* @__PURE__ */ r("warn", e)), F({
702
+ }).watch((e) => /* @__PURE__ */ r("warn", e)), I({
714
703
  clock: i,
715
704
  fn: ({ name: e, predicate: t }) => Object.freeze({
716
705
  name: e,
@@ -723,7 +712,7 @@ var Ne = j("predicate"), Pe = I(({ client: e }) => {
723
712
  return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
724
713
  }
725
714
  function s(t) {
726
- let n = P(() => void 0, { skipVoid: !1 }), r = O({
715
+ let n = F(() => void 0, { skipVoid: !1 }), r = k({
727
716
  source: {
728
717
  predicate: o(t),
729
718
  snapshot: e.stateSnapshotStore
@@ -735,13 +724,13 @@ var Ne = j("predicate"), Pe = I(({ client: e }) => {
735
724
  });
736
725
  }
737
726
  });
738
- return F({
727
+ return I({
739
728
  source: {
740
729
  responses: e.responses.listStore,
741
730
  fields: e.fields.listStore
742
731
  },
743
732
  target: r
744
- }), F({
733
+ }), I({
745
734
  clock: r.doneData,
746
735
  filter: (e) => e !== void 0,
747
736
  target: n
@@ -754,27 +743,27 @@ var Ne = j("predicate"), Pe = I(({ client: e }) => {
754
743
  getEvokablePredicate: s
755
744
  };
756
745
  });
757
- function Fe(e) {
758
- return L(Pe, e);
746
+ function Pe(e) {
747
+ return R(Ne, e);
759
748
  }
760
- var Ie = (e, t, n) => {
749
+ var Fe = (e, t, n) => {
761
750
  n.register({
762
751
  name: e,
763
752
  predicate: t
764
753
  });
765
- }, Le = j("feature"), Re = I(({ client: e }) => {
766
- let t = Le.store({}), n = Le.store([]), i = A(t, { register(e, t) {
754
+ }, J = M("feature"), Ie = L(({ client: e }) => {
755
+ let t = J.store({}), n = J.store([]), i = j(t, { register(e, t) {
767
756
  return {
768
757
  ...e,
769
758
  [t.id]: t.feature
770
759
  };
771
- } }), a = N();
772
- F({
760
+ } }), a = P();
761
+ I({
773
762
  clock: a,
774
763
  source: t,
775
764
  filter: (e, { id: t }) => e[t] !== void 0,
776
765
  fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
777
- }).watch((e) => /* @__PURE__ */ r("warn", e)), F({
766
+ }).watch((e) => /* @__PURE__ */ r("warn", e)), I({
778
767
  clock: a,
779
768
  fn: ({ id: e, feature: t }) => Object.freeze({
780
769
  id: e,
@@ -788,7 +777,7 @@ var Ie = (e, t, n) => {
788
777
  }),
789
778
  target: i.register
790
779
  });
791
- let o = M(async ({ id: e, key: t, storage: n = "local" }) => {
780
+ let o = N(async ({ id: e, key: t, storage: n = "local" }) => {
792
781
  let r = E(`feature:${e}:${t}`, "global"), i = (n === "session" ? T : w).get(r).boolean();
793
782
  return i === null ? null : {
794
783
  id: e,
@@ -796,11 +785,11 @@ var Ie = (e, t, n) => {
796
785
  bucket: i,
797
786
  storage: n
798
787
  };
799
- }), s = M((e) => {
788
+ }), s = N((e) => {
800
789
  if (!e) return null;
801
790
  let t = E(`feature:${e.id}:${e.key}`, "global");
802
791
  (e.storage === "session" ? T : w).set(t, e.bucket);
803
- }), c = /* @__PURE__ */ new Map(), l = O({
792
+ }), c = /* @__PURE__ */ new Map(), l = k({
804
793
  source: {
805
794
  allFeaturesStore: t,
806
795
  resolvedFeaturesStore: n
@@ -831,7 +820,7 @@ var Ie = (e, t, n) => {
831
820
  };
832
821
  }
833
822
  });
834
- F({
823
+ I({
835
824
  clock: i.register,
836
825
  fn: (e) => {
837
826
  let { id: t, feature: n } = e;
@@ -842,7 +831,7 @@ var Ie = (e, t, n) => {
842
831
  };
843
832
  },
844
833
  target: o
845
- }), F({
834
+ }), I({
846
835
  source: t,
847
836
  clock: l.doneData,
848
837
  fn: (e, t) => {
@@ -856,7 +845,7 @@ var Ie = (e, t, n) => {
856
845
  },
857
846
  target: s
858
847
  });
859
- let u = k({
848
+ let u = A({
860
849
  allFeaturesStore: t,
861
850
  resolvedFeaturesStore: n
862
851
  }).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
@@ -878,7 +867,7 @@ var Ie = (e, t, n) => {
878
867
  isResolved: !1
879
868
  };
880
869
  }));
881
- F({
870
+ I({
882
871
  clock: l.doneData,
883
872
  source: { resolvedFeatures: n },
884
873
  filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
@@ -887,7 +876,7 @@ var Ie = (e, t, n) => {
887
876
  type: "feature_decide",
888
877
  feature: e
889
878
  }))
890
- }), F({
879
+ }), I({
891
880
  clock: [o.doneData, l.doneData],
892
881
  source: n,
893
882
  fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
@@ -900,17 +889,17 @@ var Ie = (e, t, n) => {
900
889
  return t.map((t) => t[e], { skipVoid: !1 });
901
890
  }
902
891
  function p(e) {
903
- let t = P(async () => void 0, { skipVoid: !1 }), r = O({
892
+ let t = F(async () => void 0, { skipVoid: !1 }), r = k({
904
893
  source: d(e),
905
894
  effect: async (e) => {
906
895
  if (e) return async () => (await e.getBucket()).bucket;
907
896
  }
908
897
  });
909
- return F({
898
+ return I({
910
899
  source: n,
911
900
  filter: (t) => t.some((t) => t.id === e),
912
901
  target: r
913
- }), F({
902
+ }), I({
914
903
  clock: r.doneData,
915
904
  filter: (e) => e !== void 0,
916
905
  target: t
@@ -924,69 +913,89 @@ var Ie = (e, t, n) => {
924
913
  getEvokableFeature: p
925
914
  };
926
915
  });
927
- function ze(e) {
928
- return L(Re, e);
916
+ function Le(e) {
917
+ return R(Ie, e);
929
918
  }
930
- var Be = (e, t, n) => {
919
+ var Re = (e, t, n) => {
931
920
  n.register({
932
921
  id: e,
933
922
  feature: t
934
923
  });
935
- }, J = j("history");
936
- function Y(e, t) {
924
+ }, Y = M("history");
925
+ function X(e, t, n) {
937
926
  return {
938
- id: ne(`history-entry-${Date.now()}-${Math.random()}}`),
939
- node: t,
927
+ id: O("history-entry"),
928
+ node: n,
940
929
  at: Date.now(),
941
- experienceId: e
930
+ instanceId: e,
931
+ experienceId: t
942
932
  };
943
933
  }
944
- var Ve = I(() => {
945
- let e = J.store({ entries: [] }), t = J.event(), n = J.event(), r = J.event(), i = J.event();
946
- e.on(t, (e, t) => ({ entries: [...e.entries, Y(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), Y(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
947
- function a(e, t) {
948
- let n = {
949
- lastStepIndex: -1,
950
- secondLastStepIndex: -1
951
- };
952
- for (let r = e.length - 1; r >= 0; r--) {
953
- let i = e[r], a = i?.node;
954
- if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
955
- else {
956
- n.secondLastStepIndex = r;
934
+ function ze(e) {
935
+ let t = e.findLastIndex((e) => v(e.node));
936
+ return t === -1 ? [] : e.slice(0, t + 1);
937
+ }
938
+ var Be = L(() => {
939
+ let e = Y.store([]), t = Y.event(), n = Y.event(), r = Y.event(), i = Y.event(), a = Y.event(), o = Y.event();
940
+ e.on(t, (e, t) => [...e, X(t.instanceId, t.experienceId, t.node)]), e.on(n, (e, t) => {
941
+ let n = X(t.instanceId, t.experienceId, t.node), r = e.findLastIndex((e) => e.instanceId === t.instanceId);
942
+ return r === -1 ? [...e, n] : e.with(r, n);
943
+ }), e.on(r, (e, { instanceId: t }) => {
944
+ let n = 0, r = -1;
945
+ for (let i = e.length - 1; i >= 0; i--) {
946
+ let a = e[i];
947
+ if (!(a?.instanceId !== t || !v(a.node)) && (n += 1, n === 2)) {
948
+ r = i;
957
949
  break;
958
950
  }
959
951
  }
952
+ return r === -1 ? e : e.filter((e, n) => e.instanceId !== t || n <= r);
953
+ }), e.on(i, (e, { snapshots: t }) => Object.values(t).flat()), e.on(o, (e, t) => [...e, ...t]);
954
+ let s = e.map((e) => {
955
+ let t = /* @__PURE__ */ new Map();
956
+ for (let n of e) t.set(n.experienceId, n.instanceId);
957
+ let n = {};
958
+ for (let r of e) {
959
+ if (t.get(r.experienceId) !== r.instanceId) continue;
960
+ let e = n[r.experienceId] ?? [];
961
+ e.push(r), n[r.experienceId] = e;
962
+ }
960
963
  return n;
961
- }
962
- return e.on(r, (e, t) => {
963
- let { secondLastStepIndex: n } = a(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
964
- return {
964
+ });
965
+ return I({
966
+ clock: a,
967
+ source: s,
968
+ fn: (e, { instanceId: t, experienceId: n }) => ze(e[n] ?? []).map((e) => ({
965
969
  ...e,
966
- entries: r
967
- };
970
+ id: O("history-entry"),
971
+ instanceId: t,
972
+ at: Date.now()
973
+ })),
974
+ target: o
968
975
  }), {
969
976
  push: t,
970
977
  replace: n,
971
978
  back: r,
972
- restore: i,
973
- entriesStore: e.map((e) => e.entries)
979
+ restoreSnapshots: i,
980
+ seedInstanceFromSnapshot: a,
981
+ entriesStore: e,
982
+ snapshotStore: s
974
983
  };
975
984
  });
976
- function He() {
977
- return L(Ve);
985
+ function Ve() {
986
+ return R(Be);
978
987
  }
979
988
  //#endregion
980
989
  //#region src/utils/events.ts
981
- var Ue = 0, We = (e) => {
982
- let t = P([]);
990
+ var He = 0, Ue = (e) => {
991
+ let t = F([]);
983
992
  return t.on(e, (e, t) => [...e, {
984
- id: Ue++,
993
+ id: He++,
985
994
  at: /* @__PURE__ */ new Date(),
986
995
  payload: t
987
996
  }]), t;
988
- }, Ge = j("field"), Ke = I(() => {
989
- let e = Ge.store({}), t = A(e, {
997
+ }, We = M("field"), Ge = L(() => {
998
+ let e = We.store({}), t = j(e, {
990
999
  register(e, t) {
991
1000
  return {
992
1001
  ...e,
@@ -1034,13 +1043,13 @@ var Ue = 0, We = (e) => {
1034
1043
  getByName: c
1035
1044
  };
1036
1045
  });
1037
- function qe() {
1038
- return L(Ke);
1046
+ function Ke() {
1047
+ return R(Ge);
1039
1048
  }
1040
1049
  //#endregion
1041
1050
  //#region src/entities/step/step.ts
1042
- var Je = j("step"), Ye = I(() => {
1043
- let e = Je.store({}), t = A(e, { register(e, t) {
1051
+ var qe = M("step"), Je = L(() => {
1052
+ let e = qe.store({}), t = j(e, { register(e, t) {
1044
1053
  return {
1045
1054
  ...e,
1046
1055
  [t.step.id]: t.step
@@ -1064,45 +1073,16 @@ var Je = j("step"), Ye = I(() => {
1064
1073
  indexStore: e
1065
1074
  };
1066
1075
  });
1067
- function Xe() {
1068
- return L(Ye);
1069
- }
1070
- function Ze(e, t) {
1071
- t.register(e);
1072
- }
1073
- //#endregion
1074
- //#region src/entities/content/content.ts
1075
- var Qe = j("content"), $e = I(() => {
1076
- let e = Qe.store({}), t = A(e, { register(e, t) {
1077
- return {
1078
- ...e,
1079
- [t.content.id]: t.content
1080
- };
1081
- } });
1082
- function n(e) {
1083
- t.register({ content: e });
1084
- }
1085
- let r = e.map((e) => Object.values(e));
1086
- function i(t) {
1087
- return e.map((e) => e[t] ?? null, { skipVoid: !1 });
1088
- }
1089
- return {
1090
- register: n,
1091
- getById: i,
1092
- listStore: r,
1093
- indexStore: e
1094
- };
1095
- });
1096
- function et() {
1097
- return L($e);
1076
+ function Ye() {
1077
+ return R(Je);
1098
1078
  }
1099
- function tt(e, t) {
1079
+ function Xe(e, t) {
1100
1080
  t.register(e);
1101
1081
  }
1102
1082
  //#endregion
1103
1083
  //#region src/entities/action/action.ts
1104
- var nt = j("action"), rt = I(({ client: e }) => {
1105
- let t = nt.store({}), n = A(t, { register(e, t) {
1084
+ var Ze = M("action"), Qe = L(({ client: e }) => {
1085
+ let t = Ze.store({}), n = j(t, { register(e, t) {
1106
1086
  return {
1107
1087
  ...e,
1108
1088
  [t.key]: {
@@ -1110,13 +1090,13 @@ var nt = j("action"), rt = I(({ client: e }) => {
1110
1090
  action: t.action
1111
1091
  }
1112
1092
  };
1113
- } }), i = N();
1114
- F({
1093
+ } }), i = P();
1094
+ I({
1115
1095
  clock: i,
1116
1096
  source: t,
1117
1097
  filter: (e, { key: t }) => e[t] !== void 0,
1118
1098
  fn: (e, { key: t }) => `Action '${t}' already registered. Registering again will override the previous registration.`
1119
- }).watch((e) => /* @__PURE__ */ r("warn", e)), F({
1099
+ }).watch((e) => /* @__PURE__ */ r("warn", e)), I({
1120
1100
  clock: i,
1121
1101
  fn: ({ key: e, action: t }) => Object.freeze({
1122
1102
  key: e,
@@ -1129,7 +1109,7 @@ var nt = j("action"), rt = I(({ client: e }) => {
1129
1109
  return t.map((t) => t[e]?.action, { skipVoid: !1 });
1130
1110
  }
1131
1111
  function s(t, n) {
1132
- let r = P(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, a = O({
1112
+ let r = F(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, a = k({
1133
1113
  source: {
1134
1114
  action: o(t),
1135
1115
  snapshot: e.stateSnapshotStore
@@ -1141,13 +1121,13 @@ var nt = j("action"), rt = I(({ client: e }) => {
1141
1121
  }, i);
1142
1122
  }
1143
1123
  });
1144
- return F({
1124
+ return I({
1145
1125
  source: {
1146
1126
  responses: e.responses.listStore,
1147
1127
  fields: e.fields.listStore
1148
1128
  },
1149
1129
  target: a
1150
- }), F({
1130
+ }), I({
1151
1131
  clock: a.doneData,
1152
1132
  filter: (e) => e !== void 0,
1153
1133
  target: r
@@ -1160,10 +1140,10 @@ var nt = j("action"), rt = I(({ client: e }) => {
1160
1140
  getEvokableAction: s
1161
1141
  };
1162
1142
  });
1163
- function it(e) {
1164
- return L(rt, e);
1143
+ function $e(e) {
1144
+ return R(Qe, e);
1165
1145
  }
1166
- var at = (e, t, n) => {
1146
+ var et = (e, t, n) => {
1167
1147
  n.register({
1168
1148
  key: e,
1169
1149
  action: t
@@ -1171,7 +1151,7 @@ var at = (e, t, n) => {
1171
1151
  };
1172
1152
  //#endregion
1173
1153
  //#region src/entities/response/response-validation.ts
1174
- function X(e, t, n, r) {
1154
+ function Z(e, t, n, r) {
1175
1155
  return {
1176
1156
  fieldKey: e.key,
1177
1157
  userMessage: n,
@@ -1179,62 +1159,62 @@ function X(e, t, n, r) {
1179
1159
  value: t
1180
1160
  };
1181
1161
  }
1182
- function Z(e) {
1162
+ function Q(e) {
1183
1163
  return e === null || e === "" || Array.isArray(e) && !e.length;
1184
1164
  }
1185
- function ot(e) {
1165
+ function tt(e) {
1186
1166
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
1187
1167
  }
1188
- function Q(e) {
1168
+ function nt(e) {
1189
1169
  try {
1190
1170
  return JSON.stringify(e), !0;
1191
1171
  } catch {
1192
1172
  return !1;
1193
1173
  }
1194
1174
  }
1195
- function st(e, t) {
1175
+ function rt(e, t) {
1196
1176
  return t.find((t) => t.key === e) ?? null;
1197
1177
  }
1198
- function ct(e, t) {
1178
+ function it(e, t) {
1199
1179
  return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
1200
1180
  }
1201
- function lt(e, t) {
1202
- if (e.type !== "object" || Z(t)) return null;
1181
+ function at(e, t) {
1182
+ if (e.type !== "object" || Q(t)) return null;
1203
1183
  if (e.multiple) {
1204
- if (!Array.isArray(t)) return X(e, t, "This field expects multiple values", "Field expects an array of objects.");
1184
+ if (!Array.isArray(t)) return Z(e, t, "This field expects multiple values", "Field expects an array of objects.");
1205
1185
  for (let n of t) {
1206
- if (typeof n != "object" || !n) return X(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
1207
- if (!Q(n)) return X(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1186
+ if (typeof n != "object" || !n) return Z(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
1187
+ if (!nt(n)) return Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1208
1188
  }
1209
1189
  return null;
1210
1190
  }
1211
- return Array.isArray(t) ? X(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? X(e, t, "This field expects an object value", "Field expects an object value.") : Q(t) ? null : X(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1191
+ return Array.isArray(t) ? Z(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? Z(e, t, "This field expects an object value", "Field expects an object value.") : nt(t) ? null : Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1212
1192
  }
1213
- function ut(e, t) {
1214
- if (Z(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
1193
+ function ot(e, t) {
1194
+ if (Q(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
1215
1195
  let n = Array.isArray(t) ? t : [t];
1216
1196
  if (e.type === "object") {
1217
1197
  let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
1218
- return n.every((e) => r.has(JSON.stringify(e))) ? null : X(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
1198
+ return n.every((e) => r.has(JSON.stringify(e))) ? null : Z(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
1219
1199
  }
1220
1200
  let r = e.options.map((e) => e.value);
1221
- return n.every((e) => !ot(e) || e === null ? !1 : r.includes(e)) ? null : X(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
1201
+ return n.every((e) => !tt(e) || e === null ? !1 : r.includes(e)) ? null : Z(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
1222
1202
  }
1223
- async function dt(t, n, r, i) {
1224
- if (n.validation && !e(n.validation) && !Z(r)) {
1203
+ async function st(t, n, r, i) {
1204
+ if (n.validation && !e(n.validation) && !Q(r)) {
1225
1205
  let e = i ? {
1226
1206
  $input: r,
1227
1207
  responses: i
1228
1208
  } : { $input: r }, a = await t(n.validation, e);
1229
- if (typeof a == "string") return X(n, r, a, `Field validation resulted in an error: ${a}.`);
1230
- if (a === !1) return X(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
1209
+ if (typeof a == "string") return Z(n, r, a, `Field validation resulted in an error: ${a}.`);
1210
+ if (a === !1) return Z(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
1231
1211
  }
1232
- return n.required && Z(r) ? X(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? X(n, r, "This field expects a single response", "Field expects a single response.") : null;
1212
+ return n.required && Q(r) ? Z(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? Z(n, r, "This field expects a single response", "Field expects a single response.") : null;
1233
1213
  }
1234
1214
  //#endregion
1235
1215
  //#region src/entities/response/response.ts
1236
- var ft = j("response"), pt = I(({ client: e }) => {
1237
- let t = ft.store({}), r = N(), i = N(), a = A(t, {
1216
+ var ct = M("response"), lt = L(({ client: e }) => {
1217
+ let t = ct.store({}), r = P(), i = P(), a = j(t, {
1238
1218
  register(e, t) {
1239
1219
  return {
1240
1220
  ...e,
@@ -1263,7 +1243,7 @@ var ft = j("response"), pt = I(({ client: e }) => {
1263
1243
  });
1264
1244
  } else a.registerBatch(e);
1265
1245
  }
1266
- let s = (t, r) => n(e, t, r), c = O({
1246
+ let s = (t, r) => n(e, t, r), c = k({
1267
1247
  source: {
1268
1248
  allFields: e.fields.listStore,
1269
1249
  existingResponses: t
@@ -1273,7 +1253,7 @@ var ft = j("response"), pt = I(({ client: e }) => {
1273
1253
  ...t,
1274
1254
  ...n
1275
1255
  }, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
1276
- let o = st(t, e);
1256
+ let o = rt(t, e);
1277
1257
  if (!o) {
1278
1258
  r.push({
1279
1259
  fieldKey: t,
@@ -1283,17 +1263,17 @@ var ft = j("response"), pt = I(({ client: e }) => {
1283
1263
  });
1284
1264
  return;
1285
1265
  }
1286
- let c = ct(o, n), l = await dt(s, o, c, a);
1266
+ let c = it(o, n), l = await st(s, o, c, a);
1287
1267
  if (l) {
1288
1268
  r.push(l);
1289
1269
  return;
1290
1270
  }
1291
- let u = lt(o, c);
1271
+ let u = at(o, c);
1292
1272
  if (u) {
1293
1273
  r.push(u);
1294
1274
  return;
1295
1275
  }
1296
- let d = ut(o, c);
1276
+ let d = ot(o, c);
1297
1277
  if (d) {
1298
1278
  r.push(d);
1299
1279
  return;
@@ -1321,7 +1301,7 @@ var ft = j("response"), pt = I(({ client: e }) => {
1321
1301
  async function l(e) {
1322
1302
  return c(e);
1323
1303
  }
1324
- let u = O({
1304
+ let u = k({
1325
1305
  source: t,
1326
1306
  effect: async (e, t) => {
1327
1307
  let { responsesToCommit: n, validationErrors: r } = await c(t);
@@ -1336,7 +1316,7 @@ var ft = j("response"), pt = I(({ client: e }) => {
1336
1316
  value: t
1337
1317
  })));
1338
1318
  function m(e) {
1339
- return k({
1319
+ return A({
1340
1320
  f: e,
1341
1321
  s: t
1342
1322
  }, ({ f: e, s: t }) => {
@@ -1353,10 +1333,10 @@ var ft = j("response"), pt = I(({ client: e }) => {
1353
1333
  function _(t) {
1354
1334
  return m(e.fields.getByName(t));
1355
1335
  }
1356
- return F({
1336
+ return I({
1357
1337
  clock: r,
1358
1338
  target: a.clearAll
1359
- }), F({
1339
+ }), I({
1360
1340
  clock: i,
1361
1341
  target: a.clear
1362
1342
  }), {
@@ -1372,13 +1352,13 @@ var ft = j("response"), pt = I(({ client: e }) => {
1372
1352
  getByFieldName: _
1373
1353
  };
1374
1354
  });
1375
- function mt(e) {
1376
- return L(pt, e);
1355
+ function ut(e) {
1356
+ return R(lt, e);
1377
1357
  }
1378
1358
  //#endregion
1379
1359
  //#region src/entities/condition/condition.ts
1380
- var ht = j("condition"), gt = I(() => {
1381
- let e = ht.store({}), t = A(e, { register(e, t) {
1360
+ var dt = M("condition"), ft = L(() => {
1361
+ let e = dt.store({}), t = j(e, { register(e, t) {
1382
1362
  return {
1383
1363
  ...e,
1384
1364
  [t.condition.id]: t.condition
@@ -1402,12 +1382,12 @@ var ht = j("condition"), gt = I(() => {
1402
1382
  indexStore: e
1403
1383
  };
1404
1384
  });
1405
- function _t() {
1406
- return L(gt);
1385
+ function pt() {
1386
+ return R(ft);
1407
1387
  }
1408
1388
  //#endregion
1409
1389
  //#region src/utils/api-url.ts
1410
- function vt() {
1390
+ function mt() {
1411
1391
  if (f()) {
1412
1392
  let e = [
1413
1393
  document.currentScript,
@@ -1422,7 +1402,7 @@ function vt() {
1422
1402
  }
1423
1403
  //#endregion
1424
1404
  //#region src/utils/search-params.ts
1425
- function yt() {
1405
+ function ht() {
1426
1406
  if (!o()) return {};
1427
1407
  let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
1428
1408
  for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
@@ -1440,13 +1420,13 @@ function yt() {
1440
1420
  }
1441
1421
  //#endregion
1442
1422
  //#region src/entities/session/session.ts
1443
- var bt = E("session", "global");
1444
- function xt() {
1423
+ var gt = E("session", "global");
1424
+ function _t() {
1445
1425
  return l() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
1446
1426
  }
1447
- function St() {
1427
+ function vt() {
1448
1428
  if (!u()) return null;
1449
- let e = w.get(bt);
1429
+ let e = w.get(gt);
1450
1430
  if (!e.isSet()) return null;
1451
1431
  try {
1452
1432
  return e.json();
@@ -1454,10 +1434,10 @@ function St() {
1454
1434
  return null;
1455
1435
  }
1456
1436
  }
1457
- var Ct = I(() => {
1458
- let e = St(), t = { id: e?.id ?? xt() };
1437
+ var yt = L(() => {
1438
+ let e = vt(), t = { id: e?.id ?? _t() };
1459
1439
  e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
1460
- let n = P(t), r = A(n, {
1440
+ let n = F(t), r = j(n, {
1461
1441
  setIsUser: (e, t) => ({
1462
1442
  ...e,
1463
1443
  isUser: t
@@ -1478,13 +1458,13 @@ var Ct = I(() => {
1478
1458
  return e.isUser !== void 0 && (i.isUser = e.isUser), Object.keys(r).length > 0 && (i.identifiers = r), i;
1479
1459
  }
1480
1460
  });
1481
- return F({
1461
+ return I({
1482
1462
  source: n,
1483
- target: O({
1463
+ target: k({
1484
1464
  source: n,
1485
1465
  effect: (e) => {
1486
1466
  if (u()) try {
1487
- w.get(bt).set(e);
1467
+ w.get(gt).set(e);
1488
1468
  } catch {}
1489
1469
  }
1490
1470
  })
@@ -1495,27 +1475,27 @@ var Ct = I(() => {
1495
1475
  removeIdentifier: r.removeIdentifier
1496
1476
  };
1497
1477
  });
1498
- function wt() {
1499
- return L(Ct, void 0);
1478
+ function bt() {
1479
+ return R(yt, void 0);
1500
1480
  }
1501
1481
  //#endregion
1502
1482
  //#region src/utils/picked-config.ts
1503
- function Tt() {
1483
+ function xt() {
1504
1484
  if (o()) return globalThis.window.pickedConfig;
1505
1485
  }
1506
- function Et() {
1507
- if (o()) return Tt()?.projectId;
1486
+ function St() {
1487
+ if (o()) return xt()?.projectId;
1508
1488
  }
1509
- function Dt() {
1489
+ function Ct() {
1510
1490
  if (!f()) return;
1511
1491
  let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
1512
1492
  if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
1513
1493
  }
1514
- function Ot(e) {
1494
+ function wt(e) {
1515
1495
  if (e.projectId) return e.projectId;
1516
- let t = Et();
1496
+ let t = St();
1517
1497
  if (t) return t;
1518
- let n = Dt();
1498
+ let n = Ct();
1519
1499
  if (n) return n;
1520
1500
  throw Error("projectId is required. You can provide it via one of:\n (1) createClient({ projectId }) options;\n (2) window.pickedConfig = { projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes a data-projectid (or project-id) attribute.");
1521
1501
  }
@@ -1524,7 +1504,7 @@ function Ot(e) {
1524
1504
  function $(e) {
1525
1505
  return e == null || e === "" || Number.isNaN(e);
1526
1506
  }
1527
- var kt = {
1507
+ var Tt = {
1528
1508
  default: (e, t) => $(e) ? String(t ?? "") : String(e),
1529
1509
  append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
1530
1510
  prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
@@ -1545,24 +1525,24 @@ var kt = {
1545
1525
  return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
1546
1526
  }
1547
1527
  };
1548
- function At(e) {
1528
+ function Et(e) {
1549
1529
  return typeof e == "object" && !!e;
1550
1530
  }
1551
- function jt(e, t) {
1531
+ function Dt(e, t) {
1552
1532
  let n = t;
1553
- for (let t of e.split(".")) if (At(n) && t in n) n = n[t];
1533
+ for (let t of e.split(".")) if (Et(n) && t in n) n = n[t];
1554
1534
  else return;
1555
1535
  return typeof n == "function" ? n() : n;
1556
1536
  }
1557
- function Mt(e, t) {
1558
- let n = e.split("|").map((e) => e.trim()), r = jt(n.shift() ?? "", t);
1537
+ function Ot(e, t) {
1538
+ let n = e.split("|").map((e) => e.trim()), r = Dt(n.shift() ?? "", t);
1559
1539
  for (let e of n) {
1560
- let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = kt[i];
1540
+ let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Tt[i];
1561
1541
  o && (r = o(r, a));
1562
1542
  }
1563
1543
  return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
1564
1544
  }
1565
- function Nt(e, t) {
1545
+ function kt(e, t) {
1566
1546
  let n = "", r = 0;
1567
1547
  for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
1568
1548
  r += 2;
@@ -1574,80 +1554,77 @@ function Nt(e, t) {
1574
1554
  }
1575
1555
  i += e[r++];
1576
1556
  }
1577
- n += Mt(i.trim(), t);
1557
+ n += Ot(i.trim(), t);
1578
1558
  } else n += e[r++];
1579
1559
  return n;
1580
1560
  }
1581
1561
  //#endregion
1582
1562
  //#region src/picked.ts
1583
- var Pt = class {
1563
+ var At = class {
1584
1564
  static logger = r;
1585
1565
  options;
1586
- dataSource = null;
1587
- contentLoader;
1588
1566
  plugins = {};
1589
- eventBus = N();
1567
+ eventBus = P();
1590
1568
  events;
1591
1569
  projectId;
1592
1570
  apiUrl;
1593
1571
  dashboardUrl;
1594
1572
  documentationSiteUrl;
1595
- session = wt();
1596
- searchParams = yt();
1597
- history = He();
1598
- components = he({ client: this });
1573
+ session = bt();
1574
+ searchParams = ht();
1575
+ history = Ve();
1576
+ components = me({ client: this });
1599
1577
  experienceInstances = b({ client: this });
1600
- experiences = se({ client: this });
1601
- frameworks = ye({ client: this });
1602
- predicates = Fe({ client: this });
1603
- features = ze({ client: this });
1604
- conditions = _t();
1605
- fields = qe();
1606
- responses = mt({ client: this });
1607
- steps = Xe();
1608
- contents = et();
1609
- actions = it({ client: this });
1610
- stateSnapshotStore = Se({ client: this });
1611
- evaluateRuleLogicFx = De({ client: this });
1578
+ experiences = oe({ client: this });
1579
+ frameworks = ve({ client: this });
1580
+ predicates = Pe({ client: this });
1581
+ features = Le({ client: this });
1582
+ conditions = pt();
1583
+ fields = Ke();
1584
+ responses = ut({ client: this });
1585
+ steps = Ye();
1586
+ actions = $e({ client: this });
1587
+ stateSnapshotStore = xe({ client: this });
1588
+ evaluateRuleLogicFx = Ee({ client: this });
1612
1589
  start;
1613
1590
  readyStore;
1614
1591
  preconditionPassedStore;
1615
1592
  conditionPassedStore;
1616
1593
  lifecycleStageStore;
1617
- lifecycle = Me({ client: this });
1618
- renderStringFx = O({
1594
+ lifecycle = je({ client: this });
1595
+ renderStringFx = k({
1619
1596
  source: this.responses.listStore,
1620
1597
  effect: (e, { template: t, context: n }) => {
1621
1598
  let r = {};
1622
1599
  for (let t of e) r[t.fieldKey] = t.value;
1623
- return Nt(t, {
1600
+ return kt(t, {
1624
1601
  ...n,
1625
1602
  responses: r
1626
1603
  });
1627
1604
  }
1628
1605
  });
1629
1606
  constructor(e) {
1630
- this.events = We(this.eventBus), this.projectId = Ot(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || vt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
1607
+ this.events = Ue(this.eventBus), this.projectId = wt(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || mt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
1631
1608
  type: "load",
1632
1609
  version: te()
1633
1610
  });
1634
1611
  }
1635
1612
  registerFramework = (e) => {
1636
- be(e, this.frameworks);
1613
+ ye(e, this.frameworks);
1637
1614
  };
1638
1615
  registerComponent = (e, t) => {
1639
- ge(e, t, this.components);
1616
+ he(e, t, this.components);
1640
1617
  };
1641
1618
  registerPlugin = (e) => {
1642
- ue(this, e, this.plugins);
1619
+ le(this, e, this.plugins);
1643
1620
  let t = this.plugins[e.name];
1644
1621
  t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
1645
1622
  };
1646
1623
  registerFeature = (e, t) => {
1647
- Be(e, t, this.features);
1624
+ Re(e, t, this.features);
1648
1625
  };
1649
1626
  registerPredicate = (e, t) => {
1650
- Ie(e, t, this.predicates);
1627
+ Fe(e, t, this.predicates);
1651
1628
  };
1652
1629
  registerCondition = (e) => {
1653
1630
  this.conditions.register(e);
@@ -1656,16 +1633,13 @@ var Pt = class {
1656
1633
  this.fields.register(e);
1657
1634
  };
1658
1635
  registerStep = (e) => {
1659
- Ze(e, this.steps);
1660
- };
1661
- registerContent = (e) => {
1662
- tt(e, this.contents);
1636
+ Xe(e, this.steps);
1663
1637
  };
1664
1638
  registerAction = (e, t) => {
1665
- at(e, t, this.actions);
1639
+ et(e, t, this.actions);
1666
1640
  };
1667
1641
  registerExperience = (e) => {
1668
- e.component && ge(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1642
+ e.component && he(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1669
1643
  };
1670
1644
  launchExperienceById = async (e, t) => {
1671
1645
  this.experiences.launch({
@@ -1750,20 +1724,20 @@ var Pt = class {
1750
1724
  };
1751
1725
  //#endregion
1752
1726
  //#region src/entities/component/lazyComponent.ts
1753
- function Ft(e) {
1727
+ function jt(e) {
1754
1728
  return {
1755
1729
  $$type: "lazy-component",
1756
1730
  load: e
1757
1731
  };
1758
1732
  }
1759
- function It(e) {
1733
+ function Mt(e) {
1760
1734
  return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
1761
1735
  }
1762
1736
  //#endregion
1763
1737
  //#region src/exports.ts
1764
- var Lt = (e) => {
1765
- let t = new Pt(e);
1738
+ var Nt = (e) => {
1739
+ let t = new At(e);
1766
1740
  return d(t), t;
1767
1741
  };
1768
1742
  //#endregion
1769
- export { Pt as Picked, Lt as createClient, le as createPluginEffect, E as createStorageKey, n as evaluateRuleLogic, Tt as getPickedConfig, It as isLazyLoader, _ as isPickedRoot, Ft as lazyComponent, w as localStore, T as sessionStore, C as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };
1743
+ export { At as Picked, Nt as createClient, ce as createPluginEffect, E as createStorageKey, n as evaluateRuleLogic, xt as getPickedConfig, Mt as isLazyLoader, _ as isPickedRoot, jt as lazyComponent, w as localStore, T as sessionStore, C as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };