@kosdev-code/kos-dispense-sdk 2.0.22 → 2.0.23

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