@picked/client 0.0.1-dev.1772073931707 → 0.0.1-dev.1772083499814

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/api-CbXfbi_s.js +19 -0
  2. package/dist/api-DzSCgBQ2.cjs +1 -0
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/plugins/create-experience/index.js +1 -1
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -0
  6. package/dist/cjs/plugins/web-components/index.js +1 -1
  7. package/dist/cjs/server/index.js +1 -1
  8. package/dist/esm/index.js +662 -712
  9. package/dist/esm/plugins/create-experience/index.js +228 -194
  10. package/dist/esm/plugins/dynamic-experiences/index.js +115 -0
  11. package/dist/esm/plugins/web-components/index.js +5 -5
  12. package/dist/esm/server/index.js +1 -1
  13. package/dist/experience-instance-BsXG5XJ4.cjs +1 -0
  14. package/dist/{experience-instance-CLR80xop.js → experience-instance-fvSEb72i.js} +358 -358
  15. package/dist/types/client.d.ts +10 -12
  16. package/dist/types/client.d.ts.map +1 -1
  17. package/dist/types/entities/action/action.d.ts +2 -5
  18. package/dist/types/entities/action/action.d.ts.map +1 -1
  19. package/dist/types/entities/component/component.d.ts +2 -1
  20. package/dist/types/entities/component/component.d.ts.map +1 -1
  21. package/dist/types/entities/component/lazyComponent.d.ts +11 -0
  22. package/dist/types/entities/component/lazyComponent.d.ts.map +1 -0
  23. package/dist/types/entities/experience/experience.d.ts +49 -5
  24. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  25. package/dist/types/entities/experience-instance/experience-instance.d.ts +4 -3
  26. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  27. package/dist/types/entities/field/field.d.ts +14 -51
  28. package/dist/types/entities/field/field.d.ts.map +1 -1
  29. package/dist/types/entities/plugin/plugin.d.ts +4 -1
  30. package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
  31. package/dist/types/entities/response/response.d.ts.map +1 -1
  32. package/dist/types/exports.d.ts +2 -0
  33. package/dist/types/exports.d.ts.map +1 -1
  34. package/dist/types/index.d.ts +1 -1
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/dist/types/picked.d.ts +48 -18
  37. package/dist/types/picked.d.ts.map +1 -1
  38. package/dist/types/ping.d.ts.map +1 -1
  39. package/dist/types/plugins/create-experience/create-experience.d.ts +23 -26
  40. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  41. package/dist/types/plugins/dynamic-experiences/hash.d.ts +18 -0
  42. package/dist/types/plugins/dynamic-experiences/hash.d.ts.map +1 -0
  43. package/dist/types/plugins/dynamic-experiences/index.d.ts +3 -0
  44. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -0
  45. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +23 -0
  46. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -0
  47. package/dist/types/plugins/dynamic-experiences/types.d.ts +15 -0
  48. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -0
  49. package/dist/types/utils/api.d.ts +3 -0
  50. package/dist/types/utils/api.d.ts.map +1 -0
  51. package/dist/types/utils/get-step-fields.d.ts +1 -2
  52. package/dist/types/utils/get-step-fields.d.ts.map +1 -1
  53. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  54. package/package.json +7 -1
  55. package/dist/experience-instance-5rr_D--s.cjs +0 -1
package/dist/esm/index.js CHANGED
@@ -1,202 +1,233 @@
1
- import { createDomain as x, createApi as j, createStore as U, createEffect as C, sample as w, attach as te, combine as E, createEvent as R } from "effector";
2
- import { createFactory as I, invoke as F } from "@withease/factories";
3
- import { g as W, t as re, c as ne, i as se, e as A, a as ie, b as oe, d as ae } from "../experience-instance-CLR80xop.js";
4
- import { f as $t } from "../experience-instance-CLR80xop.js";
5
- import { l as b } from "../logger-C9a75KZn.js";
6
- import { c as B, l as O, s as D } from "../storage-Co_LbKr_.js";
7
- import { a as Ct } from "../storage-Co_LbKr_.js";
1
+ import { createDomain as x, createApi as j, attach as U, createStore as T, createEffect as R, sample as k, combine as D, createEvent as V } from "effector";
2
+ import { createFactory as b, invoke as I } from "@withease/factories";
3
+ import { g as W, t as te, c as re, i as se, e as P, a as ne, b as ie, d as oe } from "../experience-instance-fvSEb72i.js";
4
+ import { f as zt } from "../experience-instance-fvSEb72i.js";
5
+ import { l as w } from "../logger-C9a75KZn.js";
6
+ import { c as A, l as C, s as M } from "../storage-Co_LbKr_.js";
7
+ import { a as Mt } from "../storage-Co_LbKr_.js";
8
+ import { p as ae } from "../api-CbXfbi_s.js";
8
9
  import { g as ce } from "../id-BW-g3y32.js";
9
10
  import { i as ue } from "../object-JwZ58NOH.js";
