@picked/client 0.0.45-next.4 → 0.0.45-next.5

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 (36) 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/dynamic-experiences/index.js +1 -0
  5. package/dist/esm/index.js +330 -321
  6. package/dist/esm/plugins/dynamic-experiences/index.js +115 -0
  7. package/dist/types/client.d.ts +10 -12
  8. package/dist/types/client.d.ts.map +1 -1
  9. package/dist/types/entities/component/component.d.ts +2 -1
  10. package/dist/types/entities/component/component.d.ts.map +1 -1
  11. package/dist/types/entities/component/lazyComponent.d.ts +11 -0
  12. package/dist/types/entities/component/lazyComponent.d.ts.map +1 -0
  13. package/dist/types/entities/experience/experience.d.ts +4 -4
  14. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  15. package/dist/types/entities/plugin/plugin.d.ts +4 -1
  16. package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
  17. package/dist/types/exports.d.ts +1 -0
  18. package/dist/types/exports.d.ts.map +1 -1
  19. package/dist/types/index.d.ts +1 -1
  20. package/dist/types/index.d.ts.map +1 -1
  21. package/dist/types/picked.d.ts +8 -3
  22. package/dist/types/picked.d.ts.map +1 -1
  23. package/dist/types/ping.d.ts.map +1 -1
  24. package/dist/types/plugins/create-experience/create-experience.d.ts +2 -2
  25. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  26. package/dist/types/plugins/dynamic-experiences/hash.d.ts +18 -0
  27. package/dist/types/plugins/dynamic-experiences/hash.d.ts.map +1 -0
  28. package/dist/types/plugins/dynamic-experiences/index.d.ts +3 -0
  29. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -0
  30. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +23 -0
  31. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -0
  32. package/dist/types/plugins/dynamic-experiences/types.d.ts +15 -0
  33. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -0
  34. package/dist/types/utils/api.d.ts +3 -0
  35. package/dist/types/utils/api.d.ts.map +1 -0
  36. package/package.json +7 -1
