ngx-scandoc 0.0.1 → 1.0.2

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 (85) hide show
  1. package/core/app.worker.d.ts +1 -0
  2. package/core/components/base.component.d.ts +6 -0
  3. package/core/components/camera-switch/camera-switch.component.d.ts +11 -0
  4. package/core/components/components.module.d.ts +15 -0
  5. package/core/components/scan/scan.component.d.ts +120 -0
  6. package/core/components/scan-results/scan-results.component.d.ts +20 -0
  7. package/core/components/webcam/domain/webcam-image.d.ts +35 -0
  8. package/core/components/webcam/domain/webcam-init-error.d.ts +4 -0
  9. package/core/components/webcam/domain/webcam-mirror-properties.d.ts +3 -0
  10. package/core/components/webcam/util/webcam.util.d.ts +8 -0
  11. package/core/components/webcam/webcam/webcam.component.d.ts +205 -0
  12. package/core/components/webcam/webcam.module.d.ts +9 -0
  13. package/core/interfaces/config.d.ts +16 -0
  14. package/core/pipes/pipes.module.d.ts +7 -0
  15. package/core/pipes/safeResourceUrl.pipe.d.ts +10 -0
  16. package/core/shared/material.module.d.ts +28 -0
  17. package/dialogs/components/blank/blank.component.d.ts +16 -0
  18. package/dialogs/components/confirm/confirm.component.d.ts +30 -0
  19. package/dialogs/components/loading/loading.component.d.ts +5 -0
  20. package/dialogs/components/scan-profile/scan-profile.component.d.ts +18 -0
  21. package/dialogs/components/scan-selfie/scan-selfie.component.d.ts +83 -0
  22. package/dialogs/components/turn-document/turn-document.component.d.ts +12 -0
  23. package/dialogs/dialogs.core.provider.d.ts +18 -0
  24. package/dialogs/dialogs.module.d.ts +21 -0
  25. package/esm2020/core/app.worker.mjs +236 -0
  26. package/esm2020/core/components/base.component.mjs +15 -0
  27. package/esm2020/core/components/camera-switch/camera-switch.component.mjs +22 -0
  28. package/esm2020/core/components/components.module.mjs +46 -0
  29. package/esm2020/core/components/scan/scan.component.mjs +587 -0
  30. package/esm2020/core/components/scan-results/scan-results.component.mjs +38 -0
  31. package/esm2020/core/components/webcam/domain/webcam-image.mjs +58 -0
  32. package/esm2020/core/components/webcam/domain/webcam-init-error.mjs +3 -0
  33. package/esm2020/core/components/webcam/domain/webcam-mirror-properties.mjs +3 -0
  34. package/esm2020/core/components/webcam/util/webcam.util.mjs +48 -0
  35. package/esm2020/core/components/webcam/webcam/webcam.component.mjs +867 -0
  36. package/esm2020/core/components/webcam/webcam.module.mjs +22 -0
  37. package/esm2020/core/interfaces/config.mjs +2 -0
  38. package/esm2020/core/pipes/pipes.module.mjs +19 -0
  39. package/esm2020/core/pipes/safeResourceUrl.pipe.mjs +20 -0
  40. package/esm2020/core/shared/material.module.mjs +162 -0
  41. package/esm2020/dialogs/components/blank/blank.component.mjs +46 -0
  42. package/esm2020/dialogs/components/confirm/confirm.component.mjs +53 -0
  43. package/esm2020/dialogs/components/loading/loading.component.mjs +12 -0
  44. package/esm2020/dialogs/components/scan-profile/scan-profile.component.mjs +48 -0
  45. package/esm2020/dialogs/components/scan-selfie/scan-selfie.component.mjs +392 -0
  46. package/esm2020/dialogs/components/turn-document/turn-document.component.mjs +32 -0
  47. package/esm2020/dialogs/dialogs.core.provider.mjs +109 -0
  48. package/esm2020/dialogs/dialogs.module.mjs +89 -0
  49. package/esm2020/forms/form.module.mjs +87 -0
  50. package/esm2020/forms/types/avatar.type.mjs +53 -0
  51. package/esm2020/forms/types/profile.image.type.mjs +54 -0
  52. package/esm2020/forms/types/title.type.mjs +60 -0
  53. package/esm2020/lib/ngx-scandoc.module.mjs +28 -11
  54. package/esm2020/providers/auth.provider.mjs +58 -0
  55. package/esm2020/providers/camera.provider.mjs +40 -0
  56. package/esm2020/providers/interceptor.provider.mjs +61 -0
  57. package/esm2020/providers/layout.provider.mjs +28 -0
  58. package/esm2020/providers/scan.form.mjs +386 -0
  59. package/esm2020/providers/scan.provider.mjs +488 -0
  60. package/esm2020/providers/translation.provider.mjs +50 -0
  61. package/esm2020/providers/webrtc.provider.mjs +58 -0
  62. package/esm2020/public-api.mjs +24 -4
  63. package/fesm2015/ngx-scandoc.mjs +4190 -31
  64. package/fesm2015/ngx-scandoc.mjs.map +1 -1
  65. package/fesm2020/ngx-scandoc.mjs +4166 -31
  66. package/fesm2020/ngx-scandoc.mjs.map +1 -1
  67. package/forms/form.module.d.ts +18 -0
  68. package/forms/types/avatar.type.d.ts +14 -0
  69. package/forms/types/profile.image.type.d.ts +14 -0
  70. package/forms/types/title.type.d.ts +12 -0
  71. package/lib/ngx-scandoc.module.d.ts +6 -2
  72. package/package.json +6 -2
  73. package/providers/auth.provider.d.ts +21 -0
  74. package/providers/camera.provider.d.ts +17 -0
  75. package/providers/interceptor.provider.d.ts +13 -0
  76. package/providers/layout.provider.d.ts +11 -0
  77. package/providers/scan.form.d.ts +13 -0
  78. package/providers/scan.provider.d.ts +237 -0
  79. package/providers/translation.provider.d.ts +9 -0
  80. package/providers/webrtc.provider.d.ts +11 -0
  81. package/public-api.d.ts +23 -3
  82. package/esm2020/lib/ngx-scandoc.component.mjs +0 -22
  83. package/esm2020/lib/ngx-scandoc.service.mjs +0 -14
  84. package/lib/ngx-scandoc.component.d.ts +0 -8
  85. package/lib/ngx-scandoc.service.d.ts +0 -6
@@ -1,53 +1,4188 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, Component, NgModule } from '@angular/core';
2
+ import { Injectable, EventEmitter, Component, Input, Output, ViewChild, HostListener, NgModule, Inject, ChangeDetectionStrategy, HostBinding, Pipe, ViewContainerRef } from '@angular/core';
3
+ import * as i5 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import { Observable, from, Subject, of, tap as tap$1, distinctUntilChanged, throwError } from 'rxjs';
6
+ import { tap, switchMap, takeUntil, map, share, catchError } from 'rxjs/operators';
7
+ import * as i1 from '@angular/cdk/layout';
8
+ import { Breakpoints } from '@angular/cdk/layout';
9
+ import * as i2 from '@angular/cdk/platform';
10
+ import { PlatformModule } from '@angular/cdk/platform';
11
+ import { v4 } from 'uuid';
12
+ import * as i4 from '@angular/forms';
13
+ import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
14
+ import moment from 'moment';
15
+ import * as i1$1 from '@angular/common/http';
16
+ import { HttpHeaders, HTTP_INTERCEPTORS } from '@angular/common/http';
17
+ import * as i1$2 from '@ngx-translate/core';
18
+ import { TranslateModule } from '@ngx-translate/core';
19
+ import jwt_decode from 'jwt-decode';
20
+ import * as i7$1 from '@angular/material/icon';
21
+ import { MatIconModule } from '@angular/material/icon';
22
+ import * as i6 from '@angular/material/button';
23
+ import { MatButtonModule } from '@angular/material/button';
24
+ import * as i9 from '@angular/material/progress-bar';
25
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
26
+ import * as i5$1 from '@angular/material/card';
27
+ import { MatCardModule } from '@angular/material/card';
28
+ import * as i7 from '@ngx-formly/core';
29
+ import { FormlyModule } from '@ngx-formly/core';
30
+ import { MatAutocompleteModule } from '@angular/material/autocomplete';
31
+ import { MatBadgeModule } from '@angular/material/badge';
32
+ import { MatCheckboxModule } from '@angular/material/checkbox';
33
+ import { MatChipsModule } from '@angular/material/chips';
34
+ import * as i6$1 from '@angular/material/core';
35
+ import { MatNativeDateModule } from '@angular/material/core';
36
+ import { MatDatepickerModule } from '@angular/material/datepicker';
37
+ import * as i1$4 from '@angular/material/dialog';
38
+ import { MatDialogModule, MAT_DIALOG_DATA } from '@angular/material/dialog';
39
+ import { MatInputModule } from '@angular/material/input';
40
+ import { MatListModule } from '@angular/material/list';
41
+ import { MatMenuModule } from '@angular/material/menu';
42
+ import { MatPaginatorModule } from '@angular/material/paginator';
43
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
44
+ import * as i5$2 from '@angular/material/select';
45
+ import { MatSelectModule } from '@angular/material/select';
46
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
47
+ import { MatSliderModule } from '@angular/material/slider';
48
+ import { MatSnackBarModule } from '@angular/material/snack-bar';
49
+ import { MatTableModule } from '@angular/material/table';
50
+ import { MatTabsModule } from '@angular/material/tabs';
51
+ import { FieldType, FormlyMaterialModule } from '@ngx-formly/material';
52
+ import * as i3 from 'ngx-avatars';
53
+ import { AvatarModule } from 'ngx-avatars';
54
+ import { FormlySelectModule } from '@ngx-formly/core/select';
55
+ import { FormlyMatDatepickerModule } from '@ngx-formly/material/datepicker';
56
+ import * as i4$1 from '@angular/material/form-field';
57
+ import * as i1$3 from '@angular/platform-browser';
58
+ import * as i4$2 from '@angular/flex-layout';
59
+ import { FlexModule, FlexLayoutModule } from '@angular/flex-layout';
60
+ import * as i5$3 from '@angular/flex-layout/extended';
61
+ import { QRCodeModule } from 'angularx-qrcode';
62
+ import { webSocket } from 'rxjs/webSocket';
3
63
 
4
- class NgxScandocService {
5
- constructor() { }
64
+ /**
65
+ * Container class for a captured webcam image
66
+ * @author basst314, davidshen84
67
+ */
68
+ class WebcamImage {
69
+ constructor(imageAsDataUrl, mimeType, imageData, resized) {
70
+ this._mimeType = mimeType;
71
+ this._imageAsDataUrl = imageAsDataUrl;
72
+ this._imageData = imageData;
73
+ this._imageResized = resized;
74
+ }
75
+ /**
76
+ * Extracts the Base64 data out of the given dataUrl.
77
+ * @param dataUrl the given dataUrl
78
+ * @param mimeType the mimeType of the data
79
+ */
80
+ static getDataFromDataUrl(dataUrl, mimeType) {
81
+ return dataUrl.replace(`data:${mimeType};base64,`, '');
82
+ }
83
+ /**
84
+ * Get the base64 encoded image data
85
+ * @returns base64 data of the image
86
+ */
87
+ get imageAsBase64() {
88
+ return this._imageAsBase64
89
+ ? this._imageAsBase64
90
+ : (this._imageAsBase64 = WebcamImage.getDataFromDataUrl(this._imageAsDataUrl, this._mimeType));
91
+ }
92
+ /**
93
+ * Get the encoded image as dataUrl
94
+ * @returns the dataUrl of the image
95
+ */
96
+ get imageAsDataUrl() {
97
+ return this._imageAsDataUrl;
98
+ }
99
+ /**
100
+ * Get the ImageData object associated with the canvas' 2d context.
101
+ * @returns the ImageData of the canvas's 2d context.
102
+ */
103
+ get imageData() {
104
+ return this._imageData;
105
+ }
106
+ get imageResized() {
107
+ return this._imageResized;
108
+ }
109
+ get dataUrl() {
110
+ const canvas = document.createElement('canvas');
111
+ const { width, height } = this._imageData;
112
+ canvas.width = width;
113
+ canvas.height = height;
114
+ const ctx = canvas.getContext('2d');
115
+ if (ctx) {
116
+ ctx.putImageData(this._imageData, 0, 0);
117
+ }
118
+ return canvas.toDataURL(this._mimeType, 1);
119
+ }
120
+ }
121
+
122
+ class WebcamUtil {
123
+ /**
124
+ * Lists available videoInput devices
125
+ * @returns a list of media device info.
126
+ */
127
+ static getAvailableVideoInputs() {
128
+ return new Observable((observer) => {
129
+ if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
130
+ return observer.error(null);
131
+ }
132
+ const _window = window;
133
+ let streams;
134
+ from(navigator.mediaDevices.getUserMedia({
135
+ video: { deviceId: undefined },
136
+ }))
137
+ .pipe(tap((s) => { streams = s; }), switchMap((s) => from(navigator.mediaDevices.enumerateDevices())))
138
+ .subscribe((devices) => {
139
+ // console.log(streams);
140
+ if (streams) {
141
+ streams.getTracks().forEach((track) => {
142
+ track.stop();
143
+ });
144
+ }
145
+ observer.next(devices.filter((device) => device.kind === 'videoinput'));
146
+ });
147
+ });
148
+ // return new Promise((resolve, reject) => {
149
+ // navigator.mediaDevices.getUserMedia({
150
+ // video: undefined,
151
+ // });
152
+ // navigator.mediaDevices
153
+ // .enumerateDevices()
154
+ // .then((devices: MediaDeviceInfo[]) => {
155
+ // resolve(
156
+ // devices.filter(
157
+ // (device: MediaDeviceInfo) => device.kind === 'videoinput'
158
+ // )
159
+ // );
160
+ // })
161
+ // .catch((err) => {
162
+ // reject(err.message || err);
163
+ // });
164
+ // });
165
+ }
166
+ }
167
+
168
+ const workertext = `
169
+
170
+
171
+ let readStream = true;
172
+ async function blobToBase64(blob) {
173
+ return new Promise((resolve, _) => {
174
+ const reader = new FileReader();
175
+ reader.onloadend = () => resolve(reader.result);
176
+ reader.readAsDataURL(blob);
177
+ });
178
+ }
179
+ async function delay(ms) {
180
+ return new Promise((resolve) =>
181
+ ms > 0 ? setTimeout(resolve, ms) : resolve(0)
182
+ );
183
+ }
184
+
185
+ function calculateDelay(startTime) {
186
+ const endTime = Date.now();
187
+ // difference in ms
188
+ const dt = endTime - startTime;
189
+ const delay = 100 - dt;
190
+ // console.log('[WORKER TIME]', dt, '[DELAY 100-x]', delay);
191
+ return delay > 4 ? delay : 0;
192
+ }
193
+ async function parseFrame(frameStream, trackSettings) {
194
+ const reader = frameStream.getReader();
195
+
196
+ while (readStream) {
197
+ const time = Date.now();
198
+ const result = await reader.read();
199
+ if (result.done) break;
200
+
201
+ const frameFromCamera = result.value;
202
+
203
+ await parseFrameFromCamera(frameFromCamera, trackSettings);
204
+ // wait
205
+ await delay(calculateDelay(time));
206
+ }
207
+ }
208
+
209
+ async function parseFrameFast(frameStream, trackSettings) {
210
+ console.warn('FAST', performance.now());
211
+ const reader = frameStream.getReader();
212
+ const { width, height } = trackSettings;
213
+ const offscreenSmall = new OffscreenCanvas(384, 384);
214
+ const context = offscreenSmall.getContext('2d');
215
+ let time = 0;
216
+ while (true) {
217
+ // const t0 = performance.now();
218
+ // console.time('result');
219
+ const result = reader.read();
220
+ // console.timeEnd('result');
221
+ if (result.done) break;
222
+
223
+ const frameFromCamera = result.value;
224
+ // console.log(frameFromCamera.timestamp);
225
+
226
+ // const tt = frameFromCamera.timestamp - time;
227
+ // console.log(tt / 1000);
228
+ // time = frameFromCamera.timestamp;
229
+
230
+ // console.time('bitmap');
231
+ const bitmap = await createImageBitmap(frameFromCamera, {
232
+ premultiplyAlpha: 'default',
233
+ });
234
+ console.warn(new Date().getTime());
235
+ // console.timeEnd('bitmap');
236
+
237
+ // context.clearRect(0, 0, 384, 384);
238
+ // console.time('draw');
239
+ // context.drawImage(bitmap, 0, 0, width, height, 0, 0, 384, 384);
240
+ // console.timeEnd('draw');
241
+ // console.time('transfer');
242
+ // const bitmapSmall = offscreenSmall.transferToImageBitmap();
243
+ // console.timeEnd('transfer');
244
+
245
+ frameFromCamera.close();
246
+ // //
247
+ // const t1 = performance.now();
248
+
249
+
250
+ // await parseFrameFromCamera(frameFromCamera, trackSettings);
251
+ }
252
+ }
253
+
254
+ async function parseFrameFromCamera(frameFromCamera, trackSettings) {
255
+ const { width, height } = trackSettings;
256
+ const offscreenSmall = new OffscreenCanvas(384, 384);
257
+ // console.time('bit2');
258
+ const bitmap = await createImageBitmap(frameFromCamera, {
259
+ premultiplyAlpha: 'default',
260
+ });
261
+ // console.timeEnd('bit2');
262
+ const context = offscreenSmall.getContext('2d');
263
+
264
+ // console.time('buffer');
265
+ // const buffer = new Uint8Array(frameFromCamera.allocationSize());
266
+ // let layout = await frameFromCamera.copyTo(buffer);
267
+
268
+ // const base64 = await blobToBase64(new Blob([buffer]));
269
+ // console.log(base64)
270
+ // console.timeEnd('buffer');
271
+
272
+ if (context) {
273
+ context.imageSmoothingEnabled = false;
274
+
275
+ // let videoFrame2 = frameFromCamera.clone();
276
+
277
+ // createImageBitmap();
278
+
279
+ // console.time('clear');
280
+ // context.clearRect(0, 0, width, height);
281
+ // console.timeEnd('clear');
282
+ // console.time('draw');
283
+ context.drawImage(bitmap, 0, 0, width, height, 0, 0, 384, 384);
284
+ // console.timeEnd('draw');
285
+ // context.drawImage(bit, 0, 0);
286
+ // bit2.close();
287
+ // bit.close();
288
+ // console.timeEnd('draw');
289
+ // console.time('capture');
290
+
291
+ // const bitmapsmall = offscreenSmall.transferToImageBitmap();
292
+
293
+ // const imageData = context.getImageData(0, 0, 384, 384);
294
+ // console.timeEnd('capture');
295
+ // console.time('blob');
296
+ const resized = await offscreenSmall.convertToBlob({
297
+ type: 'image/jpeg',
298
+ });
299
+ // console.timeEnd('blob');
300
+ // console.log(resized);
301
+ // console.time('base64');
302
+ const base64 = await blobToBase64(resized);
303
+ //console.timeEnd('base64');
304
+ // console.log(blob);
305
+
306
+ // console.time('convert')
307
+ // await convert(bitmap, trackSettings)
308
+ // console.timeEnd('convert');
309
+ // console.log(
310
+ // '%c ',
311
+ // 'font-size:384px; background:url('+blob+') no-repeat;'
312
+ // );
313
+
314
+ // console.timeEnd('blob');
315
+ postMessage({ base64, bitmap }, [bitmap]);
316
+ // videoFrame2.close();
317
+ }
318
+ frameFromCamera.close();
319
+ }
320
+
321
+ async function convert(image, trackSettings) {
322
+ const { width, height } = trackSettings;
323
+
324
+ const offscreenSmall = new OffscreenCanvas(width, height);
325
+
326
+ const context = offscreenSmall.getContext('2d');
327
+
328
+ // console.time('buffer');
329
+ // const buffer = new Uint8Array(frameFromCamera.allocationSize());
330
+ // let layout = await frameFromCamera.copyTo(buffer);
331
+ // console.timeEnd('buffer');
332
+
333
+ if (context) {
334
+ context.imageSmoothingEnabled = false;
335
+ // let videoFrame2 = frameFromCamera.clone();
336
+ console.warn(image);
337
+ // createImageBitmap();
338
+
339
+ // console.time('clear');
340
+ // context.clearRect(0, 0, width, height);
341
+ // console.timeEnd('clear');
342
+
343
+ context.drawImage(image, 0, 0);
344
+ // context.drawImage(bit, 0, 0);
345
+ // image.close();
346
+ // console.timeEnd('drawB');
347
+ console.time('blob2');
348
+ const resized = await offscreenSmall.convertToBlob({
349
+ type: 'image/jpeg',
350
+ });
351
+ console.timeEnd('blob2');
352
+
353
+ // image.close();
354
+ // console.time('base64');
355
+ const base64 = await blobToBase64(resized);
356
+
357
+ // console.log(blob);
358
+
359
+ // console.log(
360
+ // '%c ',
361
+ // 'font-size:384px; background:url(' + base64 + ') no-repeat;'
362
+ // );
363
+
364
+ // console.timeEnd('base64');
365
+ //postMessage({ type: 'convert', base64 });
366
+ }
367
+ }
368
+ addEventListener('message', ({ data }) => {
369
+ const { type, image, frameStream, trackSettings } = data;
370
+ // console.log(data);
371
+ switch (type) {
372
+ case 'start':
373
+ readStream = true;
374
+ parseFrame(frameStream, trackSettings);
375
+ break;
376
+
377
+ case 'fast':
378
+ readStream = true;
379
+ parseFrameFast(frameStream, trackSettings);
380
+ break;
381
+
382
+ case 'stop':
383
+ console.warn('STOP WORKER');
384
+ readStream = false;
385
+ break;
386
+
387
+ case 'convert':
388
+ convert(image, trackSettings);
389
+ break;
390
+ }
391
+
392
+ // const canvas = document.createElement('canvas');
393
+ // const ctx = canvas.getContext('2d');
394
+
395
+ // if (data.canvas) {
396
+ // postMessage('ok');
397
+ // } else {
398
+
399
+ // postMessage(response);
400
+ // }
401
+ });
402
+ `;
403
+
404
+ class BaseComponent {
405
+ constructor() {
406
+ this.$destroy = new Subject();
407
+ }
408
+ __subs(observable) {
409
+ return observable.pipe(takeUntil(this.$destroy));
410
+ }
411
+ __destroy() {
412
+ this.$destroy.next(true);
413
+ this.$destroy.complete();
414
+ }
6
415
  }
7
- NgxScandocService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
8
- NgxScandocService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocService, providedIn: 'root' });
9
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocService, decorators: [{
416
+
417
+ class NgxScandocCameraProvider {
418
+ constructor() {
419
+ this.switchCamera = new Subject();
420
+ this.cameraReady = false;
421
+ this.cameraSwitched = new Subject();
422
+ this.multipleWebcamsAvailable = false;
423
+ this.setup();
424
+ }
425
+ setup() {
426
+ WebcamUtil.getAvailableVideoInputs().subscribe((mediaDevices) => {
427
+ console.log('[DEVICES]', mediaDevices.map((d) => d.label));
428
+ this.mediaDevices = mediaDevices;
429
+ this.multipleWebcamsAvailable = mediaDevices && mediaDevices.length > 1;
430
+ });
431
+ }
432
+ selectCamera(event) {
433
+ this.switchCamera.next(event.value);
434
+ }
435
+ cameraWasSwitched(deviceId) {
436
+ console.log('[active device]', deviceId);
437
+ this.deviceId = deviceId;
438
+ this.cameraReady = true;
439
+ }
440
+ get nextWebcamObservable() {
441
+ return this.switchCamera.asObservable();
442
+ }
443
+ }
444
+ NgxScandocCameraProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocCameraProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
445
+ NgxScandocCameraProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocCameraProvider, providedIn: 'root' });
446
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocCameraProvider, decorators: [{
10
447
  type: Injectable,
11
448
  args: [{
12
- providedIn: 'root'
449
+ providedIn: 'root',
13
450
  }]
14
451
  }], ctorParameters: function () { return []; } });
15
452
 
