@picked/client 0.0.1-dev.1774224866171 → 0.0.1-dev.1774244905386
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-ZK-H-MlI.js → api-ENA5t36y.js} +1 -1
- package/dist/{api-WKe5XBeR.cjs → api-dkMxUUe0.cjs} +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/responses-indexeddb/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/esm/index.js +503 -426
- package/dist/esm/plugins/create-experience/index.js +352 -281
- package/dist/esm/plugins/dynamic-experiences/index.js +53 -30
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- 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/responses-indexeddb/index.js +9 -5
- package/dist/esm/plugins/single-page-app/index.js +4 -4
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-BODAwa-_.js +713 -0
- package/dist/experience-instance-DImQh64e.cjs +1 -0
- package/dist/object-BReQiaSS.cjs +1 -0
- package/dist/{object-C82v79xc.js → object-Clj5zVr1.js} +1 -2
- package/dist/storage-BFjb8azI.cjs +1 -0
- package/dist/{storage-6Xk0uAxB.js → storage-DyxpJ0pg.js} +1 -3
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/condition/condition.d.ts +17 -0
- package/dist/types/entities/condition/condition.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +36 -59
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +2 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +17 -12
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/project/project.d.ts +9 -0
- package/dist/types/entities/project/project.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +10 -7
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +38 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +8 -2
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +61 -52
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +81 -50
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/index.d.ts +2 -2
- package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +21 -4
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +47 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +0 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +3 -0
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +2 -2
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/global-obj.d.ts +1 -0
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/indexed-db.d.ts +1 -2
- package/dist/types/utils/indexed-db.d.ts.map +1 -1
- package/dist/types/utils/key.d.ts +12 -0
- package/dist/types/utils/key.d.ts.map +1 -0
- package/dist/types/utils/logger.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +3 -3
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +25 -2
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/object.d.ts +8 -0
- package/dist/types/utils/object.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +1 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/search-params.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +1 -11
- package/dist/cjs/form/index.js +0 -1
- package/dist/esm/form/index.js +0 -428
- package/dist/experience-instance-DZiAwXph.js +0 -481
- package/dist/experience-instance-Ddk4Jktn.cjs +0 -1
- package/dist/object-CUJOjanb.cjs +0 -1
- package/dist/rules-logic-B7vJrWyO.js +0 -231
- package/dist/rules-logic-CXr4wXcG.cjs +0 -1
- package/dist/storage-B6lQtc4-.cjs +0 -1
- package/dist/types/form/build-responses.d.ts +0 -14
- package/dist/types/form/build-responses.d.ts.map +0 -1
- package/dist/types/form/create-field-evaluator.d.ts +0 -19
- package/dist/types/form/create-field-evaluator.d.ts.map +0 -1
- package/dist/types/form/create-field-validation.d.ts +0 -44
- package/dist/types/form/create-field-validation.d.ts.map +0 -1
- package/dist/types/form/create-form.d.ts +0 -66
- package/dist/types/form/create-form.d.ts.map +0 -1
- package/dist/types/form/create-submit-pipeline.d.ts +0 -58
- package/dist/types/form/create-submit-pipeline.d.ts.map +0 -1
- package/dist/types/form/get-step-fields.d.ts +0 -5
- package/dist/types/form/get-step-fields.d.ts.map +0 -1
- package/dist/types/form/index.d.ts +0 -10
- package/dist/types/form/index.d.ts.map +0 -1
- package/dist/types/plugins/create-experience/serialization.d.ts +0 -6
- package/dist/types/plugins/create-experience/serialization.d.ts.map +0 -1
- /package/dist/{id-CRqy981z.js → id-BniPxOdF.js} +0 -0
- /package/dist/{id-Bv44ilEo.cjs → id-CIbS4P60.cjs} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,126 +1,150 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { createFactory as j, invoke as M } from "@withease/factories";
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, p as c, r as l, s as u, u as d } from "../experience-instance-BODAwa-_.js";
|
|
2
|
+
import { t as f } from "../object-Clj5zVr1.js";
|
|
3
|
+
import { t as p } from "../logger-6z_gb4rA.js";
|
|
4
|
+
import { a as m, c as h, d as g, i as ee, l as te, n as _, o as v, p as ne, r as y, s as re, t as ie, u as b } from "../supports-0XIfd4-R.js";
|
|
5
|
+
import { i as x, n as S, r as C, t as w } from "../storage-DyxpJ0pg.js";
|
|
6
|
+
import { n as ae, r as oe } from "../api-ENA5t36y.js";
|
|
7
|
+
import { t as se } from "../id-BniPxOdF.js";
|
|
8
|
+
import { attach as T, combine as E, createApi as D, createDomain as O, createEffect as k, createEvent as A, createStore as j, sample as M } from "effector";
|
|
9
|
+
import { createFactory as N, invoke as P } from "@withease/factories";
|
|
11
10
|
//#region src/entities/experience/experience.ts
|
|
12
|
-
var
|
|
13
|
-
let
|
|
11
|
+
var F = O("experience"), ce = N(({ client: t, experience: n }) => {
|
|
12
|
+
let r = F.store(n), a = D(r, { merge(e, t) {
|
|
14
13
|
return {
|
|
15
14
|
...e,
|
|
16
15
|
...t.experience
|
|
17
16
|
};
|
|
18
|
-
} }),
|
|
17
|
+
} }), o = r.map((e) => ({
|
|
19
18
|
name: e.name,
|
|
20
19
|
decisionLogic: e.condition,
|
|
21
20
|
targetSelectors: e.targets,
|
|
22
|
-
initializeOpenLogic:
|
|
23
|
-
})),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
initializeOpenLogic: n.initializeOpen
|
|
22
|
+
})), c = n.component ? {
|
|
23
|
+
name: `experience:${n.id}`,
|
|
24
|
+
component: n.component,
|
|
25
|
+
frameworkStore: t.frameworks.getByName(n.component.frameworkName)
|
|
26
|
+
} : void 0, u = t.components.listStore.map((e) => c || (n.componentName ? e.find((e) => e.name === n.componentName) : void 0) || e.find((e) => e.name === `experience:${n.id}`) || e.find((e) => e.name === "experience"), { skipVoid: !1 }), d = E(r, t.steps.listStore, t.conditions.listStore, (t, n, r) => {
|
|
27
|
+
let a = t.nodes.filter(i).map((e) => {
|
|
28
|
+
let t = s(e);
|
|
29
|
+
return n.find((e) => e.id === t || e.key === t);
|
|
30
|
+
}).filter((e) => e !== void 0), o = t.nodes.filter(l).map((t) => r.find((n) => n.id === e(t))).filter((e) => e !== void 0);
|
|
31
|
+
return {
|
|
32
|
+
steps: a,
|
|
33
|
+
nodes: t.nodes,
|
|
34
|
+
edges: t.edges,
|
|
35
|
+
conditions: o
|
|
36
|
+
};
|
|
37
|
+
}), f = n.actions ?? [];
|
|
29
38
|
return {
|
|
30
|
-
id:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
id: n.id,
|
|
40
|
+
key: n.key,
|
|
41
|
+
name: n.name,
|
|
42
|
+
configStore: o,
|
|
43
|
+
treeStore: d,
|
|
44
|
+
componentStore: u,
|
|
45
|
+
actions: f,
|
|
46
|
+
merge: a.merge
|
|
37
47
|
};
|
|
38
48
|
});
|
|
39
|
-
function
|
|
40
|
-
return
|
|
49
|
+
function le(e) {
|
|
50
|
+
return P(ce, e);
|
|
41
51
|
}
|
|
42
|
-
var
|
|
43
|
-
let t =
|
|
52
|
+
var ue = N(({ client: e }) => {
|
|
53
|
+
let t = F.store({}), n = F.store({}), r = D(t, { register(e, t) {
|
|
44
54
|
return {
|
|
45
55
|
...e,
|
|
46
56
|
[t.id]: t
|
|
47
57
|
};
|
|
58
|
+
} }), i = D(n, { register(e, { key: t, id: n }) {
|
|
59
|
+
return {
|
|
60
|
+
...e,
|
|
61
|
+
[t]: n
|
|
62
|
+
};
|
|
48
63
|
} });
|
|
49
|
-
function
|
|
50
|
-
let
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
experience:
|
|
64
|
+
function a(n) {
|
|
65
|
+
let a = t.getState()[n.id];
|
|
66
|
+
if (a) {
|
|
67
|
+
a.merge({
|
|
68
|
+
experience: n,
|
|
54
69
|
strategy: "override"
|
|
70
|
+
}), i.register({
|
|
71
|
+
key: n.key,
|
|
72
|
+
id: n.id
|
|
55
73
|
});
|
|
56
74
|
return;
|
|
57
75
|
}
|
|
58
|
-
let
|
|
76
|
+
let o = le({
|
|
59
77
|
client: e,
|
|
60
|
-
experience:
|
|
78
|
+
experience: n
|
|
79
|
+
});
|
|
80
|
+
r.register(o), i.register({
|
|
81
|
+
key: n.key,
|
|
82
|
+
id: n.id
|
|
61
83
|
});
|
|
62
|
-
n.register(a);
|
|
63
84
|
}
|
|
64
|
-
let
|
|
65
|
-
function
|
|
66
|
-
return t
|
|
85
|
+
let o = t.map((e) => Object.values(e));
|
|
86
|
+
function s(e) {
|
|
87
|
+
return E(t, n, (t, n) => t[n[e] ?? ""] ?? t[e], { skipVoid: !1 });
|
|
67
88
|
}
|
|
68
|
-
let
|
|
69
|
-
source:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
89
|
+
let c = T({
|
|
90
|
+
source: {
|
|
91
|
+
experiences: t,
|
|
92
|
+
keys: n
|
|
93
|
+
},
|
|
94
|
+
effect: async ({ experiences: t, keys: n }, { key: r, options: i }) => {
|
|
95
|
+
let a = t[n[r] ?? ""] ?? t[r];
|
|
96
|
+
if (!a) {
|
|
97
|
+
`${r}`;
|
|
74
98
|
return;
|
|
75
99
|
}
|
|
76
|
-
if (
|
|
77
|
-
|
|
100
|
+
if (i?.bypassCondition) {
|
|
101
|
+
I(e, a, i);
|
|
78
102
|
return;
|
|
79
103
|
}
|
|
80
|
-
await
|
|
104
|
+
await R(e, a) && I(e, a, i);
|
|
81
105
|
}
|
|
82
106
|
});
|
|
83
107
|
return {
|
|
84
|
-
register:
|
|
85
|
-
get:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
register: a,
|
|
109
|
+
get: s,
|
|
110
|
+
launch: c,
|
|
111
|
+
open: T({
|
|
112
|
+
source: {
|
|
113
|
+
instances: e.experienceInstances.listStore,
|
|
114
|
+
keys: n
|
|
115
|
+
},
|
|
116
|
+
effect: ({ instances: e, keys: t }, { key: n, options: r }) => {
|
|
117
|
+
let i = t[n] ?? n, a = e.filter((e) => e.experienceId === i);
|
|
118
|
+
if (a.length > 0) for (let e of a) e.open();
|
|
119
|
+
else c({
|
|
120
|
+
key: i,
|
|
95
121
|
options: {
|
|
96
|
-
...
|
|
122
|
+
...r,
|
|
97
123
|
initialiseOpen: !0
|
|
98
124
|
}
|
|
99
125
|
});
|
|
100
126
|
}
|
|
101
127
|
}),
|
|
102
|
-
listStore:
|
|
128
|
+
listStore: o
|
|
103
129
|
};
|
|
104
130
|
});
|
|
105
|
-
function
|
|
106
|
-
return
|
|
131
|
+
function de(e) {
|
|
132
|
+
return P(ue, e);
|
|
107
133
|
}
|
|
108
|
-
var
|
|
109
|
-
t.
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
i.forEach(({ elements: e }) => e.forEach((e) => ee(e, t.id))), te(i, t.id).forEach((r) => {
|
|
113
|
-
n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
|
|
134
|
+
var I = (e, t, r) => {
|
|
135
|
+
let { targetSelectors: i } = t.configStore.getState(), o = a(i, t.id);
|
|
136
|
+
o.forEach(({ elements: e }) => e.forEach((e) => n(e, t.id))), u(o, t.id).forEach((n) => {
|
|
137
|
+
r ? e.experienceInstances.spawn(t, n, r) : e.experienceInstances.spawn(t, n);
|
|
114
138
|
});
|
|
115
|
-
},
|
|
139
|
+
}, L = async (e) => {
|
|
116
140
|
await Promise.all(e.experiences.listStore.getState().map(async (t) => {
|
|
117
|
-
await
|
|
141
|
+
await R(e, t) && I(e, t);
|
|
118
142
|
}));
|
|
119
|
-
},
|
|
120
|
-
if (!
|
|
121
|
-
let { decisionLogic:
|
|
122
|
-
return
|
|
123
|
-
},
|
|
143
|
+
}, R = async (e, t) => {
|
|
144
|
+
if (!e.preconditionPassed || !e.session?.isUser) return !1;
|
|
145
|
+
let { decisionLogic: n, targetSelectors: i } = t.configStore.getState();
|
|
146
|
+
return a(i, t.id).length < 1 || i.length === 0 ? !1 : n === void 0 ? !0 : c(n) ? await r(e, n) === !0 : !0;
|
|
147
|
+
}, z = (e, t, n) => {
|
|
124
148
|
let r = t.name, i = t.setup(e);
|
|
125
149
|
if (i) {
|
|
126
150
|
let e = n[r] ?? {};
|
|
@@ -129,16 +153,16 @@ var de = (e, t) => {
|
|
|
129
153
|
...i
|
|
130
154
|
});
|
|
131
155
|
}
|
|
132
|
-
},
|
|
156
|
+
}, B = O("component"), V = N(({ client: e, component: t, name: n }) => ({
|
|
133
157
|
name: n,
|
|
134
158
|
component: t,
|
|
135
159
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
136
160
|
}));
|
|
137
|
-
function
|
|
138
|
-
return
|
|
161
|
+
function H(e) {
|
|
162
|
+
return P(V, e);
|
|
139
163
|
}
|
|
140
|
-
var
|
|
141
|
-
let t =
|
|
164
|
+
var fe = N(({ client: e }) => {
|
|
165
|
+
let t = B.store({}), n = D(t, { register(e, t) {
|
|
142
166
|
return {
|
|
143
167
|
...e,
|
|
144
168
|
[t.name]: t
|
|
@@ -146,7 +170,7 @@ var V = j(({ client: e }) => {
|
|
|
146
170
|
} });
|
|
147
171
|
function r(r, i) {
|
|
148
172
|
t.getState()[r] && `${r}`;
|
|
149
|
-
let a =
|
|
173
|
+
let a = H({
|
|
150
174
|
client: e,
|
|
151
175
|
name: r,
|
|
152
176
|
component: i
|
|
@@ -163,13 +187,13 @@ var V = j(({ client: e }) => {
|
|
|
163
187
|
listStore: i
|
|
164
188
|
};
|
|
165
189
|
});
|
|
166
|
-
function
|
|
167
|
-
return
|
|
190
|
+
function pe(e) {
|
|
191
|
+
return P(fe, e);
|
|
168
192
|
}
|
|
169
193
|
var U = (e, t, n) => {
|
|
170
194
|
n.register(e, t);
|
|
171
|
-
},
|
|
172
|
-
let t =
|
|
195
|
+
}, me = O("framework"), he = N(({ client: e }) => {
|
|
196
|
+
let t = me.store({}), n = D(t, { register(e, t) {
|
|
173
197
|
return {
|
|
174
198
|
...e,
|
|
175
199
|
[t.name]: t.framework
|
|
@@ -191,21 +215,21 @@ var U = (e, t, n) => {
|
|
|
191
215
|
listStore: i
|
|
192
216
|
};
|
|
193
217
|
});
|
|
194
|
-
function
|
|
195
|
-
return
|
|
218
|
+
function ge(e) {
|
|
219
|
+
return P(he, e);
|
|
196
220
|
}
|
|
197
|
-
var
|
|
221
|
+
var _e = (e, t) => {
|
|
198
222
|
t.register(e.name, e);
|
|
199
|
-
},
|
|
223
|
+
}, ve = 6e3, ye = w("last_ping", "global"), be = async (e) => {
|
|
200
224
|
try {
|
|
201
|
-
let t = Date.now(), n =
|
|
202
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
225
|
+
let t = Date.now(), n = S.get(ye), r = 0;
|
|
226
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < ve) return !0;
|
|
203
227
|
let i = {
|
|
204
228
|
projectId: e.projectId,
|
|
205
229
|
path: window.location.pathname
|
|
206
230
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
207
231
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
208
|
-
let s = (await
|
|
232
|
+
let s = (await ae(e.apiUrl, "ping", i, a)).ok;
|
|
209
233
|
return s && n.set(t), s;
|
|
210
234
|
} catch {
|
|
211
235
|
return !1;
|
|
@@ -227,8 +251,8 @@ function W(e) {
|
|
|
227
251
|
}
|
|
228
252
|
//#endregion
|
|
229
253
|
//#region src/entities/predicate/predicate.ts
|
|
230
|
-
var
|
|
231
|
-
let t =
|
|
254
|
+
var xe = O("predicate"), Se = N(({ client: e }) => {
|
|
255
|
+
let t = xe.store({}), n = D(t, { register(e, t) {
|
|
232
256
|
return {
|
|
233
257
|
...e,
|
|
234
258
|
[t.name]: {
|
|
@@ -248,7 +272,7 @@ var ye = E("predicate"), be = j(({ client: e }) => {
|
|
|
248
272
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
249
273
|
}
|
|
250
274
|
function o(t) {
|
|
251
|
-
let n =
|
|
275
|
+
let n = j(() => void 0, { skipVoid: !1 }), r = k(async () => {
|
|
252
276
|
let n = a(t).getState();
|
|
253
277
|
if (!n) return;
|
|
254
278
|
let r = W(e);
|
|
@@ -257,13 +281,13 @@ var ye = E("predicate"), be = j(({ client: e }) => {
|
|
|
257
281
|
args: e
|
|
258
282
|
});
|
|
259
283
|
});
|
|
260
|
-
return
|
|
284
|
+
return M({
|
|
261
285
|
source: {
|
|
262
286
|
responses: e.responses.listStore,
|
|
263
287
|
fields: e.fields.listStore
|
|
264
288
|
},
|
|
265
289
|
target: r
|
|
266
|
-
}),
|
|
290
|
+
}), M({
|
|
267
291
|
clock: r.doneData,
|
|
268
292
|
filter: (e) => e !== void 0,
|
|
269
293
|
target: n
|
|
@@ -276,13 +300,13 @@ var ye = E("predicate"), be = j(({ client: e }) => {
|
|
|
276
300
|
getEvokablePredicate: o
|
|
277
301
|
};
|
|
278
302
|
});
|
|
279
|
-
function
|
|
280
|
-
return
|
|
303
|
+
function Ce(e) {
|
|
304
|
+
return P(Se, e);
|
|
281
305
|
}
|
|
282
|
-
var
|
|
306
|
+
var we = (e, t, n) => {
|
|
283
307
|
n.register(e, t);
|
|
284
|
-
}, G =
|
|
285
|
-
let t = G.store({}), n = G.store([]), r =
|
|
308
|
+
}, G = O("feature"), Te = N(({ client: e }) => {
|
|
309
|
+
let t = G.store({}), n = G.store([]), r = D(t, { register(e, t) {
|
|
286
310
|
return {
|
|
287
311
|
...e,
|
|
288
312
|
[t.id]: t.feature
|
|
@@ -302,19 +326,19 @@ var Se = (e, t, n) => {
|
|
|
302
326
|
feature: i
|
|
303
327
|
}));
|
|
304
328
|
}
|
|
305
|
-
let a =
|
|
306
|
-
let r =
|
|
329
|
+
let a = k(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
330
|
+
let r = w(`feature:${e}:${t}`, "global"), i = (n === "session" ? C : S).get(r).boolean();
|
|
307
331
|
return i === null ? null : {
|
|
308
332
|
id: e,
|
|
309
333
|
key: t,
|
|
310
334
|
bucket: i,
|
|
311
335
|
storage: n
|
|
312
336
|
};
|
|
313
|
-
}), o =
|
|
337
|
+
}), o = k((e) => {
|
|
314
338
|
if (!e) return null;
|
|
315
|
-
let t =
|
|
316
|
-
(e.storage === "session" ?
|
|
317
|
-
}), s = /* @__PURE__ */ new Map(), c =
|
|
339
|
+
let t = w(`feature:${e.id}:${e.key}`, "global");
|
|
340
|
+
(e.storage === "session" ? C : S).set(t, e.bucket);
|
|
341
|
+
}), s = /* @__PURE__ */ new Map(), c = T({
|
|
318
342
|
source: {
|
|
319
343
|
allFeaturesStore: t,
|
|
320
344
|
resolvedFeaturesStore: n
|
|
@@ -345,7 +369,7 @@ var Se = (e, t, n) => {
|
|
|
345
369
|
};
|
|
346
370
|
}
|
|
347
371
|
});
|
|
348
|
-
|
|
372
|
+
M({
|
|
349
373
|
clock: r.register,
|
|
350
374
|
fn: (e) => {
|
|
351
375
|
let { id: t, feature: n } = e;
|
|
@@ -356,7 +380,7 @@ var Se = (e, t, n) => {
|
|
|
356
380
|
};
|
|
357
381
|
},
|
|
358
382
|
target: a
|
|
359
|
-
}),
|
|
383
|
+
}), M({
|
|
360
384
|
source: t,
|
|
361
385
|
clock: c.doneData,
|
|
362
386
|
fn: (e, t) => {
|
|
@@ -370,7 +394,7 @@ var Se = (e, t, n) => {
|
|
|
370
394
|
},
|
|
371
395
|
target: o
|
|
372
396
|
});
|
|
373
|
-
let l =
|
|
397
|
+
let l = E({
|
|
374
398
|
allFeaturesStore: t,
|
|
375
399
|
resolvedFeaturesStore: n
|
|
376
400
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -392,7 +416,7 @@ var Se = (e, t, n) => {
|
|
|
392
416
|
isResolved: !1
|
|
393
417
|
};
|
|
394
418
|
}));
|
|
395
|
-
|
|
419
|
+
M({
|
|
396
420
|
clock: c.doneData,
|
|
397
421
|
source: { resolvedFeatures: n },
|
|
398
422
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
@@ -401,7 +425,7 @@ var Se = (e, t, n) => {
|
|
|
401
425
|
type: "feature_decide",
|
|
402
426
|
feature: e
|
|
403
427
|
}))
|
|
404
|
-
}),
|
|
428
|
+
}), M({
|
|
405
429
|
clock: [a.doneData, c.doneData],
|
|
406
430
|
source: n,
|
|
407
431
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
@@ -414,15 +438,15 @@ var Se = (e, t, n) => {
|
|
|
414
438
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
415
439
|
}
|
|
416
440
|
function f(e) {
|
|
417
|
-
let t =
|
|
441
|
+
let t = j(async () => void 0, { skipVoid: !1 }), r = k(async () => {
|
|
418
442
|
let t = u(e).getState();
|
|
419
443
|
if (t) return async () => (await t.getBucket()).bucket;
|
|
420
444
|
});
|
|
421
|
-
return
|
|
445
|
+
return M({
|
|
422
446
|
source: n,
|
|
423
447
|
filter: (t) => t.some((t) => t.id === e),
|
|
424
448
|
target: r
|
|
425
|
-
}),
|
|
449
|
+
}), M({
|
|
426
450
|
clock: r.doneData,
|
|
427
451
|
filter: (e) => e !== void 0,
|
|
428
452
|
target: t
|
|
@@ -436,31 +460,31 @@ var Se = (e, t, n) => {
|
|
|
436
460
|
getEvokableFeature: f
|
|
437
461
|
};
|
|
438
462
|
});
|
|
439
|
-
function
|
|
440
|
-
return
|
|
463
|
+
function Ee(e) {
|
|
464
|
+
return P(Te, e);
|
|
441
465
|
}
|
|
442
|
-
var
|
|
466
|
+
var De = (e, t, n) => {
|
|
443
467
|
n.register(e, t);
|
|
444
|
-
}, K =
|
|
468
|
+
}, K = O("history");
|
|
445
469
|
function q(e, t) {
|
|
446
470
|
return {
|
|
447
|
-
id:
|
|
471
|
+
id: se(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
448
472
|
node: t,
|
|
449
473
|
at: Date.now(),
|
|
450
474
|
experienceId: e
|
|
451
475
|
};
|
|
452
476
|
}
|
|
453
|
-
var
|
|
454
|
-
let e = K.store({ entries: [] }), t = K.event(), n = K.event(), r = K.event(),
|
|
455
|
-
e.on(t, (e, t) => ({ entries: [...e.entries, q(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), q(t.experienceId, t.node)] })), e.on(
|
|
456
|
-
function
|
|
477
|
+
var Oe = N(() => {
|
|
478
|
+
let e = K.store({ entries: [] }), t = K.event(), n = K.event(), r = K.event(), a = K.event();
|
|
479
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, q(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), q(t.experienceId, t.node)] })), e.on(a, (e, t) => t);
|
|
480
|
+
function o(e, t) {
|
|
457
481
|
let n = {
|
|
458
482
|
lastStepIndex: -1,
|
|
459
483
|
secondLastStepIndex: -1
|
|
460
484
|
};
|
|
461
485
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
462
|
-
let
|
|
463
|
-
if (!(!
|
|
486
|
+
let a = e[r], o = a?.node;
|
|
487
|
+
if (!(!o || !i(o)) && !(t && a?.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
464
488
|
else {
|
|
465
489
|
n.secondLastStepIndex = r;
|
|
466
490
|
break;
|
|
@@ -469,7 +493,7 @@ var Ee = j(() => {
|
|
|
469
493
|
return n;
|
|
470
494
|
}
|
|
471
495
|
return e.on(r, (e, t) => {
|
|
472
|
-
let { secondLastStepIndex: n } =
|
|
496
|
+
let { secondLastStepIndex: n } = o(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
|
|
473
497
|
return {
|
|
474
498
|
...e,
|
|
475
499
|
entries: r
|
|
@@ -478,74 +502,97 @@ var Ee = j(() => {
|
|
|
478
502
|
push: t,
|
|
479
503
|
replace: n,
|
|
480
504
|
back: r,
|
|
481
|
-
restore:
|
|
505
|
+
restore: a,
|
|
482
506
|
entriesStore: e.map((e) => e.entries)
|
|
483
507
|
};
|
|
484
508
|
});
|
|
485
|
-
function
|
|
486
|
-
return
|
|
509
|
+
function ke() {
|
|
510
|
+
return P(Oe);
|
|
487
511
|
}
|
|
488
512
|
//#endregion
|
|
489
513
|
//#region src/utils/events.ts
|
|
490
|
-
var
|
|
491
|
-
let t =
|
|
492
|
-
return
|
|
514
|
+
var Ae = 0, je = (e) => {
|
|
515
|
+
let t = j([]);
|
|
516
|
+
return M({
|
|
493
517
|
clock: e,
|
|
494
518
|
source: t,
|
|
495
519
|
fn: (e, t) => [...e, {
|
|
496
|
-
id:
|
|
520
|
+
id: Ae++,
|
|
497
521
|
at: /* @__PURE__ */ new Date(),
|
|
498
522
|
payload: t
|
|
499
523
|
}],
|
|
500
524
|
target: t
|
|
501
525
|
}), t;
|
|
502
|
-
},
|
|
503
|
-
let e =
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
},
|
|
510
|
-
updateById(e, t) {
|
|
511
|
-
let n = e[t.fieldId];
|
|
512
|
-
return n ? {
|
|
513
|
-
...e,
|
|
514
|
-
[t.fieldId]: Object.assign({}, n, t.updates)
|
|
515
|
-
} : e;
|
|
516
|
-
}
|
|
517
|
-
});
|
|
526
|
+
}, Me = O("field"), Ne = N(() => {
|
|
527
|
+
let e = Me.store({}), t = D(e, { register(e, t) {
|
|
528
|
+
return {
|
|
529
|
+
...e,
|
|
530
|
+
[t.field.id]: t.field
|
|
531
|
+
};
|
|
532
|
+
} });
|
|
518
533
|
function n(e) {
|
|
519
534
|
t.register({ field: e });
|
|
520
535
|
}
|
|
521
|
-
function r(
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
});
|
|
536
|
+
function r(n, r) {
|
|
537
|
+
let i = e.getState()[n] ?? null;
|
|
538
|
+
if (!i) return;
|
|
539
|
+
let a = Object.assign({}, i, { ...r });
|
|
540
|
+
t.register({ field: { ...a } });
|
|
526
541
|
}
|
|
527
542
|
let i = e.map((e) => Object.values(e));
|
|
528
543
|
function a(t) {
|
|
529
|
-
return e.map((e) => e[t]
|
|
544
|
+
return e.map((e) => e[t] ?? null);
|
|
530
545
|
}
|
|
531
546
|
function o(t) {
|
|
532
|
-
return e.map((e) => Object.values(e).find((e) => e.
|
|
547
|
+
return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null);
|
|
548
|
+
}
|
|
549
|
+
function s(t) {
|
|
550
|
+
return e.map((e) => Object.values(e).find((e) => e.name === t) ?? null);
|
|
533
551
|
}
|
|
534
552
|
return {
|
|
535
553
|
register: n,
|
|
536
554
|
update: r,
|
|
537
555
|
getById: a,
|
|
556
|
+
getByKey: o,
|
|
538
557
|
listStore: i,
|
|
539
|
-
getByName:
|
|
558
|
+
getByName: s
|
|
540
559
|
};
|
|
541
560
|
});
|
|
542
|
-
function
|
|
543
|
-
return
|
|
561
|
+
function Pe() {
|
|
562
|
+
return P(Ne);
|
|
544
563
|
}
|
|
545
|
-
var
|
|
564
|
+
var Fe = (e, t) => {
|
|
546
565
|
t.register(e);
|
|
547
|
-
},
|
|
548
|
-
let e =
|
|
566
|
+
}, Ie = O("step"), Le = N(() => {
|
|
567
|
+
let e = Ie.store({}), t = D(e, { register(e, t) {
|
|
568
|
+
return {
|
|
569
|
+
...e,
|
|
570
|
+
[t.step.id]: t.step
|
|
571
|
+
};
|
|
572
|
+
} });
|
|
573
|
+
function n(e) {
|
|
574
|
+
t.register({ step: e });
|
|
575
|
+
}
|
|
576
|
+
let r = e.map((e) => Object.values(e));
|
|
577
|
+
function i(t) {
|
|
578
|
+
return e.map((e) => e[t] ?? null);
|
|
579
|
+
}
|
|
580
|
+
return {
|
|
581
|
+
register: n,
|
|
582
|
+
getById: i,
|
|
583
|
+
listStore: r
|
|
584
|
+
};
|
|
585
|
+
});
|
|
586
|
+
function Re() {
|
|
587
|
+
return P(Le);
|
|
588
|
+
}
|
|
589
|
+
function ze(e, t) {
|
|
590
|
+
t.register(e);
|
|
591
|
+
}
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/entities/action/action.ts
|
|
594
|
+
var Be = O("action"), Ve = N(() => {
|
|
595
|
+
let e = Be.store({}), t = D(e, { register(e, t) {
|
|
549
596
|
return {
|
|
550
597
|
...e,
|
|
551
598
|
[t.name]: {
|
|
@@ -577,29 +624,97 @@ var Me = (e, t) => {
|
|
|
577
624
|
getEvokableAction: a
|
|
578
625
|
};
|
|
579
626
|
});
|
|
580
|
-
function
|
|
581
|
-
return
|
|
627
|
+
function He() {
|
|
628
|
+
return P(Ve);
|
|
582
629
|
}
|
|
583
|
-
var
|
|
630
|
+
var Ue = (e, t, n) => {
|
|
584
631
|
n.register(e, t);
|
|
585
632
|
};
|
|
586
633
|
//#endregion
|
|
587
634
|
//#region src/entities/response/response.ts
|
|
588
|
-
function
|
|
635
|
+
function J(e) {
|
|
589
636
|
return e == null || e === "" || Array.isArray(e) && !e.length;
|
|
590
637
|
}
|
|
591
|
-
function
|
|
638
|
+
function We(e) {
|
|
592
639
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
593
640
|
}
|
|
594
|
-
function
|
|
641
|
+
function Y(e) {
|
|
595
642
|
try {
|
|
596
643
|
return JSON.stringify(e), !0;
|
|
597
644
|
} catch {
|
|
598
645
|
return !1;
|
|
599
646
|
}
|
|
600
647
|
}
|
|
601
|
-
|
|
602
|
-
|
|
648
|
+
function Ge(e, t) {
|
|
649
|
+
return t.find((t) => t.id === e) ?? t.find((t) => t.key === e) ?? null;
|
|
650
|
+
}
|
|
651
|
+
function Ke(e, t) {
|
|
652
|
+
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
653
|
+
}
|
|
654
|
+
function qe(e, t, n) {
|
|
655
|
+
if (e.type !== "object" || J(n)) return null;
|
|
656
|
+
if (e.multiple) {
|
|
657
|
+
if (!Array.isArray(n)) return {
|
|
658
|
+
fieldId: t,
|
|
659
|
+
userMessage: "This field expects multiple values",
|
|
660
|
+
systemMessage: "Field expects an array of objects.",
|
|
661
|
+
value: n
|
|
662
|
+
};
|
|
663
|
+
for (let e of n) {
|
|
664
|
+
if (typeof e != "object" || !e) return {
|
|
665
|
+
fieldId: t,
|
|
666
|
+
userMessage: "This field expects object values",
|
|
667
|
+
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
668
|
+
value: n
|
|
669
|
+
};
|
|
670
|
+
if (!Y(e)) return {
|
|
671
|
+
fieldId: t,
|
|
672
|
+
userMessage: "This field contains non-serializable data",
|
|
673
|
+
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
674
|
+
value: n
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
return Array.isArray(n) ? {
|
|
680
|
+
fieldId: t,
|
|
681
|
+
userMessage: "This field expects a single value",
|
|
682
|
+
systemMessage: "Field expects a single object, not an array.",
|
|
683
|
+
value: n
|
|
684
|
+
} : typeof n != "object" || !n ? {
|
|
685
|
+
fieldId: t,
|
|
686
|
+
userMessage: "This field expects an object value",
|
|
687
|
+
systemMessage: "Field expects an object value.",
|
|
688
|
+
value: n
|
|
689
|
+
} : Y(n) ? null : {
|
|
690
|
+
fieldId: t,
|
|
691
|
+
userMessage: "This field contains non-serializable data",
|
|
692
|
+
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
693
|
+
value: n
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
function Je(e, t, n) {
|
|
697
|
+
if (!Array.isArray(e.options) || e.options.length === 0) return null;
|
|
698
|
+
let r = Array.isArray(n) ? n : [n];
|
|
699
|
+
if (e.type === "object") {
|
|
700
|
+
let i = e.options.map((e) => JSON.stringify(e.value));
|
|
701
|
+
return r.every((e) => i.includes(JSON.stringify(e))) ? null : {
|
|
702
|
+
fieldId: t,
|
|
703
|
+
userMessage: "This field expects a valid option",
|
|
704
|
+
systemMessage: "Field expects a valid option from the defined choices.",
|
|
705
|
+
value: n
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
let i = e.options.map((e) => e.value);
|
|
709
|
+
return r.every((e) => !We(e) || e === null ? !1 : i.includes(e)) ? null : {
|
|
710
|
+
fieldId: t,
|
|
711
|
+
userMessage: "This field expects a valid option",
|
|
712
|
+
systemMessage: `Field expects a valid option. Valid options are: ${i.join(", ")}`,
|
|
713
|
+
value: n
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
var Ye = O("response"), Xe = N(({ client: e }) => {
|
|
717
|
+
let t = Ye.store({}), n = A(), i = A(), a = D(t, {
|
|
603
718
|
register(e, t) {
|
|
604
719
|
return {
|
|
605
720
|
...e,
|
|
@@ -613,222 +728,175 @@ var Re = E("response"), ze = j(({ client: e }) => {
|
|
|
613
728
|
};
|
|
614
729
|
},
|
|
615
730
|
clear(e, t) {
|
|
616
|
-
|
|
617
|
-
return r;
|
|
731
|
+
return Object.fromEntries(Object.entries(e).filter(([e]) => e !== t));
|
|
618
732
|
},
|
|
619
733
|
clearAll() {
|
|
620
734
|
return {};
|
|
621
735
|
}
|
|
622
736
|
});
|
|
623
|
-
function
|
|
737
|
+
function o(e, t) {
|
|
624
738
|
if (typeof e == "string") {
|
|
625
739
|
if (t === void 0) throw Error("Response is required when registering a single field");
|
|
626
|
-
|
|
740
|
+
a.register({
|
|
627
741
|
fieldId: e,
|
|
628
742
|
response: t
|
|
629
743
|
});
|
|
630
|
-
} else
|
|
744
|
+
} else a.registerBatch(e);
|
|
631
745
|
}
|
|
632
|
-
async function
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
a
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
746
|
+
async function s(t, n, i) {
|
|
747
|
+
if (t.validation && !f(t.validation) && !J(i)) {
|
|
748
|
+
let a = await r(e, t.validation, { $input: i });
|
|
749
|
+
if (typeof a == "string") return {
|
|
750
|
+
fieldId: n,
|
|
751
|
+
userMessage: a,
|
|
752
|
+
systemMessage: `Field validation resulted in an error: ${a}.`,
|
|
753
|
+
value: i
|
|
754
|
+
};
|
|
755
|
+
if (a === !1) return {
|
|
756
|
+
fieldId: n,
|
|
757
|
+
userMessage: "This field is invalid",
|
|
758
|
+
systemMessage: "Field validation resulted in an unspecified error.",
|
|
759
|
+
value: i
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
return t.required && J(i) ? {
|
|
763
|
+
fieldId: n,
|
|
764
|
+
userMessage: "This field is required",
|
|
765
|
+
systemMessage: "Field is required.",
|
|
766
|
+
value: i
|
|
767
|
+
} : !t.multiple && Array.isArray(i) && i.length > 1 ? {
|
|
768
|
+
fieldId: n,
|
|
769
|
+
userMessage: "This field expects a single response",
|
|
770
|
+
systemMessage: "Field expects a single response.",
|
|
771
|
+
value: i
|
|
772
|
+
} : null;
|
|
773
|
+
}
|
|
774
|
+
async function c(t) {
|
|
775
|
+
let n = [], r = {}, i = e.fields.listStore.getState();
|
|
776
|
+
return await Promise.allSettled(Object.entries(t).map(async ([e, t]) => {
|
|
777
|
+
let a = Ge(e, i);
|
|
778
|
+
if (!a) {
|
|
779
|
+
n.push({
|
|
780
|
+
fieldId: e,
|
|
781
|
+
userMessage: `Field '${e}' not found`,
|
|
782
|
+
systemMessage: `No field with ID or key '${e}' exists. Available field IDs are: ${i.map((e) => e.id).join(",")}.`,
|
|
783
|
+
value: t
|
|
642
784
|
});
|
|
643
785
|
return;
|
|
644
786
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
...i
|
|
649
|
-
}, s = await t(e, l.validation, {
|
|
650
|
-
$input: c,
|
|
651
|
-
responses: n
|
|
652
|
-
});
|
|
653
|
-
if (typeof s == "string") {
|
|
654
|
-
a.push({
|
|
655
|
-
fieldId: o,
|
|
656
|
-
userMessage: s,
|
|
657
|
-
systemMessage: `Field validation resulted in an error: ${s}.`,
|
|
658
|
-
value: c
|
|
659
|
-
});
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
if (s === !1) {
|
|
663
|
-
a.push({
|
|
664
|
-
fieldId: o,
|
|
665
|
-
userMessage: "This field is invalid",
|
|
666
|
-
systemMessage: "Field validation resulted in an unspecified error.",
|
|
667
|
-
value: c
|
|
668
|
-
});
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
if (l.required && Y(c)) {
|
|
673
|
-
a.push({
|
|
674
|
-
fieldId: o,
|
|
675
|
-
userMessage: "This field is required",
|
|
676
|
-
systemMessage: "Field is required.",
|
|
677
|
-
value: c
|
|
678
|
-
});
|
|
787
|
+
let o = a.id, c = Ke(a, t), l = await s(a, o, c);
|
|
788
|
+
if (l) {
|
|
789
|
+
n.push(l);
|
|
679
790
|
return;
|
|
680
791
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
userMessage: "This field expects a single response",
|
|
685
|
-
systemMessage: "Field expects a single response.",
|
|
686
|
-
value: c
|
|
687
|
-
});
|
|
792
|
+
let u = qe(a, o, c);
|
|
793
|
+
if (u) {
|
|
794
|
+
n.push(u);
|
|
688
795
|
return;
|
|
689
796
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
a.push({
|
|
693
|
-
fieldId: o,
|
|
694
|
-
userMessage: "This field expects multiple values",
|
|
695
|
-
systemMessage: "Field expects an array of objects.",
|
|
696
|
-
value: c
|
|
697
|
-
});
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
for (let e of c) {
|
|
701
|
-
if (typeof e != "object" || !e) {
|
|
702
|
-
a.push({
|
|
703
|
-
fieldId: o,
|
|
704
|
-
userMessage: "This field expects object values",
|
|
705
|
-
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
706
|
-
value: c
|
|
707
|
-
});
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
if (!X(e)) {
|
|
711
|
-
a.push({
|
|
712
|
-
fieldId: o,
|
|
713
|
-
userMessage: "This field contains non-serializable data",
|
|
714
|
-
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
715
|
-
value: c
|
|
716
|
-
});
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
} else {
|
|
721
|
-
if (Array.isArray(c)) {
|
|
722
|
-
a.push({
|
|
723
|
-
fieldId: o,
|
|
724
|
-
userMessage: "This field expects a single value",
|
|
725
|
-
systemMessage: "Field expects a single object, not an array.",
|
|
726
|
-
value: c
|
|
727
|
-
});
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
if (typeof c != "object" || !c) {
|
|
731
|
-
a.push({
|
|
732
|
-
fieldId: o,
|
|
733
|
-
userMessage: "This field expects an object value",
|
|
734
|
-
systemMessage: "Field expects an object value.",
|
|
735
|
-
value: c
|
|
736
|
-
});
|
|
737
|
-
return;
|
|
738
|
-
}
|
|
739
|
-
if (!X(c)) {
|
|
740
|
-
a.push({
|
|
741
|
-
fieldId: o,
|
|
742
|
-
userMessage: "This field contains non-serializable data",
|
|
743
|
-
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
744
|
-
value: c
|
|
745
|
-
});
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
if (Array.isArray(l.options) && l.options.length > 0) {
|
|
750
|
-
let e = Array.isArray(c) ? c : [c];
|
|
751
|
-
if (l.type === "object") {
|
|
752
|
-
let t = l.options.map((e) => JSON.stringify(e.value));
|
|
753
|
-
e.every((e) => t.includes(JSON.stringify(e))) || a.push({
|
|
754
|
-
fieldId: o,
|
|
755
|
-
userMessage: "This field expects a valid option",
|
|
756
|
-
systemMessage: "Field expects a valid option from the defined choices.",
|
|
757
|
-
value: c
|
|
758
|
-
});
|
|
759
|
-
} else {
|
|
760
|
-
let t = l.options.map((e) => e.value);
|
|
761
|
-
e.every((e) => !Le(e) || e === null ? !1 : t.includes(e)) || a.push({
|
|
762
|
-
fieldId: o,
|
|
763
|
-
userMessage: "This field expects a valid option",
|
|
764
|
-
systemMessage: `Field expects a valid option. Valid options are: ${t.join(", ")}`,
|
|
765
|
-
value: c
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
}
|
|
797
|
+
let d = Je(a, o, c);
|
|
798
|
+
d && n.push(d), r[o] = t;
|
|
769
799
|
})), {
|
|
770
|
-
responsesToCommit:
|
|
771
|
-
validationErrors:
|
|
800
|
+
responsesToCommit: r,
|
|
801
|
+
validationErrors: n
|
|
772
802
|
};
|
|
773
803
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
});
|
|
778
|
-
async function u(e) {
|
|
779
|
-
return l(e);
|
|
804
|
+
async function l(e) {
|
|
805
|
+
let { responsesToCommit: t, validationErrors: n } = await c(e);
|
|
806
|
+
return n.length ? { errors: n } : (a.registerBatch(t), { errors: [] });
|
|
780
807
|
}
|
|
781
|
-
let d =
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
808
|
+
let u = t.map((e) => e), d = E({
|
|
809
|
+
responses: t,
|
|
810
|
+
fields: e.fields.listStore
|
|
811
|
+
}, ({ responses: e, fields: t }) => {
|
|
812
|
+
let n = {};
|
|
813
|
+
for (let [r, i] of Object.entries(e)) {
|
|
814
|
+
let e = t.find((e) => e.id === r);
|
|
815
|
+
n[e?.key ?? r] = i;
|
|
786
816
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
fieldId:
|
|
793
|
-
|
|
817
|
+
return n;
|
|
818
|
+
}), p = E({
|
|
819
|
+
responses: t,
|
|
820
|
+
fields: e.fields.listStore
|
|
821
|
+
}, ({ responses: e, fields: t }) => Object.entries(e).map(([e, n]) => ({
|
|
822
|
+
fieldId: e,
|
|
823
|
+
fieldKey: t.find((t) => t.id === e)?.key ?? e,
|
|
824
|
+
value: n
|
|
794
825
|
})));
|
|
795
|
-
function
|
|
796
|
-
return
|
|
797
|
-
f: e.fields.
|
|
798
|
-
r:
|
|
799
|
-
}, ({ f: e, r: t }) => t
|
|
826
|
+
function m(n) {
|
|
827
|
+
return E({
|
|
828
|
+
f: e.fields.listStore.map((e) => e.find((e) => e.id === n) ?? null),
|
|
829
|
+
r: t.map((e) => e[n] ?? null)
|
|
830
|
+
}, ({ f: e, r: t }) => t === null ? e?.defaultValue ? e.defaultValue : null : t);
|
|
800
831
|
}
|
|
801
|
-
function
|
|
802
|
-
return
|
|
803
|
-
f: e.fields.
|
|
804
|
-
s:
|
|
832
|
+
function h(n) {
|
|
833
|
+
return E({
|
|
834
|
+
f: e.fields.getByKey(n),
|
|
835
|
+
s: t
|
|
836
|
+
}, ({ f: e, s: t }) => (e ? t[e.id] ?? null : null) || (e?.defaultValue ? e.defaultValue : null));
|
|
837
|
+
}
|
|
838
|
+
function g(n) {
|
|
839
|
+
return E({
|
|
840
|
+
f: e.fields.getByName(n),
|
|
841
|
+
s: t
|
|
805
842
|
}, ({ f: e, s: t }) => e && t[e.id] || (e?.defaultValue ? e.defaultValue : null));
|
|
806
843
|
}
|
|
807
|
-
return
|
|
844
|
+
return M({
|
|
845
|
+
clock: n,
|
|
846
|
+
target: a.clearAll
|
|
847
|
+
}), M({
|
|
808
848
|
clock: i,
|
|
809
|
-
target:
|
|
810
|
-
}), A({
|
|
811
|
-
clock: a,
|
|
812
|
-
target: o.clear
|
|
849
|
+
target: a.clear
|
|
813
850
|
}), {
|
|
814
|
-
register:
|
|
815
|
-
clearAll:
|
|
816
|
-
clear:
|
|
817
|
-
commit:
|
|
818
|
-
getResponsesToCommit:
|
|
819
|
-
listStore:
|
|
820
|
-
getAllStore:
|
|
821
|
-
|
|
851
|
+
register: o,
|
|
852
|
+
clearAll: n,
|
|
853
|
+
clear: i,
|
|
854
|
+
commit: l,
|
|
855
|
+
getResponsesToCommit: c,
|
|
856
|
+
listStore: p,
|
|
857
|
+
getAllStore: u,
|
|
858
|
+
getAllByKeyStore: d,
|
|
859
|
+
getByFieldId: m,
|
|
860
|
+
getByFieldKey: h,
|
|
822
861
|
getByFieldName: g
|
|
823
862
|
};
|
|
824
863
|
});
|
|
825
|
-
function
|
|
826
|
-
return
|
|
864
|
+
function Ze(e) {
|
|
865
|
+
return P(Xe, e);
|
|
866
|
+
}
|
|
867
|
+
//#endregion
|
|
868
|
+
//#region src/entities/condition/condition.ts
|
|
869
|
+
var Qe = O("condition"), $e = N(() => {
|
|
870
|
+
let e = Qe.store({}), t = D(e, { register(e, t) {
|
|
871
|
+
return {
|
|
872
|
+
...e,
|
|
873
|
+
[t.condition.id]: t.condition
|
|
874
|
+
};
|
|
875
|
+
} });
|
|
876
|
+
function n(e) {
|
|
877
|
+
t.register({ condition: e });
|
|
878
|
+
}
|
|
879
|
+
let r = e.map((e) => Object.values(e));
|
|
880
|
+
function i(t) {
|
|
881
|
+
return e.map((e) => e[t] ?? null);
|
|
882
|
+
}
|
|
883
|
+
function a(t) {
|
|
884
|
+
return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null);
|
|
885
|
+
}
|
|
886
|
+
return {
|
|
887
|
+
register: n,
|
|
888
|
+
getById: i,
|
|
889
|
+
getByKey: a,
|
|
890
|
+
listStore: r
|
|
891
|
+
};
|
|
892
|
+
});
|
|
893
|
+
function et() {
|
|
894
|
+
return P($e);
|
|
827
895
|
}
|
|
828
896
|
//#endregion
|
|
829
897
|
//#region src/utils/api-url.ts
|
|
830
|
-
function
|
|
831
|
-
if (
|
|
898
|
+
function tt() {
|
|
899
|
+
if (y()) {
|
|
832
900
|
let e = [
|
|
833
901
|
document.currentScript,
|
|
834
902
|
document.getElementById("picked_script"),
|
|
@@ -842,36 +910,36 @@ function Ve() {
|
|
|
842
910
|
}
|
|
843
911
|
//#endregion
|
|
844
912
|
//#region src/utils/search-params.ts
|
|
845
|
-
function
|
|
846
|
-
if (!
|
|
913
|
+
function nt() {
|
|
914
|
+
if (!g()) return {};
|
|
847
915
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
848
916
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
849
917
|
for (let r of n) {
|
|
850
918
|
let n = r.replace("picked-", "");
|
|
851
919
|
t[n] = e.getAll(r);
|
|
852
920
|
}
|
|
853
|
-
let r =
|
|
854
|
-
if (n.size > 0)
|
|
921
|
+
let r = w("s");
|
|
922
|
+
if (n.size > 0) C.set(r, t);
|
|
855
923
|
else {
|
|
856
|
-
let e =
|
|
924
|
+
let e = C.get(r);
|
|
857
925
|
if (e) return e.json() || {};
|
|
858
926
|
}
|
|
859
927
|
return t;
|
|
860
928
|
}
|
|
861
929
|
//#endregion
|
|
862
930
|
//#region src/utils/user-session.ts
|
|
863
|
-
function
|
|
864
|
-
return
|
|
931
|
+
function rt() {
|
|
932
|
+
return _() ? 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)}`;
|
|
865
933
|
}
|
|
866
|
-
var
|
|
867
|
-
let e =
|
|
934
|
+
var it = w("session", "global"), X = () => {
|
|
935
|
+
let e = S.get(it), t;
|
|
868
936
|
e.isSet() && (t = e.json());
|
|
869
937
|
let n = (t) => e.set({
|
|
870
938
|
id: t.id,
|
|
871
939
|
isUser: t.isUser,
|
|
872
940
|
identifiers: t.identifiers
|
|
873
941
|
}), r = {
|
|
874
|
-
id: t?.id ??
|
|
942
|
+
id: t?.id ?? rt(),
|
|
875
943
|
isUser: t?.isUser ?? void 0,
|
|
876
944
|
identifiers: t?.identifiers ?? void 0,
|
|
877
945
|
setIsUser(e) {
|
|
@@ -888,22 +956,22 @@ var We = S("session", "global"), Ge = () => {
|
|
|
888
956
|
}
|
|
889
957
|
};
|
|
890
958
|
return n(r), r;
|
|
891
|
-
},
|
|
959
|
+
}, at = () => v() ? X() : null;
|
|
892
960
|
//#endregion
|
|
893
961
|
//#region src/utils/picked-config.ts
|
|
894
962
|
function Z() {
|
|
895
|
-
if (
|
|
963
|
+
if (g()) return globalThis.window.pickedConfig;
|
|
896
964
|
}
|
|
897
|
-
function
|
|
898
|
-
if (!
|
|
965
|
+
function ot() {
|
|
966
|
+
if (!g()) return;
|
|
899
967
|
let e = Z(), t = e?.organizationId, n = e?.projectId;
|
|
900
968
|
return t && n ? {
|
|
901
969
|
organizationId: t,
|
|
902
970
|
projectId: n
|
|
903
971
|
} : void 0;
|
|
904
972
|
}
|
|
905
|
-
function
|
|
906
|
-
if (!
|
|
973
|
+
function st() {
|
|
974
|
+
if (!y()) return;
|
|
907
975
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
908
976
|
if (!e) return;
|
|
909
977
|
let t = e.dataset.organizationid || e.getAttribute("organization-id"), n = e.dataset.projectid || e.getAttribute("project-id");
|
|
@@ -912,15 +980,15 @@ function Je() {
|
|
|
912
980
|
projectId: n
|
|
913
981
|
} : void 0;
|
|
914
982
|
}
|
|
915
|
-
function
|
|
983
|
+
function ct(e) {
|
|
916
984
|
let { organizationId: t, projectId: n } = e;
|
|
917
985
|
if (t && n) return {
|
|
918
986
|
organizationId: t,
|
|
919
987
|
projectId: n
|
|
920
988
|
};
|
|
921
|
-
let r =
|
|
989
|
+
let r = ot();
|
|
922
990
|
if (r) return r;
|
|
923
|
-
let i =
|
|
991
|
+
let i = st();
|
|
924
992
|
if (i) return i;
|
|
925
993
|
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.");
|
|
926
994
|
}
|
|
@@ -929,7 +997,7 @@ function Ye(e) {
|
|
|
929
997
|
function Q(e) {
|
|
930
998
|
return e == null || e === "" || Number.isNaN(e);
|
|
931
999
|
}
|
|
932
|
-
var
|
|
1000
|
+
var lt = {
|
|
933
1001
|
default: (e, t) => Q(e) ? String(t ?? "") : String(e),
|
|
934
1002
|
append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
|
|
935
1003
|
prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
|
|
@@ -950,24 +1018,24 @@ var Xe = {
|
|
|
950
1018
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
951
1019
|
}
|
|
952
1020
|
};
|
|
953
|
-
function
|
|
1021
|
+
function ut(e) {
|
|
954
1022
|
return typeof e == "object" && !!e;
|
|
955
1023
|
}
|
|
956
|
-
function
|
|
1024
|
+
function dt(e, t) {
|
|
957
1025
|
let n = t;
|
|
958
|
-
for (let t of e.split(".")) if (
|
|
1026
|
+
for (let t of e.split(".")) if (ut(n) && t in n) n = n[t];
|
|
959
1027
|
else return;
|
|
960
1028
|
return typeof n == "function" ? n() : n;
|
|
961
1029
|
}
|
|
962
|
-
function
|
|
963
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1030
|
+
function ft(e, t) {
|
|
1031
|
+
let n = e.split("|").map((e) => e.trim()), r = dt(n.shift() ?? "", t);
|
|
964
1032
|
for (let e of n) {
|
|
965
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1033
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = lt[i];
|
|
966
1034
|
o && (r = o(r, a));
|
|
967
1035
|
}
|
|
968
1036
|
return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
969
1037
|
}
|
|
970
|
-
function
|
|
1038
|
+
function pt(e, t) {
|
|
971
1039
|
let n = "", r = 0;
|
|
972
1040
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
973
1041
|
r += 2;
|
|
@@ -979,19 +1047,20 @@ function et(e, t) {
|
|
|
979
1047
|
}
|
|
980
1048
|
i += e[r++];
|
|
981
1049
|
}
|
|
982
|
-
n +=
|
|
1050
|
+
n += ft(i.trim(), t);
|
|
983
1051
|
} else n += e[r++];
|
|
984
1052
|
return n;
|
|
985
1053
|
}
|
|
986
1054
|
//#endregion
|
|
987
1055
|
//#region src/picked.ts
|
|
988
1056
|
var $ = class {
|
|
989
|
-
static logger =
|
|
1057
|
+
static logger = p;
|
|
990
1058
|
options;
|
|
991
1059
|
isReady = !1;
|
|
1060
|
+
project;
|
|
992
1061
|
plugins = {};
|
|
993
1062
|
pluginStartHooks = [];
|
|
994
|
-
eventBus =
|
|
1063
|
+
eventBus = A();
|
|
995
1064
|
events;
|
|
996
1065
|
organizationId;
|
|
997
1066
|
projectId;
|
|
@@ -1002,42 +1071,44 @@ var $ = class {
|
|
|
1002
1071
|
precondition;
|
|
1003
1072
|
condition;
|
|
1004
1073
|
preconditionPassed;
|
|
1005
|
-
searchParams =
|
|
1006
|
-
history =
|
|
1007
|
-
components =
|
|
1008
|
-
experienceInstances =
|
|
1009
|
-
experiences =
|
|
1010
|
-
frameworks =
|
|
1011
|
-
predicates =
|
|
1012
|
-
features =
|
|
1013
|
-
|
|
1014
|
-
fields =
|
|
1015
|
-
|
|
1074
|
+
searchParams = nt();
|
|
1075
|
+
history = ke();
|
|
1076
|
+
components = pe({ client: this });
|
|
1077
|
+
experienceInstances = o({ client: this });
|
|
1078
|
+
experiences = de({ client: this });
|
|
1079
|
+
frameworks = ge({ client: this });
|
|
1080
|
+
predicates = Ce({ client: this });
|
|
1081
|
+
features = Ee({ client: this });
|
|
1082
|
+
conditions = et();
|
|
1083
|
+
fields = Pe();
|
|
1084
|
+
responses = Ze({ client: this });
|
|
1085
|
+
steps = Re();
|
|
1086
|
+
actions = He();
|
|
1016
1087
|
constructor(e) {
|
|
1017
|
-
this.events =
|
|
1018
|
-
let { organizationId: t, projectId: n } =
|
|
1019
|
-
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl ||
|
|
1088
|
+
this.events = je(this.eventBus);
|
|
1089
|
+
let { organizationId: t, projectId: n } = ct(e);
|
|
1090
|
+
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = at(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
|
|
1020
1091
|
type: "load",
|
|
1021
|
-
version:
|
|
1092
|
+
version: oe()
|
|
1022
1093
|
});
|
|
1023
1094
|
}
|
|
1024
1095
|
start = () => {
|
|
1025
|
-
|
|
1026
|
-
if (!
|
|
1096
|
+
be(this), (async () => {
|
|
1097
|
+
if (!y()) return;
|
|
1027
1098
|
await this.runPluginStartHooks();
|
|
1028
1099
|
let e = await this.evaluateGate(this.precondition);
|
|
1029
1100
|
this.preconditionPassed = e;
|
|
1030
|
-
let
|
|
1031
|
-
e && (
|
|
1032
|
-
let
|
|
1033
|
-
if (typeof
|
|
1034
|
-
let e =
|
|
1101
|
+
let n;
|
|
1102
|
+
e && (n = await this.evaluateGate(this.condition));
|
|
1103
|
+
let r = e && n === !0;
|
|
1104
|
+
if (typeof n == "boolean" && this.session) {
|
|
1105
|
+
let e = n;
|
|
1035
1106
|
this.session.setIsUser(e), this.eventBus({
|
|
1036
1107
|
type: "user_decide",
|
|
1037
1108
|
value: e
|
|
1038
1109
|
});
|
|
1039
1110
|
}
|
|
1040
|
-
if (this.eventBus({ type: "initialize" }),
|
|
1111
|
+
if (this.eventBus({ type: "initialize" }), r && L(this), await t(), r && L(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1041
1112
|
let { id: e, isUser: t, identifiers: n } = this.session;
|
|
1042
1113
|
this.eventBus({
|
|
1043
1114
|
type: "session",
|
|
@@ -1049,46 +1120,52 @@ var $ = class {
|
|
|
1049
1120
|
})();
|
|
1050
1121
|
};
|
|
1051
1122
|
registerFramework = (e) => {
|
|
1052
|
-
|
|
1123
|
+
_e(e, this.frameworks);
|
|
1053
1124
|
};
|
|
1054
1125
|
registerComponent = (e, t) => {
|
|
1055
1126
|
U(e, t, this.components);
|
|
1056
1127
|
};
|
|
1057
1128
|
registerPlugin = (e) => {
|
|
1058
|
-
|
|
1129
|
+
z(this, e, this.plugins);
|
|
1059
1130
|
let t = this.plugins[e.name];
|
|
1060
1131
|
t?.onStart && this.pluginStartHooks.push(t.onStart);
|
|
1061
1132
|
};
|
|
1062
1133
|
registerFeature = (e, t) => {
|
|
1063
|
-
|
|
1134
|
+
De(e, t, this.features);
|
|
1064
1135
|
};
|
|
1065
1136
|
registerPredicate = (e, t) => {
|
|
1066
|
-
|
|
1137
|
+
we(e, t, this.predicates);
|
|
1138
|
+
};
|
|
1139
|
+
registerCondition = (e) => {
|
|
1140
|
+
this.conditions.register(e);
|
|
1067
1141
|
};
|
|
1068
1142
|
registerField = (e) => {
|
|
1069
|
-
|
|
1143
|
+
Fe(e, this.fields);
|
|
1144
|
+
};
|
|
1145
|
+
registerStep = (e) => {
|
|
1146
|
+
ze(e, this.steps);
|
|
1070
1147
|
};
|
|
1071
1148
|
registerAction = (e, t) => {
|
|
1072
|
-
|
|
1149
|
+
Ue(e, t, this.actions);
|
|
1073
1150
|
};
|
|
1074
1151
|
registerExperience = (e) => {
|
|
1075
|
-
e.component && U(`experience:${e.id}`, e.component, this.components),
|
|
1152
|
+
e.component && U(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1076
1153
|
};
|
|
1077
1154
|
getStateSnapshot = () => W(this);
|
|
1078
1155
|
launchExperienceById = async (e, t) => {
|
|
1079
1156
|
this.experiences.launch({
|
|
1080
|
-
|
|
1157
|
+
key: e,
|
|
1081
1158
|
options: t
|
|
1082
1159
|
});
|
|
1083
1160
|
};
|
|
1084
1161
|
openExperienceById = async (e) => {
|
|
1085
|
-
this.experiences.open({
|
|
1162
|
+
this.experiences.open({ key: e });
|
|
1086
1163
|
};
|
|
1087
1164
|
async runPluginStartHooks() {
|
|
1088
1165
|
for (let e of this.pluginStartHooks) await e();
|
|
1089
1166
|
}
|
|
1090
1167
|
async evaluateGate(e) {
|
|
1091
|
-
return e === void 0 ? !0 : typeof e == "boolean" ? e : await
|
|
1168
|
+
return e === void 0 ? !0 : typeof e == "boolean" ? e : await r(this, e) === !0;
|
|
1092
1169
|
}
|
|
1093
1170
|
setupPlugins() {
|
|
1094
1171
|
this.options.plugins?.forEach((e) => {
|
|
@@ -1154,7 +1231,7 @@ var $ = class {
|
|
|
1154
1231
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1155
1232
|
renderString = (e, t) => {
|
|
1156
1233
|
let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldId] = t.value, e), {});
|
|
1157
|
-
return
|
|
1234
|
+
return pt(e, {
|
|
1158
1235
|
...t,
|
|
1159
1236
|
responses: n
|
|
1160
1237
|
});
|
|
@@ -1162,20 +1239,20 @@ var $ = class {
|
|
|
1162
1239
|
};
|
|
1163
1240
|
//#endregion
|
|
1164
1241
|
//#region src/entities/component/lazyComponent.ts
|
|
1165
|
-
function
|
|
1242
|
+
function mt(e) {
|
|
1166
1243
|
return {
|
|
1167
1244
|
$$type: "lazy-component",
|
|
1168
1245
|
load: e
|
|
1169
1246
|
};
|
|
1170
1247
|
}
|
|
1171
|
-
function
|
|
1248
|
+
function ht(e) {
|
|
1172
1249
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1173
1250
|
}
|
|
1174
1251
|
//#endregion
|
|
1175
1252
|
//#region src/exports.ts
|
|
1176
|
-
var
|
|
1253
|
+
var gt = (e) => {
|
|
1177
1254
|
let t = new $(e);
|
|
1178
|
-
return
|
|
1255
|
+
return ne(t), t;
|
|
1179
1256
|
};
|
|
1180
1257
|
//#endregion
|
|
1181
|
-
export { $ as Picked,
|
|
1258
|
+
export { $ as Picked, gt as createClient, w as createStorageKey, r as evaluateRuleLogic, Z as getPickedConfig, ht as isLazyLoader, d as isPickedRoot, mt as lazyComponent, S as localStore, C as sessionStore, x as subscribe, ie as supportsCookies, _ as supportsCryptoRandomUUID, y as supportsDocument, ee as supportsHistory, m as supportsIntersectionObserver, v as supportsLocalStorage, re as supportsLocation, h as supportsSessionStorage, te as supportsShadowRoot, b as supportsWebComponents, g as supportsWindow };
|