@viamedici-spc/configurator-react 1.1.0-alpha0002 → 1.1.0-alpha0003
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 +26 -33
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +409 -96
- package/dist/index.js +1038 -703
- package/package.json +18 -18
package/dist/index.js
CHANGED
|
@@ -1,764 +1,1099 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { pipe as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { GlobalAttributeIdKeyBuilder as St, globalAttributeIdKeyEq as Nt, globalAttributeIdEq as Wt, Logger as x, SessionFactory as Bt, DecisionKind as L, AttributeType as J, ExplainQuestionSubject as N, AttributeRefinements as rt, AttributeInterpreter as O, ExplainQuestionType as It, ChoiceValueInterpreter as wt } from "@viamedici-spc/configurator-ts";
|
|
2
|
+
import { pipe as j, RA as k, RM as H, Ord as kt, O as K, identity as et, Eq as b, Bool as at, Str as Rt, TE as nt, E as Ot, T as Lt, constVoid as Kt } from "@viamedici-spc/fp-ts-extensions";
|
|
3
|
+
import { atom as f, getDefaultStore as Qt, useSetAtom as Ft, useAtomValue as yt, useAtom as G, Provider as $t } from "jotai";
|
|
4
|
+
import { createContext as Et, useContext as Mt, useMemo as X, useEffect as gt } from "react";
|
|
5
|
+
import { useStableMemo as Jt } from "fp-ts-react-stable-hooks";
|
|
6
|
+
import { selectAtom as zt, atomFamily as _ } from "jotai/utils";
|
|
7
|
+
import Ht from "p-defer";
|
|
8
|
+
import { jsx as q, Fragment as Pt, jsxs as Xt } from "react/jsx-runtime";
|
|
9
|
+
import { guid as Yt } from "dyna-guid";
|
|
10
|
+
import { atomEffect as ut } from "jotai-effect";
|
|
11
|
+
import { atomWithMachine as Zt } from "jotai-xstate";
|
|
12
|
+
import { fromPromise as Gt, setup as te, assign as Dt, log as ee, enqueueActions as ft } from "xstate";
|
|
13
|
+
const E = "ConfigurationUninitialized";
|
|
14
|
+
function D(t) {
|
|
15
|
+
return f((e) => {
|
|
16
|
+
try {
|
|
17
|
+
const n = t(e, (i) => {
|
|
18
|
+
const o = e(i);
|
|
19
|
+
if (o === E)
|
|
20
|
+
throw E;
|
|
21
|
+
return o;
|
|
22
|
+
});
|
|
23
|
+
return n ?? E;
|
|
24
|
+
} catch (n) {
|
|
25
|
+
if (n === E)
|
|
26
|
+
return E;
|
|
27
|
+
throw n;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function At(t) {
|
|
32
|
+
const { guardedConfigurationAtom: e, guardedAttributesAtom: n } = t;
|
|
33
|
+
function i(o, s) {
|
|
34
|
+
const r = o === "all" ? "all" : j(
|
|
35
|
+
o,
|
|
36
|
+
k.map((u) => typeof u == "string" ? u : St(u))
|
|
37
|
+
);
|
|
38
|
+
return D((u, a) => {
|
|
39
|
+
if (r === "all")
|
|
40
|
+
return j(e, a, (m) => m.attributes, H.values(kt.trivial));
|
|
41
|
+
const c = a(n);
|
|
42
|
+
return j(
|
|
43
|
+
r,
|
|
44
|
+
k.map((m) => u(c(m))),
|
|
45
|
+
s ? k.filterMap(K.fromNullable) : et
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return i;
|
|
50
|
+
}
|
|
51
|
+
const Ct = window.configuratorReactContexts ?? {
|
|
52
|
+
AtomsContext: Et(null),
|
|
53
|
+
StoreContext: Et(Qt())
|
|
15
54
|
};
|
|
16
|
-
window.configuratorReactContexts =
|
|
17
|
-
const
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
function z() {
|
|
27
|
-
const e = j();
|
|
28
|
-
return B(e), d(() => ({
|
|
29
|
-
makeDecision: (n) => e.makeDecision(n),
|
|
30
|
-
setManyDecision: (n, s) => e.setMany(n, s)
|
|
31
|
-
}), [e]);
|
|
32
|
-
}
|
|
33
|
-
globalThis && globalThis.__spreadArray;
|
|
34
|
-
var he = function(e) {
|
|
35
|
-
return e._tag === "Some";
|
|
36
|
-
}, k = function(e) {
|
|
37
|
-
return function(n) {
|
|
38
|
-
return he(e(n));
|
|
55
|
+
window.configuratorReactContexts = Ct;
|
|
56
|
+
const Ut = Ct.AtomsContext, qt = Ct.StoreContext, W = () => Mt(Ut), ct = () => Mt(qt);
|
|
57
|
+
function xt(t, e, n) {
|
|
58
|
+
const i = b.tuple(b.eqNullable(at.Eq), n);
|
|
59
|
+
return (o, ...s) => {
|
|
60
|
+
const r = W(), u = ct(), a = Ft(r.selectors.subscriberAtom, { store: u }), c = Jt(() => o ?? !0 ? e(r, ...s) : t(r, ...s), [o, s], i), m = X(() => a(c), [a, c]);
|
|
61
|
+
return gt(() => () => {
|
|
62
|
+
m.unsubscribe();
|
|
63
|
+
}, [m]), yt(c, { store: u });
|
|
39
64
|
};
|
|
40
|
-
};
|
|
41
|
-
const ye = k((e) => e.type === S.Choice ? U(e) : D), Ee = k((e) => e.type === S.Numeric ? U(e) : D), xe = k((e) => e.type === S.Boolean ? U(e) : D), Re = k((e) => e.type === S.Component ? U(e) : D);
|
|
42
|
-
function _(e) {
|
|
43
|
-
return e.decision != null && e.decision.kind === te.Explicit;
|
|
44
|
-
}
|
|
45
|
-
function se(e) {
|
|
46
|
-
return m(
|
|
47
|
-
e.values,
|
|
48
|
-
l.filter(_),
|
|
49
|
-
l.map((n) => ({
|
|
50
|
-
type: S.Choice,
|
|
51
|
-
attributeId: e.id,
|
|
52
|
-
choiceValueId: n.id,
|
|
53
|
-
state: null
|
|
54
|
-
}))
|
|
55
|
-
);
|
|
56
65
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
attributeId: e.id,
|
|
64
|
-
state: null
|
|
65
|
-
}))
|
|
66
|
-
);
|
|
66
|
+
function y(t, e) {
|
|
67
|
+
const n = xt((o) => t(o.selectors), (o) => e(o.suspended), b.tuple());
|
|
68
|
+
function i(o) {
|
|
69
|
+
return n(o);
|
|
70
|
+
}
|
|
71
|
+
return i;
|
|
67
72
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
state: null
|
|
76
|
-
}))
|
|
77
|
-
);
|
|
73
|
+
function lt(t, e) {
|
|
74
|
+
const n = xt((o, s) => t(o.selectors)(s), (o, s) => e(o.suspended)(s), b.tuple(Rt.Eq));
|
|
75
|
+
function i(o, s) {
|
|
76
|
+
const r = X(() => typeof o == "string" ? o : St(o), [o]);
|
|
77
|
+
return n(s, r);
|
|
78
|
+
}
|
|
79
|
+
return i;
|
|
78
80
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
function g(t) {
|
|
82
|
+
const e = zt(t, (n, i) => {
|
|
83
|
+
if (n !== E)
|
|
84
|
+
return (i == null ? void 0 : i.deferredPromise) != null ? (i.deferredPromise.resolve(n), {
|
|
85
|
+
deferredPromise: null,
|
|
86
|
+
result: i.deferredPromise.promise
|
|
87
|
+
}) : {
|
|
88
|
+
deferredPromise: null,
|
|
89
|
+
result: n
|
|
90
|
+
};
|
|
91
|
+
const o = (i == null ? void 0 : i.deferredPromise) ?? Ht();
|
|
92
|
+
return {
|
|
93
|
+
deferredPromise: o,
|
|
94
|
+
result: o.promise
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
return f((n) => n(e).result);
|
|
89
98
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
),
|
|
99
|
-
m(
|
|
100
|
-
s,
|
|
101
|
-
l.filter(Ee),
|
|
102
|
-
l.map(be),
|
|
103
|
-
l.compact
|
|
104
|
-
),
|
|
105
|
-
m(
|
|
106
|
-
s,
|
|
107
|
-
l.filter(xe),
|
|
108
|
-
l.map(we),
|
|
109
|
-
l.compact
|
|
110
|
-
),
|
|
111
|
-
m(
|
|
112
|
-
s,
|
|
113
|
-
l.filter(Re),
|
|
114
|
-
l.map(Ae),
|
|
115
|
-
l.compact
|
|
116
|
-
)
|
|
117
|
-
],
|
|
118
|
-
l.flatten
|
|
119
|
-
);
|
|
99
|
+
const ne = b.union().with((t) => typeof t == "string", Nt).with((t) => typeof t == "object", Wt), ie = b.union().with((t) => t === "all", Rt.Eq).with((t) => Array.isArray(t), k.getEq(ne)), oe = xt(
|
|
100
|
+
(t, e, n) => At(t.selectors)(e, n),
|
|
101
|
+
(t, e, n) => g(At(t.selectors)(e, n)),
|
|
102
|
+
b.tuple(ie, b.eqNullable(at.Eq))
|
|
103
|
+
);
|
|
104
|
+
function Fn(t, e, n) {
|
|
105
|
+
const i = t == "all" ? e : n, o = t == "all" ? void 0 : e;
|
|
106
|
+
return oe(i, t, o);
|
|
120
107
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
applySolution: (n) => e.applySolution(n)
|
|
126
|
-
}), [e]);
|
|
127
|
-
}
|
|
128
|
-
function nn(e, n = !1) {
|
|
129
|
-
const s = x();
|
|
130
|
-
return R(s), d(
|
|
131
|
-
() => m(
|
|
132
|
-
a.fromNullable(e),
|
|
133
|
-
a.map(le(
|
|
134
|
-
l.map((i) => E.getAttribute(s, i)),
|
|
135
|
-
n ? l.filterMap(a.fromNullable) : ue
|
|
136
|
-
)),
|
|
137
|
-
a.getOrElse(() => s.attributes)
|
|
138
|
-
),
|
|
139
|
-
[e, s, n]
|
|
140
|
-
);
|
|
108
|
+
const Mn = lt((t) => t.choiceAttributeAtomFamily, (t) => t.choiceAttributeAtomFamily), zn = lt((t) => t.numericAttributeAtomFamily, (t) => t.numericAttributeAtomFamily), Pn = lt((t) => t.booleanAttributeAtomFamily, (t) => t.booleanAttributeAtomFamily), Un = lt((t) => t.componentAttributeAtomFamily, (t) => t.componentAttributeAtomFamily);
|
|
109
|
+
function se() {
|
|
110
|
+
const { effects: t } = W(), { addSessionListenersEffect: e, cleanupAtomFamiliesEffect: n, atomSubscriberEffect: i, atomSubscriptionCleanupEffect: o } = t;
|
|
111
|
+
return G(e), G(n), G(i), G(o), null;
|
|
141
112
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
a.getOrElse(() => () => Promise.resolve())
|
|
218
|
-
),
|
|
219
|
-
...t
|
|
220
|
-
}), [e, s, o, i, t]), r = d(() => ({
|
|
221
|
-
...g,
|
|
222
|
-
attribute: u
|
|
223
|
-
}), [u, g]);
|
|
224
|
-
if (u)
|
|
225
|
-
return r;
|
|
226
|
-
}
|
|
227
|
-
function O(e, n) {
|
|
228
|
-
const { explain: s, applySolution: i } = qe();
|
|
229
|
-
return d(() => ({
|
|
230
|
-
explain: (t, o) => {
|
|
231
|
-
const u = M(t.question).with(oe.whyIsNotSatisfied, () => w.attribute).otherwise(() => n), g = {
|
|
232
|
-
...t,
|
|
233
|
-
subject: u,
|
|
234
|
-
attributeId: e
|
|
235
|
-
};
|
|
236
|
-
return M(o).with("decisions", (r) => s(g, r)).with("constraints", (r) => s(g, r)).with("full", (r) => s(g, r)).exhaustive();
|
|
237
|
-
},
|
|
238
|
-
applySolution: i
|
|
239
|
-
}), [e, n, s, i]);
|
|
240
|
-
}
|
|
241
|
-
const J = c.fromEquals(re), ve = c.fromEquals(ae), Me = c.fromEquals((e, n) => ce.getEq(I.Eq).equals(e ?? {}, n ?? {})), Ue = c.struct({
|
|
242
|
-
attributeId: J,
|
|
243
|
-
decisions: l.getEq(J)
|
|
244
|
-
}), De = c.fromEquals((e, n) => l.getEq(Ue).equals(e ?? [], n ?? [])), Ie = c.struct({
|
|
245
|
-
type: I.Eq
|
|
246
|
-
}), Ne = c.struct({
|
|
247
|
-
type: I.Eq
|
|
248
|
-
}), ze = c.struct({
|
|
249
|
-
type: I.Eq,
|
|
250
|
-
rules: l.getEq(ve)
|
|
251
|
-
}), ke = c.fromEquals((e, n) => M({ x: e, y: n }).returnType().with({ x: { type: h.all }, y: { type: h.all } }, ({ x: s, y: i }) => Ie.equals(s, i)).with({ x: { type: h.none }, y: { type: h.none } }, ({ x: s, y: i }) => Ne.equals(s, i)).with({ x: { type: h.specific }, y: { type: h.specific } }, ({ x: s, y: i }) => ze.equals(s, i)).otherwise(() => !1)), _e = c.struct({
|
|
252
|
-
rules: c.eqNullable(ke)
|
|
253
|
-
}), ie = c.struct({
|
|
254
|
-
configurationModelSource: c.fromEquals((e, n) => me(e, n)),
|
|
255
|
-
attributeRelations: De,
|
|
256
|
-
usageRuleParameters: Me,
|
|
257
|
-
allowedInExplain: c.eqNullable(_e)
|
|
258
|
-
}), T = c.eqNullable(ie), Oe = c.eqStrict, v = c.eqNullable(Oe), Te = () => F({
|
|
259
|
-
predictableActionArguments: !0,
|
|
260
|
-
preserveActionOrder: !0,
|
|
261
|
-
schema: {
|
|
113
|
+
const re = 30 * 1e3, ae = WeakRef != null ? (t) => new WeakRef(t) : (t) => ({
|
|
114
|
+
deref: () => t
|
|
115
|
+
});
|
|
116
|
+
function ue() {
|
|
117
|
+
return f(H.empty);
|
|
118
|
+
}
|
|
119
|
+
function ce(t) {
|
|
120
|
+
return f(null, (e, n, i) => {
|
|
121
|
+
const o = Yt();
|
|
122
|
+
x.debug("AtomSubscription:", "Creating subscription with id", o);
|
|
123
|
+
const r = {
|
|
124
|
+
unsubscribe: () => {
|
|
125
|
+
n(t.subscriptionsAtom, (u) => {
|
|
126
|
+
const a = u.get(i);
|
|
127
|
+
if (a == null)
|
|
128
|
+
return u;
|
|
129
|
+
const c = new Map(a);
|
|
130
|
+
c.delete(o);
|
|
131
|
+
const m = new Map(u);
|
|
132
|
+
return m.set(i, c), m;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
return n(t.subscriptionsAtom, (u) => {
|
|
137
|
+
const a = new Map(u.get(i) ?? H.empty);
|
|
138
|
+
a.set(o, ae(r));
|
|
139
|
+
const c = new Map(u);
|
|
140
|
+
return c.set(i, a), c;
|
|
141
|
+
}), r;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function le(t) {
|
|
145
|
+
return ut((e) => {
|
|
146
|
+
const i = [...e(t.subscriptionsAtom).keys()];
|
|
147
|
+
x.debug("AtomSubscriber:", "There are", i.length, "Atoms to subscribe to.");
|
|
148
|
+
for (const o of i)
|
|
149
|
+
e(o);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function me(t) {
|
|
153
|
+
return ut((e, n) => {
|
|
154
|
+
const i = setInterval(() => {
|
|
155
|
+
x.info("AtomSubscriptionCleanup:", "Running cleanup");
|
|
156
|
+
let o = !1;
|
|
157
|
+
n(t.subscriptionsAtom, (s) => {
|
|
158
|
+
const r = new Map(s);
|
|
159
|
+
for (const u of [...r.keys()]) {
|
|
160
|
+
const a = new Map(r.get(u) ?? H.empty);
|
|
161
|
+
for (const c of [...a.keys()]) {
|
|
162
|
+
const m = a.get(c);
|
|
163
|
+
(m === void 0 || m.deref() === void 0) && (x.debug("AtomSubscriptionCleanup:", "Deleting subscription", c, "because it got garbage collected."), a.delete(c), o = !0);
|
|
164
|
+
}
|
|
165
|
+
r.set(u, a), a.size === 0 && (x.debug("AtomSubscriptionCleanup:", "Delete Atom with 0 subscriptions."), r.delete(u), o = !0);
|
|
166
|
+
}
|
|
167
|
+
return x.debug("AtomSubscriptionCleanup:", "There are", r.size, "Atoms with", [...r.values(), k.flatten].length, "subscriptions left."), o ? r : s;
|
|
168
|
+
});
|
|
169
|
+
}, re);
|
|
170
|
+
return () => {
|
|
171
|
+
clearInterval(i);
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const de = Gt(({ input: t }) => j(
|
|
176
|
+
t.session,
|
|
177
|
+
K.match(
|
|
178
|
+
() => () => Bt.createSession(t.sessionContext),
|
|
179
|
+
(e) => async () => (await e.setSessionContext(t.sessionContext), e)
|
|
180
|
+
),
|
|
181
|
+
(e) => nt.tryCatch(e, (n) => n),
|
|
182
|
+
nt.mapLeft((e) => ({
|
|
183
|
+
sessionContext: t.sessionContext,
|
|
184
|
+
configurationError: e
|
|
185
|
+
}))
|
|
186
|
+
)()), fe = te({
|
|
187
|
+
types: {
|
|
262
188
|
context: {},
|
|
263
189
|
events: {}
|
|
264
190
|
},
|
|
191
|
+
actors: {
|
|
192
|
+
createOrUpdateSession: de
|
|
193
|
+
},
|
|
194
|
+
guards: {
|
|
195
|
+
shallProcess: ({ context: t }) => (
|
|
196
|
+
// If there is no error or the SessionContext that resulted in an error is no longer desired.
|
|
197
|
+
(t.sessionCreateOrUpdateError == null || t.sessionCreateOrUpdateError.sessionContext !== t.desiredSessionContext) && // Initially there is no Session but a SessionContext
|
|
198
|
+
(t.configurationSession == null && t.desiredSessionContext != null || t.configurationSession != null && t.configurationSession.getSessionContext() !== t.desiredSessionContext)
|
|
199
|
+
),
|
|
200
|
+
shallDispose: ({ context: t }) => t.configurationSession != null && t.desiredSessionContext == null
|
|
201
|
+
}
|
|
202
|
+
}).createMachine({
|
|
265
203
|
context: {
|
|
266
|
-
desiredClient: null,
|
|
267
204
|
desiredSessionContext: null,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
sessionCreationError: null,
|
|
271
|
-
sessionUpdateError: null,
|
|
272
|
-
hasEverSuccessfullyCreatedSession: !1
|
|
205
|
+
configurationSession: null,
|
|
206
|
+
sessionCreateOrUpdateError: null
|
|
273
207
|
},
|
|
274
|
-
initial: "ProcessChanges",
|
|
275
208
|
on: {
|
|
276
|
-
|
|
277
|
-
actions: [
|
|
209
|
+
Retry: {
|
|
210
|
+
actions: [
|
|
211
|
+
Dt({
|
|
212
|
+
sessionCreateOrUpdateError: () => null
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
SessionContextChanged: {
|
|
217
|
+
actions: [
|
|
218
|
+
ee("SessionContextChanged"),
|
|
219
|
+
Dt({
|
|
220
|
+
desiredSessionContext: ({ event: t }) => t.sessionContext
|
|
221
|
+
})
|
|
222
|
+
]
|
|
278
223
|
},
|
|
279
|
-
|
|
280
|
-
|
|
224
|
+
Shutdown: {
|
|
225
|
+
target: "#shutdown"
|
|
281
226
|
}
|
|
282
227
|
},
|
|
283
|
-
|
|
284
|
-
C("Shutting down", "SessionManagement:"),
|
|
285
|
-
"disposeOldSession"
|
|
286
|
-
],
|
|
228
|
+
initial: "Idle",
|
|
287
229
|
states: {
|
|
288
|
-
|
|
289
|
-
entry: [
|
|
290
|
-
C("Entering ProcessChanges", "SessionManagement:"),
|
|
291
|
-
y(
|
|
292
|
-
2
|
|
293
|
-
/* Other */
|
|
294
|
-
)
|
|
295
|
-
],
|
|
230
|
+
Idle: {
|
|
296
231
|
always: [
|
|
297
|
-
{ target: "DisposeSession",
|
|
298
|
-
{ target: "
|
|
299
|
-
{ target: "UpdateSession", cond: "shallUpdateSession" }
|
|
232
|
+
{ target: "DisposeSession", guard: "shallDispose" },
|
|
233
|
+
{ target: "Processing", guard: "shallProcess" }
|
|
300
234
|
]
|
|
301
235
|
},
|
|
302
|
-
|
|
303
|
-
entry: [
|
|
304
|
-
C("Entering DisposeSession", "SessionManagement:"),
|
|
305
|
-
y(
|
|
306
|
-
2
|
|
307
|
-
/* Other */
|
|
308
|
-
)
|
|
309
|
-
],
|
|
310
|
-
always: {
|
|
311
|
-
actions: ["disposeOldSession"],
|
|
312
|
-
target: "ProcessChanges"
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
CreateSession: {
|
|
316
|
-
entry: [
|
|
317
|
-
C("Entering CreateSession", "SessionManagement:"),
|
|
318
|
-
y(
|
|
319
|
-
0
|
|
320
|
-
/* CreateSession */
|
|
321
|
-
)
|
|
322
|
-
],
|
|
236
|
+
Processing: {
|
|
323
237
|
invoke: {
|
|
324
|
-
|
|
325
|
-
|
|
238
|
+
src: "createOrUpdateSession",
|
|
239
|
+
input: ({ context: t }) => ({
|
|
240
|
+
sessionContext: t.desiredSessionContext,
|
|
241
|
+
session: K.fromNullable(t.configurationSession)
|
|
242
|
+
}),
|
|
326
243
|
onDone: {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
entry: [
|
|
338
|
-
C("Entering SessionCreationFailed", "SessionManagement:"),
|
|
339
|
-
y(
|
|
340
|
-
2
|
|
341
|
-
/* Other */
|
|
342
|
-
)
|
|
343
|
-
],
|
|
344
|
-
always: {
|
|
345
|
-
// Immediately process changes if there were changes during session creation attempt
|
|
346
|
-
// This will also be triggered if session context or client changes
|
|
347
|
-
target: "ProcessChanges",
|
|
348
|
-
cond: "shallImmediatelyProcessChangesAfterSessionCreationError"
|
|
349
|
-
},
|
|
350
|
-
exit: [
|
|
351
|
-
C("Exiting SessionCreationFailed", "SessionManagement:"),
|
|
352
|
-
"clearSessionCreationError"
|
|
353
|
-
],
|
|
354
|
-
on: {
|
|
355
|
-
RetrySessionCreation: {
|
|
356
|
-
target: "ProcessChanges",
|
|
357
|
-
actions: C("Retrying session creation", "SessionManagement:")
|
|
244
|
+
target: "Idle",
|
|
245
|
+
actions: [
|
|
246
|
+
ft(({ event: t, enqueue: e }) => {
|
|
247
|
+
Ot.isRight(t.output) ? e.assign({
|
|
248
|
+
configurationSession: t.output.right
|
|
249
|
+
}) : e.assign({
|
|
250
|
+
sessionCreateOrUpdateError: t.output.left
|
|
251
|
+
});
|
|
252
|
+
})
|
|
253
|
+
]
|
|
358
254
|
}
|
|
359
255
|
}
|
|
360
256
|
},
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
actions: "setSessionUpdateError",
|
|
377
|
-
target: "SessionUpdateFailed"
|
|
378
|
-
}
|
|
379
|
-
}
|
|
257
|
+
DisposeSession: {
|
|
258
|
+
always: [{
|
|
259
|
+
target: "Idle",
|
|
260
|
+
actions: [
|
|
261
|
+
ft(({ enqueue: t, context: e }) => {
|
|
262
|
+
nt.tryCatch(async () => {
|
|
263
|
+
var n;
|
|
264
|
+
return await ((n = e.configurationSession) == null ? void 0 : n.close());
|
|
265
|
+
}, et)(), t.assign({
|
|
266
|
+
configurationSession: () => null,
|
|
267
|
+
sessionCreateOrUpdateError: () => null
|
|
268
|
+
});
|
|
269
|
+
})
|
|
270
|
+
]
|
|
271
|
+
}]
|
|
380
272
|
},
|
|
381
|
-
|
|
273
|
+
Shutdown: {
|
|
274
|
+
type: "final",
|
|
275
|
+
id: "shutdown",
|
|
382
276
|
entry: [
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
},
|
|
395
|
-
exit: [
|
|
396
|
-
C("Exiting SessionUpdateFailed", "SessionManagement:"),
|
|
397
|
-
"clearSessionUpdateError"
|
|
398
|
-
],
|
|
399
|
-
on: {
|
|
400
|
-
RetrySessionUpdate: {
|
|
401
|
-
target: "ProcessChanges",
|
|
402
|
-
actions: C("Retrying session update", "SessionManagement:")
|
|
403
|
-
}
|
|
404
|
-
}
|
|
277
|
+
ft(({ context: t, enqueue: e }) => {
|
|
278
|
+
t.configurationSession && nt.tryCatch(async () => {
|
|
279
|
+
var n;
|
|
280
|
+
return await ((n = t.configurationSession) == null ? void 0 : n.close());
|
|
281
|
+
}, et)(), e.assign({
|
|
282
|
+
configurationSession: () => null,
|
|
283
|
+
desiredSessionContext: () => null,
|
|
284
|
+
sessionCreateOrUpdateError: () => null
|
|
285
|
+
});
|
|
286
|
+
})
|
|
287
|
+
]
|
|
405
288
|
}
|
|
406
289
|
}
|
|
407
|
-
}, {
|
|
408
|
-
actions: {
|
|
409
|
-
saveDesiredClient: f({
|
|
410
|
-
desiredClient: (e, n) => n.client
|
|
411
|
-
}),
|
|
412
|
-
saveDesiredSessionContext: f({
|
|
413
|
-
desiredSessionContext: (e, n) => n.sessionContext
|
|
414
|
-
}),
|
|
415
|
-
disposeOldSession: f((e, n) => (e.session && e.session.close().then(ge).catch((s) => {
|
|
416
|
-
}), {
|
|
417
|
-
session: null,
|
|
418
|
-
actualClient: null
|
|
419
|
-
})),
|
|
420
|
-
setSessionCreationResult: f((e, n) => ({
|
|
421
|
-
session: n.data.session,
|
|
422
|
-
actualClient: n.data.client
|
|
423
|
-
})),
|
|
424
|
-
setSessionCreationError: f((e, n) => ({
|
|
425
|
-
sessionCreationError: n.data
|
|
426
|
-
})),
|
|
427
|
-
clearSessionCreationError: f({ sessionCreationError: () => null }),
|
|
428
|
-
setSessionUpdateError: f((e, n) => ({
|
|
429
|
-
sessionUpdateError: n.data
|
|
430
|
-
})),
|
|
431
|
-
clearSessionUpdateError: f({ sessionUpdateError: () => null }),
|
|
432
|
-
setHasEverSuccessfullyCreatedSession: f({
|
|
433
|
-
hasEverSuccessfullyCreatedSession: () => !0
|
|
434
|
-
})
|
|
435
|
-
},
|
|
436
|
-
services: {
|
|
437
|
-
createSession: (e) => e.desiredClient.createSession(e.desiredSessionContext).then((n) => ({
|
|
438
|
-
session: n,
|
|
439
|
-
client: e.desiredClient
|
|
440
|
-
})).catch((n) => Promise.reject({
|
|
441
|
-
failureResult: n,
|
|
442
|
-
client: e.desiredClient,
|
|
443
|
-
sessionContext: e.desiredSessionContext
|
|
444
|
-
})),
|
|
445
|
-
updateSession: (e) => e.session.setSessionContext(e.desiredSessionContext).catch((n) => Promise.reject({
|
|
446
|
-
failureResult: n,
|
|
447
|
-
sessionContext: e.desiredSessionContext
|
|
448
|
-
}))
|
|
449
|
-
},
|
|
450
|
-
guards: {
|
|
451
|
-
shallDisposeSession: (e) => e.session != null && (e.desiredSessionContext == null || e.desiredClient == null || !v.equals(e.actualClient, e.desiredClient)),
|
|
452
|
-
shallCreateSession: (e) => e.session == null && e.desiredClient != null && e.desiredSessionContext != null,
|
|
453
|
-
shallUpdateSession: (e) => e.session != null && !ie.equals(e.session.getSessionContext(), e.desiredSessionContext),
|
|
454
|
-
shallImmediatelyProcessChangesAfterSessionCreationError: (e) => (
|
|
455
|
-
// The desired client and the desired session context is not the same that resulted in the error.
|
|
456
|
-
!v.equals(e.desiredClient, e.sessionCreationError.client) || !T.equals(e.desiredSessionContext, e.sessionCreationError.sessionContext)
|
|
457
|
-
),
|
|
458
|
-
shallImmediatelyProcessChangesAfterSessionUpdateError: (e) => (
|
|
459
|
-
// The desired client was changed
|
|
460
|
-
!v.equals(e.desiredClient, e.actualClient) || !T.equals(e.desiredSessionContext, e.sessionUpdateError.sessionContext)
|
|
461
|
-
)
|
|
462
|
-
}
|
|
463
290
|
});
|
|
464
|
-
function
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
291
|
+
function ge() {
|
|
292
|
+
return Zt(fe);
|
|
293
|
+
}
|
|
294
|
+
function Ae(t) {
|
|
295
|
+
return f((e) => e(t.sessionManagementMachineAtom).context.configurationSession);
|
|
296
|
+
}
|
|
297
|
+
function he(t) {
|
|
298
|
+
const e = f((o, s) => {
|
|
299
|
+
var m;
|
|
300
|
+
const r = o(t.sessionManagementMachineAtom), u = r.matches("Processing"), a = r.context.configurationSession != null, c = (m = r.context.sessionCreateOrUpdateError) != null && m.configurationError ? {
|
|
301
|
+
...r.context.sessionCreateOrUpdateError.configurationError,
|
|
302
|
+
retry: () => {
|
|
303
|
+
s.setSelf();
|
|
304
|
+
}
|
|
305
|
+
} : null;
|
|
306
|
+
return {
|
|
307
|
+
isProcessing: u,
|
|
308
|
+
hasSession: a,
|
|
309
|
+
error: c
|
|
310
|
+
};
|
|
311
|
+
}, (o, s) => {
|
|
312
|
+
s(t.sessionManagementMachineAtom, { type: "Retry" });
|
|
313
|
+
}), n = f((o) => {
|
|
314
|
+
const { hasSession: s, error: r, isProcessing: u } = o(e);
|
|
315
|
+
return {
|
|
316
|
+
isInitializing: !s && u,
|
|
317
|
+
error: !s && r ? r : void 0
|
|
318
|
+
};
|
|
319
|
+
}), i = f((o) => {
|
|
320
|
+
const { hasSession: s, error: r, isProcessing: u } = o(e);
|
|
321
|
+
return {
|
|
322
|
+
isUpdating: s && u,
|
|
323
|
+
error: s && r ? r : void 0
|
|
473
324
|
};
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
325
|
+
});
|
|
326
|
+
return {
|
|
327
|
+
sessionInitializationAtom: n,
|
|
328
|
+
sessionUpdatingAtom: i
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
const pe = () => _(() => f()), be = () => f(), Se = () => f(), ye = () => f(), Ce = () => f();
|
|
332
|
+
function xe(t, e) {
|
|
333
|
+
const { attributesAtom: n, configurationAtom: i, isSatisfiedAtom: o, canResetAtom: s } = t, { configurationSessionAtom: r } = e;
|
|
334
|
+
return ut((u, a) => {
|
|
335
|
+
const c = u(r);
|
|
336
|
+
if (!c) {
|
|
337
|
+
a(i, void 0), a(o, void 0), a(n, void 0), a(s, void 0);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const m = c.addConfigurationChangedListener((R, F) => {
|
|
341
|
+
x.debug("SessionSubscription:", "Received ConfigurationChanged"), a(i, R), F.isSatisfied != null && a(o, F.isSatisfied);
|
|
342
|
+
const Z = u.peek(n), V = Z ?? pe();
|
|
343
|
+
F.attributes.added.forEach((C) => {
|
|
344
|
+
a(V(C.key), C);
|
|
345
|
+
}), F.attributes.changed.forEach((C) => {
|
|
346
|
+
a(V(C.key), C);
|
|
347
|
+
}), F.attributes.removed.forEach((C) => {
|
|
348
|
+
a(V(St(C)), void 0);
|
|
349
|
+
}), Z == null && a(n, () => V);
|
|
350
|
+
}), Y = c.addCanResetConfigurationChangedListener((R) => {
|
|
351
|
+
x.debug("SessionSubscription:", "Received CanResetConfigurationChanged"), a(s, R);
|
|
479
352
|
});
|
|
353
|
+
return () => {
|
|
354
|
+
m.unsubscribe(), Y.unsubscribe();
|
|
355
|
+
};
|
|
480
356
|
});
|
|
481
357
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
358
|
+
function mt(t, e, n) {
|
|
359
|
+
const i = f((o) => {
|
|
360
|
+
const s = o(t);
|
|
361
|
+
if (!s)
|
|
362
|
+
return;
|
|
363
|
+
const r = f();
|
|
364
|
+
return r.onMount = (u) => {
|
|
365
|
+
const a = e(s, (...c) => {
|
|
366
|
+
u(c);
|
|
367
|
+
});
|
|
368
|
+
return () => {
|
|
369
|
+
u(void 0), a.unsubscribe();
|
|
370
|
+
};
|
|
371
|
+
}, r;
|
|
491
372
|
});
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
373
|
+
return f((o) => {
|
|
374
|
+
const s = o(i);
|
|
375
|
+
if (s == null)
|
|
376
|
+
return;
|
|
377
|
+
const r = o(s);
|
|
378
|
+
if (r != null)
|
|
379
|
+
return n(...r);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function ve(t) {
|
|
383
|
+
return mt(t, (e, n) => e.addStoredConfigurationChangedListener(n), (e) => e);
|
|
384
|
+
}
|
|
385
|
+
function we(t) {
|
|
386
|
+
return mt(t, (e, n) => e.addDecisionsChangedListener(n), (e) => e);
|
|
387
|
+
}
|
|
388
|
+
function Ee(t) {
|
|
389
|
+
return mt(t, (e, n) => e.addDecisionsChangedListener(L.Explicit, n), (e) => e);
|
|
390
|
+
}
|
|
391
|
+
function De(t) {
|
|
392
|
+
return mt(t, (e, n) => e.addDecisionsChangedListener(L.Implicit, n), (e) => e);
|
|
393
|
+
}
|
|
394
|
+
const Ie = () => ({
|
|
395
|
+
sessionManagementMachineAtom: ge(),
|
|
396
|
+
configurationAtom: be(),
|
|
397
|
+
isSatisfiedAtom: Se(),
|
|
398
|
+
canResetAtom: ye(),
|
|
399
|
+
attributesAtom: Ce(),
|
|
400
|
+
subscriptionsAtom: ue()
|
|
401
|
+
});
|
|
402
|
+
function ke(t, e) {
|
|
403
|
+
return D((n, i) => {
|
|
404
|
+
const o = i(t);
|
|
405
|
+
return {
|
|
406
|
+
canResetConfiguration: i(e),
|
|
407
|
+
resetConfiguration: o.resetConfiguration.bind(o)
|
|
408
|
+
};
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
function Re(t) {
|
|
412
|
+
return D((e, n) => {
|
|
413
|
+
const i = n(t);
|
|
414
|
+
return {
|
|
415
|
+
explain: i.explain.bind(i),
|
|
416
|
+
applySolution: i.applySolution.bind(i)
|
|
417
|
+
};
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function Fe(t) {
|
|
421
|
+
return j(
|
|
422
|
+
t.values,
|
|
423
|
+
H.values(kt.trivial),
|
|
424
|
+
k.filter((e) => {
|
|
425
|
+
var n;
|
|
426
|
+
return ((n = e.decision) == null ? void 0 : n.kind) === L.Explicit;
|
|
427
|
+
}),
|
|
428
|
+
k.map((e) => ({
|
|
429
|
+
type: J.Choice,
|
|
430
|
+
attributeId: t.id,
|
|
431
|
+
choiceValueId: e.id,
|
|
432
|
+
state: null
|
|
433
|
+
}))
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
const p = Symbol.for("@ts-pattern/matcher"), jt = Symbol.for("@ts-pattern/isVariadic"), it = "@ts-pattern/anonymous-select-key", ht = (t) => !!(t && typeof t == "object"), tt = (t) => t && !!t[p], A = (t, e, n) => {
|
|
437
|
+
if (tt(t)) {
|
|
438
|
+
const i = t[p](), { matched: o, selections: s } = i.match(e);
|
|
439
|
+
return o && s && Object.keys(s).forEach((r) => n(r, s[r])), o;
|
|
440
|
+
}
|
|
441
|
+
if (ht(t)) {
|
|
442
|
+
if (!ht(e)) return !1;
|
|
443
|
+
if (Array.isArray(t)) {
|
|
444
|
+
if (!Array.isArray(e)) return !1;
|
|
445
|
+
let i = [], o = [], s = [];
|
|
446
|
+
for (const r of t.keys()) {
|
|
447
|
+
const u = t[r];
|
|
448
|
+
tt(u) && u[jt] ? s.push(u) : s.length ? o.push(u) : i.push(u);
|
|
449
|
+
}
|
|
450
|
+
if (s.length) {
|
|
451
|
+
if (s.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
452
|
+
if (e.length < i.length + o.length) return !1;
|
|
453
|
+
const r = e.slice(0, i.length), u = o.length === 0 ? [] : e.slice(-o.length), a = e.slice(i.length, o.length === 0 ? 1 / 0 : -o.length);
|
|
454
|
+
return i.every((c, m) => A(c, r[m], n)) && o.every((c, m) => A(c, u[m], n)) && (s.length === 0 || A(s[0], a, n));
|
|
548
455
|
}
|
|
456
|
+
return t.length === e.length && t.every((r, u) => A(r, e[u], n));
|
|
549
457
|
}
|
|
458
|
+
return Reflect.ownKeys(t).every((i) => {
|
|
459
|
+
const o = t[i];
|
|
460
|
+
return (i in e || tt(s = o) && s[p]().matcherType === "optional") && A(o, e[i], n);
|
|
461
|
+
var s;
|
|
462
|
+
});
|
|
550
463
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
464
|
+
return Object.is(e, t);
|
|
465
|
+
}, S = (t) => {
|
|
466
|
+
var e, n, i;
|
|
467
|
+
return ht(t) ? tt(t) ? (e = (n = (i = t[p]()).getSelectionKeys) == null ? void 0 : n.call(i)) != null ? e : [] : Array.isArray(t) ? Q(t, S) : Q(Object.values(t), S) : [];
|
|
468
|
+
}, Q = (t, e) => t.reduce((n, i) => n.concat(e(i)), []);
|
|
469
|
+
function Me(...t) {
|
|
470
|
+
if (t.length === 1) {
|
|
471
|
+
const [e] = t;
|
|
472
|
+
return (n) => A(e, n, () => {
|
|
473
|
+
});
|
|
556
474
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
return {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
return
|
|
475
|
+
if (t.length === 2) {
|
|
476
|
+
const [e, n] = t;
|
|
477
|
+
return A(e, n, () => {
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`);
|
|
481
|
+
}
|
|
482
|
+
function h(t) {
|
|
483
|
+
return Object.assign(t, { optional: () => vt(t), and: (e) => d(t, e), or: (e) => Tt(t, e), select: (e) => e === void 0 ? $(t) : $(e, t) });
|
|
484
|
+
}
|
|
485
|
+
function pt(t) {
|
|
486
|
+
return Object.assign(((e) => Object.assign(e, { [Symbol.iterator]() {
|
|
487
|
+
let n = 0;
|
|
488
|
+
const i = [{ value: Object.assign(e, { [jt]: !0 }), done: !1 }, { done: !0, value: void 0 }];
|
|
489
|
+
return { next: () => {
|
|
490
|
+
var o;
|
|
491
|
+
return (o = i[n++]) != null ? o : i.at(-1);
|
|
492
|
+
} };
|
|
493
|
+
} }))(t), { optional: () => pt(vt(t)), select: (e) => pt(e === void 0 ? $(t) : $(e, t)) });
|
|
494
|
+
}
|
|
495
|
+
function vt(t) {
|
|
496
|
+
return h({ [p]: () => ({ match: (e) => {
|
|
497
|
+
let n = {};
|
|
498
|
+
const i = (o, s) => {
|
|
499
|
+
n[o] = s;
|
|
500
|
+
};
|
|
501
|
+
return e === void 0 ? (S(t).forEach((o) => i(o, void 0)), { matched: !0, selections: n }) : { matched: A(t, e, i), selections: n };
|
|
502
|
+
}, getSelectionKeys: () => S(t), matcherType: "optional" }) });
|
|
503
|
+
}
|
|
504
|
+
const ze = (t, e) => {
|
|
505
|
+
for (const n of t) if (!e(n)) return !1;
|
|
506
|
+
return !0;
|
|
507
|
+
}, Pe = (t, e) => {
|
|
508
|
+
for (const [n, i] of t.entries()) if (!e(i, n)) return !1;
|
|
509
|
+
return !0;
|
|
579
510
|
};
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
511
|
+
function d(...t) {
|
|
512
|
+
return h({ [p]: () => ({ match: (e) => {
|
|
513
|
+
let n = {};
|
|
514
|
+
const i = (o, s) => {
|
|
515
|
+
n[o] = s;
|
|
516
|
+
};
|
|
517
|
+
return { matched: t.every((o) => A(o, e, i)), selections: n };
|
|
518
|
+
}, getSelectionKeys: () => Q(t, S), matcherType: "and" }) });
|
|
519
|
+
}
|
|
520
|
+
function Tt(...t) {
|
|
521
|
+
return h({ [p]: () => ({ match: (e) => {
|
|
522
|
+
let n = {};
|
|
523
|
+
const i = (o, s) => {
|
|
524
|
+
n[o] = s;
|
|
525
|
+
};
|
|
526
|
+
return Q(t, S).forEach((o) => i(o, void 0)), { matched: t.some((o) => A(o, e, i)), selections: n };
|
|
527
|
+
}, getSelectionKeys: () => Q(t, S), matcherType: "or" }) });
|
|
528
|
+
}
|
|
529
|
+
function l(t) {
|
|
530
|
+
return { [p]: () => ({ match: (e) => ({ matched: !!t(e) }) }) };
|
|
531
|
+
}
|
|
532
|
+
function $(...t) {
|
|
533
|
+
const e = typeof t[0] == "string" ? t[0] : void 0, n = t.length === 2 ? t[1] : typeof t[0] == "string" ? void 0 : t[0];
|
|
534
|
+
return h({ [p]: () => ({ match: (i) => {
|
|
535
|
+
let o = { [e ?? it]: i };
|
|
536
|
+
return { matched: n === void 0 || A(n, i, (s, r) => {
|
|
537
|
+
o[s] = r;
|
|
538
|
+
}), selections: o };
|
|
539
|
+
}, getSelectionKeys: () => [e ?? it].concat(n === void 0 ? [] : S(n)) }) });
|
|
540
|
+
}
|
|
541
|
+
function v(t) {
|
|
542
|
+
return typeof t == "number";
|
|
543
|
+
}
|
|
544
|
+
function M(t) {
|
|
545
|
+
return typeof t == "string";
|
|
546
|
+
}
|
|
547
|
+
function z(t) {
|
|
548
|
+
return typeof t == "bigint";
|
|
549
|
+
}
|
|
550
|
+
const Vt = h(l(function(t) {
|
|
551
|
+
return !0;
|
|
552
|
+
})), Ue = Vt, P = (t) => Object.assign(h(t), { startsWith: (e) => {
|
|
553
|
+
return P(d(t, (n = e, l((i) => M(i) && i.startsWith(n)))));
|
|
554
|
+
var n;
|
|
555
|
+
}, endsWith: (e) => {
|
|
556
|
+
return P(d(t, (n = e, l((i) => M(i) && i.endsWith(n)))));
|
|
557
|
+
var n;
|
|
558
|
+
}, minLength: (e) => P(d(t, ((n) => l((i) => M(i) && i.length >= n))(e))), length: (e) => P(d(t, ((n) => l((i) => M(i) && i.length === n))(e))), maxLength: (e) => P(d(t, ((n) => l((i) => M(i) && i.length <= n))(e))), includes: (e) => {
|
|
559
|
+
return P(d(t, (n = e, l((i) => M(i) && i.includes(n)))));
|
|
560
|
+
var n;
|
|
561
|
+
}, regex: (e) => {
|
|
562
|
+
return P(d(t, (n = e, l((i) => M(i) && !!i.match(n)))));
|
|
563
|
+
var n;
|
|
564
|
+
} }), qe = P(l(M)), w = (t) => Object.assign(h(t), { between: (e, n) => w(d(t, ((i, o) => l((s) => v(s) && i <= s && o >= s))(e, n))), lt: (e) => w(d(t, ((n) => l((i) => v(i) && i < n))(e))), gt: (e) => w(d(t, ((n) => l((i) => v(i) && i > n))(e))), lte: (e) => w(d(t, ((n) => l((i) => v(i) && i <= n))(e))), gte: (e) => w(d(t, ((n) => l((i) => v(i) && i >= n))(e))), int: () => w(d(t, l((e) => v(e) && Number.isInteger(e)))), finite: () => w(d(t, l((e) => v(e) && Number.isFinite(e)))), positive: () => w(d(t, l((e) => v(e) && e > 0))), negative: () => w(d(t, l((e) => v(e) && e < 0))) }), je = w(l(v)), U = (t) => Object.assign(h(t), { between: (e, n) => U(d(t, ((i, o) => l((s) => z(s) && i <= s && o >= s))(e, n))), lt: (e) => U(d(t, ((n) => l((i) => z(i) && i < n))(e))), gt: (e) => U(d(t, ((n) => l((i) => z(i) && i > n))(e))), lte: (e) => U(d(t, ((n) => l((i) => z(i) && i <= n))(e))), gte: (e) => U(d(t, ((n) => l((i) => z(i) && i >= n))(e))), positive: () => U(d(t, l((e) => z(e) && e > 0))), negative: () => U(d(t, l((e) => z(e) && e < 0))) }), Te = U(l(z)), Ve = h(l(function(t) {
|
|
565
|
+
return typeof t == "boolean";
|
|
566
|
+
})), _e = h(l(function(t) {
|
|
567
|
+
return typeof t == "symbol";
|
|
568
|
+
})), Ne = h(l(function(t) {
|
|
569
|
+
return t == null;
|
|
570
|
+
})), We = h(l(function(t) {
|
|
571
|
+
return t != null;
|
|
572
|
+
}));
|
|
573
|
+
var Be = { __proto__: null, matcher: p, optional: vt, array: function(...t) {
|
|
574
|
+
return pt({ [p]: () => ({ match: (e) => {
|
|
575
|
+
if (!Array.isArray(e)) return { matched: !1 };
|
|
576
|
+
if (t.length === 0) return { matched: !0 };
|
|
577
|
+
const n = t[0];
|
|
578
|
+
let i = {};
|
|
579
|
+
if (e.length === 0) return S(n).forEach((s) => {
|
|
580
|
+
i[s] = [];
|
|
581
|
+
}), { matched: !0, selections: i };
|
|
582
|
+
const o = (s, r) => {
|
|
583
|
+
i[s] = (i[s] || []).concat([r]);
|
|
584
|
+
};
|
|
585
|
+
return { matched: e.every((s) => A(n, s, o)), selections: i };
|
|
586
|
+
}, getSelectionKeys: () => t.length === 0 ? [] : S(t[0]) }) });
|
|
587
|
+
}, set: function(...t) {
|
|
588
|
+
return h({ [p]: () => ({ match: (e) => {
|
|
589
|
+
if (!(e instanceof Set)) return { matched: !1 };
|
|
590
|
+
let n = {};
|
|
591
|
+
if (e.size === 0) return { matched: !0, selections: n };
|
|
592
|
+
if (t.length === 0) return { matched: !0 };
|
|
593
|
+
const i = (s, r) => {
|
|
594
|
+
n[s] = (n[s] || []).concat([r]);
|
|
595
|
+
}, o = t[0];
|
|
596
|
+
return { matched: ze(e, (s) => A(o, s, i)), selections: n };
|
|
597
|
+
}, getSelectionKeys: () => t.length === 0 ? [] : S(t[0]) }) });
|
|
598
|
+
}, map: function(...t) {
|
|
599
|
+
return h({ [p]: () => ({ match: (e) => {
|
|
600
|
+
if (!(e instanceof Map)) return { matched: !1 };
|
|
601
|
+
let n = {};
|
|
602
|
+
if (e.size === 0) return { matched: !0, selections: n };
|
|
603
|
+
const i = (u, a) => {
|
|
604
|
+
n[u] = (n[u] || []).concat([a]);
|
|
605
|
+
};
|
|
606
|
+
if (t.length === 0) return { matched: !0 };
|
|
607
|
+
var o;
|
|
608
|
+
if (t.length === 1) throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${(o = t[0]) == null ? void 0 : o.toString()}`);
|
|
609
|
+
const [s, r] = t;
|
|
610
|
+
return { matched: Pe(e, (u, a) => {
|
|
611
|
+
const c = A(s, a, i), m = A(r, u, i);
|
|
612
|
+
return c && m;
|
|
613
|
+
}), selections: n };
|
|
614
|
+
}, getSelectionKeys: () => t.length === 0 ? [] : [...S(t[0]), ...S(t[1])] }) });
|
|
615
|
+
}, intersection: d, union: Tt, not: function(t) {
|
|
616
|
+
return h({ [p]: () => ({ match: (e) => ({ matched: !A(t, e, () => {
|
|
617
|
+
}) }), getSelectionKeys: () => [], matcherType: "not" }) });
|
|
618
|
+
}, when: l, select: $, any: Vt, _: Ue, string: qe, number: je, bigint: Te, boolean: Ve, symbol: _e, nullish: Ne, nonNullable: We, instanceOf: function(t) {
|
|
619
|
+
return h(l(/* @__PURE__ */ function(e) {
|
|
620
|
+
return (n) => n instanceof e;
|
|
621
|
+
}(t)));
|
|
622
|
+
}, shape: function(t) {
|
|
623
|
+
return h(l(Me(t)));
|
|
624
|
+
} };
|
|
625
|
+
class Oe extends Error {
|
|
626
|
+
constructor(e) {
|
|
627
|
+
let n;
|
|
628
|
+
try {
|
|
629
|
+
n = JSON.stringify(e);
|
|
630
|
+
} catch {
|
|
631
|
+
n = e;
|
|
654
632
|
}
|
|
655
|
-
|
|
656
|
-
initial: "Idle",
|
|
657
|
-
states: {
|
|
658
|
-
Idle: {}
|
|
633
|
+
super(`Pattern matching error: no pattern matches value ${n}`), this.input = void 0, this.input = e;
|
|
659
634
|
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
})
|
|
635
|
+
}
|
|
636
|
+
const bt = { matched: !1, value: void 0 };
|
|
637
|
+
function ot(t) {
|
|
638
|
+
return new st(t, bt);
|
|
639
|
+
}
|
|
640
|
+
class st {
|
|
641
|
+
constructor(e, n) {
|
|
642
|
+
this.input = void 0, this.state = void 0, this.input = e, this.state = n;
|
|
669
643
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
644
|
+
with(...e) {
|
|
645
|
+
if (this.state.matched) return this;
|
|
646
|
+
const n = e[e.length - 1], i = [e[0]];
|
|
647
|
+
let o;
|
|
648
|
+
e.length === 3 && typeof e[1] == "function" ? o = e[1] : e.length > 2 && i.push(...e.slice(1, e.length - 1));
|
|
649
|
+
let s = !1, r = {};
|
|
650
|
+
const u = (c, m) => {
|
|
651
|
+
s = !0, r[c] = m;
|
|
652
|
+
}, a = !i.some((c) => A(c, this.input, u)) || o && !o(this.input) ? bt : { matched: !0, value: n(s ? it in r ? r[it] : r : this.input, this.input) };
|
|
653
|
+
return new st(this.input, a);
|
|
654
|
+
}
|
|
655
|
+
when(e, n) {
|
|
656
|
+
if (this.state.matched) return this;
|
|
657
|
+
const i = !!e(this.input);
|
|
658
|
+
return new st(this.input, i ? { matched: !0, value: n(this.input, this.input) } : bt);
|
|
659
|
+
}
|
|
660
|
+
otherwise(e) {
|
|
661
|
+
return this.state.matched ? this.state.value : e(this.input);
|
|
662
|
+
}
|
|
663
|
+
exhaustive() {
|
|
664
|
+
if (this.state.matched) return this.state.value;
|
|
665
|
+
throw new Oe(this.input);
|
|
666
|
+
}
|
|
667
|
+
run() {
|
|
668
|
+
return this.exhaustive();
|
|
669
|
+
}
|
|
670
|
+
returnType() {
|
|
671
|
+
return this;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function T(t, e) {
|
|
675
|
+
var n = 0, i, o;
|
|
676
|
+
e = e || {};
|
|
677
|
+
function s() {
|
|
678
|
+
var r = i, u = arguments.length, a, c;
|
|
679
|
+
t: for (; r; ) {
|
|
680
|
+
if (r.args.length !== arguments.length) {
|
|
681
|
+
r = r.next;
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
for (c = 0; c < u; c++)
|
|
685
|
+
if (r.args[c] !== arguments[c]) {
|
|
686
|
+
r = r.next;
|
|
687
|
+
continue t;
|
|
701
688
|
}
|
|
689
|
+
return r !== i && (r === o && (o = r.prev), r.prev.next = r.next, r.next && (r.next.prev = r.prev), r.next = i, r.prev = null, i.prev = r, i = r), r.val;
|
|
690
|
+
}
|
|
691
|
+
for (a = new Array(u), c = 0; c < u; c++)
|
|
692
|
+
a[c] = arguments[c];
|
|
693
|
+
return r = {
|
|
694
|
+
args: a,
|
|
695
|
+
// Generate the result from original function
|
|
696
|
+
val: t.apply(null, a)
|
|
697
|
+
}, i ? (i.prev = r, r.next = i) : o = r, n === /** @type {MemizeOptions} */
|
|
698
|
+
e.maxSize ? (o = /** @type {MemizeCacheNode} */
|
|
699
|
+
o.prev, o.next = null) : n++, i = r, r.val;
|
|
700
|
+
}
|
|
701
|
+
return s.clear = function() {
|
|
702
|
+
i = null, o = null, n = 0;
|
|
703
|
+
}, s;
|
|
704
|
+
}
|
|
705
|
+
function Le(t, e, n) {
|
|
706
|
+
return dt(
|
|
707
|
+
t,
|
|
708
|
+
n,
|
|
709
|
+
rt.choiceAttributeRefinement,
|
|
710
|
+
N.choiceValue,
|
|
711
|
+
(i, o, s) => {
|
|
712
|
+
const { makeDecision: r, makeManyDecisions: u } = s(e);
|
|
713
|
+
return {
|
|
714
|
+
makeDecision: (a, c) => r({
|
|
715
|
+
type: J.Choice,
|
|
716
|
+
attributeId: i.id,
|
|
717
|
+
choiceValueId: a,
|
|
718
|
+
state: c
|
|
719
|
+
}),
|
|
720
|
+
clearDecisions: () => j(
|
|
721
|
+
i,
|
|
722
|
+
Fe,
|
|
723
|
+
// Only execute if there are decisions to clear.
|
|
724
|
+
K.fromPredicate(k.isNonEmpty),
|
|
725
|
+
K.match(
|
|
726
|
+
() => () => Promise.resolve(),
|
|
727
|
+
(a) => j(() => u(a, { type: "KeepExistingDecisions" }), Lt.map(Kt))
|
|
728
|
+
)
|
|
729
|
+
)(),
|
|
730
|
+
isMultiSelect: T(() => O.isChoiceAttributeMultiSelect(i)),
|
|
731
|
+
getAllowedChoiceValues: T(() => O.getAllowedChoiceValues(i)),
|
|
732
|
+
getIncludedChoiceValues: T(() => O.getIncludedChoiceValues(i)),
|
|
733
|
+
getBlockedChoiceValues: T(() => O.getBlockedChoiceValues(i)),
|
|
734
|
+
isChoiceValueAllowed: T((a) => wt.isAllowed(a)),
|
|
735
|
+
isChoiceValueBlocked: T((a) => wt.isBlocked(a))
|
|
702
736
|
};
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
737
|
+
}
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
function Ke(t, e, n) {
|
|
741
|
+
return dt(
|
|
742
|
+
t,
|
|
743
|
+
n,
|
|
744
|
+
rt.numericAttributeRefinement,
|
|
745
|
+
N.numeric,
|
|
746
|
+
(i, o, s) => {
|
|
747
|
+
const { makeDecision: r } = s(e);
|
|
708
748
|
return {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
749
|
+
makeDecision: (u) => r({
|
|
750
|
+
type: J.Numeric,
|
|
751
|
+
attributeId: i.id,
|
|
752
|
+
state: u
|
|
753
|
+
})
|
|
714
754
|
};
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
|
|
755
|
+
}
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
function Qe(t, e, n) {
|
|
759
|
+
return dt(
|
|
760
|
+
t,
|
|
761
|
+
n,
|
|
762
|
+
rt.booleanAttributeRefinement,
|
|
763
|
+
N.boolean,
|
|
764
|
+
(i, o, s) => {
|
|
765
|
+
const { makeDecision: r } = s(e);
|
|
766
|
+
return {
|
|
767
|
+
makeDecision: (u) => r({
|
|
768
|
+
type: J.Boolean,
|
|
769
|
+
attributeId: i.id,
|
|
770
|
+
state: u
|
|
771
|
+
})
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
function $e(t, e, n) {
|
|
777
|
+
return dt(
|
|
778
|
+
t,
|
|
779
|
+
n,
|
|
780
|
+
rt.componentAttributeRefinement,
|
|
781
|
+
N.component,
|
|
782
|
+
(i, o, s) => {
|
|
783
|
+
const { makeDecision: r } = s(e);
|
|
784
|
+
return {
|
|
785
|
+
makeDecision: (u) => r({
|
|
786
|
+
type: J.Component,
|
|
787
|
+
attributeId: i.id,
|
|
788
|
+
state: u
|
|
789
|
+
})
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
function dt(t, e, n, i, o) {
|
|
795
|
+
return _((s) => D((r, u) => {
|
|
796
|
+
const a = u(t), c = r(a(s));
|
|
797
|
+
if (!c || !n(c))
|
|
798
|
+
return;
|
|
799
|
+
const { explain: m, applySolution: Y } = u(e), R = o(c, r, u);
|
|
800
|
+
return R === E ? E : {
|
|
801
|
+
attribute: c,
|
|
802
|
+
isMandatory: T(() => O.isMandatory(c)),
|
|
803
|
+
explain: (F, Z) => {
|
|
804
|
+
const V = ot(F.question).with(It.whyIsNotSatisfied, () => N.attribute).otherwise(() => i), C = {
|
|
805
|
+
...F,
|
|
806
|
+
subject: V,
|
|
807
|
+
attributeId: c.id
|
|
808
|
+
};
|
|
809
|
+
return ot(Z).with("decisions", (B) => m(C, B)).with("constraints", (B) => m(C, B)).with("full", (B) => m(C, B)).exhaustive();
|
|
810
|
+
},
|
|
811
|
+
applySolution: Y,
|
|
812
|
+
...R
|
|
813
|
+
};
|
|
814
|
+
}));
|
|
815
|
+
}
|
|
816
|
+
function _t(t, e) {
|
|
817
|
+
const n = zt(t, et, e.equals);
|
|
818
|
+
return "write" in t ? f((i) => i(n), (i, o, ...s) => o(t, ...s)) : n;
|
|
819
|
+
}
|
|
820
|
+
const Je = b.struct({
|
|
821
|
+
isInitializing: at.Eq,
|
|
822
|
+
error: b.eqNullable(b.eqStrict)
|
|
823
|
+
});
|
|
824
|
+
function He(t, e, n, i, o, s) {
|
|
825
|
+
const r = [
|
|
826
|
+
e,
|
|
827
|
+
n,
|
|
828
|
+
i,
|
|
829
|
+
o,
|
|
830
|
+
s
|
|
831
|
+
], u = f((a) => {
|
|
832
|
+
const c = j(
|
|
833
|
+
r,
|
|
834
|
+
k.every((R) => a(R) !== E)
|
|
835
|
+
), m = a(t);
|
|
836
|
+
return {
|
|
837
|
+
isInitializing: !(!m.isInitializing && c),
|
|
838
|
+
error: m.error
|
|
839
|
+
};
|
|
840
|
+
});
|
|
841
|
+
return _t(u, Je);
|
|
842
|
+
}
|
|
843
|
+
const Xe = b.struct({
|
|
844
|
+
isUpdating: at.Eq,
|
|
845
|
+
error: b.eqNullable(b.eqStrict)
|
|
846
|
+
});
|
|
847
|
+
function Ye(t) {
|
|
848
|
+
return _t(t, Xe);
|
|
849
|
+
}
|
|
850
|
+
function Ze(t) {
|
|
851
|
+
return D((e, n) => {
|
|
852
|
+
const i = n(t);
|
|
853
|
+
return {
|
|
854
|
+
storeConfiguration: i.storeConfiguration.bind(i),
|
|
855
|
+
restoreConfiguration: i.restoreConfiguration.bind(i)
|
|
856
|
+
};
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function Ge(t, e) {
|
|
860
|
+
const n = {
|
|
861
|
+
question: It.whyIsNotSatisfied,
|
|
862
|
+
subject: N.configuration
|
|
863
|
+
};
|
|
864
|
+
return D((i, o) => {
|
|
865
|
+
const s = o(t);
|
|
866
|
+
return {
|
|
867
|
+
isSatisfied: o(e),
|
|
868
|
+
explain: (u) => ot(u).with("full", (a) => s.explain(n, a)).with("decisions", (a) => s.explain(n, a)).with("constraints", (a) => s.explain(n, a)).exhaustive()
|
|
869
|
+
};
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
function tn(t) {
|
|
873
|
+
return D((e, n) => {
|
|
874
|
+
const i = n(t);
|
|
875
|
+
return {
|
|
876
|
+
reinitializeSession: i.reinitialize.bind(i)
|
|
877
|
+
};
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
function en(t) {
|
|
881
|
+
return D((e, n) => {
|
|
882
|
+
const i = n(t);
|
|
883
|
+
return {
|
|
884
|
+
scheduleTask: i.scheduleTask.bind(i)
|
|
885
|
+
};
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
function nn(t) {
|
|
889
|
+
return D((e, n) => {
|
|
890
|
+
const i = n(t);
|
|
891
|
+
return {
|
|
892
|
+
getDecisions: i.getDecisions.bind(i)
|
|
893
|
+
};
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
function on(t) {
|
|
897
|
+
return D((e, n) => {
|
|
898
|
+
const i = n(t);
|
|
899
|
+
return {
|
|
900
|
+
makeDecision: i.makeDecision.bind(i),
|
|
901
|
+
makeManyDecisions: i.makeManyDecisions.bind(i)
|
|
902
|
+
};
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
function I(t) {
|
|
906
|
+
return f((e) => e(t) ?? E);
|
|
907
|
+
}
|
|
908
|
+
function sn(t) {
|
|
909
|
+
const { sessionInitializationAtom: e, sessionUpdatingAtom: n } = he(t), i = Ae(t), o = {
|
|
910
|
+
guardedConfigurationSessionAtom: I(i),
|
|
911
|
+
guardedConfigurationAtom: I(t.configurationAtom),
|
|
912
|
+
guardedIsSatisfiedAtom: I(t.isSatisfiedAtom),
|
|
913
|
+
guardedCanResetAtom: I(t.canResetAtom),
|
|
914
|
+
guardedAttributesAtom: I(t.attributesAtom),
|
|
915
|
+
guardedStoredConfigurationAtom: I(ve(i)),
|
|
916
|
+
guardedDecisionsAtom: I(we(i)),
|
|
917
|
+
guardedExplicitDecisionsAtom: I(Ee(i)),
|
|
918
|
+
guardedImplicitDecisionsAtom: I(De(i))
|
|
919
|
+
}, s = on(o.guardedConfigurationSessionAtom), r = Re(o.guardedConfigurationSessionAtom);
|
|
718
920
|
return {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
921
|
+
...o,
|
|
922
|
+
configurationSessionAtom: i,
|
|
923
|
+
sessionInitializationAtom: e,
|
|
924
|
+
sessionUpdatingAtom: n,
|
|
925
|
+
configurationInitializationAtom: He(e, o.guardedConfigurationSessionAtom, o.guardedConfigurationAtom, o.guardedCanResetAtom, o.guardedIsSatisfiedAtom, o.guardedAttributesAtom),
|
|
926
|
+
configurationUpdatingAtom: Ye(n),
|
|
927
|
+
makeDecisionAtom: s,
|
|
928
|
+
explainAtom: r,
|
|
929
|
+
decisionQueriesAtom: nn(o.guardedConfigurationSessionAtom),
|
|
930
|
+
taskSchedulingAtom: en(o.guardedConfigurationSessionAtom),
|
|
931
|
+
configurationSatisfactionAtom: Ge(o.guardedConfigurationSessionAtom, o.guardedIsSatisfiedAtom),
|
|
932
|
+
configurationStoringAtom: Ze(o.guardedConfigurationSessionAtom),
|
|
933
|
+
configurationResetAtom: ke(o.guardedConfigurationSessionAtom, o.guardedCanResetAtom),
|
|
934
|
+
sessionReinitializationAtom: tn(o.guardedConfigurationSessionAtom),
|
|
935
|
+
choiceAttributeAtomFamily: Le(o.guardedAttributesAtom, s, r),
|
|
936
|
+
numericAttributeAtomFamily: Ke(o.guardedAttributesAtom, s, r),
|
|
937
|
+
booleanAttributeAtomFamily: Qe(o.guardedAttributesAtom, s, r),
|
|
938
|
+
componentAttributeAtomFamily: $e(o.guardedAttributesAtom, s, r),
|
|
939
|
+
subscriberAtom: ce(t)
|
|
723
940
|
};
|
|
724
941
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
942
|
+
const rn = 30 * 1e3;
|
|
943
|
+
function an(t, e, n) {
|
|
944
|
+
const i = [
|
|
945
|
+
e.choiceAttributeAtomFamily,
|
|
946
|
+
e.booleanAttributeAtomFamily,
|
|
947
|
+
e.numericAttributeAtomFamily,
|
|
948
|
+
e.componentAttributeAtomFamily,
|
|
949
|
+
n.choiceAttributeAtomFamily,
|
|
950
|
+
n.booleanAttributeAtomFamily,
|
|
951
|
+
n.numericAttributeAtomFamily,
|
|
952
|
+
n.componentAttributeAtomFamily
|
|
953
|
+
];
|
|
954
|
+
return ut((o) => {
|
|
955
|
+
o(t.configurationAtom);
|
|
956
|
+
const s = o(t.attributesAtom);
|
|
957
|
+
if (s == null)
|
|
958
|
+
return;
|
|
959
|
+
x.debug("Scheduling atomFamily cleanup");
|
|
960
|
+
const r = setTimeout(() => {
|
|
961
|
+
x.debug("Cleaning up atomFamilies");
|
|
962
|
+
for (const a of [...s.getParams()]) {
|
|
963
|
+
const c = s(a);
|
|
964
|
+
o.peek(c) == null && (x.debug("Removing attribute from attributes family because it is nullish", a), s.remove(a));
|
|
965
|
+
}
|
|
966
|
+
const u = [...s.getParams()];
|
|
967
|
+
for (const a of i)
|
|
968
|
+
for (const c of [...a.getParams()])
|
|
969
|
+
u.includes(c) || a.remove(c);
|
|
970
|
+
}, rn);
|
|
971
|
+
return () => {
|
|
972
|
+
clearTimeout(r);
|
|
973
|
+
};
|
|
729
974
|
});
|
|
730
|
-
return /* @__PURE__ */ b(Z.Provider, { value: i, children: /* @__PURE__ */ b($.Provider, { value: t, children: /* @__PURE__ */ b(Y.Provider, { value: o, children: /* @__PURE__ */ b(ee.Provider, { value: u, children: e.children }) }) }) });
|
|
731
975
|
}
|
|
732
|
-
function
|
|
733
|
-
return
|
|
976
|
+
function un(t, e, n) {
|
|
977
|
+
return {
|
|
978
|
+
addSessionListenersEffect: xe(t, e),
|
|
979
|
+
cleanupAtomFamiliesEffect: an(t, e, n),
|
|
980
|
+
atomSubscriberEffect: le(t),
|
|
981
|
+
atomSubscriptionCleanupEffect: me(t)
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
function cn(t) {
|
|
985
|
+
return {
|
|
986
|
+
configurationAtom: g(t.guardedConfigurationAtom),
|
|
987
|
+
configurationStoringAtom: g(t.configurationStoringAtom),
|
|
988
|
+
configurationSatisfactionAtom: g(t.configurationSatisfactionAtom),
|
|
989
|
+
storedConfigurationAtom: g(t.guardedStoredConfigurationAtom),
|
|
990
|
+
decisionsAtom: g(t.guardedDecisionsAtom),
|
|
991
|
+
explicitDecisionsAtom: g(t.guardedExplicitDecisionsAtom),
|
|
992
|
+
implicitDecisionsAtom: g(t.guardedImplicitDecisionsAtom),
|
|
993
|
+
makeDecisionAtom: g(t.makeDecisionAtom),
|
|
994
|
+
decisionQueriesAtom: g(t.decisionQueriesAtom),
|
|
995
|
+
configurationResetAtom: g(t.configurationResetAtom),
|
|
996
|
+
sessionReinitializationAtom: g(t.sessionReinitializationAtom),
|
|
997
|
+
explainAtom: g(t.explainAtom),
|
|
998
|
+
taskSchedulingAtom: g(t.taskSchedulingAtom),
|
|
999
|
+
choiceAttributeAtomFamily: _((e) => g(t.choiceAttributeAtomFamily(e))),
|
|
1000
|
+
numericAttributeAtomFamily: _((e) => g(t.numericAttributeAtomFamily(e))),
|
|
1001
|
+
booleanAttributeAtomFamily: _((e) => g(t.booleanAttributeAtomFamily(e))),
|
|
1002
|
+
componentAttributeAtomFamily: _((e) => g(t.componentAttributeAtomFamily(e)))
|
|
1003
|
+
};
|
|
734
1004
|
}
|
|
735
1005
|
function ln() {
|
|
736
|
-
|
|
1006
|
+
const t = Ie(), e = sn(t), n = cn(e);
|
|
1007
|
+
return {
|
|
1008
|
+
primitives: t,
|
|
1009
|
+
selectors: e,
|
|
1010
|
+
suspended: n,
|
|
1011
|
+
effects: un(t, e, n)
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
const mn = "The session context is null or undefined. This will dispose the session that may exist. If this was not intended, make sure you pass valid session context data.";
|
|
1015
|
+
function dn(t) {
|
|
1016
|
+
const { primitives: { sessionManagementMachineAtom: e } } = W(), n = Ft(e);
|
|
1017
|
+
return gt(() => {
|
|
1018
|
+
n({ type: "SessionContextChanged", sessionContext: t.sessionContext }), t.sessionContext || console.warn(mn);
|
|
1019
|
+
}, [t.sessionContext]), gt(() => () => {
|
|
1020
|
+
n({ type: "Shutdown" });
|
|
1021
|
+
}, []), null;
|
|
1022
|
+
}
|
|
1023
|
+
function qn(t) {
|
|
1024
|
+
const e = X(() => ln(), []);
|
|
1025
|
+
return /* @__PURE__ */ q(Pt, { children: /* @__PURE__ */ q(Ut.Provider, { value: e, children: /* @__PURE__ */ q(fn, { jotaiStore: t.jotaiStore, children: /* @__PURE__ */ Xt(gn, { children: [
|
|
1026
|
+
/* @__PURE__ */ q(dn, { sessionContext: t.sessionContext }),
|
|
1027
|
+
/* @__PURE__ */ q(se, {}),
|
|
1028
|
+
t.children
|
|
1029
|
+
] }) }) }) });
|
|
1030
|
+
}
|
|
1031
|
+
function fn(t) {
|
|
1032
|
+
return t.jotaiStore ? /* @__PURE__ */ q(qt.Provider, { value: t.jotaiStore, children: t.children }) : /* @__PURE__ */ q(Pt, { children: t.children });
|
|
1033
|
+
}
|
|
1034
|
+
function gn(t) {
|
|
1035
|
+
const e = ct();
|
|
1036
|
+
return /* @__PURE__ */ q($t, { store: e, children: t.children });
|
|
1037
|
+
}
|
|
1038
|
+
function jn() {
|
|
1039
|
+
const { selectors: { configurationInitializationAtom: t } } = W(), e = ct();
|
|
1040
|
+
return yt(t, { store: e });
|
|
1041
|
+
}
|
|
1042
|
+
function Tn() {
|
|
1043
|
+
const { selectors: { configurationUpdatingAtom: t } } = W(), e = ct();
|
|
1044
|
+
return yt(t, { store: e });
|
|
737
1045
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
return /* @__PURE__ */ b(fe, { children: n });
|
|
1046
|
+
const Vn = y((t) => t.explainAtom, (t) => t.explainAtom), _n = y((t) => t.guardedConfigurationAtom, (t) => t.configurationAtom), Nn = y((t) => t.configurationSatisfactionAtom, (t) => t.configurationSatisfactionAtom), Wn = y((t) => t.configurationStoringAtom, (t) => t.configurationStoringAtom), Bn = y((t) => t.configurationResetAtom, (t) => t.configurationResetAtom), On = y((t) => t.sessionReinitializationAtom, (t) => t.sessionReinitializationAtom), Ln = y((t) => t.taskSchedulingAtom, (t) => t.taskSchedulingAtom), Kn = y((t) => t.guardedStoredConfigurationAtom, (t) => t.storedConfigurationAtom), Qn = y((t) => t.makeDecisionAtom, (t) => t.makeDecisionAtom), $n = y((t) => t.decisionQueriesAtom, (t) => t.decisionQueriesAtom), An = y((t) => t.guardedDecisionsAtom, (t) => t.decisionsAtom), hn = y((t) => t.guardedExplicitDecisionsAtom, (t) => t.explicitDecisionsAtom), pn = y((t) => t.guardedImplicitDecisionsAtom, (t) => t.implicitDecisionsAtom);
|
|
1047
|
+
function Jn(t, e) {
|
|
1048
|
+
const n = typeof t == "string" ? t : void 0, i = typeof t == "boolean" ? t : e, o = X(() => ot(n).returnType().with(Be.nullish, () => An).with(L.Explicit, () => hn).with(L.Implicit, () => pn).exhaustive(), [n]);
|
|
1049
|
+
return i === !1 ? o(!1) : o();
|
|
743
1050
|
}
|
|
744
|
-
function
|
|
745
|
-
const
|
|
746
|
-
return
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
1051
|
+
function Hn() {
|
|
1052
|
+
const { selectors: t } = W();
|
|
1053
|
+
return X(() => ({
|
|
1054
|
+
getConfigurationInitializationAtom: t.configurationInitializationAtom,
|
|
1055
|
+
getConfigurationUpdatingAtom: t.configurationUpdatingAtom,
|
|
1056
|
+
createAttributesAtom: At(t),
|
|
1057
|
+
getChoiceAttributeAtomFamily: t.choiceAttributeAtomFamily,
|
|
1058
|
+
getNumericAttributeAtomFamily: t.numericAttributeAtomFamily,
|
|
1059
|
+
getBooleanAttributeAtomFamily: t.booleanAttributeAtomFamily,
|
|
1060
|
+
getComponentAttributeAtomFamily: t.componentAttributeAtomFamily,
|
|
1061
|
+
getConfigurationAtom: t.guardedConfigurationAtom,
|
|
1062
|
+
getConfigurationSatisfactionAtom: t.configurationSatisfactionAtom,
|
|
1063
|
+
getConfigurationStoringAtom: t.configurationStoringAtom,
|
|
1064
|
+
getMakeDecisionAtom: t.makeDecisionAtom,
|
|
1065
|
+
getDecisionQueriesAtom: t.decisionQueriesAtom,
|
|
1066
|
+
getConfigurationResetAtom: t.configurationResetAtom,
|
|
1067
|
+
getSessionReinitializationAtom: t.sessionReinitializationAtom,
|
|
1068
|
+
getExplainAtom: t.explainAtom,
|
|
1069
|
+
getTaskSchedulingAtom: t.taskSchedulingAtom,
|
|
1070
|
+
getStoredConfigurationAtom: t.guardedStoredConfigurationAtom,
|
|
1071
|
+
getDecisionsAtom: t.guardedDecisionsAtom,
|
|
1072
|
+
getExplicitDecisionsAtom: t.guardedExplicitDecisionsAtom,
|
|
1073
|
+
getImplicitDecisionsAtom: t.guardedImplicitDecisionsAtom
|
|
1074
|
+
}), [t]);
|
|
750
1075
|
}
|
|
751
1076
|
export {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
1077
|
+
qn as Configuration,
|
|
1078
|
+
E as ConfigurationUninitialized,
|
|
1079
|
+
Fn as useAttributes,
|
|
1080
|
+
Pn as useBooleanAttribute,
|
|
1081
|
+
Mn as useChoiceAttribute,
|
|
1082
|
+
Un as useComponentAttribute,
|
|
1083
|
+
_n as useConfiguration,
|
|
1084
|
+
jn as useConfigurationInitialization,
|
|
1085
|
+
Bn as useConfigurationReset,
|
|
1086
|
+
Nn as useConfigurationSatisfaction,
|
|
1087
|
+
Wn as useConfigurationStoring,
|
|
1088
|
+
Tn as useConfigurationUpdating,
|
|
1089
|
+
ct as useConfiguratorStore,
|
|
1090
|
+
$n as useDecisionQueries,
|
|
1091
|
+
Jn as useDecisions,
|
|
1092
|
+
Vn as useExplain,
|
|
1093
|
+
Hn as useJotaiAtoms,
|
|
1094
|
+
Qn as useMakeDecision,
|
|
1095
|
+
zn as useNumericAttribute,
|
|
1096
|
+
On as useSessionReinitialization,
|
|
1097
|
+
Kn as useStoredConfiguration,
|
|
1098
|
+
Ln as useTaskScheduling
|
|
764
1099
|
};
|