16
- class NgxScandocComponent {
17
- constructor() { }
453
+ class WebcamComponent extends BaseComponent {
454
+ constructor(breakpointObserver, platform, cd, zone, cameraProvider) {
455
+ super();
456
+ this.breakpointObserver = breakpointObserver;
457
+ this.platform = platform;
458
+ this.cd = cd;
459
+ this.zone = zone;
460
+ this.cameraProvider = cameraProvider;
461
+ /** Defines the max width of the webcam area in px */
462
+ this.width = 640;
463
+ /** Defines the max height of the webcam area in px */
464
+ this.height = 480;
465
+ /** Defines base constraints to apply when requesting video track from UserMedia */
466
+ this.videoOptions = WebcamComponent.DEFAULT_VIDEO_OPTIONS;
467
+ /** Flag to enable/disable camera switch. If enabled, a switch icon will be displayed if multiple cameras were found */
468
+ this.allowCameraSwitch = true;
469
+ /** Flag to control whether an ImageData object is stored into the WebcamImage object. */
470
+ this.captureImageData = false;
471
+ /** The image type to use when capturing snapshots */
472
+ this.imageType = WebcamComponent.DEFAULT_IMAGE_TYPE;
473
+ /** The image quality to use when capturing snapshots (number between 0 and 1) */
474
+ this.imageQuality = WebcamComponent.DEFAULT_IMAGE_QUALITY;
475
+ /** EventEmitter which fires when an image has been captured */
476
+ this.imageCapture = new EventEmitter();
477
+ /** Emits a mediaError if webcam cannot be initialized (e.g. missing user permissions) */
478
+ this.initError = new EventEmitter();
479
+ /** Emits when the webcam video was clicked */
480
+ this.imageClick = new EventEmitter();
481
+ /** Emits the active deviceId after the active video device was switched */
482
+ this.cameraSwitched = new EventEmitter();
483
+ this.videoReady = new EventEmitter();
484
+ this.showVideo = false;
485
+ this.destroyed = new EventEmitter();
486
+ /** available video devices */
487
+ this.availableVideoInputs = [];
488
+ /** Indicates whether the video device is ready to be switched */
489
+ this.videoInitialized = false;
490
+ this.canvasEl = document.createElement('canvas');
491
+ /** Index of active video in availableVideoInputs */
492
+ this.activeVideoInputIndex = -1;
493
+ /** MediaStream object in use for streaming UserMedia data */
494
+ this.mediaStream = null;
495
+ this.shutdown = false;
496
+ this.canStart = true;
497
+ this.videoSize = { width: 1920, height: 1080 };
498
+ this.canvasSize = { width: 1280, height: 720 };
499
+ this.landscape = true;
500
+ // if (typeof Worker !== 'undefined') {
501
+ // // Create a new
502
+ // this.worker = new Worker(
503
+ // new URL('./../../../../app/app.worker', import.meta.url)
504
+ // );
505
+ // this.worker.onmessage = ({ data }) => {
506
+ // console.log(`page got message: ${data}`);
507
+ // };
508
+ // console.log('POST');
509
+ // this.worker.postMessage('hello');
510
+ // } else {
511
+ // // Web workers are not supported in this environment.
512
+ // // You should add a fallback so that your program still executes correctly.
513
+ // }
514
+ }
515
+ /**
516
+ * If the given Observable emits, an image will be captured and emitted through 'imageCapture' EventEmitter
517
+ */
518
+ set trigger(trigger) {
519
+ if (this.triggerSubscription) {
520
+ this.triggerSubscription.unsubscribe();
521
+ }
522
+ // Subscribe to events from this Observable to take snapshots
523
+ this.triggerSubscription = trigger.subscribe((time) => {
524
+ this.takeSnapshot(time);
525
+ });
526
+ }
527
+ onResize() {
528
+ this.videoReady.next(false);
529
+ this.resizeStage();
530
+ }
531
+ /**
532
+ * Get MediaTrackConstraints to request streaming the given device
533
+ * @param deviceId
534
+ * @param baseMediaTrackConstraints base constraints to merge deviceId-constraint into
535
+ * @returns
536
+ */
537
+ static getMediaConstraintsForDevice(deviceId, baseMediaTrackConstraints) {
538
+ const result = baseMediaTrackConstraints
539
+ ? baseMediaTrackConstraints
540
+ : this.DEFAULT_VIDEO_OPTIONS;
541
+ if (deviceId) {
542
+ result.deviceId = { exact: deviceId };
543
+ }
544
+ return result;
545
+ }
546
+ /**
547
+ * Tries to harvest the deviceId from the given mediaStreamTrack object.
548
+ * Browsers populate this object differently; this method tries some different approaches
549
+ * to read the id.
550
+ * @param mediaStreamTrack
551
+ * @returns deviceId if found in the mediaStreamTrack
552
+ */
553
+ static getDeviceIdFromMediaStreamTrack(mediaStreamTrack) {
554
+ if (mediaStreamTrack.getSettings &&
555
+ mediaStreamTrack.getSettings() &&
556
+ mediaStreamTrack.getSettings().deviceId) {
557
+ return mediaStreamTrack.getSettings().deviceId;
558
+ }
559
+ else if (mediaStreamTrack.getConstraints &&
560
+ mediaStreamTrack.getConstraints() &&
561
+ mediaStreamTrack.getConstraints().deviceId) {
562
+ const deviceIdObj = mediaStreamTrack.getConstraints().deviceId;
563
+ return WebcamComponent.getValueFromConstrainDOMString(deviceIdObj);
564
+ }
565
+ }
566
+ /**
567
+ * Tries to harvest the facingMode from the given mediaStreamTrack object.
568
+ * Browsers populate this object differently; this method tries some different approaches
569
+ * to read the value.
570
+ * @param mediaStreamTrack
571
+ * @returns facingMode if found in the mediaStreamTrack
572
+ */
573
+ static getFacingModeFromMediaStreamTrack(mediaStreamTrack) {
574
+ if (mediaStreamTrack) {
575
+ if (mediaStreamTrack.getSettings &&
576
+ mediaStreamTrack.getSettings() &&
577
+ mediaStreamTrack.getSettings().facingMode) {
578
+ return mediaStreamTrack.getSettings().facingMode;
579
+ }
580
+ else if (mediaStreamTrack.getConstraints &&
581
+ mediaStreamTrack.getConstraints() &&
582
+ mediaStreamTrack.getConstraints().facingMode) {
583
+ const facingModeConstraint = mediaStreamTrack.getConstraints().facingMode;
584
+ return WebcamComponent.getValueFromConstrainDOMString(facingModeConstraint);
585
+ }
586
+ }
587
+ }
588
+ /**
589
+ * Determines whether the given mediaStreamTrack claims itself as user facing
590
+ * @param mediaStreamTrack
591
+ */
592
+ static isUserFacing(mediaStreamTrack) {
593
+ const facingMode = WebcamComponent.getFacingModeFromMediaStreamTrack(mediaStreamTrack);
594
+ return facingMode ? 'user' === facingMode.toLowerCase() : false;
595
+ }
596
+ /**
597
+ * Extracts the value from the given ConstrainDOMString
598
+ * @param constrainDOMString
599
+ */
600
+ static getValueFromConstrainDOMString(constrainDOMString) {
601
+ if (constrainDOMString) {
602
+ if (constrainDOMString instanceof String) {
603
+ return String(constrainDOMString);
604
+ }
605
+ else if (Array.isArray(constrainDOMString) &&
606
+ Array(constrainDOMString).length > 0) {
607
+ return String(constrainDOMString[0]);
608
+ }
609
+ else if (typeof constrainDOMString === 'object') {
610
+ if (constrainDOMString['exact']) {
611
+ return String(constrainDOMString['exact']);
612
+ }
613
+ else if (constrainDOMString['ideal']) {
614
+ return String(constrainDOMString['ideal']);
615
+ }
616
+ }
617
+ }
618
+ return null;
619
+ }
620
+ resizeStage() {
621
+ setTimeout(() => {
622
+ this.updateSize();
623
+ this.updatecanvasSize();
624
+ this.drawRectangle();
625
+ this.cd.detectChanges();
626
+ this.videoReady.next(true);
627
+ }, 10);
628
+ }
629
+ get canvasHeight() {
630
+ const landscape = this.width > this.height;
631
+ const aspect = this.videoSize.width / this.videoSize.height;
632
+ if (!landscape) {
633
+ return this.width * aspect;
634
+ }
635
+ return this.height;
636
+ }
637
+ updatecanvasSize() {
638
+ console.log(this.width, this.height);
639
+ const landscape = this.width > this.height;
640
+ const aspect = this.videoSize.width / this.videoSize.height;
641
+ let width = this.width;
642
+ let height = this.height;
643
+ if (landscape) {
644
+ height = width / aspect;
645
+ }
646
+ else {
647
+ height = width / aspect;
648
+ }
649
+ if (height > this.height) {
650
+ height = this.height;
651
+ width = this.height * aspect;
652
+ }
653
+ this.canvasSize = { width: Math.round(width), height: Math.round(height) };
654
+ console.log(this.canvasSize, this.videoSize);
655
+ if (this.isMobile) {
656
+ this.video.nativeElement.setAttribute('height', this.canvasSize.height);
657
+ this.video.nativeElement.setAttribute('width', this.canvasSize.width);
658
+ }
659
+ else {
660
+ if (this.videoSize.width > this.videoSize.hight) {
661
+ this.video.nativeElement.setAttribute('height', this.canvasSize.height);
662
+ }
663
+ else {
664
+ this.video.nativeElement.setAttribute('width', this.canvasSize.width);
665
+ }
666
+ }
667
+ this.cd.detectChanges();
668
+ }
669
+ setupWorker() {
670
+ if (typeof Worker !== 'undefined') {
671
+ // Create a new
672
+ if (this.type !== 'selfie') {
673
+ this.zone.runOutsideAngular(() => {
674
+ var blob = new Blob([workertext], { type: 'text/javascript' });
675
+ var url = URL.createObjectURL(blob);
676
+ this.worker = new Worker(url);
677
+ this.worker.onmessage = ({ data }) => {
678
+ if (data.base64) {
679
+ data.type == 'data';
680
+ this.imageHandler.next(data);
681
+ }
682
+ };
683
+ });
684
+ }
685
+ }
686
+ }
687
+ ngAfterViewInit() {
688
+ this.setupWorker();
689
+ if (this.imageHandler) {
690
+ this.__subs(this.imageHandler).subscribe((resp) => {
691
+ if (resp.type === 'stop') {
692
+ this.worker?.postMessage({ type: 'stop' });
693
+ }
694
+ });
695
+ }
696
+ this.__subs(this.breakpointObserver
697
+ .observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]))
698
+ .subscribe((state) => {
699
+ if (this.platform.IOS || this.platform.ANDROID) {
700
+ // this.landscape = state.breakpoints[Breakpoints.HandsetLandscape];
701
+ }
702
+ const mobile = this.platform.IOS;
703
+ if (state.matches && mobile) {
704
+ this.updateSize();
705
+ this.updatecanvasSize();
706
+ this.drawRectangle();
707
+ }
708
+ });
709
+ if (this.switchCamera) {
710
+ if (this.switchCameraSubscription) {
711
+ this.switchCameraSubscription.unsubscribe();
712
+ }
713
+ // Subscribe to events from this Observable to switch video device
714
+ this.switchCameraSubscription = this.switchCamera.subscribe((value) => {
715
+ this.switchToVideoInput(value);
716
+ });
717
+ }
718
+ this.detectAvailableDevices()
719
+ .then(() => {
720
+ // start video
721
+ if (this.canStart) {
722
+ this.switchToVideoInput('');
723
+ }
724
+ })
725
+ .catch((err) => {
726
+ this.initError.next({ message: err });
727
+ // fallback: still try to load webcam, even if device enumeration failed
728
+ if (this.canStart) {
729
+ this.switchToVideoInput('');
730
+ }
731
+ });
732
+ }
733
+ ngOnDestroy() {
734
+ this.canStart = false;
735
+ this.nativeVideoElement.pause();
736
+ this.destroyed.emit(true);
737
+ this.stopMediaTracks();
738
+ this.unsubscribeFromSubscriptions();
739
+ this.shutdown = true;
740
+ // shut down worker
741
+ if (this.imageHandler) {
742
+ this.imageHandler.next({ type: 'stop' });
743
+ }
744
+ if (this.nativeVideoElement.srcObject) {
745
+ this.nativeVideoElement.srcObject
746
+ .getTracks()
747
+ .forEach((track) => {
748
+ track.stop();
749
+ });
750
+ this.nativeVideoElement.srcObject = null;
751
+ }
752
+ this.__destroy();
753
+ // this.nativeVideoElement.src = null;
754
+ // this.nativeVideoElement.srcObject = null;
755
+ }
756
+ takeSelfie() {
757
+ const _video = this.nativeVideoElement;
758
+ const mimeType = this.imageType
759
+ ? this.imageType
760
+ : WebcamComponent.DEFAULT_IMAGE_TYPE;
761
+ let _canvas = document.createElement('canvas'); //this.canvasSnapshot.nativeElement;
762
+ const { width, height } = this.videoSize;
763
+ console.log(width, height);
764
+ const { padding, top, rWidth, rHeight } = this.snapRectangle;
765
+ _canvas.width = rWidth;
766
+ _canvas.height = rHeight;
767
+ const ctx = _canvas.getContext('2d', {
768
+ alpha: false,
769
+ powerPreference: 'high-performance',
770
+ antialias: false,
771
+ depth: false,
772
+ desynchronized: true,
773
+ });
774
+ if (ctx) {
775
+ ctx.drawImage(_video, padding, top, rWidth, rHeight, 0, 0, rWidth, rHeight);
776
+ const imgAsUrl = _canvas.toDataURL(mimeType, 1);
777
+ this.imageCapture.emit(new WebcamImage(imgAsUrl, mimeType, new ImageData(1, 1), null));
778
+ }
779
+ }
780
+ /**
781
+ * Takes a snapshot of the current webcam's view and emits the image as an event
782
+ */
783
+ takeSnapshot(time) {
784
+ if (this.type === 'selfie') {
785
+ this.takeSelfie();
786
+ return;
787
+ }
788
+ if (this.trackProcessor) {
789
+ return;
790
+ }
791
+ this.zone.runOutsideAngular(() => {
792
+ const canvasSmalSize = 384;
793
+ const _video = this.nativeVideoElement;
794
+ const mimeType = this.imageType
795
+ ? this.imageType
796
+ : WebcamComponent.DEFAULT_IMAGE_TYPE;
797
+ let _canvas = document.createElement('canvas'); //this.canvasSnapshot.nativeElement;
798
+ const { width, height } = this.videoSize;
799
+ _canvas.width = width;
800
+ _canvas.height = height;
801
+ const ctx = _canvas.getContext('2d', {
802
+ alpha: false,
803
+ powerPreference: 'high-performance',
804
+ antialias: false,
805
+ depth: false,
806
+ desynchronized: true,
807
+ });
808
+ const canvas = document.createElement('canvas'); // needs an initial size
809
+ canvas.height = canvasSmalSize;
810
+ canvas.width = canvasSmalSize;
811
+ const ctxO = canvas.getContext('2d', {
812
+ alpha: false,
813
+ powerPreference: 'high-performance',
814
+ antialias: false,
815
+ depth: false,
816
+ desynchronized: true,
817
+ });
818
+ if (ctx && ctxO) {
819
+ ctx.imageSmoothingEnabled = false;
820
+ ctx.drawImage(_video, 0, 0);
821
+ ctxO.drawImage(_video, 0, 0, canvasSmalSize, canvasSmalSize);
822
+ const imData = ctx.getImageData(0, 0, this.videoSize.width, this.videoSize.height);
823
+ const resize = canvas.toDataURL(mimeType, 1);
824
+ const currentTime = new Date().getTime();
825
+ const diff = currentTime - time;
826
+ const delay = diff > 100 ? 0 : 100 - diff;
827
+ const timeout = setTimeout(() => {
828
+ this.imageCapture.emit(new WebcamImage('', mimeType, imData, resize));
829
+ clearTimeout(timeout);
830
+ }, delay);
831
+ }
832
+ });
833
+ }
834
+ update() { }
835
+ resizeImage(base64data) {
836
+ return new Observable((observer) => {
837
+ let canvas = document.createElement('canvas');
838
+ const ctx = canvas.getContext('2d');
839
+ const max_size = 384;
840
+ let image = new Image();
841
+ image.src = base64data;
842
+ image.onload = () => {
843
+ let width = image.width;
844
+ let height = image.height;
845
+ if (width < height) {
846
+ height *= max_size / width;
847
+ width = max_size;
848
+ }
849
+ else {
850
+ width *= max_size / height;
851
+ height = max_size;
852
+ }
853
+ canvas.width = width;
854
+ canvas.height = height;
855
+ // console.log(width, height);
856
+ if (ctx) {
857
+ // ctx.rotate((90 * Math.PI) / 180);
858
+ // ctx.translate(0, -canvas.width);
859
+ ctx.drawImage(image, 0, 0, 384, 384);
860
+ observer.next(canvas.toDataURL());
861
+ ctx.clearRect(0, 0, 1, 1);
862
+ }
863
+ else {
864
+ observer.error({ type: 'generic error' });
865
+ }
866
+ image = null;
867
+ canvas = null;
868
+ };
869
+ image.onerror = (e) => {
870
+ observer.error(e);
871
+ };
872
+ });
873
+ }
874
+ /**
875
+ * Switches to the next/previous video device
876
+ * @param forward
877
+ */
878
+ rotateVideoInput(forward) {
879
+ if (this.availableVideoInputs && this.availableVideoInputs.length > 1) {
880
+ const increment = forward
881
+ ? 1
882
+ : this.availableVideoInputs.length - 1;
883
+ const nextInputIndex = (this.activeVideoInputIndex + increment) %
884
+ this.availableVideoInputs.length;
885
+ this.switchToVideoInput(this.availableVideoInputs[nextInputIndex].deviceId);
886
+ }
887
+ }
888
+ /**
889
+ * Switches the camera-view to the specified video device
890
+ */
891
+ switchToVideoInput(deviceId) {
892
+ // if(deviceId){
893
+ this.videoInitialized = false;
894
+ this.stopMediaTracks();
895
+ this.initWebcam(deviceId, this.videoOptions);
896
+ // }
897
+ }
898
+ /**
899
+ * Event-handler for video resize event.
900
+ * Triggers Angular change detection so that new video dimensions get applied
901
+ */
902
+ videoResize() {
903
+ // here to trigger Angular change detection
904
+ }
905
+ get videoWidth() {
906
+ const videoRatio = this.getVideoAspectRatio();
907
+ return Math.min(this.width, this.height * videoRatio);
908
+ }
909
+ get videoHeight() {
910
+ const videoRatio = this.getVideoAspectRatio();
911
+ return Math.min(this.height, this.width / videoRatio);
912
+ }
913
+ get videoStyleClasses() {
914
+ let classes = '';
915
+ if (this.isMirrorImage()) {
916
+ classes += 'mirrored ';
917
+ }
918
+ return classes.trim();
919
+ }
920
+ get nativeVideoElement() {
921
+ return this.video.nativeElement;
922
+ }
923
+ // public get smallVideoElement() {
924
+ // return this.videoSmall;
925
+ // }
926
+ /**
927
+ * Returns the video aspect ratio of the active video stream
928
+ */
929
+ getVideoAspectRatio() {
930
+ // calculate ratio from video element dimensions if present
931
+ const videoElement = this.nativeVideoElement;
932
+ if (videoElement.videoWidth &&
933
+ videoElement.videoWidth > 0 &&
934
+ videoElement.videoHeight &&
935
+ videoElement.videoHeight > 0) {
936
+ return videoElement.videoWidth / videoElement.videoHeight;
937
+ }
938
+ // nothing present - calculate ratio based on width/height params
939
+ return this.width / this.height;
940
+ }
941
+ updateSize() {
942
+ const track = this.mediaStream?.getTracks()[0];
943
+ if (track) {
944
+ let desired = {
945
+ width: {
946
+ ideal: 0,
947
+ },
948
+ height: {
949
+ ideal: 0,
950
+ },
951
+ // facingMode:'user',
952
+ frameRate: { min: 20, ideal: 24, max: 24 },
953
+ };
954
+ if (typeof track.getCapabilities === 'function') {
955
+ const { width, height } = track.getCapabilities();
956
+ desired = {
957
+ width: {
958
+ ideal: this.landscape && this.isMobile ? height?.max : width?.max,
959
+ },
960
+ height: {
961
+ ideal: this.landscape && this.isMobile ? width?.max : height?.max,
962
+ },
963
+ // facingMode:'user',
964
+ frameRate: { min: 20, ideal: 24, max: 24 },
965
+ };
966
+ }
967
+ else {
968
+ desired = {
969
+ width: {
970
+ ideal: 1920,
971
+ },
972
+ height: {
973
+ ideal: 1080,
974
+ },
975
+ // facingMode:'user',
976
+ frameRate: { min: 20, ideal: 30, max: 31 },
977
+ };
978
+ }
979
+ if (desired.height.ideal && desired.height.ideal >= 1600) {
980
+ desired.height.ideal = 1600;
981
+ desired.width.ideal = 1600;
982
+ }
983
+ if (this.platform.ANDROID) {
984
+ //desired.width.ideal = 2160;
985
+ //desired.height.ideal = 2160;
986
+ // if (!this.landscape) {
987
+ // } else {
988
+ // desired.width.ideal = width?.max;
989
+ // desired.height.ideal = height?.max;
990
+ // }
991
+ }
992
+ track.applyConstraints(desired);
993
+ //track.getSettings().facingMode!=='user';
994
+ this.videoSize = {
995
+ height: this.landscape
996
+ ? track.getSettings().height
997
+ : track.getSettings().width,
998
+ width: this.landscape
999
+ ? track.getSettings().width
1000
+ : track.getSettings().height,
1001
+ };
1002
+ this.cd.detectChanges();
1003
+ }
1004
+ }
1005
+ getStreamTrack(stream) {
1006
+ return stream.getVideoTracks()[0];
1007
+ }
1008
+ getTrackSettings() { }
1009
+ accesVideoTrack(videoTrackConstraints) {
1010
+ return from(navigator.mediaDevices.getUserMedia(videoTrackConstraints)).pipe(switchMap((stream) => {
1011
+ // default resolution 1280x720, check max resolution
1012
+ const track = this.getStreamTrack(stream);
1013
+ const capabilities = track.getCapabilities();
1014
+ const { facingMode, height, width } = capabilities;
1015
+ const desired = {
1016
+ width: {
1017
+ min: this.landscape && this.isMobile ? height?.max : width?.max,
1018
+ },
1019
+ // height: {
1020
+ // exact: this.landscape && this.isMobile ? width?.max : height?.max,
1021
+ // },
1022
+ // facingMode:'en',
1023
+ // frameRate: { min: 25, ideal: 30, max: 31 },
1024
+ };
1025
+ // get max width
1026
+ const { width: sWidth, height: sHeight } = track.getSettings();
1027
+ if (desired.width.min != sWidth) {
1028
+ return this.accesVideoTrack({ video: desired });
1029
+ }
1030
+ //return this.accesVideoTrack({video:desired});
1031
+ return of(stream);
1032
+ }));
1033
+ }
1034
+ drawRectangle() {
1035
+ const _canvas = this.canvas.nativeElement;
1036
+ const ctx = _canvas.getContext('2d');
1037
+ ctx.clearRect(0, 0, _canvas.width, _canvas.height);
1038
+ // ctx.drawImage(_video, 0, 0, _canvas.width, _canvas.height);
1039
+ const { padding, top, rWidth, rHeight } = this.cardRectangle;
1040
+ ctx.strokeStyle = 'red';
1041
+ ctx.strokeRect(padding, top, rWidth, rHeight);
1042
+ }
1043
+ getMaxAvailableResolution() { }
1044
+ /**
1045
+ * Init webcam live view
1046
+ */
1047
+ initWebcam(deviceId, userVideoTrackConstraints) {
1048
+ const _video = this.nativeVideoElement;
1049
+ // const videoStreamer = this.videoStreamer.nativeElement;
1050
+ // const videoSmall = document.createElement('video');
1051
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
1052
+ // merge deviceId -> userVideoTrackConstraints
1053
+ const videoTrackConstraints = WebcamComponent.getMediaConstraintsForDevice(deviceId, userVideoTrackConstraints);
1054
+ // // if (deviceId) {
1055
+ // this.accesVideoTrack({ video: videoTrackConstraints }).subscribe(
1056
+ // (stream: MediaStream) => {
1057
+ // console.log(
1058
+ // 'VALID SETTINGS',
1059
+ // stream.getVideoTracks()[0].getSettings()
1060
+ // );
1061
+ // }
1062
+ // );
1063
+ // }
1064
+ if (this.platform.ANDROID) {
1065
+ videoTrackConstraints.width = 1600;
1066
+ videoTrackConstraints.height = 1600;
1067
+ }
1068
+ const constraints = {
1069
+ exact: deviceId,
1070
+ width: { min: 480, ideal: 1280 },
1071
+ height: { min: 480, ideal: 720 },
1072
+ // aspectRatio: 3 / 2,
1073
+ frameRate: { min: 20 },
1074
+ };
1075
+ navigator.mediaDevices
1076
+ .getUserMedia({ video: videoTrackConstraints })
1077
+ .then((stream) => {
1078
+ this.mediaStream = stream;
1079
+ _video.srcObject = stream;
1080
+ this.updateSize();
1081
+ this.updatecanvasSize();
1082
+ _video.play();
1083
+ _video.onplay = () => {
1084
+ this.setActiveCamera(stream);
1085
+ this.drawRectangle();
1086
+ };
1087
+ })
1088
+ .catch((err) => {
1089
+ console.log(err);
1090
+ this.initError.next({
1091
+ message: err.message,
1092
+ mediaStreamError: err,
1093
+ });
1094
+ });
1095
+ }
1096
+ else {
1097
+ this.initError.next({
1098
+ message: 'Cannot read UserMedia from MediaDevices.',
1099
+ });
1100
+ }
1101
+ }
1102
+ get isMobile() {
1103
+ return this.platform.ANDROID || this.platform.IOS;
1104
+ }
1105
+ get cardRectangle() {
1106
+ const _canvas = this.canvas.nativeElement;
1107
+ const docSize = this.type === 'selfie' ? 1 : 86 / 55;
1108
+ let padding = 10;
1109
+ let rWidth = _canvas.width - 2 * padding;
1110
+ let rHeight = rWidth / docSize;
1111
+ let top = (_canvas.height - rHeight) / 2;
1112
+ if (!this.isMobile) {
1113
+ padding = 40;
1114
+ rHeight = _canvas.height - 2 * padding;
1115
+ rWidth = rHeight * docSize;
1116
+ top = (_canvas.height - rHeight) / 2;
1117
+ padding = (_canvas.width - rWidth) / 2;
1118
+ }
1119
+ return { padding, top, rWidth, rHeight };
1120
+ }
1121
+ get snapRectangle() {
1122
+ const _canvas = this.canvas.nativeElement;
1123
+ const ar = this.videoSize.width / _canvas.width;
1124
+ let { padding, top, rWidth, rHeight } = this.cardRectangle;
1125
+ padding = padding * ar;
1126
+ top = top * ar;
1127
+ rWidth = rWidth * ar;
1128
+ rHeight = rHeight * ar;
1129
+ return { padding, top, rWidth, rHeight };
1130
+ }
1131
+ setActiveCamera(stream) {
1132
+ this.videoReady.next(false);
1133
+ this.showVideo = false;
1134
+ this.activeVideoSettings = stream.getVideoTracks()[0].getSettings();
1135
+ const activeDeviceId = WebcamComponent.getDeviceIdFromMediaStreamTrack(stream.getVideoTracks()[0]);
1136
+ const videoTrack = stream.getTracks()[0];
1137
+ this.trackSettings = videoTrack.getSettings();
1138
+ this.cameraProvider.cameraWasSwitched(activeDeviceId);
1139
+ this.cameraSwitched.next(activeDeviceId);
1140
+ setTimeout(() => {
1141
+ this.zone.run(() => {
1142
+ this.resizeStage();
1143
+ this.showVideo = true;
1144
+ this.videoReady.next(true);
1145
+ if (MediaStreamTrackProcessor) {
1146
+ this.trackProcessor = new MediaStreamTrackProcessor(videoTrack);
1147
+ let frameStream = this.trackProcessor.readable;
1148
+ if (!this.shutdown) {
1149
+ this.worker?.postMessage({
1150
+ type: 'start',
1151
+ frameStream: frameStream,
1152
+ trackSettings: this.trackSettings,
1153
+ }, [frameStream]);
1154
+ }
1155
+ }
1156
+ });
1157
+ }, 500);
1158
+ }
1159
+ getActiveVideoTrack() {
1160
+ return this.mediaStream ? this.mediaStream.getVideoTracks()[0] : null;
1161
+ }
1162
+ isMirrorImage() {
1163
+ if (!this.getActiveVideoTrack()) {
1164
+ return false;
1165
+ }
1166
+ // check for explicit mirror override parameter
1167
+ {
1168
+ let mirror = 'auto';
1169
+ if (this.mirrorImage) {
1170
+ if (typeof this.mirrorImage === 'string') {
1171
+ mirror = String(this.mirrorImage).toLowerCase();
1172
+ }
1173
+ else {
1174
+ // WebcamMirrorProperties
1175
+ if (this.mirrorImage.x) {
1176
+ mirror = this.mirrorImage.x.toLowerCase();
1177
+ }
1178
+ }
1179
+ }
1180
+ switch (mirror) {
1181
+ case 'always':
1182
+ return true;
1183
+ case 'never':
1184
+ return false;
1185
+ }
1186
+ }
1187
+ // default: enable mirroring if webcam is user facing
1188
+ return WebcamComponent.isUserFacing(this.getActiveVideoTrack());
1189
+ }
1190
+ /**
1191
+ * Stops all active media tracks.
1192
+ * This prevents the webcam from being indicated as active,
1193
+ * even if it is no longer used by this component.
1194
+ */
1195
+ stopMediaTracks() {
1196
+ // this.video.nativeElement.pause();
1197
+ if (this.video.nativeElement.srcObject) {
1198
+ this.video.nativeElement.srcObject
1199
+ .getTracks()
1200
+ .forEach((track) => {
1201
+ track.stop();
1202
+ });
1203
+ this.video.nativeElement.srcObject = null;
1204
+ this.video.nativeElement.src = '';
1205
+ }
1206
+ if (this.mediaStream && this.mediaStream.getTracks) {
1207
+ // getTracks() returns all media tracks (video+audio)
1208
+ this.mediaStream
1209
+ .getTracks()
1210
+ .forEach((track) => track.stop());
1211
+ }
1212
+ }
1213
+ /**
1214
+ * Unsubscribe from all open subscriptions
1215
+ */
1216
+ unsubscribeFromSubscriptions() {
1217
+ if (this.triggerSubscription) {
1218
+ this.triggerSubscription.unsubscribe();
1219
+ }
1220
+ if (this.switchCameraSubscription) {
1221
+ this.switchCameraSubscription.unsubscribe();
1222
+ }
1223
+ }
1224
+ /**
1225
+ * Reads available input devices
1226
+ */
1227
+ detectAvailableDevices() {
1228
+ return new Promise((resolve, reject) => {
1229
+ WebcamUtil.getAvailableVideoInputs().subscribe((devices) => {
1230
+ this.availableVideoInputs = devices;
1231
+ resolve(devices);
1232
+ }, (err) => {
1233
+ this.availableVideoInputs = [];
1234
+ reject(err);
1235
+ });
1236
+ });
1237
+ }
1238
+ }
1239
+ WebcamComponent.DEFAULT_VIDEO_OPTIONS = {
1240
+ facingMode: 'environment',
1241
+ };
1242
+ WebcamComponent.DEFAULT_IMAGE_TYPE = 'image/jpeg';
1243
+ WebcamComponent.DEFAULT_IMAGE_QUALITY = 1;
1244
+ WebcamComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: WebcamComponent, deps: [{ token: i1.BreakpointObserver }, { token: i2.Platform }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: NgxScandocCameraProvider }], target: i0.ɵɵFactoryTarget.Component });
1245
+ WebcamComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: WebcamComponent, selector: "app-webcam", inputs: { imageHandler: "imageHandler", id: "id", type: "type", width: "width", height: "height", videoOptions: "videoOptions", allowCameraSwitch: "allowCameraSwitch", mirrorImage: "mirrorImage", captureImageData: "captureImageData", imageType: "imageType", imageQuality: "imageQuality", trigger: "trigger", switchCamera: "switchCamera" }, outputs: { imageCapture: "imageCapture", initError: "initError", imageClick: "imageClick", cameraSwitched: "cameraSwitched", videoReady: "videoReady", destroyed: "destroyed" }, host: { listeners: { "window:resize": "onResize($event)" } }, viewQueries: [{ propertyName: "video", first: true, predicate: ["video"], descendants: true, static: true }, { propertyName: "videoStreamer", first: true, predicate: ["videoStreamer"], descendants: true, static: true }, { propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true, static: true }, { propertyName: "canvasSnapshot", first: true, predicate: ["canvasSnapshot"], descendants: true, static: true }, { propertyName: "canvasResize", first: true, predicate: ["canvasResize"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"webcam-wrapper\">\n <div>\n <video\n #video\n autoplay\n muted\n style=\"display: block\"\n playsinline\n\n ></video>\n\n <div class=\"rectangle\">\n\n <canvas\n #canvas\n [ngStyle]=\"{ visibility: showVideo ? 'visible' : 'hidden' }\"\n [width]=\"canvasSize.width\"\n [height]=\"canvasSize.height\"\n ></canvas>\n </div>\n </div>\n</div>\n", styles: [":host{display:flex;flex-direction:row;flex:1;transform:transale3d(0,0,0);background-color:#000}.webcam-wrapper{display:flex;flex-direction:row;align-items:center;flex:1;justify-content:center}.webcam-wrapper canvas{transform:transale3d(0,0,0);display:block;position:relative;z-index:20;left:0;top:0}.webcam-wrapper .rectangle{position:absolute;left:0;top:0;display:flex;flex-direction:row;align-items:center;justify-content:center;width:100%;height:100%}\n"], dependencies: [{ kind: "directive", type: i5.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
1246
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: WebcamComponent, decorators: [{
1247
+ type: Component,
1248
+ args: [{ selector: 'app-webcam', template: "<div class=\"webcam-wrapper\">\n <div>\n <video\n #video\n autoplay\n muted\n style=\"display: block\"\n playsinline\n\n ></video>\n\n <div class=\"rectangle\">\n\n <canvas\n #canvas\n [ngStyle]=\"{ visibility: showVideo ? 'visible' : 'hidden' }\"\n [width]=\"canvasSize.width\"\n [height]=\"canvasSize.height\"\n ></canvas>\n </div>\n </div>\n</div>\n", styles: [":host{display:flex;flex-direction:row;flex:1;transform:transale3d(0,0,0);background-color:#000}.webcam-wrapper{display:flex;flex-direction:row;align-items:center;flex:1;justify-content:center}.webcam-wrapper canvas{transform:transale3d(0,0,0);display:block;position:relative;z-index:20;left:0;top:0}.webcam-wrapper .rectangle{position:absolute;left:0;top:0;display:flex;flex-direction:row;align-items:center;justify-content:center;width:100%;height:100%}\n"] }]
1249
+ }], ctorParameters: function () { return [{ type: i1.BreakpointObserver }, { type: i2.Platform }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: NgxScandocCameraProvider }]; }, propDecorators: { imageHandler: [{
1250
+ type: Input
1251
+ }], id: [{
1252
+ type: Input
1253
+ }], type: [{
1254
+ type: Input
1255
+ }], width: [{
1256
+ type: Input
1257
+ }], height: [{
1258
+ type: Input
1259
+ }], videoOptions: [{
1260
+ type: Input
1261
+ }], allowCameraSwitch: [{
1262
+ type: Input
1263
+ }], mirrorImage: [{
1264
+ type: Input
1265
+ }], captureImageData: [{
1266
+ type: Input
1267
+ }], imageType: [{
1268
+ type: Input
1269
+ }], imageQuality: [{
1270
+ type: Input
1271
+ }], imageCapture: [{
1272
+ type: Output
1273
+ }], initError: [{
1274
+ type: Output
1275
+ }], imageClick: [{
1276
+ type: Output
1277
+ }], cameraSwitched: [{
1278
+ type: Output
1279
+ }], videoReady: [{
1280
+ type: Output
1281
+ }], destroyed: [{
1282
+ type: Output
1283
+ }], video: [{
1284
+ type: ViewChild,
1285
+ args: ['video', { static: true }]
1286
+ }], videoStreamer: [{
1287
+ type: ViewChild,
1288
+ args: ['videoStreamer', { static: true }]
1289
+ }], canvas: [{
1290
+ type: ViewChild,
1291
+ args: ['canvas', { static: true }]
1292
+ }], canvasSnapshot: [{
1293
+ type: ViewChild,
1294
+ args: ['canvasSnapshot', { static: true }]
1295
+ }], canvasResize: [{
1296
+ type: ViewChild,
1297
+ args: ['canvasResize', { static: true }]
1298
+ }], trigger: [{
1299
+ type: Input
1300
+ }], switchCamera: [{
1301
+ type: Input
1302
+ }], onResize: [{
1303
+ type: HostListener,
1304
+ args: ['window:resize', ['$event']]
1305
+ }] } });
1306
+
1307
+ const COMPONENTS = [
1308
+ WebcamComponent
1309
+ ];
1310
+ class WebcamModule {
1311
+ }
1312
+ WebcamModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: WebcamModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1313
+ WebcamModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: WebcamModule, declarations: [WebcamComponent], imports: [CommonModule, PlatformModule], exports: [WebcamComponent] });
1314
+ WebcamModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: WebcamModule, imports: [CommonModule, PlatformModule] });
1315
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: WebcamModule, decorators: [{
1316
+ type: NgModule,
1317
+ args: [{
1318
+ imports: [CommonModule, PlatformModule],
1319
+ declarations: [COMPONENTS],
1320
+ exports: [COMPONENTS],
1321
+ }]
1322
+ }] });
1323
+
1324
+ class ScanProvider {
1325
+ constructor(http, config) {
1326
+ this.http = http;
1327
+ this.config = config;
1328
+ this.enableVerification = true;
1329
+ this.canStoreImages = true;
1330
+ }
1331
+ genderList() {
1332
+ return {
1333
+ M: 'MALE',
1334
+ 'M/M': 'MALE',
1335
+ F: 'FEMALE',
1336
+ 'F/F': 'FEMALE',
1337
+ };
1338
+ }
1339
+ stateless(DocumentFaceImage, LiveFaceImage) {
1340
+ const data = {
1341
+ AcceptTermsAndConditions: true,
1342
+ DataFields: {
1343
+ DocumentFaceImageType: 'base64',
1344
+ DocumentFaceImage,
1345
+ LiveFaceImageType: 'base64',
1346
+ LiveFaceImage,
1347
+ },
1348
+ };
1349
+ const $request = this.http.post(this.config.stateLessPath, data);
1350
+ return $request;
1351
+ }
1352
+ sendLog(data) {
1353
+ const { TransactionID } = data.Response;
1354
+ const $request = this.http.post(this.config.errorLoggingPath, data, {
1355
+ headers: new HttpHeaders({
1356
+ TransactionID,
1357
+ }),
1358
+ });
1359
+ return $request;
1360
+ }
1361
+ burst(Images) {
1362
+ const data = {
1363
+ AcceptTermsAndConditions: true,
1364
+ DataFields: {
1365
+ Images,
1366
+ },
1367
+ };
1368
+ const $request = this.http.post(this.config.validationPath, data);
1369
+ return $request;
1370
+ }
1371
+ countries() {
1372
+ return this.http.get('/assets/data/countries.json').pipe(map((data) => {
1373
+ return data.data.map((c) => {
1374
+ return { label: c.short.en, value: c.cca2 };
1375
+ });
1376
+ }));
1377
+ }
1378
+ countryList() {
1379
+ return {
1380
+ AFG: 'AF',
1381
+ ALB: 'AL',
1382
+ DZA: 'DZ',
1383
+ ASM: 'AS',
1384
+ AND: 'AD',
1385
+ AGO: 'AO',
1386
+ AIA: 'AI',
1387
+ ATG: 'AG',
1388
+ ARG: 'AR',
1389
+ ARM: 'AM',
1390
+ ABW: 'AW',
1391
+ AUS: 'AU',
1392
+ AUT: 'AT',
1393
+ AZE: 'AZ',
1394
+ BHS: 'BS',
1395
+ BHR: 'BH',
1396
+ BGD: 'BD',
1397
+ BRB: 'BB',
1398
+ BLR: 'BY',
1399
+ BEL: 'BE',
1400
+ BLZ: 'BZ',
1401
+ BEN: 'BJ',
1402
+ BMU: 'BM',
1403
+ BTN: 'BT',
1404
+ BOL: 'BO',
1405
+ BIH: 'BA',
1406
+ BWA: 'BW',
1407
+ BRA: 'BR',
1408
+ VGB: 'VG',
1409
+ BRN: 'BN',
1410
+ BGR: 'BG',
1411
+ BFA: 'BF',
1412
+ BDI: 'BI',
1413
+ KHM: 'KH',
1414
+ CMR: 'CM',
1415
+ CAN: 'CA',
1416
+ CPV: 'CV',
1417
+ CAF: 'CF',
1418
+ TCD: 'TD',
1419
+ CHL: 'CL',
1420
+ CHN: 'CN',
1421
+ HKG: 'HK',
1422
+ MAC: 'MO',
1423
+ COL: 'CO',
1424
+ COM: 'KM',
1425
+ COG: 'CG',
1426
+ CRI: 'CR',
1427
+ CIV: 'CI',
1428
+ HRV: 'HR',
1429
+ CUB: 'CU',
1430
+ CYP: 'CY',
1431
+ CZE: 'CZ',
1432
+ DNK: 'DK',
1433
+ DJI: 'DJ',
1434
+ DMA: 'DM',
1435
+ DOM: 'DO',
1436
+ ECU: 'EC',
1437
+ EGY: 'EG',
1438
+ SLV: 'SV',
1439
+ GNQ: 'GQ',
1440
+ ERI: 'ER',
1441
+ EST: 'EE',
1442
+ ETH: 'ET',
1443
+ FRO: 'FO',
1444
+ FJI: 'FJ',
1445
+ FIN: 'FI',
1446
+ FRA: 'FR',
1447
+ GUF: 'GF',
1448
+ PYF: 'PF',
1449
+ GAB: 'GA',
1450
+ GMB: 'GM',
1451
+ GEO: 'GE',
1452
+ DEU: 'DE',
1453
+ GHA: 'GH',
1454
+ GRC: 'GR',
1455
+ GRL: 'GL',
1456
+ GRD: 'GD',
1457
+ GLP: 'GP',
1458
+ GUM: 'GU',
1459
+ GTM: 'GT',
1460
+ GNB: 'GW',
1461
+ HTI: 'HT',
1462
+ HND: 'HN',
1463
+ ISL: 'IS',
1464
+ IDN: 'ID',
1465
+ IRQ: 'IQ',
1466
+ ITA: 'IT',
1467
+ JPN: 'JP',
1468
+ JOR: 'JO',
1469
+ KAZ: 'KZ',
1470
+ KEN: 'KE',
1471
+ KIR: 'KI',
1472
+ PRK: 'KP',
1473
+ KOR: 'KR',
1474
+ KWT: 'KW',
1475
+ KGZ: 'KG',
1476
+ LAO: 'LA',
1477
+ LVA: 'LV',
1478
+ LBN: 'LB',
1479
+ LSO: 'LS',
1480
+ LBR: 'LR',
1481
+ LBY: 'LY',
1482
+ LIE: 'LI',
1483
+ LTU: 'LT',
1484
+ LUX: 'LU',
1485
+ MDG: 'MG',
1486
+ MWI: 'MW',
1487
+ MYS: 'MY',
1488
+ MDV: 'MV',
1489
+ MLI: 'ML',
1490
+ MLT: 'MT',
1491
+ MHL: 'MH',
1492
+ MTQ: 'MQ',
1493
+ MRT: 'MR',
1494
+ MUS: 'MU',
1495
+ MEX: 'MX',
1496
+ FSM: 'FM',
1497
+ MDA: 'MD',
1498
+ MCO: 'MC',
1499
+ MNG: 'MN',
1500
+ MNE: 'ME',
1501
+ MSR: 'MS',
1502
+ MAR: 'MA',
1503
+ MOZ: 'MZ',
1504
+ MMR: 'MM',
1505
+ NAM: 'NA',
1506
+ NRU: 'NR',
1507
+ NPL: 'NP',
1508
+ NLD: 'NL',
1509
+ ANT: 'AN',
1510
+ NCL: 'NC',
1511
+ NZL: 'NZ',
1512
+ NIC: 'NI',
1513
+ NER: 'NE',
1514
+ NGA: 'NG',
1515
+ MNP: 'MP',
1516
+ NOR: 'NO',
1517
+ OMN: 'OM',
1518
+ PAK: 'PK',
1519
+ PLW: 'PW',
1520
+ PSE: 'PS',
1521
+ PAN: 'PA',
1522
+ PNG: 'PG',
1523
+ PRY: 'PY',
1524
+ PER: 'PE',
1525
+ PHL: 'PH',
1526
+ PCN: 'PN',
1527
+ POL: 'PL',
1528
+ PRT: 'PT',
1529
+ PRI: 'PR',
1530
+ QAT: 'QA',
1531
+ REU: 'RE',
1532
+ ROU: 'RO',
1533
+ RUS: 'RU',
1534
+ RWA: 'RW',
1535
+ KNA: 'KN',
1536
+ LCA: 'LC',
1537
+ VCT: 'VC',
1538
+ WSM: 'WS',
1539
+ SMR: 'SM',
1540
+ STP: 'ST',
1541
+ SAU: 'SA',
1542
+ SEN: 'SN',
1543
+ SRB: 'RS',
1544
+ SYC: 'SC',
1545
+ SLE: 'SL',
1546
+ SGP: 'SG',
1547
+ SVK: 'SK',
1548
+ SVN: 'SI',
1549
+ SLB: 'SB',
1550
+ SOM: 'SO',
1551
+ ZAF: 'ZA',
1552
+ ESP: 'ES',
1553
+ LKA: 'LK',
1554
+ SDN: 'SD',
1555
+ SUR: 'SR',
1556
+ SWZ: 'SZ',
1557
+ SWE: 'SE',
1558
+ CHE: 'CH',
1559
+ SYR: 'SY',
1560
+ TJK: 'TJ',
1561
+ TZA: 'TZ',
1562
+ THA: 'TH',
1563
+ TLS: 'TL',
1564
+ TGO: 'TG',
1565
+ TON: 'TO',
1566
+ TTO: 'TT',
1567
+ TUN: 'TN',
1568
+ TUR: 'TR',
1569
+ TKM: 'TM',
1570
+ TUV: 'TV',
1571
+ UGA: 'UG',
1572
+ UKR: 'UA',
1573
+ ARE: 'AE',
1574
+ GBR: 'GB',
1575
+ USA: 'US',
1576
+ URY: 'UY',
1577
+ UZB: 'UZ',
1578
+ VUT: 'VU',
1579
+ VEN: 'VE',
1580
+ VNM: 'VN',
1581
+ VIR: 'VI',
1582
+ YEM: 'YE',
1583
+ ZMB: 'ZM',
1584
+ ZWE: 'ZW',
1585
+ };
1586
+ }
1587
+ get fields() {
1588
+ return [
1589
+ {
1590
+ key: 'Birth Date',
1591
+ form: 'birthDate',
1592
+ type: 'date',
1593
+ main: false,
1594
+ blastKey: 'BirthDate',
1595
+ },
1596
+ {
1597
+ key: 'Given Name',
1598
+ form: 'firstName',
1599
+ ucFirst: true,
1600
+ type: 'string',
1601
+ main: true,
1602
+ blastKey: 'Name',
1603
+ },
1604
+ {
1605
+ key: 'Surname',
1606
+ form: 'lastName',
1607
+ ucFirst: true,
1608
+ type: 'string',
1609
+ main: true,
1610
+ blastKey: 'Surname',
1611
+ },
1612
+ {
1613
+ key: 'Sex',
1614
+ form: 'gender',
1615
+ type: 'gender',
1616
+ main: false,
1617
+ blastKey: 'Gender',
1618
+ },
1619
+ {
1620
+ key: 'Document Class Name',
1621
+ type: 'string',
1622
+ form: 'documentType',
1623
+ main: false,
1624
+ blastKey: 'docType',
1625
+ },
1626
+ {
1627
+ key: 'Document Number',
1628
+ type: 'string',
1629
+ form: 'documentNumber',
1630
+ main: false,
1631
+ blastKey: 'DocumentNumber',
1632
+ },
1633
+ {
1634
+ key: 'Issuing State Code',
1635
+ type: 'country',
1636
+ form: 'issueStateCode',
1637
+ blastKey: 'CountryOfIssue',
1638
+ main: false,
1639
+ },
1640
+ {
1641
+ key: 'Expiration Date',
1642
+ type: 'date',
1643
+ form: 'expirationDate',
1644
+ blastKey: 'ExpiryDate',
1645
+ main: false,
1646
+ },
1647
+ {
1648
+ key: 'Issue Date',
1649
+ type: 'date',
1650
+ form: 'issueDate',
1651
+ blastKey: 'IssuedDate',
1652
+ main: false,
1653
+ },
1654
+ {
1655
+ key: 'Birth Place',
1656
+ type: 'string',
1657
+ form: 'birthPlace',
1658
+ blastKey: 'PlaceOfBirth',
1659
+ main: false,
1660
+ },
1661
+ {
1662
+ key: 'Issuing Authority',
1663
+ type: 'string',
1664
+ form: 'issuingPlace',
1665
+ blastKey: 'IssuingAuthority',
1666
+ main: false,
1667
+ },
1668
+ {
1669
+ key: 'Nationality Code',
1670
+ type: 'country',
1671
+ form: 'nationality',
1672
+ main: false,
1673
+ blastKey: 'Nationality',
1674
+ },
1675
+ {
1676
+ key: 'street1',
1677
+ type: 'string',
1678
+ form: 'street1',
1679
+ main: false,
1680
+ blastKey: 'AddressStreet',
1681
+ },
1682
+ {
1683
+ key: 'city',
1684
+ type: 'string',
1685
+ form: 'city',
1686
+ main: false,
1687
+ blastKey: 'AddressCity',
1688
+ },
1689
+ {
1690
+ key: 'country',
1691
+ type: 'country',
1692
+ form: 'country',
1693
+ main: false,
1694
+ blastKey: 'Country',
1695
+ },
1696
+ {
1697
+ key: 'zip',
1698
+ type: 'string',
1699
+ form: 'zip',
1700
+ main: false,
1701
+ blastKey: 'AddressZip',
1702
+ },
1703
+ ];
1704
+ }
1705
+ parseBlast(results) {
1706
+ const countries = this.countryList();
1707
+ const genders = this.genderList();
1708
+ const data = this.fields;
1709
+ const validatedAddressFields = [
1710
+ 'AddressCity',
1711
+ 'AddressZip',
1712
+ 'AddressCounty',
1713
+ 'AddressStreet',
1714
+ ].filter((key) => results[key].Validated);
1715
+ // if no address is validated
1716
+ if (validatedAddressFields.length === 0) {
1717
+ if (results.Address.Validated) {
1718
+ results.AddressStreet = results.Address;
1719
+ }
1720
+ }
1721
+ const out = data.map((itm) => {
1722
+ const res = results[itm.blastKey];
1723
+ if (res) {
1724
+ const value = res.RecommendedValue || '';
1725
+ switch (itm.type) {
1726
+ case 'string':
1727
+ itm.value = value;
1728
+ if (itm.ucFirst) {
1729
+ const name = value.toLowerCase();
1730
+ itm.value = name.charAt(0).toUpperCase() + name.slice(1);
1731
+ }
1732
+ break;
1733
+ case 'date':
1734
+ itm.value = value ? moment(value, 'DD.MM.YYYY').toDate() : null;
1735
+ // if (value.indexOf('/Date') >= 0) {
1736
+ // console.log(value);
1737
+ // const timestamp = value.replace(/\D/gm, '');
1738
+ // //itm.value = moment.unix(timestamp / 1000).toDate();
1739
+ // itm.value = moment(
1740
+ // timestamp - moment(timestamp, 'x').utcOffset() * 60 * 1000,
1741
+ // 'x',
1742
+ // ).toDate();
1743
+ // }
1744
+ break;
1745
+ case 'country':
1746
+ itm.value = countries[value] || null;
1747
+ break;
1748
+ case 'gender':
1749
+ itm.value = genders[value] || null;
1750
+ }
1751
+ }
1752
+ return itm;
1753
+ });
1754
+ const model = {};
1755
+ out.forEach((element) => {
1756
+ console.log(element);
1757
+ model[element.form] = element.value;
1758
+ });
1759
+ model.documentType = results.Metadata.DocumentType;
1760
+ console.log(model);
1761
+ return {
1762
+ fields: out,
1763
+ model,
1764
+ };
1765
+ }
1766
+ blastPost(data) {
1767
+ // const $request = this.api.http.get('/assets/json/blastscan.json');
1768
+ const $request = this.http.post(this.config.extractionPath, data);
1769
+ return $request.pipe(map((m) => {
1770
+ if (m.Metadata && m.Metadata.length > 0) {
1771
+ const metadata = m.Metadata[0];
1772
+ m.Data.Country = {
1773
+ RecommendedValue: metadata.Country,
1774
+ };
1775
+ m.Data.Metadata = metadata;
1776
+ }
1777
+ return m;
1778
+ }));
1779
+ }
1780
+ blobToDataUrl(file) {
1781
+ return Observable.create((obs) => {
1782
+ const reader = new FileReader();
1783
+ reader.onerror = (err) => obs.error(err);
1784
+ reader.onabort = (err) => obs.error(err);
1785
+ reader.onload = () => {
1786
+ obs.next(reader.result);
1787
+ };
1788
+ reader.onloadend = () => obs.complete();
1789
+ return reader.readAsDataURL(file);
1790
+ });
1791
+ }
1792
+ }
1793
+ ScanProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanProvider, deps: [{ token: i1$1.HttpClient }, { token: 'config' }], target: i0.ɵɵFactoryTarget.Injectable });
1794
+ ScanProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanProvider, providedIn: 'root' });
1795
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanProvider, decorators: [{
1796
+ type: Injectable,
1797
+ args: [{
1798
+ providedIn: 'root',
1799
+ }]
1800
+ }], ctorParameters: function () { return [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
1801
+ type: Inject,
1802
+ args: ['config']
1803
+ }] }]; } });
1804
+
1805
+ class LayoutProvider {
1806
+ constructor(breakpointObserver) {
1807
+ this.breakpointObserver = breakpointObserver;
1808
+ this.isMobile = false;
1809
+ this.breakpoint$ = this.breakpointObserver
1810
+ .observe(['(min-width: 768px)'])
1811
+ .pipe(tap$1((value) => console.log(value)), distinctUntilChanged());
1812
+ }
1813
+ init() {
1814
+ this.breakpoint$.subscribe((v) => {
1815
+ this.isMobile = !v.matches;
1816
+ document.body.className = this.isMobile ? 'mobile' : 'desktop';
1817
+ });
1818
+ }
1819
+ }
1820
+ LayoutProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LayoutProvider, deps: [{ token: i1.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Injectable });
1821
+ LayoutProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LayoutProvider, providedIn: 'root' });
1822
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LayoutProvider, decorators: [{
1823
+ type: Injectable,
1824
+ args: [{
1825
+ providedIn: 'root',
1826
+ }]
1827
+ }], ctorParameters: function () { return [{ type: i1.BreakpointObserver }]; } });
1828
+
1829
+ class AuthProvider {
1830
+ constructor(http, config) {
1831
+ this.http = http;
1832
+ this.config = config;
1833
+ this.token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJDbGllbnQiOiJQcm90ZWwiLCJTdWJDbGllbnQiOiJIMSIsIklzc3VlVGltZSI6IjA5LjAzLjIwMjIsIDA5OjQ3OjAwIn0.u_FP16TGuZ4LtGbsIxBjy8vCJJuTyBbRs2gPPZU2vgaeSvLdfi1iEVcRjRVh873hkluOtotUGmw0v3Jdh-cHgQ';
1834
+ this.tokenTimestamps = {
1835
+ exp: 0,
1836
+ iat: 0,
1837
+ };
1838
+ }
1839
+ setConfig() { }
1840
+ get tokenExpired() {
1841
+ return false;
1842
+ if (this.token == '' || this.tokenTimestamps.exp === 0) {
1843
+ console.log('EXPIRED');
1844
+ return true;
1845
+ }
1846
+ const { iat, exp } = this.tokenTimestamps;
1847
+ return iat + 20 > exp;
1848
+ }
1849
+ resetToken() {
1850
+ this.token = '';
1851
+ }
1852
+ get accesToken() {
1853
+ return this.tokenExpired ? this.getToken() : of(this.token);
1854
+ }
1855
+ getToken() {
1856
+ return this.http
1857
+ .post(this.config.path, {
1858
+ clientId: this.config.clientId,
1859
+ token: this.config.tokenName,
1860
+ })
1861
+ .pipe(map((data) => data.accessToken), tap((token) => {
1862
+ this.token = token;
1863
+ const decoded = jwt_decode(this.token);
1864
+ const { iat, exp } = decoded;
1865
+ this.tokenTimestamps = { iat, exp };
1866
+ }));
1867
+ }
1868
+ }
1869
+ AuthProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AuthProvider, deps: [{ token: i1$1.HttpClient }, { token: 'configAuth' }], target: i0.ɵɵFactoryTarget.Injectable });
1870
+ AuthProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AuthProvider, providedIn: 'root' });
1871
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AuthProvider, decorators: [{
1872
+ type: Injectable,
1873
+ args: [{
1874
+ providedIn: 'root',
1875
+ }]
1876
+ }], ctorParameters: function () { return [{ type: i1$1.HttpClient }, { type: undefined, decorators: [{
1877
+ type: Inject,
1878
+ args: ['configAuth']
1879
+ }] }]; } });
1880
+
1881
+ class TranslationProvider {
1882
+ constructor(translate) {
1883
+ this.translate = translate;
1884
+ }
1885
+ forms(item, namespace = null) {
1886
+ if (item.fieldGroup) {
1887
+ item.fieldGroup = item.fieldGroup.map((field) => this.forms(field));
1888
+ }
1889
+ const prefix = namespace ? namespace + '.' : '';
1890
+ if (item.templateOptions &&
1891
+ (item.templateOptions.label ||
1892
+ item.templateOptions.placeholder ||
1893
+ item.templateOptions.options)) {
1894
+ if (!item.expressionProperties) {
1895
+ item.expressionProperties = {};
1896
+ }
1897
+ if (item.templateOptions.label) {
1898
+ item.expressionProperties['templateOptions.label'] =
1899
+ this.translate.stream(prefix + item.templateOptions.label);
1900
+ }
1901
+ if (item.templateOptions.placeholder) {
1902
+ item.expressionProperties['templateOptions.placeholder'] =
1903
+ this.translate.stream(prefix + item.templateOptions.placeholder);
1904
+ }
1905
+ if (Array.isArray(item.templateOptions.options)) {
1906
+ item.expressionProperties['templateOptions.options'] =
1907
+ item.templateOptions.options.map((m) => {
1908
+ // console.log(m);
1909
+ if (m.label) {
1910
+ m.label = this.translate.instant(prefix + m.label);
1911
+ }
1912
+ return m;
1913
+ });
1914
+ }
1915
+ }
1916
+ return item;
1917
+ }
1918
+ }
1919
+ TranslationProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TranslationProvider, deps: [{ token: i1$2.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
1920
+ TranslationProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TranslationProvider, providedIn: 'root' });
1921
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TranslationProvider, decorators: [{
1922
+ type: Injectable,
1923
+ args: [{
1924
+ providedIn: 'root',
1925
+ }]
1926
+ }], ctorParameters: function () { return [{ type: i1$2.TranslateService }]; } });
1927
+
1928
+ class ScanFieldsProvider {
1929
+ constructor(translate, provider) {
1930
+ this.translate = translate;
1931
+ this.provider = provider;
1932
+ }
1933
+ update() {
1934
+ return [
1935
+ {
1936
+ fieldGroupClassName: 'px-16',
1937
+ fieldGroup: [
1938
+ {
1939
+ wrappers: [],
1940
+ type: 'checkbox',
1941
+ key: 'profile',
1942
+ class: 'checkbox ',
1943
+ defaultValue: true,
1944
+ templateOptions: {
1945
+ label: 'form.scan.document.update.profile',
1946
+ },
1947
+ },
1948
+ {
1949
+ wrappers: [],
1950
+ type: 'checkbox',
1951
+ class: 'checkbox ',
1952
+ key: 'document',
1953
+ defaultValue: true,
1954
+ templateOptions: {
1955
+ label: 'form.scan.document.update.document',
1956
+ },
1957
+ },
1958
+ {
1959
+ wrappers: [],
1960
+ type: 'checkbox',
1961
+ class: 'checkbox ',
1962
+ key: 'attachment',
1963
+ defaultValue: true,
1964
+ templateOptions: {
1965
+ label: 'form.scan.document.update.attachment',
1966
+ },
1967
+ },
1968
+ ].map((item) => this.translate.forms(item)),
1969
+ },
1970
+ ];
1971
+ }
1972
+ document() {
1973
+ return [
1974
+ {
1975
+ className: 'w-200-p',
1976
+ fieldGroupClassName: 'form-flex-row border-card profile-details',
1977
+ fieldGroup: [
1978
+ {
1979
+ className: 'card-group',
1980
+ fieldGroupClassName: 'wraper',
1981
+ fieldGroup: [
1982
+ {
1983
+ type: 'title',
1984
+ templateOptions: {
1985
+ label: 'form.scan.document.guestDetailsTitle',
1986
+ },
1987
+ },
1988
+ // {
1989
+ // type: 'profile-image',
1990
+ // key: '_avatar',
1991
+ // templateOptions: {
1992
+ // label: 'form.scan.document.firstName',
1993
+ // },
1994
+ // },
1995
+ {
1996
+ type: 'input',
1997
+ key: 'firstName',
1998
+ className: 'small',
1999
+ templateOptions: {
2000
+ label: 'form.scan.document.firstName',
2001
+ required: true,
2002
+ },
2003
+ },
2004
+ {
2005
+ type: 'input',
2006
+ key: 'lastName',
2007
+ className: 'small',
2008
+ templateOptions: {
2009
+ label: 'form.scan.document.lastName',
2010
+ required: true,
2011
+ },
2012
+ },
2013
+ {
2014
+ className: 'small',
2015
+ key: 'secondName',
2016
+ type: 'input',
2017
+ templateOptions: {
2018
+ color: 'accent',
2019
+ label: 'form.scan.document.secondLastName',
2020
+ },
2021
+ hideExpression: 'model.hideSecondLastName',
2022
+ },
2023
+ {
2024
+ type: 'input',
2025
+ key: 'middleName',
2026
+ className: 'small',
2027
+ templateOptions: {
2028
+ label: 'form.scan.document.middleName',
2029
+ },
2030
+ },
2031
+ {
2032
+ className: '',
2033
+ fieldGroupClassName: 'form-flex-row space-between',
2034
+ fieldGroup: [
2035
+ {
2036
+ type: 'datepicker',
2037
+ key: 'birthDate',
2038
+ className: 'w-100-p small mr-8',
2039
+ templateOptions: {
2040
+ label: 'form.scan.document.birthDate',
2041
+ },
2042
+ },
2043
+ {
2044
+ type: 'select',
2045
+ key: 'gender',
2046
+ className: 'w-100-p small ml-8',
2047
+ templateOptions: {
2048
+ label: 'form.scan.document.gender',
2049
+ options: [
2050
+ { value: 'MALE', label: 'MALE' },
2051
+ { value: 'FEMALE', label: 'FEMALE' },
2052
+ { value: 'NA', label: 'N/A' },
2053
+ ],
2054
+ },
2055
+ },
2056
+ ],
2057
+ },
2058
+ {
2059
+ type: 'input',
2060
+ key: 'birthPlace',
2061
+ className: 'small',
2062
+ templateOptions: {
2063
+ label: 'form.scan.document.birthPlace',
2064
+ },
2065
+ },
2066
+ {
2067
+ type: 'select',
2068
+ key: 'birthCountry',
2069
+ className: 'small',
2070
+ templateOptions: {
2071
+ label: 'form.scan.document.birthCountry',
2072
+ options: this.provider.countries(),
2073
+ },
2074
+ },
2075
+ {
2076
+ className: 'small',
2077
+ key: 'nationality',
2078
+ type: 'select',
2079
+ templateOptions: {
2080
+ label: 'form.scan.document.nationality',
2081
+ // appearance: 'outline',
2082
+ // options: this.profileProvider.nationalities(),
2083
+ options: this.provider.countries(),
2084
+ },
2085
+ },
2086
+ ],
2087
+ },
2088
+ {
2089
+ className: 'card-group',
2090
+ fieldGroupClassName: 'wraper',
2091
+ fieldGroup: [
2092
+ {
2093
+ type: 'title',
2094
+ templateOptions: {
2095
+ label: 'form.scan.document.documentTitle',
2096
+ },
2097
+ },
2098
+ {
2099
+ type: 'select',
2100
+ key: 'documentType',
2101
+ templateOptions: {
2102
+ label: 'form.scan.document.documentType',
2103
+ options: [
2104
+ { value: 'ID', label: 'Identity Document' },
2105
+ { value: 'PASS', label: 'Passport' },
2106
+ { value: 'DL', label: 'Driver Licence' },
2107
+ ],
2108
+ // valueProp: 'id',
2109
+ // labelProp: 'value',
2110
+ required: true,
2111
+ },
2112
+ },
2113
+ {
2114
+ type: 'input',
2115
+ key: 'documentNumber',
2116
+ templateOptions: {
2117
+ label: 'form.scan.document.documentNumber',
2118
+ required: true,
2119
+ },
2120
+ },
2121
+ {
2122
+ className: '',
2123
+ fieldGroupClassName: 'form-flex-row space-between',
2124
+ fieldGroup: [
2125
+ {
2126
+ type: 'datepicker',
2127
+ key: 'issueDate',
2128
+ className: 'small mr-8',
2129
+ templateOptions: {
2130
+ label: 'form.scan.document.issueDate',
2131
+ },
2132
+ },
2133
+ {
2134
+ type: 'datepicker',
2135
+ key: 'expirationDate',
2136
+ className: 'small ml-8',
2137
+ templateOptions: {
2138
+ label: 'form.scan.document.expirationDate',
2139
+ },
2140
+ },
2141
+ ],
2142
+ },
2143
+ {
2144
+ type: 'select',
2145
+ key: 'issueStateCode',
2146
+ templateOptions: {
2147
+ label: 'form.scan.document.issuingStateCode',
2148
+ options: this.provider.countries(),
2149
+ },
2150
+ },
2151
+ {
2152
+ type: 'input',
2153
+ key: 'issuingPlace',
2154
+ templateOptions: {
2155
+ label: 'form.scan.document.issuingPlace',
2156
+ required: false,
2157
+ },
2158
+ },
2159
+ {
2160
+ className: '',
2161
+ fieldGroupClassName: 'form-flex-row space-between',
2162
+ fieldGroup: [
2163
+ {
2164
+ type: 'title',
2165
+ templateOptions: {
2166
+ label: 'form.scan.document.addressTitle',
2167
+ badge: 'communications',
2168
+ },
2169
+ },
2170
+ ].map((item) => this.translate.forms(item)),
2171
+ },
2172
+ // {
2173
+ // className: 'small',
2174
+ // key: 'typeID',
2175
+ // type: 'select',
2176
+ // templateOptions: {
2177
+ // label: 'form.profile.address.type',
2178
+ // required: true,
2179
+ // // options: this.profileProvider.addressTypes(),
2180
+ // expressionProperties: {
2181
+ // 'templateOptions.disabled': (model: any) =>
2182
+ // model.newAddress,
2183
+ // },
2184
+ // onClearValue: (field: FormlyFieldConfig) => {
2185
+ // field.formControl?.setValue('');
2186
+ // field.model.typeID = 0;
2187
+ // },
2188
+ // onSetNewValue: (field: FormlyFieldConfig, optObj: any) => {
2189
+ // field.formControl?.setValue(optObj.value);
2190
+ // field.model.typeID = optObj.value;
2191
+ // },
2192
+ // },
2193
+ // expressionProperties: {
2194
+ // 'templateOptions.disabled': (model: any) => !model.newAddress,
2195
+ // },
2196
+ // },
2197
+ {
2198
+ className: 'small',
2199
+ key: 'country',
2200
+ type: 'select',
2201
+ templateOptions: {
2202
+ required: true,
2203
+ label: 'form.profile.address.country',
2204
+ options: this.provider.countries(),
2205
+ },
2206
+ // expressionProperties: {
2207
+ // 'templateOptions.disabled': (model: any) => !model.newAddress,
2208
+ // },
2209
+ hooks: {
2210
+ onInit: (model) => {
2211
+ console.log(model);
2212
+ },
2213
+ },
2214
+ },
2215
+ {
2216
+ className: '',
2217
+ fieldGroupClassName: 'form-flex-row space-between',
2218
+ fieldGroup: [
2219
+ {
2220
+ className: 'mr-8 w-100-p',
2221
+ key: 'zip',
2222
+ type: 'input',
2223
+ templateOptions: {
2224
+ label: 'form.profile.address.zip',
2225
+ labelProp: (item) => {
2226
+ return `${item.zip} (${item.city})`;
2227
+ },
2228
+ set: (field, option) => {
2229
+ // console.log(option, field);
2230
+ field.formControl.setValue(option.value.zip);
2231
+ // set CITY
2232
+ field.form.get('city').setValue(option.value.city);
2233
+ },
2234
+ filter: (key, field) => {
2235
+ // return this.profileProvider.zipCodes({
2236
+ // countryCode: field.form.get('country').value,
2237
+ // zip: key,
2238
+ // });
2239
+ },
2240
+ },
2241
+ // expressionProperties: {
2242
+ // 'templateOptions.disabled': (model: any) =>
2243
+ // !model.newAddress,
2244
+ // },
2245
+ },
2246
+ {
2247
+ className: 'small ml-8',
2248
+ key: 'city',
2249
+ type: 'input',
2250
+ templateOptions: {
2251
+ label: 'form.profile.address.city',
2252
+ },
2253
+ // expressionProperties: {
2254
+ // 'templateOptions.disabled': (model: any) =>
2255
+ // !model.newAddress,
2256
+ // },
2257
+ },
2258
+ ].map((item) => this.translate.forms(item)),
2259
+ },
2260
+ // {
2261
+ // className: 'small',
2262
+ // key: 'state',
2263
+ // type: 'input',
2264
+ // templateOptions: {
2265
+ // label: 'form.profile.address.state',
2266
+ // },
2267
+ // // expressionProperties: {
2268
+ // // 'templateOptions.disabled': (model: any) => !model.newAddress,
2269
+ // // },
2270
+ // },
2271
+ // {
2272
+ // className: 'small',
2273
+ // key: 'countryStateID',
2274
+ // type: 'select',
2275
+ // templateOptions: {
2276
+ // label: 'form.profile.address.regionalStatistics',
2277
+ // options: this.provider.countries(),
2278
+ // },
2279
+ // // expressionProperties: {
2280
+ // // 'templateOptions.disabled': (model: any) => !model.newAddress,
2281
+ // // },
2282
+ // },
2283
+ {
2284
+ className: 'small w-100-p',
2285
+ key: 'street1',
2286
+ type: 'input',
2287
+ templateOptions: {
2288
+ label: 'form.profile.address.street',
2289
+ },
2290
+ // expressionProperties: {
2291
+ // 'templateOptions.disabled': (model: any) => !model.newAddress,
2292
+ // },
2293
+ },
2294
+ ],
2295
+ },
2296
+ ],
2297
+ },
2298
+ ].map((item) => this.translate.forms(item));
2299
+ }
2300
+ }
2301
+ ScanFieldsProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanFieldsProvider, deps: [{ token: TranslationProvider }, { token: ScanProvider }], target: i0.ɵɵFactoryTarget.Injectable });
2302
+ ScanFieldsProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanFieldsProvider, providedIn: 'root' });
2303
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanFieldsProvider, decorators: [{
2304
+ type: Injectable,
2305
+ args: [{
2306
+ providedIn: 'root',
2307
+ }]
2308
+ }], ctorParameters: function () { return [{ type: TranslationProvider }, { type: ScanProvider }]; } });
2309
+
2310
+ class ScanResultsComponent {
2311
+ constructor(cameraProvider, formProvider) {
2312
+ this.cameraProvider = cameraProvider;
2313
+ this.formProvider = formProvider;
2314
+ this.action = new EventEmitter();
2315
+ }
18
2316
  ngOnInit() {
2317
+ this.fields = this.formProvider.document();
2318
+ }
2319
+ ngOnDestroy() { }
2320
+ selfie() {
2321
+ this.action.emit({ selfie: true });
19
2322
  }
20
2323
  }
