@picked/client 0.0.7-next.1 → 0.0.7-next.2

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,24 +1,24 @@
1
- var q = Object.defineProperty;
2
- var W = (t, e, s) => e in t ? q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
- var y = (t, e, s) => W(t, typeof e != "symbol" ? e + "" : e, s);
4
- import { createDomain as F, createApi as b, createEffect as D, attach as G, sample as P, combine as A, createEvent as C } from "effector";
1
+ var W = Object.defineProperty;
2
+ var G = (t, e, s) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var y = (t, e, s) => G(t, typeof e != "symbol" ? e + "" : e, s);
4
+ import { createDomain as F, createApi as b, createEffect as D, attach as J, sample as P, combine as A, createEvent as C } from "effector";
5
5
  import { createFactory as k, invoke as x } from "@withease/factories";
6
- import { g as z, t as J, c as Y, e as B, i as Q, a as X, b as Z, d as ee } from "../experience-instance-C1Ky25uw.js";
7
- import { f as ot } from "../experience-instance-C1Ky25uw.js";
6
+ import { g as z, t as Y, c as Q, e as R, i as X, a as Z, b as ee, d as te } from "../experience-instance-C1Ky25uw.js";
7
+ import { f as it } from "../experience-instance-C1Ky25uw.js";
8
8
  import { l as v } from "../logger-C9a75KZn.js";
