@picked/client 0.0.1-dev.1770256874555 → 0.0.1-dev.1770759602712

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
@@ -1,44 +1,44 @@
1
- import { createDomain as x, createApi as j, createStore as q, createEffect as $, sample as F, attach as Z, combine as D, createEvent as N } from "effector";
1
+ import { createDomain as x, createApi as j, createStore as H, createEffect as $, sample as F, attach as Z, combine as V, createEvent as D } from "effector";
2
2
  import { createFactory as w, invoke as b } from "@withease/factories";
3
- import { g as K, t as ee, c as te, i as re, e as E, a as se, b as ne, d as ie } from "../experience-instance-D0bQ9DzM.js";
4
- import { f as At } from "../experience-instance-D0bQ9DzM.js";
3
+ import { g as q, t as ee, c as te, i as re, e as E, a as se, b as ne, d as ie } from "../experience-instance-D0bQ9DzM.js";
4
+ import { f as Pt } from "../experience-instance-D0bQ9DzM.js";
5
5
  import { l as k } from "../logger-C9a75KZn.js";
6
- import { c as A, l as C, s as O } from "../storage-Co_LbKr_.js";
6
+ import { c as P, l as z, s as C } from "../storage-Co_LbKr_.js";
7
7
  import { a as Rt } from "../storage-Co_LbKr_.js";
8
8
  import { g as oe } from "../id-BW-g3y32.js";
9
9
  import { i as ae } from "../object-JwZ58NOH.js";
