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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dispense-registration-manager-C6k10ipu.cjs +2698 -0
  2. package/dispense-registration-manager-C6k10ipu.cjs.map +1 -0
  3. package/dispense-registration-manager-lJlcyq5G.js +2700 -0
  4. package/dispense-registration-manager-lJlcyq5G.js.map +1 -0
  5. package/{extension-utils-DrsPfQWC.js → extension-utils-AS0Z5eod.js} +194 -157
  6. package/{extension-utils-DrsPfQWC.js.map → extension-utils-AS0Z5eod.js.map} +1 -1
  7. package/extension-utils-DNbm2KRk.cjs +500 -0
  8. package/{extension-utils-BDyaRwRN.cjs.map → extension-utils-DNbm2KRk.cjs.map} +1 -1
  9. package/index.cjs +142 -1
  10. package/index.cjs.map +1 -1
  11. package/index.js +124 -121
  12. package/index.js.map +1 -1
  13. package/kos-models.json +1 -1
  14. package/models/models/assembly/holder-utils.d.ts.map +1 -1
  15. package/models/models/holder/holder-model.d.ts.map +1 -1
  16. package/models/models/holder/types/index.d.ts +2 -0
  17. package/models/models/nozzle/nozzle-model.d.ts +1 -0
  18. package/models/models/nozzle/nozzle-model.d.ts.map +1 -1
  19. package/models/models/types/assembly.d.ts +1 -0
  20. package/models/models/types/assembly.d.ts.map +1 -1
  21. package/models.cjs +47 -1
  22. package/models.cjs.map +1 -1
  23. package/models.js +40 -40
  24. package/package.json +14 -2
  25. package/pump-provider-BSEusYig.js +1825 -0
  26. package/{pump-provider-Bytd6qXc.js.map → pump-provider-BSEusYig.js.map} +1 -1
  27. package/pump-provider-D4Ed_gH6.cjs +1824 -0
  28. package/{pump-provider-CTELJBW5.cjs.map → pump-provider-D4Ed_gH6.cjs.map} +1 -1
  29. package/ui.cjs +73 -1
  30. package/ui.cjs.map +1 -1
  31. package/ui.js +67 -67
  32. package/dispense-registration-manager-Cj0565Ze.cjs +0 -2
  33. package/dispense-registration-manager-Cj0565Ze.cjs.map +0 -1
  34. package/dispense-registration-manager-CzAqcL8D.js +0 -2044
  35. package/dispense-registration-manager-CzAqcL8D.js.map +0 -1
  36. package/extension-utils-BDyaRwRN.cjs +0 -2
  37. package/pump-provider-Bytd6qXc.js +0 -1308
  38. package/pump-provider-CTELJBW5.cjs +0 -2
