@picked/client 0.0.62-next.12 → 0.0.62-next.2
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/api-C-Q9t21v.cjs +1 -0
- package/dist/{api-BTbEUnGh.js → api-Cfb-8mqu.js} +1 -1
- package/dist/cjs/form/index.js +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/image-optimisation-service.md +6 -6
- package/dist/docs/sdk/content-security-policy.md +7 -8
- package/dist/docs/sdk/fields.md +2 -2
- package/dist/docs/workspaces.mdx +1 -1
- package/dist/esm/form/index.js +1 -1
- package/dist/esm/index.js +472 -1015
- package/dist/esm/plugins/create-experience/index.js +1 -1
- package/dist/esm/plugins/dynamic-experiences/index.js +60 -133
- package/dist/esm/plugins/experience-browser-storage/index.js +6 -9
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/plugins/single-page-app/index.js +1 -1
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/server/index.js +13 -23
- package/dist/experience-instance-DC2gKwA6.cjs +1 -0
- package/dist/experience-instance-DJaNc5Ob.js +486 -0
- package/dist/rules-logic-BTIxfrJJ.js +240 -0
- package/dist/rules-logic-DNLOv90w.cjs +1 -0
- package/dist/types/entities/action/action.d.ts +3 -6
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/component/component.d.ts +2 -39
- package/dist/types/entities/component/component.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +113 -69
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +2 -17
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts +2 -26
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/framework/framework.d.ts +3 -24
- package/dist/types/entities/framework/framework.d.ts.map +1 -1
- package/dist/types/entities/plugin/plugin.d.ts +1 -32
- package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
- package/dist/types/entities/predicate/predicate.d.ts +3 -24
- package/dist/types/entities/predicate/predicate.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +2 -17
- package/dist/types/entities/step/step.d.ts.map +1 -1
- package/dist/types/exports.d.ts +4 -8
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +1 -1
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +186 -141
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -2
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +1 -18
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +1 -63
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/web-components/plugin.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +0 -7
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts +9 -4
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/dist/types/utils/state-snaphot.d.ts +26 -0
- package/dist/types/utils/state-snaphot.d.ts.map +1 -0
- package/dist/types/utils/user-session.d.ts +12 -0
- package/dist/types/utils/user-session.d.ts.map +1 -0
- package/package.json +2 -12
- package/dist/api-DDd_Zf11.cjs +0 -1
- package/dist/cjs/plugins/dom-observer/index.js +0 -1
- package/dist/dom-C3C6Fmwz.cjs +0 -1
- package/dist/dom-DGePXPpM.js +0 -84
- package/dist/esm/plugins/dom-observer/index.js +0 -87
- package/dist/experience-instance-DImym3m_.js +0 -419
- package/dist/experience-instance-DygAdzbn.cjs +0 -1
- package/dist/rules-logic-D_CVBuv7.js +0 -13
- package/dist/rules-logic-H6P8xwHF.cjs +0 -1
- package/dist/types/entities/content/content.d.ts +0 -37
- package/dist/types/entities/content/content.d.ts.map +0 -1
- package/dist/types/entities/session/session.d.ts +0 -45
- package/dist/types/entities/session/session.d.ts.map +0 -1
- package/dist/types/lifecycle/lifecycle.d.ts +0 -47
- package/dist/types/lifecycle/lifecycle.d.ts.map +0 -1
- package/dist/types/lifecycle/rules-logic.d.ts +0 -24
- package/dist/types/lifecycle/rules-logic.d.ts.map +0 -1
- package/dist/types/lifecycle/state-snapshot.d.ts +0 -37
- package/dist/types/lifecycle/state-snapshot.d.ts.map +0 -1
- package/dist/types/plugins/dom-observer/index.d.ts +0 -3
- package/dist/types/plugins/dom-observer/index.d.ts.map +0 -1
- package/dist/types/plugins/dom-observer/plugin.d.ts +0 -50
- package/dist/types/plugins/dom-observer/plugin.d.ts.map +0 -1
- /package/dist/{id-Cg7fVl1O.cjs → id-Bv44ilEo.cjs} +0 -0
- /package/dist/{id-n2yrHvNo.js → id-CRqy981z.js} +0 -0
- /package/dist/{object-DvUDOytC.js → object-C82v79xc.js} +0 -0
- /package/dist/{object-ThO1DEyl.cjs → object-CUJOjanb.cjs} +0 -0
- /package/dist/{storage-hOHCCXvP.js → storage-6Xk0uAxB.js} +0 -0
- /package/dist/{storage-BXSlLTRa.cjs → storage-B6lQtc4-.cjs} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,174 +1,108 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as e, t } from "../rules-logic-BTIxfrJJ.js";
|
|
2
|
+
import { t as n } from "../object-C82v79xc.js";
|
|
3
3
|
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
|
-
import { a as g,
|
|
6
|
-
import { i as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { createFactory as I, invoke as L } from "@withease/factories";
|
|
5
|
+
import { a as g, c as _, i as v, l as ee, n as te, o as ne, r as re, s as y } from "../experience-instance-DJaNc5Ob.js";
|
|
6
|
+
import { i as ie, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
|
|
7
|
+
import { n as ae, r as oe } from "../api-Cfb-8mqu.js";
|
|
8
|
+
import { t as se } from "../id-CRqy981z.js";
|
|
9
|
+
import { attach as C, combine as w, createApi as T, createDomain as E, createEffect as D, createEvent as O, createStore as k, sample as A } from "effector";
|
|
10
|
+
import { createFactory as j, invoke as M } from "@withease/factories";
|
|
12
11
|
//#region src/entities/experience/experience.ts
|
|
13
|
-
var
|
|
14
|
-
let
|
|
12
|
+
var N = E("experience"), ce = j(({ client: e, experience: t }) => {
|
|
13
|
+
let n = N.store(t), r = T(n, { merge(e, t) {
|
|
15
14
|
return {
|
|
16
15
|
...e,
|
|
17
16
|
...t.experience
|
|
18
17
|
};
|
|
19
|
-
} }),
|
|
18
|
+
} }), i = n.map((e) => ({
|
|
20
19
|
name: e.name,
|
|
21
20
|
decisionLogic: e.condition,
|
|
22
21
|
targetSelectors: e.targets,
|
|
23
22
|
initializeOpenLogic: e.initializeOpen
|
|
24
|
-
})),
|
|
25
|
-
let r = e.nodes.filter(
|
|
23
|
+
})), a = w(n, e.components.listStore, (e, t) => (e.componentName ? t.find((t) => t.name === e.componentName) : void 0) || t.find((t) => t.name === `experience:${e.id}`) || t.find((e) => e.name === "experience"), { skipVoid: !1 }), o = w(n, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
|
|
24
|
+
let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(re).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
|
|
26
25
|
return {
|
|
27
26
|
steps: r,
|
|
28
27
|
nodes: e.nodes,
|
|
29
28
|
edges: e.edges,
|
|
30
29
|
conditions: i
|
|
31
30
|
};
|
|
32
|
-
}),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
isUser: e.session.store.map((e) => e.isUser, { skipVoid: !1 }),
|
|
44
|
-
config: o
|
|
45
|
-
}),
|
|
46
|
-
effect: async ({ preconditionPassed: i, isUser: a, config: o }) => {
|
|
47
|
-
if (!i || !a) return !1;
|
|
48
|
-
let { decisionLogic: s, targetSelectors: c } = o;
|
|
49
|
-
return c.length === 0 || _(c, r.id).length < 1 ? !1 : s === void 0 ? !0 : t(s) ? await n(e, s) === !0 : !0;
|
|
50
|
-
}
|
|
51
|
-
}), p = M(async () => {
|
|
52
|
-
if (!e.contentLoader) return !0;
|
|
53
|
-
try {
|
|
54
|
-
await e.contentLoader({
|
|
55
|
-
id: r.id,
|
|
56
|
-
key: r.key
|
|
57
|
-
});
|
|
58
|
-
} catch {
|
|
59
|
-
`${r.id}`;
|
|
60
|
-
}
|
|
61
|
-
return !0;
|
|
62
|
-
}), m = N(), h = N(), g = R.createStore(void 0, { skipVoid: !1 }).on(m, (e, t) => t).on(h, (e, t) => t);
|
|
63
|
-
return F({
|
|
64
|
-
clock: m,
|
|
65
|
-
target: f
|
|
66
|
-
}), F({
|
|
67
|
-
clock: f.doneData,
|
|
68
|
-
source: g,
|
|
69
|
-
filter: (e, t) => t,
|
|
70
|
-
fn: (e) => e,
|
|
71
|
-
target: d
|
|
72
|
-
}), F({
|
|
73
|
-
clock: f.doneData,
|
|
74
|
-
filter: Boolean,
|
|
75
|
-
target: p
|
|
76
|
-
}), F({
|
|
77
|
-
clock: h,
|
|
78
|
-
source: g,
|
|
79
|
-
fn: (e) => e,
|
|
80
|
-
target: d
|
|
81
|
-
}), F({
|
|
82
|
-
clock: h,
|
|
83
|
-
target: p
|
|
84
|
-
}), u = {
|
|
85
|
-
id: r.id,
|
|
86
|
-
key: r.key,
|
|
87
|
-
name: r.name,
|
|
88
|
-
configStore: o,
|
|
89
|
-
treeStore: c,
|
|
90
|
-
componentStore: s,
|
|
91
|
-
actions: l,
|
|
92
|
-
merge: a.merge,
|
|
93
|
-
initialiseFx: d,
|
|
94
|
-
shouldInitialiseFx: f,
|
|
95
|
-
initialiseRequested: m,
|
|
96
|
-
initialiseDirectly: h,
|
|
97
|
-
prepareExperienceContentFx: p
|
|
98
|
-
}, u;
|
|
31
|
+
}), s = t.actions ?? [];
|
|
32
|
+
return {
|
|
33
|
+
id: t.id,
|
|
34
|
+
key: t.key,
|
|
35
|
+
name: t.name,
|
|
36
|
+
configStore: i,
|
|
37
|
+
treeStore: o,
|
|
38
|
+
componentStore: a,
|
|
39
|
+
actions: s,
|
|
40
|
+
merge: r.merge
|
|
41
|
+
};
|
|
99
42
|
});
|
|
100
|
-
function
|
|
101
|
-
return
|
|
43
|
+
function le(e) {
|
|
44
|
+
return M(ce, e);
|
|
102
45
|
}
|
|
103
|
-
var
|
|
104
|
-
let t =
|
|
46
|
+
var ue = j(({ client: e }) => {
|
|
47
|
+
let t = N.store({}), n = T(t, { register(e, t) {
|
|
105
48
|
return {
|
|
106
49
|
...e,
|
|
107
50
|
[t.id]: t
|
|
108
51
|
};
|
|
109
|
-
} })
|
|
110
|
-
|
|
52
|
+
} });
|
|
53
|
+
function r(r) {
|
|
54
|
+
let i = t.getState()[r.id];
|
|
55
|
+
if (i) {
|
|
56
|
+
i.merge({
|
|
57
|
+
experience: r,
|
|
58
|
+
strategy: "override"
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let a = le({
|
|
111
63
|
client: e,
|
|
112
|
-
experience:
|
|
113
|
-
}));
|
|
114
|
-
});
|
|
115
|
-
F({
|
|
116
|
-
clock: r,
|
|
117
|
-
source: t,
|
|
118
|
-
filter: (e, t) => e[t.id] !== void 0,
|
|
119
|
-
fn: (e, t) => ({
|
|
120
|
-
existing: e[t.id],
|
|
121
|
-
experience: t
|
|
122
|
-
})
|
|
123
|
-
}).watch(({ existing: e, experience: t }) => {
|
|
124
|
-
e?.merge({
|
|
125
|
-
experience: t,
|
|
126
|
-
strategy: "override"
|
|
64
|
+
experience: r
|
|
127
65
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
fn: (e, t) => t,
|
|
133
|
-
target: i
|
|
134
|
-
});
|
|
135
|
-
let a = t.map((e) => Object.values(e));
|
|
136
|
-
function o(e) {
|
|
66
|
+
n.register(a);
|
|
67
|
+
}
|
|
68
|
+
let i = t.map((e) => Object.values(e));
|
|
69
|
+
function a(e) {
|
|
137
70
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
138
71
|
}
|
|
139
|
-
function
|
|
72
|
+
function o(e) {
|
|
140
73
|
return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
|
|
141
74
|
}
|
|
142
|
-
let
|
|
75
|
+
let s = C({
|
|
143
76
|
source: t,
|
|
144
|
-
effect: (
|
|
145
|
-
let
|
|
146
|
-
if (!
|
|
147
|
-
"key" in
|
|
77
|
+
effect: async (t, n) => {
|
|
78
|
+
let r = "key" in n ? Object.values(t).find((e) => e.key === n.key) : t[n.id];
|
|
79
|
+
if (!r) {
|
|
80
|
+
"key" in n ? `${n.key}` : `${n.id}`;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
let { options: i } = n;
|
|
84
|
+
if (i?.bypassCondition) {
|
|
85
|
+
P(e, r, i);
|
|
148
86
|
return;
|
|
149
87
|
}
|
|
150
|
-
|
|
151
|
-
r?.bypassCondition ? n.initialiseDirectly(r) : n.initialiseRequested(r);
|
|
88
|
+
await I(e, r) && P(e, r, i);
|
|
152
89
|
}
|
|
153
90
|
});
|
|
154
91
|
return {
|
|
155
92
|
register: r,
|
|
156
|
-
get:
|
|
157
|
-
getById:
|
|
158
|
-
getByKey:
|
|
159
|
-
launch:
|
|
160
|
-
open:
|
|
93
|
+
get: a,
|
|
94
|
+
getById: a,
|
|
95
|
+
getByKey: o,
|
|
96
|
+
launch: s,
|
|
97
|
+
open: C({
|
|
161
98
|
source: {
|
|
162
99
|
experiences: t,
|
|
163
100
|
instances: e.experienceInstances.listStore
|
|
164
101
|
},
|
|
165
|
-
effect:
|
|
166
|
-
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => e.experienceId === r
|
|
167
|
-
if (i.length > 0)
|
|
168
|
-
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
await c("key" in n ? {
|
|
102
|
+
effect: ({ experiences: e, instances: t }, n) => {
|
|
103
|
+
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => r && e.experienceId === r.id);
|
|
104
|
+
if (i.length > 0) for (let e of i) e.open();
|
|
105
|
+
else s("key" in n ? {
|
|
172
106
|
key: n.key,
|
|
173
107
|
options: {
|
|
174
108
|
...n.options,
|
|
@@ -183,29 +117,26 @@ var ae = I(({ client: e }) => {
|
|
|
183
117
|
});
|
|
184
118
|
}
|
|
185
119
|
}),
|
|
186
|
-
listStore:
|
|
187
|
-
initialiseExperiencesFx: O({
|
|
188
|
-
source: a,
|
|
189
|
-
effect: (e) => {
|
|
190
|
-
for (let t of e) t.initialiseRequested(void 0);
|
|
191
|
-
}
|
|
192
|
-
})
|
|
120
|
+
listStore: i
|
|
193
121
|
};
|
|
194
122
|
});
|
|
195
|
-
function
|
|
196
|
-
return
|
|
123
|
+
function de(e) {
|
|
124
|
+
return M(ue, e);
|
|
197
125
|
}
|
|
198
|
-
var
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
//#region src/entities/plugin/plugin.ts
|
|
203
|
-
function ce(e) {
|
|
204
|
-
return M(async () => {
|
|
205
|
-
await e();
|
|
126
|
+
var P = (e, t, n) => {
|
|
127
|
+
let { targetSelectors: r } = t.configStore.getState(), i = y(r, t.id);
|
|
128
|
+
i.forEach(({ elements: e }) => e.forEach((e) => ee(e, t.id))), g(i, t.id, t.key).forEach((r) => {
|
|
129
|
+
n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
|
|
206
130
|
});
|
|
207
|
-
}
|
|
208
|
-
|
|
131
|
+
}, F = async (e) => {
|
|
132
|
+
await Promise.all(e.experiences.listStore.getState().map(async (t) => {
|
|
133
|
+
await I(e, t) && P(e, t);
|
|
134
|
+
}));
|
|
135
|
+
}, I = async (n, r) => {
|
|
136
|
+
if (!n.preconditionPassed || !n.session?.isUser) return !1;
|
|
137
|
+
let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
|
|
138
|
+
return y(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
|
|
139
|
+
}, fe = (e, t, n) => {
|
|
209
140
|
let r = t.name, i = t.setup(e);
|
|
210
141
|
if (i) {
|
|
211
142
|
let e = n[r] ?? {};
|
|
@@ -214,508 +145,106 @@ var le = (e, t, n) => {
|
|
|
214
145
|
...i
|
|
215
146
|
});
|
|
216
147
|
}
|
|
217
|
-
},
|
|
148
|
+
}, L = E("component"), R = j(({ client: e, component: t, name: n }) => ({
|
|
218
149
|
name: n,
|
|
219
150
|
component: t,
|
|
220
151
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
221
152
|
}));
|
|
222
|
-
function
|
|
223
|
-
return
|
|
153
|
+
function z(e) {
|
|
154
|
+
return M(R, e);
|
|
224
155
|
}
|
|
225
|
-
var
|
|
226
|
-
let t =
|
|
156
|
+
var B = j(({ client: e }) => {
|
|
157
|
+
let t = L.store({}), n = T(t, { register(e, t) {
|
|
227
158
|
return {
|
|
228
159
|
...e,
|
|
229
160
|
[t.name]: t
|
|
230
161
|
};
|
|
231
|
-
} })
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
filter: (e, { name: t }) => e[t] !== void 0,
|
|
236
|
-
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
237
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
238
|
-
clock: i,
|
|
239
|
-
fn: ({ name: t, component: n }) => fe({
|
|
162
|
+
} });
|
|
163
|
+
function r(r, i) {
|
|
164
|
+
t.getState()[r] && `${r}`;
|
|
165
|
+
let a = z({
|
|
240
166
|
client: e,
|
|
241
|
-
name:
|
|
242
|
-
component:
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
let
|
|
247
|
-
function
|
|
167
|
+
name: r,
|
|
168
|
+
component: i
|
|
169
|
+
});
|
|
170
|
+
n.register(a);
|
|
171
|
+
}
|
|
172
|
+
let i = t.map((e) => Object.values(e));
|
|
173
|
+
function a(e) {
|
|
248
174
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
249
175
|
}
|
|
250
176
|
return {
|
|
251
|
-
register:
|
|
252
|
-
getByName:
|
|
253
|
-
listStore:
|
|
177
|
+
register: r,
|
|
178
|
+
getByName: a,
|
|
179
|
+
listStore: i
|
|
254
180
|
};
|
|
255
181
|
});
|
|
256
|
-
function
|
|
257
|
-
return
|
|
182
|
+
function V(e) {
|
|
183
|
+
return M(B, e);
|
|
258
184
|
}
|
|
259
|
-
var
|
|
260
|
-
n.register(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
});
|
|
264
|
-
}, he = j("framework"), ge = I((e) => {
|
|
265
|
-
let t = he.store({}), n = A(t, { register(e, t) {
|
|
185
|
+
var H = (e, t, n) => {
|
|
186
|
+
n.register(e, t);
|
|
187
|
+
}, pe = E("framework"), me = j(({ client: e }) => {
|
|
188
|
+
let t = pe.store({}), n = T(t, { register(e, t) {
|
|
266
189
|
return {
|
|
267
190
|
...e,
|
|
268
191
|
[t.name]: t.framework
|
|
269
192
|
};
|
|
270
|
-
} })
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
});
|
|
280
|
-
let a = t.map((e) => Object.values(e));
|
|
281
|
-
function o(e) {
|
|
193
|
+
} });
|
|
194
|
+
function r(e, r) {
|
|
195
|
+
t.getState()[e] && `${e}`, n.register({
|
|
196
|
+
name: e,
|
|
197
|
+
framework: r
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
let i = t.map((e) => Object.values(e));
|
|
201
|
+
function a(e) {
|
|
282
202
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
283
203
|
}
|
|
284
204
|
return {
|
|
285
|
-
register:
|
|
286
|
-
getByName:
|
|
287
|
-
listStore:
|
|
205
|
+
register: r,
|
|
206
|
+
getByName: a,
|
|
207
|
+
listStore: i
|
|
288
208
|
};
|
|
289
209
|
});
|
|
290
|
-
function
|
|
291
|
-
return
|
|
210
|
+
function he(e) {
|
|
211
|
+
return M(me, e);
|
|
292
212
|
}
|
|
293
|
-
var
|
|
294
|
-
t.register(
|
|
295
|
-
|
|
296
|
-
framework: e
|
|
297
|
-
});
|
|
298
|
-
}, ye = I(({ client: e }) => {
|
|
299
|
-
let t = "window" in globalThis, n = {
|
|
300
|
-
location: t ? globalThis.location : void 0,
|
|
301
|
-
document: t ? globalThis.document : void 0,
|
|
302
|
-
sessionStorage: t ? globalThis.sessionStorage : void 0,
|
|
303
|
-
localStorage: t ? globalThis.localStorage : void 0
|
|
304
|
-
};
|
|
305
|
-
return k(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
|
|
306
|
-
client: e,
|
|
307
|
-
responses: t,
|
|
308
|
-
fields: r,
|
|
309
|
-
...n
|
|
310
|
-
}));
|
|
311
|
-
});
|
|
312
|
-
function be(e) {
|
|
313
|
-
return L(ye, e);
|
|
314
|
-
}
|
|
315
|
-
//#endregion
|
|
316
|
-
//#region src/logic-engine.ts
|
|
317
|
-
function xe(e) {
|
|
318
|
-
return typeof e == "number" && !isNaN(e);
|
|
319
|
-
}
|
|
320
|
-
function B(e) {
|
|
321
|
-
return typeof e == "string";
|
|
322
|
-
}
|
|
323
|
-
function V(e) {
|
|
324
|
-
return Array.isArray(e);
|
|
325
|
-
}
|
|
326
|
-
function H(e) {
|
|
327
|
-
return e instanceof Promise;
|
|
328
|
-
}
|
|
329
|
-
function U(e) {
|
|
330
|
-
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
331
|
-
}
|
|
332
|
-
function W(e) {
|
|
333
|
-
if (xe(e)) return e;
|
|
334
|
-
let t = parseFloat(`${e}`);
|
|
335
|
-
return isNaN(t) ? 0 : t;
|
|
336
|
-
}
|
|
337
|
-
function G(e) {
|
|
338
|
-
return `${e}`;
|
|
339
|
-
}
|
|
340
|
-
var Se = {
|
|
341
|
-
"==": (e, t) => e == t,
|
|
342
|
-
"===": (e, t) => e === t,
|
|
343
|
-
"!=": (e, t) => e != t,
|
|
344
|
-
"!==": (e, t) => e !== t,
|
|
345
|
-
">": (e, t) => W(e) > W(t),
|
|
346
|
-
">=": (e, t) => W(e) >= W(t),
|
|
347
|
-
"<": (e, t, n) => {
|
|
348
|
-
let r = W(e), i = W(t);
|
|
349
|
-
if (n === void 0) return r < i;
|
|
350
|
-
let a = W(n);
|
|
351
|
-
return r < i && i < a;
|
|
352
|
-
},
|
|
353
|
-
"<=": (e, t, n) => {
|
|
354
|
-
let r = W(e), i = W(t);
|
|
355
|
-
if (n === void 0) return r <= i;
|
|
356
|
-
let a = W(n);
|
|
357
|
-
return r <= i && i <= a;
|
|
358
|
-
},
|
|
359
|
-
"!!": async (e) => await q(e),
|
|
360
|
-
"!": async (e) => !await q(e),
|
|
361
|
-
"%": (e, t) => W(e) % W(t),
|
|
362
|
-
log: (e) => (console.log(e), e),
|
|
363
|
-
in: (e, t) => t ? B(t) ? t.indexOf(G(e)) !== -1 : V(t) ? t.includes(e) : !1 : !1,
|
|
364
|
-
cat: (...e) => e.map(G).join(""),
|
|
365
|
-
substr: (e, t, n) => {
|
|
366
|
-
let r = G(e), i = W(t);
|
|
367
|
-
if (n === void 0) return r.substr(i);
|
|
368
|
-
let a = W(n);
|
|
369
|
-
if (a < 0) {
|
|
370
|
-
let e = r.substr(i);
|
|
371
|
-
return e.substr(0, e.length + a);
|
|
372
|
-
}
|
|
373
|
-
return r.substr(i, a);
|
|
374
|
-
},
|
|
375
|
-
"+": (...e) => e.reduce((e, t) => W(e) + W(t), 0),
|
|
376
|
-
"*": (...e) => e.reduce((e, t) => W(e) * W(t), 1),
|
|
377
|
-
"-": (e, t) => {
|
|
378
|
-
let n = W(e);
|
|
379
|
-
return t === void 0 ? -n : n - W(t);
|
|
380
|
-
},
|
|
381
|
-
"/": (e, t) => W(e) / W(t),
|
|
382
|
-
min: (...e) => Math.min(...e.map(W)),
|
|
383
|
-
max: (...e) => Math.max(...e.map(W)),
|
|
384
|
-
merge: (...e) => e.reduce((e, t) => V(t) ? e.concat(t) : e.concat([t]), []),
|
|
385
|
-
var(e, t) {
|
|
386
|
-
let n = arguments.length > 1 ? t : null;
|
|
387
|
-
if (e === "" || e === "." || e == null) return this;
|
|
388
|
-
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
389
|
-
let r = G(e);
|
|
390
|
-
if (r === "" || r === ".") return this;
|
|
391
|
-
let i = r.split("."), a = this;
|
|
392
|
-
for (let e of i) {
|
|
393
|
-
if (a == null) return n;
|
|
394
|
-
if (Array.isArray(a)) {
|
|
395
|
-
let t = parseInt(e, 10);
|
|
396
|
-
a = isNaN(t) ? a[e] : a[t];
|
|
397
|
-
} else a = a[e];
|
|
398
|
-
}
|
|
399
|
-
return a === void 0 ? n : a;
|
|
400
|
-
},
|
|
401
|
-
async missing(...e) {
|
|
402
|
-
let t = V(e[0]) ? e[0] : e, n = [];
|
|
403
|
-
for (let e of t) {
|
|
404
|
-
let t = await K({ var: e }, this);
|
|
405
|
-
(t === null || t === "") && n.push(`${e}`);
|
|
406
|
-
}
|
|
407
|
-
return n;
|
|
408
|
-
},
|
|
409
|
-
async missing_some(e, t) {
|
|
410
|
-
let n = await K({ missing: t }, this);
|
|
411
|
-
if (!V(n) || !V(t)) return [];
|
|
412
|
-
let r = n.filter(B);
|
|
413
|
-
return t.filter(B).length - r.length >= W(e) ? [] : r;
|
|
414
|
-
},
|
|
415
|
-
invoke(...e) {
|
|
416
|
-
let [t, ...n] = e;
|
|
417
|
-
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
418
|
-
},
|
|
419
|
-
startsWith: (e, t) => B(e) && B(t) && e.startsWith(t),
|
|
420
|
-
endsWith: (e, t) => B(e) && B(t) && e.endsWith(t),
|
|
421
|
-
regexp_matches(e, t) {
|
|
422
|
-
let n = e, r = "";
|
|
423
|
-
if (V(e)) {
|
|
424
|
-
let [t, i] = e;
|
|
425
|
-
n = t, r = i;
|
|
426
|
-
}
|
|
427
|
-
return !B(n) || !B(r) ? !1 : new RegExp(n, r).test(G(t));
|
|
428
|
-
},
|
|
429
|
-
throw(e) {
|
|
430
|
-
throw Error(G(e));
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
async function K(e, t) {
|
|
434
|
-
if (!e) return e;
|
|
435
|
-
if (H(e)) return K(await e, t);
|
|
436
|
-
if (V(e)) return Promise.all(e.map((e) => K(e, t)));
|
|
437
|
-
if (!U(e)) return e;
|
|
438
|
-
let n = Ce(e), r = n ? e[n] ?? [] : [];
|
|
439
|
-
switch (V(r) || (r = [r]), n) {
|
|
440
|
-
case "if":
|
|
441
|
-
case "?:":
|
|
442
|
-
for (let e = 0; e < r.length - 1; e += 2) if (await q(await K(r[e], t))) return K(r[e + 1], t);
|
|
443
|
-
return r.length % 2 == 1 ? K(r[r.length - 1], t) : null;
|
|
444
|
-
case "and": {
|
|
445
|
-
let e = null;
|
|
446
|
-
for (let n of r) if (e = await K(n, t), !await q(e)) return e;
|
|
447
|
-
return e;
|
|
448
|
-
}
|
|
449
|
-
case "or": {
|
|
450
|
-
let e = null;
|
|
451
|
-
for (let n of r) if (e = await K(n, t), await q(e)) return e;
|
|
452
|
-
return e;
|
|
453
|
-
}
|
|
454
|
-
case "map": {
|
|
455
|
-
let e = await K(r[0], t);
|
|
456
|
-
return V(e) ? await Promise.all(e.map((e) => K(r[1], e))) : [];
|
|
457
|
-
}
|
|
458
|
-
case "filter": {
|
|
459
|
-
let e = await K(r[0], t);
|
|
460
|
-
return V(e) ? (await Promise.all(e.map(async (e) => ({
|
|
461
|
-
item: e,
|
|
462
|
-
shouldInclude: await q(await K(r[1], e))
|
|
463
|
-
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
464
|
-
}
|
|
465
|
-
case "reduce": {
|
|
466
|
-
let e = await K(r[0], t);
|
|
467
|
-
if (!V(e)) return r.length > 2 ? await K(r[2], t) : null;
|
|
468
|
-
let n = r[1], i = r.length > 2 ? await K(r[2], t) : null;
|
|
469
|
-
for (let t of e) i = await K(n, {
|
|
470
|
-
current: t,
|
|
471
|
-
accumulator: i
|
|
472
|
-
});
|
|
473
|
-
return i;
|
|
474
|
-
}
|
|
475
|
-
case "all": {
|
|
476
|
-
let e = await K(r[0], t);
|
|
477
|
-
if (!V(e) || e.length === 0) return !1;
|
|
478
|
-
for (let t of e) if (!await q(await K(r[1], t))) return !1;
|
|
479
|
-
return !0;
|
|
480
|
-
}
|
|
481
|
-
case "some": {
|
|
482
|
-
let e = await K(r[0], t);
|
|
483
|
-
if (!V(e)) return !1;
|
|
484
|
-
for (let t of e) if (await q(await K(r[1], t))) return !0;
|
|
485
|
-
return !1;
|
|
486
|
-
}
|
|
487
|
-
case "none": {
|
|
488
|
-
let e = await K(r[0], t);
|
|
489
|
-
if (!V(e)) return !0;
|
|
490
|
-
for (let t of e) if (await q(await K(r[1], t))) return !1;
|
|
491
|
-
return !0;
|
|
492
|
-
}
|
|
493
|
-
case "catch": try {
|
|
494
|
-
return await K(r[0], t);
|
|
495
|
-
} catch (e) {
|
|
496
|
-
return U(e) ? await K(e, t) : r[1] ? await K(r[1], e) : e instanceof Error ? e.message : e;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
let i = await Promise.all(r.map((e) => K(e, t))), a = n ? Se[n] : void 0;
|
|
500
|
-
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
501
|
-
return a.apply(t, i);
|
|
502
|
-
}
|
|
503
|
-
async function q(e) {
|
|
504
|
-
return H(e) ? q(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
505
|
-
}
|
|
506
|
-
function Ce(e) {
|
|
507
|
-
return Object.keys(e)[0];
|
|
508
|
-
}
|
|
509
|
-
//#endregion
|
|
510
|
-
//#region src/lifecycle/rules-logic.ts
|
|
511
|
-
var we = I(({ client: e }) => O({
|
|
512
|
-
source: {
|
|
513
|
-
stateSnapshot: e.stateSnapshotStore,
|
|
514
|
-
predicates: e.predicates.listStore,
|
|
515
|
-
actions: e.actions.listStore,
|
|
516
|
-
features: e.features.listStore,
|
|
517
|
-
responses: e.responses.getAllStore
|
|
518
|
-
},
|
|
519
|
-
effect: async ({ stateSnapshot: e, predicates: t, actions: n, features: r, responses: i }, { rule: a, context: o }) => {
|
|
520
|
-
let s = t.reduce((t, n) => (t[n.name] = async (...t) => await n.predicate({
|
|
521
|
-
...e,
|
|
522
|
-
args: t
|
|
523
|
-
}), t), {}), c = n.reduce((t, n) => (t[n.key] = async (...t) => await n.action({
|
|
524
|
-
...e,
|
|
525
|
-
args: t
|
|
526
|
-
}, null) ?? void 0, t), {}), l = r.reduce((e, t) => (e[t.id] = async () => {
|
|
527
|
-
let { bucket: e } = await t.getBucket();
|
|
528
|
-
return e;
|
|
529
|
-
}, e), {});
|
|
530
|
-
return await K(a, {
|
|
531
|
-
responses: i,
|
|
532
|
-
location: typeof e.location == "object" ? {
|
|
533
|
-
hash: e.location.hash,
|
|
534
|
-
host: e.location.host,
|
|
535
|
-
hostname: e.location.hostname,
|
|
536
|
-
href: e.location.href,
|
|
537
|
-
origin: e.location.origin,
|
|
538
|
-
pathname: e.location.pathname,
|
|
539
|
-
port: e.location.port,
|
|
540
|
-
protocol: e.location.protocol,
|
|
541
|
-
search: e.location.search
|
|
542
|
-
} : void 0,
|
|
543
|
-
predicates: s,
|
|
544
|
-
actions: c,
|
|
545
|
-
features: l,
|
|
546
|
-
...o
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
}));
|
|
550
|
-
function Te(e) {
|
|
551
|
-
return L(we, e);
|
|
552
|
-
}
|
|
553
|
-
//#endregion
|
|
554
|
-
//#region src/ping.ts
|
|
555
|
-
var Ee = 6e3, De = E("last_ping", "global"), Oe = async (e) => {
|
|
213
|
+
var ge = (e, t) => {
|
|
214
|
+
t.register(e.name, e);
|
|
215
|
+
}, _e = 6e3, ve = S("last_ping", "global"), ye = async (e) => {
|
|
556
216
|
try {
|
|
557
|
-
let t = Date.now(), n =
|
|
558
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
217
|
+
let t = Date.now(), n = b.get(ve), r = 0;
|
|
218
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < _e) return !0;
|
|
559
219
|
let i = {
|
|
560
220
|
projectId: e.projectId,
|
|
561
221
|
path: window.location.pathname
|
|
562
222
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
563
223
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
564
|
-
let s = (await
|
|
224
|
+
let s = (await ae(e.apiUrl, "ping", i, a)).ok;
|
|
565
225
|
return s && n.set(t), s;
|
|
566
226
|
} catch {
|
|
567
227
|
return !1;
|
|
568
228
|
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
domain: J
|
|
582
|
-
}), l = N(), u = N(), d = N(), p = N(), m = N(), h = N();
|
|
583
|
-
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
|
|
584
|
-
let g = M(() => {
|
|
585
|
-
Oe(e);
|
|
586
|
-
}), _ = M(async () => {
|
|
587
|
-
await ee();
|
|
588
|
-
}), v = M(async () => {
|
|
589
|
-
await se(e);
|
|
590
|
-
}), y = O({ effect: v }), b = O({
|
|
591
|
-
source: o,
|
|
592
|
-
effect: async (e) => {
|
|
593
|
-
for (let t of e) await t();
|
|
594
|
-
}
|
|
595
|
-
}), x = O({
|
|
596
|
-
source: s,
|
|
597
|
-
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
598
|
-
}), S = O({
|
|
599
|
-
source: c,
|
|
600
|
-
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
601
|
-
}), C = F({
|
|
602
|
-
clock: l,
|
|
603
|
-
filter: () => f()
|
|
604
|
-
});
|
|
605
|
-
F({
|
|
606
|
-
clock: C,
|
|
607
|
-
fn: () => "starting",
|
|
608
|
-
target: a
|
|
609
|
-
}), F({
|
|
610
|
-
clock: C,
|
|
611
|
-
target: g
|
|
612
|
-
}), F({
|
|
613
|
-
clock: C,
|
|
614
|
-
target: b
|
|
615
|
-
}), F({
|
|
616
|
-
clock: C,
|
|
617
|
-
target: _
|
|
618
|
-
}), F({
|
|
619
|
-
clock: b.done,
|
|
620
|
-
target: x
|
|
621
|
-
}), F({
|
|
622
|
-
clock: x.doneData,
|
|
623
|
-
target: r
|
|
624
|
-
}), F({
|
|
625
|
-
clock: S.doneData,
|
|
626
|
-
target: i
|
|
627
|
-
}), F({
|
|
628
|
-
clock: x.doneData,
|
|
629
|
-
filter: (e) => e,
|
|
630
|
-
target: S
|
|
631
|
-
}), F({
|
|
632
|
-
clock: S.doneData,
|
|
633
|
-
target: e.session.setIsUser
|
|
634
|
-
}), F({
|
|
635
|
-
clock: S.doneData,
|
|
636
|
-
fn: (e) => ({
|
|
637
|
-
type: "user_decide",
|
|
638
|
-
value: e
|
|
639
|
-
}),
|
|
640
|
-
target: e.eventBus
|
|
641
|
-
}), F({
|
|
642
|
-
clock: x.doneData,
|
|
643
|
-
filter: (e) => !e,
|
|
644
|
-
fn: () => void 0,
|
|
645
|
-
target: d
|
|
646
|
-
}), F({
|
|
647
|
-
clock: S.doneData,
|
|
648
|
-
fn: () => void 0,
|
|
649
|
-
target: d
|
|
650
|
-
}), F({
|
|
651
|
-
clock: d,
|
|
652
|
-
fn: () => ({ type: "initialize" }),
|
|
653
|
-
target: e.eventBus
|
|
654
|
-
});
|
|
655
|
-
let w = P(!1).on(_.done, () => !0), T = P(!1).on(d, () => !0), E = P(!1).on(y.done, () => !0), D = k(r, i, (e, t) => e === !0 && t === !0);
|
|
656
|
-
return F({
|
|
657
|
-
clock: d,
|
|
658
|
-
source: D,
|
|
659
|
-
filter: (e) => e,
|
|
660
|
-
fn: () => void 0,
|
|
661
|
-
target: v
|
|
662
|
-
}), F({
|
|
663
|
-
clock: k(w, T, D, (e, t, n) => e && t && n),
|
|
664
|
-
filter: (e) => e,
|
|
665
|
-
fn: () => void 0,
|
|
666
|
-
target: y
|
|
667
|
-
}), F({
|
|
668
|
-
clock: k(w, T, D, E, (e, t, n, r) => e && t && (!n || r)),
|
|
669
|
-
filter: (e) => e,
|
|
670
|
-
fn: () => void 0,
|
|
671
|
-
target: u
|
|
672
|
-
}), F({
|
|
673
|
-
clock: u,
|
|
674
|
-
fn: () => "ready",
|
|
675
|
-
target: a
|
|
676
|
-
}), F({
|
|
677
|
-
clock: u,
|
|
678
|
-
fn: () => ({ type: "ready" }),
|
|
679
|
-
target: e.eventBus
|
|
680
|
-
}), F({
|
|
681
|
-
clock: u,
|
|
682
|
-
source: e.session.store,
|
|
683
|
-
fn: ({ id: e, isUser: t, identifiers: n }) => ({
|
|
684
|
-
type: "session",
|
|
685
|
-
id: e,
|
|
686
|
-
isUser: t,
|
|
687
|
-
identifiers: n
|
|
688
|
-
}),
|
|
689
|
-
target: e.eventBus
|
|
690
|
-
}), F({
|
|
691
|
-
clock: [
|
|
692
|
-
b.fail,
|
|
693
|
-
x.fail,
|
|
694
|
-
S.fail,
|
|
695
|
-
v.fail,
|
|
696
|
-
y.fail,
|
|
697
|
-
_.fail
|
|
698
|
-
],
|
|
699
|
-
fn: () => "failed",
|
|
700
|
-
target: a
|
|
701
|
-
}), {
|
|
702
|
-
start: l,
|
|
703
|
-
readyStore: t,
|
|
704
|
-
preconditionPassedStore: r,
|
|
705
|
-
conditionPassedStore: i,
|
|
706
|
-
lifecycleStageStore: a,
|
|
707
|
-
registerPluginStartHook: p,
|
|
708
|
-
setPrecondition: m,
|
|
709
|
-
setCondition: h
|
|
229
|
+
};
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/utils/state-snaphot.ts
|
|
232
|
+
function U(e) {
|
|
233
|
+
let t = typeof window < "u", n = {
|
|
234
|
+
client: e,
|
|
235
|
+
responses: e.responses.listStore.getState(),
|
|
236
|
+
fields: e.fields.listStore.getState(),
|
|
237
|
+
location: t ? window.location : void 0,
|
|
238
|
+
document: t ? window.document : void 0,
|
|
239
|
+
sessionStorage: t ? window.sessionStorage : void 0,
|
|
240
|
+
localStorage: t ? window.localStorage : void 0
|
|
710
241
|
};
|
|
711
|
-
|
|
712
|
-
function Ae(e) {
|
|
713
|
-
return L(ke, e);
|
|
242
|
+
return Object.freeze(n);
|
|
714
243
|
}
|
|
715
244
|
//#endregion
|
|
716
245
|
//#region src/entities/predicate/predicate.ts
|
|
717
|
-
var
|
|
718
|
-
let t =
|
|
246
|
+
var be = E("predicate"), xe = j(({ client: e }) => {
|
|
247
|
+
let t = be.store({}), n = T(t, { register(e, t) {
|
|
719
248
|
return {
|
|
720
249
|
...e,
|
|
721
250
|
[t.name]: {
|
|
@@ -723,103 +252,85 @@ var je = j("predicate"), Me = I(({ client: e }) => {
|
|
|
723
252
|
predicate: t.predicate
|
|
724
253
|
}
|
|
725
254
|
};
|
|
726
|
-
} })
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
source: t,
|
|
730
|
-
filter: (e, { name: t }) => e[t] !== void 0,
|
|
731
|
-
fn: (e, { name: t }) => `Predicate '${t}' already registered. Registering again will override the previous registration.`
|
|
732
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
733
|
-
clock: i,
|
|
734
|
-
fn: ({ name: e, predicate: t }) => Object.freeze({
|
|
255
|
+
} });
|
|
256
|
+
function r(e, r) {
|
|
257
|
+
t.getState()[e] && `${e}`, n.register(Object.freeze({
|
|
735
258
|
name: e,
|
|
736
|
-
predicate:
|
|
737
|
-
})
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
function o(e) {
|
|
259
|
+
predicate: r
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
let i = t.map((e) => Object.values(e));
|
|
263
|
+
function a(e) {
|
|
742
264
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
743
265
|
}
|
|
744
|
-
function
|
|
745
|
-
let n =
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
args: n
|
|
754
|
-
});
|
|
755
|
-
}
|
|
266
|
+
function o(t) {
|
|
267
|
+
let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
268
|
+
let n = a(t).getState();
|
|
269
|
+
if (!n) return;
|
|
270
|
+
let r = U(e);
|
|
271
|
+
return (...e) => n({
|
|
272
|
+
...r,
|
|
273
|
+
args: e
|
|
274
|
+
});
|
|
756
275
|
});
|
|
757
|
-
return
|
|
276
|
+
return A({
|
|
758
277
|
source: {
|
|
759
278
|
responses: e.responses.listStore,
|
|
760
279
|
fields: e.fields.listStore
|
|
761
280
|
},
|
|
762
281
|
target: r
|
|
763
|
-
}),
|
|
282
|
+
}), A({
|
|
764
283
|
clock: r.doneData,
|
|
765
284
|
filter: (e) => e !== void 0,
|
|
766
285
|
target: n
|
|
767
286
|
}), r(), n;
|
|
768
287
|
}
|
|
769
288
|
return {
|
|
770
|
-
register:
|
|
771
|
-
getByName:
|
|
772
|
-
listStore:
|
|
773
|
-
getEvokablePredicate:
|
|
289
|
+
register: r,
|
|
290
|
+
getByName: a,
|
|
291
|
+
listStore: i,
|
|
292
|
+
getEvokablePredicate: o
|
|
774
293
|
};
|
|
775
294
|
});
|
|
776
|
-
function
|
|
777
|
-
return
|
|
295
|
+
function Se(e) {
|
|
296
|
+
return M(xe, e);
|
|
778
297
|
}
|
|
779
|
-
var
|
|
780
|
-
n.register(
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
});
|
|
784
|
-
}, Y = j("feature"), Fe = I(({ client: e }) => {
|
|
785
|
-
let t = Y.store({}), n = Y.store([]), i = A(t, { register(e, t) {
|
|
298
|
+
var Ce = (e, t, n) => {
|
|
299
|
+
n.register(e, t);
|
|
300
|
+
}, W = E("feature"), we = j(({ client: e }) => {
|
|
301
|
+
let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
|
|
786
302
|
return {
|
|
787
303
|
...e,
|
|
788
304
|
[t.id]: t.feature
|
|
789
305
|
};
|
|
790
|
-
} })
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
filter: (e, { id: t }) => e[t] !== void 0,
|
|
795
|
-
fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
|
|
796
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
797
|
-
clock: a,
|
|
798
|
-
fn: ({ id: e, feature: t }) => Object.freeze({
|
|
306
|
+
} });
|
|
307
|
+
function i(e, n) {
|
|
308
|
+
t.getState()[e] && `${e}`;
|
|
309
|
+
let i = {
|
|
799
310
|
id: e,
|
|
800
311
|
feature: {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
...t,
|
|
804
|
-
id: e
|
|
805
|
-
}
|
|
312
|
+
...n,
|
|
313
|
+
id: e
|
|
806
314
|
}
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
315
|
+
};
|
|
316
|
+
r.register(Object.freeze({
|
|
317
|
+
id: e,
|
|
318
|
+
feature: i
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
let a = D(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
322
|
+
let r = S(`feature:${e}:${t}`, "global"), i = (n === "session" ? x : b).get(r).boolean();
|
|
812
323
|
return i === null ? null : {
|
|
813
324
|
id: e,
|
|
814
325
|
key: t,
|
|
815
326
|
bucket: i,
|
|
816
327
|
storage: n
|
|
817
328
|
};
|
|
818
|
-
}),
|
|
329
|
+
}), o = D((e) => {
|
|
819
330
|
if (!e) return null;
|
|
820
|
-
let t =
|
|
821
|
-
(e.storage === "session" ?
|
|
822
|
-
}),
|
|
331
|
+
let t = S(`feature:${e.id}:${e.key}`, "global");
|
|
332
|
+
(e.storage === "session" ? x : b).set(t, e.bucket);
|
|
333
|
+
}), s = /* @__PURE__ */ new Map(), c = C({
|
|
823
334
|
source: {
|
|
824
335
|
allFeaturesStore: t,
|
|
825
336
|
resolvedFeaturesStore: n
|
|
@@ -829,9 +340,9 @@ var Pe = (e, t, n) => {
|
|
|
829
340
|
if (a) return a;
|
|
830
341
|
let o = e[n];
|
|
831
342
|
if (!o) throw Error(`Feature with id '${n}' not found`);
|
|
832
|
-
let
|
|
833
|
-
if (
|
|
834
|
-
let e = await
|
|
343
|
+
let c = s.get(`${n}:${i}`);
|
|
344
|
+
if (c !== void 0) {
|
|
345
|
+
let e = await c;
|
|
835
346
|
return {
|
|
836
347
|
id: o.id,
|
|
837
348
|
bucket: e,
|
|
@@ -840,7 +351,7 @@ var Pe = (e, t, n) => {
|
|
|
840
351
|
};
|
|
841
352
|
}
|
|
842
353
|
let l = r();
|
|
843
|
-
|
|
354
|
+
s.set(`${n}:${i}`, l);
|
|
844
355
|
let u = await l;
|
|
845
356
|
return {
|
|
846
357
|
id: o.id,
|
|
@@ -850,8 +361,8 @@ var Pe = (e, t, n) => {
|
|
|
850
361
|
};
|
|
851
362
|
}
|
|
852
363
|
});
|
|
853
|
-
|
|
854
|
-
clock:
|
|
364
|
+
A({
|
|
365
|
+
clock: r.register,
|
|
855
366
|
fn: (e) => {
|
|
856
367
|
let { id: t, feature: n } = e;
|
|
857
368
|
return {
|
|
@@ -860,10 +371,10 @@ var Pe = (e, t, n) => {
|
|
|
860
371
|
storage: n.feature.storage
|
|
861
372
|
};
|
|
862
373
|
},
|
|
863
|
-
target:
|
|
864
|
-
}),
|
|
374
|
+
target: a
|
|
375
|
+
}), A({
|
|
865
376
|
source: t,
|
|
866
|
-
clock:
|
|
377
|
+
clock: c.doneData,
|
|
867
378
|
fn: (e, t) => {
|
|
868
379
|
let { id: n, bucket: r, storage: i } = t, a = e[n]?.feature.key;
|
|
869
380
|
return a ? {
|
|
@@ -873,9 +384,9 @@ var Pe = (e, t, n) => {
|
|
|
873
384
|
storage: i
|
|
874
385
|
} : null;
|
|
875
386
|
},
|
|
876
|
-
target:
|
|
387
|
+
target: o
|
|
877
388
|
});
|
|
878
|
-
let
|
|
389
|
+
let l = w({
|
|
879
390
|
allFeaturesStore: t,
|
|
880
391
|
resolvedFeaturesStore: n
|
|
881
392
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -893,12 +404,12 @@ var Pe = (e, t, n) => {
|
|
|
893
404
|
id: e.id,
|
|
894
405
|
name: e.feature.name,
|
|
895
406
|
key: e.feature.key,
|
|
896
|
-
getBucket: async () => await
|
|
407
|
+
getBucket: async () => await c(e.feature),
|
|
897
408
|
isResolved: !1
|
|
898
409
|
};
|
|
899
410
|
}));
|
|
900
|
-
|
|
901
|
-
clock:
|
|
411
|
+
A({
|
|
412
|
+
clock: c.doneData,
|
|
902
413
|
source: { resolvedFeatures: n },
|
|
903
414
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
904
415
|
fn: (e, t) => t,
|
|
@@ -906,63 +417,58 @@ var Pe = (e, t, n) => {
|
|
|
906
417
|
type: "feature_decide",
|
|
907
418
|
feature: e
|
|
908
419
|
}))
|
|
909
|
-
}),
|
|
910
|
-
clock: [
|
|
420
|
+
}), A({
|
|
421
|
+
clock: [a.doneData, c.doneData],
|
|
911
422
|
source: n,
|
|
912
423
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
913
424
|
target: n
|
|
914
425
|
});
|
|
915
|
-
function
|
|
916
|
-
return
|
|
426
|
+
function u(e) {
|
|
427
|
+
return l.map((t) => t.find((t) => t.id === e));
|
|
917
428
|
}
|
|
918
|
-
function
|
|
429
|
+
function d(e) {
|
|
919
430
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
920
431
|
}
|
|
921
|
-
function
|
|
922
|
-
let t =
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
if (e) return async () => (await e.getBucket()).bucket;
|
|
926
|
-
}
|
|
432
|
+
function f(e) {
|
|
433
|
+
let t = k(async () => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
434
|
+
let t = u(e).getState();
|
|
435
|
+
if (t) return async () => (await t.getBucket()).bucket;
|
|
927
436
|
});
|
|
928
|
-
return
|
|
437
|
+
return A({
|
|
929
438
|
source: n,
|
|
930
439
|
filter: (t) => t.some((t) => t.id === e),
|
|
931
440
|
target: r
|
|
932
|
-
}),
|
|
441
|
+
}), A({
|
|
933
442
|
clock: r.doneData,
|
|
934
443
|
filter: (e) => e !== void 0,
|
|
935
444
|
target: t
|
|
936
445
|
}), r(), t;
|
|
937
446
|
}
|
|
938
447
|
return {
|
|
939
|
-
register:
|
|
940
|
-
getById:
|
|
941
|
-
getByName:
|
|
942
|
-
listStore:
|
|
943
|
-
getEvokableFeature:
|
|
448
|
+
register: i,
|
|
449
|
+
getById: u,
|
|
450
|
+
getByName: d,
|
|
451
|
+
listStore: l,
|
|
452
|
+
getEvokableFeature: f
|
|
944
453
|
};
|
|
945
454
|
});
|
|
946
|
-
function
|
|
947
|
-
return
|
|
455
|
+
function Te(e) {
|
|
456
|
+
return M(we, e);
|
|
948
457
|
}
|
|
949
|
-
var
|
|
950
|
-
n.register(
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
});
|
|
954
|
-
}, X = j("history");
|
|
955
|
-
function Re(e, t) {
|
|
458
|
+
var Ee = (e, t, n) => {
|
|
459
|
+
n.register(e, t);
|
|
460
|
+
}, G = E("history");
|
|
461
|
+
function K(e, t) {
|
|
956
462
|
return {
|
|
957
|
-
id:
|
|
463
|
+
id: se(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
958
464
|
node: t,
|
|
959
465
|
at: Date.now(),
|
|
960
466
|
experienceId: e
|
|
961
467
|
};
|
|
962
468
|
}
|
|
963
|
-
var
|
|
964
|
-
let e =
|
|
965
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
469
|
+
var De = j(() => {
|
|
470
|
+
let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
|
|
471
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, K(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), K(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
966
472
|
function a(e, t) {
|
|
967
473
|
let n = {
|
|
968
474
|
lastStepIndex: -1,
|
|
@@ -970,7 +476,7 @@ var ze = I(() => {
|
|
|
970
476
|
};
|
|
971
477
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
972
478
|
let i = e[r], a = i?.node;
|
|
973
|
-
if (!(!a || !
|
|
479
|
+
if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
974
480
|
else {
|
|
975
481
|
n.secondLastStepIndex = r;
|
|
976
482
|
break;
|
|
@@ -992,20 +498,25 @@ var ze = I(() => {
|
|
|
992
498
|
entriesStore: e.map((e) => e.entries)
|
|
993
499
|
};
|
|
994
500
|
});
|
|
995
|
-
function
|
|
996
|
-
return
|
|
501
|
+
function Oe() {
|
|
502
|
+
return M(De);
|
|
997
503
|
}
|
|
998
504
|
//#endregion
|
|
999
505
|
//#region src/utils/events.ts
|
|
1000
|
-
var
|
|
1001
|
-
let t =
|
|
1002
|
-
return
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
506
|
+
var ke = 0, Ae = (e) => {
|
|
507
|
+
let t = k([]);
|
|
508
|
+
return A({
|
|
509
|
+
clock: e,
|
|
510
|
+
source: t,
|
|
511
|
+
fn: (e, t) => [...e, {
|
|
512
|
+
id: ke++,
|
|
513
|
+
at: /* @__PURE__ */ new Date(),
|
|
514
|
+
payload: t
|
|
515
|
+
}],
|
|
516
|
+
target: t
|
|
517
|
+
}), t;
|
|
518
|
+
}, je = E("field"), Me = j(() => {
|
|
519
|
+
let e = je.store({}), t = T(e, {
|
|
1009
520
|
register(e, t) {
|
|
1010
521
|
return {
|
|
1011
522
|
...e,
|
|
@@ -1023,43 +534,39 @@ var Ve = 0, He = (e) => {
|
|
|
1023
534
|
function n(e) {
|
|
1024
535
|
t.register({ field: e });
|
|
1025
536
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
let i = Object.values(r).find((t) => t.key === e)?.key;
|
|
1032
|
-
i && t.updateByKey({
|
|
1033
|
-
fieldKey: i,
|
|
1034
|
-
updates: n
|
|
537
|
+
function r(n, r) {
|
|
538
|
+
let i = e.getState(), a = Object.values(i).find((e) => e.key === n)?.key;
|
|
539
|
+
a && t.updateByKey({
|
|
540
|
+
fieldKey: a,
|
|
541
|
+
updates: r
|
|
1035
542
|
});
|
|
1036
543
|
}
|
|
1037
|
-
let
|
|
1038
|
-
function
|
|
544
|
+
let i = e.map((e) => Object.values(e));
|
|
545
|
+
function a(t) {
|
|
1039
546
|
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
1040
547
|
}
|
|
1041
|
-
function
|
|
548
|
+
function o(t) {
|
|
1042
549
|
return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null, { skipVoid: !1 });
|
|
1043
550
|
}
|
|
1044
|
-
function
|
|
551
|
+
function s(t) {
|
|
1045
552
|
return e.map((e) => Object.values(e).find((e) => e.name === t) ?? null, { skipVoid: !1 });
|
|
1046
553
|
}
|
|
1047
554
|
return {
|
|
1048
555
|
register: n,
|
|
1049
|
-
update:
|
|
1050
|
-
getById:
|
|
1051
|
-
getByKey:
|
|
1052
|
-
listStore:
|
|
1053
|
-
getByName:
|
|
556
|
+
update: r,
|
|
557
|
+
getById: a,
|
|
558
|
+
getByKey: o,
|
|
559
|
+
listStore: i,
|
|
560
|
+
getByName: s
|
|
1054
561
|
};
|
|
1055
562
|
});
|
|
1056
|
-
function
|
|
1057
|
-
return
|
|
563
|
+
function Ne() {
|
|
564
|
+
return M(Me);
|
|
1058
565
|
}
|
|
1059
566
|
//#endregion
|
|
1060
567
|
//#region src/entities/step/step.ts
|
|
1061
|
-
var
|
|
1062
|
-
let e =
|
|
568
|
+
var Pe = E("step"), Fe = j(() => {
|
|
569
|
+
let e = Pe.store({}), t = T(e, { register(e, t) {
|
|
1063
570
|
return {
|
|
1064
571
|
...e,
|
|
1065
572
|
[t.step.id]: t.step
|
|
@@ -1083,45 +590,16 @@ var Ke = j("step"), qe = I(() => {
|
|
|
1083
590
|
indexStore: e
|
|
1084
591
|
};
|
|
1085
592
|
});
|
|
1086
|
-
function
|
|
1087
|
-
return
|
|
593
|
+
function Ie() {
|
|
594
|
+
return M(Fe);
|
|
1088
595
|
}
|
|
1089
|
-
function
|
|
1090
|
-
t.register(e);
|
|
1091
|
-
}
|
|
1092
|
-
//#endregion
|
|
1093
|
-
//#region src/entities/content/content.ts
|
|
1094
|
-
var Xe = j("content"), Ze = I(() => {
|
|
1095
|
-
let e = Xe.store({}), t = A(e, { register(e, t) {
|
|
1096
|
-
return {
|
|
1097
|
-
...e,
|
|
1098
|
-
[t.content.id]: t.content
|
|
1099
|
-
};
|
|
1100
|
-
} });
|
|
1101
|
-
function n(e) {
|
|
1102
|
-
t.register({ content: e });
|
|
1103
|
-
}
|
|
1104
|
-
let r = e.map((e) => Object.values(e));
|
|
1105
|
-
function i(t) {
|
|
1106
|
-
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
1107
|
-
}
|
|
1108
|
-
return {
|
|
1109
|
-
register: n,
|
|
1110
|
-
getById: i,
|
|
1111
|
-
listStore: r,
|
|
1112
|
-
indexStore: e
|
|
1113
|
-
};
|
|
1114
|
-
});
|
|
1115
|
-
function Qe() {
|
|
1116
|
-
return L(Ze);
|
|
1117
|
-
}
|
|
1118
|
-
function $e(e, t) {
|
|
596
|
+
function Le(e, t) {
|
|
1119
597
|
t.register(e);
|
|
1120
598
|
}
|
|
1121
599
|
//#endregion
|
|
1122
600
|
//#region src/entities/action/action.ts
|
|
1123
|
-
var
|
|
1124
|
-
let t =
|
|
601
|
+
var Re = E("action"), ze = j(({ client: e }) => {
|
|
602
|
+
let t = Re.store({}), n = T(t, { register(e, t) {
|
|
1125
603
|
return {
|
|
1126
604
|
...e,
|
|
1127
605
|
[t.key]: {
|
|
@@ -1129,68 +607,55 @@ var et = j("action"), tt = I(({ client: e }) => {
|
|
|
1129
607
|
action: t.action
|
|
1130
608
|
}
|
|
1131
609
|
};
|
|
1132
|
-
} })
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
source: t,
|
|
1136
|
-
filter: (e, { key: t }) => e[t] !== void 0,
|
|
1137
|
-
fn: (e, { key: t }) => `Action '${t}' already registered. Registering again will override the previous registration.`
|
|
1138
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
1139
|
-
clock: i,
|
|
1140
|
-
fn: ({ key: e, action: t }) => Object.freeze({
|
|
610
|
+
} });
|
|
611
|
+
function r(e, r) {
|
|
612
|
+
t.getState()[e] && `${e}`, n.register(Object.freeze({
|
|
1141
613
|
key: e,
|
|
1142
|
-
action:
|
|
1143
|
-
})
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
function o(e) {
|
|
614
|
+
action: r
|
|
615
|
+
}));
|
|
616
|
+
}
|
|
617
|
+
let i = t.map((e) => Object.values(e));
|
|
618
|
+
function a(e) {
|
|
1148
619
|
return t.map((t) => t[e]?.action, { skipVoid: !1 });
|
|
1149
620
|
}
|
|
1150
|
-
function
|
|
1151
|
-
let r =
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
args: n
|
|
1160
|
-
}, i);
|
|
1161
|
-
}
|
|
621
|
+
function o(t, n) {
|
|
622
|
+
let r = k(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, o = D(async () => {
|
|
623
|
+
let n = a(t).getState();
|
|
624
|
+
if (!n) return;
|
|
625
|
+
let r = U(e);
|
|
626
|
+
return (...e) => n({
|
|
627
|
+
...r,
|
|
628
|
+
args: e
|
|
629
|
+
}, i);
|
|
1162
630
|
});
|
|
1163
|
-
return
|
|
631
|
+
return A({
|
|
1164
632
|
source: {
|
|
1165
633
|
responses: e.responses.listStore,
|
|
1166
634
|
fields: e.fields.listStore
|
|
1167
635
|
},
|
|
1168
|
-
target:
|
|
1169
|
-
}),
|
|
1170
|
-
clock:
|
|
636
|
+
target: o
|
|
637
|
+
}), A({
|
|
638
|
+
clock: o.doneData,
|
|
1171
639
|
filter: (e) => e !== void 0,
|
|
1172
640
|
target: r
|
|
1173
|
-
}),
|
|
641
|
+
}), o(), r;
|
|
1174
642
|
}
|
|
1175
643
|
return {
|
|
1176
|
-
register:
|
|
1177
|
-
getByKey:
|
|
1178
|
-
listStore:
|
|
1179
|
-
getEvokableAction:
|
|
644
|
+
register: r,
|
|
645
|
+
getByKey: a,
|
|
646
|
+
listStore: i,
|
|
647
|
+
getEvokableAction: o
|
|
1180
648
|
};
|
|
1181
649
|
});
|
|
1182
|
-
function
|
|
1183
|
-
return
|
|
650
|
+
function Be(e) {
|
|
651
|
+
return M(ze, e);
|
|
1184
652
|
}
|
|
1185
|
-
var
|
|
1186
|
-
n.register(
|
|
1187
|
-
key: e,
|
|
1188
|
-
action: t
|
|
1189
|
-
});
|
|
653
|
+
var Ve = (e, t, n) => {
|
|
654
|
+
n.register(e, t);
|
|
1190
655
|
};
|
|
1191
656
|
//#endregion
|
|
1192
657
|
//#region src/entities/response/response-validation.ts
|
|
1193
|
-
function
|
|
658
|
+
function q(e, t, n, r) {
|
|
1194
659
|
return {
|
|
1195
660
|
fieldKey: e.key,
|
|
1196
661
|
userMessage: n,
|
|
@@ -1198,62 +663,62 @@ function Z(e, t, n, r) {
|
|
|
1198
663
|
value: t
|
|
1199
664
|
};
|
|
1200
665
|
}
|
|
1201
|
-
function
|
|
666
|
+
function J(e) {
|
|
1202
667
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1203
668
|
}
|
|
1204
|
-
function
|
|
669
|
+
function He(e) {
|
|
1205
670
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1206
671
|
}
|
|
1207
|
-
function
|
|
672
|
+
function Y(e) {
|
|
1208
673
|
try {
|
|
1209
674
|
return JSON.stringify(e), !0;
|
|
1210
675
|
} catch {
|
|
1211
676
|
return !1;
|
|
1212
677
|
}
|
|
1213
678
|
}
|
|
1214
|
-
function
|
|
679
|
+
function Ue(e, t) {
|
|
1215
680
|
return t.find((t) => t.key === e) ?? null;
|
|
1216
681
|
}
|
|
1217
|
-
function
|
|
682
|
+
function We(e, t) {
|
|
1218
683
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1219
684
|
}
|
|
1220
|
-
function
|
|
1221
|
-
if (e.type !== "object" ||
|
|
685
|
+
function Ge(e, t) {
|
|
686
|
+
if (e.type !== "object" || J(t)) return null;
|
|
1222
687
|
if (e.multiple) {
|
|
1223
|
-
if (!Array.isArray(t)) return
|
|
688
|
+
if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1224
689
|
for (let n of t) {
|
|
1225
|
-
if (typeof n != "object" || !n) return
|
|
1226
|
-
if (!
|
|
690
|
+
if (typeof n != "object" || !n) return q(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
691
|
+
if (!Y(n)) return q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1227
692
|
}
|
|
1228
693
|
return null;
|
|
1229
694
|
}
|
|
1230
|
-
return Array.isArray(t) ?
|
|
695
|
+
return Array.isArray(t) ? q(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? q(e, t, "This field expects an object value", "Field expects an object value.") : Y(t) ? null : q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1231
696
|
}
|
|
1232
|
-
function
|
|
1233
|
-
if (
|
|
697
|
+
function Ke(e, t) {
|
|
698
|
+
if (J(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1234
699
|
let n = Array.isArray(t) ? t : [t];
|
|
1235
700
|
if (e.type === "object") {
|
|
1236
701
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1237
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
702
|
+
return n.every((e) => r.has(JSON.stringify(e))) ? null : q(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
1238
703
|
}
|
|
1239
704
|
let r = e.options.map((e) => e.value);
|
|
1240
|
-
return n.every((e) => !
|
|
705
|
+
return n.every((e) => !He(e) || e === null ? !1 : r.includes(e)) ? null : q(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
1241
706
|
}
|
|
1242
|
-
async function
|
|
1243
|
-
if (
|
|
1244
|
-
let
|
|
707
|
+
async function qe(e, t, r, i) {
|
|
708
|
+
if (t.validation && !n(t.validation) && !J(r)) {
|
|
709
|
+
let n = i ? {
|
|
1245
710
|
$input: r,
|
|
1246
711
|
responses: i
|
|
1247
|
-
} : { $input: r }, a = await t
|
|
1248
|
-
if (typeof a == "string") return
|
|
1249
|
-
if (a === !1) return
|
|
712
|
+
} : { $input: r }, a = await e(t.validation, n);
|
|
713
|
+
if (typeof a == "string") return q(t, r, a, `Field validation resulted in an error: ${a}.`);
|
|
714
|
+
if (a === !1) return q(t, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
1250
715
|
}
|
|
1251
|
-
return
|
|
716
|
+
return t.required && J(r) ? q(t, r, "This field is required", "Field is required.") : !t.multiple && Array.isArray(r) && r.length > 1 ? q(t, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
1252
717
|
}
|
|
1253
718
|
//#endregion
|
|
1254
719
|
//#region src/entities/response/response.ts
|
|
1255
|
-
var
|
|
1256
|
-
let
|
|
720
|
+
var Je = E("response"), Ye = j(({ client: e }) => {
|
|
721
|
+
let n = Je.store({}), r = O(), i = O(), a = T(n, {
|
|
1257
722
|
register(e, t) {
|
|
1258
723
|
return {
|
|
1259
724
|
...e,
|
|
@@ -1282,17 +747,17 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1282
747
|
});
|
|
1283
748
|
} else a.registerBatch(e);
|
|
1284
749
|
}
|
|
1285
|
-
let s = (
|
|
750
|
+
let s = (n, r) => t(e, n, r), c = C({
|
|
1286
751
|
source: {
|
|
1287
752
|
allFields: e.fields.listStore,
|
|
1288
|
-
existingResponses:
|
|
753
|
+
existingResponses: n
|
|
1289
754
|
},
|
|
1290
755
|
effect: async ({ allFields: e, existingResponses: t }, n) => {
|
|
1291
756
|
let r = [], i = {}, a = {
|
|
1292
757
|
...t,
|
|
1293
758
|
...n
|
|
1294
759
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1295
|
-
let o =
|
|
760
|
+
let o = Ue(t, e);
|
|
1296
761
|
if (!o) {
|
|
1297
762
|
r.push({
|
|
1298
763
|
fieldKey: t,
|
|
@@ -1302,17 +767,17 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1302
767
|
});
|
|
1303
768
|
return;
|
|
1304
769
|
}
|
|
1305
|
-
let c =
|
|
770
|
+
let c = We(o, n), l = await qe(s, o, c, a);
|
|
1306
771
|
if (l) {
|
|
1307
772
|
r.push(l);
|
|
1308
773
|
return;
|
|
1309
774
|
}
|
|
1310
|
-
let u =
|
|
775
|
+
let u = Ge(o, c);
|
|
1311
776
|
if (u) {
|
|
1312
777
|
r.push(u);
|
|
1313
778
|
return;
|
|
1314
779
|
}
|
|
1315
|
-
let d =
|
|
780
|
+
let d = Ke(o, c);
|
|
1316
781
|
if (d) {
|
|
1317
782
|
r.push(d);
|
|
1318
783
|
return;
|
|
@@ -1340,8 +805,8 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1340
805
|
async function l(e) {
|
|
1341
806
|
return c(e);
|
|
1342
807
|
}
|
|
1343
|
-
let u =
|
|
1344
|
-
source:
|
|
808
|
+
let u = C({
|
|
809
|
+
source: n,
|
|
1345
810
|
effect: async (e, t) => {
|
|
1346
811
|
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
1347
812
|
return r.length ? { errors: r } : (a.registerBatch(n), { errors: [] });
|
|
@@ -1350,14 +815,14 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1350
815
|
async function d(e) {
|
|
1351
816
|
return u(e);
|
|
1352
817
|
}
|
|
1353
|
-
let f =
|
|
818
|
+
let f = n.map((e) => e), p = n.map((e) => Object.entries(e).map(([e, t]) => ({
|
|
1354
819
|
fieldKey: e,
|
|
1355
820
|
value: t
|
|
1356
821
|
})));
|
|
1357
822
|
function m(e) {
|
|
1358
|
-
return
|
|
823
|
+
return w({
|
|
1359
824
|
f: e,
|
|
1360
|
-
s:
|
|
825
|
+
s: n
|
|
1361
826
|
}, ({ f: e, s: t }) => {
|
|
1362
827
|
let n = e ? t[e.key] ?? null : null;
|
|
1363
828
|
return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
|
|
@@ -1372,10 +837,10 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1372
837
|
function _(t) {
|
|
1373
838
|
return m(e.fields.getByName(t));
|
|
1374
839
|
}
|
|
1375
|
-
return
|
|
840
|
+
return A({
|
|
1376
841
|
clock: r,
|
|
1377
842
|
target: a.clearAll
|
|
1378
|
-
}),
|
|
843
|
+
}), A({
|
|
1379
844
|
clock: i,
|
|
1380
845
|
target: a.clear
|
|
1381
846
|
}), {
|
|
@@ -1391,13 +856,13 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1391
856
|
getByFieldName: _
|
|
1392
857
|
};
|
|
1393
858
|
});
|
|
1394
|
-
function
|
|
1395
|
-
return
|
|
859
|
+
function Xe(e) {
|
|
860
|
+
return M(Ye, e);
|
|
1396
861
|
}
|
|
1397
862
|
//#endregion
|
|
1398
863
|
//#region src/entities/condition/condition.ts
|
|
1399
|
-
var
|
|
1400
|
-
let e =
|
|
864
|
+
var Ze = E("condition"), Qe = j(() => {
|
|
865
|
+
let e = Ze.store({}), t = T(e, { register(e, t) {
|
|
1401
866
|
return {
|
|
1402
867
|
...e,
|
|
1403
868
|
[t.condition.id]: t.condition
|
|
@@ -1421,12 +886,12 @@ var mt = j("condition"), ht = I(() => {
|
|
|
1421
886
|
indexStore: e
|
|
1422
887
|
};
|
|
1423
888
|
});
|
|
1424
|
-
function
|
|
1425
|
-
return
|
|
889
|
+
function $e() {
|
|
890
|
+
return M(Qe);
|
|
1426
891
|
}
|
|
1427
892
|
//#endregion
|
|
1428
893
|
//#region src/utils/api-url.ts
|
|
1429
|
-
function
|
|
894
|
+
function et() {
|
|
1430
895
|
if (f()) {
|
|
1431
896
|
let e = [
|
|
1432
897
|
document.currentScript,
|
|
@@ -1441,7 +906,7 @@ function _t() {
|
|
|
1441
906
|
}
|
|
1442
907
|
//#endregion
|
|
1443
908
|
//#region src/utils/search-params.ts
|
|
1444
|
-
function
|
|
909
|
+
function tt() {
|
|
1445
910
|
if (!o()) return {};
|
|
1446
911
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1447
912
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -1449,104 +914,75 @@ function vt() {
|
|
|
1449
914
|
let n = r.replace("picked-", "");
|
|
1450
915
|
t[n] = e.getAll(r);
|
|
1451
916
|
}
|
|
1452
|
-
let r =
|
|
1453
|
-
if (n.size > 0)
|
|
917
|
+
let r = S("s");
|
|
918
|
+
if (n.size > 0) x.set(r, t);
|
|
1454
919
|
else {
|
|
1455
|
-
let e =
|
|
920
|
+
let e = x.get(r);
|
|
1456
921
|
if (e) return e.json() || {};
|
|
1457
922
|
}
|
|
1458
923
|
return t;
|
|
1459
924
|
}
|
|
1460
925
|
//#endregion
|
|
1461
|
-
//#region src/
|
|
1462
|
-
|
|
1463
|
-
function bt() {
|
|
926
|
+
//#region src/utils/user-session.ts
|
|
927
|
+
function nt() {
|
|
1464
928
|
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)}`;
|
|
1465
929
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
[t]: n
|
|
1489
|
-
}
|
|
1490
|
-
}),
|
|
1491
|
-
removeIdentifier: (e, t) => {
|
|
1492
|
-
let n = e.identifiers;
|
|
1493
|
-
if (!n || !(t in n)) return e;
|
|
1494
|
-
let r = {};
|
|
1495
|
-
for (let [e, i] of Object.entries(n)) e !== t && (r[e] = i);
|
|
1496
|
-
let i = { id: e.id };
|
|
1497
|
-
return e.isUser !== void 0 && (i.isUser = e.isUser), Object.keys(r).length > 0 && (i.identifiers = r), i;
|
|
930
|
+
var rt = S("session", "global"), it = () => {
|
|
931
|
+
let e = b.get(rt), t;
|
|
932
|
+
e.isSet() && (t = e.json());
|
|
933
|
+
let n = (t) => e.set({
|
|
934
|
+
id: t.id,
|
|
935
|
+
isUser: t.isUser,
|
|
936
|
+
identifiers: t.identifiers
|
|
937
|
+
}), r = {
|
|
938
|
+
id: t?.id ?? nt(),
|
|
939
|
+
isUser: t?.isUser ?? void 0,
|
|
940
|
+
identifiers: t?.identifiers ?? void 0,
|
|
941
|
+
setIsUser(e) {
|
|
942
|
+
this.isUser = e, n(this);
|
|
943
|
+
},
|
|
944
|
+
setIdentifier(e, t) {
|
|
945
|
+
this.identifiers = {
|
|
946
|
+
...this.identifiers,
|
|
947
|
+
[e]: t
|
|
948
|
+
}, n(this);
|
|
949
|
+
},
|
|
950
|
+
removeIdentifier(e) {
|
|
951
|
+
this.identifiers && (this.identifiers = Object.fromEntries(Object.entries(this.identifiers).filter(([t]) => t !== e)), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, n(this));
|
|
1498
952
|
}
|
|
1499
|
-
});
|
|
1500
|
-
return F({
|
|
1501
|
-
source: n,
|
|
1502
|
-
target: O({
|
|
1503
|
-
source: n,
|
|
1504
|
-
effect: (e) => {
|
|
1505
|
-
if (u()) try {
|
|
1506
|
-
w.get(yt).set(e);
|
|
1507
|
-
} catch {}
|
|
1508
|
-
}
|
|
1509
|
-
})
|
|
1510
|
-
}), {
|
|
1511
|
-
store: n,
|
|
1512
|
-
setIsUser: r.setIsUser,
|
|
1513
|
-
setIdentifier: r.setIdentifier,
|
|
1514
|
-
removeIdentifier: r.removeIdentifier
|
|
1515
953
|
};
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
return L(St, void 0);
|
|
1519
|
-
}
|
|
954
|
+
return n(r), r;
|
|
955
|
+
}, X = () => u() ? it() : null;
|
|
1520
956
|
//#endregion
|
|
1521
957
|
//#region src/utils/picked-config.ts
|
|
1522
|
-
function
|
|
958
|
+
function Z() {
|
|
1523
959
|
if (o()) return globalThis.window.pickedConfig;
|
|
1524
960
|
}
|
|
1525
|
-
function
|
|
1526
|
-
if (o()) return
|
|
961
|
+
function at() {
|
|
962
|
+
if (o()) return Z()?.projectId;
|
|
1527
963
|
}
|
|
1528
|
-
function
|
|
964
|
+
function ot() {
|
|
1529
965
|
if (!f()) return;
|
|
1530
966
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1531
967
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1532
968
|
}
|
|
1533
|
-
function
|
|
969
|
+
function st(e) {
|
|
1534
970
|
if (e.projectId) return e.projectId;
|
|
1535
|
-
let t =
|
|
971
|
+
let t = at();
|
|
1536
972
|
if (t) return t;
|
|
1537
|
-
let n =
|
|
973
|
+
let n = ot();
|
|
1538
974
|
if (n) return n;
|
|
1539
975
|
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.");
|
|
1540
976
|
}
|
|
1541
977
|
//#endregion
|
|
1542
978
|
//#region src/utils/render-string.ts
|
|
1543
|
-
function
|
|
979
|
+
function Q(e) {
|
|
1544
980
|
return e == null || e === "" || Number.isNaN(e);
|
|
1545
981
|
}
|
|
1546
|
-
var
|
|
1547
|
-
default: (e, t) =>
|
|
1548
|
-
append: (e, t) => t &&
|
|
1549
|
-
prepend: (e, t) => t &&
|
|
982
|
+
var ct = {
|
|
983
|
+
default: (e, t) => Q(e) ? String(t ?? "") : String(e),
|
|
984
|
+
append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
|
|
985
|
+
prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
|
|
1550
986
|
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
1551
987
|
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
1552
988
|
capitalize: (e) => typeof e == "string" ? e.charAt(0).toUpperCase() + e.slice(1) : e,
|
|
@@ -1564,24 +1000,24 @@ var Ot = {
|
|
|
1564
1000
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1565
1001
|
}
|
|
1566
1002
|
};
|
|
1567
|
-
function
|
|
1003
|
+
function lt(e) {
|
|
1568
1004
|
return typeof e == "object" && !!e;
|
|
1569
1005
|
}
|
|
1570
|
-
function
|
|
1006
|
+
function ut(e, t) {
|
|
1571
1007
|
let n = t;
|
|
1572
|
-
for (let t of e.split(".")) if (
|
|
1008
|
+
for (let t of e.split(".")) if (lt(n) && t in n) n = n[t];
|
|
1573
1009
|
else return;
|
|
1574
1010
|
return typeof n == "function" ? n() : n;
|
|
1575
1011
|
}
|
|
1576
|
-
function
|
|
1577
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1012
|
+
function dt(e, t) {
|
|
1013
|
+
let n = e.split("|").map((e) => e.trim()), r = ut(n.shift() ?? "", t);
|
|
1578
1014
|
for (let e of n) {
|
|
1579
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1015
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = ct[i];
|
|
1580
1016
|
o && (r = o(r, a));
|
|
1581
1017
|
}
|
|
1582
|
-
return
|
|
1018
|
+
return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1583
1019
|
}
|
|
1584
|
-
function
|
|
1020
|
+
function ft(e, t) {
|
|
1585
1021
|
let n = "", r = 0;
|
|
1586
1022
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1587
1023
|
r += 2;
|
|
@@ -1593,80 +1029,90 @@ function Mt(e, t) {
|
|
|
1593
1029
|
}
|
|
1594
1030
|
i += e[r++];
|
|
1595
1031
|
}
|
|
1596
|
-
n +=
|
|
1032
|
+
n += dt(i.trim(), t);
|
|
1597
1033
|
} else n += e[r++];
|
|
1598
1034
|
return n;
|
|
1599
1035
|
}
|
|
1600
1036
|
//#endregion
|
|
1601
1037
|
//#region src/picked.ts
|
|
1602
|
-
var
|
|
1038
|
+
var $ = class {
|
|
1603
1039
|
static logger = r;
|
|
1604
1040
|
options;
|
|
1605
|
-
|
|
1606
|
-
contentLoader;
|
|
1041
|
+
isReady = !1;
|
|
1607
1042
|
plugins = {};
|
|
1608
|
-
|
|
1043
|
+
pluginStartHooks = [];
|
|
1044
|
+
eventBus = O();
|
|
1609
1045
|
events;
|
|
1610
1046
|
projectId;
|
|
1611
1047
|
apiUrl;
|
|
1612
1048
|
dashboardUrl;
|
|
1613
1049
|
documentationSiteUrl;
|
|
1614
|
-
session
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
start;
|
|
1632
|
-
readyStore;
|
|
1633
|
-
preconditionPassedStore;
|
|
1634
|
-
conditionPassedStore;
|
|
1635
|
-
lifecycleStageStore;
|
|
1636
|
-
lifecycle = Ae({ client: this });
|
|
1637
|
-
renderStringFx = O({
|
|
1638
|
-
source: this.responses.listStore,
|
|
1639
|
-
effect: (e, { template: t, context: n }) => {
|
|
1640
|
-
let r = {};
|
|
1641
|
-
for (let t of e) r[t.fieldKey] = t.value;
|
|
1642
|
-
return Mt(t, {
|
|
1643
|
-
...n,
|
|
1644
|
-
responses: r
|
|
1645
|
-
});
|
|
1646
|
-
}
|
|
1647
|
-
});
|
|
1050
|
+
session;
|
|
1051
|
+
precondition;
|
|
1052
|
+
condition;
|
|
1053
|
+
preconditionPassed;
|
|
1054
|
+
searchParams = tt();
|
|
1055
|
+
history = Oe();
|
|
1056
|
+
components = V({ client: this });
|
|
1057
|
+
experienceInstances = te({ client: this });
|
|
1058
|
+
experiences = de({ client: this });
|
|
1059
|
+
frameworks = he({ client: this });
|
|
1060
|
+
predicates = Se({ client: this });
|
|
1061
|
+
features = Te({ client: this });
|
|
1062
|
+
conditions = $e();
|
|
1063
|
+
fields = Ne();
|
|
1064
|
+
responses = Xe({ client: this });
|
|
1065
|
+
steps = Ie();
|
|
1066
|
+
actions = Be({ client: this });
|
|
1648
1067
|
constructor(e) {
|
|
1649
|
-
this.events =
|
|
1068
|
+
this.events = Ae(this.eventBus), this.projectId = st(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || et(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = X(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
|
|
1650
1069
|
type: "load",
|
|
1651
|
-
version:
|
|
1070
|
+
version: oe()
|
|
1652
1071
|
});
|
|
1653
1072
|
}
|
|
1073
|
+
start = () => {
|
|
1074
|
+
ye(this), (async () => {
|
|
1075
|
+
if (!f()) return;
|
|
1076
|
+
await this.runPluginStartHooks();
|
|
1077
|
+
let e = await this.evaluateGate(this.precondition);
|
|
1078
|
+
this.preconditionPassed = e;
|
|
1079
|
+
let t;
|
|
1080
|
+
e && (t = await this.evaluateGate(this.condition));
|
|
1081
|
+
let n = e && t === !0;
|
|
1082
|
+
if (typeof t == "boolean" && this.session) {
|
|
1083
|
+
let e = t;
|
|
1084
|
+
this.session.setIsUser(e), this.eventBus({
|
|
1085
|
+
type: "user_decide",
|
|
1086
|
+
value: e
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
if (this.eventBus({ type: "initialize" }), n && F(this), await ne(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1090
|
+
let { id: e, isUser: t, identifiers: n } = this.session;
|
|
1091
|
+
this.eventBus({
|
|
1092
|
+
type: "session",
|
|
1093
|
+
id: e,
|
|
1094
|
+
isUser: t,
|
|
1095
|
+
identifiers: n
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
})();
|
|
1099
|
+
};
|
|
1654
1100
|
registerFramework = (e) => {
|
|
1655
|
-
|
|
1101
|
+
ge(e, this.frameworks);
|
|
1656
1102
|
};
|
|
1657
1103
|
registerComponent = (e, t) => {
|
|
1658
|
-
|
|
1104
|
+
H(e, t, this.components);
|
|
1659
1105
|
};
|
|
1660
1106
|
registerPlugin = (e) => {
|
|
1661
|
-
|
|
1107
|
+
fe(this, e, this.plugins);
|
|
1662
1108
|
let t = this.plugins[e.name];
|
|
1663
|
-
t?.onStart && this.
|
|
1109
|
+
t?.onStart && this.pluginStartHooks.push(t.onStart);
|
|
1664
1110
|
};
|
|
1665
1111
|
registerFeature = (e, t) => {
|
|
1666
|
-
|
|
1112
|
+
Ee(e, t, this.features);
|
|
1667
1113
|
};
|
|
1668
1114
|
registerPredicate = (e, t) => {
|
|
1669
|
-
|
|
1115
|
+
Ce(e, t, this.predicates);
|
|
1670
1116
|
};
|
|
1671
1117
|
registerCondition = (e) => {
|
|
1672
1118
|
this.conditions.register(e);
|
|
@@ -1675,17 +1121,15 @@ var Nt = class {
|
|
|
1675
1121
|
this.fields.register(e);
|
|
1676
1122
|
};
|
|
1677
1123
|
registerStep = (e) => {
|
|
1678
|
-
|
|
1679
|
-
};
|
|
1680
|
-
registerContent = (e) => {
|
|
1681
|
-
$e(e, this.contents);
|
|
1124
|
+
Le(e, this.steps);
|
|
1682
1125
|
};
|
|
1683
1126
|
registerAction = (e, t) => {
|
|
1684
|
-
|
|
1127
|
+
Ve(e, t, this.actions);
|
|
1685
1128
|
};
|
|
1686
1129
|
registerExperience = (e) => {
|
|
1687
|
-
e.component &&
|
|
1130
|
+
e.component && H(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1688
1131
|
};
|
|
1132
|
+
getStateSnapshot = () => U(this);
|
|
1689
1133
|
launchExperienceById = async (e, t) => {
|
|
1690
1134
|
this.experiences.launch({
|
|
1691
1135
|
id: e,
|
|
@@ -1704,6 +1148,12 @@ var Nt = class {
|
|
|
1704
1148
|
openExperienceByKey = async (e) => {
|
|
1705
1149
|
this.experiences.open({ key: e });
|
|
1706
1150
|
};
|
|
1151
|
+
async runPluginStartHooks() {
|
|
1152
|
+
for (let e of this.pluginStartHooks) await e();
|
|
1153
|
+
}
|
|
1154
|
+
async evaluateGate(e) {
|
|
1155
|
+
return e === void 0 ? !0 : typeof e == "boolean" ? e : await t(this, e) === !0;
|
|
1156
|
+
}
|
|
1707
1157
|
setupPlugins() {
|
|
1708
1158
|
this.options.plugins?.forEach((e) => {
|
|
1709
1159
|
if (Array.isArray(e)) {
|
|
@@ -1766,23 +1216,30 @@ var Nt = class {
|
|
|
1766
1216
|
});
|
|
1767
1217
|
}
|
|
1768
1218
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1219
|
+
renderString = (e, t) => {
|
|
1220
|
+
let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldKey] = t.value, e), {});
|
|
1221
|
+
return ft(e, {
|
|
1222
|
+
...t,
|
|
1223
|
+
responses: n
|
|
1224
|
+
});
|
|
1225
|
+
};
|
|
1769
1226
|
};
|
|
1770
1227
|
//#endregion
|
|
1771
1228
|
//#region src/entities/component/lazyComponent.ts
|
|
1772
|
-
function
|
|
1229
|
+
function pt(e) {
|
|
1773
1230
|
return {
|
|
1774
1231
|
$$type: "lazy-component",
|
|
1775
1232
|
load: e
|
|
1776
1233
|
};
|
|
1777
1234
|
}
|
|
1778
|
-
function
|
|
1235
|
+
function mt(e) {
|
|
1779
1236
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1780
1237
|
}
|
|
1781
1238
|
//#endregion
|
|
1782
1239
|
//#region src/exports.ts
|
|
1783
|
-
var
|
|
1784
|
-
let t = new
|
|
1240
|
+
var ht = (e) => {
|
|
1241
|
+
let t = new $(e);
|
|
1785
1242
|
return d(t), t;
|
|
1786
1243
|
};
|
|
1787
1244
|
//#endregion
|
|
1788
|
-
export {
|
|
1245
|
+
export { $ as Picked, ht as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, mt as isLazyLoader, _ as isPickedRoot, pt as lazyComponent, b as localStore, x as sessionStore, ie 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 };
|