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