@picked/client 0.0.1-dev.1774244905386 → 0.0.1-dev.1774912386475

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 (120) hide show
  1. package/dist/{api-dkMxUUe0.cjs → api-B-wGEgt8.cjs} +1 -1
  2. package/dist/{api-ENA5t36y.js → api-DwERBrAZ.js} +1 -1
  3. package/dist/cjs/form/index.js +1 -0
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/create-experience/index.js +1 -1
  6. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  7. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  9. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  10. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  11. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  12. package/dist/cjs/server/index.js +1 -1
  13. package/dist/esm/form/index.js +472 -0
  14. package/dist/esm/index.js +351 -369
  15. package/dist/esm/plugins/create-experience/index.js +218 -221
  16. package/dist/esm/plugins/dynamic-experiences/index.js +6 -7
  17. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  18. package/dist/esm/plugins/history-browser-storage/index.js +1 -1
  19. package/dist/esm/plugins/responses-browser-storage/index.js +48 -21
  20. package/dist/esm/plugins/responses-indexeddb/index.js +5 -9
  21. package/dist/esm/plugins/single-page-app/index.js +4 -4
  22. package/dist/esm/server/index.js +1 -1
  23. package/dist/experience-instance-CwwrKUI8.js +485 -0
  24. package/dist/experience-instance-DdFUcVRd.cjs +1 -0
  25. package/dist/{object-Clj5zVr1.js → object-C82v79xc.js} +2 -1
  26. package/dist/object-CUJOjanb.cjs +1 -0
  27. package/dist/rules-logic-BIkBWZmf.js +233 -0
  28. package/dist/rules-logic-DDxCiq4P.cjs +1 -0
  29. package/dist/{storage-DyxpJ0pg.js → storage-6Xk0uAxB.js} +3 -1
  30. package/dist/storage-B6lQtc4-.cjs +1 -0
  31. package/dist/types/entities/action/action.d.ts.map +1 -1
  32. package/dist/types/entities/experience/experience.d.ts +33 -5
  33. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  34. package/dist/types/entities/experience-instance/experience-instance.d.ts +19 -0
  35. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  36. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  37. package/dist/types/entities/field/field.d.ts +19 -13
  38. package/dist/types/entities/field/field.d.ts.map +1 -1
  39. package/dist/types/entities/history/history.d.ts.map +1 -1
  40. package/dist/types/entities/response/response-validation.d.ts +76 -0
  41. package/dist/types/entities/response/response-validation.d.ts.map +1 -0
  42. package/dist/types/entities/response/response.d.ts +17 -13
  43. package/dist/types/entities/response/response.d.ts.map +1 -1
  44. package/dist/types/entities/step/step.d.ts +1 -3
  45. package/dist/types/entities/step/step.d.ts.map +1 -1
  46. package/dist/types/form/build-responses.d.ts +17 -0
  47. package/dist/types/form/build-responses.d.ts.map +1 -0
  48. package/dist/types/form/create-field-evaluator.d.ts +27 -0
  49. package/dist/types/form/create-field-evaluator.d.ts.map +1 -0
  50. package/dist/types/form/create-field-validation.d.ts +59 -0
  51. package/dist/types/form/create-field-validation.d.ts.map +1 -0
  52. package/dist/types/form/create-form.d.ts +97 -0
  53. package/dist/types/form/create-form.d.ts.map +1 -0
  54. package/dist/types/form/create-submit-pipeline.d.ts +70 -0
  55. package/dist/types/form/create-submit-pipeline.d.ts.map +1 -0
  56. package/dist/types/form/get-step-fields.d.ts +18 -0
  57. package/dist/types/form/get-step-fields.d.ts.map +1 -0
  58. package/dist/types/form/index.d.ts +10 -0
  59. package/dist/types/form/index.d.ts.map +1 -0
  60. package/dist/types/index.d.ts +1 -1
  61. package/dist/types/index.d.ts.map +1 -1
  62. package/dist/types/logic-engine.d.ts +12 -10
  63. package/dist/types/logic-engine.d.ts.map +1 -1
  64. package/dist/types/picked.d.ts +38 -11
  65. package/dist/types/picked.d.ts.map +1 -1
  66. package/dist/types/plugins/create-experience/create-experience.d.ts +22 -32
  67. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  68. package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
  69. package/dist/types/plugins/create-experience/serialization.d.ts +7 -0
  70. package/dist/types/plugins/create-experience/serialization.d.ts.map +1 -0
  71. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  72. package/dist/types/plugins/dynamic-experiences/types.d.ts +11 -17
  73. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  74. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
  75. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  76. package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -0
  77. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  78. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
  79. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  80. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
  81. package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
  82. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  83. package/dist/types/utils/dom.d.ts +0 -3
  84. package/dist/types/utils/dom.d.ts.map +1 -1
  85. package/dist/types/utils/events.d.ts +1 -1
  86. package/dist/types/utils/events.d.ts.map +1 -1
  87. package/dist/types/utils/global-obj.d.ts +0 -1
  88. package/dist/types/utils/global-obj.d.ts.map +1 -1
  89. package/dist/types/utils/indexed-db.d.ts +2 -1
  90. package/dist/types/utils/indexed-db.d.ts.map +1 -1
  91. package/dist/types/utils/logger.d.ts.map +1 -1
  92. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +3 -0
  93. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -0
  94. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  95. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  96. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +8 -4
  97. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  98. package/dist/types/utils/nodes.d.ts +58 -9
  99. package/dist/types/utils/nodes.d.ts.map +1 -1
  100. package/dist/types/utils/object.d.ts +0 -8
  101. package/dist/types/utils/object.d.ts.map +1 -1
  102. package/dist/types/utils/picked-config.d.ts +1 -1
  103. package/dist/types/utils/picked-config.d.ts.map +1 -1
  104. package/dist/types/utils/rules-logic.d.ts +31 -0
  105. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  106. package/dist/types/utils/search-params.d.ts.map +1 -1
  107. package/dist/types/utils/storage.d.ts.map +1 -1
  108. package/package.json +42 -6
  109. package/dist/experience-instance-BODAwa-_.js +0 -713
  110. package/dist/experience-instance-DImQh64e.cjs +0 -1
  111. package/dist/object-BReQiaSS.cjs +0 -1
  112. package/dist/storage-BFjb8azI.cjs +0 -1
  113. package/dist/types/entities/project/project.d.ts +0 -9
  114. package/dist/types/entities/project/project.d.ts.map +0 -1
  115. package/dist/types/utils/key.d.ts +0 -12
  116. package/dist/types/utils/key.d.ts.map +0 -1
  117. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +0 -3
  118. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +0 -1
  119. /package/dist/{id-CIbS4P60.cjs → id-Bv44ilEo.cjs} +0 -0
  120. /package/dist/{id-BniPxOdF.js → id-CRqy981z.js} +0 -0