21
- NgxScandocComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
22
- NgxScandocComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: NgxScandocComponent, selector: "lib-ngx-scandoc", ngImport: i0, template: `
23
- <p>
24
- ngx-scandoc works!
25
- </p>
26
- `, isInline: true });
27
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocComponent, decorators: [{
2324
+ ScanResultsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanResultsComponent, deps: [{ token: NgxScandocCameraProvider }, { token: ScanFieldsProvider }], target: i0.ɵɵFactoryTarget.Component });
2325
+ ScanResultsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ScanResultsComponent, selector: "ngx-scan-results", inputs: { model: "model", images: "images", form: "form" }, outputs: { action: "action" }, ngImport: i0, template: "<div class=\"wraper\">\n <div style=\"flex: 1\">\n <mat-card style=\"margin: 4px; padding: 4px 16px\">\n <h3>Avatar</h3>\n <div class=\"selfieContainer\">\n <div class=\"selfie\">\n <img *ngIf=\"model?._avatar\" class=\"preview\" [src]=\"model._avatar\" />\n </div>\n <button (click)=\"selfie()\" mat-raised-button>Take selfie</button>\n </div>\n </mat-card>\n\n <form\n fxLayout=\"row\"\n fxLayoutAlign=\"start center\"\n class=\"px-16 py-0 w-100-p\"\n [formGroup]=\"form\"\n >\n <formly-form\n ngClass.lt-md=\"mobile\"\n fxFlex\n [form]=\"form\"\n [fields]=\"fields\"\n [model]=\"model\"\n >\n </formly-form>\n </form>\n </div>\n <div style=\"flex: 1\" class=\"pr-16 m-4\">\n <mat-card style=\"margin: 4px; padding-top: 2px\" class=\"images\">\n <h3>Images</h3>\n <ng-container *ngFor=\"let img of images\">\n <div fxLayout=\"column\">\n <ng-container *ngIf=\"img.side === 0\">\n <div class=\"title\">Front Side</div>\n </ng-container>\n <ng-container *ngIf=\"img.side === 1\">\n <div class=\"title\">Back Side</div>\n </ng-container>\n <img\n class=\"preview\"\n style=\"max-width: 460px; border-radius: 1rem\"\n [src]=\"img.data\"\n />\n </div>\n </ng-container>\n </mat-card>\n </div>\n</div>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1;overflow:hidden}.images .title{padding:8px 0;font-weight:600}.images img{margin-bottom:16px;width:100%}.wraper{padding:8px 8px 0 0;overflow:auto;flex:1;display:flex;flex-direction:row}mat-card{box-shadow:none!important}.selfieContainer{display:flex;flex-direction:row;align-items:center}.selfieContainer .selfie{width:150px}.selfieContainer .selfie .preview{width:120px;height:120px;border-radius:80px}.selfieContainer .button{box-shadow:none;border:1px solid rgba(0,0,0,.1)}\n"], dependencies: [{ kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "component", type: i5$1.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { kind: "component", type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i7.FormlyForm, selector: "formly-form", inputs: ["form", "model", "fields", "options"], outputs: ["modelChange"] }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] });
2326
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanResultsComponent, decorators: [{
28
2327
  type: Component,
29
- args: [{ selector: 'lib-ngx-scandoc', template: `
30
- <p>
31
- ngx-scandoc works!
32
- </p>
33
- ` }]
34
- }], ctorParameters: function () { return []; } });
2328
+ args: [{ selector: 'ngx-scan-results', template: "<div class=\"wraper\">\n <div style=\"flex: 1\">\n <mat-card style=\"margin: 4px; padding: 4px 16px\">\n <h3>Avatar</h3>\n <div class=\"selfieContainer\">\n <div class=\"selfie\">\n <img *ngIf=\"model?._avatar\" class=\"preview\" [src]=\"model._avatar\" />\n </div>\n <button (click)=\"selfie()\" mat-raised-button>Take selfie</button>\n </div>\n </mat-card>\n\n <form\n fxLayout=\"row\"\n fxLayoutAlign=\"start center\"\n class=\"px-16 py-0 w-100-p\"\n [formGroup]=\"form\"\n >\n <formly-form\n ngClass.lt-md=\"mobile\"\n fxFlex\n [form]=\"form\"\n [fields]=\"fields\"\n [model]=\"model\"\n >\n </formly-form>\n </form>\n </div>\n <div style=\"flex: 1\" class=\"pr-16 m-4\">\n <mat-card style=\"margin: 4px; padding-top: 2px\" class=\"images\">\n <h3>Images</h3>\n <ng-container *ngFor=\"let img of images\">\n <div fxLayout=\"column\">\n <ng-container *ngIf=\"img.side === 0\">\n <div class=\"title\">Front Side</div>\n </ng-container>\n <ng-container *ngIf=\"img.side === 1\">\n <div class=\"title\">Back Side</div>\n </ng-container>\n <img\n class=\"preview\"\n style=\"max-width: 460px; border-radius: 1rem\"\n [src]=\"img.data\"\n />\n </div>\n </ng-container>\n </mat-card>\n </div>\n</div>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1;overflow:hidden}.images .title{padding:8px 0;font-weight:600}.images img{margin-bottom:16px;width:100%}.wraper{padding:8px 8px 0 0;overflow:auto;flex:1;display:flex;flex-direction:row}mat-card{box-shadow:none!important}.selfieContainer{display:flex;flex-direction:row;align-items:center}.selfieContainer .selfie{width:150px}.selfieContainer .selfie .preview{width:120px;height:120px;border-radius:80px}.selfieContainer .button{box-shadow:none;border:1px solid rgba(0,0,0,.1)}\n"] }]
2329
+ }], ctorParameters: function () { return [{ type: NgxScandocCameraProvider }, { type: ScanFieldsProvider }]; }, propDecorators: { model: [{
2330
+ type: Input
2331
+ }], images: [{
2332
+ type: Input
2333
+ }], form: [{
2334
+ type: Input
2335
+ }], action: [{
2336
+ type: Output
2337
+ }] } });
35
2338
 
