@kosdev-code/kos-dispense-sdk 2.0.18 → 2.0.20

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