@kosdev-code/kos-dispense-sdk 2.1.38 → 2.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dispense-registration-manager-C6k10ipu.cjs +2698 -0
  2. package/dispense-registration-manager-C6k10ipu.cjs.map +1 -0
  3. package/dispense-registration-manager-lJlcyq5G.js +2700 -0
  4. package/dispense-registration-manager-lJlcyq5G.js.map +1 -0
  5. package/{extension-utils-DrsPfQWC.js → extension-utils-AS0Z5eod.js} +194 -157
  6. package/{extension-utils-DrsPfQWC.js.map → extension-utils-AS0Z5eod.js.map} +1 -1
  7. package/extension-utils-DNbm2KRk.cjs +500 -0
  8. package/{extension-utils-BDyaRwRN.cjs.map → extension-utils-DNbm2KRk.cjs.map} +1 -1
  9. package/index.cjs +142 -1
  10. package/index.cjs.map +1 -1
  11. package/index.js +124 -121
  12. package/index.js.map +1 -1
  13. package/kos-models.json +1 -1
  14. package/models/models/assembly/holder-utils.d.ts.map +1 -1
  15. package/models/models/holder/holder-model.d.ts.map +1 -1
  16. package/models/models/holder/types/index.d.ts +2 -0
  17. package/models/models/nozzle/nozzle-model.d.ts +1 -0
  18. package/models/models/nozzle/nozzle-model.d.ts.map +1 -1
  19. package/models/models/types/assembly.d.ts +1 -0
  20. package/models/models/types/assembly.d.ts.map +1 -1
  21. package/models.cjs +47 -1
  22. package/models.cjs.map +1 -1
  23. package/models.js +40 -40
  24. package/package.json +14 -2
  25. package/pump-provider-BSEusYig.js +1825 -0
  26. package/{pump-provider-Bytd6qXc.js.map → pump-provider-BSEusYig.js.map} +1 -1
  27. package/pump-provider-D4Ed_gH6.cjs +1824 -0
  28. package/{pump-provider-CTELJBW5.cjs.map → pump-provider-D4Ed_gH6.cjs.map} +1 -1
  29. package/ui.cjs +73 -1
  30. package/ui.cjs.map +1 -1
  31. package/ui.js +67 -67
  32. package/dispense-registration-manager-Cj0565Ze.cjs +0 -2
  33. package/dispense-registration-manager-Cj0565Ze.cjs.map +0 -1
  34. package/dispense-registration-manager-CzAqcL8D.js +0 -2044
  35. package/dispense-registration-manager-CzAqcL8D.js.map +0 -1
  36. package/extension-utils-BDyaRwRN.cjs +0 -2
  37. package/pump-provider-Bytd6qXc.js +0 -1308
  38. package/pump-provider-CTELJBW5.cjs +0 -2
