@picked/client 0.0.1-dev.1769998938557 → 0.0.1-dev.1770162676770

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,7 +1,7 @@
1
1
  import { createDomain as b, createApi as F, createStore as H, createEffect as R, sample as I, attach as X, combine as O, createEvent as D } from "effector";
2
2
  import { createFactory as w, invoke as v } from "@withease/factories";
3
- import { g as q, t as Z, c as ee, i as te, e as j, a as re, b as ne, d as se } from "../experience-instance-CwXYJkRx.js";
4
- import { f as jt } from "../experience-instance-CwXYJkRx.js";
3
+ import { g as q, t as Z, c as ee, i as te, e as j, a as re, b as ne, d as se } from "../experience-instance-CEwLzO0a.js";
4
+ import { f as jt } from "../experience-instance-CEwLzO0a.js";
5
5
  import { l as k } from "../logger-C9a75KZn.js";
6
6
  import { c as A, l as C, s as z } from "../storage-Co_LbKr_.js";
7
7
  import { a as At } from "../storage-Co_LbKr_.js";
@@ -12,32 +12,33 @@ import { h as Rt, f as $t, j as Ct, e as zt, g as Ot, i as Dt, k as Ut } from ".
12
12
  const K = b("experience"), de = w(
13
13
  ({ client: t, experience: e }) => {
14
14
  const r = K.store(e), n = F(r, {
15
- merge(a, f) {
15
+ merge(p, h) {
16
16
  return {
17
- ...a,
18
- ...f.experience
17
+ ...p,
18
+ ...h.experience
19
19
  };
20
20
  }
21
- }), i = r.map((a) => ({
22
- name: a.name,
23
- decisionLogic: a.condition ?? a.decide,
24
- targetSelectors: a.targets,
21
+ }), i = r.map((p) => ({
22
+ name: p.name,
23
+ decisionLogic: p.condition ?? p.decide,
24
+ targetSelectors: p.targets,
25
25
  initializeOpenLogic: e.initializeOpen
26
- })), u = t.components.listStore.map(
27
- (a) => a.find((f) => f.name === `experience:${e.id}`) || a.find((f) => f.name === "experience"),
26
+ })), c = t.components.listStore.map(
27
+ (p) => p.find((h) => h.name === `experience:${e.id}`) || p.find((h) => h.name === "experience"),
28
28
  { skipVoid: !1 }
29
- ), o = r.map((a) => ({
30
- steps: a.steps,
31
- nodes: a.nodes,
32
- edges: a.edges,
33
- conditionals: a.conditionals
34
- })), s = e.actions ?? [];
29
+ ), o = r.map((p) => ({
30
+ steps: p.steps,
31
+ nodes: p.nodes,
32
+ edges: p.edges,
33
+ conditionals: p.conditionals
34
+ })), s = r.map((p) => p.fields), d = e.actions ?? [];
35
35
  return {
36
36
  id: e.id,
37
37
  configStore: i,
38
38
  treeStore: o,
39
- componentStore: u,
40
- actions: s,
39
+ fieldsStore: s,
40
+ componentStore: c,
41
+ actions: d,
41
42
  merge: n.merge
42
43
  };
43
44
  }
@@ -60,16 +61,16 @@ const pe = w(({ client: t }) => {
60
61
  s.merge({ experience: o, strategy: "override" });
61
62
  return;
62
63
  }
63
- const a = le({ client: t, experience: o });
64
- r.register(a);
64
+ const d = le({ client: t, experience: o });
65
+ r.register(d);
65
66
  }
66
67
  const i = e.map((o) => Object.values(o));
67
- function u(o) {
68
+ function c(o) {
68
69
  return e.map((s) => s[o], { skipVoid: !1 });
69
70
  }
70
71
  return {
71
72
  register: n,
72
- getById: u,
73
+ getById: c,
73
74
  listStore: i
74
75
  };
75
76
  });
