@picked/client 0.0.1-dev.1770181472896 → 0.0.1-dev.1770759602712

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