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