@@ -81,9 +82,9 @@ const ge = (t, e) => {
81
82
  }, W = (t, e) => {
82
83
  const { targetSelectors: r } = e.configStore.getState(), n = q(r, e.id);
83
84
  n.forEach(
84
- ({ elements: u }) => u.forEach((o) => Z(o, e.id))
85
- ), ee(n, e.id).forEach((u) => {
86
- t.experienceInstances.spawn(e, u);
85
+ ({ elements: c }) => c.forEach((o) => Z(o, e.id))
86
+ ), ee(n, e.id).forEach((c) => {
87
+ t.experienceInstances.spawn(e, c);
87
88
  });
88
89
  }, M = async (t) => {
89
90
  await Promise.all(
@@ -97,8 +98,8 @@ const ge = (t, e) => {
97
98
  }, he = (t, e, r) => {
98
99
  const n = e.name, i = e.setup(t);
99
100
  if (i) {
100
- const u = r[n] ?? {};
101
- r[n] = Object.freeze({ ...u, ...i });
101
+ const c = r[n] ?? {};
102
+ r[n] = Object.freeze({ ...c, ...i });
102
103
  }
103
104
  }, ye = b("component"), Se = w(
104
105
  ({ client: t, component: e, name: r }) => {
@@ -127,16 +128,16 @@ const we = w(({ client: t }) => {
127
128
  "warn",
128
129
  `Component '${o}' already registered. Registering again will override the previous registration.`
129
130
  );
130
- const f = ke({ client: t, name: o, component: s });
131
- r.register(f);
131
+ const p = ke({ client: t, name: o, component: s });
132
+ r.register(p);
132
133
  }
133
134
  const i = e.map((o) => Object.values(o));
134
- function u(o) {
135
+ function c(o) {
135
136
  return e.map((s) => s[o], { skipVoid: !1 });
136
137
  }
137
138
  return {
138
139
  register: n,
139
- getByName: u,
140
+ getByName: c,
140
141
  listStore: i
141
142
  };
142
143
  });
@@ -161,12 +162,12 @@ const T = (t, e, r) => {
161
162
  ), r.register({ name: o, framework: s });
162
163
  }
163
164
  const i = e.map((o) => Object.values(o));
164
- function u(o) {
165
+ function c(o) {
165
166
  return e.map((s) => s[o], { skipVoid: !1 });
166
167
  }
167
168
  return {
168
169
  register: n,
169
- getByName: u,
170
+ getByName: c,
170
171
  listStore: i
171
172
  };
172
173
  });
@@ -181,13 +182,13 @@ const Ee = (t, e) => {
181
182
  let n = 0;
182
183
  if (r.isSet() && (n = r.json() ?? 0), n && e - n < xe)
183
184
  return !0;
184
- const i = Pe(t.apiUrl), u = {
185
+ const i = Pe(t.apiUrl), c = {
185
186
  projectId: t.projectId,
186
187
  path: window.location.pathname
187
- }, o = JSON.stringify(u), s = {
188
+ }, o = JSON.stringify(c), s = {
188
189
  "Content-Type": "application/json"
189
- }, f = document.getElementById("picked_script")?.dataset.verceltoken;
190
- f && (s["x-vercel-protection-bypass"] = f);
190
+ }, p = document.getElementById("picked_script")?.dataset.verceltoken;
191
+ p && (s["x-vercel-protection-bypass"] = p);
191
192
  const S = (await fetch(i, {
192
193
  method: "POST",
193
194
  headers: s,
@@ -212,32 +213,32 @@ function Y(t) {
212
213
  }
213
214
  const Be = b("predicate"), Re = w(({ client: t }) => {
214
215
  const e = Be.store({}), r = F(e, {
215
- register(s, a) {
216
+ register(s, d) {
216
217
  return {
217
218
  ...s,
218
- [a.name]: {
219
- name: a.name,
220
- predicate: a.predicate
219
+ [d.name]: {
220
+ name: d.name,
221
+ predicate: d.predicate
221
222
  }
222
223
  };
223
224
  }
224
225
  });
225
- function n(s, a) {
226
+ function n(s, d) {
226
227
  e.getState()[s] && k(
227
228
  "warn",
228
229
  `Predicate '${s}' already registered. Registering again will override the previous registration.`
229
- ), r.register(Object.freeze({ name: s, predicate: a }));
230
+ ), r.register(Object.freeze({ name: s, predicate: d }));
230
231
  }
231
232
  const i = e.map((s) => Object.values(s));
232
- function u(s) {
233
- return e.map((a) => a[s]?.predicate, { skipVoid: !1 });
233
+ function c(s) {
234
+ return e.map((d) => d[s]?.predicate, { skipVoid: !1 });
234
235
  }
235
236
  function o(s) {
236
- const a = H(() => {
237
+ const d = H(() => {
237
238
  }, {
238
239
  skipVoid: !1
239
- }), f = R(async () => {
240
- const h = u(s).getState();
240
+ }), p = R(async () => {
241
+ const h = c(s).getState();
241
242
  if (!h)
242
243
  return;
243
244
  const S = Y(t);
@@ -245,16 +246,16 @@ const Be = b("predicate"), Re = w(({ client: t }) => {
245
246
  });
246
247
  return I({
247
248
  source: { responses: t.responses.listStore, fields: t.fields.listStore },
248
- target: f
249
+ target: p
249
250
  }), I({
250
- clock: f.doneData,
251
+ clock: p.doneData,
251
252
  filter: (h) => h !== void 0,
252
- target: a
253
- }), f(), a;
253
+ target: d
254
+ }), p(), d;
254
255
  }
255
256
  return {
256
257
  register: n,
257
- getByName: u,
258
+ getByName: c,
258
259
  listStore: i,
259
260
  getEvokablePredicate: o
260
261
  };
@@ -266,157 +267,157 @@ const Ce = (t, e, r) => {
266
267
  r.register(t, e);
267
268
  }, _ = b("feature"), ze = w(({ client: t }) => {
268
269
  const e = _.store({}), r = _.store([]), n = F(e, {
269
- register(c, d) {
270
+ register(a, u) {
270
271
  return {
271
- ...c,
272
- [d.id]: d.feature
272
+ ...a,
273
+ [u.id]: u.feature
273
274
  };
274
275
  }
275
276
  });
276
- function i(c, d) {
277
- e.getState()[c] && k(
277
+ function i(a, u) {
278
+ e.getState()[a] && k(
278
279
  "warn",
279
- `Feature '${c}' already registered. Registering again will override the previous registration.`
280
+ `Feature '${a}' already registered. Registering again will override the previous registration.`
280
281
  );
281
282
  const l = {
282
- id: c,
283
+ id: a,
283
284
  feature: {
284
- ...d,
285
- id: c
285
+ ...u,
286
+ id: a
286
287
  }
287
288
  };
288
289
  n.register(
289
290
  Object.freeze({
290
- id: c,
291
+ id: a,
291
292
  feature: l
292
293
  })
293
294
  );
294
295
  }
295
- const u = R(
296
+ const c = R(
296
297
  async ({
297
- id: c,
298
- key: d,
299
- storage: p = "local"
298
+ id: a,
299
+ key: u,
300
+ storage: f = "local"
300
301
  }) => {
301
- const l = A(`feature:${c}:${d}`, "global"), y = (p === "session" ? z : C).get(l).boolean();
302
- return y === null ? null : { id: c, key: d, bucket: y, storage: p };
302
+ const l = A(`feature:${a}:${u}`, "global"), y = (f === "session" ? z : C).get(l).boolean();
303
+ return y === null ? null : { id: a, key: u, bucket: y, storage: f };
303
304
  }
304
- ), o = R((c) => {
305
- if (!c)
305
+ ), o = R((a) => {
306
+ if (!a)
306
307
  return null;
307
- const d = A(`feature:${c.id}:${c.key}`, "global");
308
- (c.storage === "session" ? z : C).set(d, c.bucket);
309
- }), s = /* @__PURE__ */ new Map(), a = X({
308
+ const u = A(`feature:${a.id}:${a.key}`, "global");
309
+ (a.storage === "session" ? z : C).set(u, a.bucket);
310
+ }), s = /* @__PURE__ */ new Map(), d = X({
310
311
  source: { allFeaturesStore: e, resolvedFeaturesStore: r },
311
- effect: async ({ allFeaturesStore: c, resolvedFeaturesStore: d }, { id: p, decide: l, key: m }) => {
312
- const y = d.find(
313
- (B) => B.id === p && B.key === m
312
+ effect: async ({ allFeaturesStore: a, resolvedFeaturesStore: u }, { id: f, decide: l, key: m }) => {
313
+ const y = u.find(
314
+ (B) => B.id === f && B.key === m
314
315
  );
315
316
  if (y)
316
317
  return y;
317
- const E = c[p];
318
+ const E = a[f];
318
319
  if (!E)
319
- throw new Error(`Feature with id '${p}' not found`);
320
- const x = s.get(`${p}:${m}`);
320
+ throw new Error(`Feature with id '${f}' not found`);
321
+ const x = s.get(`${f}:${m}`);
321
322
  if (x !== void 0) {
322
323
  const B = await x;
323
324
  return { id: E.id, bucket: B, key: m, storage: E.feature.storage };
324
325
  }
325
326
  const N = l();
326
- s.set(`${p}:${m}`, N);
327
+ s.set(`${f}:${m}`, N);
327
328
  const Q = await N;
328
329
  return { id: E.id, bucket: Q, key: m, storage: E.feature.storage };
329
330
  }
330
331
  });
331
332
  I({
332
333
  clock: n.register,
333
- fn: (c) => {
334
- const { id: d, feature: p } = c;
335
- return { id: d, key: p.feature.key, storage: p.feature.storage };
334
+ fn: (a) => {
335
+ const { id: u, feature: f } = a;
336
+ return { id: u, key: f.feature.key, storage: f.feature.storage };
336
337
  },
337
- target: u
338
+ target: c
338
339
  }), I({
339
340
  source: e,
340
- clock: a.doneData,
341
- fn: (c, d) => {
342
- const { id: p, bucket: l, storage: m } = d, y = c[p]?.feature.key;
343
- return y ? { key: y, id: p, bucket: l, storage: m } : null;
341
+ clock: d.doneData,
342
+ fn: (a, u) => {
343
+ const { id: f, bucket: l, storage: m } = u, y = a[f]?.feature.key;
344
+ return y ? { key: y, id: f, bucket: l, storage: m } : null;
344
345
  },
345
346
  target: o
346
347
  });
347
- const f = O({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
348
+ const p = O({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
348
349
  ({
349
- allFeaturesStore: c,
350
- resolvedFeaturesStore: d
351
- }) => Object.values(c).map((p) => {
352
- const l = d.find(
353
- (m) => m.id === p.id && m.key === p.feature.key
350
+ allFeaturesStore: a,
351
+ resolvedFeaturesStore: u
352
+ }) => Object.values(a).map((f) => {
353
+ const l = u.find(
354
+ (m) => m.id === f.id && m.key === f.feature.key
354
355
  );
355
356
  return l ? {
356
- id: p.id,
357
- name: p.feature.name,
358
- key: p.feature.key,
359
- getBucket: () => ({ id: p.id, bucket: l.bucket }),
357
+ id: f.id,
358
+ name: f.feature.name,
359
+ key: f.feature.key,
360
+ getBucket: () => ({ id: f.id, bucket: l.bucket }),
360
361
  isResolved: !0
361
362
  } : {
362
- id: p.id,
363
- name: p.feature.name,
364
- key: p.feature.key,
365
- getBucket: async () => await a(p.feature),
363
+ id: f.id,
364
+ name: f.feature.name,
365
+ key: f.feature.key,
366
+ getBucket: async () => await d(f.feature),
366
367
  isResolved: !1
367
368
  };
368
369
  })
369
370
  );
370
371
  I({
371
- clock: a.doneData,
372
+ clock: d.doneData,
372
373
  source: { resolvedFeatures: r },
373
- filter: ({ resolvedFeatures: c }, { id: d, key: p }) => !c.some(
374
- (m) => m.id === d && m.key === p
374
+ filter: ({ resolvedFeatures: a }, { id: u, key: f }) => !a.some(
375
+ (m) => m.id === u && m.key === f
375
376
  ),
376
- fn: (c, d) => d,
377
- target: t.eventBus.prepend((c) => ({
377
+ fn: (a, u) => u,
378
+ target: t.eventBus.prepend((a) => ({
378
379
  type: "feature_decide",
379
- feature: c
380
+ feature: a
380
381
  }))
381
382
  }), I({
382
- clock: [u.doneData, a.doneData],
383
+ clock: [c.doneData, d.doneData],
383
384
  source: r,
384
- fn: (c, d) => !d || c.some(
385
- (l) => l.id === d.id && l.key === d.key
386
- ) ? c : [...c, d],
385
+ fn: (a, u) => !u || a.some(
386
+ (l) => l.id === u.id && l.key === u.key
387
+ ) ? a : [...a, u],
387
388
  target: r
388
389
  });
389
- function h(c) {
390
- return f.map((d) => d.find((p) => p.id === c));
390
+ function h(a) {
391
+ return p.map((u) => u.find((f) => f.id === a));
391
392
  }
392
- function S(c) {
393
- return e.map((d) => d[c], { skipVoid: !1 });
393
+ function S(a) {
394
+ return e.map((u) => u[a], { skipVoid: !1 });
394
395
  }
395
- function g(c) {
396
- const d = H(
396
+ function g(a) {
397
+ const u = H(
397
398
  async () => {
398
399
  },
399
400
  { skipVoid: !1 }
400
- ), p = R(async () => {
401
- const l = h(c).getState();
401
+ ), f = R(async () => {
402
+ const l = h(a).getState();
402
403
  if (l)
403
404
  return async () => (await l.getBucket()).bucket;
404
405
  });
405
406
  return I({
406
407
  source: r,
407
- filter: (l) => l.some((m) => m.id === c),
408
- target: p
408
+ filter: (l) => l.some((m) => m.id === a),
409
+ target: f
409
410
  }), I({
410
- clock: p.doneData,
411
+ clock: f.doneData,
411
412
  filter: (l) => l !== void 0,
412
- target: d
413
- }), p(), d;
413
+ target: u
414
+ }), f(), u;
414
415
  }
415
416
  return {
416
417
  register: i,
417
418
  getById: h,
418
419
  getByName: S,
419
- listStore: f,
420
+ listStore: p,
420
421
  getEvokableFeature: g
421
422
  };
422
423
  });
@@ -445,25 +446,25 @@ const Ue = w(() => {
445
446
  L(s.experienceId, s.node)
446
447
  ]
447
448
  })), t.on(i, (o, s) => s);
448
- function u(o, s) {
449
- const a = { lastStepIndex: -1, secondLastStepIndex: -1 };
450
- for (let f = o.length - 1; f >= 0; f--) {
451
- const h = o[f], S = h?.node;
449
+ function c(o, s) {
450
+ const d = { lastStepIndex: -1, secondLastStepIndex: -1 };
451
+ for (let p = o.length - 1; p >= 0; p--) {
452
+ const h = o[p], S = h?.node;
452
453
  if (!(!S || !re(S)) && !(s && h?.experienceId !== s))
453
- if (a.lastStepIndex === -1)
454
- a.lastStepIndex = f;
454
+ if (d.lastStepIndex === -1)
455
+ d.lastStepIndex = p;
455
456
  else {
456
- a.secondLastStepIndex = f;
457
+ d.secondLastStepIndex = p;
457
458
  break;
458
459
  }
459
460
  }
460
- return a;
461
+ return d;
461
462
  }
462
463
  return t.on(n, (o, s) => {
463
- const { secondLastStepIndex: a } = u(o.entries, s.experienceId), f = a !== -1 ? o.entries.slice(0, a + 1) : o.entries;
464
+ const { secondLastStepIndex: d } = c(o.entries, s.experienceId), p = d !== -1 ? o.entries.slice(0, d + 1) : o.entries;
464
465
  return {
465
466
  ...o,
466
- entries: f
467
+ entries: p
467
468
  };
468
469
  }), {
469
470
  push: e,
@@ -478,36 +479,36 @@ function Ve() {
478
479
  }
479
480
  const Ne = () => D(), Me = b("field"), Te = w(() => {
480
481
  const t = Me.store({}), e = F(t, {
481
- register(s, a) {
482
+ register(s, d) {
482
483
  return {
483
484
  ...s,
484
- [a.field.id]: a.field
485
+ [d.field.id]: d.field
485
486
  };
486
487
  }
487
488
  });
488
489
  function r(s) {
489
490
  e.register({ field: s });
490
491
  }
491
- function n(s, a) {
492
- const f = u(s).getState();
493
- if (!f)
492
+ function n(s, d) {
493
+ const p = c(s).getState();
494
+ if (!p)
494
495
  return;
495
- const h = Object.assign({}, f, {
496
- ...a
496
+ const h = Object.assign({}, p, {
497
+ ...d
497
498
  });
498
499
  e.register({ field: { ...h } });
499
500
  }
500
501
  const i = t.map((s) => Object.values(s));
501
- function u(s) {
502
- return t.map((a) => a[s] || null);
502
+ function c(s) {
503
+ return t.map((d) => d[s] || null);
503
504
  }
504
505
  function o(s) {
505
- return t.map((a) => Object.values(a).find((f) => f.name === s) || null);
506
+ return t.map((d) => Object.values(d).find((p) => p.name === s) || null);
506
507
  }
507
508
  return {
508
509
  register: r,
509
510
  update: n,
510
- getById: u,
511
+ getById: c,
511
512
  listStore: i,
512
513
  getByName: o
513
514
  };
@@ -536,11 +537,11 @@ const Le = (t, e) => {
536
537
  function i(o) {
537
538
  return t.map((s) => s[o], { skipVoid: !1 });
538
539
  }
539
- function u(o) {
540
+ function c(o) {
540
541
  return t.map(
541
542
  (s) => {
542
- const a = s[o];
543
- return a ? a.action : void 0;
543
+ const d = s[o];
544
+ return d ? d.action : void 0;
544
545
  },
545
546
  { skipVoid: !1 }
546
547
  );
@@ -549,7 +550,7 @@ const Le = (t, e) => {
549
550
  register: r,
550
551
  getByName: i,
551
552
  listStore: n,
552
- getEvokableAction: u
553
+ getEvokableAction: c
553
554
  };
554
555
  });
555
556
  function qe() {
@@ -563,45 +564,45 @@ function G(t) {
563
564
  }
564
565
  const We = b("response"), Ye = w(({ client: t }) => {
565
566
  const e = We.store({}), r = D(), n = D(), i = F(e, {
566
- register(g, c) {
567
+ register(g, a) {
567
568
  return {
568
569
  ...g,
569
- [c.fieldId]: c.response
570
+ [a.fieldId]: a.response
570
571
  };
571
572
  },
572
- registerBatch(g, c) {
573
+ registerBatch(g, a) {
573
574
  return {
574
575
  ...g,
575
- ...c
576
+ ...a
576
577
  };
577
578
  },
578
- clear(g, c) {
579
- const { [c]: d, ...p } = g;
580
- return p;
579
+ clear(g, a) {
580
+ const { [a]: u, ...f } = g;
581
+ return f;
581
582
  },
582
583
  clearAll() {
583
584
  return {};
584
585
  }
585
586
  });
586
- function u(g, c) {
587
+ function c(g, a) {
587
588
  if (typeof g == "string") {
588
- if (c === void 0)
589
+ if (a === void 0)
589
590
  throw new Error("Response is required when registering a single field");
590
- i.register({ fieldId: g, response: c });
591
+ i.register({ fieldId: g, response: a });
591
592
  } else
592
593
  i.registerBatch(g);
593
594
  }
594
595
  async function o(g) {
595
- const c = [];
596
+ const a = [];
596
597
  return await Promise.allSettled(
597
- Object.entries(g).map(async ([d, p]) => {
598
- let l = p;
599
- const m = t.fields.getById(d).getState();
598
+ Object.entries(g).map(async ([u, f]) => {
599
+ let l = f;
600
+ const m = t.fields.getById(u).getState();
600
601
  if (!m) {
601
- c.push({
602
- fieldId: d,
603
- userMessage: `Field '${d}' not found`,
604
- systemMessage: `No field with ID '${d}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
602
+ a.push({
603
+ fieldId: u,
604
+ userMessage: `Field '${u}' not found`,
605
+ systemMessage: `No field with ID '${u}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
605
606
  value: l
606
607
  });
607
608
  return;
@@ -611,8 +612,8 @@ const We = b("response"), Ye = w(({ client: t }) => {
611
612
  $input: l
612
613
  });
613
614
  if (typeof y == "string") {
614
- c.push({
615
- fieldId: d,
615
+ a.push({
616
+ fieldId: u,
616
617
  userMessage: y,
617
618
  systemMessage: `Field validation resulted in an error: ${y}.`,
618
619
  value: l
@@ -620,8 +621,8 @@ const We = b("response"), Ye = w(({ client: t }) => {
620
621
  return;
621
622
  }
622
623
  if (y === !1) {
623
- c.push({
624
- fieldId: d,
624
+ a.push({
625
+ fieldId: u,
625
626
  userMessage: "This field is invalid",
626
627
  systemMessage: "Field validation resulted in an unspecified error.",
627
628
  value: l
@@ -630,8 +631,8 @@ const We = b("response"), Ye = w(({ client: t }) => {
630
631
  }
631
632
  }
632
633
  if (m.required && G(l)) {
633
- c.push({
634
- fieldId: d,
634
+ a.push({
635
+ fieldId: u,
635
636
  userMessage: "This field is required",
636
637
  systemMessage: "Field is required.",
637
638
  value: l
@@ -639,8 +640,8 @@ const We = b("response"), Ye = w(({ client: t }) => {
639
640
  return;
640
641
  }
641
642
  if (!m.multiple && Array.isArray(l) && l.length > 1) {
642
- c.push({
643
- fieldId: d,
643
+ a.push({
644
+ fieldId: u,
644
645
  userMessage: "This field expects a single response",
645
646
  systemMessage: "Field expects a single response.",
646
647
  value: l
@@ -649,33 +650,33 @@ const We = b("response"), Ye = w(({ client: t }) => {
649
650
  }
650
651
  if (m.options) {
651
652
  const y = m.options.map((x) => x.value), E = Array.isArray(l) ? l : [l];
652
- Array.isArray(l) && (E.every((x) => y.includes(x)) || c.push({
653
- fieldId: d,
653
+ Array.isArray(l) && (E.every((x) => y.includes(x)) || a.push({
654
+ fieldId: u,
654
655
  userMessage: "This field expects a valid option",
655
656
  systemMessage: `Field expects a valid option. Valid options are: ${y.join(", ")}`,
656
657
  value: l
657
658
  }));
658
659
  }
659
660
  })
660
- ), { responsesToCommit: g, validationErrors: c };
661
+ ), { responsesToCommit: g, validationErrors: a };
661
662
  }
662
663
  async function s(g) {
663
- const { responsesToCommit: c, validationErrors: d } = await o(g);
664
- return d.length ? { errors: d } : (i.registerBatch(c), { errors: [] });
664
+ const { responsesToCommit: a, validationErrors: u } = await o(g);
665
+ return u.length ? { errors: u } : (i.registerBatch(a), { errors: [] });
665
666
  }
666
- const a = e.map((g) => g), f = e.map((g) => Object.keys(g).map((d) => ({
667
- fieldId: d,
668
- value: g[d]
667
+ const d = e.map((g) => g), p = e.map((g) => Object.keys(g).map((u) => ({
668
+ fieldId: u,
669
+ value: g[u]
669
670
  })));
670
671
  function h(g) {
671
- const c = t.fields.getById(g), d = e.map((p) => p[g] || null);
672
- return O({ f: c, r: d }, ({ f: p, r: l }) => l || (p?.defaultValue ? p.defaultValue : null));
672
+ const a = t.fields.getById(g), u = e.map((f) => f[g] || null);
673
+ return O({ f: a, r: u }, ({ f, r: l }) => l || (f?.defaultValue ? f.defaultValue : null));
673
674
  }
674
675
  function S(g) {
675
- const c = t.fields.getByName(g);
676
- return O({ f: c, s: e }, ({ f: d, s: p }) => {
677
- const l = d && p[d.id] || null;
678
- return l || (d?.defaultValue ? d.defaultValue : null);
676
+ const a = t.fields.getByName(g);
677
+ return O({ f: a, s: e }, ({ f: u, s: f }) => {
678
+ const l = u && f[u.id] || null;
679
+ return l || (u?.defaultValue ? u.defaultValue : null);
679
680
  });
680
681
  }
681
682
  return I({
@@ -685,13 +686,13 @@ const We = b("response"), Ye = w(({ client: t }) => {
685
686
  clock: n,
686
687
  target: i.clear
687
688
  }), {
688
- register: u,
689
+ register: c,
689
690
  clearAll: r,
690
691
  clear: n,
691
692
  commit: s,
692
693
  getResponsesToCommit: o,
693
- listStore: f,
694
- getAllStore: a,
694
+ listStore: p,
695
+ getAllStore: d,
695
696
  getByFieldId: h,
696
697
  getByFieldName: S
697
698
  };
@@ -699,7 +700,7 @@ const We = b("response"), Ye = w(({ client: t }) => {
699
700
  function Je(t) {
700
701
  return v(Ye, t);
701
702
  }
702
- const Qe = () => "0.0.1-dev.1769998938557";
703
+ const Qe = () => "0.0.1-dev.1770162676770";
703
704
  function Xe() {
704
705
  if (U()) {
705
706
  const t = [
@@ -722,8 +723,8 @@ function Ze() {
722
723
  for (const [i] of t.entries())
723
724
  i.startsWith("picked-") && r.add(i);
724
725
  for (const i of r) {
725
- const u = i.replace("picked-", "");
726
- e[u] = t.getAll(i);
726
+ const c = i.replace("picked-", "");
727
+ e[c] = t.getAll(i);
727
728
  }
728
729
  const n = A("s");
729
730
  if (r.size > 0)
@@ -756,12 +757,12 @@ const tt = A("session", "global"), rt = () => {
756
757
  setIsUser(i) {
757
758
  this.isUser = i, r(this);
758
759
  },
759
- setIdentifier(i, u) {
760
- this.identifiers = { ...this.identifiers, [i]: u }, r(this);
760
+ setIdentifier(i, c) {
761
+ this.identifiers = { ...this.identifiers, [i]: c }, r(this);
761
762
  },
762
763
  removeIdentifier(i) {
763
764
  this.identifiers && (this.identifiers = Object.fromEntries(
764
- Object.entries(this.identifiers).filter(([u]) => u !== i)
765
+ Object.entries(this.identifiers).filter(([c]) => c !== i)
765
766
  ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
766
767
  }
767
768
  };
@@ -840,11 +841,11 @@ function dt(t, e) {
840
841
  return typeof r == "function" ? r() : r;
841
842
  }
842
843
  function lt(t, e) {
843
- const r = t.split("|").map((u) => u.trim()), n = r.shift() ?? "";
844
+ const r = t.split("|").map((c) => c.trim()), n = r.shift() ?? "";
844
845
  let i = dt(n, e);
845
- for (const u of r) {
846
- const [o, ...s] = u.split(":"), a = o?.trim() ?? "", f = s.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = ct[a];
847
- h && (i = h(i, f));
846
+ for (const c of r) {
847
+ const [o, ...s] = c.split(":"), d = o?.trim() ?? "", p = s.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = ct[d];
848
+ h && (i = h(i, p));
848
849
  }
849
850
  return $(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
850
851
  }
@@ -905,8 +906,8 @@ class ft {
905
906
  r && (this.condition === void 0 ? n = !0 : typeof this.condition == "boolean" ? n = this.condition : n = await j(this, this.condition) === !0);
906
907
  const i = r && n === !0;
907
908
  if (typeof n == "boolean" && this.session) {
908
- const u = n;
909
- this.session.setIsUser(u), this.eventBus({ type: "user_decide", value: u });
909
+ const c = n;
910
+ this.session.setIsUser(c), this.eventBus({ type: "user_decide", value: c });
910
911
  }
911
912
  this.eventBus({ type: "initialize" }), document.body && i && M(this), await se(), i && M(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
912
913
  })();
@@ -981,13 +982,13 @@ class ft {
981
982
  const [n, i] = r.split(":");
982
983
  if (!n || !i)
983
984
  return;
984
- let u = i;
985
- u === "true" && (u = !0), u === "false" && (u = !1), this.registerFeature(n, {
986
- key: `${u}`,
985
+ let c = i;
986
+ c === "true" && (c = !0), c === "false" && (c = !1), this.registerFeature(n, {
987
+ key: `${c}`,
987
988
  // use the assigned bucket value as the key
988
989
  name: n,
989
990
  // eslint-disable-next-line sonarjs/function-return-type
990
- decide: () => u,
991
+ decide: () => c,
991
992
  storage: "session"
992
993
  });
993
994
  } catch {
@@ -1060,7 +1061,7 @@ class ft {
1060
1061
  * // => "Fruits: apple, banana, and cherry"
1061
1062
  */
1062
1063
  renderString = (e, r) => {
1063
- const n = this.responses.listStore.getState().reduce((i, u) => (i[u.fieldId] = u.value, i), {});
1064
+ const n = this.responses.listStore.getState().reduce((i, c) => (i[c.fieldId] = c.value, i), {});
1064
1065
  return pt(e, {
1065
1066
  ...r,
1066
1067
  responses: n
@@ -1081,8 +1082,8 @@ async function bt(t, e) {
1081
1082
  if (!n.options || !J(n))
1082
1083
  return n;
1083
1084
  const o = (await Promise.all(
1084
- n.options.map(async (a) => a.condition ? await j(t, a.condition) ? a : null : a)
1085
- )).filter((a) => a !== null);
1085
+ n.options.map(async (d) => d.condition ? await j(t, d.condition) ? d : null : d)
1086
+ )).filter((d) => d !== null);
1086
1087
  return o.length === n.options.length ? n : o.length === 0 ? null : { ...n, options: o };
1087
1088
  })
1088
1089
  )).filter((n) => n !== null);