@picked/client 0.0.48 → 0.0.49-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -3,9 +3,9 @@ import { createFactory as b, invoke as I } from "@withease/factories";
3
3
  import { g as W, t as te, c as re, i as se, e as P, a as ne, b as ie, d as oe } from "../experience-instance-fvSEb72i.js";
4
4
  import { f as zt } from "../experience-instance-fvSEb72i.js";
5
5
  import { l as w } from "../logger-C9a75KZn.js";
6
- import { c as A, l as C, s as M } from "../storage-Co_LbKr_.js";
7
- import { a as Mt } from "../storage-Co_LbKr_.js";
8
- import { p as ae, g as ce } from "../api-CTXU-Aoh.js";
6
+ import { c as A, l as C, s as O } from "../storage-Co_LbKr_.js";
7
+ import { a as Ot } from "../storage-Co_LbKr_.js";
8
+ import { p as ae, g as ce } from "../api-DlWmrA8P.js";
9
9
  import { g as ue } from "../id-BW-g3y32.js";
10
10
  import { i as de } from "../object-JwZ58NOH.js";
11
11
  import { s as L, a as _, b as le, c as pe, d as fe } from "../supports-8YT4QKI7.js";
@@ -13,33 +13,33 @@ import { e as Ut, f as Dt, g as Vt, h as Nt, i as Tt, j as Lt, k as _t } from ".
13
13
  const Y = x("experience"), ge = b(
14
14
  ({ client: t, experience: e }) => {
15
15
  const r = Y.store(e), s = j(r, {
16
- merge(u, g) {
16
+ merge(d, g) {
17
17
  return {
18
- ...u,
18
+ ...d,
19
19
  ...g.experience
20
20
  };
21
21
  }
22
- }), i = r.map((u) => ({
23
- name: u.name,
24
- decisionLogic: u.condition ?? u.decide,
25
- targetSelectors: u.targets,
22
+ }), n = r.map((d) => ({
23
+ name: d.name,
24
+ decisionLogic: d.condition ?? d.decide,
25
+ targetSelectors: d.targets,
26
26
  initializeOpenLogic: e.initializeOpen
27
- })), l = t.components.listStore.map(
28
- (u) => u.find((g) => g.name === `experience:${e.id}`) || u.find((g) => g.name === "experience"),
27
+ })), p = t.components.listStore.map(
28
+ (d) => (e.componentName ? d.find((g) => g.name === e.componentName) : void 0) || d.find((g) => g.name === `experience:${e.id}`) || d.find((g) => g.name === "experience"),
29
29
  { skipVoid: !1 }
30
- ), a = r.map((u) => ({
31
- steps: u.steps,
32
- nodes: u.nodes,
33
- edges: u.edges,
34
- conditionals: u.conditionals
35
- })), n = r.map((u) => u.fields), p = e.actions ?? [];
30
+ ), a = r.map((d) => ({
31
+ steps: d.steps,
32
+ nodes: d.nodes,
33
+ edges: d.edges,
34
+ conditionals: d.conditionals
35
+ })), i = r.map((d) => d.fields), c = e.actions ?? [];
36
36
  return {
37
37
  id: e.id,
38
- configStore: i,
38
+ configStore: n,
39
39
  treeStore: a,
40
- fieldsStore: n,
41
- componentStore: l,
42
- actions: p,
40
+ fieldsStore: i,
41
+ componentStore: p,
42
+ actions: c,
43
43
  merge: s.merge
44
44
  };
45
45
  }
@@ -49,64 +49,64 @@ function me(t) {
49
49
  }
