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