@viamedici-spc/configurator-react 0.1.2 → 1.0.0

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,762 +1,254 @@
1
- import "ts-pattern";
2
- import { deepEqual as ge } from "fast-equals";
3
- import { createContext as $, useContext as B, useMemo as m, useEffect as re } from "react";
4
- import { jsx as k, Fragment as We } from "react/jsx-runtime";
5
- import { createMachine as ne, assign as C, sendParent as de, spawn as ae, forwardTo as F, send as Ge } from "xstate";
6
- import { log as S, pure as Ke, stop as ue } from "xstate/lib/actions";
7
- import { useMachine as Qe } from "@xstate/react";
8
- var Xe = globalThis && globalThis.__spreadArray || function(e, n, t) {
9
- if (t || arguments.length === 2)
10
- for (var i = 0, o = n.length, s; i < o; i++)
11
- (s || !(i in n)) && (s || (s = Array.prototype.slice.call(n, 0, i)), s[i] = n[i]);
12
- return e.concat(s || Array.prototype.slice.call(n));
13
- };
14
- function O(e) {
15
- return e;
16
- }
17
- function pe(e) {
18
- return function() {
19
- return e;
20
- };
21
- }
22
- var Ye = /* @__PURE__ */ pe(null), Ce = /* @__PURE__ */ pe(void 0), Je = Ce;
23
- function he(e, n, t, i, o, s, a, c, u) {
24
- switch (arguments.length) {
25
- case 1:
26
- return e;
27
- case 2:
28
- return function() {
29
- return n(e.apply(this, arguments));
30
- };
31
- case 3:
32
- return function() {
33
- return t(n(e.apply(this, arguments)));
34
- };
35
- case 4:
36
- return function() {
37
- return i(t(n(e.apply(this, arguments))));
38
- };
39
- case 5:
40
- return function() {
41
- return o(i(t(n(e.apply(this, arguments)))));
42
- };
43
- case 6:
44
- return function() {
45
- return s(o(i(t(n(e.apply(this, arguments))))));
46
- };
47
- case 7:
48
- return function() {
49
- return a(s(o(i(t(n(e.apply(this, arguments)))))));
50
- };
51
- case 8:
52
- return function() {
53
- return c(a(s(o(i(t(n(e.apply(this, arguments))))))));
54
- };
55
- case 9:
56
- return function() {
57
- return u(c(a(s(o(i(t(n(e.apply(this, arguments)))))))));
58
- };
59
- }
60
- }
61
- function r(e, n, t, i, o, s, a, c, u) {
62
- switch (arguments.length) {
63
- case 1:
64
- return e;
65
- case 2:
66
- return n(e);
67
- case 3:
68
- return t(n(e));
69
- case 4:
70
- return i(t(n(e)));
71
- case 5:
72
- return o(i(t(n(e))));
73
- case 6:
74
- return s(o(i(t(n(e)))));
75
- case 7:
76
- return a(s(o(i(t(n(e))))));
77
- case 8:
78
- return c(a(s(o(i(t(n(e)))))));
79
- case 9:
80
- return u(c(a(s(o(i(t(n(e))))))));
81
- default: {
82
- for (var d = arguments[0], p = 1; p < arguments.length; p++)
83
- d = arguments[p](d);
84
- return d;
85
- }
86
- }
87
- }
88
- var te = function(e, n) {
89
- var t = typeof e == "number" ? function(i) {
90
- return i.length >= e;
91
- } : e;
92
- return function() {
93
- var i = Array.from(arguments);
94
- return t(arguments) ? n.apply(this, i) : function(o) {
95
- return n.apply(void 0, Xe([o], i, !1));
96
- };
97
- };
98
- };
99
- globalThis && globalThis.__spreadArray;
100
- var me = function(e) {
101
- return e._tag === "Some";
102
- }, Se = { _tag: "None" }, ye = function(e) {
103
- return { _tag: "Some", value: e };
104
- }, Le = function(e) {
105
- return e.length > 0;
106
- }, Ze = [], en = Object.prototype.hasOwnProperty;
107
- function nn(e) {
108
- return function(n, t) {
109
- return e.chain(n, function(i) {
110
- return e.map(t(i), function() {
111
- return i;
112
- });
113
- });
114
- };
115
- }
116
- var E = function(e) {
117
- return {
118
- equals: function(n, t) {
119
- return n === t || e(n, t);
120
- }
121
- };
122
- }, M = function(e) {
123
- return E(function(n, t) {
124
- for (var i in e)
125
- if (!e[i].equals(n[i], t[i]))
126
- return !1;
127
- return !0;
128
- });
129
- }, ve = {
130
- equals: function(e, n) {
131
- return e === n;
132
- }
133
- };
134
- ve.equals;
135
- var y = Se, q = ye;
1
+ import { AttributeType as S, ConfigurationInterpreter as E, DecisionKind as ie, ExplainQuestionSubject as A, ExplainQuestionType as te, globalAttributeIdEquals as oe, globalConstraintIdEquals as re, AllowedRulesInExplainType as h } from "@viamedici-spc/configurator-ts";
2
+ import { pipe as m, RA as l, O as a, some as w, none as M, flow as ae, identity as le, Eq as c, RR as ue, Str as U, constVoid as ce } from "@viamedici-spc/fp-ts-extensions";
3
+ import { createContext as D, useContext as I, useMemo as g, useRef as V, useEffect as de } from "react";
4
+ import { match as v } from "ts-pattern";
5
+ import { jsx as b, Fragment as ge } from "react/jsx-runtime";
6
+ import { createMachine as T, assign as f, sendParent as W, spawn as Q, forwardTo as P, send as fe } from "xstate";
7
+ import { log as C, pure as pe, stop as K } from "xstate/lib/actions";
8
+ import { deepEqual as Ce } from "fast-equals";
9
+ import { useMachine as me } from "@xstate/react";
10
+ const X = D(null), Y = D(null), Z = D(null), $ = D(null), F = () => I(X), x = () => I($), ee = "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.";
136
11
  function j(e) {
137
- return function(n) {
138
- return e(n) ? q(n) : y;
139
- };
140
- }
141
- var tn = function(e, n) {
142
- return r(e, A(n));
143
- }, on = function(e, n) {
144
- return r(e, an(n));
145
- }, sn = "Option", rn = function(e) {
146
- return {
147
- equals: function(n, t) {
148
- return n === t || (v(n) ? v(t) : v(t) ? !1 : e.equals(n.value, t.value));
149
- }
150
- };
151
- }, A = function(e) {
152
- return function(n) {
153
- return v(n) ? y : q(e(n.value));
154
- };
155
- }, an = function(e) {
156
- return function(n) {
157
- return v(n) || v(e) ? y : q(n.value(e.value));
158
- };
159
- }, Ee = /* @__PURE__ */ te(2, function(e, n) {
160
- return v(e) ? y : n(e.value);
161
- }), un = {
162
- URI: sn,
163
- map: tn,
164
- ap: on,
165
- chain: Ee
166
- }, R = function(e) {
167
- return function(n) {
168
- return v(n) ? y : e(n.value) ? n : y;
169
- };
170
- }, v = function(e) {
171
- return e._tag === "None";
172
- }, cn = function(e, n) {
173
- return function(t) {
174
- return v(t) ? e() : n(t.value);
175
- };
176
- }, ie = cn, ln = function(e) {
177
- return function(n) {
178
- return v(n) ? e() : n.value;
179
- };
180
- }, D = ln, fn = /* @__PURE__ */ te(2, nn(un)), l = function(e) {
181
- return e == null ? y : q(e);
182
- }, V = /* @__PURE__ */ ie(Ye, O), b = /* @__PURE__ */ ie(Ce, O), gn = Ee, dn = fn;
183
- globalThis && globalThis.__spreadArray;
184
- var pn = Ze, Cn = Le;
185
- globalThis && globalThis.__spreadArray;
186
- var hn = function(e) {
187
- return e.length === 0;
188
- }, Ae = Cn, mn = function(e) {
189
- return function(n) {
190
- if (hn(n))
191
- return vn;
192
- for (var t = [], i = 0; i < n.length; i++)
193
- t.push.apply(t, e(i, n[i]));
194
- return t;
195
- };
196
- };
197
- function Pe(e) {
198
- return function(n) {
199
- for (var t = 0; t < n.length; t++)
200
- if (e(n[t]))
201
- return ye(n[t]);
202
- return Se;
203
- };
204
- }
205
- var Sn = function(e, n, t) {
206
- for (var i = [], o = Math.min(e.length, n.length), s = 0; s < o; s++)
207
- i[s] = t(e[s], n[s]);
208
- return i;
209
- };
210
- function Me(e, n) {
211
- return n === void 0 ? function(t) {
212
- return Me(t, e);
213
- } : Sn(e, n, function(t, i) {
214
- return [t, i];
215
- });
216
- }
217
- var qe = /* @__PURE__ */ te(2, function(e, n) {
218
- return r(e, mn(function(t, i) {
219
- return n(i, t);
220
- }));
221
- }), Re = /* @__PURE__ */ qe(O), P = function(e) {
222
- return function(n) {
223
- return n.map(function(t) {
224
- return e(t);
225
- });
226
- };
227
- }, h = function(e) {
228
- return function(n) {
229
- return n.filter(e);
230
- };
231
- }, yn = function(e) {
232
- return function(n) {
233
- for (var t = [], i = 0; i < n.length; i++) {
234
- var o = e(i, n[i]);
235
- me(o) && t.push(o.value);
236
- }
237
- return t;
238
- };
239
- }, U = function(e) {
240
- return yn(function(n, t) {
241
- return e(t);
242
- });
243
- }, Y = /* @__PURE__ */ U(O), H = function(e) {
244
- return E(function(n, t) {
245
- return n.length === t.length && n.every(function(i, o) {
246
- return e.equals(i, t[o]);
247
- });
248
- });
249
- }, vn = pn;
250
- function En(e) {
251
- return function(n) {
252
- return n.every(e);
253
- };
254
- }
255
- var An = qe, g = {
256
- equals: function(e, n) {
257
- return e === n;
258
- }
259
- };
260
- g.equals;
261
- function Ue(e) {
262
- return function(n, t) {
263
- if (t === void 0) {
264
- var i = Ue(e);
265
- return function(s) {
266
- return i(s, n);
267
- };
268
- }
269
- for (var o in n)
270
- if (!en.call(t, o) || !e.equals(n[o], t[o]))
271
- return !1;
272
- return !0;
273
- };
274
- }
275
- function xe(e) {
276
- var n = Ue(e);
277
- return E(function(t, i) {
278
- return n(t)(i) && n(i)(t);
279
- });
280
- }
281
- function W(e) {
282
- return {
283
- equals(n, t) {
284
- return n == null && t == null ? !0 : n == null || t === null || t === void 0 ? !1 : e.equals(n, t);
285
- }
286
- };
287
- }
288
- function _(e) {
289
- return {
290
- equals(n, t) {
291
- const i = r(l(n), D(() => [])), o = r(l(t), D(() => []));
292
- return H(e).equals(i, o);
293
- }
294
- };
295
- }
296
- const ce = M({
297
- localId: g,
298
- componentPath: _(g),
299
- sharedConfigurationModel: W(g)
300
- }), Pn = rn(H(M({
301
- attributeId: ce,
302
- decisions: _(ce)
303
- })));
304
- M({
305
- configurationModelSource: E((e, n) => ge(e, n)),
306
- decisionsToRespect: Pn,
307
- usageRuleParameters: xe(g)
308
- });
309
- const Ie = M({
310
- localId: g,
311
- componentPath: _(g),
312
- sharedConfigurationModelId: W(g)
313
- }), Mn = M({
314
- localId: g,
315
- componentPath: _(g),
316
- sharedConfigurationModelId: W(g)
317
- });
318
- var Z = /* @__PURE__ */ ((e) => (e.Choice = "Choice", e.ChoiceValue = "ChoiceValue", e))(Z || {}), f = /* @__PURE__ */ ((e) => (e.Boolean = "Boolean", e.Numeric = "Numeric", e.Choice = "Choice", e.Component = "Component", e))(f || {}), G = /* @__PURE__ */ ((e) => (e.Implicit = "Implicit", e.Explicit = "Explicit", e))(G || {});
319
- M({
320
- localId: g,
321
- componentPath: _(g),
322
- sharedConfigurationModelId: W(g)
323
- });
324
- function qn(e, n) {
325
- return r(
326
- e.values,
327
- U((t) => r(
328
- t.decision,
329
- l,
330
- R((i) => i.kind === n)
331
- ))
332
- );
333
- }
334
- function Rn(e) {
335
- return r(
336
- e.decision,
337
- l,
338
- R((n) => n.kind === G.Explicit),
339
- V
340
- );
341
- }
342
- function Un(e) {
343
- return r(
344
- e.decision,
345
- l,
346
- R((n) => n.kind === G.Explicit),
347
- V
348
- );
349
- }
350
- function xn(e) {
351
- return r(
352
- e.decision,
353
- l,
354
- V
355
- );
356
- }
357
- const De = (e) => e.type === f.Boolean, be = (e) => e.type === f.Choice, _e = (e) => e.type === f.Numeric, we = (e) => e.type === f.Component, In = _(g);
358
- function Dn(e, n, t) {
359
- var i;
360
- const o = ((i = n.componentPath) == null ? void 0 : i.length) ?? 0;
361
- return r(e, h((s) => {
362
- var a;
363
- const c = ((a = s.id.componentPath) == null ? void 0 : a.length) ?? 0;
364
- return t ? o > c ? !1 : r(
365
- s.id.componentPath ?? [],
366
- Me(n.componentPath ?? []),
367
- En(([u, d]) => u === d)
368
- ) : In.equals(s.id.componentPath, n.componentPath);
369
- }));
370
- }
371
- function bn(e, n, t) {
372
- return [];
373
- }
374
- function _n(e) {
375
- return r(e, h((n) => {
376
- const t = r(
377
- n.id.componentPath,
378
- l,
379
- A((o) => o.length === 0),
380
- D(() => !0)
381
- ), i = r(
382
- n.id.sharedConfigurationModelId,
383
- l,
384
- ie(() => !0, () => !1)
385
- );
386
- return t && i;
387
- }));
388
- }
389
- function wn(e, n) {
390
- return r(
391
- Ne(e),
392
- P((t) => qn(t, n)),
393
- Re,
394
- U((t) => l(t))
395
- );
396
- }
397
- function Nn(e, n) {
398
- return r(
399
- ke(e),
400
- h((t) => {
401
- var i;
402
- return ((i = t.decision) == null ? void 0 : i.kind) === n;
403
- }),
404
- P((t) => Rn(t)),
405
- U((t) => l(t))
406
- );
407
- }
408
- function Tn(e, n) {
409
- return r(
410
- Oe(e),
411
- h((t) => {
412
- var i;
413
- return ((i = t.decision) == null ? void 0 : i.kind) === n;
414
- }),
415
- P((t) => Un(t)),
416
- U((t) => l(t))
417
- );
418
- }
419
- function kn(e, n) {
420
- return r(
421
- Te(e),
422
- h((t) => {
423
- var i;
424
- return ((i = t.decision) == null ? void 0 : i.kind) === n;
425
- }),
426
- P((t) => xn(t)),
427
- U((t) => l(t))
428
- );
429
- }
430
- function Ne(e) {
431
- return r(
432
- e.attributes,
433
- h(be)
434
- );
435
- }
436
- function Te(e) {
437
- return r(
438
- e.attributes,
439
- h(we)
440
- );
441
- }
442
- function ke(e) {
443
- return r(
444
- e.attributes,
445
- h(_e)
446
- );
447
- }
448
- function Oe(e) {
449
- return r(
450
- e.attributes,
451
- h(De)
452
- );
453
- }
454
- function On(e, n) {
455
- return r(
456
- z(e, n),
457
- b
458
- );
459
- }
460
- function zn(e, n) {
461
- return r(
462
- ze(e, n),
463
- b
464
- );
465
- }
466
- function Fn(e, n, t) {
467
- return r(
468
- ze(e, n),
469
- A((i) => i.values),
470
- gn(he(Pe((i) => i.id === t))),
471
- b
472
- );
473
- }
474
- function $n(e, n) {
475
- return r(
476
- z(e, n),
477
- R(_e),
478
- b
479
- );
480
- }
481
- function Bn(e, n) {
482
- return r(
483
- z(e, n),
484
- R(De),
485
- b
486
- );
487
- }
488
- function jn(e, n) {
489
- return r(
490
- z(e, n),
491
- R(we),
492
- b
493
- );
494
- }
495
- function z(e, n) {
496
- return r(
497
- e.attributes,
498
- Pe((t) => Ie.equals(t.id, n))
499
- );
500
- }
501
- function ze(e, n) {
502
- return r(
503
- z(e, n),
504
- R(be)
505
- );
506
- }
507
- const w = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
508
- __proto__: null,
509
- filterAttributesOfComponent: Dn,
510
- filterAttributesOfRoot: _n,
511
- filterAttributesOfShared: bn,
512
- getAttribute: On,
513
- getBooleanAttribute: Bn,
514
- getBooleanAttributes: Oe,
515
- getBooleanDecisions: Tn,
516
- getChoiceAttribute: zn,
517
- getChoiceAttributes: Ne,
518
- getChoiceDecisions: wn,
519
- getChoiceValue: Fn,
520
- getComponentAttribute: jn,
521
- getComponentAttributes: Te,
522
- getComponentDecisions: kn,
523
- getNumericAttribute: $n,
524
- getNumericAttributes: ke,
525
- getNumericDecisions: Nn
526
- }, Symbol.toStringTag, { value: "Module" })), le = Ie.equals;
527
- Mn.equals;
528
- function ee(e) {
529
- return E(
530
- (n, t) => {
531
- const i = n == null, o = t == null;
532
- return i && o || !i && !o && e.equals(n, t);
533
- }
534
- );
535
- }
536
- const Fe = $(null), $e = $(null), Be = $(null), je = $(null), oe = () => B(Fe), N = () => B(je), Ve = "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.";
537
- function se(e) {
538
12
  if (!e)
539
- throw new Error(Ve);
13
+ throw new Error(ee);
540
14
  }
