@picked/client 0.0.1-dev.1772493269328 → 0.0.1-dev.1773364848747

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