@picked/client 0.0.1-dev.1777856271317 → 0.0.1-dev.1777869768355

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 (62) hide show
  1. package/dist/{api-dOWgI8zV.cjs → api-DT7ImnBi.cjs} +1 -1
  2. package/dist/{api-DaHz97Mz.js → api-Dx9PpWfN.js} +1 -1
  3. package/dist/cjs/form/index.js +1 -1
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/create-experience/index.js +1 -1
  6. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  7. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  9. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  10. package/dist/cjs/server/index.js +1 -1
  11. package/dist/docs/api/authentication.md +376 -0
  12. package/dist/docs/api/authorization-and-scopes.md +262 -0
  13. package/dist/docs/api/error-handling.md +211 -0
  14. package/dist/docs/api/index.md +172 -11
  15. package/dist/docs/api/pagination.md +176 -0
  16. package/dist/docs/image-optimisation-service.md +72 -0
  17. package/dist/docs/pickedql/data-sources.md +2 -2
  18. package/dist/docs/pickedql/schema.md +2 -2
  19. package/dist/docs/sdk/plugins/dynamic-experiences.md +2 -2
  20. package/dist/docs/workspaces.mdx +60 -1
  21. package/dist/esm/form/index.js +40 -33
  22. package/dist/esm/index.js +373 -219
  23. package/dist/esm/plugins/create-experience/index.js +1 -1
  24. package/dist/esm/plugins/dynamic-experiences/index.js +1 -1
  25. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  26. package/dist/esm/plugins/history-browser-storage/index.js +4 -4
  27. package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
  28. package/dist/esm/server/index.js +1 -1
  29. package/dist/experience-instance-BDTNGT8a.cjs +1 -0
  30. package/dist/experience-instance-CWYRLfFM.js +493 -0
  31. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  32. package/dist/types/entities/history/history.d.ts +19 -4
  33. package/dist/types/entities/history/history.d.ts.map +1 -1
  34. package/dist/types/form/create-form.d.ts +55 -0
  35. package/dist/types/form/create-form.d.ts.map +1 -1
  36. package/dist/types/picked.d.ts +8 -4
  37. package/dist/types/picked.d.ts.map +1 -1
  38. package/dist/types/plugins/history-browser-storage/plugin.d.ts +14 -0
  39. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  40. package/package.json +1 -11
  41. package/dist/cjs/plugins/dom-observer/index.js +0 -1
  42. package/dist/docs/reference/index.md +0 -11
  43. package/dist/docs/tooling/index.md +0 -19
  44. package/dist/esm/plugins/dom-observer/index.js +0 -107
  45. package/dist/experience-BhteyYBl.cjs +0 -1
  46. package/dist/experience-CoMdlvyn.js +0 -136
  47. package/dist/experience-instance-CZDcicPj.cjs +0 -1
  48. package/dist/experience-instance-IkIw31Cg.js +0 -387
  49. package/dist/nodes-ChVU1VZO.js +0 -101
  50. package/dist/nodes-DDDs-rC2.cjs +0 -1
  51. package/dist/types/plugins/dom-observer/index.d.ts +0 -3
  52. package/dist/types/plugins/dom-observer/index.d.ts.map +0 -1
  53. package/dist/types/plugins/dom-observer/plugin.d.ts +0 -51
  54. package/dist/types/plugins/dom-observer/plugin.d.ts.map +0 -1
  55. /package/dist/docs/{tooling/chrome-extension.md → chrome-extension.md} +0 -0
  56. /package/dist/docs/{tooling/gtm-template.md → gtm-template.md} +0 -0
  57. /package/dist/docs/{tooling/mcp.md → mcp.md} +0 -0
  58. /package/dist/docs/{tooling/vite-plugin.md → vite-plugin.md} +0 -0
  59. /package/dist/{id-Bbodazn8.cjs → id-Bv44ilEo.cjs} +0 -0
  60. /package/dist/{id-B-N2zNbS.js → id-CRqy981z.js} +0 -0
  61. /package/dist/{storage-hOHCCXvP.js → storage-6Xk0uAxB.js} +0 -0
  62. /package/dist/{storage-BXSlLTRa.cjs → storage-B6lQtc4-.cjs} +0 -0
