@picked/client 0.0.12-next.9 → 0.0.12

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 (29) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/plugins/create-experience/index.js +1 -1
  3. package/dist/cjs/server/index.js +1 -1
  4. package/dist/esm/index.js +481 -535
  5. package/dist/esm/plugins/create-experience/index.js +178 -229
  6. package/dist/esm/server/index.js +1 -1
  7. package/dist/experience-instance-DXWLnF-R.cjs +1 -0
  8. package/dist/experience-instance-XlIuqLrL.js +716 -0
  9. package/dist/types/client.d.ts +0 -26
  10. package/dist/types/client.d.ts.map +1 -1
  11. package/dist/types/entities/experience/experience.d.ts +6 -19
  12. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  13. package/dist/types/entities/experience-instance/experience-instance.d.ts +3 -3
  14. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  15. package/dist/types/entities/feature/feature.d.ts +2 -5
  16. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  17. package/dist/types/picked.d.ts +4 -14
  18. package/dist/types/picked.d.ts.map +1 -1
  19. package/dist/types/plugins/create-experience/create-experience.d.ts +5 -23
  20. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  21. package/dist/types/utils/events.d.ts +4 -10
  22. package/dist/types/utils/events.d.ts.map +1 -1
  23. package/dist/types/utils/nodes.d.ts +1 -2
  24. package/dist/types/utils/nodes.d.ts.map +1 -1
  25. package/package.json +6 -6
  26. package/dist/experience-instance-Bs9t-zff.js +0 -777
  27. package/dist/experience-instance-COUhADSj.cjs +0 -1
  28. package/dist/types/entities/action/action.d.ts +0 -15
  29. package/dist/types/entities/action/action.d.ts.map +0 -1
