@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
@@ -1,42 +1,41 @@
1
- import "../../../logger-6z_gb4rA.js";
2
- import { t as e } from "../../../id-BniPxOdF.js";
3
- //#region src/plugins/create-experience/plugin.ts
4
- var t = (e) => ({
1
+ import { t as e } from "../../../id-CRqy981z.js";
2
+ //#region src/plugins/create-experience/serialization.ts
3
+ var t = {
4
+ serialize(e) {
5
+ return JSON.stringify(e);
6
+ },
7
+ deserialize(e) {
8
+ return JSON.parse(e);
9
+ }
10
+ }, n = (e) => ({
5
11
  name: "create-experience",
6
- setup: (t) => {
12
+ setup: (n) => {
7
13
  e.experiences.forEach((e) => {
8
- e.fields.forEach((e) => {
9
- t.registerField(JSON.parse(e.serialize()));
10
- }), e.steps.forEach((e) => {
11
- t.registerStep(JSON.parse(e.serialize()));
12
- }), e.conditions.forEach((e) => {
13
- t.registerCondition(JSON.parse(e.serialize()));
14
+ let r = e.serialize(), i = t.deserialize(r);
15
+ i.component = e.component;
16
+ let { steps: a, conditions: o, fields: s, ...c } = i;
17
+ n.registerExperience(c), s.forEach((e) => {
18
+ n.registerField(e);
19
+ }), a.forEach((e) => {
20
+ n.registerStep(e);
21
+ }), o.forEach((e) => {
22
+ n.registerCondition(e);
14
23
  });
15
- let n = JSON.parse(e.serialize());
16
- n.component = e.component, t.registerExperience(n);
17
24
  });
18
25
  }
19
- });
20
- //#endregion
21
- //#region src/utils/key.ts
22
- function n(e) {
23
- return e.toLowerCase().replaceAll(/[^a-z0-9\s-]/g, "").trim().replaceAll(/\s+/g, "-");
24
- }
25
- //#endregion
26
- //#region src/plugins/create-experience/create-experience.ts
27
- var r = (t, n) => ({
26
+ }), r = (n, r) => ({
28
27
  id: e("node"),
29
- experience: n,
28
+ experience: r,
30
29
  type: "action",
31
- action: t.action,
30
+ action: n.action,
32
31
  addNext(e) {
33
32
  if (!e.node) throw Error("Cannot connect to node");
34
33
  let t = s({
35
34
  sourceNode: this,
36
35
  destinationNode: e.node,
37
36
  sourceNodeHandle: null
38
- }, n);
39
- n.edges.push(t);
37
+ }, r);
38
+ r.edges.push(t);
40
39
  },
41
40
  onSuccess(e) {
42
41
  if (!e.node) throw Error("Cannot connect to node");
@@ -44,8 +43,8 @@ var r = (t, n) => ({
44
43
  sourceNode: this,
45
44
  destinationNode: e.node,
46
45
  sourceNodeHandle: "true"
47
- }, n);
48
- n.edges.push(t);
46
+ }, r);
47
+ r.edges.push(t);
49
48
  },
50
49
  onFail(e) {
51
50
  if (!e.node) throw Error("Cannot connect to node");
@@ -53,37 +52,37 @@ var r = (t, n) => ({
53
52
  sourceNode: this,
54
53
  destinationNode: e.node,
55
54
  sourceNodeHandle: "false"
56
- }, n);
57
- n.edges.push(t);
55
+ }, r);
56
+ r.edges.push(t);
58
57
  },
59
58
  serialize() {
60
- return JSON.stringify({
59
+ return t.serialize({
61
60
  id: this.id,
62
61
  type: this.type,
63
62
  action: this.action
64
63
  });
65
64
  }
66
65
  }), i = (t) => {
67
- let r = t.name ?? t.label ?? "", i = t.key ?? t.id ?? n(r);
66
+ let n = t.name, r = t.id ?? e("step");
68
67
  return {
69
- id: t.id ?? e("step"),
70
- name: r,
71
- key: i,
72
- label: r,
68
+ id: r,
69
+ name: n,
70
+ key: t.key ?? r,
71
+ label: n,
73
72
  fields: t.fields ?? [],
74
73
  addField(e) {
75
74
  let t = "serialize" in e ? e : l(e);
76
75
  return this.fields.includes(t) || this.fields.push(t), t;
77
76
  }
78
77
  };
79
- }, a = (t, r) => {
80
- let i = t.name ?? t.label ?? "", a = t.key ?? t.id ?? n(i), s = {
81
- id: t.id ?? e("step"),
78
+ }, a = (n, r) => {
79
+ let i = n.name, a = n.id ?? e("step"), s = {
80
+ id: a,
82
81
  name: i,
83
- key: a,
82
+ key: n.key ?? a,
84
83
  label: i,
85
84
  experience: r,
86
- fields: t.fields ?? [],
85
+ fields: n.fields ?? [],
87
86
  node: null,
88
87
  nextStep(e) {
89
88
  return this.experience.addStep(e, this);
@@ -101,12 +100,11 @@ var r = (t, n) => ({
101
100
  return this.experience.addField(e, this);
102
101
  },
103
102
  serialize() {
104
- return JSON.stringify({
103
+ return t.serialize({
105
104
  id: this.id,
106
- name: this.name,
107
105
  key: this.key,
108
- label: this.name,
109
- fieldKeys: this.fields.map((e) => e.key),
106
+ name: this.name,
107
+ label: this.label,
110
108
  fieldIds: this.fields.map((e) => e.id)
111
109
  });
112
110
  }
@@ -115,36 +113,35 @@ var r = (t, n) => ({
115
113
  step: s,
116
114
  type: "step"
117
115
  }, r), s;
118
- }, o = (t, n) => {
119
- let r = {
116
+ }, o = (n, r) => {
117
+ let i = {
120
118
  id: e("node"),
121
- experience: n
119
+ experience: r
122
120
  };
123
- if (t.type === "step") {
121
+ if (n.type === "step") {
124
122
  let e = {
125
- ...r,
123
+ ...i,
126
124
  type: "step",
127
- connectedStep: t.step,
125
+ connectedStep: n.step,
128
126
  serialize() {
129
- return JSON.stringify({
127
+ return t.serialize({
130
128
  id: this.id,
131
129
  type: this.type,
132
- stepKey: this.connectedStep.key,
133
- stepId: this.connectedStep.key,
130
+ stepId: this.connectedStep.id,
134
131
  name: this.connectedStep.name,
135
- label: this.connectedStep.name
132
+ label: this.connectedStep.label
136
133
  });
137
134
  }
138
135
  };
139
136
  return e.connectedStep.node = e, e;
140
137
  }
141
- if (t.type === "condition") {
138
+ if (n.type === "condition") {
142
139
  let e = {
143
- ...r,
140
+ ...i,
144
141
  type: "condition",
145
- connectedCondition: t.condition,
142
+ connectedCondition: n.condition,
146
143
  serialize() {
147
- return JSON.stringify({
144
+ return t.serialize({
148
145
  id: this.id,
149
146
  type: this.type,
150
147
  conditionId: this.connectedCondition.id
@@ -153,48 +150,48 @@ var r = (t, n) => ({
153
150
  };
154
151
  return e.connectedCondition.node = e, e;
155
152
  }
156
- return t.type === "experience" ? {
157
- ...r,
153
+ return n.type === "experience" ? {
154
+ ...i,
158
155
  type: "experience",
159
- connectedExperience: t.experience,
156
+ connectedExperience: n.experience,
160
157
  serialize() {
161
- return JSON.stringify({
158
+ return t.serialize({
162
159
  id: this.id,
163
160
  type: this.type,
164
161
  experienceId: this.connectedExperience.id
165
162
  });
166
163
  }
167
164
  } : {
168
- ...r,
165
+ ...i,
169
166
  type: "origin",
170
167
  serialize() {
171
- return JSON.stringify({
168
+ return t.serialize({
172
169
  id: this.id,
173
170
  type: this.type
174
171
  });
175
172
  }
176
173
  };
177
- }, s = (t, n) => ({
174
+ }, s = (n, r) => ({
178
175
  id: e("edge"),
179
- sourceNode: t.sourceNode,
180
- sourceNodeHandle: t.sourceNodeHandle,
181
- destinationNode: t.destinationNode,
182
- experience: n,
176
+ sourceNode: n.sourceNode,
177
+ sourceNodeHandle: n.sourceNodeHandle,
178
+ destinationNode: n.destinationNode,
179
+ experience: r,
183
180
  serialize() {
184
- return JSON.stringify({
181
+ return t.serialize({
185
182
  id: this.id,
186
183
  sourceNodeHandle: this.sourceNodeHandle ?? void 0,
187
184
  sourceNodeId: this.sourceNode.id,
188
185
  destinationNodeId: this.destinationNode.id
189
186
  });
190
187
  }
191
- }), c = (t, r) => {
192
- let i = e("conditional"), a = t.name ?? t.label ?? i, c = {
188
+ }), c = (n, r) => {
189
+ let i = e("conditional"), a = n.name ?? n.label ?? i, c = {
193
190
  id: i,
194
- key: t.key ?? n(a),
191
+ key: n.key ?? i,
195
192
  name: a,
196
- label: t.label,
197
- logic: t.condition,
193
+ label: n.label,
194
+ logic: n.condition,
198
195
  node: null,
199
196
  experience: r,
200
197
  addTrue(e) {
@@ -216,7 +213,7 @@ var r = (t, n) => ({
216
213
  this.experience.edges.push(t);
217
214
  },
218
215
  serialize() {
219
- return JSON.stringify({
216
+ return t.serialize({
220
217
  id: this.id,
221
218
  key: this.key,
222
219
  name: this.name,
@@ -228,27 +225,27 @@ var r = (t, n) => ({
228
225
  condition: c,
229
226
  type: "condition"
230
227
  }, r), c;
231
- }, l = (t) => {
232
- let r = t.key ?? t.id ?? n(t.name);
233
- return t.id !== void 0 && `${t.id}${r}`, {
234
- id: t.id ?? e("field"),
235
- key: r,
236
- name: t.name,
237
- type: t.type,
238
- label: t.label,
239
- placeholder: t.placeholder,
240
- description: t.description,
241
- helpText: t.helpText,
242
- defaultValue: t.defaultValue ?? null,
243
- multiple: t.multiple,
244
- validation: t.validation ?? {},
245
- condition: t.condition,
246
- required: t.required,
247
- options: t.options?.map((t) => ({
228
+ }, l = (n) => {
229
+ let r = n.id ?? e("field");
230
+ return {
231
+ id: r,
232
+ key: n.key ?? r,
233
+ name: n.name,
234
+ type: n.type,
235
+ label: n.label,
236
+ placeholder: n.placeholder,
237
+ description: n.description,
238
+ helpText: n.helpText,
239
+ defaultValue: n.defaultValue ?? null,
240
+ multiple: n.multiple,
241
+ validation: n.validation ?? {},
242
+ condition: n.condition,
243
+ required: n.required,
244
+ options: n.options?.map((t) => ({
248
245
  id: "id" in t ? t.id : e("option"),
249
246
  ...t
250
247
  })) ?? null,
251
- policies: t.policies,
248
+ policies: n.policies,
252
249
  serialize() {
253
250
  let e = {
254
251
  id: this.id,
@@ -262,21 +259,21 @@ var r = (t, n) => ({
262
259
  validation: this.validation,
263
260
  condition: this.condition,
264
261
  policies: this.policies
265
- }, t = typeof this.defaultValue == "string" ? this.defaultValue : void 0, n = typeof this.defaultValue == "number" ? this.defaultValue : void 0, r = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
262
+ }, n = typeof this.defaultValue == "string" ? this.defaultValue : void 0, r = typeof this.defaultValue == "number" ? this.defaultValue : void 0, i = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
266
263
  switch (this.type) {
267
264
  case "text":
268
265
  if (this.multiple) {
269
- let t;
266
+ let n;
270
267
  if (Array.isArray(this.defaultValue)) {
271
- t = [];
272
- for (let e of this.defaultValue) typeof e == "string" && t.push(e);
273
- t.length === 0 && (t = void 0);
268
+ n = [];
269
+ for (let e of this.defaultValue) typeof e == "string" && n.push(e);
270
+ n.length === 0 && (n = void 0);
274
271
  }
275
- return JSON.stringify({
272
+ return t.serialize({
276
273
  ...e,
277
274
  type: "text",
278
275
  multiple: !0,
279
- defaultValue: t,
276
+ defaultValue: n,
280
277
  options: this.options ? this.options.map((e) => ({
281
278
  id: e.id,
282
279
  label: e.label,
@@ -285,11 +282,11 @@ var r = (t, n) => ({
285
282
  })) : null
286
283
  });
287
284
  }
288
- return JSON.stringify({
285
+ return t.serialize({
289
286
  ...e,
290
287
  type: "text",
291
288
  multiple: !1,
292
- defaultValue: t,
289
+ defaultValue: n,
293
290
  options: this.options ? this.options.map((e) => ({
294
291
  id: e.id,
295
292
  label: e.label,
@@ -299,17 +296,17 @@ var r = (t, n) => ({
299
296
  });
300
297
  case "number":
301
298
  if (this.multiple) {
302
- let t;
299
+ let n;
303
300
  if (Array.isArray(this.defaultValue)) {
304
- t = [];
305
- for (let e of this.defaultValue) typeof e == "number" && t.push(e);
306
- t.length === 0 && (t = void 0);
301
+ n = [];
302
+ for (let e of this.defaultValue) typeof e == "number" && n.push(e);
303
+ n.length === 0 && (n = void 0);
307
304
  }
308
- return JSON.stringify({
305
+ return t.serialize({
309
306
  ...e,
310
307
  type: "number",
311
308
  multiple: !0,
312
- defaultValue: t,
309
+ defaultValue: n,
313
310
  options: this.options ? this.options.map((e) => ({
314
311
  id: e.id,
315
312
  label: e.label,
@@ -318,11 +315,11 @@ var r = (t, n) => ({
318
315
  })) : null
319
316
  });
320
317
  }
321
- return JSON.stringify({
318
+ return t.serialize({
322
319
  ...e,
323
320
  type: "number",
324
321
  multiple: !1,
325
- defaultValue: n,
322
+ defaultValue: r,
326
323
  options: this.options ? this.options.map((e) => ({
327
324
  id: e.id,
328
325
  label: e.label,
@@ -332,17 +329,17 @@ var r = (t, n) => ({
332
329
  });
333
330
  case "boolean":
334
331
  if (this.multiple) {
335
- let t;
332
+ let n;
336
333
  if (Array.isArray(this.defaultValue)) {
337
- t = [];
338
- for (let e of this.defaultValue) typeof e == "boolean" && t.push(e);
339
- t.length === 0 && (t = void 0);
334
+ n = [];
335
+ for (let e of this.defaultValue) typeof e == "boolean" && n.push(e);
336
+ n.length === 0 && (n = void 0);
340
337
  }
341
- return JSON.stringify({
338
+ return t.serialize({
342
339
  ...e,
343
340
  type: "boolean",
344
341
  multiple: !0,
345
- defaultValue: t,
342
+ defaultValue: n,
346
343
  options: this.options ? this.options.map((e) => ({
347
344
  id: e.id,
348
345
  label: e.label,
@@ -351,11 +348,11 @@ var r = (t, n) => ({
351
348
  })) : null
352
349
  });
353
350
  }
354
- return JSON.stringify({
351
+ return t.serialize({
355
352
  ...e,
356
353
  type: "boolean",
357
354
  multiple: !1,
358
- defaultValue: r,
355
+ defaultValue: i,
359
356
  options: this.options ? this.options.map((e) => ({
360
357
  id: e.id,
361
358
  label: e.label,
@@ -363,7 +360,7 @@ var r = (t, n) => ({
363
360
  condition: e.condition
364
361
  })) : null
365
362
  });
366
- case "object": return this.multiple ? JSON.stringify({
363
+ case "object": return this.multiple ? t.serialize({
367
364
  ...e,
368
365
  type: "object",
369
366
  multiple: !0,
@@ -375,7 +372,7 @@ var r = (t, n) => ({
375
372
  value: e.value,
376
373
  condition: e.condition
377
374
  })) : null
378
- }) : JSON.stringify({
375
+ }) : t.serialize({
379
376
  ...e,
380
377
  type: "object",
381
378
  multiple: !1,
@@ -392,105 +389,105 @@ var r = (t, n) => ({
392
389
  }
393
390
  }
394
391
  };
395
- }, u = (e) => {
396
- let t = e.key ?? e.id;
397
- return {
398
- id: e.id,
399
- key: t,
400
- component: e.component,
401
- name: e.name,
402
- initializeOpen: e.initializeOpen,
403
- condition: e.condition,
404
- targets: e.targets,
405
- steps: [],
406
- nodes: [],
407
- edges: [],
408
- fields: [],
409
- conditions: [],
410
- addStep(e, t) {
411
- let n = t?.node;
412
- this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
413
- let r = "serialize" in e ? e : a(e, this);
414
- if (n) {
415
- if (!r.node) throw Error("todo no node");
416
- let e = s({
417
- sourceNode: n,
418
- destinationNode: r.node,
419
- sourceNodeHandle: null
420
- }, this);
421
- this.edges.push(e);
422
- }
423
- return r.fields.length > 0 && r.fields.forEach((e) => {
424
- this.fields.includes(e) || this.fields.push(e);
425
- }), this.steps.includes(r) || (this.steps.push(r), r.node && this.nodes.push(r.node)), r;
426
- },
427
- addAction(e, t) {
428
- let n = t?.node;
429
- this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
430
- let i = "serialize" in e ? e : r(e, this);
431
- if (n) {
432
- let e = s({
433
- sourceNode: n,
434
- destinationNode: i,
435
- sourceNodeHandle: null
436
- }, this);
437
- this.edges.push(e);
438
- }
439
- return this.nodes.push(i), i;
440
- },
441
- addCondition(e, t) {
442
- let n = t?.node;
443
- this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
444
- let r = "serialize" in e ? e : c(e, this);
445
- if (n) {
446
- if (!r.node) throw Error("todo no node");
447
- let e = s({
448
- sourceNode: n,
449
- destinationNode: r.node,
450
- sourceNodeHandle: null
451
- }, this);
452
- this.edges.push(e);
453
- }
454
- return this.conditions.includes(r) || (this.conditions.push(r), r.node && this.nodes.push(r.node)), r;
455
- },
456
- addConditional(e, t) {
457
- return this.addCondition(e, t);
458
- },
459
- addExperience(e, t) {
460
- let n = t?.node;
461
- this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
462
- let r = o({
463
- type: "experience",
464
- experience: e
392
+ }, u = (e) => ({
393
+ id: e.id,
394
+ key: e.key,
395
+ component: e.component,
396
+ name: e.name,
397
+ initializeOpen: e.initializeOpen,
398
+ condition: e.condition,
399
+ targets: e.targets,
400
+ steps: [],
401
+ nodes: [],
402
+ edges: [],
403
+ fields: [],
404
+ conditions: [],
405
+ addStep(e, t) {
406
+ let n = t?.node;
407
+ this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
408
+ let r = "serialize" in e ? e : a(e, this);
409
+ if (n) {
410
+ if (!r.node) throw Error("todo no node");
411
+ let e = s({
412
+ sourceNode: n,
413
+ destinationNode: r.node,
414
+ sourceNodeHandle: null
465
415
  }, this);
466
- if (this.nodes.push(r), n) {
467
- let e = s({
468
- sourceNode: n,
469
- destinationNode: r,
470
- sourceNodeHandle: null
471
- }, this);
472
- this.edges.push(e);
473
- }
474
- return e;
475
- },
476
- addField(e, t) {
477
- let n = "serialize" in e ? e : l(e);
478
- return t && t.fields.push(n), this.fields.includes(n) || this.fields.push(n), n;
479
- },
480
- serialize() {
481
- return JSON.stringify({
482
- id: this.id,
483
- key: this.key,
484
- component: this.component,
485
- name: this.name,
486
- initializeOpen: this.initializeOpen,
487
- condition: this.condition,
488
- targets: this.targets,
489
- nodes: this.nodes.map((e) => JSON.parse(e.serialize())),
490
- edges: this.edges.map((e) => JSON.parse(e.serialize()))
491
- });
416
+ this.edges.push(e);
492
417
  }
493
- };
494
- };
418
+ return r.fields.length > 0 && r.fields.forEach((e) => {
419
+ this.fields.includes(e) || this.fields.push(e);
420
+ }), this.steps.includes(r) || (this.steps.push(r), r.node && this.nodes.push(r.node)), r;
421
+ },
422
+ addAction(e, t) {
423
+ let n = t?.node;
424
+ this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
425
+ let i = "serialize" in e ? e : r(e, this);
426
+ if (n) {
427
+ let e = s({
428
+ sourceNode: n,
429
+ destinationNode: i,
430
+ sourceNodeHandle: null
431
+ }, this);
432
+ this.edges.push(e);
433
+ }
434
+ return this.nodes.push(i), i;
435
+ },
436
+ addCondition(e, t) {
437
+ let n = t?.node;
438
+ this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
439
+ let r = "serialize" in e ? e : c(e, this);
440
+ if (n) {
441
+ if (!r.node) throw Error("todo no node");
442
+ let e = s({
443
+ sourceNode: n,
444
+ destinationNode: r.node,
445
+ sourceNodeHandle: null
446
+ }, this);
447
+ this.edges.push(e);
448
+ }
449
+ return this.conditions.includes(r) || (this.conditions.push(r), r.node && this.nodes.push(r.node)), r;
450
+ },
451
+ addConditional(e, t) {
452
+ return this.addCondition(e, t);
453
+ },
454
+ addExperience(e, t) {
455
+ let n = t?.node;
456
+ this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
457
+ let r = o({
458
+ type: "experience",
459
+ experience: e
460
+ }, this);
461
+ if (this.nodes.push(r), n) {
462
+ let e = s({
463
+ sourceNode: n,
464
+ destinationNode: r,
465
+ sourceNodeHandle: null
466
+ }, this);
467
+ this.edges.push(e);
468
+ }
469
+ return e;
470
+ },
471
+ addField(e, t) {
472
+ let n = "serialize" in e ? e : l(e);
473
+ return t && t.fields.push(n), this.fields.includes(n) || this.fields.push(n), n;
474
+ },
475
+ serialize() {
476
+ return t.serialize({
477
+ id: this.id,
478
+ key: this.key,
479
+ component: this.component,
480
+ name: this.name,
481
+ initializeOpen: this.initializeOpen,
482
+ condition: this.condition,
483
+ targets: this.targets,
484
+ steps: this.steps.map((e) => t.deserialize(e.serialize())),
485
+ nodes: this.nodes.map((e) => t.deserialize(e.serialize())),
486
+ edges: this.edges.map((e) => t.deserialize(e.serialize())),
487
+ conditions: this.conditions.map((e) => t.deserialize(e.serialize())),
488
+ fields: this.fields.map((e) => t.deserialize(e.serialize()))
489
+ });
490
+ }
491
+ });
495
492
  //#endregion
496
- export { c as createCondition, s as createEdge, u as createExperience, t as createExperiencePlugin, l as createField, o as createNode, i as createStep };
493
+ export { c as createCondition, s as createEdge, u as createExperience, n as createExperiencePlugin, l as createField, o as createNode, i as createStep };
@@ -1,5 +1,5 @@
1
1
  import "../../../logger-6z_gb4rA.js";
2
- import { i as e, t } from "../../../api-ENA5t36y.js";
2
+ import { i as e, t } from "../../../api-DwERBrAZ.js";
3
3
  //#region src/plugins/dynamic-experiences/hash.ts
4
4
  function n(e) {
5
5
  let t = 2166136261;
@@ -18,30 +18,29 @@ function a(e) {
18
18
  return typeof e == "object" && !!e && "features" in e && Array.isArray(e.features);
19
19
  }
20
20
  function o(e, t) {
21
- if (t.conditions) for (let n of t.conditions) e.registerCondition(n);
21
+ for (let n of t.conditions) e.registerCondition(n);
22
22
  }
23
23
  function s(e, t) {
24
24
  e.registerExperience({
25
25
  id: t.id,
26
26
  key: t.key,
27
27
  name: t.name,
28
- targets: t.targets ?? [],
28
+ targets: t.targets,
29
29
  nodes: t.nodes,
30
30
  edges: t.edges,
31
- actions: t.actions,
32
31
  condition: t.condition,
33
32
  initializeOpen: t.initializeOpen,
34
33
  componentName: t.componentName
35
34
  });
36
35
  }
37
36
  function c(e, t) {
38
- if (t.fields) for (let n of t.fields) e.registerField(n);
37
+ for (let n of t.fields) e.registerField(n);
39
38
  }
40
39
  function l(e, t) {
41
- if (t.steps) for (let n of t.steps) e.registerStep(n);
40
+ for (let n of t.steps) e.registerStep(n);
42
41
  }
43
42
  function u(e, t) {
44
- if (t.experiences) for (let n of t.experiences) s(e, n);
43
+ for (let n of t.experiences) s(e, n);
45
44
  }
46
45
  function d(e) {
47
46
  let t = e.searchParams["preview-token"];