@kosdev-code/kos-dispense-sdk 2.0.17 → 2.0.19

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