@picked/client 0.0.1-dev.1774231221701 → 0.0.1-dev.1774912386475

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/{api-BEXzPJHZ.cjs → api-B-wGEgt8.cjs} +1 -1
  2. package/dist/{api-oudcFuUX.js → api-DwERBrAZ.js} +1 -1
  3. package/dist/cjs/form/index.js +1 -1
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/create-experience/index.js +1 -1
  6. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  7. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/web-components/index.js +1 -1
  9. package/dist/cjs/server/index.js +1 -1
  10. package/dist/esm/form/index.js +128 -84
  11. package/dist/esm/index.js +393 -334
  12. package/dist/esm/plugins/create-experience/index.js +183 -151
  13. package/dist/esm/plugins/dynamic-experiences/index.js +52 -30
  14. package/dist/esm/plugins/responses-browser-storage/index.js +47 -20
  15. package/dist/esm/plugins/web-components/index.js +1 -1
  16. package/dist/esm/server/index.js +1 -1
  17. package/dist/{experience-instance-DZiAwXph.js → experience-instance-CwwrKUI8.js} +50 -46
  18. package/dist/experience-instance-DdFUcVRd.cjs +1 -0
  19. package/dist/{rules-logic-B7vJrWyO.js → rules-logic-BIkBWZmf.js} +4 -2
  20. package/dist/rules-logic-DDxCiq4P.cjs +1 -0
  21. package/dist/types/entities/condition/condition.d.ts +17 -0
  22. package/dist/types/entities/condition/condition.d.ts.map +1 -0
  23. package/dist/types/entities/experience/experience.d.ts +40 -35
  24. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  25. package/dist/types/entities/experience-instance/experience-instance.d.ts +21 -2
  26. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  27. package/dist/types/entities/field/field.d.ts +13 -2
  28. package/dist/types/entities/field/field.d.ts.map +1 -1
  29. package/dist/types/entities/response/response-validation.d.ts +76 -0
  30. package/dist/types/entities/response/response-validation.d.ts.map +1 -0
  31. package/dist/types/entities/response/response.d.ts +24 -17
  32. package/dist/types/entities/response/response.d.ts.map +1 -1
  33. package/dist/types/entities/step/step.d.ts +36 -0
  34. package/dist/types/entities/step/step.d.ts.map +1 -0
  35. package/dist/types/form/build-responses.d.ts +12 -9
  36. package/dist/types/form/build-responses.d.ts.map +1 -1
  37. package/dist/types/form/create-field-evaluator.d.ts +11 -3
  38. package/dist/types/form/create-field-evaluator.d.ts.map +1 -1
  39. package/dist/types/form/create-field-validation.d.ts +21 -6
  40. package/dist/types/form/create-field-validation.d.ts.map +1 -1
  41. package/dist/types/form/create-form.d.ts +42 -11
  42. package/dist/types/form/create-form.d.ts.map +1 -1
  43. package/dist/types/form/create-submit-pipeline.d.ts +21 -9
  44. package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
  45. package/dist/types/form/get-step-fields.d.ts +13 -0
  46. package/dist/types/form/get-step-fields.d.ts.map +1 -1
  47. package/dist/types/index.d.ts +2 -0
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/dist/types/logic-engine.d.ts +10 -2
  50. package/dist/types/logic-engine.d.ts.map +1 -1
  51. package/dist/types/picked.d.ts +68 -32
  52. package/dist/types/picked.d.ts.map +1 -1
  53. package/dist/types/plugins/create-experience/create-experience.d.ts +51 -29
  54. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  55. package/dist/types/plugins/create-experience/index.d.ts +2 -2
  56. package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
  57. package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
  58. package/dist/types/plugins/create-experience/serialization.d.ts +1 -0
  59. package/dist/types/plugins/create-experience/serialization.d.ts.map +1 -1
  60. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +21 -4
  61. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  62. package/dist/types/plugins/dynamic-experiences/types.d.ts +41 -0
  63. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  64. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  65. package/dist/types/utils/events.d.ts +1 -1
  66. package/dist/types/utils/events.d.ts.map +1 -1
  67. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +3 -0
  68. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -0
  69. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +10 -6
  70. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  71. package/dist/types/utils/nodes.d.ts +74 -2
  72. package/dist/types/utils/nodes.d.ts.map +1 -1
  73. package/dist/types/utils/rules-logic.d.ts +31 -0
  74. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  75. package/package.json +32 -6
  76. package/dist/experience-instance-Ddk4Jktn.cjs +0 -1
  77. package/dist/rules-logic-CXr4wXcG.cjs +0 -1
  78. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +0 -3
  79. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +0 -1
