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