package/dist/esm/index.js CHANGED
@@ -1,207 +1,206 @@
1
- var W = Object.defineProperty;
2
- var Y = (t, e, r) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var m = (t, e, r) => Y(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { createDomain as I, createApi as x, createEffect as M, attach as J, sample as F, combine as O, createEvent as C } from "effector";
5
- import { createFactory as w, invoke as k } from "@withease/factories";
6
- import { g as U, t as Q, c as X, i as Z, e as A, a as ee, b as te, d as re } from "../experience-instance-Bs9t-zff.js";
7
- import { f as St } from "../experience-instance-Bs9t-zff.js";
1
+ var G = Object.defineProperty;
2
+ var W = (t, e, s) => e in t ? G(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var h = (t, e, s) => W(t, typeof e != "symbol" ? e + "" : e, s);
4
+ import { createDomain as I, createApi as x, createEffect as O, attach as Y, sample as P, combine as A, createEvent as C } from "effector";
5
+ import { createFactory as k, invoke as b } from "@withease/factories";
6
+ import { g as U, t as J, c as Q, e as R, i as X, a as Z, b as ee, d as te } from "../experience-instance-XlIuqLrL.js";
7
+ import { f as gt } from "../experience-instance-XlIuqLrL.js";
8
8
  import { l as v } from "../logger-C9a75KZn.js";
9
- import { c as B, s as $, l as D } from "../storage-Cb_71y48.js";
10
- import { a as wt } from "../storage-Cb_71y48.js";
11
- import { g as se } from "../id-BW-g3y32.js";
12
- import { i as ne } from "../object-JwZ58NOH.js";
13
- import { s as _, a as oe, b as ie, c as ae, d as ce } from "../supports-BjhuLJ8z.js";
14
- import { h as bt, f as It, j as xt, e as Ft, g as Et, i as Pt, k as Bt } from "../supports-BjhuLJ8z.js";
15
- const H = I("experience"), ue = w(
9
+ import { c as $, s as B, l as D } from "../storage-Cb_71y48.js";
10
+ import { a as mt } from "../storage-Cb_71y48.js";
11
+ import { g as re } from "../id-BW-g3y32.js";
12
+ import { i as se } from "../object-JwZ58NOH.js";
13
+ import { s as z, a as ne, b as oe, c as ie, d as ae } from "../supports-BjhuLJ8z.js";
14
+ import { h as yt, f as St, j as wt, e as vt, g as kt, i as bt, k as It } from "../supports-BjhuLJ8z.js";
15
+ const _ = I("experience"), ce = k(
16
16
  ({ client: t, experience: e }) => {
17
- const r = H.store(e), n = x(r, {
18
- merge(l, h) {
17
+ const s = _.store(e), o = x(s, {
18
+ merge(n, d) {
19
19
  return {
20
- ...l,
21
- ...h.experience
20
+ ...n,
21
+ ...d.experience
22
22
  };
23
23
  }
24
- }), c = r.map((l) => ({
25
- name: l.name,
26
- decisionLogic: l.decide,
27
- targetSelectors: l.targets,
28
- initializeOpenLogic: e.initializeOpen
29
- })), u = t.components.listStore.map(
30
- (l) => l.find((h) => h.name === `experience:${e.id}`) || l.find((h) => h.name === "experience"),
24
+ }), i = s.map((n) => ({
25
+ type: n.type,
26
+ name: n.name,
27
+ decisionLogic: n.decide,
28
+ targetSelectors: n.targets
29
+ })), l = t.components.listStore.map(
30
+ (n) => n.find((d) => d.name === `experience:${e.id}`) || n.find((d) => d.name === "experience"),
31
31
  { skipVoid: !1 }
32
- ), s = r.map((l) => ({
33
- steps: l.steps,
34
- nodes: l.nodes,
35
- edges: l.edges,
36
- conditionals: l.conditionals
37
- })), o = e.actions ?? [];
32
+ ), r = s.map((n) => ({
33
+ steps: n.steps,
34
+ nodes: n.nodes,
35
+ edges: n.edges,
36
+ conditionals: n.conditionals
37
+ }));
38
38
  return {
39
39
  id: e.id,
40
- configStore: c,
41
- treeStore: s,
42
- componentStore: u,
43
- actions: o,
44
- merge: n.merge
40
+ configStore: i,
41
+ treeStore: r,
42
+ componentStore: l,
43
+ merge: o.merge
45
44
  };
46
45
  }
47
46
  );
48
- function le(t) {
49
- return k(ue, t);
47
+ function ue(t) {
48
+ return b(ce, t);
50
49
  }
51
- const de = w(({ client: t }) => {
52
- const e = H.store({}), r = x(e, {
53
- register(s, o) {
50
+ const le = k(({ client: t }) => {
51
+ const e = _.store({}), s = x(e, {
52
+ register(r, n) {
54
53
  return {
55
- ...s,
56
- [o.id]: o
54
+ ...r,
55
+ [n.id]: n
57
56
  };
58
57
  }
59
58
  });
60
- function n(s) {
61
- const o = e.getState()[s.id];
62
- if (o) {
63
- o.merge({ experience: s, strategy: "override" });
59
+ function o(r) {
60
+ const n = e.getState()[r.id];
61
+ if (n) {
62
+ n.merge({ experience: r, strategy: "override" });
64
63
  return;
65
64
  }
66
- const l = le({ client: t, experience: s });
67
- r.register(l);
65
+ const d = ue({ client: t, experience: r });
66
+ s.register(d);
68
67
  }
69
- const c = e.map((s) => Object.values(s));
70
- function u(s) {
71
- return e.map((o) => o[s], { skipVoid: !1 });
68
+ const i = e.map((r) => Object.values(r));
69
+ function l(r) {
70
+ return e.map((n) => n[r], { skipVoid: !1 });
72
71
  }
73
72
  return {
74
- register: n,
75
- getById: u,
76
- listStore: c
73
+ register: o,
74
+ getById: l,
75
+ listStore: i
77
76
  };
78
77
  });
79
- function pe(t) {
80
- return k(de, t);
78
+ function de(t) {
79
+ return b(le, t);
81
80
  }
82
- const ge = (t, e) => {
81
+ const pe = (t, e) => {
83
82
  e.register(t);
84
- }, K = (t, e) => {
85
- const { targetSelectors: r } = e.configStore.getState(), n = U(r, e.id);
86
- n.forEach(
87
- ({ elements: u }) => u.forEach((s) => Q(s, e.id))
88
- ), X(n, e.id).forEach((u) => {
89
- t.experienceInstances.spawn(e, u);
83
+ }, H = (t, e) => {
84
+ const { targetSelectors: s } = e.configStore.getState(), o = U(s, e.id);
85
+ o.forEach(
86
+ ({ elements: l }) => l.forEach((r) => J(r, e.id))
87
+ ), Q(o, e.id).forEach((l) => {
88
+ t.experienceInstances.spawn(e, l);
90
89
  });
91
- }, T = async (t) => {
90
+ }, M = async (t) => {
92
91
  await Promise.all(
93
92
  t.experiences.listStore.getState().map(async (e) => {
94
- await fe(t, e) && K(t, e);
93
+ await ge(t, e) && H(t, e);
95
94
  })
96
95
  );
97
- }, fe = async (t, e) => {
98
- const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
99
- return U(n, e.id).length < 1 || n.length === 0 ? !1 : r && Z(r) ? await A(t, r) === !0 : !0;
100
- }, me = (t, e, r) => {
101
- const n = e.name, c = e.setup(t);
102
- if (c) {
103
- const u = r[n] ?? {};
104
- r[n] = Object.freeze({ ...u, ...c });
105
- }
106
- }, he = I("component"), ye = w(
107
- ({ client: t, component: e, name: r }) => {
108
- const n = t.frameworks.getByName(e.frameworkName);
96
+ }, ge = async (t, e) => {
97
+ const { type: s, decisionLogic: o, targetSelectors: i } = e.configStore.getState();
98
+ return U(i, e.id).length < 1 ? !1 : s === "funnel" ? o ? await R(t, o) === !0 : !1 : i.length === 0 ? !1 : X(o) ? await R(t, o) === !0 : !0;
99
+ }, fe = (t, e, s) => {
100
+ const o = e.name, i = e.setup(t);
101
+ if (i) {
102
+ const l = s[o] ?? {};
103
+ s[o] = Object.freeze({ ...l, ...i });
104
+ }
105
+ }, me = I("component"), he = k(
106
+ ({ client: t, component: e, name: s }) => {
107
+ const o = t.frameworks.getByName(e.frameworkName);
109
108
  return {
110
- name: r,
109
+ name: s,
111
110
  component: e,
112
- frameworkStore: n
111
+ frameworkStore: o
113
112
  };
114
113
  }
115
114
  );
116
- function Se(t) {
117
- return k(ye, t);
115
+ function ye(t) {
116
+ return b(he, t);
118
117
  }
119
- const ve = w(({ client: t }) => {
120
- const e = he.store({}), r = x(e, {
121
- register(s, o) {
118
+ const Se = k(({ client: t }) => {
119
+ const e = me.store({}), s = x(e, {
120
+ register(r, n) {
122
121
  return {
123
- ...s,
124
- [o.name]: o
122
+ ...r,
123
+ [n.name]: n
125
124
  };
126
125
  }
127
126
  });
128
- function n(s, o) {
129
- e.getState()[s] && v(
127
+ function o(r, n) {
128
+ e.getState()[r] && v(
130
129
  "warn",
131
- `Component '${s}' already registered. Registering again will override the previous registration.`
130
+ `Component '${r}' already registered. Registering again will override the previous registration.`
132
131
  );
133
- const h = Se({ client: t, name: s, component: o });
134
- r.register(h);
132
+ const y = ye({ client: t, name: r, component: n });
133
+ s.register(y);
135
134
  }
136
- const c = e.map((s) => Object.values(s));
137
- function u(s) {
138
- return e.map((o) => o[s], { skipVoid: !1 });
135
+ const i = e.map((r) => Object.values(r));
136
+ function l(r) {
137
+ return e.map((n) => n[r], { skipVoid: !1 });
139
138
  }
140
139
  return {
141
- register: n,
142
- getByName: u,
143
- listStore: c
140
+ register: o,
141
+ getByName: l,
142
+ listStore: i
144
143
  };
145
144
  });
146
145
  function we(t) {
147
- return k(ve, t);
146
+ return b(Se, t);
148
147
  }
149
- const V = (t, e, r) => {
150
- r.register(t, e);
151
- }, ke = I("framework"), be = w(({ client: t }) => {
152
- const e = ke.store({}), r = x(e, {
153
- register(s, o) {
148
+ const T = (t, e, s) => {
149
+ s.register(t, e);
150
+ }, ve = I("framework"), ke = k(({ client: t }) => {
151
+ const e = ve.store({}), s = x(e, {
152
+ register(r, n) {
154
153
  return {
155
- ...s,
156
- [o.name]: o.framework
154
+ ...r,
155
+ [n.name]: n.framework
157
156
  };
158
157
  }
159
158
  });
160
- function n(s, o) {
161
- e.getState()[s] && v(
159
+ function o(r, n) {
160
+ e.getState()[r] && v(
162
161
  "warn",
163
- `Framework '${s}' already registered. Registering again will override the previous registration.`
164
- ), r.register({ name: s, framework: o });
162
+ `Framework '${r}' already registered. Registering again will override the previous registration.`
163
+ ), s.register({ name: r, framework: n });
165
164
  }
166
- const c = e.map((s) => Object.values(s));
167
- function u(s) {
168
- return e.map((o) => o[s], { skipVoid: !1 });
165
+ const i = e.map((r) => Object.values(r));
166
+ function l(r) {
167
+ return e.map((n) => n[r], { skipVoid: !1 });
169
168
  }
170
169
  return {
171
- register: n,
172
- getByName: u,
173
- listStore: c
170
+ register: o,
171
+ getByName: l,
172
+ listStore: i
174
173
  };
175
174
  });
176
- function Ie(t) {
177
- return k(be, t);
175
+ function be(t) {
176
+ return b(ke, t);
178
177
  }
179
- const xe = (t, e) => {
178
+ const Ie = (t, e) => {
180
179
  e.register(t.name, t);
181
- }, Fe = 6e3, N = B("last_ping", "global"), Ee = (t) => `${t}/api/v1/ping`, Pe = async (t) => {
180
+ }, xe = 6e3, V = $("last_ping", "global"), Fe = (t) => `${t}/api/v1/ping`, Ee = async (t) => {
182
181
  try {
183
- const e = Date.now(), r = localStorage.getItem(N);
184
- if (r && e - parseInt(r) < Fe)
182
+ const e = Date.now(), s = localStorage.getItem(V);
183
+ if (s && e - parseInt(s) < xe)
185
184
  return !0;
186
- const n = Ee(t.apiUrl), c = {
185
+ const o = Fe(t.apiUrl), i = {
187
186
  projectId: t.projectId,
188
187
  path: window.location.pathname
189
- }, u = JSON.stringify(c), s = {
188
+ }, l = JSON.stringify(i), r = {
190
189
  "Content-Type": "application/json"
191
- }, o = document.getElementById("picked_script"), l = o == null ? void 0 : o.dataset.verceltoken;
192
- l && (s["x-vercel-protection-bypass"] = l);
193
- const S = (await fetch(n, {
190
+ }, n = document.getElementById("picked_script"), d = n == null ? void 0 : n.dataset.verceltoken;
191
+ d && (r["x-vercel-protection-bypass"] = d);
192
+ const c = (await fetch(o, {
194
193
  method: "POST",
195
- headers: s,
196
- body: u
194
+ headers: r,
195
+ body: l
197
196
  })).ok;
198
- return S && localStorage.setItem(N, e.toString()), S;
197
+ return c && localStorage.setItem(V, e.toString()), c;
199
198
  } catch (e) {
200
199
  return v("error", e), !1;
201
200
  }
202
201
  };
203
- function Be(t) {
204
- const e = typeof window < "u", r = {
202
+ function Pe(t) {
203
+ const e = typeof window < "u", s = {
205
204
  client: t,
206
205
  responses: t.responses.listStore.getState(),
207
206
  fields: t.fields.listStore.getState(),
@@ -210,418 +209,379 @@ function Be(t) {
210
209
  sessionStorage: e ? window.sessionStorage : void 0,
211
210
  localStorage: e ? window.localStorage : void 0
212
211
  };
213
- return Object.freeze(r);
212
+ return Object.freeze(s);
214
213
  }
215
- const Re = I("predicate"), Ae = w(({ client: t }) => {
216
- const e = Re.store({}), r = x(e, {
217
- register(s, o) {
214
+ const Re = I("predicate"), $e = k(({ client: t }) => {
215
+ const e = Re.store({}), s = x(e, {
216
+ register(r, n) {
218
217
  return {
219
- ...s,
220
- [o.name]: {
221
- name: o.name,
222
- predicate: o.predicate
218
+ ...r,
219
+ [n.name]: {
220
+ name: n.name,
221
+ predicate: n.predicate
223
222
  }
224
223
  };
225
224
  }
226
225
  });
227
- function n(s, o) {
228
- e.getState()[s] && v(
226
+ function o(r, n) {
227
+ e.getState()[r] && v(
229
228
  "warn",
230
- `Predicate '${s}' already registered. Registering again will override the previous registration.`
231
- ), r.register(Object.freeze({ name: s, predicate: o }));
229
+ `Predicate '${r}' already registered. Registering again will override the previous registration.`
230
+ ), s.register(Object.freeze({ name: r, predicate: n }));
232
231
  }
233
- const c = e.map((s) => Object.values(s));
234
- function u(s) {
235
- return e.map((o) => o[s], { skipVoid: !1 });
232
+ const i = e.map((r) => Object.values(r));
233
+ function l(r) {
234
+ return e.map((n) => n[r], { skipVoid: !1 });
236
235
  }
237
236
  return {
238
- register: n,
239
- getByName: u,
240
- listStore: c
237
+ register: o,
238
+ getByName: l,
239
+ listStore: i
241
240
  };
242
241
  });
243
- function $e(t) {
244
- return k(Ae, t);
242
+ function Be(t) {
243
+ return b($e, t);
245
244
  }
246
- const je = (t, e, r) => {
247
- r.register(t, e);
248
- }, z = I("feature"), Oe = w(({ client: t }) => {
249
- const e = z.store({}), r = z.store([]), n = x(e, {
250
- register(d, a) {
245
+ const je = (t, e, s) => {
246
+ s.register(t, e);
247
+ }, N = I("feature"), Ae = k(() => {
248
+ const t = N.store({}), e = N.store([]), s = x(t, {
249
+ register(c, f) {
251
250
  return {
252
- ...d,
253
- [a.id]: a.feature
251
+ ...c,
252
+ [f.id]: f.feature
254
253
  };
255
254
  }
256
255
  });
257
- function c(d, a) {
258
- e.getState()[d] && v(
256
+ function o(c, f) {
257
+ t.getState()[c] && v(
259
258
  "warn",
260
- `Feature '${d}' already registered. Registering again will override the previous registration.`
259
+ `Feature '${c}' already registered. Registering again will override the previous registration.`
261
260
  );
262
- const g = {
263
- id: d,
261
+ const p = {
262
+ id: c,
264
263
  feature: {
265
- ...a,
266
- id: d
264
+ ...f,
265
+ id: c
267
266
  }
268
267
  };
269
- n.register(
268
+ s.register(
270
269
  Object.freeze({
271
- id: d,
272
- feature: g
270
+ id: c,
271
+ feature: p
273
272
  })
274
273
  );
275
274
  }
276
- const u = M(
275
+ const i = O(
277
276
  async ({
278
- id: d,
279
- key: a,
280
- storage: i = "local"
277
+ id: c,
278
+ key: f,
279
+ storage: a = "local"
281
280
  }) => {
282
- const g = B(`feature:${d}:${a}`, "global"), p = (i === "session" ? $ : D).get(g).boolean();
283
- return p === null ? null : { id: d, key: a, bucket: p };
281
+ const p = $(`feature:${c}:${f}`, "global"), m = (a === "session" ? B : D).get(p).boolean();
282
+ if (m !== null)
283
+ return { id: c, bucket: m };
284
284
  }
285
- ), s = M((d) => {
286
- if (!d)
285
+ ), l = O((c) => {
286
+ if (!c)
287
287
  return null;
288
- const a = B(`feature:${d.id}:${d.key}`, "global");
289
- (d.storage === "session" ? $ : D).set(a, d.bucket);
290
- }), o = /* @__PURE__ */ new Map(), l = J({
291
- source: { allFeaturesStore: e, resolvedFeaturesStore: r },
292
- effect: async ({ allFeaturesStore: d, resolvedFeaturesStore: a }, { id: i, decide: g, key: f }) => {
293
- const p = a.find((j) => j.id === i);
294
- if (p)
295
- return p;
296
- const y = d[i];
297
- if (!y)
298
- throw new Error(`Feature with id '${i}' not found`);
299
- const b = o.get(`${i}:${f}`);
300
- if (b !== void 0) {
301
- const j = await b;
302
- return { id: y.id, bucket: j, key: f, storage: y.feature.storage };
288
+ const f = $(`feature:${c.id}:${c.key}`, "global");
289
+ (c.storage === "session" ? B : D).set(f, c.bucket);
290
+ }), r = /* @__PURE__ */ new Map(), n = Y({
291
+ source: { allFeaturesStore: t, resolvedFeaturesStore: e },
292
+ effect: async ({ allFeaturesStore: c, resolvedFeaturesStore: f }, { id: a, decide: p, key: g }) => {
293
+ const m = f.find((F) => F.id === a);
294
+ if (m)
295
+ return m;
296
+ const u = c[a];
297
+ if (!u)
298
+ throw new Error(`Feature with id '${a}' not found`);
299
+ const S = r.get(`${a}:${g}`);
300
+ if (S !== void 0) {
301
+ const F = await S;
302
+ return { id: u.id, bucket: F, storage: u.feature.storage };
303
303
  }
304
- const R = g();
305
- o.set(`${i}:${f}`, R);
306
- const E = await R;
307
- return { id: y.id, bucket: E, key: f, storage: y.feature.storage };
304
+ const w = p();
305
+ r.set(`${a}:${g}`, w);
306
+ const j = await w;
307
+ return { id: u.id, bucket: j, storage: u.feature.storage };
308
308
  }
309
309
  });
310
- F({
311
- clock: n.register,
312
- fn: (d) => {
313
- const { id: a, feature: i } = d;
314
- return { id: a, key: i.feature.key, storage: i.feature.storage };
310
+ P({
311
+ clock: s.register,
312
+ fn: (c) => {
313
+ const { id: f, feature: a } = c;
314
+ return { id: f, key: a.feature.key, storage: a.feature.storage };
315
315
  },
316
- target: u
317
- }), F({
316
+ target: i
317
+ }), P({
318
318
  source: e,
319
- clock: l.doneData,
320
- fn: (d, a) => {
321
- var y;
322
- const { id: i, bucket: g, storage: f } = a, p = (y = d[i]) == null ? void 0 : y.feature.key;
323
- return p ? { key: p, id: i, bucket: g, storage: f } : null;
319
+ clock: [i.doneData, n.doneData],
320
+ fn: (c, f) => !f || c.some((a) => a.id === f.id) ? c : [...c, f],
321
+ target: e
322
+ }), P({
323
+ source: t,
324
+ clock: n.doneData,
325
+ fn: (c, f) => {
326
+ var u;
327
+ const { id: a, bucket: p, storage: g } = f, m = (u = c[a]) == null ? void 0 : u.feature.key;
328
+ return m ? { key: m, id: a, bucket: p, storage: g } : null;
324
329
  },
325
- target: s
330
+ target: l
326
331
  });
327
- const h = O({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
332
+ const d = A({ allFeaturesStore: t, resolvedFeaturesStore: e }).map(
328
333
  ({
329
- allFeaturesStore: d,
330
- resolvedFeaturesStore: a
331
- }) => Object.values(d).map((i) => {
332
- const g = a.find((f) => f.id === i.id);
333
- return g ? {
334
- id: i.id,
335
- name: i.feature.name,
336
- key: i.feature.key,
337
- getBucket: () => ({ id: i.id, bucket: g.bucket }),
334
+ allFeaturesStore: c,
335
+ resolvedFeaturesStore: f
336
+ }) => Object.values(c).map((a) => {
337
+ const p = f.find((g) => g.id === a.id);
338
+ return p ? {
339
+ id: a.id,
340
+ name: a.feature.name,
341
+ key: a.feature.key,
342
+ getBucket: () => ({ id: a.id, bucket: p.bucket }),
338
343
  isResolved: !0
339
344
  } : {
340
- id: i.id,
341
- name: i.feature.name,
342
- key: i.feature.key,
343
- getBucket: async () => await l(i.feature),
345
+ id: a.id,
346
+ name: a.feature.name,
347
+ key: a.feature.key,
348
+ getBucket: async () => await n(a.feature),
344
349
  isResolved: !1
345
350
  };
346
351
  })
347
352
  );
348
- F({
349
- clock: l.doneData,
350
- source: { resolvedFeatures: r },
351
- filter: ({ resolvedFeatures: d }, { id: a }) => !d.some((i) => i.id === a),
352
- fn: (d, a) => a,
353
- target: t.eventBus.prepend((d) => ({
354
- type: "feature_decide",
355
- feature: d
356
- }))
357
- }), F({
358
- clock: [u.doneData, l.doneData],
359
- source: r,
360
- fn: (d, a) => !a || d.some((i) => i.id === a.id) ? d : [...d, a],
361
- target: r
362
- });
363
- function S(d) {
364
- return e.map((a) => a[d], { skipVoid: !1 });
353
+ function y(c) {
354
+ return t.map((f) => f[c], { skipVoid: !1 });
365
355
  }
366
356
  return {
367
- register: c,
368
- getByName: S,
369
- listStore: h
357
+ register: o,
358
+ getByName: y,
359
+ listStore: d
370
360
  };
371
361
  });
372
- function Ce(t) {
373
- return k(Oe, t);
362
+ function Ce() {
363
+ return b(Ae);
374
364
  }
375
- const De = (t, e, r) => {
376
- r.register(t, e);
377
- }, P = I("history");
365
+ const De = (t, e, s) => {
366
+ s.register(t, e);
367
+ }, E = I("history");
378
368
  function L(t, e) {
379
369
  return {
380
370
  // eslint-disable-next-line sonarjs/pseudo-random
381
- id: se(`history-entry-${Date.now()}-${Math.random()}}`),
371
+ id: re(`history-entry-${Date.now()}-${Math.random()}}`),
382
372
  node: e,
383
373
  at: Date.now(),
384
374
  experienceId: t
385
375
  };
386
376
  }
387
- const Me = w(() => {
388
- const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), c = P.event();
389
- t.on(e, (s, o) => ({
390
- entries: [...s.entries, L(o.experienceId, o.node)]
391
- })), t.on(r, (s, o) => ({
377
+ const Oe = k(() => {
378
+ const t = E.store({ entries: [] }), e = E.event(), s = E.event(), o = E.event(), i = E.event();
379
+ t.on(e, (r, n) => ({
380
+ entries: [...r.entries, L(n.experienceId, n.node)]
381
+ })), t.on(s, (r, n) => ({
392
382
  entries: [
393
- ...s.entries.slice(0, -1),
394
- L(o.experienceId, o.node)
383
+ ...r.entries.slice(0, -1),
384
+ L(n.experienceId, n.node)
395
385
  ]
396
- })), t.on(c, (s, o) => o);
397
- function u(s, o) {
398
- const l = { lastStepIndex: -1, secondLastStepIndex: -1 };
399
- for (let h = s.length - 1; h >= 0; h--) {
400
- const S = s[h], d = S == null ? void 0 : S.node;
401
- if (!(!d || !ee(d)) && !(o && (S == null ? void 0 : S.experienceId) !== o))
402
- if (l.lastStepIndex === -1)
403
- l.lastStepIndex = h;
386
+ })), t.on(i, (r, n) => n);
387
+ function l(r, n) {
388
+ const d = { lastStepIndex: -1, secondLastStepIndex: -1 };
389
+ for (let y = r.length - 1; y >= 0; y--) {
390
+ const c = r[y], f = c == null ? void 0 : c.node;
391
+ if (!(!f || !Z(f)) && !(n && (c == null ? void 0 : c.experienceId) !== n))
392
+ if (d.lastStepIndex === -1)
393
+ d.lastStepIndex = y;
404
394
  else {
405
- l.secondLastStepIndex = h;
395
+ d.secondLastStepIndex = y;
406
396
  break;
407
397
  }
408
398
  }
409
- return l;
399
+ return d;
410
400
  }
411
- return t.on(n, (s, o) => {
412
- const { secondLastStepIndex: l } = u(s.entries, o.experienceId), h = l !== -1 ? s.entries.slice(0, l + 1) : s.entries;
401
+ return t.on(o, (r, n) => {
402
+ const { secondLastStepIndex: d } = l(r.entries, n.experienceId), y = d !== -1 ? r.entries.slice(0, d + 1) : r.entries;
413
403
  return {
414
- ...s,
415
- entries: h
404
+ ...r,
405
+ entries: y
416
406
  };
417
407
  }), {
418
408
  push: e,
419
- replace: r,
420
- back: n,
421
- restore: c,
422
- entriesStore: t.map((s) => s.entries)
409
+ replace: s,
410
+ back: o,
411
+ restore: i,
412
+ entriesStore: t.map((r) => r.entries)
423
413
  };
424
414
  });
425
- function Te() {
426
- return k(Me);
415
+ function Me() {
416
+ return b(Oe);
427
417
  }
428
- const Ve = () => C(), Ne = I("field"), ze = w(() => {
429
- const t = Ne.store({}), e = x(t, {
430
- register(s, o) {
418
+ const Te = () => C(), Ve = I("field"), Ne = k(() => {
419
+ const t = Ve.store({}), e = x(t, {
420
+ register(r, n) {
431
421
  return {
432
- ...s,
433
- [o.field.id]: o.field
422
+ ...r,
423
+ [n.field.id]: n.field
434
424
  };
435
425
  }
436
426
  });
437
- function r(s) {
438
- e.register({ field: s });
427
+ function s(r) {
428
+ e.register({ field: r });
439
429
  }
440
- const n = t.map((s) => Object.values(s));
441
- function c(s) {
442
- return t.map((o) => o[s] || null);
430
+ const o = t.map((r) => Object.values(r));
431
+ function i(r) {
432
+ return t.map((n) => n[r] || null);
443
433
  }
444
- function u(s) {
445
- return t.map((o) => Object.values(o).find((l) => l.name === s) || null);
434
+ function l(r) {
435
+ return t.map((n) => Object.values(n).find((d) => d.name === r) || null);
446
436
  }
447
437
  return {
448
- register: r,
449
- getById: c,
450
- listStore: n,
451
- getByName: u
438
+ register: s,
439
+ getById: i,
440
+ listStore: o,
441
+ getByName: l
452
442
  };
453
443
  });
454
444
  function Le() {
455
- return k(ze);
445
+ return b(Ne);
456
446
  }
457
447
  const Ue = (t, e) => {
458
448
  e.register(t);
459
- }, _e = I("action"), He = w(() => {
460
- const t = _e.store({}), e = x(t, {
461
- register(u, s) {
462
- return {
463
- ...u,
464
- [s.name]: {
465
- name: s.name,
466
- action: s.action
467
- }
468
- };
469
- }
470
- });
471
- function r(u, s) {
472
- e.register({ name: u, action: s });
473
- }
474
- const n = t.map((u) => Object.values(u));
475
- function c(u) {
476
- return t.map((s) => s[u], { skipVoid: !1 });
477
- }
478
- return {
479
- register: r,
480
- getByName: c,
481
- listStore: n
482
- };
483
- });
484
- function Ke() {
485
- return k(He);
486
- }
487
- const qe = (t, e, r) => {
488
- r.register(t, e);
489
- }, Ge = I("response"), We = w(({ client: t }) => {
490
- const e = Ge.store({}), r = C(), n = C(), c = x(e, {
491
- register(a, i) {
449
+ }, ze = I("response"), _e = k(({ client: t }) => {
450
+ const e = ze.store({}), s = C(), o = C(), i = x(e, {
451
+ register(a, p) {
492
452
  return {
493
453
  ...a,
494
- [i.fieldId]: i.response
454
+ [p.fieldId]: p.response
495
455
  };
496
456
  },
497
- registerBatch(a, i) {
457
+ registerBatch(a, p) {
498
458
  return {
499
459
  ...a,
500
- ...i
460
+ ...p
501
461
  };
502
462
  },
503
- clear(a, i) {
504
- const { [i]: g, ...f } = a;
505
- return f;
463
+ clear(a, p) {
464
+ const { [p]: g, ...m } = a;
465
+ return m;
506
466
  },
507
467
  clearAll() {
508
468
  return {};
509
469
  }
510
470
  });
511
- function u(a, i) {
512
- c.register({ fieldId: a, response: i });
471
+ function l(a, p) {
472
+ i.register({ fieldId: a, response: p });
513
473
  }
514
- async function s(a) {
515
- const i = [];
474
+ async function r(a) {
475
+ const p = [];
516
476
  return await Promise.allSettled(
517
- Object.entries(a).map(async ([g, f]) => {
518
- let p = f;
519
- const y = t.fields.getById(g).getState();
520
- if (!y) {
521
- i.push({
477
+ Object.entries(a).map(async ([g, m]) => {
478
+ let u = m;
479
+ const S = t.fields.getById(g).getState();
480
+ if (!S) {
481
+ p.push({
522
482
  fieldId: g,
523
483
  userMessage: `Field '${g}' not found`,
524
484
  systemMessage: `No field with ID '${g}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
525
- value: p
485
+ value: u
526
486
  });
527
487
  return;
528
488
  }
529
- if (y.multiple && (typeof p == "string" || typeof p == "number" || typeof p == "boolean") && (p = [p]), y.validation && !ne(y.validation)) {
530
- const b = await A(t, y.validation, {
531
- $input: p
489
+ if (S.multiple && (typeof u == "string" || typeof u == "number" || typeof u == "boolean") && (u = [u]), S.validation && !se(S.validation)) {
490
+ const w = await R(t, S.validation, {
491
+ $input: u
532
492
  });
533
- if (typeof b == "string") {
534
- i.push({
493
+ if (typeof w == "string") {
494
+ p.push({
535
495
  fieldId: g,
536
- userMessage: b,
537
- systemMessage: `Field validation resulted in an error: ${b}.`,
538
- value: p
496
+ userMessage: w,
497
+ systemMessage: `Field validation resulted in an error: ${w}.`,
498
+ value: u
539
499
  });
540
500
  return;
541
501
  }
542
- if (b === !1) {
543
- i.push({
502
+ if (w === !1) {
503
+ p.push({
544
504
  fieldId: g,
545
505
  userMessage: "This field is invalid",
546
506
  systemMessage: "Field validation resulted in an unspecified error.",
547
- value: p
507
+ value: u
548
508
  });
549
509
  return;
550
510
  }
551
511
  }
552
- if (y.required && (typeof p > "u" || p === null || p === "" || Array.isArray(p) && !p.length)) {
553
- i.push({
512
+ if (S.required && (typeof u > "u" || u === null || u === "" || Array.isArray(u) && !u.length)) {
513
+ p.push({
554
514
  fieldId: g,
555
515
  userMessage: "This field is required",
556
516
  systemMessage: "Field is required.",
557
- value: p
517
+ value: u
558
518
  });
559
519
  return;
560
520
  }
561
- if (!y.multiple && Array.isArray(p) && p.length > 1) {
562
- i.push({
521
+ if (!S.multiple && Array.isArray(u) && u.length > 1) {
522
+ p.push({
563
523
  fieldId: g,
564
524
  userMessage: "This field expects a single response",
565
525
  systemMessage: "Field expects a single response.",
566
- value: p
526
+ value: u
567
527
  });
568
528
  return;
569
529
  }
570
- if (y.options) {
571
- const b = y.options.map((E) => E.value), R = Array.isArray(p) ? p : [p];
572
- Array.isArray(p) && (R.every((E) => b.includes(E)) || i.push({
530
+ if (S.options) {
531
+ const w = S.options.map((F) => F.value), j = Array.isArray(u) ? u : [u];
532
+ Array.isArray(u) && (j.every((F) => w.includes(F)) || p.push({
573
533
  fieldId: g,
574
534
  userMessage: "This field expects a valid option",
575
- systemMessage: `Field expects a valid option. Valid options are: ${b.join(", ")}`,
576
- value: p
535
+ systemMessage: `Field expects a valid option. Valid options are: ${w.join(", ")}`,
536
+ value: u
577
537
  }));
578
538
  }
579
539
  })
580
- ), { responsesToCommit: a, validationErrors: i };
540
+ ), { responsesToCommit: a, validationErrors: p };
581
541
  }
582
- async function o(a) {
583
- const { responsesToCommit: i, validationErrors: g } = await s(a);
584
- return g.length ? { errors: g } : (c.registerBatch(i), { errors: [] });
542
+ async function n(a) {
543
+ const { responsesToCommit: p, validationErrors: g } = await r(a);
544
+ return g.length ? { errors: g } : (i.registerBatch(p), { errors: [] });
585
545
  }
586
- const l = e.map((a) => a), h = e.map((a) => Object.keys(a).map((g) => ({
546
+ const d = e.map((a) => a), y = e.map((a) => Object.keys(a).map((g) => ({
587
547
  fieldId: g,
588
548
  value: a[g]
589
549
  })));
590
- function S(a) {
591
- const i = t.fields.getById(a), g = e.map((f) => f[a] || null);
592
- return O({ f: i, r: g }, ({ f, r: p }) => p || (f != null && f.defaultValue ? f.defaultValue : null));
593
- }
594
- function d(a) {
595
- const i = t.fields.getByName(a);
596
- return O({ f: i, s: e }, ({ f: g, s: f }) => {
597
- const p = g && f[g.id] || null;
598
- return p || (g != null && g.defaultValue ? g.defaultValue : null);
550
+ function c(a) {
551
+ const p = t.fields.getById(a), g = e.map((m) => m[a] || null);
552
+ return A({ f: p, r: g }, ({ f: m, r: u }) => u || (m != null && m.defaultValue ? m.defaultValue : null));
553
+ }
554
+ function f(a) {
555
+ const p = t.fields.getByName(a);
556
+ return A({ f: p, s: e }, ({ f: g, s: m }) => {
557
+ const u = g && m[g.id] || null;
558
+ return u || (g != null && g.defaultValue ? g.defaultValue : null);
599
559
  });
600
560
  }
601
- return F({
602
- clock: r,
603
- target: c.clearAll
604
- }), F({
605
- clock: n,
606
- target: c.clear
561
+ return P({
562
+ clock: s,
563
+ target: i.clearAll
564
+ }), P({
565
+ clock: o,
566
+ target: i.clear
607
567
  }), {
608
- register: u,
609
- clearAll: r,
610
- clear: n,
611
- commit: o,
612
- getResponsesToCommit: s,
613
- listStore: h,
614
- getAllStore: l,
615
- getByFieldId: S,
616
- getByFieldName: d
568
+ register: l,
569
+ clearAll: s,
570
+ clear: o,
571
+ commit: n,
572
+ getResponsesToCommit: r,
573
+ listStore: y,
574
+ getAllStore: d,
575
+ getByFieldId: c,
576
+ getByFieldName: f
617
577
  };
618
578
  });
619
- function Ye(t) {
620
- return k(We, t);
579
+ function He(t) {
580
+ return b(_e, t);
621
581
  }
622
- const Je = () => "0.0.12-next.9";
623
- function Qe() {
624
- if (_()) {
582
+ const Ke = () => "0.0.12";
583
+ function qe() {
584
+ if (z()) {
625
585
  const t = [
626
586
  document.currentScript,
627
587
  document.getElementById("picked_script"),
@@ -635,103 +595,99 @@ function Qe() {
635
595
  }
636
596
  return "https://api.picked.app";
637
597
  }
638
- function Xe() {
639
- if (!oe())
598
+ function Ge() {
599
+ if (!ne())
640
600
  return {};
641
- const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
642
- for (const [c] of t.entries())
643
- c.startsWith("picked-") && r.add(c);
644
- for (const c of r) {
645
- const u = c.replace("picked-", "");
646
- e[u] = t.getAll(c);
647
- }
648
- const n = B("s");
649
- if (r.size > 0)
650
- $.set(n, e);
601
+ const t = new URLSearchParams(window.location.search), e = {}, s = /* @__PURE__ */ new Set();
602
+ for (const [i] of t.entries())
603
+ i.startsWith("picked-") && s.add(i);
604
+ for (const i of s) {
605
+ const l = i.replace("picked-", "");
606
+ e[l] = t.getAll(i);
607
+ }
608
+ const o = $("s");
609
+ if (s.size > 0)
610
+ B.set(o, e);
651
611
  else {
652
- const c = $.get(n);
653
- if (c)
654
- return c.json() || {};
612
+ const i = B.get(o);
613
+ if (i)
614
+ return i.json() || {};
655
615
  }
656
616
  return e;
657
617
  }
658
- function Ze() {
659
- if (ae())
618
+ function We() {
619
+ if (ie())
660
620
  return crypto.randomUUID();
661
- 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);
662
- return `${t}-${e}-${r}-${n}`;
621
+ const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15), o = Math.random().toString(36).substring(2, 15);
622
+ return `${t}-${e}-${s}-${o}`;
663
623
  }
664
- const et = () => ({
665
- id: Ze()
666
- }), tt = B("session", "global"), rt = () => {
667
- if (!ie()) return null;
668
- const t = D.get(tt);
624
+ const Ye = () => ({
625
+ id: We()
626
+ }), Je = $("session", "global"), Qe = () => {
627
+ if (!oe()) return null;
628
+ const t = D.get(Je);
669
629
  let e = t.isSet() ? t.json() : null;
670
- return e || (e = et(), t.set(e)), e;
671
- }, st = () => rt();
672
- class q {
630
+ return e || (e = Ye(), t.set(e)), e;
631
+ }, Xe = () => Qe();
632
+ class K {
673
633
  constructor(e) {
674
- m(this, "options");
675
- m(this, "isReady", !1);
676
- m(this, "project");
677
- m(this, "plugins", {});
678
- m(this, "eventBus", Ve());
679
- m(this, "organizationId");
680
- m(this, "projectId");
681
- m(this, "apiUrl");
682
- m(this, "session");
683
- m(this, "searchParams", Xe());
684
- m(this, "history", Te());
685
- m(this, "components", we({ client: this }));
686
- m(this, "experienceInstances", te({ client: this }));
687
- m(this, "experiences", pe({ client: this }));
688
- m(this, "frameworks", Ie({ client: this }));
689
- m(this, "predicates", $e({ client: this }));
690
- m(this, "features", Ce({ client: this }));
691
- m(this, "responses", Ye({ client: this }));
692
- m(this, "fields", Le());
693
- m(this, "actions", Ke());
694
- v("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Qe(), this.session = st(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.eventBus({ type: "initialized", version: Je() }), v("info", "Picked client initialized.");
634
+ h(this, "options");
635
+ h(this, "isReady", !1);
636
+ h(this, "project");
637
+ h(this, "plugins", {});
638
+ h(this, "eventBus", Te());
639
+ h(this, "organizationId");
640
+ h(this, "projectId");
641
+ h(this, "apiUrl");
642
+ h(this, "session");
643
+ h(this, "searchParams", Ge());
644
+ h(this, "history", Me());
645
+ h(this, "components", we({ client: this }));
646
+ h(this, "experienceInstances", ee({ client: this }));
647
+ h(this, "experiences", de({ client: this }));
648
+ h(this, "frameworks", be({ client: this }));
649
+ h(this, "predicates", Be({ client: this }));
650
+ h(this, "features", Ce());
651
+ h(this, "responses", He({ client: this }));
652
+ h(this, "fields", Le());
653
+ v("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || qe(), this.session = Xe(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.eventBus({ type: "initialized", version: Ke() }), v("info", "Picked client initialized.");
695
654
  }
696
655
  start() {
697
- Pe(this), (async () => {
698
- _() && (document.body && T(this), await re(), await T(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session }));
656
+ Ee(this), (async () => {
657
+ z() && (document.body && M(this), await te(), await M(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session }));
699
658
  })();
700
659
  }
701
660
  registerFramework(e) {
702
- xe(e, this.frameworks);
661
+ Ie(e, this.frameworks);
703
662
  }
704
- registerComponent(e, r) {
705
- V(e, r, this.components);
663
+ registerComponent(e, s) {
664
+ T(e, s, this.components);
706
665
  }
707
666
  registerPlugin(e) {
708
- me(this, e, this.plugins);
667
+ fe(this, e, this.plugins);
709
668
  }
710
- registerFeature(e, r) {
711
- De(e, r, this.features);
669
+ registerFeature(e, s) {
670
+ De(e, s, this.features);
712
671
  }
713
- registerPredicate(e, r) {
714
- je(e, r, this.predicates);
672
+ registerPredicate(e, s) {
673
+ je(e, s, this.predicates);
715
674
  }
716
675
  registerField(e) {
717
676
  Ue(e, this.fields);
718
677
  }
719
- registerAction(e, r) {
720
- qe(e, r, this.actions);
721
- }
722
678
  registerExperience(e) {
723
- e.component && V(`experience:${e.id}`, e.component, this.components), ge(e, this.experiences);
679
+ e.component && T(`experience:${e.id}`, e.component, this.components), pe(e, this.experiences);
724
680
  }
725
681
  getStateSnapshot() {
726
- return Be(this);
682
+ return Pe(this);
727
683
  }
728
684
  async launchExperienceById(e) {
729
- const r = this.experiences.getById(e).getState();
730
- if (!r) {
685
+ const s = this.experiences.getById(e).getState();
686
+ if (!s) {
731
687
  v("warn", `Experience with id '${e}' not found.`);
732
688
  return;
733
689
  }
734
- K(this, r);
690
+ H(this, s);
735
691
  }
736
692
  // private async fetchProject() {
737
693
  // if (this.project) {
@@ -744,38 +700,38 @@ class q {
744
700
  // }
745
701
  setupPlugins() {
746
702
  var e;
747
- (e = this.options.plugins) == null || e.forEach((r) => {
748
- if (Array.isArray(r)) {
749
- r.forEach((c) => {
750
- this.registerPlugin(c);
703
+ (e = this.options.plugins) == null || e.forEach((s) => {
704
+ if (Array.isArray(s)) {
705
+ s.forEach((i) => {
706
+ this.registerPlugin(i);
751
707
  });
752
708
  return;
753
709
  }
754
- const n = typeof r == "function" ? r() : r;
755
- if (Array.isArray(n)) {
756
- n.forEach((c) => this.registerPlugin(c));
710
+ const o = typeof s == "function" ? s() : s;
711
+ if (Array.isArray(o)) {
712
+ o.forEach((i) => this.registerPlugin(i));
757
713
  return;
758
714
  }
759
- this.registerPlugin(n);
715
+ this.registerPlugin(o);
760
716
  });
761
717
  }
762
718
  setupFeatures() {
763
719
  const e = this.options.features;
764
- e && (Object.entries(e).forEach(([r, n]) => {
765
- const c = typeof n == "function" ? n() : n;
766
- this.registerFeature(r, c);
767
- }), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
720
+ e && (Object.entries(e).forEach(([s, o]) => {
721
+ const i = typeof o == "function" ? o() : o;
722
+ this.registerFeature(s, i);
723
+ }), this.searchParams.feature && this.searchParams.feature.forEach((s) => {
768
724
  try {
769
- const [n, c] = r.split(":");
770
- if (!n || !c)
725
+ const [o, i] = s.split(":");
726
+ if (!o || !i)
771
727
  return;
772
- let u = c;
773
- u === "true" && (u = !0), u === "false" && (u = !1), this.registerFeature(n, {
774
- key: `${u}`,
728
+ let l = i;
729
+ l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(o, {
730
+ key: `${l}`,
775
731
  // use the assigned bucket value as the key
776
- name: n,
732
+ name: o,
777
733
  // eslint-disable-next-line sonarjs/function-return-type
778
- decide: () => u,
734
+ decide: () => l,
779
735
  storage: "session"
780
736
  });
781
737
  } catch {
@@ -784,73 +740,63 @@ class q {
784
740
  }
785
741
  setupPredicates() {
786
742
  const e = this.options.predicates;
787
- e && Object.entries(e).forEach(([r, n]) => {
788
- if (typeof n != "function") {
789
- v("warn", `Predicate "${r}" is not a function.`);
790
- return;
791
- }
792
- this.registerPredicate(r, n);
793
- });
794
- }
795
- setupActions() {
796
- const e = this.options.actions;
797
- e && Object.entries(e).forEach(([r, n]) => {
798
- if (typeof n != "function") {
799
- v("warn", `Action "${r}" is not a function.`);
743
+ e && Object.entries(e).forEach(([s, o]) => {
744
+ if (typeof o != "function") {
745
+ v("warn", `Predicate "${s}" is not a function.`);
800
746
  return;
801
747
  }
802
- this.registerAction(r, n);
748
+ this.registerPredicate(s, o);
803
749
  });
804
750
  }
805
751
  getPluginConfig(e) {
806
752
  return this.plugins[e] ?? {};
807
753
  }
808
754
  }
809
- m(q, "logger", v);
810
- function G(t) {
755
+ h(K, "logger", v);
756
+ function q(t) {
811
757
  var e;
812
- return ((e = t.options) == null ? void 0 : e.some((r) => "condition" in r)) ?? !1;
758
+ return ((e = t.options) == null ? void 0 : e.some((s) => "condition" in s)) ?? !1;
813
759
  }
814
- function nt(t) {
815
- return t.some((e) => e.condition || G(e));
760
+ function Ze(t) {
761
+ return t.some((e) => e.condition || q(e));
816
762
  }
817
- async function ft(t, e) {
818
- return e.length === 0 || !nt(e) ? e : (await Promise.all(
819
- e.map(async (n) => {
820
- if (!(n.condition ? await A(t, n.condition) : !0))
763
+ async function ut(t, e) {
764
+ return e.length === 0 || !Ze(e) ? e : (await Promise.all(
765
+ e.map(async (o) => {
766
+ if (!(o.condition ? await R(t, o.condition) : !0))
821
767
  return null;
822
- if (!n.options || !G(n))
823
- return n;
824
- const s = (await Promise.all(
825
- n.options.map(async (l) => l.condition ? await A(t, l.condition) ? l : null : l)
826
- )).filter((l) => l !== null);
827
- return s.length === n.options.length ? n : s.length === 0 ? null : { ...n, options: s };
768
+ if (!o.options || !q(o))
769
+ return o;
770
+ const r = (await Promise.all(
771
+ o.options.map(async (d) => d.condition ? await R(t, d.condition) ? d : null : d)
772
+ )).filter((d) => d !== null);
773
+ return r.length === o.options.length ? o : r.length === 0 ? null : { ...o, options: r };
828
774
  })
829
- )).filter((n) => n !== null);
775
+ )).filter((o) => o !== null);
830
776
  }
831
- const mt = (t) => {
832
- const e = new q(t);
833
- return ce(e), e;
777
+ const lt = (t) => {
778
+ const e = new K(t);
779
+ return ae(e), e;
834
780
  };
835
781
  export {
836
- q as Picked,
837
- mt as createClient,
838
- B as createStorageKey,
839
- A as evaluateRuleLogic,
840
- ft as getStepFields,
841
- St as isPickedRoot,
782
+ K as Picked,
783
+ lt as createClient,
784
+ $ as createStorageKey,
785
+ R as evaluateRuleLogic,
786
+ ut as getStepFields,
787
+ gt as isPickedRoot,
842
788
  D as localStore,
843
- $ as sessionStore,
844
- wt as subscribe,
845
- bt as supportsCookies,
846
- ae as supportsCryptoRandomUUID,
847
- _ as supportsDocument,
848
- It as supportsHistory,
849
- xt as supportsIntersectionObserver,
850
- ie as supportsLocalStorage,
851
- Ft as supportsLocation,
852
- Et as supportsSessionStorage,
853
- Pt as supportsShadowRoot,
854
- Bt as supportsWebComponents,
855
- oe as supportsWindow
789
+ B as sessionStore,
790
+ mt as subscribe,
791
+ yt as supportsCookies,
792
+ ie as supportsCryptoRandomUUID,
793
+ z as supportsDocument,
794
+ St as supportsHistory,
795
+ wt as supportsIntersectionObserver,
796
+ oe as supportsLocalStorage,
797
+ vt as supportsLocation,
798
+ kt as supportsSessionStorage,
799
+ bt as supportsShadowRoot,
800
+ It as supportsWebComponents,
801
+ ne as supportsWindow
856
802
  };