@picked/client 0.0.1-dev.1772412203098 → 0.0.1-dev.1773363643396

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 (98) hide show
  1. package/dist/api-C7ddxkUx.cjs +1 -0
  2. package/dist/api-CQ_YBH_c.js +32 -0
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/plugins/create-experience/index.js +1 -1
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  6. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  7. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  9. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  10. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  11. package/dist/cjs/server/index.js +1 -1
  12. package/dist/esm/index.js +602 -687
  13. package/dist/esm/plugins/create-experience/index.js +237 -213
  14. package/dist/esm/plugins/dynamic-experiences/index.js +65 -43
  15. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  16. package/dist/esm/plugins/history-browser-storage/index.js +1 -1
  17. package/dist/esm/plugins/responses-browser-storage/index.js +18 -17
  18. package/dist/esm/plugins/responses-indexeddb/index.js +46 -51
  19. package/dist/esm/plugins/single-page-app/index.js +24 -24
  20. package/dist/esm/server/index.js +1 -1
  21. package/dist/experience-instance-BsXG5XJ4.cjs +1 -0
  22. package/dist/{experience-instance-DTyL1fNb.js → experience-instance-fvSEb72i.js} +199 -205
  23. package/dist/object-BbFTsGh3.cjs +1 -0
  24. package/dist/{object-CJssU1Pm.js → object-JwZ58NOH.js} +1 -1
  25. package/dist/storage-Be5xWNPC.cjs +1 -0
  26. package/dist/{storage-B2d81EOI.js → storage-Co_LbKr_.js} +30 -35
  27. package/dist/to-kebab-case-BPnCZjhB.js +6 -0
  28. package/dist/to-kebab-case-BsOQ8CON.cjs +1 -0
  29. package/dist/types/client.d.ts +13 -0
  30. package/dist/types/client.d.ts.map +1 -1
  31. package/dist/types/entities/action/action.d.ts +2 -5
  32. package/dist/types/entities/action/action.d.ts.map +1 -1
  33. package/dist/types/entities/experience/experience.d.ts +31 -17
  34. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  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 +21 -52
  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/project/project.d.ts.map +1 -1
  41. package/dist/types/entities/response/response.d.ts +6 -6
  42. package/dist/types/entities/response/response.d.ts.map +1 -1
  43. package/dist/types/index.d.ts +0 -1
  44. package/dist/types/index.d.ts.map +1 -1
  45. package/dist/types/logic-engine.d.ts +8 -2
  46. package/dist/types/logic-engine.d.ts.map +1 -1
  47. package/dist/types/picked.d.ts +17 -23
  48. package/dist/types/picked.d.ts.map +1 -1
  49. package/dist/types/plugins/create-experience/create-experience.d.ts +28 -33
  50. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  51. package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -0
  52. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  53. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +2 -2
  54. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  55. package/dist/types/plugins/dynamic-experiences/types.d.ts +7 -1
  56. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  57. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +1 -2
  58. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  59. package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -2
  60. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  61. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +1 -2
  62. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  63. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
  64. package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
  65. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  66. package/dist/types/utils/api.d.ts +1 -1
  67. package/dist/types/utils/api.d.ts.map +1 -1
  68. package/dist/types/utils/client-headers.d.ts +2 -0
  69. package/dist/types/utils/client-headers.d.ts.map +1 -0
  70. package/dist/types/utils/dom.d.ts +3 -0
  71. package/dist/types/utils/dom.d.ts.map +1 -1
  72. package/dist/types/utils/events.d.ts +1 -1
  73. package/dist/types/utils/events.d.ts.map +1 -1
  74. package/dist/types/utils/get-step-fields.d.ts +1 -2
  75. package/dist/types/utils/get-step-fields.d.ts.map +1 -1
  76. package/dist/types/utils/global-obj.d.ts +1 -0
  77. package/dist/types/utils/global-obj.d.ts.map +1 -1
  78. package/dist/types/utils/indexed-db.d.ts +1 -2
  79. package/dist/types/utils/indexed-db.d.ts.map +1 -1
  80. package/dist/types/utils/logger.d.ts.map +1 -1
  81. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  82. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  83. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  84. package/dist/types/utils/object.d.ts +8 -0
  85. package/dist/types/utils/object.d.ts.map +1 -1
  86. package/dist/types/utils/picked-config.d.ts +1 -1
  87. package/dist/types/utils/picked-config.d.ts.map +1 -1
  88. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  89. package/dist/types/utils/search-params.d.ts.map +1 -1
  90. package/dist/types/utils/storage.d.ts.map +1 -1
  91. package/dist/types/utils/to-kebab-case.d.ts +9 -0
  92. package/dist/types/utils/to-kebab-case.d.ts.map +1 -0
  93. package/package.json +59 -8
  94. package/dist/api-CbXfbi_s.js +0 -19
  95. package/dist/api-DzSCgBQ2.cjs +0 -1
  96. package/dist/experience-instance-BX0aqKsC.cjs +0 -1
  97. package/dist/object-mwaxtjLG.cjs +0 -1
  98. package/dist/storage-58NoTSsc.cjs +0 -1