10
- import { s as T, a as U, b as ce, c as ue, d as de } from "../supports-8YT4QKI7.js";
11
- import { e as zt, f as Ct, g as Ot, h as Mt, i as Vt, j as Dt, k as Nt } from "../supports-8YT4QKI7.js";
12
- const W = x("experience"), le = w(
10
+ import { s as N, a as T, b as ce, c as ue, d as de } from "../supports-8YT4QKI7.js";
11
+ import { e as Ot, f as zt, g as Ct, h as Mt, i as Vt, j as Dt, k as Nt } from "../supports-8YT4QKI7.js";
12
+ const K = x("experience"), le = w(
13
13
  ({ client: t, experience: e }) => {
14
- const r = W.store(e), s = j(r, {
15
- merge(p, h) {
14
+ const r = K.store(e), s = j(r, {
15
+ merge(l, h) {
16
16
  return {
17
- ...p,
17
+ ...l,
18
18
  ...h.experience
19
19
  };
20
20
  }
21
- }), i = r.map((p) => ({
22
- name: p.name,
23
- decisionLogic: p.condition ?? p.decide,
24
- targetSelectors: p.targets,
21
+ }), n = r.map((l) => ({
22
+ name: l.name,
23
+ decisionLogic: l.condition ?? l.decide,
24
+ targetSelectors: l.targets,
25
25
  initializeOpenLogic: e.initializeOpen
26
26
  })), d = t.components.listStore.map(
27
- (p) => p.find((h) => h.name === `experience:${e.id}`) || p.find((h) => h.name === "experience"),
27
+ (l) => l.find((h) => h.name === `experience:${e.id}`) || l.find((h) => h.name === "experience"),
28
28
  { skipVoid: !1 }
29
- ), o = r.map((p) => ({
30
- steps: p.steps,
31
- nodes: p.nodes,
32
- edges: p.edges,
33
- conditionals: p.conditionals
34
- })), n = r.map((p) => p.fields), l = e.actions ?? [];
29
+ ), a = r.map((l) => ({
30
+ steps: l.steps,
31
+ nodes: l.nodes,
32
+ edges: l.edges,
33
+ conditionals: l.conditionals
34
+ })), i = r.map((l) => l.fields), p = e.actions ?? [];
35
35
  return {
36
36
  id: e.id,
37
- configStore: i,
38
- treeStore: o,
39
- fieldsStore: n,
37
+ configStore: n,
38
+ treeStore: a,
39
+ fieldsStore: i,
40
40
  componentStore: d,
41
- actions: l,
41
+ actions: p,
42
42
  merge: s.merge
43
43
  };
44
44
  }
@@ -47,31 +47,31 @@ function pe(t) {
47
47
  return b(le, t);
48
48
  }
49
49
  const fe = w(({ client: t }) => {
50
- const e = W.store({}), r = j(e, {
51
- register(o, n) {
50
+ const e = K.store({}), r = j(e, {
51
+ register(a, i) {
52
52
  return {
53
- ...o,
54
- [n.id]: n
53
+ ...a,
54
+ [i.id]: i
55
55
  };
56
56
  }
57
57
  });
58
- function s(o) {
59
- const n = e.getState()[o.id];
60
- if (n) {
61
- n.merge({ experience: o, strategy: "override" });
58
+ function s(a) {
59
+ const i = e.getState()[a.id];
60
+ if (i) {
61
+ i.merge({ experience: a, strategy: "override" });
62
62
  return;
63
63
  }
64
- const l = pe({ client: t, experience: o });
65
- r.register(l);
64
+ const p = pe({ client: t, experience: a });
65
+ r.register(p);
66
66
  }
67
- const i = e.map((o) => Object.values(o));
68
- function d(o) {
69
- return e.map((n) => n[o], { skipVoid: !1 });
67
+ const n = e.map((a) => Object.values(a));
68
+ function d(a) {
69
+ return e.map((i) => i[a], { skipVoid: !1 });
70
70
  }
71
71
  return {
72
72
  register: s,
73
73
  getById: d,
74
- listStore: i
74
+ listStore: n
75
75
  };
76
76
  });
77
77
  function ge(t) {
@@ -79,27 +79,27 @@ function ge(t) {
79
79
  }
80
80
  const me = (t, e) => {
81
81
  e.register(t);
82
- }, Y = (t, e) => {
83
- const { targetSelectors: r } = e.configStore.getState(), s = K(r, e.id);
82
+ }, W = (t, e) => {
83
+ const { targetSelectors: r } = e.configStore.getState(), s = q(r, e.id);
84
84
  s.forEach(
85
- ({ elements: d }) => d.forEach((o) => ee(o, e.id))
85
+ ({ elements: d }) => d.forEach((a) => ee(a, e.id))
86
86
  ), te(s, e.id).forEach((d) => {
87
87
  t.experienceInstances.spawn(e, d);
88
88
  });
89
- }, _ = async (t) => {
89
+ }, U = async (t) => {
90
90
  await Promise.all(
91
91
  t.experiences.listStore.getState().map(async (e) => {
92
- await he(t, e) && Y(t, e);
92
+ await he(t, e) && W(t, e);
93
93
  })
94
94
  );
95
95
  }, he = async (t, e) => {
96
96
  const { decisionLogic: r, targetSelectors: s } = e.configStore.getState();
97
- return K(s, e.id).length < 1 || s.length === 0 ? !1 : r && re(r) ? await E(t, r) === !0 : !0;
97
+ return q(s, e.id).length < 1 || s.length === 0 ? !1 : r && re(r) ? await E(t, r) === !0 : !0;
98
98
  }, ye = (t, e, r) => {
99
- const s = e.name, i = e.setup(t);
100
- if (i) {
99
+ const s = e.name, n = e.setup(t);
100
+ if (n) {
101
101
  const d = r[s] ?? {};
102
- r[s] = Object.freeze({ ...d, ...i });
102
+ r[s] = Object.freeze({ ...d, ...n });
103
103
  }
104
104
  }, Se = x("component"), ve = w(
105
105
  ({ client: t, component: e, name: r }) => {
@@ -116,59 +116,59 @@ function ke(t) {
116
116
  }
117
117
  const we = w(({ client: t }) => {
118
118
  const e = Se.store({}), r = j(e, {
119
- register(o, n) {
119
+ register(a, i) {
120
120
  return {
121
- ...o,
122
- [n.name]: n
121
+ ...a,
122
+ [i.name]: i
123
123
  };
124
124
  }
125
125
  });
126
- function s(o, n) {
127
- e.getState()[o] && k(
126
+ function s(a, i) {
127
+ e.getState()[a] && k(
128
128
  "warn",
129
- `Component '${o}' already registered. Registering again will override the previous registration.`
129
+ `Component '${a}' already registered. Registering again will override the previous registration.`
130
130
  );
131
- const p = ke({ client: t, name: o, component: n });
132
- r.register(p);
131
+ const l = ke({ client: t, name: a, component: i });
132
+ r.register(l);
133
133
  }
134
- const i = e.map((o) => Object.values(o));
135
- function d(o) {
136
- return e.map((n) => n[o], { skipVoid: !1 });
134
+ const n = e.map((a) => Object.values(a));
135
+ function d(a) {
136
+ return e.map((i) => i[a], { skipVoid: !1 });
137
137
  }
138
138
  return {
139
139
  register: s,
140
140
  getByName: d,
141
- listStore: i
141
+ listStore: n
142
142
  };
143
143
  });
144
144
  function be(t) {
145
145
  return b(we, t);
146
146
  }
147
- const L = (t, e, r) => {
147
+ const _ = (t, e, r) => {
148
148
  r.register(t, e);
149
149
  }, Ie = x("framework"), Fe = w(({ client: t }) => {
150
150
  const e = Ie.store({}), r = j(e, {
151
- register(o, n) {
151
+ register(a, i) {
152
152
  return {
153
- ...o,
154
- [n.name]: n.framework
153
+ ...a,
154
+ [i.name]: i.framework
155
155
  };
156
156
  }
157
157
  });
158
- function s(o, n) {
159
- e.getState()[o] && k(
158
+ function s(a, i) {
159
+ e.getState()[a] && k(
160
160
  "warn",
161
- `Framework '${o}' already registered. Registering again will override the previous registration.`
162
- ), r.register({ name: o, framework: n });
161
+ `Framework '${a}' already registered. Registering again will override the previous registration.`
162
+ ), r.register({ name: a, framework: i });
163
163
  }
164
- const i = e.map((o) => Object.values(o));
165
- function d(o) {
166
- return e.map((n) => n[o], { skipVoid: !1 });
164
+ const n = e.map((a) => Object.values(a));
165
+ function d(a) {
166
+ return e.map((i) => i[a], { skipVoid: !1 });
167
167
  }
168
168
  return {
169
169
  register: s,
170
170
  getByName: d,
171
- listStore: i
171
+ listStore: n
172
172
  };
173
173
  });
174
174
  function xe(t) {
@@ -176,30 +176,30 @@ function xe(t) {
176
176
  }
177
177
  const je = (t, e) => {
178
178
  e.register(t.name, t);
179
- }, Ee = 6e3, Pe = A("last_ping", "global"), Ae = (t) => `${t}/api/v1/ping`, Be = async (t) => {
179
+ }, Ee = 6e3, Ae = P("last_ping", "global"), Pe = (t) => `${t}/api/v1/ping`, Be = async (t) => {
180
180
  try {
181
- const e = Date.now(), r = C.get(Pe);
181
+ const e = Date.now(), r = z.get(Ae);
182
182
  let s = 0;
183
183
  if (r.isSet() && (s = r.json() ?? 0), s && e - s < Ee)
184
184
  return !0;
185
- const i = Ae(t.apiUrl), d = {
185
+ const n = Pe(t.apiUrl), d = {
186
186
  projectId: t.projectId,
187
187
  path: window.location.pathname
188
- }, o = JSON.stringify(d), n = {
188
+ }, a = JSON.stringify(d), i = {
189
189
  "Content-Type": "application/json"
190
- }, p = document.getElementById("picked_script")?.dataset.verceltoken;
191
- p && (n["x-vercel-protection-bypass"] = p);
192
- const S = (await fetch(i, {
190
+ }, l = document.getElementById("picked_script")?.dataset.verceltoken;
191
+ l && (i["x-vercel-protection-bypass"] = l);
192
+ const v = (await fetch(n, {
193
193
  method: "POST",
194
- headers: n,
195
- body: o
194
+ headers: i,
195
+ body: a
196
196
  })).ok;
197
- return S && r.set(e), S;
197
+ return v && r.set(e), v;
198
198
  } catch (e) {
199
199
  return k("error", e), !1;
200
200
  }
201
201
  };
202
- function Q(t) {
202
+ function Y(t) {
203
203
  const e = typeof window < "u", r = {
204
204
  client: t,
205
205
  responses: t.responses.listStore.getState(),
@@ -213,143 +213,143 @@ function Q(t) {
213
213
  }
214
214
  const Re = x("predicate"), $e = w(({ client: t }) => {
215
215
  const e = Re.store({}), r = j(e, {
216
- register(n, l) {
216
+ register(i, p) {
217
217
  return {
218
- ...n,
219
- [l.name]: {
220
- name: l.name,
221
- predicate: l.predicate
218
+ ...i,
219
+ [p.name]: {
220
+ name: p.name,
221
+ predicate: p.predicate
222
222
  }
223
223
  };
224
224
  }
225
225
  });
226
- function s(n, l) {
227
- e.getState()[n] && k(
226
+ function s(i, p) {
227
+ e.getState()[i] && k(
228
228
  "warn",
229
- `Predicate '${n}' already registered. Registering again will override the previous registration.`
230
- ), r.register(Object.freeze({ name: n, predicate: l }));
229
+ `Predicate '${i}' already registered. Registering again will override the previous registration.`
230
+ ), r.register(Object.freeze({ name: i, predicate: p }));
231
231
  }
232
- const i = e.map((n) => Object.values(n));
233
- function d(n) {
234
- return e.map((l) => l[n]?.predicate, { skipVoid: !1 });
232
+ const n = e.map((i) => Object.values(i));
233
+ function d(i) {
234
+ return e.map((p) => p[i]?.predicate, { skipVoid: !1 });
235
235
  }
236
- function o(n) {
237
- const l = q(() => {
236
+ function a(i) {
237
+ const p = H(() => {
238
238
  }, {
239
239
  skipVoid: !1
240
- }), p = $(async () => {
241
- const h = d(n).getState();
240
+ }), l = $(async () => {
241
+ const h = d(i).getState();
242
242
  if (!h)
243
243
  return;
244
- const S = Q(t);
245
- return (...m) => h({ ...S, args: m });
244
+ const v = Y(t);
245
+ return (...m) => h({ ...v, args: m });
246
246
  });
247
247
  return F({
248
248
  source: { responses: t.responses.listStore, fields: t.fields.listStore },
249
- target: p
249
+ target: l
250
250
  }), F({
251
- clock: p.doneData,
251
+ clock: l.doneData,
252
252
  filter: (h) => h !== void 0,
253
- target: l
254
- }), p(), l;
253
+ target: p
254
+ }), l(), p;
255
255
  }
256
256
  return {
257
257
  register: s,
258
258
  getByName: d,
259
- listStore: i,
260
- getEvokablePredicate: o
259
+ listStore: n,
260
+ getEvokablePredicate: a
261
261
  };
262
262
  });
263
- function ze(t) {
263
+ function Oe(t) {
264
264
  return b($e, t);
265
265
  }
266
- const Ce = (t, e, r) => {
266
+ const ze = (t, e, r) => {
267
267
  r.register(t, e);
268
- }, J = x("feature"), Oe = w(({ client: t }) => {
269
- const e = J.store({}), r = J.store([]), s = j(e, {
270
- register(a, c) {
268
+ }, L = x("feature"), Ce = w(({ client: t }) => {
269
+ const e = L.store({}), r = L.store([]), s = j(e, {
270
+ register(o, c) {
271
271
  return {
272
- ...a,
272
+ ...o,
273
273
  [c.id]: c.feature
274
274
  };
275
275
  }
276
276
  });
277
- function i(a, c) {
278
- e.getState()[a] && k(
277
+ function n(o, c) {
278
+ e.getState()[o] && k(
279
279
  "warn",
280
- `Feature '${a}' already registered. Registering again will override the previous registration.`
280
+ `Feature '${o}' already registered. Registering again will override the previous registration.`
281
281
  );
282
282
  const u = {
283
- id: a,
283
+ id: o,
284
284
  feature: {
285
285
  ...c,
286
- id: a
286
+ id: o
287
287
  }
288
288
  };
289
289
  s.register(
290
290
  Object.freeze({
291
- id: a,
291
+ id: o,
292
292
  feature: u
293
293
  })
294
294
  );
295
295
  }
296
296
  const d = $(
297
297
  async ({
298
- id: a,
298
+ id: o,
299
299
  key: c,
300
300
  storage: f = "local"
301
301
  }) => {
302
- const u = A(`feature:${a}:${c}`, "global"), y = (f === "session" ? O : C).get(u).boolean();
303
- return y === null ? null : { id: a, key: c, bucket: y, storage: f };
302
+ const u = P(`feature:${o}:${c}`, "global"), y = (f === "session" ? C : z).get(u).boolean();
303
+ return y === null ? null : { id: o, key: c, bucket: y, storage: f };
304
304
  }
305
- ), o = $((a) => {
306
- if (!a)
305
+ ), a = $((o) => {
306
+ if (!o)
307
307
  return null;
308
- const c = A(`feature:${a.id}:${a.key}`, "global");
309
- (a.storage === "session" ? O : C).set(c, a.bucket);
310
- }), n = /* @__PURE__ */ new Map(), l = Z({
308
+ const c = P(`feature:${o.id}:${o.key}`, "global");
309
+ (o.storage === "session" ? C : z).set(c, o.bucket);
310
+ }), i = /* @__PURE__ */ new Map(), p = Z({
311
311
  source: { allFeaturesStore: e, resolvedFeaturesStore: r },
312
- effect: async ({ allFeaturesStore: a, resolvedFeaturesStore: c }, { id: f, decide: u, key: g }) => {
312
+ effect: async ({ allFeaturesStore: o, resolvedFeaturesStore: c }, { id: f, decide: u, key: g }) => {
313
313
  const y = c.find(
314
314
  (R) => R.id === f && R.key === g
315
315
  );
316
316
  if (y)
317
317
  return y;
318
- const I = a[f];
318
+ const I = o[f];
319
319
  if (!I)
320
320
  throw new Error(`Feature with id '${f}' not found`);
321
- const B = n.get(`${f}:${g}`);
321
+ const B = i.get(`${f}:${g}`);
322
322
  if (B !== void 0) {
323
323
  const R = await B;
324
324
  return { id: I.id, bucket: R, key: g, storage: I.feature.storage };
325
325
  }
326
- const v = u();
327
- n.set(`${f}:${g}`, v);
328
- const M = await v;
329
- return { id: I.id, bucket: M, key: g, storage: I.feature.storage };
326
+ const S = u();
327
+ i.set(`${f}:${g}`, S);
328
+ const X = await S;
329
+ return { id: I.id, bucket: X, key: g, storage: I.feature.storage };
330
330
  }
331
331
  });
332
332
  F({
333
333
  clock: s.register,
334
- fn: (a) => {
335
- const { id: c, feature: f } = a;
334
+ fn: (o) => {
335
+ const { id: c, feature: f } = o;
336
336
  return { id: c, key: f.feature.key, storage: f.feature.storage };
337
337
  },
338
338
  target: d
339
339
  }), F({
340
340
  source: e,
341
- clock: l.doneData,
342
- fn: (a, c) => {
343
- const { id: f, bucket: u, storage: g } = c, y = a[f]?.feature.key;
341
+ clock: p.doneData,
342
+ fn: (o, c) => {
343
+ const { id: f, bucket: u, storage: g } = c, y = o[f]?.feature.key;
344
344
  return y ? { key: y, id: f, bucket: u, storage: g } : null;
345
345
  },
346
- target: o
346
+ target: a
347
347
  });
348
- const p = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
348
+ const l = V({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
349
349
  ({
350
- allFeaturesStore: a,
350
+ allFeaturesStore: o,
351
351
  resolvedFeaturesStore: c
352
- }) => Object.values(a).map((f) => {
352
+ }) => Object.values(o).map((f) => {
353
353
  const u = c.find(
354
354
  (g) => g.id === f.id && g.key === f.feature.key
355
355
  );
@@ -363,49 +363,49 @@ const Ce = (t, e, r) => {
363
363
  id: f.id,
364
364
  name: f.feature.name,
365
365
  key: f.feature.key,
366
- getBucket: async () => await l(f.feature),
366
+ getBucket: async () => await p(f.feature),
367
367
  isResolved: !1
368
368
  };
369
369
  })
370
370
  );
371
371
  F({
372
- clock: l.doneData,
372
+ clock: p.doneData,
373
373
  source: { resolvedFeatures: r },
374
- filter: ({ resolvedFeatures: a }, { id: c, key: f }) => !a.some(
374
+ filter: ({ resolvedFeatures: o }, { id: c, key: f }) => !o.some(
375
375
  (g) => g.id === c && g.key === f
376
376
  ),
377
- fn: (a, c) => c,
378
- target: t.eventBus.prepend((a) => ({
377
+ fn: (o, c) => c,
378
+ target: t.eventBus.prepend((o) => ({
379
379
  type: "feature_decide",
380
- feature: a
380
+ feature: o
381
381
  }))
382
382
  }), F({
383
- clock: [d.doneData, l.doneData],
383
+ clock: [d.doneData, p.doneData],
384
384
  source: r,
385
- fn: (a, c) => !c || a.some(
385
+ fn: (o, c) => !c || o.some(
386
386
  (u) => u.id === c.id && u.key === c.key
387
- ) ? a : [...a, c],
387
+ ) ? o : [...o, c],
388
388
  target: r
389
389
  });
390
- function h(a) {
391
- return p.map((c) => c.find((f) => f.id === a));
390
+ function h(o) {
391
+ return l.map((c) => c.find((f) => f.id === o));
392
392
  }
393
- function S(a) {
394
- return e.map((c) => c[a], { skipVoid: !1 });
393
+ function v(o) {
394
+ return e.map((c) => c[o], { skipVoid: !1 });
395
395
  }
396
- function m(a) {
397
- const c = q(
396
+ function m(o) {
397
+ const c = H(
398
398
  async () => {
399
399
  },
400
400
  { skipVoid: !1 }
401
401
  ), f = $(async () => {
402
- const u = h(a).getState();
402
+ const u = h(o).getState();
403
403
  if (u)
404
404
  return async () => (await u.getBucket()).bucket;
405
405
  });
406
406
  return F({
407
407
  source: r,
408
- filter: (u) => u.some((g) => g.id === a),
408
+ filter: (u) => u.some((g) => g.id === o),
409
409
  target: f
410
410
  }), F({
411
411
  clock: f.doneData,
@@ -414,20 +414,20 @@ const Ce = (t, e, r) => {
414
414
  }), f(), c;
415
415
  }
416
416
  return {
417
- register: i,
417
+ register: n,
418
418
  getById: h,
419
- getByName: S,
420
- listStore: p,
419
+ getByName: v,
420
+ listStore: l,
421
421
  getEvokableFeature: m
422
422
  };
423
423
  });
424
424
  function Me(t) {
425
- return b(Oe, t);
425
+ return b(Ce, t);
426
426
  }
427
427
  const Ve = (t, e, r) => {
428
428
  r.register(t, e);
429
- }, P = x("history");
430
- function G(t, e) {
429
+ }, A = x("history");
430
+ function J(t, e) {
431
431
  return {
432
432
  // eslint-disable-next-line sonarjs/pseudo-random
433
433
  id: oe(`history-entry-${Date.now()}-${Math.random()}}`),
@@ -437,80 +437,80 @@ function G(t, e) {
437
437
  };
438
438
  }
439
439
  const De = w(() => {
440
- const t = P.store({ entries: [] }), e = P.event(), r = P.event(), s = P.event(), i = P.event();
441
- t.on(e, (o, n) => ({
442
- entries: [...o.entries, G(n.experienceId, n.node)]
443
- })), t.on(r, (o, n) => ({
440
+ const t = A.store({ entries: [] }), e = A.event(), r = A.event(), s = A.event(), n = A.event();
441
+ t.on(e, (a, i) => ({
442
+ entries: [...a.entries, J(i.experienceId, i.node)]
443
+ })), t.on(r, (a, i) => ({
444
444
  entries: [
445
- ...o.entries.slice(0, -1),
446
- G(n.experienceId, n.node)
445
+ ...a.entries.slice(0, -1),
446
+ J(i.experienceId, i.node)
447
447
  ]
448
- })), t.on(i, (o, n) => n);
449
- function d(o, n) {
450
- const l = { lastStepIndex: -1, secondLastStepIndex: -1 };
451
- for (let p = o.length - 1; p >= 0; p--) {
452
- const h = o[p], S = h?.node;
453
- if (!(!S || !se(S)) && !(n && h?.experienceId !== n))
454
- if (l.lastStepIndex === -1)
455
- l.lastStepIndex = p;
448
+ })), t.on(n, (a, i) => i);
449
+ function d(a, i) {
450
+ const p = { lastStepIndex: -1, secondLastStepIndex: -1 };
451
+ for (let l = a.length - 1; l >= 0; l--) {
452
+ const h = a[l], v = h?.node;
453
+ if (!(!v || !se(v)) && !(i && h?.experienceId !== i))
454
+ if (p.lastStepIndex === -1)
455
+ p.lastStepIndex = l;
456
456
  else {
457
- l.secondLastStepIndex = p;
457
+ p.secondLastStepIndex = l;
458
458
  break;
459
459
  }
460
460
  }
461
- return l;
461
+ return p;
462
462
  }
463
- return t.on(s, (o, n) => {
464
- const { secondLastStepIndex: l } = d(o.entries, n.experienceId), p = l !== -1 ? o.entries.slice(0, l + 1) : o.entries;
463
+ return t.on(s, (a, i) => {
464
+ const { secondLastStepIndex: p } = d(a.entries, i.experienceId), l = p !== -1 ? a.entries.slice(0, p + 1) : a.entries;
465
465
  return {
466
- ...o,
467
- entries: p
466
+ ...a,
467
+ entries: l
468
468
  };
469
469
  }), {
470
470
  push: e,
471
471
  replace: r,
472
472
  back: s,
473
- restore: i,
474
- entriesStore: t.map((o) => o.entries)
473
+ restore: n,
474
+ entriesStore: t.map((a) => a.entries)
475
475
  };
476
476
  });
477
477
  function Ne() {
478
478
  return b(De);
479
479
  }
480
- const Te = () => N(), Ue = x("field"), _e = w(() => {
480
+ const Te = () => D(), Ue = x("field"), _e = w(() => {
481
481
  const t = Ue.store({}), e = j(t, {
482
- register(n, l) {
482
+ register(i, p) {
483
483
  return {
484
- ...n,
485
- [l.field.id]: l.field
484
+ ...i,
485
+ [p.field.id]: p.field
486
486
  };
487
487
  }
488
488
  });
489
- function r(n) {
490
- e.register({ field: n });
489
+ function r(i) {
490
+ e.register({ field: i });
491
491
  }
492
- function s(n, l) {
493
- const p = d(n).getState();
494
- if (!p)
492
+ function s(i, p) {
493
+ const l = d(i).getState();
494
+ if (!l)
495
495
  return;
496
- const h = Object.assign({}, p, {
497
- ...l
496
+ const h = Object.assign({}, l, {
497
+ ...p
498
498
  });
499
499
  e.register({ field: { ...h } });
500
500
  }
501
- const i = t.map((n) => Object.values(n));
502
- function d(n) {
503
- return t.map((l) => l[n] || null);
501
+ const n = t.map((i) => Object.values(i));
502
+ function d(i) {
503
+ return t.map((p) => p[i] || null);
504
504
  }
505
- function o(n) {
506
- return t.map((l) => Object.values(l).find((p) => p.name === n) || null);
505
+ function a(i) {
506
+ return t.map((p) => Object.values(p).find((l) => l.name === i) || null);
507
507
  }
508
508
  return {
509
509
  register: r,
510
510
  update: s,
511
511
  getById: d,
512
- listStore: i,
513
- getByName: o
512
+ listStore: n,
513
+ getByName: a
514
514
  };
515
515
  });
516
516
  function Le() {
@@ -520,35 +520,35 @@ const Je = (t, e) => {
520
520
  e.register(t);
521
521
  }, Ge = x("action"), He = w(() => {
522
522
  const t = Ge.store({}), e = j(t, {
523
- register(o, n) {
523
+ register(a, i) {
524
524
  return {
525
- ...o,
526
- [n.name]: {
527
- name: n.name,
528
- action: n.action
525
+ ...a,
526
+ [i.name]: {
527
+ name: i.name,
528
+ action: i.action
529
529
  }
530
530
  };
531
531
  }
532
532
  });
533
- function r(o, n) {
534
- e.register({ name: o, action: n });
533
+ function r(a, i) {
534
+ e.register({ name: a, action: i });
535
535
  }
536
- const s = t.map((o) => Object.values(o));
537
- function i(o) {
538
- return t.map((n) => n[o], { skipVoid: !1 });
536
+ const s = t.map((a) => Object.values(a));
537
+ function n(a) {
538
+ return t.map((i) => i[a], { skipVoid: !1 });
539
539
  }
540
- function d(o) {
540
+ function d(a) {
541
541
  return t.map(
542
- (n) => {
543
- const l = n[o];
544
- return l ? l.action : void 0;
542
+ (i) => {
543
+ const p = i[a];
544
+ return p ? p.action : void 0;
545
545
  },
546
546
  { skipVoid: !1 }
547
547
  );
548
548
  }
549
549
  return {
550
550
  register: r,
551
- getByName: i,
551
+ getByName: n,
552
552
  listStore: s,
553
553
  getEvokableAction: d
554
554
  };
@@ -559,13 +559,13 @@ function qe() {
559
559
  const Ke = (t, e, r) => {
560
560
  r.register(t, e);
561
561
  };
562
- function V(t) {
562
+ function M(t) {
563
563
  return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
564
564
  }
565
565
  function We(t) {
566
566
  return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null;
567
567
  }
568
- function H(t) {
568
+ function G(t) {
569
569
  try {
570
570
  return JSON.stringify(t), !0;
571
571
  } catch {
@@ -573,43 +573,43 @@ function H(t) {
573
573
  }
574
574
  }
575
575
  const Ye = x("response"), Qe = w(({ client: t }) => {
576
- const e = Ye.store({}), r = N(), s = N(), i = j(e, {
577
- register(m, a) {
576
+ const e = Ye.store({}), r = D(), s = D(), n = j(e, {
577
+ register(m, o) {
578
578
  return {
579
579
  ...m,
580
- [a.fieldId]: a.response
580
+ [o.fieldId]: o.response
581
581
  };
582
582
  },
583
- registerBatch(m, a) {
583
+ registerBatch(m, o) {
584
584
  return {
585
585
  ...m,
586
- ...a
586
+ ...o
587
587
  };
588
588
  },
589
- clear(m, a) {
590
- const { [a]: c, ...f } = m;
589
+ clear(m, o) {
590
+ const { [o]: c, ...f } = m;
591
591
  return f;
592
592
  },
593
593
  clearAll() {
594
594
  return {};
595
595
  }
596
596
  });
597
- function d(m, a) {
597
+ function d(m, o) {
598
598
  if (typeof m == "string") {
599
- if (a === void 0)
599
+ if (o === void 0)
600
600
  throw new Error("Response is required when registering a single field");
601
- i.register({ fieldId: m, response: a });
601
+ n.register({ fieldId: m, response: o });
602
602
  } else
603
- i.registerBatch(m);
603
+ n.registerBatch(m);
604
604
  }
605
- async function o(m) {
606
- const a = [];
605
+ async function a(m) {
606
+ const o = [];
607
607
  return await Promise.allSettled(
608
608
  Object.entries(m).map(async ([c, f]) => {
609
609
  let u = f;
610
610
  const g = t.fields.getById(c).getState();
611
611
  if (!g) {
612
- a.push({
612
+ o.push({
613
613
  fieldId: c,
614
614
  userMessage: `Field '${c}' not found`,
615
615
  systemMessage: `No field with ID '${c}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
@@ -617,12 +617,12 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
617
617
  });
618
618
  return;
619
619
  }
620
- if (g.multiple && (typeof u == "string" || typeof u == "number" || typeof u == "boolean") && (u = [u]), g.validation && !ae(g.validation) && !V(u)) {
620
+ if (g.multiple && (typeof u == "string" || typeof u == "number" || typeof u == "boolean") && (u = [u]), g.validation && !ae(g.validation) && !M(u)) {
621
621
  const y = await E(t, g.validation, {
622
622
  $input: u
623
623
  });
624
624
  if (typeof y == "string") {
625
- a.push({
625
+ o.push({
626
626
  fieldId: c,
627
627
  userMessage: y,
628
628
  systemMessage: `Field validation resulted in an error: ${y}.`,
@@ -631,7 +631,7 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
631
631
  return;
632
632
  }
633
633
  if (y === !1) {
634
- a.push({
634
+ o.push({
635
635
  fieldId: c,
636
636
  userMessage: "This field is invalid",
637
637
  systemMessage: "Field validation resulted in an unspecified error.",
@@ -640,8 +640,8 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
640
640
  return;
641
641
  }
642
642
  }
643
- if (g.required && V(u)) {
644
- a.push({
643
+ if (g.required && M(u)) {
644
+ o.push({
645
645
  fieldId: c,
646
646
  userMessage: "This field is required",
647
647
  systemMessage: "Field is required.",
@@ -650,7 +650,7 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
650
650
  return;
651
651
  }
652
652
  if (!g.multiple && Array.isArray(u) && u.length > 1) {
653
- a.push({
653
+ o.push({
654
654
  fieldId: c,
655
655
  userMessage: "This field expects a single response",
656
656
  systemMessage: "Field expects a single response.",
@@ -658,10 +658,10 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
658
658
  });
659
659
  return;
660
660
  }
661
- if (g.type === "object" && !V(u))
661
+ if (g.type === "object" && !M(u))
662
662
  if (g.multiple) {
663
663
  if (!Array.isArray(u)) {
664
- a.push({
664
+ o.push({
665
665
  fieldId: c,
666
666
  userMessage: "This field expects multiple values",
667
667
  systemMessage: "Field expects an array of objects.",
@@ -671,7 +671,7 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
671
671
  }
672
672
  for (const y of u) {
673
673
  if (typeof y != "object" || y === null) {
674
- a.push({
674
+ o.push({
675
675
  fieldId: c,
676
676
  userMessage: "This field expects object values",
677
677
  systemMessage: "Field expects an array of objects, but received non-object value.",
@@ -679,8 +679,8 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
679
679
  });
680
680
  return;
681
681
  }
682
- if (!H(y)) {
683
- a.push({
682
+ if (!G(y)) {
683
+ o.push({
684
684
  fieldId: c,
685
685
  userMessage: "This field contains non-serializable data",
686
686
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
@@ -691,7 +691,7 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
691
691
  }
692
692
  } else {
693
693
  if (Array.isArray(u)) {
694
- a.push({
694
+ o.push({
695
695
  fieldId: c,
696
696
  userMessage: "This field expects a single value",
697
697
  systemMessage: "Field expects a single object, not an array.",
@@ -700,7 +700,7 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
700
700
  return;
701
701
  }
702
702
  if (typeof u != "object" || u === null) {
703
- a.push({
703
+ o.push({
704
704
  fieldId: c,
705
705
  userMessage: "This field expects an object value",
706
706
  systemMessage: "Field expects an object value.",
@@ -708,8 +708,8 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
708
708
  });
709
709
  return;
710
710
  }
711
- if (!H(u)) {
712
- a.push({
711
+ if (!G(u)) {
712
+ o.push({
713
713
  fieldId: c,
714
714
  userMessage: "This field contains non-serializable data",
715
715
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
@@ -718,19 +718,19 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
718
718
  return;
719
719
  }
720
720
  }
721
- if (g.options) {
721
+ if (g.options && typeof g.options != "function") {
722
722
  const y = Array.isArray(u) ? u : [u];
723
723
  if (g.type === "object") {
724
- const I = g.options.map((v) => JSON.stringify(v.value));
725
- y.every((v) => I.includes(JSON.stringify(v))) || a.push({
724
+ const I = g.options.map((S) => JSON.stringify(S.value));
725
+ y.every((S) => I.includes(JSON.stringify(S))) || o.push({
726
726
  fieldId: c,
727
727
  userMessage: "This field expects a valid option",
728
728
  systemMessage: "Field expects a valid option from the defined choices.",
729
729
  value: u
730
730
  });
731
731
  } else {
732
- const I = g.options.map((v) => v.value);
733
- y.every((v) => We(v) ? I.some((M) => M === v) : !1) || a.push({
732
+ const I = g.options.map((S) => S.value);
733
+ y.every((S) => !We(S) || S === null ? !1 : I.includes(S)) || o.push({
734
734
  fieldId: c,
735
735
  userMessage: "This field expects a valid option",
736
736
  systemMessage: `Field expects a valid option. Valid options are: ${I.join(", ")}`,
@@ -739,51 +739,51 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
739
739
  }
740
740
  }
741
741
  })
742
- ), { responsesToCommit: m, validationErrors: a };
742
+ ), { responsesToCommit: m, validationErrors: o };
743
743
  }
744
- async function n(m) {
745
- const { responsesToCommit: a, validationErrors: c } = await o(m);
746
- return c.length ? { errors: c } : (i.registerBatch(a), { errors: [] });
744
+ async function i(m) {
745
+ const { responsesToCommit: o, validationErrors: c } = await a(m);
746
+ return c.length ? { errors: c } : (n.registerBatch(o), { errors: [] });
747
747
  }
748
- const l = e.map((m) => m), p = e.map((m) => Object.keys(m).map((c) => ({
748
+ const p = e.map((m) => m), l = e.map((m) => Object.keys(m).map((c) => ({
749
749
  fieldId: c,
750
750
  value: m[c]
751
751
  })));
752
752
  function h(m) {
753
- const a = t.fields.getById(m), c = e.map((f) => f[m] || null);
754
- return D({ f: a, r: c }, ({ f, r: u }) => u || (f?.defaultValue ? f.defaultValue : null));
753
+ const o = t.fields.getById(m), c = e.map((f) => f[m] || null);
754
+ return V({ f: o, r: c }, ({ f, r: u }) => u || (f?.defaultValue ? f.defaultValue : null));
755
755
  }
756
- function S(m) {
757
- const a = t.fields.getByName(m);
758
- return D({ f: a, s: e }, ({ f: c, s: f }) => {
756
+ function v(m) {
757
+ const o = t.fields.getByName(m);
758
+ return V({ f: o, s: e }, ({ f: c, s: f }) => {
759
759
  const u = c && f[c.id] || null;
760
760
  return u || (c?.defaultValue ? c.defaultValue : null);
761
761
  });
762
762
  }
763
763
  return F({
764
764
  clock: r,
765
- target: i.clearAll
765
+ target: n.clearAll
766
766
  }), F({
767
767
  clock: s,
768
- target: i.clear
768
+ target: n.clear
769
769
  }), {
770
770
  register: d,
771
771
  clearAll: r,
772
772
  clear: s,
773
- commit: n,
774
- getResponsesToCommit: o,
775
- listStore: p,
776
- getAllStore: l,
773
+ commit: i,
774
+ getResponsesToCommit: a,
775
+ listStore: l,
776
+ getAllStore: p,
777
777
  getByFieldId: h,
778
- getByFieldName: S
778
+ getByFieldName: v
779
779
  };
780
780
  });
781
781
  function Xe(t) {
782
782
  return b(Qe, t);
783
783
  }
784
- const Ze = () => "0.0.1-dev.1770256874555";
784
+ const Ze = () => "0.0.1-dev.1770759602712";
785
785
  function et() {
786
- if (T()) {
786
+ if (N()) {
787
787
  const t = [
788
788
  document.currentScript,
789
789
  document.getElementById("picked_script"),
@@ -798,22 +798,22 @@ function et() {
798
798
  return "https://api.picked.app";
799
799
  }
800
800
  function tt() {
801
- if (!U())
801
+ if (!T())
802
802
  return {};
803
803
  const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
804
- for (const [i] of t.entries())
805
- i.startsWith("picked-") && r.add(i);
806
- for (const i of r) {
807
- const d = i.replace("picked-", "");
808
- e[d] = t.getAll(i);
804
+ for (const [n] of t.entries())
805
+ n.startsWith("picked-") && r.add(n);
806
+ for (const n of r) {
807
+ const d = n.replace("picked-", "");
808
+ e[d] = t.getAll(n);
809
809
  }
810
- const s = A("s");
810
+ const s = P("s");
811
811
  if (r.size > 0)
812
- O.set(s, e);
812
+ C.set(s, e);
813
813
  else {
814
- const i = O.get(s);
815
- if (i)
816
- return i.json() || {};
814
+ const n = C.get(s);
815
+ if (n)
816
+ return n.json() || {};
817
817
  }
818
818
  return e;
819
819
  }
@@ -823,44 +823,44 @@ function rt() {
823
823
  const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15);
824
824
  return `${t}-${e}-${r}-${s}`;
825
825
  }
826
- const st = A("session", "global"), nt = () => {
827
- const t = C.get(st);
826
+ const st = P("session", "global"), nt = () => {
827
+ const t = z.get(st);
828
828
  let e;
829
829
  t.isSet() && (e = t.json());
830
- const r = (i) => t.set({
831
- id: i.id,
832
- isUser: i.isUser,
833
- identifiers: i.identifiers
830
+ const r = (n) => t.set({
831
+ id: n.id,
832
+ isUser: n.isUser,
833
+ identifiers: n.identifiers
834
834
  }), s = {
835
835
  id: e?.id ?? rt(),
836
836
  isUser: e?.isUser ?? void 0,
837
837
  identifiers: e?.identifiers ?? void 0,
838
- setIsUser(i) {
839
- this.isUser = i, r(this);
838
+ setIsUser(n) {
839
+ this.isUser = n, r(this);
840
840
  },
841
- setIdentifier(i, d) {
842
- this.identifiers = { ...this.identifiers, [i]: d }, r(this);
841
+ setIdentifier(n, d) {
842
+ this.identifiers = { ...this.identifiers, [n]: d }, r(this);
843
843
  },
844
- removeIdentifier(i) {
844
+ removeIdentifier(n) {
845
845
  this.identifiers && (this.identifiers = Object.fromEntries(
846
- Object.entries(this.identifiers).filter(([d]) => d !== i)
846
+ Object.entries(this.identifiers).filter(([d]) => d !== n)
847
847
  ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
848
848
  }
849
849
  };
850
850
  return r(s), s;
851
851
  }, it = () => ce() ? nt() : null;
852
852
  function ot() {
853
- if (U())
853
+ if (T())
854
854
  return globalThis.window.pickedConfig;
855
855
  }
856
856
  function at() {
857
- if (!U())
857
+ if (!T())
858
858
  return;
859
859
  const t = ot(), e = t?.organizationId, r = t?.projectId;
860
860
  return e && r ? { organizationId: e, projectId: r } : void 0;
861
861
  }
862
862
  function ct() {
863
- if (!T())
863
+ if (!N())
864
864
  return;
865
865
  const t = document.getElementById("picked_script") || document.querySelector("script#picked") || // legacy support for 'cvly' script tag
866
866
  document.getElementById("cvly");
@@ -876,9 +876,9 @@ function ut(t) {
876
876
  const s = at();
877
877
  if (s)
878
878
  return s;
879
- const i = ct();
880
- if (i)
881
- return i;
879
+ const n = ct();
880
+ if (n)
881
+ return n;
882
882
  throw new Error(
883
883
  `organizationId and projectId are required. You can provide them via one of:
884
884
  (1) createClient({ organizationId, projectId }) options;
@@ -886,13 +886,13 @@ function ut(t) {
886
886
  (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
887
887
  );
888
888
  }
889
- function z(t) {
889
+ function O(t) {
890
890
  return t == null || t === "" || Number.isNaN(t);
891
891
  }
892
892
  const dt = {
893
- default: (t, e) => z(t) ? String(e ?? "") : String(t),
894
- append: (t, e) => e && !z(t) ? `${t} ${e}` : t,
895
- prepend: (t, e) => e && !z(t) ? `${e} ${t}` : t,
893
+ default: (t, e) => O(t) ? String(e ?? "") : String(t),
894
+ append: (t, e) => e && !O(t) ? `${t} ${e}` : t,
895
+ prepend: (t, e) => e && !O(t) ? `${e} ${t}` : t,
896
896
  upper: (t) => typeof t == "string" ? t.toUpperCase() : t,
897
897
  lower: (t) => typeof t == "string" ? t.toLowerCase() : t,
898
898
  capitalize: (t) => typeof t == "string" ? t.charAt(0).toUpperCase() + t.slice(1) : t,
@@ -903,7 +903,7 @@ const dt = {
903
903
  if (Array.isArray(t))
904
904
  return e.format(t.map(String));
905
905
  if (t instanceof Map) {
906
- const r = Array.from(t.entries()).map(([s, i]) => `${s}: ${i}`);
906
+ const r = Array.from(t.entries()).map(([s, n]) => `${s}: ${n}`);
907
907
  return e.format(r);
908
908
  }
909
909
  return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
@@ -923,27 +923,27 @@ function pt(t, e) {
923
923
  }
924
924
  function ft(t, e) {
925
925
  const r = t.split("|").map((d) => d.trim()), s = r.shift() ?? "";
926
- let i = pt(s, e);
926
+ let n = pt(s, e);
927
927
  for (const d of r) {
928
- const [o, ...n] = d.split(":"), l = o?.trim() ?? "", p = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = dt[l];
929
- h && (i = h(i, p));
928
+ const [a, ...i] = d.split(":"), p = a?.trim() ?? "", l = i.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = dt[p];
929
+ h && (n = h(n, l));
930
930
  }
931
- return z(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
931
+ return O(n) ? "" : typeof n == "object" ? JSON.stringify(n) : String(n);
932
932
  }
933
933
  function gt(t, e) {
934
934
  let r = "", s = 0;
935
935
  for (; s < t.length; )
936
936
  if (t[s] === "{" && t[s + 1] === "{") {
937
937
  s += 2;
938
- let i = "";
938
+ let n = "";
939
939
  for (; s < t.length; ) {
940
940
  if (t[s] === "}" && t[s + 1] === "}") {
941
941
  s += 2;
942
942
  break;
943
943
  }
944
- i += t[s++];
944
+ n += t[s++];
945
945
  }
946
- r += ft(i.trim(), e);
946
+ r += ft(n.trim(), e);
947
947
  } else
948
948
  r += t[s++];
949
949
  return r;
@@ -967,7 +967,7 @@ class mt {
967
967
  experienceInstances = ne({ client: this });
968
968
  experiences = ge({ client: this });
969
969
  frameworks = xe({ client: this });
970
- predicates = ze({ client: this });
970
+ predicates = Oe({ client: this });
971
971
  features = Me({ client: this });
972
972
  responses = Xe({ client: this });
973
973
  fields = Le();
@@ -977,57 +977,55 @@ class mt {
977
977
  const { organizationId: r, projectId: s } = ut(e);
978
978
  this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || et(), this.session = it(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: Ze() }), k("info", "Picked client initialized.");
979
979
  }
980
- start() {
980
+ start = () => {
981
981
  Be(this), (async () => {
982
- if (!T())
982
+ if (!N())
983
983
  return;
984
984
  let r;
985
985
  typeof this.precondition > "u" ? r = !0 : typeof this.precondition == "boolean" ? r = this.precondition : r = await E(this, this.precondition) === !0;
986
986
  let s;
987
987
  r && (this.condition === void 0 ? s = !0 : typeof this.condition == "boolean" ? s = this.condition : s = await E(this, this.condition) === !0);
988
- const i = r && s === !0;
988
+ const n = r && s === !0;
989
989
  if (typeof s == "boolean" && this.session) {
990
990
  const d = s;
991
991
  this.session.setIsUser(d), this.eventBus({ type: "user_decide", value: d });
992
992
  }
993
- this.eventBus({ type: "initialize" }), document.body && i && _(this), await ie(), i && _(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
993
+ this.eventBus({ type: "initialize" }), document.body && n && U(this), await ie(), n && U(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
994
994
  })();
995
- }
996
- registerFramework(e) {
995
+ };
996
+ registerFramework = (e) => {
997
997
  je(e, this.frameworks);
998
- }
999
- registerComponent(e, r) {
1000
- L(e, r, this.components);
1001
- }
1002
- registerPlugin(e) {
998
+ };
999
+ registerComponent = (e, r) => {
1000
+ _(e, r, this.components);
1001
+ };
1002
+ registerPlugin = (e) => {
1003
1003
  ye(this, e, this.plugins);
1004
- }
1005
- registerFeature(e, r) {
1004
+ };
1005
+ registerFeature = (e, r) => {
1006
1006
  Ve(e, r, this.features);
1007
- }
1008
- registerPredicate(e, r) {
1009
- Ce(e, r, this.predicates);
1010
- }
1011
- registerField(e) {
1007
+ };
1008
+ registerPredicate = (e, r) => {
1009
+ ze(e, r, this.predicates);
1010
+ };
1011
+ registerField = (e) => {
1012
1012
  Je(e, this.fields);
1013
- }
1014
- registerAction(e, r) {
1013
+ };
1014
+ registerAction = (e, r) => {
1015
1015
  Ke(e, r, this.actions);
1016
- }
1017
- registerExperience(e) {
1018
- e.component && L(`experience:${e.id}`, e.component, this.components), me(e, this.experiences);
1019
- }
1020
- getStateSnapshot() {
1021
- return Q(this);
1022
- }
1023
- async launchExperienceById(e) {
1016
+ };
1017
+ registerExperience = (e) => {
1018
+ e.component && _(`experience:${e.id}`, e.component, this.components), me(e, this.experiences);
1019
+ };
1020
+ getStateSnapshot = () => Y(this);
1021
+ launchExperienceById = async (e) => {
1024
1022
  const r = this.experiences.getById(e).getState();
1025
1023
  if (!r) {
1026
1024
  k("warn", `Experience with id '${e}' not found.`);
1027
1025
  return;
1028
1026
  }
1029
- Y(this, r);
1030
- }
1027
+ W(this, r);
1028
+ };
1031
1029
  // private async fetchProject() {
1032
1030
  // if (this.project) {
1033
1031
  // return
@@ -1056,14 +1054,14 @@ class mt {
1056
1054
  setupFeatures() {
1057
1055
  const e = this.options.features;
1058
1056
  e && (Object.entries(e).forEach(([r, s]) => {
1059
- const i = typeof s == "function" ? s() : s;
1060
- this.registerFeature(r, i);
1057
+ const n = typeof s == "function" ? s() : s;
1058
+ this.registerFeature(r, n);
1061
1059
  }), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
1062
1060
  try {
1063
- const [s, i] = r.split(":");
1064
- if (!s || !i)
1061
+ const [s, n] = r.split(":");
1062
+ if (!s || !n)
1065
1063
  return;
1066
- let d = i;
1064
+ let d = n;
1067
1065
  d === "true" && (d = !0), d === "false" && (d = !1), this.registerFeature(s, {
1068
1066
  key: `${d}`,
1069
1067
  // use the assigned bucket value as the key
@@ -1096,9 +1094,7 @@ class mt {
1096
1094
  this.registerAction(r, s);
1097
1095
  });
1098
1096
  }
1099
- getPluginConfig(e) {
1100
- return this.plugins[e] ?? {};
1101
- }
1097
+ getPluginConfig = (e) => this.plugins[e] ?? {};
1102
1098
  /**
1103
1099
  * Interpolates a template string using values from the client's response store and/or a provided context.
1104
1100
  * Supports dot-notation, modifiers, and executing functions found in the context.
@@ -1142,30 +1138,40 @@ class mt {
1142
1138
  * // => "Fruits: apple, banana, and cherry"
1143
1139
  */
1144
1140
  renderString = (e, r) => {
1145
- const s = this.responses.listStore.getState().reduce((i, d) => (i[d.fieldId] = d.value, i), {});
1141
+ const s = this.responses.listStore.getState().reduce((n, d) => (n[d.fieldId] = d.value, n), {});
1146
1142
  return gt(e, {
1147
1143
  ...r,
1148
1144
  responses: s
1149
1145
  });
1150
1146
  };
1151
1147
  }
1152
- function X(t) {
1153
- return t.options?.some((e) => "condition" in e) ?? !1;
1148
+ function Q(t) {
1149
+ return Array.isArray(t.options) && t.options.some((e) => "condition" in e);
1154
1150
  }
1155
1151
  function ht(t) {
1156
- return t.some((e) => e.condition || X(e));
1152
+ return t.some((e) => e.condition || Q(e));
1157
1153
  }
1158
1154
  async function xt(t, e) {
1159
- return e.length === 0 || !ht(e) ? e : (await Promise.all(
1155
+ return e.length === 0 ? e : (await Promise.all(
1160
1156
  e.map(async (s) => {
1161
- if (!(s.condition ? await E(t, s.condition) : !0))
1157
+ let n = s;
1158
+ if (s.options && typeof s.options == "function")
1159
+ try {
1160
+ const l = s.options, h = await Promise.resolve(l());
1161
+ n = { ...s, options: h };
1162
+ } catch {
1163
+ n = { ...s, options: null };
1164
+ }
1165
+ if (!ht([n]))
1166
+ return n;
1167
+ if (!(n.condition ? await E(t, n.condition) : !0))
1162
1168
  return null;
1163
- if (!s.options || !X(s))
1164
- return s;
1165
- const o = (await Promise.all(
1166
- s.options.map(async (l) => l.condition ? await E(t, l.condition) ? l : null : l)
1169
+ if (!n.options || !Q(n) || !Array.isArray(n.options))
1170
+ return n;
1171
+ const i = (await Promise.all(
1172
+ n.options.map(async (l) => l.condition ? await E(t, l.condition) ? l : null : l)
1167
1173
  )).filter((l) => l !== null);
1168
- return o.length === s.options.length ? s : o.length === 0 ? null : { ...s, options: o };
1174
+ return i.length === n.options.length ? n : i.length === 0 ? null : { ...n, options: i };
1169
1175
  })
1170
1176
  )).filter((s) => s !== null);
1171
1177
  }
@@ -1176,23 +1182,23 @@ const jt = (t) => {
1176
1182
  export {
1177
1183
  mt as Picked,
1178
1184
  jt as createClient,
1179
- A as createStorageKey,
1185
+ P as createStorageKey,
1180
1186
  E as evaluateRuleLogic,
1181
1187
  ot as getPickedConfig,
1182
1188
  xt as getStepFields,
1183
- At as isPickedRoot,
1184
- C as localStore,
1185
- O as sessionStore,
1189
+ Pt as isPickedRoot,
1190
+ z as localStore,
1191
+ C as sessionStore,
1186
1192
  Rt as subscribe,
1187
- zt as supportsCookies,
1193
+ Ot as supportsCookies,
1188
1194
  ue as supportsCryptoRandomUUID,
1189
- T as supportsDocument,
1190
- Ct as supportsHistory,
1191
- Ot as supportsIntersectionObserver,
1195
+ N as supportsDocument,
1196
+ zt as supportsHistory,
1197
+ Ct as supportsIntersectionObserver,
1192
1198
  ce as supportsLocalStorage,
1193
1199
  Mt as supportsLocation,
1194
1200
  Vt as supportsSessionStorage,
1195
1201
  Dt as supportsShadowRoot,
1196
1202
  Nt as supportsWebComponents,
1197
- U as supportsWindow
1203
+ T as supportsWindow
1198
1204
  };