@@ -12,8 +12,14 @@ var t = {
12
12
  setup: (n) => {
13
13
  e.experiences.forEach((e) => {
14
14
  let r = e.serialize(), i = t.deserialize(r);
15
- i.component = e.component, n.registerExperience(i), i.fields.forEach((e) => {
15
+ i.component = e.component;
16
+ let { steps: a, conditions: o, fields: s, ...c } = i;
17
+ n.registerExperience(c), s.forEach((e) => {
16
18
  n.registerField(e);
19
+ }), a.forEach((e) => {
20
+ n.registerStep(e);
21
+ }), o.forEach((e) => {
22
+ n.registerCondition(e);
17
23
  });
18
24
  });
19
25
  }
@@ -56,26 +62,36 @@ var t = {
56
62
  action: this.action
57
63
  });
58
64
  }
59
- }), i = (t) => ({
60
- id: t.id ?? e("step"),
61
- label: t.label,
62
- fields: t.fields ?? [],
63
- addField(e) {
64
- let t = "serialize" in e ? e : l(e);
65
- return this.fields.includes(t) || this.fields.push(t), t;
66
- }
67
- }), a = (n, r) => {
68
- let i = {
69
- id: n.id ?? e("step"),
70
- label: n.label,
65
+ }), i = (t) => {
66
+ let n = t.name, r = t.id ?? e("step");
67
+ return {
68
+ id: r,
69
+ name: n,
70
+ key: t.key ?? r,
71
+ label: n,
72
+ fields: t.fields ?? [],
73
+ addField(e) {
74
+ let t = "serialize" in e ? e : l(e);
75
+ return this.fields.includes(t) || this.fields.push(t), t;
76
+ }
77
+ };
78
+ }, a = (n, r) => {
79
+ let i = n.name, a = n.id ?? e("step"), s = {
80
+ id: a,
81
+ name: i,
82
+ key: n.key ?? a,
83
+ label: i,
71
84
  experience: r,
72
85
  fields: n.fields ?? [],
73
86
  node: null,
74
87
  nextStep(e) {
75
88
  return this.experience.addStep(e, this);
76
89
  },
90
+ nextCondition(e) {
91
+ return this.experience.addCondition(e, this);
92
+ },
77
93
  nextConditional(e) {
78
- return this.experience.addConditional(e, this);
94
+ return this.nextCondition(e);
79
95
  },
80
96
  addNextExperience(e) {
81
97
  return this.experience.addExperience(e, this);
@@ -86,15 +102,17 @@ var t = {
86
102
  serialize() {
87
103
  return t.serialize({
88
104
  id: this.id,
105
+ key: this.key,
106
+ name: this.name,
89
107
  label: this.label,
90
108
  fieldIds: this.fields.map((e) => e.id)
91
109
  });
92
110
  }
93
111
  };
94
112
  return o({
95
- step: i,
113
+ step: s,
96
114
  type: "step"
97
- }, r), i;
115
+ }, r), s;
98
116
  }, o = (n, r) => {
99
117
  let i = {
100
118
  id: e("node"),
@@ -110,26 +128,27 @@ var t = {
110
128
  id: this.id,
111
129
  type: this.type,
112
130
  stepId: this.connectedStep.id,
131
+ name: this.connectedStep.name,
113
132
  label: this.connectedStep.label
114
133
  });
115
134
  }
