@picked/client 0.0.1-dev.1778120127377 → 0.0.1-dev.1778136207545

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/esm/index.js CHANGED
@@ -4,7 +4,7 @@ import { t as r } from "../logger-6z_gb4rA.js";
4
4
  import { a as i, c as a, d as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "../supports-0XIfd4-R.js";
5
5
  import { a as g, c as _, i as v, l as y, n as b, o as ee, r as x, s as S } from "../experience-instance-BrLWgVAN.js";
6
6
  import { i as C, n as w, r as T, t as E } from "../storage-6Xk0uAxB.js";
7
- import { n as D, r as te } from "../api-zfqEYPyX.js";
7
+ import { n as D, r as te } from "../api-Crj5wFbR.js";
8
8
  import { t as ne } from "../id-CRqy981z.js";
9
9
  import { attach as O, combine as k, createApi as A, createDomain as j, createEffect as M, createEvent as N, createStore as P, sample as F } from "effector";
10
10
  import { createFactory as I, invoke as L } from "@withease/factories";
@@ -105,18 +105,18 @@ var oe = I(({ client: e }) => {
105
105
  }
106
106
  let c = O({
107
107
  source: t,
108
- effect: async (e, t) => {
109
- let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
110
- if (!n) {
111
- "key" in t ? `${t.key}` : `${t.id}`;
108
+ effect: async (t, n) => {
109
+ let r = "key" in n ? Object.values(t).find((e) => e.key === n.key) : t[n.id];
110
+ if (!r) {
111
+ "key" in n ? `${n.key}` : `${n.id}`;
112
112
  return;
113
113
  }
114
- let { options: r } = t;
115
- if (r?.bypassCondition) {
116
- await n.initialiseFx(r);
114
+ let { options: i } = n;
115
+ if (i?.bypassCondition) {
116
+ await R(e, r), await r.initialiseFx(i);
117
117
  return;
118
118
  }
119
- await n.shouldInitialiseFx() && await n.initialiseFx(r);
119
+ await r.shouldInitialiseFx() && (await R(e, r), await r.initialiseFx(i));
120
120
  }
121
121
  });
122
122
  return {
@@ -154,9 +154,9 @@ var oe = I(({ client: e }) => {
154
154
  listStore: a,
155
155
  initialiseExperiencesFx: O({
156
156
  source: a,
157
- effect: async (e) => {
158
- await Promise.all(e.map(async (e) => {
159
- await e.shouldInitialiseFx() && await e.initialiseFx(void 0);
157
+ effect: async (t) => {
158
+ await Promise.all(t.map(async (t) => {
159
+ await t.shouldInitialiseFx() && (await R(e, t), await t.initialiseFx(void 0));
160
160
  }));
161
161
  }
162
162
  })
@@ -167,6 +167,17 @@ function se(e) {
167
167
  }
168
168
  var ce = async (e) => {
169
169
  await e.experiences.initialiseExperiencesFx();
170
+ }, R = async (e, t) => {
171
+ if (!e.contentLoader) return !0;
172
+ try {
173
+ await e.contentLoader({
174
+ id: t.id,
175
+ key: t.key
176
+ });
177
+ } catch {
178
+ `${t.id}`;
179
+ }
180
+ return !0;
170
181
  };
171
182
  //#endregion
172
183
  //#region src/entities/plugin/plugin.ts
@@ -287,24 +298,24 @@ function Se(e) {
287
298
  function Ce(e) {
288
299
  return typeof e == "number" && !isNaN(e);
289
300
  }
290
- function R(e) {
301
+ function z(e) {
291
302
  return typeof e == "string";
292
303
  }
293
- function z(e) {
304
+ function B(e) {
294
305
  return Array.isArray(e);
295
306
  }
296
- function B(e) {
307
+ function V(e) {
297
308
  return e instanceof Promise;
298
309
  }
299
- function V(e) {
310
+ function H(e) {
300
311
  return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
301
312
  }
302
- function H(e) {
313
+ function U(e) {
303
314
  if (Ce(e)) return e;
304
315
  let t = parseFloat(`${e}`);
305
316
  return isNaN(t) ? 0 : t;
306
317
  }
307
- function U(e) {
318
+ function W(e) {
308
319
  return `${e}`;
309
320
  }
310
321
  var we = {
@@ -312,51 +323,51 @@ var we = {
312
323
  "===": (e, t) => e === t,
313
324
  "!=": (e, t) => e != t,
314
325
  "!==": (e, t) => e !== t,
315
- ">": (e, t) => H(e) > H(t),
316
- ">=": (e, t) => H(e) >= H(t),
326
+ ">": (e, t) => U(e) > U(t),
327
+ ">=": (e, t) => U(e) >= U(t),
317
328
  "<": (e, t, n) => {
318
- let r = H(e), i = H(t);
329
+ let r = U(e), i = U(t);
319
330
  if (n === void 0) return r < i;
320
- let a = H(n);
331
+ let a = U(n);
321
332
  return r < i && i < a;
322
333
  },
323
334
  "<=": (e, t, n) => {
324
- let r = H(e), i = H(t);
335
+ let r = U(e), i = U(t);
325
336
  if (n === void 0) return r <= i;
326
- let a = H(n);
337
+ let a = U(n);
327
338
  return r <= i && i <= a;
328
339
  },
329
- "!!": async (e) => await G(e),
330
- "!": async (e) => !await G(e),
331
- "%": (e, t) => H(e) % H(t),
340
+ "!!": async (e) => await K(e),
341
+ "!": async (e) => !await K(e),
342
+ "%": (e, t) => U(e) % U(t),
332
343
  log: (e) => (console.log(e), e),
333
- in: (e, t) => t ? R(t) ? t.indexOf(U(e)) !== -1 : z(t) ? t.includes(e) : !1 : !1,
334
- cat: (...e) => e.map(U).join(""),
344
+ in: (e, t) => t ? z(t) ? t.indexOf(W(e)) !== -1 : B(t) ? t.includes(e) : !1 : !1,
345
+ cat: (...e) => e.map(W).join(""),
335
346
  substr: (e, t, n) => {
336
- let r = U(e), i = H(t);
347
+ let r = W(e), i = U(t);
337
348
  if (n === void 0) return r.substr(i);
338
- let a = H(n);
349
+ let a = U(n);
339
350
  if (a < 0) {
340
351
  let e = r.substr(i);
341
352
  return e.substr(0, e.length + a);
342
353
  }
343
354
  return r.substr(i, a);
344
355
  },
345
- "+": (...e) => e.reduce((e, t) => H(e) + H(t), 0),
346
- "*": (...e) => e.reduce((e, t) => H(e) * H(t), 1),
356
+ "+": (...e) => e.reduce((e, t) => U(e) + U(t), 0),
357
+ "*": (...e) => e.reduce((e, t) => U(e) * U(t), 1),
347
358
  "-": (e, t) => {
348
- let n = H(e);
349
- return t === void 0 ? -n : n - H(t);
359
+ let n = U(e);
360
+ return t === void 0 ? -n : n - U(t);
350
361
  },
351
- "/": (e, t) => H(e) / H(t),
352
- min: (...e) => Math.min(...e.map(H)),
353
- max: (...e) => Math.max(...e.map(H)),
354
- merge: (...e) => e.reduce((e, t) => z(t) ? e.concat(t) : e.concat([t]), []),
362
+ "/": (e, t) => U(e) / U(t),
363
+ min: (...e) => Math.min(...e.map(U)),
364
+ max: (...e) => Math.max(...e.map(U)),
365
+ merge: (...e) => e.reduce((e, t) => B(t) ? e.concat(t) : e.concat([t]), []),
355
366
  var(e, t) {
356
367
  let n = arguments.length > 1 ? t : null;
357
368
  if (e === "" || e === "." || e == null) return this;
358
369
  if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
359
- let r = U(e);
370
+ let r = W(e);
360
371
  if (r === "" || r === ".") return this;
361
372
  let i = r.split("."), a = this;
362
373
  for (let e of i) {
@@ -369,109 +380,109 @@ var we = {
369
380
  return a === void 0 ? n : a;
370
381
  },
371
382
  async missing(...e) {
372
- let t = z(e[0]) ? e[0] : e, n = [];
383
+ let t = B(e[0]) ? e[0] : e, n = [];
373
384
  for (let e of t) {
374
- let t = await W({ var: e }, this);
385
+ let t = await G({ var: e }, this);
375
386
  (t === null || t === "") && n.push(`${e}`);
376
387
  }
377
388
  return n;
378
389
  },
379
390
  async missing_some(e, t) {
380
- let n = await W({ missing: t }, this);
381
- if (!z(n) || !z(t)) return [];
382
- let r = n.filter(R);
383
- return t.filter(R).length - r.length >= H(e) ? [] : r;
391
+ let n = await G({ missing: t }, this);
392
+ if (!B(n) || !B(t)) return [];
393
+ let r = n.filter(z);
394
+ return t.filter(z).length - r.length >= U(e) ? [] : r;
384
395
  },
385
396
  invoke(...e) {
386
397
  let [t, ...n] = e;
387
398
  return typeof t == "function" ? Reflect.apply(t, null, n) : null;
388
399
  },
389
- startsWith: (e, t) => R(e) && R(t) && e.startsWith(t),
390
- endsWith: (e, t) => R(e) && R(t) && e.endsWith(t),
400
+ startsWith: (e, t) => z(e) && z(t) && e.startsWith(t),
401
+ endsWith: (e, t) => z(e) && z(t) && e.endsWith(t),
391
402
  regexp_matches(e, t) {
392
403
  let n = e, r = "";
393
- if (z(e)) {
404
+ if (B(e)) {
394
405
  let [t, i] = e;
395
406
  n = t, r = i;
396
407
  }
397
- return !R(n) || !R(r) ? !1 : new RegExp(n, r).test(U(t));
408
+ return !z(n) || !z(r) ? !1 : new RegExp(n, r).test(W(t));
398
409
  },
399
410
  throw(e) {
400
- throw Error(U(e));
411
+ throw Error(W(e));
401
412
  }
402
413
  };
403
- async function W(e, t) {
414
+ async function G(e, t) {
404
415
  if (!e) return e;
405
- if (B(e)) return W(await e, t);
406
- if (z(e)) return Promise.all(e.map((e) => W(e, t)));
407
- if (!V(e)) return e;
416
+ if (V(e)) return G(await e, t);
417
+ if (B(e)) return Promise.all(e.map((e) => G(e, t)));
418
+ if (!H(e)) return e;
408
419
  let n = Te(e), r = n ? e[n] ?? [] : [];
409
- switch (z(r) || (r = [r]), n) {
420
+ switch (B(r) || (r = [r]), n) {
410
421
  case "if":
411
422
  case "?:":
412
- for (let e = 0; e < r.length - 1; e += 2) if (await G(await W(r[e], t))) return W(r[e + 1], t);
413
- return r.length % 2 == 1 ? W(r[r.length - 1], t) : null;
423
+ for (let e = 0; e < r.length - 1; e += 2) if (await K(await G(r[e], t))) return G(r[e + 1], t);
424
+ return r.length % 2 == 1 ? G(r[r.length - 1], t) : null;
414
425
  case "and": {
415
426
  let e = null;
416
- for (let n of r) if (e = await W(n, t), !await G(e)) return e;
427
+ for (let n of r) if (e = await G(n, t), !await K(e)) return e;
417
428
  return e;
418
429
  }
419
430
  case "or": {
420
431
  let e = null;
421
- for (let n of r) if (e = await W(n, t), await G(e)) return e;
432
+ for (let n of r) if (e = await G(n, t), await K(e)) return e;
422
433
  return e;
423
434
  }
424
435
  case "map": {
425
- let e = await W(r[0], t);
426
- return z(e) ? await Promise.all(e.map((e) => W(r[1], e))) : [];
436
+ let e = await G(r[0], t);
437
+ return B(e) ? await Promise.all(e.map((e) => G(r[1], e))) : [];
427
438
  }
428
439
  case "filter": {
429
- let e = await W(r[0], t);
430
- return z(e) ? (await Promise.all(e.map(async (e) => ({
440
+ let e = await G(r[0], t);
441
+ return B(e) ? (await Promise.all(e.map(async (e) => ({
431
442
  item: e,
432
- shouldInclude: await G(await W(r[1], e))
443
+ shouldInclude: await K(await G(r[1], e))
433
444
  })))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
434
445
  }
435
446
  case "reduce": {
436
- let e = await W(r[0], t);
437
- if (!z(e)) return r.length > 2 ? await W(r[2], t) : null;
438
- let n = r[1], i = r.length > 2 ? await W(r[2], t) : null;
439
- for (let t of e) i = await W(n, {
447
+ let e = await G(r[0], t);
448
+ if (!B(e)) return r.length > 2 ? await G(r[2], t) : null;
449
+ let n = r[1], i = r.length > 2 ? await G(r[2], t) : null;
450
+ for (let t of e) i = await G(n, {
440
451
  current: t,
441
452
  accumulator: i
442
453
  });
443
454
  return i;
444
455
  }
445
456
  case "all": {
446
- let e = await W(r[0], t);
447
- if (!z(e) || e.length === 0) return !1;
448
- for (let t of e) if (!await G(await W(r[1], t))) return !1;
457
+ let e = await G(r[0], t);
458
+ if (!B(e) || e.length === 0) return !1;
459
+ for (let t of e) if (!await K(await G(r[1], t))) return !1;
449
460
  return !0;
450
461
  }
451
462
  case "some": {
452
- let e = await W(r[0], t);
453
- if (!z(e)) return !1;
454
- for (let t of e) if (await G(await W(r[1], t))) return !0;
463
+ let e = await G(r[0], t);
464
+ if (!B(e)) return !1;
465
+ for (let t of e) if (await K(await G(r[1], t))) return !0;
455
466
  return !1;
456
467
  }
457
468
  case "none": {
458
- let e = await W(r[0], t);
459
- if (!z(e)) return !0;
460
- for (let t of e) if (await G(await W(r[1], t))) return !1;
469
+ let e = await G(r[0], t);
470
+ if (!B(e)) return !0;
471
+ for (let t of e) if (await K(await G(r[1], t))) return !1;
461
472
  return !0;
462
473
  }
463
474
  case "catch": try {
464
- return await W(r[0], t);
475
+ return await G(r[0], t);
465
476
  } catch (e) {
466
- return V(e) ? await W(e, t) : r[1] ? await W(r[1], e) : e instanceof Error ? e.message : e;
477
+ return H(e) ? await G(e, t) : r[1] ? await G(r[1], e) : e instanceof Error ? e.message : e;
467
478
  }
468
479
  }
469
- let i = await Promise.all(r.map((e) => W(e, t))), a = n ? we[n] : void 0;
480
+ let i = await Promise.all(r.map((e) => G(e, t))), a = n ? we[n] : void 0;
470
481
  if (!a) throw Error(`Unrecognized operation ${n}`);
471
482
  return a.apply(t, i);
472
483
  }
473
- async function G(e) {
474
- return B(e) ? G(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
484
+ async function K(e) {
485
+ return V(e) ? K(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
475
486
  }
476
487
  function Te(e) {
477
488
  return Object.keys(e)[0];
@@ -497,7 +508,7 @@ var Ee = I(({ client: e }) => O({
497
508
  let { bucket: e } = await t.getBucket();
498
509
  return e;
499
510
  }, e), {});
500
- return await W(a, {
511
+ return await G(a, {
501
512
  responses: i,
502
513
  location: typeof e.location == "object" ? {
503
514
  hash: e.location.hash,
@@ -536,19 +547,19 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
536
547
  } catch {
537
548
  return !1;
538
549
  }
539
- }, K = j("lifecycle"), je = I(({ client: e }) => {
540
- let t = K.store(!1), r = P(void 0, {
550
+ }, q = j("lifecycle"), je = I(({ client: e }) => {
551
+ let t = q.store(!1), r = P(void 0, {
541
552
  skipVoid: !1,
542
- domain: K
553
+ domain: q
543
554
  }), i = P(void 0, {
544
555
  skipVoid: !1,
545
- domain: K
546
- }), a = K.store("idle"), o = K.store([]), s = P(void 0, {
556
+ domain: q
557
+ }), a = q.store("idle"), o = q.store([]), s = P(void 0, {
547
558
  skipVoid: !1,
548
- domain: K
559
+ domain: q
549
560
  }), c = P(void 0, {
550
561
  skipVoid: !1,
551
- domain: K
562
+ domain: q
552
563
  }), l = N(), u = N(), d = N(), p = N(), m = N(), h = N();
553
564
  o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
554
565
  let g = M(() => {
@@ -921,8 +932,8 @@ var Be = (e, t, n) => {
921
932
  id: e,
922
933
  feature: t
923
934
  });
924
- }, q = j("history");
925
- function J(e, t) {
935
+ }, J = j("history");
936
+ function Y(e, t) {
926
937
  return {
927
938
  id: ne(`history-entry-${Date.now()}-${Math.random()}}`),
928
939
  node: t,
@@ -931,8 +942,8 @@ function J(e, t) {
931
942
  };
932
943
  }
933
944
  var Ve = I(() => {
934
- let e = q.store({ entries: [] }), t = q.event(), n = q.event(), r = q.event(), i = q.event();
935
- e.on(t, (e, t) => ({ entries: [...e.entries, J(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), J(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
945
+ let e = J.store({ entries: [] }), t = J.event(), n = J.event(), r = J.event(), i = J.event();
946
+ e.on(t, (e, t) => ({ entries: [...e.entries, Y(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), Y(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
936
947
  function a(e, t) {
937
948
  let n = {
938
949
  lastStepIndex: -1,
@@ -1060,9 +1071,38 @@ function Ze(e, t) {
1060
1071
  t.register(e);
1061
1072
  }
1062
1073
  //#endregion
1074
+ //#region src/entities/content/content.ts
1075
+ var Qe = j("content"), $e = I(() => {
1076
+ let e = Qe.store({}), t = A(e, { register(e, t) {
1077
+ return {
1078
+ ...e,
1079
+ [t.content.id]: t.content
1080
+ };
1081
+ } });
1082
+ function n(e) {
1083
+ t.register({ content: e });
1084
+ }
1085
+ let r = e.map((e) => Object.values(e));
1086
+ function i(t) {
1087
+ return e.map((e) => e[t] ?? null, { skipVoid: !1 });
1088
+ }
1089
+ return {
1090
+ register: n,
1091
+ getById: i,
1092
+ listStore: r,
1093
+ indexStore: e
1094
+ };
1095
+ });
1096
+ function et() {
1097
+ return L($e);
1098
+ }
1099
+ function tt(e, t) {
1100
+ t.register(e);
1101
+ }
1102
+ //#endregion
1063
1103
  //#region src/entities/action/action.ts
1064
- var Qe = j("action"), $e = I(({ client: e }) => {
1065
- let t = Qe.store({}), n = A(t, { register(e, t) {
1104
+ var nt = j("action"), rt = I(({ client: e }) => {
1105
+ let t = nt.store({}), n = A(t, { register(e, t) {
1066
1106
  return {
1067
1107
  ...e,
1068
1108
  [t.key]: {
@@ -1120,10 +1160,10 @@ var Qe = j("action"), $e = I(({ client: e }) => {
1120
1160
  getEvokableAction: s
1121
1161
  };
1122
1162
  });
1123
- function et(e) {
1124
- return L($e, e);
1163
+ function it(e) {
1164
+ return L(rt, e);
1125
1165
  }
1126
- var tt = (e, t, n) => {
1166
+ var at = (e, t, n) => {
1127
1167
  n.register({
1128
1168
  key: e,
1129
1169
  action: t
@@ -1131,7 +1171,7 @@ var tt = (e, t, n) => {
1131
1171
  };
1132
1172
  //#endregion
1133
1173
  //#region src/entities/response/response-validation.ts
1134
- function Y(e, t, n, r) {
1174
+ function X(e, t, n, r) {
1135
1175
  return {
1136
1176
  fieldKey: e.key,
1137
1177
  userMessage: n,
@@ -1139,62 +1179,62 @@ function Y(e, t, n, r) {
1139
1179
  value: t
1140
1180
  };
1141
1181
  }
1142
- function X(e) {
1182
+ function Z(e) {
1143
1183
  return e === null || e === "" || Array.isArray(e) && !e.length;
1144
1184
  }
1145
- function nt(e) {
1185
+ function ot(e) {
1146
1186
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
1147
1187
  }
1148
- function Z(e) {
1188
+ function Q(e) {
1149
1189
  try {
1150
1190
  return JSON.stringify(e), !0;
1151
1191
  } catch {
1152
1192
  return !1;
1153
1193
  }
1154
1194
  }
1155
- function rt(e, t) {
1195
+ function st(e, t) {
1156
1196
  return t.find((t) => t.key === e) ?? null;
1157
1197
  }
1158
- function it(e, t) {
1198
+ function ct(e, t) {
1159
1199
  return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
1160
1200
  }
1161
- function at(e, t) {
1162
- if (e.type !== "object" || X(t)) return null;
1201
+ function lt(e, t) {
1202
+ if (e.type !== "object" || Z(t)) return null;
1163
1203
  if (e.multiple) {
1164
- if (!Array.isArray(t)) return Y(e, t, "This field expects multiple values", "Field expects an array of objects.");
1204
+ if (!Array.isArray(t)) return X(e, t, "This field expects multiple values", "Field expects an array of objects.");
1165
1205
  for (let n of t) {
1166
- if (typeof n != "object" || !n) return Y(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
1167
- if (!Z(n)) return Y(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1206
+ if (typeof n != "object" || !n) return X(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
1207
+ if (!Q(n)) return X(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1168
1208
  }
1169
1209
  return null;
1170
1210
  }
1171
- return Array.isArray(t) ? Y(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? Y(e, t, "This field expects an object value", "Field expects an object value.") : Z(t) ? null : Y(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1211
+ return Array.isArray(t) ? X(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? X(e, t, "This field expects an object value", "Field expects an object value.") : Q(t) ? null : X(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1172
1212
  }
1173
- function ot(e, t) {
1174
- if (X(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
1213
+ function ut(e, t) {
1214
+ if (Z(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
1175
1215
  let n = Array.isArray(t) ? t : [t];
1176
1216
  if (e.type === "object") {
1177
1217
  let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
1178
- return n.every((e) => r.has(JSON.stringify(e))) ? null : Y(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
1218
+ return n.every((e) => r.has(JSON.stringify(e))) ? null : X(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
1179
1219
  }
1180
1220
  let r = e.options.map((e) => e.value);
1181
- return n.every((e) => !nt(e) || e === null ? !1 : r.includes(e)) ? null : Y(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
1221
+ return n.every((e) => !ot(e) || e === null ? !1 : r.includes(e)) ? null : X(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
1182
1222
  }
1183
- async function st(t, n, r, i) {
1184
- if (n.validation && !e(n.validation) && !X(r)) {
1223
+ async function dt(t, n, r, i) {
1224
+ if (n.validation && !e(n.validation) && !Z(r)) {
1185
1225
  let e = i ? {
1186
1226
  $input: r,
1187
1227
  responses: i
1188
1228
  } : { $input: r }, a = await t(n.validation, e);
1189
- if (typeof a == "string") return Y(n, r, a, `Field validation resulted in an error: ${a}.`);
1190
- if (a === !1) return Y(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
1229
+ if (typeof a == "string") return X(n, r, a, `Field validation resulted in an error: ${a}.`);
1230
+ if (a === !1) return X(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
1191
1231
  }
1192
- return n.required && X(r) ? Y(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? Y(n, r, "This field expects a single response", "Field expects a single response.") : null;
1232
+ return n.required && Z(r) ? X(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? X(n, r, "This field expects a single response", "Field expects a single response.") : null;
1193
1233
  }
1194
1234
  //#endregion
1195
1235
  //#region src/entities/response/response.ts
1196
- var ct = j("response"), lt = I(({ client: e }) => {
1197
- let t = ct.store({}), r = N(), i = N(), a = A(t, {
1236
+ var ft = j("response"), pt = I(({ client: e }) => {
1237
+ let t = ft.store({}), r = N(), i = N(), a = A(t, {
1198
1238
  register(e, t) {
1199
1239
  return {
1200
1240
  ...e,
@@ -1233,7 +1273,7 @@ var ct = j("response"), lt = I(({ client: e }) => {
1233
1273
  ...t,
1234
1274
  ...n
1235
1275
  }, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
1236
- let o = rt(t, e);
1276
+ let o = st(t, e);
1237
1277
  if (!o) {
1238
1278
  r.push({
1239
1279
  fieldKey: t,
@@ -1243,17 +1283,17 @@ var ct = j("response"), lt = I(({ client: e }) => {
1243
1283
  });
1244
1284
  return;
1245
1285
  }
1246
- let c = it(o, n), l = await st(s, o, c, a);
1286
+ let c = ct(o, n), l = await dt(s, o, c, a);
1247
1287
  if (l) {
1248
1288
  r.push(l);
1249
1289
  return;
1250
1290
  }
1251
- let u = at(o, c);
1291
+ let u = lt(o, c);
1252
1292
  if (u) {
1253
1293
  r.push(u);
1254
1294
  return;
1255
1295
  }
1256
- let d = ot(o, c);
1296
+ let d = ut(o, c);
1257
1297
  if (d) {
1258
1298
  r.push(d);
1259
1299
  return;
@@ -1332,13 +1372,13 @@ var ct = j("response"), lt = I(({ client: e }) => {
1332
1372
  getByFieldName: _
1333
1373
  };
1334
1374
  });
1335
- function ut(e) {
1336
- return L(lt, e);
1375
+ function mt(e) {
1376
+ return L(pt, e);
1337
1377
  }
1338
1378
  //#endregion
1339
1379
  //#region src/entities/condition/condition.ts
1340
- var dt = j("condition"), ft = I(() => {
1341
- let e = dt.store({}), t = A(e, { register(e, t) {
1380
+ var ht = j("condition"), gt = I(() => {
1381
+ let e = ht.store({}), t = A(e, { register(e, t) {
1342
1382
  return {
1343
1383
  ...e,
1344
1384
  [t.condition.id]: t.condition
@@ -1362,12 +1402,12 @@ var dt = j("condition"), ft = I(() => {
1362
1402
  indexStore: e
1363
1403
  };
1364
1404
  });
1365
- function pt() {
1366
- return L(ft);
1405
+ function _t() {
1406
+ return L(gt);
1367
1407
  }
1368
1408
  //#endregion
1369
1409
  //#region src/utils/api-url.ts
1370
- function mt() {
1410
+ function vt() {
1371
1411
  if (f()) {
1372
1412
  let e = [
1373
1413
  document.currentScript,
@@ -1382,7 +1422,7 @@ function mt() {
1382
1422
  }
1383
1423
  //#endregion
1384
1424
  //#region src/utils/search-params.ts
1385
- function ht() {
1425
+ function yt() {
1386
1426
  if (!o()) return {};
1387
1427
  let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
1388
1428
  for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
@@ -1400,13 +1440,13 @@ function ht() {
1400
1440
  }
1401
1441
  //#endregion
1402
1442
  //#region src/entities/session/session.ts
1403
- var Q = E("session", "global");
1404
- function gt() {
1443
+ var bt = E("session", "global");
1444
+ function xt() {
1405
1445
  return l() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
1406
1446
  }
1407
- function _t() {
1447
+ function St() {
1408
1448
  if (!u()) return null;
1409
- let e = w.get(Q);
1449
+ let e = w.get(bt);
1410
1450
  if (!e.isSet()) return null;
1411
1451
  try {
1412
1452
  return e.json();
@@ -1414,8 +1454,8 @@ function _t() {
1414
1454
  return null;
1415
1455
  }
1416
1456
  }
1417
- var vt = I(() => {
1418
- let e = _t(), t = { id: e?.id ?? gt() };
1457
+ var Ct = I(() => {
1458
+ let e = St(), t = { id: e?.id ?? xt() };
1419
1459
  e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
1420
1460
  let n = P(t), r = A(n, {
1421
1461
  setIsUser: (e, t) => ({
@@ -1444,7 +1484,7 @@ var vt = I(() => {
1444
1484
  source: n,
1445
1485
  effect: (e) => {
1446
1486
  if (u()) try {
1447
- w.get(Q).set(e);
1487
+ w.get(bt).set(e);
1448
1488
  } catch {}
1449
1489
  }
1450
1490
  })
@@ -1455,27 +1495,27 @@ var vt = I(() => {
1455
1495
  removeIdentifier: r.removeIdentifier
1456
1496
  };
1457
1497
  });
1458
- function yt() {
1459
- return L(vt, void 0);
1498
+ function wt() {
1499
+ return L(Ct, void 0);
1460
1500
  }
1461
1501
  //#endregion
1462
1502
  //#region src/utils/picked-config.ts
1463
- function bt() {
1503
+ function Tt() {
1464
1504
  if (o()) return globalThis.window.pickedConfig;
1465
1505
  }
1466
- function xt() {
1467
- if (o()) return bt()?.projectId;
1506
+ function Et() {
1507
+ if (o()) return Tt()?.projectId;
1468
1508
  }
1469
- function St() {
1509
+ function Dt() {
1470
1510
  if (!f()) return;
1471
1511
  let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
1472
1512
  if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
1473
1513
  }
1474
- function Ct(e) {
1514
+ function Ot(e) {
1475
1515
  if (e.projectId) return e.projectId;
1476
- let t = xt();
1516
+ let t = Et();
1477
1517
  if (t) return t;
1478
- let n = St();
1518
+ let n = Dt();
1479
1519
  if (n) return n;
1480
1520
  throw Error("projectId is required. You can provide it via one of:\n (1) createClient({ projectId }) options;\n (2) window.pickedConfig = { projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes a data-projectid (or project-id) attribute.");
1481
1521
  }
@@ -1484,7 +1524,7 @@ function Ct(e) {
1484
1524
  function $(e) {
1485
1525
  return e == null || e === "" || Number.isNaN(e);
1486
1526
  }
1487
- var wt = {
1527
+ var kt = {
1488
1528
  default: (e, t) => $(e) ? String(t ?? "") : String(e),
1489
1529
  append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
1490
1530
  prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
@@ -1505,24 +1545,24 @@ var wt = {
1505
1545
  return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
1506
1546
  }
1507
1547
  };
1508
- function Tt(e) {
1548
+ function At(e) {
1509
1549
  return typeof e == "object" && !!e;
1510
1550
  }
1511
- function Et(e, t) {
1551
+ function jt(e, t) {
1512
1552
  let n = t;
1513
- for (let t of e.split(".")) if (Tt(n) && t in n) n = n[t];
1553
+ for (let t of e.split(".")) if (At(n) && t in n) n = n[t];
1514
1554
  else return;
1515
1555
  return typeof n == "function" ? n() : n;
1516
1556
  }
1517
- function Dt(e, t) {
1518
- let n = e.split("|").map((e) => e.trim()), r = Et(n.shift() ?? "", t);
1557
+ function Mt(e, t) {
1558
+ let n = e.split("|").map((e) => e.trim()), r = jt(n.shift() ?? "", t);
1519
1559
  for (let e of n) {
1520
- let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = wt[i];
1560
+ let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = kt[i];
1521
1561
  o && (r = o(r, a));
1522
1562
  }
1523
1563
  return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
1524
1564
  }
1525
- function Ot(e, t) {
1565
+ function Nt(e, t) {
1526
1566
  let n = "", r = 0;
1527
1567
  for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
1528
1568
  r += 2;
@@ -1534,15 +1574,17 @@ function Ot(e, t) {
1534
1574
  }
1535
1575
  i += e[r++];
1536
1576
  }
1537
- n += Dt(i.trim(), t);
1577
+ n += Mt(i.trim(), t);
1538
1578
  } else n += e[r++];
1539
1579
  return n;
1540
1580
  }
1541
1581
  //#endregion
1542
1582
  //#region src/picked.ts
1543
- var kt = class {
1583
+ var Pt = class {
1544
1584
  static logger = r;
1545
1585
  options;
1586
+ dataSource = null;
1587
+ contentLoader;
1546
1588
  plugins = {};
1547
1589
  eventBus = N();
1548
1590
  events;
@@ -1550,8 +1592,8 @@ var kt = class {
1550
1592
  apiUrl;
1551
1593
  dashboardUrl;
1552
1594
  documentationSiteUrl;
1553
- session = yt();
1554
- searchParams = ht();
1595
+ session = wt();
1596
+ searchParams = yt();
1555
1597
  history = He();
1556
1598
  components = he({ client: this });
1557
1599
  experienceInstances = b({ client: this });
@@ -1559,11 +1601,12 @@ var kt = class {
1559
1601
  frameworks = ye({ client: this });
1560
1602
  predicates = Fe({ client: this });
1561
1603
  features = ze({ client: this });
1562
- conditions = pt();
1604
+ conditions = _t();
1563
1605
  fields = qe();
1564
- responses = ut({ client: this });
1606
+ responses = mt({ client: this });
1565
1607
  steps = Xe();
1566
- actions = et({ client: this });
1608
+ contents = et();
1609
+ actions = it({ client: this });
1567
1610
  stateSnapshotStore = Se({ client: this });
1568
1611
  evaluateRuleLogicFx = De({ client: this });
1569
1612
  start;
@@ -1577,14 +1620,14 @@ var kt = class {
1577
1620
  effect: (e, { template: t, context: n }) => {
1578
1621
  let r = {};
1579
1622
  for (let t of e) r[t.fieldKey] = t.value;
1580
- return Ot(t, {
1623
+ return Nt(t, {
1581
1624
  ...n,
1582
1625
  responses: r
1583
1626
  });
1584
1627
  }
1585
1628
  });
1586
1629
  constructor(e) {
1587
- this.events = We(this.eventBus), this.projectId = Ct(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || mt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
1630
+ this.events = We(this.eventBus), this.projectId = Ot(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || vt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
1588
1631
  type: "load",
1589
1632
  version: te()
1590
1633
  });
@@ -1615,8 +1658,11 @@ var kt = class {
1615
1658
  registerStep = (e) => {
1616
1659
  Ze(e, this.steps);
1617
1660
  };
1661
+ registerContent = (e) => {
1662
+ tt(e, this.contents);
1663
+ };
1618
1664
  registerAction = (e, t) => {
1619
- tt(e, t, this.actions);
1665
+ at(e, t, this.actions);
1620
1666
  };
1621
1667
  registerExperience = (e) => {
1622
1668
  e.component && ge(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
@@ -1704,20 +1750,20 @@ var kt = class {
1704
1750
  };
1705
1751
  //#endregion
1706
1752
  //#region src/entities/component/lazyComponent.ts
1707
- function At(e) {
1753
+ function Ft(e) {
1708
1754
  return {
1709
1755
  $$type: "lazy-component",
1710
1756
  load: e
1711
1757
  };
1712
1758
  }
1713
- function jt(e) {
1759
+ function It(e) {
1714
1760
  return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
1715
1761
  }
1716
1762
  //#endregion
1717
1763
  //#region src/exports.ts
1718
- var Mt = (e) => {
1719
- let t = new kt(e);
1764
+ var Lt = (e) => {
1765
+ let t = new Pt(e);
1720
1766
  return d(t), t;
1721
1767
  };
1722
1768
  //#endregion
1723
- export { kt as Picked, Mt as createClient, le as createPluginEffect, E as createStorageKey, n as evaluateRuleLogic, bt as getPickedConfig, jt as isLazyLoader, _ as isPickedRoot, At as lazyComponent, w as localStore, T as sessionStore, C as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };
1769
+ export { Pt as Picked, Lt as createClient, le as createPluginEffect, E as createStorageKey, n as evaluateRuleLogic, Tt as getPickedConfig, It as isLazyLoader, _ as isPickedRoot, Ft as lazyComponent, w as localStore, T as sessionStore, C as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };