@picked/client 0.0.1-dev.1787537193674 → 0.0.1-dev.1787543060859
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/.tsbuildinfo +1 -1
- package/dist/{api-DRTduQVm.cjs → api-CahTmEWe.cjs} +1 -1
- package/dist/{api-4YpcWP-x.js → api-DwTNwuWK.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/telemetry/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/reference/sdk/features.md +7 -0
- package/dist/esm/index.js +240 -478
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/plugins/telemetry/index.js +19 -12
- package/dist/esm/server/index.js +1 -1
- package/dist/plugin-BcFzHPC7.cjs +1 -0
- package/dist/{plugin-DTN7fsyp.js → plugin-L5y4NdFX.js} +73 -52
- package/dist/{provider-BxhVIcsp.cjs → provider-BLDm3i8g.cjs} +1 -1
- package/dist/{provider-DLebj-AW.js → provider-Dx6VjvZg.js} +1 -1
- package/dist/types/entities/feature/feature.d.ts +43 -2
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/plugin/plugin.d.ts +4 -0
- package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
- package/dist/types/picked.d.ts +3 -2
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/telemetry/plugin.d.ts +7 -0
- package/dist/types/plugins/telemetry/plugin.d.ts.map +1 -1
- package/dist/version-BqU6f22c.cjs +1 -0
- package/dist/version-DAFO6eas.js +256 -0
- package/package.json +3 -3
- package/dist/plugin-BPZV7SJg.cjs +0 -1
- package/dist/version-BlahSDlG.cjs +0 -1
- package/dist/version-BmBn0dXR.js +0 -4
package/dist/esm/index.js
CHANGED
|
@@ -5,14 +5,14 @@ import { a as i, c as a, d as o, f as s, i as c, l, m as u, n as d, o as f, p, r
|
|
|
5
5
|
import { a as v, i as y, r as ee, s as b, t as x } from "../dom-BqcToNL0.js";
|
|
6
6
|
import { l as S, n as C, r as w, u as T } from "../experience-instance-DGk11d8a.js";
|
|
7
7
|
import { i as te, n as E, r as D, t as O } from "../storage-1MW3-_As.js";
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
10
|
-
import { n as
|
|
11
|
-
import { attach as k, combine as A, createApi as j, createDomain as M, createEffect as N, createEvent as P, createStore as F, is as
|
|
8
|
+
import { i as ne, n as re, r as ie, t as ae } from "../version-DAFO6eas.js";
|
|
9
|
+
import { t as oe } from "../id-Bo4RBeOs.js";
|
|
10
|
+
import { n as se, r as ce, t as le } from "../inert-script-report-B_bMPRzp.js";
|
|
11
|
+
import { attach as k, combine as A, createApi as j, createDomain as M, createEffect as N, createEvent as P, createStore as F, is as ue, sample as I } from "effector";
|
|
12
12
|
import { createFactory as L, invoke as R } from "@withease/factories";
|
|
13
|
-
import { sendPing as
|
|
13
|
+
import { sendPing as de } from "@picked/delivery-api-client";
|
|
14
14
|
//#region src/entities/experience/experience.ts
|
|
15
|
-
var z = M("experience"),
|
|
15
|
+
var z = M("experience"), fe = L(({ client: e, experience: r }) => {
|
|
16
16
|
let i = z.store(r), a = j(i, { merge(e, t) {
|
|
17
17
|
return {
|
|
18
18
|
...e,
|
|
@@ -99,17 +99,17 @@ var z = M("experience"), le = L(({ client: e, experience: r }) => {
|
|
|
99
99
|
prepareExperienceContentFx: m
|
|
100
100
|
}, u;
|
|
101
101
|
});
|
|
102
|
-
function
|
|
103
|
-
return R(
|
|
102
|
+
function pe(e) {
|
|
103
|
+
return R(fe, e);
|
|
104
104
|
}
|
|
105
|
-
var
|
|
105
|
+
var me = L(({ client: e }) => {
|
|
106
106
|
let t = z.store({}), n = j(t, { register(e, t) {
|
|
107
107
|
return {
|
|
108
108
|
...e,
|
|
109
109
|
[t.id]: t
|
|
110
110
|
};
|
|
111
111
|
} }), r = P(), i = N((t) => {
|
|
112
|
-
n.register(
|
|
112
|
+
n.register(pe({
|
|
113
113
|
client: e,
|
|
114
114
|
experience: t
|
|
115
115
|
}));
|
|
@@ -195,38 +195,35 @@ var de = L(({ client: e }) => {
|
|
|
195
195
|
})
|
|
196
196
|
};
|
|
197
197
|
});
|
|
198
|
-
function
|
|
199
|
-
return R(
|
|
198
|
+
function he(e) {
|
|
199
|
+
return R(me, e);
|
|
200
200
|
}
|
|
201
|
-
var
|
|
201
|
+
var ge = async (e) => {
|
|
202
202
|
await e.experiences.initialiseExperiencesFx();
|
|
203
203
|
};
|
|
204
204
|
//#endregion
|
|
205
205
|
//#region src/entities/plugin/plugin.ts
|
|
206
|
-
function
|
|
206
|
+
function _e(e) {
|
|
207
207
|
return N(async () => {
|
|
208
208
|
await e();
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
|
-
var
|
|
212
|
-
let r = t.name, i = t.setup(e);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}, ge = M("component"), _e = L(({ client: e, component: t, name: n }) => ({
|
|
211
|
+
var ve = (e, t, n) => {
|
|
212
|
+
let r = t.name, i = t.setup(e), a = n[r] ?? {};
|
|
213
|
+
n[r] = Object.freeze({
|
|
214
|
+
...a,
|
|
215
|
+
...i
|
|
216
|
+
});
|
|
217
|
+
}, ye = M("component"), be = L(({ client: e, component: t, name: n }) => ({
|
|
221
218
|
name: n,
|
|
222
219
|
component: t,
|
|
223
220
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
224
221
|
}));
|
|
225
|
-
function
|
|
226
|
-
return R(
|
|
222
|
+
function xe(e) {
|
|
223
|
+
return R(be, e);
|
|
227
224
|
}
|
|
228
|
-
var
|
|
229
|
-
let t =
|
|
225
|
+
var Se = L(({ client: e }) => {
|
|
226
|
+
let t = ye.store({}), n = j(t, { register(e, t) {
|
|
230
227
|
return {
|
|
231
228
|
...e,
|
|
232
229
|
[t.name]: t
|
|
@@ -239,7 +236,7 @@ var ye = L(({ client: e }) => {
|
|
|
239
236
|
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
240
237
|
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
241
238
|
clock: i,
|
|
242
|
-
fn: ({ name: t, component: n }) =>
|
|
239
|
+
fn: ({ name: t, component: n }) => xe({
|
|
243
240
|
client: e,
|
|
244
241
|
name: t,
|
|
245
242
|
component: n
|
|
@@ -256,16 +253,16 @@ var ye = L(({ client: e }) => {
|
|
|
256
253
|
listStore: a
|
|
257
254
|
};
|
|
258
255
|
});
|
|
259
|
-
function
|
|
260
|
-
return R(
|
|
256
|
+
function Ce(e) {
|
|
257
|
+
return R(Se, e);
|
|
261
258
|
}
|
|
262
|
-
var
|
|
259
|
+
var we = (e, t, n) => {
|
|
263
260
|
n.register({
|
|
264
261
|
name: e,
|
|
265
262
|
component: t
|
|
266
263
|
});
|
|
267
|
-
},
|
|
268
|
-
let t =
|
|
264
|
+
}, Te = M("framework"), Ee = L((e) => {
|
|
265
|
+
let t = Te.store({}), n = j(t, { register(e, t) {
|
|
269
266
|
return {
|
|
270
267
|
...e,
|
|
271
268
|
[t.name]: t.framework
|
|
@@ -290,15 +287,15 @@ var xe = (e, t, n) => {
|
|
|
290
287
|
listStore: a
|
|
291
288
|
};
|
|
292
289
|
});
|
|
293
|
-
function
|
|
294
|
-
return R(
|
|
290
|
+
function De(e) {
|
|
291
|
+
return R(Ee, e);
|
|
295
292
|
}
|
|
296
|
-
var
|
|
293
|
+
var Oe = (e, t) => {
|
|
297
294
|
t.register({
|
|
298
295
|
name: e.name,
|
|
299
296
|
framework: e
|
|
300
297
|
});
|
|
301
|
-
},
|
|
298
|
+
}, ke = L(({ client: e }) => {
|
|
302
299
|
let t = "window" in globalThis, n = {
|
|
303
300
|
location: t ? globalThis.location : void 0,
|
|
304
301
|
document: t ? globalThis.document : void 0,
|
|
@@ -312,12 +309,12 @@ var Te = (e, t) => {
|
|
|
312
309
|
...n
|
|
313
310
|
}));
|
|
314
311
|
});
|
|
315
|
-
function
|
|
316
|
-
return R(
|
|
312
|
+
function Ae(e) {
|
|
313
|
+
return R(ke, e);
|
|
317
314
|
}
|
|
318
315
|
//#endregion
|
|
319
316
|
//#region src/logic-engine.ts
|
|
320
|
-
function
|
|
317
|
+
function je(e) {
|
|
321
318
|
return typeof e == "number" && !isNaN(e);
|
|
322
319
|
}
|
|
323
320
|
function B(e) {
|
|
@@ -326,21 +323,21 @@ function B(e) {
|
|
|
326
323
|
function V(e) {
|
|
327
324
|
return Array.isArray(e);
|
|
328
325
|
}
|
|
329
|
-
function
|
|
326
|
+
function Me(e) {
|
|
330
327
|
return e instanceof Promise;
|
|
331
328
|
}
|
|
332
|
-
function
|
|
329
|
+
function Ne(e) {
|
|
333
330
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
334
331
|
}
|
|
335
332
|
function H(e) {
|
|
336
|
-
if (
|
|
333
|
+
if (je(e)) return e;
|
|
337
334
|
let t = parseFloat(`${e}`);
|
|
338
335
|
return isNaN(t) ? 0 : t;
|
|
339
336
|
}
|
|
340
337
|
function U(e) {
|
|
341
338
|
return `${e}`;
|
|
342
339
|
}
|
|
343
|
-
var
|
|
340
|
+
var Pe = {
|
|
344
341
|
"==": (e, t) => e == t,
|
|
345
342
|
"===": (e, t) => e === t,
|
|
346
343
|
"!=": (e, t) => e != t,
|
|
@@ -435,10 +432,10 @@ var je = {
|
|
|
435
432
|
};
|
|
436
433
|
async function W(e, t) {
|
|
437
434
|
if (!e) return e;
|
|
438
|
-
if (
|
|
435
|
+
if (Me(e)) return W(await e, t);
|
|
439
436
|
if (V(e)) return Promise.all(e.map((e) => W(e, t)));
|
|
440
|
-
if (!
|
|
441
|
-
let n =
|
|
437
|
+
if (!Ne(e)) return e;
|
|
438
|
+
let n = Fe(e), r = n ? e[n] ?? [] : [];
|
|
442
439
|
switch (V(r) || (r = [r]), n) {
|
|
443
440
|
case "if":
|
|
444
441
|
case "?:":
|
|
@@ -496,32 +493,32 @@ async function W(e, t) {
|
|
|
496
493
|
case "catch": try {
|
|
497
494
|
return await W(r[0], t);
|
|
498
495
|
} catch (e) {
|
|
499
|
-
return
|
|
496
|
+
return Ne(e) ? await W(e, t) : r[1] ? await W(r[1], e) : e instanceof Error ? e.message : e;
|
|
500
497
|
}
|
|
501
498
|
}
|
|
502
|
-
let i = await Promise.all(r.map((e) => W(e, t))), a = n ?
|
|
499
|
+
let i = await Promise.all(r.map((e) => W(e, t))), a = n ? Pe[n] : void 0;
|
|
503
500
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
504
501
|
return a.apply(t, i);
|
|
505
502
|
}
|
|
506
503
|
async function G(e) {
|
|
507
|
-
return
|
|
504
|
+
return Me(e) ? G(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
508
505
|
}
|
|
509
|
-
function
|
|
506
|
+
function Fe(e) {
|
|
510
507
|
return Object.keys(e)[0];
|
|
511
508
|
}
|
|
512
509
|
//#endregion
|
|
513
510
|
//#region src/lifecycle/rules-logic.ts
|
|
514
|
-
function
|
|
511
|
+
function Ie(e, t, n) {
|
|
515
512
|
return new Proxy(Object.create(null), { get(r, i) {
|
|
516
513
|
if (typeof i != "string") return;
|
|
517
514
|
let a = e.find((e) => e.key === i);
|
|
518
515
|
if (a !== void 0) return async () => !n.has(i) && await W(a.logic, {
|
|
519
516
|
...t,
|
|
520
|
-
conditions:
|
|
517
|
+
conditions: Ie(e, t, new Set(n).add(i))
|
|
521
518
|
}) === !0;
|
|
522
519
|
} });
|
|
523
520
|
}
|
|
524
|
-
var
|
|
521
|
+
var Le = L(({ client: e }) => k({
|
|
525
522
|
source: {
|
|
526
523
|
stateSnapshot: e.stateSnapshotStore,
|
|
527
524
|
predicates: e.predicates.listStore,
|
|
@@ -560,22 +557,22 @@ var Pe = L(({ client: e }) => k({
|
|
|
560
557
|
};
|
|
561
558
|
return await W(o, {
|
|
562
559
|
...d,
|
|
563
|
-
conditions:
|
|
560
|
+
conditions: Ie(a, d, /* @__PURE__ */ new Set())
|
|
564
561
|
});
|
|
565
562
|
}
|
|
566
563
|
}));
|
|
567
|
-
function
|
|
568
|
-
return R(
|
|
564
|
+
function Re(e) {
|
|
565
|
+
return R(Le, e);
|
|
569
566
|
}
|
|
570
567
|
//#endregion
|
|
571
568
|
//#region src/ping.ts
|
|
572
|
-
var
|
|
569
|
+
var ze = 6e3, Be = O("last_ping", "global"), Ve = async (e) => {
|
|
573
570
|
try {
|
|
574
|
-
let t = Date.now(), n = E.get(
|
|
575
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
571
|
+
let t = Date.now(), n = E.get(Be), r = 0;
|
|
572
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < ze) return !0;
|
|
576
573
|
let i = {}, a = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
577
574
|
a && (i["x-vercel-protection-bypass"] = a);
|
|
578
|
-
let o = await
|
|
575
|
+
let o = await de(e.apiUrl, {
|
|
579
576
|
projectId: e.projectId,
|
|
580
577
|
path: window.location.pathname
|
|
581
578
|
}, { headers: i });
|
|
@@ -583,27 +580,27 @@ var Ie = 6e3, Le = O("last_ping", "global"), Re = async (e) => {
|
|
|
583
580
|
} catch {
|
|
584
581
|
return !1;
|
|
585
582
|
}
|
|
586
|
-
},
|
|
587
|
-
function
|
|
583
|
+
}, He = "picked:start:begin", Ue = "picked:start";
|
|
584
|
+
function We() {
|
|
588
585
|
try {
|
|
589
586
|
return s() && !!p.window && "performance" in p;
|
|
590
587
|
} catch {
|
|
591
588
|
return !1;
|
|
592
589
|
}
|
|
593
590
|
}
|
|
594
|
-
function
|
|
595
|
-
if (
|
|
596
|
-
performance.mark(
|
|
591
|
+
function Ge() {
|
|
592
|
+
if (We()) try {
|
|
593
|
+
performance.mark(He);
|
|
597
594
|
} catch {}
|
|
598
595
|
}
|
|
599
|
-
function
|
|
600
|
-
if (
|
|
601
|
-
performance.measure(
|
|
596
|
+
function Ke() {
|
|
597
|
+
if (We()) try {
|
|
598
|
+
performance.measure(Ue, He);
|
|
602
599
|
} catch {}
|
|
603
600
|
}
|
|
604
601
|
//#endregion
|
|
605
602
|
//#region src/lifecycle/lifecycle.ts
|
|
606
|
-
var K = M("lifecycle"),
|
|
603
|
+
var K = M("lifecycle"), qe = L(({ client: e }) => {
|
|
607
604
|
let t = K.store(!1), r = F(void 0, {
|
|
608
605
|
skipVoid: !1,
|
|
609
606
|
domain: K
|
|
@@ -619,11 +616,11 @@ var K = M("lifecycle"), We = L(({ client: e }) => {
|
|
|
619
616
|
}), u = P(), d = P(), f = P(), p = P(), m = P(), h = P();
|
|
620
617
|
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), l.on(h, (e, t) => t), t.on(d, () => !0);
|
|
621
618
|
let g = N(() => {
|
|
622
|
-
|
|
619
|
+
Ve(e);
|
|
623
620
|
}), _ = N(async () => {
|
|
624
621
|
await ee();
|
|
625
622
|
}), v = N(async () => {
|
|
626
|
-
await
|
|
623
|
+
await ge(e);
|
|
627
624
|
}), y = k({ effect: v }), b = k({
|
|
628
625
|
source: o,
|
|
629
626
|
effect: async (e) => {
|
|
@@ -645,7 +642,7 @@ var K = M("lifecycle"), We = L(({ client: e }) => {
|
|
|
645
642
|
clock: C,
|
|
646
643
|
fn: () => "starting",
|
|
647
644
|
target: a
|
|
648
|
-
}), C.watch(
|
|
645
|
+
}), C.watch(Ge), d.watch(Ke), I({
|
|
649
646
|
clock: C,
|
|
650
647
|
target: g
|
|
651
648
|
}), I({
|
|
@@ -752,13 +749,13 @@ var K = M("lifecycle"), We = L(({ client: e }) => {
|
|
|
752
749
|
setCondition: h
|
|
753
750
|
};
|
|
754
751
|
});
|
|
755
|
-
function
|
|
756
|
-
return R(
|
|
752
|
+
function Je(e) {
|
|
753
|
+
return R(qe, e);
|
|
757
754
|
}
|
|
758
755
|
//#endregion
|
|
759
756
|
//#region src/entities/predicate/predicate.ts
|
|
760
|
-
var
|
|
761
|
-
let t =
|
|
757
|
+
var Ye = M("predicate"), Xe = L(({ client: e }) => {
|
|
758
|
+
let t = Ye.store({}), n = j(t, { register(e, t) {
|
|
762
759
|
return {
|
|
763
760
|
...e,
|
|
764
761
|
[t.name]: {
|
|
@@ -816,261 +813,26 @@ var Ke = M("predicate"), qe = L(({ client: e }) => {
|
|
|
816
813
|
getEvokablePredicate: s
|
|
817
814
|
};
|
|
818
815
|
});
|
|
819
|
-
function
|
|
820
|
-
return R(
|
|
816
|
+
function Ze(e) {
|
|
817
|
+
return R(Xe, e);
|
|
821
818
|
}
|
|
822
|
-
var
|
|
819
|
+
var Qe = (e, t, n) => {
|
|
823
820
|
n.register({
|
|
824
821
|
name: e,
|
|
825
822
|
predicate: t
|
|
826
823
|
});
|
|
827
|
-
},
|
|
828
|
-
function
|
|
829
|
-
return e?.enabled === !1;
|
|
830
|
-
}
|
|
831
|
-
function Ze(e) {
|
|
832
|
-
return e === "true" || e !== "false" && e;
|
|
833
|
-
}
|
|
834
|
-
var Qe = L(({ client: e }) => {
|
|
835
|
-
let t = Xe.store({}), n = Xe.store([]), i = j(t, { register(e, t) {
|
|
836
|
-
return {
|
|
837
|
-
...e,
|
|
838
|
-
[t.id]: t.feature
|
|
839
|
-
};
|
|
840
|
-
} }), a = P();
|
|
841
|
-
I({
|
|
842
|
-
clock: a,
|
|
843
|
-
source: t,
|
|
844
|
-
filter: (e, { id: t }) => e[t] !== void 0,
|
|
845
|
-
fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
|
|
846
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
847
|
-
clock: a,
|
|
848
|
-
fn: ({ id: e, feature: t }) => Object.freeze({
|
|
849
|
-
id: e,
|
|
850
|
-
feature: {
|
|
851
|
-
id: e,
|
|
852
|
-
feature: {
|
|
853
|
-
...t,
|
|
854
|
-
id: e
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}),
|
|
858
|
-
target: i.register
|
|
859
|
-
});
|
|
860
|
-
let o = N(async ({ id: e, key: t, storage: n = "local", enabled: r }) => {
|
|
861
|
-
if (r === !1) return null;
|
|
862
|
-
let i = O(`feature:${e}:${t}`, "global"), a = (n === "session" ? D : E).get(i).text();
|
|
863
|
-
return a ? {
|
|
864
|
-
id: e,
|
|
865
|
-
key: t,
|
|
866
|
-
bucket: Ze(a),
|
|
867
|
-
storage: n
|
|
868
|
-
} : null;
|
|
869
|
-
}), s = N((e) => {
|
|
870
|
-
if (!e) return null;
|
|
871
|
-
let t = O(`feature:${e.id}:${e.key}`, "global");
|
|
872
|
-
(e.storage === "session" ? D : E).set(t, e.bucket);
|
|
873
|
-
}), c = /* @__PURE__ */ new Map(), l = k({
|
|
874
|
-
source: {
|
|
875
|
-
allFeaturesStore: t,
|
|
876
|
-
resolvedFeaturesStore: n
|
|
877
|
-
},
|
|
878
|
-
effect: async ({ allFeaturesStore: e, resolvedFeaturesStore: t }, { id: n, decide: r, key: i }) => {
|
|
879
|
-
let a = t.find((e) => e.id === n && e.key === i);
|
|
880
|
-
if (a) return a;
|
|
881
|
-
let o = e[n];
|
|
882
|
-
if (!o) throw Error(`Feature with id '${n}' not found`);
|
|
883
|
-
if (q(o.feature)) return {
|
|
884
|
-
id: o.id,
|
|
885
|
-
bucket: !1,
|
|
886
|
-
key: i,
|
|
887
|
-
storage: o.feature.storage
|
|
888
|
-
};
|
|
889
|
-
let s = c.get(`${n}:${i}`);
|
|
890
|
-
if (s !== void 0) {
|
|
891
|
-
let e = await s;
|
|
892
|
-
return {
|
|
893
|
-
id: o.id,
|
|
894
|
-
bucket: e,
|
|
895
|
-
key: i,
|
|
896
|
-
storage: o.feature.storage
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
|
-
let l = r();
|
|
900
|
-
c.set(`${n}:${i}`, l);
|
|
901
|
-
let u = await l;
|
|
902
|
-
return {
|
|
903
|
-
id: o.id,
|
|
904
|
-
bucket: u,
|
|
905
|
-
key: i,
|
|
906
|
-
storage: o.feature.storage
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
});
|
|
910
|
-
I({
|
|
911
|
-
clock: i.register,
|
|
912
|
-
fn: (e) => {
|
|
913
|
-
let { id: t, feature: n } = e;
|
|
914
|
-
return {
|
|
915
|
-
id: t,
|
|
916
|
-
key: n.feature.key,
|
|
917
|
-
storage: n.feature.storage,
|
|
918
|
-
enabled: n.feature.enabled
|
|
919
|
-
};
|
|
920
|
-
},
|
|
921
|
-
target: o
|
|
922
|
-
}), I({
|
|
923
|
-
source: t,
|
|
924
|
-
clock: l.doneData,
|
|
925
|
-
filter: (e, t) => !q(e[t.id]?.feature),
|
|
926
|
-
fn: (e, t) => {
|
|
927
|
-
let { id: n, bucket: r, storage: i } = t, a = e[n]?.feature.key;
|
|
928
|
-
return a ? {
|
|
929
|
-
key: a,
|
|
930
|
-
id: n,
|
|
931
|
-
bucket: r,
|
|
932
|
-
storage: i
|
|
933
|
-
} : null;
|
|
934
|
-
},
|
|
935
|
-
target: s
|
|
936
|
-
});
|
|
937
|
-
let u = A({
|
|
938
|
-
allFeaturesStore: t,
|
|
939
|
-
resolvedFeaturesStore: n
|
|
940
|
-
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
941
|
-
let n = t.find((t) => t.id === e.id && t.key === e.feature.key);
|
|
942
|
-
return n ? {
|
|
943
|
-
id: e.id,
|
|
944
|
-
name: e.feature.name,
|
|
945
|
-
key: e.feature.key,
|
|
946
|
-
enabled: e.feature.enabled,
|
|
947
|
-
weight: e.feature.weight,
|
|
948
|
-
getBucket: () => ({
|
|
949
|
-
id: e.id,
|
|
950
|
-
bucket: n.bucket
|
|
951
|
-
}),
|
|
952
|
-
isResolved: !0
|
|
953
|
-
} : {
|
|
954
|
-
id: e.id,
|
|
955
|
-
name: e.feature.name,
|
|
956
|
-
key: e.feature.key,
|
|
957
|
-
enabled: e.feature.enabled,
|
|
958
|
-
weight: e.feature.weight,
|
|
959
|
-
getBucket: async () => await l(e.feature),
|
|
960
|
-
isResolved: !1
|
|
961
|
-
};
|
|
962
|
-
}));
|
|
963
|
-
I({
|
|
964
|
-
clock: l.doneData,
|
|
965
|
-
source: {
|
|
966
|
-
resolvedFeatures: n,
|
|
967
|
-
allFeatures: t
|
|
968
|
-
},
|
|
969
|
-
filter: ({ resolvedFeatures: e, allFeatures: t }, { id: n, key: r }) => !q(t[n]?.feature) && !e.some((e) => e.id === n && e.key === r),
|
|
970
|
-
fn: (e, t) => t,
|
|
971
|
-
target: e.eventBus.prepend((e) => ({
|
|
972
|
-
type: "feature_decide",
|
|
973
|
-
feature: e
|
|
974
|
-
}))
|
|
975
|
-
}), I({
|
|
976
|
-
clock: [o.doneData, l.doneData],
|
|
977
|
-
source: {
|
|
978
|
-
resolvedFeatures: n,
|
|
979
|
-
allFeatures: t
|
|
980
|
-
},
|
|
981
|
-
fn: ({ resolvedFeatures: e, allFeatures: t }, n) => !n || q(t[n.id]?.feature) || e.some((e) => e.id === n.id && e.key === n.key) ? e : [...e, n],
|
|
982
|
-
target: n
|
|
983
|
-
});
|
|
984
|
-
function d(e) {
|
|
985
|
-
return u.map((t) => t.find((t) => t.id === e));
|
|
986
|
-
}
|
|
987
|
-
let f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
988
|
-
function h(e) {
|
|
989
|
-
let t = f.get(e);
|
|
990
|
-
if (t) return t;
|
|
991
|
-
let n = d(e);
|
|
992
|
-
return f.set(e, n), n;
|
|
993
|
-
}
|
|
994
|
-
function g(e) {
|
|
995
|
-
return t.map((t) => t[e], { skipVoid: !1 });
|
|
996
|
-
}
|
|
997
|
-
function _(e) {
|
|
998
|
-
let t = F(async () => void 0, { skipVoid: !1 }), n = h(e), r = k({
|
|
999
|
-
source: n,
|
|
1000
|
-
effect: async (e) => {
|
|
1001
|
-
if (e) return async () => (await e.getBucket()).bucket;
|
|
1002
|
-
}
|
|
1003
|
-
});
|
|
1004
|
-
return I({
|
|
1005
|
-
clock: n,
|
|
1006
|
-
target: r
|
|
1007
|
-
}), I({
|
|
1008
|
-
clock: r.doneData,
|
|
1009
|
-
filter: (e) => e !== void 0,
|
|
1010
|
-
target: t
|
|
1011
|
-
}), r(), t;
|
|
1012
|
-
}
|
|
1013
|
-
function v(e) {
|
|
1014
|
-
let t = p.get(e);
|
|
1015
|
-
if (t) return t;
|
|
1016
|
-
let n = _(e);
|
|
1017
|
-
return p.set(e, n), n;
|
|
1018
|
-
}
|
|
1019
|
-
function y(e) {
|
|
1020
|
-
let t = v(e), n = F(void 0, { skipVoid: !1 }), r = k({
|
|
1021
|
-
source: t,
|
|
1022
|
-
mapParams: (e, t) => t,
|
|
1023
|
-
effect: N(async (e) => await e())
|
|
1024
|
-
});
|
|
1025
|
-
return I({
|
|
1026
|
-
clock: r.doneData,
|
|
1027
|
-
fn: (t) => {
|
|
1028
|
-
if (t !== void 0) return {
|
|
1029
|
-
id: e,
|
|
1030
|
-
bucket: t
|
|
1031
|
-
};
|
|
1032
|
-
},
|
|
1033
|
-
target: n
|
|
1034
|
-
}), I({
|
|
1035
|
-
clock: t,
|
|
1036
|
-
target: r
|
|
1037
|
-
}), r(), n;
|
|
1038
|
-
}
|
|
1039
|
-
function ee(e) {
|
|
1040
|
-
let t = m.get(e);
|
|
1041
|
-
if (t) return t;
|
|
1042
|
-
let n = y(e);
|
|
1043
|
-
return m.set(e, n), n;
|
|
1044
|
-
}
|
|
1045
|
-
return {
|
|
1046
|
-
register: a,
|
|
1047
|
-
getById: h,
|
|
1048
|
-
getByName: g,
|
|
1049
|
-
listStore: u,
|
|
1050
|
-
getEvokableFeature: v,
|
|
1051
|
-
getFeatureResult: ee
|
|
1052
|
-
};
|
|
1053
|
-
});
|
|
1054
|
-
function $e(e) {
|
|
1055
|
-
return R(Qe, e);
|
|
1056
|
-
}
|
|
1057
|
-
var et = (e, t, n) => {
|
|
1058
|
-
n.register({
|
|
1059
|
-
id: e,
|
|
1060
|
-
feature: t
|
|
1061
|
-
});
|
|
1062
|
-
}, J = M("history");
|
|
1063
|
-
function tt(e, t) {
|
|
824
|
+
}, q = M("history");
|
|
825
|
+
function $e(e, t) {
|
|
1064
826
|
return {
|
|
1065
|
-
id:
|
|
827
|
+
id: oe(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
1066
828
|
node: t,
|
|
1067
829
|
at: Date.now(),
|
|
1068
830
|
experienceId: e
|
|
1069
831
|
};
|
|
1070
832
|
}
|
|
1071
|
-
var
|
|
1072
|
-
let e =
|
|
1073
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
833
|
+
var et = L(() => {
|
|
834
|
+
let e = q.store({ entries: [] }), t = q.event(), n = q.event(), r = q.event(), i = q.event();
|
|
835
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, $e(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), $e(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
1074
836
|
function a(e, t) {
|
|
1075
837
|
let n = {
|
|
1076
838
|
lastStepIndex: -1,
|
|
@@ -1100,20 +862,20 @@ var nt = L(() => {
|
|
|
1100
862
|
entriesStore: e.map((e) => e.entries)
|
|
1101
863
|
};
|
|
1102
864
|
});
|
|
1103
|
-
function
|
|
1104
|
-
return R(
|
|
865
|
+
function tt() {
|
|
866
|
+
return R(et);
|
|
1105
867
|
}
|
|
1106
868
|
//#endregion
|
|
1107
869
|
//#region src/utils/events.ts
|
|
1108
|
-
var
|
|
870
|
+
var nt = 0, rt = (e) => {
|
|
1109
871
|
let t = F([]);
|
|
1110
872
|
return t.on(e, (e, t) => [...e, {
|
|
1111
|
-
id:
|
|
873
|
+
id: nt++,
|
|
1112
874
|
at: /* @__PURE__ */ new Date(),
|
|
1113
875
|
payload: t
|
|
1114
876
|
}]), t;
|
|
1115
|
-
},
|
|
1116
|
-
let e =
|
|
877
|
+
}, it = M("field"), at = L(() => {
|
|
878
|
+
let e = it.store({}), t = j(e, {
|
|
1117
879
|
register(e, t) {
|
|
1118
880
|
return {
|
|
1119
881
|
...e,
|
|
@@ -1161,13 +923,13 @@ var it = 0, at = (e) => {
|
|
|
1161
923
|
getByName: c
|
|
1162
924
|
};
|
|
1163
925
|
});
|
|
1164
|
-
function
|
|
1165
|
-
return R(
|
|
926
|
+
function ot() {
|
|
927
|
+
return R(at);
|
|
1166
928
|
}
|
|
1167
929
|
//#endregion
|
|
1168
930
|
//#region src/entities/step/step.ts
|
|
1169
|
-
var
|
|
1170
|
-
let e =
|
|
931
|
+
var st = M("step"), ct = L(() => {
|
|
932
|
+
let e = st.store({}), t = j(e, { register(e, t) {
|
|
1171
933
|
return {
|
|
1172
934
|
...e,
|
|
1173
935
|
[t.step.id]: t.step
|
|
@@ -1191,16 +953,16 @@ var lt = M("step"), ut = L(() => {
|
|
|
1191
953
|
indexStore: e
|
|
1192
954
|
};
|
|
1193
955
|
});
|
|
1194
|
-
function
|
|
1195
|
-
return R(
|
|
956
|
+
function lt() {
|
|
957
|
+
return R(ct);
|
|
1196
958
|
}
|
|
1197
|
-
function
|
|
959
|
+
function ut(e, t) {
|
|
1198
960
|
t.register(e);
|
|
1199
961
|
}
|
|
1200
962
|
//#endregion
|
|
1201
963
|
//#region src/entities/content/content.ts
|
|
1202
|
-
var
|
|
1203
|
-
let e =
|
|
964
|
+
var dt = M("content"), ft = L(() => {
|
|
965
|
+
let e = dt.store({}), t = j(e, {
|
|
1204
966
|
register(e, t) {
|
|
1205
967
|
return {
|
|
1206
968
|
...e,
|
|
@@ -1241,16 +1003,16 @@ var pt = M("content"), mt = L(() => {
|
|
|
1241
1003
|
indexStore: e
|
|
1242
1004
|
};
|
|
1243
1005
|
});
|
|
1244
|
-
function
|
|
1245
|
-
return R(
|
|
1006
|
+
function pt() {
|
|
1007
|
+
return R(ft);
|
|
1246
1008
|
}
|
|
1247
|
-
function
|
|
1009
|
+
function mt(e, t) {
|
|
1248
1010
|
t.register(e);
|
|
1249
1011
|
}
|
|
1250
1012
|
//#endregion
|
|
1251
1013
|
//#region src/entities/action/action.ts
|
|
1252
|
-
var
|
|
1253
|
-
let t =
|
|
1014
|
+
var ht = M("action"), gt = L(({ client: e }) => {
|
|
1015
|
+
let t = ht.store({}), n = j(t, { register(e, t) {
|
|
1254
1016
|
return {
|
|
1255
1017
|
...e,
|
|
1256
1018
|
[t.key]: {
|
|
@@ -1308,10 +1070,10 @@ var _t = M("action"), vt = L(({ client: e }) => {
|
|
|
1308
1070
|
getEvokableAction: s
|
|
1309
1071
|
};
|
|
1310
1072
|
});
|
|
1311
|
-
function
|
|
1312
|
-
return R(
|
|
1073
|
+
function _t(e) {
|
|
1074
|
+
return R(gt, e);
|
|
1313
1075
|
}
|
|
1314
|
-
var
|
|
1076
|
+
var vt = (e, t, n) => {
|
|
1315
1077
|
n.register({
|
|
1316
1078
|
key: e,
|
|
1317
1079
|
action: t
|
|
@@ -1319,7 +1081,7 @@ var bt = (e, t, n) => {
|
|
|
1319
1081
|
};
|
|
1320
1082
|
//#endregion
|
|
1321
1083
|
//#region src/entities/response/response-validation.ts
|
|
1322
|
-
function
|
|
1084
|
+
function J(e, t, n, r) {
|
|
1323
1085
|
return {
|
|
1324
1086
|
fieldKey: e.key,
|
|
1325
1087
|
userMessage: n,
|
|
@@ -1327,62 +1089,62 @@ function Y(e, t, n, r) {
|
|
|
1327
1089
|
value: t
|
|
1328
1090
|
};
|
|
1329
1091
|
}
|
|
1330
|
-
function
|
|
1092
|
+
function Y(e) {
|
|
1331
1093
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1332
1094
|
}
|
|
1333
|
-
function
|
|
1095
|
+
function yt(e) {
|
|
1334
1096
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1335
1097
|
}
|
|
1336
|
-
function
|
|
1098
|
+
function bt(e) {
|
|
1337
1099
|
try {
|
|
1338
1100
|
return JSON.stringify(e), !0;
|
|
1339
1101
|
} catch {
|
|
1340
1102
|
return !1;
|
|
1341
1103
|
}
|
|
1342
1104
|
}
|
|
1343
|
-
function
|
|
1105
|
+
function xt(e, t) {
|
|
1344
1106
|
return t.find((t) => t.key === e) ?? null;
|
|
1345
1107
|
}
|
|
1346
|
-
function
|
|
1108
|
+
function St(e, t) {
|
|
1347
1109
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1348
1110
|
}
|
|
1349
|
-
function
|
|
1350
|
-
if (e.type !== "object" ||
|
|
1111
|
+
function Ct(e, t) {
|
|
1112
|
+
if (e.type !== "object" || Y(t)) return null;
|
|
1351
1113
|
if (e.multiple) {
|
|
1352
|
-
if (!Array.isArray(t)) return
|
|
1114
|
+
if (!Array.isArray(t)) return J(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1353
1115
|
for (let n of t) {
|
|
1354
|
-
if (typeof n != "object" || !n) return
|
|
1355
|
-
if (!
|
|
1116
|
+
if (typeof n != "object" || !n) return J(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
1117
|
+
if (!bt(n)) return J(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1356
1118
|
}
|
|
1357
1119
|
return null;
|
|
1358
1120
|
}
|
|
1359
|
-
return Array.isArray(t) ?
|
|
1121
|
+
return Array.isArray(t) ? J(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? J(e, t, "This field expects an object value", "Field expects an object value.") : bt(t) ? null : J(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1360
1122
|
}
|
|
1361
|
-
function
|
|
1362
|
-
if (
|
|
1123
|
+
function wt(e, t) {
|
|
1124
|
+
if (Y(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1363
1125
|
let n = Array.isArray(t) ? t : [t];
|
|
1364
1126
|
if (e.type === "object") {
|
|
1365
1127
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1366
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
1128
|
+
return n.every((e) => r.has(JSON.stringify(e))) ? null : J(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
1367
1129
|
}
|
|
1368
1130
|
let r = e.options.map((e) => e.value);
|
|
1369
|
-
return n.every((e) => !
|
|
1131
|
+
return n.every((e) => !yt(e) || e === null ? !1 : r.includes(e)) ? null : J(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
1370
1132
|
}
|
|
1371
|
-
async function
|
|
1372
|
-
if (n.validation && !e(n.validation) && !
|
|
1133
|
+
async function Tt(t, n, r, i) {
|
|
1134
|
+
if (n.validation && !e(n.validation) && !Y(r)) {
|
|
1373
1135
|
let e = i ? {
|
|
1374
1136
|
$input: r,
|
|
1375
1137
|
responses: i
|
|
1376
1138
|
} : { $input: r }, a = await t(n.validation, e);
|
|
1377
|
-
if (typeof a == "string") return
|
|
1378
|
-
if (a === !1) return
|
|
1139
|
+
if (typeof a == "string") return J(n, r, a, `Field validation resulted in an error: ${a}.`);
|
|
1140
|
+
if (a === !1) return J(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
1379
1141
|
}
|
|
1380
|
-
return n.required &&
|
|
1142
|
+
return n.required && Y(r) ? J(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? J(n, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
1381
1143
|
}
|
|
1382
1144
|
//#endregion
|
|
1383
1145
|
//#region src/entities/response/response.ts
|
|
1384
|
-
var
|
|
1385
|
-
let t =
|
|
1146
|
+
var Et = M("response"), Dt = L(({ client: e }) => {
|
|
1147
|
+
let t = Et.store({}), r = P(), i = P(), a = j(t, {
|
|
1386
1148
|
register(e, t) {
|
|
1387
1149
|
return {
|
|
1388
1150
|
...e,
|
|
@@ -1421,7 +1183,7 @@ var Ot = M("response"), kt = L(({ client: e }) => {
|
|
|
1421
1183
|
...t,
|
|
1422
1184
|
...n
|
|
1423
1185
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1424
|
-
let o =
|
|
1186
|
+
let o = xt(t, e);
|
|
1425
1187
|
if (!o) {
|
|
1426
1188
|
r.push({
|
|
1427
1189
|
fieldKey: t,
|
|
@@ -1431,17 +1193,17 @@ var Ot = M("response"), kt = L(({ client: e }) => {
|
|
|
1431
1193
|
});
|
|
1432
1194
|
return;
|
|
1433
1195
|
}
|
|
1434
|
-
let c =
|
|
1196
|
+
let c = St(o, n), l = await Tt(s, o, c, a);
|
|
1435
1197
|
if (l) {
|
|
1436
1198
|
r.push(l);
|
|
1437
1199
|
return;
|
|
1438
1200
|
}
|
|
1439
|
-
let u =
|
|
1201
|
+
let u = Ct(o, c);
|
|
1440
1202
|
if (u) {
|
|
1441
1203
|
r.push(u);
|
|
1442
1204
|
return;
|
|
1443
1205
|
}
|
|
1444
|
-
let d =
|
|
1206
|
+
let d = wt(o, c);
|
|
1445
1207
|
if (d) {
|
|
1446
1208
|
r.push(d);
|
|
1447
1209
|
return;
|
|
@@ -1520,13 +1282,13 @@ var Ot = M("response"), kt = L(({ client: e }) => {
|
|
|
1520
1282
|
getByFieldName: _
|
|
1521
1283
|
};
|
|
1522
1284
|
});
|
|
1523
|
-
function
|
|
1524
|
-
return R(
|
|
1285
|
+
function Ot(e) {
|
|
1286
|
+
return R(Dt, e);
|
|
1525
1287
|
}
|
|
1526
1288
|
//#endregion
|
|
1527
1289
|
//#region src/entities/condition/condition.ts
|
|
1528
|
-
var
|
|
1529
|
-
let e =
|
|
1290
|
+
var kt = M("condition"), At = L(() => {
|
|
1291
|
+
let e = kt.store({}), t = j(e, { register(e, t) {
|
|
1530
1292
|
return {
|
|
1531
1293
|
...e,
|
|
1532
1294
|
[t.condition.id]: t.condition
|
|
@@ -1550,12 +1312,12 @@ var jt = M("condition"), Mt = L(() => {
|
|
|
1550
1312
|
indexStore: e
|
|
1551
1313
|
};
|
|
1552
1314
|
});
|
|
1553
|
-
function
|
|
1554
|
-
return R(
|
|
1315
|
+
function jt() {
|
|
1316
|
+
return R(At);
|
|
1555
1317
|
}
|
|
1556
1318
|
//#endregion
|
|
1557
1319
|
//#region src/utils/api-url.ts
|
|
1558
|
-
function
|
|
1320
|
+
function Mt() {
|
|
1559
1321
|
if (c()) {
|
|
1560
1322
|
let e = [
|
|
1561
1323
|
document.currentScript,
|
|
@@ -1570,7 +1332,7 @@ function Pt() {
|
|
|
1570
1332
|
}
|
|
1571
1333
|
//#endregion
|
|
1572
1334
|
//#region src/utils/search-params.ts
|
|
1573
|
-
function
|
|
1335
|
+
function Nt() {
|
|
1574
1336
|
if (!s()) return {};
|
|
1575
1337
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1576
1338
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -1588,13 +1350,13 @@ function Ft() {
|
|
|
1588
1350
|
}
|
|
1589
1351
|
//#endregion
|
|
1590
1352
|
//#region src/entities/session/session.ts
|
|
1591
|
-
var
|
|
1592
|
-
function
|
|
1353
|
+
var Pt = O("session", "global");
|
|
1354
|
+
function Ft() {
|
|
1593
1355
|
return m() ? 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)}`;
|
|
1594
1356
|
}
|
|
1595
|
-
function
|
|
1357
|
+
function It() {
|
|
1596
1358
|
if (!h()) return null;
|
|
1597
|
-
let e = E.get(
|
|
1359
|
+
let e = E.get(Pt);
|
|
1598
1360
|
if (!e.isSet()) return null;
|
|
1599
1361
|
try {
|
|
1600
1362
|
return e.json();
|
|
@@ -1602,8 +1364,8 @@ function Rt() {
|
|
|
1602
1364
|
return null;
|
|
1603
1365
|
}
|
|
1604
1366
|
}
|
|
1605
|
-
var
|
|
1606
|
-
let e =
|
|
1367
|
+
var Lt = L(() => {
|
|
1368
|
+
let e = It(), t = { id: e?.id ?? Ft() };
|
|
1607
1369
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1608
1370
|
let n = F(t), r = j(n, {
|
|
1609
1371
|
setIsUser: (e, t) => ({
|
|
@@ -1629,7 +1391,7 @@ var zt = L(() => {
|
|
|
1629
1391
|
source: n,
|
|
1630
1392
|
effect: (e) => {
|
|
1631
1393
|
if (h()) try {
|
|
1632
|
-
E.get(
|
|
1394
|
+
E.get(Pt).set(e);
|
|
1633
1395
|
} catch {}
|
|
1634
1396
|
}
|
|
1635
1397
|
});
|
|
@@ -1643,39 +1405,39 @@ var zt = L(() => {
|
|
|
1643
1405
|
removeIdentifier: r.removeIdentifier
|
|
1644
1406
|
};
|
|
1645
1407
|
});
|
|
1646
|
-
function
|
|
1647
|
-
return R(
|
|
1408
|
+
function Rt() {
|
|
1409
|
+
return R(Lt, void 0);
|
|
1648
1410
|
}
|
|
1649
1411
|
//#endregion
|
|
1650
1412
|
//#region src/utils/picked-config.ts
|
|
1651
|
-
function
|
|
1413
|
+
function zt() {
|
|
1652
1414
|
if (s()) return globalThis.window.pickedConfig;
|
|
1653
1415
|
}
|
|
1654
|
-
function
|
|
1655
|
-
if (s()) return
|
|
1416
|
+
function Bt() {
|
|
1417
|
+
if (s()) return zt()?.projectId;
|
|
1656
1418
|
}
|
|
1657
|
-
function
|
|
1419
|
+
function Vt() {
|
|
1658
1420
|
if (!c()) return;
|
|
1659
1421
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1660
1422
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1661
1423
|
}
|
|
1662
|
-
function
|
|
1424
|
+
function Ht(e) {
|
|
1663
1425
|
if (e.projectId) return e.projectId;
|
|
1664
|
-
let t =
|
|
1426
|
+
let t = Bt();
|
|
1665
1427
|
if (t) return t;
|
|
1666
|
-
let n =
|
|
1428
|
+
let n = Vt();
|
|
1667
1429
|
if (n) return n;
|
|
1668
1430
|
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.");
|
|
1669
1431
|
}
|
|
1670
1432
|
//#endregion
|
|
1671
1433
|
//#region src/utils/render-string.ts
|
|
1672
|
-
function
|
|
1434
|
+
function X(e) {
|
|
1673
1435
|
return e == null || e === "" || Number.isNaN(e);
|
|
1674
1436
|
}
|
|
1675
|
-
var
|
|
1676
|
-
default: (e, t) =>
|
|
1677
|
-
append: (e, t) => t && !
|
|
1678
|
-
prepend: (e, t) => t && !
|
|
1437
|
+
var Ut = {
|
|
1438
|
+
default: (e, t) => X(e) ? String(t ?? "") : String(e),
|
|
1439
|
+
append: (e, t) => t && !X(e) ? `${e} ${t}` : e,
|
|
1440
|
+
prepend: (e, t) => t && !X(e) ? `${t} ${e}` : e,
|
|
1679
1441
|
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
1680
1442
|
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
1681
1443
|
capitalize: (e) => typeof e == "string" ? e.charAt(0).toUpperCase() + e.slice(1) : e,
|
|
@@ -1693,24 +1455,24 @@ var Gt = {
|
|
|
1693
1455
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1694
1456
|
}
|
|
1695
1457
|
};
|
|
1696
|
-
function
|
|
1458
|
+
function Wt(e) {
|
|
1697
1459
|
return typeof e == "object" && !!e;
|
|
1698
1460
|
}
|
|
1699
|
-
function
|
|
1461
|
+
function Gt(e, t) {
|
|
1700
1462
|
let n = t;
|
|
1701
|
-
for (let t of e.split(".")) if (
|
|
1463
|
+
for (let t of e.split(".")) if (Wt(n) && t in n) n = n[t];
|
|
1702
1464
|
else return;
|
|
1703
1465
|
return typeof n == "function" ? n() : n;
|
|
1704
1466
|
}
|
|
1705
|
-
function
|
|
1706
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1467
|
+
function Kt(e, t) {
|
|
1468
|
+
let n = e.split("|").map((e) => e.trim()), r = Gt(n.shift() ?? "", t);
|
|
1707
1469
|
for (let e of n) {
|
|
1708
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1470
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Ut[i];
|
|
1709
1471
|
o && (r = o(r, a));
|
|
1710
1472
|
}
|
|
1711
|
-
return
|
|
1473
|
+
return X(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1712
1474
|
}
|
|
1713
|
-
function
|
|
1475
|
+
function qt(e, t) {
|
|
1714
1476
|
let n = "", r = 0;
|
|
1715
1477
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1716
1478
|
r += 2;
|
|
@@ -1722,19 +1484,19 @@ function Yt(e, t) {
|
|
|
1722
1484
|
}
|
|
1723
1485
|
i += e[r++];
|
|
1724
1486
|
}
|
|
1725
|
-
n +=
|
|
1487
|
+
n += Kt(i.trim(), t);
|
|
1726
1488
|
} else n += e[r++];
|
|
1727
1489
|
return n;
|
|
1728
1490
|
}
|
|
1729
1491
|
//#endregion
|
|
1730
1492
|
//#region src/utils/preview-session.ts
|
|
1731
|
-
var
|
|
1732
|
-
function
|
|
1733
|
-
return !s() || !g() ? !1 : !!
|
|
1493
|
+
var Jt = "preview-token";
|
|
1494
|
+
function Yt() {
|
|
1495
|
+
return !s() || !g() ? !1 : !!Nt()[Jt]?.[0];
|
|
1734
1496
|
}
|
|
1735
1497
|
//#endregion
|
|
1736
1498
|
//#region src/picked.ts
|
|
1737
|
-
var
|
|
1499
|
+
var Xt = class {
|
|
1738
1500
|
static logger = r;
|
|
1739
1501
|
options;
|
|
1740
1502
|
dataSource = null;
|
|
@@ -1753,51 +1515,51 @@ var Qt = class {
|
|
|
1753
1515
|
apiUrl;
|
|
1754
1516
|
dashboardUrl;
|
|
1755
1517
|
documentationSiteUrl;
|
|
1756
|
-
session =
|
|
1757
|
-
searchParams =
|
|
1758
|
-
history =
|
|
1759
|
-
components =
|
|
1518
|
+
session = Rt();
|
|
1519
|
+
searchParams = Nt();
|
|
1520
|
+
history = tt();
|
|
1521
|
+
components = Ce({ client: this });
|
|
1760
1522
|
experienceInstances = C({ client: this });
|
|
1761
|
-
experiences =
|
|
1762
|
-
frameworks =
|
|
1763
|
-
predicates =
|
|
1764
|
-
features =
|
|
1765
|
-
conditions =
|
|
1766
|
-
fields =
|
|
1767
|
-
responses =
|
|
1768
|
-
steps =
|
|
1769
|
-
contents =
|
|
1770
|
-
actions =
|
|
1523
|
+
experiences = he({ client: this });
|
|
1524
|
+
frameworks = De({ client: this });
|
|
1525
|
+
predicates = Ze({ client: this });
|
|
1526
|
+
features = re({ client: this });
|
|
1527
|
+
conditions = jt();
|
|
1528
|
+
fields = ot();
|
|
1529
|
+
responses = Ot({ client: this });
|
|
1530
|
+
steps = lt();
|
|
1531
|
+
contents = pt();
|
|
1532
|
+
actions = _t({ client: this });
|
|
1771
1533
|
conditionResults = w();
|
|
1772
|
-
stateSnapshotStore =
|
|
1773
|
-
evaluateRuleLogicFx =
|
|
1534
|
+
stateSnapshotStore = Ae({ client: this });
|
|
1535
|
+
evaluateRuleLogicFx = Re({ client: this });
|
|
1774
1536
|
start;
|
|
1775
1537
|
readyStore;
|
|
1776
1538
|
preconditionPassedStore;
|
|
1777
1539
|
conditionPassedStore;
|
|
1778
1540
|
lifecycleStageStore;
|
|
1779
|
-
lifecycle =
|
|
1541
|
+
lifecycle = Je({ client: this });
|
|
1780
1542
|
renderStringFx = k({
|
|
1781
1543
|
source: this.responses.listStore,
|
|
1782
1544
|
effect: (e, { template: t, context: n }) => {
|
|
1783
1545
|
let r = {};
|
|
1784
1546
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1785
|
-
return
|
|
1547
|
+
return qt(t, {
|
|
1786
1548
|
...n,
|
|
1787
1549
|
responses: r
|
|
1788
1550
|
});
|
|
1789
1551
|
}
|
|
1790
1552
|
});
|
|
1791
1553
|
constructor(e) {
|
|
1792
|
-
this.events =
|
|
1554
|
+
this.events = rt(this.eventBus), this.projectId = Ht(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({
|
|
1793
1555
|
type: "load",
|
|
1794
|
-
version:
|
|
1556
|
+
version: ae()
|
|
1795
1557
|
}), this.maybeStartPreviewChannel();
|
|
1796
1558
|
}
|
|
1797
1559
|
dataProviderFor(e) {
|
|
1798
1560
|
let t = e ?? "", n = this.dataProviders.get(t);
|
|
1799
1561
|
if (n) return n;
|
|
1800
|
-
let r = import("../provider-
|
|
1562
|
+
let r = import("../provider-Dx6VjvZg.js").then((t) => t.createPickedDataProvider({
|
|
1801
1563
|
apiUrl: this.apiUrl,
|
|
1802
1564
|
projectId: this.projectId,
|
|
1803
1565
|
...e !== void 0 && { previewToken: e }
|
|
@@ -1813,24 +1575,24 @@ var Qt = class {
|
|
|
1813
1575
|
return (await this.dataProviderFor(t?.previewToken)).getContent(e, t?.signal === void 0 ? void 0 : { signal: t.signal });
|
|
1814
1576
|
}
|
|
1815
1577
|
maybeStartPreviewChannel() {
|
|
1816
|
-
|
|
1578
|
+
Yt() && import("../preview-channel-CSr96XAo.js").then((e) => e.initPreviewChannel(this)).catch(() => void 0);
|
|
1817
1579
|
}
|
|
1818
1580
|
registerFramework = (e) => {
|
|
1819
|
-
|
|
1581
|
+
Oe(e, this.frameworks);
|
|
1820
1582
|
};
|
|
1821
1583
|
registerComponent = (e, t) => {
|
|
1822
|
-
|
|
1584
|
+
we(e, t, this.components);
|
|
1823
1585
|
};
|
|
1824
1586
|
registerPlugin = (e) => {
|
|
1825
|
-
|
|
1587
|
+
ve(this, e, this.plugins);
|
|
1826
1588
|
let t = this.plugins[e.name];
|
|
1827
1589
|
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1828
1590
|
};
|
|
1829
1591
|
registerFeature = (e, t) => {
|
|
1830
|
-
|
|
1592
|
+
ne(e, t, this.features);
|
|
1831
1593
|
};
|
|
1832
1594
|
registerPredicate = (e, t) => {
|
|
1833
|
-
|
|
1595
|
+
Qe(e, t, this.predicates);
|
|
1834
1596
|
};
|
|
1835
1597
|
registerCondition = (e) => {
|
|
1836
1598
|
this.conditions.register(e);
|
|
@@ -1839,19 +1601,19 @@ var Qt = class {
|
|
|
1839
1601
|
this.fields.register(e);
|
|
1840
1602
|
};
|
|
1841
1603
|
registerStep = (e) => {
|
|
1842
|
-
|
|
1604
|
+
ut(e, this.steps);
|
|
1843
1605
|
};
|
|
1844
1606
|
registerContent = (e) => {
|
|
1845
|
-
|
|
1607
|
+
mt(e, this.contents);
|
|
1846
1608
|
};
|
|
1847
1609
|
patchContent = (e, t) => {
|
|
1848
1610
|
this.contents.patch(e, t);
|
|
1849
1611
|
};
|
|
1850
1612
|
registerAction = (e, t) => {
|
|
1851
|
-
|
|
1613
|
+
vt(e, t, this.actions);
|
|
1852
1614
|
};
|
|
1853
1615
|
registerExperience = (e) => {
|
|
1854
|
-
e.component &&
|
|
1616
|
+
e.component && we(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1855
1617
|
};
|
|
1856
1618
|
launchExperienceById = async (e, t) => {
|
|
1857
1619
|
this.experiences.launch({
|
|
@@ -1894,12 +1656,12 @@ var Qt = class {
|
|
|
1894
1656
|
this.registerFeature(e, n);
|
|
1895
1657
|
}), this.searchParams.feature && this.searchParams.feature.forEach((e) => {
|
|
1896
1658
|
try {
|
|
1897
|
-
let
|
|
1898
|
-
if (!t
|
|
1899
|
-
let r =
|
|
1900
|
-
this.registerFeature(
|
|
1659
|
+
let t = ie(e);
|
|
1660
|
+
if (!t) return;
|
|
1661
|
+
let { id: n, bucket: r } = t;
|
|
1662
|
+
this.registerFeature(n, {
|
|
1901
1663
|
key: `${r}`,
|
|
1902
|
-
name:
|
|
1664
|
+
name: n,
|
|
1903
1665
|
decide: () => r,
|
|
1904
1666
|
storage: "session"
|
|
1905
1667
|
});
|
|
@@ -1933,8 +1695,8 @@ var Qt = class {
|
|
|
1933
1695
|
});
|
|
1934
1696
|
}
|
|
1935
1697
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1936
|
-
},
|
|
1937
|
-
async function
|
|
1698
|
+
}, Zt = "application/picked-javascript", Qt = "application/picked-module", $t = "data-picked-hydrated";
|
|
1699
|
+
async function en(e) {
|
|
1938
1700
|
if (!("document" in globalThis)) return;
|
|
1939
1701
|
let t = "application/picked-module", n = "data-picked-hydrated";
|
|
1940
1702
|
function r(e) {
|
|
@@ -1963,42 +1725,42 @@ async function nn(e) {
|
|
|
1963
1725
|
a && await a;
|
|
1964
1726
|
}
|
|
1965
1727
|
}
|
|
1966
|
-
function
|
|
1967
|
-
return `<script>(${
|
|
1728
|
+
function tn() {
|
|
1729
|
+
return `<script>(${en.toString()})(document)<\/script>`;
|
|
1968
1730
|
}
|
|
1969
1731
|
//#endregion
|
|
1970
1732
|
//#region src/utils/html-asset-value.ts
|
|
1971
|
-
function
|
|
1733
|
+
function nn(e) {
|
|
1972
1734
|
return typeof e == "object" && !!e && "id" in e && typeof e.id == "string" && "content" in e && (typeof e.content == "string" || e.content === null);
|
|
1973
1735
|
}
|
|
1974
1736
|
//#endregion
|
|
1975
1737
|
//#region src/entities/component/lazyComponent.ts
|
|
1976
|
-
function
|
|
1738
|
+
function rn(e) {
|
|
1977
1739
|
return {
|
|
1978
1740
|
$$type: "lazy-component",
|
|
1979
1741
|
load: e
|
|
1980
1742
|
};
|
|
1981
1743
|
}
|
|
1982
|
-
function
|
|
1744
|
+
function an(e) {
|
|
1983
1745
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1984
1746
|
}
|
|
1985
1747
|
//#endregion
|
|
1986
1748
|
//#region src/entities/content/reference.ts
|
|
1987
|
-
function
|
|
1749
|
+
function Z(e) {
|
|
1988
1750
|
return typeof e == "object" && !!e && !Array.isArray(e) && "contentEntryId" in e && typeof e.contentEntryId == "string";
|
|
1989
1751
|
}
|
|
1990
|
-
function
|
|
1991
|
-
return
|
|
1752
|
+
function Q(e) {
|
|
1753
|
+
return Z(e) ? e.contentEntryId : null;
|
|
1992
1754
|
}
|
|
1993
|
-
function
|
|
1755
|
+
function $(e) {
|
|
1994
1756
|
let t = Array.isArray(e) ? e : [e], n = [];
|
|
1995
|
-
for (let e of t)
|
|
1757
|
+
for (let e of t) Z(e) && n.push(e.contentEntryId);
|
|
1996
1758
|
return n;
|
|
1997
1759
|
}
|
|
1998
|
-
function
|
|
1760
|
+
function on(e, t) {
|
|
1999
1761
|
return t === null ? null : e[t] ?? null;
|
|
2000
1762
|
}
|
|
2001
|
-
function
|
|
1763
|
+
function sn(e, t) {
|
|
2002
1764
|
let n = [];
|
|
2003
1765
|
for (let r of t) {
|
|
2004
1766
|
let t = e[r];
|
|
@@ -2006,29 +1768,29 @@ function un(e, t) {
|
|
|
2006
1768
|
}
|
|
2007
1769
|
return n;
|
|
2008
1770
|
}
|
|
2009
|
-
function
|
|
2010
|
-
if (
|
|
2011
|
-
let n =
|
|
2012
|
-
return e.indexStore.map((e) =>
|
|
1771
|
+
function cn(e, t) {
|
|
1772
|
+
if (ue.store(t)) return A(t, e.indexStore, (e, t) => on(t, Q(e)));
|
|
1773
|
+
let n = Q(t);
|
|
1774
|
+
return e.indexStore.map((e) => on(e, n), { skipVoid: !1 });
|
|
2013
1775
|
}
|
|
2014
|
-
function
|
|
2015
|
-
if (
|
|
2016
|
-
let n =
|
|
2017
|
-
return e.indexStore.map((e) =>
|
|
1776
|
+
function ln(e, t) {
|
|
1777
|
+
if (ue.store(t)) return A(t, e.indexStore, (e, t) => sn(t, $(e)));
|
|
1778
|
+
let n = $(t);
|
|
1779
|
+
return e.indexStore.map((e) => sn(e, n), { skipVoid: !1 });
|
|
2018
1780
|
}
|
|
2019
1781
|
//#endregion
|
|
2020
1782
|
//#region src/exports.ts
|
|
2021
|
-
var
|
|
2022
|
-
let t = new
|
|
1783
|
+
var un = (e) => {
|
|
1784
|
+
let t = new Xt(e);
|
|
2023
1785
|
return u(t), t;
|
|
2024
1786
|
};
|
|
2025
1787
|
//#endregion
|
|
2026
1788
|
//#region src/typed-content.ts
|
|
2027
|
-
function
|
|
1789
|
+
function dn(e) {
|
|
2028
1790
|
return typeof e.data == "object";
|
|
2029
1791
|
}
|
|
2030
|
-
function
|
|
2031
|
-
return e.map((e) => !e || !
|
|
1792
|
+
function fn(e) {
|
|
1793
|
+
return e.map((e) => !e || !dn(e) ? null : e, { skipVoid: !1 });
|
|
2032
1794
|
}
|
|
2033
1795
|
//#endregion
|
|
2034
|
-
export {
|
|
1796
|
+
export { $t as PICKED_HYDRATED_ATTR, Qt as PICKED_MODULE_SCRIPT_TYPE, Zt as PICKED_SCRIPT_TYPE, Jt as PREVIEW_TOKEN_PARAM, Xt as Picked, tn as buildRehydrateBootstrap, un as createClient, _e as createPluginEffect, O as createStorageKey, cn as deriveReference, ln as deriveReferences, n as evaluateRuleLogic, zt as getPickedConfig, Z as isContentReference, nn as isHtmlAssetValue, g as isInsideIframe, an as isLazyLoader, v as isPickedRoot, Yt as isPreviewSession, rn as lazyComponent, E as localStore, le as onInertScriptSubtrees, Q as readReferenceId, $ as readReferenceIds, en as rehydrateScripts, se as reportInertScriptSubtrees, ce as resetInertScriptReport, D as sessionStore, te as subscribe, d as supportsCookies, m as supportsCryptoRandomUUID, c as supportsDocument, i as supportsHistory, f as supportsIntersectionObserver, h as supportsLocalStorage, a as supportsLocation, l as supportsSessionStorage, _ as supportsShadowRoot, o as supportsWebComponents, s as supportsWindow, fn as toTypedContentStore };
|