@kosdev-code/kos-dispense-sdk 2.1.3 → 2.1.5

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.
@@ -1,1547 +0,0 @@
1
- var bt = Object.defineProperty;
2
- var vt = (e, t, s) => t in e ? bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var O = (e, t, s) => (vt(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- import { jsx as m } from "@emotion/react/jsx-runtime";
5
- import { A as Se, b as Ce, e as wt, d as Ne, N as $t, f as _e, H as gt, g as Ke, I as Me, h as He, G as Pt, P as Le } from "./dispense-registration-manager-pB5e_YT1.js";
6
- import { useKosModel as k, getKosCompanionModel as Te, kosAutoEffect as Ue, KosLog as T, usePressGesture as xe, EventBus as g, TimerManager as Ye } from "@kosdev-code/kos-ui-sdk";
7
- import It, { createContext as N, useMemo as R, useContext as S, useState as A, useCallback as u, useEffect as j, useRef as Fe } from "react";
8
- import { z as V } from "zod";
9
- const Ve = () => {
10
- const e = Se.type;
11
- return k({
12
- modelId: e,
13
- modelType: Se.type,
14
- options: {}
15
- });
16
- };
17
- function ls(e) {
18
- return (t) => {
19
- const { model: s, status: n, KosModelLoader: r } = Ve();
20
- return /* @__PURE__ */ m(r, { ...n, children: /* @__PURE__ */ m(e, { ...t, assembly: s }) });
21
- };
22
- }
23
- const Ge = () => {
24
- const e = Ce.type;
25
- return k({
26
- modelId: e,
27
- modelType: Ce.type,
28
- options: {}
29
- });
30
- };
31
- function ps(e) {
32
- return (t) => {
33
- const { model: s, status: n, KosModelLoader: r } = Ge();
34
- return /* @__PURE__ */ m(r, { ...n, children: /* @__PURE__ */ m(e, { ...t, beverage: s }) });
35
- };
36
- }
37
- const qe = (e) => k({
38
- modelId: e,
39
- modelType: wt.type,
40
- options: {}
41
- });
42
- function fs(e) {
43
- return (t) => (s) => {
44
- const { model: n, status: r, KosModelLoader: i } = qe(t);
45
- return /* @__PURE__ */ m(i, { ...r, children: /* @__PURE__ */ m(e, { ...s, board: n }) });
46
- };
47
- }
48
- const We = () => {
49
- const e = Ne.type;
50
- return k({
51
- modelId: e,
52
- modelType: Ne.type,
53
- options: {}
54
- });
55
- };
56
- function ms(e) {
57
- return (t) => {
58
- const { model: s, status: n, KosModelLoader: r } = We();
59
- return /* @__PURE__ */ m(r, { ...n, children: /* @__PURE__ */ m(e, { ...t, boardContainer: s }) });
60
- };
61
- }
62
- const Xe = (e) => k({
63
- modelId: e,
64
- modelType: $t.type,
65
- options: {
66
- path: e
67
- }
68
- }), Ze = N(void 0), Tt = ({ children: e, path: t }) => {
69
- const { model: s, ready: n } = Xe(t), r = R(() => n && s ? { model: s } : {}, [n, s]);
70
- return /* @__PURE__ */ m(Ze.Provider, { value: r, children: e });
71
- }, L = () => {
72
- const e = S(Ze);
73
- if (!e)
74
- throw new Error("useNozzleContext must be used within a NozzleProvider");
75
- return e;
76
- }, xt = ({
77
- onBeverageSelected: e,
78
- onClearBeverage: t,
79
- companionType: s
80
- }) => {
81
- const { model: n } = L(), [r, i] = A([]), [o, c] = A(null), p = R(() => s ? r.map(
82
- (l) => Te(l, s)
83
- ) : [], [r, s]), f = u(
84
- async (l) => {
85
- c(l), await (n == null ? void 0 : n.setSelectedPourable({ beverage: l })), e == null || e(l);
86
- },
87
- [n, e]
88
- ), d = u(async () => {
89
- c(null), await (n == null ? void 0 : n.setSelectedPourable({ beverage: void 0 })), t == null || t();
90
- }, [n, t]);
91
- return j(() => {
92
- const l = Ue(() => {
93
- if (!n)
94
- return;
95
- const w = n.selectedBrand;
96
- if (!w) {
97
- const b = n.getGroupAvailabilityItems("beverages").filter((v) => v.visible);
98
- i(b ?? []);
99
- return;
100
- }
101
- const $ = n.getAvailabilityByParent(w.id).filter((b) => b.visible);
102
- i($ ?? []);
103
- });
104
- return () => {
105
- l();
106
- };
107
- }, [n]), {
108
- beverages: r,
109
- beverageCompanions: p,
110
- selectBeverage: f,
111
- selectedBeverage: o,
112
- clearBeverage: d
113
- };
114
- }, Rt = ({
115
- onBrandSelected: e,
116
- onBrandCleared: t,
117
- companionType: s
118
- }) => {
119
- const { model: n } = L(), [r, i] = A(null), [o, c] = A([]), p = R(() => s ? o.map((l) => Te(l, s)) : [], [o, s]), f = u(
120
- async (l) => {
121
- i(l), n == null || n.setSelectedBrand(l), e == null || e(l);
122
- },
123
- [n, e]
124
- ), d = u(() => {
125
- i(null), n == null || n.setSelectedBrand(void 0), t == null || t();
126
- }, [n, t]);
127
- return j(() => {
128
- const l = Ue(() => {
129
- n && c(n.visibleBrands);
130
- });
131
- return () => {
132
- l();
133
- };
134
- }, [n]), {
135
- brands: o,
136
- brandCompanions: p,
137
- selectedBrand: r,
138
- selectBrand: f,
139
- clearBrand: d
140
- };
141
- }, Et = T.createLogger({
142
- name: "HoldToPourStrategy",
143
- group: "kos-hooks"
144
- }), Je = {
145
- name: "HoldToPourStrategy",
146
- async initiate(e) {
147
- if (!(e != null && e.canPour)) {
148
- Et.debug(`Nozzle ${e == null ? void 0 : e.id} cannot pour. Returning early.`);
149
- return;
150
- }
151
- await (e == null ? void 0 : e.pour());
152
- },
153
- async initiateEnded(e) {
154
- await (e == null ? void 0 : e.cancelPour());
155
- }
156
- }, ie = T.createLogger({
157
- name: "useNozzlePour",
158
- group: "kos-hooks"
159
- }), yt = ({
160
- onPour: e,
161
- onPourCancel: t,
162
- onBeforePour: s,
163
- onBeforePourRejected: n,
164
- strategy: r = Je
165
- }) => {
166
- const { model: i } = L(), o = u(async () => {
167
- (s ? await (s == null ? void 0 : s()) : !0) ? (ie.debug(
168
- `[${r == null ? void 0 : r.name}] - Pour initiated for nozzle ${i == null ? void 0 : i.id}.`
169
- ), r == null || r.initiate(i), e == null || e()) : (ie.debug(
170
- `[${r == null ? void 0 : r.name}] - Did not pass onBeforePour gate for nozzle ${i == null ? void 0 : i.id}. Cancelling pour.`
171
- ), n == null || n());
172
- }, [e, i, r, s, t]), c = u(() => {
173
- var d;
174
- ie.debug(
175
- `[${r == null ? void 0 : r.name}] - Pour initiate ended called for nozzle ${i == null ? void 0 : i.id}.`
176
- ), (d = r == null ? void 0 : r.initiateEnded) == null || d.call(r, i), t == null || t();
177
- }, [t, i, r]), p = u(() => {
178
- ie.debug(`Force cancelling pour for nozzle ${i == null ? void 0 : i.id}.`), i == null || i.cancelPour(), t == null || t();
179
- }, [t, i]);
180
- return {
181
- handlers: xe({
182
- onPressed: o,
183
- onRelease: c
184
- }).dom,
185
- cancel: p,
186
- status: i
187
- };
188
- }, At = ({
189
- onFlavorSelected: e,
190
- onFlavorCleared: t,
191
- companionType: s
192
- }) => {
193
- const { model: n } = L(), r = R(
194
- () => (n == null ? void 0 : n.getGroupAvailabilityItems("flavors").filter((d) => d.visible)) ?? [],
195
- [n]
196
- ), i = R(() => s ? r.map(
197
- (d) => Te(d, s)
198
- ) : [], [r, s]), [o, c] = A([]), p = u(
199
- async (d) => {
200
- if (c(
201
- (l) => l != null && l.includes(d) ? [...l.filter((w) => w !== d)] : [...l ?? [], d]
202
- ), n != null && n.selectedPourable) {
203
- const { beverage: l } = n.selectedPourable;
204
- await n.setSelectedPourable({
205
- beverage: l,
206
- additional: o ?? []
207
- });
208
- }
209
- e == null || e(d, o ?? []);
210
- },
211
- [n, e, o]
212
- ), f = u(async () => {
213
- if (c([]), n != null && n.selectedPourable) {
214
- const { beverage: d } = n.selectedPourable;
215
- n.setSelectedPourable({ beverage: d }), t == null || t();
216
- }
217
- }, [n, t]);
218
- return {
219
- flavors: r,
220
- flavorCompanions: i,
221
- selectFlavor: p,
222
- selectedFlavors: o,
223
- clearFlavors: f
224
- };
225
- }, Q = "brands", oe = "beverages", z = "flavors", B = T.createLogger({ name: "use-cui-kit" }), kt = ({
226
- initialGroup: e = Q,
227
- options: t = {}
228
- }) => {
229
- var se, re, ne;
230
- const [s, n] = A(e), { model: r } = L(), i = Fe([]), o = u(
231
- (h) => {
232
- n(z);
233
- const M = `/kos/dispense/${r == null ? void 0 : r.path}/brand/selected/`;
234
- g.publish(M, h);
235
- },
236
- [r == null ? void 0 : r.path]
237
- ), c = u(() => {
238
- const h = `/kos/dispense/${r == null ? void 0 : r.path}/brand/cleared/`;
239
- g.publish(h, {});
240
- }, [r == null ? void 0 : r.path]), p = u(
241
- (h) => {
242
- n(z);
243
- const M = `/kos/dispense/${r == null ? void 0 : r.path}/beverage/selected/`;
244
- g.publish(M, h);
245
- },
246
- [r == null ? void 0 : r.path]
247
- ), f = u(() => {
248
- const h = `/kos/dispense/${r == null ? void 0 : r.path}/beverage/cleared/`;
249
- g.publish(h, {});
250
- }, [r == null ? void 0 : r.path]), d = u(
251
- (h) => {
252
- const M = `/kos/dispense/${r == null ? void 0 : r.path}/flavor/selected/`;
253
- g.publish(M, h);
254
- },
255
- [r == null ? void 0 : r.path]
256
- ), l = u(() => {
257
- const h = `/kos/dispense/${r == null ? void 0 : r.path}/flavor/cleared/`;
258
- g.publish(h, {});
259
- }, [r == null ? void 0 : r.path]), w = u(() => {
260
- const h = `/kos/dispense/${r == null ? void 0 : r.path}/pour/`;
261
- g.publish(h, {});
262
- }, [r == null ? void 0 : r.path]), $ = u(async () => {
263
- const h = `/kos/dispense/${r == null ? void 0 : r.path}/pre/pour/`;
264
- return g.publish(h, {}), await (D == null ? void 0 : D()) || !0;
265
- }, [r == null ? void 0 : r.path]), b = u(async () => {
266
- const h = `/kos/dispense/${r == null ? void 0 : r.path}/pre/pour/rejected/`;
267
- g.publish(h, {});
268
- }, [r == null ? void 0 : r.path]), v = u(() => {
269
- const h = `/kos/dispense/${r == null ? void 0 : r.path}/pour/cancel/`;
270
- g.publish(h, {});
271
- }, [r == null ? void 0 : r.path]), { brands: a, selectBrand: G, selectedBrand: _, clearBrand: P, brandCompanions: Z } = Rt({
272
- companionType: (se = t.companionTypes) == null ? void 0 : se.brand,
273
- onBrandSelected: o,
274
- onBrandCleared: c
275
- }), {
276
- beverages: de,
277
- selectBeverage: ue,
278
- selectedBeverage: le,
279
- clearBeverage: I,
280
- beverageCompanions: K
281
- } = xt({
282
- companionType: (re = t.companionTypes) == null ? void 0 : re.beverage,
283
- onBeverageSelected: p,
284
- onClearBeverage: f
285
- }), {
286
- clearFlavors: J,
287
- flavors: pe,
288
- selectFlavor: q,
289
- selectedFlavors: x,
290
- flavorCompanions: C
291
- } = At({
292
- companionType: (ne = t.companionTypes) == null ? void 0 : ne.flavor,
293
- onFlavorSelected: d,
294
- onFlavorCleared: l
295
- }), [D, E] = A(), Y = u((h) => {
296
- E(() => h);
297
- }, []), W = yt({
298
- onPour: w,
299
- onPourCancel: v,
300
- onBeforePour: $,
301
- onBeforePourRejected: b
302
- }), X = u(() => {
303
- switch (B.debug(`Navigating back from group: ${s}`), s) {
304
- case Q:
305
- I(), P();
306
- break;
307
- case oe:
308
- case z:
309
- n(e), I(), P();
310
- break;
311
- }
312
- }, [I, P, s, e]), fe = u(() => {
313
- const h = `/kos/dispense/${r == null ? void 0 : r.path}/home/`;
314
- g.publish(h, {}), n(e), e === Q && (I(), P()), e === oe && I();
315
- }, [I, P, e]), me = u(() => {
316
- if (i.current.length === 0) {
317
- B.debug("No timers to pause.");
318
- return;
319
- }
320
- B.debug(`Pausing ${i.current.length} timers.`), i.current.forEach((h) => {
321
- B.debug(`Pausing timer with id ${h.id}.`), h.pause();
322
- });
323
- }, []), he = u(() => {
324
- if (i.current.length === 0) {
325
- B.debug("No timers to restart.");
326
- return;
327
- }
328
- B.debug(`Restarting ${i.current.length} timers.`), i.current.forEach((h) => {
329
- B.debug(`Restarting timer with id ${h.id}.`), h.restart();
330
- });
331
- }, []);
332
- return {
333
- timers: {
334
- add: u((h) => {
335
- if (h) {
336
- if (i.current.some((M) => M.id === h.id)) {
337
- B.debug(`Timer with id ${h.id} already exists.`);
338
- return;
339
- }
340
- i.current.push(h);
341
- }
342
- }, []),
343
- pause: me,
344
- restart: he
345
- },
346
- nav: {
347
- currentGroup: s,
348
- back: X,
349
- home: fe
350
- },
351
- pour: W,
352
- updateOnBeforePour: Y,
353
- selections: {
354
- [Q]: _,
355
- [oe]: le,
356
- [z]: x
357
- },
358
- [Q]: {
359
- models: a,
360
- companions: Z,
361
- clear: P,
362
- handlers: {
363
- onSelected: G
364
- }
365
- },
366
- [oe]: {
367
- models: de,
368
- companions: K,
369
- clear: I,
370
- handlers: {
371
- onSelected: ue
372
- }
373
- },
374
- [z]: {
375
- models: pe,
376
- companions: C,
377
- clear: J,
378
- handlers: {
379
- onSelected: q
380
- }
381
- }
382
- };
383
- }, St = (e) => {
384
- const { model: t } = L(), [s, n] = A(null), {
385
- onAmbientTimer: r,
386
- onAttractTimer: i,
387
- onResetAttractTimer: o,
388
- onResumeAttractTimer: c,
389
- defaultAttractTime: p,
390
- defaultAmbientTime: f
391
- } = e, d = u(() => {
392
- r && (T.info("Ambient timer expired. Calling callback"), r == null || r());
393
- }, [r]), l = u(() => {
394
- i && (T.info("Attract timer expired. Calling callback"), i == null || i());
395
- }, [i]), w = u(() => {
396
- s && (s.restart(), o == null || o());
397
- }, [s, o]), $ = u(() => {
398
- s && (s.reset(), o == null || o());
399
- }, [s, o]), b = u(() => {
400
- s && (s.pause(), c == null || c());
401
- }, [s, c]);
402
- return j(() => {
403
- if (t && p) {
404
- T.info("Nozzle is available. Creating timers");
405
- const v = Ye.createTimer(
406
- "attract-timer-" + t.path,
407
- p
408
- );
409
- return p && (v == null || v.addTimeoutAction({
410
- name: "attract-timer",
411
- remainingTime: 0,
412
- action: l
413
- })), f && (v == null || v.addTimeoutAction({
414
- name: "ambient-timer",
415
- remainingTime: f,
416
- action: d
417
- })), p && (v == null || v.start()), n(v ?? null), () => {
418
- v == null || v.reset(), n(null);
419
- };
420
- }
421
- return () => {
422
- T.info("Nozzle is not available. No timers to clear");
423
- };
424
- }, [
425
- f,
426
- p,
427
- d,
428
- l,
429
- t
430
- ]), {
431
- attractTimer: s,
432
- restart: w,
433
- pause: $,
434
- resume: b
435
- };
436
- }, Ct = (e, t) => {
437
- if (t)
438
- return g.subscribe(e, t).unsubscribe;
439
- }, Nt = ({
440
- onInit: e,
441
- onBrandSelected: t,
442
- onBrandCleared: s,
443
- onBeverageCleared: n,
444
- onBeverageSelected: r,
445
- onFlavorCleared: i,
446
- onFlavorSelected: o,
447
- onReturnToHome: c,
448
- onPour: p,
449
- onPourCancel: f,
450
- onBeforePourRejected: d,
451
- onAmbientTimer: l,
452
- onAttractTimer: w,
453
- onResumeAttractTimer: $,
454
- onIdleTimeout: b,
455
- onAreYouThereTimeout: v
456
- }) => {
457
- const { model: a } = L();
458
- j(() => {
459
- const _ = [
460
- {
461
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/brand/selected/`,
462
- callback: t
463
- },
464
- {
465
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/brand/cleared/`,
466
- callback: s
467
- },
468
- {
469
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/beverage/selected/`,
470
- callback: r
471
- },
472
- {
473
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/beverage/cleared/`,
474
- callback: n
475
- },
476
- {
477
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/flavor/selected/`,
478
- callback: o
479
- },
480
- {
481
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/flavor/cleared/`,
482
- callback: i
483
- },
484
- { topic: `/kos/dispense/${a == null ? void 0 : a.path}/pour/`, callback: p },
485
- {
486
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/pour/cancel/`,
487
- callback: f
488
- },
489
- {
490
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/pre/pour/rejected/`,
491
- callback: d
492
- },
493
- {
494
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/ambient/start/`,
495
- callback: l
496
- },
497
- {
498
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/attract/start/`,
499
- callback: w
500
- },
501
- {
502
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/attract/resume/`,
503
- callback: $
504
- },
505
- {
506
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/idle/timeout/`,
507
- callback: b
508
- },
509
- {
510
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/are-you-there/timeout/`,
511
- callback: v
512
- },
513
- {
514
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/init/`,
515
- callback: e
516
- },
517
- {
518
- topic: `/kos/dispense/${a == null ? void 0 : a.path}/home/`,
519
- callback: c
520
- }
521
- ].map(
522
- ({ topic: P, callback: Z }) => Ct(P, Z)
523
- );
524
- return () => {
525
- _.forEach((P) => P == null ? void 0 : P());
526
- };
527
- }, [
528
- a == null ? void 0 : a.path,
529
- l,
530
- w,
531
- n,
532
- r,
533
- s,
534
- t,
535
- i,
536
- o,
537
- p,
538
- f,
539
- $,
540
- b,
541
- v,
542
- e,
543
- c
544
- ]);
545
- }, H = T.createLogger({ name: "useCuiKitTimers" }), De = (e) => {
546
- const { model: t } = L(), [s, n] = A(null), {
547
- onAreYouThereTimer: r,
548
- onIdleTimer: i,
549
- onResetIdleTimer: o,
550
- defaultAreYouThereTime: c = 10,
551
- defaultIdleTime: p = 20
552
- } = e, f = Fe(!1), d = u(() => {
553
- !f.current && r && (T.info("Are you there timer expired. Calling callback"), f.current = !0, r == null || r());
554
- }, [r]), l = u(() => {
555
- H.debug(
556
- "handleIdleTimer called in useCuiKitTimers, onIdleTimer exists:",
557
- !!i
558
- ), i ? (H.debug("Idle timer expired. Calling callback"), i == null || i()) : H.debug("No onIdleTimer callback provided!");
559
- }, [i]), w = u(() => {
560
- H.debug(`TIMER RESTART called for ${e.prefix ?? ""}timer`), s && (s.restart(), f.current = !1, o == null || o());
561
- }, [s, o, e.prefix]), $ = u(() => {
562
- H.debug(`TIMER PAUSE/RESET called for ${e.prefix ?? ""}timer`), s && (s.reset(), f.current = !1, o == null || o());
563
- }, [s, o, e.prefix]);
564
- return j(() => {
565
- if (H.debug(
566
- `useCuiKitTimers effect triggered - nozzle: ${!!t}, path: ${t == null ? void 0 : t.path}, callbacks: handleIdle=${!!l}, handleAreYouThere=${!!d}`
567
- ), t) {
568
- H.info("Nozzle is available. Creating timers");
569
- const b = Ye.createTimer(
570
- `${e.prefix ?? ""}idle-timer-${t.path}`,
571
- p
572
- );
573
- return H.debug(
574
- `Adding idle timer action for ${e.prefix ?? ""}idle-timer-${t.path} with callback:`,
575
- !!l
576
- ), b == null || b.addTimeoutAction({
577
- name: "idle-timer",
578
- remainingTime: 0,
579
- action: l
580
- }), b == null || b.addTimeoutAction({
581
- name: "are-you-there-timer",
582
- remainingTime: c,
583
- action: d
584
- }), n(b ?? null), () => {
585
- b == null || b.reset(), n(null);
586
- };
587
- }
588
- return () => {
589
- H.info("Nozzle is not available. No timers to clear");
590
- };
591
- }, [
592
- c,
593
- p,
594
- d,
595
- l,
596
- t,
597
- e.prefix
598
- ]), {
599
- idleTimer: s,
600
- restart: w,
601
- pause: $
602
- };
603
- }, F = T.createLogger({ name: "useDefaultCuiKitLifecycle" }), hs = ({
604
- kit: e,
605
- inactivity: t,
606
- pour: s,
607
- screens: n,
608
- onBeforeAreYouThereTimer: r,
609
- areYouThereRejectionPolicy: i = "pause"
610
- }) => {
611
- var Ee, ye, Ae, ke;
612
- const [o, c] = A(!1), [p, f] = A(!1), { model: d } = L(), [l, w] = A(!1), $ = (t == null ? void 0 : t.idleTimeout) ?? 15, b = (t == null ? void 0 : t.areYouThereTimeoutOffset) ?? 10, v = (s == null ? void 0 : s.idleTimeout) ?? (t == null ? void 0 : t.idleTimeout) ?? 10, a = (s == null ? void 0 : s.areYouThereTimeoutOffset) ?? (t == null ? void 0 : t.areYouThereTimeoutOffset) ?? 5, G = n == null ? void 0 : n.ambientTimeoutOffset, _ = n == null ? void 0 : n.attractTimeout, P = u(() => {
613
- if (F.info("handleIdleTimeout called - navigating home and publishing event"), q(!1), e == null || e.nav.home(), d) {
614
- const y = `/kos/dispense/${d.path}/idle/timeout/`;
615
- g.publish(y, {});
616
- }
617
- }, [(Ee = e == null ? void 0 : e.nav) == null ? void 0 : Ee.home, d]), Z = u(() => {
618
- F.info("handleResetIdleTimer called - resetting idle timer"), q(!1);
619
- }, []), de = u(() => {
620
- if (G && (c(!0), f(!1), d)) {
621
- const y = `/kos/dispense/${d.path}/ambient/start/`;
622
- g.publish(y, {});
623
- }
624
- }, [G, d]), ue = u(() => {
625
- if (_ && (f(!0), c(!1), d)) {
626
- const y = `/kos/dispense/${d.path}/attract/start/`;
627
- g.publish(y, {});
628
- }
629
- }, [_, d]), le = u(() => {
630
- if (_ && (f(!1), c(!1), e == null || e.nav.home(), d)) {
631
- const y = `/kos/dispense/${d.path}/attract/resume/`;
632
- g.publish(y, {});
633
- }
634
- }, [e == null ? void 0 : e.nav, _, d]), {
635
- pause: I,
636
- restart: K,
637
- attractTimer: J
638
- } = St({
639
- defaultAmbientTime: G,
640
- defaultAttractTime: _,
641
- onAmbientTimer: de,
642
- onAttractTimer: ue,
643
- onResumeAttractTimer: le
644
- });
645
- (ye = e == null ? void 0 : e.timers) == null || ye.add(J);
646
- const [pe, q] = A(!1);
647
- F.info(
648
- "Creating idle timer with timeout:",
649
- $,
650
- "seconds and callback:",
651
- !!P
652
- );
653
- const { pause: x, restart: C, idleTimer: D } = De({
654
- defaultAreYouThereTime: b,
655
- defaultIdleTime: $,
656
- onIdleTimer: P,
657
- onResetIdleTimer: Z
658
- });
659
- F.info(
660
- `Creating pour timer with timeout: ${v} seconds and callback: ${!!P}`
661
- );
662
- const {
663
- pause: E,
664
- restart: Y,
665
- idleTimer: W
666
- } = De({
667
- defaultAreYouThereTime: a,
668
- defaultIdleTime: v,
669
- onIdleTimer: P,
670
- prefix: "pour-"
671
- }), X = u(async () => {
672
- let y = !0;
673
- if (r)
674
- try {
675
- y = await r();
676
- } catch (be) {
677
- F.error(`onBeforeAreYouThereTimer callback failed: ${be}`), y = !1;
678
- }
679
- if (y) {
680
- if (d) {
681
- const be = `/kos/dispense/${d.path}/are-you-there/timeout/`;
682
- g.publish(be, {});
683
- }
684
- q(!0), l ? E() : x();
685
- } else
686
- switch (i) {
687
- case "pause":
688
- l ? E() : x();
689
- break;
690
- case "restart":
691
- l ? Y() : C();
692
- break;
693
- }
694
- }, [r, d, i, l]), fe = u(() => {
695
- q(!1), I(), l ? (Y(), x()) : (C(), E());
696
- }, [l, x, E, C, Y]);
697
- j(() => {
698
- D && D.addTimeoutAction({
699
- name: "are-you-there-timer",
700
- remainingTime: b,
701
- action: X
702
- });
703
- }, [D, b, X]), j(() => {
704
- W && W.addTimeoutAction({
705
- name: "pour-are-you-there-timer",
706
- remainingTime: a,
707
- action: X
708
- });
709
- }, [W, a, X]), (Ae = e == null ? void 0 : e.timers) == null || Ae.add(D), (ke = e == null ? void 0 : e.timers) == null || ke.add(W);
710
- const me = u(() => {
711
- w(!1), E(), x(), I();
712
- }, [x, E]), he = u(() => {
713
- w(!0), F.info("restarting pour timer"), Y(), I(), x();
714
- }, [x, Y]), Re = u(() => {
715
- w(!1), F.info("restarting pour timer on before pour rejected"), E(), C();
716
- }, []), se = u(() => {
717
- I(), f(!1), c(!1), C();
718
- }, [I, C]), re = u(() => {
719
- f(!1), c(!1), w(!1), E(), K();
720
- }, [K, E]), ne = u(() => {
721
- f(!1), c(!1), w(!1), I(), C();
722
- }, [I, C]), h = u(() => {
723
- f(!1), c(!1), w(!1), K(), x(), E();
724
- }, [K, x, E]), M = u(() => {
725
- f(!1), c(!1), K(), x();
726
- }, [K, x]);
727
- Nt({
728
- onBrandSelected: se,
729
- onBrandCleared: re,
730
- onBeverageSelected: ne,
731
- onBeverageCleared: h,
732
- onPour: me,
733
- onPourCancel: he,
734
- onBeforePourRejected: Re,
735
- onInit: M
736
- // Note: Timer-related handlers (onIdleTimeout, onAmbientTimer, onAttractTimer,
737
- // onResumeAttractTimer, onAreYouThereTimeout) are NOT included here since this
738
- // component's own timer hooks call those handlers directly. Including them would
739
- // create circular event loops.
740
- });
741
- const ht = l ? a : b;
742
- return j(() => {
743
- if (d && J) {
744
- const y = `/kos/dispense/${d == null ? void 0 : d.path}/init/`;
745
- g.publish(y, {});
746
- }
747
- }, [d, J]), {
748
- showAreYouThere: pe,
749
- clearAreYouThere: fe,
750
- pauseIdleTimer: x,
751
- restartIdleTimer: C,
752
- areYouThereCountdown: ht,
753
- showAmbientScreen: o,
754
- showAttractScreen: p,
755
- pauseScreenTimer: I,
756
- restartScreenTimer: K
757
- };
758
- }, Qe = () => {
759
- const e = _e.type;
760
- return k({
761
- modelId: e,
762
- modelType: _e.type,
763
- options: {}
764
- });
765
- };
766
- function bs(e) {
767
- return (t) => {
768
- const { model: s, status: n, KosModelLoader: r } = Qe();
769
- return /* @__PURE__ */ m(r, { ...n, children: /* @__PURE__ */ m(e, { ...t, deviceAssembly: s }) });
770
- };
771
- }
772
- const ze = (e) => k({
773
- modelId: e,
774
- modelType: gt.type,
775
- options: {}
776
- });
777
- function vs(e, t) {
778
- return (s) => {
779
- const { model: n, status: r, KosModelLoader: i } = ze(e);
780
- return /* @__PURE__ */ m(i, { ...r, children: /* @__PURE__ */ m(t, { ...s, holder: n }) });
781
- };
782
- }
783
- const et = () => {
784
- const e = Ke.type;
785
- return k({
786
- modelId: e,
787
- modelType: Ke.type,
788
- options: {}
789
- });
790
- };
791
- function ws(e) {
792
- return (t) => {
793
- const { model: s, status: n, KosModelLoader: r } = et();
794
- return /* @__PURE__ */ m(r, { ...n, children: /* @__PURE__ */ m(e, { ...t, holderContainer: s }) });
795
- };
796
- }
797
- const tt = () => {
798
- const e = Me.type;
799
- return k({
800
- modelId: e,
801
- modelType: Me.type,
802
- options: {}
803
- });
804
- }, ve = T.createLogger({
805
- name: "HoldToPourIntentStrategy",
806
- group: "kos-hooks"
807
- }), _t = {
808
- name: "HoldToPourIntentStrategy",
809
- async initiate(e, t) {
810
- if (!(e != null && e.canPour)) {
811
- ve.debug(`${e == null ? void 0 : e.id} cannot pour. Returning early.`);
812
- return;
813
- }
814
- t ? (ve.debug(`performing intent: ${t}`), await (e == null ? void 0 : e.performIntent(t))) : ve.debug("no intent provided. Returning early.");
815
- },
816
- async initiateEnded(e) {
817
- await (e == null ? void 0 : e.cancelPour());
818
- }
819
- }, we = T.createLogger({
820
- name: "useNozzlePour",
821
- group: "kos-hooks"
822
- }), $s = ({
823
- onPour: e,
824
- onPourCancel: t,
825
- intentContainer: s,
826
- strategy: n = _t
827
- }) => {
828
- const r = u(() => {
829
- we.debug(
830
- `[${n == null ? void 0 : n.name}] - Pour initiated for model ${s == null ? void 0 : s.id}.`
831
- ), n == null || n.initiate(s), e == null || e();
832
- }, [e, s, n]), i = u(() => {
833
- var p;
834
- we.debug(
835
- `[${n == null ? void 0 : n.name}] - Pour initiate ended called for nozzle ${s == null ? void 0 : s.id}.`
836
- ), (p = n == null ? void 0 : n.initiateEnded) == null || p.call(n, s), t == null || t();
837
- }, [t, s, n]), o = u(() => {
838
- we.debug(`Force cancelling pour for nozzle ${s == null ? void 0 : s.id}.`), s == null || s.cancelPour(), t == null || t();
839
- }, [t, s]);
840
- return {
841
- handlers: xe({
842
- onPressed: r,
843
- onRelease: i
844
- }).dom,
845
- cancel: o,
846
- status: s
847
- };
848
- };
849
- function gs(e) {
850
- return (t) => {
851
- const { model: s, status: n, KosModelLoader: r } = tt();
852
- return /* @__PURE__ */ m(r, { ...n, children: /* @__PURE__ */ m(e, { ...t, ingredient: s }) });
853
- };
854
- }
855
- const st = () => {
856
- const e = He.type;
857
- return k({
858
- modelId: e,
859
- modelType: He.type,
860
- options: {}
861
- });
862
- };
863
- function Ps(e) {
864
- return (t) => {
865
- const { model: s, status: n, KosModelLoader: r } = st();
866
- return /* @__PURE__ */ m(r, { ...n, children: /* @__PURE__ */ m(e, { ...t, ingredientContainer: s }) });
867
- };
868
- }
869
- function Is(e, t) {
870
- return (s) => {
871
- const { model: n, status: r, KosModelLoader: i } = Xe(e);
872
- return /* @__PURE__ */ m(i, { ...r, children: /* @__PURE__ */ m(t, { ...s, nozzle: n }) });
873
- };
874
- }
875
- const ee = T.createLogger({
876
- name: "usePour",
877
- group: "kos-hooks"
878
- }), Ts = ({
879
- onBeforePour: e,
880
- onPour: t,
881
- onPourCancel: s,
882
- onPourAbort: n,
883
- pourTarget: r,
884
- strategy: i = Je
885
- }) => {
886
- const o = u(async () => {
887
- ee.debug(
888
- `[${i == null ? void 0 : i.name}] - calling before pour for pour target ${r == null ? void 0 : r.id}.`
889
- ), (e ? await (e == null ? void 0 : e()) : !0) ? (ee.debug(
890
- `[${i == null ? void 0 : i.name}] - Pour initiated for pour target ${r == null ? void 0 : r.id}.`
891
- ), await (i == null ? void 0 : i.initiate(r)), t == null || t(), r != null && r.isPouring || n == null || n()) : (ee.debug(
892
- `[${i == null ? void 0 : i.name}] - Pour cancelled for pour target ${r == null ? void 0 : r.id}.`
893
- ), s == null || s());
894
- }, [t, r, i]), c = u(async () => {
895
- var l;
896
- ee.debug(
897
- `[${i == null ? void 0 : i.name}] - Pour initiate ended called for pour target ${r == null ? void 0 : r.id}.`
898
- ), await ((l = i == null ? void 0 : i.initiateEnded) == null ? void 0 : l.call(i, r)) || s == null || s();
899
- }, [s, r, i]), p = u(async () => {
900
- ee.debug(`Force cancelling pour for pour target ${r == null ? void 0 : r.id}.`), await (r == null ? void 0 : r.cancelPour()), s == null || s();
901
- }, [s, r]);
902
- return {
903
- handlers: xe({
904
- onPressed: o,
905
- onRelease: c
906
- }).dom,
907
- cancel: p,
908
- status: r
909
- };
910
- }, te = T.createLogger({
911
- name: "TapOrHoldIntentStrategy",
912
- group: "kos-hooks"
913
- });
914
- class xs {
915
- constructor(t) {
916
- O(this, "intent");
917
- O(this, "name", "TapOrHoldIntentStrategy");
918
- O(this, "isHold", !1);
919
- O(this, "disposer", null);
920
- this.intent = t;
921
- }
922
- async initiate(t, s) {
923
- if (this.disposer = setTimeout(() => {
924
- this.isHold = !0;
925
- }, 250), t != null && t.isPouring && !this.isHold) {
926
- te.debug("additional tap detected. cancelling pour"), await t.cancelPour();
927
- return;
928
- }
929
- if (!(t != null && t.canPour)) {
930
- te.debug(`${t == null ? void 0 : t.id} cannot pour. Returning early.`);
931
- return;
932
- }
933
- s ? (te.debug(`performing intent: ${s}`), await (t == null ? void 0 : t.performIntent(s))) : te.debug("no intent provided. Returning early.");
934
- }
935
- async initiateEnded(t) {
936
- return this.disposer && clearTimeout(this.disposer), this.disposer = null, this.isHold ? (await (t == null ? void 0 : t.cancelPour()), !1) : (te.debug("Tap detected. don't cancel and return."), !0);
937
- }
938
- }
939
- const ae = T.createLogger({
940
- name: "TapToPourIntentStrategy",
941
- group: "kos-hooks"
942
- }), Rs = {
943
- name: "TapToPourIntentStrategy",
944
- async initiate(e, t) {
945
- if (e != null && e.isPouring) {
946
- ae.debug(`Nozzle ${e == null ? void 0 : e.id} is already pouring. cancelling pour`), await e.cancelPour();
947
- return;
948
- }
949
- if (!(e != null && e.canPour)) {
950
- ae.debug(`Nozzle ${e == null ? void 0 : e.id} cannot pour. Returning early.`);
951
- return;
952
- }
953
- t ? (ae.debug(`performing intent: ${t}`), await (e == null ? void 0 : e.performIntent(t))) : ae.debug("no intent provided. Returning early.");
954
- },
955
- async initiateEnded(e) {
956
- return !0;
957
- }
958
- }, Oe = T.createLogger({
959
- name: "HoldToPourStrategy",
960
- group: "kos-hooks"
961
- }), Es = {
962
- name: "TapToPourStrategy",
963
- async initiate(e) {
964
- if (e != null && e.isPouring) {
965
- Oe.debug(`Nozzle ${e == null ? void 0 : e.id} is already pouring. cancelling pour`), await e.cancelPour();
966
- return;
967
- }
968
- if (!(e != null && e.canPour)) {
969
- Oe.debug(`Nozzle ${e == null ? void 0 : e.id} cannot pour. Returning early.`);
970
- return;
971
- }
972
- await (e == null ? void 0 : e.pour());
973
- },
974
- async initiateEnded(e) {
975
- return !0;
976
- }
977
- }, Kt = (e, t, s) => k({
978
- modelId: e,
979
- modelType: Pt.type,
980
- options: {
981
- servicePathFactory: t,
982
- selectedId: s
983
- }
984
- });
985
- function ys(e) {
986
- return (t) => {
987
- const { model: s, status: n, KosModelLoader: r } = Kt(
988
- t.id,
989
- t.servicePathFactory,
990
- t.itemId
991
- );
992
- return /* @__PURE__ */ m(r, { ...n, children: /* @__PURE__ */ m(e, { ...t, genericPour: s }) });
993
- };
994
- }
995
- const rt = N(void 0), As = ({ children: e }) => {
996
- const { model: t, ready: s } = Ve(), n = R(() => s && t ? { model: t } : {}, [s, t]);
997
- return /* @__PURE__ */ m(rt.Provider, { value: n, children: e });
998
- }, ks = () => {
999
- const e = S(
1000
- rt
1001
- );
1002
- if (!e)
1003
- throw new Error(
1004
- "useAssemblyContext must be used within a AssemblyProvider"
1005
- );
1006
- return e;
1007
- }, nt = N(void 0), Ss = ({ children: e }) => {
1008
- const { model: t, ready: s } = Ge(), n = R(() => s && t ? { model: t } : {}, [s, t]);
1009
- return /* @__PURE__ */ m(nt.Provider, { value: n, children: e });
1010
- }, Cs = () => {
1011
- const e = S(nt);
1012
- if (!e)
1013
- throw new Error(
1014
- "useAvailabilityContext must be used within a AvailabilityProvider"
1015
- );
1016
- return e;
1017
- }, it = N(void 0), Ns = ({ children: e, id: t }) => {
1018
- const { model: s, ready: n } = qe(t), r = R(() => n && s ? { model: s } : {}, [n, s]);
1019
- return /* @__PURE__ */ m(it.Provider, { value: r, children: e });
1020
- }, _s = () => {
1021
- const e = S(it);
1022
- if (!e)
1023
- throw new Error("useBoardContext must be used within a BoardProvider");
1024
- return e;
1025
- }, ot = N(void 0), Ks = ({ children: e }) => {
1026
- const { model: t, ready: s } = We(), n = R(() => s && t ? { model: t } : {}, [s, t]);
1027
- return /* @__PURE__ */ m(ot.Provider, { value: n, children: e });
1028
- }, Ms = () => {
1029
- const e = S(ot);
1030
- if (!e)
1031
- throw new Error(
1032
- "useBoardContainerContext must be used within a BoardContainerProvider"
1033
- );
1034
- return e;
1035
- }, at = N(
1036
- void 0
1037
- ), Mt = ({ children: e }) => {
1038
- const { model: t, ready: s } = Qe(), n = R(() => {
1039
- if (s && t) {
1040
- const i = t.nozzlePaths;
1041
- return { model: t, nozzlePaths: i };
1042
- }
1043
- return {};
1044
- }, [s, t]), r = s && t ? e : null;
1045
- return /* @__PURE__ */ m(at.Provider, { value: n, children: r });
1046
- }, Ht = () => {
1047
- const e = S(at);
1048
- if (!e)
1049
- throw new Error(
1050
- "useDeviceAssemblyContext must be used within a DeviceAssemblyProvider"
1051
- );
1052
- return e;
1053
- };
1054
- function Lt() {
1055
- const e = It.createContext(null);
1056
- return [() => {
1057
- const s = S(e);
1058
- if (s === void 0)
1059
- throw new Error("useDispenseKitContext must be used within a Provider");
1060
- return s;
1061
- }, e.Provider];
1062
- }
1063
- function Dt({
1064
- children: e,
1065
- provider: t,
1066
- props: s,
1067
- nozzleProps: n
1068
- }) {
1069
- const r = kt(s);
1070
- return /* @__PURE__ */ m(t, { value: r, children: e(n || {}) });
1071
- }
1072
- function Ot({
1073
- children: e,
1074
- provider: t,
1075
- props: s
1076
- }) {
1077
- const { nozzlePaths: n } = Ht(), r = (n == null ? void 0 : n.length) || 0;
1078
- return (n == null ? void 0 : n.map((o, c) => /* @__PURE__ */ m(Tt, { path: o, children: /* @__PURE__ */ m(
1079
- Dt,
1080
- {
1081
- provider: t,
1082
- props: s,
1083
- nozzleProps: {
1084
- nozzleIndex: c,
1085
- nozzlePath: o,
1086
- totalNozzles: r,
1087
- isFirstNozzle: c === 0,
1088
- isLastNozzle: c === r - 1
1089
- },
1090
- children: e
1091
- }
1092
- ) }, o))) || [];
1093
- }
1094
- function Bt({
1095
- provider: e,
1096
- props: t
1097
- }) {
1098
- return ({ children: s }) => e ? /* @__PURE__ */ m(Mt, { children: /* @__PURE__ */ m(
1099
- Ot,
1100
- {
1101
- provider: e,
1102
- props: t,
1103
- children: s
1104
- }
1105
- ) }) : null;
1106
- }
1107
- function Hs(e) {
1108
- const [t, s] = Lt();
1109
- return [
1110
- t,
1111
- Bt({ provider: s, props: e })
1112
- ];
1113
- }
1114
- const ct = N(void 0), Ls = ({ children: e, id: t }) => {
1115
- const { model: s, ready: n } = ze(t || ""), r = R(() => n && s ? { model: s } : {}, [n, s]);
1116
- return /* @__PURE__ */ m(ct.Provider, { value: r, children: e });
1117
- }, Ds = () => {
1118
- const e = S(ct);
1119
- if (!e)
1120
- throw new Error("useHolderContext must be used within a HolderProvider");
1121
- return e;
1122
- }, dt = N(
1123
- void 0
1124
- ), Os = ({ children: e }) => {
1125
- const { model: t, ready: s } = et(), n = R(() => s && t ? { model: t } : {}, [s, t]);
1126
- return /* @__PURE__ */ m(dt.Provider, { value: n, children: e });
1127
- }, Bs = () => {
1128
- const e = S(dt);
1129
- if (!e)
1130
- throw new Error(
1131
- "useHolderContainerContext must be used within a HolderContainerProvider"
1132
- );
1133
- return e;
1134
- }, ut = N(void 0), js = ({ children: e }) => {
1135
- const { model: t, ready: s } = tt(), n = R(() => s && t ? { model: t } : {}, [s, t]);
1136
- return /* @__PURE__ */ m(ut.Provider, { value: n, children: e });
1137
- }, Us = () => {
1138
- const e = S(ut);
1139
- if (!e)
1140
- throw new Error(
1141
- "useIngredientContext must be used within a IngredientProvider"
1142
- );
1143
- return e;
1144
- }, lt = N(
1145
- void 0
1146
- ), Ys = ({ children: e }) => {
1147
- const { model: t, ready: s } = st(), n = R(() => s && t ? { model: t } : {}, [s, t]);
1148
- return /* @__PURE__ */ m(lt.Provider, { value: n, children: e });
1149
- }, Fs = () => {
1150
- const e = S(lt);
1151
- if (!e)
1152
- throw new Error(
1153
- "useIngredientContainerContext must be used within a IngredientContainerProvider"
1154
- );
1155
- return e;
1156
- }, jt = () => {
1157
- const e = Le.type;
1158
- return k({
1159
- modelId: e,
1160
- modelType: Le.type,
1161
- options: {}
1162
- });
1163
- }, pt = N(void 0), Vs = ({ children: e }) => {
1164
- const { model: t, ready: s } = jt(), n = R(() => s && t ? { model: t } : {}, [s, t]);
1165
- return /* @__PURE__ */ m(pt.Provider, { value: n, children: e });
1166
- }, Gs = () => {
1167
- const e = S(pt);
1168
- if (!e)
1169
- throw new Error("usePumpContext must be used within a PumpProvider");
1170
- return e;
1171
- };
1172
- function Ut(e) {
1173
- var t;
1174
- try {
1175
- if ("shape" in e) {
1176
- const s = e, n = [];
1177
- for (const [r, i] of Object.entries(
1178
- s.shape
1179
- )) {
1180
- const o = i, c = {
1181
- name: r,
1182
- required: !o.isOptional()
1183
- };
1184
- if (o._def && o._def.description && (c.description = o._def.description), o._def) {
1185
- let p = o._def.typeName || "unknown";
1186
- p === "ZodOptional" && o._def.innerType && (p = ((t = o._def.innerType._def) == null ? void 0 : t.typeName) || "unknown"), c.type = p.replace("Zod", "").toLowerCase();
1187
- }
1188
- n.push(c);
1189
- }
1190
- return n;
1191
- }
1192
- return [];
1193
- } catch (s) {
1194
- return console.warn("Failed to extract schema field info:", s), [];
1195
- }
1196
- }
1197
- class Yt {
1198
- constructor() {
1199
- O(this, "issues", []);
1200
- }
1201
- addError(t) {
1202
- this.issues.push({ type: "error", message: t });
1203
- }
1204
- addWarning(t) {
1205
- this.issues.push({ type: "warning", message: t });
1206
- }
1207
- addInfo(t) {
1208
- this.issues.push({ type: "info", message: t });
1209
- }
1210
- hasErrors() {
1211
- return this.issues.some((t) => t.type === "error");
1212
- }
1213
- hasIssues() {
1214
- return this.issues.length > 0;
1215
- }
1216
- getIssues() {
1217
- return [...this.issues];
1218
- }
1219
- }
1220
- class Ft {
1221
- constructor() {
1222
- O(this, "cache", /* @__PURE__ */ new Map());
1223
- }
1224
- set(t, s) {
1225
- this.cache.set(t, s);
1226
- }
1227
- get(t) {
1228
- return this.cache.get(t) || [];
1229
- }
1230
- clear() {
1231
- this.cache.clear();
1232
- }
1233
- }
1234
- const $e = new Ft();
1235
- class Vt {
1236
- constructor() {
1237
- O(this, "extensionPoints", /* @__PURE__ */ new Map());
1238
- }
1239
- define(t) {
1240
- if (this.extensionPoints.has(t.id))
1241
- return console.warn(`Extension point ${t.id} is already defined`), this.extensionPoints.get(t.id);
1242
- const s = {
1243
- config: t,
1244
- id: t.id,
1245
- isRegistered: !1,
1246
- getExtensions: (n) => n[t.id] || {},
1247
- register: () => {
1248
- if (s.isRegistered) {
1249
- console.warn(`Extension point ${t.id} is already registered`);
1250
- return;
1251
- }
1252
- this.createReducer(t), s.isRegistered = !0;
1253
- }
1254
- };
1255
- return t.schema && (s.getSchemaFieldInfo = () => Ut(t.schema)), this.extensionPoints.set(t.id, s), s;
1256
- }
1257
- createReducer(t) {
1258
- return (s, n, r) => {
1259
- const i = n[t.contributionKey];
1260
- return !i || typeof i != "object" || Object.entries(i).forEach(
1261
- ([o, c]) => {
1262
- var l, w;
1263
- if (!c)
1264
- return;
1265
- const p = {
1266
- remote: c.remote || "",
1267
- sectionId: c.sectionId || o,
1268
- experiences: r,
1269
- contributions: n
1270
- };
1271
- if (t.validate) {
1272
- const $ = new Yt();
1273
- if (t.validate(
1274
- c,
1275
- $
1276
- ) === "skip") {
1277
- $e.set(o, [
1278
- {
1279
- type: "warning",
1280
- message: "Plugin marked to skip processing"
1281
- }
1282
- ]);
1283
- return;
1284
- }
1285
- if ($.hasIssues()) {
1286
- const v = $.getIssues().map((a) => ({
1287
- ...a,
1288
- message: `Extension point validation: ${a.message}`
1289
- }));
1290
- if ($e.set(o, v), $.hasErrors()) {
1291
- console.error(
1292
- `Validation failed for ${t.id} contribution "${o}":`,
1293
- v.filter((a) => a.type === "error").map((a) => a.message).join(", ")
1294
- );
1295
- return;
1296
- }
1297
- } else
1298
- $e.set(o, []);
1299
- }
1300
- const f = t.transform ? t.transform(c, p) : c;
1301
- s[t.id] || (s[t.id] = {});
1302
- const d = {
1303
- id: o,
1304
- type: t.contributionKey,
1305
- data: f,
1306
- remote: p.remote,
1307
- sectionId: p.sectionId
1308
- };
1309
- if (t.isRankable && typeof c.rank == "number" && (d.rank = c.rank), f && typeof f == "object" && ("component" in f && (d.component = f.component), "view" in f && (d.view = f.view), "location" in f && (d.location = f.location)), s[t.id][o] = d, t.hasView && ((l = t.relatedPoints) != null && l.view)) {
1310
- const $ = c.experienceId, b = r == null ? void 0 : r[$];
1311
- b && (s[t.relatedPoints.view] || (s[t.relatedPoints.view] = {}), s[t.relatedPoints.view][o] = {
1312
- id: o,
1313
- type: `${t.contributionKey}.view`,
1314
- data: b,
1315
- remote: p.remote,
1316
- sectionId: p.sectionId
1317
- });
1318
- }
1319
- (w = t.relatedPoints) != null && w.definition && (s[t.relatedPoints.definition] || (s[t.relatedPoints.definition] = {}), s[t.relatedPoints.definition][o] = {
1320
- id: o,
1321
- type: `${t.contributionKey}.definition`,
1322
- data: f,
1323
- remote: p.remote,
1324
- sectionId: p.sectionId
1325
- });
1326
- }
1327
- ), s;
1328
- };
1329
- }
1330
- /**
1331
- * Get all registered extension points (for discovery/documentation)
1332
- */
1333
- getAllExtensionPoints() {
1334
- return Array.from(this.extensionPoints.values()).filter(
1335
- (t) => t.isRegistered
1336
- );
1337
- }
1338
- /**
1339
- * Get all defined extension points (registered and unregistered)
1340
- */
1341
- getAllDefinedExtensionPoints() {
1342
- return Array.from(this.extensionPoints.values());
1343
- }
1344
- /**
1345
- * Get a specific extension point definition
1346
- */
1347
- getExtensionPoint(t) {
1348
- return this.extensionPoints.get(t);
1349
- }
1350
- /**
1351
- * Check if an extension point is registered
1352
- */
1353
- hasExtensionPoint(t) {
1354
- return this.extensionPoints.has(t);
1355
- }
1356
- }
1357
- const Gt = new Vt();
1358
- var qt = {}, U = {};
1359
- Object.defineProperty(U, "__esModule", { value: !0 });
1360
- U.loadRemoteModule = U.setRemoteDefinitions = U.setRemoteUrlResolver = void 0;
1361
- let ce, Pe;
1362
- const ge = /* @__PURE__ */ new Map(), Ie = /* @__PURE__ */ new Map();
1363
- let Be = !1;
1364
- function Wt(e) {
1365
- Pe = e;
1366
- }
1367
- U.setRemoteUrlResolver = Wt;
1368
- function Xt(e) {
1369
- ce = e;
1370
- }
1371
- U.setRemoteDefinitions = Xt;
1372
- async function Zt(e, t) {
1373
- const s = `${e}:${t}`;
1374
- if (ge.has(s))
1375
- return ge.get(s);
1376
- const i = (await (Ie.has(e) ? Ie.get(e) : await Qt(e)).get(t))();
1377
- return ge.set(s, i), i;
1378
- }
1379
- U.loadRemoteModule = Zt;
1380
- const Jt = (e, t) => new Promise((s, n) => {
1381
- const r = document.createElement("script");
1382
- r.src = e, r.type = "text/javascript", r.async = !0, r.onload = () => {
1383
- s({
1384
- get: (o) => window[t].get(o),
1385
- init: (o) => {
1386
- try {
1387
- window[t].init(o);
1388
- } catch (c) {
1389
- console.error(`Failed to initialize remote ${t}`, c), n(c);
1390
- }
1391
- }
1392
- });
1393
- }, r.onerror = () => n(new Error(`Remote ${t} not found`)), document.head.appendChild(r);
1394
- });
1395
- async function Qt(e) {
1396
- if (!Pe && !ce)
1397
- throw new Error("Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.");
1398
- Be || (Be = !0, await __webpack_init_sharing__("default"));
1399
- const t = ce ? ce[e] : await Pe(e);
1400
- let s = t;
1401
- !t.endsWith(".mjs") && !t.endsWith(".js") && (s = `${t}${t.endsWith("/") ? "" : "/"}remoteEntry.js`);
1402
- const n = await Jt(s, e);
1403
- return await n.init(__webpack_share_scopes__.default), Ie.set(e, n), n;
1404
- }
1405
- (function(e) {
1406
- Object.defineProperty(e, "__esModule", { value: !0 }), e.setRemoteUrlResolver = e.setRemoteDefinitions = e.loadRemoteModule = void 0;
1407
- var t = U;
1408
- Object.defineProperty(e, "loadRemoteModule", { enumerable: !0, get: function() {
1409
- return t.loadRemoteModule;
1410
- } }), Object.defineProperty(e, "setRemoteDefinitions", { enumerable: !0, get: function() {
1411
- return t.setRemoteDefinitions;
1412
- } }), Object.defineProperty(e, "setRemoteUrlResolver", { enumerable: !0, get: function() {
1413
- return t.setRemoteUrlResolver;
1414
- } });
1415
- })(qt);
1416
- function zt(e, t, ...s) {
1417
- return [e, t, ...s].filter(Boolean).join(".");
1418
- }
1419
- function es(e = {}) {
1420
- const {
1421
- experienceIdProperty: t = "experienceId",
1422
- flattenComponentProperties: s = !0,
1423
- customTransform: n
1424
- } = e;
1425
- return (r, i) => {
1426
- var f;
1427
- const o = r[t], c = o ? ((f = i.experiences) == null ? void 0 : f[o]) || {} : {};
1428
- let p = {
1429
- ...r,
1430
- view: c
1431
- };
1432
- return s && c && (c.component && (p.component = c.component), c.location && (p.location = c.location)), n && (p = n(r, c, i) || p), p;
1433
- };
1434
- }
1435
- function ts(e) {
1436
- return Gt.define(e);
1437
- }
1438
- const ft = V.object({
1439
- id: V.string().min(1, "ID is required").describe("Unique identifier for this extension"),
1440
- title: V.string().min(1, "Title is required").describe("Display title shown in the interface"),
1441
- namespace: V.string().min(1, "Namespace is required").describe("Namespace for organizing related extensions"),
1442
- experienceId: V.string().min(1, "Experience ID is required").describe("Reference to the UI component experience for rendering")
1443
- }), ss = ft.extend({
1444
- rank: V.number().int().min(0).optional().describe("Optional ranking for ordering (higher = preferred)")
1445
- });
1446
- function rs(e, t, s) {
1447
- const n = e.safeParse(t);
1448
- return n.success ? !0 : (n.error.errors.forEach((r) => {
1449
- s.addError(`${r.path.join(".")}: ${r.message}`);
1450
- }), !1);
1451
- }
1452
- function ns(e, t = {}) {
1453
- return (t.rankable ? ss : ft).extend(e);
1454
- }
1455
- const je = ns(
1456
- {
1457
- type: V.literal("control.pour").describe("Type identifier for control pour extensions")
1458
- },
1459
- { rankable: !1 }
1460
- ), mt = zt("cui", "control", "pour"), qs = ts({
1461
- id: mt,
1462
- contributionKey: "controlPour",
1463
- displayName: "Control Pour",
1464
- description: "Extension point for controlled pour plugin configurations with view support",
1465
- hasView: !0,
1466
- isRankable: !1,
1467
- schema: je,
1468
- metadata: {
1469
- exportName: "ControlPourExtension",
1470
- category: "Dispense",
1471
- tags: ["pour", "control", "beverage"]
1472
- },
1473
- validate: (e, t) => {
1474
- rs(je, e, t);
1475
- },
1476
- transform: es()
1477
- }), Ws = mt;
1478
- export {
1479
- Ps as $,
1480
- As as A,
1481
- Ns as B,
1482
- Dt as C,
1483
- Mt as D,
1484
- Rt as E,
1485
- Q as F,
1486
- oe as G,
1487
- Ls as H,
1488
- js as I,
1489
- z as J,
1490
- kt as K,
1491
- hs as L,
1492
- Nt as M,
1493
- Tt as N,
1494
- De as O,
1495
- Vs as P,
1496
- At as Q,
1497
- Qe as R,
1498
- bs as S,
1499
- ze as T,
1500
- vs as U,
1501
- et as V,
1502
- ws as W,
1503
- tt as X,
1504
- $s as Y,
1505
- gs as Z,
1506
- st as _,
1507
- Ss as a,
1508
- Xe as a0,
1509
- Is as a1,
1510
- yt as a2,
1511
- Ts as a3,
1512
- _t as a4,
1513
- Je as a5,
1514
- xs as a6,
1515
- Rs as a7,
1516
- Es as a8,
1517
- Kt as a9,
1518
- ys as aa,
1519
- qs as ab,
1520
- Ws as ac,
1521
- Cs as b,
1522
- _s as c,
1523
- Ks as d,
1524
- Ms as e,
1525
- Bt as f,
1526
- Ht as g,
1527
- Ds as h,
1528
- Hs as i,
1529
- Os as j,
1530
- Bs as k,
1531
- Us as l,
1532
- Ys as m,
1533
- Fs as n,
1534
- L as o,
1535
- Gs as p,
1536
- Ve as q,
1537
- Ge as r,
1538
- ps as s,
1539
- qe as t,
1540
- ks as u,
1541
- fs as v,
1542
- ls as w,
1543
- We as x,
1544
- ms as y,
1545
- xt as z
1546
- };
1547
- //# sourceMappingURL=control-pour-extension-Byiwjyzw.js.map