package/dist/esm/index.js CHANGED
@@ -1,24 +1,25 @@
1
- import { createDomain as x, createApi as j, createStore as N, createEffect as $, sample as k, attach as Z, combine as D, createEvent as V } from "effector";
2
- import { createFactory as b, invoke as I } from "@withease/factories";
3
- import { g as q, t as ee, c as te, i as re, e as E, a as ne, b as se, d as ie } from "../experience-instance-CU_pYPyd.js";
4
- import { f as Bt } from "../experience-instance-CU_pYPyd.js";
5
- import { l as w } from "../logger-C9a75KZn.js";
6
- import { c as A, l as C, s as z } from "../storage-Co_LbKr_.js";
7
- import { a as $t } 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 Ct, f as zt, g as Mt, h as Dt, i as Vt, j as Nt, k as Tt } from "../supports-8YT4QKI7.js";
12
- const K = x("experience"), le = b(
1
+ import { createDomain as F, createApi as x, createStore as V, createEffect as R, sample as v, attach as Z, combine as D, createEvent as U } from "effector";
2
+ import { createFactory as w, invoke as b } from "@withease/factories";
3
+ import { g as q, t as ee, c as te, i as re, e as P, a as ne, b as se, d as ie } from "../experience-instance-CU_pYPyd.js";
4
+ import { f as zt } from "../experience-instance-CU_pYPyd.js";
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";
7
+ import { a as Ot } from "../storage-Co_LbKr_.js";
8
+ import { p as oe } from "../api-CbXfbi_s.js";
9
+ import { g as ae } from "../id-BW-g3y32.js";
10
+ import { i as ce } from "../object-JwZ58NOH.js";
11
+ import { s as N, a as T, b as ue, c as de, d as le } from "../supports-8YT4QKI7.js";
12
+ import { e as Dt, f as Ut, g as Vt, h as Nt, i as Tt, j as Lt, k as _t } from "../supports-8YT4QKI7.js";
13
+ const K = F("experience"), pe = w(
13
14
  ({ client: t, experience: e }) => {
14
- const r = K.store(e), n = j(r, {
15
+ const r = K.store(e), n = x(r, {
15
16
  merge(p, h) {
16
17
  return {
17
18
  ...p,
18
19
  ...h.experience
19
20
  };
20
21
  }
21
- }), o = r.map((p) => ({
22
+ }), i = r.map((p) => ({
22
23
  name: p.name,
23
24
  decisionLogic: p.condition ?? p.decide,
24
25
  targetSelectors: p.targets,
@@ -26,7 +27,7 @@ const K = x("experience"), le = b(
26
27
  })), d = t.components.listStore.map(
27
28
  (p) => p.find((h) => h.name === `experience:${e.id}`) || p.find((h) => h.name === "experience"),
28
29
  { skipVoid: !1 }
29
- ), i = r.map((p) => ({
30
+ ), o = r.map((p) => ({
30
31
  steps: p.steps,
31
32
  nodes: p.nodes,
32
33
  edges: p.edges,
@@ -34,8 +35,8 @@ const K = x("experience"), le = b(
34
35
  })), s = r.map((p) => p.fields), l = e.actions ?? [];
35
36
  return {
36
37
  id: e.id,
37
- configStore: o,
38
- treeStore: i,
38
+ configStore: i,
39
+ treeStore: o,
39
40
  fieldsStore: s,
40
41
  componentStore: d,
41
42
  actions: l,
@@ -43,65 +44,65 @@ const K = x("experience"), le = b(
43
44
  };
44
45
  }
45
46
  );
46
- function pe(t) {
47
- return I(le, t);
47
+ function fe(t) {
48
+ return b(pe, t);
48
49
  }
49
- const fe = b(({ client: t }) => {
50
- const e = K.store({}), r = j(e, {
51
- register(i, s) {
50
+ const ge = w(({ client: t }) => {
51
+ const e = K.store({}), r = x(e, {
52
+ register(o, s) {
52
53
  return {
53
- ...i,
54
+ ...o,
54
55
  [s.id]: s
55
56
  };
56
57
  }
57
58
  });
58
- function n(i) {
59
- const s = e.getState()[i.id];
59
+ function n(o) {
60
+ const s = e.getState()[o.id];
60
61
  if (s) {
61
- s.merge({ experience: i, strategy: "override" });
62
+ s.merge({ experience: o, strategy: "override" });
62
63
  return;
63
64
  }
64
- const l = pe({ client: t, experience: i });
65
+ const l = fe({ client: t, experience: o });
65
66
  r.register(l);
66
67
  }
67
- const o = e.map((i) => Object.values(i));
68
- function d(i) {
69
- return e.map((s) => s[i], { skipVoid: !1 });
68
+ const i = e.map((o) => Object.values(o));
69
+ function d(o) {
70
+ return e.map((s) => s[o], { skipVoid: !1 });
70
71
  }
71
72
  return {
72
73
  register: n,
73
74
  getById: d,
74
- listStore: o
75
+ listStore: i
75
76
  };
76
77
  });
77
- function ge(t) {
78
- return I(fe, t);
78
+ function me(t) {
79
+ return b(ge, t);
79
80
  }
80
- const me = (t, e) => {
81
+ const he = (t, e) => {
81
82
  e.register(t);
82
83
  }, W = (t, e, r) => {
83
- const { targetSelectors: n } = e.configStore.getState(), o = q(n, e.id);
84
- o.forEach(
85
- ({ elements: i }) => i.forEach((s) => ee(s, e.id))
86
- ), te(o, e.id).forEach((i) => {
87
- r ? t.experienceInstances.spawn(e, i, r) : t.experienceInstances.spawn(e, i);
84
+ const { targetSelectors: n } = e.configStore.getState(), i = q(n, e.id);
85
+ i.forEach(
86
+ ({ elements: o }) => o.forEach((s) => ee(s, e.id))
87
+ ), te(i, e.id).forEach((o) => {
88
+ r ? t.experienceInstances.spawn(e, o, r) : t.experienceInstances.spawn(e, o);
88
89
  });
89
- }, _ = async (t) => {
90
+ }, L = async (t) => {
90
91
  await Promise.all(
91
92
  t.experiences.listStore.getState().map(async (e) => {
92
- await he(t, e) && W(t, e);
93
+ await ye(t, e) && W(t, e);
93
94
  })
94
95
  );
95
- }, he = async (t, e) => {
96
+ }, ye = async (t, e) => {
96
97
  const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
97
- return q(n, e.id).length < 1 || n.length === 0 ? !1 : r && re(r) ? await E(t, r) === !0 : !0;
98
- }, ye = (t, e, r) => {
99
- const n = e.name, o = e.setup(t);
100
- if (o) {
98
+ return q(n, e.id).length < 1 || n.length === 0 ? !1 : r && re(r) ? await P(t, r) === !0 : !0;
99
+ }, Se = (t, e, r) => {
100
+ const n = e.name, i = e.setup(t);
101
+ if (i) {
101
102
  const d = r[n] ?? {};
102
- r[n] = Object.freeze({ ...d, ...o });
103
+ r[n] = Object.freeze({ ...d, ...i });
103
104
  }
104
- }, Se = x("component"), ve = b(
105
+ }, ve = F("component"), ke = w(
105
106
  ({ client: t, component: e, name: r }) => {
106
107
  const n = t.frameworks.getByName(e.frameworkName);
107
108
  return {
@@ -111,92 +112,86 @@ const me = (t, e) => {
111
112
  };
112
113
  }
113
114
  );
114
- function ke(t) {
115
- return I(ve, t);
115
+ function we(t) {
116
+ return b(ke, t);
116
117
  }
117
- const we = b(({ client: t }) => {
118
- const e = Se.store({}), r = j(e, {
119
- register(i, s) {
118
+ const be = w(({ client: t }) => {
119
+ const e = ve.store({}), r = x(e, {
120
+ register(o, s) {
120
121
  return {
121
- ...i,
122
+ ...o,
122
123
  [s.name]: s
123
124
  };
124
125
  }
125
126
  });
126
- function n(i, s) {
127
- e.getState()[i] && w(
127
+ function n(o, s) {
128
+ e.getState()[o] && k(
128
129
  "warn",
129
- `Component '${i}' already registered. Registering again will override the previous registration.`
130
+ `Component '${o}' already registered. Registering again will override the previous registration.`
130
131
  );
131
- const p = ke({ client: t, name: i, component: s });
132
+ const p = we({ client: t, name: o, component: s });
132
133
  r.register(p);
133
134
  }
134
- const o = e.map((i) => Object.values(i));
135
- function d(i) {
136
- return e.map((s) => s[i], { skipVoid: !1 });
135
+ const i = e.map((o) => Object.values(o));
136
+ function d(o) {
137
+ return e.map((s) => s[o], { skipVoid: !1 });
137
138
  }
138
139
  return {
139
140
  register: n,
140
141
  getByName: d,
141
- listStore: o
142
+ listStore: i
142
143
  };
143
144
  });
144
- function be(t) {
145
- return I(we, t);
145
+ function Ie(t) {
146
+ return b(be, t);
146
147
  }
147
- const L = (t, e, r) => {
148
+ const _ = (t, e, r) => {
148
149
  r.register(t, e);
149
- }, Ie = x("framework"), Fe = b(({ client: t }) => {
150
- const e = Ie.store({}), r = j(e, {
151
- register(i, s) {
150
+ }, Fe = F("framework"), xe = w(({ client: t }) => {
151
+ const e = Fe.store({}), r = x(e, {
152
+ register(o, s) {
152
153
  return {
153
- ...i,
154
+ ...o,
154
155
  [s.name]: s.framework
155
156
  };
156
157
  }
157
158
  });
158
- function n(i, s) {
159
- e.getState()[i] && w(
159
+ function n(o, s) {
160
+ e.getState()[o] && k(
160
161
  "warn",
161
- `Framework '${i}' already registered. Registering again will override the previous registration.`
162
- ), r.register({ name: i, framework: s });
162
+ `Framework '${o}' already registered. Registering again will override the previous registration.`
163
+ ), r.register({ name: o, framework: s });
163
164
  }
164
- const o = e.map((i) => Object.values(i));
165
- function d(i) {
166
- return e.map((s) => s[i], { skipVoid: !1 });
165
+ const i = e.map((o) => Object.values(o));
166
+ function d(o) {
167
+ return e.map((s) => s[o], { skipVoid: !1 });
167
168
  }
168
169
  return {
169
170
  register: n,
170
171
  getByName: d,
171
- listStore: o
172
+ listStore: i
172
173
  };
173
174
  });
174
- function xe(t) {
175
- return I(Fe, t);
175
+ function je(t) {
176
+ return b(xe, t);
176
177
  }
177
- const je = (t, e) => {
178
+ const Ee = (t, e) => {
178
179
  e.register(t.name, t);
179
- }, Ee = 6e3, Pe = A("last_ping", "global"), Ae = (t) => `${t}/api/v1/ping`, Be = async (t) => {
180
+ }, Pe = 6e3, Ae = A("last_ping", "global"), $e = async (t) => {
180
181
  try {
181
- const e = Date.now(), r = C.get(Pe);
182
+ const e = Date.now(), r = C.get(Ae);
182
183
  let n = 0;
183
- if (r.isSet() && (n = r.json() ?? 0), n && e - n < Ee)
184
+ if (r.isSet() && (n = r.json() ?? 0), n && e - n < Pe)
184
185
  return !0;
185
- const o = Ae(t.apiUrl), d = {
186
+ const i = {
186
187
  projectId: t.projectId,
187
188
  path: window.location.pathname
188
- }, i = JSON.stringify(d), s = {
189
- "Content-Type": "application/json"
190
- }, p = document.getElementById("picked_script")?.dataset.verceltoken;
191
- p && (s["x-vercel-protection-bypass"] = p);
192
- const v = (await fetch(o, {
193
- method: "POST",
194
- headers: s,
195
- body: i
196
- })).ok;
197
- return v && r.set(e), v;
189
+ }, d = {}, s = document.getElementById("picked_script")?.dataset.verceltoken;
190
+ s && (d["x-vercel-protection-bypass"] = s);
191
+ const p = (await oe(t.apiUrl, "ping", i, d)).ok;
192
+ return p && r.set(e), p;
198
193
  } catch (e) {
199
- return w("error", e), !1;
194
+ return k("error", e), !1;
200
195
  }
201
196
  };
202
197
  function Y(t) {
@@ -211,8 +206,8 @@ function Y(t) {
211
206
  };
212
207
  return Object.freeze(r);
213
208
  }
214
- const Re = x("predicate"), $e = b(({ client: t }) => {
215
- const e = Re.store({}), r = j(e, {
209
+ const Be = F("predicate"), Re = w(({ client: t }) => {
210
+ const e = Be.store({}), r = x(e, {
216
211
  register(s, l) {
217
212
  return {
218
213
  ...s,
@@ -224,30 +219,30 @@ const Re = x("predicate"), $e = b(({ client: t }) => {
224
219
  }
225
220
  });
226
221
  function n(s, l) {
227
- e.getState()[s] && w(
222
+ e.getState()[s] && k(
228
223
  "warn",
229
224
  `Predicate '${s}' already registered. Registering again will override the previous registration.`
230
225
  ), r.register(Object.freeze({ name: s, predicate: l }));
231
226
  }
232
- const o = e.map((s) => Object.values(s));
227
+ const i = e.map((s) => Object.values(s));
233
228
  function d(s) {
234
229
  return e.map((l) => l[s]?.predicate, { skipVoid: !1 });
235
230
  }
236
- function i(s) {
237
- const l = N(() => {
231
+ function o(s) {
232
+ const l = V(() => {
238
233
  }, {
239
234
  skipVoid: !1
240
- }), p = $(async () => {
235
+ }), p = R(async () => {
241
236
  const h = d(s).getState();
242
237
  if (!h)
243
238
  return;
244
- const v = Y(t);
245
- return (...m) => h({ ...v, args: m });
239
+ const j = Y(t);
240
+ return (...m) => h({ ...j, args: m });
246
241
  });
247
- return k({
242
+ return v({
248
243
  source: { responses: t.responses.listStore, fields: t.fields.listStore },
249
244
  target: p
250
- }), k({
245
+ }), v({
251
246
  clock: p.doneData,
252
247
  filter: (h) => h !== void 0,
253
248
  target: l
@@ -256,17 +251,17 @@ const Re = x("predicate"), $e = b(({ client: t }) => {
256
251
  return {
257
252
  register: n,
258
253
  getByName: d,
259
- listStore: o,
260
- getEvokablePredicate: i
254
+ listStore: i,
255
+ getEvokablePredicate: o
261
256
  };
262
257
  });
263
- function Oe(t) {
264
- return I($e, t);
258
+ function ze(t) {
259
+ return b(Re, t);
265
260
  }
266
261
  const Ce = (t, e, r) => {
267
262
  r.register(t, e);
268
- }, J = x("feature"), ze = b(({ client: t }) => {
269
- const e = J.store({}), r = J.store([]), n = j(e, {
263
+ }, H = F("feature"), Oe = w(({ client: t }) => {
264
+ const e = H.store({}), r = H.store([]), n = x(e, {
270
265
  register(a, c) {
271
266
  return {
272
267
  ...a,
@@ -274,8 +269,8 @@ const Ce = (t, e, r) => {
274
269
  };
275
270
  }
276
271
  });
277
- function o(a, c) {
278
- e.getState()[a] && w(
272
+ function i(a, c) {
273
+ e.getState()[a] && k(
279
274
  "warn",
280
275
  `Feature '${a}' already registered. Registering again will override the previous registration.`
281
276
  );
@@ -293,57 +288,57 @@ const Ce = (t, e, r) => {
293
288
  })
294
289
  );
295
290
  }
296
- const d = $(
291
+ const d = R(
297
292
  async ({
298
293
  id: a,
299
294
  key: c,
300
295
  storage: f = "local"
301
296
  }) => {
302
- const u = A(`feature:${a}:${c}`, "global"), y = (f === "session" ? z : C).get(u).boolean();
297
+ const u = A(`feature:${a}:${c}`, "global"), y = (f === "session" ? O : C).get(u).boolean();
303
298
  return y === null ? null : { id: a, key: c, bucket: y, storage: f };
304
299
  }
305
- ), i = $((a) => {
300
+ ), o = R((a) => {
306
301
  if (!a)
307
302
  return null;
308
303
  const c = A(`feature:${a.id}:${a.key}`, "global");
309
- (a.storage === "session" ? z : C).set(c, a.bucket);
304
+ (a.storage === "session" ? O : C).set(c, a.bucket);
310
305
  }), s = /* @__PURE__ */ new Map(), l = Z({
311
306
  source: { allFeaturesStore: e, resolvedFeaturesStore: r },
312
307
  effect: async ({ allFeaturesStore: a, resolvedFeaturesStore: c }, { id: f, decide: u, key: g }) => {
313
308
  const y = c.find(
314
- (R) => R.id === f && R.key === g
309
+ (B) => B.id === f && B.key === g
315
310
  );
316
311
  if (y)
317
312
  return y;
318
- const F = a[f];
319
- if (!F)
313
+ const I = a[f];
314
+ if (!I)
320
315
  throw new Error(`Feature with id '${f}' not found`);
321
- const B = s.get(`${f}:${g}`);
322
- if (B !== void 0) {
323
- const R = await B;
324
- return { id: F.id, bucket: R, key: g, storage: F.feature.storage };
316
+ const $ = s.get(`${f}:${g}`);
317
+ if ($ !== void 0) {
318
+ const B = await $;
319
+ return { id: I.id, bucket: B, key: g, storage: I.feature.storage };
325
320
  }
326
321
  const S = u();
327
322
  s.set(`${f}:${g}`, S);
328
323
  const X = await S;
329
- return { id: F.id, bucket: X, key: g, storage: F.feature.storage };
324
+ return { id: I.id, bucket: X, key: g, storage: I.feature.storage };
330
325
  }
331
326
  });
332
- k({
327
+ v({
333
328
  clock: n.register,
334
329
  fn: (a) => {
335
330
  const { id: c, feature: f } = a;
336
331
  return { id: c, key: f.feature.key, storage: f.feature.storage };
337
332
  },
338
333
  target: d
339
- }), k({
334
+ }), v({
340
335
  source: e,
341
336
  clock: l.doneData,
342
337
  fn: (a, c) => {
343
338
  const { id: f, bucket: u, storage: g } = c, y = a[f]?.feature.key;
344
339
  return y ? { key: y, id: f, bucket: u, storage: g } : null;
345
340
  },
346
- target: i
341
+ target: o
347
342
  });
348
343
  const p = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
349
344
  ({
@@ -368,7 +363,7 @@ const Ce = (t, e, r) => {
368
363
  };
369
364
  })
370
365
  );
371
- k({
366
+ v({
372
367
  clock: l.doneData,
373
368
  source: { resolvedFeatures: r },
374
369
  filter: ({ resolvedFeatures: a }, { id: c, key: f }) => !a.some(
@@ -379,7 +374,7 @@ const Ce = (t, e, r) => {
379
374
  type: "feature_decide",
380
375
  feature: a
381
376
  }))
382
- }), k({
377
+ }), v({
383
378
  clock: [d.doneData, l.doneData],
384
379
  source: r,
385
380
  fn: (a, c) => !c || a.some(
@@ -390,67 +385,67 @@ const Ce = (t, e, r) => {
390
385
  function h(a) {
391
386
  return p.map((c) => c.find((f) => f.id === a));
392
387
  }
393
- function v(a) {
388
+ function j(a) {
394
389
  return e.map((c) => c[a], { skipVoid: !1 });
395
390
  }
396
391
  function m(a) {
397
- const c = N(
392
+ const c = V(
398
393
  async () => {
399
394
  },
400
395
  { skipVoid: !1 }
401
- ), f = $(async () => {
396
+ ), f = R(async () => {
402
397
  const u = h(a).getState();
403
398
  if (u)
404
399
  return async () => (await u.getBucket()).bucket;
405
400
  });
406
- return k({
401
+ return v({
407
402
  source: r,
408
403
  filter: (u) => u.some((g) => g.id === a),
409
404
  target: f
410
- }), k({
405
+ }), v({
411
406
  clock: f.doneData,
412
407
  filter: (u) => u !== void 0,
413
408
  target: c
414
409
  }), f(), c;
415
410
  }
416
411
  return {
417
- register: o,
412
+ register: i,
418
413
  getById: h,
419
- getByName: v,
414
+ getByName: j,
420
415
  listStore: p,
421
416
  getEvokableFeature: m
422
417
  };
423
418
  });
424
419
  function Me(t) {
425
- return I(ze, t);
420
+ return b(Oe, t);
426
421
  }
427
422
  const De = (t, e, r) => {
428
423
  r.register(t, e);
429
- }, P = x("history");
430
- function H(t, e) {
424
+ }, E = F("history");
425
+ function G(t, e) {
431
426
  return {
432
427
  // eslint-disable-next-line sonarjs/pseudo-random
433
- id: oe(`history-entry-${Date.now()}-${Math.random()}}`),
428
+ id: ae(`history-entry-${Date.now()}-${Math.random()}}`),
434
429
  node: e,
435
430
  at: Date.now(),
436
431
  experienceId: t
437
432
  };
438
433
  }
439
- const Ve = b(() => {
440
- const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), o = P.event();
441
- t.on(e, (i, s) => ({
442
- entries: [...i.entries, H(s.experienceId, s.node)]
443
- })), t.on(r, (i, s) => ({
434
+ const Ue = w(() => {
435
+ const t = E.store({ entries: [] }), e = E.event(), r = E.event(), n = E.event(), i = E.event();
436
+ t.on(e, (o, s) => ({
437
+ entries: [...o.entries, G(s.experienceId, s.node)]
438
+ })), t.on(r, (o, s) => ({
444
439
  entries: [
445
- ...i.entries.slice(0, -1),
446
- H(s.experienceId, s.node)
440
+ ...o.entries.slice(0, -1),
441
+ G(s.experienceId, s.node)
447
442
  ]
448
- })), t.on(o, (i, s) => s);
449
- function d(i, s) {
443
+ })), t.on(i, (o, s) => s);
444
+ function d(o, s) {
450
445
  const l = { lastStepIndex: -1, secondLastStepIndex: -1 };
451
- for (let p = i.length - 1; p >= 0; p--) {
452
- const h = i[p], v = h?.node;
453
- if (!(!v || !ne(v)) && !(s && h?.experienceId !== s))
446
+ for (let p = o.length - 1; p >= 0; p--) {
447
+ const h = o[p], j = h?.node;
448
+ if (!(!j || !ne(j)) && !(s && h?.experienceId !== s))
454
449
  if (l.lastStepIndex === -1)
455
450
  l.lastStepIndex = p;
456
451
  else {
@@ -460,41 +455,41 @@ const Ve = b(() => {
460
455
  }
461
456
  return l;
462
457
  }
463
- return t.on(n, (i, s) => {
464
- const { secondLastStepIndex: l } = d(i.entries, s.experienceId), p = l !== -1 ? i.entries.slice(0, l + 1) : i.entries;
458
+ return t.on(n, (o, s) => {
459
+ const { secondLastStepIndex: l } = d(o.entries, s.experienceId), p = l !== -1 ? o.entries.slice(0, l + 1) : o.entries;
465
460
  return {
466
- ...i,
461
+ ...o,
467
462
  entries: p
468
463
  };
469
464
  }), {
470
465
  push: e,
471
466
  replace: r,
472
467
  back: n,
473
- restore: o,
474
- entriesStore: t.map((i) => i.entries)
468
+ restore: i,
469
+ entriesStore: t.map((o) => o.entries)
475
470
  };
476
471
  });
477
- function Ne() {
478
- return I(Ve);
472
+ function Ve() {
473
+ return b(Ue);
479
474
  }
480
- let Te = 0;
481
- const Ue = (t) => {
482
- const e = N([]);
483
- return k({
475
+ let Ne = 0;
476
+ const Te = (t) => {
477
+ const e = V([]);
478
+ return v({
484
479
  clock: t,
485
480
  source: e,
486
481
  fn: (r, n) => [
487
482
  ...r,
488
483
  {
489
- id: Te++,
484
+ id: Ne++,
490
485
  at: /* @__PURE__ */ new Date(),
491
486
  payload: n
492
487
  }
493
488
  ],
494
489
  target: e
495
490
  }), e;
496
- }, _e = x("field"), Le = b(() => {
497
- const t = _e.store({}), e = j(t, {
491
+ }, Le = F("field"), _e = w(() => {
492
+ const t = Le.store({}), e = x(t, {
498
493
  register(s, l) {
499
494
  return {
500
495
  ...s,
@@ -514,31 +509,31 @@ const Ue = (t) => {
514
509
  });
515
510
  e.register({ field: { ...h } });
516
511
  }
517
- const o = t.map((s) => Object.values(s));
512
+ const i = t.map((s) => Object.values(s));
518
513
  function d(s) {
519
514
  return t.map((l) => l[s] || null);
520
515
  }
521
- function i(s) {
516
+ function o(s) {
522
517
  return t.map((l) => Object.values(l).find((p) => p.name === s) || null);
523
518
  }
524
519
  return {
525
520
  register: r,
526
521
  update: n,
527
522
  getById: d,
528
- listStore: o,
529
- getByName: i
523
+ listStore: i,
524
+ getByName: o
530
525
  };
531
526
  });
532
- function Je() {
533
- return I(Le);
527
+ function He() {
528
+ return b(_e);
534
529
  }
535
- const He = (t, e) => {
530
+ const Ge = (t, e) => {
536
531
  e.register(t);
537
- }, Ge = x("action"), qe = b(() => {
538
- const t = Ge.store({}), e = j(t, {
539
- register(i, s) {
532
+ }, Je = F("action"), qe = w(() => {
533
+ const t = Je.store({}), e = x(t, {
534
+ register(o, s) {
540
535
  return {
541
- ...i,
536
+ ...o,
542
537
  [s.name]: {
543
538
  name: s.name,
544
539
  action: s.action
@@ -546,17 +541,17 @@ const He = (t, e) => {
546
541
  };
547
542
  }
548
543
  });
549
- function r(i, s) {
550
- e.register({ name: i, action: s });
544
+ function r(o, s) {
545
+ e.register({ name: o, action: s });
551
546
  }
552
- const n = t.map((i) => Object.values(i));
553
- function o(i) {
554
- return t.map((s) => s[i], { skipVoid: !1 });
547
+ const n = t.map((o) => Object.values(o));
548
+ function i(o) {
549
+ return t.map((s) => s[o], { skipVoid: !1 });
555
550
  }
556
- function d(i) {
551
+ function d(o) {
557
552
  return t.map(
558
553
  (s) => {
559
- const l = s[i];
554
+ const l = s[o];
560
555
  return l ? l.action : void 0;
561
556
  },
562
557
  { skipVoid: !1 }
@@ -564,13 +559,13 @@ const He = (t, e) => {
564
559
  }
565
560
  return {
566
561
  register: r,
567
- getByName: o,
562
+ getByName: i,
568
563
  listStore: n,
569
564
  getEvokableAction: d
570
565
  };
571
566
  });
572
567
  function Ke() {
573
- return I(qe);
568
+ return b(qe);
574
569
  }
575
570
  const We = (t, e, r) => {
576
571
  r.register(t, e);
@@ -581,15 +576,15 @@ function M(t) {
581
576
  function Ye(t) {
582
577
  return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null;
583
578
  }
584
- function G(t) {
579
+ function J(t) {
585
580
  try {
586
581
  return JSON.stringify(t), !0;
587
582
  } catch {
588
583
  return !1;
589
584
  }
590
585
  }
591
- const Qe = x("response"), Xe = b(({ client: t }) => {
592
- const e = Qe.store({}), r = V(), n = V(), o = j(e, {
586
+ const Qe = F("response"), Xe = w(({ client: t }) => {
587
+ const e = Qe.store({}), r = U(), n = U(), i = x(e, {
593
588
  register(m, a) {
594
589
  return {
595
590
  ...m,
@@ -614,11 +609,11 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
614
609
  if (typeof m == "string") {
615
610
  if (a === void 0)
616
611
  throw new Error("Response is required when registering a single field");
617
- o.register({ fieldId: m, response: a });
612
+ i.register({ fieldId: m, response: a });
618
613
  } else
619
- o.registerBatch(m);
614
+ i.registerBatch(m);
620
615
  }
621
- async function i(m) {
616
+ async function o(m) {
622
617
  const a = [];
623
618
  return await Promise.allSettled(
624
619
  Object.entries(m).map(async ([c, f]) => {
@@ -633,8 +628,8 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
633
628
  });
634
629
  return;
635
630
  }
636
- if (g.multiple && (typeof u == "string" || typeof u == "number" || typeof u == "boolean") && (u = [u]), g.validation && !ae(g.validation) && !M(u)) {
637
- const y = await E(t, g.validation, {
631
+ if (g.multiple && (typeof u == "string" || typeof u == "number" || typeof u == "boolean") && (u = [u]), g.validation && !ce(g.validation) && !M(u)) {
632
+ const y = await P(t, g.validation, {
638
633
  $input: u
639
634
  });
640
635
  if (typeof y == "string") {
@@ -695,7 +690,7 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
695
690
  });
696
691
  return;
697
692
  }
698
- if (!G(y)) {
693
+ if (!J(y)) {
699
694
  a.push({
700
695
  fieldId: c,
701
696
  userMessage: "This field contains non-serializable data",
@@ -724,7 +719,7 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
724
719
  });
725
720
  return;
726
721
  }
727
- if (!G(u)) {
722
+ if (!J(u)) {
728
723
  a.push({
729
724
  fieldId: c,
730
725
  userMessage: "This field contains non-serializable data",
@@ -737,19 +732,19 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
737
732
  if (g.options) {
738
733
  const y = Array.isArray(u) ? u : [u];
739
734
  if (g.type === "object") {
740
- const F = g.options.map((S) => JSON.stringify(S.value));
741
- y.every((S) => F.includes(JSON.stringify(S))) || a.push({
735
+ const I = g.options.map((S) => JSON.stringify(S.value));
736
+ y.every((S) => I.includes(JSON.stringify(S))) || a.push({
742
737
  fieldId: c,
743
738
  userMessage: "This field expects a valid option",
744
739
  systemMessage: "Field expects a valid option from the defined choices.",
745
740
  value: u
746
741
  });
747
742
  } else {
748
- const F = g.options.map((S) => S.value);
749
- y.every((S) => !Ye(S) || S === null ? !1 : F.includes(S)) || a.push({
743
+ const I = g.options.map((S) => S.value);
744
+ y.every((S) => !Ye(S) || S === null ? !1 : I.includes(S)) || a.push({
750
745
  fieldId: c,
751
746
  userMessage: "This field expects a valid option",
752
- systemMessage: `Field expects a valid option. Valid options are: ${F.join(", ")}`,
747
+ systemMessage: `Field expects a valid option. Valid options are: ${I.join(", ")}`,
753
748
  value: u
754
749
  });
755
750
  }
@@ -758,8 +753,8 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
758
753
  ), { responsesToCommit: m, validationErrors: a };
759
754
  }
760
755
  async function s(m) {
761
- const { responsesToCommit: a, validationErrors: c } = await i(m);
762
- return c.length ? { errors: c } : (o.registerBatch(a), { errors: [] });
756
+ const { responsesToCommit: a, validationErrors: c } = await o(m);
757
+ return c.length ? { errors: c } : (i.registerBatch(a), { errors: [] });
763
758
  }
764
759
  const l = e.map((m) => m), p = e.map((m) => Object.keys(m).map((c) => ({
765
760
  fieldId: c,
@@ -769,37 +764,37 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
769
764
  const a = t.fields.getById(m), c = e.map((f) => f[m] || null);
770
765
  return D({ f: a, r: c }, ({ f, r: u }) => u || (f?.defaultValue ? f.defaultValue : null));
771
766
  }
772
- function v(m) {
767
+ function j(m) {
773
768
  const a = t.fields.getByName(m);
774
769
  return D({ f: a, s: e }, ({ f: c, s: f }) => {
775
770
  const u = c && f[c.id] || null;
776
771
  return u || (c?.defaultValue ? c.defaultValue : null);
777
772
  });
778
773
  }
779
- return k({
774
+ return v({
780
775
  clock: r,
781
- target: o.clearAll
782
- }), k({
776
+ target: i.clearAll
777
+ }), v({
783
778
  clock: n,
784
- target: o.clear
779
+ target: i.clear
785
780
  }), {
786
781
  register: d,
787
782
  clearAll: r,
788
783
  clear: n,
789
784
  commit: s,
790
- getResponsesToCommit: i,
785
+ getResponsesToCommit: o,
791
786
  listStore: p,
792
787
  getAllStore: l,
793
788
  getByFieldId: h,
794
- getByFieldName: v
789
+ getByFieldName: j
795
790
  };
796
791
  });
797
792
  function Ze(t) {
798
- return I(Xe, t);
793
+ return b(Xe, t);
799
794
  }
800
- const et = () => "0.0.45-next.4";
795
+ const et = () => "0.0.45-next.5";
801
796
  function tt() {
802
- if (T()) {
797
+ if (N()) {
803
798
  const t = [
804
799
  document.currentScript,
805
800
  document.getElementById("picked_script"),
@@ -814,27 +809,27 @@ function tt() {
814
809
  return "https://api.picked.app";
815
810
  }
816
811
  function rt() {
817
- if (!U())
812
+ if (!T())
818
813
  return {};
819
814
  const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
820
- for (const [o] of t.entries())
821
- o.startsWith("picked-") && r.add(o);
822
- for (const o of r) {
823
- const d = o.replace("picked-", "");
824
- e[d] = t.getAll(o);
815
+ for (const [i] of t.entries())
816
+ i.startsWith("picked-") && r.add(i);
817
+ for (const i of r) {
818
+ const d = i.replace("picked-", "");
819
+ e[d] = t.getAll(i);
825
820
  }
826
821
  const n = A("s");
827
822
  if (r.size > 0)
828
- z.set(n, e);
823
+ O.set(n, e);
829
824
  else {
830
- const o = z.get(n);
831
- if (o)
832
- return o.json() || {};
825
+ const i = O.get(n);
826
+ if (i)
827
+ return i.json() || {};
833
828
  }
834
829
  return e;
835
830
  }
836
831
  function nt() {
837
- if (ue())
832
+ if (de())
838
833
  return crypto.randomUUID();
839
834
  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);
840
835
  return `${t}-${e}-${r}-${n}`;
@@ -843,40 +838,40 @@ const st = A("session", "global"), it = () => {
843
838
  const t = C.get(st);
844
839
  let e;
845
840
  t.isSet() && (e = t.json());
846
- const r = (o) => t.set({
847
- id: o.id,
848
- isUser: o.isUser,
849
- identifiers: o.identifiers
841
+ const r = (i) => t.set({
842
+ id: i.id,
843
+ isUser: i.isUser,
844
+ identifiers: i.identifiers
850
845
  }), n = {
851
846
  id: e?.id ?? nt(),
852
847
  isUser: e?.isUser ?? void 0,
853
848
  identifiers: e?.identifiers ?? void 0,
854
- setIsUser(o) {
855
- this.isUser = o, r(this);
849
+ setIsUser(i) {
850
+ this.isUser = i, r(this);
856
851
  },
857
- setIdentifier(o, d) {
858
- this.identifiers = { ...this.identifiers, [o]: d }, r(this);
852
+ setIdentifier(i, d) {
853
+ this.identifiers = { ...this.identifiers, [i]: d }, r(this);
859
854
  },
860
- removeIdentifier(o) {
855
+ removeIdentifier(i) {
861
856
  this.identifiers && (this.identifiers = Object.fromEntries(
862
- Object.entries(this.identifiers).filter(([d]) => d !== o)
857
+ Object.entries(this.identifiers).filter(([d]) => d !== i)
863
858
  ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
864
859
  }
865
860
  };
866
861
  return r(n), n;
867
- }, ot = () => ce() ? it() : null;
862
+ }, ot = () => ue() ? it() : null;
868
863
  function at() {
869
- if (U())
864
+ if (T())
870
865
  return globalThis.window.pickedConfig;
871
866
  }
872
867
  function ct() {
873
- if (!U())
868
+ if (!T())
874
869
  return;
875
870
  const t = at(), e = t?.organizationId, r = t?.projectId;
876
871
  return e && r ? { organizationId: e, projectId: r } : void 0;
877
872
  }
878
873
  function ut() {
879
- if (!T())
874
+ if (!N())
880
875
  return;
881
876
  const t = document.getElementById("picked_script") || document.querySelector("script#picked") || // legacy support for 'cvly' script tag
882
877
  document.getElementById("cvly");
@@ -892,9 +887,9 @@ function dt(t) {
892
887
  const n = ct();
893
888
  if (n)
894
889
  return n;
895
- const o = ut();
896
- if (o)
897
- return o;
890
+ const i = ut();
891
+ if (i)
892
+ return i;
898
893
  throw new Error(
899
894
  `organizationId and projectId are required. You can provide them via one of:
900
895
  (1) createClient({ organizationId, projectId }) options;
@@ -902,13 +897,13 @@ function dt(t) {
902
897
  (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
903
898
  );
904
899
  }
905
- function O(t) {
900
+ function z(t) {
906
901
  return t == null || t === "" || Number.isNaN(t);
907
902
  }
908
903
  const lt = {
909
- default: (t, e) => O(t) ? String(e ?? "") : String(t),
910
- append: (t, e) => e && !O(t) ? `${t} ${e}` : t,
911
- prepend: (t, e) => e && !O(t) ? `${e} ${t}` : t,
904
+ default: (t, e) => z(t) ? String(e ?? "") : String(t),
905
+ append: (t, e) => e && !z(t) ? `${t} ${e}` : t,
906
+ prepend: (t, e) => e && !z(t) ? `${e} ${t}` : t,
912
907
  upper: (t) => typeof t == "string" ? t.toUpperCase() : t,
913
908
  lower: (t) => typeof t == "string" ? t.toLowerCase() : t,
914
909
  capitalize: (t) => typeof t == "string" ? t.charAt(0).toUpperCase() + t.slice(1) : t,
@@ -919,7 +914,7 @@ const lt = {
919
914
  if (Array.isArray(t))
920
915
  return e.format(t.map(String));
921
916
  if (t instanceof Map) {
922
- const r = Array.from(t.entries()).map(([n, o]) => `${n}: ${o}`);
917
+ const r = Array.from(t.entries()).map(([n, i]) => `${n}: ${i}`);
923
918
  return e.format(r);
924
919
  }
925
920
  return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
@@ -939,88 +934,93 @@ function ft(t, e) {
939
934
  }
940
935
  function gt(t, e) {
941
936
  const r = t.split("|").map((d) => d.trim()), n = r.shift() ?? "";
942
- let o = ft(n, e);
937
+ let i = ft(n, e);
943
938
  for (const d of r) {
944
- const [i, ...s] = d.split(":"), l = i?.trim() ?? "", p = s.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = lt[l];
945
- h && (o = h(o, p));
939
+ const [o, ...s] = d.split(":"), l = o?.trim() ?? "", p = s.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = lt[l];
940
+ h && (i = h(i, p));
946
941
  }
947
- return O(o) ? "" : typeof o == "object" ? JSON.stringify(o) : String(o);
942
+ return z(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
948
943
  }
949
944
  function mt(t, e) {
950
945
  let r = "", n = 0;
951
946
  for (; n < t.length; )
952
947
  if (t[n] === "{" && t[n + 1] === "{") {
953
948
  n += 2;
954
- let o = "";
949
+ let i = "";
955
950
  for (; n < t.length; ) {
956
951
  if (t[n] === "}" && t[n + 1] === "}") {
957
952
  n += 2;
958
953
  break;
959
954
  }
960
- o += t[n++];
955
+ i += t[n++];
961
956
  }
962
- r += gt(o.trim(), e);
957
+ r += gt(i.trim(), e);
963
958
  } else
964
959
  r += t[n++];
965
960
  return r;
966
961
  }
967
962
  class ht {
968
- static logger = w;
963
+ static logger = k;
969
964
  options;
970
965
  isReady = !1;
971
966
  project;
972
967
  plugins = {};
973
- eventBus = V();
968
+ pluginStartHooks = [];
969
+ eventBus = U();
974
970
  events;
975
971
  organizationId;
976
972
  projectId;
977
973
  apiUrl;
974
+ dashboardUrl;
975
+ documentationSiteUrl;
978
976
  session;
979
977
  precondition;
980
978
  condition;
981
979
  searchParams = rt();
982
- history = Ne();
983
- components = be({ client: this });
980
+ history = Ve();
981
+ components = Ie({ client: this });
984
982
  experienceInstances = se({ client: this });
985
- experiences = ge({ client: this });
986
- frameworks = xe({ client: this });
987
- predicates = Oe({ client: this });
983
+ experiences = me({ client: this });
984
+ frameworks = je({ client: this });
985
+ predicates = ze({ client: this });
988
986
  features = Me({ client: this });
989
987
  responses = Ze({ client: this });
990
- fields = Je();
988
+ fields = He();
991
989
  actions = Ke();
992
990
  constructor(e) {
993
- w("info", "Picked client initializing."), this.events = Ue(this.eventBus);
991
+ k("info", "Picked client initializing."), this.events = Te(this.eventBus);
994
992
  const { organizationId: r, projectId: n } = dt(e);
995
- this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), 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.");
993
+ this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: et() }), k("info", "Picked client initialized.");
996
994
  }
997
995
  start = () => {
998
- Be(this), (async () => {
999
- if (!T())
996
+ $e(this), (async () => {
997
+ if (!N())
1000
998
  return;
1001
- let r;
1002
- typeof this.precondition > "u" ? r = !0 : typeof this.precondition == "boolean" ? r = this.precondition : r = await E(this, this.precondition) === !0;
999
+ await this.runPluginStartHooks();
1000
+ const r = await this.evaluateGate(this.precondition);
1003
1001
  let n;
1004
- r && (this.condition === void 0 ? n = !0 : typeof this.condition == "boolean" ? n = this.condition : n = await E(this, this.condition) === !0);
1005
- const o = r && n === !0;
1002
+ r && (n = await this.evaluateGate(this.condition));
1003
+ const i = r && n === !0;
1006
1004
  if (typeof n == "boolean" && this.session) {
1007
1005
  const d = n;
1008
1006
  this.session.setIsUser(d), this.eventBus({ type: "user_decide", value: d });
1009
1007
  }
1010
- if (this.eventBus({ type: "initialize" }), document.body && o && _(this), await ie(), o && _(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1011
- const { id: d, isUser: i, identifiers: s } = this.session;
1012
- this.eventBus({ type: "session", id: d, isUser: i, identifiers: s });
1008
+ if (this.eventBus({ type: "initialize" }), i && L(this), await ie(), i && L(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1009
+ const { id: d, isUser: o, identifiers: s } = this.session;
1010
+ this.eventBus({ type: "session", id: d, isUser: o, identifiers: s });
1013
1011
  }
1014
1012
  })();
1015
1013
  };
1016
1014
  registerFramework = (e) => {
1017
- je(e, this.frameworks);
1015
+ Ee(e, this.frameworks);
1018
1016
  };
1019
1017
  registerComponent = (e, r) => {
1020
- L(e, r, this.components);
1018
+ _(e, r, this.components);
1021
1019
  };
1022
1020
  registerPlugin = (e) => {
1023
- ye(this, e, this.plugins);
1021
+ Se(this, e, this.plugins);
1022
+ const r = this.plugins[e.name];
1023
+ r?.onStart && this.pluginStartHooks.push(r.onStart);
1024
1024
  };
1025
1025
  registerFeature = (e, r) => {
1026
1026
  De(e, r, this.features);
@@ -1029,19 +1029,19 @@ class ht {
1029
1029
  Ce(e, r, this.predicates);
1030
1030
  };
1031
1031
  registerField = (e) => {
1032
- He(e, this.fields);
1032
+ Ge(e, this.fields);
1033
1033
  };
1034
1034
  registerAction = (e, r) => {
1035
1035
  We(e, r, this.actions);
1036
1036
  };
1037
1037
  registerExperience = (e) => {
1038
- e.component && L(`experience:${e.id}`, e.component, this.components), me(e, this.experiences);
1038
+ e.component && _(`experience:${e.id}`, e.component, this.components), he(e, this.experiences);
1039
1039
  };
1040
1040
  getStateSnapshot = () => Y(this);
1041
1041
  launchExperienceById = async (e, r) => {
1042
1042
  const n = this.experiences.getById(e).getState();
1043
1043
  if (!n) {
1044
- w("warn", `Experience with id '${e}' not found.`);
1044
+ k("warn", `Experience with id '${e}' not found.`);
1045
1045
  return;
1046
1046
  }
1047
1047
  W(this, n, r);
@@ -1054,15 +1054,13 @@ class ht {
1054
1054
  else
1055
1055
  return this.launchExperienceById(e, { initialiseOpen: !0 });
1056
1056
  };
1057
- // private async fetchProject() {
1058
- // if (this.project) {
1059
- // return
1060
- // }
1061
- //
1062
- // // todo: fetch project
1063
- //
1064
- // this.project.experiences.forEach((experience) => setupExperience(experience, this.experiences))
1065
- // }
1057
+ async runPluginStartHooks() {
1058
+ for (const e of this.pluginStartHooks)
1059
+ await e();
1060
+ }
1061
+ async evaluateGate(e) {
1062
+ return e === void 0 ? !0 : typeof e == "boolean" ? e : await P(this, e) === !0;
1063
+ }
1066
1064
  setupPlugins() {
1067
1065
  this.options.plugins?.forEach((e) => {
1068
1066
  if (Array.isArray(e)) {
@@ -1082,14 +1080,14 @@ class ht {
1082
1080
  setupFeatures() {
1083
1081
  const e = this.options.features;
1084
1082
  e && (Object.entries(e).forEach(([r, n]) => {
1085
- const o = typeof n == "function" ? n() : n;
1086
- this.registerFeature(r, o);
1083
+ const i = typeof n == "function" ? n() : n;
1084
+ this.registerFeature(r, i);
1087
1085
  }), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
1088
1086
  try {
1089
- const [n, o] = r.split(":");
1090
- if (!n || !o)
1087
+ const [n, i] = r.split(":");
1088
+ if (!n || !i)
1091
1089
  return;
1092
- let d = o;
1090
+ let d = i;
1093
1091
  d === "true" && (d = !0), d === "false" && (d = !1), this.registerFeature(n, {
1094
1092
  key: `${d}`,
1095
1093
  // use the assigned bucket value as the key
@@ -1106,7 +1104,7 @@ class ht {
1106
1104
  const e = this.options.predicates;
1107
1105
  e && Object.entries(e).forEach(([r, n]) => {
1108
1106
  if (typeof n != "function") {
1109
- w("warn", `Predicate "${r}" is not a function.`);
1107
+ k("warn", `Predicate "${r}" is not a function.`);
1110
1108
  return;
1111
1109
  }
1112
1110
  this.registerPredicate(r, n);
@@ -1116,7 +1114,7 @@ class ht {
1116
1114
  const e = this.options.actions;
1117
1115
  e && Object.entries(e).forEach(([r, n]) => {
1118
1116
  if (typeof n != "function") {
1119
- w("warn", `Action "${r}" is not a function.`);
1117
+ k("warn", `Action "${r}" is not a function.`);
1120
1118
  return;
1121
1119
  }
1122
1120
  this.registerAction(r, n);
@@ -1166,7 +1164,7 @@ class ht {
1166
1164
  * // => "Fruits: apple, banana, and cherry"
1167
1165
  */
1168
1166
  renderString = (e, r) => {
1169
- const n = this.responses.listStore.getState().reduce((o, d) => (o[d.fieldId] = d.value, o), {});
1167
+ const n = this.responses.listStore.getState().reduce((i, d) => (i[d.fieldId] = d.value, i), {});
1170
1168
  return mt(e, {
1171
1169
  ...r,
1172
1170
  responses: n
@@ -1179,44 +1177,55 @@ function Q(t) {
1179
1177
  function yt(t) {
1180
1178
  return t.some((e) => e.condition || Q(e));
1181
1179
  }
1182
- async function jt(t, e) {
1180
+ async function Et(t, e) {
1183
1181
  return e.length === 0 || !yt(e) ? e : (await Promise.all(
1184
1182
  e.map(async (n) => {
1185
- if (!(n.condition ? await E(t, n.condition) : !0))
1183
+ if (!(n.condition ? await P(t, n.condition) : !0))
1186
1184
  return null;
1187
1185
  if (!n.options || !Q(n))
1188
1186
  return n;
1189
- const i = (await Promise.all(
1190
- n.options.map(async (l) => l.condition ? await E(t, l.condition) ? l : null : l)
1187
+ const o = (await Promise.all(
1188
+ n.options.map(async (l) => l.condition ? await P(t, l.condition) ? l : null : l)
1191
1189
  )).filter((l) => l !== null);
1192
- return i.length === n.options.length ? n : i.length === 0 ? null : { ...n, options: i };
1190
+ return o.length === n.options.length ? n : o.length === 0 ? null : { ...n, options: o };
1193
1191
  })
1194
1192
  )).filter((n) => n !== null);
1195
1193
  }
1196
- const Et = (t) => {
1194
+ function Pt(t) {
1195
+ return {
1196
+ $$type: "lazy-component",
1197
+ load: t
1198
+ };
1199
+ }
1200
+ function At(t) {
1201
+ return typeof t == "object" && t !== null && "$$type" in t && t.$$type === "lazy-component";
1202
+ }
1203
+ const $t = (t) => {
1197
1204
  const e = new ht(t);
1198
- return de(e), e;
1205
+ return le(e), e;
1199
1206
  };
1200
1207
  export {
1201
1208
  ht as Picked,
1202
- Et as createClient,
1209
+ $t as createClient,
1203
1210
  A as createStorageKey,
1204
- E as evaluateRuleLogic,
1211
+ P as evaluateRuleLogic,
1205
1212
  at as getPickedConfig,
1206
- jt as getStepFields,
1207
- Bt as isPickedRoot,
1213
+ Et as getStepFields,
1214
+ At as isLazyLoader,
1215
+ zt as isPickedRoot,
1216
+ Pt as lazyComponent,
1208
1217
  C as localStore,
1209
- z as sessionStore,
1210
- $t as subscribe,
1211
- Ct as supportsCookies,
1212
- ue as supportsCryptoRandomUUID,
1213
- T as supportsDocument,
1214
- zt as supportsHistory,
1215
- Mt as supportsIntersectionObserver,
1216
- ce as supportsLocalStorage,
1217
- Dt as supportsLocation,
1218
- Vt as supportsSessionStorage,
1219
- Nt as supportsShadowRoot,
1220
- Tt as supportsWebComponents,
1221
- U as supportsWindow
1218
+ O as sessionStore,
1219
+ Ot as subscribe,
1220
+ Dt as supportsCookies,
1221
+ de as supportsCryptoRandomUUID,
1222
+ N as supportsDocument,
1223
+ Ut as supportsHistory,
1224
+ Vt as supportsIntersectionObserver,
1225
+ ue as supportsLocalStorage,
1226
+ Nt as supportsLocation,
1227
+ Tt as supportsSessionStorage,
1228
+ Lt as supportsShadowRoot,
1229
+ _t as supportsWebComponents,
1230
+ T as supportsWindow
1222
1231
  };