@picked/client 0.0.9 → 0.0.10-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/index.js +1 -1
  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/cjs/plugins/shopify/index.js +1 -1
  6. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  7. package/dist/cjs/plugins/web-components/index.js +1 -1
  8. package/dist/cjs/plugins/window-object/index.js +1 -1
  9. package/dist/cjs/server/index.js +1 -1
  10. package/dist/esm/index.js +168 -152
  11. package/dist/esm/plugins/experience-browser-storage/index.js +15 -14
  12. package/dist/esm/plugins/history-browser-storage/index.js +1 -1
  13. package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
  14. package/dist/esm/plugins/shopify/index.js +32 -33
  15. package/dist/esm/plugins/single-page-app/index.js +3 -3
  16. package/dist/esm/plugins/web-components/index.js +1 -1
  17. package/dist/esm/plugins/window-object/index.js +1 -1
  18. package/dist/esm/server/index.js +1 -1
  19. package/dist/{experience-instance-C1Ky25uw.js → experience-instance-BEKoIaYp.js} +156 -151
  20. package/dist/{experience-instance-DNI5sbjx.cjs → experience-instance-D4dHslLZ.cjs} +1 -1
  21. package/dist/{storage-D87xFySf.js → storage-BxBBl9Bw.js} +39 -31
  22. package/dist/storage-LI3UdcCr.cjs +1 -0
  23. package/dist/{supports-yKVnaaMQ.js → supports-BjhuLJ8z.js} +20 -12
  24. package/dist/supports-YvpQZxbh.cjs +1 -0
  25. package/dist/types/entities/experience-instance/experience-instance.d.ts +7 -7
  26. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  27. package/dist/types/picked.d.ts +2 -0
  28. package/dist/types/picked.d.ts.map +1 -1
  29. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  30. package/dist/types/plugins/shopify/plugin.d.ts.map +1 -1
  31. package/dist/types/utils/events.d.ts +23 -24
  32. package/dist/types/utils/events.d.ts.map +1 -1
  33. package/dist/types/utils/storage.d.ts +3 -0
  34. package/dist/types/utils/storage.d.ts.map +1 -1
  35. package/dist/types/utils/supports.d.ts +1 -0
  36. package/dist/types/utils/supports.d.ts.map +1 -1
  37. package/dist/types/utils/user-session.d.ts +5 -0
  38. package/dist/types/utils/user-session.d.ts.map +1 -0
  39. package/package.json +1 -1
  40. package/dist/storage-BPJwmlva.cjs +0 -1
  41. package/dist/supports-B6KShYPU.cjs +0 -1
