@idscan/idvc2 3.12.1 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/idvc.js.gzip CHANGED
Binary file
package/dist/index.html CHANGED
@@ -1,20 +1,166 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta charset="utf-8"><title>Demo Pages</title><style>body {
2
- /*background: #eff3fc;*/
3
- background: #ffe4c4;
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta charset="utf-8"><title>Demo Pages</title><style>:root {
2
+ --demo-bg: #F4F5F8;
3
+ --demo-surface: #FFFFFF;
4
+ --demo-border: #E3E5EB;
5
+ --demo-text: #1C1C1C;
6
+ --demo-muted: #6B6E78;
7
+ --demo-accent: #3B6FE0;
8
+ --demo-accent-soft: #E9F0FD;
9
+ --demo-danger: #C4372B;
10
+ --demo-radius: 12px;
11
+ }
12
+ body {
13
+ margin: 0;
14
+ background: var(--demo-bg);
15
+ color: var(--demo-text);
16
+ font: 14px/1.4 Inter, Arial, "Helvetica Neue", Helvetica, sans-serif;
17
+ }
18
+ .container * {
19
+ box-sizing: border-box;
20
+ font-family: Inter, sans-serif;
21
+ }
22
+ .demo-header {
23
+ max-width: 920px;
24
+ margin: 0 auto;
25
+ padding: 20px 24px 0;
26
+ }
27
+ .demo-header h1 {
4
28
  margin: 0;
29
+ font-size: 20px;
30
+ font-weight: 600;
31
+ }
32
+ .demo-layout {
33
+ display: flex;
34
+ flex-direction: column;
35
+ align-items: center;
36
+ gap: 20px;
37
+ padding: 20px 24px 40px;
38
+ }
39
+ .demo-card,
40
+ .demo-panel {
41
+ background: var(--demo-surface);
42
+ border: 1px solid var(--demo-border);
43
+ border-radius: var(--demo-radius);
44
+ box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
45
+ }
46
+ .demo-card {
47
+ width: 100%;
48
+ max-width: 560px;
49
+ overflow: hidden;
50
+ }
51
+ .demo-panel {
52
+ display: grid;
53
+ grid-template-columns: repeat(3, minmax(0, 1fr));
54
+ width: 100%;
55
+ max-width: 920px;
56
+ box-sizing: border-box;
57
+ }
58
+ .demo-section {
59
+ padding: 14px 16px;
60
+ }
61
+ .demo-section + .demo-section {
62
+ border-left: 1px solid var(--demo-border);
63
+ }
64
+ .demo-section_wide {
65
+ grid-column: 1 / -1;
66
+ border-top: 1px solid var(--demo-border);
67
+ }
68
+ .demo-panel .demo-section_wide {
69
+ border-left: 0;
70
+ }
71
+ .demo-groups {
72
+ display: grid;
73
+ grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
74
+ gap: 14px 20px;
75
+ }
76
+ .demo-section h2 {
77
+ margin: 0 0 10px;
78
+ font-size: 12px;
79
+ font-weight: 600;
80
+ letter-spacing: 0.04em;
81
+ text-transform: uppercase;
82
+ color: var(--demo-muted);
83
+ }
84
+ .demo-section h3 {
85
+ margin: 0 0 6px;
86
+ font-size: 13px;
87
+ font-weight: 600;
88
+ }
89
+ .demo-section h3 small {
90
+ margin-left: 4px;
91
+ font-size: 12px;
92
+ font-weight: 400;
93
+ color: var(--demo-muted);
94
+ }
95
+ .demo-buttons {
96
+ display: flex;
97
+ flex-wrap: wrap;
98
+ gap: 6px;
99
+ }
100
+ .demo-panel button {
101
+ padding: 7px 12px;
102
+ border: 1px solid var(--demo-border);
103
+ border-radius: 8px;
104
+ background: var(--demo-surface);
105
+ color: var(--demo-text);
106
+ font: inherit;
107
+ font-size: 13px;
108
+ cursor: pointer;
109
+ transition: background-color 0.15s, border-color 0.15s, color 0.15s;
5
110
  }
6
- .container * {
7
- box-sizing: border-box;
8
- font-family: Inter, sans-serif;
111
+ .demo-panel button:hover {
112
+ border-color: #C9CDD6;
113
+ background: #F8F9FB;
114
+ }
115
+ .demo-panel button:focus-visible {
116
+ outline: 2px solid var(--demo-accent);
117
+ outline-offset: 2px;
118
+ }
119
+ .demo-panel button[aria-pressed="true"] {
120
+ position: relative;
121
+ border-color: var(--demo-accent);
122
+ background: var(--demo-accent-soft);
123
+ color: var(--demo-accent);
124
+ }
125
+ .demo-panel button.demo-danger {
126
+ color: var(--demo-danger);
127
+ }
128
+ .demo-panel button.demo-quiet {
129
+ border-style: dashed;
130
+ color: var(--demo-muted);
131
+ }
132
+ .demo-segmented {
133
+ display: inline-flex;
134
+ }
135
+ .demo-segmented button {
136
+ min-width: 48px;
137
+ }
138
+ .demo-segmented button:first-child {
139
+ border-radius: 8px 0 0 8px;
140
+ }
141
+ .demo-segmented button + button {
142
+ margin-left: -1px;
143
+ border-radius: 0 8px 8px 0;
144
+ }
145
+ @media (max-width: 720px) {
146
+ .demo-panel {
147
+ grid-template-columns: minmax(0, 1fr);
9
148
  }
10
- #control-buttons-container {
11
- margin-top: 25px;
12
- height: 100px;
149
+ .demo-section + .demo-section {
150
+ border-left: 0;
151
+ border-top: 1px solid var(--demo-border);
13
152
  }
14
- #control-buttons-container button {
15
- padding: 8px;
16
- font-size: 14px;
17
- }</style></head><body><div><div id="videoCapturingEl" class="container"></div></div><div id="control-buttons-container"><button id="btn">Show Spinner</button> <button id="btn-loader">Show Loader</button> <button id="btn-reload">Reload component</button> <button id="btn-remount">Remount component</button> <button id="btn-resetAllSteps">Reset All Steps</button> <button id="btn-reconfig">Change config</button> <button id="btn-reconfig1">Change config 1</button> <button id="btn-redocs">Change docTypes</button> <button id="btn-unmount">Unmount IDVC</button> <button id="btn-change-en">En</button> <button id="btn-change-es">Es</button></div><script type="module" src="idvc.js"></script><script type="module" src="langs.js"></script><script type="module">import IDVC, { prepareRequestDataForDiveApi } from './idvc.js'
153
+ .demo-groups {
154
+ grid-template-columns: minmax(0, 1fr);
155
+ }
156
+ }
157
+ @media (max-width: 480px) {
158
+ .demo-header,
159
+ .demo-layout {
160
+ padding-left: 16px;
161
+ padding-right: 16px;
162
+ }
163
+ }</style></head><body><header class="demo-header"><h1>IDVC demo</h1></header><main class="demo-layout"><div class="demo-card"><div id="videoCapturingEl" class="container"></div></div><section class="demo-panel" aria-label="Controls"><section class="demo-section"><h2>Component</h2><div class="demo-buttons"><button id="btn-reload">Reload</button> <button id="btn-remount">Remount</button> <button id="btn-resetAllSteps">Reset all steps</button> <button id="btn-unmount" class="demo-danger">Unmount</button></div></section><section class="demo-section"><h2>Config</h2><div class="demo-buttons"><button id="btn-reconfig">GreenCard + IntId, es</button> <button id="btn-reconfig1">PassportCard</button> <button id="btn-redocs">docTypes: PassportCard</button></div></section><section class="demo-section"><h2>Language</h2><div class="demo-segmented" role="group" aria-label="Language"><button id="btn-change-en" aria-pressed="true">En</button> <button id="btn-change-es" aria-pressed="false">Es</button></div></section><section class="demo-section demo-section_wide" id="loader-scenes-container"><h2>Loader</h2><div class="demo-groups"><div><h3>prepare <small>starting</small></h3><div class="demo-buttons"><button data-scene="prepare" data-top="Neural network is warming up" data-bottom="Document capture will be ready to use shortly...">Warm-up</button> <button data-scene="prepare" data-bottom="Preparing to work">Preparing to work</button> <button data-scene="prepare" data-bottom="Loading step">Loading step</button> <button data-scene="prepare" data-bottom="Mode is changing">Mode is changing</button> <button data-scene="prepare" data-bottom="Loading document">Loading document</button> <button data-scene="prepare" data-bottom="Resetting">Resetting</button></div></div><div><h3>check <small>processing</small></h3><div class="demo-buttons"><button data-scene="check" data-top="Document has been submitted for processing" data-bottom="Please wait for the response">Submit</button> <button data-scene="check" data-top="We are pre-validating your images" data-bottom="Please wait">Consent check</button></div></div><div><h3>send <small>sending</small></h3><div class="demo-buttons"><button data-scene="send" data-bottom="Uploading">Uploading</button> <button data-scene="send" data-top="Sending form data" data-bottom="Please wait">Sending form data</button></div></div><div><h3>Other</h3><div class="demo-buttons"><button id="btn" aria-pressed="false">Spinner</button> <button id="btn-loader" aria-pressed="false">Custom texts</button> <button id="btn-loader-scene-hide" class="demo-quiet">Hide loader</button></div></div></div></section></section></main><script type="module" src="idvc.js"></script><script type="module" src="langs.js"></script><script type="module">import IDVC, { prepareRequestDataForDiveApi } from './idvc.js'
18
164
  const keys = {
19
165
  '10.105.74.121': 'eyJwZGY0MTdrZXkiOiJXYkZZY2RrdTJOMWdlVXJIb1hZL2RhQW1QUERKZ2NGRTRDODJqazhzYkczaWJoekM0dXV3SnJ4dWZtOE5YcFNBWDJoREhYRXQvMVl4SVhPRGNhOUVHQ0w1cUFPdllQemp2T2hhTzZzcXAvc1lHWGxBTytnZ0NVSkthRm04MTFnQThpajE0RXhrY013NzNLMEwzcEhwMTlvYjdsUUpFSE9xbG83dTNvTjRNczQ9IiwiaW1hZ2VQcm9jZXNzaW5nS2V5Ijoiam1EWWVVMkhqOFhVVWJEdFlPcHRkLzZobnFEcEFQaldhVlpWOG9qOGU3WUVoQ3Q1L3ovNlVlWnRkMDhDWjduaXhrQ1d3SlVpUUllbC9rRHI4RGFxeXpLVnRtZzNRbnROcHZBZnFjQ2ZmeGpBTk1SeVkvbjJWQjloSE02MzlWcG03dktsNWxRQWRJQlFMZFUydGdBcHhYVy9WK3JFa1pIVDVKT1FMdzA0WXBnPSIsInRyYWNrU3RyaW5nUGFyc2VyS2V5IjoiSGlBaUt4UER6amRtUjFSRUZJR0oxUEpmR0tleFl2Z2ZFS3dtVXMwcDVxdWswL1pzbGNiazRXaGt0amFxc0FiYnRyYllZeVB5b21mRm1neFVkLzdHVnJtdFJPTiszZEZZcFk5NHlNMEtSY2dpd3Nrdm5PaGlZZjJubnZ1U0REMGhUWkZKWlh1NDNJNDQxR0U5OHh0d3JJdGN2aVQ1SWJ6bXJOTS9OYlRKK2Z3PSIsImNvbW1vbkxpY2Vuc2VLZXkiOiJkaTdLYmN6T3gzUjA2MTNxNENUaUIrYS9iY2gvcEhuemlucmVUK0JtOXBrcERod1EvbXUyM0dJOFdnOWtkcHRPR3VJbDRmWHpCd214enRZN1hZclg5YVU0SWxoNHhRQUgzY0x6cHJnb0ZyY2EyZjllZ3RJb0NiYkJKcnRWZFVXdUVmZE15NkRMSVA4WG04ZHJjdDFFc29XYnE5dHB3OFh5Ukt4cEM4N1pIbGs9In0=',
20
166
  '10.105.74.158': 'eyJwZGY0MTdrZXkiOiIxdFAxUmlYSlx1MDAyQjZxaU0yYUFMYW1CVWNQTGdGY202Y3RVXHUwMDJCeU9OeWg1RjZ4YzdhTmFoR2dUazBzQWs5RjdEZjE2ZXlreXVZcnRJM0Jxc2pnQjZuRklickZrWWl3d3dlSGg2SENObDNGWkttTC9yUmZJc0FLc0FzMUNLMHJrVk5FS1BwdEJIQTc0TmxZNVhlajl1NnpRVms5QUxHeDdxeE1adUlvUUNvVDNqYnFNPSIsImNvbW1vbkxpY2Vuc2VLZXkiOiJuelhkTnRpc0NFXHUwMDJCNTNJODR4dDh3eEZwcGV4TU5QMW54MjdqcnFxNDJvVzRqZ05jZFYwUzFscGM2OGZcdTAwMkIxdlFNVGtlTWR5SjZrNjRRbG80c0prbVpnM3VEUFx1MDAyQjFvWVZ0eVFZODNrdHlKaXZNNE5pLzkxbURBNS9sQURUMEVjY2phUnpaRXZHNGU4RGE5SU1cdTAwMkI5TktFejZlWk5KN20xd3BYaWx0Ny9CdEZzT0VoUT0iLCJpbWFnZVByb2Nlc3NpbmdLZXkiOiIyeW9JWnlpa1hRTHBjdmU2ZjN5YlF6cFo3cGJYR0FjZk9udVVvc3oxbWhUdDlmSW5RcldQaXVta0NlVTg5d2pwaUxoZDJnVWlDSHVKNng5ZnRBZzNNXHUwMDJCV09LYzVSVnhIdm56enl3WGpDb2V2cEQwS05mZ0tCRjQyalRJNXlOQmVFTkpzOVV0MVhPRzdFa1FpdUJWeGtBSEo3TVhuNU1ESmg1S0J1QkVRbWIwMD0iLCJ0cmFja1N0cmluZ1BhcnNlcktleSI6IjFQVmpjeUE3eC9Ia1V5QW55dHdHZEZjZWZNMG5XV0RaYnVSb0VlTXNhOU01L2xqeVBjdHlVNmd5c0NhV0IwWVBQSDFRbm5RQ0xiYktIRER3VGE3TGxmVHNJOUY3emJsOW5ZVGVwbzM1ZE81aWhcdTAwMkJcdTAwMkI4VUhwZWFsaDFQUGJWMzBwL1Rwd1MyQTJqZjVvWnVpS2V4U2haYlx1MDAyQlZcdTAwMkJ1MUdtTk50cTV6YzNJNnNFVWp3PSIsImlPU01SWkRldGVjdG9yS2V5IjoibHZKNkVMM0Q0ZWdNMVpLTWh5VEJhdXlBeDNkNmViL2JWYWt1L1h2a1lFdFc1b3N4MVYxWlJMZUhtcW5TV3JtUUF2Smp1N3dnTnNNN1dWNFBKNEtvT3NHeU5QbjdxdTZhWDZFemI0ejIzMGVuUVpDWFBRVjBaTEVpcEtGUkZqZEc4bS9qU1dObmlFSW1Pd2ZPbko0VXBIXHUwMDJCRzNvOTVnbHQ0MjdDT2tDRUpsTVU9IiwiaU9TUERGRGV0ZWN0b3JLZXkiOiIxQjBLLkIxUDBNNU8uRzdJNEQuRTFFNUg4T3pCZU9qTiJ9',
@@ -207,9 +353,10 @@
207
353
  let videoCapturingComponent = new IDVC(config);
208
354
  let k = false
209
355
  let c = false
210
- document.getElementById('btn').addEventListener('click', () => {
356
+ document.getElementById('btn').addEventListener('click', (e) => {
211
357
  k = !k
212
358
  videoCapturingComponent.showSpinner(k)
359
+ e.currentTarget.setAttribute('aria-pressed', String(k))
213
360
  })
214
361
  document.getElementById('btn-reconfig').addEventListener('click', () => {
215
362
  videoCapturingComponent.reloadComponent(newConfig)
@@ -217,10 +364,31 @@
217
364
  document.getElementById('btn-reconfig1').addEventListener('click', () => {
218
365
  videoCapturingComponent.reloadComponent(newConfig1)
219
366
  })
220
- document.getElementById('btn-loader').addEventListener('click', () => {
367
+ document.getElementById('btn-loader').addEventListener('click', (e) => {
221
368
  c = !c
222
- videoCapturingComponent.showLoader(c, '<div>lupa <br> pupa</div>', 'peepo pepe')
369
+ videoCapturingComponent.showLoader(c, 'The bottom text set by showLoader', 'Custom top text')
370
+ e.currentTarget.setAttribute('aria-pressed', String(c))
223
371
  })
372
+ let isSceneLoaderShown = false
373
+ const sceneButtons = document.querySelectorAll('#loader-scenes-container [data-scene]')
374
+ const hideSceneLoader = () => {
375
+ if (isSceneLoaderShown) {
376
+ videoCapturingComponent.showLoader(false)
377
+ isSceneLoaderShown = false
378
+ }
379
+ sceneButtons.forEach((button) => button.setAttribute('aria-pressed', 'false'))
380
+ }
381
+ sceneButtons.forEach((button) => {
382
+ button.setAttribute('aria-pressed', 'false')
383
+ button.addEventListener('click', () => {
384
+ const { scene, top = '', bottom = '' } = button.dataset
385
+ hideSceneLoader()
386
+ videoCapturingComponent.showLoader(true, bottom, top, { scene })
387
+ isSceneLoaderShown = true
388
+ button.setAttribute('aria-pressed', 'true')
389
+ })
390
+ })
391
+ document.getElementById('btn-loader-scene-hide').addEventListener('click', hideSceneLoader)
224
392
  document.getElementById('btn-reload').addEventListener('click', () => {
225
393
  videoCapturingComponent.reloadComponent(config);
226
394
  })
@@ -244,12 +412,13 @@
244
412
  },
245
413
  ]);
246
414
  })
247
- document.getElementById('btn-change-en').addEventListener('click', () => {
248
- videoCapturingComponent.changeLanguage('en');
249
- })
250
- document.getElementById('btn-change-es').addEventListener('click', () => {
251
- videoCapturingComponent.changeLanguage('es');
252
- })
415
+ const setLanguage = (language) => {
416
+ videoCapturingComponent.changeLanguage(language);
417
+ document.getElementById('btn-change-en').setAttribute('aria-pressed', String(language === 'en'))
418
+ document.getElementById('btn-change-es').setAttribute('aria-pressed', String(language === 'es'))
419
+ }
420
+ document.getElementById('btn-change-en').addEventListener('click', () => setLanguage('en'))
421
+ document.getElementById('btn-change-es').addEventListener('click', () => setLanguage('es'))
253
422
  document.getElementById('btn-unmount').addEventListener('click', () => {
254
423
  const el = document.getElementById(config.el);
255
424
  el.remove();
@@ -1 +1 @@
1
- (self.webpackChunk_idscan_idvc2=self.webpackChunk_idscan_idvc2||[]).push([[300],{3698(e,t,r){r.r(t),r.d(t,{default:()=>oe});var n=r(2639),i=r(5909),o=r(4955),s=r(6367),c=r(6248);function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}var h=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),u(this,"realFace",void 0),u(this,"moveToCenter",void 0),u(this,"noFace",void 0),u(this,"perimeter",void 0),u(this,"distance",void 0),u(this,"baseSizes",void 0),u(this,"lowFacePerimeterPercent",void 0),u(this,"lowFacePerimeterPercentDefault",void 0),u(this,"correctDirection",void 0),u(this,"direction",void 0),u(this,"turnDistances",void 0),u(this,"prediction",void 0),u(this,"faceFailCount",void 0),u(this,"faceSuccessCount",void 0),u(this,"res",void 0),u(this,"geometry",void 0),this.faceFailCount=0,this.faceSuccessCount=0,this.realFace=!1,this.moveToCenter=!1,this.noFace=!1,this.perimeter=0,this.distance=0,this.baseSizes={width:320,height:320},this.res={status:!1,cancel:!1,touch:!1,image:null,type:"VolumeFace"},this.lowFacePerimeterPercent=27,this.lowFacePerimeterPercentDefault=27,this.correctDirection=!1,this.direction=null,this.turnDistances={leftRightPercents:0,isLeft:!1}}var t,r,n;return t=e,r=[{key:"init",value:function(e){this.geometry=e}},{key:"result",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=l(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){u(e,t,r[t])})}return e}({drawPoints:this.prediction?this.prediction.keypointList:[]},this.res),{status:e,faceFailCount:this.faceFailCount,faceSuccessCount:this.faceSuccessCount,perimeter:this.perimeter,realFace:this.realFace,moveToCenter:this.moveToCenter,distance:this.distance,noFace:this.noFace,prediction:this.prediction,isCorrectDirection:this.correctDirection});return e&&(this.faceSuccessCount=0,this.faceFailCount=0,this.realFace=!1),t}},{key:"noPredictions",value:function(){return this.perimeter=0,this.distance=0,this.prediction=null,this.moveToCenter=!1,this.faceFailCount+=1,this.realFace=!1,this.faceSuccessCount=0,this.noFace=!0,this.res.status=!1,this.result(!1)}},{key:"processFace",value:function(e,t){return this.perimeter=0,this.moveToCenter=!1,this.noFace=!1,this.distance=0,this.baseSizes.width=t instanceof HTMLVideoElement?t.videoWidth:t.width,this.baseSizes.height=t instanceof HTMLVideoElement?t.videoHeight:t.height,this.prediction=e,this.processPrediction(),this.faceSuccessCount>3&&e.score>15?this.result(!0):this.result(!1)}},{key:"dropSuccess",value:function(){this.lowFacePerimeterPercent=this.lowFacePerimeterPercentDefault,this.faceSuccessCount=0,this.realFace=!1}},{key:"getDirection",value:function(){return this.direction}},{key:"isCorrectKeyPointsDistances",value:function(e){return e.eyeDistance>35&&e.earDistance>75}},{key:"setDirection",value:function(e){this.direction=e}},{key:"getMf",value:function(e){return[Math.abs((this.baseSizes.width/2-e[0])*(100/this.baseSizes.width)),Math.abs((this.baseSizes.height/2-e[1])*(100/this.baseSizes.height))]}},{key:"processBadPerimeter",value:function(e){e<=this.lowFacePerimeterPercent?this.perimeter=1:e>=100&&(this.perimeter=2)}},{key:"main",value:function(e,t,r){var n;e>this.lowFacePerimeterPercent&&e<100?t[0]<=15&&t[1]<=15&&this.isCorrectKeyPointsDistances(r)?((null===(n=o.A.currentStepObj)||void 0===n?void 0:n.shouldRecordMultiImages)&&!c.UI.mainScreen.videoWrapper.canvasWrapper.isStartedRecord&&c.UI.mainScreen.videoWrapper.canvasWrapper.toggleRecordMultiImages(o.A.currentStepObj,o.A.isStarted),this.lowFacePerimeterPercent=this.lowFacePerimeterPercentDefault-7,this.calculateDistance(),this.processDistance(),this.processRealFace()):(this.dropSuccess(),this.moveToCenter=!0):(this.dropSuccess(),this.processBadPerimeter(e))}},{key:"processRealFace",value:function(){this.realFace&&(this.distance>75?this.faceSuccessCount+=1:this.faceSuccessCount=0)}},{key:"calculateFace",value:function(){var e=this.prediction.bbox,t=e.x,r=e.y,n=e.w,i=e.h,o=[t,r],s=[t+n,r+i],c=(n+i)/(this.baseSizes.width+this.baseSizes.height)*100,a=this.geometry.rectCenter(o,s);return{perimeter:c,mf:this.getMf(a)}}},{key:"calculateKeyPointsDistances",value:function(){return{eyeDistance:~~this.geometry.distanceBetweenPointsX(this.prediction.face.leftEye,this.prediction.face.rightEye),earDistance:~~this.geometry.distanceBetweenPointsX(this.prediction.face.leftEar,this.prediction.face.rightEar)}}},{key:"processPrediction",value:function(){var e=this.calculateFace(),t=e.perimeter,r=e.mf,n=this.calculateKeyPointsDistances();this.main(t,r,n)}},{key:"processDistance",value:function(){this.correctDirection=this.direction===s.m.LEFT?this.turnDistances.isLeft:!this.turnDistances.isLeft,this.distance=this.turnDistances.leftRightPercents,this.correctDirection&&this.distance<=50&&(this.realFace=!0)}},{key:"calculateTurn",value:function(e,t){var r=Math.min(e,t),n=Math.max(e,t);return Math.trunc(r/n*100)}},{key:"calculateDistance",value:function(){var e=~~this.geometry.distanceBetweenPointsX(this.prediction.face.rightEye,this.prediction.face.nose),t=~~this.geometry.distanceBetweenPointsX(this.prediction.face.leftEye,this.prediction.face.nose),r=this.calculateTurn(e,t),n=t>=e;this.turnDistances={leftRightPercents:r,isLeft:n}}},{key:"allocate",value:function(){}}],r&&a(t.prototype,r),n&&a(t,n),e}();const f=h;var p=r(7734),y=r(2842),d=r(4703),v=r(2933),b=r(3814);function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e,t,r,n,i,o,s){try{var c=e[o](s),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,i)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){g(o,n,i,s,c,"next",e)}function c(e){g(o,n,i,s,c,"throw",e)}s(void 0)})}}function P(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function k(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}function S(e,t){return!t||"object"!=((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)&&"function"!=typeof t?w(e):t;var r}function L(e,t){return L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},L(e,t)}function O(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=x(e);if(t){var i=x(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return S(this,r)}}function F(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var D=[[16,16],[8,8]],M=[2,6],C=128,E=128,j=[1,E,C,3],A="Identity:0",z="Identity_2:0",B=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&L(e,t)}(o,e);var t,r,n,i=O(o);function o(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:y.K.WASM,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),k(w(e=i.call(this,t,r,n)),"anchorList",new Array(896)),k(w(e),"scoreList",new Float32Array(896)),k(w(e),"regressorList",new Float32Array(14336)),k(w(e),"thresholdLogit",1.0986122886681096),k(w(e),"bBoxList",[]),k(w(e),"keyPoints",Array(6)),k(w(e),"origSize",{height:0,width:0}),e.createAnchor(),e}return t=o,(r=[{key:"createAnchor",value:function(){for(var e=0,t=0;t<D.length;t+=1)for(var r=D[t][0],n=D[t][1],i=128/r,o=128/n,s=M[t],c=0,a=0,u=0;u<n;u+=1){c=o*(u+.5);for(var l=0;l<r;l+=1){a=i*(l+.5);for(var h=0;h<s;h+=1)this.anchorList[e]=[a,c],e+=1}}}},{key:"processImage",value:function(e){var t=this;return m(function(){var r;return F(this,function(n){return t.getBoundingBoxes({scaleX:e.width/C,scaleY:e.height/E}),(r=t.nms())?(t.fillKeyPoints({bbox:r,crop:e}),[2,{bbox:r,keyPoints:t.keyPoints,face:{leftEye:t.keyPoints[0],rightEye:t.keyPoints[1],nose:t.keyPoints[2],mouth:t.keyPoints[3],leftEar:t.keyPoints[4],rightEar:t.keyPoints[5]}}]):[2,!1]})})()}},{key:"predict",value:function(e){var t=this;return m(function(){var r,n;return F(this,function(i){switch(i.label){case 0:return r=new p.qY("float32",e,j),[4,t.session.run(k({},"input:0",r))];case 1:return n=i.sent(),t.scoreList.set(n[A].data,0),t.scoreList.set(n["Identity_1:0"].data,n[A].size),t.regressorList.set(n[z].data,0),t.regressorList.set(n["Identity_3:0"].data,n[z].size),[2]}})})()}},{key:"predictFromImage",value:function(e,t){var r=this;return m(function(){var n,i,o,s,c,a;return F(this,function(u){switch(u.label){case 0:if(!r.session)throw new Error("ONNX session isn't started");return n=r.createSrc(e,"angles-input-canvas"),i=t||(0,v.Nw)("angles-canvas",{width:C,height:E}),r.origSize.width=n instanceof HTMLVideoElement?n.videoWidth:n.width,r.origSize.height=n instanceof HTMLVideoElement?n.videoHeight:n.height,o=(0,v.CA)(n,i),s=o.resized,c=o.crop,a=(0,b.Js)(s,b.Qg.HALF),[4,r.predict(a)];case 1:return u.sent(),[2,r.processImage(c)]}})})()}},{key:"getBoundingBoxes",value:function(e){var t=e.scaleX,r=e.scaleY,n=this;this.bBoxList.length=0,this.anchorList.forEach(function(e,i){if(n.scoreList[i]>n.thresholdLogit){var o=16*i,s=n.regressorList[o]+e[0],c=n.regressorList[o+1]+e[1],a=n.regressorList[o+2],u=n.regressorList[o+3],l={classId:i,label:"",score:+n.scoreList[i],x:~~((s-a/2)*t),y:~~((c-u/2)*r),w:~~(a*t),h:~~(u*r)};n.bBoxList.push(l)}})}},{key:"calculateIoU",value:function(e,t){var r=Math.max(e.x,t.x),n=Math.max(e.y,t.y),i=Math.min(e.x+e.w,t.x+t.w),o=Math.min(e.y+e.h,t.y+t.h);if(i<r||o<n)return 0;var s=(i-r)*(o-n);return s/(e.w*e.h+t.w*t.h-s)}},{key:"nms",value:function(){var e=[];this.bBoxList.sort(function(e,t){return t.score-e.score});for(var t=new Array(this.bBoxList.length).fill(!1),r=0;r<this.bBoxList.length;r+=1){var n=[];if(!t[r]){n.push(this.bBoxList[r]);for(var i=r+1;i<this.bBoxList.length;i+=1)t[i]||this.calculateIoU(this.bBoxList[r],this.bBoxList[i])>.5&&(n.push(this.bBoxList[i]),t[i]=!0);e.push(n[0])}}return e[0]}},{key:"fixInScreen",value:function(e){e.x=Math.max(0,e.x),e.y=Math.max(0,e.y),e.w=Math.min(this.origSize.width-e.x,e.w),e.h=Math.min(this.origSize.height-e.y,e.h)}},{key:"fillKeyPoints",value:function(e){var t=e.bbox,r=e.crop,n=t.classId;t.classId=0,t.label="FACE",t.x+=r.x,t.y+=r.y,this.fixInScreen(t);for(var i=16*n,o=0;o<6;o+=1){var s=this.regressorList[i+4+2*o]+this.anchorList[n][0],c=this.regressorList[i+4+2*o+1]+this.anchorList[n][1];this.keyPoints[o]=[~~(s*r.width/C+r.x),~~(c*r.height/E+r.y)]}}}])&&P(t.prototype,r),n&&P(t,n),o}(d.A);function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function T(e,t,r,n,i,o,s){try{var c=e[o](s),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,i)}function I(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){T(o,n,i,s,c,"next",e)}function c(e){T(o,n,i,s,c,"throw",e)}s(void 0)})}}function R(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function W(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function H(e){return H=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},H(e)}function K(e,t){return!t||"object"!=((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)&&"function"!=typeof t?_(e):t;var r}function X(e,t){return X=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},X(e,t)}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=H(e);if(t){var i=H(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return K(this,r)}}function V(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var U=[1,192,192,3],G=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&X(e,t)}(o,e);var t,r,n,i=N(o);function o(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:y.K.WASM,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),W(_(e=i.call(this,t,r,n)),"origSize",{width:0,height:0}),W(_(e),"crop",{x:0,y:0,width:0,height:0}),W(_(e),"landmarkList",new Float32Array(1404)),W(_(e),"keypointList",new Array(468)),e}return t=o,(r=[{key:"preProcess",value:function(e){var t=~~(e.x+e.w/2),r=~~(e.y+e.h/2),n=~~(1.7*Math.max(e.w,e.h));this.crop.x=~~Math.max(0,t-n/2),this.crop.y=~~Math.max(0,r-n/2),this.crop.width=~~Math.min(n,this.origSize.width-this.crop.x),this.crop.height=~~Math.min(n,this.origSize.height-this.crop.y)}},{key:"predict",value:function(e){var t=this;return I(function(){var r,n,i,o,s,c;return V(this,function(a){switch(a.label){case 0:return r=new p.qY("float32",e,U),n=W({},"input_1",r),[4,t.session.run(n)];case 1:for(i=a.sent(),t.landmarkList.set(i.conv2d_20.data,0),o=t.crop.width/192,s=t.crop.height/192,c=0;c<468;c+=1)t.keypointList[c]=[~~(t.landmarkList[3*c+0]*o+.5+t.crop.x),~~(t.landmarkList[3*c+1]*s+.5+t.crop.y)];return[2,{score:i.conv2d_30.data[0],keypointList:t.keypointList}]}})})()}},{key:"prepareMesh",value:function(e,t){var r=t.getContext("2d");return r.drawImage(e,this.crop.x,this.crop.y,this.crop.width,this.crop.height,0,0,t.width,t.height),r.getImageData(0,0,t.width,t.height)}},{key:"predictFromImage",value:function(e,t){var r=this;return I(function(){var n,i,o;return V(this,function(s){if(!r.session)throw new Error("ONNX session isn't started");return n=r.createSrc(e,"mesh-face-input-canvasWrapper"),i=t||(0,v.Nw)("mesh-face-canvasWrapper",{width:192,height:192}),r.origSize.width=n instanceof HTMLVideoElement?n.videoWidth:n.width,r.origSize.height=n instanceof HTMLVideoElement?n.videoHeight:n.height,o=(0,b.Js)(r.prepareMesh(n,i),b.Qg.HALF),[2,r.predict(o)]})})()}}])&&R(t.prototype,r),n&&R(t,n),o}(d.A),Y=r(8200);function J(e,t,r,n,i,o,s){try{var c=e[o](s),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,i)}function q(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){J(o,n,i,s,c,"next",e)}function c(e){J(o,n,i,s,c,"throw",e)}s(void 0)})}}function Q(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var Z,$=(Z=q(function(){var e;return Q(this,function(t){return e=new f,n.A.setModule("module","face",e),[2]})}),function(){return Z.apply(this,arguments)}),ee=function(){var e=q(function(){var e,t,r,s,c;return Q(this,function(a){switch(a.label){case 0:return e=Y.f.simdSupport?y.K.WASM:y.K.WEBGL,"ios"===o.A.browser.os.toLowerCase()&&(t=o.A.browser.version,r=+t.split(".").pop(),Number.isFinite(r)&&r<16&&(e=y.K.WASM)),s=new B("".concat(i.n.ey),e,o.A.networkUrl),c=new G("".concat(i.n.w0),e,o.A.networkUrl),n.A.setModule("model","blazeFace",s),n.A.setModule("model","meshFace",c),[4,$()];case 1:return a.sent(),[2,[s.initialize.bind(s),c.initialize.bind(c)]]}})});return function(){return e.apply(this,arguments)}}();const te=ee;function re(e,t,r,n,i,o,s){try{var c=e[o](s),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,i)}function ne(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var ie=function(){var e,t=(e=function(){return ne(this,function(e){switch(e.label){case 0:return[4,te()];case 1:return[2,e.sent()]}})},function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){re(o,n,i,s,c,"next",e)}function c(e){re(o,n,i,s,c,"throw",e)}s(void 0)})});return function(){return t.apply(this,arguments)}}();const oe=ie},5909(e){e.exports=JSON.parse('{"n":{"EX":"mrz03032023.onnx","w0":"faceLandmark03032023.onnx","ey":"faceDetection03032023.onnx","sh":"yoloFaceFingers.onnx"}}')}}]);
1
+ (self.webpackChunk_idscan_idvc2=self.webpackChunk_idscan_idvc2||[]).push([[300],{3698(e,t,r){r.r(t),r.d(t,{default:()=>oe});var n=r(2639),i=r(5909),o=r(4955),s=r(6367),c=r(7746);function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}var h=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),u(this,"realFace",void 0),u(this,"moveToCenter",void 0),u(this,"noFace",void 0),u(this,"perimeter",void 0),u(this,"distance",void 0),u(this,"baseSizes",void 0),u(this,"lowFacePerimeterPercent",void 0),u(this,"lowFacePerimeterPercentDefault",void 0),u(this,"correctDirection",void 0),u(this,"direction",void 0),u(this,"turnDistances",void 0),u(this,"prediction",void 0),u(this,"faceFailCount",void 0),u(this,"faceSuccessCount",void 0),u(this,"res",void 0),u(this,"geometry",void 0),this.faceFailCount=0,this.faceSuccessCount=0,this.realFace=!1,this.moveToCenter=!1,this.noFace=!1,this.perimeter=0,this.distance=0,this.baseSizes={width:320,height:320},this.res={status:!1,cancel:!1,touch:!1,image:null,type:"VolumeFace"},this.lowFacePerimeterPercent=27,this.lowFacePerimeterPercentDefault=27,this.correctDirection=!1,this.direction=null,this.turnDistances={leftRightPercents:0,isLeft:!1}}var t,r,n;return t=e,r=[{key:"init",value:function(e){this.geometry=e}},{key:"result",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=l(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){u(e,t,r[t])})}return e}({drawPoints:this.prediction?this.prediction.keypointList:[]},this.res),{status:e,faceFailCount:this.faceFailCount,faceSuccessCount:this.faceSuccessCount,perimeter:this.perimeter,realFace:this.realFace,moveToCenter:this.moveToCenter,distance:this.distance,noFace:this.noFace,prediction:this.prediction,isCorrectDirection:this.correctDirection});return e&&(this.faceSuccessCount=0,this.faceFailCount=0,this.realFace=!1),t}},{key:"noPredictions",value:function(){return this.perimeter=0,this.distance=0,this.prediction=null,this.moveToCenter=!1,this.faceFailCount+=1,this.realFace=!1,this.faceSuccessCount=0,this.noFace=!0,this.res.status=!1,this.result(!1)}},{key:"processFace",value:function(e,t){return this.perimeter=0,this.moveToCenter=!1,this.noFace=!1,this.distance=0,this.baseSizes.width=t instanceof HTMLVideoElement?t.videoWidth:t.width,this.baseSizes.height=t instanceof HTMLVideoElement?t.videoHeight:t.height,this.prediction=e,this.processPrediction(),this.faceSuccessCount>3&&e.score>15?this.result(!0):this.result(!1)}},{key:"dropSuccess",value:function(){this.lowFacePerimeterPercent=this.lowFacePerimeterPercentDefault,this.faceSuccessCount=0,this.realFace=!1}},{key:"getDirection",value:function(){return this.direction}},{key:"isCorrectKeyPointsDistances",value:function(e){return e.eyeDistance>35&&e.earDistance>75}},{key:"setDirection",value:function(e){this.direction=e}},{key:"getMf",value:function(e){return[Math.abs((this.baseSizes.width/2-e[0])*(100/this.baseSizes.width)),Math.abs((this.baseSizes.height/2-e[1])*(100/this.baseSizes.height))]}},{key:"processBadPerimeter",value:function(e){e<=this.lowFacePerimeterPercent?this.perimeter=1:e>=100&&(this.perimeter=2)}},{key:"main",value:function(e,t,r){var n;e>this.lowFacePerimeterPercent&&e<100?t[0]<=15&&t[1]<=15&&this.isCorrectKeyPointsDistances(r)?((null===(n=o.A.currentStepObj)||void 0===n?void 0:n.shouldRecordMultiImages)&&!c.UI.mainScreen.videoWrapper.canvasWrapper.isStartedRecord&&c.UI.mainScreen.videoWrapper.canvasWrapper.toggleRecordMultiImages(o.A.currentStepObj,o.A.isStarted),this.lowFacePerimeterPercent=this.lowFacePerimeterPercentDefault-7,this.calculateDistance(),this.processDistance(),this.processRealFace()):(this.dropSuccess(),this.moveToCenter=!0):(this.dropSuccess(),this.processBadPerimeter(e))}},{key:"processRealFace",value:function(){this.realFace&&(this.distance>75?this.faceSuccessCount+=1:this.faceSuccessCount=0)}},{key:"calculateFace",value:function(){var e=this.prediction.bbox,t=e.x,r=e.y,n=e.w,i=e.h,o=[t,r],s=[t+n,r+i],c=(n+i)/(this.baseSizes.width+this.baseSizes.height)*100,a=this.geometry.rectCenter(o,s);return{perimeter:c,mf:this.getMf(a)}}},{key:"calculateKeyPointsDistances",value:function(){return{eyeDistance:~~this.geometry.distanceBetweenPointsX(this.prediction.face.leftEye,this.prediction.face.rightEye),earDistance:~~this.geometry.distanceBetweenPointsX(this.prediction.face.leftEar,this.prediction.face.rightEar)}}},{key:"processPrediction",value:function(){var e=this.calculateFace(),t=e.perimeter,r=e.mf,n=this.calculateKeyPointsDistances();this.main(t,r,n)}},{key:"processDistance",value:function(){this.correctDirection=this.direction===s.m.LEFT?this.turnDistances.isLeft:!this.turnDistances.isLeft,this.distance=this.turnDistances.leftRightPercents,this.correctDirection&&this.distance<=50&&(this.realFace=!0)}},{key:"calculateTurn",value:function(e,t){var r=Math.min(e,t),n=Math.max(e,t);return Math.trunc(r/n*100)}},{key:"calculateDistance",value:function(){var e=~~this.geometry.distanceBetweenPointsX(this.prediction.face.rightEye,this.prediction.face.nose),t=~~this.geometry.distanceBetweenPointsX(this.prediction.face.leftEye,this.prediction.face.nose),r=this.calculateTurn(e,t),n=t>=e;this.turnDistances={leftRightPercents:r,isLeft:n}}},{key:"allocate",value:function(){}}],r&&a(t.prototype,r),n&&a(t,n),e}();const f=h;var p=r(7734),y=r(2842),d=r(4703),v=r(2933),b=r(3814);function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e,t,r,n,i,o,s){try{var c=e[o](s),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,i)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){g(o,n,i,s,c,"next",e)}function c(e){g(o,n,i,s,c,"throw",e)}s(void 0)})}}function P(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function k(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}function S(e,t){return!t||"object"!=((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)&&"function"!=typeof t?w(e):t;var r}function L(e,t){return L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},L(e,t)}function O(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=x(e);if(t){var i=x(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return S(this,r)}}function F(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var D=[[16,16],[8,8]],M=[2,6],C=128,E=128,j=[1,E,C,3],A="Identity:0",z="Identity_2:0",B=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&L(e,t)}(o,e);var t,r,n,i=O(o);function o(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:y.K.WASM,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),k(w(e=i.call(this,t,r,n)),"anchorList",new Array(896)),k(w(e),"scoreList",new Float32Array(896)),k(w(e),"regressorList",new Float32Array(14336)),k(w(e),"thresholdLogit",1.0986122886681096),k(w(e),"bBoxList",[]),k(w(e),"keyPoints",Array(6)),k(w(e),"origSize",{height:0,width:0}),e.createAnchor(),e}return t=o,(r=[{key:"createAnchor",value:function(){for(var e=0,t=0;t<D.length;t+=1)for(var r=D[t][0],n=D[t][1],i=128/r,o=128/n,s=M[t],c=0,a=0,u=0;u<n;u+=1){c=o*(u+.5);for(var l=0;l<r;l+=1){a=i*(l+.5);for(var h=0;h<s;h+=1)this.anchorList[e]=[a,c],e+=1}}}},{key:"processImage",value:function(e){var t=this;return m(function(){var r;return F(this,function(n){return t.getBoundingBoxes({scaleX:e.width/C,scaleY:e.height/E}),(r=t.nms())?(t.fillKeyPoints({bbox:r,crop:e}),[2,{bbox:r,keyPoints:t.keyPoints,face:{leftEye:t.keyPoints[0],rightEye:t.keyPoints[1],nose:t.keyPoints[2],mouth:t.keyPoints[3],leftEar:t.keyPoints[4],rightEar:t.keyPoints[5]}}]):[2,!1]})})()}},{key:"predict",value:function(e){var t=this;return m(function(){var r,n;return F(this,function(i){switch(i.label){case 0:return r=new p.qY("float32",e,j),[4,t.session.run(k({},"input:0",r))];case 1:return n=i.sent(),t.scoreList.set(n[A].data,0),t.scoreList.set(n["Identity_1:0"].data,n[A].size),t.regressorList.set(n[z].data,0),t.regressorList.set(n["Identity_3:0"].data,n[z].size),[2]}})})()}},{key:"predictFromImage",value:function(e,t){var r=this;return m(function(){var n,i,o,s,c,a;return F(this,function(u){switch(u.label){case 0:if(!r.session)throw new Error("ONNX session isn't started");return n=r.createSrc(e,"angles-input-canvas"),i=t||(0,v.Nw)("angles-canvas",{width:C,height:E}),r.origSize.width=n instanceof HTMLVideoElement?n.videoWidth:n.width,r.origSize.height=n instanceof HTMLVideoElement?n.videoHeight:n.height,o=(0,v.CA)(n,i),s=o.resized,c=o.crop,a=(0,b.Js)(s,b.Qg.HALF),[4,r.predict(a)];case 1:return u.sent(),[2,r.processImage(c)]}})})()}},{key:"getBoundingBoxes",value:function(e){var t=e.scaleX,r=e.scaleY,n=this;this.bBoxList.length=0,this.anchorList.forEach(function(e,i){if(n.scoreList[i]>n.thresholdLogit){var o=16*i,s=n.regressorList[o]+e[0],c=n.regressorList[o+1]+e[1],a=n.regressorList[o+2],u=n.regressorList[o+3],l={classId:i,label:"",score:+n.scoreList[i],x:~~((s-a/2)*t),y:~~((c-u/2)*r),w:~~(a*t),h:~~(u*r)};n.bBoxList.push(l)}})}},{key:"calculateIoU",value:function(e,t){var r=Math.max(e.x,t.x),n=Math.max(e.y,t.y),i=Math.min(e.x+e.w,t.x+t.w),o=Math.min(e.y+e.h,t.y+t.h);if(i<r||o<n)return 0;var s=(i-r)*(o-n);return s/(e.w*e.h+t.w*t.h-s)}},{key:"nms",value:function(){var e=[];this.bBoxList.sort(function(e,t){return t.score-e.score});for(var t=new Array(this.bBoxList.length).fill(!1),r=0;r<this.bBoxList.length;r+=1){var n=[];if(!t[r]){n.push(this.bBoxList[r]);for(var i=r+1;i<this.bBoxList.length;i+=1)t[i]||this.calculateIoU(this.bBoxList[r],this.bBoxList[i])>.5&&(n.push(this.bBoxList[i]),t[i]=!0);e.push(n[0])}}return e[0]}},{key:"fixInScreen",value:function(e){e.x=Math.max(0,e.x),e.y=Math.max(0,e.y),e.w=Math.min(this.origSize.width-e.x,e.w),e.h=Math.min(this.origSize.height-e.y,e.h)}},{key:"fillKeyPoints",value:function(e){var t=e.bbox,r=e.crop,n=t.classId;t.classId=0,t.label="FACE",t.x+=r.x,t.y+=r.y,this.fixInScreen(t);for(var i=16*n,o=0;o<6;o+=1){var s=this.regressorList[i+4+2*o]+this.anchorList[n][0],c=this.regressorList[i+4+2*o+1]+this.anchorList[n][1];this.keyPoints[o]=[~~(s*r.width/C+r.x),~~(c*r.height/E+r.y)]}}}])&&P(t.prototype,r),n&&P(t,n),o}(d.A);function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function T(e,t,r,n,i,o,s){try{var c=e[o](s),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,i)}function I(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){T(o,n,i,s,c,"next",e)}function c(e){T(o,n,i,s,c,"throw",e)}s(void 0)})}}function R(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function W(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function H(e){return H=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},H(e)}function K(e,t){return!t||"object"!=((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)&&"function"!=typeof t?_(e):t;var r}function X(e,t){return X=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},X(e,t)}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=H(e);if(t){var i=H(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return K(this,r)}}function V(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var U=[1,192,192,3],G=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&X(e,t)}(o,e);var t,r,n,i=N(o);function o(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:y.K.WASM,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),W(_(e=i.call(this,t,r,n)),"origSize",{width:0,height:0}),W(_(e),"crop",{x:0,y:0,width:0,height:0}),W(_(e),"landmarkList",new Float32Array(1404)),W(_(e),"keypointList",new Array(468)),e}return t=o,(r=[{key:"preProcess",value:function(e){var t=~~(e.x+e.w/2),r=~~(e.y+e.h/2),n=~~(1.7*Math.max(e.w,e.h));this.crop.x=~~Math.max(0,t-n/2),this.crop.y=~~Math.max(0,r-n/2),this.crop.width=~~Math.min(n,this.origSize.width-this.crop.x),this.crop.height=~~Math.min(n,this.origSize.height-this.crop.y)}},{key:"predict",value:function(e){var t=this;return I(function(){var r,n,i,o,s,c;return V(this,function(a){switch(a.label){case 0:return r=new p.qY("float32",e,U),n=W({},"input_1",r),[4,t.session.run(n)];case 1:for(i=a.sent(),t.landmarkList.set(i.conv2d_20.data,0),o=t.crop.width/192,s=t.crop.height/192,c=0;c<468;c+=1)t.keypointList[c]=[~~(t.landmarkList[3*c+0]*o+.5+t.crop.x),~~(t.landmarkList[3*c+1]*s+.5+t.crop.y)];return[2,{score:i.conv2d_30.data[0],keypointList:t.keypointList}]}})})()}},{key:"prepareMesh",value:function(e,t){var r=t.getContext("2d");return r.drawImage(e,this.crop.x,this.crop.y,this.crop.width,this.crop.height,0,0,t.width,t.height),r.getImageData(0,0,t.width,t.height)}},{key:"predictFromImage",value:function(e,t){var r=this;return I(function(){var n,i,o;return V(this,function(s){if(!r.session)throw new Error("ONNX session isn't started");return n=r.createSrc(e,"mesh-face-input-canvasWrapper"),i=t||(0,v.Nw)("mesh-face-canvasWrapper",{width:192,height:192}),r.origSize.width=n instanceof HTMLVideoElement?n.videoWidth:n.width,r.origSize.height=n instanceof HTMLVideoElement?n.videoHeight:n.height,o=(0,b.Js)(r.prepareMesh(n,i),b.Qg.HALF),[2,r.predict(o)]})})()}}])&&R(t.prototype,r),n&&R(t,n),o}(d.A),Y=r(8200);function J(e,t,r,n,i,o,s){try{var c=e[o](s),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,i)}function q(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){J(o,n,i,s,c,"next",e)}function c(e){J(o,n,i,s,c,"throw",e)}s(void 0)})}}function Q(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var Z,$=(Z=q(function(){var e;return Q(this,function(t){return e=new f,n.A.setModule("module","face",e),[2]})}),function(){return Z.apply(this,arguments)}),ee=function(){var e=q(function(){var e,t,r,s,c;return Q(this,function(a){switch(a.label){case 0:return e=Y.f.simdSupport?y.K.WASM:y.K.WEBGL,"ios"===o.A.browser.os.toLowerCase()&&(t=o.A.browser.version,r=+t.split(".").pop(),Number.isFinite(r)&&r<16&&(e=y.K.WASM)),s=new B("".concat(i.n.ey),e,o.A.networkUrl),c=new G("".concat(i.n.w0),e,o.A.networkUrl),n.A.setModule("model","blazeFace",s),n.A.setModule("model","meshFace",c),[4,$()];case 1:return a.sent(),[2,[s.initialize.bind(s),c.initialize.bind(c)]]}})});return function(){return e.apply(this,arguments)}}();const te=ee;function re(e,t,r,n,i,o,s){try{var c=e[o](s),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,i)}function ne(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var ie=function(){var e,t=(e=function(){return ne(this,function(e){switch(e.label){case 0:return[4,te()];case 1:return[2,e.sent()]}})},function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){re(o,n,i,s,c,"next",e)}function c(e){re(o,n,i,s,c,"throw",e)}s(void 0)})});return function(){return t.apply(this,arguments)}}();const oe=ie},5909(e){e.exports=JSON.parse('{"n":{"EX":"mrz03032023.onnx","w0":"faceLandmark03032023.onnx","ey":"faceDetection03032023.onnx","sh":"yoloFaceFingers.onnx"}}')}}]);
@@ -1,5 +1,6 @@
1
1
  import { IConfig } from './modules/Config';
