@picked/client 0.0.1-dev.1767670478319 → 0.0.1-dev.1767836126674

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