package/dist/esm/index.js CHANGED
@@ -1,20 +1,20 @@
1
- var W = Object.defineProperty;
2
- var G = (t, e, s) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
- var y = (t, e, s) => G(t, typeof e != "symbol" ? e + "" : e, s);
4
- import { createDomain as F, createApi as b, createEffect as D, attach as J, sample as P, combine as A, createEvent as C } from "effector";
5
- import { createFactory as k, invoke as x } from "@withease/factories";
6
- import { g as z, t as Y, c as Q, e as R, i as X, a as Z, b as ee, d as te } from "../experience-instance-C1Ky25uw.js";
7
- import { f as it } from "../experience-instance-C1Ky25uw.js";
1
+ var G = Object.defineProperty;
2
+ var W = (t, e, s) => e in t ? G(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var h = (t, e, s) => W(t, typeof e != "symbol" ? e + "" : e, s);
4
+ import { createDomain as x, createApi as I, createEffect as O, attach as Y, sample as P, combine as A, createEvent as C } from "effector";
5
+ import { createFactory as k, invoke as b } from "@withease/factories";
6
+ import { g as U, t as J, c as Q, e as R, i as X, a as Z, b as ee, d as te } from "../experience-instance-BEKoIaYp.js";
7
+ import { f as gt } from "../experience-instance-BEKoIaYp.js";
8
8
  import { l as v } from "../logger-C9a75KZn.js";
9
- import { c as B, s as j, l as O } from "../storage-D87xFySf.js";
10
- import { a as ct } from "../storage-D87xFySf.js";
9
+ import { c as $, s as B, l as D } from "../storage-BxBBl9Bw.js";
10
+ import { a as mt } from "../storage-BxBBl9Bw.js";
11
11
  import { g as re } from "../id-BW-g3y32.js";
12
12
  import { i as se } from "../object-JwZ58NOH.js";
13
- import { s as _, a as ne, b as oe } from "../supports-yKVnaaMQ.js";
14
- import { g as lt, d as dt, i as pt, e as gt, c as ft, f as mt, h as yt, j as ht } from "../supports-yKVnaaMQ.js";
15
- const U = F("experience"), ie = k(
13
+ import { s as z, a as ne, b as oe, c as ie, d as ae } from "../supports-BjhuLJ8z.js";
14
+ import { h as yt, f as St, j as wt, e as vt, g as kt, i as bt, k as xt } from "../supports-BjhuLJ8z.js";
15
+ const _ = x("experience"), ce = k(
16
16
  ({ client: t, experience: e }) => {
17
- const s = U.store(e), o = b(s, {
17
+ const s = _.store(e), o = I(s, {
18
18
  merge(n, d) {
19
19
  return {
20
20
  ...n,
@@ -44,11 +44,11 @@ const U = F("experience"), ie = k(
44
44
  };
45
45
  }
46
46
  );
47
- function ae(t) {
48
- return x(ie, t);
47
+ function ue(t) {
48
+ return b(ce, t);
49
49
  }
50
- const ce = k(({ client: t }) => {
51
- const e = U.store({}), s = b(e, {
50
+ const le = k(({ client: t }) => {
51
+ const e = _.store({}), s = I(e, {
52
52
  register(r, n) {
53
53
  return {
54
54
  ...r,
@@ -62,7 +62,7 @@ const ce = k(({ client: t }) => {
62
62
  n.merge({ experience: r, strategy: "override" });
63
63
  return;
64
64
  }
65
- const d = ae({ client: t, experience: r });
65
+ const d = ue({ client: t, experience: r });
66
66
  s.register(d);
67
67
  }
68
68
  const i = e.map((r) => Object.values(r));
@@ -75,34 +75,34 @@ const ce = k(({ client: t }) => {
75
75
  listStore: i
76
76
  };
77
77
  });
78
- function ue(t) {
79
- return x(ce, t);
78
+ function de(t) {
79
+ return b(le, t);
80
80
  }
81
- const le = (t, e) => {
81
+ const pe = (t, e) => {
82
82
  e.register(t);
83
83
  }, H = (t, e) => {
84
- const { targetSelectors: s } = e.configStore.getState(), o = z(s, e.id);
84
+ const { targetSelectors: s } = e.configStore.getState(), o = U(s, e.id);
85
85
  o.forEach(
86
- ({ elements: l }) => l.forEach((r) => Y(r, e.id))
86
+ ({ elements: l }) => l.forEach((r) => J(r, e.id))
87
87
  ), Q(o, e.id).forEach((l) => {
88
88
  t.experienceInstances.spawn(e, l);
89
89
  });
90
- }, T = async (t) => {
90
+ }, M = async (t) => {
91
91
  await Promise.all(
92
92
  t.experiences.listStore.getState().map(async (e) => {
93
- await de(t, e) && H(t, e);
93
+ await ge(t, e) && H(t, e);
94
94
  })
95
95
  );
96
- }, de = async (t, e) => {
96
+ }, ge = async (t, e) => {
97
97
  const { type: s, decisionLogic: o, targetSelectors: i } = e.configStore.getState();
98
- return z(i, e.id).length < 1 ? !1 : s === "funnel" ? o ? await R(t, o) === !0 : !1 : i.length === 0 ? !1 : X(o) ? await R(t, o) === !0 : !0;
99
- }, pe = (t, e, s) => {
98
+ return U(i, e.id).length < 1 ? !1 : s === "funnel" ? o ? await R(t, o) === !0 : !1 : i.length === 0 ? !1 : X(o) ? await R(t, o) === !0 : !0;
99
+ }, fe = (t, e, s) => {
100
100
  const o = e.name, i = e.setup(t);
101
101
  if (i) {
102
102
  const l = s[o] ?? {};
103
103
  s[o] = Object.freeze({ ...l, ...i });
104
104
  }
105
- }, ge = F("component"), fe = k(
105
+ }, me = x("component"), he = k(
106
106
  ({ client: t, component: e, name: s }) => {
107
107
  const o = t.frameworks.getByName(e.frameworkName);
108
108
  return {
@@ -112,11 +112,11 @@ const le = (t, e) => {
112
112
  };
113
113
  }
114
114
  );
115
- function me(t) {
116
- return x(fe, t);
115
+ function ye(t) {
116
+ return b(he, t);
117
117
  }
118
- const ye = k(({ client: t }) => {
119
- const e = ge.store({}), s = b(e, {
118
+ const Se = k(({ client: t }) => {
119
+ const e = me.store({}), s = I(e, {
120
120
  register(r, n) {
121
121
  return {
122
122
  ...r,
@@ -129,8 +129,8 @@ const ye = k(({ client: t }) => {
129
129
  "warn",
130
130
  `Component '${r}' already registered. Registering again will override the previous registration.`
131
131
  );
132
- const h = me({ client: t, name: r, component: n });
133
- s.register(h);
132
+ const y = ye({ client: t, name: r, component: n });
133
+ s.register(y);
134
134
  }
135
135
  const i = e.map((r) => Object.values(r));
136
136
  function l(r) {
@@ -142,13 +142,13 @@ const ye = k(({ client: t }) => {
142
142
  listStore: i
143
143
  };
144
144
  });
145
- function he(t) {
146
- return x(ye, t);
145
+ function we(t) {
146
+ return b(Se, t);
147
147
  }
148
- const V = (t, e, s) => {
148
+ const T = (t, e, s) => {
149
149
  s.register(t, e);
150
- }, Se = F("framework"), we = k(({ client: t }) => {
151
- const e = Se.store({}), s = b(e, {
150
+ }, ve = x("framework"), ke = k(({ client: t }) => {
151
+ const e = ve.store({}), s = I(e, {
152
152
  register(r, n) {
153
153
  return {
154
154
  ...r,
@@ -172,15 +172,15 @@ const V = (t, e, s) => {
172
172
  listStore: i
173
173
  };
174
174
  });
175
- function ve(t) {
176
- return x(we, t);
175
+ function be(t) {
176
+ return b(ke, t);
177
177
  }
178
- const ke = (t, e) => {
178
+ const xe = (t, e) => {
179
179
  e.register(t.name, t);
180
- }, xe = 6e3, M = B("last_ping", "global"), Fe = (t) => `${t}/api/v1/ping`, be = async (t) => {
180
+ }, Ie = 6e3, V = $("last_ping", "global"), Fe = (t) => `${t}/api/v1/ping`, Ee = async (t) => {
181
181
  try {
182
- const e = Date.now(), s = localStorage.getItem(M);
183
- if (s && e - parseInt(s) < xe)
182
+ const e = Date.now(), s = localStorage.getItem(V);
183
+ if (s && e - parseInt(s) < Ie)
184
184
  return !0;
185
185
  const o = Fe(t.apiUrl), i = {
186
186
  projectId: t.projectId,
@@ -194,12 +194,12 @@ const ke = (t, e) => {
194
194
  headers: r,
195
195
  body: l
196
196
  })).ok;
197
- return c && localStorage.setItem(M, e.toString()), c;
197
+ return c && localStorage.setItem(V, e.toString()), c;
198
198
  } catch (e) {
199
199
  return v("error", e), !1;
200
200
  }
201
201
  };
202
- function Ie(t) {
202
+ function Pe(t) {
203
203
  const e = typeof window < "u", s = {
204
204
  client: t,
205
205
  responses: t.responses.listStore.getState(),
@@ -211,8 +211,8 @@ function Ie(t) {
211
211
  };
212
212
  return Object.freeze(s);
213
213
  }
214
- const Ee = F("predicate"), Pe = k(({ client: t }) => {
215
- const e = Ee.store({}), s = b(e, {
214
+ const Re = x("predicate"), $e = k(({ client: t }) => {
215
+ const e = Re.store({}), s = I(e, {
216
216
  register(r, n) {
217
217
  return {
218
218
  ...r,
@@ -239,13 +239,13 @@ const Ee = F("predicate"), Pe = k(({ client: t }) => {
239
239
  listStore: i
240
240
  };
241
241
  });
242
- function Re(t) {
243
- return x(Pe, t);
242
+ function Be(t) {
243
+ return b($e, t);
244
244
  }
245
- const Be = (t, e, s) => {
245
+ const je = (t, e, s) => {
246
246
  s.register(t, e);
247
- }, N = F("feature"), je = k(() => {
248
- const t = N.store({}), e = N.store([]), s = b(t, {
247
+ }, N = x("feature"), Ae = k(() => {
248
+ const t = N.store({}), e = N.store([]), s = I(t, {
249
249
  register(c, f) {
250
250
  return {
251
251
  ...c,
@@ -272,25 +272,25 @@ const Be = (t, e, s) => {
272
272
  })
273
273
  );
274
274
  }
275
- const i = D(
275
+ const i = O(
276
276
  async ({
277
277
  id: c,
278
278
  key: f,
279
279
  storage: a = "local"
280
280
  }) => {
281
- const p = B(`feature:${c}:${f}`, "global"), m = (a === "session" ? j : O).get(p).boolean();
281
+ const p = $(`feature:${c}:${f}`, "global"), m = (a === "session" ? B : D).get(p).boolean();
282
282
  if (m !== null)
283
283
  return { id: c, bucket: m };
284
284
  }
285
- ), l = D((c) => {
285
+ ), l = O((c) => {
286
286
  if (!c)
287
287
  return null;
288
- const f = B(`feature:${c.id}:${c.key}`, "global");
289
- (c.storage === "session" ? j : O).set(f, c.bucket);
290
- }), r = /* @__PURE__ */ new Map(), n = J({
288
+ const f = $(`feature:${c.id}:${c.key}`, "global");
289
+ (c.storage === "session" ? B : D).set(f, c.bucket);
290
+ }), r = /* @__PURE__ */ new Map(), n = Y({
291
291
  source: { allFeaturesStore: t, resolvedFeaturesStore: e },
292
292
  effect: async ({ allFeaturesStore: c, resolvedFeaturesStore: f }, { id: a, decide: p, key: g }) => {
293
- const m = f.find((I) => I.id === a);
293
+ const m = f.find((F) => F.id === a);
294
294
  if (m)
295
295
  return m;
296
296
  const u = c[a];
@@ -298,13 +298,13 @@ const Be = (t, e, s) => {
298
298
  throw new Error(`Feature with id '${a}' not found`);
299
299
  const S = r.get(`${a}:${g}`);
300
300
  if (S) {
301
- const I = await S;
302
- return { id: u.id, bucket: I, storage: u.feature.storage };
301
+ const F = await S;
302
+ return { id: u.id, bucket: F, storage: u.feature.storage };
303
303
  }
304
304
  const w = p();
305
305
  r.set(`${a}:${g}`, w);
306
- const $ = await w;
307
- return { id: u.id, bucket: $, storage: u.feature.storage };
306
+ const j = await w;
307
+ return { id: u.id, bucket: j, storage: u.feature.storage };
308
308
  }
309
309
  });
310
310
  P({
@@ -350,21 +350,21 @@ const Be = (t, e, s) => {
350
350
  };
351
351
  })
352
352
  );
353
- function h(c) {
353
+ function y(c) {
354
354
  return t.map((f) => f[c], { skipVoid: !1 });
355
355
  }
356
356
  return {
357
357
  register: o,
358
- getByName: h,
358
+ getByName: y,
359
359
  listStore: d
360
360
  };
361
361
  });
362
- function $e() {
363
- return x(je);
362
+ function Ce() {
363
+ return b(Ae);
364
364
  }
365
- const Ae = (t, e, s) => {
365
+ const De = (t, e, s) => {
366
366
  s.register(t, e);
367
- }, E = F("history");
367
+ }, E = x("history");
368
368
  function L(t, e) {
369
369
  return {
370
370
  // eslint-disable-next-line sonarjs/pseudo-random
@@ -374,7 +374,7 @@ function L(t, e) {
374
374
  experienceId: t
375
375
  };
376
376
  }
377
- const Ce = k(() => {
377
+ const Oe = k(() => {
378
378
  const t = E.store({ entries: [] }), e = E.event(), s = E.event(), o = E.event(), i = E.event();
379
379
  t.on(e, (r, n) => ({
380
380
  entries: [...r.entries, L(n.experienceId, n.node)]
@@ -386,23 +386,23 @@ const Ce = k(() => {
386
386
  })), t.on(i, (r, n) => n);
387
387
  function l(r, n) {
388
388
  const d = { lastStepIndex: -1, secondLastStepIndex: -1 };
389
- for (let h = r.length - 1; h >= 0; h--) {
390
- const c = r[h], f = c == null ? void 0 : c.node;
389
+ for (let y = r.length - 1; y >= 0; y--) {
390
+ const c = r[y], f = c == null ? void 0 : c.node;
391
391
  if (!(!f || !Z(f)) && !(n && (c == null ? void 0 : c.experienceId) !== n))
392
392
  if (d.lastStepIndex === -1)
393
- d.lastStepIndex = h;
393
+ d.lastStepIndex = y;
394
394
  else {
395
- d.secondLastStepIndex = h;
395
+ d.secondLastStepIndex = y;
396
396
  break;
397
397
  }
398
398
  }
399
399
  return d;
400
400
  }
401
401
  return t.on(o, (r, n) => {
402
- const { secondLastStepIndex: d } = l(r.entries, n.experienceId), h = d !== -1 ? r.entries.slice(0, d + 1) : r.entries;
402
+ const { secondLastStepIndex: d } = l(r.entries, n.experienceId), y = d !== -1 ? r.entries.slice(0, d + 1) : r.entries;
403
403
  return {
404
404
  ...r,
405
- entries: h
405
+ entries: y
406
406
  };
407
407
  }), {
408
408
  push: e,
@@ -412,11 +412,11 @@ const Ce = k(() => {
412
412
  entriesStore: t.map((r) => r.entries)
413
413
  };
414
414
  });
415
- function De() {
416
- return x(Ce);
415
+ function Me() {
416
+ return b(Oe);
417
417
  }
418
- const Oe = () => C(), Te = F("field"), Ve = k(() => {
419
- const t = Te.store({}), e = b(t, {
418
+ const Te = () => C(), Ve = x("field"), Ne = k(() => {
419
+ const t = Ve.store({}), e = I(t, {
420
420
  register(r, n) {
421
421
  return {
422
422
  ...r,
@@ -441,13 +441,13 @@ const Oe = () => C(), Te = F("field"), Ve = k(() => {
441
441
  getByName: l
442
442
  };
443
443
  });
444
- function Me() {
445
- return x(Ve);
444
+ function Le() {
445
+ return b(Ne);
446
446
  }
447
- const Ne = (t, e) => {
447
+ const Ue = (t, e) => {
448
448
  e.register(t);
449
- }, Le = F("response"), ze = k(({ client: t }) => {
450
- const e = Le.store({}), s = C(), o = C(), i = b(e, {
449
+ }, ze = x("response"), _e = k(({ client: t }) => {
450
+ const e = ze.store({}), s = C(), o = C(), i = I(e, {
451
451
  register(a, p) {
452
452
  return {
453
453
  ...a,
@@ -528,8 +528,8 @@ const Ne = (t, e) => {
528
528
  return;
529
529
  }
530
530
  if (S.options) {
531
- const w = S.options.map((I) => I.value), $ = Array.isArray(u) ? u : [u];
532
- Array.isArray(u) && ($.every((I) => w.includes(I)) || p.push({
531
+ const w = S.options.map((F) => F.value), j = Array.isArray(u) ? u : [u];
532
+ Array.isArray(u) && (j.every((F) => w.includes(F)) || p.push({
533
533
  fieldId: g,
534
534
  userMessage: "This field expects a valid option",
535
535
  systemMessage: `Field expects a valid option. Valid options are: ${w.join(", ")}`,
@@ -543,7 +543,7 @@ const Ne = (t, e) => {
543
543
  const { responsesToCommit: p, validationErrors: g } = await r(a);
544
544
  return g.length ? { errors: g } : (i.registerBatch(p), { errors: [] });
545
545
  }
546
- const d = e.map((a) => a), h = e.map((a) => Object.keys(a).map((g) => ({
546
+ const d = e.map((a) => a), y = e.map((a) => Object.keys(a).map((g) => ({
547
547
  fieldId: g,
548
548
  value: a[g]
549
549
  })));
@@ -570,18 +570,18 @@ const Ne = (t, e) => {
570
570
  clear: o,
571
571
  commit: n,
572
572
  getResponsesToCommit: r,
573
- listStore: h,
573
+ listStore: y,
574
574
  getAllStore: d,
575
575
  getByFieldId: c,
576
576
  getByFieldName: f
577
577
  };
578
578
  });
579
- function _e(t) {
580
- return x(ze, t);
579
+ function He(t) {
580
+ return b(_e, t);
581
581
  }
582
- const Ue = () => "0.0.9";
583
- function He() {
584
- if (_()) {
582
+ const Ke = () => "0.0.10-next.2";
583
+ function qe() {
584
+ if (z()) {
585
585
  const t = [
586
586
  document.currentScript,
587
587
  document.getElementById("picked_script"),
@@ -595,7 +595,7 @@ function He() {
595
595
  }
596
596
  return "https://api.picked.app";
597
597
  }
598
- function Ke() {
598
+ function Ge() {
599
599
  if (!ne())
600
600
  return {};
601
601
  const t = new URLSearchParams(window.location.search), e = {}, s = /* @__PURE__ */ new Set();
@@ -605,66 +605,81 @@ function Ke() {
605
605
  const l = i.replace("picked-", "");
606
606
  e[l] = t.getAll(i);
607
607
  }
608
- const o = B("s");
608
+ const o = $("s");
609
609
  if (s.size > 0)
610
- j.set(o, e);
610
+ B.set(o, e);
611
611
  else {
612
- const i = j.get(o);
612
+ const i = B.get(o);
613
613
  if (i)
614
614
  return i.json() || {};
615
615
  }
616
616
  return e;
617
617
  }
618
+ function We() {
619
+ if (ie())
620
+ return crypto.randomUUID();
621
+ const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15), o = Math.random().toString(36).substring(2, 15);
622
+ return `${t}-${e}-${s}-${o}`;
623
+ }
624
+ const Ye = () => ({
625
+ id: We()
626
+ }), Je = $("session", "global"), Qe = () => {
627
+ if (!oe()) return null;
628
+ const t = D.get(Je);
629
+ let e = t.isSet() ? t.json() : null;
630
+ return e || (e = Ye(), t.set(e)), e;
631
+ }, Xe = () => Qe();
618
632
  class K {
619
633
  constructor(e) {
620
- y(this, "options");
621
- y(this, "isReady", !1);
622
- y(this, "project");
623
- y(this, "plugins", {});
624
- y(this, "eventBus", Oe());
625
- y(this, "organizationId");
626
- y(this, "projectId");
627
- y(this, "apiUrl");
628
- y(this, "searchParams", Ke());
629
- y(this, "history", De());
630
- y(this, "components", he({ client: this }));
631
- y(this, "experienceInstances", ee({ client: this }));
632
- y(this, "experiences", ue({ client: this }));
633
- y(this, "frameworks", ve({ client: this }));
634
- y(this, "predicates", Re({ client: this }));
635
- y(this, "features", $e());
636
- y(this, "responses", _e({ client: this }));
637
- y(this, "fields", Me());
638
- v("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || He(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.eventBus({ type: "initialized", version: Ue() }), v("info", "Picked client initialized.");
634
+ h(this, "options");
635
+ h(this, "isReady", !1);
636
+ h(this, "project");
637
+ h(this, "plugins", {});
638
+ h(this, "eventBus", Te());
639
+ h(this, "organizationId");
640
+ h(this, "projectId");
641
+ h(this, "apiUrl");
642
+ h(this, "session");
643
+ h(this, "searchParams", Ge());
644
+ h(this, "history", Me());
645
+ h(this, "components", we({ client: this }));
646
+ h(this, "experienceInstances", ee({ client: this }));
647
+ h(this, "experiences", de({ client: this }));
648
+ h(this, "frameworks", be({ client: this }));
649
+ h(this, "predicates", Be({ client: this }));
650
+ h(this, "features", Ce());
651
+ h(this, "responses", He({ client: this }));
652
+ h(this, "fields", Le());
653
+ v("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || qe(), this.session = Xe(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.eventBus({ type: "initialized", version: Ke() }), v("info", "Picked client initialized.");
639
654
  }
640
655
  start() {
641
- be(this), (async () => {
642
- _() && (document.body && await T(this), await te(), await T(this), this.eventBus({ type: "ready" }), this.isReady = !0);
656
+ Ee(this), (async () => {
657
+ z() && (document.body && M(this), await te(), await M(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session }));
643
658
  })();
644
659
  }
645
660
  registerFramework(e) {
646
- ke(e, this.frameworks);
661
+ xe(e, this.frameworks);
647
662
  }
648
663
  registerComponent(e, s) {
649
- V(e, s, this.components);
664
+ T(e, s, this.components);
650
665
  }
651
666
  registerPlugin(e) {
652
- pe(this, e, this.plugins);
667
+ fe(this, e, this.plugins);
653
668
  }
654
669
  registerFeature(e, s) {
655
- Ae(e, s, this.features);
670
+ De(e, s, this.features);
656
671
  }
657
672
  registerPredicate(e, s) {
658
- Be(e, s, this.predicates);
673
+ je(e, s, this.predicates);
659
674
  }
660
675
  registerField(e) {
661
- Ne(e, this.fields);
676
+ Ue(e, this.fields);
662
677
  }
663
678
  registerExperience(e) {
664
- e.component && V(`experience:${e.id}`, e.component, this.components), le(e, this.experiences);
679
+ e.component && T(`experience:${e.id}`, e.component, this.components), pe(e, this.experiences);
665
680
  }
666
681
  getStateSnapshot() {
667
- return Ie(this);
682
+ return Pe(this);
668
683
  }
669
684
  async launchExperienceById(e) {
670
685
  const s = this.experiences.getById(e).getState();
@@ -737,16 +752,16 @@ class K {
737
752
  return this.plugins[e] ?? {};
738
753
  }
739
754
  }
740
- y(K, "logger", v);
755
+ h(K, "logger", v);
741
756
  function q(t) {
742
757
  var e;
743
758
  return ((e = t.options) == null ? void 0 : e.some((s) => "condition" in s)) ?? !1;
744
759
  }
745
- function qe(t) {
760
+ function Ze(t) {
746
761
  return t.some((e) => e.condition || q(e));
747
762
  }
748
- async function rt(t, e) {
749
- return e.length === 0 || !qe(e) ? e : (await Promise.all(
763
+ async function ut(t, e) {
764
+ return e.length === 0 || !Ze(e) ? e : (await Promise.all(
750
765
  e.map(async (o) => {
751
766
  if (!(o.condition ? await R(t, o.condition) : !0))
752
767
  return null;
@@ -759,28 +774,29 @@ async function rt(t, e) {
759
774
  })
760
775
  )).filter((o) => o !== null);
761
776
  }
762
- const st = (t) => {
777
+ const lt = (t) => {
763
778
  const e = new K(t);
764
- return oe(e), e;
779
+ return ae(e), e;
765
780
  };
766
781
  export {
767
782
  K as Picked,
768
- st as createClient,
769
- B as createStorageKey,
783
+ lt as createClient,
784
+ $ as createStorageKey,
770
785
  R as evaluateRuleLogic,
771
- rt as getStepFields,
772
- it as isPickedRoot,
773
- O as localStore,
774
- j as sessionStore,
775
- ct as subscribe,
776
- lt as supportsCookies,
777
- _ as supportsDocument,
778
- dt as supportsHistory,
779
- pt as supportsIntersectionObserver,
780
- gt as supportsLocalStorage,
781
- ft as supportsLocation,
782
- mt as supportsSessionStorage,
783
- yt as supportsShadowRoot,
784
- ht as supportsWebComponents,
786
+ ut as getStepFields,
787
+ gt as isPickedRoot,
788
+ D as localStore,
789
+ B as sessionStore,
790
+ mt as subscribe,
791
+ yt as supportsCookies,
792
+ ie as supportsCryptoRandomUUID,
793
+ z as supportsDocument,
794
+ St as supportsHistory,
795
+ wt as supportsIntersectionObserver,
796
+ oe as supportsLocalStorage,
797
+ vt as supportsLocation,
798
+ kt as supportsSessionStorage,
799
+ bt as supportsShadowRoot,
800
+ xt as supportsWebComponents,
785
801
  ne as supportsWindow
786
802
  };
@@ -1,35 +1,36 @@
1
- import { createEffect as n, sample as i } from "effector";
2
- import { c, l as x, s as S } from "../../../storage-D87xFySf.js";
1
+ import { createEffect as r, sample as i } from "effector";
2
+ import { c, l as g, s as S } from "../../../storage-BxBBl9Bw.js";
3
3
  import { l as f } from "../../../logger-C9a75KZn.js";
4
4
  const y = ({
5
5
  storage: a = "local"
6
6
  } = {}) => ({
7
7
  name: "experience-browser-storage-plugin",
8
- setup: (s) => {
9
- const r = a === "local" ? x : S, p = n(async (e) => {
8
+ setup: (n) => {
9
+ const o = a === "local" ? g : S, p = r(async (e) => {
10
10
  if (!e) {
11
11
  f("warn", "No experience instance provided to loadExperienceVisiblityFx.");
12
12
  return;
13
13
  }
14
- const t = c("open-close", "experience", e), o = r.get(t).boolean();
15
- e.setOpen(o ?? e.isOpenStore.getState());
14
+ const t = c("open-close", "experience", e), s = o.get(t).boolean();
15
+ e.setOpen(s ?? e.isOpenStore.getState());
16
16
  });
17
17
  i({
18
- source: s.eventBus,
19
- filter: (e) => e.type === "experience_initialized",
18
+ source: n.eventBus,
19
+ filter: (e) => e.type === "experience_initialized" && "experienceInstance" in e,
20
+ // @ts-ignore todo
20
21
  fn: (e) => e.experienceInstance,
21
22
  target: p
22
23
  });
23
- const l = n(async (e) => {
24
- const t = c("open-close", "experience", e), o = e.isOpenStore.getState();
25
- r.set(t, o);
26
- }), g = (e) => i({
24
+ const l = r(async (e) => {
25
+ const t = c("open-close", "experience", e), s = e.isOpenStore.getState();
26
+ o.set(t, s);
27
+ }), x = (e) => i({
27
28
  source: e.isOpenStore,
28
29
  fn: () => e,
29
30
  target: l
30
31
  });
31
- s.experienceInstances.listStore.watch((e) => {
32
- e.forEach((t) => g(t));
32
+ n.experienceInstances.listStore.watch((e) => {
33
+ e.forEach((t) => x(t));
33
34
  });
34
35
  }
35
36
  });
@@ -1,5 +1,5 @@
1
1
  import { createEffect as s, sample as r } from "effector";
2
- import { c as l, l as y, s as g } from "../../../storage-D87xFySf.js";
2
+ import { c as l, l as y, s as g } from "../../../storage-BxBBl9Bw.js";
3
3
  const a = l("history", "global"), f = ({
4
4
  storage: i = "local"
5
5
  } = {}) => ({
@@ -1,5 +1,5 @@
1
1
  import { createEffect as p, sample as i } from "effector";
2
- import { c as b, l as d, s as y } from "../../../storage-D87xFySf.js";
2
+ import { c as b, l as d, s as y } from "../../../storage-BxBBl9Bw.js";
3
3
  const a = b("responses", "global"), R = ({
4
4
  storage: g = "local"
5
5
  } = {}) => ({