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