@viamedici-spc/configurator-react 1.0.1 → 1.0.3-rc0001

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/index.js CHANGED
@@ -1,764 +1,1099 @@
1
- import { AttributeType as S, ConfigurationInterpreter as E, DecisionKind as te, ExplainQuestionSubject as w, ExplainQuestionType as oe, globalAttributeIdEquals as re, globalConstraintIdEquals as ae, AllowedRulesInExplainType as h } from "@viamedici-spc/configurator-ts";
2
- import { pipe as m, RA as l, O as a, some as U, none as D, flow as le, identity as ue, Eq as c, RR as ce, Str as I, constVoid as ge } from "@viamedici-spc/fp-ts-extensions";
3
- import { createContext as P, useContext as N, useMemo as d, useRef as Q, useEffect as de } from "react";
4
- import { match as M } from "ts-pattern";
5
- import { jsx as b, Fragment as fe } from "react/jsx-runtime";
6
- import { createMachine as F, assign as f, sendParent as X, spawn as K, forwardTo as q, send as pe } from "xstate";
7
- import { log as C, pure as Ce, stop as G } from "xstate/lib/actions";
8
- import { deepEqual as me } from "fast-equals";
9
- import { useMachine as Se } from "@xstate/react";
10
- const A = window.configuratorReactContexts ?? {
11
- ConfigurationSessionContext: P(null),
12
- ConfigurationInitializationContext: P(null),
13
- ConfigurationUpdatingContext: P(null),
14
- ConfigurationContext: P(null)
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 = A;
17
- const Y = A.ConfigurationSessionContext, Z = A.ConfigurationInitializationContext, $ = A.ConfigurationUpdatingContext, ee = A.ConfigurationContext, j = () => N(Y), x = () => N(ee), ne = "The configuration is not initialized. Consider using the ConfigurationSuspender or unload components manually that make use of any unsafe hook while the configuration is initializing. Check the hooks documentation to see if it is safe to use while the configuration is initializing.";
18
- function B(e) {
19
- if (!e)
20
- throw new Error(ne);
21
- }
22
- function R(e) {
23
- if (!e)
24
- throw new Error(ne);
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 be(e) {
58
- return m(
59
- e,
60
- a.fromPredicate(_),
61
- a.map(() => ({
62
- type: S.Numeric,
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 we(e) {
69
- return m(
70
- e,
71
- a.fromPredicate(_),
72
- a.map(() => ({
73
- type: S.Boolean,
74
- attributeId: e.id,
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 Ae(e) {
80
- return m(
81
- e,
82
- a.fromPredicate(_),
83
- a.map(() => ({
84
- type: S.Component,
85
- attributeId: e.id,
86
- state: null
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
- function Pe(e, n) {
91
- return m(
92
- E.filterAttributesOfComponent(n, e, !0),
93
- (s) => [
94
- m(
95
- s,
96
- l.filter(ye),
97
- l.chain(se)
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
- function qe() {
122
- const e = j();
123
- return B(e), d(() => ({
124
- explain: (n, s) => M(s).with("decisions", (i) => e.explain(n, i)).with("constraints", (i) => e.explain(n, i)).with("full", (i) => e.explain(n, i)).exhaustive(),
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
- function sn(e) {
143
- const n = x(), { makeDecision: s, setManyDecision: i } = z(), t = O(e, w.choiceValue);
144
- R(n);
145
- const o = E.getChoiceAttribute(n, e), u = d(() => ({
146
- makeDecision: (r, p) => s({
147
- type: S.Choice,
148
- attributeId: e,
149
- choiceValueId: r,
150
- state: p
151
- }),
152
- clearDecisions: m(
153
- o,
154
- a.fromNullable,
155
- a.map(se),
156
- // Only setMany if there are decisions to clear.
157
- a.filter(l.isNonEmpty),
158
- a.map((r) => () => i(r, { type: "Default" })),
159
- a.getOrElse(() => () => Promise.resolve())
160
- ),
161
- ...t
162
- }), [e, o, s, i, t]), g = d(() => ({
163
- ...u,
164
- attribute: o
165
- }), [o, u]);
166
- if (o)
167
- return g;
168
- }
169
- function tn(e) {
170
- const n = x(), { makeDecision: s } = z(), i = O(e, w.numeric);
171
- R(n);
172
- const t = E.getNumericAttribute(n, e), o = d(() => ({
173
- makeDecision: (g) => s({
174
- type: S.Numeric,
175
- attributeId: e,
176
- state: g
177
- }),
178
- ...i
179
- }), [e, s, i]), u = d(() => ({
180
- ...o,
181
- attribute: t
182
- }), [t, o]);
183
- if (t)
184
- return u;
185
- }
186
- function on(e) {
187
- const n = x(), { makeDecision: s } = z(), i = O(e, w.boolean);
188
- R(n);
189
- const t = E.getBooleanAttribute(n, e), o = d(() => ({
190
- makeDecision: (g) => s({
191
- type: S.Boolean,
192
- attributeId: e,
193
- state: g
194
- }),
195
- ...i
196
- }), [e, s, i]), u = d(() => ({
197
- ...o,
198
- attribute: t
199
- }), [t, o]);
200
- if (t)
201
- return u;
202
- }
203
- function rn(e) {
204
- const n = x(), { makeDecision: s, setManyDecision: i } = z(), t = O(e, w.component);
205
- R(n);
206
- const o = n.attributes, u = E.getComponentAttribute(n, e), g = d(() => ({
207
- makeDecision: (p) => s({
208
- type: S.Component,
209
- attributeId: e,
210
- state: p
211
- }),
212
- clearSubtree: m(
213
- Pe(e, o),
214
- // Only setMany if there are decisions to clear.
215
- a.fromPredicate(l.isNonEmpty),
216
- a.map((p) => () => i(p, { type: "Default" })),
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
- actualClient: null,
269
- session: null,
270
- sessionCreationError: null,
271
- sessionUpdateError: null,
272
- hasEverSuccessfullyCreatedSession: !1
205
+ configurationSession: null,
206
+ sessionCreateOrUpdateError: null
273
207
  },
274
- initial: "ProcessChanges",
275
208
  on: {
276
- ChangeConfigurationClient: {
277
- actions: ["saveDesiredClient"]
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
- ChangeSessionContext: {
280
- actions: ["saveDesiredSessionContext"]
224
+ Shutdown: {
225
+ target: "#shutdown"
281
226
  }
282
227
  },
283
- exit: [
284
- C("Shutting down", "SessionManagement:"),
285
- "disposeOldSession"
286
- ],
228
+ initial: "Idle",
287
229
  states: {
288
- ProcessChanges: {
289
- entry: [
290
- C("Entering ProcessChanges", "SessionManagement:"),
291
- y(
292
- 2
293
- /* Other */
294
- )
295
- ],
230
+ Idle: {
296
231
  always: [
297
- { target: "DisposeSession", cond: "shallDisposeSession" },
298
- { target: "CreateSession", cond: "shallCreateSession" },
299
- { target: "UpdateSession", cond: "shallUpdateSession" }
232
+ { target: "DisposeSession", guard: "shallDispose" },
233
+ { target: "Processing", guard: "shallProcess" }
300
234
  ]
301
235
  },
302
- DisposeSession: {
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
- id: "getNewSession",
325
- src: "createSession",
238
+ src: "createOrUpdateSession",
239
+ input: ({ context: t }) => ({
240
+ sessionContext: t.desiredSessionContext,
241
+ session: K.fromNullable(t.configurationSession)
242
+ }),
326
243
  onDone: {
327
- actions: ["setSessionCreationResult", "setHasEverSuccessfullyCreatedSession"],
328
- target: "ProcessChanges"
329
- },
330
- onError: {
331
- actions: "setSessionCreationError",
332
- target: "SessionCreationFailed"
333
- }
334
- }
335
- },
336
- SessionCreationFailed: {
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
- UpdateSession: {
362
- entry: [
363
- C("Entering UpdateSession", "SessionManagement:"),
364
- y(
365
- 1
366
- /* UpdateSession */
367
- )
368
- ],
369
- invoke: {
370
- id: "updateExistingSession",
371
- src: "updateSession",
372
- onDone: {
373
- target: "ProcessChanges"
374
- },
375
- onError: {
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
- SessionUpdateFailed: {
273
+ Shutdown: {
274
+ type: "final",
275
+ id: "shutdown",
382
276
  entry: [
383
- C("Entering SessionUpdateFailed", "SessionManagement:"),
384
- y(
385
- 2
386
- /* Other */
387
- )
388
- ],
389
- always: {
390
- // Immediately process changes if there were changes during session update attempt
391
- // This will also be triggered if session context or client changes
392
- target: "ProcessChanges",
393
- cond: "shallImmediatelyProcessChangesAfterSessionUpdateError"
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 y(e) {
465
- const n = e === 0, s = e === 1;
466
- return Ce((i, t) => {
467
- const o = {
468
- isInitializing: (!i.hasEverSuccessfullyCreatedSession || n) && i.sessionCreationError == null,
469
- failureResult: i.sessionCreationError && i.sessionCreationError.failureResult
470
- }, u = {
471
- isUpdating: s && i.sessionUpdateError == null,
472
- failureResult: i.sessionUpdateError && i.sessionUpdateError.failureResult
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
- return X({
475
- type: "SessionManagementStateChanged",
476
- sessionInitialization: o,
477
- sessionUpdating: u,
478
- session: i.session
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
- const Fe = (e) => (n) => (n({
483
- type: "ConfigurationChanged",
484
- session: e,
485
- configuration: e.getConfiguration()
486
- }), e.setOnConfigurationChangedHandler((s) => {
487
- n({
488
- type: "ConfigurationChanged",
489
- session: e,
490
- configuration: s
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
- e.setOnConfigurationChangedHandler(null);
494
- }), je = () => F({
495
- predictableActionArguments: !0,
496
- preserveActionOrder: !0,
497
- schema: {
498
- context: {},
499
- events: {}
500
- },
501
- context: {
502
- session: null
503
- },
504
- on: {
505
- // Forward the configuration data to the parent.
506
- ConfigurationChanged: {
507
- actions: [
508
- X((e, n) => n)
509
- ]
510
- }
511
- },
512
- initial: "ProcessChanges",
513
- states: {
514
- ProcessChanges: {
515
- entry: [
516
- C("Entering ProcessChanges", "ConfigurationSubscriptionManagement:")
517
- ],
518
- on: {
519
- ChangeSession: {
520
- actions: [
521
- "saveSession"
522
- ]
523
- }
524
- },
525
- always: [
526
- {
527
- target: "Subscribe",
528
- cond: (e, n) => e.session != null
529
- }
530
- ]
531
- },
532
- Subscribe: {
533
- entry: [
534
- C("Entering Subscribe", "ConfigurationSubscriptionManagement:")
535
- ],
536
- on: {
537
- ChangeSession: {
538
- target: "ProcessChanges",
539
- cond: (e, n) => n.session == null || e.session !== n.session,
540
- actions: [
541
- "saveSession"
542
- ]
543
- }
544
- },
545
- invoke: {
546
- id: "configurationSubscriptionActor",
547
- src: (e, n) => Fe(e.session)
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
- actions: {
553
- saveSession: f((e, n) => ({
554
- session: n.session
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
- }), Be = () => {
558
- let e, n;
559
- return {
560
- promise: new Promise((i, t) => {
561
- e = i, n = t;
562
- }),
563
- resolve: e,
564
- reject: n
565
- };
566
- }, L = () => {
567
- const e = Be();
568
- return {
569
- capsule: { promise: e.promise },
570
- resolve: e.resolve,
571
- reject: e.reject
572
- };
573
- };
574
- var He = function(e, n, s) {
575
- var i = Q(), t = Q(0);
576
- return i.current == null && (i.current = e), n.equals(e, i.current) || (s && s.debug && process.env.NODE_ENV !== "production" && console.info("Stable hook update triggered:", { prev: i.current, value: e }), i.current = e, t.current += 1), [t.current];
577
- }, W = function(e, n, s, i) {
578
- return de(e, He(n, s, i));
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
- const Ve = () => F({
581
- predictableActionArguments: !0,
582
- preserveActionOrder: !0,
583
- schema: {
584
- context: {},
585
- events: {}
586
- },
587
- context: {
588
- sessionManagementActor: null,
589
- configurationSubscriptionManagementActor: null,
590
- sessionInitialization: null,
591
- sessionUpdating: null,
592
- session: null,
593
- configuration: null,
594
- isReadyPromise: L()
595
- },
596
- entry: [
597
- f({
598
- sessionManagementActor: () => K(Te()),
599
- configurationSubscriptionManagementActor: () => K(je())
600
- })
601
- ],
602
- exit: [
603
- G((e) => e.sessionManagementActor),
604
- G((e) => e.configurationSubscriptionManagementActor)
605
- ],
606
- on: {
607
- // Forward events for sessionManagement
608
- ChangeConfigurationClient: {
609
- actions: [
610
- q((e) => e.sessionManagementActor)
611
- ]
612
- },
613
- ChangeSessionContext: {
614
- actions: [
615
- q((e) => e.sessionManagementActor)
616
- ]
617
- },
618
- RetrySessionCreation: {
619
- actions: [
620
- q((e) => e.sessionManagementActor)
621
- ]
622
- },
623
- RetrySessionUpdate: {
624
- actions: [
625
- q((e) => e.sessionManagementActor)
626
- ]
627
- },
628
- SessionManagementStateChanged: {
629
- actions: [
630
- // Assign the received data
631
- f((e, n) => ({
632
- session: n.session,
633
- sessionInitialization: n.sessionInitialization,
634
- sessionUpdating: n.sessionUpdating
635
- })),
636
- // Forward the session to the configuration subscription
637
- pe((e) => ({
638
- type: "ChangeSession",
639
- session: e.session
640
- }), { to: (e) => e.configurationSubscriptionManagementActor }),
641
- "calculateReadyState"
642
- ]
643
- },
644
- ConfigurationChanged: {
645
- actions: [
646
- f((e, n) => ({
647
- configuration: {
648
- session: n.session,
649
- configuration: n.configuration
650
- }
651
- })),
652
- "calculateReadyState"
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
- actions: {
662
- calculateReadyState: f((e, n) => {
663
- var t;
664
- const s = !((t = e.sessionInitialization) != null && t.isInitializing) && e.session != null && e.configuration != null && e.configuration.session === e.session;
665
- return e.isReadyPromise && s && (e.isReadyPromise.resolve(), e.isReadyPromise.capsule.promise = null), {
666
- isReadyPromise: (() => s ? null : e.isReadyPromise != null ? e.isReadyPromise : L())()
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
- function Qe(e) {
672
- var u, g;
673
- const [n, s] = Se(Ve, {
674
- logger: (...r) => console.log("ConfigurationManagement:", ...r)
675
- });
676
- W(() => {
677
- s({
678
- type: "ChangeConfigurationClient",
679
- client: e.configuratorClient
680
- }), e.configuratorClient || console.warn("The configurator client is null or undefined. This will dispose the session that may exist. If this was not intended, make sure you pass a valid client.");
681
- }, [e.configuratorClient], c.tuple(v)), W(() => {
682
- const r = m(
683
- a.fromNullable(e.sessionContext),
684
- a.chainFirst((p) => a.fromNullable(p.configurationModelSource)),
685
- a.toNullable
686
- );
687
- s({
688
- type: "ChangeSessionContext",
689
- sessionContext: r
690
- }), r || console.warn("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.");
691
- }, [e.sessionContext], c.tuple(T));
692
- const i = d(
693
- () => {
694
- var r, p, H, V;
695
- return {
696
- isInitializing: ((p = (r = n.context.isReadyPromise) == null ? void 0 : r.capsule) == null ? void 0 : p.promise) != null,
697
- isInitializingPromise: (H = n.context.isReadyPromise) == null ? void 0 : H.capsule,
698
- error: ((V = n.context.sessionInitialization) == null ? void 0 : V.failureResult) && {
699
- ...n.context.sessionInitialization.failureResult,
700
- retry: () => s({ type: "RetrySessionCreation" })
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
- [n.context.sessionInitialization, n.context.isReadyPromise]
705
- ), t = d(
706
- () => {
707
- var r, p;
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
- isUpdating: (r = n.context.sessionUpdating) == null ? void 0 : r.isUpdating,
710
- error: ((p = n.context.sessionUpdating) == null ? void 0 : p.failureResult) && {
711
- ...n.context.sessionUpdating.failureResult,
712
- retry: () => s({ type: "RetrySessionUpdate" })
713
- }
749
+ makeDecision: (u) => r({
750
+ type: J.Numeric,
751
+ attributeId: i.id,
752
+ state: u
753
+ })
714
754
  };
715
- },
716
- [n.context.sessionUpdating]
717
- ), o = ((u = n.context.configuration) == null ? void 0 : u.session) === n.context.session ? (g = n.context.configuration) == null ? void 0 : g.configuration : null;
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
- configurationInitialization: i,
720
- configurationUpdating: t,
721
- session: n.context.session,
722
- configuration: o
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
- function an(e) {
726
- const { configuratorClient: n, ...s } = e, { configurationInitialization: i, configurationUpdating: t, session: o, configuration: u } = Qe({
727
- configuratorClient: n,
728
- sessionContext: s
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 Ke() {
733
- return N(Z);
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
- return N($);
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
- function un(e) {
739
- const { children: n } = e, { isInitializingPromise: s } = Ke();
740
- if (s != null && s.promise)
741
- throw s.promise;
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 cn() {
745
- const e = j(), n = x();
746
- return B(e), R(n), d(() => ({
747
- configuration: n,
748
- restoreConfiguration: (s) => e.restoreConfiguration(s)
749
- }), [n, e]);
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
- an as Configuration,
753
- un as ConfigurationSuspender,
754
- nn as useAttributes,
755
- on as useBooleanAttribute,
756
- sn as useChoiceAttribute,
757
- rn as useComponentAttribute,
758
- cn as useConfiguration,
759
- Ke as useConfigurationInitialization,
760
- ln as useConfigurationUpdating,
761
- z as useDecision,
762
- qe as useExplain,
763
- tn as useNumericAttribute
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
  };