50
50
  const he = b(({ client: t }) => {
51
51
  const e = Y.store({}), r = j(e, {
52
- register(u, g) {
52
+ register(c, d) {
53
53
  return {
54
- ...u,
55
- [g.id]: g
54
+ ...c,
55
+ [d.id]: d
56
56
  };
57
57
  }
58
58
  });
59
- function s(u) {
60
- const g = e.getState()[u.id];
61
- if (g) {
62
- g.merge({ experience: u, strategy: "override" });
59
+ function s(c) {
60
+ const d = e.getState()[c.id];
61
+ if (d) {
62
+ d.merge({ experience: c, strategy: "override" });
63
63
  return;
64
64
  }
65
- const S = me({ client: t, experience: u });
66
- r.register(S);
65
+ const g = me({ client: t, experience: c });
66
+ r.register(g);
67
67
  }
68
- const i = e.map((u) => Object.values(u));
69
- function l(u) {
70
- return e.map((g) => g[u], { skipVoid: !1 });
68
+ const n = e.map((c) => Object.values(c));
69
+ function p(c) {
70
+ return e.map((d) => d[c], { skipVoid: !1 });
71
71
  }
72
- const a = l, n = U({
72
+ const a = U({
73
73
  source: e,
74
- effect: async (u, { id: g, options: S }) => {
75
- const m = u[g];
76
- if (!m) {
77
- w("warn", `Experience with id '${g}' not found.`);
74
+ effect: async (c, { id: d, options: g }) => {
75
+ const S = c[d];
76
+ if (!S) {
77
+ w("warn", `Experience with id '${d}' not found.`);
78
78
  return;
79
79
  }
80
- if (S?.bypassCondition) {
81
- N(t, m, S);
80
+ if (g?.bypassCondition) {
81
+ N(t, S, g);
82
82
  return;
83
83
  }
84
- await Q(t, m) && N(t, m, S);
84
+ await Q(t, S) && N(t, S, g);
85
85
  }
86
- }), p = U({
86
+ }), i = U({
87
87
  source: t.experienceInstances.listStore,
88
- effect: (u, { id: g, options: S }) => {
89
- const m = u.filter((o) => o.experienceId === g);
90
- if (m.length > 0)
91
- for (const o of m)
92
- o.open();
88
+ effect: (c, { id: d, options: g }) => {
89
+ const S = c.filter((m) => m.experienceId === d);
90
+ if (S.length > 0)
91
+ for (const m of S)
92
+ m.open();
93
93
  else
94
- n({ id: g, options: { ...S, initialiseOpen: !0 } });
94
+ a({ id: d, options: { ...g, initialiseOpen: !0 } });
95
95
  }
96
96
  });
97
97
  return {
98
98
  /** Registers an experience in the index. If an experience with the same ID already exists, it is merged. */
99
99
  register: s,
100
100
  /** Returns a derived store for an experience by its ID. The store value is `undefined` when no match exists. */
101
- get: l,
101
+ get: p,
102
102
  /** @deprecated Use `experiences.get(id)` instead. */
103
- getById: a,
103
+ getById: p,
104
104
  /** Effector effect that launches an experience by ID, creating instances for each DOM target. */
105
- launch: n,
105
+ launch: a,
106
106
  /** Effector effect that opens an experience's existing instances, or launches it with `initialiseOpen` if none exist. */
107
- open: p,
107
+ open: i,
108
108
  /** Derived store containing all registered experiences as an array. */
109
- listStore: i
109
+ listStore: n
110
110
  };
111
111
  });
112
112
  function ye(t) {
@@ -115,10 +115,10 @@ function ye(t) {
115
115
  const Se = (t, e) => {
116
116
  e.register(t);
117
117
  }, N = (t, e, r) => {
118
- const { targetSelectors: s } = e.configStore.getState(), i = W(s, e.id);
119
- i.forEach(
120
- ({ elements: a }) => a.forEach((n) => te(n, e.id))
121
- ), re(i, e.id).forEach((a) => {
118
+ const { targetSelectors: s } = e.configStore.getState(), n = W(s, e.id);
119
+ n.forEach(
120
+ ({ elements: a }) => a.forEach((i) => te(i, e.id))
121
+ ), re(n, e.id).forEach((a) => {
122
122
  r ? t.experienceInstances.spawn(e, a, r) : t.experienceInstances.spawn(e, a);
123
123
  });
124
124
  }, H = async (t) => {
@@ -128,15 +128,15 @@ const Se = (t, e) => {
128
128
  })
129
129
  );
130
130
  }, Q = async (t, e) => {
131
- if (!t.session?.isUser)
131
+ if (!t.preconditionPassed || !t.session?.isUser)
132
132
  return !1;
133
133
  const { decisionLogic: r, targetSelectors: s } = e.configStore.getState();
134
134
  return W(s, e.id).length < 1 || s.length === 0 ? !1 : r === void 0 ? !0 : se(r) ? await P(t, r) === !0 : !0;
135
135
  }, ve = (t, e, r) => {
136
- const s = e.name, i = e.setup(t);
137
- if (i) {
138
- const l = r[s] ?? {};
139
- r[s] = Object.freeze({ ...l, ...i });
136
+ const s = e.name, n = e.setup(t);
137
+ if (n) {
138
+ const p = r[s] ?? {};
139
+ r[s] = Object.freeze({ ...p, ...n });
140
140
  }
141
141
  }, ke = x("component"), we = b(
142
142
  ({ client: t, component: e, name: r }) => {
@@ -153,29 +153,29 @@ function be(t) {
153
153
  }
154
154
  const Ie = b(({ client: t }) => {
155
155
  const e = ke.store({}), r = j(e, {
156
- register(a, n) {
156
+ register(a, i) {
157
157
  return {
158
158
  ...a,
159
- [n.name]: n
159
+ [i.name]: i
160
160
  };
161
161
  }
162
162
  });
163
- function s(a, n) {
163
+ function s(a, i) {
164
164
  e.getState()[a] && w(
165
165
  "warn",
166
166
  `Component '${a}' already registered. Registering again will override the previous registration.`
167
167
  );
168
- const u = be({ client: t, name: a, component: n });
169
- r.register(u);
168
+ const d = be({ client: t, name: a, component: i });
169
+ r.register(d);
170
170
  }
171
- const i = e.map((a) => Object.values(a));
172
- function l(a) {
173
- return e.map((n) => n[a], { skipVoid: !1 });
171
+ const n = e.map((a) => Object.values(a));
172
+ function p(a) {
173
+ return e.map((i) => i[a], { skipVoid: !1 });
174
174
  }
175
175
  return {
176
176
  register: s,
177
- getByName: l,
178
- listStore: i
177
+ getByName: p,
178
+ listStore: n
179
179
  };
180
180
  });
181
181
  function Fe(t) {
@@ -185,27 +185,27 @@ const G = (t, e, r) => {
185
185
  r.register(t, e);
186
186
  }, xe = x("framework"), je = b(({ client: t }) => {
187
187
  const e = xe.store({}), r = j(e, {
188
- register(a, n) {
188
+ register(a, i) {
189
189
  return {
190
190
  ...a,
191
- [n.name]: n.framework
191
+ [i.name]: i.framework
192
192
  };
193
193
  }
194
194
  });
195
- function s(a, n) {
195
+ function s(a, i) {
196
196
  e.getState()[a] && w(
197
197
  "warn",
198
198
  `Framework '${a}' already registered. Registering again will override the previous registration.`
199
- ), r.register({ name: a, framework: n });
199
+ ), r.register({ name: a, framework: i });
200
200
  }
201
- const i = e.map((a) => Object.values(a));
202
- function l(a) {
203
- return e.map((n) => n[a], { skipVoid: !1 });
201
+ const n = e.map((a) => Object.values(a));
202
+ function p(a) {
203
+ return e.map((i) => i[a], { skipVoid: !1 });
204
204
  }
205
205
  return {
206
206
  register: s,
207
- getByName: l,
208
- listStore: i
207
+ getByName: p,
208
+ listStore: n
209
209
  };
210
210
  });
211
211
  function Ee(t) {
@@ -219,13 +219,13 @@ const Pe = (t, e) => {
219
219
  let s = 0;
220
220
  if (r.isSet() && (s = r.json() ?? 0), s && e - s < Ae)
221
221
  return !0;
222
- const i = {
222
+ const n = {
223
223
  projectId: t.projectId,
224
224
  path: window.location.pathname
225
- }, l = {}, n = document.getElementById("picked_script")?.dataset.verceltoken;
226
- n && (l["x-vercel-protection-bypass"] = n);
227
- const u = (await ae(t.apiUrl, "ping", i, l)).ok;
228
- return u && r.set(e), u;
225
+ }, p = {}, i = document.getElementById("picked_script")?.dataset.verceltoken;
226
+ i && (p["x-vercel-protection-bypass"] = i);
227
+ const d = (await ae(t.apiUrl, "ping", n, p)).ok;
228
+ return d && r.set(e), d;
229
229
  } catch (e) {
230
230
  return w("error", e), !1;
231
231
  }
@@ -244,32 +244,32 @@ function X(t) {
244
244
  }
245
245
  const Re = x("predicate"), ze = b(({ client: t }) => {
246
246
  const e = Re.store({}), r = j(e, {
247
- register(n, p) {
247
+ register(i, c) {
248
248
  return {
249
- ...n,
250
- [p.name]: {
251
- name: p.name,
252
- predicate: p.predicate
249
+ ...i,
250
+ [c.name]: {
251
+ name: c.name,
252
+ predicate: c.predicate
253
253
  }
254
254
  };
255
255
  }
256
256
  });
257
- function s(n, p) {
258
- e.getState()[n] && w(
257
+ function s(i, c) {
258
+ e.getState()[i] && w(
259
259
  "warn",
260
- `Predicate '${n}' already registered. Registering again will override the previous registration.`
261
- ), r.register(Object.freeze({ name: n, predicate: p }));
260
+ `Predicate '${i}' already registered. Registering again will override the previous registration.`
261
+ ), r.register(Object.freeze({ name: i, predicate: c }));
262
262
  }
263
- const i = e.map((n) => Object.values(n));
264
- function l(n) {
265
- return e.map((p) => p[n]?.predicate, { skipVoid: !1 });
263
+ const n = e.map((i) => Object.values(i));
264
+ function p(i) {
265
+ return e.map((c) => c[i]?.predicate, { skipVoid: !1 });
266
266
  }
267
- function a(n) {
268
- const p = T(() => {
267
+ function a(i) {
268
+ const c = T(() => {
269
269
  }, {
270
270
  skipVoid: !1
271
- }), u = R(async () => {
272
- const g = l(n).getState();
271
+ }), d = R(async () => {
272
+ const g = p(i).getState();
273
273
  if (!g)
274
274
  return;
275
275
  const S = X(t);
@@ -277,71 +277,71 @@ const Re = x("predicate"), ze = b(({ client: t }) => {
277
277
  });
278
278
  return k({
279
279
  source: { responses: t.responses.listStore, fields: t.fields.listStore },
280
- target: u
280
+ target: d
281
281
  }), k({
282
- clock: u.doneData,
282
+ clock: d.doneData,
283
283
  filter: (g) => g !== void 0,
284
- target: p
285
- }), u(), p;
284
+ target: c
285
+ }), d(), c;
286
286
  }
287
287
  return {
288
288
  register: s,
289
- getByName: l,
290
- listStore: i,
289
+ getByName: p,
290
+ listStore: n,
291
291
  getEvokablePredicate: a
292
292
  };
293
293
  });
294
294
  function Ce(t) {
295
295
  return I(ze, t);
296
296
  }
297
- const Me = (t, e, r) => {
297
+ const Oe = (t, e, r) => {
298
298
  r.register(t, e);
299
- }, J = x("feature"), Oe = b(({ client: t }) => {
299
+ }, J = x("feature"), Me = b(({ client: t }) => {
300
300
  const e = J.store({}), r = J.store([]), s = j(e, {
301
- register(o, c) {
301
+ register(o, u) {
302
302
  return {
303
303
  ...o,
304
- [c.id]: c.feature
304
+ [u.id]: u.feature
305
305
  };
306
306
  }
307
307
  });
308
- function i(o, c) {
308
+ function n(o, u) {
309
309
  e.getState()[o] && w(
310
310
  "warn",
311
311
  `Feature '${o}' already registered. Registering again will override the previous registration.`
312
312
  );
313
- const d = {
313
+ const l = {
314
314
  id: o,
315
315
  feature: {
316
- ...c,
316
+ ...u,
317
317
  id: o
318
318
  }
319
319
  };
320
320
  s.register(
321
321
  Object.freeze({
322
322
  id: o,
323
- feature: d
323
+ feature: l
324
324
  })
325
325
  );
326
326
  }
327
- const l = R(
327
+ const p = R(
328
328
  async ({
329
329
  id: o,
330
- key: c,
330
+ key: u,
331
331
  storage: f = "local"
332
332
  }) => {
333
- const d = A(`feature:${o}:${c}`, "global"), y = (f === "session" ? M : C).get(d).boolean();
334
- return y === null ? null : { id: o, key: c, bucket: y, storage: f };
333
+ const l = A(`feature:${o}:${u}`, "global"), y = (f === "session" ? O : C).get(l).boolean();
334
+ return y === null ? null : { id: o, key: u, bucket: y, storage: f };
335
335
  }
336
336
  ), a = R((o) => {
337
337
  if (!o)
338
338
  return null;
339
- const c = A(`feature:${o.id}:${o.key}`, "global");
340
- (o.storage === "session" ? M : C).set(c, o.bucket);
341
- }), n = /* @__PURE__ */ new Map(), p = U({
339
+ const u = A(`feature:${o.id}:${o.key}`, "global");
340
+ (o.storage === "session" ? O : C).set(u, o.bucket);
341
+ }), i = /* @__PURE__ */ new Map(), c = U({
342
342
  source: { allFeaturesStore: e, resolvedFeaturesStore: r },
343
- effect: async ({ allFeaturesStore: o, resolvedFeaturesStore: c }, { id: f, decide: d, key: h }) => {
344
- const y = c.find(
343
+ effect: async ({ allFeaturesStore: o, resolvedFeaturesStore: u }, { id: f, decide: l, key: h }) => {
344
+ const y = u.find(
345
345
  (B) => B.id === f && B.key === h
346
346
  );
347
347
  if (y)
@@ -349,13 +349,13 @@ const Me = (t, e, r) => {
349
349
  const F = o[f];
350
350
  if (!F)
351
351
  throw new Error(`Feature with id '${f}' not found`);
352
- const $ = n.get(`${f}:${h}`);
352
+ const $ = i.get(`${f}:${h}`);
353
353
  if ($ !== void 0) {
354
354
  const B = await $;
355
355
  return { id: F.id, bucket: B, key: h, storage: F.feature.storage };
356
356
  }
357
- const v = d();
358
- n.set(`${f}:${h}`, v);
357
+ const v = l();
358
+ i.set(`${f}:${h}`, v);
359
359
  const ee = await v;
360
360
  return { id: F.id, bucket: ee, key: h, storage: F.feature.storage };
361
361
  }
@@ -363,97 +363,97 @@ const Me = (t, e, r) => {
363
363
  k({
364
364
  clock: s.register,
365
365
  fn: (o) => {
366
- const { id: c, feature: f } = o;
367
- return { id: c, key: f.feature.key, storage: f.feature.storage };
366
+ const { id: u, feature: f } = o;
367
+ return { id: u, key: f.feature.key, storage: f.feature.storage };
368
368
  },
369
- target: l
369
+ target: p
370
370
  }), k({
371
371
  source: e,
372
- clock: p.doneData,
373
- fn: (o, c) => {
374
- const { id: f, bucket: d, storage: h } = c, y = o[f]?.feature.key;
375
- return y ? { key: y, id: f, bucket: d, storage: h } : null;
372
+ clock: c.doneData,
373
+ fn: (o, u) => {
374
+ const { id: f, bucket: l, storage: h } = u, y = o[f]?.feature.key;
375
+ return y ? { key: y, id: f, bucket: l, storage: h } : null;
376
376
  },
377
377
  target: a
378
378
  });
379
- const u = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
379
+ const d = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
380
380
  ({
381
381
  allFeaturesStore: o,
382
- resolvedFeaturesStore: c
382
+ resolvedFeaturesStore: u
383
383
  }) => Object.values(o).map((f) => {
384
- const d = c.find(
384
+ const l = u.find(
385
385
  (h) => h.id === f.id && h.key === f.feature.key
386
386
  );
387
- return d ? {
387
+ return l ? {
388
388
  id: f.id,
389
389
  name: f.feature.name,
390
390
  key: f.feature.key,
391
- getBucket: () => ({ id: f.id, bucket: d.bucket }),
391
+ getBucket: () => ({ id: f.id, bucket: l.bucket }),
392
392
  isResolved: !0
393
393
  } : {
394
394
  id: f.id,
395
395
  name: f.feature.name,
396
396
  key: f.feature.key,
397
- getBucket: async () => await p(f.feature),
397
+ getBucket: async () => await c(f.feature),
398
398
  isResolved: !1
399
399
  };
400
400
  })
401
401
  );
402
402
  k({
403
- clock: p.doneData,
403
+ clock: c.doneData,
404
404
  source: { resolvedFeatures: r },
405
- filter: ({ resolvedFeatures: o }, { id: c, key: f }) => !o.some(
406
- (h) => h.id === c && h.key === f
405
+ filter: ({ resolvedFeatures: o }, { id: u, key: f }) => !o.some(
406
+ (h) => h.id === u && h.key === f
407
407
  ),
408
- fn: (o, c) => c,
408
+ fn: (o, u) => u,
409
409
  target: t.eventBus.prepend((o) => ({
410
410
  type: "feature_decide",
411
411
  feature: o
412
412
  }))
413
413
  }), k({
414
- clock: [l.doneData, p.doneData],
414
+ clock: [p.doneData, c.doneData],
415
415
  source: r,
416
- fn: (o, c) => !c || o.some(
417
- (d) => d.id === c.id && d.key === c.key
418
- ) ? o : [...o, c],
416
+ fn: (o, u) => !u || o.some(
417
+ (l) => l.id === u.id && l.key === u.key
418
+ ) ? o : [...o, u],
419
419
  target: r
420
420
  });
421
421
  function g(o) {
422
- return u.map((c) => c.find((f) => f.id === o));
422
+ return d.map((u) => u.find((f) => f.id === o));
423
423
  }
424
424
  function S(o) {
425
- return e.map((c) => c[o], { skipVoid: !1 });
425
+ return e.map((u) => u[o], { skipVoid: !1 });
426
426
  }
427
427
  function m(o) {
428
- const c = T(
428
+ const u = T(
429
429
  async () => {
430
430
  },
431
431
  { skipVoid: !1 }
432
432
  ), f = R(async () => {
433
- const d = g(o).getState();
434
- if (d)
435
- return async () => (await d.getBucket()).bucket;
433
+ const l = g(o).getState();
434
+ if (l)
435
+ return async () => (await l.getBucket()).bucket;
436
436
  });
437
437
  return k({
438
438
  source: r,
439
- filter: (d) => d.some((h) => h.id === o),
439
+ filter: (l) => l.some((h) => h.id === o),
440
440
  target: f
441
441
  }), k({
442
442
  clock: f.doneData,
443
- filter: (d) => d !== void 0,
444
- target: c
445
- }), f(), c;
443
+ filter: (l) => l !== void 0,
444
+ target: u
445
+ }), f(), u;
446
446
  }
447
447
  return {
448
- register: i,
448
+ register: n,
449
449
  getById: g,
450
450
  getByName: S,
451
- listStore: u,
451
+ listStore: d,
452
452
  getEvokableFeature: m
453
453
  };
454
454
  });
455
455
  function Ue(t) {
456
- return I(Oe, t);
456
+ return I(Me, t);
457
457
  }
458
458
  const De = (t, e, r) => {
459
459
  r.register(t, e);
@@ -468,40 +468,40 @@ function q(t, e) {
468
468
  };
469
469
  }
470
470
  const Ve = b(() => {
471
- const t = E.store({ entries: [] }), e = E.event(), r = E.event(), s = E.event(), i = E.event();
472
- t.on(e, (a, n) => ({
473
- entries: [...a.entries, q(n.experienceId, n.node)]
474
- })), t.on(r, (a, n) => ({
471
+ const t = E.store({ entries: [] }), e = E.event(), r = E.event(), s = E.event(), n = E.event();
472
+ t.on(e, (a, i) => ({
473
+ entries: [...a.entries, q(i.experienceId, i.node)]
474
+ })), t.on(r, (a, i) => ({
475
475
  entries: [
476
476
  ...a.entries.slice(0, -1),
477
- q(n.experienceId, n.node)
477
+ q(i.experienceId, i.node)
478
478
  ]
479
- })), t.on(i, (a, n) => n);
480
- function l(a, n) {
481
- const p = { lastStepIndex: -1, secondLastStepIndex: -1 };
482
- for (let u = a.length - 1; u >= 0; u--) {
483
- const g = a[u], S = g?.node;
484
- if (!(!S || !ne(S)) && !(n && g?.experienceId !== n))
485
- if (p.lastStepIndex === -1)
486
- p.lastStepIndex = u;
479
+ })), t.on(n, (a, i) => i);
480
+ function p(a, i) {
481
+ const c = { lastStepIndex: -1, secondLastStepIndex: -1 };
482
+ for (let d = a.length - 1; d >= 0; d--) {
483
+ const g = a[d], S = g?.node;
484
+ if (!(!S || !ne(S)) && !(i && g?.experienceId !== i))
485
+ if (c.lastStepIndex === -1)
486
+ c.lastStepIndex = d;
487
487
  else {
488
- p.secondLastStepIndex = u;
488
+ c.secondLastStepIndex = d;
489
489
  break;
490
490
  }
491
491
  }
492
- return p;
492
+ return c;
493
493
  }
494
- return t.on(s, (a, n) => {
495
- const { secondLastStepIndex: p } = l(a.entries, n.experienceId), u = p !== -1 ? a.entries.slice(0, p + 1) : a.entries;
494
+ return t.on(s, (a, i) => {
495
+ const { secondLastStepIndex: c } = p(a.entries, i.experienceId), d = c !== -1 ? a.entries.slice(0, c + 1) : a.entries;
496
496
  return {
497
497
  ...a,
498
- entries: u
498
+ entries: d
499
499
  };
500
500
  }), {
501
501
  push: e,
502
502
  replace: r,
503
503
  back: s,
504
- restore: i,
504
+ restore: n,
505
505
  entriesStore: t.map((a) => a.entries)
506
506
  };
507
507
  });
@@ -526,37 +526,37 @@ const Le = (t) => {
526
526
  }), e;
527
527
  }, _e = x("field"), He = b(() => {
528
528
  const t = _e.store({}), e = j(t, {
529
- register(n, p) {
529
+ register(i, c) {
530
530
  return {
531
- ...n,
532
- [p.field.id]: p.field
531
+ ...i,
532
+ [c.field.id]: c.field
533
533
  };
534
534
  }
535
535
  });
536
- function r(n) {
537
- e.register({ field: n });
536
+ function r(i) {
537
+ e.register({ field: i });
538
538
  }
539
- function s(n, p) {
540
- const u = l(n).getState();
541
- if (!u)
539
+ function s(i, c) {
540
+ const d = p(i).getState();
541
+ if (!d)
542
542
  return;
543
- const g = Object.assign({}, u, {
544
- ...p
543
+ const g = Object.assign({}, d, {
544
+ ...c
545
545
  });
546
546
  e.register({ field: { ...g } });
547
547
  }
548
- const i = t.map((n) => Object.values(n));
549
- function l(n) {
550
- return t.map((p) => p[n] || null);
548
+ const n = t.map((i) => Object.values(i));
549
+ function p(i) {
550
+ return t.map((c) => c[i] || null);
551
551
  }
552
- function a(n) {
553
- return t.map((p) => Object.values(p).find((u) => u.name === n) || null);
552
+ function a(i) {
553
+ return t.map((c) => Object.values(c).find((d) => d.name === i) || null);
554
554
  }
555
555
  return {
556
556
  register: r,
557
557
  update: s,
558
- getById: l,
559
- listStore: i,
558
+ getById: p,
559
+ listStore: n,
560
560
  getByName: a
561
561
  };
562
562
  });
@@ -567,37 +567,37 @@ const Je = (t, e) => {
567
567
  e.register(t);
568
568
  }, qe = x("action"), Ke = b(() => {
569
569
  const t = qe.store({}), e = j(t, {
570
- register(a, n) {
570
+ register(a, i) {
571
571
  return {
572
572
  ...a,
573
- [n.name]: {
574
- name: n.name,
575
- action: n.action
573
+ [i.name]: {
574
+ name: i.name,
575
+ action: i.action
576
576
  }
577
577
  };
578
578
  }
579
579
  });
580
- function r(a, n) {
581
- e.register({ name: a, action: n });
580
+ function r(a, i) {
581
+ e.register({ name: a, action: i });
582
582
  }
583
583
  const s = t.map((a) => Object.values(a));
584
- function i(a) {
585
- return t.map((n) => n[a], { skipVoid: !1 });
584
+ function n(a) {
585
+ return t.map((i) => i[a], { skipVoid: !1 });
586
586
  }
587
- function l(a) {
587
+ function p(a) {
588
588
  return t.map(
589
- (n) => {
590
- const p = n[a];
591
- return p ? p.action : void 0;
589
+ (i) => {
590
+ const c = i[a];
591
+ return c ? c.action : void 0;
592
592
  },
593
593
  { skipVoid: !1 }
594
594
  );
595
595
  }
596
596
  return {
597
597
  register: r,
598
- getByName: i,
598
+ getByName: n,
599
599
  listStore: s,
600
- getEvokableAction: l
600
+ getEvokableAction: p
601
601
  };
602
602
  });
603
603
  function We() {
@@ -606,7 +606,7 @@ function We() {
606
606
  const Ye = (t, e, r) => {
607
607
  r.register(t, e);
608
608
  };
609
- function O(t) {
609
+ function M(t) {
610
610
  return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
611
611
  }
612
612
  function Qe(t) {
@@ -620,7 +620,7 @@ function K(t) {
620
620
  }
621
621
  }
622
622
  const Xe = x("response"), Ze = b(({ client: t }) => {
623
- const e = Xe.store({}), r = V(), s = V(), i = j(e, {
623
+ const e = Xe.store({}), r = V(), s = V(), n = j(e, {
624
624
  register(m, o) {
625
625
  return {
626
626
  ...m,
@@ -634,193 +634,193 @@ const Xe = x("response"), Ze = b(({ client: t }) => {
634
634
  };
635
635
  },
636
636
  clear(m, o) {
637
- const { [o]: c, ...f } = m;
637
+ const { [o]: u, ...f } = m;
638
638
  return f;
639
639
  },
640
640
  clearAll() {
641
641
  return {};
642
642
  }
643
643
  });
644
- function l(m, o) {
644
+ function p(m, o) {
645
645
  if (typeof m == "string") {
646
646
  if (o === void 0)
647
647
  throw new Error("Response is required when registering a single field");
648
- i.register({ fieldId: m, response: o });
648
+ n.register({ fieldId: m, response: o });
649
649
  } else
650
- i.registerBatch(m);
650
+ n.registerBatch(m);
651
651
  }
652
652
  async function a(m) {
653
653
  const o = [];
654
654
  return await Promise.allSettled(
655
- Object.entries(m).map(async ([c, f]) => {
656
- let d = f;
657
- const h = t.fields.getById(c).getState();
655
+ Object.entries(m).map(async ([u, f]) => {
656
+ let l = f;
657
+ const h = t.fields.getById(u).getState();
658
658
  if (!h) {
659
659
  o.push({
660
- fieldId: c,
661
- userMessage: `Field '${c}' not found`,
662
- systemMessage: `No field with ID '${c}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
663
- value: d
660
+ fieldId: u,
661
+ userMessage: `Field '${u}' not found`,
662
+ systemMessage: `No field with ID '${u}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
663
+ value: l
664
664
  });
665
665
  return;
666
666
  }
667
- if (h.multiple && (typeof d == "string" || typeof d == "number" || typeof d == "boolean") && (d = [d]), h.validation && !de(h.validation) && !O(d)) {
667
+ if (h.multiple && (typeof l == "string" || typeof l == "number" || typeof l == "boolean") && (l = [l]), h.validation && !de(h.validation) && !M(l)) {
668
668
  const y = await P(t, h.validation, {
669
- $input: d
669
+ $input: l
670
670
  });
671
671
  if (typeof y == "string") {
672
672
  o.push({
673
- fieldId: c,
673
+ fieldId: u,
674
674
  userMessage: y,
675
675
  systemMessage: `Field validation resulted in an error: ${y}.`,
676
- value: d
676
+ value: l
677
677
  });
678
678
  return;
679
679
  }
680
680
  if (y === !1) {
681
681
  o.push({
682
- fieldId: c,
682
+ fieldId: u,
683
683
  userMessage: "This field is invalid",
684
684
  systemMessage: "Field validation resulted in an unspecified error.",
685
- value: d
685
+ value: l
686
686
  });
687
687
  return;
688
688
  }
689
689
  }
690
- if (h.required && O(d)) {
690
+ if (h.required && M(l)) {
691
691
  o.push({
692
- fieldId: c,
692
+ fieldId: u,
693
693
  userMessage: "This field is required",
694
694
  systemMessage: "Field is required.",
695
- value: d
695
+ value: l
696
696
  });
697
697
  return;
698
698
  }
699
- if (!h.multiple && Array.isArray(d) && d.length > 1) {
699
+ if (!h.multiple && Array.isArray(l) && l.length > 1) {
700
700
  o.push({
701
- fieldId: c,
701
+ fieldId: u,
702
702
  userMessage: "This field expects a single response",
703
703
  systemMessage: "Field expects a single response.",
704
- value: d
704
+ value: l
705
705
  });
706
706
  return;
707
707
  }
708
- if (h.type === "object" && !O(d))
708
+ if (h.type === "object" && !M(l))
709
709
  if (h.multiple) {
710
- if (!Array.isArray(d)) {
710
+ if (!Array.isArray(l)) {
711
711
  o.push({
712
- fieldId: c,
712
+ fieldId: u,
713
713
  userMessage: "This field expects multiple values",
714
714
  systemMessage: "Field expects an array of objects.",
715
- value: d
715
+ value: l
716
716
  });
717
717
  return;
718
718
  }
719
- for (const y of d) {
719
+ for (const y of l) {
720
720
  if (typeof y != "object" || y === null) {
721
721
  o.push({
722
- fieldId: c,
722
+ fieldId: u,
723
723
  userMessage: "This field expects object values",
724
724
  systemMessage: "Field expects an array of objects, but received non-object value.",
725
- value: d
725
+ value: l
726
726
  });
727
727
  return;
728
728
  }
729
729
  if (!K(y)) {
730
730
  o.push({
731
- fieldId: c,
731
+ fieldId: u,
732
732
  userMessage: "This field contains non-serializable data",
733
733
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
734
- value: d
734
+ value: l
735
735
  });
736
736
  return;
737
737
  }
738
738
  }
739
739
  } else {
740
- if (Array.isArray(d)) {
740
+ if (Array.isArray(l)) {
741
741
  o.push({
742
- fieldId: c,
742
+ fieldId: u,
743
743
  userMessage: "This field expects a single value",
744
744
  systemMessage: "Field expects a single object, not an array.",
745
- value: d
745
+ value: l
746
746
  });
747
747
  return;
748
748
  }
749
- if (typeof d != "object" || d === null) {
749
+ if (typeof l != "object" || l === null) {
750
750
  o.push({
751
- fieldId: c,
751
+ fieldId: u,
752
752
  userMessage: "This field expects an object value",
753
753
  systemMessage: "Field expects an object value.",
754
- value: d
754
+ value: l
755
755
  });
756
756
  return;
757
757
  }
758
- if (!K(d)) {
758
+ if (!K(l)) {
759
759
  o.push({
760
- fieldId: c,
760
+ fieldId: u,
761
761
  userMessage: "This field contains non-serializable data",
762
762
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
763
- value: d
763
+ value: l
764
764
  });
765
765
  return;
766
766
  }
767
767
  }
768
768
  if (Array.isArray(h.options) && h.options.length > 0) {
769
- const y = Array.isArray(d) ? d : [d];
769
+ const y = Array.isArray(l) ? l : [l];
770
770
  if (h.type === "object") {
771
771
  const F = h.options.map((v) => JSON.stringify(v.value));
772
772
  y.every((v) => F.includes(JSON.stringify(v))) || o.push({
773
- fieldId: c,
773
+ fieldId: u,
774
774
  userMessage: "This field expects a valid option",
775
775
  systemMessage: "Field expects a valid option from the defined choices.",
776
- value: d
776
+ value: l
777
777
  });
778
778
  } else {
779
779
  const F = h.options.map((v) => v.value);
780
780
  y.every((v) => !Qe(v) || v === null ? !1 : F.includes(v)) || o.push({
781
- fieldId: c,
781
+ fieldId: u,
782
782
  userMessage: "This field expects a valid option",
783
783
  systemMessage: `Field expects a valid option. Valid options are: ${F.join(", ")}`,
784
- value: d
784
+ value: l
785
785
  });
786
786
  }
787
787
  }
788
788
  })
789
789
  ), { responsesToCommit: m, validationErrors: o };
790
790
  }
791
- async function n(m) {
792
- const { responsesToCommit: o, validationErrors: c } = await a(m);
793
- return c.length ? { errors: c } : (i.registerBatch(o), { errors: [] });
791
+ async function i(m) {
792
+ const { responsesToCommit: o, validationErrors: u } = await a(m);
793
+ return u.length ? { errors: u } : (n.registerBatch(o), { errors: [] });
794
794
  }
795
- const p = e.map((m) => m), u = e.map((m) => Object.keys(m).map((c) => ({
796
- fieldId: c,
797
- value: m[c]
795
+ const c = e.map((m) => m), d = e.map((m) => Object.keys(m).map((u) => ({
796
+ fieldId: u,
797
+ value: m[u]
798
798
  })));
799
799
  function g(m) {
800
- const o = t.fields.getById(m), c = e.map((f) => f[m] || null);
801
- return D({ f: o, r: c }, ({ f, r: d }) => d || (f?.defaultValue ? f.defaultValue : null));
800
+ const o = t.fields.getById(m), u = e.map((f) => f[m] || null);
801
+ return D({ f: o, r: u }, ({ f, r: l }) => l || (f?.defaultValue ? f.defaultValue : null));
802
802
  }
803
803
  function S(m) {
804
804
  const o = t.fields.getByName(m);
805
- return D({ f: o, s: e }, ({ f: c, s: f }) => {
806
- const d = c && f[c.id] || null;
807
- return d || (c?.defaultValue ? c.defaultValue : null);
805
+ return D({ f: o, s: e }, ({ f: u, s: f }) => {
806
+ const l = u && f[u.id] || null;
807
+ return l || (u?.defaultValue ? u.defaultValue : null);
808
808
  });
809
809
  }
810
810
  return k({
811
811
  clock: r,
812
- target: i.clearAll
812
+ target: n.clearAll
813
813
  }), k({
814
814
  clock: s,
815
- target: i.clear
815
+ target: n.clear
816
816
  }), {
817
- register: l,
817
+ register: p,
818
818
  clearAll: r,
819
819
  clear: s,
820
- commit: n,
820
+ commit: i,
821
821
  getResponsesToCommit: a,
822
- listStore: u,
823
- getAllStore: p,
822
+ listStore: d,
823
+ getAllStore: c,
824
824
  getByFieldId: g,
825
825
  getByFieldName: S
826
826
  };
@@ -847,19 +847,19 @@ function rt() {
847
847
  if (!_())
848
848
  return {};
849
849
  const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
850
- for (const [i] of t.entries())
851
- i.startsWith("picked-") && r.add(i);
852
- for (const i of r) {
853
- const l = i.replace("picked-", "");
854
- e[l] = t.getAll(i);
850
+ for (const [n] of t.entries())
851
+ n.startsWith("picked-") && r.add(n);
852
+ for (const n of r) {
853
+ const p = n.replace("picked-", "");
854
+ e[p] = t.getAll(n);
855
855
  }
856
856
  const s = A("s");
857
857
  if (r.size > 0)
858
- M.set(s, e);
858
+ O.set(s, e);
859
859
  else {
860
- const i = M.get(s);
861
- if (i)
862
- return i.json() || {};
860
+ const n = O.get(s);
861
+ if (n)
862
+ return n.json() || {};
863
863
  }
864
864
  return e;
865
865
  }
@@ -873,23 +873,23 @@ const nt = A("session", "global"), it = () => {
873
873
  const t = C.get(nt);
874
874
  let e;
875
875
  t.isSet() && (e = t.json());
876
- const r = (i) => t.set({
877
- id: i.id,
878
- isUser: i.isUser,
879
- identifiers: i.identifiers
876
+ const r = (n) => t.set({
877
+ id: n.id,
878
+ isUser: n.isUser,
879
+ identifiers: n.identifiers
880
880
  }), s = {
881
881
  id: e?.id ?? st(),
882
882
  isUser: e?.isUser ?? void 0,
883
883
  identifiers: e?.identifiers ?? void 0,
884
- setIsUser(i) {
885
- this.isUser = i, r(this);
884
+ setIsUser(n) {
885
+ this.isUser = n, r(this);
886
886
  },
887
- setIdentifier(i, l) {
888
- this.identifiers = { ...this.identifiers, [i]: l }, r(this);
887
+ setIdentifier(n, p) {
888
+ this.identifiers = { ...this.identifiers, [n]: p }, r(this);
889
889
  },
890
- removeIdentifier(i) {
890
+ removeIdentifier(n) {
891
891
  this.identifiers && (this.identifiers = Object.fromEntries(
892
- Object.entries(this.identifiers).filter(([l]) => l !== i)
892
+ Object.entries(this.identifiers).filter(([p]) => p !== n)
893
893
  ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
894
894
  }
895
895
  };
@@ -922,9 +922,9 @@ function dt(t) {
922
922
  const s = ct();
923
923
  if (s)
924
924
  return s;
925
- const i = ut();
926
- if (i)
927
- return i;
925
+ const n = ut();
926
+ if (n)
927
+ return n;
928
928
  throw new Error(
929
929
  `organizationId and projectId are required. You can provide them via one of:
930
930
  (1) createClient({ organizationId, projectId }) options;
@@ -949,7 +949,7 @@ const lt = {
949
949
  if (Array.isArray(t))
950
950
  return e.format(t.map(String));
951
951
  if (t instanceof Map) {
952
- const r = Array.from(t.entries()).map(([s, i]) => `${s}: ${i}`);
952
+ const r = Array.from(t.entries()).map(([s, n]) => `${s}: ${n}`);
953
953
  return e.format(r);
954
954
  }
955
955
  return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
@@ -968,28 +968,28 @@ function ft(t, e) {
968
968
  return typeof r == "function" ? r() : r;
969
969
  }
970
970
  function gt(t, e) {
971
- const r = t.split("|").map((l) => l.trim()), s = r.shift() ?? "";
972
- let i = ft(s, e);
973
- for (const l of r) {
974
- const [a, ...n] = l.split(":"), p = a?.trim() ?? "", u = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), g = lt[p];
975
- g && (i = g(i, u));
971
+ const r = t.split("|").map((p) => p.trim()), s = r.shift() ?? "";
972
+ let n = ft(s, e);
973
+ for (const p of r) {
974
+ const [a, ...i] = p.split(":"), c = a?.trim() ?? "", d = i.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), g = lt[c];
975
+ g && (n = g(n, d));
976
976
  }
977
- return z(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
977
+ return z(n) ? "" : typeof n == "object" ? JSON.stringify(n) : String(n);
978
978
  }
979
979
  function mt(t, e) {
980
980
  let r = "", s = 0;
981
981
  for (; s < t.length; )
982
982
  if (t[s] === "{" && t[s + 1] === "{") {
983
983
  s += 2;
984
- let i = "";
984
+ let n = "";
985
985
  for (; s < t.length; ) {
986
986
  if (t[s] === "}" && t[s + 1] === "}") {
987
987
  s += 2;
988
988
  break;
989
989
  }
990
- i += t[s++];
990
+ n += t[s++];
991
991
  }
992
- r += gt(i.trim(), e);
992
+ r += gt(n.trim(), e);
993
993
  } else
994
994
  r += t[s++];
995
995
  return r;
@@ -1011,6 +1011,7 @@ class ht {
1011
1011
  session;
1012
1012
  precondition;
1013
1013
  condition;
1014
+ preconditionPassed;
1014
1015
  searchParams = rt();
1015
1016
  history = Ne();
1016
1017
  components = Fe({ client: this });
@@ -1025,7 +1026,7 @@ class ht {
1025
1026
  constructor(e) {
1026
1027
  w("info", "Picked client initializing."), this.events = Le(this.eventBus);
1027
1028
  const { organizationId: r, projectId: s } = dt(e);
1028
- this.organizationId = r, this.projectId = s, 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 = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: ce() }), w("info", "Picked client initialized.");
1029
+ this.organizationId = r, this.projectId = s, 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 = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: ce() }), w("info", "Picked client initialized.");
1029
1030
  }
1030
1031
  start = () => {
1031
1032
  Be(this), (async () => {
@@ -1033,16 +1034,17 @@ class ht {
1033
1034
  return;
1034
1035
  await this.runPluginStartHooks();
1035
1036
  const r = await this.evaluateGate(this.precondition);
1037
+ this.preconditionPassed = r;
1036
1038
  let s;
1037
1039
  r && (s = await this.evaluateGate(this.condition));
1038
- const i = r && s === !0;
1040
+ const n = r && s === !0;
1039
1041
  if (typeof s == "boolean" && this.session) {
1040
- const l = s;
1041
- this.session.setIsUser(l), this.eventBus({ type: "user_decide", value: l });
1042
+ const p = s;
1043
+ this.session.setIsUser(p), this.eventBus({ type: "user_decide", value: p });
1042
1044
  }
1043
- if (this.eventBus({ type: "initialize" }), i && H(this), await oe(), i && H(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1044
- const { id: l, isUser: a, identifiers: n } = this.session;
1045
- this.eventBus({ type: "session", id: l, isUser: a, identifiers: n });
1045
+ if (this.eventBus({ type: "initialize" }), n && H(this), await oe(), n && H(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1046
+ const { id: p, isUser: a, identifiers: i } = this.session;
1047
+ this.eventBus({ type: "session", id: p, isUser: a, identifiers: i });
1046
1048
  }
1047
1049
  })();
1048
1050
  };
@@ -1061,7 +1063,7 @@ class ht {
1061
1063
  De(e, r, this.features);
1062
1064
  };
1063
1065
  registerPredicate = (e, r) => {
1064
- Me(e, r, this.predicates);
1066
+ Oe(e, r, this.predicates);
1065
1067
  };
1066
1068
  registerField = (e) => {
1067
1069
  Je(e, this.fields);
@@ -1107,20 +1109,20 @@ class ht {
1107
1109
  setupFeatures() {
1108
1110
  const e = this.options.features;
1109
1111
  e && (Object.entries(e).forEach(([r, s]) => {
1110
- const i = typeof s == "function" ? s() : s;
1111
- this.registerFeature(r, i);
1112
+ const n = typeof s == "function" ? s() : s;
1113
+ this.registerFeature(r, n);
1112
1114
  }), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
1113
1115
  try {
1114
- const [s, i] = r.split(":");
1115
- if (!s || !i)
1116
+ const [s, n] = r.split(":");
1117
+ if (!s || !n)
1116
1118
  return;
1117
- let l = i;
1118
- l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(s, {
1119
- key: `${l}`,
1119
+ let p = n;
1120
+ p === "true" && (p = !0), p === "false" && (p = !1), this.registerFeature(s, {
1121
+ key: `${p}`,
1120
1122
  // use the assigned bucket value as the key
1121
1123
  name: s,
1122
1124
  // eslint-disable-next-line sonarjs/function-return-type
1123
- decide: () => l,
1125
+ decide: () => p,
1124
1126
  storage: "session"
1125
1127
  });
1126
1128
  } catch {
@@ -1147,6 +1149,12 @@ class ht {
1147
1149
  this.registerAction(r, s);
1148
1150
  });
1149
1151
  }
1152
+ setupComponents() {
1153
+ const e = this.options.components;
1154
+ e && Object.entries(e).forEach(([r, s]) => {
1155
+ this.registerComponent(r, s);
1156
+ });
1157
+ }
1150
1158
  getPluginConfig = (e) => this.plugins[e] ?? {};
1151
1159
  /**
1152
1160
  * Interpolates a template string using values from the client's response store and/or a provided context.
@@ -1191,7 +1199,7 @@ class ht {
1191
1199
  * // => "Fruits: apple, banana, and cherry"
1192
1200
  */
1193
1201
  renderString = (e, r) => {
1194
- const s = this.responses.listStore.getState().reduce((i, l) => (i[l.fieldId] = l.value, i), {});
1202
+ const s = this.responses.listStore.getState().reduce((n, p) => (n[p.fieldId] = p.value, n), {});
1195
1203
  return mt(e, {
1196
1204
  ...r,
1197
1205
  responses: s
@@ -1212,8 +1220,8 @@ async function Et(t, e) {
1212
1220
  if (!s.options || !Z(s))
1213
1221
  return s;
1214
1222
  const a = (await Promise.all(
1215
- s.options.map(async (p) => p.condition ? await P(t, p.condition) ? p : null : p)
1216
- )).filter((p) => p !== null);
1223
+ s.options.map(async (c) => c.condition ? await P(t, c.condition) ? c : null : c)
1224
+ )).filter((c) => c !== null);
1217
1225
  return a.length === s.options.length ? s : a.length === 0 ? null : { ...s, options: a };
1218
1226
  })
1219
1227
  )).filter((s) => s !== null);
@@ -1242,8 +1250,8 @@ export {
1242
1250
  zt as isPickedRoot,
1243
1251
  Pt as lazyComponent,
1244
1252
  C as localStore,
1245
- M as sessionStore,
1246
- Mt as subscribe,
1253
+ O as sessionStore,
1254
+ Ot as subscribe,
1247
1255
  Ut as supportsCookies,
1248
1256
  pe as supportsCryptoRandomUUID,
1249
1257
  L as supportsDocument,