ngx-scandoc 0.0.1 → 1.0.1

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