@kosdev-code/kos-freestyle-sdk 2.0.33 → 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
@@ -0,0 +1,1111 @@
1
+ var Ne = Object.defineProperty;
2
+ var Fe = (e, t, r) => t in e ? Ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var o = (e, t, r) => (Fe(e, typeof t != "symbol" ? t + "" : t, r), r);
4
+ import { kosModel as f, KosModelRegistrationFactory as P, KosModelContainer as de, kosChild as X, resolveServiceUrl as L, ServiceFactory as G, createPropKey as j, kosStateProp as J, kosFuture as U, setupMinimalFutureSupport as Le, kosEffect as Ge, EventBus as w, SingletonKosModelRegistrationFactory as k, kosParentAware as ue, KosFeatureFlags as H, kosConfigProperty as p, getKosModelSync as v, KosContextManager as je, KosLog as A, FutureManager as Ue, kosAutoEffect as Be, kosAction as M, FetchError as He, KOS_MODEL_ID as m, kosModelEffect as xe, MultipleFutureHandler as Ke, kosTopicHandler as Ye, modelTypeEventTopicFactory as qe, DependencyLifecycle as Ve, RegistrationManager as h, registerCoreModels as We, Trouble as Ze, ExtensionManager as x, EXTENSION_TROUBLE_DATA_MAPPER as K } from "@kosdev-code/kos-ui-sdk";
5
+ import { PourState as u, Assembly as ge, KosModelRegistry as Qe, registerDispenseModels as Xe, Nozzle as Je, Pump as ke, Holder as et, PumpContainer as tt, PumpIndex as rt } from "@kosdev-code/kos-dispense-sdk";
6
+ var at = Object.defineProperty, ot = Object.getOwnPropertyDescriptor, st = (e, t, r, s) => {
7
+ for (var a = s > 1 ? void 0 : s ? ot(t, r) : t, i = e.length - 1, n; i >= 0; i--)
8
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
9
+ return s && a && at(t, r, a), a;
10
+ };
11
+ const ce = "carb-agitator-model";
12
+ let q = class {
13
+ constructor(e, t, r) {
14
+ o(this, "id");
15
+ o(this, "name");
16
+ o(this, "path");
17
+ o(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
+ q = st([
29
+ f(ce)
30
+ ], q);
31
+ const he = new P({
32
+ class: q,
33
+ type: ce
34
+ });
35
+ var it = Object.defineProperty, nt = Object.getOwnPropertyDescriptor, pe = (e, t, r, s) => {
36
+ for (var a = s > 1 ? void 0 : s ? nt(t, r) : t, i = e.length - 1, n; i >= 0; i--)
37
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
38
+ return s && a && it(t, r, a), a;
39
+ };
40
+ const ye = "cartridge-agitator-container-model";
41
+ let S = class {
42
+ constructor(e, t, r) {
43
+ o(this, "id");
44
+ o(this, "logger");
45
+ o(this, "_models");
46
+ this.id = e, this.logger = r.logger, this._models = new de({
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
+ pe([
78
+ X
79
+ ], S.prototype, "_models", 2);
80
+ S = pe([
81
+ f(ye)
82
+ ], S);
83
+ const { URL: fe } = L("CARTRIDGE_AGITATOR_SERVICE"), { postModel: lt } = G.build({
84
+ basePath: `${fe}/api/ext/freestyle/freestyle/ice`
85
+ }), dt = async (e, t) => {
86
+ const r = await lt({
87
+ model: {},
88
+ tracker: t,
89
+ urlOverride: `${fe}/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 ut = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, ee = (e, t, r, s) => {
96
+ for (var a = s > 1 ? void 0 : s ? gt(t, r) : t, i = e.length - 1, n; i >= 0; i--)
97
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
98
+ return s && a && ut(t, r, a), a;
99
+ };
100
+ const me = "cartridge-agitator-model";
101
+ class R {
102
+ }
103
+ o(R, "TOPIC_AGITATION_STARTED", "/kos/events/ddk/agitation-started"), o(R, "TOPIC_AGITATION_ENDED", "/kos/events/ddk/agitation-ended");
104
+ const ct = j("statePath");
105
+ let O = class {
106
+ constructor(e, t, r) {
107
+ o(this, "id");
108
+ o(this, "futureHandler");
109
+ o(this, "logger");
110
+ o(this, "disposer");
111
+ o(this, "agitating");
112
+ o(this, "path");
113
+ o(this, "statePath");
114
+ o(this, "name");
115
+ this.id = e, this.logger = r.logger, this.path = t.path, this.name = t.name, this.statePath = t.statePath, Le(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}`), dt(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 = Ge(
135
+ () => this.isAgitating,
136
+ () => {
137
+ var e;
138
+ this.isAgitating ? (this.logger.info(`agitating cartridge-agitator ${this.id}`), w.publish(R.TOPIC_AGITATION_STARTED, {
139
+ path: this.path,
140
+ futureId: (e = this.futureHandler.future) == null ? void 0 : e.futureId
141
+ })) : w.publish(R.TOPIC_AGITATION_ENDED, {
142
+ path: this.path
143
+ });
144
+ },
145
+ {}
146
+ );
147
+ }
148
+ };
149
+ ee([
150
+ J({ path: ct, attribute: "agitating" })
151
+ ], O.prototype, "agitating", 2);
152
+ ee([
153
+ U()
154
+ ], O.prototype, "testAgitate", 1);
155
+ O = ee([
156
+ f(me)
157
+ ], O);
158
+ const _e = new P({
159
+ class: O,
160
+ type: me
161
+ }), te = new k({
162
+ class: S,
163
+ type: ye
164
+ });
165
+ te.addRelatedModel(_e);
166
+ var ht = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, Pe = (e, t, r, s) => {
167
+ for (var a = s > 1 ? void 0 : s ? pt(t, r) : t, i = e.length - 1, n; i >= 0; i--)
168
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
169
+ return s && a && ht(t, r, a), a;
170
+ };
171
+ const be = "freestyle-assembly-model", yt = "iceAgitator", ft = "carbAgitator", mt = "remoteTrays";
172
+ let D = class {
173
+ constructor(e, t, r) {
174
+ o(this, "id");
175
+ o(this, "logger");
176
+ o(this, "assembly");
177
+ o(this, "_remoteTrays");
178
+ this.id = e, this.logger = r.logger, this.assembly = t.companionParent;
179
+ }
180
+ get holderGroups() {
181
+ return this.assembly.holderGroups;
182
+ }
183
+ get nozzlePaths() {
184
+ return this.assembly.nozzlePaths;
185
+ }
186
+ get allHolders() {
187
+ return this.assembly.allHolders;
188
+ }
189
+ getHoldersByGroup(e) {
190
+ return this.assembly.getHoldersByGroup(e);
191
+ }
192
+ getHoldersByNozzle(e) {
193
+ return this.assembly.getHoldersByNozzle(e);
194
+ }
195
+ get pumpsByNozzle() {
196
+ return this.assembly.pumpsByNozzle;
197
+ }
198
+ get pumpPaths() {
199
+ return this.assembly.pumpPaths;
200
+ }
201
+ get boards() {
202
+ return this.assembly.boards;
203
+ }
204
+ updateModel(e) {
205
+ return this.assembly.updateModel(e);
206
+ }
207
+ get iceAgitator() {
208
+ return this.assembly.iceAgitator;
209
+ }
210
+ get carbAgitator() {
211
+ return this.assembly.carbAgitator;
212
+ }
213
+ get cartridgeAgitators() {
214
+ return this.assembly.cartridgeAgitators;
215
+ }
216
+ get defaultCartridgeAgitator() {
217
+ return this.assembly.cartridgeAgitators.data[0];
218
+ }
219
+ get cartridgeAgitatorModels() {
220
+ return this.assembly.cartridgeAgitators.data;
221
+ }
222
+ get hasCartridgeAgitators() {
223
+ return this.assembly.cartridgeAgitators.data.length > 0;
224
+ }
225
+ get remoteTrays() {
226
+ return this.assembly.remoteTrays;
227
+ }
228
+ get hasRemoteTrays() {
229
+ return this.assembly.remoteTrays ? this.assembly.remoteTrays.data.length > 0 : !1;
230
+ }
231
+ // -------------------LIFECYCLE----------------------------
232
+ get supportsRemoteTrays() {
233
+ return H.isFeatureEnabled(mt);
234
+ }
235
+ get supportsIce() {
236
+ return H.isFeatureEnabled(yt);
237
+ }
238
+ get supportsCarb() {
239
+ return H.isFeatureEnabled(ft);
240
+ }
241
+ async init() {
242
+ this.logger.debug(`initializing freestyle-assembly ${this.id}`);
243
+ }
244
+ };
245
+ Pe([
246
+ X
247
+ ], D.prototype, "_remoteTrays", 2);
248
+ D = Pe([
249
+ ue(),
250
+ f(be)
251
+ ], D);
252
+ const V = new k({
253
+ class: D,
254
+ type: be
255
+ });
256
+ var _t = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, ve = (e, t, r, s) => {
257
+ for (var a = s > 1 ? void 0 : s ? Pt(t, r) : t, i = e.length - 1, n; i >= 0; i--)
258
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
259
+ return s && a && _t(t, r, a), a;
260
+ };
261
+ const Ie = "remote-tray-model";
262
+ j("holderPath");
263
+ const bt = j("configPath");
264
+ let z = class {
265
+ constructor(e, t, r) {
266
+ /** Unique identifier for the remote tray instance */
267
+ o(this, "id");
268
+ o(this, "logger");
269
+ /** Path reference to the associated holder model */
270
+ o(this, "holderPath");
271
+ /** Configuration path for tray-specific settings */
272
+ o(this, "configPath");
273
+ /** Display name of the remote tray */
274
+ o(this, "name");
275
+ o(this, "remoteTrayEnabled");
276
+ this.id = e, this.logger = r.logger, this.holderPath = t.holderPath, this.configPath = t.configPath, this.name = t.name;
277
+ }
278
+ /**
279
+ * Gets the troubles from the associated holder model.
280
+ * Propagates trouble states from the holder to this remote tray.
281
+ *
282
+ * @returns Array of trouble models from the holder, or empty array if no holder
283
+ */
284
+ get troubles() {
285
+ var e;
286
+ return ((e = this.holder) == null ? void 0 : e.troubles) ?? [];
287
+ }
288
+ /**
289
+ * Gets the highest priority trouble status.
290
+ * Currently returns empty string as troubles are managed by the holder.
291
+ *
292
+ * @returns Empty string (trouble status handled by holder)
293
+ */
294
+ get troubleStatus() {
295
+ return "";
296
+ }
297
+ /**
298
+ * Gets troubles grouped by type from the associated holder.
299
+ *
300
+ * @returns Record of troubles grouped by type from the holder, or empty object if no holder
301
+ */
302
+ get troublesByType() {
303
+ var e;
304
+ return ((e = this.holder) == null ? void 0 : e.troublesByType) ?? {};
305
+ }
306
+ /**
307
+ * Updates the model with new configuration options.
308
+ * Can be used to modify the holder path, config path, or name after initialization.
309
+ *
310
+ * @param _options - New configuration options for the remote tray
311
+ */
312
+ updateModel(e) {
313
+ }
314
+ /**
315
+ * Gets the associated holder model for this remote tray.
316
+ * Uses synchronous model lookup to retrieve the holder by path.
317
+ *
318
+ * @returns The HolderModel instance referenced by holderPath, or undefined if not found
319
+ */
320
+ get holder() {
321
+ return v(this.holderPath).model;
322
+ }
323
+ /**
324
+ * Determines if the remote tray is currently active.
325
+ * Active state is based on the remoteTrayEnabled configuration property.
326
+ *
327
+ * @returns true if the tray is enabled, false otherwise
328
+ */
329
+ get active() {
330
+ return !!this.remoteTrayEnabled.value;
331
+ }
332
+ // -------------------LIFECYCLE----------------------------
333
+ /**
334
+ * Initializes the remote tray model.
335
+ * Called during the model lifecycle initialization phase.
336
+ * Sets up initial state and prepares the model for use.
337
+ *
338
+ * @returns Promise that resolves when initialization is complete
339
+ */
340
+ async init() {
341
+ this.logger.debug(`initializing remote-tray ${this.id}`);
342
+ }
343
+ /**
344
+ * Loads the remote tray configuration and associated data.
345
+ * Called during the model lifecycle load phase.
346
+ * Typically loads configuration settings and establishes holder references.
347
+ *
348
+ * @returns Promise that resolves when loading is complete
349
+ */
350
+ async load() {
351
+ this.logger.debug(`loading remote-tray ${this.id}`);
352
+ }
353
+ };
354
+ ve([
355
+ p({
356
+ path: bt,
357
+ attribute: "enabled"
358
+ })
359
+ ], z.prototype, "remoteTrayEnabled", 2);
360
+ z = ve([
361
+ f(Ie)
362
+ ], z);
363
+ const E = new P({
364
+ class: z,
365
+ type: Ie
366
+ });
367
+ var vt = Object.defineProperty, It = Object.getOwnPropertyDescriptor, Te = (e, t, r, s) => {
368
+ for (var a = s > 1 ? void 0 : s ? It(t, r) : t, i = e.length - 1, n; i >= 0; i--)
369
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
370
+ return s && a && vt(t, r, a), a;
371
+ };
372
+ const Oe = "remote-tray-container-model";
373
+ let N = class {
374
+ constructor(e, t, r) {
375
+ o(this, "id");
376
+ o(this, "logger");
377
+ o(this, "_models");
378
+ this.id = e, this.logger = r.logger, this._models = new de({
379
+ parentId: e
380
+ });
381
+ }
382
+ getModel(e) {
383
+ return this._models.getModel(e);
384
+ }
385
+ get models() {
386
+ return this._models;
387
+ }
388
+ get data() {
389
+ return this._models.data;
390
+ }
391
+ updateModel(e) {
392
+ }
393
+ addModel(e) {
394
+ this._models.addModel(e);
395
+ }
396
+ removeModel(e) {
397
+ this._models.removeModel(e);
398
+ }
399
+ // -------------------LIFECYCLE----------------------------
400
+ async init() {
401
+ this.logger.debug(
402
+ `initializing remote-tray-container container ${this.id}`
403
+ );
404
+ }
405
+ async load() {
406
+ this.logger.debug(`loading remote-tray-container container ${this.id}`);
407
+ }
408
+ };
409
+ Te([
410
+ X
411
+ ], N.prototype, "_models", 2);
412
+ N = Te([
413
+ f(Oe)
414
+ ], N);
415
+ const re = new k({
416
+ class: N,
417
+ type: Oe
418
+ });
419
+ re.addRelatedModel(E);
420
+ var Tt = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor, Et = (e, t, r, s) => {
421
+ for (var a = s > 1 ? void 0 : s ? Ot(t, r) : t, i = e.length - 1, n; i >= 0; i--)
422
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
423
+ return s && a && Tt(t, r, a), a;
424
+ };
425
+ const Ee = "freestyle-holder-model";
426
+ function $t(e) {
427
+ const t = je.getContext(e), r = t == null ? void 0 : t.get(
428
+ V.type
429
+ );
430
+ if (!r) {
431
+ A.error("Freestyle assembly not found");
432
+ return;
433
+ }
434
+ return r;
435
+ }
436
+ async function At(e, t) {
437
+ if (!e || !t)
438
+ return;
439
+ const r = await e[t]();
440
+ if (r != null && r.tracker)
441
+ return Ue.getFuture(r.tracker);
442
+ }
443
+ let W = class {
444
+ constructor(e, t, r) {
445
+ o(this, "id");
446
+ o(this, "logger");
447
+ o(this, "holder");
448
+ o(this, "context");
449
+ o(this, "future");
450
+ this.id = e, this.logger = r.logger, this.context = r.kosContext, this.holder = t.companionParent;
451
+ }
452
+ get agitated() {
453
+ return this.holder.data.agitated;
454
+ }
455
+ async agitate() {
456
+ if (!this.holder.data.agitated)
457
+ return;
458
+ this.future = void 0;
459
+ const e = $t(this.id);
460
+ if (!e)
461
+ return;
462
+ if (!e.defaultCartridgeAgitator) {
463
+ this.logger.error("Agitator not found");
464
+ return;
465
+ }
466
+ return this.future = await At(
467
+ e.defaultCartridgeAgitator,
468
+ "testAgitate"
469
+ ), this.future;
470
+ }
471
+ get isRemote() {
472
+ const e = `${E.type}-${this.holder.path}`, t = v(e);
473
+ return t != null && t.model ? !!t.model.remoteTrayEnabled.value : !1;
474
+ }
475
+ // -------------------LIFECYCLE----------------------------
476
+ async init() {
477
+ this.logger.debug(`initializing freestyle-holder ${this.id}`);
478
+ }
479
+ async load() {
480
+ this.logger.debug(`loading freestyle-holder ${this.id}`);
481
+ }
482
+ };
483
+ W = Et([
484
+ f(Ee)
485
+ ], W);
486
+ const se = new P({
487
+ class: W,
488
+ type: Ee
489
+ }), { URL: Ct } = L("FREESTYLE-NOZZLE_SERVICE"), { getOne: Mt } = G.build({
490
+ basePath: `${Ct}/api/freestyle-nozzle`
491
+ }), C = A.createLogger({
492
+ name: "freestyle-nozzle-service",
493
+ group: "Services"
494
+ });
495
+ class wt extends Error {
496
+ constructor(t) {
497
+ super(t), this.name = "NutritionInfoError";
498
+ }
499
+ }
500
+ class ie extends Error {
501
+ constructor(t) {
502
+ super(t), this.name = "InvalidRequestError";
503
+ }
504
+ }
505
+ const St = async (e, t, r, s = "http://localhost:8081") => {
506
+ if (C.debug("sending GET for freestyle-nozzle"), !t)
507
+ throw C.error("Invalid freestyle-nozzle request: beverageId is required"), new ie("No beverageId provided");
508
+ if (!r || r.length === 0)
509
+ throw C.error("Invalid freestyle-nozzle request: volumes are required"), new ie("No volumes provided");
510
+ const a = await Mt({
511
+ urlOverride: `${s}${e}/pipeline/beverage/engine/nutrition/${t}?volumes=${r.join(
512
+ ","
513
+ )}`
514
+ });
515
+ if (!(a != null && a.data))
516
+ throw C.error("Failed to retrieve freestyle-nozzle data"), new Error("Failed to retrieve freestyle-nozzle data");
517
+ if (a.data.error)
518
+ throw new wt(a.data.error);
519
+ return a.data;
520
+ };
521
+ var Rt = Object.defineProperty, Dt = Object.getOwnPropertyDescriptor, zt = (e, t, r, s) => {
522
+ for (var a = s > 1 ? void 0 : s ? Dt(t, r) : t, i = e.length - 1, n; i >= 0; i--)
523
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
524
+ return s && a && Rt(t, r, a), a;
525
+ };
526
+ const $e = "freestyle-nozzle-model";
527
+ let Z = class {
528
+ constructor(e, t, r) {
529
+ o(this, "id");
530
+ o(this, "logger");
531
+ o(this, "nozzleModel");
532
+ o(this, "_cupSizes");
533
+ o(this, "_nutritionInfo");
534
+ o(this, "_disposer", null);
535
+ this.id = e, this.logger = r.logger, this.nozzleModel = t.companionParent, this._cupSizes = [100];
536
+ }
537
+ set cupSizes(e) {
538
+ this._cupSizes = e;
539
+ }
540
+ get nutritionInfo() {
541
+ return this._nutritionInfo;
542
+ }
543
+ // -------------------LIFECYCLE----------------------------
544
+ async init() {
545
+ this.logger.debug(`initializing freestyle-nozzle ${this.id}`), this._disposer = Be(async () => {
546
+ if (this.nozzleModel.selectedPourable.beverage && this._cupSizes.length) {
547
+ this.logger.debug(
548
+ `selected beverage: ${this.nozzleModel.selectedPourable.beverage.rawId}. Volume: ${this._cupSizes.join(", ")}`
549
+ );
550
+ const e = this.nozzleModel.selectedPourable.beverage.rawId, t = this.nozzleModel.urlPrefix;
551
+ try {
552
+ const r = await St(
553
+ t,
554
+ e,
555
+ this._cupSizes
556
+ );
557
+ M(() => {
558
+ this._nutritionInfo = r;
559
+ });
560
+ } catch (r) {
561
+ this.logger.error(`Error fetching nutrition info: ${r}`);
562
+ }
563
+ }
564
+ });
565
+ }
566
+ unload() {
567
+ this.logger.debug(`unloading freestyle-nozzle ${this.id}`), this._disposer && this._disposer();
568
+ }
569
+ async load() {
570
+ this.logger.debug(`loading freestyle-nozzle ${this.id}`);
571
+ }
572
+ };
573
+ Z = zt([
574
+ ue(),
575
+ f($e)
576
+ ], Z);
577
+ const ne = new P({
578
+ class: Z,
579
+ type: $e
580
+ }), { URL: Ae } = L("PUMP_SERVICE"), { postModel: Nt } = G.build({
581
+ basePath: `${Ae}/api/ext/freestyle/microCalibration`
582
+ }), Y = A.createLogger({
583
+ name: "freestyle-pump-service",
584
+ group: "Services"
585
+ }), Ft = async (e, t) => {
586
+ var r, s, a, i, n;
587
+ Y.debug(
588
+ `replacePump - sending POST request to /api/ext/freestyle/microCalibration/cal/${e}/code/${t}`
589
+ );
590
+ try {
591
+ const l = await Nt({
592
+ model: {},
593
+ urlOverride: `${Ae}/api/ext/freestyle/microCalibration/cal/${e}/code/${t}`
594
+ });
595
+ return Y.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];
596
+ } catch (l) {
597
+ if (Y.error(
598
+ `replacePump - sending POST request to /api/cal/${e}/code/${t}`,
599
+ l
600
+ ), l instanceof He) {
601
+ const T = ((a = (s = l.payload) == null ? void 0 : s.data) == null ? void 0 : a.error) || ((i = l.payload) == null ? void 0 : i.error) || "unknownError";
602
+ return [T, ((n = l.payload) == null ? void 0 : n.data) || { error: T }];
603
+ }
604
+ }
605
+ return ["unknownError", { error: "unknownError" }];
606
+ };
607
+ var Lt = Object.defineProperty, Gt = Object.getOwnPropertyDescriptor, jt = (e, t, r, s) => {
608
+ for (var a = s > 1 ? void 0 : s ? Gt(t, r) : t, i = e.length - 1, n; i >= 0; i--)
609
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
610
+ return s && a && Lt(t, r, a), a;
611
+ };
612
+ const Ce = "freestyle-pump-model";
613
+ let Q = class {
614
+ constructor(e, t, r) {
615
+ o(this, "id");
616
+ o(this, "logger");
617
+ o(this, "pump");
618
+ this.id = e, this.logger = r.logger, this.pump = t.companionParent;
619
+ }
620
+ // -------------------LIFECYCLE----------------------------
621
+ async replacePump(e) {
622
+ const [t, r] = await Ft(this.pump.path, e);
623
+ return t && this.logger.error(`Failed to replace the pump, ${this.pump.id}`, t), [t, r];
624
+ }
625
+ };
626
+ Q = jt([
627
+ f(Ce)
628
+ ], Q);
629
+ const le = new P({
630
+ class: Q,
631
+ type: Ce
632
+ }), { URL: I } = L("ICE_AGITATOR_SERVICE"), { getAll: Me, postModel: B } = G.build({
633
+ basePath: `${I}/api/ext/freestyle/ice`
634
+ }), we = A.createLogger({
635
+ name: "ice-agitator-service",
636
+ group: "Services"
637
+ }), Ut = async (e) => (we.debug("sending GET for ice types"), await Me({
638
+ urlOverride: `${I}/api/handle/${e}/types`
639
+ })), Bt = async (e, t) => (we.debug("sending POST for ice types"), await B({
640
+ urlOverride: `${I}/api/handle/${e}/type/${t}`,
641
+ model: {}
642
+ })), Ht = async (e) => await Me({
643
+ urlOverride: `${I}/api/kos/config/details/${e}/4`
644
+ }), xt = async (e, t) => {
645
+ const r = await B({
646
+ model: {},
647
+ tracker: t,
648
+ urlOverride: `${I}/api/handle/${e}/pour`
649
+ });
650
+ if (!(r != null && r.data))
651
+ throw new Error("No response from server");
652
+ return r == null ? void 0 : r.data;
653
+ }, Kt = async (e, t) => {
654
+ const r = await B({
655
+ model: {},
656
+ tracker: t,
657
+ urlOverride: `${I}/api/handle/${e}/test/agitation`
658
+ });
659
+ if (!(r != null && r.data))
660
+ throw new Error("No response from server");
661
+ return r == null ? void 0 : r.data;
662
+ }, Yt = async (e, t) => {
663
+ const r = await B({
664
+ model: {},
665
+ tracker: t,
666
+ urlOverride: `${I}/api/handle/${e}/test/gate`
667
+ });
668
+ if (!(r != null && r.data))
669
+ throw new Error("No response from server");
670
+ return r == null ? void 0 : r.data;
671
+ };
672
+ var qt = Object.defineProperty, Vt = Object.getOwnPropertyDescriptor, g = (e, t, r, s) => {
673
+ for (var a = s > 1 ? void 0 : s ? Vt(t, r) : t, i = e.length - 1, n; i >= 0; i--)
674
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
675
+ return s && a && qt(t, r, a), a;
676
+ };
677
+ class F {
678
+ }
679
+ o(F, "TOPIC_AGITATION_STARTED", "/kos/events/ddk/ice-agitation-started"), o(F, "TOPIC_AGITATION_ENDED", "/kos/events/ddk/ice-agitation-ended");
680
+ const Se = "ice-agitator-model", Re = j("statePath");
681
+ let d = class {
682
+ constructor(e, t, r) {
683
+ o(this, "id");
684
+ o(this, "name");
685
+ o(this, "path");
686
+ o(this, "futureHandler");
687
+ o(this, "volWithoutIceMl");
688
+ o(this, "durationSec");
689
+ o(this, "enableIceChuteClear");
690
+ o(this, "iceChuteClearDurationMs");
691
+ o(this, "iceChuteClearIntervalSec");
692
+ o(this, "iceChuteClearRetryIntervalSec");
693
+ o(this, "maxDispenseSec");
694
+ o(this, "type");
695
+ o(this, "dilutionOffset");
696
+ o(this, "inactivitySec");
697
+ o(this, "agitating");
698
+ o(this, "iceChuteOpen");
699
+ o(this, "statePath");
700
+ o(this, "_allIceTypes");
701
+ o(this, "logger");
702
+ o(this, "currentState", u.IDLE);
703
+ o(this, "resetDefaultValues", async () => await Ht(this.path));
704
+ this.id = e, this.name = t.name, this.path = t.path, this.statePath = t.statePath, this._allIceTypes = [], this.logger = r.logger, this.futureHandler = new Ke(this);
705
+ }
706
+ get iceTypes() {
707
+ return this._allIceTypes;
708
+ }
709
+ get isAgitating() {
710
+ return !!this.agitating.value;
711
+ }
712
+ get isIceChuteOpen() {
713
+ return !!this.iceChuteOpen.value;
714
+ }
715
+ get future() {
716
+ return this.futureHandler.future;
717
+ }
718
+ get pourFuture() {
719
+ return this.futureHandler.futureMap.get("pour");
720
+ }
721
+ get agitateFuture() {
722
+ return this.futureHandler.futureMap.get("agitate");
723
+ }
724
+ get gateFuture() {
725
+ return this.futureHandler.futureMap.get("gate");
726
+ }
727
+ /**
728
+ * A derived value that indicates if the nozzle is currently pouring a beverage.
729
+ * @readonly
730
+ */
731
+ get isPouring() {
732
+ var e;
733
+ return !!(this.pourFuture && !((e = this.pourFuture) != null && e.endState)) || this.currentState === u.POUR_STARTING || this.currentState === u.POURING || this.currentState === u.POUR_CANCELING;
734
+ }
735
+ /**
736
+ * A derived value that indicates if it is possible to dispense ice.
737
+ *
738
+ * The value is observable and will change as the current dispense state changes
739
+ * @readonly
740
+ * */
741
+ get canPour() {
742
+ return this.currentState === u.IDLE;
743
+ }
744
+ updateIfCurrent(e, t) {
745
+ this.currentState === e && M(() => {
746
+ this.currentState = t;
747
+ });
748
+ }
749
+ async pourIce(e) {
750
+ try {
751
+ if (this.currentState === u.IDLE) {
752
+ if (this.updateIfCurrent(u.IDLE, u.POUR_STARTING), !e)
753
+ throw new Error("No tracker provided");
754
+ const t = await xt(this.path, e);
755
+ return this.updateIfCurrent(u.POUR_STARTING, u.POURING), t != null && t.endState && this.updateIfCurrent(u.POURING, u.IDLE), t;
756
+ } else
757
+ throw new Error(`Cannot pour in state ${this.currentState}`);
758
+ } catch (t) {
759
+ throw this.logger.error(t), this.currentState = u.IDLE, t;
760
+ }
761
+ }
762
+ /**
763
+ * An action that will cancel the ice dispense if it is currently in progress.
764
+ * */
765
+ async cancelIceDispense() {
766
+ var e;
767
+ this.currentState === u.POURING || this.currentState === u.POUR_STARTING ? (this.currentState = u.POUR_CANCELING, await ((e = this.pourFuture) == null ? void 0 : e.cancelFuture()), M(() => {
768
+ this.currentState = u.IDLE;
769
+ })) : this.logger.warn(
770
+ `Cannot cancel ice dispense in state ${this.currentState}`
771
+ );
772
+ }
773
+ async testAgitate(e) {
774
+ if (!e)
775
+ throw new Error("No tracker provided");
776
+ return this.logger.info(`agitating ice-agitator ${this.id}`), Kt(this.path, e);
777
+ }
778
+ async testGate(e) {
779
+ if (!e)
780
+ throw new Error("No tracker provided");
781
+ return this.logger.info(`testing ice gate: ${this.id}`), Yt(this.path, e);
782
+ }
783
+ handleAgitationChange() {
784
+ var e;
785
+ this.isAgitating ? (this.logger.info(`agitating ice-agitator ${this.id}`), w.publish(F.TOPIC_AGITATION_STARTED, {
786
+ path: this.path,
787
+ futureId: (e = this.futureHandler.future) == null ? void 0 : e.futureId
788
+ })) : w.publish(F.TOPIC_AGITATION_ENDED, {
789
+ path: this.path
790
+ });
791
+ }
792
+ async updateIceType(e) {
793
+ await Bt(this.path, e);
794
+ }
795
+ async init() {
796
+ this.logger.debug(`initializing ice-agitator ${this.id}`);
797
+ }
798
+ async load() {
799
+ this.logger.debug(`loading ice-agitator ${this.id}`);
800
+ const e = await Ut(this.path);
801
+ (e == null ? void 0 : e.status) === 200 && M(() => {
802
+ this._allIceTypes = e.data || [];
803
+ });
804
+ }
805
+ };
806
+ g([
807
+ p({
808
+ path: m,
809
+ attribute: "settings.volWithoutIceMl"
810
+ })
811
+ ], d.prototype, "volWithoutIceMl", 2);
812
+ g([
813
+ p({
814
+ path: m,
815
+ attribute: "settings.durationSec",
816
+ converter: {
817
+ to: "second"
818
+ }
819
+ })
820
+ ], d.prototype, "durationSec", 2);
821
+ g([
822
+ p({
823
+ path: m,
824
+ attribute: "enableIceChuteClear"
825
+ })
826
+ ], d.prototype, "enableIceChuteClear", 2);
827
+ g([
828
+ p({
829
+ path: m,
830
+ attribute: "iceChuteClearDurationMs"
831
+ })
832
+ ], d.prototype, "iceChuteClearDurationMs", 2);
833
+ g([
834
+ p({
835
+ path: m,
836
+ attribute: "iceChuteClearIntervalSec"
837
+ })
838
+ ], d.prototype, "iceChuteClearIntervalSec", 2);
839
+ g([
840
+ p({
841
+ path: m,
842
+ attribute: "iceChuteClearRetryIntervalSec"
843
+ })
844
+ ], d.prototype, "iceChuteClearRetryIntervalSec", 2);
845
+ g([
846
+ p({
847
+ path: m,
848
+ attribute: "maxDispenseSec"
849
+ })
850
+ ], d.prototype, "maxDispenseSec", 2);
851
+ g([
852
+ p({
853
+ path: m,
854
+ attribute: "type"
855
+ })
856
+ ], d.prototype, "type", 2);
857
+ g([
858
+ p({
859
+ path: m,
860
+ attribute: "settings.dilutionOffset"
861
+ })
862
+ ], d.prototype, "dilutionOffset", 2);
863
+ g([
864
+ p({
865
+ path: m,
866
+ attribute: "settings.inactivitySec",
867
+ converter: {
868
+ to: "minute"
869
+ }
870
+ })
871
+ ], d.prototype, "inactivitySec", 2);
872
+ g([
873
+ J({ path: Re, attribute: "agitating" })
874
+ ], d.prototype, "agitating", 2);
875
+ g([
876
+ J({ path: Re, attribute: "iceChuteOpen" })
877
+ ], d.prototype, "iceChuteOpen", 2);
878
+ g([
879
+ U({ alias: "pour" })
880
+ ], d.prototype, "pourIce", 1);
881
+ g([
882
+ U({ alias: "agitate" })
883
+ ], d.prototype, "testAgitate", 1);
884
+ g([
885
+ U({
886
+ alias: "gate"
887
+ })
888
+ ], d.prototype, "testGate", 1);
889
+ g([
890
+ xe({
891
+ dependencies: (e) => [e.isAgitating]
892
+ })
893
+ ], d.prototype, "handleAgitationChange", 1);
894
+ d = g([
895
+ f(Se)
896
+ ], d);
897
+ const De = new P({
898
+ class: d,
899
+ type: Se
900
+ });
901
+ var Wt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, ae = (e, t, r, s) => {
902
+ for (var a = s > 1 ? void 0 : s ? Zt(t, r) : t, i = e.length - 1, n; i >= 0; i--)
903
+ (n = e[i]) && (a = (s ? n(t, r, a) : n(a)) || a);
904
+ return s && a && Wt(t, r, a), a;
905
+ };
906
+ const oe = "agitation-required-trouble-model", Qt = (e) => {
907
+ if (e.data.agitationRequired)
908
+ return oe;
909
+ }, Xt = "InsufficientAgitationTrouble";
910
+ let $ = class {
911
+ constructor(e, t, r) {
912
+ o(this, "id");
913
+ o(this, "logger");
914
+ o(this, "trouble");
915
+ o(this, "_deferred");
916
+ o(this, "_holdersLoaded", !1);
917
+ o(this, "agitateBeforePour");
918
+ this.id = e, this.logger = r.logger, this._deferred = !1, this.trouble = t.companionParent;
919
+ }
920
+ async resolve() {
921
+ return this.trouble.resolve();
922
+ }
923
+ get holder() {
924
+ const e = this.trouble.data.holderPaths[0], t = v(e);
925
+ if (!(!this._holdersLoaded && !t.model))
926
+ return t == null ? void 0 : t.model;
927
+ }
928
+ updateHolder() {
929
+ if (!this._holdersLoaded) {
930
+ const e = this.trouble.data.holderPaths[0];
931
+ v(e).model && (this._holdersLoaded = !0);
932
+ }
933
+ }
934
+ get shouldDefer() {
935
+ var s, a;
936
+ if (!this.holder)
937
+ return !0;
938
+ const t = (((s = this.holder) == null ? void 0 : s.troublesByType[Xt]) || []).length > 0;
939
+ return !!((a = this.agitateBeforePour) != null && a.value) && t;
940
+ }
941
+ get deferred() {
942
+ return this._deferred;
943
+ }
944
+ defer() {
945
+ this._deferred = !0;
946
+ }
947
+ clearDefer() {
948
+ this._deferred = !1;
949
+ }
950
+ };
951
+ ae([
952
+ p({
953
+ path: "app:kosdev.ddk:app",
954
+ attribute: "ncui.agitateBeforePour"
955
+ })
956
+ ], $.prototype, "agitateBeforePour", 2);
957
+ ae([
958
+ Ye({
959
+ topic: qe(ge.type),
960
+ lifecycle: Ve.INIT
961
+ })
962
+ ], $.prototype, "updateHolder", 1);
963
+ $ = ae([
964
+ f(oe)
965
+ ], $);
966
+ const Jt = new P({
967
+ class: $,
968
+ type: oe
969
+ }), kt = ["iceAgitator", "carbAgitator"], er = {
970
+ iceAgitator: De.factory,
971
+ carbAgitator: he.factory
972
+ }, tr = A.createLogger({ name: "freestyle-assembly-data-mapper" }), ir = async (e) => {
973
+ const t = te.instance().options({}).build(), r = re.instance().options({}).build(), s = e.assemblies.reduce((n, l) => {
974
+ var T;
975
+ return kt.forEach((c) => {
976
+ var b;
977
+ const _ = l[c];
978
+ if (_) {
979
+ const ze = er[c](_.path);
980
+ n[c] = ze({
981
+ name: _.name,
982
+ path: _.path,
983
+ statePath: ((b = _.state) == null ? void 0 : b.path) || ""
984
+ });
985
+ }
986
+ }), (T = l.cartridgeAgitators) == null || T.forEach((c) => {
987
+ var b;
988
+ const _ = _e.instance(
989
+ c.path
990
+ ).options({
991
+ name: c.name,
992
+ path: c.path,
993
+ statePath: ((b = c.state) == null ? void 0 : b.path) || ""
994
+ }).build();
995
+ t.addModel(_);
996
+ }), l.remoteTrays && l.remoteTrays.forEach((c) => {
997
+ tr.info(`Found remote tray ${c.name} with path ${c.path}`);
998
+ const _ = `${E.type}-${c.holderPath}`, b = E.instance(_).options({
999
+ holderPath: c.holderPath,
1000
+ configPath: c.path,
1001
+ name: c.name
1002
+ }).build();
1003
+ r.addModel(b);
1004
+ }), n;
1005
+ }, {}), a = !!s.iceAgitator, i = !!s.carbAgitator;
1006
+ return {
1007
+ ...s,
1008
+ cartridgeAgitators: t,
1009
+ remoteTrays: r,
1010
+ supportsCarb: i,
1011
+ supportsIce: a
1012
+ };
1013
+ }, rr = (e) => () => (We(e)(), Xe(e)(), ne.register(), V.register(), De.register(), he.register(), te.register(), le.register(), se.register(), E.register(), re.register(), h.companion.register(e)(
1014
+ Je.type,
1015
+ ne.type
1016
+ ), h.companion.register(e)(
1017
+ ge.type,
1018
+ V.type
1019
+ ), Jt.register(), h.companion.register(e)(
1020
+ Ze.type,
1021
+ Qt
1022
+ ), h.companion.register(e)(ke.type, le.type), h.companion.register(e)(
1023
+ et.type,
1024
+ se.type
1025
+ ), x[K].register(
1026
+ "EnjoyByTrouble",
1027
+ async (t) => {
1028
+ if (t.data.enjoyByDate) {
1029
+ const r = new Date(t.data.enjoyByDate);
1030
+ return {
1031
+ enjoyByDays: Math.floor(
1032
+ ((/* @__PURE__ */ new Date()).getTime() - r.getTime()) / (1e3 * 60 * 60 * 24)
1033
+ ) || ""
1034
+ };
1035
+ }
1036
+ return {};
1037
+ }
1038
+ ), x[K].register(
1039
+ "SuperPumpRequiredTrouble",
1040
+ // This is the trouble type
1041
+ async (t) => {
1042
+ const { model: r } = v(
1043
+ tt.type
1044
+ );
1045
+ return r ? {
1046
+ superPumps: r.models.getIndexByKey(
1047
+ rt.byType,
1048
+ "microSuper"
1049
+ ).map((i) => i.name).join(", ")
1050
+ } : {};
1051
+ }
1052
+ ), x[K].register(
1053
+ "MicroPumpAirDetectTrouble",
1054
+ async (t) => {
1055
+ if (t.ifaces.includes("container"))
1056
+ return {};
1057
+ if (t.data.pumpPath) {
1058
+ const { model: r } = v(
1059
+ t.data.pumpPath
1060
+ );
1061
+ if (r) {
1062
+ const s = r.ingredientId ? v(r.ingredientId).model : void 0;
1063
+ return {
1064
+ ingredientId: r.ingredientId,
1065
+ ingredientName: (s == null ? void 0 : s.name) || ""
1066
+ };
1067
+ }
1068
+ }
1069
+ return {};
1070
+ }
1071
+ ), {
1072
+ preload: h.model.preloadModel(e),
1073
+ model: h.model.register(e),
1074
+ companion: h.companion.register(e),
1075
+ legacy: h.model.registerLegacyModel(e)
1076
+ }), y = {
1077
+ ...Qe
1078
+ };
1079
+ y.freestyle = {
1080
+ models: rr(y)
1081
+ };
1082
+ y.preload = h.model.preloadModel(y);
1083
+ y.model = h.model.register(y);
1084
+ y.companion = h.companion.register(y);
1085
+ y.legacy = h.model.registerLegacyModel(y);
1086
+ const nr = y;
1087
+ export {
1088
+ Xt as A,
1089
+ he as C,
1090
+ V as F,
1091
+ F as I,
1092
+ nr as K,
1093
+ wt as N,
1094
+ re as R,
1095
+ te as a,
1096
+ R as b,
1097
+ _e as c,
1098
+ se as d,
1099
+ ne as e,
1100
+ le as f,
1101
+ De as g,
1102
+ Jt as h,
1103
+ E as i,
1104
+ ie as j,
1105
+ St as k,
1106
+ Ft as l,
1107
+ ir as m,
1108
+ yt as n,
1109
+ rr as r
1110
+ };
1111
+ //# sourceMappingURL=freestyle-registration-manager-CI8el36E.js.map