@picked/client 0.0.24-next.1 → 0.0.24-next.3

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