scandit-capacitor-datacapture-label 8.0.0-beta.1

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.
package/dist/index.js ADDED
@@ -0,0 +1,1919 @@
1
+ import { nameForSerialization, ignoreFromSerializationIfNull, serializationDefault, NoViewfinder, DefaultSerializeable, ignoreFromSerialization, Quadrilateral, CameraSettings, Rect, Point, Size, FactoryMaker, BaseNewController, BaseController, Anchor, PointWithUnit, createNativeProxy, Brush, Feedback } from 'scandit-capacitor-datacapture-core/dist/core';
2
+ import { Barcode, getBarcodeDefaults } from 'scandit-capacitor-datacapture-barcode/dist/barcode';
3
+ import { registerPlugin } from '@capacitor/core';
4
+ import { CapacitorNativeCaller, capacitorExec, CapacitorCore } from 'scandit-capacitor-datacapture-core';
5
+
6
+ function loadLabelCaptureDefaults(jsonDefaults) {
7
+ const defaults = parseLabelCaptureDefaults(jsonDefaults);
8
+ FactoryMaker.bindInstanceIfNotExists('LabelCaptureDefaults', defaults);
9
+ }
10
+ function getLabelCaptureDefaults() {
11
+ return FactoryMaker.getInstance('LabelCaptureDefaults');
12
+ }
13
+ function parseLabelCaptureDefaults(jsonDefaults) {
14
+ return {
15
+ LabelCapture: {
16
+ RecommendedCameraSettings: CameraSettings
17
+ .fromJSON(jsonDefaults.LabelCapture.RecommendedCameraSettings),
18
+ LabelCaptureBasicOverlay: {
19
+ DefaultPredictedFieldBrush: Brush.fromJSON(jsonDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultPredictedFieldBrush),
20
+ DefaultCapturedFieldBrush: Brush.fromJSON(jsonDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultCapturedFieldBrush),
21
+ DefaultLabelBrush: Brush.fromJSON(jsonDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultLabelBrush)
22
+ },
23
+ LabelCaptureValidationFlowOverlay: {
24
+ Settings: {
25
+ missingFieldsHintText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.missingFieldsHintText,
26
+ standbyHintText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.standbyHintText,
27
+ validationHintText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.validationHintText,
28
+ validationErrorText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.validationErrorText,
29
+ requiredFieldErrorText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.requiredFieldErrorText,
30
+ manualInputButtonText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.manualInputButtonText,
31
+ }
32
+ },
33
+ Feedback: {
34
+ success: Feedback.fromJSON(JSON.parse(jsonDefaults.LabelCapture.feedback).success),
35
+ },
36
+ },
37
+ };
38
+ }
39
+
40
+ /******************************************************************************
41
+ Copyright (c) Microsoft Corporation.
42
+
43
+ Permission to use, copy, modify, and/or distribute this software for any
44
+ purpose with or without fee is hereby granted.
45
+
46
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
47
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
48
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
49
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
50
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
51
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
52
+ PERFORMANCE OF THIS SOFTWARE.
53
+ ***************************************************************************** */
54
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
55
+
56
+
57
+ function __decorate(decorators, target, key, desc) {
58
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
59
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
60
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
61
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
62
+ }
63
+
64
+ function __awaiter(thisArg, _arguments, P, generator) {
65
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
66
+ return new (P || (P = Promise))(function (resolve, reject) {
67
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
68
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
69
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
70
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
71
+ });
72
+ }
73
+
74
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
75
+ var e = new Error(message);
76
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
77
+ };
78
+
79
+ class LabelFieldDefinition extends DefaultSerializeable {
80
+ get name() {
81
+ return this._name;
82
+ }
83
+ get patterns() {
84
+ return this._patterns;
85
+ }
86
+ set patterns(value) {
87
+ this._patterns = value;
88
+ }
89
+ get optional() {
90
+ return this._optional;
91
+ }
92
+ set optional(value) {
93
+ this._optional = value;
94
+ }
95
+ get hiddenProperties() {
96
+ return this._hiddenProperties;
97
+ }
98
+ set hiddenProperties(newValue) {
99
+ for (const key in this._hiddenProperties) {
100
+ if (Object.prototype.hasOwnProperty.call(this._hiddenProperties, key)) {
101
+ delete this[key];
102
+ }
103
+ }
104
+ for (const key in newValue) {
105
+ if (Object.prototype.hasOwnProperty.call(newValue, key)) {
106
+ const item = newValue[key];
107
+ this[key] = item;
108
+ }
109
+ }
110
+ this._hiddenProperties = newValue;
111
+ }
112
+ constructor(name) {
113
+ super();
114
+ this._patterns = [];
115
+ this._optional = false;
116
+ this._hiddenProperties = {};
117
+ this._name = name;
118
+ }
119
+ }
120
+ __decorate([
121
+ nameForSerialization('name')
122
+ ], LabelFieldDefinition.prototype, "_name", void 0);
123
+ __decorate([
124
+ nameForSerialization('patterns')
125
+ ], LabelFieldDefinition.prototype, "_patterns", void 0);
126
+ __decorate([
127
+ nameForSerialization('optional')
128
+ ], LabelFieldDefinition.prototype, "_optional", void 0);
129
+ __decorate([
130
+ ignoreFromSerialization
131
+ ], LabelFieldDefinition.prototype, "_hiddenProperties", void 0);
132
+
133
+ class BarcodeField extends LabelFieldDefinition {
134
+ get symbologySettings() {
135
+ return this._symbologySettings;
136
+ }
137
+ constructor(name, symbologies) {
138
+ super(name);
139
+ this._symbologySettings = symbologies;
140
+ this._symbologies = symbologies.reduce((acc, item) => {
141
+ acc[item.symbology.toString()] = item;
142
+ return acc;
143
+ }, {});
144
+ }
145
+ }
146
+ __decorate([
147
+ nameForSerialization('symbologies'),
148
+ ignoreFromSerializationIfNull
149
+ ], BarcodeField.prototype, "_symbologies", void 0);
150
+ __decorate([
151
+ ignoreFromSerialization
152
+ ], BarcodeField.prototype, "_symbologySettings", void 0);
153
+
154
+ class LabelDateResult extends DefaultSerializeable {
155
+ constructor(day, month, year, dayString, monthString, yearString) {
156
+ super();
157
+ this._day = day;
158
+ this._month = month;
159
+ this._year = year;
160
+ this._dayString = dayString;
161
+ this._monthString = monthString;
162
+ this._yearString = yearString;
163
+ }
164
+ get day() {
165
+ return this._day;
166
+ }
167
+ get month() {
168
+ return this._month;
169
+ }
170
+ get year() {
171
+ return this._year;
172
+ }
173
+ get dayString() {
174
+ var _a;
175
+ return (_a = this._dayString) !== null && _a !== void 0 ? _a : '';
176
+ }
177
+ get monthString() {
178
+ var _a;
179
+ return (_a = this._monthString) !== null && _a !== void 0 ? _a : '';
180
+ }
181
+ get yearString() {
182
+ var _a;
183
+ return (_a = this._yearString) !== null && _a !== void 0 ? _a : '';
184
+ }
185
+ static fromJSON(json) {
186
+ return new LabelDateResult(json.day, json.month, json.year, json.dayStr, json.monthStr, json.yearStr);
187
+ }
188
+ }
189
+ __decorate([
190
+ nameForSerialization('day')
191
+ ], LabelDateResult.prototype, "_day", void 0);
192
+ __decorate([
193
+ nameForSerialization('month')
194
+ ], LabelDateResult.prototype, "_month", void 0);
195
+ __decorate([
196
+ nameForSerialization('year')
197
+ ], LabelDateResult.prototype, "_year", void 0);
198
+ __decorate([
199
+ nameForSerialization('dayStr')
200
+ ], LabelDateResult.prototype, "_dayString", void 0);
201
+ __decorate([
202
+ nameForSerialization('monthStr')
203
+ ], LabelDateResult.prototype, "_monthString", void 0);
204
+ __decorate([
205
+ nameForSerialization('yearStr')
206
+ ], LabelDateResult.prototype, "_yearString", void 0);
207
+
208
+ class LabelField {
209
+ get name() {
210
+ return this._name;
211
+ }
212
+ get type() {
213
+ return this._type;
214
+ }
215
+ get predictedLocation() {
216
+ return this._predictedLocation;
217
+ }
218
+ get state() {
219
+ return this._state;
220
+ }
221
+ get isRequired() {
222
+ return this._isRequired;
223
+ }
224
+ get barcode() {
225
+ return this._barcode;
226
+ }
227
+ get text() {
228
+ return this._text;
229
+ }
230
+ asDate() {
231
+ return this._dateResult;
232
+ }
233
+ static fromJSON(json) {
234
+ const field = new LabelField();
235
+ field._name = json.name;
236
+ field._type = json.type;
237
+ field._predictedLocation = Quadrilateral.fromJSON(json.location);
238
+ field._state = json.state;
239
+ field._isRequired = json.isRequired;
240
+ field._barcode = json.barcode ? Barcode.fromJSON(json.barcode) : null;
241
+ field._text = json.text;
242
+ field._dateResult = json.date ? LabelDateResult.fromJSON(json.date) : null;
243
+ return field;
244
+ }
245
+ }
246
+
247
+ class CapturedLabel {
248
+ get fields() {
249
+ return this._fields;
250
+ }
251
+ get name() {
252
+ return this._name;
253
+ }
254
+ get isComplete() {
255
+ return this._isComplete;
256
+ }
257
+ get predictedBounds() {
258
+ return this._predictedBounds;
259
+ }
260
+ get deltaTimeToPrediction() {
261
+ return this._deltaTimeToPrediction;
262
+ }
263
+ get trackingID() {
264
+ return this._trackingID;
265
+ }
266
+ static fromJSON(json) {
267
+ const label = new CapturedLabel();
268
+ label._fields = json.fields.map(LabelField.fromJSON);
269
+ label._name = json.name;
270
+ label._predictedBounds = Quadrilateral.fromJSON(json.predictedBounds);
271
+ label._deltaTimeToPrediction = json.deltaTimeToPrediction;
272
+ label._trackingID = json.trackingId;
273
+ label._isComplete = json.isComplete;
274
+ return label;
275
+ }
276
+ }
277
+
278
+ class CustomBarcode extends BarcodeField {
279
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
280
+ return new CustomBarcode(name, symbologySettings);
281
+ }
282
+ static initWithNameAndSymbologies(name, symbologies) {
283
+ const symbologySettings = Object.values(symbologies).map(symbology => {
284
+ const symbologyObj = CustomBarcode.barcodeDefaults.SymbologySettings[symbology];
285
+ symbologyObj.isEnabled = true;
286
+ return symbologyObj;
287
+ });
288
+ return new CustomBarcode(name, symbologySettings);
289
+ }
290
+ static initWithNameAndSymbology(name, symbology) {
291
+ return CustomBarcode.initWithNameAndSymbologies(name, [symbology]);
292
+ }
293
+ constructor(name, symbologies) {
294
+ super(name, symbologies);
295
+ this.location = null;
296
+ this._dataTypePatterns = [];
297
+ this._fieldType = 'customBarcode';
298
+ }
299
+ get dataTypePatterns() {
300
+ return this._dataTypePatterns;
301
+ }
302
+ set dataTypePatterns(value) {
303
+ this._dataTypePatterns = value;
304
+ }
305
+ static get barcodeDefaults() {
306
+ return getBarcodeDefaults();
307
+ }
308
+ }
309
+ __decorate([
310
+ nameForSerialization('location')
311
+ ], CustomBarcode.prototype, "location", void 0);
312
+ __decorate([
313
+ nameForSerialization('dataTypePatterns')
314
+ ], CustomBarcode.prototype, "_dataTypePatterns", void 0);
315
+ __decorate([
316
+ nameForSerialization('fieldType')
317
+ ], CustomBarcode.prototype, "_fieldType", void 0);
318
+
319
+ class TextField extends LabelFieldDefinition {
320
+ }
321
+
322
+ class CustomText extends TextField {
323
+ constructor(name) {
324
+ super(name);
325
+ this.location = null;
326
+ this._dataTypePatterns = [];
327
+ this._fieldType = 'customText';
328
+ }
329
+ get dataTypePatterns() {
330
+ return this._dataTypePatterns;
331
+ }
332
+ set dataTypePatterns(value) {
333
+ this._dataTypePatterns = value;
334
+ }
335
+ }
336
+ __decorate([
337
+ nameForSerialization('location')
338
+ ], CustomText.prototype, "location", void 0);
339
+ __decorate([
340
+ nameForSerialization('dataTypePatterns')
341
+ ], CustomText.prototype, "_dataTypePatterns", void 0);
342
+ __decorate([
343
+ nameForSerialization('fieldType')
344
+ ], CustomText.prototype, "_fieldType", void 0);
345
+
346
+ class ExpiryDateText extends TextField {
347
+ constructor(name) {
348
+ super(name);
349
+ this._fieldType = 'expiryDateText';
350
+ this._dataTypePatterns = [];
351
+ this._labelDateFormat = null;
352
+ }
353
+ get labelDateFormat() {
354
+ return this._labelDateFormat;
355
+ }
356
+ set labelDateFormat(value) {
357
+ this._labelDateFormat = value;
358
+ }
359
+ get dataTypePatterns() {
360
+ return this._dataTypePatterns;
361
+ }
362
+ set dataTypePatterns(value) {
363
+ this._dataTypePatterns = value;
364
+ }
365
+ }
366
+ __decorate([
367
+ nameForSerialization('fieldType')
368
+ ], ExpiryDateText.prototype, "_fieldType", void 0);
369
+ __decorate([
370
+ nameForSerialization('dataTypePatterns')
371
+ ], ExpiryDateText.prototype, "_dataTypePatterns", void 0);
372
+ __decorate([
373
+ nameForSerialization('labelDateFormat')
374
+ ], ExpiryDateText.prototype, "_labelDateFormat", void 0);
375
+
376
+ class ImeiOneBarcode extends BarcodeField {
377
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
378
+ return new ImeiOneBarcode(name, symbologySettings);
379
+ }
380
+ static initWithNameAndSymbologies(name, symbologies) {
381
+ const symbologySettings = Object.values(symbologies).map(symbology => {
382
+ const symbologyObj = ImeiOneBarcode.barcodeDefaults.SymbologySettings[symbology];
383
+ symbologyObj.isEnabled = true;
384
+ return symbologyObj;
385
+ });
386
+ return new ImeiOneBarcode(name, symbologySettings);
387
+ }
388
+ static initWithNameAndSymbology(name, symbology) {
389
+ return ImeiOneBarcode.initWithNameAndSymbologies(name, [symbology]);
390
+ }
391
+ static get barcodeDefaults() {
392
+ return getBarcodeDefaults();
393
+ }
394
+ constructor(name, symbologies) {
395
+ super(name, symbologies);
396
+ this._fieldType = 'imeiOneBarcode';
397
+ }
398
+ }
399
+ __decorate([
400
+ nameForSerialization('fieldType')
401
+ ], ImeiOneBarcode.prototype, "_fieldType", void 0);
402
+
403
+ class ImeiTwoBarcode extends BarcodeField {
404
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
405
+ return new ImeiTwoBarcode(name, symbologySettings);
406
+ }
407
+ static initWithNameAndSymbologies(name, symbologies) {
408
+ const symbologySettings = Object.values(symbologies).map(symbology => {
409
+ const symbologyObj = ImeiTwoBarcode.barcodeDefaults.SymbologySettings[symbology];
410
+ symbologyObj.isEnabled = true;
411
+ return symbologyObj;
412
+ });
413
+ return new ImeiTwoBarcode(name, symbologySettings);
414
+ }
415
+ static initWithNameAndSymbology(name, symbology) {
416
+ return ImeiTwoBarcode.initWithNameAndSymbologies(name, [symbology]);
417
+ }
418
+ static get barcodeDefaults() {
419
+ return getBarcodeDefaults();
420
+ }
421
+ constructor(name, symbologies) {
422
+ super(name, symbologies);
423
+ this._fieldType = 'imeiTwoBarcode';
424
+ }
425
+ }
426
+ __decorate([
427
+ nameForSerialization('fieldType')
428
+ ], ImeiTwoBarcode.prototype, "_fieldType", void 0);
429
+
430
+ class LabelCaptureSession {
431
+ get capturedLabels() {
432
+ return this._capturedLabels;
433
+ }
434
+ get frameSequenceID() {
435
+ return this._frameSequenceID;
436
+ }
437
+ static fromJSON(json) {
438
+ const session = new LabelCaptureSession();
439
+ session._frameSequenceID = json.frameSequenceId;
440
+ session._capturedLabels = json.labels
441
+ .map(CapturedLabel.fromJSON);
442
+ session._capturedLabels
443
+ .forEach(label => label.frameSequenceID = session._frameSequenceID);
444
+ return session;
445
+ }
446
+ }
447
+
448
+ var LabelCaptureListenerEvents;
449
+ (function (LabelCaptureListenerEvents) {
450
+ LabelCaptureListenerEvents["didUpdateSession"] = "LabelCaptureListener.didUpdateSession";
451
+ })(LabelCaptureListenerEvents || (LabelCaptureListenerEvents = {}));
452
+ class LabelCaptureController extends BaseNewController {
453
+ constructor(mode) {
454
+ super('LabelCaptureProxy');
455
+ this.mode = mode;
456
+ this.initialize().catch(error => console.error('Failed to initialize LabelCaptureController:', error));
457
+ }
458
+ initialize() {
459
+ return __awaiter(this, void 0, void 0, function* () {
460
+ if (this.mode.listeners.length > 0) {
461
+ yield this.subscribeLabelCaptureListener();
462
+ }
463
+ });
464
+ }
465
+ setModeEnabledState(isEnabled) {
466
+ return this._proxy.$setModeEnabledState({ modeId: this.modeId, isEnabled });
467
+ }
468
+ updateLabelCaptureSettings(settingsJson) {
469
+ return this._proxy.$updateLabelCaptureSettings({ modeId: this.modeId, settingsJson });
470
+ }
471
+ subscribeLabelCaptureListener() {
472
+ return __awaiter(this, void 0, void 0, function* () {
473
+ if (this._boundHandleDidUpdateSession) {
474
+ return;
475
+ }
476
+ yield this._proxy.$registerListenerForEvents({ modeId: this.modeId });
477
+ this._boundHandleDidUpdateSession = this.handleDidUpdateSessionEvent.bind(this);
478
+ this._proxy.subscribeForEvents(Object.values(LabelCaptureListenerEvents));
479
+ this._proxy.eventEmitter.on(LabelCaptureListenerEvents.didUpdateSession, this._boundHandleDidUpdateSession);
480
+ });
481
+ }
482
+ handleDidUpdateSessionEvent(ev) {
483
+ return __awaiter(this, void 0, void 0, function* () {
484
+ const payload = JSON.parse(ev.data);
485
+ const session = LabelCaptureSession.fromJSON(JSON.parse(payload.session));
486
+ this.notifyListenersOfDidUpdateSession(session);
487
+ yield this._proxy.$finishDidUpdateSessionCallback({ modeId: this.modeId, isEnabled: this.mode.isEnabled });
488
+ });
489
+ }
490
+ unsubscribeLabelCaptureListener() {
491
+ return __awaiter(this, void 0, void 0, function* () {
492
+ yield this._proxy.$unregisterListenerForEvents({ modeId: this.modeId });
493
+ this._proxy.unsubscribeFromEvents(Object.values(LabelCaptureListenerEvents));
494
+ if (this._boundHandleDidUpdateSession) {
495
+ this._proxy.eventEmitter.off(LabelCaptureListenerEvents.didUpdateSession, this._boundHandleDidUpdateSession);
496
+ this._boundHandleDidUpdateSession = undefined;
497
+ }
498
+ });
499
+ }
500
+ updateFeedback(feedback) {
501
+ this._proxy.$updateLabelCaptureFeedback({ modeId: this.modeId, feedbackJson: JSON.stringify(feedback.toJSON()) });
502
+ }
503
+ dispose() {
504
+ this.unsubscribeLabelCaptureListener();
505
+ this._proxy.dispose();
506
+ }
507
+ get modeId() {
508
+ return this.mode.modeId;
509
+ }
510
+ notifyListenersOfDidUpdateSession(session) {
511
+ const mode = this.mode;
512
+ mode.listeners.forEach(listener => {
513
+ if (listener.didUpdateSession) {
514
+ listener.didUpdateSession(this.mode, session);
515
+ }
516
+ });
517
+ }
518
+ }
519
+
520
+ class LabelCaptureFeedback extends DefaultSerializeable {
521
+ static get defaultFeedback() {
522
+ return new LabelCaptureFeedback();
523
+ }
524
+ static get labelCaptureDefaults() {
525
+ return getLabelCaptureDefaults();
526
+ }
527
+ get success() {
528
+ return this._success;
529
+ }
530
+ set success(success) {
531
+ this._success = success;
532
+ this.updateFeedback();
533
+ }
534
+ updateFeedback() {
535
+ var _a;
536
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateFeedback(this);
537
+ }
538
+ constructor() {
539
+ super();
540
+ this.controller = null;
541
+ this._success = LabelCaptureFeedback.labelCaptureDefaults.LabelCapture.Feedback.success;
542
+ }
543
+ }
544
+ __decorate([
545
+ nameForSerialization('success')
546
+ ], LabelCaptureFeedback.prototype, "_success", void 0);
547
+ __decorate([
548
+ ignoreFromSerialization
549
+ ], LabelCaptureFeedback.prototype, "controller", void 0);
550
+ __decorate([
551
+ ignoreFromSerialization
552
+ ], LabelCaptureFeedback, "labelCaptureDefaults", null);
553
+
554
+ class LabelCapture extends DefaultSerializeable {
555
+ get isEnabled() {
556
+ return this._isEnabled;
557
+ }
558
+ set isEnabled(isEnabled) {
559
+ var _a;
560
+ this._isEnabled = isEnabled;
561
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setModeEnabledState(isEnabled);
562
+ }
563
+ get context() {
564
+ return this._context;
565
+ }
566
+ static createRecommendedCameraSettings() {
567
+ return new CameraSettings(getLabelCaptureDefaults().LabelCapture.RecommendedCameraSettings);
568
+ }
569
+ get _context() {
570
+ return this.privateContext;
571
+ }
572
+ set _context(newContext) {
573
+ var _a, _b;
574
+ if (newContext == null) {
575
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
576
+ this.controller = null;
577
+ this._feedback.controller = null;
578
+ return;
579
+ }
580
+ this.privateContext = newContext;
581
+ (_b = this.controller) !== null && _b !== void 0 ? _b : (this.controller = new LabelCaptureController(this));
582
+ this._feedback.controller = this.controller;
583
+ }
584
+ constructor(settings) {
585
+ super();
586
+ this.type = 'labelCapture';
587
+ this.modeId = Math.floor(Math.random() * 100000000);
588
+ this.parentId = null;
589
+ this._isEnabled = true;
590
+ this._feedback = LabelCaptureFeedback.defaultFeedback;
591
+ this.hasListeners = false;
592
+ this.privateContext = null;
593
+ this.listeners = [];
594
+ this.controller = null;
595
+ this.settings = settings;
596
+ }
597
+ applySettings(settings) {
598
+ return __awaiter(this, void 0, void 0, function* () {
599
+ var _a;
600
+ this.settings = settings;
601
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateLabelCaptureSettings(JSON.stringify(settings.toJSON()));
602
+ });
603
+ }
604
+ addListener(listener) {
605
+ if (this.listeners.includes(listener)) {
606
+ return;
607
+ }
608
+ this.listeners.push(listener);
609
+ this.hasListeners = this.listeners.length > 0;
610
+ }
611
+ removeListener(listener) {
612
+ if (!this.listeners.includes(listener)) {
613
+ return;
614
+ }
615
+ this.listeners.splice(this.listeners.indexOf(listener), 1);
616
+ this.hasListeners = this.listeners.length > 0;
617
+ }
618
+ get feedback() {
619
+ return this._feedback;
620
+ }
621
+ set feedback(feedback) {
622
+ var _a;
623
+ this._feedback.controller = null;
624
+ this._feedback = feedback;
625
+ this._feedback.controller = this.controller;
626
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateFeedback(feedback);
627
+ }
628
+ }
629
+ __decorate([
630
+ nameForSerialization('parentId'),
631
+ ignoreFromSerializationIfNull
632
+ ], LabelCapture.prototype, "parentId", void 0);
633
+ __decorate([
634
+ nameForSerialization('enabled')
635
+ ], LabelCapture.prototype, "_isEnabled", void 0);
636
+ __decorate([
637
+ nameForSerialization('feedback')
638
+ ], LabelCapture.prototype, "_feedback", void 0);
639
+ __decorate([
640
+ ignoreFromSerialization
641
+ ], LabelCapture.prototype, "privateContext", void 0);
642
+ __decorate([
643
+ ignoreFromSerialization
644
+ ], LabelCapture.prototype, "listeners", void 0);
645
+ __decorate([
646
+ ignoreFromSerialization
647
+ ], LabelCapture.prototype, "controller", void 0);
648
+
649
+ var LabelCaptureAdvancedOverlayListenerEvents;
650
+ (function (LabelCaptureAdvancedOverlayListenerEvents) {
651
+ LabelCaptureAdvancedOverlayListenerEvents["viewForLabel"] = "LabelCaptureAdvancedOverlayListener.viewForLabel";
652
+ LabelCaptureAdvancedOverlayListenerEvents["anchorForLabel"] = "LabelCaptureAdvancedOverlayListener.anchorForLabel";
653
+ LabelCaptureAdvancedOverlayListenerEvents["offsetForLabel"] = "LabelCaptureAdvancedOverlayListener.offsetForLabel";
654
+ LabelCaptureAdvancedOverlayListenerEvents["viewForCapturedLabelField"] = "LabelCaptureAdvancedOverlayListener.viewForFieldOfLabel";
655
+ LabelCaptureAdvancedOverlayListenerEvents["anchorForCapturedLabelField"] = "LabelCaptureAdvancedOverlayListener.anchorForFieldOfLabel";
656
+ LabelCaptureAdvancedOverlayListenerEvents["offsetForCapturedLabelField"] = "LabelCaptureAdvancedOverlayListener.offsetForFieldOfLabel";
657
+ })(LabelCaptureAdvancedOverlayListenerEvents || (LabelCaptureAdvancedOverlayListenerEvents = {}));
658
+ class LabelCaptureAdvancedOverlayController extends BaseController {
659
+ constructor(overlay) {
660
+ super('LabelCaptureAdvancedOverlayProxy');
661
+ // Arrow function wrappers to avoid .bind(this) and always use current class state
662
+ this.handleViewForLabelWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
663
+ return this.handleViewForLabel(ev);
664
+ });
665
+ this.handleAnchorForLabelWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
666
+ return this.handleAnchorForLabel(ev);
667
+ });
668
+ this.handleOffsetForLabelWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
669
+ return this.handleOffsetForLabel(ev);
670
+ });
671
+ this.handleViewForCapturedLabelFieldWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
672
+ return this.handleViewForCapturedLabelField(ev);
673
+ });
674
+ this.handleAnchorForCapturedLabelFieldWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
675
+ return this.handleAnchorForCapturedLabelField(ev);
676
+ });
677
+ this.handleOffsetForCapturedLabelFieldWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
678
+ return this.handleOffsetForCapturedLabelField(ev);
679
+ });
680
+ this.overlay = overlay;
681
+ this.initialize();
682
+ }
683
+ initialize() {
684
+ if (this.overlay.listener) {
685
+ this.subscribeListener();
686
+ }
687
+ }
688
+ setViewForCapturedLabel(label, view) {
689
+ return __awaiter(this, void 0, void 0, function* () {
690
+ const awitedView = yield view;
691
+ return this._proxy.$setViewForCapturedLabel({
692
+ jsonView: awitedView ? JSON.stringify(awitedView.toJSON()) : null,
693
+ trackingId: label.trackingID,
694
+ dataCaptureViewId: this.dataCaptureViewId
695
+ });
696
+ });
697
+ }
698
+ setAnchorForCapturedLabel(label, anchor) {
699
+ return this._proxy.$setAnchorForCapturedLabel({
700
+ anchor: anchor,
701
+ trackingId: label.trackingID,
702
+ dataCaptureViewId: this.dataCaptureViewId
703
+ });
704
+ }
705
+ setOffsetForCapturedLabel(label, offset) {
706
+ return this._proxy.$setOffsetForCapturedLabel({
707
+ offsetJson: JSON.stringify(offset.toJSON()),
708
+ trackingId: label.trackingID,
709
+ dataCaptureViewId: this.dataCaptureViewId
710
+ });
711
+ }
712
+ setViewForCapturedLabelField(label, field, view) {
713
+ const identifier = `${label.trackingID}§${field.name}`;
714
+ return this.setViewForCapturedLabelFieldPrivate(identifier, view);
715
+ }
716
+ setViewForCapturedLabelFieldPrivate(identifier, view) {
717
+ return __awaiter(this, void 0, void 0, function* () {
718
+ const awitedView = yield view;
719
+ return this._proxy.$setViewForCapturedLabelField({
720
+ view: awitedView ? JSON.stringify(awitedView.toJSON()) : null,
721
+ identifier: identifier,
722
+ dataCaptureViewId: this.dataCaptureViewId
723
+ });
724
+ });
725
+ }
726
+ setAnchorForCapturedLabelField(label, field, anchor) {
727
+ const identifier = `${label.trackingID}§${field.name}`;
728
+ return this.setAnchorForCapturedLabelFieldPrivate(identifier, anchor);
729
+ }
730
+ setAnchorForCapturedLabelFieldPrivate(identifier, anchor) {
731
+ return this._proxy.$setAnchorForCapturedLabelField({
732
+ anchor: anchor,
733
+ identifier: identifier,
734
+ dataCaptureViewId: this.dataCaptureViewId
735
+ });
736
+ }
737
+ setOffsetForCapturedLabelField(label, field, offset) {
738
+ const identifier = `${label.trackingID}§${field.name}`;
739
+ return this.setOffsetForCapturedLabelFieldPrivate(identifier, offset);
740
+ }
741
+ setOffsetForCapturedLabelFieldPrivate(identifier, offset) {
742
+ return this._proxy.$setOffsetForCapturedLabelField({
743
+ offset: JSON.stringify(offset.toJSON()),
744
+ identifier: identifier,
745
+ dataCaptureViewId: this.dataCaptureViewId
746
+ });
747
+ }
748
+ clearCapturedLabelViews() {
749
+ return this._proxy.$clearCapturedLabelViews({ dataCaptureViewId: this.dataCaptureViewId });
750
+ }
751
+ subscribeListener() {
752
+ if (this.dataCaptureViewId !== -1) {
753
+ this._proxy.$registerListenerForAdvancedOverlayEvents({ dataCaptureViewId: this.dataCaptureViewId });
754
+ }
755
+ this._proxy.subscribeForEvents(Object.values(LabelCaptureAdvancedOverlayListenerEvents));
756
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.viewForLabel, this.handleViewForLabelWrapper);
757
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.anchorForLabel, this.handleAnchorForLabelWrapper);
758
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.offsetForLabel, this.handleOffsetForLabelWrapper);
759
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.viewForCapturedLabelField, this.handleViewForCapturedLabelFieldWrapper);
760
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.anchorForCapturedLabelField, this.handleAnchorForCapturedLabelFieldWrapper);
761
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.offsetForCapturedLabelField, this.handleOffsetForCapturedLabelFieldWrapper);
762
+ }
763
+ handleViewForLabel(ev) {
764
+ return __awaiter(this, void 0, void 0, function* () {
765
+ const payload = JSON.parse(ev.data);
766
+ let view = null;
767
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
768
+ if (this.overlay.listener && this.overlay.listener.viewForCapturedLabel) {
769
+ view = this.overlay.listener.viewForCapturedLabel(this.overlay, label);
770
+ }
771
+ yield this.setViewForCapturedLabel(label, view);
772
+ });
773
+ }
774
+ handleAnchorForLabel(ev) {
775
+ return __awaiter(this, void 0, void 0, function* () {
776
+ const payload = JSON.parse(ev.data);
777
+ let anchor = Anchor.Center;
778
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
779
+ if (this.overlay.listener && this.overlay.listener.anchorForCapturedLabel) {
780
+ anchor = this.overlay.listener.anchorForCapturedLabel(this.overlay, label);
781
+ }
782
+ yield this.setAnchorForCapturedLabel(label, anchor);
783
+ });
784
+ }
785
+ handleViewForCapturedLabelField(ev) {
786
+ return __awaiter(this, void 0, void 0, function* () {
787
+ const payload = JSON.parse(ev.data);
788
+ let view = null;
789
+ const field = LabelField.fromJSON(JSON.parse(payload.field));
790
+ if (this.overlay.listener && this.overlay.listener.viewForCapturedLabelField) {
791
+ view = this.overlay.listener.viewForCapturedLabelField(this.overlay, field);
792
+ }
793
+ yield this.setViewForCapturedLabelFieldPrivate(payload.identifier, view);
794
+ });
795
+ }
796
+ handleOffsetForLabel(ev) {
797
+ return __awaiter(this, void 0, void 0, function* () {
798
+ const payload = JSON.parse(ev.data);
799
+ let offset = PointWithUnit.zero;
800
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
801
+ if (this.overlay.listener && this.overlay.listener.offsetForCapturedLabel) {
802
+ offset = this.overlay.listener.offsetForCapturedLabel(this.overlay, label);
803
+ }
804
+ yield this.setOffsetForCapturedLabel(label, offset);
805
+ });
806
+ }
807
+ handleAnchorForCapturedLabelField(ev) {
808
+ return __awaiter(this, void 0, void 0, function* () {
809
+ const payload = JSON.parse(ev.data);
810
+ let anchor = Anchor.Center;
811
+ const field = LabelField.fromJSON(JSON.parse(payload.field));
812
+ if (this.overlay.listener && this.overlay.listener.anchorForCapturedLabelField) {
813
+ anchor = this.overlay.listener.anchorForCapturedLabelField(this.overlay, field);
814
+ }
815
+ yield this.setAnchorForCapturedLabelFieldPrivate(payload.identifier, anchor);
816
+ });
817
+ }
818
+ handleOffsetForCapturedLabelField(ev) {
819
+ return __awaiter(this, void 0, void 0, function* () {
820
+ const payload = JSON.parse(ev.data);
821
+ let offset = PointWithUnit.zero;
822
+ const field = LabelField.fromJSON(JSON.parse(payload.field));
823
+ if (this.overlay.listener && this.overlay.listener.offsetForCapturedLabelField) {
824
+ offset = this.overlay.listener.offsetForCapturedLabelField(this.overlay, field);
825
+ }
826
+ yield this.setOffsetForCapturedLabelFieldPrivate(payload.identifier, offset);
827
+ });
828
+ }
829
+ unsubscribeListener() {
830
+ this._proxy.$unregisterListenerForAdvancedOverlayEvents({ dataCaptureViewId: this.dataCaptureViewId });
831
+ this._proxy.unsubscribeFromEvents(Object.values(LabelCaptureAdvancedOverlayListenerEvents));
832
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.viewForLabel, this.handleViewForLabelWrapper);
833
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.anchorForLabel, this.handleAnchorForLabelWrapper);
834
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.offsetForLabel, this.handleOffsetForLabelWrapper);
835
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.viewForCapturedLabelField, this.handleViewForCapturedLabelFieldWrapper);
836
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.anchorForCapturedLabelField, this.handleAnchorForCapturedLabelFieldWrapper);
837
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.offsetForCapturedLabelField, this.handleOffsetForCapturedLabelFieldWrapper);
838
+ }
839
+ dispose() {
840
+ this.unsubscribeListener();
841
+ this._proxy.dispose();
842
+ }
843
+ updateAdvancedOverlay(advancedOverlayJson) {
844
+ return this._proxy.$updateLabelCaptureAdvancedOverlay({ dataCaptureViewId: this.dataCaptureViewId, advancedOverlayJson });
845
+ }
846
+ get dataCaptureViewId() {
847
+ var _a, _b;
848
+ return (_b = (_a = this.overlay.view) === null || _a === void 0 ? void 0 : _a.viewId) !== null && _b !== void 0 ? _b : -1;
849
+ }
850
+ }
851
+
852
+ class LabelCaptureAdvancedOverlay extends DefaultSerializeable {
853
+ get view() {
854
+ return this._view;
855
+ }
856
+ set view(newView) {
857
+ var _a, _b;
858
+ if (newView === null) {
859
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
860
+ this.controller = null;
861
+ this._view = null;
862
+ return;
863
+ }
864
+ this._view = newView;
865
+ (_b = this.controller) !== null && _b !== void 0 ? _b : (this.controller = new LabelCaptureAdvancedOverlayController(this));
866
+ }
867
+ get shouldShowScanAreaGuides() {
868
+ return this._shouldShowScanAreaGuides;
869
+ }
870
+ set shouldShowScanAreaGuides(shouldShow) {
871
+ var _a;
872
+ this._shouldShowScanAreaGuides = shouldShow;
873
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateAdvancedOverlay(JSON.stringify(this.toJSON()));
874
+ }
875
+ get listener() {
876
+ return this._listener;
877
+ }
878
+ set listener(listener) {
879
+ var _a, _b;
880
+ this._listener = listener;
881
+ this.hasListener = listener != null;
882
+ if (this.hasListener) {
883
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.subscribeListener();
884
+ }
885
+ else {
886
+ (_b = this.controller) === null || _b === void 0 ? void 0 : _b.unsubscribeListener();
887
+ }
888
+ }
889
+ constructor(mode) {
890
+ super();
891
+ this.type = 'labelCaptureAdvanced';
892
+ this.controller = null;
893
+ this._view = null;
894
+ this._listener = null;
895
+ this.hasListener = false;
896
+ this._shouldShowScanAreaGuides = false;
897
+ this.modeId = mode.modeId;
898
+ }
899
+ setViewForCapturedLabel(capturedLabel, view) {
900
+ return __awaiter(this, void 0, void 0, function* () {
901
+ var _a;
902
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setViewForCapturedLabel(capturedLabel, view);
903
+ });
904
+ }
905
+ setViewForCapturedLabelField(field, capturedLabel, view) {
906
+ return __awaiter(this, void 0, void 0, function* () {
907
+ var _a;
908
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setViewForCapturedLabelField(capturedLabel, field, view);
909
+ });
910
+ }
911
+ setAnchorForCapturedLabel(capturedLabel, anchor) {
912
+ return __awaiter(this, void 0, void 0, function* () {
913
+ var _a;
914
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setAnchorForCapturedLabel(capturedLabel, anchor);
915
+ });
916
+ }
917
+ setAnchorForCapturedLabelField(field, capturedLabel, anchor) {
918
+ return __awaiter(this, void 0, void 0, function* () {
919
+ var _a;
920
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setAnchorForCapturedLabelField(capturedLabel, field, anchor);
921
+ });
922
+ }
923
+ setOffsetForCapturedLabel(capturedLabel, offset) {
924
+ return __awaiter(this, void 0, void 0, function* () {
925
+ var _a;
926
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setOffsetForCapturedLabel(capturedLabel, offset);
927
+ });
928
+ }
929
+ setOffsetForCapturedLabelField(field, capturedLabel, offset) {
930
+ return __awaiter(this, void 0, void 0, function* () {
931
+ var _a;
932
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setOffsetForCapturedLabelField(capturedLabel, field, offset);
933
+ });
934
+ }
935
+ clearCapturedLabelViews() {
936
+ return __awaiter(this, void 0, void 0, function* () {
937
+ var _a;
938
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.clearCapturedLabelViews();
939
+ });
940
+ }
941
+ }
942
+ __decorate([
943
+ ignoreFromSerialization
944
+ ], LabelCaptureAdvancedOverlay.prototype, "controller", void 0);
945
+ __decorate([
946
+ ignoreFromSerialization
947
+ ], LabelCaptureAdvancedOverlay.prototype, "_view", void 0);
948
+ __decorate([
949
+ ignoreFromSerialization
950
+ ], LabelCaptureAdvancedOverlay.prototype, "_listener", void 0);
951
+ __decorate([
952
+ nameForSerialization('shouldShowScanAreaGuides')
953
+ ], LabelCaptureAdvancedOverlay.prototype, "_shouldShowScanAreaGuides", void 0);
954
+
955
+ class LabelCaptureSettings extends DefaultSerializeable {
956
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
957
+ static fromJSON(json) {
958
+ // tslint:disable-next-line:no-console
959
+ throw new Error('This property is deprecated in favour of LabelCaptureSettings.settingsFromLabelDefinitions. Please update your code to use the new property.');
960
+ }
961
+ static get barcodeDefaults() {
962
+ return getBarcodeDefaults();
963
+ }
964
+ static settingsFromLabelDefinitions(definitions, properties) {
965
+ const settings = new LabelCaptureSettings();
966
+ settings._definitions = definitions;
967
+ if (properties) {
968
+ settings.properties = properties;
969
+ }
970
+ return settings;
971
+ }
972
+ constructor() {
973
+ super();
974
+ this._definitions = [];
975
+ this.properties = {};
976
+ }
977
+ settingsForSymbology(symbology) {
978
+ return LabelCaptureSettings.barcodeDefaults.SymbologySettings[symbology];
979
+ }
980
+ setProperty(name, value) {
981
+ this[name] = value;
982
+ }
983
+ getProperty(name) {
984
+ return this[name];
985
+ }
986
+ }
987
+ __decorate([
988
+ nameForSerialization('labelDefinitions')
989
+ ], LabelCaptureSettings.prototype, "_definitions", void 0);
990
+ __decorate([
991
+ ignoreFromSerialization
992
+ ], LabelCaptureSettings, "barcodeDefaults", null);
993
+
994
+ var LabelDateComponentFormat;
995
+ (function (LabelDateComponentFormat) {
996
+ LabelDateComponentFormat["DMY"] = "dmy";
997
+ LabelDateComponentFormat["MDY"] = "mdy";
998
+ LabelDateComponentFormat["YMD"] = "ymd";
999
+ })(LabelDateComponentFormat || (LabelDateComponentFormat = {}));
1000
+
1001
+ class LabelDateFormat extends DefaultSerializeable {
1002
+ constructor(componentFormat, acceptPartialDates) {
1003
+ super();
1004
+ this._componentFormat = componentFormat;
1005
+ this._acceptPartialDates = acceptPartialDates;
1006
+ }
1007
+ get componentFormat() {
1008
+ return this._componentFormat;
1009
+ }
1010
+ get acceptPartialDates() {
1011
+ return this._acceptPartialDates;
1012
+ }
1013
+ }
1014
+ __decorate([
1015
+ nameForSerialization('componentFormat')
1016
+ ], LabelDateFormat.prototype, "_componentFormat", void 0);
1017
+ __decorate([
1018
+ nameForSerialization('acceptPartialDates')
1019
+ ], LabelDateFormat.prototype, "_acceptPartialDates", void 0);
1020
+
1021
+ class LabelDefinition extends DefaultSerializeable {
1022
+ get name() {
1023
+ return this._name;
1024
+ }
1025
+ get fields() {
1026
+ return this._fields;
1027
+ }
1028
+ set fields(values) {
1029
+ this._fields = values;
1030
+ }
1031
+ get hiddenProperties() {
1032
+ return this._hiddenProperties;
1033
+ }
1034
+ set hiddenProperties(newValue) {
1035
+ for (const key in this._hiddenProperties) {
1036
+ if (Object.prototype.hasOwnProperty.call(this._hiddenProperties, key)) {
1037
+ delete this[key];
1038
+ }
1039
+ }
1040
+ for (const key in newValue) {
1041
+ if (Object.prototype.hasOwnProperty.call(newValue, key)) {
1042
+ const item = newValue[key];
1043
+ this[key] = item;
1044
+ }
1045
+ }
1046
+ this._hiddenProperties = newValue;
1047
+ }
1048
+ static fromJSON(json) {
1049
+ const definition = new LabelDefinition(json.name);
1050
+ definition._fields = json.fields;
1051
+ definition.hiddenProperties = json.hidden_properties;
1052
+ return definition;
1053
+ }
1054
+ static createVinLabelDefinition(name) {
1055
+ const definition = new LabelDefinition(name);
1056
+ definition._type = 'vin';
1057
+ return definition;
1058
+ }
1059
+ static createPriceCaptureDefinition(name) {
1060
+ const definition = new LabelDefinition(name);
1061
+ definition._type = 'priceCapture';
1062
+ return definition;
1063
+ }
1064
+ static createSevenSegmentDisplayLabelDefinition(name) {
1065
+ const definition = new LabelDefinition(name);
1066
+ definition._type = 'sevenSegment';
1067
+ return definition;
1068
+ }
1069
+ constructor(name) {
1070
+ super();
1071
+ this._name = '';
1072
+ this._fields = [];
1073
+ this._type = null;
1074
+ this._hiddenProperties = {};
1075
+ this._name = name;
1076
+ }
1077
+ }
1078
+ __decorate([
1079
+ nameForSerialization('name')
1080
+ ], LabelDefinition.prototype, "_name", void 0);
1081
+ __decorate([
1082
+ nameForSerialization('fields')
1083
+ ], LabelDefinition.prototype, "_fields", void 0);
1084
+ __decorate([
1085
+ nameForSerialization('type'),
1086
+ ignoreFromSerializationIfNull
1087
+ ], LabelDefinition.prototype, "_type", void 0);
1088
+ __decorate([
1089
+ ignoreFromSerialization
1090
+ ], LabelDefinition.prototype, "_hiddenProperties", void 0);
1091
+
1092
+ var LabelFieldLocationType;
1093
+ (function (LabelFieldLocationType) {
1094
+ LabelFieldLocationType["TopLeft"] = "topLeft";
1095
+ LabelFieldLocationType["TopRight"] = "topRight";
1096
+ LabelFieldLocationType["BottomRight"] = "bottomRight";
1097
+ LabelFieldLocationType["BottomLeft"] = "bottomLeft";
1098
+ LabelFieldLocationType["Top"] = "top";
1099
+ LabelFieldLocationType["Right"] = "right";
1100
+ LabelFieldLocationType["Bottom"] = "bottom";
1101
+ LabelFieldLocationType["Left"] = "left";
1102
+ LabelFieldLocationType["Center"] = "center";
1103
+ LabelFieldLocationType["WholeLabel"] = "wholeLabel";
1104
+ })(LabelFieldLocationType || (LabelFieldLocationType = {}));
1105
+
1106
+ class LabelFieldLocation extends DefaultSerializeable {
1107
+ constructor() {
1108
+ super(...arguments);
1109
+ this._rect = null;
1110
+ this._type = null;
1111
+ }
1112
+ static forRect(rect) {
1113
+ const location = new LabelFieldLocation();
1114
+ location._rect = rect;
1115
+ return location;
1116
+ }
1117
+ static for(left, top, right, bottom) {
1118
+ const location = new LabelFieldLocation();
1119
+ location._rect = new Rect(new Point(left, top), new Size(right - left, bottom - top));
1120
+ return location;
1121
+ }
1122
+ static topLeft() {
1123
+ const location = new LabelFieldLocation();
1124
+ location._type = LabelFieldLocationType.TopLeft;
1125
+ return location;
1126
+ }
1127
+ static topRight() {
1128
+ const location = new LabelFieldLocation();
1129
+ location._type = LabelFieldLocationType.TopRight;
1130
+ return location;
1131
+ }
1132
+ static bottomLeft() {
1133
+ const location = new LabelFieldLocation();
1134
+ location._type = LabelFieldLocationType.BottomLeft;
1135
+ return location;
1136
+ }
1137
+ static bottomRight() {
1138
+ const location = new LabelFieldLocation();
1139
+ location._type = LabelFieldLocationType.BottomRight;
1140
+ return location;
1141
+ }
1142
+ static top() {
1143
+ const location = new LabelFieldLocation();
1144
+ location._type = LabelFieldLocationType.Top;
1145
+ return location;
1146
+ }
1147
+ static bottom() {
1148
+ const location = new LabelFieldLocation();
1149
+ location._type = LabelFieldLocationType.Bottom;
1150
+ return location;
1151
+ }
1152
+ static left() {
1153
+ const location = new LabelFieldLocation();
1154
+ location._type = LabelFieldLocationType.Left;
1155
+ return location;
1156
+ }
1157
+ static right() {
1158
+ const location = new LabelFieldLocation();
1159
+ location._type = LabelFieldLocationType.Right;
1160
+ return location;
1161
+ }
1162
+ static center() {
1163
+ const location = new LabelFieldLocation();
1164
+ location._type = LabelFieldLocationType.Center;
1165
+ return location;
1166
+ }
1167
+ static wholeLabel() {
1168
+ const location = new LabelFieldLocation();
1169
+ location._type = LabelFieldLocationType.WholeLabel;
1170
+ return location;
1171
+ }
1172
+ }
1173
+ __decorate([
1174
+ nameForSerialization('rect')
1175
+ ], LabelFieldLocation.prototype, "_rect", void 0);
1176
+ __decorate([
1177
+ nameForSerialization('type'),
1178
+ ignoreFromSerializationIfNull
1179
+ ], LabelFieldLocation.prototype, "_type", void 0);
1180
+
1181
+ var LabelFieldState;
1182
+ (function (LabelFieldState) {
1183
+ LabelFieldState["Captured"] = "captured";
1184
+ LabelFieldState["Predicted"] = "predicted";
1185
+ LabelFieldState["Unknown"] = "unknown";
1186
+ })(LabelFieldState || (LabelFieldState = {}));
1187
+
1188
+ var LabelFieldType;
1189
+ (function (LabelFieldType) {
1190
+ LabelFieldType["Barcode"] = "barcode";
1191
+ LabelFieldType["Text"] = "text";
1192
+ LabelFieldType["Unknown"] = "unknown";
1193
+ })(LabelFieldType || (LabelFieldType = {}));
1194
+
1195
+ class PackingDateText extends TextField {
1196
+ constructor(name) {
1197
+ super(name);
1198
+ this._fieldType = 'packingDateText';
1199
+ this._dataTypePatterns = [];
1200
+ this._labelDateFormat = null;
1201
+ }
1202
+ get dataTypePatterns() {
1203
+ return this._dataTypePatterns;
1204
+ }
1205
+ get labelDateFormat() {
1206
+ return this._labelDateFormat;
1207
+ }
1208
+ set labelDateFormat(value) {
1209
+ this._labelDateFormat = value;
1210
+ }
1211
+ }
1212
+ __decorate([
1213
+ nameForSerialization('fieldType')
1214
+ ], PackingDateText.prototype, "_fieldType", void 0);
1215
+ __decorate([
1216
+ nameForSerialization('dataTypePatterns')
1217
+ ], PackingDateText.prototype, "_dataTypePatterns", void 0);
1218
+ __decorate([
1219
+ nameForSerialization('labelDateFormat')
1220
+ ], PackingDateText.prototype, "_labelDateFormat", void 0);
1221
+
1222
+ class PartNumberBarcode extends BarcodeField {
1223
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
1224
+ return new PartNumberBarcode(name, symbologySettings);
1225
+ }
1226
+ static initWithNameAndSymbologies(name, symbologies) {
1227
+ const symbologySettings = Object.values(symbologies).map(symbology => {
1228
+ const symbologyObj = PartNumberBarcode.barcodeDefaults.SymbologySettings[symbology];
1229
+ symbologyObj.isEnabled = true;
1230
+ return symbologyObj;
1231
+ });
1232
+ return new PartNumberBarcode(name, symbologySettings);
1233
+ }
1234
+ static initWithNameAndSymbology(name, symbology) {
1235
+ return PartNumberBarcode.initWithNameAndSymbologies(name, [symbology]);
1236
+ }
1237
+ static get barcodeDefaults() {
1238
+ return getBarcodeDefaults();
1239
+ }
1240
+ constructor(name, symbologies) {
1241
+ super(name, symbologies);
1242
+ this._fieldType = 'partNumberBarcode';
1243
+ }
1244
+ }
1245
+ __decorate([
1246
+ nameForSerialization('fieldType')
1247
+ ], PartNumberBarcode.prototype, "_fieldType", void 0);
1248
+
1249
+ class SerialNumberBarcode extends BarcodeField {
1250
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
1251
+ return new SerialNumberBarcode(name, symbologySettings);
1252
+ }
1253
+ static initWithNameAndSymbologies(name, symbologies) {
1254
+ const symbologySettings = Object.values(symbologies).map(symbology => {
1255
+ const symbologyObj = SerialNumberBarcode.barcodeDefaults.SymbologySettings[symbology];
1256
+ symbologyObj.isEnabled = true;
1257
+ return symbologyObj;
1258
+ });
1259
+ return new SerialNumberBarcode(name, symbologySettings);
1260
+ }
1261
+ static initWithNameAndSymbology(name, symbology) {
1262
+ return SerialNumberBarcode.initWithNameAndSymbologies(name, [symbology]);
1263
+ }
1264
+ static get barcodeDefaults() {
1265
+ return getBarcodeDefaults();
1266
+ }
1267
+ constructor(name, symbologies) {
1268
+ super(name, symbologies);
1269
+ this._fieldType = 'serialNumberBarcode';
1270
+ }
1271
+ }
1272
+ __decorate([
1273
+ nameForSerialization('fieldType')
1274
+ ], SerialNumberBarcode.prototype, "_fieldType", void 0);
1275
+
1276
+ class TotalPriceText extends TextField {
1277
+ constructor(name) {
1278
+ super(name);
1279
+ this._fieldType = 'totalPriceText';
1280
+ this._dataTypePatterns = [];
1281
+ }
1282
+ get dataTypePatterns() {
1283
+ return this._dataTypePatterns;
1284
+ }
1285
+ set dataTypePatterns(value) {
1286
+ this._dataTypePatterns = value;
1287
+ }
1288
+ }
1289
+ __decorate([
1290
+ nameForSerialization('fieldType')
1291
+ ], TotalPriceText.prototype, "_fieldType", void 0);
1292
+ __decorate([
1293
+ nameForSerialization('dataTypePatterns')
1294
+ ], TotalPriceText.prototype, "_dataTypePatterns", void 0);
1295
+
1296
+ class UnitPriceText extends TextField {
1297
+ constructor(name) {
1298
+ super(name);
1299
+ this._fieldType = 'unitPriceText';
1300
+ this._dataTypePatterns = [];
1301
+ }
1302
+ get dataTypePatterns() {
1303
+ return this._dataTypePatterns;
1304
+ }
1305
+ set dataTypePatterns(value) {
1306
+ this._dataTypePatterns = value;
1307
+ }
1308
+ }
1309
+ __decorate([
1310
+ nameForSerialization('fieldType')
1311
+ ], UnitPriceText.prototype, "_fieldType", void 0);
1312
+ __decorate([
1313
+ nameForSerialization('dataTypePatterns')
1314
+ ], UnitPriceText.prototype, "_dataTypePatterns", void 0);
1315
+
1316
+ class WeightText extends TextField {
1317
+ constructor(name) {
1318
+ super(name);
1319
+ this._fieldType = 'weightText';
1320
+ this._dataTypePatterns = [];
1321
+ }
1322
+ get dataTypePatterns() {
1323
+ return this._dataTypePatterns;
1324
+ }
1325
+ set dataTypePatterns(value) {
1326
+ this._dataTypePatterns = value;
1327
+ }
1328
+ }
1329
+ __decorate([
1330
+ nameForSerialization('fieldType')
1331
+ ], WeightText.prototype, "_fieldType", void 0);
1332
+ __decorate([
1333
+ nameForSerialization('dataTypePatterns')
1334
+ ], WeightText.prototype, "_dataTypePatterns", void 0);
1335
+
1336
+ var LabelCaptureBasicOverlayListenerEvents;
1337
+ (function (LabelCaptureBasicOverlayListenerEvents) {
1338
+ LabelCaptureBasicOverlayListenerEvents["brushForFieldOfLabel"] = "LabelCaptureBasicOverlayListener.brushForFieldOfLabel";
1339
+ LabelCaptureBasicOverlayListenerEvents["brushForLabel"] = "LabelCaptureBasicOverlayListener.brushForLabel";
1340
+ LabelCaptureBasicOverlayListenerEvents["didTapLabel"] = "LabelCaptureBasicOverlayListener.didTapLabel";
1341
+ })(LabelCaptureBasicOverlayListenerEvents || (LabelCaptureBasicOverlayListenerEvents = {}));
1342
+ class LabelCaptureBasicOverlayController extends BaseController {
1343
+ constructor(overlay) {
1344
+ super('LabelCaptureBasicOverlayProxy');
1345
+ // Arrow function wrappers to avoid .bind(this) and always use current class state
1346
+ this.handleBrushForFieldOfLabelWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
1347
+ return this.handleBrushForFieldOfLabel(ev);
1348
+ });
1349
+ this.handleBrushForLabelWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
1350
+ return this.handleBrushForLabel(ev);
1351
+ });
1352
+ this.handleDidTapLabelWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
1353
+ return this.handleDidTapLabel(ev);
1354
+ });
1355
+ this.overlay = overlay;
1356
+ this.initialize();
1357
+ }
1358
+ initialize() {
1359
+ if (this.overlay.listener) {
1360
+ this.subscribeListener();
1361
+ }
1362
+ }
1363
+ setBrushForFieldOfLabel(brush, field, label) {
1364
+ return this._proxy.$setBrushForFieldOfLabel({
1365
+ brushJson: brush ? JSON.stringify(brush.toJSON()) : null,
1366
+ fieldName: field.name,
1367
+ trackingId: label.trackingID,
1368
+ dataCaptureViewId: this.dataCaptureViewId
1369
+ });
1370
+ }
1371
+ setBrushForLabel(brush, label) {
1372
+ return this._proxy.$setBrushForLabel({
1373
+ brushJson: brush ? JSON.stringify(brush.toJSON()) : null,
1374
+ trackingId: label.trackingID,
1375
+ dataCaptureViewId: this.dataCaptureViewId
1376
+ });
1377
+ }
1378
+ subscribeListener() {
1379
+ return __awaiter(this, void 0, void 0, function* () {
1380
+ if (this.dataCaptureViewId !== -1) {
1381
+ yield this._proxy.$registerListenerForBasicOverlayEvents({ dataCaptureViewId: this.dataCaptureViewId });
1382
+ }
1383
+ this._proxy.subscribeForEvents(Object.values(LabelCaptureBasicOverlayListenerEvents));
1384
+ this._proxy.eventEmitter.on(LabelCaptureBasicOverlayListenerEvents.brushForFieldOfLabel, this.handleBrushForFieldOfLabelWrapper);
1385
+ this._proxy.eventEmitter.on(LabelCaptureBasicOverlayListenerEvents.brushForLabel, this.handleBrushForLabelWrapper);
1386
+ this._proxy.eventEmitter.on(LabelCaptureBasicOverlayListenerEvents.didTapLabel, this.handleDidTapLabelWrapper);
1387
+ });
1388
+ }
1389
+ handleBrushForFieldOfLabel(ev) {
1390
+ return __awaiter(this, void 0, void 0, function* () {
1391
+ const payload = JSON.parse(ev.data);
1392
+ let brush = this.overlay.capturedFieldBrush;
1393
+ const field = LabelField.fromJSON(JSON.parse(payload.field));
1394
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1395
+ if (this.overlay.listener && this.overlay.listener.brushForFieldOfLabel) {
1396
+ brush = this.overlay.listener.brushForFieldOfLabel(this.overlay, field, label);
1397
+ }
1398
+ yield this.setBrushForFieldOfLabel(brush, field, label);
1399
+ });
1400
+ }
1401
+ handleBrushForLabel(ev) {
1402
+ return __awaiter(this, void 0, void 0, function* () {
1403
+ const payload = JSON.parse(ev.data);
1404
+ let brush = this.overlay.labelBrush;
1405
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1406
+ if (this.overlay.listener && this.overlay.listener.brushForLabel) {
1407
+ brush = this.overlay.listener.brushForLabel(this.overlay, label);
1408
+ }
1409
+ yield this.setBrushForLabel(brush, label);
1410
+ });
1411
+ }
1412
+ handleDidTapLabel(ev) {
1413
+ return __awaiter(this, void 0, void 0, function* () {
1414
+ const payload = JSON.parse(ev.data);
1415
+ if (this.overlay.listener && this.overlay.listener.didTapLabel) {
1416
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1417
+ this.overlay.listener.didTapLabel(this.overlay, label);
1418
+ }
1419
+ });
1420
+ }
1421
+ unsubscribeListener() {
1422
+ return __awaiter(this, void 0, void 0, function* () {
1423
+ this._proxy.$unregisterListenerForBasicOverlayEvents({ dataCaptureViewId: this.dataCaptureViewId });
1424
+ this._proxy.unsubscribeFromEvents(Object.values(LabelCaptureBasicOverlayListenerEvents));
1425
+ this._proxy.eventEmitter.off(LabelCaptureBasicOverlayListenerEvents.brushForFieldOfLabel, this.handleBrushForFieldOfLabelWrapper);
1426
+ this._proxy.eventEmitter.off(LabelCaptureBasicOverlayListenerEvents.brushForLabel, this.handleBrushForLabelWrapper);
1427
+ this._proxy.eventEmitter.off(LabelCaptureBasicOverlayListenerEvents.didTapLabel, this.handleDidTapLabelWrapper);
1428
+ });
1429
+ }
1430
+ updateBasicOverlay(basicOverlayJson) {
1431
+ return this._proxy.$updateLabelCaptureBasicOverlay({ dataCaptureViewId: this.dataCaptureViewId, basicOverlayJson });
1432
+ }
1433
+ dispose() {
1434
+ this.unsubscribeListener();
1435
+ this._proxy.dispose();
1436
+ }
1437
+ get dataCaptureViewId() {
1438
+ var _a, _b;
1439
+ return (_b = (_a = this.overlay.view) === null || _a === void 0 ? void 0 : _a.viewId) !== null && _b !== void 0 ? _b : -1;
1440
+ }
1441
+ }
1442
+
1443
+ class LabelCaptureBasicOverlay extends DefaultSerializeable {
1444
+ static get defaultPredictedFieldBrush() {
1445
+ return LabelCaptureBasicOverlay.labelCaptureDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultPredictedFieldBrush;
1446
+ }
1447
+ static get defaultCapturedFieldBrush() {
1448
+ return LabelCaptureBasicOverlay.labelCaptureDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultCapturedFieldBrush;
1449
+ }
1450
+ static get defaultLabelBrush() {
1451
+ return LabelCaptureBasicOverlay.labelCaptureDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultLabelBrush;
1452
+ }
1453
+ static get labelCaptureDefaults() {
1454
+ return getLabelCaptureDefaults();
1455
+ }
1456
+ get view() {
1457
+ return this._view;
1458
+ }
1459
+ set view(newView) {
1460
+ var _a, _b;
1461
+ if (newView === null) {
1462
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
1463
+ this.controller = null;
1464
+ this._view = null;
1465
+ return;
1466
+ }
1467
+ this._view = newView;
1468
+ (_b = this.controller) !== null && _b !== void 0 ? _b : (this.controller = new LabelCaptureBasicOverlayController(this));
1469
+ }
1470
+ get predictedFieldBrush() {
1471
+ return this._predictedFieldBrush;
1472
+ }
1473
+ set predictedFieldBrush(newBrush) {
1474
+ var _a;
1475
+ this._predictedFieldBrush = newBrush;
1476
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1477
+ }
1478
+ get capturedFieldBrush() {
1479
+ return this._capturedFieldBrush;
1480
+ }
1481
+ set capturedFieldBrush(newBrush) {
1482
+ var _a;
1483
+ this._capturedFieldBrush = newBrush;
1484
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1485
+ }
1486
+ get labelBrush() {
1487
+ return this._labelBrush;
1488
+ }
1489
+ set labelBrush(newBrush) {
1490
+ var _a;
1491
+ this._labelBrush = newBrush;
1492
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1493
+ }
1494
+ get listener() {
1495
+ return this._listener;
1496
+ }
1497
+ set listener(listener) {
1498
+ var _a, _b;
1499
+ this._listener = listener;
1500
+ this.hasListener = listener != null;
1501
+ if (this.hasListener) {
1502
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.subscribeListener();
1503
+ }
1504
+ else {
1505
+ (_b = this.controller) === null || _b === void 0 ? void 0 : _b.unsubscribeListener();
1506
+ }
1507
+ }
1508
+ get shouldShowScanAreaGuides() {
1509
+ return this._shouldShowScanAreaGuides;
1510
+ }
1511
+ set shouldShowScanAreaGuides(shouldShow) {
1512
+ var _a;
1513
+ this._shouldShowScanAreaGuides = shouldShow;
1514
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1515
+ }
1516
+ get viewfinder() {
1517
+ return this._viewfinder;
1518
+ }
1519
+ set viewfinder(newViewfinder) {
1520
+ var _a;
1521
+ this._viewfinder = newViewfinder;
1522
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1523
+ }
1524
+ constructor(mode) {
1525
+ super();
1526
+ this.type = 'labelCaptureBasic';
1527
+ this.controller = null;
1528
+ this._view = null;
1529
+ this._predictedFieldBrush = LabelCaptureBasicOverlay.defaultPredictedFieldBrush.copy;
1530
+ this._capturedFieldBrush = LabelCaptureBasicOverlay.defaultCapturedFieldBrush.copy;
1531
+ this._labelBrush = LabelCaptureBasicOverlay.defaultLabelBrush.copy;
1532
+ this._shouldShowScanAreaGuides = false;
1533
+ this.hasListener = false;
1534
+ this._listener = null;
1535
+ this._viewfinder = null;
1536
+ this.modeId = mode.modeId;
1537
+ }
1538
+ setBrushForFieldOfLabel(brush, field, label) {
1539
+ return __awaiter(this, void 0, void 0, function* () {
1540
+ var _a;
1541
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setBrushForFieldOfLabel(brush, field, label);
1542
+ });
1543
+ }
1544
+ setBrushForLabel(brush, label) {
1545
+ return __awaiter(this, void 0, void 0, function* () {
1546
+ var _a;
1547
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setBrushForLabel(brush, label);
1548
+ });
1549
+ }
1550
+ }
1551
+ __decorate([
1552
+ ignoreFromSerialization
1553
+ ], LabelCaptureBasicOverlay.prototype, "controller", void 0);
1554
+ __decorate([
1555
+ ignoreFromSerialization
1556
+ ], LabelCaptureBasicOverlay.prototype, "_view", void 0);
1557
+ __decorate([
1558
+ nameForSerialization('defaultPredictedFieldBrush')
1559
+ ], LabelCaptureBasicOverlay.prototype, "_predictedFieldBrush", void 0);
1560
+ __decorate([
1561
+ nameForSerialization('defaultCapturedFieldBrush')
1562
+ ], LabelCaptureBasicOverlay.prototype, "_capturedFieldBrush", void 0);
1563
+ __decorate([
1564
+ nameForSerialization('defaultLabelBrush')
1565
+ ], LabelCaptureBasicOverlay.prototype, "_labelBrush", void 0);
1566
+ __decorate([
1567
+ nameForSerialization('shouldShowScanAreaGuides')
1568
+ ], LabelCaptureBasicOverlay.prototype, "_shouldShowScanAreaGuides", void 0);
1569
+ __decorate([
1570
+ ignoreFromSerialization
1571
+ ], LabelCaptureBasicOverlay.prototype, "_listener", void 0);
1572
+ __decorate([
1573
+ serializationDefault(NoViewfinder),
1574
+ nameForSerialization('viewfinder')
1575
+ ], LabelCaptureBasicOverlay.prototype, "_viewfinder", void 0);
1576
+
1577
+ var LabelCaptureValidationFlowListenerEvents;
1578
+ (function (LabelCaptureValidationFlowListenerEvents) {
1579
+ LabelCaptureValidationFlowListenerEvents["didCaptureLabelWithFields"] = "LabelCaptureValidationFlowListener.didCaptureLabelWithFields";
1580
+ })(LabelCaptureValidationFlowListenerEvents || (LabelCaptureValidationFlowListenerEvents = {}));
1581
+ class LabelCaptureValidationFlowOverlayController extends BaseController {
1582
+ constructor(overlay) {
1583
+ super('LabelCaptureValidationFlowOverlayProxy');
1584
+ this.isSubscribed = false;
1585
+ // Arrow function wrapper to avoid .bind(this) and always use current class state
1586
+ this.handleDidCaptureLabelWithFieldsEventWrapper = (ev) => __awaiter(this, void 0, void 0, function* () {
1587
+ return this.handleDidCaptureLabelWithFieldsEvent(ev);
1588
+ });
1589
+ this.overlay = overlay;
1590
+ this.initialize();
1591
+ }
1592
+ initialize() {
1593
+ if (this.overlay.listener) {
1594
+ this.subscribeLabelCaptureValidationFlowListener();
1595
+ }
1596
+ }
1597
+ updateValidationFlowOverlay() {
1598
+ return __awaiter(this, void 0, void 0, function* () {
1599
+ yield this._proxy.$updateLabelCaptureValidationFlowOverlay({ dataCaptureViewId: this.dataCaptureViewId, overlayJson: JSON.stringify(this.overlay.toJSON()) });
1600
+ });
1601
+ }
1602
+ subscribeLabelCaptureValidationFlowListener() {
1603
+ if (this.isSubscribed) {
1604
+ return;
1605
+ }
1606
+ this._proxy.$registerListenerForValidationFlowEvents({ dataCaptureViewId: this.dataCaptureViewId });
1607
+ this._proxy.subscribeForEvents(Object.values(LabelCaptureValidationFlowListenerEvents));
1608
+ this._proxy.eventEmitter.on(LabelCaptureValidationFlowListenerEvents.didCaptureLabelWithFields, this.handleDidCaptureLabelWithFieldsEventWrapper);
1609
+ this.isSubscribed = true;
1610
+ }
1611
+ unsubscribeLabelCaptureValidationFlowListener() {
1612
+ if (!this.isSubscribed) {
1613
+ return;
1614
+ }
1615
+ this._proxy.$unregisterListenerForValidationFlowEvents({ dataCaptureViewId: this.dataCaptureViewId });
1616
+ this._proxy.eventEmitter.off(LabelCaptureValidationFlowListenerEvents.didCaptureLabelWithFields, this.handleDidCaptureLabelWithFieldsEventWrapper);
1617
+ this._proxy.unsubscribeFromEvents(Object.values(LabelCaptureValidationFlowListenerEvents));
1618
+ this.isSubscribed = false;
1619
+ }
1620
+ handleDidCaptureLabelWithFieldsEvent(ev) {
1621
+ return __awaiter(this, void 0, void 0, function* () {
1622
+ const payload = JSON.parse(ev.data);
1623
+ const fields = payload.fields.map((field) => LabelField.fromJSON(JSON.parse(field)));
1624
+ this.notifyListenersOfDidCaptureLabelWithFields(fields);
1625
+ });
1626
+ }
1627
+ notifyListenersOfDidCaptureLabelWithFields(fields) {
1628
+ var _a;
1629
+ (_a = this.overlay.listener) === null || _a === void 0 ? void 0 : _a.didCaptureLabelWithFields(fields);
1630
+ }
1631
+ get dataCaptureViewId() {
1632
+ var _a, _b;
1633
+ return (_b = (_a = this.overlay.view) === null || _a === void 0 ? void 0 : _a.viewId) !== null && _b !== void 0 ? _b : -1;
1634
+ }
1635
+ dispose() {
1636
+ this.unsubscribeLabelCaptureValidationFlowListener();
1637
+ this._proxy.dispose();
1638
+ }
1639
+ }
1640
+
1641
+ class LabelCaptureValidationFlowOverlay extends DefaultSerializeable {
1642
+ get view() {
1643
+ return this._view;
1644
+ }
1645
+ set view(newView) {
1646
+ var _a, _b;
1647
+ if (newView === null) {
1648
+ this._view = null;
1649
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
1650
+ this.controller = null;
1651
+ return;
1652
+ }
1653
+ this._view = newView;
1654
+ (_b = this.controller) !== null && _b !== void 0 ? _b : (this.controller = new LabelCaptureValidationFlowOverlayController(this));
1655
+ }
1656
+ get listener() {
1657
+ return this._listener;
1658
+ }
1659
+ set listener(listener) {
1660
+ var _a, _b;
1661
+ this.hasListener = listener != null;
1662
+ this._listener = listener;
1663
+ if (listener == null) {
1664
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.unsubscribeLabelCaptureValidationFlowListener();
1665
+ }
1666
+ else if (this.listener == null) {
1667
+ (_b = this.controller) === null || _b === void 0 ? void 0 : _b.subscribeLabelCaptureValidationFlowListener();
1668
+ }
1669
+ }
1670
+ applySettings(settings) {
1671
+ var _a, _b;
1672
+ this.settings = settings;
1673
+ return (_b = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateValidationFlowOverlay()) !== null && _b !== void 0 ? _b : Promise.resolve();
1674
+ }
1675
+ constructor(mode) {
1676
+ super();
1677
+ this.type = 'validationFlow';
1678
+ this.settings = null;
1679
+ this.hasListener = false;
1680
+ this._listener = null;
1681
+ this.controller = null;
1682
+ this._view = null;
1683
+ this.modeId = mode.modeId;
1684
+ }
1685
+ }
1686
+ __decorate([
1687
+ nameForSerialization('hasListener')
1688
+ ], LabelCaptureValidationFlowOverlay.prototype, "hasListener", void 0);
1689
+ __decorate([
1690
+ ignoreFromSerialization
1691
+ ], LabelCaptureValidationFlowOverlay.prototype, "_listener", void 0);
1692
+ __decorate([
1693
+ ignoreFromSerialization
1694
+ ], LabelCaptureValidationFlowOverlay.prototype, "controller", void 0);
1695
+ __decorate([
1696
+ ignoreFromSerialization
1697
+ ], LabelCaptureValidationFlowOverlay.prototype, "_view", void 0);
1698
+
1699
+ class LabelCaptureValidationFlowSettings extends DefaultSerializeable {
1700
+ static create() {
1701
+ return new LabelCaptureValidationFlowSettings();
1702
+ }
1703
+ constructor() {
1704
+ super();
1705
+ const defaults = getLabelCaptureDefaults().LabelCapture.LabelCaptureValidationFlowOverlay.Settings;
1706
+ this._missingFieldsHintText = defaults.missingFieldsHintText;
1707
+ this._standbyHintText = defaults.standbyHintText;
1708
+ this._validationHintText = defaults.validationHintText;
1709
+ this._validationErrorText = defaults.validationErrorText;
1710
+ this._requiredFieldErrorText = defaults.requiredFieldErrorText;
1711
+ this._manualInputButtonText = defaults.manualInputButtonText;
1712
+ }
1713
+ get missingFieldsHintText() {
1714
+ return this._missingFieldsHintText;
1715
+ }
1716
+ set missingFieldsHintText(text) {
1717
+ this._missingFieldsHintText = text;
1718
+ }
1719
+ get standbyHintText() {
1720
+ return this._standbyHintText;
1721
+ }
1722
+ set standbyHintText(text) {
1723
+ this._standbyHintText = text;
1724
+ }
1725
+ get validationHintText() {
1726
+ return this._validationHintText;
1727
+ }
1728
+ set validationHintText(text) {
1729
+ this._validationHintText = text;
1730
+ }
1731
+ get validationErrorText() {
1732
+ return this._validationErrorText;
1733
+ }
1734
+ set validationErrorText(text) {
1735
+ this._validationErrorText = text;
1736
+ }
1737
+ get requiredFieldErrorText() {
1738
+ return this._requiredFieldErrorText;
1739
+ }
1740
+ set requiredFieldErrorText(text) {
1741
+ this._requiredFieldErrorText = text;
1742
+ }
1743
+ get manualInputButtonText() {
1744
+ return this._manualInputButtonText;
1745
+ }
1746
+ set manualInputButtonText(text) {
1747
+ this._manualInputButtonText = text;
1748
+ }
1749
+ }
1750
+ __decorate([
1751
+ nameForSerialization('missingFieldsHintText')
1752
+ ], LabelCaptureValidationFlowSettings.prototype, "_missingFieldsHintText", void 0);
1753
+ __decorate([
1754
+ nameForSerialization('standbyHintText')
1755
+ ], LabelCaptureValidationFlowSettings.prototype, "_standbyHintText", void 0);
1756
+ __decorate([
1757
+ nameForSerialization('validationHintText')
1758
+ ], LabelCaptureValidationFlowSettings.prototype, "_validationHintText", void 0);
1759
+ __decorate([
1760
+ nameForSerialization('validationErrorText')
1761
+ ], LabelCaptureValidationFlowSettings.prototype, "_validationErrorText", void 0);
1762
+ __decorate([
1763
+ nameForSerialization('requiredFieldErrorText')
1764
+ ], LabelCaptureValidationFlowSettings.prototype, "_requiredFieldErrorText", void 0);
1765
+ __decorate([
1766
+ nameForSerialization('manualInputButtonText')
1767
+ ], LabelCaptureValidationFlowSettings.prototype, "_manualInputButtonText", void 0);
1768
+
1769
+ class LabelCaptureAdvancedOverlayView extends DefaultSerializeable {
1770
+ static withHTMLElement(element, options) {
1771
+ return this.getEncodedImageData(element).then(data => new LabelCaptureAdvancedOverlayView(data, options));
1772
+ }
1773
+ static withBase64EncodedData(data, options) {
1774
+ return Promise.resolve(new LabelCaptureAdvancedOverlayView(data, options));
1775
+ }
1776
+ static getEncodedImageData(element) {
1777
+ return this.getBase64DataForSVG(this.getSVGDataForElement(element));
1778
+ }
1779
+ static getSize(element) {
1780
+ const isInDOM = document.body.contains(element);
1781
+ if (!isInDOM) {
1782
+ document.body.appendChild(element);
1783
+ }
1784
+ const size = element.getBoundingClientRect();
1785
+ if (!isInDOM) {
1786
+ document.body.removeChild(element);
1787
+ }
1788
+ return new Size(size.width, size.height);
1789
+ }
1790
+ static getSVGDataForElement(element) {
1791
+ const size = this.getSize(element);
1792
+ const data = encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${size.width}px" height="${size.height}px">
1793
+ <foreignObject width="100%" height="100%">
1794
+ <div xmlns="http://www.w3.org/1999/xhtml">
1795
+ ${element.outerHTML}
1796
+ </div>
1797
+ </foreignObject>
1798
+ </svg>`);
1799
+ return { data, size };
1800
+ }
1801
+ static getCanvasWithSize(size) {
1802
+ const canvas = document.createElement('canvas');
1803
+ canvas.width = size.width;
1804
+ canvas.height = size.height;
1805
+ return canvas;
1806
+ }
1807
+ static getBase64DataForSVG(svgData) {
1808
+ return new Promise((resolve, reject) => {
1809
+ const image = new Image();
1810
+ image.onload = () => {
1811
+ const canvas = this.getCanvasWithSize(svgData.size);
1812
+ canvas.getContext('2d').drawImage(image, 0, 0);
1813
+ resolve(canvas.toDataURL('image/png', 1));
1814
+ };
1815
+ image.onerror = reject;
1816
+ image.src = 'data:image/svg+xml,' + svgData.data;
1817
+ });
1818
+ }
1819
+ constructor(encodedData, options) {
1820
+ super();
1821
+ if (options == null) {
1822
+ options = { scale: 1 };
1823
+ }
1824
+ this.data = encodedData;
1825
+ this.options = options;
1826
+ }
1827
+ }
1828
+
1829
+ var LabelExports = /*#__PURE__*/Object.freeze({
1830
+ __proto__: null,
1831
+ BarcodeField: BarcodeField,
1832
+ CapturedLabel: CapturedLabel,
1833
+ CustomBarcode: CustomBarcode,
1834
+ CustomText: CustomText,
1835
+ ExpiryDateText: ExpiryDateText,
1836
+ ImeiOneBarcode: ImeiOneBarcode,
1837
+ ImeiTwoBarcode: ImeiTwoBarcode,
1838
+ LabelCapture: LabelCapture,
1839
+ LabelCaptureAdvancedOverlay: LabelCaptureAdvancedOverlay,
1840
+ LabelCaptureAdvancedOverlayView: LabelCaptureAdvancedOverlayView,
1841
+ LabelCaptureBasicOverlay: LabelCaptureBasicOverlay,
1842
+ LabelCaptureFeedback: LabelCaptureFeedback,
1843
+ LabelCaptureSession: LabelCaptureSession,
1844
+ LabelCaptureSettings: LabelCaptureSettings,
1845
+ LabelCaptureValidationFlowOverlay: LabelCaptureValidationFlowOverlay,
1846
+ LabelCaptureValidationFlowSettings: LabelCaptureValidationFlowSettings,
1847
+ get LabelDateComponentFormat () { return LabelDateComponentFormat; },
1848
+ LabelDateFormat: LabelDateFormat,
1849
+ LabelDateResult: LabelDateResult,
1850
+ LabelDefinition: LabelDefinition,
1851
+ LabelField: LabelField,
1852
+ LabelFieldDefinition: LabelFieldDefinition,
1853
+ LabelFieldLocation: LabelFieldLocation,
1854
+ get LabelFieldLocationType () { return LabelFieldLocationType; },
1855
+ get LabelFieldState () { return LabelFieldState; },
1856
+ get LabelFieldType () { return LabelFieldType; },
1857
+ PackingDateText: PackingDateText,
1858
+ PartNumberBarcode: PartNumberBarcode,
1859
+ SerialNumberBarcode: SerialNumberBarcode,
1860
+ TextField: TextField,
1861
+ TotalPriceText: TotalPriceText,
1862
+ UnitPriceText: UnitPriceText,
1863
+ WeightText: WeightText
1864
+ });
1865
+
1866
+ const pluginName = 'ScanditLabelNative';
1867
+ // tslint:disable-next-line:variable-name
1868
+ const Capacitor = {
1869
+ pluginName,
1870
+ defaults: {},
1871
+ exec: (success, error, functionName, args) => capacitorExec(success, error, pluginName, functionName, args),
1872
+ };
1873
+ const getDefaults = async () => {
1874
+ try {
1875
+ const defaultsJSON = await window.Capacitor.Plugins[pluginName]['getDefaults']();
1876
+ loadLabelCaptureDefaults(defaultsJSON);
1877
+ Capacitor.defaults = getLabelCaptureDefaults();
1878
+ }
1879
+ catch (error) {
1880
+ // tslint:disable-next-line:no-console
1881
+ console.warn(error);
1882
+ }
1883
+ return Capacitor.defaults;
1884
+ };
1885
+ const capacitorLabelNativeCaller = new CapacitorNativeCaller(Capacitor.pluginName);
1886
+
1887
+ function initLabelProxy() {
1888
+ FactoryMaker.bindLazyInstance('LabelCaptureProxy', () => {
1889
+ return createNativeProxy(capacitorLabelNativeCaller);
1890
+ });
1891
+ FactoryMaker.bindLazyInstance('LabelCaptureBasicOverlayProxy', () => {
1892
+ return createNativeProxy(capacitorLabelNativeCaller);
1893
+ });
1894
+ FactoryMaker.bindLazyInstance('LabelCaptureAdvancedOverlayProxy', () => {
1895
+ return createNativeProxy(capacitorLabelNativeCaller);
1896
+ });
1897
+ FactoryMaker.bindLazyInstance('LabelCaptureValidationFlowOverlayProxy', () => {
1898
+ return createNativeProxy(capacitorLabelNativeCaller);
1899
+ });
1900
+ }
1901
+
1902
+ class ScanditLabelPluginImplementation {
1903
+ async initialize(coreDefaults) {
1904
+ CapacitorCore.defaults = coreDefaults;
1905
+ await getDefaults();
1906
+ initLabelProxy();
1907
+ const api = Object.assign({}, LabelExports);
1908
+ return api;
1909
+ }
1910
+ }
1911
+ registerPlugin('ScanditLabelPlugin', {
1912
+ android: () => new ScanditLabelPluginImplementation(),
1913
+ ios: () => new ScanditLabelPluginImplementation(),
1914
+ web: () => new ScanditLabelPluginImplementation(),
1915
+ });
1916
+ // tslint:disable-next-line:variable-name
1917
+ const ScanditLabelPlugin = new ScanditLabelPluginImplementation();
1918
+
1919
+ export { BarcodeField, CapturedLabel, CustomBarcode, CustomText, ExpiryDateText, ImeiOneBarcode, ImeiTwoBarcode, LabelCapture, LabelCaptureAdvancedOverlay, LabelCaptureAdvancedOverlayView, LabelCaptureBasicOverlay, LabelCaptureFeedback, LabelCaptureSession, LabelCaptureSettings, LabelCaptureValidationFlowOverlay, LabelCaptureValidationFlowSettings, LabelDateComponentFormat, LabelDateFormat, LabelDateResult, LabelDefinition, LabelField, LabelFieldDefinition, LabelFieldLocation, LabelFieldLocationType, LabelFieldState, LabelFieldType, PackingDateText, PartNumberBarcode, ScanditLabelPlugin, ScanditLabelPluginImplementation, SerialNumberBarcode, TextField, TotalPriceText, UnitPriceText, WeightText };