@picked/client 0.0.48 → 0.0.49

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