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