36
- class NgxScandocModule {
2339
+ class ScanComponent extends BaseComponent {
2340
+ constructor(cd, zone, translate, cameraProvider, injector, layoutProvider, auth // private api: ServerProvider
2341
+ ) {
2342
+ super();
2343
+ this.cd = cd;
2344
+ this.zone = zone;
2345
+ this.translate = translate;
2346
+ this.cameraProvider = cameraProvider;
2347
+ this.injector = injector;
2348
+ this.layoutProvider = layoutProvider;
2349
+ this.auth = auth;
2350
+ this.scanBlastData = [
2351
+ {
2352
+ title: 'pms.dialogs.components.scanProfile.front',
2353
+ description: 'pms.dialogs.components.scanProfile.frontDescription',
2354
+ side: 'FRONT',
2355
+ },
2356
+ {
2357
+ title: 'pms.dialogs.components.scanProfile.back',
2358
+ description: 'pms.dialogs.components.scanProfile.backDescription',
2359
+ disabled: true,
2360
+ side: 'BACK',
2361
+ },
2362
+ ];
2363
+ this.type = 'desktop';
2364
+ this.actions = new EventEmitter();
2365
+ this.mediaDevices = [];
2366
+ this.videoOptions = {
2367
+ width: 1920,
2368
+ height: 1080,
2369
+ facingMode: 'environment',
2370
+ };
2371
+ this.startTime = 0;
2372
+ this.isDebug = false;
2373
+ this.multipleWebcamsAvailable = false;
2374
+ this.scanInProgress = false;
2375
+ // webcam snapshot trigger
2376
+ this.documentTypeSelected = false;
2377
+ this.preview = null;
2378
+ this.errorCode = '1000';
2379
+ this.displayInfo = 'Position document inside rectange and hold steady.';
2380
+ this.allowCameraSwitch = true;
2381
+ this.verificationErrorSent = false;
2382
+ this.error = false;
2383
+ this.cameraReady = false;
2384
+ this.scaning = false;
2385
+ this.imageHandler = new Subject();
2386
+ this.logData = {
2387
+ AcceptTermsAndConditions: true,
2388
+ Request: null,
2389
+ Response: null,
2390
+ ExpectedOutput: null,
2391
+ };
2392
+ this.scanDatas = [];
2393
+ this.idScan = null;
2394
+ this.validation = false;
2395
+ this.scannedImages = [];
2396
+ this.scanDelay = 0;
2397
+ this.trigger = new Subject();
2398
+ // switch to next / previous / specific webcam; true/false: forward/backwards, string: deviceId
2399
+ this.nextWebcam = new Subject();
2400
+ this.imageVerified = false;
2401
+ this.form = new FormGroup({});
2402
+ this.isMobile = false;
2403
+ this.showDialog = false;
2404
+ this.scanImageTimestamps = {
2405
+ time: 0,
2406
+ load: 0,
2407
+ };
2408
+ this.scanProvider = this.injector.get(ScanProvider);
2409
+ }
2410
+ get class() {
2411
+ return this.isMobile;
2412
+ }
2413
+ onResize() {
2414
+ if (this.wraper) {
2415
+ this.width = this.wraper.nativeElement.clientWidth;
2416
+ this.height = this.wraper.nativeElement.clientHeight;
2417
+ setTimeout(() => {
2418
+ const video = this.wraper?.nativeElement.querySelector('video');
2419
+ if (video) {
2420
+ // console.log(video.clientWidth, video.clientHeight);
2421
+ this.videoWidth = video.clientWidth;
2422
+ this.videoHeight = video.clientHeight;
2423
+ }
2424
+ this.cd.detectChanges();
2425
+ }, 100);
2426
+ this.cd.detectChanges();
2427
+ }
2428
+ }
2429
+ test() {
2430
+ this.dialogs.turnDocument('BACK');
2431
+ }
2432
+ resetLogData() {
2433
+ this.logData = {
2434
+ Request: null,
2435
+ Response: null,
2436
+ ExpectedOutput: null,
2437
+ AcceptTermsAndConditions: true,
2438
+ };
2439
+ }
2440
+ ngOnDestroy() {
2441
+ if (this.scanTimeout) {
2442
+ clearTimeout(this.scanTimeout);
2443
+ }
2444
+ if (this.imageHandlerSubscription) {
2445
+ this.imageHandlerSubscription.unsubscribe();
2446
+ }
2447
+ console.log('DESTROXY');
2448
+ this.__destroy();
2449
+ }
2450
+ init() {
2451
+ this.auth.accesToken.subscribe();
2452
+ this.resetLogData();
2453
+ // this.result=true;
2454
+ // this.result ={};
2455
+ console.log('INIT SCAN');
2456
+ }
2457
+ cameraOff(ev) {
2458
+ this.cameraReady = false;
2459
+ this.cd.detectChanges();
2460
+ }
2461
+ continue() {
2462
+ this.documentTypeSelected = false;
2463
+ setTimeout(() => {
2464
+ this.selectedSide.image = this.webcamImage;
2465
+ if (this.selectedSide.side === 'FRONT') {
2466
+ this.scanBlastData[1].disabled = false;
2467
+ }
2468
+ this.cd.detectChanges();
2469
+ }, 200);
2470
+ }
2471
+ scan() {
2472
+ // this.triggerSnapshot();
2473
+ // this.scanDatas[0] = true;
2474
+ // if (this.scanTimeout) {
2475
+ // clearTimeout(this.scanTimeout);
2476
+ // }
2477
+ // this.scanTimeout = setTimeout(() => {
2478
+ // this.scan();
2479
+ // }, 1);
2480
+ }
2481
+ handleImage(webcamImage) {
2482
+ // console.log('[received webcam image]', webcamImage);
2483
+ this.zone.runOutsideAngular(() => {
2484
+ const time = new Date().getTime();
2485
+ if (this.scanImageTimestamps.load > 0) {
2486
+ const { load } = this.scanImageTimestamps;
2487
+ const diff = time - load;
2488
+ // console.log('time:', diff);
2489
+ this.scanDelay = diff;
2490
+ }
2491
+ this.scanImageTimestamps.load = time;
2492
+ if (webcamImage.imageData) {
2493
+ this.scannedImages.push(webcamImage);
2494
+ }
2495
+ this.cd.detectChanges();
2496
+ if (this.scannedImages.length > 4 && !this.validation) {
2497
+ console.timeEnd('scan');
2498
+ console.time('scan');
2499
+ // get last 10
2500
+ console.log('CAPTURED:', this.scannedImages.length);
2501
+ const images = this.scannedImages.slice(-5);
2502
+ // set images to 0
2503
+ this.scannedImages = [];
2504
+ const imagesArray = images.map((m) => m.imageResized.split(',')[1]);
2505
+ this.validation = true;
2506
+ this.handleBurstData(imagesArray, images);
2507
+ }
2508
+ if (this.cameraReady) {
2509
+ this.trigger.next(new Date().getTime());
2510
+ }
2511
+ });
2512
+ }
2513
+ handleBurstData(imagesArray, images, type = 'plain') {
2514
+ this.__subs(this.scanProvider.burst(imagesArray)).subscribe((resp) => {
2515
+ this.displayInfo = resp.Info;
2516
+ console.timeEnd('validationPOST');
2517
+ console.log('AnalysisTime', resp.AnalysisTime);
2518
+ const { DocType, Series, Side, InfoCode } = resp;
2519
+ // if (InfoCode === '1006' && this.idScan) {
2520
+ // this.handleLongValidationError(image);
2521
+ // }
2522
+ if (resp.Validated) {
2523
+ console.log('[SCANNED INDEX]', resp.Index);
2524
+ const selectedImage = images[resp.Index];
2525
+ // this.preview = this.webcamImage.imageAsDataUrl;
2526
+ this.cd.detectChanges();
2527
+ let image = selectedImage;
2528
+ if (type == 'worker') {
2529
+ const dataUrl = this.handleBitmapImage(selectedImage.bitmap);
2530
+ image = { dataUrl };
2531
+ }
2532
+ if (InfoCode === '1007') {
2533
+ // For ID ask for other side
2534
+ if (Side === 'FRONT') {
2535
+ this.scanBlastData[0].image = image;
2536
+ }
2537
+ else {
2538
+ this.scanBlastData[1].image = image;
2539
+ }
2540
+ if (this.scanBlastData[0].image && this.scanBlastData[1].image) {
2541
+ console.warn('UPLOAD');
2542
+ if (type == 'worker') {
2543
+ this.imageHandler.next({ type: 'stop' });
2544
+ }
2545
+ this.scanBlastFinish();
2546
+ }
2547
+ else {
2548
+ const num = Side === 'FRONT' ? 1 : 0;
2549
+ this.singleScan(this.scanBlastData[num]);
2550
+ this.scan();
2551
+ this.idScan = this.scanBlastData[num].side;
2552
+ if (!this.showDialog) {
2553
+ this.showDialog = true;
2554
+ this.zone.run(() => {
2555
+ this.dialogs.turnDocument(this.idScan).subscribe(() => {
2556
+ this.showDialog = false;
2557
+ });
2558
+ });
2559
+ // this.actions.emit({
2560
+ // type: 'turnDocumentOver',
2561
+ // side: this.idScan,
2562
+ // });
2563
+ }
2564
+ console.log('ID SIDE', this.idScan);
2565
+ this.displayInfo = 'Please turn the document over!';
2566
+ this.validation = false;
2567
+ }
2568
+ }
2569
+ else {
2570
+ this.scanBlastData[0].image = image;
2571
+ console.warn('UPLOAD');
2572
+ if (type == 'worker') {
2573
+ this.imageHandler.next({ type: 'stop' });
2574
+ }
2575
+ this.scanBlastFinish();
2576
+ }
2577
+ this.scannedImages = [];
2578
+ // this.scanBlastData[0].image = selectedImage;
2579
+ //this.scanBlastFinish();
2580
+ }
2581
+ else {
2582
+ this.validation = false;
2583
+ }
2584
+ });
2585
+ }
2586
+ handleInitError(error) {
2587
+ console.log(error);
2588
+ }
2589
+ get scanBlastCanUpload() {
2590
+ return this.scanBlastData[0].image ? true : false;
2591
+ }
2592
+ cameraWasSwitched(deviceId) {
2593
+ console.log('[active device]', deviceId);
2594
+ this.deviceId = deviceId;
2595
+ this.cameraReady = true;
2596
+ this.defaultDevice = deviceId;
2597
+ setTimeout(() => {
2598
+ this.onResize();
2599
+ this.scan();
2600
+ }, 300);
2601
+ }
2602
+ get nextWebcamObservable() {
2603
+ return this.nextWebcam.asObservable();
2604
+ }
2605
+ handleLongValidationError(img) {
2606
+ // save current image after 10sec
2607
+ const diff = (Date.now() - this.startTime) / 1000;
2608
+ if (diff > 15 && !this.verificationErrorSent) {
2609
+ this.verificationErrorSent = true;
2610
+ const dataUrl = this.handleBitmapImage(img.bitmap);
2611
+ console.warn('SENT');
2612
+ this.displayInfo = 'Cant detect document!';
2613
+ this.logData.Request = this.__subs(this.scanProvider.sendLog({
2614
+ AcceptTermsAndConditions: true,
2615
+ ExpectedOutput: {},
2616
+ Request: {
2617
+ verification: dataUrl.split(',')[1],
2618
+ },
2619
+ Response: {
2620
+ TransactionID: v4(),
2621
+ },
2622
+ })).subscribe();
2623
+ }
2624
+ }
2625
+ ngAfterViewInit() {
2626
+ this.cd.detectChanges();
2627
+ this.autoScan();
2628
+ this.__subs(this.layoutProvider.breakpoint$).subscribe((v) => {
2629
+ this.isMobile = !v.matches;
2630
+ console.log('MNOBILE', this.isMobile);
2631
+ });
2632
+ this.imageHandlerSubscription = this.imageHandler.subscribe((webcamImage) => {
2633
+ // return;
2634
+ if (this.startTime === 0) {
2635
+ this.startTime = Date.now();
2636
+ }
2637
+ this.zone.runOutsideAngular(() => {
2638
+ if (webcamImage.base64) {
2639
+ const time = new Date().getTime();
2640
+ if (this.scanImageTimestamps.load > 0) {
2641
+ const { load } = this.scanImageTimestamps;
2642
+ const diff = time - load;
2643
+ // console.warn('TIME', diff);
2644
+ this.scanDelay = diff;
2645
+ }
2646
+ this.scanImageTimestamps.load = time;
2647
+ this.scannedImages.push(webcamImage);
2648
+ this.handleLongValidationError(webcamImage);
2649
+ }
2650
+ // this.cd.detectChanges();
2651
+ if (this.scannedImages.length > 4 && !this.validation) {
2652
+ // get last 10
2653
+ console.timeEnd('validationTOTAL_UI');
2654
+ console.time('validationTOTAL_UI');
2655
+ const images = this.scannedImages.slice(-5);
2656
+ // set images to 0
2657
+ this.scannedImages = [];
2658
+ console.log(images);
2659
+ const imagesArray = images.map((m) => m.base64.split(',')[1]);
2660
+ this.validation = true;
2661
+ this.handleBurstData(imagesArray, images, 'worker');
2662
+ console.time('validationPOST');
2663
+ }
2664
+ this.cd.detectChanges();
2665
+ });
2666
+ });
2667
+ }
2668
+ handleBitmapImage(bitmap) {
2669
+ const { width, height } = bitmap;
2670
+ const offscreenSmall = document.createElement('canvas');
2671
+ offscreenSmall.width = width;
2672
+ offscreenSmall.height = height;
2673
+ const ctx = offscreenSmall.getContext('bitmaprenderer');
2674
+ if (ctx) {
2675
+ ctx.imageSmoothingEnabled = false;
2676
+ ctx.transferFromImageBitmap(bitmap);
2677
+ bitmap.close();
2678
+ const data = ctx.canvas.toDataURL('image/jpeg');
2679
+ return data;
2680
+ }
2681
+ return null;
2682
+ }
2683
+ autoScan() {
2684
+ const side = this.scanBlastData[0];
2685
+ this.idScan = null;
2686
+ this.singleScan(side);
2687
+ }
2688
+ singleScan(side) {
2689
+ this.scanType = side.side;
2690
+ this.preview = null;
2691
+ this.selectedSide = side;
2692
+ this.selectedSide.image = null;
2693
+ this.documentTypeSelected = true;
2694
+ this.scanBlastData[1].disabled = false;
2695
+ this.cd.detectChanges();
2696
+ setTimeout(() => {
2697
+ this.onResize();
2698
+ }, 10);
2699
+ }
2700
+ getImgBase64(num) {
2701
+ console.log('GET 64');
2702
+ return this.scanBlastData[num].image.dataUrl.split(',')[1];
2703
+ }
2704
+ scanBlastFinish() {
2705
+ console.time('upload');
2706
+ if (this.type === 'mobile') {
2707
+ this.actions.emit({ data: this.scanBlastData });
2708
+ this.retake();
2709
+ return;
2710
+ }
2711
+ this.idScan = null;
2712
+ // const loading = this.dialogs.loading();
2713
+ this.scaning = true;
2714
+ this.cd.detectChanges();
2715
+ console.time('payload');
2716
+ const payload = {
2717
+ AcceptTermsAndConditions: true,
2718
+ DataFields: {
2719
+ FrontImageType: 'base64',
2720
+ FrontImageCropped: false,
2721
+ BackImageType: 'base64',
2722
+ BackImageCropped: false,
2723
+ FrontImage: this.getImgBase64(0),
2724
+ BackImage: this.scanBlastData[1].image ? this.getImgBase64(1) : null,
2725
+ },
2726
+ Settings: {
2727
+ ShouldValidate: true,
2728
+ ShouldReturnDocumentImage: true,
2729
+ ShouldReturnFaceIfDetected: true,
2730
+ SkipImageSizeCheck: true,
2731
+ CanStoreImages: this.scanProvider.canStoreImages,
2732
+ },
2733
+ // CallBackUrl: 'http://demo:5000/report/extracted/',
2734
+ };
2735
+ if (!this.scanBlastData[1].image) {
2736
+ payload.Settings.IgnoreBackImage = true;
2737
+ }
2738
+ this.logData.Request = JSON.parse(JSON.stringify(payload));
2739
+ console.timeEnd('payload');
2740
+ this.__subs(this.scanProvider.blastPost(payload)).subscribe((data) => {
2741
+ //console.log(data);
2742
+ const results = data.Data;
2743
+ console.timeEnd('upload');
2744
+ console.time('parse');
2745
+ // data.InfoCode = '1001';
2746
+ this.logData.Response = JSON.parse(JSON.stringify(data));
2747
+ //loading.close();
2748
+ this.documentTypeSelected = true;
2749
+ this.scaning = false;
2750
+ if (data.InfoCode === '1001') {
2751
+ this.error = true;
2752
+ console.log('[ERROR] 1001');
2753
+ this.errorCode = '1001';
2754
+ // this.scanSide = 0;
2755
+ this.preview = true;
2756
+ this.cd.detectChanges();
2757
+ return;
2758
+ }
2759
+ if (data.InfoCode === '1002') {
2760
+ this.error = true;
2761
+ console.log('[ERROR] 1002');
2762
+ this.errorCode = '1002';
2763
+ // this.scanSide = 0;
2764
+ this.preview = true;
2765
+ this.cd.detectChanges();
2766
+ return;
2767
+ }
2768
+ if (results && data.Metadata.length > 0 && data.InfoCode === '1000') {
2769
+ console.log('Extraction time', data.AnalysisTime);
2770
+ this.zone.run(() => {
2771
+ if (data.ImageData?.Documents) {
2772
+ const { Documents } = data.ImageData;
2773
+ this.images = Documents.map((image, i) => {
2774
+ return { data: 'data:image/jpeg;base64,' + Documents[i] };
2775
+ });
2776
+ }
2777
+ this.result = this.scanProvider.parseBlast(results);
2778
+ console.log('RES', this.result);
2779
+ this.cd.detectChanges();
2780
+ this.model = this.result.model;
2781
+ if (data.ImageData?.FaceImage) {
2782
+ this.model._avatar =
2783
+ 'data:image/jpeg;base64,' + data.ImageData?.FaceImage;
2784
+ }
2785
+ console.log('MODEL', this.model);
2786
+ this.cd.detectChanges();
2787
+ });
2788
+ }
2789
+ else {
2790
+ console.log('ERROR');
2791
+ // this.scanSide = 0;
2792
+ this.error = true;
2793
+ this.preview = true;
2794
+ this.cd.detectChanges();
2795
+ // this.documentTypeSelected = false;
2796
+ // this.retry();
2797
+ }
2798
+ this.cd.detectChanges();
2799
+ console.timeEnd('parse');
2800
+ }, (err) => {
2801
+ // loading.close();
2802
+ // this.scanSide = 0;
2803
+ this.error = true;
2804
+ this.preview = true;
2805
+ this.documentTypeSelected = true;
2806
+ this.scaning = false;
2807
+ });
2808
+ }
2809
+ retry() {
2810
+ this.preview = false;
2811
+ this.validation = false;
2812
+ this.errorCode = '1000';
2813
+ this.result = false;
2814
+ if (this.error) {
2815
+ this.documentTypeSelected = false;
2816
+ this.scanBlastData.forEach((element) => {
2817
+ element.image = null;
2818
+ });
2819
+ }
2820
+ this.error = false;
2821
+ this.autoScan();
2822
+ this.cd.detectChanges();
2823
+ }
2824
+ triggerSnapshot() {
2825
+ this.trigger.next(0);
2826
+ }
2827
+ retake() {
2828
+ this.validation = false;
2829
+ this.preview = false;
2830
+ this.error = false;
2831
+ this.result = false;
2832
+ this.scanSide = 0;
2833
+ this.imageVerified = false;
2834
+ this.scanDatas = [];
2835
+ this.scaning = false;
2836
+ this.images = [];
2837
+ this.scanInProgress = false;
2838
+ this.documentTypeSelected = false;
2839
+ this.scanBlastData.forEach((m) => {
2840
+ m.image = null;
2841
+ });
2842
+ this.autoScan();
2843
+ this.cd.detectChanges();
2844
+ }
2845
+ use() {
2846
+ // save images??
2847
+ if (this.scanProvider.canStoreImages) {
2848
+ this.logData.ExpectedOutput = JSON.parse(JSON.stringify(this.model));
2849
+ if (this.logData.ExpectedOutput?._avatar) {
2850
+ delete this.logData.ExpectedOutput._avatar;
2851
+ }
2852
+ this.__subs(this.scanProvider.sendLog(this.logData)).subscribe();
2853
+ console.log(this.logData);
2854
+ }
2855
+ this.dialogRef?.close({
2856
+ model: this.model,
2857
+ images: this.images,
2858
+ });
2859
+ }
2860
+ selfie() {
2861
+ this.dialogs
2862
+ .scanSelfie({ avatar: this.model._avatar })
2863
+ .afterClosed()
2864
+ .subscribe((resp) => {
2865
+ if (resp) {
2866
+ console.log(resp);
2867
+ if (this.scanProvider.enableVerification) {
2868
+ this.imageVerified = true;
2869
+ }
2870
+ this.model._avatar = resp.imageAsDataUrl;
2871
+ this.cd.detectChanges();
2872
+ }
2873
+ });
2874
+ }
2875
+ videoReady(event) {
2876
+ this.cameraReady = event;
2877
+ if (this.cameraReady && !this.scanInProgress) {
2878
+ this.scanInProgress = true;
2879
+ setTimeout(() => {
2880
+ this.trigger.next(new Date().getTime());
2881
+ }, 1000);
2882
+ }
2883
+ }
37
2884
  }
38
- NgxScandocModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
39
- NgxScandocModulemod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocModule, declarations: [NgxScandocComponent], exports: [NgxScandocComponent] });
40
- NgxScandocModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocModule });
41
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocModule, decorators: [{
2885
+ ScanComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i1$2.TranslateService }, { token: NgxScandocCameraProvider }, { token: i0.Injector }, { token: LayoutProvider }, { token: AuthProvider }], target: i0.ɵɵFactoryTarget.Component });
2886
+ ScanComponentcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ScanComponent, selector: "ngx-scan", inputs: { type: "type", dialogs: "dialogs", showDialog: "showDialog" }, outputs: { actions: "actions" }, host: { listeners: { "window:resize": "onResize($event)" }, properties: { "class.mobile": "this.class" } }, viewQueries: [{ propertyName: "wraper", first: true, predicate: ["wraper"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<section *ngIf=\"result\">\n <ngx-scan-results\n (action)=\"selfie()\"\n [form]=\"form\"\n [model]=\"model\"\n [images]=\"images\"\n ></ngx-scan-results>\n\n <footer>\n <div class=\"actions\">\n <button fxFlex class=\"mr-4\" mat-raised-button (click)=\"retake()\">\n {{ \"pms.dialogs.components.scanProfile.reTake\" | translate }}\n </button>\n <button\n [disabled]=\"error || form.invalid\"\n fxFlex\n class=\"ml-4\"\n mat-raised-button\n (click)=\"use()\"\n >\n {{ \"pms.dialogs.components.scanProfile.useData\" | translate }}\n </button>\n </div>\n </footer>\n</section>\n\n<section *ngIf=\"!result && documentTypeSelected\">\n <div #wraper class=\"wraper\">\n <div class=\"loading\" *ngIf=\"!cameraReady && !preview\">\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n </div>\n\n <ng-container *ngIf=\"!error\">\n <app-webcam\n *ngIf=\"!preview && !scaning\"\n class=\"main\"\n [imageQuality]=\"1\"\n #webcam\n fxFlex\n type=\"document\"\n [trigger]=\"trigger\"\n [imageHandler]=\"imageHandler\"\n (imageCapture)=\"handleImage($event)\"\n [allowCameraSwitch]=\"allowCameraSwitch\"\n [videoOptions]=\"videoOptions\"\n [switchCamera]=\"cameraProvider.nextWebcamObservable\"\n (cameraSwitched)=\"cameraWasSwitched($event)\"\n (initError)=\"handleInitError($event)\"\n [width]=\"width\"\n [height]=\"height\"\n (destroyed)=\"cameraOff($event)\"\n (videoReady)=\"videoReady($event)\"\n >\n </app-webcam>\n </ng-container>\n <div\n fxLayout=\"row\"\n fxFlex\n class=\"previewData\"\n *ngIf=\"preview\"\n style=\"z-index: 20; position: absolute; width: 100%; height: 100%\"\n >\n <div class=\"p-16 error\" *ngIf=\"error\">\n <div>\n <div class=\"title\" fxLayout=\"row\" fxLayoutAlign=\"start center\">\n <mat-icon>error_outline</mat-icon\n ><span class=\"ml-8\">{{\n \"pms.dialogs.components.scanProfile.unableToDetectId\" | translate\n }}</span>\n </div>\n\n <ng-container *ngIf=\"errorCode === '1001'\">\n <div>\n Could not classify the given object as a supported document.\n </div>\n </ng-container>\n <ng-container *ngIf=\"errorCode === '1002'\">\n <div>\n Something is wrong with extraction data. Please try again.\n </div>\n </ng-container>\n\n <ul *ngIf=\"errorCode === '1000'\">\n <li>\n {{\n \"pms.dialogs.components.scanProfile.placeIdCloseToDevice\"\n | translate\n }}\n </li>\n <li>\n {{\n \"pms.dialogs.components.scanProfile.ensureSufficientLight\"\n | translate\n }}\n </li>\n <li>\n {{\n \"pms.dialogs.components.scanProfile.holdDocumentSteady\"\n | translate\n }}\n </li>\n <li>\n {{\n \"pms.dialogs.components.scanProfile.makeSureAllEdgesOfTheIdAreVisible\"\n | translate\n }}\n </li>\n <li>\n {{\n \"pms.dialogs.components.scanProfile.makeSureThereAreNoGlareAndShadowsOnTheId\"\n | translate\n }}\n </li>\n </ul>\n </div>\n </div>\n\n <div\n class=\"scanPreview\"\n fxFlex\n fxLayout=\"column\"\n *ngIf=\"!error && !scaning\"\n >\n <!-- <div class=\"py-16\" style=\"font-size: 16px\">\n {{\n \"pms.dialogs.components.scanProfile.ensureAllTextsAreVisible\"\n | translate\n }}\n </div> -->\n <div\n fxFlex\n class=\"image\"\n [style.background-image]=\"'url(' + preview + ')'\"\n ></div>\n </div>\n </div>\n </div>\n\n <footer>\n <div\n class=\"displayInfo\"\n ngClass.lt-sm=\"mobile\"\n *ngIf=\"!preview && cameraReady\"\n >\n {{ displayInfo }}\n </div>\n <!-- <div style=\"height: 26px\">\n <div\n style=\"text-align: center; font-size: 18px\"\n *ngIf=\"idScan && !preview && cameraReady\"\n >\n <ng-container *ngIf=\"idScan === 'BACK'\">\n Turn document and:\n {{ \"pms.dialogs.components.scanProfile.captureBack\" | translate }}\n </ng-container>\n <ng-container *ngIf=\"idScan === 'FRONT'\">\n Turn document and:\n {{ \"pms.dialogs.components.scanProfile.captureFront\" | translate }}\n </ng-container>\n </div>\n </div> -->\n\n <div class=\"actions\" *ngIf=\"preview\">\n <button fxFlex class=\"mr-4\" mat-raised-button (click)=\"retry()\">\n {{ \"pms.dialogs.components.scanProfile.retry\" | translate }}\n </button>\n\n <button\n [disabled]=\"error\"\n fxFlex\n class=\"ml-4\"\n mat-raised-button\n (click)=\"continue()\"\n >\n {{\n \"pms.dialogs.components.scanProfile.continueWithSelectedImage\"\n | translate\n }}\n </button>\n </div>\n </footer>\n</section>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1;background-color:#f5f5f5;overflow:hidden}section{flex:1;display:flex;flex-direction:column;position:relative;overflow:hidden}.wraper{position:relative;overflow:hidden;display:flex;flex-direction:column;flex:1}.wraper .loading{position:absolute;inset:0;z-index:20;background-color:#f5f5f5}.documentTurnOver{position:absolute;width:100%;height:100%;top:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center}.documentTurnOver mat-icon{width:200px;color:#fff;height:200px;font-size:100px}.displayInfo{text-align:center;flex:1;width:100%;background-color:#000;height:50px;line-height:50px;color:#fff;z-index:200}.displayInfo.mobile{font-size:12px}.preview{width:100%;border-radius:1%}footer button{box-shadow:none!important;height:45px;min-height:45px;text-transform:uppercase}footer .actions{display:flex;flex-direction:row;align-items:center;padding:8px}footer .actions button{flex:1}.error{display:flex;align-items:center;justify-content:center;flex:1}.error .title{font-size:20px;margin-bottom:8px}.error .title mat-icon{margin-right:8px}.error ul{font-size:18px;list-style-type:none}mat-card{box-shadow:none!important}.mr-4{margin-right:4px}.ml-4{margin-left:4px}.p-16{padding:16px}.p-8{padding:8px}.py-16{padding:16px 0}.w-100-p{width:100%}.scanPreview{padding:16px}.scanPreview .image{background-position:center;background-repeat:no-repeat;background-size:contain}.empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center}\n"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: WebcamComponent, selector: "app-webcam", inputs: ["imageHandler", "id", "type", "width", "height", "videoOptions", "allowCameraSwitch", "mirrorImage", "captureImageData", "imageType", "imageQuality", "trigger", "switchCamera"], outputs: ["imageCapture", "initError", "imageClick", "cameraSwitched", "videoReady", "destroyed"] }, { kind: "component", type: i7$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i9.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: ScanResultsComponent, selector: "ngx-scan-results", inputs: ["model", "images", "form"], outputs: ["action"] }, { kind: "pipe", type: i1$2.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2887
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanComponent, decorators: [{
2888
+ type: Component,
2889
+ args: [{ selector: 'ngx-scan', changeDetection: ChangeDetectionStrategy.OnPush, template: "<section *ngIf=\"result\">\n <ngx-scan-results\n (action)=\"selfie()\"\n [form]=\"form\"\n [model]=\"model\"\n [images]=\"images\"\n ></ngx-scan-results>\n\n <footer>\n <div class=\"actions\">\n <button fxFlex class=\"mr-4\" mat-raised-button (click)=\"retake()\">\n {{ \"pms.dialogs.components.scanProfile.reTake\" | translate }}\n </button>\n <button\n [disabled]=\"error || form.invalid\"\n fxFlex\n class=\"ml-4\"\n mat-raised-button\n (click)=\"use()\"\n >\n {{ \"pms.dialogs.components.scanProfile.useData\" | translate }}\n </button>\n </div>\n </footer>\n</section>\n\n<section *ngIf=\"!result && documentTypeSelected\">\n <div #wraper class=\"wraper\">\n <div class=\"loading\" *ngIf=\"!cameraReady && !preview\">\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n </div>\n\n <ng-container *ngIf=\"!error\">\n <app-webcam\n *ngIf=\"!preview && !scaning\"\n class=\"main\"\n [imageQuality]=\"1\"\n #webcam\n fxFlex\n type=\"document\"\n [trigger]=\"trigger\"\n [imageHandler]=\"imageHandler\"\n (imageCapture)=\"handleImage($event)\"\n [allowCameraSwitch]=\"allowCameraSwitch\"\n [videoOptions]=\"videoOptions\"\n [switchCamera]=\"cameraProvider.nextWebcamObservable\"\n (cameraSwitched)=\"cameraWasSwitched($event)\"\n (initError)=\"handleInitError($event)\"\n [width]=\"width\"\n [height]=\"height\"\n (destroyed)=\"cameraOff($event)\"\n (videoReady)=\"videoReady($event)\"\n >\n </app-webcam>\n </ng-container>\n <div\n fxLayout=\"row\"\n fxFlex\n class=\"previewData\"\n *ngIf=\"preview\"\n style=\"z-index: 20; position: absolute; width: 100%; height: 100%\"\n >\n <div class=\"p-16 error\" *ngIf=\"error\">\n <div>\n <div class=\"title\" fxLayout=\"row\" fxLayoutAlign=\"start center\">\n <mat-icon>error_outline</mat-icon\n ><span class=\"ml-8\">{{\n \"pms.dialogs.components.scanProfile.unableToDetectId\" | translate\n }}</span>\n </div>\n\n <ng-container *ngIf=\"errorCode === '1001'\">\n <div>\n Could not classify the given object as a supported document.\n </div>\n </ng-container>\n <ng-container *ngIf=\"errorCode === '1002'\">\n <div>\n Something is wrong with extraction data. Please try again.\n </div>\n </ng-container>\n\n <ul *ngIf=\"errorCode === '1000'\">\n <li>\n {{\n \"pms.dialogs.components.scanProfile.placeIdCloseToDevice\"\n | translate\n }}\n </li>\n <li>\n {{\n \"pms.dialogs.components.scanProfile.ensureSufficientLight\"\n | translate\n }}\n </li>\n <li>\n {{\n \"pms.dialogs.components.scanProfile.holdDocumentSteady\"\n | translate\n }}\n </li>\n <li>\n {{\n \"pms.dialogs.components.scanProfile.makeSureAllEdgesOfTheIdAreVisible\"\n | translate\n }}\n </li>\n <li>\n {{\n \"pms.dialogs.components.scanProfile.makeSureThereAreNoGlareAndShadowsOnTheId\"\n | translate\n }}\n </li>\n </ul>\n </div>\n </div>\n\n <div\n class=\"scanPreview\"\n fxFlex\n fxLayout=\"column\"\n *ngIf=\"!error && !scaning\"\n >\n <!-- <div class=\"py-16\" style=\"font-size: 16px\">\n {{\n \"pms.dialogs.components.scanProfile.ensureAllTextsAreVisible\"\n | translate\n }}\n </div> -->\n <div\n fxFlex\n class=\"image\"\n [style.background-image]=\"'url(' + preview + ')'\"\n ></div>\n </div>\n </div>\n </div>\n\n <footer>\n <div\n class=\"displayInfo\"\n ngClass.lt-sm=\"mobile\"\n *ngIf=\"!preview && cameraReady\"\n >\n {{ displayInfo }}\n </div>\n <!-- <div style=\"height: 26px\">\n <div\n style=\"text-align: center; font-size: 18px\"\n *ngIf=\"idScan && !preview && cameraReady\"\n >\n <ng-container *ngIf=\"idScan === 'BACK'\">\n Turn document and:\n {{ \"pms.dialogs.components.scanProfile.captureBack\" | translate }}\n </ng-container>\n <ng-container *ngIf=\"idScan === 'FRONT'\">\n Turn document and:\n {{ \"pms.dialogs.components.scanProfile.captureFront\" | translate }}\n </ng-container>\n </div>\n </div> -->\n\n <div class=\"actions\" *ngIf=\"preview\">\n <button fxFlex class=\"mr-4\" mat-raised-button (click)=\"retry()\">\n {{ \"pms.dialogs.components.scanProfile.retry\" | translate }}\n </button>\n\n <button\n [disabled]=\"error\"\n fxFlex\n class=\"ml-4\"\n mat-raised-button\n (click)=\"continue()\"\n >\n {{\n \"pms.dialogs.components.scanProfile.continueWithSelectedImage\"\n | translate\n }}\n </button>\n </div>\n </footer>\n</section>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1;background-color:#f5f5f5;overflow:hidden}section{flex:1;display:flex;flex-direction:column;position:relative;overflow:hidden}.wraper{position:relative;overflow:hidden;display:flex;flex-direction:column;flex:1}.wraper .loading{position:absolute;inset:0;z-index:20;background-color:#f5f5f5}.documentTurnOver{position:absolute;width:100%;height:100%;top:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center}.documentTurnOver mat-icon{width:200px;color:#fff;height:200px;font-size:100px}.displayInfo{text-align:center;flex:1;width:100%;background-color:#000;height:50px;line-height:50px;color:#fff;z-index:200}.displayInfo.mobile{font-size:12px}.preview{width:100%;border-radius:1%}footer button{box-shadow:none!important;height:45px;min-height:45px;text-transform:uppercase}footer .actions{display:flex;flex-direction:row;align-items:center;padding:8px}footer .actions button{flex:1}.error{display:flex;align-items:center;justify-content:center;flex:1}.error .title{font-size:20px;margin-bottom:8px}.error .title mat-icon{margin-right:8px}.error ul{font-size:18px;list-style-type:none}mat-card{box-shadow:none!important}.mr-4{margin-right:4px}.ml-4{margin-left:4px}.p-16{padding:16px}.p-8{padding:8px}.py-16{padding:16px 0}.w-100-p{width:100%}.scanPreview{padding:16px}.scanPreview .image{background-position:center;background-repeat:no-repeat;background-size:contain}.empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center}\n"] }]
2890
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i1$2.TranslateService }, { type: NgxScandocCameraProvider }, { type: i0.Injector }, { type: LayoutProvider }, { type: AuthProvider }]; }, propDecorators: { type: [{
2891
+ type: Input
2892
+ }], dialogs: [{
2893
+ type: Input
2894
+ }], actions: [{
2895
+ type: Output
2896
+ }], showDialog: [{
2897
+ type: Input
2898
+ }], wraper: [{
2899
+ type: ViewChild,
2900
+ args: ['wraper']
2901
+ }], class: [{
2902
+ type: HostBinding,
2903
+ args: ['class.mobile']
2904
+ }], onResize: [{
2905
+ type: HostListener,
2906
+ args: ['window:resize', ['$event']]
2907
+ }] } });
2908
+
2909
+ class MaterialModule {
2910
+ }
2911
+ MaterialModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MaterialModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2912
+ MaterialModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: MaterialModule, imports: [MatNativeDateModule,
2913
+ MatDatepickerModule,
2914
+ MatCardModule,
2915
+ MatMenuModule,
2916
+ MatIconModule,
2917
+ MatButtonModule,
2918
+ MatDialogModule,
2919
+ MatInputModule,
2920
+ MatSnackBarModule,
2921
+ MatProgressBarModule,
2922
+ MatTableModule,
2923
+ MatProgressSpinnerModule,
2924
+ MatPaginatorModule,
2925
+ MatSelectModule,
2926
+ MatCheckboxModule,
2927
+ MatChipsModule,
2928
+ MatBadgeModule,
2929
+ MatListModule,
2930
+ MatTabsModule,
2931
+ MatSliderModule,
2932
+ MatSlideToggleModule], exports: [MatNativeDateModule,
2933
+ MatDatepickerModule,
2934
+ MatSelectModule,
2935
+ MatCardModule,
2936
+ MatMenuModule,
2937
+ MatIconModule,
2938
+ MatButtonModule,
2939
+ MatDialogModule,
2940
+ MatInputModule,
2941
+ MatSnackBarModule,
2942
+ MatProgressBarModule,
2943
+ MatProgressSpinnerModule,
2944
+ MatTableModule,
2945
+ MatPaginatorModule,
2946
+ MatChipsModule,
2947
+ MatBadgeModule,
2948
+ MatCheckboxModule,
2949
+ MatListModule,
2950
+ MatTabsModule,
2951
+ MatSlideToggleModule,
2952
+ MatAutocompleteModule] });
2953
+ MaterialModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MaterialModule, imports: [MatNativeDateModule,
2954
+ MatDatepickerModule,
2955
+ MatCardModule,
2956
+ MatMenuModule,
2957
+ MatIconModule,
2958
+ MatButtonModule,
2959
+ MatDialogModule,
2960
+ MatInputModule,
2961
+ MatSnackBarModule,
2962
+ MatProgressBarModule,
2963
+ MatTableModule,
2964
+ MatProgressSpinnerModule,
2965
+ MatPaginatorModule,
2966
+ MatSelectModule,
2967
+ MatCheckboxModule,
2968
+ MatChipsModule,
2969
+ MatBadgeModule,
2970
+ MatListModule,
2971
+ MatTabsModule,
2972
+ MatSliderModule,
2973
+ MatSlideToggleModule, MatNativeDateModule,
2974
+ MatDatepickerModule,
2975
+ MatSelectModule,
2976
+ MatCardModule,
2977
+ MatMenuModule,
2978
+ MatIconModule,
2979
+ MatButtonModule,
2980
+ MatDialogModule,
2981
+ MatInputModule,
2982
+ MatSnackBarModule,
2983
+ MatProgressBarModule,
2984
+ MatProgressSpinnerModule,
2985
+ MatTableModule,
2986
+ MatPaginatorModule,
2987
+ MatChipsModule,
2988
+ MatBadgeModule,
2989
+ MatCheckboxModule,
2990
+ MatListModule,
2991
+ MatTabsModule,
2992
+ MatSlideToggleModule,
2993
+ MatAutocompleteModule] });
2994
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MaterialModule, decorators: [{
2995
+ type: NgModule,
2996
+ args: [{
2997
+ imports: [
2998
+ MatNativeDateModule,
2999
+ MatDatepickerModule,
3000
+ MatCardModule,
3001
+ MatMenuModule,
3002
+ MatIconModule,
3003
+ MatButtonModule,
3004
+ MatDialogModule,
3005
+ MatInputModule,
3006
+ MatSnackBarModule,
3007
+ MatProgressBarModule,
3008
+ MatTableModule,
3009
+ MatProgressSpinnerModule,
3010
+ MatPaginatorModule,
3011
+ MatSelectModule,
3012
+ MatCheckboxModule,
3013
+ MatChipsModule,
3014
+ MatBadgeModule,
3015
+ MatListModule,
3016
+ MatTabsModule,
3017
+ MatSliderModule,
3018
+ MatSlideToggleModule,
3019
+ ],
3020
+ exports: [
3021
+ MatNativeDateModule,
3022
+ MatDatepickerModule,
3023
+ MatSelectModule,
3024
+ MatCardModule,
3025
+ MatMenuModule,
3026
+ MatIconModule,
3027
+ MatButtonModule,
3028
+ MatDialogModule,
3029
+ MatInputModule,
3030
+ MatSnackBarModule,
3031
+ MatProgressBarModule,
3032
+ MatProgressSpinnerModule,
3033
+ MatTableModule,
3034
+ MatPaginatorModule,
3035
+ MatChipsModule,
3036
+ MatBadgeModule,
3037
+ MatCheckboxModule,
3038
+ MatListModule,
3039
+ MatTabsModule,
3040
+ MatSlideToggleModule,
3041
+ MatAutocompleteModule,
3042
+ ],
3043
+ providers: [],
3044
+ }]
3045
+ }] });
3046
+
3047
+ class AvatarTypeComponent extends FieldType {
3048
+ constructor(cd) {
3049
+ super();
3050
+ this.cd = cd;
3051
+ this.width = 'w-120';
3052
+ this.padding = 'px-32 pt-8 pb-8';
3053
+ }
3054
+ ngOnChange() { }
3055
+ ngAfterViewInit() {
3056
+ if (this.to.width) {
3057
+ this.width = this.to.width;
3058
+ }
3059
+ if (this.to.padding) {
3060
+ this.padding = this.to.padding;
3061
+ }
3062
+ this.cd.detectChanges();
3063
+ }
3064
+ }
3065
+ AvatarTypeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AvatarTypeComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3066
+ AvatarTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: AvatarTypeComponent, selector: "app-formly-avatar-type", usesInheritance: true, ngImport: i0, template: `
3067
+ <mat-card
3068
+ [ngClass]="padding"
3069
+ fxLayout="column"
3070
+ fxLayoutAlign="center center"
3071
+ >
3072
+ <ngx-avatars
3073
+ [name]="model[key.toString()]"
3074
+ [ngClass]="width"
3075
+ ></ngx-avatars>
3076
+ </mat-card>
3077
+ `, isInline: true, styles: ["mat-card{border-radius:0;box-shadow:none!important}\n"], dependencies: [{ kind: "directive", type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: i5$1.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { kind: "component", type: i3.AvatarComponent, selector: "ngx-avatars", inputs: ["round", "size", "textSizeRatio", "bgColor", "fgColor", "borderColor", "style", "cornerRadius", "facebookId", "twitterId", "googleId", "instagramId", "vkontakteId", "skypeId", "gravatarId", "githubId", "src", "name", "value", "referrerpolicy", "placeholder", "initialsSize"], outputs: ["clickOnAvatar"] }] });
3078
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AvatarTypeComponent, decorators: [{
3079
+ type: Component,
3080
+ args: [{ selector: 'app-formly-avatar-type', template: `
3081
+ <mat-card
3082
+ [ngClass]="padding"
3083
+ fxLayout="column"
3084
+ fxLayoutAlign="center center"
3085
+ >
3086
+ <ngx-avatars
3087
+ [name]="model[key.toString()]"
3088
+ [ngClass]="width"
3089
+ ></ngx-avatars>
3090
+ </mat-card>
3091
+ `, styles: ["mat-card{border-radius:0;box-shadow:none!important}\n"] }]
3092
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
3093
+
3094
+ class TitleTypeComponent extends FieldType {
3095
+ constructor(cd) {
3096
+ super();
3097
+ this.cd = cd;
3098
+ }
3099
+ ngOnInit() {
3100
+ this.opt = {
3101
+ badge: this.to.badge,
3102
+ };
3103
+ }
3104
+ ngAfterViewInit() {
3105
+ this.cd.detectChanges();
3106
+ }
3107
+ }
3108
+ TitleTypeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TitleTypeComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3109
+ TitleTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TitleTypeComponent, selector: "app-formly-title-type", usesInheritance: true, ngImport: i0, template: `
3110
+ <div fxLayout="row" fxLayoutAlign="start center">
3111
+ <h3>
3112
+ <span>{{ to.label }}</span>
3113
+
3114
+ <span
3115
+ *ngIf="opt.badge && model[opt.badge] && model[opt.badge].length > 1"
3116
+ matBadgeSize="small"
3117
+ matBadgeColor="primary"
3118
+ matBadgeOverlap="false"
3119
+ ></span>
3120
+ </h3>
3121
+ <span fxFlex></span>
3122
+ <div *ngIf="to.chip" class="chip">
3123
+ {{ to.chip | translate }}
3124
+ </div>
3125
+ </div>
3126
+ `, isInline: true, styles: [".chip{background:whitesmoke;border-radius:6px;padding:4px 8px;font-size:12px;color:#888;font-weight:600}\n"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1$2.TranslatePipe, name: "translate" }] });
3127
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TitleTypeComponent, decorators: [{
3128
+ type: Component,
3129
+ args: [{ selector: 'app-formly-title-type', template: `
3130
+ <div fxLayout="row" fxLayoutAlign="start center">
3131
+ <h3>
3132
+ <span>{{ to.label }}</span>
3133
+
3134
+ <span
3135
+ *ngIf="opt.badge && model[opt.badge] && model[opt.badge].length > 1"
3136
+ matBadgeSize="small"
3137
+ matBadgeColor="primary"
3138
+ matBadgeOverlap="false"
3139
+ ></span>
3140
+ </h3>
3141
+ <span fxFlex></span>
3142
+ <div *ngIf="to.chip" class="chip">
3143
+ {{ to.chip | translate }}
3144
+ </div>
3145
+ </div>
3146
+ `, styles: [".chip{background:whitesmoke;border-radius:6px;padding:4px 8px;font-size:12px;color:#888;font-weight:600}\n"] }]
3147
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
3148
+
3149
+ class ProfileImageTypeComponent extends FieldType {
3150
+ constructor(cd) {
3151
+ super();
3152
+ this.cd = cd;
3153
+ }
3154
+ ngOnChange() { }
3155
+ ngAfterViewInit() {
3156
+ if (this.to.width) {
3157
+ this.width = this.to.width;
3158
+ }
3159
+ if (this.to.padding) {
3160
+ this.padding = this.to.padding;
3161
+ }
3162
+ this.cd.detectChanges();
3163
+ }
3164
+ }
3165
+ ProfileImageTypeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ProfileImageTypeComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3166
+ ProfileImageTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ProfileImageTypeComponent, selector: "app-formly-profile-image-type", usesInheritance: true, ngImport: i0, template: `
3167
+ <mat-card
3168
+
3169
+ fxLayout="column"
3170
+ fxLayoutAlign="center center"
3171
+ >
3172
+ <ngx-avatars
3173
+ class="profile-image"
3174
+ [src]="model[key.toString()]"
3175
+ [size]="150"
3176
+
3177
+ ></ngx-avatars>
3178
+ </mat-card>
3179
+ `, isInline: true, styles: ["mat-card{border-radius:0;box-shadow:none!important}.profile-image{width:150px;height:150px;border-radius:50%}\n"], dependencies: [{ kind: "component", type: i5$1.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { kind: "component", type: i3.AvatarComponent, selector: "ngx-avatars", inputs: ["round", "size", "textSizeRatio", "bgColor", "fgColor", "borderColor", "style", "cornerRadius", "facebookId", "twitterId", "googleId", "instagramId", "vkontakteId", "skypeId", "gravatarId", "githubId", "src", "name", "value", "referrerpolicy", "placeholder", "initialsSize"], outputs: ["clickOnAvatar"] }] });
3180
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ProfileImageTypeComponent, decorators: [{
3181
+ type: Component,
3182
+ args: [{ selector: 'app-formly-profile-image-type', template: `
3183
+ <mat-card
3184
+
3185
+ fxLayout="column"
3186
+ fxLayoutAlign="center center"
3187
+ >
3188
+ <ngx-avatars
3189
+ class="profile-image"
3190
+ [src]="model[key.toString()]"
3191
+ [size]="150"
3192
+
3193
+ ></ngx-avatars>
3194
+ </mat-card>
3195
+ `, styles: ["mat-card{border-radius:0;box-shadow:none!important}.profile-image{width:150px;height:150px;border-radius:50%}\n"] }]
3196
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
3197
+
3198
+ class AppFormModule {
3199
+ }
3200
+ AppFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3201
+ AppFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: AppFormModule, declarations: [TitleTypeComponent,
3202
+ AvatarTypeComponent,
3203
+ ProfileImageTypeComponent], imports: [CommonModule,
3204
+ FormsModule,
3205
+ FormlyMatDatepickerModule,
3206
+ FormlySelectModule,
3207
+ MaterialModule,
3208
+ AvatarModule,
3209
+ TranslateModule,
3210
+ FormlyMaterialModule, i7.FormlyModule], exports: [FormlyModule] });
3211
+ AppFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppFormModule, imports: [CommonModule,
3212
+ FormsModule,
3213
+ FormlyMatDatepickerModule,
3214
+ FormlySelectModule,
3215
+ MaterialModule,
3216
+ AvatarModule,
3217
+ TranslateModule,
3218
+ FormlyMaterialModule,
3219
+ FormlyModule.forRoot({
3220
+ types: [
3221
+ {
3222
+ name: 'title',
3223
+ component: TitleTypeComponent,
3224
+ wrappers: [],
3225
+ },
3226
+ {
3227
+ name: 'profile-image',
3228
+ component: ProfileImageTypeComponent,
3229
+ wrappers: [],
3230
+ },
3231
+ ],
3232
+ }), FormlyModule] });
3233
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppFormModule, decorators: [{
42
3234
  type: NgModule,
43
3235
  args: [{
44
3236
  declarations: [
45
- NgxScandocComponent
3237
+ TitleTypeComponent,
3238
+ AvatarTypeComponent,
3239
+ ProfileImageTypeComponent,
3240
+ ],
3241
+ imports: [
3242
+ CommonModule,
3243
+ FormsModule,
3244
+ FormlyMatDatepickerModule,
3245
+ FormlySelectModule,
3246
+ MaterialModule,
3247
+ AvatarModule,
3248
+ TranslateModule,
3249
+ FormlyMaterialModule,
3250
+ FormlyModule.forRoot({
3251
+ types: [
3252
+ {
3253
+ name: 'title',
3254
+ component: TitleTypeComponent,
3255
+ wrappers: [],
3256
+ },
3257
+ {
3258
+ name: 'profile-image',
3259
+ component: ProfileImageTypeComponent,
3260
+ wrappers: [],
3261
+ },
3262
+ ],
3263
+ }),
3264
+ ],
3265
+ providers: [],
3266
+ exports: [FormlyModule],
3267
+ }]
3268
+ }] });
3269
+
3270
+ class CameraSwitchComponent {
3271
+ constructor(cameraProvider) {
3272
+ this.cameraProvider = cameraProvider;
3273
+ }
3274
+ ngAfterViewInit() { }
3275
+ ngOnDestroy() { }
3276
+ }
3277
+ CameraSwitchComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CameraSwitchComponent, deps: [{ token: NgxScandocCameraProvider }], target: i0.ɵɵFactoryTarget.Component });
3278
+ CameraSwitchComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: CameraSwitchComponent, selector: "ngx-scan-camera-switch", ngImport: i0, template: "<mat-form-field\n style=\"font-size: 14px; width: 200px; margin-top: 8px\"\n class=\"w-100 mr-16 mt-8\"\n>\n <mat-label> Camera </mat-label>\n <mat-select (selectionChange)=\"cameraProvider.selectCamera($event)\" [(ngModel)]=\"cameraProvider.deviceId\">\n <mat-option *ngFor=\"let device of cameraProvider.mediaDevices\" [value]=\"device.deviceId\">\n {{ device.label }}\n </mat-option>\n </mat-select>\n</mat-form-field>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1}\n"], dependencies: [{ kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i4$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4$1.MatLabel, selector: "mat-label" }, { kind: "component", type: i5$2.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i6$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }] });
3279
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CameraSwitchComponent, decorators: [{
3280
+ type: Component,
3281
+ args: [{ selector: 'ngx-scan-camera-switch', template: "<mat-form-field\n style=\"font-size: 14px; width: 200px; margin-top: 8px\"\n class=\"w-100 mr-16 mt-8\"\n>\n <mat-label> Camera </mat-label>\n <mat-select (selectionChange)=\"cameraProvider.selectCamera($event)\" [(ngModel)]=\"cameraProvider.deviceId\">\n <mat-option *ngFor=\"let device of cameraProvider.mediaDevices\" [value]=\"device.deviceId\">\n {{ device.label }}\n </mat-option>\n </mat-select>\n</mat-form-field>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1}\n"] }]
3282
+ }], ctorParameters: function () { return [{ type: NgxScandocCameraProvider }]; } });
3283
+
3284
+ class CoreComponentsModule {
3285
+ }
3286
+ CoreComponentsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoreComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3287
+ CoreComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: CoreComponentsModule, declarations: [ScanComponent, ScanResultsComponent, CameraSwitchComponent], imports: [CommonModule,
3288
+ FormsModule,
3289
+ TranslateModule,
3290
+ WebcamModule,
3291
+ MaterialModule,
3292
+ AppFormModule,
3293
+ ReactiveFormsModule], exports: [WebcamModule, ScanComponent, CameraSwitchComponent] });
3294
+ CoreComponentsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoreComponentsModule, imports: [CommonModule,
3295
+ FormsModule,
3296
+ TranslateModule,
3297
+ WebcamModule,
3298
+ MaterialModule,
3299
+ AppFormModule,
3300
+ ReactiveFormsModule, WebcamModule] });
3301
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoreComponentsModule, decorators: [{
3302
+ type: NgModule,
3303
+ args: [{
3304
+ imports: [
3305
+ CommonModule,
3306
+ FormsModule,
3307
+ TranslateModule,
3308
+ WebcamModule,
3309
+ MaterialModule,
3310
+ AppFormModule,
3311
+ ReactiveFormsModule,
46
3312
  ],
3313
+ declarations: [ScanComponent, ScanResultsComponent, CameraSwitchComponent],
3314
+ exports: [WebcamModule, ScanComponent, CameraSwitchComponent],
3315
+ providers: [],
3316
+ }]
3317
+ }] });
3318
+
3319
+ class SafeResourceUrlPipe {
3320
+ constructor(sanitizer) {
3321
+ this.sanitizer = sanitizer;
3322
+ }
3323
+ transform(style) {
3324
+ return this.sanitizer.bypassSecurityTrustResourceUrl(style);
3325
+ // return this.sanitizer.bypassSecurityTrustStyle(style);
3326
+ // return this.sanitizer.bypassSecurityTrustXxx(style); - see docs
3327
+ }
3328
+ }
3329
+ SafeResourceUrlPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SafeResourceUrlPipe, deps: [{ token: i1$3.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
3330
+ SafeResourceUrlPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: SafeResourceUrlPipe, name: "safeResourceUrl" });
3331
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SafeResourceUrlPipe, decorators: [{
3332
+ type: Pipe,
3333
+ args: [{ name: 'safeResourceUrl' }]
3334
+ }], ctorParameters: function () { return [{ type: i1$3.DomSanitizer }]; } });
3335
+
3336
+ class CorePipesModule {
3337
+ }
3338
+ CorePipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CorePipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3339
+ CorePipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: CorePipesModule, declarations: [SafeResourceUrlPipe], exports: [SafeResourceUrlPipe] });
3340
+ CorePipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CorePipesModule });
3341
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CorePipesModule, decorators: [{
3342
+ type: NgModule,
3343
+ args: [{
3344
+ declarations: [SafeResourceUrlPipe],
47
3345
  imports: [],
48
3346
  exports: [
49
- NgxScandocComponent
50
- ]
3347
+ SafeResourceUrlPipe,
3348
+ ],
3349
+ }]
3350
+ }] });
3351
+
3352
+ class BlankComponent {
3353
+ constructor(dialogRef, data, cd) {
3354
+ this.dialogRef = dialogRef;
3355
+ this.data = data;
3356
+ this.cd = cd;
3357
+ this.initSet = false;
3358
+ }
3359
+ setModel(model) {
3360
+ this.data.data.model = model;
3361
+ this.init();
3362
+ }
3363
+ init() {
3364
+ this.initSet = true;
3365
+ this.body?.clear();
3366
+ const componentRef = this.body?.createComponent(this.data.component);
3367
+ componentRef.instance.data = this.data.data;
3368
+ // componentRef.instance.dialogs = this.dialogs;
3369
+ componentRef.instance.dialogRef = this.dialogRef;
3370
+ if (componentRef.instance.init) {
3371
+ componentRef.instance.init();
3372
+ }
3373
+ this.cd.detectChanges();
3374
+ }
3375
+ ngAfterViewInit() {
3376
+ if (!this.initSet) {
3377
+ this.init();
3378
+ }
3379
+ }
3380
+ }
3381
+ BlankComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BlankComponent, deps: [{ token: i1$4.MatDialogRef }, { token: MAT_DIALOG_DATA }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3382
+ BlankComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: BlankComponent, selector: "app-dialog-blank", viewQueries: [{ propertyName: "body", first: true, predicate: ["body"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<ng-template #body></ng-template>\n", styles: [":host{display:flex;flex:1;flex-direction:column;overflow:hidden;height:100%}\n"] });
3383
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BlankComponent, decorators: [{
3384
+ type: Component,
3385
+ args: [{ selector: 'app-dialog-blank', template: "<ng-template #body></ng-template>\n", styles: [":host{display:flex;flex:1;flex-direction:column;overflow:hidden;height:100%}\n"] }]
3386
+ }], ctorParameters: function () { return [{ type: i1$4.MatDialogRef }, { type: undefined, decorators: [{
3387
+ type: Inject,
3388
+ args: [MAT_DIALOG_DATA]
3389
+ }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { body: [{
3390
+ type: ViewChild,
3391
+ args: ['body', { read: ViewContainerRef, static: true }]
3392
+ }] } });
3393
+
3394
+ class LoadingComponent {
3395
+ }
3396
+ LoadingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoadingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3397
+ LoadingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: LoadingComponent, selector: "app-loading", ngImport: i0, template: "<div style=\"width:240px;\">\n\n <div class=\"pb-16\" style=\"font-size: 18px;padding-bottom:16px;\">\n Loading...\n </div>\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n</div>\n", styles: [""], dependencies: [{ kind: "component", type: i9.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }] });
3398
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoadingComponent, decorators: [{
3399
+ type: Component,
3400
+ args: [{ selector: 'app-loading', template: "<div style=\"width:240px;\">\n\n <div class=\"pb-16\" style=\"font-size: 18px;padding-bottom:16px;\">\n Loading...\n </div>\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n</div>\n" }]
3401
+ }] });
3402
+
3403
+ class ConfirmComponent {
3404
+ constructor(dialogRef, data) {
3405
+ this.dialogRef = dialogRef;
3406
+ this.data = data;
3407
+ this.showDetails = false;
3408
+ this.images = {
3409
+ alert: 'page-lost.svg',
3410
+ prompt: 'bedroom.svg',
3411
+ dirty: 'opps.svg',
3412
+ };
3413
+ this.options = {};
3414
+ }
3415
+ onEnterPress(e) {
3416
+ this.action(true);
3417
+ }
3418
+ onEscapePress(e) {
3419
+ this.action(false);
3420
+ }
3421
+ ngOnInit() {
3422
+ console.log(this.data);
3423
+ this.options = this.data.options || {};
3424
+ this.type = this.options.type || this.data.type || 'prompt';
3425
+ }
3426
+ action(key) {
3427
+ this.dialogRef.close(key);
3428
+ }
3429
+ close() { }
3430
+ }
3431
+ ConfirmComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ConfirmComponent, deps: [{ token: i1$4.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
3432
+ ConfirmComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ConfirmComponent, selector: "app-confirm", host: { listeners: { "document:keyup.enter": "onEnterPress($event)", "document:keyup.escape": "onEscapePress($event)" } }, ngImport: i0, template: "<header class=\"page-header\" fxLayout=\"row\" fxLayoutAlign=\"start center\">\n\n\n <div class=\"title\" ngClass.lt-sm=\"title-small\">\n {{ data.title | translate }}\n\n <!-- {{ data.text.statusText }} {{ data.text.status }} -->\n </div>\n\n <span fxFlex></span>\n\n <!-- <div class=\"separator\"></div>\n\n <button mat-button (click)=\"close()\">\n <mat-icon>close</mat-icon>\n </button> -->\n <!-- <mat-icon class=\"mr-16\" style=\"color:#888;\">info_outline</mat-icon> -->\n</header>\n\n<div fxLayout=\"column\" fxLayoutAlign=\"center center\">\n <!-- <img\n style=\"height: 240px; margin: 34px 0px;display: none;\"\n [src]=\"'/assets/images/illustrations/' + images[type]\"\n /> -->\n <!-- <img style=\"width:60px;\" src=\"/assets/images/illustrations/door-lock.png\"> -->\n\n <div class=\"text\" *ngIf=\"data.text\">\n <span [innerHtml]=\"data.text\"></span>\n </div>\n</div>\n\n<!-- -->\n\n<footer>\n\n <div class=\"actions\" fxLayout=\"row\" fxLayoutAlign=\"end center\">\n <button\n *ngIf=\"!data.alert && !options?.hideCancelButton\"\n (click)=\"action(false)\"\n mat-raised-button\n >\n {{ data.cancel || 'core.page.cancel' | translate }}\n </button>\n\n <button\n *ngIf=\"data.no && !options?.hideNoButton\"\n (click)=\"action('no')\"\n\n mat-raised-button\n >\n {{ data.no }}\n </button>\n <button\n *ngIf=\"!data.hideOkButton && !options?.hideOkButton\"\n (click)=\"action(true)\"\n color=\"accent\"\n mat-raised-button\n >\n <ng-container *ngIf=\"!data.alert\">\n {{ data.ok || 'core.page.confirm' | translate }}\n </ng-container>\n\n <ng-container *ngIf=\"data.alert\">\n {{ data.ok || 'core.page.close' | translate }}\n </ng-container>\n </button>\n </div>\n</footer>\n", styles: [":host{display:flex;flex-direction:column;flex:1;height:100%;width:100%}.title{font-size:18px}.text{padding:0 30px;text-align:center;font-size:16px;margin:40px 0}.actions{min-height:60px}.actions button{min-width:120px;margin-right:16px;box-shadow:none;text-transform:uppercase}footer{background-color:#fff}footer button{box-shadow:none!important;border:1px solid rgba(0,0,0,.12);font-size:13px}\n", ".page-header{z-index:2000;height:64px;padding:0;background-color:#fff;border-bottom:1px solid rgba(0,0,0,.12)}.page-header .title{padding-left:24px;line-height:64px;font-size:18px}.page-header .separator{width:1px;background-color:#0000001f;height:100%}.page-header .total{line-height:64px}.page-header .total span{font-weight:700}.page-footer{height:64px}.page-footer button{margin-left:24px;box-shadow:none!important}\n"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i4$2.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i4$2.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { kind: "directive", type: i4$2.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "directive", type: i5$3.DefaultClassDirective, selector: " [ngClass], [ngClass.xs], [ngClass.sm], [ngClass.md], [ngClass.lg], [ngClass.xl], [ngClass.lt-sm], [ngClass.lt-md], [ngClass.lt-lg], [ngClass.lt-xl], [ngClass.gt-xs], [ngClass.gt-sm], [ngClass.gt-md], [ngClass.gt-lg]", inputs: ["ngClass", "ngClass.xs", "ngClass.sm", "ngClass.md", "ngClass.lg", "ngClass.xl", "ngClass.lt-sm", "ngClass.lt-md", "ngClass.lt-lg", "ngClass.lt-xl", "ngClass.gt-xs", "ngClass.gt-sm", "ngClass.gt-md", "ngClass.gt-lg"] }, { kind: "pipe", type: i1$2.TranslatePipe, name: "translate" }] });
3433
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ConfirmComponent, decorators: [{
3434
+ type: Component,
3435
+ args: [{ selector: 'app-confirm', template: "<header class=\"page-header\" fxLayout=\"row\" fxLayoutAlign=\"start center\">\n\n\n <div class=\"title\" ngClass.lt-sm=\"title-small\">\n {{ data.title | translate }}\n\n <!-- {{ data.text.statusText }} {{ data.text.status }} -->\n </div>\n\n <span fxFlex></span>\n\n <!-- <div class=\"separator\"></div>\n\n <button mat-button (click)=\"close()\">\n <mat-icon>close</mat-icon>\n </button> -->\n <!-- <mat-icon class=\"mr-16\" style=\"color:#888;\">info_outline</mat-icon> -->\n</header>\n\n<div fxLayout=\"column\" fxLayoutAlign=\"center center\">\n <!-- <img\n style=\"height: 240px; margin: 34px 0px;display: none;\"\n [src]=\"'/assets/images/illustrations/' + images[type]\"\n /> -->\n <!-- <img style=\"width:60px;\" src=\"/assets/images/illustrations/door-lock.png\"> -->\n\n <div class=\"text\" *ngIf=\"data.text\">\n <span [innerHtml]=\"data.text\"></span>\n </div>\n</div>\n\n<!-- -->\n\n<footer>\n\n <div class=\"actions\" fxLayout=\"row\" fxLayoutAlign=\"end center\">\n <button\n *ngIf=\"!data.alert && !options?.hideCancelButton\"\n (click)=\"action(false)\"\n mat-raised-button\n >\n {{ data.cancel || 'core.page.cancel' | translate }}\n </button>\n\n <button\n *ngIf=\"data.no && !options?.hideNoButton\"\n (click)=\"action('no')\"\n\n mat-raised-button\n >\n {{ data.no }}\n </button>\n <button\n *ngIf=\"!data.hideOkButton && !options?.hideOkButton\"\n (click)=\"action(true)\"\n color=\"accent\"\n mat-raised-button\n >\n <ng-container *ngIf=\"!data.alert\">\n {{ data.ok || 'core.page.confirm' | translate }}\n </ng-container>\n\n <ng-container *ngIf=\"data.alert\">\n {{ data.ok || 'core.page.close' | translate }}\n </ng-container>\n </button>\n </div>\n</footer>\n", styles: [":host{display:flex;flex-direction:column;flex:1;height:100%;width:100%}.title{font-size:18px}.text{padding:0 30px;text-align:center;font-size:16px;margin:40px 0}.actions{min-height:60px}.actions button{min-width:120px;margin-right:16px;box-shadow:none;text-transform:uppercase}footer{background-color:#fff}footer button{box-shadow:none!important;border:1px solid rgba(0,0,0,.12);font-size:13px}\n", ".page-header{z-index:2000;height:64px;padding:0;background-color:#fff;border-bottom:1px solid rgba(0,0,0,.12)}.page-header .title{padding-left:24px;line-height:64px;font-size:18px}.page-header .separator{width:1px;background-color:#0000001f;height:100%}.page-header .total{line-height:64px}.page-header .total span{font-weight:700}.page-footer{height:64px}.page-footer button{margin-left:24px;box-shadow:none!important}\n"] }]
3436
+ }], ctorParameters: function () { return [{ type: i1$4.MatDialogRef }, { type: undefined, decorators: [{
3437
+ type: Inject,
3438
+ args: [MAT_DIALOG_DATA]
3439
+ }] }]; }, propDecorators: { onEnterPress: [{
3440
+ type: HostListener,
3441
+ args: ['document:keyup.enter', ['$event']]
3442
+ }], onEscapePress: [{
3443
+ type: HostListener,
3444
+ args: ['document:keyup.escape', ['$event']]
3445
+ }] } });
3446
+
3447
+ class ScanSelfieComponent {
3448
+ constructor(cd, scanProvider, dialogs,
3449
+ // private formProvider: ScanFieldsProvider,
3450
+ translate) {
3451
+ this.cd = cd;
3452
+ this.scanProvider = scanProvider;
3453
+ this.dialogs = dialogs;
3454
+ this.translate = translate;
3455
+ this.scanBlastData = [
3456
+ {
3457
+ title: 'pms.dialogs.components.scanProfile.front',
3458
+ description: 'pms.dialogs.components.scanProfile.frontDescription',
3459
+ side: 'FRONT',
3460
+ },
3461
+ {
3462
+ title: 'pms.dialogs.components.scanProfile.back',
3463
+ description: 'pms.dialogs.components.scanProfile.backDescription',
3464
+ disabled: true,
3465
+ side: 'BACK',
3466
+ },
3467
+ ];
3468
+ this.type = 'desktop';
3469
+ this.actions = new EventEmitter();
3470
+ this.mediaDevices = [];
3471
+ this.videoOptions = {
3472
+ width: 1920,
3473
+ height: 1080,
3474
+ facingMode: 'environment',
3475
+ };
3476
+ this.multipleWebcamsAvailable = false;
3477
+ // webcam snapshot trigger
3478
+ this.documentTypeSelected = false;
3479
+ this.preview = null;
3480
+ this.allowCameraSwitch = true;
3481
+ this.error = false;
3482
+ this.cameraReady = false;
3483
+ this.scaning = false;
3484
+ this.scanDatas = [];
3485
+ this.trigger = new Subject();
3486
+ // switch to next / previous / specific webcam; true/false: forward/backwards, string: deviceId
3487
+ this.nextWebcam = new Subject();
3488
+ this.form = new FormGroup({});
3489
+ }
3490
+ onResize() {
3491
+ if (this.wraper) {
3492
+ this.width = this.wraper.nativeElement.clientWidth;
3493
+ this.height = this.wraper.nativeElement.clientHeight;
3494
+ console.log(this.width, this.height);
3495
+ setTimeout(() => {
3496
+ const video = this.wraper?.nativeElement.querySelector('video');
3497
+ if (video) {
3498
+ // console.log(video.clientWidth, video.clientHeight);
3499
+ this.videoWidth = video.clientWidth;
3500
+ this.videoHeight = video.clientHeight;
3501
+ }
3502
+ }, 100);
3503
+ this.cd.detectChanges();
3504
+ }
3505
+ }
3506
+ init() {
3507
+ console.log('HAS MULTI');
3508
+ // this.result=true;
3509
+ // this.result ={};
3510
+ this.fields = []; //this.formProvider.document();
3511
+ WebcamUtil.getAvailableVideoInputs().subscribe((mediaDevices) => {
3512
+ console.log('[DEVICES]', mediaDevices);
3513
+ this.mediaDevices = mediaDevices;
3514
+ this.multipleWebcamsAvailable = mediaDevices && mediaDevices.length > 1;
3515
+ this.singleScan(this.scanBlastData[0]);
3516
+ });
3517
+ }
3518
+ handleImage(webcamImage) {
3519
+ console.log('[received webcam image]', webcamImage);
3520
+ this.webcamImage = webcamImage;
3521
+ this.preview = webcamImage.imageAsDataUrl;
3522
+ this.cd.detectChanges();
3523
+ }
3524
+ handleInitError(error) {
3525
+ console.log(error);
3526
+ }
3527
+ get scanBlastCanUpload() {
3528
+ return this.scanBlastData[0].image ? true : false;
3529
+ }
3530
+ cameraWasSwitched(deviceId) {
3531
+ console.log('active device: ' + deviceId);
3532
+ this.deviceId = deviceId;
3533
+ this.cameraReady = true;
3534
+ this.defaultDevice = deviceId;
3535
+ this.onResize();
3536
+ }
3537
+ get nextWebcamObservable() {
3538
+ return this.nextWebcam.asObservable();
3539
+ }
3540
+ ngAfterViewInit() {
3541
+ this.cd.detectChanges();
3542
+ }
3543
+ selectCamera(event) {
3544
+ console.log(event);
3545
+ this.nextWebcam.next(event.value);
3546
+ }
3547
+ close() {
3548
+ this.dialogRef?.close();
3549
+ }
3550
+ singleScan(side) {
3551
+ this.scanType = side.side;
3552
+ this.preview = null;
3553
+ this.selectedSide = side;
3554
+ this.selectedSide.image = null;
3555
+ this.documentTypeSelected = true;
3556
+ this.scanBlastData[1].disabled = false;
3557
+ this.cd.detectChanges();
3558
+ setTimeout(() => {
3559
+ this.onResize();
3560
+ }, 10);
3561
+ }
3562
+ getBase64(file) {
3563
+ return new Observable((observer) => {
3564
+ const reader = new FileReader();
3565
+ reader.readAsDataURL(file);
3566
+ reader.onload = () => {
3567
+ observer.next(reader.result);
3568
+ };
3569
+ reader.onerror = (error) => {
3570
+ observer.error(error);
3571
+ };
3572
+ });
3573
+ }
3574
+ handleFileInput(target, event, side) {
3575
+ const files = target.files;
3576
+ this.selectedSide = side;
3577
+ console.log(files);
3578
+ const file = files.item(0);
3579
+ this.resolutionLimit(file)
3580
+ .pipe(switchMap((valid) => {
3581
+ return valid ? this.getBase64(file) : of(false);
3582
+ }))
3583
+ .subscribe((imageAsDataUrl) => {
3584
+ // console.log(imageAsDataUrl);
3585
+ event.target.value = null;
3586
+ if (!imageAsDataUrl) {
3587
+ this.dialogs.alert('core.page.error', this.translate.instant('pms.dialogs.components.scanProfile.minResolution'));
3588
+ }
3589
+ else {
3590
+ side.image = {
3591
+ imageAsDataUrl,
3592
+ };
3593
+ if (this.selectedSide.side === 'FRONT') {
3594
+ this.scanBlastData[1].disabled = false;
3595
+ }
3596
+ }
3597
+ this.cd.detectChanges();
3598
+ });
3599
+ }
3600
+ rotateBase64Image(base64data) {
3601
+ return new Observable((observer) => {
3602
+ const canvas = document.createElement('canvas');
3603
+ const ctx = canvas.getContext('2d');
3604
+ var image = new Image();
3605
+ image.src = base64data;
3606
+ image.onload = () => {
3607
+ console.log(canvas);
3608
+ canvas.width = image.height;
3609
+ canvas.height = image.width;
3610
+ if (ctx) {
3611
+ ctx.rotate((90 * Math.PI) / 180);
3612
+ ctx.translate(0, -canvas.width);
3613
+ ctx.drawImage(image, 0, 0);
3614
+ observer.next(canvas.toDataURL());
3615
+ }
3616
+ else {
3617
+ observer.error({ type: 'generic error' });
3618
+ }
3619
+ };
3620
+ image.onerror = (e) => {
3621
+ observer.error(e);
3622
+ };
3623
+ });
3624
+ }
3625
+ sendMobile() {
3626
+ // this.dialogs.scanMobile({ id: 1 });
3627
+ }
3628
+ singleScanRotate(side) {
3629
+ console.log(side);
3630
+ this.rotateBase64Image(side.image.imageAsDataUrl).subscribe((data) => {
3631
+ side.image = { imageAsDataUrl: data };
3632
+ this.cd.detectChanges();
3633
+ });
3634
+ }
3635
+ singleScanRemove(side) {
3636
+ side.image = null;
3637
+ if (side.side === 'FRONT') {
3638
+ this.scanBlastData[1].disabled = true;
3639
+ }
3640
+ this.cd.detectChanges();
3641
+ }
3642
+ resolutionLimit(file) {
3643
+ const minWidth = 1280;
3644
+ const minHeight = 720;
3645
+ return new Observable((observer) => {
3646
+ const img = new Image();
3647
+ img.src = window.URL.createObjectURL(file);
3648
+ img.onload = () => {
3649
+ const width = img.naturalWidth;
3650
+ const height = img.naturalHeight;
3651
+ let valid = false;
3652
+ if (width > height) {
3653
+ valid = width >= minWidth && height >= minHeight;
3654
+ }
3655
+ else {
3656
+ valid = width >= minHeight && height >= minWidth;
3657
+ }
3658
+ observer.next(valid);
3659
+ };
3660
+ img.onerror = (error) => {
3661
+ observer.error(error);
3662
+ };
3663
+ });
3664
+ }
3665
+ getImgBase64(num) {
3666
+ return this.scanBlastData[num].image.dataUrl.split(',')[1];
3667
+ }
3668
+ scanBlastFinish() {
3669
+ if (this.type === 'mobile') {
3670
+ this.actions.emit({ data: this.scanBlastData });
3671
+ this.retake();
3672
+ return;
3673
+ }
3674
+ const loading = this.dialogs.loading();
3675
+ this.scaning = true;
3676
+ const payload = {
3677
+ AcceptTermsAndConditions: true,
3678
+ DataFields: {
3679
+ FrontImageType: 'base64',
3680
+ FrontImageCropped: false,
3681
+ BackImageType: 'base64',
3682
+ BackImageCropped: false,
3683
+ FrontImage: this.getImgBase64(0),
3684
+ BackImage: this.scanBlastData[1].image ? this.getImgBase64(1) : null,
3685
+ },
3686
+ Settings: {
3687
+ ShouldValidate: true,
3688
+ ShouldReturnDocumentImage: true,
3689
+ ShouldReturnFaceIfDetected: true,
3690
+ SkipImageSizeCheck: true,
3691
+ CanStoreImages: this.scanProvider.canStoreImages,
3692
+ },
3693
+ // CallBackUrl: 'http://demo:5000/report/extracted/',
3694
+ };
3695
+ if (!this.scanBlastData[1].image) {
3696
+ payload.Settings.IgnoreBackImage = true;
3697
+ }
3698
+ this.scanProvider.blastPost(payload).subscribe((data) => {
3699
+ const results = data.Data;
3700
+ loading.close();
3701
+ this.documentTypeSelected = true;
3702
+ this.scaning = false;
3703
+ if (results && data.Metadata.length > 0) {
3704
+ if (data.ImageData?.Documents) {
3705
+ const { Documents } = data.ImageData;
3706
+ this.images = Documents.map((image, i) => {
3707
+ return { data: 'data:image/jpeg;base64,' + Documents[i] };
3708
+ });
3709
+ }
3710
+ this.result = this.scanProvider.parseBlast(results);
3711
+ console.log('RES', this.result);
3712
+ this.model = this.result.model;
3713
+ if (data.ImageData?.FaceImage) {
3714
+ this.model._avatar =
3715
+ 'data:image/jpeg;base64,' + data.ImageData?.FaceImage;
3716
+ }
3717
+ console.log('MODEL', this.model);
3718
+ }
3719
+ else {
3720
+ console.log('ERROR');
3721
+ // this.scanSide = 0;
3722
+ this.error = true;
3723
+ this.preview = true;
3724
+ // this.documentTypeSelected = false;
3725
+ // this.retry();
3726
+ }
3727
+ this.cd.detectChanges();
3728
+ }, (err) => {
3729
+ loading.close();
3730
+ // this.scanSide = 0;
3731
+ this.error = true;
3732
+ this.preview = true;
3733
+ this.documentTypeSelected = true;
3734
+ this.scaning = false;
3735
+ });
3736
+ }
3737
+ cameraOff(ev) {
3738
+ this.cameraReady = false;
3739
+ this.cd.detectChanges();
3740
+ }
3741
+ continue() {
3742
+ if (this.scanProvider.enableVerification) {
3743
+ const loading = this.dialogs.loading();
3744
+ console.log(this.data.avatar);
3745
+ this.scanProvider
3746
+ .stateless(this.data.avatar.split(',')[1], this.webcamImage?.imageAsDataUrl.split(',')[1])
3747
+ .subscribe((resp) => {
3748
+ loading.close();
3749
+ if (resp.Data?.Verified) {
3750
+ this.dialogRef?.close(this.webcamImage);
3751
+ }
3752
+ else {
3753
+ this.dialogs.alert('Verification failed!', "We can't verify that your selfie is same as image on document.");
3754
+ }
3755
+ console.log(resp);
3756
+ }, (err) => {
3757
+ loading.close();
3758
+ this.dialogRef?.close(this.webcamImage);
3759
+ });
3760
+ }
3761
+ else {
3762
+ this.dialogRef?.close(this.webcamImage);
3763
+ }
3764
+ // this.dialogRef.close(this.webcamImage)
3765
+ }
3766
+ retry() {
3767
+ this.preview = false;
3768
+ this.result = false;
3769
+ if (this.error) {
3770
+ this.documentTypeSelected = false;
3771
+ this.scanBlastData.forEach((element) => {
3772
+ element.image = null;
3773
+ });
3774
+ }
3775
+ this.error = false;
3776
+ }
3777
+ triggerSnapshot() {
3778
+ this.trigger.next(0);
3779
+ }
3780
+ scan() {
3781
+ console.log('SCAN');
3782
+ this.triggerSnapshot();
3783
+ this.scanDatas[0] = true;
3784
+ }
3785
+ retake() {
3786
+ this.preview = false;
3787
+ this.error = false;
3788
+ this.result = false;
3789
+ this.scanSide = 0;
3790
+ this.scanDatas = [];
3791
+ this.scaning = false;
3792
+ this.images = [];
3793
+ this.documentTypeSelected = false;
3794
+ this.scanBlastData.forEach((m) => {
3795
+ m.image = null;
3796
+ });
3797
+ this.cd.detectChanges();
3798
+ }
3799
+ use() { }
3800
+ selfie() { }
3801
+ }
3802
+ ScanSelfieComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanSelfieComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: ScanProvider }, { token: DialogsCoreProvider }, { token: i1$2.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
3803
+ ScanSelfieComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ScanSelfieComponent, selector: "app-scan-selfie", inputs: { type: "type" }, outputs: { actions: "actions" }, host: { listeners: { "window:resize": "onResize($event)" } }, viewQueries: [{ propertyName: "wraper", first: true, predicate: ["wraper"], descendants: true }], ngImport: i0, template: "<header class=\"page-header\" fxLayout=\"row\">\n <div class=\"title\" ngClass.lt-sm=\"title-small\">Selfie</div>\n\n <span fxFlex></span>\n <ng-container\n *ngIf=\"\n documentTypeSelected &&\n !result &&\n !error &&\n multipleWebcamsAvailable &&\n !preview\n \"\n >\n <div class=\"separator\"></div>\n <div style=\"padding: 0px 16px\">\n <div fxLayout=\"row\" fxLayoutAlign=\"end center\">\n <mat-form-field\n style=\"font-size: 14px; width: 200px; margin-top: 8px\"\n class=\"w-200 mr-16 mt-8\"\n >\n <mat-label> Camera </mat-label>\n <mat-select\n (selectionChange)=\"selectCamera($event)\"\n [(ngModel)]=\"deviceId\"\n >\n <mat-option\n *ngFor=\"let device of mediaDevices\"\n [value]=\"device.deviceId\"\n >\n {{ device.label }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n </div>\n </ng-container>\n\n <ng-container>\n <div class=\"separator\"></div>\n\n <button mat-button (click)=\"close()\">\n <mat-icon>close</mat-icon>\n </button>\n </ng-container>\n <!-- <ng-container *ngIf=\"type === 'desktop'\">\n <div class=\"separator\"></div>\n <button mat-button (click)=\"sendMobile()\">\n <mat-icon>tablet_mac</mat-icon>\n </button>\n\n <div class=\"separator\"></div>\n\n <button mat-button (click)=\"close()\">\n <mat-icon>close</mat-icon>\n </button>\n </ng-container> -->\n</header>\n\n<div *ngIf=\"!result\" fxFlex fxLayout=\"column\">\n <div fxFlex #wraper class=\"wraper\" fxLayout=\"row\">\n <div\n style=\"\n position: absolute;\n top: 0px;\n left: 0px;\n right: 0px;\n bottom: 0px;\n z-index: 20;\n background-color: whitesmoke;\n \"\n *ngIf=\"!cameraReady && !preview\"\n >\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n </div>\n\n <ng-container *ngIf=\"!error\">\n <!-- <div\n class=\"rectangle\"\n [ngStyle]=\"{\n 'width.px': videoHeight * 0.75 * 1.588,\n 'height.px': videoHeight * 0.75\n }\"\n ></div>\n <svg\n *ngIf=\"videoWidth\"\n style=\"position: absolute; left: 0px; top: 0px\"\n width=\"0\"\n height=\"0\"\n >\n <defs>\n <clipPath id=\"myClip\">\n <rect\n stroke-width=\"6\"\n stroke-color=\"red\"\n [attr.x]=\"(videoWidth - videoHeight * 0.75 * 1.588) / 2\"\n [attr.y]=\"(videoHeight * 0.25) / 2\"\n [attr.width]=\"videoHeight * 0.75 * 1.588\"\n [attr.height]=\"videoHeight * 0.75\"\n rx=\"25\"\n />\n </clipPath>\n </defs>\n </svg> -->\n\n <app-webcam\n *ngIf=\"!preview && !scaning\"\n class=\"main\"\n [imageQuality]=\"1\"\n #webcam\n fxFlex\n [trigger]=\"trigger\"\n (imageCapture)=\"handleImage($event)\"\n [allowCameraSwitch]=\"allowCameraSwitch\"\n [videoOptions]=\"videoOptions\"\n [switchCamera]=\"nextWebcamObservable\"\n (cameraSwitched)=\"cameraWasSwitched($event)\"\n (initError)=\"handleInitError($event)\"\n type=\"selfie\"\n [width]=\"width\"\n [height]=\"height\"\n (destroyed)=\"cameraOff($event)\"\n >\n </app-webcam>\n </ng-container>\n <div\n fxLayout=\"row\"\n fxFlex\n class=\"previewData\"\n *ngIf=\"preview\"\n style=\"z-index: 20; position: absolute; width: 100%; height: 100%\"\n >\n <div\n class=\"scanPreview\"\n fxFlex\n fxLayout=\"column\"\n *ngIf=\"!error && !scaning\"\n >\n <div\n fxFlex\n class=\"image\"\n [style.background-image]=\"'url(' + preview + ')'\"\n ></div>\n </div>\n </div>\n </div>\n\n <footer fxLayout=\"row\" class=\"p-8\">\n <button\n [disabled]=\"!cameraReady\"\n class=\"w-100-p\"\n *ngIf=\"!preview\"\n mat-raised-button\n (click)=\"scan()\"\n >\n <ng-container>\n TAKE SELFIE\n </ng-container>\n </button>\n\n <div\n class=\"w-100-p\"\n *ngIf=\"preview\"\n fxLayout=\"row\"\n fxLayoutAlign=\"start center\"\n fxFlex\n >\n <button fxFlex class=\"mr-4\" mat-raised-button (click)=\"retry()\">\n RETRY\n </button>\n\n <button\n [disabled]=\"error\"\n fxFlex\n class=\"ml-4\"\n mat-raised-button\n (click)=\"continue()\"\n >\n CONTINUE\n\n </button>\n </div>\n </footer>\n</div>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1;background-color:#f5f5f5}.element{margin-bottom:8px}.element label{font-size:14px}.element div{font-size:18px}.wraper{position:relative;overflow:hidden}h3{color:#459ae5;font-size:16px}.preview{width:100%;border-radius:1%}.documentTypeWraper{width:400px}.documentTypeWraper .label{font-size:14px;margin-bottom:20px}.documentTypeWraper button{box-shadow:none}.overPane{position:absolute;width:100%;height:100%;top:0;left:0}.overPane app-webcam{clip-path:url(#myClip)}.subhead{height:55px;padding-top:8px}.rectangle{z-index:2;position:absolute;top:50%;left:50%;width:85.6mm;height:53.98mm;transform:translate(-50%,-50%);box-sizing:border-box;border:2px dashed #459be5;border-radius:3mm}.mask{z-index:1;position:absolute;width:100%;height:100%;background-position:center center;background-size:380mm;background-repeat:no-repeat}.label{font-size:11px;margin-top:4px}footer button{box-shadow:none!important;height:45px;min-height:45px;border:1px solid rgba(0,0,0,.12);text-transform:uppercase}h4{font-size:16px}.images label{font-size:11px;color:#888;line-height:20px}.images .title{padding:8px 0;font-weight:600}.images img{margin-bottom:16px}.error .title{font-size:22px}.error ul{font-size:18px}.photo{width:120px;height:120px;overflow:hidden}.signature{width:200px}mat-card{box-shadow:none!important}.scanBlastWraper button{text-transform:uppercase}.scanBlastWraper.mobile mat-card{margin:4px!important}.scanBlastWraper.mobile .description{font-size:12px;flex-direction:row!important}.scanBlastWraper.mobile .description .imgWrap{padding:0!important}.scanBlastWraper.mobile .description .btnActions{position:absolute;right:0}.scanBlastWraper.mobile .description button{font-size:11px!important;margin:0!important;position:absolute;right:16px}.scanBlastWraper.mobile .description button.rotateButton{top:58px}.scanBlastWraper.mobile .description button.remButton{top:8px}.scanBlastWraper.mobile .description button mat-icon{margin:0!important}.scanBlastWraper.mobile .description button div.label{display:none}.mobile .scanBlast button{font-size:11px!important}.scanBlast{display:flex;flex-direction:row;flex:1;padding:0 4px}.scanBlast mat-card{padding:0;box-shadow:none;margin:8px 4px;flex:1}.scanBlast mat-card .head{display:flex;flex-direction:row;align-items:center;justify-items:center;border-bottom:1px solid rgba(0,0,0,.12);height:60px;padding:8px}.scanBlast mat-card .head.small{height:30px!important;padding:4px 8px!important}.scanBlast mat-card .head.small .title{font-size:12px!important;margin-left:4px!important}.scanBlast mat-card .head button{max-width:120px;height:40px;box-shadow:none;border:1px solid rgba(0,0,0,.12)}.scanBlast mat-card .head .title{margin-left:16px;color:#459ae5;font-size:16px}.scanBlast mat-card .content{margin:8px;flex:1}.scanBlast mat-card .description{text-align:center;color:#888;font-size:14px}.scanBlast mat-card .actions{background-color:#e9e9e9;display:flex;flex-direction:row}.scanBlast mat-card .actions .mat-button-disabled{background-color:#fff!important}.scanBlast mat-card .actions button{box-shadow:none;width:50%;margin:8px;height:40px;font-size:12px}.scanBlast mat-card .actions button mat-icon{margin-right:8px}.scanBlast mat-card .previewPlaceholder{flex:1;border-radius:6px;display:flex;flex-direction:column}.scanBlast mat-card .previewPlaceholder .description{display:flex;flex:1;flex-direction:column;justify-content:center}.scanBlast mat-card .previewPlaceholder button{box-shadow:none;margin-top:8px;height:40px;font-size:12px}.scanBlast mat-card .previewPlaceholder button mat-icon{margin-right:8px}.scanBlast mat-card .previewPlaceholder .imgWrap{flex-direction:column;flex:1;padding:8px;background-color:#f5f5f5;border-radius:4px}.scanBlast mat-card .previewPlaceholder .imgWrap img{width:100%;border-radius:4px}.scanBlast mat-card .previewPlaceholder .imgWrap .image{background-position:center;background-repeat:no-repeat;background-size:contain}.mr-4{margin-right:4px}.ml-4{margin-left:4px}.p-16{padding:16px}.p-8{padding:8px}.py-16{padding:16px 0}.w-100-p{width:100%}.scanPreview{padding:16px}.scanPreview .image{background-position:center;background-repeat:no-repeat;background-size:contain}.empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center}.summary label{font-size:12px;color:#888;margin-top:2px}.summary .name{font-size:14px}.selfieContainer{display:flex;flex-direction:column;margin-bottom:20px}.selfieContainer button{box-shadow:none;border:1px solid rgba(0,0,0,.12)}.selfieContainer .selfie{margin:8px auto;width:120px;height:120px;border-radius:60px;border:1px solid rgba(0,0,0,.12)}\n", ".page-header{z-index:2000;height:64px;padding:0;background-color:#fff;border-bottom:1px solid rgba(0,0,0,.12)}.page-header .title{padding-left:24px;line-height:64px;font-size:18px}.page-header .separator{width:1px;background-color:#0000001f;height:100%}.page-header .total{line-height:64px}.page-header .total span{font-weight:700}.page-footer{height:64px}.page-footer button{margin-left:24px;box-shadow:none!important}\n"], dependencies: [{ kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i4$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4$1.MatLabel, selector: "mat-label" }, { kind: "component", type: i5$2.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i6$1.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i7$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i9.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: WebcamComponent, selector: "app-webcam", inputs: ["imageHandler", "id", "type", "width", "height", "videoOptions", "allowCameraSwitch", "mirrorImage", "captureImageData", "imageType", "imageQuality", "trigger", "switchCamera"], outputs: ["imageCapture", "initError", "imageClick", "cameraSwitched", "videoReady", "destroyed"] }, { kind: "directive", type: i4$2.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i4$2.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { kind: "directive", type: i4$2.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "directive", type: i5$3.DefaultClassDirective, selector: " [ngClass], [ngClass.xs], [ngClass.sm], [ngClass.md], [ngClass.lg], [ngClass.xl], [ngClass.lt-sm], [ngClass.lt-md], [ngClass.lt-lg], [ngClass.lt-xl], [ngClass.gt-xs], [ngClass.gt-sm], [ngClass.gt-md], [ngClass.gt-lg]", inputs: ["ngClass", "ngClass.xs", "ngClass.sm", "ngClass.md", "ngClass.lg", "ngClass.xl", "ngClass.lt-sm", "ngClass.lt-md", "ngClass.lt-lg", "ngClass.lt-xl", "ngClass.gt-xs", "ngClass.gt-sm", "ngClass.gt-md", "ngClass.gt-lg"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3804
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanSelfieComponent, decorators: [{
3805
+ type: Component,
3806
+ args: [{ selector: 'app-scan-selfie', changeDetection: ChangeDetectionStrategy.OnPush, template: "<header class=\"page-header\" fxLayout=\"row\">\n <div class=\"title\" ngClass.lt-sm=\"title-small\">Selfie</div>\n\n <span fxFlex></span>\n <ng-container\n *ngIf=\"\n documentTypeSelected &&\n !result &&\n !error &&\n multipleWebcamsAvailable &&\n !preview\n \"\n >\n <div class=\"separator\"></div>\n <div style=\"padding: 0px 16px\">\n <div fxLayout=\"row\" fxLayoutAlign=\"end center\">\n <mat-form-field\n style=\"font-size: 14px; width: 200px; margin-top: 8px\"\n class=\"w-200 mr-16 mt-8\"\n >\n <mat-label> Camera </mat-label>\n <mat-select\n (selectionChange)=\"selectCamera($event)\"\n [(ngModel)]=\"deviceId\"\n >\n <mat-option\n *ngFor=\"let device of mediaDevices\"\n [value]=\"device.deviceId\"\n >\n {{ device.label }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n </div>\n </ng-container>\n\n <ng-container>\n <div class=\"separator\"></div>\n\n <button mat-button (click)=\"close()\">\n <mat-icon>close</mat-icon>\n </button>\n </ng-container>\n <!-- <ng-container *ngIf=\"type === 'desktop'\">\n <div class=\"separator\"></div>\n <button mat-button (click)=\"sendMobile()\">\n <mat-icon>tablet_mac</mat-icon>\n </button>\n\n <div class=\"separator\"></div>\n\n <button mat-button (click)=\"close()\">\n <mat-icon>close</mat-icon>\n </button>\n </ng-container> -->\n</header>\n\n<div *ngIf=\"!result\" fxFlex fxLayout=\"column\">\n <div fxFlex #wraper class=\"wraper\" fxLayout=\"row\">\n <div\n style=\"\n position: absolute;\n top: 0px;\n left: 0px;\n right: 0px;\n bottom: 0px;\n z-index: 20;\n background-color: whitesmoke;\n \"\n *ngIf=\"!cameraReady && !preview\"\n >\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n </div>\n\n <ng-container *ngIf=\"!error\">\n <!-- <div\n class=\"rectangle\"\n [ngStyle]=\"{\n 'width.px': videoHeight * 0.75 * 1.588,\n 'height.px': videoHeight * 0.75\n }\"\n ></div>\n <svg\n *ngIf=\"videoWidth\"\n style=\"position: absolute; left: 0px; top: 0px\"\n width=\"0\"\n height=\"0\"\n >\n <defs>\n <clipPath id=\"myClip\">\n <rect\n stroke-width=\"6\"\n stroke-color=\"red\"\n [attr.x]=\"(videoWidth - videoHeight * 0.75 * 1.588) / 2\"\n [attr.y]=\"(videoHeight * 0.25) / 2\"\n [attr.width]=\"videoHeight * 0.75 * 1.588\"\n [attr.height]=\"videoHeight * 0.75\"\n rx=\"25\"\n />\n </clipPath>\n </defs>\n </svg> -->\n\n <app-webcam\n *ngIf=\"!preview && !scaning\"\n class=\"main\"\n [imageQuality]=\"1\"\n #webcam\n fxFlex\n [trigger]=\"trigger\"\n (imageCapture)=\"handleImage($event)\"\n [allowCameraSwitch]=\"allowCameraSwitch\"\n [videoOptions]=\"videoOptions\"\n [switchCamera]=\"nextWebcamObservable\"\n (cameraSwitched)=\"cameraWasSwitched($event)\"\n (initError)=\"handleInitError($event)\"\n type=\"selfie\"\n [width]=\"width\"\n [height]=\"height\"\n (destroyed)=\"cameraOff($event)\"\n >\n </app-webcam>\n </ng-container>\n <div\n fxLayout=\"row\"\n fxFlex\n class=\"previewData\"\n *ngIf=\"preview\"\n style=\"z-index: 20; position: absolute; width: 100%; height: 100%\"\n >\n <div\n class=\"scanPreview\"\n fxFlex\n fxLayout=\"column\"\n *ngIf=\"!error && !scaning\"\n >\n <div\n fxFlex\n class=\"image\"\n [style.background-image]=\"'url(' + preview + ')'\"\n ></div>\n </div>\n </div>\n </div>\n\n <footer fxLayout=\"row\" class=\"p-8\">\n <button\n [disabled]=\"!cameraReady\"\n class=\"w-100-p\"\n *ngIf=\"!preview\"\n mat-raised-button\n (click)=\"scan()\"\n >\n <ng-container>\n TAKE SELFIE\n </ng-container>\n </button>\n\n <div\n class=\"w-100-p\"\n *ngIf=\"preview\"\n fxLayout=\"row\"\n fxLayoutAlign=\"start center\"\n fxFlex\n >\n <button fxFlex class=\"mr-4\" mat-raised-button (click)=\"retry()\">\n RETRY\n </button>\n\n <button\n [disabled]=\"error\"\n fxFlex\n class=\"ml-4\"\n mat-raised-button\n (click)=\"continue()\"\n >\n CONTINUE\n\n </button>\n </div>\n </footer>\n</div>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1;background-color:#f5f5f5}.element{margin-bottom:8px}.element label{font-size:14px}.element div{font-size:18px}.wraper{position:relative;overflow:hidden}h3{color:#459ae5;font-size:16px}.preview{width:100%;border-radius:1%}.documentTypeWraper{width:400px}.documentTypeWraper .label{font-size:14px;margin-bottom:20px}.documentTypeWraper button{box-shadow:none}.overPane{position:absolute;width:100%;height:100%;top:0;left:0}.overPane app-webcam{clip-path:url(#myClip)}.subhead{height:55px;padding-top:8px}.rectangle{z-index:2;position:absolute;top:50%;left:50%;width:85.6mm;height:53.98mm;transform:translate(-50%,-50%);box-sizing:border-box;border:2px dashed #459be5;border-radius:3mm}.mask{z-index:1;position:absolute;width:100%;height:100%;background-position:center center;background-size:380mm;background-repeat:no-repeat}.label{font-size:11px;margin-top:4px}footer button{box-shadow:none!important;height:45px;min-height:45px;border:1px solid rgba(0,0,0,.12);text-transform:uppercase}h4{font-size:16px}.images label{font-size:11px;color:#888;line-height:20px}.images .title{padding:8px 0;font-weight:600}.images img{margin-bottom:16px}.error .title{font-size:22px}.error ul{font-size:18px}.photo{width:120px;height:120px;overflow:hidden}.signature{width:200px}mat-card{box-shadow:none!important}.scanBlastWraper button{text-transform:uppercase}.scanBlastWraper.mobile mat-card{margin:4px!important}.scanBlastWraper.mobile .description{font-size:12px;flex-direction:row!important}.scanBlastWraper.mobile .description .imgWrap{padding:0!important}.scanBlastWraper.mobile .description .btnActions{position:absolute;right:0}.scanBlastWraper.mobile .description button{font-size:11px!important;margin:0!important;position:absolute;right:16px}.scanBlastWraper.mobile .description button.rotateButton{top:58px}.scanBlastWraper.mobile .description button.remButton{top:8px}.scanBlastWraper.mobile .description button mat-icon{margin:0!important}.scanBlastWraper.mobile .description button div.label{display:none}.mobile .scanBlast button{font-size:11px!important}.scanBlast{display:flex;flex-direction:row;flex:1;padding:0 4px}.scanBlast mat-card{padding:0;box-shadow:none;margin:8px 4px;flex:1}.scanBlast mat-card .head{display:flex;flex-direction:row;align-items:center;justify-items:center;border-bottom:1px solid rgba(0,0,0,.12);height:60px;padding:8px}.scanBlast mat-card .head.small{height:30px!important;padding:4px 8px!important}.scanBlast mat-card .head.small .title{font-size:12px!important;margin-left:4px!important}.scanBlast mat-card .head button{max-width:120px;height:40px;box-shadow:none;border:1px solid rgba(0,0,0,.12)}.scanBlast mat-card .head .title{margin-left:16px;color:#459ae5;font-size:16px}.scanBlast mat-card .content{margin:8px;flex:1}.scanBlast mat-card .description{text-align:center;color:#888;font-size:14px}.scanBlast mat-card .actions{background-color:#e9e9e9;display:flex;flex-direction:row}.scanBlast mat-card .actions .mat-button-disabled{background-color:#fff!important}.scanBlast mat-card .actions button{box-shadow:none;width:50%;margin:8px;height:40px;font-size:12px}.scanBlast mat-card .actions button mat-icon{margin-right:8px}.scanBlast mat-card .previewPlaceholder{flex:1;border-radius:6px;display:flex;flex-direction:column}.scanBlast mat-card .previewPlaceholder .description{display:flex;flex:1;flex-direction:column;justify-content:center}.scanBlast mat-card .previewPlaceholder button{box-shadow:none;margin-top:8px;height:40px;font-size:12px}.scanBlast mat-card .previewPlaceholder button mat-icon{margin-right:8px}.scanBlast mat-card .previewPlaceholder .imgWrap{flex-direction:column;flex:1;padding:8px;background-color:#f5f5f5;border-radius:4px}.scanBlast mat-card .previewPlaceholder .imgWrap img{width:100%;border-radius:4px}.scanBlast mat-card .previewPlaceholder .imgWrap .image{background-position:center;background-repeat:no-repeat;background-size:contain}.mr-4{margin-right:4px}.ml-4{margin-left:4px}.p-16{padding:16px}.p-8{padding:8px}.py-16{padding:16px 0}.w-100-p{width:100%}.scanPreview{padding:16px}.scanPreview .image{background-position:center;background-repeat:no-repeat;background-size:contain}.empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center}.summary label{font-size:12px;color:#888;margin-top:2px}.summary .name{font-size:14px}.selfieContainer{display:flex;flex-direction:column;margin-bottom:20px}.selfieContainer button{box-shadow:none;border:1px solid rgba(0,0,0,.12)}.selfieContainer .selfie{margin:8px auto;width:120px;height:120px;border-radius:60px;border:1px solid rgba(0,0,0,.12)}\n", ".page-header{z-index:2000;height:64px;padding:0;background-color:#fff;border-bottom:1px solid rgba(0,0,0,.12)}.page-header .title{padding-left:24px;line-height:64px;font-size:18px}.page-header .separator{width:1px;background-color:#0000001f;height:100%}.page-header .total{line-height:64px}.page-header .total span{font-weight:700}.page-footer{height:64px}.page-footer button{margin-left:24px;box-shadow:none!important}\n"] }]
3807
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: ScanProvider }, { type: DialogsCoreProvider }, { type: i1$2.TranslateService }]; }, propDecorators: { type: [{
3808
+ type: Input
3809
+ }], actions: [{
3810
+ type: Output
3811
+ }], wraper: [{
3812
+ type: ViewChild,
3813
+ args: ['wraper']
3814
+ }], onResize: [{
3815
+ type: HostListener,
3816
+ args: ['window:resize', ['$event']]
3817
+ }] } });
3818
+
3819
+ class TurnDocumentComponent {
3820
+ constructor(dialogRef, data) {
3821
+ this.dialogRef = dialogRef;
3822
+ this.data = data;
3823
+ }
3824
+ ngOnInit() {
3825
+ console.log(this.data);
3826
+ }
3827
+ close() {
3828
+ console.log(this.dialogRef);
3829
+ this.dialogRef.close();
3830
+ }
3831
+ }
3832
+ TurnDocumentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TurnDocumentComponent, deps: [{ token: i1$4.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
3833
+ TurnDocumentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: TurnDocumentComponent, selector: "app-turndocuments", ngImport: i0, template: "<div class=\"inner\" fxLayout=\"column\" fxLayoutAlign=\"center center\">\n <!-- <img\n style=\"height: 240px; margin: 34px 0px;display: none;\"\n [src]=\"'/assets/images/illustrations/' + images[type]\"\n /> -->\n <!-- <img style=\"width:60px;\" src=\"/assets/images/illustrations/door-lock.png\"> -->\n\n <mat-icon>360</mat-icon>\n <div class=\"text\">\n <ng-container *ngIf=\"data.idScan === 'BACK'\">\n Turn document and:\n {{ \"pms.dialogs.components.scanProfile.captureBack\" | translate }}\n </ng-container>\n <ng-container *ngIf=\"data.idScan === 'FRONT'\">\n Turn document and:\n {{ \"pms.dialogs.components.scanProfile.captureFront\" | translate }}\n </ng-container>\n </div>\n</div>\n\n<!-- -->\n\n<footer>\n <button (click)=\"close()\" mat-raised-button>Ok</button>\n</footer>\n", styles: [":host{display:flex;flex-direction:column;flex:1;height:100%;width:100%}.inner{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:30px 20px 0}.inner mat-icon{width:60px;height:60px;font-size:60px}.inner .text{margin:20px 0}footer{display:flex;flex-direction:row;align-items:center;justify-content:center;padding-bottom:20px}footer button{min-width:200px;box-shadow:none;border:1px solid #ccc}\n"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i7$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i4$2.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i4$2.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { kind: "pipe", type: i1$2.TranslatePipe, name: "translate" }] });
3834
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TurnDocumentComponent, decorators: [{
3835
+ type: Component,
3836
+ args: [{ selector: 'app-turndocuments', template: "<div class=\"inner\" fxLayout=\"column\" fxLayoutAlign=\"center center\">\n <!-- <img\n style=\"height: 240px; margin: 34px 0px;display: none;\"\n [src]=\"'/assets/images/illustrations/' + images[type]\"\n /> -->\n <!-- <img style=\"width:60px;\" src=\"/assets/images/illustrations/door-lock.png\"> -->\n\n <mat-icon>360</mat-icon>\n <div class=\"text\">\n <ng-container *ngIf=\"data.idScan === 'BACK'\">\n Turn document and:\n {{ \"pms.dialogs.components.scanProfile.captureBack\" | translate }}\n </ng-container>\n <ng-container *ngIf=\"data.idScan === 'FRONT'\">\n Turn document and:\n {{ \"pms.dialogs.components.scanProfile.captureFront\" | translate }}\n </ng-container>\n </div>\n</div>\n\n<!-- -->\n\n<footer>\n <button (click)=\"close()\" mat-raised-button>Ok</button>\n</footer>\n", styles: [":host{display:flex;flex-direction:column;flex:1;height:100%;width:100%}.inner{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:30px 20px 0}.inner mat-icon{width:60px;height:60px;font-size:60px}.inner .text{margin:20px 0}footer{display:flex;flex-direction:row;align-items:center;justify-content:center;padding-bottom:20px}footer button{min-width:200px;box-shadow:none;border:1px solid #ccc}\n"] }]
3837
+ }], ctorParameters: function () { return [{ type: i1$4.MatDialogRef }, { type: undefined, decorators: [{
3838
+ type: Inject,
3839
+ args: [MAT_DIALOG_DATA]
3840
+ }] }]; } });
3841
+
3842
+ class DialogsCoreProvider {
3843
+ constructor(matDialog) {
3844
+ this.matDialog = matDialog;
3845
+ this.components = {
3846
+ ScanProfile: { component: ScanProfileComponent },
3847
+ Loading: { component: LoadingComponent },
3848
+ ConfirmComponent: { component: ConfirmComponent },
3849
+ TurnDocumentComponent: { component: TurnDocumentComponent },
3850
+ ScanSelfie: { component: ScanSelfieComponent },
3851
+ };
3852
+ this.blank = BlankComponent;
3853
+ }
3854
+ getComponent(name) {
3855
+ if (!this.components[name]) {
3856
+ console.warn('Component missing', name, this.components);
3857
+ }
3858
+ return this.components[name].component;
3859
+ }
3860
+ open(config, withComponent = true) {
3861
+ // console.log(config);
3862
+ const panelClass = config.panelClass ? config.panelClass : config.name;
3863
+ const component = this.getComponent(config.name);
3864
+ const dialogRef = this.matDialog.open(this.blank, {
3865
+ panelClass,
3866
+ data: {
3867
+ data: config.data,
3868
+ withComponent,
3869
+ component,
3870
+ },
3871
+ autoFocus: false,
3872
+ width: config.width || '',
3873
+ height: config.height || '',
3874
+ maxWidth: config.maxWidth || '',
3875
+ minWidth: config.minWidth || '',
3876
+ maxHeight: config.maxHeight || '',
3877
+ minHeight: config.minHeight || '',
3878
+ position: config.position || {},
3879
+ hasBackdrop: config.hasBackdrop === undefined ? true : config.hasBackdrop,
3880
+ disableClose: config.disableClose === undefined ? true : config.disableClose,
3881
+ });
3882
+ return dialogRef;
3883
+ }
3884
+ scanProfile(data) {
3885
+ return this.open({
3886
+ name: 'ScanProfile',
3887
+ panelClass: 'ScanProfileComponent',
3888
+ data,
3889
+ });
3890
+ }
3891
+ // Generic loading dialog
3892
+ loading(title = '') {
3893
+ return this.open({
3894
+ name: 'Loading',
3895
+ data: { title },
3896
+ });
3897
+ }
3898
+ alert(title, text) {
3899
+ return this.open({
3900
+ name: 'ConfirmComponent',
3901
+ maxWidth: '600px',
3902
+ panelClass: 'DialogNoPadding',
3903
+ minWidth: '440px',
3904
+ data: { title, text, alert: true },
3905
+ });
3906
+ }
3907
+ turnDocument(idScan) {
3908
+ return this.open({
3909
+ name: 'TurnDocumentComponent',
3910
+ maxWidth: '400px',
3911
+ panelClass: 'DialogNoPadding',
3912
+ minWidth: '300px',
3913
+ data: { idScan },
3914
+ }).afterClosed();
3915
+ }
3916
+ // public scanMobile(data: any) {
3917
+ // return this.open({
3918
+ // name: 'ScanMobileComponent',
3919
+ // maxWidth: '600px',
3920
+ // panelClass: 'DialogNoPadding',
3921
+ // minWidth: '440px',
3922
+ // data,
3923
+ // });
3924
+ // }
3925
+ scanSelfie(data) {
3926
+ return this.open({
3927
+ name: 'ScanSelfie',
3928
+ panelClass: 'ScanProfileComponent',
3929
+ data,
3930
+ });
3931
+ }
3932
+ }
3933
+ DialogsCoreProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogsCoreProvider, deps: [{ token: i1$4.MatDialog }], target: i0.ɵɵFactoryTarget.Injectable });
3934
+ DialogsCoreProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogsCoreProvider, providedIn: 'root' });
3935
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogsCoreProvider, decorators: [{
3936
+ type: Injectable,
3937
+ args: [{
3938
+ providedIn: 'root',
3939
+ }]
3940
+ }], ctorParameters: function () { return [{ type: i1$4.MatDialog }]; } });
3941
+
3942
+ class ScanProfileComponent extends BaseComponent {
3943
+ constructor(dialogs, dialogRef) {
3944
+ super();
3945
+ this.dialogs = dialogs;
3946
+ this.dialogRef = dialogRef;
3947
+ this.type = 'desktop';
3948
+ this.showDialog = false;
3949
+ }
3950
+ ngAfterViewInit() { }
3951
+ ngOnDestroy() {
3952
+ this.__destroy();
3953
+ console.log('DES');
3954
+ }
3955
+ actions(event) {
3956
+ console.log(event);
3957
+ switch (event.type) {
3958
+ case 'turnDocumentOver':
3959
+ this.dialogs.turnDocument(event.side).subscribe(() => {
3960
+ this.showDialog = false;
3961
+ });
3962
+ break;
3963
+ }
3964
+ }
3965
+ close() {
3966
+ this.dialogRef?.close();
3967
+ }
3968
+ }
3969
+ ScanProfileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanProfileComponent, deps: [{ token: DialogsCoreProvider }, { token: i1$4.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
3970
+ ScanProfileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ScanProfileComponent, selector: "app-scan-profile", inputs: { type: "type" }, usesInheritance: true, ngImport: i0, template: "<header class=\"page-header\">\n <div class=\"title\" ngClass.lt-sm=\"title-small\">Scan</div>\n\n <span fxFlex></span>\n\n <!-- <mat-slide-toggle style=\"margin:0px 20px\" [(ngModel)]=\"isDebug\"\n >Debug</mat-slide-toggle\n > -->\n\n <ng-container\n\n >\n <div class=\"separator\"></div>\n <div style=\"padding: 0px 16px\">\n <div fxLayout=\"row\" fxLayoutAlign=\"end center\">\n <ngx-scan-camera-switch></ngx-scan-camera-switch>\n </div>\n </div>\n </ng-container>\n\n <ng-container *ngIf=\"type === 'desktop'\">\n <!-- <div class=\"separator\"></div>\n <button mat-button (click)=\"sendMobile()\">\n <mat-icon>tablet_mac</mat-icon>\n </button> -->\n\n <div class=\"separator\"></div>\n\n <button mat-button (click)=\"close()\">\n <mat-icon>close</mat-icon>\n </button>\n </ng-container>\n</header>\n\n<ngx-scan (actions)=\"actions($event)\" [showDialog]=\"showDialog\" [dialogs]=\"dialogs\"></ngx-scan>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1;background-color:#f5f5f5;overflow:hidden}.page-header{display:flex;flex-direction:row;align-items:center}.page-header button{height:100%}\n", ".page-header{z-index:2000;height:64px;padding:0;background-color:#fff;border-bottom:1px solid rgba(0,0,0,.12)}.page-header .title{padding-left:24px;line-height:64px;font-size:18px}.page-header .separator{width:1px;background-color:#0000001f;height:100%}.page-header .total{line-height:64px}.page-header .total span{font-weight:700}.page-footer{height:64px}.page-footer button{margin-left:24px;box-shadow:none!important}\n"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i7$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: ScanComponent, selector: "ngx-scan", inputs: ["type", "dialogs", "showDialog"], outputs: ["actions"] }, { kind: "component", type: CameraSwitchComponent, selector: "ngx-scan-camera-switch" }, { kind: "directive", type: i4$2.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i4$2.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { kind: "directive", type: i4$2.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "directive", type: i5$3.DefaultClassDirective, selector: " [ngClass], [ngClass.xs], [ngClass.sm], [ngClass.md], [ngClass.lg], [ngClass.xl], [ngClass.lt-sm], [ngClass.lt-md], [ngClass.lt-lg], [ngClass.lt-xl], [ngClass.gt-xs], [ngClass.gt-sm], [ngClass.gt-md], [ngClass.gt-lg]", inputs: ["ngClass", "ngClass.xs", "ngClass.sm", "ngClass.md", "ngClass.lg", "ngClass.xl", "ngClass.lt-sm", "ngClass.lt-md", "ngClass.lt-lg", "ngClass.lt-xl", "ngClass.gt-xs", "ngClass.gt-sm", "ngClass.gt-md", "ngClass.gt-lg"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3971
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScanProfileComponent, decorators: [{
3972
+ type: Component,
3973
+ args: [{ selector: 'app-scan-profile', changeDetection: ChangeDetectionStrategy.OnPush, template: "<header class=\"page-header\">\n <div class=\"title\" ngClass.lt-sm=\"title-small\">Scan</div>\n\n <span fxFlex></span>\n\n <!-- <mat-slide-toggle style=\"margin:0px 20px\" [(ngModel)]=\"isDebug\"\n >Debug</mat-slide-toggle\n > -->\n\n <ng-container\n\n >\n <div class=\"separator\"></div>\n <div style=\"padding: 0px 16px\">\n <div fxLayout=\"row\" fxLayoutAlign=\"end center\">\n <ngx-scan-camera-switch></ngx-scan-camera-switch>\n </div>\n </div>\n </ng-container>\n\n <ng-container *ngIf=\"type === 'desktop'\">\n <!-- <div class=\"separator\"></div>\n <button mat-button (click)=\"sendMobile()\">\n <mat-icon>tablet_mac</mat-icon>\n </button> -->\n\n <div class=\"separator\"></div>\n\n <button mat-button (click)=\"close()\">\n <mat-icon>close</mat-icon>\n </button>\n </ng-container>\n</header>\n\n<ngx-scan (actions)=\"actions($event)\" [showDialog]=\"showDialog\" [dialogs]=\"dialogs\"></ngx-scan>\n", styles: [":host{display:flex;flex-direction:column!important;flex:1;background-color:#f5f5f5;overflow:hidden}.page-header{display:flex;flex-direction:row;align-items:center}.page-header button{height:100%}\n", ".page-header{z-index:2000;height:64px;padding:0;background-color:#fff;border-bottom:1px solid rgba(0,0,0,.12)}.page-header .title{padding-left:24px;line-height:64px;font-size:18px}.page-header .separator{width:1px;background-color:#0000001f;height:100%}.page-header .total{line-height:64px}.page-header .total span{font-weight:700}.page-footer{height:64px}.page-footer button{margin-left:24px;box-shadow:none!important}\n"] }]
3974
+ }], ctorParameters: function () { return [{ type: DialogsCoreProvider }, { type: i1$4.MatDialogRef }]; }, propDecorators: { type: [{
3975
+ type: Input
3976
+ }] } });
3977
+
3978
+ class DialogsModule {
3979
+ }
3980
+ DialogsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3981
+ DialogsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: DialogsModule, declarations: [ScanProfileComponent,
3982
+ BlankComponent,
3983
+ LoadingComponent,
3984
+ ConfirmComponent,
3985
+ TurnDocumentComponent,
3986
+ ScanSelfieComponent], imports: [QRCodeModule,
3987
+ ReactiveFormsModule,
3988
+ CommonModule,
3989
+ FormsModule,
3990
+ AppFormModule,
3991
+ TranslateModule,
3992
+ MaterialModule,
3993
+ CoreComponentsModule,
3994
+ CorePipesModule,
3995
+ FlexModule,
3996
+ FlexLayoutModule], exports: [ScanProfileComponent,
3997
+ LoadingComponent,
3998
+ BlankComponent,
3999
+ TurnDocumentComponent,
4000
+ MaterialModule,
4001
+ ScanSelfieComponent] });
4002
+ DialogsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogsModule, providers: [DialogsCoreProvider], imports: [QRCodeModule,
4003
+ ReactiveFormsModule,
4004
+ CommonModule,
4005
+ FormsModule,
4006
+ AppFormModule,
4007
+ TranslateModule,
4008
+ MaterialModule,
4009
+ CoreComponentsModule,
4010
+ CorePipesModule,
4011
+ FlexModule,
4012
+ FlexLayoutModule, MaterialModule] });
4013
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogsModule, decorators: [{
4014
+ type: NgModule,
4015
+ args: [{
4016
+ declarations: [
4017
+ ScanProfileComponent,
4018
+ BlankComponent,
4019
+ LoadingComponent,
4020
+ ConfirmComponent,
4021
+ TurnDocumentComponent,
4022
+ ScanSelfieComponent,
4023
+ ],
4024
+ exports: [
4025
+ ScanProfileComponent,
4026
+ LoadingComponent,
4027
+ BlankComponent,
4028
+ TurnDocumentComponent,
4029
+ MaterialModule,
4030
+ ScanSelfieComponent,
4031
+ ],
4032
+ imports: [
4033
+ QRCodeModule,
4034
+ ReactiveFormsModule,
4035
+ CommonModule,
4036
+ FormsModule,
4037
+ AppFormModule,
4038
+ TranslateModule,
4039
+ MaterialModule,
4040
+ CoreComponentsModule,
4041
+ CorePipesModule,
4042
+ FlexModule,
4043
+ FlexLayoutModule,
4044
+ ],
4045
+ providers: [DialogsCoreProvider],
4046
+ }]
4047
+ }] });
4048
+
4049
+ class HttpErrorInterceptor {
4050
+ constructor(injector) {
4051
+ this.injector = injector;
4052
+ }
4053
+ intercept(req, next) {
4054
+ //console.log(req.url);
4055
+ if (req.url.indexOf('auth') >= 0 || req.url.indexOf('/assets/') >= 0) {
4056
+ return next.handle(req);
4057
+ }
4058
+ const authProvider = this.injector.get(AuthProvider);
4059
+ this.inflightAuthRequest = authProvider.accesToken;
4060
+ return this.inflightAuthRequest.pipe(share(), switchMap((token) => {
4061
+ // unset request inflight
4062
+ this.inflightAuthRequest = null;
4063
+ const transaction = req.headers.get('TransactionID');
4064
+ const authReq = req.clone({
4065
+ headers: this.getHeaders(token, transaction || ''),
4066
+ });
4067
+ return next.handle(authReq);
4068
+ }), catchError((err) => {
4069
+ let tokenExpired = false;
4070
+ if (err.errors) {
4071
+ const find = err.erros.find((es) => es.indexOf('Invalid token') > -1);
4072
+ tokenExpired = find ? true : false;
4073
+ }
4074
+ console.log(err);
4075
+ if (err.status === 401 || tokenExpired) {
4076
+ authProvider.resetToken();
4077
+ return this.intercept(req, next);
4078
+ }
4079
+ else {
4080
+ return throwError(() => new Error('' + (err && err.status ? ':' + err.status : '')));
4081
+ }
4082
+ }));
4083
+ }
4084
+ getHeaders(token, TransactionID) {
4085
+ if (TransactionID) {
4086
+ return new HttpHeaders({
4087
+ 'Content-Type': 'application/json',
4088
+ Authorization: token,
4089
+ TransactionID,
4090
+ });
4091
+ }
4092
+ return new HttpHeaders({
4093
+ 'Content-Type': 'application/json',
4094
+ Authorization: token,
4095
+ });
4096
+ }
4097
+ }
4098
+ HttpErrorInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HttpErrorInterceptor, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
4099
+ HttpErrorInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HttpErrorInterceptor });
4100
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HttpErrorInterceptor, decorators: [{
4101
+ type: Injectable
4102
+ }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
4103
+
4104
+ class webRtcProvider {
4105
+ constructor() {
4106
+ this.pc = new RTCPeerConnection();
4107
+ }
4108
+ connect(id = 1) {
4109
+ this.subject = webSocket('wss://localhost:3000?id=' + id);
4110
+ }
4111
+ setup() {
4112
+ this.connect(1);
4113
+ // try {
4114
+ // this.pc = new RTCPeerConnection({
4115
+ // iceServers: [
4116
+ // { urls: 'stun:stun.services.mozilla.com' },
4117
+ // { urls: 'stun:stun.l.google.com:19302' },
4118
+ // ],
4119
+ // });
4120
+ // } catch (error) {
4121
+ // console.log(error);
4122
+ // this.pc = new RTCPeerConnection({
4123
+ // iceServers: [
4124
+ // { urls: 'stun:stun.services.mozilla.com' },
4125
+ // { urls: 'stun:stun.l.google.com:19302' },
4126
+ // ],
4127
+ // });
4128
+ // }
4129
+ // this.pc.onicecandidate = (event) => {
4130
+ // event.candidate
4131
+ // ? this.sendMessage({ ice: event.candidate })
4132
+ // : console.log('Sent All Ice');
4133
+ // };
4134
+ // if (this.pc) {
4135
+ // from(this.pc.createOffer())
4136
+ // .pipe(switchMap((offer) => from(this.pc.setLocalDescription(offer))))
4137
+ // .subscribe((data: any) => {
4138
+ // this.sendMessage({
4139
+ // type: 'offer',
4140
+ // sdp: this.pc.localDescription,
4141
+ // });
4142
+ // });
4143
+ // }
4144
+ }
4145
+ sendMessage(data) {
4146
+ console.log(data);
4147
+ this.subject.next(JSON.stringify(data));
4148
+ }
4149
+ }
4150
+ webRtcProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: webRtcProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4151
+ webRtcProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: webRtcProvider, providedIn: 'root' });
4152
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: webRtcProvider, decorators: [{
4153
+ type: Injectable,
4154
+ args: [{
4155
+ providedIn: 'root',
4156
+ }]
4157
+ }], ctorParameters: function () { return []; } });
4158
+
4159
+ class NgxScandocModule {
4160
+ static forRoot(config) {
4161
+ return {
4162
+ ngModule: NgxScandocModule,
4163
+ providers: [
4164
+ AuthProvider,
4165
+ { provide: 'configAuth', useValue: config.auth },
4166
+ ScanProvider,
4167
+ { provide: 'config', useValue: config.scan },
4168
+ {
4169
+ provide: HTTP_INTERCEPTORS,
4170
+ useClass: HttpErrorInterceptor,
4171
+ multi: true,
4172
+ },
4173
+ ],
4174
+ };
4175
+ }
4176
+ }
4177
+ NgxScandocModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
4178
+ NgxScandocModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocModule, imports: [CoreComponentsModule, DialogsModule], exports: [CoreComponentsModule, DialogsModule] });
4179
+ NgxScandocModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocModule, imports: [CoreComponentsModule, DialogsModule, CoreComponentsModule, DialogsModule] });
4180
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgxScandocModule, decorators: [{
4181
+ type: NgModule,
4182
+ args: [{
4183
+ declarations: [],
4184
+ imports: [CoreComponentsModule, DialogsModule],
4185
+ exports: [CoreComponentsModule, DialogsModule],
51
4186
  }]
52
4187
  }] });
53
4188
 
@@ -59,5 +4194,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
59
4194
  * Generated bundle index. Do not edit.
60
4195
  */
61
4196
 
62
- export { NgxScandocComponent, NgxScandocModule, NgxScandocService };
4197
+ export { AppFormModule, AuthProvider, BlankComponent, CameraSwitchComponent, CoreComponentsModule, CorePipesModule, DialogsCoreProvider, DialogsModule, HttpErrorInterceptor, LoadingComponent, MaterialModule, NgxScandocModule, SafeResourceUrlPipe, ScanComponent, ScanFieldsProvider, ScanProfileComponent, ScanProvider, ScanSelfieComponent, TranslationProvider, TurnDocumentComponent, WebcamComponent, WebcamModule, webRtcProvider };
63
4198
  //# sourceMappingURL=ngx-scandoc.mjs.map