@@ -1,113 +1,111 @@
1
- import { g as f } from "../../../id-BW-g3y32.js";
2
- const a = {
1
+ import { g as h } from "../../../id-BW-g3y32.js";
2
+ import { t as m } from "../../../to-kebab-case-BPnCZjhB.js";
3
+ const r = {
3
4
  serialize(i) {
4
5
  return JSON.stringify(i);
5
6
  },
6
7
  deserialize(i) {
7
8
  return JSON.parse(i);
8
9
  }
9
- }, V = (i) => ({
10
+ }, x = (i) => ({
10
11
  name: "create-experience",
11
- setup: (n) => {
12
- i.experiences.forEach((s) => {
13
- const t = s.serialize(), d = a.deserialize(t);
14
- d.component = s.component, n.registerExperience(d), d.fields.forEach((N) => {
15
- n.registerField(N);
12
+ setup: (o) => {
13
+ i.experiences.forEach((t) => {
14
+ const n = t.serialize(), d = r.deserialize(n);
15
+ d.component = t.component, o.registerExperience(d), d.fields.forEach((f) => {
16
+ o.registerField(f);
16
17
  });
17
18
  });
18
19
  }
19
- }), z = (i, n) => ({
20
- id: f("node"),
21
- position: [0, 0],
22
- experience: n,
20
+ }), y = (i, o) => ({
21
+ id: h("node"),
22
+ experience: o,
23
23
  type: "action",
24
24
  action: i.action,
25
- addNext(t) {
26
- if (!t.node) throw new Error("Cannot connect to node");
27
- const d = h(
28
- { sourceNode: this, destinationNode: t.node, sourceNodeHandle: null },
29
- n
25
+ addNext(n) {
26
+ if (!n.node) throw new Error("Cannot connect to node");
27
+ const d = c(
28
+ { sourceNode: this, destinationNode: n.node, sourceNodeHandle: null },
29
+ o
30
30
  );
31
- n.edges.push(d);
31
+ o.edges.push(d);
32
32
  },
33
- onSuccess(t) {
34
- if (!t.node) throw new Error("Cannot connect to node");
35
- const d = h(
36
- { sourceNode: this, destinationNode: t.node, sourceNodeHandle: "true" },
37
- n
33
+ onSuccess(n) {
34
+ if (!n.node) throw new Error("Cannot connect to node");
35
+ const d = c(
36
+ { sourceNode: this, destinationNode: n.node, sourceNodeHandle: "true" },
37
+ o
38
38
  );
39
- n.edges.push(d);
39
+ o.edges.push(d);
40
40
  },
41
- onFail(t) {
42
- if (!t.node) throw new Error("Cannot connect to node");
43
- const d = h(
44
- { sourceNode: this, destinationNode: t.node, sourceNodeHandle: "false" },
45
- n
41
+ onFail(n) {
42
+ if (!n.node) throw new Error("Cannot connect to node");
43
+ const d = c(
44
+ { sourceNode: this, destinationNode: n.node, sourceNodeHandle: "false" },
45
+ o
46
46
  );
47
- n.edges.push(d);
47
+ o.edges.push(d);
48
48
  },
49
49
  serialize() {
50
- return a.serialize({
50
+ return r.serialize({
51
51
  id: this.id,
52
52
  type: this.type,
53
- action: this.action,
54
- position: this.position
53
+ action: this.action
55
54
  });
56
55
  }
57
- }), E = (i) => ({
58
- id: i.id ?? f("step"),
59
- label: i.label,
56
+ }), V = (i) => ({
57
+ id: i.id ?? h("step"),
58
+ name: i.name,
60
59
  fields: i.fields ?? [],
61
- addField(n) {
62
- const s = "serialize" in n ? n : y(n);
63
- return this.fields.includes(s) || this.fields.push(s), s;
60
+ addField(o) {
61
+ const t = "serialize" in o ? o : N(o);
62
+ return this.fields.includes(t) || this.fields.push(t), t;
64
63
  }
65
- }), g = (i, n) => {
66
- const s = {
67
- id: i.id ?? f("step"),
68
- label: i.label,
69
- experience: n,
64
+ }), z = (i, o) => {
65
+ const t = {
66
+ id: i.id ?? h("step"),
67
+ name: i.name,
68
+ experience: o,
70
69
  fields: i.fields ?? [],
71
70
  node: null,
72
- nextStep(t) {
73
- return this.experience.addStep(t, this);
71
+ nextStep(n) {
72
+ return this.experience.addStep(n, this);
74
73
  },
75
- nextConditional(t) {
76
- return this.experience.addConditional(t, this);
74
+ nextConditional(n) {
75
+ return this.experience.addConditional(n, this);
77
76
  },
78
- addNextExperience(t) {
79
- return this.experience.addExperience(t, this);
77
+ addNextExperience(n) {
78
+ return this.experience.addExperience(n, this);
80
79
  },
81
- addField(t) {
82
- return this.experience.addField(t, this);
80
+ addField(n) {
81
+ return this.experience.addField(n, this);
83
82
  },
84
83
  serialize() {
85
- return a.serialize({
84
+ return r.serialize({
86
85
  id: this.id,
87
- label: this.label,
88
- fieldIds: this.fields.map((t) => t.id)
86
+ key: m(this.name),
87
+ name: this.name,
88
+ fieldIds: this.fields.map((n) => n.id)
89
89
  });
90
90
  }
91
91
  };
92
- return p({ step: s, type: "step" }, n), s;
93
- }, m = () => [0, 0], p = (i, n) => {
94
- const s = {
95
- id: f("node"),
96
- position: m(),
97
- experience: n
92
+ return p({ step: t, type: "step" }, o), t;
93
+ }, p = (i, o) => {
94
+ const t = {
95
+ id: h("node"),
96
+ experience: o
98
97
  };
99
98
  if (i.type === "step") {
100
99
  const d = {
101
- ...s,
100
+ ...t,
102
101
  type: "step",
103
102
  connectedStep: i.step,
104
103
  serialize() {
105
- return a.serialize({
104
+ return r.serialize({
106
105
  id: this.id,
107
106
  type: this.type,
108
107
  stepId: this.connectedStep.id,
109
- position: this.position,
110
- label: this.connectedStep.label
108
+ name: this.connectedStep.name
111
109
  });
112
110
  }
113
111
  };
@@ -115,93 +113,91 @@ const a = {
115
113
  }
116
114
  if (i.type === "conditional") {
117
115
  const d = {
118
- ...s,
116
+ ...t,
119
117
  type: "conditional",
120
118
  connectedConditional: i.conditional,
121
119
  serialize() {
122
- return a.serialize({
120
+ return r.serialize({
123
121
  id: this.id,
124
122
  type: this.type,
125
- conditionalId: this.connectedConditional.id,
126
- position: this.position
123
+ conditionalId: this.connectedConditional.id
127
124
  });
128
125
  }
129
126
  };
130
127
  return d.connectedConditional.node = d, d;
131
128
  }
132
129
  return i.type === "experience" ? {
133
- ...s,
130
+ ...t,
134
131
  type: "experience",
135
132
  connectedExperience: i.experience,
136
133
  serialize() {
137
- return a.serialize({
134
+ return r.serialize({
138
135
  id: this.id,
139
136
  type: this.type,
140
- experienceId: this.connectedExperience.id,
141
- position: this.position
137
+ experienceId: this.connectedExperience.id
142
138
  });
143
139
  }
144
140
  } : {
145
- ...s,
141
+ ...t,
146
142
  type: "origin",
147
143
  serialize() {
148
- return a.serialize({
144
+ return r.serialize({
149
145
  id: this.id,
150
- type: this.type,
151
- position: this.position
146
+ type: this.type
152
147
  });
153
148
  }
154
149
  };
155
- }, h = (i, n) => ({
156
- id: f("edge"),
150
+ }, c = (i, o) => ({
151
+ id: h("edge"),
157
152
  sourceNode: i.sourceNode,
158
153
  sourceNodeHandle: i.sourceNodeHandle,
159
154
  destinationNode: i.destinationNode,
160
- experience: n,
155
+ experience: o,
161
156
  serialize() {
162
- return a.serialize({
157
+ return r.serialize({
163
158
  id: this.id,
164
159
  sourceNodeHandle: this.sourceNodeHandle ?? void 0,
165
160
  sourceNodeId: this.sourceNode.id,
166
161
  destinationNodeId: this.destinationNode.id
167
162
  });
168
163
  }
169
- }), b = (i, n) => {
170
- const s = {
171
- id: f("conditional"),
164
+ }), g = (i, o) => {
165
+ const t = {
166
+ id: h("conditional"),
172
167
  label: i.label,
173
168
  condition: i.condition,
174
169
  node: null,
175
- experience: n,
176
- addTrue(t) {
177
- if (!this.node || !t.node)
170
+ experience: o,
171
+ addTrue(n) {
172
+ if (!this.node || !n.node)
178
173
  throw new Error("todo no node");
179
- const d = h(
180
- { sourceNode: this.node, destinationNode: t.node, sourceNodeHandle: "true" },
174
+ const d = c(
175
+ { sourceNode: this.node, destinationNode: n.node, sourceNodeHandle: "true" },
181
176
  this.experience
182
177
  );
183
178
  this.experience.edges.push(d);
184
179
  },
185
- addFalse(t) {
186
- if (!this.node || !t.node)
180
+ addFalse(n) {
181
+ if (!this.node || !n.node)
187
182
  throw new Error("todo no node");
188
- const d = h(
189
- { sourceNode: this.node, destinationNode: t.node, sourceNodeHandle: "false" },
183
+ const d = c(
184
+ { sourceNode: this.node, destinationNode: n.node, sourceNodeHandle: "false" },
190
185
  this.experience
191
186
  );
192
187
  this.experience.edges.push(d);
193
188
  },
194
189
  serialize() {
195
- return a.serialize({
190
+ return r.serialize({
196
191
  id: this.id,
197
192
  label: this.label,
198
193
  condition: this.condition
199
194
  });
200
195
  }
201
196
  };
202
- return p({ conditional: s, type: "conditional" }, n), s;
203
- }, y = (i) => ({
204
- id: i.id,
197
+ return p({ conditional: t, type: "conditional" }, o), t;
198
+ }, N = (i) => ({
199
+ id: i.id ?? h("field"),
200
+ key: i.key ?? m(i.name),
205
201
  name: i.name,
206
202
  type: i.type,
207
203
  label: i.label,
@@ -213,17 +209,16 @@ const a = {
213
209
  validation: i.validation ?? {},
214
210
  condition: i.condition,
215
211
  required: i.required,
216
- options: Array.isArray(i.options) ? i.options.map(({ id: s, ...t }) => ({
217
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- defensive fallback in case option id is omitted at runtime
218
- id: s ?? f("option"),
212
+ options: i.options?.map((t) => ({
213
+ id: "id" in t ? t.id : h("option"),
219
214
  ...t
220
- })) : i.options ?? null,
221
- dependsOn: i.dependsOn,
215
+ })) ?? null,
222
216
  policies: i.policies,
223
- // eslint-disable-next-line sonarjs/cognitive-complexity -- field type serialization logic requires branching per type/multiple combination
217
+ // eslint-disable-next-line sonarjs/cognitive-complexity -- this function handles all field types and subtypes; splitting it would increase indirection without improving clarity. Addressed in PR #1372
224
218
  serialize() {
225
- const s = {
219
+ const t = {
226
220
  id: this.id,
221
+ key: this.key,
227
222
  name: this.name,
228
223
  label: this.label,
229
224
  placeholder: this.placeholder,
@@ -232,217 +227,246 @@ const a = {
232
227
  helpText: this.helpText,
233
228
  validation: this.validation,
234
229
  condition: this.condition,
235
- dependsOn: this.dependsOn,
236
230
  policies: this.policies
237
- }, t = typeof this.defaultValue == "string" ? this.defaultValue : void 0, d = typeof this.defaultValue == "number" ? this.defaultValue : void 0, N = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0, u = (e) => this.options ? Array.isArray(this.options) ? this.options.map((o) => ({
238
- id: o.id,
239
- label: o.label,
240
- description: o.description,
241
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- option.value may be wider than JsonValue at this point; cast is safe before passing to castValue
242
- value: e(o.value),
243
- condition: o.condition
244
- })) : this.options : null;
231
+ }, n = typeof this.defaultValue == "string" ? this.defaultValue : void 0, d = typeof this.defaultValue == "number" ? this.defaultValue : void 0, f = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
245
232
  switch (this.type) {
246
233
  case "text":
247
234
  if (this.multiple) {
248
235
  let e;
249
236
  if (Array.isArray(this.defaultValue)) {
250
237
  e = [];
251
- for (const o of this.defaultValue)
252
- typeof o == "string" && e.push(o);
238
+ for (const s of this.defaultValue)
239
+ typeof s == "string" && e.push(s);
253
240
  e.length === 0 && (e = void 0);
254
241
  }
255
- return a.serialize({
256
- ...s,
242
+ return r.serialize({
243
+ ...t,
257
244
  type: "text",
258
245
  multiple: !0,
259
246
  defaultValue: e,
260
- options: u((o) => `${o}`)
247
+ options: this.options ? this.options.map((s) => ({
248
+ id: s.id,
249
+ label: s.label,
250
+ value: `${s.value}`,
251
+ condition: s.condition
252
+ })) : null
261
253
  });
262
254
  }
263
- return a.serialize({
264
- ...s,
255
+ return r.serialize({
256
+ ...t,
265
257
  type: "text",
266
258
  multiple: !1,
267
- defaultValue: t,
268
- options: u((e) => `${e}`)
259
+ defaultValue: n,
260
+ options: this.options ? this.options.map((e) => ({
261
+ id: e.id,
262
+ label: e.label,
263
+ value: `${e.value}`,
264
+ condition: e.condition
265
+ })) : null
269
266
  });
270
267
  case "number":
271
268
  if (this.multiple) {
272
269
  let e;
273
270
  if (Array.isArray(this.defaultValue)) {
274
271
  e = [];
275
- for (const o of this.defaultValue)
276
- typeof o == "number" && e.push(o);
272
+ for (const s of this.defaultValue)
273
+ typeof s == "number" && e.push(s);
277
274
  e.length === 0 && (e = void 0);
278
275
  }
279
- return a.serialize({
280
- ...s,
276
+ return r.serialize({
277
+ ...t,
281
278
  type: "number",
282
279
  multiple: !0,
283
280
  defaultValue: e,
284
- options: u((o) => Number(o))
281
+ options: this.options ? this.options.map((s) => ({
282
+ id: s.id,
283
+ label: s.label,
284
+ value: Number(s.value),
285
+ condition: s.condition
286
+ })) : null
285
287
  });
286
288
  }
287
- return a.serialize({
288
- ...s,
289
+ return r.serialize({
290
+ ...t,
289
291
  type: "number",
290
292
  multiple: !1,
291
293
  defaultValue: d,
292
- options: u((e) => Number(e))
294
+ options: this.options ? this.options.map((e) => ({
295
+ id: e.id,
296
+ label: e.label,
297
+ value: Number(e.value),
298
+ condition: e.condition
299
+ })) : null
293
300
  });
294
301
  case "boolean":
295
302
  if (this.multiple) {
296
303
  let e;
297
304
  if (Array.isArray(this.defaultValue)) {
298
305
  e = [];
299
- for (const o of this.defaultValue)
300
- typeof o == "boolean" && e.push(o);
306
+ for (const s of this.defaultValue)
307
+ typeof s == "boolean" && e.push(s);
301
308
  e.length === 0 && (e = void 0);
302
309
  }
303
- return a.serialize({
304
- ...s,
310
+ return r.serialize({
311
+ ...t,
305
312
  type: "boolean",
306
313
  multiple: !0,
307
314
  defaultValue: e,
308
- options: u((o) => !!o)
315
+ options: this.options ? this.options.map((s) => ({
316
+ id: s.id,
317
+ label: s.label,
318
+ value: !!s.value,
319
+ condition: s.condition
320
+ })) : null
309
321
  });
310
322
  }
311
- return a.serialize({
312
- ...s,
323
+ return r.serialize({
324
+ ...t,
313
325
  type: "boolean",
314
326
  multiple: !1,
315
- defaultValue: N,
316
- options: u((e) => !!e)
327
+ defaultValue: f,
328
+ options: this.options ? this.options.map((e) => ({
329
+ id: e.id,
330
+ label: e.label,
331
+ value: !!e.value,
332
+ condition: e.condition
333
+ })) : null
317
334
  });
318
335
  case "object":
319
- return this.multiple ? a.serialize({
320
- ...s,
336
+ return this.multiple ? r.serialize({
337
+ ...t,
321
338
  type: "object",
322
339
  multiple: !0,
323
340
  defaultValue: this.defaultValue,
324
- options: u((e) => e)
325
- }) : a.serialize({
326
- ...s,
341
+ options: this.options ? this.options.map((e) => ({
342
+ id: e.id,
343
+ label: e.label,
344
+ description: e.description,
345
+ value: e.value,
346
+ condition: e.condition
347
+ })) : null
348
+ }) : r.serialize({
349
+ ...t,
327
350
  type: "object",
328
351
  multiple: !1,
329
352
  defaultValue: this.defaultValue,
330
- options: u((e) => e)
353
+ options: this.options ? this.options.map((e) => ({
354
+ id: e.id,
355
+ label: e.label,
356
+ description: e.description,
357
+ value: e.value,
358
+ condition: e.condition
359
+ })) : null
331
360
  });
332
361
  default:
333
362
  throw new Error("Unsupported field type");
334
363
  }
335
364
  }
336
- }), w = (i) => {
337
- const n = [], s = [], t = [], d = [], N = [], u = i.condition ?? i.decide;
365
+ }), E = (i) => {
366
+ const o = [], t = [], n = [], d = [], f = [];
338
367
  return {
339
368
  id: i.id,
340
369
  component: i.component,
341
370
  name: i.name,
342
371
  initializeOpen: i.initializeOpen,
343
- condition: u,
344
- // eslint-disable-next-line sonarjs/deprecation -- kept for serialization backwards compatibility
345
- decide: i.decide,
372
+ condition: i.condition,
346
373
  targets: i.targets,
347
- steps: n,
348
- nodes: s,
349
- edges: t,
350
- fields: N,
374
+ steps: o,
375
+ nodes: t,
376
+ edges: n,
377
+ fields: f,
351
378
  conditionals: d,
352
- addStep(e, o) {
353
- let r = o?.node;
354
- this.nodes.length === 0 && (r = p({ type: "origin" }, this), this.nodes.push(r));
355
- const l = "serialize" in e ? e : g(e, this);
356
- if (r) {
357
- if (!l.node)
379
+ addStep(e, s) {
380
+ let l = s?.node;
381
+ this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
382
+ const a = "serialize" in e ? e : z(e, this);
383
+ if (l) {
384
+ if (!a.node)
358
385
  throw new Error("todo no node");
359
- const c = h(
360
- { sourceNode: r, destinationNode: l.node, sourceNodeHandle: null },
386
+ const u = c(
387
+ { sourceNode: l, destinationNode: a.node, sourceNodeHandle: null },
361
388
  this
362
389
  );
363
- this.edges.push(c);
390
+ this.edges.push(u);
364
391
  }
365
- return l.fields.length > 0 && l.fields.forEach((c) => {
366
- this.fields.includes(c) || this.fields.push(c);
367
- }), this.steps.includes(l) || (this.steps.push(l), l.node && this.nodes.push(l.node)), l;
392
+ return a.fields.length > 0 && a.fields.forEach((u) => {
393
+ this.fields.includes(u) || this.fields.push(u);
394
+ }), this.steps.includes(a) || (this.steps.push(a), a.node && this.nodes.push(a.node)), a;
368
395
  },
369
- addAction(e, o) {
370
- let r = o?.node;
371
- this.nodes.length === 0 && (r = p({ type: "origin" }, this), this.nodes.push(r));
372
- const l = "serialize" in e ? e : z(e, this);
373
- if (r) {
374
- const c = h(
375
- { sourceNode: r, destinationNode: l, sourceNodeHandle: null },
396
+ addAction(e, s) {
397
+ let l = s?.node;
398
+ this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
399
+ const a = "serialize" in e ? e : y(e, this);
400
+ if (l) {
401
+ const u = c(
402
+ { sourceNode: l, destinationNode: a, sourceNodeHandle: null },
376
403
  this
377
404
  );
378
- this.edges.push(c);
405
+ this.edges.push(u);
379
406
  }
380
- return this.nodes.push(l), l;
407
+ return this.nodes.push(a), a;
381
408
  },
382
- addConditional(e, o) {
383
- let r = o?.node;
384
- this.nodes.length === 0 && (r = p({ type: "origin" }, this), this.nodes.push(r));
385
- const l = "serialize" in e ? e : b(e, this);
386
- if (r) {
387
- if (!l.node)
409
+ addConditional(e, s) {
410
+ let l = s?.node;
411
+ this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
412
+ const a = "serialize" in e ? e : g(e, this);
413
+ if (l) {
414
+ if (!a.node)
388
415
  throw new Error("todo no node");
389
- const c = h(
390
- { sourceNode: r, destinationNode: l.node, sourceNodeHandle: null },
416
+ const u = c(
417
+ { sourceNode: l, destinationNode: a.node, sourceNodeHandle: null },
391
418
  this
392
419
  );
393
- this.edges.push(c);
420
+ this.edges.push(u);
394
421
  }
395
- return this.conditionals.includes(l) || (this.conditionals.push(l), l.node && this.nodes.push(l.node)), l;
422
+ return this.conditionals.includes(a) || (this.conditionals.push(a), a.node && this.nodes.push(a.node)), a;
396
423
  },
397
- addExperience(e, o) {
398
- let r = o?.node;
399
- this.nodes.length === 0 && (r = p({ type: "origin" }, this), this.nodes.push(r));
400
- const l = p(
424
+ addExperience(e, s) {
425
+ let l = s?.node;
426
+ this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
427
+ const a = p(
401
428
  { type: "experience", experience: e },
402
429
  this
403
430
  );
404
- if (this.nodes.push(l), r) {
405
- const c = h(
406
- { sourceNode: r, destinationNode: l, sourceNodeHandle: null },
431
+ if (this.nodes.push(a), l) {
432
+ const u = c(
433
+ { sourceNode: l, destinationNode: a, sourceNodeHandle: null },
407
434
  this
408
435
  );
409
- this.edges.push(c);
436
+ this.edges.push(u);
410
437
  }
411
438
  return e;
412
439
  },
413
- addField(e, o) {
414
- const r = "serialize" in e ? e : y(e);
415
- return o && o.fields.push(r), this.fields.includes(r) || this.fields.push(r), r;
440
+ addField(e, s) {
441
+ const l = "serialize" in e ? e : N(e);
442
+ return s && s.fields.push(l), this.fields.includes(l) || this.fields.push(l), l;
416
443
  },
417
444
  serialize() {
418
- return a.serialize({
445
+ return r.serialize({
419
446
  id: this.id,
420
447
  component: this.component,
421
448
  name: this.name,
422
449
  initializeOpen: this.initializeOpen,
423
- // eslint-disable-next-line sonarjs/deprecation -- backwards compatibility: `decide` is deprecated but still supported
424
- condition: this.condition ?? this.decide,
425
- // eslint-disable-next-line sonarjs/deprecation -- kept for serialization backwards compatibility
426
- decide: this.decide,
450
+ condition: this.condition,
427
451
  targets: this.targets,
428
- steps: this.steps.map((e) => a.deserialize(e.serialize())),
429
- nodes: this.nodes.map((e) => a.deserialize(e.serialize())),
430
- edges: this.edges.map((e) => a.deserialize(e.serialize())),
452
+ steps: this.steps.map((e) => r.deserialize(e.serialize())),
453
+ nodes: this.nodes.map((e) => r.deserialize(e.serialize())),
454
+ edges: this.edges.map((e) => r.deserialize(e.serialize())),
431
455
  conditionals: this.conditionals.map(
432
- (e) => a.deserialize(e.serialize())
456
+ (e) => r.deserialize(e.serialize())
433
457
  ),
434
- fields: this.fields.map((e) => a.deserialize(e.serialize()))
458
+ fields: this.fields.map((e) => r.deserialize(e.serialize()))
435
459
  });
436
460
  }
437
461
  };
438
462
  };
439
463
  export {
440
- b as createConditional,
441
- h as createEdge,
442
- w as createExperience,
443
- V as createExperiencePlugin,
444
- y as createField,
464
+ g as createConditional,
465
+ c as createEdge,
466
+ E as createExperience,
467
+ x as createExperiencePlugin,
468
+ N as createField,
445
469
  p as createNode,
446
- E as createStep,
447
- a as serialization
470
+ V as createStep,
471
+ r as serialization
448
472
  };