@kosdev-code/kos-dispense-sdk 2.0.25 → 2.0.26

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.
@@ -0,0 +1,1139 @@
1
+ var Ze = Object.defineProperty;
2
+ var ze = (e, t, r) => t in e ? Ze(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var O = (e, t, r) => (ze(e, typeof t != "symbol" ? t + "" : t, r), r);
4
+ import { jsx as u } from "@emotion/react/jsx-runtime";
5
+ import { useKosModel as E, getKosCompanionModel as pe, kosAutoEffect as et, KosLog as w, usePressGesture as me, EventBus as T, TimerManager as He } from "@kosdev-code/kos-ui-sdk";
6
+ import tt, { createContext as S, useMemo as P, useContext as k, useState as x, useCallback as i, useEffect as U, useRef as st } from "react";
7
+ import { A as $e, a as we, d as rt, c as Pe, N as nt, e as ge, H as ot, f as Te, I as Ie, g as Ae, G as at, P as xe } from "./dispense-registration-manager-CKFF29mO.js";
8
+ const Se = () => {
9
+ const e = $e.type;
10
+ return E({
11
+ modelId: e,
12
+ modelType: $e.type,
13
+ options: {}
14
+ });
15
+ };
16
+ function Kt(e) {
17
+ return (t) => {
18
+ const { model: r, status: n, KosModelLoader: s } = Se();
19
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, assembly: r }) });
20
+ };
21
+ }
22
+ const Ne = () => {
23
+ const e = we.type;
24
+ return E({
25
+ modelId: e,
26
+ modelType: we.type,
27
+ options: {}
28
+ });
29
+ };
30
+ function Bt(e) {
31
+ return (t) => {
32
+ const { model: r, status: n, KosModelLoader: s } = Ne();
33
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, beverage: r }) });
34
+ };
35
+ }
36
+ const Ke = (e) => E({
37
+ modelId: e,
38
+ modelType: rt.type,
39
+ options: {}
40
+ });
41
+ function Lt(e) {
42
+ return (t) => (r) => {
43
+ const { model: n, status: s, KosModelLoader: o } = Ke(t);
44
+ return /* @__PURE__ */ u(o, { ...s, children: /* @__PURE__ */ u(e, { ...r, board: n }) });
45
+ };
46
+ }
47
+ const Be = () => {
48
+ const e = Pe.type;
49
+ return E({
50
+ modelId: e,
51
+ modelType: Pe.type,
52
+ options: {}
53
+ });
54
+ };
55
+ function Ct(e) {
56
+ return (t) => {
57
+ const { model: r, status: n, KosModelLoader: s } = Be();
58
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, boardContainer: r }) });
59
+ };
60
+ }
61
+ const Le = (e) => E({
62
+ modelId: e,
63
+ modelType: nt.type,
64
+ options: {
65
+ path: e
66
+ }
67
+ }), Ce = S(void 0), it = ({ children: e, path: t }) => {
68
+ const { model: r, ready: n } = Le(t), s = P(() => n && r ? { model: r } : {}, [n, r]);
69
+ return /* @__PURE__ */ u(Ce.Provider, { value: s, children: e });
70
+ }, C = () => {
71
+ const e = k(Ce);
72
+ if (!e)
73
+ throw new Error("useNozzleContext must be used within a NozzleProvider");
74
+ return e;
75
+ }, ct = ({
76
+ onBeverageSelected: e,
77
+ onClearBeverage: t,
78
+ companionType: r
79
+ }) => {
80
+ const { model: n } = C(), [s, o] = x([]), [d, p] = x(null), h = P(() => r ? s.map(
81
+ (m) => pe(m, r)
82
+ ) : [], [s, r]), f = i(
83
+ async (m) => {
84
+ p(m), await (n == null ? void 0 : n.setSelectedPourable({ beverage: m })), e == null || e(m);
85
+ },
86
+ [n, e]
87
+ ), c = i(async () => {
88
+ p(null), await (n == null ? void 0 : n.setSelectedPourable({ beverage: void 0 })), t == null || t();
89
+ }, [n, t]);
90
+ return U(() => {
91
+ const m = et(() => {
92
+ if (!n)
93
+ return;
94
+ const v = n.selectedBrand;
95
+ if (!v) {
96
+ const a = n.getGroupAvailabilityItems("beverages").filter(($) => $.visible);
97
+ o(a ?? []);
98
+ return;
99
+ }
100
+ const b = n.getAvailabilityByParent(v.id).filter((a) => a.visible);
101
+ o(b ?? []);
102
+ });
103
+ return () => {
104
+ m();
105
+ };
106
+ }, [n]), {
107
+ beverages: s,
108
+ beverageCompanions: h,
109
+ selectBeverage: f,
110
+ selectedBeverage: d,
111
+ clearBeverage: c
112
+ };
113
+ }, dt = ({
114
+ onBrandSelected: e,
115
+ onBrandCleared: t,
116
+ companionType: r
117
+ }) => {
118
+ const { model: n } = C(), [s, o] = x(null), d = P(
119
+ () => (n == null ? void 0 : n.getGroupAvailabilityItems("brands").filter((c) => c.visible)) ?? [],
120
+ [n]
121
+ ), p = P(() => r ? d.map((c) => pe(c, r)) : [], [d, r]), h = i(
122
+ async (c) => {
123
+ o(c), n == null || n.setSelectedBrand(c), e == null || e(c);
124
+ },
125
+ [n, e]
126
+ ), f = i(() => {
127
+ o(null), n == null || n.setSelectedBrand(void 0), t == null || t();
128
+ }, [n, t]);
129
+ return {
130
+ brands: d,
131
+ brandCompanions: p,
132
+ selectedBrand: s,
133
+ selectBrand: h,
134
+ clearBrand: f
135
+ };
136
+ }, ut = w.createLogger({
137
+ name: "HoldToPourStrategy",
138
+ group: "kos-hooks"
139
+ }), De = {
140
+ name: "HoldToPourStrategy",
141
+ async initiate(e) {
142
+ if (!(e != null && e.canPour)) {
143
+ ut.debug(`Nozzle ${e == null ? void 0 : e.id} cannot pour. Returning early.`);
144
+ return;
145
+ }
146
+ await (e == null ? void 0 : e.pour());
147
+ },
148
+ async initiateEnded(e) {
149
+ await (e == null ? void 0 : e.cancelPour());
150
+ }
151
+ }, Q = w.createLogger({
152
+ name: "useNozzlePour",
153
+ group: "kos-hooks"
154
+ }), lt = ({
155
+ onPour: e,
156
+ onPourCancel: t,
157
+ onBeforePour: r,
158
+ onBeforePourRejected: n,
159
+ strategy: s = De
160
+ }) => {
161
+ const { model: o } = C(), d = i(async () => {
162
+ (r ? await (r == null ? void 0 : r()) : !0) ? (Q.debug(
163
+ `[${s == null ? void 0 : s.name}] - Pour initiated for nozzle ${o == null ? void 0 : o.id}.`
164
+ ), s == null || s.initiate(o), e == null || e()) : (Q.debug(
165
+ `[${s == null ? void 0 : s.name}] - Did not pass onBeforePour gate for nozzle ${o == null ? void 0 : o.id}. Cancelling pour.`
166
+ ), n == null || n());
167
+ }, [e, o, s, r, t]), p = i(() => {
168
+ var c;
169
+ Q.debug(
170
+ `[${s == null ? void 0 : s.name}] - Pour initiate ended called for nozzle ${o == null ? void 0 : o.id}.`
171
+ ), (c = s == null ? void 0 : s.initiateEnded) == null || c.call(s, o), t == null || t();
172
+ }, [t, o, s]), h = i(() => {
173
+ Q.debug(`Force cancelling pour for nozzle ${o == null ? void 0 : o.id}.`), o == null || o.cancelPour(), t == null || t();
174
+ }, [t, o]);
175
+ return {
176
+ handlers: me({
177
+ onPressed: d,
178
+ onRelease: p
179
+ }).dom,
180
+ cancel: h,
181
+ status: o
182
+ };
183
+ }, pt = ({
184
+ onFlavorSelected: e,
185
+ onFlavorCleared: t,
186
+ companionType: r
187
+ }) => {
188
+ const { model: n } = C(), s = P(
189
+ () => (n == null ? void 0 : n.getGroupAvailabilityItems("flavors").filter((c) => c.visible)) ?? [],
190
+ [n]
191
+ ), o = P(() => r ? s.map(
192
+ (c) => pe(c, r)
193
+ ) : [], [s, r]), [d, p] = x([]), h = i(
194
+ async (c) => {
195
+ if (p(
196
+ (m) => m != null && m.includes(c) ? [...m.filter((v) => v !== c)] : [...m ?? [], c]
197
+ ), n != null && n.selectedPourable) {
198
+ const { beverage: m } = n.selectedPourable;
199
+ await n.setSelectedPourable({
200
+ beverage: m,
201
+ additional: d ?? []
202
+ });
203
+ }
204
+ e == null || e(c, d ?? []);
205
+ },
206
+ [n, e, d]
207
+ ), f = i(async () => {
208
+ if (p([]), n != null && n.selectedPourable) {
209
+ const { beverage: c } = n.selectedPourable;
210
+ n.setSelectedPourable({ beverage: c }), t == null || t();
211
+ }
212
+ }, [n, t]);
213
+ return {
214
+ flavors: s,
215
+ flavorCompanions: o,
216
+ selectFlavor: h,
217
+ selectedFlavors: d,
218
+ clearFlavors: f
219
+ };
220
+ }, G = "brands", X = "beverages", _ = "flavors", R = w.createLogger({ name: "use-cui-kit" }), mt = ({
221
+ initialGroup: e = G,
222
+ options: t = {}
223
+ }) => {
224
+ var W, q, J;
225
+ const [r, n] = x(e), { model: s } = C(), o = st([]), d = i(
226
+ (l) => {
227
+ n(_);
228
+ const N = `/kos/dispense/${s == null ? void 0 : s.path}/brand/selected/`;
229
+ T.publish(N, l);
230
+ },
231
+ [s == null ? void 0 : s.path]
232
+ ), p = i(() => {
233
+ const l = `/kos/dispense/${s == null ? void 0 : s.path}/brand/cleared/`;
234
+ T.publish(l, {});
235
+ }, [s == null ? void 0 : s.path]), h = i(
236
+ (l) => {
237
+ n(_);
238
+ const N = `/kos/dispense/${s == null ? void 0 : s.path}/beverage/selected/`;
239
+ T.publish(N, l);
240
+ },
241
+ [s == null ? void 0 : s.path]
242
+ ), f = i(() => {
243
+ const l = `/kos/dispense/${s == null ? void 0 : s.path}/beverage/cleared/`;
244
+ T.publish(l, {});
245
+ }, [s == null ? void 0 : s.path]), c = i(
246
+ (l) => {
247
+ const N = `/kos/dispense/${s == null ? void 0 : s.path}/flavor/selected/`;
248
+ T.publish(N, l);
249
+ },
250
+ [s == null ? void 0 : s.path]
251
+ ), m = i(() => {
252
+ const l = `/kos/dispense/${s == null ? void 0 : s.path}/flavor/cleared/`;
253
+ T.publish(l, {});
254
+ }, [s == null ? void 0 : s.path]), v = i(() => {
255
+ const l = `/kos/dispense/${s == null ? void 0 : s.path}/pour/`;
256
+ T.publish(l, {});
257
+ }, [s == null ? void 0 : s.path]), b = i(async () => {
258
+ const l = `/kos/dispense/${s == null ? void 0 : s.path}/pre/pour/`;
259
+ return T.publish(l, {}), await (g == null ? void 0 : g()) || !0;
260
+ }, [s == null ? void 0 : s.path]), a = i(async () => {
261
+ const l = `/kos/dispense/${s == null ? void 0 : s.path}/pre/pour/rejected/`;
262
+ T.publish(l, {});
263
+ }, [s == null ? void 0 : s.path]), $ = i(() => {
264
+ const l = `/kos/dispense/${s == null ? void 0 : s.path}/pour/cancel/`;
265
+ T.publish(l, {});
266
+ }, [s == null ? void 0 : s.path]), { brands: y, selectBrand: H, selectedBrand: K, clearBrand: B, brandCompanions: V } = dt({
267
+ companionType: (W = t.companionTypes) == null ? void 0 : W.brand,
268
+ onBrandSelected: d,
269
+ onBrandCleared: p
270
+ }), {
271
+ beverages: z,
272
+ selectBeverage: ee,
273
+ selectedBeverage: te,
274
+ clearBeverage: I,
275
+ beverageCompanions: D
276
+ } = ct({
277
+ companionType: (q = t.companionTypes) == null ? void 0 : q.beverage,
278
+ onBeverageSelected: h,
279
+ onClearBeverage: f
280
+ }), {
281
+ clearFlavors: se,
282
+ flavors: Y,
283
+ selectFlavor: A,
284
+ selectedFlavors: L,
285
+ flavorCompanions: re
286
+ } = pt({
287
+ companionType: (J = t.companionTypes) == null ? void 0 : J.flavor,
288
+ onFlavorSelected: c,
289
+ onFlavorCleared: m
290
+ }), [g, M] = x(), ne = i((l) => {
291
+ M(() => l);
292
+ }, []), oe = lt({
293
+ onPour: v,
294
+ onPourCancel: $,
295
+ onBeforePour: b,
296
+ onBeforePourRejected: a
297
+ }), ae = i(() => {
298
+ switch (R.debug(`Navigating back from group: ${r}`), r) {
299
+ case G:
300
+ I(), B();
301
+ break;
302
+ case X:
303
+ case _:
304
+ n(e), I(), B();
305
+ break;
306
+ }
307
+ }, [I, B, r, e]), ie = i(() => {
308
+ const l = `/kos/dispense/${s == null ? void 0 : s.path}/home/`;
309
+ T.publish(l, {}), n(e), e === G && (I(), B()), e === X && I();
310
+ }, [I, B, e]), ce = i(() => {
311
+ if (o.current.length === 0) {
312
+ R.debug("No timers to pause.");
313
+ return;
314
+ }
315
+ R.debug(`Pausing ${o.current.length} timers.`), o.current.forEach((l) => {
316
+ R.debug(`Pausing timer with id ${l.id}.`), l.pause();
317
+ });
318
+ }, []), de = i(() => {
319
+ if (o.current.length === 0) {
320
+ R.debug("No timers to restart.");
321
+ return;
322
+ }
323
+ R.debug(`Restarting ${o.current.length} timers.`), o.current.forEach((l) => {
324
+ R.debug(`Restarting timer with id ${l.id}.`), l.restart();
325
+ });
326
+ }, []);
327
+ return {
328
+ timers: {
329
+ add: i((l) => {
330
+ if (l) {
331
+ if (o.current.some((N) => N.id === l.id)) {
332
+ R.debug(`Timer with id ${l.id} already exists.`);
333
+ return;
334
+ }
335
+ o.current.push(l);
336
+ }
337
+ }, []),
338
+ pause: ce,
339
+ restart: de
340
+ },
341
+ nav: {
342
+ currentGroup: r,
343
+ back: ae,
344
+ home: ie
345
+ },
346
+ pour: oe,
347
+ updateOnBeforePour: ne,
348
+ selections: {
349
+ [G]: K,
350
+ [X]: te,
351
+ [_]: L
352
+ },
353
+ [G]: {
354
+ models: y,
355
+ companions: V,
356
+ clear: B,
357
+ handlers: {
358
+ onSelected: H
359
+ }
360
+ },
361
+ [X]: {
362
+ models: z,
363
+ companions: D,
364
+ clear: I,
365
+ handlers: {
366
+ onSelected: ee
367
+ }
368
+ },
369
+ [_]: {
370
+ models: Y,
371
+ companions: re,
372
+ clear: se,
373
+ handlers: {
374
+ onSelected: A
375
+ }
376
+ }
377
+ };
378
+ }, ht = (e) => {
379
+ const { model: t } = C(), [r, n] = x(null), {
380
+ onAmbientTimer: s,
381
+ onAttractTimer: o,
382
+ onResetAttractTimer: d,
383
+ onResumeAttractTimer: p,
384
+ defaultAttractTime: h,
385
+ defaultAmbientTime: f
386
+ } = e, c = i(() => {
387
+ s && (w.info("Ambient timer expired. Calling callback"), s == null || s());
388
+ }, [s]), m = i(() => {
389
+ o && (w.info("Attract timer expired. Calling callback"), o == null || o());
390
+ }, [o]), v = i(() => {
391
+ r && (r.restart(), d == null || d());
392
+ }, [r, d]), b = i(() => {
393
+ r && (r.reset(), d == null || d());
394
+ }, [r, d]), a = i(() => {
395
+ r && (r.pause(), p == null || p());
396
+ }, [r, p]);
397
+ return U(() => {
398
+ if (t && h) {
399
+ w.info("Nozzle is available. Creating timers");
400
+ const $ = He.createTimer(
401
+ "attract-timer-" + t.path,
402
+ h
403
+ );
404
+ return h && ($ == null || $.addTimeoutAction({
405
+ name: "attract-timer",
406
+ remainingTime: 0,
407
+ action: m
408
+ })), f && ($ == null || $.addTimeoutAction({
409
+ name: "ambient-timer",
410
+ remainingTime: f,
411
+ action: c
412
+ })), h && ($ == null || $.start()), n($ ?? null), () => {
413
+ $ == null || $.reset(), n(null);
414
+ };
415
+ }
416
+ return () => {
417
+ w.info("Nozzle is not available. No timers to clear");
418
+ };
419
+ }, [
420
+ f,
421
+ h,
422
+ c,
423
+ m,
424
+ t
425
+ ]), {
426
+ attractTimer: r,
427
+ restart: v,
428
+ pause: b,
429
+ resume: a
430
+ };
431
+ }, ft = (e, t) => {
432
+ if (t)
433
+ return T.subscribe(e, t).unsubscribe;
434
+ }, bt = ({
435
+ onInit: e,
436
+ onBrandSelected: t,
437
+ onBrandCleared: r,
438
+ onBeverageCleared: n,
439
+ onBeverageSelected: s,
440
+ onFlavorCleared: o,
441
+ onFlavorSelected: d,
442
+ onReturnToHome: p,
443
+ onPour: h,
444
+ onPourCancel: f,
445
+ onBeforePourRejected: c,
446
+ onAmbientTimer: m,
447
+ onAttractTimer: v,
448
+ onResumeAttractTimer: b
449
+ }) => {
450
+ const { model: a } = C();
451
+ U(() => {
452
+ const y = [
453
+ {
454
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/brand/selected/`,
455
+ callback: t
456
+ },
457
+ {
458
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/brand/cleared/`,
459
+ callback: r
460
+ },
461
+ {
462
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/beverage/selected/`,
463
+ callback: s
464
+ },
465
+ {
466
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/beverage/cleared/`,
467
+ callback: n
468
+ },
469
+ {
470
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/flavor/selected/`,
471
+ callback: d
472
+ },
473
+ {
474
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/flavor/cleared/`,
475
+ callback: o
476
+ },
477
+ { topic: `/kos/dispense/${a == null ? void 0 : a.path}/pour/`, callback: h },
478
+ {
479
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/pour/cancel/`,
480
+ callback: f
481
+ },
482
+ {
483
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/pre/pour/rejected/`,
484
+ callback: c
485
+ },
486
+ {
487
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/ambient/start/`,
488
+ callback: m
489
+ },
490
+ {
491
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/attract/start/`,
492
+ callback: v
493
+ },
494
+ {
495
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/attract/resume/`,
496
+ callback: b
497
+ },
498
+ {
499
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/init/`,
500
+ callback: e
501
+ },
502
+ {
503
+ topic: `/kos/dispense/${a == null ? void 0 : a.path}/home/`,
504
+ callback: p
505
+ }
506
+ ].map(
507
+ ({ topic: H, callback: K }) => ft(H, K)
508
+ );
509
+ return () => {
510
+ y.forEach((H) => H == null ? void 0 : H());
511
+ };
512
+ }, [
513
+ a == null ? void 0 : a.path,
514
+ m,
515
+ v,
516
+ n,
517
+ s,
518
+ r,
519
+ t,
520
+ o,
521
+ d,
522
+ h,
523
+ f,
524
+ b,
525
+ e,
526
+ p
527
+ ]);
528
+ }, Ee = (e) => {
529
+ const { model: t } = C(), [r, n] = x(null), {
530
+ onAreYouThereTimer: s,
531
+ onIdleTimer: o,
532
+ onResetIdleTimer: d,
533
+ defaultAreYouThereTime: p = 10,
534
+ defaultIdleTime: h = 20
535
+ } = e, f = i(() => {
536
+ s && (w.info("Are you there timer expired. Calling callback"), s == null || s());
537
+ }, [s]), c = i(() => {
538
+ o && (w.info("Idle timer expired. Calling callback"), o == null || o());
539
+ }, [o]), m = i(() => {
540
+ r && (r.restart(), d == null || d());
541
+ }, [r, d]), v = i(() => {
542
+ r && (r.reset(), d == null || d());
543
+ }, [r, d]);
544
+ return U(() => {
545
+ if (t) {
546
+ w.info("Nozzle is available. Creating timers");
547
+ const b = He.createTimer(
548
+ `${e.prefix ?? ""}idle-timer-${t.path}`,
549
+ h
550
+ );
551
+ return b == null || b.addTimeoutAction({
552
+ name: "idle-timer",
553
+ remainingTime: 0,
554
+ action: c
555
+ }), b == null || b.addTimeoutAction({
556
+ name: "are-you-there-timer",
557
+ remainingTime: p,
558
+ action: f
559
+ }), n(b ?? null), () => {
560
+ b == null || b.reset(), n(null);
561
+ };
562
+ }
563
+ return () => {
564
+ w.info("Nozzle is not available. No timers to clear");
565
+ };
566
+ }, [
567
+ p,
568
+ h,
569
+ f,
570
+ c,
571
+ t,
572
+ e.prefix
573
+ ]), {
574
+ idleTimer: r,
575
+ restart: m,
576
+ pause: v
577
+ };
578
+ }, Dt = ({
579
+ kit: e,
580
+ inactivity: t,
581
+ pour: r,
582
+ screens: n
583
+ }) => {
584
+ var N, fe, be, ve;
585
+ const [s, o] = x(!1), [d, p] = x(!1), [h, f] = x(!1), { model: c } = C(), [m, v] = x(!1), b = (t == null ? void 0 : t.idleTimeout) ?? 15, a = (t == null ? void 0 : t.areYouThereTimeoutOffset) ?? 10, $ = (r == null ? void 0 : r.idleTimeout) ?? (t == null ? void 0 : t.idleTimeout) ?? 10, y = (r == null ? void 0 : r.areYouThereTimeoutOffset) ?? (t == null ? void 0 : t.areYouThereTimeoutOffset) ?? 5, H = n == null ? void 0 : n.ambientTimeoutOffset, K = n == null ? void 0 : n.attractTimeout, B = i(() => {
586
+ o(!0);
587
+ }, []), V = i(() => {
588
+ o(!1), e == null || e.nav.home();
589
+ }, [(N = e == null ? void 0 : e.nav) == null ? void 0 : N.home]), z = i(() => {
590
+ H && (p(!0), f(!1));
591
+ }, [H]), ee = i(() => {
592
+ K && (f(!0), p(!1));
593
+ }, [K]), te = i(() => {
594
+ K && (f(!1), p(!1), e == null || e.nav.home());
595
+ }, [e == null ? void 0 : e.nav, K]), {
596
+ pause: I,
597
+ restart: D,
598
+ resume: se,
599
+ attractTimer: Y
600
+ } = ht({
601
+ defaultAmbientTime: H,
602
+ defaultAttractTime: K,
603
+ onAmbientTimer: z,
604
+ onAttractTimer: ee,
605
+ onResumeAttractTimer: te
606
+ });
607
+ (fe = e == null ? void 0 : e.timers) == null || fe.add(Y);
608
+ const { pause: A, restart: L, idleTimer: re } = Ee({
609
+ defaultAreYouThereTime: a,
610
+ defaultIdleTime: b,
611
+ onAreYouThereTimer: B,
612
+ onIdleTimer: V
613
+ });
614
+ (be = e == null ? void 0 : e.timers) == null || be.add(re);
615
+ const {
616
+ pause: g,
617
+ restart: M,
618
+ idleTimer: ne
619
+ } = Ee({
620
+ defaultAreYouThereTime: y,
621
+ defaultIdleTime: $,
622
+ onAreYouThereTimer: B,
623
+ onIdleTimer: V,
624
+ prefix: "pour-"
625
+ });
626
+ (ve = e == null ? void 0 : e.timers) == null || ve.add(ne);
627
+ const oe = i(() => {
628
+ v(!1), g(), A();
629
+ }, [A, g]), ae = i(() => {
630
+ v(!0), console.log("restarting pour timer"), M(), A();
631
+ }, [A, M]), ie = i(() => {
632
+ v(!1), console.log("restarting pour timer on before pour rejected"), g(), L();
633
+ }, []), ce = i(() => {
634
+ o(!1), m ? (M(), A()) : (L(), g());
635
+ }, [m, A, g, L, M]), de = i(() => {
636
+ I(), f(!1), p(!1), L();
637
+ }, [I, L]), he = i(() => {
638
+ f(!1), p(!1), v(!1), g(), D();
639
+ }, [D, g]), W = i(() => {
640
+ f(!1), p(!1), v(!1), I(), L();
641
+ }, [I, L]), q = i(() => {
642
+ f(!1), p(!1), v(!1), D(), A(), g();
643
+ }, [D, A, g]), J = i(() => {
644
+ f(!1), p(!1), D(), A();
645
+ }, [D, A]);
646
+ bt({
647
+ onBrandSelected: de,
648
+ onBrandCleared: he,
649
+ onBeverageSelected: W,
650
+ onBeverageCleared: q,
651
+ onPour: oe,
652
+ onPourCancel: ae,
653
+ onBeforePourRejected: ie,
654
+ onInit: J
655
+ });
656
+ const l = m ? y : a;
657
+ return U(() => {
658
+ if (c && Y) {
659
+ const Xe = `/kos/dispense/${c == null ? void 0 : c.path}/init/`;
660
+ T.publish(Xe, {});
661
+ }
662
+ }, [c, Y]), {
663
+ showAreYouThere: s,
664
+ clearAreYouThere: ce,
665
+ areYouThereCountdown: l,
666
+ showAmbientScreen: d,
667
+ showAttractScreen: h,
668
+ pauseScreenTimer: se
669
+ };
670
+ }, Re = () => {
671
+ const e = ge.type;
672
+ return E({
673
+ modelId: e,
674
+ modelType: ge.type,
675
+ options: {}
676
+ });
677
+ };
678
+ function Rt(e) {
679
+ return (t) => {
680
+ const { model: r, status: n, KosModelLoader: s } = Re();
681
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, deviceAssembly: r }) });
682
+ };
683
+ }
684
+ const ye = (e) => E({
685
+ modelId: e,
686
+ modelType: ot.type,
687
+ options: {}
688
+ });
689
+ function yt(e, t) {
690
+ return (r) => {
691
+ const { model: n, status: s, KosModelLoader: o } = ye(e);
692
+ return /* @__PURE__ */ u(o, { ...s, children: /* @__PURE__ */ u(t, { ...r, holder: n }) });
693
+ };
694
+ }
695
+ const Me = () => {
696
+ const e = Te.type;
697
+ return E({
698
+ modelId: e,
699
+ modelType: Te.type,
700
+ options: {}
701
+ });
702
+ };
703
+ function Mt(e) {
704
+ return (t) => {
705
+ const { model: r, status: n, KosModelLoader: s } = Me();
706
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, holderContainer: r }) });
707
+ };
708
+ }
709
+ const Ye = () => {
710
+ const e = Ie.type;
711
+ return E({
712
+ modelId: e,
713
+ modelType: Ie.type,
714
+ options: {}
715
+ });
716
+ }, ue = w.createLogger({
717
+ name: "HoldToPourIntentStrategy",
718
+ group: "kos-hooks"
719
+ }), vt = {
720
+ name: "HoldToPourIntentStrategy",
721
+ async initiate(e, t) {
722
+ if (!(e != null && e.canPour)) {
723
+ ue.debug(`${e == null ? void 0 : e.id} cannot pour. Returning early.`);
724
+ return;
725
+ }
726
+ t ? (ue.debug(`performing intent: ${t}`), await (e == null ? void 0 : e.performIntent(t))) : ue.debug("no intent provided. Returning early.");
727
+ },
728
+ async initiateEnded(e) {
729
+ await (e == null ? void 0 : e.cancelPour());
730
+ }
731
+ }, le = w.createLogger({
732
+ name: "useNozzlePour",
733
+ group: "kos-hooks"
734
+ }), Yt = ({
735
+ onPour: e,
736
+ onPourCancel: t,
737
+ intentContainer: r,
738
+ strategy: n = vt
739
+ }) => {
740
+ const s = i(() => {
741
+ le.debug(
742
+ `[${n == null ? void 0 : n.name}] - Pour initiated for model ${r == null ? void 0 : r.id}.`
743
+ ), n == null || n.initiate(r), e == null || e();
744
+ }, [e, r, n]), o = i(() => {
745
+ var h;
746
+ le.debug(
747
+ `[${n == null ? void 0 : n.name}] - Pour initiate ended called for nozzle ${r == null ? void 0 : r.id}.`
748
+ ), (h = n == null ? void 0 : n.initiateEnded) == null || h.call(n, r), t == null || t();
749
+ }, [t, r, n]), d = i(() => {
750
+ le.debug(`Force cancelling pour for nozzle ${r == null ? void 0 : r.id}.`), r == null || r.cancelPour(), t == null || t();
751
+ }, [t, r]);
752
+ return {
753
+ handlers: me({
754
+ onPressed: s,
755
+ onRelease: o
756
+ }).dom,
757
+ cancel: d,
758
+ status: r
759
+ };
760
+ };
761
+ function Ot(e) {
762
+ return (t) => {
763
+ const { model: r, status: n, KosModelLoader: s } = Ye();
764
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, ingredient: r }) });
765
+ };
766
+ }
767
+ const Oe = () => {
768
+ const e = Ae.type;
769
+ return E({
770
+ modelId: e,
771
+ modelType: Ae.type,
772
+ options: {}
773
+ });
774
+ };
775
+ function Gt(e) {
776
+ return (t) => {
777
+ const { model: r, status: n, KosModelLoader: s } = Oe();
778
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, ingredientContainer: r }) });
779
+ };
780
+ }
781
+ function _t(e, t) {
782
+ return (r) => {
783
+ const { model: n, status: s, KosModelLoader: o } = Le(e);
784
+ return /* @__PURE__ */ u(o, { ...s, children: /* @__PURE__ */ u(t, { ...r, nozzle: n }) });
785
+ };
786
+ }
787
+ const j = w.createLogger({
788
+ name: "usePour",
789
+ group: "kos-hooks"
790
+ }), jt = ({
791
+ onBeforePour: e,
792
+ onPour: t,
793
+ onPourCancel: r,
794
+ onPourAbort: n,
795
+ pourTarget: s,
796
+ strategy: o = De
797
+ }) => {
798
+ const d = i(async () => {
799
+ j.debug(
800
+ `[${o == null ? void 0 : o.name}] - calling before pour for pour target ${s == null ? void 0 : s.id}.`
801
+ ), (e ? await (e == null ? void 0 : e()) : !0) ? (j.debug(
802
+ `[${o == null ? void 0 : o.name}] - Pour initiated for pour target ${s == null ? void 0 : s.id}.`
803
+ ), await (o == null ? void 0 : o.initiate(s)), t == null || t(), s != null && s.isPouring || n == null || n()) : (j.debug(
804
+ `[${o == null ? void 0 : o.name}] - Pour cancelled for pour target ${s == null ? void 0 : s.id}.`
805
+ ), r == null || r());
806
+ }, [t, s, o]), p = i(async () => {
807
+ var m;
808
+ j.debug(
809
+ `[${o == null ? void 0 : o.name}] - Pour initiate ended called for pour target ${s == null ? void 0 : s.id}.`
810
+ ), await ((m = o == null ? void 0 : o.initiateEnded) == null ? void 0 : m.call(o, s)) || r == null || r();
811
+ }, [r, s, o]), h = i(async () => {
812
+ j.debug(`Force cancelling pour for pour target ${s == null ? void 0 : s.id}.`), await (s == null ? void 0 : s.cancelPour()), r == null || r();
813
+ }, [r, s]);
814
+ return {
815
+ handlers: me({
816
+ onPressed: d,
817
+ onRelease: p
818
+ }).dom,
819
+ cancel: h,
820
+ status: s
821
+ };
822
+ }, F = w.createLogger({
823
+ name: "TapOrHoldIntentStrategy",
824
+ group: "kos-hooks"
825
+ });
826
+ class Ft {
827
+ constructor(t) {
828
+ O(this, "intent");
829
+ O(this, "name", "TapOrHoldIntentStrategy");
830
+ O(this, "isHold", !1);
831
+ O(this, "disposer", null);
832
+ this.intent = t;
833
+ }
834
+ async initiate(t, r) {
835
+ if (this.disposer = setTimeout(() => {
836
+ this.isHold = !0;
837
+ }, 250), t != null && t.isPouring && !this.isHold) {
838
+ F.debug("additional tap detected. cancelling pour"), await t.cancelPour();
839
+ return;
840
+ }
841
+ if (!(t != null && t.canPour)) {
842
+ F.debug(`${t == null ? void 0 : t.id} cannot pour. Returning early.`);
843
+ return;
844
+ }
845
+ r ? (F.debug(`performing intent: ${r}`), await (t == null ? void 0 : t.performIntent(r))) : F.debug("no intent provided. Returning early.");
846
+ }
847
+ async initiateEnded(t) {
848
+ return this.disposer && clearTimeout(this.disposer), this.disposer = null, this.isHold ? (await (t == null ? void 0 : t.cancelPour()), !1) : (F.debug("Tap detected. don't cancel and return."), !0);
849
+ }
850
+ }
851
+ const Z = w.createLogger({
852
+ name: "TapToPourIntentStrategy",
853
+ group: "kos-hooks"
854
+ }), Ut = {
855
+ name: "TapToPourIntentStrategy",
856
+ async initiate(e, t) {
857
+ if (e != null && e.isPouring) {
858
+ Z.debug(`Nozzle ${e == null ? void 0 : e.id} is already pouring. cancelling pour`), await e.cancelPour();
859
+ return;
860
+ }
861
+ if (!(e != null && e.canPour)) {
862
+ Z.debug(`Nozzle ${e == null ? void 0 : e.id} cannot pour. Returning early.`);
863
+ return;
864
+ }
865
+ t ? (Z.debug(`performing intent: ${t}`), await (e == null ? void 0 : e.performIntent(t))) : Z.debug("no intent provided. Returning early.");
866
+ },
867
+ async initiateEnded(e) {
868
+ return !0;
869
+ }
870
+ }, ke = w.createLogger({
871
+ name: "HoldToPourStrategy",
872
+ group: "kos-hooks"
873
+ }), Vt = {
874
+ name: "TapToPourStrategy",
875
+ async initiate(e) {
876
+ if (e != null && e.isPouring) {
877
+ ke.debug(`Nozzle ${e == null ? void 0 : e.id} is already pouring. cancelling pour`), await e.cancelPour();
878
+ return;
879
+ }
880
+ if (!(e != null && e.canPour)) {
881
+ ke.debug(`Nozzle ${e == null ? void 0 : e.id} cannot pour. Returning early.`);
882
+ return;
883
+ }
884
+ await (e == null ? void 0 : e.pour());
885
+ },
886
+ async initiateEnded(e) {
887
+ return !0;
888
+ }
889
+ }, $t = (e, t, r) => E({
890
+ modelId: e,
891
+ modelType: at.type,
892
+ options: {
893
+ servicePathFactory: t,
894
+ selectedId: r
895
+ }
896
+ });
897
+ function Wt(e) {
898
+ return (t) => {
899
+ const { model: r, status: n, KosModelLoader: s } = $t(
900
+ t.id,
901
+ t.servicePathFactory,
902
+ t.itemId
903
+ );
904
+ return /* @__PURE__ */ u(s, { ...n, children: /* @__PURE__ */ u(e, { ...t, genericPour: r }) });
905
+ };
906
+ }
907
+ const Ge = S(void 0), qt = ({ children: e }) => {
908
+ const { model: t, ready: r } = Se(), n = P(() => r && t ? { model: t } : {}, [r, t]);
909
+ return /* @__PURE__ */ u(Ge.Provider, { value: n, children: e });
910
+ }, Jt = () => {
911
+ const e = k(
912
+ Ge
913
+ );
914
+ if (!e)
915
+ throw new Error(
916
+ "useAssemblyContext must be used within a AssemblyProvider"
917
+ );
918
+ return e;
919
+ }, _e = S(void 0), Qt = ({ children: e }) => {
920
+ const { model: t, ready: r } = Ne(), n = P(() => r && t ? { model: t } : {}, [r, t]);
921
+ return /* @__PURE__ */ u(_e.Provider, { value: n, children: e });
922
+ }, Xt = () => {
923
+ const e = k(_e);
924
+ if (!e)
925
+ throw new Error(
926
+ "useAvailabilityContext must be used within a AvailabilityProvider"
927
+ );
928
+ return e;
929
+ }, je = S(void 0), Zt = ({ children: e, id: t }) => {
930
+ const { model: r, ready: n } = Ke(t), s = P(() => n && r ? { model: r } : {}, [n, r]);
931
+ return /* @__PURE__ */ u(je.Provider, { value: s, children: e });
932
+ }, zt = () => {
933
+ const e = k(je);
934
+ if (!e)
935
+ throw new Error("useBoardContext must be used within a BoardProvider");
936
+ return e;
937
+ }, Fe = S(void 0), es = ({ children: e }) => {
938
+ const { model: t, ready: r } = Be(), n = P(() => r && t ? { model: t } : {}, [r, t]);
939
+ return /* @__PURE__ */ u(Fe.Provider, { value: n, children: e });
940
+ }, ts = () => {
941
+ const e = k(Fe);
942
+ if (!e)
943
+ throw new Error(
944
+ "useBoardContainerContext must be used within a BoardContainerProvider"
945
+ );
946
+ return e;
947
+ }, Ue = S(
948
+ void 0
949
+ ), wt = ({ children: e }) => {
950
+ const { model: t, ready: r } = Re(), n = P(() => {
951
+ if (r && t) {
952
+ const o = t.nozzlePaths;
953
+ return { model: t, nozzlePaths: o };
954
+ }
955
+ return {};
956
+ }, [r, t]), s = r && t ? e : null;
957
+ return /* @__PURE__ */ u(Ue.Provider, { value: n, children: s });
958
+ }, Pt = () => {
959
+ const e = k(Ue);
960
+ if (!e)
961
+ throw new Error(
962
+ "useDeviceAssemblyContext must be used within a DeviceAssemblyProvider"
963
+ );
964
+ return e;
965
+ };
966
+ function gt() {
967
+ const e = tt.createContext(null);
968
+ return [() => {
969
+ const r = k(e);
970
+ if (r === void 0)
971
+ throw new Error("useDispenseKitContext must be used within a Provider");
972
+ return r;
973
+ }, e.Provider];
974
+ }
975
+ function Tt({ children: e, provider: t, props: r }) {
976
+ const n = mt(r);
977
+ return /* @__PURE__ */ u(t, { value: n, children: e({}) });
978
+ }
979
+ function It({
980
+ children: e,
981
+ provider: t,
982
+ props: r
983
+ }) {
984
+ const { nozzlePaths: n } = Pt();
985
+ return (n == null ? void 0 : n.map((o) => /* @__PURE__ */ u(it, { path: o, children: /* @__PURE__ */ u(
986
+ Tt,
987
+ {
988
+ provider: t,
989
+ props: r,
990
+ children: e
991
+ }
992
+ ) }, o))) || [];
993
+ }
994
+ function At({
995
+ provider: e,
996
+ props: t
997
+ }) {
998
+ return ({ children: r }) => e ? /* @__PURE__ */ u(wt, { children: /* @__PURE__ */ u(
999
+ It,
1000
+ {
1001
+ provider: e,
1002
+ props: t,
1003
+ children: r
1004
+ }
1005
+ ) }) : null;
1006
+ }
1007
+ function ss(e) {
1008
+ const [t, r] = gt();
1009
+ return [
1010
+ t,
1011
+ At({ provider: r, props: e })
1012
+ ];
1013
+ }
1014
+ const Ve = S(void 0), rs = ({ children: e, id: t }) => {
1015
+ const { model: r, ready: n } = ye(t || ""), s = P(() => n && r ? { model: r } : {}, [n, r]);
1016
+ return /* @__PURE__ */ u(Ve.Provider, { value: s, children: e });
1017
+ }, ns = () => {
1018
+ const e = k(Ve);
1019
+ if (!e)
1020
+ throw new Error("useHolderContext must be used within a HolderProvider");
1021
+ return e;
1022
+ }, We = S(
1023
+ void 0
1024
+ ), os = ({ children: e }) => {
1025
+ const { model: t, ready: r } = Me(), n = P(() => r && t ? { model: t } : {}, [r, t]);
1026
+ return /* @__PURE__ */ u(We.Provider, { value: n, children: e });
1027
+ }, as = () => {
1028
+ const e = k(We);
1029
+ if (!e)
1030
+ throw new Error(
1031
+ "useHolderContainerContext must be used within a HolderContainerProvider"
1032
+ );
1033
+ return e;
1034
+ }, qe = S(void 0), is = ({ children: e }) => {
1035
+ const { model: t, ready: r } = Ye(), n = P(() => r && t ? { model: t } : {}, [r, t]);
1036
+ return /* @__PURE__ */ u(qe.Provider, { value: n, children: e });
1037
+ }, cs = () => {
1038
+ const e = k(qe);
1039
+ if (!e)
1040
+ throw new Error(
1041
+ "useIngredientContext must be used within a IngredientProvider"
1042
+ );
1043
+ return e;
1044
+ }, Je = S(
1045
+ void 0
1046
+ ), ds = ({ children: e }) => {
1047
+ const { model: t, ready: r } = Oe(), n = P(() => r && t ? { model: t } : {}, [r, t]);
1048
+ return /* @__PURE__ */ u(Je.Provider, { value: n, children: e });
1049
+ }, us = () => {
1050
+ const e = k(Je);
1051
+ if (!e)
1052
+ throw new Error(
1053
+ "useIngredientContainerContext must be used within a IngredientContainerProvider"
1054
+ );
1055
+ return e;
1056
+ }, xt = () => {
1057
+ const e = xe.type;
1058
+ return E({
1059
+ modelId: e,
1060
+ modelType: xe.type,
1061
+ options: {}
1062
+ });
1063
+ }, Qe = S(void 0), ls = ({ children: e }) => {
1064
+ const { model: t, ready: r } = xt(), n = P(() => r && t ? { model: t } : {}, [r, t]);
1065
+ return /* @__PURE__ */ u(Qe.Provider, { value: n, children: e });
1066
+ }, ps = () => {
1067
+ const e = k(Qe);
1068
+ if (!e)
1069
+ throw new Error("usePumpContext must be used within a PumpProvider");
1070
+ return e;
1071
+ };
1072
+ export {
1073
+ Gt as $,
1074
+ qt as A,
1075
+ Zt as B,
1076
+ Tt as C,
1077
+ wt as D,
1078
+ dt as E,
1079
+ G as F,
1080
+ X as G,
1081
+ rs as H,
1082
+ is as I,
1083
+ _ as J,
1084
+ mt as K,
1085
+ Dt as L,
1086
+ bt as M,
1087
+ it as N,
1088
+ Ee as O,
1089
+ ls as P,
1090
+ pt as Q,
1091
+ Re as R,
1092
+ Rt as S,
1093
+ ye as T,
1094
+ yt as U,
1095
+ Me as V,
1096
+ Mt as W,
1097
+ Ye as X,
1098
+ Yt as Y,
1099
+ Ot as Z,
1100
+ Oe as _,
1101
+ Qt as a,
1102
+ Le as a0,
1103
+ _t as a1,
1104
+ lt as a2,
1105
+ jt as a3,
1106
+ vt as a4,
1107
+ De as a5,
1108
+ Ft as a6,
1109
+ Ut as a7,
1110
+ Vt as a8,
1111
+ $t as a9,
1112
+ Wt as aa,
1113
+ Xt as b,
1114
+ zt as c,
1115
+ es as d,
1116
+ ts as e,
1117
+ At as f,
1118
+ Pt as g,
1119
+ ns as h,
1120
+ ss as i,
1121
+ os as j,
1122
+ as as k,
1123
+ cs as l,
1124
+ ds as m,
1125
+ us as n,
1126
+ C as o,
1127
+ ps as p,
1128
+ Se as q,
1129
+ Ne as r,
1130
+ Bt as s,
1131
+ Ke as t,
1132
+ Jt as u,
1133
+ Lt as v,
1134
+ Kt as w,
1135
+ Be as x,
1136
+ Ct as y,
1137
+ ct as z
1138
+ };
1139
+ //# sourceMappingURL=pump-provider-CiU4D_1r.js.map