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

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