package/dist/esm/index.js CHANGED
@@ -1,17 +1,142 @@
1
- import { t as e } from "../rules-logic-BTIxfrJJ.js";
2
- import { t } from "../object-C82v79xc.js";
3
- import { t as n } from "../logger-6z_gb4rA.js";
4
- import { a as r, c as i, d as a, i as o, l as s, n as c, o as l, p as u, r as d, s as f, t as p, u as m } from "../supports-0XIfd4-R.js";
5
- import { a as h, c as g, u as _ } from "../nodes-ChVU1VZO.js";
6
- import { n as v, t as ee } from "../experience-CoMdlvyn.js";
7
- import { i as te, n as y, r as b, t as x } from "../storage-hOHCCXvP.js";
8
- import { n as ne, r as re } from "../api-DaHz97Mz.js";
9
- import { n as ie } from "../experience-instance-IkIw31Cg.js";
10
- import { t as S } from "../id-B-N2zNbS.js";
11
- import { attach as C, combine as w, createApi as T, createDomain as E, createEffect as D, createEvent as O, createStore as k, sample as A } from "effector";
12
- import { createFactory as j, invoke as M } from "@withease/factories";
13
- //#region src/entities/plugin/plugin.ts
14
- var ae = (e, t, n) => {
1
+ import { n as e, t } from "../rules-logic-BTIxfrJJ.js";
2
+ import { t as n } from "../object-C82v79xc.js";
3
+ import { t as r } from "../logger-6z_gb4rA.js";
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 ee, n as te, o as ne, r as re, s as y } from "../experience-instance-CWYRLfFM.js";
6
+ import { i as ie, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
7
+ import { n as ae, r as oe } from "../api-Dx9PpWfN.js";
8
+ import { t as C } from "../id-CRqy981z.js";
9
+ import { attach as w, combine as T, createApi as E, createDomain as D, createEffect as O, createEvent as k, createStore as A, sample as j } from "effector";
10
+ import { createFactory as M, invoke as N } from "@withease/factories";
11
+ //#region src/entities/experience/experience.ts
12
+ var P = D("experience"), se = M(({ client: e, experience: t }) => {
13
+ let n = P.store(t), r = E(n, { merge(e, t) {
14
+ return {
15
+ ...e,
16
+ ...t.experience
17
+ };
18
+ } }), i = n.map((e) => ({
19
+ name: e.name,
20
+ decisionLogic: e.condition,
21
+ targetSelectors: e.targets,
22
+ initializeOpenLogic: e.initializeOpen
23
+ })), a = T(n, 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 }), o = T(n, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
24
+ let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(re).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
25
+ return {
26
+ steps: r,
27
+ nodes: e.nodes,
28
+ edges: e.edges,
29
+ conditions: i
30
+ };
31
+ }), s = t.actions ?? [];
32
+ return {
33
+ id: t.id,
34
+ key: t.key,
35
+ name: t.name,
36
+ configStore: i,
37
+ treeStore: o,
38
+ componentStore: a,
39
+ actions: s,
40
+ merge: r.merge
41
+ };
42
+ });
43
+ function ce(e) {
44
+ return N(se, e);
45
+ }
46
+ var le = M(({ client: e }) => {
47
+ let t = P.store({}), n = E(t, { register(e, t) {
48
+ return {
49
+ ...e,
50
+ [t.id]: t
51
+ };
52
+ } });
53
+ function r(r) {
54
+ let i = t.getState()[r.id];
55
+ if (i) {
56
+ i.merge({
57
+ experience: r,
58
+ strategy: "override"
59
+ });
60
+ return;
61
+ }
62
+ let a = ce({
63
+ client: e,
64
+ experience: r
65
+ });
66
+ n.register(a);
67
+ }
68
+ let i = t.map((e) => Object.values(e));
69
+ function a(e) {
70
+ return t.map((t) => t[e], { skipVoid: !1 });
71
+ }
72
+ function o(e) {
73
+ return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
74
+ }
75
+ let s = w({
76
+ source: t,
77
+ effect: async (t, n) => {
78
+ let r = "key" in n ? Object.values(t).find((e) => e.key === n.key) : t[n.id];
79
+ if (!r) {
80
+ "key" in n ? `${n.key}` : `${n.id}`;
81
+ return;
82
+ }
83
+ let { options: i } = n;
84
+ if (i?.bypassCondition) {
85
+ F(e, r, i);
86
+ return;
87
+ }
88
+ await L(e, r) && F(e, r, i);
89
+ }
90
+ });
91
+ return {
92
+ register: r,
93
+ get: a,
94
+ getById: a,
95
+ getByKey: o,
96
+ launch: s,
97
+ open: w({
98
+ source: {
99
+ experiences: t,
100
+ instances: e.experienceInstances.listStore
101
+ },
102
+ effect: ({ experiences: e, instances: t }, n) => {
103
+ let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => r && e.experienceId === r.id);
104
+ if (i.length > 0) for (let e of i) e.open();
105
+ else s("key" in n ? {
106
+ key: n.key,
107
+ options: {
108
+ ...n.options,
109
+ initialiseOpen: !0
110
+ }
111
+ } : {
112
+ id: n.id,
113
+ options: {
114
+ ...n.options,
115
+ initialiseOpen: !0
116
+ }
117
+ });
118
+ }
119
+ }),
120
+ listStore: i
121
+ };
122
+ });
123
+ function ue(e) {
124
+ return N(le, e);
125
+ }
126
+ var F = (e, t, n) => {
127
+ let { targetSelectors: r } = t.configStore.getState(), i = y(r, t.id);
128
+ i.forEach(({ elements: e }) => e.forEach((e) => ee(e, t.id))), g(i, t.id, t.key).forEach((r) => {
129
+ n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
130
+ });
131
+ }, I = async (e) => {
132
+ await Promise.all(e.experiences.listStore.getState().map(async (t) => {
133
+ await L(e, t) && F(e, t);
134
+ }));
135
+ }, L = async (n, r) => {
136
+ if (!n.preconditionPassed || !n.session?.isUser) return !1;
137
+ let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
138
+ return y(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
139
+ }, de = (e, t, n) => {
15
140
  let r = t.name, i = t.setup(e);
16
141
  if (i) {
17
142
  let e = n[r] ?? {};
@@ -20,16 +145,16 @@ var ae = (e, t, n) => {
20
145
  ...i
21
146
  });
22
147
  }
23
- }, oe = E("component"), se = j(({ client: e, component: t, name: n }) => ({
148
+ }, fe = D("component"), R = M(({ client: e, component: t, name: n }) => ({
24
149
  name: n,
25
150
  component: t,
26
151
  frameworkStore: e.frameworks.getByName(t.frameworkName)
27
152
  }));
28
- function ce(e) {
29
- return M(se, e);
153
+ function z(e) {
154
+ return N(R, e);
30
155
  }
31
- var le = j(({ client: e }) => {
32
- let t = oe.store({}), n = T(t, { register(e, t) {
156
+ var B = M(({ client: e }) => {
157
+ let t = fe.store({}), n = E(t, { register(e, t) {
33
158
  return {
34
159
  ...e,
35
160
  [t.name]: t
@@ -37,7 +162,7 @@ var le = j(({ client: e }) => {
37
162
  } });
38
163
  function r(r, i) {
39
164
  t.getState()[r] && `${r}`;
40
- let a = ce({
165
+ let a = z({
41
166
  client: e,
42
167
  name: r,
43
168
  component: i
@@ -54,13 +179,13 @@ var le = j(({ client: e }) => {
54
179
  listStore: i
55
180
  };
56
181
  });
57
- function ue(e) {
58
- return M(le, e);
182
+ function V(e) {
183
+ return N(B, e);
59
184
  }
60
- var N = (e, t, n) => {
185
+ var H = (e, t, n) => {
61
186
  n.register(e, t);
62
- }, P = E("framework"), F = j(({ client: e }) => {
63
- let t = P.store({}), n = T(t, { register(e, t) {
187
+ }, pe = D("framework"), me = M(({ client: e }) => {
188
+ let t = pe.store({}), n = E(t, { register(e, t) {
64
189
  return {
65
190
  ...e,
66
191
  [t.name]: t.framework
@@ -82,21 +207,21 @@ var N = (e, t, n) => {
82
207
  listStore: i
83
208
  };
84
209
  });
85
- function I(e) {
86
- return M(F, e);
210
+ function he(e) {
211
+ return N(me, e);
87
212
  }
88
- var L = (e, t) => {
213
+ var ge = (e, t) => {
89
214
  t.register(e.name, e);
90
- }, R = 6e3, z = x("last_ping", "global"), B = async (e) => {
215
+ }, _e = 6e3, ve = S("last_ping", "global"), ye = async (e) => {
91
216
  try {
92
- let t = Date.now(), n = y.get(z), r = 0;
93
- if (n.isSet() && (r = n.json() ?? 0), r && t - r < R) return !0;
217
+ let t = Date.now(), n = b.get(ve), r = 0;
218
+ if (n.isSet() && (r = n.json() ?? 0), r && t - r < _e) return !0;
94
219
  let i = {
95
220
  projectId: e.projectId,
96
221
  path: window.location.pathname
97
222
  }, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
98
223
  o && (a["x-vercel-protection-bypass"] = o);
99
- let s = (await ne(e.apiUrl, "ping", i, a)).ok;
224
+ let s = (await ae(e.apiUrl, "ping", i, a)).ok;
100
225
  return s && n.set(t), s;
101
226
  } catch {
102
227
  return !1;
@@ -104,7 +229,7 @@ var L = (e, t) => {
104
229
  };
105
230
  //#endregion
106
231
  //#region src/utils/state-snaphot.ts
107
- function V(e) {
232
+ function U(e) {
108
233
  let t = typeof window < "u", n = {
109
234
  client: e,
110
235
  responses: e.responses.listStore.getState(),
@@ -118,8 +243,8 @@ function V(e) {
118
243
  }
119
244
  //#endregion
120
245
  //#region src/entities/predicate/predicate.ts
121
- var H = E("predicate"), U = j(({ client: e }) => {
122
- let t = H.store({}), n = T(t, { register(e, t) {
246
+ var be = D("predicate"), xe = M(({ client: e }) => {
247
+ let t = be.store({}), n = E(t, { register(e, t) {
123
248
  return {
124
249
  ...e,
125
250
  [t.name]: {
@@ -139,22 +264,22 @@ var H = E("predicate"), U = j(({ client: e }) => {
139
264
  return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
140
265
  }
141
266
  function o(t) {
142
- let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
267
+ let n = A(() => void 0, { skipVoid: !1 }), r = O(async () => {
143
268
  let n = a(t).getState();
144
269
  if (!n) return;
145
- let r = V(e);
270
+ let r = U(e);
146
271
  return (...e) => n({
147
272
  ...r,
148
273
  args: e
149
274
  });
150
275
  });
151
- return A({
276
+ return j({
152
277
  source: {
153
278
  responses: e.responses.listStore,
154
279
  fields: e.fields.listStore
155
280
  },
156
281
  target: r
157
- }), A({
282
+ }), j({
158
283
  clock: r.doneData,
159
284
  filter: (e) => e !== void 0,
160
285
  target: n
@@ -167,13 +292,13 @@ var H = E("predicate"), U = j(({ client: e }) => {
167
292
  getEvokablePredicate: o
168
293
  };
169
294
  });
170
- function de(e) {
171
- return M(U, e);
295
+ function Se(e) {
296
+ return N(xe, e);
172
297
  }
173
- var fe = (e, t, n) => {
298
+ var Ce = (e, t, n) => {
174
299
  n.register(e, t);
175
- }, W = E("feature"), pe = j(({ client: e }) => {
176
- let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
300
+ }, W = D("feature"), we = M(({ client: e }) => {
301
+ let t = W.store({}), n = W.store([]), r = E(t, { register(e, t) {
177
302
  return {
178
303
  ...e,
179
304
  [t.id]: t.feature
@@ -193,19 +318,19 @@ var fe = (e, t, n) => {
193
318
  feature: i
194
319
  }));
195
320
  }
196
- let a = D(async ({ id: e, key: t, storage: n = "local" }) => {
197
- let r = x(`feature:${e}:${t}`, "global"), i = (n === "session" ? b : y).get(r).boolean();
321
+ let a = O(async ({ id: e, key: t, storage: n = "local" }) => {
322
+ let r = S(`feature:${e}:${t}`, "global"), i = (n === "session" ? x : b).get(r).boolean();
198
323
  return i === null ? null : {
199
324
  id: e,
200
325
  key: t,
201
326
  bucket: i,
202
327
  storage: n
203
328
  };
204
- }), o = D((e) => {
329
+ }), o = O((e) => {
205
330
  if (!e) return null;
206
- let t = x(`feature:${e.id}:${e.key}`, "global");
207
- (e.storage === "session" ? b : y).set(t, e.bucket);
208
- }), s = /* @__PURE__ */ new Map(), c = C({
331
+ let t = S(`feature:${e.id}:${e.key}`, "global");
332
+ (e.storage === "session" ? x : b).set(t, e.bucket);
333
+ }), s = /* @__PURE__ */ new Map(), c = w({
209
334
  source: {
210
335
  allFeaturesStore: t,
211
336
  resolvedFeaturesStore: n
@@ -236,7 +361,7 @@ var fe = (e, t, n) => {
236
361
  };
237
362
  }
238
363
  });
239
- A({
364
+ j({
240
365
  clock: r.register,
241
366
  fn: (e) => {
242
367
  let { id: t, feature: n } = e;
@@ -247,7 +372,7 @@ var fe = (e, t, n) => {
247
372
  };
248
373
  },
249
374
  target: a
250
- }), A({
375
+ }), j({
251
376
  source: t,
252
377
  clock: c.doneData,
253
378
  fn: (e, t) => {
@@ -261,7 +386,7 @@ var fe = (e, t, n) => {
261
386
  },
262
387
  target: o
263
388
  });
264
- let l = w({
389
+ let l = T({
265
390
  allFeaturesStore: t,
266
391
  resolvedFeaturesStore: n
267
392
  }).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
@@ -283,7 +408,7 @@ var fe = (e, t, n) => {
283
408
  isResolved: !1
284
409
  };
285
410
  }));
286
- A({
411
+ j({
287
412
  clock: c.doneData,
288
413
  source: { resolvedFeatures: n },
289
414
  filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
@@ -292,7 +417,7 @@ var fe = (e, t, n) => {
292
417
  type: "feature_decide",
293
418
  feature: e
294
419
  }))
295
- }), A({
420
+ }), j({
296
421
  clock: [a.doneData, c.doneData],
297
422
  source: n,
298
423
  fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
@@ -305,15 +430,15 @@ var fe = (e, t, n) => {
305
430
  return t.map((t) => t[e], { skipVoid: !1 });
306
431
  }
307
432
  function f(e) {
308
- let t = k(async () => void 0, { skipVoid: !1 }), r = D(async () => {
433
+ let t = A(async () => void 0, { skipVoid: !1 }), r = O(async () => {
309
434
  let t = u(e).getState();
310
435
  if (t) return async () => (await t.getBucket()).bucket;
311
436
  });
312
- return A({
437
+ return j({
313
438
  source: n,
314
439
  filter: (t) => t.some((t) => t.id === e),
315
440
  target: r
316
- }), A({
441
+ }), j({
317
442
  clock: r.doneData,
318
443
  filter: (e) => e !== void 0,
319
444
  target: t
@@ -327,72 +452,101 @@ var fe = (e, t, n) => {
327
452
  getEvokableFeature: f
328
453
  };
329
454
  });
330
- function me(e) {
331
- return M(pe, e);
455
+ function Te(e) {
456
+ return N(we, e);
332
457
  }
333
- var he = (e, t, n) => {
458
+ var Ee = (e, t, n) => {
334
459
  n.register(e, t);
335
- }, G = E("history");
336
- function K(e, t) {
460
+ }, G = D("history");
461
+ function K(e, t, n) {
337
462
  return {
338
- id: S(`history-entry-${Date.now()}-${Math.random()}}`),
339
- node: t,
463
+ id: C(`history-entry-${Date.now()}-${Math.random()}}`),
464
+ node: n,
340
465
  at: Date.now(),
341
- experienceId: e
466
+ instanceId: e,
467
+ experienceId: t
342
468
  };
343
469
  }
344
- var ge = j(() => {
345
- let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event(), a = G.event();
346
- e.on(t, (e, t) => ({ entries: [...e.entries, K(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), K(t.experienceId, t.node)] })), e.on(i, (e, t) => t), e.on(a, (e, t) => e.entries.every((e) => e.experienceId !== t.experienceId) ? e : { entries: e.entries.filter((e) => e.experienceId !== t.experienceId) });
347
- function o(e, t) {
348
- let n = {
349
- lastStepIndex: -1,
350
- secondLastStepIndex: -1
351
- };
352
- for (let r = e.length - 1; r >= 0; r--) {
353
- let i = e[r], a = i?.node;
354
- if (!(!a || !h(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
470
+ function De(e) {
471
+ for (let t = e.length - 1; t >= 0; t--) {
472
+ let n = e[t];
473
+ if (n && v(n.node)) return e.slice(0, t + 1);
474
+ }
475
+ return [];
476
+ }
477
+ var Oe = M(() => {
478
+ let e = G.store([]), t = G.event(), n = G.event(), r = G.event(), i = G.event(), a = G.event(), o = G.event();
479
+ e.on(t, (e, t) => [...e, K(t.instanceId, t.experienceId, t.node)]), e.on(n, (e, t) => {
480
+ let n = -1;
481
+ for (let r = e.length - 1; r >= 0; r--) if (e[r]?.instanceId === t.instanceId) {
482
+ n = r;
483
+ break;
484
+ }
485
+ let r = K(t.instanceId, t.experienceId, t.node);
486
+ return n === -1 ? [...e, r] : e.map((e, t) => t === n ? r : e);
487
+ }), e.on(r, (e, { instanceId: t }) => {
488
+ let n = -1, r = -1;
489
+ for (let i = e.length - 1; i >= 0; i--) {
490
+ let a = e[i];
491
+ if (!(!a || a.instanceId !== t || !v(a.node))) if (n === -1) n = i;
355
492
  else {
356
- n.secondLastStepIndex = r;
493
+ r = i;
357
494
  break;
358
495
  }
359
496
  }
497
+ return r === -1 ? e : e.filter((e, n) => e.instanceId !== t || n <= r);
498
+ }), e.on(i, (e, { snapshots: t }) => {
499
+ let n = [];
500
+ for (let e of Object.values(t)) n.push(...e);
360
501
  return n;
361
- }
362
- return e.on(r, (e, t) => {
363
- let { secondLastStepIndex: n } = o(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
364
- return {
502
+ }), e.on(o, (e, t) => [...e, ...t]);
503
+ let s = e.map((e) => {
504
+ let t = {};
505
+ for (let n of e) {
506
+ let e = t[n.experienceId];
507
+ e ? e.push(n) : t[n.experienceId] = [n];
508
+ }
509
+ return t;
510
+ });
511
+ return j({
512
+ clock: a,
513
+ source: s,
514
+ fn: (e, { instanceId: t, experienceId: n }) => De(e[n] ?? []).map((e) => ({
365
515
  ...e,
366
- entries: r
367
- };
516
+ id: C(`history-entry-${Date.now()}-${Math.random()}}`),
517
+ instanceId: t,
518
+ at: Date.now()
519
+ })),
520
+ target: o
368
521
  }), {
369
522
  push: t,
370
523
  replace: n,
371
524
  back: r,
372
- restore: i,
373
- clearForExperience: a,
374
- entriesStore: e.map((e) => e.entries)
525
+ restoreSnapshots: i,
526
+ seedInstanceFromSnapshot: a,
527
+ entriesStore: e.map((e) => e),
528
+ snapshotStore: s
375
529
  };
376
530
  });
377
- function _e() {
378
- return M(ge);
531
+ function ke() {
532
+ return N(Oe);
379
533
  }
380
534
  //#endregion
381
535
  //#region src/utils/events.ts
382
- var ve = 0, ye = (e) => {
383
- let t = k([]);
384
- return A({
536
+ var Ae = 0, je = (e) => {
537
+ let t = A([]);
538
+ return j({
385
539
  clock: e,
386
540
  source: t,
387
541
  fn: (e, t) => [...e, {
388
- id: ve++,
542
+ id: Ae++,
389
543
  at: /* @__PURE__ */ new Date(),
390
544
  payload: t
391
545
  }],
392
546
  target: t
393
547
  }), t;
394
- }, be = E("field"), xe = j(() => {
395
- let e = be.store({}), t = T(e, {
548
+ }, Me = D("field"), Ne = M(() => {
549
+ let e = Me.store({}), t = E(e, {
396
550
  register(e, t) {
397
551
  return {
398
552
  ...e,
@@ -436,13 +590,13 @@ var ve = 0, ye = (e) => {
436
590
  getByName: s
437
591
  };
438
592
  });
439
- function Se() {
440
- return M(xe);
593
+ function Pe() {
594
+ return N(Ne);
441
595
  }
442
596
  //#endregion
443
597
  //#region src/entities/step/step.ts
444
- var Ce = E("step"), we = j(() => {
445
- let e = Ce.store({}), t = T(e, { register(e, t) {
598
+ var Fe = D("step"), Ie = M(() => {
599
+ let e = Fe.store({}), t = E(e, { register(e, t) {
446
600
  return {
447
601
  ...e,
448
602
  [t.step.id]: t.step
@@ -466,16 +620,16 @@ var Ce = E("step"), we = j(() => {
466
620
  indexStore: e
467
621
  };
468
622
  });
469
- function Te() {
470
- return M(we);
623
+ function Le() {
624
+ return N(Ie);
471
625
  }
472
- function Ee(e, t) {
626
+ function Re(e, t) {
473
627
  t.register(e);
474
628
  }
475
629
  //#endregion
476
630
  //#region src/entities/action/action.ts
477
- var De = E("action"), Oe = j(({ client: e }) => {
478
- let t = De.store({}), n = T(t, { register(e, t) {
631
+ var ze = D("action"), Be = M(({ client: e }) => {
632
+ let t = ze.store({}), n = E(t, { register(e, t) {
479
633
  return {
480
634
  ...e,
481
635
  [t.key]: {
@@ -495,22 +649,22 @@ var De = E("action"), Oe = j(({ client: e }) => {
495
649
  return t.map((t) => t[e]?.action, { skipVoid: !1 });
496
650
  }
497
651
  function o(t, n) {
498
- let r = k(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, o = D(async () => {
652
+ let r = A(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, o = O(async () => {
499
653
  let n = a(t).getState();
500
654
  if (!n) return;
501
- let r = V(e);
655
+ let r = U(e);
502
656
  return (...e) => n({
503
657
  ...r,
504
658
  args: e
505
659
  }, i);
506
660
  });
507
- return A({
661
+ return j({
508
662
  source: {
509
663
  responses: e.responses.listStore,
510
664
  fields: e.fields.listStore
511
665
  },
512
666
  target: o
513
- }), A({
667
+ }), j({
514
668
  clock: o.doneData,
515
669
  filter: (e) => e !== void 0,
516
670
  target: r
@@ -523,10 +677,10 @@ var De = E("action"), Oe = j(({ client: e }) => {
523
677
  getEvokableAction: o
524
678
  };
525
679
  });
526
- function ke(e) {
527
- return M(Oe, e);
680
+ function Ve(e) {
681
+ return N(Be, e);
528
682
  }
529
- var Ae = (e, t, n) => {
683
+ var He = (e, t, n) => {
530
684
  n.register(e, t);
531
685
  };
532
686
  //#endregion
@@ -542,7 +696,7 @@ function q(e, t, n, r) {
542
696
  function J(e) {
543
697
  return e === null || e === "" || Array.isArray(e) && !e.length;
544
698
  }
545
- function je(e) {
699
+ function Ue(e) {
546
700
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
547
701
  }
548
702
  function Y(e) {
@@ -552,13 +706,13 @@ function Y(e) {
552
706
  return !1;
553
707
  }
554
708
  }
555
- function Me(e, t) {
709
+ function We(e, t) {
556
710
  return t.find((t) => t.key === e) ?? null;
557
711
  }
558
- function Ne(e, t) {
712
+ function Ge(e, t) {
559
713
  return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
560
714
  }
561
- function Pe(e, t) {
715
+ function Ke(e, t) {
562
716
  if (e.type !== "object" || J(t)) return null;
563
717
  if (e.multiple) {
564
718
  if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
@@ -570,7 +724,7 @@ function Pe(e, t) {
570
724
  }
571
725
  return Array.isArray(t) ? q(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? q(e, t, "This field expects an object value", "Field expects an object value.") : Y(t) ? null : q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
572
726
  }
573
- function Fe(e, t) {
727
+ function qe(e, t) {
574
728
  if (J(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
575
729
  let n = Array.isArray(t) ? t : [t];
576
730
  if (e.type === "object") {
@@ -578,23 +732,23 @@ function Fe(e, t) {
578
732
  return n.every((e) => r.has(JSON.stringify(e))) ? null : q(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
579
733
  }
580
734
  let r = e.options.map((e) => e.value);
581
- return n.every((e) => !je(e) || e === null ? !1 : r.includes(e)) ? null : q(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
735
+ return n.every((e) => !Ue(e) || e === null ? !1 : r.includes(e)) ? null : q(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
582
736
  }
583
- async function Ie(e, n, r, i) {
584
- if (n.validation && !t(n.validation) && !J(r)) {
585
- let t = i ? {
737
+ async function Je(e, t, r, i) {
738
+ if (t.validation && !n(t.validation) && !J(r)) {
739
+ let n = i ? {
586
740
  $input: r,
587
741
  responses: i
588
- } : { $input: r }, a = await e(n.validation, t);
589
- if (typeof a == "string") return q(n, r, a, `Field validation resulted in an error: ${a}.`);
590
- if (a === !1) return q(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
742
+ } : { $input: r }, a = await e(t.validation, n);
743
+ if (typeof a == "string") return q(t, r, a, `Field validation resulted in an error: ${a}.`);
744
+ if (a === !1) return q(t, r, "This field is invalid", "Field validation resulted in an unspecified error.");
591
745
  }
592
- return n.required && J(r) ? q(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? q(n, r, "This field expects a single response", "Field expects a single response.") : null;
746
+ return t.required && J(r) ? q(t, r, "This field is required", "Field is required.") : !t.multiple && Array.isArray(r) && r.length > 1 ? q(t, r, "This field expects a single response", "Field expects a single response.") : null;
593
747
  }
594
748
  //#endregion
595
749
  //#region src/entities/response/response.ts
596
- var Le = E("response"), Re = j(({ client: t }) => {
597
- let n = Le.store({}), r = O(), i = O(), a = T(n, {
750
+ var Ye = D("response"), Xe = M(({ client: e }) => {
751
+ let n = Ye.store({}), r = k(), i = k(), a = E(n, {
598
752
  register(e, t) {
599
753
  return {
600
754
  ...e,
@@ -623,9 +777,9 @@ var Le = E("response"), Re = j(({ client: t }) => {
623
777
  });
624
778
  } else a.registerBatch(e);
625
779
  }
626
- let s = (n, r) => e(t, n, r), c = C({
780
+ let s = (n, r) => t(e, n, r), c = w({
627
781
  source: {
628
- allFields: t.fields.listStore,
782
+ allFields: e.fields.listStore,
629
783
  existingResponses: n
630
784
  },
631
785
  effect: async ({ allFields: e, existingResponses: t }, n) => {
@@ -633,7 +787,7 @@ var Le = E("response"), Re = j(({ client: t }) => {
633
787
  ...t,
634
788
  ...n
635
789
  }, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
636
- let o = Me(t, e);
790
+ let o = We(t, e);
637
791
  if (!o) {
638
792
  r.push({
639
793
  fieldKey: t,
@@ -643,17 +797,17 @@ var Le = E("response"), Re = j(({ client: t }) => {
643
797
  });
644
798
  return;
645
799
  }
646
- let c = Ne(o, n), l = await Ie(s, o, c, a);
800
+ let c = Ge(o, n), l = await Je(s, o, c, a);
647
801
  if (l) {
648
802
  r.push(l);
649
803
  return;
650
804
  }
651
- let u = Pe(o, c);
805
+ let u = Ke(o, c);
652
806
  if (u) {
653
807
  r.push(u);
654
808
  return;
655
809
  }
656
- let d = Fe(o, c);
810
+ let d = qe(o, c);
657
811
  if (d) {
658
812
  r.push(d);
659
813
  return;
@@ -681,7 +835,7 @@ var Le = E("response"), Re = j(({ client: t }) => {
681
835
  async function l(e) {
682
836
  return c(e);
683
837
  }
684
- let u = C({
838
+ let u = w({
685
839
  source: n,
686
840
  effect: async (e, t) => {
687
841
  let { responsesToCommit: n, validationErrors: r } = await c(t);
@@ -696,7 +850,7 @@ var Le = E("response"), Re = j(({ client: t }) => {
696
850
  value: t
697
851
  })));
698
852
  function m(e) {
699
- return w({
853
+ return T({
700
854
  f: e,
701
855
  s: n
702
856
  }, ({ f: e, s: t }) => {
@@ -704,19 +858,19 @@ var Le = E("response"), Re = j(({ client: t }) => {
704
858
  return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
705
859
  });
706
860
  }
707
- function h(e) {
708
- return m(t.fields.getById(e));
861
+ function h(t) {
862
+ return m(e.fields.getById(t));
709
863
  }
710
- function g(e) {
711
- return m(t.fields.getByKey(e));
864
+ function g(t) {
865
+ return m(e.fields.getByKey(t));
712
866
  }
713
- function _(e) {
714
- return m(t.fields.getByName(e));
867
+ function _(t) {
868
+ return m(e.fields.getByName(t));
715
869
  }
716
- return A({
870
+ return j({
717
871
  clock: r,
718
872
  target: a.clearAll
719
- }), A({
873
+ }), j({
720
874
  clock: i,
721
875
  target: a.clear
722
876
  }), {
@@ -732,13 +886,13 @@ var Le = E("response"), Re = j(({ client: t }) => {
732
886
  getByFieldName: _
733
887
  };
734
888
  });
735
- function ze(e) {
736
- return M(Re, e);
889
+ function Ze(e) {
890
+ return N(Xe, e);
737
891
  }
738
892
  //#endregion
739
893
  //#region src/entities/condition/condition.ts
740
- var Be = E("condition"), Ve = j(() => {
741
- let e = Be.store({}), t = T(e, { register(e, t) {
894
+ var Qe = D("condition"), $e = M(() => {
895
+ let e = Qe.store({}), t = E(e, { register(e, t) {
742
896
  return {
743
897
  ...e,
744
898
  [t.condition.id]: t.condition
@@ -762,13 +916,13 @@ var Be = E("condition"), Ve = j(() => {
762
916
  indexStore: e
763
917
  };
764
918
  });
765
- function He() {
766
- return M(Ve);
919
+ function et() {
920
+ return N($e);
767
921
  }
768
922
  //#endregion
769
923
  //#region src/utils/api-url.ts
770
- function Ue() {
771
- if (d()) {
924
+ function tt() {
925
+ if (f()) {
772
926
  let e = [
773
927
  document.currentScript,
774
928
  document.getElementById("picked_script"),
@@ -782,36 +936,36 @@ function Ue() {
782
936
  }
783
937
  //#endregion
784
938
  //#region src/utils/search-params.ts
785
- function We() {
786
- if (!a()) return {};
939
+ function nt() {
940
+ if (!o()) return {};
787
941
  let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
788
942
  for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
789
943
  for (let r of n) {
790
944
  let n = r.replace("picked-", "");
791
945
  t[n] = e.getAll(r);
792
946
  }
793
- let r = x("s");
794
- if (n.size > 0) b.set(r, t);
947
+ let r = S("s");
948
+ if (n.size > 0) x.set(r, t);
795
949
  else {
796
- let e = b.get(r);
950
+ let e = x.get(r);
797
951
  if (e) return e.json() || {};
798
952
  }
799
953
  return t;
800
954
  }
801
955
  //#endregion
802
956
  //#region src/utils/user-session.ts
803
- function Ge() {
804
- return c() ? 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)}`;
957
+ function rt() {
958
+ 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)}`;
805
959
  }
806
- var Ke = x("session", "global"), qe = () => {
807
- let e = y.get(Ke), t;
960
+ var it = S("session", "global"), X = () => {
961
+ let e = b.get(it), t;
808
962
  e.isSet() && (t = e.json());
809
963
  let n = (t) => e.set({
810
964
  id: t.id,
811
965
  isUser: t.isUser,
812
966
  identifiers: t.identifiers
813
967
  }), r = {
814
- id: t?.id ?? Ge(),
968
+ id: t?.id ?? rt(),
815
969
  isUser: t?.isUser ?? void 0,
816
970
  identifiers: t?.identifiers ?? void 0,
817
971
  setIsUser(e) {
@@ -828,22 +982,22 @@ var Ke = x("session", "global"), qe = () => {
828
982
  }
829
983
  };
830
984
  return n(r), r;
831
- }, Je = () => l() ? qe() : null;
985
+ }, at = () => u() ? X() : null;
832
986
  //#endregion
833
987
  //#region src/utils/picked-config.ts
834
- function X() {
835
- if (a()) return globalThis.window.pickedConfig;
988
+ function Z() {
989
+ if (o()) return globalThis.window.pickedConfig;
836
990
  }
837
- function Ye() {
838
- if (!a()) return;
839
- let e = X(), t = e?.organizationId, n = e?.projectId;
991
+ function ot() {
992
+ if (!o()) return;
993
+ let e = Z(), t = e?.organizationId, n = e?.projectId;
840
994
  return t && n ? {
841
995
  organizationId: t,
842
996
  projectId: n
843
997
  } : void 0;
844
998
  }
845
- function Xe() {
846
- if (!d()) return;
999
+ function st() {
1000
+ if (!f()) return;
847
1001
  let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
848
1002
  if (!e) return;
849
1003
  let t = e.dataset.organizationid || e.getAttribute("organization-id"), n = e.dataset.projectid || e.getAttribute("project-id");
@@ -852,15 +1006,15 @@ function Xe() {
852
1006
  projectId: n
853
1007
  } : void 0;
854
1008
  }
855
- function Z(e) {
1009
+ function ct(e) {
856
1010
  let { organizationId: t, projectId: n } = e;
857
1011
  if (t && n) return {
858
1012
  organizationId: t,
859
1013
  projectId: n
860
1014
  };
861
- let r = Ye();
1015
+ let r = ot();
862
1016
  if (r) return r;
863
- let i = Xe();
1017
+ let i = st();
864
1018
  if (i) return i;
865
1019
  throw Error("organizationId and projectId are required. You can provide them via one of:\n (1) createClient({ organizationId, projectId }) options;\n (2) window.pickedConfig = { organizationId, projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.");
866
1020
  }
@@ -869,7 +1023,7 @@ function Z(e) {
869
1023
  function Q(e) {
870
1024
  return e == null || e === "" || Number.isNaN(e);
871
1025
  }
872
- var Ze = {
1026
+ var lt = {
873
1027
  default: (e, t) => Q(e) ? String(t ?? "") : String(e),
874
1028
  append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
875
1029
  prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
@@ -890,24 +1044,24 @@ var Ze = {
890
1044
  return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
891
1045
  }
892
1046
  };
893
- function Qe(e) {
1047
+ function ut(e) {
894
1048
  return typeof e == "object" && !!e;
895
1049
  }
896
- function $e(e, t) {
1050
+ function dt(e, t) {
897
1051
  let n = t;
898
- for (let t of e.split(".")) if (Qe(n) && t in n) n = n[t];
1052
+ for (let t of e.split(".")) if (ut(n) && t in n) n = n[t];
899
1053
  else return;
900
1054
  return typeof n == "function" ? n() : n;
901
1055
  }
902
- function et(e, t) {
903
- let n = e.split("|").map((e) => e.trim()), r = $e(n.shift() ?? "", t);
1056
+ function ft(e, t) {
1057
+ let n = e.split("|").map((e) => e.trim()), r = dt(n.shift() ?? "", t);
904
1058
  for (let e of n) {
905
- let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Ze[i];
1059
+ let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = lt[i];
906
1060
  o && (r = o(r, a));
907
1061
  }
908
1062
  return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
909
1063
  }
910
- function tt(e, t) {
1064
+ function pt(e, t) {
911
1065
  let n = "", r = 0;
912
1066
  for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
913
1067
  r += 2;
@@ -919,19 +1073,19 @@ function tt(e, t) {
919
1073
  }
920
1074
  i += e[r++];
921
1075
  }
922
- n += et(i.trim(), t);
1076
+ n += ft(i.trim(), t);
923
1077
  } else n += e[r++];
924
1078
  return n;
925
1079
  }
926
1080
  //#endregion
927
1081
  //#region src/picked.ts
928
1082
  var $ = class {
929
- static logger = n;
1083
+ static logger = r;
930
1084
  options;
931
1085
  isReady = !1;
932
1086
  plugins = {};
933
1087
  pluginStartHooks = [];
934
- eventBus = O();
1088
+ eventBus = k();
935
1089
  events;
936
1090
  organizationId;
937
1091
  projectId;
@@ -942,30 +1096,30 @@ var $ = class {
942
1096
  precondition;
943
1097
  condition;
944
1098
  preconditionPassed;
945
- searchParams = We();
946
- history = _e();
947
- components = ue({ client: this });
948
- experienceInstances = ie({ client: this });
949
- experiences = ee({ client: this });
950
- frameworks = I({ client: this });
951
- predicates = de({ client: this });
952
- features = me({ client: this });
953
- conditions = He();
954
- fields = Se();
955
- responses = ze({ client: this });
956
- steps = Te();
957
- actions = ke({ client: this });
1099
+ searchParams = nt();
1100
+ history = ke();
1101
+ components = V({ client: this });
1102
+ experienceInstances = te({ client: this });
1103
+ experiences = ue({ client: this });
1104
+ frameworks = he({ client: this });
1105
+ predicates = Se({ client: this });
1106
+ features = Te({ client: this });
1107
+ conditions = et();
1108
+ fields = Pe();
1109
+ responses = Ze({ client: this });
1110
+ steps = Le();
1111
+ actions = Ve({ client: this });
958
1112
  constructor(e) {
959
- this.events = ye(this.eventBus);
960
- let { organizationId: t, projectId: n } = Z(e);
961
- this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Ue(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = Je(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
1113
+ this.events = je(this.eventBus);
1114
+ let { organizationId: t, projectId: n } = ct(e);
1115
+ this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = at(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
962
1116
  type: "load",
963
- version: re()
1117
+ version: oe()
964
1118
  });
965
1119
  }
966
1120
  start = () => {
967
- B(this), (async () => {
968
- if (!d()) return;
1121
+ ye(this), (async () => {
1122
+ if (!f()) return;
969
1123
  await this.runPluginStartHooks();
970
1124
  let e = await this.evaluateGate(this.precondition);
971
1125
  this.preconditionPassed = e;
@@ -979,7 +1133,7 @@ var $ = class {
979
1133
  value: e
980
1134
  });
981
1135
  }
982
- if (this.eventBus({ type: "initialize" }), n && v(this), await g(), n && v(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1136
+ if (this.eventBus({ type: "initialize" }), n && I(this), await ne(), n && I(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
983
1137
  let { id: e, isUser: t, identifiers: n } = this.session;
984
1138
  this.eventBus({
985
1139
  type: "session",
@@ -991,21 +1145,21 @@ var $ = class {
991
1145
  })();
992
1146
  };
993
1147
  registerFramework = (e) => {
994
- L(e, this.frameworks);
1148
+ ge(e, this.frameworks);
995
1149
  };
996
1150
  registerComponent = (e, t) => {
997
- N(e, t, this.components);
1151
+ H(e, t, this.components);
998
1152
  };
999
1153
  registerPlugin = (e) => {
1000
- ae(this, e, this.plugins);
1154
+ de(this, e, this.plugins);
1001
1155
  let t = this.plugins[e.name];
1002
1156
  t?.onStart && this.pluginStartHooks.push(t.onStart);
1003
1157
  };
1004
1158
  registerFeature = (e, t) => {
1005
- he(e, t, this.features);
1159
+ Ee(e, t, this.features);
1006
1160
  };
1007
1161
  registerPredicate = (e, t) => {
1008
- fe(e, t, this.predicates);
1162
+ Ce(e, t, this.predicates);
1009
1163
  };
1010
1164
  registerCondition = (e) => {
1011
1165
  this.conditions.register(e);
@@ -1014,15 +1168,15 @@ var $ = class {
1014
1168
  this.fields.register(e);
1015
1169
  };
1016
1170
  registerStep = (e) => {
1017
- Ee(e, this.steps);
1171
+ Re(e, this.steps);
1018
1172
  };
1019
1173
  registerAction = (e, t) => {
1020
- Ae(e, t, this.actions);
1174
+ He(e, t, this.actions);
1021
1175
  };
1022
1176
  registerExperience = (e) => {
1023
- e.component && N(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1177
+ e.component && H(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1024
1178
  };
1025
- getStateSnapshot = () => V(this);
1179
+ getStateSnapshot = () => U(this);
1026
1180
  launchExperienceById = async (e, t) => {
1027
1181
  this.experiences.launch({
1028
1182
  id: e,
@@ -1044,8 +1198,8 @@ var $ = class {
1044
1198
  async runPluginStartHooks() {
1045
1199
  for (let e of this.pluginStartHooks) await e();
1046
1200
  }
1047
- async evaluateGate(t) {
1048
- return t === void 0 ? !0 : typeof t == "boolean" ? t : await e(this, t) === !0;
1201
+ async evaluateGate(e) {
1202
+ return e === void 0 ? !0 : typeof e == "boolean" ? e : await t(this, e) === !0;
1049
1203
  }
1050
1204
  setupPlugins() {
1051
1205
  this.options.plugins?.forEach((e) => {
@@ -1111,7 +1265,7 @@ var $ = class {
1111
1265
  getPluginConfig = (e) => this.plugins[e] ?? {};
1112
1266
  renderString = (e, t) => {
1113
1267
  let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldKey] = t.value, e), {});
1114
- return tt(e, {
1268
+ return pt(e, {
1115
1269
  ...t,
1116
1270
  responses: n
1117
1271
  });
@@ -1119,20 +1273,20 @@ var $ = class {
1119
1273
  };
1120
1274
  //#endregion
1121
1275
  //#region src/entities/component/lazyComponent.ts
1122
- function nt(e) {
1276
+ function mt(e) {
1123
1277
  return {
1124
1278
  $$type: "lazy-component",
1125
1279
  load: e
1126
1280
  };
1127
1281
  }
1128
- function rt(e) {
1282
+ function ht(e) {
1129
1283
  return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
1130
1284
  }
1131
1285
  //#endregion
1132
1286
  //#region src/exports.ts
1133
- var it = (e) => {
1287
+ var gt = (e) => {
1134
1288
  let t = new $(e);
1135
- return u(t), t;
1289
+ return d(t), t;
1136
1290
  };
1137
1291
  //#endregion
1138
- export { $ as Picked, it as createClient, x as createStorageKey, e as evaluateRuleLogic, X as getPickedConfig, rt as isLazyLoader, _ as isPickedRoot, nt as lazyComponent, y as localStore, b as sessionStore, te as subscribe, p as supportsCookies, c as supportsCryptoRandomUUID, d as supportsDocument, o as supportsHistory, r as supportsIntersectionObserver, l as supportsLocalStorage, f as supportsLocation, i as supportsSessionStorage, s as supportsShadowRoot, m as supportsWebComponents, a as supportsWindow };
1292
+ export { $ as Picked, gt as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, ht as isLazyLoader, _ as isPickedRoot, mt as lazyComponent, b as localStore, x as sessionStore, ie 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 };