@kosdev-code/kos-ddk-models 2.1.2 → 3.0.0

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 (217) hide show
  1. package/constants.d.ts.map +1 -1
  2. package/index.d.ts.map +1 -1
  3. package/index.js +3102 -1
  4. package/index.js.map +1 -0
  5. package/index.mjs +2190 -1597
  6. package/index.mjs.map +1 -0
  7. package/lib/agitation-control/agitation-control-model.d.ts +4 -5
  8. package/lib/agitation-control/agitation-control-model.d.ts.map +1 -1
  9. package/lib/agitation-control/agitation-control-registration.d.ts +2 -3
  10. package/lib/agitation-control/agitation-control-registration.d.ts.map +1 -1
  11. package/lib/agitation-control/index.d.ts.map +1 -1
  12. package/lib/agitation-control/types/index.d.ts +1 -3
  13. package/lib/animation/animation-model.d.ts +1 -2
  14. package/lib/animation/animation-model.d.ts.map +1 -1
  15. package/lib/animation/animation-registration.d.ts +1 -2
  16. package/lib/animation/animation-registration.d.ts.map +1 -1
  17. package/lib/animation/index.d.ts.map +1 -1
  18. package/lib/animation/services/animation-services.d.ts +1 -1
  19. package/lib/animation/services/animation-services.d.ts.map +1 -1
  20. package/lib/animation/services/index.d.ts.map +1 -1
  21. package/lib/animation/types/index.d.ts +1 -3
  22. package/lib/application/application-model.d.ts +5 -6
  23. package/lib/application/application-model.d.ts.map +1 -1
  24. package/lib/application/application-registration.d.ts +1 -2
  25. package/lib/application/application-registration.d.ts.map +1 -1
  26. package/lib/application/index.d.ts.map +1 -1
  27. package/lib/application/services/application-services.d.ts +3 -3
  28. package/lib/application/services/application-services.d.ts.map +1 -1
  29. package/lib/application/services/index.d.ts.map +1 -1
  30. package/lib/application/types/index.d.ts +2 -4
  31. package/lib/auth/auth-model.d.ts +2 -3
  32. package/lib/auth/auth-model.d.ts.map +1 -1
  33. package/lib/auth/auth-registration.d.ts +1 -2
  34. package/lib/auth/auth-registration.d.ts.map +1 -1
  35. package/lib/auth/index.d.ts.map +1 -1
  36. package/lib/auth/services/auth-services.d.ts +1 -2
  37. package/lib/auth/services/auth-services.d.ts.map +1 -1
  38. package/lib/auth/services/index.d.ts.map +1 -1
  39. package/lib/auth/types/index.d.ts +1 -3
  40. package/lib/carb-water/carb-water-model.d.ts +3 -4
  41. package/lib/carb-water/carb-water-model.d.ts.map +1 -1
  42. package/lib/carb-water/carb-water-registration.d.ts +2 -3
  43. package/lib/carb-water/carb-water-registration.d.ts.map +1 -1
  44. package/lib/carb-water/index.d.ts.map +1 -1
  45. package/lib/carb-water/services/carb-water-services.d.ts.map +1 -1
  46. package/lib/carb-water/services/index.d.ts.map +1 -1
  47. package/lib/copy-logs/copy-logs-model.d.ts +4 -5
  48. package/lib/copy-logs/copy-logs-model.d.ts.map +1 -1
  49. package/lib/copy-logs/index.d.ts +1 -1
  50. package/lib/copy-logs/index.d.ts.map +1 -1
  51. package/lib/copy-logs/services/copy-logs-services.d.ts +1 -2
  52. package/lib/copy-logs/services/copy-logs-services.d.ts.map +1 -1
  53. package/lib/copy-logs/services/index.d.ts.map +1 -1
  54. package/lib/dashboard-operations/dashboard-operations-model.d.ts +4 -5
  55. package/lib/dashboard-operations/dashboard-operations-model.d.ts.map +1 -1
  56. package/lib/dashboard-operations/dashboard-operations-registration.d.ts +1 -2
  57. package/lib/dashboard-operations/dashboard-operations-registration.d.ts.map +1 -1
  58. package/lib/dashboard-operations/index.d.ts.map +1 -1
  59. package/lib/dashboard-operations/services/dashboard-operations-services.d.ts +2 -2
  60. package/lib/dashboard-operations/services/dashboard-operations-services.d.ts.map +1 -1
  61. package/lib/dashboard-operations/services/index.d.ts.map +1 -1
  62. package/lib/dashboard-operations/types/index.d.ts +1 -3
  63. package/lib/dispenser/dispenser-model.d.ts +1 -2
  64. package/lib/dispenser/dispenser-model.d.ts.map +1 -1
  65. package/lib/dispenser/dispenser-registration.d.ts +1 -2
  66. package/lib/dispenser/dispenser-registration.d.ts.map +1 -1
  67. package/lib/dispenser/index.d.ts.map +1 -1
  68. package/lib/dispenser/services/dispenser-services.d.ts +1 -1
  69. package/lib/dispenser/services/dispenser-services.d.ts.map +1 -1
  70. package/lib/dispenser/services/index.d.ts.map +1 -1
  71. package/lib/dispenser/types/index.d.ts +1 -3
  72. package/lib/dispenser-info/dispenser-info-model.d.ts +1 -2
  73. package/lib/dispenser-info/dispenser-info-model.d.ts.map +1 -1
  74. package/lib/dispenser-info/dispenser-info-registration.d.ts +1 -2
  75. package/lib/dispenser-info/dispenser-info-registration.d.ts.map +1 -1
  76. package/lib/dispenser-info/index.d.ts.map +1 -1
  77. package/lib/dispenser-info/services/dispenser-info-services.d.ts +1 -1
  78. package/lib/dispenser-info/services/dispenser-info-services.d.ts.map +1 -1
  79. package/lib/dispenser-info/services/index.d.ts.map +1 -1
  80. package/lib/dispenser-info/types/index.d.ts +1 -3
  81. package/lib/door/door-model.d.ts +1 -2
  82. package/lib/door/door-model.d.ts.map +1 -1
  83. package/lib/door/door-registration.d.ts +2 -3
  84. package/lib/door/door-registration.d.ts.map +1 -1
  85. package/lib/door/index.d.ts.map +1 -1
  86. package/lib/enrollment/enrollment-model.d.ts +1 -2
  87. package/lib/enrollment/enrollment-model.d.ts.map +1 -1
  88. package/lib/enrollment/enrollment-registration.d.ts +1 -2
  89. package/lib/enrollment/enrollment-registration.d.ts.map +1 -1
  90. package/lib/enrollment/index.d.ts.map +1 -1
  91. package/lib/enrollment/services/enrollment-services.d.ts +1 -1
  92. package/lib/enrollment/services/enrollment-services.d.ts.map +1 -1
  93. package/lib/enrollment/services/index.d.ts.map +1 -1
  94. package/lib/enrollment/types/index.d.ts +1 -3
  95. package/lib/extension/index.d.ts.map +1 -1
  96. package/lib/ingredient-summary/index.d.ts.map +1 -1
  97. package/lib/ingredient-summary/ingredient-summary-model.d.ts +4 -5
  98. package/lib/ingredient-summary/ingredient-summary-model.d.ts.map +1 -1
  99. package/lib/ingredient-summary/ingredient-summary-registration.d.ts +1 -2
  100. package/lib/ingredient-summary/ingredient-summary-registration.d.ts.map +1 -1
  101. package/lib/ingredient-summary/types/index.d.ts +2 -4
  102. package/lib/lockout/index.d.ts.map +1 -1
  103. package/lib/lockout/lockout-model.d.ts +1 -2
  104. package/lib/lockout/lockout-model.d.ts.map +1 -1
  105. package/lib/lockout/lockout-registration.d.ts +2 -3
  106. package/lib/lockout/lockout-registration.d.ts.map +1 -1
  107. package/lib/lockout/services/index.d.ts.map +1 -1
  108. package/lib/lockout/services/lockout-services.d.ts +1 -1
  109. package/lib/lockout/services/lockout-services.d.ts.map +1 -1
  110. package/lib/macro-assignment/index.d.ts.map +1 -1
  111. package/lib/macro-assignment/macro-assignment-model.d.ts +5 -6
  112. package/lib/macro-assignment/macro-assignment-model.d.ts.map +1 -1
  113. package/lib/macro-assignment/macro-assignment-registration.d.ts +1 -2
  114. package/lib/macro-assignment/macro-assignment-registration.d.ts.map +1 -1
  115. package/lib/macro-assignment/services/index.d.ts.map +1 -1
  116. package/lib/macro-assignment/services/macro-assignment-services.d.ts +1 -1
  117. package/lib/macro-assignment/services/macro-assignment-services.d.ts.map +1 -1
  118. package/lib/macro-assignment/types/index.d.ts +2 -4
  119. package/lib/network-test/index.d.ts.map +1 -1
  120. package/lib/network-test/network-test-container-model.d.ts +3 -4
  121. package/lib/network-test/network-test-container-model.d.ts.map +1 -1
  122. package/lib/network-test/network-test-container-registration.d.ts +1 -2
  123. package/lib/network-test/network-test-container-registration.d.ts.map +1 -1
  124. package/lib/network-test/network-test-model.d.ts +2 -3
  125. package/lib/network-test/network-test-model.d.ts.map +1 -1
  126. package/lib/network-test/network-test-registration.d.ts +1 -2
  127. package/lib/network-test/network-test-registration.d.ts.map +1 -1
  128. package/lib/network-test/services/index.d.ts.map +1 -1
  129. package/lib/network-test/services/network-test-services.d.ts +2 -3
  130. package/lib/network-test/services/network-test-services.d.ts.map +1 -1
  131. package/lib/network-test/types/index.d.ts +1 -3
  132. package/lib/nutritive-sweetener/index.d.ts.map +1 -1
  133. package/lib/nutritive-sweetener/nutritive-sweetener-model.d.ts +7 -8
  134. package/lib/nutritive-sweetener/nutritive-sweetener-model.d.ts.map +1 -1
  135. package/lib/nutritive-sweetener/nutritive-sweetener-registration.d.ts +2 -3
  136. package/lib/nutritive-sweetener/nutritive-sweetener-registration.d.ts.map +1 -1
  137. package/lib/nutritive-sweetener/services/index.d.ts.map +1 -1
  138. package/lib/nutritive-sweetener/services/nutritive-sweetener-services.d.ts.map +1 -1
  139. package/lib/plain-water/index.d.ts.map +1 -1
  140. package/lib/plain-water/plain-water-model.d.ts +4 -5
  141. package/lib/plain-water/plain-water-model.d.ts.map +1 -1
  142. package/lib/plain-water/plain-water-registration.d.ts +2 -3
  143. package/lib/plain-water/plain-water-registration.d.ts.map +1 -1
  144. package/lib/plain-water/services/index.d.ts.map +1 -1
  145. package/lib/plain-water/services/plain-water-services.d.ts.map +1 -1
  146. package/lib/reboot/index.d.ts.map +1 -1
  147. package/lib/reboot/reboot-model.d.ts +1 -2
  148. package/lib/reboot/reboot-model.d.ts.map +1 -1
  149. package/lib/reboot/reboot-registration.d.ts +1 -2
  150. package/lib/reboot/reboot-registration.d.ts.map +1 -1
  151. package/lib/reboot/services/index.d.ts.map +1 -1
  152. package/lib/reboot/services/reboot-services.d.ts +1 -1
  153. package/lib/reboot/services/reboot-services.d.ts.map +1 -1
  154. package/lib/reboot/types/index.d.ts +1 -3
  155. package/lib/registration.d.ts +1 -2
  156. package/lib/registration.d.ts.map +1 -1
  157. package/lib/settings/index.d.ts.map +1 -1
  158. package/lib/settings/services/index.d.ts.map +1 -1
  159. package/lib/settings/services/settings-services.d.ts +2 -3
  160. package/lib/settings/services/settings-services.d.ts.map +1 -1
  161. package/lib/settings/settings-model.d.ts +1 -2
  162. package/lib/settings/settings-model.d.ts.map +1 -1
  163. package/lib/settings/settings-registration.d.ts +1 -2
  164. package/lib/settings/settings-registration.d.ts.map +1 -1
  165. package/lib/settings/types/index.d.ts +1 -3
  166. package/lib/setup-step/index.d.ts.map +1 -1
  167. package/lib/setup-step/services/index.d.ts.map +1 -1
  168. package/lib/setup-step/services/setup-step-services.d.ts +2 -2
  169. package/lib/setup-step/services/setup-step-services.d.ts.map +1 -1
  170. package/lib/setup-step/setup-step-container-model.d.ts +3 -4
  171. package/lib/setup-step/setup-step-container-model.d.ts.map +1 -1
  172. package/lib/setup-step/setup-step-container-registration.d.ts +1 -2
  173. package/lib/setup-step/setup-step-container-registration.d.ts.map +1 -1
  174. package/lib/setup-step/setup-step-model.d.ts +1 -2
  175. package/lib/setup-step/setup-step-model.d.ts.map +1 -1
  176. package/lib/setup-step/setup-step-registration.d.ts +1 -2
  177. package/lib/setup-step/setup-step-registration.d.ts.map +1 -1
  178. package/lib/setup-step/types/index.d.ts +1 -3
  179. package/lib/trouble-action/index.d.ts.map +1 -1
  180. package/lib/trouble-action/trouble-action-model.d.ts +2 -3
  181. package/lib/trouble-action/trouble-action-model.d.ts.map +1 -1
  182. package/lib/utilities/index.d.ts.map +1 -1
  183. package/lib/utilities/services/index.d.ts.map +1 -1
  184. package/lib/utilities/services/utilities-services.d.ts.map +1 -1
  185. package/lib/utilities/types/index.d.ts +1 -3
  186. package/lib/utilities/utilities-container-model.d.ts +1 -2
  187. package/lib/utilities/utilities-container-model.d.ts.map +1 -1
  188. package/lib/utilities/utilities-container-registration.d.ts +1 -2
  189. package/lib/utilities/utilities-container-registration.d.ts.map +1 -1
  190. package/lib/utilities/utilities-model.d.ts +1 -2
  191. package/lib/utilities/utilities-model.d.ts.map +1 -1
  192. package/lib/utilities/utilities-registration.d.ts +1 -2
  193. package/lib/utilities/utilities-registration.d.ts.map +1 -1
  194. package/lib/utils/assembly-utils.d.ts +2 -3
  195. package/lib/utils/assembly-utils.d.ts.map +1 -1
  196. package/lib/utils/holder-view-extension.d.ts +1 -2
  197. package/lib/utils/holder-view-extension.d.ts.map +1 -1
  198. package/lib/utils/index.d.ts.map +1 -1
  199. package/lib/utils/time-utils.d.ts.map +1 -1
  200. package/lib/utils/trouble-visibility-filter.d.ts +1 -2
  201. package/lib/utils/trouble-visibility-filter.d.ts.map +1 -1
  202. package/package.json +5 -5
  203. package/start/index.d.ts.map +1 -1
  204. package/start/services/index.d.ts.map +1 -1
  205. package/start/services/start-services.d.ts +1 -1
  206. package/start/services/start-services.d.ts.map +1 -1
  207. package/start/start-model.d.ts +1 -2
  208. package/start/start-model.d.ts.map +1 -1
  209. package/start/start-registration.d.ts +2 -3
  210. package/start/start-registration.d.ts.map +1 -1
  211. package/types/global.d.ts.map +1 -1
  212. package/types/index.d.ts.map +1 -1
  213. package/utils/openapi-index.d.ts.map +1 -1
  214. package/utils/services/kosdev.ddk/snapshot/service.d.ts +47 -48
  215. package/utils/services/kosdev.ddk/snapshot/service.d.ts.map +1 -1
  216. package/utils/services-index.d.ts.map +1 -1
  217. package/kos-models.json +0 -358
package/index.mjs CHANGED
@@ -1,39 +1,64 @@
1
- var yo = Object.defineProperty;
2
- var fo = (e, t, o) => t in e ? yo(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
- var i = (e, t, o) => (fo(e, typeof t != "symbol" ? t + "" : t, o), o);
4
- import { resolveServiceUrl as h, ServiceFactory as y, KosLog as g, kosTopicHandler as Te, kosModel as l, kosAction as v, Kos as c, isKosModel as u, createPropKey as ht, kosStateProp as vo, kosConfigProperty as d, KosModelRegistrationFactory as mo, kosDependency as p, KosModelContainer as Ve, resolveContainerDeltas as it, kosChild as $e, Device as bo, kosFuture as M, kosModelEffect as Pe, MultipleFutureHandler as _o, FutureEndState as T, TroubleServices as Me, Troubles as nt, SingletonKosModelRegistrationFactory as He, getKosCompanionModel as Be, FetchError as yt, StorageDeviceContainer as To, kosFutureAware as $o, kosLoggerAware as Ke, KosDataContainer as Po, TroubleContainer as Ye, FutureHandler as Ge, troubleByTypeReducer as Mo, registerExtensionPoint as Oo, ExtensionManager as Oe, kosConfigBean as So, kosStateBean as wo, ObservableData as Eo } from "@kosdev-code/kos-ui-sdk";
5
- import { AGITATION_REQUIRED_TROUBLE as ft, CartridgeAgitatorEvents as vt, FcmPump as mt, FreestyleHolder as Co } from "@kosdev-code/kos-freestyle-sdk";
6
- import { Assembly as Se, HolderContainer as Lo, IngredientContainer as Do } from "@kosdev-code/kos-dispense-sdk";
7
- const at = "PurgeTrouble", ko = "PrimeTrouble", { URL: qe } = h("AUTH_SERVICE"), { getOne: Io, postModel: Ro } = y.build({
8
- basePath: `${qe}/api/auth`
9
- }), bt = g.createLogger({ name: "auth-service", group: "Services" }), _t = async () => (bt.debug("sending GET for auth"), await Io({
10
- urlOverride: `${qe}/api/app/kosdev.ddk/auth/role`
11
- })), Tt = async (e) => (bt.debug("sending POST for auth"), await Ro({
12
- urlOverride: `${qe}/api/app/kosdev.ddk/auth/pincode/${e}`,
13
- model: {}
14
- })), Bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1
+ import { resolveServiceUrl, ServiceFactory, KosLog, kosTopicHandler, kosModel, kosAction, Kos, isKosModel, createPropKey, kosStateProp, kosConfigProperty, KosModelRegistrationFactory, kosDependency, KosModelContainer, resolveContainerDeltas, kosChild, Device, kosFuture, kosModelEffect, MultipleFutureHandler, FutureEndState, TroubleServices, Troubles, SingletonKosModelRegistrationFactory, getKosCompanionModel, FetchError, StorageDeviceContainer, kosFutureAware, kosLoggerAware, KosDataContainer, TroubleContainer, FutureHandler, troubleByTypeReducer, registerExtensionPoint, ExtensionManager, kosConfigBean, kosStateBean, ObservableData } from "@kosdev-code/kos-ui-sdk";
2
+ import { AGITATION_REQUIRED_TROUBLE, CartridgeAgitatorEvents, FcmPump, FreestyleHolder } from "@kosdev-code/kos-freestyle-sdk";
3
+ import { Assembly, HolderContainer, IngredientContainer } from "@kosdev-code/kos-dispense-sdk";
4
+ const TROUBLE_TYPE_PURGE$1 = "PurgeTrouble";
5
+ const TROUBLE_TYPE_PRIME$1 = "PrimeTrouble";
6
+ const { URL: URL$d } = resolveServiceUrl("AUTH_SERVICE");
7
+ const { getOne: getOne$4, postModel: postModel$4 } = ServiceFactory.build({
8
+ basePath: `${URL$d}/api/auth`
9
+ });
10
+ const log$e = KosLog.createLogger({ name: "auth-service", group: "Services" });
11
+ const getCurrentRole = async () => {
12
+ log$e.debug("sending GET for auth");
13
+ const response = await getOne$4({
14
+ urlOverride: `${URL$d}/api/app/kosdev.ddk/auth/role`
15
+ });
16
+ return response;
17
+ };
18
+ const sendPinCode = async (pinCode) => {
19
+ log$e.debug("sending POST for auth");
20
+ const response = await postModel$4({
21
+ urlOverride: `${URL$d}/api/app/kosdev.ddk/auth/pincode/${pinCode}`,
22
+ model: {}
23
+ });
24
+ return response;
25
+ };
26
+ const index$d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
15
27
  __proto__: null,
16
- getCurrentRole: _t,
17
- sendPinCode: Tt
28
+ getCurrentRole,
29
+ sendPinCode
18
30
  }, Symbol.toStringTag, { value: "Module" }));