@@ -0,0 +1,500 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => {
5
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ return value;
7
+ };
8
+ const dispenseRegistrationManager = require("./dispense-registration-manager-C6k10ipu.cjs");
9
+ const kosUiSdk = require("@kosdev-code/kos-ui-sdk");
10
+ const React = require("react");
11
+ const index$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
12
+ __proto__: null,
13
+ getIngredients: dispenseRegistrationManager.getIngredients
14
+ }, Symbol.toStringTag, { value: "Module" }));
15
+ const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
16
+ __proto__: null,
17
+ addAssignment: dispenseRegistrationManager.addAssignment,
18
+ assignHolderIngredient: dispenseRegistrationManager.assignHolderIngredient,
19
+ deleteAssignment: dispenseRegistrationManager.deleteAssignment,
20
+ getAssignments: dispenseRegistrationManager.getAssignments,
21
+ getHolders: dispenseRegistrationManager.getHolders,
22
+ replaceLine: dispenseRegistrationManager.replaceLine,
23
+ sendRfidOverride: dispenseRegistrationManager.sendRfidOverride,
24
+ unassignHolderIngredient: dispenseRegistrationManager.unassignHolderIngredient
25
+ }, Symbol.toStringTag, { value: "Module" }));
26
+ const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
27
+ __proto__: null,
28
+ getAssembly: dispenseRegistrationManager.getAssembly
29
+ }, Symbol.toStringTag, { value: "Module" }));
30
+ const index$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
31
+ __proto__: null,
32
+ getIntentVolume: dispenseRegistrationManager.getIntentVolume,
33
+ sendIntent: dispenseRegistrationManager.sendIntent
34
+ }, Symbol.toStringTag, { value: "Module" }));
35
+ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
36
+ __proto__: null,
37
+ clearPourable: dispenseRegistrationManager.clearPourable,
38
+ getAvailability: dispenseRegistrationManager.getAvailability,
39
+ pourNamedPourable: dispenseRegistrationManager.pourNamedPourable,
40
+ pourPourable: dispenseRegistrationManager.pourPourable,
41
+ selectPourable: dispenseRegistrationManager.selectPourable
42
+ }, Symbol.toStringTag, { value: "Module" }));
43
+ const assembly = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
44
+ __proto__: null
45
+ }, Symbol.toStringTag, { value: "Module" }));
46
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47
+ __proto__: null,
48
+ pourOnTarget: dispenseRegistrationManager.pourOnTarget
49
+ }, Symbol.toStringTag, { value: "Module" }));
50
+ const getFuelGaugeValue = (holder) => {
51
+ var _a, _b, _c, _d;
52
+ const [maxVolume, setMaxVolume] = React.useState(
53
+ ((_a = holder == null ? void 0 : holder.slice) == null ? void 0 : _a.maxVolMl) ?? 0
54
+ );
55
+ const [remainingVolume, setRemainingVolume] = React.useState(
56
+ ((_b = holder == null ? void 0 : holder.slice) == null ? void 0 : _b.currentVolMl) ?? 0
57
+ );
58
+ const [hasMaxVolume, setHasMaxVolume] = React.useState(
59
+ ((_c = holder == null ? void 0 : holder.slice) == null ? void 0 : _c.maxVolMl) !== void 0
60
+ );
61
+ const [hasRemainingVolume, setHasRemainingVolume] = React.useState(
62
+ ((_d = holder == null ? void 0 : holder.slice) == null ? void 0 : _d.currentVolMl) !== void 0
63
+ );
64
+ const [fillPercent, setFillPercent] = React.useState(
65
+ remainingVolume <= 0 ? 0 : Math.floor((remainingVolume || 1) / (maxVolume || 1) * 100)
66
+ );
67
+ const [hasFuelGuage, setHasFuelGuage] = React.useState(
68
+ hasMaxVolume && hasRemainingVolume
69
+ );
70
+ React.useEffect(() => {
71
+ const disposer = kosUiSdk.kosAutoEffect(() => {
72
+ var _a2, _b2, _c2, _d2;
73
+ setMaxVolume(((_a2 = holder == null ? void 0 : holder.slice) == null ? void 0 : _a2.maxVolMl) ?? 0);
74
+ setRemainingVolume(((_b2 = holder == null ? void 0 : holder.slice) == null ? void 0 : _b2.currentVolMl) ?? 0);
75
+ setHasMaxVolume(((_c2 = holder == null ? void 0 : holder.slice) == null ? void 0 : _c2.maxVolMl) !== void 0);
76
+ setHasRemainingVolume(((_d2 = holder == null ? void 0 : holder.slice) == null ? void 0 : _d2.currentVolMl) !== void 0);
77
+ setFillPercent(
78
+ remainingVolume <= 0 ? 0 : Math.floor((remainingVolume || 1) / (maxVolume || 1) * 100)
79
+ );
80
+ setHasFuelGuage(hasMaxVolume && hasRemainingVolume);
81
+ });
82
+ return () => {
83
+ disposer();
84
+ };
85
+ }, [holder]);
86
+ return { maxVolume, remainingVolume, fillPercent, hasFuelGuage };
87
+ };
88
+ class DispenseExtensionManager {
89
+ constructor() {
90
+ __publicField(this, "core", new kosUiSdk.CoreExtensionManager());
91
+ }
92
+ /**
93
+ * Maps data into the {@link IngredientModel}
94
+ *
95
+ * It is common for the ingredient data provided by the ingredient service to be augmented with additional properties that are
96
+ * not provided by the base KOS Ingredient model. The {@link IngredientMapper} extension point allows for the data to be mapped
97
+ * into the {@link IngredientModel} and the {@link IngredientModel.data} property to be augmented with additional properties.
98
+ *
99
+ * @param ingredientDataMapper - Mapping function that maps an {@link IngredientResponse} into additional model data
100
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
101
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
102
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
103
+ * @returns this instance for chaining
104
+ *
105
+ * @example
106
+ * The following example shows how to map the data from the service response into the {@link IngredientModel}.
107
+ * The context is provided by the {@link IngredientLoader} extension point with its data being used to optionally augment the
108
+ * ingredient data.
109
+ *
110
+ * The result of the mapping will be available in the `data` property of the {@link IngredientModel}.
111
+ *
112
+ * In this case the `IngedientReponseData` interface represents the data being returned by the ingredient service and the
113
+ * `IngredientData` interface represents the data that will be available in the {@link IngredientModel.data} property. The `ingredientDataMapper`
114
+ * is responsible for mapping from one format to the other.
115
+ *
116
+ * ```typescript
117
+ *
118
+ * interface IngredientResponseData extends NozzleServices.IngredientResponse {
119
+ * chilled: boolean;
120
+ * carbonated: boolean;
121
+ * highYield: boolean;
122
+ * }
123
+ *
124
+ * interface IngredientData {
125
+ * chilled: boolean;
126
+ * carbonated: boolean;
127
+ * highYield: boolean;
128
+ * }
129
+ *
130
+ * export const ingredientDataMapper = async (
131
+ * data: IngredientResponseData,
132
+ * context: IngredientContext
133
+ * ): Promise<IngredientData> => {
134
+ * return {
135
+ * chilled: data.chilled,
136
+ * carbonated: data.carbonated,
137
+ * highYield: data.highYield,
138
+ * }
139
+ * }
140
+ * ```
141
+ * */
142
+ registerIngredientDataMapper(ingredientDataMapper, options) {
143
+ kosUiSdk.ExtensionManager.dataMapper.registerDataMapper(
144
+ dispenseRegistrationManager.ExtensionType.IngredientMapper,
145
+ ingredientDataMapper,
146
+ options
147
+ );
148
+ return this;
149
+ }
150
+ /**
151
+ * Loads data that will be provided as context into the {@link IngredientMapper}.
152
+ *
153
+ * @param ingredientLoader - Async function that loads and returns ingredient context data
154
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
155
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on loader failure.
156
+ * Set to `"continue"` to log the error and return `undefined` instead.
157
+ * @returns this instance for chaining
158
+ *
159
+ * @example
160
+ * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework
161
+ * where it can be used by the other extension points.
162
+ *
163
+ * In the ingredient container model, the data is provided to the {@link IngredientMapper} extension point in order to augment ingredient data
164
+ * and also loaded into the ingredient container model context in order to make the data available throughout the code.
165
+ *
166
+ * ```typescript
167
+ * export const ingredientContextLoader = async (): Promise<BeverageContext> => {
168
+ * const response = await kosFetch('kos:/system/some/ingredient/endpoint.json');
169
+ *
170
+ * if (response.status !== 200) {
171
+ * KosLog.error('Failed to load ingredient data');
172
+ * return {};
173
+ * }
174
+ * const json = await response.json();
175
+ * return json;
176
+ * };
177
+ * ```
178
+ * */
179
+ registerIngredientLoader(ingredientLoader, options) {
180
+ kosUiSdk.ExtensionManager.loader.registerLoader(
181
+ dispenseRegistrationManager.ExtensionType.IngredientLoader,
182
+ ingredientLoader,
183
+ options
184
+ );
185
+ return this;
186
+ }
187
+ registerIngredientIndex(ingredientIndex) {
188
+ kosUiSdk.ExtensionManager.indexExtension.registerIndexExtension(
189
+ dispenseRegistrationManager.ExtensionType.IngredientIndex,
190
+ ingredientIndex
191
+ );
192
+ return this;
193
+ }
194
+ /**
195
+ * Registers a property mapper that derives the `type` property of the {@link IngredientModel}
196
+ * from an {@link IngredientResponse}.
197
+ *
198
+ * @param ingredientTypeMapper - Mapping function that extracts a type string from an {@link IngredientResponse}
199
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
200
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
201
+ * Set to `"continue"` to log the error and return a fallback value instead.
202
+ * @returns this instance for chaining
203
+ * */
204
+ registerIngredientTypeMapper(ingredientTypeMapper, options) {
205
+ kosUiSdk.ExtensionManager.propertyMapper.registerPropertyMapper(
206
+ dispenseRegistrationManager.ExtensionType.IngredientTypeMapper,
207
+ ingredientTypeMapper,
208
+ options
209
+ );
210
+ return this;
211
+ }
212
+ /**
213
+ * Registers a data mapper for the {@link HolderModel} model.
214
+ *
215
+ * @param holderDataMapper - Mapping function that maps additional data from a {@link HolderResponse}
216
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
217
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
218
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
219
+ * @returns this instance for chaining
220
+ */
221
+ registerHolderDataMapper(holderDataMapper, options) {
222
+ kosUiSdk.ExtensionManager.dataMapper.registerDataMapper(
223
+ dispenseRegistrationManager.ExtensionType.HolderMapper,
224
+ holderDataMapper,
225
+ options
226
+ );
227
+ return this;
228
+ }
229
+ /**
230
+ * Registers a property mapper that derives the `type` property of the {@link HolderModel}
231
+ * from a {@link HolderResponse}.
232
+ *
233
+ * @param holderTypeMapper - Mapping function that extracts a type string from a {@link HolderResponse}
234
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
235
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
236
+ * Set to `"continue"` to log the error and return a fallback value instead.
237
+ * @returns this instance for chaining
238
+ */
239
+ registerHolderTypeMapper(holderTypeMapper, options) {
240
+ kosUiSdk.ExtensionManager.propertyMapper.registerPropertyMapper(
241
+ dispenseRegistrationManager.ExtensionType.HolderTypeMapper,
242
+ holderTypeMapper,
243
+ options
244
+ );
245
+ return this;
246
+ }
247
+ /**
248
+ * Maps the ingredientId property of the holder into the {@link HolderModel}.
249
+ * If not provided, the ingredientId will assume that the value is mapped from the
250
+ * ingredientId property of the service response.
251
+ *
252
+ * @param holderTypeMapper - Mapping function that extracts the ingredientId from a {@link HolderResponse}
253
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
254
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
255
+ * Set to `"continue"` to log the error and return a fallback value instead.
256
+ * @returns this instance for chaining
257
+ * */
258
+ registerHolderIngredientMapper(holderTypeMapper, options) {
259
+ kosUiSdk.ExtensionManager.propertyMapper.registerPropertyMapper(
260
+ dispenseRegistrationManager.ExtensionType.HolderTypeMapper,
261
+ holderTypeMapper,
262
+ options
263
+ );
264
+ return this;
265
+ }
266
+ registerHolderIndex(holderIndex) {
267
+ kosUiSdk.ExtensionManager.indexExtension.registerIndexExtension(
268
+ dispenseRegistrationManager.ExtensionType.HolderIndex,
269
+ holderIndex
270
+ );
271
+ return this;
272
+ }
273
+ /**
274
+ * Maps data into the {@link AvailabilityModel}.
275
+ *
276
+ * @param availabilityMapper - Mapping function that maps a {@link GroupBeverageResponse} into additional availability data
277
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
278
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
279
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
280
+ * @returns this instance for chaining
281
+ *
282
+ * @example
283
+ * The following example shows how to map the data from the service response into the {@link AvailabilityModel}.
284
+ * The context is provided by the {@link AvailabilityLoader} extension point with its data being used to augment the
285
+ * availability data.
286
+ *
287
+ * The result of the mapping will be available in the `data` property of the {@link AvailabilityModel}.
288
+ *
289
+ * ```typescript
290
+ * export const beverageDataMapper = async (
291
+ * data: NozzleServices.BeverageResponse,
292
+ * context: BeverageContext
293
+ * ): Promise<BeverageData> => {
294
+ * const id = data.altId;
295
+ * const iconUrl = encodeURI(
296
+ * `http://localhost:8081/system/brandset/${context?.[id]?.icon}`
297
+ * );
298
+ * const cuiColorCode = context?.[id]?.cuiColorCode
299
+ * ? context?.[id]?.cuiColorCode
300
+ * : '';
301
+ * return { iconUrl, cuiColorCode };
302
+ * };
303
+ * ```
304
+ * */
305
+ registerAvailabilityDataMapper(availabilityMapper, options) {
306
+ kosUiSdk.ExtensionManager.dataMapper.registerDataMapper(
307
+ dispenseRegistrationManager.ExtensionType.AvailabilityMapper,
308
+ availabilityMapper,
309
+ options
310
+ );
311
+ return this;
312
+ }
313
+ /**
314
+ * Loads data that will be provided as context into the {@link AvailabilityMapper}.
315
+ *
316
+ * @param availabilityLoader - Async function that loads and returns availability context data
317
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
318
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on loader failure.
319
+ * Set to `"continue"` to log the error and return `undefined` instead.
320
+ * @returns this instance for chaining
321
+ *
322
+ * @example
323
+ * A common use case is to load brandset data that is UI specific and not provided directly by the Java service.
324
+ *
325
+ * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework
326
+ * where it can be used by the other extension points.
327
+ *
328
+ * In the nozzle model, the data is provided to the {@link AvailabilityMapper} extension point in order to augment availability data
329
+ * and also loaded into the nozzle model context in order to make the data available throughout the code.
330
+ *
331
+ * ```typescript
332
+ * export const beverageContextLoader = async (): Promise<BeverageContext> => {
333
+ * const response = await kosFetch('kos:/system/brandset/brandset.json');
334
+ *
335
+ * if (response.status !== 200) {
336
+ * KosLog.error('Failed to load beverage data');
337
+ * return {};
338
+ * }
339
+ * const json: BrandsetResponse | null = await response.json();
340
+ * const initialBeverages: Record<string, BrandsetIngredient> = {};
341
+ * const beverages = json?.ingredients?.reduce((acc, beverage) => {
342
+ * acc[beverage.ingredientId] = beverage;
343
+ * return acc;
344
+ * }, initialBeverages);
345
+ * return beverages;
346
+ * };
347
+ * ```
348
+ * */
349
+ registerAvailabilityLoader(availabilityLoader, options) {
350
+ kosUiSdk.ExtensionManager.loader.registerLoader(
351
+ dispenseRegistrationManager.ExtensionType.AvailabilityLoader,
352
+ availabilityLoader,
353
+ options
354
+ );
355
+ return this;
356
+ }
357
+ /**
358
+ * Maps the abstract {@link SelectedPourable} data into a format that is specific to the nozzle.
359
+ *
360
+ * @param selectedPourableMapper - Mapping function that transforms {@link SelectedPourable} data
361
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
362
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
363
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
364
+ * @returns this instance for chaining
365
+ * */
366
+ registerSelectedPourableDataMapper(selectedPourableMapper, options) {
367
+ kosUiSdk.ExtensionManager.dataMapper.registerDataMapper(
368
+ dispenseRegistrationManager.ExtensionType.SelectedPourableMapper,
369
+ selectedPourableMapper,
370
+ options
371
+ );
372
+ return this;
373
+ }
374
+ /**
375
+ * Maps data into the {@link AssemblyModel} data.
376
+ * Used in cases where the base assembly has been extended with additional properties in the backend. This extension
377
+ * point allows for the data to be mapped into the {@link AssemblyModel} and augmented with additional properties.
378
+ *
379
+ * @param assemblyDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyResponse} into additional assembly data
380
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
381
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
382
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
383
+ * @returns this instance for chaining
384
+ *
385
+ * @example
386
+ *
387
+ * In this example of an implementation of a {@link AssemblyMapper}, the {@link AssemblyResponse} data is mapped into
388
+ * a {@link FreestyleAssembly} object.
389
+ *
390
+ * The {@link FreestyleAssemblyResponse} interface represents the additional data being returned by the assembly service and is
391
+ * merged into the {@link AssemblyResponse} interface.
392
+ *
393
+ * The {@link FreestyleAssembly} interface represents the additional data, beyond the base data set, that will be merged into the {@link AssemblyModel}.
394
+ *
395
+ * The mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.
396
+ * ```typescript
397
+ * import { AssemblyTypes } from "@kosdev-code/kos-dispense-sdk";
398
+ * import { DataMapper } from "@kosdev-code/kos-ui-sdk";
399
+ *
400
+ * // define the additional data being returned by the assembly service
401
+ * export interface FreestyleAssemblyResponse {
402
+ * iceAgitator?: {
403
+ * name: "iceAgitator";
404
+ * path: string;
405
+ * };
406
+ * }
407
+ *
408
+ * // define the additional data structure that will be merged into the assembly model
409
+ * export interface FreestyleAssembly {
410
+ * iceAgitator: {
411
+ * path: string;
412
+ * };
413
+ * carbAgitator: {
414
+ * path: string;
415
+ * };
416
+ * }
417
+ *
418
+ *
419
+ * // define the mapper that will map the data from the service response into the additional data structure
420
+ * // that will be merged into the assembly model.
421
+ * // In this case the mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.
422
+ * export const assemblyDataMapper: DataMapper<
423
+ * AssemblyTypes.AssemblyResponse<FreestyleAssemblyResponse>,
424
+ * FreestyleAssembly
425
+ * > = async (data) => {
426
+ * const response = data.assemblies.reduce((acc, assembly) => {
427
+ * const agitatorKeys = ["iceAgitator", "carbAgitator"];
428
+ * agitatorKeys.forEach((key) => {
429
+ * const agitator = assembly[key];
430
+ * if (agitator) {
431
+ * acc[key] = agitator;
432
+ * }
433
+ * });
434
+ *
435
+ * return acc;
436
+ * }, {} as FreestyleAssembly);
437
+ * return response;
438
+ * };
439
+ *```
440
+ */
441
+ registerAssemblyDataMapper(assemblyDataMapper, options) {
442
+ kosUiSdk.ExtensionManager.dataMapper.registerDataMapper(
443
+ dispenseRegistrationManager.ExtensionType.AssemblyMapper,
444
+ assemblyDataMapper,
445
+ options
446
+ );
447
+ return this;
448
+ }
449
+ registerBoardIndex(boardIndex) {
450
+ kosUiSdk.ExtensionManager.indexExtension.registerIndexExtension(
451
+ dispenseRegistrationManager.ExtensionType.BoardIndex,
452
+ boardIndex
453
+ );
454
+ return this;
455
+ }
456
+ /**
457
+ * Registers a data mapper for the board model within an assembly.
458
+ *
459
+ * @param boardDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyBoard} into additional board data
460
+ * @param options - Optional {@link ExtensionOptions} to control failure behavior.
461
+ * Defaults to `failurePolicy: "throw"`, which throws an {@link ExtensionException} on mapper failure.
462
+ * Set to `"continue"` to log the error and continue processing remaining mappers.
463
+ * @returns this instance for chaining
464
+ */
465
+ registerBoardDataMapper(boardDataMapper, options) {
466
+ kosUiSdk.ExtensionManager.dataMapper.registerDataMapper(
467
+ dispenseRegistrationManager.ExtensionType.BoardMapper,
468
+ boardDataMapper,
469
+ options
470
+ );
471
+ return this;
472
+ }
473
+ registerAssemblyFeatureFlagResolver(assemblyFeatureFlagResolver) {
474
+ var _a;
475
+ (_a = kosUiSdk.ExtensionManager[kosUiSdk.EXTENSION_FEATURE_FLAG_RESOLVER]) == null ? void 0 : _a.register(
476
+ dispenseRegistrationManager.ExtensionType.AssemblyFeatureFlags,
477
+ assemblyFeatureFlagResolver
478
+ );
479
+ return this;
480
+ }
481
+ }
482
+ class KosExtensionManager {
483
+ constructor() {
484
+ __publicField(this, "dispense");
485
+ __publicField(this, "core");
486
+ this.dispense = new DispenseExtensionManager();
487
+ this.core = new kosUiSdk.CoreExtensionManager();
488
+ }
489
+ }
490
+ exports.DispenseExtensionManager = DispenseExtensionManager;
491
+ exports.KosExtensionManager = KosExtensionManager;
492
+ exports.assembly = assembly;
493
+ exports.getFuelGaugeValue = getFuelGaugeValue;
494
+ exports.index = index$3;
495
+ exports.index$1 = index;
496
+ exports.index$2 = index$4;
497
+ exports.index$3 = index$5;
498
+ exports.index$4 = index$1;
499
+ exports.index$5 = index$2;
500
+ //# sourceMappingURL=extension-utils-DNbm2KRk.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension-utils-BDyaRwRN.cjs","sources":["../../../../packages/sdk/kos-dispense-sdk/src/models/models/holder/utils/holder-utils.ts","../../../../packages/sdk/kos-dispense-sdk/src/models/utils/extension-utils.ts"],"sourcesContent":["import { kosAutoEffect } from \"@kosdev-code/kos-ui-sdk\";\nimport { useEffect, useState } from \"react\";\nimport type { HolderModel } from \"../types\";\n\nexport const getFuelGaugeValue = (holder: HolderModel) => {\n const [maxVolume, setMaxVolume] = useState<number>(\n holder?.slice?.maxVolMl ?? 0\n );\n const [remainingVolume, setRemainingVolume] = useState<number>(\n holder?.slice?.currentVolMl ?? 0\n );\n\n const [hasMaxVolume, setHasMaxVolume] = useState<boolean>(\n holder?.slice?.maxVolMl !== undefined\n );\n\n const [hasRemainingVolume, setHasRemainingVolume] = useState<boolean>(\n holder?.slice?.currentVolMl !== undefined\n );\n\n const [fillPercent, setFillPercent] = useState<number>(\n remainingVolume <= 0\n ? 0\n : Math.floor(((remainingVolume || 1) / (maxVolume || 1)) * 100)\n );\n\n const [hasFuelGuage, setHasFuelGuage] = useState<boolean>(\n hasMaxVolume && hasRemainingVolume\n );\n\n useEffect(() => {\n const disposer = kosAutoEffect(() => {\n setMaxVolume(holder?.slice?.maxVolMl ?? 0);\n setRemainingVolume(holder?.slice?.currentVolMl ?? 0);\n setHasMaxVolume(holder?.slice?.maxVolMl !== undefined);\n setHasRemainingVolume(holder?.slice?.currentVolMl !== undefined);\n setFillPercent(\n remainingVolume <= 0\n ? 0\n : Math.floor(((remainingVolume || 1) / (maxVolume || 1)) * 100)\n );\n setHasFuelGuage(hasMaxVolume && hasRemainingVolume);\n });\n\n return () => {\n disposer();\n };\n }, [holder]);\n\n return { maxVolume, remainingVolume, fillPercent, hasFuelGuage };\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n CoreExtensionManager,\n DataLoader,\n DataMapper,\n EXTENSION_FEATURE_FLAG_RESOLVER,\n ExtensionManager,\n ExtensionOptions,\n IndexExtension,\n PropertyMapper,\n type FlagResolver,\n} from \"@kosdev-code/kos-ui-sdk\";\nimport { ExtensionType } from \"../constants\";\nimport { AssemblyTypes, type AssemblyModel } from \"../models\";\nimport type { HolderResponse } from \"../models/holder/services\";\nimport type { HolderModel } from \"../models/holder/types\";\nimport type { IngredientResponse } from \"../models/ingredient/services\";\nimport type { BeverageResponse } from \"../models/nozzle/services\";\nimport type { SelectedPourable } from \"../models/nozzle/types\";\n\nexport type IngredientDataMapper<\n AdditionalData extends object = Record<string, any>\n> = DataMapper<IngredientResponse, AdditionalData, any>;\n\n/**\n * Mapping function that maps an ingredient response into the type property of\n * the {@link IngredientModel}.\n */\nexport type IngredientTypeMapper<\n T extends IngredientResponse = IngredientResponse\n> = PropertyMapper<T, string>;\n\n/**\n * Mapping function that maps additional data from holder service response\n * into the {@link HolderModel} data.\n */\nexport type HolderTypeMapper<T extends HolderResponse = HolderResponse> =\n PropertyMapper<T, string>;\n\n/**\n * Mapping function that maps additional data from holder service response\n * into the {@link HolderModel} data.\n */\nexport type HolderDataMapper<\n AdditionalData extends object = Record<string, any>,\n HolderData extends HolderResponse = HolderResponse\n> = DataMapper<HolderData, AdditionalData, any>;\n\nexport type GroupBeverageResponse = BeverageResponse & { groupId: string };\nexport type AvailabilityDataMapper<\n AdditionalData extends object = Record<string, any>,\n AvailabilityData extends GroupBeverageResponse = GroupBeverageResponse\n> = DataMapper<AvailabilityData, AdditionalData, any>;\n\nexport type SelectedPourableMapper = DataMapper<SelectedPourable, any>;\n\nexport type BoardDataMapper<\n AdditionalData extends object = Record<string, any>,\n BoardData extends AssemblyTypes.AssemblyBoard<any> = AssemblyTypes.AssemblyBoard<any>\n> = DataMapper<BoardData, AdditionalData, any>;\n\nexport type AssemblyMapper<\n AdditionalData extends object = Record<string, any>,\n AssemblyResponseData extends AssemblyTypes.AssemblyResponse<any> = AssemblyTypes.AssemblyResponse<any>\n> = DataMapper<AssemblyResponseData, AdditionalData, any>;\n/**\n * The DispenseExtensionManager is responsible for managing the extension points that are specific to the Dispense application.\n */\nexport class DispenseExtensionManager {\n core: CoreExtensionManager = new CoreExtensionManager();\n /**\n * Maps data into the {@link IngredientModel}\n *\n * It is common for the ingredient data provided by the ingredient service to be augmented with additional properties that are\n * not provided by the base KOS Ingredient model. The {@link IngredientMapper} extension point allows for the data to be mapped\n * into the {@link IngredientModel} and the {@link IngredientModel.data} property to be augmented with additional properties.\n *\n * @param ingredientDataMapper - Mapping function that maps an {@link IngredientResponse} into additional model data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n *\n * @example\n * The following example shows how to map the data from the service response into the {@link IngredientModel}.\n * The context is provided by the {@link IngredientLoader} extension point with its data being used to optionally augment the\n * ingredient data.\n *\n * The result of the mapping will be available in the `data` property of the {@link IngredientModel}.\n *\n * In this case the `IngedientReponseData` interface represents the data being returned by the ingredient service and the\n * `IngredientData` interface represents the data that will be available in the {@link IngredientModel.data} property. The `ingredientDataMapper`\n * is responsible for mapping from one format to the other.\n *\n * ```typescript\n *\n * interface IngredientResponseData extends NozzleServices.IngredientResponse {\n * chilled: boolean;\n * carbonated: boolean;\n * highYield: boolean;\n * }\n *\n * interface IngredientData {\n * chilled: boolean;\n * carbonated: boolean;\n * highYield: boolean;\n * }\n *\n * export const ingredientDataMapper = async (\n * data: IngredientResponseData,\n * context: IngredientContext\n * ): Promise<IngredientData> => {\n * return {\n * chilled: data.chilled,\n * carbonated: data.carbonated,\n * highYield: data.highYield,\n * }\n * }\n * ```\n * */\n registerIngredientDataMapper(\n ingredientDataMapper: IngredientDataMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.IngredientMapper,\n ingredientDataMapper,\n options\n );\n\n return this;\n }\n\n /**\n * Loads data that will be provided as context into the {@link IngredientMapper}.\n *\n * @param ingredientLoader - Async function that loads and returns ingredient context data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on loader failure.\n * Set to `\"continue\"` to log the error and return `undefined` instead.\n * @returns this instance for chaining\n *\n * @example\n * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework\n * where it can be used by the other extension points.\n *\n * In the ingredient container model, the data is provided to the {@link IngredientMapper} extension point in order to augment ingredient data\n * and also loaded into the ingredient container model context in order to make the data available throughout the code.\n *\n * ```typescript\n * export const ingredientContextLoader = async (): Promise<BeverageContext> => {\n * const response = await kosFetch('kos:/system/some/ingredient/endpoint.json');\n *\n * if (response.status !== 200) {\n * KosLog.error('Failed to load ingredient data');\n * return {};\n * }\n * const json = await response.json();\n * return json;\n * };\n * ```\n * */\n registerIngredientLoader(\n ingredientLoader: DataLoader,\n options?: ExtensionOptions\n ) {\n ExtensionManager.loader.registerLoader(\n ExtensionType.IngredientLoader,\n ingredientLoader,\n options\n );\n return this;\n }\n\n registerIngredientIndex(ingredientIndex: IndexExtension) {\n ExtensionManager.indexExtension.registerIndexExtension(\n ExtensionType.IngredientIndex,\n ingredientIndex\n );\n return this;\n }\n\n /**\n * Registers a property mapper that derives the `type` property of the {@link IngredientModel}\n * from an {@link IngredientResponse}.\n *\n * @param ingredientTypeMapper - Mapping function that extracts a type string from an {@link IngredientResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and return a fallback value instead.\n * @returns this instance for chaining\n * */\n registerIngredientTypeMapper(\n ingredientTypeMapper: IngredientTypeMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.propertyMapper.registerPropertyMapper(\n ExtensionType.IngredientTypeMapper,\n ingredientTypeMapper,\n options\n );\n return this;\n }\n\n /**\n * Registers a data mapper for the {@link HolderModel} model.\n *\n * @param holderDataMapper - Mapping function that maps additional data from a {@link HolderResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n */\n registerHolderDataMapper(\n holderDataMapper: HolderDataMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.HolderMapper,\n holderDataMapper,\n options\n );\n return this;\n }\n\n /**\n * Registers a property mapper that derives the `type` property of the {@link HolderModel}\n * from a {@link HolderResponse}.\n *\n * @param holderTypeMapper - Mapping function that extracts a type string from a {@link HolderResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and return a fallback value instead.\n * @returns this instance for chaining\n */\n registerHolderTypeMapper(\n holderTypeMapper: HolderTypeMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.propertyMapper.registerPropertyMapper(\n ExtensionType.HolderTypeMapper,\n holderTypeMapper,\n options\n );\n return this;\n }\n\n /**\n * Maps the ingredientId property of the holder into the {@link HolderModel}.\n * If not provided, the ingredientId will assume that the value is mapped from the\n * ingredientId property of the service response.\n *\n * @param holderTypeMapper - Mapping function that extracts the ingredientId from a {@link HolderResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and return a fallback value instead.\n * @returns this instance for chaining\n * */\n registerHolderIngredientMapper(\n holderTypeMapper: HolderTypeMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.propertyMapper.registerPropertyMapper(\n ExtensionType.HolderTypeMapper,\n holderTypeMapper,\n options\n );\n return this;\n }\n\n registerHolderIndex<T extends HolderModel = HolderModel>(\n holderIndex: IndexExtension<T>\n ) {\n ExtensionManager.indexExtension.registerIndexExtension(\n ExtensionType.HolderIndex,\n holderIndex\n );\n return this;\n }\n\n /**\n * Maps data into the {@link AvailabilityModel}.\n *\n * @param availabilityMapper - Mapping function that maps a {@link GroupBeverageResponse} into additional availability data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n *\n * @example\n * The following example shows how to map the data from the service response into the {@link AvailabilityModel}.\n * The context is provided by the {@link AvailabilityLoader} extension point with its data being used to augment the\n * availability data.\n *\n * The result of the mapping will be available in the `data` property of the {@link AvailabilityModel}.\n *\n * ```typescript\n * export const beverageDataMapper = async (\n * data: NozzleServices.BeverageResponse,\n * context: BeverageContext\n * ): Promise<BeverageData> => {\n * const id = data.altId;\n * const iconUrl = encodeURI(\n * `http://localhost:8081/system/brandset/${context?.[id]?.icon}`\n * );\n * const cuiColorCode = context?.[id]?.cuiColorCode\n * ? context?.[id]?.cuiColorCode\n * : '';\n * return { iconUrl, cuiColorCode };\n * };\n * ```\n * */\n registerAvailabilityDataMapper(\n availabilityMapper: AvailabilityDataMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.AvailabilityMapper,\n availabilityMapper,\n options\n );\n return this;\n }\n\n /**\n * Loads data that will be provided as context into the {@link AvailabilityMapper}.\n *\n * @param availabilityLoader - Async function that loads and returns availability context data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on loader failure.\n * Set to `\"continue\"` to log the error and return `undefined` instead.\n * @returns this instance for chaining\n *\n * @example\n * A common use case is to load brandset data that is UI specific and not provided directly by the Java service.\n *\n * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework\n * where it can be used by the other extension points.\n *\n * In the nozzle model, the data is provided to the {@link AvailabilityMapper} extension point in order to augment availability data\n * and also loaded into the nozzle model context in order to make the data available throughout the code.\n *\n * ```typescript\n * export const beverageContextLoader = async (): Promise<BeverageContext> => {\n * const response = await kosFetch('kos:/system/brandset/brandset.json');\n *\n * if (response.status !== 200) {\n * KosLog.error('Failed to load beverage data');\n * return {};\n * }\n * const json: BrandsetResponse | null = await response.json();\n * const initialBeverages: Record<string, BrandsetIngredient> = {};\n * const beverages = json?.ingredients?.reduce((acc, beverage) => {\n * acc[beverage.ingredientId] = beverage;\n * return acc;\n * }, initialBeverages);\n * return beverages;\n * };\n * ```\n * */\n registerAvailabilityLoader(\n availabilityLoader: DataLoader,\n options?: ExtensionOptions\n ) {\n ExtensionManager.loader.registerLoader(\n ExtensionType.AvailabilityLoader,\n availabilityLoader,\n options\n );\n return this;\n }\n\n /**\n * Maps the abstract {@link SelectedPourable} data into a format that is specific to the nozzle.\n *\n * @param selectedPourableMapper - Mapping function that transforms {@link SelectedPourable} data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n * */\n registerSelectedPourableDataMapper(\n selectedPourableMapper: SelectedPourableMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.SelectedPourableMapper,\n selectedPourableMapper,\n options\n );\n return this;\n }\n\n /**\n * Maps data into the {@link AssemblyModel} data.\n * Used in cases where the base assembly has been extended with additional properties in the backend. This extension\n * point allows for the data to be mapped into the {@link AssemblyModel} and augmented with additional properties.\n *\n * @param assemblyDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyResponse} into additional assembly data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n *\n * @example\n *\n * In this example of an implementation of a {@link AssemblyMapper}, the {@link AssemblyResponse} data is mapped into\n * a {@link FreestyleAssembly} object.\n *\n * The {@link FreestyleAssemblyResponse} interface represents the additional data being returned by the assembly service and is\n * merged into the {@link AssemblyResponse} interface.\n *\n * The {@link FreestyleAssembly} interface represents the additional data, beyond the base data set, that will be merged into the {@link AssemblyModel}.\n *\n * The mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.\n * ```typescript\n * import { AssemblyTypes } from \"@kosdev-code/kos-dispense-sdk\";\n * import { DataMapper } from \"@kosdev-code/kos-ui-sdk\";\n *\n * // define the additional data being returned by the assembly service\n * export interface FreestyleAssemblyResponse {\n * iceAgitator?: {\n * name: \"iceAgitator\";\n * path: string;\n * };\n * }\n *\n * // define the additional data structure that will be merged into the assembly model\n * export interface FreestyleAssembly {\n * iceAgitator: {\n * path: string;\n * };\n * carbAgitator: {\n * path: string;\n * };\n * }\n *\n *\n * // define the mapper that will map the data from the service response into the additional data structure\n * // that will be merged into the assembly model.\n * // In this case the mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.\n * export const assemblyDataMapper: DataMapper<\n * AssemblyTypes.AssemblyResponse<FreestyleAssemblyResponse>,\n * FreestyleAssembly\n * > = async (data) => {\n * const response = data.assemblies.reduce((acc, assembly) => {\n * const agitatorKeys = [\"iceAgitator\", \"carbAgitator\"];\n * agitatorKeys.forEach((key) => {\n * const agitator = assembly[key];\n * if (agitator) {\n * acc[key] = agitator;\n * }\n * });\n *\n * return acc;\n * }, {} as FreestyleAssembly);\n * return response;\n * };\n *```\n */\n registerAssemblyDataMapper(\n assemblyDataMapper: AssemblyMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.AssemblyMapper,\n assemblyDataMapper,\n options\n );\n return this;\n }\n\n registerBoardIndex(boardIndex: IndexExtension) {\n ExtensionManager.indexExtension.registerIndexExtension(\n ExtensionType.BoardIndex,\n boardIndex\n );\n return this;\n }\n\n /**\n * Registers a data mapper for the board model within an assembly.\n *\n * @param boardDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyBoard} into additional board data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n */\n registerBoardDataMapper(\n boardDataMapper: BoardDataMapper<any, any>,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.BoardMapper,\n boardDataMapper,\n options\n );\n return this;\n }\n\n registerAssemblyFeatureFlagResolver(\n assemblyFeatureFlagResolver: FlagResolver<AssemblyModel>\n ) {\n ExtensionManager[EXTENSION_FEATURE_FLAG_RESOLVER]?.register(\n ExtensionType.AssemblyFeatureFlags,\n assemblyFeatureFlagResolver\n );\n return this;\n }\n}\n\n/**\n * The KosExtensionManager provides access to the extension points that are provided in the SDK for Dispense applications.\n *\n * The extension points are divided into two categories:\n *\n * @param core - The core extension {@link CoreExtensionManager} points are used to extend the base models that are provided by the SDK.\n * @param dispense - The dispense extension {@link DispenseExtensionManager} points are used to extend the models that are specific to the Dispense SDK.\n */\nexport class KosExtensionManager {\n dispense: DispenseExtensionManager;\n core: CoreExtensionManager;\n constructor() {\n this.dispense = new DispenseExtensionManager();\n this.core = new CoreExtensionManager();\n }\n}\n"],"names":["getFuelGaugeValue","holder","maxVolume","setMaxVolume","useState","_a","remainingVolume","setRemainingVolume","_b","hasMaxVolume","setHasMaxVolume","_c","hasRemainingVolume","setHasRemainingVolume","_d","fillPercent","setFillPercent","hasFuelGuage","setHasFuelGuage","useEffect","disposer","kosAutoEffect","DispenseExtensionManager","__publicField","CoreExtensionManager","ingredientDataMapper","options","ExtensionManager","ExtensionType","ingredientLoader","ingredientIndex","ingredientTypeMapper","holderDataMapper","holderTypeMapper","holderIndex","availabilityMapper","availabilityLoader","selectedPourableMapper","assemblyDataMapper","boardIndex","boardDataMapper","assemblyFeatureFlagResolver","EXTENSION_FEATURE_FLAG_RESOLVER","KosExtensionManager"],"mappings":"sgDAIaA,EAAqBC,GAAwB,aACxD,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAAAA,WAChCC,EAAAJ,GAAA,YAAAA,EAAQ,QAAR,YAAAI,EAAe,WAAY,CAAA,EAEvB,CAACC,EAAiBC,CAAkB,EAAIH,EAAAA,WAC5CI,EAAAP,GAAA,YAAAA,EAAQ,QAAR,YAAAO,EAAe,eAAgB,CAAA,EAG3B,CAACC,EAAcC,CAAe,EAAIN,EAAAA,WACtCO,EAAAV,GAAA,YAAAA,EAAQ,QAAR,YAAAU,EAAe,YAAa,MAAA,EAGxB,CAACC,EAAoBC,CAAqB,EAAIT,EAAAA,WAClDU,EAAAb,GAAA,YAAAA,EAAQ,QAAR,YAAAa,EAAe,gBAAiB,MAAA,EAG5B,CAACC,EAAaC,CAAc,EAAIZ,EAAAA,SACpCE,GAAmB,EACf,EACA,KAAK,OAAQA,GAAmB,IAAMJ,GAAa,GAAM,GAAG,CAAA,EAG5D,CAACe,EAAcC,CAAe,EAAId,EAAAA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A,EAAA,aAEE,KAAK,SAAW,IAAID,EACpB,KAAK,KAAO,IAAIE,sBAClB,CACF"}
1
+ {"version":3,"file":"extension-utils-DNbm2KRk.cjs","sources":["../../../../packages/sdk/kos-dispense-sdk/src/models/models/holder/utils/holder-utils.ts","../../../../packages/sdk/kos-dispense-sdk/src/models/utils/extension-utils.ts"],"sourcesContent":["import { kosAutoEffect } from \"@kosdev-code/kos-ui-sdk\";\nimport { useEffect, useState } from \"react\";\nimport type { HolderModel } from \"../types\";\n\nexport const getFuelGaugeValue = (holder: HolderModel) => {\n const [maxVolume, setMaxVolume] = useState<number>(\n holder?.slice?.maxVolMl ?? 0\n );\n const [remainingVolume, setRemainingVolume] = useState<number>(\n holder?.slice?.currentVolMl ?? 0\n );\n\n const [hasMaxVolume, setHasMaxVolume] = useState<boolean>(\n holder?.slice?.maxVolMl !== undefined\n );\n\n const [hasRemainingVolume, setHasRemainingVolume] = useState<boolean>(\n holder?.slice?.currentVolMl !== undefined\n );\n\n const [fillPercent, setFillPercent] = useState<number>(\n remainingVolume <= 0\n ? 0\n : Math.floor(((remainingVolume || 1) / (maxVolume || 1)) * 100)\n );\n\n const [hasFuelGuage, setHasFuelGuage] = useState<boolean>(\n hasMaxVolume && hasRemainingVolume\n );\n\n useEffect(() => {\n const disposer = kosAutoEffect(() => {\n setMaxVolume(holder?.slice?.maxVolMl ?? 0);\n setRemainingVolume(holder?.slice?.currentVolMl ?? 0);\n setHasMaxVolume(holder?.slice?.maxVolMl !== undefined);\n setHasRemainingVolume(holder?.slice?.currentVolMl !== undefined);\n setFillPercent(\n remainingVolume <= 0\n ? 0\n : Math.floor(((remainingVolume || 1) / (maxVolume || 1)) * 100)\n );\n setHasFuelGuage(hasMaxVolume && hasRemainingVolume);\n });\n\n return () => {\n disposer();\n };\n }, [holder]);\n\n return { maxVolume, remainingVolume, fillPercent, hasFuelGuage };\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n CoreExtensionManager,\n DataLoader,\n DataMapper,\n EXTENSION_FEATURE_FLAG_RESOLVER,\n ExtensionManager,\n ExtensionOptions,\n IndexExtension,\n PropertyMapper,\n type FlagResolver,\n} from \"@kosdev-code/kos-ui-sdk\";\nimport { ExtensionType } from \"../constants\";\nimport { AssemblyTypes, type AssemblyModel } from \"../models\";\nimport type { HolderResponse } from \"../models/holder/services\";\nimport type { HolderModel } from \"../models/holder/types\";\nimport type { IngredientResponse } from \"../models/ingredient/services\";\nimport type { BeverageResponse } from \"../models/nozzle/services\";\nimport type { SelectedPourable } from \"../models/nozzle/types\";\n\nexport type IngredientDataMapper<\n AdditionalData extends object = Record<string, any>\n> = DataMapper<IngredientResponse, AdditionalData, any>;\n\n/**\n * Mapping function that maps an ingredient response into the type property of\n * the {@link IngredientModel}.\n */\nexport type IngredientTypeMapper<\n T extends IngredientResponse = IngredientResponse\n> = PropertyMapper<T, string>;\n\n/**\n * Mapping function that maps additional data from holder service response\n * into the {@link HolderModel} data.\n */\nexport type HolderTypeMapper<T extends HolderResponse = HolderResponse> =\n PropertyMapper<T, string>;\n\n/**\n * Mapping function that maps additional data from holder service response\n * into the {@link HolderModel} data.\n */\nexport type HolderDataMapper<\n AdditionalData extends object = Record<string, any>,\n HolderData extends HolderResponse = HolderResponse\n> = DataMapper<HolderData, AdditionalData, any>;\n\nexport type GroupBeverageResponse = BeverageResponse & { groupId: string };\nexport type AvailabilityDataMapper<\n AdditionalData extends object = Record<string, any>,\n AvailabilityData extends GroupBeverageResponse = GroupBeverageResponse\n> = DataMapper<AvailabilityData, AdditionalData, any>;\n\nexport type SelectedPourableMapper = DataMapper<SelectedPourable, any>;\n\nexport type BoardDataMapper<\n AdditionalData extends object = Record<string, any>,\n BoardData extends AssemblyTypes.AssemblyBoard<any> = AssemblyTypes.AssemblyBoard<any>\n> = DataMapper<BoardData, AdditionalData, any>;\n\nexport type AssemblyMapper<\n AdditionalData extends object = Record<string, any>,\n AssemblyResponseData extends AssemblyTypes.AssemblyResponse<any> = AssemblyTypes.AssemblyResponse<any>\n> = DataMapper<AssemblyResponseData, AdditionalData, any>;\n/**\n * The DispenseExtensionManager is responsible for managing the extension points that are specific to the Dispense application.\n */\nexport class DispenseExtensionManager {\n core: CoreExtensionManager = new CoreExtensionManager();\n /**\n * Maps data into the {@link IngredientModel}\n *\n * It is common for the ingredient data provided by the ingredient service to be augmented with additional properties that are\n * not provided by the base KOS Ingredient model. The {@link IngredientMapper} extension point allows for the data to be mapped\n * into the {@link IngredientModel} and the {@link IngredientModel.data} property to be augmented with additional properties.\n *\n * @param ingredientDataMapper - Mapping function that maps an {@link IngredientResponse} into additional model data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n *\n * @example\n * The following example shows how to map the data from the service response into the {@link IngredientModel}.\n * The context is provided by the {@link IngredientLoader} extension point with its data being used to optionally augment the\n * ingredient data.\n *\n * The result of the mapping will be available in the `data` property of the {@link IngredientModel}.\n *\n * In this case the `IngedientReponseData` interface represents the data being returned by the ingredient service and the\n * `IngredientData` interface represents the data that will be available in the {@link IngredientModel.data} property. The `ingredientDataMapper`\n * is responsible for mapping from one format to the other.\n *\n * ```typescript\n *\n * interface IngredientResponseData extends NozzleServices.IngredientResponse {\n * chilled: boolean;\n * carbonated: boolean;\n * highYield: boolean;\n * }\n *\n * interface IngredientData {\n * chilled: boolean;\n * carbonated: boolean;\n * highYield: boolean;\n * }\n *\n * export const ingredientDataMapper = async (\n * data: IngredientResponseData,\n * context: IngredientContext\n * ): Promise<IngredientData> => {\n * return {\n * chilled: data.chilled,\n * carbonated: data.carbonated,\n * highYield: data.highYield,\n * }\n * }\n * ```\n * */\n registerIngredientDataMapper(\n ingredientDataMapper: IngredientDataMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.IngredientMapper,\n ingredientDataMapper,\n options\n );\n\n return this;\n }\n\n /**\n * Loads data that will be provided as context into the {@link IngredientMapper}.\n *\n * @param ingredientLoader - Async function that loads and returns ingredient context data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on loader failure.\n * Set to `\"continue\"` to log the error and return `undefined` instead.\n * @returns this instance for chaining\n *\n * @example\n * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework\n * where it can be used by the other extension points.\n *\n * In the ingredient container model, the data is provided to the {@link IngredientMapper} extension point in order to augment ingredient data\n * and also loaded into the ingredient container model context in order to make the data available throughout the code.\n *\n * ```typescript\n * export const ingredientContextLoader = async (): Promise<BeverageContext> => {\n * const response = await kosFetch('kos:/system/some/ingredient/endpoint.json');\n *\n * if (response.status !== 200) {\n * KosLog.error('Failed to load ingredient data');\n * return {};\n * }\n * const json = await response.json();\n * return json;\n * };\n * ```\n * */\n registerIngredientLoader(\n ingredientLoader: DataLoader,\n options?: ExtensionOptions\n ) {\n ExtensionManager.loader.registerLoader(\n ExtensionType.IngredientLoader,\n ingredientLoader,\n options\n );\n return this;\n }\n\n registerIngredientIndex(ingredientIndex: IndexExtension) {\n ExtensionManager.indexExtension.registerIndexExtension(\n ExtensionType.IngredientIndex,\n ingredientIndex\n );\n return this;\n }\n\n /**\n * Registers a property mapper that derives the `type` property of the {@link IngredientModel}\n * from an {@link IngredientResponse}.\n *\n * @param ingredientTypeMapper - Mapping function that extracts a type string from an {@link IngredientResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and return a fallback value instead.\n * @returns this instance for chaining\n * */\n registerIngredientTypeMapper(\n ingredientTypeMapper: IngredientTypeMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.propertyMapper.registerPropertyMapper(\n ExtensionType.IngredientTypeMapper,\n ingredientTypeMapper,\n options\n );\n return this;\n }\n\n /**\n * Registers a data mapper for the {@link HolderModel} model.\n *\n * @param holderDataMapper - Mapping function that maps additional data from a {@link HolderResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n */\n registerHolderDataMapper(\n holderDataMapper: HolderDataMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.HolderMapper,\n holderDataMapper,\n options\n );\n return this;\n }\n\n /**\n * Registers a property mapper that derives the `type` property of the {@link HolderModel}\n * from a {@link HolderResponse}.\n *\n * @param holderTypeMapper - Mapping function that extracts a type string from a {@link HolderResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and return a fallback value instead.\n * @returns this instance for chaining\n */\n registerHolderTypeMapper(\n holderTypeMapper: HolderTypeMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.propertyMapper.registerPropertyMapper(\n ExtensionType.HolderTypeMapper,\n holderTypeMapper,\n options\n );\n return this;\n }\n\n /**\n * Maps the ingredientId property of the holder into the {@link HolderModel}.\n * If not provided, the ingredientId will assume that the value is mapped from the\n * ingredientId property of the service response.\n *\n * @param holderTypeMapper - Mapping function that extracts the ingredientId from a {@link HolderResponse}\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and return a fallback value instead.\n * @returns this instance for chaining\n * */\n registerHolderIngredientMapper(\n holderTypeMapper: HolderTypeMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.propertyMapper.registerPropertyMapper(\n ExtensionType.HolderTypeMapper,\n holderTypeMapper,\n options\n );\n return this;\n }\n\n registerHolderIndex<T extends HolderModel = HolderModel>(\n holderIndex: IndexExtension<T>\n ) {\n ExtensionManager.indexExtension.registerIndexExtension(\n ExtensionType.HolderIndex,\n holderIndex\n );\n return this;\n }\n\n /**\n * Maps data into the {@link AvailabilityModel}.\n *\n * @param availabilityMapper - Mapping function that maps a {@link GroupBeverageResponse} into additional availability data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n *\n * @example\n * The following example shows how to map the data from the service response into the {@link AvailabilityModel}.\n * The context is provided by the {@link AvailabilityLoader} extension point with its data being used to augment the\n * availability data.\n *\n * The result of the mapping will be available in the `data` property of the {@link AvailabilityModel}.\n *\n * ```typescript\n * export const beverageDataMapper = async (\n * data: NozzleServices.BeverageResponse,\n * context: BeverageContext\n * ): Promise<BeverageData> => {\n * const id = data.altId;\n * const iconUrl = encodeURI(\n * `http://localhost:8081/system/brandset/${context?.[id]?.icon}`\n * );\n * const cuiColorCode = context?.[id]?.cuiColorCode\n * ? context?.[id]?.cuiColorCode\n * : '';\n * return { iconUrl, cuiColorCode };\n * };\n * ```\n * */\n registerAvailabilityDataMapper(\n availabilityMapper: AvailabilityDataMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.AvailabilityMapper,\n availabilityMapper,\n options\n );\n return this;\n }\n\n /**\n * Loads data that will be provided as context into the {@link AvailabilityMapper}.\n *\n * @param availabilityLoader - Async function that loads and returns availability context data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on loader failure.\n * Set to `\"continue\"` to log the error and return `undefined` instead.\n * @returns this instance for chaining\n *\n * @example\n * A common use case is to load brandset data that is UI specific and not provided directly by the Java service.\n *\n * The following example shows how to load the brandset data, normalize it into a map and then provide it back to the framework\n * where it can be used by the other extension points.\n *\n * In the nozzle model, the data is provided to the {@link AvailabilityMapper} extension point in order to augment availability data\n * and also loaded into the nozzle model context in order to make the data available throughout the code.\n *\n * ```typescript\n * export const beverageContextLoader = async (): Promise<BeverageContext> => {\n * const response = await kosFetch('kos:/system/brandset/brandset.json');\n *\n * if (response.status !== 200) {\n * KosLog.error('Failed to load beverage data');\n * return {};\n * }\n * const json: BrandsetResponse | null = await response.json();\n * const initialBeverages: Record<string, BrandsetIngredient> = {};\n * const beverages = json?.ingredients?.reduce((acc, beverage) => {\n * acc[beverage.ingredientId] = beverage;\n * return acc;\n * }, initialBeverages);\n * return beverages;\n * };\n * ```\n * */\n registerAvailabilityLoader(\n availabilityLoader: DataLoader,\n options?: ExtensionOptions\n ) {\n ExtensionManager.loader.registerLoader(\n ExtensionType.AvailabilityLoader,\n availabilityLoader,\n options\n );\n return this;\n }\n\n /**\n * Maps the abstract {@link SelectedPourable} data into a format that is specific to the nozzle.\n *\n * @param selectedPourableMapper - Mapping function that transforms {@link SelectedPourable} data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n * */\n registerSelectedPourableDataMapper(\n selectedPourableMapper: SelectedPourableMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.SelectedPourableMapper,\n selectedPourableMapper,\n options\n );\n return this;\n }\n\n /**\n * Maps data into the {@link AssemblyModel} data.\n * Used in cases where the base assembly has been extended with additional properties in the backend. This extension\n * point allows for the data to be mapped into the {@link AssemblyModel} and augmented with additional properties.\n *\n * @param assemblyDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyResponse} into additional assembly data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n *\n * @example\n *\n * In this example of an implementation of a {@link AssemblyMapper}, the {@link AssemblyResponse} data is mapped into\n * a {@link FreestyleAssembly} object.\n *\n * The {@link FreestyleAssemblyResponse} interface represents the additional data being returned by the assembly service and is\n * merged into the {@link AssemblyResponse} interface.\n *\n * The {@link FreestyleAssembly} interface represents the additional data, beyond the base data set, that will be merged into the {@link AssemblyModel}.\n *\n * The mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.\n * ```typescript\n * import { AssemblyTypes } from \"@kosdev-code/kos-dispense-sdk\";\n * import { DataMapper } from \"@kosdev-code/kos-ui-sdk\";\n *\n * // define the additional data being returned by the assembly service\n * export interface FreestyleAssemblyResponse {\n * iceAgitator?: {\n * name: \"iceAgitator\";\n * path: string;\n * };\n * }\n *\n * // define the additional data structure that will be merged into the assembly model\n * export interface FreestyleAssembly {\n * iceAgitator: {\n * path: string;\n * };\n * carbAgitator: {\n * path: string;\n * };\n * }\n *\n *\n * // define the mapper that will map the data from the service response into the additional data structure\n * // that will be merged into the assembly model.\n * // In this case the mapper is responsible for mapping from the {@link FreestyleAssemblyResponse} format to the {@link FreestyleAssembly} format.\n * export const assemblyDataMapper: DataMapper<\n * AssemblyTypes.AssemblyResponse<FreestyleAssemblyResponse>,\n * FreestyleAssembly\n * > = async (data) => {\n * const response = data.assemblies.reduce((acc, assembly) => {\n * const agitatorKeys = [\"iceAgitator\", \"carbAgitator\"];\n * agitatorKeys.forEach((key) => {\n * const agitator = assembly[key];\n * if (agitator) {\n * acc[key] = agitator;\n * }\n * });\n *\n * return acc;\n * }, {} as FreestyleAssembly);\n * return response;\n * };\n *```\n */\n registerAssemblyDataMapper(\n assemblyDataMapper: AssemblyMapper,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.AssemblyMapper,\n assemblyDataMapper,\n options\n );\n return this;\n }\n\n registerBoardIndex(boardIndex: IndexExtension) {\n ExtensionManager.indexExtension.registerIndexExtension(\n ExtensionType.BoardIndex,\n boardIndex\n );\n return this;\n }\n\n /**\n * Registers a data mapper for the board model within an assembly.\n *\n * @param boardDataMapper - Mapping function that maps an {@link AssemblyTypes.AssemblyBoard} into additional board data\n * @param options - Optional {@link ExtensionOptions} to control failure behavior.\n * Defaults to `failurePolicy: \"throw\"`, which throws an {@link ExtensionException} on mapper failure.\n * Set to `\"continue\"` to log the error and continue processing remaining mappers.\n * @returns this instance for chaining\n */\n registerBoardDataMapper(\n boardDataMapper: BoardDataMapper<any, any>,\n options?: ExtensionOptions\n ) {\n ExtensionManager.dataMapper.registerDataMapper(\n ExtensionType.BoardMapper,\n boardDataMapper,\n options\n );\n return this;\n }\n\n registerAssemblyFeatureFlagResolver(\n assemblyFeatureFlagResolver: FlagResolver<AssemblyModel>\n ) {\n ExtensionManager[EXTENSION_FEATURE_FLAG_RESOLVER]?.register(\n ExtensionType.AssemblyFeatureFlags,\n assemblyFeatureFlagResolver\n );\n return this;\n }\n}\n\n/**\n * The KosExtensionManager provides access to the extension points that are provided in the SDK for Dispense applications.\n *\n * The extension points are divided into two categories:\n *\n * @param core - The core extension {@link CoreExtensionManager} points are used to extend the base models that are provided by the SDK.\n * @param dispense - The dispense extension {@link DispenseExtensionManager} points are used to extend the models that are specific to the Dispense SDK.\n */\nexport class KosExtensionManager {\n dispense: DispenseExtensionManager;\n core: CoreExtensionManager;\n constructor() {\n this.dispense = new DispenseExtensionManager();\n this.core = new CoreExtensionManager();\n }\n}\n"],"names":["useState","useEffect","kosAutoEffect","_a","_b","_c","_d","CoreExtensionManager","ExtensionManager","ExtensionType","EXTENSION_FEATURE_FLAG_RESOLVER"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,oBAAoB,CAAC,WAAwB;;AACxD,QAAM,CAAC,WAAW,YAAY,IAAIA,MAAAA;AAAAA,MAChC,sCAAQ,UAAR,mBAAe,aAAY;AAAA,EAAA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