9
- import { c as j, s as R, l as O } from "../storage-D87xFySf.js";
10
- import { a as at } from "../storage-D87xFySf.js";
11
- import { g as te } from "../id-BW-g3y32.js";
12
- import { i as re } from "../object-JwZ58NOH.js";
13
- import { s as _, a as se, b as ne } from "../supports-yKVnaaMQ.js";
14
- import { g as ut, d as lt, i as dt, e as pt, c as gt, f as ft, h as mt, j as yt } from "../supports-yKVnaaMQ.js";
15
- const U = F("experience"), oe = k(
9
+ import { c as B, s as j, l as O } from "../storage-D87xFySf.js";
10
+ import { a as ct } from "../storage-D87xFySf.js";
11
+ import { g as re } from "../id-BW-g3y32.js";
12
+ import { i as se } from "../object-JwZ58NOH.js";
13
+ import { s as _, a as ne, b as oe } from "../supports-yKVnaaMQ.js";
14
+ import { g as lt, d as dt, i as pt, e as gt, c as ft, f as mt, h as yt, j as ht } from "../supports-yKVnaaMQ.js";
15
+ const U = F("experience"), ie = k(
16
16
  ({ client: t, experience: e }) => {
17
17
  const s = U.store(e), o = b(s, {
18
- merge(n, g) {
18
+ merge(n, d) {
19
19
  return {
20
20
  ...n,
21
- ...g.experience
21
+ ...d.experience
22
22
  };
23
23
  }
24
24
  }), i = s.map((n) => ({
@@ -27,7 +27,7 @@ const U = F("experience"), oe = k(
27
27
  decisionLogic: n.decide,
28
28
  targetSelectors: n.targets
29
29
  })), l = t.components.listStore.map(
30
- (n) => n.find((g) => g.name === `experience:${e.id}`) || n.find((g) => g.name === "experience"),
30
+ (n) => n.find((d) => d.name === `experience:${e.id}`) || n.find((d) => d.name === "experience"),
31
31
  { skipVoid: !1 }
32
32
  ), r = s.map((n) => ({
33
33
  steps: n.steps,
@@ -44,10 +44,10 @@ const U = F("experience"), oe = k(
44
44
  };
45
45
  }
46
46
  );
47
- function ie(t) {
48
- return x(oe, t);
47
+ function ae(t) {
48
+ return x(ie, t);
49
49
  }
50
- const ae = k(({ client: t }) => {
50
+ const ce = k(({ client: t }) => {
51
51
  const e = U.store({}), s = b(e, {
52
52
  register(r, n) {
53
53
  return {
@@ -62,8 +62,8 @@ const ae = k(({ client: t }) => {
62
62
  n.merge({ experience: r, strategy: "override" });
63
63
  return;
64
64
  }
65
- const g = ie({ client: t, experience: r });
66
- s.register(g);
65
+ const d = ae({ client: t, experience: r });
66
+ s.register(d);
67
67
  }
68
68
  const i = e.map((r) => Object.values(r));
69
69
  function l(r) {
@@ -75,34 +75,34 @@ const ae = k(({ client: t }) => {
75
75
  listStore: i
76
76
  };
77
77
  });
78
- function ce(t) {
79
- return x(ae, t);
78
+ function ue(t) {
79
+ return x(ce, t);
80
80
  }
81
- const ue = (t, e) => {
81
+ const le = (t, e) => {
82
82
  e.register(t);
83
83
  }, H = (t, e) => {
84
84
  const { targetSelectors: s } = e.configStore.getState(), o = z(s, e.id);
85
85
  o.forEach(
86
- ({ elements: l }) => l.forEach((r) => J(r, e.id))
87
- ), Y(o, e.id).forEach((l) => {
86
+ ({ elements: l }) => l.forEach((r) => Y(r, e.id))
87
+ ), Q(o, e.id).forEach((l) => {
88
88
  t.experienceInstances.spawn(e, l);
89
89
  });
90
90
  }, T = async (t) => {
91
91
  await Promise.all(
92
92
  t.experiences.listStore.getState().map(async (e) => {
93
- await le(t, e) && H(t, e);
93
+ await de(t, e) && H(t, e);
94
94
  })
95
95
  );
96
- }, le = async (t, e) => {
96
+ }, de = async (t, e) => {
97
97
  const { type: s, decisionLogic: o, targetSelectors: i } = e.configStore.getState();
98
- return z(i, e.id).length < 1 ? !1 : s === "funnel" ? o ? await B(t, o) === !0 : !1 : i.length === 0 ? !1 : Q(o) ? await B(t, o) === !0 : !0;
99
- }, de = (t, e, s) => {
98
+ return z(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
+ }, pe = (t, e, s) => {
100
100
  const o = e.name, i = e.setup(t);
101
101
  if (i) {
102
102
  const l = s[o] ?? {};
103
103
  s[o] = Object.freeze({ ...l, ...i });
104
104
  }
105
- }, pe = F("component"), ge = k(
105
+ }, ge = F("component"), fe = k(
106
106
  ({ client: t, component: e, name: s }) => {
107
107
  const o = t.frameworks.getByName(e.frameworkName);
108
108
  return {
@@ -112,11 +112,11 @@ const ue = (t, e) => {
112
112
  };
113
113
  }
114
114
  );
115
- function fe(t) {
116
- return x(ge, t);
115
+ function me(t) {
116
+ return x(fe, t);
117
117
  }
118
- const me = k(({ client: t }) => {
119
- const e = pe.store({}), s = b(e, {
118
+ const ye = k(({ client: t }) => {
119
+ const e = ge.store({}), s = b(e, {
120
120
  register(r, n) {
121
121
  return {
122
122
  ...r,
@@ -129,7 +129,7 @@ const me = k(({ client: t }) => {
129
129
  "warn",
130
130
  `Component '${r}' already registered. Registering again will override the previous registration.`
131
131
  );
132
- const h = fe({ client: t, name: r, component: n });
132
+ const h = me({ client: t, name: r, component: n });
133
133
  s.register(h);
134
134
  }
135
135
  const i = e.map((r) => Object.values(r));
@@ -142,13 +142,13 @@ const me = k(({ client: t }) => {
142
142
  listStore: i
143
143
  };
144
144
  });
145
- function ye(t) {
146
- return x(me, t);
145
+ function he(t) {
146
+ return x(ye, t);
147
147
  }
148
148
  const V = (t, e, s) => {
149
149
  s.register(t, e);
150
- }, he = F("framework"), Se = k(({ client: t }) => {
151
- const e = he.store({}), s = b(e, {
150
+ }, Se = F("framework"), we = k(({ client: t }) => {
151
+ const e = Se.store({}), s = b(e, {
152
152
  register(r, n) {
153
153
  return {
154
154
  ...r,
@@ -172,23 +172,23 @@ const V = (t, e, s) => {
172
172
  listStore: i
173
173
  };
174
174
  });
175
- function we(t) {
176
- return x(Se, t);
175
+ function ve(t) {
176
+ return x(we, t);
177
177
  }
178
- const ve = (t, e) => {
178
+ const ke = (t, e) => {
179
179
  e.register(t.name, t);
180
- }, ke = 6e3, M = j("last_ping", "global"), xe = (t) => `${t}/api/v1/ping`, Fe = async (t) => {
180
+ }, xe = 6e3, M = B("last_ping", "global"), Fe = (t) => `${t}/api/v1/ping`, be = async (t) => {
181
181
  try {
182
182
  const e = Date.now(), s = localStorage.getItem(M);
183
- if (s && e - parseInt(s) < ke)
183
+ if (s && e - parseInt(s) < xe)
184
184
  return !0;
185
- const o = xe(t.apiUrl), i = {
185
+ const o = Fe(t.apiUrl), i = {
186
186
  projectId: t.projectId,
187
187
  path: window.location.pathname
188
188
  }, l = JSON.stringify(i), r = {
189
189
  "Content-Type": "application/json"
190
- }, n = document.getElementById("picked_script"), g = n == null ? void 0 : n.dataset.verceltoken;
191
- g && (r["x-vercel-protection-bypass"] = g);
190
+ }, n = document.getElementById("picked_script"), d = n == null ? void 0 : n.dataset.verceltoken;
191
+ d && (r["x-vercel-protection-bypass"] = d);
192
192
  const c = (await fetch(o, {
193
193
  method: "POST",
194
194
  headers: r,
@@ -199,7 +199,7 @@ const ve = (t, e) => {
199
199
  return v("error", e), !1;
200
200
  }
201
201
  };
202
- function be(t) {
202
+ function Ie(t) {
203
203
  const e = typeof window < "u", s = {
204
204
  client: t,
205
205
  responses: t.responses.listStore.getState(),
@@ -211,8 +211,8 @@ function be(t) {
211
211
  };
212
212
  return Object.freeze(s);
213
213
  }
214
- const Ie = F("predicate"), Ee = k(({ client: t }) => {
215
- const e = Ie.store({}), s = b(e, {
214
+ const Ee = F("predicate"), Pe = k(({ client: t }) => {
215
+ const e = Ee.store({}), s = b(e, {
216
216
  register(r, n) {
217
217
  return {
218
218
  ...r,
@@ -239,8 +239,8 @@ const Ie = F("predicate"), Ee = k(({ client: t }) => {
239
239
  listStore: i
240
240
  };
241
241
  });
242
- function Pe(t) {
243
- return x(Ee, t);
242
+ function Re(t) {
243
+ return x(Pe, t);
244
244
  }
245
245
  const Be = (t, e, s) => {
246
246
  s.register(t, e);
@@ -258,7 +258,7 @@ const Be = (t, e, s) => {
258
258
  "warn",
259
259
  `Feature '${c}' already registered. Registering again will override the previous registration.`
260
260
  );
261
- const d = {
261
+ const p = {
262
262
  id: c,
263
263
  feature: {
264
264
  ...f,
@@ -268,7 +268,7 @@ const Be = (t, e, s) => {
268
268
  s.register(
269
269
  Object.freeze({
270
270
  id: c,
271
- feature: d
271
+ feature: p
272
272
  })
273
273
  );
274
274
  }
@@ -278,31 +278,31 @@ const Be = (t, e, s) => {
278
278
  key: f,
279
279
  storage: a = "local"
280
280
  }) => {
281
- const d = j(`feature:${c}:${f}`, "global"), m = (a === "session" ? R : O).get(d).boolean();
281
+ const p = B(`feature:${c}:${f}`, "global"), m = (a === "session" ? j : O).get(p).boolean();
282
282
  if (m !== null)
283
283
  return { id: c, bucket: m };
284
284
  }
285
285
  ), l = D((c) => {
286
286
  if (!c)
287
287
  return null;
288
- const f = j(`feature:${c.id}:${c.key}`, "global");
289
- (c.storage === "session" ? R : O).set(f, c.bucket);
290
- }), r = /* @__PURE__ */ new Map(), n = G({
288
+ const f = B(`feature:${c.id}:${c.key}`, "global");
289
+ (c.storage === "session" ? j : O).set(f, c.bucket);
290
+ }), r = /* @__PURE__ */ new Map(), n = J({
291
291
  source: { allFeaturesStore: t, resolvedFeaturesStore: e },
292
- effect: async ({ allFeaturesStore: c, resolvedFeaturesStore: f }, { id: a, decide: d, key: p }) => {
292
+ effect: async ({ allFeaturesStore: c, resolvedFeaturesStore: f }, { id: a, decide: p, key: g }) => {
293
293
  const m = f.find((I) => I.id === a);
294
294
  if (m)
295
295
  return m;
296
296
  const u = c[a];
297
297
  if (!u)
298
298
  throw new Error(`Feature with id '${a}' not found`);
299
- const S = r.get(`${a}:${p}`);
299
+ const S = r.get(`${a}:${g}`);
300
300
  if (S) {
301
301
  const I = await S;
302
302
  return { id: u.id, bucket: I, storage: u.feature.storage };
303
303
  }
304
- const w = d();
305
- r.set(`${a}:${p}`, w);
304
+ const w = p();
305
+ r.set(`${a}:${g}`, w);
306
306
  const $ = await w;
307
307
  return { id: u.id, bucket: $, storage: u.feature.storage };
308
308
  }
@@ -324,22 +324,22 @@ const Be = (t, e, s) => {
324
324
  clock: n.doneData,
325
325
  fn: (c, f) => {
326
326
  var u;
327
- const { id: a, bucket: d, storage: p } = f, m = (u = c[a]) == null ? void 0 : u.feature.key;
328
- return m ? { key: m, id: a, bucket: d, storage: p } : null;
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;
329
329
  },
330
330
  target: l
331
331
  });
332
- const g = A({ allFeaturesStore: t, resolvedFeaturesStore: e }).map(
332
+ const d = A({ allFeaturesStore: t, resolvedFeaturesStore: e }).map(
333
333
  ({
334
334
  allFeaturesStore: c,
335
335
  resolvedFeaturesStore: f
336
336
  }) => Object.values(c).map((a) => {
337
- const d = f.find((p) => p.id === a.id);
338
- return d ? {
337
+ const p = f.find((g) => g.id === a.id);
338
+ return p ? {
339
339
  id: a.id,
340
340
  name: a.feature.name,
341
341
  key: a.feature.key,
342
- getBucket: () => ({ id: a.id, bucket: d.bucket }),
342
+ getBucket: () => ({ id: a.id, bucket: p.bucket }),
343
343
  isResolved: !0
344
344
  } : {
345
345
  id: a.id,
@@ -356,25 +356,25 @@ const Be = (t, e, s) => {
356
356
  return {
357
357
  register: o,
358
358
  getByName: h,
359
- listStore: g
359
+ listStore: d
360
360
  };
361
361
  });
362
- function Re() {
362
+ function $e() {
363
363
  return x(je);
364
364
  }
365
- const $e = (t, e, s) => {
365
+ const Ae = (t, e, s) => {
366
366
  s.register(t, e);
367
367
  }, E = F("history");
368
368
  function L(t, e) {
369
369
  return {
370
370
  // eslint-disable-next-line sonarjs/pseudo-random
371
- id: te(`history-entry-${Date.now()}-${Math.random()}}`),
371
+ id: re(`history-entry-${Date.now()}-${Math.random()}}`),
372
372
  node: e,
373
373
  at: Date.now(),
374
374
  experienceId: t
375
375
  };
376
376
  }
377
- const Ae = k(() => {
377
+ const Ce = k(() => {
378
378
  const t = E.store({ entries: [] }), e = E.event(), s = E.event(), o = E.event(), i = E.event();
379
379
  t.on(e, (r, n) => ({
380
380
  entries: [...r.entries, L(n.experienceId, n.node)]
@@ -385,21 +385,21 @@ const Ae = k(() => {
385
385
  ]
386
386
  })), t.on(i, (r, n) => n);
387
387
  function l(r, n) {
388
- const g = { lastStepIndex: -1, secondLastStepIndex: -1 };
388
+ const d = { lastStepIndex: -1, secondLastStepIndex: -1 };
389
389
  for (let h = r.length - 1; h >= 0; h--) {
390
390
  const c = r[h], f = c == null ? void 0 : c.node;
391
- if (!(!f || !X(f)) && !(n && (c == null ? void 0 : c.experienceId) !== n))
392
- if (g.lastStepIndex === -1)
393
- g.lastStepIndex = h;
391
+ if (!(!f || !Z(f)) && !(n && (c == null ? void 0 : c.experienceId) !== n))
392
+ if (d.lastStepIndex === -1)
393
+ d.lastStepIndex = h;
394
394
  else {
395
- g.secondLastStepIndex = h;
395
+ d.secondLastStepIndex = h;
396
396
  break;
397
397
  }
398
398
  }
399
- return g;
399
+ return d;
400
400
  }
401
401
  return t.on(o, (r, n) => {
402
- const { secondLastStepIndex: g } = l(r.entries, n.experienceId), h = g !== -1 ? r.entries.slice(0, g + 1) : r.entries;
402
+ const { secondLastStepIndex: d } = l(r.entries, n.experienceId), h = d !== -1 ? r.entries.slice(0, d + 1) : r.entries;
403
403
  return {
404
404
  ...r,
405
405
  entries: h
@@ -412,11 +412,11 @@ const Ae = k(() => {
412
412
  entriesStore: t.map((r) => r.entries)
413
413
  };
414
414
  });
415
- function Ce() {
416
- return x(Ae);
415
+ function De() {
416
+ return x(Ce);
417
417
  }
418
- const De = () => C(), Oe = F("field"), Te = k(() => {
419
- const t = Oe.store({}), e = b(t, {
418
+ const Oe = () => C(), Te = F("field"), Ve = k(() => {
419
+ const t = Te.store({}), e = b(t, {
420
420
  register(r, n) {
421
421
  return {
422
422
  ...r,
@@ -432,7 +432,7 @@ const De = () => C(), Oe = F("field"), Te = k(() => {
432
432
  return t.map((n) => n[r] || null);
433
433
  }
434
434
  function l(r) {
435
- return t.map((n) => Object.values(n).find((g) => g.name === r) || null);
435
+ return t.map((n) => Object.values(n).find((d) => d.name === r) || null);
436
436
  }
437
437
  return {
438
438
  register: s,
@@ -441,58 +441,58 @@ const De = () => C(), Oe = F("field"), Te = k(() => {
441
441
  getByName: l
442
442
  };
443
443
  });
444
- function Ve() {
445
- return x(Te);
444
+ function Me() {
445
+ return x(Ve);
446
446
  }
447
- const Me = (t, e) => {
447
+ const Ne = (t, e) => {
448
448
  e.register(t);
449
- }, Ne = F("response"), Le = k(({ client: t }) => {
450
- const e = Ne.store({}), s = C(), o = C(), i = b(e, {
451
- register(a, d) {
449
+ }, Le = F("response"), ze = k(({ client: t }) => {
450
+ const e = Le.store({}), s = C(), o = C(), i = b(e, {
451
+ register(a, p) {
452
452
  return {
453
453
  ...a,
454
- [d.fieldId]: d.response
454
+ [p.fieldId]: p.response
455
455
  };
456
456
  },
457
- registerBatch(a, d) {
457
+ registerBatch(a, p) {
458
458
  return {
459
459
  ...a,
460
- ...d
460
+ ...p
461
461
  };
462
462
  },
463
- clear(a, d) {
464
- const { [d]: p, ...m } = a;
463
+ clear(a, p) {
464
+ const { [p]: g, ...m } = a;
465
465
  return m;
466
466
  },
467
467
  clearAll() {
468
468
  return {};
469
469
  }
470
470
  });
471
- function l(a, d) {
472
- i.register({ fieldId: a, response: d });
471
+ function l(a, p) {
472
+ i.register({ fieldId: a, response: p });
473
473
  }
474
474
  async function r(a) {
475
- const d = [];
475
+ const p = [];
476
476
  return await Promise.allSettled(
477
- Object.entries(a).map(async ([p, m]) => {
477
+ Object.entries(a).map(async ([g, m]) => {
478
478
  let u = m;
479
- const S = t.fields.getById(p).getState();
479
+ const S = t.fields.getById(g).getState();
480
480
  if (!S) {
481
- d.push({
482
- fieldId: p,
483
- userMessage: `Field '${p}' not found`,
484
- systemMessage: `No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
481
+ p.push({
482
+ fieldId: g,
483
+ userMessage: `Field '${g}' not found`,
484
+ systemMessage: `No field with ID '${g}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
485
485
  value: u
486
486
  });
487
487
  return;
488
488
  }
489
- if (S.multiple && (typeof u == "string" || typeof u == "number" || typeof u == "boolean") && (u = [u]), !re(S.validation)) {
490
- const w = await B(t, S.validation, {
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
491
  $input: u
492
492
  });
493
493
  if (typeof w == "string") {
494
- d.push({
495
- fieldId: p,
494
+ p.push({
495
+ fieldId: g,
496
496
  userMessage: w,
497
497
  systemMessage: `Field validation resulted in an error: ${w}.`,
498
498
  value: u
@@ -500,8 +500,8 @@ const Me = (t, e) => {
500
500
  return;
501
501
  }
502
502
  if (w === !1) {
503
- d.push({
504
- fieldId: p,
503
+ p.push({
504
+ fieldId: g,
505
505
  userMessage: "This field is invalid",
506
506
  systemMessage: "Field validation resulted in an unspecified error.",
507
507
  value: u
@@ -510,8 +510,8 @@ const Me = (t, e) => {
510
510
  }
511
511
  }
512
512
  if (S.required && (typeof u > "u" || u === null || u === "" || Array.isArray(u) && !u.length)) {
513
- d.push({
514
- fieldId: p,
513
+ p.push({
514
+ fieldId: g,
515
515
  userMessage: "This field is required",
516
516
  systemMessage: "Field is required.",
517
517
  value: u
@@ -519,8 +519,8 @@ const Me = (t, e) => {
519
519
  return;
520
520
  }
521
521
  if (!S.multiple && Array.isArray(u) && u.length > 1) {
522
- d.push({
523
- fieldId: p,
522
+ p.push({
523
+ fieldId: g,
524
524
  userMessage: "This field expects a single response",
525
525
  systemMessage: "Field expects a single response.",
526
526
  value: u
@@ -529,33 +529,33 @@ const Me = (t, e) => {
529
529
  }
530
530
  if (S.options) {
531
531
  const w = S.options.map((I) => I.value), $ = Array.isArray(u) ? u : [u];
532
- Array.isArray(u) && ($.every((I) => w.includes(I)) || d.push({
533
- fieldId: p,
532
+ Array.isArray(u) && ($.every((I) => w.includes(I)) || p.push({
533
+ fieldId: g,
534
534
  userMessage: "This field expects a valid option",
535
535
  systemMessage: `Field expects a valid option. Valid options are: ${w.join(", ")}`,
536
536
  value: u
537
537
  }));
538
538
  }
539
539
  })
540
- ), { responsesToCommit: a, validationErrors: d };
540
+ ), { responsesToCommit: a, validationErrors: p };
541
541
  }
542
542
  async function n(a) {
543
- const { responsesToCommit: d, validationErrors: p } = await r(a);
544
- return p.length ? { errors: p } : (i.registerBatch(d), { errors: [] });
543
+ const { responsesToCommit: p, validationErrors: g } = await r(a);
544
+ return g.length ? { errors: g } : (i.registerBatch(p), { errors: [] });
545
545
  }
546
- const g = e.map((a) => a), h = e.map((a) => Object.keys(a).map((p) => ({
547
- fieldId: p,
548
- value: a[p]
546
+ const d = e.map((a) => a), h = e.map((a) => Object.keys(a).map((g) => ({
547
+ fieldId: g,
548
+ value: a[g]
549
549
  })));
550
550
  function c(a) {
551
- const d = t.fields.getById(a), p = e.map((m) => m[a] || null);
552
- return A({ f: d, r: p }, ({ f: m, r: u }) => u || (m != null && m.defaultValue ? m.defaultValue : null));
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
553
  }
554
554
  function f(a) {
555
- const d = t.fields.getByName(a);
556
- return A({ f: d, s: e }, ({ f: p, s: m }) => {
557
- const u = p && m[p.id] || null;
558
- return u || (p != null && p.defaultValue ? p.defaultValue : null);
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);
559
559
  });
560
560
  }
561
561
  return P({
@@ -571,16 +571,16 @@ const Me = (t, e) => {
571
571
  commit: n,
572
572
  getResponsesToCommit: r,
573
573
  listStore: h,
574
- getAllStore: g,
574
+ getAllStore: d,
575
575
  getByFieldId: c,
576
576
  getByFieldName: f
577
577
  };
578
578
  });
579
- function ze(t) {
580
- return x(Le, t);
579
+ function _e(t) {
580
+ return x(ze, t);
581
581
  }
582
- const _e = () => "0.0.7-next.1";
583
- function Ue() {
582
+ const Ue = () => "0.0.7-next.2";
583
+ function He() {
584
584
  if (_()) {
585
585
  const t = [
586
586
  document.currentScript,
@@ -595,8 +595,8 @@ function Ue() {
595
595
  }
596
596
  return "https://api.picked.app";
597
597
  }
598
- function He() {
599
- if (!se())
598
+ function Ke() {
599
+ if (!ne())
600
600
  return {};
601
601
  const t = new URLSearchParams(window.location.search), e = {}, s = /* @__PURE__ */ new Set();
602
602
  for (const [i] of t.entries())
@@ -605,11 +605,11 @@ function He() {
605
605
  const l = i.replace("picked-", "");
606
606
  e[l] = t.getAll(i);
607
607
  }
608
- const o = j("s");
608
+ const o = B("s");
609
609
  if (s.size > 0)
610
- R.set(o, e);
610
+ j.set(o, e);
611
611
  else {
612
- const i = R.get(o);
612
+ const i = j.get(o);
613
613
  if (i)
614
614
  return i.json() || {};
615
615
  }
@@ -621,50 +621,50 @@ class K {
621
621
  y(this, "isReady", !1);
622
622
  y(this, "project");
623
623
  y(this, "plugins", {});
624
- y(this, "eventBus", De());
624
+ y(this, "eventBus", Oe());
625
625
  y(this, "organizationId");
626
626
  y(this, "projectId");
627
627
  y(this, "apiUrl");
628
- y(this, "searchParams", He());
629
- y(this, "history", Ce());
630
- y(this, "components", ye({ client: this }));
631
- y(this, "experienceInstances", Z({ client: this }));
632
- y(this, "experiences", ce({ client: this }));
633
- y(this, "frameworks", we({ client: this }));
634
- y(this, "predicates", Pe({ client: this }));
635
- y(this, "features", Re());
636
- y(this, "responses", ze({ client: this }));
637
- y(this, "fields", Ve());
638
- v("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Ue(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.eventBus({ type: "initialized", version: _e() }), v("info", "Picked client initialized.");
628
+ y(this, "searchParams", Ke());
629
+ y(this, "history", De());
630
+ y(this, "components", he({ client: this }));
631
+ y(this, "experienceInstances", ee({ client: this }));
632
+ y(this, "experiences", ue({ client: this }));
633
+ y(this, "frameworks", ve({ client: this }));
634
+ y(this, "predicates", Re({ client: this }));
635
+ y(this, "features", $e());
636
+ y(this, "responses", _e({ client: this }));
637
+ y(this, "fields", Me());
638
+ v("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || He(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.eventBus({ type: "initialized", version: Ue() }), v("info", "Picked client initialized.");
639
639
  }
640
640
  start() {
641
- Fe(this), (async () => {
642
- _() && (document.body && await T(this), await ee(), await T(this), this.eventBus({ type: "ready" }), this.isReady = !0);
641
+ be(this), (async () => {
642
+ _() && (document.body && await T(this), await te(), await T(this), this.eventBus({ type: "ready" }), this.isReady = !0);
643
643
  })();
644
644
  }
645
645
  registerFramework(e) {
646
- ve(e, this.frameworks);
646
+ ke(e, this.frameworks);
647
647
  }
648
648
  registerComponent(e, s) {
649
649
  V(e, s, this.components);
650
650
  }
651
651
  registerPlugin(e) {
652
- de(this, e, this.plugins);
652
+ pe(this, e, this.plugins);
653
653
  }
654
654
  registerFeature(e, s) {
655
- $e(e, s, this.features);
655
+ Ae(e, s, this.features);
656
656
  }
657
657
  registerPredicate(e, s) {
658
658
  Be(e, s, this.predicates);
659
659
  }
660
660
  registerField(e) {
661
- Me(e, this.fields);
661
+ Ne(e, this.fields);
662
662
  }
663
663
  registerExperience(e) {
664
- e.component && V(`experience:${e.id}`, e.component, this.components), ue(e, this.experiences);
664
+ e.component && V(`experience:${e.id}`, e.component, this.components), le(e, this.experiences);
665
665
  }
666
666
  getStateSnapshot() {
667
- return be(this);
667
+ return Ie(this);
668
668
  }
669
669
  async launchExperienceById(e) {
670
670
  const s = this.experiences.getById(e).getState();
@@ -738,36 +738,49 @@ class K {
738
738
  }
739
739
  }
740
740
  y(K, "logger", v);
741
- function Ke(t) {
742
- return t.some((e) => "condition" in e);
741
+ function q(t) {
742
+ var e;
743
+ return ((e = t.options) == null ? void 0 : e.some((s) => "condition" in s)) ?? !1;
743
744
  }
744
- async function tt(t, e) {
745
- return !Ke(e) || e.length === 0 ? e : (await Promise.all(
746
- e.map(async (o) => o.condition ? await B(t, o.condition) ? o : null : o)
745
+ function qe(t) {
746
+ return t.some((e) => e.condition || q(e));
747
+ }
748
+ async function rt(t, e) {
749
+ return e.length === 0 || !qe(e) ? e : (await Promise.all(
750
+ e.map(async (o) => {
751
+ if (!(o.condition ? await R(t, o.condition) : !0))
752
+ return null;
753
+ if (!o.options || !q(o))
754
+ return o;
755
+ const r = (await Promise.all(
756
+ o.options.map(async (d) => d.condition ? await R(t, d.condition) ? d : null : d)
757
+ )).filter((d) => d !== null);
758
+ return r.length === o.options.length ? o : r.length === 0 ? null : { ...o, options: r };
759
+ })
747
760
  )).filter((o) => o !== null);
748
761
  }
749
- const rt = (t) => {
762
+ const st = (t) => {
750
763
  const e = new K(t);
751
- return ne(e), e;
764
+ return oe(e), e;
752
765
  };
753
766
  export {
754
767
  K as Picked,
755
- rt as createClient,
756
- j as createStorageKey,
757
- B as evaluateRuleLogic,
758
- tt as getStepFields,
759
- ot as isPickedRoot,
768
+ st as createClient,
769
+ B as createStorageKey,
770
+ R as evaluateRuleLogic,
771
+ rt as getStepFields,
772
+ it as isPickedRoot,
760
773
  O as localStore,
761
- R as sessionStore,
762
- at as subscribe,
763
- ut as supportsCookies,
774
+ j as sessionStore,
775
+ ct as subscribe,
776
+ lt as supportsCookies,
764
777
  _ as supportsDocument,
765
- lt as supportsHistory,
766
- dt as supportsIntersectionObserver,
767
- pt as supportsLocalStorage,
768
- gt as supportsLocation,
769
- ft as supportsSessionStorage,
770
- mt as supportsShadowRoot,
771
- yt as supportsWebComponents,
772
- se as supportsWindow
778
+ dt as supportsHistory,
779
+ pt as supportsIntersectionObserver,
780
+ gt as supportsLocalStorage,
781
+ ft as supportsLocation,
782
+ mt as supportsSessionStorage,
783
+ yt as supportsShadowRoot,
784
+ ht as supportsWebComponents,
785
+ ne as supportsWindow
773
786
  };