@@ -1,2044 +0,0 @@
1
- var ut = Object.defineProperty;
2
- var yt = (e, t, r) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var o = (e, t, r) => (yt(e, typeof t != "symbol" ? t + "" : t, r), r);
4
- import { kosModel as P, Kos as v, isKosModel as b, resolveServiceUrl as D, ServiceFactory as T, KosLog as m, KosModelContainer as S, KosExtensionUtils as U, kosChild as _, FetchError as Pt, ExtensionManager as y, EXTENSION_TROUBLE_MAPPER as Me, EXTENSION_TROUBLE_DATA_MAPPER as te, getKosModelSync as x, kosDependency as Be, kosTroubleAware as It, kosAction as O, kosTopicHandler as re, DependencyLifecycle as pe, getKosModel as Ge, FutureManager as ge, kosFuture as he, FutureHandler as je, EXTENSION_FEATURE_FLAG_RESOLVER as mt, isKosDataModel as ft, ChildModels as vt, KosFeatureFlags as bt, kosParentAware as Ot, createPropKey as _t, kosStateEntry as ue, kosStateExit as ye, kosStateGuard as ae, kosLoggerAware as Fe, kosStateMachine as He, MultipleFutureHandler as Et, arraysEqual as Mt, getAllKosCompanionModels as z, EventBus as $, KosContextManager as wt, destroyKosModel as Rt, SingletonKosModelRegistrationFactory as Ct, kosFutureAware as $t, ObservableData as Se, KosModelRegistrationFactory as Nt, KosModelRegistry as Dt, RegistrationManager as R, registerCoreModels as Tt, registerLegacyModel as St } from "@kosdev-code/kos-ui-sdk";
5
- import "react";
6
- var h = /* @__PURE__ */ ((e) => (e.IngredientLoader = "kos.ingredient.loader", e.IngredientMapper = "kos.ingredient.mapper", e.IngredientIndex = "kos.ingredient.index", e.IngredientTypeMapper = "kos.ingredient.type.mapper", e.HolderTypeMapper = "kos.holder.type.mapper", e.HolderMapper = "kos.holder.mapper", e.HolderIndex = "kos.holder.index", e.HolderIngredientMapper = "kos.holder.ingredient.mapper", e.AvailabilityMapper = "kos.availability.mapper", e.AvailabilityLoader = "kos.availability.loader", e.SelectedPourableMapper = "kos.selected.pourable.mapper", e.AssemblyMapper = "kos.assembly.mapper", e.BoardMapper = "kos.board.mapper", e.BoardIndex = "kos.board.index", e.PumpIndex = "kos.pump.index", e.AssemblyFeatureFlags = "kos.assembly.feature.flags", e))(h || {}), L = /* @__PURE__ */ ((e) => (e.Nozzle = "nozzle-model", e.Availability = "availability-model", e.Holder = "holder-model", e.HolderContainer = "holder-container-model", e.IngredientContainer = "ingredient-container-model", e.Ingredient = "ingredient-model", e.Pump = "pump-model", e.PumpContainer = "pump-container-model", e))(L || {}), Lt = Object.getOwnPropertyDescriptor, At = (e, t, r, a) => {
7
- for (var i = a > 1 ? void 0 : a ? Lt(t, r) : t, s = e.length - 1, n; s >= 0; s--)
8
- (n = e[s]) && (i = n(i) || i);
9
- return i;
10
- };
11
- const H = "ingredient-model";
12
- let be = class {
13
- constructor(e, {
14
- name: t,
15
- type: r,
16
- data: a,
17
- ingredientId: i,
18
- ...s
19
- }) {
20
- o(this, "id");
21
- o(this, "ingredientId");
22
- o(this, "name");
23
- o(this, "type");
24
- o(this, "data");
25
- this.id = e, this.ingredientId = i, this.name = t, this.type = r, this.data = a, Object.assign(this, s);
26
- }
27
- updateModel({
28
- name: e,
29
- type: t,
30
- data: r,
31
- ingredientId: a,
32
- ...i
33
- }) {
34
- this.name = e, this.type = t, this.ingredientId = a, this.data = r, Object.assign(this, i);
35
- }
36
- // -------------------LIFECYCLE----------------------------
37
- // -------------------ENTITY----------------------------
38
- };
39
- be = At([
40
- P(H)
41
- ], be);
42
- const Ve = {
43
- registration: {
44
- [H]: {
45
- class: be,
46
- singleton: !1
47
- }
48
- },
49
- type: H,
50
- predicate: b(H),
51
- factory: v.Factory.create(H)
52
- }, { URL: Ke } = D("INGREDIENT_SERVICE"), { getOne: Ut } = T.build({
53
- basePath: `${Ke}/api/ext/dispense/ingredients`
54
- }), zt = async () => await Ut({
55
- urlOverride: `${Ke}/api/ext/dispense/ingredients`
56
- });
57
- var xt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, ke = (e, t, r, a) => {
58
- for (var i = a > 1 ? void 0 : a ? Bt(t, r) : t, s = e.length - 1, n; s >= 0; s--)
59
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
60
- return a && i && xt(t, r, i), i;
61
- };
62
- const V = "ingredient-container-model", Gt = m.createLogger({ name: "ingredient-container-model" });
63
- let se = class {
64
- constructor(e, t) {
65
- o(this, "id");
66
- o(this, "ingredients");
67
- this.id = e, this.ingredients = new S({
68
- indexMap: {
69
- ingredientType: "type"
70
- },
71
- extensionId: h.IngredientIndex,
72
- parentId: e
73
- });
74
- }
75
- updateModel() {
76
- }
77
- // -------------------LIFECYCLE----------------------------
78
- getIngredientsByType(e) {
79
- return this.ingredients.getIndexByKey("ingredientType", e);
80
- }
81
- async load(e) {
82
- var i;
83
- Gt.debug(`loading ingredient container ${this.id}`);
84
- const t = await zt();
85
- if ((t == null ? void 0 : t.status) !== 200)
86
- throw new Error("Failed to load ingredients");
87
- const r = await U.executeLoaderExtension({
88
- context: e,
89
- extension: h.IngredientLoader
90
- }), a = (t == null ? void 0 : t.data) ?? {};
91
- for (const s of Object.keys(a))
92
- for (const n of ((i = t == null ? void 0 : t.data) == null ? void 0 : i[s]) || []) {
93
- const c = await U.executeDataMapperExtension({
94
- extension: h.IngredientMapper,
95
- data: n,
96
- contextData: r
97
- }), l = await U.executePropertyMapperExtension({
98
- extension: h.IngredientTypeMapper,
99
- data: n,
100
- contextData: r
101
- }), p = {
102
- ...n,
103
- type: l || n.type,
104
- ...c,
105
- data: c
106
- }, u = Ve.factory(n.id)(
107
- p
108
- );
109
- this.ingredients.addModel(u);
110
- }
111
- }
112
- // -------------------ENTITY----------------------------
113
- };
114
- ke([
115
- _
116
- ], se.prototype, "ingredients", 2);
117
- se = ke([
118
- P(V)
119
- ], se);
120
- const Ye = {
121
- registration: {
122
- [V]: {
123
- class: se,
124
- singleton: !0
125
- }
126
- },
127
- type: V,
128
- predicate: b(V),
129
- factory: v.Singleton.create(V)
130
- }, { URL: Pe } = D("HOLDER_SERVICE"), { getAll: jt, postModel: Ze, deleteModel: Ft } = T.build({
131
- basePath: `${Pe}/api/kos/holders`
132
- }), Ht = m.createLogger({
133
- name: "holder-service",
134
- group: "Services"
135
- }), da = async () => await jt({}), Vt = async (e, t) => {
136
- if (!e || !t)
137
- throw new Error("Missing holderPath or ingredientId");
138
- return await Ze({
139
- model: { holderPath: e, ingredientId: t },
140
- urlOverride: `${Pe}/api/ext/dispense/assignments`
141
- });
142
- }, Kt = async (e) => {
143
- if (!e)
144
- throw new Error("Missing holderPath");
145
- return await Ft({
146
- id: e,
147
- urlOverride: `${Pe}/api/ext/dispense/assignments/${e}`
148
- });
149
- }, kt = async (e) => {
150
- if (!e)
151
- throw new Error("Missing holderPath");
152
- return Ht.debug(
153
- `sending POST request to /api/ext/dispense/pumpEvents/replaceLine/${e}`
154
- ), await Ze({
155
- model: {},
156
- urlOverride: `${Pe}/api/ext/dispense/pumpEvents/replaceLine/${e}`
157
- });
158
- }, { URL: ne } = D("ASSIGNMENT_SERVICE"), { getAll: Yt, postModel: Xe, deleteModel: Zt } = T.build({
159
- destinationAddress: "",
160
- basePath: `${ne}/api/ext/dispense/assignments`
161
- }), oe = window.kosUseFos, la = async () => await Yt({ fos: oe }), Xt = async (e, t) => {
162
- var i, s, n, c;
163
- const r = JSON.stringify(t), a = `${ne}/api/ext/dispense/assignments`;
164
- try {
165
- const l = await Xe({
166
- model: { holderPath: e, factoryJson: r },
167
- urlOverride: a
168
- });
169
- return (l == null ? void 0 : l.status) === 200 && ((i = l == null ? void 0 : l.data) != null && i.error) ? [l.data.error || "unknownError", l.data] : [void 0, l == null ? void 0 : l.data];
170
- } catch (l) {
171
- if (l instanceof Pt)
172
- return [
173
- ((n = (s = l.payload) == null ? void 0 : s.data) == null ? void 0 : n.error) || "unknownError",
174
- (c = l.payload) == null ? void 0 : c.data
175
- ];
176
- }
177
- return ["unknownError", void 0];
178
- }, ca = async (e) => {
179
- const t = oe ? `${ne}/api/ingredients/assignments/${e.holderPath}` : `${ne}/api/ext/dispense/assignments`;
180
- return await Xe({
181
- model: { ...e, fuelGauge: 680 },
182
- fos: oe,
183
- urlOverride: t
184
- });
185
- }, pa = async (e) => await Zt({ id: e, fos: oe });
186
- var Jt = Object.defineProperty, qt = Object.getOwnPropertyDescriptor, we = (e, t, r, a) => {
187
- for (var i = a > 1 ? void 0 : a ? qt(t, r) : t, s = e.length - 1, n; s >= 0; s--)
188
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
189
- return a && i && Jt(t, r, i), i;
190
- };
191
- const K = L.Holder, Le = m.createLogger({ name: "holder-model" });
192
- y[Me].register(
193
- "holder",
194
- async (e) => {
195
- const t = [];
196
- return t.push(...e.data.holderPaths), t;
197
- }
198
- );
199
- y[te].register(
200
- "pump",
201
- async (e) => {
202
- if (e.data.pumpPath) {
203
- const { model: t } = x(
204
- e.data.pumpPath
205
- );
206
- if (t) {
207
- const r = t.ingredientId ? x(t.ingredientId).model : void 0;
208
- return {
209
- ingredientId: t.ingredientId,
210
- ingredientName: (r == null ? void 0 : r.displayName) ?? ((r == null ? void 0 : r.name) || ""),
211
- childPumpName: t.name
212
- };
213
- }
214
- }
215
- return {};
216
- }
217
- );
218
- y[te].register(
219
- "holder",
220
- async (e) => e.data.holderNames.length > 0 ? {
221
- holderName: e.data.holderNames[0] || ""
222
- } : {}
223
- );
224
- y[te].register(
225
- "container",
226
- async (e) => {
227
- if (e.data.ingredients.length > 0) {
228
- const t = e.data.ingredients[0], { model: r } = x(t);
229
- return {
230
- ingredientName: (r == null ? void 0 : r.displayName) ?? ((r == null ? void 0 : r.name) || ""),
231
- ingredients: e.data.ingredients ? e.data.ingredients : [],
232
- unknonwnIngredientId: e.data.unknonwnIngredientId ?? ""
233
- };
234
- }
235
- return {};
236
- }
237
- );
238
- class Wt extends Error {
239
- constructor(r, a) {
240
- super(a);
241
- o(this, "type");
242
- this.name = "AssignmentError", this.type = r;
243
- }
244
- }
245
- let ee = class {
246
- constructor(e, {
247
- path: t,
248
- name: r,
249
- ingredientSource: a,
250
- ingredientId: i,
251
- ingredientType: s,
252
- slice: n,
253
- group: c,
254
- data: l,
255
- enjoyByDate: p
256
- }, u) {
257
- o(this, "id");
258
- o(this, "path");
259
- o(this, "name");
260
- o(this, "ingredientId");
261
- o(this, "ingredientType");
262
- o(this, "ingredientSource");
263
- o(this, "group");
264
- o(this, "slice");
265
- o(this, "logger");
266
- o(this, "data");
267
- o(this, "enjoyByDate");
268
- o(this, "pumps");
269
- o(this, "ingredientContainer");
270
- this.id = e, this.path = t, this.name = r, this.ingredientType = s, this.ingredientSource = a, this.ingredientId = i, this.group = c, this.slice = n, this.enjoyByDate = p, this.data = l, this.pumps = new S({
271
- parentId: e,
272
- sortKey: "path"
273
- }), this.logger = u.logger;
274
- }
275
- updateModel({
276
- path: e,
277
- name: t,
278
- ingredientSource: r,
279
- ingredientId: a,
280
- ingredientType: i,
281
- group: s,
282
- slice: n,
283
- enjoyByDate: c,
284
- data: l
285
- }) {
286
- this.path = e, this.name = t, this.ingredientId = a, this.ingredientType = i, this.ingredientSource = r, this.enjoyByDate = c, this.slice = n, this.group = s, this.data = l;
287
- }
288
- get hasEnjoyByDate() {
289
- return !!this.enjoyByDate && !this.unassigned;
290
- }
291
- get hasEnjoyByWarning() {
292
- var e;
293
- return ((e = this.troublesByType.EnjoyByTrouble) == null ? void 0 : e.length) > 0;
294
- }
295
- get nozzlePaths() {
296
- return this.pumps.data.map((e) => e.nozzlePath);
297
- }
298
- async cancelPour() {
299
- await Promise.all(
300
- this.pumps.data.filter((e) => e.isPouring).map((e) => e.cancelPour())
301
- );
302
- }
303
- get canPour() {
304
- return !this.shouldDefer && this.pumps.data.every((e) => e.canPour);
305
- }
306
- get isPouring() {
307
- const e = this.pumps.data.some((t) => t.isPouring);
308
- return this.logger.debug(`isPouring: ${!!e}`), e;
309
- }
310
- async performIntent(e) {
311
- const t = typeof e == "string" ? e : e.intent, r = typeof e == "string" ? void 0 : e.pumpPath, a = r ? this.pumps.getModel(r) : this.pumps.data[0];
312
- return a == null ? void 0 : a.performIntent({ intent: t });
313
- }
314
- get pourState() {
315
- return this.pumps.data.reduce((t, r) => r.pouringState ? r.pouringState : t, "");
316
- }
317
- get nozzlePath() {
318
- var e;
319
- return (e = this.pumps.data[0]) == null ? void 0 : e.nozzlePath;
320
- }
321
- get pumpPaths() {
322
- return this.pumps.data.map((e) => e.id);
323
- }
324
- get sortedPumps() {
325
- return this.pumps.data.sort((e, t) => e.virtual && !t.virtual ? -1 : !e.virtual && t.virtual ? 1 : e.name.localeCompare(t.name));
326
- }
327
- get ingredient() {
328
- var t;
329
- return this.ingredientId ? (t = this.ingredientContainer) == null ? void 0 : t.ingredients.getModel(
330
- this.ingredientId
331
- ) : void 0;
332
- }
333
- get ingredientName() {
334
- return this.ingredient ? this.ingredient.displayName ?? this.ingredient.name : this.ingredientId ? "unknown" : "";
335
- }
336
- get previousIngredient() {
337
- var t;
338
- return this.prevIngredientId ? (t = this.ingredientContainer) == null ? void 0 : t.ingredients.getModel(
339
- this.prevIngredientId
340
- ) : void 0;
341
- }
342
- get previousIngredientName() {
343
- return this.previousIngredient ? this.previousIngredient.displayName ?? this.previousIngredient.name : this.prevIngredientId ? "unknown" : "";
344
- }
345
- get prevIngredientId() {
346
- var e, t;
347
- return (t = (e = this.pumps.data) == null ? void 0 : e[0]) == null ? void 0 : t.prevIngredientId;
348
- }
349
- get unassigned() {
350
- return (!this.ingredientId || this.ingredientId === "0") && (!this.prevIngredientId || this.prevIngredientId === "0");
351
- }
352
- get removed() {
353
- return (!this.ingredientId || this.ingredientId === "0") && this.prevIngredientId !== void 0 && this.prevIngredientId !== "0";
354
- }
355
- get maxVolume() {
356
- return this.slice.maxVolMl ?? 0;
357
- }
358
- get remainingVolume() {
359
- return this.slice.currentVolMl ?? 0;
360
- }
361
- get hasMaxVolume() {
362
- return this.slice.maxVolMl !== void 0;
363
- }
364
- get hasRemainingVolume() {
365
- return this.slice.currentVolMl !== void 0;
366
- }
367
- get fillPercent() {
368
- return this.remainingVolume <= 0 ? 0 : Math.floor((this.remainingVolume || 1) / (this.maxVolume || 1) * 100);
369
- }
370
- get hasFuelGuage() {
371
- return this.hasMaxVolume && this.hasRemainingVolume;
372
- }
373
- updateIngredient(e) {
374
- this.ingredientId !== e && O(() => {
375
- this.ingredientId = e;
376
- });
377
- }
378
- async resolveIntentVolume(e) {
379
- const t = this.pumps.data[0];
380
- return t ? t.resolveIntentVolume(e) : { volume: -1 };
381
- }
382
- async overrideRfidCode(e) {
383
- if (!e)
384
- throw new Error("Invalid override");
385
- try {
386
- const [t, r] = await Xt(this.path, e);
387
- if (t)
388
- throw new Wt(
389
- t,
390
- `Failed to perform rfid override on holder ${this.id}`
391
- );
392
- return O(() => {
393
- this.ingredientId = r == null ? void 0 : r.ingredientId;
394
- }), r;
395
- } catch (t) {
396
- throw Le.error(`Failed to perform rfid override on holder ${this.id}`, t), t;
397
- }
398
- }
399
- async assignIngredient(e) {
400
- try {
401
- e ? await Vt(this.path, e) : await Kt(this.path), O(() => {
402
- this.ingredientId = e;
403
- });
404
- } catch (t) {
405
- throw Le.error(`Failed to perform assign ingredient to holder ${this.id}`, t), t;
406
- }
407
- }
408
- /**
409
- * @kosApiLevel 3
410
- */
411
- get shouldDefer() {
412
- return this.troubles.some((e) => e.shouldDefer);
413
- }
414
- async replaceLine() {
415
- await kt(this.path);
416
- }
417
- // -------------------LIFECYCLE----------------------------
418
- // ----------------------------------
419
- // UNCOMMENT FOR TESTING FUEL GAUGE
420
- // ----------------------------------
421
- // async load() {
422
- // const random = Math.max(1000, Math.floor(Math.random() * 5000));
423
- // this.slice.maxVolMl = 1000;
424
- // setInterval(() => {
425
- // kosAction(() => {
426
- // if (this.remainingVolume < -100) {
427
- // this.slice.maxVolMl = 1000;
428
- // this.slice.currentVolMl = this.maxVolume;
429
- // } else {
430
- // this.slice.currentVolMl = this.remainingVolume - 50;
431
- // }
432
- // });
433
- // }, random);
434
- // }
435
- // -------------------ENTITY----------------------------
436
- };
437
- we([
438
- _
439
- ], ee.prototype, "pumps", 2);
440
- we([
441
- Be({ modelType: Ye.type })
442
- ], ee.prototype, "ingredientContainer", 2);
443
- ee = we([
444
- P(K),
445
- It()
446
- ], ee);
447
- const Je = {
448
- registration: {
449
- [K]: {
450
- class: ee,
451
- singleton: !1
452
- }
453
- },
454
- type: K,
455
- predicate: b(K),
456
- factory: v.Factory.create(K)
457
- }, Qt = async (e, t) => {
458
- var Te;
459
- const r = y.propertyMapper.executeMapper(
460
- h.HolderIngredientMapper,
461
- t
462
- ), a = y.propertyMapper.executeMapper(
463
- h.HolderTypeMapper,
464
- t
465
- ) || t.ingType, i = await U.executeDataMapperExtension({
466
- extension: h.HolderMapper,
467
- data: t,
468
- contextData: {}
469
- }), { name: s, path: n, ingredientId: c, ingType: l, ingSource: p, slice: u, ...F } = t, g = { ...F, ...i }, M = u || { pos: 0 }, C = {
470
- name: s,
471
- path: n,
472
- ingredientId: r || c,
473
- ingredientType: a || l,
474
- ingredientSource: p,
475
- enjoyByDate: (Te = t.container) != null && Te.enjoyByDate ? new Date(t.container.enjoyByDate) : void 0,
476
- slice: M,
477
- group: e,
478
- data: g
479
- };
480
- return Je.factory(t.path)(C);
481
- }, { URL: er } = D("ASSEMBLY_SERVICE"), { getOne: tr } = T.build({
482
- basePath: `${er}/api/kos/device/assemblies`
483
- }), rr = m.createLogger({
484
- name: "assembly-service",
485
- group: "Services"
486
- }), qe = async () => (rr.debug("sending GET for assembly"), await tr({}));
487
- var ar = Object.defineProperty, ir = Object.getOwnPropertyDescriptor, Ie = (e, t, r, a) => {
488
- for (var i = a > 1 ? void 0 : a ? ir(t, r) : t, s = e.length - 1, n; s >= 0; s--)
489
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
490
- return a && i && ar(t, r, i), i;
491
- };
492
- const k = "board-container-model", We = "/kos/hardware/board/linked", Qe = "/kos/hardware/board/unlinked";
493
- let B = class {
494
- constructor(e, t, r) {
495
- o(this, "id");
496
- o(this, "logger");
497
- o(this, "models");
498
- this.id = e, this.logger = r.logger, this.models = new S({
499
- parentId: e,
500
- extensionId: h.BoardIndex
501
- });
502
- }
503
- get boardList() {
504
- return this.models.data;
505
- }
506
- updateModel() {
507
- }
508
- addModel(e) {
509
- this.models.addModel(e);
510
- }
511
- removeModel(e) {
512
- this.models.removeModel(e);
513
- }
514
- updateBoard(e) {
515
- const t = e.path, r = this.models.getModel(t);
516
- if (!r) {
517
- this.logger.warn(`board ${t} not found`);
518
- return;
519
- }
520
- r.updateModel(e);
521
- }
522
- handleBoardLinkEvent(e) {
523
- this.logger.debug(`handling ${We} event ${e}`), e ? this.updateBoard(e) : this.logger.debug("- boardLinkEvent is undefined");
524
- }
525
- handleBoardUnlinkEvent(e) {
526
- this.logger.debug(
527
- `handling ${Qe} event ${e}`
528
- ), e ? this.updateBoard(e) : this.logger.debug("- boardLinkEvent is undefined");
529
- }
530
- };
531
- Ie([
532
- _
533
- ], B.prototype, "models", 2);
534
- Ie([
535
- re({
536
- lifecycle: pe.INIT,
537
- topic: We,
538
- websocket: !0
539
- })
540
- ], B.prototype, "handleBoardLinkEvent", 1);
541
- Ie([
542
- re({
543
- lifecycle: pe.INIT,
544
- topic: Qe,
545
- websocket: !0
546
- })
547
- ], B.prototype, "handleBoardUnlinkEvent", 1);
548
- B = Ie([
549
- P(k)
550
- ], B);
551
- const sr = async (e) => {
552
- const t = e.data.boardPath, { model: r } = x(t);
553
- return {
554
- boardName: (r == null ? void 0 : r.name) || ""
555
- };
556
- };
557
- var nr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, et = (e, t, r, a) => {
558
- for (var i = a > 1 ? void 0 : a ? or(t, r) : t, s = e.length - 1, n; s >= 0; s--)
559
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
560
- return a && i && nr(t, r, i), i;
561
- };
562
- const Y = L.PumpContainer;
563
- var tt = /* @__PURE__ */ ((e) => (e.byBoard = "byBoard", e.byType = "byType", e.byNozzle = "byNozzle", e))(tt || {});
564
- let de = class {
565
- constructor(e, t) {
566
- o(this, "id");
567
- o(this, "pumps");
568
- this.id = e, this.pumps = new S({
569
- indexMap: {
570
- byNozzle: (r) => r.nozzlePaths,
571
- byBoard: (r) => r.boardPath,
572
- byType: "type"
573
- },
574
- parentId: e,
575
- extensionId: h.PumpIndex
576
- });
577
- }
578
- /**
579
- * The collection of pump models.
580
- */
581
- get pumpModels() {
582
- return this.pumps.data;
583
- }
584
- /**
585
- * The collection of pump paths.
586
- */
587
- get pumpPaths() {
588
- return this.pumpModels.map((e) => e.path);
589
- }
590
- addModel(e) {
591
- this.pumps.addModel(e);
592
- }
593
- removeModel(e) {
594
- this.pumps.removeModel(e);
595
- }
596
- getModel(e) {
597
- return this.pumps.getModel(e);
598
- }
599
- get models() {
600
- return this.pumps;
601
- }
602
- get data() {
603
- return this.pumps.data;
604
- }
605
- updateModel() {
606
- }
607
- // -------------------LIFECYCLE----------------------------
608
- async load() {
609
- }
610
- // -------------------ENTITY----------------------------
611
- };
612
- et([
613
- _
614
- ], de.prototype, "pumps", 2);
615
- de = et([
616
- P(Y)
617
- ], de);
618
- const Re = {
619
- registration: {
620
- [Y]: {
621
- class: de,
622
- singleton: !0
623
- }
624
- },
625
- type: Y,
626
- predicate: b(Y),
627
- factory: v.Singleton.create(
628
- Y
629
- )
630
- }, rt = async (e) => {
631
- const t = [], { model: r } = await Ge(e);
632
- return r && (t.push(r.boardPath), t.push(r.nozzlePath), t.push(r.holderPath)), t;
633
- }, dr = async (e) => {
634
- const t = [], r = e.data.pumpPath;
635
- t.push(r);
636
- const a = await rt(r);
637
- return [...t, ...a];
638
- }, lr = async (e) => {
639
- const t = [], r = e.data.boardPath;
640
- t.push(e.data.boardPath);
641
- const a = await Ge(
642
- Re.type
643
- );
644
- if (a != null && a.model) {
645
- const s = a.model.models.getIndexByKey(
646
- tt.byBoard,
647
- r
648
- ).map(
649
- (c) => rt(c.path)
650
- );
651
- (await Promise.allSettled(s)).forEach((c) => {
652
- c.status === "fulfilled" && c.value.forEach((l) => t.push(l));
653
- });
654
- }
655
- return Array.from(new Set(t));
656
- };
657
- var cr = Object.getOwnPropertyDescriptor, pr = (e, t, r, a) => {
658
- for (var i = a > 1 ? void 0 : a ? cr(t, r) : t, s = e.length - 1, n; s >= 0; s--)
659
- (n = e[s]) && (i = n(i) || i);
660
- return i;
661
- };
662
- const Z = "board-model", Ae = (e, t) => {
663
- const { type: r, name: a, path: i, linked: s, instanceId: n, link: c, ...l } = e;
664
- t.type = r, t.name = a, t.path = i, t.linked = s, t.link = Object.freeze(c), t.instanceId = n, Object.assign(t, l);
665
- };
666
- y[Me].register(
667
- "board",
668
- lr
669
- );
670
- y[te].register(
671
- "board",
672
- sr
673
- );
674
- let Oe = class {
675
- constructor(e, t, r) {
676
- o(this, "id");
677
- o(this, "type");
678
- o(this, "name");
679
- o(this, "path");
680
- o(this, "linked");
681
- o(this, "instanceId");
682
- o(this, "logger");
683
- this.id = e, this.logger = r.logger, Ae(t, this);
684
- }
685
- updateModel(e) {
686
- Ae(e, this);
687
- }
688
- // -------------------LIFECYCLE----------------------------
689
- async init() {
690
- this.logger.debug(`initializing board ${this.id}`);
691
- }
692
- async load() {
693
- this.logger.debug(`loading board ${this.id}`);
694
- }
695
- };
696
- Oe = pr([
697
- P(Z)
698
- ], Oe);
699
- const at = {
700
- registration: {
701
- [Z]: {
702
- class: Oe,
703
- singleton: !1
704
- }
705
- },
706
- type: Z,
707
- predicate: b(Z),
708
- factory: v.Factory.create(Z)
709
- }, it = {
710
- registration: {
711
- [k]: {
712
- class: B,
713
- singleton: !0
714
- },
715
- ...at.registration
716
- },
717
- type: k,
718
- predicate: b(k),
719
- factory: v.Singleton.create(
720
- k
721
- )
722
- };
723
- var gr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, me = (e, t, r, a) => {
724
- for (var i = a > 1 ? void 0 : a ? hr(t, r) : t, s = e.length - 1, n; s >= 0; s--)
725
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
726
- return a && i && gr(t, r, i), i;
727
- };
728
- const X = L.HolderContainer, ur = "/kos/insertion/insert/start", yr = "/kos/insertion/insert/complete", Pr = "/kos/insertion/insert/update", Ir = "/kos/insertion/remove", mr = "/kos/pumpEvent/replaceLine", fr = "/kos/handle/*";
729
- let G = class {
730
- constructor(e, t, r) {
731
- o(this, "id");
732
- o(this, "holders");
733
- o(this, "logger");
734
- this.id = e, this.holders = new S({
735
- indexMap: {
736
- nozzle: (a) => a.nozzlePaths,
737
- group: "group"
738
- },
739
- parentId: e,
740
- extensionId: h.HolderIndex
741
- }), this.logger = r.logger;
742
- }
743
- updateModel() {
744
- }
745
- handleHolderEvents(e) {
746
- var r, a, i;
747
- m.ifDebug(
748
- () => this.logger.debug("Received holder change event", JSON.stringify(e))
749
- );
750
- const t = this.holders.getModel(e.path);
751
- t && (this.logger.info(
752
- `Received change event for holder ${t.path}. Updating fuel gauge data.`
753
- ), t.slice.currentVolMl = (r = e.slice) == null ? void 0 : r.currentVolMl, t.slice.maxVolMl = (a = e.slice) == null ? void 0 : a.maxVolMl, (i = e == null ? void 0 : e.container) != null && i.enjoyByDate ? t.enjoyByDate = new Date(e.container.enjoyByDate) : t.enjoyByDate = void 0);
754
- }
755
- handleInsertion(e) {
756
- m.ifDebug(
757
- () => this.logger.debug("Received insertion event", JSON.stringify(e))
758
- ), (Array.isArray(e) ? e : [e]).forEach((r) => {
759
- O(() => {
760
- var s, n, c;
761
- const a = r.ingredientId, i = this.holders.getModel(r.path);
762
- i && (this.logger.info(
763
- `Received insertion event for holder ${i.path}`
764
- ), i.updateIngredient(a), i.slice.currentVolMl = (s = r.slice) == null ? void 0 : s.currentVolMl, i.slice.maxVolMl = (n = r.slice) == null ? void 0 : n.maxVolMl, (c = r == null ? void 0 : r.container) != null && c.enjoyByDate ? i.enjoyByDate = new Date(r.container.enjoyByDate) : i.enjoyByDate = void 0, r.pumps.forEach((l) => {
765
- O(() => {
766
- const p = i.pumps.getModel(l.path);
767
- p && (p.ingredientId = l.ingredientId, p.inserted = l.inserted, p.prevIngredientId = l.prevIngredientId);
768
- });
769
- }));
770
- });
771
- });
772
- }
773
- // -------------------ENTITY----------------------------
774
- };
775
- me([
776
- _
777
- ], G.prototype, "holders", 2);
778
- me([
779
- re({
780
- topic: fr,
781
- websocket: !0,
782
- condition: (e, t) => t.holders.getModel(e.path) !== void 0
783
- })
784
- ], G.prototype, "handleHolderEvents", 1);
785
- me([
786
- re({
787
- topic: [
788
- ur,
789
- yr,
790
- Pr,
791
- Ir,
792
- mr
793
- ],
794
- websocket: !0
795
- })
796
- ], G.prototype, "handleInsertion", 1);
797
- G = me([
798
- P(X)
799
- ], G);
800
- const st = {
801
- registration: {
802
- [X]: {
803
- class: G,
804
- singleton: !0
805
- }
806
- },
807
- type: X,
808
- predicate: b(X),
809
- factory: v.Singleton.create(
810
- X
811
- )
812
- }, vr = m.createLogger({ name: "board-utils" }), br = async (e) => {
813
- const t = await U.executeDataMapperExtension({
814
- extension: h.BoardMapper,
815
- data: e,
816
- contextData: {}
817
- }), { type: r, name: a, path: i, linked: s, instanceId: n, ...c } = e, l = { ...c, ...t }, p = {
818
- type: r,
819
- name: a,
820
- path: i,
821
- linked: s,
822
- instanceId: n,
823
- ...l
824
- }, u = at.factory(e.path)(p);
825
- return u.updateModel(p), u;
826
- }, Or = (e) => async (t) => {
827
- vr.debug(`adding board ${t.name}`);
828
- const r = await br(t);
829
- e.addModel(r);
830
- };
831
- var d = /* @__PURE__ */ ((e) => (e.IDLE = "IDLE", e.POURING = "POURING", e.POUR_STARTING = "POUR_STARTING", e.POUR_CANCELING = "POUR_CANCELING", e))(d || {});
832
- const { URL: Ce } = D("PUMP_SERVICE"), { postModel: _r, getOne: Er } = T.build({
833
- basePath: `${Ce}/api/kos/holders`
834
- });
835
- m.createLogger({
836
- name: "pump-service",
837
- group: "Services"
838
- });
839
- const Mr = async ({
840
- intent: e,
841
- pumpId: t,
842
- tracker: r
843
- }) => {
844
- const a = `${Ce}/api/ext/dispense/nozzle/nozzle/pipeline/ingredient/pour/${t}/${e}`, i = await _r({ model: {}, urlOverride: a, tracker: r });
845
- return i != null && i.data && ge.initiateFuture(i.data), i;
846
- }, wr = async (e, t) => {
847
- const r = `${Ce}/api/ext/dispense/nozzle/nozzle/pipeline/ingredient/intent/${e}/${t}/volume`, a = await Er({ urlOverride: r });
848
- return a != null && a.data ? a.data : { volume: -1 };
849
- };
850
- var Rr = Object.defineProperty, Cr = Object.getOwnPropertyDescriptor, nt = (e, t, r, a) => {
851
- for (var i = a > 1 ? void 0 : a ? Cr(t, r) : t, s = e.length - 1, n; s >= 0; s--)
852
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
853
- return a && i && Rr(t, r, i), i;
854
- };
855
- const J = L.Pump;
856
- y[Me].register(
857
- "pump",
858
- dr
859
- );
860
- let le = class {
861
- constructor(e, t) {
862
- o(this, "id");
863
- o(this, "inserted");
864
- o(this, "type");
865
- o(this, "virtual");
866
- o(this, "ingredientId");
867
- o(this, "holderPath");
868
- o(this, "boardPath");
869
- o(this, "nozzlePath");
870
- o(this, "childPump");
871
- o(this, "name");
872
- o(this, "path");
873
- o(this, "prevIngredientId");
874
- /**
875
- * @kosApiLevel 12
876
- */
877
- o(this, "state");
878
- o(this, "futureHandler");
879
- o(this, "currentState", d.IDLE);
880
- this.id = e;
881
- const {
882
- inserted: r,
883
- holderPath: a,
884
- boardPath: i,
885
- nozzlePath: s,
886
- name: n,
887
- path: c,
888
- childPump: l,
889
- virtual: p,
890
- prevIngredientId: u,
891
- state: F,
892
- ...g
893
- } = t;
894
- this.inserted = r, this.type = t.type, this.ingredientId = t.ingredientId, this.holderPath = a, this.boardPath = i, this.nozzlePath = s, this.name = n, this.path = c, this.childPump = !!l, this.virtual = !!p, this.prevIngredientId = u, this.state = F, Object.assign(this, g), this.futureHandler = new je(this);
895
- }
896
- updateModel(e) {
897
- const {
898
- inserted: t,
899
- holderPath: r,
900
- boardPath: a,
901
- nozzlePath: i,
902
- childPump: s,
903
- name: n,
904
- path: c,
905
- ...l
906
- } = e;
907
- this.inserted = t, this.type = e.type, this.ingredientId = e.ingredientId, this.holderPath = r, this.boardPath = a, this.nozzlePath = i, this.childPump = this.childPump ? this.childPump : !!s, this.name = n, this.path = c, this.prevIngredientId = e.prevIngredientId, Object.assign(this, l);
908
- }
909
- // -------------------LIFECYCLE----------------------------
910
- get pouringState() {
911
- var e;
912
- return ((e = this.future) == null ? void 0 : e.endState) || "";
913
- }
914
- get isPouring() {
915
- var e;
916
- return !!(this.future && !((e = this.future) != null && e.endState)) || this.currentState === d.POUR_STARTING || this.currentState === d.POURING;
917
- }
918
- get canPour() {
919
- return !!this.ingredientId && !this.isPouring;
920
- }
921
- onFutureUpdate(e) {
922
- e.endState && O(() => {
923
- this.currentState = d.IDLE;
924
- });
925
- }
926
- async cancelPour() {
927
- var e;
928
- this.currentState === d.POURING || this.currentState === d.POUR_STARTING ? (this.currentState = d.POUR_CANCELING, await ((e = this.future) == null ? void 0 : e.cancelFuture()), O(() => {
929
- this.currentState = d.IDLE;
930
- })) : m.warn(`Cannot cancel pour in state ${this.currentState}`);
931
- }
932
- get future() {
933
- return this.futureHandler.future;
934
- }
935
- async resolveIntentVolume(e) {
936
- return await wr(this.path, e);
937
- }
938
- async performIntent(e, t) {
939
- const r = typeof e == "string" ? e : e.intent;
940
- if (!r)
941
- throw new Error("No intent provided");
942
- try {
943
- if (this.currentState === d.IDLE) {
944
- if (this.currentState = d.POUR_STARTING, !t)
945
- throw new Error("No tracker provided");
946
- const a = await Mr({
947
- tracker: t,
948
- intent: r,
949
- pumpId: this.path
950
- });
951
- return this.currentState === d.POUR_STARTING && O(() => {
952
- this.currentState = d.POURING;
953
- }), a == null ? void 0 : a.data;
954
- } else
955
- throw new Error(`Cannot pour in state ${this.currentState}`);
956
- } catch (a) {
957
- throw m.error(a), this.currentState = d.IDLE, a;
958
- }
959
- }
960
- // -------------------ENTITY----------------------------
961
- };
962
- nt([
963
- he()
964
- ], le.prototype, "performIntent", 1);
965
- le = nt([
966
- P(J)
967
- ], le);
968
- const ot = {
969
- registration: {
970
- [J]: {
971
- class: le,
972
- singleton: !1
973
- }
974
- },
975
- type: J,
976
- predicate: b(J),
977
- factory: v.Factory.create(J)
978
- }, Ue = m.createLogger({ name: "pump-utils" }), $r = (e, t) => {
979
- const r = (t.pumps ?? []).length > 1, a = {
980
- boardPath: t.boardPath,
981
- holderPath: t.holderPath,
982
- ingredientId: t.ingredientId,
983
- childPump: !!t.childPump,
984
- virtual: r,
985
- inserted: t.inserted,
986
- name: t.name,
987
- path: t.path,
988
- type: t.type,
989
- nozzlePath: e,
990
- prevIngredientId: t.prevIngredientId,
991
- state: t.state
992
- }, i = ot.factory(t.path)(a);
993
- return i.updateModel(a), i;
994
- }, dt = (e) => (t) => (r) => (a) => {
995
- var i;
996
- try {
997
- Ue.debug(`adding pump ${a.name}`);
998
- const s = $r(r.path, a);
999
- e.addModel(s);
1000
- const n = s.holderPath, c = t.holders.getModel(n);
1001
- c == null || c.pumps.addModel(s), c != null && c.nozzlePaths.includes(r.path) || c == null || c.nozzlePaths.push(r.path), (i = a == null ? void 0 : a.pumps) == null || i.forEach((l) => {
1002
- const p = s.holderPath, u = {
1003
- ...l,
1004
- childPump: !0,
1005
- holderPath: p,
1006
- ingredientId: s.ingredientId
1007
- };
1008
- dt(e)(t)(r)(u);
1009
- });
1010
- } catch (s) {
1011
- throw Ue.error(`Error mapping assembly pump: ${s}`), s;
1012
- }
1013
- };
1014
- var Nr = Object.defineProperty, Dr = Object.getOwnPropertyDescriptor, ie = (e, t, r, a) => {
1015
- for (var i = a > 1 ? void 0 : a ? Dr(t, r) : t, s = e.length - 1, n; s >= 0; s--)
1016
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
1017
- return a && i && Nr(t, r, i), i;
1018
- };
1019
- const q = "assembly-model", Tr = "assembly-data", Sr = "assembly-raw-data";
1020
- let N = class {
1021
- constructor(e, t, r) {
1022
- o(this, "id");
1023
- o(this, "_nozzlePaths", /* @__PURE__ */ new Set());
1024
- o(this, "troubleContainer");
1025
- o(this, "holderContainer");
1026
- o(this, "boardContainer");
1027
- o(this, "pumpContainer");
1028
- o(this, "logger");
1029
- this.id = e, this.holderContainer = st.factory({}), this.boardContainer = it.factory({}), this.pumpContainer = Re.factory({}), this.logger = r.logger;
1030
- }
1031
- updateModel(e) {
1032
- }
1033
- get allHolders() {
1034
- return this.holderContainer.holders.data;
1035
- }
1036
- get holderGroups() {
1037
- return this.holderContainer.holders.getIndexKeys("group");
1038
- }
1039
- get nozzlePaths() {
1040
- return Array.from(this._nozzlePaths);
1041
- }
1042
- getHoldersByGroup(e) {
1043
- return this.holderContainer.holders.getIndexByKey("group", e);
1044
- }
1045
- getHoldersByNozzle(e) {
1046
- return this.holderContainer.holders.getIndexByKey("nozzle", e);
1047
- }
1048
- /**
1049
- * Returns a map of the pumps associated with each nozzle
1050
- *
1051
- * Can be used in conjunction with the nozzlePaths to get the pumps associated with each nozzle
1052
- * @returns Record<string, PumpModel[]>
1053
- */
1054
- get pumpsByNozzle() {
1055
- return this.pumpContainer.models.idx.byNozzle;
1056
- }
1057
- /**
1058
- * Returns a list of all fo the pumps paths across the entire assembly.
1059
- */
1060
- get pumpPaths() {
1061
- return this.pumpContainer.models.data.map((e) => e.path);
1062
- }
1063
- get boards() {
1064
- return this.boardContainer.boardList;
1065
- }
1066
- // -------------------LIFECYCLE----------------------------
1067
- async init() {
1068
- this.logger.debug(`initializing assembly ${this.id}`);
1069
- }
1070
- async ready() {
1071
- var e;
1072
- (e = this.troubleContainer) == null || e.troubles.increment(), y[mt].execute(
1073
- h.AssemblyFeatureFlags,
1074
- this
1075
- );
1076
- }
1077
- async load(e) {
1078
- this.logger.debug(`loading assembly ${this.id}`);
1079
- const t = await qe();
1080
- if ((t == null ? void 0 : t.status) === 200) {
1081
- const r = await U.executeDataMapperExtension({
1082
- extension: h.AssemblyMapper,
1083
- data: t.data,
1084
- contextData: {}
1085
- });
1086
- e.set(Tr, r), Object.assign(this, r), Object.entries(r).forEach(([a, i]) => {
1087
- ft(i) && (this.logger.debug(`adding child model ${a} from extension data`), this[vt][a] = !0);
1088
- }), e.set(Sr, t.data);
1089
- for await (const a of t.data.assemblies) {
1090
- const {
1091
- boards: i = [],
1092
- holders: s = {},
1093
- nozzles: n = [],
1094
- core: c,
1095
- name: l,
1096
- path: p,
1097
- ...u
1098
- } = a;
1099
- this.logger.debug(`adding assembly ${l}`), this.logger.warn(`Assembly rest keys: ${Object.keys(u).join(", ")}`), Object.keys(u).forEach((g) => {
1100
- var M;
1101
- if (this.logger.warn(`Enabling feature flag: ${g}`), bt.enableFeature(g), e.set(`assembly-feature-${g}`, u[g]), ((M = u[g].state) == null ? void 0 : M.path) !== void 0) {
1102
- const C = u[g].state.path;
1103
- this.logger.warn(`Feature flag ${g} state path: ${C}`), e.set(`assembly-state-path-${g}`, C);
1104
- }
1105
- });
1106
- for await (const g of i)
1107
- this.logger.debug(`adding board ${g.name}`), await Or(this.boardContainer)(g);
1108
- for await (const [g, M] of Object.entries(
1109
- s ?? {}
1110
- ))
1111
- for await (const C of M) {
1112
- this.logger.debug(`adding holder ${C.name}`);
1113
- const De = await Qt(g, C);
1114
- this.holderContainer.holders.addModel(De);
1115
- }
1116
- const F = dt(this.pumpContainer)(
1117
- this.holderContainer
1118
- );
1119
- n.forEach((g) => {
1120
- this._nozzlePaths.add(g.path);
1121
- const M = F(g);
1122
- g.pumps.forEach(M);
1123
- });
1124
- }
1125
- }
1126
- }
1127
- };
1128
- ie([
1129
- Be({
1130
- modelType: "trouble-container-model"
1131
- })
1132
- ], N.prototype, "troubleContainer", 2);
1133
- ie([
1134
- _
1135
- ], N.prototype, "holderContainer", 2);
1136
- ie([
1137
- _
1138
- ], N.prototype, "boardContainer", 2);
1139
- ie([
1140
- _
1141
- ], N.prototype, "pumpContainer", 2);
1142
- N = ie([
1143
- P(q)
1144
- ], N);
1145
- const lt = {
1146
- registration: {
1147
- [q]: {
1148
- class: N,
1149
- singleton: !0
1150
- }
1151
- },
1152
- type: q,
1153
- predicate: b(q),
1154
- factory: v.Singleton.create(q)
1155
- };
1156
- var Lr = Object.getOwnPropertyDescriptor, Ar = (e, t, r, a) => {
1157
- for (var i = a > 1 ? void 0 : a ? Lr(t, r) : t, s = e.length - 1, n; s >= 0; s--)
1158
- (n = e[s]) && (i = n(i) || i);
1159
- return i;
1160
- };
1161
- const W = L.Availability;
1162
- let _e = class {
1163
- constructor(e, t, r) {
1164
- o(this, "id");
1165
- o(this, "data");
1166
- o(this, "properties");
1167
- o(this, "available");
1168
- o(this, "visible");
1169
- o(this, "groupId");
1170
- o(this, "rawId");
1171
- o(this, "altId");
1172
- o(this, "type");
1173
- o(this, "note");
1174
- o(this, "taggedIds");
1175
- o(this, "parentId");
1176
- o(this, "logger");
1177
- this.id = e, this.taggedIds = t.taggedIds || [], this.logger = r.logger, this.available = t.available, this.visible = t.visible, this.groupId = t.groupId, this.rawId = t.rawId, this.altId = t.altId, this.type = t.type, this.parentId = t.kosParentId, this.data = t.data, this.note = t.note, this.properties = t.properties || {};
1178
- }
1179
- updateModel(e) {
1180
- this.taggedIds = e.taggedIds || [], this.available = e.available, this.visible = e.visible, this.groupId = e.groupId, this.rawId = e.rawId, this.altId = e.altId, this.type = e.type, this.data = e.data;
1181
- }
1182
- updateAvailability(e) {
1183
- this.available = e;
1184
- }
1185
- // -------------------LIFECYCLE----------------------------
1186
- // -------------------ENTITY----------------------------
1187
- };
1188
- _e = Ar([
1189
- Ot(),
1190
- P(W)
1191
- ], _e);
1192
- const Ee = {
1193
- registration: {
1194
- [W]: {
1195
- class: _e,
1196
- singleton: !1
1197
- }
1198
- },
1199
- type: W,
1200
- predicate: b(W),
1201
- factory: v.Factory.create(
1202
- W
1203
- )
1204
- }, { URL: j } = D("NOZZLE_SERVICE"), { postModel: $e, deleteModel: Ur, getOne: zr } = T.build({
1205
- basePath: `${j}/api/nozzle`
1206
- }), xr = async (e, t) => {
1207
- const r = await $e({
1208
- model: {},
1209
- urlOverride: `${j}/api/ext/dispense/nozzle/${e}/pipeline/beverage/pour`,
1210
- ordered: !0,
1211
- tracker: t
1212
- });
1213
- return r != null && r.data && ge.initiateFuture(r.data), r;
1214
- }, Br = async (e, t, r) => {
1215
- const a = await $e({
1216
- model: {},
1217
- urlOverride: `${j}/api/ext/dispense/nozzle/${t}/pipeline/beverage/fixed/${e}`,
1218
- ordered: !0,
1219
- tracker: r
1220
- });
1221
- return a != null && a.data && ge.initiateFuture(a.data), a;
1222
- }, Gr = async (e) => await zr({
1223
- urlOverride: `${j}${e}/pipeline/beverage/availability`
1224
- }), jr = async (e, t) => await $e({
1225
- model: t,
1226
- urlOverride: `${j}/api/ext/dispense/nozzle/${e}/pipeline/beverage/select`
1227
- }), Fr = async (e) => await Ur({
1228
- id: e,
1229
- urlOverride: `${j}/api/ext/dispense/nozzle/${e}/pipeline/beverage/select`
1230
- });
1231
- var Hr = Object.defineProperty, Vr = Object.getOwnPropertyDescriptor, E = (e, t, r, a) => {
1232
- for (var i = a > 1 ? void 0 : a ? Vr(t, r) : t, s = e.length - 1, n; s >= 0; s--)
1233
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
1234
- return a && i && Hr(t, r, i), i;
1235
- };
1236
- const Q = L.Nozzle, Kr = _t(
1237
- "beverageTopicPrefix"
1238
- ), fe = (e) => e.onPourStart !== void 0 && e.onPourCancel !== void 0 && e.onPourProgress !== void 0, ze = "/kos/nozzle/pour/started", kr = "/kos/nozzle/pour/progress", Yr = "/kos/nozzle/pour/cancel";
1239
- let I = class {
1240
- constructor(e, t) {
1241
- /** the unique identifier for this nozzle.*/
1242
- o(this, "id");
1243
- o(this, "path");
1244
- o(this, "name");
1245
- o(this, "_selectedBeverage");
1246
- o(this, "_selectedBrand");
1247
- o(this, "_additionalItems");
1248
- o(this, "_availabilityItems");
1249
- o(this, "futureHandler");
1250
- o(this, "beverageTopicPrefix");
1251
- o(this, "topicPrefix");
1252
- o(this, "urlPrefix");
1253
- this.id = e, this.path = t.path, this.name = t.name, this.beverageTopicPrefix = t.beverageTopicPrefix, this.topicPrefix = t.topicPrefix, this.urlPrefix = t.urlPrefix, this._selectedBeverage = void 0, this._selectedBrand = void 0, this._additionalItems = [], this.futureHandler = new Et(this), this._availabilityItems = new S({
1254
- indexMap: {
1255
- byGroup: "groupId",
1256
- byParent: "parentId"
1257
- },
1258
- parentId: e
1259
- });
1260
- }
1261
- /**
1262
- * The availability nodes that can be dispensed from this nozzle.
1263
- * This is a subset of the availability for the entire dispenser
1264
- * and is determined by the nodes associated with a nozzle.
1265
- */
1266
- get beverages() {
1267
- return this._availabilityItems.getIndexByKey("byGroup", "beverages");
1268
- }
1269
- /**
1270
- * The availability nodes that have been grouped into the "brands" group.
1271
- *
1272
- */
1273
- get brands() {
1274
- return this._availabilityItems.getIndexByKey("byGroup", "brands");
1275
- }
1276
- get visibleBrands() {
1277
- return this.brands.filter((e) => e.visible);
1278
- }
1279
- get visibleBeverages() {
1280
- return this.beverages.filter((e) => e.visible);
1281
- }
1282
- /**
1283
- * A derived value that indicates if the nozzle is currently pouring a beverage.
1284
- * @readonly
1285
- */
1286
- get isPouring() {
1287
- var e;
1288
- return !!(this.futureHandler.getFuture() && !((e = this.futureHandler.getFuture()) != null && e.endState)) || this.currentState === d.POUR_STARTING || this.currentState === d.POURING || this.currentState === d.POUR_CANCELING;
1289
- }
1290
- /**
1291
- * A derived value that indicates if the nozzle is currently available to pour a beverage.
1292
- *
1293
- * This will generally be determined by whether there is a currently selected pourable AND
1294
- * the nozzle is not currently pouring.
1295
- *
1296
- * The value is observable and will change when the selected pourable changes or the nozzle
1297
- * starts or stops pouring.
1298
- * @readonly
1299
- * */
1300
- get canPour() {
1301
- return !!this._selectedBeverage && this._selectedBeverage.available && this.currentState === d.IDLE;
1302
- }
1303
- /**
1304
- * The selected pourable for this nozzle. Its shape is determined by the results of the
1305
- * {@link ExtensionType.SelectedPourableMapper} extension.
1306
- * @readonly
1307
- *
1308
- * */
1309
- get selectedPourable() {
1310
- return {
1311
- beverage: this._selectedBeverage,
1312
- additional: this._additionalItems
1313
- };
1314
- }
1315
- get future() {
1316
- return this.futureHandler.getFuture();
1317
- }
1318
- get pourProgress() {
1319
- var e;
1320
- return ((e = this.future) == null ? void 0 : e.progress) ?? 0;
1321
- }
1322
- updateModel() {
1323
- }
1324
- // -------------------LIFECYCLE----------------------------
1325
- setSelectedBrand(e, t) {
1326
- t && this.logger.debug("context is currenty being ignored when setting brand"), this._selectedBrand = e, this._selectedBeverage = void 0;
1327
- }
1328
- get selectedBrand() {
1329
- return this._selectedBrand;
1330
- }
1331
- /**
1332
- * Set the values used to determine the selected pourable for this nozzle.
1333
- *
1334
- * @param pourable The pourable to set.
1335
- * @param pourable.beverage The beverage selected.
1336
- * @param pourable.additional The additional items such as flavors or other items that could be incorporated
1337
- * into the pourable.
1338
- * */
1339
- async setSelectedPourable({ beverage: e, additional: t, context: r }, a = !1) {
1340
- if (!e) {
1341
- const l = await Fr(this.name);
1342
- if ((l == null ? void 0 : l.status) !== 200)
1343
- throw new Error("Failed to clear pourable");
1344
- this._selectedBeverage = void 0;
1345
- return;
1346
- }
1347
- if (!a && e === this._selectedBeverage && Mt(this._additionalItems, t)) {
1348
- this.logger.info("No change in selected pourable");
1349
- return;
1350
- }
1351
- this._selectedBeverage = e, this._additionalItems = t;
1352
- let i;
1353
- try {
1354
- i = await y.dataMapper.executeMapper(
1355
- h.SelectedPourableMapper,
1356
- {
1357
- beverage: e,
1358
- additional: t,
1359
- context: r
1360
- }
1361
- );
1362
- } catch (l) {
1363
- this.logger.error(
1364
- `Error executing SelectedPourableMapper, falling back to default payload. Error: ${l}`
1365
- ), i = void 0;
1366
- }
1367
- const s = {
1368
- bevId: e.rawId
1369
- };
1370
- (!i || Object.keys(i).length === 0) && (this.logger.info(
1371
- `No selected pourable mapper defined, using the default payload ${s}`
1372
- ), i = s);
1373
- const n = i ?? s, c = await jr(this.name, n);
1374
- if ((c == null ? void 0 : c.status) !== 200)
1375
- throw new Error("Failed to select pourable");
1376
- }
1377
- /**
1378
- * Utility method that will return the availability nodes that belong to the specified
1379
- * group as defined in the dispenser beverage graph. For example, a dispenser
1380
- * implementation may group availability nodes by Brand, Beverage, or Flavors
1381
- *
1382
- * @param groupId The group to filter by.
1383
- * @returns The availability nodes that are available to be dispensed from this nozzle
1384
- * and are in the specified group.
1385
- * */
1386
- getGroupAvailabilityItems(e) {
1387
- return this._availabilityItems.getIndexByKey(
1388
- "byGroup",
1389
- e
1390
- );
1391
- }
1392
- /**
1393
- * Utility method that will return the availability nodes that are tagged with the specified parent id.
1394
- *
1395
- * This is useful when brandsets use the taggedIds property to associate nodes with a parent node. For example,
1396
- * when organizing a brandset into brands and beverages, the brand nodes will be tagged with the beverage nodes.
1397
- *
1398
- * @param parentId - The parent id to filter by.
1399
- * @returns the availability nodes that are tagged with the specified parent id.
1400
- */
1401
- getAvailabilityByParent(e) {
1402
- return this._availabilityItems.getIndexByKey(
1403
- "byParent",
1404
- e
1405
- );
1406
- }
1407
- handlePouringStart() {
1408
- this.logger.info("Pour started"), z(this).forEach((e) => {
1409
- var t;
1410
- fe(e) && ((t = e.onPourStart) == null || t.call(e));
1411
- });
1412
- }
1413
- handlePouringEnd() {
1414
- this.logger.info("Pour ended");
1415
- }
1416
- handleCancelStart() {
1417
- this.logger.info("Pour canceling");
1418
- }
1419
- handleCanceled() {
1420
- this.logger.info("Pour canceled"), z(this).forEach((t) => {
1421
- var r;
1422
- fe(t) && ((r = t.onPourCancel) == null || r.call(t));
1423
- });
1424
- const e = {
1425
- nozzleId: this.id
1426
- };
1427
- $.publish(Yr, e);
1428
- }
1429
- // ============================================================================
1430
- // Future Lifecycle Handler
1431
- // ============================================================================
1432
- onFutureUpdate(e) {
1433
- z(this).forEach((a) => {
1434
- fe(a) && a.onPourProgress(e);
1435
- });
1436
- const r = {
1437
- nozzleId: this.id,
1438
- progress: e.progress,
1439
- status: e.status,
1440
- clientData: e.clientData,
1441
- futureId: e.futureId,
1442
- remainingTimeMs: e.remainingTimeMs,
1443
- endState: e.endState,
1444
- reason: e.reason,
1445
- timeRemaining: e.timeRemaining
1446
- };
1447
- $.publish(kr, r), e.endState && O(() => {
1448
- this.currentState === d.POURING && this.transition("POUR_COMPLETED");
1449
- });
1450
- }
1451
- // Inherits throwOnInvalid: false from class
1452
- async pour(e) {
1453
- var t;
1454
- try {
1455
- if (this.transition("START_POUR"), !e)
1456
- throw new Error("No tracker provided");
1457
- const r = await xr(this.name, e);
1458
- this.transition("POUR_ACTIVE");
1459
- const a = {
1460
- nozzleId: this.id,
1461
- type: "free"
1462
- };
1463
- return $.publish(ze, a), (t = r == null ? void 0 : r.data) != null && t.endState && this.transition("POUR_COMPLETED"), r;
1464
- } catch (r) {
1465
- throw this.logger.error(r), this.currentState !== d.IDLE && this.transition("POUR_COMPLETED"), r;
1466
- }
1467
- }
1468
- // Inherits throwOnInvalid: false from class
1469
- async fixedPour(e, t) {
1470
- var r;
1471
- try {
1472
- if (this.transition("START_POUR"), !t)
1473
- throw new Error("No tracker provided");
1474
- const a = await Br(e, this.name, t);
1475
- this.transition("POUR_ACTIVE");
1476
- const i = {
1477
- nozzleId: this.id,
1478
- type: "fixed"
1479
- };
1480
- return $.publish(ze, i), (r = a == null ? void 0 : a.data) != null && r.endState && this.transition("POUR_COMPLETED"), a;
1481
- } catch (a) {
1482
- throw this.logger.error(a), this.currentState !== d.IDLE && this.transition("POUR_COMPLETED"), a;
1483
- }
1484
- }
1485
- // Inherits throwOnInvalid: false - silently ignore if already idle
1486
- async cancelPour() {
1487
- var e;
1488
- this.transition("CANCEL_POUR"), await ((e = this.futureHandler.getFuture()) == null ? void 0 : e.cancelFuture()), this.transition("POUR_CANCELED");
1489
- }
1490
- updateGroupMembers() {
1491
- this._availabilityItems.data.forEach((e) => {
1492
- (e.taggedIds || []).forEach((r) => {
1493
- const a = this._availabilityItems.data.find(
1494
- (i) => i.rawId === r
1495
- );
1496
- a && a.parentId !== e.id && (a.parentId = e.id, this._availabilityItems.updateModel(a));
1497
- });
1498
- });
1499
- }
1500
- /** @internal */
1501
- async load(e) {
1502
- var a, i;
1503
- this.logger.debug(`loading nozzle ${this.id}`);
1504
- const t = await Gr(this.urlPrefix);
1505
- if ((t == null ? void 0 : t.status) !== 200)
1506
- throw new Error("Failed to load nozzle availability");
1507
- const r = await y.loader.executeLoader(
1508
- h.AvailabilityLoader,
1509
- {}
1510
- );
1511
- e == null || e.set(h.AvailabilityLoader, r), e == null || e.set(Ne.type, this);
1512
- for (const s of Object.keys((a = t.data) == null ? void 0 : a.groups) || [])
1513
- for (const n of ((i = t.data) == null ? void 0 : i.groups[s]) || []) {
1514
- const c = await y.dataMapper.executeMapper(
1515
- h.AvailabilityMapper,
1516
- { ...n, groupId: s },
1517
- r
1518
- ), l = {
1519
- ...n,
1520
- note: n.note ?? void 0,
1521
- kosParentId: this.id,
1522
- rawId: n.id,
1523
- groupId: s,
1524
- data: c,
1525
- properties: n.properties || {}
1526
- }, p = Ee.factory(
1527
- `${this.id}-${s}-${n.id}`
1528
- )(l);
1529
- this._availabilityItems.addModel(p);
1530
- }
1531
- this.updateGroupMembers();
1532
- }
1533
- async updateAvailability(e) {
1534
- const t = wt.getContext(this.id), r = (t == null ? void 0 : t.get(h.AvailabilityLoader)) || {};
1535
- if (e.rebuild)
1536
- for (const a of Object.keys(e == null ? void 0 : e.groups) || []) {
1537
- this._availabilityItems.getIndexByKey("group", a).filter(
1538
- (s) => !e.groups[a].find(
1539
- (n) => `${this.id}-${a}-${n.id}` === s.id
1540
- )
1541
- ).forEach((s) => {
1542
- this._availabilityItems.removeModel(s.id), Rt(s);
1543
- });
1544
- for (const s of (e == null ? void 0 : e.groups[a]) || []) {
1545
- const n = await y.dataMapper.executeMapper(
1546
- h.AvailabilityMapper,
1547
- { ...s, groupId: a },
1548
- r
1549
- ), c = {
1550
- ...s,
1551
- note: s.note ?? void 0,
1552
- kosParentId: this.id,
1553
- groupId: a,
1554
- rawId: s.id,
1555
- data: n,
1556
- taggedIds: s.taggedIds,
1557
- properties: s.properties || {}
1558
- }, l = this._availabilityItems.getModel(
1559
- `${this.id}-${a}-${s.id}`
1560
- );
1561
- if (l)
1562
- l.updateModel(c);
1563
- else {
1564
- const p = Ee.factory(
1565
- `${this.id}-${a}-${s.id}`
1566
- )(c);
1567
- this._availabilityItems.addModel(p);
1568
- }
1569
- }
1570
- }
1571
- else
1572
- for (const a of Object.keys(e == null ? void 0 : e.groups) || [])
1573
- for (const i of (e == null ? void 0 : e.groups[a]) || []) {
1574
- const s = await y.dataMapper.executeMapper(
1575
- h.AvailabilityMapper,
1576
- { ...i, groupId: a },
1577
- r
1578
- ), n = {
1579
- ...i,
1580
- note: i.note ?? void 0,
1581
- kosParentId: this.id,
1582
- groupId: a,
1583
- rawId: i.id,
1584
- data: s,
1585
- type: i.type,
1586
- taggedIds: i.taggedIds,
1587
- properties: i.properties || {}
1588
- }, c = this._availabilityItems.getModel(
1589
- `${this.id}-${a}-${i.id}`
1590
- );
1591
- c && c.updateModel(n);
1592
- }
1593
- this.updateGroupMembers();
1594
- }
1595
- // -------------------ENTITY----------------------------
1596
- };
1597
- E([
1598
- _
1599
- ], I.prototype, "_availabilityItems", 2);
1600
- E([
1601
- ue(d.POURING)
1602
- ], I.prototype, "handlePouringStart", 1);
1603
- E([
1604
- ye(d.POURING)
1605
- ], I.prototype, "handlePouringEnd", 1);
1606
- E([
1607
- ue(d.POUR_CANCELING)
1608
- ], I.prototype, "handleCancelStart", 1);
1609
- E([
1610
- ye(d.POUR_CANCELING)
1611
- ], I.prototype, "handleCanceled", 1);
1612
- E([
1613
- he(),
1614
- ae({ allowedStates: [d.IDLE] })
1615
- ], I.prototype, "pour", 1);
1616
- E([
1617
- he(),
1618
- ae({ allowedStates: [d.IDLE] })
1619
- ], I.prototype, "fixedPour", 1);
1620
- E([
1621
- ae({
1622
- allowedStates: [d.POUR_STARTING, d.POURING]
1623
- })
1624
- ], I.prototype, "cancelPour", 1);
1625
- E([
1626
- re({
1627
- topic: `${Kr}/availability`,
1628
- websocket: !0
1629
- })
1630
- ], I.prototype, "updateAvailability", 1);
1631
- I = E([
1632
- P({ modelTypeId: Q, singleton: !1 }),
1633
- Fe(),
1634
- He(
1635
- {
1636
- initial: d.IDLE,
1637
- initializeAt: pe.READY,
1638
- states: {
1639
- [d.IDLE]: {
1640
- on: {
1641
- START_POUR: d.POUR_STARTING
1642
- }
1643
- },
1644
- [d.POUR_STARTING]: {
1645
- on: {
1646
- POUR_ACTIVE: d.POURING,
1647
- CANCEL_POUR: d.POUR_CANCELING,
1648
- POUR_COMPLETED: d.IDLE
1649
- }
1650
- },
1651
- [d.POURING]: {
1652
- on: {
1653
- CANCEL_POUR: d.POUR_CANCELING,
1654
- POUR_COMPLETED: d.IDLE
1655
- }
1656
- },
1657
- [d.POUR_CANCELING]: {
1658
- on: {
1659
- POUR_CANCELED: d.IDLE
1660
- }
1661
- }
1662
- }
1663
- },
1664
- {
1665
- trackHistory: !1,
1666
- throwOnInvalid: !1
1667
- // Gracefully ignore invalid state calls (expected runtime scenarios)
1668
- }
1669
- )
1670
- ], I);
1671
- const Ne = {
1672
- registration: {
1673
- [Q]: {
1674
- class: I,
1675
- singleton: !1
1676
- }
1677
- },
1678
- type: Q,
1679
- predicate: b(Q),
1680
- factory: v.Factory.create(Q)
1681
- };
1682
- var Zr = Object.defineProperty, Xr = Object.getOwnPropertyDescriptor, ct = (e, t, r, a) => {
1683
- for (var i = a > 1 ? void 0 : a ? Xr(t, r) : t, s = e.length - 1, n; s >= 0; s--)
1684
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
1685
- return a && i && Zr(t, r, i), i;
1686
- };
1687
- const pt = "device-assembly-model";
1688
- let ce = class {
1689
- constructor(e, t, r) {
1690
- o(this, "id");
1691
- o(this, "deviceNozzles");
1692
- o(this, "logger");
1693
- this.id = e, this.logger = r.logger, this.deviceNozzles = new S();
1694
- }
1695
- // -------------------LIFECYCLE----------------------------
1696
- async init() {
1697
- this.logger.debug(`initializing device-assembly ${this.id}`);
1698
- }
1699
- getNozzle(e) {
1700
- return this.deviceNozzles.getModel(e);
1701
- }
1702
- get nozzlePaths() {
1703
- return this.deviceNozzles.data.map((e) => e.path);
1704
- }
1705
- async load() {
1706
- this.logger.debug(`loading device-assembly ${this.id}`);
1707
- const e = await qe();
1708
- (e == null ? void 0 : e.status) === 200 && e.data.assemblies.map((r) => r.nozzles ?? []).flat().forEach((r) => {
1709
- var n;
1710
- const a = r.path, i = ((n = r.pipelines.find((c) => c.name === "beverage")) == null ? void 0 : n.topicPrefix) || "", s = Ne.factory(a)({
1711
- path: r.path,
1712
- name: r.name,
1713
- urlPrefix: r.urlPrefix,
1714
- topicPrefix: r.topicPrefix,
1715
- beverageTopicPrefix: i
1716
- });
1717
- this.deviceNozzles.addModel(s);
1718
- });
1719
- }
1720
- };
1721
- ct([
1722
- _
1723
- ], ce.prototype, "deviceNozzles", 2);
1724
- ce = ct([
1725
- P(pt)
1726
- ], ce);
1727
- const Jr = new Ct({
1728
- class: ce,
1729
- type: pt
1730
- }), { URL: gt } = D("GENERIC_POUR_SERVICE"), { postModel: qr } = T.build({
1731
- basePath: `${gt}/api/nozzle`
1732
- }), Wr = async (e, t) => {
1733
- const r = await qr({
1734
- model: {},
1735
- urlOverride: `${gt}${e}`,
1736
- ordered: !0,
1737
- tracker: t
1738
- });
1739
- return r != null && r.data && ge.initiateFuture(r.data), r;
1740
- };
1741
- var Qr = Object.defineProperty, ea = Object.getOwnPropertyDescriptor, A = (e, t, r, a) => {
1742
- for (var i = a > 1 ? void 0 : a ? ea(t, r) : t, s = e.length - 1, n; s >= 0; s--)
1743
- (n = e[s]) && (i = (a ? n(t, r, i) : n(i)) || i);
1744
- return a && i && Qr(t, r, i), i;
1745
- };
1746
- const ht = "generic-pour-model", ta = "/kos/generic/pour/started", ra = "/kos/generic/pour/progress", aa = "/kos/generic/pour/cancel", ve = (e) => e.onPourStart !== void 0 && e.onPourCancel !== void 0 && e.onPourProgress !== void 0;
1747
- let w = class {
1748
- constructor(e, t) {
1749
- o(this, "id");
1750
- /**
1751
- * @kosApiLevel 5
1752
- */
1753
- o(this, "servicePathFactory");
1754
- o(this, "pourType");
1755
- /**
1756
- * @kosApiLevel 5
1757
- */
1758
- o(this, "selectedId");
1759
- o(this, "state");
1760
- this.id = e, this.futureHandler = new je(this), this.servicePathFactory = t.servicePathFactory, this.pourType = t.pourType || "free", this.selectedId = t.selectedId, this.state = Se(t.initialData || {});
1761
- }
1762
- get servicePath() {
1763
- return this.selectedId ? this.servicePathFactory(this.selectedId, this.state) : "";
1764
- }
1765
- /**
1766
- * @kosApiLevel 12
1767
- */
1768
- updateContextData(e, t) {
1769
- this.state[e] = t;
1770
- }
1771
- /**
1772
- * @kosApiLevel 12
1773
- */
1774
- removeContextData(e) {
1775
- delete this.state[e];
1776
- }
1777
- /**
1778
- * @kosApiLevel 12
1779
- */
1780
- clearContextData() {
1781
- this.state = Se();
1782
- }
1783
- /**
1784
- * @kosApiLevel 14
1785
- */
1786
- updateModel(e) {
1787
- e.pourType && (this.pourType = e.pourType), e.initialData && this.state.setValues(e.initialData);
1788
- }
1789
- handlePouringStart() {
1790
- this.logger.info("Pour started"), z(this).forEach((t) => {
1791
- var r;
1792
- ve(t) && ((r = t.onPourStart) == null || r.call(t));
1793
- });
1794
- const e = {
1795
- pourTarget: this.id,
1796
- type: this.pourType
1797
- };
1798
- $.publish(ta, e);
1799
- }
1800
- handlePouringEnd() {
1801
- this.logger.info("Pour ended");
1802
- }
1803
- handleCancelStart() {
1804
- this.logger.info("Pour canceling");
1805
- }
1806
- handleCanceled() {
1807
- this.logger.info("Pour canceled"), z(this).forEach((t) => {
1808
- var r;
1809
- ve(t) && ((r = t.onPourCancel) == null || r.call(t));
1810
- });
1811
- const e = {
1812
- pourTarget: this.id
1813
- };
1814
- $.publish(aa, e);
1815
- }
1816
- // Inherits throwOnInvalid: false from class
1817
- async pour(e) {
1818
- var t;
1819
- try {
1820
- if (this.transition("START_POUR"), !e)
1821
- throw new Error("No tracker provided");
1822
- const r = await Wr(this.servicePath, e);
1823
- return this.transition("POUR_ACTIVE"), (t = r == null ? void 0 : r.data) != null && t.endState && this.transition("POUR_COMPLETED"), r;
1824
- } catch (r) {
1825
- throw this.logger.error(r), this.currentState !== d.IDLE && this.transition("POUR_COMPLETED"), r;
1826
- }
1827
- }
1828
- // Inherits throwOnInvalid: false - silently ignore if already idle
1829
- async cancelPour() {
1830
- var e;
1831
- this.transition("CANCEL_POUR"), await ((e = this.futureHandler.getFuture()) == null ? void 0 : e.cancelFuture()), this.transition("POUR_CANCELED");
1832
- }
1833
- // ============================================================================
1834
- // Computed Properties
1835
- // ============================================================================
1836
- /**
1837
- * A derived value that indicates if the nozzle is currently pouring a beverage.
1838
- * @readonly
1839
- */
1840
- get isPouring() {
1841
- var e;
1842
- return !!(this.future && !((e = this.future) != null && e.endState)) || this.currentState === d.POUR_STARTING || this.currentState === d.POURING || this.currentState === d.POUR_CANCELING;
1843
- }
1844
- /**
1845
- * A derived value that indicates if the pour target is currently available to pour a beverage.
1846
- *
1847
- * Generally this means that the pour target is currently idle and not in the process of pouring,
1848
- * initiating a pour, or canceling a pour.
1849
- * The value is observable and will change when the selected pourable changes or the pour target
1850
- * starts or stops pouring.
1851
- * @readonly
1852
- */
1853
- get canPour() {
1854
- return this.currentState === d.IDLE;
1855
- }
1856
- get pourProgress() {
1857
- return this.progress ?? 0;
1858
- }
1859
- // ============================================================================
1860
- // Future Lifecycle Handler
1861
- // ============================================================================
1862
- onFutureUpdate(e) {
1863
- z(this).forEach((r) => {
1864
- ve(r) && r.onPourProgress(e);
1865
- });
1866
- const t = {
1867
- pourTarget: this.id,
1868
- progress: e.progress,
1869
- status: e.status,
1870
- clientData: e.clientData,
1871
- futureId: e.futureId,
1872
- remainingTimeMs: e.remainingTimeMs,
1873
- endState: e.endState,
1874
- reason: e.reason,
1875
- timeRemaining: e.timeRemaining
1876
- };
1877
- $.publish(ra, t), e.endState && O(() => {
1878
- this.currentState === d.POURING && this.transition("POUR_COMPLETED");
1879
- });
1880
- }
1881
- };
1882
- A([
1883
- ue(d.POURING)
1884
- ], w.prototype, "handlePouringStart", 1);
1885
- A([
1886
- ye(d.POURING)
1887
- ], w.prototype, "handlePouringEnd", 1);
1888
- A([
1889
- ue(d.POUR_CANCELING)
1890
- ], w.prototype, "handleCancelStart", 1);
1891
- A([
1892
- ye(d.POUR_CANCELING)
1893
- ], w.prototype, "handleCanceled", 1);
1894
- A([
1895
- he(),
1896
- ae({ allowedStates: [d.IDLE] })
1897
- ], w.prototype, "pour", 1);
1898
- A([
1899
- ae({
1900
- allowedStates: [d.POUR_STARTING, d.POURING]
1901
- })
1902
- ], w.prototype, "cancelPour", 1);
1903
- w = A([
1904
- P(ht),
1905
- Fe(),
1906
- $t(),
1907
- He(
1908
- {
1909
- initial: d.IDLE,
1910
- initializeAt: pe.READY,
1911
- states: {
1912
- [d.IDLE]: {
1913
- on: {
1914
- START_POUR: d.POUR_STARTING
1915
- }
1916
- },
1917
- [d.POUR_STARTING]: {
1918
- on: {
1919
- POUR_ACTIVE: d.POURING,
1920
- CANCEL_POUR: d.POUR_CANCELING,
1921
- POUR_COMPLETED: d.IDLE
1922
- }
1923
- },
1924
- [d.POURING]: {
1925
- on: {
1926
- CANCEL_POUR: d.POUR_CANCELING,
1927
- POUR_COMPLETED: d.IDLE
1928
- }
1929
- },
1930
- [d.POUR_CANCELING]: {
1931
- on: {
1932
- POUR_CANCELED: d.IDLE
1933
- }
1934
- }
1935
- }
1936
- },
1937
- {
1938
- trackHistory: !1,
1939
- throwOnInvalid: !1
1940
- // Gracefully ignore invalid state calls (expected runtime scenarios)
1941
- }
1942
- )
1943
- ], w);
1944
- const ga = new Nt({
1945
- class: w,
1946
- type: ht
1947
- }), xe = {
1948
- ...Ye.registration,
1949
- ...Ve.registration,
1950
- ...st.registration,
1951
- ...Je.registration,
1952
- ...Ne.registration,
1953
- ...ot.registration,
1954
- ...Re.registration,
1955
- ...Ee.registration,
1956
- ...lt.registration,
1957
- ...it.registration
1958
- }, ia = (e) => () => (Tt(e)(), Jr.register(), Object.keys(xe).forEach((t) => {
1959
- const r = xe[t];
1960
- St(e)(t, r);
1961
- }), y[te].register(
1962
- "FirmwareUpdateInProgressTrouble",
1963
- async (t) => {
1964
- var r;
1965
- if ((r = t.data) != null && r.deviceId) {
1966
- const { model: a } = x(
1967
- lt.type
1968
- );
1969
- if (a) {
1970
- const i = a.boards.find(
1971
- (s) => s.id === t.data.deviceId
1972
- ) ? x(t.data.deviceId).model : void 0;
1973
- return {
1974
- devices: i ? i.name : ""
1975
- };
1976
- }
1977
- }
1978
- return {};
1979
- }
1980
- ), {
1981
- preload: R.model.preloadModel(e),
1982
- model: R.model.register(e),
1983
- companion: R.companion.register(e),
1984
- legacy: R.model.registerLegacyModel(e)
1985
- }), f = {
1986
- ...Dt
1987
- };
1988
- f.dispense = {
1989
- models: ia(f)
1990
- };
1991
- f.preload = R.model.preloadModel(f);
1992
- f.model = R.model.register(f);
1993
- f.companion = R.companion.register(f);
1994
- f.legacy = R.model.registerLegacyModel(f);
1995
- const ha = f;
1996
- export {
1997
- lt as A,
1998
- B,
1999
- Tr as C,
2000
- L as D,
2001
- h as E,
2002
- wr as F,
2003
- ga as G,
2004
- Je as H,
2005
- Ve as I,
2006
- Mr as J,
2007
- ha as K,
2008
- Fr as L,
2009
- Gr as M,
2010
- Ne as N,
2011
- Br as O,
2012
- ot as P,
2013
- xr as Q,
2014
- jr as R,
2015
- Wr as S,
2016
- We as T,
2017
- Sr as a,
2018
- Ee as b,
2019
- Qe as c,
2020
- it as d,
2021
- at as e,
2022
- Jr as f,
2023
- aa as g,
2024
- ra as h,
2025
- ta as i,
2026
- st as j,
2027
- Ye as k,
2028
- Re as l,
2029
- tt as m,
2030
- d as n,
2031
- xe as o,
2032
- zt as p,
2033
- ca as q,
2034
- ia as r,
2035
- Vt as s,
2036
- pa as t,
2037
- la as u,
2038
- da as v,
2039
- kt as w,
2040
- Xt as x,
2041
- Kt as y,
2042
- qe as z
2043
- };
2044
- //# sourceMappingURL=dispense-registration-manager-CzAqcL8D.js.map