19
- var Ao = Object.defineProperty, Fo = Object.getOwnPropertyDescriptor, $t = (e, t, o, s) => {
20
- for (var r = s > 1 ? void 0 : s ? Fo(t, o) : t, n = e.length - 1, a; n >= 0; n--)
21
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
22
- return s && r && Ao(t, o, r), r;
23
- };
24
- const x = "auth-model", lt = (e) => e.toLowerCase();
25
- let he = class {
26
- constructor(e, t, o) {
27
- i(this, "id");
28
- i(this, "logger");
29
- i(this, "currentRole");
30
- this.id = e, this.logger = o.logger, this.currentRole = "crew";
31
- }
32
- async authorize(e) {
33
- if (!e)
34
- return !1;
35
- const t = await Tt(e);
36
- return (t == null ? void 0 : t.status) === 200 ? t.data : !1;
31
+ var __defProp$j = Object.defineProperty;
32
+ var __getOwnPropDesc$p = Object.getOwnPropertyDescriptor;
33
+ var __decorateClass$p = (decorators, target, key, kind) => {
34
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$p(target, key) : target;
35
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
36
+ if (decorator = decorators[i])
37
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
38
+ if (kind && result) __defProp$j(target, key, result);
39
+ return result;
40
+ };
41
+ const MODEL_TYPE$p = "auth-model";
42
+ const convertAuthResponse = (response) => response.toLowerCase();
43
+ let AuthModelImpl = class {
44
+ id;
45
+ logger;
46
+ currentRole;
47
+ constructor(modelId, options, context) {
48
+ this.id = modelId;
49
+ this.logger = context.logger;
50
+ this.currentRole = "crew";
51
+ }
52
+ async authorize(pinCode) {
53
+ if (!pinCode) {
54
+ return false;
55
+ }
56
+ const response = await sendPinCode(pinCode);
57
+ if (response?.status === 200) {
58
+ return response.data;
59
+ } else {
60
+ return false;
61
+ }
37
62
  }
38
63
  // -------------------LIFECYCLE----------------------------
39
64
  async init() {
@@ -41,112 +66,158 @@ let he = class {
41
66
  }
42
67
  async load() {
43
68
  this.logger.debug(`loading auth ${this.id}`);
44
- const e = await _t();
45
- (e == null ? void 0 : e.status) === 200 && (this.logger.debug(`response ${e.data}`), v(() => {
46
- this.currentRole = lt(e.data);
47
- }));
69
+ const response = await getCurrentRole();
70
+ if (response?.status === 200) {
71
+ this.logger.debug(`response ${response.data}`);
72
+ kosAction(() => {
73
+ this.currentRole = convertAuthResponse(response.data);
74
+ });
75
+ }
48
76
  }
49
- handleRoleChange(e) {
50
- this.currentRole = lt(e);
77
+ handleRoleChange(role) {
78
+ this.currentRole = convertAuthResponse(role);
51
79
  }
52
- forceRole(e) {
53
- this.currentRole = e;
80
+ forceRole(role) {
81
+ this.currentRole = role;
54
82
  }
55
83
  };
56
- $t([
57
- Te({
84
+ __decorateClass$p([
85
+ kosTopicHandler({
58
86
  topic: "/app/kosdev.ddk/auth/role",
59
- websocket: !0
87
+ websocket: true
60
88
  })
61
- ], he.prototype, "handleRoleChange", 1);
62
- he = $t([
63
- l(x)
64
- ], he);
65
- const Qe = {
89
+ ], AuthModelImpl.prototype, "handleRoleChange", 1);
90
+ AuthModelImpl = __decorateClass$p([
91
+ kosModel(MODEL_TYPE$p)
92
+ ], AuthModelImpl);
93
+ const Auth = {
66
94
  registration: {
67
- [x]: {
68
- class: he,
69
- singleton: !1
95
+ [MODEL_TYPE$p]: {
96
+ class: AuthModelImpl,
97
+ singleton: false
70
98
  }
71
99
  },
72
- type: x,
73
- predicate: u(x),
74
- factory: c.Factory.create(x)
75
- };
76
- var xo = Object.defineProperty, Uo = Object.getOwnPropertyDescriptor, Xe = (e, t, o, s) => {
77
- for (var r = s > 1 ? void 0 : s ? Uo(t, o) : t, n = e.length - 1, a; n >= 0; n--)
78
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
79
- return s && r && xo(t, o, r), r;
80
- };
81
- const Pt = "door-model", jo = ht("doorPath");
82
- let re = class {
83
- constructor(e, t, o) {
84
- i(this, "id");
85
- i(this, "logger");
86
- i(this, "doorPath");
87
- i(this, "open");
88
- i(this, "ignoreDoor");
89
- this.id = e, this.logger = o.logger, this.doorPath = t.doorPath;
100
+ type: MODEL_TYPE$p,
101
+ predicate: isKosModel(MODEL_TYPE$p),
102
+ factory: Kos.Factory.create(MODEL_TYPE$p)
103
+ };
104
+ var __defProp$i = Object.defineProperty;
105
+ var __getOwnPropDesc$o = Object.getOwnPropertyDescriptor;
106
+ var __decorateClass$o = (decorators, target, key, kind) => {
107
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$o(target, key) : target;
108
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
109
+ if (decorator = decorators[i])
110
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
111
+ if (kind && result) __defProp$i(target, key, result);
112
+ return result;
113
+ };
114
+ const MODEL_TYPE$o = "door-model";
115
+ const PROP_PATH = createPropKey("doorPath");
116
+ let DoorModelImpl = class {
117
+ id;
118
+ logger;
119
+ doorPath;
120
+ open;
121
+ ignoreDoor;
122
+ constructor(modelId, options, context) {
123
+ this.id = modelId;
124
+ this.logger = context.logger;
125
+ this.doorPath = options.doorPath;
90
126
  }
91
127
  get currentState() {
92
- return this.open.value === void 0 ? "UNKNOWN" : this.open.value ? "OPEN" : "CLOSED";
128
+ if (this.open.value === void 0) {
129
+ return "UNKNOWN";
130
+ }
131
+ return this.open.value ? "OPEN" : "CLOSED";
93
132
  }
94
133
  get isOpen() {
95
- const e = this.open.value === void 0 ? !0 : this.open.value;
96
- return this.ignoreDoor.value ? (this.logger.debug(
97
- "Door state is being ignored (treating as closed) due to ignoreDoor config property being true."
98
- ), !1) : e;
134
+ const value = this.open.value === void 0 ? true : this.open.value;
135
+ const ignore = this.ignoreDoor.value;
136
+ if (ignore) {
137
+ this.logger.debug(
138
+ `Door state is being ignored (treating as closed) due to ignoreDoor config property being true.`
139
+ );
140
+ return false;
141
+ }
142
+ return value;
99
143
  }
100
144
  };
101
- Xe([
102
- vo({ path: jo, attribute: "state" })
103
- ], re.prototype, "open", 2);
104
- Xe([
105
- d({
145
+ __decorateClass$o([
146
+ kosStateProp({ path: PROP_PATH, attribute: "state" })
147
+ ], DoorModelImpl.prototype, "open", 2);
148
+ __decorateClass$o([
149
+ kosConfigProperty({
106
150
  path: "app:kosdev.ddk:app",
107
151
  attribute: "ncui.ignoreDoorStateOnExit"
108
152
  })
109
- ], re.prototype, "ignoreDoor", 2);
110
- re = Xe([
111
- l(Pt)
112
- ], re);
113
- const Wo = new mo({
114
- class: re,
115
- type: Pt
116
- }), { URL: Je } = h("SETUP-STEP_SERVICE"), { getAll: No, postModel: zo } = y.build({
117
- basePath: `${Je}/api/setup-step`
118
- }), Mt = g.createLogger({
153
+ ], DoorModelImpl.prototype, "ignoreDoor", 2);
154
+ DoorModelImpl = __decorateClass$o([
155
+ kosModel(MODEL_TYPE$o)
156
+ ], DoorModelImpl);
157
+ const Door = new KosModelRegistrationFactory({
158
+ class: DoorModelImpl,
159
+ type: MODEL_TYPE$o
160
+ });
161
+ const { URL: URL$c } = resolveServiceUrl("SETUP-STEP_SERVICE");
162
+ const { getAll: getAll$9, postModel: postModel$3 } = ServiceFactory.build({
163
+ basePath: `${URL$c}/api/setup-step`
164
+ });
165
+ const log$d = KosLog.createLogger({
119
166
  name: "setup-step-service",
120
167
  group: "Services"
121
- }), Ot = async () => (Mt.debug("sending GET for setup-step"), await No({
122
- urlOverride: `${Je}/api/app/kosdev.ddk/setup/steps`
123
- })), St = async (e) => (Mt.debug("sending POST for setup-step"), await zo({
124
- urlOverride: `${Je}/api/app/kosdev.ddk/setup/complete/${e}`,
125
- model: {}
126
- })), Ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
168
+ });
169
+ const getSetupSteps = async () => {
170
+ log$d.debug("sending GET for setup-step");
171
+ const response = await getAll$9({
172
+ urlOverride: `${URL$c}/api/app/kosdev.ddk/setup/steps`
173
+ });
174
+ return response;
175
+ };
176
+ const markStepComplete = async (stepId) => {
177
+ log$d.debug("sending POST for setup-step");
178
+ const response = await postModel$3({
179
+ urlOverride: `${URL$c}/api/app/kosdev.ddk/setup/complete/${stepId}`,
180
+ model: {}
181
+ });
182
+ return response;
183
+ };
184
+ const index$c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
127
185
  __proto__: null,
128
- getSetupSteps: Ot,
129
- markStepComplete: St
186
+ getSetupSteps,
187
+ markStepComplete
130
188
  }, Symbol.toStringTag, { value: "Module" }));
131
- var Vo = Object.getOwnPropertyDescriptor, Ho = (e, t, o, s) => {
132
- for (var r = s > 1 ? void 0 : s ? Vo(t, o) : t, n = e.length - 1, a; n >= 0; n--)
133
- (a = e[n]) && (r = a(r) || r);
134
- return r;
135
- };
136
- const U = "setup-step-model";
137
- let Ae = class {
138
- constructor(e, t, o) {
139
- i(this, "id");
140
- i(this, "idx");
141
- i(this, "name");
142
- i(this, "complete");
143
- i(this, "preStep");
144
- i(this, "exclusive");
145
- i(this, "logger");
146
- this.id = e, this.idx = t.idx, this.logger = o.logger, this.name = t.name, this.complete = t.complete, this.preStep = t.preStep, this.exclusive = t.exclusive;
147
- }
148
- updateModel(e) {
149
- this.name = e.name, this.idx = e.idx, this.complete = e.complete, this.preStep = e.preStep, this.exclusive = e.exclusive;
189
+ var __getOwnPropDesc$n = Object.getOwnPropertyDescriptor;
190
+ var __decorateClass$n = (decorators, target, key, kind) => {
191
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$n(target, key) : target;
192
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
193
+ if (decorator = decorators[i])
194
+ result = decorator(result) || result;
195
+ return result;
196
+ };
197
+ const MODEL_TYPE$n = "setup-step-model";
198
+ let SetupStepModelImpl = class {
199
+ id;
200
+ idx;
201
+ name;
202
+ complete;
203
+ preStep;
204
+ exclusive;
205
+ logger;
206
+ constructor(modelId, options, context) {
207
+ this.id = modelId;
208
+ this.idx = options.idx;
209
+ this.logger = context.logger;
210
+ this.name = options.name;
211
+ this.complete = options.complete;
212
+ this.preStep = options.preStep;
213
+ this.exclusive = options.exclusive;
214
+ }
215
+ updateModel(options) {
216
+ this.name = options.name;
217
+ this.idx = options.idx;
218
+ this.complete = options.complete;
219
+ this.preStep = options.preStep;
220
+ this.exclusive = options.exclusive;
150
221
  }
151
222
  get titleKey() {
152
223
  return `setup.${this.name}.title`;
@@ -155,10 +226,12 @@ let Ae = class {
155
226
  return `setup.${this.name}.body`;
156
227
  }
157
228
  async completeStep() {
158
- const e = await St(this.name);
159
- (e == null ? void 0 : e.status) === 200 && v(() => {
160
- this.complete = !0;
161
- });
229
+ const response = await markStepComplete(this.name);
230
+ if (response?.status === 200) {
231
+ kosAction(() => {
232
+ this.complete = true;
233
+ });
234
+ }
162
235
  }
163
236
  // -------------------LIFECYCLE----------------------------
164
237
  async init() {
@@ -168,88 +241,101 @@ let Ae = class {
168
241
  this.logger.debug(`loading setup-step ${this.id}`);
169
242
  }
170
243
  };
171
- Ae = Ho([
172
- l(U)
173
- ], Ae);
174
- const wt = {
244
+ SetupStepModelImpl = __decorateClass$n([
245
+ kosModel(MODEL_TYPE$n)
246
+ ], SetupStepModelImpl);
247
+ const SetupStep = {
175
248
  registration: {
176
- [U]: {
177
- class: Ae,
178
- singleton: !1
249
+ [MODEL_TYPE$n]: {
250
+ class: SetupStepModelImpl,
251
+ singleton: false
179
252
  }
180
253
  },
181
- type: U,
182
- predicate: u(U),
183
- factory: c.Factory.create(U)
184
- };
185
- var Bo = Object.defineProperty, Ko = Object.getOwnPropertyDescriptor, we = (e, t, o, s) => {
186
- for (var r = s > 1 ? void 0 : s ? Ko(t, o) : t, n = e.length - 1, a; n >= 0; n--)
187
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
188
- return s && r && Bo(t, o, r), r;
189
- };
190
- const j = "setup-step-container-model";
191
- function dt(e) {
192
- return (t) => {
193
- const o = wt.factory(t.id)(t);
194
- o.updateModel(t), e.addModel(o);
254
+ type: MODEL_TYPE$n,
255
+ predicate: isKosModel(MODEL_TYPE$n),
256
+ factory: Kos.Factory.create(MODEL_TYPE$n)
257
+ };
258
+ var __defProp$h = Object.defineProperty;
259
+ var __getOwnPropDesc$m = Object.getOwnPropertyDescriptor;
260
+ var __decorateClass$m = (decorators, target, key, kind) => {
261
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$m(target, key) : target;
262
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
263
+ if (decorator = decorators[i])
264
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
265
+ if (kind && result) __defProp$h(target, key, result);
266
+ return result;
267
+ };
268
+ const MODEL_TYPE$m = "setup-step-container-model";
269
+ function addStep(container) {
270
+ return (step) => {
271
+ const model = SetupStep.factory(step.id)(step);
272
+ model.updateModel(step);
273
+ container.addModel(model);
195
274
  };
196
275
  }
197
- function ct(e) {
198
- return (t) => {
199
- e.removeModel(t);
276
+ function removeStep(container) {
277
+ return (id) => {
278
+ container.removeModel(id);
200
279
  };
201
280
  }
202
- let E = class {
203
- constructor(e, t, o) {
204
- i(this, "id");
205
- i(this, "_currentStep");
206
- i(this, "logger");
207
- i(this, "models");
208
- i(this, "authModel");
209
- this.id = e, this.logger = o.logger, this._currentStep = void 0, this.models = new Ve({
210
- parentId: e,
281
+ let SetupStepContainerModelImpl = class {
282
+ id;
283
+ _currentStep;
284
+ logger;
285
+ models;
286
+ authModel;
287
+ constructor(modelId, options, context) {
288
+ this.id = modelId;
289
+ this.logger = context.logger;
290
+ this._currentStep = void 0;
291
+ this.models = new KosModelContainer({
292
+ parentId: modelId,
211
293
  sortKey: "idx"
212
294
  });
213
295
  }
214
296
  get currentStep() {
215
297
  return this._currentStep;
216
298
  }
217
- setCurrentStep(e) {
218
- const t = this.models.getModel(e);
219
- t && (this._currentStep = t);
299
+ setCurrentStep(id) {
300
+ const step = this.models.getModel(id);
301
+ if (step) {
302
+ this._currentStep = step;
303
+ }
220
304
  }
221
305
  nextStep() {
222
- if (!this._currentStep)
306
+ if (!this._currentStep) {
223
307
  this._currentStep = this.firstIncompleteStep;
224
- else {
225
- const e = this._currentStep.idx, t = this.models.data.find((o) => o.idx > e);
226
- t && (this._currentStep = t);
308
+ } else {
309
+ const currentIdx = this._currentStep.idx;
310
+ const nextStep = this.models.data.find((step) => step.idx > currentIdx);
311
+ if (nextStep) {
312
+ this._currentStep = nextStep;
313
+ }
227
314
  }
228
315
  }
229
316
  get hasIncompletePreSteps() {
230
- return this.models.data.some((e) => e.preStep && !e.complete);
317
+ return this.models.data.some((step) => step.preStep && !step.complete);
231
318
  }
232
319
  get setupRequired() {
233
- return this.models.data.some((e) => !e.complete);
320
+ return this.models.data.some((step) => !step.complete);
234
321
  }
235
322
  get firstIncompleteStep() {
236
- return this.models.data.find((e) => !e.complete);
323
+ return this.models.data.find((step) => !step.complete);
237
324
  }
238
325
  get isLastStep() {
239
- var e;
240
- return this.models.data[this.models.data.length - 1].id === ((e = this._currentStep) == null ? void 0 : e.id);
326
+ return this.models.data[this.models.data.length - 1].id === this._currentStep?.id;
241
327
  }
242
328
  get data() {
243
329
  return this.models.data;
244
330
  }
245
- getModel(e) {
246
- return this.models.getModel(e);
331
+ getModel(id) {
332
+ return this.models.getModel(id);
247
333
  }
248
- addModel(e) {
249
- this.models.addModel(e);
334
+ addModel(model) {
335
+ this.models.addModel(model);
250
336
  }
251
- removeModel(e) {
252
- this.models.removeModel(e);
337
+ removeModel(id) {
338
+ this.models.removeModel(id);
253
339
  }
254
340
  // -------------------LIFECYCLE----------------------------
255
341
  async init() {
@@ -257,156 +343,190 @@ let E = class {
257
343
  }
258
344
  async load() {
259
345
  this.logger.debug(`loading setup-step-container container ${this.id}`);
260
- const e = await Ot();
261
- if (e != null && e.data) {
262
- const t = e.data.map(
263
- (o, s) => ({
264
- ...o,
265
- idx: s,
266
- id: `setup-${o.name}`
267
- })
346
+ const response = await getSetupSteps();
347
+ if (response?.data) {
348
+ const identifiableSteps = response.data.map(
349
+ (step, index2) => {
350
+ return {
351
+ ...step,
352
+ idx: index2,
353
+ id: `setup-${step.name}`
354
+ };
355
+ }
268
356
  );
269
- it({
357
+ resolveContainerDeltas({
270
358
  container: this.models,
271
- onAddItem: dt(this),
272
- onRemoveItem: ct(this)
273
- })(t);
359
+ onAddItem: addStep(this),
360
+ onRemoveItem: removeStep(this)
361
+ })(identifiableSteps);
274
362
  }
275
363
  this.nextStep();
276
364
  }
277
- handleStepChanges(e) {
278
- const t = e.map((o, s) => ({
279
- ...o,
280
- idx: s,
281
- id: `setup-${o.name}`
282
- }));
283
- it({
365
+ handleStepChanges(steps) {
366
+ const identifiableSteps = steps.map((step, index2) => {
367
+ return {
368
+ ...step,
369
+ idx: index2,
370
+ id: `setup-${step.name}`
371
+ };
372
+ });
373
+ resolveContainerDeltas({
284
374
  container: this.models,
285
- onAddItem: dt(this),
286
- onRemoveItem: ct(this)
287
- })(t);
288
- }
289
- };
290
- we([
291
- $e
292
- ], E.prototype, "models", 2);
293
- we([
294
- p({ modelType: Qe.type })
295
- ], E.prototype, "authModel", 2);
296
- we([
297
- Te({
375
+ onAddItem: addStep(this),
376
+ onRemoveItem: removeStep(this)
377
+ })(identifiableSteps);
378
+ }
379
+ };
380
+ __decorateClass$m([
381
+ kosChild
382
+ ], SetupStepContainerModelImpl.prototype, "models", 2);
383
+ __decorateClass$m([
384
+ kosDependency({ modelType: Auth.type })
385
+ ], SetupStepContainerModelImpl.prototype, "authModel", 2);
386
+ __decorateClass$m([
387
+ kosTopicHandler({
298
388
  topic: "/app/kosdev.ddk/setup/steps",
299
- websocket: !0
389
+ websocket: true
300
390
  })
301
- ], E.prototype, "handleStepChanges", 1);
302
- E = we([
303
- l(j)
304
- ], E);
305
- const Et = {
391
+ ], SetupStepContainerModelImpl.prototype, "handleStepChanges", 1);
392
+ SetupStepContainerModelImpl = __decorateClass$m([
393
+ kosModel(MODEL_TYPE$m)
394
+ ], SetupStepContainerModelImpl);
395
+ const SetupStepContainer = {
306
396
  registration: {
307
- [j]: {
308
- class: E,
309
- singleton: !0
397
+ [MODEL_TYPE$m]: {
398
+ class: SetupStepContainerModelImpl,
399
+ singleton: true
310
400
  },
311
- ...wt.registration
401
+ ...SetupStep.registration
312
402
  },
313
- type: j,
314
- predicate: u(j),
315
- factory: c.Singleton.create(j)
316
- }, { URL: S } = h("AUTH_SERVICE"), { getOne: Ct, getAll: pe } = y.build({
317
- basePath: `${S}/api/app/kosdev.ddk/ncui/`
318
- }), se = g.createLogger({ name: "auth-service", group: "Services" }), Yo = async () => {
319
- se.debug("sending GET for cuis");
320
- const e = await pe({
321
- urlOverride: `${S}/api/app/kosdev.ddk/cui`
403
+ type: MODEL_TYPE$m,
404
+ predicate: isKosModel(MODEL_TYPE$m),
405
+ factory: Kos.Singleton.create(MODEL_TYPE$m)
406
+ };
407
+ const { URL: URL$b } = resolveServiceUrl("AUTH_SERVICE");
408
+ const { getOne: getOne$3, getAll: getAll$8 } = ServiceFactory.build({
409
+ basePath: `${URL$b}/api/app/kosdev.ddk/ncui/`
410
+ });
411
+ const log$c = KosLog.createLogger({ name: "auth-service", group: "Services" });
412
+ const getCuis = async () => {
413
+ log$c.debug("sending GET for cuis");
414
+ const response = await getAll$8({
415
+ urlOverride: `${URL$b}/api/app/kosdev.ddk/cui`
322
416
  });
323
- if ((e == null ? void 0 : e.status) !== 200)
417
+ if (response?.status !== 200) {
324
418
  throw new Error("Failed to retrieve cuis");
325
- return e.data;
326
- }, Go = async () => {
327
- se.debug("sending GET for navigation");
419
+ }
420
+ return response.data;
421
+ };
422
+ const getNavigation = async () => {
423
+ log$c.debug("sending GET for navigation");
328
424
  try {
329
- const e = await pe({
330
- urlOverride: `${S}/api/kos/descriptor/app:kosdev.ddk:ncuiDescriptor/kondra.ncui.navigations`
425
+ const extensionResponse = await getAll$8({
426
+ urlOverride: `${URL$b}/api/kos/descriptor/app:kosdev.ddk:ncuiDescriptor/kondra.ncui.navigations`
331
427
  });
332
- if ((e == null ? void 0 : e.status) !== 200) {
333
- se.info("no extensions found, using base data");
334
- const t = await pe({
335
- urlOverride: `${S}/api/kos/descriptor/system:app/kondra.ncui.navigations`
428
+ if (extensionResponse?.status !== 200) {
429
+ log$c.info(`no extensions found, using base data`);
430
+ const response = await getAll$8({
431
+ urlOverride: `${URL$b}/api/kos/descriptor/system:app/kondra.ncui.navigations`
336
432
  });
337
- return (t == null ? void 0 : t.data) ?? [];
433
+ return response?.data ?? [];
338
434
  }
339
- return (e == null ? void 0 : e.data) ?? [];
340
- } catch {
341
- const t = await pe({
342
- urlOverride: `${S}/api/kos/descriptor/system:app/kondra.ncui.navigations`
435
+ return extensionResponse?.data ?? [];
436
+ } catch (error) {
437
+ const response = await getAll$8({
438
+ urlOverride: `${URL$b}/api/kos/descriptor/system:app/kondra.ncui.navigations`
343
439
  });
344
- return (t == null ? void 0 : t.data) ?? [];
345
- }
346
- }, qo = async () => (se.debug("navigating to CUI"), await Ct({
347
- urlOverride: `${S}/api/app/kosdev.ddk/cui/open`
348
- })), Qo = async () => (se.debug("navigating to NCUI"), await Ct({
349
- urlOverride: `${S}/api/app/kosdev.ddk/ncui/open`
350
- }));
351
- var Xo = Object.defineProperty, Jo = Object.getOwnPropertyDescriptor, O = (e, t, o, s) => {
352
- for (var r = s > 1 ? void 0 : s ? Jo(t, o) : t, n = e.length - 1, a; n >= 0; n--)
353
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
354
- return s && r && Xo(t, o, r), r;
355
- };
356
- const W = "application-model", Lt = (e, t = "") => e.reduce((o, s) => {
357
- const r = t ? `${t}.${s.name}` : s.name;
358
- if (o[r] = { ...s, root: !t }, s.children) {
359
- const n = Lt(s.children, r);
360
- Object.keys(n).forEach((a) => {
361
- o[a] = n[a];
440
+ return response?.data ?? [];
441
+ }
442
+ };
443
+ const navigateToCui = async () => {
444
+ log$c.debug("navigating to CUI");
445
+ const response = await getOne$3({
446
+ urlOverride: `${URL$b}/api/app/kosdev.ddk/cui/open`
447
+ });
448
+ return response;
449
+ };
450
+ const navigateToNCui$1 = async () => {
451
+ log$c.debug("navigating to NCUI");
452
+ const response = await getOne$3({
453
+ urlOverride: `${URL$b}/api/app/kosdev.ddk/ncui/open`
454
+ });
455
+ return response;
456
+ };
457
+ var __defProp$g = Object.defineProperty;
458
+ var __getOwnPropDesc$l = Object.getOwnPropertyDescriptor;
459
+ var __decorateClass$l = (decorators, target, key, kind) => {
460
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$l(target, key) : target;
461
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
462
+ if (decorator = decorators[i])
463
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
464
+ if (kind && result) __defProp$g(target, key, result);
465
+ return result;
466
+ };
467
+ const MODEL_TYPE$l = "application-model";
468
+ const flattenNavigationItems = (items, path = "") => items.reduce((acc, item) => {
469
+ const itemPath = path ? `${path}.${item.name}` : item.name;
470
+ acc[itemPath] = { ...item, root: !path };
471
+ if (item.children) {
472
+ const childItems = flattenNavigationItems(item.children, itemPath);
473
+ Object.keys(childItems).forEach((key) => {
474
+ acc[key] = childItems[key];
362
475
  });
363
476
  }
364
- return o;
477
+ return acc;
365
478
  }, {});
366
- let b = class {
367
- constructor(e, t, o) {
368
- i(this, "id");
369
- i(this, "device");
370
- i(this, "authModel");
371
- i(this, "setupStepContainer");
372
- i(this, "door");
373
- i(this, "ncuiLanguage");
374
- i(this, "activeCui");
375
- i(this, "fallbackCui");
376
- i(this, "_cuis", []);
377
- i(this, "_navigationItems", []);
378
- // @kosConfigProperty({
379
- // path: 'somewhere.enable.dial.animation',
380
- // attribute: 'enableDialAnimation',
381
- // })
382
- // enableDialAnimation!: KosConfigProperty<boolean>;
383
- // @kosConfigProperty({
384
- // path: 'somewhere.enable.modal.animation',
385
- // attribute: 'enableModalAnimation',
386
- // })
387
- // enableModalAnimation!: KosConfigProperty<boolean>;
388
- // @kosConfigProperty({
389
- // path: 'somewhere.enable.sidebar.animation',
390
- // attribute: 'enableSidebarAnimation',
391
- // })
392
- // enableSidebarAnimation!: KosConfigProperty<boolean>;
393
- i(this, "languages");
394
- i(this, "logger");
395
- this.id = e, this.languages = [], this._cuis = [], this.logger = o.logger, this.door = Wo.instance("app:kosdev.ddk:service:door:door").options({
479
+ let ApplicationModelImpl = class {
480
+ id;
481
+ device;
482
+ authModel;
483
+ setupStepContainer;
484
+ door;
485
+ ncuiLanguage;
486
+ activeCui;
487
+ fallbackCui;
488
+ _cuis = [];
489
+ _navigationItems = [];
490
+ // @kosConfigProperty({
491
+ // path: 'somewhere.enable.dial.animation',
492
+ // attribute: 'enableDialAnimation',
493
+ // })
494
+ // enableDialAnimation!: KosConfigProperty<boolean>;
495
+ // @kosConfigProperty({
496
+ // path: 'somewhere.enable.modal.animation',
497
+ // attribute: 'enableModalAnimation',
498
+ // })
499
+ // enableModalAnimation!: KosConfigProperty<boolean>;
500
+ // @kosConfigProperty({
501
+ // path: 'somewhere.enable.sidebar.animation',
502
+ // attribute: 'enableSidebarAnimation',
503
+ // })
504
+ // enableSidebarAnimation!: KosConfigProperty<boolean>;
505
+ languages;
506
+ logger;
507
+ constructor(modelId, _options, context) {
508
+ this.id = modelId;
509
+ this.languages = [];
510
+ this._cuis = [];
511
+ this.logger = context.logger;
512
+ this.door = Door.instance("app:kosdev.ddk:service:door:door").options({
396
513
  doorPath: "app:kosdev.ddk:service:door:door"
397
514
  }).build();
398
515
  }
399
516
  get setupRequired() {
400
- return this.authModel.currentRole === "crew" ? !1 : this.setupStepContainer.setupRequired;
517
+ return this.authModel.currentRole === "crew" ? false : this.setupStepContainer.setupRequired;
401
518
  }
402
519
  get currentRole() {
403
520
  return this.authModel.currentRole;
404
521
  }
405
522
  get cuis() {
406
- return this._cuis.reduce((e, t) => (e[t.appId] = t, e), {});
523
+ return this._cuis.reduce((acc, cui) => {
524
+ acc[cui.appId] = cui;
525
+ return acc;
526
+ }, {});
407
527
  }
408
528
  get navigationItems() {
409
- return Lt(this._navigationItems);
529
+ return flattenNavigationItems(this._navigationItems);
410
530
  }
411
531
  get hasCuiDefined() {
412
532
  return !!this.activeCui.value || !!this.fallbackCui.value;
@@ -415,19 +535,24 @@ let b = class {
415
535
  return this.door.isOpen;
416
536
  }
417
537
  async enter() {
418
- this.logger.info("navigating to NCUI"), await Qo();
538
+ this.logger.info("navigating to NCUI");
539
+ await navigateToNCui$1();
419
540
  }
420
541
  async exit() {
421
- this.logger.info("navigating to CUI"), await qo();
542
+ this.logger.info("navigating to CUI");
543
+ await navigateToCui();
422
544
  }
423
545
  // -------------------LIFECYCLE----------------------------
424
546
  async load() {
425
- var o, s;
426
547
  this.logger.debug(`loading application ${this.id}`);
427
- const e = await Go();
428
- this._navigationItems = e;
429
- const t = await Yo();
430
- this._cuis = t, (o = this.setupStepContainer) != null && o.hasIncompletePreSteps && ((s = this.authModel) == null || s.forceRole("technician")), this.languages = [
548
+ const navigationItems = await getNavigation();
549
+ this._navigationItems = navigationItems;
550
+ const cuis = await getCuis();
551
+ this._cuis = cuis;
552
+ if (this.setupStepContainer?.hasIncompletePreSteps) {
553
+ this.authModel?.forceRole("technician");
554
+ }
555
+ this.languages = [
431
556
  {
432
557
  name: "English",
433
558
  locale: "en"
@@ -435,90 +560,103 @@ let b = class {
435
560
  ];
436
561
  }
437
562
  };
438
- O([
439
- p({ modelType: bo.type })
440
- ], b.prototype, "device", 2);
441
- O([
442
- p({ modelType: Qe.type })
443
- ], b.prototype, "authModel", 2);
444
- O([
445
- p({ modelType: Et.type })
446
- ], b.prototype, "setupStepContainer", 2);
447
- O([
448
- $e
449
- ], b.prototype, "door", 2);
450
- O([
451
- d({
563
+ __decorateClass$l([
564
+ kosDependency({ modelType: Device.type })
565
+ ], ApplicationModelImpl.prototype, "device", 2);
566
+ __decorateClass$l([
567
+ kosDependency({ modelType: Auth.type })
568
+ ], ApplicationModelImpl.prototype, "authModel", 2);
569
+ __decorateClass$l([
570
+ kosDependency({ modelType: SetupStepContainer.type })
571
+ ], ApplicationModelImpl.prototype, "setupStepContainer", 2);
572
+ __decorateClass$l([
573
+ kosChild
574
+ ], ApplicationModelImpl.prototype, "door", 2);
575
+ __decorateClass$l([
576
+ kosConfigProperty({
452
577
  path: "app:kosdev.ddk:app",
453
578
  attribute: "ncui.ncuiLanguage"
454
579
  //updated attribute for language config property
455
580
  })
456
- ], b.prototype, "ncuiLanguage", 2);
457
- O([
458
- d({
581
+ ], ApplicationModelImpl.prototype, "ncuiLanguage", 2);
582
+ __decorateClass$l([
583
+ kosConfigProperty({
459
584
  path: "app:kosdev.ddk:service:cui",
460
585
  attribute: "activeCui"
461
586
  })
462
- ], b.prototype, "activeCui", 2);
463
- O([
464
- d({
587
+ ], ApplicationModelImpl.prototype, "activeCui", 2);
588
+ __decorateClass$l([
589
+ kosConfigProperty({
465
590
  path: "app:kosdev.ddk:service:cui",
466
591
  attribute: "fallbackCui"
467
592
  })
468
- ], b.prototype, "fallbackCui", 2);
469
- b = O([
470
- l(W)
471
- ], b);
472
- const Ze = {
593
+ ], ApplicationModelImpl.prototype, "fallbackCui", 2);
594
+ ApplicationModelImpl = __decorateClass$l([
595
+ kosModel(MODEL_TYPE$l)
596
+ ], ApplicationModelImpl);
597
+ const Application = {
473
598
  registration: {
474
- [W]: {
475
- class: b,
476
- singleton: !0
599
+ [MODEL_TYPE$l]: {
600
+ class: ApplicationModelImpl,
601
+ singleton: true
477
602
  }
478
603
  },
479
- type: W,
480
- predicate: u(W),
481
- factory: c.Singleton.create(
482
- W
604
+ type: MODEL_TYPE$l,
605
+ predicate: isKosModel(MODEL_TYPE$l),
606
+ factory: Kos.Singleton.create(
607
+ MODEL_TYPE$l
483
608
  )
484
- }, ue = {
609
+ };
610
+ const RoleMap = {
485
611
  none: 999,
486
612
  crew: 0,
487
613
  technician: 1,
488
614
  manager: 2
489
- }, Dt = (e) => (t) => {
490
- if (t.type === ft)
491
- return !1;
492
- const o = (t == null ? void 0 : t.role) || "technician";
493
- if (e && o) {
494
- const s = ue[e.toLowerCase()] ?? ue.crew, r = ue[o.toLowerCase()] ?? ue.crew;
495
- return s >= r;
496
- }
497
- return !1;
498
- };
499
- var Zo = Object.defineProperty, er = Object.getOwnPropertyDescriptor, I = (e, t, o, s) => {
500
- for (var r = s > 1 ? void 0 : s ? er(t, o) : t, n = e.length - 1, a; n >= 0; n--)
501
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
502
- return s && r && Zo(t, o, r), r;
503
- };
504
- const kt = "agitation-control-model", Fe = "resolve", tr = "agitate";
505
- let $ = class {
506
- constructor(e, t, o) {
507
- i(this, "id");
508
- i(this, "futureHandler");
509
- i(this, "logger");
510
- i(this, "troubleContainer");
511
- i(this, "_agitationFutureId");
512
- i(this, "_canExit", !0);
513
- i(this, "_exiting", !1);
514
- i(this, "_isFailed", !1);
515
- i(this, "disposer");
516
- i(this, "application");
517
- i(this, "inProgress", []);
518
- this.id = e, this.logger = o.logger, this.troubleContainer = t.companionParent, this.futureHandler = new _o(this, Fe);
519
- }
520
- set isFailed(e) {
521
- this._isFailed = e;
615
+ };
616
+ const troubleVisibilityFilter = (currentRole) => (trouble) => {
617
+ if (trouble.type === AGITATION_REQUIRED_TROUBLE) {
618
+ return false;
619
+ }
620
+ const visibleRole = trouble?.role || "technician";
621
+ if (currentRole && visibleRole) {
622
+ const currentRoleIndex = RoleMap[currentRole.toLowerCase()] ?? RoleMap["crew"];
623
+ const visibleRoleIndex = RoleMap[visibleRole.toLowerCase()] ?? RoleMap["crew"];
624
+ return currentRoleIndex >= visibleRoleIndex;
625
+ }
626
+ return false;
627
+ };
628
+ var __defProp$f = Object.defineProperty;
629
+ var __getOwnPropDesc$k = Object.getOwnPropertyDescriptor;
630
+ var __decorateClass$k = (decorators, target, key, kind) => {
631
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$k(target, key) : target;
632
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
633
+ if (decorator = decorators[i])
634
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
635
+ if (kind && result) __defProp$f(target, key, result);
636
+ return result;
637
+ };
638
+ const MODEL_TYPE$k = "agitation-control-model";
639
+ const FUTURE_RESOLVE = "resolve";
640
+ const FUTURE_AGITATE = "agitate";
641
+ let AgitationControlModelImpl = class {
642
+ id;
643
+ futureHandler;
644
+ logger;
645
+ troubleContainer;
646
+ _agitationFutureId;
647
+ _canExit = true;
648
+ _exiting = false;
649
+ _isFailed = false;
650
+ disposer;
651
+ application;
652
+ constructor(modelId, options, context) {
653
+ this.id = modelId;
654
+ this.logger = context.logger;
655
+ this.troubleContainer = options.companionParent;
656
+ this.futureHandler = new MultipleFutureHandler(this, FUTURE_RESOLVE);
657
+ }
658
+ set isFailed(value) {
659
+ this._isFailed = value;
522
660
  }
523
661
  get isFailed() {
524
662
  return this._isFailed;
@@ -529,188 +667,241 @@ let $ = class {
529
667
  get isAgitating() {
530
668
  return !!this._agitationFutureId;
531
669
  }
532
- set exiting(e) {
533
- this._exiting = e;
670
+ set exiting(value) {
671
+ this._exiting = value;
534
672
  }
535
673
  get exiting() {
536
674
  return this._exiting;
537
675
  }
538
676
  get canExit() {
539
- return this.queuedTroubles.length === 0 && this._canExit;
677
+ const allDeferredCount = this.queuedTroubles.length;
678
+ return allDeferredCount === 0 && this._canExit;
540
679
  }
541
680
  clearAll() {
542
- this.queuedTroubles.forEach((e) => {
543
- e.clearDefer();
681
+ this.queuedTroubles.forEach((trouble) => {
682
+ trouble.clearDefer();
544
683
  });
545
684
  }
546
685
  get readyToResolve() {
547
- const e = this.queuedTroubles.length, t = this.queuedTroubles.filter((s) => s.shouldDefer), o = e > 0 && t.length === 0;
548
- return this.isDoorClosed && o && this.exiting;
549
- }
550
- onFutureUpdate(e) {
551
- e.endState === T.Success ? (this.logger.debug(
552
- `Resolve deferred troubles future ${e.id} completed successfully`
553
- ), this.queuedTroubles.forEach((t) => {
554
- t.clearDefer();
555
- }), v(() => {
556
- this._canExit = !0, this._isFailed = !1;
557
- })) : (e.endState === T.Fail || e.endState === T.Canceled || e.endState === T.Aborted) && (this.logger.error(`Resolve deferred troubles future ${e.id} failed`), this.clearAll(), v(() => {
558
- this._canExit = !1, this._isFailed = !0;
559
- }));
560
- }
561
- async resolveDeferredTroubles(e) {
562
- const t = this.queuedTroubles.filter((s) => !s.shouldDefer).map((s) => s.rawId).filter((s) => !this.inProgress.includes(s));
563
- return this.inProgress.push(...t), t.length === 0 ? void 0 : await Me.bulkResolveTroubles(
564
- t,
686
+ const allDeferredCount = this.queuedTroubles.length;
687
+ const notResolvable = this.queuedTroubles.filter((t) => t.shouldDefer);
688
+ const _readyToResolve = allDeferredCount > 0 && notResolvable.length === 0;
689
+ return this.isDoorClosed && _readyToResolve && this.exiting;
690
+ }
691
+ onFutureUpdate(future) {
692
+ if (future.endState === FutureEndState.Success) {
693
+ this.logger.debug(
694
+ `Resolve deferred troubles future ${future.id} completed successfully`
695
+ );
696
+ this.queuedTroubles.forEach((trouble) => {
697
+ trouble.clearDefer();
698
+ });
699
+ kosAction(() => {
700
+ this._canExit = true;
701
+ this._isFailed = false;
702
+ });
703
+ } else if (future.endState === FutureEndState.Fail || future.endState === FutureEndState.Canceled || future.endState === FutureEndState.Aborted) {
704
+ this.logger.error(`Resolve deferred troubles future ${future.id} failed`);
705
+ this.clearAll();
706
+ kosAction(() => {
707
+ this._canExit = false;
708
+ this._isFailed = true;
709
+ });
710
+ }
711
+ }
712
+ inProgress = [];
713
+ async resolveDeferredTroubles(tracker) {
714
+ const toResolve = this.queuedTroubles.filter((t) => !t.shouldDefer).map((trouble) => trouble.rawId).filter((id) => !this.inProgress.includes(id));
715
+ this.inProgress.push(...toResolve);
716
+ if (toResolve.length === 0) {
717
+ return void 0;
718
+ }
719
+ const response = await TroubleServices.bulkResolveTroubles(
720
+ toResolve,
565
721
  void 0,
566
- e
722
+ tracker
567
723
  );
724
+ return response;
568
725
  }
569
726
  get hasQueuedTroubles() {
570
727
  return this.queuedTroubles.length > 0;
571
728
  }
572
729
  get queuedTroubles() {
573
730
  return this.troubleContainer.troubles.getIndexByKey(
574
- nt.INDEX_TROUBLES_BY_DEFERRED,
575
- nt.TROUBLES_DEFERRED
731
+ Troubles.INDEX_TROUBLES_BY_DEFERRED,
732
+ Troubles.TROUBLES_DEFERRED
576
733
  );
577
734
  }
578
735
  get visibleTroubles() {
579
- const e = this.application.currentRole;
580
- return this.troubleContainer.troubles.data.filter(Dt(e)).filter((t) => t.type !== ft);
736
+ const currentRole = this.application.currentRole;
737
+ return this.troubleContainer.troubles.data.filter(troubleVisibilityFilter(currentRole)).filter((trouble) => trouble.type !== AGITATION_REQUIRED_TROUBLE);
581
738
  }
582
739
  // -------------------LIFECYCLE----------------------------
583
740
  get future() {
584
741
  return this.futureHandler.future;
585
742
  }
586
743
  get resolveFuture() {
587
- return this.futureHandler.getFuture(Fe);
744
+ return this.futureHandler.getFuture(FUTURE_RESOLVE);
588
745
  }
589
746
  get agitateFuture() {
590
- return this.futureHandler.getFuture(tr);
747
+ return this.futureHandler.getFuture(FUTURE_AGITATE);
591
748
  }
592
- handleAgitationStarted(e) {
593
- this.logger.info(`Agitation started for ${e.path}`), this._agitationFutureId = String(e.futureId);
749
+ handleAgitationStarted(event) {
750
+ this.logger.info(`Agitation started for ${event.path}`);
751
+ this._agitationFutureId = String(event.futureId);
594
752
  }
595
- handleAgitationEnded(e) {
596
- this.logger.info(`Agitation ended for ${e.path}`), this._agitationFutureId = void 0;
753
+ handleAgitationEnded(event) {
754
+ this.logger.info(`Agitation ended for ${event.path}`);
755
+ this._agitationFutureId = void 0;
597
756
  }
598
757
  async init() {
599
758
  this.logger.debug(`initializing agitation-control ${this.id}`);
600
759
  }
601
760
  unload() {
602
- this.logger.debug(`unloading agitation-control ${this.id}`), this.disposer && this.disposer();
761
+ this.logger.debug(`unloading agitation-control ${this.id}`);
762
+ if (this.disposer) {
763
+ this.disposer();
764
+ }
603
765
  }
604
766
  handleReadyToResolve() {
605
- this.readyToResolve && (this.logger.info("AgitationControl - Resolving deferred troubles"), this.resolveDeferredTroubles()), this._agitationFutureId && this.logger.info("AgitationControl - Agitation started");
767
+ if (this.readyToResolve) {
768
+ this.logger.info(`AgitationControl - Resolving deferred troubles`);
769
+ this.resolveDeferredTroubles();
770
+ }
771
+ if (this._agitationFutureId) {
772
+ this.logger.info(`AgitationControl - Agitation started`);
773
+ }
606
774
  }
607
775
  async load() {
608
776
  this.logger.debug(`loading agitation-control ${this.id}`);
609
777
  }
610
778
  };
611
- I([
612
- p({ modelType: Ze.type })
613
- ], $.prototype, "application", 2);
614
- I([
615
- M({ alias: Fe })
616
- ], $.prototype, "resolveDeferredTroubles", 1);
617
- I([
618
- Te({ topic: vt.TOPIC_AGITATION_STARTED })
619
- ], $.prototype, "handleAgitationStarted", 1);
620
- I([
621
- Te({ topic: vt.TOPIC_AGITATION_ENDED })
622
- ], $.prototype, "handleAgitationEnded", 1);
623
- I([
624
- Pe({
625
- dependencies: (e) => [e.readyToResolve, e._agitationFutureId]
779
+ __decorateClass$k([
780
+ kosDependency({ modelType: Application.type })
781
+ ], AgitationControlModelImpl.prototype, "application", 2);
782
+ __decorateClass$k([
783
+ kosFuture({ alias: FUTURE_RESOLVE })
784
+ ], AgitationControlModelImpl.prototype, "resolveDeferredTroubles", 1);
785
+ __decorateClass$k([
786
+ kosTopicHandler({ topic: CartridgeAgitatorEvents.TOPIC_AGITATION_STARTED })
787
+ ], AgitationControlModelImpl.prototype, "handleAgitationStarted", 1);
788
+ __decorateClass$k([
789
+ kosTopicHandler({ topic: CartridgeAgitatorEvents.TOPIC_AGITATION_ENDED })
790
+ ], AgitationControlModelImpl.prototype, "handleAgitationEnded", 1);
791
+ __decorateClass$k([
792
+ kosModelEffect({
793
+ dependencies: (model) => [model.readyToResolve, model._agitationFutureId]
626
794
  })
627
- ], $.prototype, "handleReadyToResolve", 1);
628
- $ = I([
629
- l(kt)
630
- ], $);
631
- const Ys = new He({
632
- class: $,
633
- type: kt
795
+ ], AgitationControlModelImpl.prototype, "handleReadyToResolve", 1);
796
+ AgitationControlModelImpl = __decorateClass$k([
797
+ kosModel(MODEL_TYPE$k)
798
+ ], AgitationControlModelImpl);
799
+ const AgitationControl = new SingletonKosModelRegistrationFactory({
800
+ class: AgitationControlModelImpl,
801
+ type: MODEL_TYPE$k
634
802
  });
635
- var or = Object.defineProperty, rr = Object.getOwnPropertyDescriptor, le = (e, t, o, s) => {
636
- for (var r = s > 1 ? void 0 : s ? rr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
637
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
638
- return s && r && or(t, o, r), r;
639
- };
640
- const N = "animation-model";
641
- let w = class {
642
- constructor(e, t, o) {
643
- i(this, "id");
644
- i(this, "logger");
645
- i(this, "disableAll");
646
- i(this, "enableDial");
647
- i(this, "enableModal");
648
- i(this, "enableSideBar");
649
- this.id = e, this.logger = o.logger;
650
- }
651
- };
652
- le([
653
- d({
803
+ var __defProp$e = Object.defineProperty;
804
+ var __getOwnPropDesc$j = Object.getOwnPropertyDescriptor;
805
+ var __decorateClass$j = (decorators, target, key, kind) => {
806
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target;
807
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
808
+ if (decorator = decorators[i])
809
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
810
+ if (kind && result) __defProp$e(target, key, result);
811
+ return result;
812
+ };
813
+ const MODEL_TYPE$j = "animation-model";
814
+ let AnimationModelImpl = class {
815
+ id;
816
+ logger;
817
+ disableAll;
818
+ enableDial;
819
+ enableModal;
820
+ enableSideBar;
821
+ constructor(modelId, options, context) {
822
+ this.id = modelId;
823
+ this.logger = context.logger;
824
+ }
825
+ };
826
+ __decorateClass$j([
827
+ kosConfigProperty({
654
828
  path: "app:kosdev.ddk:app",
655
829
  attribute: "ncui.uiConfig.animations.disableAll"
656
830
  })
657
- ], w.prototype, "disableAll", 2);
658
- le([
659
- d({
831
+ ], AnimationModelImpl.prototype, "disableAll", 2);
832
+ __decorateClass$j([
833
+ kosConfigProperty({
660
834
  path: "app:kosdev.ddk:app",
661
835
  attribute: "ncui.uiConfig.animations.enableDial"
662
836
  })
663
- ], w.prototype, "enableDial", 2);
664
- le([
665
- d({
837
+ ], AnimationModelImpl.prototype, "enableDial", 2);
838
+ __decorateClass$j([
839
+ kosConfigProperty({
666
840
  path: "app:kosdev.ddk:app",
667
841
  attribute: "ncui.uiConfig.animations.enableModal"
668
842
  })
669
- ], w.prototype, "enableModal", 2);
670
- le([
671
- d({
843
+ ], AnimationModelImpl.prototype, "enableModal", 2);
844
+ __decorateClass$j([
845
+ kosConfigProperty({
672
846
  path: "app:kosdev.ddk:app",
673
847
  attribute: "ncui.uiConfig.animations.enableSideBar"
674
848
  })
675
- ], w.prototype, "enableSideBar", 2);
676
- w = le([
677
- l(N)
678
- ], w);
679
- const sr = {
849
+ ], AnimationModelImpl.prototype, "enableSideBar", 2);
850
+ AnimationModelImpl = __decorateClass$j([
851
+ kosModel(MODEL_TYPE$j)
852
+ ], AnimationModelImpl);
853
+ const Animation = {
680
854
  registration: {
681
- [N]: {
682
- class: w,
683
- singleton: !0
855
+ [MODEL_TYPE$j]: {
856
+ class: AnimationModelImpl,
857
+ singleton: true
684
858
  }
685
859
  },
686
- type: N,
687
- predicate: u(N),
688
- factory: c.Singleton.create(N)
689
- }, { URL: ir } = h("ANIMATION_SERVICE"), { getAll: nr } = y.build({
690
- basePath: `${ir}/api/animation`
691
- }), ar = g.createLogger({
860
+ type: MODEL_TYPE$j,
861
+ predicate: isKosModel(MODEL_TYPE$j),
862
+ factory: Kos.Singleton.create(MODEL_TYPE$j)
863
+ };
864
+ const { URL: URL$a } = resolveServiceUrl("ANIMATION_SERVICE");
865
+ const { getAll: getAll$7 } = ServiceFactory.build({
866
+ basePath: `${URL$a}/api/animation`
867
+ });
868
+ const log$b = KosLog.createLogger({
692
869
  name: "animation-service",
693
870
  group: "Services"
694
- }), lr = async () => (ar.debug("sending GET for animation"), await nr({})), Gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
871
+ });
872
+ const getAnimations = async () => {
873
+ log$b.debug("sending GET for animation");
874
+ const response = await getAll$7({});
875
+ return response;
876
+ };
877
+ const index$b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
695
878
  __proto__: null,
696
- getAnimations: lr
879
+ getAnimations
697
880
  }, Symbol.toStringTag, { value: "Module" }));
698
- var dr = Object.defineProperty, cr = Object.getOwnPropertyDescriptor, It = (e, t, o, s) => {
699
- for (var r = s > 1 ? void 0 : s ? cr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
700
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
701
- return s && r && dr(t, o, r), r;
702
- };
703
- const z = "carb-water-model";
704
- let ye = class {
705
- constructor(e, t, o) {
706
- i(this, "id");
707
- i(this, "assemblyModel");
708
- i(this, "logger");
709
- this.id = e, this.logger = o.logger;
881
+ var __defProp$d = Object.defineProperty;
882
+ var __getOwnPropDesc$i = Object.getOwnPropertyDescriptor;
883
+ var __decorateClass$i = (decorators, target, key, kind) => {
884
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target;
885
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
886
+ if (decorator = decorators[i])
887
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
888
+ if (kind && result) __defProp$d(target, key, result);
889
+ return result;
890
+ };
891
+ const MODEL_TYPE$i = "carb-water-model";
892
+ let CarbWaterModelImpl = class {
893
+ id;
894
+ assemblyModel;
895
+ logger;
896
+ constructor(modelId, _options, context) {
897
+ this.id = modelId;
898
+ this.logger = context.logger;
710
899
  }
711
900
  getPump() {
712
- const t = this.assemblyModel.getHoldersByGroup("carb")[0].pumps.data[0];
713
- return Be(t, mt.type);
901
+ const carbHolder = this.assemblyModel.getHoldersByGroup("carb")[0];
902
+ const pump = carbHolder.pumps.data[0];
903
+ const model = getKosCompanionModel(pump, FcmPump.type);
904
+ return model;
714
905
  }
715
906
  // -------------------LIFECYCLE----------------------------
716
907
  async init() {
@@ -720,102 +911,128 @@ let ye = class {
720
911
  this.logger.debug(`loading carb-water ${this.id}`);
721
912
  }
722
913
  };
723
- It([
724
- p({ modelType: Se.type })
725
- ], ye.prototype, "assemblyModel", 2);
726
- ye = It([
727
- l(z)
728
- ], ye);
729
- const ur = {
914
+ __decorateClass$i([
915
+ kosDependency({ modelType: Assembly.type })
916
+ ], CarbWaterModelImpl.prototype, "assemblyModel", 2);
917
+ CarbWaterModelImpl = __decorateClass$i([
918
+ kosModel(MODEL_TYPE$i)
919
+ ], CarbWaterModelImpl);
920
+ const CarbWater = {
730
921
  registration: {
731
- [z]: {
732
- class: ye,
733
- singleton: !1
922
+ [MODEL_TYPE$i]: {
923
+ class: CarbWaterModelImpl,
924
+ singleton: false
734
925
  }
735
926
  },
736
- type: z,
737
- predicate: u(z),
738
- factory: c.Factory.create(z)
739
- }, { URL: R } = h("COPY-LOGS_SERVICE"), { getAll: pr, getOne: gr, postModel: Rt, deleteModel: hr } = y.build({
740
- basePath: `${R}/api/copy-logs`
741
- }), fe = g.createLogger({
927
+ type: MODEL_TYPE$i,
928
+ predicate: isKosModel(MODEL_TYPE$i),
929
+ factory: Kos.Factory.create(MODEL_TYPE$i)
930
+ };
931
+ const { URL: URL$9 } = resolveServiceUrl("COPY-LOGS_SERVICE");
932
+ const { getAll: getAll$6, getOne: getOne$2, postModel: postModel$2, deleteModel } = ServiceFactory.build({
933
+ basePath: `${URL$9}/api/copy-logs`
934
+ });
935
+ const log$a = KosLog.createLogger({
742
936
  name: "copy-logs-service",
743
937
  group: "Services"
744
- }), At = async (e, t) => {
745
- const o = await hr({
746
- tracker: t,
747
- id: e,
748
- urlOverride: `${R}/api/app/kosdev.ddk/copyLogs/${e}`
938
+ });
939
+ const eraseVolume = async (volumeId, tracker) => {
940
+ const response = await deleteModel({
941
+ tracker,
942
+ id: volumeId,
943
+ urlOverride: `${URL$9}/api/app/kosdev.ddk/copyLogs/${volumeId}`
749
944
  });
750
- if (!(o != null && o.data))
945
+ if (!response?.data) {
751
946
  throw new Error("No response from server");
752
- return o.data;
753
- }, Ft = async (e, t) => {
754
- const o = await Rt({
947
+ }
948
+ return response.data;
949
+ };
950
+ const eraseAndCopyLogsToVolume = async (volumeId, tracker) => {
951
+ const response = await postModel$2({
755
952
  model: {},
756
- tracker: t,
757
- urlOverride: `${R}/api/app/kosdev.ddk/copyLogs/eraseAndCopy/${e}`
953
+ tracker,
954
+ urlOverride: `${URL$9}/api/app/kosdev.ddk/copyLogs/eraseAndCopy/${volumeId}`
758
955
  });
759
- if (!(o != null && o.data))
956
+ if (!response?.data) {
760
957
  throw new Error("No response from server");
761
- return o.data;
762
- }, xt = async (e, t) => {
763
- const o = await Rt({
958
+ }
959
+ return response.data;
960
+ };
961
+ const copyLogFromVolume = async (volumeId, tracker) => {
962
+ const response = await postModel$2({
764
963
  model: {},
765
- tracker: t,
766
- urlOverride: `${R}/api/app/kosdev.ddk/copyLogs/${e}`
964
+ tracker,
965
+ urlOverride: `${URL$9}/api/app/kosdev.ddk/copyLogs/${volumeId}`
767
966
  });
768
- if (!(o != null && o.data))
967
+ if (!response?.data) {
769
968
  throw new Error("No response from server");
770
- return o.data;
771
- }, Ut = async () => {
772
- fe.debug("sending GET for copy-logs");
969
+ }
970
+ return response.data;
971
+ };
972
+ const getVolumes = async () => {
973
+ log$a.debug("sending GET for copy-logs");
773
974
  try {
774
- const e = await pr({
775
- urlOverride: `${R}/api/app/kosdev.ddk/copyLogs/volumes/size`
975
+ const response = await getAll$6({
976
+ urlOverride: `${URL$9}/api/app/kosdev.ddk/copyLogs/volumes/size`
776
977
  });
777
- return [void 0, e == null ? void 0 : e.data];
778
- } catch (e) {
779
- if (e instanceof yt)
780
- return fe.error(`Error fetching log file size: ${e.payload.error}`), [e.payload.error, void 0];
978
+ return [void 0, response?.data];
979
+ } catch (error) {
980
+ if (error instanceof FetchError) {
981
+ log$a.error(`Error fetching log file size: ${error.payload.error}`);
982
+ return [error.payload.error, void 0];
983
+ }
781
984
  }
782
985
  return ["unknownError", void 0];
783
- }, jt = async () => {
784
- fe.debug("sending GET for log file size");
986
+ };
987
+ const getLogFileSize = async () => {
988
+ log$a.debug("sending GET for log file size");
785
989
  try {
786
- const e = await gr({
787
- urlOverride: `${R}/api/app/kosdev.ddk/copyLogs/files/size`
990
+ const response = await getOne$2({
991
+ urlOverride: `${URL$9}/api/app/kosdev.ddk/copyLogs/files/size`
788
992
  });
789
- return [void 0, e == null ? void 0 : e.data];
790
- } catch (e) {
791
- if (e instanceof yt)
792
- return fe.error(`Error fetching log file size: ${e.payload.error}`), [e.payload.error, void 0];
993
+ return [void 0, response?.data];
994
+ } catch (error) {
995
+ if (error instanceof FetchError) {
996
+ log$a.error(`Error fetching log file size: ${error.payload.error}`);
997
+ return [error.payload.error, void 0];
998
+ }
793
999
  }
794
1000
  return ["unknownError", void 0];
795
- }, qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1001
+ };
1002
+ const index$a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
796
1003
  __proto__: null,
797
- copyLogFromVolume: xt,
798
- eraseAndCopyLogsToVolume: Ft,
799
- eraseVolume: At,
800
- getLogFileSize: jt,
801
- getVolumes: Ut
1004
+ copyLogFromVolume,
1005
+ eraseAndCopyLogsToVolume,
1006
+ eraseVolume,
1007
+ getLogFileSize,
1008
+ getVolumes
802
1009
  }, Symbol.toStringTag, { value: "Module" }));
803
- var Wt = Object.defineProperty, yr = Object.getOwnPropertyDescriptor, fr = (e, t, o) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, A = (e, t, o, s) => {
804
- for (var r = s > 1 ? void 0 : s ? yr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
805
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
806
- return s && r && Wt(t, o, r), r;
807
- }, vr = (e, t, o) => (fr(e, t + "", o), o);
808
- const mr = "copy-logs-model";
809
- let _ = class {
810
- constructor(e) {
811
- i(this, "id");
812
- i(this, "_volumes");
813
- i(this, "storageDeviceContainer");
814
- i(this, "_activeVolume");
815
- i(this, "_logFileSize", 0);
816
- i(this, "_actionState", "idle");
817
- i(this, "copyProgress");
818
- this.id = e, this._volumes = new Po(), this._activeVolume = void 0, this.copyProgress = {
1010
+ var __defProp$c = Object.defineProperty;
1011
+ var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
1012
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1013
+ var __decorateClass$h = (decorators, target, key, kind) => {
1014
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target;
1015
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1016
+ if (decorator = decorators[i])
1017
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1018
+ if (kind && result) __defProp$c(target, key, result);
1019
+ return result;
1020
+ };
1021
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "", value);
1022
+ const MODEL_TYPE$h = "copy-logs-model";
1023
+ let CopyLogsModelImpl = class {
1024
+ id;
1025
+ _volumes;
1026
+ storageDeviceContainer;
1027
+ _activeVolume;
1028
+ _logFileSize = 0;
1029
+ _actionState = "idle";
1030
+ copyProgress;
1031
+ constructor(modelId) {
1032
+ this.id = modelId;
1033
+ this._volumes = new KosDataContainer();
1034
+ this._activeVolume = void 0;
1035
+ this.copyProgress = {
819
1036
  bytesCopied: 0,
820
1037
  bytesToCopy: 0,
821
1038
  filesCopied: 0,
@@ -833,19 +1050,20 @@ let _ = class {
833
1050
  return this._logFileSize;
834
1051
  }
835
1052
  reset() {
836
- this.clearActiveVolume(), this.futureHandler.removeFuture();
1053
+ this.clearActiveVolume();
1054
+ this.futureHandler.removeFuture();
837
1055
  }
838
1056
  clearActiveVolume() {
839
1057
  this._activeVolume = void 0;
840
1058
  }
841
- updateActiveVolume(e) {
842
- this._activeVolume = e;
1059
+ updateActiveVolume(volume) {
1060
+ this._activeVolume = volume;
843
1061
  }
844
1062
  get inserted() {
845
1063
  return this.storageDeviceContainer.isStorageInserted;
846
1064
  }
847
- updateLogFileSize(e) {
848
- this._logFileSize = e;
1065
+ updateLogFileSize(size) {
1066
+ this._logFileSize = size;
849
1067
  }
850
1068
  get canCopyLogs() {
851
1069
  return this.inserted && this._activeVolume;
@@ -854,170 +1072,235 @@ let _ = class {
854
1072
  return this._actionState;
855
1073
  }
856
1074
  get diskFull() {
857
- var e;
858
- return ((e = this.future) == null ? void 0 : e.status) === T.Success && this.copyProgress.filesSkipped > 0;
859
- }
860
- onFutureUpdate(e) {
861
- this.logger.info(`Future update: ${e.status}`), e.status === T.Success && (this.logger.info(`Future success: ${e.status}`), this.diskFull && v(() => {
862
- e.endState = T.Fail, e.reason = "errDiskFull";
863
- })), e.status === T.Fail && this.logger.error(`Future failed: ${e.status}`), e.note === "copy" ? v(() => {
864
- this._actionState = "copying", this.copyProgress = e.clientData || {
865
- bytesCopied: 0,
866
- bytesToCopy: 0,
867
- filesCopied: 0,
868
- filesSkipped: 0
869
- };
870
- }) : (this._actionState = "erasing", v(() => {
871
- this.copyProgress = {
872
- bytesCopied: 0,
873
- bytesToCopy: 0,
874
- filesCopied: 0,
875
- filesSkipped: 0
876
- };
877
- }));
1075
+ return this.future?.status === FutureEndState.Success && this.copyProgress.filesSkipped > 0;
1076
+ }
1077
+ onFutureUpdate(update) {
1078
+ this.logger.info(`Future update: ${update.status}`);
1079
+ if (update.status === FutureEndState.Success) {
1080
+ this.logger.info(`Future success: ${update.status}`);
1081
+ if (this.diskFull) {
1082
+ kosAction(() => {
1083
+ update.endState = FutureEndState.Fail;
1084
+ update.reason = "errDiskFull";
1085
+ });
1086
+ }
1087
+ }
1088
+ if (update.status === FutureEndState.Fail) {
1089
+ this.logger.error(`Future failed: ${update.status}`);
1090
+ }
1091
+ if (update.note === "copy") {
1092
+ kosAction(() => {
1093
+ this._actionState = "copying";
1094
+ this.copyProgress = update.clientData || {
1095
+ bytesCopied: 0,
1096
+ bytesToCopy: 0,
1097
+ filesCopied: 0,
1098
+ filesSkipped: 0
1099
+ };
1100
+ });
1101
+ } else {
1102
+ this._actionState = "erasing";
1103
+ kosAction(() => {
1104
+ this.copyProgress = {
1105
+ bytesCopied: 0,
1106
+ bytesToCopy: 0,
1107
+ filesCopied: 0,
1108
+ filesSkipped: 0
1109
+ };
1110
+ });
1111
+ }
878
1112
  }
879
- async eraseAndCopyVolume(e) {
880
- var t;
881
- if (!e)
1113
+ async eraseAndCopyVolume(tracker) {
1114
+ if (!tracker) {
882
1115
  throw new Error("No tracker provided");
883
- if (v(() => {
1116
+ }
1117
+ kosAction(() => {
884
1118
  this._actionState = "erasing";
885
- }), !this._activeVolume)
886
- throw this.logger.error("No active volume selected"), new Error("No active volume selected");
887
- return this.logger.info(`Erasing volume ${(t = this._activeVolume) == null ? void 0 : t.name}`), Ft(this._activeVolume.id, e);
1119
+ });
1120
+ if (!this._activeVolume) {
1121
+ this.logger.error("No active volume selected");
1122
+ throw new Error("No active volume selected");
1123
+ }
1124
+ this.logger.info(`Erasing volume ${this._activeVolume?.name}`);
1125
+ return eraseAndCopyLogsToVolume(this._activeVolume.id, tracker);
888
1126
  }
889
- async eraseVolume(e) {
890
- var t;
891
- if (!e)
1127
+ async eraseVolume(tracker) {
1128
+ if (!tracker) {
892
1129
  throw new Error("No tracker provided");
893
- if (v(() => {
1130
+ }
1131
+ kosAction(() => {
894
1132
  this._actionState = "erasing";
895
- }), !this._activeVolume)
896
- throw this.logger.error("No active volume selected"), new Error("No active volume selected");
897
- return this.logger.info(`Erasing volume ${(t = this._activeVolume) == null ? void 0 : t.name}`), At(this._activeVolume.id, e);
1133
+ });
1134
+ if (!this._activeVolume) {
1135
+ this.logger.error("No active volume selected");
1136
+ throw new Error("No active volume selected");
1137
+ }
1138
+ this.logger.info(`Erasing volume ${this._activeVolume?.name}`);
1139
+ return eraseVolume(this._activeVolume.id, tracker);
898
1140
  }
899
- async copyLogs(e) {
900
- var t;
901
- if (!e)
1141
+ async copyLogs(tracker) {
1142
+ if (!tracker) {
902
1143
  throw new Error("No tracker provided");
903
- if (v(() => {
1144
+ }
1145
+ kosAction(() => {
904
1146
  this._actionState = "copying";
905
- }), !this._activeVolume)
906
- throw this.logger.error("No active volume selected"), new Error("No active volume selected");
907
- return this.logger.info(`Copying logs to ${(t = this._activeVolume) == null ? void 0 : t.name}`), xt(this._activeVolume.id, e);
1147
+ });
1148
+ if (!this._activeVolume) {
1149
+ this.logger.error("No active volume selected");
1150
+ throw new Error("No active volume selected");
1151
+ }
1152
+ this.logger.info(`Copying logs to ${this._activeVolume?.name}`);
1153
+ return copyLogFromVolume(this._activeVolume.id, tracker);
908
1154
  }
909
1155
  handleInsertion() {
910
- this.inserted ? this.syncVolumes() : (this._volumes.clear(), this.clearActiveVolume());
1156
+ if (this.inserted) {
1157
+ this.syncVolumes();
1158
+ } else {
1159
+ this._volumes.clear();
1160
+ this.clearActiveVolume();
1161
+ }
911
1162
  }
912
1163
  async init() {
913
1164
  this.logger.debug(`initializing copy-logs ${this.id}`);
914
1165
  }
915
1166
  async syncVolumes() {
916
- const [e, t] = await Ut(), [o, s] = await jt();
917
- if (o) {
918
- this.logger.error(`Error fetching log file size: ${o}`);
1167
+ const [volumeError, volumes] = await getVolumes();
1168
+ const [error, logSize] = await getLogFileSize();
1169
+ if (error) {
1170
+ this.logger.error(`Error fetching log file size: ${error}`);
919
1171
  return;
920
1172
  }
921
- if (e) {
922
- this.logger.error(`Error fetching volumes: ${e}`);
1173
+ if (volumeError) {
1174
+ this.logger.error(`Error fetching volumes: ${volumeError}`);
923
1175
  return;
924
1176
  }
925
- t && (t.forEach((r) => {
926
- const n = this.storageDeviceContainer.getModel(r.id);
927
- if (n) {
928
- const a = {
929
- id: r.id,
930
- name: n.label,
931
- freeBytes: r.info.freeBytes,
932
- totalBytes: r.info.totalBytes
933
- };
934
- this._volumes.addModel(a);
1177
+ if (volumes) {
1178
+ volumes.forEach((volume) => {
1179
+ const storageVolume = this.storageDeviceContainer.getModel(volume.id);
1180
+ if (storageVolume) {
1181
+ const _volume = {
1182
+ id: volume.id,
1183
+ name: storageVolume.label,
1184
+ freeBytes: volume.info.freeBytes,
1185
+ totalBytes: volume.info.totalBytes
1186
+ };
1187
+ this._volumes.addModel(_volume);
1188
+ }
1189
+ });
1190
+ if (volumes.length === 1) {
1191
+ this.updateActiveVolume(this._volumes.data[0]);
1192
+ } else {
1193
+ this.clearActiveVolume();
935
1194
  }
936
- }), t.length === 1 ? this.updateActiveVolume(this._volumes.data[0]) : this.clearActiveVolume()), s && (this.logger.info(`Log file size: ${s}`), this.updateLogFileSize(parseInt(s, 10)));
1195
+ }
1196
+ if (logSize) {
1197
+ this.logger.info(`Log file size: ${logSize}`);
1198
+ this.updateLogFileSize(parseInt(logSize, 10));
1199
+ }
937
1200
  }
938
1201
  async activate() {
939
- this.logger.debug(`activating copy-logs ${this.id}`), await this.syncVolumes();
1202
+ this.logger.debug(`activating copy-logs ${this.id}`);
1203
+ await this.syncVolumes();
940
1204
  }
941
1205
  async load() {
942
1206
  this.logger.debug(`loading copy-logs ${this.id}`);
943
1207
  }
944
1208
  };
945
- vr(_, "Registration");
946
- A([
947
- p({ modelType: To.type })
948
- ], _.prototype, "storageDeviceContainer", 2);
949
- A([
950
- M()
951
- ], _.prototype, "eraseAndCopyVolume", 1);
952
- A([
953
- M()
954
- ], _.prototype, "eraseVolume", 1);
955
- A([
956
- M()
957
- ], _.prototype, "copyLogs", 1);
958
- A([
959
- Pe({
960
- dependencies: (e) => [e.inserted]
1209
+ __publicField$1(CopyLogsModelImpl, "Registration");
1210
+ __decorateClass$h([
1211
+ kosDependency({ modelType: StorageDeviceContainer.type })
1212
+ ], CopyLogsModelImpl.prototype, "storageDeviceContainer", 2);
1213
+ __decorateClass$h([
1214
+ kosFuture()
1215
+ ], CopyLogsModelImpl.prototype, "eraseAndCopyVolume", 1);
1216
+ __decorateClass$h([
1217
+ kosFuture()
1218
+ ], CopyLogsModelImpl.prototype, "eraseVolume", 1);
1219
+ __decorateClass$h([
1220
+ kosFuture()
1221
+ ], CopyLogsModelImpl.prototype, "copyLogs", 1);
1222
+ __decorateClass$h([
1223
+ kosModelEffect({
1224
+ dependencies: (model) => [model.inserted]
961
1225
  })
962
- ], _.prototype, "handleInsertion", 1);
963
- _ = A([
964
- l({ modelTypeId: mr, singleton: !0 }),
965
- $o(),
966
- Ke()
967
- ], _);
968
- const Qs = _.Registration, Nt = g.createLogger({
1226
+ ], CopyLogsModelImpl.prototype, "handleInsertion", 1);
1227
+ CopyLogsModelImpl = __decorateClass$h([
1228
+ kosModel({ modelTypeId: MODEL_TYPE$h, singleton: true }),
1229
+ kosFutureAware(),
1230
+ kosLoggerAware()
1231
+ ], CopyLogsModelImpl);
1232
+ const CopyLogs = CopyLogsModelImpl.Registration;
1233
+ const log$9 = KosLog.createLogger({
969
1234
  name: "dashboard-operations-service",
970
1235
  group: "Services"
971
- }), zt = async (e, t) => (Nt.debug("resolveAll"), await Me.bulkResolveTroubles(
972
- e,
973
- void 0,
974
- t
975
- )), Vt = async (e, t) => (Nt.debug("resolveTrouble"), await Me.resolveTrouble(
976
- e,
977
- void 0,
978
- t
979
- )), Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1236
+ });
1237
+ const resolveAll = async (troubleIds, tracker) => {
1238
+ log$9.debug("resolveAll");
1239
+ const response = await TroubleServices.bulkResolveTroubles(
1240
+ troubleIds,
1241
+ void 0,
1242
+ tracker
1243
+ );
1244
+ return response;
1245
+ };
1246
+ const resolveTrouble = async (troubleId, tracker) => {
1247
+ log$9.debug("resolveTrouble");
1248
+ const response = await TroubleServices.resolveTrouble(
1249
+ troubleId,
1250
+ void 0,
1251
+ tracker
1252
+ );
1253
+ return response;
1254
+ };
1255
+ const index$9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
980
1256
  __proto__: null,
981
- resolveAll: zt,
982
- resolveTrouble: Vt
1257
+ resolveAll,
1258
+ resolveTrouble
983
1259
  }, Symbol.toStringTag, { value: "Module" }));
984
- var br = Object.defineProperty, _r = Object.getOwnPropertyDescriptor, Ee = (e, t, o, s) => {
985
- for (var r = s > 1 ? void 0 : s ? _r(t, o) : t, n = e.length - 1, a; n >= 0; n--)
986
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
987
- return s && r && br(t, o, r), r;
988
- };
989
- const V = "dashboard-operations-model";
990
- function ut(e) {
991
- return !e.deferred;
1260
+ var __defProp$b = Object.defineProperty;
1261
+ var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
1262
+ var __decorateClass$g = (decorators, target, key, kind) => {
1263
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target;
1264
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1265
+ if (decorator = decorators[i])
1266
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1267
+ if (kind && result) __defProp$b(target, key, result);
1268
+ return result;
1269
+ };
1270
+ const MODEL_TYPE$g = "dashboard-operations-model";
1271
+ function resolvableTroubleFilter(trouble) {
1272
+ return !trouble.deferred;
992
1273
  }
993
- function pt(e) {
994
- return e.deferred;
1274
+ function deferredTroubleFilter(trouble) {
1275
+ return trouble.deferred;
995
1276
  }
996
- let C = class {
997
- constructor(e, t, o) {
998
- i(this, "id");
999
- i(this, "troubles");
1000
- i(this, "futureHandler");
1001
- i(this, "logger");
1002
- this.id = e, this.futureHandler = new Ge(this), this.logger = o.logger;
1277
+ let DashboardOperationsModelImpl = class {
1278
+ id;
1279
+ troubles;
1280
+ futureHandler;
1281
+ logger;
1282
+ constructor(modelId, options, context) {
1283
+ this.id = modelId;
1284
+ this.futureHandler = new FutureHandler(this);
1285
+ this.logger = context.logger;
1003
1286
  }
1004
1287
  get troublesByType() {
1005
1288
  return this.troubles.troubles.data.reduce(
1006
- Mo,
1289
+ troubleByTypeReducer,
1007
1290
  {}
1008
1291
  );
1009
1292
  }
1010
1293
  get queuedPurgeTroubles() {
1011
- return this.purgeTroubles.filter(pt);
1294
+ return this.purgeTroubles.filter(deferredTroubleFilter);
1012
1295
  }
1013
1296
  get queuedPrimeTroubles() {
1014
- return this.primeTroubles.filter(pt);
1297
+ return this.primeTroubles.filter(deferredTroubleFilter);
1015
1298
  }
1016
1299
  get resolvablePrimeTroubles() {
1017
- return this.primeTroubles.filter(ut);
1300
+ return this.primeTroubles.filter(resolvableTroubleFilter);
1018
1301
  }
1019
1302
  get resolvablePurgeTroubles() {
1020
- return this.purgeTroubles.filter(ut);
1303
+ return this.purgeTroubles.filter(resolvableTroubleFilter);
1021
1304
  }
1022
1305
  get hasResolvablePurgeTroubles() {
1023
1306
  return this.resolvablePurgeTroubles.length > 0;
@@ -1032,28 +1315,37 @@ let C = class {
1032
1315
  return this.primeTroubles.length > 0;
1033
1316
  }
1034
1317
  get purgeTroubles() {
1035
- return this.troublesByType[at] || [];
1318
+ return this.troublesByType[TROUBLE_TYPE_PURGE$1] || [];
1036
1319
  }
1037
1320
  get primeTroubles() {
1038
- return this.troublesByType[ko] || [];
1321
+ return this.troublesByType[TROUBLE_TYPE_PRIME$1] || [];
1039
1322
  }
1040
1323
  get future() {
1041
1324
  return this.futureHandler.getFuture();
1042
1325
  }
1043
- async resolveAllTroubles(e, t) {
1044
- if (!t)
1326
+ async resolveAllTroubles(type, tracker) {
1327
+ if (!tracker) {
1045
1328
  throw new Error("No tracker provided");
1046
- const o = e === at ? this.purgeTroubles : this.primeTroubles;
1047
- o.filter((a) => a.shouldDefer).forEach((a) => {
1048
- this.logger.info(`Deferring trouble ${a.rawId}`), a.defer();
1329
+ }
1330
+ const container = type === TROUBLE_TYPE_PURGE$1 ? this.purgeTroubles : this.primeTroubles;
1331
+ const shouldDefer = container.filter((trouble) => trouble.shouldDefer);
1332
+ shouldDefer.forEach((trouble) => {
1333
+ this.logger.info(`Deferring trouble ${trouble.rawId}`);
1334
+ trouble.defer();
1049
1335
  });
1050
- const r = o.filter((a) => !a.shouldDefer).map((a) => a.rawId);
1051
- return r.length === 0 ? void 0 : await zt(r, t);
1336
+ const allTroubles = container.filter((trouble) => !trouble.shouldDefer).map((trouble) => trouble.rawId);
1337
+ if (allTroubles.length === 0) {
1338
+ return void 0;
1339
+ }
1340
+ const response = await resolveAll(allTroubles, tracker);
1341
+ return response;
1052
1342
  }
1053
- async resolveTrouble(e, t) {
1054
- if (!t)
1343
+ async resolveTrouble(troubleId, tracker) {
1344
+ if (!tracker) {
1055
1345
  throw new Error("No tracker provided");
1056
- return await Vt(e, t);
1346
+ }
1347
+ const response = await resolveTrouble(troubleId, tracker);
1348
+ return response;
1057
1349
  }
1058
1350
  // -------------------LIFECYCLE----------------------------
1059
1351
  async init() {
@@ -1063,42 +1355,46 @@ let C = class {
1063
1355
  this.logger.debug(`loading dashboard-operations ${this.id}`);
1064
1356
  }
1065
1357
  };
1066
- Ee([
1067
- p({
1068
- modelType: Ye.type
1358
+ __decorateClass$g([
1359
+ kosDependency({
1360
+ modelType: TroubleContainer.type
1069
1361
  })
1070
- ], C.prototype, "troubles", 2);
1071
- Ee([
1072
- M()
1073
- ], C.prototype, "resolveAllTroubles", 1);
1074
- Ee([
1075
- M()
1076
- ], C.prototype, "resolveTrouble", 1);
1077
- C = Ee([
1078
- l(V)
1079
- ], C);
1080
- const et = {
1362
+ ], DashboardOperationsModelImpl.prototype, "troubles", 2);
1363
+ __decorateClass$g([
1364
+ kosFuture()
1365
+ ], DashboardOperationsModelImpl.prototype, "resolveAllTroubles", 1);
1366
+ __decorateClass$g([
1367
+ kosFuture()
1368
+ ], DashboardOperationsModelImpl.prototype, "resolveTrouble", 1);
1369
+ DashboardOperationsModelImpl = __decorateClass$g([
1370
+ kosModel(MODEL_TYPE$g)
1371
+ ], DashboardOperationsModelImpl);
1372
+ const DashboardOperations = {
1081
1373
  registration: {
1082
- [V]: {
1083
- class: C,
1084
- singleton: !0
1374
+ [MODEL_TYPE$g]: {
1375
+ class: DashboardOperationsModelImpl,
1376
+ singleton: true
1085
1377
  }
1086
1378
  },
1087
- type: V,
1088
- predicate: u(V),
1089
- factory: c.Singleton.create(V)
1090
- };
1091
- var Tr = Object.getOwnPropertyDescriptor, $r = (e, t, o, s) => {
1092
- for (var r = s > 1 ? void 0 : s ? Tr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1093
- (a = e[n]) && (r = a(r) || r);
1094
- return r;
1095
- };
1096
- const H = "dispenser-model";
1097
- let xe = class {
1098
- constructor(e, t, o) {
1099
- i(this, "id");
1100
- i(this, "logger");
1101
- this.id = e, this.logger = o.logger;
1379
+ type: MODEL_TYPE$g,
1380
+ predicate: isKosModel(MODEL_TYPE$g),
1381
+ factory: Kos.Singleton.create(MODEL_TYPE$g)
1382
+ };
1383
+ var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
1384
+ var __decorateClass$f = (decorators, target, key, kind) => {
1385
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
1386
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1387
+ if (decorator = decorators[i])
1388
+ result = decorator(result) || result;
1389
+ return result;
1390
+ };
1391
+ const MODEL_TYPE$f = "dispenser-model";
1392
+ let DispenserModelImpl = class {
1393
+ id;
1394
+ logger;
1395
+ constructor(modelId, options, context) {
1396
+ this.id = modelId;
1397
+ this.logger = context.logger;
1102
1398
  }
1103
1399
  updateModel() {
1104
1400
  }
@@ -1110,40 +1406,55 @@ let xe = class {
1110
1406
  this.logger.debug(`loading dispenser ${this.id}`);
1111
1407
  }
1112
1408
  };
1113
- xe = $r([
1114
- l(H)
1115
- ], xe);
1116
- const Pr = {
1409
+ DispenserModelImpl = __decorateClass$f([
1410
+ kosModel(MODEL_TYPE$f)
1411
+ ], DispenserModelImpl);
1412
+ const Dispenser = {
1117
1413
  registration: {
1118
- [H]: {
1119
- class: xe,
1120
- singleton: !0
1414
+ [MODEL_TYPE$f]: {
1415
+ class: DispenserModelImpl,
1416
+ singleton: true
1121
1417
  }
1122
1418
  },
1123
- type: H,
1124
- predicate: u(H),
1125
- factory: c.Singleton.create(H)
1126
- }, { URL: Mr } = h("DISPENSER_SERVICE"), { getAll: Or } = y.build({
1127
- basePath: `${Mr}/api/dispenser`
1128
- }), Sr = g.createLogger({
1419
+ type: MODEL_TYPE$f,
1420
+ predicate: isKosModel(MODEL_TYPE$f),
1421
+ factory: Kos.Singleton.create(MODEL_TYPE$f)
1422
+ };
1423
+ const { URL: URL$8 } = resolveServiceUrl("DISPENSER_SERVICE");
1424
+ const { getAll: getAll$5 } = ServiceFactory.build({
1425
+ basePath: `${URL$8}/api/dispenser`
1426
+ });
1427
+ const log$8 = KosLog.createLogger({
1129
1428
  name: "dispenser-service",
1130
1429
  group: "Services"
1131
- }), wr = async () => (Sr.debug("sending GET for dispenser"), await Or({})), Js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1430
+ });
1431
+ const getDispensers = async () => {
1432
+ log$8.debug("sending GET for dispenser");
1433
+ const response = await getAll$5({});
1434
+ return response;
1435
+ };
1436
+ const index$8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1132
1437
  __proto__: null,
1133
- getDispensers: wr
1438
+ getDispensers
1134
1439
  }, Symbol.toStringTag, { value: "Module" }));
1135
- var Er = Object.defineProperty, Cr = Object.getOwnPropertyDescriptor, Ht = (e, t, o, s) => {
1136
- for (var r = s > 1 ? void 0 : s ? Cr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1137
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
1138
- return s && r && Er(t, o, r), r;
1139
- };
1140
- const B = "dispenser-info-model";
1141
- let ve = class {
1142
- constructor(e, t, o) {
1143
- i(this, "logger");
1144
- i(this, "id");
1145
- i(this, "name");
1146
- this.id = e, this.logger = o.logger;
1440
+ var __defProp$a = Object.defineProperty;
1441
+ var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
1442
+ var __decorateClass$e = (decorators, target, key, kind) => {
1443
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
1444
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1445
+ if (decorator = decorators[i])
1446
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1447
+ if (kind && result) __defProp$a(target, key, result);
1448
+ return result;
1449
+ };
1450
+ const MODEL_TYPE$e = "dispenser-info-model";
1451
+ let DispenserInfoModelImpl = class {
1452
+ logger;
1453
+ id;
1454
+ name;
1455
+ constructor(modelId, _options, context) {
1456
+ this.id = modelId;
1457
+ this.logger = context.logger;
1147
1458
  }
1148
1459
  // -------------------LIFECYCLE----------------------------
1149
1460
  async init() {
@@ -1153,51 +1464,65 @@ let ve = class {
1153
1464
  this.logger.debug(`loading dispenser-info ${this.id}`);
1154
1465
  }
1155
1466
  };
1156
- Ht([
1157
- d({
1467
+ __decorateClass$e([
1468
+ kosConfigProperty({
1158
1469
  path: "kos:device",
1159
1470
  attribute: "name"
1160
1471
  })
1161
- ], ve.prototype, "name", 2);
1162
- ve = Ht([
1163
- l(B)
1164
- ], ve);
1165
- const Lr = {
1472
+ ], DispenserInfoModelImpl.prototype, "name", 2);
1473
+ DispenserInfoModelImpl = __decorateClass$e([
1474
+ kosModel(MODEL_TYPE$e)
1475
+ ], DispenserInfoModelImpl);
1476
+ const DispenserInfo = {
1166
1477
  registration: {
1167
- [B]: {
1168
- class: ve,
1169
- singleton: !1
1478
+ [MODEL_TYPE$e]: {
1479
+ class: DispenserInfoModelImpl,
1480
+ singleton: false
1170
1481
  }
1171
1482
  },
1172
- type: B,
1173
- predicate: u(B),
1174
- factory: c.Factory.create(
1175
- B
1483
+ type: MODEL_TYPE$e,
1484
+ predicate: isKosModel(MODEL_TYPE$e),
1485
+ factory: Kos.Factory.create(
1486
+ MODEL_TYPE$e
1176
1487
  )
1177
- }, { URL: Dr } = h("DISPENSER-INFO_SERVICE"), { getAll: kr } = y.build({
1178
- basePath: `${Dr}/api/dispenser-info`
1179
- }), Ir = g.createLogger({
1488
+ };
1489
+ const { URL: URL$7 } = resolveServiceUrl("DISPENSER-INFO_SERVICE");
1490
+ const { getAll: getAll$4 } = ServiceFactory.build({
1491
+ basePath: `${URL$7}/api/dispenser-info`
1492
+ });
1493
+ const log$7 = KosLog.createLogger({
1180
1494
  name: "dispenser-info-service",
1181
1495
  group: "Services"
1182
- }), Rr = async () => (Ir.debug("sending GET for dispenser-info"), await kr({})), Zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1496
+ });
1497
+ const getDispenserInfos = async () => {
1498
+ log$7.debug("sending GET for dispenser-info");
1499
+ const response = await getAll$4({});
1500
+ return response;
1501
+ };
1502
+ const index$7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1183
1503
  __proto__: null,
1184
- getDispenserInfos: Rr
1504
+ getDispenserInfos
1185
1505
  }, Symbol.toStringTag, { value: "Module" }));
1186
- var Ar = Object.getOwnPropertyDescriptor, Fr = (e, t, o, s) => {
1187
- for (var r = s > 1 ? void 0 : s ? Ar(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1188
- (a = e[n]) && (r = a(r) || r);
1189
- return r;
1190
- };
1191
- const K = "enrollment-model";
1192
- let Ue = class {
1193
- constructor(e, t, o) {
1194
- i(this, "id");
1195
- i(this, "logger");
1196
- i(this, "enrolled");
1197
- this.id = e, this.logger = o.logger, this.enrolled = !1;
1198
- }
1199
- updateModel(e) {
1200
- console.log("updateModel:", e);
1506
+ var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
1507
+ var __decorateClass$d = (decorators, target, key, kind) => {
1508
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
1509
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1510
+ if (decorator = decorators[i])
1511
+ result = decorator(result) || result;
1512
+ return result;
1513
+ };
1514
+ const MODEL_TYPE$d = "enrollment-model";
1515
+ let EnrollmentModelImpl = class {
1516
+ id;
1517
+ logger;
1518
+ enrolled;
1519
+ constructor(modelId, _options, context) {
1520
+ this.id = modelId;
1521
+ this.logger = context.logger;
1522
+ this.enrolled = false;
1523
+ }
1524
+ updateModel(options) {
1525
+ console.log("updateModel:", options);
1201
1526
  }
1202
1527
  // -------------------LIFECYCLE----------------------------
1203
1528
  async init() {
@@ -1207,100 +1532,159 @@ let Ue = class {
1207
1532
  this.logger.debug(`loading enrollment ${this.id}`);
1208
1533
  }
1209
1534
  };
1210
- Ue = Fr([
1211
- l(K)
1212
- ], Ue);
1213
- const xr = {
1535
+ EnrollmentModelImpl = __decorateClass$d([
1536
+ kosModel(MODEL_TYPE$d)
1537
+ ], EnrollmentModelImpl);
1538
+ const Enrollment = {
1214
1539
  registration: {
1215
- [K]: {
1216
- class: Ue,
1217
- singleton: !0
1540
+ [MODEL_TYPE$d]: {
1541
+ class: EnrollmentModelImpl,
1542
+ singleton: true
1218
1543
  }
1219
1544
  },
1220
- type: K,
1221
- predicate: u(K),
1222
- factory: c.Singleton.create(K)
1223
- }, { URL: Ur } = h("ENROLLMENT_SERVICE"), { getAll: jr } = y.build({
1224
- basePath: `${Ur}/api/enrollment`
1225
- }), Wr = g.createLogger({
1545
+ type: MODEL_TYPE$d,
1546
+ predicate: isKosModel(MODEL_TYPE$d),
1547
+ factory: Kos.Singleton.create(MODEL_TYPE$d)
1548
+ };
1549
+ const { URL: URL$6 } = resolveServiceUrl("ENROLLMENT_SERVICE");
1550
+ const { getAll: getAll$3 } = ServiceFactory.build({
1551
+ basePath: `${URL$6}/api/enrollment`
1552
+ });
1553
+ const log$6 = KosLog.createLogger({
1226
1554
  name: "enrollment-service",
1227
1555
  group: "Services"
1228
- }), Nr = async () => (Wr.debug("sending GET for enrollment"), await jr({})), ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1556
+ });
1557
+ const getEnrollments = async () => {
1558
+ log$6.debug("sending GET for enrollment");
1559
+ const response = await getAll$3({});
1560
+ return response;
1561
+ };
1562
+ const index$6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1229
1563
  __proto__: null,
1230
- getEnrollments: Nr
1231
- }, Symbol.toStringTag, { value: "Module" })), ti = (e) => e.toLowerCase().includes("micros"), oi = (e) => !e.toLowerCase().includes("micros"), ri = (e) => (t) => {
1232
- const o = e == null ? void 0 : e.getHoldersByGroup(t);
1233
- return o ? o.map((s) => ({ id: s.id, name: s.ingredientName, path: s.path })) : null;
1234
- }, si = ["water", "carb", "ns", "nss"], ie = "dashboardKeyFactory", ke = [];
1235
- Oo(ie, {
1236
- register: (e, t) => {
1237
- ke.includes(t) || ke.push(t);
1564
+ getEnrollments
1565
+ }, Symbol.toStringTag, { value: "Module" }));
1566
+ const isMicroGroup = (group) => group.toLowerCase().includes("micros");
1567
+ const isMacroGroup = (group) => !group.toLowerCase().includes("micros");
1568
+ const macroHolderMap = (assembly) => (holderName) => {
1569
+ const holderGroup = assembly?.getHoldersByGroup(holderName);
1570
+ if (!holderGroup) {
1571
+ return null;
1572
+ }
1573
+ return holderGroup.map((holder) => {
1574
+ return { id: holder.id, name: holder.ingredientName, path: holder.path };
1575
+ });
1576
+ };
1577
+ const MACRO_KEYS = ["water", "carb", "ns", "nss"];
1578
+ const EXTENSION_POINT_DASHBOARD_KEY_FACTORY = "dashboardKeyFactory";
1579
+ const dashboardKeyFactories = [];
1580
+ registerExtensionPoint(EXTENSION_POINT_DASHBOARD_KEY_FACTORY, {
1581
+ register: (_id, factory) => {
1582
+ if (dashboardKeyFactories.includes(factory)) {
1583
+ return;
1584
+ }
1585
+ dashboardKeyFactories.push(factory);
1238
1586
  },
1239
- execute: (e, t) => {
1240
- const o = ke.sort((s, r) => s.rank - r.rank);
1241
- for (const s of o) {
1242
- const r = s.factory(t);
1243
- if (r)
1244
- return r;
1587
+ execute: (_id, holder) => {
1588
+ const factories = dashboardKeyFactories.sort((a, b) => a.rank - b.rank);
1589
+ for (const factory of factories) {
1590
+ const key = factory.factory(holder);
1591
+ if (key) {
1592
+ return key;
1593
+ }
1245
1594
  }
1595
+ return void 0;
1246
1596
  }
1247
1597
  });
1248
- const zr = (e) => {
1249
- Oe[ie].register(
1250
- ie,
1251
- e
1598
+ const registerDashboardKeyFactory = (factory) => {
1599
+ ExtensionManager[EXTENSION_POINT_DASHBOARD_KEY_FACTORY].register(
1600
+ EXTENSION_POINT_DASHBOARD_KEY_FACTORY,
1601
+ factory
1252
1602
  );
1253
- }, Vr = (e) => Oe[ie].execute(
1254
- ie,
1255
- e
1603
+ };
1604
+ const executeDashboardKeyFactory = (holder) => ExtensionManager[EXTENSION_POINT_DASHBOARD_KEY_FACTORY].execute(
1605
+ EXTENSION_POINT_DASHBOARD_KEY_FACTORY,
1606
+ holder
1256
1607
  );
1257
- Oe.registerDashboardKeyFactory = zr;
1258
- Oe.executeDashboardKeyFactory = Vr;
1259
- const je = 3600, Bt = 60, ii = (e) => {
1260
- const t = Math.floor(e / je), o = Math.floor(e % je / Bt);
1261
- return { hours: t, minutes: o };
1262
- }, ni = (e, t) => e * je + t * Bt, Hr = (e) => {
1263
- const o = (/* @__PURE__ */ new Date()).valueOf() - e.valueOf(), s = Math.floor(o / (1e3 * 60)), r = Math.floor(s / 60), n = Math.floor(r / 24), a = s % 60, de = r % 24;
1264
- let ce = "";
1265
- return n > 0 && (ce += `${n} day${n > 1 ? "s" : ""} `), de > 0 && (ce += `${de} hour${de > 1 ? "s" : ""} `), (a > 0 || n === 0 && de === 0) && (ce += `${a} minute${a > 1 ? "s" : ""} `), ce;
1266
- };
1267
- var Br = Object.defineProperty, Kr = Object.getOwnPropertyDescriptor, Ce = (e, t, o, s) => {
1268
- for (var r = s > 1 ? void 0 : s ? Kr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1269
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
1270
- return s && r && Br(t, o, r), r;
1271
- };
1272
- const Y = "ingredient-summary-model";
1273
- let L = class {
1274
- constructor(e, t, o) {
1275
- i(this, "id");
1276
- i(this, "assemblyModel");
1277
- i(this, "dashboardOperationModel");
1278
- i(this, "appModel");
1279
- i(this, "logger");
1280
- this.id = e, this.logger = o.logger, this.dashboardOperationModel = et.factory({});
1608
+ ExtensionManager.registerDashboardKeyFactory = registerDashboardKeyFactory;
1609
+ ExtensionManager.executeDashboardKeyFactory = executeDashboardKeyFactory;
1610
+ const HOUR = 3600;
1611
+ const MINUTE = 60;
1612
+ const toTimeComponents = (seconds) => {
1613
+ const hours = Math.floor(seconds / HOUR);
1614
+ const minutes = Math.floor(seconds % HOUR / MINUTE);
1615
+ return { hours, minutes };
1616
+ };
1617
+ const toSeconds = (hours, minutes) => {
1618
+ const time = hours * HOUR + minutes * MINUTE;
1619
+ return time;
1620
+ };
1621
+ const calculateTimeDifference = (date) => {
1622
+ const currentDate = /* @__PURE__ */ new Date();
1623
+ const timeDifference = currentDate.valueOf() - date.valueOf();
1624
+ const minutes = Math.floor(timeDifference / (1e3 * 60));
1625
+ const hours = Math.floor(minutes / 60);
1626
+ const days = Math.floor(hours / 24);
1627
+ const remainingMinutes = minutes % 60;
1628
+ const remainingHours = hours % 24;
1629
+ let result = "";
1630
+ if (days > 0) {
1631
+ result += `${days} day${days > 1 ? "s" : ""} `;
1632
+ }
1633
+ if (remainingHours > 0) {
1634
+ result += `${remainingHours} hour${remainingHours > 1 ? "s" : ""} `;
1635
+ }
1636
+ if (remainingMinutes > 0 || days === 0 && remainingHours === 0) {
1637
+ result += `${remainingMinutes} minute${remainingMinutes > 1 ? "s" : ""} `;
1638
+ }
1639
+ return result;
1640
+ };
1641
+ var __defProp$9 = Object.defineProperty;
1642
+ var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
1643
+ var __decorateClass$c = (decorators, target, key, kind) => {
1644
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
1645
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1646
+ if (decorator = decorators[i])
1647
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1648
+ if (kind && result) __defProp$9(target, key, result);
1649
+ return result;
1650
+ };
1651
+ const MODEL_TYPE$c = "ingredient-summary-model";
1652
+ let IngredientSummaryModelImpl = class {
1653
+ id;
1654
+ assemblyModel;
1655
+ dashboardOperationModel;
1656
+ appModel;
1657
+ logger;
1658
+ constructor(modelId, options, context) {
1659
+ this.id = modelId;
1660
+ this.logger = context.logger;
1661
+ this.dashboardOperationModel = DashboardOperations.factory({});
1281
1662
  }
1282
1663
  get highPriorityHolders() {
1283
1664
  return this.assemblyModel.allHolders.filter(
1284
- (e) => e.troubles.length > 0 && e.troubles.find((t) => t.rank >= 400)
1665
+ (holder) => holder.troubles.length > 0 && holder.troubles.find((trouble) => trouble.rank >= 400)
1285
1666
  );
1286
1667
  }
1287
1668
  get actionRequiredHolders() {
1288
- const e = this.appModel.currentRole, t = Dt(e);
1289
- return this.assemblyModel.allHolders.filter((o) => {
1290
- const s = Be(
1291
- o,
1292
- Co.type
1669
+ const currentRole = this.appModel.currentRole;
1670
+ const filter = troubleVisibilityFilter(currentRole);
1671
+ return this.assemblyModel.allHolders.filter((holder) => {
1672
+ const companionModel = getKosCompanionModel(
1673
+ holder,
1674
+ FreestyleHolder.type
1293
1675
  );
1294
- if (s != null && s.isRemote)
1295
- return !1;
1296
- const r = o.troubles.filter(t);
1297
- return r.length > 0 && r.find((n) => n.resolvable);
1676
+ if (companionModel?.isRemote) {
1677
+ return false;
1678
+ }
1679
+ const visibleTroubles = holder.troubles.filter(filter);
1680
+ return visibleTroubles.length > 0 && visibleTroubles.find((trouble) => trouble.resolvable);
1298
1681
  });
1299
1682
  }
1300
1683
  get lowLevelHolders() {
1301
- return this.assemblyModel.allHolders.filter((e) => {
1302
- const t = e.fillPercent;
1303
- return e.hasFuelGuage && t < 20;
1684
+ return this.assemblyModel.allHolders.filter((holder) => {
1685
+ const fillPercent = holder.fillPercent;
1686
+ const hasFuelGuage = holder.hasFuelGuage;
1687
+ return hasFuelGuage && fillPercent < 20;
1304
1688
  });
1305
1689
  }
1306
1690
  // -------------------LIFECYCLE----------------------------
@@ -1311,53 +1695,69 @@ let L = class {
1311
1695
  this.logger.debug(`loading ingredient-summary ${this.id}`);
1312
1696
  }
1313
1697
  };
1314
- Ce([
1315
- p({ modelType: Se.type })
1316
- ], L.prototype, "assemblyModel", 2);
1317
- Ce([
1318
- p({ modelType: et.type })
1319
- ], L.prototype, "dashboardOperationModel", 2);
1320
- Ce([
1321
- p({ modelType: Ze.type })
1322
- ], L.prototype, "appModel", 2);
1323
- L = Ce([
1324
- l(Y)
1325
- ], L);
1326
- const Yr = {
1698
+ __decorateClass$c([
1699
+ kosDependency({ modelType: Assembly.type })
1700
+ ], IngredientSummaryModelImpl.prototype, "assemblyModel", 2);
1701
+ __decorateClass$c([
1702
+ kosDependency({ modelType: DashboardOperations.type })
1703
+ ], IngredientSummaryModelImpl.prototype, "dashboardOperationModel", 2);
1704
+ __decorateClass$c([
1705
+ kosDependency({ modelType: Application.type })
1706
+ ], IngredientSummaryModelImpl.prototype, "appModel", 2);
1707
+ IngredientSummaryModelImpl = __decorateClass$c([
1708
+ kosModel(MODEL_TYPE$c)
1709
+ ], IngredientSummaryModelImpl);
1710
+ const IngredientSummary = {
1327
1711
  registration: {
1328
- [Y]: {
1329
- class: L,
1330
- singleton: !1
1712
+ [MODEL_TYPE$c]: {
1713
+ class: IngredientSummaryModelImpl,
1714
+ singleton: false
1331
1715
  }
1332
1716
  },
1333
- type: Y,
1334
- predicate: u(Y),
1335
- factory: c.Factory.create(
1336
- Y
1717
+ type: MODEL_TYPE$c,
1718
+ predicate: isKosModel(MODEL_TYPE$c),
1719
+ factory: Kos.Factory.create(
1720
+ MODEL_TYPE$c
1337
1721
  )
1338
- }, { URL: tt } = h("LOCKOUT_SERVICE"), { postModel: Kt } = y.build({
1339
- basePath: `${tt}/api/app/kosdev.ddk/lockout`
1340
- }), Yt = g.createLogger({ name: "lockout-service", group: "Services" }), Gr = async () => (Yt.info("lock"), await Kt({
1341
- model: {},
1342
- urlOverride: `${tt}/api/app/kosdev.ddk/lockout/lockNow`
1343
- })), Gt = async (e) => {
1344
- Yt.info("unlock");
1345
- const t = await Kt({
1722
+ };
1723
+ const { URL: URL$5 } = resolveServiceUrl("LOCKOUT_SERVICE");
1724
+ const { postModel: postModel$1 } = ServiceFactory.build({
1725
+ basePath: `${URL$5}/api/app/kosdev.ddk/lockout`
1726
+ });
1727
+ const log$5 = KosLog.createLogger({ name: "lockout-service", group: "Services" });
1728
+ const lock = async () => {
1729
+ log$5.info("lock");
1730
+ const response = await postModel$1({
1346
1731
  model: {},
1347
- urlOverride: `${tt}/api/app/kosdev.ddk/lockout/unlock/${e}`
1732
+ urlOverride: `${URL$5}/api/app/kosdev.ddk/lockout/lockNow`
1348
1733
  });
1349
- return t == null ? void 0 : t.data;
1350
- }, ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1734
+ return response;
1735
+ };
1736
+ const unlock = async (pin) => {
1737
+ log$5.info("unlock");
1738
+ const response = await postModel$1({
1739
+ model: {},
1740
+ urlOverride: `${URL$5}/api/app/kosdev.ddk/lockout/unlock/${pin}`
1741
+ });
1742
+ return response?.data;
1743
+ };
1744
+ const index$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1351
1745
  __proto__: null,
1352
- lock: Gr,
1353
- unlock: Gt
1746
+ lock,
1747
+ unlock
1354
1748
  }, Symbol.toStringTag, { value: "Module" }));
1355
- var qr = Object.defineProperty, Qr = Object.getOwnPropertyDescriptor, F = (e, t, o, s) => {
1356
- for (var r = s > 1 ? void 0 : s ? Qr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1357
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
1358
- return s && r && qr(t, o, r), r;
1749
+ var __defProp$8 = Object.defineProperty;
1750
+ var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
1751
+ var __decorateClass$b = (decorators, target, key, kind) => {
1752
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
1753
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1754
+ if (decorator = decorators[i])
1755
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1756
+ if (kind && result) __defProp$8(target, key, result);
1757
+ return result;
1359
1758
  };
1360
- const qt = "lockout-model", Xr = [
1759
+ const MODEL_TYPE$b = "lockout-model";
1760
+ const scheduleData = [
1361
1761
  { day: "monday", lock: "dayWiseLockConfigMap.Mon.enabled", open: "dayWiseLockConfigMap.Mon.unlockTime", close: "dayWiseLockConfigMap.Mon.lockTime" },
1362
1762
  { day: "tuesday", lock: "dayWiseLockConfigMap.Tue.enabled", open: "dayWiseLockConfigMap.Tue.unlockTime", close: "dayWiseLockConfigMap.Tue.lockTime" },
1363
1763
  { day: "wednesday", lock: "dayWiseLockConfigMap.Wed.enabled", open: "dayWiseLockConfigMap.Wed.unlockTime", close: "dayWiseLockConfigMap.Wed.lockTime" },
@@ -1366,146 +1766,170 @@ const qt = "lockout-model", Xr = [
1366
1766
  { day: "saturday", lock: "dayWiseLockConfigMap.Sat.enabled", open: "dayWiseLockConfigMap.Sat.unlockTime", close: "dayWiseLockConfigMap.Sat.lockTime" },
1367
1767
  { day: "sunday", lock: "dayWiseLockConfigMap.Sun.enabled", open: "dayWiseLockConfigMap.Sun.unlockTime", close: "dayWiseLockConfigMap.Sun.lockTime" }
1368
1768
  ];
1369
- let P = class {
1370
- constructor(e, t, o) {
1371
- i(this, "id");
1372
- i(this, "logger");
1373
- i(this, "dayEnabledList", [
1374
- "dayWiseLockConfigMap.Sun.enabled",
1375
- "dayWiseLockConfigMap.Mon.enabled",
1376
- "dayWiseLockConfigMap.Tue.enabled",
1377
- "dayWiseLockConfigMap.Wed.enabled",
1378
- "dayWiseLockConfigMap.Thu.enabled",
1379
- "dayWiseLockConfigMap.Fri.enabled",
1380
- "dayWiseLockConfigMap.Sat.enabled"
1381
- ]);
1382
- i(this, "dayOpenAtList", [
1383
- "dayWiseLockConfigMap.Sun.unlockTime",
1384
- "dayWiseLockConfigMap.Mon.unlockTime",
1385
- "dayWiseLockConfigMap.Tue.unlockTime",
1386
- "dayWiseLockConfigMap.Wed.unlockTime",
1387
- "dayWiseLockConfigMap.Thu.unlockTime",
1388
- "dayWiseLockConfigMap.Fri.unlockTime",
1389
- "dayWiseLockConfigMap.Sat.unlockTime"
1390
- ]);
1391
- i(this, "dayCloseAtList", [
1392
- "dayWiseLockConfigMap.Sun.lockTime",
1393
- "dayWiseLockConfigMap.Mon.lockTime",
1394
- "dayWiseLockConfigMap.Tue.lockTime",
1395
- "dayWiseLockConfigMap.Wed.lockTime",
1396
- "dayWiseLockConfigMap.Thu.lockTime",
1397
- "dayWiseLockConfigMap.Fri.lockTime",
1398
- "dayWiseLockConfigMap.Sat.lockTime"
1399
- ]);
1400
- i(this, "saveMap");
1401
- i(this, "pin");
1402
- i(this, "nextLockSkipped");
1403
- i(this, "nextLockTime");
1404
- i(this, "nextUnLockTime");
1405
- i(this, "cuiLockout");
1406
- this.id = e, this.logger = o.logger, this.saveMap = /* @__PURE__ */ new Map();
1407
- }
1769
+ let LockoutModelImpl = class {
1770
+ id;
1771
+ logger;
1772
+ dayEnabledList = [
1773
+ "dayWiseLockConfigMap.Sun.enabled",
1774
+ "dayWiseLockConfigMap.Mon.enabled",
1775
+ "dayWiseLockConfigMap.Tue.enabled",
1776
+ "dayWiseLockConfigMap.Wed.enabled",
1777
+ "dayWiseLockConfigMap.Thu.enabled",
1778
+ "dayWiseLockConfigMap.Fri.enabled",
1779
+ "dayWiseLockConfigMap.Sat.enabled"
1780
+ ];
1781
+ dayOpenAtList = [
1782
+ "dayWiseLockConfigMap.Sun.unlockTime",
1783
+ "dayWiseLockConfigMap.Mon.unlockTime",
1784
+ "dayWiseLockConfigMap.Tue.unlockTime",
1785
+ "dayWiseLockConfigMap.Wed.unlockTime",
1786
+ "dayWiseLockConfigMap.Thu.unlockTime",
1787
+ "dayWiseLockConfigMap.Fri.unlockTime",
1788
+ "dayWiseLockConfigMap.Sat.unlockTime"
1789
+ ];
1790
+ dayCloseAtList = [
1791
+ "dayWiseLockConfigMap.Sun.lockTime",
1792
+ "dayWiseLockConfigMap.Mon.lockTime",
1793
+ "dayWiseLockConfigMap.Tue.lockTime",
1794
+ "dayWiseLockConfigMap.Wed.lockTime",
1795
+ "dayWiseLockConfigMap.Thu.lockTime",
1796
+ "dayWiseLockConfigMap.Fri.lockTime",
1797
+ "dayWiseLockConfigMap.Sat.lockTime"
1798
+ ];
1799
+ saveMap;
1800
+ pin;
1801
+ nextLockSkipped;
1802
+ nextLockTime;
1803
+ nextUnLockTime;
1804
+ cuiLockout;
1408
1805
  get enabled() {
1409
- const e = this.getProp(
1806
+ const oneTimeLockConfigLockTime = this.getProp(
1410
1807
  "oneTimeLockConfig.lockTime"
1411
- ), t = e !== void 0 && e !== "", o = this.getProp("lockScheduleEnabled");
1412
- return t || o;
1808
+ );
1809
+ const oneTimeLockEnabled = oneTimeLockConfigLockTime !== void 0 && oneTimeLockConfigLockTime !== "";
1810
+ const lockScheduleEnabled = this.getProp("lockScheduleEnabled");
1811
+ const enabled = oneTimeLockEnabled || lockScheduleEnabled;
1812
+ return enabled;
1413
1813
  }
1414
1814
  get schedule() {
1415
- return Xr;
1815
+ return scheduleData;
1416
1816
  }
1417
- getProp(e) {
1418
- return this.saveMap.get(e);
1817
+ constructor(modelId, _options, context) {
1818
+ this.id = modelId;
1819
+ this.logger = context.logger;
1820
+ this.saveMap = /* @__PURE__ */ new Map();
1419
1821
  }
1420
- setProp(e, t) {
1421
- this.saveMap.set(e, t);
1822
+ getProp(key) {
1823
+ return this.saveMap.get(key);
1824
+ }
1825
+ setProp(key, value) {
1826
+ this.saveMap.set(key, value);
1422
1827
  }
1423
1828
  // Skip or resume the next lock...
1424
1829
  toggleSkip() {
1425
- if (this.nextLockSkipped.value === "0") {
1426
- const t = this.nextLockTime.value;
1427
- t !== void 0 && this.nextLockSkipped.updateProperty(t);
1428
- } else
1830
+ const nextLockSkipped = this.nextLockSkipped.value;
1831
+ if (nextLockSkipped === "0") {
1832
+ const nextLockTime = this.nextLockTime.value;
1833
+ if (nextLockTime !== void 0)
1834
+ this.nextLockSkipped.updateProperty(nextLockTime);
1835
+ } else {
1429
1836
  this.nextLockSkipped.updateProperty("0");
1837
+ }
1430
1838
  }
1431
- async unlock(e) {
1432
- return await Gt(e);
1839
+ async unlock(pin) {
1840
+ return await unlock(pin);
1433
1841
  }
1434
1842
  async save() {
1435
- return this.saveMap.forEach((e, t) => {
1436
- e !== this.cuiLockout.props[t] && (this.cuiLockout.props[t] = e);
1437
- }), this.cuiLockout.updateConfigBean();
1843
+ this.saveMap.forEach((value, key) => {
1844
+ if (value !== this.cuiLockout.props[key])
1845
+ this.cuiLockout.props[key] = value;
1846
+ });
1847
+ return this.cuiLockout.updateConfigBean();
1438
1848
  }
1439
1849
  reset() {
1440
1850
  this.cuiLockout.props.entries.forEach(
1441
- ([e, t]) => this.saveMap.set(e, t)
1851
+ ([key, value]) => this.saveMap.set(key, value)
1442
1852
  );
1443
1853
  }
1444
1854
  // -------------------LIFECYCLE----------------------------
1445
1855
  async init() {
1446
- this.logger.debug(`initializing lockout ${this.id}`), this.cuiLockout.props.entries.forEach(
1447
- ([e, t]) => this.saveMap.set(e, t)
1856
+ this.logger.debug(`initializing lockout ${this.id}`);
1857
+ this.cuiLockout.props.entries.forEach(
1858
+ ([key, value]) => this.saveMap.set(key, value)
1448
1859
  );
1449
1860
  }
1450
1861
  async load() {
1451
1862
  this.logger.debug(`loading lockout ${this.id}`);
1452
1863
  }
1453
1864
  };
1454
- F([
1455
- d({
1865
+ __decorateClass$b([
1866
+ kosConfigProperty({
1456
1867
  path: "app:kosdev.ddk:service:cuiLockout",
1457
1868
  attribute: "pin"
1458
1869
  })
1459
- ], P.prototype, "pin", 2);
1460
- F([
1461
- d({
1870
+ ], LockoutModelImpl.prototype, "pin", 2);
1871
+ __decorateClass$b([
1872
+ kosConfigProperty({
1462
1873
  path: "app:kosdev.ddk:service:cuiLockout",
1463
1874
  attribute: "nextLockSkipped"
1464
1875
  })
1465
- ], P.prototype, "nextLockSkipped", 2);
1466
- F([
1467
- d({
1876
+ ], LockoutModelImpl.prototype, "nextLockSkipped", 2);
1877
+ __decorateClass$b([
1878
+ kosConfigProperty({
1468
1879
  path: "app:kosdev.ddk:service:cuiLockout",
1469
1880
  attribute: "nextLockTime"
1470
1881
  })
1471
- ], P.prototype, "nextLockTime", 2);
1472
- F([
1473
- d({
1882
+ ], LockoutModelImpl.prototype, "nextLockTime", 2);
1883
+ __decorateClass$b([
1884
+ kosConfigProperty({
1474
1885
  path: "app:kosdev.ddk:service:cuiLockout",
1475
1886
  attribute: "nextUnLockTime"
1476
1887
  })
1477
- ], P.prototype, "nextUnLockTime", 2);
1478
- F([
1479
- So({ path: "app:kosdev.ddk:service:cuiLockout" })
1480
- ], P.prototype, "cuiLockout", 2);
1481
- P = F([
1482
- l(qt)
1483
- ], P);
1484
- const li = new He({
1485
- class: P,
1486
- type: qt
1487
- }), Jr = async (e, t) => await Me.bulkResolveTroubles(
1488
- e,
1489
- void 0,
1490
- t
1491
- );
1492
- var Zr = Object.defineProperty, es = Object.getOwnPropertyDescriptor, Le = (e, t, o, s) => {
1493
- for (var r = s > 1 ? void 0 : s ? es(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1494
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
1495
- return s && r && Zr(t, o, r), r;
1496
- };
1497
- const G = "macro-assignment-model", gt = "PurgeTrouble", ts = "PrimeTrouble";
1498
- let D = class {
1499
- constructor(e, t, o) {
1500
- i(this, "id");
1501
- i(this, "logger");
1502
- /**
1503
- * futureHandler is used to handle async operations
1504
- */
1505
- i(this, "futureHandler");
1506
- i(this, "holders");
1507
- i(this, "ingredients");
1508
- this.id = e, this.futureHandler = new Ge(), this.logger = o.logger;
1888
+ ], LockoutModelImpl.prototype, "nextUnLockTime", 2);
1889
+ __decorateClass$b([
1890
+ kosConfigBean({ path: "app:kosdev.ddk:service:cuiLockout" })
1891
+ ], LockoutModelImpl.prototype, "cuiLockout", 2);
1892
+ LockoutModelImpl = __decorateClass$b([
1893
+ kosModel(MODEL_TYPE$b)
1894
+ ], LockoutModelImpl);
1895
+ const Lockout = new SingletonKosModelRegistrationFactory({
1896
+ class: LockoutModelImpl,
1897
+ type: MODEL_TYPE$b
1898
+ });
1899
+ const purgeMacroPumps = async (troubleIds, tracker) => {
1900
+ const response = await TroubleServices.bulkResolveTroubles(
1901
+ troubleIds,
1902
+ void 0,
1903
+ tracker
1904
+ );
1905
+ return response;
1906
+ };
1907
+ var __defProp$7 = Object.defineProperty;
1908
+ var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
1909
+ var __decorateClass$a = (decorators, target, key, kind) => {
1910
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
1911
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1912
+ if (decorator = decorators[i])
1913
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1914
+ if (kind && result) __defProp$7(target, key, result);
1915
+ return result;
1916
+ };
1917
+ const MODEL_TYPE$a = "macro-assignment-model";
1918
+ const TROUBLE_TYPE_PURGE = "PurgeTrouble";
1919
+ const TROUBLE_TYPE_PRIME = "PrimeTrouble";
1920
+ let MacroAssignmentModelImpl = class {
1921
+ id;
1922
+ logger;
1923
+ /**
1924
+ * futureHandler is used to handle async operations
1925
+ */
1926
+ futureHandler;
1927
+ holders;
1928
+ ingredients;
1929
+ constructor(modelId, _options, context) {
1930
+ this.id = modelId;
1931
+ this.futureHandler = new FutureHandler();
1932
+ this.logger = context.logger;
1509
1933
  }
1510
1934
  /**
1511
1935
  * shortcut to the current running future
@@ -1520,7 +1944,11 @@ let D = class {
1520
1944
  * by the holders position in the dispenser assembly.
1521
1945
  */
1522
1946
  get macroHolders() {
1523
- return this.holders.holders.getIndexByKey("group", "macros").sort((e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : 0);
1947
+ return this.holders.holders.getIndexByKey("group", "macros").sort((a, b) => {
1948
+ if (a.name < b.name) return -1;
1949
+ if (a.name > b.name) return 1;
1950
+ return 0;
1951
+ });
1524
1952
  }
1525
1953
  /**
1526
1954
  * Returns true if there are any macro holders in the dispenser assembly
@@ -1534,16 +1962,20 @@ let D = class {
1534
1962
  * Relying on the indexing of troubles by type to find the purge troubles.
1535
1963
  */
1536
1964
  get holderPurgeTroubles() {
1537
- return this.macroHolders.reduce((t, o) => {
1538
- const s = o.troublesByType[gt] || [];
1539
- return t = [...t, ...s], t;
1965
+ const troubles = this.macroHolders.reduce((acc, curr) => {
1966
+ const purgeTroubles = curr.troublesByType[TROUBLE_TYPE_PURGE] || [];
1967
+ acc = [...acc, ...purgeTroubles];
1968
+ return acc;
1540
1969
  }, []);
1970
+ return troubles;
1541
1971
  }
1542
1972
  get holderPrimeTroubles() {
1543
- return this.macroHolders.reduce((t, o) => {
1544
- const s = o.troublesByType[ts] || [];
1545
- return t = [...t, ...s], t;
1973
+ const troubles = this.macroHolders.reduce((acc, curr) => {
1974
+ const primeTroubles = curr.troublesByType[TROUBLE_TYPE_PRIME] || [];
1975
+ acc = [...acc, ...primeTroubles];
1976
+ return acc;
1546
1977
  }, []);
1978
+ return troubles;
1547
1979
  }
1548
1980
  /**
1549
1981
  * Returns true if there are any purge troubles for the macro holders.
@@ -1574,59 +2006,77 @@ let D = class {
1574
2006
  get hasMacroIngredients() {
1575
2007
  return this.macroIngredients.length > 0;
1576
2008
  }
1577
- async resolveAll(e, t) {
1578
- if (!t)
2009
+ async resolveAll(type, tracker) {
2010
+ if (!tracker) {
1579
2011
  throw new Error("No tracker provided");
1580
- const s = (e === gt ? this.holderPurgeTroubles : this.holderPrimeTroubles).map((n) => n.rawId);
1581
- return await Jr(s, t);
1582
- }
1583
- };
1584
- Le([
1585
- p({ modelType: Lo.type })
1586
- ], D.prototype, "holders", 2);
1587
- Le([
1588
- p({ modelType: Do.type })
1589
- ], D.prototype, "ingredients", 2);
1590
- Le([
1591
- M()
1592
- ], D.prototype, "resolveAll", 1);
1593
- D = Le([
1594
- l(G)
1595
- ], D);
1596
- const os = {
2012
+ }
2013
+ const container = type === TROUBLE_TYPE_PURGE ? this.holderPurgeTroubles : this.holderPrimeTroubles;
2014
+ const allTroubles = container.map((trouble) => trouble.rawId);
2015
+ const response = await purgeMacroPumps(allTroubles, tracker);
2016
+ return response;
2017
+ }
2018
+ };
2019
+ __decorateClass$a([
2020
+ kosDependency({ modelType: HolderContainer.type })
2021
+ ], MacroAssignmentModelImpl.prototype, "holders", 2);
2022
+ __decorateClass$a([
2023
+ kosDependency({ modelType: IngredientContainer.type })
2024
+ ], MacroAssignmentModelImpl.prototype, "ingredients", 2);
2025
+ __decorateClass$a([
2026
+ kosFuture()
2027
+ ], MacroAssignmentModelImpl.prototype, "resolveAll", 1);
2028
+ MacroAssignmentModelImpl = __decorateClass$a([
2029
+ kosModel(MODEL_TYPE$a)
2030
+ ], MacroAssignmentModelImpl);
2031
+ const MacroAssignment = {
1597
2032
  registration: {
1598
- [G]: {
1599
- class: D,
1600
- singleton: !0
2033
+ [MODEL_TYPE$a]: {
2034
+ class: MacroAssignmentModelImpl,
2035
+ singleton: true
1601
2036
  }
1602
2037
  },
1603
- type: G,
1604
- predicate: u(G),
1605
- factory: c.Singleton.create(
1606
- G
2038
+ type: MODEL_TYPE$a,
2039
+ predicate: isKosModel(MODEL_TYPE$a),
2040
+ factory: Kos.Singleton.create(
2041
+ MODEL_TYPE$a
1607
2042
  )
1608
2043
  };
1609
- var rs = Object.getOwnPropertyDescriptor, ss = (e, t, o, s) => {
1610
- for (var r = s > 1 ? void 0 : s ? rs(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1611
- (a = e[n]) && (r = a(r) || r);
1612
- return r;
1613
- };
1614
- const q = "network-test-model";
1615
- let We = class {
1616
- constructor(e, t, o) {
1617
- i(this, "id");
1618
- i(this, "group");
1619
- i(this, "passed");
1620
- i(this, "inProgress");
1621
- i(this, "failureTime");
1622
- i(this, "timestamp");
1623
- i(this, "name");
1624
- i(this, "results");
1625
- i(this, "logger");
1626
- this.id = e, this.logger = o.logger, this.group = t.group, this.passed = !1, this.inProgress = !1, this.name = t.name, this.results = [];
1627
- }
1628
- updateModel(e) {
1629
- this.group = e.group, this.name = e.name, this.passed = e.passed, this.failureTime = e.failureTime, this.inProgress = e.inProgress, this.timestamp = e.timestamp, this.results = e.results;
2044
+ var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
2045
+ var __decorateClass$9 = (decorators, target, key, kind) => {
2046
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
2047
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2048
+ if (decorator = decorators[i])
2049
+ result = decorator(result) || result;
2050
+ return result;
2051
+ };
2052
+ const MODEL_TYPE$9 = "network-test-model";
2053
+ let NetworkTestModelImpl = class {
2054
+ id;
2055
+ group;
2056
+ passed;
2057
+ inProgress;
2058
+ failureTime;
2059
+ timestamp;
2060
+ name;
2061
+ results;
2062
+ logger;
2063
+ constructor(modelId, options, context) {
2064
+ this.id = modelId;
2065
+ this.logger = context.logger;
2066
+ this.group = options.group;
2067
+ this.passed = false;
2068
+ this.inProgress = false;
2069
+ this.name = options.name;
2070
+ this.results = [];
2071
+ }
2072
+ updateModel(options) {
2073
+ this.group = options.group;
2074
+ this.name = options.name;
2075
+ this.passed = options.passed;
2076
+ this.failureTime = options.failureTime;
2077
+ this.inProgress = options.inProgress;
2078
+ this.timestamp = options.timestamp;
2079
+ this.results = options.results;
1630
2080
  }
1631
2081
  // -------------------LIFECYCLE----------------------------
1632
2082
  async init() {
@@ -1636,75 +2086,94 @@ let We = class {
1636
2086
  this.logger.debug(`loading network-test ${this.id}`);
1637
2087
  }
1638
2088
  };
1639
- We = ss([
1640
- l(q)
1641
- ], We);
1642
- const Qt = {
2089
+ NetworkTestModelImpl = __decorateClass$9([
2090
+ kosModel(MODEL_TYPE$9)
2091
+ ], NetworkTestModelImpl);
2092
+ const NetworkTest = {
1643
2093
  registration: {
1644
- [q]: {
1645
- class: We,
1646
- singleton: !1
2094
+ [MODEL_TYPE$9]: {
2095
+ class: NetworkTestModelImpl,
2096
+ singleton: false
1647
2097
  }
1648
2098
  },
1649
- type: q,
1650
- predicate: u(q),
1651
- factory: c.Factory.create(q)
1652
- }, { URL: De } = h("NETWORK-TEST_SERVICE"), { getAll: is, getOne: Xt } = y.build({
1653
- basePath: `${De}/api/app/ncui/network/tests`
1654
- }), ns = g.createLogger({
2099
+ type: MODEL_TYPE$9,
2100
+ predicate: isKosModel(MODEL_TYPE$9),
2101
+ factory: Kos.Factory.create(MODEL_TYPE$9)
2102
+ };
2103
+ const { URL: URL$4 } = resolveServiceUrl("NETWORK-TEST_SERVICE");
2104
+ const { getAll: getAll$2, getOne: getOne$1 } = ServiceFactory.build({
2105
+ basePath: `${URL$4}/api/app/ncui/network/tests`
2106
+ });
2107
+ const log$4 = KosLog.createLogger({
1655
2108
  name: "network-test-service",
1656
2109
  group: "Services"
1657
- }), Jt = async () => {
1658
- ns.debug("sending GET for network-test");
1659
- const e = await is({
1660
- urlOverride: `${De}/api/app/kosdev.ddk/network/tests`
2110
+ });
2111
+ const getNetworkTests = async () => {
2112
+ log$4.debug("sending GET for network-test");
2113
+ const response = await getAll$2({
2114
+ urlOverride: `${URL$4}/api/app/kosdev.ddk/network/tests`
2115
+ });
2116
+ return response?.data;
2117
+ };
2118
+ const getTestsReports = async () => {
2119
+ const response = await getOne$1({
2120
+ urlOverride: `${URL$4}/api/app/kosdev.ddk/network/reports`
1661
2121
  });
1662
- return e == null ? void 0 : e.data;
1663
- }, Zt = async () => {
1664
- const e = await Xt({
1665
- urlOverride: `${De}/api/app/kosdev.ddk/network/reports`
2122
+ return response?.data;
2123
+ };
2124
+ const performGroupTest = async (group, tracker) => {
2125
+ const response = await getOne$1({
2126
+ urlOverride: `${URL$4}/api/app/kosdev.ddk/network/tests/run/group/${group}`,
2127
+ tracker
1666
2128
  });
1667
- return e == null ? void 0 : e.data;
1668
- }, eo = async (e, t) => await Xt({
1669
- urlOverride: `${De}/api/app/kosdev.ddk/network/tests/run/group/${e}`,
1670
- tracker: t
1671
- }), di = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2129
+ return response;
2130
+ };
2131
+ const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1672
2132
  __proto__: null,
1673
- getNetworkTests: Jt,
1674
- getTestsReports: Zt,
1675
- performGroupTest: eo
2133
+ getNetworkTests,
2134
+ getTestsReports,
2135
+ performGroupTest
1676
2136
  }, Symbol.toStringTag, { value: "Module" }));
1677
- var as = Object.defineProperty, ls = Object.getOwnPropertyDescriptor, ot = (e, t, o, s) => {
1678
- for (var r = s > 1 ? void 0 : s ? ls(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1679
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
1680
- return s && r && as(t, o, r), r;
1681
- };
1682
- const Q = "network-test-container-model";
1683
- let ne = class {
1684
- constructor(e, t, o) {
1685
- i(this, "id");
1686
- i(this, "logger");
1687
- i(this, "lastTested");
1688
- i(this, "futureHandler");
1689
- i(this, "models");
1690
- this.id = e, this.logger = o.logger, this.futureHandler = new Ge(this), this.models = new Ve({
1691
- parentId: e,
2137
+ var __defProp$6 = Object.defineProperty;
2138
+ var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
2139
+ var __decorateClass$8 = (decorators, target, key, kind) => {
2140
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
2141
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2142
+ if (decorator = decorators[i])
2143
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2144
+ if (kind && result) __defProp$6(target, key, result);
2145
+ return result;
2146
+ };
2147
+ const MODEL_TYPE$8 = "network-test-container-model";
2148
+ let NetworkTestContainerModelImpl = class {
2149
+ id;
2150
+ logger;
2151
+ lastTested;
2152
+ futureHandler;
2153
+ models;
2154
+ constructor(modelId, options, context) {
2155
+ this.id = modelId;
2156
+ this.logger = context.logger;
2157
+ this.futureHandler = new FutureHandler(this);
2158
+ this.models = new KosModelContainer({
2159
+ parentId: modelId,
1692
2160
  indexMap: {
1693
2161
  group: "group"
1694
2162
  }
1695
- }), this.lastTested = /* @__PURE__ */ new Date("default");
2163
+ });
2164
+ this.lastTested = /* @__PURE__ */ new Date("default");
1696
2165
  }
1697
2166
  get data() {
1698
2167
  return this.models.data;
1699
2168
  }
1700
- addModel(e) {
1701
- this.models.addModel(e);
2169
+ addModel(model) {
2170
+ this.models.addModel(model);
1702
2171
  }
1703
- removeModel(e) {
1704
- this.models.removeModel(e);
2172
+ removeModel(id) {
2173
+ this.models.removeModel(id);
1705
2174
  }
1706
- getModel(e) {
1707
- return this.models.getModel(e);
2175
+ getModel(id) {
2176
+ return this.models.getModel(id);
1708
2177
  }
1709
2178
  // -------------------LIFECYCLE----------------------------
1710
2179
  async init() {
@@ -1712,99 +2181,119 @@ let ne = class {
1712
2181
  `initializing network-test-container container ${this.id}`
1713
2182
  );
1714
2183
  }
1715
- getLastTested(e) {
1716
- const t = this.models.getIndexByKey("group", e).map((s) => s.timestamp && new Date(s.timestamp)), o = Math.max(
1717
- ...t.map((s) => s ? s.getTime() : 0)
2184
+ getLastTested(groupName) {
2185
+ const dateArray = this.models.getIndexByKey("group", groupName).map((obj) => obj.timestamp && new Date(obj.timestamp));
2186
+ const latestDate = Math.max(
2187
+ ...dateArray.map((date) => date ? date.getTime() : 0)
1718
2188
  );
1719
- return o ? Hr(new Date(o)) : "";
2189
+ return latestDate ? calculateTimeDifference(new Date(latestDate)) : "";
1720
2190
  }
1721
2191
  async load() {
1722
2192
  this.logger.debug(`loading network-test-container container ${this.id}`);
1723
- const e = await Jt(), t = await Zt();
1724
- e && e.forEach((o) => {
1725
- const s = Qt.factory(o.id)(o);
1726
- this.addModel(s);
1727
- }), e && t && e.forEach((o) => {
1728
- const s = t == null ? void 0 : t[o.group], r = s == null ? void 0 : s[o.id], n = this.getModel(o.id);
1729
- if (n && r) {
1730
- const a = {
1731
- group: r.group,
1732
- name: r.name,
1733
- passed: r.passed,
1734
- failureTime: r.failureTime ? new Date(r.failureTime) : void 0,
1735
- inProgress: r.inProgress,
1736
- timestamp: new Date(r.timestamp),
1737
- results: r.results
1738
- };
1739
- n.updateModel(a);
1740
- }
1741
- });
2193
+ const testResponse = await getNetworkTests();
2194
+ const testReportResponse = await getTestsReports();
2195
+ if (testResponse) {
2196
+ testResponse.forEach((item) => {
2197
+ const testModel = NetworkTest.factory(item.id)(item);
2198
+ this.addModel(testModel);
2199
+ });
2200
+ }
2201
+ if (testResponse && testReportResponse) {
2202
+ testResponse.forEach((item) => {
2203
+ const groupReport = testReportResponse?.[item.group];
2204
+ const testReport = groupReport?.[item.id];
2205
+ const testModel = this.getModel(item.id);
2206
+ if (testModel && testReport) {
2207
+ const update = {
2208
+ group: testReport.group,
2209
+ name: testReport.name,
2210
+ passed: testReport.passed,
2211
+ failureTime: testReport.failureTime ? new Date(testReport.failureTime) : void 0,
2212
+ inProgress: testReport.inProgress,
2213
+ timestamp: new Date(testReport.timestamp),
2214
+ results: testReport.results
2215
+ };
2216
+ testModel.updateModel(update);
2217
+ }
2218
+ });
2219
+ }
1742
2220
  }
1743
- async performTest(e, t) {
1744
- if (!t)
2221
+ async performTest(group, tracker) {
2222
+ if (!tracker) {
1745
2223
  throw new Error("No tracker provided");
1746
- const o = await eo(e, t);
1747
- return o == null ? void 0 : o.data;
1748
- }
1749
- onFutureUpdate(e) {
1750
- const { clientData: t } = e;
1751
- t && t.forEach((o) => {
1752
- const s = this.getModel(o.id);
1753
- if (v(() => {
1754
- this.lastTested = this.lastTested > new Date(o.timestamp) ? this.lastTested : new Date(o.timestamp);
1755
- }), s) {
1756
- const r = {
1757
- group: o.group,
1758
- name: o.name,
1759
- passed: o.passed,
1760
- failureTime: o.failureTime ? new Date(o.failureTime) : void 0,
1761
- inProgress: o.inProgress,
1762
- timestamp: new Date(o.timestamp),
1763
- results: o.results
1764
- };
1765
- v(() => {
1766
- s.updateModel(r);
2224
+ }
2225
+ const result = await performGroupTest(group, tracker);
2226
+ return result?.data;
2227
+ }
2228
+ onFutureUpdate(future) {
2229
+ const { clientData } = future;
2230
+ if (clientData) {
2231
+ clientData.forEach((item) => {
2232
+ const testModel = this.getModel(item.id);
2233
+ kosAction(() => {
2234
+ this.lastTested = this.lastTested > new Date(item.timestamp) ? this.lastTested : new Date(item.timestamp);
1767
2235
  });
1768
- }
1769
- });
2236
+ if (testModel) {
2237
+ const update = {
2238
+ group: item.group,
2239
+ name: item.name,
2240
+ passed: item.passed,
2241
+ failureTime: item.failureTime ? new Date(item.failureTime) : void 0,
2242
+ inProgress: item.inProgress,
2243
+ timestamp: new Date(item.timestamp),
2244
+ results: item.results
2245
+ };
2246
+ kosAction(() => {
2247
+ testModel.updateModel(update);
2248
+ });
2249
+ }
2250
+ });
2251
+ }
1770
2252
  }
1771
2253
  };
1772
- ot([
1773
- $e
1774
- ], ne.prototype, "models", 2);
1775
- ot([
1776
- M()
1777
- ], ne.prototype, "performTest", 1);
1778
- ne = ot([
1779
- l(Q)
1780
- ], ne);
1781
- const ds = {
2254
+ __decorateClass$8([
2255
+ kosChild
2256
+ ], NetworkTestContainerModelImpl.prototype, "models", 2);
2257
+ __decorateClass$8([
2258
+ kosFuture()
2259
+ ], NetworkTestContainerModelImpl.prototype, "performTest", 1);
2260
+ NetworkTestContainerModelImpl = __decorateClass$8([
2261
+ kosModel(MODEL_TYPE$8)
2262
+ ], NetworkTestContainerModelImpl);
2263
+ const NetworkTestContainer = {
1782
2264
  registration: {
1783
- [Q]: {
1784
- class: ne,
1785
- singleton: !0
2265
+ [MODEL_TYPE$8]: {
2266
+ class: NetworkTestContainerModelImpl,
2267
+ singleton: true
1786
2268
  },
1787
- ...Qt.registration
2269
+ ...NetworkTest.registration
1788
2270
  },
1789
- type: Q,
1790
- predicate: u(Q),
1791
- factory: c.Singleton.create(Q)
1792
- };
1793
- var cs = Object.defineProperty, us = Object.getOwnPropertyDescriptor, rt = (e, t, o, s) => {
1794
- for (var r = s > 1 ? void 0 : s ? us(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1795
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
1796
- return s && r && cs(t, o, r), r;
1797
- };
1798
- const X = "nutritive-sweetener-model", ps = ht("statePath");
1799
- let ae = class {
1800
- constructor(e, t) {
1801
- i(this, "id");
1802
- i(this, "assemblyModel");
1803
- i(this, "pumpState");
1804
- this.id = e;
2271
+ type: MODEL_TYPE$8,
2272
+ predicate: isKosModel(MODEL_TYPE$8),
2273
+ factory: Kos.Singleton.create(MODEL_TYPE$8)
2274
+ };
2275
+ var __defProp$5 = Object.defineProperty;
2276
+ var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
2277
+ var __decorateClass$7 = (decorators, target, key, kind) => {
2278
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
2279
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2280
+ if (decorator = decorators[i])
2281
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2282
+ if (kind && result) __defProp$5(target, key, result);
2283
+ return result;
2284
+ };
2285
+ const MODEL_TYPE$7 = "nutritive-sweetener-model";
2286
+ const PATH_PUMP_STATE = createPropKey("statePath");
2287
+ let NutritiveSweetenerModelImpl = class {
2288
+ id;
2289
+ assemblyModel;
2290
+ pumpState;
2291
+ constructor(modelId, _options) {
2292
+ this.id = modelId;
1805
2293
  }
1806
2294
  get holder() {
1807
- return this.assemblyModel.getHoldersByGroup("ns")[0];
2295
+ const nsHolder = this.assemblyModel.getHoldersByGroup("ns")[0];
2296
+ return nsHolder;
1808
2297
  }
1809
2298
  getHolder() {
1810
2299
  return this.holder;
@@ -1819,49 +2308,57 @@ let ae = class {
1819
2308
  return this.pump;
1820
2309
  }
1821
2310
  };
1822
- rt([
1823
- p({ modelType: Se.type })
1824
- ], ae.prototype, "assemblyModel", 2);
1825
- rt([
1826
- wo({
1827
- path: ps
2311
+ __decorateClass$7([
2312
+ kosDependency({ modelType: Assembly.type })
2313
+ ], NutritiveSweetenerModelImpl.prototype, "assemblyModel", 2);
2314
+ __decorateClass$7([
2315
+ kosStateBean({
2316
+ path: PATH_PUMP_STATE
1828
2317
  })
1829
- ], ae.prototype, "pumpState", 2);
1830
- ae = rt([
1831
- l(X),
1832
- Ke()
1833
- ], ae);
1834
- const gs = {
2318
+ ], NutritiveSweetenerModelImpl.prototype, "pumpState", 2);
2319
+ NutritiveSweetenerModelImpl = __decorateClass$7([
2320
+ kosModel(MODEL_TYPE$7),
2321
+ kosLoggerAware()
2322
+ ], NutritiveSweetenerModelImpl);
2323
+ const NutritiveSweetener = {
1835
2324
  registration: {
1836
- [X]: {
1837
- class: ae,
1838
- singleton: !1
2325
+ [MODEL_TYPE$7]: {
2326
+ class: NutritiveSweetenerModelImpl,
2327
+ singleton: false
1839
2328
  }
1840
2329
  },
1841
- type: X,
1842
- predicate: u(X),
1843
- factory: c.Factory.create(X)
1844
- };
1845
- var hs = Object.defineProperty, ys = Object.getOwnPropertyDescriptor, to = (e, t, o, s) => {
1846
- for (var r = s > 1 ? void 0 : s ? ys(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1847
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
1848
- return s && r && hs(t, o, r), r;
1849
- };
1850
- const J = "plain-water-model";
1851
- let me = class {
1852
- constructor(e, t, o) {
1853
- i(this, "id");
1854
- i(this, "assemblyModel");
1855
- i(this, "logger");
1856
- this.id = e, this.logger = o.logger;
2330
+ type: MODEL_TYPE$7,
2331
+ predicate: isKosModel(MODEL_TYPE$7),
2332
+ factory: Kos.Factory.create(MODEL_TYPE$7)
2333
+ };
2334
+ var __defProp$4 = Object.defineProperty;
2335
+ var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
2336
+ var __decorateClass$6 = (decorators, target, key, kind) => {
2337
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
2338
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2339
+ if (decorator = decorators[i])
2340
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2341
+ if (kind && result) __defProp$4(target, key, result);
2342
+ return result;
2343
+ };
2344
+ const MODEL_TYPE$6 = "plain-water-model";
2345
+ let PlainWaterModelImpl = class {
2346
+ id;
2347
+ assemblyModel;
2348
+ logger;
2349
+ constructor(modelId, _options, context) {
2350
+ this.id = modelId;
2351
+ this.logger = context.logger;
1857
2352
  }
1858
2353
  getHolder() {
1859
- return this.assemblyModel.getHoldersByGroup("water")[0];
2354
+ const waterHolder = this.assemblyModel.getHoldersByGroup("water")[0];
2355
+ return waterHolder;
1860
2356
  }
1861
2357
  getPump() {
1862
- var s, r;
1863
- const e = this.getHolder(), t = (r = (s = e == null ? void 0 : e.pumps) == null ? void 0 : s.data) == null ? void 0 : r[0];
1864
- return Be(t, mt.type);
2358
+ const waterHolder = this.getHolder();
2359
+ const pump = waterHolder?.pumps?.data?.[0];
2360
+ const model = getKosCompanionModel(pump, FcmPump.type);
2361
+ return model;
1865
2362
  }
1866
2363
  // -------------------LIFECYCLE----------------------------
1867
2364
  async init() {
@@ -1871,45 +2368,58 @@ let me = class {
1871
2368
  this.logger.debug(`loading plain-water ${this.id}`);
1872
2369
  }
1873
2370
  };
1874
- to([
1875
- p({ modelType: Se.type })
1876
- ], me.prototype, "assemblyModel", 2);
1877
- me = to([
1878
- l(J)
1879
- ], me);
1880
- const fs = {
2371
+ __decorateClass$6([
2372
+ kosDependency({ modelType: Assembly.type })
2373
+ ], PlainWaterModelImpl.prototype, "assemblyModel", 2);
2374
+ PlainWaterModelImpl = __decorateClass$6([
2375
+ kosModel(MODEL_TYPE$6)
2376
+ ], PlainWaterModelImpl);
2377
+ const PlainWater = {
1881
2378
  registration: {
1882
- [J]: {
1883
- class: me,
1884
- singleton: !1
2379
+ [MODEL_TYPE$6]: {
2380
+ class: PlainWaterModelImpl,
2381
+ singleton: false
1885
2382
  }
1886
2383
  },
1887
- type: J,
1888
- predicate: u(J),
1889
- factory: c.Factory.create(J)
1890
- }, { URL: oo } = h("REBOOT_SERVICE"), { postModel: vs } = y.build({
1891
- basePath: `${oo}/api/reboot`
1892
- }), ms = g.createLogger({ name: "reboot-service", group: "Services" }), ro = async () => (ms.debug("sending POST call for Reboot Dispenser"), await vs({
1893
- urlOverride: `${oo}/api/app/kosdev.ddk/ncui/reboot`,
1894
- model: {}
1895
- })), ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2384
+ type: MODEL_TYPE$6,
2385
+ predicate: isKosModel(MODEL_TYPE$6),
2386
+ factory: Kos.Factory.create(MODEL_TYPE$6)
2387
+ };
2388
+ const { URL: URL$3 } = resolveServiceUrl("REBOOT_SERVICE");
2389
+ const { postModel } = ServiceFactory.build({
2390
+ basePath: `${URL$3}/api/reboot`
2391
+ });
2392
+ const log$3 = KosLog.createLogger({ name: "reboot-service", group: "Services" });
2393
+ const rebootDispenser = async () => {
2394
+ log$3.debug("sending POST call for Reboot Dispenser");
2395
+ const response = await postModel({
2396
+ urlOverride: `${URL$3}/api/app/kosdev.ddk/ncui/reboot`,
2397
+ model: {}
2398
+ });
2399
+ return response;
2400
+ };
2401
+ const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1896
2402
  __proto__: null,
1897
- rebootDispenser: ro
2403
+ rebootDispenser
1898
2404
  }, Symbol.toStringTag, { value: "Module" }));
1899
- var bs = Object.getOwnPropertyDescriptor, _s = (e, t, o, s) => {
1900
- for (var r = s > 1 ? void 0 : s ? bs(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1901
- (a = e[n]) && (r = a(r) || r);
1902
- return r;
1903
- };
1904
- const Z = "reboot-model";
1905
- let Ne = class {
1906
- constructor(e, t, o) {
1907
- i(this, "id");
1908
- i(this, "logger");
1909
- this.id = e, this.logger = o.logger;
2405
+ var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
2406
+ var __decorateClass$5 = (decorators, target, key, kind) => {
2407
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
2408
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2409
+ if (decorator = decorators[i])
2410
+ result = decorator(result) || result;
2411
+ return result;
2412
+ };
2413
+ const MODEL_TYPE$5 = "reboot-model";
2414
+ let RebootModelImpl = class {
2415
+ id;
2416
+ logger;
2417
+ constructor(modelId, options, context) {
2418
+ this.id = modelId;
2419
+ this.logger = context.logger;
1910
2420
  }
1911
2421
  async completeReboot() {
1912
- await ro();
2422
+ await rebootDispenser();
1913
2423
  }
1914
2424
  updateModel() {
1915
2425
  }
@@ -1921,41 +2431,47 @@ let Ne = class {
1921
2431
  this.logger.debug(`loading reboot ${this.id}`);
1922
2432
  }
1923
2433
  };
1924
- Ne = _s([
1925
- l(Z)
1926
- ], Ne);
1927
- const Ts = {
2434
+ RebootModelImpl = __decorateClass$5([
2435
+ kosModel(MODEL_TYPE$5)
2436
+ ], RebootModelImpl);
2437
+ const Reboot = {
1928
2438
  registration: {
1929
- [Z]: {
1930
- class: Ne,
1931
- singleton: !1
2439
+ [MODEL_TYPE$5]: {
2440
+ class: RebootModelImpl,
2441
+ singleton: false
1932
2442
  }
1933
2443
  },
1934
- type: Z,
1935
- predicate: u(Z),
1936
- factory: c.Factory.create(Z)
1937
- };
1938
- var $s = Object.defineProperty, Ps = Object.getOwnPropertyDescriptor, m = (e, t, o, s) => {
1939
- for (var r = s > 1 ? void 0 : s ? Ps(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1940
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
1941
- return s && r && $s(t, o, r), r;
1942
- };
1943
- const ee = "settings-model";
1944
- let f = class {
1945
- constructor(e, t, o) {
1946
- i(this, "id");
1947
- i(this, "logger");
1948
- i(this, "ncuiLanguageData");
1949
- i(this, "resolveDelaysMs");
1950
- i(this, "dateFormat");
1951
- i(this, "timeFormat");
1952
- i(this, "hidePlainWaterBev");
1953
- i(this, "hideCarbWaterBev");
1954
- i(this, "ncuiLanguage");
1955
- i(this, "name");
1956
- i(this, "activateAndRebootTime");
1957
- i(this, "horizontalMode");
1958
- this.id = e, this.logger = o.logger;
2444
+ type: MODEL_TYPE$5,
2445
+ predicate: isKosModel(MODEL_TYPE$5),
2446
+ factory: Kos.Factory.create(MODEL_TYPE$5)
2447
+ };
2448
+ var __defProp$3 = Object.defineProperty;
2449
+ var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
2450
+ var __decorateClass$4 = (decorators, target, key, kind) => {
2451
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
2452
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2453
+ if (decorator = decorators[i])
2454
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2455
+ if (kind && result) __defProp$3(target, key, result);
2456
+ return result;
2457
+ };
2458
+ const MODEL_TYPE$4 = "settings-model";
2459
+ let SettingsModelImpl = class {
2460
+ id;
2461
+ logger;
2462
+ ncuiLanguageData;
2463
+ resolveDelaysMs;
2464
+ dateFormat;
2465
+ timeFormat;
2466
+ hidePlainWaterBev;
2467
+ hideCarbWaterBev;
2468
+ ncuiLanguage;
2469
+ name;
2470
+ activateAndRebootTime;
2471
+ horizontalMode;
2472
+ constructor(modelId, _options, context) {
2473
+ this.id = modelId;
2474
+ this.logger = context.logger;
1959
2475
  }
1960
2476
  // -------------------LIFECYCLE----------------------------
1961
2477
  async ready() {
@@ -1975,7 +2491,8 @@ let f = class {
1975
2491
  };
1976
2492
  }
1977
2493
  async load() {
1978
- this.logger.debug(`loading settings ${this.id}`), this.ncuiLanguageData = {
2494
+ this.logger.debug(`loading settings ${this.id}`);
2495
+ this.ncuiLanguageData = {
1979
2496
  status: 200,
1980
2497
  data: {
1981
2498
  languages: [
@@ -1991,114 +2508,141 @@ let f = class {
1991
2508
  this.updateDisplayMode();
1992
2509
  }
1993
2510
  updateDisplayMode() {
1994
- this.horizontalMode.value ? document.body.setAttribute("data-dashboard-layout", "horizontal") : document.body.setAttribute("data-dashboard-layout", "vertical");
2511
+ if (this.horizontalMode.value) {
2512
+ document.body.setAttribute("data-dashboard-layout", "horizontal");
2513
+ } else {
2514
+ document.body.setAttribute("data-dashboard-layout", "vertical");
2515
+ }
1995
2516
  }
1996
2517
  };
1997
- m([
1998
- d({
2518
+ __decorateClass$4([
2519
+ kosConfigProperty({
1999
2520
  path: "system:app",
2000
2521
  attribute: "resolveDelaysMs"
2001
2522
  // optionsExpander: () => [],
2002
2523
  })
2003
- ], f.prototype, "resolveDelaysMs", 2);
2004
- m([
2005
- d({
2524
+ ], SettingsModelImpl.prototype, "resolveDelaysMs", 2);
2525
+ __decorateClass$4([
2526
+ kosConfigProperty({
2006
2527
  path: "system:app",
2007
2528
  attribute: "dateFormat"
2008
2529
  // optionsExpander: () => [],
2009
2530
  })
2010
- ], f.prototype, "dateFormat", 2);
2011
- m([
2012
- d({
2531
+ ], SettingsModelImpl.prototype, "dateFormat", 2);
2532
+ __decorateClass$4([
2533
+ kosConfigProperty({
2013
2534
  path: "system:app",
2014
2535
  attribute: "timeFormat"
2015
2536
  // optionsExpander: () => [],
2016
2537
  })
2017
- ], f.prototype, "timeFormat", 2);
2018
- m([
2019
- d({
2538
+ ], SettingsModelImpl.prototype, "timeFormat", 2);
2539
+ __decorateClass$4([
2540
+ kosConfigProperty({
2020
2541
  path: "app:kosdev.ddk:app",
2021
2542
  attribute: "ncui.hidePlainWaterBev"
2022
2543
  })
2023
- ], f.prototype, "hidePlainWaterBev", 2);
2024
- m([
2025
- d({
2544
+ ], SettingsModelImpl.prototype, "hidePlainWaterBev", 2);
2545
+ __decorateClass$4([
2546
+ kosConfigProperty({
2026
2547
  path: "app:kosdev.ddk:app",
2027
2548
  attribute: "ncui.hideCarbWaterBev"
2028
2549
  })
2029
- ], f.prototype, "hideCarbWaterBev", 2);
2030
- m([
2031
- d({
2550
+ ], SettingsModelImpl.prototype, "hideCarbWaterBev", 2);
2551
+ __decorateClass$4([
2552
+ kosConfigProperty({
2032
2553
  path: "app:kosdev.ddk:app",
2033
2554
  attribute: "ncui.ncuiLanguage"
2034
2555
  })
2035
- ], f.prototype, "ncuiLanguage", 2);
2036
- m([
2037
- d({
2556
+ ], SettingsModelImpl.prototype, "ncuiLanguage", 2);
2557
+ __decorateClass$4([
2558
+ kosConfigProperty({
2038
2559
  path: "kos:device",
2039
2560
  attribute: "name"
2040
2561
  })
2041
- ], f.prototype, "name", 2);
2042
- m([
2043
- d({
2562
+ ], SettingsModelImpl.prototype, "name", 2);
2563
+ __decorateClass$4([
2564
+ kosConfigProperty({
2044
2565
  path: "kos:service:OTA",
2045
2566
  attribute: "activateAndRebootTime"
2046
2567
  })
2047
- ], f.prototype, "activateAndRebootTime", 2);
2048
- m([
2049
- d({
2568
+ ], SettingsModelImpl.prototype, "activateAndRebootTime", 2);
2569
+ __decorateClass$4([
2570
+ kosConfigProperty({
2050
2571
  path: "app:kosdev.ddk:app",
2051
2572
  attribute: "ncui.uiConfig.display.horizontalMode"
2052
2573
  })
2053
- ], f.prototype, "horizontalMode", 2);
2054
- m([
2055
- Pe({
2056
- dependencies: (e) => [e.horizontalMode.value]
2574
+ ], SettingsModelImpl.prototype, "horizontalMode", 2);
2575
+ __decorateClass$4([
2576
+ kosModelEffect({
2577
+ dependencies: (model) => [model.horizontalMode.value]
2057
2578
  })
2058
- ], f.prototype, "handleUpdateDisplayMode", 1);
2059
- f = m([
2060
- l(ee)
2061
- ], f);
2062
- const Ms = {
2579
+ ], SettingsModelImpl.prototype, "handleUpdateDisplayMode", 1);
2580
+ SettingsModelImpl = __decorateClass$4([
2581
+ kosModel(MODEL_TYPE$4)
2582
+ ], SettingsModelImpl);
2583
+ const Settings = {
2063
2584
  registration: {
2064
- [ee]: {
2065
- class: f,
2066
- singleton: !0
2585
+ [MODEL_TYPE$4]: {
2586
+ class: SettingsModelImpl,
2587
+ singleton: true
2067
2588
  }
2068
2589
  },
2069
- type: ee,
2070
- predicate: u(ee),
2071
- factory: c.Singleton.create(ee)
2072
- }, { URL: so } = h("SETTINGS_SERVICE"), { getAll: io } = y.build({
2073
- basePath: `${so}/api/settings`
2074
- }), Os = g.createLogger({
2590
+ type: MODEL_TYPE$4,
2591
+ predicate: isKosModel(MODEL_TYPE$4),
2592
+ factory: Kos.Singleton.create(MODEL_TYPE$4)
2593
+ };
2594
+ const { URL: URL$2 } = resolveServiceUrl("SETTINGS_SERVICE");
2595
+ const { getAll: getAll$1 } = ServiceFactory.build({
2596
+ basePath: `${URL$2}/api/settings`
2597
+ });
2598
+ const log$2 = KosLog.createLogger({
2075
2599
  name: "settings-service",
2076
2600
  group: "Services"
2077
- }), Ss = async () => (Os.debug("sending GET for settings"), await io({})), ws = async () => await io({
2078
- urlOverride: `${so}api/app/kosdev.ddk/ncui/languages`
2079
- }), ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2601
+ });
2602
+ const getSettings = async () => {
2603
+ log$2.debug("sending GET for settings");
2604
+ const response = await getAll$1({});
2605
+ return response;
2606
+ };
2607
+ const getNcuiLanguage = async () => {
2608
+ const response = await getAll$1({
2609
+ urlOverride: `${URL$2}api/app/kosdev.ddk/ncui/languages`
2610
+ });
2611
+ return response;
2612
+ };
2613
+ const index$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2080
2614
  __proto__: null,
2081
- getNcuiLanguage: ws,
2082
- getSettings: Ss
2615
+ getNcuiLanguage,
2616
+ getSettings
2083
2617
  }, Symbol.toStringTag, { value: "Module" }));
2084
- var Es = Object.getOwnPropertyDescriptor, Cs = (e, t, o, s) => {
2085
- for (var r = s > 1 ? void 0 : s ? Es(t, o) : t, n = e.length - 1, a; n >= 0; n--)
2086
- (a = e[n]) && (r = a(r) || r);
2087
- return r;
2088
- };
2089
- const te = "utilities-model";
2090
- let ze = class {
2091
- constructor(e, t, o) {
2092
- i(this, "id");
2093
- i(this, "name");
2094
- i(this, "options");
2095
- i(this, "roles");
2096
- i(this, "columnId");
2097
- i(this, "logger");
2098
- this.id = e, this.logger = o.logger, this.name = t.name, this.options = t.options, this.roles = t == null ? void 0 : t.roles, this.columnId = t.columnId;
2099
- }
2100
- updateModel(e) {
2101
- this.name = e.name, this.options = e.options, this.roles = e == null ? void 0 : e.roles;
2618
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
2619
+ var __decorateClass$3 = (decorators, target, key, kind) => {
2620
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
2621
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2622
+ if (decorator = decorators[i])
2623
+ result = decorator(result) || result;
2624
+ return result;
2625
+ };
2626
+ const MODEL_TYPE$3 = "utilities-model";
2627
+ let UtilitiesModelImpl = class {
2628
+ id;
2629
+ name;
2630
+ options;
2631
+ roles;
2632
+ columnId;
2633
+ logger;
2634
+ constructor(modelId, options, context) {
2635
+ this.id = modelId;
2636
+ this.logger = context.logger;
2637
+ this.name = options.name;
2638
+ this.options = options.options;
2639
+ this.roles = options?.roles;
2640
+ this.columnId = options.columnId;
2641
+ }
2642
+ updateModel(options) {
2643
+ this.name = options.name;
2644
+ this.options = options.options;
2645
+ this.roles = options?.roles;
2102
2646
  }
2103
2647
  get titleKey() {
2104
2648
  return `utility.${this.id}.title`;
@@ -2114,62 +2658,74 @@ let ze = class {
2114
2658
  this.logger.debug(`loading utilities ${this.id}`);
2115
2659
  }
2116
2660
  };
2117
- ze = Cs([
2118
- l(te)
2119
- ], ze);
2120
- const no = {
2661
+ UtilitiesModelImpl = __decorateClass$3([
2662
+ kosModel(MODEL_TYPE$3)
2663
+ ], UtilitiesModelImpl);
2664
+ const Utilities = {
2121
2665
  registration: {
2122
- [te]: {
2123
- class: ze,
2124
- singleton: !1
2666
+ [MODEL_TYPE$3]: {
2667
+ class: UtilitiesModelImpl,
2668
+ singleton: false
2125
2669
  }
2126
2670
  },
2127
- type: te,
2128
- predicate: u(te),
2129
- factory: c.Factory.create(te)
2130
- }, { URL: ge } = h("UTILITIES_SERVICE"), { getAll: Ie } = y.build({
2131
- basePath: `${ge}/api/utilities`
2132
- }), Re = g.createLogger({
2671
+ type: MODEL_TYPE$3,
2672
+ predicate: isKosModel(MODEL_TYPE$3),
2673
+ factory: Kos.Factory.create(MODEL_TYPE$3)
2674
+ };
2675
+ const { URL: URL$1 } = resolveServiceUrl("UTILITIES_SERVICE");
2676
+ const { getAll } = ServiceFactory.build({
2677
+ basePath: `${URL$1}/api/utilities`
2678
+ });
2679
+ const log$1 = KosLog.createLogger({
2133
2680
  name: "utilities-service",
2134
2681
  group: "Services"
2135
- }), ao = async () => {
2136
- Re.debug("sending GET for utilities");
2682
+ });
2683
+ const getUtilities = async () => {
2684
+ log$1.debug("sending GET for utilities");
2137
2685
  try {
2138
- const e = await Ie({
2139
- urlOverride: `${ge}/api/kos/descriptor/app:kosdev.ddk:ncuiDescriptor/kondra.ncui.utilities`
2686
+ const extensionResponse = await getAll({
2687
+ urlOverride: `${URL$1}/api/kos/descriptor/app:kosdev.ddk:ncuiDescriptor/kondra.ncui.utilities`
2140
2688
  });
2141
- if ((e == null ? void 0 : e.status) !== 200) {
2142
- Re.info("no extensions found, using base data");
2143
- const t = await Ie({
2144
- urlOverride: `${ge}/api/kos/descriptor/system:app/kondra.ncui.utilities`
2689
+ if (extensionResponse?.status !== 200) {
2690
+ log$1.info(`no extensions found, using base data`);
2691
+ const response = await getAll({
2692
+ urlOverride: `${URL$1}/api/kos/descriptor/system:app/kondra.ncui.utilities`
2145
2693
  });
2146
- return (t == null ? void 0 : t.data) ?? [];
2694
+ return response?.data ?? [];
2147
2695
  }
2148
- return (e == null ? void 0 : e.data) ?? [];
2149
- } catch (e) {
2150
- Re.info(`error fetching utilities: ${e}. Using base data`);
2151
- const t = await Ie({
2152
- urlOverride: `${ge}/api/kos/descriptor/system:app/kondra.ncui.utilities`
2696
+ return extensionResponse?.data ?? [];
2697
+ } catch (error) {
2698
+ log$1.info(`error fetching utilities: ${error}. Using base data`);
2699
+ const response = await getAll({
2700
+ urlOverride: `${URL$1}/api/kos/descriptor/system:app/kondra.ncui.utilities`
2153
2701
  });
2154
- return (t == null ? void 0 : t.data) ?? [];
2702
+ return response?.data ?? [];
2155
2703
  }
2156
- }, pi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2704
+ };
2705
+ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2157
2706
  __proto__: null,
2158
- getUtilities: ao
2707
+ getUtilities
2159
2708
  }, Symbol.toStringTag, { value: "Module" }));
2160
- var Ls = Object.defineProperty, Ds = Object.getOwnPropertyDescriptor, lo = (e, t, o, s) => {
2161
- for (var r = s > 1 ? void 0 : s ? Ds(t, o) : t, n = e.length - 1, a; n >= 0; n--)
2162
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
2163
- return s && r && Ls(t, o, r), r;
2164
- };
2165
- const oe = "utilities-container-model";
2166
- let be = class {
2167
- constructor(e, t, o) {
2168
- i(this, "id");
2169
- i(this, "logger");
2170
- i(this, "_models");
2171
- this.id = e, this.logger = o.logger, this._models = new Ve({
2172
- parentId: e,
2709
+ var __defProp$2 = Object.defineProperty;
2710
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
2711
+ var __decorateClass$2 = (decorators, target, key, kind) => {
2712
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
2713
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2714
+ if (decorator = decorators[i])
2715
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2716
+ if (kind && result) __defProp$2(target, key, result);
2717
+ return result;
2718
+ };
2719
+ const MODEL_TYPE$2 = "utilities-container-model";
2720
+ let UtilitiesContainerModelImpl = class {
2721
+ id;
2722
+ logger;
2723
+ _models;
2724
+ constructor(modelId, _options, context) {
2725
+ this.id = modelId;
2726
+ this.logger = context.logger;
2727
+ this._models = new KosModelContainer({
2728
+ parentId: modelId,
2173
2729
  sortKey: "id",
2174
2730
  indexMap: {
2175
2731
  byColumn: "columnId"
@@ -2183,80 +2739,129 @@ let be = class {
2183
2739
  return this._models;
2184
2740
  }
2185
2741
  get columns() {
2186
- return this._models.getIndexKeys("byColumn").sort((e, t) => e.localeCompare(t));
2742
+ return this._models.getIndexKeys("byColumn").sort((a, b) => a.localeCompare(b));
2187
2743
  }
2188
- addModel(e) {
2189
- this._models.addModel(e);
2744
+ addModel(model) {
2745
+ this._models.addModel(model);
2190
2746
  }
2191
- removeModel(e) {
2192
- this._models.removeModel(e);
2747
+ removeModel(id) {
2748
+ this._models.removeModel(id);
2193
2749
  }
2194
- getModel(e) {
2195
- return this._models.getModel(e);
2750
+ getModel(id) {
2751
+ return this._models.getModel(id);
2196
2752
  }
2197
- getUtilitiesByColumn(e) {
2198
- return this._models.getIndexByKey("byColumn", e);
2753
+ getUtilitiesByColumn(id) {
2754
+ return this._models.getIndexByKey("byColumn", id);
2199
2755
  }
2200
2756
  // -------------------LIFECYCLE----------------------------
2201
2757
  async load() {
2202
2758
  this.logger.debug(`loading utilities-container container ${this.id}`);
2203
- const e = await ao();
2204
- e == null || e.forEach((t, o) => {
2205
- t.forEach((s) => {
2206
- const r = {
2207
- ...s,
2208
- columnId: String(o)
2209
- }, n = no.factory(s.name)(
2210
- r
2759
+ const utilitiesResponse = await getUtilities();
2760
+ utilitiesResponse?.forEach((utilityColumnsResponse, columnId) => {
2761
+ utilityColumnsResponse.forEach((utilityResponse) => {
2762
+ const utilityOptions = {
2763
+ ...utilityResponse,
2764
+ columnId: String(columnId)
2765
+ };
2766
+ const utilityModel = Utilities.factory(utilityResponse.name)(
2767
+ utilityOptions
2211
2768
  );
2212
- this.addModel(n);
2769
+ this.addModel(utilityModel);
2213
2770
  });
2214
2771
  });
2215
2772
  }
2216
2773
  };
2217
- lo([
2218
- $e
2219
- ], be.prototype, "_models", 2);
2220
- be = lo([
2221
- l(oe)
2222
- ], be);
2223
- const ks = {
2774
+ __decorateClass$2([
2775
+ kosChild
2776
+ ], UtilitiesContainerModelImpl.prototype, "_models", 2);
2777
+ UtilitiesContainerModelImpl = __decorateClass$2([
2778
+ kosModel(MODEL_TYPE$2)
2779
+ ], UtilitiesContainerModelImpl);
2780
+ const UtilitiesContainer = {
2224
2781
  registration: {
2225
- [oe]: {
2226
- class: be,
2227
- singleton: !0
2782
+ [MODEL_TYPE$2]: {
2783
+ class: UtilitiesContainerModelImpl,
2784
+ singleton: true
2228
2785
  },
2229
- ...no.registration
2786
+ ...Utilities.registration
2230
2787
  },
2231
- type: oe,
2232
- predicate: u(oe),
2233
- factory: c.Singleton.create(oe)
2234
- }, gi = {
2235
- ...sr.registration,
2236
- ...Ze.registration,
2237
- ...Qe.registration,
2238
- ...ur.registration,
2239
- ...et.registration,
2240
- ...Pr.registration,
2241
- ...Lr.registration,
2242
- ...xr.registration,
2243
- ...Yr.registration,
2244
- ...os.registration,
2245
- ...ds.registration,
2246
- ...gs.registration,
2247
- ...fs.registration,
2248
- ...Ts.registration,
2249
- ...Ms.registration,
2250
- ...Et.registration,
2251
- ...ks.registration
2252
- };
2253
- var co = Object.defineProperty, Is = Object.getOwnPropertyDescriptor, Rs = (e, t, o) => t in e ? co(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, st = (e, t, o, s) => {
2254
- for (var r = s > 1 ? void 0 : s ? Is(t, o) : t, n = e.length - 1, a; n >= 0; n--)
2255
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
2256
- return s && r && co(t, o, r), r;
2257
- }, As = (e, t, o) => (Rs(e, t + "", o), o);
2258
- const Fs = "trouble-action-model";
2259
- let k = class {
2788
+ type: MODEL_TYPE$2,
2789
+ predicate: isKosModel(MODEL_TYPE$2),
2790
+ factory: Kos.Singleton.create(MODEL_TYPE$2)
2791
+ };
2792
+ const DDKModels = {
2793
+ ...Animation.registration,
2794
+ ...Application.registration,
2795
+ ...Auth.registration,
2796
+ ...CarbWater.registration,
2797
+ ...DashboardOperations.registration,
2798
+ ...Dispenser.registration,
2799
+ ...DispenserInfo.registration,
2800
+ ...Enrollment.registration,
2801
+ ...IngredientSummary.registration,
2802
+ ...MacroAssignment.registration,
2803
+ ...NetworkTestContainer.registration,
2804
+ ...NutritiveSweetener.registration,
2805
+ ...PlainWater.registration,
2806
+ ...Reboot.registration,
2807
+ ...Settings.registration,
2808
+ ...SetupStepContainer.registration,
2809
+ ...UtilitiesContainer.registration
2810
+ };
2811
+ var __defProp$1 = Object.defineProperty;
2812
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
2813
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2814
+ var __decorateClass$1 = (decorators, target, key, kind) => {
2815
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
2816
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2817
+ if (decorator = decorators[i])
2818
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2819
+ if (kind && result) __defProp$1(target, key, result);
2820
+ return result;
2821
+ };
2822
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
2823
+ const MODEL_TYPE$1 = "trouble-action-model";
2824
+ let TroubleActionModelImpl = class {
2825
+ /**
2826
+ * Unique identifier for this model instance.
2827
+ *
2828
+ * Set during construction and used for model lifecycle management
2829
+ * and debugging purposes.
2830
+ *
2831
+ * @category Model Properties
2832
+ */
2833
+ id;
2834
+ troubleContainer;
2835
+ /**
2836
+ * Observable state object mapping trouble state keys to values.
2837
+ *
2838
+ * This reactive state object is automatically updated when troubles are
2839
+ * added or removed from the system. Keys and values are determined by
2840
+ * the trouble action definitions provided during model initialization.
2841
+ *
2842
+ * State keys that no longer have associated active troubles are set to
2843
+ * undefined.
2844
+ *
2845
+ * @example
2846
+ * ```typescript
2847
+ * // Access state values
2848
+ * const isAgitationRequired = troubleActionModel.state.agitationRequired;
2849
+ *
2850
+ * // State is reactive - updates automatically propagate to React components
2851
+ * ```
2852
+ *
2853
+ * @category Model State
2854
+ */
2855
+ state;
2856
+ /**
2857
+ * Internal mapping of trouble types to their action definitions.
2858
+ *
2859
+ * Built from the definitions array provided in TroubleActionOptions during
2860
+ * construction. Used for efficient lookup when processing trouble changes.
2861
+ *
2862
+ * @category Internal State
2863
+ */
2864
+ troubleActionData;
2260
2865
  /**
2261
2866
  * Creates a new TroubleActionModel instance.
2262
2867
  *
@@ -2270,48 +2875,13 @@ let k = class {
2270
2875
  *
2271
2876
  * @category Lifecycle
2272
2877
  */
2273
- constructor(e, t) {
2274
- /**
2275
- * Unique identifier for this model instance.
2276
- *
2277
- * Set during construction and used for model lifecycle management
2278
- * and debugging purposes.
2279
- *
2280
- * @category Model Properties
2281
- */
2282
- i(this, "id");
2283
- i(this, "troubleContainer");
2284
- /**
2285
- * Observable state object mapping trouble state keys to values.
2286
- *
2287
- * This reactive state object is automatically updated when troubles are
2288
- * added or removed from the system. Keys and values are determined by
2289
- * the trouble action definitions provided during model initialization.
2290
- *
2291
- * State keys that no longer have associated active troubles are set to
2292
- * undefined.
2293
- *
2294
- * @example
2295
- * ```typescript
2296
- * // Access state values
2297
- * const isAgitationRequired = troubleActionModel.state.agitationRequired;
2298
- *
2299
- * // State is reactive - updates automatically propagate to React components
2300
- * ```
2301
- *
2302
- * @category Model State
2303
- */
2304
- i(this, "state");
2305
- /**
2306
- * Internal mapping of trouble types to their action definitions.
2307
- *
2308
- * Built from the definitions array provided in TroubleActionOptions during
2309
- * construction. Used for efficient lookup when processing trouble changes.
2310
- *
2311
- * @category Internal State
2312
- */
2313
- i(this, "troubleActionData");
2314
- this.id = e, this.state = Eo(), this.troubleActionData = t.definitions.reduce((o, s) => (o[s.troubleType] = s, o), {});
2878
+ constructor(modelId, options) {
2879
+ this.id = modelId;
2880
+ this.state = ObservableData();
2881
+ this.troubleActionData = options.definitions.reduce((acc, curr) => {
2882
+ acc[curr.troubleType] = curr;
2883
+ return acc;
2884
+ }, {});
2315
2885
  }
2316
2886
  // -------------------LIFECYCLE----------------------------
2317
2887
  /**
@@ -2336,14 +2906,20 @@ let k = class {
2336
2906
  * @see {@link TroubleContainerModel} for trouble data structure
2337
2907
  */
2338
2908
  get activeTrouble() {
2339
- const e = Object.keys(this.troubleActionData);
2340
- if (e.length > 0) {
2341
- const t = e[0], o = this.troubleContainer.troubles.getIndexByKey(
2909
+ const actions = Object.keys(this.troubleActionData);
2910
+ if (actions.length > 0) {
2911
+ const firstAction = actions[0];
2912
+ const troubles = this.troubleContainer.troubles.getIndexByKey(
2342
2913
  "byType",
2343
- t
2914
+ firstAction
2344
2915
  );
2345
- return o.length > 0 ? o[0] : void 0;
2916
+ if (troubles.length > 0) {
2917
+ return troubles[0];
2918
+ } else {
2919
+ return void 0;
2920
+ }
2346
2921
  }
2922
+ return void 0;
2347
2923
  }
2348
2924
  /**
2349
2925
  * Gets the type of the first active trouble with an associated action definition.
@@ -2364,59 +2940,75 @@ let k = class {
2364
2940
  * @category Trouble Access
2365
2941
  */
2366
2942
  get activeTroubleType() {
2367
- var e;
2368
- return (e = this.activeTrouble) == null ? void 0 : e.type;
2943
+ return this.activeTrouble?.type;
2369
2944
  }
2370
2945
  handleTroubleActions() {
2371
- const e = this.troubleContainer.troubles.data.reduce((t, o) => {
2372
- const s = o.type;
2373
- if (this.troubleActionData[s]) {
2374
- const r = this.troubleActionData[s].stateKey ?? s, n = this.troubleActionData[s].stateValue ?? s;
2375
- t[r] = n;
2946
+ const _state = this.troubleContainer.troubles.data.reduce((acc, curr) => {
2947
+ const _troubleType = curr.type;
2948
+ if (this.troubleActionData[_troubleType]) {
2949
+ const _stateKey = this.troubleActionData[_troubleType].stateKey ?? _troubleType;
2950
+ const _stateValue = this.troubleActionData[_troubleType].stateValue ?? _troubleType;
2951
+ acc[_stateKey] = _stateValue;
2376
2952
  }
2377
- return t;
2953
+ return acc;
2378
2954
  }, {});
2379
- this.state.setValues(e), Object.keys(this.troubleActionData).forEach((t) => {
2380
- if (this.troubleContainer.troubles.getIndexByKey("byType", t).length === 0) {
2381
- const o = this.troubleActionData[t].stateKey ?? t;
2382
- this.state[o] = void 0;
2955
+ this.state.setValues(_state);
2956
+ Object.keys(this.troubleActionData).forEach((key) => {
2957
+ if (this.troubleContainer.troubles.getIndexByKey("byType", key).length === 0) {
2958
+ const _stateKey = this.troubleActionData[key].stateKey ?? key;
2959
+ this.state[_stateKey] = void 0;
2383
2960
  }
2384
2961
  });
2385
2962
  }
2386
2963
  };
2387
- As(k, "Registration");
2388
- st([
2389
- p({ modelType: Ye.type })
2390
- ], k.prototype, "troubleContainer", 2);
2391
- st([
2392
- Pe({
2393
- dependencies: (e) => [e.troubleContainer.troubles.data]
2964
+ __publicField(TroubleActionModelImpl, "Registration");
2965
+ __decorateClass$1([
2966
+ kosDependency({ modelType: TroubleContainer.type })
2967
+ ], TroubleActionModelImpl.prototype, "troubleContainer", 2);
2968
+ __decorateClass$1([
2969
+ kosModelEffect({
2970
+ dependencies: (model) => [model.troubleContainer.troubles.data]
2394
2971
  })
2395
- ], k.prototype, "handleTroubleActions", 1);
2396
- k = st([
2397
- l({ modelTypeId: Fs, singleton: !0 }),
2398
- Ke()
2399
- ], k);
2400
- const hi = k.Registration, { URL: uo } = h("START_SERVICE"), { getOne: xs } = y.build({
2401
- basePath: `${uo}/api/start`
2402
- }), Us = g.createLogger({ name: "start-service", group: "Services" }), po = async () => (Us.debug("navigating to NCUI"), await xs({
2403
- urlOverride: `${uo}/api/app/kosdev.ddk/ncui/open`
2404
- })), yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2972
+ ], TroubleActionModelImpl.prototype, "handleTroubleActions", 1);
2973
+ TroubleActionModelImpl = __decorateClass$1([
2974
+ kosModel({ modelTypeId: MODEL_TYPE$1, singleton: true }),
2975
+ kosLoggerAware()
2976
+ ], TroubleActionModelImpl);
2977
+ const TroubleAction = TroubleActionModelImpl.Registration;
2978
+ const { URL } = resolveServiceUrl("START_SERVICE");
2979
+ const { getOne } = ServiceFactory.build({
2980
+ basePath: `${URL}/api/start`
2981
+ });
2982
+ const log = KosLog.createLogger({ name: "start-service", group: "Services" });
2983
+ const navigateToNCui = async () => {
2984
+ log.debug("navigating to NCUI");
2985
+ const response = await getOne({
2986
+ urlOverride: `${URL}/api/app/kosdev.ddk/ncui/open`
2987
+ });
2988
+ return response;
2989
+ };
2990
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2405
2991
  __proto__: null,
2406
- navigateToNCui: po
2992
+ navigateToNCui
2407
2993
  }, Symbol.toStringTag, { value: "Module" }));
2408
- var js = Object.defineProperty, Ws = Object.getOwnPropertyDescriptor, go = (e, t, o, s) => {
2409
- for (var r = s > 1 ? void 0 : s ? Ws(t, o) : t, n = e.length - 1, a; n >= 0; n--)
2410
- (a = e[n]) && (r = (s ? a(t, o, r) : a(r)) || r);
2411
- return s && r && js(t, o, r), r;
2412
- };
2413
- const ho = "start-model";
2414
- let _e = class {
2415
- constructor(e, t, o) {
2416
- i(this, "id");
2417
- i(this, "logger");
2418
- i(this, "troubles");
2419
- this.id = e, this.logger = o.logger;
2994
+ var __defProp = Object.defineProperty;
2995
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2996
+ var __decorateClass = (decorators, target, key, kind) => {
2997
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
2998
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
2999
+ if (decorator = decorators[i])
3000
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
3001
+ if (kind && result) __defProp(target, key, result);
3002
+ return result;
3003
+ };
3004
+ const MODEL_TYPE = "start-model";
3005
+ let StartModelImpl = class {
3006
+ id;
3007
+ logger;
3008
+ troubles;
3009
+ constructor(modelId, options, context) {
3010
+ this.id = modelId;
3011
+ this.logger = context.logger;
2420
3012
  }
2421
3013
  get firmwareFailed() {
2422
3014
  return this.troubles.troubles.getIndexByKey(
@@ -2431,7 +3023,7 @@ let _e = class {
2431
3023
  ).length > 0;
2432
3024
  }
2433
3025
  async navigate() {
2434
- await po();
3026
+ await navigateToNCui();
2435
3027
  }
2436
3028
  // -------------------LIFECYCLE----------------------------
2437
3029
  async init() {
@@ -2441,69 +3033,70 @@ let _e = class {
2441
3033
  this.logger.debug(`loading start ${this.id}`);
2442
3034
  }
2443
3035
  };
2444
- go([
2445
- p({ modelType: Ye.type })
2446
- ], _e.prototype, "troubles", 2);
2447
- _e = go([
2448
- l(ho)
2449
- ], _e);
2450
- const fi = new He({
2451
- class: _e,
2452
- type: ho
3036
+ __decorateClass([
3037
+ kosDependency({ modelType: TroubleContainer.type })
3038
+ ], StartModelImpl.prototype, "troubles", 2);
3039
+ StartModelImpl = __decorateClass([
3040
+ kosModel(MODEL_TYPE)
3041
+ ], StartModelImpl);
3042
+ const Start = new SingletonKosModelRegistrationFactory({
3043
+ class: StartModelImpl,
3044
+ type: MODEL_TYPE
2453
3045
  });
2454
3046
  export {
2455
- Ys as AgitationControl,
2456
- sr as Animation,
2457
- Gs as AnimationServices,
2458
- Ze as Application,
2459
- Qe as Auth,
2460
- Bs as AuthServices,
2461
- ur as CarbWater,
2462
- Qs as CopyLogs,
2463
- qs as CopyLogsServices,
2464
- gi as DDKModels,
2465
- et as DashboardOperations,
2466
- Xs as DashboardOperationsServices,
2467
- Pr as Dispenser,
2468
- Lr as DispenserInfo,
2469
- Zs as DispenserInfoServices,
2470
- Js as DispenserServices,
2471
- Wo as Door,
2472
- ie as EXTENSION_POINT_DASHBOARD_KEY_FACTORY,
2473
- xr as Enrollment,
2474
- ei as EnrollmentServices,
2475
- Yr as IngredientSummary,
2476
- li as Lockout,
2477
- ai as LockoutServices,
2478
- si as MACRO_KEYS,
2479
- os as MacroAssignment,
2480
- Qt as NetworkTest,
2481
- ds as NetworkTestContainer,
2482
- di as NetworkTestServices,
2483
- gs as NutritiveSweetener,
2484
- fs as PlainWater,
2485
- Ts as Reboot,
2486
- ci as RebootServices,
2487
- Ms as Settings,
2488
- ui as SettingsServices,
2489
- wt as SetupStep,
2490
- Et as SetupStepContainer,
2491
- Ks as SetupStepServices,
2492
- fi as Start,
2493
- yi as StartServices,
2494
- ko as TROUBLE_TYPE_PRIME,
2495
- at as TROUBLE_TYPE_PURGE,
2496
- hi as TroubleActionManager,
2497
- no as Utilities,
2498
- ks as UtilitiesContainer,
2499
- pi as UtilitiesServices,
2500
- Hr as calculateTimeDifference,
2501
- Vr as executeDashboardKeyFactory,
2502
- oi as isMacroGroup,
2503
- ti as isMicroGroup,
2504
- ri as macroHolderMap,
2505
- zr as registerDashboardKeyFactory,
2506
- ni as toSeconds,
2507
- ii as toTimeComponents,
2508
- Dt as troubleVisibilityFilter
3047
+ AgitationControl,
3048
+ Animation,
3049
+ index$b as AnimationServices,
3050
+ Application,
3051
+ Auth,
3052
+ index$d as AuthServices,
3053
+ CarbWater,
3054
+ CopyLogs,
3055
+ index$a as CopyLogsServices,
3056
+ DDKModels,
3057
+ DashboardOperations,
3058
+ index$9 as DashboardOperationsServices,
3059
+ Dispenser,
3060
+ DispenserInfo,
3061
+ index$7 as DispenserInfoServices,
3062
+ index$8 as DispenserServices,
3063
+ Door,
3064
+ EXTENSION_POINT_DASHBOARD_KEY_FACTORY,
3065
+ Enrollment,
3066
+ index$6 as EnrollmentServices,
3067
+ IngredientSummary,
3068
+ Lockout,
3069
+ index$5 as LockoutServices,
3070
+ MACRO_KEYS,
3071
+ MacroAssignment,
3072
+ NetworkTest,
3073
+ NetworkTestContainer,
3074
+ index$4 as NetworkTestServices,
3075
+ NutritiveSweetener,
3076
+ PlainWater,
3077
+ Reboot,
3078
+ index$3 as RebootServices,
3079
+ Settings,
3080
+ index$2 as SettingsServices,
3081
+ SetupStep,
3082
+ SetupStepContainer,
3083
+ index$c as SetupStepServices,
3084
+ Start,
3085
+ index as StartServices,
3086
+ TROUBLE_TYPE_PRIME$1 as TROUBLE_TYPE_PRIME,
3087
+ TROUBLE_TYPE_PURGE$1 as TROUBLE_TYPE_PURGE,
3088
+ TroubleAction as TroubleActionManager,
3089
+ Utilities,
3090
+ UtilitiesContainer,
3091
+ index$1 as UtilitiesServices,
3092
+ calculateTimeDifference,
3093
+ executeDashboardKeyFactory,
3094
+ isMacroGroup,
3095
+ isMicroGroup,
3096
+ macroHolderMap,
3097
+ registerDashboardKeyFactory,
3098
+ toSeconds,
3099
+ toTimeComponents,
3100
+ troubleVisibilityFilter
2509
3101
  };
3102
+ //# sourceMappingURL=index.mjs.map