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

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