package/dist/esm/index.js CHANGED
@@ -1,150 +1,137 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, p as c, r as l, s as u, u as d } from "../experience-instance-BODAwa-_.js";
2
- import { t as f } from "../object-Clj5zVr1.js";
3
- import { t as p } from "../logger-6z_gb4rA.js";
4
- import { a as m, c as h, d as g, i as ee, l as te, n as _, o as v, p as ne, r as y, s as re, t as ie, u as b } from "../supports-0XIfd4-R.js";
5
- import { i as x, n as S, r as C, t as w } from "../storage-DyxpJ0pg.js";
6
- import { n as ae, r as oe } from "../api-ENA5t36y.js";
7
- import { t as se } from "../id-BniPxOdF.js";
8
- import { attach as T, combine as E, createApi as D, createDomain as O, createEffect as k, createEvent as A, createStore as j, sample as M } from "effector";
9
- import { createFactory as N, invoke as P } from "@withease/factories";
1
+ import { n as e, t } from "../rules-logic-BIkBWZmf.js";
2
+ import { t as n } from "../object-C82v79xc.js";
3
+ import { t as r } from "../logger-6z_gb4rA.js";
4
+ import { a as i, c as a, d as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "../supports-0XIfd4-R.js";
5
+ import { a as g, c as _, i as v, l as ee, n as te, o as ne, r as re, s as ie, u as ae } from "../experience-instance-CwwrKUI8.js";
6
+ import { i as y, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
7
+ import { n as oe, r as se } from "../api-DwERBrAZ.js";
8
+ import { t as ce } from "../id-CRqy981z.js";
9
+ import { attach as C, combine as w, createApi as T, createDomain as E, createEffect as D, createEvent as O, createStore as k, sample as A } from "effector";
10
+ import { createFactory as j, invoke as M } from "@withease/factories";
10
11
  //#region src/entities/experience/experience.ts
11
- var F = O("experience"), ce = N(({ client: t, experience: n }) => {
12
- let r = F.store(n), a = D(r, { merge(e, t) {
12
+ var N = E("experience"), le = j(({ client: e, experience: t }) => {
13
+ let n = N.store(t), r = T(n, { merge(e, t) {
13
14
  return {
14
15
  ...e,
15
16
  ...t.experience
16
17
  };
17
- } }), o = r.map((e) => ({
18
+ } }), i = n.map((e) => ({
18
19
  name: e.name,
19
20
  decisionLogic: e.condition,
20
21
  targetSelectors: e.targets,
21
- initializeOpenLogic: n.initializeOpen
22
- })), c = n.component ? {
23
- name: `experience:${n.id}`,
24
- component: n.component,
25
- frameworkStore: t.frameworks.getByName(n.component.frameworkName)
26
- } : void 0, u = t.components.listStore.map((e) => c || (n.componentName ? e.find((e) => e.name === n.componentName) : void 0) || e.find((e) => e.name === `experience:${n.id}`) || e.find((e) => e.name === "experience"), { skipVoid: !1 }), d = E(r, t.steps.listStore, t.conditions.listStore, (t, n, r) => {
27
- let a = t.nodes.filter(i).map((e) => {
28
- let t = s(e);
29
- return n.find((e) => e.id === t || e.key === t);
30
- }).filter((e) => e !== void 0), o = t.nodes.filter(l).map((t) => r.find((n) => n.id === e(t))).filter((e) => e !== void 0);
22
+ initializeOpenLogic: e.initializeOpen
23
+ })), a = w(n, e.components.listStore, (e, t) => (e.componentName ? t.find((t) => t.name === e.componentName) : void 0) || t.find((t) => t.name === `experience:${e.id}`) || t.find((e) => e.name === "experience"), { skipVoid: !1 }), o = w(n, e.steps.listStore, e.conditions.listStore, (e, t, n) => {
24
+ let r = e.nodes.filter(v).map((e) => {
25
+ let n = e.stepId;
26
+ return t.find((e) => e.id === n || e.key === n);
27
+ }).filter((e) => e !== void 0), i = e.nodes.filter(re).map((e) => n.find((t) => t.id === g(e))).filter((e) => e !== void 0);
31
28
  return {
32
- steps: a,
33
- nodes: t.nodes,
34
- edges: t.edges,
35
- conditions: o
29
+ steps: r,
30
+ nodes: e.nodes,
31
+ edges: e.edges,
32
+ conditions: i
36
33
  };
37
- }), f = n.actions ?? [];
34
+ }), s = t.actions ?? [];
38
35
  return {
39
- id: n.id,
40
- key: n.key,
41
- name: n.name,
42
- configStore: o,
43
- treeStore: d,
44
- componentStore: u,
45
- actions: f,
46
- merge: a.merge
36
+ id: t.id,
37
+ key: t.key,
38
+ name: t.name,
39
+ configStore: i,
40
+ treeStore: o,
41
+ componentStore: a,
42
+ actions: s,
43
+ merge: r.merge
47
44
  };
48
45
  });
49
- function le(e) {
50
- return P(ce, e);
46
+ function ue(e) {
47
+ return M(le, e);
51
48
  }
52
- var ue = N(({ client: e }) => {
53
- let t = F.store({}), n = F.store({}), r = D(t, { register(e, t) {
49
+ var de = j(({ client: e }) => {
50
+ let t = N.store({}), n = T(t, { register(e, t) {
54
51
  return {
55
52
  ...e,
56
53
  [t.id]: t
57
54
  };
58
- } }), i = D(n, { register(e, { key: t, id: n }) {
59
- return {
60
- ...e,
61
- [t]: n
62
- };
63
- } });
64
- function a(n) {
65
- let a = t.getState()[n.id];
66
- if (a) {
67
- a.merge({
68
- experience: n,
55
+ } }), r = t.map((e) => Object.fromEntries(Object.values(e).map((e) => [e.key, e.id])));
56
+ function i(r) {
57
+ let i = t.getState()[r.id];
58
+ if (i) {
59
+ i.merge({
60
+ experience: r,
69
61
  strategy: "override"
70
- }), i.register({
71
- key: n.key,
72
- id: n.id
73
62
  });
74
63
  return;
75
64
  }
76
- let o = le({
65
+ let a = ue({
77
66
  client: e,
78
- experience: n
79
- });
80
- r.register(o), i.register({
81
- key: n.key,
82
- id: n.id
67
+ experience: r
83
68
  });
69
+ n.register(a);
84
70
  }
85
- let o = t.map((e) => Object.values(e));
86
- function s(e) {
87
- return E(t, n, (t, n) => t[n[e] ?? ""] ?? t[e], { skipVoid: !1 });
71
+ let a = t.map((e) => Object.values(e));
72
+ function o(e) {
73
+ return w(t, r, (t, n) => t[n[e] ?? ""] ?? t[e], { skipVoid: !1 });
88
74
  }
89
- let c = T({
75
+ let s = C({
90
76
  source: {
91
77
  experiences: t,
92
- keys: n
78
+ keys: r
93
79
  },
94
- effect: async ({ experiences: t, keys: n }, { key: r, options: i }) => {
95
- let a = t[n[r] ?? ""] ?? t[r];
96
- if (!a) {
97
- `${r}`;
80
+ effect: async ({ experiences: t, keys: n }, { key: r, id: i, options: a }) => {
81
+ let o = r ?? i ?? "", s = t[n[o] ?? ""] ?? t[o];
82
+ if (!s) {
83
+ `${o}`;
98
84
  return;
99
85
  }
100
- if (i?.bypassCondition) {
101
- I(e, a, i);
86
+ if (a?.bypassCondition) {
87
+ P(e, s, a);
102
88
  return;
103
89
  }
104
- await R(e, a) && I(e, a, i);
90
+ await I(e, s) && P(e, s, a);
105
91
  }
106
92
  });
107
93
  return {
108
- register: a,
109
- get: s,
110
- launch: c,
111
- open: T({
94
+ register: i,
95
+ get: o,
96
+ getById: o,
97
+ launch: s,
98
+ open: C({
112
99
  source: {
113
100
  instances: e.experienceInstances.listStore,
114
- keys: n
101
+ keys: r
115
102
  },
116
- effect: ({ instances: e, keys: t }, { key: n, options: r }) => {
117
- let i = t[n] ?? n, a = e.filter((e) => e.experienceId === i);
118
- if (a.length > 0) for (let e of a) e.open();
119
- else c({
120
- key: i,
103
+ effect: ({ instances: e, keys: t }, { key: n, id: r, options: i }) => {
104
+ let a = n ?? r ?? "", o = t[a] ?? a, c = e.filter((e) => e.experienceId === o);
105
+ if (c.length > 0) for (let e of c) e.open();
106
+ else s({
107
+ key: o,
121
108
  options: {
122
- ...r,
109
+ ...i,
123
110
  initialiseOpen: !0
124
111
  }
125
112
  });
126
113
  }
127
114
  }),
128
- listStore: o
115
+ listStore: a
129
116
  };
130
117
  });
131
- function de(e) {
132
- return P(ue, e);
118
+ function fe(e) {
119
+ return M(de, e);
133
120
  }
134
- var I = (e, t, r) => {
135
- let { targetSelectors: i } = t.configStore.getState(), o = a(i, t.id);
136
- o.forEach(({ elements: e }) => e.forEach((e) => n(e, t.id))), u(o, t.id).forEach((n) => {
137
- r ? e.experienceInstances.spawn(t, n, r) : e.experienceInstances.spawn(t, n);
121
+ var P = (e, t, n) => {
122
+ let { targetSelectors: r } = t.configStore.getState(), i = _(r, t.id);
123
+ i.forEach(({ elements: e }) => e.forEach((e) => ae(e, t.id))), ne(i, t.id).forEach((r) => {
124
+ n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
138
125
  });
139
- }, L = async (e) => {
126
+ }, F = async (e) => {
140
127
  await Promise.all(e.experiences.listStore.getState().map(async (t) => {
141
- await R(e, t) && I(e, t);
128
+ await I(e, t) && P(e, t);
142
129
  }));
143
- }, R = async (e, t) => {
144
- if (!e.preconditionPassed || !e.session?.isUser) return !1;
145
- let { decisionLogic: n, targetSelectors: i } = t.configStore.getState();
146
- return a(i, t.id).length < 1 || i.length === 0 ? !1 : n === void 0 ? !0 : c(n) ? await r(e, n) === !0 : !0;
147
- }, z = (e, t, n) => {
130
+ }, I = async (n, r) => {
131
+ if (!n.preconditionPassed || !n.session?.isUser) return !1;
132
+ let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
133
+ return _(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
134
+ }, L = (e, t, n) => {
148
135
  let r = t.name, i = t.setup(e);
149
136
  if (i) {
150
137
  let e = n[r] ?? {};
@@ -153,16 +140,16 @@ var I = (e, t, r) => {
153
140
  ...i
154
141
  });
155
142
  }
156
- }, B = O("component"), V = N(({ client: e, component: t, name: n }) => ({
143
+ }, R = E("component"), z = j(({ client: e, component: t, name: n }) => ({
157
144
  name: n,
158
145
  component: t,
159
146
  frameworkStore: e.frameworks.getByName(t.frameworkName)
160
147
  }));
161
- function H(e) {
162
- return P(V, e);
148
+ function B(e) {
149
+ return M(z, e);
163
150
  }
164
- var fe = N(({ client: e }) => {
165
- let t = B.store({}), n = D(t, { register(e, t) {
151
+ var V = j(({ client: e }) => {
152
+ let t = R.store({}), n = T(t, { register(e, t) {
166
153
  return {
167
154
  ...e,
168
155
  [t.name]: t
@@ -170,7 +157,7 @@ var fe = N(({ client: e }) => {
170
157
  } });
171
158
  function r(r, i) {
172
159
  t.getState()[r] && `${r}`;
173
- let a = H({
160
+ let a = B({
174
161
  client: e,
175
162
  name: r,
176
163
  component: i
@@ -188,12 +175,12 @@ var fe = N(({ client: e }) => {
188
175
  };
189
176
  });
190
177
  function pe(e) {
191
- return P(fe, e);
178
+ return M(V, e);
192
179
  }
193
- var U = (e, t, n) => {
180
+ var H = (e, t, n) => {
194
181
  n.register(e, t);
195
- }, me = O("framework"), he = N(({ client: e }) => {
196
- let t = me.store({}), n = D(t, { register(e, t) {
182
+ }, me = E("framework"), he = j(({ client: e }) => {
183
+ let t = me.store({}), n = T(t, { register(e, t) {
197
184
  return {
198
185
  ...e,
199
186
  [t.name]: t.framework
@@ -216,20 +203,20 @@ var U = (e, t, n) => {
216
203
  };
217
204
  });
218
205
  function ge(e) {
219
- return P(he, e);
206
+ return M(he, e);
220
207
  }
221
208
  var _e = (e, t) => {
222
209
  t.register(e.name, e);
223
- }, ve = 6e3, ye = w("last_ping", "global"), be = async (e) => {
210
+ }, ve = 6e3, ye = S("last_ping", "global"), be = async (e) => {
224
211
  try {
225
- let t = Date.now(), n = S.get(ye), r = 0;
212
+ let t = Date.now(), n = b.get(ye), r = 0;
226
213
  if (n.isSet() && (r = n.json() ?? 0), r && t - r < ve) return !0;
227
214
  let i = {
228
215
  projectId: e.projectId,
229
216
  path: window.location.pathname
230
217
  }, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
231
218
  o && (a["x-vercel-protection-bypass"] = o);
232
- let s = (await ae(e.apiUrl, "ping", i, a)).ok;
219
+ let s = (await oe(e.apiUrl, "ping", i, a)).ok;
233
220
  return s && n.set(t), s;
234
221
  } catch {
235
222
  return !1;
@@ -237,7 +224,7 @@ var _e = (e, t) => {
237
224
  };
238
225
  //#endregion
239
226
  //#region src/utils/state-snaphot.ts
240
- function W(e) {
227
+ function U(e) {
241
228
  let t = typeof window < "u", n = {
242
229
  client: e,
243
230
  responses: e.responses.listStore.getState(),
@@ -251,8 +238,8 @@ function W(e) {
251
238
  }
252
239
  //#endregion
253
240
  //#region src/entities/predicate/predicate.ts
254
- var xe = O("predicate"), Se = N(({ client: e }) => {
255
- let t = xe.store({}), n = D(t, { register(e, t) {
241
+ var xe = E("predicate"), Se = j(({ client: e }) => {
242
+ let t = xe.store({}), n = T(t, { register(e, t) {
256
243
  return {
257
244
  ...e,
258
245
  [t.name]: {
@@ -272,22 +259,22 @@ var xe = O("predicate"), Se = N(({ client: e }) => {
272
259
  return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
273
260
  }
274
261
  function o(t) {
275
- let n = j(() => void 0, { skipVoid: !1 }), r = k(async () => {
262
+ let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
276
263
  let n = a(t).getState();
277
264
  if (!n) return;
278
- let r = W(e);
265
+ let r = U(e);
279
266
  return (...e) => n({
280
267
  ...r,
281
268
  args: e
282
269
  });
283
270
  });
284
- return M({
271
+ return A({
285
272
  source: {
286
273
  responses: e.responses.listStore,
287
274
  fields: e.fields.listStore
288
275
  },
289
276
  target: r
290
- }), M({
277
+ }), A({
291
278
  clock: r.doneData,
292
279
  filter: (e) => e !== void 0,
293
280
  target: n
@@ -301,12 +288,12 @@ var xe = O("predicate"), Se = N(({ client: e }) => {
301
288
  };
302
289
  });
303
290
  function Ce(e) {
304
- return P(Se, e);
291
+ return M(Se, e);
305
292
  }
306
293
  var we = (e, t, n) => {
307
294
  n.register(e, t);
308
- }, G = O("feature"), Te = N(({ client: e }) => {
309
- let t = G.store({}), n = G.store([]), r = D(t, { register(e, t) {
295
+ }, W = E("feature"), Te = j(({ client: e }) => {
296
+ let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
310
297
  return {
311
298
  ...e,
312
299
  [t.id]: t.feature
@@ -326,19 +313,19 @@ var we = (e, t, n) => {
326
313
  feature: i
327
314
  }));
328
315
  }
329
- let a = k(async ({ id: e, key: t, storage: n = "local" }) => {
330
- let r = w(`feature:${e}:${t}`, "global"), i = (n === "session" ? C : S).get(r).boolean();
316
+ let a = D(async ({ id: e, key: t, storage: n = "local" }) => {
317
+ let r = S(`feature:${e}:${t}`, "global"), i = (n === "session" ? x : b).get(r).boolean();
331
318
  return i === null ? null : {
332
319
  id: e,
333
320
  key: t,
334
321
  bucket: i,
335
322
  storage: n
336
323
  };
337
- }), o = k((e) => {
324
+ }), o = D((e) => {
338
325
  if (!e) return null;
339
- let t = w(`feature:${e.id}:${e.key}`, "global");
340
- (e.storage === "session" ? C : S).set(t, e.bucket);
341
- }), s = /* @__PURE__ */ new Map(), c = T({
326
+ let t = S(`feature:${e.id}:${e.key}`, "global");
327
+ (e.storage === "session" ? x : b).set(t, e.bucket);
328
+ }), s = /* @__PURE__ */ new Map(), c = C({
342
329
  source: {
343
330
  allFeaturesStore: t,
344
331
  resolvedFeaturesStore: n
@@ -369,7 +356,7 @@ var we = (e, t, n) => {
369
356
  };
370
357
  }
371
358
  });
372
- M({
359
+ A({
373
360
  clock: r.register,
374
361
  fn: (e) => {
375
362
  let { id: t, feature: n } = e;
@@ -380,7 +367,7 @@ var we = (e, t, n) => {
380
367
  };
381
368
  },
382
369
  target: a
383
- }), M({
370
+ }), A({
384
371
  source: t,
385
372
  clock: c.doneData,
386
373
  fn: (e, t) => {
@@ -394,7 +381,7 @@ var we = (e, t, n) => {
394
381
  },
395
382
  target: o
396
383
  });
397
- let l = E({
384
+ let l = w({
398
385
  allFeaturesStore: t,
399
386
  resolvedFeaturesStore: n
400
387
  }).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
@@ -416,7 +403,7 @@ var we = (e, t, n) => {
416
403
  isResolved: !1
417
404
  };
418
405
  }));
419
- M({
406
+ A({
420
407
  clock: c.doneData,
421
408
  source: { resolvedFeatures: n },
422
409
  filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
@@ -425,7 +412,7 @@ var we = (e, t, n) => {
425
412
  type: "feature_decide",
426
413
  feature: e
427
414
  }))
428
- }), M({
415
+ }), A({
429
416
  clock: [a.doneData, c.doneData],
430
417
  source: n,
431
418
  fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
@@ -438,15 +425,15 @@ var we = (e, t, n) => {
438
425
  return t.map((t) => t[e], { skipVoid: !1 });
439
426
  }
440
427
  function f(e) {
441
- let t = j(async () => void 0, { skipVoid: !1 }), r = k(async () => {
428
+ let t = k(async () => void 0, { skipVoid: !1 }), r = D(async () => {
442
429
  let t = u(e).getState();
443
430
  if (t) return async () => (await t.getBucket()).bucket;
444
431
  });
445
- return M({
432
+ return A({
446
433
  source: n,
447
434
  filter: (t) => t.some((t) => t.id === e),
448
435
  target: r
449
- }), M({
436
+ }), A({
450
437
  clock: r.doneData,
451
438
  filter: (e) => e !== void 0,
452
439
  target: t
@@ -461,30 +448,30 @@ var we = (e, t, n) => {
461
448
  };
462
449
  });
463
450
  function Ee(e) {
464
- return P(Te, e);
451
+ return M(Te, e);
465
452
  }
466
453
  var De = (e, t, n) => {
467
454
  n.register(e, t);
468
- }, K = O("history");
469
- function q(e, t) {
455
+ }, G = E("history");
456
+ function K(e, t) {
470
457
  return {
471
- id: se(`history-entry-${Date.now()}-${Math.random()}}`),
458
+ id: ce(`history-entry-${Date.now()}-${Math.random()}}`),
472
459
  node: t,
473
460
  at: Date.now(),
474
461
  experienceId: e
475
462
  };
476
463
  }
477
- var Oe = N(() => {
478
- let e = K.store({ entries: [] }), t = K.event(), n = K.event(), r = K.event(), a = K.event();
479
- e.on(t, (e, t) => ({ entries: [...e.entries, q(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), q(t.experienceId, t.node)] })), e.on(a, (e, t) => t);
480
- function o(e, t) {
464
+ var Oe = j(() => {
465
+ let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
466
+ e.on(t, (e, t) => ({ entries: [...e.entries, K(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), K(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
467
+ function a(e, t) {
481
468
  let n = {
482
469
  lastStepIndex: -1,
483
470
  secondLastStepIndex: -1
484
471
  };
485
472
  for (let r = e.length - 1; r >= 0; r--) {
486
- let a = e[r], o = a?.node;
487
- if (!(!o || !i(o)) && !(t && a?.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
473
+ let i = e[r], a = i?.node;
474
+ if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
488
475
  else {
489
476
  n.secondLastStepIndex = r;
490
477
  break;
@@ -493,7 +480,7 @@ var Oe = N(() => {
493
480
  return n;
494
481
  }
495
482
  return e.on(r, (e, t) => {
496
- let { secondLastStepIndex: n } = o(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
483
+ let { secondLastStepIndex: n } = a(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
497
484
  return {
498
485
  ...e,
499
486
  entries: r
@@ -502,18 +489,18 @@ var Oe = N(() => {
502
489
  push: t,
503
490
  replace: n,
504
491
  back: r,
505
- restore: a,
492
+ restore: i,
506
493
  entriesStore: e.map((e) => e.entries)
507
494
  };
508
495
  });
509
496
  function ke() {
510
- return P(Oe);
497
+ return M(Oe);
511
498
  }
512
499
  //#endregion
513
500
  //#region src/utils/events.ts
514
501
  var Ae = 0, je = (e) => {
515
- let t = j([]);
516
- return M({
502
+ let t = k([]);
503
+ return A({
517
504
  clock: e,
518
505
  source: t,
519
506
  fn: (e, t) => [...e, {
@@ -523,21 +510,31 @@ var Ae = 0, je = (e) => {
523
510
  }],
524
511
  target: t
525
512
  }), t;
526
- }, Me = O("field"), Ne = N(() => {
527
- let e = Me.store({}), t = D(e, { register(e, t) {
528
- return {
529
- ...e,
530
- [t.field.id]: t.field
531
- };
532
- } });
513
+ }, Me = E("field"), Ne = j(() => {
514
+ let e = Me.store({}), t = T(e, {
515
+ register(e, t) {
516
+ return {
517
+ ...e,
518
+ [t.field.id]: t.field
519
+ };
520
+ },
521
+ updateById(e, t) {
522
+ let n = e[t.fieldId];
523
+ return n ? {
524
+ ...e,
525
+ [t.fieldId]: Object.assign({}, n, t.updates)
526
+ } : e;
527
+ }
528
+ });
533
529
  function n(e) {
534
530
  t.register({ field: e });
535
531
  }
536
532
  function r(n, r) {
537
- let i = e.getState()[n] ?? null;
538
- if (!i) return;
539
- let a = Object.assign({}, i, { ...r });
540
- t.register({ field: { ...a } });
533
+ let i = e.getState(), a = Object.values(i).find((e) => e.key === n)?.id ?? n;
534
+ t.updateById({
535
+ fieldId: a,
536
+ updates: r
537
+ });
541
538
  }
542
539
  let i = e.map((e) => Object.values(e));
543
540
  function a(t) {
@@ -559,12 +556,12 @@ var Ae = 0, je = (e) => {
559
556
  };
560
557
  });
561
558
  function Pe() {
562
- return P(Ne);
559
+ return M(Ne);
563
560
  }
564
- var Fe = (e, t) => {
565
- t.register(e);
566
- }, Ie = O("step"), Le = N(() => {
567
- let e = Ie.store({}), t = D(e, { register(e, t) {
561
+ //#endregion
562
+ //#region src/entities/step/step.ts
563
+ var Fe = E("step"), Ie = j(() => {
564
+ let e = Fe.store({}), t = T(e, { register(e, t) {
568
565
  return {
569
566
  ...e,
570
567
  [t.step.id]: t.step
@@ -583,16 +580,16 @@ var Fe = (e, t) => {
583
580
  listStore: r
584
581
  };
585
582
  });
586
- function Re() {
587
- return P(Le);
583
+ function Le() {
584
+ return M(Ie);
588
585
  }
589
- function ze(e, t) {
586
+ function Re(e, t) {
590
587
  t.register(e);
591
588
  }
592
589
  //#endregion
593
590
  //#region src/entities/action/action.ts
594
- var Be = O("action"), Ve = N(() => {
595
- let e = Be.store({}), t = D(e, { register(e, t) {
591
+ var ze = E("action"), Be = j(() => {
592
+ let e = ze.store({}), t = T(e, { register(e, t) {
596
593
  return {
597
594
  ...e,
598
595
  [t.name]: {
@@ -624,18 +621,27 @@ var Be = O("action"), Ve = N(() => {
624
621
  getEvokableAction: a
625
622
  };
626
623
  });
627
- function He() {
628
- return P(Ve);
624
+ function Ve() {
625
+ return M(Be);
629
626
  }
630
- var Ue = (e, t, n) => {
627
+ var He = (e, t, n) => {
631
628
  n.register(e, t);
632
629
  };
633
630
  //#endregion
634
- //#region src/entities/response/response.ts
631
+ //#region src/entities/response/response-validation.ts
632
+ function q(e, t, n, r) {
633
+ return {
634
+ fieldKey: e.key,
635
+ fieldId: e.id,
636
+ userMessage: n,
637
+ systemMessage: r,
638
+ value: t
639
+ };
640
+ }
635
641
  function J(e) {
636
642
  return e == null || e === "" || Array.isArray(e) && !e.length;
637
643
  }
638
- function We(e) {
644
+ function Ue(e) {
639
645
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
640
646
  }
641
647
  function Y(e) {
@@ -645,80 +651,53 @@ function Y(e) {
645
651
  return !1;
646
652
  }
647
653
  }
648
- function Ge(e, t) {
654
+ function We(e, t) {
649
655
  return t.find((t) => t.id === e) ?? t.find((t) => t.key === e) ?? null;
650
656
  }
651
- function Ke(e, t) {
657
+ function Ge(e, t) {
652
658
  return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
653
659
  }
654
- function qe(e, t, n) {
655
- if (e.type !== "object" || J(n)) return null;
660
+ function Ke(e, t) {
661
+ if (e.type !== "object" || J(t)) return null;
656
662
  if (e.multiple) {
657
- if (!Array.isArray(n)) return {
658
- fieldId: t,
659
- userMessage: "This field expects multiple values",
660
- systemMessage: "Field expects an array of objects.",
661
- value: n
662
- };
663
- for (let e of n) {
664
- if (typeof e != "object" || !e) return {
665
- fieldId: t,
666
- userMessage: "This field expects object values",
667
- systemMessage: "Field expects an array of objects, but received non-object value.",
668
- value: n
669
- };
670
- if (!Y(e)) return {
671
- fieldId: t,
672
- userMessage: "This field contains non-serializable data",
673
- systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
674
- value: n
675
- };
663
+ if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
664
+ for (let n of t) {
665
+ if (typeof n != "object" || !n) return q(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
666
+ if (!Y(n)) return q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
676
667
  }
677
668
  return null;
678
669
  }
679
- return Array.isArray(n) ? {
680
- fieldId: t,
681
- userMessage: "This field expects a single value",
682
- systemMessage: "Field expects a single object, not an array.",
683
- value: n
684
- } : typeof n != "object" || !n ? {
685
- fieldId: t,
686
- userMessage: "This field expects an object value",
687
- systemMessage: "Field expects an object value.",
688
- value: n
689
- } : Y(n) ? null : {
690
- fieldId: t,
691
- userMessage: "This field contains non-serializable data",
692
- systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
693
- value: n
694
- };
670
+ return Array.isArray(t) ? q(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? q(e, t, "This field expects an object value", "Field expects an object value.") : Y(t) ? null : q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
695
671
  }
696
- function Je(e, t, n) {
672
+ function qe(e, t) {
697
673
  if (!Array.isArray(e.options) || e.options.length === 0) return null;
698
- let r = Array.isArray(n) ? n : [n];
674
+ let n = Array.isArray(t) ? t : [t];
699
675
  if (e.type === "object") {
700
- let i = e.options.map((e) => JSON.stringify(e.value));
701
- return r.every((e) => i.includes(JSON.stringify(e))) ? null : {
702
- fieldId: t,
703
- userMessage: "This field expects a valid option",
704
- systemMessage: "Field expects a valid option from the defined choices.",
705
- value: n
706
- };
676
+ let r = e.options.map((e) => JSON.stringify(e.value));
677
+ return n.every((e) => r.includes(JSON.stringify(e))) ? null : q(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
707
678
  }
708
- let i = e.options.map((e) => e.value);
709
- return r.every((e) => !We(e) || e === null ? !1 : i.includes(e)) ? null : {
710
- fieldId: t,
711
- userMessage: "This field expects a valid option",
712
- systemMessage: `Field expects a valid option. Valid options are: ${i.join(", ")}`,
713
- value: n
714
- };
679
+ let r = e.options.map((e) => e.value);
680
+ return n.every((e) => !Ue(e) || e === null ? !1 : r.includes(e)) ? null : q(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
681
+ }
682
+ async function Je(e, t, r, i) {
683
+ if (t.validation && !n(t.validation) && !J(r)) {
684
+ let n = i ? {
685
+ $input: r,
686
+ responses: i
687
+ } : { $input: r }, a = await e(t.validation, n);
688
+ if (typeof a == "string") return q(t, r, a, `Field validation resulted in an error: ${a}.`);
689
+ if (a === !1) return q(t, r, "This field is invalid", "Field validation resulted in an unspecified error.");
690
+ }
691
+ return t.required && J(r) ? q(t, r, "This field is required", "Field is required.") : !t.multiple && Array.isArray(r) && r.length > 1 ? q(t, r, "This field expects a single response", "Field expects a single response.") : null;
715
692
  }
716
- var Ye = O("response"), Xe = N(({ client: e }) => {
717
- let t = Ye.store({}), n = A(), i = A(), a = D(t, {
693
+ //#endregion
694
+ //#region src/entities/response/response.ts
695
+ var Ye = E("response"), Xe = j(({ client: e }) => {
696
+ let n = Ye.store({}), r = O(), i = O(), a = T(n, {
718
697
  register(e, t) {
719
698
  return {
720
699
  ...e,
721
- [t.fieldId]: t.response
700
+ [t.fieldKey]: t.response
722
701
  };
723
702
  },
724
703
  registerBatch(e, t) {
@@ -738,136 +717,140 @@ var Ye = O("response"), Xe = N(({ client: e }) => {
738
717
  if (typeof e == "string") {
739
718
  if (t === void 0) throw Error("Response is required when registering a single field");
740
719
  a.register({
741
- fieldId: e,
720
+ fieldKey: e,
742
721
  response: t
743
722
  });
744
723
  } else a.registerBatch(e);
745
724
  }
746
- async function s(t, n, i) {
747
- if (t.validation && !f(t.validation) && !J(i)) {
748
- let a = await r(e, t.validation, { $input: i });
749
- if (typeof a == "string") return {
750
- fieldId: n,
751
- userMessage: a,
752
- systemMessage: `Field validation resulted in an error: ${a}.`,
753
- value: i
754
- };
755
- if (a === !1) return {
756
- fieldId: n,
757
- userMessage: "This field is invalid",
758
- systemMessage: "Field validation resulted in an unspecified error.",
759
- value: i
760
- };
761
- }
762
- return t.required && J(i) ? {
763
- fieldId: n,
764
- userMessage: "This field is required",
765
- systemMessage: "Field is required.",
766
- value: i
767
- } : !t.multiple && Array.isArray(i) && i.length > 1 ? {
768
- fieldId: n,
769
- userMessage: "This field expects a single response",
770
- systemMessage: "Field expects a single response.",
771
- value: i
772
- } : null;
773
- }
774
- async function c(t) {
775
- let n = [], r = {}, i = e.fields.listStore.getState();
776
- return await Promise.allSettled(Object.entries(t).map(async ([e, t]) => {
777
- let a = Ge(e, i);
778
- if (!a) {
779
- n.push({
780
- fieldId: e,
781
- userMessage: `Field '${e}' not found`,
782
- systemMessage: `No field with ID or key '${e}' exists. Available field IDs are: ${i.map((e) => e.id).join(",")}.`,
783
- value: t
725
+ let s = (n, r) => t(e, n, r), c = C({
726
+ source: {
727
+ allFields: e.fields.listStore,
728
+ existingResponses: n
729
+ },
730
+ effect: async ({ allFields: e, existingResponses: t }, n) => {
731
+ let r = [], i = {}, a = {
732
+ ...t,
733
+ ...n
734
+ }, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
735
+ let o = We(t, e);
736
+ if (!o) {
737
+ r.push({
738
+ fieldKey: t,
739
+ userMessage: `Field '${t}' not found`,
740
+ systemMessage: `No field with key '${t}' exists. Available field keys are: ${e.map((e) => e.key).join(",")}.`,
741
+ value: n
742
+ });
743
+ return;
744
+ }
745
+ let c = Ge(o, n), l = await Je(s, o, c, a);
746
+ if (l) {
747
+ r.push(l);
748
+ return;
749
+ }
750
+ let u = Ke(o, c);
751
+ if (u) {
752
+ r.push(u);
753
+ return;
754
+ }
755
+ let d = qe(o, c);
756
+ if (d) {
757
+ r.push(d);
758
+ return;
759
+ }
760
+ i[o.key] = n;
761
+ }));
762
+ for (let [e, t] of c.entries()) {
763
+ if (t.status !== "rejected") continue;
764
+ let n = o[e];
765
+ if (!n) continue;
766
+ let [i, a] = n, s = t.reason instanceof Error ? t.reason.message : String(t.reason);
767
+ r.push({
768
+ fieldKey: i,
769
+ userMessage: "An unexpected error occurred validating this field",
770
+ systemMessage: `Validation threw for field '${i}': ${s}`,
771
+ value: a
784
772
  });
785
- return;
786
773
  }
787
- let o = a.id, c = Ke(a, t), l = await s(a, o, c);
788
- if (l) {
789
- n.push(l);
790
- return;
791
- }
792
- let u = qe(a, o, c);
793
- if (u) {
794
- n.push(u);
795
- return;
796
- }
797
- let d = Je(a, o, c);
798
- d && n.push(d), r[o] = t;
799
- })), {
800
- responsesToCommit: r,
801
- validationErrors: n
802
- };
803
- }
774
+ return {
775
+ responsesToCommit: i,
776
+ validationErrors: r
777
+ };
778
+ }
779
+ });
804
780
  async function l(e) {
805
- let { responsesToCommit: t, validationErrors: n } = await c(e);
806
- return n.length ? { errors: n } : (a.registerBatch(t), { errors: [] });
781
+ return c(e);
807
782
  }
808
- let u = t.map((e) => e), d = E({
809
- responses: t,
810
- fields: e.fields.listStore
811
- }, ({ responses: e, fields: t }) => {
812
- let n = {};
813
- for (let [r, i] of Object.entries(e)) {
814
- let e = t.find((e) => e.id === r);
815
- n[e?.key ?? r] = i;
783
+ let u = C({
784
+ source: n,
785
+ effect: async (e, t) => {
786
+ let { responsesToCommit: n, validationErrors: r } = await c(t);
787
+ return r.length ? { errors: r } : (a.registerBatch(n), { errors: [] });
816
788
  }
817
- return n;
818
- }), p = E({
819
- responses: t,
789
+ });
790
+ async function d(e) {
791
+ return u(e);
792
+ }
793
+ let f = n.map((e) => e), p = w({
794
+ responses: n,
820
795
  fields: e.fields.listStore
821
796
  }, ({ responses: e, fields: t }) => Object.entries(e).map(([e, n]) => ({
822
- fieldId: e,
823
- fieldKey: t.find((t) => t.id === e)?.key ?? e,
797
+ fieldId: t.find((t) => t.key === e)?.id ?? e,
798
+ fieldKey: e,
824
799
  value: n
825
800
  })));
826
- function m(n) {
827
- return E({
828
- f: e.fields.listStore.map((e) => e.find((e) => e.id === n) ?? null),
829
- r: t.map((e) => e[n] ?? null)
830
- }, ({ f: e, r: t }) => t === null ? e?.defaultValue ? e.defaultValue : null : t);
801
+ function m(t) {
802
+ return w({
803
+ f: e.fields.listStore.map((e) => e.find((e) => e.id === t || e.key === t) ?? null),
804
+ s: n
805
+ }, ({ f: e, s: t }) => {
806
+ let n = e ? t[e.key] ?? null : null;
807
+ return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
808
+ });
831
809
  }
832
- function h(n) {
833
- return E({
834
- f: e.fields.getByKey(n),
835
- s: t
836
- }, ({ f: e, s: t }) => (e ? t[e.id] ?? null : null) || (e?.defaultValue ? e.defaultValue : null));
810
+ function h(t) {
811
+ return w({
812
+ f: e.fields.getByKey(t),
813
+ s: n
814
+ }, ({ f: e, s: t }) => {
815
+ let n = e ? t[e.key] ?? null : null;
816
+ return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
817
+ });
837
818
  }
838
- function g(n) {
839
- return E({
840
- f: e.fields.getByName(n),
841
- s: t
842
- }, ({ f: e, s: t }) => e && t[e.id] || (e?.defaultValue ? e.defaultValue : null));
819
+ function g(t) {
820
+ return w({
821
+ f: e.fields.getByName(t),
822
+ s: n
823
+ }, ({ f: e, s: t }) => {
824
+ let n = e ? t[e.key] ?? null : null;
825
+ return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
826
+ });
843
827
  }
844
- return M({
845
- clock: n,
828
+ return A({
829
+ clock: r,
846
830
  target: a.clearAll
847
- }), M({
831
+ }), A({
848
832
  clock: i,
849
833
  target: a.clear
850
834
  }), {
851
835
  register: o,
852
- clearAll: n,
836
+ clearAll: r,
853
837
  clear: i,
854
- commit: l,
855
- getResponsesToCommit: c,
838
+ commit: d,
839
+ getResponsesToCommit: l,
856
840
  listStore: p,
857
- getAllStore: u,
858
- getAllByKeyStore: d,
841
+ getAllStore: f,
859
842
  getByFieldId: m,
860
843
  getByFieldKey: h,
861
844
  getByFieldName: g
862
845
  };
863
846
  });
864
847
  function Ze(e) {
865
- return P(Xe, e);
848
+ return M(Xe, e);
866
849
  }
867
850
  //#endregion
868
851
  //#region src/entities/condition/condition.ts
869
- var Qe = O("condition"), $e = N(() => {
870
- let e = Qe.store({}), t = D(e, { register(e, t) {
852
+ var Qe = E("condition"), $e = j(() => {
853
+ let e = Qe.store({}), t = T(e, { register(e, t) {
871
854
  return {
872
855
  ...e,
873
856
  [t.condition.id]: t.condition
@@ -891,12 +874,12 @@ var Qe = O("condition"), $e = N(() => {
891
874
  };
892
875
  });
893
876
  function et() {
894
- return P($e);
877
+ return M($e);
895
878
  }
896
879
  //#endregion
897
880
  //#region src/utils/api-url.ts
898
881
  function tt() {
899
- if (y()) {
882
+ if (f()) {
900
883
  let e = [
901
884
  document.currentScript,
902
885
  document.getElementById("picked_script"),
@@ -911,17 +894,17 @@ function tt() {
911
894
  //#endregion
912
895
  //#region src/utils/search-params.ts
913
896
  function nt() {
914
- if (!g()) return {};
897
+ if (!o()) return {};
915
898
  let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
916
899
  for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
917
900
  for (let r of n) {
918
901
  let n = r.replace("picked-", "");
919
902
  t[n] = e.getAll(r);
920
903
  }
921
- let r = w("s");
922
- if (n.size > 0) C.set(r, t);
904
+ let r = S("s");
905
+ if (n.size > 0) x.set(r, t);
923
906
  else {
924
- let e = C.get(r);
907
+ let e = x.get(r);
925
908
  if (e) return e.json() || {};
926
909
  }
927
910
  return t;
@@ -929,10 +912,10 @@ function nt() {
929
912
  //#endregion
930
913
  //#region src/utils/user-session.ts
931
914
  function rt() {
932
- return _() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
915
+ return l() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
933
916
  }
934
- var it = w("session", "global"), X = () => {
935
- let e = S.get(it), t;
917
+ var it = S("session", "global"), X = () => {
918
+ let e = b.get(it), t;
936
919
  e.isSet() && (t = e.json());
937
920
  let n = (t) => e.set({
938
921
  id: t.id,
@@ -956,14 +939,14 @@ var it = w("session", "global"), X = () => {
956
939
  }
957
940
  };
958
941
  return n(r), r;
959
- }, at = () => v() ? X() : null;
942
+ }, at = () => u() ? X() : null;
960
943
  //#endregion
961
944
  //#region src/utils/picked-config.ts
962
945
  function Z() {
963
- if (g()) return globalThis.window.pickedConfig;
946
+ if (o()) return globalThis.window.pickedConfig;
964
947
  }
965
948
  function ot() {
966
- if (!g()) return;
949
+ if (!o()) return;
967
950
  let e = Z(), t = e?.organizationId, n = e?.projectId;
968
951
  return t && n ? {
969
952
  organizationId: t,
@@ -971,7 +954,7 @@ function ot() {
971
954
  } : void 0;
972
955
  }
973
956
  function st() {
974
- if (!y()) return;
957
+ if (!f()) return;
975
958
  let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
976
959
  if (!e) return;
977
960
  let t = e.dataset.organizationid || e.getAttribute("organization-id"), n = e.dataset.projectid || e.getAttribute("project-id");
@@ -1054,13 +1037,12 @@ function pt(e, t) {
1054
1037
  //#endregion
1055
1038
  //#region src/picked.ts
1056
1039
  var $ = class {
1057
- static logger = p;
1040
+ static logger = r;
1058
1041
  options;
1059
1042
  isReady = !1;
1060
- project;
1061
1043
  plugins = {};
1062
1044
  pluginStartHooks = [];
1063
- eventBus = A();
1045
+ eventBus = O();
1064
1046
  events;
1065
1047
  organizationId;
1066
1048
  projectId;
@@ -1074,41 +1056,41 @@ var $ = class {
1074
1056
  searchParams = nt();
1075
1057
  history = ke();
1076
1058
  components = pe({ client: this });
1077
- experienceInstances = o({ client: this });
1078
- experiences = de({ client: this });
1059
+ experienceInstances = te({ client: this });
1060
+ experiences = fe({ client: this });
1079
1061
  frameworks = ge({ client: this });
1080
1062
  predicates = Ce({ client: this });
1081
1063
  features = Ee({ client: this });
1082
1064
  conditions = et();
1083
1065
  fields = Pe();
1084
1066
  responses = Ze({ client: this });
1085
- steps = Re();
1086
- actions = He();
1067
+ steps = Le();
1068
+ actions = Ve();
1087
1069
  constructor(e) {
1088
1070
  this.events = je(this.eventBus);
1089
1071
  let { organizationId: t, projectId: n } = ct(e);
1090
1072
  this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = at(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
1091
1073
  type: "load",
1092
- version: oe()
1074
+ version: se()
1093
1075
  });
1094
1076
  }
1095
1077
  start = () => {
1096
1078
  be(this), (async () => {
1097
- if (!y()) return;
1079
+ if (!f()) return;
1098
1080
  await this.runPluginStartHooks();
1099
1081
  let e = await this.evaluateGate(this.precondition);
1100
1082
  this.preconditionPassed = e;
1101
- let n;
1102
- e && (n = await this.evaluateGate(this.condition));
1103
- let r = e && n === !0;
1104
- if (typeof n == "boolean" && this.session) {
1105
- let e = n;
1083
+ let t;
1084
+ e && (t = await this.evaluateGate(this.condition));
1085
+ let n = e && t === !0;
1086
+ if (typeof t == "boolean" && this.session) {
1087
+ let e = t;
1106
1088
  this.session.setIsUser(e), this.eventBus({
1107
1089
  type: "user_decide",
1108
1090
  value: e
1109
1091
  });
1110
1092
  }
1111
- if (this.eventBus({ type: "initialize" }), r && L(this), await t(), r && L(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1093
+ if (this.eventBus({ type: "initialize" }), n && F(this), await ie(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1112
1094
  let { id: e, isUser: t, identifiers: n } = this.session;
1113
1095
  this.eventBus({
1114
1096
  type: "session",
@@ -1123,10 +1105,10 @@ var $ = class {
1123
1105
  _e(e, this.frameworks);
1124
1106
  };
1125
1107
  registerComponent = (e, t) => {
1126
- U(e, t, this.components);
1108
+ H(e, t, this.components);
1127
1109
  };
1128
1110
  registerPlugin = (e) => {
1129
- z(this, e, this.plugins);
1111
+ L(this, e, this.plugins);
1130
1112
  let t = this.plugins[e.name];
1131
1113
  t?.onStart && this.pluginStartHooks.push(t.onStart);
1132
1114
  };
@@ -1140,18 +1122,18 @@ var $ = class {
1140
1122
  this.conditions.register(e);
1141
1123
  };
1142
1124
  registerField = (e) => {
1143
- Fe(e, this.fields);
1125
+ this.fields.register(e);
1144
1126
  };
1145
1127
  registerStep = (e) => {
1146
- ze(e, this.steps);
1128
+ Re(e, this.steps);
1147
1129
  };
1148
1130
  registerAction = (e, t) => {
1149
- Ue(e, t, this.actions);
1131
+ He(e, t, this.actions);
1150
1132
  };
1151
1133
  registerExperience = (e) => {
1152
- e.component && U(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1134
+ e.component && H(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1153
1135
  };
1154
- getStateSnapshot = () => W(this);
1136
+ getStateSnapshot = () => U(this);
1155
1137
  launchExperienceById = async (e, t) => {
1156
1138
  this.experiences.launch({
1157
1139
  key: e,
@@ -1165,7 +1147,7 @@ var $ = class {
1165
1147
  for (let e of this.pluginStartHooks) await e();
1166
1148
  }
1167
1149
  async evaluateGate(e) {
1168
- return e === void 0 ? !0 : typeof e == "boolean" ? e : await r(this, e) === !0;
1150
+ return e === void 0 ? !0 : typeof e == "boolean" ? e : await t(this, e) === !0;
1169
1151
  }
1170
1152
  setupPlugins() {
1171
1153
  this.options.plugins?.forEach((e) => {
@@ -1252,7 +1234,7 @@ function ht(e) {
1252
1234
  //#region src/exports.ts
1253
1235
  var gt = (e) => {
1254
1236
  let t = new $(e);
1255
- return ne(t), t;
1237
+ return d(t), t;
1256
1238
  };
1257
1239
  //#endregion
1258
- export { $ as Picked, gt as createClient, w as createStorageKey, r as evaluateRuleLogic, Z as getPickedConfig, ht as isLazyLoader, d as isPickedRoot, mt as lazyComponent, S as localStore, C as sessionStore, x as subscribe, ie as supportsCookies, _ as supportsCryptoRandomUUID, y as supportsDocument, ee as supportsHistory, m as supportsIntersectionObserver, v as supportsLocalStorage, re as supportsLocation, h as supportsSessionStorage, te as supportsShadowRoot, b as supportsWebComponents, g as supportsWindow };
1240
+ export { $ as Picked, gt as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, ht as isLazyLoader, ee as isPickedRoot, mt as lazyComponent, b as localStore, x as sessionStore, y as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };