@kosdev-code/kos-freestyle-sdk 2.0.32 → 2.0.34

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 (46) hide show
  1. package/{extension-utils-ua-l7F5-.js → extension-utils-B4aRuLqC.js} +2 -2
  2. package/{extension-utils-ua-l7F5-.js.map → extension-utils-B4aRuLqC.js.map} +1 -1
  3. package/{extension-utils-VVeh-q52.cjs → extension-utils-BY9yhVLb.cjs} +2 -2
  4. package/{extension-utils-VVeh-q52.cjs.map → extension-utils-BY9yhVLb.cjs.map} +1 -1
  5. package/freestyle-registration-manager-CI8el36E.js +1111 -0
  6. package/freestyle-registration-manager-CI8el36E.js.map +1 -0
  7. package/freestyle-registration-manager-Dbdeo0JU.cjs +2 -0
  8. package/freestyle-registration-manager-Dbdeo0JU.cjs.map +1 -0
  9. package/index.cjs +1 -1
  10. package/index.d.ts +1 -0
  11. package/index.d.ts.map +1 -1
  12. package/index.js +20 -18
  13. package/models/models/freestyle-assembly/freestyle-assembly-model.d.ts +6 -1
  14. package/models/models/freestyle-assembly/freestyle-assembly-model.d.ts.map +1 -1
  15. package/models/models/freestyle-holder/freestyle-holder-model.d.ts +2 -0
  16. package/models/models/freestyle-holder/freestyle-holder-model.d.ts.map +1 -1
  17. package/models/models/remote-tray/index.d.ts +6 -0
  18. package/models/models/remote-tray/index.d.ts.map +1 -0
  19. package/models/models/remote-tray/remote-tray-container-model.d.ts +21 -0
  20. package/models/models/remote-tray/remote-tray-container-model.d.ts.map +1 -0
  21. package/models/models/remote-tray/remote-tray-container-registration.d.ts +87 -0
  22. package/models/models/remote-tray/remote-tray-container-registration.d.ts.map +1 -0
  23. package/models/models/remote-tray/remote-tray-model.d.ts +175 -0
  24. package/models/models/remote-tray/remote-tray-model.d.ts.map +1 -0
  25. package/models/models/remote-tray/remote-tray-registration.d.ts +90 -0
  26. package/models/models/remote-tray/remote-tray-registration.d.ts.map +1 -0
  27. package/models/models/remote-tray/types/index.d.ts +10 -0
  28. package/models/models/types/assembly.d.ts +5 -0
  29. package/models/models/types/assembly.d.ts.map +1 -1
  30. package/models/utils/extensions/assembly/assembly-data-mapper.d.ts.map +1 -1
  31. package/models/utils/extensions/assembly/types.d.ts +5 -0
  32. package/models/utils/extensions/assembly/types.d.ts.map +1 -1
  33. package/models/utils/freestyle-registration-manager.d.ts.map +1 -1
  34. package/models.cjs +1 -1
  35. package/models.js +3 -3
  36. package/package.json +4 -4
  37. package/ui.cjs +1 -1
  38. package/ui.js +2 -2
  39. package/{use-nutrition-info-CnB4QbnQ.cjs → use-nutrition-info-BqyF2EOl.cjs} +2 -2
  40. package/{use-nutrition-info-CnB4QbnQ.cjs.map → use-nutrition-info-BqyF2EOl.cjs.map} +1 -1
  41. package/{use-nutrition-info-i7otBVPd.js → use-nutrition-info-uacoD9lS.js} +2 -2
  42. package/{use-nutrition-info-i7otBVPd.js.map → use-nutrition-info-uacoD9lS.js.map} +1 -1
  43. package/freestyle-registration-manager-BNSA2Xyl.cjs +0 -2
  44. package/freestyle-registration-manager-BNSA2Xyl.cjs.map +0 -1
  45. package/freestyle-registration-manager-CBMdfM3_.js +0 -920
  46. package/freestyle-registration-manager-CBMdfM3_.js.map +0 -1