541
- function T(e) {
15
+ function R(e) {
542
16
  if (!e)
543
- throw new Error(Ve);
544
- }
545
- function Vn() {
546
- const e = oe();
547
- return se(e), m(() => ({
548
- explainChoiceAttributeConsequence: (n, t, i) => e.explain({
549
- type: Z.ChoiceValue,
550
- attributeId: n,
551
- choiceValueId: t,
552
- question: i
553
- }),
554
- explainChoiceAttributeConsequences: (n, t) => e.explain({
555
- type: Z.Choice,
556
- attributeId: n,
557
- question: t
558
- }),
559
- applySolution: (n) => e.applySolution(n)
560
- }), [e]);
17
+ throw new Error(ee);
561
18
  }
562
- function K() {
563
- const e = oe();
564
- return se(e), m(() => ({
19
+ function N() {
20
+ const e = F();
21
+ return j(e), g(() => ({
565
22
  makeDecision: (n) => e.makeDecision(n),
566
- setManyDecision: (n, t) => e.setMany(n, t)
23
+ setManyDecision: (n, s) => e.setMany(n, s)
567
24
  }), [e]);
568
25
  }
569
- var Q = function(e) {
26
+ globalThis && globalThis.__spreadArray;
27
+ var Se = function(e) {
28
+ return e._tag === "Some";
29
+ }, k = function(e) {
570
30
  return function(n) {
571
- return me(e(n));
31
+ return Se(e(n));
572
32
  };
573
33
  };
574
- const Hn = Q((e) => e.type === f.Choice ? q(e) : y), Wn = Q((e) => e.type === f.Numeric ? q(e) : y), Gn = Q((e) => e.type === f.Boolean ? q(e) : y), Kn = Q((e) => e.type === f.Component ? q(e) : y);
575
- function X(e) {
576
- return e.decision != null && e.decision.kind === G.Explicit;
34
+ const he = k((e) => e.type === S.Choice ? w(e) : M), ye = k((e) => e.type === S.Numeric ? w(e) : M), Ee = k((e) => e.type === S.Boolean ? w(e) : M), xe = k((e) => e.type === S.Component ? w(e) : M);
35
+ function z(e) {
36
+ return e.decision != null && e.decision.kind === ie.Explicit;
577
37
  }
578
- function He(e) {
579
- return r(
38
+ function ne(e) {
39
+ return m(
580
40
  e.values,
581
- h(X),
582
- P((n) => ({
583
- type: f.Choice,
41
+ l.filter(z),
42
+ l.map((n) => ({
43
+ type: S.Choice,
584
44
  attributeId: e.id,
585
45
  choiceValueId: n.id,
586
46
  state: null
587
47
  }))
588
48
  );
589
49
  }
590
- function Qn(e) {
591
- return r(
50
+ function Re(e) {
51
+ return m(
592
52
  e,
593
- j(X),
594
- A(() => ({
595
- type: f.Numeric,
53
+ a.fromPredicate(z),
54
+ a.map(() => ({
55
+ type: S.Numeric,
596
56
  attributeId: e.id,
597
57
  state: null
598
58
  }))
599
59
  );
600
60
  }
601
- function Xn(e) {
602
- return r(
61
+ function be(e) {
62
+ return m(
603
63
  e,
604
- j(X),
605
- A(() => ({
606
- type: f.Boolean,
64
+ a.fromPredicate(z),
65
+ a.map(() => ({
66
+ type: S.Boolean,
607
67
  attributeId: e.id,
608
68
  state: null
609
69
  }))
610
70
  );
611
71
  }
612
- function Yn(e) {
613
- return r(
72
+ function Ae(e) {
73
+ return m(
614
74
  e,
615
- j(X),
616
- A(() => ({
617
- type: f.Component,
75
+ a.fromPredicate(z),
76
+ a.map(() => ({
77
+ type: S.Component,
618
78
  attributeId: e.id,
619
79
  state: null
620
80
  }))
621
81
  );
622
82
  }
623
- function Jn(e, n) {
624
- return r(
625
- w.filterAttributesOfComponent(n, e, !0),
626
- (t) => [
627
- r(
628
- t,
629
- h(Hn),
630
- An(He)
83
+ function Pe(e, n) {
84
+ return m(
85
+ E.filterAttributesOfComponent(n, e, !0),
86
+ (s) => [
87
+ m(
88
+ s,
89
+ l.filter(he),
90
+ l.chain(ne)
631
91
  ),
632
- r(
633
- t,
634
- h(Wn),
635
- P(Qn),
636
- Y
92
+ m(
93
+ s,
94
+ l.filter(ye),
95
+ l.map(Re),
96
+ l.compact
637
97
  ),
638
- r(
639
- t,
640
- h(Gn),
641
- P(Xn),
642
- Y
98
+ m(
99
+ s,
100
+ l.filter(Ee),
101
+ l.map(be),
102
+ l.compact
643
103
  ),
644
- r(
645
- t,
646
- h(Kn),
647
- P(Yn),
648
- Y
104
+ m(
105
+ s,
106
+ l.filter(xe),
107
+ l.map(Ae),
108
+ l.compact
649
109
  )
650
110
  ],
651
- Re
111
+ l.flatten
652
112
  );
653
113
  }
654
- function ht(e, n) {
655
- const t = N();
656
- return T(t), m(
657
- () => r(
658
- l(e),
659
- A(he(
660
- P((i) => w.getAttribute(t, i)),
661
- n ?? !1 ? O : U(l)
114
+ function qe() {
115
+ const e = F();
116
+ return j(e), g(() => ({
117
+ explain: (n, s) => v(s).with("decisions", (i) => e.explain(n, i)).with("constraints", (i) => e.explain(n, i)).with("full", (i) => e.explain(n, i)).exhaustive(),
118
+ applySolution: (n) => e.applySolution(n)
119
+ }), [e]);
120
+ }
121
+ function en(e, n = !1) {
122
+ const s = x();
123
+ return R(s), g(
124
+ () => m(
125
+ a.fromNullable(e),
126
+ a.map(ae(
127
+ l.map((i) => E.getAttribute(s, i)),
128
+ n ? l.filterMap(a.fromNullable) : le
662
129
  )),
663
- D(() => t.attributes)
130
+ a.getOrElse(() => s.attributes)
664
131
  ),
665
- [e, t, n]
132
+ [e, s, n]
666
133
  );
667
134
  }
668
- function mt(e) {
669
- const n = N(), { explainChoiceAttributeConsequence: t, explainChoiceAttributeConsequences: i, applySolution: o } = Vn(), { makeDecision: s, setManyDecision: a } = K();
670
- T(n);
671
- const c = w.getChoiceAttribute(n, e), u = m(() => ({
672
- explainConsequence: (p, x) => t(e, p, x),
673
- explainConsequences: (p) => i(e, p),
674
- makeDecision: (p, x) => s({
675
- type: f.Choice,
135
+ function nn(e) {
136
+ const n = x(), { makeDecision: s, setManyDecision: i } = N(), t = _(e, A.choiceValue);
137
+ R(n);
138
+ const o = E.getChoiceAttribute(n, e), u = g(() => ({
139
+ makeDecision: (r, p) => s({
140
+ type: S.Choice,
676
141
  attributeId: e,
677
- choiceValueId: p,
678
- state: x
142
+ choiceValueId: r,
143
+ state: p
679
144
  }),
680
- clearDecisions: r(
681
- c,
682
- l,
683
- A(He),
145
+ clearDecisions: m(
146
+ o,
147
+ a.fromNullable,
148
+ a.map(ne),
684
149
  // Only setMany if there are decisions to clear.
685
- R(Ae),
686
- A((p) => () => a(p, { type: "Default" })),
687
- D(() => () => Promise.resolve())
150
+ a.filter(l.isNonEmpty),
151
+ a.map((r) => () => i(r, { type: "Default" })),
152
+ a.getOrElse(() => () => Promise.resolve())
688
153
  ),
689
- applySolution: o
690
- }), [e, c, s, a, t, i, o]), d = m(() => ({
154
+ ...t
155
+ }), [e, o, s, i, t]), d = g(() => ({
691
156
  ...u,
692
- attribute: c
693
- }), [c, u]);
694
- if (c)
157
+ attribute: o
158
+ }), [o, u]);
159
+ if (o)
695
160
  return d;
696
161
  }
697
- function St(e) {
698
- const n = N(), { makeDecision: t } = K();
699
- T(n);
700
- const i = w.getNumericAttribute(n, e), o = m(() => ({
701
- makeDecision: (a) => t({
702
- type: f.Numeric,
162
+ function sn(e) {
163
+ const n = x(), { makeDecision: s } = N(), i = _(e, A.numeric);
164
+ R(n);
165
+ const t = E.getNumericAttribute(n, e), o = g(() => ({
166
+ makeDecision: (d) => s({
167
+ type: S.Numeric,
703
168
  attributeId: e,
704
- state: a
705
- })
706
- }), [e, t]), s = m(() => ({
169
+ state: d
170
+ }),
171
+ ...i
172
+ }), [e, s, i]), u = g(() => ({
707
173
  ...o,
708
- attribute: i
709
- }), [i, o]);
710
- if (i)
711
- return s;
712
- }
713
- function yt(e) {
714
- const n = N(), { makeDecision: t } = K();
715
- T(n);
716
- const i = w.getBooleanAttribute(n, e), o = m(() => ({
717
- makeDecision: (a) => t({
718
- type: f.Boolean,
174
+ attribute: t
175
+ }), [t, o]);
176
+ if (t)
177
+ return u;
178
+ }
179
+ function tn(e) {
180
+ const n = x(), { makeDecision: s } = N(), i = _(e, A.boolean);
181
+ R(n);
182
+ const t = E.getBooleanAttribute(n, e), o = g(() => ({
183
+ makeDecision: (d) => s({
184
+ type: S.Boolean,
719
185
  attributeId: e,
720
- state: a
721
- })
722
- }), [e, t]), s = m(() => ({
186
+ state: d
187
+ }),
188
+ ...i
189
+ }), [e, s, i]), u = g(() => ({
723
190
  ...o,
724
- attribute: i
725
- }), [i, o]);
726
- if (i)
727
- return s;
728
- }
729
- function vt(e) {
730
- const n = N(), { makeDecision: t, setManyDecision: i } = K();
731
- T(n);
732
- const o = n.attributes, s = w.getComponentAttribute(n, e), a = m(() => ({
733
- makeDecision: (u) => t({
734
- type: f.Component,
191
+ attribute: t
192
+ }), [t, o]);
193
+ if (t)
194
+ return u;
195
+ }
196
+ function on(e) {
197
+ const n = x(), { makeDecision: s, setManyDecision: i } = N(), t = _(e, A.component);
198
+ R(n);
199
+ const o = n.attributes, u = E.getComponentAttribute(n, e), d = g(() => ({
200
+ makeDecision: (p) => s({
201
+ type: S.Component,
735
202
  attributeId: e,
736
- state: u
203
+ state: p
737
204
  }),
738
- clearSubtree: r(
739
- Jn(e, o),
205
+ clearSubtree: m(
206
+ Pe(e, o),
740
207
  // Only setMany if there are decisions to clear.
741
- j(Ae),
742
- A((u) => () => i(u, { type: "Default" })),
743
- D(() => () => Promise.resolve())
744
- )
745
- }), [e, t, o, i]), c = m(() => ({
746
- ...a,
747
- attribute: s
748
- }), [s, a]);
749
- if (s)
750
- return c;
751
- }
752
- const Ln = E((e, n) => xe(g).equals(e ?? {}, n ?? {})), Zn = M({
753
- attributeId: E(le),
754
- decisions: H(E(le))
755
- }), et = E((e, n) => H(Zn).equals(e ?? [], n ?? [])), J = M({
756
- configurationModelSource: E((e, n) => ge(e, n)),
757
- attributeRelations: et,
758
- usageRuleParameters: Ln
759
- }), nt = ve, L = ee(nt), tt = () => ne({
208
+ a.fromPredicate(l.isNonEmpty),
209
+ a.map((p) => () => i(p, { type: "Default" })),
210
+ a.getOrElse(() => () => Promise.resolve())
211
+ ),
212
+ ...t
213
+ }), [e, s, o, i, t]), r = g(() => ({
214
+ ...d,
215
+ attribute: u
216
+ }), [u, d]);
217
+ if (u)
218
+ return r;
219
+ }
220
+ function _(e, n) {
221
+ const { explain: s, applySolution: i } = qe();
222
+ return g(() => ({
223
+ explain: (t, o) => {
224
+ const u = v(t.question).with(te.whyIsNotSatisfied, () => A.attribute).otherwise(() => n), d = {
225
+ ...t,
226
+ subject: u,
227
+ attributeId: e
228
+ };
229
+ return v(o).with("decisions", (r) => s(d, r)).with("constraints", (r) => s(d, r)).with("full", (r) => s(d, r)).exhaustive();
230
+ },
231
+ applySolution: i
232
+ }), [e, n, s, i]);
233
+ }
234
+ const G = c.fromEquals(oe), ve = c.fromEquals(re), we = c.fromEquals((e, n) => ue.getEq(U.Eq).equals(e ?? {}, n ?? {})), Me = c.struct({
235
+ attributeId: G,
236
+ decisions: l.getEq(G)
237
+ }), Ue = c.fromEquals((e, n) => l.getEq(Me).equals(e ?? [], n ?? [])), De = c.struct({
238
+ type: U.Eq
239
+ }), Ie = c.struct({
240
+ type: U.Eq
241
+ }), Ne = c.struct({
242
+ type: U.Eq,
243
+ rules: l.getEq(ve)
244
+ }), ke = c.fromEquals((e, n) => v({ x: e, y: n }).returnType().with({ x: { type: h.all }, y: { type: h.all } }, ({ x: s, y: i }) => De.equals(s, i)).with({ x: { type: h.none }, y: { type: h.none } }, ({ x: s, y: i }) => Ie.equals(s, i)).with({ x: { type: h.specific }, y: { type: h.specific } }, ({ x: s, y: i }) => Ne.equals(s, i)).otherwise(() => !1)), ze = c.struct({
245
+ rules: c.eqNullable(ke)
246
+ }), se = c.struct({
247
+ configurationModelSource: c.fromEquals((e, n) => Ce(e, n)),
248
+ attributeRelations: Ue,
249
+ usageRuleParameters: we,
250
+ allowedInExplain: c.eqNullable(ze)
251
+ }), O = c.eqNullable(se), _e = c.eqStrict, q = c.eqNullable(_e), Oe = () => T({
760
252
  predictableActionArguments: !0,
761
253
  preserveActionOrder: !0,
762
254
  schema: {
@@ -782,14 +274,14 @@ const Ln = E((e, n) => xe(g).equals(e ?? {}, n ?? {})), Zn = M({
782
274
  }
783
275
  },
784
276
  exit: [
785
- S("Shutting down", "SessionManagement:"),
277
+ C("Shutting down", "SessionManagement:"),
786
278
  "disposeOldSession"
787
279
  ],
788
280
  states: {
789
281
  ProcessChanges: {
790
282
  entry: [
791
- S("Entering ProcessChanges", "SessionManagement:"),
792
- I(
283
+ C("Entering ProcessChanges", "SessionManagement:"),
284
+ y(
793
285
  2
794
286
  /* Other */
795
287
  )
@@ -802,8 +294,8 @@ const Ln = E((e, n) => xe(g).equals(e ?? {}, n ?? {})), Zn = M({
802
294
  },
803
295
  DisposeSession: {
804
296
  entry: [
805
- S("Entering DisposeSession", "SessionManagement:"),
806
- I(
297
+ C("Entering DisposeSession", "SessionManagement:"),
298
+ y(
807
299
  2
808
300
  /* Other */
809
301
  )
@@ -815,8 +307,8 @@ const Ln = E((e, n) => xe(g).equals(e ?? {}, n ?? {})), Zn = M({
815
307
  },
816
308
  CreateSession: {
817
309
  entry: [
818
- S("Entering CreateSession", "SessionManagement:"),
819
- I(
310
+ C("Entering CreateSession", "SessionManagement:"),
311
+ y(
820
312
  0
821
313
  /* CreateSession */
822
314
  )
@@ -836,8 +328,8 @@ const Ln = E((e, n) => xe(g).equals(e ?? {}, n ?? {})), Zn = M({
836
328
  },
837
329
  SessionCreationFailed: {
838
330
  entry: [
839
- S("Entering SessionCreationFailed", "SessionManagement:"),
840
- I(
331
+ C("Entering SessionCreationFailed", "SessionManagement:"),
332
+ y(
841
333
  2
842
334
  /* Other */
843
335
  )
@@ -849,20 +341,20 @@ const Ln = E((e, n) => xe(g).equals(e ?? {}, n ?? {})), Zn = M({
849
341
  cond: "shallImmediatelyProcessChangesAfterSessionCreationError"
850
342
  },
851
343
  exit: [
852
- S("Exiting SessionCreationFailed", "SessionManagement:"),
344
+ C("Exiting SessionCreationFailed", "SessionManagement:"),
853
345
  "clearSessionCreationError"
854
346
  ],
855
347
  on: {
856
348
  RetrySessionCreation: {
857
349
  target: "ProcessChanges",
858
- actions: S("Retrying session creation", "SessionManagement:")
350
+ actions: C("Retrying session creation", "SessionManagement:")
859
351
  }
860
352
  }
861
353
  },
862
354
  UpdateSession: {
863
355
  entry: [
864
- S("Entering UpdateSession", "SessionManagement:"),
865
- I(
356
+ C("Entering UpdateSession", "SessionManagement:"),
357
+ y(
866
358
  1
867
359
  /* UpdateSession */
868
360
  )
@@ -881,8 +373,8 @@ const Ln = E((e, n) => xe(g).equals(e ?? {}, n ?? {})), Zn = M({
881
373
  },
882
374
  SessionUpdateFailed: {
883
375
  entry: [
884
- S("Entering SessionUpdateFailed", "SessionManagement:"),
885
- I(
376
+ C("Entering SessionUpdateFailed", "SessionManagement:"),
377
+ y(
886
378
  2
887
379
  /* Other */
888
380
  )
@@ -894,43 +386,43 @@ const Ln = E((e, n) => xe(g).equals(e ?? {}, n ?? {})), Zn = M({
894
386
  cond: "shallImmediatelyProcessChangesAfterSessionUpdateError"
895
387
  },
896
388
  exit: [
897
- S("Exiting SessionUpdateFailed", "SessionManagement:"),
389
+ C("Exiting SessionUpdateFailed", "SessionManagement:"),
898
390
  "clearSessionUpdateError"
899
391
  ],
900
392
  on: {
901
393
  RetrySessionUpdate: {
902
394
  target: "ProcessChanges",
903
- actions: S("Retrying session update", "SessionManagement:")
395
+ actions: C("Retrying session update", "SessionManagement:")
904
396
  }
905
397
  }
906
398
  }
907
399
  }
908
400
  }, {
909
401
  actions: {
910
- saveDesiredClient: C({
402
+ saveDesiredClient: f({
911
403
  desiredClient: (e, n) => n.client
912
404
  }),
913
- saveDesiredSessionContext: C({
405
+ saveDesiredSessionContext: f({
914
406
  desiredSessionContext: (e, n) => n.sessionContext
915
407
  }),
916
- disposeOldSession: C((e, n) => (e.session && e.session.close().then(Je).catch((t) => {
408
+ disposeOldSession: f((e, n) => (e.session && e.session.close().then(ce).catch((s) => {
917
409
  }), {
918
410
  session: null,
919
411
  actualClient: null
920
412
  })),
921
- setSessionCreationResult: C((e, n) => ({
413
+ setSessionCreationResult: f((e, n) => ({
922
414
  session: n.data.session,
923
415
  actualClient: n.data.client
924
416
  })),
925
- setSessionCreationError: C((e, n) => ({
417
+ setSessionCreationError: f((e, n) => ({
926
418
  sessionCreationError: n.data
927
419
  })),
928
- clearSessionCreationError: C({ sessionCreationError: () => null }),
929
- setSessionUpdateError: C((e, n) => ({
420
+ clearSessionCreationError: f({ sessionCreationError: () => null }),
421
+ setSessionUpdateError: f((e, n) => ({
930
422
  sessionUpdateError: n.data
931
423
  })),
932
- clearSessionUpdateError: C({ sessionUpdateError: () => null }),
933
- setHasEverSuccessfullyCreatedSession: C({
424
+ clearSessionUpdateError: f({ sessionUpdateError: () => null }),
425
+ setHasEverSuccessfullyCreatedSession: f({
934
426
  hasEverSuccessfullyCreatedSession: () => !0
935
427
  })
936
428
  },
@@ -939,60 +431,60 @@ const Ln = E((e, n) => xe(g).equals(e ?? {}, n ?? {})), Zn = M({
939
431
  session: n,
940
432
  client: e.desiredClient
941
433
  })).catch((n) => Promise.reject({
942
- type: n.type,
434
+ failureResult: n,
943
435
  client: e.desiredClient,
944
436
  sessionContext: e.desiredSessionContext
945
437
  })),
946
438
  updateSession: (e) => e.session.setSessionContext(e.desiredSessionContext).catch((n) => Promise.reject({
947
- type: n.type,
439
+ failureResult: n,
948
440
  sessionContext: e.desiredSessionContext
949
441
  }))
950
442
  },
951
443
  guards: {
952
- shallDisposeSession: (e) => e.session != null && (e.desiredSessionContext == null || e.desiredClient == null || !L.equals(e.actualClient, e.desiredClient)),
444
+ shallDisposeSession: (e) => e.session != null && (e.desiredSessionContext == null || e.desiredClient == null || !q.equals(e.actualClient, e.desiredClient)),
953
445
  shallCreateSession: (e) => e.session == null && e.desiredClient != null && e.desiredSessionContext != null,
954
- shallUpdateSession: (e) => e.session != null && !J.equals(e.session.getSessionContext(), e.desiredSessionContext),
446
+ shallUpdateSession: (e) => e.session != null && !se.equals(e.session.getSessionContext(), e.desiredSessionContext),
955
447
  shallImmediatelyProcessChangesAfterSessionCreationError: (e) => (
956
448
  // The desired client and the desired session context is not the same that resulted in the error.
957
- !L.equals(e.desiredClient, e.sessionCreationError.client) || !ee(J).equals(e.desiredSessionContext, e.sessionCreationError.sessionContext)
449
+ !q.equals(e.desiredClient, e.sessionCreationError.client) || !O.equals(e.desiredSessionContext, e.sessionCreationError.sessionContext)
958
450
  ),
959
451
  shallImmediatelyProcessChangesAfterSessionUpdateError: (e) => (
960
452
  // The desired client was changed
961
- !L.equals(e.desiredClient, e.actualClient) || !ee(J).equals(e.desiredSessionContext, e.sessionUpdateError.sessionContext)
453
+ !q.equals(e.desiredClient, e.actualClient) || !O.equals(e.desiredSessionContext, e.sessionUpdateError.sessionContext)
962
454
  )
963
455
  }
964
456
  });
965
- function I(e) {
966
- const n = e === 0, t = e === 1;
967
- return Ke((i, o) => {
968
- const s = {
457
+ function y(e) {
458
+ const n = e === 0, s = e === 1;
459
+ return pe((i, t) => {
460
+ const o = {
969
461
  isInitializing: (!i.hasEverSuccessfullyCreatedSession || n) && i.sessionCreationError == null,
970
- errorType: i.sessionCreationError && i.sessionCreationError.type
971
- }, a = {
972
- isUpdating: t && i.sessionUpdateError == null,
973
- errorType: i.sessionUpdateError && i.sessionUpdateError.type
462
+ failureResult: i.sessionCreationError && i.sessionCreationError.failureResult
463
+ }, u = {
464
+ isUpdating: s && i.sessionUpdateError == null,
465
+ failureResult: i.sessionUpdateError && i.sessionUpdateError.failureResult
974
466
  };
975
- return de({
467
+ return W({
976
468
  type: "SessionManagementStateChanged",
977
- sessionInitialization: s,
978
- sessionUpdating: a,
469
+ sessionInitialization: o,
470
+ sessionUpdating: u,
979
471
  session: i.session
980
472
  });
981
473
  });
982
474
  }
983
- const it = (e) => (n) => (n({
475
+ const Te = (e) => (n) => (n({
984
476
  type: "ConfigurationChanged",
985
477
  session: e,
986
478
  configuration: e.getConfiguration()
987
- }), e.setOnConfigurationChangedHandler((t) => {
479
+ }), e.setOnConfigurationChangedHandler((s) => {
988
480
  n({
989
481
  type: "ConfigurationChanged",
990
482
  session: e,
991
- configuration: t
483
+ configuration: s
992
484
  });
993
485
  }), () => {
994
486
  e.setOnConfigurationChangedHandler(null);
995
- }), ot = () => ne({
487
+ }), Fe = () => T({
996
488
  predictableActionArguments: !0,
997
489
  preserveActionOrder: !0,
998
490
  schema: {
@@ -1006,7 +498,7 @@ const it = (e) => (n) => (n({
1006
498
  // Forward the configuration data to the parent.
1007
499
  ConfigurationChanged: {
1008
500
  actions: [
1009
- de((e, n) => n)
501
+ W((e, n) => n)
1010
502
  ]
1011
503
  }
1012
504
  },
@@ -1014,7 +506,7 @@ const it = (e) => (n) => (n({
1014
506
  states: {
1015
507
  ProcessChanges: {
1016
508
  entry: [
1017
- S("Entering ProcessChanges", "ConfigurationSubscriptionManagement:")
509
+ C("Entering ProcessChanges", "ConfigurationSubscriptionManagement:")
1018
510
  ],
1019
511
  on: {
1020
512
  ChangeSession: {
@@ -1032,7 +524,7 @@ const it = (e) => (n) => (n({
1032
524
  },
1033
525
  Subscribe: {
1034
526
  entry: [
1035
- S("Entering Subscribe", "ConfigurationSubscriptionManagement:")
527
+ C("Entering Subscribe", "ConfigurationSubscriptionManagement:")
1036
528
  ],
1037
529
  on: {
1038
530
  ChangeSession: {
@@ -1045,33 +537,40 @@ const it = (e) => (n) => (n({
1045
537
  },
1046
538
  invoke: {
1047
539
  id: "configurationSubscriptionActor",
1048
- src: (e, n) => it(e.session)
540
+ src: (e, n) => Te(e.session)
1049
541
  }
1050
542
  }
1051
543
  }
1052
544
  }, {
1053
545
  actions: {
1054
- saveSession: C((e, n) => ({
546
+ saveSession: f((e, n) => ({
1055
547
  session: n.session
1056
548
  }))
1057
549
  }
1058
- }), st = () => {
550
+ }), je = () => {
1059
551
  let e, n;
1060
552
  return {
1061
- promise: new Promise((i, o) => {
1062
- e = i, n = o;
553
+ promise: new Promise((i, t) => {
554
+ e = i, n = t;
1063
555
  }),
1064
556
  resolve: e,
1065
557
  reject: n
1066
558
  };
1067
- }, fe = () => {
1068
- const e = st();
559
+ }, J = () => {
560
+ const e = je();
1069
561
  return {
1070
562
  capsule: { promise: e.promise },
1071
563
  resolve: e.resolve,
1072
564
  reject: e.reject
1073
565
  };
1074
- }, rt = () => ne({
566
+ };
567
+ var Be = function(e, n, s) {
568
+ var i = V(), t = V(0);
569
+ 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];
570
+ }, L = function(e, n, s, i) {
571
+ return de(e, Be(n, s, i));
572
+ };
573
+ const He = () => T({
1075
574
  predictableActionArguments: !0,
1076
575
  preserveActionOrder: !0,
1077
576
  schema: {
@@ -1085,50 +584,50 @@ const it = (e) => (n) => (n({
1085
584
  sessionUpdating: null,
1086
585
  session: null,
1087
586
  configuration: null,
1088
- isReadyPromise: fe()
587
+ isReadyPromise: J()
1089
588
  },
1090
589
  entry: [
1091
- C({
1092
- sessionManagementActor: () => ae(tt()),
1093
- configurationSubscriptionManagementActor: () => ae(ot())
590
+ f({
591
+ sessionManagementActor: () => Q(Oe()),
592
+ configurationSubscriptionManagementActor: () => Q(Fe())
1094
593
  })
1095
594
  ],
1096
595
  exit: [
1097
- ue((e) => e.sessionManagementActor),
1098
- ue((e) => e.configurationSubscriptionManagementActor)
596
+ K((e) => e.sessionManagementActor),
597
+ K((e) => e.configurationSubscriptionManagementActor)
1099
598
  ],
1100
599
  on: {
1101
600
  // Forward events for sessionManagement
1102
601
  ChangeConfigurationClient: {
1103
602
  actions: [
1104
- F((e) => e.sessionManagementActor)
603
+ P((e) => e.sessionManagementActor)
1105
604
  ]
1106
605
  },
1107
606
  ChangeSessionContext: {
1108
607
  actions: [
1109
- F((e) => e.sessionManagementActor)
608
+ P((e) => e.sessionManagementActor)
1110
609
  ]
1111
610
  },
1112
611
  RetrySessionCreation: {
1113
612
  actions: [
1114
- F((e) => e.sessionManagementActor)
613
+ P((e) => e.sessionManagementActor)
1115
614
  ]
1116
615
  },
1117
616
  RetrySessionUpdate: {
1118
617
  actions: [
1119
- F((e) => e.sessionManagementActor)
618
+ P((e) => e.sessionManagementActor)
1120
619
  ]
1121
620
  },
1122
621
  SessionManagementStateChanged: {
1123
622
  actions: [
1124
623
  // Assign the received data
1125
- C((e, n) => ({
624
+ f((e, n) => ({
1126
625
  session: n.session,
1127
626
  sessionInitialization: n.sessionInitialization,
1128
627
  sessionUpdating: n.sessionUpdating
1129
628
  })),
1130
629
  // Forward the session to the configuration subscription
1131
- Ge((e) => ({
630
+ fe((e) => ({
1132
631
  type: "ChangeSession",
1133
632
  session: e.session
1134
633
  }), { to: (e) => e.configurationSubscriptionManagementActor }),
@@ -1137,7 +636,7 @@ const it = (e) => (n) => (n({
1137
636
  },
1138
637
  ConfigurationChanged: {
1139
638
  actions: [
1140
- C((e, n) => ({
639
+ f((e, n) => ({
1141
640
  configuration: {
1142
641
  session: n.session,
1143
642
  configuration: n.configuration
@@ -1153,106 +652,106 @@ const it = (e) => (n) => (n({
1153
652
  }
1154
653
  }, {
1155
654
  actions: {
1156
- calculateReadyState: C((e, n) => {
1157
- var o;
1158
- const t = !((o = e.sessionInitialization) != null && o.isInitializing) && e.session != null && e.configuration != null && e.configuration.session === e.session;
1159
- return e.isReadyPromise && t && (e.isReadyPromise.resolve(), e.isReadyPromise.capsule.promise = null), {
1160
- isReadyPromise: (() => t ? null : e.isReadyPromise != null ? e.isReadyPromise : fe())()
655
+ calculateReadyState: f((e, n) => {
656
+ var t;
657
+ const s = !((t = e.sessionInitialization) != null && t.isInitializing) && e.session != null && e.configuration != null && e.configuration.session === e.session;
658
+ return e.isReadyPromise && s && (e.isReadyPromise.resolve(), e.isReadyPromise.capsule.promise = null), {
659
+ isReadyPromise: (() => s ? null : e.isReadyPromise != null ? e.isReadyPromise : J())()
1161
660
  };
1162
661
  })
1163
662
  }
1164
663
  });
1165
- function at(e) {
1166
- var a, c;
1167
- const [n, t] = Qe(rt, {
1168
- logger: (...u) => console.log("ConfigurationManagement:", ...u)
664
+ function Ve(e) {
665
+ var u, d;
666
+ const [n, s] = me(He, {
667
+ logger: (...r) => console.log("ConfigurationManagement:", ...r)
1169
668
  });
1170
- re(() => {
1171
- t({
669
+ L(() => {
670
+ s({
1172
671
  type: "ChangeConfigurationClient",
1173
672
  client: e.configuratorClient
1174
673
  }), 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.");
1175
- }, [e.configuratorClient]), re(() => {
1176
- const u = r(
1177
- l(e.sessionContext),
1178
- dn((d) => l(d.configurationModelSource)),
1179
- V
674
+ }, [e.configuratorClient], c.tuple(q)), L(() => {
675
+ const r = m(
676
+ a.fromNullable(e.sessionContext),
677
+ a.chainFirst((p) => a.fromNullable(p.configurationModelSource)),
678
+ a.toNullable
1180
679
  );
1181
- t({
680
+ s({
1182
681
  type: "ChangeSessionContext",
1183
- sessionContext: u
1184
- }), u || 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.");
1185
- }, [e.sessionContext]);
1186
- const i = m(
682
+ sessionContext: r
683
+ }), 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.");
684
+ }, [e.sessionContext], c.tuple(O));
685
+ const i = g(
1187
686
  () => {
1188
- var u, d, p, x;
687
+ var r, p, B, H;
1189
688
  return {
1190
- isInitializing: ((d = (u = n.context.isReadyPromise) == null ? void 0 : u.capsule) == null ? void 0 : d.promise) != null,
1191
- isInitializingPromise: (p = n.context.isReadyPromise) == null ? void 0 : p.capsule,
1192
- error: ((x = n.context.sessionInitialization) == null ? void 0 : x.errorType) && {
1193
- type: n.context.sessionInitialization.errorType,
1194
- retry: () => t({ type: "RetrySessionCreation" })
689
+ isInitializing: ((p = (r = n.context.isReadyPromise) == null ? void 0 : r.capsule) == null ? void 0 : p.promise) != null,
690
+ isInitializingPromise: (B = n.context.isReadyPromise) == null ? void 0 : B.capsule,
691
+ error: ((H = n.context.sessionInitialization) == null ? void 0 : H.failureResult) && {
692
+ ...n.context.sessionInitialization.failureResult,
693
+ retry: () => s({ type: "RetrySessionCreation" })
1195
694
  }
1196
695
  };
1197
696
  },
1198
697
  [n.context.sessionInitialization, n.context.isReadyPromise]
1199
- ), o = m(
698
+ ), t = g(
1200
699
  () => {
1201
- var u, d;
700
+ var r, p;
1202
701
  return {
1203
- isUpdating: (u = n.context.sessionUpdating) == null ? void 0 : u.isUpdating,
1204
- error: ((d = n.context.sessionUpdating) == null ? void 0 : d.errorType) && {
1205
- type: n.context.sessionUpdating.errorType,
1206
- retry: () => t({ type: "RetrySessionUpdate" })
702
+ isUpdating: (r = n.context.sessionUpdating) == null ? void 0 : r.isUpdating,
703
+ error: ((p = n.context.sessionUpdating) == null ? void 0 : p.failureResult) && {
704
+ ...n.context.sessionUpdating.failureResult,
705
+ retry: () => s({ type: "RetrySessionUpdate" })
1207
706
  }
1208
707
  };
1209
708
  },
1210
709
  [n.context.sessionUpdating]
1211
- ), s = ((a = n.context.configuration) == null ? void 0 : a.session) === n.context.session ? (c = n.context.configuration) == null ? void 0 : c.configuration : null;
710
+ ), o = ((u = n.context.configuration) == null ? void 0 : u.session) === n.context.session ? (d = n.context.configuration) == null ? void 0 : d.configuration : null;
1212
711
  return {
1213
712
  configurationInitialization: i,
1214
- configurationUpdating: o,
713
+ configurationUpdating: t,
1215
714
  session: n.context.session,
1216
- configuration: s
715
+ configuration: o
1217
716
  };
1218
717
  }
1219
- function Et(e) {
1220
- const { configurationInitialization: n, configurationUpdating: t, session: i, configuration: o } = at({
1221
- configuratorClient: e.configuratorClient,
1222
- sessionContext: e
718
+ function rn(e) {
719
+ const { configuratorClient: n, ...s } = e, { configurationInitialization: i, configurationUpdating: t, session: o, configuration: u } = Ve({
720
+ configuratorClient: n,
721
+ sessionContext: s
1223
722
  });
1224
- return /* @__PURE__ */ k($e.Provider, { value: n, children: /* @__PURE__ */ k(Be.Provider, { value: t, children: /* @__PURE__ */ k(Fe.Provider, { value: i, children: /* @__PURE__ */ k(je.Provider, { value: o, children: e.children }) }) }) });
723
+ return /* @__PURE__ */ b(Y.Provider, { value: i, children: /* @__PURE__ */ b(Z.Provider, { value: t, children: /* @__PURE__ */ b(X.Provider, { value: o, children: /* @__PURE__ */ b($.Provider, { value: u, children: e.children }) }) }) });
1225
724
  }
1226
- function ut() {
1227
- return B($e);
725
+ function Qe() {
726
+ return I(Y);
1228
727
  }
1229
- function At() {
1230
- return B(Be);
728
+ function an() {
729
+ return I(Z);
1231
730
  }
1232
- function Pt(e) {
1233
- const { children: n } = e, { isInitializingPromise: t } = ut();
1234
- if (t != null && t.promise)
1235
- throw t.promise;
1236
- return /* @__PURE__ */ k(We, { children: n });
731
+ function ln(e) {
732
+ const { children: n } = e, { isInitializingPromise: s } = Qe();
733
+ if (s != null && s.promise)
734
+ throw s.promise;
735
+ return /* @__PURE__ */ b(ge, { children: n });
1237
736
  }
1238
- function Mt() {
1239
- const e = oe(), n = N();
1240
- return se(e), T(n), m(() => ({
737
+ function un() {
738
+ const e = F(), n = x();
739
+ return j(e), R(n), g(() => ({
1241
740
  configuration: n,
1242
- restoreConfiguration: (t) => e.restoreConfiguration(t)
741
+ restoreConfiguration: (s) => e.restoreConfiguration(s)
1243
742
  }), [n, e]);
1244
743
  }
1245
744
  export {
1246
- Et as Configuration,
1247
- Pt as ConfigurationSuspender,
1248
- ht as useAttributes,
1249
- yt as useBooleanAttribute,
1250
- mt as useChoiceAttribute,
1251
- vt as useComponentAttribute,
1252
- Mt as useConfiguration,
1253
- ut as useConfigurationInitialization,
1254
- At as useConfigurationUpdating,
1255
- K as useDecision,
1256
- Vn as useExplain,
1257
- St as useNumericAttribute
745
+ rn as Configuration,
746
+ ln as ConfigurationSuspender,
747
+ en as useAttributes,
748
+ tn as useBooleanAttribute,
749
+ nn as useChoiceAttribute,
750
+ on as useComponentAttribute,
751
+ un as useConfiguration,
752
+ Qe as useConfigurationInitialization,
753
+ an as useConfigurationUpdating,
754
+ N as useDecision,
755
+ qe as useExplain,
756
+ sn as useNumericAttribute
1258
757
  };