2
2
  import { IDocumentTypeConfig } from './modules/validator';
3
+ import type { ILoaderOptions } from './modules/Loader/loaderStack';
3
4
  declare const bl: {
4
5
  showSelectDocumentTypeModal(isFirstInit: boolean): void;
5
6
  postInit(): Promise<void>;
@@ -10,6 +11,6 @@ declare const bl: {
10
11
  resetSteps(): Promise<void>;
11
12
  updateDocumentTypes(documentTypes: IDocumentTypeConfig): Promise<any>;
12
13
  reloadComponent(config: Partial<IConfig>): Promise<void>;
13
- showLoader(val: boolean, bottomText?: string, topText?: string): void;
14
+ showLoader(val: boolean, bottomText?: string, topText?: string, options?: ILoaderOptions): void;
14
15
  };
15
16
  export default bl;
@@ -1,10 +1,12 @@
1
1
  import { IConfig } from './modules/Config';
2
2
  import type { SupportedLanguage } from './environment/langs';
3
3
  import type { IDocumentTypeConfig } from './modules/validator';
4
+ import type { ILoaderOptions } from './modules/Loader/loaderStack';
4
5
  export { prepareRequestDataForDiveApi, } from './integrations/prepareRequestDataForDiveApi';
5
6
  export type { IPrepareRequestDataForDiveApiParams } from './integrations/prepareRequestDataForDiveApi';
6
7
  export { splitTrackString } from './integrations/splitTrackString';
7
8
  export type { ITrackStringParts } from './integrations/splitTrackString';
9
+ export type { ILoaderOptions, LoaderScene } from './modules/Loader/loaderStack';
8
10
  export default class VideoCapturing {
9
11
  /**
10
12
  * Splits the captured track string (`<data>.<barcodeParams>`) into its parts.
@@ -21,8 +23,14 @@ export default class VideoCapturing {
21
23
  resetAllSteps(): void;
22
24
  reloadComponent(newConfig: Partial<IConfig>): void;
23
25
  updateDocumentTypes(documentTypes: IDocumentTypeConfig): void;
26
+ /** Shows (val = true) or hides the loader without texts, with the animation of the prepare scene. */
24
27
  showSpinner(val: any): void;
25
- showLoader(val: boolean, bottomText?: string, topText?: string): void;
28
+ /**
29
+ * Shows the loader (val = true) or hides the last shown one (val = false).
30
+ * Shows and hides are stacked: each hide removes the state of the last show, the loader stays while any is left.
31
+ * options.scene picks the animation: 'check' (default) while something is checked, 'send' while data is sent.
32
+ */
33
+ showLoader(val: boolean, bottomText?: string, topText?: string, options?: ILoaderOptions): void;
26
34
  private prepareContext;
27
35
  private init;
28
36
  }
@@ -1,4 +1,5 @@
1
1
  import { LoaderState } from '../ui/Loader/LoaderUI';
2
+ import { ILoaderOptions } from './loaderStack';
2
3
  interface ILoader {
3
4
  addState: () => void;
4
5
  showLoader: () => void;
@@ -8,15 +9,13 @@ interface ILoader {
8
9
  }
9
10
  export declare class Loader implements ILoader {
10
11
  private ui;
11
- private stats;
12
+ private stack;
12
13
  constructor(mountElement: any, state: LoaderState);
13
- addState(bottomText?: string, topText?: string): void;
14
+ addState(bottomText?: string, topText?: string, options?: ILoaderOptions): void;
14
15
  removeState(): void;
15
16
  clearState(): void;
16
17
  showLoader(): void;
17
18
  hideLoader(): void;
18
- private setText;
19
- private setVideoLoadingText;
20
19
  private statsProcessing;
21
20
  }
22
21
  export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The scene of the loader:
3
+ * - `check` (default): a curtain of light passes over the cubes and a wave of soft hops follows it,
4
+ * for waiting while something is being checked or processed;
5
+ * - `send`: the cubes fly away by diagonals and dissolve, for waiting while data is being sent or uploaded;
6
+ * - `prepare`: the cubes come down by diagonals and the grid is built, for waiting while something
7
+ * is being started or prepared (a step, the camera, the neural network).
8
+ */
9
+ export type LoaderScene = 'check' | 'send' | 'prepare';
10
+ export declare const LOADER_SCENES: readonly LoaderScene[];
11
+ export declare const DEFAULT_LOADER_SCENE: LoaderScene;
12
+ export interface ILoaderOptions {
13
+ /** The scene drawn above the texts, `check` by default. */
14
+ scene?: LoaderScene;
15
+ }
16
+ export type LoaderStat = {
17
+ bottomText: string;
18
+ topText: string;
19
+ scene: LoaderScene;
20
+ };
21
+ /** Returns the scene if it is known, otherwise the default one. */
22
+ export declare function resolveLoaderScene(scene: unknown): LoaderScene;
23
+ /**
24
+ * The states of the loader: each show pushes one, each hide pops the last one,
25
+ * and the loader draws the last pushed state while any is left.
26
+ */
27
+ export declare class LoaderStack {
28
+ private stats;
29
+ push(bottomText?: string, topText?: string, options?: ILoaderOptions | null): void;
30
+ pop(): void;
31
+ clear(): void;
32
+ get size(): number;
33
+ /** The state drawn now, undefined when the loader is hidden. */
34
+ get current(): LoaderStat | undefined;
35
+ }
@@ -1,9 +1,11 @@
1
1
  import { ComponentLit } from '../ComponentLit';
2
+ import type { LoaderScene } from '../../Loader/loaderStack';
2
3
  export type LoaderState = {
3
4
  loading: boolean;
4
5
  spinnerVisibility: boolean;
5
6
  bottomText?: string;
6
7
  topText?: string;
8
+ scene?: LoaderScene;
7
9
  };
8
10
  export declare class LoaderUI extends ComponentLit<LoaderState> {
9
11
  constructor(mountElement: HTMLElement | string, state: LoaderState, events?: any);
@@ -1,2 +1,3 @@
1
- import { TemplateResult } from 'lit-html';
2
- export declare const LoaderTemplate: (state: any) => TemplateResult;
1
+ import { type TemplateResult } from 'lit-html';
2
+ import type { LoaderState } from './LoaderUI';
3
+ export declare const LoaderTemplate: (state: LoaderState) => TemplateResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idscan/idvc2",
3
- "version": "3.12.1",
3
+ "version": "3.13.0",
4
4
  "description": "component for the capturing documents",
5
5
  "main": "dist/idvc.js",
6
6
  "types": "dist/types/idvc.d.ts",
@@ -25,6 +25,7 @@
25
25
  "minor": "npm version minor",
26
26
  "patch": "npm version patch",
27
27
  "lint": "eslint ./src",
28
+ "test": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON --test \"src/**/*.test.ts\"",
28
29
  "tsc": "tsc"
29
30
  },
30
31
  "devDependencies": {