@@ -1,920 +0,0 @@
1
- var Ie = Object.defineProperty;
2
- var Ae = (e, t, r) => t in e ? Ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var i = (e, t, r) => (Ae(e, typeof t != "symbol" ? t + "" : t, r), r);
4
- import { PourState as d, Assembly as te, KosModelRegistry as Oe, registerDispenseModels as Ee, Nozzle as Te, Pump as $e, Holder as Ce, PumpContainer as we, PumpIndex as Me } from "@kosdev-code/kos-dispense-sdk";
5
- import { kosModel as m, KosModelRegistrationFactory as _, KosModelContainer as Se, kosChild as De, resolveServiceUrl as S, ServiceFactory as D, createPropKey as re, kosStateProp as q, kosFuture as z, setupMinimalFutureSupport as ze, kosEffect as Re, EventBus as $, SingletonKosModelRegistrationFactory as ae, KosFeatureFlags as Q, KosContextManager as Ne, KosLog as R, FutureManager as Fe, kosParentAware as Le, kosAutoEffect as Ge, kosAction as T, FetchError as je, kosConfigProperty as y, KOS_MODEL_ID as f, kosModelEffect as Ue, MultipleFutureHandler as He, kosTopicHandler as Be, modelTypeEventTopicFactory as xe, DependencyLifecycle as Ke, getKosModelSync as I, RegistrationManager as g, registerCoreModels as qe, Trouble as Ye, ExtensionManager as F, EXTENSION_TROUBLE_DATA_MAPPER as L } from "@kosdev-code/kos-ui-sdk";
6
- var Ve = Object.defineProperty, We = Object.getOwnPropertyDescriptor, Ze = (e, t, r, s) => {
7
- for (var a = s > 1 ? void 0 : s ? We(t, r) : t, o = e.length - 1, n; o >= 0; o--)
8
- (n = e[o]) && (a = (s ? n(t, r, a) : n(a)) || a);
9
- return s && a && Ve(t, r, a), a;
10
- };
11
- const ie = "carb-agitator-model";
12
- let j = class {
13
- constructor(e, t, r) {
14
- i(this, "id");
15
- i(this, "name");
16
- i(this, "path");
17
- i(this, "logger");
18
- this.id = e, this.name = t.name, this.path = t.path, this.logger = r.logger;
19
- }
20
- // -------------------LIFECYCLE----------------------------
21
- async init() {
22
- this.logger.debug(`initializing carb-agitator ${this.id}`);
23
- }
24
- async load() {
25
- this.logger.debug(`loading carb-agitator ${this.id}`);
26
- }
27
- };
28
- j = Ze([
29
- m(ie)
30
- ], j);
31
- const se = new _({
32
- class: j,
33
- type: ie
34
- });
35
- var Qe = Object.defineProperty, Xe = Object.getOwnPropertyDescriptor, oe = (e, t, r, s) => {
36
- for (var a = s > 1 ? void 0 : s ? Xe(t, r) : t, o = e.length - 1, n; o >= 0; o--)
37
- (n = e[o]) && (a = (s ? n(t, r, a) : n(a)) || a);
38
- return s && a && Qe(t, r, a), a;
39
- };
40
- const ne = "cartridge-agitator-container-model";
41
- let C = class {
42
- constructor(e, t, r) {
43
- i(this, "id");
44
- i(this, "logger");
45
- i(this, "_models");
46
- this.id = e, this.logger = r.logger, this._models = new Se({
47
- parentId: e
48
- });
49
- }
50
- getModel(e) {
51
- return this._models.getModel(e);
52
- }
53
- get models() {
54
- return this._models;
55
- }
56
- get data() {
57
- return this._models.data;
58
- }
59
- addModel(e) {
60
- this._models.addModel(e);
61
- }
62
- removeModel(e) {
63
- this._models.removeModel(e);
64
- }
65
- // -------------------LIFECYCLE----------------------------
66
- async init() {
67
- this.logger.debug(
68
- `initializing cartridge-agitator-container container ${this.id}`
69
- );
70
- }
71
- async load() {
72
- this.logger.debug(
73
- `loading cartridge-agitator-container container ${this.id}`
74
- );
75
- }
76
- };
77
- oe([
78
- De
79
- ], C.prototype, "_models", 2);
80
- C = oe([
81
- m(ne)
82
- ], C);
83
- const { URL: le } = S("CARTRIDGE_AGITATOR_SERVICE"), { postModel: Je } = D.build({
84
- basePath: `${le}/api/ext/freestyle/freestyle/ice`
85
- }), ke = async (e, t) => {
86
- const r = await Je({
87
- model: {},
88
- tracker: t,
89
- urlOverride: `${le}/api/handle/${e}/test`
90
- });
91
- if (!(r != null && r.data))
92
- throw new Error("No response from server");
93
- return r.data;
94
- };
95
- var et = Object.defineProperty, tt = Object.getOwnPropertyDescriptor, Y = (e, t, r, s) => {
96
- for (var a = s > 1 ? void 0 : s ? tt(t, r) : t, o = e.length - 1, n; o >= 0; o--)
97
- (n = e[o]) && (a = (s ? n(t, r, a) : n(a)) || a);
98
- return s && a && et(t, r, a), a;
99
- };
100
- const ue = "cartridge-agitator-model";
101
- class w {
102
- }
103
- i(w, "TOPIC_AGITATION_STARTED", "/kos/events/ddk/agitation-started"), i(w, "TOPIC_AGITATION_ENDED", "/kos/events/ddk/agitation-ended");
104
- const rt = re("statePath");
105
- let A = class {
106
- constructor(e, t, r) {
107
- i(this, "id");
108
- i(this, "futureHandler");
109
- i(this, "logger");
110
- i(this, "disposer");
111
- i(this, "agitating");
112
- i(this, "path");
113
- i(this, "statePath");
114
- i(this, "name");
115
- this.id = e, this.logger = r.logger, this.path = t.path, this.name = t.name, this.statePath = t.statePath, ze(this);
116
- }
117
- get isAgitating() {
118
- return !!this.agitating.value;
119
- }
120
- async testAgitate(e) {
121
- if (!e)
122
- throw new Error("No tracker provided");
123
- return this.logger.info(`agitating cartridge-agitator ${this.id}`), ke(this.path, e);
124
- }
125
- // -------------------LIFECYCLE----------------------------
126
- async init() {
127
- this.logger.debug(`initializing cartridge-agitator ${this.id}`);
128
- }
129
- unload() {
130
- var e;
131
- (e = this.disposer) == null || e.call(this);
132
- }
133
- async load() {
134
- this.logger.debug(`loading cartridge-agitator ${this.id}`), this.disposer = Re(
135
- () => this.isAgitating,
136
- () => {
137
- var e;
138
- this.isAgitating ? (this.logger.info(`agitating cartridge-agitator ${this.id}`), $.publish(w.TOPIC_AGITATION_STARTED, {
139
- path: this.path,
140
- futureId: (e = this.futureHandler.future) == null ? void 0 : e.futureId
141
- })) : $.publish(w.TOPIC_AGITATION_ENDED, {
142
- path: this.path
143
- });
144
- },
145
- {}
146
- );
147
- }
148
- };
149
- Y([
150
- q({ path: rt, attribute: "agitating" })
151
- ], A.prototype, "agitating", 2);
152
- Y([
153
- z()
154
- ], A.prototype, "testAgitate", 1);
155
- A = Y([
156
- m(ue)
157
- ], A);
158
- const de = new _({
159
- class: A,
160
- type: ue
161
- }), V = new ae({
162
- class: C,
163
- type: ne
164
- });
165
- V.addRelatedModel(de);
166
- var at = Object.defineProperty, it = Object.getOwnPropertyDescriptor, st = (e, t, r, s) => {
167
- for (var a = s > 1 ? void 0 : s ? it(t, r) : t, o = e.length - 1, n; o >= 0; o--)
168
- (n = e[o]) && (a = (s ? n(t, r, a) : n(a)) || a);
169
- return s && a && at(t, r, a), a;
170
- };
171
- const ce = "freestyle-assembly-model", ot = "iceAgitator", nt = "carbAgitator";
172
- let U = class {
173
- constructor(e, t, r) {
174
- i(this, "id");
175
- i(this, "logger");
176
- i(this, "assembly");
177
- this.id = e, this.logger = r.logger, this.assembly = t.companionParent;
178
- }
179
- get holderGroups() {
180
- return this.assembly.holderGroups;
181
- }
182
- get nozzlePaths() {
183
- return this.assembly.nozzlePaths;
184
- }
185
- get allHolders() {
186
- return this.assembly.allHolders;
187
- }
188
- getHoldersByGroup(e) {
189
- return this.assembly.getHoldersByGroup(e);
190
- }
191
- getHoldersByNozzle(e) {
192
- return this.assembly.getHoldersByNozzle(e);
193
- }
194
- get pumpsByNozzle() {
195
- return this.assembly.pumpsByNozzle;
196
- }
197
- get pumpPaths() {
198
- return this.assembly.pumpPaths;
199
- }
200
- get boards() {
201
- return this.assembly.boards;
202
- }
203
- updateModel(e) {
204
- return this.assembly.updateModel(e);
205
- }
206
- get iceAgitator() {
207
- return this.assembly.iceAgitator;
208
- }
209
- get carbAgitator() {
210
- return this.assembly.carbAgitator;
211
- }
212
- get cartridgeAgitators() {
213
- return this.assembly.cartridgeAgitators;
214
- }
215
- get defaultCartridgeAgitator() {
216
- return this.assembly.cartridgeAgitators.data[0];
217
- }
218
- get cartridgeAgitatorModels() {
219
- return this.assembly.cartridgeAgitators.data;
220
- }
221
- get hasCartridgeAgitators() {
222
- return this.assembly.cartridgeAgitators.data.length > 0;
223
- }
224
- // -------------------LIFECYCLE----------------------------
225
- get supportsIce() {
226
- return Q.isFeatureEnabled(ot);
227
- }
228
- get supportsCarb() {
229
- return Q.isFeatureEnabled(nt);
230
- }
231
- async init() {
232
- this.logger.debug(`initializing freestyle-assembly ${this.id}`);
233
- }
234
- async load() {
235
- this.logger.debug(`loading freestyle-assembly ${this.id}`);
236
- }
237
- };
238
- U = st([
239
- m(ce)
240
- ], U);
241
- const H = new ae({
242
- class: U,
243
- type: ce
244
- });
245
- var lt = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, dt = (e, t, r, s) => {
246
- for (var a = s > 1 ? void 0 : s ? ut(t, r) : t, o = e.length - 1, n; o >= 0; o--)
247
- (n = e[o]) && (a = (s ? n(t, r, a) : n(a)) || a);
248
- return s && a && lt(t, r, a), a;
249
- };
250
- const ge = "freestyle-holder-model";
251
- function ct(e) {
252
- const t = Ne.getContext(e), r = t == null ? void 0 : t.get(
253
- H.type
254
- );
255
- if (!r) {
256
- R.error("Freestyle assembly not found");
257
- return;
258
- }
259
- return r;
260
- }
261
- async function gt(e, t) {
262
- if (!e || !t)
263
- return;
264
- const r = await e[t]();
265
- if (r != null && r.tracker)
266
- return Fe.getFuture(r.tracker);
267
- }
268
- let B = class {
269
- constructor(e, t, r) {
270
- i(this, "id");
271
- i(this, "logger");
272
- i(this, "holder");
273
- i(this, "future");
274
- this.id = e, this.logger = r.logger, this.holder = t.companionParent;
275
- }
276
- get agitated() {
277
- return this.holder.data.agitated;
278
- }
279
- async agitate() {
280
- if (!this.holder.data.agitated)
281
- return;
282
- this.future = void 0;
283
- const e = ct(this.id);
284
- if (!e)
285
- return;
286
- if (!e.defaultCartridgeAgitator) {
287
- this.logger.error("Agitator not found");
288
- return;
289
- }
290
- return this.future = await gt(
291
- e.defaultCartridgeAgitator,
292
- "testAgitate"
293
- ), this.future;
294
- }
295
- // -------------------LIFECYCLE----------------------------
296
- async init() {
297
- this.logger.debug(`initializing freestyle-holder ${this.id}`);
298
- }
299
- async load() {
300
- this.logger.debug(`loading freestyle-holder ${this.id}`);
301
- }
302
- };
303
- B = dt([
304
- m(ge)
305
- ], B);
306
- const X = new _({
307
- class: B,
308
- type: ge
309
- }), { URL: pt } = S("FREESTYLE-NOZZLE_SERVICE"), { getOne: ht } = D.build({
310
- basePath: `${pt}/api/freestyle-nozzle`
311
- }), E = R.createLogger({
312
- name: "freestyle-nozzle-service",
313
- group: "Services"
314
- });
315
- class yt extends Error {
316
- constructor(t) {
317
- super(t), this.name = "NutritionInfoError";
318
- }
319
- }
320
- class J extends Error {
321
- constructor(t) {
322
- super(t), this.name = "InvalidRequestError";
323
- }
324
- }
325
- const ft = async (e, t, r, s = "http://localhost:8081") => {
326
- if (E.debug("sending GET for freestyle-nozzle"), !t)
327
- throw E.error("Invalid freestyle-nozzle request: beverageId is required"), new J("No beverageId provided");
328
- if (!r || r.length === 0)
329
- throw E.error("Invalid freestyle-nozzle request: volumes are required"), new J("No volumes provided");
330
- const a = await ht({
331
- urlOverride: `${s}${e}/pipeline/beverage/engine/nutrition/${t}?volumes=${r.join(
332
- ","
333
- )}`
334
- });
335
- if (!(a != null && a.data))
336
- throw E.error("Failed to retrieve freestyle-nozzle data"), new Error("Failed to retrieve freestyle-nozzle data");
337
- if (a.data.error)
338
- throw new yt(a.data.error);
339
- return a.data;
340
- };
341
- var mt = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, _t = (e, t, r, s) => {
342
- for (var a = s > 1 ? void 0 : s ? bt(t, r) : t, o = e.length - 1, n; o >= 0; o--)
343
- (n = e[o]) && (a = (s ? n(t, r, a) : n(a)) || a);
344
- return s && a && mt(t, r, a), a;
345
- };
346
- const pe = "freestyle-nozzle-model";
347
- let x = class {
348
- constructor(e, t, r) {
349
- i(this, "id");
350
- i(this, "logger");
351
- i(this, "nozzleModel");
352
- i(this, "_cupSizes");
353
- i(this, "_nutritionInfo");
354
- i(this, "_disposer", null);
355
- this.id = e, this.logger = r.logger, this.nozzleModel = t.companionParent, this._cupSizes = [100];
356
- }
357
- set cupSizes(e) {
358
- this._cupSizes = e;
359
- }
360
- get nutritionInfo() {
361
- return this._nutritionInfo;
362
- }
363
- // -------------------LIFECYCLE----------------------------
364
- async init() {
365
- this.logger.debug(`initializing freestyle-nozzle ${this.id}`), this._disposer = Ge(async () => {
366
- if (this.nozzleModel.selectedPourable.beverage && this._cupSizes.length) {
367
- this.logger.debug(
368
- `selected beverage: ${this.nozzleModel.selectedPourable.beverage.rawId}. Volume: ${this._cupSizes.join(", ")}`
369
- );
370
- const e = this.nozzleModel.selectedPourable.beverage.rawId, t = this.nozzleModel.urlPrefix;
371
- try {
372
- const r = await ft(
373
- t,
374
- e,
375
- this._cupSizes
376
- );
377
- T(() => {
378
- this._nutritionInfo = r;
379
- });
380
- } catch (r) {
381
- this.logger.error(`Error fetching nutrition info: ${r}`);
382
- }
383
- }
384
- });
385
- }
386
- unload() {
387
- this.logger.debug(`unloading freestyle-nozzle ${this.id}`), this._disposer && this._disposer();
388
- }
389
- async load() {
390
- this.logger.debug(`loading freestyle-nozzle ${this.id}`);
391
- }
392
- };
393
- x = _t([
394
- Le(),
395
- m(pe)
396
- ], x);
397
- const k = new _({
398
- class: x,
399
- type: pe
400
- }), { URL: he } = S("PUMP_SERVICE"), { postModel: Pt } = D.build({
401
- basePath: `${he}/api/ext/freestyle/microCalibration`
402
- }), G = R.createLogger({
403
- name: "freestyle-pump-service",
404
- group: "Services"
405
- }), vt = async (e, t) => {
406
- var r, s, a, o, n;
407
- G.debug(
408
- `replacePump - sending POST request to /api/ext/freestyle/microCalibration/cal/${e}/code/${t}`
409
- );
410
- try {
411
- const l = await Pt({
412
- model: {},
413
- urlOverride: `${he}/api/ext/freestyle/microCalibration/cal/${e}/code/${t}`
414
- });
415
- return G.debug("replacePump - response:", l), ((l == null ? void 0 : l.status) === 200 || (l == null ? void 0 : l.status) === 499) && ((r = l.data) != null && r.error) ? [l.data.error || "unknownError", l.data] : [void 0, l == null ? void 0 : l.data];
416
- } catch (l) {
417
- if (G.error(
418
- `replacePump - sending POST request to /api/cal/${e}/code/${t}`,
419
- l
420
- ), l instanceof je) {
421
- const p = ((a = (s = l.payload) == null ? void 0 : s.data) == null ? void 0 : a.error) || ((o = l.payload) == null ? void 0 : o.error) || "unknownError";
422
- return [p, ((n = l.payload) == null ? void 0 : n.data) || { error: p }];
423
- }
424
- }
425
- return ["unknownError", { error: "unknownError" }];
426
- };
427
- var It = Object.defineProperty, At = Object.getOwnPropertyDescriptor, Ot = (e, t, r, s) => {
428
- for (var a = s > 1 ? void 0 : s ? At(t, r) : t, o = e.length - 1, n; o >= 0; o--)
429
- (n = e[o]) && (a = (s ? n(t, r, a) : n(a)) || a);
430
- return s && a && It(t, r, a), a;
431
- };
432
- const ye = "freestyle-pump-model";
433
- let K = class {
434
- constructor(e, t, r) {
435
- i(this, "id");
436
- i(this, "logger");
437
- i(this, "pump");
438
- this.id = e, this.logger = r.logger, this.pump = t.companionParent;
439
- }
440
- // -------------------LIFECYCLE----------------------------
441
- async replacePump(e) {
442
- const [t, r] = await vt(this.pump.path, e);
443
- return t && this.logger.error(`Failed to replace the pump, ${this.pump.id}`, t), [t, r];
444
- }
445
- };
446
- K = Ot([
447
- m(ye)
448
- ], K);
449
- const ee = new _({
450
- class: K,
451
- type: ye
452
- }), { URL: P } = S("ICE_AGITATOR_SERVICE"), { getAll: fe, postModel: N } = D.build({
453
- basePath: `${P}/api/ext/freestyle/ice`
454
- }), me = R.createLogger({
455
- name: "ice-agitator-service",
456
- group: "Services"
457
- }), Et = async (e) => (me.debug("sending GET for ice types"), await fe({
458
- urlOverride: `${P}/api/handle/${e}/types`
459
- })), Tt = async (e, t) => (me.debug("sending POST for ice types"), await N({
460
- urlOverride: `${P}/api/handle/${e}/type/${t}`,
461
- model: {}
462
- })), $t = async (e) => await fe({
463
- urlOverride: `${P}/api/kos/config/details/${e}/4`
464
- }), Ct = async (e, t) => {
465
- const r = await N({
466
- model: {},
467
- tracker: t,
468
- urlOverride: `${P}/api/handle/${e}/pour`
469
- });
470
- if (!(r != null && r.data))
471
- throw new Error("No response from server");
472
- return r == null ? void 0 : r.data;
473
- }, wt = async (e, t) => {
474
- const r = await N({
475
- model: {},
476
- tracker: t,
477
- urlOverride: `${P}/api/handle/${e}/test/agitation`
478
- });
479
- if (!(r != null && r.data))
480
- throw new Error("No response from server");
481
- return r == null ? void 0 : r.data;
482
- }, Mt = async (e, t) => {
483
- const r = await N({
484
- model: {},
485
- tracker: t,
486
- urlOverride: `${P}/api/handle/${e}/test/gate`
487
- });
488
- if (!(r != null && r.data))
489
- throw new Error("No response from server");
490
- return r == null ? void 0 : r.data;
491
- };
492
- var St = Object.defineProperty, Dt = Object.getOwnPropertyDescriptor, c = (e, t, r, s) => {
493
- for (var a = s > 1 ? void 0 : s ? Dt(t, r) : t, o = e.length - 1, n; o >= 0; o--)
494
- (n = e[o]) && (a = (s ? n(t, r, a) : n(a)) || a);
495
- return s && a && St(t, r, a), a;
496
- };
497
- class M {
498
- }
499
- i(M, "TOPIC_AGITATION_STARTED", "/kos/events/ddk/ice-agitation-started"), i(M, "TOPIC_AGITATION_ENDED", "/kos/events/ddk/ice-agitation-ended");
500
- const be = "ice-agitator-model", _e = re("statePath");
501
- let u = class {
502
- constructor(e, t, r) {
503
- i(this, "id");
504
- i(this, "name");
505
- i(this, "path");
506
- i(this, "futureHandler");
507
- i(this, "volWithoutIceMl");
508
- i(this, "durationSec");
509
- i(this, "enableIceChuteClear");
510
- i(this, "iceChuteClearDurationMs");
511
- i(this, "iceChuteClearIntervalSec");
512
- i(this, "iceChuteClearRetryIntervalSec");
513
- i(this, "maxDispenseSec");
514
- i(this, "type");
515
- i(this, "dilutionOffset");
516
- i(this, "inactivitySec");
517
- i(this, "agitating");
518
- i(this, "iceChuteOpen");
519
- i(this, "statePath");
520
- i(this, "_allIceTypes");
521
- i(this, "logger");
522
- i(this, "currentState", d.IDLE);
523
- i(this, "resetDefaultValues", async () => await $t(this.path));
524
- this.id = e, this.name = t.name, this.path = t.path, this.statePath = t.statePath, this._allIceTypes = [], this.logger = r.logger, this.futureHandler = new He(this);
525
- }
526
- get iceTypes() {
527
- return this._allIceTypes;
528
- }
529
- get isAgitating() {
530
- return !!this.agitating.value;
531
- }
532
- get isIceChuteOpen() {
533
- return !!this.iceChuteOpen.value;
534
- }
535
- get future() {
536
- return this.futureHandler.future;
537
- }
538
- get pourFuture() {
539
- return this.futureHandler.futureMap.get("pour");
540
- }
541
- get agitateFuture() {
542
- return this.futureHandler.futureMap.get("agitate");
543
- }
544
- get gateFuture() {
545
- return this.futureHandler.futureMap.get("gate");
546
- }
547
- /**
548
- * A derived value that indicates if the nozzle is currently pouring a beverage.
549
- * @readonly
550
- */
551
- get isPouring() {
552
- var e;
553
- return !!(this.pourFuture && !((e = this.pourFuture) != null && e.endState)) || this.currentState === d.POUR_STARTING || this.currentState === d.POURING || this.currentState === d.POUR_CANCELING;
554
- }
555
- /**
556
- * A derived value that indicates if it is possible to dispense ice.
557
- *
558
- * The value is observable and will change as the current dispense state changes
559
- * @readonly
560
- * */
561
- get canPour() {
562
- return this.currentState === d.IDLE;
563
- }
564
- updateIfCurrent(e, t) {
565
- this.currentState === e && T(() => {
566
- this.currentState = t;
567
- });
568
- }
569
- async pourIce(e) {
570
- try {
571
- if (this.currentState === d.IDLE) {
572
- if (this.updateIfCurrent(d.IDLE, d.POUR_STARTING), !e)
573
- throw new Error("No tracker provided");
574
- const t = await Ct(this.path, e);
575
- return this.updateIfCurrent(d.POUR_STARTING, d.POURING), t != null && t.endState && this.updateIfCurrent(d.POURING, d.IDLE), t;
576
- } else
577
- throw new Error(`Cannot pour in state ${this.currentState}`);
578
- } catch (t) {
579
- throw this.logger.error(t), this.currentState = d.IDLE, t;
580
- }
581
- }
582
- /**
583
- * An action that will cancel the ice dispense if it is currently in progress.
584
- * */
585
- async cancelIceDispense() {
586
- var e;
587
- this.currentState === d.POURING || this.currentState === d.POUR_STARTING ? (this.currentState = d.POUR_CANCELING, await ((e = this.pourFuture) == null ? void 0 : e.cancelFuture()), T(() => {
588
- this.currentState = d.IDLE;
589
- })) : this.logger.warn(
590
- `Cannot cancel ice dispense in state ${this.currentState}`
591
- );
592
- }
593
- async testAgitate(e) {
594
- if (!e)
595
- throw new Error("No tracker provided");
596
- return this.logger.info(`agitating ice-agitator ${this.id}`), wt(this.path, e);
597
- }
598
- async testGate(e) {
599
- if (!e)
600
- throw new Error("No tracker provided");
601
- return this.logger.info(`testing ice gate: ${this.id}`), Mt(this.path, e);
602
- }
603
- handleAgitationChange() {
604
- var e;
605
- this.isAgitating ? (this.logger.info(`agitating ice-agitator ${this.id}`), $.publish(M.TOPIC_AGITATION_STARTED, {
606
- path: this.path,
607
- futureId: (e = this.futureHandler.future) == null ? void 0 : e.futureId
608
- })) : $.publish(M.TOPIC_AGITATION_ENDED, {
609
- path: this.path
610
- });
611
- }
612
- async updateIceType(e) {
613
- await Tt(this.path, e);
614
- }
615
- async init() {
616
- this.logger.debug(`initializing ice-agitator ${this.id}`);
617
- }
618
- async load() {
619
- this.logger.debug(`loading ice-agitator ${this.id}`);
620
- const e = await Et(this.path);
621
- (e == null ? void 0 : e.status) === 200 && T(() => {
622
- this._allIceTypes = e.data || [];
623
- });
624
- }
625
- };
626
- c([
627
- y({
628
- path: f,
629
- attribute: "settings.volWithoutIceMl"
630
- })
631
- ], u.prototype, "volWithoutIceMl", 2);
632
- c([
633
- y({
634
- path: f,
635
- attribute: "settings.durationSec",
636
- converter: {
637
- to: "second"
638
- }
639
- })
640
- ], u.prototype, "durationSec", 2);
641
- c([
642
- y({
643
- path: f,
644
- attribute: "enableIceChuteClear"
645
- })
646
- ], u.prototype, "enableIceChuteClear", 2);
647
- c([
648
- y({
649
- path: f,
650
- attribute: "iceChuteClearDurationMs"
651
- })
652
- ], u.prototype, "iceChuteClearDurationMs", 2);
653
- c([
654
- y({
655
- path: f,
656
- attribute: "iceChuteClearIntervalSec"
657
- })
658
- ], u.prototype, "iceChuteClearIntervalSec", 2);
659
- c([
660
- y({
661
- path: f,
662
- attribute: "iceChuteClearRetryIntervalSec"
663
- })
664
- ], u.prototype, "iceChuteClearRetryIntervalSec", 2);
665
- c([
666
- y({
667
- path: f,
668
- attribute: "maxDispenseSec"
669
- })
670
- ], u.prototype, "maxDispenseSec", 2);
671
- c([
672
- y({
673
- path: f,
674
- attribute: "type"
675
- })
676
- ], u.prototype, "type", 2);
677
- c([
678
- y({
679
- path: f,
680
- attribute: "settings.dilutionOffset"
681
- })
682
- ], u.prototype, "dilutionOffset", 2);
683
- c([
684
- y({
685
- path: f,
686
- attribute: "settings.inactivitySec",
687
- converter: {
688
- to: "minute"
689
- }
690
- })
691
- ], u.prototype, "inactivitySec", 2);
692
- c([
693
- q({ path: _e, attribute: "agitating" })
694
- ], u.prototype, "agitating", 2);
695
- c([
696
- q({ path: _e, attribute: "iceChuteOpen" })
697
- ], u.prototype, "iceChuteOpen", 2);
698
- c([
699
- z({ alias: "pour" })
700
- ], u.prototype, "pourIce", 1);
701
- c([
702
- z({ alias: "agitate" })
703
- ], u.prototype, "testAgitate", 1);
704
- c([
705
- z({
706
- alias: "gate"
707
- })
708
- ], u.prototype, "testGate", 1);
709
- c([
710
- Ue({
711
- dependencies: (e) => [e.isAgitating]
712
- })
713
- ], u.prototype, "handleAgitationChange", 1);
714
- u = c([
715
- m(be)
716
- ], u);
717
- const Pe = new _({
718
- class: u,
719
- type: be
720
- });
721
- var zt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, W = (e, t, r, s) => {
722
- for (var a = s > 1 ? void 0 : s ? Rt(t, r) : t, o = e.length - 1, n; o >= 0; o--)
723
- (n = e[o]) && (a = (s ? n(t, r, a) : n(a)) || a);
724
- return s && a && zt(t, r, a), a;
725
- };
726
- const Z = "agitation-required-trouble-model", Nt = (e) => {
727
- if (e.data.agitationRequired)
728
- return Z;
729
- }, Ft = "InsufficientAgitationTrouble";
730
- let O = class {
731
- constructor(e, t, r) {
732
- i(this, "id");
733
- i(this, "logger");
734
- i(this, "trouble");
735
- i(this, "_deferred");
736
- i(this, "_holdersLoaded", !1);
737
- i(this, "agitateBeforePour");
738
- this.id = e, this.logger = r.logger, this._deferred = !1, this.trouble = t.companionParent;
739
- }
740
- async resolve() {
741
- return this.trouble.resolve();
742
- }
743
- get holder() {
744
- const e = this.trouble.data.holderPaths[0], t = I(e);
745
- if (!(!this._holdersLoaded && !t.model))
746
- return t == null ? void 0 : t.model;
747
- }
748
- updateHolder() {
749
- if (!this._holdersLoaded) {
750
- const e = this.trouble.data.holderPaths[0];
751
- I(e).model && (this._holdersLoaded = !0);
752
- }
753
- }
754
- get shouldDefer() {
755
- var s, a;
756
- if (!this.holder)
757
- return !0;
758
- const t = (((s = this.holder) == null ? void 0 : s.troublesByType[Ft]) || []).length > 0;
759
- return !!((a = this.agitateBeforePour) != null && a.value) && t;
760
- }
761
- get deferred() {
762
- return this._deferred;
763
- }
764
- defer() {
765
- this._deferred = !0;
766
- }
767
- clearDefer() {
768
- this._deferred = !1;
769
- }
770
- };
771
- W([
772
- y({
773
- path: "app:kosdev.ddk:app",
774
- attribute: "ncui.agitateBeforePour"
775
- })
776
- ], O.prototype, "agitateBeforePour", 2);
777
- W([
778
- Be({
779
- topic: xe(te.type),
780
- lifecycle: Ke.INIT
781
- })
782
- ], O.prototype, "updateHolder", 1);
783
- O = W([
784
- m(Z)
785
- ], O);
786
- const Lt = new _({
787
- class: O,
788
- type: Z
789
- }), Gt = ["iceAgitator", "carbAgitator"], jt = {
790
- iceAgitator: Pe.factory,
791
- carbAgitator: se.factory
792
- }, Kt = async (e) => {
793
- const t = V.instance().options({}).build(), r = e.assemblies.reduce((o, n) => {
794
- var l;
795
- return Gt.forEach((p) => {
796
- var v;
797
- const b = n[p];
798
- if (b) {
799
- const ve = jt[p](b.path);
800
- o[p] = ve({
801
- name: b.name,
802
- path: b.path,
803
- statePath: ((v = b.state) == null ? void 0 : v.path) || ""
804
- });
805
- }
806
- }), (l = n.cartridgeAgitators) == null || l.forEach((p) => {
807
- var v;
808
- const b = de.instance(
809
- p.path
810
- ).options({
811
- name: p.name,
812
- path: p.path,
813
- statePath: ((v = p.state) == null ? void 0 : v.path) || ""
814
- }).build();
815
- t.addModel(b);
816
- }), o;
817
- }, {}), s = !!r.iceAgitator, a = !!r.carbAgitator;
818
- return {
819
- ...r,
820
- cartridgeAgitators: t,
821
- supportsCarb: a,
822
- supportsIce: s
823
- };
824
- }, Ut = (e) => () => (qe(e)(), Ee(e)(), k.register(), H.register(), Pe.register(), se.register(), V.register(), ee.register(), X.register(), g.companion.register(e)(
825
- Te.type,
826
- k.type
827
- ), g.companion.register(e)(
828
- te.type,
829
- H.type
830
- ), Lt.register(), g.companion.register(e)(
831
- Ye.type,
832
- Nt
833
- ), g.companion.register(e)($e.type, ee.type), g.companion.register(e)(
834
- Ce.type,
835
- X.type
836
- ), F[L].register(
837
- "EnjoyByTrouble",
838
- async (t) => {
839
- if (t.data.enjoyByDate) {
840
- const r = new Date(t.data.enjoyByDate);
841
- return {
842
- enjoyByDays: Math.floor(
843
- ((/* @__PURE__ */ new Date()).getTime() - r.getTime()) / (1e3 * 60 * 60 * 24)
844
- ) || ""
845
- };
846
- }
847
- return {};
848
- }
849
- ), F[L].register(
850
- "SuperPumpRequiredTrouble",
851
- // This is the trouble type
852
- async (t) => {
853
- const { model: r } = I(
854
- we.type
855
- );
856
- return r ? {
857
- superPumps: r.models.getIndexByKey(
858
- Me.byType,
859
- "microSuper"
860
- ).map((o) => o.name).join(", ")
861
- } : {};
862
- }
863
- ), F[L].register(
864
- "MicroPumpAirDetectTrouble",
865
- async (t) => {
866
- if (t.ifaces.includes("container"))
867
- return {};
868
- if (t.data.pumpPath) {
869
- const { model: r } = I(
870
- t.data.pumpPath
871
- );
872
- if (r) {
873
- const s = r.ingredientId ? I(r.ingredientId).model : void 0;
874
- return {
875
- ingredientId: r.ingredientId,
876
- ingredientName: (s == null ? void 0 : s.name) || ""
877
- };
878
- }
879
- }
880
- return {};
881
- }
882
- ), {
883
- preload: g.model.preloadModel(e),
884
- model: g.model.register(e),
885
- companion: g.companion.register(e),
886
- legacy: g.model.registerLegacyModel(e)
887
- }), h = {
888
- ...Oe
889
- };
890
- h.freestyle = {
891
- models: Ut(h)
892
- };
893
- h.preload = g.model.preloadModel(h);
894
- h.model = g.model.register(h);
895
- h.companion = g.companion.register(h);
896
- h.legacy = g.model.registerLegacyModel(h);
897
- const qt = h;
898
- export {
899
- Ft as A,
900
- se as C,
901
- H as F,
902
- M as I,
903
- qt as K,
904
- yt as N,
905
- V as a,
906
- w as b,
907
- de as c,
908
- X as d,
909
- k as e,
910
- ee as f,
911
- Pe as g,
912
- Lt as h,
913
- J as i,
914
- ft as j,
915
- vt as k,
916
- Kt as l,
917
- ot as m,
918
- Ut as r
919
- };
920
- //# sourceMappingURL=freestyle-registration-manager-CBMdfM3_.js.map