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