@kosdev-code/kos-dispense-sdk 2.0.34 → 2.0.35

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