@picked/client 0.0.1-dev.1769486944066 → 0.0.1-dev.1769989663715

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