@kosdev-code/kos-dispense-sdk 2.0.11 → 2.0.15

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