@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.
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/esm/index.js +496 -461
- package/dist/esm/plugins/create-experience/index.js +277 -346
- package/dist/types/entities/field/field.d.ts +28 -135
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/picked.d.ts +2 -0
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +14 -30
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,112 +1,113 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
const
|
|
3
|
-
serialize(
|
|
4
|
-
return JSON.stringify(
|
|
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(
|
|
7
|
-
return JSON.parse(
|
|
6
|
+
deserialize(e) {
|
|
7
|
+
return JSON.parse(e);
|
|
8
8
|
}
|
|
9
|
-
},
|
|
9
|
+
}, v = (e) => ({
|
|
10
10
|
name: "create-experience",
|
|
11
|
-
setup: (
|
|
11
|
+
setup: (n) => {
|
|
12
12
|
Promise.all(
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
d.
|
|
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((
|
|
20
|
-
throw new Error(`Failed to create experiences: ${
|
|
20
|
+
).catch((d) => {
|
|
21
|
+
throw new Error(`Failed to create experiences: ${d}`);
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
}),
|
|
24
|
-
id:
|
|
24
|
+
}), z = (e, n) => ({
|
|
25
|
+
id: N("node"),
|
|
25
26
|
position: [0, 0],
|
|
26
|
-
experience:
|
|
27
|
+
experience: n,
|
|
27
28
|
type: "action",
|
|
28
|
-
action:
|
|
29
|
-
addNext(
|
|
30
|
-
if (!
|
|
31
|
-
const
|
|
32
|
-
{ sourceNode: this, destinationNode:
|
|
33
|
-
|
|
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
|
-
|
|
36
|
+
n.edges.push(r);
|
|
36
37
|
},
|
|
37
|
-
onSuccess(
|
|
38
|
-
if (!
|
|
39
|
-
const
|
|
40
|
-
{ sourceNode: this, destinationNode:
|
|
41
|
-
|
|
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
|
-
|
|
44
|
+
n.edges.push(r);
|
|
44
45
|
},
|
|
45
|
-
onFail(
|
|
46
|
-
if (!
|
|
47
|
-
const
|
|
48
|
-
{ sourceNode: this, destinationNode:
|
|
49
|
-
|
|
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
|
-
|
|
52
|
+
n.edges.push(r);
|
|
52
53
|
},
|
|
53
54
|
serialize() {
|
|
54
|
-
return
|
|
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
|
-
}),
|
|
62
|
-
id:
|
|
63
|
-
label:
|
|
64
|
-
fields:
|
|
65
|
-
addField(
|
|
66
|
-
const
|
|
67
|
-
return this.fields?.includes(
|
|
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
|
-
}),
|
|
70
|
-
const
|
|
71
|
-
id:
|
|
72
|
-
label:
|
|
73
|
-
experience:
|
|
74
|
-
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(
|
|
77
|
-
return this.experience.addStep(
|
|
77
|
+
nextStep(s) {
|
|
78
|
+
return this.experience.addStep(s, this);
|
|
78
79
|
},
|
|
79
|
-
nextConditional(
|
|
80
|
-
return this.experience.addConditional(
|
|
80
|
+
nextConditional(s) {
|
|
81
|
+
return this.experience.addConditional(s, this);
|
|
81
82
|
},
|
|
82
|
-
addNextExperience(
|
|
83
|
-
return this.experience.addExperience(
|
|
83
|
+
addNextExperience(s) {
|
|
84
|
+
return this.experience.addExperience(s, this);
|
|
84
85
|
},
|
|
85
|
-
addField(
|
|
86
|
-
return this.experience.addField(
|
|
86
|
+
addField(s) {
|
|
87
|
+
return this.experience.addField(s, this);
|
|
87
88
|
},
|
|
88
89
|
serialize() {
|
|
89
|
-
return
|
|
90
|
+
return a.serialize({
|
|
90
91
|
id: this.id,
|
|
91
92
|
label: this.label,
|
|
92
|
-
fieldIds: this.fields.map((
|
|
93
|
+
fieldIds: this.fields.map((s) => s.id)
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
|
-
return
|
|
97
|
-
},
|
|
98
|
-
const
|
|
99
|
-
id:
|
|
100
|
-
position:
|
|
101
|
-
experience:
|
|
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 (
|
|
104
|
-
const
|
|
105
|
-
...
|
|
104
|
+
if (e.type === "step") {
|
|
105
|
+
const r = {
|
|
106
|
+
...d,
|
|
106
107
|
type: "step",
|
|
107
|
-
connectedStep:
|
|
108
|
+
connectedStep: e.step,
|
|
108
109
|
serialize() {
|
|
109
|
-
return
|
|
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
|
|
119
|
+
return r.connectedStep.node = r, r;
|
|
119
120
|
}
|
|
120
|
-
if (
|
|
121
|
-
const
|
|
122
|
-
...
|
|
121
|
+
if (e.type === "conditional") {
|
|
122
|
+
const r = {
|
|
123
|
+
...d,
|
|
123
124
|
type: "conditional",
|
|
124
|
-
connectedConditional:
|
|
125
|
+
connectedConditional: e.conditional,
|
|
125
126
|
serialize() {
|
|
126
|
-
return
|
|
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
|
|
135
|
+
return r.connectedConditional.node = r, r;
|
|
135
136
|
}
|
|
136
|
-
return
|
|
137
|
-
...
|
|
137
|
+
return e.type === "experience" ? {
|
|
138
|
+
...d,
|
|
138
139
|
type: "experience",
|
|
139
|
-
connectedExperience:
|
|
140
|
+
connectedExperience: e.experience,
|
|
140
141
|
serialize() {
|
|
141
|
-
return
|
|
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
|
-
...
|
|
150
|
+
...d,
|
|
150
151
|
type: "origin",
|
|
151
152
|
serialize() {
|
|
152
|
-
return
|
|
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 = (
|
|
160
|
-
id:
|
|
161
|
-
sourceNode:
|
|
162
|
-
sourceNodeHandle:
|
|
163
|
-
destinationNode:
|
|
164
|
-
experience:
|
|
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
|
|
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
|
-
}),
|
|
174
|
-
const
|
|
175
|
-
id:
|
|
176
|
-
condition:
|
|
174
|
+
}), x = (e, n) => {
|
|
175
|
+
const d = {
|
|
176
|
+
id: N("conditional"),
|
|
177
|
+
condition: e.condition,
|
|
177
178
|
node: null,
|
|
178
|
-
experience:
|
|
179
|
-
addTrue(
|
|
180
|
-
if (!this.node || !
|
|
179
|
+
experience: n,
|
|
180
|
+
addTrue(s) {
|
|
181
|
+
if (!this.node || !s.node)
|
|
181
182
|
throw new Error("todo no node");
|
|
182
|
-
const
|
|
183
|
-
{ sourceNode: this.node, destinationNode:
|
|
183
|
+
const r = u(
|
|
184
|
+
{ sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "true" },
|
|
184
185
|
this.experience
|
|
185
186
|
);
|
|
186
|
-
this.experience.edges.push(
|
|
187
|
+
this.experience.edges.push(r);
|
|
187
188
|
},
|
|
188
|
-
addFalse(
|
|
189
|
-
if (!this.node || !
|
|
189
|
+
addFalse(s) {
|
|
190
|
+
if (!this.node || !s.node)
|
|
190
191
|
throw new Error("todo no node");
|
|
191
|
-
const
|
|
192
|
-
{ sourceNode: this.node, destinationNode:
|
|
192
|
+
const r = u(
|
|
193
|
+
{ sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "false" },
|
|
193
194
|
this.experience
|
|
194
195
|
);
|
|
195
|
-
this.experience.edges.push(
|
|
196
|
+
this.experience.edges.push(r);
|
|
196
197
|
},
|
|
197
198
|
serialize() {
|
|
198
|
-
return
|
|
199
|
+
return a.serialize({
|
|
199
200
|
id: this.id,
|
|
200
201
|
condition: this.condition
|
|
201
202
|
});
|
|
202
203
|
}
|
|
203
204
|
};
|
|
204
|
-
return
|
|
205
|
-
}
|
|
206
|
-
|
|
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:
|
|
209
|
-
name:
|
|
210
|
-
type:
|
|
211
|
-
label:
|
|
212
|
-
placeholder:
|
|
213
|
-
description:
|
|
214
|
-
helpText:
|
|
215
|
-
defaultValue:
|
|
216
|
-
multiple:
|
|
217
|
-
validation:
|
|
218
|
-
condition:
|
|
219
|
-
required:
|
|
220
|
-
options:
|
|
221
|
-
...
|
|
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:
|
|
233
|
+
policies: e.policies,
|
|
224
234
|
serialize() {
|
|
225
|
-
const
|
|
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
|
-
},
|
|
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
|
|
256
|
+
let i;
|
|
241
257
|
if (Array.isArray(this.defaultValue)) {
|
|
242
|
-
|
|
243
|
-
for (const
|
|
244
|
-
typeof
|
|
245
|
-
|
|
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
|
|
248
|
-
...
|
|
263
|
+
return a.serialize({
|
|
264
|
+
...s,
|
|
249
265
|
type: "text",
|
|
250
266
|
multiple: !0,
|
|
251
|
-
defaultValue:
|
|
252
|
-
options:
|
|
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
|
|
269
|
-
...
|
|
271
|
+
return a.serialize({
|
|
272
|
+
...s,
|
|
270
273
|
type: "text",
|
|
271
274
|
multiple: !1,
|
|
272
|
-
defaultValue:
|
|
273
|
-
options:
|
|
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
|
-
|
|
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
|
|
287
|
+
let i;
|
|
291
288
|
if (Array.isArray(this.defaultValue)) {
|
|
292
|
-
|
|
293
|
-
for (const
|
|
294
|
-
typeof
|
|
295
|
-
|
|
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
|
|
298
|
-
...
|
|
294
|
+
return a.serialize({
|
|
295
|
+
...s,
|
|
299
296
|
type: "number",
|
|
300
297
|
multiple: !0,
|
|
301
|
-
defaultValue:
|
|
302
|
-
options:
|
|
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
|
|
319
|
-
...
|
|
302
|
+
return a.serialize({
|
|
303
|
+
...s,
|
|
320
304
|
type: "number",
|
|
321
305
|
multiple: !1,
|
|
322
|
-
defaultValue:
|
|
323
|
-
options:
|
|
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
|
-
|
|
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
|
|
318
|
+
let i;
|
|
341
319
|
if (Array.isArray(this.defaultValue)) {
|
|
342
|
-
|
|
343
|
-
for (const
|
|
344
|
-
typeof
|
|
345
|
-
|
|
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
|
|
348
|
-
...
|
|
325
|
+
return a.serialize({
|
|
326
|
+
...s,
|
|
349
327
|
type: "boolean",
|
|
350
328
|
multiple: !0,
|
|
351
|
-
defaultValue:
|
|
352
|
-
options:
|
|
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
|
|
369
|
-
...
|
|
333
|
+
return a.serialize({
|
|
334
|
+
...s,
|
|
370
335
|
type: "boolean",
|
|
371
336
|
multiple: !1,
|
|
372
|
-
defaultValue:
|
|
373
|
-
options:
|
|
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
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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:
|
|
395
|
-
|
|
396
|
-
|
|
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:
|
|
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
|
-
},
|
|
438
|
-
const
|
|
368
|
+
}, w = (e) => {
|
|
369
|
+
const n = [], d = [], s = [], r = [], h = [], p = e.condition ?? e.decide;
|
|
439
370
|
return {
|
|
440
|
-
id:
|
|
441
|
-
component:
|
|
442
|
-
name:
|
|
443
|
-
initializeOpen:
|
|
444
|
-
condition:
|
|
445
|
-
decide:
|
|
446
|
-
targets:
|
|
447
|
-
steps:
|
|
448
|
-
nodes:
|
|
449
|
-
edges:
|
|
450
|
-
fields:
|
|
451
|
-
conditionals:
|
|
452
|
-
addStep(
|
|
453
|
-
let
|
|
454
|
-
this.nodes.length === 0 && (
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
if (!
|
|
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:
|
|
391
|
+
{ sourceNode: o, destinationNode: l.node, sourceNodeHandle: null },
|
|
461
392
|
this
|
|
462
393
|
);
|
|
463
394
|
this.edges.push(c);
|
|
464
395
|
}
|
|
465
|
-
return
|
|
396
|
+
return l.fields.length > 0 && l.fields.forEach((c) => {
|
|
466
397
|
this.fields.includes(c) || this.fields.push(c);
|
|
467
|
-
}), this.steps.includes(
|
|
398
|
+
}), this.steps.includes(l) || (this.steps.push(l), l.node && this.nodes.push(l.node)), l;
|
|
468
399
|
},
|
|
469
|
-
addAction(
|
|
470
|
-
let
|
|
471
|
-
this.nodes.length === 0 && (
|
|
472
|
-
const
|
|
473
|
-
if (
|
|
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:
|
|
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(
|
|
411
|
+
return this.nodes.push(l), l;
|
|
481
412
|
},
|
|
482
|
-
addConditional(
|
|
483
|
-
let
|
|
484
|
-
this.nodes.length === 0 && (
|
|
485
|
-
const
|
|
486
|
-
if (
|
|
487
|
-
if (!
|
|
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:
|
|
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(
|
|
426
|
+
return this.conditionals.includes(l) || (this.conditionals.push(l), l.node && this.nodes.push(l.node)), l;
|
|
496
427
|
},
|
|
497
|
-
addExperience(
|
|
498
|
-
let
|
|
499
|
-
this.nodes.length === 0 && (
|
|
500
|
-
const
|
|
501
|
-
{ type: "experience", experience:
|
|
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(
|
|
435
|
+
if (this.nodes.push(l), o) {
|
|
505
436
|
const c = u(
|
|
506
|
-
{ sourceNode:
|
|
437
|
+
{ sourceNode: o, destinationNode: l, sourceNodeHandle: null },
|
|
507
438
|
this
|
|
508
439
|
);
|
|
509
440
|
this.edges.push(c);
|
|
510
441
|
}
|
|
511
|
-
return
|
|
442
|
+
return t;
|
|
512
443
|
},
|
|
513
|
-
addField(
|
|
514
|
-
const
|
|
515
|
-
return
|
|
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
|
|
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((
|
|
527
|
-
nodes: this.nodes.map((
|
|
528
|
-
edges: this.edges.map((
|
|
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
|
-
(
|
|
461
|
+
(t) => a.deserialize(t.serialize())
|
|
531
462
|
),
|
|
532
|
-
fields: this.fields.map((
|
|
463
|
+
fields: this.fields.map((t) => a.deserialize(t.serialize()))
|
|
533
464
|
});
|
|
534
465
|
}
|
|
535
466
|
};
|
|
536
467
|
};
|
|
537
468
|
export {
|
|
538
|
-
|
|
469
|
+
x as createConditional,
|
|
539
470
|
u as createEdge,
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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
|
};
|