10
- import { s as _, a as L, b as le, c as de, d as pe } from "../supports-8YT4QKI7.js";
11
- import { e as Ot, f as Dt, g as Vt, h as Nt, i as Tt, j as Ut, k as _t } from "../supports-8YT4QKI7.js";
12
- const Y = x("experience"), fe = I(
11
+ import { s as L, a as _, b as de, c as le, d as pe } from "../supports-8YT4QKI7.js";
12
+ import { e as Ut, f as Dt, g as Vt, h as Nt, i as Tt, j as Lt, k as _t } from "../supports-8YT4QKI7.js";
13
+ const Y = x("experience"), fe = b(
13
14
  ({ client: t, experience: e }) => {
14
- const r = Y.store(e), n = j(r, {
15
- merge(p, y) {
15
+ const r = Y.store(e), s = j(r, {
16
+ merge(u, g) {
16
17
  return {
17
- ...p,
18
- ...y.experience
18
+ ...u,
19
+ ...g.experience
19
20
  };
20
21
  }
21
- }), i = r.map((p) => ({
22
- name: p.name,
23
- decisionLogic: p.condition ?? p.decide,
24
- targetSelectors: p.targets,
22
+ }), i = r.map((u) => ({
23
+ name: u.name,
24
+ decisionLogic: u.condition ?? u.decide,
25
+ targetSelectors: u.targets,
25
26
  initializeOpenLogic: e.initializeOpen
26
- })), d = t.components.listStore.map(
27
- (p) => p.find((y) => y.name === `experience:${e.id}`) || p.find((y) => y.name === "experience"),
27
+ })), l = t.components.listStore.map(
28
+ (u) => u.find((g) => g.name === `experience:${e.id}`) || u.find((g) => g.name === "experience"),
28
29
  { skipVoid: !1 }
29
- ), l = r.map((p) => ({
30
- steps: p.steps,
31
- nodes: p.nodes,
32
- edges: p.edges,
33
- conditionals: p.conditionals
34
- })), c = r.map((p) => p.fields), g = e.actions ?? [];
30
+ ), a = r.map((u) => ({
31
+ steps: u.steps,
32
+ nodes: u.nodes,
33
+ edges: u.edges,
34
+ conditionals: u.conditionals
35
+ })), n = r.map((u) => u.fields), p = e.actions ?? [];
35
36
  return {
36
37
  id: e.id,
37
38
  configStore: i,
38
- treeStore: l,
39
- fieldsStore: c,
40
- componentStore: d,
41
- actions: g,
42
- merge: n.merge
39
+ treeStore: a,
40
+ fieldsStore: n,
41
+ componentStore: l,
42
+ actions: p,
43
+ merge: s.merge
43
44
  };
44
45
  }
45
46
  );
46
47
  function ge(t) {
47
- return F(fe, t);
48
+ return I(fe, t);
48
49
  }
49
- const me = I(({ client: t }) => {
50
+ const me = b(({ client: t }) => {
50
51
  const e = Y.store({}), r = j(e, {
51
- register(l, c) {
52
+ register(u, g) {
52
53
  return {
53
- ...l,
54
- [c.id]: c
54
+ ...u,
55
+ [g.id]: g
55
56
  };
56
57
  }
57
58
  });
58
- function n(l) {
59
- const c = e.getState()[l.id];
60
- if (c) {
61
- c.merge({ experience: l, strategy: "override" });
59
+ function s(u) {
60
+ const g = e.getState()[u.id];
61
+ if (g) {
62
+ g.merge({ experience: u, strategy: "override" });
62
63
  return;
63
64
  }
64
- const g = ge({ client: t, experience: l });
65
- r.register(g);
65
+ const S = ge({ client: t, experience: u });
66
+ r.register(S);
66
67
  }
67
- const i = e.map((l) => Object.values(l));
68
- function d(l) {
69
- return e.map((c) => c[l], { skipVoid: !1 });
68
+ const i = e.map((u) => Object.values(u));
69
+ function l(u) {
70
+ return e.map((g) => g[u], { skipVoid: !1 });
70
71
  }
72
+ const a = l, n = U({
73
+ source: e,
74
+ effect: async (u, { id: g, options: S }) => {
75
+ const m = u[g];
76
+ if (!m) {
77
+ w("warn", `Experience with id '${g}' not found.`);
78
+ return;
79
+ }
80
+ if (S?.bypassCondition) {
81
+ N(t, m, S);
82
+ return;
83
+ }
84
+ await Q(t, m) && N(t, m, S);
85
+ }
86
+ }), p = U({
87
+ source: t.experienceInstances.listStore,
88
+ effect: (u, g) => {
89
+ const S = u.filter((m) => m.experienceId === g);
90
+ if (S.length > 0)
91
+ for (const m of S)
92
+ m.open();
93
+ else
94
+ n({ id: g, options: { initialiseOpen: !0 } });
95
+ }
96
+ });
71
97
  return {
72
- register: n,
73
- getById: d,
98
+ /** Registers an experience in the index. If an experience with the same ID already exists, it is merged. */
99
+ register: s,
100
+ /** Returns a derived store for an experience by its ID. The store value is `undefined` when no match exists. */
101
+ get: l,
102
+ /** @deprecated Use `experiences.get(id)` instead. */
103
+ getById: a,
104
+ /** Effector effect that launches an experience by ID, creating instances for each DOM target. */
105
+ launch: n,
106
+ /** Effector effect that opens an experience's existing instances, or launches it with `initialiseOpen` if none exist. */
107
+ open: p,
108
+ /** Derived store containing all registered experiences as an array. */
74
109
  listStore: i
75
110
  };
76
111
  });
77
- function ye(t) {
78
- return F(me, t);
112
+ function he(t) {
113
+ return I(me, t);
79
114
  }
80
- const he = (t, e) => {
115
+ const ye = (t, e) => {
81
116
  e.register(t);
82
- }, Q = (t, e) => {
83
- const { targetSelectors: r } = e.configStore.getState(), n = W(r, e.id);
84
- n.forEach(
85
- ({ elements: d }) => d.forEach((l) => re(l, e.id))
86
- ), ne(n, e.id).forEach((d) => {
87
- t.experienceInstances.spawn(e, d);
117
+ }, N = (t, e, r) => {
118
+ const { targetSelectors: s } = e.configStore.getState(), i = W(s, e.id);
119
+ i.forEach(
120
+ ({ elements: a }) => a.forEach((n) => te(n, e.id))
121
+ ), re(i, e.id).forEach((a) => {
122
+ r ? t.experienceInstances.spawn(e, a, r) : t.experienceInstances.spawn(e, a);
88
123
  });
89
- }, J = async (t) => {
124
+ }, H = async (t) => {
90
125
  await Promise.all(
91
126
  t.experiences.listStore.getState().map(async (e) => {
92
- await ve(t, e) && Q(t, e);
127
+ await Q(t, e) && N(t, e);
93
128
  })
94
129
  );
95
- }, ve = async (t, e) => {
96
- const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
97
- return W(n, e.id).length < 1 || n.length === 0 ? !1 : r && se(r) ? await A(t, r) === !0 : !0;
130
+ }, Q = async (t, e) => {
131
+ if (!t.session?.isUser)
132
+ return !1;
133
+ const { decisionLogic: r, targetSelectors: s } = e.configStore.getState();
134
+ return W(s, e.id).length < 1 || s.length === 0 ? !1 : r && se(r) ? await P(t, r) === !0 : !0;
98
135
  }, Se = (t, e, r) => {
99
- const n = e.name, i = e.setup(t);
136
+ const s = e.name, i = e.setup(t);
100
137
  if (i) {
101
- const d = r[n] ?? {};
102
- r[n] = Object.freeze({ ...d, ...i });
138
+ const l = r[s] ?? {};
139
+ r[s] = Object.freeze({ ...l, ...i });
103
140
  }
104
- }, ke = x("component"), we = I(
141
+ }, ve = x("component"), ke = b(
105
142
  ({ client: t, component: e, name: r }) => {
106
- const n = t.frameworks.getByName(e.frameworkName);
143
+ const s = t.frameworks.getByName(e.frameworkName);
107
144
  return {
108
145
  name: r,
109
146
  component: e,
110
- frameworkStore: n
147
+ frameworkStore: s
111
148
  };
112
149
  }
113
150
  );
114
- function be(t) {
115
- return F(we, t);
151
+ function we(t) {
152
+ return I(ke, t);
116
153
  }
117
- const Ie = I(({ client: t }) => {
118
- const e = ke.store({}), r = j(e, {
119
- register(l, c) {
154
+ const be = b(({ client: t }) => {
155
+ const e = ve.store({}), r = j(e, {
156
+ register(a, n) {
120
157
  return {
121
- ...l,
122
- [c.name]: c
158
+ ...a,
159
+ [n.name]: n
123
160
  };
124
161
  }
125
162
  });
126
- function n(l, c) {
127
- e.getState()[l] && b(
163
+ function s(a, n) {
164
+ e.getState()[a] && w(
128
165
  "warn",
129
- `Component '${l}' already registered. Registering again will override the previous registration.`
166
+ `Component '${a}' already registered. Registering again will override the previous registration.`
130
167
  );
131
- const p = be({ client: t, name: l, component: c });
132
- r.register(p);
168
+ const u = we({ client: t, name: a, component: n });
169
+ r.register(u);
133
170
  }
134
- const i = e.map((l) => Object.values(l));
135
- function d(l) {
136
- return e.map((c) => c[l], { skipVoid: !1 });
171
+ const i = e.map((a) => Object.values(a));
172
+ function l(a) {
173
+ return e.map((n) => n[a], { skipVoid: !1 });
137
174
  }
138
175
  return {
139
- register: n,
140
- getByName: d,
176
+ register: s,
177
+ getByName: l,
141
178
  listStore: i
142
179
  };
143
180
  });
144
- function Fe(t) {
145
- return F(Ie, t);
181
+ function Ie(t) {
182
+ return I(be, t);
146
183
  }
147
- const H = (t, e, r) => {
184
+ const G = (t, e, r) => {
148
185
  r.register(t, e);
149
- }, xe = x("framework"), je = I(({ client: t }) => {
150
- const e = xe.store({}), r = j(e, {
151
- register(l, c) {
186
+ }, Fe = x("framework"), xe = b(({ client: t }) => {
187
+ const e = Fe.store({}), r = j(e, {
188
+ register(a, n) {
152
189
  return {
153
- ...l,
154
- [c.name]: c.framework
190
+ ...a,
191
+ [n.name]: n.framework
155
192
  };
156
193
  }
157
194
  });
158
- function n(l, c) {
159
- e.getState()[l] && b(
195
+ function s(a, n) {
196
+ e.getState()[a] && w(
160
197
  "warn",
161
- `Framework '${l}' already registered. Registering again will override the previous registration.`
162
- ), r.register({ name: l, framework: c });
198
+ `Framework '${a}' already registered. Registering again will override the previous registration.`
199
+ ), r.register({ name: a, framework: n });
163
200
  }
164
- const i = e.map((l) => Object.values(l));
165
- function d(l) {
166
- return e.map((c) => c[l], { skipVoid: !1 });
201
+ const i = e.map((a) => Object.values(a));
202
+ function l(a) {
203
+ return e.map((n) => n[a], { skipVoid: !1 });
167
204
  }
168
205
  return {
169
- register: n,
170
- getByName: d,
206
+ register: s,
207
+ getByName: l,
171
208
  listStore: i
172
209
  };
173
210
  });
174
- function Ae(t) {
175
- return F(je, t);
211
+ function je(t) {
212
+ return I(xe, t);
176
213
  }
177
214
  const Ee = (t, e) => {
178
215
  e.register(t.name, t);
179
- }, Pe = 6e3, Re = B("last_ping", "global"), Be = (t) => `${t}/api/v1/ping`, $e = async (t) => {
216
+ }, Pe = 6e3, Ae = A("last_ping", "global"), $e = async (t) => {
180
217
  try {
181
- const e = Date.now(), r = O.get(Re);
182
- let n = 0;
183
- if (r.isSet() && (n = r.json() ?? 0), n && e - n < Pe)
218
+ const e = Date.now(), r = C.get(Ae);
219
+ let s = 0;
220
+ if (r.isSet() && (s = r.json() ?? 0), s && e - s < Pe)
184
221
  return !0;
185
- const i = Be(t.apiUrl), d = {
222
+ const i = {
186
223
  projectId: t.projectId,
187
224
  path: window.location.pathname
188
- }, l = JSON.stringify(d), c = {
189
- "Content-Type": "application/json"
190
- }, p = document.getElementById("picked_script")?.dataset.verceltoken;
191
- p && (c["x-vercel-protection-bypass"] = p);
192
- const v = (await fetch(i, {
193
- method: "POST",
194
- headers: c,
195
- body: l
196
- })).ok;
197
- return v && r.set(e), v;
225
+ }, l = {}, n = document.getElementById("picked_script")?.dataset.verceltoken;
226
+ n && (l["x-vercel-protection-bypass"] = n);
227
+ const u = (await ae(t.apiUrl, "ping", i, l)).ok;
228
+ return u && r.set(e), u;
198
229
  } catch (e) {
199
- return b("error", e), !1;
230
+ return w("error", e), !1;
200
231
  }
201
232
  };
202
233
  function X(t) {
@@ -211,222 +242,222 @@ function X(t) {
211
242
  };
212
243
  return Object.freeze(r);
213
244
  }
214
- const ze = x("predicate"), Ce = I(({ client: t }) => {
215
- const e = ze.store({}), r = j(e, {
216
- register(c, g) {
245
+ const Be = x("predicate"), Re = b(({ client: t }) => {
246
+ const e = Be.store({}), r = j(e, {
247
+ register(n, p) {
217
248
  return {
218
- ...c,
219
- [g.name]: {
220
- name: g.name,
221
- predicate: g.predicate
249
+ ...n,
250
+ [p.name]: {
251
+ name: p.name,
252
+ predicate: p.predicate
222
253
  }
223
254
  };
224
255
  }
225
256
  });
226
- function n(c, g) {
227
- e.getState()[c] && b(
257
+ function s(n, p) {
258
+ e.getState()[n] && w(
228
259
  "warn",
229
- `Predicate '${c}' already registered. Registering again will override the previous registration.`
230
- ), r.register(Object.freeze({ name: c, predicate: g }));
260
+ `Predicate '${n}' already registered. Registering again will override the previous registration.`
261
+ ), r.register(Object.freeze({ name: n, predicate: p }));
231
262
  }
232
- const i = e.map((c) => Object.values(c));
233
- function d(c) {
234
- return e.map((g) => g[c]?.predicate, { skipVoid: !1 });
263
+ const i = e.map((n) => Object.values(n));
264
+ function l(n) {
265
+ return e.map((p) => p[n]?.predicate, { skipVoid: !1 });
235
266
  }
236
- function l(c) {
237
- const g = U(() => {
267
+ function a(n) {
268
+ const p = T(() => {
238
269
  }, {
239
270
  skipVoid: !1
240
- }), p = C(async () => {
241
- const y = d(c).getState();
242
- if (!y)
271
+ }), u = R(async () => {
272
+ const g = l(n).getState();
273
+ if (!g)
243
274
  return;
244
- const v = X(t);
245
- return (...m) => y({ ...v, args: m });
275
+ const S = X(t);
276
+ return (...m) => g({ ...S, args: m });
246
277
  });
247
- return w({
278
+ return k({
248
279
  source: { responses: t.responses.listStore, fields: t.fields.listStore },
280
+ target: u
281
+ }), k({
282
+ clock: u.doneData,
283
+ filter: (g) => g !== void 0,
249
284
  target: p
250
- }), w({
251
- clock: p.doneData,
252
- filter: (y) => y !== void 0,
253
- target: g
254
- }), p(), g;
285
+ }), u(), p;
255
286
  }
256
287
  return {
257
- register: n,
258
- getByName: d,
288
+ register: s,
289
+ getByName: l,
259
290
  listStore: i,
260
- getEvokablePredicate: l
291
+ getEvokablePredicate: a
261
292
  };
262
293
  });
263
- function Me(t) {
264
- return F(Ce, t);
294
+ function ze(t) {
295
+ return I(Re, t);
265
296
  }
266
- const Oe = (t, e, r) => {
297
+ const Ce = (t, e, r) => {
267
298
  r.register(t, e);
268
- }, G = x("feature"), De = I(({ client: t }) => {
269
- const e = G.store({}), r = G.store([]), n = j(e, {
270
- register(u, s) {
299
+ }, J = x("feature"), Me = b(({ client: t }) => {
300
+ const e = J.store({}), r = J.store([]), s = j(e, {
301
+ register(o, c) {
271
302
  return {
272
- ...u,
273
- [s.id]: s.feature
303
+ ...o,
304
+ [c.id]: c.feature
274
305
  };
275
306
  }
276
307
  });
277
- function i(u, s) {
278
- e.getState()[u] && b(
308
+ function i(o, c) {
309
+ e.getState()[o] && w(
279
310
  "warn",
280
- `Feature '${u}' already registered. Registering again will override the previous registration.`
311
+ `Feature '${o}' already registered. Registering again will override the previous registration.`
281
312
  );
282
- const a = {
283
- id: u,
313
+ const d = {
314
+ id: o,
284
315
  feature: {
285
- ...s,
286
- id: u
316
+ ...c,
317
+ id: o
287
318
  }
288
319
  };
289
- n.register(
320
+ s.register(
290
321
  Object.freeze({
291
- id: u,
292
- feature: a
322
+ id: o,
323
+ feature: d
293
324
  })
294
325
  );
295
326
  }
296
- const d = C(
327
+ const l = R(
297
328
  async ({
298
- id: u,
299
- key: s,
300
- storage: o = "local"
329
+ id: o,
330
+ key: c,
331
+ storage: f = "local"
301
332
  }) => {
302
- const a = B(`feature:${u}:${s}`, "global"), h = (o === "session" ? D : O).get(a).boolean();
303
- return h === null ? null : { id: u, key: s, bucket: h, storage: o };
333
+ const d = A(`feature:${o}:${c}`, "global"), y = (f === "session" ? M : C).get(d).boolean();
334
+ return y === null ? null : { id: o, key: c, bucket: y, storage: f };
304
335
  }
305
- ), l = C((u) => {
306
- if (!u)
336
+ ), a = R((o) => {
337
+ if (!o)
307
338
  return null;
308
- const s = B(`feature:${u.id}:${u.key}`, "global");
309
- (u.storage === "session" ? D : O).set(s, u.bucket);
310
- }), c = /* @__PURE__ */ new Map(), g = te({
339
+ const c = A(`feature:${o.id}:${o.key}`, "global");
340
+ (o.storage === "session" ? M : C).set(c, o.bucket);
341
+ }), n = /* @__PURE__ */ new Map(), p = U({
311
342
  source: { allFeaturesStore: e, resolvedFeaturesStore: r },
312
- effect: async ({ allFeaturesStore: u, resolvedFeaturesStore: s }, { id: o, decide: a, key: f }) => {
313
- const h = s.find(
314
- (z) => z.id === o && z.key === f
343
+ effect: async ({ allFeaturesStore: o, resolvedFeaturesStore: c }, { id: f, decide: d, key: h }) => {
344
+ const y = c.find(
345
+ (B) => B.id === f && B.key === h
315
346
  );
316
- if (h)
317
- return h;
318
- const S = u[o];
319
- if (!S)
320
- throw new Error(`Feature with id '${o}' not found`);
321
- const $ = c.get(`${o}:${f}`);
347
+ if (y)
348
+ return y;
349
+ const F = o[f];
350
+ if (!F)
351
+ throw new Error(`Feature with id '${f}' not found`);
352
+ const $ = n.get(`${f}:${h}`);
322
353
  if ($ !== void 0) {
323
- const z = await $;
324
- return { id: S.id, bucket: z, key: f, storage: S.feature.storage };
354
+ const B = await $;
355
+ return { id: F.id, bucket: B, key: h, storage: F.feature.storage };
325
356
  }
326
- const k = a();
327
- c.set(`${o}:${f}`, k);
328
- const ee = await k;
329
- return { id: S.id, bucket: ee, key: f, storage: S.feature.storage };
357
+ const v = d();
358
+ n.set(`${f}:${h}`, v);
359
+ const ee = await v;
360
+ return { id: F.id, bucket: ee, key: h, storage: F.feature.storage };
330
361
  }
331
362
  });
332
- w({
333
- clock: n.register,
334
- fn: (u) => {
335
- const { id: s, feature: o } = u;
336
- return { id: s, key: o.feature.key, storage: o.feature.storage };
363
+ k({
364
+ clock: s.register,
365
+ fn: (o) => {
366
+ const { id: c, feature: f } = o;
367
+ return { id: c, key: f.feature.key, storage: f.feature.storage };
337
368
  },
338
- target: d
339
- }), w({
369
+ target: l
370
+ }), k({
340
371
  source: e,
341
- clock: g.doneData,
342
- fn: (u, s) => {
343
- const { id: o, bucket: a, storage: f } = s, h = u[o]?.feature.key;
344
- return h ? { key: h, id: o, bucket: a, storage: f } : null;
372
+ clock: p.doneData,
373
+ fn: (o, c) => {
374
+ const { id: f, bucket: d, storage: h } = c, y = o[f]?.feature.key;
375
+ return y ? { key: y, id: f, bucket: d, storage: h } : null;
345
376
  },
346
- target: l
377
+ target: a
347
378
  });
348
- const p = E({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
379
+ const u = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
349
380
  ({
350
- allFeaturesStore: u,
351
- resolvedFeaturesStore: s
352
- }) => Object.values(u).map((o) => {
353
- const a = s.find(
354
- (f) => f.id === o.id && f.key === o.feature.key
381
+ allFeaturesStore: o,
382
+ resolvedFeaturesStore: c
383
+ }) => Object.values(o).map((f) => {
384
+ const d = c.find(
385
+ (h) => h.id === f.id && h.key === f.feature.key
355
386
  );
356
- return a ? {
357
- id: o.id,
358
- name: o.feature.name,
359
- key: o.feature.key,
360
- getBucket: () => ({ id: o.id, bucket: a.bucket }),
387
+ return d ? {
388
+ id: f.id,
389
+ name: f.feature.name,
390
+ key: f.feature.key,
391
+ getBucket: () => ({ id: f.id, bucket: d.bucket }),
361
392
  isResolved: !0
362
393
  } : {
363
- id: o.id,
364
- name: o.feature.name,
365
- key: o.feature.key,
366
- getBucket: async () => await g(o.feature),
394
+ id: f.id,
395
+ name: f.feature.name,
396
+ key: f.feature.key,
397
+ getBucket: async () => await p(f.feature),
367
398
  isResolved: !1
368
399
  };
369
400
  })
370
401
  );
371
- w({
372
- clock: g.doneData,
402
+ k({
403
+ clock: p.doneData,
373
404
  source: { resolvedFeatures: r },
374
- filter: ({ resolvedFeatures: u }, { id: s, key: o }) => !u.some(
375
- (f) => f.id === s && f.key === o
405
+ filter: ({ resolvedFeatures: o }, { id: c, key: f }) => !o.some(
406
+ (h) => h.id === c && h.key === f
376
407
  ),
377
- fn: (u, s) => s,
378
- target: t.eventBus.prepend((u) => ({
408
+ fn: (o, c) => c,
409
+ target: t.eventBus.prepend((o) => ({
379
410
  type: "feature_decide",
380
- feature: u
411
+ feature: o
381
412
  }))
382
- }), w({
383
- clock: [d.doneData, g.doneData],
413
+ }), k({
414
+ clock: [l.doneData, p.doneData],
384
415
  source: r,
385
- fn: (u, s) => !s || u.some(
386
- (a) => a.id === s.id && a.key === s.key
387
- ) ? u : [...u, s],
416
+ fn: (o, c) => !c || o.some(
417
+ (d) => d.id === c.id && d.key === c.key
418
+ ) ? o : [...o, c],
388
419
  target: r
389
420
  });
390
- function y(u) {
391
- return p.map((s) => s.find((o) => o.id === u));
421
+ function g(o) {
422
+ return u.map((c) => c.find((f) => f.id === o));
392
423
  }
393
- function v(u) {
394
- return e.map((s) => s[u], { skipVoid: !1 });
424
+ function S(o) {
425
+ return e.map((c) => c[o], { skipVoid: !1 });
395
426
  }
396
- function m(u) {
397
- const s = U(
427
+ function m(o) {
428
+ const c = T(
398
429
  async () => {
399
430
  },
400
431
  { skipVoid: !1 }
401
- ), o = C(async () => {
402
- const a = y(u).getState();
403
- if (a)
404
- return async () => (await a.getBucket()).bucket;
432
+ ), f = R(async () => {
433
+ const d = g(o).getState();
434
+ if (d)
435
+ return async () => (await d.getBucket()).bucket;
405
436
  });
406
- return w({
437
+ return k({
407
438
  source: r,
408
- filter: (a) => a.some((f) => f.id === u),
409
- target: o
410
- }), w({
411
- clock: o.doneData,
412
- filter: (a) => a !== void 0,
413
- target: s
414
- }), o(), s;
439
+ filter: (d) => d.some((h) => h.id === o),
440
+ target: f
441
+ }), k({
442
+ clock: f.doneData,
443
+ filter: (d) => d !== void 0,
444
+ target: c
445
+ }), f(), c;
415
446
  }
416
447
  return {
417
448
  register: i,
418
- getById: y,
419
- getByName: v,
420
- listStore: p,
449
+ getById: g,
450
+ getByName: S,
451
+ listStore: u,
421
452
  getEvokableFeature: m
422
453
  };
423
454
  });
424
- function Ve(t) {
425
- return F(De, t);
455
+ function Oe(t) {
456
+ return I(Me, t);
426
457
  }
427
- const Ne = (t, e, r) => {
458
+ const Ue = (t, e, r) => {
428
459
  r.register(t, e);
429
- }, P = x("history");
460
+ }, E = x("history");
430
461
  function q(t, e) {
431
462
  return {
432
463
  // eslint-disable-next-line sonarjs/pseudo-random
@@ -436,243 +467,149 @@ function q(t, e) {
436
467
  experienceId: t
437
468
  };
438
469
  }
439
- const Te = I(() => {
440
- const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), i = P.event();
441
- t.on(e, (l, c) => ({
442
- entries: [...l.entries, q(c.experienceId, c.node)]
443
- })), t.on(r, (l, c) => ({
470
+ const De = b(() => {
471
+ const t = E.store({ entries: [] }), e = E.event(), r = E.event(), s = E.event(), i = E.event();
472
+ t.on(e, (a, n) => ({
473
+ entries: [...a.entries, q(n.experienceId, n.node)]
474
+ })), t.on(r, (a, n) => ({
444
475
  entries: [
445
- ...l.entries.slice(0, -1),
446
- q(c.experienceId, c.node)
476
+ ...a.entries.slice(0, -1),
477
+ q(n.experienceId, n.node)
447
478
  ]
448
- })), t.on(i, (l, c) => c);
449
- function d(l, c) {
450
- const g = { lastStepIndex: -1, secondLastStepIndex: -1 };
451
- for (let p = l.length - 1; p >= 0; p--) {
452
- const y = l[p], v = y?.node;
453
- if (!(!v || !ie(v)) && !(c && y?.experienceId !== c))
454
- if (g.lastStepIndex === -1)
455
- g.lastStepIndex = p;
479
+ })), t.on(i, (a, n) => n);
480
+ function l(a, n) {
481
+ const p = { lastStepIndex: -1, secondLastStepIndex: -1 };
482
+ for (let u = a.length - 1; u >= 0; u--) {
483
+ const g = a[u], S = g?.node;
484
+ if (!(!S || !ne(S)) && !(n && g?.experienceId !== n))
485
+ if (p.lastStepIndex === -1)
486
+ p.lastStepIndex = u;
456
487
  else {
457
- g.secondLastStepIndex = p;
488
+ p.secondLastStepIndex = u;
458
489
  break;
459
490
  }
460
491
  }
461
- return g;
492
+ return p;
462
493
  }
463
- return t.on(n, (l, c) => {
464
- const { secondLastStepIndex: g } = d(l.entries, c.experienceId), p = g !== -1 ? l.entries.slice(0, g + 1) : l.entries;
494
+ return t.on(s, (a, n) => {
495
+ const { secondLastStepIndex: p } = l(a.entries, n.experienceId), u = p !== -1 ? a.entries.slice(0, p + 1) : a.entries;
465
496
  return {
466
- ...l,
467
- entries: p
497
+ ...a,
498
+ entries: u
468
499
  };
469
500
  }), {
470
501
  push: e,
471
502
  replace: r,
472
- back: n,
503
+ back: s,
473
504
  restore: i,
474
- entriesStore: t.map((l) => l.entries)
505
+ entriesStore: t.map((a) => a.entries)
475
506
  };
476
507
  });
477
- function Ue() {
478
- return F(Te);
508
+ function Ve() {
509
+ return I(De);
479
510
  }
480
- let _e = 0;
481
- const Le = (t) => {
482
- const e = U([]);
483
- return w({
511
+ let Ne = 0;
512
+ const Te = (t) => {
513
+ const e = T([]);
514
+ return k({
484
515
  clock: t,
485
516
  source: e,
486
- fn: (r, n) => [
517
+ fn: (r, s) => [
487
518
  ...r,
488
519
  {
489
- id: _e++,
520
+ id: Ne++,
490
521
  at: /* @__PURE__ */ new Date(),
491
- payload: n
522
+ payload: s
492
523
  }
493
524
  ],
494
525
  target: e
495
526
  }), e;
496
- }, V = x("field");
497
- function Je(t) {
498
- return Array.isArray(t) && t.every(
499
- (e) => typeof e == "object" && e !== null && "id" in e && "label" in e && "value" in e
500
- );
501
- }
502
- function N(t, e) {
503
- const r = e ?? {
504
- status: "idle",
505
- options: Array.isArray(t.options) ? t.options : null
506
- };
507
- return {
508
- ...t,
509
- ...r,
510
- options: r.options ?? (Array.isArray(t.options) ? t.options : null)
511
- };
512
- }
513
- const He = I(({ client: t }) => {
514
- const e = V.store({}), r = j(e, {
515
- register(s, o) {
527
+ }, Le = x("field"), _e = b(() => {
528
+ const t = Le.store({}), e = j(t, {
529
+ register(n, p) {
516
530
  return {
517
- ...s,
518
- [o.field.id]: o.field
531
+ ...n,
532
+ [p.field.id]: p.field
519
533
  };
520
534
  }
521
535
  });
522
- function n(s) {
523
- r.register({ field: s });
536
+ function r(n) {
537
+ e.register({ field: n });
524
538
  }
525
- function i(s, o) {
526
- const a = e.getState()[s];
527
- if (!a)
539
+ function s(n, p) {
540
+ const u = l(n).getState();
541
+ if (!u)
528
542
  return;
529
- const f = Object.assign({}, a, {
530
- ...o
543
+ const g = Object.assign({}, u, {
544
+ ...p
531
545
  });
532
- r.register({ field: { ...f } });
546
+ e.register({ field: { ...g } });
533
547
  }
534
- const d = V.store({}), l = E(
535
- e,
536
- d,
537
- (s, o) => Object.values(s).map((a) => N(a, o[a.id]))
538
- );
539
- function c(s) {
540
- return E(e, d, (o, a) => {
541
- const f = o[s];
542
- return f ? N(f, a[s]) : null;
543
- });
544
- }
545
- function g(s) {
546
- return E(e, d, (o, a) => {
547
- const f = Object.values(o).find((h) => h.name === s);
548
- return f ? N(f, a[f.id]) : null;
549
- });
550
- }
551
- const p = V.effect(
552
- async ({
553
- fieldId: s,
554
- fieldOptions: o,
555
- context: a
556
- }) => {
557
- if (t && !Array.isArray(o) && o !== null) {
558
- const f = await A(t, o, a);
559
- return Je(f) ? { fieldId: s, options: f } : { fieldId: s, options: null };
560
- }
561
- return { fieldId: s, options: Array.isArray(o) ? o : null };
562
- }
563
- );
564
- d.on(p, (s, { fieldId: o }) => {
565
- const a = s[o];
566
- return {
567
- ...s,
568
- [o]: {
569
- status: "loading",
570
- // Preserve stale options during re-fetch so the UI doesn't flash blank
571
- options: a?.status === "resolved" ? a.options : null
572
- }
573
- };
574
- }), d.on(p.doneData, (s, { fieldId: o, options: a }) => ({
575
- ...s,
576
- [o]: { status: "resolved", options: a }
577
- })), d.on(p.fail, (s, { params: { fieldId: o } }) => ({
578
- ...s,
579
- [o]: { status: "error", options: null, error: "Failed to resolve field options" }
580
- }));
581
- const y = R();
582
- d.on(y, (s, o) => ({
583
- ...s,
584
- [o]: { status: "waiting", options: null }
585
- }));
586
- const v = R();
587
- t && w({
588
- clock: v,
589
- source: {
590
- states: d,
591
- fields: e
592
- },
593
- filter: ({ states: s }, { fieldId: o, force: a }) => {
594
- if (a) return !0;
595
- const f = s[o];
596
- return !f || f.status === "idle";
597
- },
598
- fn: ({ fields: s }, { fieldId: o, context: a }) => {
599
- const f = s[o] ?? null;
600
- return {
601
- fieldId: o,
602
- fieldOptions: f?.options ?? null,
603
- context: a
604
- };
605
- },
606
- target: p
607
- });
608
- function m(s, o) {
609
- v({ fieldId: s, force: o?.force, context: o?.context });
548
+ const i = t.map((n) => Object.values(n));
549
+ function l(n) {
550
+ return t.map((p) => p[n] || null);
610
551
  }
611
- function u(s, o) {
612
- for (const a of s)
613
- v({ fieldId: a, force: o?.force, context: o?.context });
552
+ function a(n) {
553
+ return t.map((p) => Object.values(p).find((u) => u.name === n) || null);
614
554
  }
615
555
  return {
616
- register: n,
617
- update: i,
618
- getById: c,
619
- listStore: l,
620
- getByName: g,
621
- resolve: m,
622
- resolveAll: u,
623
- setWaiting: y
556
+ register: r,
557
+ update: s,
558
+ getById: l,
559
+ listStore: i,
560
+ getByName: a
624
561
  };
625
562
  });
626
- function Ge(t) {
627
- return F(He, t ?? {});
563
+ function He() {
564
+ return I(_e);
628
565
  }
629
- const qe = (t, e) => {
566
+ const Ge = (t, e) => {
630
567
  e.register(t);
631
- }, Ke = x("action"), We = I(({ client: t }) => {
632
- const e = Ke.store({}), r = j(e, {
633
- register(c, g) {
568
+ }, Je = x("action"), qe = b(() => {
569
+ const t = Je.store({}), e = j(t, {
570
+ register(a, n) {
634
571
  return {
635
- ...c,
636
- [g.name]: {
637
- name: g.name,
638
- action: g.action
572
+ ...a,
573
+ [n.name]: {
574
+ name: n.name,
575
+ action: n.action
639
576
  }
640
577
  };
641
578
  }
642
579
  });
643
- function n(c, g) {
644
- r.register({ name: c, action: g });
580
+ function r(a, n) {
581
+ e.register({ name: a, action: n });
645
582
  }
646
- const i = e.map((c) => Object.values(c));
647
- function d(c) {
648
- return e.map((g) => g[c], { skipVoid: !1 });
583
+ const s = t.map((a) => Object.values(a));
584
+ function i(a) {
585
+ return t.map((n) => n[a], { skipVoid: !1 });
649
586
  }
650
- function l(c) {
651
- return e.map(
652
- (g) => {
653
- const p = g[c];
587
+ function l(a) {
588
+ return t.map(
589
+ (n) => {
590
+ const p = n[a];
654
591
  return p ? p.action : void 0;
655
592
  },
656
593
  { skipVoid: !1 }
657
594
  );
658
595
  }
659
596
  return {
660
- register: n,
661
- getByName: d,
662
- listStore: i,
597
+ register: r,
598
+ getByName: i,
599
+ listStore: s,
663
600
  getEvokableAction: l
664
601
  };
665
602
  });
666
- function Ye(t) {
667
- return F(We, t);
603
+ function Ke() {
604
+ return I(qe);
668
605
  }
669
- const Qe = (t, e, r) => {
606
+ const We = (t, e, r) => {
670
607
  r.register(t, e);
671
608
  };
672
- function T(t) {
609
+ function O(t) {
673
610
  return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
674
611
  }
675
- function Xe(t) {
612
+ function Ye(t) {
676
613
  return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null;
677
614
  }
678
615
  function K(t) {
@@ -682,219 +619,218 @@ function K(t) {
682
619
  return !1;
683
620
  }
684
621
  }
685
- const Ze = x("response"), et = I(({ client: t }) => {
686
- const e = Ze.store({}), r = R(), n = R(), i = j(e, {
687
- register(m, u) {
622
+ const Qe = x("response"), Xe = b(({ client: t }) => {
623
+ const e = Qe.store({}), r = V(), s = V(), i = j(e, {
624
+ register(m, o) {
688
625
  return {
689
626
  ...m,
690
- [u.fieldId]: u.response
627
+ [o.fieldId]: o.response
691
628
  };
692
629
  },
693
- registerBatch(m, u) {
630
+ registerBatch(m, o) {
694
631
  return {
695
632
  ...m,
696
- ...u
633
+ ...o
697
634
  };
698
635
  },
699
- clear(m, u) {
700
- const { [u]: s, ...o } = m;
701
- return o;
636
+ clear(m, o) {
637
+ const { [o]: c, ...f } = m;
638
+ return f;
702
639
  },
703
640
  clearAll() {
704
641
  return {};
705
642
  }
706
643
  });
707
- function d(m, u) {
644
+ function l(m, o) {
708
645
  if (typeof m == "string") {
709
- if (u === void 0)
646
+ if (o === void 0)
710
647
  throw new Error("Response is required when registering a single field");
711
- i.register({ fieldId: m, response: u });
648
+ i.register({ fieldId: m, response: o });
712
649
  } else
713
650
  i.registerBatch(m);
714
651
  }
715
- async function l(m) {
716
- const u = [];
652
+ async function a(m) {
653
+ const o = [];
717
654
  return await Promise.allSettled(
718
- Object.entries(m).map(async ([s, o]) => {
719
- let a = o;
720
- const f = t.fields.getById(s).getState();
721
- if (!f) {
722
- u.push({
723
- fieldId: s,
724
- userMessage: `Field '${s}' not found`,
725
- systemMessage: `No field with ID '${s}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
726
- value: a
655
+ Object.entries(m).map(async ([c, f]) => {
656
+ let d = f;
657
+ const h = t.fields.getById(c).getState();
658
+ if (!h) {
659
+ o.push({
660
+ fieldId: c,
661
+ userMessage: `Field '${c}' not found`,
662
+ systemMessage: `No field with ID '${c}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
663
+ value: d
727
664
  });
728
665
  return;
729
666
  }
730
- if (f.multiple && (typeof a == "string" || typeof a == "number" || typeof a == "boolean") && (a = [a]), f.validation && !ue(f.validation) && !T(a)) {
731
- const h = { ...e.getState(), ...m }, S = await A(t, f.validation, {
732
- $input: a,
733
- responses: h
667
+ if (h.multiple && (typeof d == "string" || typeof d == "number" || typeof d == "boolean") && (d = [d]), h.validation && !ue(h.validation) && !O(d)) {
668
+ const y = await P(t, h.validation, {
669
+ $input: d
734
670
  });
735
- if (typeof S == "string") {
736
- u.push({
737
- fieldId: s,
738
- userMessage: S,
739
- systemMessage: `Field validation resulted in an error: ${S}.`,
740
- value: a
671
+ if (typeof y == "string") {
672
+ o.push({
673
+ fieldId: c,
674
+ userMessage: y,
675
+ systemMessage: `Field validation resulted in an error: ${y}.`,
676
+ value: d
741
677
  });
742
678
  return;
743
679
  }
744
- if (S === !1) {
745
- u.push({
746
- fieldId: s,
680
+ if (y === !1) {
681
+ o.push({
682
+ fieldId: c,
747
683
  userMessage: "This field is invalid",
748
684
  systemMessage: "Field validation resulted in an unspecified error.",
749
- value: a
685
+ value: d
750
686
  });
751
687
  return;
752
688
  }
753
689
  }
754
- if (f.required && T(a)) {
755
- u.push({
756
- fieldId: s,
690
+ if (h.required && O(d)) {
691
+ o.push({
692
+ fieldId: c,
757
693
  userMessage: "This field is required",
758
694
  systemMessage: "Field is required.",
759
- value: a
695
+ value: d
760
696
  });
761
697
  return;
762
698
  }
763
- if (!f.multiple && Array.isArray(a) && a.length > 1) {
764
- u.push({
765
- fieldId: s,
699
+ if (!h.multiple && Array.isArray(d) && d.length > 1) {
700
+ o.push({
701
+ fieldId: c,
766
702
  userMessage: "This field expects a single response",
767
703
  systemMessage: "Field expects a single response.",
768
- value: a
704
+ value: d
769
705
  });
770
706
  return;
771
707
  }
772
- if (f.type === "object" && !T(a))
773
- if (f.multiple) {
774
- if (!Array.isArray(a)) {
775
- u.push({
776
- fieldId: s,
708
+ if (h.type === "object" && !O(d))
709
+ if (h.multiple) {
710
+ if (!Array.isArray(d)) {
711
+ o.push({
712
+ fieldId: c,
777
713
  userMessage: "This field expects multiple values",
778
714
  systemMessage: "Field expects an array of objects.",
779
- value: a
715
+ value: d
780
716
  });
781
717
  return;
782
718
  }
783
- for (const h of a) {
784
- if (typeof h != "object" || h === null) {
785
- u.push({
786
- fieldId: s,
719
+ for (const y of d) {
720
+ if (typeof y != "object" || y === null) {
721
+ o.push({
722
+ fieldId: c,
787
723
  userMessage: "This field expects object values",
788
724
  systemMessage: "Field expects an array of objects, but received non-object value.",
789
- value: a
725
+ value: d
790
726
  });
791
727
  return;
792
728
  }
793
- if (!K(h)) {
794
- u.push({
795
- fieldId: s,
729
+ if (!K(y)) {
730
+ o.push({
731
+ fieldId: c,
796
732
  userMessage: "This field contains non-serializable data",
797
733
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
798
- value: a
734
+ value: d
799
735
  });
800
736
  return;
801
737
  }
802
738
  }
803
739
  } else {
804
- if (Array.isArray(a)) {
805
- u.push({
806
- fieldId: s,
740
+ if (Array.isArray(d)) {
741
+ o.push({
742
+ fieldId: c,
807
743
  userMessage: "This field expects a single value",
808
744
  systemMessage: "Field expects a single object, not an array.",
809
- value: a
745
+ value: d
810
746
  });
811
747
  return;
812
748
  }
813
- if (typeof a != "object" || a === null) {
814
- u.push({
815
- fieldId: s,
749
+ if (typeof d != "object" || d === null) {
750
+ o.push({
751
+ fieldId: c,
816
752
  userMessage: "This field expects an object value",
817
753
  systemMessage: "Field expects an object value.",
818
- value: a
754
+ value: d
819
755
  });
820
756
  return;
821
757
  }
822
- if (!K(a)) {
823
- u.push({
824
- fieldId: s,
758
+ if (!K(d)) {
759
+ o.push({
760
+ fieldId: c,
825
761
  userMessage: "This field contains non-serializable data",
826
762
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
827
- value: a
763
+ value: d
828
764
  });
829
765
  return;
830
766
  }
831
767
  }
832
- if (Array.isArray(f.options) && f.options.length > 0) {
833
- const h = Array.isArray(a) ? a : [a];
834
- if (f.type === "object") {
835
- const S = f.options.map((k) => JSON.stringify(k.value));
836
- h.every((k) => S.includes(JSON.stringify(k))) || u.push({
837
- fieldId: s,
768
+ if (h.options) {
769
+ const y = Array.isArray(d) ? d : [d];
770
+ if (h.type === "object") {
771
+ const F = h.options.map((v) => JSON.stringify(v.value));
772
+ y.every((v) => F.includes(JSON.stringify(v))) || o.push({
773
+ fieldId: c,
838
774
  userMessage: "This field expects a valid option",
839
775
  systemMessage: "Field expects a valid option from the defined choices.",
840
- value: a
776
+ value: d
841
777
  });
842
778
  } else {
843
- const S = f.options.map((k) => k.value);
844
- h.every((k) => !Xe(k) || k === null ? !1 : S.includes(k)) || u.push({
845
- fieldId: s,
779
+ const F = h.options.map((v) => v.value);
780
+ y.every((v) => !Ye(v) || v === null ? !1 : F.includes(v)) || o.push({
781
+ fieldId: c,
846
782
  userMessage: "This field expects a valid option",
847
- systemMessage: `Field expects a valid option. Valid options are: ${S.join(", ")}`,
848
- value: a
783
+ systemMessage: `Field expects a valid option. Valid options are: ${F.join(", ")}`,
784
+ value: d
849
785
  });
850
786
  }
851
787
  }
852
788
  })
853
- ), { responsesToCommit: m, validationErrors: u };
789
+ ), { responsesToCommit: m, validationErrors: o };
854
790
  }
855
- async function c(m) {
856
- const { responsesToCommit: u, validationErrors: s } = await l(m);
857
- return s.length ? { errors: s } : (i.registerBatch(u), { errors: [] });
791
+ async function n(m) {
792
+ const { responsesToCommit: o, validationErrors: c } = await a(m);
793
+ return c.length ? { errors: c } : (i.registerBatch(o), { errors: [] });
858
794
  }
859
- const g = e.map((m) => m), p = e.map((m) => Object.keys(m).map((s) => ({
860
- fieldId: s,
861
- value: m[s]
795
+ const p = e.map((m) => m), u = e.map((m) => Object.keys(m).map((c) => ({
796
+ fieldId: c,
797
+ value: m[c]
862
798
  })));
863
- function y(m) {
864
- const u = t.fields.getById(m), s = e.map((o) => o[m] || null);
865
- return E({ f: u, r: s }, ({ f: o, r: a }) => a || (o?.defaultValue ? o.defaultValue : null));
799
+ function g(m) {
800
+ const o = t.fields.getById(m), c = e.map((f) => f[m] || null);
801
+ return D({ f: o, r: c }, ({ f, r: d }) => d || (f?.defaultValue ? f.defaultValue : null));
866
802
  }
867
- function v(m) {
868
- const u = t.fields.getByName(m);
869
- return E({ f: u, s: e }, ({ f: s, s: o }) => {
870
- const a = s && o[s.id] || null;
871
- return a || (s?.defaultValue ? s.defaultValue : null);
803
+ function S(m) {
804
+ const o = t.fields.getByName(m);
805
+ return D({ f: o, s: e }, ({ f: c, s: f }) => {
806
+ const d = c && f[c.id] || null;
807
+ return d || (c?.defaultValue ? c.defaultValue : null);
872
808
  });
873
809
  }
874
- return w({
810
+ return k({
875
811
  clock: r,
876
812
  target: i.clearAll
877
- }), w({
878
- clock: n,
813
+ }), k({
814
+ clock: s,
879
815
  target: i.clear
880
816
  }), {
881
- register: d,
817
+ register: l,
882
818
  clearAll: r,
883
- clear: n,
884
- commit: c,
885
- getResponsesToCommit: l,
886
- listStore: p,
887
- getAllStore: g,
888
- getByFieldId: y,
889
- getByFieldName: v
819
+ clear: s,
820
+ commit: n,
821
+ getResponsesToCommit: a,
822
+ listStore: u,
823
+ getAllStore: p,
824
+ getByFieldId: g,
825
+ getByFieldName: S
890
826
  };
891
827
  });
892
- function tt(t) {
893
- return F(et, t);
828
+ function Ze(t) {
829
+ return I(Xe, t);
894
830
  }
895
- const rt = () => "0.0.1-dev.1772073931707";
896
- function nt() {
897
- if (_()) {
831
+ const et = () => "0.0.1-dev.1772083499814";
832
+ function tt() {
833
+ if (L()) {
898
834
  const t = [
899
835
  document.currentScript,
900
836
  document.getElementById("picked_script"),
@@ -908,70 +844,70 @@ function nt() {
908
844
  }
909
845
  return "https://api.picked.app";
910
846
  }
911
- function st() {
912
- if (!L())
847
+ function rt() {
848
+ if (!_())
913
849
  return {};
914
850
  const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
915
851
  for (const [i] of t.entries())
916
852
  i.startsWith("picked-") && r.add(i);
917
853
  for (const i of r) {
918
- const d = i.replace("picked-", "");
919
- e[d] = t.getAll(i);
854
+ const l = i.replace("picked-", "");
855
+ e[l] = t.getAll(i);
920
856
  }
921
- const n = B("s");
857
+ const s = A("s");
922
858
  if (r.size > 0)
923
- D.set(n, e);
859
+ M.set(s, e);
924
860
  else {
925
- const i = D.get(n);
861
+ const i = M.get(s);
926
862
  if (i)
927
863
  return i.json() || {};
928
864
  }
929
865
  return e;
930
866
  }
931
- function it() {
932
- if (de())
867
+ function st() {
868
+ if (le())
933
869
  return crypto.randomUUID();
934
- const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15), n = Math.random().toString(36).substring(2, 15);
935
- return `${t}-${e}-${r}-${n}`;
870
+ 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);
871
+ return `${t}-${e}-${r}-${s}`;
936
872
  }
937
- const ot = B("session", "global"), at = () => {
938
- const t = O.get(ot);
873
+ const nt = A("session", "global"), it = () => {
874
+ const t = C.get(nt);
939
875
  let e;
940
876
  t.isSet() && (e = t.json());
941
877
  const r = (i) => t.set({
942
878
  id: i.id,
943
879
  isUser: i.isUser,
944
880
  identifiers: i.identifiers
945
- }), n = {
946
- id: e?.id ?? it(),
881
+ }), s = {
882
+ id: e?.id ?? st(),
947
883
  isUser: e?.isUser ?? void 0,
948
884
  identifiers: e?.identifiers ?? void 0,
949
885
  setIsUser(i) {
950
886
  this.isUser = i, r(this);
951
887
  },
952
- setIdentifier(i, d) {
953
- this.identifiers = { ...this.identifiers, [i]: d }, r(this);
888
+ setIdentifier(i, l) {
889
+ this.identifiers = { ...this.identifiers, [i]: l }, r(this);
954
890
  },
955
891
  removeIdentifier(i) {
956
892
  this.identifiers && (this.identifiers = Object.fromEntries(
957
- Object.entries(this.identifiers).filter(([d]) => d !== i)
893
+ Object.entries(this.identifiers).filter(([l]) => l !== i)
958
894
  ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
959
895
  }
960
896
  };
961
- return r(n), n;
962
- }, ct = () => le() ? at() : null;
963
- function ut() {
964
- if (L())
897
+ return r(s), s;
898
+ }, ot = () => de() ? it() : null;
899
+ function at() {
900
+ if (_())
965
901
  return globalThis.window.pickedConfig;
966
902
  }
967
- function lt() {
968
- if (!L())
903
+ function ct() {
904
+ if (!_())
969
905
  return;
970
- const t = ut(), e = t?.organizationId, r = t?.projectId;
906
+ const t = at(), e = t?.organizationId, r = t?.projectId;
971
907
  return e && r ? { organizationId: e, projectId: r } : void 0;
972
908
  }
973
- function dt() {
974
- if (!_())
909
+ function ut() {
910
+ if (!L())
975
911
  return;
976
912
  const t = document.getElementById("picked_script") || document.querySelector("script#picked") || // legacy support for 'cvly' script tag
977
913
  document.getElementById("cvly");
@@ -980,14 +916,14 @@ function dt() {
980
916
  const e = t.dataset.organizationid || t.getAttribute("organization-id"), r = t.dataset.projectid || t.getAttribute("project-id");
981
917
  return e && r ? { organizationId: e, projectId: r } : void 0;
982
918
  }
983
- function pt(t) {
919
+ function dt(t) {
984
920
  const { organizationId: e, projectId: r } = t;
985
921
  if (e && r)
986
922
  return { organizationId: e, projectId: r };
987
- const n = lt();
988
- if (n)
989
- return n;
990
- const i = dt();
923
+ const s = ct();
924
+ if (s)
925
+ return s;
926
+ const i = ut();
991
927
  if (i)
992
928
  return i;
993
929
  throw new Error(
@@ -997,13 +933,13 @@ function pt(t) {
997
933
  (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
998
934
  );
999
935
  }
1000
- function M(t) {
936
+ function z(t) {
1001
937
  return t == null || t === "" || Number.isNaN(t);
1002
938
  }
1003
- const ft = {
1004
- default: (t, e) => M(t) ? String(e ?? "") : String(t),
1005
- append: (t, e) => e && !M(t) ? `${t} ${e}` : t,
1006
- prepend: (t, e) => e && !M(t) ? `${e} ${t}` : t,
939
+ const lt = {
940
+ default: (t, e) => z(t) ? String(e ?? "") : String(t),
941
+ append: (t, e) => e && !z(t) ? `${t} ${e}` : t,
942
+ prepend: (t, e) => e && !z(t) ? `${e} ${t}` : t,
1007
943
  upper: (t) => typeof t == "string" ? t.toUpperCase() : t,
1008
944
  lower: (t) => typeof t == "string" ? t.toLowerCase() : t,
1009
945
  capitalize: (t) => typeof t == "string" ? t.charAt(0).toUpperCase() + t.slice(1) : t,
@@ -1014,97 +950,100 @@ const ft = {
1014
950
  if (Array.isArray(t))
1015
951
  return e.format(t.map(String));
1016
952
  if (t instanceof Map) {
1017
- const r = Array.from(t.entries()).map(([n, i]) => `${n}: ${i}`);
953
+ const r = Array.from(t.entries()).map(([s, i]) => `${s}: ${i}`);
1018
954
  return e.format(r);
1019
955
  }
1020
956
  return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
1021
957
  }
1022
958
  };
1023
- function gt(t) {
959
+ function pt(t) {
1024
960
  return typeof t == "object" && t !== null;
1025
961
  }
1026
- function mt(t, e) {
962
+ function ft(t, e) {
1027
963
  let r = e;
1028
- for (const n of t.split("."))
1029
- if (gt(r) && n in r)
1030
- r = r[n];
964
+ for (const s of t.split("."))
965
+ if (pt(r) && s in r)
966
+ r = r[s];
1031
967
  else
1032
968
  return;
1033
969
  return typeof r == "function" ? r() : r;
1034
970
  }
1035
- function yt(t, e) {
1036
- const r = t.split("|").map((d) => d.trim()), n = r.shift() ?? "";
1037
- let i = mt(n, e);
1038
- for (const d of r) {
1039
- const [l, ...c] = d.split(":"), g = l?.trim() ?? "", p = c.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), y = ft[g];
1040
- y && (i = y(i, p));
971
+ function gt(t, e) {
972
+ const r = t.split("|").map((l) => l.trim()), s = r.shift() ?? "";
973
+ let i = ft(s, e);
974
+ for (const l of r) {
975
+ const [a, ...n] = l.split(":"), p = a?.trim() ?? "", u = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), g = lt[p];
976
+ g && (i = g(i, u));
1041
977
  }
1042
- return M(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
978
+ return z(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
1043
979
  }
1044
- function ht(t, e) {
1045
- let r = "", n = 0;
1046
- for (; n < t.length; )
1047
- if (t[n] === "{" && t[n + 1] === "{") {
1048
- n += 2;
980
+ function mt(t, e) {
981
+ let r = "", s = 0;
982
+ for (; s < t.length; )
983
+ if (t[s] === "{" && t[s + 1] === "{") {
984
+ s += 2;
1049
985
  let i = "";
1050
- for (; n < t.length; ) {
1051
- if (t[n] === "}" && t[n + 1] === "}") {
1052
- n += 2;
986
+ for (; s < t.length; ) {
987
+ if (t[s] === "}" && t[s + 1] === "}") {
988
+ s += 2;
1053
989
  break;
1054
990
  }
1055
- i += t[n++];
991
+ i += t[s++];
1056
992
  }
1057
- r += yt(i.trim(), e);
993
+ r += gt(i.trim(), e);
1058
994
  } else
1059
- r += t[n++];
995
+ r += t[s++];
1060
996
  return r;
1061
997
  }
1062
- class vt {
1063
- static logger = b;
998
+ class ht {
999
+ static logger = w;
1064
1000
  options;
1065
1001
  isReady = !1;
1066
1002
  project;
1067
1003
  plugins = {};
1068
- eventBus = R();
1004
+ pluginStartHooks = [];
1005
+ eventBus = V();
1069
1006
  events;
1070
1007
  organizationId;
1071
1008
  projectId;
1072
1009
  apiUrl;
1010
+ dashboardUrl;
1011
+ documentationSiteUrl;
1073
1012
  session;
1074
1013
  precondition;
1075
1014
  condition;
1076
- searchParams = st();
1077
- history = Ue();
1078
- components = Fe({ client: this });
1079
- experienceInstances = oe({ client: this });
1080
- experiences = ye({ client: this });
1081
- frameworks = Ae({ client: this });
1082
- predicates = Me({ client: this });
1083
- features = Ve({ client: this });
1084
- responses = tt({ client: this });
1085
- fields = Ge({ client: this });
1086
- actions = Ye({ client: this });
1015
+ searchParams = rt();
1016
+ history = Ve();
1017
+ components = Ie({ client: this });
1018
+ experienceInstances = ie({ client: this });
1019
+ experiences = he({ client: this });
1020
+ frameworks = je({ client: this });
1021
+ predicates = ze({ client: this });
1022
+ features = Oe({ client: this });
1023
+ responses = Ze({ client: this });
1024
+ fields = He();
1025
+ actions = Ke();
1087
1026
  constructor(e) {
1088
- b("info", "Picked client initializing."), this.events = Le(this.eventBus);
1089
- const { organizationId: r, projectId: n } = pt(e);
1090
- this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || nt(), this.session = ct(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: rt() }), b("info", "Picked client initialized.");
1027
+ w("info", "Picked client initializing."), this.events = Te(this.eventBus);
1028
+ const { organizationId: r, projectId: s } = dt(e);
1029
+ this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: et() }), w("info", "Picked client initialized.");
1091
1030
  }
1092
1031
  start = () => {
1093
1032
  $e(this), (async () => {
1094
- if (!_())
1033
+ if (!L())
1095
1034
  return;
1096
- let r;
1097
- typeof this.precondition > "u" ? r = !0 : typeof this.precondition == "boolean" ? r = this.precondition : r = await A(this, this.precondition) === !0;
1098
- let n;
1099
- r && (this.condition === void 0 ? n = !0 : typeof this.condition == "boolean" ? n = this.condition : n = await A(this, this.condition) === !0);
1100
- const i = r && n === !0;
1101
- if (typeof n == "boolean" && this.session) {
1102
- const d = n;
1103
- this.session.setIsUser(d), this.eventBus({ type: "user_decide", value: d });
1035
+ await this.runPluginStartHooks();
1036
+ const r = await this.evaluateGate(this.precondition);
1037
+ let s;
1038
+ r && (s = await this.evaluateGate(this.condition));
1039
+ const i = r && s === !0;
1040
+ if (typeof s == "boolean" && this.session) {
1041
+ const l = s;
1042
+ this.session.setIsUser(l), this.eventBus({ type: "user_decide", value: l });
1104
1043
  }
1105
- if (this.eventBus({ type: "initialize" }), document.body && i && J(this), await ae(), i && J(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1106
- const { id: d, isUser: l, identifiers: c } = this.session;
1107
- this.eventBus({ type: "session", id: d, isUser: l, identifiers: c });
1044
+ if (this.eventBus({ type: "initialize" }), i && H(this), await oe(), i && H(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1045
+ const { id: l, isUser: a, identifiers: n } = this.session;
1046
+ this.eventBus({ type: "session", id: l, isUser: a, identifiers: n });
1108
1047
  }
1109
1048
  })();
1110
1049
  };
@@ -1112,55 +1051,55 @@ class vt {
1112
1051
  Ee(e, this.frameworks);
1113
1052
  };
1114
1053
  registerComponent = (e, r) => {
1115
- H(e, r, this.components);
1054
+ G(e, r, this.components);
1116
1055
  };
1117
1056
  registerPlugin = (e) => {
1118
1057
  Se(this, e, this.plugins);
1058
+ const r = this.plugins[e.name];
1059
+ r?.onStart && this.pluginStartHooks.push(r.onStart);
1119
1060
  };
1120
1061
  registerFeature = (e, r) => {
1121
- Ne(e, r, this.features);
1062
+ Ue(e, r, this.features);
1122
1063
  };
1123
1064
  registerPredicate = (e, r) => {
1124
- Oe(e, r, this.predicates);
1065
+ Ce(e, r, this.predicates);
1125
1066
  };
1126
1067
  registerField = (e) => {
1127
- qe(e, this.fields);
1068
+ Ge(e, this.fields);
1128
1069
  };
1129
1070
  registerAction = (e, r) => {
1130
- Qe(e, r, this.actions);
1071
+ We(e, r, this.actions);
1131
1072
  };
1132
1073
  registerExperience = (e) => {
1133
- e.component && H(`experience:${e.id}`, e.component, this.components), he(e, this.experiences);
1074
+ e.component && G(`experience:${e.id}`, e.component, this.components), ye(e, this.experiences);
1134
1075
  };
1135
1076
  getStateSnapshot = () => X(this);
1136
- launchExperienceById = async (e) => {
1137
- const r = this.experiences.getById(e).getState();
1138
- if (!r) {
1139
- b("warn", `Experience with id '${e}' not found.`);
1140
- return;
1141
- }
1142
- Q(this, r);
1077
+ /** @deprecated Use `client.experiences.launch({ id: experienceId })` instead. */
1078
+ launchExperienceById = async (e, r) => {
1079
+ this.experiences.launch({ id: e, options: r });
1080
+ };
1081
+ /** @deprecated Use `client.experiences.open(experienceId)` instead. */
1082
+ openExperienceById = async (e) => {
1083
+ this.experiences.open(e);
1143
1084
  };
1144
- // private async fetchProject() {
1145
- // if (this.project) {
1146
- // return
1147
- // }
1148
- //
1149
- // // todo: fetch project
1150
- //
1151
- // this.project.experiences.forEach((experience) => setupExperience(experience, this.experiences))
1152
- // }
1085
+ async runPluginStartHooks() {
1086
+ for (const e of this.pluginStartHooks)
1087
+ await e();
1088
+ }
1089
+ async evaluateGate(e) {
1090
+ return e === void 0 ? !0 : typeof e == "boolean" ? e : await P(this, e) === !0;
1091
+ }
1153
1092
  setupPlugins() {
1154
1093
  this.options.plugins?.forEach((e) => {
1155
1094
  if (Array.isArray(e)) {
1156
- e.forEach((n) => {
1157
- this.registerPlugin(n);
1095
+ e.forEach((s) => {
1096
+ this.registerPlugin(s);
1158
1097
  });
1159
1098
  return;
1160
1099
  }
1161
1100
  const r = typeof e == "function" ? e() : e;
1162
1101
  if (Array.isArray(r)) {
1163
- r.forEach((n) => this.registerPlugin(n));
1102
+ r.forEach((s) => this.registerPlugin(s));
1164
1103
  return;
1165
1104
  }
1166
1105
  this.registerPlugin(r);
@@ -1168,21 +1107,21 @@ class vt {
1168
1107
  }
1169
1108
  setupFeatures() {
1170
1109
  const e = this.options.features;
1171
- e && (Object.entries(e).forEach(([r, n]) => {
1172
- const i = typeof n == "function" ? n() : n;
1110
+ e && (Object.entries(e).forEach(([r, s]) => {
1111
+ const i = typeof s == "function" ? s() : s;
1173
1112
  this.registerFeature(r, i);
1174
1113
  }), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
1175
1114
  try {
1176
- const [n, i] = r.split(":");
1177
- if (!n || !i)
1115
+ const [s, i] = r.split(":");
1116
+ if (!s || !i)
1178
1117
  return;
1179
- let d = i;
1180
- d === "true" && (d = !0), d === "false" && (d = !1), this.registerFeature(n, {
1181
- key: `${d}`,
1118
+ let l = i;
1119
+ l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(s, {
1120
+ key: `${l}`,
1182
1121
  // use the assigned bucket value as the key
1183
- name: n,
1122
+ name: s,
1184
1123
  // eslint-disable-next-line sonarjs/function-return-type
1185
- decide: () => d,
1124
+ decide: () => l,
1186
1125
  storage: "session"
1187
1126
  });
1188
1127
  } catch {
@@ -1191,22 +1130,22 @@ class vt {
1191
1130
  }
1192
1131
  setupPredicates() {
1193
1132
  const e = this.options.predicates;
1194
- e && Object.entries(e).forEach(([r, n]) => {
1195
- if (typeof n != "function") {
1196
- b("warn", `Predicate "${r}" is not a function.`);
1133
+ e && Object.entries(e).forEach(([r, s]) => {
1134
+ if (typeof s != "function") {
1135
+ w("warn", `Predicate "${r}" is not a function.`);
1197
1136
  return;
1198
1137
  }
1199
- this.registerPredicate(r, n);
1138
+ this.registerPredicate(r, s);
1200
1139
  });
1201
1140
  }
1202
1141
  setupActions() {
1203
1142
  const e = this.options.actions;
1204
- e && Object.entries(e).forEach(([r, n]) => {
1205
- if (typeof n != "function") {
1206
- b("warn", `Action "${r}" is not a function.`);
1143
+ e && Object.entries(e).forEach(([r, s]) => {
1144
+ if (typeof s != "function") {
1145
+ w("warn", `Action "${r}" is not a function.`);
1207
1146
  return;
1208
1147
  }
1209
- this.registerAction(r, n);
1148
+ this.registerAction(r, s);
1210
1149
  });
1211
1150
  }
1212
1151
  getPluginConfig = (e) => this.plugins[e] ?? {};
@@ -1253,57 +1192,68 @@ class vt {
1253
1192
  * // => "Fruits: apple, banana, and cherry"
1254
1193
  */
1255
1194
  renderString = (e, r) => {
1256
- const n = this.responses.listStore.getState().reduce((i, d) => (i[d.fieldId] = d.value, i), {});
1257
- return ht(e, {
1195
+ const s = this.responses.listStore.getState().reduce((i, l) => (i[l.fieldId] = l.value, i), {});
1196
+ return mt(e, {
1258
1197
  ...r,
1259
- responses: n
1198
+ responses: s
1260
1199
  });
1261
1200
  };
1262
1201
  }
1263
1202
  function Z(t) {
1264
- return Array.isArray(t.options) && t.options.some((e) => "condition" in e);
1203
+ return t.options?.some((e) => "condition" in e) ?? !1;
1265
1204
  }
1266
- function St(t) {
1205
+ function yt(t) {
1267
1206
  return t.some((e) => e.condition || Z(e));
1268
1207
  }
1269
- async function Et(t, e, r) {
1270
- return e.length === 0 || !St(e) ? e : (await Promise.all(
1271
- e.map(async (i) => {
1272
- if (!(i.condition ? await A(t, i.condition, r) : !0))
1208
+ async function Et(t, e) {
1209
+ return e.length === 0 || !yt(e) ? e : (await Promise.all(
1210
+ e.map(async (s) => {
1211
+ if (!(s.condition ? await P(t, s.condition) : !0))
1273
1212
  return null;
1274
- if (!Array.isArray(i.options) || !Z(i))
1275
- return i;
1276
- const c = (await Promise.all(
1277
- i.options.map(async (p) => p.condition ? await A(t, p.condition, r) ? p : null : p)
1213
+ if (!s.options || !Z(s))
1214
+ return s;
1215
+ const a = (await Promise.all(
1216
+ s.options.map(async (p) => p.condition ? await P(t, p.condition) ? p : null : p)
1278
1217
  )).filter((p) => p !== null);
1279
- return c.length === i.options.length ? i : c.length === 0 ? null : { ...i, options: c };
1218
+ return a.length === s.options.length ? s : a.length === 0 ? null : { ...s, options: a };
1280
1219
  })
1281
- )).filter((i) => i !== null);
1220
+ )).filter((s) => s !== null);
1221
+ }
1222
+ function Pt(t) {
1223
+ return {
1224
+ $$type: "lazy-component",
1225
+ load: t
1226
+ };
1227
+ }
1228
+ function At(t) {
1229
+ return typeof t == "object" && t !== null && "$$type" in t && t.$$type === "lazy-component";
1282
1230
  }
1283
- const Pt = (t) => {
1284
- const e = new vt(t);
1231
+ const $t = (t) => {
1232
+ const e = new ht(t);
1285
1233
  return pe(e), e;
1286
1234
  };
1287
1235
  export {
1288
- vt as Picked,
1289
- Pt as createClient,
1290
- B as createStorageKey,
1291
- A as evaluateRuleLogic,
1292
- ut as getPickedConfig,
1236
+ ht as Picked,
1237
+ $t as createClient,
1238
+ A as createStorageKey,
1239
+ P as evaluateRuleLogic,
1240
+ at as getPickedConfig,
1293
1241
  Et as getStepFields,
1294
- $t as isPickedRoot,
1295
- O as localStore,
1296
- D as sessionStore,
1297
- Ct as subscribe,
1298
- Ot as supportsCookies,
1299
- de as supportsCryptoRandomUUID,
1300
- _ as supportsDocument,
1242
+ At as isLazyLoader,
1243
+ zt as isPickedRoot,
1244
+ Pt as lazyComponent,
1245
+ C as localStore,
1246
+ M as sessionStore,
1247
+ Mt as subscribe,
1248
+ Ut as supportsCookies,
1249
+ le as supportsCryptoRandomUUID,
1250
+ L as supportsDocument,
1301
1251
  Dt as supportsHistory,
1302
1252
  Vt as supportsIntersectionObserver,
1303
- le as supportsLocalStorage,
1253
+ de as supportsLocalStorage,
1304
1254
  Nt as supportsLocation,
1305
1255
  Tt as supportsSessionStorage,
1306
- Ut as supportsShadowRoot,
1256
+ Lt as supportsShadowRoot,
1307
1257
  _t as supportsWebComponents,
1308
- L as supportsWindow
1258
+ _ as supportsWindow
1309
1259
  };