116
135
  };
117
136
  return e.connectedStep.node = e, e;
118
137
  }
119
- if (n.type === "conditional") {
138
+ if (n.type === "condition") {
120
139
  let e = {
121
140
  ...i,
122
- type: "conditional",
123
- connectedConditional: n.conditional,
141
+ type: "condition",
142
+ connectedCondition: n.condition,
124
143
  serialize() {
125
144
  return t.serialize({
126
145
  id: this.id,
127
146
  type: this.type,
128
- conditionalId: this.connectedConditional.id
147
+ conditionId: this.connectedCondition.id
129
148
  });
130
149
  }
131
150
  };
132
- return e.connectedConditional.node = e, e;
151
+ return e.connectedCondition.node = e, e;
133
152
  }
134
153
  return n.type === "experience" ? {
135
154
  ...i,
@@ -167,10 +186,12 @@ var t = {
167
186
  });
168
187
  }
169
188
  }), c = (n, r) => {
170
- let i = {
171
- id: e("conditional"),
189
+ let i = e("conditional"), a = n.name ?? n.label ?? i, c = {
190
+ id: i,
191
+ key: n.key ?? i,
192
+ name: a,
172
193
  label: n.label,
173
- condition: n.condition,
194
+ logic: n.condition,
174
195
  node: null,
175
196
  experience: r,
176
197
  addTrue(e) {
@@ -194,59 +215,77 @@ var t = {
194
215
  serialize() {
195
216
  return t.serialize({
196
217
  id: this.id,
197
- label: this.label,
198
- condition: this.condition
218
+ key: this.key,
219
+ name: this.name,
220
+ logic: this.logic
199
221
  });
200
222
  }
201
223
  };
202
224
  return o({
203
- conditional: i,
204
- type: "conditional"
205
- }, r), i;
206
- }, l = (n) => ({
207
- id: n.id,
208
- name: n.name,
209
- type: n.type,
210
- label: n.label,
211
- placeholder: n.placeholder,
212
- description: n.description,
213
- helpText: n.helpText,
214
- defaultValue: n.defaultValue ?? null,
215
- multiple: n.multiple,
216
- validation: n.validation ?? {},
217
- condition: n.condition,
218
- required: n.required,
219
- options: n.options?.map((t) => ({
220
- id: "id" in t ? t.id : e("option"),
221
- ...t
222
- })) ?? null,
223
- policies: n.policies,
224
- serialize() {
225
- let e = {
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
- }, n = typeof this.defaultValue == "string" ? this.defaultValue : void 0, r = typeof this.defaultValue == "number" ? this.defaultValue : void 0, i = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
237
- switch (this.type) {
238
- case "text":
239
- if (this.multiple) {
240
- let n;
241
- if (Array.isArray(this.defaultValue)) {
242
- n = [];
243
- for (let e of this.defaultValue) typeof e == "string" && n.push(e);
244
- n.length === 0 && (n = void 0);
225
+ condition: c,
226
+ type: "condition"
227
+ }, r), c;
228
+ }, l = (n) => {
229
+ let r = n.id ?? e("field");
230
+ return {
231
+ id: r,
232
+ key: n.key ?? r,
233
+ name: n.name,
234
+ type: n.type,
235
+ label: n.label,
236
+ placeholder: n.placeholder,
237
+ description: n.description,
238
+ helpText: n.helpText,
239
+ defaultValue: n.defaultValue ?? null,
240
+ multiple: n.multiple,
241
+ validation: n.validation ?? {},
242
+ condition: n.condition,
243
+ required: n.required,
244
+ options: n.options?.map((t) => ({
245
+ id: "id" in t ? t.id : e("option"),
246
+ ...t
247
+ })) ?? null,
248
+ policies: n.policies,
249
+ serialize() {
250
+ let e = {
251
+ id: this.id,
252
+ key: this.key,
253
+ name: this.name,
254
+ label: this.label,
255
+ placeholder: this.placeholder,
256
+ required: this.required,
257
+ description: this.description,
258
+ helpText: this.helpText,
259
+ validation: this.validation,
260
+ condition: this.condition,
261
+ policies: this.policies
262
+ }, n = typeof this.defaultValue == "string" ? this.defaultValue : void 0, r = typeof this.defaultValue == "number" ? this.defaultValue : void 0, i = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
263
+ switch (this.type) {
264
+ case "text":
265
+ if (this.multiple) {
266
+ let n;
267
+ if (Array.isArray(this.defaultValue)) {
268
+ n = [];
269
+ for (let e of this.defaultValue) typeof e == "string" && n.push(e);
270
+ n.length === 0 && (n = void 0);
271
+ }
272
+ return t.serialize({
273
+ ...e,
274
+ type: "text",
275
+ multiple: !0,
276
+ defaultValue: n,
277
+ options: this.options ? this.options.map((e) => ({
278
+ id: e.id,
279
+ label: e.label,
280
+ value: `${e.value}`,
281
+ condition: e.condition
282
+ })) : null
283
+ });
245
284
  }
246
285
  return t.serialize({
247
286
  ...e,
248
287
  type: "text",
249
- multiple: !0,
288
+ multiple: !1,
250
289
  defaultValue: n,
251
290
  options: this.options ? this.options.map((e) => ({
252
291
  id: e.id,
@@ -255,32 +294,32 @@ var t = {
255
294
  condition: e.condition
256
295
  })) : null
257
296
  });
258
- }
259
- return t.serialize({
260
- ...e,
261
- type: "text",
262
- multiple: !1,
263
- defaultValue: n,
264
- options: this.options ? this.options.map((e) => ({
265
- id: e.id,
266
- label: e.label,
267
- value: `${e.value}`,
268
- condition: e.condition
269
- })) : null
270
- });
271
- case "number":
272
- if (this.multiple) {
273
- let n;
274
- if (Array.isArray(this.defaultValue)) {
275
- n = [];
276
- for (let e of this.defaultValue) typeof e == "number" && n.push(e);
277
- n.length === 0 && (n = void 0);
297
+ case "number":
298
+ if (this.multiple) {
299
+ let n;
300
+ if (Array.isArray(this.defaultValue)) {
301
+ n = [];
302
+ for (let e of this.defaultValue) typeof e == "number" && n.push(e);
303
+ n.length === 0 && (n = void 0);
304
+ }
305
+ return t.serialize({
306
+ ...e,
307
+ type: "number",
308
+ multiple: !0,
309
+ defaultValue: n,
310
+ options: this.options ? this.options.map((e) => ({
311
+ id: e.id,
312
+ label: e.label,
313
+ value: Number(e.value),
314
+ condition: e.condition
315
+ })) : null
316
+ });
278
317
  }
279
318
  return t.serialize({
280
319
  ...e,
281
320
  type: "number",
282
- multiple: !0,
283
- defaultValue: n,
321
+ multiple: !1,
322
+ defaultValue: r,
284
323
  options: this.options ? this.options.map((e) => ({
285
324
  id: e.id,
286
325
  label: e.label,
@@ -288,32 +327,32 @@ var t = {
288
327
  condition: e.condition
289
328
  })) : null
290
329
  });
291
- }
292
- return t.serialize({
293
- ...e,
294
- type: "number",
295
- multiple: !1,
296
- defaultValue: r,
297
- options: this.options ? this.options.map((e) => ({
298
- id: e.id,
299
- label: e.label,
300
- value: Number(e.value),
301
- condition: e.condition
302
- })) : null
303
- });
304
- case "boolean":
305
- if (this.multiple) {
306
- let n;
307
- if (Array.isArray(this.defaultValue)) {
308
- n = [];
309
- for (let e of this.defaultValue) typeof e == "boolean" && n.push(e);
310
- n.length === 0 && (n = void 0);
330
+ case "boolean":
331
+ if (this.multiple) {
332
+ let n;
333
+ if (Array.isArray(this.defaultValue)) {
334
+ n = [];
335
+ for (let e of this.defaultValue) typeof e == "boolean" && n.push(e);
336
+ n.length === 0 && (n = void 0);
337
+ }
338
+ return t.serialize({
339
+ ...e,
340
+ type: "boolean",
341
+ multiple: !0,
342
+ defaultValue: n,
343
+ options: this.options ? this.options.map((e) => ({
344
+ id: e.id,
345
+ label: e.label,
346
+ value: !!e.value,
347
+ condition: e.condition
348
+ })) : null
349
+ });
311
350
  }
312
351
  return t.serialize({
313
352
  ...e,
314
353
  type: "boolean",
315
- multiple: !0,
316
- defaultValue: n,
354
+ multiple: !1,
355
+ defaultValue: i,
317
356
  options: this.options ? this.options.map((e) => ({
318
357
  id: e.id,
319
358
  label: e.label,
@@ -321,49 +360,38 @@ var t = {
321
360
  condition: e.condition
322
361
  })) : null
323
362
  });
324
- }
325
- return t.serialize({
363
+ case "object": return this.multiple ? t.serialize({
326
364
  ...e,
327
- type: "boolean",
365
+ type: "object",
366
+ multiple: !0,
367
+ defaultValue: this.defaultValue,
368
+ options: this.options ? this.options.map((e) => ({
369
+ id: e.id,
370
+ label: e.label,
371
+ description: e.description,
372
+ value: e.value,
373
+ condition: e.condition
374
+ })) : null
375
+ }) : t.serialize({
376
+ ...e,
377
+ type: "object",
328
378
  multiple: !1,
329
- defaultValue: i,
379
+ defaultValue: this.defaultValue,
330
380
  options: this.options ? this.options.map((e) => ({
331
381
  id: e.id,
332
382
  label: e.label,
333
- value: !!e.value,
383
+ description: e.description,
384
+ value: e.value,
334
385
  condition: e.condition
335
386
  })) : null
336
387
  });
337
- case "object": return this.multiple ? t.serialize({
338
- ...e,
339
- type: "object",
340
- multiple: !0,
341
- defaultValue: this.defaultValue,
342
- options: this.options ? this.options.map((e) => ({
343
- id: e.id,
344
- label: e.label,
345
- description: e.description,
346
- value: e.value,
347
- condition: e.condition
348
- })) : null
349
- }) : t.serialize({
350
- ...e,
351
- type: "object",
352
- multiple: !1,
353
- defaultValue: this.defaultValue,
354
- options: this.options ? this.options.map((e) => ({
355
- id: e.id,
356
- label: e.label,
357
- description: e.description,
358
- value: e.value,
359
- condition: e.condition
360
- })) : null
361
- });
362
- default: throw Error("Unsupported field type");
388
+ default: throw Error("Unsupported field type");
389
+ }
363
390
  }
364
- }
365
- }), u = (e) => ({
391
+ };
392
+ }, u = (e) => ({
366
393
  id: e.id,
394
+ key: e.key,
367
395
  component: e.component,
368
396
  name: e.name,
369
397
  initializeOpen: e.initializeOpen,
@@ -373,7 +401,7 @@ var t = {
373
401
  nodes: [],
374
402
  edges: [],
375
403
  fields: [],
376
- conditionals: [],
404
+ conditions: [],
377
405
  addStep(e, t) {
378
406
  let n = t?.node;
379
407
  this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
@@ -405,7 +433,7 @@ var t = {
405
433
  }
406
434
  return this.nodes.push(i), i;
407
435
  },
408
- addConditional(e, t) {
436
+ addCondition(e, t) {
409
437
  let n = t?.node;
410
438
  this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
411
439
  let r = "serialize" in e ? e : c(e, this);
@@ -418,7 +446,10 @@ var t = {
418
446
  }, this);
419
447
  this.edges.push(e);
420
448
  }
421
- return this.conditionals.includes(r) || (this.conditionals.push(r), r.node && this.nodes.push(r.node)), r;
449
+ return this.conditions.includes(r) || (this.conditions.push(r), r.node && this.nodes.push(r.node)), r;
450
+ },
451
+ addConditional(e, t) {
452
+ return this.addCondition(e, t);
422
453
  },
423
454
  addExperience(e, t) {
424
455
  let n = t?.node;
@@ -444,6 +475,7 @@ var t = {
444
475
  serialize() {
445
476
  return t.serialize({
446
477
  id: this.id,
478
+ key: this.key,
447
479
  component: this.component,
448
480
  name: this.name,
449
481
  initializeOpen: this.initializeOpen,
@@ -452,10 +484,10 @@ var t = {
452
484
  steps: this.steps.map((e) => t.deserialize(e.serialize())),
453
485
  nodes: this.nodes.map((e) => t.deserialize(e.serialize())),
454
486
  edges: this.edges.map((e) => t.deserialize(e.serialize())),
455
- conditionals: this.conditionals.map((e) => t.deserialize(e.serialize())),
487
+ conditions: this.conditions.map((e) => t.deserialize(e.serialize())),
456
488
  fields: this.fields.map((e) => t.deserialize(e.serialize()))
457
489
  });
458
490
  }
459
491
  });
460
492
  //#endregion
461
- export { c as createConditional, s as createEdge, u as createExperience, n as createExperiencePlugin, l as createField, o as createNode, i as createStep, t as serialization };
493
+ export { c as createCondition, s as createEdge, u as createExperience, n as createExperiencePlugin, l as createField, o as createNode, i as createStep };
@@ -1,5 +1,5 @@
1
1
  import "../../../logger-6z_gb4rA.js";
2
- import { i as e, t } from "../../../api-oudcFuUX.js";
2
+ import { i as e, t } from "../../../api-DwERBrAZ.js";
3
3
  //#region src/plugins/dynamic-experiences/hash.ts
4
4
  function n(e) {
5
5
  let t = 2166136261;
@@ -15,16 +15,38 @@ function i(e, t) {
15
15
  //#endregion
16
16
  //#region src/plugins/dynamic-experiences/plugin.ts
17
17
  function a(e) {
18
- return typeof e != "object" || !e || !("id" in e && "name" in e && "enabled" in e && "weight" in e && "version" in e) ? !1 : typeof e.id == "string" && typeof e.name == "string" && typeof e.enabled == "boolean" && typeof e.weight == "number" && typeof e.version == "number";
18
+ return typeof e == "object" && !!e && "features" in e && Array.isArray(e.features);
19
19
  }
20
- function o(e) {
21
- return typeof e != "object" || !e || !("features" in e) || !Array.isArray(e.features) ? !1 : e.features.every(a);
20
+ function o(e, t) {
21
+ for (let n of t.conditions) e.registerCondition(n);
22
22
  }
23
- function s(e) {
23
+ function s(e, t) {
24
+ e.registerExperience({
25
+ id: t.id,
26
+ key: t.key,
27
+ name: t.name,
28
+ targets: t.targets,
29
+ nodes: t.nodes,
30
+ edges: t.edges,
31
+ condition: t.condition,
32
+ initializeOpen: t.initializeOpen,
33
+ componentName: t.componentName
34
+ });
35
+ }
36
+ function c(e, t) {
37
+ for (let n of t.fields) e.registerField(n);
38
+ }
39
+ function l(e, t) {
40
+ for (let n of t.steps) e.registerStep(n);
41
+ }
42
+ function u(e, t) {
43
+ for (let n of t.experiences) s(e, n);
44
+ }
45
+ function d(e) {
24
46
  let t = e.searchParams["preview-token"];
25
47
  if (t && t.length > 0) return t[0];
26
48
  }
27
- function c(e) {
49
+ function f(e) {
28
50
  let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
29
51
  if (!n) return t;
30
52
  for (let e of n) {
@@ -33,13 +55,13 @@ function c(e) {
33
55
  }
34
56
  return t;
35
57
  }
36
- function l(e, t, n) {
37
- let i = c(e), a = e.session?.id;
58
+ function p(e, t, n) {
59
+ let i = f(e), a = e.session?.id;
38
60
  if (!a) throw Error("Session ID is required for feature registration");
39
61
  let o = r(a);
40
- for (let r of t.features) i.has(r.id) || u(e, r, n, o);
62
+ for (let r of t.features) i.has(r.id) || m(e, r, n, o);
41
63
  }
42
- function u(e, t, n, r) {
64
+ function m(e, t, n, r) {
43
65
  e.registerFeature(t.id, {
44
66
  key: `v${t.version}`,
45
67
  name: t.name,
@@ -47,7 +69,7 @@ function u(e, t, n, r) {
47
69
  decide: () => t.enabled ? i(r, t.weight) : !1
48
70
  });
49
71
  }
50
- function d() {
72
+ function h() {
51
73
  let e;
52
74
  try {
53
75
  e = __PICKED_PROJECT_CONFIG__;
@@ -62,9 +84,9 @@ function d() {
62
84
  return;
63
85
  }
64
86
  else t = e;
65
- if (o(t)) return t;
87
+ if (a(t)) return t;
66
88
  }
67
- function f(e) {
89
+ function g(e) {
68
90
  try {
69
91
  let t = new URL(e).hostname;
70
92
  return t === "localhost" || t === "127.0.0.1" || t === "::1";
@@ -72,49 +94,49 @@ function f(e) {
72
94
  return !1;
73
95
  }
74
96
  }
75
- function p(e) {
97
+ function _(e) {
76
98
  if (typeof e != "object" || !e || !("cause" in e)) return !1;
77
99
  let { cause: t } = e;
78
100
  return typeof t != "object" || !t || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
79
101
  }
80
- async function m(e, n, r) {
81
- let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, a;
102
+ async function v(e, n, r) {
103
+ let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, o;
82
104
  try {
83
- a = await t(e, i, r?.headers);
105
+ o = await t(e, i, r?.headers);
84
106
  } catch (t) {
85
- return f(e) && p(t), null;
107
+ return g(e) && _(t), null;
86
108
  }
87
- if (!a.ok) return `${a.status.toString()}`, null;
109
+ if (!o.ok) return `${o.status.toString()}`, null;
88
110
  let s;
89
111
  try {
90
- s = await a.json();
112
+ s = await o.json();
91
113
  } catch {
92
114
  return null;
93
115
  }
94
- return o(s) ? s : null;
116
+ return a(s) ? s : null;
95
117
  }
96
- function h(e) {
118
+ function y(e) {
97
119
  return {
98
120
  name: "dynamic-experiences",
99
121
  setup: (t) => {
100
122
  let n = e?.apiUrl ?? t.apiUrl;
101
123
  return { onStart: async () => {
102
- let r = s(t);
124
+ let r = d(t);
103
125
  if (r) {
104
- let e = await m(n, t.projectId, { previewToken: r });
105
- e && l(t, e, !0);
126
+ let e = await v(n, t.projectId, { previewToken: r });
127
+ e && (p(t, e, !0), o(t, e), c(t, e), l(t, e), u(t, e));
106
128
  return;
107
129
  }
108
- let i = e?.projectConfig ?? d();
130
+ let i = e?.projectConfig ?? h();
109
131
  if (i) {
110
- l(t, i, !1);
132
+ p(t, i, !1), o(t, i), c(t, i), l(t, i), u(t, i);
111
133
  return;
112
134
  }
113
- let a = await m(n, t.projectId);
114
- a && l(t, a, !1);
135
+ let a = await v(n, t.projectId);
136
+ a && (p(t, a, !1), o(t, a), c(t, a), l(t, a), u(t, a));
115
137
  } };
116
138
  }
117
139
  };
118
140
  }
119
141
  //#endregion
120
- export { e as createClientHeaders, h as dynamicExperiencesPlugin, m as fetchProject };
142
+ export { e as createClientHeaders, y as dynamicExperiencesPlugin, v as fetchProject };